linkque-cli-v2 1.6.11-alpha.0 → 1.6.11

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 +116 -9
  2. package/package.json +1 -1
  3. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-NE7CUP5E.js → chunk-3J4AB676.js} +1 -1
  4. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-H7TMASQH.js → chunk-DPHKD4SK.js} +633 -558
  5. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-FA5CNADA.js → chunk-EHNI5TX3.js} +25 -1
  6. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-DNTEEBEH.js → chunk-SICWMO5Y.js} +1 -0
  7. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{getMachineId-bsd-JGCLGHFY.js → getMachineId-bsd-NYGVHXGN.js} +1 -1
  8. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{getMachineId-darwin-COHLFNXH.js → getMachineId-darwin-OPTJOAYC.js} +1 -1
  9. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{getMachineId-linux-XV3Z5FQG.js → getMachineId-linux-5SQRYTUJ.js} +1 -1
  10. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{getMachineId-unsupported-FCRKLIZL.js → getMachineId-unsupported-OJE7WPEH.js} +1 -1
  11. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{getMachineId-win-A4WRNVV6.js → getMachineId-win-SLTTCNXU.js} +1 -1
  12. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{mistral-conversations-ZYAKAOUL.js → mistral-conversations-XUDTCRDY.js} +1 -1
  13. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{otel-BHGIWGIT.js → otel-3OUODIOB.js} +1 -1
  14. package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js +25 -18
  15. package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/clientCapability.js +3 -3
  16. package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js +3 -3
  17. package/worker.js +740 -666
@@ -22,7 +22,7 @@ import {
22
22
  RUNTIME_CONFIG_DEFAULTS,
23
23
  RuntimeConfigProvider,
24
24
  isDebugLoggingEnabled
25
- } from "./chunk-H7TMASQH.js";
25
+ } from "./chunk-DPHKD4SK.js";
26
26
  import {
27
27
  __commonJS,
28
28
  __require,
@@ -15663,6 +15663,7 @@ var API_KEY_HEADER = "x-appwrite-key";
15663
15663
  var TRIGGER_HEADER = "x-appwrite-trigger";
15664
15664
  var ENV_SELECTOR_HEADER = "x-linkque-env";
15665
15665
  var TRACE_ID_HEADER = "x-trace-id";
15666
+ var OTEL_TRACE_ID_HEADER = "x-linkque-otel-trace-id";
15666
15667
  var TEMPORARY_FRONTEND_APP_ID_HEADER = "x-linkque-alipay-app-id";
15667
15668
  var ALIPAY_AUTH_CODE_HEADER = "x-alipay-authcode";
15668
15669
  var AUTH_UNAVAILABLE_HEADER = "x-linkque-phone-auth-unavailable";
@@ -15742,6 +15743,28 @@ function readTraceId(headers) {
15742
15743
  }
15743
15744
  return void 0;
15744
15745
  }
