linkque-cli-v2 1.6.4 → 1.6.6
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/package.json +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-UZS5YLV2.js → chunk-FC6S43DG.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-VBERH5QM.js → chunk-FH2M6YD6.js} +78 -20
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-CO4I3RJE.js → chunk-ICPH34ZQ.js} +23 -11
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js +21 -16
- 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 +103 -38
package/package.json
CHANGED
package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-VBERH5QM.js → chunk-FH2M6YD6.js}
RENAMED
|
@@ -29810,6 +29810,41 @@ function resolveWebSearchResource(resources) {
|
|
|
29810
29810
|
};
|
|
29811
29811
|
}
|
|
29812
29812
|
|
|
29813
|
+
// ../linkque-agent-runtime/dist/esm/core/webSearchPresentation.js
|
|
29814
|
+
function projectWebSearchSources(result) {
|
|
29815
|
+
if (!isRecord2(result))
|
|
29816
|
+
return void 0;
|
|
29817
|
+
const value = result;
|
|
29818
|
+
if (value.error || typeof value.query !== "string" || !Array.isArray(value.items))
|
|
29819
|
+
return void 0;
|
|
29820
|
+
const items = value.items.slice(0, 10).flatMap((item) => {
|
|
29821
|
+
if (!isRecord2(item) || typeof item.id !== "string" || !item.id.trim() || typeof item.title !== "string" || !item.title.trim() || typeof item.content !== "string")
|
|
29822
|
+
return [];
|
|
29823
|
+
let url2;
|
|
29824
|
+
if (typeof item.url === "string") {
|
|
29825
|
+
try {
|
|
29826
|
+
const parsed = new URL(item.url);
|
|
29827
|
+
if (["http:", "https:"].includes(parsed.protocol) && !parsed.username && !parsed.password)
|
|
29828
|
+
url2 = parsed.href;
|
|
29829
|
+
} catch {
|
|
29830
|
+
}
|
|
29831
|
+
}
|
|
29832
|
+
return [
|
|
29833
|
+
{
|
|
29834
|
+
id: item.id.slice(0, 256),
|
|
29835
|
+
title: item.title.slice(0, 256),
|
|
29836
|
+
content: item.content.slice(0, 4e3),
|
|
29837
|
+
...url2 ? { url: url2 } : {},
|
|
29838
|
+
...typeof item.channel === "string" ? { channel: item.channel.slice(0, 64) } : {}
|
|
29839
|
+
}
|
|
29840
|
+
];
|
|
29841
|
+
});
|
|
29842
|
+
return items.length ? { query: value.query.slice(0, 2048), items } : void 0;
|
|
29843
|
+
}
|
|
29844
|
+
function isRecord2(value) {
|
|
29845
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
29846
|
+
}
|
|
29847
|
+
|
|
29813
29848
|
// ../linkque-agent-runtime/dist/esm/core/createWebSearchTool.js
|
|
29814
29849
|
function createWebSearchTool(resource, searchPort, agentId, debugLog) {
|
|
29815
29850
|
return {
|
|
@@ -29846,6 +29881,15 @@ function createWebSearchTool(resource, searchPort, agentId, debugLog) {
|
|
|
29846
29881
|
const result = await waitWithSignal(() => searchPort.search({ agentId, ...parsed }, signal, context2?.observation), signal);
|
|
29847
29882
|
throwIfWebSearchAborted(signal);
|
|
29848
29883
|
count = result.items.length;
|
|
29884
|
+
const presentation = context2 ? projectWebSearchSources(result) : void 0;
|
|
29885
|
+
if (context2 && presentation) {
|
|
29886
|
+
context2.emit({
|
|
29887
|
+
type: "tool_result",
|
|
29888
|
+
toolCallId: context2.toolCallId,
|
|
29889
|
+
messageId: `${context2.toolCallId}:web-search-result`,
|
|
29890
|
+
content: JSON.stringify(presentation)
|
|
29891
|
+
});
|
|
29892
|
+
}
|
|
29849
29893
|
return result;
|
|
29850
29894
|
} catch (error) {
|
|
29851
29895
|
if (signal?.aborted || error instanceof Error && error.name === "AbortError") {
|
|
@@ -30077,7 +30121,7 @@ var ConversationControlValidationError = class extends Error {
|
|
|
30077
30121
|
};
|
|
30078
30122
|
function parseCancelConversationRunRequest(value) {
|
|
30079
30123
|
const issues = [];
|
|
30080
|
-
if (!
|
|
30124
|
+
if (!isRecord3(value)) {
|
|
30081
30125
|
throw new ConversationControlValidationError([
|
|
30082
30126
|
"control request must be an object"
|
|
30083
30127
|
]);
|
|
@@ -30097,7 +30141,7 @@ function parseCancelConversationRunRequest(value) {
|
|
|
30097
30141
|
}
|
|
30098
30142
|
function parseMarkConversationRunsReadRequest(value) {
|
|
30099
30143
|
const issues = [];
|
|
30100
|
-
if (!
|
|
30144
|
+
if (!isRecord3(value)) {
|
|
30101
30145
|
throw new ConversationControlValidationError([
|
|
30102
30146
|
"control request must be an object"
|
|
30103
30147
|
]);
|
|
@@ -30131,7 +30175,7 @@ function parseMarkConversationRunsReadRequest(value) {
|
|
|
30131
30175
|
function isNonEmptyString(value) {
|
|
30132
30176
|
return typeof value === "string" && Boolean(value.trim());
|
|
30133
30177
|
}
|
|
30134
|
-
function
|
|
30178
|
+
function isRecord3(value) {
|
|
30135
30179
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
30136
30180
|
}
|
|
30137
30181
|
|
|
@@ -30767,12 +30811,12 @@ var CONVERSATION_CUSTOM_EVENT_NAMES = Object.freeze({
|
|
|
30767
30811
|
var MAX_CONVERSATION_FOLLOW_UP_QUESTIONS = 3;
|
|
30768
30812
|
var MAX_CONVERSATION_FOLLOW_UP_QUESTION_LENGTH = 20;
|
|
30769
30813
|
function parseConversationFollowUpQuestions(value) {
|
|
30770
|
-
if (!
|
|
30814
|
+
if (!isRecord4(value) || !Array.isArray(value.questions))
|
|
30771
30815
|
return void 0;
|
|
30772
30816
|
const seen = /* @__PURE__ */ new Set();
|
|
30773
30817
|
const questions = [];
|
|
30774
30818
|
for (const candidate of value.questions) {
|
|
30775
|
-
if (!
|
|
30819
|
+
if (!isRecord4(candidate))
|
|
30776
30820
|
continue;
|
|
30777
30821
|
const label = normalizeFollowUpText(candidate.label);
|
|
30778
30822
|
const prompt = normalizeFollowUpText(candidate.prompt);
|
|
@@ -30797,7 +30841,7 @@ function normalizeFollowUpText(value) {
|
|
|
30797
30841
|
const normalized = value.replace(/\s+/gu, " ").trim();
|
|
30798
30842
|
return normalized || void 0;
|
|
30799
30843
|
}
|
|
30800
|
-
function
|
|
30844
|
+
function isRecord4(value) {
|
|
30801
30845
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30802
30846
|
}
|
|
30803
30847
|
function createConversationCustomEvent(name, value, fields = {}) {
|
|
@@ -30826,7 +30870,7 @@ function parseConversationRunRequest(value) {
|
|
|
30826
30870
|
return value;
|
|
30827
30871
|
}
|
|
30828
30872
|
function getConversationRunRequestIssues(value) {
|
|
30829
|
-
if (!
|
|
30873
|
+
if (!isRecord5(value))
|
|
30830
30874
|
return ["request must be an object"];
|
|
30831
30875
|
const issues = [];
|
|
30832
30876
|
if (!isSupportedConversationProtocolVersion(value.protocolVersion)) {
|
|
@@ -30849,7 +30893,7 @@ function getConversationRunRequestIssues(value) {
|
|
|
30849
30893
|
} else {
|
|
30850
30894
|
value.attachments.forEach((attachment, index) => validateAttachment(attachment, index, issues));
|
|
30851
30895
|
}
|
|
30852
|
-
if (!
|
|
30896
|
+
if (!isRecord5(value.metadata))
|
|
30853
30897
|
issues.push("metadata must be an object");
|
|
30854
30898
|
if (value.clientCapabilities !== void 0) {
|
|
30855
30899
|
if (!Array.isArray(value.clientCapabilities)) {
|
|
@@ -30867,7 +30911,7 @@ function getConversationRunRequestIssues(value) {
|
|
|
30867
30911
|
return issues;
|
|
30868
30912
|
}
|
|
30869
30913
|
function validateMessage(value, index, issues) {
|
|
30870
|
-
if (!
|
|
30914
|
+
if (!isRecord5(value)) {
|
|
30871
30915
|
issues.push(`messages[${index}] must be an object`);
|
|
30872
30916
|
return;
|
|
30873
30917
|
}
|
|
@@ -30878,7 +30922,7 @@ function validateMessage(value, index, issues) {
|
|
|
30878
30922
|
}
|
|
30879
30923
|
if (value.content !== void 0) {
|
|
30880
30924
|
if (typeof value.content === "string") {
|
|
30881
|
-
} else if (
|
|
30925
|
+
} else if (isRecord5(value.content) && value.content.type === "a2ui.event") {
|
|
30882
30926
|
if (value.role !== "user") {
|
|
30883
30927
|
issues.push(`messages[${index}].content a2ui.event requires the user role`);
|
|
30884
30928
|
}
|
|
@@ -30902,21 +30946,21 @@ function validateA2UIEventContent(value, path2, issues) {
|
|
|
30902
30946
|
validateA2UIEventSource(value.source, `${path2}.source`, issues);
|
|
30903
30947
|
}
|
|
30904
30948
|
function validateA2UIEvent(value, path2, issues) {
|
|
30905
|
-
if (!
|
|
30949
|
+
if (!isRecord5(value)) {
|
|
30906
30950
|
issues.push(`${path2} must be an object`);
|
|
30907
30951
|
return;
|
|
30908
30952
|
}
|
|
30909
30953
|
if (!isSafeEventName(value.name)) {
|
|
30910
30954
|
issues.push(`${path2}.name must be a safe event name up to 96 characters`);
|
|
30911
30955
|
}
|
|
30912
|
-
if (!
|
|
30956
|
+
if (!isRecord5(value.payload)) {
|
|
30913
30957
|
issues.push(`${path2}.payload must be an object`);
|
|
30914
30958
|
return;
|
|
30915
30959
|
}
|
|
30916
30960
|
validateJsonValue(value.payload, `${path2}.payload`, issues);
|
|
30917
30961
|
}
|
|
30918
30962
|
function validateA2UIEventSource(value, path2, issues) {
|
|
30919
|
-
if (!
|
|
30963
|
+
if (!isRecord5(value)) {
|
|
30920
30964
|
issues.push(`${path2} must be an object`);
|
|
30921
30965
|
return;
|
|
30922
30966
|
}
|
|
@@ -30957,7 +31001,7 @@ function validateJsonValue(value, path2, issues) {
|
|
|
30957
31001
|
value.forEach((entry, index) => validateJsonValue(entry, `${path2}[${index}]`, issues));
|
|
30958
31002
|
return;
|
|
30959
31003
|
}
|
|
30960
|
-
if (!
|
|
31004
|
+
if (!isRecord5(value)) {
|
|
30961
31005
|
issues.push(`${path2} must be JSON-safe`);
|
|
30962
31006
|
return;
|
|
30963
31007
|
}
|
|
@@ -30970,7 +31014,7 @@ function validateJsonValue(value, path2, issues) {
|
|
|
30970
31014
|
}
|
|
30971
31015
|
}
|
|
30972
31016
|
function validateAttachment(value, index, issues) {
|
|
30973
|
-
if (!
|
|
31017
|
+
if (!isRecord5(value)) {
|
|
30974
31018
|
issues.push(`attachments[${index}] must be an object`);
|
|
30975
31019
|
return;
|
|
30976
31020
|
}
|
|
@@ -30988,11 +31032,11 @@ function validateAttachment(value, index, issues) {
|
|
|
30988
31032
|
if (value.size !== void 0 && (!Number.isSafeInteger(value.size) || Number(value.size) < 0)) {
|
|
30989
31033
|
issues.push(`attachments[${index}].size must be a non-negative safe integer when provided`);
|
|
30990
31034
|
}
|
|
30991
|
-
if (value.metadata !== void 0 && !
|
|
31035
|
+
if (value.metadata !== void 0 && !isRecord5(value.metadata)) {
|
|
30992
31036
|
issues.push(`attachments[${index}].metadata must be an object when provided`);
|
|
30993
31037
|
}
|
|
30994
31038
|
}
|
|
30995
|
-
function
|
|
31039
|
+
function isRecord5(value) {
|
|
30996
31040
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30997
31041
|
}
|
|
30998
31042
|
function isNonEmptyString2(value) {
|
|
@@ -31034,7 +31078,7 @@ function parseConversationHistoryRequest(value) {
|
|
|
31034
31078
|
return value;
|
|
31035
31079
|
}
|
|
31036
31080
|
function getConversationHistoryRequestIssues(value) {
|
|
31037
|
-
if (!
|
|
31081
|
+
if (!isRecord6(value))
|
|
31038
31082
|
return ["history request must be an object"];
|
|
31039
31083
|
const issues = [];
|
|
31040
31084
|
if (!isSupportedConversationProtocolVersion(value.protocolVersion)) {
|
|
@@ -31132,7 +31176,7 @@ var HISTORY_OPERATIONS = /* @__PURE__ */ new Set([
|
|
|
31132
31176
|
function isNonEmptyString3(value) {
|
|
31133
31177
|
return typeof value === "string" && Boolean(value.trim());
|
|
31134
31178
|
}
|
|
31135
|
-
function
|
|
31179
|
+
function isRecord6(value) {
|
|
31136
31180
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
31137
31181
|
}
|
|
31138
31182
|
|
|
@@ -31258,6 +31302,9 @@ function deriveScenarioRuntimeMacKey(accessKey) {
|
|
|
31258
31302
|
return Buffer.from(hkdfSync("sha256", Buffer.from(normalized, "utf8"), "linkque-scenario-agent-aak-v1", "linkque:scenario:runtime-mac:v1", 32));
|
|
31259
31303
|
}
|
|
31260
31304
|
function createGatewayRunAuthorization(options) {
|
|
31305
|
+
if (options.authorizationHeader !== `Scenario ${options.token}` || !/^lqs_[A-Za-z0-9_-]{43}$/u.test(options.token)) {
|
|
31306
|
+
throw new Error("scenario authorization credential mismatch");
|
|
31307
|
+
}
|
|
31261
31308
|
const base = new URL(options.baseUrl);
|
|
31262
31309
|
const key = deriveScenarioRuntimeMacKey(options.accessKey);
|
|
31263
31310
|
if (base.protocol !== "https:" || base.username || base.password || base.search || base.hash) {
|
|
@@ -31305,7 +31352,7 @@ function createGatewayRunAuthorization(options) {
|
|
|
31305
31352
|
redirect: "error",
|
|
31306
31353
|
signal: AbortSignal.timeout(5e3),
|
|
31307
31354
|
headers: {
|
|
31308
|
-
authorization:
|
|
31355
|
+
authorization: options.authorizationHeader,
|
|
31309
31356
|
"content-type": "application/json",
|
|
31310
31357
|
...signedHeaders(url2, body, previousProof ?? "")
|
|
31311
31358
|
},
|
|
@@ -38474,6 +38521,17 @@ function mapAgentEventToBaseEvents(event, messageId, thinkingId) {
|
|
|
38474
38521
|
}
|
|
38475
38522
|
return events;
|
|
38476
38523
|
}
|
|
38524
|
+
case "tool_result": {
|
|
38525
|
+
return [
|
|
38526
|
+
{
|
|
38527
|
+
type: EventType.TOOL_CALL_RESULT,
|
|
38528
|
+
toolCallId: event.toolCallId,
|
|
38529
|
+
messageId: event.messageId,
|
|
38530
|
+
role: "tool",
|
|
38531
|
+
content: event.content
|
|
38532
|
+
}
|
|
38533
|
+
];
|
|
38534
|
+
}
|
|
38477
38535
|
case "tool_end": {
|
|
38478
38536
|
return [{ type: EventType.TOOL_CALL_END, toolCallId: event.toolCallId }];
|
|
38479
38537
|
}
|
package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-CO4I3RJE.js → chunk-ICPH34ZQ.js}
RENAMED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
RUNTIME_CONFIG_DEFAULTS,
|
|
23
23
|
RuntimeConfigProvider,
|
|
24
24
|
isDebugLoggingEnabled
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-FH2M6YD6.js";
|
|
26
26
|
import {
|
|
27
27
|
__commonJS,
|
|
28
28
|
__require,
|
|
@@ -15310,7 +15310,7 @@ var LINKQUE_AUTHORIZATION_HEADER = "x-linkque-authorization";
|
|
|
15310
15310
|
var LinkqueGatewayAuthError = class extends Error {
|
|
15311
15311
|
code = "invalid_linkque_authorization";
|
|
15312
15312
|
status = 401;
|
|
15313
|
-
constructor(message = "X-Linkque-Authorization \u5FC5\u987B\u662F\u5355\u4E2A Bearer \u51ED\u636E") {
|
|
15313
|
+
constructor(message = "X-Linkque-Authorization \u5FC5\u987B\u662F\u5355\u4E2A Bearer \u6216 Scenario \u51ED\u636E") {
|
|
15314
15314
|
super(message);
|
|
15315
15315
|
this.name = "LinkqueGatewayAuthError";
|
|
15316
15316
|
}
|
|
@@ -15334,7 +15334,13 @@ function resolveLinkqueGatewayRequestAuth(headers, env = process.env, logCtx) {
|
|
|
15334
15334
|
logCtx?.error?.("[auth-resolve] stage=failed, reason=scenario-user-token-required");
|
|
15335
15335
|
throw new LinkqueGatewayAuthError("\u573A\u666F\u7528\u6237\u51ED\u8BC1\u7F3A\u5931\uFF0C\u8BF7\u4ECE\u90E8\u7F72\u5165\u53E3\u91CD\u65B0\u767B\u5F55");
|
|
15336
15336
|
}
|
|
15337
|
-
|
|
15337
|
+
const resolved = resolveLinkqueGatewayAuth(headers, env, logCtx);
|
|
15338
|
+
const isScenarioUser = /^lqs_[a-f0-9]{32}$/u.test(userId ?? "");
|
|
15339
|
+
if (isScenarioUser && resolved.mode !== "scenario-token" || !isScenarioUser && resolved.mode === "scenario-token") {
|
|
15340
|
+
logCtx?.error?.("[auth-resolve] stage=failed, reason=scenario-identity-mismatch");
|
|
15341
|
+
throw new LinkqueGatewayAuthError("\u573A\u666F\u7528\u6237\u8EAB\u4EFD\u4E0E\u51ED\u8BC1\u7C7B\u578B\u4E0D\u5339\u914D");
|
|
15342
|
+
}
|
|
15343
|
+
return resolved;
|
|
15338
15344
|
}
|
|
15339
15345
|
function resolveLinkqueGatewayAuth(headers, env = process.env, logCtx) {
|
|
15340
15346
|
const config = new AppbaseRuntimeConfigProvider({ ...env });
|
|
@@ -15344,7 +15350,7 @@ function resolveLinkqueGatewayAuth(headers, env = process.env, logCtx) {
|
|
|
15344
15350
|
const matches = Object.entries(headers ?? {}).filter(([key]) => key.toLowerCase() === LINKQUE_AUTHORIZATION_HEADER);
|
|
15345
15351
|
if (matches.length > 0) {
|
|
15346
15352
|
log(`stage=header-inspection, state=present, count=${matches.length}`);
|
|
15347
|
-
log("stage=
|
|
15353
|
+
log("stage=credential-validation, state=start");
|
|
15348
15354
|
if (matches.length !== 1) {
|
|
15349
15355
|
logError("stage=failed, reason=duplicate-header");
|
|
15350
15356
|
throw new LinkqueGatewayAuthError();
|
|
@@ -15358,19 +15364,25 @@ function resolveLinkqueGatewayAuth(headers, env = process.env, logCtx) {
|
|
|
15358
15364
|
logError("stage=failed, reason=joined-header");
|
|
15359
15365
|
throw new LinkqueGatewayAuthError();
|
|
15360
15366
|
}
|
|
15361
|
-
const match = /^Bearer[\t ]+([^\s,]+)$/iu.exec(value.trim());
|
|
15362
|
-
const
|
|
15367
|
+
const match = /^(Bearer|Scenario)[\t ]+([^\s,]+)$/iu.exec(value.trim());
|
|
15368
|
+
const scheme = match?.[1]?.toLowerCase();
|
|
15369
|
+
const token = match?.[2];
|
|
15363
15370
|
if (!token) {
|
|
15364
|
-
logError("stage=failed, reason=invalid-
|
|
15371
|
+
logError("stage=failed, reason=invalid-authorization-format");
|
|
15372
|
+
throw new LinkqueGatewayAuthError();
|
|
15373
|
+
}
|
|
15374
|
+
const scenario = scheme === "scenario";
|
|
15375
|
+
if (scenario ? !/^lqs_[A-Za-z0-9_-]{43}$/u.test(token) : token.startsWith("lqs_")) {
|
|
15376
|
+
logError("stage=failed, reason=credential-scheme-mismatch");
|
|
15365
15377
|
throw new LinkqueGatewayAuthError();
|
|
15366
15378
|
}
|
|
15367
|
-
log(
|
|
15379
|
+
log(`stage=credential-validation, state=success, scheme=${scenario ? "Scenario" : "Bearer"}`);
|
|
15368
15380
|
const provider2 = resolveProvider(config.get("LINKQUE_MODEL_PROVIDER"), log, logError);
|
|
15369
|
-
log(
|
|
15381
|
+
log(`stage=complete, mode=${scenario ? "scenario-token" : "user-token"}, source=request-header`);
|
|
15370
15382
|
return {
|
|
15371
|
-
mode: "user-token",
|
|
15383
|
+
mode: scenario ? "scenario-token" : "user-token",
|
|
15372
15384
|
modelCredential: token,
|
|
15373
|
-
authorizationHeader:
|
|
15385
|
+
authorizationHeader: `${scenario ? "Scenario" : "Bearer"} ${token}`,
|
|
15374
15386
|
auth: { provider: provider2, apiKey: token }
|
|
15375
15387
|
};
|
|
15376
15388
|
}
|
|
@@ -50,13 +50,13 @@ import {
|
|
|
50
50
|
resolveRunStorage,
|
|
51
51
|
toAgentRunMessages,
|
|
52
52
|
withIsoTimestamp
|
|
53
|
-
} from "../../chunk-
|
|
53
|
+
} from "../../chunk-ICPH34ZQ.js";
|
|
54
54
|
import "../../chunk-IWOFD643.js";
|
|
55
55
|
import "../../chunk-PXCGFBV5.js";
|
|
56
56
|
import "../../chunk-ETG6PNHQ.js";
|
|
57
57
|
import {
|
|
58
58
|
getBakedProtocol
|
|
59
|
-
} from "../../chunk-
|
|
59
|
+
} from "../../chunk-FC6S43DG.js";
|
|
60
60
|
import {
|
|
61
61
|
ACTIVATE_SKILL_TOOL_NAME,
|
|
62
62
|
CANCEL_CONVERSATION_RUN_OPERATION,
|
|
@@ -194,7 +194,7 @@ import {
|
|
|
194
194
|
warnLogFailure,
|
|
195
195
|
wrapToolWithHooks,
|
|
196
196
|
writeJsonPointer
|
|
197
|
-
} from "../../chunk-
|
|
197
|
+
} from "../../chunk-FH2M6YD6.js";
|
|
198
198
|
import "../../chunk-EAODRPW4.js";
|
|
199
199
|
import "../../chunk-XUFLSZM4.js";
|
|
200
200
|
import "../../chunk-GAYNLDWK.js";
|
|
@@ -43764,7 +43764,7 @@ var createLinkquegwEventHookResource = (resourceId, stage) => ({
|
|
|
43764
43764
|
hasSideEffects: false
|
|
43765
43765
|
}
|
|
43766
43766
|
});
|
|
43767
|
-
var
|
|
43767
|
+
var isGatewayAuthorization = (value) => /^Bearer[\t ]+[^\s,]+$/u.test(value) && !/^Bearer[\t ]+lqs_/u.test(value) || /^Scenario[\t ]+lqs_[A-Za-z0-9_-]{43}$/u.test(value);
|
|
43768
43768
|
var isLinkquegwEventHook = (resource, stage) => {
|
|
43769
43769
|
if (resource.resourceType !== EResourceType.HOOK)
|
|
43770
43770
|
return false;
|
|
@@ -43775,11 +43775,15 @@ var LinkquegwEventPlugin = class {
|
|
|
43775
43775
|
name = LINKQUEGW_EVENT_PLUGIN_NAME;
|
|
43776
43776
|
hookExecutorList;
|
|
43777
43777
|
constructor(options) {
|
|
43778
|
+
const getAuthorizationHeader = options.getGatewayAuthorizationHeader ?? options.getUserTokenAuthorizationHeader;
|
|
43779
|
+
if (!getAuthorizationHeader) {
|
|
43780
|
+
throw new Error("LinkqueGW event trigger \u7F3A\u5C11\u8BA4\u8BC1\u5934\u63D0\u4F9B\u5668");
|
|
43781
|
+
}
|
|
43778
43782
|
const executorOptions = {
|
|
43779
43783
|
getAuthHeaders: async () => {
|
|
43780
|
-
const authorization = await
|
|
43781
|
-
if (!
|
|
43782
|
-
throw new Error("LinkqueGW event trigger \u53EA\u5141\u8BB8\u5355\u4E2A Bearer
|
|
43784
|
+
const authorization = await getAuthorizationHeader();
|
|
43785
|
+
if (!isGatewayAuthorization(authorization)) {
|
|
43786
|
+
throw new Error("LinkqueGW event trigger \u53EA\u5141\u8BB8\u5355\u4E2A Bearer \u6216 Scenario \u51ED\u636E");
|
|
43783
43787
|
}
|
|
43784
43788
|
return {
|
|
43785
43789
|
authorization,
|
|
@@ -44262,7 +44266,7 @@ function createAppBaseRuntime(protocol, env = process.env, ports = {}, logCtx) {
|
|
|
44262
44266
|
...debugLog ? { debugLog } : {}
|
|
44263
44267
|
}) : void 0);
|
|
44264
44268
|
log("knowledgeSearchPort:", ports.knowledgeSearchPort ? "\u4F7F\u7528\u6CE8\u5165\u5B9E\u73B0" : mcpAuthHeader ? "LinkqueKnowledgeSearchPort(\u9274\u6743\u5934\u6A21\u5F0F,\u9ED8\u8BA4\u6D3E\u751F)" : "Noop(\u9ED8\u8BA4,\u65E0\u9274\u6743\u5934\u6E90)");
|
|
44265
|
-
const webSearchAuth = ports.webSearchAuthorizationHeaderProvider ?? (ports.gatewayAuthMode === "user-token" ? mcpAuthHeader : void 0);
|
|
44269
|
+
const webSearchAuth = ports.webSearchAuthorizationHeaderProvider ?? (ports.gatewayAuthMode === "user-token" || ports.gatewayAuthMode === "scenario-token" ? mcpAuthHeader : void 0);
|
|
44266
44270
|
runtimePorts.webSearchPort = ports.webSearchPort ?? new LinkqueWebSearchPort({
|
|
44267
44271
|
baseUrl: ports.webSearchBaseUrl,
|
|
44268
44272
|
getAuthHeaders: async () => webSearchAuth ? { authorization: await webSearchAuth() } : {},
|
|
@@ -44280,9 +44284,9 @@ function createAppBaseRuntime(protocol, env = process.env, ports = {}, logCtx) {
|
|
|
44280
44284
|
}
|
|
44281
44285
|
const hasLinkquegwEventPlugin = plugins.some((plugin) => plugin.name === LINKQUEGW_EVENT_PLUGIN_NAME);
|
|
44282
44286
|
const eventBaseUrl = ports.eventBaseUrl ?? ports.knowledgeBaseUrl;
|
|
44283
|
-
if (ports.gatewayAuthMode === "user-token" && mcpAuthHeader && !hasLinkquegwEventPlugin) {
|
|
44287
|
+
if ((ports.gatewayAuthMode === "user-token" || ports.gatewayAuthMode === "scenario-token") && mcpAuthHeader && !hasLinkquegwEventPlugin) {
|
|
44284
44288
|
plugins.push(new LinkquegwEventPlugin({
|
|
44285
|
-
|
|
44289
|
+
getGatewayAuthorizationHeader: mcpAuthHeader,
|
|
44286
44290
|
...eventBaseUrl ? { baseUrl: eventBaseUrl } : {},
|
|
44287
44291
|
...ports.gatewayAgentId ? { agentId: ports.gatewayAgentId } : {},
|
|
44288
44292
|
...ports.temporaryFrontendAppId !== void 0 && {
|
|
@@ -44311,7 +44315,7 @@ function createAppBaseRuntime(protocol, env = process.env, ports = {}, logCtx) {
|
|
|
44311
44315
|
function describeHookExecutorAssembly(ports, mcpAuthHeader, hasLinkquegwEventPlugin, plugins) {
|
|
44312
44316
|
if (ports.hookExecutorList) {
|
|
44313
44317
|
return "\u7AEF\u53E3\u5217\u8868\u4E0E\u63D2\u4EF6\u5217\u8868\u6309 name \u5408\u5E76";
|
|
44314
|
-
} else if (ports.gatewayAuthMode === "user-token" && mcpAuthHeader) {
|
|
44318
|
+
} else if ((ports.gatewayAuthMode === "user-token" || ports.gatewayAuthMode === "scenario-token") && mcpAuthHeader) {
|
|
44315
44319
|
if (hasLinkquegwEventPlugin) {
|
|
44316
44320
|
return "\u4F7F\u7528\u6CE8\u5165\u7684 LinkquegwEventPlugin";
|
|
44317
44321
|
} else {
|
|
@@ -45934,7 +45938,7 @@ async function publishConversationRunReadHooks(input) {
|
|
|
45934
45938
|
const { eventBaseUrl } = resolveLinkqueEndpoints(input.env, input.envSelector);
|
|
45935
45939
|
const debugLog = input.logCtx?.log ? (line) => input.logCtx?.log?.("[readStatus]", line) : void 0;
|
|
45936
45940
|
const plugin = new LinkquegwEventPlugin({
|
|
45937
|
-
|
|
45941
|
+
getGatewayAuthorizationHeader: async () => input.gatewayAuth?.authorizationHeader ?? "",
|
|
45938
45942
|
agentId: input.protocol.agentId,
|
|
45939
45943
|
...input.temporaryFrontendAppId !== void 0 && {
|
|
45940
45944
|
temporaryFrontendAppId: input.temporaryFrontendAppId
|
|
@@ -46275,7 +46279,7 @@ function createAppbaseTelemetry(options) {
|
|
|
46275
46279
|
authorization: {
|
|
46276
46280
|
subject: version,
|
|
46277
46281
|
version,
|
|
46278
|
-
mode: mode === "
|
|
46282
|
+
mode: mode === "aak" ? "aak" : mode === "scenario-token" ? "scenario" : "bearer",
|
|
46279
46283
|
agentId: options.agentId,
|
|
46280
46284
|
environment: options.environment,
|
|
46281
46285
|
getHeaders: () => ({
|
|
@@ -46475,14 +46479,15 @@ function resolveChatDeps(env, deps, logCtx, historyOwnerId, appwriteApiKey, envS
|
|
|
46475
46479
|
const isScenarioUser = /^lqs_[a-f0-9]{32}$/u.test(historyOwnerId ?? "");
|
|
46476
46480
|
if (!runAuthorization && isScenarioUser) {
|
|
46477
46481
|
try {
|
|
46478
|
-
if (resolved.mode !== "
|
|
46479
|
-
throw new Error("scenario
|
|
46482
|
+
if (resolved.mode !== "scenario-token")
|
|
46483
|
+
throw new Error("scenario token required");
|
|
46480
46484
|
const accessKey = env.LINKQUE_AGENT_ACCESS_KEY?.trim() ?? "";
|
|
46481
46485
|
if (!accessKey || !linkqueBaseUrl)
|
|
46482
46486
|
throw new Error("invalid config");
|
|
46483
46487
|
runAuthorization = createGatewayRunAuthorization({
|
|
46484
46488
|
baseUrl: linkqueBaseUrl,
|
|
46485
46489
|
token: resolved.modelCredential,
|
|
46490
|
+
authorizationHeader: resolved.authorizationHeader,
|
|
46486
46491
|
accessKey
|
|
46487
46492
|
});
|
|
46488
46493
|
} catch {
|
|
@@ -46514,7 +46519,7 @@ function resolveChatDeps(env, deps, logCtx, historyOwnerId, appwriteApiKey, envS
|
|
|
46514
46519
|
mcpServerProvider,
|
|
46515
46520
|
mcpConfigResolver,
|
|
46516
46521
|
mcpAuthorizationHeaderProvider,
|
|
46517
|
-
...resolved.mode === "user-token" ? {
|
|
46522
|
+
...resolved.mode === "user-token" || resolved.mode === "scenario-token" ? {
|
|
46518
46523
|
webSearchAuthorizationHeaderProvider: mcpAuthorizationHeaderProvider
|
|
46519
46524
|
} : {},
|
|
46520
46525
|
gatewayAuthMode: resolved.mode,
|
package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/clientCapability.js
CHANGED
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
runClientCapability,
|
|
4
4
|
runClientCapabilityCleanup,
|
|
5
5
|
runClientCapabilityResult
|
|
6
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-ICPH34ZQ.js";
|
|
7
7
|
import "../../chunk-IWOFD643.js";
|
|
8
8
|
import "../../chunk-PXCGFBV5.js";
|
|
9
9
|
import "../../chunk-ETG6PNHQ.js";
|
|
10
|
-
import "../../chunk-
|
|
10
|
+
import "../../chunk-FH2M6YD6.js";
|
|
11
11
|
import "../../chunk-EAODRPW4.js";
|
|
12
12
|
import "../../chunk-XUFLSZM4.js";
|
|
13
13
|
import "../../chunk-GAYNLDWK.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getBakedProtocol,
|
|
3
3
|
setBakedProtocol
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-FC6S43DG.js";
|
|
5
|
+
import "../chunk-FH2M6YD6.js";
|
|
6
6
|
import "../chunk-EAODRPW4.js";
|
|
7
7
|
import "../chunk-XUFLSZM4.js";
|
|
8
8
|
import "../chunk-GAYNLDWK.js";
|
package/worker.js
CHANGED
|
@@ -15792,6 +15792,46 @@ var init_webSearchResource = __esm({
|
|
|
15792
15792
|
}
|
|
15793
15793
|
});
|
|
15794
15794
|
|
|
15795
|
+
// ../linkque-agent-runtime/dist/esm/core/webSearchPresentation.js
|
|
15796
|
+
function projectWebSearchSources(result) {
|
|
15797
|
+
if (!isRecord2(result))
|
|
15798
|
+
return void 0;
|
|
15799
|
+
const value = result;
|
|
15800
|
+
if (value.error || typeof value.query !== "string" || !Array.isArray(value.items))
|
|
15801
|
+
return void 0;
|
|
15802
|
+
const items = value.items.slice(0, 10).flatMap((item) => {
|
|
15803
|
+
if (!isRecord2(item) || typeof item.id !== "string" || !item.id.trim() || typeof item.title !== "string" || !item.title.trim() || typeof item.content !== "string")
|
|
15804
|
+
return [];
|
|
15805
|
+
let url2;
|
|
15806
|
+
if (typeof item.url === "string") {
|
|
15807
|
+
try {
|
|
15808
|
+
const parsed = new URL(item.url);
|
|
15809
|
+
if (["http:", "https:"].includes(parsed.protocol) && !parsed.username && !parsed.password)
|
|
15810
|
+
url2 = parsed.href;
|
|
15811
|
+
} catch {
|
|
15812
|
+
}
|
|
15813
|
+
}
|
|
15814
|
+
return [
|
|
15815
|
+
{
|
|
15816
|
+
id: item.id.slice(0, 256),
|
|
15817
|
+
title: item.title.slice(0, 256),
|
|
15818
|
+
content: item.content.slice(0, 4e3),
|
|
15819
|
+
...url2 ? { url: url2 } : {},
|
|
15820
|
+
...typeof item.channel === "string" ? { channel: item.channel.slice(0, 64) } : {}
|
|
15821
|
+
}
|
|
15822
|
+
];
|
|
15823
|
+
});
|
|
15824
|
+
return items.length ? { query: value.query.slice(0, 2048), items } : void 0;
|
|
15825
|
+
}
|
|
15826
|
+
function isRecord2(value) {
|
|
15827
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
15828
|
+
}
|
|
15829
|
+
var init_webSearchPresentation = __esm({
|
|
15830
|
+
"../linkque-agent-runtime/dist/esm/core/webSearchPresentation.js"() {
|
|
15831
|
+
"use strict";
|
|
15832
|
+
}
|
|
15833
|
+
});
|
|
15834
|
+
|
|
15795
15835
|
// ../linkque-agent-runtime/dist/esm/core/createWebSearchTool.js
|
|
15796
15836
|
function createWebSearchTool(resource, searchPort, agentId, debugLog) {
|
|
15797
15837
|
return {
|
|
@@ -15828,6 +15868,15 @@ function createWebSearchTool(resource, searchPort, agentId, debugLog) {
|
|
|
15828
15868
|
const result = await waitWithSignal(() => searchPort.search({ agentId, ...parsed }, signal, context2?.observation), signal);
|
|
15829
15869
|
throwIfWebSearchAborted(signal);
|
|
15830
15870
|
count = result.items.length;
|
|
15871
|
+
const presentation = context2 ? projectWebSearchSources(result) : void 0;
|
|
15872
|
+
if (context2 && presentation) {
|
|
15873
|
+
context2.emit({
|
|
15874
|
+
type: "tool_result",
|
|
15875
|
+
toolCallId: context2.toolCallId,
|
|
15876
|
+
messageId: `${context2.toolCallId}:web-search-result`,
|
|
15877
|
+
content: JSON.stringify(presentation)
|
|
15878
|
+
});
|
|
15879
|
+
}
|
|
15831
15880
|
return result;
|
|
15832
15881
|
} catch (error40) {
|
|
15833
15882
|
if (signal?.aborted || error40 instanceof Error && error40.name === "AbortError") {
|
|
@@ -15852,6 +15901,7 @@ function createWebSearchTool(resource, searchPort, agentId, debugLog) {
|
|
|
15852
15901
|
var init_createWebSearchTool = __esm({
|
|
15853
15902
|
"../linkque-agent-runtime/dist/esm/core/createWebSearchTool.js"() {
|
|
15854
15903
|
"use strict";
|
|
15904
|
+
init_webSearchPresentation();
|
|
15855
15905
|
init_types();
|
|
15856
15906
|
init_webSearchTools();
|
|
15857
15907
|
init_abort();
|
|
@@ -34213,7 +34263,7 @@ function parseConversationRunRequest(value) {
|
|
|
34213
34263
|
return value;
|
|
34214
34264
|
}
|
|
34215
34265
|
function getConversationRunRequestIssues(value) {
|
|
34216
|
-
if (!
|
|
34266
|
+
if (!isRecord4(value))
|
|
34217
34267
|
return ["request must be an object"];
|
|
34218
34268
|
const issues = [];
|
|
34219
34269
|
if (!isSupportedConversationProtocolVersion(value.protocolVersion)) {
|
|
@@ -34236,7 +34286,7 @@ function getConversationRunRequestIssues(value) {
|
|
|
34236
34286
|
} else {
|
|
34237
34287
|
value.attachments.forEach((attachment, index2) => validateAttachment(attachment, index2, issues));
|
|
34238
34288
|
}
|
|
34239
|
-
if (!
|
|
34289
|
+
if (!isRecord4(value.metadata))
|
|
34240
34290
|
issues.push("metadata must be an object");
|
|
34241
34291
|
if (value.clientCapabilities !== void 0) {
|
|
34242
34292
|
if (!Array.isArray(value.clientCapabilities)) {
|
|
@@ -34254,7 +34304,7 @@ function getConversationRunRequestIssues(value) {
|
|
|
34254
34304
|
return issues;
|
|
34255
34305
|
}
|
|
34256
34306
|
function validateMessage(value, index2, issues) {
|
|
34257
|
-
if (!
|
|
34307
|
+
if (!isRecord4(value)) {
|
|
34258
34308
|
issues.push(`messages[${index2}] must be an object`);
|
|
34259
34309
|
return;
|
|
34260
34310
|
}
|
|
@@ -34265,7 +34315,7 @@ function validateMessage(value, index2, issues) {
|
|
|
34265
34315
|
}
|
|
34266
34316
|
if (value.content !== void 0) {
|
|
34267
34317
|
if (typeof value.content === "string") {
|
|
34268
|
-
} else if (
|
|
34318
|
+
} else if (isRecord4(value.content) && value.content.type === "a2ui.event") {
|
|
34269
34319
|
if (value.role !== "user") {
|
|
34270
34320
|
issues.push(`messages[${index2}].content a2ui.event requires the user role`);
|
|
34271
34321
|
}
|
|
@@ -34289,21 +34339,21 @@ function validateA2UIEventContent(value, path9, issues) {
|
|
|
34289
34339
|
validateA2UIEventSource(value.source, `${path9}.source`, issues);
|
|
34290
34340
|
}
|
|
34291
34341
|
function validateA2UIEvent(value, path9, issues) {
|
|
34292
|
-
if (!
|
|
34342
|
+
if (!isRecord4(value)) {
|
|
34293
34343
|
issues.push(`${path9} must be an object`);
|
|
34294
34344
|
return;
|
|
34295
34345
|
}
|
|
34296
34346
|
if (!isSafeEventName(value.name)) {
|
|
34297
34347
|
issues.push(`${path9}.name must be a safe event name up to 96 characters`);
|
|
34298
34348
|
}
|
|
34299
|
-
if (!
|
|
34349
|
+
if (!isRecord4(value.payload)) {
|
|
34300
34350
|
issues.push(`${path9}.payload must be an object`);
|
|
34301
34351
|
return;
|
|
34302
34352
|
}
|
|
34303
34353
|
validateJsonValue(value.payload, `${path9}.payload`, issues);
|
|
34304
34354
|
}
|
|
34305
34355
|
function validateA2UIEventSource(value, path9, issues) {
|
|
34306
|
-
if (!
|
|
34356
|
+
if (!isRecord4(value)) {
|
|
34307
34357
|
issues.push(`${path9} must be an object`);
|
|
34308
34358
|
return;
|
|
34309
34359
|
}
|
|
@@ -34344,7 +34394,7 @@ function validateJsonValue(value, path9, issues) {
|
|
|
34344
34394
|
value.forEach((entry, index2) => validateJsonValue(entry, `${path9}[${index2}]`, issues));
|
|
34345
34395
|
return;
|
|
34346
34396
|
}
|
|
34347
|
-
if (!
|
|
34397
|
+
if (!isRecord4(value)) {
|
|
34348
34398
|
issues.push(`${path9} must be JSON-safe`);
|
|
34349
34399
|
return;
|
|
34350
34400
|
}
|
|
@@ -34357,7 +34407,7 @@ function validateJsonValue(value, path9, issues) {
|
|
|
34357
34407
|
}
|
|
34358
34408
|
}
|
|
34359
34409
|
function validateAttachment(value, index2, issues) {
|
|
34360
|
-
if (!
|
|
34410
|
+
if (!isRecord4(value)) {
|
|
34361
34411
|
issues.push(`attachments[${index2}] must be an object`);
|
|
34362
34412
|
return;
|
|
34363
34413
|
}
|
|
@@ -34375,11 +34425,11 @@ function validateAttachment(value, index2, issues) {
|
|
|
34375
34425
|
if (value.size !== void 0 && (!Number.isSafeInteger(value.size) || Number(value.size) < 0)) {
|
|
34376
34426
|
issues.push(`attachments[${index2}].size must be a non-negative safe integer when provided`);
|
|
34377
34427
|
}
|
|
34378
|
-
if (value.metadata !== void 0 && !
|
|
34428
|
+
if (value.metadata !== void 0 && !isRecord4(value.metadata)) {
|
|
34379
34429
|
issues.push(`attachments[${index2}].metadata must be an object when provided`);
|
|
34380
34430
|
}
|
|
34381
34431
|
}
|
|
34382
|
-
function
|
|
34432
|
+
function isRecord4(value) {
|
|
34383
34433
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
34384
34434
|
}
|
|
34385
34435
|
function isNonEmptyString(value) {
|
|
@@ -34551,6 +34601,17 @@ function mapAgentEventToBaseEvents(event, messageId, thinkingId) {
|
|
|
34551
34601
|
}
|
|
34552
34602
|
return events;
|
|
34553
34603
|
}
|
|
34604
|
+
case "tool_result": {
|
|
34605
|
+
return [
|
|
34606
|
+
{
|
|
34607
|
+
type: EventType.TOOL_CALL_RESULT,
|
|
34608
|
+
toolCallId: event.toolCallId,
|
|
34609
|
+
messageId: event.messageId,
|
|
34610
|
+
role: "tool",
|
|
34611
|
+
content: event.content
|
|
34612
|
+
}
|
|
34613
|
+
];
|
|
34614
|
+
}
|
|
34554
34615
|
case "tool_end": {
|
|
34555
34616
|
return [{ type: EventType.TOOL_CALL_END, toolCallId: event.toolCallId }];
|
|
34556
34617
|
}
|
|
@@ -159917,13 +159978,13 @@ __export(pi_messages_exports, {
|
|
|
159917
159978
|
stream: () => stream10,
|
|
159918
159979
|
streamSimple: () => streamSimple9
|
|
159919
159980
|
});
|
|
159920
|
-
function
|
|
159981
|
+
function isRecord5(value) {
|
|
159921
159982
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
159922
159983
|
}
|
|
159923
159984
|
function parsePiMessagesErrorBody(body) {
|
|
159924
159985
|
try {
|
|
159925
159986
|
const parsed = JSON.parse(body);
|
|
159926
|
-
return
|
|
159987
|
+
return isRecord5(parsed) && isRecord5(parsed.error) ? parsed : void 0;
|
|
159927
159988
|
} catch {
|
|
159928
159989
|
return void 0;
|
|
159929
159990
|
}
|
|
@@ -196938,14 +196999,14 @@ var init_openrouter = __esm({
|
|
|
196938
196999
|
});
|
|
196939
197000
|
|
|
196940
197001
|
// ../../node_modules/@earendil-works/pi-ai/dist/providers/radius-config.js
|
|
196941
|
-
function
|
|
197002
|
+
function isRecord6(value) {
|
|
196942
197003
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
196943
197004
|
}
|
|
196944
197005
|
function isRadiusGatewayModel(value) {
|
|
196945
|
-
return
|
|
197006
|
+
return isRecord6(value) && typeof value.id === "string" && typeof value.name === "string" && typeof value.reasoning === "boolean" && Array.isArray(value.input) && isRecord6(value.cost) && typeof value.contextWindow === "number" && typeof value.maxTokens === "number";
|
|
196946
197007
|
}
|
|
196947
197008
|
function sanitizeRadiusGatewayConfig(config2) {
|
|
196948
|
-
if (!
|
|
197009
|
+
if (!isRecord6(config2) || typeof config2.baseUrl !== "string" || !Array.isArray(config2.models))
|
|
196949
197010
|
return void 0;
|
|
196950
197011
|
return {
|
|
196951
197012
|
baseUrl: config2.baseUrl,
|
|
@@ -206639,14 +206700,14 @@ function getToolUiStatusEnabledNames(descriptors) {
|
|
|
206639
206700
|
}
|
|
206640
206701
|
function decorateToolParametersWithUiStatus(value) {
|
|
206641
206702
|
const parameters = normalizeParameters(value);
|
|
206642
|
-
if (!
|
|
206703
|
+
if (!isRecord7(parameters) || parameters.type !== "object") {
|
|
206643
206704
|
return { parameters, enabled: false };
|
|
206644
206705
|
}
|
|
206645
206706
|
if ([...UNSAFE_TOOL_SCHEMA_KEYS].some((key) => key in parameters)) {
|
|
206646
206707
|
return { parameters, enabled: false };
|
|
206647
206708
|
}
|
|
206648
206709
|
const properties = parameters.properties;
|
|
206649
|
-
if (properties !== void 0 && !
|
|
206710
|
+
if (properties !== void 0 && !isRecord7(properties)) {
|
|
206650
206711
|
return { parameters, enabled: false };
|
|
206651
206712
|
}
|
|
206652
206713
|
const required2 = parameters.required;
|
|
@@ -206665,12 +206726,12 @@ function decorateToolParametersWithUiStatus(value) {
|
|
|
206665
206726
|
};
|
|
206666
206727
|
}
|
|
206667
206728
|
function stripToolUiStatusArgument(value) {
|
|
206668
|
-
if (!
|
|
206729
|
+
if (!isRecord7(value) || !(TOOL_UI_STATUS_ARGUMENT in value))
|
|
206669
206730
|
return value;
|
|
206670
206731
|
const { [TOOL_UI_STATUS_ARGUMENT]: _status, ...args } = value;
|
|
206671
206732
|
return args;
|
|
206672
206733
|
}
|
|
206673
|
-
function
|
|
206734
|
+
function isRecord7(value) {
|
|
206674
206735
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
206675
206736
|
}
|
|
206676
206737
|
function normalizeParameters(value) {
|
|
@@ -210685,7 +210746,7 @@ var init_imageUnderstandingPlugin = __esm({
|
|
|
210685
210746
|
});
|
|
210686
210747
|
|
|
210687
210748
|
// ../linkque-agent-runtime/dist/esm/impl/plugin/linkquegwEventPlugin.js
|
|
210688
|
-
var LINKQUEGW_EVENT_PLUGIN_NAME, LINKQUEGW_EVENT_HOOK_RESOURCE_ID, LINKQUEGW_RUN_COMPLETED_HOOK_RESOURCE_ID, LINKQUEGW_RUN_FAILED_HOOK_RESOURCE_ID, LINKQUEGW_RUN_READ_HOOK_RESOURCE_ID, DEFAULT_LINKQUEGW_EVENT_HOOKS, createLinkquegwEventHookResource,
|
|
210749
|
+
var LINKQUEGW_EVENT_PLUGIN_NAME, LINKQUEGW_EVENT_HOOK_RESOURCE_ID, LINKQUEGW_RUN_COMPLETED_HOOK_RESOURCE_ID, LINKQUEGW_RUN_FAILED_HOOK_RESOURCE_ID, LINKQUEGW_RUN_READ_HOOK_RESOURCE_ID, DEFAULT_LINKQUEGW_EVENT_HOOKS, createLinkquegwEventHookResource, isGatewayAuthorization, isLinkquegwEventHook, LinkquegwEventPlugin;
|
|
210689
210750
|
var init_linkquegwEventPlugin = __esm({
|
|
210690
210751
|
"../linkque-agent-runtime/dist/esm/impl/plugin/linkquegwEventPlugin.js"() {
|
|
210691
210752
|
"use strict";
|
|
@@ -210725,7 +210786,7 @@ var init_linkquegwEventPlugin = __esm({
|
|
|
210725
210786
|
hasSideEffects: false
|
|
210726
210787
|
}
|
|
210727
210788
|
});
|
|
210728
|
-
|
|
210789
|
+
isGatewayAuthorization = (value) => /^Bearer[\t ]+[^\s,]+$/u.test(value) && !/^Bearer[\t ]+lqs_/u.test(value) || /^Scenario[\t ]+lqs_[A-Za-z0-9_-]{43}$/u.test(value);
|
|
210729
210790
|
isLinkquegwEventHook = (resource, stage) => {
|
|
210730
210791
|
if (resource.resourceType !== EResourceType.HOOK)
|
|
210731
210792
|
return false;
|
|
@@ -210736,11 +210797,15 @@ var init_linkquegwEventPlugin = __esm({
|
|
|
210736
210797
|
name = LINKQUEGW_EVENT_PLUGIN_NAME;
|
|
210737
210798
|
hookExecutorList;
|
|
210738
210799
|
constructor(options) {
|
|
210800
|
+
const getAuthorizationHeader = options.getGatewayAuthorizationHeader ?? options.getUserTokenAuthorizationHeader;
|
|
210801
|
+
if (!getAuthorizationHeader) {
|
|
210802
|
+
throw new Error("LinkqueGW event trigger \u7F3A\u5C11\u8BA4\u8BC1\u5934\u63D0\u4F9B\u5668");
|
|
210803
|
+
}
|
|
210739
210804
|
const executorOptions = {
|
|
210740
210805
|
getAuthHeaders: async () => {
|
|
210741
|
-
const authorization = await
|
|
210742
|
-
if (!
|
|
210743
|
-
throw new Error("LinkqueGW event trigger \u53EA\u5141\u8BB8\u5355\u4E2A Bearer
|
|
210806
|
+
const authorization = await getAuthorizationHeader();
|
|
210807
|
+
if (!isGatewayAuthorization(authorization)) {
|
|
210808
|
+
throw new Error("LinkqueGW event trigger \u53EA\u5141\u8BB8\u5355\u4E2A Bearer \u6216 Scenario \u51ED\u636E");
|
|
210744
210809
|
}
|
|
210745
210810
|
return {
|
|
210746
210811
|
authorization,
|
|
@@ -217541,7 +217606,7 @@ var LocalHttpMcpServerProvider = class {
|
|
|
217541
217606
|
listTools: async (signal) => {
|
|
217542
217607
|
const response = await this.fetchImpl(toolsUrl, { signal });
|
|
217543
217608
|
const body = await readJsonResponse(response);
|
|
217544
|
-
if (!
|
|
217609
|
+
if (!isRecord3(body) || !Array.isArray(body.tools)) {
|
|
217545
217610
|
throw new Error(`Invalid local MCP tool catalog for ${resource.resourceId}`);
|
|
217546
217611
|
}
|
|
217547
217612
|
return body.tools.map((value) => this.createDescriptor(resource.resourceId, value));
|
|
@@ -217550,16 +217615,16 @@ var LocalHttpMcpServerProvider = class {
|
|
|
217550
217615
|
};
|
|
217551
217616
|
}
|
|
217552
217617
|
createDescriptor(resourceId, value) {
|
|
217553
|
-
if (!
|
|
217618
|
+
if (!isRecord3(value) || typeof value.name !== "string") {
|
|
217554
217619
|
throw new Error(`Invalid local MCP tool descriptor for ${resourceId}`);
|
|
217555
217620
|
}
|
|
217556
217621
|
return {
|
|
217557
217622
|
name: value.name,
|
|
217558
217623
|
resourceId,
|
|
217559
217624
|
...typeof value.description === "string" ? { description: value.description } : {},
|
|
217560
|
-
...
|
|
217561
|
-
...
|
|
217562
|
-
...
|
|
217625
|
+
...isRecord3(value.inputSchema) ? { inputSchema: value.inputSchema } : {},
|
|
217626
|
+
...isRecord3(value.outputSchema) ? { outputSchema: value.outputSchema } : {},
|
|
217627
|
+
...isRecord3(value.annotations) ? { annotations: value.annotations } : {},
|
|
217563
217628
|
execute: (args, signal, context2) => this.callTool(resourceId, value.name, args, signal, {
|
|
217564
217629
|
context: context2,
|
|
217565
217630
|
toolSchema: {
|
|
@@ -217591,7 +217656,7 @@ async function readJsonResponse(response) {
|
|
|
217591
217656
|
const raw = await response.json().catch(() => void 0);
|
|
217592
217657
|
const value = raw === void 0 ? void 0 : JSON.parse(JSON.stringify(raw));
|
|
217593
217658
|
if (!response.ok) {
|
|
217594
|
-
const message =
|
|
217659
|
+
const message = isRecord3(value) && typeof value.message === "string" ? value.message : `Local MCP fixture request failed with ${response.status}`;
|
|
217595
217660
|
throw new Error(message);
|
|
217596
217661
|
}
|
|
217597
217662
|
return value;
|
|
@@ -217602,7 +217667,7 @@ function ensureTrailingSlash(url2) {
|
|
|
217602
217667
|
next.pathname += "/";
|
|
217603
217668
|
return next;
|
|
217604
217669
|
}
|
|
217605
|
-
function
|
|
217670
|
+
function isRecord3(value) {
|
|
217606
217671
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
217607
217672
|
}
|
|
217608
217673
|
|
|
@@ -220285,10 +220350,10 @@ var handleFunctionActionMcp = async (req, res, input) => {
|
|
|
220285
220350
|
}
|
|
220286
220351
|
};
|
|
220287
220352
|
var parseHomeDataProxyInput = (value) => {
|
|
220288
|
-
const trustedContext =
|
|
220289
|
-
const trustedUserId =
|
|
220353
|
+
const trustedContext = isRecord8(value) ? value[HOME_DATA_TRUSTED_CONTEXT_FIELD] : void 0;
|
|
220354
|
+
const trustedUserId = isRecord8(trustedContext) ? trustedContext.userId : void 0;
|
|
220290
220355
|
const normalizedUserId = typeof trustedUserId === "string" ? trustedUserId.trim() : "";
|
|
220291
|
-
if (!
|
|
220356
|
+
if (!isRecord8(value) || !normalizedUserId) {
|
|
220292
220357
|
throw new Error("home-data trusted user is invalid");
|
|
220293
220358
|
}
|
|
220294
220359
|
const request = { ...value };
|
|
@@ -220296,9 +220361,9 @@ var parseHomeDataProxyInput = (value) => {
|
|
|
220296
220361
|
return { request, userId: normalizedUserId };
|
|
220297
220362
|
};
|
|
220298
220363
|
var parseFunctionActionMcpProxyInput = (value) => {
|
|
220299
|
-
if (!
|
|
220364
|
+
if (!isRecord8(value)) throw new Error("function action request is invalid");
|
|
220300
220365
|
const trustedContext = value._trustedContext_;
|
|
220301
|
-
const userId =
|
|
220366
|
+
const userId = isRecord8(trustedContext) && typeof trustedContext.userId === "string" ? trustedContext.userId.trim() : "";
|
|
220302
220367
|
if (!userId) {
|
|
220303
220368
|
throw new Error("function action trusted context is invalid");
|
|
220304
220369
|
}
|
|
@@ -220310,7 +220375,7 @@ var writeJson = (res, status, value) => {
|
|
|
220310
220375
|
res.writeHead(status, { "content-type": "application/json; charset=utf-8" });
|
|
220311
220376
|
res.end(JSON.stringify(value));
|
|
220312
220377
|
};
|
|
220313
|
-
var
|
|
220378
|
+
var isRecord8 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
220314
220379
|
var errorMessage3 = (error40) => error40 instanceof Error ? error40.message : "unknown agent error";
|
|
220315
220380
|
var main = async () => {
|
|
220316
220381
|
const input = decodeInput();
|