@theokit/sdk 4.33.0 → 4.34.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 (70) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/{agent-LFSVFAUI.js → agent-EQQA5VGX.js} +8 -8
  3. package/dist/{agent-LFSVFAUI.js.map → agent-EQQA5VGX.js.map} +1 -1
  4. package/dist/{agent-2STDGKNI.cjs → agent-W6NI3HY4.cjs} +9 -9
  5. package/dist/{agent-2STDGKNI.cjs.map → agent-W6NI3HY4.cjs.map} +1 -1
  6. package/dist/{chunk-WBGCDZDV.js → chunk-5QMXYX3X.js} +3 -3
  7. package/dist/{chunk-WBGCDZDV.js.map → chunk-5QMXYX3X.js.map} +1 -1
  8. package/dist/{chunk-SDYJESYZ.js → chunk-7BTE3RXJ.js} +13 -9
  9. package/dist/{chunk-SDYJESYZ.js.map → chunk-7BTE3RXJ.js.map} +1 -1
  10. package/dist/{chunk-E33A7YIR.cjs → chunk-G4WI3VW2.cjs} +12 -8
  11. package/dist/chunk-G4WI3VW2.cjs.map +1 -0
  12. package/dist/{chunk-FER7UMIC.cjs → chunk-IAZX7RZM.cjs} +24 -7
  13. package/dist/chunk-IAZX7RZM.cjs.map +1 -0
  14. package/dist/{chunk-B3HUL2OQ.js → chunk-IPHW3VKP.js} +18 -9
  15. package/dist/chunk-IPHW3VKP.js.map +1 -0
  16. package/dist/{chunk-KT6SWUY6.js → chunk-IX2LKBCD.js} +3 -3
  17. package/dist/{chunk-KT6SWUY6.js.map → chunk-IX2LKBCD.js.map} +1 -1
  18. package/dist/{chunk-PZ4Q5K7O.cjs → chunk-IZFZ6RHA.cjs} +5 -5
  19. package/dist/{chunk-PZ4Q5K7O.cjs.map → chunk-IZFZ6RHA.cjs.map} +1 -1
  20. package/dist/{chunk-LDDUIXWS.cjs → chunk-JYMBHNNU.cjs} +17 -8
  21. package/dist/chunk-JYMBHNNU.cjs.map +1 -0
  22. package/dist/{chunk-FX2DAR5R.cjs → chunk-M2PU44HP.cjs} +3 -3
  23. package/dist/{chunk-FX2DAR5R.cjs.map → chunk-M2PU44HP.cjs.map} +1 -1
  24. package/dist/{chunk-GBCQ5742.js → chunk-RKG6QFCJ.js} +3 -3
  25. package/dist/{chunk-GBCQ5742.js.map → chunk-RKG6QFCJ.js.map} +1 -1
  26. package/dist/{chunk-TKE4RTYA.js → chunk-TPTHVSIG.js} +23 -9
  27. package/dist/chunk-TPTHVSIG.js.map +1 -0
  28. package/dist/{chunk-HTO4C32Q.cjs → chunk-TS6IPRME.cjs} +56 -42
  29. package/dist/chunk-TS6IPRME.cjs.map +1 -0
  30. package/dist/{chunk-OMDRRHRF.js → chunk-VQ6NY4F5.js} +23 -6
  31. package/dist/chunk-VQ6NY4F5.js.map +1 -0
  32. package/dist/{chunk-FTRNHGAD.cjs → chunk-WEHUJ7ZS.cjs} +8 -8
  33. package/dist/{chunk-FTRNHGAD.cjs.map → chunk-WEHUJ7ZS.cjs.map} +1 -1
  34. package/dist/{compact-session-J7VNCICZ.js → compact-session-5BDD4HIB.js} +4 -4
  35. package/dist/{compact-session-J7VNCICZ.js.map → compact-session-5BDD4HIB.js.map} +1 -1
  36. package/dist/{compact-session-24PK2G4M.cjs → compact-session-BEA3IOON.cjs} +12 -12
  37. package/dist/{compact-session-24PK2G4M.cjs.map → compact-session-BEA3IOON.cjs.map} +1 -1
  38. package/dist/compaction.cjs +14 -14
  39. package/dist/compaction.d.cts +9 -4
  40. package/dist/compaction.d.ts +9 -4
  41. package/dist/compaction.js +1 -1
  42. package/dist/cron.cjs +8 -8
  43. package/dist/cron.js +7 -7
  44. package/dist/eval.cjs +7 -7
  45. package/dist/eval.js +6 -6
  46. package/dist/{fs-session-store-YMBSJ5Y7.cjs → fs-session-store-QS763E3Y.cjs} +5 -5
  47. package/dist/{fs-session-store-YMBSJ5Y7.cjs.map → fs-session-store-QS763E3Y.cjs.map} +1 -1
  48. package/dist/fs-session-store-SJ3RA5I2.js +10 -0
  49. package/dist/{fs-session-store-MZ4GD2C6.js.map → fs-session-store-SJ3RA5I2.js.map} +1 -1
  50. package/dist/index.cjs +29 -29
  51. package/dist/index.js +9 -9
  52. package/dist/{inject-session-343WIDCM.cjs → inject-session-SMH56NXP.cjs} +4 -4
  53. package/dist/{inject-session-343WIDCM.cjs.map → inject-session-SMH56NXP.cjs.map} +1 -1
  54. package/dist/{inject-session-RZEDWO53.js → inject-session-V5FTK72N.js} +3 -3
  55. package/dist/{inject-session-RZEDWO53.js.map → inject-session-V5FTK72N.js.map} +1 -1
  56. package/dist/internal/persistence/fs-session-store.d.cts +15 -0
  57. package/dist/internal/persistence/fs-session-store.d.ts +15 -0
  58. package/dist/internal/persistence/session-writer.d.cts +14 -4
  59. package/dist/internal/persistence/session-writer.d.ts +14 -4
  60. package/dist/persistence.cjs +3 -3
  61. package/dist/persistence.js +1 -1
  62. package/package.json +1 -1
  63. package/dist/chunk-B3HUL2OQ.js.map +0 -1
  64. package/dist/chunk-E33A7YIR.cjs.map +0 -1
  65. package/dist/chunk-FER7UMIC.cjs.map +0 -1
  66. package/dist/chunk-HTO4C32Q.cjs.map +0 -1
  67. package/dist/chunk-LDDUIXWS.cjs.map +0 -1
  68. package/dist/chunk-OMDRRHRF.js.map +0 -1
  69. package/dist/chunk-TKE4RTYA.js.map +0 -1
  70. package/dist/fs-session-store-MZ4GD2C6.js +0 -10