15746
+ function readOtelTraceId(headers) {
15747
+ if (!headers)
15748
+ return { kind: "missing" };
15749
+ let found = Object.prototype.hasOwnProperty.call(headers, OTEL_TRACE_ID_HEADER);
15750
+ let value = found ? headers[OTEL_TRACE_ID_HEADER] : void 0;
15751
+ if (!found) {
15752
+ for (const [key, candidate] of Object.entries(headers)) {
15753
+ if (key.toLowerCase() === OTEL_TRACE_ID_HEADER) {
15754
+ found = true;
15755
+ value = candidate;
15756
+ break;
15757
+ }
15758
+ }
15759
+ }
15760
+ if (!found)
15761
+ return { kind: "missing" };
15762
+ const raw = headValue(value);
15763
+ if (!raw)
15764
+ return { kind: "invalid" };
15765
+ const traceId = raw.toLowerCase();
15766
+ return /^[0-9a-f]{32}$/u.test(traceId) && traceId !== "00000000000000000000000000000000" ? { kind: "valid", traceId } : { kind: "invalid" };
15767
+ }
15745
15768
  function readTemporaryFrontendAppId(headers) {
15746
15769
  if (!headers)
15747
15770
  return void 0;
@@ -15916,6 +15939,7 @@ export {
15916
15939
  mcpPhoneAuthorizationChallenge,
15917
15940
  readEnvSelector,
15918
15941
  readTraceId,
15942
+ readOtelTraceId,
15919
15943
  readTemporaryFrontendAppId,
15920
15944
  readAuthenticatedUserId,
15921
15945
  readAppwriteApiKey,
@@ -1632,6 +1632,7 @@ var init_esm = __esm({
1632
1632
  export {
1633
1633
  createContextKey,
1634
1634
  ROOT_CONTEXT,
1635
+ isValidTraceId,
1635
1636
  isSpanContextValid,
1636
1637
  SpanKind,
1637
1638
  SpanStatusCode,
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  esm_exports,
6
6
  init_esm
7
- } from "./chunk-DNTEEBEH.js";
7
+ } from "./chunk-SICWMO5Y.js";
8
8
  import {
9
9
  __commonJS,
10
10
  __require,
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  esm_exports,
6
6
  init_esm
7
- } from "./chunk-DNTEEBEH.js";
7
+ } from "./chunk-SICWMO5Y.js";
8
8
  import {
9
9
  __commonJS,
10
10
  __toCommonJS
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  esm_exports,
3
3
  init_esm
4
- } from "./chunk-DNTEEBEH.js";
4
+ } from "./chunk-SICWMO5Y.js";
5
5
  import {
6
6
  __commonJS,
7
7
  __require,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  esm_exports,
3
3
  init_esm
4
- } from "./chunk-DNTEEBEH.js";
4
+ } from "./chunk-SICWMO5Y.js";
5
5
  import {
6
6
  __commonJS,
7
7
  __toCommonJS
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  esm_exports,
6
6
  init_esm
7
- } from "./chunk-DNTEEBEH.js";
7
+ } from "./chunk-SICWMO5Y.js";
8
8
  import {
9
9
  __commonJS,
10
10
  __require,
@@ -388,7 +388,7 @@ async function getObservabilityModule() {
388
388
  return observabilityModule;
389
389
  }
390
390
  try {
391
- observabilityModule = await import("./otel-BHGIWGIT.js");
391
+ observabilityModule = await import("./otel-3OUODIOB.js");
392
392
  } catch {
393
393
  observabilityModule = null;
394
394
  }
@@ -258,7 +258,7 @@ import {
258
258
  init_esm,
259
259
  propagation,
260
260
  trace
261
- } from "./chunk-DNTEEBEH.js";
261
+ } from "./chunk-SICWMO5Y.js";
262
262
  import {
263
263
  __export
264
264
  } from "./chunk-2ESYSVXG.js";
@@ -42,6 +42,7 @@ import {
42
42
  readAuthenticatedUserId,
43
43
  readEnvSelector,
44
44
  readMcpPhoneAuthorization,
45
+ readOtelTraceId,
45
46
  readTemporaryFrontendAppId,
46
47
  readTraceId,
47
48
  resolveBodyJSON,
@@ -50,13 +51,13 @@ import {
50
51
  resolveRunStorage,
51
52
  toAgentRunMessages,
52
53
  withIsoTimestamp
53
- } from "../../chunk-FA5CNADA.js";
54
+ } from "../../chunk-EHNI5TX3.js";
54
55
  import "../../chunk-IWOFD643.js";
55
56
  import "../../chunk-PXCGFBV5.js";
56
57
  import "../../chunk-ETG6PNHQ.js";
57
58
  import {
58
59
  getBakedProtocol
59
- } from "../../chunk-NE7CUP5E.js";
60
+ } from "../../chunk-3J4AB676.js";
60
61
  import {
61
62
  ACTIVATE_SKILL_TOOL_NAME,
62
63
  CANCEL_CONVERSATION_RUN_OPERATION,
@@ -196,11 +197,11 @@ import {
196
197
  warnLogFailure,
197
198
  wrapToolWithHooks,
198
199
  writeJsonPointer
199
- } from "../../chunk-H7TMASQH.js";
200
+ } from "../../chunk-DPHKD4SK.js";
200
201
  import "../../chunk-EAODRPW4.js";
