voratiq 0.1.0-beta.21 → 0.1.0-beta.23

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.
Files changed (222) hide show
  1. package/README.md +19 -23
  2. package/dist/agents/launch/chat.d.ts +3 -1
  3. package/dist/agents/launch/chat.js +2 -0
  4. package/dist/agents/runtime/policy.js +2 -1
  5. package/dist/auth/providers/utils.js +1 -1
  6. package/dist/bin.js +28 -7
  7. package/dist/cli/auto.js +4 -16
  8. package/dist/cli/contract.d.ts +26 -17
  9. package/dist/cli/contract.js +3 -1
  10. package/dist/cli/doctor.d.ts +12 -0
  11. package/dist/cli/doctor.js +115 -0
  12. package/dist/cli/list.js +5 -1
  13. package/dist/cli/message.js +16 -11
  14. package/dist/cli/operator-envelope.d.ts +27 -7
  15. package/dist/cli/operator-envelope.js +95 -3
  16. package/dist/cli/option-parsers.d.ts +2 -0
  17. package/dist/cli/option-parsers.js +7 -0
  18. package/dist/cli/output.d.ts +1 -5
  19. package/dist/cli/reduce.js +5 -13
  20. package/dist/cli/run.js +5 -12
  21. package/dist/cli/spec.js +4 -10
  22. package/dist/cli/verify.d.ts +1 -1
  23. package/dist/cli/verify.js +51 -22
  24. package/dist/commands/auto/command.d.ts +1 -0
  25. package/dist/commands/auto/command.js +22 -15
  26. package/dist/commands/auto/errors.js +1 -1
  27. package/dist/commands/auto/validation.js +3 -1
  28. package/dist/commands/doctor/agents.d.ts +5 -0
  29. package/dist/commands/{init → doctor}/agents.js +40 -20
  30. package/dist/commands/doctor/command.d.ts +22 -0
  31. package/dist/commands/doctor/command.js +100 -0
  32. package/dist/commands/doctor/environment.d.ts +2 -0
  33. package/dist/commands/{init → doctor}/environment.js +41 -7
  34. package/dist/commands/{init/types.d.ts → doctor/fix-types.d.ts} +30 -9
  35. package/dist/commands/doctor/fix.d.ts +2 -0
  36. package/dist/commands/{init/command.js → doctor/fix.js} +109 -11
  37. package/dist/commands/doctor/reconcile.d.ts +2 -0
  38. package/dist/commands/doctor/reconcile.js +103 -0
  39. package/dist/commands/interactive/lifecycle.d.ts +2 -0
  40. package/dist/commands/interactive/lifecycle.js +16 -0
  41. package/dist/commands/list/command.d.ts +1 -0
  42. package/dist/commands/list/command.js +241 -361
  43. package/dist/commands/list/normalization.d.ts +51 -0
  44. package/dist/commands/list/normalization.js +309 -0
  45. package/dist/commands/list/records.d.ts +9 -0
  46. package/dist/commands/list/records.js +6 -0
  47. package/dist/commands/message/command.d.ts +2 -2
  48. package/dist/commands/message/command.js +29 -16
  49. package/dist/commands/message/errors.d.ts +12 -3
  50. package/dist/commands/message/errors.js +19 -3
  51. package/dist/commands/prune/command.js +4 -1
  52. package/dist/commands/reduce/command.js +16 -17
  53. package/dist/commands/reduce/errors.d.ts +2 -2
  54. package/dist/commands/reduce/errors.js +3 -3
  55. package/dist/commands/reduce/targets.js +12 -3
  56. package/dist/commands/root-launcher/command.js +12 -6
  57. package/dist/commands/run/command.d.ts +1 -0
  58. package/dist/commands/run/command.js +4 -1
  59. package/dist/commands/run/record-init.d.ts +2 -0
  60. package/dist/commands/run/record-init.js +8 -1
  61. package/dist/commands/run/spec-provenance.d.ts +37 -0
  62. package/dist/commands/run/spec-provenance.js +384 -0
  63. package/dist/commands/run/validation.d.ts +4 -0
  64. package/dist/commands/run/validation.js +25 -62
  65. package/dist/commands/shared/resolve-stage-competitors.js +2 -1
  66. package/dist/commands/spec/command.js +64 -138
  67. package/dist/commands/spec/errors.d.ts +5 -0
  68. package/dist/commands/spec/errors.js +9 -0
  69. package/dist/commands/verify/agents.d.ts +4 -2
  70. package/dist/commands/verify/agents.js +4 -11
  71. package/dist/commands/verify/command.js +23 -6
  72. package/dist/commands/verify/errors.d.ts +12 -0
  73. package/dist/commands/verify/errors.js +22 -0
  74. package/dist/commands/verify/lifecycle.js +1 -1
  75. package/dist/commands/verify/targets.js +108 -12
  76. package/dist/competition/shared/preflight.d.ts +1 -1
  77. package/dist/competition/shared/preflight.js +15 -2
  78. package/dist/competition/shared/teardown.d.ts +7 -0
  79. package/dist/competition/shared/teardown.js +6 -0
  80. package/dist/configs/agents/defaults.js +13 -44
  81. package/dist/configs/agents/loader.js +1 -1
  82. package/dist/configs/environment/loader.js +2 -1
  83. package/dist/configs/orchestration/loader.js +2 -1
  84. package/dist/configs/sandbox/loader.js +2 -1
  85. package/dist/configs/settings/loader.js +1 -1
  86. package/dist/configs/verification/loader.js +2 -1
  87. package/dist/contracts/list.d.ts +129 -149
  88. package/dist/contracts/list.js +47 -99
  89. package/dist/domain/interactive/model/types.d.ts +2 -0
  90. package/dist/domain/interactive/model/types.js +16 -1
  91. package/dist/domain/interactive/persistence/adapter.d.ts +23 -0
  92. package/dist/domain/interactive/persistence/adapter.js +67 -5
  93. package/dist/domain/interactive/prompt.d.ts +1 -1
  94. package/dist/domain/interactive/prompt.js +1 -1
  95. package/dist/domain/interactive/session-env.d.ts +10 -0
  96. package/dist/domain/interactive/session-env.js +25 -0
  97. package/dist/domain/message/competition/adapter.js +3 -9
  98. package/dist/domain/message/model/types.d.ts +32 -1
  99. package/dist/domain/message/model/types.js +25 -1
  100. package/dist/domain/reduce/competition/adapter.js +30 -16
  101. package/dist/domain/reduce/competition/finalize.d.ts +7 -0
  102. package/dist/domain/reduce/competition/finalize.js +19 -0
  103. package/dist/domain/reduce/model/types.d.ts +3 -3
  104. package/dist/domain/run/competition/agents/artifacts.js +4 -2
  105. package/dist/domain/run/competition/agents/lifecycle.js +1 -1
  106. package/dist/domain/run/competition/agents/workspace.js +2 -1
  107. package/dist/domain/run/competition/errors.d.ts +1 -1
  108. package/dist/domain/run/competition/errors.js +4 -7
  109. package/dist/domain/run/competition/reports.js +2 -1
  110. package/dist/domain/run/model/enhanced.d.ts +1 -1
  111. package/dist/domain/run/model/enhanced.js +2 -1
  112. package/dist/domain/run/model/types.d.ts +384 -0
  113. package/dist/domain/run/model/types.js +87 -0
  114. package/dist/domain/spec/competition/adapter.d.ts +1 -0
  115. package/dist/domain/spec/competition/adapter.js +9 -10
  116. package/dist/domain/spec/model/mutators.d.ts +20 -0
  117. package/dist/domain/spec/model/mutators.js +146 -0
  118. package/dist/domain/spec/model/types.d.ts +3 -0
  119. package/dist/domain/spec/model/types.js +5 -0
  120. package/dist/domain/spec/persistence/adapter.d.ts +1 -0
  121. package/dist/domain/spec/persistence/adapter.js +7 -2
  122. package/dist/domain/verify/competition/adapter.d.ts +1 -1
  123. package/dist/domain/verify/competition/adapter.js +4 -9
  124. package/dist/domain/verify/competition/finalize.d.ts +9 -0
  125. package/dist/domain/verify/competition/finalize.js +22 -3
  126. package/dist/domain/verify/competition/programmatic.js +2 -1
  127. package/dist/domain/verify/competition/prompt.js +1 -1
  128. package/dist/domain/verify/competition/shared-layout.js +1 -1
  129. package/dist/domain/verify/model/types.d.ts +2 -2
  130. package/dist/interactive/providers/launch.d.ts +2 -0
  131. package/dist/interactive/providers/launch.js +19 -2
  132. package/dist/interactive/providers/mcp.d.ts +1 -0
  133. package/dist/interactive/providers/mcp.js +45 -7
  134. package/dist/interactive/substrate.js +32 -5
  135. package/dist/mcp/server.d.ts +1 -0
  136. package/dist/mcp/server.js +337 -44
  137. package/dist/policy/auto.d.ts +0 -1
  138. package/dist/policy/auto.js +3 -14
  139. package/dist/policy/verification.js +18 -1
  140. package/dist/preflight/agents.d.ts +24 -0
  141. package/dist/preflight/agents.js +71 -0
  142. package/dist/preflight/environment.d.ts +6 -0
  143. package/dist/preflight/environment.js +17 -0
  144. package/dist/preflight/formatting.d.ts +5 -0
  145. package/dist/preflight/formatting.js +20 -0
  146. package/dist/preflight/index.d.ts +2 -0
  147. package/dist/preflight/index.js +6 -9
  148. package/dist/preflight/operator.d.ts +32 -0
  149. package/dist/preflight/operator.js +40 -0
  150. package/dist/preflight/settings.d.ts +2 -0
  151. package/dist/preflight/settings.js +17 -0
  152. package/dist/render/transcripts/apply.js +2 -1
  153. package/dist/render/transcripts/interactive.d.ts +16 -0
  154. package/dist/render/transcripts/interactive.js +42 -0
  155. package/dist/render/transcripts/list.d.ts +41 -0
  156. package/dist/render/transcripts/list.js +152 -3
  157. package/dist/render/transcripts/message.d.ts +3 -5
  158. package/dist/render/transcripts/message.js +29 -74
  159. package/dist/render/transcripts/reduce.d.ts +2 -4
  160. package/dist/render/transcripts/reduce.js +31 -75
  161. package/dist/render/transcripts/root-launcher.js +2 -12
  162. package/dist/render/transcripts/run.d.ts +4 -4
  163. package/dist/render/transcripts/run.js +36 -47
  164. package/dist/render/transcripts/spec.d.ts +1 -4
  165. package/dist/render/transcripts/spec.js +15 -62
  166. package/dist/render/transcripts/verify.d.ts +6 -7
  167. package/dist/render/transcripts/verify.js +54 -85
  168. package/dist/render/utils/cli-writer.d.ts +4 -0
  169. package/dist/render/utils/cli-writer.js +1 -0
  170. package/dist/render/utils/duration.d.ts +5 -0
  171. package/dist/render/utils/duration.js +6 -0
  172. package/dist/render/utils/progressive-render.d.ts +3 -0
  173. package/dist/render/utils/progressive-render.js +44 -0
  174. package/dist/render/utils/runs.d.ts +1 -0
  175. package/dist/render/utils/runs.js +1 -0
  176. package/dist/render/utils/transcript-shell.d.ts +2 -1
  177. package/dist/render/utils/transcript-shell.js +19 -6
  178. package/dist/utils/diff.d.ts +2 -0
  179. package/dist/utils/diff.js +1 -0
  180. package/dist/utils/errors.d.ts +2 -1
  181. package/dist/utils/errors.js +3 -1
  182. package/dist/utils/git.d.ts +1 -1
  183. package/dist/utils/git.js +25 -2
  184. package/dist/utils/list-target.d.ts +4 -0
  185. package/dist/utils/list-target.js +35 -0
  186. package/dist/utils/swarm-session-ack.d.ts +9 -0
  187. package/dist/utils/swarm-session-ack.js +17 -0
  188. package/dist/utils/terminal.d.ts +1 -0
  189. package/dist/utils/terminal.js +11 -0
  190. package/dist/workspace/artifact-paths.d.ts +55 -0
  191. package/dist/workspace/artifact-paths.js +106 -0
  192. package/dist/workspace/chat/artifacts.d.ts +7 -0
  193. package/dist/workspace/chat/artifacts.js +95 -4
  194. package/dist/workspace/chat/native-usage.js +1 -1
  195. package/dist/workspace/chat/sources.d.ts +2 -5
  196. package/dist/workspace/chat/sources.js +4 -4
  197. package/dist/workspace/constants.d.ts +47 -0
  198. package/dist/workspace/constants.js +47 -0
  199. package/dist/workspace/errors.js +2 -2
  200. package/dist/workspace/layout.js +3 -1
  201. package/dist/workspace/managed-state.d.ts +32 -0
  202. package/dist/workspace/managed-state.js +104 -0
  203. package/dist/workspace/path-formatters.d.ts +9 -0
  204. package/dist/workspace/path-formatters.js +46 -0
  205. package/dist/workspace/path-resolvers.d.ts +1 -0
  206. package/dist/workspace/path-resolvers.js +5 -0
  207. package/dist/workspace/session-paths.d.ts +16 -0
  208. package/dist/workspace/session-paths.js +59 -0
  209. package/dist/workspace/setup.js +67 -2
  210. package/dist/workspace/shim.d.ts +1 -0
  211. package/dist/workspace/shim.js +3 -3
  212. package/package.json +2 -2
  213. package/dist/cli/init.d.ts +0 -15
  214. package/dist/cli/init.js +0 -70
  215. package/dist/commands/init/agents.d.ts +0 -4
  216. package/dist/commands/init/command.d.ts +0 -2
  217. package/dist/commands/init/environment.d.ts +0 -2
  218. package/dist/render/transcripts/init.d.ts +0 -7
  219. package/dist/render/transcripts/init.js +0 -83
  220. package/dist/workspace/structure.d.ts +0 -143
  221. package/dist/workspace/structure.js +0 -319
  222. /package/dist/commands/{init/types.js → doctor/fix-types.js} +0 -0
