@noetic-tools/core 0.0.1 → 0.1.1

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 (254) hide show
  1. package/README.md +31 -11
  2. package/dist/adapters/in-memory-fs-adapter.d.ts +1 -1
  3. package/dist/adapters/in-memory-fs-adapter.js +1 -1
  4. package/dist/adapters/in-memory-shell-adapter.d.ts +1 -1
  5. package/dist/adapters/in-memory-subprocess/manifest-persistence.d.ts +8 -0
  6. package/dist/adapters/in-memory-subprocess/manifest-persistence.js +56 -0
  7. package/dist/adapters/in-memory-subprocess/metadata.d.ts +12 -0
  8. package/dist/adapters/in-memory-subprocess/metadata.js +58 -0
  9. package/dist/adapters/in-memory-subprocess/step-completion.d.ts +3 -0
  10. package/dist/adapters/in-memory-subprocess/step-completion.js +86 -0
  11. package/dist/adapters/in-memory-subprocess/types.d.ts +88 -0
  12. package/dist/adapters/in-memory-subprocess/types.js +2 -0
  13. package/dist/adapters/in-memory-subprocess-adapter.d.ts +12 -4
  14. package/dist/adapters/in-memory-subprocess-adapter.js +164 -55
  15. package/dist/adapters/openrouter.d.ts +16 -7
  16. package/dist/adapters/openrouter.js +68 -7
  17. package/dist/builders/channel-builder.d.ts +1 -1
  18. package/dist/builders/control-flow-builders.d.ts +3 -3
  19. package/dist/builders/control-flow-builders.js +9 -4
  20. package/dist/builders/every.d.ts +3 -3
  21. package/dist/builders/every.js +5 -2
  22. package/dist/builders/layer-provides-builders.d.ts +1 -32
  23. package/dist/builders/layer-provides-builders.js +1 -33
  24. package/dist/builders/loop-builder.d.ts +2 -2
  25. package/dist/builders/loop-builder.js +5 -2
  26. package/dist/builders/memory-builder.d.ts +1 -1
  27. package/dist/builders/memory-builder.js +1 -1
  28. package/dist/builders/provide-builder.d.ts +2 -2
  29. package/dist/builders/provide-builder.js +5 -2
  30. package/dist/builders/spawn-builder.d.ts +22 -9
  31. package/dist/builders/spawn-builder.js +17 -3
  32. package/dist/builders/step-builders.d.ts +51 -30
  33. package/dist/builders/step-builders.js +31 -12
  34. package/dist/builders/tool-builder.d.ts +7 -3
  35. package/dist/builders/tool-builder.js +3 -1
  36. package/dist/builders/workflow-hydrator.d.ts +38 -0
  37. package/dist/builders/workflow-hydrator.js +336 -0
  38. package/dist/conditions/conditions.d.ts +4 -4
  39. package/dist/conditions/conditions.js +2 -2
  40. package/dist/errors/noetic-error.d.ts +1 -1
  41. package/dist/errors/noetic-error.js +2 -0
  42. package/dist/{runtime → harness}/agent-harness.d.ts +65 -45
  43. package/dist/harness/agent-harness.js +576 -0
  44. package/dist/harness/deps/adapters.d.ts +4 -0
  45. package/dist/harness/deps/adapters.js +4 -0
  46. package/dist/harness/deps/interpreter.d.ts +5 -0
  47. package/dist/harness/deps/interpreter.js +4 -0
  48. package/dist/harness/deps/memory.d.ts +5 -0
  49. package/dist/harness/deps/memory.js +4 -0
  50. package/dist/harness/deps/runtime.d.ts +10 -0
  51. package/dist/harness/deps/runtime.js +7 -0
  52. package/dist/harness/deps/types.d.ts +17 -0
  53. package/dist/harness/deps/types.js +1 -0
  54. package/dist/harness/model-call.d.ts +50 -0
  55. package/dist/harness/model-call.js +694 -0
  56. package/dist/harness/model-schema.d.ts +19 -0
  57. package/dist/harness/model-schema.js +46 -0
  58. package/dist/harness/step-bootstrap.d.ts +25 -0
  59. package/dist/harness/step-bootstrap.js +170 -0
  60. package/dist/index.d.ts +114 -76
  61. package/dist/index.js +74 -50
  62. package/dist/internal-test.d.ts +4 -4
  63. package/dist/internal-test.js +4 -4
  64. package/dist/interpreter/action-deps.d.ts +12 -0
  65. package/dist/interpreter/action-deps.js +10 -0
  66. package/dist/interpreter/action-types.d.ts +8 -0
  67. package/dist/interpreter/action-types.js +1 -0
  68. package/dist/interpreter/collect-tools.d.ts +2 -2
  69. package/dist/interpreter/collect-tools.js +6 -2
  70. package/dist/interpreter/execute-action.d.ts +22 -0
  71. package/dist/interpreter/execute-action.js +527 -0
  72. package/dist/interpreter/{execute-every.d.ts → execute-control.d.ts} +8 -2
  73. package/dist/interpreter/execute-control.js +530 -0
  74. package/dist/interpreter/execute.d.ts +16 -3
  75. package/dist/interpreter/execute.js +154 -51
  76. package/dist/interpreter/message-helpers.d.ts +1 -9
  77. package/dist/interpreter/message-helpers.js +1 -42
  78. package/dist/interpreter/step-dispatcher.d.ts +61 -0
  79. package/dist/interpreter/step-dispatcher.js +67 -0
  80. package/dist/interpreter/typeguards.d.ts +8 -15
  81. package/dist/interpreter/typeguards.js +4 -21
  82. package/dist/memory/budget.d.ts +2 -2
  83. package/dist/memory/budget.js +1 -1
  84. package/dist/{runtime → memory}/exec-context-factory.d.ts +2 -2
  85. package/dist/{runtime → memory}/exec-context-factory.js +1 -1
  86. package/dist/memory/flow-schema.d.ts +52 -0
  87. package/dist/memory/flow-schema.js +102 -0
  88. package/dist/memory/function-call-utils.d.ts +1 -1
  89. package/dist/memory/function-call-utils.js +4 -2
  90. package/dist/memory/layer-api.d.ts +4 -4
  91. package/dist/memory/layer-api.js +2 -2
  92. package/dist/memory/layer-lifecycle.d.ts +6 -6
  93. package/dist/memory/layer-lifecycle.js +6 -6
  94. package/dist/memory/layer-provides.d.ts +32 -0
  95. package/dist/memory/layer-provides.js +33 -0
  96. package/dist/memory/layer-usage.d.ts +4 -3
  97. package/dist/memory/layer-usage.js +9 -3
  98. package/dist/memory/layers/durable-task-state.d.ts +8 -8
  99. package/dist/memory/layers/durable-task-state.js +2 -2
  100. package/dist/memory/layers/file-reference.d.ts +1 -1
  101. package/dist/memory/layers/file-reference.js +303 -247
  102. package/dist/memory/layers/history-window.d.ts +1 -1
  103. package/dist/memory/layers/history-window.js +4 -4
  104. package/dist/memory/layers/observational-memory.d.ts +5 -5
  105. package/dist/memory/layers/observational-memory.js +2 -3
  106. package/dist/memory/layers/plan.d.ts +2 -2
  107. package/dist/memory/layers/plan.js +15 -10
  108. package/dist/memory/layers/static-content.d.ts +2 -2
  109. package/dist/memory/layers/static-content.js +1 -1
  110. package/dist/memory/layers/steering.d.ts +7 -7
  111. package/dist/memory/layers/steering.js +5 -5
  112. package/dist/memory/layers/tool-memory-layer.d.ts +2 -2
  113. package/dist/memory/layers/tool-memory-layer.js +1 -1
  114. package/dist/memory/layers/working-memory.d.ts +7 -7
  115. package/dist/memory/layers/working-memory.js +4 -4
  116. package/dist/memory/projector.d.ts +2 -2
  117. package/dist/memory/scope.d.ts +1 -1
  118. package/dist/memory/strip-unresolved.d.ts +1 -1
  119. package/dist/observability/span-impl.d.ts +1 -1
  120. package/dist/observability/trace-exporter.d.ts +2 -2
  121. package/dist/observability/trace-exporter.js +1 -1
  122. package/dist/patterns/dynamic-workflow.d.ts +55 -0
  123. package/dist/patterns/dynamic-workflow.js +194 -0
  124. package/dist/patterns/flow.d.ts +2 -52
  125. package/dist/patterns/flow.js +1 -103
  126. package/dist/patterns/interview.d.ts +2 -2
  127. package/dist/patterns/interview.js +5 -5
  128. package/dist/patterns/plans.d.ts +6 -6
  129. package/dist/patterns/plans.js +4 -4
  130. package/dist/patterns/ralph-wiggum.d.ts +4 -4
  131. package/dist/patterns/ralph-wiggum.js +5 -5
  132. package/dist/patterns/react.d.ts +3 -3
  133. package/dist/patterns/react.js +5 -5
  134. package/dist/portable/adapters.d.ts +6 -0
  135. package/dist/portable/adapters.js +6 -0
  136. package/dist/portable/ask-user.d.ts +4 -0
  137. package/dist/portable/ask-user.js +2 -0
  138. package/dist/portable/builders.d.ts +12 -0
  139. package/dist/portable/builders.js +12 -0
  140. package/dist/portable/memory-layers.d.ts +12 -0
  141. package/dist/portable/memory-layers.js +12 -0
  142. package/dist/portable/runtime.d.ts +4 -0
  143. package/dist/portable/runtime.js +4 -0
  144. package/dist/portable/until.d.ts +4 -0
  145. package/dist/portable/until.js +4 -0
  146. package/dist/portable.d.ts +8 -26
  147. package/dist/portable.js +8 -34
  148. package/dist/runtime/broadcaster-utils.d.ts +7 -3
  149. package/dist/runtime/broadcaster-utils.js +11 -6
  150. package/dist/runtime/channel-store.d.ts +1 -1
  151. package/dist/runtime/channel-store.js +2 -2
  152. package/dist/runtime/context-deps.d.ts +4 -0
  153. package/dist/runtime/context-deps.js +2 -0
  154. package/dist/runtime/context-impl.d.ts +42 -12
  155. package/dist/runtime/context-impl.js +52 -5
  156. package/dist/runtime/context-type-deps.d.ts +14 -0
  157. package/dist/runtime/context-type-deps.js +1 -0
  158. package/dist/runtime/cwd-helpers.d.ts +1 -1
  159. package/dist/runtime/detached-handle.d.ts +52 -4
  160. package/dist/runtime/detached-handle.js +218 -14
  161. package/dist/runtime/durable/checkpoint-store.d.ts +38 -0
  162. package/dist/runtime/durable/checkpoint-store.js +101 -0
  163. package/dist/runtime/durable/detached-signal.d.ts +37 -0
  164. package/dist/runtime/durable/detached-signal.js +52 -0
  165. package/dist/runtime/durable/harness-checkpoints.d.ts +51 -0
  166. package/dist/runtime/durable/harness-checkpoints.js +104 -0
  167. package/dist/runtime/durable/index.d.ts +10 -0
  168. package/dist/runtime/durable/index.js +5 -0
  169. package/dist/runtime/durable/runnable-loop.d.ts +100 -0
  170. package/dist/runtime/durable/runnable-loop.js +90 -0
  171. package/dist/runtime/durable/session-seed.d.ts +28 -0
  172. package/dist/runtime/durable/session-seed.js +27 -0
  173. package/dist/runtime/durable/stall-nudge.d.ts +82 -0
  174. package/dist/runtime/durable/stall-nudge.js +87 -0
  175. package/dist/runtime/event-broadcaster.d.ts +1 -1
  176. package/dist/runtime/in-memory-storage.d.ts +1 -1
  177. package/dist/runtime/in-memory-storage.js +1 -1
  178. package/dist/runtime/item-log-impl.d.ts +3 -3
  179. package/dist/runtime/item-log-impl.js +1 -1
  180. package/dist/runtime/message-queue.d.ts +2 -2
  181. package/dist/runtime/session-runner.d.ts +7 -7
  182. package/dist/runtime/session-runner.js +3 -3
  183. package/dist/runtime/session-streams.d.ts +3 -3
  184. package/dist/runtime/session-streams.js +1 -1
  185. package/dist/runtime/step-registry.d.ts +42 -0
  186. package/dist/runtime/step-registry.js +77 -0
  187. package/dist/runtime/tool-memory.d.ts +3 -3
  188. package/dist/schemas/item.d.ts +1 -1
  189. package/dist/schemas/workflow.d.ts +139 -0
  190. package/dist/schemas/workflow.js +232 -0
  191. package/dist/types/ask-user-types.d.ts +57 -0
  192. package/dist/types/ask-user-types.js +74 -0
  193. package/dist/types/checkpoint.d.ts +98 -0
  194. package/dist/types/checkpoint.js +81 -0
  195. package/dist/types/common.d.ts +1 -50
  196. package/dist/types/context-parts/item-log.d.ts +6 -0
  197. package/dist/types/context-parts/item-log.js +1 -0
  198. package/dist/types/context-parts/layer-usage.d.ts +18 -0
  199. package/dist/types/context-parts/layer-usage.js +1 -0
  200. package/dist/types/context.d.ts +140 -31
  201. package/dist/types/error.d.ts +15 -0
  202. package/dist/types/harness-result.d.ts +2 -2
  203. package/dist/types/items.d.ts +18 -2
  204. package/dist/types/memory-context.d.ts +39 -0
  205. package/dist/types/memory-context.js +1 -0
  206. package/dist/types/memory.d.ts +38 -68
  207. package/dist/types/mutable-context.d.ts +3 -3
  208. package/dist/types/runtime.d.ts +14 -13
  209. package/dist/types/steering.d.ts +2 -2
  210. package/dist/types/step-registrar.d.ts +46 -0
  211. package/dist/types/step-registrar.js +56 -0
  212. package/dist/types/step.d.ts +34 -9
  213. package/dist/types/subprocess-adapter.d.ts +119 -3
  214. package/dist/types/subprocess-adapter.js +2 -0
  215. package/dist/types/tool-context.d.ts +6 -6
  216. package/dist/types/tool.d.ts +64 -0
  217. package/dist/types/tool.js +1 -0
  218. package/dist/unstable.d.ts +9 -9
  219. package/dist/unstable.js +7 -7
  220. package/dist/until/combinators.d.ts +1 -1
  221. package/dist/until/never.d.ts +1 -1
  222. package/dist/until/predicates.d.ts +13 -4
  223. package/dist/until/predicates.js +16 -2
  224. package/dist/util/message-helpers.d.ts +17 -0
  225. package/dist/util/message-helpers.js +64 -0
  226. package/package.json +6 -4
  227. package/dist/adapters/local-fs-adapter.d.ts +0 -3
  228. package/dist/adapters/local-fs-adapter.js +0 -43
  229. package/dist/adapters/local-shell-adapter.d.ts +0 -51
  230. package/dist/adapters/local-shell-adapter.js +0 -167
  231. package/dist/adapters/local-subprocess-adapter.d.ts +0 -16
  232. package/dist/adapters/local-subprocess-adapter.js +0 -187
  233. package/dist/conditions/index.d.ts +0 -3
  234. package/dist/conditions/index.js +0 -2
  235. package/dist/interpreter/execute-branch.d.ts +0 -3
  236. package/dist/interpreter/execute-branch.js +0 -10
  237. package/dist/interpreter/execute-every.js +0 -143
  238. package/dist/interpreter/execute-fork.d.ts +0 -3
  239. package/dist/interpreter/execute-fork.js +0 -215
  240. package/dist/interpreter/execute-llm.d.ts +0 -4
  241. package/dist/interpreter/execute-llm.js +0 -217
  242. package/dist/interpreter/execute-loop.d.ts +0 -3
  243. package/dist/interpreter/execute-loop.js +0 -171
  244. package/dist/interpreter/execute-provide.d.ts +0 -10
  245. package/dist/interpreter/execute-provide.js +0 -64
  246. package/dist/interpreter/execute-run.d.ts +0 -3
  247. package/dist/interpreter/execute-run.js +0 -39
  248. package/dist/interpreter/execute-spawn.d.ts +0 -11
  249. package/dist/interpreter/execute-spawn.js +0 -113
  250. package/dist/interpreter/execute-tool.d.ts +0 -5
  251. package/dist/interpreter/execute-tool.js +0 -81
  252. package/dist/runtime/agent-harness.js +0 -1170
  253. /package/dist/{interpreter → util}/framework-cast.d.ts +0 -0
  254. /package/dist/{interpreter → util}/framework-cast.js +0 -0
