agent-relay-runner 0.86.0 → 0.88.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-relay-runner",
3
- "version": "0.86.0",
3
+ "version": "0.88.0",
4
4
  "description": "Unified provider lifecycle runner for Agent Relay",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agent-relay-runner",
3
3
  "description": "Thin Agent Relay runner bridge for Claude Code",
4
- "version": "0.86.0",
4
+ "version": "0.88.0",
5
5
  "agentRelayContracts": {
6
6
  "providerPluginProtocol": 1
7
7
  }
@@ -28,6 +28,7 @@ import { publishCapturedResponse } from "./response-capture-report";
28
28
  import { runnerLaunchInjectionSessionEvents, type RunnerRelayInjectionEvent } from "./relay-injection-events";
29
29
  import { providerTerminalSession, providerTerminalSocket } from "./process-meta";
30
30
  import { capsFromEnv, logLevelFromEnv, mcpProxyEnabledFromEnv, orchestratorBaseDirFromEnv, orchestratorUrlFromEnv, registrationTimeoutMsFromEnv, runnerInfoFileFromEnv, runnerLogFileFromEnv, runnerOutboxDirWithInfoFallback, sessionDebugEnabled, tagsFromEnv, workspaceModeFromEnv } from "./config";
31
+ import { boundaryReasonForCommand, PRE_DESTROY_TIMEOUT_MS, reasonExitsRunner, type LifecycleAction, type SessionDestroyReason } from "./session-destroy";
31
32
  import {
32
33
  appliedAgentProfileMetadata,
33
34
  commandTimeoutMs,
@@ -55,48 +56,13 @@ import {
55
56
  type ProbeModelInfo,
56
57
  } from "./runner-helpers";
57
58
 
58
- // A destructive session transition. The runner runs end-of-session work (Insights
59
- // capture, #183/#184) before the invasive operation and, during that window, presents a
60
- // distinct non-addressable lifecycle state. Bus commands and provider hooks (Claude
61
- // PreCompact / SessionEnd) both normalize to one of these.
62
- type SessionDestroyReason = "compact" | "clear" | "restart" | "shutdown" | "kill" | "crash";
63
-
64
- // Reasons after which the runner process won't survive to drain the durable outbox (and the
65
- // per-agent outbox is never reopened once the agent is gone). For these, pre-destroy must
66
- // block on delivery of the just-captured Insights datapoint, not just enqueue it (#183).
67
- // `restart` (bus command) deliberately excluded: the runner stays alive and drains normally.
68
- function reasonExitsRunner(reason: SessionDestroyReason): boolean {
69
- return reason === "shutdown" || reason === "kill" || reason === "crash";
70
- }
71
-
72
- // `finalizing-<reason>` is the transient pre-destroy window; the others are the executing
73
- // teardown states the dashboard already renders.
74
- type LifecycleAction =
75
- | "shutting-down" | "killing" | "restarting"
76
- | `finalizing-${SessionDestroyReason}`;
77
-
78
59
  // Pre-destroy work is best-effort and must never hang teardown. Capping it keeps a slow
79
60
  // transcript read or a wedged provider from stalling a shutdown the operator asked for.
80
- const PRE_DESTROY_TIMEOUT_MS = 4_000;
81
-
82
61
  // Bounded window to deliver the durable outbox before an exit-bound teardown (#183). Kept
83
62
  // short so a wedged/down server can't stall an operator-requested shutdown for long; a
84
63
  // row that still can't land is logged, not silently dropped.
85
64
  const OUTBOX_FLUSH_TIMEOUT_MS = 3_000;
86
65
 
87
- // Map a lifecycle bus command to its destructive boundary reason, or undefined for
88
- // non-destructive commands (interrupt, inject, reconnect, permission decisions).
89
- function boundaryReasonForCommand(type: string): SessionDestroyReason | undefined {
90
- switch (type) {
91
- case "agent.compact": return "compact";
92
- case "agent.clearContext": return "clear";
93
- case "agent.restart": return "restart";
94
- case "agent.shutdown": return "shutdown";
95
- case "agent.kill": return "kill";
96
- default: return undefined;
97
- }
98
- }
99
-
100
66
  interface RunnerOptions {
101
67
  provider: string;
102
68
  model?: string;
@@ -258,6 +224,7 @@ export class AgentRunner {
258
224
  private readonly pendingMessages = new Map<number, Message>();
259
225
  private readonly activeTaskClaims = new Map<number, ActiveTaskClaim>();
260
226
  private pendingTimelineEvent?: RunnerTimelineEvent;
227
+ private lastProviderEventAt?: number;
261
228
  private pendingPromptMessageId?: number;
262
229
  // #329: a spawn-time initial prompt whose first delivery timed out before the TUI was
263
230
  // ready. Held (not dropped) for a ready-signal-driven re-attempt; cleared on success.
@@ -1167,6 +1134,7 @@ export class AgentRunner {
1167
1134
 
1168
1135
  private setProviderStatus(update: ProviderStatusUpdate): void {
1169
1136
  const status = typeof update === "string" ? update : update.status;
1137
+ this.lastProviderEventAt = Date.now();
1170
1138
  const providerSessionId = typeof update === "string" ? undefined : update.providerSessionId;
1171
1139
  if (providerSessionId && providerSessionId !== this.providerSessionId) return;
1172
1140
  const reason = typeof update === "string" ? "provider-turn" : update.reason ?? "provider-turn";
@@ -1856,6 +1824,7 @@ export class AgentRunner {
1856
1824
  activeWork,
1857
1825
  activeSubagents,
1858
1826
  activeSubagentCount: activeSubagents.length,
1827
+ ...(this.lastProviderEventAt !== undefined ? { lastProviderEventAt: this.lastProviderEventAt } : {}),
1859
1828
  providerState,
1860
1829
  auth: {
1861
1830
  profileId: this.currentTokenProfileId ?? null,
@@ -1,12 +1,11 @@
1
1
  import type { WorkspaceMetadata } from "agent-relay-sdk";
2
2
  import type { ManagedProcess, ProviderAdapter } from "./adapter";
3
3
  import type { Outbox } from "./outbox";
4
+ import type { SessionDestroyReason } from "./session-destroy";
4
5
  import { resolveProjectName } from "./config";
5
6
  import { computeContextRatio } from "./session-insights";
6
7
  import { boundContinuationArchiveSegment } from "./continuation-archive";
7
8
 
8
- type SessionDestroyReason = "compact" | "clear" | "restart" | "shutdown" | "kill" | "crash";
9
-
10
9
  interface RunnerInsightsDeps {
11
10
  agentId: string;
12
11
  cwd: string;
@@ -0,0 +1,22 @@
1
+ export type SessionDestroyReason = "compact" | "clear" | "restart" | "shutdown" | "kill" | "crash";
2
+
3
+ export type LifecycleAction =
4
+ | "shutting-down" | "killing" | "restarting"
5
+ | `finalizing-${SessionDestroyReason}`;
6
+
7
+ export const PRE_DESTROY_TIMEOUT_MS = 4_000;
8
+
9
+ export function reasonExitsRunner(reason: SessionDestroyReason): boolean {
10
+ return reason === "shutdown" || reason === "kill" || reason === "crash";
11
+ }
12
+
13
+ export function boundaryReasonForCommand(type: string): SessionDestroyReason | undefined {
14
+ switch (type) {
15
+ case "agent.compact": return "compact";
16
+ case "agent.clearContext": return "clear";
17
+ case "agent.restart": return "restart";
18
+ case "agent.shutdown": return "shutdown";
19
+ case "agent.kill": return "kill";
20
+ default: return undefined;
21
+ }
22
+ }