@exaudeus/workrail 3.79.2 → 3.80.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.
@@ -3,14 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ActiveSessionSet = void 0;
4
4
  class SessionHandleImpl {
5
5
  constructor(sessionId, onSteer, set) {
6
+ this._workrailSessionId = null;
6
7
  this._agent = null;
7
8
  this.sessionId = sessionId;
8
9
  this._onSteer = onSteer;
9
10
  this._set = set;
10
11
  }
12
+ get workrailSessionId() {
13
+ return this._workrailSessionId;
14
+ }
11
15
  steer(text) {
12
16
  this._onSteer(text);
13
17
  }
18
+ setWorkrailSessionId(workrailSessionId) {
19
+ if (this._workrailSessionId === null) {
20
+ this._workrailSessionId = workrailSessionId;
21
+ }
22
+ }
14
23
  setAgent(agent) {
15
24
  if (this._agent === null) {
16
25
  this._agent = agent;
@@ -37,8 +46,8 @@ class ActiveSessionSet {
37
46
  get(sessionId) {
38
47
  return this._handles.get(sessionId);
39
48
  }
40
- sessionIds() {
41
- return this._handles.keys();
49
+ handles() {
50
+ return this._handles.values();
42
51
  }
43
52
  abortAll() {
44
53
  for (const handle of this._handles.values()) {
@@ -1,4 +1,4 @@
1
- import type { WorkflowTrigger, WorkflowRunResult } from '../types.js';
1
+ import type { WorkflowTrigger, WorkflowRunResult, RunId } from '../types.js';
2
2
  import type { SessionState } from '../state/session-state.js';
3
3
  export declare function tagToStatsOutcome(tag: WorkflowRunResult['_tag']): 'success' | 'error' | 'timeout' | 'stuck';
4
4
  export type SidecarLifecycle = {
@@ -7,4 +7,4 @@ export type SidecarLifecycle = {
7
7
  readonly kind: 'retain_for_delivery';
8
8
  };
9
9
  export declare function sidecardLifecycleFor(tag: WorkflowRunResult['_tag'], branchStrategy: WorkflowTrigger['branchStrategy']): SidecarLifecycle;
10
- export declare function buildSessionResult(state: Readonly<SessionState>, stopReason: string, errorMessage: string | undefined, trigger: WorkflowTrigger, sessionId: string, sessionWorktreePath: string | undefined): WorkflowRunResult;
10
+ export declare function buildSessionResult(state: Readonly<SessionState>, stopReason: string, errorMessage: string | undefined, trigger: WorkflowTrigger, sessionId: RunId, sessionWorktreePath: string | undefined): WorkflowRunResult;
@@ -1,3 +1,7 @@
1
+ export type RunId = string & {
2
+ readonly _brand: 'RunId';
3
+ };
4
+ export declare function asRunId(value: string): RunId;
1
5
  export interface DaemonStartedEvent {
2
6
  readonly kind: 'daemon_started';
3
7
  readonly port: number;
@@ -15,33 +19,33 @@ export interface SessionQueuedEvent {
15
19
  }
16
20
  export interface SessionStartedEvent {
17
21
  readonly kind: 'session_started';
18
- readonly sessionId: string;
22
+ readonly sessionId: RunId;
19
23
  readonly workflowId: string;
20
24
  readonly workspacePath: string;
21
25
  readonly workrailSessionId?: string;
22
26
  }
23
27
  export interface ToolCalledEvent {
24
28
  readonly kind: 'tool_called';
25
- readonly sessionId: string;
29
+ readonly sessionId: RunId;
26
30
  readonly toolName: string;
27
31
  readonly summary?: string;
28
32
  readonly workrailSessionId?: string;
29
33
  }
30
34
  export interface ToolErrorEvent {
31
35
  readonly kind: 'tool_error';
32
- readonly sessionId: string;
36
+ readonly sessionId: RunId;
33
37
  readonly toolName: string;
34
38
  readonly error: string;
35
39
  readonly workrailSessionId?: string;
36
40
  }
37
41
  export interface StepAdvancedEvent {
38
42
  readonly kind: 'step_advanced';
39
- readonly sessionId: string;
43
+ readonly sessionId: RunId;
40
44
  readonly workrailSessionId?: string;
41
45
  }
42
46
  export interface SessionCompletedEvent {
43
47
  readonly kind: 'session_completed';
44
- readonly sessionId: string;
48
+ readonly sessionId: RunId;
45
49
  readonly workflowId: string;
46
50
  readonly outcome: 'success' | 'error' | 'timeout' | 'stuck';
47
51
  readonly detail?: string;
@@ -55,7 +59,7 @@ export interface DeliveryAttemptedEvent {
55
59
  }
56
60
  export interface IssueReportedEvent {
57
61
  readonly kind: 'issue_reported';
58
- readonly sessionId: string;
62
+ readonly sessionId: RunId;
59
63
  readonly issueKind: 'tool_failure' | 'blocked' | 'unexpected_behavior' | 'needs_human' | 'self_correction';
60
64
  readonly severity: 'info' | 'warn' | 'error' | 'fatal';
61
65
  readonly summary: string;
@@ -64,14 +68,14 @@ export interface IssueReportedEvent {
64
68
  }
65
69
  export interface LlmTurnStartedEvent {
66
70
  readonly kind: 'llm_turn_started';
67
- readonly sessionId: string;
71
+ readonly sessionId: RunId;
68
72
  readonly messageCount: number;
69
73
  readonly modelId?: string;
70
74
  readonly workrailSessionId?: string;
71
75
  }
72
76
  export interface LlmTurnCompletedEvent {
73
77
  readonly kind: 'llm_turn_completed';
74
- readonly sessionId: string;
78
+ readonly sessionId: RunId;
75
79
  readonly stopReason: string;
76
80
  readonly outputTokens: number;
77
81
  readonly inputTokens: number;
@@ -80,14 +84,14 @@ export interface LlmTurnCompletedEvent {
80
84
  }
81
85
  export interface ToolCallStartedEvent {
82
86
  readonly kind: 'tool_call_started';
83
- readonly sessionId: string;
87
+ readonly sessionId: RunId;
84
88
  readonly toolName: string;
85
89
  readonly argsSummary: string;
86
90
  readonly workrailSessionId?: string;
87
91
  }
88
92
  export interface ToolCallCompletedEvent {
89
93
  readonly kind: 'tool_call_completed';
90
- readonly sessionId: string;
94
+ readonly sessionId: RunId;
91
95
  readonly toolName: string;
92
96
  readonly durationMs: number;
93
97
  readonly resultSummary: string;
@@ -95,7 +99,7 @@ export interface ToolCallCompletedEvent {
95
99
  }
96
100
  export interface ToolCallFailedEvent {
97
101
  readonly kind: 'tool_call_failed';
98
- readonly sessionId: string;
102
+ readonly sessionId: RunId;
99
103
  readonly toolName: string;
100
104
  readonly durationMs: number;
101
105
  readonly errorMessage: string;
@@ -128,7 +132,7 @@ export interface SessionDroppedEvent {
128
132
  }
129
133
  export interface SignalEmittedEvent {
130
134
  readonly kind: 'signal_emitted';
131
- readonly sessionId: string;
135
+ readonly sessionId: RunId;
132
136
  readonly signalKind: string;
133
137
  readonly signalId: string;
134
138
  readonly payload: Readonly<Record<string, unknown>>;
@@ -136,7 +140,7 @@ export interface SignalEmittedEvent {
136
140
  }
137
141
  export interface AgentStuckEvent {
138
142
  readonly kind: 'agent_stuck';
139
- readonly sessionId: string;
143
+ readonly sessionId: RunId;
140
144
  readonly reason: 'repeated_tool_call' | 'no_progress' | 'timeout_imminent' | 'stall';
141
145
  readonly detail: string;
142
146
  readonly toolName?: string;
@@ -34,9 +34,13 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.DaemonEventEmitter = void 0;
37
+ exports.asRunId = asRunId;
37
38
  const fs = __importStar(require("node:fs/promises"));
38
39
  const path = __importStar(require("node:path"));
39
40
  const os = __importStar(require("node:os"));
41
+ function asRunId(value) {
42
+ return value;
43
+ }
40
44
  class DaemonEventEmitter {
41
45
  constructor(dirOverride) {
42
46
  this._tail = Promise.resolve();
@@ -1,7 +1,7 @@
1
1
  import type { AgentLoop, AgentEvent, AgentLoopCallbacks } from '../agent-loop.js';
2
2
  import type { V2ToolContext } from '../../mcp/types.js';
3
3
  import type { DaemonRegistry } from '../../v2/infra/in-memory/daemon-registry/index.js';
4
- import type { DaemonEventEmitter } from '../daemon-events.js';
4
+ import type { DaemonEventEmitter, RunId } from '../daemon-events.js';
5
5
  import type { SessionState } from '../state/session-state.js';
6
6
  import type { StuckConfig } from '../state/stuck-detection.js';
7
7
  import { ActiveSessionSet } from '../active-sessions.js';
@@ -13,7 +13,7 @@ export interface TurnEndSubscriberContext {
13
13
  readonly agent: AgentLoop;
14
14
  readonly state: SessionState;
15
15
  readonly stuckConfig: StuckConfig;
16
- readonly sessionId: string;
16
+ readonly sessionId: RunId;
17
17
  readonly workflowId: string;
18
18
  readonly emitter: DaemonEventEmitter | undefined;
19
19
  readonly conversationPath: string;
@@ -23,6 +23,6 @@ export interface TurnEndSubscriberContext {
23
23
  readonly stuckRepeatThreshold: number;
24
24
  }
25
25
  export declare function buildTurnEndSubscriber(ctx: TurnEndSubscriberContext): (event: AgentEvent) => Promise<void>;
26
- export declare function buildAgentCallbacks(sessionId: string, state: SessionState, modelId: string, emitter: DaemonEventEmitter | undefined, stuckRepeatThreshold: number, workflowId?: string): AgentLoopCallbacks;
27
- export declare function buildAgentReadySession(preAgentSession: PreAgentSession, trigger: WorkflowTrigger, ctx: V2ToolContext, apiKey: string, sessionId: string, emitter: DaemonEventEmitter | undefined, daemonRegistry: DaemonRegistry | undefined, activeSessionSet: ActiveSessionSet | undefined, runWorkflowFn: typeof runWorkflow, enricherResult?: EnricherResult): Promise<AgentReadySession>;
26
+ export declare function buildAgentCallbacks(sessionId: RunId, state: SessionState, modelId: string, emitter: DaemonEventEmitter | undefined, stuckRepeatThreshold: number, workflowId?: string): AgentLoopCallbacks;
27
+ export declare function buildAgentReadySession(preAgentSession: PreAgentSession, trigger: WorkflowTrigger, ctx: V2ToolContext, apiKey: string, sessionId: RunId, emitter: DaemonEventEmitter | undefined, daemonRegistry: DaemonRegistry | undefined, activeSessionSet: ActiveSessionSet | undefined, runWorkflowFn: typeof runWorkflow, enricherResult?: EnricherResult): Promise<AgentReadySession>;
28
28
  export declare function runAgentLoop(session: AgentReadySession, trigger: WorkflowTrigger, conversationPath: string): Promise<SessionOutcome>;
@@ -1,7 +1,7 @@
1
1
  import type { V2ToolContext } from '../../mcp/types.js';
2
2
  import type { DaemonRegistry } from '../../v2/infra/in-memory/daemon-registry/index.js';
3
- import type { DaemonEventEmitter } from '../daemon-events.js';
3
+ import type { DaemonEventEmitter, RunId } from '../daemon-events.js';
4
4
  import { ActiveSessionSet } from '../active-sessions.js';
5
5
  import type { WorkflowTrigger, SessionSource } from '../types.js';
6
6
  import type { PreAgentSessionResult } from './runner-types.js';
7
- export declare function buildPreAgentSession(trigger: WorkflowTrigger, ctx: V2ToolContext, apiKey: string, sessionId: string, startMs: number, statsDir: string, sessionsDir: string, emitter: DaemonEventEmitter | undefined, daemonRegistry: DaemonRegistry | undefined, activeSessionSet: ActiveSessionSet | undefined, source?: SessionSource): Promise<PreAgentSessionResult>;
7
+ export declare function buildPreAgentSession(trigger: WorkflowTrigger, ctx: V2ToolContext, apiKey: string, sessionId: RunId, startMs: number, statsDir: string, sessionsDir: string, emitter: DaemonEventEmitter | undefined, daemonRegistry: DaemonRegistry | undefined, activeSessionSet: ActiveSessionSet | undefined, source?: SessionSource): Promise<PreAgentSessionResult>;
@@ -185,9 +185,10 @@ async function buildPreAgentSession(trigger, ctx, apiKey, sessionId, startMs, st
185
185
  }
186
186
  }
187
187
  let handle;
188
+ handle = activeSessionSet?.register(sessionId, (text) => { state.pendingSteerParts.push(text); });
188
189
  if (state.workrailSessionId !== null) {
189
190
  daemonRegistry?.register(state.workrailSessionId, trigger.workflowId);
190
- handle = activeSessionSet?.register(state.workrailSessionId, (text) => { state.pendingSteerParts.push(text); });
191
+ handle?.setWorkrailSessionId(state.workrailSessionId);
191
192
  }
192
193
  if (isComplete) {
193
194
  return {
@@ -4,7 +4,7 @@ import type { SessionContext } from '../core/session-context.js';
4
4
  import type { ContextBundle } from '../context-loader.js';
5
5
  import type { SessionScope } from '../session-scope.js';
6
6
  import type { SessionHandle } from '../active-sessions.js';
7
- import type { DaemonEventEmitter } from '../daemon-events.js';
7
+ import type { DaemonEventEmitter, RunId } from '../daemon-events.js';
8
8
  import type { DaemonRegistry } from '../../v2/infra/in-memory/daemon-registry/index.js';
9
9
  import type { WorkflowRunResult } from '../types.js';
10
10
  import type { ReadFileState } from '../types.js';
@@ -12,7 +12,7 @@ import Anthropic from '@anthropic-ai/sdk';
12
12
  import { AnthropicBedrock } from '@anthropic-ai/bedrock-sdk';
13
13
  export declare const WORKTREES_DIR: string;
14
14
  export interface PreAgentSession {
15
- readonly sessionId: string;
15
+ readonly sessionId: RunId;
16
16
  readonly workrailSessionId: string | null;
17
17
  readonly continueToken: string;
18
18
  readonly checkpointToken: string | null;
@@ -44,7 +44,7 @@ export interface AgentReadySession {
44
44
  readonly tools: readonly AgentTool[];
45
45
  readonly sessionCtx: SessionContext;
46
46
  readonly handle: SessionHandle | undefined;
47
- readonly sessionId: string;
47
+ readonly sessionId: RunId;
48
48
  readonly workflowId: string;
49
49
  readonly worktreePath: string | undefined;
50
50
  readonly agent: AgentLoop;
@@ -59,7 +59,7 @@ export type SessionOutcome = {
59
59
  readonly errorMessage?: string;
60
60
  };
61
61
  export interface FinalizationContext {
62
- readonly sessionId: string;
62
+ readonly sessionId: RunId;
63
63
  readonly workrailSessionId: string | null;
64
64
  readonly startMs: number;
65
65
  readonly stepAdvanceCount: number;
@@ -1,6 +1,6 @@
1
1
  import type { ReadFileState } from './types.js';
2
2
  import type { ActiveSessionSet } from './active-sessions.js';
3
- import type { DaemonEventEmitter } from './daemon-events.js';
3
+ import type { DaemonEventEmitter, RunId } from './daemon-events.js';
4
4
  export interface FileStateTracker {
5
5
  recordRead(filePath: string, content: string, timestamp: number, isPartialView: boolean): void;
6
6
  getReadState(filePath: string): ReadFileState | undefined;
@@ -28,7 +28,7 @@ export interface SessionScope {
28
28
  readonly spawnMaxDepth: number;
29
29
  readonly workrailSessionId: string | null;
30
30
  readonly emitter: DaemonEventEmitter | undefined;
31
- readonly sessionId: string;
31
+ readonly sessionId: RunId;
32
32
  readonly workflowId: string;
33
33
  readonly activeSessionSet: ActiveSessionSet | undefined;
34
34
  }
@@ -50,6 +50,7 @@ const assert_never_js_1 = require("../runtime/assert-never.js");
50
50
  const session_recovery_policy_js_1 = require("./session-recovery-policy.js");
51
51
  const _shared_js_1 = require("./tools/_shared.js");
52
52
  const workflow_runner_js_1 = require("./workflow-runner.js");
53
+ const daemon_events_js_1 = require("./daemon-events.js");
53
54
  const execFileAsync = (0, node_util_1.promisify)(node_child_process_1.execFile);
54
55
  const MAX_ORPHAN_AGE_MS = 2 * 60 * 60 * 1000;
55
56
  const MAX_WORKTREE_ORPHAN_AGE_MS = 24 * 60 * 60 * 1000;
@@ -80,7 +81,7 @@ async function readAllDaemonSessions(sessionsDir = _shared_js_1.DAEMON_SESSIONS_
80
81
  for (const entry of entries) {
81
82
  if (!entry.endsWith('.json') || entry.startsWith('queue-issue-'))
82
83
  continue;
83
- const sessionId = entry.slice(0, -5);
84
+ const sessionId = (0, daemon_events_js_1.asRunId)(entry.slice(0, -5));
84
85
  const filePath = path.join(sessionsDir, entry);
85
86
  try {
86
87
  const raw = await fs.readFile(filePath, 'utf8');
@@ -1,3 +1,3 @@
1
1
  import type { AgentTool } from '../agent-loop.js';
2
- import type { DaemonEventEmitter } from '../daemon-events.js';
3
- export declare function makeBashTool(workspacePath: string, schemas: Record<string, any>, sessionId?: string, emitter?: DaemonEventEmitter, workrailSessionId?: string | null): AgentTool;
2
+ import type { DaemonEventEmitter, RunId } from '../daemon-events.js';
3
+ export declare function makeBashTool(workspacePath: string, schemas: Record<string, any>, sessionId?: RunId, emitter?: DaemonEventEmitter, workrailSessionId?: string | null): AgentTool;
@@ -35,7 +35,7 @@ function makeBashTool(workspacePath, schemas, sessionId, emitter, workrailSessio
35
35
  };
36
36
  }
37
37
  catch (err) {
38
- if (err.code === 'ABORT_ERR')
38
+ if (err instanceof Error && err.name === 'AbortError')
39
39
  throw err;
40
40
  const e = err;
41
41
  const stdout = String(e.stdout ?? '');
@@ -1,6 +1,6 @@
1
1
  import type { AgentTool } from '../agent-loop.js';
2
2
  import type { V2ToolContext } from '../../mcp/types.js';
3
- import type { DaemonEventEmitter } from '../daemon-events.js';
3
+ import type { DaemonEventEmitter, RunId } from '../daemon-events.js';
4
4
  import { executeContinueWorkflow } from '../../mcp/handlers/v2-execution/index.js';
5
- export declare function makeContinueWorkflowTool(sessionId: string, ctx: V2ToolContext, onAdvance: (nextStepText: string, continueToken: string) => void, onComplete: (notes: string | undefined, artifacts?: readonly unknown[]) => void, schemas: Record<string, any>, _executeContinueWorkflowFn?: typeof executeContinueWorkflow, emitter?: DaemonEventEmitter, workrailSessionId?: string | null): AgentTool;
6
- export declare function makeCompleteStepTool(sessionId: string, ctx: V2ToolContext, getCurrentToken: () => string, onAdvance: (nextStepText: string, continueToken: string) => void, onComplete: (notes: string | undefined, artifacts?: readonly unknown[]) => void, onTokenUpdate: (t: string) => void, schemas: Record<string, any>, _executeContinueWorkflowFn?: typeof executeContinueWorkflow, emitter?: DaemonEventEmitter, workrailSessionId?: string | null): AgentTool;
5
+ export declare function makeContinueWorkflowTool(sessionId: RunId, ctx: V2ToolContext, onAdvance: (nextStepText: string, continueToken: string) => void, onComplete: (notes: string | undefined, artifacts?: readonly unknown[]) => void, schemas: Record<string, any>, _executeContinueWorkflowFn?: typeof executeContinueWorkflow, emitter?: DaemonEventEmitter, workrailSessionId?: string | null): AgentTool;
6
+ export declare function makeCompleteStepTool(sessionId: RunId, ctx: V2ToolContext, getCurrentToken: () => string, onAdvance: (nextStepText: string, continueToken: string) => void, onComplete: (notes: string | undefined, artifacts?: readonly unknown[]) => void, onTokenUpdate: (t: string) => void, schemas: Record<string, any>, _executeContinueWorkflowFn?: typeof executeContinueWorkflow, emitter?: DaemonEventEmitter, workrailSessionId?: string | null): AgentTool;
@@ -1,6 +1,6 @@
1
1
  import type { AgentTool } from '../agent-loop.js';
2
- import type { DaemonEventEmitter } from '../daemon-events.js';
2
+ import type { DaemonEventEmitter, RunId } from '../daemon-events.js';
3
3
  import type { ReadFileState } from '../types.js';
4
- export declare function makeReadTool(workspacePath: string, readFileState: Map<string, ReadFileState>, schemas: Record<string, any>, sessionId?: string, emitter?: DaemonEventEmitter, workrailSessionId?: string | null): AgentTool;
5
- export declare function makeWriteTool(workspacePath: string, readFileState: Map<string, ReadFileState>, schemas: Record<string, any>, sessionId?: string, emitter?: DaemonEventEmitter, workrailSessionId?: string | null): AgentTool;
6
- export declare function makeEditTool(workspacePath: string, readFileState: Map<string, ReadFileState>, schemas: Record<string, any>, sessionId?: string, emitter?: DaemonEventEmitter, workrailSessionId?: string | null): AgentTool;
4
+ export declare function makeReadTool(workspacePath: string, readFileState: Map<string, ReadFileState>, schemas: Record<string, any>, sessionId?: RunId, emitter?: DaemonEventEmitter, workrailSessionId?: string | null): AgentTool;
5
+ export declare function makeWriteTool(workspacePath: string, readFileState: Map<string, ReadFileState>, schemas: Record<string, any>, sessionId?: RunId, emitter?: DaemonEventEmitter, workrailSessionId?: string | null): AgentTool;
6
+ export declare function makeEditTool(workspacePath: string, readFileState: Map<string, ReadFileState>, schemas: Record<string, any>, sessionId?: RunId, emitter?: DaemonEventEmitter, workrailSessionId?: string | null): AgentTool;
@@ -1,4 +1,4 @@
1
1
  import type { AgentTool } from '../agent-loop.js';
2
- import type { DaemonEventEmitter } from '../daemon-events.js';
3
- export declare function makeGlobTool(workspacePath: string, schemas: Record<string, any>, sessionId?: string, emitter?: DaemonEventEmitter, workrailSessionId?: string | null): AgentTool;
4
- export declare function makeGrepTool(workspacePath: string, schemas: Record<string, any>, sessionId?: string, emitter?: DaemonEventEmitter, workrailSessionId?: string | null): AgentTool;
2
+ import type { DaemonEventEmitter, RunId } from '../daemon-events.js';
3
+ export declare function makeGlobTool(workspacePath: string, schemas: Record<string, any>, sessionId?: RunId, emitter?: DaemonEventEmitter, workrailSessionId?: string | null): AgentTool;
4
+ export declare function makeGrepTool(workspacePath: string, schemas: Record<string, any>, sessionId?: RunId, emitter?: DaemonEventEmitter, workrailSessionId?: string | null): AgentTool;
@@ -1,3 +1,3 @@
1
1
  import type { AgentTool } from '../agent-loop.js';
2
- import type { DaemonEventEmitter } from '../daemon-events.js';
3
- export declare function makeReportIssueTool(sessionId: string, emitter?: DaemonEventEmitter, workrailSessionId?: string | null, issuesDirOverride?: string, onIssueSummary?: (summary: string) => void): AgentTool;
2
+ import type { DaemonEventEmitter, RunId } from '../daemon-events.js';
3
+ export declare function makeReportIssueTool(sessionId: RunId, emitter?: DaemonEventEmitter, workrailSessionId?: string | null, issuesDirOverride?: string, onIssueSummary?: (summary: string) => void): AgentTool;
@@ -1,4 +1,4 @@
1
1
  import type { AgentTool } from '../agent-loop.js';
2
- import type { DaemonEventEmitter } from '../daemon-events.js';
2
+ import type { DaemonEventEmitter, RunId } from '../daemon-events.js';
3
3
  export declare const DAEMON_SIGNALS_DIR: string;
4
- export declare function makeSignalCoordinatorTool(sessionId: string, emitter?: DaemonEventEmitter, workrailSessionId?: string | null, signalsDirOverride?: string): AgentTool;
4
+ export declare function makeSignalCoordinatorTool(sessionId: RunId, emitter?: DaemonEventEmitter, workrailSessionId?: string | null, signalsDirOverride?: string): AgentTool;
@@ -1,6 +1,6 @@
1
1
  import type { AgentTool } from '../agent-loop.js';
2
2
  import type { V2ToolContext } from '../../mcp/types.js';
3
- import type { DaemonEventEmitter } from '../daemon-events.js';
3
+ import type { DaemonEventEmitter, RunId } from '../daemon-events.js';
4
4
  import type { runWorkflow } from '../workflow-runner.js';
5
5
  import type { ActiveSessionSet } from '../active-sessions.js';
6
- export declare function makeSpawnAgentTool(sessionId: string, ctx: V2ToolContext, apiKey: string, thisWorkrailSessionId: string, currentDepth: number, maxDepth: number, runWorkflowFn: typeof runWorkflow, schemas: Record<string, any>, emitter?: DaemonEventEmitter, activeSessionSet?: ActiveSessionSet): AgentTool;
6
+ export declare function makeSpawnAgentTool(sessionId: RunId, ctx: V2ToolContext, apiKey: string, thisWorkrailSessionId: string, currentDepth: number, maxDepth: number, runWorkflowFn: typeof runWorkflow, schemas: Record<string, any>, emitter?: DaemonEventEmitter, activeSessionSet?: ActiveSessionSet): AgentTool;
@@ -1,3 +1,5 @@
1
+ import type { RunId } from './daemon-events.js';
2
+ export type { RunId } from './daemon-events.js';
1
3
  export type ReadFileState = {
2
4
  content: string;
3
5
  timestamp: number;
@@ -53,7 +55,7 @@ export interface WorkflowRunSuccess {
53
55
  readonly lastStepNotes?: string;
54
56
  readonly lastStepArtifacts?: readonly unknown[];
55
57
  readonly sessionWorkspacePath?: string;
56
- readonly sessionId?: string;
58
+ readonly sessionId?: RunId;
57
59
  readonly botIdentity?: {
58
60
  readonly name: string;
59
61
  readonly email: string;
@@ -94,7 +96,7 @@ export interface WorkflowContextSlots {
94
96
  export declare function extractContextSlots(context: Readonly<Record<string, unknown>> | undefined): WorkflowContextSlots;
95
97
  export type ChildWorkflowRunResult = WorkflowRunSuccess | WorkflowRunError | WorkflowRunTimeout | WorkflowRunStuck;
96
98
  export interface OrphanedSession {
97
- readonly sessionId: string;
99
+ readonly sessionId: RunId;
98
100
  readonly continueToken: string;
99
101
  readonly checkpointToken: string | null;
100
102
  readonly ts: number;
@@ -40,6 +40,7 @@ const path = __importStar(require("node:path"));
40
40
  const node_child_process_1 = require("node:child_process");
41
41
  const node_util_1 = require("node:util");
42
42
  const node_crypto_1 = require("node:crypto");
43
+ const daemon_events_js_1 = require("./daemon-events.js");
43
44
  const types_js_1 = require("./types.js");
44
45
  const workflow_enricher_js_1 = require("./workflow-enricher.js");
45
46
  const index_js_1 = require("./core/index.js");
@@ -121,7 +122,7 @@ async function runWorkflow(trigger, ctx, apiKey, daemonRegistry, emitter, active
121
122
  const statsDir = _statsDir ?? index_js_2.DAEMON_STATS_DIR;
122
123
  const sessionsDir = _sessionsDir ?? _shared_js_1.DAEMON_SESSIONS_DIR;
123
124
  const startMs = Date.now();
124
- const sessionId = (0, node_crypto_1.randomUUID)();
125
+ const sessionId = (0, daemon_events_js_1.asRunId)((0, node_crypto_1.randomUUID)());
125
126
  console.log(`[WorkflowRunner] Session started: sessionId=${sessionId} workflowId=${trigger.workflowId}`);
126
127
  emitter?.emit({
127
128
  kind: 'session_started',