@cuylabs/agent-a365-observability 4.5.0 → 4.7.0
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.
- package/README.md +215 -9
- package/dist/index.d.ts +165 -8
- package/dist/index.js +886 -189
- package/docs/README.md +10 -3
- package/docs/architecture.md +33 -8
- package/docs/lifecycle-and-limits.md +55 -4
- package/docs/microsoft-a365-observability.md +16 -7
- package/docs/microsoft-node-package-comparison.md +75 -0
- package/docs/sdk-and-auth-flow.md +125 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -14,7 +14,9 @@ It does four things:
|
|
|
14
14
|
- wraps each request in Agent 365 baggage so spans include tenant, agent,
|
|
15
15
|
conversation, channel, and caller identity.
|
|
16
16
|
|
|
17
|
-
For the deeper design, read [docs/README.md](./docs/README.md).
|
|
17
|
+
For the deeper design, read [docs/README.md](./docs/README.md). For the full
|
|
18
|
+
SDK and auth flow, read
|
|
19
|
+
[docs/sdk-and-auth-flow.md](./docs/sdk-and-auth-flow.md).
|
|
18
20
|
|
|
19
21
|
## Install
|
|
20
22
|
|
|
@@ -22,14 +24,29 @@ For the deeper design, read [docs/README.md](./docs/README.md).
|
|
|
22
24
|
pnpm add @cuylabs/agent-a365-observability @microsoft/agents-a365-observability @microsoft/agents-a365-runtime
|
|
23
25
|
```
|
|
24
26
|
|
|
27
|
+
Install `@microsoft/agents-a365-observability-hosting` as well when using the
|
|
28
|
+
M365/OBO token-cache helpers.
|
|
29
|
+
|
|
30
|
+
Dependency roles:
|
|
31
|
+
|
|
32
|
+
| Package | Required when | Notes |
|
|
33
|
+
| ---------------------------------------------- | ----------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
|
34
|
+
| `@microsoft/agents-a365-observability` | Always, when exporting to Agent 365 | Owns Microsoft's `ObservabilityManager`, exporter, baggage processor, trace propagation utilities, and optional `OutputScope`. |
|
|
35
|
+
| `@microsoft/agents-a365-runtime` | Always with Microsoft's observability SDK | Provides Microsoft runtime configuration types used by the SDK. |
|
|
36
|
+
| `@microsoft/agents-a365-observability-hosting` | Only for M365/OBO token-cache helpers | Provides `AgenticTokenCache`. It is an optional peer and is lazy-loaded only by OBO helpers. S2S App Service agents do not need it. |
|
|
37
|
+
|
|
25
38
|
## Usage
|
|
26
39
|
|
|
27
40
|
```typescript
|
|
28
41
|
import { createAgent } from "@cuylabs/agent-core";
|
|
29
42
|
import {
|
|
43
|
+
createA365ObservedTurnSource,
|
|
44
|
+
createA365S2STokenResolverFromEnv,
|
|
30
45
|
createA365TracingConfig,
|
|
46
|
+
initA365S2SObservability,
|
|
31
47
|
initA365Observability,
|
|
32
48
|
runWithA365Context,
|
|
49
|
+
runWithA365OutputMessages,
|
|
33
50
|
runWithA365TurnContext,
|
|
34
51
|
} from "@cuylabs/agent-a365-observability";
|
|
35
52
|
|
|
@@ -74,6 +91,25 @@ await agent.close();
|
|
|
74
91
|
await observability.shutdown();
|
|
75
92
|
```
|
|
76
93
|
|
|
94
|
+
When you are adapting a custom channel around `AgentTurnSource`, use
|
|
95
|
+
`createA365ObservedTurnSource(...)` instead of hand-rolling async-generator
|
|
96
|
+
wrapping. The helper keeps the full event stream inside the Agent 365 baggage
|
|
97
|
+
scope while letting the channel own its own metadata mapping:
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
const observedSource = createA365ObservedTurnSource({
|
|
101
|
+
source: agent,
|
|
102
|
+
context: ({ sessionId }) => ({
|
|
103
|
+
tenantId: "tenant-123",
|
|
104
|
+
agentId: "agent-456",
|
|
105
|
+
conversationId: sessionId,
|
|
106
|
+
sessionId,
|
|
107
|
+
channelName: "slack",
|
|
108
|
+
userId: "slack-user-id",
|
|
109
|
+
}),
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
77
113
|
## M365 / Teams bot turns
|
|
78
114
|
|
|
79
115
|
When your bot uses `@microsoft/agents-hosting` `TurnContext`, use the
|
|
@@ -116,7 +152,15 @@ startup so the Microsoft exporter and token resolver are registered.
|
|
|
116
152
|
|
|
117
153
|
## Shape
|
|
118
154
|
|
|
119
|
-
|
|
155
|
+
This package is the `@cuylabs/agent-core` equivalent of a framework-specific
|
|
156
|
+
Agent 365 observability extension. Microsoft's OpenAI Agents and LangChain
|
|
157
|
+
extension packages patch those harnesses directly so their model/framework
|
|
158
|
+
spans flow through the Agent 365 ObservabilityManager. This package does the
|
|
159
|
+
same kind of adapter work at the agent-core layer: it starts the Microsoft
|
|
160
|
+
ObservabilityManager, feeds agent-core tracing metadata, and wraps each
|
|
161
|
+
agent-core turn with Agent 365 baggage.
|
|
162
|
+
|
|
163
|
+
The integration has four separate pieces:
|
|
120
164
|
|
|
121
165
|
1. `initA365Observability(...)` starts Microsoft's exporter and baggage span
|
|
122
166
|
processor once at host startup.
|
|
@@ -124,6 +168,16 @@ The integration has three separate pieces:
|
|
|
124
168
|
contract.
|
|
125
169
|
3. `runWithA365Context(...)` or `runWithA365TurnContext(...)` binds
|
|
126
170
|
per-request Agent 365 baggage before `agent.chat()` runs.
|
|
171
|
+
4. `createA365ObservedTurnSource(...)` wraps a channel-neutral
|
|
172
|
+
`AgentTurnSource` when a host needs streaming-safe A365 baggage around every
|
|
173
|
+
emitted event.
|
|
174
|
+
5. `createA365S2STokenResolver(...)` provides a reusable service-to-service
|
|
175
|
+
token resolver for Agent 365 Observability API export.
|
|
176
|
+
|
|
177
|
+
The source follows those same boundaries: `auth/` owns Agent 365 S2S token
|
|
178
|
+
resolution, `context/` owns baggage and TurnContext mapping, `runtime/` owns
|
|
179
|
+
Microsoft SDK startup and lazy loading, and `tracing/` owns the agent-core
|
|
180
|
+
tracing config adapter.
|
|
127
181
|
|
|
128
182
|
Use agent-core for portable OpenTelemetry spans:
|
|
129
183
|
|
|
@@ -203,17 +257,169 @@ you need those dimensions.
|
|
|
203
257
|
|
|
204
258
|
For batch export, provide `tokenResolver` in `initA365Observability()`.
|
|
205
259
|
|
|
206
|
-
For
|
|
260
|
+
For non-OBO service-to-service export, use `initA365S2SObservability()` when
|
|
261
|
+
the host should use the Agent 365 CLI generated environment values. The helper
|
|
262
|
+
understands both `A365_OBSERVABILITY_*` names and generated
|
|
263
|
+
`agent365Observability__*` names such as `agent365Observability__tenantId`,
|
|
264
|
+
`agent365Observability__agentId`, `agent365Observability__clientId`, and
|
|
265
|
+
`agent365Observability__clientSecret`.
|
|
266
|
+
|
|
267
|
+
```typescript
|
|
268
|
+
await initA365S2SObservability({
|
|
269
|
+
serviceName: "email-agent-service",
|
|
270
|
+
serviceVersion: "1.0.0",
|
|
271
|
+
});
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
The S2S initializer creates the token resolver, enables the Microsoft S2S
|
|
275
|
+
exporter endpoint, and enables the exporter unless configuration overrides it.
|
|
276
|
+
|
|
277
|
+
Use `createA365S2STokenResolverFromEnv()` when you want the resolver only:
|
|
278
|
+
|
|
279
|
+
```typescript
|
|
280
|
+
const tokenResolver = createA365S2STokenResolverFromEnv();
|
|
281
|
+
|
|
282
|
+
await initA365Observability({
|
|
283
|
+
serviceName: "email-agent-service",
|
|
284
|
+
tokenResolver,
|
|
285
|
+
exporterOptions: { useS2SEndpoint: true },
|
|
286
|
+
configuration: { exporterEnabled: true },
|
|
287
|
+
});
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Use `createA365S2STokenResolver()` when you want to pass values explicitly:
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
import {
|
|
294
|
+
createA365S2STokenResolver,
|
|
295
|
+
initA365Observability,
|
|
296
|
+
} from "@cuylabs/agent-a365-observability";
|
|
297
|
+
|
|
298
|
+
const tokenResolver = createA365S2STokenResolver({
|
|
299
|
+
tenantId: process.env.A365_OBSERVABILITY_TENANT_ID!,
|
|
300
|
+
agentId: process.env.A365_OBSERVABILITY_AGENT_ID!,
|
|
301
|
+
blueprintClientId: process.env.A365_OBSERVABILITY_CLIENT_ID!,
|
|
302
|
+
blueprintClientSecret: process.env.A365_OBSERVABILITY_CLIENT_SECRET,
|
|
303
|
+
useManagedIdentity:
|
|
304
|
+
process.env.A365_OBSERVABILITY_USE_MANAGED_IDENTITY === "true",
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
await initA365Observability({
|
|
308
|
+
serviceName: "email-agent-service",
|
|
309
|
+
tokenResolver,
|
|
310
|
+
exporterOptions: { useS2SEndpoint: true },
|
|
311
|
+
configuration: { exporterEnabled: true },
|
|
312
|
+
});
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Hosts that want Azure managed identity without taking an Azure dependency in
|
|
316
|
+
this package can pass `managedIdentityAssertionProvider`; the provider should
|
|
317
|
+
return an assertion token for `api://AzureADTokenExchange`.
|
|
318
|
+
|
|
319
|
+
For per-request export, pass `exportToken` to `runWithA365Context()` and enable
|
|
320
|
+
per-request export in startup configuration:
|
|
321
|
+
|
|
322
|
+
```typescript
|
|
323
|
+
await initA365Observability({
|
|
324
|
+
serviceName: "email-agent-service",
|
|
325
|
+
tokenResolver,
|
|
326
|
+
configuration: {
|
|
327
|
+
exporterEnabled: true,
|
|
328
|
+
perRequest: {
|
|
329
|
+
enabled: true,
|
|
330
|
+
maxTraces: 1000,
|
|
331
|
+
maxSpansPerTrace: 5000,
|
|
332
|
+
maxConcurrentExports: 20,
|
|
333
|
+
flushGraceMs: 250,
|
|
334
|
+
maxTraceAgeMs: 30 * 60 * 1000,
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
});
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
Microsoft's current per-request processor reads its tuning options from
|
|
341
|
+
environment-backed configuration. This package applies these explicit startup
|
|
342
|
+
values to the Microsoft environment variables before the SDK starts.
|
|
343
|
+
|
|
344
|
+
## Trace Propagation
|
|
345
|
+
|
|
346
|
+
Use the trace propagation helpers when one agent calls another over HTTP or
|
|
347
|
+
when async work needs to keep a parent span:
|
|
348
|
+
|
|
349
|
+
```typescript
|
|
350
|
+
const headers = await injectA365TraceContextToHeaders({});
|
|
351
|
+
await fetch(agentUrl, { method: "POST", headers });
|
|
352
|
+
|
|
353
|
+
await runWithA365ExtractedTraceContext(req.headers, () =>
|
|
354
|
+
runWithA365Context(context, () => agent.chat(sessionId, text)),
|
|
355
|
+
);
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
For queue or callback flows where you persisted the parent span ids, use
|
|
359
|
+
`runWithA365ParentSpanRef(...)`.
|
|
360
|
+
|
|
361
|
+
## Optional Output Spans
|
|
362
|
+
|
|
363
|
+
agent-core records output messages on the agent turn span. If an Agent 365
|
|
364
|
+
deployment needs Microsoft's separate `output_messages` span shape, wrap the
|
|
365
|
+
outgoing delivery path:
|
|
366
|
+
|
|
367
|
+
```typescript
|
|
368
|
+
await runWithA365OutputMessages(
|
|
369
|
+
{
|
|
370
|
+
tenantId,
|
|
371
|
+
agentId,
|
|
372
|
+
conversationId,
|
|
373
|
+
channelName: "msteams",
|
|
374
|
+
messages: ["Done."],
|
|
375
|
+
},
|
|
376
|
+
() => sendMessage("Done."),
|
|
377
|
+
);
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
This is opt-in because outgoing message content is recorded as telemetry.
|
|
381
|
+
|
|
382
|
+
## OBO Token Cache
|
|
383
|
+
|
|
384
|
+
For M365/OBO hosts, use the OBO helpers around Microsoft's
|
|
385
|
+
`AgenticTokenCache`. This is separate from the S2S setup flow.
|
|
386
|
+
|
|
387
|
+
This path requires the optional
|
|
388
|
+
`@microsoft/agents-a365-observability-hosting` peer because `AgenticTokenCache`
|
|
389
|
+
lives in Microsoft's hosting package. The adapter does not load that package
|
|
390
|
+
for S2S startup, S2S token resolution, baggage wrapping, trace propagation, or
|
|
391
|
+
output spans. It is loaded only when an OBO helper is called.
|
|
392
|
+
|
|
393
|
+
```typescript
|
|
394
|
+
await refreshA365OboObservabilityToken({
|
|
395
|
+
agentId,
|
|
396
|
+
tenantId,
|
|
397
|
+
turnContext,
|
|
398
|
+
authorization,
|
|
399
|
+
scopes: ["api://9b975845-388f-4429-889e-eab1ef63949c/.default"],
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
await initA365Observability({
|
|
403
|
+
serviceName: "email-agent-service",
|
|
404
|
+
tokenResolver: createA365OboTokenResolver(),
|
|
405
|
+
configuration: { exporterEnabled: true },
|
|
406
|
+
});
|
|
407
|
+
```
|
|
207
408
|
|
|
208
|
-
##
|
|
409
|
+
## Optional Features
|
|
209
410
|
|
|
210
|
-
|
|
411
|
+
The adapter now exposes the official additive pieces that do not duplicate
|
|
412
|
+
agent-core telemetry:
|
|
211
413
|
|
|
212
|
-
-
|
|
213
|
-
-
|
|
214
|
-
-
|
|
414
|
+
- S2S Observability token resolution, including Agent 365 CLI env aliases;
|
|
415
|
+
- Microsoft trace context propagation helpers;
|
|
416
|
+
- per-request export token and processor configuration;
|
|
417
|
+
- optional Microsoft `OutputScope` output-message spans;
|
|
418
|
+
- OBO token cache helpers for M365 per-user authorization.
|
|
215
419
|
|
|
216
|
-
|
|
420
|
+
Real-time threat protection and chat-history submission are outside
|
|
421
|
+
observability and should live in separate Agent 365 tooling or security
|
|
422
|
+
packages.
|
|
217
423
|
|
|
218
424
|
## Examples
|
|
219
425
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,34 @@
|
|
|
1
1
|
import { TelemetryOptions } from 'ai';
|
|
2
|
+
import { AgentTurnSourceChatOptions, AgentTurnSource } from '@cuylabs/agent-core';
|
|
2
3
|
|
|
3
4
|
type A365TokenResolver = (agentId: string, tenantId: string) => string | null | Promise<string | null>;
|
|
4
5
|
type A365Logger = {
|
|
5
6
|
info(message: string, ...args: unknown[]): void;
|
|
6
7
|
warn(message: string, ...args: unknown[]): void;
|
|
7
8
|
error(message: string, ...args: unknown[]): void;
|
|
8
|
-
event?(eventName: string, success: boolean, durationMs: number, message?: string, details?: Record<string, string>): void;
|
|
9
|
+
event?(eventName: A365ExporterEventName | (string & {}), success: boolean, durationMs: number, message?: string, details?: Record<string, string>): void;
|
|
9
10
|
};
|
|
11
|
+
declare const A365_EXPORTER_EVENT_NAMES: {
|
|
12
|
+
readonly export: "agent365-export";
|
|
13
|
+
readonly exportGroup: "export-group";
|
|
14
|
+
readonly exportPartitionSpanMissingIdentity: "export-partition-span-missing-identity";
|
|
15
|
+
};
|
|
16
|
+
type A365ExporterEventName = (typeof A365_EXPORTER_EVENT_NAMES)[keyof typeof A365_EXPORTER_EVENT_NAMES];
|
|
10
17
|
type SpanAttributeValue = string | number | boolean | string[] | number[] | boolean[];
|
|
11
18
|
type A365ObservabilityConfiguration = {
|
|
12
19
|
exporterEnabled?: boolean;
|
|
13
20
|
domainOverride?: string | null;
|
|
14
21
|
logLevel?: string;
|
|
15
22
|
authenticationScopes?: string[];
|
|
23
|
+
perRequest?: A365PerRequestExportConfiguration;
|
|
24
|
+
};
|
|
25
|
+
type A365PerRequestExportConfiguration = {
|
|
26
|
+
enabled?: boolean;
|
|
27
|
+
maxTraces?: number;
|
|
28
|
+
maxSpansPerTrace?: number;
|
|
29
|
+
maxConcurrentExports?: number;
|
|
30
|
+
flushGraceMs?: number;
|
|
31
|
+
maxTraceAgeMs?: number;
|
|
16
32
|
};
|
|
17
33
|
type A365RequestContext = {
|
|
18
34
|
tenantId?: string;
|
|
@@ -130,15 +146,85 @@ type A365TracingConfig = {
|
|
|
130
146
|
spanAttributes?: Record<string, SpanAttributeValue>;
|
|
131
147
|
};
|
|
132
148
|
|
|
149
|
+
declare class A365ObservabilityModuleLoadError extends Error {
|
|
150
|
+
constructor(message: string, options?: ErrorOptions);
|
|
151
|
+
}
|
|
152
|
+
declare class A365ObservabilityHostingModuleLoadError extends Error {
|
|
153
|
+
constructor(message: string, options?: ErrorOptions);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
type A365ManagedIdentityAssertionProvider = () => string | Promise<string>;
|
|
157
|
+
type A365S2STokenResolverLogger = {
|
|
158
|
+
warn(message: string, details?: Record<string, unknown>): void;
|
|
159
|
+
};
|
|
160
|
+
type A365S2STokenResolverOptions = {
|
|
161
|
+
tenantId: string;
|
|
162
|
+
agentId: string;
|
|
163
|
+
blueprintClientId: string;
|
|
164
|
+
blueprintClientSecret?: string;
|
|
165
|
+
useManagedIdentity?: boolean;
|
|
166
|
+
managedIdentityAssertionProvider?: A365ManagedIdentityAssertionProvider;
|
|
167
|
+
allowManagedIdentityClientSecretFallback?: boolean;
|
|
168
|
+
observabilityScope?: string;
|
|
169
|
+
fmiScope?: string;
|
|
170
|
+
refreshSkewMs?: number;
|
|
171
|
+
logger?: A365S2STokenResolverLogger;
|
|
172
|
+
fetch?: typeof fetch;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Creates an Agent 365 S2S Observability API token resolver.
|
|
177
|
+
*
|
|
178
|
+
* The resolver implements the Agent 365 3-hop FMI flow used by non-OBO agents:
|
|
179
|
+
*
|
|
180
|
+
* 1. Blueprint credential or managed-identity assertion -> FMI token targeted at
|
|
181
|
+
* the agent identity through `fmi_path`.
|
|
182
|
+
* 2. Agent identity uses that FMI token as a client assertion.
|
|
183
|
+
* 3. Entra returns an Observability API token for the Agent 365 exporter.
|
|
184
|
+
*/
|
|
185
|
+
declare function createA365S2STokenResolver(options: A365S2STokenResolverOptions): A365TokenResolver;
|
|
186
|
+
|
|
187
|
+
type A365Environment = Record<string, string | undefined>;
|
|
188
|
+
type A365ResolvedObservabilityEnvironment = {
|
|
189
|
+
tenantId?: string;
|
|
190
|
+
agentId?: string;
|
|
191
|
+
agentName?: string;
|
|
192
|
+
agentDescription?: string;
|
|
193
|
+
blueprintClientId?: string;
|
|
194
|
+
blueprintClientSecret?: string;
|
|
195
|
+
useManagedIdentity?: boolean;
|
|
196
|
+
observabilityScope?: string;
|
|
197
|
+
fmiScope?: string;
|
|
198
|
+
configuration: A365ObservabilityConfiguration;
|
|
199
|
+
};
|
|
200
|
+
type A365S2STokenResolverFromEnvOptions = Partial<Omit<A365S2STokenResolverOptions, "tenantId" | "agentId" | "blueprintClientId">> & Partial<Pick<A365S2STokenResolverOptions, "tenantId" | "agentId" | "blueprintClientId">> & {
|
|
201
|
+
env?: A365Environment;
|
|
202
|
+
};
|
|
203
|
+
declare function resolveA365ObservabilityEnvironment(env?: A365Environment): A365ResolvedObservabilityEnvironment;
|
|
204
|
+
declare function createA365S2STokenResolverFromEnv(options?: A365S2STokenResolverFromEnvOptions): A365TokenResolver;
|
|
205
|
+
|
|
206
|
+
type A365AgenticTokenCacheLike = {
|
|
207
|
+
getObservabilityToken(agentId: string, tenantId: string): string | null;
|
|
208
|
+
RefreshObservabilityToken(agentId: string, tenantId: string, turnContext: unknown, authorization: unknown, scopes: string[], authHandlerName?: string): Promise<void>;
|
|
209
|
+
invalidateToken?(agentId: string, tenantId: string): void;
|
|
210
|
+
invalidateAll?(): void;
|
|
211
|
+
};
|
|
212
|
+
|
|
133
213
|
type A365ObservabilityModuleLoader = () => Promise<unknown>;
|
|
134
214
|
type A365ObservabilityRuntimeOptions = {
|
|
135
215
|
/**
|
|
136
|
-
*
|
|
216
|
+
* Loader override for `@microsoft/agents-a365-observability`.
|
|
137
217
|
*
|
|
138
218
|
* Production code normally leaves this unset so the package is loaded lazily
|
|
139
219
|
* only when observability is used.
|
|
140
220
|
*/
|
|
141
221
|
getObservabilityModule?: A365ObservabilityModuleLoader;
|
|
222
|
+
/**
|
|
223
|
+
* Loader override for `@microsoft/agents-a365-observability-hosting`.
|
|
224
|
+
*
|
|
225
|
+
* Only OBO token-cache helpers use this package.
|
|
226
|
+
*/
|
|
227
|
+
getObservabilityHostingModule?: A365ObservabilityModuleLoader;
|
|
142
228
|
};
|
|
143
229
|
type InitA365ObservabilityOptions = A365ObservabilityRuntimeOptions & {
|
|
144
230
|
serviceName: string;
|
|
@@ -154,9 +240,28 @@ type A365ObservabilityHandle = {
|
|
|
154
240
|
shutdown(): Promise<void>;
|
|
155
241
|
};
|
|
156
242
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
243
|
+
type A365AuthorizationLike = {
|
|
244
|
+
exchangeToken(turnContext: unknown, authHandlerName: string, options: {
|
|
245
|
+
scopes: string[];
|
|
246
|
+
}): Promise<{
|
|
247
|
+
token?: string;
|
|
248
|
+
} | undefined>;
|
|
249
|
+
};
|
|
250
|
+
type A365OboTokenCacheOptions = A365ObservabilityRuntimeOptions & {
|
|
251
|
+
cache?: A365AgenticTokenCacheLike;
|
|
252
|
+
};
|
|
253
|
+
type A365RefreshOboObservabilityTokenOptions = A365OboTokenCacheOptions & {
|
|
254
|
+
agentId: string;
|
|
255
|
+
tenantId: string;
|
|
256
|
+
turnContext: unknown;
|
|
257
|
+
authorization: A365AuthorizationLike;
|
|
258
|
+
scopes?: string[];
|
|
259
|
+
authHandlerName?: string;
|
|
260
|
+
};
|
|
261
|
+
declare function createA365OboTokenResolver(options?: A365OboTokenCacheOptions): A365TokenResolver;
|
|
262
|
+
declare function refreshA365OboObservabilityToken(options: A365RefreshOboObservabilityTokenOptions): Promise<void>;
|
|
263
|
+
declare function invalidateA365OboObservabilityToken(agentId: string, tenantId: string, options?: A365OboTokenCacheOptions): Promise<void>;
|
|
264
|
+
declare function invalidateAllA365OboObservabilityTokens(options?: A365OboTokenCacheOptions): Promise<void>;
|
|
160
265
|
|
|
161
266
|
declare const A365_BAGGAGE_KEYS: {
|
|
162
267
|
readonly tenantId: "microsoft.tenant.id";
|
|
@@ -192,15 +297,67 @@ declare const A365_BAGGAGE_KEYS: {
|
|
|
192
297
|
|
|
193
298
|
declare function buildA365BaggagePairs(context: A365RequestContext): Record<string, string>;
|
|
194
299
|
|
|
195
|
-
declare function createA365TracingConfig(options?: A365TracingConfigOptions): A365TracingConfig;
|
|
196
|
-
|
|
197
300
|
declare function createA365ContextFromTurnContext(turnContext: A365TurnContextLike, options?: A365TurnContextOptions): A365RequestContext;
|
|
198
301
|
|
|
199
302
|
declare function runWithA365TurnContext<T>(turnContext: A365TurnContextLike, fn: () => T, runtimeOptions?: A365ObservabilityRuntimeOptions): Promise<Awaited<T>>;
|
|
200
303
|
declare function runWithA365TurnContext<T>(turnContext: A365TurnContextLike, options: A365TurnContextOptions, fn: () => T, runtimeOptions?: A365ObservabilityRuntimeOptions): Promise<Awaited<T>>;
|
|
201
304
|
|
|
305
|
+
type A365ObservedTurnSourceContextInput = {
|
|
306
|
+
sessionId: string;
|
|
307
|
+
message: string;
|
|
308
|
+
options?: AgentTurnSourceChatOptions;
|
|
309
|
+
};
|
|
310
|
+
type A365ObservedTurnSourceContextFactory = (input: A365ObservedTurnSourceContextInput) => A365RequestContext | Promise<A365RequestContext>;
|
|
311
|
+
type A365ObservedTurnSourceOptions = {
|
|
312
|
+
source: AgentTurnSource;
|
|
313
|
+
context: A365RequestContext | A365ObservedTurnSourceContextFactory;
|
|
314
|
+
runtimeOptions?: A365ObservabilityRuntimeOptions;
|
|
315
|
+
};
|
|
316
|
+
declare function createA365ObservedTurnSource({ context, runtimeOptions, source, }: A365ObservedTurnSourceOptions): AgentTurnSource;
|
|
317
|
+
|
|
202
318
|
declare function initA365Observability(options: InitA365ObservabilityOptions): Promise<A365ObservabilityHandle>;
|
|
203
319
|
declare function runWithA365Context<T>(requestContext: A365RequestContext, fn: () => T, options?: A365ObservabilityRuntimeOptions): Promise<Awaited<T>>;
|
|
204
320
|
declare function updateA365ExportToken(token: string, options?: A365ObservabilityRuntimeOptions): Promise<boolean>;
|
|
205
321
|
|
|
206
|
-
|
|
322
|
+
/**
|
|
323
|
+
* Microsoft currently reads per-request processor settings through its default
|
|
324
|
+
* env-backed provider. Apply explicit startup options before the SDK starts.
|
|
325
|
+
*/
|
|
326
|
+
declare function applyA365PerRequestEnvironment(configuration: A365PerRequestExportConfiguration | undefined, env?: NodeJS.ProcessEnv): void;
|
|
327
|
+
|
|
328
|
+
type InitA365S2SObservabilityOptions = Omit<InitA365ObservabilityOptions, "tokenResolver"> & {
|
|
329
|
+
s2s?: A365S2STokenResolverFromEnvOptions;
|
|
330
|
+
};
|
|
331
|
+
declare function initA365S2SObservability(options: InitA365S2SObservabilityOptions): Promise<A365ObservabilityHandle>;
|
|
332
|
+
|
|
333
|
+
declare function createA365TracingConfig(options?: A365TracingConfigOptions): A365TracingConfig;
|
|
334
|
+
|
|
335
|
+
type A365HeadersCarrier = Record<string, string | string[] | undefined>;
|
|
336
|
+
type A365MutableHeadersCarrier = Record<string, string>;
|
|
337
|
+
type A365ParentSpanRef = {
|
|
338
|
+
traceId: string;
|
|
339
|
+
spanId: string;
|
|
340
|
+
traceFlags?: number;
|
|
341
|
+
traceState?: unknown;
|
|
342
|
+
isRemote?: boolean;
|
|
343
|
+
};
|
|
344
|
+
type A365TraceContextOptions = A365ObservabilityRuntimeOptions & {
|
|
345
|
+
context?: unknown;
|
|
346
|
+
};
|
|
347
|
+
declare function injectA365TraceContextToHeaders(headers?: A365MutableHeadersCarrier, options?: A365TraceContextOptions): Promise<A365MutableHeadersCarrier>;
|
|
348
|
+
declare function extractA365TraceContextFromHeaders(headers: A365HeadersCarrier, options?: A365TraceContextOptions): Promise<unknown>;
|
|
349
|
+
declare function runWithA365ExtractedTraceContext<T>(headers: A365HeadersCarrier, fn: () => T, options?: A365ObservabilityRuntimeOptions): Promise<Awaited<T>>;
|
|
350
|
+
declare function runWithA365ParentSpanRef<T>(parent: A365ParentSpanRef, fn: () => T, options?: A365ObservabilityRuntimeOptions): Promise<Awaited<T>>;
|
|
351
|
+
declare function createA365ContextWithParentSpanRef(baseContext: unknown, parent: A365ParentSpanRef, options?: A365ObservabilityRuntimeOptions): Promise<unknown>;
|
|
352
|
+
|
|
353
|
+
type A365OutputMessagesParam = string | string[] | Record<string, unknown> | {
|
|
354
|
+
version: string;
|
|
355
|
+
messages: unknown[];
|
|
356
|
+
};
|
|
357
|
+
type A365OutputScopeContext = A365RequestContext & {
|
|
358
|
+
messages: A365OutputMessagesParam;
|
|
359
|
+
parentSpan?: A365ParentSpanRef;
|
|
360
|
+
};
|
|
361
|
+
declare function runWithA365OutputMessages<T>(output: A365OutputScopeContext, fn: () => T, options?: A365ObservabilityRuntimeOptions): Promise<Awaited<T>>;
|
|
362
|
+
|
|
363
|
+
export { type A365ActivityAccountLike, type A365ActivityLike, type A365AuthorizationLike, type A365Environment, type A365ExporterEventName, type A365HeadersCarrier, type A365Logger, type A365ManagedIdentityAssertionProvider, type A365MutableHeadersCarrier, type A365OboTokenCacheOptions, type A365ObservabilityConfiguration, type A365ObservabilityHandle, A365ObservabilityHostingModuleLoadError, A365ObservabilityModuleLoadError, type A365ObservabilityModuleLoader, type A365ObservabilityRuntimeOptions, type A365ObservedTurnSourceContextFactory, type A365ObservedTurnSourceContextInput, type A365ObservedTurnSourceOptions, type A365OutputMessagesParam, type A365OutputScopeContext, type A365ParentSpanRef, type A365PerRequestExportConfiguration, type A365RefreshOboObservabilityTokenOptions, type A365RequestContext, type A365ResolvedObservabilityEnvironment, type A365S2STokenResolverFromEnvOptions, type A365S2STokenResolverLogger, type A365S2STokenResolverOptions, type A365TokenResolver, type A365TraceContextOptions, type A365TracingConfig, type A365TracingConfigOptions, type A365TurnContextLike, type A365TurnContextOptions, A365_BAGGAGE_KEYS, A365_EXPORTER_EVENT_NAMES, type InitA365ObservabilityOptions, type InitA365S2SObservabilityOptions, type SpanAttributeValue, applyA365PerRequestEnvironment, buildA365BaggagePairs, createA365ContextFromTurnContext, createA365ContextWithParentSpanRef, createA365OboTokenResolver, createA365ObservedTurnSource, createA365S2STokenResolver, createA365S2STokenResolverFromEnv, createA365TracingConfig, extractA365TraceContextFromHeaders, initA365Observability, initA365S2SObservability, injectA365TraceContextToHeaders, invalidateA365OboObservabilityToken, invalidateAllA365OboObservabilityTokens, refreshA365OboObservabilityToken, resolveA365ObservabilityEnvironment, runWithA365Context, runWithA365ExtractedTraceContext, runWithA365OutputMessages, runWithA365ParentSpanRef, runWithA365TurnContext, updateA365ExportToken };
|