linkque-cli-v2 1.2.0 → 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 +683 -356
- package/package.json +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-HPOFEAMP.js → chunk-7YMZ4CJ5.js} +144 -47
- 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 +91 -24
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";
|
|
@@ -14356,14 +14357,16 @@ function getA2UIPaymentActionReferenceIssues(card, bindings, path6 = "a2uiTempla
|
|
|
14356
14357
|
const issues = [];
|
|
14357
14358
|
const bindingIds = new Set(bindings.map((binding) => binding.actionId));
|
|
14358
14359
|
const referenced = /* @__PURE__ */ new Set();
|
|
14359
|
-
card.forEach((
|
|
14360
|
-
|
|
14361
|
-
|
|
14362
|
-
|
|
14363
|
-
|
|
14364
|
-
|
|
14365
|
-
|
|
14366
|
-
|
|
14360
|
+
card.forEach((message, messageIndex) => {
|
|
14361
|
+
message.datas.forEach((instruction, instructionIndex) => {
|
|
14362
|
+
const instructionRecord = instruction;
|
|
14363
|
+
const update = isPlainRecord(instructionRecord.updateComponents) ? instructionRecord.updateComponents : void 0;
|
|
14364
|
+
const components = update && Array.isArray(update.components) ? update.components : [];
|
|
14365
|
+
components.forEach((component, componentIndex) => {
|
|
14366
|
+
if (!isPlainRecord(component))
|
|
14367
|
+
return;
|
|
14368
|
+
collectPaymentActionReferences(component.action, `${path6}[${messageIndex}].datas[${instructionIndex}].updateComponents.components[${componentIndex}].action`, referenced, issues);
|
|
14369
|
+
});
|
|
14367
14370
|
});
|
|
14368
14371
|
});
|
|
14369
14372
|
for (const actionId of referenced) {
|
|
@@ -15388,6 +15391,7 @@ var init_authoring_model = __esm({
|
|
|
15388
15391
|
"use strict";
|
|
15389
15392
|
init_binding_analyzer();
|
|
15390
15393
|
init_json2();
|
|
15394
|
+
init_payment_action();
|
|
15391
15395
|
init_validation();
|
|
15392
15396
|
}
|
|
15393
15397
|
});
|
|
@@ -16424,15 +16428,27 @@ async function verifyPaymentResult(input) {
|
|
|
16424
16428
|
function resolvePaymentBinding(protocol, source, actionId) {
|
|
16425
16429
|
const card = protocol.agent.resources.find((resource) => resource.resourceType === EResourceType.CARD && resource.resourceId === source.cardRef);
|
|
16426
16430
|
if (!card)
|
|
16427
|
-
return {
|
|
16431
|
+
return {
|
|
16432
|
+
ok: false,
|
|
16433
|
+
response: failure2("CARD_NOT_FOUND", "\u652F\u4ED8\u5361\u7247\u4E0D\u5B58\u5728", false)
|
|
16434
|
+
};
|
|
16428
16435
|
if (card.config.revision !== source.cardRevision) {
|
|
16429
|
-
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
|
+
};
|
|
16430
16440
|
}
|
|
16431
16441
|
const binding = card.config.schemaVersion === "3" ? card.config.actionBindings?.find((candidate) => candidate.actionId === actionId) : void 0;
|
|
16432
16442
|
if (!binding)
|
|
16433
|
-
return {
|
|
16443
|
+
return {
|
|
16444
|
+
ok: false,
|
|
16445
|
+
response: failure2("ACTION_NOT_FOUND", "\u652F\u4ED8\u52A8\u4F5C\u672A\u7ED1\u5B9A", false)
|
|
16446
|
+
};
|
|
16434
16447
|
if (binding.kind !== "payment") {
|
|
16435
|
-
return {
|
|
16448
|
+
return {
|
|
16449
|
+
ok: false,
|
|
16450
|
+
response: failure2("ACTION_KIND_MISMATCH", "\u52A8\u4F5C\u4E0D\u662F\u652F\u4ED8\u7C7B\u578B", false)
|
|
16451
|
+
};
|
|
16436
16452
|
}
|
|
16437
16453
|
return { ok: true, binding };
|
|
16438
16454
|
}
|
|
@@ -16913,6 +16929,9 @@ var init_hookDispatcher = __esm({
|
|
|
16913
16929
|
run: {
|
|
16914
16930
|
...subject.runDurationMs !== void 0 && {
|
|
16915
16931
|
durationMs: subject.runDurationMs
|
|
16932
|
+
},
|
|
16933
|
+
...subject.messageContent !== void 0 && {
|
|
16934
|
+
messageContent: subject.messageContent
|
|
16916
16935
|
}
|
|
16917
16936
|
}
|
|
16918
16937
|
};
|
|
@@ -16922,6 +16941,12 @@ var init_hookDispatcher = __esm({
|
|
|
16922
16941
|
stage: EHookStage.RUN_FAILED,
|
|
16923
16942
|
error: subject.error ?? { message: "unknown error" }
|
|
16924
16943
|
};
|
|
16944
|
+
case EHookStage.RUN_READ:
|
|
16945
|
+
return {
|
|
16946
|
+
...base,
|
|
16947
|
+
stage: EHookStage.RUN_READ,
|
|
16948
|
+
read: { readAt: subject.readAt ?? now() }
|
|
16949
|
+
};
|
|
16925
16950
|
case EHookStage.BEFORE_TOOL_CALL:
|
|
16926
16951
|
return {
|
|
16927
16952
|
...base,
|
|
@@ -16956,7 +16981,9 @@ var init_hookDispatcher = __esm({
|
|
|
16956
16981
|
eventId: context2.eventId,
|
|
16957
16982
|
runId: context2.commonParams.runId,
|
|
16958
16983
|
conversationId: context2.commonParams.conversationId,
|
|
16959
|
-
|
|
16984
|
+
...context2.commonParams.runIndex !== void 0 && {
|
|
16985
|
+
runIndex: context2.commonParams.runIndex
|
|
16986
|
+
},
|
|
16960
16987
|
agentId: context2.commonParams.agentId,
|
|
16961
16988
|
...context2.commonParams.sessionId !== void 0 && {
|
|
16962
16989
|
sessionId: context2.commonParams.sessionId
|
|
@@ -16987,7 +17014,9 @@ var init_hookDispatcher = __esm({
|
|
|
16987
17014
|
eventId: context2.eventId,
|
|
16988
17015
|
runId: context2.commonParams.runId,
|
|
16989
17016
|
conversationId: context2.commonParams.conversationId,
|
|
16990
|
-
|
|
17017
|
+
...context2.commonParams.runIndex !== void 0 && {
|
|
17018
|
+
runIndex: context2.commonParams.runIndex
|
|
17019
|
+
},
|
|
16991
17020
|
agentId: context2.commonParams.agentId,
|
|
16992
17021
|
...context2.commonParams.sessionId !== void 0 && {
|
|
16993
17022
|
sessionId: context2.commonParams.sessionId
|
|
@@ -17015,7 +17044,9 @@ var init_hookDispatcher = __esm({
|
|
|
17015
17044
|
eventId: context2.eventId,
|
|
17016
17045
|
runId: context2.commonParams.runId,
|
|
17017
17046
|
conversationId: context2.commonParams.conversationId,
|
|
17018
|
-
|
|
17047
|
+
...context2.commonParams.runIndex !== void 0 && {
|
|
17048
|
+
runIndex: context2.commonParams.runIndex
|
|
17049
|
+
},
|
|
17019
17050
|
agentId: context2.commonParams.agentId,
|
|
17020
17051
|
...context2.commonParams.sessionId !== void 0 && {
|
|
17021
17052
|
sessionId: context2.commonParams.sessionId
|
|
@@ -17180,7 +17211,9 @@ var init_sideEffectRunner = __esm({
|
|
|
17180
17211
|
eventId: context2.eventId,
|
|
17181
17212
|
runId: context2.commonParams.runId,
|
|
17182
17213
|
conversationId: context2.commonParams.conversationId,
|
|
17183
|
-
|
|
17214
|
+
...context2.commonParams.runIndex !== void 0 && {
|
|
17215
|
+
runIndex: context2.commonParams.runIndex
|
|
17216
|
+
},
|
|
17184
17217
|
agentId: context2.commonParams.agentId,
|
|
17185
17218
|
...context2.commonParams.sessionId !== void 0 && {
|
|
17186
17219
|
sessionId: context2.commonParams.sessionId
|
|
@@ -17482,11 +17515,22 @@ var init_httpLoggingFetch = __esm({
|
|
|
17482
17515
|
});
|
|
17483
17516
|
|
|
17484
17517
|
// ../linkque-agent-runtime/dist/esm/core/hook/linkquegwEventHookExecutor.js
|
|
17485
|
-
function
|
|
17518
|
+
function truncateMessageContent(messageContent) {
|
|
17519
|
+
return Array.from(messageContent).slice(0, LINKQUEGW_MESSAGE_CONTENT_MAX_LENGTH).join("");
|
|
17520
|
+
}
|
|
17521
|
+
function buildLinkquegwEventBody(context2, temporaryFrontendAppId) {
|
|
17486
17522
|
const eventType = LINKQUEGW_EVENT_TYPE_BY_STAGE[context2.stage];
|
|
17487
17523
|
if (eventType === void 0)
|
|
17488
17524
|
return void 0;
|
|
17489
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
|
+
};
|
|
17490
17534
|
return {
|
|
17491
17535
|
agentId: commonParams.agentId,
|
|
17492
17536
|
eventType,
|
|
@@ -17499,10 +17543,16 @@ function buildLinkquegwEventBody(context2) {
|
|
|
17499
17543
|
sessionId: commonParams.sessionId
|
|
17500
17544
|
},
|
|
17501
17545
|
runId: commonParams.runId,
|
|
17502
|
-
|
|
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 }
|
|
17503
17553
|
};
|
|
17504
17554
|
}
|
|
17505
|
-
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;
|
|
17506
17556
|
var init_linkquegwEventHookExecutor = __esm({
|
|
17507
17557
|
"../linkque-agent-runtime/dist/esm/core/hook/linkquegwEventHookExecutor.js"() {
|
|
17508
17558
|
"use strict";
|
|
@@ -17511,10 +17561,12 @@ var init_linkquegwEventHookExecutor = __esm({
|
|
|
17511
17561
|
init_hookMetrics();
|
|
17512
17562
|
DEFAULT_LINKQUEGW_EVENT_BASE_URL = "https://linkquegw.alipay.com";
|
|
17513
17563
|
LINKQUEGW_AGENT_EVENT_TRIGGER_PATH = "/api/agent/event/trigger";
|
|
17564
|
+
LINKQUEGW_MESSAGE_CONTENT_MAX_LENGTH = 2048;
|
|
17514
17565
|
LINKQUEGW_EVENT_TYPE_BY_STAGE = {
|
|
17515
17566
|
[EHookStage.RUN_STARTED]: "RUN_STARTED",
|
|
17516
17567
|
[EHookStage.RUN_COMPLETED]: "RUN_ENDED",
|
|
17517
|
-
[EHookStage.RUN_FAILED]: "RUN_ENDED"
|
|
17568
|
+
[EHookStage.RUN_FAILED]: "RUN_ENDED",
|
|
17569
|
+
[EHookStage.RUN_READ]: "RUN_READ"
|
|
17518
17570
|
};
|
|
17519
17571
|
LinkquegwEventHookExecutor = class {
|
|
17520
17572
|
name = EHookExecutorName.LinkquegwEventHookExecutor;
|
|
@@ -17522,6 +17574,7 @@ var init_linkquegwEventHookExecutor = __esm({
|
|
|
17522
17574
|
getAuthHeaders;
|
|
17523
17575
|
fetchImpl;
|
|
17524
17576
|
metricsSink;
|
|
17577
|
+
temporaryFrontendAppId;
|
|
17525
17578
|
now;
|
|
17526
17579
|
constructor(options) {
|
|
17527
17580
|
this.baseUrl = options.baseUrl ?? DEFAULT_LINKQUEGW_EVENT_BASE_URL;
|
|
@@ -17529,6 +17582,7 @@ var init_linkquegwEventHookExecutor = __esm({
|
|
|
17529
17582
|
const baseFetch = options.fetchImpl ?? globalThis.fetch;
|
|
17530
17583
|
this.fetchImpl = options.debugLog ? createHttpLoggingFetch(options.debugLog, "hook-linkque", baseFetch) : baseFetch;
|
|
17531
17584
|
this.metricsSink = options.metricsSink;
|
|
17585
|
+
this.temporaryFrontendAppId = options.temporaryFrontendAppId;
|
|
17532
17586
|
this.now = options.now ?? Date.now;
|
|
17533
17587
|
}
|
|
17534
17588
|
async execute(resource, context2, options) {
|
|
@@ -17540,7 +17594,7 @@ var init_linkquegwEventHookExecutor = __esm({
|
|
|
17540
17594
|
message: `hook \u671F\u671B executor=${resource.config.executorName} provider=${resource.providerType},\u975E LinkquegwEventHookExecutor \u6D88\u8D39\u8303\u56F4`
|
|
17541
17595
|
};
|
|
17542
17596
|
}
|
|
17543
|
-
const body = buildLinkquegwEventBody(context2);
|
|
17597
|
+
const body = buildLinkquegwEventBody(context2, this.temporaryFrontendAppId);
|
|
17544
17598
|
if (body === void 0) {
|
|
17545
17599
|
return {
|
|
17546
17600
|
ok: true,
|
|
@@ -189598,7 +189652,10 @@ var init_agentRuntime = __esm({
|
|
|
189598
189652
|
});
|
|
189599
189653
|
return;
|
|
189600
189654
|
}
|
|
189601
|
-
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
|
+
});
|
|
189602
189659
|
};
|
|
189603
189660
|
try {
|
|
189604
189661
|
for await (const ev of this.agentLoop.run(agentReq)) {
|
|
@@ -197650,7 +197707,7 @@ var init_examplePlugin = __esm({
|
|
|
197650
197707
|
});
|
|
197651
197708
|
|
|
197652
197709
|
// ../linkque-agent-runtime/dist/esm/impl/plugin/linkquegwEventPlugin.js
|
|
197653
|
-
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;
|
|
197654
197711
|
var init_linkquegwEventPlugin = __esm({
|
|
197655
197712
|
"../linkque-agent-runtime/dist/esm/impl/plugin/linkquegwEventPlugin.js"() {
|
|
197656
197713
|
"use strict";
|
|
@@ -197660,6 +197717,7 @@ var init_linkquegwEventPlugin = __esm({
|
|
|
197660
197717
|
LINKQUEGW_EVENT_HOOK_RESOURCE_ID = "linkquegw-event-run-started";
|
|
197661
197718
|
LINKQUEGW_RUN_COMPLETED_HOOK_RESOURCE_ID = "linkquegw-event-run-completed";
|
|
197662
197719
|
LINKQUEGW_RUN_FAILED_HOOK_RESOURCE_ID = "linkquegw-event-run-failed";
|
|
197720
|
+
LINKQUEGW_RUN_READ_HOOK_RESOURCE_ID = "linkquegw-event-run-read";
|
|
197663
197721
|
DEFAULT_LINKQUEGW_EVENT_HOOKS = [
|
|
197664
197722
|
{
|
|
197665
197723
|
resourceId: LINKQUEGW_EVENT_HOOK_RESOURCE_ID,
|
|
@@ -197672,6 +197730,10 @@ var init_linkquegwEventPlugin = __esm({
|
|
|
197672
197730
|
{
|
|
197673
197731
|
resourceId: LINKQUEGW_RUN_FAILED_HOOK_RESOURCE_ID,
|
|
197674
197732
|
stage: EHookStage.RUN_FAILED
|
|
197733
|
+
},
|
|
197734
|
+
{
|
|
197735
|
+
resourceId: LINKQUEGW_RUN_READ_HOOK_RESOURCE_ID,
|
|
197736
|
+
stage: EHookStage.RUN_READ
|
|
197675
197737
|
}
|
|
197676
197738
|
];
|
|
197677
197739
|
createLinkquegwEventHookResource = (resourceId, stage) => ({
|
|
@@ -197713,6 +197775,9 @@ var init_linkquegwEventPlugin = __esm({
|
|
|
197713
197775
|
...options.metricsSink !== void 0 && {
|
|
197714
197776
|
metricsSink: options.metricsSink
|
|
197715
197777
|
},
|
|
197778
|
+
...options.temporaryFrontendAppId !== void 0 && {
|
|
197779
|
+
temporaryFrontendAppId: options.temporaryFrontendAppId
|
|
197780
|
+
},
|
|
197716
197781
|
...options.now !== void 0 && { now: options.now }
|
|
197717
197782
|
};
|
|
197718
197783
|
this.hookExecutorList = [new LinkquegwEventHookExecutor(executorOptions)];
|
|
@@ -197738,6 +197803,7 @@ __export(plugin_exports, {
|
|
|
197738
197803
|
LINKQUEGW_EVENT_PLUGIN_NAME: () => LINKQUEGW_EVENT_PLUGIN_NAME,
|
|
197739
197804
|
LINKQUEGW_RUN_COMPLETED_HOOK_RESOURCE_ID: () => LINKQUEGW_RUN_COMPLETED_HOOK_RESOURCE_ID,
|
|
197740
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,
|
|
197741
197807
|
LinkquegwEventPlugin: () => LinkquegwEventPlugin
|
|
197742
197808
|
});
|
|
197743
197809
|
var init_plugin = __esm({
|
|
@@ -198281,7 +198347,8 @@ var parseHomeDataProxyInput = (value) => {
|
|
|
198281
198347
|
var parseA2UIActionProxyInput = (value) => {
|
|
198282
198348
|
const trustedContext = isRecord6(value) ? value[HOME_DATA_TRUSTED_CONTEXT_FIELD] : void 0;
|
|
198283
198349
|
const userId = isRecord6(trustedContext) && typeof trustedContext.userId === "string" ? trustedContext.userId.trim() : "";
|
|
198284
|
-
if (!isRecord6(value) || !userId)
|
|
198350
|
+
if (!isRecord6(value) || !userId)
|
|
198351
|
+
throw new Error("a2ui action trusted user is invalid");
|
|
198285
198352
|
const request = { ...value };
|
|
198286
198353
|
delete request[HOME_DATA_TRUSTED_CONTEXT_FIELD];
|
|
198287
198354
|
const tenantId = isRecord6(trustedContext) && typeof trustedContext.tenantId === "string" ? trustedContext.tenantId.trim() : void 0;
|