linkque-cli-v2 1.6.4 → 1.6.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 (25) hide show
  1. package/dev/worker.js +3 -16
  2. package/linkquejs.js +631 -1015
  3. package/package.json +1 -1
  4. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-KDHBKVSL.js → anthropic-messages-5DOLTIGP.js} +15 -14
  5. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{azure-openai-responses-NPKMM3LF.js → azure-openai-responses-HVAVRLTK.js} +9 -7
  6. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-JMBJJF7P.js → chunk-4XAZNSEQ.js} +5 -18
  7. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-UZS5YLV2.js → chunk-IATVK6CO.js} +1 -1
  8. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-J4JCPZDI.js → chunk-Q2Y6LMNC.js} +7 -5
  9. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-RYONFGPP.js +317 -0
  10. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-VBERH5QM.js → chunk-UTJ7DVT7.js} +133 -423
  11. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-XOLFZ4XS.js → chunk-Y3G4J3TB.js} +1 -316
  12. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-CO4I3RJE.js → chunk-YZLXAZFT.js} +2 -15
  13. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{dist-TGBYXSBU.js → dist-ZPLSQEAM.js} +42 -27
  14. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{google-generative-ai-KD7MXONK.js → google-generative-ai-OLT56CSV.js} +10 -8
  15. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{google-vertex-TREYA472.js → google-vertex-4DBBJ7SR.js} +11 -9
  16. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{mistral-conversations-OEOTQWE5.js → mistral-conversations-OEBGEDLQ.js} +9 -7
  17. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{openai-codex-responses-GEFKSNVN.js → openai-codex-responses-3KOC6KHN.js} +12 -10
  18. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{openai-completions-TAACO6T5.js → openai-completions-HG6OJRL5.js} +15 -13
  19. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{openai-responses-4DDTXIGI.js → openai-responses-F6V2PG3Y.js} +14 -12
  20. package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js +60 -181
  21. package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/clientCapability.js +2 -2
  22. package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js +2 -2
  23. package/worker.js +183 -381
  24. package/vendor/linkque-agent-appwrite-integrate/dist/esm/anthropic-messages-GSYNBLMR.js +0 -17
  25. package/vendor/linkque-agent-appwrite-integrate/dist/esm/{pi-messages-7JN3W3BC.js → pi-messages-DC4DVRAJ.js} +4 -4
@@ -1,3 +1,7 @@
1
+ import {
2
+ buildCopilotDynamicHeaders,
3
+ hasCopilotVisionInput
4
+ } from "./chunk-XMVFOHGJ.js";
1
5
  import {
2
6
  clampOpenAIPromptCacheKey
3
7
  } from "./chunk-FHNQ6DPF.js";
@@ -9,9 +13,15 @@ import {
9
13
  normalizeProviderError
10
14
  } from "./chunk-NKEOCGYU.js";
11
15
  import {
12
- buildCopilotDynamicHeaders,
13
- hasCopilotVisionInput
14
- } from "./chunk-XMVFOHGJ.js";
16
+ buildBaseOptions,
17
+ transformMessages
18
+ } from "./chunk-RYONFGPP.js";
19
+ import {
20
+ sanitizeSurrogates
21
+ } from "./chunk-CT4G24PS.js";
22
+ import {
23
+ headersToRecord
24
+ } from "./chunk-Y6UTJIT4.js";
15
25
  import {
16
26
  getProviderEnvValue
17
27
  } from "./chunk-B5XRGKYX.js";
@@ -19,20 +29,12 @@ import {
19
29
  parseStreamingJson
20
30
  } from "./chunk-WJHOHUET.js";
21
31
  import {
22
- buildBaseOptions,
23
32
  calculateCost,
24
- clampThinkingLevel,
25
- transformMessages
26
- } from "./chunk-XOLFZ4XS.js";
33
+ clampThinkingLevel
34
+ } from "./chunk-Y3G4J3TB.js";
27
35
  import {
28
36
  AssistantMessageEventStream
29
37
  } from "./chunk-46SEH6ER.js";
30
- import {
31
- sanitizeSurrogates
32
- } from "./chunk-CT4G24PS.js";
33
- import {
34
- headersToRecord
35
- } from "./chunk-Y6UTJIT4.js";
36
38
  import "./chunk-2ESYSVXG.js";
37
39
 
38
40
  // ../../node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js
@@ -1,8 +1,15 @@
1
+ import {
2
+ splitDeferredTools
3
+ } from "./chunk-HTG7JBF2.js";
4
+ import {
5
+ buildCopilotDynamicHeaders,
6
+ hasCopilotVisionInput
7
+ } from "./chunk-XMVFOHGJ.js";
1
8
  import {
2
9
  convertResponsesMessages,
3
10
  convertResponsesTools,
4
11
  processResponsesStream
5
- } from "./chunk-J4JCPZDI.js";
12
+ } from "./chunk-Q2Y6LMNC.js";
6
13
  import "./chunk-UFVAKOTZ.js";