@@ -1,20 +1,9 @@
1
- import type { ZodType } from 'zod';
2
- import type { LayerStateStore } from '../memory/layer-lifecycle';
3
- import type { Channel, ChannelHandle, ExternalChannel } from '../types/channel';
4
- import type { LLMResponse, LlmProviderConfig } from '../types/common';
5
- import type { Context, CwdState } from '../types/context';
6
- import type { DetachedHandle } from '../types/detached';
7
- import type { FsAdapter } from '../types/fs-adapter';
8
- import type { HarnessResponse, StreamEvent, StreamingItem } from '../types/harness-result';
9
- import type { ExecuteInput, Item, ItemSchemaExtensions } from '../types/items';
10
- import type { ContextMemory, MemoryLayer, StorageAdapter } from '../types/memory';
11
- import type { Span, TraceExporter } from '../types/observability';
12
- import type { AgentConfig, AgentHarnessContract, AgentHooks, CallModelRequest, DeliveryMode, ExecuteOptions, HarnessStatus, RecallLayerOutput, SessionScope } from '../types/runtime';
13
- import type { ShellAdapter } from '../types/shell-adapter';
14
- import type { SteeringDecision } from '../types/steering';
15
- import type { Step } from '../types/step';
16
- import type { SubprocessAdapter } from '../types/subprocess-adapter';
17
- import type { EventBroadcaster } from './event-broadcaster';
1
+ import { ItemSchemaRegistry } from '../schemas/item.js';
2
+ import type { DetachedSpawnOverrides } from './deps/interpreter.js';
3
+ import type { LayerStateStore } from './deps/memory.js';
4
+ import type { CheckpointStore, EventBroadcaster } from './deps/runtime.js';
5
+ import type { AgentConfig, AgentHarnessContract, AgentHooks, CallModelRequest, Channel, ChannelHandle, Context, ContextMemory, CwdState, DeliveryMode, DetachedHandle, ExecuteInput, ExecuteOptions, ExternalChannel, FsAdapter, HarnessResponse, HarnessStatus, Item, ItemSchemaExtensions, LLMResponse, LlmProviderConfig, MemoryLayer, RecallLayerOutput, SessionScope, ShellAdapter, Span, SteeringDecision, Step, StorageAdapter, StreamEvent, StreamingItem, SubprocessAdapter, Tool, TraceExporter, ZodType } from './deps/types.js';
6
+ export { createStreamIdleWatchdog } from './model-call.js';
18
7
  interface AgentHarnessOpts<TParams extends Record<string, unknown> = Record<string, unknown>> {
19
8
  name: string;
20
9
  initialStep?: Step<ContextMemory, string, string>;
@@ -22,6 +11,13 @@ interface AgentHarnessOpts<TParams extends Record<string, unknown> = Record<stri
22
11
  memory?: MemoryLayer[];
23
12
  storage?: StorageAdapter;
24
13
  hooks?: AgentHooks;
14
+ /**
15
+ * Harness-wide tool pool. Merged (identity-deduplicated) with tools
16
+ * collected from `initialStep` to form every context's `unifiedTools`.
17
+ * Use this when the workflow step tree is static and tools are supplied
18
+ * per harness instance rather than baked into individual `step.llm` calls.
19
+ */
20
+ tools?: Tool[];
25
21
  params: TParams;
26
22
  paramsSchema?: ZodType<TParams>;
27
23
  /** Filesystem adapter. Defaults to local node:fs when not provided. */
@@ -30,6 +26,13 @@ interface AgentHarnessOpts<TParams extends Record<string, unknown> = Record<stri
30
26
  shell?: ShellAdapter;
31
27
  /** Subprocess adapter. Defaults to an in-memory, same-process adapter. */
32
28
  subprocess?: SubprocessAdapter;
29
+ /**
30
+ * Checkpoint store used by `harness.checkpoint(ctx)` / `harness.restore()`.
31
+ * When absent, checkpoint/restore are no-ops — a zero-config harness keeps
32
+ * its current ephemeral semantics. Construct with `createCheckpointStore`
33
+ * to enable durable execution.
34
+ */
35
+ checkpointStore?: CheckpointStore;
33
36
  llm?: LlmProviderConfig;
34
37
  /** Harness-wide item schema extensions. */
35
38
  itemSchemas?: ItemSchemaExtensions;
@@ -54,19 +57,6 @@ interface AgentHarnessOpts<TParams extends Record<string, unknown> = Record<stri
54
57
  /** @internal Test-only escape hatch to inject a mock callModel implementation. */
55
58
  _testCallModel?: (request: CallModelRequest) => Promise<LLMResponse>;
56
59
  }
