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/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-DCQYAWC6.js → chunk-MLVSBCIT.js}
RENAMED
|
@@ -8846,6 +8846,7 @@ var EHookStage;
|
|
|
8846
8846
|
EHookStage2["RUN_FAILED"] = "RUN_FAILED";
|
|
8847
8847
|
EHookStage2["RUN_READ"] = "RUN_READ";
|
|
8848
8848
|
EHookStage2["AFTER_MODEL_CALL"] = "AFTER_MODEL_CALL";
|
|
8849
|
+
EHookStage2["MODEL_RESPONSE_RECEIVED"] = "MODEL_RESPONSE_RECEIVED";
|
|
8849
8850
|
EHookStage2["BEFORE_TOOL_CALL"] = "BEFORE_TOOL_CALL";
|
|
8850
8851
|
EHookStage2["AFTER_TOOL_CALL"] = "AFTER_TOOL_CALL";
|
|
8851
8852
|
EHookStage2["TOOL_CALL_FAILED"] = "TOOL_CALL_FAILED";
|
|
@@ -8993,6 +8994,8 @@ var ALLOWED_AST_TYPES = /* @__PURE__ */ new Set([
|
|
|
8993
8994
|
"Field",
|
|
8994
8995
|
"Function",
|
|
8995
8996
|
"Identity",
|
|
8997
|
+
"Index",
|
|
8998
|
+
"IndexExpression",
|
|
8996
8999
|
"KeyValuePair",
|
|
8997
9000
|
"Literal",
|
|
8998
9001
|
"MultiSelectHash",
|
|
@@ -9064,6 +9067,9 @@ function validateAst(ast) {
|
|
|
9064
9067
|
if (!ALLOWED_AST_TYPES.has(value.type)) {
|
|
9065
9068
|
throw new StructuralExpressionError("STRUCTURAL_EXPRESSION_NODE_FORBIDDEN", `JMESPath node ${value.type} is not allowed`);
|
|
9066
9069
|
}
|
|
9070
|
+
if (value.type === "Index" && (typeof value.value !== "number" || !Number.isSafeInteger(value.value) || value.value < 0)) {
|
|
9071
|
+
throw new StructuralExpressionError("STRUCTURAL_EXPRESSION_INVALID", "array index must be a non-negative safe integer");
|
|
9072
|
+
}
|
|
9067
9073
|
if (value.type === "Function" && value.name !== "not_null") {
|
|
9068
9074
|
throw new StructuralExpressionError("STRUCTURAL_EXPRESSION_FUNCTION_FORBIDDEN", `JMESPath function ${String(value.name)} is not allowed`);
|
|
9069
9075
|
}
|
|
@@ -9851,6 +9857,8 @@ var ALLOWED_AST_TYPES2 = /* @__PURE__ */ new Set([
|
|
|
9851
9857
|
"Field",
|
|
9852
9858
|
"Function",
|
|
9853
9859
|
"Identity",
|
|
9860
|
+
"Index",
|
|
9861
|
+
"IndexExpression",
|
|
9854
9862
|
"KeyValuePair",
|
|
9855
9863
|
"Literal",
|
|
9856
9864
|
"MultiSelectHash",
|
|
@@ -9943,6 +9951,9 @@ function validateAst2(ast) {
|
|
|
9943
9951
|
if (!ALLOWED_AST_TYPES2.has(value.type)) {
|
|
9944
9952
|
throw new A2UICardExpressionError("CARD_EXPRESSION_NODE_FORBIDDEN", `JMESPath node ${value.type} is not allowed by ${A2UI_CARD_TRANSFORM_PROFILE}`);
|
|
9945
9953
|
}
|
|
9954
|
+
if (value.type === "Index" && (typeof value.value !== "number" || !Number.isSafeInteger(value.value) || value.value < 0)) {
|
|
9955
|
+
throw new A2UICardExpressionError("CARD_EXPRESSION_INVALID", "array index must be a non-negative safe integer");
|
|
9956
|
+
}
|
|
9946
9957
|
if (value.type === "Function" && value.name !== "not_null") {
|
|
9947
9958
|
throw new A2UICardExpressionError("CARD_EXPRESSION_FUNCTION_FORBIDDEN", `JMESPath function ${String(value.name)} is not allowed`);
|
|
9948
9959
|
}
|
|
@@ -9961,7 +9972,6 @@ var colors = [
|
|
|
9961
9972
|
"default",
|
|
9962
9973
|
"muted",
|
|
9963
9974
|
"primary",
|
|
9964
|
-
"accent",
|
|
9965
9975
|
"success",
|
|
9966
9976
|
"warning",
|
|
9967
9977
|
"error",
|
|
@@ -10013,8 +10023,18 @@ var iconNames = [
|
|
|
10013
10023
|
"warning",
|
|
10014
10024
|
"arrow-right-long"
|
|
10015
10025
|
];
|
|
10016
|
-
var
|
|
10017
|
-
|
|
10026
|
+
var layoutItem = {
|
|
10027
|
+
grow: {
|
|
10028
|
+
kind: "number",
|
|
10029
|
+
values: [0, 1, 2, 3, 4],
|
|
10030
|
+
parentComponents: ["Row", "Column"]
|
|
10031
|
+
}
|
|
10032
|
+
};
|
|
10033
|
+
var width = { width: { kind: "string", values: ["fit", "fill"] } };
|
|
10034
|
+
var radius = {
|
|
10035
|
+
radius: { kind: "string", values: ["none", "xs", "sm", "md", "full"] }
|
|
10036
|
+
};
|
|
10037
|
+
var decoration = {
|
|
10018
10038
|
padding: { kind: "string", values: spacing },
|
|
10019
10039
|
background: {
|
|
10020
10040
|
kind: "string",
|
|
@@ -10032,29 +10052,17 @@ var box = {
|
|
|
10032
10052
|
kind: "string",
|
|
10033
10053
|
values: ["none", "subtle", "card-border", "primary"]
|
|
10034
10054
|
},
|
|
10035
|
-
radius
|
|
10036
|
-
width: { kind: "string", values: ["fit", "fill"] },
|
|
10037
|
-
grow: { kind: "number", values: [0, 1, 2, 3, 4] },
|
|
10038
|
-
shrink: { kind: "boolean" }
|
|
10055
|
+
...radius
|
|
10039
10056
|
};
|
|
10040
10057
|
var typography = {
|
|
10041
10058
|
color: { kind: "string", values: colors },
|
|
10042
|
-
fontSize: {
|
|
10043
|
-
kind: "string",
|
|
10044
|
-
values: [
|
|
10045
|
-
"small",
|
|
10046
|
-
"medium",
|
|
10047
|
-
"large",
|
|
10048
|
-
"striking",
|
|
10049
|
-
"display",
|
|
10050
|
-
"badge",
|
|
10051
|
-
"merchant"
|
|
10052
|
-
]
|
|
10053
|
-
},
|
|
10059
|
+
fontSize: { kind: "string", values: ["xs", "sm", "md", "lg", "xl", "xxl"] },
|
|
10054
10060
|
fontWeight: { kind: "string", values: ["normal", "semibold", "bold"] }
|
|
10055
10061
|
};
|
|
10056
10062
|
var container = {
|
|
10057
|
-
...
|
|
10063
|
+
...layoutItem,
|
|
10064
|
+
...width,
|
|
10065
|
+
padding: { kind: "string", values: spacing },
|
|
10058
10066
|
children: { kind: "children", required: true },
|
|
10059
10067
|
gap: { kind: "string", values: spacing },
|
|
10060
10068
|
align: {
|
|
@@ -10074,6 +10082,7 @@ var container = {
|
|
|
10074
10082
|
},
|
|
10075
10083
|
"x2-overflow": { kind: "format" }
|
|
10076
10084
|
};
|
|
10085
|
+
var { justify: _listJustify, ...listContainer } = container;
|
|
10077
10086
|
var A2UI_V4_COMPONENT_CATALOG = Object.freeze({
|
|
10078
10087
|
catalogId: LINKQUE_A2UI_V4_CATALOG_ID,
|
|
10079
10088
|
protocolVersion: "0.9",
|
|
@@ -10081,7 +10090,10 @@ var A2UI_V4_COMPONENT_CATALOG = Object.freeze({
|
|
|
10081
10090
|
Card: {
|
|
10082
10091
|
interaction: "action",
|
|
10083
10092
|
properties: {
|
|
10084
|
-
...
|
|
10093
|
+
...layoutItem,
|
|
10094
|
+
...width,
|
|
10095
|
+
...decoration,
|
|
10096
|
+
child: { kind: "child", required: true },
|
|
10085
10097
|
action: { kind: "action" },
|
|
10086
10098
|
disabled: { kind: "boolean" }
|
|
10087
10099
|
}
|
|
@@ -10097,7 +10109,7 @@ var A2UI_V4_COMPONENT_CATALOG = Object.freeze({
|
|
|
10097
10109
|
List: {
|
|
10098
10110
|
interaction: "none",
|
|
10099
10111
|
properties: {
|
|
10100
|
-
...
|
|
10112
|
+
...listContainer,
|
|
10101
10113
|
variant: {
|
|
10102
10114
|
kind: "string",
|
|
10103
10115
|
required: true,
|
|
@@ -10108,8 +10120,9 @@ var A2UI_V4_COMPONENT_CATALOG = Object.freeze({
|
|
|
10108
10120
|
Text: {
|
|
10109
10121
|
interaction: "none",
|
|
10110
10122
|
properties: {
|
|
10111
|
-
...
|
|
10123
|
+
...layoutItem,
|
|
10112
10124
|
...typography,
|
|
10125
|
+
shrink: { kind: "boolean" },
|
|
10113
10126
|
text: { kind: "binding", required: true },
|
|
10114
10127
|
maxLines: { kind: "number", values: [0, 1, 2, 3, 4, 5, 6] },
|
|
10115
10128
|
decoration: { kind: "string", values: ["line-through"] },
|
|
@@ -10119,19 +10132,31 @@ var A2UI_V4_COMPONENT_CATALOG = Object.freeze({
|
|
|
10119
10132
|
Tag: {
|
|
10120
10133
|
interaction: "none",
|
|
10121
10134
|
properties: {
|
|
10122
|
-
...
|
|
10123
|
-
...typography,
|
|
10135
|
+
...layoutItem,
|
|
10124
10136
|
text: { kind: "binding", required: true },
|
|
10125
10137
|
icon: { kind: "string", values: iconNames },
|
|
10126
|
-
|
|
10127
|
-
|
|
10128
|
-
|
|
10138
|
+
tone: {
|
|
10139
|
+
kind: "string",
|
|
10140
|
+
values: [
|
|
10141
|
+
"default",
|
|
10142
|
+
"muted",
|
|
10143
|
+
"primary",
|
|
10144
|
+
"success",
|
|
10145
|
+
"warning",
|
|
10146
|
+
"error"
|
|
10147
|
+
]
|
|
10148
|
+
},
|
|
10149
|
+
variant: { kind: "string", values: ["soft", "outline", "plain"] },
|
|
10150
|
+
size: { kind: "string", values: ["sm", "md"] },
|
|
10151
|
+
shrink: { kind: "boolean" },
|
|
10152
|
+
maxLines: { kind: "number", values: [0, 1, 2, 3, 4, 5, 6] }
|
|
10129
10153
|
}
|
|
10130
10154
|
},
|
|
10131
10155
|
Button: {
|
|
10132
10156
|
interaction: "action",
|
|
10133
10157
|
properties: {
|
|
10134
|
-
...
|
|
10158
|
+
...layoutItem,
|
|
10159
|
+
...width,
|
|
10135
10160
|
label: { kind: "binding", required: true },
|
|
10136
10161
|
action: { kind: "action", required: true },
|
|
10137
10162
|
checks: { kind: "format" },
|
|
@@ -10149,34 +10174,29 @@ var A2UI_V4_COMPONENT_CATALOG = Object.freeze({
|
|
|
10149
10174
|
Image: {
|
|
10150
10175
|
interaction: "none",
|
|
10151
10176
|
properties: {
|
|
10152
|
-
...
|
|
10177
|
+
...layoutItem,
|
|
10178
|
+
...radius,
|
|
10153
10179
|
src: { kind: "binding", required: true },
|
|
10154
10180
|
alt: { kind: "binding" },
|
|
10155
10181
|
fit: {
|
|
10156
10182
|
kind: "string",
|
|
10157
10183
|
values: ["contain", "cover", "fill", "none", "scale-down"]
|
|
10158
10184
|
},
|
|
10159
|
-
|
|
10185
|
+
aspectRatio: {
|
|
10160
10186
|
kind: "string",
|
|
10161
|
-
values: [
|
|
10162
|
-
|
|
10163
|
-
|
|
10164
|
-
|
|
10165
|
-
|
|
10166
|
-
|
|
10167
|
-
"portraitFeature",
|
|
10168
|
-
"productThumbnail",
|
|
10169
|
-
"voucherThumbnail",
|
|
10170
|
-
"largeFeature",
|
|
10171
|
-
"header"
|
|
10172
|
-
]
|
|
10187
|
+
values: ["square", "portrait", "landscape", "wide", "banner"]
|
|
10188
|
+
},
|
|
10189
|
+
height: { kind: "string", values: ["auto", "fill"] },
|
|
10190
|
+
size: {
|
|
10191
|
+
kind: "string",
|
|
10192
|
+
values: ["xs", "sm", "md", "lg", "xl", "full"]
|
|
10173
10193
|
}
|
|
10174
10194
|
}
|
|
10175
10195
|
},
|
|
10176
10196
|
Icon: {
|
|
10177
10197
|
interaction: "none",
|
|
10178
10198
|
properties: {
|
|
10179
|
-
...
|
|
10199
|
+
...layoutItem,
|
|
10180
10200
|
name: { kind: "string", required: true, values: iconNames },
|
|
10181
10201
|
label: { kind: "string" },
|
|
10182
10202
|
color: { kind: "string", values: colors },
|
|
@@ -10189,15 +10209,15 @@ var A2UI_V4_COMPONENT_CATALOG = Object.freeze({
|
|
|
10189
10209
|
Divider: {
|
|
10190
10210
|
interaction: "none",
|
|
10191
10211
|
properties: {
|
|
10192
|
-
...
|
|
10212
|
+
...layoutItem,
|
|
10193
10213
|
axis: { kind: "string", values: ["horizontal", "vertical"] }
|
|
10194
10214
|
}
|
|
10195
10215
|
},
|
|
10196
10216
|
TextField: {
|
|
10197
10217
|
interaction: "input",
|
|
10198
10218
|
properties: {
|
|
10199
|
-
...
|
|
10200
|
-
...
|
|
10219
|
+
...layoutItem,
|
|
10220
|
+
...width,
|
|
10201
10221
|
label: { kind: "string", required: true },
|
|
10202
10222
|
value: { kind: "binding", required: true },
|
|
10203
10223
|
checks: { kind: "format" },
|
|
@@ -10221,7 +10241,8 @@ var A2UI_V4_COMPONENT_CATALOG = Object.freeze({
|
|
|
10221
10241
|
ChoicePicker: {
|
|
10222
10242
|
interaction: "input",
|
|
10223
10243
|
properties: {
|
|
10224
|
-
...
|
|
10244
|
+
...layoutItem,
|
|
10245
|
+
...width,
|
|
10225
10246
|
label: { kind: "string", required: true },
|
|
10226
10247
|
value: { kind: "binding", required: true },
|
|
10227
10248
|
options: { kind: "options", required: true },
|
|
@@ -10236,7 +10257,8 @@ var A2UI_V4_COMPONENT_CATALOG = Object.freeze({
|
|
|
10236
10257
|
Stepper: {
|
|
10237
10258
|
interaction: "input",
|
|
10238
10259
|
properties: {
|
|
10239
|
-
...
|
|
10260
|
+
...layoutItem,
|
|
10261
|
+
...width,
|
|
10240
10262
|
label: { kind: "string", required: true },
|
|
10241
10263
|
value: { kind: "binding", required: true },
|
|
10242
10264
|
min: { kind: "number" },
|
|
@@ -10352,8 +10374,6 @@ function validateComponents(payload, path2, surfaces, issues) {
|
|
|
10352
10374
|
if (value !== void 0)
|
|
10353
10375
|
validateProperty(value, property, `${componentPath}.${name}`, issues, name);
|
|
10354
10376
|
}
|
|
10355
|
-
if (component.component === "Tag" && component.icon === void 0 && component.gap !== void 0)
|
|
10356
|
-
issues.push(issue2(`${componentPath}.gap`, "TAG_GAP_REQUIRES_ICON", "Tag.gap requires Tag.icon"));
|
|
10357
10377
|
if (component["x2-overflow"] !== void 0)
|
|
10358
10378
|
validateOverflow(component, componentPath, issues);
|
|
10359
10379
|
if (component.component === "TextField")
|
|
@@ -10367,7 +10387,7 @@ function validateComponents(payload, path2, surfaces, issues) {
|
|
|
10367
10387
|
validateStepper(component, componentPath, issues);
|
|
10368
10388
|
if (component.checks !== void 0)
|
|
10369
10389
|
validateChecks(component.checks, `${componentPath}.checks`, issues);
|
|
10370
|
-
if (component.format !== void 0 &&
|
|
10390
|
+
if (component.format !== void 0 && component.component === "Text")
|
|
10371
10391
|
validateNumberFormat(component.format, `${componentPath}.format`, issues);
|
|
10372
10392
|
if (component.action !== void 0)
|
|
10373
10393
|
validateAction(component.action, `${componentPath}.action`, issues, 0);
|
|
@@ -10381,6 +10401,11 @@ function validateProperty(value, schema, path2, issues, propertyName) {
|
|
|
10381
10401
|
issues.push(issue2(path2, "INVALID_DISPLAY_VALUE", `display value must be ${stringOnly ? "a string" : "a string or finite number"}, or a compatible display binding`));
|
|
10382
10402
|
return;
|
|
10383
10403
|
}
|
|
10404
|
+
if (schema.kind === "child") {
|
|
10405
|
+
if (!isSafeIdentifier(value))
|
|
10406
|
+
issues.push(issue2(path2, "INVALID_CHILD", "child must be a safe component id"));
|
|
10407
|
+
return;
|
|
10408
|
+
}
|
|
10384
10409
|
if (schema.kind === "children") {
|
|
10385
10410
|
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);
|
|
10386
10411
|
if (!valid)
|
|
@@ -10621,20 +10646,27 @@ function validateReferences(surfaces, path2, issues) {
|
|
|
10621
10646
|
issues.push(issue2(`${path2}.surfaces.${surfaceId}`, "MISSING_ROOT_COMPONENT", "surface must define root"));
|
|
10622
10647
|
const edges = /* @__PURE__ */ new Map();
|
|
10623
10648
|
for (const [id, component] of components) {
|
|
10624
|
-
const
|
|
10625
|
-
const refs = Array.isArray(children) ? children.filter((entry) => typeof entry === "string") : isPlainRecord(children) && typeof children.componentId === "string" ? [children.componentId] : [];
|
|
10649
|
+
const refs = getComponentReferences(component);
|
|
10626
10650
|
edges.set(id, refs);
|
|
10627
10651
|
refs.forEach((ref) => {
|
|
10628
10652
|
if (!components.has(ref))
|
|
10629
|
-
issues.push(issue2(`${path2}.surfaces.${surfaceId}.components.${id}.children`, "MISSING_COMPONENT_REFERENCE", `component ${ref} does not exist`));
|
|
10653
|
+
issues.push(issue2(`${path2}.surfaces.${surfaceId}.components.${id}.${component.child !== void 0 ? "child" : "children"}`, "MISSING_COMPONENT_REFERENCE", `component ${ref} does not exist`));
|
|
10630
10654
|
});
|
|
10631
10655
|
if ((component.component === "Button" || component.component === "Card" && component.action !== void 0) && refs.some((ref) => hasInteractiveDescendant(ref, components, /* @__PURE__ */ new Set())))
|
|
10632
|
-
issues.push(issue2(`${path2}.surfaces.${surfaceId}.components.${id}.children`, "NESTED_INTERACTION", "action components cannot contain interactive descendants"));
|
|
10656
|
+
issues.push(issue2(`${path2}.surfaces.${surfaceId}.components.${id}.${component.child !== void 0 ? "child" : "children"}`, "NESTED_INTERACTION", "action components cannot contain interactive descendants"));
|
|
10633
10657
|
collectSurfaceOpenReferences(component.action).forEach((targetSurfaceId) => {
|
|
10634
10658
|
if (!surfaces.has(targetSurfaceId))
|
|
10635
10659
|
issues.push(issue2(`${path2}.surfaces.${surfaceId}.components.${id}.action`, "MISSING_SURFACE_REFERENCE", `surface ${targetSurfaceId} does not exist`));
|
|
10636
10660
|
});
|
|
10637
10661
|
}
|
|
10662
|
+
components.forEach((component, id) => {
|
|
10663
|
+
if (component.grow === void 0)
|
|
10664
|
+
return;
|
|
10665
|
+
const parents = [...components.values()].filter((parent) => getComponentReferences(parent).includes(id));
|
|
10666
|
+
if (id === "root" || parents.length === 0 || parents.some((parent) => parent.component !== "Row" && parent.component !== "Column")) {
|
|
10667
|
+
issues.push(issue2(`${path2}.surfaces.${surfaceId}.components.${id}.grow`, "INVALID_LAYOUT_PARENT", "grow requires a direct Row or Column parent in every occurrence"));
|
|
10668
|
+
}
|
|
10669
|
+
});
|
|
10638
10670
|
const visiting = /* @__PURE__ */ new Set();
|
|
10639
10671
|
const visited = /* @__PURE__ */ new Set();
|
|
10640
10672
|
const walk = (id) => {
|
|
@@ -10665,6 +10697,14 @@ function collectSurfaceOpenReferences(value, result = /* @__PURE__ */ new Set())
|
|
|
10665
10697
|
}
|
|
10666
10698
|
return result;
|
|
10667
10699
|
}
|
|
10700
|
+
function getComponentReferences(component) {
|
|
10701
|
+
if (typeof component.child === "string")
|
|
10702
|
+
return [component.child];
|
|
10703
|
+
const children = component.children;
|
|
10704
|
+
if (Array.isArray(children))
|
|
10705
|
+
return children.filter((entry) => typeof entry === "string");
|
|
10706
|
+
return isPlainRecord(children) && typeof children.componentId === "string" ? [children.componentId] : [];
|
|
10707
|
+
}
|
|
10668
10708
|
function hasInteractiveDescendant(id, components, visited) {
|
|
10669
10709
|
if (visited.has(id))
|
|
10670
10710
|
return false;
|
|
@@ -10674,8 +10714,7 @@ function hasInteractiveDescendant(id, components, visited) {
|
|
|
10674
10714
|
return false;
|
|
10675
10715
|
if (component.component === "Button" || component.action !== void 0 || ["TextField", "ChoicePicker", "Stepper"].includes(String(component.component)))
|
|
10676
10716
|
return true;
|
|
10677
|
-
const
|
|
10678
|
-
const refs = Array.isArray(children) ? children : isPlainRecord(children) ? [children.componentId] : [];
|
|
10717
|
+
const refs = getComponentReferences(component);
|
|
10679
10718
|
return refs.some((ref) => typeof ref === "string" && hasInteractiveDescendant(ref, components, visited));
|
|
10680
10719
|
}
|
|
10681
10720
|
|
|
@@ -11669,6 +11708,7 @@ function aggregateMcpServers(resources, protocolAgentId) {
|
|
|
11669
11708
|
// ../linkque-agent-runtime/dist/esm/core/types.js
|
|
11670
11709
|
var EDebugLogScope;
|
|
11671
11710
|
(function(EDebugLogScope2) {
|
|
11711
|
+
EDebugLogScope2["A2UI_ACTION"] = "A2UI_ACTION";
|
|
11672
11712
|
EDebugLogScope2["CONFIG"] = "CONFIG";
|
|
11673
11713
|
EDebugLogScope2["LLM"] = "LLM";
|
|
11674
11714
|
EDebugLogScope2["PI_EVENT"] = "PI_EVENT";
|
|
@@ -11736,7 +11776,11 @@ var McpProxyTool = class {
|
|
|
11736
11776
|
return;
|
|
11737
11777
|
try {
|
|
11738
11778
|
await entry.server.close?.();
|
|
11739
|
-
} catch {
|
|
11779
|
+
} catch (error) {
|
|
11780
|
+
try {
|
|
11781
|
+
this.debugLog(`[mcp] server ${entry.server.serverName} close failed: ${error instanceof Error ? error.message : "unknown error"}`, EDebugLogScope.MCP);
|
|
11782
|
+
} catch {
|
|
11783
|
+
}
|
|
11740
11784
|
}
|
|
11741
11785
|
}));
|
|
11742
11786
|
}
|
|
@@ -12114,14 +12158,89 @@ var MCP_PROXY_INPUT_SCHEMA = {
|
|
|
12114
12158
|
}
|
|
12115
12159
|
};
|
|
12116
12160
|
|
|
12161
|
+
// ../linkque-agent-runtime/dist/esm/core/cardActionDiagnostics.js
|
|
12162
|
+
var CardActionDiagnostics = class {
|
|
12163
|
+
sink;
|
|
12164
|
+
layer;
|
|
12165
|
+
stage = "validate";
|
|
12166
|
+
context;
|
|
12167
|
+
debugLog;
|
|
12168
|
+
startedAt = performance.now();
|
|
12169
|
+
constructor(sink, context, layer = "runtime") {
|
|
12170
|
+
this.sink = sink;
|
|
12171
|
+
this.layer = layer;
|
|
12172
|
+
this.context = { ...context };
|
|
12173
|
+
if (sink) {
|
|
12174
|
+
this.debugLog = (line, scope) => {
|
|
12175
|
+
this.write("diagnostic", { message: line }, scope);
|
|
12176
|
+
};
|
|
12177
|
+
}
|
|
12178
|
+
}
|
|
12179
|
+
write(event, fields = {}, scope = EDebugLogScope.A2UI_ACTION) {
|
|
12180
|
+
if (!this.sink)
|
|
12181
|
+
return;
|
|
12182
|
+
try {
|
|
12183
|
+
const record2 = { ...this.context, ...fields };
|
|
12184
|
+
if (record2.message)
|
|
12185
|
+
record2.message = sanitizeDiagnosticText(record2.message);
|
|
12186
|
+
if (record2.errorName)
|
|
12187
|
+
record2.errorName = sanitizeDiagnosticText(record2.errorName);
|
|
12188
|
+
this.sink(JSON.stringify({
|
|
12189
|
+
operation: "a2uiAction.execute",
|
|
12190
|
+
layer: this.layer,
|
|
12191
|
+
event,
|
|
12192
|
+
stage: this.stage,
|
|
12193
|
+
...record2,
|
|
12194
|
+
costMs: Math.max(0, Math.round(performance.now() - this.startedAt))
|
|
12195
|
+
}), scope);
|
|
12196
|
+
} catch {
|
|
12197
|
+
}
|
|
12198
|
+
}
|
|
12199
|
+
error(event, error) {
|
|
12200
|
+
if (!this.sink)
|
|
12201
|
+
return;
|
|
12202
|
+
try {
|
|
12203
|
+
this.write(event, {
|
|
12204
|
+
errorName: error instanceof Error ? error.name : typeof error,
|
|
12205
|
+
message: error instanceof Error ? error.message : typeof error === "string" ? error : "\u975E\u6807\u51C6\u5F02\u5E38"
|
|
12206
|
+
});
|
|
12207
|
+
} catch {
|
|
12208
|
+
}
|
|
12209
|
+
}
|
|
12210
|
+
};
|
|
12211
|
+
function sanitizeDiagnosticText(value) {
|
|
12212
|
+
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);
|
|
12213
|
+
}
|
|
12214
|
+
|
|
12117
12215
|
// ../linkque-agent-runtime/dist/esm/core/cardActionExecutor.js
|
|
12118
12216
|
async function executeCardAction(input) {
|
|
12217
|
+
const diagnostics = new CardActionDiagnostics(input.debugLog, {
|
|
12218
|
+
agentId: input.protocol.agentId,
|
|
12219
|
+
threadId: input.runtimeContext.threadId
|
|
12220
|
+
});
|
|
12221
|
+
diagnostics.write("started");
|
|
12222
|
+
try {
|
|
12223
|
+
const response = await executeCardActionInternal(input, diagnostics);
|
|
12224
|
+
diagnostics.write(response.ok ? "completed" : "failed", response.ok ? {} : { code: response.error.code, retryable: response.error.retryable });
|
|
12225
|
+
return response;
|
|
12226
|
+
} catch (error) {
|
|
12227
|
+
diagnostics.error("failed", error);
|
|
12228
|
+
throw error;
|
|
12229
|
+
}
|
|
12230
|
+
}
|
|
12231
|
+
async function executeCardActionInternal(input, diagnostics) {
|
|
12119
12232
|
let request;
|
|
12120
12233
|
try {
|
|
12121
12234
|
request = parseA2UIActionExecuteRequest(input.request);
|
|
12122
12235
|
} catch (error) {
|
|
12123
12236
|
return failure("INVALID_INPUT", errorMessage(error, "\u652F\u4ED8\u52A8\u4F5C\u8BF7\u6C42\u65E0\u6548"), false);
|
|
12124
12237
|
}
|
|
12238
|
+
Object.assign(diagnostics.context, {
|
|
12239
|
+
invocationId: request.invocationId,
|
|
12240
|
+
actionId: request.actionId,
|
|
12241
|
+
cardRef: request.source.cardRef,
|
|
12242
|
+
cardRevision: request.source.cardRevision
|
|
12243
|
+
});
|
|
12125
12244
|
if (request.agentId !== input.protocol.agentId) {
|
|
12126
12245
|
return failure("AGENT_MISMATCH", "\u652F\u4ED8\u52A8\u4F5C\u4E0E\u5F53\u524D Agent \u4E0D\u5339\u914D", false);
|
|
12127
12246
|
}
|
|
@@ -12131,24 +12250,38 @@ async function executeCardAction(input) {
|
|
|
12131
12250
|
if (!input.runtimeContext.userId.trim()) {
|
|
12132
12251
|
return failure("AUTH_REQUIRED", "\u652F\u4ED8\u52A8\u4F5C\u7F3A\u5C11\u53EF\u4FE1\u7528\u6237\u8EAB\u4EFD", false);
|
|
12133
12252
|
}
|
|
12253
|
+
diagnostics.write("validated");
|
|
12254
|
+
diagnostics.stage = "binding";
|
|
12134
12255
|
const resolved = resolvePaymentBinding(input.protocol, request.source, request.actionId);
|
|
12135
12256
|
if (!resolved.ok)
|
|
12136
12257
|
return resolved.response;
|
|
12137
|
-
|
|
12258
|
+
Object.assign(diagnostics.context, {
|
|
12259
|
+
mcpResourceId: resolved.binding.createTrade.mcpResourceId,
|
|
12260
|
+
toolName: resolved.binding.createTrade.toolName
|
|
12261
|
+
});
|
|
12262
|
+
diagnostics.write("binding_resolved");
|
|
12263
|
+
diagnostics.stage = "tool_resolve";
|
|
12264
|
+
const registry = createRegistry(input.protocol, input.mcpServerProvider, diagnostics.debugLog);
|
|
12138
12265
|
try {
|
|
12139
12266
|
const tool = await registry.resolve(resolved.binding.createTrade.mcpResourceId, resolved.binding.createTrade.toolName, input.signal);
|
|
12140
12267
|
if (!tool) {
|
|
12141
12268
|
return failure("TOOL_NOT_ALLOWED", "\u521B\u5EFA\u4EA4\u6613 MCP Tool \u4E0D\u5B58\u5728\u6216\u672A\u6388\u6743", false);
|
|
12142
12269
|
}
|
|
12270
|
+
diagnostics.stage = "tool_input";
|
|
12143
12271
|
const args = createToolInput(resolved.binding.createTrade.inputBindings, request.actionContext, input.runtimeContext);
|
|
12144
12272
|
if (!args)
|
|
12145
12273
|
return failure("INVALID_INPUT", "\u65E0\u6CD5\u751F\u6210\u521B\u5EFA\u4EA4\u6613 MCP \u5165\u53C2", false);
|
|
12146
12274
|
let result;
|
|
12275
|
+
diagnostics.stage = "tool_execute";
|
|
12276
|
+
diagnostics.write("tool_started");
|
|
12147
12277
|
try {
|
|
12148
12278
|
result = await tool.execute(args, input.signal);
|
|
12149
|
-
|
|
12279
|
+
diagnostics.write("tool_completed");
|
|
12280
|
+
} catch (error) {
|
|
12281
|
+
diagnostics.error("tool_failed", error);
|
|
12150
12282
|
return failure("EXECUTION_FAILED", "\u521B\u5EFA\u4EA4\u6613\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5", true);
|
|
12151
12283
|
}
|
|
12284
|
+
diagnostics.stage = "tool_output";
|
|
12152
12285
|
const structured = readStructuredContent(result);
|
|
12153
12286
|
const tradeNO = readJsonPointer(structured, resolved.binding.createTrade.tradeNoPath);
|
|
12154
12287
|
if (typeof tradeNO !== "string" || !tradeNO.trim() || tradeNO.length > 64) {
|
|
@@ -12160,7 +12293,10 @@ async function executeCardAction(input) {
|
|
|
12160
12293
|
result: { kind: "payment", tradeNO }
|
|
12161
12294
|
};
|
|
12162
12295
|
} finally {
|
|
12296
|
+
const stage = diagnostics.stage;
|
|
12297
|
+
diagnostics.stage = "cleanup";
|
|
12163
12298
|
await registry.closeAll();
|
|
12299
|
+
diagnostics.stage = stage;
|
|
12164
12300
|
}
|
|
12165
12301
|
}
|
|
12166
12302
|
async function verifyPaymentResult(input) {
|
|
@@ -12223,9 +12359,9 @@ function resolvePaymentBinding(protocol, source, actionId) {
|
|
|
12223
12359
|
}
|
|
12224
12360
|
return { ok: true, binding };
|
|
12225
12361
|
}
|
|
12226
|
-
function createRegistry(protocol, provider) {
|
|
12362
|
+
function createRegistry(protocol, provider, debugLog) {
|
|
12227
12363
|
const resources = protocol.agent.resources.filter((resource) => resource.resourceType === EResourceType.MCP || resource.resourceType === EResourceType.MCP_TOOL);
|
|
12228
|
-
return new McpProxyTool(provider, aggregateMcpServers(resources, protocol.agentId));
|
|
12364
|
+
return new McpProxyTool(provider, aggregateMcpServers(resources, protocol.agentId), { debugLog });
|
|
12229
12365
|
}
|
|
12230
12366
|
function createToolInput(bindings, actionContext, runtimeContext, tradeNO, callback) {
|
|
12231
12367
|
const result = {};
|
|
@@ -12425,6 +12561,90 @@ function stableToolName(prefix, raw) {
|
|
|
12425
12561
|
return `${prefix}_${readable}_${digest}`;
|
|
12426
12562
|
}
|
|
12427
12563
|
|
|
12564
|
+
// ../linkque-agent-runtime/dist/esm/core/cardSemanticSnapshot.js
|
|
12565
|
+
var MAX_BYTES = 6e3;
|
|
12566
|
+
var MAX_LABEL = 160;
|
|
12567
|
+
function createCardSemanticSnapshot(receipt, fields) {
|
|
12568
|
+
const groups = receipt.coverage.map((coverage) => {
|
|
12569
|
+
const field = fields.find((f) => f.fieldId === coverage.fieldId);
|
|
12570
|
+
const entities = receipt.entities.filter((e) => e.fieldId === coverage.fieldId);
|
|
12571
|
+
const echo = field?.presentation?.visibility === "echo";
|
|
12572
|
+
const attributes = echo ? [...new Set(entities.flatMap((e) => Object.keys(e.attributes ?? {})))] : [];
|
|
12573
|
+
const hasValue = echo && entities.some((e) => Object.hasOwn(e, "value"));
|
|
12574
|
+
const hasLabel = echo && entities.some((e) => !Object.hasOwn(e, "value"));
|
|
12575
|
+
const columns = [
|
|
12576
|
+
"\u6761\u76EE\u5F15\u7528",
|
|
12577
|
+
...hasLabel ? [columnLabel(field, field?.presentation?.labelPath, "\u540D\u79F0")] : [],
|
|
12578
|
+
...hasValue ? [short(coverage.label)] : [],
|
|
12579
|
+
...attributes.map((path2) => columnLabel(field, path2, path2))
|
|
12580
|
+
];
|
|
12581
|
+
const rows = entities.map((e) => [
|
|
12582
|
+
e.ref,
|
|
12583
|
+
...hasLabel ? [e.label] : [],
|
|
12584
|
+
...hasValue ? [e.value ?? null] : [],
|
|
12585
|
+
...attributes.map((path2) => e.attributes?.[path2] ?? null)
|
|
12586
|
+
]);
|
|
12587
|
+
const total = coverage.itemCount ?? (coverage.present ? 1 : 0);
|
|
12588
|
+
return {
|
|
12589
|
+
field: coverage.fieldId,
|
|
12590
|
+
label: short(coverage.label),
|
|
12591
|
+
present: coverage.present,
|
|
12592
|
+
total,
|
|
12593
|
+
included: rows.length,
|
|
12594
|
+
complete: echo && coverage.present && rows.length === total && !entities.some((e) => e.truncated) && !receipt.omissions.some((o) => o.fieldId === coverage.fieldId),
|
|
12595
|
+
columns,
|
|
12596
|
+
rows
|
|
12597
|
+
};
|
|
12598
|
+
});
|
|
12599
|
+
const snapshot = {
|
|
12600
|
+
version: 1,
|
|
12601
|
+
groups,
|
|
12602
|
+
omissions: receipt.omissions.map((o) => ({ ...o }))
|
|
12603
|
+
};
|
|
12604
|
+
while (bytes(snapshot) > MAX_BYTES) {
|
|
12605
|
+
let group;
|
|
12606
|
+
for (let i = groups.length - 1; i >= 0; i--) {
|
|
12607
|
+
if (groups[i].rows.length > 0) {
|
|
12608
|
+
group = groups[i];
|
|
12609
|
+
break;
|
|
12610
|
+
}
|
|
12611
|
+
}
|
|
12612
|
+
snapshot.truncated = true;
|
|
12613
|
+
if (group) {
|
|
12614
|
+
group.rows.pop();
|
|
12615
|
+
group.included = group.rows.length;
|
|
12616
|
+
group.complete = false;
|
|
12617
|
+
} else if (groups.length) {
|
|
12618
|
+
groups.pop();
|
|
12619
|
+
} else if (snapshot.omissions.length) {
|
|
12620
|
+
snapshot.omissions.pop();
|
|
12621
|
+
} else
|
|
12622
|
+
break;
|
|
12623
|
+
}
|
|
12624
|
+
return snapshot;
|
|
12625
|
+
}
|
|
12626
|
+
function bytes(value) {
|
|
12627
|
+
return Buffer.byteLength(JSON.stringify(value));
|
|
12628
|
+
}
|
|
12629
|
+
function short(value) {
|
|
12630
|
+
return value.length > MAX_LABEL ? `${value.slice(0, MAX_LABEL - 1)}\u2026` : value;
|
|
12631
|
+
}
|
|
12632
|
+
function columnLabel(field, path2, fallback) {
|
|
12633
|
+
if (!field || !path2)
|
|
12634
|
+
return short(fallback);
|
|
12635
|
+
let schema = field.type === "array" ? field.valueSchema.items : field.valueSchema;
|
|
12636
|
+
for (const token of path2.slice(1).split("/").map((t) => t.replaceAll("~1", "/").replaceAll("~0", "~"))) {
|
|
12637
|
+
if (!schema || typeof schema !== "object" || Array.isArray(schema))
|
|
12638
|
+
return short(fallback);
|
|
12639
|
+
const properties = schema.properties;
|
|
12640
|
+
if (!properties || typeof properties !== "object" || Array.isArray(properties) || !Object.hasOwn(properties, token))
|
|
12641
|
+
return short(fallback);
|
|
12642
|
+
schema = properties[token];
|
|
12643
|
+
}
|
|
12644
|
+
const title = schema && typeof schema === "object" && !Array.isArray(schema) ? schema.title : void 0;
|
|
12645
|
+
return short(typeof title === "string" && title ? title : fallback);
|
|
12646
|
+
}
|
|
12647
|
+
|
|
12428
12648
|
// ../linkque-agent-runtime/dist/esm/core/cardTools.js
|
|
12429
12649
|
var FALLBACK_OBJECT_SCHEMA = {
|
|
12430
12650
|
type: "object",
|
|
@@ -12548,6 +12768,7 @@ function createPresentationResult(resource, config, viewModel) {
|
|
|
12548
12768
|
...createA2UICardPresentationReceiptContent(config.fields, viewModel),
|
|
12549
12769
|
responsePolicy: { verbatimEcho: "forbidden", hint: "acknowledge" }
|
|
12550
12770
|
};
|
|
12771
|
+
receipt.semanticSnapshot = createCardSemanticSnapshot(receipt, config.fields);
|
|
12551
12772
|
return {
|
|
12552
12773
|
type: "linkque.presentation-tool-result",
|
|
12553
12774
|
modelText: formatPresentationReceiptForModel(receipt),
|
|
@@ -12567,11 +12788,23 @@ function createPresentationResult(resource, config, viewModel) {
|
|
|
12567
12788
|
function formatPresentationReceiptForModel(receipt) {
|
|
12568
12789
|
return [
|
|
12569
12790
|
"<a2ui-presentation-receipt>",
|
|
12570
|
-
JSON.stringify(receipt),
|
|
12791
|
+
JSON.stringify(projectPresentationReceiptForModel(receipt)),
|
|
12571
12792
|
"</a2ui-presentation-receipt>",
|
|
12572
|
-
"
|
|
12793
|
+
"\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"
|
|
12573
12794
|
].join("\n");
|
|
12574
12795
|
}
|
|
12796
|
+
function projectPresentationReceiptForModel(receipt) {
|
|
12797
|
+
if (!receipt.semanticSnapshot)
|
|
12798
|
+
return receipt;
|
|
12799
|
+
return {
|
|
12800
|
+
version: receipt.version,
|
|
12801
|
+
cardRef: receipt.cardRef,
|
|
12802
|
+
cardRevision: receipt.cardRevision,
|
|
12803
|
+
cardInstanceId: receipt.cardInstanceId,
|
|
12804
|
+
status: receipt.status,
|
|
12805
|
+
semanticSnapshot: receipt.semanticSnapshot
|
|
12806
|
+
};
|
|
12807
|
+
}
|
|
12575
12808
|
function parseCardConfig(resource) {
|
|
12576
12809
|
const parsed = parseA2UICardResourceConfig(resource.config);
|
|
12577
12810
|
if (!parsed.success) {
|
|
@@ -12625,9 +12858,9 @@ function collectA2UISurfaceIdsForLegacyContract(protocol) {
|
|
|
12625
12858
|
function createPresentationDescription(config) {
|
|
12626
12859
|
return [
|
|
12627
12860
|
config.description,
|
|
12628
|
-
|
|
12629
|
-
...config.whenNotToUse ? [
|
|
12630
|
-
"
|
|
12861
|
+
`\u9002\u7528\u573A\u666F\uFF1A${config.whenToUse}`,
|
|
12862
|
+
...config.whenNotToUse ? [`\u4E0D\u9002\u7528\u573A\u666F\uFF1A${config.whenNotToUse}`] : [],
|
|
12863
|
+
"\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"
|
|
12631
12864
|
].join("\n");
|
|
12632
12865
|
}
|
|
12633
12866
|
function cloneJsonObject2(value, label) {
|
|
@@ -12891,6 +13124,12 @@ function normalizeHookResources(resources) {
|
|
|
12891
13124
|
}).sort((a, b) => (a.config.order ?? 0) - (b.config.order ?? 0));
|
|
12892
13125
|
}
|
|
12893
13126
|
|
|
13127
|
+
// ../linkque-agent-runtime/dist/esm/core/logFailure.js
|
|
13128
|
+
import { emitWarning } from "node:process";
|
|
13129
|
+
function warnLogFailure(stage, error) {
|
|
13130
|
+
emitWarning(`[${stage}] errorType=${error instanceof Error ? error.name : typeof error}`, { code: "LINKQUE_RUNTIME_DIAGNOSTIC_FAILURE" });
|
|
13131
|
+
}
|
|
13132
|
+
|
|
12894
13133
|
// ../linkque-agent-runtime/dist/esm/core/hook/hookLog.js
|
|
12895
13134
|
var HOOK_LOG_MESSAGE_MAX_LENGTH = 200;
|
|
12896
13135
|
function writeHookLog(debugLog, record2) {
|
|
@@ -12898,7 +13137,8 @@ function writeHookLog(debugLog, record2) {
|
|
|
12898
13137
|
return;
|
|
12899
13138
|
try {
|
|
12900
13139
|
debugLog(JSON.stringify(redactHookLogRecord(record2)), EDebugLogScope.HOOK);
|
|
12901
|
-
} catch {
|
|
13140
|
+
} catch (error) {
|
|
13141
|
+
warnLogFailure("writeHookLog", error);
|
|
12902
13142
|
}
|
|
12903
13143
|
}
|
|
12904
13144
|
function redactHookLogRecord(record2) {
|
|
@@ -13097,6 +13337,15 @@ var HookDispatcher = class {
|
|
|
13097
13337
|
stage: EHookStage.RUN_READ,
|
|
13098
13338
|
read: { readAt: subject.readAt ?? now() }
|
|
13099
13339
|
};
|
|
13340
|
+
case EHookStage.MODEL_RESPONSE_RECEIVED: {
|
|
13341
|
+
if (!subject.model)
|
|
13342
|
+
throw new Error("MODEL_RESPONSE_RECEIVED Hook \u7F3A\u5C11\u54CD\u5E94\u4E0A\u4E0B\u6587");
|
|
13343
|
+
return {
|
|
13344
|
+
...base,
|
|
13345
|
+
stage: EHookStage.MODEL_RESPONSE_RECEIVED,
|
|
13346
|
+
model: subject.model
|
|
13347
|
+
};
|
|
13348
|
+
}
|
|
13100
13349
|
case EHookStage.AFTER_MODEL_CALL: {
|
|
13101
13350
|
if (!subject.model || subject.model.messageContent === void 0) {
|
|
13102
13351
|
throw new Error("AFTER_MODEL_CALL Hook \u7F3A\u5C11\u5B8C\u6574 model context");
|
|
@@ -13645,7 +13894,8 @@ function redactHeaders(headers) {
|
|
|
13645
13894
|
pairs.push(`${key}=${redactHeader(key, value)}`);
|
|
13646
13895
|
}
|
|
13647
13896
|
}
|
|
13648
|
-
} catch {
|
|
13897
|
+
} catch (error) {
|
|
13898
|
+
warnLogFailure("httpLoggingFetch.redactHeaders", error);
|
|
13649
13899
|
}
|
|
13650
13900
|
return pairs.join(",");
|
|
13651
13901
|
}
|
|
@@ -13682,7 +13932,8 @@ function createHttpLoggingFetch(debugLog, tag, baseFetch = globalThis.fetch) {
|
|
|
13682
13932
|
const cl = resp.headers.get("content-length");
|
|
13683
13933
|
if (cl)
|
|
13684
13934
|
len = cl;
|
|
13685
|
-
} catch {
|
|
13935
|
+
} catch (error) {
|
|
13936
|
+
warnLogFailure("httpLoggingFetch.contentLength", error);
|
|
13686
13937
|
}
|
|
13687
13938
|
const correlation = readResponseCorrelationId(resp.headers);
|
|
13688
13939
|
const correlationField = correlation ? ` traceId=${correlation.value} traceHeader=${correlation.name}` : "";
|
|
@@ -13711,14 +13962,16 @@ function readResponseCorrelationId(headers) {
|
|
|
13711
13962
|
};
|
|
13712
13963
|
});
|
|
13713
13964
|
return matched;
|
|
13714
|
-
} catch {
|
|
13965
|
+
} catch (error) {
|
|
13966
|
+
warnLogFailure("httpLoggingFetch.responseCorrelationId", error);
|
|
13715
13967
|
}
|
|
13716
13968
|
return void 0;
|
|
13717
13969
|
}
|
|
13718
13970
|
function safeLog(debugLog, line) {
|
|
13719
13971
|
try {
|
|
13720
13972
|
debugLog(line, EDebugLogScope.HTTP);
|
|
13721
|
-
} catch {
|
|
13973
|
+
} catch (error) {
|
|
13974
|
+
warnLogFailure("httpLoggingFetch.safeLog", error);
|
|
13722
13975
|
}
|
|
13723
13976
|
}
|
|
13724
13977
|
function nowMs() {
|
|
@@ -14794,9 +15047,6 @@ function getConversationRunRequestIssues(value) {
|
|
|
14794
15047
|
issues.push("attachments must be an array");
|
|
14795
15048
|
} else {
|
|
14796
15049
|
value.attachments.forEach((attachment, index) => validateAttachment(attachment, index, issues));
|
|
14797
|
-
if (value.attachments.length > 0 && (!Array.isArray(value.messages) || !value.messages.some((message) => isRecord4(message) && message.role === "user"))) {
|
|
14798
|
-
issues.push("non-empty attachments require at least one user message");
|
|
14799
|
-
}
|
|
14800
15050
|
}
|
|
14801
15051
|
if (!isRecord4(value.metadata))
|
|
14802
15052
|
issues.push("metadata must be an object");
|
|
@@ -14937,9 +15187,6 @@ function validateAttachment(value, index, issues) {
|
|
|
14937
15187
|
if (value.size !== void 0 && (!Number.isSafeInteger(value.size) || Number(value.size) < 0)) {
|
|
14938
15188
|
issues.push(`attachments[${index}].size must be a non-negative safe integer when provided`);
|
|
14939
15189
|
}
|
|
14940
|
-
if (value.availability !== void 0 && value.availability !== "resolvable" && value.availability !== "current_turn_only") {
|
|
14941
|
-
issues.push(`attachments[${index}].availability must be resolvable or current_turn_only when provided`);
|
|
14942
|
-
}
|
|
14943
15190
|
if (value.metadata !== void 0 && !isRecord4(value.metadata)) {
|
|
14944
15191
|
issues.push(`attachments[${index}].metadata must be an object when provided`);
|
|
14945
15192
|
}
|
|
@@ -20316,13 +20563,42 @@ var RemoteGatewayMcpServerProvider = class {
|
|
|
20316
20563
|
});
|
|
20317
20564
|
const serverName = resource.config.serverName ?? resource.resourceId;
|
|
20318
20565
|
const argsMappingRules = resource.config.argsMappingRules ?? [];
|
|
20566
|
+
let requestSequence = 0;
|
|
20567
|
+
const request = async (method, params, invoke) => {
|
|
20568
|
+
const requestId = ++requestSequence;
|
|
20569
|
+
const log = (phase, payload) => {
|
|
20570
|
+
if (!this.debugLog)
|
|
20571
|
+
return;
|
|
20572
|
+
try {
|
|
20573
|
+
this.debugLog(`[mcp-client] ${JSON.stringify({ serverName, resourceId: resource.resourceId, requestId, method, phase, payload })}`, EDebugLogScope.MCP);
|
|
20574
|
+
} catch (error) {
|
|
20575
|
+
warnLogFailure("remoteGatewayMcpServer.log", error);
|
|
20576
|
+
}
|
|
20577
|
+
};
|
|
20578
|
+
log("request", params);
|
|
20579
|
+
try {
|
|
20580
|
+
const result = await invoke();
|
|
20581
|
+
log("response", result);
|
|
20582
|
+
return result;
|
|
20583
|
+
} catch (error) {
|
|
20584
|
+
log("error", error instanceof Error ? { name: error.name, message: error.message } : error);
|
|
20585
|
+
throw error;
|
|
20586
|
+
}
|
|
20587
|
+
};
|
|
20588
|
+
const loggedClient = {
|
|
20589
|
+
listTools: () => request("tools/list", {}, () => client.listTools()),
|
|
20590
|
+
callTool: (params) => request("tools/call", params, () => client.callTool(params))
|
|
20591
|
+
};
|
|
20319
20592
|
return {
|
|
20320
20593
|
resourceId: resource.resourceId,
|
|
20321
20594
|
serverName,
|
|
20322
|
-
listTools: () => listToolsFromClient(
|
|
20595
|
+
listTools: () => listToolsFromClient(loggedClient, resource.resourceId),
|
|
20323
20596
|
callTool: (name, args) => {
|
|
20324
20597
|
const mapped = applyArgsMappingRules(name, args, argsMappingRules);
|
|
20325
|
-
return
|
|
20598
|
+
return loggedClient.callTool({
|
|
20599
|
+
name,
|
|
20600
|
+
arguments: mapped ?? {}
|
|
20601
|
+
});
|
|
20326
20602
|
},
|
|
20327
20603
|
close: async () => {
|
|
20328
20604
|
try {
|
|
@@ -21196,8 +21472,8 @@ var WebSkillLoader = class {
|
|
|
21196
21472
|
return readFile(path.join(candidate, "SKILL.md"), "utf8");
|
|
21197
21473
|
}
|
|
21198
21474
|
if (isZipPath(candidate)) {
|
|
21199
|
-
const
|
|
21200
|
-
const files = await unzipBytes(
|
|
21475
|
+
const bytes2 = new Uint8Array(await readFile(candidate));
|
|
21476
|
+
const files = await unzipBytes(bytes2, resourceId);
|
|
21201
21477
|
const body = extractSkillMarkdown(files);
|
|
21202
21478
|
if (body === void 0) {
|
|
21203
21479
|
throw new Error(`WebSkillLoader \u5728\u672C\u5730 zip \u5185\u672A\u627E\u5230 SKILL.md(\u6216\u56DE\u9000 .md)\u6B63\u6587: ${url2} (resourceId=${resourceId})`);
|
|
@@ -21240,7 +21516,7 @@ var extractSkillMarkdown = (files) => {
|
|
|
21240
21516
|
const rootMd = paths.find((p) => p.endsWith(".md") && !p.includes("/"));
|
|
21241
21517
|
return rootMd === void 0 ? void 0 : decodeUtf8(files[rootMd]);
|
|
21242
21518
|
};
|
|
21243
|
-
var decodeUtf8 = (
|
|
21519
|
+
var decodeUtf8 = (bytes2) => new TextDecoder("utf-8", { fatal: true }).decode(bytes2);
|
|
21244
21520
|
var globalFetch = (url2) => fetch(url2);
|
|
21245
21521
|
var detectScheme = (url2) => {
|
|
21246
21522
|
if (/^https:\/\//i.test(url2))
|
|
@@ -21447,6 +21723,7 @@ export {
|
|
|
21447
21723
|
createCardPresentationToolName,
|
|
21448
21724
|
executeCardPresentation,
|
|
21449
21725
|
executeCardPresentationFromSources,
|
|
21726
|
+
projectPresentationReceiptForModel,
|
|
21450
21727
|
parseCardConfig,
|
|
21451
21728
|
isAgentPresentationToolResult,
|
|
21452
21729
|
createPresentationDescription,
|
|
@@ -21456,6 +21733,7 @@ export {
|
|
|
21456
21733
|
aggregateMcpServers,
|
|
21457
21734
|
McpProxyTool,
|
|
21458
21735
|
executeHomeData,
|
|
21736
|
+
CardActionDiagnostics,
|
|
21459
21737
|
executeCardAction,
|
|
21460
21738
|
verifyPaymentResult,
|
|
21461
21739
|
FOLLOW_UP_CONTEXT_MAX_HISTORY_RUNS,
|
|
@@ -21466,6 +21744,7 @@ export {
|
|
|
21466
21744
|
NoopMcpServerProvider,
|
|
21467
21745
|
buildHookCommonParams,
|
|
21468
21746
|
normalizeHookResources,
|
|
21747
|
+
warnLogFailure,
|
|
21469
21748
|
HookDispatcher,
|
|
21470
21749
|
DEFAULT_HOOK_DRAIN_BUDGET_MS,
|
|
21471
21750
|
SideEffectRunner,
|