voratiq 0.1.0-beta.21 → 0.1.0-beta.22
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/README.md +18 -22
- package/dist/agents/launch/chat.d.ts +3 -1
- package/dist/agents/launch/chat.js +2 -0
- package/dist/bin.js +28 -7
- package/dist/cli/auto.js +1 -0
- package/dist/cli/contract.d.ts +26 -17
- package/dist/cli/contract.js +3 -1
- package/dist/cli/doctor.d.ts +12 -0
- package/dist/cli/doctor.js +115 -0
- package/dist/cli/list.js +4 -1
- package/dist/cli/operator-envelope.d.ts +19 -6
- package/dist/cli/operator-envelope.js +61 -1
- package/dist/cli/run.js +2 -0
- package/dist/cli/verify.d.ts +1 -1
- package/dist/cli/verify.js +48 -9
- package/dist/commands/auto/command.d.ts +1 -0
- package/dist/commands/auto/command.js +22 -12
- package/dist/commands/auto/errors.js +1 -1
- package/dist/commands/doctor/agents.d.ts +5 -0
- package/dist/commands/{init → doctor}/agents.js +37 -19
- package/dist/commands/doctor/command.d.ts +22 -0
- package/dist/commands/doctor/command.js +99 -0
- package/dist/commands/doctor/environment.d.ts +2 -0
- package/dist/commands/{init → doctor}/environment.js +38 -6
- package/dist/commands/{init/types.d.ts → doctor/fix-types.d.ts} +30 -9
- package/dist/commands/doctor/fix.d.ts +2 -0
- package/dist/commands/{init/command.js → doctor/fix.js} +106 -10
- package/dist/commands/doctor/reconcile.d.ts +2 -0
- package/dist/commands/doctor/reconcile.js +101 -0
- package/dist/commands/interactive/lifecycle.d.ts +2 -0
- package/dist/commands/interactive/lifecycle.js +8 -0
- package/dist/commands/list/command.d.ts +1 -0
- package/dist/commands/list/command.js +211 -352
- package/dist/commands/list/normalization.d.ts +56 -0
- package/dist/commands/list/normalization.js +317 -0
- package/dist/commands/message/command.d.ts +2 -1
- package/dist/commands/message/command.js +35 -14
- package/dist/commands/message/errors.d.ts +12 -3
- package/dist/commands/message/errors.js +19 -3
- package/dist/commands/reduce/command.js +16 -17
- package/dist/commands/reduce/errors.d.ts +2 -2
- package/dist/commands/reduce/errors.js +3 -3
- package/dist/commands/reduce/targets.js +11 -2
- package/dist/commands/root-launcher/command.js +12 -6
- package/dist/commands/run/command.d.ts +1 -0
- package/dist/commands/run/command.js +4 -1
- package/dist/commands/run/record-init.d.ts +2 -0
- package/dist/commands/run/record-init.js +2 -1
- package/dist/commands/run/spec-provenance.d.ts +37 -0
- package/dist/commands/run/spec-provenance.js +384 -0
- package/dist/commands/run/validation.d.ts +4 -0
- package/dist/commands/run/validation.js +25 -62
- package/dist/commands/spec/command.js +19 -6
- package/dist/commands/spec/errors.d.ts +5 -0
- package/dist/commands/spec/errors.js +9 -0
- package/dist/commands/verify/agents.d.ts +4 -2
- package/dist/commands/verify/agents.js +4 -11
- package/dist/commands/verify/command.js +15 -5
- package/dist/commands/verify/errors.d.ts +12 -0
- package/dist/commands/verify/errors.js +22 -0
- package/dist/commands/verify/targets.js +108 -12
- package/dist/competition/shared/preflight.d.ts +1 -1
- package/dist/competition/shared/preflight.js +15 -2
- package/dist/contracts/list.d.ts +129 -149
- package/dist/contracts/list.js +47 -99
- package/dist/domain/interactive/persistence/adapter.d.ts +23 -0
- package/dist/domain/interactive/persistence/adapter.js +42 -0
- package/dist/domain/message/model/types.d.ts +32 -0
- package/dist/domain/message/model/types.js +25 -0
- package/dist/domain/reduce/competition/adapter.js +21 -7
- package/dist/domain/reduce/competition/finalize.d.ts +7 -0
- package/dist/domain/reduce/competition/finalize.js +19 -0
- package/dist/domain/reduce/model/types.d.ts +3 -3
- package/dist/domain/run/competition/agents/artifacts.js +4 -2
- package/dist/domain/run/competition/errors.d.ts +1 -1
- package/dist/domain/run/competition/errors.js +4 -7
- package/dist/domain/run/model/types.d.ts +384 -0
- package/dist/domain/run/model/types.js +87 -0
- package/dist/domain/spec/competition/adapter.d.ts +1 -0
- package/dist/domain/spec/competition/adapter.js +6 -1
- package/dist/domain/spec/model/types.d.ts +3 -0
- package/dist/domain/spec/model/types.js +5 -0
- package/dist/domain/verify/competition/finalize.d.ts +9 -0
- package/dist/domain/verify/competition/finalize.js +22 -3
- package/dist/domain/verify/model/types.d.ts +2 -2
- package/dist/interactive/providers/mcp.d.ts +1 -0
- package/dist/interactive/providers/mcp.js +45 -7
- package/dist/interactive/substrate.js +20 -3
- package/dist/mcp/server.js +26 -9
- package/dist/policy/verification.js +18 -1
- package/dist/preflight/agents.d.ts +24 -0
- package/dist/preflight/agents.js +71 -0
- package/dist/preflight/environment.d.ts +6 -0
- package/dist/preflight/environment.js +17 -0
- package/dist/preflight/formatting.d.ts +5 -0
- package/dist/preflight/formatting.js +20 -0
- package/dist/preflight/index.d.ts +2 -0
- package/dist/preflight/index.js +5 -9
- package/dist/preflight/operator.d.ts +32 -0
- package/dist/preflight/operator.js +40 -0
- package/dist/preflight/settings.d.ts +2 -0
- package/dist/preflight/settings.js +17 -0
- package/dist/render/transcripts/interactive.d.ts +16 -0
- package/dist/render/transcripts/interactive.js +42 -0
- package/dist/render/transcripts/list.d.ts +41 -0
- package/dist/render/transcripts/list.js +152 -3
- package/dist/render/transcripts/message.d.ts +2 -1
- package/dist/render/transcripts/message.js +19 -20
- package/dist/render/transcripts/reduce.d.ts +1 -0
- package/dist/render/transcripts/reduce.js +21 -21
- package/dist/render/transcripts/root-launcher.js +2 -12
- package/dist/render/transcripts/run.d.ts +3 -0
- package/dist/render/transcripts/run.js +30 -4
- package/dist/render/transcripts/spec.js +5 -8
- package/dist/render/transcripts/verify.d.ts +5 -3
- package/dist/render/transcripts/verify.js +44 -31
- package/dist/render/utils/duration.d.ts +5 -0
- package/dist/render/utils/duration.js +6 -0
- package/dist/render/utils/runs.d.ts +1 -0
- package/dist/render/utils/runs.js +1 -0
- package/dist/render/utils/transcript-shell.d.ts +2 -1
- package/dist/render/utils/transcript-shell.js +19 -6
- package/dist/utils/errors.d.ts +2 -1
- package/dist/utils/errors.js +3 -1
- package/dist/utils/git.d.ts +1 -1
- package/dist/utils/git.js +25 -2
- package/dist/utils/list-target.d.ts +4 -0
- package/dist/utils/list-target.js +35 -0
- package/dist/utils/terminal.d.ts +1 -0
- package/dist/utils/terminal.js +11 -0
- package/dist/workspace/chat/artifacts.d.ts +7 -0
- package/dist/workspace/chat/artifacts.js +94 -3
- package/dist/workspace/errors.js +2 -2
- package/dist/workspace/managed-state.d.ts +32 -0
- package/dist/workspace/managed-state.js +103 -0
- package/dist/workspace/setup.js +66 -2
- package/dist/workspace/shim.d.ts +1 -0
- package/dist/workspace/shim.js +3 -3
- package/dist/workspace/structure.d.ts +1 -0
- package/dist/workspace/structure.js +1 -0
- package/package.json +2 -2
- package/dist/cli/init.d.ts +0 -15
- package/dist/cli/init.js +0 -70
- package/dist/commands/init/agents.d.ts +0 -4
- package/dist/commands/init/command.d.ts +0 -2
- package/dist/commands/init/environment.d.ts +0 -2
- package/dist/render/transcripts/init.d.ts +0 -7
- package/dist/render/transcripts/init.js +0 -83
- /package/dist/commands/{init/types.js → doctor/fix-types.js} +0 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ListJsonArtifact, ListJsonChanges, ListJsonTargetRef, ListOperator } from "../../contracts/list.js";
|
|
2
|
+
import type { InteractiveSessionRecord } from "../../domain/interactive/model/types.js";
|
|
3
|
+
import type { MessageRecord } from "../../domain/message/model/types.js";
|
|
4
|
+
import type { ReductionRecord } from "../../domain/reduce/model/types.js";
|
|
5
|
+
import type { RunRecord } from "../../domain/run/model/types.js";
|
|
6
|
+
import type { SpecRecord } from "../../domain/spec/model/types.js";
|
|
7
|
+
import type { VerificationRecord } from "../../domain/verify/model/types.js";
|
|
8
|
+
export { formatTargetDisplay, formatTargetTablePreview, TARGET_TABLE_PREVIEW_LENGTH, } from "../../utils/list-target.js";
|
|
9
|
+
export type ListTargetOperator = ListOperator;
|
|
10
|
+
export type ListSessionTarget = {
|
|
11
|
+
kind: ListTargetOperator;
|
|
12
|
+
sessionId: string;
|
|
13
|
+
};
|
|
14
|
+
export type ListLaneTarget = {
|
|
15
|
+
kind: Exclude<ListTargetOperator, "interactive">;
|
|
16
|
+
sessionId: string;
|
|
17
|
+
agentId: string;
|
|
18
|
+
};
|
|
19
|
+
export type ListFileTarget = {
|
|
20
|
+
kind: "file";
|
|
21
|
+
path: string;
|
|
22
|
+
};
|
|
23
|
+
export type ListTarget = ListSessionTarget | ListLaneTarget | ListFileTarget;
|
|
24
|
+
export type ListOperatorRecord = InteractiveSessionRecord | RunRecord | SpecRecord | MessageRecord | ReductionRecord | VerificationRecord;
|
|
25
|
+
export interface NormalizedListSession {
|
|
26
|
+
operator: ListOperator;
|
|
27
|
+
sessionId: string;
|
|
28
|
+
status: string;
|
|
29
|
+
createdAt: string;
|
|
30
|
+
target?: ListTarget;
|
|
31
|
+
description?: string | null;
|
|
32
|
+
}
|
|
33
|
+
export interface NormalizedListAgent {
|
|
34
|
+
agentId: string | null;
|
|
35
|
+
status: string;
|
|
36
|
+
startedAt?: string;
|
|
37
|
+
completedAt?: string;
|
|
38
|
+
verifier?: string;
|
|
39
|
+
diffStatistics?: string;
|
|
40
|
+
changes?: ListJsonChanges;
|
|
41
|
+
outputPath?: string;
|
|
42
|
+
dataPath?: string;
|
|
43
|
+
errorLine?: string;
|
|
44
|
+
artifacts: ListJsonArtifact[];
|
|
45
|
+
}
|
|
46
|
+
export interface NormalizedListDetailSession extends NormalizedListSession {
|
|
47
|
+
startedAt?: string;
|
|
48
|
+
completedAt?: string;
|
|
49
|
+
workspacePath: string;
|
|
50
|
+
agents: NormalizedListAgent[];
|
|
51
|
+
}
|
|
52
|
+
export declare function normalizeListSession(operator: ListOperator, record: ListOperatorRecord): NormalizedListSession;
|
|
53
|
+
export declare function normalizeListDetailSession(operator: ListOperator, record: ListOperatorRecord): NormalizedListDetailSession;
|
|
54
|
+
export declare function normalizeListTarget(operator: ListOperator, record: ListOperatorRecord): ListTarget | undefined;
|
|
55
|
+
export declare function toListJsonTargetRef(target: ListTarget): ListJsonTargetRef;
|
|
56
|
+
export declare function normalizeDescription(description: string | null | undefined): string | null;
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { buildRunRecordEnhanced } from "../../domain/run/model/enhanced.js";
|
|
2
|
+
import { getInteractiveSessionDirectoryPath, getMessageSessionDirectoryPath, getReductionSessionDirectoryPath, getRunDirectoryPath, getSpecSessionDirectoryPath, getVerificationSessionDirectoryPath, } from "../../workspace/structure.js";
|
|
3
|
+
export { formatTargetDisplay, formatTargetTablePreview, TARGET_TABLE_PREVIEW_LENGTH, } from "../../utils/list-target.js";
|
|
4
|
+
const FILES_CHANGED_PATTERN = /(\d+)\s+file/u;
|
|
5
|
+
const INSERTIONS_PATTERN = /(\d+)\s+insertion/u;
|
|
6
|
+
const DELETIONS_PATTERN = /(\d+)\s+deletion/u;
|
|
7
|
+
export function normalizeListSession(operator, record) {
|
|
8
|
+
return {
|
|
9
|
+
operator,
|
|
10
|
+
sessionId: getRecordId(operator, record),
|
|
11
|
+
status: getRecordStatus(record),
|
|
12
|
+
createdAt: getRecordCreatedAt(record),
|
|
13
|
+
target: normalizeListTarget(operator, record),
|
|
14
|
+
...(operator === "spec"
|
|
15
|
+
? {
|
|
16
|
+
description: normalizeDescription(record.description),
|
|
17
|
+
}
|
|
18
|
+
: {}),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function normalizeListDetailSession(operator, record) {
|
|
22
|
+
const session = normalizeListSession(operator, record);
|
|
23
|
+
if (operator === "run") {
|
|
24
|
+
const runRecord = record;
|
|
25
|
+
const enhancedRunRecord = buildRunRecordEnhanced(runRecord);
|
|
26
|
+
return {
|
|
27
|
+
...session,
|
|
28
|
+
startedAt: runRecord.startedAt,
|
|
29
|
+
completedAt: runRecord.completedAt,
|
|
30
|
+
workspacePath: getRunDirectoryPath(runRecord.runId),
|
|
31
|
+
agents: enhancedRunRecord.agents.map((agent) => ({
|
|
32
|
+
agentId: agent.agentId,
|
|
33
|
+
status: agent.status,
|
|
34
|
+
startedAt: agent.startedAt,
|
|
35
|
+
completedAt: agent.completedAt,
|
|
36
|
+
diffStatistics: agent.diffStatistics,
|
|
37
|
+
changes: parseDiffStatistics(agent.diffStatistics),
|
|
38
|
+
outputPath: agent.assets.diffPath,
|
|
39
|
+
errorLine: agent.error ?? undefined,
|
|
40
|
+
artifacts: agent.assets.diffPath
|
|
41
|
+
? [
|
|
42
|
+
{
|
|
43
|
+
kind: "diff",
|
|
44
|
+
role: "output",
|
|
45
|
+
path: agent.assets.diffPath,
|
|
46
|
+
},
|
|
47
|
+
]
|
|
48
|
+
: [],
|
|
49
|
+
})),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
if (operator === "spec") {
|
|
53
|
+
const specRecord = record;
|
|
54
|
+
return {
|
|
55
|
+
...session,
|
|
56
|
+
startedAt: specRecord.startedAt,
|
|
57
|
+
completedAt: specRecord.completedAt,
|
|
58
|
+
workspacePath: getSpecSessionDirectoryPath(specRecord.sessionId),
|
|
59
|
+
agents: specRecord.agents.map((agent) => ({
|
|
60
|
+
agentId: agent.agentId,
|
|
61
|
+
status: agent.status,
|
|
62
|
+
startedAt: agent.startedAt,
|
|
63
|
+
completedAt: agent.completedAt,
|
|
64
|
+
outputPath: agent.outputPath,
|
|
65
|
+
dataPath: agent.dataPath,
|
|
66
|
+
errorLine: agent.error ?? undefined,
|
|
67
|
+
artifacts: [
|
|
68
|
+
...(agent.outputPath
|
|
69
|
+
? [
|
|
70
|
+
{
|
|
71
|
+
kind: "spec",
|
|
72
|
+
role: "output",
|
|
73
|
+
path: agent.outputPath,
|
|
74
|
+
},
|
|
75
|
+
]
|
|
76
|
+
: []),
|
|
77
|
+
...(agent.dataPath
|
|
78
|
+
? [
|
|
79
|
+
{
|
|
80
|
+
kind: "spec",
|
|
81
|
+
role: "data",
|
|
82
|
+
path: agent.dataPath,
|
|
83
|
+
},
|
|
84
|
+
]
|
|
85
|
+
: []),
|
|
86
|
+
],
|
|
87
|
+
})),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
if (operator === "reduce") {
|
|
91
|
+
const reductionRecord = record;
|
|
92
|
+
return {
|
|
93
|
+
...session,
|
|
94
|
+
startedAt: reductionRecord.startedAt,
|
|
95
|
+
completedAt: reductionRecord.completedAt,
|
|
96
|
+
workspacePath: getReductionSessionDirectoryPath(reductionRecord.sessionId),
|
|
97
|
+
agents: reductionRecord.reducers.map((reducer) => ({
|
|
98
|
+
agentId: reducer.agentId,
|
|
99
|
+
status: reducer.status,
|
|
100
|
+
startedAt: reducer.startedAt,
|
|
101
|
+
completedAt: reducer.completedAt,
|
|
102
|
+
outputPath: reducer.outputPath,
|
|
103
|
+
dataPath: reducer.dataPath,
|
|
104
|
+
errorLine: reducer.error ?? undefined,
|
|
105
|
+
artifacts: [
|
|
106
|
+
...(reducer.outputPath
|
|
107
|
+
? [
|
|
108
|
+
{
|
|
109
|
+
kind: "reduction",
|
|
110
|
+
role: "output",
|
|
111
|
+
path: reducer.outputPath,
|
|
112
|
+
},
|
|
113
|
+
]
|
|
114
|
+
: []),
|
|
115
|
+
...(reducer.dataPath
|
|
116
|
+
? [
|
|
117
|
+
{
|
|
118
|
+
kind: "reduction",
|
|
119
|
+
role: "data",
|
|
120
|
+
path: reducer.dataPath,
|
|
121
|
+
},
|
|
122
|
+
]
|
|
123
|
+
: []),
|
|
124
|
+
],
|
|
125
|
+
})),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
if (operator === "message") {
|
|
129
|
+
const messageRecord = record;
|
|
130
|
+
return {
|
|
131
|
+
...session,
|
|
132
|
+
startedAt: messageRecord.startedAt,
|
|
133
|
+
completedAt: messageRecord.completedAt,
|
|
134
|
+
workspacePath: getMessageSessionDirectoryPath(messageRecord.sessionId),
|
|
135
|
+
agents: messageRecord.recipients.map((recipient) => ({
|
|
136
|
+
agentId: recipient.agentId,
|
|
137
|
+
status: recipient.status,
|
|
138
|
+
startedAt: recipient.startedAt,
|
|
139
|
+
completedAt: recipient.completedAt,
|
|
140
|
+
outputPath: recipient.outputPath,
|
|
141
|
+
errorLine: recipient.error ?? undefined,
|
|
142
|
+
artifacts: recipient.outputPath
|
|
143
|
+
? [
|
|
144
|
+
{
|
|
145
|
+
kind: "response",
|
|
146
|
+
role: "output",
|
|
147
|
+
path: recipient.outputPath,
|
|
148
|
+
},
|
|
149
|
+
]
|
|
150
|
+
: [],
|
|
151
|
+
})),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
if (operator === "interactive") {
|
|
155
|
+
const interactiveRecord = record;
|
|
156
|
+
return {
|
|
157
|
+
...session,
|
|
158
|
+
workspacePath: getInteractiveSessionDirectoryPath(interactiveRecord.sessionId),
|
|
159
|
+
agents: [
|
|
160
|
+
{
|
|
161
|
+
agentId: interactiveRecord.agentId,
|
|
162
|
+
status: interactiveRecord.status,
|
|
163
|
+
outputPath: interactiveRecord.chat?.captured
|
|
164
|
+
? interactiveRecord.chat.artifactPath
|
|
165
|
+
: undefined,
|
|
166
|
+
artifacts: interactiveRecord.chat?.captured &&
|
|
167
|
+
interactiveRecord.chat.artifactPath
|
|
168
|
+
? [
|
|
169
|
+
{
|
|
170
|
+
kind: "chat",
|
|
171
|
+
role: "output",
|
|
172
|
+
path: interactiveRecord.chat.artifactPath,
|
|
173
|
+
},
|
|
174
|
+
]
|
|
175
|
+
: [],
|
|
176
|
+
},
|
|
177
|
+
],
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
const verificationRecord = record;
|
|
181
|
+
return {
|
|
182
|
+
...session,
|
|
183
|
+
startedAt: verificationRecord.startedAt,
|
|
184
|
+
completedAt: verificationRecord.completedAt,
|
|
185
|
+
workspacePath: getVerificationSessionDirectoryPath(verificationRecord.sessionId),
|
|
186
|
+
agents: verificationRecord.methods.map(normalizeVerificationMethod),
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
export function normalizeListTarget(operator, record) {
|
|
190
|
+
if (operator === "spec" || operator === "interactive") {
|
|
191
|
+
return undefined;
|
|
192
|
+
}
|
|
193
|
+
if (operator === "message") {
|
|
194
|
+
return normalizeMessageTarget(record);
|
|
195
|
+
}
|
|
196
|
+
if (operator === "run") {
|
|
197
|
+
return normalizeRunTarget(record);
|
|
198
|
+
}
|
|
199
|
+
if (operator === "reduce") {
|
|
200
|
+
const reductionRecord = record;
|
|
201
|
+
return {
|
|
202
|
+
kind: reductionRecord.target.type,
|
|
203
|
+
sessionId: reductionRecord.target.id,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
const verificationRecord = record;
|
|
207
|
+
return {
|
|
208
|
+
kind: verificationRecord.target.kind,
|
|
209
|
+
sessionId: verificationRecord.target.sessionId,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
export function toListJsonTargetRef(target) {
|
|
213
|
+
return target.kind === "file"
|
|
214
|
+
? target
|
|
215
|
+
: {
|
|
216
|
+
kind: target.kind,
|
|
217
|
+
sessionId: target.sessionId,
|
|
218
|
+
...("agentId" in target && target.agentId
|
|
219
|
+
? { agentId: target.agentId }
|
|
220
|
+
: {}),
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
export function normalizeDescription(description) {
|
|
224
|
+
if (typeof description !== "string") {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
const normalized = description.replace(/\s+/gu, " ").trim();
|
|
228
|
+
return normalized.length > 0 ? normalized : null;
|
|
229
|
+
}
|
|
230
|
+
function normalizeRunTarget(record) {
|
|
231
|
+
if (record.spec.target?.kind === "spec") {
|
|
232
|
+
return {
|
|
233
|
+
kind: "spec",
|
|
234
|
+
sessionId: record.spec.target.sessionId,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
return {
|
|
238
|
+
kind: "file",
|
|
239
|
+
path: record.spec.path,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
function normalizeMessageTarget(record) {
|
|
243
|
+
if (!record.target) {
|
|
244
|
+
return undefined;
|
|
245
|
+
}
|
|
246
|
+
if (record.target.agentId) {
|
|
247
|
+
return {
|
|
248
|
+
kind: record.target.kind,
|
|
249
|
+
sessionId: record.target.sessionId,
|
|
250
|
+
agentId: record.target.agentId,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
return {
|
|
254
|
+
kind: record.target.kind,
|
|
255
|
+
sessionId: record.target.sessionId,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
function normalizeVerificationMethod(method) {
|
|
259
|
+
return {
|
|
260
|
+
agentId: method.verifierId ?? null,
|
|
261
|
+
verifier: method.method === "programmatic"
|
|
262
|
+
? "programmatic"
|
|
263
|
+
: (method.template ?? "rubric"),
|
|
264
|
+
status: method.status,
|
|
265
|
+
startedAt: method.startedAt,
|
|
266
|
+
completedAt: method.completedAt,
|
|
267
|
+
outputPath: method.artifactPath,
|
|
268
|
+
errorLine: method.error ?? undefined,
|
|
269
|
+
artifacts: method.artifactPath
|
|
270
|
+
? [
|
|
271
|
+
{
|
|
272
|
+
kind: "verification-result",
|
|
273
|
+
role: "output",
|
|
274
|
+
path: method.artifactPath,
|
|
275
|
+
},
|
|
276
|
+
]
|
|
277
|
+
: [],
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
function parseDiffStatistics(value) {
|
|
281
|
+
if (!value) {
|
|
282
|
+
return undefined;
|
|
283
|
+
}
|
|
284
|
+
const filesChanged = extractStat(FILES_CHANGED_PATTERN, value);
|
|
285
|
+
const insertions = extractStat(INSERTIONS_PATTERN, value);
|
|
286
|
+
const deletions = extractStat(DELETIONS_PATTERN, value);
|
|
287
|
+
if (filesChanged === undefined &&
|
|
288
|
+
insertions === undefined &&
|
|
289
|
+
deletions === undefined) {
|
|
290
|
+
return undefined;
|
|
291
|
+
}
|
|
292
|
+
return {
|
|
293
|
+
...(filesChanged !== undefined ? { filesChanged } : {}),
|
|
294
|
+
...(insertions !== undefined ? { insertions } : {}),
|
|
295
|
+
...(deletions !== undefined ? { deletions } : {}),
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
function extractStat(pattern, input) {
|
|
299
|
+
const match = input.match(pattern);
|
|
300
|
+
if (!match) {
|
|
301
|
+
return undefined;
|
|
302
|
+
}
|
|
303
|
+
const parsed = Number.parseInt(match[1], 10);
|
|
304
|
+
return Number.isNaN(parsed) ? undefined : parsed;
|
|
305
|
+
}
|
|
306
|
+
function getRecordId(operator, record) {
|
|
307
|
+
if (operator === "run") {
|
|
308
|
+
return record.runId;
|
|
309
|
+
}
|
|
310
|
+
return record.sessionId;
|
|
311
|
+
}
|
|
312
|
+
function getRecordStatus(record) {
|
|
313
|
+
return record.status;
|
|
314
|
+
}
|
|
315
|
+
function getRecordCreatedAt(record) {
|
|
316
|
+
return record.createdAt;
|
|
317
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ResolvedExtraContextFile } from "../../competition/shared/extra-context.js";
|
|
2
2
|
import { type MessageCompetitionExecution } from "../../domain/message/competition/adapter.js";
|
|
3
|
-
import { type MessageRecipientEntry, type MessageRecord } from "../../domain/message/model/types.js";
|
|
3
|
+
import { type MessageRecipientEntry, type MessageRecord, type MessageTarget } from "../../domain/message/model/types.js";
|
|
4
4
|
import type { MessageProgressRenderer } from "../../render/transcripts/message.js";
|
|
5
5
|
export interface ExecuteMessageCommandInput {
|
|
6
6
|
root: string;
|
|
@@ -11,6 +11,7 @@ export interface ExecuteMessageCommandInput {
|
|
|
11
11
|
profileName?: string;
|
|
12
12
|
maxParallel?: number;
|
|
13
13
|
extraContextFiles?: readonly ResolvedExtraContextFile[];
|
|
14
|
+
target?: MessageTarget;
|
|
14
15
|
sourceInteractiveSessionId?: string;
|
|
15
16
|
renderer?: MessageProgressRenderer;
|
|
16
17
|
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { verifyAgentProviders } from "../../agents/runtime/auth.js";
|
|
2
1
|
import { executeCompetitionWithAdapter } from "../../competition/command-adapter.js";
|
|
3
2
|
import { createTeardownController } from "../../competition/shared/teardown.js";
|
|
4
3
|
import { AgentNotFoundError } from "../../configs/agents/errors.js";
|
|
5
|
-
import { loadEnvironmentConfig } from "../../configs/environment/loader.js";
|
|
6
4
|
import { createMessageCompetitionAdapter, } from "../../domain/message/competition/adapter.js";
|
|
7
5
|
import { createMessageRecordMutators } from "../../domain/message/model/mutators.js";
|
|
8
6
|
import { deriveMessageStatusFromRecipients, } from "../../domain/message/model/types.js";
|
|
9
7
|
import { appendMessageRecord, flushMessageRecordBuffer, } from "../../domain/message/persistence/adapter.js";
|
|
10
8
|
import { buildPersistedExtraContextFields } from "../../extra-context/contract.js";
|
|
9
|
+
import { loadOperatorEnvironment } from "../../preflight/environment.js";
|
|
10
|
+
import { prepareConfiguredOperatorReadiness } from "../../preflight/operator.js";
|
|
11
11
|
import { toErrorMessage } from "../../utils/errors.js";
|
|
12
12
|
import { getHeadRevision } from "../../utils/git.js";
|
|
13
13
|
import { VORATIQ_MESSAGE_DIR, VORATIQ_REDUCTION_DIR, VORATIQ_RUN_DIR, VORATIQ_SPEC_DIR, VORATIQ_VERIFICATION_DIR, } from "../../workspace/structure.js";
|
|
14
14
|
import { resolveEffectiveMaxParallel } from "../shared/max-parallel.js";
|
|
15
15
|
import { resolveStageCompetitors } from "../shared/resolve-stage-competitors.js";
|
|
16
16
|
import { generateSessionId } from "../shared/session-id.js";
|
|
17
|
-
import { MessageAgentNotFoundError, MessageGenerationFailedError, MessageInvocationContextError, } from "./errors.js";
|
|
17
|
+
import { MessageAgentNotFoundError, MessageGenerationFailedError, MessageInvocationContextError, MessagePreflightError, } from "./errors.js";
|
|
18
18
|
import { finalizeActiveMessage, registerActiveMessage } from "./lifecycle.js";
|
|
19
19
|
export async function executeMessageCommand(input) {
|
|
20
20
|
assertMessageInvocationContext();
|
|
21
|
-
const { root, messagesFilePath, prompt, agentIds, agentOverrideFlag, profileName, maxParallel: requestedMaxParallel, extraContextFiles = [], sourceInteractiveSessionId, renderer, } = input;
|
|
22
|
-
let
|
|
21
|
+
const { root, messagesFilePath, prompt, agentIds, agentOverrideFlag, profileName, maxParallel: requestedMaxParallel, extraContextFiles = [], target, sourceInteractiveSessionId, renderer, } = input;
|
|
22
|
+
let resolvedAgentIds;
|
|
23
23
|
try {
|
|
24
24
|
const resolution = resolveStageCompetitors({
|
|
25
25
|
root,
|
|
@@ -27,8 +27,9 @@ export async function executeMessageCommand(input) {
|
|
|
27
27
|
cliAgentIds: agentIds,
|
|
28
28
|
cliOverrideFlag: agentOverrideFlag,
|
|
29
29
|
profileName,
|
|
30
|
+
includeDefinitions: false,
|
|
30
31
|
});
|
|
31
|
-
|
|
32
|
+
resolvedAgentIds = resolution.agentIds;
|
|
32
33
|
}
|
|
33
34
|
catch (error) {
|
|
34
35
|
if (error instanceof AgentNotFoundError) {
|
|
@@ -36,12 +37,24 @@ export async function executeMessageCommand(input) {
|
|
|
36
37
|
}
|
|
37
38
|
throw error;
|
|
38
39
|
}
|
|
39
|
-
await
|
|
40
|
-
|
|
40
|
+
const preflight = await prepareConfiguredOperatorReadiness({
|
|
41
|
+
root,
|
|
42
|
+
resolvedAgentIds,
|
|
43
|
+
includeEnvironment: false,
|
|
44
|
+
});
|
|
45
|
+
if (preflight.issues.length > 0) {
|
|
46
|
+
throw new MessagePreflightError(preflight.issues, preflight.preProviderIssueCount);
|
|
47
|
+
}
|
|
48
|
+
const competitors = preflight.agents;
|
|
49
|
+
const environment = loadOperatorEnvironment({ root });
|
|
41
50
|
const baseRevisionSha = await getHeadRevision(root);
|
|
42
51
|
const messageId = generateSessionId();
|
|
43
52
|
const createdAt = new Date().toISOString();
|
|
44
53
|
const startedAt = createdAt;
|
|
54
|
+
const persistedTarget = resolveMessageTarget({
|
|
55
|
+
target,
|
|
56
|
+
sourceInteractiveSessionId,
|
|
57
|
+
});
|
|
45
58
|
const effectiveMaxParallel = resolveEffectiveMaxParallel({
|
|
46
59
|
competitorCount: competitors.length,
|
|
47
60
|
requestedMaxParallel,
|
|
@@ -62,6 +75,7 @@ export async function executeMessageCommand(input) {
|
|
|
62
75
|
prompt,
|
|
63
76
|
recipients: initialRecipients,
|
|
64
77
|
...buildPersistedExtraContextFields(extraContextFiles),
|
|
78
|
+
...(persistedTarget ? { target: persistedTarget } : {}),
|
|
65
79
|
...(sourceInteractiveSessionId ? { sourceInteractiveSessionId } : {}),
|
|
66
80
|
},
|
|
67
81
|
});
|
|
@@ -187,12 +201,6 @@ function toRecipientEntry(execution) {
|
|
|
187
201
|
error: execution.error ?? null,
|
|
188
202
|
};
|
|
189
203
|
}
|
|
190
|
-
async function assertMessagePreflight(agents) {
|
|
191
|
-
const providerIssues = await verifyAgentProviders(agents.map((agent) => ({ id: agent.id, provider: agent.provider })));
|
|
192
|
-
if (providerIssues.length > 0) {
|
|
193
|
-
throw new MessageGenerationFailedError(providerIssues.map((issue) => `${issue.agentId}: ${issue.message}`));
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
204
|
function assertMessageInvocationContext() {
|
|
197
205
|
const cwd = process.cwd().replace(/\\/gu, "/");
|
|
198
206
|
const batchDomains = [
|
|
@@ -213,3 +221,16 @@ function collectRecipientErrors(recipients) {
|
|
|
213
221
|
.map((recipient) => `${recipient.agentId}: ${recipient.error}`);
|
|
214
222
|
return details.length > 0 ? details.join("; ") : undefined;
|
|
215
223
|
}
|
|
224
|
+
function resolveMessageTarget(options) {
|
|
225
|
+
const { target, sourceInteractiveSessionId } = options;
|
|
226
|
+
if (target) {
|
|
227
|
+
return target;
|
|
228
|
+
}
|
|
229
|
+
if (sourceInteractiveSessionId) {
|
|
230
|
+
return {
|
|
231
|
+
kind: "interactive",
|
|
232
|
+
sessionId: sourceInteractiveSessionId,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
return undefined;
|
|
236
|
+
}
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import { CliError } from "../../cli/errors.js";
|
|
2
|
+
import type { PreflightIssue } from "../../competition/shared/preflight.js";
|
|
3
|
+
export declare class MessageError extends CliError {
|
|
4
|
+
constructor(headline: string, detailLines?: readonly string[], hintLines?: readonly string[]);
|
|
5
|
+
}
|
|
6
|
+
export declare class MessageAgentNotFoundError extends MessageError {
|
|
2
7
|
constructor(agentId: string);
|
|
3
8
|
}
|
|
4
|
-
export declare class MessageGenerationFailedError extends
|
|
9
|
+
export declare class MessageGenerationFailedError extends MessageError {
|
|
5
10
|
constructor(details: readonly string[]);
|
|
6
11
|
}
|
|
7
|
-
export declare class
|
|
12
|
+
export declare class MessagePreflightError extends MessageError {
|
|
13
|
+
readonly issues: readonly PreflightIssue[];
|
|
14
|
+
constructor(issues: readonly PreflightIssue[], preProviderIssueCount: number);
|
|
15
|
+
}
|
|
16
|
+
export declare class MessageInvocationContextError extends MessageError {
|
|
8
17
|
constructor();
|
|
9
18
|
}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import { CliError } from "../../cli/errors.js";
|
|
2
|
+
import { formatOperatorPreflightIssueLines, resolveOperatorPreflightHintLines, } from "../../preflight/formatting.js";
|
|
3
|
+
export class MessageError extends CliError {
|
|
4
|
+
constructor(headline, detailLines = [], hintLines = []) {
|
|
5
|
+
super(headline, detailLines, hintLines);
|
|
6
|
+
this.name = "MessageError";
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export class MessageAgentNotFoundError extends MessageError {
|
|
2
10
|
constructor(agentId) {
|
|
3
11
|
super(`Message agent not found: ${agentId}`);
|
|
4
12
|
this.name = "MessageAgentNotFoundError";
|
|
5
13
|
}
|
|
6
14
|
}
|
|
7
|
-
export class MessageGenerationFailedError extends
|
|
15
|
+
export class MessageGenerationFailedError extends MessageError {
|
|
8
16
|
constructor(details) {
|
|
9
17
|
super(details.length > 0
|
|
10
18
|
? `Message execution failed: ${details.join("; ")}`
|
|
@@ -12,7 +20,15 @@ export class MessageGenerationFailedError extends Error {
|
|
|
12
20
|
this.name = "MessageGenerationFailedError";
|
|
13
21
|
}
|
|
14
22
|
}
|
|
15
|
-
export class
|
|
23
|
+
export class MessagePreflightError extends MessageError {
|
|
24
|
+
issues;
|
|
25
|
+
constructor(issues, preProviderIssueCount) {
|
|
26
|
+
super("Preflight failed. Aborting message.", formatOperatorPreflightIssueLines(issues), resolveOperatorPreflightHintLines(issues, preProviderIssueCount) ?? []);
|
|
27
|
+
this.issues = Array.from(issues);
|
|
28
|
+
this.name = "MessagePreflightError";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export class MessageInvocationContextError extends MessageError {
|
|
16
32
|
constructor() {
|
|
17
33
|
super("`message` cannot be invoked from inside a batch agent workspace.");
|
|
18
34
|
this.name = "MessageInvocationContextError";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { verifyAgentProviders } from "../../agents/runtime/auth.js";
|
|
2
1
|
import { executeCompetitionWithAdapter } from "../../competition/command-adapter.js";
|
|
3
2
|
import { AgentNotFoundError } from "../../configs/agents/errors.js";
|
|
4
|
-
import { loadEnvironmentConfig } from "../../configs/environment/loader.js";
|
|
5
3
|
import { createReduceCompetitionAdapter, } from "../../domain/reduce/competition/adapter.js";
|
|
6
4
|
import { flushReductionRecordBuffer, readReductionRecords, } from "../../domain/reduce/persistence/adapter.js";
|
|
5
|
+
import { loadOperatorEnvironment } from "../../preflight/environment.js";
|
|
6
|
+
import { prepareConfiguredOperatorReadiness } from "../../preflight/operator.js";
|
|
7
7
|
import { toErrorMessage } from "../../utils/errors.js";
|
|
8
8
|
import { resolveEffectiveMaxParallel } from "../shared/max-parallel.js";
|
|
9
9
|
import { resolveReductionCompetitors } from "../shared/resolve-reduction-competitors.js";
|
|
@@ -21,14 +21,22 @@ export async function executeReduceCommand(input) {
|
|
|
21
21
|
verificationsFilePath,
|
|
22
22
|
target,
|
|
23
23
|
});
|
|
24
|
-
const
|
|
24
|
+
const reducerPlan = resolveReduceAgentPlan({
|
|
25
25
|
root,
|
|
26
26
|
agentIds,
|
|
27
27
|
agentOverrideFlag,
|
|
28
28
|
profileName,
|
|
29
29
|
});
|
|
30
|
-
await
|
|
31
|
-
|
|
30
|
+
const preflight = await prepareConfiguredOperatorReadiness({
|
|
31
|
+
root,
|
|
32
|
+
resolvedAgentIds: reducerPlan.agentIds,
|
|
33
|
+
includeEnvironment: false,
|
|
34
|
+
});
|
|
35
|
+
if (preflight.issues.length > 0) {
|
|
36
|
+
throw new ReducePreflightError(preflight.issues, preflight.preProviderIssueCount);
|
|
37
|
+
}
|
|
38
|
+
const reducers = preflight.agents;
|
|
39
|
+
const environment = loadOperatorEnvironment({ root });
|
|
32
40
|
const reductionId = generateSessionId();
|
|
33
41
|
const createdAt = new Date().toISOString();
|
|
34
42
|
const effectiveMaxParallel = resolveEffectiveMaxParallel({
|
|
@@ -106,16 +114,16 @@ export async function executeReduceCommand(input) {
|
|
|
106
114
|
reductions: reductionResults,
|
|
107
115
|
};
|
|
108
116
|
}
|
|
109
|
-
function
|
|
117
|
+
function resolveReduceAgentPlan(options) {
|
|
110
118
|
const { agentIds, root, agentOverrideFlag, profileName } = options;
|
|
111
119
|
try {
|
|
112
|
-
|
|
120
|
+
return resolveReductionCompetitors({
|
|
113
121
|
root,
|
|
114
122
|
cliAgentIds: agentIds,
|
|
115
123
|
cliOverrideFlag: agentOverrideFlag,
|
|
116
124
|
profileName,
|
|
125
|
+
includeDefinitions: false,
|
|
117
126
|
});
|
|
118
|
-
return [...resolution.competitors];
|
|
119
127
|
}
|
|
120
128
|
catch (error) {
|
|
121
129
|
if (error instanceof AgentNotFoundError) {
|
|
@@ -124,15 +132,6 @@ function resolveReduceAgents(options) {
|
|
|
124
132
|
throw error;
|
|
125
133
|
}
|
|
126
134
|
}
|
|
127
|
-
async function assertReducePreflight(agents) {
|
|
128
|
-
const providerIssues = await verifyAgentProviders(agents.map((agent) => ({
|
|
129
|
-
id: agent.id,
|
|
130
|
-
provider: agent.provider,
|
|
131
|
-
})));
|
|
132
|
-
if (providerIssues.length > 0) {
|
|
133
|
-
throw new ReducePreflightError(providerIssues, []);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
135
|
async function readReductionSessionRecord(options) {
|
|
137
136
|
const { root, reductionsFilePath, reductionId } = options;
|
|
138
137
|
const records = await readReductionRecords({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CliError } from "../../cli/errors.js";
|
|
2
|
-
import {
|
|
2
|
+
import type { PreflightIssue } from "../../competition/shared/preflight.js";
|
|
3
3
|
export type ReducePreflightIssue = PreflightIssue;
|
|
4
4
|
export declare class ReduceError extends CliError {
|
|
5
5
|
constructor(headline: string, detailLines?: readonly string[], hintLines?: readonly string[]);
|
|
@@ -10,7 +10,7 @@ export declare class ReduceAgentNotFoundError extends ReduceError {
|
|
|
10
10
|
}
|
|
11
11
|
export declare class ReducePreflightError extends ReduceError {
|
|
12
12
|
readonly issues: readonly ReducePreflightIssue[];
|
|
13
|
-
constructor(issues: readonly ReducePreflightIssue[],
|
|
13
|
+
constructor(issues: readonly ReducePreflightIssue[], preProviderIssueCount?: number);
|
|
14
14
|
}
|
|
15
15
|
export declare class ReduceGenerationFailedError extends ReduceError {
|
|
16
16
|
constructor(detailLines?: readonly string[]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CliError } from "../../cli/errors.js";
|
|
2
|
-
import {
|
|
2
|
+
import { formatOperatorPreflightIssueLines, resolveOperatorPreflightHintLines, } from "../../preflight/formatting.js";
|
|
3
3
|
export class ReduceError extends CliError {
|
|
4
4
|
constructor(headline, detailLines = [], hintLines) {
|
|
5
5
|
super(headline, detailLines, hintLines);
|
|
@@ -16,8 +16,8 @@ export class ReduceAgentNotFoundError extends ReduceError {
|
|
|
16
16
|
}
|
|
17
17
|
export class ReducePreflightError extends ReduceError {
|
|
18
18
|
issues;
|
|
19
|
-
constructor(issues,
|
|
20
|
-
super("Preflight failed. Aborting reduction.",
|
|
19
|
+
constructor(issues, preProviderIssueCount = issues.length) {
|
|
20
|
+
super("Preflight failed. Aborting reduction.", formatOperatorPreflightIssueLines(issues), resolveOperatorPreflightHintLines(issues, preProviderIssueCount) ?? []);
|
|
21
21
|
this.issues = Array.from(issues);
|
|
22
22
|
this.name = "ReducePreflightError";
|
|
23
23
|
}
|