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