Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/agents-a365-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@
"dependencies": {
"@azure/identity": "^4.12.1",
"@microsoft/agents-hosting": "*",
"jsonwebtoken": "^9.0.2"
"jsonwebtoken": "^9.0.2",
"pkginfo": "^0.4.1"
},
"devDependencies": {
"@eslint/js": "^9.39.1",
"@types/jest": "workspace:*",
"@types/jsonwebtoken": "^9.0.10",
"@types/node": "^20.0.0",
"@types/pkginfo": "^0.4.4",
Comment thread
JesuTerraz marked this conversation as resolved.
Outdated
Comment thread
JesuTerraz marked this conversation as resolved.
Outdated
"@typescript-eslint/eslint-plugin": "^8.47.0",
"@typescript-eslint/parser": "^8.47.0",
"eslint": "^9.39.1",
Expand Down
32 changes: 32 additions & 0 deletions packages/agents-a365-runtime/src/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@

import { TurnContext } from '@microsoft/agents-hosting';
import * as jwt from 'jsonwebtoken';
import { type } from 'os';
Comment thread
JesuTerraz marked this conversation as resolved.
Outdated
import pkginfo from 'pkginfo';

/**
* Utility class providing helper methods for agent runtime operations.
*/
export class Utility {
private static cachedVersion: string | null = null;

/**
* Decodes the current token and retrieves the App ID (appid or azp claim).
* @param token Token to Decode
Expand Down Expand Up @@ -47,4 +51,32 @@ export class Utility {

return agenticAppId;
}

Comment thread
JesuTerraz marked this conversation as resolved.
/**
* Generates a User-Agent header string containing SDK version, OS type, Node.js version, and orchestrator.
* @param orchestrator Optional orchestrator identifier to include in the User-Agent string.
* @returns Formatted User-Agent header string.
*/
public static GetUserAgentHeader(orchestrator: string = ''): string {
if (!this.cachedVersion) {
pkginfo(module, 'version');
this.cachedVersion = module.exports.version || 'unknown';
Comment thread
JesuTerraz marked this conversation as resolved.
Outdated
}
Comment thread
JesuTerraz marked this conversation as resolved.
Outdated
const orchestratorPart = orchestrator ? `; ${orchestrator}` : '';
return `Agent365SDK/${this.cachedVersion} (${this.ResolveOsType()}; Node.js ${process.version}${orchestratorPart})`;
}

private static ResolveOsType(): string {
Comment thread
JesuTerraz marked this conversation as resolved.
Outdated
const osType = type();
switch (osType) {
case 'Windows_NT':
return 'Windows';
case 'Darwin':
return 'macOS';
case 'Linux':
return 'Linux';
default:
return osType;
}
}
}
95 changes: 61 additions & 34 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ overrides:
# JSON Web Token
"jsonwebtoken": "^9.0.2"

# Package info
"pkginfo": "^0.4.1"
"@types/pkginfo": "^0.4.4"
Comment thread
JesuTerraz marked this conversation as resolved.
Outdated
Comment thread
JesuTerraz marked this conversation as resolved.
Outdated

# Development dependencies - align versions
"@microsoft/m365agentsplayground": "^0.2.18"
"typescript": "^5.9.3"
Expand Down
Loading