@meetsmore-oss/use-ai-server 1.8.0 → 1.9.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/agents/AISDKAgent.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +181 -85
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/mcpConfirmation.d.ts +23 -0
- package/dist/mcp/mcpConfirmation.d.ts.map +1 -0
- package/dist/mcp/mcpConfirmation.test.d.ts +2 -0
- package/dist/mcp/mcpConfirmation.test.d.ts.map +1 -0
- package/dist/mcp/useAIInternalResponse.d.ts +5 -0
- package/dist/mcp/useAIInternalResponse.d.ts.map +1 -0
- package/dist/mcp/useAIInternalResponse.test.d.ts +2 -0
- package/dist/mcp/useAIInternalResponse.test.d.ts.map +1 -0
- package/dist/src/agents/AISDKAgent.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/mcp/index.d.ts +2 -0
- package/dist/src/mcp/index.d.ts.map +1 -1
- package/dist/src/mcp/mcpConfirmation.d.ts +23 -0
- package/dist/src/mcp/mcpConfirmation.d.ts.map +1 -0
- package/dist/src/mcp/mcpConfirmation.test.d.ts +2 -0
- package/dist/src/mcp/mcpConfirmation.test.d.ts.map +1 -0
- package/dist/src/mcp/useAIInternalResponse.d.ts +5 -0
- package/dist/src/mcp/useAIInternalResponse.d.ts.map +1 -0
- package/dist/src/mcp/useAIInternalResponse.test.d.ts +2 -0
- package/dist/src/mcp/useAIInternalResponse.test.d.ts.map +1 -0
- package/dist/src/tools/serverToolExecutor.d.ts +3 -2
- package/dist/src/tools/serverToolExecutor.d.ts.map +1 -1
- package/dist/src/tools/types.d.ts +14 -0
- package/dist/src/tools/types.d.ts.map +1 -1
- package/dist/tools/serverToolExecutor.d.ts +3 -2
- package/dist/tools/serverToolExecutor.d.ts.map +1 -1
- package/dist/tools/types.d.ts +14 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AISDKAgent.d.ts","sourceRoot":"","sources":["../../../src/agents/AISDKAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,aAAa,EAA2D,MAAM,IAAI,CAAC;AAKpH,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAiB,MAAM,SAAS,CAAC;AAC3F,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"AISDKAgent.d.ts","sourceRoot":"","sources":["../../../src/agents/AISDKAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,aAAa,EAA2D,MAAM,IAAI,CAAC;AAKpH,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAiB,MAAM,SAAS,CAAC;AAC3F,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,UAAU,CAAC;AAyBpE,OAAO,EAAyB,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAkBjF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;;;;;;;;;OAkBG;IACH,KAAK,EAAE,aAAa,CAAC;IAErB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;;;;;;;OAUG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAEzD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAA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C;IAEX,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAAqB,CAKlC;IAEX,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAG9B;IAEX,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAG/B;IAEX,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAI9B;IAEX;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,4BAA4B,CAWhD;IAEJ,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAOtC;IAEH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAM1B;IAEX,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAqC;IAEhF;;;;;;;;OAQG;IACH,OAAO,CAAC,gBAAgB;CAgBzB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,5 +10,6 @@ export { logger } from './logger';
|
|
|
10
10
|
export { startRunSpan, flushTelemetry, type RunSpan } from './telemetry';
|
|
11
11
|
export { defineServerTool } from './tools';
|
|
12
12
|
export type { ServerToolConfig, ServerToolContext, ServerToolDefinition } from './tools';
|
|
13
|
+
export { isUseAIInternalResponse, type UseAIInternalResponseBase, type UseAIInternalResponse, isMcpConfirmationResponse, type McpConfirmationResponse, } from './mcp';
|
|
13
14
|
export { createClientToolExecutor, isRemoteTool, isServerTool, getToolAnnotations, createGlobFilter, and, or, not, } from './utils';
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACjG,YAAY,EAAE,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uBAAuB,EAAE,KAAK,QAAQ,EAAE,KAAK,qBAAqB,EAAE,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAG9J,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG3C,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAGzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAGzF,OAAO,EACL,uBAAuB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,yBAAyB,EACzB,KAAK,uBAAuB,GAC7B,MAAM,OAAO,CAAC;AAGf,OAAO,EACL,wBAAwB,EACxB,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,GAAG,EACH,EAAE,EACF,GAAG,GACJ,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -85732,6 +85732,17 @@ var ErrorCode;
|
|
|
85732
85732
|
ErrorCode2["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
85733
85733
|
})(ErrorCode ||= {});
|
|
85734
85734
|
var TOOL_APPROVAL_REQUEST = "TOOL_APPROVAL_REQUEST";
|
|
85735
|
+
function asRecord(value) {
|
|
85736
|
+
return value != null && typeof value === "object" ? value : null;
|
|
85737
|
+
}
|
|
85738
|
+
function isMcpConfirmationResponse(value) {
|
|
85739
|
+
const obj = asRecord(value);
|
|
85740
|
+
const metadata = obj ? asRecord(obj._use_ai_metadata) : null;
|
|
85741
|
+
return !!(obj && obj._use_ai_internal === true && obj._use_ai_type === "confirmation_required" && metadata && typeof metadata.message === "string");
|
|
85742
|
+
}
|
|
85743
|
+
function isUseAIInternalResponse(value) {
|
|
85744
|
+
return isMcpConfirmationResponse(value);
|
|
85745
|
+
}
|
|
85735
85746
|
var export_EventType = import_core.EventType;
|
|
85736
85747
|
|
|
85737
85748
|
// src/rateLimiter.ts
|
|
@@ -89726,6 +89737,136 @@ class RemoteMcpToolsProvider {
|
|
|
89726
89737
|
return Object.entries(headers).map(([key, value]) => `${key}: ${isDebug ? value : "*".repeat(value.length)}`).join(", ");
|
|
89727
89738
|
}
|
|
89728
89739
|
}
|
|
89740
|
+
// src/utils/toolConverter.ts
|
|
89741
|
+
function createClientToolExecutor(session) {
|
|
89742
|
+
return async (args, { toolCallId }) => {
|
|
89743
|
+
const result = await new Promise((resolve, reject) => {
|
|
89744
|
+
if (session.abortController?.signal.aborted) {
|
|
89745
|
+
reject(new Error("Run aborted"));
|
|
89746
|
+
return;
|
|
89747
|
+
}
|
|
89748
|
+
session.pendingToolCalls.set(toolCallId, resolve);
|
|
89749
|
+
session.abortController?.signal.addEventListener("abort", () => {
|
|
89750
|
+
session.pendingToolCalls.delete(toolCallId);
|
|
89751
|
+
reject(new Error("Run aborted"));
|
|
89752
|
+
}, { once: true });
|
|
89753
|
+
});
|
|
89754
|
+
return JSON.parse(result);
|
|
89755
|
+
};
|
|
89756
|
+
}
|
|
89757
|
+
// src/utils/toolAnnotations.ts
|
|
89758
|
+
function getToolAnnotations(tool) {
|
|
89759
|
+
if (!tool) {
|
|
89760
|
+
return;
|
|
89761
|
+
}
|
|
89762
|
+
if (tool.annotations) {
|
|
89763
|
+
return tool.annotations;
|
|
89764
|
+
}
|
|
89765
|
+
if (isRemoteTool(tool)) {
|
|
89766
|
+
return tool._remote.annotations;
|
|
89767
|
+
}
|
|
89768
|
+
return;
|
|
89769
|
+
}
|
|
89770
|
+
// src/agents/toolApproval.ts
|
|
89771
|
+
function toolNeedsApproval(toolDef) {
|
|
89772
|
+
const annotations = getToolAnnotations(toolDef);
|
|
89773
|
+
return annotations?.destructiveHint === true;
|
|
89774
|
+
}
|
|
89775
|
+
function waitForApproval(session, toolCallId) {
|
|
89776
|
+
return new Promise((resolve, reject) => {
|
|
89777
|
+
if (session.abortController?.signal.aborted) {
|
|
89778
|
+
reject(new Error("Run aborted"));
|
|
89779
|
+
return;
|
|
89780
|
+
}
|
|
89781
|
+
session.pendingToolApprovals.set(toolCallId, resolve);
|
|
89782
|
+
session.abortController?.signal.addEventListener("abort", () => {
|
|
89783
|
+
session.pendingToolApprovals.delete(toolCallId);
|
|
89784
|
+
reject(new Error("Run aborted"));
|
|
89785
|
+
}, { once: true });
|
|
89786
|
+
});
|
|
89787
|
+
}
|
|
89788
|
+
function createApprovalWrapper(toolDef, session, events, actualExecutor) {
|
|
89789
|
+
return async (args, options) => {
|
|
89790
|
+
const annotations = getToolAnnotations(toolDef);
|
|
89791
|
+
logger2.info("Tool requires approval", {
|
|
89792
|
+
toolCallId: options.toolCallId,
|
|
89793
|
+
toolName: toolDef.name
|
|
89794
|
+
});
|
|
89795
|
+
events.emit({
|
|
89796
|
+
type: TOOL_APPROVAL_REQUEST,
|
|
89797
|
+
toolCallId: options.toolCallId,
|
|
89798
|
+
toolCallName: toolDef.name,
|
|
89799
|
+
toolCallArgs: args,
|
|
89800
|
+
annotations,
|
|
89801
|
+
timestamp: Date.now()
|
|
89802
|
+
});
|
|
89803
|
+
const approvalResult = await waitForApproval(session, options.toolCallId);
|
|
89804
|
+
if (approvalResult.approved) {
|
|
89805
|
+
logger2.info("Tool approved by user", { toolCallId: options.toolCallId });
|
|
89806
|
+
return actualExecutor(args, options);
|
|
89807
|
+
} else {
|
|
89808
|
+
logger2.info("Tool rejected by user", {
|
|
89809
|
+
toolCallId: options.toolCallId,
|
|
89810
|
+
reason: approvalResult.reason
|
|
89811
|
+
});
|
|
89812
|
+
return {
|
|
89813
|
+
error: true,
|
|
89814
|
+
message: `Tool execution denied by user: ${approvalResult.reason || "Action was rejected"}`
|
|
89815
|
+
};
|
|
89816
|
+
}
|
|
89817
|
+
};
|
|
89818
|
+
}
|
|
89819
|
+
|
|
89820
|
+
// src/mcp/mcpConfirmation.ts
|
|
89821
|
+
async function handleMcpConfirmation(confirmation, toolCallId, toolCallName, originalToolName, originalArgs, provider, session, events, mcpHeaders) {
|
|
89822
|
+
const { message, metadata, additional_columns } = confirmation._use_ai_metadata;
|
|
89823
|
+
logger2.info("[MCP] Tool returned confirmation_required", {
|
|
89824
|
+
toolCallId,
|
|
89825
|
+
toolCallName,
|
|
89826
|
+
message,
|
|
89827
|
+
originalToolName
|
|
89828
|
+
});
|
|
89829
|
+
events.emit({
|
|
89830
|
+
type: TOOL_APPROVAL_REQUEST,
|
|
89831
|
+
toolCallId,
|
|
89832
|
+
toolCallName,
|
|
89833
|
+
toolCallArgs: originalArgs,
|
|
89834
|
+
message,
|
|
89835
|
+
metadata,
|
|
89836
|
+
timestamp: Date.now()
|
|
89837
|
+
});
|
|
89838
|
+
const approvalResult = await waitForApproval(session, toolCallId);
|
|
89839
|
+
if (!approvalResult.approved) {
|
|
89840
|
+
logger2.info("[MCP] Confirmation rejected by user", {
|
|
89841
|
+
toolCallId,
|
|
89842
|
+
reason: approvalResult.reason
|
|
89843
|
+
});
|
|
89844
|
+
return {
|
|
89845
|
+
error: true,
|
|
89846
|
+
message: `Tool execution denied by user: ${approvalResult.reason || "Action was rejected"}`
|
|
89847
|
+
};
|
|
89848
|
+
}
|
|
89849
|
+
const phase2Args = additional_columns ? { ...originalArgs, ...additional_columns } : originalArgs;
|
|
89850
|
+
logger2.info("[MCP] Confirmation approved, executing phase 2", {
|
|
89851
|
+
toolCallId,
|
|
89852
|
+
originalToolName
|
|
89853
|
+
});
|
|
89854
|
+
try {
|
|
89855
|
+
const result = await provider.executeTool(originalToolName, phase2Args, mcpHeaders);
|
|
89856
|
+
return result;
|
|
89857
|
+
} catch (error) {
|
|
89858
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
89859
|
+
logger2.error("[MCP] Phase 2 execution failed", {
|
|
89860
|
+
toolCallId,
|
|
89861
|
+
originalToolName,
|
|
89862
|
+
error: errorMsg
|
|
89863
|
+
});
|
|
89864
|
+
return {
|
|
89865
|
+
error: true,
|
|
89866
|
+
message: `MCP confirmation execution failed: ${errorMsg}`
|
|
89867
|
+
};
|
|
89868
|
+
}
|
|
89869
|
+
}
|
|
89729
89870
|
// src/runtime/detection.ts
|
|
89730
89871
|
function detectRuntime() {
|
|
89731
89872
|
if (typeof globalThis !== "undefined" && "Bun" in globalThis) {
|
|
@@ -113727,26 +113868,8 @@ async function flushTelemetry() {
|
|
|
113727
113868
|
await flushTracing();
|
|
113728
113869
|
await langfuse.client?.flushAsync();
|
|
113729
113870
|
}
|
|
113730
|
-
// src/utils/toolConverter.ts
|
|
113731
|
-
function createClientToolExecutor(session) {
|
|
113732
|
-
return async (args, { toolCallId }) => {
|
|
113733
|
-
const result = await new Promise((resolve2, reject) => {
|
|
113734
|
-
if (session.abortController?.signal.aborted) {
|
|
113735
|
-
reject(new Error("Run aborted"));
|
|
113736
|
-
return;
|
|
113737
|
-
}
|
|
113738
|
-
session.pendingToolCalls.set(toolCallId, resolve2);
|
|
113739
|
-
session.abortController?.signal.addEventListener("abort", () => {
|
|
113740
|
-
session.pendingToolCalls.delete(toolCallId);
|
|
113741
|
-
reject(new Error("Run aborted"));
|
|
113742
|
-
}, { once: true });
|
|
113743
|
-
});
|
|
113744
|
-
return JSON.parse(result);
|
|
113745
|
-
};
|
|
113746
|
-
}
|
|
113747
|
-
|
|
113748
113871
|
// src/tools/serverToolExecutor.ts
|
|
113749
|
-
function createServerToolExecutor(serverTool, session) {
|
|
113872
|
+
function createServerToolExecutor(serverTool, session, events) {
|
|
113750
113873
|
return async (args, { toolCallId }) => {
|
|
113751
113874
|
logger2.info("[Server Tool] Executing", {
|
|
113752
113875
|
toolName: serverTool.name,
|
|
@@ -113756,7 +113879,26 @@ function createServerToolExecutor(serverTool, session) {
|
|
|
113756
113879
|
session,
|
|
113757
113880
|
state: session.state,
|
|
113758
113881
|
runId: session.currentRunId || "",
|
|
113759
|
-
toolCallId
|
|
113882
|
+
toolCallId,
|
|
113883
|
+
requestApproval: async ({ message, metadata }) => {
|
|
113884
|
+
const approvalId = `${toolCallId}-approval-${Date.now()}`;
|
|
113885
|
+
logger2.info("[Server Tool] Runtime approval requested", {
|
|
113886
|
+
toolName: serverTool.name,
|
|
113887
|
+
toolCallId,
|
|
113888
|
+
approvalId,
|
|
113889
|
+
message
|
|
113890
|
+
});
|
|
113891
|
+
events.emit({
|
|
113892
|
+
type: TOOL_APPROVAL_REQUEST,
|
|
113893
|
+
toolCallId: approvalId,
|
|
113894
|
+
toolCallName: serverTool.name,
|
|
113895
|
+
toolCallArgs: args,
|
|
113896
|
+
timestamp: Date.now(),
|
|
113897
|
+
message,
|
|
113898
|
+
metadata
|
|
113899
|
+
});
|
|
113900
|
+
return waitForApproval(session, approvalId);
|
|
113901
|
+
}
|
|
113760
113902
|
};
|
|
113761
113903
|
try {
|
|
113762
113904
|
const result = await serverTool._server.execute(args, context);
|
|
@@ -113819,68 +113961,6 @@ function applyCacheBreakpoints(messages, cacheBreakpoint, model) {
|
|
|
113819
113961
|
}
|
|
113820
113962
|
return result;
|
|
113821
113963
|
}
|
|
113822
|
-
// src/utils/toolAnnotations.ts
|
|
113823
|
-
function getToolAnnotations(tool2) {
|
|
113824
|
-
if (!tool2) {
|
|
113825
|
-
return;
|
|
113826
|
-
}
|
|
113827
|
-
if (tool2.annotations) {
|
|
113828
|
-
return tool2.annotations;
|
|
113829
|
-
}
|
|
113830
|
-
if (isRemoteTool(tool2)) {
|
|
113831
|
-
return tool2._remote.annotations;
|
|
113832
|
-
}
|
|
113833
|
-
return;
|
|
113834
|
-
}
|
|
113835
|
-
// src/agents/toolApproval.ts
|
|
113836
|
-
function toolNeedsApproval(toolDef) {
|
|
113837
|
-
const annotations = getToolAnnotations(toolDef);
|
|
113838
|
-
return annotations?.destructiveHint === true;
|
|
113839
|
-
}
|
|
113840
|
-
function waitForApproval(session, toolCallId) {
|
|
113841
|
-
return new Promise((resolve2, reject) => {
|
|
113842
|
-
if (session.abortController?.signal.aborted) {
|
|
113843
|
-
reject(new Error("Run aborted"));
|
|
113844
|
-
return;
|
|
113845
|
-
}
|
|
113846
|
-
session.pendingToolApprovals.set(toolCallId, resolve2);
|
|
113847
|
-
session.abortController?.signal.addEventListener("abort", () => {
|
|
113848
|
-
session.pendingToolApprovals.delete(toolCallId);
|
|
113849
|
-
reject(new Error("Run aborted"));
|
|
113850
|
-
}, { once: true });
|
|
113851
|
-
});
|
|
113852
|
-
}
|
|
113853
|
-
function createApprovalWrapper(toolDef, session, events, actualExecutor) {
|
|
113854
|
-
return async (args, options) => {
|
|
113855
|
-
const annotations = getToolAnnotations(toolDef);
|
|
113856
|
-
logger2.info("Tool requires approval", {
|
|
113857
|
-
toolCallId: options.toolCallId,
|
|
113858
|
-
toolName: toolDef.name
|
|
113859
|
-
});
|
|
113860
|
-
events.emit({
|
|
113861
|
-
type: TOOL_APPROVAL_REQUEST,
|
|
113862
|
-
toolCallId: options.toolCallId,
|
|
113863
|
-
toolCallName: toolDef.name,
|
|
113864
|
-
toolCallArgs: args,
|
|
113865
|
-
annotations,
|
|
113866
|
-
timestamp: Date.now()
|
|
113867
|
-
});
|
|
113868
|
-
const approvalResult = await waitForApproval(session, options.toolCallId);
|
|
113869
|
-
if (approvalResult.approved) {
|
|
113870
|
-
logger2.info("Tool approved by user", { toolCallId: options.toolCallId });
|
|
113871
|
-
return actualExecutor(args, options);
|
|
113872
|
-
} else {
|
|
113873
|
-
logger2.info("Tool rejected by user", {
|
|
113874
|
-
toolCallId: options.toolCallId,
|
|
113875
|
-
reason: approvalResult.reason
|
|
113876
|
-
});
|
|
113877
|
-
return {
|
|
113878
|
-
error: true,
|
|
113879
|
-
message: `Tool execution denied by user: ${approvalResult.reason || "Action was rejected"}`
|
|
113880
|
-
};
|
|
113881
|
-
}
|
|
113882
|
-
};
|
|
113883
|
-
}
|
|
113884
113964
|
|
|
113885
113965
|
// src/agents/AISDKAgent.ts
|
|
113886
113966
|
var DEFAULT_MAX_OUTPUT_TOKENS = 4096;
|
|
@@ -114276,7 +114356,7 @@ ${JSON.stringify(state, null, 2)}`
|
|
|
114276
114356
|
}
|
|
114277
114357
|
return filteredTools;
|
|
114278
114358
|
}
|
|
114279
|
-
createMcpToolExecutor(remoteTool, session) {
|
|
114359
|
+
createMcpToolExecutor(remoteTool, session, events) {
|
|
114280
114360
|
return async (args, { toolCallId }) => {
|
|
114281
114361
|
logger2.info("[MCP] Executing remote tool", {
|
|
114282
114362
|
toolName: remoteTool.name,
|
|
@@ -114284,6 +114364,20 @@ ${JSON.stringify(state, null, 2)}`
|
|
|
114284
114364
|
});
|
|
114285
114365
|
try {
|
|
114286
114366
|
const result = await remoteTool._remote.provider.executeTool(remoteTool._remote.originalName, args, session.currentMcpHeaders);
|
|
114367
|
+
if (isUseAIInternalResponse(result)) {
|
|
114368
|
+
switch (result._use_ai_type) {
|
|
114369
|
+
case "confirmation_required":
|
|
114370
|
+
if (isMcpConfirmationResponse(result)) {
|
|
114371
|
+
return handleMcpConfirmation(result, toolCallId, remoteTool.name, remoteTool._remote.originalName, args, remoteTool._remote.provider, session, events, session.currentMcpHeaders);
|
|
114372
|
+
}
|
|
114373
|
+
break;
|
|
114374
|
+
default:
|
|
114375
|
+
logger2.warn("[MCP] Unknown _use_ai_type, returning as-is", {
|
|
114376
|
+
toolCallId,
|
|
114377
|
+
type: result._use_ai_type
|
|
114378
|
+
});
|
|
114379
|
+
}
|
|
114380
|
+
}
|
|
114287
114381
|
return result;
|
|
114288
114382
|
} catch (error40) {
|
|
114289
114383
|
const errorMsg = error40 instanceof Error ? error40.message : String(error40);
|
|
@@ -114304,9 +114398,9 @@ ${JSON.stringify(state, null, 2)}`
|
|
|
114304
114398
|
const inputSchema = rawParams && typeof rawParams === "object" ? { ...rawParams, type: rawParams.type || "object" } : { type: "object", properties: {} };
|
|
114305
114399
|
let baseExecutor;
|
|
114306
114400
|
if (isRemoteTool(toolDef)) {
|
|
114307
|
-
baseExecutor = this.createMcpToolExecutor(toolDef, session);
|
|
114401
|
+
baseExecutor = this.createMcpToolExecutor(toolDef, session, events);
|
|
114308
114402
|
} else if (isServerTool(toolDef)) {
|
|
114309
|
-
baseExecutor = createServerToolExecutor(toolDef, session);
|
|
114403
|
+
baseExecutor = createServerToolExecutor(toolDef, session, events);
|
|
114310
114404
|
} else {
|
|
114311
114405
|
baseExecutor = clientToolExecutor;
|
|
114312
114406
|
}
|
|
@@ -115661,8 +115755,10 @@ export {
|
|
|
115661
115755
|
or,
|
|
115662
115756
|
not,
|
|
115663
115757
|
logger2 as logger,
|
|
115758
|
+
isUseAIInternalResponse,
|
|
115664
115759
|
isServerTool,
|
|
115665
115760
|
isRemoteTool,
|
|
115761
|
+
isMcpConfirmationResponse,
|
|
115666
115762
|
getToolAnnotations,
|
|
115667
115763
|
flushTelemetry,
|
|
115668
115764
|
defineServerTool,
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { RemoteMcpToolsProvider, type RemoteToolDefinition } from './RemoteMcpToolsProvider';
|
|
2
|
+
export { isUseAIInternalResponse, type UseAIInternalResponseBase, type UseAIInternalResponse, } from './useAIInternalResponse';
|
|
3
|
+
export { isMcpConfirmationResponse, type McpConfirmationResponse } from './mcpConfirmation';
|
|
2
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/mcp/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EACL,uBAAuB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,GAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,yBAAyB,EAAE,KAAK,uBAAuB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool runtime interactive approval (`_use_ai_type: "confirmation_required"`).
|
|
3
|
+
*
|
|
4
|
+
* When an MCP tool returns this type the server shows an approval dialog.
|
|
5
|
+
* If the user approves, the server re-calls the same tool with
|
|
6
|
+
* `{ ...originalArgs, ...additional_columns }`.
|
|
7
|
+
*/
|
|
8
|
+
import type { ClientSession, EventEmitter } from '../agents/types';
|
|
9
|
+
import type { RemoteMcpToolsProvider } from './RemoteMcpToolsProvider';
|
|
10
|
+
import type { McpHeadersMap } from '@meetsmore-oss/use-ai-core';
|
|
11
|
+
import type { McpConfirmationResponse } from '@meetsmore-oss/use-ai-core';
|
|
12
|
+
export { isMcpConfirmationResponse, type McpConfirmationResponse, } from '@meetsmore-oss/use-ai-core';
|
|
13
|
+
/**
|
|
14
|
+
* Handles an MCP confirmation response:
|
|
15
|
+
* 1. Emits TOOL_APPROVAL_REQUEST to the client
|
|
16
|
+
* 2. Waits for user approval via waitForApproval()
|
|
17
|
+
* 3. If approved → re-calls the same tool with { ...originalArgs, ...additional_columns }
|
|
18
|
+
* 4. If rejected → returns error result
|
|
19
|
+
*
|
|
20
|
+
* Phase-2 results are returned as-is (no re-interception).
|
|
21
|
+
*/
|
|
22
|
+
export declare function handleMcpConfirmation(confirmation: McpConfirmationResponse, toolCallId: string, toolCallName: string, originalToolName: string, originalArgs: Record<string, unknown>, provider: RemoteMcpToolsProvider, session: ClientSession, events: EventEmitter, mcpHeaders?: McpHeadersMap): Promise<unknown>;
|
|
23
|
+
//# sourceMappingURL=mcpConfirmation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpConfirmation.d.ts","sourceRoot":"","sources":["../../../src/mcp/mcpConfirmation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAInE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAG1E,OAAO,EACL,yBAAyB,EACzB,KAAK,uBAAuB,GAC7B,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CACzC,YAAY,EAAE,uBAAuB,EACrC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,MAAM,EACxB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,QAAQ,EAAE,sBAAsB,EAChC,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,YAAY,EACpB,UAAU,CAAC,EAAE,aAAa,GACzB,OAAO,CAAC,OAAO,CAAC,CAgElB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpConfirmation.test.d.ts","sourceRoot":"","sources":["../../../src/mcp/mcpConfirmation.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAIInternalResponse.d.ts","sourceRoot":"","sources":["../../../src/mcp/useAIInternalResponse.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,uBAAuB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,GAC3B,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAIInternalResponse.test.d.ts","sourceRoot":"","sources":["../../../src/mcp/useAIInternalResponse.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AISDKAgent.d.ts","sourceRoot":"","sources":["../../../src/agents/AISDKAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,aAAa,EAA2D,MAAM,IAAI,CAAC;AAKpH,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAiB,MAAM,SAAS,CAAC;AAC3F,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"AISDKAgent.d.ts","sourceRoot":"","sources":["../../../src/agents/AISDKAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,aAAa,EAA2D,MAAM,IAAI,CAAC;AAKpH,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAiB,MAAM,SAAS,CAAC;AAC3F,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,UAAU,CAAC;AAyBpE,OAAO,EAAyB,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAkBjF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;;;;;;;;;OAkBG;IACH,KAAK,EAAE,aAAa,CAAC;IAErB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;;;;;;;OAUG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAEzD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,OAAO,CAAC;IAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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EX,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAG9B;IAEX,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAG/B;IAEX,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAI9B;IAEX;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,4BAA4B,CAWhD;IAEJ,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAOtC;IAEH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAM1B;IAEX,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAqC;IAEhF;;;;;;;;OAQG;IACH,OAAO,CAAC,gBAAgB;CAgBzB"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -10,5 +10,6 @@ export { logger } from './logger';
|
|
|
10
10
|
export { startRunSpan, flushTelemetry, type RunSpan } from './telemetry';
|
|
11
11
|
export { defineServerTool } from './tools';
|
|
12
12
|
export type { ServerToolConfig, ServerToolContext, ServerToolDefinition } from './tools';
|
|
13
|
+
export { isUseAIInternalResponse, type UseAIInternalResponseBase, type UseAIInternalResponse, isMcpConfirmationResponse, type McpConfirmationResponse, } from './mcp';
|
|
13
14
|
export { createClientToolExecutor, isRemoteTool, isServerTool, getToolAnnotations, createGlobFilter, and, or, not, } from './utils';
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACjG,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9C,YAAY,EAAE,KAAK,EAA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,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAG9J,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG3C,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAGzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAGzF,OAAO,EACL,uBAAuB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,yBAAyB,EACzB,KAAK,uBAAuB,GAC7B,MAAM,OAAO,CAAC;AAGf,OAAO,EACL,wBAAwB,EACxB,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,GAAG,EACH,EAAE,EACF,GAAG,GACJ,MAAM,SAAS,CAAC"}
|
package/dist/src/mcp/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { RemoteMcpToolsProvider, type RemoteToolDefinition } from './RemoteMcpToolsProvider';
|
|
2
|
+
export { isUseAIInternalResponse, type UseAIInternalResponseBase, type UseAIInternalResponse, } from './useAIInternalResponse';
|
|
3
|
+
export { isMcpConfirmationResponse, type McpConfirmationResponse } from './mcpConfirmation';
|
|
2
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EACL,uBAAuB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,GAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,yBAAyB,EAAE,KAAK,uBAAuB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool runtime interactive approval (`_use_ai_type: "confirmation_required"`).
|
|
3
|
+
*
|
|
4
|
+
* When an MCP tool returns this type the server shows an approval dialog.
|
|
5
|
+
* If the user approves, the server re-calls the same tool with
|
|
6
|
+
* `{ ...originalArgs, ...additional_columns }`.
|
|
7
|
+
*/
|
|
8
|
+
import type { ClientSession, EventEmitter } from '../agents/types';
|
|
9
|
+
import type { RemoteMcpToolsProvider } from './RemoteMcpToolsProvider';
|
|
10
|
+
import type { McpHeadersMap } from '@meetsmore-oss/use-ai-core';
|
|
11
|
+
import type { McpConfirmationResponse } from '@meetsmore-oss/use-ai-core';
|
|
12
|
+
export { isMcpConfirmationResponse, type McpConfirmationResponse, } from '@meetsmore-oss/use-ai-core';
|
|
13
|
+
/**
|
|
14
|
+
* Handles an MCP confirmation response:
|
|
15
|
+
* 1. Emits TOOL_APPROVAL_REQUEST to the client
|
|
16
|
+
* 2. Waits for user approval via waitForApproval()
|
|
17
|
+
* 3. If approved → re-calls the same tool with { ...originalArgs, ...additional_columns }
|
|
18
|
+
* 4. If rejected → returns error result
|
|
19
|
+
*
|
|
20
|
+
* Phase-2 results are returned as-is (no re-interception).
|
|
21
|
+
*/
|
|
22
|
+
export declare function handleMcpConfirmation(confirmation: McpConfirmationResponse, toolCallId: string, toolCallName: string, originalToolName: string, originalArgs: Record<string, unknown>, provider: RemoteMcpToolsProvider, session: ClientSession, events: EventEmitter, mcpHeaders?: McpHeadersMap): Promise<unknown>;
|
|
23
|
+
//# sourceMappingURL=mcpConfirmation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpConfirmation.d.ts","sourceRoot":"","sources":["../../../src/mcp/mcpConfirmation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAInE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAG1E,OAAO,EACL,yBAAyB,EACzB,KAAK,uBAAuB,GAC7B,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CACzC,YAAY,EAAE,uBAAuB,EACrC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,MAAM,EACxB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,QAAQ,EAAE,sBAAsB,EAChC,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,YAAY,EACpB,UAAU,CAAC,EAAE,aAAa,GACzB,OAAO,CAAC,OAAO,CAAC,CAgElB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpConfirmation.test.d.ts","sourceRoot":"","sources":["../../../src/mcp/mcpConfirmation.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAIInternalResponse.d.ts","sourceRoot":"","sources":["../../../src/mcp/useAIInternalResponse.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,uBAAuB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,GAC3B,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAIInternalResponse.test.d.ts","sourceRoot":"","sources":["../../../src/mcp/useAIInternalResponse.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClientSession } from '../agents/types';
|
|
1
|
+
import type { ClientSession, EventEmitter } from '../agents/types';
|
|
2
2
|
import type { ServerToolDefinition } from './types';
|
|
3
3
|
/** Generic tool arguments type */
|
|
4
4
|
type ToolArguments = Record<string, unknown>;
|
|
@@ -11,9 +11,10 @@ type ToolResult = unknown;
|
|
|
11
11
|
*
|
|
12
12
|
* @param serverTool - The server tool definition with execute function
|
|
13
13
|
* @param session - The client session (for context)
|
|
14
|
+
* @param events - Event emitter for sending approval requests to client
|
|
14
15
|
* @returns An async function compatible with the ToolExecutor signature
|
|
15
16
|
*/
|
|
16
|
-
export declare function createServerToolExecutor(serverTool: ServerToolDefinition, session: ClientSession): (args: ToolArguments, options: {
|
|
17
|
+
export declare function createServerToolExecutor(serverTool: ServerToolDefinition, session: ClientSession, events: EventEmitter): (args: ToolArguments, options: {
|
|
17
18
|
toolCallId: string;
|
|
18
19
|
}) => Promise<ToolResult>;
|
|
19
20
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverToolExecutor.d.ts","sourceRoot":"","sources":["../../../src/tools/serverToolExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"serverToolExecutor.d.ts","sourceRoot":"","sources":["../../../src/tools/serverToolExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGnE,OAAO,KAAK,EAAE,oBAAoB,EAAqB,MAAM,SAAS,CAAC;AAIvE,kCAAkC;AAClC,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC7C,+BAA+B;AAC/B,KAAK,UAAU,GAAG,OAAO,CAAC;AAE1B;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,oBAAoB,EAChC,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,YAAY,GACnB,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,UAAU,CAAC,CAiD/E"}
|
|
@@ -13,6 +13,20 @@ export interface ServerToolContext {
|
|
|
13
13
|
runId: string;
|
|
14
14
|
/** Unique identifier for this specific tool call */
|
|
15
15
|
toolCallId: string;
|
|
16
|
+
/**
|
|
17
|
+
* Request user approval during tool execution.
|
|
18
|
+
* Use this for conditional approval based on runtime values.
|
|
19
|
+
*
|
|
20
|
+
* @param input - Approval request details
|
|
21
|
+
* @returns Promise resolving with approval decision
|
|
22
|
+
*/
|
|
23
|
+
requestApproval(input: {
|
|
24
|
+
message: string;
|
|
25
|
+
metadata?: Record<string, unknown>;
|
|
26
|
+
}): Promise<{
|
|
27
|
+
approved: boolean;
|
|
28
|
+
reason?: string;
|
|
29
|
+
}>;
|
|
16
30
|
}
|
|
17
31
|
/**
|
|
18
32
|
* Server-side execute function signature.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tools/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,sDAAsD;IACtD,OAAO,EAAE,aAAa,CAAC;IACvB,gDAAgD;IAChD,KAAK,EAAE,OAAO,CAAC;IACf,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAC;
|
|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ACH,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D,gCAAgC;IAChC,OAAO,EAAE;QACP,iEAAiE;QACjE,OAAO,EAAE,mBAAmB,CAAC;KAC9B,CAAC;CACH"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClientSession } from '../agents/types';
|
|
1
|
+
import type { ClientSession, EventEmitter } from '../agents/types';
|
|
2
2
|
import type { ServerToolDefinition } from './types';
|
|
3
3
|
/** Generic tool arguments type */
|
|
4
4
|
type ToolArguments = Record<string, unknown>;
|
|
@@ -11,9 +11,10 @@ type ToolResult = unknown;
|
|
|
11
11
|
*
|
|
12
12
|
* @param serverTool - The server tool definition with execute function
|
|
13
13
|
* @param session - The client session (for context)
|
|
14
|
+
* @param events - Event emitter for sending approval requests to client
|
|
14
15
|
* @returns An async function compatible with the ToolExecutor signature
|
|
15
16
|
*/
|
|
16
|
-
export declare function createServerToolExecutor(serverTool: ServerToolDefinition, session: ClientSession): (args: ToolArguments, options: {
|
|
17
|
+
export declare function createServerToolExecutor(serverTool: ServerToolDefinition, session: ClientSession, events: EventEmitter): (args: ToolArguments, options: {
|
|
17
18
|
toolCallId: string;
|
|
18
19
|
}) => Promise<ToolResult>;
|
|
19
20
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverToolExecutor.d.ts","sourceRoot":"","sources":["../../../src/tools/serverToolExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"serverToolExecutor.d.ts","sourceRoot":"","sources":["../../../src/tools/serverToolExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGnE,OAAO,KAAK,EAAE,oBAAoB,EAAqB,MAAM,SAAS,CAAC;AAIvE,kCAAkC;AAClC,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC7C,+BAA+B;AAC/B,KAAK,UAAU,GAAG,OAAO,CAAC;AAE1B;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,oBAAoB,EAChC,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,YAAY,GACnB,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,UAAU,CAAC,CAiD/E"}
|
package/dist/tools/types.d.ts
CHANGED
|
@@ -13,6 +13,20 @@ export interface ServerToolContext {
|
|
|
13
13
|
runId: string;
|
|
14
14
|
/** Unique identifier for this specific tool call */
|
|
15
15
|
toolCallId: string;
|
|
16
|
+
/**
|
|
17
|
+
* Request user approval during tool execution.
|
|
18
|
+
* Use this for conditional approval based on runtime values.
|
|
19
|
+
*
|
|
20
|
+
* @param input - Approval request details
|
|
21
|
+
* @returns Promise resolving with approval decision
|
|
22
|
+
*/
|
|
23
|
+
requestApproval(input: {
|
|
24
|
+
message: string;
|
|
25
|
+
metadata?: Record<string, unknown>;
|
|
26
|
+
}): Promise<{
|
|
27
|
+
approved: boolean;
|
|
28
|
+
reason?: string;
|
|
29
|
+
}>;
|
|
16
30
|
}
|
|
17
31
|
/**
|
|
18
32
|
* Server-side execute function signature.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tools/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,sDAAsD;IACtD,OAAO,EAAE,aAAa,CAAC;IACvB,gDAAgD;IAChD,KAAK,EAAE,OAAO,CAAC;IACf,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,oD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