linkque-cli-v2 1.2.5 → 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 +1235 -817
- package/package.json +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-7OQJF6OX.js → chunk-5SPKWM3O.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-E5KGGPEP.js → chunk-B5QEJGC6.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-YYBDYBTX.js → chunk-MLVSBCIT.js} +191 -21
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js +284 -52
- 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 +331 -72
package/package.json
CHANGED
package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-YYBDYBTX.js → chunk-MLVSBCIT.js}
RENAMED
|
@@ -3211,6 +3211,7 @@ var require_utils = __commonJS({
|
|
|
3211
3211
|
"use strict";
|
|
3212
3212
|
var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
|
|
3213
3213
|
var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
|
|
3214
|
+
var isPort = RegExp.prototype.test.bind(/^\d*$/u);
|
|
3214
3215
|
var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
|
|
3215
3216
|
var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
|
|
3216
3217
|
var isPathCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u);
|
|
@@ -3676,8 +3677,12 @@ var require_utils = __commonJS({
|
|
|
3676
3677
|
uriTokens.push(host);
|
|
3677
3678
|
}
|
|
3678
3679
|
if (typeof component.port === "number" || typeof component.port === "string") {
|
|
3680
|
+
const port = String(component.port);
|
|
3681
|
+
if (!isPort(port)) {
|
|
3682
|
+
throw new TypeError("URI port is malformed.");
|
|
3683
|
+
}
|
|
3679
3684
|
uriTokens.push(":");
|
|
3680
|
-
uriTokens.push(
|
|
3685
|
+
uriTokens.push(port);
|
|
3681
3686
|
}
|
|
3682
3687
|
return uriTokens.length ? uriTokens.join("") : void 0;
|
|
3683
3688
|
}
|
|
@@ -4120,12 +4125,15 @@ var require_fast_uri = __commonJS({
|
|
|
4120
4125
|
}
|
|
4121
4126
|
return false;
|
|
4122
4127
|
}
|
|
4128
|
+
function isIPLiteral(host) {
|
|
4129
|
+
return host[0] === "[" && host[host.length - 1] === "]";
|
|
4130
|
+
}
|
|
4123
4131
|
function hasMalformedComponentPercentEncoding(matches) {
|
|
4124
4132
|
const host = matches[4];
|
|
4125
|
-
return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !(host
|
|
4133
|
+
return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !isIPLiteral(host) && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
|
|
4126
4134
|
}
|
|
4127
4135
|
function canonicalizeHost(parsed, options, schemeHandler, isIP) {
|
|
4128
|
-
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && parsed.host
|
|
4136
|
+
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
|
|
4129
4137
|
try {
|
|
4130
4138
|
parsed.host = new URL("http://" + parsed.host).hostname;
|
|
4131
4139
|
} catch (e) {
|
|
@@ -4212,10 +4220,11 @@ var require_fast_uri = __commonJS({
|
|
|
4212
4220
|
if (parsed.host) {
|
|
4213
4221
|
const ipv4result = isIPv4(parsed.host);
|
|
4214
4222
|
if (ipv4result === false) {
|
|
4215
|
-
const bracketedIPLiteral = parsed.host
|
|
4223
|
+
const bracketedIPLiteral = isIPLiteral(parsed.host);
|
|
4224
|
+
const hasIPLiteralBracket = parsed.host.indexOf("[") !== -1 || parsed.host.indexOf("]") !== -1;
|
|
4216
4225
|
const ipv6result = normalizeIPv6(parsed.host);
|
|
4217
4226
|
isIP = ipv6result.isIPV6 || ipv6result.isIPVFuture === true;
|
|
4218
|
-
malformedIPLiteral =
|
|
4227
|
+
malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
|
|
4219
4228
|
parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
|
|
4220
4229
|
if (malformedIPLiteral) {
|
|
4221
4230
|
parsed.error = parsed.error || "URI host is malformed.";
|
|
@@ -4238,7 +4247,9 @@ var require_fast_uri = __commonJS({
|
|
|
4238
4247
|
parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
|
|
4239
4248
|
}
|
|
4240
4249
|
const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
|
|
4241
|
-
|
|
4250
|
+
if (!malformedIPLiteral) {
|
|
4251
|
+
malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
|
|
4252
|
+
}
|
|
4242
4253
|
if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
|
|
4243
4254
|
if (uri.indexOf("%") !== -1) {
|
|
4244
4255
|
if (parsed.host !== void 0 && !malformedIPLiteral) {
|
|
@@ -8835,6 +8846,7 @@ var EHookStage;
|
|
|
8835
8846
|
EHookStage2["RUN_FAILED"] = "RUN_FAILED";
|
|
8836
8847
|
EHookStage2["RUN_READ"] = "RUN_READ";
|
|
8837
8848
|
EHookStage2["AFTER_MODEL_CALL"] = "AFTER_MODEL_CALL";
|
|
8849
|
+
EHookStage2["MODEL_RESPONSE_RECEIVED"] = "MODEL_RESPONSE_RECEIVED";
|
|
8838
8850
|
EHookStage2["BEFORE_TOOL_CALL"] = "BEFORE_TOOL_CALL";
|
|
8839
8851
|
EHookStage2["AFTER_TOOL_CALL"] = "AFTER_TOOL_CALL";
|
|
8840
8852
|
EHookStage2["TOOL_CALL_FAILED"] = "TOOL_CALL_FAILED";
|
|
@@ -8982,6 +8994,8 @@ var ALLOWED_AST_TYPES = /* @__PURE__ */ new Set([
|
|
|
8982
8994
|
"Field",
|
|
8983
8995
|
"Function",
|
|
8984
8996
|
"Identity",
|
|
8997
|
+
"Index",
|
|
8998
|
+
"IndexExpression",
|
|
8985
8999
|
"KeyValuePair",
|
|
8986
9000
|
"Literal",
|
|
8987
9001
|
"MultiSelectHash",
|
|
@@ -9053,6 +9067,9 @@ function validateAst(ast) {
|
|
|
9053
9067
|
if (!ALLOWED_AST_TYPES.has(value.type)) {
|
|
9054
9068
|
throw new StructuralExpressionError("STRUCTURAL_EXPRESSION_NODE_FORBIDDEN", `JMESPath node ${value.type} is not allowed`);
|
|
9055
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
|
+
}
|
|
9056
9073
|
if (value.type === "Function" && value.name !== "not_null") {
|
|
9057
9074
|
throw new StructuralExpressionError("STRUCTURAL_EXPRESSION_FUNCTION_FORBIDDEN", `JMESPath function ${String(value.name)} is not allowed`);
|
|
9058
9075
|
}
|
|
@@ -9840,6 +9857,8 @@ var ALLOWED_AST_TYPES2 = /* @__PURE__ */ new Set([
|
|
|
9840
9857
|
"Field",
|
|
9841
9858
|
"Function",
|
|
9842
9859
|
"Identity",
|
|
9860
|
+
"Index",
|
|
9861
|
+
"IndexExpression",
|
|
9843
9862
|
"KeyValuePair",
|
|
9844
9863
|
"Literal",
|
|
9845
9864
|
"MultiSelectHash",
|
|
@@ -9932,6 +9951,9 @@ function validateAst2(ast) {
|
|
|
9932
9951
|
if (!ALLOWED_AST_TYPES2.has(value.type)) {
|
|
9933
9952
|
throw new A2UICardExpressionError("CARD_EXPRESSION_NODE_FORBIDDEN", `JMESPath node ${value.type} is not allowed by ${A2UI_CARD_TRANSFORM_PROFILE}`);
|
|
9934
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
|
+
}
|
|
9935
9957
|
if (value.type === "Function" && value.name !== "not_null") {
|
|
9936
9958
|
throw new A2UICardExpressionError("CARD_EXPRESSION_FUNCTION_FORBIDDEN", `JMESPath function ${String(value.name)} is not allowed`);
|
|
9937
9959
|
}
|
|
@@ -12539,6 +12561,90 @@ function stableToolName(prefix, raw) {
|
|
|
12539
12561
|
return `${prefix}_${readable}_${digest}`;
|
|
12540
12562
|
}
|
|
12541
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
|
+
|
|
12542
12648
|
// ../linkque-agent-runtime/dist/esm/core/cardTools.js
|
|
12543
12649
|
var FALLBACK_OBJECT_SCHEMA = {
|
|
12544
12650
|
type: "object",
|
|
@@ -12662,6 +12768,7 @@ function createPresentationResult(resource, config, viewModel) {
|
|
|
12662
12768
|
...createA2UICardPresentationReceiptContent(config.fields, viewModel),
|
|
12663
12769
|
responsePolicy: { verbatimEcho: "forbidden", hint: "acknowledge" }
|
|
12664
12770
|
};
|
|
12771
|
+
receipt.semanticSnapshot = createCardSemanticSnapshot(receipt, config.fields);
|
|
12665
12772
|
return {
|
|
12666
12773
|
type: "linkque.presentation-tool-result",
|
|
12667
12774
|
modelText: formatPresentationReceiptForModel(receipt),
|
|
@@ -12681,11 +12788,23 @@ function createPresentationResult(resource, config, viewModel) {
|
|
|
12681
12788
|
function formatPresentationReceiptForModel(receipt) {
|
|
12682
12789
|
return [
|
|
12683
12790
|
"<a2ui-presentation-receipt>",
|
|
12684
|
-
JSON.stringify(receipt),
|
|
12791
|
+
JSON.stringify(projectPresentationReceiptForModel(receipt)),
|
|
12685
12792
|
"</a2ui-presentation-receipt>",
|
|
12686
|
-
"
|
|
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"
|
|
12687
12794
|
].join("\n");
|
|
12688
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
|
+
}
|
|
12689
12808
|
function parseCardConfig(resource) {
|
|
12690
12809
|
const parsed = parseA2UICardResourceConfig(resource.config);
|
|
12691
12810
|
if (!parsed.success) {
|
|
@@ -12739,9 +12858,9 @@ function collectA2UISurfaceIdsForLegacyContract(protocol) {
|
|
|
12739
12858
|
function createPresentationDescription(config) {
|
|
12740
12859
|
return [
|
|
12741
12860
|
config.description,
|
|
12742
|
-
|
|
12743
|
-
...config.whenNotToUse ? [
|
|
12744
|
-
"
|
|
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"
|
|
12745
12864
|
].join("\n");
|
|
12746
12865
|
}
|
|
12747
12866
|
function cloneJsonObject2(value, label) {
|
|
@@ -13005,6 +13124,12 @@ function normalizeHookResources(resources) {
|
|
|
13005
13124
|
}).sort((a, b) => (a.config.order ?? 0) - (b.config.order ?? 0));
|
|
13006
13125
|
}
|
|
13007
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
|
+
|
|
13008
13133
|
// ../linkque-agent-runtime/dist/esm/core/hook/hookLog.js
|
|
13009
13134
|
var HOOK_LOG_MESSAGE_MAX_LENGTH = 200;
|
|
13010
13135
|
function writeHookLog(debugLog, record2) {
|
|
@@ -13012,7 +13137,8 @@ function writeHookLog(debugLog, record2) {
|
|
|
13012
13137
|
return;
|
|
13013
13138
|
try {
|
|
13014
13139
|
debugLog(JSON.stringify(redactHookLogRecord(record2)), EDebugLogScope.HOOK);
|
|
13015
|
-
} catch {
|
|
13140
|
+
} catch (error) {
|
|
13141
|
+
warnLogFailure("writeHookLog", error);
|
|
13016
13142
|
}
|
|
13017
13143
|
}
|
|
13018
13144
|
function redactHookLogRecord(record2) {
|
|
@@ -13211,6 +13337,15 @@ var HookDispatcher = class {
|
|
|
13211
13337
|
stage: EHookStage.RUN_READ,
|
|
13212
13338
|
read: { readAt: subject.readAt ?? now() }
|
|
13213
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
|
+
}
|
|
13214
13349
|
case EHookStage.AFTER_MODEL_CALL: {
|
|
13215
13350
|
if (!subject.model || subject.model.messageContent === void 0) {
|
|
13216
13351
|
throw new Error("AFTER_MODEL_CALL Hook \u7F3A\u5C11\u5B8C\u6574 model context");
|
|
@@ -13759,7 +13894,8 @@ function redactHeaders(headers) {
|
|
|
13759
13894
|
pairs.push(`${key}=${redactHeader(key, value)}`);
|
|
13760
13895
|
}
|
|
13761
13896
|
}
|
|
13762
|
-
} catch {
|
|
13897
|
+
} catch (error) {
|
|
13898
|
+
warnLogFailure("httpLoggingFetch.redactHeaders", error);
|
|
13763
13899
|
}
|
|
13764
13900
|
return pairs.join(",");
|
|
13765
13901
|
}
|
|
@@ -13796,7 +13932,8 @@ function createHttpLoggingFetch(debugLog, tag, baseFetch = globalThis.fetch) {
|
|
|
13796
13932
|
const cl = resp.headers.get("content-length");
|
|
13797
13933
|
if (cl)
|
|
13798
13934
|
len = cl;
|
|
13799
|
-
} catch {
|
|
13935
|
+
} catch (error) {
|
|
13936
|
+
warnLogFailure("httpLoggingFetch.contentLength", error);
|
|
13800
13937
|
}
|
|
13801
13938
|
const correlation = readResponseCorrelationId(resp.headers);
|
|
13802
13939
|
const correlationField = correlation ? ` traceId=${correlation.value} traceHeader=${correlation.name}` : "";
|
|
@@ -13825,14 +13962,16 @@ function readResponseCorrelationId(headers) {
|
|
|
13825
13962
|
};
|
|
13826
13963
|
});
|
|
13827
13964
|
return matched;
|
|
13828
|
-
} catch {
|
|
13965
|
+
} catch (error) {
|
|
13966
|
+
warnLogFailure("httpLoggingFetch.responseCorrelationId", error);
|
|
13829
13967
|
}
|
|
13830
13968
|
return void 0;
|
|
13831
13969
|
}
|
|
13832
13970
|
function safeLog(debugLog, line) {
|
|
13833
13971
|
try {
|
|
13834
13972
|
debugLog(line, EDebugLogScope.HTTP);
|
|
13835
|
-
} catch {
|
|
13973
|
+
} catch (error) {
|
|
13974
|
+
warnLogFailure("httpLoggingFetch.safeLog", error);
|
|
13836
13975
|
}
|
|
13837
13976
|
}
|
|
13838
13977
|
function nowMs() {
|
|
@@ -20424,13 +20563,42 @@ var RemoteGatewayMcpServerProvider = class {
|
|
|
20424
20563
|
});
|
|
20425
20564
|
const serverName = resource.config.serverName ?? resource.resourceId;
|
|
20426
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
|
+
};
|
|
20427
20592
|
return {
|
|
20428
20593
|
resourceId: resource.resourceId,
|
|
20429
20594
|
serverName,
|
|
20430
|
-
listTools: () => listToolsFromClient(
|
|
20595
|
+
listTools: () => listToolsFromClient(loggedClient, resource.resourceId),
|
|
20431
20596
|
callTool: (name, args) => {
|
|
20432
20597
|
const mapped = applyArgsMappingRules(name, args, argsMappingRules);
|
|
20433
|
-
return
|
|
20598
|
+
return loggedClient.callTool({
|
|
20599
|
+
name,
|
|
20600
|
+
arguments: mapped ?? {}
|
|
20601
|
+
});
|
|
20434
20602
|
},
|
|
20435
20603
|
close: async () => {
|
|
20436
20604
|
try {
|
|
@@ -21304,8 +21472,8 @@ var WebSkillLoader = class {
|
|
|
21304
21472
|
return readFile(path.join(candidate, "SKILL.md"), "utf8");
|
|
21305
21473
|
}
|
|
21306
21474
|
if (isZipPath(candidate)) {
|
|
21307
|
-
const
|
|
21308
|
-
const files = await unzipBytes(
|
|
21475
|
+
const bytes2 = new Uint8Array(await readFile(candidate));
|
|
21476
|
+
const files = await unzipBytes(bytes2, resourceId);
|
|
21309
21477
|
const body = extractSkillMarkdown(files);
|
|
21310
21478
|
if (body === void 0) {
|
|
21311
21479
|
throw new Error(`WebSkillLoader \u5728\u672C\u5730 zip \u5185\u672A\u627E\u5230 SKILL.md(\u6216\u56DE\u9000 .md)\u6B63\u6587: ${url2} (resourceId=${resourceId})`);
|
|
@@ -21348,7 +21516,7 @@ var extractSkillMarkdown = (files) => {
|
|
|
21348
21516
|
const rootMd = paths.find((p) => p.endsWith(".md") && !p.includes("/"));
|
|
21349
21517
|
return rootMd === void 0 ? void 0 : decodeUtf8(files[rootMd]);
|
|
21350
21518
|
};
|
|
21351
|
-
var decodeUtf8 = (
|
|
21519
|
+
var decodeUtf8 = (bytes2) => new TextDecoder("utf-8", { fatal: true }).decode(bytes2);
|
|
21352
21520
|
var globalFetch = (url2) => fetch(url2);
|
|
21353
21521
|
var detectScheme = (url2) => {
|
|
21354
21522
|
if (/^https:\/\//i.test(url2))
|
|
@@ -21555,6 +21723,7 @@ export {
|
|
|
21555
21723
|
createCardPresentationToolName,
|
|
21556
21724
|
executeCardPresentation,
|
|
21557
21725
|
executeCardPresentationFromSources,
|
|
21726
|
+
projectPresentationReceiptForModel,
|
|
21558
21727
|
parseCardConfig,
|
|
21559
21728
|
isAgentPresentationToolResult,
|
|
21560
21729
|
createPresentationDescription,
|
|
@@ -21575,6 +21744,7 @@ export {
|
|
|
21575
21744
|
NoopMcpServerProvider,
|
|
21576
21745
|
buildHookCommonParams,
|
|
21577
21746
|
normalizeHookResources,
|
|
21747
|
+
warnLogFailure,
|
|
21578
21748
|
HookDispatcher,
|
|
21579
21749
|
DEFAULT_HOOK_DRAIN_BUDGET_MS,
|
|
21580
21750
|
SideEffectRunner,
|