@microsoft/agents-a365-observability-hosting 0.1.0-preview.53
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/dist/cjs/caching/AgenticTokenCache.d.ts +20 -0
- package/dist/cjs/caching/AgenticTokenCache.d.ts.map +1 -0
- package/dist/cjs/caching/AgenticTokenCache.js +182 -0
- package/dist/cjs/caching/AgenticTokenCache.js.map +1 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +27 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/utils/BaggageBuilderUtils.d.ts +57 -0
- package/dist/cjs/utils/BaggageBuilderUtils.d.ts.map +1 -0
- package/dist/cjs/utils/BaggageBuilderUtils.js +93 -0
- package/dist/cjs/utils/BaggageBuilderUtils.js.map +1 -0
- package/dist/cjs/utils/InvokeAgentScopeUtils.d.ts +64 -0
- package/dist/cjs/utils/InvokeAgentScopeUtils.d.ts.map +1 -0
- package/dist/cjs/utils/InvokeAgentScopeUtils.js +105 -0
- package/dist/cjs/utils/InvokeAgentScopeUtils.js.map +1 -0
- package/dist/cjs/utils/TurnContextUtils.d.ts +38 -0
- package/dist/cjs/utils/TurnContextUtils.d.ts.map +1 -0
- package/dist/cjs/utils/TurnContextUtils.js +144 -0
- package/dist/cjs/utils/TurnContextUtils.js.map +1 -0
- package/dist/esm/caching/AgenticTokenCache.d.ts +20 -0
- package/dist/esm/caching/AgenticTokenCache.d.ts.map +1 -0
- package/dist/esm/caching/AgenticTokenCache.js +179 -0
- package/dist/esm/caching/AgenticTokenCache.js.map +1 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/utils/BaggageBuilderUtils.d.ts +57 -0
- package/dist/esm/utils/BaggageBuilderUtils.d.ts.map +1 -0
- package/dist/esm/utils/BaggageBuilderUtils.js +89 -0
- package/dist/esm/utils/BaggageBuilderUtils.js.map +1 -0
- package/dist/esm/utils/InvokeAgentScopeUtils.d.ts +64 -0
- package/dist/esm/utils/InvokeAgentScopeUtils.d.ts.map +1 -0
- package/dist/esm/utils/InvokeAgentScopeUtils.js +101 -0
- package/dist/esm/utils/InvokeAgentScopeUtils.js.map +1 -0
- package/dist/esm/utils/TurnContextUtils.d.ts +38 -0
- package/dist/esm/utils/TurnContextUtils.d.ts.map +1 -0
- package/dist/esm/utils/TurnContextUtils.js +136 -0
- package/dist/esm/utils/TurnContextUtils.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// ------------------------------------------------------------------------------
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
// ------------------------------------------------------------------------------
|
|
5
|
+
import { getCallerBaggagePairs, getExecutionTypePair, getTargetAgentBaggagePairs, getTenantIdPair, getSourceMetadataBaggagePairs, getConversationIdAndItemLinkPairs } from './TurnContextUtils';
|
|
6
|
+
/**
|
|
7
|
+
* Utilities to populate InvokeAgentScope tags from a TurnContext.
|
|
8
|
+
*/
|
|
9
|
+
export class InvokeAgentScopeUtils {
|
|
10
|
+
/**
|
|
11
|
+
* Populate all supported InvokeAgentScope tags from the provided TurnContext.
|
|
12
|
+
* @param scope The InvokeAgentScope instance to populate.
|
|
13
|
+
* @param turnContext The TurnContext containing activity information.
|
|
14
|
+
* @returns The updated InvokeAgentScope instance.
|
|
15
|
+
*/
|
|
16
|
+
static populateFromTurnContext(scope, turnContext) {
|
|
17
|
+
if (!turnContext) {
|
|
18
|
+
throw new Error('turnContext is required');
|
|
19
|
+
}
|
|
20
|
+
this.setCallerTags(scope, turnContext);
|
|
21
|
+
this.setExecutionTypeTags(scope, turnContext);
|
|
22
|
+
this.setTargetAgentTags(scope, turnContext);
|
|
23
|
+
this.setTenantIdTags(scope, turnContext);
|
|
24
|
+
this.setSourceMetadataTags(scope, turnContext);
|
|
25
|
+
this.setConversationIdTags(scope, turnContext);
|
|
26
|
+
return scope;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Sets the caller-related attribute values from the TurnContext.
|
|
30
|
+
* @param scope The InvokeAgentScope instance.
|
|
31
|
+
* @param turnContext The TurnContext containing activity information.
|
|
32
|
+
* @returns The updated InvokeAgentScope instance.
|
|
33
|
+
*/
|
|
34
|
+
static setCallerTags(scope, turnContext) {
|
|
35
|
+
scope.recordAttributes(getCallerBaggagePairs(turnContext));
|
|
36
|
+
return scope;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Sets the execution type tag based on caller and recipient agentic status.
|
|
40
|
+
* @param scope The InvokeAgentScope instance.
|
|
41
|
+
* @param turnContext The TurnContext containing activity information.
|
|
42
|
+
* @returns The updated InvokeAgentScope instance.
|
|
43
|
+
*/
|
|
44
|
+
static setExecutionTypeTags(scope, turnContext) {
|
|
45
|
+
scope.recordAttributes(getExecutionTypePair(turnContext));
|
|
46
|
+
return scope;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Sets the target agent-related tags from the TurnContext.
|
|
50
|
+
* @param scope The InvokeAgentScope instance.
|
|
51
|
+
* @param turnContext The TurnContext containing activity information.
|
|
52
|
+
* @returns The updated InvokeAgentScope instance.
|
|
53
|
+
*/
|
|
54
|
+
static setTargetAgentTags(scope, turnContext) {
|
|
55
|
+
scope.recordAttributes(getTargetAgentBaggagePairs(turnContext));
|
|
56
|
+
return scope;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Sets the tenant ID tag, extracting from ChannelData if necessary.
|
|
60
|
+
* @param scope The InvokeAgentScope instance.
|
|
61
|
+
* @param turnContext The TurnContext containing activity information.
|
|
62
|
+
* @returns The updated InvokeAgentScope instance.
|
|
63
|
+
*/
|
|
64
|
+
static setTenantIdTags(scope, turnContext) {
|
|
65
|
+
scope.recordAttributes(getTenantIdPair(turnContext));
|
|
66
|
+
return scope;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Sets the source metadata tags from the TurnContext.
|
|
70
|
+
* @param scope The InvokeAgentScope instance.
|
|
71
|
+
* @param turnContext The TurnContext containing activity information.
|
|
72
|
+
* @returns The updated InvokeAgentScope instance.
|
|
73
|
+
*/
|
|
74
|
+
static setSourceMetadataTags(scope, turnContext) {
|
|
75
|
+
scope.recordAttributes(getSourceMetadataBaggagePairs(turnContext));
|
|
76
|
+
return scope;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Sets the conversation ID and item link tags from the TurnContext.
|
|
80
|
+
* @param scope The InvokeAgentScope instance.
|
|
81
|
+
* @param turnContext The TurnContext containing activity information.
|
|
82
|
+
* @returns The updated InvokeAgentScope instance.
|
|
83
|
+
*/
|
|
84
|
+
static setConversationIdTags(scope, turnContext) {
|
|
85
|
+
scope.recordAttributes(getConversationIdAndItemLinkPairs(turnContext));
|
|
86
|
+
return scope;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Sets the input message tag from the TurnContext.
|
|
90
|
+
* @param scope The InvokeAgentScope instance.
|
|
91
|
+
* @param turnContext The TurnContext containing activity information.
|
|
92
|
+
* @returns The updated InvokeAgentScope instance.
|
|
93
|
+
*/
|
|
94
|
+
static setInputMessageTags(scope, turnContext) {
|
|
95
|
+
if (turnContext?.activity?.text) {
|
|
96
|
+
scope.recordInputMessages([turnContext?.activity?.text]);
|
|
97
|
+
}
|
|
98
|
+
return scope;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=InvokeAgentScopeUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InvokeAgentScopeUtils.js","sourceRoot":"","sources":["../../../src/utils/InvokeAgentScopeUtils.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,uCAAuC;AACvC,kCAAkC;AAClC,iFAAiF;AAIjF,OAAO,EACN,qBAAqB,EACrB,oBAAoB,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;OAKG;IACH,MAAM,CAAC,eAAe,CAAC,KAAuB,EAAE,WAAwB;QACvE,KAAK,CAAC,gBAAgB,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC;QACrD,OAAO,KAAK,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,qBAAqB,CAAC,KAAuB,EAAE,WAAwB;QAC7E,KAAK,CAAC,gBAAgB,CAAC,6BAA6B,CAAC,WAAW,CAAC,CAAC,CAAC;QACnE,OAAO,KAAK,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,qBAAqB,CAAC,KAAuB,EAAE,WAAwB;QAC7E,KAAK,CAAC,gBAAgB,CAAC,iCAAiC,CAAC,WAAW,CAAC,CAAC,CAAC;QACvE,OAAO,KAAK,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CAAC,KAAuB,EAAE,WAAwB;QAC3E,IAAG,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;YACjC,KAAK,CAAC,mBAAmB,CAAC,CAAC,WAAW,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;CACD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { TurnContext } from '@microsoft/agents-hosting';
|
|
2
|
+
/**
|
|
3
|
+
* Extracts caller-related OpenTelemetry baggage pairs from the TurnContext.
|
|
4
|
+
* @param turnContext The current TurnContext (activity context)
|
|
5
|
+
* @returns Array of [key, value] pairs for caller identity and tenant
|
|
6
|
+
*/
|
|
7
|
+
export declare function getCallerBaggagePairs(turnContext: TurnContext): Array<[string, string]>;
|
|
8
|
+
/**
|
|
9
|
+
* Extracts the execution type baggage key-value pair based on caller and recipient agentic status.
|
|
10
|
+
* @param turnContext The current TurnContext (activity context)
|
|
11
|
+
* @returns Array of [key, value] for execution type
|
|
12
|
+
*/
|
|
13
|
+
export declare function getExecutionTypePair(turnContext: TurnContext): Array<[string, string]>;
|
|
14
|
+
/**
|
|
15
|
+
* Extracts agent/recipient-related OpenTelemetry baggage pairs from the TurnContext.
|
|
16
|
+
* @param turnContext The current TurnContext (activity context)
|
|
17
|
+
* @returns Array of [key, value] pairs for agent identity and description
|
|
18
|
+
*/
|
|
19
|
+
export declare function getTargetAgentBaggagePairs(turnContext: TurnContext): Array<[string, string]>;
|
|
20
|
+
/**
|
|
21
|
+
* Extracts the tenant ID baggage key-value pair, attempting to retrieve from ChannelData if necessary.
|
|
22
|
+
* @param turnContext The current TurnContext (activity context)
|
|
23
|
+
* @returns Array of [key, value] for tenant ID
|
|
24
|
+
*/
|
|
25
|
+
export declare function getTenantIdPair(turnContext: TurnContext): Array<[string, string]>;
|
|
26
|
+
/**
|
|
27
|
+
* Extracts source metadata baggage pairs from the TurnContext.
|
|
28
|
+
* @param turnContext The current TurnContext (activity context)
|
|
29
|
+
* @returns Array of [key, value] pairs for channel name and link
|
|
30
|
+
*/
|
|
31
|
+
export declare function getSourceMetadataBaggagePairs(turnContext: TurnContext): Array<[string, string]>;
|
|
32
|
+
/**
|
|
33
|
+
* Extracts conversation ID and item link baggage key-value pairs from the provided turn context.
|
|
34
|
+
* @param turnContext The current TurnContext (activity context)
|
|
35
|
+
* @returns Array of [key, value] pairs for conversation ID and item link
|
|
36
|
+
*/
|
|
37
|
+
export declare function getConversationIdAndItemLinkPairs(turnContext: TurnContext): Array<[string, string]>;
|
|
38
|
+
//# sourceMappingURL=TurnContextUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TurnContextUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/TurnContextUtils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAcxD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAevF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAkBtF;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,WAAW,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAgB5F;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,WAAW,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAoBjF;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,WAAW,EAAE,WAAW,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAS/F;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAAC,WAAW,EAAE,WAAW,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAWnG"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// ------------------------------------------------------------------------------
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
// ------------------------------------------------------------------------------
|
|
5
|
+
import { ExecutionType, OpenTelemetryConstants } from '@microsoft/agents-a365-observability';
|
|
6
|
+
import { RoleTypes } from '@microsoft/agents-activity';
|
|
7
|
+
/**
|
|
8
|
+
* TurnContext utility methods.
|
|
9
|
+
*/
|
|
10
|
+
function normalizePairs(pairs) {
|
|
11
|
+
return pairs
|
|
12
|
+
.filter(([, v]) => v != null && String(v).trim() !== '')
|
|
13
|
+
.map(([k, v]) => [k, String(v)]);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Extracts caller-related OpenTelemetry baggage pairs from the TurnContext.
|
|
17
|
+
* @param turnContext The current TurnContext (activity context)
|
|
18
|
+
* @returns Array of [key, value] pairs for caller identity and tenant
|
|
19
|
+
*/
|
|
20
|
+
export function getCallerBaggagePairs(turnContext) {
|
|
21
|
+
if (!turnContext || !turnContext.activity?.from) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
const from = turnContext.activity.from;
|
|
25
|
+
const upn = from.agenticUserId;
|
|
26
|
+
const pairs = [
|
|
27
|
+
[OpenTelemetryConstants.GEN_AI_CALLER_ID_KEY, from.aadObjectId],
|
|
28
|
+
[OpenTelemetryConstants.GEN_AI_CALLER_NAME_KEY, from.name],
|
|
29
|
+
[OpenTelemetryConstants.GEN_AI_CALLER_UPN_KEY, upn],
|
|
30
|
+
[OpenTelemetryConstants.GEN_AI_CALLER_TENANT_ID_KEY, from.tenantId],
|
|
31
|
+
[OpenTelemetryConstants.GEN_AI_AGENT_BLUEPRINT_ID_KEY, from.agenticAppBlueprintId]
|
|
32
|
+
];
|
|
33
|
+
return normalizePairs(pairs);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Extracts the execution type baggage key-value pair based on caller and recipient agentic status.
|
|
37
|
+
* @param turnContext The current TurnContext (activity context)
|
|
38
|
+
* @returns Array of [key, value] for execution type
|
|
39
|
+
*/
|
|
40
|
+
export function getExecutionTypePair(turnContext) {
|
|
41
|
+
if (!turnContext || !turnContext.activity?.from || !turnContext.activity?.recipient) {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
const from = turnContext.activity.from;
|
|
45
|
+
let executionType = ExecutionType.HumanToAgent;
|
|
46
|
+
if (from.role) {
|
|
47
|
+
switch (from.role) {
|
|
48
|
+
case RoleTypes.AgenticUser:
|
|
49
|
+
executionType = ExecutionType.Agent2Agent;
|
|
50
|
+
break;
|
|
51
|
+
case RoleTypes.User:
|
|
52
|
+
executionType = ExecutionType.HumanToAgent;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return [[OpenTelemetryConstants.GEN_AI_EXECUTION_TYPE_KEY, executionType]];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Extracts agent/recipient-related OpenTelemetry baggage pairs from the TurnContext.
|
|
60
|
+
* @param turnContext The current TurnContext (activity context)
|
|
61
|
+
* @returns Array of [key, value] pairs for agent identity and description
|
|
62
|
+
*/
|
|
63
|
+
export function getTargetAgentBaggagePairs(turnContext) {
|
|
64
|
+
if (!turnContext || !turnContext.activity?.recipient) {
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
const recipient = turnContext.activity.recipient;
|
|
68
|
+
const agentId = recipient.agenticAppId;
|
|
69
|
+
const agentName = recipient.name;
|
|
70
|
+
const aadObjectId = recipient.aadObjectId;
|
|
71
|
+
const agentDescription = recipient.role;
|
|
72
|
+
const pairs = [
|
|
73
|
+
[OpenTelemetryConstants.GEN_AI_AGENT_ID_KEY, agentId],
|
|
74
|
+
[OpenTelemetryConstants.GEN_AI_AGENT_NAME_KEY, agentName],
|
|
75
|
+
[OpenTelemetryConstants.GEN_AI_AGENT_AUID_KEY, aadObjectId],
|
|
76
|
+
[OpenTelemetryConstants.GEN_AI_AGENT_DESCRIPTION_KEY, agentDescription]
|
|
77
|
+
];
|
|
78
|
+
return normalizePairs(pairs);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Extracts the tenant ID baggage key-value pair, attempting to retrieve from ChannelData if necessary.
|
|
82
|
+
* @param turnContext The current TurnContext (activity context)
|
|
83
|
+
* @returns Array of [key, value] for tenant ID
|
|
84
|
+
*/
|
|
85
|
+
export function getTenantIdPair(turnContext) {
|
|
86
|
+
let tenantId = turnContext.activity?.recipient?.tenantId;
|
|
87
|
+
// If not found, try to extract from channelData. Accepts both object and JSON string.
|
|
88
|
+
if (!tenantId && turnContext.activity?.channelData) {
|
|
89
|
+
try {
|
|
90
|
+
let channelData = turnContext.activity.channelData;
|
|
91
|
+
if (typeof channelData === 'string') {
|
|
92
|
+
channelData = JSON.parse(channelData);
|
|
93
|
+
}
|
|
94
|
+
if (typeof channelData === 'object' && channelData !== null) {
|
|
95
|
+
tenantId = channelData?.tenant?.id;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch (_err) {
|
|
99
|
+
// ignore JSON parse errors
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return tenantId ? [[OpenTelemetryConstants.TENANT_ID_KEY, tenantId]] : [];
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Extracts source metadata baggage pairs from the TurnContext.
|
|
106
|
+
* @param turnContext The current TurnContext (activity context)
|
|
107
|
+
* @returns Array of [key, value] pairs for channel name and link
|
|
108
|
+
*/
|
|
109
|
+
export function getSourceMetadataBaggagePairs(turnContext) {
|
|
110
|
+
if (!turnContext) {
|
|
111
|
+
return [];
|
|
112
|
+
}
|
|
113
|
+
const pairs = [
|
|
114
|
+
[OpenTelemetryConstants.GEN_AI_EXECUTION_SOURCE_NAME_KEY, turnContext.activity?.channelId],
|
|
115
|
+
[OpenTelemetryConstants.GEN_AI_EXECUTION_SOURCE_DESCRIPTION_KEY, turnContext.activity?.channelIdSubChannel]
|
|
116
|
+
];
|
|
117
|
+
return normalizePairs(pairs);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Extracts conversation ID and item link baggage key-value pairs from the provided turn context.
|
|
121
|
+
* @param turnContext The current TurnContext (activity context)
|
|
122
|
+
* @returns Array of [key, value] pairs for conversation ID and item link
|
|
123
|
+
*/
|
|
124
|
+
export function getConversationIdAndItemLinkPairs(turnContext) {
|
|
125
|
+
if (!turnContext) {
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
const conversationId = turnContext.activity?.conversation?.id;
|
|
129
|
+
const itemLink = turnContext.activity?.serviceUrl;
|
|
130
|
+
const pairs = [
|
|
131
|
+
[OpenTelemetryConstants.GEN_AI_CONVERSATION_ID_KEY, conversationId],
|
|
132
|
+
[OpenTelemetryConstants.GEN_AI_CONVERSATION_ITEM_LINK_KEY, itemLink]
|
|
133
|
+
];
|
|
134
|
+
return normalizePairs(pairs);
|
|
135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AAC;IACZ,CAAC;IACD,MAAM,KAAK,GAAwC;QACjD,CAAC,sBAAsB,CAAC,gCAAgC,EAAE,WAAW,CAAC,QAAQ,EAAE,SAAS,CAAC;QAC1F,CAAC,sBAAsB,CAAC,uCAAuC,EAAE,WAAW,CAAC,QAAQ,EAAE,mBAAyC,CAAC;KAClI,CAAC;IACF,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iCAAiC,CAAC,WAAwB;IACxE,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,cAAc,GAAG,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,CAAC;IAC9D,MAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,EAAE,UAAU,CAAC;IAClD,MAAM,KAAK,GAAwC;QACjD,CAAC,sBAAsB,CAAC,0BAA0B,EAAE,cAAc,CAAC;QACnE,CAAC,sBAAsB,CAAC,iCAAiC,EAAE,QAAQ,CAAC;KACrE,CAAC;IACF,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@microsoft/agents-a365-observability-hosting",
|
|
3
|
+
"version": "0.1.0-preview.53",
|
|
4
|
+
"description": "Hosting & Observability utilities for Agent365 (Node.js): token caching, baggage builder, hosting registration.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"agent365",
|
|
7
|
+
"observability",
|
|
8
|
+
"telemetry",
|
|
9
|
+
"token",
|
|
10
|
+
"cache"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/microsoft/Agent365-nodejs",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/microsoft/Agent365-nodejs/issues"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/microsoft/Agent365-nodejs.git",
|
|
19
|
+
"directory": "packages/agents-a365-observability-hosting"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"author": "Microsoft",
|
|
23
|
+
"main": "./dist/cjs/index.js",
|
|
24
|
+
"module": "./dist/esm/index.js",
|
|
25
|
+
"types": "./dist/cjs/index.d.ts",
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"README.md",
|
|
29
|
+
"CHANGELOG.md"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "npm run build:cjs && npm run build:esm",
|
|
33
|
+
"build:cjs": "npx tsc --project tsconfig.cjs.json",
|
|
34
|
+
"build:esm": "npx tsc --project tsconfig.esm.json",
|
|
35
|
+
"build:watch": "npx tsc --watch",
|
|
36
|
+
"clean": "npx rimraf dist",
|
|
37
|
+
"lint": "eslint src/**/*.ts",
|
|
38
|
+
"lint:fix": "eslint src/**/*.ts --fix",
|
|
39
|
+
"test": "jest --passWithNoTests",
|
|
40
|
+
"test:watch": "jest --watch",
|
|
41
|
+
"test:coverage": "jest --coverage",
|
|
42
|
+
"pack": "npm pack --pack-destination=../"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@microsoft/agents-a365-observability": "0.1.0-preview.53",
|
|
46
|
+
"@microsoft/agents-a365-runtime": "0.1.0-preview.53",
|
|
47
|
+
"@microsoft/agents-hosting": "^1.1.0-alpha.85"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@eslint/js": "^9.39.1",
|
|
51
|
+
"@types/jest": "workspace:*",
|
|
52
|
+
"@types/node": "^20.0.0",
|
|
53
|
+
"@typescript-eslint/eslint-plugin": "^8.47.0",
|
|
54
|
+
"@typescript-eslint/parser": "^8.47.0",
|
|
55
|
+
"eslint": "^9.39.1",
|
|
56
|
+
"jest": "workspace:*",
|
|
57
|
+
"rimraf": "^6.0.0",
|
|
58
|
+
"ts-jest": "workspace:*",
|
|
59
|
+
"typescript": "^5.9.3",
|
|
60
|
+
"typescript-eslint": "^8.47.0"
|
|
61
|
+
},
|
|
62
|
+
"engines": {
|
|
63
|
+
"node": ">=18.0.0"
|
|
64
|
+
}
|
|
65
|
+
}
|