linkque-cli-v2 1.3.3 → 1.3.5

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.
Files changed (17) hide show
  1. package/linkquejs.js +188 -317
  2. package/package.json +1 -1
  3. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-BWCMNWG2.js → chunk-LT6VSAY4.js} +54 -41
  4. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-JXQYQ563.js → chunk-NBYB7HSY.js} +1 -1
  5. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-CM4N2PT3.js → chunk-VVEDZWQ5.js} +1850 -1944
  6. package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js +708 -351
  7. package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/clientCapability.js +2 -2
  8. package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js +2 -2
  9. package/vendor/linkque-agent-appwrite-integrate/package.json +1 -1
  10. package/worker.js +892 -616
  11. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{anthropic-messages-5DOLTIGP.js → anthropic-messages-EL2IU4YU.js} +3 -3
  12. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{azure-openai-responses-HVAVRLTK.js → azure-openai-responses-A4XURCOX.js} +1 -1
  13. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{mistral-conversations-UJBDG2KY.js → mistral-conversations-TQA2MPJJ.js} +10 -10
  14. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{openai-codex-responses-3KOC6KHN.js → openai-codex-responses-WLREQPZK.js} +1 -1
  15. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{openai-completions-HG6OJRL5.js → openai-completions-U6LUBY4P.js} +3 -3
  16. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{openai-responses-F6V2PG3Y.js → openai-responses-SFZAU5JA.js} +1 -1
  17. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{pi-messages-DC4DVRAJ.js → pi-messages-QQA6ZGV2.js} +3 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linkque-cli-v2",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "description": "Public Linkque CLI bundle for sandbox debugging",