57
- interface StreamIdleWatchdog {
58
- /** Bump the deadline because a stream event just arrived. */
59
- reset: () => void;
60
- /** Clear the pending timer. Safe to call multiple times. */
61
- stop: () => void;
62
- }
63
- /** @internal Create a watchdog that aborts `controller` when no
64
- * {@link StreamIdleWatchdog.reset reset} is called within `timeoutMs`. When
65
- * `timeoutMs <= 0`, returns an inert no-op so callers can always call `.reset()`
66
- * / `.stop()` without a branch. Starts armed: the caller is responsible for
67
- * `.stop()` in a `finally`. `onTimeout` runs before the abort so observers can
68
- * emit a framework event with the original cause. Exported only for unit tests. */
69
- export declare function createStreamIdleWatchdog(timeoutMs: number, controller: AbortController, onTimeout?: () => void): StreamIdleWatchdog;
70
60
  /**
71
61
  * Default agent harness for executing agent steps with built-in channel, memory, and trace support.
72
62
  * Provides channel store, memory layer lifecycle, and trace export with no external dependencies.
@@ -82,8 +72,19 @@ export declare class AgentHarness<TParams extends Record<string, unknown> = Reco
82
72
  readonly fs: FsAdapter;
83
73
  readonly shell: ShellAdapter;
84
74
  readonly subprocess: SubprocessAdapter;
75
+ /**
76
+ * Optional durable-execution store. When present, `checkpoint(ctx)` writes
77
+ * a `CheckpointSnapshot`; when absent, it's a no-op.
78
+ * @internal
79
+ */
80
+ readonly checkpointStore?: CheckpointStore;
85
81
  private readonly initialStep?;