7
14
  import {
8
15
  clampOpenAIPromptCacheKey
@@ -15,27 +22,22 @@ import {
15
22
  normalizeProviderError
16
23
  } from "./chunk-NKEOCGYU.js";
17
24
  import {
18
- splitDeferredTools
19
- } from "./chunk-HTG7JBF2.js";
25
+ buildBaseOptions
26
+ } from "./chunk-RYONFGPP.js";
27
+ import "./chunk-CT4G24PS.js";
20
28
  import {
21
- buildCopilotDynamicHeaders,
22
- hasCopilotVisionInput
23
- } from "./chunk-XMVFOHGJ.js";
29
+ headersToRecord
30
+ } from "./chunk-Y6UTJIT4.js";
24
31
  import {
25
32
  getProviderEnvValue
26
33
  } from "./chunk-B5XRGKYX.js";
27
34
  import "./chunk-WJHOHUET.js";
28
35
  import {
29
- buildBaseOptions,
30
36
  clampThinkingLevel
31
- } from "./chunk-XOLFZ4XS.js";
37
+ } from "./chunk-Y3G4J3TB.js";
32
38
  import {
33
39
  AssistantMessageEventStream
34
40
  } from "./chunk-46SEH6ER.js";
35
- import "./chunk-CT4G24PS.js";
36
- import {
37
- headersToRecord
38
- } from "./chunk-Y6UTJIT4.js";
39
41
  import "./chunk-2ESYSVXG.js";
40
42
 
41
43
  // ../../node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js
@@ -1,29 +1,18 @@
1
1
  import "../../chunk-6MHDOBWO.js";
2
2
  import "../../chunk-E2P6TIFG.js";
3
- import {
4
- Anthropic,
5
- stream
6
- } from "../../chunk-KDHBKVSL.js";
7
- import "../../chunk-HTG7JBF2.js";
8
- import "../../chunk-XMVFOHGJ.js";
9
3
  import {
10
4
  getProviderEnvValue
11
5
  } from "../../chunk-B5XRGKYX.js";
12
6
  import "../../chunk-WJHOHUET.js";
13
7
  import {
14
- adjustMaxTokensForThinking,
15
- buildBaseOptions,
16
- clampMaxTokensToContext,
17
8
  createModels,
18
9
  createProvider,
19
10
  lazyApi,
20
11
  lazyStream
21
- } from "../../chunk-XOLFZ4XS.js";
12
+ } from "../../chunk-Y3G4J3TB.js";
22
13
  import {
23
14
  createAssistantMessageEventStream
24
15
  } from "../../chunk-46SEH6ER.js";
25
- import "../../chunk-CT4G24PS.js";
26
- import "../../chunk-Y6UTJIT4.js";
27
16
  import {
28
17
  APPBASE_RUNTIME_CONFIG_DEFAULTS,
29
18
  AppbaseRuntimeConfigProvider,
@@ -46,17 +35,17 @@ import {
46
35
  readTraceId,
47
36
  resolveBodyJSON,
48
37
  resolveGatewayAuthContext,
49
- resolveLinkqueGatewayRequestAuth,
38
+ resolveLinkqueGatewayAuth,
50
39
  resolveRunStorage,
51
40
  toAgentRunMessages,
52
41
  withIsoTimestamp
53
- } from "../../chunk-CO4I3RJE.js";
42
+ } from "../../chunk-YZLXAZFT.js";
54
43
  import "../../chunk-IWOFD643.js";
55
44
  import "../../chunk-PXCGFBV5.js";
56
45
  import "../../chunk-ETG6PNHQ.js";
