@yaag/cli 0.8.2 → 0.9.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.
@@ -12,7 +12,7 @@ export interface AskEndOutcome {
12
12
  }
13
13
  /**
14
14
  * Emits the Ask-scoped Lifecycle Events for one exchange, plus the Agent-scoped
15
- * `model_fallback` this exchange's fallback loop reports.
15
+ * `model_fallback` and `agent_model` this exchange's fallback loop reports.
16
16
  */
17
17
  export declare class AskEvents {
18
18
  #private;
@@ -24,6 +24,12 @@ export declare class AskEvents {
24
24
  node: (snapshot: NodeSnapshot) => void;
25
25
  /** Not Ask-scoped: a fallback names the Agent only, like the spawn-time loop. */
26
26
  fallback: (fallback: ModelFallback) => void;
27
+ /**
28
+ * The concrete model the Agent runs after a swap that landed (ADR-0041).
29
+ * Agent-scoped like `fallback`: the pattern side of the story stays in
30
+ * `model_fallback`, and this carries pi's own `provider/id`.
31
+ */
32
+ model: (model: string) => void;
27
33
  /** A `normal` cause is the absent default, so ordinary settlements stay lean. */
28
34
  end(outcome: AskEndOutcome): void;
29
35
  }
@@ -22,7 +22,8 @@ export interface RunCheckpointOptions {
22
22
  * What one publication attempt did. `published` covers both a written artifact
23
23
  * and a Run that keeps none. `displaced` carries the error that must become the
24
24
  * Run's outcome. `lost` reports a Checkpoint the Run asked for and did not get,
25
- * while a primary program error keeps the outcome.
25
+ * while the Run keeps its own outcome — a completed result, or a primary
26
+ * program error (ADR-0021 amendment).
26
27
  */
27
28
  export type RunCheckpointResult = {
28
29
  readonly kind: "published";
@@ -130,6 +130,19 @@ export type LifecycleEventBody = {
130
130
  readonly attempt: number;
131
131
  /** The candidate resolution picked next. */
132
132
  readonly resolvedModel: string;
133
+ } | {
134
+ /**
135
+ * The concrete model an Agent runs from now on, reported when it changes
136
+ * after spawn. Today the only producer is a successful mid-Ask model swap
137
+ * (ADR-0038, ADR-0041): `model_fallback` names the pattern the resolver
138
+ * picked, this names the `provider/id` pi landed on, so `agent.model`
139
+ * stays concrete. Spawn needs none: `agent_spawn.model` is already
140
+ * concrete.
141
+ */
142
+ readonly type: "agent_model";
143
+ readonly agent: string;
144
+ /** pi's concrete `provider/id` for the model the Agent runs now. */
145
+ readonly model: string;
133
146
  } | {
134
147
  readonly type: "agent_usage";
135
148
  readonly agent: string;
@@ -6,7 +6,10 @@ export interface ModelFallback {
6
6
  readonly reason: ModelErrorReason;
7
7
  /** 0-based index of the failed attempt in the Agent's shared history. */
8
8
  readonly attempt: number;
9
- /** The candidate the resolver picked next. */
9
+ /**
10
+ * The candidate the resolver picked next. It is a yaag pattern, not a
11
+ * concrete `provider/id`, so it is never an Agent's model (ADR-0041).
12
+ */
10
13
  readonly resolvedModel: string;
11
14
  }
12
15
  /** Where a Model Resolution loop reports each fallback it takes. */
@@ -9,6 +9,11 @@ export type { NodeInfo } from "./summary-nodes.ts";
9
9
  export type AgentState = "idle" | "asking" | "exited";
10
10
  /** Identity and accounting facts that apply in every observer Agent state. */
11
11
  interface AgentInfoBase {
12
+ /**
13
+ * Always the concrete `provider/id` pi reports — from `agent_spawn` at spawn
14
+ * and from `agent_model` after every Model Fallback that landed (ADR-0041).
15
+ * A `resolvedModel` pattern never lands here.
16
+ */
12
17
  readonly model: string | null;
13
18
  readonly cwd: string | null;
14
19
  readonly branch: string | null;
@@ -22,9 +22,8 @@ type ModelFallbackEvent = Extract<LifecycleEventBody, {
22
22
  * The Agent's `model` is left alone. `resolvedModel` is a yaag pattern, which
23
23
  * can be partial, and the event reports it before the swap is applied, while
24
24
  * `model` is pi's resolved `provider/id` for the model the Agent really runs.
25
- * `agent_spawn` is the only writer of that field: a mid-Ask swap updates the
26
- * Handle alone and reports no Lifecycle Event, so the Summary keeps the
27
- * spawn-time id.
25
+ * Only `agent_spawn` and `agent_model` write that field: a mid-Ask swap that
26
+ * lands reports the concrete model in its own `agent_model` event (ADR-0041).
28
27
  */
29
28
  export declare function applyModelFallback(agent: AgentRecord, event: ModelFallbackEvent, at: number | null): AgentRecord;
30
29
  export {};
@@ -0,0 +1,16 @@
1
+ import type { LifecycleEventBody } from "../events.ts";
2
+ import type { AgentRecord } from "./summary-agent.ts";
3
+ type AgentModelEvent = Extract<LifecycleEventBody, {
4
+ readonly type: "agent_model";
5
+ }>;
6
+ /**
7
+ * Folds the concrete model an Agent runs now (ADR-0041).
8
+ *
9
+ * The event reports pi's `provider/id` after a swap landed, so it replaces
10
+ * `model` and nothing else: a model change is not a lifecycle state change, and
11
+ * `state`, `askIndex`, `activity`, `stateChangedAt` and the bounded fallback
12
+ * table stay as they are. An exited Agent is skipped, because its model is
13
+ * frozen together with its final accounting.
14
+ */
15
+ export declare function applyAgentModel(agent: AgentRecord, event: AgentModelEvent): AgentRecord;
16
+ export {};
@@ -45,6 +45,8 @@ export interface FakeTransportOptions extends FakePromptScript {
45
45
  readonly schemaCommandError?: string;
46
46
  /** The snapshot answered to `get_available_models`; defaults to this fake's own model. */
47
47
  readonly models?: readonly AvailableModel[];
48
+ /** The model this fake reports before any swap; defaults to a placeholder id. */
49
+ readonly model?: string;
48
50
  /** Makes a `set_model` command fail, as pi does for a pair it does not know. */
49
51
  readonly setModelError?: string;
50
52
  /** Makes a `set_thinking_level` command fail. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yaag/cli",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -21,8 +21,8 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@earendil-works/pi-tui": "^0.84.0",
24
- "@yaag/runtime": "0.8.2",
25
- "@yaag/tui": "0.8.2",
24
+ "@yaag/runtime": "0.9.0",
25
+ "@yaag/tui": "0.9.0",
26
26
  "typebox": "1.3.7"
27
27
  }
28
28
  }
@@ -41,6 +41,8 @@ function renderPlainEvent(event: LifecycleEventBody, mode: PlainRenderMode): str
41
41
  }
42
42
  case "model_fallback":
43
43
  return `[${event.agent}] model ${event.failedModel} ${event.reason} — falling back to ${event.resolvedModel}`;
44
+ case "agent_model":
45
+ return `[${event.agent}] model \u2014 now running ${event.model}`;
44
46
  case "agent_exit":
45
47
  return `[${event.agent}] exit ${tokens(event.tokens)} ${cost(event.cost)}${event.incomplete ? " (killed mid-ask, cost incomplete)" : ""}`;
46
48
  case "run_end": {
@@ -61,6 +63,7 @@ function minimalEvent(type: LifecycleEventBody["type"]): boolean {
61
63
  type === "ask_start" ||
62
64
  type === "ask_end" ||
63
65
  type === "model_fallback" ||
66
+ type === "agent_model" ||
64
67
  type === "agent_exit" ||
65
68
  type === "run_end"
66
69
  );