@@ -2,9 +2,9 @@
2
2
 
3
3
  var chunkBV2MWEMV_cjs = require('./chunk-BV2MWEMV.cjs');
4
4
  var chunkMZ5ZRORA_cjs = require('./chunk-MZ5ZRORA.cjs');
5
- var chunkE33A7YIR_cjs = require('./chunk-E33A7YIR.cjs');
6
- var chunkFER7UMIC_cjs = require('./chunk-FER7UMIC.cjs');
7
- var chunkFTRNHGAD_cjs = require('./chunk-FTRNHGAD.cjs');
5
+ var chunkG4WI3VW2_cjs = require('./chunk-G4WI3VW2.cjs');
6
+ var chunkIAZX7RZM_cjs = require('./chunk-IAZX7RZM.cjs');
7
+ var chunkWEHUJ7ZS_cjs = require('./chunk-WEHUJ7ZS.cjs');
8
8
  var chunkJLMXKTBX_cjs = require('./chunk-JLMXKTBX.cjs');
9
9
  var chunkN24XBYNX_cjs = require('./chunk-N24XBYNX.cjs');
10
10
  var chunkWPZTYOUX_cjs = require('./chunk-WPZTYOUX.cjs');
@@ -21,7 +21,7 @@ var chunk2DYI7MIF_cjs = require('./chunk-2DYI7MIF.cjs');
21
21
  var chunkWJVHMTKB_cjs = require('./chunk-WJVHMTKB.cjs');
22
22
  var chunkTIZ4TS5V_cjs = require('./chunk-TIZ4TS5V.cjs');
23
23
  var chunkRZQ6E5YZ_cjs = require('./chunk-RZQ6E5YZ.cjs');