201
202
  import "../../chunk-GTEZTRCK.js";
202
203
  import "../../chunk-6POVPTQH.js";
203
- import "../../chunk-DNTEEBEH.js";
204
+ import "../../chunk-SICWMO5Y.js";
204
205
  import {
205
206
  __commonJS,
206
207
  __export,
@@ -8449,7 +8450,7 @@ var googleGenerativeAIApi = () => lazyApi(() => import("../../google-generative-
8449
8450
  var googleVertexApi = () => lazyApi(() => import("../../google-vertex-C3RF55I7.js"));
8450
8451
 
8451
8452
  // ../../node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.lazy.js
8452
- var mistralConversationsApi = () => lazyApi(() => import("../../mistral-conversations-ZYAKAOUL.js"));
8453
+ var mistralConversationsApi = () => lazyApi(() => import("../../mistral-conversations-XUDTCRDY.js"));
8453
8454
 
8454
8455
  // ../../node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.lazy.js
8455
8456
  var openAICodexResponsesApi = () => lazyApi(() => import("../../openai-codex-responses-GEFKSNVN.js"));
@@ -44134,7 +44135,7 @@ var DEFAULT_OPEN_MCP_BASE_URL = APPBASE_RUNTIME_CONFIG_DEFAULTS.LINKQUE_OPEN_MCP
44134
44135
  function createAppbaseMcpConfigResolver(options) {
44135
44136
  return (resource) => ({
44136
44137
  remoteBaseUrl: options.remoteBaseUrl ?? DEFAULT_OPEN_MCP_BASE_URL,
44137
- sseEndpoint: `api/v1/open/mcps/${resource.config.serverName}/sse`,
44138
+ sseEndpoint: `api/v1/open/mcps/${resource.config.serverName}/mcp`,
44138
44139
  agentId: options.agentId,
44139
44140
  ...options.signEndpoint ? { signEndpoint: options.signEndpoint } : {}
44140
44141
  });
@@ -46245,6 +46246,7 @@ function createAppbaseTelemetry(options) {
46245
46246
  environment: options.environment,
46246
46247
  logsEndpoint: options.logsEndpoint,
46247
46248
  tracesEndpoint: options.tracesEndpoint,
46249
+ ...options.initialRootTraceId ? { initialRootTraceId: options.initialRootTraceId } : {},
46248
46250
  diagnostic: ({ code }) => diagnostic(code)
46249
46251
  });
46250
46252
  } catch {
@@ -46395,7 +46397,7 @@ function createSecurityAnswerPlugin(historyStore, log) {
46395
46397
  }
46396
46398
 
46397
46399
  // ../linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chatConfig.js
46398
- function resolveChatDeps(env, deps, logCtx, historyOwnerId, appwriteApiKey, envSelector, gatewayAuth, temporaryFrontendAppId) {
46400
+ function resolveChatDeps(env, deps, logCtx, historyOwnerId, appwriteApiKey, envSelector, gatewayAuth, temporaryFrontendAppId, initialRootTraceId) {
46399
46401
  const log = (...a) => logCtx?.log?.("[chat]", ...a);
46400
46402
  const logError = (...a) => logCtx?.error?.("[chat]", ...a);
46401
46403
  const protocol = deps?.protocol ?? getBakedProtocol();
@@ -46494,6 +46496,7 @@ function resolveChatDeps(env, deps, logCtx, historyOwnerId, appwriteApiKey, envS
46494
46496
  environment: new AppbaseRuntimeConfigProvider(env).get("LINKQUE_TELEMETRY_ENVIRONMENT") ?? (envSelector === "PRE" ? "pre" : "prod"),
46495
46497
  logsEndpoint: telemetryLogsEndpoint,
46496
46498
  tracesEndpoint: telemetryTracesEndpoint,
46499
+ ...initialRootTraceId ? { initialRootTraceId } : {},
46497
46500
  logCtx
46498
46501
  });
46499
46502
  const runtime = deps?.runtime ?? createAppBaseRuntime(protocol, env, {
@@ -47205,7 +47208,7 @@ function failure2(status, code, message, retryable = false) {
47205
47208
  }
47206
47209
 
47207
47210
  // ../linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js
47208
- async function runChat(method, bodyJSON, env, deps, logCtx, historyOwnerId, appwriteApiKey, envSelector, traceId, gatewayAuth, temporaryFrontendAppId) {
47211
+ async function runChat(method, bodyJSON, env, deps, logCtx, historyOwnerId, appwriteApiKey, envSelector, traceId, gatewayAuth, temporaryFrontendAppId, otelTraceId) {
47209
47212
  const log = (...args) => logCtx?.log?.("[chat]", ...args);
47210
47213
  const logError = (...args) => logCtx?.error?.("[chat]", ...args);
47211
47214
  const guarded = guardChatRequest(method, bodyJSON, logCtx);
@@ -47213,7 +47216,7 @@ async function runChat(method, bodyJSON, env, deps, logCtx, historyOwnerId, appw
47213
47216
  return guarded;
47214
47217
  let request = guarded;
47215
47218
  const isPresentationRun = request.executionScope === "presentation";
47216
- const cfg = resolveChatDeps(env, deps, logCtx, historyOwnerId, appwriteApiKey, envSelector, gatewayAuth, temporaryFrontendAppId);
47219
+ const cfg = resolveChatDeps(env, deps, logCtx, historyOwnerId, appwriteApiKey, envSelector, gatewayAuth, temporaryFrontendAppId, otelTraceId);
47217
47220
  if ("status" in cfg)
47218
47221
  return cfg;
47219
47222
  const leaseOwnerId = randomUUID8();
@@ -47522,7 +47525,7 @@ function waitForCancellationPoll(delayMs, signal) {
47522
47525
  }
47523
47526
  });
47524
47527
  }
47525
- async function runGateway(method, bodyJSON, env, deps, logCtx, historyOwnerId, appwriteApiKey, envSelector, traceId, gatewayAuth, temporaryFrontendAppId, mcpPhoneAuthorization) {
47528
+ async function runGateway(method, bodyJSON, env, deps, logCtx, historyOwnerId, appwriteApiKey, envSelector, traceId, gatewayAuth, temporaryFrontendAppId, mcpPhoneAuthorization, otelTraceId) {
47526
47529
  const operation = readOperation(bodyJSON);
47527
47530
  const startedAt = Date.now();
47528
47531
  const logGateway = (event, fields = {}, failed = false) => {
@@ -47603,7 +47606,7 @@ async function runGateway(method, bodyJSON, env, deps, logCtx, historyOwnerId, a
47603
47606
  if (operation) {
47604
47607
  return observe(() => jsonError(400, "operation_unsupported", `\u4E0D\u652F\u6301\u7684 operation: ${operation}`));
47605
47608
  }
47606
- return observe(() => runChat(method, bodyJSON, env, deps, logCtx, historyOwnerId, appwriteApiKey, envSelector, traceId, gatewayAuth, temporaryFrontendAppId));
47609
+ return observe(() => runChat(method, bodyJSON, env, deps, logCtx, historyOwnerId, appwriteApiKey, envSelector, traceId, gatewayAuth, temporaryFrontendAppId, otelTraceId));
47607
47610
  }
47608
47611
  async function chat(ctx) {
47609
47612
  let result;
@@ -47612,15 +47615,19 @@ async function chat(ctx) {
47612
47615
  const bodyJSON = resolveBodyJSON(ctx.req);
47613
47616
  const historyOwnerId = readAuthenticatedUserId(ctx.req.headers);
47614
47617
  const appwriteApiKey = readAppwriteApiKey(ctx.req.headers);
47615
- if (readOperation(bodyJSON) === REPLACE_ANSWER_OPERATION) {
47618
+ const otelTraceIdResult = readOtelTraceId(ctx.req.headers);
47619
+ if (otelTraceIdResult.kind === "invalid") {
47620
+ result = jsonError(400, "invalid_otel_trace_id", "x-linkque-otel-trace-id \u683C\u5F0F\u975E\u6CD5");
47621
+ } else if (readOperation(bodyJSON) === REPLACE_ANSWER_OPERATION) {
47616
47622
  const control = await runReplaceAnswer(ctx.req.method, bodyJSON, process.env, void 0, logCtx, appwriteApiKey);
47617
- return ctx.res.json?.(control.body, control.status);
47623
+ result = control;
47624
+ } else {
47625
+ const envSelector = readEnvSelector(ctx.req.headers);
47626
+ const traceId = readTraceId(ctx.req.headers);
47627
+ const temporaryFrontendAppId = readTemporaryFrontendAppId(ctx.req.headers);
47628
+ const gatewayAuth = historyOwnerId ? resolveLinkqueGatewayRequestAuth(ctx.req.headers, process.env, logCtx) : void 0;
47629
+ result = historyOwnerId ? await runGateway(ctx.req.method, bodyJSON, process.env, void 0, logCtx, historyOwnerId, appwriteApiKey, envSelector, traceId, gatewayAuth, temporaryFrontendAppId, readMcpPhoneAuthorization(ctx.req.headers), otelTraceIdResult.kind === "valid" ? otelTraceIdResult.traceId : void 0) : jsonError(401, "authentication_required", "\u7F3A\u5C11 Appwrite \u8BA4\u8BC1\u7528\u6237");
47618
47630
  }
47619
- const envSelector = readEnvSelector(ctx.req.headers);
47620
- const traceId = readTraceId(ctx.req.headers);
47621
- const temporaryFrontendAppId = readTemporaryFrontendAppId(ctx.req.headers);
47622
- const gatewayAuth = historyOwnerId ? resolveLinkqueGatewayRequestAuth(ctx.req.headers, process.env, logCtx) : void 0;
47623
- result = historyOwnerId ? await runGateway(ctx.req.method, bodyJSON, process.env, void 0, logCtx, historyOwnerId, appwriteApiKey, envSelector, traceId, gatewayAuth, temporaryFrontendAppId, readMcpPhoneAuthorization(ctx.req.headers)) : jsonError(401, "authentication_required", "\u7F3A\u5C11 Appwrite \u8BA4\u8BC1\u7528\u6237");
47624
47631
  } catch (err2) {
47625
47632
  logCtx?.error?.(err2);
47626
47633
  result = err2 instanceof LinkqueGatewayAuthError || err2 instanceof LinkqueGatewayAuthUnconfiguredError ? jsonError(err2.status, err2.code, err2.message) : {
@@ -3,15 +3,15 @@ import {
3
3
  runClientCapability,
4
4
  runClientCapabilityCleanup,
5
5
  runClientCapabilityResult
6
- } from "../../chunk-FA5CNADA.js";
6
+ } from "../../chunk-EHNI5TX3.js";
7
7
  import "../../chunk-IWOFD643.js";
8
8
  import "../../chunk-PXCGFBV5.js";
9
9
  import "../../chunk-ETG6PNHQ.js";
10
- import "../../chunk-H7TMASQH.js";
10
+ import "../../chunk-DPHKD4SK.js";
11
11
  import "../../chunk-EAODRPW4.js";
12
12
  import "../../chunk-GTEZTRCK.js";
13
13
  import "../../chunk-6POVPTQH.js";
14
- import "../../chunk-DNTEEBEH.js";
14
+ import "../../chunk-SICWMO5Y.js";
15
15
  import "../../chunk-2ESYSVXG.js";
16
16
  export {
17
17
  clientCapability as default,
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  getBakedProtocol,
3
3
  setBakedProtocol
4
- } from "../chunk-NE7CUP5E.js";
5
- import "../chunk-H7TMASQH.js";
4
+ } from "../chunk-3J4AB676.js";
5
+ import "../chunk-DPHKD4SK.js";
6
6
  import "../chunk-EAODRPW4.js";
7
7
  import "../chunk-GTEZTRCK.js";
8
8
  import "../chunk-6POVPTQH.js";
9
- import "../chunk-DNTEEBEH.js";
9
+ import "../chunk-SICWMO5Y.js";
10
10
  import "../chunk-2ESYSVXG.js";
11
11
  export {
12
12
  getBakedProtocol,