linkque-cli-v2 1.2.6 → 1.2.9
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 +1305 -863
- package/package.json +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-EG3MWFEG.js → chunk-G46UWJIX.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-LVUJW2KB.js → chunk-LULNN6DW.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-DCQYAWC6.js → chunk-WPZG6QOH.js} +365 -85
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js +418 -116
- 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 +519 -137
package/worker.js
CHANGED
|
@@ -39,6 +39,7 @@ var init_types = __esm({
|
|
|
39
39
|
"../linkque-agent-runtime/dist/esm/core/types.js"() {
|
|
40
40
|
"use strict";
|
|
41
41
|
(function(EDebugLogScope2) {
|
|
42
|
+
EDebugLogScope2["A2UI_ACTION"] = "A2UI_ACTION";
|
|
42
43
|
EDebugLogScope2["CONFIG"] = "CONFIG";
|
|
43
44
|
EDebugLogScope2["LLM"] = "LLM";
|
|
44
45
|
EDebugLogScope2["PI_EVENT"] = "PI_EVENT";
|
|
@@ -85,6 +86,7 @@ var init_agentProtocol = __esm({
|
|
|
85
86
|
EHookStage2["RUN_FAILED"] = "RUN_FAILED";
|
|
86
87
|
EHookStage2["RUN_READ"] = "RUN_READ";
|
|
87
88
|
EHookStage2["AFTER_MODEL_CALL"] = "AFTER_MODEL_CALL";
|
|
89
|
+
EHookStage2["MODEL_RESPONSE_RECEIVED"] = "MODEL_RESPONSE_RECEIVED";
|
|
88
90
|
EHookStage2["BEFORE_TOOL_CALL"] = "BEFORE_TOOL_CALL";
|
|
89
91
|
EHookStage2["AFTER_TOOL_CALL"] = "AFTER_TOOL_CALL";
|
|
90
92
|
EHookStage2["TOOL_CALL_FAILED"] = "TOOL_CALL_FAILED";
|
|
@@ -8687,6 +8689,9 @@ function validateAst(ast) {
|
|
|
8687
8689
|
if (!ALLOWED_AST_TYPES.has(value.type)) {
|
|
8688
8690
|
throw new StructuralExpressionError("STRUCTURAL_EXPRESSION_NODE_FORBIDDEN", `JMESPath node ${value.type} is not allowed`);
|
|
8689
8691
|
}
|
|
8692
|
+
if (value.type === "Index" && (typeof value.value !== "number" || !Number.isSafeInteger(value.value) || value.value < 0)) {
|
|
8693
|
+
throw new StructuralExpressionError("STRUCTURAL_EXPRESSION_INVALID", "array index must be a non-negative safe integer");
|
|
8694
|
+
}
|
|
8690
8695
|
if (value.type === "Function" && value.name !== "not_null") {
|
|
8691
8696
|
throw new StructuralExpressionError("STRUCTURAL_EXPRESSION_FUNCTION_FORBIDDEN", `JMESPath function ${String(value.name)} is not allowed`);
|
|
8692
8697
|
}
|
|
@@ -8712,6 +8717,8 @@ var init_structural = __esm({
|
|
|
8712
8717
|
"Field",
|
|
8713
8718
|
"Function",
|
|
8714
8719
|
"Identity",
|
|
8720
|
+
"Index",
|
|
8721
|
+
"IndexExpression",
|
|
8715
8722
|
"KeyValuePair",
|
|
8716
8723
|
"Literal",
|
|
8717
8724
|
"MultiSelectHash",
|
|
@@ -9289,6 +9296,9 @@ function validateAst2(ast) {
|
|
|
9289
9296
|
if (!ALLOWED_AST_TYPES2.has(value.type)) {
|
|
9290
9297
|
throw new A2UICardExpressionError("CARD_EXPRESSION_NODE_FORBIDDEN", `JMESPath node ${value.type} is not allowed by ${A2UI_CARD_TRANSFORM_PROFILE}`);
|
|
9291
9298
|
}
|
|
9299
|
+
if (value.type === "Index" && (typeof value.value !== "number" || !Number.isSafeInteger(value.value) || value.value < 0)) {
|
|
9300
|
+
throw new A2UICardExpressionError("CARD_EXPRESSION_INVALID", "array index must be a non-negative safe integer");
|
|
9301
|
+
}
|
|
9292
9302
|
if (value.type === "Function" && value.name !== "not_null") {
|
|
9293
9303
|
throw new A2UICardExpressionError("CARD_EXPRESSION_FUNCTION_FORBIDDEN", `JMESPath function ${String(value.name)} is not allowed`);
|
|
9294
9304
|
}
|
|
@@ -9313,6 +9323,8 @@ var init_expression = __esm({
|
|
|
9313
9323
|
"Field",
|
|
9314
9324
|
"Function",
|
|
9315
9325
|
"Identity",
|
|
9326
|
+
"Index",
|
|
9327
|
+
"IndexExpression",
|
|
9316
9328
|
"KeyValuePair",
|
|
9317
9329
|
"Literal",
|
|
9318
9330
|
"MultiSelectHash",
|
|
@@ -9744,8 +9756,6 @@ function validateComponents(payload, path6, surfaces, issues) {
|
|
|
9744
9756
|
if (value !== void 0)
|
|
9745
9757
|
validateProperty(value, property, `${componentPath}.${name}`, issues, name);
|
|
9746
9758
|
}
|
|
9747
|
-
if (component.component === "Tag" && component.icon === void 0 && component.gap !== void 0)
|
|
9748
|
-
issues.push(issue2(`${componentPath}.gap`, "TAG_GAP_REQUIRES_ICON", "Tag.gap requires Tag.icon"));
|
|
9749
9759
|
if (component["x2-overflow"] !== void 0)
|
|
9750
9760
|
validateOverflow(component, componentPath, issues);
|
|
9751
9761
|
if (component.component === "TextField")
|
|
@@ -9759,7 +9769,7 @@ function validateComponents(payload, path6, surfaces, issues) {
|
|
|
9759
9769
|
validateStepper(component, componentPath, issues);
|
|
9760
9770
|
if (component.checks !== void 0)
|
|
9761
9771
|
validateChecks(component.checks, `${componentPath}.checks`, issues);
|
|
9762
|
-
if (component.format !== void 0 &&
|
|
9772
|
+
if (component.format !== void 0 && component.component === "Text")
|
|
9763
9773
|
validateNumberFormat(component.format, `${componentPath}.format`, issues);
|
|
9764
9774
|
if (component.action !== void 0)
|
|
9765
9775
|
validateAction(component.action, `${componentPath}.action`, issues, 0);
|
|
@@ -9773,6 +9783,11 @@ function validateProperty(value, schema, path6, issues, propertyName) {
|
|
|
9773
9783
|
issues.push(issue2(path6, "INVALID_DISPLAY_VALUE", `display value must be ${stringOnly ? "a string" : "a string or finite number"}, or a compatible display binding`));
|
|
9774
9784
|
return;
|
|
9775
9785
|
}
|
|
9786
|
+
if (schema.kind === "child") {
|
|
9787
|
+
if (!isSafeIdentifier(value))
|
|
9788
|
+
issues.push(issue2(path6, "INVALID_CHILD", "child must be a safe component id"));
|
|
9789
|
+
return;
|
|
9790
|
+
}
|
|
9776
9791
|
if (schema.kind === "children") {
|
|
9777
9792
|
const valid = Array.isArray(value) ? value.every(isSafeIdentifier) : isPlainRecord(value) && Object.keys(value).length === 2 && isSafeIdentifier(value.componentId) && typeof value.path === "string" && isSafePath(value.path);
|
|
9778
9793
|
if (!valid)
|
|
@@ -10013,20 +10028,27 @@ function validateReferences(surfaces, path6, issues) {
|
|
|
10013
10028
|
issues.push(issue2(`${path6}.surfaces.${surfaceId}`, "MISSING_ROOT_COMPONENT", "surface must define root"));
|
|
10014
10029
|
const edges = /* @__PURE__ */ new Map();
|
|
10015
10030
|
for (const [id, component] of components) {
|
|
10016
|
-
const
|
|
10017
|
-
const refs = Array.isArray(children) ? children.filter((entry) => typeof entry === "string") : isPlainRecord(children) && typeof children.componentId === "string" ? [children.componentId] : [];
|
|
10031
|
+
const refs = getComponentReferences(component);
|
|
10018
10032
|
edges.set(id, refs);
|
|
10019
10033
|
refs.forEach((ref) => {
|
|
10020
10034
|
if (!components.has(ref))
|
|
10021
|
-
issues.push(issue2(`${path6}.surfaces.${surfaceId}.components.${id}.children`, "MISSING_COMPONENT_REFERENCE", `component ${ref} does not exist`));
|
|
10035
|
+
issues.push(issue2(`${path6}.surfaces.${surfaceId}.components.${id}.${component.child !== void 0 ? "child" : "children"}`, "MISSING_COMPONENT_REFERENCE", `component ${ref} does not exist`));
|
|
10022
10036
|
});
|
|
10023
10037
|
if ((component.component === "Button" || component.component === "Card" && component.action !== void 0) && refs.some((ref) => hasInteractiveDescendant(ref, components, /* @__PURE__ */ new Set())))
|
|
10024
|
-
issues.push(issue2(`${path6}.surfaces.${surfaceId}.components.${id}.children`, "NESTED_INTERACTION", "action components cannot contain interactive descendants"));
|
|
10038
|
+
issues.push(issue2(`${path6}.surfaces.${surfaceId}.components.${id}.${component.child !== void 0 ? "child" : "children"}`, "NESTED_INTERACTION", "action components cannot contain interactive descendants"));
|
|
10025
10039
|
collectSurfaceOpenReferences(component.action).forEach((targetSurfaceId) => {
|
|
10026
10040
|
if (!surfaces.has(targetSurfaceId))
|
|
10027
10041
|
issues.push(issue2(`${path6}.surfaces.${surfaceId}.components.${id}.action`, "MISSING_SURFACE_REFERENCE", `surface ${targetSurfaceId} does not exist`));
|
|
10028
10042
|
});
|
|
10029
10043
|
}
|
|
10044
|
+
components.forEach((component, id) => {
|
|
10045
|
+
if (component.grow === void 0)
|
|
10046
|
+
return;
|
|
10047
|
+
const parents = [...components.values()].filter((parent) => getComponentReferences(parent).includes(id));
|
|
10048
|
+
if (id === "root" || parents.length === 0 || parents.some((parent) => parent.component !== "Row" && parent.component !== "Column")) {
|
|
10049
|
+
issues.push(issue2(`${path6}.surfaces.${surfaceId}.components.${id}.grow`, "INVALID_LAYOUT_PARENT", "grow requires a direct Row or Column parent in every occurrence"));
|
|
10050
|
+
}
|
|
10051
|
+
});
|
|
10030
10052
|
const visiting = /* @__PURE__ */ new Set();
|
|
10031
10053
|
const visited2 = /* @__PURE__ */ new Set();
|
|
10032
10054
|
const walk = (id) => {
|
|
@@ -10057,6 +10079,14 @@ function collectSurfaceOpenReferences(value, result = /* @__PURE__ */ new Set())
|
|
|
10057
10079
|
}
|
|
10058
10080
|
return result;
|
|
10059
10081
|
}
|
|
10082
|
+
function getComponentReferences(component) {
|
|
10083
|
+
if (typeof component.child === "string")
|
|
10084
|
+
return [component.child];
|
|
10085
|
+
const children = component.children;
|
|
10086
|
+
if (Array.isArray(children))
|
|
10087
|
+
return children.filter((entry) => typeof entry === "string");
|
|
10088
|
+
return isPlainRecord(children) && typeof children.componentId === "string" ? [children.componentId] : [];
|
|
10089
|
+
}
|
|
10060
10090
|
function hasInteractiveDescendant(id, components, visited2) {
|
|
10061
10091
|
if (visited2.has(id))
|
|
10062
10092
|
return false;
|
|
@@ -10066,22 +10096,20 @@ function hasInteractiveDescendant(id, components, visited2) {
|
|
|
10066
10096
|
return false;
|
|
10067
10097
|
if (component.component === "Button" || component.action !== void 0 || ["TextField", "ChoicePicker", "Stepper"].includes(String(component.component)))
|
|
10068
10098
|
return true;
|
|
10069
|
-
const
|
|
10070
|
-
const refs = Array.isArray(children) ? children : isPlainRecord(children) ? [children.componentId] : [];
|
|
10099
|
+
const refs = getComponentReferences(component);
|
|
10071
10100
|
return refs.some((ref) => typeof ref === "string" && hasInteractiveDescendant(ref, components, visited2));
|
|
10072
10101
|
}
|
|
10073
|
-
var spacing, colors, iconNames,
|
|
10102
|
+
var spacing, colors, iconNames, layoutItem, width, radius, decoration, typography, container, _listJustify, listContainer, A2UI_V4_COMPONENT_CATALOG;
|
|
10074
10103
|
var init_v4Catalog = __esm({
|
|
10075
10104
|
"../agent-a2ui-card-contract/dist/esm/v4Catalog.js"() {
|
|
10076
10105
|
"use strict";
|
|
10077
|
-
init_protocol();
|
|
10078
10106
|
init_json2();
|
|
10107
|
+
init_protocol();
|
|
10079
10108
|
spacing = ["none", "xs", "sm", "md", "lg"];
|
|
10080
10109
|
colors = [
|
|
10081
10110
|
"default",
|
|
10082
10111
|
"muted",
|
|
10083
10112
|
"primary",
|
|
10084
|
-
"accent",
|
|
10085
10113
|
"success",
|
|
10086
10114
|
"warning",
|
|
10087
10115
|
"error",
|
|
@@ -10133,8 +10161,18 @@ var init_v4Catalog = __esm({
|
|
|
10133
10161
|
"warning",
|
|
10134
10162
|
"arrow-right-long"
|
|
10135
10163
|
];
|
|
10136
|
-
|
|
10137
|
-
|
|
10164
|
+
layoutItem = {
|
|
10165
|
+
grow: {
|
|
10166
|
+
kind: "number",
|
|
10167
|
+
values: [0, 1, 2, 3, 4],
|
|
10168
|
+
parentComponents: ["Row", "Column"]
|
|
10169
|
+
}
|
|
10170
|
+
};
|
|
10171
|
+
width = { width: { kind: "string", values: ["fit", "fill"] } };
|
|
10172
|
+
radius = {
|
|
10173
|
+
radius: { kind: "string", values: ["none", "xs", "sm", "md", "full"] }
|
|
10174
|
+
};
|
|
10175
|
+
decoration = {
|
|
10138
10176
|
padding: { kind: "string", values: spacing },
|
|
10139
10177
|
background: {
|
|
10140
10178
|
kind: "string",
|
|
@@ -10152,29 +10190,17 @@ var init_v4Catalog = __esm({
|
|
|
10152
10190
|
kind: "string",
|
|
10153
10191
|
values: ["none", "subtle", "card-border", "primary"]
|
|
10154
10192
|
},
|
|
10155
|
-
radius
|
|
10156
|
-
width: { kind: "string", values: ["fit", "fill"] },
|
|
10157
|
-
grow: { kind: "number", values: [0, 1, 2, 3, 4] },
|
|
10158
|
-
shrink: { kind: "boolean" }
|
|
10193
|
+
...radius
|
|
10159
10194
|
};
|
|
10160
10195
|
typography = {
|
|
10161
10196
|
color: { kind: "string", values: colors },
|
|
10162
|
-
fontSize: {
|
|
10163
|
-
kind: "string",
|
|
10164
|
-
values: [
|
|
10165
|
-
"small",
|
|
10166
|
-
"medium",
|
|
10167
|
-
"large",
|
|
10168
|
-
"striking",
|
|
10169
|
-
"display",
|
|
10170
|
-
"badge",
|
|
10171
|
-
"merchant"
|
|
10172
|
-
]
|
|
10173
|
-
},
|
|
10197
|
+
fontSize: { kind: "string", values: ["xs", "sm", "md", "lg", "xl", "xxl"] },
|
|
10174
10198
|
fontWeight: { kind: "string", values: ["normal", "semibold", "bold"] }
|
|
10175
10199
|
};
|
|
10176
10200
|
container = {
|
|
10177
|
-
...
|
|
10201
|
+
...layoutItem,
|
|
10202
|
+
...width,
|
|
10203
|
+
padding: { kind: "string", values: spacing },
|
|
10178
10204
|
children: { kind: "children", required: true },
|
|
10179
10205
|
gap: { kind: "string", values: spacing },
|
|
10180
10206
|
align: {
|
|
@@ -10194,6 +10220,7 @@ var init_v4Catalog = __esm({
|
|
|
10194
10220
|
},
|
|
10195
10221
|
"x2-overflow": { kind: "format" }
|
|
10196
10222
|
};
|
|
10223
|
+
({ justify: _listJustify, ...listContainer } = container);
|
|
10197
10224
|
A2UI_V4_COMPONENT_CATALOG = Object.freeze({
|
|
10198
10225
|
catalogId: LINKQUE_A2UI_V4_CATALOG_ID,
|
|
10199
10226
|
protocolVersion: "0.9",
|
|
@@ -10201,7 +10228,10 @@ var init_v4Catalog = __esm({
|
|
|
10201
10228
|
Card: {
|
|
10202
10229
|
interaction: "action",
|
|
10203
10230
|
properties: {
|
|
10204
|
-
...
|
|
10231
|
+
...layoutItem,
|
|
10232
|
+
...width,
|
|
10233
|
+
...decoration,
|
|
10234
|
+
child: { kind: "child", required: true },
|
|
10205
10235
|
action: { kind: "action" },
|
|
10206
10236
|
disabled: { kind: "boolean" }
|
|
10207
10237
|
}
|
|
@@ -10211,13 +10241,14 @@ var init_v4Catalog = __esm({
|
|
|
10211
10241
|
interaction: "none",
|
|
10212
10242
|
properties: {
|
|
10213
10243
|
...container,
|
|
10214
|
-
wrap: { kind: "string", values: ["wrap", "nowrap"] }
|
|
10244
|
+
wrap: { kind: "string", values: ["wrap", "nowrap"] },
|
|
10245
|
+
layout: { kind: "string", values: ["flex", "inline"] }
|
|
10215
10246
|
}
|
|
10216
10247
|
},
|
|
10217
10248
|
List: {
|
|
10218
10249
|
interaction: "none",
|
|
10219
10250
|
properties: {
|
|
10220
|
-
...
|
|
10251
|
+
...listContainer,
|
|
10221
10252
|
variant: {
|
|
10222
10253
|
kind: "string",
|
|
10223
10254
|
required: true,
|
|
@@ -10228,8 +10259,9 @@ var init_v4Catalog = __esm({
|
|
|
10228
10259
|
Text: {
|
|
10229
10260
|
interaction: "none",
|
|
10230
10261
|
properties: {
|
|
10231
|
-
...
|
|
10262
|
+
...layoutItem,
|
|
10232
10263
|
...typography,
|
|
10264
|
+
shrink: { kind: "boolean" },
|
|
10233
10265
|
text: { kind: "binding", required: true },
|
|
10234
10266
|
maxLines: { kind: "number", values: [0, 1, 2, 3, 4, 5, 6] },
|
|
10235
10267
|
decoration: { kind: "string", values: ["line-through"] },
|
|
@@ -10239,19 +10271,31 @@ var init_v4Catalog = __esm({
|
|
|
10239
10271
|
Tag: {
|
|
10240
10272
|
interaction: "none",
|
|
10241
10273
|
properties: {
|
|
10242
|
-
...
|
|
10243
|
-
...typography,
|
|
10274
|
+
...layoutItem,
|
|
10244
10275
|
text: { kind: "binding", required: true },
|
|
10245
10276
|
icon: { kind: "string", values: iconNames },
|
|
10246
|
-
|
|
10247
|
-
|
|
10248
|
-
|
|
10277
|
+
tone: {
|
|
10278
|
+
kind: "string",
|
|
10279
|
+
values: [
|
|
10280
|
+
"default",
|
|
10281
|
+
"muted",
|
|
10282
|
+
"primary",
|
|
10283
|
+
"success",
|
|
10284
|
+
"warning",
|
|
10285
|
+
"error"
|
|
10286
|
+
]
|
|
10287
|
+
},
|
|
10288
|
+
variant: { kind: "string", values: ["soft", "outline", "plain"] },
|
|
10289
|
+
size: { kind: "string", values: ["sm", "md"] },
|
|
10290
|
+
shrink: { kind: "boolean" },
|
|
10291
|
+
maxLines: { kind: "number", values: [0, 1, 2, 3, 4, 5, 6] }
|
|
10249
10292
|
}
|
|
10250
10293
|
},
|
|
10251
10294
|
Button: {
|
|
10252
10295
|
interaction: "action",
|
|
10253
10296
|
properties: {
|
|
10254
|
-
...
|
|
10297
|
+
...layoutItem,
|
|
10298
|
+
...width,
|
|
10255
10299
|
label: { kind: "binding", required: true },
|
|
10256
10300
|
action: { kind: "action", required: true },
|
|
10257
10301
|
checks: { kind: "format" },
|
|
@@ -10269,34 +10313,29 @@ var init_v4Catalog = __esm({
|
|
|
10269
10313
|
Image: {
|
|
10270
10314
|
interaction: "none",
|
|
10271
10315
|
properties: {
|
|
10272
|
-
...
|
|
10316
|
+
...layoutItem,
|
|
10317
|
+
...radius,
|
|
10273
10318
|
src: { kind: "binding", required: true },
|
|
10274
10319
|
alt: { kind: "binding" },
|
|
10275
10320
|
fit: {
|
|
10276
10321
|
kind: "string",
|
|
10277
10322
|
values: ["contain", "cover", "fill", "none", "scale-down"]
|
|
10278
10323
|
},
|
|
10279
|
-
|
|
10324
|
+
aspectRatio: {
|
|
10280
10325
|
kind: "string",
|
|
10281
|
-
values: [
|
|
10282
|
-
|
|
10283
|
-
|
|
10284
|
-
|
|
10285
|
-
|
|
10286
|
-
|
|
10287
|
-
"portraitFeature",
|
|
10288
|
-
"productThumbnail",
|
|
10289
|
-
"voucherThumbnail",
|
|
10290
|
-
"largeFeature",
|
|
10291
|
-
"header"
|
|
10292
|
-
]
|
|
10326
|
+
values: ["square", "portrait", "landscape", "wide", "banner"]
|
|
10327
|
+
},
|
|
10328
|
+
height: { kind: "string", values: ["auto", "fill"] },
|
|
10329
|
+
size: {
|
|
10330
|
+
kind: "string",
|
|
10331
|
+
values: ["xs", "sm", "md", "lg", "xl", "full"]
|
|
10293
10332
|
}
|
|
10294
10333
|
}
|
|
10295
10334
|
},
|
|
10296
10335
|
Icon: {
|
|
10297
10336
|
interaction: "none",
|
|
10298
10337
|
properties: {
|
|
10299
|
-
...
|
|
10338
|
+
...layoutItem,
|
|
10300
10339
|
name: { kind: "string", required: true, values: iconNames },
|
|
10301
10340
|
label: { kind: "string" },
|
|
10302
10341
|
color: { kind: "string", values: colors },
|
|
@@ -10309,15 +10348,15 @@ var init_v4Catalog = __esm({
|
|
|
10309
10348
|
Divider: {
|
|
10310
10349
|
interaction: "none",
|
|
10311
10350
|
properties: {
|
|
10312
|
-
...
|
|
10351
|
+
...layoutItem,
|
|
10313
10352
|
axis: { kind: "string", values: ["horizontal", "vertical"] }
|
|
10314
10353
|
}
|
|
10315
10354
|
},
|
|
10316
10355
|
TextField: {
|
|
10317
10356
|
interaction: "input",
|
|
10318
10357
|
properties: {
|
|
10319
|
-
...
|
|
10320
|
-
...
|
|
10358
|
+
...layoutItem,
|
|
10359
|
+
...width,
|
|
10321
10360
|
label: { kind: "string", required: true },
|
|
10322
10361
|
value: { kind: "binding", required: true },
|
|
10323
10362
|
checks: { kind: "format" },
|
|
@@ -10341,7 +10380,8 @@ var init_v4Catalog = __esm({
|
|
|
10341
10380
|
ChoicePicker: {
|
|
10342
10381
|
interaction: "input",
|
|
10343
10382
|
properties: {
|
|
10344
|
-
...
|
|
10383
|
+
...layoutItem,
|
|
10384
|
+
...width,
|
|
10345
10385
|
label: { kind: "string", required: true },
|
|
10346
10386
|
value: { kind: "binding", required: true },
|
|
10347
10387
|
options: { kind: "options", required: true },
|
|
@@ -10356,7 +10396,8 @@ var init_v4Catalog = __esm({
|
|
|
10356
10396
|
Stepper: {
|
|
10357
10397
|
interaction: "input",
|
|
10358
10398
|
properties: {
|
|
10359
|
-
...
|
|
10399
|
+
...layoutItem,
|
|
10400
|
+
...width,
|
|
10360
10401
|
label: { kind: "string", required: true },
|
|
10361
10402
|
value: { kind: "binding", required: true },
|
|
10362
10403
|
min: { kind: "number" },
|
|
@@ -11424,6 +11465,96 @@ var init_mcpNaming = __esm({
|
|
|
11424
11465
|
}
|
|
11425
11466
|
});
|
|
11426
11467
|
|
|
11468
|
+
// ../linkque-agent-runtime/dist/esm/core/cardSemanticSnapshot.js
|
|
11469
|
+
function createCardSemanticSnapshot(receipt, fields) {
|
|
11470
|
+
const groups = receipt.coverage.map((coverage) => {
|
|
11471
|
+
const field = fields.find((f3) => f3.fieldId === coverage.fieldId);
|
|
11472
|
+
const entities = receipt.entities.filter((e2) => e2.fieldId === coverage.fieldId);
|
|
11473
|
+
const echo = field?.presentation?.visibility === "echo";
|
|
11474
|
+
const attributes = echo ? [...new Set(entities.flatMap((e2) => Object.keys(e2.attributes ?? {})))] : [];
|
|
11475
|
+
const hasValue = echo && entities.some((e2) => Object.hasOwn(e2, "value"));
|
|
11476
|
+
const hasLabel = echo && entities.some((e2) => !Object.hasOwn(e2, "value"));
|
|
11477
|
+
const columns = [
|
|
11478
|
+
"\u6761\u76EE\u5F15\u7528",
|
|
11479
|
+
...hasLabel ? [columnLabel(field, field?.presentation?.labelPath, "\u540D\u79F0")] : [],
|
|
11480
|
+
...hasValue ? [short(coverage.label)] : [],
|
|
11481
|
+
...attributes.map((path6) => columnLabel(field, path6, path6))
|
|
11482
|
+
];
|
|
11483
|
+
const rows = entities.map((e2) => [
|
|
11484
|
+
e2.ref,
|
|
11485
|
+
...hasLabel ? [e2.label] : [],
|
|
11486
|
+
...hasValue ? [e2.value ?? null] : [],
|
|
11487
|
+
...attributes.map((path6) => e2.attributes?.[path6] ?? null)
|
|
11488
|
+
]);
|
|
11489
|
+
const total = coverage.itemCount ?? (coverage.present ? 1 : 0);
|
|
11490
|
+
return {
|
|
11491
|
+
field: coverage.fieldId,
|
|
11492
|
+
label: short(coverage.label),
|
|
11493
|
+
present: coverage.present,
|
|
11494
|
+
total,
|
|
11495
|
+
included: rows.length,
|
|
11496
|
+
complete: echo && coverage.present && rows.length === total && !entities.some((e2) => e2.truncated) && !receipt.omissions.some((o) => o.fieldId === coverage.fieldId),
|
|
11497
|
+
columns,
|
|
11498
|
+
rows
|
|
11499
|
+
};
|
|
11500
|
+
});
|
|
11501
|
+
const snapshot = {
|
|
11502
|
+
version: 1,
|
|
11503
|
+
groups,
|
|
11504
|
+
omissions: receipt.omissions.map((o) => ({ ...o }))
|
|
11505
|
+
};
|
|
11506
|
+
while (bytes(snapshot) > MAX_BYTES) {
|
|
11507
|
+
let group;
|
|
11508
|
+
for (let i2 = groups.length - 1; i2 >= 0; i2--) {
|
|
11509
|
+
if (groups[i2].rows.length > 0) {
|
|
11510
|
+
group = groups[i2];
|
|
11511
|
+
break;
|
|
11512
|
+
}
|
|
11513
|
+
}
|
|
11514
|
+
snapshot.truncated = true;
|
|
11515
|
+
if (group) {
|
|
11516
|
+
group.rows.pop();
|
|
11517
|
+
group.included = group.rows.length;
|
|
11518
|
+
group.complete = false;
|
|
11519
|
+
} else if (groups.length) {
|
|
11520
|
+
groups.pop();
|
|
11521
|
+
} else if (snapshot.omissions.length) {
|
|
11522
|
+
snapshot.omissions.pop();
|
|
11523
|
+
} else
|
|
11524
|
+
break;
|
|
11525
|
+
}
|
|
11526
|
+
return snapshot;
|
|
11527
|
+
}
|
|
11528
|
+
function bytes(value) {
|
|
11529
|
+
return Buffer.byteLength(JSON.stringify(value));
|
|
11530
|
+
}
|
|
11531
|
+
function short(value) {
|
|
11532
|
+
return value.length > MAX_LABEL ? `${value.slice(0, MAX_LABEL - 1)}\u2026` : value;
|
|
11533
|
+
}
|
|
11534
|
+
function columnLabel(field, path6, fallback) {
|
|
11535
|
+
if (!field || !path6)
|
|
11536
|
+
return short(fallback);
|
|
11537
|
+
let schema = field.type === "array" ? field.valueSchema.items : field.valueSchema;
|
|
11538
|
+
for (const token of path6.slice(1).split("/").map((t2) => t2.replaceAll("~1", "/").replaceAll("~0", "~"))) {
|
|
11539
|
+
if (!schema || typeof schema !== "object" || Array.isArray(schema))
|
|
11540
|
+
return short(fallback);
|
|
11541
|
+
const properties = schema.properties;
|
|
11542
|
+
if (!properties || typeof properties !== "object" || Array.isArray(properties) || !Object.hasOwn(properties, token))
|
|
11543
|
+
return short(fallback);
|
|
11544
|
+
schema = properties[token];
|
|
11545
|
+
}
|
|
11546
|
+
const title = schema && typeof schema === "object" && !Array.isArray(schema) ? schema.title : void 0;
|
|
11547
|
+
return short(typeof title === "string" && title ? title : fallback);
|
|
11548
|
+
}
|
|
11549
|
+
var MAX_BYTES, MAX_LABEL;
|
|
11550
|
+
var init_cardSemanticSnapshot = __esm({
|
|
11551
|
+
"../linkque-agent-runtime/dist/esm/core/cardSemanticSnapshot.js"() {
|
|
11552
|
+
"use strict";
|
|
11553
|
+
MAX_BYTES = 6e3;
|
|
11554
|
+
MAX_LABEL = 160;
|
|
11555
|
+
}
|
|
11556
|
+
});
|
|
11557
|
+
|
|
11427
11558
|
// ../linkque-agent-runtime/dist/esm/core/cardTools.js
|
|
11428
11559
|
function createCardPresentationToolName(resourceId) {
|
|
11429
11560
|
return stableToolName("a2ui_card", resourceId);
|
|
@@ -11543,6 +11674,7 @@ function createPresentationResult(resource, config2, viewModel) {
|
|
|
11543
11674
|
...createA2UICardPresentationReceiptContent(config2.fields, viewModel),
|
|
11544
11675
|
responsePolicy: { verbatimEcho: "forbidden", hint: "acknowledge" }
|
|
11545
11676
|
};
|
|
11677
|
+
receipt.semanticSnapshot = createCardSemanticSnapshot(receipt, config2.fields);
|
|
11546
11678
|
return {
|
|
11547
11679
|
type: "linkque.presentation-tool-result",
|
|
11548
11680
|
modelText: formatPresentationReceiptForModel(receipt),
|
|
@@ -11562,11 +11694,23 @@ function createPresentationResult(resource, config2, viewModel) {
|
|
|
11562
11694
|
function formatPresentationReceiptForModel(receipt) {
|
|
11563
11695
|
return [
|
|
11564
11696
|
"<a2ui-presentation-receipt>",
|
|
11565
|
-
JSON.stringify(receipt),
|
|
11697
|
+
JSON.stringify(projectPresentationReceiptForModel(receipt)),
|
|
11566
11698
|
"</a2ui-presentation-receipt>",
|
|
11567
|
-
"
|
|
11699
|
+
"\u5361\u7247\u5DF2\u53D1\u51FA\uFF08\u4E0D\u4EE3\u8868\u5BA2\u6237\u7AEF\u5DF2\u6E32\u67D3\uFF09\u3002\u8BED\u4E49\u5FEB\u7167\u6765\u81EA\u6388\u6743\u7684\u6700\u7EC8\u5361\u7247\u6570\u636E\uFF1Bcolumns \u4E0E rows \u6309\u4F4D\u7F6E\u5BF9\u5E94\uFF0Cnull \u8868\u793A\u7F3A\u5931\u6216\u7A7A\u503C\uFF0Ccomplete=false \u65F6\u4E0D\u5F97\u628A\u91C7\u6837\u5F53\u4F5C\u5168\u96C6\u3002\u4E0D\u8981\u7528 Markdown \u91CD\u590D\u5217\u51FA\u6216\u6539\u5199\u5361\u7247\u4E2D\u7684\u6761\u76EE\uFF1B\u53EA\u8865\u5145\u7528\u6237\u5C1A\u672A\u5F97\u5230\u7684\u6BD4\u8F83\u3001\u89E3\u91CA\u6216\u5FC5\u8981\u8FFD\u95EE\uFF0C\u7528\u6237\u660E\u786E\u8981\u6C42\u6587\u5B57\u8868\u683C\u65F6\u53EF\u4EE5\u63D0\u4F9B\u3002\u5FEB\u7167\u672A\u5305\u542B\u7684\u4FE1\u606F\u4FDD\u6301\u672A\u77E5\uFF0C\u6E90\u5DE5\u5177\u7684\u989D\u5916\u4FE1\u606F\u4E0D\u80FD\u79F0\u4E3A\u5361\u7247\u5DF2\u5C55\u793A\u5185\u5BB9\u3002"
|
|
11568
11700
|
].join("\n");
|
|
11569
11701
|
}
|
|
11702
|
+
function projectPresentationReceiptForModel(receipt) {
|
|
11703
|
+
if (!receipt.semanticSnapshot)
|
|
11704
|
+
return receipt;
|
|
11705
|
+
return {
|
|
11706
|
+
version: receipt.version,
|
|
11707
|
+
cardRef: receipt.cardRef,
|
|
11708
|
+
cardRevision: receipt.cardRevision,
|
|
11709
|
+
cardInstanceId: receipt.cardInstanceId,
|
|
11710
|
+
status: receipt.status,
|
|
11711
|
+
semanticSnapshot: receipt.semanticSnapshot
|
|
11712
|
+
};
|
|
11713
|
+
}
|
|
11570
11714
|
function parseCardConfig(resource) {
|
|
11571
11715
|
const parsed = parseA2UICardResourceConfig(resource.config);
|
|
11572
11716
|
if (!parsed.success) {
|
|
@@ -11620,9 +11764,9 @@ function collectA2UISurfaceIdsForLegacyContract(protocol) {
|
|
|
11620
11764
|
function createPresentationDescription(config2) {
|
|
11621
11765
|
return [
|
|
11622
11766
|
config2.description,
|
|
11623
|
-
|
|
11624
|
-
...config2.whenNotToUse ? [
|
|
11625
|
-
"
|
|
11767
|
+
`\u9002\u7528\u573A\u666F\uFF1A${config2.whenToUse}`,
|
|
11768
|
+
...config2.whenNotToUse ? [`\u4E0D\u9002\u7528\u573A\u666F\uFF1A${config2.whenNotToUse}`] : [],
|
|
11769
|
+
"\u53EA\u63D0\u4F9B\u5DF2\u58F0\u660E\u7684\u6807\u8BC6\u6216\u7B5B\u9009\u53C2\u6570\u3002\u6743\u5A01\u4E1A\u52A1\u6570\u636E\u7531\u5E73\u53F0\u89E3\u6790\u83B7\u53D6\u3002"
|
|
11626
11770
|
].join("\n");
|
|
11627
11771
|
}
|
|
11628
11772
|
function cloneJsonObject2(value, label) {
|
|
@@ -11696,6 +11840,7 @@ var init_cardTools = __esm({
|
|
|
11696
11840
|
import_node_crypto2 = require("node:crypto");
|
|
11697
11841
|
init_esm3();
|
|
11698
11842
|
init_mcpNaming();
|
|
11843
|
+
init_cardSemanticSnapshot();
|
|
11699
11844
|
FALLBACK_OBJECT_SCHEMA = {
|
|
11700
11845
|
type: "object",
|
|
11701
11846
|
additionalProperties: true
|
|
@@ -11896,7 +12041,11 @@ var init_mcpProxyTool = __esm({
|
|
|
11896
12041
|
return;
|
|
11897
12042
|
try {
|
|
11898
12043
|
await entry.server.close?.();
|
|
11899
|
-
} catch {
|
|
12044
|
+
} catch (error40) {
|
|
12045
|
+
try {
|
|
12046
|
+
this.debugLog(`[mcp] server ${entry.server.serverName} close failed: ${error40 instanceof Error ? error40.message : "unknown error"}`, EDebugLogScope.MCP);
|
|
12047
|
+
} catch {
|
|
12048
|
+
}
|
|
11900
12049
|
}
|
|
11901
12050
|
}));
|
|
11902
12051
|
}
|
|
@@ -12481,13 +12630,26 @@ var init_hookRegistry = __esm({
|
|
|
12481
12630
|
}
|
|
12482
12631
|
});
|
|
12483
12632
|
|
|
12633
|
+
// ../linkque-agent-runtime/dist/esm/core/logFailure.js
|
|
12634
|
+
function warnLogFailure(stage, error40) {
|
|
12635
|
+
(0, import_node_process.emitWarning)(`[${stage}] errorType=${error40 instanceof Error ? error40.name : typeof error40}`, { code: "LINKQUE_RUNTIME_DIAGNOSTIC_FAILURE" });
|
|
12636
|
+
}
|
|
12637
|
+
var import_node_process;
|
|
12638
|
+
var init_logFailure = __esm({
|
|
12639
|
+
"../linkque-agent-runtime/dist/esm/core/logFailure.js"() {
|
|
12640
|
+
"use strict";
|
|
12641
|
+
import_node_process = require("node:process");
|
|
12642
|
+
}
|
|
12643
|
+
});
|
|
12644
|
+
|
|
12484
12645
|
// ../linkque-agent-runtime/dist/esm/core/hook/hookLog.js
|
|
12485
12646
|
function writeHookLog(debugLog, record3) {
|
|
12486
12647
|
if (!debugLog)
|
|
12487
12648
|
return;
|
|
12488
12649
|
try {
|
|
12489
12650
|
debugLog(JSON.stringify(redactHookLogRecord(record3)), EDebugLogScope.HOOK);
|
|
12490
|
-
} catch {
|
|
12651
|
+
} catch (error40) {
|
|
12652
|
+
warnLogFailure("writeHookLog", error40);
|
|
12491
12653
|
}
|
|
12492
12654
|
}
|
|
12493
12655
|
function redactHookLogRecord(record3) {
|
|
@@ -12507,6 +12669,7 @@ var HOOK_LOG_MESSAGE_MAX_LENGTH;
|
|
|
12507
12669
|
var init_hookLog = __esm({
|
|
12508
12670
|
"../linkque-agent-runtime/dist/esm/core/hook/hookLog.js"() {
|
|
12509
12671
|
"use strict";
|
|
12672
|
+
init_logFailure();
|
|
12510
12673
|
init_types();
|
|
12511
12674
|
HOOK_LOG_MESSAGE_MAX_LENGTH = 200;
|
|
12512
12675
|
}
|
|
@@ -12708,6 +12871,15 @@ var init_hookDispatcher = __esm({
|
|
|
12708
12871
|
stage: EHookStage.RUN_READ,
|
|
12709
12872
|
read: { readAt: subject.readAt ?? now() }
|
|
12710
12873
|
};
|
|
12874
|
+
case EHookStage.MODEL_RESPONSE_RECEIVED: {
|
|
12875
|
+
if (!subject.model)
|
|
12876
|
+
throw new Error("MODEL_RESPONSE_RECEIVED Hook \u7F3A\u5C11\u54CD\u5E94\u4E0A\u4E0B\u6587");
|
|
12877
|
+
return {
|
|
12878
|
+
...base,
|
|
12879
|
+
stage: EHookStage.MODEL_RESPONSE_RECEIVED,
|
|
12880
|
+
model: subject.model
|
|
12881
|
+
};
|
|
12882
|
+
}
|
|
12711
12883
|
case EHookStage.AFTER_MODEL_CALL: {
|
|
12712
12884
|
if (!subject.model || subject.model.messageContent === void 0) {
|
|
12713
12885
|
throw new Error("AFTER_MODEL_CALL Hook \u7F3A\u5C11\u5B8C\u6574 model context");
|
|
@@ -13272,7 +13444,8 @@ function redactHeaders(headers) {
|
|
|
13272
13444
|
pairs.push(`${key}=${redactHeader(key, value)}`);
|
|
13273
13445
|
}
|
|
13274
13446
|
}
|
|
13275
|
-
} catch {
|
|
13447
|
+
} catch (error40) {
|
|
13448
|
+
warnLogFailure("httpLoggingFetch.redactHeaders", error40);
|
|
13276
13449
|
}
|
|
13277
13450
|
return pairs.join(",");
|
|
13278
13451
|
}
|
|
@@ -13309,7 +13482,8 @@ function createHttpLoggingFetch(debugLog, tag, baseFetch = globalThis.fetch) {
|
|
|
13309
13482
|
const cl = resp.headers.get("content-length");
|
|
13310
13483
|
if (cl)
|
|
13311
13484
|
len = cl;
|
|
13312
|
-
} catch {
|
|
13485
|
+
} catch (error40) {
|
|
13486
|
+
warnLogFailure("httpLoggingFetch.contentLength", error40);
|
|
13313
13487
|
}
|
|
13314
13488
|
const correlation = readResponseCorrelationId(resp.headers);
|
|
13315
13489
|
const correlationField = correlation ? ` traceId=${correlation.value} traceHeader=${correlation.name}` : "";
|
|
@@ -13338,14 +13512,16 @@ function readResponseCorrelationId(headers) {
|
|
|
13338
13512
|
};
|
|
13339
13513
|
});
|
|
13340
13514
|
return matched;
|
|
13341
|
-
} catch {
|
|
13515
|
+
} catch (error40) {
|
|
13516
|
+
warnLogFailure("httpLoggingFetch.responseCorrelationId", error40);
|
|
13342
13517
|
}
|
|
13343
13518
|
return void 0;
|
|
13344
13519
|
}
|
|
13345
13520
|
function safeLog(debugLog, line) {
|
|
13346
13521
|
try {
|
|
13347
13522
|
debugLog(line, EDebugLogScope.HTTP);
|
|
13348
|
-
} catch {
|
|
13523
|
+
} catch (error40) {
|
|
13524
|
+
warnLogFailure("httpLoggingFetch.safeLog", error40);
|
|
13349
13525
|
}
|
|
13350
13526
|
}
|
|
13351
13527
|
function nowMs() {
|
|
@@ -13360,6 +13536,7 @@ var init_httpLoggingFetch = __esm({
|
|
|
13360
13536
|
"../linkque-agent-runtime/dist/esm/impl/httpLoggingFetch.js"() {
|
|
13361
13537
|
"use strict";
|
|
13362
13538
|
init_types();
|
|
13539
|
+
init_logFailure();
|
|
13363
13540
|
MAX_BODY_SUMMARY_LEN = 2e3;
|
|
13364
13541
|
REDACTED_HEADER_NAMES = /* @__PURE__ */ new Set([
|
|
13365
13542
|
"authorization",
|
|
@@ -31861,9 +32038,6 @@ function getConversationRunRequestIssues(value) {
|
|
|
31861
32038
|
issues.push("attachments must be an array");
|
|
31862
32039
|
} else {
|
|
31863
32040
|
value.attachments.forEach((attachment, index2) => validateAttachment(attachment, index2, issues));
|
|
31864
|
-
if (value.attachments.length > 0 && (!Array.isArray(value.messages) || !value.messages.some((message) => isRecord3(message) && message.role === "user"))) {
|
|
31865
|
-
issues.push("non-empty attachments require at least one user message");
|
|
31866
|
-
}
|
|
31867
32041
|
}
|
|
31868
32042
|
if (!isRecord3(value.metadata))
|
|
31869
32043
|
issues.push("metadata must be an object");
|
|
@@ -32004,9 +32178,6 @@ function validateAttachment(value, index2, issues) {
|
|
|
32004
32178
|
if (value.size !== void 0 && (!Number.isSafeInteger(value.size) || Number(value.size) < 0)) {
|
|
32005
32179
|
issues.push(`attachments[${index2}].size must be a non-negative safe integer when provided`);
|
|
32006
32180
|
}
|
|
32007
|
-
if (value.availability !== void 0 && value.availability !== "resolvable" && value.availability !== "current_turn_only") {
|
|
32008
|
-
issues.push(`attachments[${index2}].availability must be resolvable or current_turn_only when provided`);
|
|
32009
|
-
}
|
|
32010
32181
|
if (value.metadata !== void 0 && !isRecord3(value.metadata)) {
|
|
32011
32182
|
issues.push(`attachments[${index2}].metadata must be an object when provided`);
|
|
32012
32183
|
}
|
|
@@ -32940,9 +33111,9 @@ function encodeUTF8(str2) {
|
|
|
32940
33111
|
let encoder2;
|
|
32941
33112
|
return (encodeUTF8_ ?? (encoder2 = new globalThis.TextEncoder(), encodeUTF8_ = encoder2.encode.bind(encoder2)))(str2);
|
|
32942
33113
|
}
|
|
32943
|
-
function decodeUTF8(
|
|
33114
|
+
function decodeUTF8(bytes2) {
|
|
32944
33115
|
let decoder;
|
|
32945
|
-
return (decodeUTF8_ ?? (decoder = new globalThis.TextDecoder(), decodeUTF8_ = decoder.decode.bind(decoder)))(
|
|
33116
|
+
return (decodeUTF8_ ?? (decoder = new globalThis.TextDecoder(), decodeUTF8_ = decoder.decode.bind(decoder)))(bytes2);
|
|
32946
33117
|
}
|
|
32947
33118
|
var encodeUTF8_, decodeUTF8_;
|
|
32948
33119
|
var init_bytes = __esm({
|
|
@@ -33322,8 +33493,8 @@ var init_streaming = __esm({
|
|
|
33322
33493
|
const { value, done } = await iter.next();
|
|
33323
33494
|
if (done)
|
|
33324
33495
|
return ctrl.close();
|
|
33325
|
-
const
|
|
33326
|
-
ctrl.enqueue(
|
|
33496
|
+
const bytes2 = encodeUTF8(JSON.stringify(value) + "\n");
|
|
33497
|
+
ctrl.enqueue(bytes2);
|
|
33327
33498
|
} catch (err3) {
|
|
33328
33499
|
ctrl.error(err3);
|
|
33329
33500
|
}
|
|
@@ -42371,9 +42542,9 @@ function encodeUTF82(str2) {
|
|
|
42371
42542
|
let encoder2;
|
|
42372
42543
|
return (encodeUTF8_2 ?? (encoder2 = new globalThis.TextEncoder(), encodeUTF8_2 = encoder2.encode.bind(encoder2)))(str2);
|
|
42373
42544
|
}
|
|
42374
|
-
function decodeUTF82(
|
|
42545
|
+
function decodeUTF82(bytes2) {
|
|
42375
42546
|
let decoder;
|
|
42376
|
-
return (decodeUTF8_2 ?? (decoder = new globalThis.TextDecoder(), decodeUTF8_2 = decoder.decode.bind(decoder)))(
|
|
42547
|
+
return (decodeUTF8_2 ?? (decoder = new globalThis.TextDecoder(), decodeUTF8_2 = decoder.decode.bind(decoder)))(bytes2);
|
|
42377
42548
|
}
|
|
42378
42549
|
var encodeUTF8_2, decodeUTF8_2;
|
|
42379
42550
|
var init_bytes2 = __esm({
|
|
@@ -42759,8 +42930,8 @@ var init_streaming3 = __esm({
|
|
|
42759
42930
|
const { value, done } = await iter.next();
|
|
42760
42931
|
if (done)
|
|
42761
42932
|
return ctrl.close();
|
|
42762
|
-
const
|
|
42763
|
-
ctrl.enqueue(
|
|
42933
|
+
const bytes2 = encodeUTF82(JSON.stringify(value) + "\n");
|
|
42934
|
+
ctrl.enqueue(bytes2);
|
|
42764
42935
|
} catch (err3) {
|
|
42765
42936
|
ctrl.error(err3);
|
|
42766
42937
|
}
|
|
@@ -45477,11 +45648,11 @@ var init_base64 = __esm({
|
|
|
45477
45648
|
} else {
|
|
45478
45649
|
const binaryStr = atob(base64Str);
|
|
45479
45650
|
const len = binaryStr.length;
|
|
45480
|
-
const
|
|
45651
|
+
const bytes2 = new Uint8Array(len);
|
|
45481
45652
|
for (let i2 = 0; i2 < len; i2++) {
|
|
45482
|
-
|
|
45653
|
+
bytes2[i2] = binaryStr.charCodeAt(i2);
|
|
45483
45654
|
}
|
|
45484
|
-
return Array.from(new Float32Array(
|
|
45655
|
+
return Array.from(new Float32Array(bytes2.buffer));
|
|
45485
45656
|
}
|
|
45486
45657
|
};
|
|
45487
45658
|
}
|
|
@@ -56695,14 +56866,14 @@ var require_streams = __commonJS({
|
|
|
56695
56866
|
if (!globalThis.ReadableStream) {
|
|
56696
56867
|
try {
|
|
56697
56868
|
const process2 = require("node:process");
|
|
56698
|
-
const { emitWarning } = process2;
|
|
56869
|
+
const { emitWarning: emitWarning2 } = process2;
|
|
56699
56870
|
try {
|
|
56700
56871
|
process2.emitWarning = () => {
|
|
56701
56872
|
};
|
|
56702
56873
|
Object.assign(globalThis, require("node:stream/web"));
|
|
56703
|
-
process2.emitWarning =
|
|
56874
|
+
process2.emitWarning = emitWarning2;
|
|
56704
56875
|
} catch (error40) {
|
|
56705
|
-
process2.emitWarning =
|
|
56876
|
+
process2.emitWarning = emitWarning2;
|
|
56706
56877
|
throw error40;
|
|
56707
56878
|
}
|
|
56708
56879
|
} catch (error40) {
|
|
@@ -82258,9 +82429,9 @@ function encodeUTF83(str2) {
|
|
|
82258
82429
|
let encoder2;
|
|
82259
82430
|
return (encodeUTF8_3 !== null && encodeUTF8_3 !== void 0 ? encodeUTF8_3 : (encoder2 = new globalThis.TextEncoder(), encodeUTF8_3 = encoder2.encode.bind(encoder2)))(str2);
|
|
82260
82431
|
}
|
|
82261
|
-
function decodeUTF83(
|
|
82432
|
+
function decodeUTF83(bytes2) {
|
|
82262
82433
|
let decoder;
|
|
82263
|
-
return (decodeUTF8_3 !== null && decodeUTF8_3 !== void 0 ? decodeUTF8_3 : (decoder = new globalThis.TextDecoder(), decodeUTF8_3 = decoder.decode.bind(decoder)))(
|
|
82434
|
+
return (decodeUTF8_3 !== null && decodeUTF8_3 !== void 0 ? decodeUTF8_3 : (decoder = new globalThis.TextDecoder(), decodeUTF8_3 = decoder.decode.bind(decoder)))(bytes2);
|
|
82264
82435
|
}
|
|
82265
82436
|
function findNewlineIndex3(buffer, startIndex) {
|
|
82266
82437
|
const newline = 10;
|
|
@@ -89420,8 +89591,8 @@ ${underline}`);
|
|
|
89420
89591
|
const { value, done } = await iter.next();
|
|
89421
89592
|
if (done)
|
|
89422
89593
|
return ctrl.close();
|
|
89423
|
-
const
|
|
89424
|
-
ctrl.enqueue(
|
|
89594
|
+
const bytes2 = encodeUTF83(JSON.stringify(value) + "\n");
|
|
89595
|
+
ctrl.enqueue(bytes2);
|
|
89425
89596
|
} catch (err3) {
|
|
89426
89597
|
ctrl.error(err3);
|
|
89427
89598
|
}
|
|
@@ -189374,7 +189545,8 @@ async function createAgentSession(options) {
|
|
|
189374
189545
|
onDelay: (delayMs) => {
|
|
189375
189546
|
try {
|
|
189376
189547
|
options.debugLog?.(`[llm-throttle] wait ${delayMs}ms before next request`, EDebugLogScope.LLM);
|
|
189377
|
-
} catch {
|
|
189548
|
+
} catch (error40) {
|
|
189549
|
+
warnLogFailure("createAgentSession.throttleLog", error40);
|
|
189378
189550
|
}
|
|
189379
189551
|
}
|
|
189380
189552
|
});
|
|
@@ -189407,7 +189579,8 @@ async function createAgentSession(options) {
|
|
|
189407
189579
|
await prevOnPayload?.(payload, m2);
|
|
189408
189580
|
try {
|
|
189409
189581
|
logSink(formatHttpLogLine("llm", "req", `POST ${baseUrl} model=${m2.id} payload=${summarizeBody(safeStringifyPayload(payload))}`), EDebugLogScope.LLM);
|
|
189410
|
-
} catch {
|
|
189582
|
+
} catch (error40) {
|
|
189583
|
+
warnLogFailure("createAgentSession.requestLog", error40);
|
|
189411
189584
|
}
|
|
189412
189585
|
};
|
|
189413
189586
|
}
|
|
@@ -189424,6 +189597,7 @@ async function createAgentSession(options) {
|
|
|
189424
189597
|
responseHeaders: response.headers
|
|
189425
189598
|
}
|
|
189426
189599
|
};
|
|
189600
|
+
await options.hookRuntime.dispatcher.dispatch(EHookStage.MODEL_RESPONSE_RECEIVED, options.hookRuntime.commonParams, subject);
|
|
189427
189601
|
if (options.hookRuntime.dispatcher.hasMatchingResource(EHookStage.AFTER_MODEL_CALL, subject)) {
|
|
189428
189602
|
gateState = { subject };
|
|
189429
189603
|
}
|
|
@@ -189432,7 +189606,8 @@ async function createAgentSession(options) {
|
|
|
189432
189606
|
try {
|
|
189433
189607
|
const baseUrl = model.baseUrl ?? "<unknown>";
|
|
189434
189608
|
logSink(formatHttpLogLine("llm", "resp", `POST ${baseUrl} model=${m2.id} ${response.status} headers=${redactHeaders(response.headers)}`), EDebugLogScope.LLM);
|
|
189435
|
-
} catch {
|
|
189609
|
+
} catch (error40) {
|
|
189610
|
+
warnLogFailure("createAgentSession.responseLog", error40);
|
|
189436
189611
|
}
|
|
189437
189612
|
}
|
|
189438
189613
|
};
|
|
@@ -189459,7 +189634,8 @@ async function createAgentSession(options) {
|
|
|
189459
189634
|
try {
|
|
189460
189635
|
agent.abort();
|
|
189461
189636
|
agent.reset();
|
|
189462
|
-
} catch {
|
|
189637
|
+
} catch (error40) {
|
|
189638
|
+
warnLogFailure("createAgentSession.dispose", error40);
|
|
189463
189639
|
}
|
|
189464
189640
|
}
|
|
189465
189641
|
}
|
|
@@ -189512,7 +189688,8 @@ function serializeToolResult2(value) {
|
|
|
189512
189688
|
try {
|
|
189513
189689
|
const serialized = JSON.stringify(value);
|
|
189514
189690
|
return serialized === void 0 ? "\u5DE5\u5177\u6267\u884C\u5B8C\u6210\u3002" : serialized;
|
|
189515
|
-
} catch {
|
|
189691
|
+
} catch (error40) {
|
|
189692
|
+
warnLogFailure("createAgentSession.toolResultSerialization", error40);
|
|
189516
189693
|
return "\u5DE5\u5177\u6267\u884C\u5B8C\u6210\u3002";
|
|
189517
189694
|
}
|
|
189518
189695
|
}
|
|
@@ -189523,13 +189700,15 @@ function safeStringifyPayload(payload) {
|
|
|
189523
189700
|
return payload;
|
|
189524
189701
|
try {
|
|
189525
189702
|
return JSON.stringify(payload) ?? "";
|
|
189526
|
-
} catch {
|
|
189703
|
+
} catch (error40) {
|
|
189704
|
+
warnLogFailure("createAgentSession.payloadSerialization", error40);
|
|
189527
189705
|
return "<unserializable>";
|
|
189528
189706
|
}
|
|
189529
189707
|
}
|
|
189530
189708
|
var init_createAgentSession = __esm({
|
|
189531
189709
|
"../linkque-agent-runtime/dist/esm/impl/agent/pi/createAgentSession.js"() {
|
|
189532
189710
|
"use strict";
|
|
189711
|
+
init_logFailure();
|
|
189533
189712
|
init_dist4();
|
|
189534
189713
|
init_dist3();
|
|
189535
189714
|
init_esm();
|
|
@@ -190126,6 +190305,10 @@ var init_followUpQuestionGenerator = __esm({
|
|
|
190126
190305
|
FOLLOW_UP_QUESTION_TOOL_NAME = "submit_follow_up_questions";
|
|
190127
190306
|
FOLLOW_UP_QUESTION_TIMEOUT_MS = 4500;
|
|
190128
190307
|
SYSTEM_PROMPT = `\u6839\u636E\u5BF9\u8BDD\u8C03\u7528 submit_follow_up_questions\uFF0C\u63D0\u4EA4\u7528\u6237\u63A5\u4E0B\u6765\u53EF\u80FD\u63D0\u51FA\u7684\u8FFD\u95EE\uFF1A
|
|
190308
|
+
- \u8FD9\u4E9B\u5EFA\u8BAE\u70B9\u51FB\u540E\u4F1A\u76F4\u63A5\u4F5C\u4E3A\u4E0B\u4E00\u6761\u7528\u6237\u6D88\u606F\u53D1\u9001\u3002\u7AD9\u5728\u5F53\u524D\u6D88\u8D39\u8005/\u670D\u52A1\u4F7F\u7528\u8005\u7684\u89C6\u89D2\u5411\u52A9\u624B\u63D0\u95EE\uFF0C\u4E0D\u8981\u66FF\u5546\u6237\u3001\u5BA2\u670D\u6216\u52A9\u624B\u5411\u7528\u6237\u53D1\u95EE\u3002
|
|
190309
|
+
- \u4FDD\u6301\u5F53\u524D\u7528\u6237\u7684\u8EAB\u4EFD\u548C\u610F\u56FE\uFF1B\u53EA\u6709\u7528\u6237\u660E\u786E\u4EE5\u5546\u6237\u8EAB\u4EFD\u54A8\u8BE2\u7ECF\u8425\u95EE\u9898\u65F6\uFF0C\u624D\u6CBF\u7528\u8BE5\u8EAB\u4EFD\u3002\u4E0D\u8981\u56E0\u4E3A\u52A9\u624B\u7684\u63AA\u8F9E\u6539\u53D8\u7528\u6237\u89D2\u8272\u3002
|
|
190310
|
+
- \u4F8B\u5982\u8D2D\u7968\u573A\u666F\u53EF\u95EE\u201C\u53EF\u4EE5\u9884\u7EA6\u8BB2\u89E3\u670D\u52A1\u5417\uFF1F\u201D\u6216\u201C\u513F\u7AE5\u7968\u600E\u4E48\u4E70\uFF1F\u201D\uFF0C\u4E0D\u8981\u5199\u201C\u9700\u8981\u9884\u7EA6\u8BB2\u89E3\u670D\u52A1\u5417\uFF1F\u201D\u201C\u8BF7\u63D0\u4F9B\u6BCF\u4F4D\u5165\u56ED\u4EBA\u7684\u8EAB\u4EFD\u8BC1\u4FE1\u606F\u201D\u3002
|
|
190311
|
+
- \u52A9\u624B\u6B63\u5728\u8BE2\u95EE\u4EBA\u6570\u3001\u65E5\u671F\u3001\u9884\u7B97\u7B49\u4FE1\u606F\u65F6\uFF0C\u4E0D\u8981\u91CD\u590D\u5B83\u7684\u53CD\u95EE\uFF0C\u4E0D\u8981\u7F16\u9020\u7528\u6237\u5C1A\u672A\u63D0\u4F9B\u7684\u7B54\u6848\u6216\u66FF\u7528\u6237\u627F\u8BFA\u4E0B\u5355\u3001\u652F\u4ED8\uFF1B\u53EF\u5EFA\u8BAE\u76F8\u5173\u89C4\u5219\u95EE\u9898\uFF0C\u6CA1\u6709\u5408\u9002\u95EE\u9898\u5C31\u7559\u7A7A\u3002
|
|
190129
190312
|
- 0\uFF5E3 \u6761\uFF0C\u81EA\u7136\u3001\u76F8\u5173\u3001\u4E0D\u91CD\u590D\uFF1B\u6CA1\u6709\u5408\u9002\u8FFD\u95EE\u65F6\u63D0\u4EA4\u7A7A\u6570\u7EC4\u3002
|
|
190130
190313
|
- \u8DDF\u968F\u6700\u540E\u4E00\u6761\u7528\u6237\u6D88\u606F\u7684\u8BED\u8A00\uFF0C\u6BCF\u6761 JavaScript \u5B57\u7B26\u4E32\u957F\u5EA6\u4E3A 1\uFF5E20\u3002
|
|
190131
190314
|
- \u5386\u53F2\u8FFD\u95EE\u662F\u7CFB\u7EDF\u66FE\u751F\u6210\u7684\u5EFA\u8BAE\uFF0C\u4E0D\u662F\u7528\u6237\u8BF4\u8FC7\u7684\u8BDD\uFF1B\u4EC5\u7528\u4E8E\u7406\u89E3\u8BDD\u9898\u548C\u907F\u514D\u91CD\u590D\u3002
|
|
@@ -190164,8 +190347,10 @@ var init_followUpQuestionGenerator = __esm({
|
|
|
190164
190347
|
tools: [
|
|
190165
190348
|
{
|
|
190166
190349
|
name: FOLLOW_UP_QUESTION_TOOL_NAME,
|
|
190167
|
-
description: "\u63D0\u4EA4\
|
|
190168
|
-
parameters: typebox_exports.Object({
|
|
190350
|
+
description: "\u63D0\u4EA4\u5F53\u524D\u7528\u6237\u63A5\u4E0B\u6765\u5411\u52A9\u624B\u63D0\u51FA\u7684\u95EE\u9898\uFF0C\u9ED8\u8BA4\u91C7\u7528\u6D88\u8D39\u8005\u89C6\u89D2\uFF1B\u70B9\u51FB\u540E\u4F5C\u4E3A\u7528\u6237\u6D88\u606F\u53D1\u9001\uFF0C\u4E0D\u80FD\u662F\u5BA2\u670D\u5411\u6D88\u8D39\u8005\u7684\u53CD\u95EE\u6216\u8D44\u6599\u7D22\u53D6\u3002",
|
|
190351
|
+
parameters: typebox_exports.Object({
|
|
190352
|
+
questions: typebox_exports.Array(typebox_exports.String({ minLength: 1, maxLength: 20 }), { maxItems: 3 })
|
|
190353
|
+
}, { additionalProperties: false })
|
|
190169
190354
|
}
|
|
190170
190355
|
]
|
|
190171
190356
|
};
|
|
@@ -190341,18 +190526,39 @@ var init_pi = __esm({
|
|
|
190341
190526
|
});
|
|
190342
190527
|
|
|
190343
190528
|
// ../linkque-agent-runtime/dist/esm/core/cardRenderMcpServer.js
|
|
190529
|
+
function readAfterCard(args) {
|
|
190530
|
+
if (!args || typeof args !== "object")
|
|
190531
|
+
return void 0;
|
|
190532
|
+
const mode = args.responseMode;
|
|
190533
|
+
if (Object.hasOwn(args, "responseMode") && !["card_only", "supplement", "user_requested_text"].includes(mode))
|
|
190534
|
+
throw new Error("responseMode \u65E0\u6548\uFF0C\u8BF7\u9009\u62E9\u5DF2\u58F0\u660E\u7684\u6A21\u5F0F");
|
|
190535
|
+
if (!Object.hasOwn(args, "afterCard")) {
|
|
190536
|
+
if (mode !== void 0)
|
|
190537
|
+
throw new Error("\u6307\u5B9A responseMode \u65F6\u5FC5\u987B\u63D0\u4F9B afterCard");
|
|
190538
|
+
return void 0;
|
|
190539
|
+
}
|
|
190540
|
+
const value = args.afterCard;
|
|
190541
|
+
if (typeof value !== "string" || value.length > 16e3)
|
|
190542
|
+
throw new Error("afterCard \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\uFF0C\u957F\u5EA6\u4E0D\u80FD\u8D85\u8FC7 16000");
|
|
190543
|
+
if (mode === "card_only" && value.trim() !== "")
|
|
190544
|
+
throw new Error("card_only \u6A21\u5F0F\u4E0B afterCard \u5FC5\u987B\u4E3A\u7A7A\u5B57\u7B26\u4E32\uFF1B\u5361\u7247\u5DF2\u7ECF\u56DE\u7B54\u4E86\u67E5\u8BE2");
|
|
190545
|
+
return value.trim();
|
|
190546
|
+
}
|
|
190344
190547
|
function createCardSourceToolName(resourceId, sourceId) {
|
|
190345
190548
|
return stableToolName("card_source", `${resourceId}_${sourceId}`);
|
|
190346
190549
|
}
|
|
190347
190550
|
function createCardFinishToolName(resourceId) {
|
|
190348
190551
|
return stableToolName("card_finish", resourceId);
|
|
190349
190552
|
}
|
|
190350
|
-
var CardRenderMcpServer;
|
|
190553
|
+
var CARD_SEQUENCE, AFTER_CARD_DESCRIPTION, RESPONSE_MODE_DESCRIPTION, CardRenderMcpServer;
|
|
190351
190554
|
var init_cardRenderMcpServer = __esm({
|
|
190352
190555
|
"../linkque-agent-runtime/dist/esm/core/cardRenderMcpServer.js"() {
|
|
190353
190556
|
"use strict";
|
|
190354
190557
|
init_cardTools();
|
|
190355
190558
|
init_mcpNaming();
|
|
190559
|
+
CARD_SEQUENCE = "\u540C\u4E00\u65F6\u95F4\u53EA\u80FD\u5236\u4F5C\u4E00\u5F20\u5361\u7247\uFF1A\u5148\u5B8C\u6210\u5F53\u524D\u5361\u7247\u7684\u9009\u62E9 \u2192 \u6570\u636E\u6E90\u8C03\u7528 \u2192 \u5C55\u793A\uFF0C\u518D\u9009\u62E9\u4E0B\u4E00\u5F20\u5361\u7247\u3002\u4E0D\u8981\u4EA4\u53C9\u8C03\u7528\u4E0D\u540C\u672A\u5B8C\u6210\u5361\u7247\u7684\u5DE5\u5177\u3002";
|
|
190560
|
+
AFTER_CARD_DESCRIPTION = "\u968F\u5361\u7247\u4E00\u8D77\u5C55\u793A\u7684\u6587\u5B57\u3002card_only \u5FC5\u987B\u4E3A\u7A7A\u5B57\u7B26\u4E32\u3002supplement \u53EA\u5B8C\u6210\u5269\u4F59\u95EE\u9898\uFF0C\u76F4\u63A5\u7ED9\u7ED3\u8BBA\uFF0C\u4E0D\u5148\u6982\u8FF0\u5404\u4E2A\u5019\u9009\uFF1A\u4EF7\u683C\u603B\u7ED3\u5E94\u8BF4\u8303\u56F4/\u96C6\u4E2D\u533A\u95F4/\u53D6\u820D\uFF0C\u4E0D\u6309\u9152\u5E97\u5206\u522B\u5199\u8BC4\u4EF7\uFF1B\u8FFD\u95EE\u53EA\u95EE\u6240\u9700\u6761\u4EF6\uFF0C\u4E0D\u5148\u4ECB\u7ECD\u5168\u90E8\u9152\u5E97\uFF1B\u9009\u4E00\u5BB6\u53EA\u7ED9\u8BE5\u9879\u53CA\u7406\u7531\u3002\u5141\u8BB8\u5FC5\u8981\u5F15\u7528\u4E2A\u522B\u540D\u79F0\u6570\u503C\u3002\u4E0D\u8981\u4ECE\u8BC4\u5206\u63A8\u65AD\u536B\u751F\u3001\u4ECE\u8FD1\u5730\u94C1\u63A8\u65AD\u7279\u5B9A\u666F\u70B9\u4FBF\u5229\u6027\uFF0C\u672A\u77E5\u4FDD\u6301\u672A\u77E5\u3002user_requested_text \u53EF\u63D0\u4F9B\u7528\u6237\u660E\u786E\u8981\u6C42\u7684\u5B8C\u6574\u6587\u5B57/\u8868\u683C\u3002\u591A\u5361\u7247\u65F6\u586B\u5199\u7D27\u63A5\u5F53\u524D\u5361\u7247\u7684\u8BF4\u660E\uFF0C\u7136\u540E\u7EE7\u7EED\u8C03\u7528\u4E0B\u4E00\u5F20\u5361\u7247\u5DE5\u5177\u3002\u6B64\u5904\u6587\u5B57\u4F1A\u76F4\u63A5\u5C55\u793A\uFF0Cfinish \u6210\u529F\u540E\u4E0D\u8981\u53E6\u5199\u4E00\u904D\uFF1B\u5361\u7247\u5931\u8D25\u65F6\u4ECD\u53EF\u6B63\u5E38\u6587\u5B57\u56DE\u7B54\u3002";
|
|
190561
|
+
RESPONSE_MODE_DESCRIPTION = "\u6309\u7528\u6237\u4EFB\u52A1\u9009\u62E9\uFF1Acard_only=\u67E5\u8BE2/\u5C55\u793A\u7ED3\u679C/\u6CDB\u6CDB\u63A8\u8350\u5019\u9009\uFF0C\u5361\u7247\u5DF2\u7ECF\u5B8C\u6210\u4EFB\u52A1\uFF0C\u4E0D\u4E3B\u52A8\u65B0\u589E\u89E3\u91CA\u6216\u8FFD\u95EE\uFF1Bsupplement=\u7528\u6237\u8FD8\u8981\u6C42\u9009\u4E00\u5BB6\u53CA\u7406\u7531\u3001\u603B\u7ED3\u53D6\u820D\u3001\u8865\u5145\u653F\u7B56\u3001\u9884\u8BA2\u6240\u9700\u4FE1\u606F\uFF0C\u6216\u67E5\u8BE2\u4E3A\u7A7A\u9700\u8BF4\u660E\uFF1Buser_requested_text=\u7528\u6237\u660E\u786E\u8981\u6C42\u53E6\u7ED9\u6587\u5B57/\u53EF\u590D\u5236\u8868\u683C\u3002\u793A\u4F8B\uFF1A\u201C\u63A8\u8350\u676D\u5DDE\u9152\u5E97\u201D\u2192card_only\uFF1B\u201C\u63A8\u8350\u676D\u5DDE\u9152\u5E97\uFF0C\u9009\u4E00\u5BB6\u9002\u5408\u5E26\u5B69\u5B50\u7684\u201D\u2192supplement\uFF1B\u201C\u65E2\u8981\u5361\u7247\u4E5F\u8981\u5B8C\u6574\u8868\u683C\u201D\u2192user_requested_text\u3002";
|
|
190356
190562
|
CardRenderMcpServer = class {
|
|
190357
190563
|
resources;
|
|
190358
190564
|
registry;
|
|
@@ -190374,6 +190580,8 @@ var init_cardRenderMcpServer = __esm({
|
|
|
190374
190580
|
toolByName = /* @__PURE__ */ new Map();
|
|
190375
190581
|
activeCardId;
|
|
190376
190582
|
invalidCards = [];
|
|
190583
|
+
/** 只信任本实例实际执行成功的结果,普通 MCP JSON 无权控制文字输出。 */
|
|
190584
|
+
companions = /* @__PURE__ */ new WeakMap();
|
|
190377
190585
|
/** 本轮被隔离的坏卡,仅供宿主诊断,不影响其它卡片注册。 */
|
|
190378
190586
|
getInvalidCards() {
|
|
190379
190587
|
return this.invalidCards;
|
|
@@ -190414,7 +190622,7 @@ var init_cardRenderMcpServer = __esm({
|
|
|
190414
190622
|
resourceId: resource.resourceId,
|
|
190415
190623
|
label: config2.displayName,
|
|
190416
190624
|
description: `${createPresentationDescription(config2)}
|
|
190417
|
-
|
|
190625
|
+
\u5148\u9009\u62E9\u6B64\u5361\u7247\uFF0C\u518D\u4F9D\u6B21\u8C03\u7528\u5B83\u7684 card_source \u6570\u636E\u6E90\u5DE5\u5177\u548C card_finish \u5C55\u793A\u5DE5\u5177\u3002${CARD_SEQUENCE}`,
|
|
190418
190626
|
inputSchema: {
|
|
190419
190627
|
type: "object",
|
|
190420
190628
|
properties: {},
|
|
@@ -190453,18 +190661,18 @@ Select this card first, then call its card_source tools and card_finish tool.`,
|
|
|
190453
190661
|
modelName: sourceToolName,
|
|
190454
190662
|
resourceId: resource.resourceId,
|
|
190455
190663
|
label: source.purpose,
|
|
190456
|
-
description:
|
|
190664
|
+
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}`,
|
|
190457
190665
|
inputSchema: normalizeMcpInputSchema(discoveredHandle?.inputSchema),
|
|
190458
190666
|
outputSchema: discoveredHandle?.outputSchema ?? source.outputSchema,
|
|
190459
190667
|
execute: async (args, signal) => {
|
|
190460
190668
|
if (!state2.selected || this.activeCardId !== resource.resourceId)
|
|
190461
|
-
throw new Error(
|
|
190669
|
+
throw new Error(`\u8C03\u7528\u6570\u636E\u6E90\u524D\uFF0C\u8BF7\u5148\u9009\u62E9\u5361\u7247 ${name}`);
|
|
190462
190670
|
const missingDependencies = (source.dependsOn ?? []).filter((dependency) => !state2.results.has(dependency));
|
|
190463
190671
|
if (missingDependencies.length)
|
|
190464
|
-
throw new Error(
|
|
190672
|
+
throw new Error(`\u6570\u636E\u6E90 ${source.sourceId} \u9700\u8981\u5148\u5B8C\u6210\u4EE5\u4E0B\u4F9D\u8D56\uFF1A${missingDependencies.join(", ")}`);
|
|
190465
190673
|
const handle = discoveredHandle ?? await this.registry.resolve(source.mcpResourceId, source.toolName, signal);
|
|
190466
190674
|
if (!handle)
|
|
190467
|
-
throw new Error(`MCP
|
|
190675
|
+
throw new Error(`MCP \u5DE5\u5177 ${source.mcpResourceId}/${source.toolName} \u5F53\u524D\u4E0D\u53EF\u7528`);
|
|
190468
190676
|
const result = await handle.execute(args, signal);
|
|
190469
190677
|
const structured = readStructuredContent(result);
|
|
190470
190678
|
if (structured === void 0) {
|
|
@@ -190491,16 +190699,36 @@ Select this card first, then call its card_source tools and card_finish tool.`,
|
|
|
190491
190699
|
modelName: finishName,
|
|
190492
190700
|
resourceId: resource.resourceId,
|
|
190493
190701
|
label: `\u5C55\u793A${config2.displayName}`,
|
|
190494
|
-
description:
|
|
190702
|
+
description: `\u6240\u6709\u5FC5\u9700\u7684 card_source \u6570\u636E\u6E90\u5DE5\u5177\u6210\u529F\u540E\uFF0C\u5B8C\u6210\u5E76\u5C55\u793A${config2.displayName}\u3002${CARD_SEQUENCE}
|
|
190703
|
+
${AFTER_CARD_DESCRIPTION}`,
|
|
190495
190704
|
inputSchema: {
|
|
190496
190705
|
type: "object",
|
|
190497
|
-
|
|
190706
|
+
required: ["responseMode", "afterCard"],
|
|
190707
|
+
properties: {
|
|
190708
|
+
responseMode: {
|
|
190709
|
+
type: "string",
|
|
190710
|
+
enum: ["card_only", "supplement", "user_requested_text"],
|
|
190711
|
+
description: RESPONSE_MODE_DESCRIPTION
|
|
190712
|
+
},
|
|
190713
|
+
afterCard: {
|
|
190714
|
+
type: "string",
|
|
190715
|
+
maxLength: 16e3,
|
|
190716
|
+
description: AFTER_CARD_DESCRIPTION
|
|
190717
|
+
}
|
|
190718
|
+
},
|
|
190498
190719
|
additionalProperties: false
|
|
190499
190720
|
},
|
|
190500
|
-
execute: async (
|
|
190721
|
+
execute: async (args, signal) => {
|
|
190501
190722
|
if (!state2.selected || this.activeCardId !== resource.resourceId)
|
|
190502
|
-
throw new Error(
|
|
190723
|
+
throw new Error(`\u5B8C\u6210\u5C55\u793A\u524D\uFF0C\u8BF7\u5148\u9009\u62E9\u5361\u7247 ${name}`);
|
|
190724
|
+
const afterCard = readAfterCard(args);
|
|
190503
190725
|
const result = await executeCardPresentationFromSources(resource, this.runtimeContext, state2.results, signal);
|
|
190726
|
+
if (afterCard !== void 0) {
|
|
190727
|
+
this.companions.set(result, afterCard);
|
|
190728
|
+
result.modelText += `
|
|
190729
|
+
<a2ui-companion-delivery>${JSON.stringify({ afterCard })}</a2ui-companion-delivery>
|
|
190730
|
+
\u5361\u7247\u548C\u4E0A\u8FF0\u4F34\u968F\u6587\u5B57\u5DF2\u4F5C\u4E3A\u56DE\u7B54\u53D1\u51FA\u3002\u65E0\u9700\u518D\u6B21\u8F93\u51FA\u6587\u5B57\uFF1B\u82E5\u8FD8\u6709\u5176\u4ED6\u4EFB\u52A1\uFF0C\u7EE7\u7EED\u8C03\u7528\u5DE5\u5177\u3002`;
|
|
190731
|
+
}
|
|
190504
190732
|
state2.selected = false;
|
|
190505
190733
|
this.activeCardId = void 0;
|
|
190506
190734
|
return result;
|
|
@@ -190531,6 +190759,32 @@ Select this card first, then call its card_source tools and card_finish tool.`,
|
|
|
190531
190759
|
this.activeCardId = void 0;
|
|
190532
190760
|
this.states.clear();
|
|
190533
190761
|
this.toolByName.clear();
|
|
190762
|
+
this.companions = /* @__PURE__ */ new WeakMap();
|
|
190763
|
+
}
|
|
190764
|
+
/** 卡片与伴随文字的共享输出边界,不参与模型循环或工具调度。 */
|
|
190765
|
+
async *projectConversation(events) {
|
|
190766
|
+
const pending = /* @__PURE__ */ new WeakMap();
|
|
190767
|
+
let cardOwnsText = false;
|
|
190768
|
+
for await (const event of events) {
|
|
190769
|
+
if (event.type === "tool_start" || event.type === "error" || event.type === "done")
|
|
190770
|
+
cardOwnsText = false;
|
|
190771
|
+
if (event.type === "tool_end" && !event.isError) {
|
|
190772
|
+
const details = event.result && typeof event.result === "object" && "details" in event.result ? event.result.details : void 0;
|
|
190773
|
+
if (details && this.companions.has(details)) {
|
|
190774
|
+
pending.set(details.card, this.companions.get(details));
|
|
190775
|
+
}
|
|
190776
|
+
}
|
|
190777
|
+
if (event.type === "delta" && cardOwnsText)
|
|
190778
|
+
continue;
|
|
190779
|
+
yield event;
|
|
190780
|
+
if (event.type === "a2ui_card" && pending.has(event)) {
|
|
190781
|
+
const text2 = pending.get(event);
|
|
190782
|
+
pending.delete(event);
|
|
190783
|
+
cardOwnsText = true;
|
|
190784
|
+
if (text2)
|
|
190785
|
+
yield { type: "delta", content: text2 };
|
|
190786
|
+
}
|
|
190787
|
+
}
|
|
190534
190788
|
}
|
|
190535
190789
|
};
|
|
190536
190790
|
}
|
|
@@ -191176,7 +191430,7 @@ var init_agentRuntime = __esm({
|
|
|
191176
191430
|
});
|
|
191177
191431
|
};
|
|
191178
191432
|
try {
|
|
191179
|
-
for await (const ev of this.agentLoop.run(agentReq)) {
|
|
191433
|
+
for await (const ev of cardServer.projectConversation(this.agentLoop.run(agentReq))) {
|
|
191180
191434
|
if (ev.type === "delta")
|
|
191181
191435
|
assistantText += ev.content;
|
|
191182
191436
|
if (ev.type === "tool_end" && !ev.isError) {
|
|
@@ -191196,7 +191450,10 @@ var init_agentRuntime = __esm({
|
|
|
191196
191450
|
...presentationReceipts.map((receipt) => ({
|
|
191197
191451
|
role: "tool",
|
|
191198
191452
|
name: "a2ui_presentation_receipt",
|
|
191199
|
-
content: {
|
|
191453
|
+
content: {
|
|
191454
|
+
type: "a2ui.presentation-receipt",
|
|
191455
|
+
receipt: projectPresentationReceiptForModel(receipt)
|
|
191456
|
+
}
|
|
191200
191457
|
})),
|
|
191201
191458
|
{ role: "assistant", content: assistantText }
|
|
191202
191459
|
];
|
|
@@ -191401,16 +191658,16 @@ async function boundedBody(response, max2) {
|
|
|
191401
191658
|
}
|
|
191402
191659
|
}
|
|
191403
191660
|
function validate(data, mediaType) {
|
|
191404
|
-
if (data.length > Math.ceil(
|
|
191661
|
+
if (data.length > Math.ceil(MAX_BYTES2 / 3) * 4)
|
|
191405
191662
|
imageError("IMAGE_TOO_LARGE");
|
|
191406
191663
|
if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(data))
|
|
191407
191664
|
imageError("IMAGE_DATA_INVALID");
|
|
191408
|
-
const
|
|
191409
|
-
if (
|
|
191665
|
+
const bytes2 = Buffer.from(data, "base64");
|
|
191666
|
+
if (bytes2.length > MAX_BYTES2)
|
|
191410
191667
|
imageError("IMAGE_TOO_LARGE");
|
|
191411
|
-
if (
|
|
191668
|
+
if (bytes2.toString("base64") !== data || !bytes2.length)
|
|
191412
191669
|
imageError("IMAGE_DATA_INVALID");
|
|
191413
|
-
const magic = mediaType === "image/png" ?
|
|
191670
|
+
const magic = mediaType === "image/png" ? bytes2.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10])) : mediaType === "image/jpeg" ? bytes2[0] === 255 && bytes2[1] === 216 && bytes2[2] === 255 : mediaType === "image/webp" && bytes2.subarray(0, 4).toString() === "RIFF" && bytes2.subarray(8, 12).toString() === "WEBP";
|
|
191414
191671
|
if (!magic)
|
|
191415
191672
|
imageError("IMAGE_MEDIA_INVALID");
|
|
191416
191673
|
return { mediaType, data };
|
|
@@ -191418,7 +191675,7 @@ function validate(data, mediaType) {
|
|
|
191418
191675
|
async function resolveImage(image, fetchImpl, rules, signal) {
|
|
191419
191676
|
signal.throwIfAborted();
|
|
191420
191677
|
if (image.dataUrl) {
|
|
191421
|
-
if (image.dataUrl.length > Math.ceil(
|
|
191678
|
+
if (image.dataUrl.length > Math.ceil(MAX_BYTES2 / 3) * 4 + 32)
|
|
191422
191679
|
imageError("IMAGE_TOO_LARGE");
|
|
191423
191680
|
const match2 = /^data:(image\/(?:png|jpeg|webp));base64,([A-Za-z0-9+/=]+)$/.exec(image.dataUrl);
|
|
191424
191681
|
if (!match2 || match2[1] !== image.mimeType)
|
|
@@ -191447,9 +191704,9 @@ async function resolveImage(image, fetchImpl, rules, signal) {
|
|
|
191447
191704
|
await response.body?.cancel();
|
|
191448
191705
|
imageError("IMAGE_MEDIA_INVALID");
|
|
191449
191706
|
}
|
|
191450
|
-
return validate(Buffer.from(await boundedBody(response,
|
|
191707
|
+
return validate(Buffer.from(await boundedBody(response, MAX_BYTES2)).toString("base64"), mediaType);
|
|
191451
191708
|
}
|
|
191452
|
-
var DEFAULT_IMAGE_URL_RULES,
|
|
191709
|
+
var DEFAULT_IMAGE_URL_RULES, MAX_BYTES2;
|
|
191453
191710
|
var init_io = __esm({
|
|
191454
191711
|
"../linkque-agent-runtime/dist/esm/impl/plugin/imageUnderstanding/io.js"() {
|
|
191455
191712
|
"use strict";
|
|
@@ -191457,7 +191714,7 @@ var init_io = __esm({
|
|
|
191457
191714
|
{ host: "mass.alipay.com", pathPrefix: "/linkque/afts/img/" },
|
|
191458
191715
|
{ host: "masspre.alipay.com", pathPrefix: "/linkque/afts/img/" }
|
|
191459
191716
|
];
|
|
191460
|
-
|
|
191717
|
+
MAX_BYTES2 = 2 * 1024 * 1024;
|
|
191461
191718
|
}
|
|
191462
191719
|
});
|
|
191463
191720
|
|
|
@@ -192038,6 +192295,61 @@ function failure(code, message, retryable) {
|
|
|
192038
192295
|
return { ok: false, error: { code, message, retryable } };
|
|
192039
192296
|
}
|
|
192040
192297
|
|
|
192298
|
+
// ../linkque-agent-runtime/dist/esm/core/cardActionDiagnostics.js
|
|
192299
|
+
init_types();
|
|
192300
|
+
var CardActionDiagnostics = class {
|
|
192301
|
+
sink;
|
|
192302
|
+
layer;
|
|
192303
|
+
stage = "validate";
|
|
192304
|
+
context;
|
|
192305
|
+
debugLog;
|
|
192306
|
+
startedAt = performance.now();
|
|
192307
|
+
constructor(sink, context2, layer = "runtime") {
|
|
192308
|
+
this.sink = sink;
|
|
192309
|
+
this.layer = layer;
|
|
192310
|
+
this.context = { ...context2 };
|
|
192311
|
+
if (sink) {
|
|
192312
|
+
this.debugLog = (line, scope) => {
|
|
192313
|
+
this.write("diagnostic", { message: line }, scope);
|
|
192314
|
+
};
|
|
192315
|
+
}
|
|
192316
|
+
}
|
|
192317
|
+
write(event, fields = {}, scope = EDebugLogScope.A2UI_ACTION) {
|
|
192318
|
+
if (!this.sink)
|
|
192319
|
+
return;
|
|
192320
|
+
try {
|
|
192321
|
+
const record3 = { ...this.context, ...fields };
|
|
192322
|
+
if (record3.message)
|
|
192323
|
+
record3.message = sanitizeDiagnosticText(record3.message);
|
|
192324
|
+
if (record3.errorName)
|
|
192325
|
+
record3.errorName = sanitizeDiagnosticText(record3.errorName);
|
|
192326
|
+
this.sink(JSON.stringify({
|
|
192327
|
+
operation: "a2uiAction.execute",
|
|
192328
|
+
layer: this.layer,
|
|
192329
|
+
event,
|
|
192330
|
+
stage: this.stage,
|
|
192331
|
+
...record3,
|
|
192332
|
+
costMs: Math.max(0, Math.round(performance.now() - this.startedAt))
|
|
192333
|
+
}), scope);
|
|
192334
|
+
} catch {
|
|
192335
|
+
}
|
|
192336
|
+
}
|
|
192337
|
+
error(event, error40) {
|
|
192338
|
+
if (!this.sink)
|
|
192339
|
+
return;
|
|
192340
|
+
try {
|
|
192341
|
+
this.write(event, {
|
|
192342
|
+
errorName: error40 instanceof Error ? error40.name : typeof error40,
|
|
192343
|
+
message: error40 instanceof Error ? error40.message : typeof error40 === "string" ? error40 : "\u975E\u6807\u51C6\u5F02\u5E38"
|
|
192344
|
+
});
|
|
192345
|
+
} catch {
|
|
192346
|
+
}
|
|
192347
|
+
}
|
|
192348
|
+
};
|
|
192349
|
+
function sanitizeDiagnosticText(value) {
|
|
192350
|
+
return value.replace(/\b(?:body|arguments|payload|headers)\s*[:=][\s\S]*/giu, "<payload>").replace(/\{[\s\S]*/gu, "<payload>").replace(/https?:\/\/[^\s]+/giu, "<url>").replace(/\b(?:authorization|cookie|set-cookie)\s*[:=][^\r\n]*/giu, "<redacted>").replace(/\bbearer\s+[^\s,;]+/giu, "Bearer <redacted>").replace(/\b((?:api[_-]?key|access[_-]?key|token|secret|password|ak|sk|tradeNO|userId|orderId)\s*[:=]\s*)(?:"[^"]*"|'[^']*'|[^\s,;]+)/giu, "$1<redacted>").replace(/\s+/gu, " ").slice(0, 300);
|
|
192351
|
+
}
|
|
192352
|
+
|
|
192041
192353
|
// ../linkque-agent-runtime/dist/esm/core/cardActionExecutor.js
|
|
192042
192354
|
init_esm3();
|
|
192043
192355
|
init_esm2();
|
|
@@ -192045,12 +192357,33 @@ init_esm();
|
|
|
192045
192357
|
init_mcpAggregator();
|
|
192046
192358
|
init_mcpProxyTool();
|
|
192047
192359
|
async function executeCardAction(input) {
|
|
192360
|
+
const diagnostics = new CardActionDiagnostics(input.debugLog, {
|
|
192361
|
+
agentId: input.protocol.agentId,
|
|
192362
|
+
threadId: input.runtimeContext.threadId
|
|
192363
|
+
});
|
|
192364
|
+
diagnostics.write("started");
|
|
192365
|
+
try {
|
|
192366
|
+
const response = await executeCardActionInternal(input, diagnostics);
|
|
192367
|
+
diagnostics.write(response.ok ? "completed" : "failed", response.ok ? {} : { code: response.error.code, retryable: response.error.retryable });
|
|
192368
|
+
return response;
|
|
192369
|
+
} catch (error40) {
|
|
192370
|
+
diagnostics.error("failed", error40);
|
|
192371
|
+
throw error40;
|
|
192372
|
+
}
|
|
192373
|
+
}
|
|
192374
|
+
async function executeCardActionInternal(input, diagnostics) {
|
|
192048
192375
|
let request;
|
|
192049
192376
|
try {
|
|
192050
192377
|
request = parseA2UIActionExecuteRequest(input.request);
|
|
192051
192378
|
} catch (error40) {
|
|
192052
192379
|
return failure2("INVALID_INPUT", errorMessage(error40, "\u652F\u4ED8\u52A8\u4F5C\u8BF7\u6C42\u65E0\u6548"), false);
|
|
192053
192380
|
}
|
|
192381
|
+
Object.assign(diagnostics.context, {
|
|
192382
|
+
invocationId: request.invocationId,
|
|
192383
|
+
actionId: request.actionId,
|
|
192384
|
+
cardRef: request.source.cardRef,
|
|
192385
|
+
cardRevision: request.source.cardRevision
|
|
192386
|
+
});
|
|
192054
192387
|
if (request.agentId !== input.protocol.agentId) {
|
|
192055
192388
|
return failure2("AGENT_MISMATCH", "\u652F\u4ED8\u52A8\u4F5C\u4E0E\u5F53\u524D Agent \u4E0D\u5339\u914D", false);
|
|
192056
192389
|
}
|
|
@@ -192060,24 +192393,38 @@ async function executeCardAction(input) {
|
|
|
192060
192393
|
if (!input.runtimeContext.userId.trim()) {
|
|
192061
192394
|
return failure2("AUTH_REQUIRED", "\u652F\u4ED8\u52A8\u4F5C\u7F3A\u5C11\u53EF\u4FE1\u7528\u6237\u8EAB\u4EFD", false);
|
|
192062
192395
|
}
|
|
192396
|
+
diagnostics.write("validated");
|
|
192397
|
+
diagnostics.stage = "binding";
|
|
192063
192398
|
const resolved = resolvePaymentBinding(input.protocol, request.source, request.actionId);
|
|
192064
192399
|
if (!resolved.ok)
|
|
192065
192400
|
return resolved.response;
|
|
192066
|
-
|
|
192401
|
+
Object.assign(diagnostics.context, {
|
|
192402
|
+
mcpResourceId: resolved.binding.createTrade.mcpResourceId,
|
|
192403
|
+
toolName: resolved.binding.createTrade.toolName
|
|
192404
|
+
});
|
|
192405
|
+
diagnostics.write("binding_resolved");
|
|
192406
|
+
diagnostics.stage = "tool_resolve";
|
|
192407
|
+
const registry2 = createRegistry(input.protocol, input.mcpServerProvider, diagnostics.debugLog);
|
|
192067
192408
|
try {
|
|
192068
192409
|
const tool = await registry2.resolve(resolved.binding.createTrade.mcpResourceId, resolved.binding.createTrade.toolName, input.signal);
|
|
192069
192410
|
if (!tool) {
|
|
192070
192411
|
return failure2("TOOL_NOT_ALLOWED", "\u521B\u5EFA\u4EA4\u6613 MCP Tool \u4E0D\u5B58\u5728\u6216\u672A\u6388\u6743", false);
|
|
192071
192412
|
}
|
|
192413
|
+
diagnostics.stage = "tool_input";
|
|
192072
192414
|
const args = createToolInput(resolved.binding.createTrade.inputBindings, request.actionContext, input.runtimeContext);
|
|
192073
192415
|
if (!args)
|
|
192074
192416
|
return failure2("INVALID_INPUT", "\u65E0\u6CD5\u751F\u6210\u521B\u5EFA\u4EA4\u6613 MCP \u5165\u53C2", false);
|
|
192075
192417
|
let result;
|
|
192418
|
+
diagnostics.stage = "tool_execute";
|
|
192419
|
+
diagnostics.write("tool_started");
|
|
192076
192420
|
try {
|
|
192077
192421
|
result = await tool.execute(args, input.signal);
|
|
192078
|
-
|
|
192422
|
+
diagnostics.write("tool_completed");
|
|
192423
|
+
} catch (error40) {
|
|
192424
|
+
diagnostics.error("tool_failed", error40);
|
|
192079
192425
|
return failure2("EXECUTION_FAILED", "\u521B\u5EFA\u4EA4\u6613\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5", true);
|
|
192080
192426
|
}
|
|
192427
|
+
diagnostics.stage = "tool_output";
|
|
192081
192428
|
const structured = readStructuredContent3(result);
|
|
192082
192429
|
const tradeNO = readJsonPointer(structured, resolved.binding.createTrade.tradeNoPath);
|
|
192083
192430
|
if (typeof tradeNO !== "string" || !tradeNO.trim() || tradeNO.length > 64) {
|
|
@@ -192089,7 +192436,10 @@ async function executeCardAction(input) {
|
|
|
192089
192436
|
result: { kind: "payment", tradeNO }
|
|
192090
192437
|
};
|
|
192091
192438
|
} finally {
|
|
192439
|
+
const stage = diagnostics.stage;
|
|
192440
|
+
diagnostics.stage = "cleanup";
|
|
192092
192441
|
await registry2.closeAll();
|
|
192442
|
+
diagnostics.stage = stage;
|
|
192093
192443
|
}
|
|
192094
192444
|
}
|
|
192095
192445
|
function resolvePaymentBinding(protocol, source, actionId) {
|
|
@@ -192119,9 +192469,9 @@ function resolvePaymentBinding(protocol, source, actionId) {
|
|
|
192119
192469
|
}
|
|
192120
192470
|
return { ok: true, binding };
|
|
192121
192471
|
}
|
|
192122
|
-
function createRegistry(protocol, provider) {
|
|
192472
|
+
function createRegistry(protocol, provider, debugLog) {
|
|
192123
192473
|
const resources = protocol.agent.resources.filter((resource) => resource.resourceType === EResourceType.MCP || resource.resourceType === EResourceType.MCP_TOOL);
|
|
192124
|
-
return new McpProxyTool(provider, aggregateMcpServers(resources, protocol.agentId));
|
|
192474
|
+
return new McpProxyTool(provider, aggregateMcpServers(resources, protocol.agentId), { debugLog });
|
|
192125
192475
|
}
|
|
192126
192476
|
function createToolInput(bindings, actionContext, runtimeContext, tradeNO, callback) {
|
|
192127
192477
|
const result = {};
|
|
@@ -197362,6 +197712,8 @@ function applyArgsMappingRules(toolName, args, rules) {
|
|
|
197362
197712
|
init_esm();
|
|
197363
197713
|
|
|
197364
197714
|
// ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/remoteGatewayMcpServer.js
|
|
197715
|
+
init_types();
|
|
197716
|
+
init_logFailure();
|
|
197365
197717
|
var defaultCreateSigner = (config2, getAuthorizationHeader, debugLog) => new RemoteSignatureSigner({
|
|
197366
197718
|
agentId: config2.agentId,
|
|
197367
197719
|
signEndpoint: config2.signEndpoint,
|
|
@@ -197397,13 +197749,42 @@ var RemoteGatewayMcpServerProvider = class {
|
|
|
197397
197749
|
});
|
|
197398
197750
|
const serverName = resource.config.serverName ?? resource.resourceId;
|
|
197399
197751
|
const argsMappingRules = resource.config.argsMappingRules ?? [];
|
|
197752
|
+
let requestSequence = 0;
|
|
197753
|
+
const request = async (method, params, invoke) => {
|
|
197754
|
+
const requestId = ++requestSequence;
|
|
197755
|
+
const log = (phase, payload) => {
|
|
197756
|
+
if (!this.debugLog)
|
|
197757
|
+
return;
|
|
197758
|
+
try {
|
|
197759
|
+
this.debugLog(`[mcp-client] ${JSON.stringify({ serverName, resourceId: resource.resourceId, requestId, method, phase, payload })}`, EDebugLogScope.MCP);
|
|
197760
|
+
} catch (error40) {
|
|
197761
|
+
warnLogFailure("remoteGatewayMcpServer.log", error40);
|
|
197762
|
+
}
|
|
197763
|
+
};
|
|
197764
|
+
log("request", params);
|
|
197765
|
+
try {
|
|
197766
|
+
const result = await invoke();
|
|
197767
|
+
log("response", result);
|
|
197768
|
+
return result;
|
|
197769
|
+
} catch (error40) {
|
|
197770
|
+
log("error", error40 instanceof Error ? { name: error40.name, message: error40.message } : error40);
|
|
197771
|
+
throw error40;
|
|
197772
|
+
}
|
|
197773
|
+
};
|
|
197774
|
+
const loggedClient = {
|
|
197775
|
+
listTools: () => request("tools/list", {}, () => client.listTools()),
|
|
197776
|
+
callTool: (params) => request("tools/call", params, () => client.callTool(params))
|
|
197777
|
+
};
|
|
197400
197778
|
return {
|
|
197401
197779
|
resourceId: resource.resourceId,
|
|
197402
197780
|
serverName,
|
|
197403
|
-
listTools: () => listToolsFromClient(
|
|
197781
|
+
listTools: () => listToolsFromClient(loggedClient, resource.resourceId),
|
|
197404
197782
|
callTool: (name, args) => {
|
|
197405
197783
|
const mapped = applyArgsMappingRules(name, args, argsMappingRules);
|
|
197406
|
-
return
|
|
197784
|
+
return loggedClient.callTool({
|
|
197785
|
+
name,
|
|
197786
|
+
arguments: mapped ?? {}
|
|
197787
|
+
});
|
|
197407
197788
|
},
|
|
197408
197789
|
close: async () => {
|
|
197409
197790
|
try {
|
|
@@ -198359,8 +198740,8 @@ var WebSkillLoader = class {
|
|
|
198359
198740
|
return (0, import_promises.readFile)(import_node_path.default.join(candidate, "SKILL.md"), "utf8");
|
|
198360
198741
|
}
|
|
198361
198742
|
if (isZipPath(candidate)) {
|
|
198362
|
-
const
|
|
198363
|
-
const files = await unzipBytes(
|
|
198743
|
+
const bytes2 = new Uint8Array(await (0, import_promises.readFile)(candidate));
|
|
198744
|
+
const files = await unzipBytes(bytes2, resourceId);
|
|
198364
198745
|
const body = extractSkillMarkdown(files);
|
|
198365
198746
|
if (body === void 0) {
|
|
198366
198747
|
throw new Error(`WebSkillLoader \u5728\u672C\u5730 zip \u5185\u672A\u627E\u5230 SKILL.md(\u6216\u56DE\u9000 .md)\u6B63\u6587: ${url2} (resourceId=${resourceId})`);
|
|
@@ -198403,7 +198784,7 @@ var extractSkillMarkdown = (files) => {
|
|
|
198403
198784
|
const rootMd = paths.find((p) => p.endsWith(".md") && !p.includes("/"));
|
|
198404
198785
|
return rootMd === void 0 ? void 0 : decodeUtf8(files[rootMd]);
|
|
198405
198786
|
};
|
|
198406
|
-
var decodeUtf8 = (
|
|
198787
|
+
var decodeUtf8 = (bytes2) => new TextDecoder("utf-8", { fatal: true }).decode(bytes2);
|
|
198407
198788
|
var globalFetch = (url2) => fetch(url2);
|
|
198408
198789
|
var detectScheme = (url2) => {
|
|
198409
198790
|
if (/^https:\/\//i.test(url2))
|
|
@@ -198907,7 +199288,7 @@ var handleHomeData = async (req, res, input) => {
|
|
|
198907
199288
|
);
|
|
198908
199289
|
}
|
|
198909
199290
|
};
|
|
198910
|
-
var handleA2UIAction = async (req, res, input) => {
|
|
199291
|
+
var handleA2UIAction = async (req, res, input, debugLog) => {
|
|
198911
199292
|
if (!executeCardAction2 || !createMcpServerProvider) {
|
|
198912
199293
|
writeJsonError2(res, 500, "AGENTDEV_NOT_READY", "agent runtime not loaded");
|
|
198913
199294
|
return;
|
|
@@ -198931,7 +199312,8 @@ var handleA2UIAction = async (req, res, input) => {
|
|
|
198931
199312
|
userId: proxyInput.userId,
|
|
198932
199313
|
...proxyInput.tenantId ? { tenantId: proxyInput.tenantId } : {}
|
|
198933
199314
|
},
|
|
198934
|
-
mcpServerProvider: createMcpServerProvider(protocol)
|
|
199315
|
+
mcpServerProvider: createMcpServerProvider(protocol),
|
|
199316
|
+
debugLog
|
|
198935
199317
|
});
|
|
198936
199318
|
res.writeHead(200, { "content-type": "application/json; charset=utf-8" });
|
|
198937
199319
|
res.end(JSON.stringify(result));
|
|
@@ -199109,7 +199491,7 @@ var main = async () => {
|
|
|
199109
199491
|
return;
|
|
199110
199492
|
}
|
|
199111
199493
|
if (req.method === "POST" && pathname === input.a2uiActionPath) {
|
|
199112
|
-
void handleA2UIAction(req, res, input);
|
|
199494
|
+
void handleA2UIAction(req, res, input, debugLog);
|
|
199113
199495
|
return;
|
|
199114
199496
|
}
|
|
199115
199497
|
const cancelMatch = pathname.match(
|