@theokit/sdk 5.10.0 → 5.11.0

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 (58) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/dist/{agent-TLRURB7W.cjs → agent-5DOR5T3E.cjs} +7 -6
  3. package/dist/{agent-TLRURB7W.cjs.map → agent-5DOR5T3E.cjs.map} +1 -1
  4. package/dist/{agent-XTLAVVYC.js → agent-GWKRARAL.js} +6 -5
  5. package/dist/{agent-XTLAVVYC.js.map → agent-GWKRARAL.js.map} +1 -1
  6. package/dist/{chunk-RTE2DD4S.js → chunk-4PHSVR2R.js} +50 -32
  7. package/dist/chunk-4PHSVR2R.js.map +1 -0
  8. package/dist/{chunk-PCLRIQPX.cjs → chunk-5H2GJXGC.cjs} +4 -4
  9. package/dist/{chunk-PCLRIQPX.cjs.map → chunk-5H2GJXGC.cjs.map} +1 -1
  10. package/dist/{chunk-CVEQ5366.cjs → chunk-5OHB5HJF.cjs} +90 -72
  11. package/dist/chunk-5OHB5HJF.cjs.map +1 -0
  12. package/dist/{chunk-EVH3OUMY.js → chunk-74OA5DIM.js} +189 -43
  13. package/dist/chunk-74OA5DIM.js.map +1 -0
  14. package/dist/{chunk-EXI7EHDN.js → chunk-7Y23B7XX.js} +3 -3
  15. package/dist/{chunk-EXI7EHDN.js.map → chunk-7Y23B7XX.js.map} +1 -1
  16. package/dist/{chunk-QY3CIMUV.cjs → chunk-BZKF7TXX.cjs} +192 -44
  17. package/dist/chunk-BZKF7TXX.cjs.map +1 -0
  18. package/dist/chunk-LZJXEPEQ.js +58 -0
  19. package/dist/chunk-LZJXEPEQ.js.map +1 -0
  20. package/dist/{chunk-FR6COQXZ.cjs → chunk-N7ZIPW2N.cjs} +3 -3
  21. package/dist/{chunk-FR6COQXZ.cjs.map → chunk-N7ZIPW2N.cjs.map} +1 -1
  22. package/dist/chunk-NWS2CS3Y.cjs +61 -0
  23. package/dist/chunk-NWS2CS3Y.cjs.map +1 -0
  24. package/dist/{chunk-523O5UYB.js → chunk-Z5BAFHPU.js} +3 -3
  25. package/dist/{chunk-523O5UYB.js.map → chunk-Z5BAFHPU.js.map} +1 -1
  26. package/dist/{compact-session-4QHBBGEY.cjs → compact-session-2AETONOS.cjs} +12 -12
  27. package/dist/{compact-session-4QHBBGEY.cjs.map → compact-session-2AETONOS.cjs.map} +1 -1
  28. package/dist/{compact-session-PVAWTKKL.js → compact-session-F2UDGZCN.js} +3 -3
  29. package/dist/{compact-session-PVAWTKKL.js.map → compact-session-F2UDGZCN.js.map} +1 -1
  30. package/dist/cron.cjs +6 -5
  31. package/dist/cron.js +5 -4
  32. package/dist/eval.cjs +5 -4
  33. package/dist/eval.cjs.map +1 -1
  34. package/dist/eval.js +4 -3
  35. package/dist/eval.js.map +1 -1
  36. package/dist/index.cjs +38 -128
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.js +9 -104
  39. package/dist/index.js.map +1 -1
  40. package/dist/{inject-session-O24XGRR6.js → inject-session-E5UDFVLI.js} +3 -3
  41. package/dist/{inject-session-O24XGRR6.js.map → inject-session-E5UDFVLI.js.map} +1 -1
  42. package/dist/{inject-session-OMLFL2V3.cjs → inject-session-W4UKACYJ.cjs} +4 -4
  43. package/dist/{inject-session-OMLFL2V3.cjs.map → inject-session-W4UKACYJ.cjs.map} +1 -1
  44. package/dist/internal/budget/normalize-usage.d.ts +81 -0
  45. package/dist/internal/llm/anthropic-shared.d.ts +6 -0
  46. package/dist/internal/llm/openai.d.ts +3 -5
  47. package/dist/internal/llm/openrouter-system.d.ts +1 -0
  48. package/dist/internal/llm/types.d.ts +10 -5
  49. package/dist/models.cjs +5 -50
  50. package/dist/models.cjs.map +1 -1
  51. package/dist/models.js +3 -51
  52. package/dist/models.js.map +1 -1
  53. package/docs/error-codes.md +3 -2
  54. package/package.json +1 -1
  55. package/dist/chunk-CVEQ5366.cjs.map +0 -1
  56. package/dist/chunk-EVH3OUMY.js.map +0 -1
  57. package/dist/chunk-QY3CIMUV.cjs.map +0 -1
  58. package/dist/chunk-RTE2DD4S.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkJ6GXS5A2_cjs = require('./chunk-J6GXS5A2.cjs');
