linkque-cli-v2 1.3.5 → 1.3.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/linkquejs.js CHANGED
@@ -7574,14 +7574,13 @@ var require_fast_uri = __commonJS({
7574
7574
  if (!malformedIPLiteral) {
7575
7575
  malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
7576
7576
  }
7577
- if (uri.indexOf("%") !== -1 && parsed.host !== void 0 && !malformedIPLiteral) {
7578
- let host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true);
7579
- if (!isIP) {
7580
- host = normalizePercentEncoding(host.toLowerCase());
7581
- }
7582
- parsed.host = reescapeHostDelimiters(host, isIP);
7583
- }
7584
7577
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
7578
+ if (uri.indexOf("%") !== -1) {
7579
+ if (parsed.host !== void 0 && !malformedIPLiteral) {
7580
+ const host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true);
7581
+ parsed.host = reescapeHostDelimiters(host, isIP);
7582
+ }
7583
+ }
7585
7584
  if (parsed.path) {
7586
7585
  parsed.path = normalizePathEncoding(parsed.path);
7587
7586
  }
@@ -34578,8 +34577,6 @@ var APPBASE_RUNTIME_CONFIG_DEFAULTS = Object.freeze({
34578
34577
  SEARCH_TABLE_ID: "linkque_conversation_message_search",
34579
34578
  CLIENT_CAPABILITY_DATABASE_ID: "linkque",
34580
34579
  CLIENT_CAPABILITY_TABLE_ID: "linkque_client_cap_invocations",
34581
- A2UI_ACTION_DATABASE_ID: "linkque",
34582
- A2UI_ACTION_TABLE_ID: "linkque_a2ui_action_invocations",
34583
34580
  RUN_CHUNK_SIZE: "30",
34584
34581
  RUN_CANCEL_POLL_INTERVAL_MS: "500",
34585
34582
  LOG_LEVEL: "INFO"
@@ -34588,97 +34585,6 @@ var APPBASE_RUNTIME_CONFIG_DEFAULTS = Object.freeze({
34588
34585
  // src/commands/agentbuild/configTemplate.ts
34589
34586
  var import_path7 = __toESM(require("path"));
34590
34587
  var APPWRITE_CONFIG_NAME = "appwrite.config.json";
34591
- var A2UI_ACTION_TABLE_COLUMNS = [
34592
- ...[
34593
- "ownerId",
34594
- "agentId",
34595
- "threadId",
34596
- "cardRef",
34597
- "cardRevision",
34598
- "surfaceId",
34599
- "componentId"
34600
- ].map((key) => ({
34601
- key,
34602
- type: "varchar",
34603
- required: true,
34604
- array: false,
34605
- size: 128,
34606
- default: null
34607
- })),
34608
- {
34609
- key: "cardInstanceId",
34610
- type: "varchar",
34611
- required: true,
34612
- array: false,
34613
- size: 256,
34614
- default: null
34615
- },
34616
- {
34617
- key: "status",
34618
- type: "varchar",
34619
- required: true,
34620
- array: false,
34621
- size: 32,
34622
- default: null
34623
- },
34624
- {
34625
- key: "input",
34626
- type: "text",
34627
- required: true,
34628
- array: false,
34629
- size: 0,
34630
- default: null
34631
- },
34632
- {
34633
- key: "tradeNO",
34634
- type: "varchar",
34635
- required: false,
34636
- array: false,
34637
- size: 64,
34638
- default: null
34639
- },
34640
- {
34641
- key: "callback",
34642
- type: "text",
34643
- required: false,
34644
- array: false,
34645
- size: 0,
34646
- default: null
34647
- },
34648
- {
34649
- key: "verification",
34650
- type: "text",
34651
- required: false,
34652
- array: false,
34653
- size: 0,
34654
- default: null
34655
- },
34656
- {
34657
- key: "createdAt",
34658
- type: "varchar",
34659
- required: true,
34660
- array: false,
34661
- size: 32,
34662
- default: null
34663
- },
34664
- {
34665
- key: "expiresAt",
34666
- type: "varchar",
34667
- required: true,
34668
- array: false,
34669
- size: 32,
34670
- default: null
34671
- }
34672
- ];
34673
- var A2UI_ACTION_TABLE_INDEXES = [
34674
- {
34675
- key: "thread_status",
34676
- type: "key",
34677
- columns: ["threadId", "status"],
34678
- orders: ["asc", "asc"]
34679
- },
34680
- { key: "expires_at", type: "key", columns: ["expiresAt"], orders: ["asc"] }
34681
- ];
34682
34588
  var CLIENT_CAPABILITY_TABLE_COLUMNS = [
34683
34589
  ...["ownerId", "agentId", "threadId", "runId", "toolCallId"].map((key) => ({
34684
34590
  key,
@@ -35342,16 +35248,6 @@ var TABLES = [
35342
35248
  permissions: [],
35343
35249
  columns: CLIENT_CAPABILITY_TABLE_COLUMNS,
35344
35250
  indexes: CLIENT_CAPABILITY_TABLE_INDEXES
35345
- },
35346
- {
35347
- $id: APPBASE_RUNTIME_CONFIG_DEFAULTS.A2UI_ACTION_TABLE_ID,
35348
- databaseId: APPBASE_RUNTIME_CONFIG_DEFAULTS.A2UI_ACTION_DATABASE_ID,
35349
- name: APPBASE_RUNTIME_CONFIG_DEFAULTS.A2UI_ACTION_TABLE_ID,
35350
- enabled: true,
35351
- rowSecurity: true,
35352
- permissions: [],
35353
- columns: A2UI_ACTION_TABLE_COLUMNS,
35354
- indexes: A2UI_ACTION_TABLE_INDEXES
35355
35251
  }
35356
35252
  ];
35357
35253
  var buildAppwriteConfigTemplate = (envOverrides = {}) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linkque-cli-v2",
3
- "version": "1.3.5",
3
+ "version": "1.3.6",
4
4
  "description": "Public Linkque CLI bundle for sandbox debugging",
5
5
  "bin": {
6
6
  "linkquejs": "linkquejs.js"
@@ -16,9 +16,11 @@ import {
16
16
  require_json_bigint
17
17
  } from "./chunk-ETG6PNHQ.js";
18
18
  import {
19
+ McpPhoneAuthorizationFailedError,
20
+ McpPhoneAuthorizationRequiredError,
19
21
  RUNTIME_CONFIG_DEFAULTS,
20
22
  RuntimeConfigProvider
21
- } from "./chunk-VVEDZWQ5.js";
23
+ } from "./chunk-RHFHCJYP.js";
22
24
  import {
23
25
  __commonJS,
24
26
  __require,
@@ -7358,8 +7360,6 @@ var APPBASE_RUNTIME_CONFIG_DEFAULTS = Object.freeze({
7358
7360
  SEARCH_TABLE_ID: "linkque_conversation_message_search",
7359
7361
  CLIENT_CAPABILITY_DATABASE_ID: "linkque",
7360
7362
  CLIENT_CAPABILITY_TABLE_ID: "linkque_client_cap_invocations",
7361
- A2UI_ACTION_DATABASE_ID: "linkque",
7362
- A2UI_ACTION_TABLE_ID: "linkque_a2ui_action_invocations",
7363
7363
  RUN_CHUNK_SIZE: "30",
7364
7364
  RUN_CANCEL_POLL_INTERVAL_MS: "500",
7365
7365
  LOG_LEVEL: "INFO"
@@ -11913,138 +11913,6 @@ function parsePositiveInt(raw, name) {
11913
11913
  return n;
11914
11914
  }
11915
11915
 
11916
- // ../linkque-agent-appwrite-integrate/dist/esm/runtime/paymentActionStore.js
11917
- import { createHash as createHash2 } from "node:crypto";
11918
- var PAYMENT_INVOCATION_TTL_MS = 24 * 60 * 60 * 1e3;
11919
- function createPaymentInvocation(ownerId, request, now = /* @__PURE__ */ new Date()) {
11920
- const invocationId = createPaymentInvocationId(ownerId, request);
11921
- return {
11922
- invocationId,
11923
- ownerId,
11924
- agentId: request.agentId,
11925
- threadId: request.threadId,
11926
- cardRef: request.source.cardRef,
11927
- cardRevision: request.source.cardRevision,
11928
- cardInstanceId: request.source.cardInstanceId,
11929
- surfaceId: request.source.surfaceId,
11930
- componentId: request.source.componentId,
11931
- input: request.input,
11932
- status: "executing",
11933
- createdAt: now.toISOString(),
11934
- expiresAt: new Date(now.getTime() + PAYMENT_INVOCATION_TTL_MS).toISOString()
11935
- };
11936
- }
11937
- function createPaymentInvocationId(ownerId, request) {
11938
- const material = stableStringify({
11939
- ownerId,
11940
- agentId: request.agentId,
11941
- threadId: request.threadId,
11942
- cardInstanceId: request.source.cardInstanceId,
11943
- cardRevision: request.source.cardRevision,
11944
- surfaceId: request.source.surfaceId,
11945
- componentId: request.source.componentId,
11946
- input: request.input
11947
- });
11948
- return `pa_${createHash2("sha256").update(material).digest("hex").slice(0, 32)}`;
11949
- }
11950
- function createPaymentActionStore(databases, databaseId, tableId) {
11951
- return {
11952
- async begin(invocation) {
11953
- const { invocationId, input, ...fields } = invocation;
11954
- try {
11955
- const document = await databases.createDocument(databaseId, tableId, invocationId, { ...fields, input: JSON.stringify(input) }, []);
11956
- return {
11957
- kind: "created",
11958
- invocation: readInvocation2(document) ?? invocation
11959
- };
11960
- } catch (error) {
11961
- if (!isConflict2(error))
11962
- throw error;
11963
- const existing = await this.get(invocationId);
11964
- if (!existing)
11965
- throw error;
11966
- return { kind: "existing", invocation: existing };
11967
- }
11968
- },
11969
- async get(invocationId) {
11970
- try {
11971
- return readInvocation2(await databases.getDocument(databaseId, tableId, invocationId));
11972
- } catch (error) {
11973
- if (isNotFound2(error))
11974
- return void 0;
11975
- throw error;
11976
- }
11977
- },
11978
- async update(invocationId, patch) {
11979
- const data = { ...patch };
11980
- const document = await databases.updateDocument(databaseId, tableId, invocationId, data);
11981
- const invocation = readInvocation2(document);
11982
- if (!invocation)
11983
- throw new Error("\u652F\u4ED8 invocation \u6301\u4E45\u5316\u7ED3\u679C\u65E0\u6548");
11984
- return invocation;
11985
- },
11986
- async cleanup(now) {
11987
- const result = await databases.listDocuments(databaseId, tableId, [
11988
- Query.lessThanEqual("expiresAt", now),
11989
- Query.limit(500)
11990
- ]);
11991
- for (const document of result.documents) {
11992
- await databases.deleteDocument(databaseId, tableId, document.$id);
11993
- }
11994
- return result.documents.length;
11995
- }
11996
- };
11997
- }
11998
- function readInvocation2(value) {
11999
- if (!value || typeof value !== "object" || Array.isArray(value))
12000
- return void 0;
12001
- const row = value;
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")
12003
- return void 0;
12004
- const input = parseJsonObject(row.input);
12005
- if (!input)
12006
- return void 0;
12007
- return {
12008
- invocationId: row.$id,
12009
- ownerId: row.ownerId,
12010
- agentId: row.agentId,
12011
- threadId: row.threadId,
12012
- cardRef: row.cardRef,
12013
- cardRevision: row.cardRevision,
12014
- cardInstanceId: row.cardInstanceId,
12015
- surfaceId: row.surfaceId,
12016
- componentId: row.componentId,
12017
- input,
12018
- status: row.status,
12019
- ...typeof row.tradeNO === "string" ? { tradeNO: row.tradeNO } : {},
12020
- createdAt: row.createdAt,
12021
- expiresAt: row.expiresAt
12022
- };
12023
- }
12024
- function parseJsonObject(value) {
12025
- try {
12026
- const parsed = JSON.parse(value);
12027
- return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : void 0;
12028
- } catch {
12029
- return void 0;
12030
- }
12031
- }
12032
- function stableStringify(value) {
12033
- if (Array.isArray(value))
12034
- return `[${value.map(stableStringify).join(",")}]`;
12035
- if (value && typeof value === "object") {
12036
- return `{${Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, item]) => `${JSON.stringify(key)}:${stableStringify(item)}`).join(",")}}`;
12037
- }
12038
- return JSON.stringify(value);
12039
- }
12040
- function isNotFound2(error) {
12041
- return Boolean(error && typeof error === "object" && "code" in error && error.code === 404);
12042
- }
12043
- function isConflict2(error) {
12044
- const value = error;
12045
- return value?.code === 409 || /already exists|conflict|duplicate|409/i.test(value?.message ?? "");
12046
- }
12047
-
12048
11916
  // ../linkque-agent-appwrite-integrate/dist/esm/runtime/handler/handlerUtils.js
12049
11917
  function resolveBodyJSON(req) {
12050
11918
  if (req.bodyJSON !== void 0 && typeof req.bodyJSON !== "string") {
@@ -12089,6 +11957,52 @@ var TRIGGER_HEADER = "x-appwrite-trigger";
12089
11957
  var ENV_SELECTOR_HEADER = "x-linkque-env";
12090
11958
  var TRACE_ID_HEADER = "x-trace-id";
12091
11959
  var TEMPORARY_FRONTEND_APP_ID_HEADER = "x-linkque-alipay-app-id";
11960
+ var ALIPAY_AUTH_CODE_HEADER = "x-alipay-authcode";
11961
+ var AUTH_UNAVAILABLE_HEADER = "x-linkque-phone-auth-unavailable";
11962
+ function readMcpPhoneAuthorization(headers) {
11963
+ const authCode = readHeader(headers, ALIPAY_AUTH_CODE_HEADER)?.trim();
11964
+ if (authCode && authCode.length <= 4096)
11965
+ return { kind: "authorized", authCode };
11966
+ if (readHeader(headers, AUTH_UNAVAILABLE_HEADER) === "1")
11967
+ return { kind: "unavailable" };
11968
+ return void 0;
11969
+ }
11970
+ function mcpPhoneAuthorizationChallenge(error) {
11971
+ if (error instanceof McpPhoneAuthorizationFailedError) {
11972
+ return {
11973
+ status: 403,
11974
+ body: {
11975
+ ok: false,
11976
+ error: { code: error.code, message: error.message, retryable: true }
11977
+ }
11978
+ };
11979
+ }
11980
+ if (!(error instanceof McpPhoneAuthorizationRequiredError))
11981
+ return void 0;
11982
+ return {
11983
+ status: 428,
11984
+ body: {
11985
+ error: { code: error.code, message: error.message, retryable: true },
11986
+ authorization: {
11987
+ capability: "userInfo",
11988
+ scopes: ["auth_user"],
11989
+ required: error.required
11990
+ }
11991
+ }
11992
+ };
11993
+ }
11994
+ function readHeader(headers, name) {
11995
+ if (!headers)
11996
+ return void 0;
11997
+ const direct = headValue(headers[name]);
11998
+ if (direct !== void 0)
11999
+ return direct;
12000
+ for (const [key, value] of Object.entries(headers)) {
12001
+ if (key.toLowerCase() === name)
12002
+ return headValue(value);
12003
+ }
12004
+ return void 0;
12005
+ }
12092
12006
  function readEnvSelector(headers) {
12093
12007
  if (!headers)
12094
12008
  return "PROD";
@@ -12236,13 +12150,6 @@ async function clientCapability(ctx) {
12236
12150
  const store = createClientCapabilityStore(handle.databases, config.get("CLIENT_CAPABILITY_DATABASE_ID"), config.get("CLIENT_CAPABILITY_TABLE_ID"));
12237
12151
  const trigger = readAppwriteTrigger(ctx.req.headers);
12238
12152
  result = await runClientCapability(trigger, ctx.req.method, resolveBodyJSON(ctx.req), readAuthenticatedUserId(ctx.req.headers), store);
12239
- if (trigger === "schedule") {
12240
- const paymentDeleted = await createPaymentActionStore(handle.databases, config.get("A2UI_ACTION_DATABASE_ID"), config.get("A2UI_ACTION_TABLE_ID")).cleanup((/* @__PURE__ */ new Date()).toISOString());
12241
- result = {
12242
- status: 200,
12243
- body: { ...result.body, paymentDeleted }
12244
- };
12245
- }
12246
12153
  } catch (error) {
12247
12154
  ctx.error?.(error);
12248
12155
  result = error instanceof LinkqueGatewayAuthError || error instanceof LinkqueGatewayAuthUnconfiguredError ? jsonError(error.status, error.code, error.message) : jsonError(500, "internal_error", error instanceof Error ? error.message : "unknown error");
@@ -12290,6 +12197,8 @@ export {
12290
12197
  resolveBodyJSON,
12291
12198
  toAgentRunMessages,
12292
12199
  jsonError,
12200
+ readMcpPhoneAuthorization,
12201
+ mcpPhoneAuthorizationChallenge,
12293
12202
  readEnvSelector,
12294
12203
  readTraceId,
12295
12204
  readTemporaryFrontendAppId,
@@ -12303,8 +12212,6 @@ export {
12303
12212
  createAppBaseClient,
12304
12213
  createClientCapabilityStore,
12305
12214
  parseStoredClientCapabilityResult,
12306
- createPaymentInvocation,
12307
- createPaymentActionStore,
12308
12215
  runClientCapability,
12309
12216
  runClientCapabilityResult,
12310
12217
  runClientCapabilityCleanup,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  EModelProvider
3
- } from "./chunk-VVEDZWQ5.js";
3
+ } from "./chunk-RHFHCJYP.js";
4
4
 
5
5
  // ../linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js
6
6
  var baked;