@exaudeus/workrail 3.71.0 → 3.72.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.
@@ -0,0 +1,2 @@
1
+ export type { StuckSignal, StuckConfig } from '../workflow-runner.js';
2
+ export { evaluateStuckSignals as detectStuck } from '../workflow-runner.js';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.detectStuck = void 0;
4
+ var workflow_runner_js_1 = require("../workflow-runner.js");
5
+ Object.defineProperty(exports, "detectStuck", { enumerable: true, get: function () { return workflow_runner_js_1.evaluateStuckSignals; } });
@@ -0,0 +1,8 @@
1
+ import type { SessionState } from '../workflow-runner.js';
2
+ export declare function injectPendingSteps(state: SessionState, agent: {
3
+ steer(msg: {
4
+ role: 'user';
5
+ content: string;
6
+ timestamp: number;
7
+ }): void;
8
+ }): void;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.injectPendingSteps = injectPendingSteps;
4
+ function injectPendingSteps(state, agent) {
5
+ if (state.pendingSteerParts.length > 0 && !state.isComplete) {
6
+ const joined = state.pendingSteerParts.join('\n\n');
7
+ state.pendingSteerParts.length = 0;
8
+ agent.steer({ role: 'user', content: joined, timestamp: Date.now() });
9
+ }
10
+ }
@@ -1,7 +1,8 @@
1
1
  import 'reflect-metadata';
2
2
  import Anthropic from '@anthropic-ai/sdk';
3
3
  import { AnthropicBedrock } from '@anthropic-ai/bedrock-sdk';
4
- import type { AgentTool } from "./agent-loop.js";
4
+ import { AgentLoop } from "./agent-loop.js";
5
+ import type { AgentTool, AgentEvent, AgentLoopCallbacks } from "./agent-loop.js";
5
6
  import type { V2ToolContext } from '../mcp/types.js';
6
7
  import { executeContinueWorkflow } from '../mcp/handlers/v2-execution/index.js';
7
8
  import type { DaemonRegistry } from '../v2/infra/in-memory/daemon-registry/index.js';
@@ -103,6 +104,10 @@ export interface OrphanedSession {
103
104
  readonly goal?: string;
104
105
  readonly workspacePath?: string;
105
106
  }
107
+ export interface PersistTokensError {
108
+ readonly code: string;
109
+ readonly message: string;
110
+ }
106
111
  export declare function readDaemonSessionState(sessionId: string): Promise<{
107
112
  continueToken: string;
108
113
  checkpointToken: string | null;
@@ -111,7 +116,7 @@ export declare function readAllDaemonSessions(sessionsDir?: string): Promise<Orp
111
116
  export declare function runStartupRecovery(sessionsDir?: string, execFn?: (file: string, args: string[]) => Promise<{
112
117
  stdout: string;
113
118
  stderr: string;
114
- }>, ctx?: V2ToolContext, _countStepAdvancesFn?: typeof countOrphanStepAdvances, _executeContinueWorkflowFn?: typeof executeContinueWorkflow, _runWorkflowFn?: typeof runWorkflow): Promise<void>;
119
+ }>, ctx?: V2ToolContext, _countStepAdvancesFn?: typeof countOrphanStepAdvances, _executeContinueWorkflowFn?: typeof executeContinueWorkflow, _runWorkflowFn?: typeof runWorkflow, apiKey?: string): Promise<void>;
115
120
  export declare function countOrphanStepAdvances(continueToken: string, ctx: V2ToolContext, _parseFn?: ((raw: string) => ResultAsync<ContinueTokenResolved, ToolFailure>) | undefined, _loadFn?: SessionEventLogReadonlyStorePortV2['loadValidatedPrefix'] | undefined): Promise<number>;
116
121
  export declare function clearQueueIssueSidecars(sessionsDir: string): Promise<void>;
117
122
  export declare function stripFrontmatter(content: string): string;
