@fitlab-ai/agent-infra 0.12.1 → 0.12.2
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 +0 -2
- package/README.zh-CN.md +0 -2
- package/dist/bin/internal-cli.js +2 -17
- package/dist/lib/agent-clients/adapter.js +0 -13
- package/dist/lib/agent-clients/adapters/antigravity-cli.js +0 -5
- package/dist/lib/agent-clients/adapters/claude-code-credentials.js +0 -17
- package/dist/lib/agent-clients/adapters/claude-code.js +0 -9
- package/dist/lib/agent-clients/adapters/codex.js +0 -52
- package/dist/lib/agent-clients/adapters/opencode.js +0 -5
- package/dist/lib/agent-clients/adapters/traecli.js +0 -5
- package/dist/lib/agent-clients/config.js +19 -54
- package/dist/lib/agent-clients/registry.js +1 -12
- package/dist/lib/agent-clients/schema.js +0 -18
- package/dist/lib/agent-clients/tokens.js +1 -2
- package/dist/lib/agent-clients/types.js +0 -1
- package/dist/lib/decide.js +2 -0
- package/dist/lib/git/worktree-identity.js +1 -9
- package/dist/lib/internal/agent-client.js +2 -62
- package/dist/lib/internal/cli-route-inventory.js +1 -5
- package/dist/lib/internal/manual-validation.js +18 -10
- package/dist/lib/internal/task-create.js +1 -1
- package/dist/lib/internal/task-event.js +1 -8
- package/dist/lib/internal/task-finalization.js +0 -1
- package/dist/lib/internal/task-lifecycle.js +2 -2
- package/dist/lib/internal/task-operation-registry.js +4 -20
- package/dist/lib/internal/task-review.js +4 -4
- package/dist/lib/platform/comment-safety.js +1 -7
- package/dist/lib/platform/in-label-sync.js +1 -14
- package/dist/lib/platform/issue-comments.js +1 -16
- package/dist/lib/platform/issues.js +1 -1
- package/dist/lib/platform/operation-coordinator.js +4 -2
- package/dist/lib/platform/pr-change-report.js +1 -4
- package/dist/lib/platform/pr-checks.js +2 -8
- package/dist/lib/platform/provider-validation.js +0 -20
- package/dist/lib/platform/pull-requests.js +73 -84
- package/dist/lib/platform/releases.js +1 -43
- package/dist/lib/platform/verification-required.js +0 -2
- package/dist/lib/platform/verification-sync.js +1 -79
- package/dist/lib/process-data/normalize.js +1 -185
- package/dist/lib/process-data/privacy.js +1 -16
- package/dist/lib/process-data/sources.js +2 -279
- package/dist/lib/render.js +0 -12
- package/dist/lib/run/index.js +15 -10
- package/dist/lib/run/skills.js +0 -3
- package/dist/lib/sandbox/commands/create.js +40 -53
- package/dist/lib/sandbox/commands/list-running.js +0 -18
- package/dist/lib/sandbox/commands/start.js +7 -8
- package/dist/lib/sandbox/constants.js +0 -6
- package/dist/lib/sandbox/control/client.js +0 -1
- package/dist/lib/sandbox/control/container-identity.js +1 -16
- package/dist/lib/sandbox/control/executor.js +0 -4
- package/dist/lib/sandbox/control/identity-sentinel.js +0 -7
- package/dist/lib/sandbox/control/lifecycle.js +21 -37
- package/dist/lib/sandbox/control/native-file-lock.js +0 -3
- package/dist/lib/sandbox/control/server.js +18 -38
- package/dist/lib/sandbox/control/state.js +1 -9
- package/dist/lib/sandbox/dockerfile.js +0 -6
- package/dist/lib/sandbox/engine.js +0 -14
- package/dist/lib/sandbox/engines/docker-exact-discovery.js +1 -4
- package/dist/lib/sandbox/engines/wsl2-paths.js +0 -3
- package/dist/lib/sandbox/recovery.js +24 -26
- package/dist/lib/sandbox/removal.js +11 -519
- package/dist/lib/sandbox/task-resolver.js +0 -41
- package/dist/lib/sandbox/tools.js +1 -4
- package/dist/lib/sandbox/workspace-view.js +1 -2
- package/dist/lib/server/display.js +0 -6
- package/dist/lib/task/activity-intent.js +45 -40
- package/dist/lib/task/activity-log.js +9 -16
- package/dist/lib/task/artifact-command.js +1 -1
- package/dist/lib/task/artifact-lifecycle.js +61 -63
- package/dist/lib/task/artifact-name.js +0 -6
- package/dist/lib/task/artifact-operations.js +3 -3
- package/dist/lib/task/capabilities.js +4 -5
- package/dist/lib/task/commands/log.js +0 -6
- package/dist/lib/task/commands/status.js +17 -60
- package/dist/lib/task/commit-operation.js +28 -39
- package/dist/lib/task/completion-facts.js +56 -43
- package/dist/lib/task/control-authority.js +23 -256
- package/dist/lib/task/control-recovery.js +3 -5
- package/dist/lib/task/create.js +2 -4
- package/dist/lib/task/decision-intents.js +8 -9
- package/dist/lib/task/delivery-target.js +1 -40
- package/dist/lib/task/events.js +84 -107
- package/dist/lib/task/finalization.js +44 -8
- package/dist/lib/task/ledger-intents.js +1 -1
- package/dist/lib/task/lifecycle-execution.js +38 -33
- package/dist/lib/task/lifecycle.js +49 -41
- package/dist/lib/task/local-artifact-finalization.js +1 -4
- package/dist/lib/task/manual-validation-evidence.js +1 -37
- package/dist/lib/task/platform-operation-recovery.js +67 -24
- package/dist/lib/task/pr-delivery-fact.js +2 -5
- package/dist/lib/task/qualification-confirmation.js +5 -7
- package/dist/lib/task/resolve-ref.js +1 -25
- package/dist/lib/task/review-command.js +2 -2
- package/dist/lib/task/review-finalization.js +1 -21
- package/dist/lib/task/review-fingerprint.js +0 -4
- package/dist/lib/task/secure-fs.js +0 -56
- package/dist/lib/task/short-id.js +1 -39
- package/dist/lib/task/skill-scope.js +0 -1
- package/dist/lib/task/verification-engine.js +58 -282
- package/dist/lib/task/verification.js +6 -3
- package/dist/lib/task/write.js +11 -1
- package/lib/agent-clients/adapter.ts +0 -76
- package/lib/agent-clients/adapters/antigravity-cli.ts +0 -5
- package/lib/agent-clients/adapters/claude-code-credentials.ts +0 -19
- package/lib/agent-clients/adapters/claude-code.ts +0 -9
- package/lib/agent-clients/adapters/codex.ts +0 -56
- package/lib/agent-clients/adapters/opencode.ts +0 -5
- package/lib/agent-clients/adapters/traecli.ts +0 -5
- package/lib/agent-clients/config.ts +20 -61
- package/lib/agent-clients/registry.ts +1 -34
- package/lib/agent-clients/schema.ts +0 -18
- package/lib/agent-clients/tokens.ts +1 -2
- package/lib/agent-clients/types.ts +0 -15
- package/lib/decide.ts +1 -0
- package/lib/git/worktree-identity.ts +0 -10
- package/lib/internal/agent-client.ts +2 -70
- package/lib/internal/cli-route-inventory.ts +1 -4
- package/lib/internal/manual-validation.ts +16 -9
- package/lib/internal/task-create.ts +0 -1
- package/lib/internal/task-event.ts +1 -5
- package/lib/internal/task-finalization.ts +0 -1
- package/lib/internal/task-lifecycle.ts +3 -5
- package/lib/internal/task-operation-registry.ts +3 -19
- package/lib/internal/task-review.ts +4 -4
- package/lib/platform/comment-safety.ts +0 -10
- package/lib/platform/github-provider.ts +0 -2
- package/lib/platform/in-label-sync.ts +0 -16
- package/lib/platform/issue-comments.ts +0 -21
- package/lib/platform/issues.ts +0 -2
- package/lib/platform/operation-coordinator.ts +4 -2
- package/lib/platform/pr-change-report.ts +0 -5
- package/lib/platform/pr-checks.ts +1 -10
- package/lib/platform/pr-review.ts +1 -1
- package/lib/platform/provider-bridge.ts +0 -1
- package/lib/platform/provider-loader.ts +1 -5
- package/lib/platform/provider-validation.ts +1 -49
- package/lib/platform/pull-requests.ts +64 -99
- package/lib/platform/releases.ts +1 -40
- package/lib/platform/verification-required.ts +0 -2
- package/lib/platform/verification-sync.ts +0 -94
- package/lib/process-data/normalize.ts +1 -186
- package/lib/process-data/privacy.ts +2 -19
- package/lib/process-data/sources.ts +3 -283
- package/lib/render.ts +0 -15
- package/lib/run/index.ts +13 -7
- package/lib/run/skills.ts +0 -4
- package/lib/sandbox/commands/create.ts +37 -74
- package/lib/sandbox/commands/list-running.ts +0 -19
- package/lib/sandbox/commands/start.ts +7 -10
- package/lib/sandbox/constants.ts +0 -8
- package/lib/sandbox/control/client.ts +0 -1
- package/lib/sandbox/control/container-identity.ts +1 -16
- package/lib/sandbox/control/executor.ts +1 -5
- package/lib/sandbox/control/identity-sentinel.ts +0 -8
- package/lib/sandbox/control/lifecycle.ts +18 -51
- package/lib/sandbox/control/native-file-lock.ts +0 -8
- package/lib/sandbox/control/protocol.ts +0 -2
- package/lib/sandbox/control/server.ts +13 -39
- package/lib/sandbox/control/state.ts +1 -10
- package/lib/sandbox/dockerfile.ts +0 -11
- package/lib/sandbox/engine.ts +0 -17
- package/lib/sandbox/engines/docker-exact-discovery.ts +1 -5
- package/lib/sandbox/engines/wsl2-paths.ts +0 -4
- package/lib/sandbox/recovery.ts +24 -26
- package/lib/sandbox/removal.ts +11 -696
- package/lib/sandbox/shell.ts +1 -1
- package/lib/sandbox/task-resolver.ts +0 -48
- package/lib/sandbox/tools.ts +1 -5
- package/lib/sandbox/workspace-view.ts +2 -4
- package/lib/server/display.ts +0 -14
- package/lib/server/process-control.ts +1 -1
- package/lib/task/activity-intent.ts +36 -44
- package/lib/task/activity-log.ts +9 -22
- package/lib/task/artifact-command.ts +1 -1
- package/lib/task/artifact-lifecycle.ts +58 -67
- package/lib/task/artifact-name.ts +0 -7
- package/lib/task/artifact-operations.ts +3 -3
- package/lib/task/capabilities.ts +5 -6
- package/lib/task/commands/log.ts +0 -7
- package/lib/task/commands/status.ts +14 -79
- package/lib/task/commit-operation.ts +29 -51
- package/lib/task/completion-facts.ts +45 -42
- package/lib/task/control-authority.ts +27 -317
- package/lib/task/control-recovery.ts +2 -5
- package/lib/task/create.ts +2 -5
- package/lib/task/decision-intents.ts +5 -5
- package/lib/task/delivery-target.ts +0 -40
- package/lib/task/events.ts +89 -123
- package/lib/task/finalization.ts +41 -9
- package/lib/task/ledger-intents.ts +1 -1
- package/lib/task/lifecycle-execution.ts +37 -89
- package/lib/task/lifecycle.ts +48 -44
- package/lib/task/local-artifact-finalization.ts +0 -7
- package/lib/task/manual-validation-evidence.ts +1 -47
- package/lib/task/platform-operation-recovery.ts +50 -26
- package/lib/task/pr-delivery-fact.ts +2 -11
- package/lib/task/qualification-confirmation.ts +6 -6
- package/lib/task/resolve-ref.ts +0 -23
- package/lib/task/review-command.ts +2 -2
- package/lib/task/review-finalization.ts +1 -27
- package/lib/task/review-fingerprint.ts +0 -8
- package/lib/task/secure-fs.ts +0 -42
- package/lib/task/short-id.ts +0 -43
- package/lib/task/skill-scope.ts +0 -1
- package/lib/task/verification-engine.ts +56 -287
- package/lib/task/verification.ts +5 -5
- package/lib/task/write.ts +12 -1
- package/package.json +2 -2
- package/templates/.agents/README.en.md +1 -3
- package/templates/.agents/README.zh-CN.md +0 -2
- package/templates/.agents/rules/README.en.md +0 -1
- package/templates/.agents/rules/README.zh-CN.md +0 -1
- package/templates/.agents/rules/commit-and-pr.en.md +1 -1
- package/templates/.agents/rules/commit-and-pr.zh-CN.md +1 -1
- package/templates/.agents/rules/no-mid-flow-questions.en.md +0 -10
- package/templates/.agents/rules/no-mid-flow-questions.zh-CN.md +0 -10
- package/templates/.agents/rules/pr-sync.en.md +1 -1
- package/templates/.agents/rules/pr-sync.zh-CN.md +1 -1
- package/templates/.agents/rules/task-management.en.md +3 -3
- package/templates/.agents/rules/task-management.zh-CN.md +3 -3
- package/templates/.agents/skills/analyze-task/SKILL.en.md +3 -3
- package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +3 -3
- package/templates/.agents/skills/cancel-task/SKILL.en.md +2 -2
- package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/code-task/SKILL.en.md +2 -2
- package/templates/.agents/skills/code-task/SKILL.zh-CN.md +4 -4
- package/templates/.agents/skills/commit/SKILL.en.md +2 -2
- package/templates/.agents/skills/commit/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/commit/reference/commit-orchestration.en.md +6 -6
- package/templates/.agents/skills/commit/reference/commit-orchestration.zh-CN.md +6 -6
- package/templates/.agents/skills/plan-task/SKILL.en.md +2 -2
- package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/review-analysis/SKILL.en.md +3 -3
- package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +3 -3
- package/templates/.agents/skills/review-code/SKILL.en.md +5 -5
- package/templates/.agents/skills/review-code/SKILL.zh-CN.md +5 -5
- package/templates/.agents/skills/review-plan/SKILL.en.md +3 -3
- package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +3 -3
- package/templates/.agents/skills/review-pr/SKILL.en.md +4 -4
- package/templates/.agents/skills/review-pr/SKILL.zh-CN.md +4 -4
- package/templates/.agents/skills/run-manual-validation/SKILL.en.md +1 -1
- package/templates/.agents/skills/run-manual-validation/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +3 -75
- package/templates/.agents/templates/task.en.md +1 -0
- package/templates/.agents/templates/task.zh-CN.md +1 -0
- package/templates/.claude/settings.json +0 -24
- package/templates/.codex/hooks.json +0 -50
- package/dist/lib/agent-clients/adapters/codex-lifecycle/app-server.js +0 -582
- package/dist/lib/agent-clients/adapters/codex-lifecycle/binding.js +0 -114
- package/dist/lib/agent-clients/adapters/codex-lifecycle/build-identity.js +0 -237
- package/dist/lib/agent-clients/adapters/codex-lifecycle/cli.js +0 -443
- package/dist/lib/agent-clients/adapters/codex-lifecycle/evidence.js +0 -236
- package/dist/lib/agent-clients/adapters/codex-lifecycle/recovery.js +0 -292
- package/dist/lib/agent-clients/adapters/codex-lifecycle/store.js +0 -267
- package/dist/lib/agent-clients/adapters/codex-orchestration.js +0 -466
- package/dist/lib/internal/task-orchestration.js +0 -71
- package/dist/lib/platform/verification.js +0 -6
- package/dist/lib/run/prompt.js +0 -2
- package/dist/lib/sandbox/engines/authority.js +0 -289
- package/dist/lib/task/delegation-receipts.js +0 -410
- package/dist/lib/task/orchestration.js +0 -1233
- package/dist/lib/task/verification-checks.js +0 -9
- package/dist/lib/task/workspace-snapshot.js +0 -121
- package/dist/lifecycle-build-manifest.json +0 -6
- package/lib/agent-clients/adapters/codex-lifecycle/app-server.ts +0 -688
- package/lib/agent-clients/adapters/codex-lifecycle/binding.ts +0 -147
- package/lib/agent-clients/adapters/codex-lifecycle/build-identity.ts +0 -349
- package/lib/agent-clients/adapters/codex-lifecycle/cli.ts +0 -506
- package/lib/agent-clients/adapters/codex-lifecycle/evidence.ts +0 -385
- package/lib/agent-clients/adapters/codex-lifecycle/manifest-files.json +0 -41
- package/lib/agent-clients/adapters/codex-lifecycle/recovery.ts +0 -418
- package/lib/agent-clients/adapters/codex-lifecycle/store.ts +0 -354
- package/lib/agent-clients/adapters/codex-orchestration.ts +0 -630
- package/lib/internal/task-orchestration.ts +0 -74
- package/lib/platform/verification.ts +0 -11
- package/lib/run/prompt.ts +0 -1
- package/lib/sandbox/engines/authority.ts +0 -365
- package/lib/task/delegation-receipts.ts +0 -547
- package/lib/task/orchestration.ts +0 -1651
- package/lib/task/verification-checks.ts +0 -10
- package/lib/task/workspace-snapshot.ts +0 -144
- package/templates/.agents/hooks/lifecycle-delegation.js +0 -140
- package/templates/.agents/rules/lifecycle-orchestration.en.md +0 -44
- package/templates/.agents/rules/lifecycle-orchestration.zh-CN.md +0 -44
- package/templates/.agents/skills/run-task/SKILL.en.md +0 -29
- package/templates/.agents/skills/run-task/SKILL.zh-CN.md +0 -29
- package/templates/.agents/skills/run-task/config/verify.en.json +0 -10
- package/templates/.agents/skills/run-task/config/verify.zh-CN.json +0 -10
- package/templates/.agents/skills/run-task/reference/host-validation.en.md +0 -24
- package/templates/.agents/skills/run-task/reference/host-validation.zh-CN.md +0 -24
- package/templates/.claude/agents/agent-infra-lifecycle-executor.en.md +0 -6
- package/templates/.claude/agents/agent-infra-lifecycle-executor.zh-CN.md +0 -6
- package/templates/.claude/agents/agent-infra-lifecycle-reviewer.en.md +0 -6
- package/templates/.claude/agents/agent-infra-lifecycle-reviewer.zh-CN.md +0 -6
- package/templates/.claude/commands/run-task.en.md +0 -8
- package/templates/.claude/commands/run-task.zh-CN.md +0 -8
- package/templates/.codex/agents/agent-infra-lifecycle-executor.en.toml +0 -3
- package/templates/.codex/agents/agent-infra-lifecycle-executor.zh-CN.toml +0 -3
- package/templates/.codex/agents/agent-infra-lifecycle-reviewer.en.toml +0 -3
- package/templates/.codex/agents/agent-infra-lifecycle-reviewer.zh-CN.toml +0 -3
- package/templates/.opencode/commands/run-task.en.md +0 -11
- package/templates/.opencode/commands/run-task.zh-CN.md +0 -11
|
@@ -1,385 +0,0 @@
|
|
|
1
|
-
import type { CodexLifecycleTaskBinding } from './binding.ts';
|
|
2
|
-
|
|
3
|
-
type CodexEvidenceSource =
|
|
4
|
-
| 'codex-hook'
|
|
5
|
-
| 'codex-app-server-thread'
|
|
6
|
-
| 'codex-app-server-settings'
|
|
7
|
-
| 'codex-app-server-turn'
|
|
8
|
-
| 'codex-app-server-reroute';
|
|
9
|
-
|
|
10
|
-
type CodexLifecycleEvent =
|
|
11
|
-
| Readonly<{
|
|
12
|
-
type: 'hook-spawn';
|
|
13
|
-
sessionId: string;
|
|
14
|
-
turnId: string;
|
|
15
|
-
toolUseId: string;
|
|
16
|
-
nativeAgent: string;
|
|
17
|
-
requestedModel?: string;
|
|
18
|
-
requestedReasoningEffort?: string;
|
|
19
|
-
hookDefinitionHash: string;
|
|
20
|
-
taskBinding?: CodexLifecycleTaskBinding;
|
|
21
|
-
}>
|
|
22
|
-
| Readonly<{
|
|
23
|
-
type: 'hook-child';
|
|
24
|
-
sessionId: string;
|
|
25
|
-
turnId: string;
|
|
26
|
-
childThreadId: string;
|
|
27
|
-
parentThreadId: string;
|
|
28
|
-
nativeAgent: string;
|
|
29
|
-
source?: 'hook' | 'parent-rollout';
|
|
30
|
-
}>
|
|
31
|
-
| Readonly<{
|
|
32
|
-
type: 'app-thread';
|
|
33
|
-
childThreadId: string;
|
|
34
|
-
parentThreadId: string;
|
|
35
|
-
forkedFromId: string | null;
|
|
36
|
-
sourceParentThreadId: string;
|
|
37
|
-
nativeAgent: string;
|
|
38
|
-
}>
|
|
39
|
-
| Readonly<{
|
|
40
|
-
type: 'app-settings';
|
|
41
|
-
childThreadId: string;
|
|
42
|
-
model: string;
|
|
43
|
-
reasoningEffort: string;
|
|
44
|
-
}>
|
|
45
|
-
| Readonly<{
|
|
46
|
-
type: 'app-reroute';
|
|
47
|
-
childThreadId: string;
|
|
48
|
-
turnId: string;
|
|
49
|
-
fromModel: string;
|
|
50
|
-
toModel: string;
|
|
51
|
-
reason: string;
|
|
52
|
-
}>
|
|
53
|
-
| Readonly<{
|
|
54
|
-
type: 'app-terminal';
|
|
55
|
-
childThreadId: string;
|
|
56
|
-
turnId: string;
|
|
57
|
-
status: 'completed' | 'interrupted' | 'failed';
|
|
58
|
-
}>
|
|
59
|
-
| Readonly<{
|
|
60
|
-
type: 'hook-stop';
|
|
61
|
-
sessionId: string;
|
|
62
|
-
turnId: string;
|
|
63
|
-
childThreadId: string;
|
|
64
|
-
nativeAgent: string;
|
|
65
|
-
source?: 'hook' | 'parent-rollout';
|
|
66
|
-
}>;
|
|
67
|
-
|
|
68
|
-
type CodexStartEvidence = Readonly<{
|
|
69
|
-
schemaVersion: 1;
|
|
70
|
-
cliVersion: string;
|
|
71
|
-
parentThreadId: string;
|
|
72
|
-
parentTurnId: string;
|
|
73
|
-
spawnToolUseId: string;
|
|
74
|
-
childThreadId: string;
|
|
75
|
-
nativeAgent: string;
|
|
76
|
-
spawnMode: 'fresh';
|
|
77
|
-
actualModel: Readonly<{ value: string; source: CodexEvidenceSource }>;
|
|
78
|
-
actualReasoningEffort: Readonly<{ value: string; source: CodexEvidenceSource }>;
|
|
79
|
-
modelFallbackReason: string | null;
|
|
80
|
-
reasoningEffortFallbackReason: string | null;
|
|
81
|
-
hookDefinitionHash: string;
|
|
82
|
-
}>;
|
|
83
|
-
|
|
84
|
-
type CodexStopEvidence = Readonly<{
|
|
85
|
-
schemaVersion: 1;
|
|
86
|
-
childThreadId: string;
|
|
87
|
-
turnId: string;
|
|
88
|
-
terminalStatus: 'completed';
|
|
89
|
-
hookStopObserved: boolean;
|
|
90
|
-
}>;
|
|
91
|
-
|
|
92
|
-
type CodexLifecycleStatus =
|
|
93
|
-
| 'empty'
|
|
94
|
-
| 'observed-spawn'
|
|
95
|
-
| 'observed-child'
|
|
96
|
-
| 'start-ready'
|
|
97
|
-
| 'observed-terminal'
|
|
98
|
-
| 'stop-ready'
|
|
99
|
-
| 'invalid'
|
|
100
|
-
| 'expired';
|
|
101
|
-
|
|
102
|
-
type CodexEvidenceError = Readonly<{ code: string; message: string }>;
|
|
103
|
-
|
|
104
|
-
function isCodexLifecycleActivationEvidence(value: unknown, parentId: string): boolean {
|
|
105
|
-
if (!value || typeof value !== 'object' || Array.isArray(value)) return false;
|
|
106
|
-
const state = value as Record<string, unknown>;
|
|
107
|
-
const evidence = state.activationEvidence;
|
|
108
|
-
if (!evidence || typeof evidence !== 'object' || Array.isArray(evidence)) return false;
|
|
109
|
-
const activation = evidence as Record<string, unknown>;
|
|
110
|
-
return activation.kind === 'codex-lifecycle-v2'
|
|
111
|
-
&& typeof activation.hookDefinitionHash === 'string'
|
|
112
|
-
&& activation.hookDefinitionHash.trim() !== ''
|
|
113
|
-
&& Number.isSafeInteger(activation.startRevision)
|
|
114
|
-
&& (activation.startRevision as number) >= 1
|
|
115
|
-
&& activation.capabilitySessionId === parentId;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function isCodexDelegationReceiptEvidence(value: unknown): boolean {
|
|
119
|
-
if (!value || typeof value !== 'object' || Array.isArray(value)) return false;
|
|
120
|
-
const receipt = value as Record<string, unknown>;
|
|
121
|
-
if (receipt.client !== 'codex' || typeof receipt.id !== 'string') return false;
|
|
122
|
-
const status = receipt.status;
|
|
123
|
-
if (!['activated', 'stage-completed', 'sealed', 'consumed', 'aborted'].includes(status as string)) return true;
|
|
124
|
-
const adapterEvidence = receipt.adapterEvidence;
|
|
125
|
-
if (!adapterEvidence || typeof adapterEvidence !== 'object' || Array.isArray(adapterEvidence)) return false;
|
|
126
|
-
const codex = (adapterEvidence as Record<string, unknown>).codex;
|
|
127
|
-
if (!codex || typeof codex !== 'object' || Array.isArray(codex)) return false;
|
|
128
|
-
const state = codex as Record<string, unknown>;
|
|
129
|
-
if (!isCodexLifecycleActivationEvidence(state, String(receipt.parentId ?? ''))) return false;
|
|
130
|
-
if (!['sealed', 'consumed', 'aborted'].includes(status as string)) return true;
|
|
131
|
-
const records = state.records;
|
|
132
|
-
if (!records || typeof records !== 'object' || Array.isArray(records)) return false;
|
|
133
|
-
return Object.values(records as Record<string, unknown>).some((record) => {
|
|
134
|
-
if (!record || typeof record !== 'object' || Array.isArray(record)) return false;
|
|
135
|
-
const evidence = record as Record<string, unknown>;
|
|
136
|
-
return evidence.consumer === receipt.id
|
|
137
|
-
&& typeof evidence.consumedAt === 'string'
|
|
138
|
-
&& evidence.consumedAt.trim() !== '';
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
type CodexLifecycleState = Readonly<{
|
|
143
|
-
schemaVersion: 1;
|
|
144
|
-
cliVersion: string;
|
|
145
|
-
status: CodexLifecycleStatus;
|
|
146
|
-
spawn: Extract<CodexLifecycleEvent, { type: 'hook-spawn' }> | null;
|
|
147
|
-
child: Extract<CodexLifecycleEvent, { type: 'hook-child' }> | null;
|
|
148
|
-
thread: Extract<CodexLifecycleEvent, { type: 'app-thread' }> | null;
|
|
149
|
-
settings: Extract<CodexLifecycleEvent, { type: 'app-settings' }> | null;
|
|
150
|
-
reroute: Extract<CodexLifecycleEvent, { type: 'app-reroute' }> | null;
|
|
151
|
-
terminal: Extract<CodexLifecycleEvent, { type: 'app-terminal' }> | null;
|
|
152
|
-
stop: Extract<CodexLifecycleEvent, { type: 'hook-stop' }> | null;
|
|
153
|
-
startEvidence: CodexStartEvidence | null;
|
|
154
|
-
stopEvidence: CodexStopEvidence | null;
|
|
155
|
-
error: CodexEvidenceError | null;
|
|
156
|
-
}>;
|
|
157
|
-
|
|
158
|
-
function createCodexLifecycleState(cliVersion: string): CodexLifecycleState {
|
|
159
|
-
if (!cliVersion.trim()) throw new Error('Codex CLI version is required');
|
|
160
|
-
return Object.freeze({
|
|
161
|
-
schemaVersion: 1,
|
|
162
|
-
cliVersion,
|
|
163
|
-
status: 'empty',
|
|
164
|
-
spawn: null,
|
|
165
|
-
child: null,
|
|
166
|
-
thread: null,
|
|
167
|
-
settings: null,
|
|
168
|
-
reroute: null,
|
|
169
|
-
terminal: null,
|
|
170
|
-
stop: null,
|
|
171
|
-
startEvidence: null,
|
|
172
|
-
stopEvidence: null,
|
|
173
|
-
error: null
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function invalid(state: CodexLifecycleState, code: string, message: string): CodexLifecycleState {
|
|
178
|
-
return Object.freeze({
|
|
179
|
-
...state,
|
|
180
|
-
status: 'invalid',
|
|
181
|
-
startEvidence: null,
|
|
182
|
-
stopEvidence: null,
|
|
183
|
-
error: Object.freeze({ code, message })
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function same(left: unknown, right: unknown): boolean {
|
|
188
|
-
return JSON.stringify(left) === JSON.stringify(right);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
function sameChildCorrelation(
|
|
192
|
-
left: Extract<CodexLifecycleEvent, { type: 'hook-child' }>,
|
|
193
|
-
right: Extract<CodexLifecycleEvent, { type: 'hook-child' }>
|
|
194
|
-
): boolean {
|
|
195
|
-
return left.sessionId === right.sessionId
|
|
196
|
-
&& left.childThreadId === right.childThreadId
|
|
197
|
-
&& left.parentThreadId === right.parentThreadId
|
|
198
|
-
&& left.nativeAgent === right.nativeAgent;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function requiredStrings(event: CodexLifecycleEvent): boolean {
|
|
202
|
-
return Object.entries(event).every(([key, value]) =>
|
|
203
|
-
key === 'forkedFromId'
|
|
204
|
-
|| (typeof value !== 'string' || value.trim() !== '')
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function derive(state: CodexLifecycleState): CodexLifecycleState {
|
|
209
|
-
const { spawn, child, thread, settings, reroute, terminal, stop } = state;
|
|
210
|
-
if (spawn && child && (
|
|
211
|
-
spawn.sessionId !== child.parentThreadId
|
|
212
|
-
|| spawn.nativeAgent !== child.nativeAgent
|
|
213
|
-
)) {
|
|
214
|
-
return invalid(state, 'CODEX_EVIDENCE_IDENTITY_MISMATCH', 'hook spawn and child identity do not match');
|
|
215
|
-
}
|
|
216
|
-
if (child && child.sessionId !== child.parentThreadId) {
|
|
217
|
-
return invalid(state, 'CODEX_EVIDENCE_IDENTITY_MISMATCH', 'child event session does not match the parent thread');
|
|
218
|
-
}
|
|
219
|
-
if (child && thread && child.childThreadId !== thread.childThreadId) {
|
|
220
|
-
return invalid(state, 'CODEX_EVIDENCE_IDENTITY_MISMATCH', 'hook and App Server child identity do not match');
|
|
221
|
-
}
|
|
222
|
-
if (child && thread && child.nativeAgent !== thread.nativeAgent) {
|
|
223
|
-
return invalid(state, 'CODEX_EVIDENCE_IDENTITY_MISMATCH', 'hook and App Server agent roles do not match');
|
|
224
|
-
}
|
|
225
|
-
if (child && thread && child.parentThreadId !== thread.parentThreadId) {
|
|
226
|
-
return invalid(state, 'CODEX_EVIDENCE_PARENT_MISMATCH', 'hook and App Server parent identity do not match');
|
|
227
|
-
}
|
|
228
|
-
if (spawn && thread && (
|
|
229
|
-
thread.parentThreadId !== spawn.sessionId
|
|
230
|
-
|| thread.sourceParentThreadId !== spawn.sessionId
|
|
231
|
-
)) {
|
|
232
|
-
return invalid(state, 'CODEX_EVIDENCE_PARENT_MISMATCH', 'App Server parent identity does not match the spawning session');
|
|
233
|
-
}
|
|
234
|
-
if (spawn && thread && spawn.nativeAgent !== thread.nativeAgent) {
|
|
235
|
-
return invalid(state, 'CODEX_EVIDENCE_IDENTITY_MISMATCH', 'spawn and App Server agent roles do not match');
|
|
236
|
-
}
|
|
237
|
-
if (thread?.forkedFromId !== null && thread?.forkedFromId !== undefined) {
|
|
238
|
-
return invalid(state, 'CODEX_EVIDENCE_FORK_FORBIDDEN', 'forked child threads are not fresh lifecycle evidence');
|
|
239
|
-
}
|
|
240
|
-
if (settings && child && settings.childThreadId !== child.childThreadId) {
|
|
241
|
-
return invalid(state, 'CODEX_EVIDENCE_IDENTITY_MISMATCH', 'resolved settings belong to a different child');
|
|
242
|
-
}
|
|
243
|
-
if (reroute && child && reroute.childThreadId !== child.childThreadId) {
|
|
244
|
-
return invalid(state, 'CODEX_EVIDENCE_IDENTITY_MISMATCH', 'model reroute belongs to a different child');
|
|
245
|
-
}
|
|
246
|
-
if (spawn?.requestedModel && settings && spawn.requestedModel !== settings.model) {
|
|
247
|
-
if (
|
|
248
|
-
!reroute
|
|
249
|
-
|| reroute.fromModel !== spawn.requestedModel
|
|
250
|
-
|| reroute.toModel !== settings.model
|
|
251
|
-
|| !reroute.reason.trim()
|
|
252
|
-
) {
|
|
253
|
-
return invalid(state, 'CODEX_EVIDENCE_MODEL_UNEXPLAINED', 'resolved model differs without a matching host reroute');
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
if (
|
|
257
|
-
spawn?.requestedReasoningEffort
|
|
258
|
-
&& settings
|
|
259
|
-
&& spawn.requestedReasoningEffort !== settings.reasoningEffort
|
|
260
|
-
) {
|
|
261
|
-
return invalid(state, 'CODEX_EVIDENCE_EFFORT_UNEXPLAINED', 'resolved reasoning effort differs without structured host evidence');
|
|
262
|
-
}
|
|
263
|
-
if (terminal && terminal.status !== 'completed') {
|
|
264
|
-
return invalid(state, 'CODEX_EVIDENCE_TERMINAL_INVALID', `child turn ended as '${terminal.status}'`);
|
|
265
|
-
}
|
|
266
|
-
if (terminal && child && terminal.childThreadId !== child.childThreadId) {
|
|
267
|
-
return invalid(state, 'CODEX_EVIDENCE_IDENTITY_MISMATCH', 'terminal event belongs to a different child');
|
|
268
|
-
}
|
|
269
|
-
if (stop && child && (
|
|
270
|
-
stop.sessionId !== child.sessionId
|
|
271
|
-
|| stop.turnId !== child.turnId
|
|
272
|
-
|| stop.childThreadId !== child.childThreadId
|
|
273
|
-
|| stop.nativeAgent !== child.nativeAgent
|
|
274
|
-
)) {
|
|
275
|
-
return invalid(state, 'CODEX_EVIDENCE_IDENTITY_MISMATCH', 'hook stop identity does not match the child');
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
let startEvidence: CodexStartEvidence | null = null;
|
|
279
|
-
if (spawn && child && thread && settings) {
|
|
280
|
-
startEvidence = Object.freeze({
|
|
281
|
-
schemaVersion: 1,
|
|
282
|
-
cliVersion: state.cliVersion,
|
|
283
|
-
parentThreadId: spawn.sessionId,
|
|
284
|
-
parentTurnId: spawn.turnId,
|
|
285
|
-
spawnToolUseId: spawn.toolUseId,
|
|
286
|
-
childThreadId: child.childThreadId,
|
|
287
|
-
nativeAgent: child.nativeAgent,
|
|
288
|
-
spawnMode: 'fresh',
|
|
289
|
-
actualModel: Object.freeze({ value: settings.model, source: 'codex-app-server-settings' }),
|
|
290
|
-
actualReasoningEffort: Object.freeze({ value: settings.reasoningEffort, source: 'codex-app-server-settings' }),
|
|
291
|
-
modelFallbackReason: reroute?.reason ?? null,
|
|
292
|
-
reasoningEffortFallbackReason: null,
|
|
293
|
-
hookDefinitionHash: spawn.hookDefinitionHash
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
let stopEvidence: CodexStopEvidence | null = null;
|
|
297
|
-
if (startEvidence && terminal?.status === 'completed' && stop) {
|
|
298
|
-
stopEvidence = Object.freeze({
|
|
299
|
-
schemaVersion: 1,
|
|
300
|
-
childThreadId: startEvidence.childThreadId,
|
|
301
|
-
turnId: terminal.turnId,
|
|
302
|
-
terminalStatus: 'completed',
|
|
303
|
-
hookStopObserved: stop.source !== 'parent-rollout'
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
const status: CodexLifecycleStatus = stopEvidence
|
|
307
|
-
? 'stop-ready'
|
|
308
|
-
: terminal
|
|
309
|
-
? 'observed-terminal'
|
|
310
|
-
: startEvidence
|
|
311
|
-
? 'start-ready'
|
|
312
|
-
: child
|
|
313
|
-
? 'observed-child'
|
|
314
|
-
: spawn
|
|
315
|
-
? 'observed-spawn'
|
|
316
|
-
: 'empty';
|
|
317
|
-
return Object.freeze({ ...state, status, startEvidence, stopEvidence, error: null });
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
function reduceCodexLifecycleEvent(
|
|
321
|
-
state: CodexLifecycleState,
|
|
322
|
-
event: CodexLifecycleEvent
|
|
323
|
-
): CodexLifecycleState {
|
|
324
|
-
if (state.status === 'invalid' || state.status === 'expired') return state;
|
|
325
|
-
if (!requiredStrings(event)) {
|
|
326
|
-
return invalid(state, 'CODEX_EVIDENCE_FIELD_MISSING', 'lifecycle event contains an empty required field');
|
|
327
|
-
}
|
|
328
|
-
const key = ({
|
|
329
|
-
'hook-spawn': 'spawn',
|
|
330
|
-
'hook-child': 'child',
|
|
331
|
-
'app-thread': 'thread',
|
|
332
|
-
'app-settings': 'settings',
|
|
333
|
-
'app-reroute': 'reroute',
|
|
334
|
-
'app-terminal': 'terminal',
|
|
335
|
-
'hook-stop': 'stop'
|
|
336
|
-
} as const)[event.type];
|
|
337
|
-
const existing = state[key];
|
|
338
|
-
if (existing) {
|
|
339
|
-
if (same(existing, event)) return state;
|
|
340
|
-
if (
|
|
341
|
-
existing.type === 'hook-child'
|
|
342
|
-
&& event.type === 'hook-child'
|
|
343
|
-
&& sameChildCorrelation(existing, event)
|
|
344
|
-
&& (existing.source === 'parent-rollout') !== (event.source === 'parent-rollout')
|
|
345
|
-
) {
|
|
346
|
-
if (existing.source !== 'parent-rollout') return state;
|
|
347
|
-
return derive(Object.freeze({ ...state, child: Object.freeze({ ...event }) }));
|
|
348
|
-
}
|
|
349
|
-
return invalid(state, 'CODEX_EVIDENCE_REPLAY_CONFLICT', `conflicting '${event.type}' event`);
|
|
350
|
-
}
|
|
351
|
-
return derive(Object.freeze({ ...state, [key]: Object.freeze({ ...event }) }));
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
function expireCodexLifecycleState(state: CodexLifecycleState): CodexLifecycleState {
|
|
355
|
-
if (!['observed-spawn', 'observed-child', 'start-ready', 'observed-terminal'].includes(state.status)) {
|
|
356
|
-
return state;
|
|
357
|
-
}
|
|
358
|
-
return Object.freeze({
|
|
359
|
-
...state,
|
|
360
|
-
status: 'expired',
|
|
361
|
-
startEvidence: null,
|
|
362
|
-
stopEvidence: null,
|
|
363
|
-
error: Object.freeze({
|
|
364
|
-
code: 'CODEX_EVIDENCE_EXPIRED',
|
|
365
|
-
message: 'Codex lifecycle evidence expired before completion'
|
|
366
|
-
})
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
export {
|
|
371
|
-
createCodexLifecycleState,
|
|
372
|
-
expireCodexLifecycleState,
|
|
373
|
-
isCodexLifecycleActivationEvidence,
|
|
374
|
-
isCodexDelegationReceiptEvidence,
|
|
375
|
-
reduceCodexLifecycleEvent
|
|
376
|
-
};
|
|
377
|
-
export type {
|
|
378
|
-
CodexEvidenceError,
|
|
379
|
-
CodexEvidenceSource,
|
|
380
|
-
CodexLifecycleEvent,
|
|
381
|
-
CodexLifecycleState,
|
|
382
|
-
CodexLifecycleStatus,
|
|
383
|
-
CodexStartEvidence,
|
|
384
|
-
CodexStopEvidence
|
|
385
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"executableFiles": [
|
|
3
|
-
"bin/internal-cli.ts",
|
|
4
|
-
"lib/agent-clients/adapters/codex-lifecycle/cli.ts",
|
|
5
|
-
"lib/internal/sandbox-control.ts",
|
|
6
|
-
"lib/internal/task-orchestration.ts",
|
|
7
|
-
"lib/agent-clients/adapters/codex-orchestration.ts",
|
|
8
|
-
"lib/task/delegation-receipts.ts",
|
|
9
|
-
"lib/task/orchestration.ts",
|
|
10
|
-
"lib/agent-clients/adapters/codex-lifecycle/build-identity.ts",
|
|
11
|
-
"lib/agent-clients/adapters/codex-lifecycle/app-server.ts",
|
|
12
|
-
"lib/agent-clients/adapters/codex-lifecycle/binding.ts",
|
|
13
|
-
"lib/agent-clients/adapters/codex-lifecycle/evidence.ts",
|
|
14
|
-
"lib/agent-clients/adapters/codex-lifecycle/store.ts",
|
|
15
|
-
"lib/agent-clients/adapters/codex-lifecycle/manifest-files.json",
|
|
16
|
-
"lib/sandbox/control/protocol.ts",
|
|
17
|
-
"lib/sandbox/control/client.ts",
|
|
18
|
-
"lib/sandbox/control/executor.ts",
|
|
19
|
-
"lib/server/process-state.ts",
|
|
20
|
-
"lib/sandbox/shell.ts"
|
|
21
|
-
],
|
|
22
|
-
"contractFiles": [
|
|
23
|
-
".codex/hooks.json",
|
|
24
|
-
".codex/agents/agent-infra-lifecycle-executor.toml",
|
|
25
|
-
".codex/agents/agent-infra-lifecycle-reviewer.toml",
|
|
26
|
-
".agents/hooks/lifecycle-delegation.js",
|
|
27
|
-
".agents/skills/run-task/SKILL.md",
|
|
28
|
-
".agents/rules/lifecycle-orchestration.md"
|
|
29
|
-
],
|
|
30
|
-
"launcherShebang": {
|
|
31
|
-
"sourceFile": "bin/internal-cli.ts",
|
|
32
|
-
"compiledFile": "dist/bin/internal-cli.js",
|
|
33
|
-
"canonicalLine": "#!/usr/bin/env node\n",
|
|
34
|
-
"acceptedLines": [
|
|
35
|
-
"#!/usr/bin/env node\n",
|
|
36
|
-
"#!/opt/homebrew/opt/node/bin/node\n",
|
|
37
|
-
"#!/usr/local/opt/node/bin/node\n",
|
|
38
|
-
"#!/home/linuxbrew/.linuxbrew/opt/node/bin/node\n"
|
|
39
|
-
]
|
|
40
|
-
}
|
|
41
|
-
}
|