@yagni-app/code-staging 1.2.14-staging.2421.1 → 1.2.14-staging.2437.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.
@@ -72,9 +72,4 @@ export declare function switchChosenModel(pi: ExtensionAPI, ctx: ChosenSwitchCon
72
72
  * pick anyway (the launcher opens every session on it).
73
73
  */
74
74
  export declare function chosenModelFallback(pi: ExtensionAPI, ctx: ChosenSwitchContext, errorMessage: string | undefined): Promise<string | null>;
75
- /** The label a person reads for the session's model: a lane's name, else the model's name. PURE. */
76
- export declare function sessionModelLabel(model: {
77
- id: string;
78
- name?: string;
79
- } | undefined): string;
80
75
  //# sourceMappingURL=modelChoice.d.ts.map
@@ -19,7 +19,7 @@
19
19
  * Pure helpers first, wiring last, as in `tierCommand.ts`.
20
20
  */
21
21
  import { logEvent } from "./errorSink.js";
22
- import { CHOSEN_MODEL_PREFIX, SESSION_START_TIER, TIER_LABEL, YAGNI_PROVIDER, isSelectableTier, trailReason, } from "./tierCommand.js";
22
+ import { CHOSEN_MODEL_PREFIX, SESSION_START_TIER, TIER_LABEL, YAGNI_PROVIDER, trailReason, } from "./tierCommand.js";
23
23
  export { CHOSEN_MODEL_PREFIX };
24
24
  export function isChosenModelId(id) {
25
25
  return !!id && id.startsWith(CHOSEN_MODEL_PREFIX) && id.length > CHOSEN_MODEL_PREFIX.length;
@@ -79,7 +79,7 @@ export function parseChosenModels(raw) {
79
79
  }
80
80
  /** The picker's second line for a model: who made it, where it bills, and whether it has a backup. PURE. */
81
81
  export function chosenModelDescription(entry) {
82
- const parts = [entry.maker, `billed on the ${TIER_LABEL[entry.lane]} lane`];
82
+ const parts = [entry.maker, `billed at list price plus 7%`];
83
83
  if (!entry.hasBackup)
84
84
  parts.push("no backup provider");
85
85
  return parts.join(" · ");
@@ -121,7 +121,7 @@ export function formatChosenModelFallback(name, refusal, landed) {
121
121
  }
122
122
  /** The notice when a switch to a chosen model lands. PURE. */
123
123
  export function formatChosenModelSwitched(entry) {
124
- return `Session model is now ${entry.name} (${entry.maker}, billed on the ${TIER_LABEL[entry.lane]} lane).`;
124
+ return `Session model is now ${entry.name} (${entry.maker}, billed at list price plus 7%).`;
125
125
  }
126
126
  /**
127
127
  * Move the session to a chosen model, the model picker's path for a model
@@ -204,12 +204,4 @@ export async function chosenModelFallback(pi, ctx, errorMessage) {
204
204
  }
205
205
  return notice;
206
206
  }
207
- /** The label a person reads for the session's model: a lane's name, else the model's name. PURE. */
208
- export function sessionModelLabel(model) {
209
- if (!model)
210
- return "unknown";
211
- if (isSelectableTier(model.id))
212
- return TIER_LABEL[model.id];
213
- return model.name || model.id;
214
- }
215
207
  //# sourceMappingURL=modelChoice.js.map
@@ -30,7 +30,7 @@
30
30
  *
31
31
  * Model choice (models.customer_choice, modelChoice.ts): when the workspace
32
32
  * allows models by name, they follow the lanes in the same panel, each with
33
- * its maker, the lane it bills on, and whether it has a backup provider; the
33
+ * its maker, how it is billed, and whether it has a backup provider; the
34
34
  * lanes then read as YAGNI's pick. `/model <name>` switches to one directly.
35
35
  * With nothing listed the panel is exactly the lanes.
36
36
  */
@@ -30,7 +30,7 @@
30
30
  *
31
31
  * Model choice (models.customer_choice, modelChoice.ts): when the workspace
32
32
  * allows models by name, they follow the lanes in the same panel, each with
33
- * its maker, the lane it bills on, and whether it has a backup provider; the
33
+ * its maker, how it is billed, and whether it has a backup provider; the
34
34
  * lanes then read as YAGNI's pick. `/model <name>` switches to one directly.
35
35
  * With nothing listed the panel is exactly the lanes.
36
36
  */
@@ -38,6 +38,7 @@ export type RunStageFn = (stage: PipelineStage, ctx: {
38
38
  lens?: ReviewLens;
39
39
  grounded?: boolean;
40
40
  }, deps: RunStageDeps) => Promise<StageResult>;
41
+ export declare const IDLE_TIMEOUT_MESSAGE = "stage exceeded its idle timeout";
41
42
  /** True when at least {@link MODEL_BOUND_SHARE} of a stage's elapsed time was spent outside tools. */
42
43
  export declare function isModelBound(elapsedMs: number, toolMs: number): boolean;
43
44
  /** One telemetry record per attempt (routed through the orchestrator logger). */
@@ -46,7 +46,7 @@ const WALL_TIMEOUT_MODEL_MESSAGE = `${WALL_TIMEOUT_MESSAGE} while waiting on the
46
46
  * real wall window of many minutes.
47
47
  */
48
48
  const MODEL_BOUND_SHARE = 0.6;
49
- const IDLE_TIMEOUT_MESSAGE = "stage exceeded its idle timeout";
49
+ export const IDLE_TIMEOUT_MESSAGE = "stage exceeded its idle timeout";
50
50
  /** True when at least {@link MODEL_BOUND_SHARE} of a stage's elapsed time was spent outside tools. */
51
51
  export function isModelBound(elapsedMs, toolMs) {
52
52
  if (elapsedMs <= 0)
@@ -49,6 +49,7 @@ import { type CodeWriter } from "./codeWriter.js";
49
49
  import { type AttemptResult, type CloudIdentity, type CloudStage } from "./cloud.js";
50
50
  import type { ContinuationInputs } from "./continuation.js";
51
51
  import { type PlanChange } from "./planChanges.js";
52
+ import { type ResilienceAttemptRecord } from "./resilience.js";
52
53
  import { type RunStageDeps } from "./runner.js";
53
54
  import { type SessionTicketPath } from "./ticketPath.js";
54
55
  import type { JsonEvent, ModelTier, PipelineStage, StageId, StageResult, StopReason } from "./types.js";
@@ -222,6 +223,28 @@ export declare function childStderrTail(stderr: string): string;
222
223
  * else clean. Red tests and empty searches are errored `bash` calls and never
223
224
  * count: the gate asks whether the edits landed.
224
225
  */
226
+ /**
227
+ * How long a turn's child may write no event at all before the turn ends it
228
+ * (YAG-1295): a model call whose stream went silent mid-message (2026-11-12,
229
+ * a retried call that began a tool call and then sent nothing for 40
230
+ * minutes) is otherwise never ended from inside the session, and its
231
+ * heartbeat keeps the host's stall watch from seeing it. Every token delta
232
+ * counts as an event, and a running tool or subagent (the verification
233
+ * subagent may run for two hours) defers the window, as in the stage-graph
234
+ * lane (`resilience.ts`); the window is that lane's idle window, well above a
235
+ * thinking model's quiet stretch.
236
+ */
237
+ export declare const SESSION_SILENCE_MS: number;
238
+ /** What a turn its silence watch ended says, in its result's notes and on its stderr. */
239
+ export declare const SILENT_STREAM_NOTE: string;
240
+ /**
241
+ * The silence watch's record, in the extension's log: one content-free line
242
+ * for each model call it ended (its stage, how long it ran, whether the model
243
+ * or a tool held the time), so how often turns die this way can be counted.
244
+ * A call that ended on its own writes nothing: one per turn would be noise.
245
+ * Only the idle timer is silence: the 24 hour wall is not, and writes nothing.
246
+ */
247
+ export declare function sessionSilenceTelemetry(sessionId: string | undefined): (rec: ResilienceAttemptRecord) => void;
225
248
  export declare function turnStop(run: StageResult, writes: boolean, aborted: boolean): {
226
249
  stop: StopReason;
227
250
  note?: string;
@@ -272,6 +295,10 @@ export interface SessionTurnDeps {
272
295
  rss: number;
273
296
  heapUsed: number;
274
297
  };
298
+ /** The silence watch's window ({@link SESSION_SILENCE_MS}); a test sets a short one. */
299
+ silenceMs?: number;
300
+ /** Where the silence watch's records go ({@link sessionSilenceTelemetry}); a test reads them. */
301
+ telemetry?: (rec: ResilienceAttemptRecord) => void;
275
302
  /** A yak's placed values (YAG-1209); absent, read from the machine, null on any other. */
276
303
  placedValues?: PlacedValues | null;
277
304
  }
@@ -310,7 +337,16 @@ export interface TurnPulse {
310
337
  lastTool: string | null;
311
338
  /** When the child last wrote an event; null before its first. */
312
339
  lastEventAt: number | null;
340
+ /**
341
+ * Tool calls started and not yet ended, by their call id: a subagent is
342
+ * one, however long it runs, and an end said twice ends only its own call.
343
+ */
344
+ toolsRunning: Set<string>;
345
+ /** Tool calls started without a call id and not yet ended: counted, never matched. */
346
+ unnamedToolsRunning: number;
313
347
  }
348
+ /** How many tool calls the turn's model has running. */
349
+ export declare function toolsInFlight(pulse: TurnPulse): number;
314
350
  /** One child event folded into the pulse: its spend, its tool, its time. */
315
351
  export declare function notePulse(pulse: TurnPulse, event: JsonEvent, at: number): void;
316
352
  /** The heartbeat line a turn writes on the stream. */
@@ -48,6 +48,7 @@ import { createHash } from "node:crypto";
48
48
  import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
49
49
  import { homedir } from "node:os";
50
50
  import { isAbsolute, join, relative } from "node:path";
51
+ import { logEvent } from "../errorSink.js";
51
52
  import { openPlacedValues } from "../placedValues.js";
52
53
  import { scanChange } from "./changeScan.js";
53
54
  import { CODE_WRITER_ENV, ignoredCodeWriter, resolveCodeWriter, } from "./codeWriter.js";
@@ -62,12 +63,14 @@ import { healPlacedSecrets, publicationBase } from "./placedValueHeal.js";
62
63
  import { extractPlanJson } from "./planOutput.js";
63
64
  import { checkPlanPaths, selfReviewPlan, selfReviewSection } from "./planReview.js";
64
65
  import { PLAN_CHANGES_RULE, parsePlanChanges, planChangeNote, } from "./planChanges.js";
66
+ import { IDLE_TIMEOUT_MESSAGE, withResilience, } from "./resilience.js";
65
67
  import { runStage as defaultRunStage } from "./runner.js";
66
68
  import { scrubSecrets } from "./scrubSecrets.js";
67
69
  import { DECISIONS_READ_TOOL, PLAN_JSON_CONTRACT, YAK_PLAN_JSON_CONTRACT } from "./stages.js";
68
70
  import { planReviewRoundsFor, planSizeOf, sessionTicketPathOf, TICKET_PATH_FILE_NAME, } from "./ticketPath.js";
69
71
  import { STAGE_WRAP_UP_GRACE_MS } from "./stageClock.js";
70
72
  import { editsMostlyFailed } from "./events.js";
73
+ import { DEFAULT_RESILIENCE_POLICY } from "./types.js";
71
74
  import { baselineDirs, parseChangedPaths, planPaths } from "./verify.js";
72
75
  import { snapshotWorkspace } from "./workspace.js";
73
76
  /** The one tier the session's writer runs on; its subagents keep their own. */
@@ -573,8 +576,67 @@ export function childStderrTail(stderr) {
573
576
  * else clean. Red tests and empty searches are errored `bash` calls and never
574
577
  * count: the gate asks whether the edits landed.
575
578
  */
579
+ /**
580
+ * How long a turn's child may write no event at all before the turn ends it
581
+ * (YAG-1295): a model call whose stream went silent mid-message (2026-11-12,
582
+ * a retried call that began a tool call and then sent nothing for 40
583
+ * minutes) is otherwise never ended from inside the session, and its
584
+ * heartbeat keeps the host's stall watch from seeing it. Every token delta
585
+ * counts as an event, and a running tool or subagent (the verification
586
+ * subagent may run for two hours) defers the window, as in the stage-graph
587
+ * lane (`resilience.ts`); the window is that lane's idle window, well above a
588
+ * thinking model's quiet stretch.
589
+ */
590
+ export const SESSION_SILENCE_MS = DEFAULT_RESILIENCE_POLICY.idleTimeoutMs;
591
+ /** What a turn its silence watch ended says, in its result's notes and on its stderr. */
592
+ export const SILENT_STREAM_NOTE = `The session's model call sent nothing for ${Math.round(SESSION_SILENCE_MS / 60_000)} minutes, so the turn ended it; the next turn resumes the same conversation.`;
593
+ /**
594
+ * The silence watch over one child: only the idle window. One attempt, so a
595
+ * silent call is never sent again here (the host resumes the conversation),
596
+ * and a wall far past any session window, since the turn's own clock is its
597
+ * stage's `timeBudgetMs`.
598
+ */
599
+ function silenceWatch(base, silenceMs, telemetry) {
600
+ return withResilience(base, {
601
+ ...DEFAULT_RESILIENCE_POLICY,
602
+ idleTimeoutMs: silenceMs,
603
+ wallTimeoutMs: 24 * 60 * 60_000,
604
+ maxAttempts: 1,
605
+ }, { telemetry });
606
+ }
607
+ /**
608
+ * The silence watch's record, in the extension's log: one content-free line
609
+ * for each model call it ended (its stage, how long it ran, whether the model
610
+ * or a tool held the time), so how often turns die this way can be counted.
611
+ * A call that ended on its own writes nothing: one per turn would be noise.
612
+ * Only the idle timer is silence: the 24 hour wall is not, and writes nothing.
613
+ */
614
+ export function sessionSilenceTelemetry(sessionId) {
615
+ return (rec) => {
616
+ if (rec.outcome !== "timeout" || rec.timeoutKind !== "idle")
617
+ return;
618
+ logEvent({
619
+ source: "session_lane",
620
+ level: "error",
621
+ event: "model_call_silent",
622
+ sessionId,
623
+ fields: {
624
+ stage: rec.stageId,
625
+ elapsedMs: rec.elapsedMs,
626
+ ...(rec.toolMs !== undefined ? { toolMs: rec.toolMs } : {}),
627
+ ...(rec.modelBound !== undefined ? { modelBound: rec.modelBound } : {}),
628
+ },
629
+ });
630
+ };
631
+ }
576
632
  export function turnStop(run, writes, aborted) {
577
- if (aborted || run.stopReason === "aborted")
633
+ if (aborted)
634
+ return { stop: "aborted" };
635
+ // Ended by its own silence watch (YAG-1295), which aborts the child: never a person's abort.
636
+ if (run.errorMessage === IDLE_TIMEOUT_MESSAGE) {
637
+ return { stop: "failed", note: SILENT_STREAM_NOTE };
638
+ }
639
+ if (run.stopReason === "aborted")
578
640
  return { stop: "aborted" };
579
641
  if (run.timedOut) {
580
642
  return { stop: "budget_exceeded", note: "The turn ran out of the run's time and was stopped." };
@@ -628,11 +690,27 @@ const EXECUTION_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{
628
690
  export function sessionInboxDir(inputDir, executionId) {
629
691
  return EXECUTION_ID.test(executionId) ? join(inputDir, "inbox", executionId) : null;
630
692
  }
693
+ /** How many tool calls the turn's model has running. */
694
+ export function toolsInFlight(pulse) {
695
+ return pulse.toolsRunning.size + pulse.unnamedToolsRunning;
696
+ }
631
697
  /** One child event folded into the pulse: its spend, its tool, its time. */
632
698
  export function notePulse(pulse, event, at) {
633
699
  pulse.lastEventAt = at;
634
- if (event.type === "tool_execution_start" && event.toolName)
635
- pulse.lastTool = event.toolName;
700
+ if (event.type === "tool_execution_start") {
701
+ if (event.toolCallId)
702
+ pulse.toolsRunning.add(event.toolCallId);
703
+ else
704
+ pulse.unnamedToolsRunning += 1;
705
+ if (event.toolName)
706
+ pulse.lastTool = event.toolName;
707
+ }
708
+ if (event.type === "tool_execution_end") {
709
+ if (event.toolCallId)
710
+ pulse.toolsRunning.delete(event.toolCallId);
711
+ else
712
+ pulse.unnamedToolsRunning = Math.max(0, pulse.unnamedToolsRunning - 1);
713
+ }
636
714
  const usage = event.type === "message_end" ? event.message?.usage : undefined;
637
715
  if (usage && event.message?.role === "assistant") {
638
716
  pulse.tokens +=
@@ -649,6 +727,7 @@ export function heartbeatLine(pulse, stage, at, memory) {
649
727
  rssBytes: memory?.rss ?? null,
650
728
  heapUsedBytes: memory?.heapUsed ?? null,
651
729
  sinceEventMs: pulse.lastEventAt === null ? null : Math.max(0, at - pulse.lastEventAt),
730
+ toolsInFlight: toolsInFlight(pulse),
652
731
  yagni: { stage },
653
732
  };
654
733
  }
@@ -675,7 +754,13 @@ export async function runSessionTurn(input, deps = {}) {
675
754
  const now = deps.now ?? Date.now;
676
755
  const memory = deps.memory ?? processMemory;
677
756
  const stage = feedStage(input.stage);
678
- const pulse = { tokens: 0, lastTool: null, lastEventAt: null };
757
+ const pulse = {
758
+ tokens: 0,
759
+ lastTool: null,
760
+ lastEventAt: null,
761
+ toolsRunning: new Set(),
762
+ unnamedToolsRunning: 0,
763
+ };
679
764
  const beat = (deps.every ?? everyUnref)(() => {
680
765
  try {
681
766
  input.emit(heartbeatLine(pulse, stage, now(), memory()));
@@ -699,7 +784,7 @@ async function runTurn(input, deps, pulse) {
699
784
  const remove = deps.remove ?? ((path) => rmSync(path, { force: true }));
700
785
  const exec = deps.exec ?? finishExec;
701
786
  const snapshot = deps.snapshot ?? snapshotWorkspace;
702
- const runStage = deps.runStage ?? defaultRunStage;
787
+ const runStage = silenceWatch(deps.runStage ?? defaultRunStage, deps.silenceMs ?? SESSION_SILENCE_MS, deps.telemetry ?? sessionSilenceTelemetry(input.childEnv.YAGNI_SESSION_ID?.trim()));
703
788
  const now = deps.now ?? Date.now;
704
789
  const readOrNull = (path) => {
705
790
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yagni-app/code-staging",
3
- "version": "1.2.14-staging.2421.1",
3
+ "version": "1.2.14-staging.2437.1",
4
4
  "description": "YAGNI Code: a terminal coding agent that already knows your company. One YAGNI login routes the model and grounds the agent in your team's context.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "author": "YAGNI, Inc. <jack@yagni.app> (https://yagni.app)",
@@ -58,5 +58,5 @@
58
58
  "turndown": "^7.2.4",
59
59
  "typebox": "^1.3.15"
60
60
  },
61
- "yagniSourceSha": "22aa037b2ba9574c14b2d99ce5a46ae05ccbbe71"
61
+ "yagniSourceSha": "56cd10e6fb5c708aa93cac153eb4fc840c8a2086"
62
62
  }