@@ -132,6 +137,12 @@ export declare function makeSignalCoordinatorTool(sessionId: string, emitter?: D
132
137
  export declare function buildSessionRecap(notes: readonly string[]): string;
133
138
  export declare function buildSystemPrompt(trigger: WorkflowTrigger, sessionState: string, soulContent: string, workspaceContext: string | null): string;
134
139
  export declare function tagToStatsOutcome(tag: WorkflowRunResult['_tag']): 'success' | 'error' | 'timeout' | 'stuck';
140
+ export type SidecarLifecycle = {
141
+ readonly kind: 'delete_now';
142
+ } | {
143
+ readonly kind: 'retain_for_delivery';
144
+ };
145
+ export declare function sidecardLifecycleFor(tag: WorkflowRunResult['_tag'], branchStrategy: WorkflowTrigger['branchStrategy']): SidecarLifecycle;
135
146
  export declare function buildAgentClient(trigger: WorkflowTrigger, apiKey: string, env: NodeJS.ProcessEnv): {
136
147
  agentClient: Anthropic | AnthropicBedrock;
137
148
  modelId: string;
@@ -175,6 +186,29 @@ export type StuckSignal = {
175
186
  timeoutReason: 'wall_clock' | 'max_turns';
176
187
  };
177
188
  export declare function evaluateStuckSignals(state: Readonly<SessionState>, config: StuckConfig): StuckSignal | null;
189
+ export interface PreAgentSession {
190
+ readonly sessionId: string;
191
+ readonly workrailSessionId: string | null;
192
+ readonly continueToken: string;
193
+ readonly checkpointToken: string | null;
194
+ readonly sessionWorkspacePath: string;
195
+ readonly sessionWorktreePath: string | undefined;
196
+ readonly firstStep: import('zod').infer<typeof V2StartWorkflowOutputSchema>;
197
+ readonly state: SessionState;
198
+ readonly spawnCurrentDepth: number;
199
+ readonly spawnMaxDepth: number;
200
+ readonly readFileState: Map<string, ReadFileState>;
201
+ readonly agentClient: Anthropic | AnthropicBedrock;
202
+ readonly modelId: string;
203
+ readonly startMs: number;
204
+ }
205
+ export type PreAgentSessionResult = {
206
+ readonly kind: 'ready';
207
+ readonly session: PreAgentSession;
208
+ } | {
209
+ readonly kind: 'complete';
210
+ readonly result: WorkflowRunResult;
211
+ };
178
212
  export interface FinalizationContext {
179
213
  readonly sessionId: string;
180
214
  readonly workrailSessionId: string | null;
@@ -202,4 +236,21 @@ export interface SessionContext {
202
236
  readonly maxTurns: number;
203
237
  }
204
238
  export declare function buildSessionContext(trigger: WorkflowTrigger, inputs: SessionContextInputs): SessionContext;
239
+ export declare function buildPreAgentSession(trigger: WorkflowTrigger, ctx: V2ToolContext, apiKey: string, sessionId: string, startMs: number, statsDir: string, sessionsDir: string, emitter: DaemonEventEmitter | undefined, daemonRegistry: DaemonRegistry | undefined, steerRegistry: SteerRegistry | undefined): Promise<PreAgentSessionResult>;
240
+ export interface TurnEndSubscriberContext {
241
+ readonly agent: AgentLoop;
242
+ readonly state: SessionState;
243
+ readonly stuckConfig: StuckConfig;
244
+ readonly sessionId: string;
245
+ readonly workflowId: string;
246
+ readonly emitter: DaemonEventEmitter | undefined;
247
+ readonly conversationPath: string;
248
+ readonly lastFlushedRef: {
249
+ count: number;
250
+ };
251
+ readonly stuckRepeatThreshold: number;
252
+ }
253
+ export declare function buildTurnEndSubscriber(ctx: TurnEndSubscriberContext): (event: AgentEvent) => Promise<void>;
254
+ export declare function buildAgentCallbacks(sessionId: string, state: SessionState, modelId: string, emitter: DaemonEventEmitter | undefined, stuckRepeatThreshold: number): AgentLoopCallbacks;
255
+ export declare function buildSessionResult(state: Readonly<SessionState>, stopReason: string, errorMessage: string | undefined, trigger: WorkflowTrigger, sessionId: string, sessionWorktreePath: string | undefined): WorkflowRunResult;
205
256
  export declare function runWorkflow(trigger: WorkflowTrigger, ctx: V2ToolContext, apiKey: string, daemonRegistry?: DaemonRegistry, emitter?: DaemonEventEmitter, steerRegistry?: SteerRegistry, abortRegistry?: AbortRegistry, _statsDir?: string, _sessionsDir?: string): Promise<WorkflowRunResult>;