@fitlab-ai/agent-infra 0.9.7 → 0.9.9
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/claude-code.js +3 -3
- package/dist/lib/agent-clients/adapters/codex-lifecycle/app-server.js +60 -22
- package/dist/lib/agent-clients/adapters/codex-lifecycle/build-identity.js +8 -1
- package/dist/lib/agent-clients/adapters/codex-lifecycle/capability-store.js +175 -11
- package/dist/lib/agent-clients/adapters/codex-lifecycle/controller-context.js +147 -0
- package/dist/lib/agent-clients/adapters/codex-lifecycle/evidence.js +14 -0
- package/dist/lib/agent-clients/adapters/codex-lifecycle/sandbox-controller.js +86 -69
- package/dist/lib/agent-clients/adapters/codex-lifecycle/store.js +2 -1
- package/dist/lib/decide.js +68 -14
- package/dist/lib/git/workflow.js +10 -1
- package/dist/lib/init.js +1 -1
- package/dist/lib/internal/codex-lifecycle.js +19 -5
- package/dist/lib/internal/codex-sandbox-controller.js +6 -13
- 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 +3 -4
- package/dist/lib/internal/sandbox-control.js +79 -2
- package/dist/lib/internal/task-activity.js +57 -7
- package/dist/lib/internal/task-event.js +57 -4
- package/dist/lib/internal/task-finalization.js +54 -0
- package/dist/lib/internal/task-ledger.js +59 -5
- package/dist/lib/internal/task-lifecycle.js +59 -8
- package/dist/lib/internal/task-orchestration.js +161 -288
- package/dist/lib/internal/task-override.js +131 -0
- package/dist/lib/internal/task-review.js +64 -6
- package/dist/lib/internal/task-verify.js +65 -3
- package/dist/lib/internal/task-warning.js +57 -4
- package/dist/lib/platform/pr-summary.js +53 -13
- package/dist/lib/platform/pull-requests.js +205 -41
- package/dist/lib/runtime/agent-runtime.js +56 -0
- package/dist/lib/sandbox/commands/create.js +389 -311
- package/dist/lib/sandbox/commands/rm.js +316 -55
- package/dist/lib/sandbox/control/client.js +190 -6
- package/dist/lib/sandbox/control/container-identity.js +1 -1
- package/dist/lib/sandbox/control/controller-registration.js +273 -0
- package/dist/lib/sandbox/control/executor.js +145 -5
- package/dist/lib/sandbox/control/lifecycle.js +395 -73
- package/dist/lib/sandbox/control/protocol.js +67 -6
- package/dist/lib/sandbox/control/state.js +27 -11
- package/dist/lib/sandbox/engine.js +14 -7
- package/dist/lib/sandbox/index.js +5 -3
- package/dist/lib/sandbox/managed-fs.js +5 -0
- package/dist/lib/sandbox/mounts.js +20 -5
- package/dist/lib/sandbox/recovery.js +78 -10
- package/dist/lib/sandbox/task-resolver.js +50 -6
- package/dist/lib/sandbox/workspace-identity.js +27 -0
- package/dist/lib/sandbox/workspace-view.js +62 -40
- package/dist/lib/sandbox/worktree-safety.js +215 -2
- package/dist/lib/server/process-state.js +51 -1
- package/dist/lib/task/activity-intent.js +4 -1
- package/dist/lib/task/codex-orchestration.js +158 -33
- 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/decision-intents.js +4 -2
- package/dist/lib/task/delegation-receipts.js +279 -17
- package/dist/lib/task/events.js +9 -5
- package/dist/lib/task/finalization.js +567 -0
- package/dist/lib/task/guard-override.js +31 -0
- package/dist/lib/task/human-override.js +1240 -0
- package/dist/lib/task/ledger-intents.js +6 -3
- package/dist/lib/task/lifecycle.js +69 -14
- package/dist/lib/task/operation-outcome.js +33 -0
- package/dist/lib/task/orchestration.js +199 -719
- package/dist/lib/task/review-finalization.js +3 -2
- 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 +138 -59
- package/dist/lib/task/verification.js +15 -2
- package/dist/lib/task/workflow-warning-intents.js +54 -3
- package/dist/lib/task/write.js +2 -1
- package/dist/lifecycle-build-manifest.json +3 -3
- package/lib/agent-clients/adapters/claude-code.ts +3 -3
- package/lib/agent-clients/adapters/codex-lifecycle/app-server.ts +63 -20
- package/lib/agent-clients/adapters/codex-lifecycle/build-identity.ts +12 -0
- package/lib/agent-clients/adapters/codex-lifecycle/capability-store.ts +278 -13
- package/lib/agent-clients/adapters/codex-lifecycle/controller-context.ts +180 -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 +112 -93
- package/lib/agent-clients/adapters/codex-lifecycle/store.ts +2 -1
- package/lib/decide.ts +59 -14
- package/lib/git/workflow.ts +11 -2
- package/lib/init.ts +1 -1
- package/lib/internal/codex-lifecycle.ts +18 -5
- package/lib/internal/codex-sandbox-controller.ts +6 -12
- package/lib/internal/git-workflow.ts +5 -6
- package/lib/internal/platform-pr.ts +14 -7
- package/lib/internal/release-workflow.ts +3 -4
- package/lib/internal/sandbox-control.ts +92 -2
- package/lib/internal/task-activity.ts +46 -6
- package/lib/internal/task-event.ts +53 -4
- package/lib/internal/task-finalization.ts +68 -0
- package/lib/internal/task-ledger.ts +48 -4
- package/lib/internal/task-lifecycle.ts +56 -12
- package/lib/internal/task-orchestration.ts +32 -107
- package/lib/internal/task-override.ts +138 -0
- package/lib/internal/task-review.ts +51 -6
- package/lib/internal/task-verify.ts +52 -3
- package/lib/internal/task-warning.ts +44 -3
- package/lib/platform/pr-summary.ts +65 -14
- package/lib/platform/pull-requests.ts +211 -41
- package/lib/runtime/agent-runtime.ts +76 -0
- package/lib/sandbox/commands/create.ts +88 -4
- package/lib/sandbox/commands/rm.ts +413 -61
- package/lib/sandbox/config.ts +2 -1
- package/lib/sandbox/control/client.ts +255 -6
- package/lib/sandbox/control/container-identity.ts +3 -3
- package/lib/sandbox/control/controller-registration.ts +347 -0
- package/lib/sandbox/control/executor.ts +172 -6
- package/lib/sandbox/control/lifecycle.ts +465 -77
- package/lib/sandbox/control/protocol.ts +85 -9
- package/lib/sandbox/control/state.ts +35 -18
- package/lib/sandbox/engine.ts +20 -9
- package/lib/sandbox/index.ts +5 -3
- package/lib/sandbox/managed-fs.ts +5 -0
- package/lib/sandbox/mounts.ts +23 -5
- package/lib/sandbox/recovery.ts +90 -9
- package/lib/sandbox/task-resolver.ts +58 -7
- package/lib/sandbox/workspace-identity.ts +50 -2
- package/lib/sandbox/workspace-view.ts +73 -43
- package/lib/sandbox/worktree-safety.ts +236 -2
- package/lib/server/process-state.ts +48 -1
- package/lib/task/activity-intent.ts +4 -2
- package/lib/task/codex-orchestration.ts +167 -33
- 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/decision-intents.ts +4 -2
- package/lib/task/delegation-receipts.ts +304 -19
- package/lib/task/events.ts +10 -5
- package/lib/task/finalization.ts +719 -0
- package/lib/task/guard-override.ts +50 -0
- package/lib/task/human-override.ts +1503 -0
- package/lib/task/ledger-intents.ts +6 -3
- package/lib/task/lifecycle.ts +71 -14
- package/lib/task/operation-outcome.ts +48 -0
- package/lib/task/orchestration.ts +239 -922
- package/lib/task/review-finalization.ts +6 -2
- package/lib/task/short-id.ts +65 -1
- package/lib/task/task-execution-lock.ts +10 -1
- package/lib/task/verification-engine.ts +145 -64
- package/lib/task/verification.ts +18 -3
- package/lib/task/workflow-warning-intents.ts +61 -4
- package/lib/task/write.ts +4 -1
- package/package.json +2 -2
- package/templates/.agents/QUICKSTART.en.md +2 -2
- package/templates/.agents/QUICKSTART.zh-CN.md +2 -2
- package/templates/.agents/hooks/lifecycle-delegation.js +9 -24
- package/templates/.agents/rules/lifecycle-orchestration.en.md +4 -3
- package/templates/.agents/rules/lifecycle-orchestration.zh-CN.md +4 -3
- 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/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/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 +6 -4
- package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +6 -4
- 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/run-task/SKILL.en.md +5 -5
- package/templates/.agents/skills/run-task/SKILL.zh-CN.md +5 -5
- package/templates/.agents/skills/run-task/reference/host-validation.en.md +3 -1
- package/templates/.agents/skills/run-task/reference/host-validation.zh-CN.md +3 -1
- 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/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
|
@@ -4,8 +4,12 @@ import path from 'node:path';
|
|
|
4
4
|
import { randomUUID } from 'node:crypto';
|
|
5
5
|
import { getProcessStartTime } from '../../server/process-state.js';
|
|
6
6
|
import { createTask } from '../../task/create-service.js';
|
|
7
|
+
import { applyTaskFinalization } from '../../task/finalization.js';
|
|
8
|
+
import { verifyTaskEvent } from '../../task/verification.js';
|
|
7
9
|
import { bindSandboxControlTask } from './protocol.js';
|
|
8
10
|
import { atomicWriteJson, executionPath, terminateSandboxControlExecution } from './state.js';
|
|
11
|
+
import { computeLifecycleBuildIdentity } from '../../agent-clients/adapters/codex-lifecycle/build-identity.js';
|
|
12
|
+
import { closeCodexControllerRegistration, CodexControllerRegistrationError, openCodexControllerRegistration, resolveCodexControllerBinding } from './controller-registration.js';
|
|
9
13
|
function safeEnv(env) {
|
|
10
14
|
return Object.fromEntries(Object.entries(env).filter(([key]) => !key.toUpperCase().startsWith('AGENT_INFRA_CONTROL_')));
|
|
11
15
|
}
|
|
@@ -32,7 +36,11 @@ export async function prepareSandboxControlExecution(params) {
|
|
|
32
36
|
cwd: params.manifest.repoRoot,
|
|
33
37
|
detached: process.platform !== 'win32',
|
|
34
38
|
stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
|
|
35
|
-
env: {
|
|
39
|
+
env: {
|
|
40
|
+
...safeEnv(process.env),
|
|
41
|
+
AGENT_INFRA_EXECUTOR_MANIFEST: params.manifestPath,
|
|
42
|
+
AGENT_INFRA_RUNTIME_DIR: params.manifest.runtimeDir
|
|
43
|
+
}
|
|
36
44
|
});
|
|
37
45
|
if (typeof child.pid !== 'number')
|
|
38
46
|
throw new Error('SANDBOX_CONTROL_EXECUTOR_SPAWN_FAILED');
|
|
@@ -104,7 +112,58 @@ function waitForGate(nonce, timeoutMs = 2_000) {
|
|
|
104
112
|
});
|
|
105
113
|
});
|
|
106
114
|
}
|
|
107
|
-
function
|
|
115
|
+
function controllerFailure(error) {
|
|
116
|
+
const code = error instanceof CodexControllerRegistrationError
|
|
117
|
+
? error.code
|
|
118
|
+
: /^([A-Z][A-Z0-9_]+)/u.exec(error instanceof Error ? error.message : String(error))?.[1]
|
|
119
|
+
?? 'CODEX_SANDBOX_CONTROLLER_FAILED';
|
|
120
|
+
const payload = {
|
|
121
|
+
version: 1,
|
|
122
|
+
status: 'failed',
|
|
123
|
+
changed: false,
|
|
124
|
+
lease: null,
|
|
125
|
+
error: { code, message: `${code}: controller request failed`, retryable: false }
|
|
126
|
+
};
|
|
127
|
+
return { exitCode: 1, stdout: `${JSON.stringify(payload)}\n`, stderr: '' };
|
|
128
|
+
}
|
|
129
|
+
function orchestrationFailure(code, message) {
|
|
130
|
+
return {
|
|
131
|
+
exitCode: 1,
|
|
132
|
+
stdout: `${JSON.stringify({
|
|
133
|
+
status: 'failed', changed: false, taskId: null, run: null, next: null,
|
|
134
|
+
error: { code, message }
|
|
135
|
+
})}\n`,
|
|
136
|
+
stderr: ''
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function finalizationResult(result) {
|
|
140
|
+
const payload = {
|
|
141
|
+
version: 1,
|
|
142
|
+
status: result.status,
|
|
143
|
+
changed: result.changed,
|
|
144
|
+
accepted: true,
|
|
145
|
+
result,
|
|
146
|
+
error: result.error
|
|
147
|
+
};
|
|
148
|
+
return {
|
|
149
|
+
exitCode: result.status === 'completed' ? 0 : result.status === 'blocked' ? 2 : 1,
|
|
150
|
+
stdout: `${JSON.stringify(payload)}\n`,
|
|
151
|
+
stderr: ''
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function isCodexPrepare(args) {
|
|
155
|
+
if (args[1] !== 'prepare')
|
|
156
|
+
return false;
|
|
157
|
+
const values = [];
|
|
158
|
+
for (let index = 2; index < args.length; index += 1) {
|
|
159
|
+
if (args[index] === '--client')
|
|
160
|
+
values.push(args[index + 1] ?? '');
|
|
161
|
+
else if (args[index]?.startsWith('--client='))
|
|
162
|
+
values.push(args[index].slice('--client='.length));
|
|
163
|
+
}
|
|
164
|
+
return values.length === 1 && values[0] === 'codex';
|
|
165
|
+
}
|
|
166
|
+
export function executeRequest(manifest, manifestPath, request, options = {}) {
|
|
108
167
|
if (request.family === 'task-create') {
|
|
109
168
|
const result = createTask(request.candidate, { repoRoot: manifest.repoRoot });
|
|
110
169
|
return {
|
|
@@ -113,10 +172,91 @@ function executeRequest(manifest, request) {
|
|
|
113
172
|
stderr: ''
|
|
114
173
|
};
|
|
115
174
|
}
|
|
175
|
+
if (request.family === 'codex-controller') {
|
|
176
|
+
try {
|
|
177
|
+
if (request.command === 'verify') {
|
|
178
|
+
const binding = (options.resolveControllerBinding ?? resolveCodexControllerBinding)({
|
|
179
|
+
manifest,
|
|
180
|
+
manifestPath,
|
|
181
|
+
proof: request.controllerProof,
|
|
182
|
+
buildIdentity: (options.buildIdentity ?? computeLifecycleBuildIdentity)(manifest.repoRoot)
|
|
183
|
+
});
|
|
184
|
+
return {
|
|
185
|
+
exitCode: 0,
|
|
186
|
+
stdout: `${JSON.stringify({
|
|
187
|
+
version: 1,
|
|
188
|
+
status: 'verified',
|
|
189
|
+
changed: false,
|
|
190
|
+
lease: null,
|
|
191
|
+
binding: {
|
|
192
|
+
taskId: manifest.taskId,
|
|
193
|
+
controlGeneration: binding.controlGeneration,
|
|
194
|
+
controllerInstanceDigest: binding.instanceDigest
|
|
195
|
+
},
|
|
196
|
+
error: null
|
|
197
|
+
})}\n`,
|
|
198
|
+
stderr: ''
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
const result = request.command === 'open'
|
|
202
|
+
? openCodexControllerRegistration({
|
|
203
|
+
manifest,
|
|
204
|
+
manifestPath,
|
|
205
|
+
controllerProcess: request.controllerProcess,
|
|
206
|
+
buildIdentity: (options.buildIdentity ?? computeLifecycleBuildIdentity)(manifest.repoRoot)
|
|
207
|
+
})
|
|
208
|
+
: closeCodexControllerRegistration({
|
|
209
|
+
manifest,
|
|
210
|
+
manifestPath,
|
|
211
|
+
proof: request.controllerProof
|
|
212
|
+
});
|
|
213
|
+
return { exitCode: 0, stdout: `${JSON.stringify(result)}\n`, stderr: '' };
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
return controllerFailure(error);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (request.family === 'task-finalization') {
|
|
220
|
+
return finalizationResult(applyTaskFinalization({ taskRef: manifest.taskId, intent: 'complete', agent: request.agent }, { repoRoot: manifest.repoRoot, preflight: (input, options) => verifyTaskEvent({ ...input, event: 'complete-task.hard-preflight' }, options) }));
|
|
221
|
+
}
|
|
116
222
|
const boundArgs = bindSandboxControlTask(request, manifest.taskId);
|
|
117
|
-
|
|
223
|
+
let controllerBinding = null;
|
|
224
|
+
if (request.family === 'task-orchestration') {
|
|
225
|
+
if (isCodexPrepare(request.args)) {
|
|
226
|
+
if (!request.controllerProof) {
|
|
227
|
+
return orchestrationFailure('CODEX_SANDBOX_CONTROLLER_PROOF_REQUIRED', 'Codex prepare requires a current controller lease proof');
|
|
228
|
+
}
|
|
229
|
+
try {
|
|
230
|
+
controllerBinding = (options.resolveControllerBinding ?? resolveCodexControllerBinding)({
|
|
231
|
+
manifest,
|
|
232
|
+
manifestPath,
|
|
233
|
+
proof: request.controllerProof,
|
|
234
|
+
buildIdentity: (options.buildIdentity ?? computeLifecycleBuildIdentity)(manifest.repoRoot)
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
const code = error instanceof CodexControllerRegistrationError
|
|
239
|
+
? error.code
|
|
240
|
+
: 'CODEX_SANDBOX_CONTROLLER_PROOF_INVALID';
|
|
241
|
+
return orchestrationFailure(code, `${code}: Codex controller proof was rejected`);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
else if (request.controllerProof !== null) {
|
|
245
|
+
return orchestrationFailure('CODEX_SANDBOX_CONTROLLER_PROOF_INVALID', 'Controller proof is only accepted for canonical Codex prepare');
|
|
246
|
+
}
|
|
118
247
|
boundArgs.push('--git-worktree-root', manifest.worktreeRoot);
|
|
119
|
-
|
|
248
|
+
}
|
|
249
|
+
const result = (options.spawnDomain ?? spawnSync)(process.execPath, nodeEntryArgs(process.argv[1], [request.family, ...boundArgs]), {
|
|
250
|
+
cwd: manifest.repoRoot,
|
|
251
|
+
encoding: 'utf8',
|
|
252
|
+
env: {
|
|
253
|
+
...safeEnv(process.env),
|
|
254
|
+
AGENT_INFRA_RUNTIME_DIR: manifest.runtimeDir,
|
|
255
|
+
...(controllerBinding
|
|
256
|
+
? { AGENT_INFRA_CONTROL_CONTROLLER_BINDING: JSON.stringify(controllerBinding) }
|
|
257
|
+
: {})
|
|
258
|
+
}
|
|
259
|
+
});
|
|
120
260
|
return { exitCode: result.status ?? 1, stdout: result.stdout ?? '', stderr: result.stderr ?? '' };
|
|
121
261
|
}
|
|
122
262
|
export async function runSandboxControlExecutor(requestPath, nonce) {
|
|
@@ -130,7 +270,7 @@ export async function runSandboxControlExecutor(requestPath, nonce) {
|
|
|
130
270
|
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
131
271
|
if (fs.realpathSync.native(manifest.repoRoot) !== root)
|
|
132
272
|
throw new Error('SANDBOX_CONTROL_EXECUTOR_ROOT_INVALID');
|
|
133
|
-
const result = executeRequest(manifest, request);
|
|
273
|
+
const result = executeRequest(manifest, manifestPath, request);
|
|
134
274
|
process.stdout.write(result.stdout);
|
|
135
275
|
process.stderr.write(result.stderr);
|
|
136
276
|
process.exitCode = result.exitCode;
|