linkque-cli-v2 1.3.4 → 1.3.6
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/linkquejs.js +75 -173
- package/package.json +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-23PMJWOG.js → chunk-7SF3H2GM.js} +85 -153
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-VSZ3UDC7.js → chunk-NHRW2KQW.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-YSRA6KFZ.js → chunk-RHFHCJYP.js} +227 -110
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js +260 -155
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/clientCapability.js +2 -2
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js +2 -2
- package/worker.js +363 -166
package/worker.js
CHANGED
|
@@ -9452,6 +9452,54 @@ function getA2UIV4ProtocolIssues(value, path9 = "card") {
|
|
|
9452
9452
|
validateReferences(surfaces, path9, issues);
|
|
9453
9453
|
return issues;
|
|
9454
9454
|
}
|
|
9455
|
+
function validateV4Component(component, componentPath, issues) {
|
|
9456
|
+
const schema = A2UI_V4_COMPONENT_CATALOG.components[component.component];
|
|
9457
|
+
if (!schema) {
|
|
9458
|
+
issues.push(issue2(`${componentPath}.component`, "UNSUPPORTED_COMPONENT", `V4 does not support component ${component.component}`));
|
|
9459
|
+
return;
|
|
9460
|
+
}
|
|
9461
|
+
const allowed = /* @__PURE__ */ new Set([
|
|
9462
|
+
"id",
|
|
9463
|
+
"component",
|
|
9464
|
+
...Object.keys(schema.properties)
|
|
9465
|
+
]);
|
|
9466
|
+
for (const key of Object.keys(component))
|
|
9467
|
+
if (!allowed.has(key))
|
|
9468
|
+
issues.push(issue2(`${componentPath}.${key}`, "UNSUPPORTED_COMPONENT_PROP", `${component.component} does not support property ${key}`));
|
|
9469
|
+
for (const [name, property] of Object.entries(schema.properties)) {
|
|
9470
|
+
const value = component[name];
|
|
9471
|
+
if (property.required && value === void 0)
|
|
9472
|
+
issues.push(issue2(`${componentPath}.${name}`, "REQUIRED_COMPONENT_PROP_MISSING", `${component.component}.${name} is required`));
|
|
9473
|
+
if (value !== void 0)
|
|
9474
|
+
validateProperty(value, property, `${componentPath}.${name}`, issues, name);
|
|
9475
|
+
}
|
|
9476
|
+
if (component["x2-overflow"] !== void 0)
|
|
9477
|
+
validateOverflow(component, componentPath, issues);
|
|
9478
|
+
if (component.component === "TextField")
|
|
9479
|
+
validateTextField(component, componentPath, issues);
|
|
9480
|
+
if (component.component === "ChoicePicker") {
|
|
9481
|
+
if (!isStrictBinding(component.value))
|
|
9482
|
+
issues.push(issue2(`${componentPath}.value`, "INPUT_REQUIRES_BINDING", "ChoicePicker.value must be a strict writable binding"));
|
|
9483
|
+
validateOptions(component.options, `${componentPath}.options`, issues);
|
|
9484
|
+
}
|
|
9485
|
+
if (component.component === "Stepper")
|
|
9486
|
+
validateStepper(component, componentPath, issues);
|
|
9487
|
+
if (["Card", "Row", "Column", "List"].includes(component.component)) {
|
|
9488
|
+
for (const axis of ["width", "height"]) {
|
|
9489
|
+
const value = component[axis];
|
|
9490
|
+
const modes = axis === "width" ? ["fit", "fill"] : ["auto"];
|
|
9491
|
+
if (value !== void 0 && !(typeof value === "string" && (modes.includes(value) || /^\d+(?:\.\d+)?px$/.test(value) && Number.isFinite(parseFloat(value))))) {
|
|
9492
|
+
issues.push(issue2(`${componentPath}.${axis}`, "INVALID_COMPONENT_PROP_VALUE", `size must be ${modes.join(" / ")} or a non-negative px string such as 120px`));
|
|
9493
|
+
}
|
|
9494
|
+
}
|
|
9495
|
+
}
|
|
9496
|
+
if (component.checks !== void 0)
|
|
9497
|
+
validateChecks(component.checks, `${componentPath}.checks`, issues);
|
|
9498
|
+
if (component.format !== void 0 && component.component === "Text")
|
|
9499
|
+
validateNumberFormat(component.format, `${componentPath}.format`, issues);
|
|
9500
|
+
if (component.action !== void 0)
|
|
9501
|
+
validateAction(component.action, `${componentPath}.action`, issues, 0);
|
|
9502
|
+
}
|
|
9455
9503
|
function validateComponents(payload, path9, surfaces, issues) {
|
|
9456
9504
|
if (!Array.isArray(payload.components)) {
|
|
9457
9505
|
issues.push(issue2(`${path9}.updateComponents.components`, "INVALID_A2UI_COMPONENTS", "components must be an array"));
|
|
@@ -9468,52 +9516,7 @@ function validateComponents(payload, path9, surfaces, issues) {
|
|
|
9468
9516
|
if (surface.has(component.id))
|
|
9469
9517
|
issues.push(issue2(`${componentPath}.id`, "DUPLICATE_COMPONENT_ID", `component id ${component.id} is duplicated`));
|
|
9470
9518
|
surface.set(component.id, component);
|
|
9471
|
-
|
|
9472
|
-
if (!schema) {
|
|
9473
|
-
issues.push(issue2(`${componentPath}.component`, "UNSUPPORTED_COMPONENT", `V4 does not support component ${component.component}`));
|
|
9474
|
-
return;
|
|
9475
|
-
}
|
|
9476
|
-
const allowed = /* @__PURE__ */ new Set([
|
|
9477
|
-
"id",
|
|
9478
|
-
"component",
|
|
9479
|
-
...Object.keys(schema.properties)
|
|
9480
|
-
]);
|
|
9481
|
-
for (const key of Object.keys(component))
|
|
9482
|
-
if (!allowed.has(key))
|
|
9483
|
-
issues.push(issue2(`${componentPath}.${key}`, "UNSUPPORTED_COMPONENT_PROP", `${component.component} does not support property ${key}`));
|
|
9484
|
-
for (const [name, property] of Object.entries(schema.properties)) {
|
|
9485
|
-
const value = component[name];
|
|
9486
|
-
if (property.required && value === void 0)
|
|
9487
|
-
issues.push(issue2(`${componentPath}.${name}`, "REQUIRED_COMPONENT_PROP_MISSING", `${component.component}.${name} is required`));
|
|
9488
|
-
if (value !== void 0)
|
|
9489
|
-
validateProperty(value, property, `${componentPath}.${name}`, issues, name);
|
|
9490
|
-
}
|
|
9491
|
-
if (component["x2-overflow"] !== void 0)
|
|
9492
|
-
validateOverflow(component, componentPath, issues);
|
|
9493
|
-
if (component.component === "TextField")
|
|
9494
|
-
validateTextField(component, componentPath, issues);
|
|
9495
|
-
if (component.component === "ChoicePicker") {
|
|
9496
|
-
if (!isStrictBinding(component.value))
|
|
9497
|
-
issues.push(issue2(`${componentPath}.value`, "INPUT_REQUIRES_BINDING", "ChoicePicker.value must be a strict writable binding"));
|
|
9498
|
-
validateOptions(component.options, `${componentPath}.options`, issues);
|
|
9499
|
-
}
|
|
9500
|
-
if (component.component === "Stepper")
|
|
9501
|
-
validateStepper(component, componentPath, issues);
|
|
9502
|
-
if (["Card", "Row", "Column", "List"].includes(component.component)) {
|
|
9503
|
-
for (const axis of ["width", "height"]) {
|
|
9504
|
-
const value = component[axis];
|
|
9505
|
-
const modes = axis === "width" ? ["fit", "fill"] : ["auto"];
|
|
9506
|
-
if (value !== void 0 && !(typeof value === "string" && (modes.includes(value) || /^\d+(?:\.\d+)?px$/.test(value) && Number.isFinite(parseFloat(value))))) {
|
|
9507
|
-
issues.push(issue2(`${componentPath}.${axis}`, "INVALID_COMPONENT_PROP_VALUE", `size must be ${modes.join(" / ")} or a non-negative px string such as 120px`));
|
|
9508
|
-
}
|
|
9509
|
-
}
|
|
9510
|
-
}
|
|
9511
|
-
if (component.checks !== void 0)
|
|
9512
|
-
validateChecks(component.checks, `${componentPath}.checks`, issues);
|
|
9513
|
-
if (component.format !== void 0 && component.component === "Text")
|
|
9514
|
-
validateNumberFormat(component.format, `${componentPath}.format`, issues);
|
|
9515
|
-
if (component.action !== void 0)
|
|
9516
|
-
validateAction(component.action, `${componentPath}.action`, issues, 0);
|
|
9519
|
+
validateV4Component(component, componentPath, issues);
|
|
9517
9520
|
});
|
|
9518
9521
|
}
|
|
9519
9522
|
function validateProperty(value, schema, path9, issues, propertyName) {
|
|
@@ -11161,6 +11164,7 @@ var init_authoring_operation = __esm({
|
|
|
11161
11164
|
"use strict";
|
|
11162
11165
|
init_authoring_model();
|
|
11163
11166
|
init_json2();
|
|
11167
|
+
init_v4Catalog();
|
|
11164
11168
|
}
|
|
11165
11169
|
});
|
|
11166
11170
|
|
|
@@ -11508,7 +11512,7 @@ var init_cardSemanticSnapshot = __esm({
|
|
|
11508
11512
|
function createCardPresentationToolName(resourceId) {
|
|
11509
11513
|
return stableToolName("a2ui_card", resourceId);
|
|
11510
11514
|
}
|
|
11511
|
-
async function executeCardPresentation(resource, registry2, runtimeContext, args, signal) {
|
|
11515
|
+
async function executeCardPresentation(resource, registry2, runtimeContext, args, signal, context2) {
|
|
11512
11516
|
const config2 = parseCardConfig(resource);
|
|
11513
11517
|
if (config2.schemaVersion !== "2") {
|
|
11514
11518
|
throw new Error(`Schema v${config2.schemaVersion} cards must be executed through the card data-source loop`);
|
|
@@ -11537,7 +11541,7 @@ async function executeCardPresentation(resource, registry2, runtimeContext, args
|
|
|
11537
11541
|
inputSchema,
|
|
11538
11542
|
outputSchema: isJsonObject(handle.outputSchema) ? handle.outputSchema : FALLBACK_OBJECT_SCHEMA,
|
|
11539
11543
|
call: async (input, callSignal) => {
|
|
11540
|
-
const result = await handle.execute(supplementMcpInput(input, invocation, config2.presentationInputSchema, inputSchema), callSignal);
|
|
11544
|
+
const result = await handle.execute(supplementMcpInput(input, invocation, config2.presentationInputSchema, inputSchema), callSignal, context2);
|
|
11541
11545
|
return { structuredContent: readStructuredContent(result) };
|
|
11542
11546
|
}
|
|
11543
11547
|
};
|
|
@@ -11818,6 +11822,8 @@ function aggregateMcpServers(resources, protocolAgentId) {
|
|
|
11818
11822
|
argsMappingRules: [],
|
|
11819
11823
|
allowedTools: void 0,
|
|
11820
11824
|
resourceIds: [],
|
|
11825
|
+
allToolResourceIds: [],
|
|
11826
|
+
resourceIdsByTool: /* @__PURE__ */ new Map(),
|
|
11821
11827
|
description: ""
|
|
11822
11828
|
};
|
|
11823
11829
|
specs.set(serverName, spec);
|
|
@@ -11841,14 +11847,19 @@ function aggregateMcpServers(resources, protocolAgentId) {
|
|
|
11841
11847
|
if (allowed && allowed.length > 0) {
|
|
11842
11848
|
if (!spec.allowedTools)
|
|
11843
11849
|
spec.allowedTools = /* @__PURE__ */ new Set();
|
|
11844
|
-
for (const toolName of allowed)
|
|
11850
|
+
for (const toolName of allowed) {
|
|
11845
11851
|
spec.allowedTools.add(toolName);
|
|
11852
|
+
addToolResourceId(spec.resourceIdsByTool, toolName, resource.resourceId);
|
|
11853
|
+
}
|
|
11854
|
+
} else {
|
|
11855
|
+
spec.allToolResourceIds.push(resource.resourceId);
|
|
11846
11856
|
}
|
|
11847
11857
|
continue;
|
|
11848
11858
|
}
|
|
11849
11859
|
if (!spec.allowedTools)
|
|
11850
11860
|
spec.allowedTools = /* @__PURE__ */ new Set();
|
|
11851
11861
|
spec.allowedTools.add(resource.config.toolName);
|
|
11862
|
+
addToolResourceId(spec.resourceIdsByTool, resource.config.toolName, resource.resourceId);
|
|
11852
11863
|
for (const rule of resource.config.argsMappingRules ?? []) {
|
|
11853
11864
|
const fullRule = {
|
|
11854
11865
|
mcpToolName: resource.config.toolName,
|
|
@@ -11862,6 +11873,11 @@ function aggregateMcpServers(resources, protocolAgentId) {
|
|
|
11862
11873
|
}
|
|
11863
11874
|
return [...specs.values()];
|
|
11864
11875
|
}
|
|
11876
|
+
function addToolResourceId(target, toolName, resourceId) {
|
|
11877
|
+
const current = target.get(toolName) ?? [];
|
|
11878
|
+
current.push(resourceId);
|
|
11879
|
+
target.set(toolName, current);
|
|
11880
|
+
}
|
|
11865
11881
|
var init_mcpAggregator = __esm({
|
|
11866
11882
|
"../linkque-agent-runtime/dist/esm/core/mcpAggregator.js"() {
|
|
11867
11883
|
"use strict";
|
|
@@ -11870,6 +11886,14 @@ var init_mcpAggregator = __esm({
|
|
|
11870
11886
|
});
|
|
11871
11887
|
|
|
11872
11888
|
// ../linkque-agent-runtime/dist/esm/core/mcpProxyTool.js
|
|
11889
|
+
function resourceIdsForTool(spec, toolName) {
|
|
11890
|
+
if (!spec.allToolResourceIds && !spec.resourceIdsByTool)
|
|
11891
|
+
return spec.resourceIds;
|
|
11892
|
+
return [
|
|
11893
|
+
...spec.allToolResourceIds ?? [],
|
|
11894
|
+
...spec.resourceIdsByTool?.get(toolName) ?? []
|
|
11895
|
+
];
|
|
11896
|
+
}
|
|
11873
11897
|
function parseProxyArgs(args) {
|
|
11874
11898
|
if (!isRecord(args))
|
|
11875
11899
|
return {};
|
|
@@ -11944,6 +11968,7 @@ var init_mcpProxyTool = __esm({
|
|
|
11944
11968
|
specByResourceId;
|
|
11945
11969
|
specs;
|
|
11946
11970
|
debugLog;
|
|
11971
|
+
authorizeCall;
|
|
11947
11972
|
constructor(provider, specs, options = {}) {
|
|
11948
11973
|
this.provider = provider;
|
|
11949
11974
|
this.specs = specs;
|
|
@@ -11951,6 +11976,7 @@ var init_mcpProxyTool = __esm({
|
|
|
11951
11976
|
this.specByResourceId = new Map(specs.flatMap((spec) => spec.resourceIds.map((id) => [id, spec])));
|
|
11952
11977
|
this.debugLog = options.debugLog ?? (() => {
|
|
11953
11978
|
});
|
|
11979
|
+
this.authorizeCall = options.authorizeCall;
|
|
11954
11980
|
}
|
|
11955
11981
|
/**
|
|
11956
11982
|
* 产单个 `mcp` 代理工具描述符,注入 `agentReq.tools`。
|
|
@@ -11963,7 +11989,7 @@ var init_mcpProxyTool = __esm({
|
|
|
11963
11989
|
label: "MCP",
|
|
11964
11990
|
description: MCP_PROXY_DESCRIPTION,
|
|
11965
11991
|
inputSchema: MCP_PROXY_INPUT_SCHEMA,
|
|
11966
|
-
execute: (args, signal) => this.dispatch(args, signal)
|
|
11992
|
+
execute: (args, signal, context2) => this.dispatch(args, signal, context2)
|
|
11967
11993
|
};
|
|
11968
11994
|
}
|
|
11969
11995
|
/** {@link IMcpToolRegistry.resolve}:按 (resourceId, toolName) 解析可调用句柄。 */
|
|
@@ -11980,7 +12006,18 @@ var init_mcpProxyTool = __esm({
|
|
|
11980
12006
|
return {
|
|
11981
12007
|
inputSchema: tool.inputSchema,
|
|
11982
12008
|
outputSchema: tool.outputSchema,
|
|
11983
|
-
execute: (args, sig) =>
|
|
12009
|
+
execute: async (args, sig, context2) => {
|
|
12010
|
+
const headers = await this.authorizeCall?.({
|
|
12011
|
+
resourceIds: [resourceId],
|
|
12012
|
+
toolName: tool.name,
|
|
12013
|
+
signal: sig,
|
|
12014
|
+
context: context2
|
|
12015
|
+
});
|
|
12016
|
+
return entry.server.callTool(tool.name, args, sig, {
|
|
12017
|
+
...headers ? { headers } : {},
|
|
12018
|
+
...context2 ? { context: context2 } : {}
|
|
12019
|
+
});
|
|
12020
|
+
}
|
|
11984
12021
|
};
|
|
11985
12022
|
}
|
|
11986
12023
|
/** 关闭所有已连 server(忽略单 server 关闭错误)。 */
|
|
@@ -12067,7 +12104,7 @@ var init_mcpProxyTool = __esm({
|
|
|
12067
12104
|
}
|
|
12068
12105
|
// —— 派发 ——
|
|
12069
12106
|
/** 按入参字段派发;返回 LLM 可读文本。 */
|
|
12070
|
-
async dispatch(args, signal) {
|
|
12107
|
+
async dispatch(args, signal, context2) {
|
|
12071
12108
|
const params = parseProxyArgs(args);
|
|
12072
12109
|
if (params.connect !== void 0) {
|
|
12073
12110
|
return this.executeConnect(params.connect, signal);
|
|
@@ -12082,7 +12119,7 @@ var init_mcpProxyTool = __esm({
|
|
|
12082
12119
|
return this.executeSearch(params.search, params.server);
|
|
12083
12120
|
}
|
|
12084
12121
|
if (params.tool !== void 0) {
|
|
12085
|
-
return this.executeCall(params.tool, params.args, params.server, signal);
|
|
12122
|
+
return this.executeCall(params.tool, params.args, params.server, signal, context2);
|
|
12086
12123
|
}
|
|
12087
12124
|
if (params.server !== void 0) {
|
|
12088
12125
|
return this.executeList(params.server, signal);
|
|
@@ -12210,14 +12247,23 @@ ${formatSchema(tool.inputSchema)}`);
|
|
|
12210
12247
|
return lines.join("\n").trim();
|
|
12211
12248
|
}
|
|
12212
12249
|
/** `mcp({ tool: "name", args: {...} })`:调用工具,返回序列化结果。 */
|
|
12213
|
-
async executeCall(toolName, args, serverHint, signal) {
|
|
12250
|
+
async executeCall(toolName, args, serverHint, signal, context2) {
|
|
12214
12251
|
const found = await this.findTool(toolName, serverHint, signal);
|
|
12215
12252
|
if (!found) {
|
|
12216
12253
|
return `Tool "${toolName}" not found. Use mcp({ search: "..." }) to search.`;
|
|
12217
12254
|
}
|
|
12218
|
-
const { entry, tool } = found;
|
|
12255
|
+
const { entry, tool, spec } = found;
|
|
12219
12256
|
try {
|
|
12220
|
-
const
|
|
12257
|
+
const headers = await this.authorizeCall?.({
|
|
12258
|
+
resourceIds: resourceIdsForTool(spec, tool.name),
|
|
12259
|
+
toolName: tool.name,
|
|
12260
|
+
signal,
|
|
12261
|
+
context: context2
|
|
12262
|
+
});
|
|
12263
|
+
const result = await entry.server.callTool(tool.name, args, signal, {
|
|
12264
|
+
...headers ? { headers } : {},
|
|
12265
|
+
...context2 ? { context: context2 } : {}
|
|
12266
|
+
});
|
|
12221
12267
|
return serializeToolResult(result);
|
|
12222
12268
|
} catch (error40) {
|
|
12223
12269
|
const message = error40 instanceof Error ? error40.message : String(error40);
|
|
@@ -12234,7 +12280,7 @@ ${formatSchema(tool.inputSchema)}`);
|
|
|
12234
12280
|
continue;
|
|
12235
12281
|
const tool = entry.tools.find((t2) => t2.name === toolName);
|
|
12236
12282
|
if (tool) {
|
|
12237
|
-
return { entry, server: spec.serverName, tool };
|
|
12283
|
+
return { entry, server: spec.serverName, tool, spec };
|
|
12238
12284
|
}
|
|
12239
12285
|
}
|
|
12240
12286
|
await Promise.all(specs.map((s2) => this.ensureEntry(s2.serverName, signal)));
|
|
@@ -12244,7 +12290,7 @@ ${formatSchema(tool.inputSchema)}`);
|
|
|
12244
12290
|
continue;
|
|
12245
12291
|
const tool = entry.tools.find((t2) => t2.name === toolName);
|
|
12246
12292
|
if (tool) {
|
|
12247
|
-
return { entry, server: spec.serverName, tool };
|
|
12293
|
+
return { entry, server: spec.serverName, tool, spec };
|
|
12248
12294
|
}
|
|
12249
12295
|
}
|
|
12250
12296
|
return void 0;
|
|
@@ -12579,10 +12625,10 @@ var init_hookRegistry = __esm({
|
|
|
12579
12625
|
}
|
|
12580
12626
|
});
|
|
12581
12627
|
|
|
12582
|
-
// ../linkque-agent-
|
|
12583
|
-
var ETelemetryAttribute, ETelemetryEventPrefix, ETelemetryEventPhase, ETelemetryEventName, ETelemetryOperationName, ETelemetryOutcome, ETelemetrySignal,
|
|
12628
|
+
// ../linkque-agent-protocol/dist/esm/telemetry/telemetryEnums.js
|
|
12629
|
+
var ETelemetryAttribute, ETelemetryEventPrefix, ETelemetryEventPhase, ETelemetryEventName, ETelemetryOperationName, ETelemetryOutcome, ETelemetrySignal, ETelemetryLossReason, ETelemetryAdvanceOutcome, ETelemetryStreamTermination, ETelemetryCancelSource, ETelemetryObservationBoundary, ETelemetryRemoteCompletion, ETelemetryCommitStatus, ETelemetryHookMode, ETelemetryHookResult, ETelemetrySource, ETelemetryEvidence, ETelemetryCompleteness, ETelemetryCoverage, ETelemetryUsageSource, ETelemetryAttemptVisibility, ETelemetryLinkRelation, ETelemetryToolFailureStage, ETelemetryTerminalEvidence, ETelemetryTerminalSource, ETelemetryModelPurpose, ETelemetryErrorType, ETelemetrySpanKind, ETelemetryGenAiOperation, ETelemetryVersion;
|
|
12584
12630
|
var init_telemetryEnums = __esm({
|
|
12585
|
-
"../linkque-agent-
|
|
12631
|
+
"../linkque-agent-protocol/dist/esm/telemetry/telemetryEnums.js"() {
|
|
12586
12632
|
"use strict";
|
|
12587
12633
|
(function(ETelemetryAttribute2) {
|
|
12588
12634
|
ETelemetryAttribute2["HARNESS_TELEMETRY_SCHEMA_VERSION"] = "harness.telemetry.schema.version";
|
|
@@ -12768,23 +12814,6 @@ var init_telemetryEnums = __esm({
|
|
|
12768
12814
|
ETelemetrySignal2["LOGS"] = "logs";
|
|
12769
12815
|
ETelemetrySignal2["TRACES"] = "traces";
|
|
12770
12816
|
})(ETelemetrySignal || (ETelemetrySignal = {}));
|
|
12771
|
-
(function(ETelemetryDiagnosticCode2) {
|
|
12772
|
-
ETelemetryDiagnosticCode2["INVALID_AUTHORIZATION"] = "invalid_authorization";
|
|
12773
|
-
ETelemetryDiagnosticCode2["PARTITION_LIMIT"] = "partition_limit";
|
|
12774
|
-
ETelemetryDiagnosticCode2["UNAVAILABLE_PARTITION"] = "unavailable_partition";
|
|
12775
|
-
ETelemetryDiagnosticCode2["QUEUE_LIMIT"] = "queue_limit";
|
|
12776
|
-
ETelemetryDiagnosticCode2["QUEUE_EXPIRED"] = "queue_expired";
|
|
12777
|
-
ETelemetryDiagnosticCode2["SENDER_FAILED"] = "sender_failed";
|
|
12778
|
-
ETelemetryDiagnosticCode2["PARTIAL_SUCCESS"] = "partial_success";
|
|
12779
|
-
ETelemetryDiagnosticCode2["AUTHORIZATION_REJECTED"] = "authorization_rejected";
|
|
12780
|
-
ETelemetryDiagnosticCode2["PERMANENT_REJECTION"] = "permanent_rejection";
|
|
12781
|
-
ETelemetryDiagnosticCode2["SEND_RETRY"] = "send_retry";
|
|
12782
|
-
ETelemetryDiagnosticCode2["SHUTDOWN_DROP"] = "shutdown_drop";
|
|
12783
|
-
ETelemetryDiagnosticCode2["LOCAL_SINK_FAILED"] = "local_sink_failed";
|
|
12784
|
-
ETelemetryDiagnosticCode2["CAPTURE_FAILED"] = "capture_failed";
|
|
12785
|
-
ETelemetryDiagnosticCode2["IDENTITY_MISMATCH"] = "identity_mismatch";
|
|
12786
|
-
ETelemetryDiagnosticCode2["ACTIVE_LIMIT"] = "active_limit";
|
|
12787
|
-
})(ETelemetryDiagnosticCode || (ETelemetryDiagnosticCode = {}));
|
|
12788
12817
|
(function(ETelemetryLossReason2) {
|
|
12789
12818
|
ETelemetryLossReason2["UNCAUGHT_ERROR"] = "uncaught_error";
|
|
12790
12819
|
ETelemetryLossReason2["ACTIVE_LIMIT"] = "active_limit";
|
|
@@ -12892,19 +12921,6 @@ var init_telemetryEnums = __esm({
|
|
|
12892
12921
|
ETelemetryGenAiOperation2["EXECUTE_TOOL"] = "execute_tool";
|
|
12893
12922
|
ETelemetryGenAiOperation2["INVOKE_AGENT"] = "invoke_agent";
|
|
12894
12923
|
})(ETelemetryGenAiOperation || (ETelemetryGenAiOperation = {}));
|
|
12895
|
-
(function(ETelemetryAssociation2) {
|
|
12896
|
-
ETelemetryAssociation2["LOOP"] = "loop";
|
|
12897
|
-
ETelemetryAssociation2["ITERATION"] = "iteration";
|
|
12898
|
-
ETelemetryAssociation2["MODEL"] = "model";
|
|
12899
|
-
ETelemetryAssociation2["TOOL"] = "tool";
|
|
12900
|
-
ETelemetryAssociation2["PROVIDER"] = "provider";
|
|
12901
|
-
})(ETelemetryAssociation || (ETelemetryAssociation = {}));
|
|
12902
|
-
(function(ETelemetryMetadata2) {
|
|
12903
|
-
ETelemetryMetadata2["SCOPE_NAME"] = "com.alipay.linkque.runtime.telemetry";
|
|
12904
|
-
ETelemetryMetadata2["RUNTIME_KIND"] = "node_toolkit";
|
|
12905
|
-
ETelemetryMetadata2["SERVICE_NAMESPACE"] = "linkque";
|
|
12906
|
-
ETelemetryMetadata2["ROUTE_CONTEXT_KEY"] = "linkque.telemetry.route";
|
|
12907
|
-
})(ETelemetryMetadata || (ETelemetryMetadata = {}));
|
|
12908
12924
|
(function(ETelemetryVersion2) {
|
|
12909
12925
|
ETelemetryVersion2["V0_2"] = "0.2";
|
|
12910
12926
|
ETelemetryVersion2["V1_0"] = "1.0";
|
|
@@ -12912,6 +12928,14 @@ var init_telemetryEnums = __esm({
|
|
|
12912
12928
|
}
|
|
12913
12929
|
});
|
|
12914
12930
|
|
|
12931
|
+
// ../linkque-agent-protocol/dist/esm/telemetry.js
|
|
12932
|
+
var init_telemetry = __esm({
|
|
12933
|
+
"../linkque-agent-protocol/dist/esm/telemetry.js"() {
|
|
12934
|
+
"use strict";
|
|
12935
|
+
init_telemetryEnums();
|
|
12936
|
+
}
|
|
12937
|
+
});
|
|
12938
|
+
|
|
12915
12939
|
// ../linkque-agent-runtime/dist/esm/core/logFailure.js
|
|
12916
12940
|
function warnLogFailure(stage, error40) {
|
|
12917
12941
|
(0, import_node_process.emitWarning)(`[${stage}] errorType=${error40 instanceof Error ? error40.name : typeof error40}`, { code: "LINKQUE_RUNTIME_DIAGNOSTIC_FAILURE" });
|
|
@@ -13064,7 +13088,7 @@ var import_node_crypto3, PREPARE_PATCH_KEYS, HookDispatcher;
|
|
|
13064
13088
|
var init_hookDispatcher = __esm({
|
|
13065
13089
|
"../linkque-agent-runtime/dist/esm/core/hook/hookDispatcher.js"() {
|
|
13066
13090
|
"use strict";
|
|
13067
|
-
|
|
13091
|
+
init_telemetry();
|
|
13068
13092
|
import_node_crypto3 = require("node:crypto");
|
|
13069
13093
|
init_esm();
|
|
13070
13094
|
init_hookContext();
|
|
@@ -13486,7 +13510,7 @@ var import_node_crypto4, DEFAULT_HOOK_DRAIN_BUDGET_MS, SideEffectRunner;
|
|
|
13486
13510
|
var init_sideEffectRunner = __esm({
|
|
13487
13511
|
"../linkque-agent-runtime/dist/esm/core/hook/sideEffectRunner.js"() {
|
|
13488
13512
|
"use strict";
|
|
13489
|
-
|
|
13513
|
+
init_telemetry();
|
|
13490
13514
|
import_node_crypto4 = require("node:crypto");
|
|
13491
13515
|
init_hookLog();
|
|
13492
13516
|
init_hookMetrics();
|
|
@@ -13724,6 +13748,45 @@ var init_sideEffectRunner = __esm({
|
|
|
13724
13748
|
}
|
|
13725
13749
|
});
|
|
13726
13750
|
|
|
13751
|
+
// ../linkque-agent-runtime/dist/esm/core/telemetry/telemetryEnums.js
|
|
13752
|
+
var ETelemetryDiagnosticCode, ETelemetryAssociation, ETelemetryMetadata;
|
|
13753
|
+
var init_telemetryEnums2 = __esm({
|
|
13754
|
+
"../linkque-agent-runtime/dist/esm/core/telemetry/telemetryEnums.js"() {
|
|
13755
|
+
"use strict";
|
|
13756
|
+
init_telemetry();
|
|
13757
|
+
(function(ETelemetryDiagnosticCode2) {
|
|
13758
|
+
ETelemetryDiagnosticCode2["INVALID_AUTHORIZATION"] = "invalid_authorization";
|
|
13759
|
+
ETelemetryDiagnosticCode2["PARTITION_LIMIT"] = "partition_limit";
|
|
13760
|
+
ETelemetryDiagnosticCode2["UNAVAILABLE_PARTITION"] = "unavailable_partition";
|
|
13761
|
+
ETelemetryDiagnosticCode2["QUEUE_LIMIT"] = "queue_limit";
|
|
13762
|
+
ETelemetryDiagnosticCode2["QUEUE_EXPIRED"] = "queue_expired";
|
|
13763
|
+
ETelemetryDiagnosticCode2["SENDER_FAILED"] = "sender_failed";
|
|
13764
|
+
ETelemetryDiagnosticCode2["PARTIAL_SUCCESS"] = "partial_success";
|
|
13765
|
+
ETelemetryDiagnosticCode2["AUTHORIZATION_REJECTED"] = "authorization_rejected";
|
|
13766
|
+
ETelemetryDiagnosticCode2["PERMANENT_REJECTION"] = "permanent_rejection";
|
|
13767
|
+
ETelemetryDiagnosticCode2["SEND_RETRY"] = "send_retry";
|
|
13768
|
+
ETelemetryDiagnosticCode2["SHUTDOWN_DROP"] = "shutdown_drop";
|
|
13769
|
+
ETelemetryDiagnosticCode2["LOCAL_SINK_FAILED"] = "local_sink_failed";
|
|
13770
|
+
ETelemetryDiagnosticCode2["CAPTURE_FAILED"] = "capture_failed";
|
|
13771
|
+
ETelemetryDiagnosticCode2["IDENTITY_MISMATCH"] = "identity_mismatch";
|
|
13772
|
+
ETelemetryDiagnosticCode2["ACTIVE_LIMIT"] = "active_limit";
|
|
13773
|
+
})(ETelemetryDiagnosticCode || (ETelemetryDiagnosticCode = {}));
|
|
13774
|
+
(function(ETelemetryAssociation2) {
|
|
13775
|
+
ETelemetryAssociation2["LOOP"] = "loop";
|
|
13776
|
+
ETelemetryAssociation2["ITERATION"] = "iteration";
|
|
13777
|
+
ETelemetryAssociation2["MODEL"] = "model";
|
|
13778
|
+
ETelemetryAssociation2["TOOL"] = "tool";
|
|
13779
|
+
ETelemetryAssociation2["PROVIDER"] = "provider";
|
|
13780
|
+
})(ETelemetryAssociation || (ETelemetryAssociation = {}));
|
|
13781
|
+
(function(ETelemetryMetadata2) {
|
|
13782
|
+
ETelemetryMetadata2["SCOPE_NAME"] = "com.alipay.linkque.runtime.telemetry";
|
|
13783
|
+
ETelemetryMetadata2["RUNTIME_KIND"] = "node_toolkit";
|
|
13784
|
+
ETelemetryMetadata2["SERVICE_NAMESPACE"] = "linkque";
|
|
13785
|
+
ETelemetryMetadata2["ROUTE_CONTEXT_KEY"] = "linkque.telemetry.route";
|
|
13786
|
+
})(ETelemetryMetadata || (ETelemetryMetadata = {}));
|
|
13787
|
+
}
|
|
13788
|
+
});
|
|
13789
|
+
|
|
13727
13790
|
// ../linkque-agent-runtime/dist/esm/core/hook/hookToolWrapper.js
|
|
13728
13791
|
function resolveHookToolName(tool) {
|
|
13729
13792
|
return tool.modelName ?? tool.name;
|
|
@@ -13769,7 +13832,8 @@ function wrapToolWithHooks(tool, dispatcher, commonParams, now = Date.now, obser
|
|
|
13769
13832
|
var init_hookToolWrapper = __esm({
|
|
13770
13833
|
"../linkque-agent-runtime/dist/esm/core/hook/hookToolWrapper.js"() {
|
|
13771
13834
|
"use strict";
|
|
13772
|
-
|
|
13835
|
+
init_telemetry();
|
|
13836
|
+
init_telemetryEnums2();
|
|
13773
13837
|
init_esm();
|
|
13774
13838
|
}
|
|
13775
13839
|
});
|
|
@@ -13955,6 +14019,7 @@ var init_httpLoggingFetch = __esm({
|
|
|
13955
14019
|
"x-api-key",
|
|
13956
14020
|
"x-signature-content",
|
|
13957
14021
|
"x-alipay-sdk-version",
|
|
14022
|
+
"x-alipay-authcode",
|
|
13958
14023
|
"anthropic-api-key"
|
|
13959
14024
|
]);
|
|
13960
14025
|
REDACTED_VALUE = "ak***";
|
|
@@ -14614,7 +14679,7 @@ var RuntimeObservation;
|
|
|
14614
14679
|
var init_runtimeObservation = __esm({
|
|
14615
14680
|
"../linkque-agent-runtime/dist/esm/core/telemetry/runtimeObservation.js"() {
|
|
14616
14681
|
"use strict";
|
|
14617
|
-
|
|
14682
|
+
init_telemetry();
|
|
14618
14683
|
init_noopRuntimeTelemetry();
|
|
14619
14684
|
RuntimeObservation = class _RuntimeObservation {
|
|
14620
14685
|
sink;
|
|
@@ -33085,7 +33150,10 @@ var init_run = __esm({
|
|
|
33085
33150
|
"../agent-conversation-contract/dist/esm/run.js"() {
|
|
33086
33151
|
"use strict";
|
|
33087
33152
|
init_version();
|
|
33088
|
-
CONVERSATION_CLIENT_CAPABILITIES = [
|
|
33153
|
+
CONVERSATION_CLIENT_CAPABILITIES = [
|
|
33154
|
+
"location",
|
|
33155
|
+
"userInfo"
|
|
33156
|
+
];
|
|
33089
33157
|
ConversationProtocolValidationError = class extends Error {
|
|
33090
33158
|
issues;
|
|
33091
33159
|
code = "CONVERSATION_PROTOCOL_INVALID";
|
|
@@ -49007,7 +49075,8 @@ var import_node_crypto6;
|
|
|
49007
49075
|
var init_toolObservation = __esm({
|
|
49008
49076
|
"../linkque-agent-runtime/dist/esm/core/telemetry/toolObservation.js"() {
|
|
49009
49077
|
"use strict";
|
|
49010
|
-
|
|
49078
|
+
init_telemetry();
|
|
49079
|
+
init_telemetryEnums2();
|
|
49011
49080
|
import_node_crypto6 = require("node:crypto");
|
|
49012
49081
|
}
|
|
49013
49082
|
});
|
|
@@ -49106,7 +49175,8 @@ var import_node_crypto7, PiTelemetry;
|
|
|
49106
49175
|
var init_piTelemetry = __esm({
|
|
49107
49176
|
"../linkque-agent-runtime/dist/esm/impl/agent/pi/piTelemetry.js"() {
|
|
49108
49177
|
"use strict";
|
|
49109
|
-
|
|
49178
|
+
init_telemetry();
|
|
49179
|
+
init_telemetryEnums2();
|
|
49110
49180
|
init_toolObservation();
|
|
49111
49181
|
import_node_crypto7 = require("node:crypto");
|
|
49112
49182
|
PiTelemetry = class {
|
|
@@ -205152,7 +205222,7 @@ function safeStringifyPayload(payload) {
|
|
|
205152
205222
|
var init_createAgentSession = __esm({
|
|
205153
205223
|
"../linkque-agent-runtime/dist/esm/impl/agent/pi/createAgentSession.js"() {
|
|
205154
205224
|
"use strict";
|
|
205155
|
-
|
|
205225
|
+
init_telemetry();
|
|
205156
205226
|
init_piTelemetry();
|
|
205157
205227
|
init_logFailure();
|
|
205158
205228
|
init_dist4();
|
|
@@ -206033,7 +206103,7 @@ var ERROR_FLUSH_TIMEOUT_MS;
|
|
|
206033
206103
|
var init_runtimeErrorBoundary = __esm({
|
|
206034
206104
|
"../linkque-agent-runtime/dist/esm/core/telemetry/runtimeErrorBoundary.js"() {
|
|
206035
206105
|
"use strict";
|
|
206036
|
-
|
|
206106
|
+
init_telemetry();
|
|
206037
206107
|
init_runtimeObservation();
|
|
206038
206108
|
ERROR_FLUSH_TIMEOUT_MS = 200;
|
|
206039
206109
|
}
|
|
@@ -206567,7 +206637,7 @@ var init_cardRenderMcpServer = __esm({
|
|
|
206567
206637
|
description: createPresentationDescription(config2),
|
|
206568
206638
|
inputSchema: config2.presentationInputSchema,
|
|
206569
206639
|
// execute 委托 callTool,返回 IAgentPresentationToolResult(execute 返回 unknown 兼容)。
|
|
206570
|
-
execute: (args, signal) => this.callTool(name, args, signal)
|
|
206640
|
+
execute: (args, signal, context2) => this.callTool(name, args, signal, { context: context2 })
|
|
206571
206641
|
});
|
|
206572
206642
|
continue;
|
|
206573
206643
|
}
|
|
@@ -206624,7 +206694,7 @@ var init_cardRenderMcpServer = __esm({
|
|
|
206624
206694
|
description: `\u9009\u62E9 ${name} \u540E\u4F7F\u7528\u3002${source.purpose}\u3002\u6839\u636E\u5BF9\u8BDD\u548C\u5DF2\u6709\u6570\u636E\u6E90\u7ED3\u679C\u786E\u5B9A\u6240\u6709 MCP \u53C2\u6570\u3002${CARD_SEQUENCE}`,
|
|
206625
206695
|
inputSchema: normalizeMcpInputSchema(discoveredHandle?.inputSchema),
|
|
206626
206696
|
outputSchema: CARD_SOURCE_RECEIPT_SCHEMA,
|
|
206627
|
-
execute: async (args, signal) => {
|
|
206697
|
+
execute: async (args, signal, context2) => {
|
|
206628
206698
|
if (!state2.selected || this.activeCardId !== resource.resourceId)
|
|
206629
206699
|
throw new Error(`\u8C03\u7528\u6570\u636E\u6E90\u524D\uFF0C\u8BF7\u5148\u9009\u62E9\u5361\u7247 ${name}`);
|
|
206630
206700
|
const missingDependencies = (source.dependsOn ?? []).filter((dependency) => !state2.results.has(dependency));
|
|
@@ -206634,7 +206704,7 @@ var init_cardRenderMcpServer = __esm({
|
|
|
206634
206704
|
if (!handle)
|
|
206635
206705
|
throw new Error(`MCP \u5DE5\u5177 ${source.mcpResourceId}/${source.toolName} \u5F53\u524D\u4E0D\u53EF\u7528`);
|
|
206636
206706
|
const mcpStartedAt = Date.now();
|
|
206637
|
-
const result = await handle.execute(args, signal);
|
|
206707
|
+
const result = await handle.execute(args, signal, context2);
|
|
206638
206708
|
signal?.throwIfAborted();
|
|
206639
206709
|
if (this.closed)
|
|
206640
206710
|
throw new Error("\u5361\u7247\u8FD0\u884C\u5DF2\u7ED3\u675F");
|
|
@@ -206742,22 +206812,22 @@ ${AFTER_CARD_DESCRIPTION}`,
|
|
|
206742
206812
|
this.toolByName = new Map(tools.map((tool) => [tool.name, tool]));
|
|
206743
206813
|
return tools;
|
|
206744
206814
|
}
|
|
206745
|
-
async callTool(name, args, signal) {
|
|
206815
|
+
async callTool(name, args, signal, options) {
|
|
206746
206816
|
const resource = this.resources.find((r2) => createCardPresentationToolName(r2.resourceId) === name);
|
|
206747
206817
|
if (!resource) {
|
|
206748
206818
|
const descriptor = this.toolByName.get(name);
|
|
206749
206819
|
if (!descriptor)
|
|
206750
206820
|
throw new Error(`\u672A\u77E5\u5361\u7247\u5DE5\u5177: ${name}`);
|
|
206751
|
-
return descriptor.execute(args, signal);
|
|
206821
|
+
return descriptor.execute(args, signal, options?.context);
|
|
206752
206822
|
}
|
|
206753
206823
|
const config2 = parseCardConfig(resource);
|
|
206754
206824
|
if (config2.schemaVersion === "3" || config2.schemaVersion === "4") {
|
|
206755
206825
|
const descriptor = this.toolByName.get(name);
|
|
206756
206826
|
if (!descriptor)
|
|
206757
206827
|
throw new Error(`\u672A\u77E5\u5361\u7247\u5DE5\u5177: ${name}`);
|
|
206758
|
-
return descriptor.execute(args, signal);
|
|
206828
|
+
return descriptor.execute(args, signal, options?.context);
|
|
206759
206829
|
}
|
|
206760
|
-
return executeCardPresentation(resource, this.registry, this.runtimeContext, args, signal);
|
|
206830
|
+
return executeCardPresentation(resource, this.registry, this.runtimeContext, args, signal, options?.context);
|
|
206761
206831
|
}
|
|
206762
206832
|
async close() {
|
|
206763
206833
|
this.closed = true;
|
|
@@ -207053,7 +207123,7 @@ var DEFAULT_HARNESS_PROMPT, AgentRuntime;
|
|
|
207053
207123
|
var init_agentRuntime = __esm({
|
|
207054
207124
|
"../linkque-agent-runtime/dist/esm/core/agentRuntime.js"() {
|
|
207055
207125
|
"use strict";
|
|
207056
|
-
|
|
207126
|
+
init_telemetry();
|
|
207057
207127
|
init_noopRuntimeTelemetry();
|
|
207058
207128
|
init_runtimeErrorBoundary();
|
|
207059
207129
|
init_toolObservation();
|
|
@@ -207425,7 +207495,8 @@ var init_agentRuntime = __esm({
|
|
|
207425
207495
|
debugLog?.("[mcp] no mcp servers configured (no MCP tools will be available)", EDebugLogScope.MCP);
|
|
207426
207496
|
}
|
|
207427
207497
|
const mcpProxy = new McpProxyTool(this.mcpServerProvider, mcpServerSpecs, {
|
|
207428
|
-
debugLog
|
|
207498
|
+
debugLog,
|
|
207499
|
+
...options.mcpCallAuthorizer ? { authorizeCall: options.mcpCallAuthorizer } : {}
|
|
207429
207500
|
});
|
|
207430
207501
|
cleanup.push(() => mcpProxy.closeAll());
|
|
207431
207502
|
const cardServer = new CardRenderMcpServer(this.cardResources, mcpProxy, { ...options.runtimeContext, threadId: request.threadId }, debugLog);
|
|
@@ -207641,6 +207712,8 @@ async function* runConversation(request, auth2, options = {}) {
|
|
|
207641
207712
|
runOptions.requestSource = options.requestSource;
|
|
207642
207713
|
if (options.debugLog)
|
|
207643
207714
|
runOptions.debugLog = options.debugLog;
|
|
207715
|
+
if (options.mcpCallAuthorizer)
|
|
207716
|
+
runOptions.mcpCallAuthorizer = options.mcpCallAuthorizer;
|
|
207644
207717
|
runOptions.runtimeContext = {
|
|
207645
207718
|
...options.runtimeContext,
|
|
207646
207719
|
...request.agentId ? { agentId: request.agentId } : {},
|
|
@@ -207837,17 +207910,72 @@ function parseArgs(args, imageId) {
|
|
|
207837
207910
|
imageError("IMAGE_INPUT_INVALID");
|
|
207838
207911
|
return { imageId, query, mode: args.mode };
|
|
207839
207912
|
}
|
|
207913
|
+
function outputError(reason) {
|
|
207914
|
+
imageError(`IMAGE_OUTPUT_INVALID_${reason}`);
|
|
207915
|
+
}
|
|
207840
207916
|
function parseObservation(value, imageId, mode) {
|
|
207841
|
-
if (!record3(value) || !keys(value, ["version", "imageId", "mode", "truncated", "observation"])
|
|
207842
|
-
|
|
207917
|
+
if (!record3(value) || !keys(value, ["version", "imageId", "mode", "truncated", "observation"]))
|
|
207918
|
+
outputError("ROOT_FIELDS");
|
|
207919
|
+
if (value.version !== "tool-v1")
|
|
207920
|
+
outputError("VERSION");
|
|
207921
|
+
if (value.imageId !== imageId)
|
|
207922
|
+
outputError("IMAGE_ID");
|
|
207923
|
+
if (value.mode !== mode)
|
|
207924
|
+
outputError("MODE");
|
|
207925
|
+
if (typeof value.truncated !== "boolean")
|
|
207926
|
+
outputError("TRUNCATED");
|
|
207843
207927
|
const obs = value.observation;
|
|
207928
|
+
if (!record3(obs) || !keys(obs, ["summary", "ocrText", "facts", "uncertainties"]))
|
|
207929
|
+
outputError("OBSERVATION_FIELDS");
|
|
207844
207930
|
const list = (v, count, chars) => Array.isArray(v) && v.length <= count && v.every((s2) => text(s2, 1, chars));
|
|
207845
|
-
if (!
|
|
207846
|
-
|
|
207847
|
-
if (
|
|
207848
|
-
|
|
207931
|
+
if (!text(obs.summary, 1, 400))
|
|
207932
|
+
outputError("SUMMARY");
|
|
207933
|
+
if (!text(obs.ocrText, 0, 800))
|
|
207934
|
+
outputError("OCR_TEXT");
|
|
207935
|
+
if (!list(obs.facts, 8, 120))
|
|
207936
|
+
outputError("FACTS");
|
|
207937
|
+
if (!list(obs.uncertainties, 6, 160))
|
|
207938
|
+
outputError("UNCERTAINTIES");
|
|
207939
|
+
if ([obs.summary, obs.ocrText, ...obs.facts, ...obs.uncertainties].reduce((n, s2) => n + Array.from(s2).length, 0) > 1200)
|
|
207940
|
+
outputError("OBSERVATION_BUDGET");
|
|
207941
|
+
if (obs.uncertainties.filter((s2) => s2 === MARKER).length !== (value.truncated ? 1 : 0))
|
|
207942
|
+
outputError("TRUNCATION_MARKER");
|
|
207849
207943
|
return { ok: true, ...value };
|
|
207850
207944
|
}
|
|
207945
|
+
function parseImageEnvelope(envelope, imageId, mode) {
|
|
207946
|
+
if (!record3(envelope) || typeof envelope.id !== "string" || !envelope.id || envelope.type !== "message" || envelope.role !== "assistant" || envelope.model !== "linkque-image-understanding")
|
|
207947
|
+
outputError("ENVELOPE");
|
|
207948
|
+
if (envelope.stop_reason !== "end_turn")
|
|
207949
|
+
outputError("STOP_REASON");
|
|
207950
|
+
const usage = envelope.usage;
|
|
207951
|
+
if (!record3(usage) || !["input_tokens", "output_tokens"].every((k) => Number.isSafeInteger(usage[k]) && Number(usage[k]) >= 0))
|
|
207952
|
+
outputError("USAGE");
|
|
207953
|
+
if (!Array.isArray(envelope.content) || !envelope.content.length)
|
|
207954
|
+
outputError("TEXT_EMPTY");
|
|
207955
|
+
const parts = [];
|
|
207956
|
+
for (const block of envelope.content) {
|
|
207957
|
+
if (!record3(block))
|
|
207958
|
+
outputError("BLOCK_TYPE");
|
|
207959
|
+
if (block.type === "thinking" || block.type === "redacted_thinking")
|
|
207960
|
+
continue;
|
|
207961
|
+
if (block.type !== "text")
|
|
207962
|
+
outputError("BLOCK_TYPE");
|
|
207963
|
+
if (typeof block.text !== "string")
|
|
207964
|
+
outputError("TEXT_TYPE");
|
|
207965
|
+
parts.push(block.text);
|
|
207966
|
+
}
|
|
207967
|
+
const visible = parts.join("").trim();
|
|
207968
|
+
if (!visible)
|
|
207969
|
+
outputError("TEXT_EMPTY");
|
|
207970
|
+
const fence = /^```(?:json)?[ \t]*\r?\n([\s\S]*?)\r?\n```$/i.exec(visible);
|
|
207971
|
+
let value;
|
|
207972
|
+
try {
|
|
207973
|
+
value = JSON.parse(fence ? fence[1] : visible);
|
|
207974
|
+
} catch {
|
|
207975
|
+
outputError("TEXT_JSON");
|
|
207976
|
+
}
|
|
207977
|
+
return parseObservation(value, imageId, mode);
|
|
207978
|
+
}
|
|
207851
207979
|
var IMAGE_PROMPT, MODES, MARKER;
|
|
207852
207980
|
var init_contract = __esm({
|
|
207853
207981
|
"../linkque-agent-runtime/dist/esm/impl/plugin/imageUnderstanding/contract.js"() {
|
|
@@ -207970,19 +208098,11 @@ function createImageTool(image, input, options, rules) {
|
|
|
207970
208098
|
}
|
|
207971
208099
|
let envelope;
|
|
207972
208100
|
try {
|
|
207973
|
-
envelope = JSON.parse(
|
|
208101
|
+
envelope = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(await boundedBody(response, 128 * 1024)));
|
|
207974
208102
|
} catch {
|
|
207975
|
-
imageError("
|
|
208103
|
+
imageError("IMAGE_OUTPUT_INVALID_ENVELOPE_JSON");
|
|
207976
208104
|
}
|
|
207977
|
-
|
|
207978
|
-
imageError("IMAGE_OUTPUT_INVALID");
|
|
207979
|
-
let value;
|
|
207980
|
-
try {
|
|
207981
|
-
value = JSON.parse(envelope.content.map((block) => block.text).join(""));
|
|
207982
|
-
} catch {
|
|
207983
|
-
imageError("IMAGE_OUTPUT_INVALID");
|
|
207984
|
-
}
|
|
207985
|
-
return parseObservation(value, image.id, parsed.mode);
|
|
208105
|
+
return parseImageEnvelope(envelope, image.id, parsed.mode);
|
|
207986
208106
|
} catch (error40) {
|
|
207987
208107
|
if (signal.aborted)
|
|
207988
208108
|
imageError("IMAGE_CANCELLED");
|
|
@@ -208304,6 +208424,49 @@ init_cardTools();
|
|
|
208304
208424
|
init_mcpNaming();
|
|
208305
208425
|
init_mcpAggregator();
|
|
208306
208426
|
|
|
208427
|
+
// ../linkque-agent-runtime/dist/esm/core/mcpPhoneAuthorization.js
|
|
208428
|
+
init_esm();
|
|
208429
|
+
var McpPhoneAuthorizationRequiredError = class extends Error {
|
|
208430
|
+
required;
|
|
208431
|
+
code = "MCP_PHONE_AUTHORIZATION_REQUIRED";
|
|
208432
|
+
constructor(required2) {
|
|
208433
|
+
super("\u8C03\u7528\u8BE5 MCP Tool \u524D\u9700\u8981\u83B7\u53D6\u624B\u673A\u53F7\u6388\u6743");
|
|
208434
|
+
this.required = required2;
|
|
208435
|
+
this.name = "McpPhoneAuthorizationRequiredError";
|
|
208436
|
+
}
|
|
208437
|
+
};
|
|
208438
|
+
var McpPhoneAuthorizationFailedError = class extends Error {
|
|
208439
|
+
code = "MCP_PHONE_AUTHORIZATION_FAILED";
|
|
208440
|
+
constructor() {
|
|
208441
|
+
super("\u672A\u53D6\u5F97\u624B\u673A\u53F7\u6388\u6743\uFF0C\u65E0\u6CD5\u8C03\u7528\u8BE5 MCP Tool");
|
|
208442
|
+
this.name = "McpPhoneAuthorizationFailedError";
|
|
208443
|
+
}
|
|
208444
|
+
};
|
|
208445
|
+
function createRequestMcpPhoneAuthorizer(protocol, attempt) {
|
|
208446
|
+
return async ({ resourceIds, toolName, signal }) => {
|
|
208447
|
+
if (signal?.aborted)
|
|
208448
|
+
throw Object.assign(new Error("\u64CD\u4F5C\u5DF2\u53D6\u6D88"), { name: "AbortError" });
|
|
208449
|
+
const policy = resolvePhoneAuthorizationDependency(protocol, resourceIds, toolName);
|
|
208450
|
+
if (!policy)
|
|
208451
|
+
return void 0;
|
|
208452
|
+
if (attempt?.kind === "authorized")
|
|
208453
|
+
return { "x-alipay-authcode": attempt.authCode };
|
|
208454
|
+
if (attempt?.kind === "unavailable") {
|
|
208455
|
+
if (policy.required)
|
|
208456
|
+
throw new McpPhoneAuthorizationFailedError();
|
|
208457
|
+
return void 0;
|
|
208458
|
+
}
|
|
208459
|
+
throw new McpPhoneAuthorizationRequiredError(policy.required);
|
|
208460
|
+
};
|
|
208461
|
+
}
|
|
208462
|
+
function isMcpPhoneAuthorizationError(error40) {
|
|
208463
|
+
return error40 instanceof McpPhoneAuthorizationRequiredError || error40 instanceof McpPhoneAuthorizationFailedError;
|
|
208464
|
+
}
|
|
208465
|
+
function resolvePhoneAuthorizationDependency(protocol, resourceIds, toolName) {
|
|
208466
|
+
const dependencies = protocol.agent.resources.filter((resource) => resource.resourceType === EResourceType.MCP_TOOL).flatMap((resource) => resourceIds.includes(resource.resourceId) && resource.config.toolName === toolName ? (resource.config.dependencies ?? []).filter((dependency) => dependency.name === "phoneAuthorization") : []);
|
|
208467
|
+
return dependencies.length ? { required: dependencies.some((dependency) => dependency.required) } : void 0;
|
|
208468
|
+
}
|
|
208469
|
+
|
|
208307
208470
|
// ../linkque-agent-runtime/dist/esm/core/homeData.js
|
|
208308
208471
|
init_esm2();
|
|
208309
208472
|
init_esm();
|
|
@@ -208331,7 +208494,9 @@ async function executeHomeData(input) {
|
|
|
208331
208494
|
if (spec.allowedTools && !spec.allowedTools.has(request.binding.toolName)) {
|
|
208332
208495
|
return failure("TOOL_NOT_ALLOWED", "\u5F53\u524D Agent \u672A\u5141\u8BB8\u8C03\u7528\u8BE5 MCP \u5DE5\u5177", false);
|
|
208333
208496
|
}
|
|
208334
|
-
const registry2 = new McpProxyTool(input.mcpServerProvider, specs
|
|
208497
|
+
const registry2 = new McpProxyTool(input.mcpServerProvider, specs, {
|
|
208498
|
+
authorizeCall: createRequestMcpPhoneAuthorizer(input.protocol, input.phoneAuthorization)
|
|
208499
|
+
});
|
|
208335
208500
|
try {
|
|
208336
208501
|
const handle = await registry2.resolve(spec.resourceIds[0], request.binding.toolName, input.signal);
|
|
208337
208502
|
if (!handle) {
|
|
@@ -208359,6 +208524,8 @@ async function executeHomeData(input) {
|
|
|
208359
208524
|
try {
|
|
208360
208525
|
result = await handle.execute(toolInput, input.signal);
|
|
208361
208526
|
} catch (error40) {
|
|
208527
|
+
if (isMcpPhoneAuthorizationError(error40))
|
|
208528
|
+
throw error40;
|
|
208362
208529
|
return failure("EXECUTION_FAILED", error40 instanceof Error ? error40.message : "MCP \u5DE5\u5177\u8C03\u7528\u5931\u8D25", true);
|
|
208363
208530
|
}
|
|
208364
208531
|
const structured = readStructuredContent2(result);
|
|
@@ -208610,7 +208777,7 @@ async function executeCardActionInternal(input, diagnostics) {
|
|
|
208610
208777
|
});
|
|
208611
208778
|
diagnostics.write("binding_resolved", { output: createTrade });
|
|
208612
208779
|
diagnostics.stage = "tool_resolve";
|
|
208613
|
-
const registry2 = createRegistry(input.protocol, input.mcpServerProvider, diagnostics.debugLog);
|
|
208780
|
+
const registry2 = createRegistry(input.protocol, input.mcpServerProvider, diagnostics.debugLog, input.phoneAuthorization);
|
|
208614
208781
|
try {
|
|
208615
208782
|
diagnostics.write("tool_resolve_started", { input: createTrade });
|
|
208616
208783
|
const tool = await registry2.resolve(createTrade.mcpResourceId, createTrade.toolName, input.signal);
|
|
@@ -208638,6 +208805,8 @@ async function executeCardActionInternal(input, diagnostics) {
|
|
|
208638
208805
|
diagnostics.write("tool_completed", { output: result });
|
|
208639
208806
|
} catch (error40) {
|
|
208640
208807
|
diagnostics.error("tool_failed", error40);
|
|
208808
|
+
if (isMcpPhoneAuthorizationError(error40))
|
|
208809
|
+
throw error40;
|
|
208641
208810
|
return failure2("EXECUTION_FAILED", "\u521B\u5EFA\u4EA4\u6613\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5", true);
|
|
208642
208811
|
}
|
|
208643
208812
|
diagnostics.stage = "tool_output";
|
|
@@ -208777,9 +208946,12 @@ function materializeValue(definition, supplied) {
|
|
|
208777
208946
|
}
|
|
208778
208947
|
return definition;
|
|
208779
208948
|
}
|
|
208780
|
-
function createRegistry(protocol, provider, debugLog) {
|
|
208949
|
+
function createRegistry(protocol, provider, debugLog, phoneAuthorization) {
|
|
208781
208950
|
const resources = protocol.agent.resources.filter((resource) => resource.resourceType === EResourceType.MCP || resource.resourceType === EResourceType.MCP_TOOL);
|
|
208782
|
-
return new McpProxyTool(provider, aggregateMcpServers(resources, protocol.agentId), {
|
|
208951
|
+
return new McpProxyTool(provider, aggregateMcpServers(resources, protocol.agentId), {
|
|
208952
|
+
debugLog,
|
|
208953
|
+
authorizeCall: createRequestMcpPhoneAuthorizer(protocol, phoneAuthorization)
|
|
208954
|
+
});
|
|
208783
208955
|
}
|
|
208784
208956
|
function readStructuredContent3(result) {
|
|
208785
208957
|
const object3 = cloneJsonObject(result);
|
|
@@ -208819,7 +208991,9 @@ async function executeAuthorizedMcp(input) {
|
|
|
208819
208991
|
if (!input.userId.trim())
|
|
208820
208992
|
return failure3("AUTH_REQUIRED", "\u7F3A\u5C11\u53EF\u4FE1\u7528\u6237\u8EAB\u4EFD", false);
|
|
208821
208993
|
const resources = input.protocol.agent.resources.filter((resource) => resource.resourceType === EResourceType.MCP || resource.resourceType === EResourceType.MCP_TOOL);
|
|
208822
|
-
const registry2 = new McpProxyTool(input.mcpServerProvider, aggregateMcpServers(resources, input.protocol.agentId)
|
|
208994
|
+
const registry2 = new McpProxyTool(input.mcpServerProvider, aggregateMcpServers(resources, input.protocol.agentId), {
|
|
208995
|
+
authorizeCall: createRequestMcpPhoneAuthorizer(input.protocol, input.phoneAuthorization)
|
|
208996
|
+
});
|
|
208823
208997
|
try {
|
|
208824
208998
|
const tool = await registry2.resolve(input.tool.mcpResourceId, input.tool.toolName, input.signal);
|
|
208825
208999
|
if (!tool)
|
|
@@ -208831,7 +209005,9 @@ async function executeAuthorizedMcp(input) {
|
|
|
208831
209005
|
let result;
|
|
208832
209006
|
try {
|
|
208833
209007
|
result = await tool.execute(input.tool.input, input.signal);
|
|
208834
|
-
} catch {
|
|
209008
|
+
} catch (error40) {
|
|
209009
|
+
if (isMcpPhoneAuthorizationError(error40))
|
|
209010
|
+
throw error40;
|
|
208835
209011
|
return failure3("EXECUTION_UNCERTAIN", "MCP \u6267\u884C\u7ED3\u679C\u4E0D\u786E\u5B9A\uFF0C\u8BF7\u52FF\u81EA\u52A8\u91CD\u8BD5", false);
|
|
208836
209012
|
}
|
|
208837
209013
|
const structured = readStructuredContent4(result);
|
|
@@ -208895,7 +209071,8 @@ async function executeFunctionActionMcp(input) {
|
|
|
208895
209071
|
callId: request.callId,
|
|
208896
209072
|
tool: request.tool,
|
|
208897
209073
|
mcpServerProvider: input.mcpServerProvider,
|
|
208898
|
-
signal: input.signal
|
|
209074
|
+
signal: input.signal,
|
|
209075
|
+
phoneAuthorization: input.phoneAuthorization
|
|
208899
209076
|
});
|
|
208900
209077
|
}
|
|
208901
209078
|
function failure4(code, message, retryable) {
|
|
@@ -208929,7 +209106,7 @@ init_createKnowledgeTools();
|
|
|
208929
209106
|
init_noopWebSearchPort();
|
|
208930
209107
|
init_noopRuntimeTelemetry();
|
|
208931
209108
|
init_runtimeObservation();
|
|
208932
|
-
|
|
209109
|
+
init_telemetryEnums2();
|
|
208933
209110
|
|
|
208934
209111
|
// ../../node_modules/zod/v4/mini/parse.js
|
|
208935
209112
|
init_core2();
|
|
@@ -213947,7 +214124,7 @@ var SSEClientTransport = class {
|
|
|
213947
214124
|
init_httpLoggingFetch();
|
|
213948
214125
|
var ALIPAY_SDK_VERSION = "@alipay/open-mcp-server-2.0.4";
|
|
213949
214126
|
var OAGW_ALIPAY_UID_HEADER = "x-oagw-alipay-uid";
|
|
213950
|
-
function createSigningFetch(signer, baseFetch = globalThis.fetch, onTraceId, debugLog) {
|
|
214127
|
+
function createSigningFetch(signer, baseFetch = globalThis.fetch, onTraceId, debugLog, getCallHeaders) {
|
|
213951
214128
|
const loggedFetch = debugLog ? createHttpLoggingFetch(debugLog, "mcp-call", baseFetch) : baseFetch;
|
|
213952
214129
|
return async (url2, init) => {
|
|
213953
214130
|
const targetUrl = url2 instanceof URL ? url2 : new URL(typeof url2 === "string" ? url2 : url2.url);
|
|
@@ -213966,6 +214143,13 @@ function createSigningFetch(signer, baseFetch = globalThis.fetch, onTraceId, deb
|
|
|
213966
214143
|
} else {
|
|
213967
214144
|
headers.delete(OAGW_ALIPAY_UID_HEADER);
|
|
213968
214145
|
}
|
|
214146
|
+
if ((init?.method ?? "GET").toUpperCase() === "POST") {
|
|
214147
|
+
const authCode = getCallHeaders?.()?.["x-alipay-authcode"];
|
|
214148
|
+
if (authCode)
|
|
214149
|
+
headers.set("x-alipay-authcode", authCode);
|
|
214150
|
+
else
|
|
214151
|
+
headers.delete("x-alipay-authcode");
|
|
214152
|
+
}
|
|
213969
214153
|
const resp = await loggedFetch(url2, { ...init, headers });
|
|
213970
214154
|
if (onTraceId) {
|
|
213971
214155
|
try {
|
|
@@ -213994,10 +214178,10 @@ function withTimeout(fetch3, timeoutMs) {
|
|
|
213994
214178
|
return fetch3(url2, { ...init, signal });
|
|
213995
214179
|
};
|
|
213996
214180
|
}
|
|
213997
|
-
function createSseTransport(config2, signer, onTraceId, debugLog) {
|
|
214181
|
+
function createSseTransport(config2, signer, onTraceId, debugLog, getCallHeaders) {
|
|
213998
214182
|
const url2 = new URL(config2.sseEndpoint, config2.remoteBaseUrl);
|
|
213999
214183
|
const timeoutMs = config2.requestTimeoutMs ?? 18e4;
|
|
214000
|
-
const signingFetch = withTimeout(createSigningFetch(signer, void 0, onTraceId, debugLog), timeoutMs);
|
|
214184
|
+
const signingFetch = withTimeout(createSigningFetch(signer, void 0, onTraceId, debugLog, getCallHeaders), timeoutMs);
|
|
214001
214185
|
return new SSEClientTransport(url2, {
|
|
214002
214186
|
// SSE 建连(EventSource)的 GET fetch:SDK 先包默认头再调这里。
|
|
214003
214187
|
eventSourceInit: { fetch: signingFetch },
|
|
@@ -214101,6 +214285,7 @@ function applyArgsMappingRules(toolName, args, rules) {
|
|
|
214101
214285
|
init_esm();
|
|
214102
214286
|
|
|
214103
214287
|
// ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/remoteGatewayMcpServer.js
|
|
214288
|
+
var import_node_async_hooks = require("node:async_hooks");
|
|
214104
214289
|
init_types();
|
|
214105
214290
|
init_logFailure();
|
|
214106
214291
|
var defaultCreateSigner = (config2, getAuthorizationHeader, debugLog) => new RemoteSignatureSigner({
|
|
@@ -214132,8 +214317,9 @@ var RemoteGatewayMcpServerProvider = class {
|
|
|
214132
214317
|
/** 连单个远端 server 并包装成 IMcpServer。建连失败有限重试 + 失败清理由 helper 负责。 */
|
|
214133
214318
|
async connectOne(resource) {
|
|
214134
214319
|
const config2 = await this.resolveConfig(resource);
|
|
214320
|
+
const callHeaders = new import_node_async_hooks.AsyncLocalStorage();
|
|
214135
214321
|
const { client } = await connectMcpClientWithRetry(config2, {
|
|
214136
|
-
createTransport: () => createSseTransport(config2, this.createSigner(config2, this.getAuthorizationHeader), this.onTraceId, this.debugLog),
|
|
214322
|
+
createTransport: () => createSseTransport(config2, this.createSigner(config2, this.getAuthorizationHeader), this.onTraceId, this.debugLog, () => callHeaders.getStore()),
|
|
214137
214323
|
createClient: () => this.createClient()
|
|
214138
214324
|
});
|
|
214139
214325
|
const serverName = resource.config.serverName ?? resource.resourceId;
|
|
@@ -214168,12 +214354,9 @@ var RemoteGatewayMcpServerProvider = class {
|
|
|
214168
214354
|
resourceId: resource.resourceId,
|
|
214169
214355
|
serverName,
|
|
214170
214356
|
listTools: () => listToolsFromClient(loggedClient, resource.resourceId),
|
|
214171
|
-
callTool: (name, args) => {
|
|
214357
|
+
callTool: (name, args, _signal, options) => {
|
|
214172
214358
|
const mapped = applyArgsMappingRules(name, args, argsMappingRules);
|
|
214173
|
-
return loggedClient.callTool({
|
|
214174
|
-
name,
|
|
214175
|
-
arguments: mapped ?? {}
|
|
214176
|
-
});
|
|
214359
|
+
return callHeaders.run(options?.headers ?? {}, () => loggedClient.callTool({ name, arguments: mapped ?? {} }));
|
|
214177
214360
|
},
|
|
214178
214361
|
close: async () => {
|
|
214179
214362
|
try {
|
|
@@ -215413,7 +215596,8 @@ init_conversationBridge();
|
|
|
215413
215596
|
init_config();
|
|
215414
215597
|
|
|
215415
215598
|
// ../linkque-agent-runtime/dist/esm/impl/telemetry/otelRuntimeTelemetry.js
|
|
215416
|
-
|
|
215599
|
+
init_telemetry();
|
|
215600
|
+
init_telemetryEnums2();
|
|
215417
215601
|
var import_node_crypto5 = require("node:crypto");
|
|
215418
215602
|
init_esm6();
|
|
215419
215603
|
var import_sdk_trace_base = __toESM(require_index_shim(), 1);
|
|
@@ -215424,8 +215608,9 @@ var import_otlp_transformer = __toESM(require_src7(), 1);
|
|
|
215424
215608
|
init_noopRuntimeTelemetry();
|
|
215425
215609
|
|
|
215426
215610
|
// ../linkque-agent-runtime/dist/esm/impl/telemetry/identityQueue.js
|
|
215427
|
-
|
|
215428
|
-
|
|
215611
|
+
init_telemetry();
|
|
215612
|
+
init_telemetryEnums2();
|
|
215613
|
+
var import_node_async_hooks2 = require("node:async_hooks");
|
|
215429
215614
|
init_esm6();
|
|
215430
215615
|
var import_core11 = __toESM(require_src(), 1);
|
|
215431
215616
|
function authorizationKey(auth2) {
|
|
@@ -215439,7 +215624,7 @@ function authorizationKey(auth2) {
|
|
|
215439
215624
|
}
|
|
215440
215625
|
var IdentityQueue = class {
|
|
215441
215626
|
options;
|
|
215442
|
-
exportContext = new
|
|
215627
|
+
exportContext = new import_node_async_hooks2.AsyncLocalStorage();
|
|
215443
215628
|
get isExporting() {
|
|
215444
215629
|
return this.exportContext.getStore() === true;
|
|
215445
215630
|
}
|
|
@@ -215752,7 +215937,7 @@ var IdentityQueue = class {
|
|
|
215752
215937
|
};
|
|
215753
215938
|
|
|
215754
215939
|
// ../linkque-agent-runtime/dist/esm/impl/telemetry/attributes.js
|
|
215755
|
-
|
|
215940
|
+
init_telemetry();
|
|
215756
215941
|
var MAX_ATTRIBUTE_COUNT = 64;
|
|
215757
215942
|
var MAX_STRING_LENGTH = 256;
|
|
215758
215943
|
var MAX_ARRAY_LENGTH = 16;
|
|
@@ -216283,21 +216468,22 @@ function createSandboxMcpHandler() {
|
|
|
216283
216468
|
if (payload.agentId !== void 0 && payload.agentId !== protocol.agentId) {
|
|
216284
216469
|
return failure5(403, "AGENT_MISMATCH", "Agent \u4E0D\u5339\u914D");
|
|
216285
216470
|
}
|
|
216286
|
-
if (value.operation === "homeData.request") {
|
|
216287
|
-
const result = await executeHomeData({
|
|
216288
|
-
request: { ...payload, agentId: protocol.agentId },
|
|
216289
|
-
protocol,
|
|
216290
|
-
userId,
|
|
216291
|
-
mcpServerProvider: provider
|
|
216292
|
-
});
|
|
216293
|
-
return { status: result.ok ? 200 : 400, body: result };
|
|
216294
|
-
}
|
|
216295
|
-
if (value.operation !== "mcp.call" || typeof payload.callId !== "string" || !/^[A-Za-z0-9._:-]{1,128}$/u.test(payload.callId) || !record2(payload.tool) || typeof payload.tool.mcpResourceId !== "string" || !payload.tool.mcpResourceId.trim() || typeof payload.tool.toolName !== "string" || !payload.tool.toolName.trim() || !record2(payload.tool.input) || Object.keys(payload.tool).some(
|
|
216296
|
-
(key) => !["mcpResourceId", "toolName", "input"].includes(key)
|
|
216297
|
-
)) {
|
|
216298
|
-
return failure5(400, "INVALID_INPUT", "MCP \u8C03\u7528\u53C2\u6570\u65E0\u6548");
|
|
216299
|
-
}
|
|
216300
216471
|
try {
|
|
216472
|
+
if (value.operation === "homeData.request") {
|
|
216473
|
+
const result2 = await executeHomeData({
|
|
216474
|
+
request: { ...payload, agentId: protocol.agentId },
|
|
216475
|
+
protocol,
|
|
216476
|
+
userId,
|
|
216477
|
+
mcpServerProvider: provider,
|
|
216478
|
+
phoneAuthorization: { kind: "unavailable" }
|
|
216479
|
+
});
|
|
216480
|
+
return { status: result2.ok ? 200 : 400, body: result2 };
|
|
216481
|
+
}
|
|
216482
|
+
if (value.operation !== "mcp.call" || typeof payload.callId !== "string" || !/^[A-Za-z0-9._:-]{1,128}$/u.test(payload.callId) || !record2(payload.tool) || typeof payload.tool.mcpResourceId !== "string" || !payload.tool.mcpResourceId.trim() || typeof payload.tool.toolName !== "string" || !payload.tool.toolName.trim() || !record2(payload.tool.input) || Object.keys(payload.tool).some(
|
|
216483
|
+
(key) => !["mcpResourceId", "toolName", "input"].includes(key)
|
|
216484
|
+
)) {
|
|
216485
|
+
return failure5(400, "INVALID_INPUT", "MCP \u8C03\u7528\u53C2\u6570\u65E0\u6548");
|
|
216486
|
+
}
|
|
216301
216487
|
const result = await executeAuthorizedMcp({
|
|
216302
216488
|
protocol,
|
|
216303
216489
|
agentId: protocol.agentId,
|
|
@@ -216308,13 +216494,17 @@ function createSandboxMcpHandler() {
|
|
|
216308
216494
|
toolName: payload.tool.toolName,
|
|
216309
216495
|
input: payload.tool.input
|
|
216310
216496
|
},
|
|
216311
|
-
mcpServerProvider: provider
|
|
216497
|
+
mcpServerProvider: provider,
|
|
216498
|
+
phoneAuthorization: { kind: "unavailable" }
|
|
216312
216499
|
});
|
|
216313
216500
|
return {
|
|
216314
216501
|
status: result.ok ? 200 : result.error.code === "EXECUTION_UNCERTAIN" ? 409 : 400,
|
|
216315
216502
|
body: result
|
|
216316
216503
|
};
|
|
216317
|
-
} catch {
|
|
216504
|
+
} catch (error40) {
|
|
216505
|
+
if (error40 instanceof McpPhoneAuthorizationFailedError) {
|
|
216506
|
+
return failure5(403, error40.code, "\u6C99\u7BB1\u4E0D\u652F\u6301\u624B\u673A\u53F7\u6388\u6743\uFF0C\u8BF7\u4F7F\u7528\u771F\u673A\u9884\u89C8");
|
|
216507
|
+
}
|
|
216318
216508
|
return failure5(
|
|
216319
216509
|
409,
|
|
216320
216510
|
"EXECUTION_UNCERTAIN",
|
|
@@ -216744,6 +216934,7 @@ var handleSandboxChat = async (req, res, deps, activeRuns2, cancelActiveRun2) =>
|
|
|
216744
216934
|
cwd: deps.cwd,
|
|
216745
216935
|
signal: abort.signal,
|
|
216746
216936
|
telemetryContext: deps.createTelemetryContext(request.runId),
|
|
216937
|
+
mcpCallAuthorizer: deps.createMcpCallAuthorizer(protocol),
|
|
216747
216938
|
debugLog: deps.debugLog,
|
|
216748
216939
|
...inboundUserId && { runtimeContext: { userId: inboundUserId } }
|
|
216749
216940
|
});
|
|
@@ -216955,6 +217146,9 @@ var handleRun = async (req, res, input, debugLog) => {
|
|
|
216955
217146
|
agentId: input.agentId,
|
|
216956
217147
|
bodyMaxBytes: 1024 * 1024,
|
|
216957
217148
|
createRuntime,
|
|
217149
|
+
createMcpCallAuthorizer: (protocol) => createRequestMcpPhoneAuthorizer(protocol, {
|
|
217150
|
+
kind: "unavailable"
|
|
217151
|
+
}),
|
|
216958
217152
|
debugLog,
|
|
216959
217153
|
createTelemetryContext: agentDevTelemetry.createContext
|
|
216960
217154
|
},
|
|
@@ -216993,7 +217187,8 @@ var handleHomeData = async (req, res, input) => {
|
|
|
216993
217187
|
request: homeDataInput.request,
|
|
216994
217188
|
protocol,
|
|
216995
217189
|
userId: homeDataInput.userId,
|
|
216996
|
-
mcpServerProvider: createMcpServerProvider(protocol)
|
|
217190
|
+
mcpServerProvider: createMcpServerProvider(protocol),
|
|
217191
|
+
phoneAuthorization: { kind: "unavailable" }
|
|
216997
217192
|
});
|
|
216998
217193
|
res.writeHead(200, { "content-type": "application/json; charset=utf-8" });
|
|
216999
217194
|
res.end(JSON.stringify(result));
|
|
@@ -217031,6 +217226,7 @@ var handleA2UIAction = async (req, res, input, debugLog) => {
|
|
|
217031
217226
|
...proxyInput.tenantId ? { tenantId: proxyInput.tenantId } : {}
|
|
217032
217227
|
},
|
|
217033
217228
|
mcpServerProvider: createMcpServerProvider(protocol),
|
|
217229
|
+
phoneAuthorization: { kind: "unavailable" },
|
|
217034
217230
|
debugLog
|
|
217035
217231
|
});
|
|
217036
217232
|
res.writeHead(200, { "content-type": "application/json; charset=utf-8" });
|
|
@@ -217062,7 +217258,8 @@ var handleFunctionActionMcp = async (req, res, input) => {
|
|
|
217062
217258
|
request: proxyInput.request,
|
|
217063
217259
|
protocol,
|
|
217064
217260
|
runtimeContext: { threadId: request.threadId, userId: proxyInput.userId },
|
|
217065
|
-
mcpServerProvider: createMcpServerProvider(protocol)
|
|
217261
|
+
mcpServerProvider: createMcpServerProvider(protocol),
|
|
217262
|
+
phoneAuthorization: { kind: "unavailable" }
|
|
217066
217263
|
});
|
|
217067
217264
|
writeJson(
|
|
217068
217265
|
res,
|