57
46
  import {
58
47
  getBakedProtocol
59
- } from "../../chunk-UZS5YLV2.js";
48
+ } from "../../chunk-IATVK6CO.js";
60
49
  import {
61
50
  ACTIVATE_SKILL_TOOL_NAME,
62
51
  CANCEL_CONVERSATION_RUN_OPERATION,
@@ -140,7 +129,6 @@ import {
140
129
  createA2UICardPipelineModelInputSchema,
141
130
  createActivateSkillTool,
142
131
  createCardPresentationToolName,
143
- createGatewayRunAuthorization,
144
132
  createKnowledgeTools,
145
133
  createPresentationDescription,
146
134
  createPresentationResult,
@@ -194,7 +182,7 @@ import {
194
182
  warnLogFailure,
195
183
  wrapToolWithHooks,
196
184
  writeJsonPointer
197
- } from "../../chunk-VBERH5QM.js";
185
+ } from "../../chunk-UTJ7DVT7.js";
198
186
  import "../../chunk-EAODRPW4.js";
199
187
  import "../../chunk-XUFLSZM4.js";
200
188
  import "../../chunk-GAYNLDWK.js";
@@ -8419,10 +8407,10 @@ function projectProviderUsage(usage) {
8419
8407
  }
8420
8408
 
8421
8409
  // ../../node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.lazy.js
8422
- var anthropicMessagesApi = () => lazyApi(() => import("../../anthropic-messages-GSYNBLMR.js"));
8410
+ var anthropicMessagesApi = () => lazyApi(() => import("../../anthropic-messages-5DOLTIGP.js"));
8423
8411
 
8424
8412
  // ../../node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.lazy.js
8425
- var azureOpenAIResponsesApi = () => lazyApi(() => import("../../azure-openai-responses-NPKMM3LF.js"));
8413
+ var azureOpenAIResponsesApi = () => lazyApi(() => import("../../azure-openai-responses-HVAVRLTK.js"));
8426
8414
 
8427
8415
  // ../../node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.lazy.js
8428
8416
  var __rewriteRelativeImportExtension = function(path, preserveJsx) {
@@ -8441,25 +8429,25 @@ var bedrockModuleOverride;
8441
8429
  var bedrockConverseStreamApi = () => lazyApi(async () => bedrockModuleOverride ?? await importNodeOnlyApi("./bedrock-converse-stream.ts"));
8442
8430
 
8443
8431
  // ../../node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.lazy.js
8444
- var googleGenerativeAIApi = () => lazyApi(() => import("../../google-generative-ai-KD7MXONK.js"));
8432
+ var googleGenerativeAIApi = () => lazyApi(() => import("../../google-generative-ai-OLT56CSV.js"));
8445
8433
 
8446
8434
  // ../../node_modules/@earendil-works/pi-ai/dist/api/google-vertex.lazy.js
8447
- var googleVertexApi = () => lazyApi(() => import("../../google-vertex-TREYA472.js"));
8435
+ var googleVertexApi = () => lazyApi(() => import("../../google-vertex-4DBBJ7SR.js"));
8448
8436
 
8449
8437
  // ../../node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.lazy.js
8450
- var mistralConversationsApi = () => lazyApi(() => import("../../mistral-conversations-OEOTQWE5.js"));
8438
+ var mistralConversationsApi = () => lazyApi(() => import("../../mistral-conversations-OEBGEDLQ.js"));
8451
8439
 
8452
8440
  // ../../node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.lazy.js
8453
- var openAICodexResponsesApi = () => lazyApi(() => import("../../openai-codex-responses-GEFKSNVN.js"));
8441
+ var openAICodexResponsesApi = () => lazyApi(() => import("../../openai-codex-responses-3KOC6KHN.js"));
8454
8442
 
8455
8443
  // ../../node_modules/@earendil-works/pi-ai/dist/api/openai-completions.lazy.js
8456
- var openAICompletionsApi = () => lazyApi(() => import("../../openai-completions-TAACO6T5.js"));
8444
+ var openAICompletionsApi = () => lazyApi(() => import("../../openai-completions-HG6OJRL5.js"));
8457
8445
 
8458
8446
  // ../../node_modules/@earendil-works/pi-ai/dist/api/openai-responses.lazy.js
8459
- var openAIResponsesApi = () => lazyApi(() => import("../../openai-responses-4DDTXIGI.js"));
8447
+ var openAIResponsesApi = () => lazyApi(() => import("../../openai-responses-F6V2PG3Y.js"));
8460
8448
 
8461
8449
  // ../../node_modules/@earendil-works/pi-ai/dist/api/pi-messages.lazy.js
8462
- var piMessagesApi = () => lazyApi(() => import("../../pi-messages-7JN3W3BC.js"));
8450
+ var piMessagesApi = () => lazyApi(() => import("../../pi-messages-DC4DVRAJ.js"));
8463
8451
 
8464
8452
  // ../../node_modules/@earendil-works/pi-ai/dist/env-api-keys.js
8465
8453
  var __rewriteRelativeImportExtension2 = function(path, preserveJsx) {
@@ -13558,38 +13546,38 @@ function scheduleChunk(chunk, tokensPerSecond) {
13558
13546
  const delayMs = estimateTokens(chunk) / tokensPerSecond * 1e3;
13559
13547
  return new Promise((resolve) => setTimeout(resolve, delayMs));
13560
13548
  }
13561
- async function streamWithDeltas(stream2, message, minTokenSize, maxTokenSize, tokensPerSecond, signal) {
13549
+ async function streamWithDeltas(stream, message, minTokenSize, maxTokenSize, tokensPerSecond, signal) {
13562
13550
  const partial = { ...message, content: [] };
13563
13551
  if (signal?.aborted) {
13564
13552
  const aborted = createAbortedMessage(partial);
13565
- stream2.push({ type: "error", reason: "aborted", error: aborted });
13566
- stream2.end(aborted);
13553
+ stream.push({ type: "error", reason: "aborted", error: aborted });
13554
+ stream.end(aborted);
13567
13555
  return;
13568
13556
  }
13569
- stream2.push({ type: "start", partial: { ...partial } });
13557
+ stream.push({ type: "start", partial: { ...partial } });
13570
13558
  for (let index2 = 0; index2 < message.content.length; index2++) {
13571
13559
  if (signal?.aborted) {
13572
13560
  const aborted = createAbortedMessage(partial);
13573
- stream2.push({ type: "error", reason: "aborted", error: aborted });
13574
- stream2.end(aborted);
13561
+ stream.push({ type: "error", reason: "aborted", error: aborted });
13562
+ stream.end(aborted);
13575
13563
  return;
13576
13564
  }
13577
13565
  const block = message.content[index2];
13578
13566
  if (block.type === "thinking") {
13579
13567
  partial.content = [...partial.content, { type: "thinking", thinking: "" }];
13580
- stream2.push({ type: "thinking_start", contentIndex: index2, partial: { ...partial } });
13568
+ stream.push({ type: "thinking_start", contentIndex: index2, partial: { ...partial } });
13581
13569
  for (const chunk of splitStringByTokenSize(block.thinking, minTokenSize, maxTokenSize)) {
13582
13570
  await scheduleChunk(chunk, tokensPerSecond);
13583
13571
  if (signal?.aborted) {
13584
13572
  const aborted = createAbortedMessage(partial);
13585
- stream2.push({ type: "error", reason: "aborted", error: aborted });
13586
- stream2.end(aborted);
13573
+ stream.push({ type: "error", reason: "aborted", error: aborted });
13574
+ stream.end(aborted);
13587
13575
  return;
13588
13576
  }
13589
13577
  partial.content[index2].thinking += chunk;
13590
- stream2.push({ type: "thinking_delta", contentIndex: index2, delta: chunk, partial: { ...partial } });
13578
+ stream.push({ type: "thinking_delta", contentIndex: index2, delta: chunk, partial: { ...partial } });
13591
13579
  }
13592
- stream2.push({
13580
+ stream.push({
13593
13581
  type: "thinking_end",
13594
13582
  contentIndex: index2,
13595
13583
  content: block.thinking,
@@ -13599,43 +13587,43 @@ async function streamWithDeltas(stream2, message, minTokenSize, maxTokenSize, to
13599
13587
  }
13600
13588
  if (block.type === "text") {
13601
13589
  partial.content = [...partial.content, { type: "text", text: "" }];
13602
- stream2.push({ type: "text_start", contentIndex: index2, partial: { ...partial } });
13590
+ stream.push({ type: "text_start", contentIndex: index2, partial: { ...partial } });
13603
13591
  for (const chunk of splitStringByTokenSize(block.text, minTokenSize, maxTokenSize)) {
13604
13592
  await scheduleChunk(chunk, tokensPerSecond);
13605
13593
  if (signal?.aborted) {
13606
13594
  const aborted = createAbortedMessage(partial);
13607
- stream2.push({ type: "error", reason: "aborted", error: aborted });
13608
- stream2.end(aborted);
13595
+ stream.push({ type: "error", reason: "aborted", error: aborted });
13596
+ stream.end(aborted);
13609
13597
  return;
13610
13598
  }
13611
13599
  partial.content[index2].text += chunk;
13612
- stream2.push({ type: "text_delta", contentIndex: index2, delta: chunk, partial: { ...partial } });
13600
+ stream.push({ type: "text_delta", contentIndex: index2, delta: chunk, partial: { ...partial } });
13613
13601
  }
13614
- stream2.push({ type: "text_end", contentIndex: index2, content: block.text, partial: { ...partial } });
13602
+ stream.push({ type: "text_end", contentIndex: index2, content: block.text, partial: { ...partial } });
13615
13603
  continue;
13616
13604
  }
13617
13605
  partial.content = [...partial.content, { type: "toolCall", id: block.id, name: block.name, arguments: {} }];
13618
- stream2.push({ type: "toolcall_start", contentIndex: index2, partial: { ...partial } });
13606
+ stream.push({ type: "toolcall_start", contentIndex: index2, partial: { ...partial } });
13619
13607
  for (const chunk of splitStringByTokenSize(JSON.stringify(block.arguments), minTokenSize, maxTokenSize)) {
13620
13608
  await scheduleChunk(chunk, tokensPerSecond);
13621
13609
  if (signal?.aborted) {
13622
13610
  const aborted = createAbortedMessage(partial);
13623
- stream2.push({ type: "error", reason: "aborted", error: aborted });
13624
- stream2.end(aborted);
13611
+ stream.push({ type: "error", reason: "aborted", error: aborted });
13612
+ stream.end(aborted);
13625
13613
  return;
13626
13614
  }
13627
- stream2.push({ type: "toolcall_delta", contentIndex: index2, delta: chunk, partial: { ...partial } });
13615
+ stream.push({ type: "toolcall_delta", contentIndex: index2, delta: chunk, partial: { ...partial } });
13628
13616
  }
13629
13617
  partial.content[index2].arguments = block.arguments;
13630
- stream2.push({ type: "toolcall_end", contentIndex: index2, toolCall: block, partial: { ...partial } });
13618
+ stream.push({ type: "toolcall_end", contentIndex: index2, toolCall: block, partial: { ...partial } });
13631
13619
  }
13632
13620
  if (message.stopReason === "error" || message.stopReason === "aborted") {
13633
- stream2.push({ type: "error", reason: message.stopReason, error: message });
13634
- stream2.end(message);
13621
+ stream.push({ type: "error", reason: message.stopReason, error: message });
13622
+ stream.end(message);
13635
13623
  return;
13636
13624
  }
13637
- stream2.push({ type: "done", reason: message.stopReason, message });
13638
- stream2.end(message);
13625
+ stream.push({ type: "done", reason: message.stopReason, message });
13626
+ stream.end(message);
13639
13627
  }
13640
13628
  function createFauxCore(options) {
13641
13629
  const api = options.api ?? randomId(DEFAULT_API);
@@ -13669,7 +13657,7 @@ function createFauxCore(options) {
13669
13657
  contextWindow: definition.contextWindow ?? 128e3,
13670
13658
  maxTokens: definition.maxTokens ?? 16384
13671
13659
  }));
13672
- const stream2 = (requestModel, context, streamOptions) => {
13660
+ const stream = (requestModel, context, streamOptions) => {
13673
13661
  const outer = createAssistantMessageEventStream();
13674
13662
  const step = pendingResponses.shift();
13675
13663
  state2.callCount++;
@@ -13695,7 +13683,7 @@ function createFauxCore(options) {
13695
13683
  });
13696
13684
  return outer;
13697
13685
  };
13698
- const streamSimple2 = (streamModel, context, streamOptions) => stream2(streamModel, context, streamOptions);
13686
+ const streamSimple2 = (streamModel, context, streamOptions) => stream(streamModel, context, streamOptions);
13699
13687
  function getModel(requestedModelId) {
13700
13688
  if (!requestedModelId) {
13701
13689
  return models[0];
@@ -13706,7 +13694,7 @@ function createFauxCore(options) {
13706
13694
  api,
13707
13695
  provider,
13708
13696
  models,
13709
- stream: stream2,
13697
+ stream,
13710
13698
  streamSimple: streamSimple2,
13711
13699
  getModel,
13712
13700
  state: state2,
@@ -38801,12 +38789,12 @@ function builtinModels(options) {
38801
38789
 
38802
38790
  // ../../node_modules/@earendil-works/pi-ai/dist/compat.js
38803
38791
  var apiProviderRegistry = /* @__PURE__ */ new Map();
38804
- function wrapStream(api, stream2) {
38792
+ function wrapStream(api, stream) {
38805
38793
  return (model, context, options) => {
38806
38794
  if (model.api !== api) {
38807
38795
  throw new Error(`Mismatched api: ${model.api} expected ${api}`);
38808
38796
  }
38809
- return stream2(model, context, options);
38797
+ return stream(model, context, options);
38810
38798
  };
38811
38799
  }
38812
38800
  function wrapStreamSimple(api, streamSimple2) {
@@ -40237,47 +40225,6 @@ function createTestProvider() {
40237
40225
  return { providerId: TEST_PROVIDER_ID, core, provider };
40238
40226
  }
40239
40227
 
40240
- // ../linkque-agent-runtime/dist/esm/impl/agent/pi/provider/base/transportAnthropicApi.js
40241
- function createTransportAnthropicApi(modelFetch) {
40242
- const call = (model, context, options = {}) => {
40243
- const client = new Anthropic({
40244
- baseURL: model.baseUrl,
40245
- apiKey: options.apiKey ?? null,
40246
- authToken: null,
40247
- defaultHeaders: { ...model.headers, ...options.headers },
40248
- fetch: modelFetch,
40249
- maxRetries: 0
40250
- });
40251
- return stream(model, context, {
40252
- ...options,
40253
- client,
40254
- maxRetries: 0
40255
- });
40256
- };
40257
- const simple = (model, context, options) => {
40258
- const base = buildBaseOptions(model, context, options, options?.apiKey);
40259
- if (!options?.reasoning)
40260
- return call(model, context, { ...base, thinkingEnabled: false });
40261
- if (model.compat?.forceAdaptiveThinking === true) {
40262
- const mapped = model.thinkingLevelMap?.[options.reasoning];
40263
- const effort = typeof mapped === "string" ? mapped : options.reasoning === "minimal" || options.reasoning === "low" ? "low" : options.reasoning === "medium" ? "medium" : "high";
40264
- return call(model, context, { ...base, thinkingEnabled: true, effort });
40265
- }
40266
- const adjusted = adjustMaxTokensForThinking(base.maxTokens, model.maxTokens, options.reasoning, options.thinkingBudgets);
40267
- const maxTokens = clampMaxTokensToContext(model, context, adjusted.maxTokens);
40268
- return call(model, context, {
40269
- ...base,
40270
- thinkingEnabled: true,
40271
- maxTokens,
40272
- thinkingBudgetTokens: Math.min(adjusted.thinkingBudget, Math.max(0, maxTokens - 1024))
40273
- });
40274
- };
40275
- return {
40276
- stream: (m, c, o) => call(m, c, o),
40277
- streamSimple: (m, c, o) => simple(m, c, o)
40278
- };
40279
- }
40280
-
40281
40228
  // ../linkque-agent-runtime/dist/esm/impl/agent/pi/provider/base/anthropicProvider.js
40282
40229
  function createApiKeyAuth(authName, fixedApiKey) {
40283
40230
  return {
@@ -40300,7 +40247,7 @@ function createAnthropicProvider(options) {
40300
40247
  auth: { apiKey: createApiKeyAuth(authName, fixedApiKey) },
40301
40248
  models,
40302
40249
  // 复用 pi-ai 内置的 Anthropic Messages 协议实现(含 stream/SSE 逻辑)
40303
- api: options.modelFetch ? createTransportAnthropicApi(options.modelFetch) : anthropicMessagesApi()
40250
+ api: anthropicMessagesApi()
40304
40251
  });
40305
40252
  }
40306
40253
  function buildAnthropicModel(providerId, baseUrl, descriptor) {
@@ -40400,14 +40347,13 @@ function createLinkqueModel(modelId, baseUrl = LINKQUE_DEFAULT_BASE_URL) {
40400
40347
  id: modelId
40401
40348
  });
40402
40349
  }
40403
- function createLinkqueProvider(baseUrl = LINKQUE_DEFAULT_BASE_URL, modelFetch) {
40350
+ function createLinkqueProvider(baseUrl = LINKQUE_DEFAULT_BASE_URL) {
40404
40351
  return createAnthropicProvider({
40405
40352
  providerId: LINKQUE_PROVIDER_ID,
40406
40353
  providerName: "Linkque",
40407
40354
  baseUrl,
40408
40355
  models: LINKQUE_MODELS,
40409
- authName: "Linkque API key",
40410
- modelFetch
40356
+ authName: "Linkque API key"
40411
40357
  });
40412
40358
  }
40413
40359
 
@@ -40630,7 +40576,7 @@ var StreamBridge = class {
40630
40576
  async startSession() {
40631
40577
  const models = createModels();
40632
40578
  const providerId = providerIdFor(this.auth.provider);
40633
- models.setProvider(createLinkqueProvider(this.linkqueBaseUrl, this.auth.modelFetch));
40579
+ models.setProvider(createLinkqueProvider(this.linkqueBaseUrl));
40634
40580
  models.setProvider(createTestProvider().provider);
40635
40581
  let model;
40636
40582
  if (this.options.model !== void 0) {
@@ -40816,7 +40762,7 @@ var PiFollowUpQuestionGenerator = class {
40816
40762
  }
40817
40763
  async generate(input) {
40818
40764
  const models = this.modelsFactory();
40819
- models.setProvider(createLinkqueProvider(this.linkqueBaseUrl, input.auth.modelFetch));
40765
+ models.setProvider(createLinkqueProvider(this.linkqueBaseUrl));
40820
40766
  let model = models.getModel(LINKQUE_PROVIDER_ID, FOLLOW_UP_QUESTION_MODEL_ID);
40821
40767
  model ??= createLinkqueModel(FOLLOW_UP_QUESTION_MODEL_ID, this.linkqueBaseUrl);
40822
40768
  model = {
@@ -41313,24 +41259,6 @@ var EMPTY_TELEMETRY_RUN_CONTEXT = {
41313
41259
  userKey: ""
41314
41260
  };
41315
41261
 
41316
- // ../linkque-agent-runtime/dist/esm/core/scenarioRunAuthorization.js
41317
- async function authorizeAgentRun(runId, identity, port) {
41318
- if (typeof runId !== "string" || !/^[\x21-\x7e]{1,64}$/u.test(runId) || typeof identity?.userId !== "string" || !/^[\x21-\x7e]{1,128}$/u.test(identity.userId) || typeof identity.agentId !== "string" || !/^[A-Za-z0-9_-]{1,128}$/u.test(identity.agentId)) {
41319
- throw new Error("SCENARIO_RUNTIME_AUTH_INVALID");
41320
- }
41321
- const result = await port.authorizeRun({
41322
- runId,
41323
- agentId: identity.agentId,
41324
- appbaseUserId: identity.userId
41325
- });
41326
- if (result?.quotaMode === "NORMAL")
41327
- return { quotaMode: "NORMAL" };
41328
- if (result?.quotaMode !== "LIMITED" && result?.quotaMode !== "AUTH_ONLY" || typeof result.modelFetch !== "function") {
41329
- throw new Error("SCENARIO_RUN_UNAVAILABLE");
41330
- }
41331
- return result;
41332
- }
41333
-
41334
41262
  // ../linkque-agent-runtime/dist/esm/core/agentRuntimePlugin.js
41335
41263
  var validatePlugins = (plugins) => {
41336
41264
  const names = /* @__PURE__ */ new Set();
@@ -42655,28 +42583,6 @@ var AgentRuntime = class _AgentRuntime {
42655
42583
  }
42656
42584
  /** 产出 AgentStreamEvent 流;内核编排「解析上行资源 → 组请求 → agent loop」。 */
42657
42585
  async *runAgentLoop(request, auth, options = {}) {
42658
- if (options.runAuthorization) {
42659
- try {
42660
- const grant = await authorizeAgentRun(request.runId, options.runtimeContext, options.runAuthorization);
42661
- if (grant.quotaMode !== "NORMAL")
42662
- auth = { ...auth, modelFetch: grant.modelFetch };
42663
- } catch (error) {
42664
- const reason = error instanceof Error ? error.message : "";
42665
- const code = [
42666
- "SCENARIO_TURN_LIMIT",
42667
- "SCENARIO_RUNTIME_AUTH_INVALID",
42668
- "SCENARIO_RUNTIME_REPLAY"
42669
- ].includes(reason) ? reason : "SCENARIO_RUN_UNAVAILABLE";
42670
- yield {
42671
- type: "error",
42672
- error: {
42673
- code,
42674
- message: code === "SCENARIO_TURN_LIMIT" ? "\u4F53\u9A8C\u5BF9\u8BDD\u6B21\u6570\u5DF2\u7528\u5B8C" : "\u672C\u8F6E\u5BF9\u8BDD\u672A\u83B7\u51C6\u6267\u884C"
42675
- }
42676
- };
42677
- return;
42678
- }
42679
- }
42680
42586
  const input = {
42681
42587
  runId: request.runId,
42682
42588
  agentId: options.runtimeContext?.agentId ?? this.agentId,
@@ -43452,7 +43358,6 @@ async function waitForObservation(promise, signal) {
43452
43358
  function createImageTool(image, input, options, rules) {
43453
43359
  const fetchImpl = options.fetchImpl ?? globalThis.fetch;
43454
43360
  const auth = { ...input.auth };
43455
- const modelFetch = auth.modelFetch ?? fetchImpl;
43456
43361
  const cache = /* @__PURE__ */ new Map();
43457
43362
  let calls = 0;
43458
43363
  return {
@@ -43492,7 +43397,7 @@ function createImageTool(image, input, options, rules) {
43492
43397
  const pending = (async () => {
43493
43398
  try {
43494
43399
  const resolved = await resolveImage(image, fetchImpl, rules, signal);
43495
- const response = await modelFetch(`${(options.baseUrl ?? RUNTIME_CONFIG_DEFAULTS.LINKQUE_BASE_URL).replace(/\/+$/, "")}/v1/messages`, {
43400
+ const response = await fetchImpl(`${(options.baseUrl ?? RUNTIME_CONFIG_DEFAULTS.LINKQUE_BASE_URL).replace(/\/+$/, "")}/v1/messages`, {
43496
43401
  method: "POST",
43497
43402
  signal,
43498
43403
  redirect: "error",
@@ -46471,32 +46376,19 @@ function resolveChatDeps(env, deps, logCtx, historyOwnerId, appwriteApiKey, envS
46471
46376
  }
46472
46377
  const mcpAuthorizationHeaderProvider = async () => resolved.authorizationHeader;
46473
46378
  const { linkqueBaseUrl, knowledgeBaseUrl, skillLoaderBaseUrl, webSearchBaseUrl, eventBaseUrl, mcpSignEndpoint, openMcpBaseUrl, telemetryLogsEndpoint, telemetryTracesEndpoint } = resolveLinkqueEndpoints(env, envSelector);
46474
- let runAuthorization = deps?.runAuthorization;
46475
- const isScenarioUser = /^lqs_[a-f0-9]{32}$/u.test(historyOwnerId ?? "");
46476
- if (!runAuthorization && isScenarioUser) {
46477
- try {
46478
- if (resolved.mode !== "user-token")
46479
- throw new Error("scenario user token required");
46480
- const accessKey = env.LINKQUE_AGENT_ACCESS_KEY?.trim() ?? "";
46481
- if (!accessKey || !linkqueBaseUrl)
46482
- throw new Error("invalid config");
46483
- runAuthorization = createGatewayRunAuthorization({
46484
- baseUrl: linkqueBaseUrl,
46485
- token: resolved.modelCredential,
46486
- accessKey
46487
- });
46488
- } catch {
46489
- return jsonError(503, "SCENARIO_RUN_UNAVAILABLE", "\u573A\u666F\u53EF\u4FE1\u8BA4\u8BC1\u914D\u7F6E\u6682\u4E0D\u53EF\u7528");
46490
- }
46491
- }
46492
46379
  const mcpConfigResolver = createAppbaseMcpConfigResolver({
46493
46380
  agentId: protocol.agentId,
46494
46381
  remoteBaseUrl: openMcpBaseUrl,
46495
46382
  ...mcpSignEndpoint ? { signEndpoint: mcpSignEndpoint } : {}
46496
46383
  });
46384
+ const mcpDebugLog = isDebugLogLevel(env) && logCtx?.log ? (line, scope) => {
46385
+ const prefix = scope ? `[${scope}] ` : "";
46386
+ logCtx.log?.(prefix + line);
46387
+ } : void 0;
46497
46388
  const rawMcpServerProvider = deps?.mcpServerProvider ?? createAppbaseMcpProvider({
46498
46389
  resolveConfig: mcpConfigResolver,
46499
- getAuthorizationHeader: mcpAuthorizationHeaderProvider
46390
+ getAuthorizationHeader: mcpAuthorizationHeaderProvider,
46391
+ ...mcpDebugLog ? { debugLog: mcpDebugLog } : {}
46500
46392
  });
46501
46393
  const mcpServerProvider = rawMcpServerProvider;
46502
46394
  const securityAnswerPlugin = deps?.securityAnswerPlugin ?? createSecurityAnswerPlugin(historyStore, logCtx?.log);
@@ -46528,7 +46420,6 @@ function resolveChatDeps(env, deps, logCtx, historyOwnerId, appwriteApiKey, envS
46528
46420
  ...temporaryFrontendAppId !== void 0 && { temporaryFrontendAppId }
46529
46421
  }, logCtx);
46530
46422
  return {
46531
- ...runAuthorization ? { runAuthorization } : {},
46532
46423
  auth: resolved.auth,
46533
46424
  // 模型取自 bundler 已 bake-in 的 protocol 默认模型(历史来自 env AGENT_MODEL,已移除)。
46534
46425
  model: protocol.agent.model.defaultModel || void 0,
@@ -46664,12 +46555,12 @@ function preview(value, max = DEBUG_PREVIEW_MAX) {
46664
46555
  str = str.replace(/\s+/g, " ").trim();
46665
46556
  return str.length > max ? `${str.slice(0, max)}\u2026` : str;
46666
46557
  }
46667
- async function* debugLogAgentStream(stream2, debugLog) {
46558
+ async function* debugLogAgentStream(stream, debugLog) {
46668
46559
  const start = Date.now();
46669
46560
  let firstResponseLogged = false;
46670
46561
  const counts = { delta: 0, thinking: 0, tool: 0, card: 0 };
46671
46562
  const summary = () => `\u4E8B\u4EF6\u603B\u6570=${counts.delta + counts.thinking + counts.tool + counts.card}(delta=${counts.delta},thinking=${counts.thinking},tool=${counts.tool},card=${counts.card})`;
46672
- for await (const ev of stream2) {
46563
+ for await (const ev of stream) {
46673
46564
  switch (ev.type) {
46674
46565
  case "delta":
46675
46566
  counts.delta += 1;
@@ -46961,20 +46852,9 @@ async function runAgentToChunksObserved(observation, deps, request, env, logCtx,
46961
46852
  securityAnswer: false
46962
46853
  };
46963
46854
  }
46964
- let modelAuth = deps.auth;
46965
46855
  const runOptions = {
46966
46856
  telemetryContext: observation.runtimeContext,
46967
46857
  eventObservations: observation.events,
46968
- ...deps.runAuthorization ? {
46969
- runAuthorization: {
46970
- authorizeRun: async (input) => {
46971
- const grant = await deps.runAuthorization.authorizeRun(input);
46972
- if (grant.quotaMode !== "NORMAL")
46973
- modelAuth = { ...deps.auth, modelFetch: grant.modelFetch };
46974
- return grant;
46975
- }
46976
- }
46977
- } : {},
46978
46858
  requestSource: EModelRequestSource.APPBASE_FUNCTION,
46979
46859
  runtimeContext: {
46980
46860
  agentId: deps.protocol.agentId,
@@ -47116,7 +46996,6 @@ async function runAgentToChunksObserved(observation, deps, request, env, logCtx,
47116
46996
  }
47117
46997
  }
47118
46998
  return {
47119
- modelAuth,
47120
46999
  response: completionError ? jsonError(500, "run_completion_failed", "\u4F1A\u8BDD\u6536\u5C3E\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002") : {
47121
47000
  status: 201,
47122
47001
  body: { runId: request.runId, threadId: request.threadId }
@@ -47438,7 +47317,7 @@ async function runChat(method, bodyJSON, env, deps, logCtx, historyOwnerId, appw
47438
47317
  if (!preparedFollowUpContext || await isAnswerBlocked())
47439
47318
  return execution.response;
47440
47319
  const generationStartedAt = Date.now();
47441
- const questions = await cfg.runtime.generateFollowUpQuestions(preparedFollowUpContext, execution.modelAuth ?? cfg.auth, {
47320
+ const questions = await cfg.runtime.generateFollowUpQuestions(preparedFollowUpContext, cfg.auth, {
47442
47321
  runId: request.runId,
47443
47322
  requestSource: EModelRequestSource.APPBASE_FUNCTION,
47444
47323
  telemetryContext: cfg.telemetry?.createContext(request.runId),
@@ -47631,7 +47510,7 @@ async function chat(ctx) {
47631
47510
  const envSelector = readEnvSelector(ctx.req.headers);
47632
47511
  const traceId = readTraceId(ctx.req.headers);
47633
47512
  const temporaryFrontendAppId = readTemporaryFrontendAppId(ctx.req.headers);
47634
- const gatewayAuth = historyOwnerId ? resolveLinkqueGatewayRequestAuth(ctx.req.headers, process.env, logCtx) : void 0;
47513
+ const gatewayAuth = historyOwnerId ? resolveLinkqueGatewayAuth(ctx.req.headers, process.env, logCtx) : void 0;
47635
47514
  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");
47636
47515
  } catch (err2) {
47637
47516
  logCtx?.error?.(err2);
@@ -3,11 +3,11 @@ import {
3
3
  runClientCapability,
4
4
  runClientCapabilityCleanup,
5
5
  runClientCapabilityResult
6
- } from "../../chunk-CO4I3RJE.js";
6
+ } from "../../chunk-YZLXAZFT.js";
7
7
  import "../../chunk-IWOFD643.js";
8
8
  import "../../chunk-PXCGFBV5.js";
9
9
  import "../../chunk-ETG6PNHQ.js";
10
- import "../../chunk-VBERH5QM.js";
10
+ import "../../chunk-UTJ7DVT7.js";
11
11
  import "../../chunk-EAODRPW4.js";
12
12
  import "../../chunk-XUFLSZM4.js";
13
13
  import "../../chunk-GAYNLDWK.js";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  getBakedProtocol,
3
3
  setBakedProtocol
4
- } from "../chunk-UZS5YLV2.js";
5
- import "../chunk-VBERH5QM.js";
4
+ } from "../chunk-IATVK6CO.js";
5
+ import "../chunk-UTJ7DVT7.js";
6
6
  import "../chunk-EAODRPW4.js";
7
7
  import "../chunk-XUFLSZM4.js";
8
8
  import "../chunk-GAYNLDWK.js";