@microsoft/agents-a365-runtime 0.1.0-preview.103

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +33 -0
  3. package/dist/cjs/agentic-authorization-service.d.ts +28 -0
  4. package/dist/cjs/agentic-authorization-service.d.ts.map +1 -0
  5. package/dist/cjs/agentic-authorization-service.js +18 -0
  6. package/dist/cjs/agentic-authorization-service.js.map +1 -0
  7. package/dist/cjs/configuration/DefaultConfigurationProvider.d.ts +39 -0
  8. package/dist/cjs/configuration/DefaultConfigurationProvider.d.ts.map +1 -0
  9. package/dist/cjs/configuration/DefaultConfigurationProvider.js +47 -0
  10. package/dist/cjs/configuration/DefaultConfigurationProvider.js.map +1 -0
  11. package/dist/cjs/configuration/IConfigurationProvider.d.ts +8 -0
  12. package/dist/cjs/configuration/IConfigurationProvider.d.ts.map +1 -0
  13. package/dist/cjs/configuration/IConfigurationProvider.js +5 -0
  14. package/dist/cjs/configuration/IConfigurationProvider.js.map +1 -0
  15. package/dist/cjs/configuration/RuntimeConfiguration.d.ts +35 -0
  16. package/dist/cjs/configuration/RuntimeConfiguration.d.ts.map +1 -0
  17. package/dist/cjs/configuration/RuntimeConfiguration.js +71 -0
  18. package/dist/cjs/configuration/RuntimeConfiguration.js.map +1 -0
  19. package/dist/cjs/configuration/RuntimeConfigurationOptions.d.ts +35 -0
  20. package/dist/cjs/configuration/RuntimeConfigurationOptions.d.ts.map +1 -0
  21. package/dist/cjs/configuration/RuntimeConfigurationOptions.js +5 -0
  22. package/dist/cjs/configuration/RuntimeConfigurationOptions.js.map +1 -0
  23. package/dist/cjs/configuration/index.d.ts +5 -0
  24. package/dist/cjs/configuration/index.d.ts.map +1 -0
  25. package/dist/cjs/configuration/index.js +23 -0
  26. package/dist/cjs/configuration/index.js.map +1 -0
  27. package/dist/cjs/environment-utils.d.ts +98 -0
  28. package/dist/cjs/environment-utils.d.ts.map +1 -0
  29. package/dist/cjs/environment-utils.js +121 -0
  30. package/dist/cjs/environment-utils.js.map +1 -0
  31. package/dist/cjs/index.d.ts +8 -0
  32. package/dist/cjs/index.d.ts.map +1 -0
  33. package/dist/cjs/index.js +26 -0
  34. package/dist/cjs/index.js.map +1 -0
  35. package/dist/cjs/operation-error.d.ts +24 -0
  36. package/dist/cjs/operation-error.d.ts.map +1 -0
  37. package/dist/cjs/operation-error.js +35 -0
  38. package/dist/cjs/operation-error.js.map +1 -0
  39. package/dist/cjs/operation-result.d.ts +41 -0
  40. package/dist/cjs/operation-result.d.ts.map +1 -0
  41. package/dist/cjs/operation-result.js +56 -0
  42. package/dist/cjs/operation-result.js.map +1 -0
  43. package/dist/cjs/power-platform-api-discovery.d.ts +30 -0
  44. package/dist/cjs/power-platform-api-discovery.d.ts.map +1 -0
  45. package/dist/cjs/power-platform-api-discovery.js +86 -0
  46. package/dist/cjs/power-platform-api-discovery.js.map +1 -0
  47. package/dist/cjs/utility.d.ts +73 -0
  48. package/dist/cjs/utility.d.ts.map +1 -0
  49. package/dist/cjs/utility.js +187 -0
  50. package/dist/cjs/utility.js.map +1 -0
  51. package/dist/cjs/version.d.ts +2 -0
  52. package/dist/cjs/version.d.ts.map +1 -0
  53. package/dist/cjs/version.js +5 -0
  54. package/dist/cjs/version.js.map +1 -0
  55. package/dist/esm/agentic-authorization-service.d.ts +28 -0
  56. package/dist/esm/agentic-authorization-service.d.ts.map +1 -0
  57. package/dist/esm/agentic-authorization-service.js +14 -0
  58. package/dist/esm/agentic-authorization-service.js.map +1 -0
  59. package/dist/esm/configuration/DefaultConfigurationProvider.d.ts +39 -0
  60. package/dist/esm/configuration/DefaultConfigurationProvider.d.ts.map +1 -0
  61. package/dist/esm/configuration/DefaultConfigurationProvider.js +43 -0
  62. package/dist/esm/configuration/DefaultConfigurationProvider.js.map +1 -0
  63. package/dist/esm/configuration/IConfigurationProvider.d.ts +8 -0
  64. package/dist/esm/configuration/IConfigurationProvider.d.ts.map +1 -0
  65. package/dist/esm/configuration/IConfigurationProvider.js +4 -0
  66. package/dist/esm/configuration/IConfigurationProvider.js.map +1 -0
  67. package/dist/esm/configuration/RuntimeConfiguration.d.ts +35 -0
  68. package/dist/esm/configuration/RuntimeConfiguration.d.ts.map +1 -0
  69. package/dist/esm/configuration/RuntimeConfiguration.js +67 -0
  70. package/dist/esm/configuration/RuntimeConfiguration.js.map +1 -0
  71. package/dist/esm/configuration/RuntimeConfigurationOptions.d.ts +35 -0
  72. package/dist/esm/configuration/RuntimeConfigurationOptions.d.ts.map +1 -0
  73. package/dist/esm/configuration/RuntimeConfigurationOptions.js +4 -0
  74. package/dist/esm/configuration/RuntimeConfigurationOptions.js.map +1 -0
  75. package/dist/esm/configuration/index.d.ts +5 -0
  76. package/dist/esm/configuration/index.d.ts.map +1 -0
  77. package/dist/esm/configuration/index.js +7 -0
  78. package/dist/esm/configuration/index.js.map +1 -0
  79. package/dist/esm/environment-utils.d.ts +98 -0
  80. package/dist/esm/environment-utils.d.ts.map +1 -0
  81. package/dist/esm/environment-utils.js +114 -0
  82. package/dist/esm/environment-utils.js.map +1 -0
  83. package/dist/esm/index.d.ts +8 -0
  84. package/dist/esm/index.d.ts.map +1 -0
  85. package/dist/esm/index.js +10 -0
  86. package/dist/esm/index.js.map +1 -0
  87. package/dist/esm/operation-error.d.ts +24 -0
  88. package/dist/esm/operation-error.d.ts.map +1 -0
  89. package/dist/esm/operation-error.js +31 -0
  90. package/dist/esm/operation-error.js.map +1 -0
  91. package/dist/esm/operation-result.d.ts +41 -0
  92. package/dist/esm/operation-result.d.ts.map +1 -0
  93. package/dist/esm/operation-result.js +52 -0
  94. package/dist/esm/operation-result.js.map +1 -0
  95. package/dist/esm/power-platform-api-discovery.d.ts +30 -0
  96. package/dist/esm/power-platform-api-discovery.d.ts.map +1 -0
  97. package/dist/esm/power-platform-api-discovery.js +82 -0
  98. package/dist/esm/power-platform-api-discovery.js.map +1 -0
  99. package/dist/esm/utility.d.ts +73 -0
  100. package/dist/esm/utility.d.ts.map +1 -0
  101. package/dist/esm/utility.js +147 -0
  102. package/dist/esm/utility.js.map +1 -0
  103. package/dist/esm/version.d.ts +2 -0
  104. package/dist/esm/version.d.ts.map +1 -0
  105. package/dist/esm/version.js +2 -0
  106. package/dist/esm/version.js.map +1 -0
  107. package/package.json +63 -0
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
17
+ }) : function(o, v) {
18
+ o["default"] = v;
19
+ });
20
+ var __importStar = (this && this.__importStar) || (function () {
21
+ var ownKeys = function(o) {
22
+ ownKeys = Object.getOwnPropertyNames || function (o) {
23
+ var ar = [];
24
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
+ return ar;
26
+ };
27
+ return ownKeys(o);
28
+ };
29
+ return function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ })();
37
+ var __importDefault = (this && this.__importDefault) || function (mod) {
38
+ return (mod && mod.__esModule) ? mod : { "default": mod };
39
+ };
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.Utility = void 0;
42
+ const jwt = __importStar(require("jsonwebtoken"));
43
+ const os_1 = __importDefault(require("os"));
44
+ const fs_1 = __importDefault(require("fs"));
45
+ const path_1 = __importDefault(require("path"));
46
+ const version_1 = require("./version");
47
+ /**
48
+ * Utility class providing helper methods for agent runtime operations.
49
+ */
50
+ class Utility {
51
+ /**
52
+ * Reads the application name from package.json at module load time.
53
+ * This ensures file I/O happens during initialization, not during requests.
54
+ *
55
+ * Note: Uses process.cwd() which assumes the application is started from its root directory.
56
+ * This is a fallback mechanism - npm_package_name (checked first in getApplicationName) is
57
+ * the preferred source as it's reliably set by npm/pnpm when running package scripts.
58
+ */
59
+ static initPackageName() {
60
+ try {
61
+ const packageJsonPath = path_1.default.resolve(process.cwd(), 'package.json');
62
+ const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf-8'));
63
+ return packageJson.name || null;
64
+ }
65
+ catch {
66
+ // TODO: Add debug-level logging once a logger implementation is available
67
+ // to help troubleshoot package.json read failures in production environments
68
+ return null;
69
+ }
70
+ }
71
+ /**
72
+ * **WARNING: NO SIGNATURE VERIFICATION** - This method uses jwt.decode() which does NOT
73
+ * verify the token signature. The token claims can be spoofed by malicious actors.
74
+ * This method is ONLY suitable for logging, analytics, and diagnostics purposes.
75
+ * Do NOT use the returned value for authorization, access control, or security decisions.
76
+ *
77
+ * Decodes the current token and retrieves the App ID (appid or azp claim).
78
+ *
79
+ * Note: Returns a default GUID ('00000000-0000-0000-0000-000000000000') for empty tokens
80
+ * for backward compatibility with callers that expect a valid-looking GUID.
81
+ * For agent identification where empty string is preferred, use {@link getAgentIdFromToken}.
82
+ *
83
+ * @param token Token to Decode
84
+ * @returns AppId, or default GUID for empty token, or empty string if decode fails
85
+ */
86
+ static GetAppIdFromToken(token) {
87
+ if (!token || token.trim() === '') {
88
+ return '00000000-0000-0000-0000-000000000000';
89
+ }
90
+ try {
91
+ const decoded = jwt.decode(token);
92
+ if (!decoded) {
93
+ return '';
94
+ }
95
+ // Look for appid claim first, then azp claim as fallback
96
+ const appIdClaim = decoded['appid'] || decoded['azp'];
97
+ return appIdClaim || '';
98
+ }
99
+ catch (_error) {
100
+ // Silent error handling - return empty string on decode failure
101
+ return '';
102
+ }
103
+ }
104
+ /**
105
+ * **WARNING: NO SIGNATURE VERIFICATION** - This method uses jwt.decode() which does NOT
106
+ * verify the token signature. The token claims can be spoofed by malicious actors.
107
+ * This method is ONLY suitable for logging, analytics, and diagnostics purposes.
108
+ * Do NOT use the returned value for authorization, access control, or security decisions.
109
+ *
110
+ * Decodes the token and retrieves the best available agent identifier.
111
+ * Checks claims in priority order: xms_par_app_azp (agent blueprint ID) > appid > azp.
112
+ *
113
+ * Note: Returns empty string for empty/missing tokens (unlike {@link GetAppIdFromToken} which
114
+ * returns a default GUID). This allows callers to omit headers when no identifier is available.
115
+ *
116
+ * @param token JWT token to decode
117
+ * @returns Agent ID (GUID) or empty string if not found or token is empty
118
+ */
119
+ static getAgentIdFromToken(token) {
120
+ if (!token || token.trim() === '') {
121
+ return '';
122
+ }
123
+ try {
124
+ const decoded = jwt.decode(token);
125
+ if (!decoded) {
126
+ return '';
127
+ }
128
+ // Priority: xms_par_app_azp (agent blueprint ID) > appid > azp
129
+ return decoded['xms_par_app_azp'] || decoded['appid'] || decoded['azp'] || '';
130
+ }
131
+ catch (_error) {
132
+ // Silent error handling - return empty string on decode failure
133
+ return '';
134
+ }
135
+ }
136
+ /**
137
+ * Resolves the agent identity from the turn context or auth token.
138
+ * @param context Turn Context of the turn.
139
+ * @param authToken Auth token if available.
140
+ * @returns Agent identity (App ID)
141
+ */
142
+ static ResolveAgentIdentity(context, authToken) {
143
+ // App ID is required to pass to MCP server URL.
144
+ const agenticAppId = context.activity.isAgenticRequest()
145
+ ? context.activity.getAgenticInstanceId() || ''
146
+ : this.GetAppIdFromToken(authToken);
147
+ return agenticAppId;
148
+ }
149
+ /**
150
+ * Generates a User-Agent header string containing SDK version, OS type, Node.js version, and orchestrator.
151
+ * @param orchestrator Optional orchestrator identifier to include in the User-Agent string.
152
+ * @returns Formatted User-Agent header string.
153
+ */
154
+ static GetUserAgentHeader(orchestrator) {
155
+ const osType = os_1.default.type();
156
+ const orchestratorPart = orchestrator ? `; ${orchestrator}` : '';
157
+ return `Agent365SDK/${version_1.LIB_VERSION} (${osType}; Node.js ${process.version}${orchestratorPart})`;
158
+ }
159
+ /**
160
+ * Gets the application name from npm_package_name environment variable or package.json.
161
+ * The package.json result is cached at module load time to avoid sync I/O during requests.
162
+ * @returns Application name or undefined if not available.
163
+ */
164
+ static getApplicationName() {
165
+ // First try npm_package_name (set automatically by npm/pnpm when running scripts)
166
+ // eslint-disable-next-line no-restricted-properties -- npm_package_name is set by npm at runtime, not a configurable setting
167
+ if (process.env.npm_package_name) {
168
+ // eslint-disable-next-line no-restricted-properties -- npm_package_name is set by npm at runtime, not a configurable setting
169
+ return process.env.npm_package_name;
170
+ }
171
+ // Fall back to cached package.json name (read at module load time)
172
+ return this.cachedPackageName || undefined;
173
+ }
174
+ /**
175
+ * Resets the cached application name. Used for testing purposes.
176
+ * @internal
177
+ */
178
+ static resetApplicationNameCache() {
179
+ this.cachedPackageName = Utility.initPackageName();
180
+ }
181
+ }
182
+ exports.Utility = Utility;
183
+ // Cache for application name read from package.json
184
+ // null = checked but not found, string = found
185
+ // Eagerly initialized at module load time to avoid sync I/O during requests
186
+ Utility.cachedPackageName = Utility.initPackageName();
187
+ //# sourceMappingURL=utility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utility.js","sourceRoot":"","sources":["../../src/utility.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGlC,kDAAoC;AACpC,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;AAExB,uCAAwC;AAExC;;GAEG;AACH,MAAa,OAAO;IAMlB;;;;;;;OAOG;IACK,MAAM,CAAC,eAAe;QAC5B,IAAI,CAAC;YAC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AAiB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IACrD,CAAC;;AA/IH,0BAgJC;AA/IC,oDAAoD;AACpD,+CAA+C;AAC/C,4EAA4E;AAC7D,yBAAiB,GAAkB,OAAO,CAAC,eAAe,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const LIB_VERSION = "0.1.0-preview.103";
2
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,sBAAsB,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LIB_VERSION = void 0;
4
+ exports.LIB_VERSION = "0.1.0-preview.103";
5
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,mBAAmB,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { TurnContext, Authorization } from '@microsoft/agents-hosting';
2
+ /**
3
+ * Service for handling agentic user authentication.
4
+ */
5
+ export declare class AgenticAuthenticationService {
6
+ /**
7
+ * Gets an agentic user token for platform authentication.
8
+ * Uses the default MCP platform authentication scope.
9
+ *
10
+ * @param authorization The authorization handler.
11
+ * @param authHandlerName The name of the auth handler to use.
12
+ * @param turnContext The turn context for the current request.
13
+ * @returns The token string, or empty string if no token was returned.
14
+ * @deprecated Use the overload with explicit scopes parameter for better control over requested permissions.
15
+ */
16
+ static GetAgenticUserToken(authorization: Authorization, authHandlerName: string, turnContext: TurnContext): Promise<string>;
17
+ /**
18
+ * Gets an agentic user token for platform authentication.
19
+ *
20
+ * @param authorization The authorization handler.
21
+ * @param authHandlerName The name of the auth handler to use.
22
+ * @param turnContext The turn context for the current request.
23
+ * @param scopes The OAuth scopes to request. Should be obtained from the appropriate configuration (e.g., ToolingConfiguration.mcpPlatformAuthenticationScope).
24
+ * @returns The token string, or empty string if no token was returned.
25
+ */
26
+ static GetAgenticUserToken(authorization: Authorization, authHandlerName: string, turnContext: TurnContext, scopes: string[]): Promise<string>;
27
+ }
28
+ //# sourceMappingURL=agentic-authorization-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentic-authorization-service.d.ts","sourceRoot":"","sources":["../../src/agentic-authorization-service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAGvE;;GAEG;AACH,qBAAa,4BAA4B;IACvC;;;;;;;;;OASG;WACiB,mBAAmB,CACrC,aAAa,EAAE,aAAa,EAC5B,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,MAAM,CAAC;IAElB;;;;;;;;OAQG;WACiB,mBAAmB,CACrC,aAAa,EAAE,aAAa,EAC5B,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,EAAE,GACf,OAAO,CAAC,MAAM,CAAC;CAYnB"}
@@ -0,0 +1,14 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { PROD_MCP_PLATFORM_AUTHENTICATION_SCOPE } from './environment-utils';
4
+ /**
5
+ * Service for handling agentic user authentication.
6
+ */
7
+ export class AgenticAuthenticationService {
8
+ static async GetAgenticUserToken(authorization, authHandlerName, turnContext, scopes) {
9
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- Intentional: maintaining backward compatibility for deprecated 3-param overload
10
+ const effectiveScopes = scopes ?? [PROD_MCP_PLATFORM_AUTHENTICATION_SCOPE];
11
+ return (await authorization.exchangeToken(turnContext, authHandlerName, { scopes: effectiveScopes })).token || '';
12
+ }
13
+ }
14
+ //# sourceMappingURL=agentic-authorization-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentic-authorization-service.js","sourceRoot":"","sources":["../../src/agentic-authorization-service.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,sCAAsC,EAAE,MAAM,qBAAqB,CAAC;AAE7E;;GAEG;AACH,MAAM,OAAO,4BAA4B;IAiChC,MAAM,CAAC,KAAK,CAAC,mBAAmB,CACrC,aAA4B,EAC5B,eAAuB,EACvB,WAAwB,EACxB,MAAiB;QAEjB,+IAA+I;QAC/I,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,sCAAsC,CAAC,CAAC;QAC3E,OAAO,CAAC,MAAM,aAAa,CAAC,aAAa,CAAC,WAAW,EAAE,eAAe,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;IACpH,CAAC;CACF"}
@@ -0,0 +1,39 @@
1
+ import { IConfigurationProvider } from './IConfigurationProvider';
2
+ import { RuntimeConfiguration } from './RuntimeConfiguration';
3
+ /**
4
+ * Default provider that returns environment-based configuration.
5
+ *
6
+ * **Multi-tenant considerations:**
7
+ * This provider creates a single configuration instance at construction time,
8
+ * shared across all requests in a process. The default module-level providers
9
+ * (e.g., `defaultRuntimeConfigurationProvider`) are singletons.
10
+ *
11
+ * For multi-tenant scenarios, two approaches are supported:
12
+ *
13
+ * 1. **Dynamic override functions (recommended):** Pass override functions that
14
+ * read from async context (e.g., OpenTelemetry baggage) at runtime. The same
15
+ * Configuration instance returns different values per request.
16
+ * ```typescript
17
+ * const config = new ToolingConfiguration({
18
+ * mcpPlatformEndpoint: () => {
19
+ * const tenantConfig = context.active().getValue(TENANT_KEY);
20
+ * return tenantConfig?.endpoint ?? 'https://default.endpoint';
21
+ * }
22
+ * });
23
+ * ```
24
+ *
25
+ * 2. **Per-tenant providers:** Create separate provider instances for each tenant
26
+ * when different tenants need different override functions entirely.
27
+ */
28
+ export declare class DefaultConfigurationProvider<T extends RuntimeConfiguration> implements IConfigurationProvider<T> {
29
+ private readonly _configuration;
30
+ constructor(factory: () => T);
31
+ getConfiguration(): T;
32
+ }
33
+ /**
34
+ * Shared default provider for RuntimeConfiguration.
35
+ * Uses environment variables with no overrides - suitable for single-tenant
36
+ * deployments or when using dynamic override functions for multi-tenancy.
37
+ */
38
+ export declare const defaultRuntimeConfigurationProvider: DefaultConfigurationProvider<RuntimeConfiguration>;
39
+ //# sourceMappingURL=DefaultConfigurationProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultConfigurationProvider.d.ts","sourceRoot":"","sources":["../../../src/configuration/DefaultConfigurationProvider.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,4BAA4B,CAAC,CAAC,SAAS,oBAAoB,CACtE,YAAW,sBAAsB,CAAC,CAAC,CAAC;IAEpC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAI;gBAEvB,OAAO,EAAE,MAAM,CAAC;IAI5B,gBAAgB,IAAI,CAAC;CAGtB;AAED;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,oDACoB,CAAC"}
@@ -0,0 +1,43 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { RuntimeConfiguration } from './RuntimeConfiguration';
4
+ /**
5
+ * Default provider that returns environment-based configuration.
6
+ *
7
+ * **Multi-tenant considerations:**
8
+ * This provider creates a single configuration instance at construction time,
9
+ * shared across all requests in a process. The default module-level providers
10
+ * (e.g., `defaultRuntimeConfigurationProvider`) are singletons.
11
+ *
12
+ * For multi-tenant scenarios, two approaches are supported:
13
+ *
14
+ * 1. **Dynamic override functions (recommended):** Pass override functions that
15
+ * read from async context (e.g., OpenTelemetry baggage) at runtime. The same
16
+ * Configuration instance returns different values per request.
17
+ * ```typescript
18
+ * const config = new ToolingConfiguration({
19
+ * mcpPlatformEndpoint: () => {
20
+ * const tenantConfig = context.active().getValue(TENANT_KEY);
21
+ * return tenantConfig?.endpoint ?? 'https://default.endpoint';
22
+ * }
23
+ * });
24
+ * ```
25
+ *
26
+ * 2. **Per-tenant providers:** Create separate provider instances for each tenant
27
+ * when different tenants need different override functions entirely.
28
+ */
29
+ export class DefaultConfigurationProvider {
30
+ constructor(factory) {
31
+ this._configuration = factory();
32
+ }
33
+ getConfiguration() {
34
+ return this._configuration;
35
+ }
36
+ }
37
+ /**
38
+ * Shared default provider for RuntimeConfiguration.
39
+ * Uses environment variables with no overrides - suitable for single-tenant
40
+ * deployments or when using dynamic override functions for multi-tenancy.
41
+ */
42
+ export const defaultRuntimeConfigurationProvider = new DefaultConfigurationProvider(() => new RuntimeConfiguration());
43
+ //# sourceMappingURL=DefaultConfigurationProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultConfigurationProvider.js","sourceRoot":"","sources":["../../../src/configuration/DefaultConfigurationProvider.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,OAAO,4BAA4B;IAKvC,YAAY,OAAgB;QAC1B,IAAI,CAAC,cAAc,GAAG,OAAO,EAAE,CAAC;IAClC,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAC9C,IAAI,4BAA4B,CAAC,GAAG,EAAE,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Generic interface for providing configuration.
3
+ * Each package defines its own configuration type T.
4
+ */
5
+ export interface IConfigurationProvider<T> {
6
+ getConfiguration(): T;
7
+ }
8
+ //# sourceMappingURL=IConfigurationProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IConfigurationProvider.d.ts","sourceRoot":"","sources":["../../../src/configuration/IConfigurationProvider.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,WAAW,sBAAsB,CAAC,CAAC;IACvC,gBAAgB,IAAI,CAAC,CAAC;CACvB"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ export {};
4
+ //# sourceMappingURL=IConfigurationProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IConfigurationProvider.js","sourceRoot":"","sources":["../../../src/configuration/IConfigurationProvider.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC"}
@@ -0,0 +1,35 @@
1
+ import { ClusterCategory } from '../power-platform-api-discovery';
2
+ import { RuntimeConfigurationOptions } from './RuntimeConfigurationOptions';
3
+ /**
4
+ * Base configuration class for Agent365 SDK.
5
+ * Other packages extend this to add their own settings.
6
+ *
7
+ * Override functions are called on each property access, enabling dynamic
8
+ * resolution from async context (e.g., OpenTelemetry baggage) per-request.
9
+ */
10
+ export declare class RuntimeConfiguration {
11
+ protected readonly overrides: RuntimeConfigurationOptions;
12
+ /**
13
+ * Parse an environment variable as a boolean.
14
+ * Recognizes 'true', '1', 'yes', 'on' (case-insensitive) as true; all other values as false.
15
+ */
16
+ static parseEnvBoolean(envValue: string | undefined): boolean;
17
+ /**
18
+ * Parse an environment variable as an integer, returning fallback if invalid or not set.
19
+ */
20
+ static parseEnvInt(envValue: string | undefined, fallback: number): number;
21
+ constructor(overrides?: RuntimeConfigurationOptions);
22
+ get clusterCategory(): ClusterCategory;
23
+ /**
24
+ * Whether the cluster is a development environment (local or dev).
25
+ * Based on clusterCategory.
26
+ */
27
+ get isDevelopmentEnvironment(): boolean;
28
+ /**
29
+ * Whether NODE_ENV indicates development mode.
30
+ * Returns true when NODE_ENV is 'development' (case-insensitive).
31
+ * This is the standard Node.js way of indicating development mode.
32
+ */
33
+ get isNodeEnvDevelopment(): boolean;
34
+ }
35
+ //# sourceMappingURL=RuntimeConfiguration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RuntimeConfiguration.d.ts","sourceRoot":"","sources":["../../../src/configuration/RuntimeConfiguration.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAE5E;;;;;;GAMG;AACH,qBAAa,oBAAoB;IAC/B,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,2BAA2B,CAAC;IAE1D;;;OAGG;WACW,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO;IAKpE;;OAEG;WACW,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;gBAMrE,SAAS,CAAC,EAAE,2BAA2B;IAInD,IAAI,eAAe,IAAI,eAAe,CAarC;IAED;;;OAGG;IACH,IAAI,wBAAwB,IAAI,OAAO,CAEtC;IAED;;;;OAIG;IACH,IAAI,oBAAoB,IAAI,OAAO,CAMlC;CACF"}
@@ -0,0 +1,67 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { ClusterCategory } from '../power-platform-api-discovery';
4
+ /**
5
+ * Base configuration class for Agent365 SDK.
6
+ * Other packages extend this to add their own settings.
7
+ *
8
+ * Override functions are called on each property access, enabling dynamic
9
+ * resolution from async context (e.g., OpenTelemetry baggage) per-request.
10
+ */
11
+ export class RuntimeConfiguration {
12
+ /**
13
+ * Parse an environment variable as a boolean.
14
+ * Recognizes 'true', '1', 'yes', 'on' (case-insensitive) as true; all other values as false.
15
+ */
16
+ static parseEnvBoolean(envValue) {
17
+ if (!envValue)
18
+ return false;
19
+ return ['true', '1', 'yes', 'on'].includes(envValue.toLowerCase());
20
+ }
21
+ /**
22
+ * Parse an environment variable as an integer, returning fallback if invalid or not set.
23
+ */
24
+ static parseEnvInt(envValue, fallback) {
25
+ if (!envValue)
26
+ return fallback;
27
+ const parsed = parseInt(envValue, 10);
28
+ return Number.isFinite(parsed) ? parsed : fallback;
29
+ }
30
+ constructor(overrides) {
31
+ this.overrides = overrides ?? {};
32
+ }
33
+ get clusterCategory() {
34
+ if (this.overrides.clusterCategory) {
35
+ return this.overrides.clusterCategory();
36
+ }
37
+ const envValue = process.env.CLUSTER_CATEGORY;
38
+ if (envValue) {
39
+ const normalized = envValue.toLowerCase();
40
+ if (Object.values(ClusterCategory).includes(normalized)) {
41
+ return normalized;
42
+ }
43
+ // Invalid value - fall through to default
44
+ }
45
+ return ClusterCategory.prod;
46
+ }
47
+ /**
48
+ * Whether the cluster is a development environment (local or dev).
49
+ * Based on clusterCategory.
50
+ */
51
+ get isDevelopmentEnvironment() {
52
+ return [ClusterCategory.local, ClusterCategory.dev].includes(this.clusterCategory);
53
+ }
54
+ /**
55
+ * Whether NODE_ENV indicates development mode.
56
+ * Returns true when NODE_ENV is 'development' (case-insensitive).
57
+ * This is the standard Node.js way of indicating development mode.
58
+ */
59
+ get isNodeEnvDevelopment() {
60
+ const override = this.overrides.isNodeEnvDevelopment?.();
61
+ if (override !== undefined)
62
+ return override;
63
+ const nodeEnv = process.env.NODE_ENV ?? '';
64
+ return nodeEnv.toLowerCase() === 'development';
65
+ }
66
+ }
67
+ //# sourceMappingURL=RuntimeConfiguration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RuntimeConfiguration.js","sourceRoot":"","sources":["../../../src/configuration/RuntimeConfiguration.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAGlE;;;;;;GAMG;AACH,MAAM,OAAO,oBAAoB;IAG/B;;;OAGG;IACI,MAAM,CAAC,eAAe,CAAC,QAA4B;QACxD,IAAI,CAAC,QAAQ;YAAE,OAAO,KAAK,CAAC;QAC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AAI,CAAC,SAAS,CAAC,oBAAoB,EAAE,EAAE,CAAC;QACzD,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,QAAQ,CAAC;QAE5C,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC;QAC3C,OAAO,OAAO,CAAC,WAAW,EAAE,KAAK,aAAa,CAAC;IACjD,CAAC;CACF"}
@@ -0,0 +1,35 @@
1
+ import { ClusterCategory } from '../power-platform-api-discovery';
2
+ /**
3
+ * Runtime configuration options - all optional functions.
4
+ * Functions are called on each property access, enabling dynamic resolution.
5
+ * Unset values fall back to environment variables.
6
+ */
7
+ export type RuntimeConfigurationOptions = {
8
+ /**
9
+ * Override function for cluster category.
10
+ * Called on each property access to enable dynamic per-request resolution.
11
+ * Falls back to CLUSTER_CATEGORY env var, then 'prod'.
12
+ *
13
+ * @example
14
+ * // Static override
15
+ * { clusterCategory: () => ClusterCategory.gov }
16
+ *
17
+ * // Dynamic per-tenant override using async context
18
+ * { clusterCategory: () => context.active().getValue(TENANT_CONFIG_KEY)?.cluster ?? ClusterCategory.prod }
19
+ */
20
+ clusterCategory?: () => ClusterCategory;
21
+ /**
22
+ * Override for NODE_ENV-based development mode detection.
23
+ * Called on each property access to enable dynamic per-request resolution.
24
+ * Falls back to NODE_ENV === 'development' check.
25
+ *
26
+ * @example
27
+ * // Static override
28
+ * { isNodeEnvDevelopment: () => true }
29
+ *
30
+ * // Dynamic override based on request context
31
+ * { isNodeEnvDevelopment: () => context.active().getValue(DEBUG_KEY) === true }
32
+ */
33
+ isNodeEnvDevelopment?: () => boolean;
34
+ };
35
+ //# sourceMappingURL=RuntimeConfigurationOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RuntimeConfigurationOptions.d.ts","sourceRoot":"","sources":["../../../src/configuration/RuntimeConfigurationOptions.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE;;;;GAIG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC;;;;;;;;;;;OAWG;IACH,eAAe,CAAC,EAAE,MAAM,eAAe,CAAC;IACxC;;;;;;;;;;;OAWG;IACH,oBAAoB,CAAC,EAAE,MAAM,OAAO,CAAC;CACtC,CAAC"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ export {};
4
+ //# sourceMappingURL=RuntimeConfigurationOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RuntimeConfigurationOptions.js","sourceRoot":"","sources":["../../../src/configuration/RuntimeConfigurationOptions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC"}
@@ -0,0 +1,5 @@
1
+ export * from './IConfigurationProvider';
2
+ export * from './RuntimeConfigurationOptions';
3
+ export * from './RuntimeConfiguration';
4
+ export * from './DefaultConfigurationProvider';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/configuration/index.ts"],"names":[],"mappings":"AAGA,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC"}
@@ -0,0 +1,7 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ export * from './IConfigurationProvider';
4
+ export * from './RuntimeConfigurationOptions';
5
+ export * from './RuntimeConfiguration';
6
+ export * from './DefaultConfigurationProvider';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/configuration/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC"}