@fitlab-ai/agent-infra 0.9.8 → 0.9.10
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 +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/bin/internal-cli.js +11 -1
- package/dist/lib/agent-clients/adapters/codex-lifecycle/app-server.js +58 -21
- package/dist/lib/agent-clients/adapters/codex-lifecycle/build-identity.js +25 -11
- package/dist/lib/agent-clients/adapters/codex-lifecycle/capability-store.js +173 -10
- package/dist/lib/agent-clients/adapters/codex-lifecycle/controller-context.js +127 -0
- package/dist/lib/agent-clients/adapters/codex-lifecycle/evidence.js +14 -0
- package/dist/lib/agent-clients/adapters/codex-lifecycle/sandbox-controller.js +63 -92
- package/dist/lib/agent-clients/adapters/codex-sandbox.js +72 -11
- package/dist/lib/agent-clients/adapters/index.js +3 -1
- package/dist/lib/agent-clients/adapters/traecli.js +66 -0
- package/dist/lib/agent-clients/tokens.js +2 -2
- package/dist/lib/agent-clients/types.js +2 -1
- package/dist/lib/defaults.json +5 -0
- package/dist/lib/git/workflow.js +10 -1
- package/dist/lib/internal/codex-lifecycle.js +20 -6
- package/dist/lib/internal/codex-sandbox-controller.js +9 -15
- package/dist/lib/internal/git-workflow.js +5 -7
- package/dist/lib/internal/platform-pr.js +20 -7
- package/dist/lib/internal/release-workflow.js +2 -1
- package/dist/lib/internal/sandbox-control.js +79 -2
- package/dist/lib/internal/task-finalization.js +54 -0
- package/dist/lib/internal/task-orchestration.js +156 -291
- package/dist/lib/{task/commands/validate.js → internal/task-validate.js} +75 -42
- package/dist/lib/platform/pr-summary.js +48 -10
- package/dist/lib/platform/pull-requests.js +205 -41
- package/dist/lib/run/tui.js +5 -2
- package/dist/lib/sandbox/commands/rm.js +316 -55
- package/dist/lib/sandbox/control/client.js +190 -6
- package/dist/lib/sandbox/control/controller-registration.js +275 -0
- package/dist/lib/sandbox/control/executor.js +140 -5
- package/dist/lib/sandbox/control/lifecycle.js +3 -1
- package/dist/lib/sandbox/control/protocol.js +67 -6
- package/dist/lib/sandbox/index.js +5 -3
- package/dist/lib/sandbox/managed-fs.js +5 -0
- package/dist/lib/sandbox/task-resolver.js +50 -6
- package/dist/lib/sandbox/workspace-identity.js +27 -0
- package/dist/lib/sandbox/worktree-safety.js +215 -2
- package/dist/lib/task/codex-orchestration.js +161 -39
- package/dist/lib/task/commands/status.js +59 -1
- package/dist/lib/task/commit-operation.js +335 -0
- package/dist/lib/task/commit-policy.js +18 -0
- package/dist/lib/task/delegation-receipts.js +248 -6
- package/dist/lib/task/finalization.js +593 -0
- package/dist/lib/task/index.js +0 -9
- package/dist/lib/task/operation-outcome.js +33 -0
- package/dist/lib/task/orchestration.js +187 -761
- package/dist/lib/task/short-id.js +59 -1
- package/dist/lib/task/task-execution-lock.js +6 -1
- package/dist/lib/task/verification-engine.js +110 -60
- package/dist/lib/task/verification.js +2 -1
- package/dist/lib/task/workflow-warning-intents.js +50 -1
- package/dist/lifecycle-build-manifest.json +3 -3
- package/lib/agent-clients/adapters/codex-lifecycle/app-server.ts +61 -19
- package/lib/agent-clients/adapters/codex-lifecycle/build-identity.ts +37 -10
- package/lib/agent-clients/adapters/codex-lifecycle/capability-store.ts +276 -12
- package/lib/agent-clients/adapters/codex-lifecycle/controller-context.ts +163 -0
- package/lib/agent-clients/adapters/codex-lifecycle/evidence.ts +19 -0
- package/lib/agent-clients/adapters/codex-lifecycle/manifest-files.json +9 -1
- package/lib/agent-clients/adapters/codex-lifecycle/sandbox-controller.ts +91 -118
- package/lib/agent-clients/adapters/codex-sandbox.ts +89 -14
- package/lib/agent-clients/adapters/index.ts +3 -1
- package/lib/agent-clients/adapters/traecli.ts +67 -0
- package/lib/agent-clients/tokens.ts +2 -2
- package/lib/agent-clients/types.ts +2 -1
- package/lib/defaults.json +5 -0
- package/lib/git/workflow.ts +11 -2
- package/lib/internal/codex-lifecycle.ts +19 -6
- package/lib/internal/codex-sandbox-controller.ts +9 -14
- package/lib/internal/git-workflow.ts +5 -6
- package/lib/internal/platform-pr.ts +14 -7
- package/lib/internal/release-workflow.ts +2 -1
- package/lib/internal/sandbox-control.ts +92 -2
- package/lib/internal/task-finalization.ts +68 -0
- package/lib/internal/task-orchestration.ts +20 -103
- package/lib/{task/commands/validate.ts → internal/task-validate.ts} +75 -40
- package/lib/platform/pr-summary.ts +55 -11
- package/lib/platform/pull-requests.ts +211 -41
- package/lib/run/tui.ts +5 -3
- package/lib/sandbox/commands/rm.ts +413 -61
- package/lib/sandbox/control/client.ts +255 -6
- package/lib/sandbox/control/controller-registration.ts +352 -0
- package/lib/sandbox/control/executor.ts +169 -5
- package/lib/sandbox/control/lifecycle.ts +2 -1
- package/lib/sandbox/control/protocol.ts +80 -7
- package/lib/sandbox/index.ts +5 -3
- package/lib/sandbox/managed-fs.ts +5 -0
- package/lib/sandbox/task-resolver.ts +58 -7
- package/lib/sandbox/workspace-identity.ts +50 -2
- package/lib/sandbox/workspace-view.ts +3 -3
- package/lib/sandbox/worktree-safety.ts +236 -2
- package/lib/task/codex-orchestration.ts +168 -40
- package/lib/task/commands/status.ts +78 -1
- package/lib/task/commit-operation.ts +430 -0
- package/lib/task/commit-policy.ts +30 -0
- package/lib/task/delegation-receipts.ts +263 -4
- package/lib/task/finalization.ts +761 -0
- package/lib/task/index.ts +0 -8
- package/lib/task/operation-outcome.ts +48 -0
- package/lib/task/orchestration.ts +218 -982
- package/lib/task/short-id.ts +65 -1
- package/lib/task/task-execution-lock.ts +10 -1
- package/lib/task/verification-engine.ts +115 -63
- package/lib/task/verification.ts +3 -2
- package/lib/task/workflow-warning-intents.ts +57 -2
- package/package.json +2 -2
- package/templates/.agents/QUICKSTART.en.md +3 -4
- package/templates/.agents/QUICKSTART.zh-CN.md +3 -4
- package/templates/.agents/hooks/lifecycle-delegation.js +1 -21
- package/templates/.agents/rules/README.en.md +1 -0
- package/templates/.agents/rules/README.zh-CN.md +1 -0
- package/templates/.agents/rules/compatibility-policy.en.md +39 -0
- package/templates/.agents/rules/compatibility-policy.zh-CN.md +39 -0
- package/templates/.agents/rules/lifecycle-orchestration.en.md +4 -4
- package/templates/.agents/rules/lifecycle-orchestration.zh-CN.md +4 -4
- package/templates/.agents/rules/pr-sync.en.md +1 -1
- package/templates/.agents/rules/pr-sync.github.en.md +2 -1
- package/templates/.agents/rules/pr-sync.github.zh-CN.md +2 -0
- package/templates/.agents/rules/pr-sync.zh-CN.md +1 -0
- package/templates/.agents/rules/review-method.en.md +1 -0
- package/templates/.agents/rules/review-method.zh-CN.md +1 -0
- package/templates/.agents/rules/task-management.en.md +2 -2
- package/templates/.agents/rules/task-management.zh-CN.md +2 -2
- package/templates/.agents/skills/analyze-task/SKILL.en.md +1 -0
- package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +1 -0
- package/templates/.agents/skills/block-task/SKILL.en.md +2 -4
- package/templates/.agents/skills/block-task/SKILL.zh-CN.md +2 -4
- package/templates/.agents/skills/cancel-task/SKILL.en.md +3 -3
- package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +3 -3
- package/templates/.agents/skills/close-codescan/SKILL.en.md +6 -2
- package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +6 -2
- package/templates/.agents/skills/close-dependabot/SKILL.en.md +6 -2
- package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +6 -2
- package/templates/.agents/skills/code-task/SKILL.en.md +1 -0
- package/templates/.agents/skills/code-task/SKILL.zh-CN.md +2 -0
- package/templates/.agents/skills/commit/SKILL.en.md +41 -125
- package/templates/.agents/skills/commit/SKILL.zh-CN.md +52 -123
- package/templates/.agents/skills/commit/reference/commit-message.en.md +1 -1
- package/templates/.agents/skills/commit/reference/commit-message.zh-CN.md +1 -1
- package/templates/.agents/skills/commit/reference/commit-orchestration.en.md +14 -43
- package/templates/.agents/skills/commit/reference/commit-orchestration.zh-CN.md +14 -49
- package/templates/.agents/skills/commit/reference/pr-summary-sync.en.md +1 -1
- package/templates/.agents/skills/commit/reference/pr-summary-sync.zh-CN.md +1 -1
- package/templates/.agents/skills/commit/reference/task-status-update.en.md +2 -35
- package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +2 -35
- package/templates/.agents/skills/complete-task/SKILL.en.md +31 -38
- package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +31 -38
- package/templates/.agents/skills/complete-task/config/verify.en.json +1 -0
- package/templates/.agents/skills/complete-task/config/verify.zh-CN.json +1 -0
- package/templates/.agents/skills/complete-task/reference/external-delivery.en.md +1 -1
- package/templates/.agents/skills/complete-task/reference/external-delivery.zh-CN.md +1 -1
- package/templates/.agents/skills/create-pr/SKILL.en.md +17 -9
- package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +17 -9
- package/templates/.agents/skills/create-pr/reference/change-report.en.md +41 -0
- package/templates/.agents/skills/create-pr/reference/change-report.zh-CN.md +41 -0
- package/templates/.agents/skills/create-pr/reference/comment-publish.en.md +2 -2
- package/templates/.agents/skills/create-pr/reference/comment-publish.zh-CN.md +2 -2
- package/templates/.agents/skills/plan-task/SKILL.en.md +2 -1
- package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +2 -1
- package/templates/.agents/skills/review-code/reference/migration-risks.en.md +8 -6
- package/templates/.agents/skills/review-code/reference/migration-risks.zh-CN.md +8 -6
- package/templates/.agents/skills/run-manual-validation/SKILL.en.md +3 -3
- package/templates/.agents/skills/run-manual-validation/SKILL.zh-CN.md +3 -3
- package/templates/.agents/skills/run-manual-validation/reference/discovery-and-execution.en.md +1 -1
- package/templates/.agents/skills/run-manual-validation/reference/discovery-and-execution.zh-CN.md +1 -1
- package/templates/.agents/skills/run-manual-validation/reference/report-template.en.md +2 -2
- package/templates/.agents/skills/run-manual-validation/reference/report-template.zh-CN.md +2 -2
- package/templates/.agents/skills/run-task/SKILL.en.md +6 -6
- package/templates/.agents/skills/run-task/SKILL.zh-CN.md +6 -6
- package/templates/.agents/skills/run-task/reference/host-validation.en.md +2 -2
- package/templates/.agents/skills/run-task/reference/host-validation.zh-CN.md +2 -2
- package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +24 -0
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.en.md +1 -1
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.zh-CN.md +1 -1
- package/templates/.codex/hooks.json +4 -4
- package/templates/.trae/skills/update-agent-infra.en.md +8 -0
- package/templates/.trae/skills/update-agent-infra.zh-CN.md +8 -0
- package/dist/lib/task/commit-finalization.js +0 -305
- package/dist/lib/task/commit-intent.js +0 -165
- package/lib/task/commit-finalization.ts +0 -419
- package/lib/task/commit-intent.ts +0 -230
|
@@ -7,12 +7,12 @@ const USAGE = `Usage: agent-infra-internal platform-pr inspect <task-ref> [--cwd
|
|
|
7
7
|
agent-infra-internal platform-pr resolve-external <task-ref> --agent <agent> [--pr <N>] [--dry-run] [--cwd <path>]
|
|
8
8
|
agent-infra-internal platform-pr create <task-ref> --agent <agent> --base <branch> --head <branch> --title-file <path|-> --body-file <path|-> [--draft] [--dry-run] [--cwd <path>]
|
|
9
9
|
agent-infra-internal platform-pr bind <task-ref> --pr <N> --agent <agent> [--dry-run] [--cwd <path>]
|
|
10
|
-
agent-infra-internal platform-pr sync <task-ref> --agent <agent> [--metadata] [--closing-issue] [--dry-run] [--cwd <path>]
|
|
10
|
+
agent-infra-internal platform-pr sync <task-ref> --agent <agent> [--metadata] [--closing-issue] --result <pr_created|pr_reused|no_op> [--dry-run] [--cwd <path>]
|
|
11
11
|
agent-infra-internal platform-pr summary-context <task-ref> [--cwd <path>]
|
|
12
|
-
agent-infra-internal platform-pr summary-sync <task-ref> --agent <agent> --body-file <path|-> [--dry-run] [--cwd <path>]
|
|
12
|
+
agent-infra-internal platform-pr summary-sync <task-ref> --agent <agent> --body-file <path|-> --result <pr_created|pr_reused|no_op> [--dry-run] [--cwd <path>]
|
|
13
13
|
`;
|
|
14
14
|
const BOOLEAN_FLAGS = new Set(['--draft', '--dry-run', '--metadata', '--closing-issue']);
|
|
15
|
-
const VALUE_FLAGS = new Set(['--cwd', '--agent', '--base', '--head', '--title-file', '--body-file', '--pr']);
|
|
15
|
+
const VALUE_FLAGS = new Set(['--cwd', '--agent', '--base', '--head', '--title-file', '--body-file', '--pr', '--result']);
|
|
16
16
|
function key(flag) {
|
|
17
17
|
return flag.slice(2).replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
18
18
|
}
|
|
@@ -79,9 +79,9 @@ function platformPr(args = []) {
|
|
|
79
79
|
'resolve-external': ['cwd', 'agent', 'pr', 'dryRun'],
|
|
80
80
|
create: ['cwd', 'agent', 'base', 'head', 'titleFile', 'bodyFile', 'draft', 'dryRun'],
|
|
81
81
|
bind: ['cwd', 'agent', 'pr', 'dryRun'],
|
|
82
|
-
sync: ['cwd', 'agent', 'metadata', 'closingIssue', 'dryRun'],
|
|
82
|
+
sync: ['cwd', 'agent', 'metadata', 'closingIssue', 'result', 'dryRun'],
|
|
83
83
|
'summary-context': ['cwd'],
|
|
84
|
-
'summary-sync': ['cwd', 'agent', 'bodyFile', 'dryRun']
|
|
84
|
+
'summary-sync': ['cwd', 'agent', 'bodyFile', 'result', 'dryRun']
|
|
85
85
|
};
|
|
86
86
|
const unexpected = Object.keys(values).find((name) => !allowed[operation].includes(name));
|
|
87
87
|
if (unexpected) {
|
|
@@ -106,6 +106,11 @@ function platformPr(args = []) {
|
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
108
|
values.agent = agent;
|
|
109
|
+
const primaryResult = values.result === undefined ? undefined : values.result;
|
|
110
|
+
if (primaryResult !== undefined && !['pr_created', 'pr_reused', 'no_op'].includes(primaryResult)) {
|
|
111
|
+
fail('--result must be pr_created, pr_reused, or no_op');
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
109
114
|
if (operation === 'resolve-external') {
|
|
110
115
|
const pr = values.pr === undefined ? undefined : Number(values.pr);
|
|
111
116
|
if (pr !== undefined && (!Number.isInteger(pr) || pr <= 0)) {
|
|
@@ -129,7 +134,11 @@ function platformPr(args = []) {
|
|
|
129
134
|
fail('sync requires --metadata or --closing-issue');
|
|
130
135
|
return;
|
|
131
136
|
}
|
|
132
|
-
|
|
137
|
+
if (!primaryResult) {
|
|
138
|
+
fail('sync requires --result pr_created, pr_reused, or no_op');
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
finish(syncPlatformPullRequest(taskRef, { cwd, agent: values.agent, metadata: values.metadata === true, closingIssue: values.closingIssue === true, primaryResult: primaryResult, dryRun: values.dryRun === true }));
|
|
133
142
|
return;
|
|
134
143
|
}
|
|
135
144
|
if (operation === 'summary-sync') {
|
|
@@ -137,8 +146,12 @@ function platformPr(args = []) {
|
|
|
137
146
|
fail('summary-sync requires --body-file');
|
|
138
147
|
return;
|
|
139
148
|
}
|
|
149
|
+
if (!primaryResult) {
|
|
150
|
+
fail('summary-sync requires --result pr_created, pr_reused, or no_op');
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
140
153
|
try {
|
|
141
|
-
finish(syncPullRequestSummary(taskRef, { cwd, agent: values.agent, body: readFile(values.bodyFile, cwd), dryRun: values.dryRun === true }));
|
|
154
|
+
finish(syncPullRequestSummary(taskRef, { cwd, agent: values.agent, body: readFile(values.bodyFile, cwd), primaryResult: primaryResult, dryRun: values.dryRun === true }));
|
|
142
155
|
}
|
|
143
156
|
catch (error) {
|
|
144
157
|
fail(`unable to read body file: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -10,12 +10,13 @@ import { releaseSnapshot } from '../release/workflow.js';
|
|
|
10
10
|
function command(cwd, executable, args) {
|
|
11
11
|
return spawnSync(executable, args, { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
|
|
12
12
|
}
|
|
13
|
+
// The tape is the canonical init interaction contract. Do not hash all of
|
|
14
|
+
// lib/init.ts: non-visual config serialization changes must not re-record it.
|
|
13
15
|
const DEMO_INPUT_PATHS = [
|
|
14
16
|
'assets/demo-init.tape',
|
|
15
17
|
'scripts/demo-regen.sh',
|
|
16
18
|
'scripts/normalize-gif-duration.py',
|
|
17
19
|
'bin/cli.ts',
|
|
18
|
-
'lib/init.ts',
|
|
19
20
|
'lib/log.ts',
|
|
20
21
|
'lib/prompt.ts',
|
|
21
22
|
'lib/paths.ts',
|
|
@@ -1,6 +1,70 @@
|
|
|
1
|
-
import { requestSandboxControl, SandboxControlClientError } from '../sandbox/control/client.js';
|
|
1
|
+
import { requestSandboxControl, requestSandboxTaskFinalization, requestSandboxTaskControl, SandboxControlClientError } from '../sandbox/control/client.js';
|
|
2
|
+
import { normalizeAgentToken, AGENT_USAGE_HINT } from '../agent-clients/tokens.js';
|
|
2
3
|
import { serveSandboxControl } from '../sandbox/control/server.js';
|
|
3
4
|
import { runSandboxControlExecutor } from '../sandbox/control/executor.js';
|
|
5
|
+
import { controllerProofFromContext, verifyCodexSandboxControllerContextWithWarnings } from '../agent-clients/adapters/codex-lifecycle/sandbox-controller.js';
|
|
6
|
+
function isCanonicalCodexPrepare(args) {
|
|
7
|
+
if (args[1] !== 'prepare')
|
|
8
|
+
return false;
|
|
9
|
+
const clients = [];
|
|
10
|
+
for (let index = 2; index < args.length; index += 1) {
|
|
11
|
+
if (args[index] === '--client')
|
|
12
|
+
clients.push(args[index + 1] ?? '');
|
|
13
|
+
else if (args[index]?.startsWith('--client='))
|
|
14
|
+
clients.push(args[index].slice('--client='.length));
|
|
15
|
+
}
|
|
16
|
+
return clients.length === 1 && clients[0] === 'codex';
|
|
17
|
+
}
|
|
18
|
+
function writeFinalizationEnvelope(status, accepted, error, changed = false, result = null) {
|
|
19
|
+
process.stdout.write(`${JSON.stringify({ version: 1, status, changed, accepted, result, error })}\n`);
|
|
20
|
+
}
|
|
21
|
+
function finalizationErrorStatus(error) {
|
|
22
|
+
if (error.code === 'SANDBOX_CONTROL_RESULT_UNKNOWN')
|
|
23
|
+
return 'unknown';
|
|
24
|
+
return error.retryable ? 'blocked' : 'failed';
|
|
25
|
+
}
|
|
26
|
+
function sandboxFinalizationClient(args) {
|
|
27
|
+
if (args.length !== 4 || !args[0] || args[1] !== 'complete' || args[2] !== '--agent' || !args[3]) {
|
|
28
|
+
const error = { code: 'TASK_FINALIZATION_PAYLOAD_INVALID', message: 'task ref, complete intent, and --agent are required', retryable: false };
|
|
29
|
+
writeFinalizationEnvelope('failed', false, error);
|
|
30
|
+
process.stderr.write('Usage: agent-infra-internal task-finalization <N | TASK-id> complete --agent <agent>\n');
|
|
31
|
+
process.exitCode = 1;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const agent = normalizeAgentToken(args[3]);
|
|
35
|
+
if (!agent) {
|
|
36
|
+
const error = { code: 'TASK_FINALIZATION_PAYLOAD_INVALID', message: `invalid --agent: ${AGENT_USAGE_HINT}`, retryable: false };
|
|
37
|
+
writeFinalizationEnvelope('failed', false, error);
|
|
38
|
+
process.exitCode = 1;
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
let response;
|
|
42
|
+
try {
|
|
43
|
+
response = requestSandboxTaskFinalization({ agent });
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if (!(error instanceof SandboxControlClientError))
|
|
47
|
+
throw error;
|
|
48
|
+
writeFinalizationEnvelope(finalizationErrorStatus(error.detail), error.accepted, error.detail);
|
|
49
|
+
process.stderr.write(`${error.detail.message}\n`);
|
|
50
|
+
process.exitCode = error.detail.code === 'SANDBOX_CONTROL_RESULT_UNKNOWN' ? 1 : error.detail.retryable ? 2 : 1;
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (response.phase === 'rejected') {
|
|
54
|
+
const error = response.error ?? {
|
|
55
|
+
code: 'SANDBOX_CONTROL_REJECTED',
|
|
56
|
+
message: 'sandbox control rejected the finalization request',
|
|
57
|
+
retryable: false
|
|
58
|
+
};
|
|
59
|
+
writeFinalizationEnvelope(finalizationErrorStatus(error), error.code === 'SANDBOX_CONTROL_RESULT_UNKNOWN', error);
|
|
60
|
+
process.stderr.write(`${error.message}\n`);
|
|
61
|
+
process.exitCode = error.code === 'SANDBOX_CONTROL_RESULT_UNKNOWN' ? 1 : error.retryable ? 2 : 1;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
process.stdout.write(response.stdout);
|
|
65
|
+
process.stderr.write(response.stderr);
|
|
66
|
+
process.exitCode = response.exitCode ?? 1;
|
|
67
|
+
}
|
|
4
68
|
async function sandboxControl(args) {
|
|
5
69
|
const [operation, ...rest] = args;
|
|
6
70
|
if (operation === 'serve') {
|
|
@@ -33,9 +97,22 @@ async function sandboxControl(args) {
|
|
|
33
97
|
}
|
|
34
98
|
if (operation === 'client') {
|
|
35
99
|
const [family = '', ...commandArgs] = rest;
|
|
100
|
+
if (family === 'task-finalization') {
|
|
101
|
+
sandboxFinalizationClient(commandArgs);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
36
104
|
let response;
|
|
37
105
|
try {
|
|
38
|
-
|
|
106
|
+
if (family === 'task-orchestration' && isCanonicalCodexPrepare(commandArgs)) {
|
|
107
|
+
const contextPath = process.env.AGENT_INFRA_CODEX_CONTROLLER_CONTEXT;
|
|
108
|
+
const proof = contextPath
|
|
109
|
+
? controllerProofFromContext(verifyCodexSandboxControllerContextWithWarnings(contextPath).context)
|
|
110
|
+
: null;
|
|
111
|
+
response = requestSandboxTaskControl({ family, args: commandArgs, controllerProof: proof });
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
response = requestSandboxControl({ family, args: commandArgs });
|
|
115
|
+
}
|
|
39
116
|
}
|
|
40
117
|
catch (error) {
|
|
41
118
|
if (!(error instanceof SandboxControlClientError))
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { normalizeAgentToken, AGENT_USAGE_HINT } from '../agent-clients/tokens.js';
|
|
2
|
+
import { applyTaskFinalization } from '../task/finalization.js';
|
|
3
|
+
import { detectRepoRoot, resolveTaskRef } from '../task/resolve-ref.js';
|
|
4
|
+
import { verifyTaskEvent } from '../task/verification.js';
|
|
5
|
+
const USAGE = 'Usage: agent-infra-internal task-finalization <N | TASK-id> complete --agent <agent>\n';
|
|
6
|
+
function envelope(status, changed, accepted, result, error) {
|
|
7
|
+
return `${JSON.stringify({ version: 1, status, changed, accepted, result, error })}\n`;
|
|
8
|
+
}
|
|
9
|
+
function exitCode(status) {
|
|
10
|
+
return status === 'completed' ? 0 : status === 'blocked' ? 2 : 1;
|
|
11
|
+
}
|
|
12
|
+
function fail(message) {
|
|
13
|
+
const error = { code: 'TASK_FINALIZATION_PAYLOAD_INVALID', message, retryable: false };
|
|
14
|
+
process.stdout.write(envelope('failed', false, false, null, error));
|
|
15
|
+
process.stderr.write(USAGE);
|
|
16
|
+
process.exitCode = 1;
|
|
17
|
+
}
|
|
18
|
+
function taskFinalization(args = []) {
|
|
19
|
+
if (args[0] === '--help' || args[0] === '-h') {
|
|
20
|
+
process.stdout.write(USAGE);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (args.length !== 4 || !args[0] || args[1] !== 'complete' || args[2] !== '--agent' || !args[3]) {
|
|
24
|
+
fail('task ref, complete intent, and --agent are required');
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const agent = normalizeAgentToken(args[3]);
|
|
28
|
+
if (!agent) {
|
|
29
|
+
fail(`invalid --agent: ${AGENT_USAGE_HINT}`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
let repoRoot;
|
|
33
|
+
try {
|
|
34
|
+
repoRoot = detectRepoRoot();
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
const detail = { code: 'REPO_ROOT_NOT_FOUND', message: error instanceof Error ? error.message : String(error), retryable: false };
|
|
38
|
+
process.stdout.write(envelope('failed', false, true, null, detail));
|
|
39
|
+
process.exitCode = 1;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const resolved = resolveTaskRef(args[0], { repoRoot });
|
|
43
|
+
if (!resolved.ok) {
|
|
44
|
+
const detail = { code: resolved.code, message: resolved.message, retryable: false };
|
|
45
|
+
process.stdout.write(envelope('failed', false, true, null, detail));
|
|
46
|
+
process.exitCode = 1;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const result = applyTaskFinalization({ taskRef: resolved.taskId, intent: 'complete', agent }, { repoRoot, preflight: (request, options) => verifyTaskEvent({ ...request, event: 'complete-task.hard-preflight' }, options) });
|
|
50
|
+
process.stdout.write(envelope(result.status, result.changed, true, result, result.error));
|
|
51
|
+
process.exitCode = exitCode(result.status);
|
|
52
|
+
}
|
|
53
|
+
export { taskFinalization };
|
|
54
|
+
//# sourceMappingURL=task-finalization.js.map
|