4
- var chunkFR6COQXZ_cjs = require('./chunk-FR6COQXZ.cjs');
4
+ var chunkN7ZIPW2N_cjs = require('./chunk-N7ZIPW2N.cjs');
5
5
  var chunkL3C6CCBG_cjs = require('./chunk-L3C6CCBG.cjs');
6
6
  var chunkKIKKTW5O_cjs = require('./chunk-KIKKTW5O.cjs');
7
7
  var chunkBV2MWEMV_cjs = require('./chunk-BV2MWEMV.cjs');
@@ -9,7 +9,7 @@ var chunkYEHQ3SIC_cjs = require('./chunk-YEHQ3SIC.cjs');
9
9
  var chunkTMKTSYDS_cjs = require('./chunk-TMKTSYDS.cjs');
10
10
  var chunkZD66GFH5_cjs = require('./chunk-ZD66GFH5.cjs');
11
11
  var chunkNQVWSSX2_cjs = require('./chunk-NQVWSSX2.cjs');
12
- var chunkQY3CIMUV_cjs = require('./chunk-QY3CIMUV.cjs');
12
+ var chunkBZKF7TXX_cjs = require('./chunk-BZKF7TXX.cjs');
13
13
  var chunk2ZPEDVLM_cjs = require('./chunk-2ZPEDVLM.cjs');
14
14
  var chunkXKZFIP7Z_cjs = require('./chunk-XKZFIP7Z.cjs');
15
15
  var chunkN6OEX5TN_cjs = require('./chunk-N6OEX5TN.cjs');
@@ -31,6 +31,7 @@ var chunkC7GKRGKN_cjs = require('./chunk-C7GKRGKN.cjs');
31
31
  var chunkTY56BKSK_cjs = require('./chunk-TY56BKSK.cjs');
32
32
  var chunkMPR2ISL2_cjs = require('./chunk-MPR2ISL2.cjs');
33
33
  var chunkJ5623RIV_cjs = require('./chunk-J5623RIV.cjs');
34
+ var chunkNWS2CS3Y_cjs = require('./chunk-NWS2CS3Y.cjs');
34
35
  var chunk3EE6LVWT_cjs = require('./chunk-3EE6LVWT.cjs');
35
36
  var chunkSGC7LSHF_cjs = require('./chunk-SGC7LSHF.cjs');
36
37
  var chunkHU666T3Q_cjs = require('./chunk-HU666T3Q.cjs');
@@ -1566,7 +1567,7 @@ function createRealCloudRun(options) {
1566
1567
  conversation: []
1567
1568
  };
1568
1569
  const apiKey = chunk6LHQPOMI_cjs.resolveApiKey(options.agentOptions.apiKey);
