@yaag/runtime 0.11.0 → 0.12.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 (37) hide show
  1. package/package.json +1 -1
  2. package/src/agent/agent-compaction.ts +1 -1
  3. package/src/agent/agent.ts +1 -1
  4. package/src/agent/define-agent.ts +7 -5
  5. package/src/ask/ask-exchange.ts +2 -8
  6. package/src/catalog/agent-describe-fixture.ts +121 -0
  7. package/src/catalog/agent-describe.ts +210 -0
  8. package/src/catalog/catalog-entry.ts +39 -0
  9. package/src/catalog/catalog-fixture.ts +87 -0
  10. package/src/catalog/catalog-match.ts +77 -0
  11. package/src/catalog/catalog-result.ts +69 -0
  12. package/src/catalog/index.ts +57 -0
  13. package/src/catalog/load-catalog.ts +74 -0
  14. package/src/catalog/program-scan.ts +64 -0
  15. package/src/catalog/registry-paths.ts +26 -0
  16. package/src/catalog/registry-reader.ts +115 -0
  17. package/src/catalog/registry-schema.ts +119 -0
  18. package/src/config/config-paths.ts +14 -7
  19. package/src/config/index.ts +1 -0
  20. package/src/contract/agent-report.ts +42 -0
  21. package/src/contract/error-codes.ts +65 -0
  22. package/src/contract/handle.ts +132 -0
  23. package/src/contract/index.ts +34 -0
  24. package/src/contract/model-spec.ts +81 -0
  25. package/src/contract/spawn-options.ts +127 -0
  26. package/src/error-factories.ts +70 -0
  27. package/src/errors.ts +22 -118
  28. package/src/index.ts +43 -0
  29. package/src/model/model-resolution.ts +19 -71
  30. package/src/model/model-swap.ts +1 -1
  31. package/src/model/resolution-loop.ts +1 -1
  32. package/src/model/thinking-level.ts +5 -5
  33. package/src/public-api.ts +28 -0
  34. package/src/run/run-context.ts +4 -2
  35. package/src/transport/pi-state.ts +2 -9
  36. package/src/transport/transport.ts +8 -26
  37. package/src/types.ts +16 -243
@@ -1,76 +1,24 @@
1
+ import type {
2
+ ModelError,
3
+ ModelResolver,
4
+ ModelSelection,
5
+ ModelSpec,
6
+ ThinkingLevel,
7
+ ThinkingResolver,
8
+ ThinkingSpec,
9
+ } from "../contract/index.ts";
1
10
  import { parseModelSuffix } from "./model-suffix.ts";
2
- import { isThinkingLevel, type ThinkingLevel } from "./thinking-level.ts";
11
+ import { isThinkingLevel } from "./thinking-level.ts";
3
12
 
4
- /**
5
- * Why one model candidate was rejected by pi (ADR-0037).
6
- *
7
- * `not_found`: the pattern matched no model, or pi refused the live swap.
8
- * `auth`: the provider refused the credentials.
9
- * `rate_limited`: the provider stayed rate-limited after pi's own retries.
10
- *
11
- * These three classes are the only triggers of Model Resolution. A different
12
- * transport or turn failure stays an ordinary failure and starts no new attempt.
13
- */
14
- export type ModelErrorReason = "not_found" | "auth" | "rate_limited";
15
-
16
- /**
17
- * One failed Model Resolution attempt, handed back to the caller's resolver.
18
- *
19
- * yaag gives the full history to each resolver call, oldest attempt first. The
20
- * first call gets an empty list (ADR-0037).
21
- */
22
- export interface ModelError {
23
- readonly reason: ModelErrorReason;
24
- /** The model pattern that failed, after inline-suffix stripping. */
25
- readonly failedModel: string;
26
- /** 0-based index of the attempt that produced this error. */
27
- readonly attempt: number;
28
- }
29
-
30
- /**
31
- * Picks the next model candidate, or `undefined` to give up (ADR-0037).
32
- *
33
- * When the resolver gives up, the spawn or the Ask fails with
34
- * `MODEL_RESOLUTION_FAILED`, which carries the full error history. yaag also
35
- * refuses a candidate that already failed with `not_found` or `auth` in the
36
- * same loop, so a resolver cannot loop forever. The resolver must be pure and
37
- * synchronous.
38
- */
39
- export type ModelResolver = (errors: readonly ModelError[]) => string | undefined;
40
-
41
- /**
42
- * Every accepted `model` form: one pattern, an ordered list, or a resolver.
43
- *
44
- * An array is the resolver that reads the candidate at the attempt index, and
45
- * gives `undefined` past the end. One pattern is the one-element list. So the
46
- * termination rule of `ModelResolver` covers every form (ADR-0037).
47
- */
48
- export type ModelSpec = string | readonly string[] | ModelResolver;
49
-
50
- /**
51
- * Picks the thinking level for a settled model, or `undefined` for pi's default.
52
- *
53
- * `undefined` means "no thinking preference". It is not a failure, and it does
54
- * not stop the attempt (ADR-0037).
55
- */
56
- export type ThinkingResolver = (
57
- selectedModel: string,
58
- errors: readonly ModelError[],
59
- ) => ThinkingLevel | undefined;
60
-
61
- /**
62
- * Every accepted `thinking` form: one level or a resolver.
63
- *
64
- * An inline suffix on the resolved model pattern wins over this property
65
- * (ADR-0037).
66
- */
67
- export type ThinkingSpec = ThinkingLevel | ThinkingResolver;
68
-
69
- /** One attempt's settled selection; `model: undefined` inherits pi's default model. */
70
- export interface ModelSelection {
71
- readonly model: string | undefined;
72
- readonly thinking: ThinkingLevel | undefined;
73
- }
13
+ export type {
14
+ ModelError,
15
+ ModelErrorReason,
16
+ ModelResolver,
17
+ ModelSelection,
18
+ ModelSpec,
19
+ ThinkingResolver,
20
+ ThinkingSpec,
21
+ } from "../contract/index.ts";
74
22
 