5
5
  "bin": {
6
6
  "linkquejs": "linkquejs.js"
@@ -18,7 +18,7 @@ import {
18
18
  import {
19
19
  RUNTIME_CONFIG_DEFAULTS,
20
20
  RuntimeConfigProvider
21
- } from "./chunk-CM4N2PT3.js";
21
+ } from "./chunk-VVEDZWQ5.js";
22
22
  import {
23
23
  __commonJS,
24
24
  __require,
@@ -11629,6 +11629,7 @@ _Operator.dateSubDays = (days) => new _Operator("dateSubDays", [days]).toString(
11629
11629
  _Operator.dateSetNow = () => new _Operator("dateSetNow", []).toString();
11630
11630
 
11631
11631
  // ../linkque-agent-appwrite-integrate/dist/esm/runtime/clientCapabilityStore.js
11632
+ import { createHash } from "node:crypto";
11632
11633
  var TRANSACTION_TTL_SECONDS = 60;
11633
11634
  var COMPLETE_MAX_ATTEMPTS = 3;
11634
11635
  function createClientCapabilityStore(databases, databaseId, tableId) {
@@ -11667,6 +11668,10 @@ function createClientCapabilityStore(databases, databaseId, tableId) {
11667
11668
  await rollbackTransaction(databases, transaction.$id);
11668
11669
  return { kind: "forbidden" };
11669
11670
  }
11671
+ if (!matchesCapability(current.capability, request.result)) {
11672
+ await rollbackTransaction(databases, transaction.$id);
11673
+ return { kind: "invalid" };
11674
+ }
11670
11675
  if (current.status === "expired" || Date.parse(current.acceptUntil) <= Date.now()) {
11671
11676
  if (current.status === "pending") {
11672
11677
  await databases.updateDocument({
@@ -11685,7 +11690,7 @@ function createClientCapabilityStore(databases, databaseId, tableId) {
11685
11690
  const serialized = serializeResult(request.result);
11686
11691
  if (current.status !== "pending") {
11687
11692
  await rollbackTransaction(databases, transaction.$id);
11688
- return current.result === serialized ? { kind: "accepted", repeated: true } : { kind: "conflict" };
11693
+ return current.result === serialized || current.result === consumedDigest(serialized) ? { kind: "accepted", repeated: true } : { kind: "conflict" };
11689
11694
  }
11690
11695
  await databases.updateDocument({
11691
11696
  databaseId,
@@ -11711,8 +11716,10 @@ function createClientCapabilityStore(databases, databaseId, tableId) {
11711
11716
  throw new Error("Failed to complete client capability result");
11712
11717
  },
11713
11718
  async consume(invocationId) {
11719
+ const current = await this.get(invocationId);
11714
11720
  await databases.updateDocument(databaseId, tableId, invocationId, {
11715
11721
  status: "consumed",
11722
+ result: current?.result ? consumedDigest(current.result) : void 0,
11716
11723
  consumedAt: (/* @__PURE__ */ new Date()).toISOString()
11717
11724
  });
11718
11725
  },
@@ -11752,6 +11759,15 @@ function parseStoredClientCapabilityResult(value) {
11752
11759
  function serializeResult(result) {
11753
11760
  return JSON.stringify(result);
11754
11761
  }
11762
+ function consumedDigest(serialized) {
11763
+ return `sha256:${createHash("sha256").update(serialized).digest("hex")}`;
11764
+ }
11765
+ function matchesCapability(capability, result) {
11766
+ if (!result.ok)
11767
+ return true;
11768
+ const data = isRecord(result.data) ? result.data : {};
11769
+ return capability === "location" ? Number.isFinite(data.latitude) && Number.isFinite(data.longitude) : typeof data.authCode === "string" && data.authCode.length > 0;
11770
+ }
11755
11771
  async function commitTransaction(databases, transactionId) {
11756
11772
  await databases.updateTransaction({ transactionId, commit: true });
11757
11773
  }
@@ -11762,7 +11778,7 @@ function readInvocation(value) {
11762
11778
  if (!value || typeof value !== "object" || Array.isArray(value))
11763
11779
  return void 0;
11764
11780
  const row = value;
11765
- if (typeof row.$id !== "string" || typeof row.ownerId !== "string" || typeof row.agentId !== "string" || typeof row.threadId !== "string" || typeof row.runId !== "string" || typeof row.toolCallId !== "string" || row.capability !== "location" || typeof row.status !== "string" || typeof row.input !== "string" || typeof row.createdAt !== "string" || typeof row.acceptUntil !== "string" || typeof row.expiresAt !== "string")
11781
+ if (typeof row.$id !== "string" || typeof row.ownerId !== "string" || typeof row.agentId !== "string" || typeof row.threadId !== "string" || typeof row.runId !== "string" || typeof row.toolCallId !== "string" || !["location", "userInfo"].includes(String(row.capability)) || typeof row.status !== "string" || typeof row.input !== "string" || typeof row.createdAt !== "string" || typeof row.acceptUntil !== "string" || typeof row.expiresAt !== "string")
11766
11782
  return void 0;
11767
11783
  return {
11768
11784
  invocationId: row.$id,
@@ -11771,7 +11787,7 @@ function readInvocation(value) {
11771
11787
  threadId: row.threadId,
11772
11788
  runId: row.runId,
11773
11789
  toolCallId: row.toolCallId,
11774
- capability: "location",
11790
+ capability: row.capability,
11775
11791
  status: row.status,
11776
11792
  input: row.input,
11777
11793
  ...typeof row.result === "string" ? { result: row.result } : {},
@@ -11781,6 +11797,9 @@ function readInvocation(value) {
11781
11797
  ...typeof row.consumedAt === "string" ? { consumedAt: row.consumedAt } : {}
11782
11798
  };
11783
11799
  }
11800
+ function isRecord(value) {
11801
+ return Boolean(value && typeof value === "object" && !Array.isArray(value));
11802
+ }
11784
11803
  function isNotFound(error) {
11785
11804
  return Boolean(error && typeof error === "object" && "code" in error && error.code === 404);
11786
11805
  }
@@ -11895,7 +11914,7 @@ function parsePositiveInt(raw, name) {
11895
11914
  }
11896
11915
 
11897
11916
  // ../linkque-agent-appwrite-integrate/dist/esm/runtime/paymentActionStore.js
11898
- import { createHash } from "node:crypto";
11917
+ import { createHash as createHash2 } from "node:crypto";
11899
11918
  var PAYMENT_INVOCATION_TTL_MS = 24 * 60 * 60 * 1e3;
11900
11919
  function createPaymentInvocation(ownerId, request, now = /* @__PURE__ */ new Date()) {
11901
11920
  const invocationId = createPaymentInvocationId(ownerId, request);
@@ -11904,13 +11923,12 @@ function createPaymentInvocation(ownerId, request, now = /* @__PURE__ */ new Dat
11904
11923
  ownerId,
11905
11924
  agentId: request.agentId,
11906
11925
  threadId: request.threadId,
11907
- actionId: request.actionId,
11908
11926
  cardRef: request.source.cardRef,
11909
11927
  cardRevision: request.source.cardRevision,
11910
11928
  cardInstanceId: request.source.cardInstanceId,
11911
11929
  surfaceId: request.source.surfaceId,
11912
11930
  componentId: request.source.componentId,
11913
- actionContext: request.actionContext,
11931
+ input: request.input,
11914
11932
  status: "executing",
11915
11933
  createdAt: now.toISOString(),
11916
11934
  expiresAt: new Date(now.getTime() + PAYMENT_INVOCATION_TTL_MS).toISOString()
@@ -11922,17 +11940,19 @@ function createPaymentInvocationId(ownerId, request) {
11922
11940
  agentId: request.agentId,
11923
11941
  threadId: request.threadId,
11924
11942
  cardInstanceId: request.source.cardInstanceId,
11925
- actionId: request.actionId,
11926
- actionContext: request.actionContext
11943
+ cardRevision: request.source.cardRevision,
11944
+ surfaceId: request.source.surfaceId,
11945
+ componentId: request.source.componentId,
11946
+ input: request.input
11927
11947
  });
11928
- return `pa_${createHash("sha256").update(material).digest("hex").slice(0, 32)}`;
11948
+ return `pa_${createHash2("sha256").update(material).digest("hex").slice(0, 32)}`;
11929
11949
  }
11930
11950
  function createPaymentActionStore(databases, databaseId, tableId) {
11931
11951
  return {
11932
11952
  async begin(invocation) {
11933
- const { invocationId, actionContext, ...fields } = invocation;
11953
+ const { invocationId, input, ...fields } = invocation;
11934
11954
  try {
11935
- const document = await databases.createDocument(databaseId, tableId, invocationId, { ...fields, actionContext: JSON.stringify(actionContext) }, []);
11955
+ const document = await databases.createDocument(databaseId, tableId, invocationId, { ...fields, input: JSON.stringify(input) }, []);
11936
11956
  return {
11937
11957
  kind: "created",
11938
11958
  invocation: readInvocation2(document) ?? invocation
@@ -11957,10 +11977,6 @@ function createPaymentActionStore(databases, databaseId, tableId) {
11957
11977
  },
11958
11978
  async update(invocationId, patch) {
11959
11979
  const data = { ...patch };
11960
- if (patch.callback)
11961
- data.callback = JSON.stringify(patch.callback);
11962
- if (patch.verification)
11963
- data.verification = JSON.stringify(patch.verification);
11964
11980
  const document = await databases.updateDocument(databaseId, tableId, invocationId, data);
11965
11981
  const invocation = readInvocation2(document);
11966
11982
  if (!invocation)
@@ -11983,29 +11999,24 @@ function readInvocation2(value) {
11983
11999
  if (!value || typeof value !== "object" || Array.isArray(value))
11984
12000
  return void 0;
11985
12001
  const row = value;
11986
- if (typeof row.$id !== "string" || typeof row.ownerId !== "string" || typeof row.agentId !== "string" || typeof row.threadId !== "string" || typeof row.actionId !== "string" || typeof row.cardRef !== "string" || typeof row.cardRevision !== "string" || typeof row.cardInstanceId !== "string" || typeof row.surfaceId !== "string" || typeof row.componentId !== "string" || typeof row.actionContext !== "string" || typeof row.status !== "string" || typeof row.createdAt !== "string" || typeof row.expiresAt !== "string")
12002
+ if (typeof row.$id !== "string" || typeof row.ownerId !== "string" || typeof row.agentId !== "string" || typeof row.threadId !== "string" || typeof row.cardRef !== "string" || typeof row.cardRevision !== "string" || typeof row.cardInstanceId !== "string" || typeof row.surfaceId !== "string" || typeof row.componentId !== "string" || typeof row.input !== "string" || typeof row.status !== "string" || typeof row.createdAt !== "string" || typeof row.expiresAt !== "string")
11987
12003
  return void 0;
11988
- const actionContext = parseJsonObject(row.actionContext);
11989
- if (!actionContext)
12004
+ const input = parseJsonObject(row.input);
12005
+ if (!input)
11990
12006
  return void 0;
11991
12007
  return {
11992
12008
  invocationId: row.$id,
11993
12009
  ownerId: row.ownerId,
11994
12010
  agentId: row.agentId,
11995
12011
  threadId: row.threadId,
11996
- actionId: row.actionId,
11997
12012
  cardRef: row.cardRef,
11998
12013
  cardRevision: row.cardRevision,
11999
12014
  cardInstanceId: row.cardInstanceId,
12000
12015
  surfaceId: row.surfaceId,
12001
12016
  componentId: row.componentId,
12002
- actionContext,
12017
+ input,
12003
12018
  status: row.status,
12004
12019
  ...typeof row.tradeNO === "string" ? { tradeNO: row.tradeNO } : {},
12005
- ...typeof row.callback === "string" && parseJsonObject(row.callback) ? { callback: parseJsonObject(row.callback) } : {},
12006
- ...typeof row.verification === "string" && parseVerification(row.verification) ? {
12007
- verification: parseVerification(row.verification)
12008
- } : {},
12009
12020
  createdAt: row.createdAt,
12010
12021
  expiresAt: row.expiresAt
12011
12022
  };
@@ -12018,10 +12029,6 @@ function parseJsonObject(value) {
12018
12029
  return void 0;
12019
12030
  }
12020
12031
  }
12021
- function parseVerification(value) {
12022
- const parsed = parseJsonObject(value);
12023
- return parsed && typeof parsed.paid === "boolean" ? parsed : void 0;
12024
- }
12025
12032
  function stableStringify(value) {
12026
12033
  if (Array.isArray(value))
12027
12034
  return `[${value.map(stableStringify).join(",")}]`;
@@ -12209,6 +12216,9 @@ async function runClientCapabilityResult(method, body, ownerId, store) {
12209
12216
  if (outcome.kind === "conflict") {
12210
12217
  return jsonError(409, "result_conflict", "\u8BE5\u8C03\u7528\u5DF2\u6709\u4E0D\u540C\u7ED3\u679C");
12211
12218
  }
12219
+ if (outcome.kind === "invalid") {
12220
+ return jsonError(400, "invalid_result", "\u7AEF\u4FA7\u80FD\u529B\u7ED3\u679C\u4E0E\u8BF7\u6C42\u4E0D\u5339\u914D");
12221
+ }
12212
12222
  if (outcome.kind === "expired" || outcome.kind === "not_found") {
12213
12223
  return jsonError(410, "invocation_expired", "\u8BE5\u7AEF\u4FA7\u8C03\u7528\u5DF2\u5931\u6548");
12214
12224
  }
@@ -12240,17 +12250,17 @@ async function clientCapability(ctx) {
12240
12250
  return ctx.res.json?.(result.body, result.status);
12241
12251
  }
12242
12252
  function parseResultRequest(value) {
12243
- if (!isRecord(value) || value.version !== "1.0")
12253
+ if (!isRecord2(value) || value.version !== "1.0")
12244
12254
  return void 0;
12245
- if (!nonEmpty(value.invocationId) || !nonEmpty(value.runId) || !isRecord(value.result)) {
12255
+ if (!nonEmpty(value.invocationId) || !nonEmpty(value.runId) || !isRecord2(value.result)) {
12246
12256
  return void 0;
12247
12257
  }
12248
12258
  if (value.result.ok === true) {
12249
- if (!isLocation(value.result.data))
12259
+ if (!isLocation(value.result.data) && !isUserInfo(value.result.data))
12250
12260
  return void 0;
12251
12261
  } else if (value.result.ok === false) {
12252
12262
  const error = value.result.error;
12253
- if (!isRecord(error) || !nonEmpty(error.code) || !nonEmpty(error.message) || typeof error.retriable !== "boolean") {
12263
+ if (!isRecord2(error) || !nonEmpty(error.code) || !nonEmpty(error.message) || typeof error.retriable !== "boolean") {
12254
12264
  return void 0;
12255
12265
  }
12256
12266
  } else
@@ -12258,9 +12268,12 @@ function parseResultRequest(value) {
12258
12268
  return value;
12259
12269
  }
12260
12270
  function isLocation(value) {
12261
- return isRecord(value) && Number.isFinite(value.latitude) && Number.isFinite(value.longitude);
12271
+ return isRecord2(value) && Number.isFinite(value.latitude) && Number.isFinite(value.longitude);
12262
12272
  }
12263
- function isRecord(value) {
12273
+ function isUserInfo(value) {
12274
+ return isRecord2(value) && nonEmpty(value.authCode) && value.authCode.length <= 4096;
12275
+ }
12276
+ function isRecord2(value) {
12264
12277
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
12265
12278
  }
12266
12279
  function nonEmpty(value) {
@@ -12270,12 +12283,6 @@ function nonEmpty(value) {
12270
12283
  export {
12271
12284
  APPBASE_RUNTIME_CONFIG_DEFAULTS,
12272
12285
  AppbaseRuntimeConfigProvider,
12273
- Query,
12274
- resolveRunStorage,
12275
- createAppBaseClient,
12276
- createA2UIInfoLog,
12277
- isDebugLogLevel,
12278
- describeRuntimeEnv,
12279
12286
  LinkqueGatewayAuthError,
12280
12287
  LinkqueGatewayAuthUnconfiguredError,
12281
12288
  resolveLinkqueGatewayAuth,
@@ -12288,6 +12295,12 @@ export {
12288
12295
  readTemporaryFrontendAppId,
12289
12296
  readAuthenticatedUserId,
12290
12297
  readAppwriteApiKey,
12298
+ Query,
12299
+ createA2UIInfoLog,
12300
+ isDebugLogLevel,
12301
+ describeRuntimeEnv,
12302
+ resolveRunStorage,
12303
+ createAppBaseClient,
12291
12304
  createClientCapabilityStore,
12292
12305
  parseStoredClientCapabilityResult,
12293
12306
  createPaymentInvocation,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  EModelProvider
3
- } from "./chunk-CM4N2PT3.js";
3
+ } from "./chunk-VVEDZWQ5.js";
4
4
 
5
5
  // ../linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js
6
6
  var baked;