@@ -1,86 +1,49 @@
1
- import { readFile } from "node:fs/promises";
2
- import { verifyAgentProviders } from "../../agents/runtime/auth.js";
3
- import { loadAgentCatalogDiagnostics } from "../../configs/agents/loader.js";
4
- import { EnvironmentConfigParseError, MissingEnvironmentConfigError, } from "../../configs/environment/errors.js";
5
- import { DEFAULT_ENVIRONMENT_FILE_DISPLAY, loadEnvironmentConfig, } from "../../configs/environment/loader.js";
6
- import { loadRepoSettings } from "../../configs/settings/loader.js";
7
1
  import { NoAgentsEnabledError, RunPreflightError, } from "../../domain/run/competition/errors.js";
8
2
  import { RunOptionValidationError } from "../../domain/run/model/errors.js";
9
- import { toErrorMessage } from "../../utils/errors.js";
3
+ import { loadOperatorEnvironment } from "../../preflight/environment.js";
4
+ import { prepareConfiguredOperatorReadiness } from "../../preflight/operator.js";
10
5
  import { getHeadRevision } from "../../utils/git.js";
11
- import { WorkspaceMissingEntryError } from "../../workspace/errors.js";
12
6
  import { resolveEffectiveMaxParallel } from "../shared/max-parallel.js";