75
23
  /** The canonical shape the spawn loop consumes, whatever form the caller wrote. */
76
24
  export interface ModelResolution {
@@ -1,4 +1,4 @@
1
- import { agentError } from "../errors.ts";
1
+ import { agentError } from "../error-factories.ts";
2
2
  import type { CommandResponse, Frame } from "../transport/index.ts";
3
3
  import { matchAvailableModel, readAvailableModel, readAvailableModels } from "./model-match.ts";
4
4
  import type { ModelSelection } from "./model-resolution.ts";
@@ -1,4 +1,4 @@
1
- import { modelResolutionError } from "../errors.ts";
1
+ import { modelResolutionError } from "../error-factories.ts";
2
2
  import { ModelErrorHistory } from "./model-error-history.ts";
3
3
  import { classifyAskFailure, classifyModelFailure } from "./model-failure.ts";
4
4
  import type { ModelFallbackSink } from "./model-fallback.ts";
@@ -1,10 +1,10 @@
1
1
  /**
2
- * pi's supported thinking levels.
3
- *
4
- * Lives in its own leaf module so both `types.ts` and the Model Resolution
5
- * modules can depend on it without forming an import cycle.
2
+ * The value side of pi's thinking levels. The type itself lives in
3
+ * `contract/model-spec.ts` (ADR-0045) and is re-exported here.
6
4
  */
7
- export type ThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
5
+ import type { ThinkingLevel } from "../contract/index.ts";
6
+
7
+ export type { ThinkingLevel } from "../contract/index.ts";
8
8
 
9
9
  /**
10
10
  * The closed level list, authored as a total record so that adding a level to
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The author surface of `@yaag/runtime` (ADR-0045).
3
+ *
4
+ * An Orchestration Program imports exactly `@yaag/runtime` and `typebox`
5
+ * (ADR-0033). This file states the subset a program author may use, and the
6
+ * declaration tree a workspace gets is emitted from it alone.
7
+ *
8
+ * The imports go past the directory indexes on purpose: a directory index
9
+ * states the runtime API, which holds `executeRun`, `Agent`, or `promptGist`
10
+ * as well. This file must not pull those into the emitted tree.
11
+ */
12
+
13
+ export type { AgentConfig, AgentDefinition } from "./agent/define-agent.ts";
14
+ export { defineAgent } from "./agent/define-agent.ts";
15
+ export type {
16
+ AskOptions,
17
+ Handle,
18
+ SpawnOptions,
19
+ SpawnOverrides,
20
+ StructuredAskOptions,
21
+ ThinkingLevel,
22
+ } from "./contract/index.ts";
23
+ export type { YaagErrorCode } from "./errors.ts";
24
+ export { isYaagError, YaagError } from "./errors.ts";
25
+ export { prompt } from "./prompt/prompt.ts";
26
+ export type { OrchestrationProgram, ProgramDefinition } from "./run/define-run.ts";
27
+ export { defineRun } from "./run/define-run.ts";
28
+ export type { RunContext } from "./run/run-context.ts";
@@ -1,5 +1,7 @@
1
- import type { AgentDefinition } from "../agent/index.ts";
2
- import type { Handle, SpawnOptions, SpawnOverrides } from "../types.ts";
1
+ // `../agent/define-agent.ts` is a deep import on purpose: the author
2
+ // declaration tree must not pull the `agent/` barrel (ADR-0045).
3
+ import type { AgentDefinition } from "../agent/define-agent.ts";
4
+ import type { Handle, SpawnOptions, SpawnOverrides } from "../contract/index.ts";
3
5
 
4
6
  /** What an Orchestration Program is handed. */
5
7
  export interface RunContext<Args = unknown> {
@@ -1,4 +1,5 @@
1
1
  import { REPORT_RESULT_EXTENSION_PATH, REPORT_RESULT_TOOL_NAME } from "../ask-contract/index.ts";
2
+ import type { AgentProgress } from "../contract/index.ts";
2
3
  import { SYSTEM_PROMPT_RECORDER_EXTENSION_PATH } from "./system-prompt-recorder.ts";
3
4
  import type {
4
5
  AgentStats,
@@ -8,15 +9,7 @@ import type {
8
9
  TokenBreakdown,
9
10
  } from "./transport.ts";
10
11
 
11
- /** What the Agent reported about its own work, read from a `get_state` probe. */
12
- export interface AgentProgress {
13
- /** True while pi streams a completion, compacts its context, or holds a queued prompt. */
14
- readonly working: boolean;
15
- readonly streaming: boolean;
16
- readonly compacting: boolean;
17
- /** Prompts pi has queued but not started. */
18
- readonly pendingMessages: number;
19
- }
12
+ export type { AgentProgress } from "../contract/index.ts";
20
13
 
21
14
  /** The command line for one Agent. */
22
15
  export function piCommand(options: OpenOptions, toolProbeExtensionPath?: string): string[] {
@@ -1,7 +1,13 @@
1
1
  import type { CanonicalJsonObject, ReportedResult } from "../ask-contract/index.ts";
2
+ import type {
3
+ AskOptions,
4
+ CompactionResult,
5
+ ResolvedSpawnOptions,
6
+ ThinkingLevel,
7
+ TokenBreakdown,
8
+ } from "../contract/index.ts";
2
9
  import type { AskLimitOutcome, AskStalledOutcome } from "../errors.ts";
3
10
  import type { RecordedSpawnSelection } from "../model/index.ts";
4
- import type { AskOptions, ResolvedSpawnOptions, ThinkingLevel } from "../types.ts";
5
11
 
6
12
  /**
7
13
  * The one seam of the runtime (ticket 04). An AgentTransport represents a whole
@@ -15,14 +21,7 @@ import type { AskOptions, ResolvedSpawnOptions, ThinkingLevel } from "../types.t
15
21
  /** One JSONL frame in either direction. Unknown `type`s must survive (ticket 01). */
16
22
  export type Frame = { readonly type: string; readonly [k: string]: unknown };
17
23
 
18
- /** pi's full token usage for one Agent, as reported by `get_session_stats`. */
19
- export interface TokenBreakdown {
20
- readonly input: number;
21
- readonly output: number;
22
- readonly cacheRead: number;
23
- readonly cacheWrite: number;
24
- readonly total: number;
25
- }
24
+ export type { CompactionResult, TokenBreakdown } from "../contract/index.ts";
26
25
 
27
26
  /** Cost and usage read at Agent shutdown (ADR-0012). */
28
27
  export interface AgentStats {
@@ -31,23 +30,6 @@ export interface AgentStats {
31
30
  readonly cost: number | null;
32
31
  }
33
32
 
34
- /**
35
- * What one compaction of an Agent's context reported (ADR-0043).
36
- *
37
- * Every field is null when pi reported nothing for it: a custom compaction
38
- * handler may answer without usage, and "unknown" must stay distinct from 0.
39
- */
40
- export interface CompactionResult {
41
- /** Context tokens before the summary replaced the transcript. */
42
- readonly tokensBefore: number | null;
43
- /** Estimated context tokens after the summary replaced the transcript. */
44
- readonly tokensAfter: number | null;
45
- /** Token breakdown of the summary call itself. */
46
- readonly tokens: TokenBreakdown | null;
47
- /** Cost of the summary call itself. */
48
- readonly cost: number | null;
49
- }
50
-
51
33
  /** Recorded inputs used to explain an Ask-hash mismatch without changing identity. */
52
34
  export interface AskMarkerContext {
53
35
  readonly prompt: string;
package/src/types.ts CHANGED
@@ -1,246 +1,19 @@
1
- import type { Static, TSchema } from "typebox";
2
- import type { ModelSpec, ThinkingLevel, ThinkingSpec } from "./model/index.ts";
3
- import type { CompactionResult } from "./transport/index.ts";
4
-
5
- export type { ThinkingLevel } from "./model/index.ts";
6
- export type { CompactionResult } from "./transport/index.ts";
7
-
8
- /** Options for spawning one Agent (ADR-0001, ADR-0009, ADR-0026). */
9
- export interface SpawnOptions {
10
- /** Working directory. Defaults to the Orchestrator's cwd. */
11
- readonly cwd?: string;
12
- /**
13
- * Model pattern, e.g. "anthropic/claude-haiku-4". Unset inherits the user's default.
14
- *
15
- * An array is an ordered fallback list and a function picks the next candidate
16
- * from the failures so far. Any resolved pattern may carry an inline thinking
17
- * suffix (`"opus-5:medium"`), which wins over `thinking`. Each attempt settles
18
- * the model first, then the thinking level for that model. yaag starts a new
19
- * attempt only when pi reports `not_found`, `auth`, or `rate_limited`. See
20
- * `ModelSpec` and `ModelResolver` for the termination rules (ADR-0037).
21
- */
22
- readonly model?: ModelSpec;
23
- /** Replaces the default system prompt (`pi --system-prompt`). */
24
- readonly systemPrompt?: string;
25
- /**
26
- * Sets pi's thinking level; omission preserves pi's default. A function picks
27
- * the level from the settled model, and is not consulted for a model pattern
28
- * that carries an inline thinking suffix. The resolver runs again for each
29
- * attempt, with the model that settled for that attempt (ADR-0037).
30
- */
31
- readonly thinking?: ThinkingSpec;
32
- /** Appends text to pi's system prompt (`pi --append-system-prompt`). */
33
- readonly appendSystemPrompt?: string;
34
- /**
35
- * Restores pi discovery. Omission or false selects ADR-0026's hermetic baseline.
36
- */
37
- readonly inherit?: boolean;
38
- /**
39
- * Explicit pi extensions layer over either ADR-0026 baseline. Relative entries
40
- * resolve from the Orchestration Program file; each becomes `pi -e <path>`.
41
- */
42
- readonly extensions?: readonly string[];
43
- /**
44
- * Load the Effective Config's `agents.extensions` for this Agent. Default
45
- * true; false spawns with only the extensions this call declares (ADR-0040).
46
- */
47
- readonly configExtensions?: boolean;
48
- /**
49
- * Tool allowlist layered over the ADR-0026 baseline; omission is tool-free when hermetic.
50
- * `disallowedTools` applies last. A non-empty surviving allowlist is verified after startup;
51
- * a missing promised name rejects spawn.
52
- */
53
- readonly tools?: readonly string[];
54
- /**
55
- * Tool denylist applied last under ADR-0026; `['yaag_run']` prevents nested yaag Runs.
56
- * Denying an absent tool is inert and is not presence-validated.
57
- */
58
- readonly disallowedTools?: readonly string[];
59
- /**
60
- * Skill-name allowlist, not filesystem paths, layered over the ADR-0026 baseline.
61
- * Omission is skill-free when hermetic; `disallowedSkills` applies last. Unknown requested
62
- * names reject spawn.
63
- */
64
- readonly skills?: readonly string[];
65
- /** Skill-name denylist discovered from pi and applied last (ADR-0026). */
66
- readonly disallowedSkills?: readonly string[];
67
- /** Log and event label. Defaults to a1, a2, …; duplicate names are suffixed. */
68
- readonly name?: string;
69
- /** Request a fresh Git worktree. The requested cwd remains the base until spawn resolves. */
70
- readonly worktree?: boolean;
71
- /**
72
- * Names this Agent's parent in the Run tree (Parent Link). Data only: it is
73
- * no conversation channel and no lifetime rule.
74
- */
75
- readonly parent?: Handle;
76
- }
77
-
78
1
  /**
79
- * Spawn options after Model Resolution has settled one model and thinking level.
2
+ * The author-facing shapes of the runtime.
80
3
  *
81
- * This is the settled shape, and it is what the Cassette identity hashes
82
- * (ADR-0039).
83
- *
84
- * `parent` is omitted on purpose: a Handle must never reach this shape, because
85
- * an Ask records these options into the Cassette. Spawn resolves the Parent
86
- * Link to a name, which travels in `OpenOptions` and stays out of Ask identity.
87
- */
88
- export interface ResolvedSpawnOptions extends Omit<SpawnOptions, "model" | "thinking" | "parent"> {
89
- readonly model?: string;
90
- readonly thinking?: ThinkingLevel;
91
- }
92
-
93
- /**
94
- * What a fork may change about the Agent it copies (ADR-0044).
95
- *
96
- * A fork inherits the source's resolved spawn options verbatim: model,
97
- * thinking, tools, skills, system prompt, extensions and Ask defaults. `name`
98
- * is the exception — the child always gets a fresh auto-name unless this object
99
- * names one. The fork source becomes the child's default `parent`.
100
- *
101
- * The inherited model is the concrete one the source settled on, so the child
102
- * never re-runs the source's fallback list; `fork({ model })` is the way out.
103
- * A fork of a Worktree Agent gets its own fresh worktree, branched from the
104
- * source's branch, so only committed state transfers. The child re-runs the
105
- * ADR-0026 Tool Contract probe against its own effective options.
106
- */
107
- export interface ForkOptions extends SpawnOptions {
108
- /** true = pi's default compaction; a string = pi custom instructions. */
109
- readonly compact?: boolean | string;
110
- }
111
-
112
- /** Topology-only fields that may change when spawning an Agent Definition. */
113
- export interface SpawnOverrides {
114
- /** Log and event label. Defaults to the definition's name; duplicates are suffixed. */
115
- readonly name?: string;
116
- /** Working directory. Defaults to the Orchestrator's cwd. */
117
- readonly cwd?: string;
118
- /** Request a fresh Git worktree. */
119
- readonly worktree?: boolean;
120
- /** Names this Agent's parent in the Run tree (Parent Link). Data only. */
121
- readonly parent?: Handle;
122
- }
123
-
124
- /**
125
- * Options for one Ask (ADR-0003).
126
- *
127
- * Soft limits trip at their configured count: turns are `turn_start` frames and
128
- * tool calls are `tool_execution_start` frames between `agent_start` and
129
- * `agent_settled`; duration is wall time from prompt send. A trip steers the
130
- * Agent, permits one further turn (or a fixed duration grace), then aborts and
131
- * rejects with `ASK_LIMIT` if it has not settled. This leaves the Handle alive.
132
- * `timeoutMs` is independent: it kills the Agent and rejects with `ASK_TIMEOUT`.
133
- *
134
- * A model failure inside an Ask starts Model Fallback and retries the Ask
135
- * (ADR-0038). Each attempt gets fresh soft limits, a fresh Stall Watchdog and a
136
- * fresh output collector. `timeoutMs` is the exception: it is the hard ceiling
137
- * of the whole Ask, and every attempt shares one deadline.
138
- */
139
- export interface AskOptions {
140
- /** Reject and kill the Agent if it has not settled in time. Unset = no bound. */
141
- readonly timeoutMs?: number;
142
- /** Soft budget of `turn_start` frames between `agent_start` and `agent_settled`. */
143
- readonly maxTurns?: number;
144
- /** Soft budget of `tool_execution_start` frames between `agent_start` and `agent_settled`. */
145
- readonly maxToolCalls?: number;
146
- /** Soft wall-clock budget in milliseconds, measured from prompt send. */
147
- readonly maxDurationMs?: number;
148
- /**
149
- * Maximum silence in milliseconds: rejects with `ASK_STALLED` when no frame
150
- * arrives for this span. Complementary to `maxDurationMs` (silence vs.
151
- * trickle) and separate from `timeoutMs`, which always kills. Unset disables
152
- * idle detection (ADR-0020).
153
- */
154
- readonly idleMs?: number;
155
- /**
156
- * Silence budget in milliseconds for the Stall Watchdog, which guards every
157
- * live Ask by default (ADR-0029). On expiry yaag probes the Agent and either
158
- * recovers a missed settlement or rejects with `ASK_STALLED`. Omission uses
159
- * the 10-minute default. `false`, and any value that is not above zero,
160
- * disable the watchdog for this Ask. `ASK_STALLED` is a generic failure: it
161
- * never starts Model Fallback. If the silence budget ends the Ask before pi
162
- * reports a model failure, the Ask fails `ASK_STALLED` and no swap happens
163
- * (ADR-0029).
164
- */
165
- readonly stallMs?: number | false;
166
- /** Per-Ask replacement for the runtime's wrap-up steering message. */
167
- readonly wrapUpPrompt?: string;
168
- }
169
-
170
- /** Ask options that require a schema and preserve its inferred successful result. */
171
- export interface StructuredAskOptions<Schema extends TSchema> extends AskOptions {
172
- /**
173
- * TypeBox object schema the Agent reports its result against, instead of text.
174
- *
175
- * It becomes the input schema of one internal tool, so it must describe an
176
- * object (ADR-0032).
177
- */
178
- readonly outputSchema: Schema;
179
- /**
180
- * Maximum settlements without a reported result that this Ask corrects;
181
- * defaults to 3 when omitted. Argument repair inside a turn is the Agent's
182
- * own loop and costs nothing here.
183
- */
184
- readonly maxSteers?: number;
185
- }
186
-
187
- /**
188
- * A handle to one long-lived Agent.
189
- * ADR-0003: `ask()` is the only conversational verb; everything else is data.
4
+ * The declarations live in `contract/`, which imports nothing outside itself
5
+ * except `typebox` (ADR-0045). This file keeps the historic import path.
190
6
  */
191
- export interface Handle {
192
- /** Stable identity, used in every Lifecycle Event and log line. */
193
- readonly name: string;
194
- /** Resolved absolute working directory; a worktree's actual cwd after spawn resolves. */
195
- readonly cwd: string;
196
- /** Fresh branch for a worktree Agent; undefined for ordinary Agents. */
197
- readonly branch: string | undefined;
198
- /**
199
- * Model id as reported by the Agent's own `get_state` — not the requested
200
- * pattern. A mid-Ask model swap updates it (ADR-0038).
201
- */
202
- readonly model: string;
203
-
204
- /**
205
- * Sends a prompt and resolves after the Agent's turn settles.
206
- *
207
- * Schema-free calls resolve with the exact final assistant text. Calls with
208
- * `outputSchema` resolve with the TypeBox-validated value the Agent reports
209
- * through one internal tool call (ADR-0032). Rejects with a YaagError for a
210
- * failed or empty turn, timeout, `ASK_LIMIT`, or dead Agent. An Ask that
211
- * settles without a reported result is corrected at most `maxSteers` times
212
- * (default 3) and then rejects recoverably with `ASK_INVALID_OUTPUT` after an
213
- * abort settlement; a reported value the schema rejects fails the same way
214
- * without a correction. These recoverable outcomes leave the Handle reusable.
215
- * A retry after a Model Fallback discards the result the failed attempt
216
- * reported, and arms the collector again, so a stale result cannot settle the
217
- * retried Ask (ADR-0032, ADR-0038).
218
- * A concurrent call rejects with `AGENT_BUSY`.
219
- */
220
- ask<Schema extends TSchema>(
221
- prompt: string,
222
- options: StructuredAskOptions<Schema>,
223
- ): Promise<Static<Schema>>;
224
- ask(prompt: string, options?: AskOptions): Promise<string>;
225
-
226
- /**
227
- * Spawns a new Agent from a copy of this Agent's session (ADR-0044).
228
- *
229
- * The fork point is a settled Ask boundary: a call while an Ask is in flight
230
- * rejects with `FORK_DURING_ASK`. An Agent that died mid-Ask, or that holds
231
- * no session file, rejects with `FORK_REFUSED`. An Agent that exited cleanly
232
- * stays forkable, so a program can build context, let the Agent exit, then
233
- * fork its final state many times.
234
- */
235
- fork(overrides?: ForkOptions): Promise<Handle>;
236
-
237
- /**
238
- * Replaces this Agent's context with a summary of it (ADR-0043).
239
- *
240
- * `instructions` becomes pi's `customInstructions`. A call while an Ask is in
241
- * flight rejects with `COMPACT_DURING_ASK`; a refusal from pi rejects with
242
- * `COMPACT_FAILED`. The result reports what the summary call cost; each field
243
- * is null when pi reported nothing for it.
244
- */
245
- compact(instructions?: string): Promise<CompactionResult>;
246
- }
7
+ export type {
8
+ AgentProgress,
9
+ AskOptions,
10
+ CompactionResult,
11
+ ForkOptions,
12
+ Handle,
13
+ ModelError,
14
+ ResolvedSpawnOptions,
15
+ SpawnOptions,
16
+ SpawnOverrides,
17
+ StructuredAskOptions,
18
+ ThinkingLevel,
19
+ } from "./contract/index.ts";