@theokit/sdk 5.3.0 → 5.3.2

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 (46) hide show
  1. package/CHANGELOG.md +103 -0
  2. package/dist/{agent-CvmTR9uf.d.ts → agent-CTbU0O1R.d.ts} +20 -1
  3. package/dist/{agent-GACKKINM.cjs → agent-KJLAWKZB.cjs} +5 -5
  4. package/dist/{agent-GACKKINM.cjs.map → agent-KJLAWKZB.cjs.map} +1 -1
  5. package/dist/{agent-VUNM33WJ.js → agent-PNYJ5S2Y.js} +4 -4
  6. package/dist/{agent-VUNM33WJ.js.map → agent-PNYJ5S2Y.js.map} +1 -1
  7. package/dist/{agent-C3KO5LKm.d.cts → agent-QLwxhXY3.d.cts} +20 -1
  8. package/dist/agent.d.ts +20 -2
  9. package/dist/{chunk-43H4EBS2.js → chunk-363RBGIR.js} +37 -9
  10. package/dist/chunk-363RBGIR.js.map +1 -0
  11. package/dist/{chunk-SSIRPWWD.cjs → chunk-65UMH5V3.cjs} +9 -7
  12. package/dist/chunk-65UMH5V3.cjs.map +1 -0
  13. package/dist/{chunk-AI4MXACC.js → chunk-7L3MIW2F.js} +9 -7
  14. package/dist/chunk-7L3MIW2F.js.map +1 -0
  15. package/dist/{chunk-PEAOQMWE.cjs → chunk-L4XENLQO.cjs} +4 -4
  16. package/dist/{chunk-PEAOQMWE.cjs.map → chunk-L4XENLQO.cjs.map} +1 -1
  17. package/dist/{chunk-DEJCKB65.cjs → chunk-Y46VI73J.cjs} +54 -26
  18. package/dist/chunk-Y46VI73J.cjs.map +1 -0
  19. package/dist/{chunk-WHTMFN4Q.js → chunk-ZITYGJOD.js} +3 -3
  20. package/dist/{chunk-WHTMFN4Q.js.map → chunk-ZITYGJOD.js.map} +1 -1
  21. package/dist/{context-XNREEC7M.js → context-BUIE52VH.js} +3 -3
  22. package/dist/{context-XNREEC7M.js.map → context-BUIE52VH.js.map} +1 -1
  23. package/dist/{context-3YMZDEX5.cjs → context-FCCJQ3FN.cjs} +6 -6
  24. package/dist/{context-3YMZDEX5.cjs.map → context-FCCJQ3FN.cjs.map} +1 -1
  25. package/dist/{cron-crfMMdAw.d.ts → cron-Cl8FrK3D.d.ts} +1 -1
  26. package/dist/{cron-C3PhZED0.d.cts → cron-Dz8AOpy3.d.cts} +1 -1
  27. package/dist/cron.cjs +4 -4
  28. package/dist/cron.d.cts +2 -2
  29. package/dist/cron.d.ts +2 -2
  30. package/dist/cron.js +3 -3
  31. package/dist/eval.cjs +3 -3
  32. package/dist/eval.js +2 -2
  33. package/dist/index.cjs +19 -19
  34. package/dist/index.d.cts +23 -5
  35. package/dist/index.d.ts +23 -5
  36. package/dist/index.js +5 -5
  37. package/dist/subagents-loader.d.cts +1 -1
  38. package/dist/subagents-loader.d.ts +1 -1
  39. package/dist/types/plugin.d.ts +20 -1
  40. package/docs/error-codes.md +2 -2
  41. package/docs/harness-capability-map.md +1 -1
  42. package/package.json +1 -1
  43. package/dist/chunk-43H4EBS2.js.map +0 -1
  44. package/dist/chunk-AI4MXACC.js.map +0 -1
  45. package/dist/chunk-DEJCKB65.cjs.map +0 -1
  46. package/dist/chunk-SSIRPWWD.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,108 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#619](https://github.com/usetheokit/theokit-sdk/pull/619) [`3f80bba`](https://github.com/usetheokit/theokit-sdk/commit/3f80bbaf0e7b1a6e7cd81a08f63aba243e1a0f18) Thanks [@usetheodev](https://github.com/usetheodev)! - A wrongly-shaped `hooks` block is refused with the shape that would work