1569
- const baseUrl = chunkQY3CIMUV_cjs.getConfiguredBaseUrl();
1570
+ const baseUrl = chunkBZKF7TXX_cjs.getConfiguredBaseUrl();
1570
1571
  const handle = new RealCloudRun(
1571
1572
  {
1572
1573
  id,
@@ -1649,7 +1650,7 @@ var RealCloudRun = class extends FixtureRunBase {
1649
1650
  async consumeStream(response) {
1650
1651
  let finalStatus = "finished";
1651
1652
  let finalText = "";
1652
- for await (const record of chunkQY3CIMUV_cjs.parseSseStream(response.body, this.controller.signal)) {
1653
+ for await (const record of chunkBZKF7TXX_cjs.parseSseStream(response.body, this.controller.signal)) {
1653
1654
  const parsed = safeParse(record.data);
1654
1655
  if (parsed === void 0) continue;
1655
1656
  const update = this.applyRecord(record.event, parsed);
@@ -1816,7 +1817,7 @@ var CloudAgent = class _CloudAgent {
1816
1817
  */
1817
1818
  isFixtureMode() {
1818
1819
  const apiKey = chunk6LHQPOMI_cjs.resolveApiKey(this.options.apiKey);
1819
- return chunkQY3CIMUV_cjs.isFixtureApiKey(apiKey) && chunkQY3CIMUV_cjs.getConfiguredBaseUrl() === void 0;
1820
+ return chunkBZKF7TXX_cjs.isFixtureApiKey(apiKey) && chunkBZKF7TXX_cjs.getConfiguredBaseUrl() === void 0;
1820
1821
  }
1821
1822
  // SE9 — integrated structured output; delegates to the shared helper.
1822
1823
  generate(message, options) {
@@ -1868,7 +1869,7 @@ var CloudAgent = class _CloudAgent {
1868
1869
  const userText = typeof message === "string" ? message : message.text;
1869
1870
  const systemPrompt = await this.resolveSystemPromptForSend(userText, options);
1870
1871
  const apiKey = chunk6LHQPOMI_cjs.resolveApiKey(this.options.apiKey);
1871
- const useRealRuntime = apiKey !== void 0 && !chunkQY3CIMUV_cjs.isFixtureApiKey(apiKey) && chunkQY3CIMUV_cjs.getConfiguredBaseUrl() !== void 0;
1872
+ const useRealRuntime = apiKey !== void 0 && !chunkBZKF7TXX_cjs.isFixtureApiKey(apiKey) && chunkBZKF7TXX_cjs.getConfiguredBaseUrl() !== void 0;
1872
1873
  return useRealRuntime ? createRealCloudRun({
1873
1874
  agentId: this.agentId,
1874
1875
  model: this.model ?? { id: DEFAULT_AGENTIC_MODEL_ID },
@@ -2933,7 +2934,7 @@ async function runPostRunLifecycle(inputs) {
2933
2934
  try {
2934
2935
  const partial = await safeConversation(run);
2935
2936
  if (partial !== void 0) {
2936
- chunkFR6COQXZ_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
2937
+ chunkN7ZIPW2N_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
2937
2938
  userText,
2938
2939
  conversation: partial
2939
2940
  });
@@ -2943,11 +2944,11 @@ async function runPostRunLifecycle(inputs) {
2943
2944
  chunk6LHQPOMI_cjs.diag(`[theokit-sdk] partial transcript write failed (${agentId}): ${msg}
2944
2945
  `);
2945
2946
  }
2946
- await chunkFR6COQXZ_cjs.flushSessionWrites();
2947
+ await chunkN7ZIPW2N_cjs.flushSessionWrites();
2947
2948
  return;
2948
2949
  }
2949
2950
  if (result.result !== void 0) {
2950
- chunkFR6COQXZ_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
2951
+ chunkN7ZIPW2N_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
2951
2952
  }
2952
2953
  const conversation = await safeConversation(run);
2953
2954
  const resolvedWindow = resolveWindowForRun(model, contextWindow);
@@ -2958,7 +2959,7 @@ async function runPostRunLifecycle(inputs) {
2958
2959
  }
2959
2960
  const lastRequestUsage = result.usage?.requests?.at(-1)?.totalTokens;
2960
2961
  const usageForTrigger = lastRequestUsage ?? result.usage?.totalTokens;
2961
- chunkFR6COQXZ_cjs.persistTurnToTranscript(
2962
+ chunkN7ZIPW2N_cjs.persistTurnToTranscript(
2962
2963
  sessionStore,
2963
2964
  { cwd: workspaceCwd, agentId, model },
2964
2965
  agentId,
@@ -2970,7 +2971,7 @@ async function runPostRunLifecycle(inputs) {
2970
2971
  // The EFFECTIVE window (after override, clamp and margin) — not the declared one. Swapping for
2971
2972
  // `contextWindow` here would budget against a number the clamp already rejected.
2972
2973
  contextWindow: effectiveWindow,
2973
- summarize: chunkQY3CIMUV_cjs.buildDefaultSummarizer({
2974
+ summarize: chunkBZKF7TXX_cjs.buildDefaultSummarizer({
2974
2975
  agentModel: model,
2975
2976
  ...inputs.apiKey !== void 0 ? { apiKey: inputs.apiKey } : {}
2976
2977
  })
@@ -3012,7 +3013,7 @@ async function runPostRunLifecycle(inputs) {
3012
3013
  agentId,
3013
3014
  runId: result.id
3014
3015
  });
3015
- await chunkFR6COQXZ_cjs.flushSessionWrites();
3016
+ await chunkN7ZIPW2N_cjs.flushSessionWrites();
3016
3017
  }
3017
3018
  async function safeConversation(run) {
3018
3019
  try {
@@ -3643,7 +3644,7 @@ var HISTOGRAM_NAMES = {
3643
3644
  };
3644
3645
  function safeRequire(moduleName) {
3645
3646
  try {
3646
- const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-CVEQ5366.cjs', document.baseURI).href)));
3647
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-5OHB5HJF.cjs', document.baseURI).href)));
3647
3648
  return r(moduleName);
3648
3649
  } catch {
3649
3650
  return void 0;
@@ -3886,7 +3887,7 @@ var cachedOtel;
3886
3887
  function loadOtel() {
3887
3888
  if (cachedOtel === void 0) {
3888
3889
  try {
3889
- const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-CVEQ5366.cjs', document.baseURI).href)));
3890
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-5OHB5HJF.cjs', document.baseURI).href)));
3890
3891
  const mod = r("@opentelemetry/api");
3891
3892
  cachedOtel = mod;
3892
3893
  } catch {
@@ -5807,14 +5808,27 @@ function stripThinkBlocks(content) {
5807
5808
  // src/internal/agent-loop/loop-llm-stream.ts
5808
5809
  function resolveSystemPromptWithMemoryAdditions(systemPrompt, additions) {
5809
5810
  if (additions === void 0 || additions.length === 0) return systemPrompt;
5810
- const block = `<active-memory>
5811
- ${chunkHG5LKFG7_cjs.escapeBlockBody(additions)}
5812
- </active-memory>`;
5811
+ const block = activeMemoryBlock(additions);
5813
5812
  if (systemPrompt === void 0 || systemPrompt.length === 0) return block;
5814
5813
  return `${block}
5815
5814
 
5816
5815
  ${systemPrompt}`;
5817
5816
  }
5817
+ function activeMemoryBlock(additions) {
5818
+ return `<active-memory>
5819
+ ${chunkHG5LKFG7_cjs.escapeBlockBody(additions)}
5820
+ </active-memory>`;
5821
+ }
5822
+ function buildLoopSystem(systemPrompt, additions, modelId) {
5823
+ if (!chunkNWS2CS3Y_cjs.isAnthropicFamilyModel(modelId) || systemPrompt === void 0 || systemPrompt.length === 0) {
5824
+ return resolveSystemPromptWithMemoryAdditions(systemPrompt, additions);
5825
+ }
5826
+ const blocks = [{ text: systemPrompt, cacheable: true }];
5827
+ if (additions !== void 0 && additions.length > 0) {
5828
+ blocks.push({ text: activeMemoryBlock(additions) });
5829
+ }
5830
+ return blocks;
5831
+ }
5818
5832
  function toLlmTool(tool) {
5819
5833
  return { name: tool.name, description: tool.description, inputSchema: tool.inputSchema };
5820
5834
  }
@@ -5853,9 +5867,10 @@ async function streamLlmTurn(inputs, ctx) {
5853
5867
  {
5854
5868
  model: inputs.model.id ?? "auto",
5855
5869
  ...(() => {
5856
- const effective = resolveSystemPromptWithMemoryAdditions(
5870
+ const effective = buildLoopSystem(
5857
5871
  inputs.systemPrompt,
5858
- ctx.memorySystemPromptAdditions
5872
+ ctx.memorySystemPromptAdditions,
5873
+ inputs.model.id
5859
5874
  );
5860
5875
  return effective !== void 0 ? { system: effective } : {};
5861
5876
  })(),
@@ -6654,7 +6669,7 @@ function applyToolResultGuard(parts, opts) {
6654
6669
  (p) => (
6655
6670
  // SE7 — guard the TEXT of a tool result (string or the text blocks of a
6656
6671
  // structured content); image blocks pass through untouched.
6657
- p.type === "tool_result" ? { ...p, content: chunkQY3CIMUV_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
6672
+ p.type === "tool_result" ? { ...p, content: chunkBZKF7TXX_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
6658
6673
  )
6659
6674
  );
6660
6675
  }
@@ -6842,29 +6857,32 @@ async function runIteration(inputs, ctx) {
6842
6857
  const llmOutput = await streamLlmTurn(inputs, ctx);
6843
6858
  await inputs.pluginManager?.runPostLlmCallHooks(hookCtx);
6844
6859
  accumulateUsage(ctx.usage, llmOutput);
6845
- if (inputs.budgetTracker !== void 0) {
6846
- const modelId = inputs.model.id ?? "auto";
6847
- const inputT = llmOutput.inputTokens ?? 0;
6848
- const outputT = llmOutput.outputTokens ?? 0;
6849
- try {
6850
- if (inputT > 0) {
6851
- inputs.budgetTracker.track({
6852
- tokens: inputT,
6853
- model: modelId,
6854
- type: "input"
6855
- });
6856
- }
6857
- if (outputT > 0) {
6858
- inputs.budgetTracker.track({
6859
- tokens: outputT,
6860
- model: modelId,
6861
- type: "output"
6862
- });
6863
- }
6864
- } catch {
6860
+ trackTurnUsage(inputs, llmOutput);
6861
+ return continueOrTerminate(inputs, ctx, llmOutput);
6862
+ }
6863
+ function trackTurnUsage(inputs, llmOutput) {
6864
+ const tracker = inputs.budgetTracker;
6865
+ if (tracker === void 0) return;
6866
+ const modelId = inputs.model.id ?? "auto";
6867
+ const inputT = (llmOutput.inputTokens ?? 0) + (llmOutput.cacheReadTokens ?? 0) + (llmOutput.cacheWriteTokens ?? 0);
6868
+ const outputT = llmOutput.outputTokens ?? 0;
6869
+ try {
6870
+ if (inputT > 0) {
6871
+ tracker.track({
6872
+ tokens: inputT,
6873
+ model: modelId,
6874
+ type: "input"
6875
+ });
6876
+ }
6877
+ if (outputT > 0) {
6878
+ tracker.track({
6879
+ tokens: outputT,
6880
+ model: modelId,
6881
+ type: "output"
6882
+ });
6865
6883
  }
6884
+ } catch {
6866
6885
  }
6867
- return continueOrTerminate(inputs, ctx, llmOutput);
6868
6886
  }
6869
6887
  async function transformLlmOutputText(inputs, text, ctx) {
6870
6888
  return inputs.pluginManager !== void 0 ? inputs.pluginManager.runTransformLlmOutputHooks(text, ctx) : text;
@@ -6946,13 +6964,13 @@ var FallbackLlmClient = class {
6946
6964
  async *stream(request, signal) {
6947
6965
  let lastError;
6948
6966
  for (const client of this.clients) {
6949
- if (signal.aborted) throw chunkQY3CIMUV_cjs.abortError(signal);
6950
- const attempt = await chunkQY3CIMUV_cjs.tryFirstEvent(client, request, signal, true);
6967
+ if (signal.aborted) throw chunkBZKF7TXX_cjs.abortError(signal);
6968
+ const attempt = await chunkBZKF7TXX_cjs.tryFirstEvent(client, request, signal, true);
6951
6969
  if (attempt.kind === "handshake_error") {
6952
6970
  lastError = attempt.error;
6953
6971
  continue;
6954
6972
  }
6955
- return yield* chunkQY3CIMUV_cjs.relayStream(attempt.generator, attempt.firstResult);
6973
+ return yield* chunkBZKF7TXX_cjs.relayStream(attempt.generator, attempt.firstResult);
6956
6974
  }
6957
6975
  if (lastError !== void 0) throw lastError;
6958
6976
  throw new chunkUNFBHV46_cjs.NetworkError("FallbackLlmClient has no providers configured", {
@@ -7588,9 +7606,9 @@ function buildLoopInputs(options, runId, userText, userImages) {
7588
7606
  { code: "invalid_max_iterations" }
7589
7607
  );
7590
7608
  }
7591
- const { primary, effectiveModelId } = chunkQY3CIMUV_cjs.resolveRunProvider(options);
7609
+ const { primary, effectiveModelId } = chunkBZKF7TXX_cjs.resolveRunProvider(options);
7592
7610
  const fallback = options.agentOptions.providers?.fallback;
7593
- const apiKeys = chunkQY3CIMUV_cjs.mergeExplicitApiKey(
7611
+ const apiKeys = chunkBZKF7TXX_cjs.mergeExplicitApiKey(
7594
7612
  options.agentOptions.providers?.apiKeys,
7595
7613
  primary,
7596
7614
  options.agentOptions.apiKey
@@ -7599,7 +7617,7 @@ function buildLoopInputs(options, runId, userText, userImages) {
7599
7617
  const extractToolCallsFromContent = options.agentOptions.providers?.routes?.[0]?.extractToolCallsFromContent;
7600
7618
  const rateLimitSink = options.sendOptions.onRunEvent;
7601
7619
  const modelBaseUrl = options.model?.url;
7602
- const chain = chunkQY3CIMUV_cjs.resolveProviderChain({
7620
+ const chain = chunkBZKF7TXX_cjs.resolveProviderChain({
7603
7621
  primary,
7604
7622
  ...modelBaseUrl !== void 0 ? { baseUrl: modelBaseUrl } : {},
7605
7623
  ...fallback !== void 0 ? { fallback } : {},
@@ -7859,7 +7877,7 @@ function buildRealRunOptions(args) {
7859
7877
  };
7860
7878
  }
7861
7879
  async function createFixtureRunHelper(args) {
7862
- const sessionMessages = chunkFR6COQXZ_cjs.getSessionMessages(args.inputs.agentId);
7880
+ const sessionMessages = chunkN7ZIPW2N_cjs.getSessionMessages(args.inputs.agentId);
7863
7881
  const projectMcpServers = args.inputs.settingSourcesIncludeProject ? await readProjectMcpServers(args.inputs.workspaceCwd) : {};
7864
7882
  return createLocalRun({
7865
7883
  agentId: args.inputs.agentId,
@@ -7878,7 +7896,7 @@ async function createFixtureRunHelper(args) {
7878
7896
  }
7879
7897
  async function dispatchLocalRun(args) {
7880
7898
  const apiKey = chunk6LHQPOMI_cjs.resolveApiKey(args.inputs.options.apiKey);
7881
- if (chunkQY3CIMUV_cjs.shouldUseRealLocalRuntime(apiKey)) {
7899
+ if (chunkBZKF7TXX_cjs.shouldUseRealLocalRuntime(apiKey)) {
7882
7900
  return createRealLocalRun(
7883
7901
  buildRealRunOptions({
7884
7902
  inputs: args.inputs,
@@ -8134,10 +8152,10 @@ async function disposeLocalAgentSession(agent) {
8134
8152
  agent.lifecycleAbortController.abort();
8135
8153
  await chunkZF2LDKQQ_cjs.withCwdMutex(`agent-send:${agent.agentId}`, () => Promise.resolve());
8136
8154
  disposeSessionMcpClients(agent.agentId);
8137
- await chunkFR6COQXZ_cjs.flushSessionWrites();
8155
+ await chunkN7ZIPW2N_cjs.flushSessionWrites();
8138
8156
  await flushRegistrySaves(agent.workspaceCwd);
8139
8157
  await disposeSessionStore(agent.sessionStore);
8140
- chunkFR6COQXZ_cjs.discardSession(agent.workspaceCwd, agent.agentId);
8158
+ chunkN7ZIPW2N_cjs.discardSession(agent.workspaceCwd, agent.agentId);
8141
8159
  }
8142
8160
  async function reloadLocalAgent(agent) {
8143
8161
  if (agent.context !== void 0) await agent.context.refresh();
@@ -9001,7 +9019,7 @@ var LocalAgentMemory = class {
9001
9019
  async runActiveMemoryIfEnabled(userText, priorMessages, telemetry) {
9002
9020
  const cfg = this.options.memory?.activeRecall;
9003
9021
  if (cfg?.enabled !== true || this.index === void 0) return void 0;
9004
- if (this.breaker === void 0) this.breaker = new chunkQY3CIMUV_cjs.CircuitBreaker();
9022
+ if (this.breaker === void 0) this.breaker = new chunkBZKF7TXX_cjs.CircuitBreaker();
9005
9023
  if (this.cache === void 0) this.cache = new ActiveMemoryCache();
9006
9024
  const result = await runActiveMemory({
9007
9025
  userText,
@@ -9316,8 +9334,8 @@ async function localAgentUsePersonality(agent, name, opts) {
9316
9334
  registry,
9317
9335
  store: agent.personalityStore,
9318
9336
  invalidateCache: (reason) => agent.invalidateCache(reason),
9319
- appendSessionMessage: (msg) => chunkFR6COQXZ_cjs.appendSessionMessage(agent.agentId, msg),
9320
- clearSession: () => chunkFR6COQXZ_cjs.clearSession(agent.agentId),
9337
+ appendSessionMessage: (msg) => chunkN7ZIPW2N_cjs.appendSessionMessage(agent.agentId, msg),
9338
+ clearSession: () => chunkN7ZIPW2N_cjs.clearSession(agent.agentId),
9321
9339
  opts: opts ?? {}
9322
9340
  })
9323
9341
  );
@@ -9871,7 +9889,7 @@ async function executeSendLocked(inputs, message, options) {
9871
9889
  if (inputs.options.onBeforeSend !== void 0) {
9872
9890
  await inputs.options.onBeforeSend({
9873
9891
  conversationId: inputs.agentId,
9874
- previousMessageCount: chunkFR6COQXZ_cjs.getSessionMessages(inputs.agentId).length
9892
+ previousMessageCount: chunkN7ZIPW2N_cjs.getSessionMessages(inputs.agentId).length
9875
9893
  });
9876
9894
  }
9877
9895
  await inputs.runPreHook(userText);
@@ -9883,8 +9901,8 @@ async function executeSendLocked(inputs, message, options) {
9883
9901
  userText,
9884
9902
  sendOptions: options
9885
9903
  });
9886
- const priorMessages = [...chunkFR6COQXZ_cjs.getSessionMessages(inputs.agentId)];
9887
- chunkFR6COQXZ_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
9904
+ const priorMessages = [...chunkN7ZIPW2N_cjs.getSessionMessages(inputs.agentId)];
9905
+ chunkN7ZIPW2N_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
9888
9906
  await persistMemoryFactIfWritePrompt(inputs.workspaceCwd, inputs.options.memory, userText);
9889
9907
  const memoryFacts = await readMemoryForSend(inputs.workspaceCwd, inputs.options.memory, userText);
9890
9908
  const memoryTools = void 0;
@@ -10190,7 +10208,7 @@ var LocalAgent = class {
10190
10208
  );
10191
10209
  await acquireLeaseIfPossible(this.sessionStore, this.agentId);
10192
10210
  try {
10193
- await chunkFR6COQXZ_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
10211
+ await chunkN7ZIPW2N_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
10194
10212
  await this.personalityStore.hydrate(this.agentId);
10195
10213
  } catch (err) {
10196
10214
  await releaseLeaseIfPossible(this.sessionStore, this.agentId);
@@ -10531,15 +10549,15 @@ async function maybeInjectHandoffTools(options) {
10531
10549
  };
10532
10550
  }
10533
10551
  function keyWillFlowToProvider(apiKey, provider) {
10534
- if (chunkQY3CIMUV_cjs.isFixtureApiKey(apiKey)) return false;
10535
- if (chunkQY3CIMUV_cjs.getConfiguredBaseUrl() !== void 0) return false;
10552
+ if (chunkBZKF7TXX_cjs.isFixtureApiKey(apiKey)) return false;
10553
+ if (chunkBZKF7TXX_cjs.getConfiguredBaseUrl() !== void 0) return false;
10536
10554
  if (provider === void 0) return false;
10537
10555
  const profile = chunkSGC7LSHF_cjs.getProviderProfile(provider);
10538
10556
  if (profile === void 0) return false;
10539
10557
  return profile.authType !== "none";
10540
10558
  }
10541
10559
  function missingApiKeyMessage() {
10542
- const present = chunkQY3CIMUV_cjs.presentProviderCredentialEnvVars();
10560
+ const present = chunkBZKF7TXX_cjs.presentProviderCredentialEnvVars();
10543
10561
  const base = `Missing API key \u2014 set ${chunk6LHQPOMI_cjs.API_KEY_ENV_VAR}, or pass \`apiKey\` to Agent.create()`;
10544
10562
  if (present.length === 0) return `${base}.`;
10545
10563
  return `${base}. ${present.join(" and ")} ${present.length === 1 ? "is" : "are"} set, but a provider credential is not read from the environment automatically \u2014 pass it explicitly, e.g. \`Agent.create({ apiKey: process.env.${present[0]}, ... })\`.`;
@@ -10559,7 +10577,7 @@ async function createLocalAgent(options) {
10559
10577
  }
10560
10578
  } else {
10561
10579
  const willFlowToProvider = keyWillFlowToProvider(apiKey, provider);
10562
- const shape = chunkQY3CIMUV_cjs.validateApiKeyShape(apiKey, {
10580
+ const shape = chunkBZKF7TXX_cjs.validateApiKeyShape(apiKey, {
10563
10581
  strict: willFlowToProvider,
10564
10582
  ...willFlowToProvider ? { provider } : {}
10565
10583
  });
@@ -10578,15 +10596,15 @@ async function createCloudAgent(options) {
10578
10596
  code: "missing_api_key"
10579
10597
  });
10580
10598
  }
10581
- const shape = chunkQY3CIMUV_cjs.validateApiKeyShape(apiKey);
10599
+ const shape = chunkBZKF7TXX_cjs.validateApiKeyShape(apiKey);
10582
10600
  if (shape.malformed) {
10583
10601
  throw new chunkUNFBHV46_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
10584
10602
  }
10585
- const baseUrl = chunkQY3CIMUV_cjs.getConfiguredBaseUrl();
10603
+ const baseUrl = chunkBZKF7TXX_cjs.getConfiguredBaseUrl();
10586
10604
  if (baseUrl === void 0) {
10587
10605
  return new CloudAgent(options);
10588
10606
  }
10589
- const response = await chunkQY3CIMUV_cjs.httpRequest("/v1/agents", {
10607
+ const response = await chunkBZKF7TXX_cjs.httpRequest("/v1/agents", {
10590
10608
  apiKey,
10591
10609
  method: "POST",
10592
10610
  body: {
@@ -10611,7 +10629,7 @@ function resolveAgentPersistenceCwd(options) {
10611
10629
  return process.cwd();
10612
10630
  }
10613
10631
  async function rehydrateExistingAgent(agentId, existing, options) {
10614
- await chunkQY3CIMUV_cjs.discoverProviderPlugins();
10632
+ await chunkBZKF7TXX_cjs.discoverProviderPlugins();
10615
10633
  await validateRehydratedAgent(agentId, existing);
10616
10634
  const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
10617
10635
  const mergedMemory = mergeResumedMemory(existing.options.memory, options.memory);
@@ -10771,7 +10789,7 @@ var Agent = class _Agent {
10771
10789
  pluginCount: enabledPluginNames(options.plugins).length
10772
10790
  });
10773
10791
  try {
10774
- await chunkQY3CIMUV_cjs.discoverProviderPlugins();
10792
+ await chunkBZKF7TXX_cjs.discoverProviderPlugins();
10775
10793
  const agent = await runCreateUnderSpan(options, span);
10776
10794
  return agent;
10777
10795
  } catch (err) {
@@ -11069,9 +11087,9 @@ var Agent = class _Agent {
11069
11087
  */
11070
11088
  static async compact(agentId, options = {}) {
11071
11089
  const reg = await requireLocalAgent(agentId, "compact");
11072
- const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-4QHBBGEY.cjs');
11090
+ const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-2AETONOS.cjs');
11073
11091
  const { cwd, model, store } = await openLocalStore(reg);
11074
- return chunkFR6COQXZ_cjs.enqueueSessionWrite(
11092
+ return chunkN7ZIPW2N_cjs.enqueueSessionWrite(
11075
11093
  cwd,
11076
11094
  agentId,
11077
11095
  () => compactSessionTranscript({
@@ -11099,7 +11117,7 @@ var Agent = class _Agent {
11099
11117
  */
11100
11118
  static async injectSessionTurn(agentId, turn) {
11101
11119
  const reg = await requireLocalAgent(agentId, "injectSessionTurn");
11102
- const { injectSessionTurn } = await import('./inject-session-OMLFL2V3.cjs');
11120
+ const { injectSessionTurn } = await import('./inject-session-W4UKACYJ.cjs');
11103
11121
  const { cwd, model, store } = await openLocalStore(reg);
11104
11122
  await injectSessionTurn({
11105
11123
  store,
@@ -11270,5 +11288,5 @@ exports.managedSettingsPathFor = managedSettingsPathFor;
11270
11288
  exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
11271
11289
  exports.readManagedSettings = readManagedSettings;
11272
11290
  exports.resolveSessionDir = resolveSessionDir;
11273
- //# sourceMappingURL=chunk-CVEQ5366.cjs.map
11274
- //# sourceMappingURL=chunk-CVEQ5366.cjs.map
11291
+ //# sourceMappingURL=chunk-5OHB5HJF.cjs.map
11292
+ //# sourceMappingURL=chunk-5OHB5HJF.cjs.map