7
+ import { loadRunSpecInput } from "./spec-provenance.js";
13
8
  /**
14
9
  * Validate command parameters, load spec, and prepare execution prerequisites.
15
10
  */
16
11
  export async function validateAndPrepare(input) {
17
- const { root, specAbsolutePath, resolvedAgentIds, maxParallel: requestedMaxParallel, } = input;
12
+ const { root, specAbsolutePath, specDisplayPath, specsFilePath, resolvedAgentIds, maxParallel: requestedMaxParallel, } = input;
18
13
  if (requestedMaxParallel !== undefined &&
19
14
  (!Number.isInteger(requestedMaxParallel) || requestedMaxParallel <= 0)) {
20
15
  throw new RunOptionValidationError("maxParallel", "must be a positive integer");
21
16
  }
22
- const specContent = await readFile(specAbsolutePath, "utf8");
17
+ const { specContent, specTarget } = await loadRunSpecInput({
18
+ root,
19
+ specAbsolutePath,
20
+ specDisplayPath: specDisplayPath ?? specAbsolutePath,
21
+ specsFilePath,
22
+ });
23
23
  const baseRevisionSha = await getHeadRevision(root);
24
- const preflightIssues = [];
25
- let agents;
26
- if (resolvedAgentIds) {
27
- if (resolvedAgentIds.length === 0) {
28
- throw new NoAgentsEnabledError();
29
- }
30
- const selectedAgentIds = new Set(resolvedAgentIds);
31
- const agentDiagnostics = loadAgentCatalogDiagnostics({ root });
32
- preflightIssues.push(...agentDiagnostics.issues.filter((issue) => selectedAgentIds.has(issue.agentId)));
33
- const catalogById = new Map(agentDiagnostics.catalog.map((agent) => [agent.id, agent]));
34
- agents = resolvedAgentIds.flatMap((agentId) => {
35
- const agent = catalogById.get(agentId);
36
- return agent ? [agent] : [];
37
- });
38
- }
39
- else {
40
- const agentDiagnostics = loadAgentCatalogDiagnostics({ root });
41
- const enabledAgents = agentDiagnostics.enabledAgents;
42
- if (enabledAgents.length === 0) {
43
- throw new NoAgentsEnabledError();
44
- }
45
- preflightIssues.push(...agentDiagnostics.issues);
46
- agents = agentDiagnostics.catalog;
47
- }
48
- try {
49
- loadRepoSettings({ root });
50
- }
51
- catch (error) {
52
- preflightIssues.push({
53
- agentId: "settings",
54
- message: toErrorMessage(error),
55
- });
24
+ const preflight = await prepareConfiguredOperatorReadiness({
25
+ root,
26
+ resolvedAgentIds,
27
+ includeEnvironment: false,
28
+ });
29
+ if (preflight.noAgentsEnabled) {
30
+ throw new NoAgentsEnabledError();
56
31
  }
57
- const preProviderIssueCount = preflightIssues.length;
58
- const providerIssues = await verifyAgentProviders(agents.map((agent) => ({
59
- id: agent.id,
60
- provider: agent.provider,
61
- })));
62
- preflightIssues.push(...providerIssues);
63
- if (preflightIssues.length > 0) {
64
- throw new RunPreflightError(preflightIssues, preProviderIssueCount === 0 ? [] : undefined);
32
+ if (preflight.issues.length > 0) {
33
+ throw new RunPreflightError(preflight.issues, preflight.preProviderIssueCount);
65
34
  }
66
- const environment = (() => {
67
- try {
68
- return loadEnvironmentConfig({ root });
69
- }
70
- catch (error) {
71
- if (error instanceof MissingEnvironmentConfigError ||
72
- error instanceof EnvironmentConfigParseError) {
73
- throw new WorkspaceMissingEntryError(DEFAULT_ENVIRONMENT_FILE_DISPLAY);
74
- }
75
- throw error;
76
- }
77
- })();
35
+ const agents = preflight.agents;
36
+ const environment = loadOperatorEnvironment({
37
+ root,
38
+ errorMode: "workspace-missing",
39
+ });
78
40
  const effectiveMaxParallel = resolveEffectiveMaxParallel({
79
41
  competitorCount: agents.length,
80
42
  requestedMaxParallel,
81
43
  });
82
44
  return {
83
45
  specContent,
46
+ specTarget,
84
47
  baseRevisionSha,
85
48
  agents,
86
49
  effectiveMaxParallel,
@@ -4,7 +4,8 @@ import { loadAgentById } from "../../configs/agents/loader.js";
4
4
  import { loadOrchestrationConfig } from "../../configs/orchestration/loader.js";
5
5
  import { HintedError } from "../../utils/errors.js";
6
6
  import { readUtf8File } from "../../utils/fs.js";
7
- import { resolveWorkspacePath, VORATIQ_AGENTS_FILE, VORATIQ_ORCHESTRATION_FILE, } from "../../workspace/structure.js";
7
+ import { VORATIQ_AGENTS_FILE, VORATIQ_ORCHESTRATION_FILE, } from "../../workspace/constants.js";
8
+ import { resolveWorkspacePath } from "../../workspace/path-resolvers.js";
8
9
  const ORCHESTRATION_CONFIG_DISPLAY_PATH = VORATIQ_ORCHESTRATION_FILE;
9
10
  const DEFAULT_PROFILE_NAME = "default";
10
11
  export function resolveStageCompetitors(input) {
@@ -1,20 +1,22 @@
1
1
  import { executeCompetitionWithAdapter } from "../../competition/command-adapter.js";
2
2
  import { AgentNotFoundError } from "../../configs/agents/errors.js";
3
- import { loadEnvironmentConfig } from "../../configs/environment/loader.js";
4
- import { buildLifecycleStartFields, buildOperationLifecycleCompleteFields, } from "../../domain/shared/lifecycle.js";
5
3
  import { createSpecCompetitionAdapter, } from "../../domain/spec/competition/adapter.js";
4
+ import { createSpecRecordMutators } from "../../domain/spec/model/mutators.js";
6
5
  import { deriveSpecStatusFromAgents, } from "../../domain/spec/model/types.js";
7
- import { appendSpecRecord, finalizeSpecRecord, flushSpecRecordBuffer, rewriteSpecRecord, } from "../../domain/spec/persistence/adapter.js";
6
+ import { appendSpecRecord, flushSpecRecordBuffer, } from "../../domain/spec/persistence/adapter.js";
8
7
  import { buildPersistedExtraContextFields } from "../../extra-context/contract.js";
8
+ import { loadOperatorEnvironment } from "../../preflight/environment.js";
9
+ import { prepareConfiguredOperatorReadiness } from "../../preflight/operator.js";
9
10
  import { toErrorMessage } from "../../utils/errors.js";
10
11
  import { getHeadRevision } from "../../utils/git.js";
12
+ import { emitSwarmSessionAcknowledgement } from "../../utils/swarm-session-ack.js";
11
13
  import { resolveEffectiveMaxParallel } from "../shared/max-parallel.js";
12
14
  import { resolveStageCompetitors } from "../shared/resolve-stage-competitors.js";
13
15
  import { generateSessionId } from "../shared/session-id.js";
14
- import { SpecAgentNotFoundError, SpecGenerationFailedError } from "./errors.js";
16
+ import { SpecAgentNotFoundError, SpecGenerationFailedError, SpecPreflightError, } from "./errors.js";
15
17
  export async function executeSpecCommand(input) {
16
18
  const { root, specsFilePath, description, agentIds: cliAgentIds, profileName, maxParallel: requestedMaxParallel, title: providedTitle, extraContextFiles = [], onStatus, renderer, } = input;
17
- let competitors;
19
+ let resolvedAgentIds;
18
20
  try {
19
21
  const normalizedCliIds = cliAgentIds && cliAgentIds.length > 0 ? [...cliAgentIds] : undefined;
20
22
  const resolution = resolveStageCompetitors({
@@ -22,9 +24,10 @@ export async function executeSpecCommand(input) {
22
24
  stageId: "spec",
23
25
  cliAgentIds: normalizedCliIds,
24
26
  profileName,
27
+ includeDefinitions: false,
25
28
  });
26
- competitors = resolution.competitors;
27
- if (competitors.length === 0) {
29
+ resolvedAgentIds = resolution.agentIds;
30
+ if (resolvedAgentIds.length === 0) {
28
31
  throw new SpecGenerationFailedError(["Spec agent resolution failed."]);
29
32
  }
30
33
  }
@@ -34,7 +37,16 @@ export async function executeSpecCommand(input) {
34
37
  }
35
38
  throw error;
36
39
  }
37
- const environment = loadEnvironmentConfig({ root });
40
+ const preflight = await prepareConfiguredOperatorReadiness({
41
+ root,
42
+ resolvedAgentIds,
43
+ includeEnvironment: false,
44
+ });
45
+ if (preflight.issues.length > 0) {
46
+ throw new SpecPreflightError(preflight.issues, preflight.preProviderIssueCount);
47
+ }
48
+ const competitors = preflight.agents;
49
+ const environment = loadOperatorEnvironment({ root });
38
50
  const effectiveMaxParallel = resolveEffectiveMaxParallel({
39
51
  competitorCount: competitors.length,
40
52
  requestedMaxParallel,
@@ -65,6 +77,16 @@ export async function executeSpecCommand(input) {
65
77
  specsFilePath,
66
78
  record,
67
79
  });
80
+ await emitSwarmSessionAcknowledgement({
81
+ operator: "spec",
82
+ sessionId,
83
+ status: "running",
84
+ });
85
+ const mutators = createSpecRecordMutators({
86
+ root,
87
+ specsFilePath,
88
+ sessionId,
89
+ });
68
90
  let currentAgents = [...initialAgents];
69
91
  onStatus?.("Generating specification…");
70
92
  renderer?.begin({
@@ -90,14 +112,15 @@ export async function executeSpecCommand(input) {
90
112
  adapter: {
91
113
  ...baseAdapter,
92
114
  onPreparationFailure: async (result) => {
93
- currentAgents = await persistSpecAgentFailure({
94
- root,
95
- specsFilePath,
96
- sessionId,
115
+ const updatedRecord = await mutators.recordAgentSnapshot({
97
116
  agentId: result.agentId,
117
+ status: "failed",
118
+ startedAt: new Date().toISOString(),
119
+ completedAt: new Date().toISOString(),
98
120
  tokenUsage: result.tokenUsage,
99
121
  error: result.error ?? null,
100
122
  });
123
+ currentAgents = [...updatedRecord.agents];
101
124
  const failedAgent = currentAgents.find((agent) => agent.agentId === result.agentId);
102
125
  renderer?.update({
103
126
  agentId: result.agentId,
@@ -110,12 +133,10 @@ export async function executeSpecCommand(input) {
110
133
  },
111
134
  onCandidateRunning: async (prepared, index) => {
112
135
  await baseAdapter.onCandidateRunning?.(prepared, index);
113
- currentAgents = await persistSpecAgentRunning({
114
- root,
115
- specsFilePath,
116
- sessionId,
136
+ const updatedRecord = await mutators.recordAgentRunning({
117
137
  agentId: prepared.candidate.id,
118
138
  });
139
+ currentAgents = [...updatedRecord.agents];
119
140
  const runningAgent = currentAgents.find((agent) => agent.agentId === prepared.candidate.id);
120
141
  renderer?.update({
121
142
  agentId: prepared.candidate.id,
@@ -124,12 +145,8 @@ export async function executeSpecCommand(input) {
124
145
  });
125
146
  },
126
147
  onCandidateCompleted: async (_prepared, result) => {
127
- currentAgents = await persistSpecAgentCompletion({
128
- root,
129
- specsFilePath,
130
- sessionId,
131
- result,
132
- });
148
+ const updatedRecord = await mutators.recordAgentSnapshot(toSpecAgentEntry(result));
149
+ currentAgents = [...updatedRecord.agents];
133
150
  const completedAgent = currentAgents.find((agent) => agent.agentId === result.agentId);
134
151
  renderer?.update({
135
152
  agentId: result.agentId,
@@ -145,10 +162,7 @@ export async function executeSpecCommand(input) {
145
162
  }
146
163
  catch (error) {
147
164
  const detail = toErrorMessage(error);
148
- await finalizeSpecRecord({
149
- root,
150
- specsFilePath,
151
- sessionId,
165
+ await mutators.completeSpec({
152
166
  status: "failed",
153
167
  error: detail,
154
168
  });
@@ -161,10 +175,7 @@ export async function executeSpecCommand(input) {
161
175
  : mapExecutionResultsToSpecAgents(executionResults, startedAt);
162
176
  // Derive session status from agent outcomes.
163
177
  const sessionStatus = deriveSpecStatusFromAgents(agentEntries.map((a) => a.status));
164
- const latestRecord = await finalizeSpecRecord({
165
- root,
166
- specsFilePath,
167
- sessionId,
178
+ const latestRecord = await mutators.completeSpec({
168
179
  status: sessionStatus,
169
180
  agents: agentEntries,
170
181
  error: sessionStatus === "failed" ? collectAgentErrors(agentEntries) : undefined,
@@ -195,114 +206,6 @@ function collectAgentErrors(agents) {
195
206
  .map((a) => `${a.agentId}: ${a.error}`);
196
207
  return errors.length > 0 ? errors.join("; ") : null;
197
208
  }
198
- async function persistSpecAgentRunning(options) {
199
- const { root, specsFilePath, sessionId, agentId } = options;
200
- const timestamp = new Date().toISOString();
201
- const updated = await rewriteSpecRecord({
202
- root,
203
- specsFilePath,
204
- sessionId,
205
- mutate: (record) => ({
206
- ...record,
207
- agents: record.agents.map((agent) => agent.agentId === agentId
208
- ? {
209
- ...agent,
210
- status: "running",
211
- ...buildLifecycleStartFields({
212
- existingStartedAt: agent.startedAt,
213
- timestamp,
214
- }),
215
- completedAt: undefined,
216
- error: null,
217
- }
218
- : agent),
219
- }),
220
- });
221
- return [...updated.agents];
222
- }
223
- async function persistSpecAgentCompletion(options) {
224
- const { root, specsFilePath, sessionId, result } = options;
225
- const completedAt = new Date().toISOString();
226
- const updated = await rewriteSpecRecord({
227
- root,
228
- specsFilePath,
229
- sessionId,
230
- mutate: (record) => ({
231
- ...record,
232
- agents: record.agents.map((agent) => {
233
- if (agent.agentId !== result.agentId) {
234
- return agent;
235
- }
236
- const startedAt = buildLifecycleStartFields({
237
- existingStartedAt: agent.startedAt,
238
- timestamp: completedAt,
239
- }).startedAt;
240
- const completeFields = buildOperationLifecycleCompleteFields({
241
- existing: {
242
- startedAt,
243
- completedAt: agent.completedAt,
244
- },
245
- completedAt,
246
- });
247
- if (result.status === "succeeded") {
248
- return {
249
- ...agent,
250
- status: "succeeded",
251
- ...completeFields,
252
- outputPath: result.outputPath,
253
- dataPath: result.dataPath,
254
- tokenUsage: result.tokenUsage,
255
- error: null,
256
- };
257
- }
258
- return {
259
- ...agent,
260
- status: "failed",
261
- ...completeFields,
262
- tokenUsage: result.tokenUsage,
263
- error: result.error ?? null,
264
- };
265
- }),
266
- }),
267
- });
268
- return [...updated.agents];
269
- }
270
- async function persistSpecAgentFailure(options) {
271
- const { root, specsFilePath, sessionId, agentId, tokenUsage, error } = options;
272
- const completedAt = new Date().toISOString();
273
- const updated = await rewriteSpecRecord({
274
- root,
275
- specsFilePath,
276
- sessionId,
277
- mutate: (record) => ({
278
- ...record,
279
- agents: record.agents.map((agent) => {
280
- if (agent.agentId !== agentId) {
281
- return agent;
282
- }
283
- const startedAt = buildLifecycleStartFields({
284
- existingStartedAt: agent.startedAt,
285
- timestamp: completedAt,
286
- }).startedAt;
287
- const completeFields = buildOperationLifecycleCompleteFields({
288
- existing: {
289
- startedAt,
290
- completedAt: agent.completedAt,
291
- },
292
- completedAt,
293
- });
294
- return {
295
- ...agent,
296
- status: "failed",
297
- ...completeFields,
298
- ...(tokenUsage ? { tokenUsage } : {}),
299
- error: error ?? null,
300
- };
301
- }),
302
- }),
303
- });
304
- return [...updated.agents];
305
- }
306
209
  function mapExecutionResultsToSpecAgents(executionResults, startedAt) {
307
210
  return executionResults.map((result) => {
308
211
  const completedAt = new Date().toISOString();
@@ -317,6 +220,7 @@ function mapExecutionResultsToSpecAgents(executionResults, startedAt) {
317
220
  status: "succeeded",
318
221
  outputPath: result.outputPath,
319
222
  dataPath: result.dataPath,
223
+ contentHash: result.contentHash,
320
224
  tokenUsage: result.tokenUsage,
321
225
  };
322
226
  }
@@ -328,3 +232,25 @@ function mapExecutionResultsToSpecAgents(executionResults, startedAt) {
328
232
  };
329
233
  });
330
234
  }
235
+ function toSpecAgentEntry(result) {
236
+ const completedAt = new Date().toISOString();
237
+ if (result.status === "succeeded") {
238
+ return {
239
+ agentId: result.agentId,
240
+ status: "succeeded",
241
+ completedAt,
242
+ outputPath: result.outputPath,
243
+ dataPath: result.dataPath,
244
+ contentHash: result.contentHash,
245
+ tokenUsage: result.tokenUsage,
246
+ error: null,
247
+ };
248
+ }
249
+ return {
250
+ agentId: result.agentId,
251
+ status: "failed",
252
+ completedAt,
253
+ tokenUsage: result.tokenUsage,
254
+ error: result.error ?? null,
255
+ };
256
+ }
@@ -1,4 +1,5 @@
1
1
  import { CliError } from "../../cli/errors.js";
2
+ import type { PreflightIssue } from "../../competition/shared/preflight.js";
2
3
  export declare class SpecError extends CliError {
3
4
  constructor(headline: string, detailLines?: readonly string[], hintLines?: readonly string[]);
4
5
  }
@@ -9,3 +10,7 @@ export declare class SpecAgentNotFoundError extends SpecError {
9
10
  export declare class SpecGenerationFailedError extends SpecError {
10
11
  constructor(detailLines?: readonly string[]);
11
12
  }
13
+ export declare class SpecPreflightError extends SpecError {
14
+ readonly issues: readonly PreflightIssue[];
15
+ constructor(issues: readonly PreflightIssue[], preProviderIssueCount: number);
16
+ }
@@ -1,4 +1,5 @@
1
1
  import { CliError } from "../../cli/errors.js";
2
+ import { formatOperatorPreflightIssueLines, resolveOperatorPreflightHintLines, } from "../../preflight/formatting.js";
2
3
  export class SpecError extends CliError {
3
4
  constructor(headline, detailLines = [], hintLines = []) {
4
5
  super(headline, detailLines, hintLines);
@@ -21,3 +22,11 @@ export class SpecGenerationFailedError extends SpecError {
21
22
  this.name = "SpecGenerationFailedError";
22
23
  }
23
24
  }
25
+ export class SpecPreflightError extends SpecError {
26
+ issues;
27
+ constructor(issues, preProviderIssueCount) {
28
+ super("Preflight failed. Aborting specification generation.", formatOperatorPreflightIssueLines(issues), resolveOperatorPreflightHintLines(issues, preProviderIssueCount) ?? []);
29
+ this.issues = Array.from(issues);
30
+ this.name = "SpecPreflightError";
31
+ }
32
+ }
@@ -4,5 +4,7 @@ export declare function resolveVerificationAgents(options: {
4
4
  root: string;
5
5
  agentOverrideFlag?: string;
6
6
  profileName?: string;
7
- }): AgentDefinition[];
8
- export declare function assertVerifierPreflight(agents: readonly AgentDefinition[]): Promise<void>;
7
+ }): {
8
+ readonly agentIds: readonly string[];
9
+ readonly competitors: readonly AgentDefinition[];
10
+ };
@@ -1,29 +1,22 @@
1
- import { verifyAgentProviders } from "../../agents/runtime/auth.js";
2
1
  import { AgentNotFoundError } from "../../configs/agents/errors.js";
3
2
  import { resolveStageCompetitors } from "../shared/resolve-stage-competitors.js";
3
+ import { VerifyAgentNotFoundError } from "./errors.js";
4
4
  export function resolveVerificationAgents(options) {
5
5
  const { agentIds, root, agentOverrideFlag, profileName } = options;
6
6
  try {
7
- const resolution = resolveStageCompetitors({
7
+ return resolveStageCompetitors({
8
8
  root,
9
9
  stageId: "verify",
10
10
  cliAgentIds: agentIds,
11
11
  cliOverrideFlag: agentOverrideFlag,
12
12
  profileName,
13
+ includeDefinitions: false,
13
14
  });
14
- return [...resolution.competitors];
15
15
  }
16
16
  catch (error) {
17
17
  if (error instanceof AgentNotFoundError) {
18
- throw new Error(`Verifier agent not found: ${error.agentId}`);
18
+ throw new VerifyAgentNotFoundError(error.agentId);
19
19
  }
20
20
  throw error;
21
21
  }
22
22
  }
23
- export async function assertVerifierPreflight(agents) {
24
- const providerIssues = await verifyAgentProviders(agents.map((agent) => ({ id: agent.id, provider: agent.provider })));
25
- if (providerIssues.length > 0) {
26
- const detail = providerIssues.map((issue) => issue.message).join("; ");
27
- throw new Error(`Verifier preflight failed: ${detail}`);
28
- }
29
- }
@@ -1,6 +1,5 @@
1
1
  import { teardownSessionAuth } from "../../agents/runtime/registry.js";
2
2
  import { createTeardownController } from "../../competition/shared/teardown.js";
3
- import { loadEnvironmentConfig } from "../../configs/environment/loader.js";
4
3
  import { loadVerificationConfig } from "../../configs/verification/loader.js";
5
4
  import { buildBlindedAliasMap } from "../../domain/verify/competition/blinding.js";
6
5
  import { deriveVerificationStatusFromMethods, maybePersistSelectedSpecPath, } from "../../domain/verify/competition/finalize.js";
@@ -9,11 +8,16 @@ import { executeAndPersistRubricMethods } from "../../domain/verify/competition/
9
8
  import { createVerificationRecordMutators } from "../../domain/verify/model/mutators.js";
10
9
  import { appendVerificationRecord, flushVerificationRecordBuffer, } from "../../domain/verify/persistence/adapter.js";
11
10
  import { buildPersistedExtraContextFields } from "../../extra-context/contract.js";
11
+ import { loadOperatorEnvironment } from "../../preflight/environment.js";
12
+ import { prepareConfiguredOperatorReadiness } from "../../preflight/operator.js";
12
13
  import { toErrorMessage } from "../../utils/errors.js";
13
14
  import { normalizePathForDisplay, relativeToRoot } from "../../utils/path.js";
14
- import { resolveWorkspacePath, VORATIQ_VERIFICATION_SESSIONS_DIR, } from "../../workspace/structure.js";
15
+ import { emitSwarmSessionAcknowledgement } from "../../utils/swarm-session-ack.js";
16
+ import { VORATIQ_VERIFICATION_SESSIONS_DIR } from "../../workspace/constants.js";
17
+ import { resolveWorkspacePath } from "../../workspace/path-resolvers.js";
15
18
  import { generateSessionId } from "../shared/session-id.js";
16
- import { assertVerifierPreflight, resolveVerificationAgents, } from "./agents.js";
19
+ import { resolveVerificationAgents } from "./agents.js";
20
+ import { VerifyPreflightError } from "./errors.js";
17
21
  import { finalizeActiveVerification, registerActiveVerification, } from "./lifecycle.js";
18
22
  import { resolveVerifyRubricMaxParallel } from "./max-parallel.js";
19
23
  import { resolveVerifyTarget } from "./targets.js";
@@ -29,14 +33,22 @@ export async function executeVerifyCommand(input) {
29
33
  target,
30
34
  });
31
35
  const verificationConfig = loadVerificationConfig({ root });
32
- const verificationAgents = resolveVerificationAgents({
36
+ const verificationPlan = resolveVerificationAgents({
33
37
  agentIds,
34
38
  root,
35
39
  agentOverrideFlag,
36
40
  profileName,
37
41
  });
38
- await assertVerifierPreflight(verificationAgents);
39
- const environment = loadEnvironmentConfig({ root });
42
+ const preflight = await prepareConfiguredOperatorReadiness({
43
+ root,
44
+ resolvedAgentIds: verificationPlan.agentIds,
45
+ includeEnvironment: false,
46
+ });
47
+ if (preflight.issues.length > 0) {
48
+ throw new VerifyPreflightError(preflight.issues, preflight.preProviderIssueCount);
49
+ }
50
+ const verificationAgents = preflight.agents;
51
+ const environment = loadOperatorEnvironment({ root });
40
52
  const verificationId = generateSessionId();
41
53
  const createdAt = new Date().toISOString();
42
54
  const aliasMap = buildBlindedAliasMap(resolvedTarget);
@@ -59,6 +71,11 @@ export async function executeVerifyCommand(input) {
59
71
  methods: [],
60
72
  },
61
73
  });
74
+ await emitSwarmSessionAcknowledgement({
75
+ operator: "verify",
76
+ sessionId: verificationId,
77
+ status: "queued",
78
+ });
62
79
  renderer?.begin({
63
80
  verificationId,
64
81
  createdAt,
@@ -0,0 +1,12 @@
1
+ import { CliError } from "../../cli/errors.js";
2
+ import type { PreflightIssue } from "../../competition/shared/preflight.js";
3
+ export declare class VerifyError extends CliError {
4
+ constructor(headline: string, detailLines?: readonly string[], hintLines?: readonly string[]);
5
+ }
6
+ export declare class VerifyAgentNotFoundError extends VerifyError {
7
+ constructor(agentId: string);
8
+ }
9
+ export declare class VerifyPreflightError extends VerifyError {
10
+ readonly issues: readonly PreflightIssue[];
11
+ constructor(issues: readonly PreflightIssue[], preProviderIssueCount: number);
12
+ }
@@ -0,0 +1,22 @@
1
+ import { CliError } from "../../cli/errors.js";
2
+ import { formatOperatorPreflightIssueLines, resolveOperatorPreflightHintLines, } from "../../preflight/formatting.js";
3
+ export class VerifyError extends CliError {
4
+ constructor(headline, detailLines = [], hintLines = []) {
5
+ super(headline, detailLines, hintLines);
6
+ this.name = "VerifyError";
7
+ }
8
+ }
9
+ export class VerifyAgentNotFoundError extends VerifyError {
10
+ constructor(agentId) {
11
+ super(`Verifier agent not found: ${agentId}`);
12
+ this.name = "VerifyAgentNotFoundError";
13
+ }
14
+ }
15
+ export class VerifyPreflightError extends VerifyError {
16
+ issues;
17
+ constructor(issues, preProviderIssueCount) {
18
+ super("Preflight failed. Aborting verification.", formatOperatorPreflightIssueLines(issues), resolveOperatorPreflightHintLines(issues, preProviderIssueCount) ?? []);
19
+ this.issues = Array.from(issues);
20
+ this.name = "VerifyPreflightError";
21
+ }
22
+ }
@@ -3,7 +3,7 @@ import { buildOperationLifecycleCompleteFields, buildRecordLifecycleCompleteFiel
3
3
  import { writeVerificationArtifact } from "../../domain/verify/competition/artifacts.js";
4
4
  import { flushVerificationRecordBuffer, readVerificationRecords, rewriteVerificationRecord, } from "../../domain/verify/persistence/adapter.js";
5
5
  import { toErrorMessage } from "../../utils/errors.js";
6
- import { getVerificationProgrammaticResultPath, getVerificationRubricResultPath, } from "../../workspace/structure.js";
6
+ import { getVerificationProgrammaticResultPath, getVerificationRubricResultPath, } from "../../workspace/artifact-paths.js";
7
7
  export const VERIFY_ABORT_DETAIL = "Verification aborted before completion.";
8
8
  let activeVerification;
9
9
  let terminationInFlight = false;