8
+
9
+ `hooks: expected an object at "hooks" in <path>` named the validator's expectation and nothing an operator could act on. It now carries the accepted shape:
10
+
11
+ ```
12
+ hooks: expected an object at "hooks" in <path> — hooks are keyed by event,
13
+ e.g. { "hooks": { "PreToolUse": [ { "hooks": [ { "type": "command", "command": "…" } ] } ] } }
14
+ ```
15
+
16
+ Measured on a consumer in 2026-09. A flat `hooks` array in a `.theokit/settings.json` made this loader throw on **every turn** — and the file parsed perfectly for the product that had written it. `.theokit/` is this package's filebase, so what failed was an independent read of a path another product had started using, and the collision was one of **shape**, not of location. With only the diagnosis to go on, the operator looked in the wrong file.
17
+
18
+ Two tests ship with it: the refusal names the shape, and a control proves the shape it names is accepted. Without the control, "the error mentions `keyed by event`" would say nothing about whether that advice is correct.
19
+
20
+ - [#619](https://github.com/usetheokit/theokit-sdk/pull/619) [`a75059c`](https://github.com/usetheokit/theokit-sdk/commit/a75059cb496e4655e571a703c937e4e71ff670d8) Thanks [@usetheodev](https://github.com/usetheodev)! - Document that `on_session_start` / `on_session_end` fire once per **run** ([#613](https://github.com/usetheokit/theokit-sdk/issues/613) follow-up)
21
+
22
+ Docs and a test only; no behaviour change.
23
+
24
+ `SessionLifecycleContext` is named for a session and carries a `runId` that changes on every firing. The hooks fire once per pass through the agent loop — which is per-message for any application that builds its agent per turn. Nothing a consumer could read said so: the only accurate sentence was an internal comment at the firing site (`loop.ts`, *"fires once per run"*).
25
+
26
+ That gap was measured. In 2026-09 it cost two sessions several hours and produced a defect filed against this package for behaviour that is correct; the real answer turned out to be an architectural mismatch in a consumer that constructs an agent per turn, where "once per run" is not what a `SessionStart` handler assumes.
27
+
28
+ Two changes:
29
+
30
+ - The cadence is now stated on `SessionLifecycleContext` and in the `HookName` docblock, where a consumer meets the hook.
31
+ - `test_on_session_start_fires_once_per_run_and_again_on_the_next_run` pins it across two runs. The existing integration case could not: it collects into a `Set`, so a hook firing twice and a hook firing once are indistinguishable there by construction.
32
+
33
+ ## 5.3.1
34
+
35
+ ### Patch Changes
36
+
37
+ - [#614](https://github.com/usetheokit/theokit-sdk/pull/614) [`20794ef`](https://github.com/usetheokit/theokit-sdk/commit/20794efffa012edf200a3409abc53b988960e7af) Thanks [@usetheodev](https://github.com/usetheodev)! - `Agent.delete` removes the entry from the persisted registry ([#612](https://github.com/usetheokit/theokit-sdk/issues/612))
38
+
39
+ It did not. The method was a no-op against `registry.json` whenever the agent was not already in the
40
+ calling process's memory — which is every agent in a freshly started process, so every CLI
41
+ invocation:
42
+
43
+ ```ts
44
+ static async delete(agentId: string, _options: AgentOperationOptions = {}): Promise<void> {
45
+ removeRegisteredAgent(agentId); // Map is empty → returns false → no save scheduled
46
+ await flushRegistrySaves(); // flushes an empty queue
47
+ }
48
+ ```
49
+
50
+ `Agent.delete` returns `Promise<void>` and throws nothing when it removed nothing, so a caller had no
51
+ way to notice. Measured downstream as a `sessions delete` that reported success and exited 0 while
52
+ the session stayed in the listing — the transcript really was removed, leaving a registry entry
53
+ pointing at a file that no longer existed.
54
+
55
+ **What makes this an omission rather than a design:** every neighbouring mutator already hydrates.
56
+ `Agent.rename` and `Agent.archive` reach `getRegisteredAgentOrThrow`, which loads from disk on a
57
+ miss; `delete` was the only one that never did.
58
+
59
+ `options.cwd` is now read instead of being defaulted away — it is declared on
60
+ `AgentOperationOptions` and the parameter was `_options`. Hydrating `process.cwd()` unconditionally
61
+ would repeat B-115 (a documented option that compiles and does nothing) on the one path whose job is
62
+ to remove data.
63
+
64
+ **Deliberately unchanged:** deleting an unknown id still resolves rather than throwing. Matching
65
+ `rename`'s `UnknownAgentError` is defensible, but it is a breaking change for callers that delete
66
+ idempotently, and an entry and its transcript can legitimately outlive one another in both
67
+ directions. A persistence fix should not smuggle in an API break.
68
+
69
+ Consumers that already called `Agent.delete` and observed the entry surviving will now see it
70
+ removed. Nothing that behaved correctly before changes.
71
+
72
+ - [#614](https://github.com/usetheokit/theokit-sdk/pull/614) [`52d31d9`](https://github.com/usetheokit/theokit-sdk/commit/52d31d903fa5ddd3236db7f628f943e7e8ceae58) Thanks [@usetheodev](https://github.com/usetheodev)! - A local agent's public `summary` is a runtime label, not a fixture name ([#611](https://github.com/usetheokit/theokit-sdk/issues/611))
73
+
74
+ `SDKAgentInfo.summary` is `@public` and required, returned by `Agent.list()` and `Agent.get()`.
75
+ `registerLocalAgent` assigned it unconditionally:
76
+
77
+ ```ts
78
+ summary: "Local contract fixture",
79
+ ```
80
+
81
+ So that string was the **only** value the field could hold for a local agent, and `AgentOptions`
82
+ exposes no `summary` for a consumer to override it. It was found on a real user's session record on
83
+ disk, written through a consumer by a real turn — nothing about the run was a fixture.
84
+
85
+ The cloud sibling faces the same requirement and guards it, which is what makes this an omission
86
+ rather than a decision:
87
+
88
+ ```ts
89
+ summary: this.isFixtureMode() ? "Cloud contract fixture" : "Cloud agent",
90
+ ```
91
+
92
+ `isFixtureMode()` keys off a `theo_test_*` key with no configured base URL — it describes whether
93
+ the *remote* is stubbed, so there is no local equivalent to port. The local branch therefore takes
94
+ the cloud branch's non-fixture value: **`"Local agent"`**.
95
+
96
+ The `toLocalAgentInfo` / `toCloudAgentInfo` **fallbacks** carried the same two literals and move
97
+ with it. That pair is the reason this was worth fixing carefully rather than quickly: while the
98
+ registration wrote a fixture name unconditionally, the fallback could never be observed, so fixing
99
+ only the reachable site would have left the string ready to reappear for any record that arrives
100
+ without a summary.
101
+
102
+ Consumers rendering `summary` will see `Local agent` where they previously saw
103
+ `Local contract fixture`. Nothing reads the value programmatically in this package; a consumer that
104
+ matched on the old string was matching on a placeholder.
105
+
3
106
  ## 5.3.0
4
107
 
5
108
  ### Minor Changes
@@ -689,6 +689,8 @@ interface ProviderProfile {
689
689
  * `on_session_end`, `post_assistant_reply`) is fire-and-forget: the return value is DISCARDED. A
690
690
  * policy that needs to change a tool result belongs on `transform_tool_result` — put it on
691
691
  * `post_tool_call` and it quietly degrades to observation.
692
+ * - `on_session_start` / `on_session_end` fire once per **run**, not once per agent lifetime — see
693
+ * {@link SessionLifecycleContext}. Build an agent per turn and they fire on every message.
692
694
  *
693
695
  * Failure is asymmetric too. A fire-and-forget or transform handler that throws is caught, logged to
694
696
  * stderr, and the run continues. A `pre_tool_call` handler that throws is NOT caught by the hook
@@ -750,7 +752,24 @@ interface PostToolCallContext {
750
752
  agentId: string;
751
753
  runId: string;
752
754
  }
753
- /** #65 — context for the `on_session_start` / `on_session_end` hooks. @public */
755
+ /**
756
+ * #65 — context for the `on_session_start` / `on_session_end` hooks.
757
+ *
758
+ * **These fire once per RUN, not once per agent lifetime**, and the `runId` on this very context is
759
+ * the tell: it changes every time they fire. "Session" here means one pass through the agent loop.
760
+ *
761
+ * The distinction is invisible to an application that creates an agent once and sends many messages
762
+ * — there, per-run and per-session coincide. It is decisive for one that builds an agent **per
763
+ * turn**: `on_session_start` then fires on every message, which is the opposite of what a handler
764
+ * named for a session start usually assumes.
765
+ *
766
+ * Stated here because it was not stated anywhere a consumer could read it. The only accurate
767
+ * sentence lived in an internal comment at the firing site, and in 2026-09 that cost two people
768
+ * hours and produced a defect report filed against this package for behaviour that is correct.
769
+ * `test_on_session_start_fires_once_per_run_and_again_on_the_next_run` now pins it.
770
+ *
771
+ * @public
772
+ */
754
773
  interface SessionLifecycleContext {
755
774
  agentId: string;
756
775
  runId: string;
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var chunkDEJCKB65_cjs = require('./chunk-DEJCKB65.cjs');
3
+ var chunkY46VI73J_cjs = require('./chunk-Y46VI73J.cjs');
4
4
  require('./chunk-KVSAY6NZ.cjs');
5
5
  require('./chunk-Y2KYR2ED.cjs');
6
6
  require('./chunk-BUUUWQMB.cjs');
7
7
  require('./chunk-Z2JFX372.cjs');
8
- require('./chunk-SSIRPWWD.cjs');
8
+ require('./chunk-65UMH5V3.cjs');
9
9
  require('./chunk-BV2MWEMV.cjs');
10
10
  require('./chunk-D6POWE7E.cjs');
11
11
  require('./chunk-GHX4P3V2.cjs');
@@ -61,7 +61,7 @@ require('./chunk-6LHQPOMI.cjs');
61
61
 
62
62
  Object.defineProperty(exports, "Agent", {
63
63
  enumerable: true,
64
- get: function () { return chunkDEJCKB65_cjs.Agent; }
64
+ get: function () { return chunkY46VI73J_cjs.Agent; }
65
65
  });
66
- //# sourceMappingURL=agent-GACKKINM.cjs.map
67
- //# sourceMappingURL=agent-GACKKINM.cjs.map
66
+ //# sourceMappingURL=agent-KJLAWKZB.cjs.map
67
+ //# sourceMappingURL=agent-KJLAWKZB.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-GACKKINM.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-KJLAWKZB.cjs"}
@@ -1,9 +1,9 @@
1
- export { Agent } from './chunk-43H4EBS2.js';
1
+ export { Agent } from './chunk-363RBGIR.js';
2
2
  import './chunk-K2VMFZQ5.js';
3
3
  import './chunk-AWINL3ZC.js';
4
4
  import './chunk-K2BQQ445.js';
5
5
  import './chunk-7SZAV6QG.js';
6
- import './chunk-AI4MXACC.js';
6
+ import './chunk-7L3MIW2F.js';
7
7
  import './chunk-2SFBB54R.js';
8
8
  import './chunk-55GB6JYQ.js';
9
9
  import './chunk-H73MEMQB.js';
@@ -54,5 +54,5 @@ import './chunk-V22DZIXO.js';
54
54
  import './chunk-NJWYQWDL.js';
55
55
  import './chunk-ALUN2B4W.js';
56
56
  import './chunk-CZJ6Q7CW.js';
57
- //# sourceMappingURL=agent-VUNM33WJ.js.map
58
- //# sourceMappingURL=agent-VUNM33WJ.js.map
57
+ //# sourceMappingURL=agent-PNYJ5S2Y.js.map
58
+ //# sourceMappingURL=agent-PNYJ5S2Y.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-VUNM33WJ.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-PNYJ5S2Y.js"}
@@ -689,6 +689,8 @@ interface ProviderProfile {
689
689
  * `on_session_end`, `post_assistant_reply`) is fire-and-forget: the return value is DISCARDED. A
690
690
  * policy that needs to change a tool result belongs on `transform_tool_result` — put it on
691
691
  * `post_tool_call` and it quietly degrades to observation.
692
+ * - `on_session_start` / `on_session_end` fire once per **run**, not once per agent lifetime — see
693
+ * {@link SessionLifecycleContext}. Build an agent per turn and they fire on every message.
692
694
  *
693
695
  * Failure is asymmetric too. A fire-and-forget or transform handler that throws is caught, logged to
694
696
  * stderr, and the run continues. A `pre_tool_call` handler that throws is NOT caught by the hook
@@ -750,7 +752,24 @@ interface PostToolCallContext {
750
752
  agentId: string;
751
753
  runId: string;
752
754
  }
753
- /** #65 — context for the `on_session_start` / `on_session_end` hooks. @public */
755
+ /**
756
+ * #65 — context for the `on_session_start` / `on_session_end` hooks.
757
+ *
758
+ * **These fire once per RUN, not once per agent lifetime**, and the `runId` on this very context is
759
+ * the tell: it changes every time they fire. "Session" here means one pass through the agent loop.
760
+ *
761
+ * The distinction is invisible to an application that creates an agent once and sends many messages
762
+ * — there, per-run and per-session coincide. It is decisive for one that builds an agent **per
763
+ * turn**: `on_session_start` then fires on every message, which is the opposite of what a handler
764
+ * named for a session start usually assumes.
765
+ *
766
+ * Stated here because it was not stated anywhere a consumer could read it. The only accurate
767
+ * sentence lived in an internal comment at the firing site, and in 2026-09 that cost two people
768
+ * hours and produced a defect report filed against this package for behaviour that is correct.
769
+ * `test_on_session_start_fires_once_per_run_and_again_on_the_next_run` now pins it.
770
+ *
771
+ * @public
772
+ */
754
773
  interface SessionLifecycleContext {
755
774
  agentId: string;
756
775
  runId: string;
package/dist/agent.d.ts CHANGED
@@ -268,9 +268,27 @@ export declare class Agent {
268
268
  */
269
269
  static describe(agentId: string): Promise<AgentDescription>;
270
270
  /**
271
- * Permanently delete a cloud agent.
271
+ * Permanently delete a registered agent — local or cloud.
272
+ *
273
+ * #612 — this HYDRATES before removing, and until it did the method was a no-op against the
274
+ * persisted registry whenever the agent was not already in this process's memory. Which is every
275
+ * agent in a freshly started process: `removeRegisteredAgent` only schedules a save when the entry
276
+ * was in the Map, so `agents.delete()` returned `false`, nothing was scheduled, and
277
+ * `flushRegistrySaves()` flushed an empty queue. The entry survived and this returned normally.
278
+ *
279
+ * Every neighbouring mutator already did this — `rename` and `archive` reach
280
+ * `getRegisteredAgentOrThrow`, which hydrates on a miss. `delete` was the only one that did not.
281
+ *
282
+ * `options.cwd` is read rather than defaulted away: it is declared on `AgentOperationOptions`, and
283
+ * hydrating `process.cwd()` unconditionally is the B-115 defect — an option that compiles and does
284
+ * nothing — on the one path that is supposed to remove data.
285
+ *
286
+ * Deleting an unknown id still resolves rather than throwing, deliberately. `rename` throws
287
+ * `UnknownAgentError` and matching it here is defensible, but it is a breaking change for callers
288
+ * that delete idempotently, and an entry and its transcript can legitimately outlive one another
289
+ * in both directions. That decision belongs to its own change, not to a persistence fix.
272
290
  *
273
291
  * @public
274
292
  */
275
- static delete(agentId: string, _options?: AgentOperationOptions): Promise<void>;
293
+ static delete(agentId: string, options?: AgentOperationOptions): Promise<void>;
276
294
  }
@@ -1,7 +1,7 @@
1
1
  import { submit, emitRunEvent } from './chunk-K2VMFZQ5.js';
2
2
  import { enqueueSessionWrite, hydrateSession, persistTurnToTranscript, flushSessionWrites, appendSessionMessage, getSessionMessages, discardSession, clearSession } from './chunk-AWINL3ZC.js';
3
3
  import { IndexManager } from './chunk-7SZAV6QG.js';
4
- import { loadHookConfig, warnOnce, currentPersonalityContext, warnPersonalitySwitchInsideFork } from './chunk-AI4MXACC.js';
4
+ import { loadHookConfig, warnOnce, currentPersonalityContext, warnPersonalitySwitchInsideFork } from './chunk-7L3MIW2F.js';
5
5
  import { extractCodePlugins } from './chunk-2SFBB54R.js';
6
6
  import { createOpenAiCompatibleRuntime } from './chunk-55GB6JYQ.js';
7
7
  import { persistActiveMemoryTranscript } from './chunk-OR6XIWLB.js';
@@ -4453,7 +4453,13 @@ function registerLocalAgent(args) {
4453
4453
  agentId: args.agentId,
4454
4454
  runtime: "local",
4455
4455
  name: args.options.name,
4456
- summary: "Local contract fixture",
4456
+ // #611 — a runtime label, not a fixture name. `SDKAgentInfo.summary` is `@public` and required,
4457
+ // `AgentOptions` has no `summary` for a consumer to override, and this line was unconditional —
4458
+ // so "Local contract fixture" was the only value the field could hold for a local agent, and it
4459
+ // was measured reaching a user's session record on disk. The cloud sibling already guards its
4460
+ // own fixture string behind `isFixtureMode()`; there is no local equivalent to port, so the
4461
+ // local branch simply takes the non-fixture value.
4462
+ summary: "Local agent",
4457
4463
  model: args.model,
4458
4464
  createdAt: Date.now(),
4459
4465
  lastModified: Date.now(),
@@ -9116,7 +9122,7 @@ async function* localAgentStreamToCompletion(agent, message, options) {
9116
9122
  async function localAgentFork(parent, options) {
9117
9123
  const { forkAgentImpl } = await import('./fork-agent-S2EPIML7.js');
9118
9124
  const { getAgentFacade } = await import('./agent-factory-registry-ZVTABLEY.js');
9119
- const { withPersonalityContext } = await import('./context-XNREEC7M.js');
9125
+ const { withPersonalityContext } = await import('./context-BUIE52VH.js');
9120
9126
  const create = getAgentFacade().create;
9121
9127
  return withPersonalityContext(
9122
9128
  { slug: parent.personalitySlugSnapshot, isFork: true },
@@ -10421,14 +10427,17 @@ function commonAgentInfo(agent, fallbackSummary) {
10421
10427
  }
10422
10428
  function toLocalAgentInfo(agent) {
10423
10429
  return {
10424
- ...commonAgentInfo(agent, "Local contract fixture"),
10430
+ ...commonAgentInfo(agent, "Local agent"),
10425
10431
  runtime: "local",
10426
10432
  ...agent.cwd !== void 0 ? { cwd: agent.cwd } : {}
10427
10433
  };
10428
10434
  }
10429
10435
  function toCloudAgentInfo(agent) {
10430
10436
  return {
10431
- ...commonAgentInfo(agent, "Cloud contract fixture"),
10437
+ // Same fallback, same reason (#611). The cloud REGISTRATION already guards its fixture string
10438
+ // behind `isFixtureMode()`, so this line only answers for a record that carries no summary —
10439
+ // and a fixture name is the wrong answer for that record whichever runtime it came from.
10440
+ ...commonAgentInfo(agent, "Cloud agent"),
10432
10441
  archived: agent.archived,
10433
10442
  runtime: "cloud",
10434
10443
  env: { type: "cloud" },
@@ -10920,11 +10929,30 @@ var Agent = class _Agent {
10920
10929
  };
10921
10930
  }
10922
10931
  /**
10923
- * Permanently delete a cloud agent.
10932
+ * Permanently delete a registered agent — local or cloud.
10933
+ *
10934
+ * #612 — this HYDRATES before removing, and until it did the method was a no-op against the
10935
+ * persisted registry whenever the agent was not already in this process's memory. Which is every
10936
+ * agent in a freshly started process: `removeRegisteredAgent` only schedules a save when the entry
10937
+ * was in the Map, so `agents.delete()` returned `false`, nothing was scheduled, and
10938
+ * `flushRegistrySaves()` flushed an empty queue. The entry survived and this returned normally.
10939
+ *
10940
+ * Every neighbouring mutator already did this — `rename` and `archive` reach
10941
+ * `getRegisteredAgentOrThrow`, which hydrates on a miss. `delete` was the only one that did not.
10942
+ *
10943
+ * `options.cwd` is read rather than defaulted away: it is declared on `AgentOperationOptions`, and
10944
+ * hydrating `process.cwd()` unconditionally is the B-115 defect — an option that compiles and does
10945
+ * nothing — on the one path that is supposed to remove data.
10946
+ *
10947
+ * Deleting an unknown id still resolves rather than throwing, deliberately. `rename` throws
10948
+ * `UnknownAgentError` and matching it here is defensible, but it is a breaking change for callers
10949
+ * that delete idempotently, and an entry and its transcript can legitimately outlive one another
10950
+ * in both directions. That decision belongs to its own change, not to a persistence fix.
10924
10951
  *
10925
10952
  * @public
10926
10953
  */
10927
- static async delete(agentId, _options = {}) {
10954
+ static async delete(agentId, options = {}) {
10955
+ await hydrateRegistryFromDisk(options.cwd ?? process.cwd());
10928
10956
  removeRegisteredAgent(agentId);
10929
10957
  await flushRegistrySaves();
10930
10958
  }
@@ -10977,5 +11005,5 @@ async function openLocalStore(reg) {
10977
11005
  }
10978
11006
 
10979
11007
  export { Agent, AgentBuilder, DEFAULT_AGENTIC_MODEL_ID, MEMORY_EMBEDDING_ADAPTERS, Tool, ToolError, UsageAccumulator, computeCost, generateCronId, getPricingEntry, openRouterMemoryEmbeddingProviderAdapter, resolveSessionDir };
10980
- //# sourceMappingURL=chunk-43H4EBS2.js.map
10981
- //# sourceMappingURL=chunk-43H4EBS2.js.map
11008
+ //# sourceMappingURL=chunk-363RBGIR.js.map
11009
+ //# sourceMappingURL=chunk-363RBGIR.js.map