linkque-cli-v2 1.2.6 → 1.2.7
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 +1303 -862
- package/package.json +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-LVUJW2KB.js → chunk-5SPKWM3O.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-EG3MWFEG.js → chunk-B5QEJGC6.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-DCQYAWC6.js → chunk-MLVSBCIT.js} +363 -84
- 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 +517 -136
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
|
}
|
|
@@ -10217,7 +10247,7 @@ var init_v4Catalog = __esm({
|
|
|
10217
10247
|
List: {
|
|
10218
10248
|
interaction: "none",
|
|
10219
10249
|
properties: {
|
|
10220
|
-
...
|
|
10250
|
+
...listContainer,
|
|
10221
10251
|
variant: {
|
|
10222
10252
|
kind: "string",
|
|
10223
10253
|
required: true,
|
|
@@ -10228,8 +10258,9 @@ var init_v4Catalog = __esm({
|
|
|
10228
10258
|
Text: {
|
|
10229
10259
|
interaction: "none",
|
|
10230
10260
|
properties: {
|
|
10231
|
-
...
|
|
10261
|
+
...layoutItem,
|
|
10232
10262
|
...typography,
|
|
10263
|
+
shrink: { kind: "boolean" },
|
|
10233
10264
|
text: { kind: "binding", required: true },
|
|
10234
10265
|
maxLines: { kind: "number", values: [0, 1, 2, 3, 4, 5, 6] },
|
|
10235
10266
|
decoration: { kind: "string", values: ["line-through"] },
|
|
@@ -10239,19 +10270,31 @@ var init_v4Catalog = __esm({
|
|
|
10239
10270
|
Tag: {
|
|
10240
10271
|
interaction: "none",
|
|
10241
10272
|
properties: {
|
|
10242
|
-
...
|
|
10243
|
-
...typography,
|
|
10273
|
+
...layoutItem,
|
|
10244
10274
|
text: { kind: "binding", required: true },
|
|
10245
10275
|
icon: { kind: "string", values: iconNames },
|
|
10246
|
-
|
|
10247
|
-
|
|
10248
|
-
|
|
10276
|
+
tone: {
|
|
10277
|
+
kind: "string",
|
|
10278
|
+
values: [
|
|
10279
|
+
"default",
|
|
10280
|
+
"muted",
|
|
10281
|
+
"primary",
|
|
10282
|
+
"success",
|
|
10283
|
+
"warning",
|
|
10284
|
+
"error"
|
|
10285
|
+
]
|
|
10286
|
+
},
|
|
10287
|
+
variant: { kind: "string", values: ["soft", "outline", "plain"] },
|
|
10288
|
+
size: { kind: "string", values: ["sm", "md"] },
|
|
10289
|
+
shrink: { kind: "boolean" },
|
|
10290
|
+
maxLines: { kind: "number", values: [0, 1, 2, 3, 4, 5, 6] }
|
|
10249
10291
|
}
|
|
10250
10292
|
},
|
|
10251
10293
|
Button: {
|
|
10252
10294
|
interaction: "action",
|
|
10253
10295
|
properties: {
|
|
10254
|
-
...
|
|
10296
|
+
...layoutItem,
|
|
10297
|
+
...width,
|
|
10255
10298
|
label: { kind: "binding", required: true },
|
|
10256
10299
|
action: { kind: "action", required: true },
|
|
10257
10300
|
checks: { kind: "format" },
|
|
@@ -10269,34 +10312,29 @@ var init_v4Catalog = __esm({
|
|
|
10269
10312
|
Image: {
|
|
10270
10313
|
interaction: "none",
|
|
10271
10314
|
properties: {
|
|
10272
|
-
...
|
|
10315
|
+
...layoutItem,
|
|
10316
|
+
...radius,
|
|
10273
10317
|
src: { kind: "binding", required: true },
|
|
10274
10318
|
alt: { kind: "binding" },
|
|
10275
10319
|
fit: {
|
|
10276
10320
|
kind: "string",
|
|
10277
10321
|
values: ["contain", "cover", "fill", "none", "scale-down"]
|
|
10278
10322
|
},
|
|
10279
|
-
|
|
10323
|
+
aspectRatio: {
|
|
10280
10324
|
kind: "string",
|
|
10281
|
-
values: [
|
|
10282
|
-
|
|
10283
|
-
|
|
10284
|
-
|
|
10285
|
-
|
|
10286
|
-
|
|
10287
|
-
"portraitFeature",
|
|
10288
|
-
"productThumbnail",
|
|
10289
|
-
"voucherThumbnail",
|
|
10290
|
-
"largeFeature",
|
|
10291
|
-
"header"
|
|
10292
|
-
]
|
|
10325
|
+
values: ["square", "portrait", "landscape", "wide", "banner"]
|
|
10326
|
+
},
|
|
10327
|
+
height: { kind: "string", values: ["auto", "fill"] },
|
|
10328
|
+
size: {
|
|
10329
|
+
kind: "string",
|
|
10330
|
+
values: ["xs", "sm", "md", "lg", "xl", "full"]
|
|
10293
10331
|
}
|
|
10294
10332
|
}
|
|
10295
10333
|
},
|
|
10296
10334
|
Icon: {
|
|
10297
10335
|
interaction: "none",
|
|
10298
10336
|
properties: {
|
|
10299
|
-
...
|
|
10337
|
+
...layoutItem,
|
|
10300
10338
|
name: { kind: "string", required: true, values: iconNames },
|
|
10301
10339
|
label: { kind: "string" },
|
|
10302
10340
|
color: { kind: "string", values: colors },
|
|
@@ -10309,15 +10347,15 @@ var init_v4Catalog = __esm({
|
|
|
10309
10347
|
Divider: {
|
|
10310
10348
|
interaction: "none",
|
|
10311
10349
|
properties: {
|
|
10312
|
-
...
|
|
10350
|
+
...layoutItem,
|
|
10313
10351
|
axis: { kind: "string", values: ["horizontal", "vertical"] }
|
|
10314
10352
|
}
|
|
10315
10353
|
},
|
|
10316
10354
|
TextField: {
|
|
10317
10355
|
interaction: "input",
|
|
10318
10356
|
properties: {
|
|
10319
|
-
...
|
|
10320
|
-
...
|
|
10357
|
+
...layoutItem,
|
|
10358
|
+
...width,
|
|
10321
10359
|
label: { kind: "string", required: true },
|
|
10322
10360
|
value: { kind: "binding", required: true },
|
|
10323
10361
|
checks: { kind: "format" },
|
|
@@ -10341,7 +10379,8 @@ var init_v4Catalog = __esm({
|
|
|
10341
10379
|
ChoicePicker: {
|
|
10342
10380
|
interaction: "input",
|
|
10343
10381
|
properties: {
|
|
10344
|
-
...
|
|
10382
|
+
...layoutItem,
|
|
10383
|
+
...width,
|
|
10345
10384
|
label: { kind: "string", required: true },
|
|
10346
10385
|
value: { kind: "binding", required: true },
|
|
10347
10386
|
options: { kind: "options", required: true },
|
|
@@ -10356,7 +10395,8 @@ var init_v4Catalog = __esm({
|
|
|
10356
10395
|
Stepper: {
|
|
10357
10396
|
interaction: "input",
|
|
10358
10397
|
properties: {
|
|
10359
|
-
...
|
|
10398
|
+
...layoutItem,
|
|
10399
|
+
...width,
|
|
10360
10400
|
label: { kind: "string", required: true },
|
|
10361
10401
|
value: { kind: "binding", required: true },
|
|
10362
10402
|
min: { kind: "number" },
|
|
@@ -11424,6 +11464,96 @@ var init_mcpNaming = __esm({
|
|
|
11424
11464
|
}
|
|
11425
11465
|
});
|
|
11426
11466
|
|
|
11467
|
+
// ../linkque-agent-runtime/dist/esm/core/cardSemanticSnapshot.js
|
|
11468
|
+
function createCardSemanticSnapshot(receipt, fields) {
|
|
11469
|
+
const groups = receipt.coverage.map((coverage) => {
|
|
11470
|
+
const field = fields.find((f3) => f3.fieldId === coverage.fieldId);
|
|
11471
|
+
const entities = receipt.entities.filter((e2) => e2.fieldId === coverage.fieldId);
|
|
11472
|
+
const echo = field?.presentation?.visibility === "echo";
|
|
11473
|
+
const attributes = echo ? [...new Set(entities.flatMap((e2) => Object.keys(e2.attributes ?? {})))] : [];
|
|
11474
|
+
const hasValue = echo && entities.some((e2) => Object.hasOwn(e2, "value"));
|
|
11475
|
+
const hasLabel = echo && entities.some((e2) => !Object.hasOwn(e2, "value"));
|
|
11476
|
+
const columns = [
|
|
11477
|
+
"\u6761\u76EE\u5F15\u7528",
|
|
11478
|
+
...hasLabel ? [columnLabel(field, field?.presentation?.labelPath, "\u540D\u79F0")] : [],
|
|
11479
|
+
...hasValue ? [short(coverage.label)] : [],
|
|
11480
|
+
...attributes.map((path6) => columnLabel(field, path6, path6))
|
|
11481
|
+
];
|
|
11482
|
+
const rows = entities.map((e2) => [
|
|
11483
|
+
e2.ref,
|
|
11484
|
+
...hasLabel ? [e2.label] : [],
|
|
11485
|
+
...hasValue ? [e2.value ?? null] : [],
|
|
11486
|
+
...attributes.map((path6) => e2.attributes?.[path6] ?? null)
|
|
11487
|
+
]);
|
|
11488
|
+
const total = coverage.itemCount ?? (coverage.present ? 1 : 0);
|
|
11489
|
+
return {
|
|
11490
|
+
field: coverage.fieldId,
|
|
11491
|
+
label: short(coverage.label),
|
|
11492
|
+
present: coverage.present,
|
|
11493
|
+
total,
|
|
11494
|
+
included: rows.length,
|
|
11495
|
+
complete: echo && coverage.present && rows.length === total && !entities.some((e2) => e2.truncated) && !receipt.omissions.some((o) => o.fieldId === coverage.fieldId),
|
|
11496
|
+
columns,
|
|
11497
|
+
rows
|
|
11498
|
+
};
|
|
11499
|
+
});
|
|
11500
|
+
const snapshot = {
|
|
11501
|
+
version: 1,
|
|
11502
|
+
groups,
|
|
11503
|
+
omissions: receipt.omissions.map((o) => ({ ...o }))
|
|
11504
|
+
};
|
|
11505
|
+
while (bytes(snapshot) > MAX_BYTES) {
|
|
11506
|
+
let group;
|
|
11507
|
+
for (let i2 = groups.length - 1; i2 >= 0; i2--) {
|
|
11508
|
+
if (groups[i2].rows.length > 0) {
|
|
11509
|
+
group = groups[i2];
|
|
11510
|
+
break;
|
|
11511
|
+
}
|
|
11512
|
+
}
|
|
11513
|
+
snapshot.truncated = true;
|
|
11514
|
+
if (group) {
|
|
11515
|
+
group.rows.pop();
|
|
11516
|
+
group.included = group.rows.length;
|
|
11517
|
+
group.complete = false;
|
|
11518
|
+
} else if (groups.length) {
|
|
11519
|
+
groups.pop();
|
|
11520
|
+
} else if (snapshot.omissions.length) {
|
|
11521
|
+
snapshot.omissions.pop();
|
|
11522
|
+
} else
|
|
11523
|
+
break;
|
|
11524
|
+
}
|
|
11525
|
+
return snapshot;
|
|
11526
|
+
}
|
|
11527
|
+
function bytes(value) {
|
|
11528
|
+
return Buffer.byteLength(JSON.stringify(value));
|
|
11529
|
+
}
|
|
11530
|
+
function short(value) {
|
|
11531
|
+
return value.length > MAX_LABEL ? `${value.slice(0, MAX_LABEL - 1)}\u2026` : value;
|
|
11532
|
+
}
|
|
11533
|
+
function columnLabel(field, path6, fallback) {
|
|
11534
|
+
if (!field || !path6)
|
|
11535
|
+
return short(fallback);
|
|
11536
|
+
let schema = field.type === "array" ? field.valueSchema.items : field.valueSchema;
|
|
11537
|
+
for (const token of path6.slice(1).split("/").map((t2) => t2.replaceAll("~1", "/").replaceAll("~0", "~"))) {
|
|
11538
|
+
if (!schema || typeof schema !== "object" || Array.isArray(schema))
|
|
11539
|
+
return short(fallback);
|
|
11540
|
+
const properties = schema.properties;
|
|
11541
|
+
if (!properties || typeof properties !== "object" || Array.isArray(properties) || !Object.hasOwn(properties, token))
|
|
11542
|
+
return short(fallback);
|
|
11543
|
+
schema = properties[token];
|
|
11544
|
+
}
|
|
11545
|
+
const title = schema && typeof schema === "object" && !Array.isArray(schema) ? schema.title : void 0;
|
|
11546
|
+
return short(typeof title === "string" && title ? title : fallback);
|
|
11547
|
+
}
|
|
11548
|
+
var MAX_BYTES, MAX_LABEL;
|
|
11549
|
+
var init_cardSemanticSnapshot = __esm({
|
|
11550
|
+
"../linkque-agent-runtime/dist/esm/core/cardSemanticSnapshot.js"() {
|
|
11551
|
+
"use strict";
|
|
11552
|
+
MAX_BYTES = 6e3;
|
|
11553
|
+
MAX_LABEL = 160;
|
|
11554
|
+
}
|
|
11555
|
+
});
|
|
11556
|
+
|
|
11427
11557
|
// ../linkque-agent-runtime/dist/esm/core/cardTools.js
|
|
11428
11558
|
function createCardPresentationToolName(resourceId) {
|
|
11429
11559
|
return stableToolName("a2ui_card", resourceId);
|
|
@@ -11543,6 +11673,7 @@ function createPresentationResult(resource, config2, viewModel) {
|
|
|
11543
11673
|
...createA2UICardPresentationReceiptContent(config2.fields, viewModel),
|
|
11544
11674
|
responsePolicy: { verbatimEcho: "forbidden", hint: "acknowledge" }
|
|
11545
11675
|
};
|
|
11676
|
+
receipt.semanticSnapshot = createCardSemanticSnapshot(receipt, config2.fields);
|
|
11546
11677
|
return {
|
|
11547
11678
|
type: "linkque.presentation-tool-result",
|
|
11548
11679
|
modelText: formatPresentationReceiptForModel(receipt),
|
|
@@ -11562,11 +11693,23 @@ function createPresentationResult(resource, config2, viewModel) {
|
|
|
11562
11693
|
function formatPresentationReceiptForModel(receipt) {
|
|
11563
11694
|
return [
|
|
11564
11695
|
"<a2ui-presentation-receipt>",
|
|
11565
|
-
JSON.stringify(receipt),
|
|
11696
|
+
JSON.stringify(projectPresentationReceiptForModel(receipt)),
|
|
11566
11697
|
"</a2ui-presentation-receipt>",
|
|
11567
|
-
"
|
|
11698
|
+
"\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
11699
|
].join("\n");
|
|
11569
11700
|
}
|
|
11701
|
+
function projectPresentationReceiptForModel(receipt) {
|
|
11702
|
+
if (!receipt.semanticSnapshot)
|
|
11703
|
+
return receipt;
|
|
11704
|
+
return {
|
|
11705
|
+
version: receipt.version,
|
|
11706
|
+
cardRef: receipt.cardRef,
|
|
11707
|
+
cardRevision: receipt.cardRevision,
|
|
11708
|
+
cardInstanceId: receipt.cardInstanceId,
|
|
11709
|
+
status: receipt.status,
|
|
11710
|
+
semanticSnapshot: receipt.semanticSnapshot
|
|
11711
|
+
};
|
|
11712
|
+
}
|
|
11570
11713
|
function parseCardConfig(resource) {
|
|
11571
11714
|
const parsed = parseA2UICardResourceConfig(resource.config);
|
|
11572
11715
|
if (!parsed.success) {
|
|
@@ -11620,9 +11763,9 @@ function collectA2UISurfaceIdsForLegacyContract(protocol) {
|
|
|
11620
11763
|
function createPresentationDescription(config2) {
|
|
11621
11764
|
return [
|
|
11622
11765
|
config2.description,
|
|
11623
|
-
|
|
11624
|
-
...config2.whenNotToUse ? [
|
|
11625
|
-
"
|
|
11766
|
+
`\u9002\u7528\u573A\u666F\uFF1A${config2.whenToUse}`,
|
|
11767
|
+
...config2.whenNotToUse ? [`\u4E0D\u9002\u7528\u573A\u666F\uFF1A${config2.whenNotToUse}`] : [],
|
|
11768
|
+
"\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
11769
|
].join("\n");
|
|
11627
11770
|
}
|
|
11628
11771
|
function cloneJsonObject2(value, label) {
|
|
@@ -11696,6 +11839,7 @@ var init_cardTools = __esm({
|
|
|
11696
11839
|
import_node_crypto2 = require("node:crypto");
|
|
11697
11840
|
init_esm3();
|
|
11698
11841
|
init_mcpNaming();
|
|
11842
|
+
init_cardSemanticSnapshot();
|
|
11699
11843
|
FALLBACK_OBJECT_SCHEMA = {
|
|
11700
11844
|
type: "object",
|
|
11701
11845
|
additionalProperties: true
|
|
@@ -11896,7 +12040,11 @@ var init_mcpProxyTool = __esm({
|
|
|
11896
12040
|
return;
|
|
11897
12041
|
try {
|
|
11898
12042
|
await entry.server.close?.();
|
|
11899
|
-
} catch {
|
|
12043
|
+
} catch (error40) {
|
|
12044
|
+
try {
|
|
12045
|
+
this.debugLog(`[mcp] server ${entry.server.serverName} close failed: ${error40 instanceof Error ? error40.message : "unknown error"}`, EDebugLogScope.MCP);
|
|
12046
|
+
} catch {
|
|
12047
|
+
}
|
|
11900
12048
|
}
|
|
11901
12049
|
}));
|
|
11902
12050
|
}
|
|
@@ -12481,13 +12629,26 @@ var init_hookRegistry = __esm({
|
|
|
12481
12629
|
}
|
|
12482
12630
|
});
|
|
12483
12631
|
|
|
12632
|
+
// ../linkque-agent-runtime/dist/esm/core/logFailure.js
|
|
12633
|
+
function warnLogFailure(stage, error40) {
|
|
12634
|
+
(0, import_node_process.emitWarning)(`[${stage}] errorType=${error40 instanceof Error ? error40.name : typeof error40}`, { code: "LINKQUE_RUNTIME_DIAGNOSTIC_FAILURE" });
|
|
12635
|
+
}
|
|
12636
|
+
var import_node_process;
|
|
12637
|
+
var init_logFailure = __esm({
|
|
12638
|
+
"../linkque-agent-runtime/dist/esm/core/logFailure.js"() {
|
|
12639
|
+
"use strict";
|
|
12640
|
+
import_node_process = require("node:process");
|
|
12641
|
+
}
|
|
12642
|
+
});
|
|
12643
|
+
|
|
12484
12644
|
// ../linkque-agent-runtime/dist/esm/core/hook/hookLog.js
|
|
12485
12645
|
function writeHookLog(debugLog, record3) {
|
|
12486
12646
|
if (!debugLog)
|
|
12487
12647
|
return;
|
|
12488
12648
|
try {
|
|
12489
12649
|
debugLog(JSON.stringify(redactHookLogRecord(record3)), EDebugLogScope.HOOK);
|
|
12490
|
-
} catch {
|
|
12650
|
+
} catch (error40) {
|
|
12651
|
+
warnLogFailure("writeHookLog", error40);
|
|
12491
12652
|
}
|
|
12492
12653
|
}
|
|
12493
12654
|
function redactHookLogRecord(record3) {
|
|
@@ -12507,6 +12668,7 @@ var HOOK_LOG_MESSAGE_MAX_LENGTH;
|
|
|
12507
12668
|
var init_hookLog = __esm({
|
|
12508
12669
|
"../linkque-agent-runtime/dist/esm/core/hook/hookLog.js"() {
|
|
12509
12670
|
"use strict";
|
|
12671
|
+
init_logFailure();
|
|
12510
12672
|
init_types();
|
|
12511
12673
|
HOOK_LOG_MESSAGE_MAX_LENGTH = 200;
|
|
12512
12674
|
}
|
|
@@ -12708,6 +12870,15 @@ var init_hookDispatcher = __esm({
|
|
|
12708
12870
|
stage: EHookStage.RUN_READ,
|
|
12709
12871
|
read: { readAt: subject.readAt ?? now() }
|
|
12710
12872
|
};
|
|
12873
|
+
case EHookStage.MODEL_RESPONSE_RECEIVED: {
|
|
12874
|
+
if (!subject.model)
|
|
12875
|
+
throw new Error("MODEL_RESPONSE_RECEIVED Hook \u7F3A\u5C11\u54CD\u5E94\u4E0A\u4E0B\u6587");
|
|
12876
|
+
return {
|
|
12877
|
+
...base,
|
|
12878
|
+
stage: EHookStage.MODEL_RESPONSE_RECEIVED,
|
|
12879
|
+
model: subject.model
|
|
12880
|
+
};
|
|
12881
|
+
}
|
|
12711
12882
|
case EHookStage.AFTER_MODEL_CALL: {
|
|
12712
12883
|
if (!subject.model || subject.model.messageContent === void 0) {
|
|
12713
12884
|
throw new Error("AFTER_MODEL_CALL Hook \u7F3A\u5C11\u5B8C\u6574 model context");
|
|
@@ -13272,7 +13443,8 @@ function redactHeaders(headers) {
|
|
|
13272
13443
|
pairs.push(`${key}=${redactHeader(key, value)}`);
|
|
13273
13444
|
}
|
|
13274
13445
|
}
|
|
13275
|
-
} catch {
|
|
13446
|
+
} catch (error40) {
|
|
13447
|
+
warnLogFailure("httpLoggingFetch.redactHeaders", error40);
|
|
13276
13448
|
}
|
|
13277
13449
|
return pairs.join(",");
|
|
13278
13450
|
}
|
|
@@ -13309,7 +13481,8 @@ function createHttpLoggingFetch(debugLog, tag, baseFetch = globalThis.fetch) {
|
|
|
13309
13481
|
const cl = resp.headers.get("content-length");
|
|
13310
13482
|
if (cl)
|
|
13311
13483
|
len = cl;
|
|
13312
|
-
} catch {
|
|
13484
|
+
} catch (error40) {
|
|
13485
|
+
warnLogFailure("httpLoggingFetch.contentLength", error40);
|
|
13313
13486
|
}
|
|
13314
13487
|
const correlation = readResponseCorrelationId(resp.headers);
|
|
13315
13488
|
const correlationField = correlation ? ` traceId=${correlation.value} traceHeader=${correlation.name}` : "";
|
|
@@ -13338,14 +13511,16 @@ function readResponseCorrelationId(headers) {
|
|
|
13338
13511
|
};
|
|
13339
13512
|
});
|
|
13340
13513
|
return matched;
|
|
13341
|
-
} catch {
|
|
13514
|
+
} catch (error40) {
|
|
13515
|
+
warnLogFailure("httpLoggingFetch.responseCorrelationId", error40);
|
|
13342
13516
|
}
|
|
13343
13517
|
return void 0;
|
|
13344
13518
|
}
|
|
13345
13519
|
function safeLog(debugLog, line) {
|
|
13346
13520
|
try {
|
|
13347
13521
|
debugLog(line, EDebugLogScope.HTTP);
|
|
13348
|
-
} catch {
|
|
13522
|
+
} catch (error40) {
|
|
13523
|
+
warnLogFailure("httpLoggingFetch.safeLog", error40);
|
|
13349
13524
|
}
|
|
13350
13525
|
}
|
|
13351
13526
|
function nowMs() {
|
|
@@ -13360,6 +13535,7 @@ var init_httpLoggingFetch = __esm({
|
|
|
13360
13535
|
"../linkque-agent-runtime/dist/esm/impl/httpLoggingFetch.js"() {
|
|
13361
13536
|
"use strict";
|
|
13362
13537
|
init_types();
|
|
13538
|
+
init_logFailure();
|
|
13363
13539
|
MAX_BODY_SUMMARY_LEN = 2e3;
|
|
13364
13540
|
REDACTED_HEADER_NAMES = /* @__PURE__ */ new Set([
|
|
13365
13541
|
"authorization",
|
|
@@ -31861,9 +32037,6 @@ function getConversationRunRequestIssues(value) {
|
|
|
31861
32037
|
issues.push("attachments must be an array");
|
|
31862
32038
|
} else {
|
|
31863
32039
|
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
32040
|
}
|
|
31868
32041
|
if (!isRecord3(value.metadata))
|
|
31869
32042
|
issues.push("metadata must be an object");
|
|
@@ -32004,9 +32177,6 @@ function validateAttachment(value, index2, issues) {
|
|
|
32004
32177
|
if (value.size !== void 0 && (!Number.isSafeInteger(value.size) || Number(value.size) < 0)) {
|
|
32005
32178
|
issues.push(`attachments[${index2}].size must be a non-negative safe integer when provided`);
|
|
32006
32179
|
}
|
|
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
32180
|
if (value.metadata !== void 0 && !isRecord3(value.metadata)) {
|
|
32011
32181
|
issues.push(`attachments[${index2}].metadata must be an object when provided`);
|
|
32012
32182
|
}
|
|
@@ -32940,9 +33110,9 @@ function encodeUTF8(str2) {
|
|
|
32940
33110
|
let encoder2;
|
|
32941
33111
|
return (encodeUTF8_ ?? (encoder2 = new globalThis.TextEncoder(), encodeUTF8_ = encoder2.encode.bind(encoder2)))(str2);
|
|
32942
33112
|
}
|
|
32943
|
-
function decodeUTF8(
|
|
33113
|
+
function decodeUTF8(bytes2) {
|
|
32944
33114
|
let decoder;
|
|
32945
|
-
return (decodeUTF8_ ?? (decoder = new globalThis.TextDecoder(), decodeUTF8_ = decoder.decode.bind(decoder)))(
|
|
33115
|
+
return (decodeUTF8_ ?? (decoder = new globalThis.TextDecoder(), decodeUTF8_ = decoder.decode.bind(decoder)))(bytes2);
|
|
32946
33116
|
}
|
|
32947
33117
|
var encodeUTF8_, decodeUTF8_;
|
|
32948
33118
|
var init_bytes = __esm({
|
|
@@ -33322,8 +33492,8 @@ var init_streaming = __esm({
|
|
|
33322
33492
|
const { value, done } = await iter.next();
|
|
33323
33493
|
if (done)
|
|
33324
33494
|
return ctrl.close();
|
|
33325
|
-
const
|
|
33326
|
-
ctrl.enqueue(
|
|
33495
|
+
const bytes2 = encodeUTF8(JSON.stringify(value) + "\n");
|
|
33496
|
+
ctrl.enqueue(bytes2);
|
|
33327
33497
|
} catch (err3) {
|
|
33328
33498
|
ctrl.error(err3);
|
|
33329
33499
|
}
|
|
@@ -42371,9 +42541,9 @@ function encodeUTF82(str2) {
|
|
|
42371
42541
|
let encoder2;
|
|
42372
42542
|
return (encodeUTF8_2 ?? (encoder2 = new globalThis.TextEncoder(), encodeUTF8_2 = encoder2.encode.bind(encoder2)))(str2);
|
|
42373
42543
|
}
|
|
42374
|
-
function decodeUTF82(
|
|
42544
|
+
function decodeUTF82(bytes2) {
|
|
42375
42545
|
let decoder;
|
|
42376
|
-
return (decodeUTF8_2 ?? (decoder = new globalThis.TextDecoder(), decodeUTF8_2 = decoder.decode.bind(decoder)))(
|
|
42546
|
+
return (decodeUTF8_2 ?? (decoder = new globalThis.TextDecoder(), decodeUTF8_2 = decoder.decode.bind(decoder)))(bytes2);
|
|
42377
42547
|
}
|
|
42378
42548
|
var encodeUTF8_2, decodeUTF8_2;
|
|
42379
42549
|
var init_bytes2 = __esm({
|
|
@@ -42759,8 +42929,8 @@ var init_streaming3 = __esm({
|
|
|
42759
42929
|
const { value, done } = await iter.next();
|
|
42760
42930
|
if (done)
|
|
42761
42931
|
return ctrl.close();
|
|
42762
|
-
const
|
|
42763
|
-
ctrl.enqueue(
|
|
42932
|
+
const bytes2 = encodeUTF82(JSON.stringify(value) + "\n");
|
|
42933
|
+
ctrl.enqueue(bytes2);
|
|
42764
42934
|
} catch (err3) {
|
|
42765
42935
|
ctrl.error(err3);
|
|
42766
42936
|
}
|
|
@@ -45477,11 +45647,11 @@ var init_base64 = __esm({
|
|
|
45477
45647
|
} else {
|
|
45478
45648
|
const binaryStr = atob(base64Str);
|
|
45479
45649
|
const len = binaryStr.length;
|
|
45480
|
-
const
|
|
45650
|
+
const bytes2 = new Uint8Array(len);
|
|
45481
45651
|
for (let i2 = 0; i2 < len; i2++) {
|
|
45482
|
-
|
|
45652
|
+
bytes2[i2] = binaryStr.charCodeAt(i2);
|
|
45483
45653
|
}
|
|
45484
|
-
return Array.from(new Float32Array(
|
|
45654
|
+
return Array.from(new Float32Array(bytes2.buffer));
|
|
45485
45655
|
}
|
|
45486
45656
|
};
|
|
45487
45657
|
}
|
|
@@ -56695,14 +56865,14 @@ var require_streams = __commonJS({
|
|
|
56695
56865
|
if (!globalThis.ReadableStream) {
|
|
56696
56866
|
try {
|
|
56697
56867
|
const process2 = require("node:process");
|
|
56698
|
-
const { emitWarning } = process2;
|
|
56868
|
+
const { emitWarning: emitWarning2 } = process2;
|
|
56699
56869
|
try {
|
|
56700
56870
|
process2.emitWarning = () => {
|
|
56701
56871
|
};
|
|
56702
56872
|
Object.assign(globalThis, require("node:stream/web"));
|
|
56703
|
-
process2.emitWarning =
|
|
56873
|
+
process2.emitWarning = emitWarning2;
|
|
56704
56874
|
} catch (error40) {
|
|
56705
|
-
process2.emitWarning =
|
|
56875
|
+
process2.emitWarning = emitWarning2;
|
|
56706
56876
|
throw error40;
|
|
56707
56877
|
}
|
|
56708
56878
|
} catch (error40) {
|
|
@@ -82258,9 +82428,9 @@ function encodeUTF83(str2) {
|
|
|
82258
82428
|
let encoder2;
|
|
82259
82429
|
return (encodeUTF8_3 !== null && encodeUTF8_3 !== void 0 ? encodeUTF8_3 : (encoder2 = new globalThis.TextEncoder(), encodeUTF8_3 = encoder2.encode.bind(encoder2)))(str2);
|
|
82260
82430
|
}
|
|
82261
|
-
function decodeUTF83(
|
|
82431
|
+
function decodeUTF83(bytes2) {
|
|
82262
82432
|
let decoder;
|
|
82263
|
-
return (decodeUTF8_3 !== null && decodeUTF8_3 !== void 0 ? decodeUTF8_3 : (decoder = new globalThis.TextDecoder(), decodeUTF8_3 = decoder.decode.bind(decoder)))(
|
|
82433
|
+
return (decodeUTF8_3 !== null && decodeUTF8_3 !== void 0 ? decodeUTF8_3 : (decoder = new globalThis.TextDecoder(), decodeUTF8_3 = decoder.decode.bind(decoder)))(bytes2);
|
|
82264
82434
|
}
|
|
82265
82435
|
function findNewlineIndex3(buffer, startIndex) {
|
|
82266
82436
|
const newline = 10;
|
|
@@ -89420,8 +89590,8 @@ ${underline}`);
|
|
|
89420
89590
|
const { value, done } = await iter.next();
|
|
89421
89591
|
if (done)
|
|
89422
89592
|
return ctrl.close();
|
|
89423
|
-
const
|
|
89424
|
-
ctrl.enqueue(
|
|
89593
|
+
const bytes2 = encodeUTF83(JSON.stringify(value) + "\n");
|
|
89594
|
+
ctrl.enqueue(bytes2);
|
|
89425
89595
|
} catch (err3) {
|
|
89426
89596
|
ctrl.error(err3);
|
|
89427
89597
|
}
|
|
@@ -189374,7 +189544,8 @@ async function createAgentSession(options) {
|
|
|
189374
189544
|
onDelay: (delayMs) => {
|
|
189375
189545
|
try {
|
|
189376
189546
|
options.debugLog?.(`[llm-throttle] wait ${delayMs}ms before next request`, EDebugLogScope.LLM);
|
|
189377
|
-
} catch {
|
|
189547
|
+
} catch (error40) {
|
|
189548
|
+
warnLogFailure("createAgentSession.throttleLog", error40);
|
|
189378
189549
|
}
|
|
189379
189550
|
}
|
|
189380
189551
|
});
|
|
@@ -189407,7 +189578,8 @@ async function createAgentSession(options) {
|
|
|
189407
189578
|
await prevOnPayload?.(payload, m2);
|
|
189408
189579
|
try {
|
|
189409
189580
|
logSink(formatHttpLogLine("llm", "req", `POST ${baseUrl} model=${m2.id} payload=${summarizeBody(safeStringifyPayload(payload))}`), EDebugLogScope.LLM);
|
|
189410
|
-
} catch {
|
|
189581
|
+
} catch (error40) {
|
|
189582
|
+
warnLogFailure("createAgentSession.requestLog", error40);
|
|
189411
189583
|
}
|
|
189412
189584
|
};
|
|
189413
189585
|
}
|
|
@@ -189424,6 +189596,7 @@ async function createAgentSession(options) {
|
|
|
189424
189596
|
responseHeaders: response.headers
|
|
189425
189597
|
}
|
|
189426
189598
|
};
|
|
189599
|
+
await options.hookRuntime.dispatcher.dispatch(EHookStage.MODEL_RESPONSE_RECEIVED, options.hookRuntime.commonParams, subject);
|
|
189427
189600
|
if (options.hookRuntime.dispatcher.hasMatchingResource(EHookStage.AFTER_MODEL_CALL, subject)) {
|
|
189428
189601
|
gateState = { subject };
|
|
189429
189602
|
}
|
|
@@ -189432,7 +189605,8 @@ async function createAgentSession(options) {
|
|
|
189432
189605
|
try {
|
|
189433
189606
|
const baseUrl = model.baseUrl ?? "<unknown>";
|
|
189434
189607
|
logSink(formatHttpLogLine("llm", "resp", `POST ${baseUrl} model=${m2.id} ${response.status} headers=${redactHeaders(response.headers)}`), EDebugLogScope.LLM);
|
|
189435
|
-
} catch {
|
|
189608
|
+
} catch (error40) {
|
|
189609
|
+
warnLogFailure("createAgentSession.responseLog", error40);
|
|
189436
189610
|
}
|
|
189437
189611
|
}
|
|
189438
189612
|
};
|
|
@@ -189459,7 +189633,8 @@ async function createAgentSession(options) {
|
|
|
189459
189633
|
try {
|
|
189460
189634
|
agent.abort();
|
|
189461
189635
|
agent.reset();
|
|
189462
|
-
} catch {
|
|
189636
|
+
} catch (error40) {
|
|
189637
|
+
warnLogFailure("createAgentSession.dispose", error40);
|
|
189463
189638
|
}
|
|
189464
189639
|
}
|
|
189465
189640
|
}
|
|
@@ -189512,7 +189687,8 @@ function serializeToolResult2(value) {
|
|
|
189512
189687
|
try {
|
|
189513
189688
|
const serialized = JSON.stringify(value);
|
|
189514
189689
|
return serialized === void 0 ? "\u5DE5\u5177\u6267\u884C\u5B8C\u6210\u3002" : serialized;
|
|
189515
|
-
} catch {
|
|
189690
|
+
} catch (error40) {
|
|
189691
|
+
warnLogFailure("createAgentSession.toolResultSerialization", error40);
|
|
189516
189692
|
return "\u5DE5\u5177\u6267\u884C\u5B8C\u6210\u3002";
|
|
189517
189693
|
}
|
|
189518
189694
|
}
|
|
@@ -189523,13 +189699,15 @@ function safeStringifyPayload(payload) {
|
|
|
189523
189699
|
return payload;
|
|
189524
189700
|
try {
|
|
189525
189701
|
return JSON.stringify(payload) ?? "";
|
|
189526
|
-
} catch {
|
|
189702
|
+
} catch (error40) {
|
|
189703
|
+
warnLogFailure("createAgentSession.payloadSerialization", error40);
|
|
189527
189704
|
return "<unserializable>";
|
|
189528
189705
|
}
|
|
189529
189706
|
}
|
|
189530
189707
|
var init_createAgentSession = __esm({
|
|
189531
189708
|
"../linkque-agent-runtime/dist/esm/impl/agent/pi/createAgentSession.js"() {
|
|
189532
189709
|
"use strict";
|
|
189710
|
+
init_logFailure();
|
|
189533
189711
|
init_dist4();
|
|
189534
189712
|
init_dist3();
|
|
189535
189713
|
init_esm();
|
|
@@ -190126,6 +190304,10 @@ var init_followUpQuestionGenerator = __esm({
|
|
|
190126
190304
|
FOLLOW_UP_QUESTION_TOOL_NAME = "submit_follow_up_questions";
|
|
190127
190305
|
FOLLOW_UP_QUESTION_TIMEOUT_MS = 4500;
|
|
190128
190306
|
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
|
|
190307
|
+
- \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
|
|
190308
|
+
- \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
|
|
190309
|
+
- \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
|
|
190310
|
+
- \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
190311
|
- 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
190312
|
- \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
190313
|
- \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 +190346,10 @@ var init_followUpQuestionGenerator = __esm({
|
|
|
190164
190346
|
tools: [
|
|
190165
190347
|
{
|
|
190166
190348
|
name: FOLLOW_UP_QUESTION_TOOL_NAME,
|
|
190167
|
-
description: "\u63D0\u4EA4\
|
|
190168
|
-
parameters: typebox_exports.Object({
|
|
190349
|
+
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",
|
|
190350
|
+
parameters: typebox_exports.Object({
|
|
190351
|
+
questions: typebox_exports.Array(typebox_exports.String({ minLength: 1, maxLength: 20 }), { maxItems: 3 })
|
|
190352
|
+
}, { additionalProperties: false })
|
|
190169
190353
|
}
|
|
190170
190354
|
]
|
|
190171
190355
|
};
|
|
@@ -190341,18 +190525,39 @@ var init_pi = __esm({
|
|
|
190341
190525
|
});
|
|
190342
190526
|
|
|
190343
190527
|
// ../linkque-agent-runtime/dist/esm/core/cardRenderMcpServer.js
|
|
190528
|
+
function readAfterCard(args) {
|
|
190529
|
+
if (!args || typeof args !== "object")
|
|
190530
|
+
return void 0;
|
|
190531
|
+
const mode = args.responseMode;
|
|
190532
|
+
if (Object.hasOwn(args, "responseMode") && !["card_only", "supplement", "user_requested_text"].includes(mode))
|
|
190533
|
+
throw new Error("responseMode \u65E0\u6548\uFF0C\u8BF7\u9009\u62E9\u5DF2\u58F0\u660E\u7684\u6A21\u5F0F");
|
|
190534
|
+
if (!Object.hasOwn(args, "afterCard")) {
|
|
190535
|
+
if (mode !== void 0)
|
|
190536
|
+
throw new Error("\u6307\u5B9A responseMode \u65F6\u5FC5\u987B\u63D0\u4F9B afterCard");
|
|
190537
|
+
return void 0;
|
|
190538
|
+
}
|
|
190539
|
+
const value = args.afterCard;
|
|
190540
|
+
if (typeof value !== "string" || value.length > 16e3)
|
|
190541
|
+
throw new Error("afterCard \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\uFF0C\u957F\u5EA6\u4E0D\u80FD\u8D85\u8FC7 16000");
|
|
190542
|
+
if (mode === "card_only" && value.trim() !== "")
|
|
190543
|
+
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");
|
|
190544
|
+
return value.trim();
|
|
190545
|
+
}
|
|
190344
190546
|
function createCardSourceToolName(resourceId, sourceId) {
|
|
190345
190547
|
return stableToolName("card_source", `${resourceId}_${sourceId}`);
|
|
190346
190548
|
}
|
|
190347
190549
|
function createCardFinishToolName(resourceId) {
|
|
190348
190550
|
return stableToolName("card_finish", resourceId);
|
|
190349
190551
|
}
|
|
190350
|
-
var CardRenderMcpServer;
|
|
190552
|
+
var CARD_SEQUENCE, AFTER_CARD_DESCRIPTION, RESPONSE_MODE_DESCRIPTION, CardRenderMcpServer;
|
|
190351
190553
|
var init_cardRenderMcpServer = __esm({
|
|
190352
190554
|
"../linkque-agent-runtime/dist/esm/core/cardRenderMcpServer.js"() {
|
|
190353
190555
|
"use strict";
|
|
190354
190556
|
init_cardTools();
|
|
190355
190557
|
init_mcpNaming();
|
|
190558
|
+
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";
|
|
190559
|
+
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";
|
|
190560
|
+
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
190561
|
CardRenderMcpServer = class {
|
|
190357
190562
|
resources;
|
|
190358
190563
|
registry;
|
|
@@ -190374,6 +190579,8 @@ var init_cardRenderMcpServer = __esm({
|
|
|
190374
190579
|
toolByName = /* @__PURE__ */ new Map();
|
|
190375
190580
|
activeCardId;
|
|
190376
190581
|
invalidCards = [];
|
|
190582
|
+
/** 只信任本实例实际执行成功的结果,普通 MCP JSON 无权控制文字输出。 */
|
|
190583
|
+
companions = /* @__PURE__ */ new WeakMap();
|
|
190377
190584
|
/** 本轮被隔离的坏卡,仅供宿主诊断,不影响其它卡片注册。 */
|
|
190378
190585
|
getInvalidCards() {
|
|
190379
190586
|
return this.invalidCards;
|
|
@@ -190414,7 +190621,7 @@ var init_cardRenderMcpServer = __esm({
|
|
|
190414
190621
|
resourceId: resource.resourceId,
|
|
190415
190622
|
label: config2.displayName,
|
|
190416
190623
|
description: `${createPresentationDescription(config2)}
|
|
190417
|
-
|
|
190624
|
+
\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
190625
|
inputSchema: {
|
|
190419
190626
|
type: "object",
|
|
190420
190627
|
properties: {},
|
|
@@ -190453,18 +190660,18 @@ Select this card first, then call its card_source tools and card_finish tool.`,
|
|
|
190453
190660
|
modelName: sourceToolName,
|
|
190454
190661
|
resourceId: resource.resourceId,
|
|
190455
190662
|
label: source.purpose,
|
|
190456
|
-
description:
|
|
190663
|
+
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
190664
|
inputSchema: normalizeMcpInputSchema(discoveredHandle?.inputSchema),
|
|
190458
190665
|
outputSchema: discoveredHandle?.outputSchema ?? source.outputSchema,
|
|
190459
190666
|
execute: async (args, signal) => {
|
|
190460
190667
|
if (!state2.selected || this.activeCardId !== resource.resourceId)
|
|
190461
|
-
throw new Error(
|
|
190668
|
+
throw new Error(`\u8C03\u7528\u6570\u636E\u6E90\u524D\uFF0C\u8BF7\u5148\u9009\u62E9\u5361\u7247 ${name}`);
|
|
190462
190669
|
const missingDependencies = (source.dependsOn ?? []).filter((dependency) => !state2.results.has(dependency));
|
|
190463
190670
|
if (missingDependencies.length)
|
|
190464
|
-
throw new Error(
|
|
190671
|
+
throw new Error(`\u6570\u636E\u6E90 ${source.sourceId} \u9700\u8981\u5148\u5B8C\u6210\u4EE5\u4E0B\u4F9D\u8D56\uFF1A${missingDependencies.join(", ")}`);
|
|
190465
190672
|
const handle = discoveredHandle ?? await this.registry.resolve(source.mcpResourceId, source.toolName, signal);
|
|
190466
190673
|
if (!handle)
|
|
190467
|
-
throw new Error(`MCP
|
|
190674
|
+
throw new Error(`MCP \u5DE5\u5177 ${source.mcpResourceId}/${source.toolName} \u5F53\u524D\u4E0D\u53EF\u7528`);
|
|
190468
190675
|
const result = await handle.execute(args, signal);
|
|
190469
190676
|
const structured = readStructuredContent(result);
|
|
190470
190677
|
if (structured === void 0) {
|
|
@@ -190491,16 +190698,36 @@ Select this card first, then call its card_source tools and card_finish tool.`,
|
|
|
190491
190698
|
modelName: finishName,
|
|
190492
190699
|
resourceId: resource.resourceId,
|
|
190493
190700
|
label: `\u5C55\u793A${config2.displayName}`,
|
|
190494
|
-
description:
|
|
190701
|
+
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}
|
|
190702
|
+
${AFTER_CARD_DESCRIPTION}`,
|
|
190495
190703
|
inputSchema: {
|
|
190496
190704
|
type: "object",
|
|
190497
|
-
|
|
190705
|
+
required: ["responseMode", "afterCard"],
|
|
190706
|
+
properties: {
|
|
190707
|
+
responseMode: {
|
|
190708
|
+
type: "string",
|
|
190709
|
+
enum: ["card_only", "supplement", "user_requested_text"],
|
|
190710
|
+
description: RESPONSE_MODE_DESCRIPTION
|
|
190711
|
+
},
|
|
190712
|
+
afterCard: {
|
|
190713
|
+
type: "string",
|
|
190714
|
+
maxLength: 16e3,
|
|
190715
|
+
description: AFTER_CARD_DESCRIPTION
|
|
190716
|
+
}
|
|
190717
|
+
},
|
|
190498
190718
|
additionalProperties: false
|
|
190499
190719
|
},
|
|
190500
|
-
execute: async (
|
|
190720
|
+
execute: async (args, signal) => {
|
|
190501
190721
|
if (!state2.selected || this.activeCardId !== resource.resourceId)
|
|
190502
|
-
throw new Error(
|
|
190722
|
+
throw new Error(`\u5B8C\u6210\u5C55\u793A\u524D\uFF0C\u8BF7\u5148\u9009\u62E9\u5361\u7247 ${name}`);
|
|
190723
|
+
const afterCard = readAfterCard(args);
|
|
190503
190724
|
const result = await executeCardPresentationFromSources(resource, this.runtimeContext, state2.results, signal);
|
|
190725
|
+
if (afterCard !== void 0) {
|
|
190726
|
+
this.companions.set(result, afterCard);
|
|
190727
|
+
result.modelText += `
|
|
190728
|
+
<a2ui-companion-delivery>${JSON.stringify({ afterCard })}</a2ui-companion-delivery>
|
|
190729
|
+
\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`;
|
|
190730
|
+
}
|
|
190504
190731
|
state2.selected = false;
|
|
190505
190732
|
this.activeCardId = void 0;
|
|
190506
190733
|
return result;
|
|
@@ -190531,6 +190758,32 @@ Select this card first, then call its card_source tools and card_finish tool.`,
|
|
|
190531
190758
|
this.activeCardId = void 0;
|
|
190532
190759
|
this.states.clear();
|
|
190533
190760
|
this.toolByName.clear();
|
|
190761
|
+
this.companions = /* @__PURE__ */ new WeakMap();
|
|
190762
|
+
}
|
|
190763
|
+
/** 卡片与伴随文字的共享输出边界,不参与模型循环或工具调度。 */
|
|
190764
|
+
async *projectConversation(events) {
|
|
190765
|
+
const pending = /* @__PURE__ */ new WeakMap();
|
|
190766
|
+
let cardOwnsText = false;
|
|
190767
|
+
for await (const event of events) {
|
|
190768
|
+
if (event.type === "tool_start" || event.type === "error" || event.type === "done")
|
|
190769
|
+
cardOwnsText = false;
|
|
190770
|
+
if (event.type === "tool_end" && !event.isError) {
|
|
190771
|
+
const details = event.result && typeof event.result === "object" && "details" in event.result ? event.result.details : void 0;
|
|
190772
|
+
if (details && this.companions.has(details)) {
|
|
190773
|
+
pending.set(details.card, this.companions.get(details));
|
|
190774
|
+
}
|
|
190775
|
+
}
|
|
190776
|
+
if (event.type === "delta" && cardOwnsText)
|
|
190777
|
+
continue;
|
|
190778
|
+
yield event;
|
|
190779
|
+
if (event.type === "a2ui_card" && pending.has(event)) {
|
|
190780
|
+
const text2 = pending.get(event);
|
|
190781
|
+
pending.delete(event);
|
|
190782
|
+
cardOwnsText = true;
|
|
190783
|
+
if (text2)
|
|
190784
|
+
yield { type: "delta", content: text2 };
|
|
190785
|
+
}
|
|
190786
|
+
}
|
|
190534
190787
|
}
|
|
190535
190788
|
};
|
|
190536
190789
|
}
|
|
@@ -191176,7 +191429,7 @@ var init_agentRuntime = __esm({
|
|
|
191176
191429
|
});
|
|
191177
191430
|
};
|
|
191178
191431
|
try {
|
|
191179
|
-
for await (const ev of this.agentLoop.run(agentReq)) {
|
|
191432
|
+
for await (const ev of cardServer.projectConversation(this.agentLoop.run(agentReq))) {
|
|
191180
191433
|
if (ev.type === "delta")
|
|
191181
191434
|
assistantText += ev.content;
|
|
191182
191435
|
if (ev.type === "tool_end" && !ev.isError) {
|
|
@@ -191196,7 +191449,10 @@ var init_agentRuntime = __esm({
|
|
|
191196
191449
|
...presentationReceipts.map((receipt) => ({
|
|
191197
191450
|
role: "tool",
|
|
191198
191451
|
name: "a2ui_presentation_receipt",
|
|
191199
|
-
content: {
|
|
191452
|
+
content: {
|
|
191453
|
+
type: "a2ui.presentation-receipt",
|
|
191454
|
+
receipt: projectPresentationReceiptForModel(receipt)
|
|
191455
|
+
}
|
|
191200
191456
|
})),
|
|
191201
191457
|
{ role: "assistant", content: assistantText }
|
|
191202
191458
|
];
|
|
@@ -191401,16 +191657,16 @@ async function boundedBody(response, max2) {
|
|
|
191401
191657
|
}
|
|
191402
191658
|
}
|
|
191403
191659
|
function validate(data, mediaType) {
|
|
191404
|
-
if (data.length > Math.ceil(
|
|
191660
|
+
if (data.length > Math.ceil(MAX_BYTES2 / 3) * 4)
|
|
191405
191661
|
imageError("IMAGE_TOO_LARGE");
|
|
191406
191662
|
if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(data))
|
|
191407
191663
|
imageError("IMAGE_DATA_INVALID");
|
|
191408
|
-
const
|
|
191409
|
-
if (
|
|
191664
|
+
const bytes2 = Buffer.from(data, "base64");
|
|
191665
|
+
if (bytes2.length > MAX_BYTES2)
|
|
191410
191666
|
imageError("IMAGE_TOO_LARGE");
|
|
191411
|
-
if (
|
|
191667
|
+
if (bytes2.toString("base64") !== data || !bytes2.length)
|
|
191412
191668
|
imageError("IMAGE_DATA_INVALID");
|
|
191413
|
-
const magic = mediaType === "image/png" ?
|
|
191669
|
+
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
191670
|
if (!magic)
|
|
191415
191671
|
imageError("IMAGE_MEDIA_INVALID");
|
|
191416
191672
|
return { mediaType, data };
|
|
@@ -191418,7 +191674,7 @@ function validate(data, mediaType) {
|
|
|
191418
191674
|
async function resolveImage(image, fetchImpl, rules, signal) {
|
|
191419
191675
|
signal.throwIfAborted();
|
|
191420
191676
|
if (image.dataUrl) {
|
|
191421
|
-
if (image.dataUrl.length > Math.ceil(
|
|
191677
|
+
if (image.dataUrl.length > Math.ceil(MAX_BYTES2 / 3) * 4 + 32)
|
|
191422
191678
|
imageError("IMAGE_TOO_LARGE");
|
|
191423
191679
|
const match2 = /^data:(image\/(?:png|jpeg|webp));base64,([A-Za-z0-9+/=]+)$/.exec(image.dataUrl);
|
|
191424
191680
|
if (!match2 || match2[1] !== image.mimeType)
|
|
@@ -191447,9 +191703,9 @@ async function resolveImage(image, fetchImpl, rules, signal) {
|
|
|
191447
191703
|
await response.body?.cancel();
|
|
191448
191704
|
imageError("IMAGE_MEDIA_INVALID");
|
|
191449
191705
|
}
|
|
191450
|
-
return validate(Buffer.from(await boundedBody(response,
|
|
191706
|
+
return validate(Buffer.from(await boundedBody(response, MAX_BYTES2)).toString("base64"), mediaType);
|
|
191451
191707
|
}
|
|
191452
|
-
var DEFAULT_IMAGE_URL_RULES,
|
|
191708
|
+
var DEFAULT_IMAGE_URL_RULES, MAX_BYTES2;
|
|
191453
191709
|
var init_io = __esm({
|
|
191454
191710
|
"../linkque-agent-runtime/dist/esm/impl/plugin/imageUnderstanding/io.js"() {
|
|
191455
191711
|
"use strict";
|
|
@@ -191457,7 +191713,7 @@ var init_io = __esm({
|
|
|
191457
191713
|
{ host: "mass.alipay.com", pathPrefix: "/linkque/afts/img/" },
|
|
191458
191714
|
{ host: "masspre.alipay.com", pathPrefix: "/linkque/afts/img/" }
|
|
191459
191715
|
];
|
|
191460
|
-
|
|
191716
|
+
MAX_BYTES2 = 2 * 1024 * 1024;
|
|
191461
191717
|
}
|
|
191462
191718
|
});
|
|
191463
191719
|
|
|
@@ -192038,6 +192294,61 @@ function failure(code, message, retryable) {
|
|
|
192038
192294
|
return { ok: false, error: { code, message, retryable } };
|
|
192039
192295
|
}
|
|
192040
192296
|
|
|
192297
|
+
// ../linkque-agent-runtime/dist/esm/core/cardActionDiagnostics.js
|
|
192298
|
+
init_types();
|
|
192299
|
+
var CardActionDiagnostics = class {
|
|
192300
|
+
sink;
|
|
192301
|
+
layer;
|
|
192302
|
+
stage = "validate";
|
|
192303
|
+
context;
|
|
192304
|
+
debugLog;
|
|
192305
|
+
startedAt = performance.now();
|
|
192306
|
+
constructor(sink, context2, layer = "runtime") {
|
|
192307
|
+
this.sink = sink;
|
|
192308
|
+
this.layer = layer;
|
|
192309
|
+
this.context = { ...context2 };
|
|
192310
|
+
if (sink) {
|
|
192311
|
+
this.debugLog = (line, scope) => {
|
|
192312
|
+
this.write("diagnostic", { message: line }, scope);
|
|
192313
|
+
};
|
|
192314
|
+
}
|
|
192315
|
+
}
|
|
192316
|
+
write(event, fields = {}, scope = EDebugLogScope.A2UI_ACTION) {
|
|
192317
|
+
if (!this.sink)
|
|
192318
|
+
return;
|
|
192319
|
+
try {
|
|
192320
|
+
const record3 = { ...this.context, ...fields };
|
|
192321
|
+
if (record3.message)
|
|
192322
|
+
record3.message = sanitizeDiagnosticText(record3.message);
|
|
192323
|
+
if (record3.errorName)
|
|
192324
|
+
record3.errorName = sanitizeDiagnosticText(record3.errorName);
|
|
192325
|
+
this.sink(JSON.stringify({
|
|
192326
|
+
operation: "a2uiAction.execute",
|
|
192327
|
+
layer: this.layer,
|
|
192328
|
+
event,
|
|
192329
|
+
stage: this.stage,
|
|
192330
|
+
...record3,
|
|
192331
|
+
costMs: Math.max(0, Math.round(performance.now() - this.startedAt))
|
|
192332
|
+
}), scope);
|
|
192333
|
+
} catch {
|
|
192334
|
+
}
|
|
192335
|
+
}
|
|
192336
|
+
error(event, error40) {
|
|
192337
|
+
if (!this.sink)
|
|
192338
|
+
return;
|
|
192339
|
+
try {
|
|
192340
|
+
this.write(event, {
|
|
192341
|
+
errorName: error40 instanceof Error ? error40.name : typeof error40,
|
|
192342
|
+
message: error40 instanceof Error ? error40.message : typeof error40 === "string" ? error40 : "\u975E\u6807\u51C6\u5F02\u5E38"
|
|
192343
|
+
});
|
|
192344
|
+
} catch {
|
|
192345
|
+
}
|
|
192346
|
+
}
|
|
192347
|
+
};
|
|
192348
|
+
function sanitizeDiagnosticText(value) {
|
|
192349
|
+
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);
|
|
192350
|
+
}
|
|
192351
|
+
|
|
192041
192352
|
// ../linkque-agent-runtime/dist/esm/core/cardActionExecutor.js
|
|
192042
192353
|
init_esm3();
|
|
192043
192354
|
init_esm2();
|
|
@@ -192045,12 +192356,33 @@ init_esm();
|
|
|
192045
192356
|
init_mcpAggregator();
|
|
192046
192357
|
init_mcpProxyTool();
|
|
192047
192358
|
async function executeCardAction(input) {
|
|
192359
|
+
const diagnostics = new CardActionDiagnostics(input.debugLog, {
|
|
192360
|
+
agentId: input.protocol.agentId,
|
|
192361
|
+
threadId: input.runtimeContext.threadId
|
|
192362
|
+
});
|
|
192363
|
+
diagnostics.write("started");
|
|
192364
|
+
try {
|
|
192365
|
+
const response = await executeCardActionInternal(input, diagnostics);
|
|
192366
|
+
diagnostics.write(response.ok ? "completed" : "failed", response.ok ? {} : { code: response.error.code, retryable: response.error.retryable });
|
|
192367
|
+
return response;
|
|
192368
|
+
} catch (error40) {
|
|
192369
|
+
diagnostics.error("failed", error40);
|
|
192370
|
+
throw error40;
|
|
192371
|
+
}
|
|
192372
|
+
}
|
|
192373
|
+
async function executeCardActionInternal(input, diagnostics) {
|
|
192048
192374
|
let request;
|
|
192049
192375
|
try {
|
|
192050
192376
|
request = parseA2UIActionExecuteRequest(input.request);
|
|
192051
192377
|
} catch (error40) {
|
|
192052
192378
|
return failure2("INVALID_INPUT", errorMessage(error40, "\u652F\u4ED8\u52A8\u4F5C\u8BF7\u6C42\u65E0\u6548"), false);
|
|
192053
192379
|
}
|
|
192380
|
+
Object.assign(diagnostics.context, {
|
|
192381
|
+
invocationId: request.invocationId,
|
|
192382
|
+
actionId: request.actionId,
|
|
192383
|
+
cardRef: request.source.cardRef,
|
|
192384
|
+
cardRevision: request.source.cardRevision
|
|
192385
|
+
});
|
|
192054
192386
|
if (request.agentId !== input.protocol.agentId) {
|
|
192055
192387
|
return failure2("AGENT_MISMATCH", "\u652F\u4ED8\u52A8\u4F5C\u4E0E\u5F53\u524D Agent \u4E0D\u5339\u914D", false);
|
|
192056
192388
|
}
|
|
@@ -192060,24 +192392,38 @@ async function executeCardAction(input) {
|
|
|
192060
192392
|
if (!input.runtimeContext.userId.trim()) {
|
|
192061
192393
|
return failure2("AUTH_REQUIRED", "\u652F\u4ED8\u52A8\u4F5C\u7F3A\u5C11\u53EF\u4FE1\u7528\u6237\u8EAB\u4EFD", false);
|
|
192062
192394
|
}
|
|
192395
|
+
diagnostics.write("validated");
|
|
192396
|
+
diagnostics.stage = "binding";
|
|
192063
192397
|
const resolved = resolvePaymentBinding(input.protocol, request.source, request.actionId);
|
|
192064
192398
|
if (!resolved.ok)
|
|
192065
192399
|
return resolved.response;
|
|
192066
|
-
|
|
192400
|
+
Object.assign(diagnostics.context, {
|
|
192401
|
+
mcpResourceId: resolved.binding.createTrade.mcpResourceId,
|
|
192402
|
+
toolName: resolved.binding.createTrade.toolName
|
|
192403
|
+
});
|
|
192404
|
+
diagnostics.write("binding_resolved");
|
|
192405
|
+
diagnostics.stage = "tool_resolve";
|
|
192406
|
+
const registry2 = createRegistry(input.protocol, input.mcpServerProvider, diagnostics.debugLog);
|
|
192067
192407
|
try {
|
|
192068
192408
|
const tool = await registry2.resolve(resolved.binding.createTrade.mcpResourceId, resolved.binding.createTrade.toolName, input.signal);
|
|
192069
192409
|
if (!tool) {
|
|
192070
192410
|
return failure2("TOOL_NOT_ALLOWED", "\u521B\u5EFA\u4EA4\u6613 MCP Tool \u4E0D\u5B58\u5728\u6216\u672A\u6388\u6743", false);
|
|
192071
192411
|
}
|
|
192412
|
+
diagnostics.stage = "tool_input";
|
|
192072
192413
|
const args = createToolInput(resolved.binding.createTrade.inputBindings, request.actionContext, input.runtimeContext);
|
|
192073
192414
|
if (!args)
|
|
192074
192415
|
return failure2("INVALID_INPUT", "\u65E0\u6CD5\u751F\u6210\u521B\u5EFA\u4EA4\u6613 MCP \u5165\u53C2", false);
|
|
192075
192416
|
let result;
|
|
192417
|
+
diagnostics.stage = "tool_execute";
|
|
192418
|
+
diagnostics.write("tool_started");
|
|
192076
192419
|
try {
|
|
192077
192420
|
result = await tool.execute(args, input.signal);
|
|
192078
|
-
|
|
192421
|
+
diagnostics.write("tool_completed");
|
|
192422
|
+
} catch (error40) {
|
|
192423
|
+
diagnostics.error("tool_failed", error40);
|
|
192079
192424
|
return failure2("EXECUTION_FAILED", "\u521B\u5EFA\u4EA4\u6613\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5", true);
|
|
192080
192425
|
}
|
|
192426
|
+
diagnostics.stage = "tool_output";
|
|
192081
192427
|
const structured = readStructuredContent3(result);
|
|
192082
192428
|
const tradeNO = readJsonPointer(structured, resolved.binding.createTrade.tradeNoPath);
|
|
192083
192429
|
if (typeof tradeNO !== "string" || !tradeNO.trim() || tradeNO.length > 64) {
|
|
@@ -192089,7 +192435,10 @@ async function executeCardAction(input) {
|
|
|
192089
192435
|
result: { kind: "payment", tradeNO }
|
|
192090
192436
|
};
|
|
192091
192437
|
} finally {
|
|
192438
|
+
const stage = diagnostics.stage;
|
|
192439
|
+
diagnostics.stage = "cleanup";
|
|
192092
192440
|
await registry2.closeAll();
|
|
192441
|
+
diagnostics.stage = stage;
|
|
192093
192442
|
}
|
|
192094
192443
|
}
|
|
192095
192444
|
function resolvePaymentBinding(protocol, source, actionId) {
|
|
@@ -192119,9 +192468,9 @@ function resolvePaymentBinding(protocol, source, actionId) {
|
|
|
192119
192468
|
}
|
|
192120
192469
|
return { ok: true, binding };
|
|
192121
192470
|
}
|
|
192122
|
-
function createRegistry(protocol, provider) {
|
|
192471
|
+
function createRegistry(protocol, provider, debugLog) {
|
|
192123
192472
|
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));
|
|
192473
|
+
return new McpProxyTool(provider, aggregateMcpServers(resources, protocol.agentId), { debugLog });
|
|
192125
192474
|
}
|
|
192126
192475
|
function createToolInput(bindings, actionContext, runtimeContext, tradeNO, callback) {
|
|
192127
192476
|
const result = {};
|
|
@@ -197362,6 +197711,8 @@ function applyArgsMappingRules(toolName, args, rules) {
|
|
|
197362
197711
|
init_esm();
|
|
197363
197712
|
|
|
197364
197713
|
// ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/remoteGatewayMcpServer.js
|
|
197714
|
+
init_types();
|
|
197715
|
+
init_logFailure();
|
|
197365
197716
|
var defaultCreateSigner = (config2, getAuthorizationHeader, debugLog) => new RemoteSignatureSigner({
|
|
197366
197717
|
agentId: config2.agentId,
|
|
197367
197718
|
signEndpoint: config2.signEndpoint,
|
|
@@ -197397,13 +197748,42 @@ var RemoteGatewayMcpServerProvider = class {
|
|
|
197397
197748
|
});
|
|
197398
197749
|
const serverName = resource.config.serverName ?? resource.resourceId;
|
|
197399
197750
|
const argsMappingRules = resource.config.argsMappingRules ?? [];
|
|
197751
|
+
let requestSequence = 0;
|
|
197752
|
+
const request = async (method, params, invoke) => {
|
|
197753
|
+
const requestId = ++requestSequence;
|
|
197754
|
+
const log = (phase, payload) => {
|
|
197755
|
+
if (!this.debugLog)
|
|
197756
|
+
return;
|
|
197757
|
+
try {
|
|
197758
|
+
this.debugLog(`[mcp-client] ${JSON.stringify({ serverName, resourceId: resource.resourceId, requestId, method, phase, payload })}`, EDebugLogScope.MCP);
|
|
197759
|
+
} catch (error40) {
|
|
197760
|
+
warnLogFailure("remoteGatewayMcpServer.log", error40);
|
|
197761
|
+
}
|
|
197762
|
+
};
|
|
197763
|
+
log("request", params);
|
|
197764
|
+
try {
|
|
197765
|
+
const result = await invoke();
|
|
197766
|
+
log("response", result);
|
|
197767
|
+
return result;
|
|
197768
|
+
} catch (error40) {
|
|
197769
|
+
log("error", error40 instanceof Error ? { name: error40.name, message: error40.message } : error40);
|
|
197770
|
+
throw error40;
|
|
197771
|
+
}
|
|
197772
|
+
};
|
|
197773
|
+
const loggedClient = {
|
|
197774
|
+
listTools: () => request("tools/list", {}, () => client.listTools()),
|
|
197775
|
+
callTool: (params) => request("tools/call", params, () => client.callTool(params))
|
|
197776
|
+
};
|
|
197400
197777
|
return {
|
|
197401
197778
|
resourceId: resource.resourceId,
|
|
197402
197779
|
serverName,
|
|
197403
|
-
listTools: () => listToolsFromClient(
|
|
197780
|
+
listTools: () => listToolsFromClient(loggedClient, resource.resourceId),
|
|
197404
197781
|
callTool: (name, args) => {
|
|
197405
197782
|
const mapped = applyArgsMappingRules(name, args, argsMappingRules);
|
|
197406
|
-
return
|
|
197783
|
+
return loggedClient.callTool({
|
|
197784
|
+
name,
|
|
197785
|
+
arguments: mapped ?? {}
|
|
197786
|
+
});
|
|
197407
197787
|
},
|
|
197408
197788
|
close: async () => {
|
|
197409
197789
|
try {
|
|
@@ -198359,8 +198739,8 @@ var WebSkillLoader = class {
|
|
|
198359
198739
|
return (0, import_promises.readFile)(import_node_path.default.join(candidate, "SKILL.md"), "utf8");
|
|
198360
198740
|
}
|
|
198361
198741
|
if (isZipPath(candidate)) {
|
|
198362
|
-
const
|
|
198363
|
-
const files = await unzipBytes(
|
|
198742
|
+
const bytes2 = new Uint8Array(await (0, import_promises.readFile)(candidate));
|
|
198743
|
+
const files = await unzipBytes(bytes2, resourceId);
|
|
198364
198744
|
const body = extractSkillMarkdown(files);
|
|
198365
198745
|
if (body === void 0) {
|
|
198366
198746
|
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 +198783,7 @@ var extractSkillMarkdown = (files) => {
|
|
|
198403
198783
|
const rootMd = paths.find((p) => p.endsWith(".md") && !p.includes("/"));
|
|
198404
198784
|
return rootMd === void 0 ? void 0 : decodeUtf8(files[rootMd]);
|
|
198405
198785
|
};
|
|
198406
|
-
var decodeUtf8 = (
|
|
198786
|
+
var decodeUtf8 = (bytes2) => new TextDecoder("utf-8", { fatal: true }).decode(bytes2);
|
|
198407
198787
|
var globalFetch = (url2) => fetch(url2);
|
|
198408
198788
|
var detectScheme = (url2) => {
|
|
198409
198789
|
if (/^https:\/\//i.test(url2))
|
|
@@ -198907,7 +199287,7 @@ var handleHomeData = async (req, res, input) => {
|
|
|
198907
199287
|
);
|
|
198908
199288
|
}
|
|
198909
199289
|
};
|
|
198910
|
-
var handleA2UIAction = async (req, res, input) => {
|
|
199290
|
+
var handleA2UIAction = async (req, res, input, debugLog) => {
|
|
198911
199291
|
if (!executeCardAction2 || !createMcpServerProvider) {
|
|
198912
199292
|
writeJsonError2(res, 500, "AGENTDEV_NOT_READY", "agent runtime not loaded");
|
|
198913
199293
|
return;
|
|
@@ -198931,7 +199311,8 @@ var handleA2UIAction = async (req, res, input) => {
|
|
|
198931
199311
|
userId: proxyInput.userId,
|
|
198932
199312
|
...proxyInput.tenantId ? { tenantId: proxyInput.tenantId } : {}
|
|
198933
199313
|
},
|
|
198934
|
-
mcpServerProvider: createMcpServerProvider(protocol)
|
|
199314
|
+
mcpServerProvider: createMcpServerProvider(protocol),
|
|
199315
|
+
debugLog
|
|
198935
199316
|
});
|
|
198936
199317
|
res.writeHead(200, { "content-type": "application/json; charset=utf-8" });
|
|
198937
199318
|
res.end(JSON.stringify(result));
|
|
@@ -199109,7 +199490,7 @@ var main = async () => {
|
|
|
199109
199490
|
return;
|
|
199110
199491
|
}
|
|
199111
199492
|
if (req.method === "POST" && pathname === input.a2uiActionPath) {
|
|
199112
|
-
void handleA2UIAction(req, res, input);
|
|
199493
|
+
void handleA2UIAction(req, res, input, debugLog);
|
|
199113
199494
|
return;
|
|
199114
199495
|
}
|
|
199115
199496
|
const cancelMatch = pathname.match(
|