linkque-cli-v2 1.2.1 → 1.2.2
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 +674 -349
- package/package.json +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-IXJFWSVE.js → chunk-7YMZ4CJ5.js} +134 -39
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-NRTXRI33.js → chunk-F3IESVDW.js} +27 -6
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js +348 -21
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/clientCapability.js +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js +1 -1
- package/worker.js +81 -16
package/worker.js
CHANGED
|
@@ -5024,6 +5024,7 @@ var init_agentProtocol = __esm({
|
|
|
5024
5024
|
EHookStage2["RUN_STARTED"] = "RUN_STARTED";
|
|
5025
5025
|
EHookStage2["RUN_COMPLETED"] = "RUN_COMPLETED";
|
|
5026
5026
|
EHookStage2["RUN_FAILED"] = "RUN_FAILED";
|
|
5027
|
+
EHookStage2["RUN_READ"] = "RUN_READ";
|
|
5027
5028
|
EHookStage2["BEFORE_TOOL_CALL"] = "BEFORE_TOOL_CALL";
|
|
5028
5029
|
EHookStage2["AFTER_TOOL_CALL"] = "AFTER_TOOL_CALL";
|
|
5029
5030
|
EHookStage2["TOOL_CALL_FAILED"] = "TOOL_CALL_FAILED";
|
|
@@ -15390,6 +15391,7 @@ var init_authoring_model = __esm({
|
|
|
15390
15391
|
"use strict";
|
|
15391
15392
|
init_binding_analyzer();
|
|
15392
15393
|
init_json2();
|
|
15394
|
+
init_payment_action();
|
|
15393
15395
|
init_validation();
|
|
15394
15396
|
}
|
|
15395
15397
|
});
|
|
@@ -16426,15 +16428,27 @@ async function verifyPaymentResult(input) {
|
|
|
16426
16428
|
function resolvePaymentBinding(protocol, source, actionId) {
|
|
16427
16429
|
const card = protocol.agent.resources.find((resource) => resource.resourceType === EResourceType.CARD && resource.resourceId === source.cardRef);
|
|
16428
16430
|
if (!card)
|
|
16429
|
-
return {
|
|
16431
|
+
return {
|
|
16432
|
+
ok: false,
|
|
16433
|
+
response: failure2("CARD_NOT_FOUND", "\u652F\u4ED8\u5361\u7247\u4E0D\u5B58\u5728", false)
|
|
16434
|
+
};
|
|
16430
16435
|
if (card.config.revision !== source.cardRevision) {
|
|
16431
|
-
return {
|
|
16436
|
+
return {
|
|
16437
|
+
ok: false,
|
|
16438
|
+
response: failure2("CARD_REVISION_MISMATCH", "\u652F\u4ED8\u5361\u7247\u7248\u672C\u5DF2\u53D8\u5316\uFF0C\u8BF7\u5237\u65B0\u540E\u91CD\u8BD5", false)
|
|
16439
|
+
};
|
|
16432
16440
|
}
|
|
16433
16441
|
const binding = card.config.schemaVersion === "3" ? card.config.actionBindings?.find((candidate) => candidate.actionId === actionId) : void 0;
|
|
16434
16442
|
if (!binding)
|
|
16435
|
-
return {
|
|
16443
|
+
return {
|
|
16444
|
+
ok: false,
|
|
16445
|
+
response: failure2("ACTION_NOT_FOUND", "\u652F\u4ED8\u52A8\u4F5C\u672A\u7ED1\u5B9A", false)
|
|
16446
|
+
};
|
|
16436
16447
|
if (binding.kind !== "payment") {
|
|
16437
|
-
return {
|
|
16448
|
+
return {
|
|
16449
|
+
ok: false,
|
|
16450
|
+
response: failure2("ACTION_KIND_MISMATCH", "\u52A8\u4F5C\u4E0D\u662F\u652F\u4ED8\u7C7B\u578B", false)
|
|
16451
|
+
};
|
|
16438
16452
|
}
|
|
16439
16453
|
return { ok: true, binding };
|
|
16440
16454
|
}
|
|
@@ -16915,6 +16929,9 @@ var init_hookDispatcher = __esm({
|
|
|
16915
16929
|
run: {
|
|
16916
16930
|
...subject.runDurationMs !== void 0 && {
|
|
16917
16931
|
durationMs: subject.runDurationMs
|
|
16932
|
+
},
|
|
16933
|
+
...subject.messageContent !== void 0 && {
|
|
16934
|
+
messageContent: subject.messageContent
|
|
16918
16935
|
}
|
|
16919
16936
|
}
|
|
16920
16937
|
};
|
|
@@ -16924,6 +16941,12 @@ var init_hookDispatcher = __esm({
|
|
|
16924
16941
|
stage: EHookStage.RUN_FAILED,
|
|
16925
16942
|
error: subject.error ?? { message: "unknown error" }
|
|
16926
16943
|
};
|
|
16944
|
+
case EHookStage.RUN_READ:
|
|
16945
|
+
return {
|
|
16946
|
+
...base,
|
|
16947
|
+
stage: EHookStage.RUN_READ,
|
|
16948
|
+
read: { readAt: subject.readAt ?? now() }
|
|
16949
|
+
};
|
|
16927
16950
|
case EHookStage.BEFORE_TOOL_CALL:
|
|
16928
16951
|
return {
|
|
16929
16952
|
...base,
|
|
@@ -16958,7 +16981,9 @@ var init_hookDispatcher = __esm({
|
|
|
16958
16981
|
eventId: context2.eventId,
|
|
16959
16982
|
runId: context2.commonParams.runId,
|
|
16960
16983
|
conversationId: context2.commonParams.conversationId,
|
|
16961
|
-
|
|
16984
|
+
...context2.commonParams.runIndex !== void 0 && {
|
|
16985
|
+
runIndex: context2.commonParams.runIndex
|
|
16986
|
+
},
|
|
16962
16987
|
agentId: context2.commonParams.agentId,
|
|
16963
16988
|
...context2.commonParams.sessionId !== void 0 && {
|
|
16964
16989
|
sessionId: context2.commonParams.sessionId
|
|
@@ -16989,7 +17014,9 @@ var init_hookDispatcher = __esm({
|
|
|
16989
17014
|
eventId: context2.eventId,
|
|
16990
17015
|
runId: context2.commonParams.runId,
|
|
16991
17016
|
conversationId: context2.commonParams.conversationId,
|
|
16992
|
-
|
|
17017
|
+
...context2.commonParams.runIndex !== void 0 && {
|
|
17018
|
+
runIndex: context2.commonParams.runIndex
|
|
17019
|
+
},
|
|
16993
17020
|
agentId: context2.commonParams.agentId,
|
|
16994
17021
|
...context2.commonParams.sessionId !== void 0 && {
|
|
16995
17022
|
sessionId: context2.commonParams.sessionId
|
|
@@ -17017,7 +17044,9 @@ var init_hookDispatcher = __esm({
|
|
|
17017
17044
|
eventId: context2.eventId,
|
|
17018
17045
|
runId: context2.commonParams.runId,
|
|
17019
17046
|
conversationId: context2.commonParams.conversationId,
|
|
17020
|
-
|
|
17047
|
+
...context2.commonParams.runIndex !== void 0 && {
|
|
17048
|
+
runIndex: context2.commonParams.runIndex
|
|
17049
|
+
},
|
|
17021
17050
|
agentId: context2.commonParams.agentId,
|
|
17022
17051
|
...context2.commonParams.sessionId !== void 0 && {
|
|
17023
17052
|
sessionId: context2.commonParams.sessionId
|
|
@@ -17182,7 +17211,9 @@ var init_sideEffectRunner = __esm({
|
|
|
17182
17211
|
eventId: context2.eventId,
|
|
17183
17212
|
runId: context2.commonParams.runId,
|
|
17184
17213
|
conversationId: context2.commonParams.conversationId,
|
|
17185
|
-
|
|
17214
|
+
...context2.commonParams.runIndex !== void 0 && {
|
|
17215
|
+
runIndex: context2.commonParams.runIndex
|
|
17216
|
+
},
|
|
17186
17217
|
agentId: context2.commonParams.agentId,
|
|
17187
17218
|
...context2.commonParams.sessionId !== void 0 && {
|
|
17188
17219
|
sessionId: context2.commonParams.sessionId
|
|
@@ -17484,11 +17515,22 @@ var init_httpLoggingFetch = __esm({
|
|
|
17484
17515
|
});
|
|
17485
17516
|
|
|
17486
17517
|
// ../linkque-agent-runtime/dist/esm/core/hook/linkquegwEventHookExecutor.js
|
|
17487
|
-
function
|
|
17518
|
+
function truncateMessageContent(messageContent) {
|
|
17519
|
+
return Array.from(messageContent).slice(0, LINKQUEGW_MESSAGE_CONTENT_MAX_LENGTH).join("");
|
|
17520
|
+
}
|
|
17521
|
+
function buildLinkquegwEventBody(context2, temporaryFrontendAppId) {
|
|
17488
17522
|
const eventType = LINKQUEGW_EVENT_TYPE_BY_STAGE[context2.stage];
|
|
17489
17523
|
if (eventType === void 0)
|
|
17490
17524
|
return void 0;
|
|
17491
17525
|
const { commonParams } = context2;
|
|
17526
|
+
const payload = {
|
|
17527
|
+
...temporaryFrontendAppId !== void 0 && {
|
|
17528
|
+
appId: temporaryFrontendAppId
|
|
17529
|
+
},
|
|
17530
|
+
...context2.stage === EHookStage.RUN_COMPLETED && context2.run.messageContent !== void 0 && {
|
|
17531
|
+
messageContent: truncateMessageContent(context2.run.messageContent)
|
|
17532
|
+
}
|
|
17533
|
+
};
|
|
17492
17534
|
return {
|
|
17493
17535
|
agentId: commonParams.agentId,
|
|
17494
17536
|
eventType,
|
|
@@ -17501,10 +17543,16 @@ function buildLinkquegwEventBody(context2) {
|
|
|
17501
17543
|
sessionId: commonParams.sessionId
|
|
17502
17544
|
},
|
|
17503
17545
|
runId: commonParams.runId,
|
|
17504
|
-
|
|
17546
|
+
...commonParams.runIndex !== void 0 && {
|
|
17547
|
+
runIndex: commonParams.runIndex
|
|
17548
|
+
},
|
|
17549
|
+
...context2.stage === EHookStage.RUN_READ && {
|
|
17550
|
+
readAt: context2.read.readAt
|
|
17551
|
+
},
|
|
17552
|
+
...Object.keys(payload).length > 0 && { payload }
|
|
17505
17553
|
};
|
|
17506
17554
|
}
|
|
17507
|
-
var DEFAULT_LINKQUEGW_EVENT_BASE_URL, LINKQUEGW_AGENT_EVENT_TRIGGER_PATH, LINKQUEGW_EVENT_TYPE_BY_STAGE, LinkquegwEventHookExecutor;
|
|
17555
|
+
var DEFAULT_LINKQUEGW_EVENT_BASE_URL, LINKQUEGW_AGENT_EVENT_TRIGGER_PATH, LINKQUEGW_MESSAGE_CONTENT_MAX_LENGTH, LINKQUEGW_EVENT_TYPE_BY_STAGE, LinkquegwEventHookExecutor;
|
|
17508
17556
|
var init_linkquegwEventHookExecutor = __esm({
|
|
17509
17557
|
"../linkque-agent-runtime/dist/esm/core/hook/linkquegwEventHookExecutor.js"() {
|
|
17510
17558
|
"use strict";
|
|
@@ -17513,10 +17561,12 @@ var init_linkquegwEventHookExecutor = __esm({
|
|
|
17513
17561
|
init_hookMetrics();
|
|
17514
17562
|
DEFAULT_LINKQUEGW_EVENT_BASE_URL = "https://linkquegw.alipay.com";
|
|
17515
17563
|
LINKQUEGW_AGENT_EVENT_TRIGGER_PATH = "/api/agent/event/trigger";
|
|
17564
|
+
LINKQUEGW_MESSAGE_CONTENT_MAX_LENGTH = 2048;
|
|
17516
17565
|
LINKQUEGW_EVENT_TYPE_BY_STAGE = {
|
|
17517
17566
|
[EHookStage.RUN_STARTED]: "RUN_STARTED",
|
|
17518
17567
|
[EHookStage.RUN_COMPLETED]: "RUN_ENDED",
|
|
17519
|
-
[EHookStage.RUN_FAILED]: "RUN_ENDED"
|
|
17568
|
+
[EHookStage.RUN_FAILED]: "RUN_ENDED",
|
|
17569
|
+
[EHookStage.RUN_READ]: "RUN_READ"
|
|
17520
17570
|
};
|
|
17521
17571
|
LinkquegwEventHookExecutor = class {
|
|
17522
17572
|
name = EHookExecutorName.LinkquegwEventHookExecutor;
|
|
@@ -17524,6 +17574,7 @@ var init_linkquegwEventHookExecutor = __esm({
|
|
|
17524
17574
|
getAuthHeaders;
|
|
17525
17575
|
fetchImpl;
|
|
17526
17576
|
metricsSink;
|
|
17577
|
+
temporaryFrontendAppId;
|
|
17527
17578
|
now;
|
|
17528
17579
|
constructor(options) {
|
|
17529
17580
|
this.baseUrl = options.baseUrl ?? DEFAULT_LINKQUEGW_EVENT_BASE_URL;
|
|
@@ -17531,6 +17582,7 @@ var init_linkquegwEventHookExecutor = __esm({
|
|
|
17531
17582
|
const baseFetch = options.fetchImpl ?? globalThis.fetch;
|
|
17532
17583
|
this.fetchImpl = options.debugLog ? createHttpLoggingFetch(options.debugLog, "hook-linkque", baseFetch) : baseFetch;
|
|
17533
17584
|
this.metricsSink = options.metricsSink;
|
|
17585
|
+
this.temporaryFrontendAppId = options.temporaryFrontendAppId;
|
|
17534
17586
|
this.now = options.now ?? Date.now;
|
|
17535
17587
|
}
|
|
17536
17588
|
async execute(resource, context2, options) {
|
|
@@ -17542,7 +17594,7 @@ var init_linkquegwEventHookExecutor = __esm({
|
|
|
17542
17594
|
message: `hook \u671F\u671B executor=${resource.config.executorName} provider=${resource.providerType},\u975E LinkquegwEventHookExecutor \u6D88\u8D39\u8303\u56F4`
|
|
17543
17595
|
};
|
|
17544
17596
|
}
|
|
17545
|
-
const body = buildLinkquegwEventBody(context2);
|
|
17597
|
+
const body = buildLinkquegwEventBody(context2, this.temporaryFrontendAppId);
|
|
17546
17598
|
if (body === void 0) {
|
|
17547
17599
|
return {
|
|
17548
17600
|
ok: true,
|
|
@@ -189600,7 +189652,10 @@ var init_agentRuntime = __esm({
|
|
|
189600
189652
|
});
|
|
189601
189653
|
return;
|
|
189602
189654
|
}
|
|
189603
|
-
await hookDispatcher.dispatch(EHookStage.RUN_COMPLETED, hookCommonParams, {
|
|
189655
|
+
await hookDispatcher.dispatch(EHookStage.RUN_COMPLETED, hookCommonParams, {
|
|
189656
|
+
runDurationMs: Date.now() - runStartedAt,
|
|
189657
|
+
...assistantText !== "" && { messageContent: assistantText }
|
|
189658
|
+
});
|
|
189604
189659
|
};
|
|
189605
189660
|
try {
|
|
189606
189661
|
for await (const ev of this.agentLoop.run(agentReq)) {
|
|
@@ -197652,7 +197707,7 @@ var init_examplePlugin = __esm({
|
|
|
197652
197707
|
});
|
|
197653
197708
|
|
|
197654
197709
|
// ../linkque-agent-runtime/dist/esm/impl/plugin/linkquegwEventPlugin.js
|
|
197655
|
-
var LINKQUEGW_EVENT_PLUGIN_NAME, LINKQUEGW_EVENT_HOOK_RESOURCE_ID, LINKQUEGW_RUN_COMPLETED_HOOK_RESOURCE_ID, LINKQUEGW_RUN_FAILED_HOOK_RESOURCE_ID, DEFAULT_LINKQUEGW_EVENT_HOOKS, createLinkquegwEventHookResource, isUserTokenAuthorization, isLinkquegwEventHook, LinkquegwEventPlugin;
|
|
197710
|
+
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, isUserTokenAuthorization, isLinkquegwEventHook, LinkquegwEventPlugin;
|
|
197656
197711
|
var init_linkquegwEventPlugin = __esm({
|
|
197657
197712
|
"../linkque-agent-runtime/dist/esm/impl/plugin/linkquegwEventPlugin.js"() {
|
|
197658
197713
|
"use strict";
|
|
@@ -197662,6 +197717,7 @@ var init_linkquegwEventPlugin = __esm({
|
|
|
197662
197717
|
LINKQUEGW_EVENT_HOOK_RESOURCE_ID = "linkquegw-event-run-started";
|
|
197663
197718
|
LINKQUEGW_RUN_COMPLETED_HOOK_RESOURCE_ID = "linkquegw-event-run-completed";
|
|
197664
197719
|
LINKQUEGW_RUN_FAILED_HOOK_RESOURCE_ID = "linkquegw-event-run-failed";
|
|
197720
|
+
LINKQUEGW_RUN_READ_HOOK_RESOURCE_ID = "linkquegw-event-run-read";
|
|
197665
197721
|
DEFAULT_LINKQUEGW_EVENT_HOOKS = [
|
|
197666
197722
|
{
|
|
197667
197723
|
resourceId: LINKQUEGW_EVENT_HOOK_RESOURCE_ID,
|
|
@@ -197674,6 +197730,10 @@ var init_linkquegwEventPlugin = __esm({
|
|
|
197674
197730
|
{
|
|
197675
197731
|
resourceId: LINKQUEGW_RUN_FAILED_HOOK_RESOURCE_ID,
|
|
197676
197732
|
stage: EHookStage.RUN_FAILED
|
|
197733
|
+
},
|
|
197734
|
+
{
|
|
197735
|
+
resourceId: LINKQUEGW_RUN_READ_HOOK_RESOURCE_ID,
|
|
197736
|
+
stage: EHookStage.RUN_READ
|
|
197677
197737
|
}
|
|
197678
197738
|
];
|
|
197679
197739
|
createLinkquegwEventHookResource = (resourceId, stage) => ({
|
|
@@ -197715,6 +197775,9 @@ var init_linkquegwEventPlugin = __esm({
|
|
|
197715
197775
|
...options.metricsSink !== void 0 && {
|
|
197716
197776
|
metricsSink: options.metricsSink
|
|
197717
197777
|
},
|
|
197778
|
+
...options.temporaryFrontendAppId !== void 0 && {
|
|
197779
|
+
temporaryFrontendAppId: options.temporaryFrontendAppId
|
|
197780
|
+
},
|
|
197718
197781
|
...options.now !== void 0 && { now: options.now }
|
|
197719
197782
|
};
|
|
197720
197783
|
this.hookExecutorList = [new LinkquegwEventHookExecutor(executorOptions)];
|
|
@@ -197740,6 +197803,7 @@ __export(plugin_exports, {
|
|
|
197740
197803
|
LINKQUEGW_EVENT_PLUGIN_NAME: () => LINKQUEGW_EVENT_PLUGIN_NAME,
|
|
197741
197804
|
LINKQUEGW_RUN_COMPLETED_HOOK_RESOURCE_ID: () => LINKQUEGW_RUN_COMPLETED_HOOK_RESOURCE_ID,
|
|
197742
197805
|
LINKQUEGW_RUN_FAILED_HOOK_RESOURCE_ID: () => LINKQUEGW_RUN_FAILED_HOOK_RESOURCE_ID,
|
|
197806
|
+
LINKQUEGW_RUN_READ_HOOK_RESOURCE_ID: () => LINKQUEGW_RUN_READ_HOOK_RESOURCE_ID,
|
|
197743
197807
|
LinkquegwEventPlugin: () => LinkquegwEventPlugin
|
|
197744
197808
|
});
|
|
197745
197809
|
var init_plugin = __esm({
|
|
@@ -198283,7 +198347,8 @@ var parseHomeDataProxyInput = (value) => {
|
|
|
198283
198347
|
var parseA2UIActionProxyInput = (value) => {
|
|
198284
198348
|
const trustedContext = isRecord6(value) ? value[HOME_DATA_TRUSTED_CONTEXT_FIELD] : void 0;
|
|
198285
198349
|
const userId = isRecord6(trustedContext) && typeof trustedContext.userId === "string" ? trustedContext.userId.trim() : "";
|
|
198286
|
-
if (!isRecord6(value) || !userId)
|
|
198350
|
+
if (!isRecord6(value) || !userId)
|
|
198351
|
+
throw new Error("a2ui action trusted user is invalid");
|
|
198287
198352
|
const request = { ...value };
|
|
198288
198353
|
delete request[HOME_DATA_TRUSTED_CONTEXT_FIELD];
|
|
198289
198354
|
const tenantId = isRecord6(trustedContext) && typeof trustedContext.tenantId === "string" ? trustedContext.tenantId.trim() : void 0;
|