@dexto/core 1.12.0 → 1.13.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/dist/agent/DextoAgent.d.ts +2 -5
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/approval/index.cjs +4 -2
- package/dist/approval/index.d.ts +1 -1
- package/dist/approval/index.d.ts.map +1 -1
- package/dist/approval/index.js +3 -2
- package/dist/approval/manager.cjs +23 -4
- package/dist/approval/manager.d.ts +3 -2
- package/dist/approval/manager.d.ts.map +1 -1
- package/dist/approval/manager.js +21 -3
- package/dist/approval/schemas.cjs +5 -0
- package/dist/approval/schemas.d.ts +8 -0
- package/dist/approval/schemas.d.ts.map +1 -1
- package/dist/approval/schemas.js +5 -0
- package/dist/approval/types.d.ts +2 -2
- package/dist/approval/types.d.ts.map +1 -1
- package/dist/events/index.d.ts +2 -0
- package/dist/events/index.d.ts.map +1 -1
- package/dist/llm/executor/provider-options.cjs +6 -6
- package/dist/llm/executor/provider-options.d.ts.map +1 -1
- package/dist/llm/executor/provider-options.js +7 -8
- package/dist/llm/executor/turn-executor.cjs +13 -20
- package/dist/llm/executor/turn-executor.d.ts +0 -1
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +13 -20
- package/dist/mcp/errors.cjs +9 -0
- package/dist/mcp/errors.d.ts +4 -0
- package/dist/mcp/errors.d.ts.map +1 -1
- package/dist/mcp/errors.js +9 -0
- package/dist/mcp/manager.cjs +79 -3
- package/dist/mcp/manager.d.ts +14 -7
- package/dist/mcp/manager.d.ts.map +1 -1
- package/dist/mcp/manager.js +79 -3
- package/dist/mcp/mcp-client.cjs +52 -62
- package/dist/mcp/mcp-client.d.ts.map +1 -1
- package/dist/mcp/mcp-client.js +54 -63
- package/dist/storage/tool-executions/types.cjs +12 -8
- package/dist/storage/tool-executions/types.d.ts +9 -0
- package/dist/storage/tool-executions/types.d.ts.map +1 -1
- package/dist/storage/tool-executions/types.js +12 -8
- package/dist/telemetry/decorators.cjs +47 -23
- package/dist/telemetry/decorators.d.ts +6 -0
- package/dist/telemetry/decorators.d.ts.map +1 -1
- package/dist/telemetry/decorators.js +47 -23
- package/dist/telemetry/operation-span.cjs +5 -2
- package/dist/telemetry/operation-span.d.ts +3 -0
- package/dist/telemetry/operation-span.d.ts.map +1 -1
- package/dist/telemetry/operation-span.js +5 -2
- package/dist/tools/approval/tool-approval-policy.cjs +11 -1
- package/dist/tools/approval/tool-approval-policy.d.ts +2 -2
- package/dist/tools/approval/tool-approval-policy.d.ts.map +1 -1
- package/dist/tools/approval/tool-approval-policy.js +11 -1
- package/dist/tools/identity.cjs +36 -0
- package/dist/tools/identity.d.ts +6 -0
- package/dist/tools/identity.d.ts.map +1 -0
- package/dist/tools/identity.js +13 -0
- package/dist/tools/index.cjs +2 -0
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +4 -1
- package/dist/tools/presentation/tool-presentation.d.ts +5 -0
- package/dist/tools/presentation/tool-presentation.d.ts.map +1 -1
- package/dist/tools/schema-fingerprint.cjs +48 -0
- package/dist/tools/schema-fingerprint.d.ts +4 -0
- package/dist/tools/schema-fingerprint.d.ts.map +1 -0
- package/dist/tools/schema-fingerprint.js +25 -0
- package/dist/tools/schemas.cjs +3 -0
- package/dist/tools/schemas.d.ts +1 -0
- package/dist/tools/schemas.d.ts.map +1 -1
- package/dist/tools/schemas.js +2 -0
- package/dist/tools/tool-manager.cjs +160 -43
- package/dist/tools/tool-manager.d.ts +20 -11
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +160 -43
- package/dist/tools/types.d.ts +48 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/utils/schema.cjs +2 -2
- package/dist/utils/schema.d.ts +1 -1
- package/dist/utils/schema.d.ts.map +1 -1
- package/dist/utils/schema.js +2 -2
- package/dist/utils/stable-fingerprint.cjs +32 -0
- package/dist/utils/stable-fingerprint.d.ts +3 -0
- package/dist/utils/stable-fingerprint.d.ts.map +1 -0
- package/dist/utils/stable-fingerprint.js +9 -0
- package/package.json +9 -2
|
@@ -10,6 +10,9 @@ import { hasActiveTelemetry, getBaggageValues } from "./utils.js";
|
|
|
10
10
|
import { safeStringify } from "../utils/safe-stringify.js";
|
|
11
11
|
import { getHostRuntimeAttributes, getHostRuntimeBaggageEntries } from "../runtime/index.js";
|
|
12
12
|
function withSpan(options) {
|
|
13
|
+
const captureArguments = options.captureArguments ?? true;
|
|
14
|
+
const captureErrors = options.captureErrors ?? true;
|
|
15
|
+
const captureResult = options.captureResult ?? true;
|
|
13
16
|
return function(_target, propertyKey, descriptor) {
|
|
14
17
|
if (!descriptor || typeof descriptor === "number") return;
|
|
15
18
|
const originalMethod = descriptor.value;
|
|
@@ -46,9 +49,14 @@ function withSpan(options) {
|
|
|
46
49
|
const effectiveHostRuntime = hostRuntime;
|
|
47
50
|
const effectiveRunId = effectiveHostRuntime?.ids?.runId ?? runId;
|
|
48
51
|
const applySpanAttributes = (span) => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
if (captureArguments) {
|
|
53
|
+
args.forEach((arg, index) => {
|
|
54
|
+
span.setAttribute(
|
|
55
|
+
`${spanName}.argument.${index}`,
|
|
56
|
+
safeStringify(arg, 8192)
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
52
60
|
if (sessionId) {
|
|
53
61
|
span.setAttribute("sessionId", sessionId);
|
|
54
62
|
span.setAttribute("baggage.sessionId", sessionId);
|
|
@@ -142,36 +150,49 @@ function withSpan(options) {
|
|
|
142
150
|
result = originalMethod.apply(this, args);
|
|
143
151
|
if (result instanceof Promise) {
|
|
144
152
|
return result.then((resolvedValue) => {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
153
|
+
if (captureResult) {
|
|
154
|
+
span.setAttribute(
|
|
155
|
+
`${spanName}.result`,
|
|
156
|
+
safeStringify(resolvedValue, 8192)
|
|
157
|
+
);
|
|
158
|
+
}
|
|
149
159
|
return resolvedValue;
|
|
150
160
|
}).catch((error) => {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
161
|
+
if (captureErrors) {
|
|
162
|
+
span.recordException(error);
|
|
163
|
+
span.setStatus({
|
|
164
|
+
code: SpanStatusCode.ERROR,
|
|
165
|
+
message: error?.toString()
|
|
166
|
+
});
|
|
167
|
+
} else {
|
|
168
|
+
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
169
|
+
}
|
|
156
170
|
throw error;
|
|
157
171
|
}).finally(() => {
|
|
158
172
|
span.end();
|
|
159
173
|
});
|
|
160
174
|
}
|
|
161
|
-
|
|
175
|
+
if (captureResult) {
|
|
176
|
+
span.setAttribute(`${spanName}.result`, safeStringify(result, 8192));
|
|
177
|
+
}
|
|
162
178
|
return result;
|
|
163
179
|
} catch (error) {
|
|
164
180
|
const logger2 = this?.logger;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
181
|
+
if (captureErrors) {
|
|
182
|
+
logger2?.error(
|
|
183
|
+
`withSpan: Error in method '${methodName}': ${error instanceof Error ? error.message : String(error)}`,
|
|
184
|
+
{ error }
|
|
185
|
+
);
|
|
186
|
+
span.setStatus({
|
|
187
|
+
code: SpanStatusCode.ERROR,
|
|
188
|
+
message: error instanceof Error ? error.message : "Unknown error"
|
|
189
|
+
});
|
|
190
|
+
if (error instanceof Error) {
|
|
191
|
+
span.recordException(error);
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
logger2?.error(`withSpan: Error in method '${methodName}'`);
|
|
195
|
+
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
175
196
|
}
|
|
176
197
|
throw error;
|
|
177
198
|
} finally {
|
|
@@ -198,6 +219,9 @@ function InstrumentClass(options) {
|
|
|
198
219
|
target.prototype,
|
|
199
220
|
method,
|
|
200
221
|
withSpan({
|
|
222
|
+
captureArguments: options?.captureArguments ?? true,
|
|
223
|
+
captureErrors: options?.captureErrors ?? true,
|
|
224
|
+
captureResult: options?.captureResult ?? true,
|
|
201
225
|
spanName: options?.prefix ? `${options.prefix}.${method}` : method,
|
|
202
226
|
skipIfNoTelemetry: true,
|
|
203
227
|
spanKind: options?.spanKind || SpanKind.INTERNAL,
|
|
@@ -28,7 +28,8 @@ async function recordOperationSpan(options, operation, logger) {
|
|
|
28
28
|
if (skipIfNoTelemetry && !(0, import_utils.hasActiveTelemetry)(logger)) {
|
|
29
29
|
return operation();
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
const spanKind = options.spanKind ?? import_api.SpanKind.INTERNAL;
|
|
32
|
+
return import_api.trace.getTracer(options.tracerName ?? "dexto").startActiveSpan(options.name, { kind: spanKind }, async (span) => {
|
|
32
33
|
const spanContext = import_api.trace.setSpan(import_api.context.active(), span);
|
|
33
34
|
(0, import_utils.addBaggageAttributesToSpan)(span, spanContext, logger);
|
|
34
35
|
if (options.componentName !== void 0) {
|
|
@@ -48,7 +49,9 @@ async function recordOperationSpan(options, operation, logger) {
|
|
|
48
49
|
span.setStatus({ code: import_api.SpanStatusCode.OK });
|
|
49
50
|
return result;
|
|
50
51
|
} catch (error) {
|
|
51
|
-
if (
|
|
52
|
+
if (!(options.captureErrors ?? true)) {
|
|
53
|
+
span.setStatus({ code: import_api.SpanStatusCode.ERROR });
|
|
54
|
+
} else if (error instanceof Error) {
|
|
52
55
|
span.recordException(error);
|
|
53
56
|
span.setStatus({ code: import_api.SpanStatusCode.ERROR, message: error.message });
|
|
54
57
|
} else {
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import { SpanKind } from '@opentelemetry/api';
|
|
1
2
|
import type { Logger } from '../logger/v2/types.js';
|
|
2
3
|
type OperationSpanAttributes = Record<string, string | number | boolean>;
|
|
3
4
|
export type OperationSpanOptions<T> = {
|
|
4
5
|
attributes?: OperationSpanAttributes;
|
|
6
|
+
captureErrors?: boolean;
|
|
5
7
|
componentName?: string;
|
|
6
8
|
name: string;
|
|
7
9
|
resultAttributes?: (result: T) => OperationSpanAttributes | undefined;
|
|
8
10
|
skipIfNoTelemetry?: boolean;
|
|
11
|
+
spanKind?: SpanKind;
|
|
9
12
|
tracerName?: string;
|
|
10
13
|
};
|
|
11
14
|
export declare function recordOperationSpan<T>(options: OperationSpanOptions<T>, operation: () => T | Promise<T>, logger?: Logger): Promise<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-span.d.ts","sourceRoot":"","sources":["../../src/telemetry/operation-span.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"operation-span.d.ts","sourceRoot":"","sources":["../../src/telemetry/operation-span.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,QAAQ,EAAyB,MAAM,oBAAoB,CAAC;AAE9E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,KAAK,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;AAEzE,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI;IAClC,UAAU,CAAC,EAAE,uBAAuB,CAAC;IACrC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,uBAAuB,GAAG,SAAS,CAAC;IACtE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,wBAAsB,mBAAmB,CAAC,CAAC,EACvC,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAChC,SAAS,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAC/B,MAAM,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,CAAC,CAAC,CA6CZ"}
|
|
@@ -6,7 +6,8 @@ async function recordOperationSpan(options, operation, logger) {
|
|
|
6
6
|
if (skipIfNoTelemetry && !hasActiveTelemetry(logger)) {
|
|
7
7
|
return operation();
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
const spanKind = options.spanKind ?? SpanKind.INTERNAL;
|
|
10
|
+
return trace.getTracer(options.tracerName ?? "dexto").startActiveSpan(options.name, { kind: spanKind }, async (span) => {
|
|
10
11
|
const spanContext = trace.setSpan(context.active(), span);
|
|
11
12
|
addBaggageAttributesToSpan(span, spanContext, logger);
|
|
12
13
|
if (options.componentName !== void 0) {
|
|
@@ -26,7 +27,9 @@ async function recordOperationSpan(options, operation, logger) {
|
|
|
26
27
|
span.setStatus({ code: SpanStatusCode.OK });
|
|
27
28
|
return result;
|
|
28
29
|
} catch (error) {
|
|
29
|
-
if (
|
|
30
|
+
if (!(options.captureErrors ?? true)) {
|
|
31
|
+
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
32
|
+
} else if (error instanceof Error) {
|
|
30
33
|
span.recordException(error);
|
|
31
34
|
span.setStatus({ code: SpanStatusCode.ERROR, message: error.message });
|
|
32
35
|
} else {
|
|
@@ -52,10 +52,20 @@ class ToolApprovalPolicy {
|
|
|
52
52
|
kind: "approval-required"
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
|
+
if (input.identity.type === "mcp") {
|
|
56
|
+
const approvalKey = `mcp:${encodeURIComponent(input.identity.connectionId)}:${encodeURIComponent(input.identity.toolName)}`;
|
|
57
|
+
if (this.deps.isApprovalKeySessionApproved({
|
|
58
|
+
approvalKey,
|
|
59
|
+
...input.sessionId !== void 0 ? { sessionId: input.sessionId } : {}
|
|
60
|
+
})) {
|
|
61
|
+
return { kind: "ready" };
|
|
62
|
+
}
|
|
63
|
+
return { approvalKey, kind: "approval-required" };
|
|
64
|
+
}
|
|
55
65
|
return { kind: "approval-required" };
|
|
56
66
|
}
|
|
57
67
|
async resolveAuthoredPolicy(input) {
|
|
58
|
-
if (input.
|
|
68
|
+
if (input.identity.type !== "local") {
|
|
59
69
|
return { kind: "none" };
|
|
60
70
|
}
|
|
61
71
|
const needsApproval = this.deps.getLocalTool(input.toolName)?.needsApproval;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Tool, ToolExecutionContext } from '../types.js';
|
|
1
|
+
import type { Tool, ToolExecutionContext, ToolIdentity } from '../types.js';
|
|
2
2
|
export type ToolApprovalGate = {
|
|
3
3
|
kind: 'ready';
|
|
4
4
|
} | {
|
|
@@ -8,8 +8,8 @@ export type ToolApprovalGate = {
|
|
|
8
8
|
export type ToolApprovalPolicyInput = {
|
|
9
9
|
args: Record<string, unknown>;
|
|
10
10
|
getContext: () => ToolExecutionContext;
|
|
11
|
+
identity: ToolIdentity;
|
|
11
12
|
sessionId?: string | undefined;
|
|
12
|
-
source: 'local' | 'mcp';
|
|
13
13
|
toolName: string;
|
|
14
14
|
};
|
|
15
15
|
export type ToolApprovalPolicyDeps = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-approval-policy.d.ts","sourceRoot":"","sources":["../../../src/tools/approval/tool-approval-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAwB,oBAAoB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-approval-policy.d.ts","sourceRoot":"","sources":["../../../src/tools/approval/tool-approval-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAwB,oBAAoB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGlG,MAAM,MAAM,gBAAgB,GACtB;IACI,IAAI,EAAE,OAAO,CAAC;CACjB,GACD;IACI,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,IAAI,EAAE,mBAAmB,CAAC;CAC7B,CAAC;AAcR,MAAM,MAAM,uBAAuB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,UAAU,EAAE,MAAM,oBAAoB,CAAC;IACvC,QAAQ,EAAE,YAAY,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACjC,eAAe,IAAI,QAAQ,GAAG,cAAc,CAAC;IAC7C,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACjD,4BAA4B,CAAC,KAAK,EAAE;QAChC,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAClC,GAAG,OAAO,CAAC;IACZ,uBAAuB,CAAC,KAAK,EAAE;QAC3B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,QAAQ,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CAClC,CAAC;AAEF,qBAAa,kBAAkB;IACf,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,sBAAsB;IAEnD,OAAO,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC;YAsD1D,qBAAqB;IA8BnC,OAAO,CAAC,wBAAwB;CASnC"}
|
|
@@ -30,10 +30,20 @@ class ToolApprovalPolicy {
|
|
|
30
30
|
kind: "approval-required"
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
+
if (input.identity.type === "mcp") {
|
|
34
|
+
const approvalKey = `mcp:${encodeURIComponent(input.identity.connectionId)}:${encodeURIComponent(input.identity.toolName)}`;
|
|
35
|
+
if (this.deps.isApprovalKeySessionApproved({
|
|
36
|
+
approvalKey,
|
|
37
|
+
...input.sessionId !== void 0 ? { sessionId: input.sessionId } : {}
|
|
38
|
+
})) {
|
|
39
|
+
return { kind: "ready" };
|
|
40
|
+
}
|
|
41
|
+
return { approvalKey, kind: "approval-required" };
|
|
42
|
+
}
|
|
33
43
|
return { kind: "approval-required" };
|
|
34
44
|
}
|
|
35
45
|
async resolveAuthoredPolicy(input) {
|
|
36
|
-
if (input.
|
|
46
|
+
if (input.identity.type !== "local") {
|
|
37
47
|
return { kind: "none" };
|
|
38
48
|
}
|
|
39
49
|
const needsApproval = this.deps.getLocalTool(input.toolName)?.needsApproval;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var identity_exports = {};
|
|
20
|
+
__export(identity_exports, {
|
|
21
|
+
ToolIdentitySchema: () => ToolIdentitySchema
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(identity_exports);
|
|
24
|
+
var import_zod = require("zod");
|
|
25
|
+
const ToolIdentitySchema = import_zod.z.discriminatedUnion("type", [
|
|
26
|
+
import_zod.z.object({ type: import_zod.z.literal("local"), toolId: import_zod.z.string() }).strict(),
|
|
27
|
+
import_zod.z.object({
|
|
28
|
+
type: import_zod.z.literal("mcp"),
|
|
29
|
+
connectionId: import_zod.z.string(),
|
|
30
|
+
toolName: import_zod.z.string()
|
|
31
|
+
}).strict()
|
|
32
|
+
]);
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
ToolIdentitySchema
|
|
36
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ToolIdentity } from './types.js';
|
|
3
|
+
/** Browser-safe schema for the canonical identity of one local or MCP tool. */
|
|
4
|
+
export declare const ToolIdentitySchema: z.ZodType<ToolIdentity>;
|
|
5
|
+
export type { ToolIdentity } from './types.js';
|
|
6
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/tools/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,+EAA+E;AAC/E,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CASrD,CAAC;AAEH,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import "../chunk-C6A6W6XS.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
const ToolIdentitySchema = z.discriminatedUnion("type", [
|
|
4
|
+
z.object({ type: z.literal("local"), toolId: z.string() }).strict(),
|
|
5
|
+
z.object({
|
|
6
|
+
type: z.literal("mcp"),
|
|
7
|
+
connectionId: z.string(),
|
|
8
|
+
toolName: z.string()
|
|
9
|
+
}).strict()
|
|
10
|
+
]);
|
|
11
|
+
export {
|
|
12
|
+
ToolIdentitySchema
|
|
13
|
+
};
|
package/dist/tools/index.cjs
CHANGED
|
@@ -36,6 +36,7 @@ __reExport(tools_exports, require("./display-types.js"), module.exports);
|
|
|
36
36
|
__reExport(tools_exports, require("./activity.js"), module.exports);
|
|
37
37
|
var import_presentation_schema = require("./presentation-schema.js");
|
|
38
38
|
__reExport(tools_exports, require("./schemas.js"), module.exports);
|
|
39
|
+
__reExport(tools_exports, require("./schema-fingerprint.js"), module.exports);
|
|
39
40
|
__reExport(tools_exports, require("./presentation.js"), module.exports);
|
|
40
41
|
var import_errors = require("./errors.js");
|
|
41
42
|
var import_error_codes = require("./error-codes.js");
|
|
@@ -54,5 +55,6 @@ var import_tool_manager = require("./tool-manager.js");
|
|
|
54
55
|
...require("./display-types.js"),
|
|
55
56
|
...require("./activity.js"),
|
|
56
57
|
...require("./schemas.js"),
|
|
58
|
+
...require("./schema-fingerprint.js"),
|
|
57
59
|
...require("./presentation.js")
|
|
58
60
|
});
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -13,10 +13,11 @@ export * from './activity.js';
|
|
|
13
13
|
export { isToolPresentationSnapshotV1, ToolPresentationSnapshotV1Schema, } from './presentation-schema.js';
|
|
14
14
|
export type { ToolPresentationSnapshotV1 } from './presentation-schema.js';
|
|
15
15
|
export * from './schemas.js';
|
|
16
|
+
export * from './schema-fingerprint.js';
|
|
16
17
|
export * from './presentation.js';
|
|
17
18
|
export type { ToolCallMetadata, ToolCallMetaWrapper } from './tool-call-metadata.js';
|
|
18
19
|
export { ToolError } from './errors.js';
|
|
19
20
|
export { ToolErrorCode } from './error-codes.js';
|
|
20
|
-
export { ToolManager, type ToolExecutionContextFactory } from './tool-manager.js';
|
|
21
|
+
export { ToolManager, type ToolExecutionContextFactory, type ToolExecutionInvocation, } from './tool-manager.js';
|
|
21
22
|
export type { ExecutableToolCall, RecordedToolApproval, ToolApprovalDecisionApplication, ToolApprovalRecordIdentity, ApprovalRequiredPreparedToolCall, PreparedToolCall, PrepareToolCallInput, } from './tool-manager.js';
|
|
22
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,YAAY,CAAC;AAG3B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACH,4BAA4B,EAC5B,2BAA2B,GAC9B,MAAM,qCAAqC,CAAC;AAC7C,YAAY,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAGlF,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,OAAO,EACH,4BAA4B,EAC5B,gCAAgC,GACnC,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAG3E,cAAc,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,YAAY,CAAC;AAG3B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACH,4BAA4B,EAC5B,2BAA2B,GAC9B,MAAM,qCAAqC,CAAC;AAC7C,YAAY,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAGlF,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,OAAO,EACH,4BAA4B,EAC5B,gCAAgC,GACnC,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAG3E,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AAGxC,cAAc,mBAAmB,CAAC;AAClC,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAGrF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EACH,WAAW,EACX,KAAK,2BAA2B,EAChC,KAAK,uBAAuB,GAC/B,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACR,kBAAkB,EAClB,oBAAoB,EACpB,+BAA+B,EAC/B,0BAA0B,EAC1B,gCAAgC,EAChC,gBAAgB,EAChB,oBAAoB,GACvB,MAAM,mBAAmB,CAAC"}
|
package/dist/tools/index.js
CHANGED
|
@@ -12,10 +12,13 @@ import {
|
|
|
12
12
|
ToolPresentationSnapshotV1Schema
|
|
13
13
|
} from "./presentation-schema.js";
|
|
14
14
|
export * from "./schemas.js";
|
|
15
|
+
export * from "./schema-fingerprint.js";
|
|
15
16
|
export * from "./presentation.js";
|
|
16
17
|
import { ToolError } from "./errors.js";
|
|
17
18
|
import { ToolErrorCode } from "./error-codes.js";
|
|
18
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
ToolManager
|
|
21
|
+
} from "./tool-manager.js";
|
|
19
22
|
export {
|
|
20
23
|
SessionToolPreferencesSchema,
|
|
21
24
|
SessionToolPreferencesStore,
|
|
@@ -5,6 +5,7 @@ import { type ToolDisplayData } from '../display-types.js';
|
|
|
5
5
|
type BuildToolExecutionContext = (options: {
|
|
6
6
|
sessionId?: string | undefined;
|
|
7
7
|
toolCallId?: string | undefined;
|
|
8
|
+
parentToolCallId?: string | undefined;
|
|
8
9
|
runContext?: AgentRunContext | undefined;
|
|
9
10
|
}) => ToolExecutionContext;
|
|
10
11
|
export declare class ToolPresentation {
|
|
@@ -18,6 +19,7 @@ export declare class ToolPresentation {
|
|
|
18
19
|
toolName: string;
|
|
19
20
|
args: Record<string, unknown>;
|
|
20
21
|
toolCallId: string;
|
|
22
|
+
parentToolCallId?: string | undefined;
|
|
21
23
|
sessionId?: string | undefined;
|
|
22
24
|
runContext?: AgentRunContext | undefined;
|
|
23
25
|
}): ToolPresentationSnapshotV1;
|
|
@@ -25,6 +27,7 @@ export declare class ToolPresentation {
|
|
|
25
27
|
toolName: string;
|
|
26
28
|
args: Record<string, unknown>;
|
|
27
29
|
toolCallId: string;
|
|
30
|
+
parentToolCallId?: string | undefined;
|
|
28
31
|
sessionId?: string | undefined;
|
|
29
32
|
runContext?: AgentRunContext | undefined;
|
|
30
33
|
}): Promise<ToolPresentationSnapshotV1>;
|
|
@@ -34,6 +37,7 @@ export declare class ToolPresentation {
|
|
|
34
37
|
result: unknown;
|
|
35
38
|
args: Record<string, unknown>;
|
|
36
39
|
toolCallId: string;
|
|
40
|
+
parentToolCallId?: string | undefined;
|
|
37
41
|
sessionId?: string | undefined;
|
|
38
42
|
runContext?: AgentRunContext | undefined;
|
|
39
43
|
}): Promise<ToolPresentationSnapshotV1>;
|
|
@@ -51,6 +55,7 @@ export declare class ToolPresentation {
|
|
|
51
55
|
toolName: string;
|
|
52
56
|
args: Record<string, unknown>;
|
|
53
57
|
toolCallId: string;
|
|
58
|
+
parentToolCallId?: string | undefined;
|
|
54
59
|
sessionId?: string | undefined;
|
|
55
60
|
runContext?: AgentRunContext | undefined;
|
|
56
61
|
}): Promise<ToolDisplayData | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-presentation.d.ts","sourceRoot":"","sources":["../../../src/tools/presentation/tool-presentation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,OAAO,KAAK,EACR,IAAI,EACJ,oBAAoB,EACpB,0BAA0B,EAC1B,0BAA0B,EAC7B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAI/E,KAAK,yBAAyB,GAAG,CAAC,OAAO,EAAE;IACvC,SAAS,CAAC,EAAE,MAAM,GAAG,S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AC,QAAQ,EAAE,MAAM,GAAG,0BAA0B,GAAG,SAAS;IAQ7E,OAAO,CAAC,kBAAkB;IAQpB,OAAO,CAAC,KAAK,EAAE;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC9B,UAAU,EAAE,MAAM,CAAC;QACnB,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACtC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,UAAU,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;KAC5C,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAgCxC,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,WAAW;CAQtB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var schema_fingerprint_exports = {};
|
|
20
|
+
__export(schema_fingerprint_exports, {
|
|
21
|
+
toolSchemaFingerprint: () => toolSchemaFingerprint
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(schema_fingerprint_exports);
|
|
24
|
+
var import_stable_fingerprint = require("../utils/stable-fingerprint.js");
|
|
25
|
+
function toolSchemaFingerprint(inputSchema, outputSchema) {
|
|
26
|
+
return (0, import_stable_fingerprint.stableFingerprint)(
|
|
27
|
+
canonicalJson({ inputSchema, ...outputSchema === void 0 ? {} : { outputSchema } })
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
function canonicalJson(value) {
|
|
31
|
+
if (value === null) return "null";
|
|
32
|
+
if (Array.isArray(value)) {
|
|
33
|
+
return `[${value.map((entry) => canonicalJson(entry ?? null)).join(",")}]`;
|
|
34
|
+
}
|
|
35
|
+
if (typeof value === "object") {
|
|
36
|
+
const properties = Object.entries(value).filter(([, entry]) => entry !== void 0).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([key, entry]) => `${JSON.stringify(key)}:${canonicalJson(entry)}`);
|
|
37
|
+
return `{${properties.join(",")}}`;
|
|
38
|
+
}
|
|
39
|
+
const serialized = JSON.stringify(value);
|
|
40
|
+
if (serialized === void 0) {
|
|
41
|
+
throw new Error(`Tool schema contains a non-JSON ${typeof value} value.`);
|
|
42
|
+
}
|
|
43
|
+
return serialized;
|
|
44
|
+
}
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
toolSchemaFingerprint
|
|
48
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { JSONSchema7 } from 'json-schema';
|
|
2
|
+
/** Fingerprints the callable input/output contract independent of object key order. */
|
|
3
|
+
export declare function toolSchemaFingerprint(inputSchema: JSONSchema7, outputSchema?: JSONSchema7): string;
|
|
4
|
+
//# sourceMappingURL=schema-fingerprint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-fingerprint.d.ts","sourceRoot":"","sources":["../../src/tools/schema-fingerprint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,uFAAuF;AACvF,wBAAgB,qBAAqB,CACjC,WAAW,EAAE,WAAW,EACxB,YAAY,CAAC,EAAE,WAAW,GAC3B,MAAM,CAIR"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "../chunk-C6A6W6XS.js";
|
|
2
|
+
import { stableFingerprint } from "../utils/stable-fingerprint.js";
|
|
3
|
+
function toolSchemaFingerprint(inputSchema, outputSchema) {
|
|
4
|
+
return stableFingerprint(
|
|
5
|
+
canonicalJson({ inputSchema, ...outputSchema === void 0 ? {} : { outputSchema } })
|
|
6
|
+
);
|
|
7
|
+
}
|
|
8
|
+
function canonicalJson(value) {
|
|
9
|
+
if (value === null) return "null";
|
|
10
|
+
if (Array.isArray(value)) {
|
|
11
|
+
return `[${value.map((entry) => canonicalJson(entry ?? null)).join(",")}]`;
|
|
12
|
+
}
|
|
13
|
+
if (typeof value === "object") {
|
|
14
|
+
const properties = Object.entries(value).filter(([, entry]) => entry !== void 0).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([key, entry]) => `${JSON.stringify(key)}:${canonicalJson(entry)}`);
|
|
15
|
+
return `{${properties.join(",")}}`;
|
|
16
|
+
}
|
|
17
|
+
const serialized = JSON.stringify(value);
|
|
18
|
+
if (serialized === void 0) {
|
|
19
|
+
throw new Error(`Tool schema contains a non-JSON ${typeof value} value.`);
|
|
20
|
+
}
|
|
21
|
+
return serialized;
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
toolSchemaFingerprint
|
|
25
|
+
};
|
package/dist/tools/schemas.cjs
CHANGED
|
@@ -24,12 +24,14 @@ __export(schemas_exports, {
|
|
|
24
24
|
ElicitationConfigSchema: () => ElicitationConfigSchema,
|
|
25
25
|
PERMISSIONS_MODES: () => PERMISSIONS_MODES,
|
|
26
26
|
PermissionsConfigSchema: () => PermissionsConfigSchema,
|
|
27
|
+
ToolIdentitySchema: () => import_identity.ToolIdentitySchema,
|
|
27
28
|
ToolLimitsSchema: () => ToolLimitsSchema,
|
|
28
29
|
ToolPoliciesSchema: () => ToolPoliciesSchema,
|
|
29
30
|
ToolsConfigSchema: () => ToolsConfigSchema
|
|
30
31
|
});
|
|
31
32
|
module.exports = __toCommonJS(schemas_exports);
|
|
32
33
|
var import_zod = require("zod");
|
|
34
|
+
var import_identity = require("./identity.js");
|
|
33
35
|
const PERMISSIONS_MODES = ["manual", "auto-approve"];
|
|
34
36
|
const ALLOWED_TOOLS_STORAGE_TYPES = ["memory", "storage"];
|
|
35
37
|
const DEFAULT_PERMISSIONS_MODE = "auto-approve";
|
|
@@ -75,6 +77,7 @@ const ToolsConfigSchema = import_zod.z.record(import_zod.z.string(), ToolLimitsS
|
|
|
75
77
|
ElicitationConfigSchema,
|
|
76
78
|
PERMISSIONS_MODES,
|
|
77
79
|
PermissionsConfigSchema,
|
|
80
|
+
ToolIdentitySchema,
|
|
78
81
|
ToolLimitsSchema,
|
|
79
82
|
ToolPoliciesSchema,
|
|
80
83
|
ToolsConfigSchema
|
package/dist/tools/schemas.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
export { ToolIdentitySchema } from './identity.js';
|
|
2
3
|
export declare const PERMISSIONS_MODES: readonly ["manual", "auto-approve"];
|
|
3
4
|
export type PermissionsMode = (typeof PERMISSIONS_MODES)[number];
|
|
4
5
|
export declare const ALLOWED_TOOLS_STORAGE_TYPES: readonly ["memory", "storage"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/tools/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/tools/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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A6W6XS.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import { ToolIdentitySchema } from "./identity.js";
|
|
3
4
|
const PERMISSIONS_MODES = ["manual", "auto-approve"];
|
|
4
5
|
const ALLOWED_TOOLS_STORAGE_TYPES = ["memory", "storage"];
|
|
5
6
|
const DEFAULT_PERMISSIONS_MODE = "auto-approve";
|
|
@@ -44,6 +45,7 @@ export {
|
|
|
44
45
|
ElicitationConfigSchema,
|
|
45
46
|
PERMISSIONS_MODES,
|
|
46
47
|
PermissionsConfigSchema,
|
|
48
|
+
ToolIdentitySchema,
|
|
47
49
|
ToolLimitsSchema,
|
|
48
50
|
ToolPoliciesSchema,
|
|
49
51
|
ToolsConfigSchema
|