voratiq 0.1.0-beta.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/LICENSE +21 -0
- package/README.md +59 -0
- package/dist/auth/providers/claude/constants.d.ts +7 -0
- package/dist/auth/providers/claude/constants.js +9 -0
- package/dist/auth/providers/claude/credentials.d.ts +5 -0
- package/dist/auth/providers/claude/credentials.js +112 -0
- package/dist/auth/providers/claude/error.d.ts +5 -0
- package/dist/auth/providers/claude/error.js +6 -0
- package/dist/auth/providers/claude/keychain.d.ts +4 -0
- package/dist/auth/providers/claude/keychain.js +158 -0
- package/dist/auth/providers/claude.d.ts +2 -0
- package/dist/auth/providers/claude.js +124 -0
- package/dist/auth/providers/codex.d.ts +2 -0
- package/dist/auth/providers/codex.js +93 -0
- package/dist/auth/providers/gemini.d.ts +2 -0
- package/dist/auth/providers/gemini.js +159 -0
- package/dist/auth/providers/index.d.ts +2 -0
- package/dist/auth/providers/index.js +16 -0
- package/dist/auth/providers/messages.d.ts +1 -0
- package/dist/auth/providers/messages.js +3 -0
- package/dist/auth/providers/secret-staging.d.ts +14 -0
- package/dist/auth/providers/secret-staging.js +72 -0
- package/dist/auth/providers/teardown.d.ts +2 -0
- package/dist/auth/providers/teardown.js +6 -0
- package/dist/auth/providers/types.d.ts +31 -0
- package/dist/auth/providers/types.js +1 -0
- package/dist/auth/providers/utils.d.ts +20 -0
- package/dist/auth/providers/utils.js +148 -0
- package/dist/auth/runtime.d.ts +2 -0
- package/dist/auth/runtime.js +17 -0
- package/dist/auth/staging.d.ts +8 -0
- package/dist/auth/staging.js +7 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +142 -0
- package/dist/cli/apply.d.ts +14 -0
- package/dist/cli/apply.js +38 -0
- package/dist/cli/commander-utils.d.ts +3 -0
- package/dist/cli/commander-utils.js +27 -0
- package/dist/cli/confirmation.d.ts +14 -0
- package/dist/cli/confirmation.js +16 -0
- package/dist/cli/errors.d.ts +5 -0
- package/dist/cli/errors.js +16 -0
- package/dist/cli/init.d.ts +10 -0
- package/dist/cli/init.js +41 -0
- package/dist/cli/list.d.ts +14 -0
- package/dist/cli/list.js +48 -0
- package/dist/cli/output.d.ts +14 -0
- package/dist/cli/output.js +62 -0
- package/dist/cli/prune.d.ts +14 -0
- package/dist/cli/prune.js +54 -0
- package/dist/cli/review.d.ts +12 -0
- package/dist/cli/review.js +33 -0
- package/dist/cli/run.d.ts +13 -0
- package/dist/cli/run.js +51 -0
- package/dist/commands/apply/command.d.ts +9 -0
- package/dist/commands/apply/command.js +135 -0
- package/dist/commands/apply/errors.d.ts +35 -0
- package/dist/commands/apply/errors.js +73 -0
- package/dist/commands/apply/types.d.ts +13 -0
- package/dist/commands/apply/types.js +1 -0
- package/dist/commands/errors.d.ts +4 -0
- package/dist/commands/errors.js +7 -0
- package/dist/commands/fetch.d.ts +8 -0
- package/dist/commands/fetch.js +25 -0
- package/dist/commands/init/agents.d.ts +3 -0
- package/dist/commands/init/agents.js +159 -0
- package/dist/commands/init/command.d.ts +2 -0
- package/dist/commands/init/command.js +40 -0
- package/dist/commands/init/environment.d.ts +2 -0
- package/dist/commands/init/environment.js +76 -0
- package/dist/commands/init/evals.d.ts +4 -0
- package/dist/commands/init/evals.js +219 -0
- package/dist/commands/init/types.d.ts +48 -0
- package/dist/commands/init/types.js +1 -0
- package/dist/commands/list/command.d.ts +13 -0
- package/dist/commands/list/command.js +60 -0
- package/dist/commands/prune/command.d.ts +2 -0
- package/dist/commands/prune/command.js +336 -0
- package/dist/commands/prune/errors.d.ts +20 -0
- package/dist/commands/prune/errors.js +39 -0
- package/dist/commands/prune/types.d.ts +42 -0
- package/dist/commands/prune/types.js +1 -0
- package/dist/commands/review/command.d.ts +10 -0
- package/dist/commands/review/command.js +26 -0
- package/dist/commands/run/agent-execution.d.ts +19 -0
- package/dist/commands/run/agent-execution.js +63 -0
- package/dist/commands/run/agents/auth-stage.d.ts +23 -0
- package/dist/commands/run/agents/auth-stage.js +108 -0
- package/dist/commands/run/agents/chat-preserver.d.ts +9 -0
- package/dist/commands/run/agents/chat-preserver.js +35 -0
- package/dist/commands/run/agents/eval-runner.d.ts +19 -0
- package/dist/commands/run/agents/eval-runner.js +27 -0
- package/dist/commands/run/agents/failures.d.ts +7 -0
- package/dist/commands/run/agents/failures.js +32 -0
- package/dist/commands/run/agents/lifecycle.d.ts +9 -0
- package/dist/commands/run/agents/lifecycle.js +157 -0
- package/dist/commands/run/agents/preparation.d.ts +2 -0
- package/dist/commands/run/agents/preparation.js +123 -0
- package/dist/commands/run/agents/run-context.d.ts +46 -0
- package/dist/commands/run/agents/run-context.js +193 -0
- package/dist/commands/run/agents/sandbox-launcher.d.ts +44 -0
- package/dist/commands/run/agents/sandbox-launcher.js +211 -0
- package/dist/commands/run/agents/types.d.ts +47 -0
- package/dist/commands/run/agents/types.js +1 -0
- package/dist/commands/run/agents/watchdog.d.ts +39 -0
- package/dist/commands/run/agents/watchdog.js +172 -0
- package/dist/commands/run/agents/workspace-prep.d.ts +17 -0
- package/dist/commands/run/agents/workspace-prep.js +78 -0
- package/dist/commands/run/agents.d.ts +14 -0
- package/dist/commands/run/agents.js +47 -0
- package/dist/commands/run/argv.d.ts +1 -0
- package/dist/commands/run/argv.js +19 -0
- package/dist/commands/run/command.d.ts +14 -0
- package/dist/commands/run/command.js +170 -0
- package/dist/commands/run/errors.d.ts +61 -0
- package/dist/commands/run/errors.js +86 -0
- package/dist/commands/run/id.d.ts +1 -0
- package/dist/commands/run/id.js +22 -0
- package/dist/commands/run/lifecycle.d.ts +19 -0
- package/dist/commands/run/lifecycle.js +186 -0
- package/dist/commands/run/phases.d.ts +11 -0
- package/dist/commands/run/phases.js +1 -0
- package/dist/commands/run/prompts.d.ts +4 -0
- package/dist/commands/run/prompts.js +16 -0
- package/dist/commands/run/record-init.d.ts +15 -0
- package/dist/commands/run/record-init.js +29 -0
- package/dist/commands/run/reports.d.ts +14 -0
- package/dist/commands/run/reports.js +63 -0
- package/dist/commands/run/sandbox-registry.d.ts +4 -0
- package/dist/commands/run/sandbox-registry.js +54 -0
- package/dist/commands/run/sandbox.d.ts +16 -0
- package/dist/commands/run/sandbox.js +96 -0
- package/dist/commands/run/shim/agent-manifest.d.ts +7 -0
- package/dist/commands/run/shim/agent-manifest.js +1 -0
- package/dist/commands/run/shim/run-agent-shim.d.ts +1 -0
- package/dist/commands/run/shim/run-agent-shim.js +232 -0
- package/dist/commands/run/shim/run-agent-shim.mjs +10 -0
- package/dist/commands/run/validation.d.ts +20 -0
- package/dist/commands/run/validation.js +60 -0
- package/dist/configs/agents/defaults.d.ts +9 -0
- package/dist/configs/agents/defaults.js +55 -0
- package/dist/configs/agents/errors.d.ts +40 -0
- package/dist/configs/agents/errors.js +78 -0
- package/dist/configs/agents/loader.d.ts +8 -0
- package/dist/configs/agents/loader.js +137 -0
- package/dist/configs/agents/types.d.ts +39 -0
- package/dist/configs/agents/types.js +31 -0
- package/dist/configs/environment/detect.d.ts +17 -0
- package/dist/configs/environment/detect.js +79 -0
- package/dist/configs/environment/errors.d.ts +12 -0
- package/dist/configs/environment/errors.js +26 -0
- package/dist/configs/environment/loader.d.ts +10 -0
- package/dist/configs/environment/loader.js +80 -0
- package/dist/configs/environment/types.d.ts +21 -0
- package/dist/configs/environment/types.js +98 -0
- package/dist/configs/evals/defaults.d.ts +8 -0
- package/dist/configs/evals/defaults.js +28 -0
- package/dist/configs/evals/detect.d.ts +10 -0
- package/dist/configs/evals/detect.js +224 -0
- package/dist/configs/evals/errors.d.ts +16 -0
- package/dist/configs/evals/errors.js +29 -0
- package/dist/configs/evals/loader.d.ts +9 -0
- package/dist/configs/evals/loader.js +46 -0
- package/dist/configs/evals/types.d.ts +42 -0
- package/dist/configs/evals/types.js +74 -0
- package/dist/configs/sandbox/defaults.d.ts +14 -0
- package/dist/configs/sandbox/defaults.js +54 -0
- package/dist/configs/sandbox/errors.d.ts +5 -0
- package/dist/configs/sandbox/errors.js +8 -0
- package/dist/configs/sandbox/loader.d.ts +6 -0
- package/dist/configs/sandbox/loader.js +192 -0
- package/dist/configs/sandbox/merge.d.ts +9 -0
- package/dist/configs/sandbox/merge.js +94 -0
- package/dist/configs/sandbox/schemas.d.ts +58 -0
- package/dist/configs/sandbox/schemas.js +72 -0
- package/dist/configs/sandbox/types.d.ts +34 -0
- package/dist/configs/sandbox/types.js +1 -0
- package/dist/configs/shared/loader-factory.d.ts +19 -0
- package/dist/configs/shared/loader-factory.js +33 -0
- package/dist/configs/shared/yaml-error-formatter.d.ts +40 -0
- package/dist/configs/shared/yaml-error-formatter.js +41 -0
- package/dist/evals/runner.d.ts +16 -0
- package/dist/evals/runner.js +132 -0
- package/dist/preflight/errors.d.ts +10 -0
- package/dist/preflight/errors.js +21 -0
- package/dist/preflight/index.d.ts +30 -0
- package/dist/preflight/index.js +157 -0
- package/dist/records/enhanced.d.ts +38 -0
- package/dist/records/enhanced.js +139 -0
- package/dist/records/errors.d.ts +23 -0
- package/dist/records/errors.js +43 -0
- package/dist/records/history-lock.d.ts +27 -0
- package/dist/records/history-lock.js +184 -0
- package/dist/records/mutators.d.ts +17 -0
- package/dist/records/mutators.js +144 -0
- package/dist/records/persistence.d.ts +95 -0
- package/dist/records/persistence.js +459 -0
- package/dist/records/types.d.ts +238 -0
- package/dist/records/types.js +131 -0
- package/dist/render/interactions/confirmation.d.ts +19 -0
- package/dist/render/interactions/confirmation.js +63 -0
- package/dist/render/transcripts/apply.d.ts +2 -0
- package/dist/render/transcripts/apply.js +52 -0
- package/dist/render/transcripts/init.d.ts +18 -0
- package/dist/render/transcripts/init.js +84 -0
- package/dist/render/transcripts/list.d.ts +3 -0
- package/dist/render/transcripts/list.js +44 -0
- package/dist/render/transcripts/prune.d.ts +16 -0
- package/dist/render/transcripts/prune.js +50 -0
- package/dist/render/transcripts/review.d.ts +2 -0
- package/dist/render/transcripts/review.js +36 -0
- package/dist/render/transcripts/run.d.ts +25 -0
- package/dist/render/transcripts/run.js +295 -0
- package/dist/render/transcripts/shared.d.ts +12 -0
- package/dist/render/transcripts/shared.js +41 -0
- package/dist/render/utils/agents.d.ts +28 -0
- package/dist/render/utils/agents.js +261 -0
- package/dist/render/utils/badges.d.ts +20 -0
- package/dist/render/utils/badges.js +37 -0
- package/dist/render/utils/errors.d.ts +2 -0
- package/dist/render/utils/errors.js +14 -0
- package/dist/render/utils/records.d.ts +1 -0
- package/dist/render/utils/records.js +32 -0
- package/dist/render/utils/runs.d.ts +16 -0
- package/dist/render/utils/runs.js +50 -0
- package/dist/render/utils/table.d.ts +12 -0
- package/dist/render/utils/table.js +32 -0
- package/dist/render/utils/transcript.d.ts +14 -0
- package/dist/render/utils/transcript.js +44 -0
- package/dist/status/colors.d.ts +10 -0
- package/dist/status/colors.js +33 -0
- package/dist/status/index.d.ts +37 -0
- package/dist/status/index.js +30 -0
- package/dist/testing/test-hooks.d.ts +7 -0
- package/dist/testing/test-hooks.js +16 -0
- package/dist/utils/binaries.d.ts +1 -0
- package/dist/utils/binaries.js +13 -0
- package/dist/utils/cli-root.d.ts +2 -0
- package/dist/utils/cli-root.js +42 -0
- package/dist/utils/colors.d.ts +2 -0
- package/dist/utils/colors.js +23 -0
- package/dist/utils/diff.d.ts +9 -0
- package/dist/utils/diff.js +61 -0
- package/dist/utils/env.d.ts +10 -0
- package/dist/utils/env.js +56 -0
- package/dist/utils/errors.d.ts +31 -0
- package/dist/utils/errors.js +53 -0
- package/dist/utils/fs.d.ts +13 -0
- package/dist/utils/fs.js +70 -0
- package/dist/utils/git.d.ts +40 -0
- package/dist/utils/git.js +126 -0
- package/dist/utils/output.d.ts +4 -0
- package/dist/utils/output.js +12 -0
- package/dist/utils/path.d.ts +11 -0
- package/dist/utils/path.js +84 -0
- package/dist/utils/process.d.ts +37 -0
- package/dist/utils/process.js +152 -0
- package/dist/utils/terminal.d.ts +5 -0
- package/dist/utils/terminal.js +5 -0
- package/dist/utils/validators.d.ts +1 -0
- package/dist/utils/validators.js +15 -0
- package/dist/utils/version.d.ts +1 -0
- package/dist/utils/version.js +25 -0
- package/dist/utils/yaml-reader.d.ts +14 -0
- package/dist/utils/yaml-reader.js +41 -0
- package/dist/utils/yaml.d.ts +33 -0
- package/dist/utils/yaml.js +75 -0
- package/dist/workspace/agents.d.ts +33 -0
- package/dist/workspace/agents.js +189 -0
- package/dist/workspace/chat/artifacts.d.ts +14 -0
- package/dist/workspace/chat/artifacts.js +157 -0
- package/dist/workspace/chat/sources.d.ts +5 -0
- package/dist/workspace/chat/sources.js +80 -0
- package/dist/workspace/chat/types.d.ts +1 -0
- package/dist/workspace/chat/types.js +1 -0
- package/dist/workspace/cleanup.d.ts +4 -0
- package/dist/workspace/cleanup.js +12 -0
- package/dist/workspace/credential-guard.d.ts +4 -0
- package/dist/workspace/credential-guard.js +71 -0
- package/dist/workspace/dependencies.d.ts +23 -0
- package/dist/workspace/dependencies.js +190 -0
- package/dist/workspace/errors.d.ts +16 -0
- package/dist/workspace/errors.js +43 -0
- package/dist/workspace/layout.d.ts +30 -0
- package/dist/workspace/layout.js +124 -0
- package/dist/workspace/prune.d.ts +8 -0
- package/dist/workspace/prune.js +29 -0
- package/dist/workspace/run.d.ts +14 -0
- package/dist/workspace/run.js +28 -0
- package/dist/workspace/sandbox-requirements.d.ts +17 -0
- package/dist/workspace/sandbox-requirements.js +69 -0
- package/dist/workspace/setup.d.ts +3 -0
- package/dist/workspace/setup.js +81 -0
- package/dist/workspace/shim.d.ts +4 -0
- package/dist/workspace/shim.js +65 -0
- package/dist/workspace/structure.d.ts +77 -0
- package/dist/workspace/structure.js +134 -0
- package/dist/workspace/templates.d.ts +9 -0
- package/dist/workspace/templates.js +66 -0
- package/dist/workspace/types.d.ts +4 -0
- package/dist/workspace/types.js +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CliError } from "../../cli/errors.js";
|
|
2
|
+
export declare class PruneError extends CliError {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class RunMetadataMissingError extends PruneError {
|
|
6
|
+
readonly runId: string;
|
|
7
|
+
constructor(runId: string);
|
|
8
|
+
}
|
|
9
|
+
export declare class InteractiveConfirmationRequiredError extends PruneError {
|
|
10
|
+
constructor();
|
|
11
|
+
}
|
|
12
|
+
export declare class PruneBranchDeletionError extends PruneError {
|
|
13
|
+
readonly branch: string;
|
|
14
|
+
readonly detail: string;
|
|
15
|
+
constructor(branch: string, detail: string);
|
|
16
|
+
}
|
|
17
|
+
export declare class PruneRunDeletedError extends PruneError {
|
|
18
|
+
readonly runId: string;
|
|
19
|
+
constructor(runId: string);
|
|
20
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CliError } from "../../cli/errors.js";
|
|
2
|
+
export class PruneError extends CliError {
|
|
3
|
+
constructor(message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "PruneError";
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export class RunMetadataMissingError extends PruneError {
|
|
9
|
+
runId;
|
|
10
|
+
constructor(runId) {
|
|
11
|
+
super(`Run metadata for ${runId} is missing from .voratiq/runs/${runId}/record.json; prune cannot proceed.`);
|
|
12
|
+
this.runId = runId;
|
|
13
|
+
this.name = "RunMetadataMissingError";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export class InteractiveConfirmationRequiredError extends PruneError {
|
|
17
|
+
constructor() {
|
|
18
|
+
super("Interactive confirmation required; re-run with --yes or from a tty.");
|
|
19
|
+
this.name = "InteractiveConfirmationRequiredError";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export class PruneBranchDeletionError extends PruneError {
|
|
23
|
+
branch;
|
|
24
|
+
detail;
|
|
25
|
+
constructor(branch, detail) {
|
|
26
|
+
super(`Failed to delete branch ${branch}: ${detail}`);
|
|
27
|
+
this.branch = branch;
|
|
28
|
+
this.detail = detail;
|
|
29
|
+
this.name = "PruneBranchDeletionError";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export class PruneRunDeletedError extends PruneError {
|
|
33
|
+
runId;
|
|
34
|
+
constructor(runId) {
|
|
35
|
+
super(`Run ${runId} has been deleted.`);
|
|
36
|
+
this.runId = runId;
|
|
37
|
+
this.name = "PruneRunDeletedError";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ConfirmationOptions } from "../../render/interactions/confirmation.js";
|
|
2
|
+
export type PruneConfirmationHandler = (options: ConfirmationOptions) => Promise<boolean>;
|
|
3
|
+
export interface PruneCommandInput {
|
|
4
|
+
root: string;
|
|
5
|
+
runsDir: string;
|
|
6
|
+
runsFilePath: string;
|
|
7
|
+
runId: string;
|
|
8
|
+
confirm: PruneConfirmationHandler;
|
|
9
|
+
purge?: boolean;
|
|
10
|
+
clock?: () => Date;
|
|
11
|
+
}
|
|
12
|
+
export interface PruneBranchSummary {
|
|
13
|
+
deleted: string[];
|
|
14
|
+
skipped: string[];
|
|
15
|
+
}
|
|
16
|
+
export interface PruneWorkspaceSummary {
|
|
17
|
+
removed: string[];
|
|
18
|
+
missing: string[];
|
|
19
|
+
}
|
|
20
|
+
export interface PruneArtifactSummary {
|
|
21
|
+
purged: boolean;
|
|
22
|
+
removed: string[];
|
|
23
|
+
missing: string[];
|
|
24
|
+
}
|
|
25
|
+
export interface PruneSuccessResult {
|
|
26
|
+
status: "pruned";
|
|
27
|
+
runId: string;
|
|
28
|
+
specPath: string;
|
|
29
|
+
runPath: string;
|
|
30
|
+
createdAt: string;
|
|
31
|
+
deletedAt: string;
|
|
32
|
+
workspaces: PruneWorkspaceSummary;
|
|
33
|
+
artifacts: PruneArtifactSummary;
|
|
34
|
+
branches: PruneBranchSummary;
|
|
35
|
+
}
|
|
36
|
+
export interface PruneAbortedResult {
|
|
37
|
+
status: "aborted";
|
|
38
|
+
runId: string;
|
|
39
|
+
specPath: string;
|
|
40
|
+
runPath: string;
|
|
41
|
+
}
|
|
42
|
+
export type PruneResult = PruneSuccessResult | PruneAbortedResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RunRecordEnhanced } from "../../records/enhanced.js";
|
|
2
|
+
export interface ReviewCommandInput {
|
|
3
|
+
root: string;
|
|
4
|
+
runsFilePath: string;
|
|
5
|
+
runId: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ReviewCommandResult {
|
|
8
|
+
runRecord: RunRecordEnhanced;
|
|
9
|
+
}
|
|
10
|
+
export declare function executeReviewCommand(input: ReviewCommandInput): Promise<ReviewCommandResult>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { buildRunRecordView } from "../../records/enhanced.js";
|
|
2
|
+
import { RunRecordNotFoundError } from "../../records/errors.js";
|
|
3
|
+
import { fetchRunsSafely } from "../../records/persistence.js";
|
|
4
|
+
import { RunNotFoundCliError } from "../errors.js";
|
|
5
|
+
export async function executeReviewCommand(input) {
|
|
6
|
+
const { root, runsFilePath, runId } = input;
|
|
7
|
+
const { records } = await fetchRunsSafely({
|
|
8
|
+
root,
|
|
9
|
+
runsFilePath,
|
|
10
|
+
runId,
|
|
11
|
+
filters: { includeDeleted: true },
|
|
12
|
+
}).catch((error) => {
|
|
13
|
+
if (error instanceof RunRecordNotFoundError) {
|
|
14
|
+
throw new RunNotFoundCliError(runId);
|
|
15
|
+
}
|
|
16
|
+
throw error;
|
|
17
|
+
});
|
|
18
|
+
const runRecord = records[0];
|
|
19
|
+
if (!runRecord) {
|
|
20
|
+
throw new RunNotFoundCliError(runId);
|
|
21
|
+
}
|
|
22
|
+
const enhanced = await buildRunRecordView(runRecord, {
|
|
23
|
+
workspaceRoot: root,
|
|
24
|
+
});
|
|
25
|
+
return { runRecord: enhanced };
|
|
26
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AgentDefinition } from "../../configs/agents/types.js";
|
|
2
|
+
import type { EnvironmentConfig } from "../../configs/environment/types.js";
|
|
3
|
+
import type { EvalDefinition } from "../../configs/evals/types.js";
|
|
4
|
+
import type { AgentRecordMutators } from "../../records/mutators.js";
|
|
5
|
+
import type { AgentExecutionPhaseResult } from "./phases.js";
|
|
6
|
+
export interface AgentExecutionInput {
|
|
7
|
+
readonly agents: readonly AgentDefinition[];
|
|
8
|
+
readonly baseRevisionSha: string;
|
|
9
|
+
readonly runId: string;
|
|
10
|
+
readonly root: string;
|
|
11
|
+
readonly evalPlan: readonly EvalDefinition[];
|
|
12
|
+
readonly effectiveMaxParallel: number;
|
|
13
|
+
readonly mutators: AgentRecordMutators;
|
|
14
|
+
readonly environment: EnvironmentConfig;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Execute all agents and aggregate results.
|
|
18
|
+
*/
|
|
19
|
+
export declare function executeAgents(input: AgentExecutionInput): Promise<AgentExecutionPhaseResult>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { toError } from "../../utils/errors.js";
|
|
2
|
+
import { prepareAgents, runAgentsWithLimit } from "./agents.js";
|
|
3
|
+
import { hasEvalFailures } from "./reports.js";
|
|
4
|
+
/**
|
|
5
|
+
* Execute all agents and aggregate results.
|
|
6
|
+
*/
|
|
7
|
+
export async function executeAgents(input) {
|
|
8
|
+
const { agents, baseRevisionSha, runId, root, evalPlan, effectiveMaxParallel, mutators, environment, } = input;
|
|
9
|
+
let executionError;
|
|
10
|
+
let phaseResult;
|
|
11
|
+
try {
|
|
12
|
+
for (const agent of agents) {
|
|
13
|
+
await mutators.recordAgentQueued(agent);
|
|
14
|
+
}
|
|
15
|
+
const { ready: preparedAgents, failures: preparationFailures } = await prepareAgents({
|
|
16
|
+
agents,
|
|
17
|
+
baseRevisionSha,
|
|
18
|
+
runId,
|
|
19
|
+
root,
|
|
20
|
+
evalPlan,
|
|
21
|
+
environment,
|
|
22
|
+
});
|
|
23
|
+
for (const failure of preparationFailures) {
|
|
24
|
+
await mutators.recordAgentSnapshot(failure.record);
|
|
25
|
+
}
|
|
26
|
+
for (const execution of preparedAgents) {
|
|
27
|
+
execution.progress = {
|
|
28
|
+
onRunning: mutators.recordAgentSnapshot,
|
|
29
|
+
onCompleted: async (result) => {
|
|
30
|
+
await mutators.recordAgentSnapshot(result.record);
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const executionResults = preparedAgents.length > 0 && effectiveMaxParallel > 0
|
|
35
|
+
? await runAgentsWithLimit(preparedAgents, effectiveMaxParallel)
|
|
36
|
+
: [];
|
|
37
|
+
const agentExecutions = [...preparationFailures, ...executionResults];
|
|
38
|
+
const sortedExecutions = sortExecutions(agentExecutions);
|
|
39
|
+
const agentRecords = sortedExecutions.map((execution) => execution.record);
|
|
40
|
+
const agentReports = sortedExecutions.map((execution) => execution.report);
|
|
41
|
+
const hadAgentFailure = agentReports.some((report) => report.status === "failed");
|
|
42
|
+
const hadEvalFailure = hasEvalFailures(agentReports);
|
|
43
|
+
phaseResult = {
|
|
44
|
+
agentRecords,
|
|
45
|
+
agentReports,
|
|
46
|
+
hadAgentFailure,
|
|
47
|
+
hadEvalFailure,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
executionError = error;
|
|
52
|
+
}
|
|
53
|
+
if (executionError) {
|
|
54
|
+
throw toError(executionError);
|
|
55
|
+
}
|
|
56
|
+
if (!phaseResult) {
|
|
57
|
+
throw new Error(`Agent execution did not produce a result for run ${runId}`);
|
|
58
|
+
}
|
|
59
|
+
return phaseResult;
|
|
60
|
+
}
|
|
61
|
+
function sortExecutions(executions) {
|
|
62
|
+
return [...executions].sort((a, b) => a.record.agentId.localeCompare(b.record.agentId));
|
|
63
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AuthProvider, AuthRuntimeContext } from "../../../auth/providers/types.js";
|
|
2
|
+
import type { AgentDefinition } from "../../../configs/agents/types.js";
|
|
3
|
+
export interface StagedAuthContext {
|
|
4
|
+
provider: AuthProvider;
|
|
5
|
+
sandboxPath: string;
|
|
6
|
+
runtime: AuthRuntimeContext;
|
|
7
|
+
agentId: string;
|
|
8
|
+
runId: string;
|
|
9
|
+
}
|
|
10
|
+
export interface StageAuthOptions {
|
|
11
|
+
agent: AgentDefinition;
|
|
12
|
+
agentRoot: string;
|
|
13
|
+
runId: string;
|
|
14
|
+
root: string;
|
|
15
|
+
runtime?: AuthRuntimeContext;
|
|
16
|
+
}
|
|
17
|
+
export interface StageAuthResult {
|
|
18
|
+
env: Record<string, string>;
|
|
19
|
+
context: StagedAuthContext;
|
|
20
|
+
}
|
|
21
|
+
export declare function verifyAgentProviders(agents: readonly AgentDefinition[]): Promise<void>;
|
|
22
|
+
export declare function stageAgentAuth(options: StageAuthOptions): Promise<StageAuthResult>;
|
|
23
|
+
export declare function teardownAuthContext(context: StagedAuthContext | undefined): Promise<void>;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { rm } from "node:fs/promises";
|
|
2
|
+
import { resolveAuthProvider } from "../../../auth/providers/index.js";
|
|
3
|
+
import { buildAuthRuntimeContext } from "../../../auth/runtime.js";
|
|
4
|
+
import { toErrorMessage } from "../../../utils/errors.js";
|
|
5
|
+
import { isFileSystemError } from "../../../utils/fs.js";
|
|
6
|
+
import { AuthProviderStageError, AuthProviderVerificationError, MissingAgentProviderError, RunCommandError, UnknownAuthProviderError, } from "../errors.js";
|
|
7
|
+
import { getRunCommand } from "./sandbox-launcher.js";
|
|
8
|
+
export async function verifyAgentProviders(agents) {
|
|
9
|
+
if (agents.length === 0) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
await getRunCommand();
|
|
13
|
+
const runtime = buildAuthRuntimeContext();
|
|
14
|
+
for (const agent of agents) {
|
|
15
|
+
const provider = resolveAgentProvider(agent);
|
|
16
|
+
try {
|
|
17
|
+
await provider.verify({
|
|
18
|
+
agentId: agent.id,
|
|
19
|
+
runtime,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
throw new AuthProviderVerificationError(extractAuthProviderMessage(error));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export async function stageAgentAuth(options) {
|
|
28
|
+
const { agent, agentRoot, runId } = options;
|
|
29
|
+
const provider = resolveAgentProvider(agent);
|
|
30
|
+
const runtime = options.runtime ?? buildAuthRuntimeContext();
|
|
31
|
+
try {
|
|
32
|
+
const stageResult = await provider.stage({
|
|
33
|
+
agentId: agent.id,
|
|
34
|
+
agentRoot,
|
|
35
|
+
runtime,
|
|
36
|
+
runId,
|
|
37
|
+
root: options.root,
|
|
38
|
+
});
|
|
39
|
+
return {
|
|
40
|
+
env: stageResult.env,
|
|
41
|
+
context: {
|
|
42
|
+
provider,
|
|
43
|
+
sandboxPath: stageResult.sandboxPath,
|
|
44
|
+
runtime,
|
|
45
|
+
agentId: agent.id,
|
|
46
|
+
runId,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
throw new AuthProviderStageError(extractAuthProviderMessage(error));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export async function teardownAuthContext(context) {
|
|
55
|
+
if (!context) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (tornDownContexts.has(context)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
tornDownContexts.add(context);
|
|
62
|
+
try {
|
|
63
|
+
if (context.provider.teardown) {
|
|
64
|
+
try {
|
|
65
|
+
await context.provider.teardown({
|
|
66
|
+
sandboxPath: context.sandboxPath,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
if (!isIgnorableTeardownError(error)) {
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
await rm(context.sandboxPath, { recursive: true, force: true });
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
tornDownContexts.delete(context);
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const tornDownContexts = new WeakSet();
|
|
83
|
+
function isIgnorableTeardownError(error) {
|
|
84
|
+
if (!isFileSystemError(error)) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
return error.code === "ENOENT";
|
|
88
|
+
}
|
|
89
|
+
function resolveAgentProvider(agent) {
|
|
90
|
+
const providerId = agent.provider;
|
|
91
|
+
if (!providerId) {
|
|
92
|
+
throw new MissingAgentProviderError(agent.id);
|
|
93
|
+
}
|
|
94
|
+
const provider = resolveAuthProvider(providerId);
|
|
95
|
+
if (!provider) {
|
|
96
|
+
throw new UnknownAuthProviderError(providerId);
|
|
97
|
+
}
|
|
98
|
+
return provider;
|
|
99
|
+
}
|
|
100
|
+
function extractAuthProviderMessage(error) {
|
|
101
|
+
if (error instanceof RunCommandError) {
|
|
102
|
+
return error.messageForDisplay();
|
|
103
|
+
}
|
|
104
|
+
if (error instanceof Error && error.message) {
|
|
105
|
+
return error.message;
|
|
106
|
+
}
|
|
107
|
+
return toErrorMessage(error);
|
|
108
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AgentDefinition } from "../../../configs/agents/types.js";
|
|
2
|
+
import { AgentRunContext } from "./run-context.js";
|
|
3
|
+
export interface CaptureChatOptions {
|
|
4
|
+
agent: AgentDefinition;
|
|
5
|
+
agentContext: AgentRunContext;
|
|
6
|
+
agentRoot: string;
|
|
7
|
+
reason?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function captureAgentChatTranscripts(options: CaptureChatOptions): Promise<void>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { toErrorMessage } from "../../../utils/errors.js";
|
|
2
|
+
import { preserveProviderChatTranscripts } from "../../../workspace/chat/artifacts.js";
|
|
3
|
+
export async function captureAgentChatTranscripts(options) {
|
|
4
|
+
const providerId = options.agent.provider;
|
|
5
|
+
if (!providerId) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const result = await preserveProviderChatTranscripts({
|
|
9
|
+
providerId,
|
|
10
|
+
agentRoot: options.agentRoot,
|
|
11
|
+
});
|
|
12
|
+
const format = result.format;
|
|
13
|
+
if ((result.status === "captured" || result.status === "already-exists") &&
|
|
14
|
+
format) {
|
|
15
|
+
options.agentContext.markChatArtifact(format);
|
|
16
|
+
if (result.status === "captured" &&
|
|
17
|
+
format === "json" &&
|
|
18
|
+
(result.sourceCount ?? 0) > 1) {
|
|
19
|
+
// Intentionally silent: avoid noisy warnings during routine runs.
|
|
20
|
+
}
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (result.status === "not-found") {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (result.status === "error") {
|
|
27
|
+
throw new Error(formatChatWarning(options, `Failed to preserve ${providerId} transcripts: ${toErrorMessage(result.error)}`));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function formatChatWarning(options, message) {
|
|
31
|
+
const prefix = options.reason
|
|
32
|
+
? `[voratiq] (${options.agent.id}, ${options.reason})`
|
|
33
|
+
: `[voratiq] (${options.agent.id})`;
|
|
34
|
+
return `${prefix} ${message}`;
|
|
35
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { EnvironmentConfig } from "../../../configs/environment/types.js";
|
|
2
|
+
import type { AgentEvalResult, EvalDefinition } from "../../../configs/evals/types.js";
|
|
3
|
+
import { type ArtifactCollectionResult, type SandboxPersona } from "../../../workspace/agents.js";
|
|
4
|
+
import type { AgentWorkspacePaths } from "../../../workspace/layout.js";
|
|
5
|
+
export interface EvalRunInput {
|
|
6
|
+
evalPlan: readonly EvalDefinition[];
|
|
7
|
+
workspacePaths: AgentWorkspacePaths;
|
|
8
|
+
baseRevisionSha: string;
|
|
9
|
+
root: string;
|
|
10
|
+
manifestEnv: Record<string, string>;
|
|
11
|
+
environment: EnvironmentConfig;
|
|
12
|
+
persona: SandboxPersona;
|
|
13
|
+
}
|
|
14
|
+
export interface EvalRunResult {
|
|
15
|
+
artifacts: ArtifactCollectionResult;
|
|
16
|
+
evaluations: AgentEvalResult[];
|
|
17
|
+
warnings: string[];
|
|
18
|
+
}
|
|
19
|
+
export declare function runPostProcessingAndEvaluations(input: EvalRunInput): Promise<EvalRunResult>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { executeEvaluations } from "../../../evals/runner.js";
|
|
2
|
+
import { collectAgentArtifacts, } from "../../../workspace/agents.js";
|
|
3
|
+
export async function runPostProcessingAndEvaluations(input) {
|
|
4
|
+
const { evalPlan, workspacePaths, baseRevisionSha, root, manifestEnv, environment, persona, } = input;
|
|
5
|
+
const artifacts = await collectAgentArtifacts({
|
|
6
|
+
baseRevisionSha,
|
|
7
|
+
workspacePath: workspacePaths.workspacePath,
|
|
8
|
+
summaryPath: workspacePaths.summaryPath,
|
|
9
|
+
diffPath: workspacePaths.diffPath,
|
|
10
|
+
root,
|
|
11
|
+
environment,
|
|
12
|
+
persona,
|
|
13
|
+
});
|
|
14
|
+
const evalOutcome = await executeEvaluations({
|
|
15
|
+
evaluations: evalPlan,
|
|
16
|
+
cwd: workspacePaths.workspacePath,
|
|
17
|
+
root,
|
|
18
|
+
logsDirectory: workspacePaths.evalsDirPath,
|
|
19
|
+
env: manifestEnv,
|
|
20
|
+
environment,
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
artifacts,
|
|
24
|
+
evaluations: evalOutcome.results,
|
|
25
|
+
warnings: evalOutcome.warnings,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { CLAUDE_OAUTH_RELOGIN_HINT, CLAUDE_PROVIDER_ID, } from "../../../auth/providers/claude/constants.js";
|
|
3
|
+
const CLAUDE_FAILURE_PATTERNS = [
|
|
4
|
+
/Please run \/login/i,
|
|
5
|
+
/OAuth token has expired/i,
|
|
6
|
+
];
|
|
7
|
+
export async function detectAgentProcessFailureDetail(input) {
|
|
8
|
+
if (input.provider !== CLAUDE_PROVIDER_ID) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
const combinedLogs = await readCombinedLogs(input.stdoutPath, input.stderrPath);
|
|
12
|
+
if (combinedLogs &&
|
|
13
|
+
CLAUDE_FAILURE_PATTERNS.some((pattern) => pattern.test(combinedLogs))) {
|
|
14
|
+
return CLAUDE_OAUTH_RELOGIN_HINT;
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
async function readCombinedLogs(stdoutPath, stderrPath) {
|
|
19
|
+
const [stdout, stderr] = await Promise.all([
|
|
20
|
+
safeRead(stdoutPath),
|
|
21
|
+
safeRead(stderrPath),
|
|
22
|
+
]);
|
|
23
|
+
return `${stdout}\n${stderr}`;
|
|
24
|
+
}
|
|
25
|
+
async function safeRead(path) {
|
|
26
|
+
try {
|
|
27
|
+
return await readFile(path, "utf8");
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return "";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AgentInvocationRecord } from "../../../records/types.js";
|
|
2
|
+
import { RunCommandError } from "../errors.js";
|
|
3
|
+
import type { AgentExecutionResult } from "../reports.js";
|
|
4
|
+
import { AgentRunContext } from "./run-context.js";
|
|
5
|
+
import type { PreparedAgentExecution } from "./types.js";
|
|
6
|
+
export declare function runPreparedAgent(execution: PreparedAgentExecution): Promise<AgentExecutionResult>;
|
|
7
|
+
export declare function executeAgentLifecycle(execution: PreparedAgentExecution): Promise<AgentExecutionResult>;
|
|
8
|
+
export declare function buildRunningAgentRecord(execution: PreparedAgentExecution, agentContext: AgentRunContext): AgentInvocationRecord;
|
|
9
|
+
export declare function classifyPostProcessError(error: unknown): RunCommandError;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { toErrorMessage } from "../../../utils/errors.js";
|
|
2
|
+
import { GIT_AUTHOR_EMAIL, GIT_AUTHOR_NAME } from "../../../utils/git.js";
|
|
3
|
+
import { AgentProcessError, GitOperationError, RunCommandError, } from "../errors.js";
|
|
4
|
+
import { teardownRegisteredSandboxContext } from "../sandbox-registry.js";
|
|
5
|
+
import { captureAgentChatTranscripts } from "./chat-preserver.js";
|
|
6
|
+
import { runPostProcessingAndEvaluations } from "./eval-runner.js";
|
|
7
|
+
import { detectAgentProcessFailureDetail } from "./failures.js";
|
|
8
|
+
import { runAgentProcess } from "./sandbox-launcher.js";
|
|
9
|
+
import { WATCHDOG_DEFAULTS } from "./watchdog.js";
|
|
10
|
+
export async function runPreparedAgent(execution) {
|
|
11
|
+
try {
|
|
12
|
+
return await executeAgentLifecycle(execution);
|
|
13
|
+
}
|
|
14
|
+
finally {
|
|
15
|
+
await teardownRegisteredSandboxContext(execution.authContext);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export async function executeAgentLifecycle(execution) {
|
|
19
|
+
const { agentContext, agent, workspacePaths, baseRevisionSha, root, evalPlan, runtimeManifestPath, environment, manifestEnv, } = execution;
|
|
20
|
+
// Set initial watchdog metadata (will be updated with trigger if fired)
|
|
21
|
+
const initialWatchdog = {
|
|
22
|
+
silenceTimeoutMs: WATCHDOG_DEFAULTS.silenceTimeoutMs,
|
|
23
|
+
wallClockCapMs: WATCHDOG_DEFAULTS.wallClockCapMs,
|
|
24
|
+
};
|
|
25
|
+
agentContext.setWatchdogMetadata(initialWatchdog);
|
|
26
|
+
try {
|
|
27
|
+
agentContext.markStarted();
|
|
28
|
+
if (execution.progress?.onRunning) {
|
|
29
|
+
await execution.progress.onRunning(buildRunningAgentRecord(execution, agentContext));
|
|
30
|
+
}
|
|
31
|
+
// Create watchdog trigger callback for immediate UI surfacing
|
|
32
|
+
const onWatchdogTrigger = (trigger, reason) => {
|
|
33
|
+
// Update watchdog metadata with trigger
|
|
34
|
+
agentContext.setWatchdogMetadata({
|
|
35
|
+
...initialWatchdog,
|
|
36
|
+
trigger,
|
|
37
|
+
});
|
|
38
|
+
// Fire early failure callback for immediate UI update
|
|
39
|
+
if (execution.progress?.onEarlyFailure) {
|
|
40
|
+
const earlyRecord = agentContext.buildEarlyFailureRecord(reason);
|
|
41
|
+
void execution.progress.onEarlyFailure(earlyRecord);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const processResult = await runAgentProcess({
|
|
45
|
+
runtimeManifestPath,
|
|
46
|
+
agentRoot: workspacePaths.agentRoot,
|
|
47
|
+
stdoutPath: workspacePaths.stdoutPath,
|
|
48
|
+
stderrPath: workspacePaths.stderrPath,
|
|
49
|
+
sandboxSettingsPath: workspacePaths.sandboxSettingsPath,
|
|
50
|
+
providerId: agent.provider,
|
|
51
|
+
onWatchdogTrigger,
|
|
52
|
+
});
|
|
53
|
+
// Update watchdog metadata from process result (in case trigger came via watchdog)
|
|
54
|
+
if (processResult.watchdog) {
|
|
55
|
+
agentContext.setWatchdogMetadata(processResult.watchdog);
|
|
56
|
+
}
|
|
57
|
+
if (processResult.exitCode !== 0 || processResult.errorMessage) {
|
|
58
|
+
// Use watchdog error message if available, otherwise detect from logs
|
|
59
|
+
const failureDetail = processResult.watchdog?.trigger && processResult.errorMessage
|
|
60
|
+
? processResult.errorMessage
|
|
61
|
+
: await detectAgentProcessFailureDetail({
|
|
62
|
+
agentId: agent.id,
|
|
63
|
+
provider: agent.provider,
|
|
64
|
+
stdoutPath: workspacePaths.stdoutPath,
|
|
65
|
+
stderrPath: workspacePaths.stderrPath,
|
|
66
|
+
});
|
|
67
|
+
const failure = new AgentProcessError({
|
|
68
|
+
exitCode: processResult.exitCode,
|
|
69
|
+
detail: failureDetail,
|
|
70
|
+
});
|
|
71
|
+
agentContext.markFailure(failure);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (rawError) {
|
|
75
|
+
const failure = rawError instanceof RunCommandError
|
|
76
|
+
? rawError
|
|
77
|
+
: new AgentProcessError({
|
|
78
|
+
detail: toErrorMessage(rawError),
|
|
79
|
+
});
|
|
80
|
+
agentContext.markFailure(failure);
|
|
81
|
+
}
|
|
82
|
+
await captureAgentChatTranscripts({
|
|
83
|
+
agent,
|
|
84
|
+
agentContext,
|
|
85
|
+
agentRoot: workspacePaths.agentRoot,
|
|
86
|
+
reason: "post-run",
|
|
87
|
+
});
|
|
88
|
+
if (agentContext.isFailed()) {
|
|
89
|
+
agentContext.setCompleted();
|
|
90
|
+
return finalizeExecution(execution, () => agentContext.finalize());
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
const postProcessResult = await runPostProcessingAndEvaluations({
|
|
94
|
+
evalPlan,
|
|
95
|
+
workspacePaths,
|
|
96
|
+
baseRevisionSha,
|
|
97
|
+
root,
|
|
98
|
+
manifestEnv,
|
|
99
|
+
environment,
|
|
100
|
+
persona: resolveSandboxPersona(manifestEnv),
|
|
101
|
+
});
|
|
102
|
+
agentContext.applyArtifacts(postProcessResult.artifacts);
|
|
103
|
+
if (postProcessResult.warnings.length > 0) {
|
|
104
|
+
for (const warning of postProcessResult.warnings) {
|
|
105
|
+
console.warn(`[voratiq] ${warning}`);
|
|
106
|
+
}
|
|
107
|
+
agentContext.recordEvalWarnings(postProcessResult.warnings);
|
|
108
|
+
}
|
|
109
|
+
agentContext.applyEvaluations(postProcessResult.evaluations);
|
|
110
|
+
}
|
|
111
|
+
catch (rawError) {
|
|
112
|
+
const failure = classifyPostProcessError(rawError);
|
|
113
|
+
return finalizeExecution(execution, async () => agentContext.failWith(failure));
|
|
114
|
+
}
|
|
115
|
+
agentContext.setCompleted();
|
|
116
|
+
return finalizeExecution(execution, () => agentContext.finalize());
|
|
117
|
+
}
|
|
118
|
+
export function buildRunningAgentRecord(execution, agentContext) {
|
|
119
|
+
const { agent } = execution;
|
|
120
|
+
return {
|
|
121
|
+
agentId: agent.id,
|
|
122
|
+
model: agent.model,
|
|
123
|
+
status: "running",
|
|
124
|
+
startedAt: agentContext.getStartedAt(),
|
|
125
|
+
artifacts: {
|
|
126
|
+
diffAttempted: false,
|
|
127
|
+
diffCaptured: false,
|
|
128
|
+
stdoutCaptured: true,
|
|
129
|
+
stderrCaptured: true,
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
export function classifyPostProcessError(error) {
|
|
134
|
+
if (error instanceof RunCommandError) {
|
|
135
|
+
return error;
|
|
136
|
+
}
|
|
137
|
+
const detail = toErrorMessage(error);
|
|
138
|
+
return new GitOperationError({
|
|
139
|
+
operation: "Run finalization failed",
|
|
140
|
+
detail,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
async function finalizeExecution(execution, finalize) {
|
|
144
|
+
const result = await finalize();
|
|
145
|
+
if (execution.progress?.onCompleted) {
|
|
146
|
+
await execution.progress.onCompleted(result);
|
|
147
|
+
}
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
function resolveSandboxPersona(env) {
|
|
151
|
+
// The sandbox shim injects these Git persona env vars before spawning agent binaries.
|
|
152
|
+
// Keep this helper synchronized with src/commands/run/shim/run-agent-shim.ts.
|
|
153
|
+
return {
|
|
154
|
+
authorName: env["GIT_AUTHOR_NAME"] ?? GIT_AUTHOR_NAME,
|
|
155
|
+
authorEmail: env["GIT_AUTHOR_EMAIL"] ?? GIT_AUTHOR_EMAIL,
|
|
156
|
+
};
|
|
157
|
+
}
|