specrails-core 6.4.0 → 6.5.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/dist/agent-runtime/capabilities.js +22 -5
- package/dist/agent-runtime/cli-executor.js +8 -3
- package/dist/agent-runtime/cli.d.ts +1 -1
- package/dist/agent-runtime/cli.js +50 -3
- package/dist/agent-runtime/compact/environment.d.ts +30 -2
- package/dist/agent-runtime/compact/environment.js +120 -2
- package/dist/agent-runtime/engine/pieces/role-turn.d.ts +5 -0
- package/dist/agent-runtime/engine/pieces/role-turn.js +54 -21
- package/dist/agent-runtime/engine/pieces/verify.js +3 -5
- package/dist/agent-runtime/session/application/active-session.d.ts +176 -0
- package/dist/agent-runtime/session/application/active-session.js +701 -0
- package/dist/agent-runtime/session/application/delegation.d.ts +73 -0
- package/dist/agent-runtime/session/application/delegation.js +171 -0
- package/dist/agent-runtime/session/application/output-buffer.d.ts +43 -0
- package/dist/agent-runtime/session/application/output-buffer.js +65 -0
- package/dist/agent-runtime/session/application/session-service.d.ts +121 -0
- package/dist/agent-runtime/session/application/session-service.js +256 -0
- package/dist/agent-runtime/session/application/timers.d.ts +15 -0
- package/dist/agent-runtime/session/application/timers.js +35 -0
- package/dist/agent-runtime/session/domain/descriptor.d.ts +6 -0
- package/dist/agent-runtime/session/domain/descriptor.js +32 -0
- package/dist/agent-runtime/session/domain/errors.d.ts +9 -0
- package/dist/agent-runtime/session/domain/errors.js +16 -0
- package/dist/agent-runtime/session/domain/events.d.ts +147 -0
- package/dist/agent-runtime/session/domain/events.js +24 -0
- package/dist/agent-runtime/session/domain/fingerprint.d.ts +2 -0
- package/dist/agent-runtime/session/domain/fingerprint.js +10 -0
- package/dist/agent-runtime/session/domain/interruption.d.ts +13 -0
- package/dist/agent-runtime/session/domain/interruption.js +39 -0
- package/dist/agent-runtime/session/domain/policy.d.ts +42 -0
- package/dist/agent-runtime/session/domain/policy.js +104 -0
- package/dist/agent-runtime/session/domain/snapshot.d.ts +100 -0
- package/dist/agent-runtime/session/domain/snapshot.js +234 -0
- package/dist/agent-runtime/session/domain/state-machines.d.ts +21 -0
- package/dist/agent-runtime/session/domain/state-machines.js +41 -0
- package/dist/agent-runtime/session/domain/types.d.ts +130 -0
- package/dist/agent-runtime/session/domain/types.js +15 -0
- package/dist/agent-runtime/session/domain/usage.d.ts +54 -0
- package/dist/agent-runtime/session/domain/usage.js +86 -0
- package/dist/agent-runtime/session/drivers/claude/argv.d.ts +19 -0
- package/dist/agent-runtime/session/drivers/claude/argv.js +67 -0
- package/dist/agent-runtime/session/drivers/claude/driver.d.ts +19 -0
- package/dist/agent-runtime/session/drivers/claude/driver.js +134 -0
- package/dist/agent-runtime/session/drivers/claude/translator.d.ts +40 -0
- package/dist/agent-runtime/session/drivers/claude/translator.js +247 -0
- package/dist/agent-runtime/session/drivers/codex/argv.d.ts +12 -0
- package/dist/agent-runtime/session/drivers/codex/argv.js +76 -0
- package/dist/agent-runtime/session/drivers/codex/driver.d.ts +19 -0
- package/dist/agent-runtime/session/drivers/codex/driver.js +193 -0
- package/dist/agent-runtime/session/drivers/codex/rpc.d.ts +28 -0
- package/dist/agent-runtime/session/drivers/codex/rpc.js +81 -0
- package/dist/agent-runtime/session/drivers/codex/translator.d.ts +53 -0
- package/dist/agent-runtime/session/drivers/codex/translator.js +267 -0
- package/dist/agent-runtime/session/drivers/common/process.d.ts +37 -0
- package/dist/agent-runtime/session/drivers/common/process.js +116 -0
- package/dist/agent-runtime/session/drivers/executor/driver.d.ts +22 -0
- package/dist/agent-runtime/session/drivers/executor/driver.js +163 -0
- package/dist/agent-runtime/session/drivers/registry.d.ts +32 -0
- package/dist/agent-runtime/session/drivers/registry.js +38 -0
- package/dist/agent-runtime/session/host/protocol.d.ts +18 -0
- package/dist/agent-runtime/session/host/protocol.js +88 -0
- package/dist/agent-runtime/session/host/server.d.ts +57 -0
- package/dist/agent-runtime/session/host/server.js +229 -0
- package/dist/agent-runtime/session/index.d.ts +45 -0
- package/dist/agent-runtime/session/index.js +74 -0
- package/dist/agent-runtime/session/journal/schema.d.ts +7 -0
- package/dist/agent-runtime/session/journal/schema.js +44 -0
- package/dist/agent-runtime/session/journal/sqlite-journal.d.ts +70 -0
- package/dist/agent-runtime/session/journal/sqlite-journal.js +279 -0
- package/dist/agent-runtime/session/ports.d.ts +192 -0
- package/dist/agent-runtime/session/ports.js +1 -0
- package/dist/agent-runtime/session/testing/driver-conformance.d.ts +21 -0
- package/dist/agent-runtime/session/testing/driver-conformance.js +97 -0
- package/dist/agent-runtime/session/testing/fake-clock.d.ts +20 -0
- package/dist/agent-runtime/session/testing/fake-clock.js +34 -0
- package/dist/agent-runtime/session/testing/fixture-replayer.d.ts +41 -0
- package/dist/agent-runtime/session/testing/fixture-replayer.js +172 -0
- package/dist/agent-runtime/session/testing/index.d.ts +9 -0
- package/dist/agent-runtime/session/testing/index.js +9 -0
- package/dist/agent-runtime/session/testing/memory-journal.d.ts +27 -0
- package/dist/agent-runtime/session/testing/memory-journal.js +70 -0
- package/dist/agent-runtime/session/testing/scripted-driver.d.ts +30 -0
- package/dist/agent-runtime/session/testing/scripted-driver.js +77 -0
- package/dist/agent-runtime/verification-proposals.d.ts +9 -0
- package/dist/agent-runtime/verification-proposals.js +69 -0
- package/dist/installer/util/registry.js +3 -3
- package/dist/shared/specrails-home.d.ts +21 -0
- package/dist/shared/specrails-home.js +36 -0
- package/integration-contract.json +42 -1
- package/package.json +11 -1
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import type { SessionEventEnvelope, ToolActivity } from '../domain/events.js';
|
|
2
|
+
import { type SessionSnapshot } from '../domain/snapshot.js';
|
|
3
|
+
import { type SessionPolicy, type SubagentPhase, type Usage } from '../domain/types.js';
|
|
4
|
+
import { type RateCard } from '../domain/usage.js';
|
|
5
|
+
import type { Clock, CloseReason, DriverFactory, DriverInput, Ids, SessionJournal } from '../ports.js';
|
|
6
|
+
import { type OutputLimits } from './output-buffer.js';
|
|
7
|
+
export interface ActiveSessionDeps {
|
|
8
|
+
journal: SessionJournal;
|
|
9
|
+
factory: DriverFactory;
|
|
10
|
+
clock: Clock;
|
|
11
|
+
ids: Ids;
|
|
12
|
+
rateCard: (driver: string, model: string) => RateCard | null;
|
|
13
|
+
publish: (envelopes: SessionEventEnvelope[]) => void;
|
|
14
|
+
/** Called whenever the session's process liveness or recency changes (LRU bookkeeping). */
|
|
15
|
+
touched: (session: ActiveSession) => void;
|
|
16
|
+
outputLimits?: OutputLimits;
|
|
17
|
+
/** How long `interrupt` waits for the provider before ending the process. */
|
|
18
|
+
interruptGraceMs?: number;
|
|
19
|
+
/** Delay before buffered deltas are flushed. */
|
|
20
|
+
flushMs?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface SessionConfig {
|
|
23
|
+
cwd: string;
|
|
24
|
+
model: string;
|
|
25
|
+
effort: string | null;
|
|
26
|
+
systemPrompt: string | null;
|
|
27
|
+
policy: SessionPolicy;
|
|
28
|
+
}
|
|
29
|
+
/** How work that was running ends when the process goes away. */
|
|
30
|
+
interface Teardown {
|
|
31
|
+
turnStatus: 'stopped' | 'interrupted' | 'failed';
|
|
32
|
+
subagentPhase: SubagentPhase;
|
|
33
|
+
reason: string;
|
|
34
|
+
error?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Coordinates one session: turns driver facts into journaled events, owns the
|
|
38
|
+
* provider process lifecycle, phases, settlement, limits and teardown.
|
|
39
|
+
* All mutation goes through `commit`, which folds before appending, so the
|
|
40
|
+
* journal never holds an event the domain would reject.
|
|
41
|
+
*/
|
|
42
|
+
export declare class ActiveSession {
|
|
43
|
+
readonly sessionId: string;
|
|
44
|
+
private config;
|
|
45
|
+
private readonly deps;
|
|
46
|
+
state: SessionSnapshot;
|
|
47
|
+
private driver;
|
|
48
|
+
private opening;
|
|
49
|
+
private generation;
|
|
50
|
+
/** Generation whose events are accepted (the live or opening process); null when none. */
|
|
51
|
+
private liveGeneration;
|
|
52
|
+
private closing;
|
|
53
|
+
private baseline;
|
|
54
|
+
private readonly timers;
|
|
55
|
+
private readonly output;
|
|
56
|
+
private readonly descriptor;
|
|
57
|
+
/** Inputs held back for drivers without a native input queue. */
|
|
58
|
+
private readonly heldInputs;
|
|
59
|
+
/** Inputs the application wrote on its own (policy-driven turns). */
|
|
60
|
+
private readonly systemInputIds;
|
|
61
|
+
private pendingDeferred;
|
|
62
|
+
private roster;
|
|
63
|
+
private handoffs;
|
|
64
|
+
private finishedSinceLastTurn;
|
|
65
|
+
/** Finished delegated sub-agents whose results the agent has not received yet. */
|
|
66
|
+
private readonly delegatedResults;
|
|
67
|
+
private lastUserTurnAt;
|
|
68
|
+
lastUsedAt: number;
|
|
69
|
+
constructor(sessionId: string, snapshot: SessionSnapshot, config: SessionConfig, deps: ActiveSessionDeps);
|
|
70
|
+
get processAlive(): boolean;
|
|
71
|
+
get isBusy(): boolean;
|
|
72
|
+
get policy(): SessionPolicy;
|
|
73
|
+
send(input: {
|
|
74
|
+
inputId: string;
|
|
75
|
+
text: string;
|
|
76
|
+
attachments?: DriverInput['attachments'];
|
|
77
|
+
delivery: 'queue' | 'steer';
|
|
78
|
+
}): Promise<{
|
|
79
|
+
inputId: string;
|
|
80
|
+
state: string;
|
|
81
|
+
}>;
|
|
82
|
+
interrupt(): Promise<string | null>;
|
|
83
|
+
stopSubagents(ids?: string[]): Promise<string[]>;
|
|
84
|
+
/**
|
|
85
|
+
* Policy says no sub-agents, yet the provider started one (a provider switch
|
|
86
|
+
* can be ignored by a model or CLI version). Stop it and say so: the policy
|
|
87
|
+
* holds whatever the provider's own switch does.
|
|
88
|
+
*/
|
|
89
|
+
private blockSubagent;
|
|
90
|
+
/** Apply now when nothing is running; otherwise defer to the next idle point. */
|
|
91
|
+
update(changes: {
|
|
92
|
+
model?: string;
|
|
93
|
+
effort?: string;
|
|
94
|
+
systemPrompt?: string;
|
|
95
|
+
policy?: SessionPolicy;
|
|
96
|
+
}): Promise<'applied' | 'deferred'>;
|
|
97
|
+
close(reason: string): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Record work a previous host left running as interrupted. Nothing is
|
|
100
|
+
* restarted: the next user input carries the interruption notice instead.
|
|
101
|
+
*/
|
|
102
|
+
recoverAfterHostLoss(reason: 'restart' | 'host_lost'): void;
|
|
103
|
+
/** Retire the provider process; running work ends as described by `teardown`. */
|
|
104
|
+
retire(reason: CloseReason, teardown: Teardown): Promise<void>;
|
|
105
|
+
private deliver;
|
|
106
|
+
private ensureDriver;
|
|
107
|
+
private onDriverEvent;
|
|
108
|
+
private handleDriverEvent;
|
|
109
|
+
private startTurn;
|
|
110
|
+
private completeTurn;
|
|
111
|
+
/**
|
|
112
|
+
* Inputs whose receipts never reported completion are completed with their
|
|
113
|
+
* turn: the ones that opened it and the ones steered into it.
|
|
114
|
+
*/
|
|
115
|
+
private completeTurnInputs;
|
|
116
|
+
private settlePhaseAfterTurn;
|
|
117
|
+
private afterSubagentChange;
|
|
118
|
+
private onSettled;
|
|
119
|
+
/** Live = running in our tree and, when the provider reports a roster, still on it. */
|
|
120
|
+
private liveCount;
|
|
121
|
+
private maybeResumeAgent;
|
|
122
|
+
/** Give the agent the results of delegated sub-agents it has not seen. */
|
|
123
|
+
private maybeDeliverDelegatedResults;
|
|
124
|
+
/** Running sub-agents Core launched for this session. */
|
|
125
|
+
delegatedLive(): string[];
|
|
126
|
+
delegatedStarted(child: {
|
|
127
|
+
subagentId: string;
|
|
128
|
+
description: string;
|
|
129
|
+
agentType: string;
|
|
130
|
+
prompt: string;
|
|
131
|
+
driver: string;
|
|
132
|
+
model: string;
|
|
133
|
+
}): void;
|
|
134
|
+
delegatedOutput(subagentId: string, event: {
|
|
135
|
+
channel: 'text';
|
|
136
|
+
delta: string;
|
|
137
|
+
} | {
|
|
138
|
+
channel: 'tool';
|
|
139
|
+
tool: ToolActivity;
|
|
140
|
+
}): void;
|
|
141
|
+
/**
|
|
142
|
+
* A delegated child ended. Its usage is its own provider's spend (billed
|
|
143
|
+
* separately); unless a host already collected the result, the agent gets it
|
|
144
|
+
* when the session next settles.
|
|
145
|
+
*/
|
|
146
|
+
delegatedFinished(subagentId: string, outcome: {
|
|
147
|
+
status: 'completed' | 'failed' | 'stopped' | 'interrupted';
|
|
148
|
+
text: string;
|
|
149
|
+
usage: Usage | null;
|
|
150
|
+
reason?: string;
|
|
151
|
+
collected: boolean;
|
|
152
|
+
}): void;
|
|
153
|
+
/** A host received these results through a wait; never inject them again. */
|
|
154
|
+
collectDelegated(subagentIds: readonly string[]): void;
|
|
155
|
+
private enterIdle;
|
|
156
|
+
private enterBackground;
|
|
157
|
+
private idleTeardown;
|
|
158
|
+
private armTurnInactivity;
|
|
159
|
+
private markActivity;
|
|
160
|
+
private applyChanges;
|
|
161
|
+
private releaseHeldInput;
|
|
162
|
+
/** End whatever was running; used by retire and unexpected exits. */
|
|
163
|
+
private endRunningWork;
|
|
164
|
+
private turnUsage;
|
|
165
|
+
private subagentUsage;
|
|
166
|
+
private commitBuffered;
|
|
167
|
+
/**
|
|
168
|
+
* Validate (fold) then append atomically, then publish. Buffered deltas are
|
|
169
|
+
* flushed first so ordering is preserved.
|
|
170
|
+
*/
|
|
171
|
+
private commit;
|
|
172
|
+
private requireTurn;
|
|
173
|
+
private assertOpen;
|
|
174
|
+
private touch;
|
|
175
|
+
}
|
|
176
|
+
export {};
|