86
- private readonly _memory?;
82
+ /** Harness-wide tool pool merged into every context's `unifiedTools`. */
83
+ private readonly harnessTools;
84
+ /** @internal Memory layers configured for this harness. Exposed non-private
85
+ * so free functions in `runtime/durable/` (checkpoint/restore) can read it
86
+ * without friend-class gymnastics. Do not access from outside core. */
87
+ readonly _memory?: MemoryLayer[];
87
88
  private readonly client?;
88
89
  private readonly channelStore;
89
90
  private readonly callModelOverride?;
@@ -98,7 +99,10 @@ export declare class AgentHarness<TParams extends Record<string, unknown> = Reco
98
99
  * TUI — observe each other's `cd`s.
99
100
  */
100
101
  readonly rootCwdState: CwdState;
101
- private readonly itemSchemas;
102
+ /** @internal Item schema registry. Exposed non-private so free functions
103
+ * in `runtime/durable/` (restore) can parse persisted items. Do not
104
+ * access from outside core. */
105
+ readonly itemSchemas: ItemSchemaRegistry;
102
106
  constructor(opts: AgentHarnessOpts<TParams>);
103
107
  /**
104
108
  * Update the harness-wide root cwd. The TUI calls this in response to a
@@ -122,20 +126,11 @@ export declare class AgentHarness<TParams extends Record<string, unknown> = Reco
122
126
  private getOrCreateSession;
123
127
  private requireSession;
124
128
  callModel(request: CallModelRequest): Promise<LLMResponse>;
125
- /** @internal Drain only messages tagged `between-rounds` from the queue. */
126
- private drainBetweenRoundsMessages;
127
129
  run<I, O>(s: Step<ContextMemory, I, O>, input: I, ctx: Context): Promise<O>;
