linkque-cli-v2 1.0.7 → 1.1.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 +42 -11
- package/package.json +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-FJ2BZPIM.js → chunk-MN4S5EF5.js} +237 -79
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js +77 -10
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js +1 -1
- package/worker.js +406 -117
|
@@ -31,6 +31,9 @@ import {
|
|
|
31
31
|
DEFAULT_CONVERSATION_LIST_LIMIT,
|
|
32
32
|
DEFAULT_CONVERSATION_RUN_LIST_LIMIT,
|
|
33
33
|
DEFAULT_CONVERSATION_SEARCH_LIMIT,
|
|
34
|
+
EHookExecutorName,
|
|
35
|
+
EHookStage,
|
|
36
|
+
EResourceProviderType,
|
|
34
37
|
EResourceType,
|
|
35
38
|
ESkillUrlScheme,
|
|
36
39
|
EventType,
|
|
@@ -48,7 +51,7 @@ import {
|
|
|
48
51
|
parseConversationRunRequest,
|
|
49
52
|
parseSkillFile,
|
|
50
53
|
streamToConversationEvents
|
|
51
|
-
} from "../../chunk-
|
|
54
|
+
} from "../../chunk-MN4S5EF5.js";
|
|
52
55
|
import "../../chunk-XUFLSZM4.js";
|
|
53
56
|
import "../../chunk-I64V3ICJ.js";
|
|
54
57
|
import "../../chunk-6MHDOBWO.js";
|
|
@@ -62,6 +65,61 @@ import "../../chunk-VS2QQHAK.js";
|
|
|
62
65
|
// ../linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js
|
|
63
66
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
64
67
|
|
|
68
|
+
// ../linkque-agent-runtime/dist/esm/impl/plugin/linkquegwEventPlugin.js
|
|
69
|
+
var LINKQUEGW_EVENT_PLUGIN_NAME = "linkquegw-event-plugin";
|
|
70
|
+
var LINKQUEGW_EVENT_HOOK_RESOURCE_ID = "linkquegw-event-run-started";
|
|
71
|
+
var createLinkquegwEventHookResource = () => ({
|
|
72
|
+
resourceId: LINKQUEGW_EVENT_HOOK_RESOURCE_ID,
|
|
73
|
+
resourceType: EResourceType.HOOK,
|
|
74
|
+
providerType: EResourceProviderType.LINK_QUE,
|
|
75
|
+
config: {
|
|
76
|
+
name: "LinkqueGW \u751F\u547D\u5468\u671F\u4E8B\u4EF6\u4E0A\u62A5",
|
|
77
|
+
executorName: EHookExecutorName.LinkquegwEventHookExecutor,
|
|
78
|
+
stage: EHookStage.RUN_STARTED,
|
|
79
|
+
hasSideEffects: true
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
var isUserTokenAuthorization = (value) => /^Bearer[\t ]+[^\s,]+$/u.test(value);
|
|
83
|
+
var isLinkquegwRunStartedHook = (resource) => {
|
|
84
|
+
if (resource.resourceType !== EResourceType.HOOK)
|
|
85
|
+
return false;
|
|
86
|
+
const hookResource = resource;
|
|
87
|
+
return hookResource.config.executorName === EHookExecutorName.LinkquegwEventHookExecutor && hookResource.config.stage === EHookStage.RUN_STARTED;
|
|
88
|
+
};
|
|
89
|
+
var LinkquegwEventPlugin = class {
|
|
90
|
+
name = LINKQUEGW_EVENT_PLUGIN_NAME;
|
|
91
|
+
hookExecutorList;
|
|
92
|
+
constructor(options) {
|
|
93
|
+
const executorOptions = {
|
|
94
|
+
getAuthHeaders: async () => {
|
|
95
|
+
const authorization = await options.getUserTokenAuthorizationHeader();
|
|
96
|
+
if (!isUserTokenAuthorization(authorization)) {
|
|
97
|
+
throw new Error("LinkqueGW event trigger \u53EA\u5141\u8BB8\u5355\u4E2A Bearer user token");
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
authorization,
|
|
101
|
+
...options.agentId ? { "x-linkque-agent-id": options.agentId } : {}
|
|
102
|
+
};
|
|
103
|
+
},
|
|
104
|
+
...options.baseUrl !== void 0 && { baseUrl: options.baseUrl },
|
|
105
|
+
...options.fetchImpl !== void 0 && { fetchImpl: options.fetchImpl },
|
|
106
|
+
...options.debugLog !== void 0 && { debugLog: options.debugLog },
|
|
107
|
+
...options.metricsSink !== void 0 && {
|
|
108
|
+
metricsSink: options.metricsSink
|
|
109
|
+
},
|
|
110
|
+
...options.now !== void 0 && { now: options.now }
|
|
111
|
+
};
|
|
112
|
+
this.hookExecutorList = [new LinkquegwEventHookExecutor(executorOptions)];
|
|
113
|
+
}
|
|
114
|
+
/** 自动补入 event trigger 所需 HookResource;已有同 executorName + stage 时保持原配置。 */
|
|
115
|
+
modifyAgentConfig(agentConfig) {
|
|
116
|
+
const exists = agentConfig.agent.resources.some(isLinkquegwRunStartedHook);
|
|
117
|
+
if (exists)
|
|
118
|
+
return;
|
|
119
|
+
agentConfig.agent.resources.push(createLinkquegwEventHookResource());
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
65
123
|
// ../linkque-agent-appwrite-integrate/dist/esm/runtime/ports/appbaseSessionManager.js
|
|
66
124
|
var AppbaseSessionManager = class {
|
|
67
125
|
store;
|
|
@@ -290,15 +348,23 @@ function createAppBaseRuntime(protocol, env = process.env, ports = {}, logCtx) {
|
|
|
290
348
|
...debugLog ? { debugLog } : {}
|
|
291
349
|
}) : void 0);
|
|
292
350
|
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)");
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
351
|
+
if (ports.hookExecutorList) {
|
|
352
|
+
runtimePorts.hookExecutorList = ports.hookExecutorList;
|
|
353
|
+
}
|
|
354
|
+
const plugins = [...ports.plugins ?? []];
|
|
355
|
+
const hasLinkquegwEventPlugin = plugins.some((plugin) => plugin.name === LINKQUEGW_EVENT_PLUGIN_NAME);
|
|
356
|
+
if (ports.gatewayAuthMode === "user-token" && mcpAuthHeader && !hasLinkquegwEventPlugin) {
|
|
357
|
+
plugins.push(new LinkquegwEventPlugin({
|
|
358
|
+
getUserTokenAuthorizationHeader: mcpAuthHeader,
|
|
359
|
+
...ports.knowledgeBaseUrl ? { baseUrl: ports.knowledgeBaseUrl } : {},
|
|
360
|
+
...ports.gatewayAgentId ? { agentId: ports.gatewayAgentId } : {},
|
|
361
|
+
...debugLog ? { debugLog } : {}
|
|
362
|
+
}));
|
|
363
|
+
}
|
|
364
|
+
if (plugins.length > 0) {
|
|
365
|
+
runtimePorts.plugins = plugins;
|
|
366
|
+
}
|
|
367
|
+
log("hookExecutorList:", ports.hookExecutorList ? "\u7AEF\u53E3\u5217\u8868\u4E0E\u63D2\u4EF6\u5217\u8868\u6309 name \u5408\u5E76" : ports.gatewayAuthMode === "user-token" && mcpAuthHeader ? hasLinkquegwEventPlugin ? "\u4F7F\u7528\u6CE8\u5165\u7684 LinkquegwEventPlugin" : "LinkquegwEventPlugin(user-token,\u9ED8\u8BA4\u6CE8\u5165)" : ports.gatewayAuthMode === "aak" ? "Noop(AAK \u6A21\u5F0F\u4E0D\u89E6\u53D1 user-token-only event)" : plugins.length > 0 ? "\u4F7F\u7528\u6CE8\u5165\u63D2\u4EF6" : "Noop(\u9ED8\u8BA4,\u65E0 user token)");
|
|
302
368
|
if (debugLog) {
|
|
303
369
|
runtimePorts.debugLog = debugLog;
|
|
304
370
|
log("debugLog: \u6CE8\u5165 runtime(\u7EDF\u4E00 ctx.log sink)");
|
|
@@ -1688,6 +1754,7 @@ function resolveChatDeps(env, deps, logCtx, historyOwnerId, appwriteApiKey, envS
|
|
|
1688
1754
|
...appwriteApiKey ? { appBaseApiKey: appwriteApiKey } : {},
|
|
1689
1755
|
mcpConfigResolver,
|
|
1690
1756
|
mcpAuthorizationHeaderProvider,
|
|
1757
|
+
gatewayAuthMode: resolved.mode,
|
|
1691
1758
|
gatewayAgentId: protocol.agentId,
|
|
1692
1759
|
...linkqueBaseUrl ? { linkqueBaseUrl } : {},
|
|
1693
1760
|
...knowledgeBaseUrl ? { knowledgeBaseUrl } : {}
|