24
- var chunkFX2DAR5R_cjs = require('./chunk-FX2DAR5R.cjs');
24
+ var chunkM2PU44HP_cjs = require('./chunk-M2PU44HP.cjs');
25
25
  var chunkVYHJZVL5_cjs = require('./chunk-VYHJZVL5.cjs');
26
26
  var chunkD42XHI4O_cjs = require('./chunk-D42XHI4O.cjs');
27
27
  var chunkDHLZIMP6_cjs = require('./chunk-DHLZIMP6.cjs');
@@ -1663,7 +1663,7 @@ var RealCloudRun = class extends FixtureRunBase {
1663
1663
  async consumeStream(response) {
1664
1664
  let finalStatus = "finished";
1665
1665
  let finalText = "";
1666
- for await (const record of chunkFTRNHGAD_cjs.parseSseStream(response.body, this.controller.signal)) {
1666
+ for await (const record of chunkWEHUJ7ZS_cjs.parseSseStream(response.body, this.controller.signal)) {
1667
1667
  const parsed = safeParse(record.data);
1668
1668
  if (parsed === void 0) continue;
1669
1669
  const update = this.applyRecord(record.event, parsed);
@@ -2705,11 +2705,11 @@ function buildContextBudgetEvent(model, resolved) {
2705
2705
  // src/internal/runtime/lifecycle/post-run-lifecycle.ts
2706
2706
  function resolveWindowForRun(model, contextWindow) {
2707
2707
  const override = contextWindow !== void 0 && contextWindow > 0 ? contextWindow : void 0;
2708
- return chunkFX2DAR5R_cjs.resolveEffectiveContextWindow({
2708
+ return chunkM2PU44HP_cjs.resolveEffectiveContextWindow({
2709
2709
  ...override !== void 0 ? { override } : {},
2710
2710
  catalog: chunkD42XHI4O_cjs.getCatalogModelInfo(model)?.limit?.context,
2711
- margin: chunkFX2DAR5R_cjs.CONTEXT_WINDOW_MARGIN,
2712
- floor: chunkFX2DAR5R_cjs.CONTEXT_WINDOW_FLOOR
2711
+ margin: chunkM2PU44HP_cjs.CONTEXT_WINDOW_MARGIN,
2712
+ floor: chunkM2PU44HP_cjs.CONTEXT_WINDOW_FLOOR
2713
2713
  });
2714
2714
  }
2715
2715
  async function runPostRunLifecycle(inputs) {
@@ -2733,7 +2733,7 @@ async function runPostRunLifecycle(inputs) {
2733
2733
  try {
2734
2734
  const parcial = await safeConversation(run);
2735
2735
  if (parcial !== void 0) {
2736
- chunkE33A7YIR_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
2736
+ chunkG4WI3VW2_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
2737
2737
  userText,
2738
2738
  conversation: parcial
2739
2739
  });
@@ -2743,11 +2743,11 @@ async function runPostRunLifecycle(inputs) {
2743
2743
  process.stderr.write(`[theokit-sdk] partial transcript write failed (${agentId}): ${msg}
2744
2744
  `);
2745
2745
  }
2746
- await chunkE33A7YIR_cjs.flushSessionWrites();
2746
+ await chunkG4WI3VW2_cjs.flushSessionWrites();
2747
2747
  return;
2748
2748
  }
2749
2749
  if (result.result !== void 0) {
2750
- chunkE33A7YIR_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
2750
+ chunkG4WI3VW2_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
2751
2751
  }
2752
2752
  const conversation = await safeConversation(run);
2753
2753
  const resolvedWindow = resolveWindowForRun(model, contextWindow);
@@ -2758,7 +2758,7 @@ async function runPostRunLifecycle(inputs) {
2758
2758
  }
2759
2759
  const lastRequestUsage = result.usage?.requests?.at(-1)?.totalTokens;
2760
2760
  const usageForTrigger = lastRequestUsage ?? result.usage?.totalTokens;
2761
- chunkE33A7YIR_cjs.persistTurnToTranscript(
2761
+ chunkG4WI3VW2_cjs.persistTurnToTranscript(
2762
2762
  sessionStore,
2763
2763
  { cwd: workspaceCwd, agentId, model },
2764
2764
  agentId,
@@ -2770,7 +2770,7 @@ async function runPostRunLifecycle(inputs) {
2770
2770
  // A janela EFETIVA (após override, clamp e margem) — não a declarada. Trocar por
2771
2771
  // `contextWindow` aqui orçaria contra um número que o clamp já rejeitou.
2772
2772
  contextWindow: janelaEfetiva,
2773
- summarize: chunkFTRNHGAD_cjs.buildDefaultSummarizer({
2773
+ summarize: chunkWEHUJ7ZS_cjs.buildDefaultSummarizer({
2774
2774
  agentModel: model,
2775
2775
  ...inputs.apiKey !== void 0 ? { apiKey: inputs.apiKey } : {}
2776
2776
  })
@@ -2814,7 +2814,7 @@ async function runPostRunLifecycle(inputs) {
2814
2814
  agentId,
2815
2815
  runId: result.id
2816
2816
  });
2817
- await chunkE33A7YIR_cjs.flushSessionWrites();
2817
+ await chunkG4WI3VW2_cjs.flushSessionWrites();
2818
2818
  }
2819
2819
  async function safeConversation(run) {
2820
2820
  try {
@@ -3571,7 +3571,7 @@ var HISTOGRAM_NAMES = {
3571
3571
  };
3572
3572
  function safeRequire(moduleName) {
3573
3573
  try {
3574
- const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-HTO4C32Q.cjs', document.baseURI).href)));
3574
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-TS6IPRME.cjs', document.baseURI).href)));
3575
3575
  return r(moduleName);
3576
3576
  } catch {
3577
3577
  return void 0;
@@ -3796,7 +3796,7 @@ var cachedOtel;
3796
3796
  function loadOtel() {
3797
3797
  if (cachedOtel === void 0) {
3798
3798
  try {
3799
- const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-HTO4C32Q.cjs', document.baseURI).href)));
3799
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-TS6IPRME.cjs', document.baseURI).href)));
3800
3800
  const mod = r("@opentelemetry/api");
3801
3801
  cachedOtel = mod;
3802
3802
  } catch {
@@ -6225,7 +6225,7 @@ function applyToolResultGuard(parts, opts) {
6225
6225
  (p) => (
6226
6226
  // SE7 — guard the TEXT of a tool result (string or the text blocks of a
6227
6227
  // structured content); image blocks pass through untouched.
6228
- p.type === "tool_result" ? { ...p, content: chunkFTRNHGAD_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
6228
+ p.type === "tool_result" ? { ...p, content: chunkWEHUJ7ZS_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
6229
6229
  )
6230
6230
  );
6231
6231
  }
@@ -6880,12 +6880,12 @@ var FallbackLlmClient = class {
6880
6880
  let lastError;
6881
6881
  for (const client of this.clients) {
6882
6882
  if (signal.aborted) throw abortError(signal);
6883
- const attempt = await chunkFTRNHGAD_cjs.tryFirstEvent(client, request, signal, true);
6883
+ const attempt = await chunkWEHUJ7ZS_cjs.tryFirstEvent(client, request, signal, true);
6884
6884
  if (attempt.kind === "handshake_error") {
6885
6885
  lastError = attempt.error;
6886
6886
  continue;
6887
6887
  }
6888
- return yield* chunkFTRNHGAD_cjs.relayStream(attempt.generator, attempt.firstResult);
6888
+ return yield* chunkWEHUJ7ZS_cjs.relayStream(attempt.generator, attempt.firstResult);
6889
6889
  }
6890
6890
  if (lastError !== void 0) throw lastError;
6891
6891
  throw new chunkA44COQJJ_cjs.NetworkError("FallbackLlmClient has no providers configured", {
@@ -7392,8 +7392,8 @@ function resolveRunProvider(options) {
7392
7392
  }
7393
7393
  const parsedModel = chunkVYHJZVL5_cjs.parseModelId(options.model?.id);
7394
7394
  const modelInferredProvider = parsedModel.provider !== void 0 && chunkD42XHI4O_cjs.getProviderProfile(parsedModel.provider) !== void 0 ? parsedModel.provider : void 0;
7395
- const keyInferredProvider = chunkFTRNHGAD_cjs.inferProviderFromApiKey(options.agentOptions.apiKey);
7396
- const primary = options.agentOptions.providers?.routes?.[0]?.provider ?? keyInferredProvider ?? modelInferredProvider ?? chunkFTRNHGAD_cjs.detectPrimaryProvider();
7395
+ const keyInferredProvider = chunkWEHUJ7ZS_cjs.inferProviderFromApiKey(options.agentOptions.apiKey);
7396
+ const primary = options.agentOptions.providers?.routes?.[0]?.provider ?? keyInferredProvider ?? modelInferredProvider ?? chunkWEHUJ7ZS_cjs.detectPrimaryProvider();
7397
7397
  const effectiveModelId = modelInferredProvider !== void 0 && modelInferredProvider === primary ? parsedModel.name : options.model?.id ?? "claude-sonnet-4-6";
7398
7398
  return { primary, effectiveModelId };
7399
7399
  }
@@ -7422,7 +7422,7 @@ function buildLoopInputs(options, runId, userText, userImages) {
7422
7422
  const credentialPoolStrategy = options.agentOptions.providers?.credentialPoolStrategy;
7423
7423
  const extractToolCallsFromContent = options.agentOptions.providers?.routes?.[0]?.extractToolCallsFromContent;
7424
7424
  const rateLimitSink = options.sendOptions.onRunEvent;
7425
- const chain = chunkFTRNHGAD_cjs.resolveProviderChain({
7425
+ const chain = chunkWEHUJ7ZS_cjs.resolveProviderChain({
7426
7426
  primary,
7427
7427
  ...fallback !== void 0 ? { fallback } : {},
7428
7428
  ...apiKeys !== void 0 ? { apiKeys } : {},
@@ -7647,7 +7647,7 @@ function buildRealRunOptions(args) {
7647
7647
  };
7648
7648
  }
7649
7649
  async function createFixtureRunHelper(args) {
7650
- const sessionMessages = chunkE33A7YIR_cjs.getSessionMessages(args.inputs.agentId);
7650
+ const sessionMessages = chunkG4WI3VW2_cjs.getSessionMessages(args.inputs.agentId);
7651
7651
  const projectMcpServers = args.inputs.settingSourcesIncludeProject ? await readProjectMcpServers(args.inputs.workspaceCwd) : {};
7652
7652
  return createLocalRun({
7653
7653
  agentId: args.inputs.agentId,
@@ -8096,7 +8096,7 @@ async function embedBatch(opts) {
8096
8096
  body = JSON.parse(text);
8097
8097
  } catch {
8098
8098
  }
8099
- throw chunkFTRNHGAD_cjs.mapOpenAICompatibleError({
8099
+ throw chunkWEHUJ7ZS_cjs.mapOpenAICompatibleError({
8100
8100
  providerId: opts.providerId,
8101
8101
  status: response.status,
8102
8102
  body,
@@ -8647,7 +8647,7 @@ var LocalAgentMemory = class {
8647
8647
  async runActiveMemoryIfEnabled(userText, priorMessages, telemetry) {
8648
8648
  const cfg = this.options.memory?.activeRecall;
8649
8649
  if (cfg?.enabled !== true || this.index === void 0) return void 0;
8650
- if (this.breaker === void 0) this.breaker = new chunkFTRNHGAD_cjs.CircuitBreaker();
8650
+ if (this.breaker === void 0) this.breaker = new chunkWEHUJ7ZS_cjs.CircuitBreaker();
8651
8651
  if (this.cache === void 0) this.cache = new ActiveMemoryCache();
8652
8652
  const result = await runActiveMemory({
8653
8653
  userText,
@@ -9051,8 +9051,8 @@ async function localAgentUsePersonality(args) {
9051
9051
  registry,
9052
9052
  store: args.personalityStore,
9053
9053
  invalidateCache: (reason) => args.invalidateCache(reason),
9054
- appendSessionMessage: (msg) => chunkE33A7YIR_cjs.appendSessionMessage(args.agentId, msg),
9055
- clearSession: () => chunkE33A7YIR_cjs.clearSession(args.agentId),
9054
+ appendSessionMessage: (msg) => chunkG4WI3VW2_cjs.appendSessionMessage(args.agentId, msg),
9055
+ clearSession: () => chunkG4WI3VW2_cjs.clearSession(args.agentId),
9056
9056
  opts: args.opts ?? {}
9057
9057
  })
9058
9058
  );
@@ -9400,7 +9400,7 @@ async function executeSendLocked(inputs, message, options) {
9400
9400
  if (inputs.options.onBeforeSend !== void 0) {
9401
9401
  await inputs.options.onBeforeSend({
9402
9402
  conversationId: inputs.agentId,
9403
- previousMessageCount: chunkE33A7YIR_cjs.getSessionMessages(inputs.agentId).length
9403
+ previousMessageCount: chunkG4WI3VW2_cjs.getSessionMessages(inputs.agentId).length
9404
9404
  });
9405
9405
  }
9406
9406
  await inputs.runPreHook(userText);
@@ -9412,8 +9412,8 @@ async function executeSendLocked(inputs, message, options) {
9412
9412
  userText,
9413
9413
  sendOptions: options
9414
9414
  });
9415
- const priorMessages = [...chunkE33A7YIR_cjs.getSessionMessages(inputs.agentId)];
9416
- chunkE33A7YIR_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
9415
+ const priorMessages = [...chunkG4WI3VW2_cjs.getSessionMessages(inputs.agentId)];
9416
+ chunkG4WI3VW2_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
9417
9417
  await persistMemoryFactIfWritePrompt(inputs.workspaceCwd, inputs.options.memory, userText);
9418
9418
  const memoryFacts = await readMemoryForSend(inputs.workspaceCwd, inputs.options.memory);
9419
9419
  const portPathActive = shouldUsePortMemoryPath();
@@ -9512,6 +9512,19 @@ function registerRunAsTask(run, agentId, taskOpt, userText) {
9512
9512
  }
9513
9513
 
9514
9514
  // src/internal/local-agent/local-agent.ts
9515
+ async function adquirirLeaseSePossivel(store, agentId) {
9516
+ const a = store.acquire;
9517
+ if (typeof a !== "function") return;
9518
+ try {
9519
+ await a.call(store, agentId);
9520
+ } catch (err) {
9521
+ if (err instanceof Error && err.name === "SessionBusyError") throw err;
9522
+ process.stderr.write(
9523
+ `[theokit-sdk] writer lease unavailable for ${agentId} (${err instanceof Error ? err.message : String(err)}) \u2014 proceeding without single-writer protection
9524
+ `
9525
+ );
9526
+ }
9527
+ }
9515
9528
  async function disposeSessionStore(store) {
9516
9529
  const d = store.dispose;
9517
9530
  if (typeof d === "function") await d.call(store);
@@ -9579,7 +9592,7 @@ var LocalAgent = class {
9579
9592
  this.options = options;
9580
9593
  this.workspaceCwd = resolveCwd(options.local?.cwd);
9581
9594
  this.transcriptBaseDir = resolveBaseDir(options.local?.baseDir);
9582
- this.sessionStore = options.local?.sessionStore ?? new chunkFER7UMIC_cjs.FsSessionStore({ baseDir: this.transcriptBaseDir, cwd: this.workspaceCwd });
9595
+ this.sessionStore = options.local?.sessionStore ?? new chunkIAZX7RZM_cjs.FsSessionStore({ baseDir: this.transcriptBaseDir, cwd: this.workspaceCwd });
9583
9596
  this.settingSourcesIncludeProject = includesSetting(options, "project");
9584
9597
  this.settingSourcesIncludePlugins = includesSetting(options, "plugins");
9585
9598
  const sub = bootstrapSubmanagers({
@@ -9627,7 +9640,8 @@ var LocalAgent = class {
9627
9640
  this.settingSourcesIncludeProject,
9628
9641
  this.options.agents
9629
9642
  );
9630
- await chunkE33A7YIR_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
9643
+ await adquirirLeaseSePossivel(this.sessionStore, this.agentId);
9644
+ await chunkG4WI3VW2_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
9631
9645
  await this.personalityStore.hydrate(this.agentId);
9632
9646
  }
9633
9647
  /** T4.2 — expose PluginManager so agent-loop can fire pre_tool_call hooks. @internal */
@@ -9820,10 +9834,10 @@ var LocalAgent = class {
9820
9834
  this.lifecycleAbortController.abort();
9821
9835
  await chunkYLQQX5W2_cjs.withCwdMutex(`agent-send:${this.agentId}`, () => Promise.resolve());
9822
9836
  disposeSessionMcpClients(this.agentId);
9823
- await chunkE33A7YIR_cjs.flushSessionWrites();
9837
+ await chunkG4WI3VW2_cjs.flushSessionWrites();
9824
9838
  await flushRegistrySaves(this.workspaceCwd);
9825
9839
  await disposeSessionStore(this.sessionStore);
9826
- chunkE33A7YIR_cjs.descartarSessao(this.workspaceCwd, this.agentId);
9840
+ chunkG4WI3VW2_cjs.descartarSessao(this.workspaceCwd, this.agentId);
9827
9841
  }
9828
9842
  [Symbol.asyncDispose]() {
9829
9843
  return this.dispose();
@@ -10030,7 +10044,7 @@ function resolveAgentPersistenceCwd(options) {
10030
10044
  return process.cwd();
10031
10045
  }
10032
10046
  async function rehydrateExistingAgent(agentId, existing, options) {
10033
- await chunkFTRNHGAD_cjs.discoverProviderPlugins();
10047
+ await chunkWEHUJ7ZS_cjs.discoverProviderPlugins();
10034
10048
  await validateRehydratedAgent(agentId, existing);
10035
10049
  const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
10036
10050
  const mergedOptions = {
@@ -10158,7 +10172,7 @@ var Agent = class _Agent {
10158
10172
  pluginCount: enabledPluginNames(options.plugins).length
10159
10173
  });
10160
10174
  try {
10161
- await chunkFTRNHGAD_cjs.discoverProviderPlugins();
10175
+ await chunkWEHUJ7ZS_cjs.discoverProviderPlugins();
10162
10176
  const agent = await runCreateUnderSpan(options, span);
10163
10177
  return agent;
10164
10178
  } catch (err) {
@@ -10427,9 +10441,9 @@ var Agent = class _Agent {
10427
10441
  `No local agent "${agentId}" registered \u2014 compact targets local sessions.`
10428
10442
  );
10429
10443
  }
10430
- const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-24PK2G4M.cjs');
10444
+ const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-BEA3IOON.cjs');
10431
10445
  const { cwd, model, store } = await abrirStoreLocal(reg);
10432
- return chunkE33A7YIR_cjs.enqueueSessionWrite(
10446
+ return chunkG4WI3VW2_cjs.enqueueSessionWrite(
10433
10447
  cwd,
10434
10448
  agentId,
10435
10449
  () => compactSessionTranscript({
@@ -10463,7 +10477,7 @@ var Agent = class _Agent {
10463
10477
  `No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`
10464
10478
  );
10465
10479
  }
10466
- const { injectSessionTurn } = await import('./inject-session-343WIDCM.cjs');
10480
+ const { injectSessionTurn } = await import('./inject-session-SMH56NXP.cjs');
10467
10481
  const { cwd, model, store } = await abrirStoreLocal(reg);
10468
10482
  await injectSessionTurn({
10469
10483
  store,
@@ -10510,7 +10524,7 @@ async function abrirStoreLocal(reg) {
10510
10524
  const cwd = reg.cwd ?? process.cwd();
10511
10525
  const optModel = reg.options.model;
10512
10526
  const model = reg.model?.id ?? (typeof optModel === "string" ? optModel : optModel?.id) ?? "unknown";
10513
- const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-YMBSJ5Y7.cjs');
10527
+ const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-QS763E3Y.cjs');
10514
10528
  const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-JXFMPLOT.cjs');
10515
10529
  const baseDir = reg.options.local?.baseDir !== void 0 ? expandTilde2(reg.options.local.baseDir) : defaultBaseDir2();
10516
10530
  return { cwd, model, store: new FsSessionStore2({ baseDir, cwd }) };
@@ -10531,5 +10545,5 @@ exports.isFixtureApiKey = isFixtureApiKey;
10531
10545
  exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
10532
10546
  exports.resolveApiKey = resolveApiKey;
10533
10547
  exports.shouldUseFixtureMode = shouldUseFixtureMode;
10534
- //# sourceMappingURL=chunk-HTO4C32Q.cjs.map
10535
- //# sourceMappingURL=chunk-HTO4C32Q.cjs.map
10548
+ //# sourceMappingURL=chunk-TS6IPRME.cjs.map
10549
+ //# sourceMappingURL=chunk-TS6IPRME.cjs.map