128
130
  /** Run all layer `init` hooks before the first step executes. Per spec 11,
129
131
  * init MUST complete before any recall fires so layer state is populated. */
130
132
  private initAndRun;
131
- detachedSpawn<I, O>(s: Step<ContextMemory, I, O>, input: I, parentCtx: Context, overrides?: {
132
- /** Override the child's thread id. Default inherits from `parentCtx.threadId`. */
133
- threadId?: string;
134
- /** Override the child's resource id. Default inherits from `parentCtx.resourceId`. */
135
- resourceId?: string;
136
- /** Override the child's initial cwd. Used by worktree isolation to root the child at the worktree path. */
137
- cwdInit?: string;
138
- }): DetachedHandle<O>;
133
+ detachedSpawn<I, O>(s: Step<ContextMemory, I, O>, input: I, parentCtx: Context, overrides?: DetachedSpawnOverrides): DetachedHandle<O>;
139
134
  createContext(opts?: {
140
135
  parent?: Context;
141
136
  items?: Item[];
@@ -174,8 +169,34 @@ export declare class AgentHarness<TParams extends Record<string, unknown> = Reco
174
169
  previewRequestItems(scope?: SessionScope): Promise<ReadonlyArray<Item>>;
175
170
  storeLayers(layers: MemoryLayer[], response: LLMResponse, ctx: Context): Promise<void>;
176
171
  disposeLayers(layers: MemoryLayer[], ctx: Context): Promise<void>;
177
- checkpoint(_ctx: Context): Promise<void>;
178
- restore(_executionId: string): Promise<Context | null>;
172
+ /**
173
+ * Snapshot the execution state at a checkpoint boundary.
174
+ *
175
+ * Fires at four well-defined points on the happy path:
176
+ * 1. End of every `execute()` that mutated the item log — so a crash
177
+ * between turns lands on a snapshot that includes the user/assistant
178
+ * items that actually flowed.
179
+ * 2. After `detachedSpawn()` settles (success or failure) — the parent's
180
+ * record of running/completed children stays consistent with the
181
+ * adapter's handle manifest.
182
+ * 3. After an ask-user enqueue — a restart can replay the pending modal
183
+ * to the TUI.
184
+ * 4. After `runAppendPipeline` — layer state can mutate as items land,
185
+ * so the snapshot must follow the mutation.
186
+ *
187
+ * Delegates to `captureCheckpoint` / `restoreFromCheckpoint` in
188
+ * `runtime/durable/harness-checkpoints` so the ~140 lines of snapshot
189
+ * logic live beside the other durability machinery.
190
+ */
191
+ checkpoint(ctx: Context): Promise<void>;
192
+ /**
193
+ * Rebuild a `Context` from a previously-persisted snapshot. Returns `null`
194
+ * if no snapshot is recorded for `executionId`. Surface a typed
195
+ * `NoeticConfigError(CHECKPOINT_SCHEMA_MISMATCH)` when the snapshot's
196
+ * schema version is unrecognised — the caller is expected to discard the
197
+ * checkpoint via `CheckpointStore.clear()` and start a fresh execution.
198
+ */
199
+ restore(executionId: string): Promise<Context | null>;
179
200
  cancel(_ctx: Context, _reason?: string): Promise<void>;
180
201
  createSpan(name: string, parent: Span | null): Span;
181
202
  getLayerState<T>(executionId: string, layerId: string): T | undefined;
@@ -203,4 +224,3 @@ export declare class AgentHarness<TParams extends Record<string, unknown> = Reco
203
224
  tokenCount: number;
204
225
  }[]>;
205
226
  }
206
- export {};