@yaag/runtime 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/types.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import type { Static, TSchema } from "typebox";
2
2
  import type { ModelSpec, ThinkingLevel, ThinkingSpec } from "./model/index.ts";
3
+ import type { CompactionResult } from "./transport/index.ts";
3
4
 
4
5
  export type { ThinkingLevel } from "./model/index.ts";
6
+ export type { CompactionResult } from "./transport/index.ts";
5
7
 
6
8
  /** Options for spawning one Agent (ADR-0001, ADR-0009, ADR-0026). */
7
9
  export interface SpawnOptions {
@@ -88,6 +90,25 @@ export interface ResolvedSpawnOptions extends Omit<SpawnOptions, "model" | "thin
88
90
  readonly thinking?: ThinkingLevel;
89
91
  }
90
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
+
91
112
  /** Topology-only fields that may change when spawning an Agent Definition. */
92
113
  export interface SpawnOverrides {
93
114
  /** Log and event label. Defaults to the definition's name; duplicates are suffixed. */
@@ -201,4 +222,25 @@ export interface Handle {
201
222
  options: StructuredAskOptions<Schema>,
202
223
  ): Promise<Static<Schema>>;
203
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>;
204
246
  }