@aibyzero/cm-workflow 0.16.8 → 0.17.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/.codex-plugin/plugin.json +1 -1
- package/CHANGELOG.md +31 -0
- package/README.md +22 -3
- package/VERSION +1 -1
- package/compat/claude-commands/cm-notify.md +3 -0
- package/docs/cm-control-policy-v2.md +331 -0
- package/docs/execution-optimizations.md +1 -1
- package/docs/external-models.md +3 -3
- package/docs/human-correction.md +5 -5
- package/docs/installation.md +1 -1
- package/docs/js-workflow-control.md +119 -78
- package/docs/next-steps.md +19 -2
- package/docs/untested-branches.md +2 -3
- package/docs/user-guide.md +105 -5
- package/package.json +2 -1
- package/runtime/js/cm-ai/claude-review-stream.mjs +49 -13
- package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +103 -68
- package/runtime/js/cm-ai/cm-ai-qa-log.mjs +79 -27
- package/runtime/js/cm-ai/code-projects.mjs +4 -1
- package/runtime/js/cm-ai/control-policy.mjs +111 -0
- package/runtime/js/cm-ai/developer-adapter.mjs +7 -0
- package/runtime/js/cm-ai/drive-bootstrap.mjs +11 -8
- package/runtime/js/cm-ai/drive-core.mjs +9 -0
- package/runtime/js/cm-ai/durable-runner-state.mjs +883 -69
- package/runtime/js/cm-ai/effect-abandon-log.mjs +5 -2
- package/runtime/js/cm-ai/effect-contract.mjs +6 -1
- package/runtime/js/cm-ai/external-run-guard.mjs +18 -7
- package/runtime/js/cm-ai/gate-bridge.mjs +4 -4
- package/runtime/js/cm-ai/host-check.mjs +4 -1
- package/runtime/js/cm-ai/host-conversation-execution.mjs +33 -24
- package/runtime/js/cm-ai/host-documentation.mjs +53 -12
- package/runtime/js/cm-ai/host-project-execution.mjs +2 -2
- package/runtime/js/cm-ai/host-qa-executor.mjs +49 -4
- package/runtime/js/cm-ai/host-qa-fix-owner.mjs +53 -9
- package/runtime/js/cm-ai/host-qa-policy.mjs +63 -21
- package/runtime/js/cm-ai/host-review-authority.mjs +2 -2
- package/runtime/js/cm-ai/host-review-file.mjs +1 -1
- package/runtime/js/cm-ai/host-session.mjs +1 -1
- package/runtime/js/cm-ai/host-tool-bridge.mjs +43 -3
- package/runtime/js/cm-ai/host-workflow-capabilities.mjs +21 -10
- package/runtime/js/cm-ai/host.mjs +1 -2
- package/runtime/js/cm-ai/operator-guidance.mjs +89 -3
- package/runtime/js/cm-ai/provider-review-observation.mjs +50 -0
- package/runtime/js/cm-ai/qa-resource-release.mjs +46 -0
- package/runtime/js/cm-ai/qa-round-budget.mjs +13 -0
- package/runtime/js/cm-ai/review-package.mjs +26 -5
- package/runtime/js/cm-ai/reviewed-deliveries.mjs +1 -1
- package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +1 -1
- package/runtime/js/cm-ai/task-commit.mjs +39 -0
- package/runtime/js/cm-ai/task-runner.mjs +629 -121
- package/runtime/js/cm-ai/worker-claude-developer.mjs +9 -0
- package/runtime/js/cm-ai/worker-claude.mjs +10 -3
- package/runtime/js/cm-ai/worker-process-identity.mjs +43 -0
- package/runtime/js/cm-fix/execution.mjs +176 -48
- package/runtime/js/cm-fix/host.mjs +2 -1
- package/runtime/js/cm-fix/pinned-baseline.mjs +24 -0
- package/runtime/js/cm-fix/progress.mjs +13 -3
- package/runtime/js/cm-fix/protected-edits.mjs +10 -3
- package/runtime/js/cm-fix/repair.mjs +11 -3
- package/runtime/js/cm-fix/test-author.mjs +10 -3
- package/runtime/js/cm-idea/session.mjs +67 -4
- package/runtime/js/cm-init/review-evidence.mjs +3 -1
- package/runtime/js/cm-prd/review-correction.mjs +10 -4
- package/runtime/js/cm-prd/review-host.mjs +1 -1
- package/runtime/js/cm-prd/review-publication.mjs +5 -3
- package/runtime/js/cm-prd/session.mjs +43 -0
- package/runtime/js/cm-refactor/records.mjs +98 -8
- package/runtime/js/cm-refactor/workflow.mjs +80 -10
- package/runtime/js/cm-test/host.mjs +10 -3
- package/runtime/js/cm-test/session.mjs +45 -6
- package/runtime/js/notify-safe-read.mjs +49 -0
- package/runtime/js/notify-send.mjs +313 -0
- package/runtime/js/notify.mjs +164 -37
- package/runtime/js/policy-binding-compat.mjs +55 -0
- package/runtime/review.md +52 -7
- package/runtime/task-gates.md +107 -9
- package/scripts/ci-test-shards.mjs +67 -0
- package/scripts/ci-test-shards.test.mjs +64 -0
- package/scripts/ci-test-weights.json +222 -0
- package/scripts/cm-ai-abandon-effect-position.test.mjs +71 -10
- package/scripts/cm-ai-answer-gap-dispatch.test.mjs +86 -0
- package/scripts/cm-ai-answer-gap-driver.test.mjs +51 -0
- package/scripts/cm-ai-answer-gap-fixture.mjs +89 -0
- package/scripts/cm-ai-answer-gap-recheck.test.mjs +70 -0
- package/scripts/cm-ai-answer-gap-redo.test.mjs +103 -0
- package/scripts/cm-ai-batch-drive.mjs +98 -34
- package/scripts/cm-ai-batch-drive.test.mjs +124 -16
- package/scripts/cm-ai-batch-host.mjs +167 -29
- package/scripts/cm-ai-batch-host.test.mjs +303 -31
- package/scripts/cm-ai-batch-run-fixture.mjs +452 -0
- package/scripts/cm-ai-batch-run-member-stops.test.mjs +26 -0
- package/scripts/cm-ai-batch-run-parallel.test.mjs +7 -0
- package/scripts/cm-ai-batch-run-reschedule.test.mjs +17 -0
- package/scripts/cm-ai-batch-run.mjs +213 -25
- package/scripts/cm-ai-batch-run.test.mjs +21 -341
- package/scripts/cm-ai-bootstrap-flow.test.mjs +1 -7
- package/scripts/cm-ai-bootstrap.test.mjs +2 -3
- package/scripts/cm-ai-control-launch.test.mjs +219 -0
- package/scripts/cm-ai-control-policy.test.mjs +124 -0
- package/scripts/cm-ai-control-v2-drive.test.mjs +270 -0
- package/scripts/cm-ai-develop-answer-invalid.test.mjs +97 -0
- package/scripts/cm-ai-develop-call-timeout.test.mjs +146 -0
- package/scripts/cm-ai-develop-driver-gaps.test.mjs +37 -23
- package/scripts/cm-ai-direct-review.test.mjs +348 -0
- package/scripts/cm-ai-documentation-sync-gap.test.mjs +424 -0
- package/scripts/cm-ai-drive-bootstrap-rules.test.mjs +54 -25
- package/scripts/cm-ai-drive.mjs +142 -58
- package/scripts/cm-ai-drive.test.mjs +70 -84
- package/scripts/cm-ai-fix-integration.test.mjs +3 -5
- package/scripts/cm-ai-fix-later-delivery.test.mjs +3 -6
- package/scripts/cm-ai-fix-run-delivery.test.mjs +3 -6
- package/scripts/cm-ai-host-cli-workflow.test.mjs +267 -0
- package/scripts/cm-ai-host-fixture.mjs +296 -0
- package/scripts/cm-ai-host-protected.test.mjs +253 -0
- package/scripts/cm-ai-host.mjs +122 -100
- package/scripts/cm-ai-host.test.mjs +35 -776
- package/scripts/cm-ai-launch-diagnostics.test.mjs +5 -3
- package/scripts/cm-ai-legacy-history.test.mjs +53 -0
- package/scripts/cm-ai-light-modules.test.mjs +54 -0
- package/scripts/cm-ai-multi-root.test.mjs +4 -4
- package/scripts/cm-ai-nested-execution.test.mjs +16 -19
- package/scripts/cm-ai-operator-guidance.test.mjs +30 -5
- package/scripts/cm-ai-progress.test.mjs +10 -8
- package/scripts/cm-ai-project-qa-gate.test.mjs +37 -10
- package/scripts/cm-ai-protected-scope.test.mjs +8 -5
- package/scripts/cm-ai-qa-answer-gaps.test.mjs +99 -0
- package/scripts/cm-ai-qa-config-revision.test.mjs +1 -9
- package/scripts/cm-ai-qa-fingerprint-config.test.mjs +12 -9
- package/scripts/cm-ai-qa-fix-cross-session.test.mjs +95 -13
- package/scripts/cm-ai-qa-fixed-log.test.mjs +41 -0
- package/scripts/cm-ai-qa-recovery-args.test.mjs +7 -0
- package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +59 -14
- package/scripts/cm-ai-review-drift-precedence.test.mjs +1 -1
- package/scripts/cm-ai-review-failure.test.mjs +137 -32
- package/scripts/cm-ai-review-timeout-config.test.mjs +3 -1
- package/scripts/cm-ai-review-timeout.test.mjs +132 -67
- package/scripts/cm-ai-run.mjs +91 -28
- package/scripts/cm-ai-run.test.mjs +11 -38
- package/scripts/cm-ai-selection-guard.test.mjs +2 -2
- package/scripts/cm-ai-session-chain.test.mjs +18 -15
- package/scripts/cm-ai-spec-rebind.test.mjs +14 -18
- package/scripts/cm-ai-supersede.test.mjs +489 -51
- package/scripts/cm-blocked-reason.test.mjs +2 -3
- package/scripts/cm-capability-gate.test.mjs +33 -1
- package/scripts/cm-check-drive-files.mjs +8 -0
- package/scripts/cm-check-drive.test.mjs +2 -5
- package/scripts/cm-check-runtime.sh +4 -2
- package/scripts/cm-claude-developer-worker.test.mjs +15 -0
- package/scripts/cm-claude-review-stream.test.mjs +21 -16
- package/scripts/cm-claude-review-synthetic.test.mjs +155 -0
- package/scripts/cm-claude-worker.test.mjs +23 -5
- package/scripts/cm-controlled-correction.test.mjs +469 -0
- package/scripts/cm-external-batch-host.test.mjs +30 -11
- package/scripts/cm-external-model-host.test.mjs +1 -1
- package/scripts/cm-external-model-recovery.test.mjs +32 -12
- package/scripts/cm-external-qa-fix.test.mjs +1 -1
- package/scripts/cm-external-review-reconciliation.test.mjs +6 -24
- package/scripts/cm-fix-abandon.test.mjs +163 -10
- package/scripts/cm-fix-drive-unprotected.test.mjs +37 -0
- package/scripts/cm-fix-drive.mjs +25 -7
- package/scripts/cm-fix-host.mjs +8 -7
- package/scripts/cm-fix-review-budget.test.mjs +13 -0
- package/scripts/cm-fix-review-recovery.test.mjs +36 -1
- package/scripts/cm-host-answer-timeout.test.mjs +65 -0
- package/scripts/cm-host-call-kinds.test.mjs +28 -0
- package/scripts/cm-host-documentation.test.mjs +49 -0
- package/scripts/cm-host-qa-executor.test.mjs +23 -12
- package/scripts/cm-host-qa-policy.test.mjs +43 -16
- package/scripts/cm-host-review-authority.test.mjs +0 -31
- package/scripts/cm-idea-answer-gaps.test.mjs +164 -0
- package/scripts/cm-idea-drive.mjs +49 -11
- package/scripts/cm-idea-drive.test.mjs +66 -0
- package/scripts/cm-idea-host.mjs +106 -16
- package/scripts/cm-init-answer-gaps.test.mjs +258 -0
- package/scripts/cm-init-drive.mjs +41 -7
- package/scripts/cm-init-host.mjs +61 -12
- package/scripts/cm-knowledge-closeout.test.mjs +3 -3
- package/scripts/cm-log-event.mjs +21 -10
- package/scripts/cm-notify-command.test.mjs +936 -0
- package/scripts/cm-notify-read-drift.test.mjs +270 -0
- package/scripts/cm-notify.mjs +481 -0
- package/scripts/cm-notify.test.mjs +312 -23
- package/scripts/cm-patrol.test.mjs +3 -2
- package/scripts/cm-prd-answer-gaps.test.mjs +216 -0
- package/scripts/cm-prd-drive.mjs +18 -5
- package/scripts/cm-prd-drive.test.mjs +15 -0
- package/scripts/cm-prd-host.mjs +37 -4
- package/scripts/cm-prd-review-disposition.test.mjs +6 -1
- package/scripts/cm-prd-review-gate.mjs +56 -0
- package/scripts/cm-refactor-answer-gaps.test.mjs +206 -0
- package/scripts/cm-refactor-drive.mjs +52 -8
- package/scripts/cm-refactor-drive.test.mjs +44 -0
- package/scripts/cm-refactor-host.test.mjs +10 -6
- package/scripts/cm-release-smoke.sh +2 -0
- package/scripts/cm-task-gate-correction.test.mjs +69 -16
- package/scripts/cm-task-gate.mjs +368 -34
- package/scripts/cm-task-gate.py +2 -0
- package/scripts/cm-task-gate.test.mjs +252 -4
- package/scripts/cm-test-answer-gaps.test.mjs +151 -0
- package/scripts/cm-test-drive.mjs +21 -5
- package/scripts/fixtures/bootstrap-review-runner.mjs +1 -7
- package/scripts/fixtures/claude-review-process.mjs +1 -1
- package/scripts/fixtures/native-gate-fixture.mjs +18 -0
- package/scripts/policy-binding-compat.test.mjs +103 -0
- package/scripts/scan-public-safety.py +4 -0
- package/scripts/validate-public-repo.py +4 -0
- package/skills/cm-ai/SKILL.md +8 -6
- package/skills/cm-ai/references/N3-execute-task.md +17 -2
- package/skills/cm-ai/references/N4-review.md +11 -21
- package/skills/cm-ai/references/N5-mark-done.md +1 -1
- package/skills/cm-ai/references/N6-qa-eval.md +49 -21
- package/skills/cm-ai/references/js-host-modes.md +35 -14
- package/skills/cm-ai/references/js-host-qa-recovery.md +85 -11
- package/skills/cm-ai/references/js-host-recovery.md +181 -21
- package/skills/cm-ai/references/js-host.md +76 -32
- package/skills/cm-check/SKILL.md +3 -3
- package/skills/cm-fix/SKILL.md +12 -0
- package/skills/cm-fix/references/js-host.md +44 -5
- package/skills/cm-idea/references/js-host.md +27 -2
- package/skills/cm-init/references/js-host.md +17 -4
- package/skills/cm-notify/SKILL.md +34 -0
- package/skills/cm-prd/references/js-change-recovery.md +35 -1
- package/skills/cm-prd/references/js-host.md +1 -1
- package/skills/cm-refactor/SKILL.md +12 -0
- package/skills/cm-refactor/references/js-host.md +17 -0
- package/skills/cm-test/references/js-host.md +14 -1
|
@@ -5,32 +5,135 @@ import {readBatchExternalModels,freezeBatchExternalModels,batchModelsFile} from
|
|
|
5
5
|
import fs from 'node:fs';
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import {fileURLToPath} from 'node:url';
|
|
8
|
-
import {createCmAiBatch,batchTaskRunId} from './cm-ai-batch-run.mjs';
|
|
8
|
+
import {createCmAiBatch,batchTaskRunId,BATCH_MEMBER_ACTIONS} from './cm-ai-batch-run.mjs';
|
|
9
|
+
import {validEnvironmentFailureReason} from '../runtime/js/cm-ai/cm-ai-qa-log.mjs';
|
|
9
10
|
import {assertCreatableScope} from './cm-ai-run.mjs';
|
|
10
|
-
import {createConversationExecution,readConversationReviewConfiguration,readConversationProtection,runReviewPreflight} from './cm-ai-host.mjs';
|
|
11
|
+
import {createConversationExecution,readConversationReviewConfiguration,readConversationReviewConfigurationValue,readConversationProtection,runReviewPreflight} from './cm-ai-host.mjs';
|
|
11
12
|
import {loadConfig,resolveProtectedRuntimes} from './cm-workflow-config.mjs';
|
|
12
13
|
import {preflightMatches} from '../runtime/js/cm-ai/worker-codex.mjs';
|
|
13
14
|
import {claudePreflightMatches} from '../runtime/js/cm-ai/worker-claude.mjs';
|
|
14
|
-
import {createHostToolBridge} from '../runtime/js/cm-ai/host-tool-bridge.mjs';
|
|
15
|
+
import {createHostToolBridge,HOST_ANSWER_BACKSTOP_MS} from '../runtime/js/cm-ai/host-tool-bridge.mjs';
|
|
15
16
|
import {serveCmAiHost,parseHostInputLimit,inputLimitReason} from '../runtime/js/cm-ai/host-session.mjs';
|
|
16
17
|
import {validateHostWorkflowConfiguration,featureHasBrowserCases,readBrowserCapability} from '../runtime/js/cm-ai/host-workflow-capabilities.mjs';
|
|
17
18
|
import {digest,json,need,shape} from '../runtime/js/cm-ai/effect-contract.mjs';
|
|
18
19
|
import {identifyApprovedBootstrapFeature} from '../runtime/js/cm-ai/bootstrap-feature.mjs';
|
|
20
|
+
import {readControlPolicyFile} from '../runtime/js/cm-ai/control-policy.mjs';
|
|
19
21
|
|
|
20
|
-
const usage='cm-ai-batch-host.mjs serve --config PATH --host-context ID --allow-development --review-config PATH (required for a new batch; later launches pass the same file) [--execution-optimizations] [--external-models [--external-models-config PATH]] [--runtime codex|claude] [--input-limit BYTES] [--allow-
|
|
22
|
+
const usage='cm-ai-batch-host.mjs serve --config PATH --host-context ID --allow-development --review-config PATH (required for a new batch; later launches pass the same file) [--execution-optimizations] [--external-models [--external-models-config PATH]] [--runtime codex|claude] [--input-limit BYTES] [--allow-qa] [--rerun-unknown-qa | --rerun-blocked-qa [--qa-environment-failure REASON]] [--allow-develop-redo FEATURE/TASK]... [--allow-abandon-effect FEATURE/TASK]... [--allow-abandon-review FEATURE/TASK]... [--allow-bootstrap-review-recovery FEATURE/TASK]... [--verification-precheck] [--browser-qa available|unavailable] [--protected-conversation-config PATH | --protected-config PATH] [--allow-provider-development FEATURE/TASK:1|2]... [--hold-revision FEATURE/TASK]...';
|
|
21
23
|
const safeCode=error=>typeof error?.code==='string'&&/^[a-z][a-z0-9_]{0,63}$/.test(error.code)?error.code:'batch_host_failed';
|
|
24
|
+
// Operator-facing reasons the batch owner writes itself (R4); others stay redacted.
|
|
25
|
+
const REASONED=new Set(['batch_resources_open','legacy_preflight_cache_invalid']);
|
|
26
|
+
const boundedReason=error=>REASONED.has(error?.code)&&typeof error.reason==='string'&&error.reason.length<=8192&&!/[\r\n\0]/.test(error.reason)?error.reason:null;
|
|
27
|
+
const actionFlags=new Map(Object.entries(BATCH_MEMBER_ACTIONS).map(([name,{flag}])=>[flag,name]));
|
|
28
|
+
// Single-task recovery inputs a batch cannot take: each member's fingerprint binds
|
|
29
|
+
// the whole batch workflow map, and a member cannot be rebound alone.
|
|
30
|
+
const UNSUPPORTED={'--revise-qa-config':'batch_qa_revision_unavailable','--qa-config-revision-reason':'batch_qa_revision_unavailable',
|
|
31
|
+
'--rebind-spec-material':'batch_spec_rebind_unavailable','--spec-rebind-reason':'batch_spec_rebind_unavailable'};
|
|
32
|
+
const UNSUPPORTED_REASON={batch_qa_revision_unavailable:'批次不能修订单个成员的 QA 配置:每个成员的运行指纹绑定整批 workflows,改一个成员会让其他成员都无法恢复,单任务宿主也打不开批次成员运行。出口:QA 环境问题用 --rerun-blocked-qa(必要时加 --qa-environment-failure 原因);确需改 QA 命令,取消本批次后用单任务宿主 cm-ai-host.mjs 以 --supersede-reviewed-evidence --supersede-reason 原因 新建运行重做该任务',
|
|
33
|
+
batch_spec_rebind_unavailable:'批次成员不能换绑规格。出口:还原这些规格改动并重新批准后继续本批次;或取消本批次,还原该任务已改动的代码后,用单任务宿主 cm-ai-host.mjs 以 --supersede-reviewed-evidence --supersede-reason 原因 新建运行重做该任务'};
|
|
22
34
|
|
|
23
35
|
export async function serveHostTransport(options,rawInputLimit,serve=serveCmAiHost){
|
|
24
36
|
return serve({...options,inputLimit:parseHostInputLimit(rawInputLimit)});
|
|
25
37
|
}
|
|
26
38
|
|
|
27
|
-
|
|
39
|
+
// Before 53c385e an execution-policy batch (without external models) cached its member
|
|
40
|
+
// loopback preflights in .reviews/.execution/<batchId>/preflight-<task>.json. The
|
|
41
|
+
// external run guard refuses that non-run directory, so such a batch could never open
|
|
42
|
+
// a member again. A directory that is exactly that old cache (only 0600 single-link
|
|
43
|
+
// preflight files of this batch's parallel members, each still bound to the launch
|
|
44
|
+
// review model, disabled skills and the member worktree cwd) moves file by file to
|
|
45
|
+
// the current location; an identical file already there drops the old copy. Anything
|
|
46
|
+
// else is refused with the directory named and nothing moved, so it is checked by hand.
|
|
47
|
+
export function migrateLegacyPreflightCache(batch,review,runtime){
|
|
48
|
+
const legacy=path.join(batch.specsDir,'.reviews','.execution',batch.batchId);
|
|
49
|
+
let stat;try{stat=fs.lstatSync(legacy);}catch(error){if(error.code==='ENOENT')return {moved:[],dropped:[]};throw error;}
|
|
50
|
+
const refuse=detail=>{throw Object.assign(new Error('legacy_preflight_cache_invalid'),{code:'legacy_preflight_cache_invalid',
|
|
51
|
+
reason:`运行目录下的 ${legacy} 不是可识别的旧版并行成员预检缓存(${detail})。外部运行守卫会把它当作无法核实的运行,批次成员打不开;宿主没有移动或删除其中任何文件。`
|
|
52
|
+
+`下一步:只读核对该目录;确认只是旧版 preflight 缓存且没有进程在写后,把它移出 .reviews/.execution(例如移到 .reviews/external-preflight-legacy/),再用同一批次配置重新启动批次宿主并 advance,成员会重新做一次本地 loopback 预检`});};
|
|
53
|
+
if(!stat.isDirectory()||stat.isSymbolicLink()||(stat.mode&0o077)!==0||fs.realpathSync(legacy)!==legacy)refuse('不是权限 0700 的普通目录');
|
|
54
|
+
if(review===null)refuse('本次启动没有 --review-config,无法核对缓存绑定的审查模型');
|
|
55
|
+
const members=new Map((batch.parallel??[]).flat().map(key=>[`preflight-${key.slice(key.lastIndexOf('/')+1)}.json`,key.slice(key.lastIndexOf('/')+1)]));
|
|
56
|
+
// The target and its parent are checked before anything is moved or deleted,
|
|
57
|
+
// whether or not a file will be moved; a missing one is created 0700 (one level at
|
|
58
|
+
// a time) and checked again only right before the first move.
|
|
59
|
+
const parent=path.join(batch.specsDir,'.reviews','external-preflight'),target=path.join(parent,batch.batchId);
|
|
60
|
+
const targetDirectories=create=>{
|
|
61
|
+
for(const directory of [parent,target]){
|
|
62
|
+
if(create)try{fs.mkdirSync(directory,{mode:0o700});}catch(error){if(error.code!=='EEXIST')throw error;}
|
|
63
|
+
let info;try{info=fs.lstatSync(directory);}catch(error){if(error.code==='ENOENT'&&!create)return;throw error;}
|
|
64
|
+
if(!info.isDirectory()||info.isSymbolicLink()||(info.mode&0o077)!==0||fs.realpathSync(directory)!==directory)
|
|
65
|
+
refuse(`新位置 ${directory} 不是权限 0700 的普通目录`);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
targetDirectories(false);
|
|
69
|
+
// One read per file through a no-follow fd bound to the path's dev+ino; only these
|
|
70
|
+
// exact bytes are validated and compared. links: 2 only for an interrupted move,
|
|
71
|
+
// where the old and new names are the same inode.
|
|
72
|
+
const pinned=(file,links=1)=>{
|
|
73
|
+
let before;try{before=fs.lstatSync(file);}catch(error){if(error.code==='ENOENT')return null;throw error;}
|
|
74
|
+
if(!before.isFile()||before.isSymbolicLink()||before.nlink!==links||(before.mode&0o077)!==0||before.size>64*1024)
|
|
75
|
+
refuse(`${file} 不是权限 0600、${links} 个链接的普通文件`);
|
|
76
|
+
let fd;try{fd=fs.openSync(file,fs.constants.O_RDONLY|fs.constants.O_NOFOLLOW);}catch{refuse(`${file} 无法按不跟随链接的方式打开`);}
|
|
77
|
+
try{
|
|
78
|
+
const info=fs.fstatSync(fd);
|
|
79
|
+
if(info.dev!==before.dev||info.ino!==before.ino||!info.isFile()||info.nlink!==links)refuse(`${file} 在核对时被替换`);
|
|
80
|
+
return {bytes:fs.readFileSync(fd),dev:info.dev,ino:info.ino};
|
|
81
|
+
}finally{fs.closeSync(fd);}
|
|
82
|
+
};
|
|
83
|
+
const same=(left,right)=>left!==null&&right!==null&&left.dev===right.dev&&left.ino===right.ino&&left.bytes.equals(right.bytes);
|
|
84
|
+
const plan=[];
|
|
85
|
+
for(const entry of fs.readdirSync(legacy,{withFileTypes:true})){
|
|
86
|
+
const taskId=members.get(entry.name);if(!taskId)refuse(`含有不属于本批次并行成员预检缓存的条目 ${entry.name}`);
|
|
87
|
+
const file=path.join(legacy,entry.name),destination=path.join(target,entry.name);
|
|
88
|
+
let interrupted=false;
|
|
89
|
+
try{const a=fs.lstatSync(file),b=fs.lstatSync(destination);interrupted=a.dev===b.dev&&a.ino===b.ino;}catch(error){if(error.code!=='ENOENT')throw error;}
|
|
90
|
+
const source=pinned(file,interrupted?2:1);
|
|
91
|
+
if(source===null)refuse(`${entry.name} 在核对时消失`);
|
|
92
|
+
const cwd=path.resolve(batch.codeProject,'..','.cm-worktrees',batch.batchId.slice(0,8),taskId);
|
|
93
|
+
const options={cwd,model:review.model,disabledSkills:review.disabledSkills,promptTransport:'stdin'};
|
|
94
|
+
let cached;try{cached=readConversationReviewConfigurationValue(JSON.parse(source.bytes.toString('utf8')),null);}
|
|
95
|
+
catch{refuse(`${entry.name} 不是预检缓存格式`);}
|
|
96
|
+
if(Object.hasOwn(cached,'timeoutMs')||cached.model!==review.model||digest(cached.disabledSkills)!==digest(review.disabledSkills)
|
|
97
|
+
||!(runtime==='claude'?claudePreflightMatches:preflightMatches)(cached.preflight,options))
|
|
98
|
+
refuse(`${entry.name} 绑定的审查模型、禁用技能或成员 worktree 指纹与本次启动不一致`);
|
|
99
|
+
if(interrupted){plan.push({file,destination,source,action:'finish'});continue;}
|
|
100
|
+
const existing=pinned(destination);
|
|
101
|
+
if(existing!==null&&!existing.bytes.equals(source.bytes))refuse(`新位置 ${destination} 已有不同内容`);
|
|
102
|
+
plan.push({file,destination,source,existing,action:existing===null?'move':'drop'});
|
|
103
|
+
}
|
|
104
|
+
// Commit without overwriting: link (fails on an existing name), re-read the linked
|
|
105
|
+
// inode, then remove the old name. A duplicate is removed only after both sides are
|
|
106
|
+
// re-read unchanged. A stop at any point leaves either the old file, or the same inode
|
|
107
|
+
// under both names, which the next launch finishes ('finish').
|
|
108
|
+
const moved=[],dropped=[];
|
|
109
|
+
if(plan.some(item=>item.action==='move'))targetDirectories(true);
|
|
110
|
+
for(const item of plan){
|
|
111
|
+
const name=path.basename(item.file);
|
|
112
|
+
if(item.action==='move'){
|
|
113
|
+
try{fs.linkSync(item.file,item.destination);}
|
|
114
|
+
catch(error){if(error.code==='EEXIST')refuse(`新位置 ${item.destination} 在迁移时出现`);throw error;}
|
|
115
|
+
const linked=pinned(item.destination,2);
|
|
116
|
+
if(!same(linked,item.source)){fs.unlinkSync(item.destination);refuse(`${name} 在迁移时被改动`);}
|
|
117
|
+
}else if(item.action==='drop'){
|
|
118
|
+
if(!same(pinned(item.file),item.source)||!same(pinned(item.destination),item.existing))refuse(`${name} 或新位置的副本在迁移时被改动`);
|
|
119
|
+
}else if(!same(pinned(item.destination,2),item.source))refuse(`${name} 在迁移时被改动`);
|
|
120
|
+
fs.unlinkSync(item.file);
|
|
121
|
+
(item.action==='drop'?dropped:moved).push(name);
|
|
122
|
+
}
|
|
123
|
+
try{fs.rmdirSync(legacy);}catch(error){if(['ENOTEMPTY','EEXIST'].includes(error.code))refuse('迁移时目录里出现了新条目');throw error;}
|
|
124
|
+
return {moved,dropped};
|
|
125
|
+
}
|
|
126
|
+
// strict: an execution-policy batch. Its member runs take the external run guard,
|
|
127
|
+
// which refuses any non-run directory under .reviews/.execution, so the loopback
|
|
128
|
+
// cache lives beside the external-model one instead.
|
|
129
|
+
async function memberReviewConfiguration(batch,definition,review,runtime,pair=null,allowPreflight=true,strict=false){
|
|
130
|
+
if(strict&&!pair)migrateLegacyPreflightCache(batch,review,runtime);
|
|
28
131
|
try{
|
|
29
132
|
need(review!==null,'review_configuration_required');
|
|
30
133
|
const options={cwd:definition.codeProject,model:review.model,...(pair?{effort:pair.effort}:{}),disabledSkills:review.disabledSkills,promptTransport:'stdin'};
|
|
31
134
|
const matches=config=>config.model===review.model&&digest(config.disabledSkills)===digest(review.disabledSkills)
|
|
32
135
|
&&(runtime==='claude'?claudePreflightMatches:preflightMatches)(config.preflight,options);
|
|
33
|
-
const directory=path.join(batch.specsDir,'.reviews',...(pair?['external-preflight']:['.execution']),batch.batchId);
|
|
136
|
+
const directory=path.join(batch.specsDir,'.reviews',...(pair||strict?['external-preflight']:['.execution']),batch.batchId);
|
|
34
137
|
fs.mkdirSync(directory,{recursive:true,mode:0o700});
|
|
35
138
|
need(fs.realpathSync(directory)===directory,'invalid_preflight_cache');
|
|
36
139
|
const file=path.join(directory,`preflight-${definition.identity.taskId}.json`);
|
|
@@ -53,12 +156,24 @@ async function memberReviewConfiguration(batch,definition,review,runtime,pair=nu
|
|
|
53
156
|
}
|
|
54
157
|
|
|
55
158
|
export async function main(argv=process.argv.slice(2),{input=process.stdin,output=process.stdout,error=process.stderr}={}){
|
|
159
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Control v2: serve --config BUNDLE --host-context ID --control-config POLICY --review-config REVIEW; no --allow-*. Batch qaFix must be disabled. See docs/cm-control-policy-v2.md.\n');
|
|
56
160
|
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('Optional --execution-optimizations freezes policy v1 for new runs only; recovery retains the original policy and legacy runs reject retrofit. See docs/execution-optimizations.md.\n');
|
|
57
|
-
if(argv.length===1&&['--help','-h'].includes(argv[0]))
|
|
161
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0]))output.write('成员恢复(Q24):--allow-develop-redo / --allow-abandon-effect / --allow-abandon-review / --allow-bootstrap-review-recovery FEATURE/TASK 各授权一次同名批次操作 {operation, requestId, taskKey, reason},只转给批次当前停住的那个成员运行(同一 cm-ai 入口、只带这一项权限,不跨成员),之后 advance 继续本批次;缺授权返回 batch_member_action_authorization_required,非当前成员返回 batch_member_action_not_current。批次 cancel 后永久停止不变。--qa-environment-failure REASON 随 --rerun-blocked-qa / --rerun-unknown-qa 使用。--revise-qa-config 与 --rebind-spec-material 不支持(batch_qa_revision_unavailable / batch_spec_rebind_unavailable,原因里写明出口)。并行成员停在可在原运行内恢复的状态时返回 batch_parallel_member_recovery_required;结果未确认时返回 batch_parallel_member_unresolved 并留在原运行;只有原始存档为已 checkpoint 的 blocked 才改排串行第二代,且先停在 batch_member_rescheduled,下一次 advance 才开发第二代(普通批次与外部模型、执行策略批次相同)。\n');
|
|
162
|
+
if(argv.length===1&&['--help','-h'].includes(argv[0])){output.write(usage+'\nOptional --input-limit BYTES sets the host input transport limit to an integer from 65536 to 4194304 (default 65536); it may change on resume.\nOptional --protected-conversation-config PATH uses the shared current-host scoped text proposals and native sandbox checks; {checkCommands,timeoutMs}. No extra model call, same Codex/Claude runtime and configured per-task review execution. Optional --protected-config PATH {model,checkCommands,timeoutMs} enables CLI development only for per-task --allow-provider-development FEATURE/TASK:1|2 grants; mutually exclusive with --protected-conversation-config. Optional bundle.bootstraps maps approved bootstrap task keys to {selection}; --allow-bootstrap-write grants only those fixed instruction/scaffold steps. Optional batch.codeProjects uses prefixed paths and checks with codeProject per command; one task remains one completion gate.\n--review-config PATH is required when no member run of the batch exists yet (like single-task create): it is bound into every member fingerprint and cannot be added on resume. It is {model,preflight[,disabledSkills][,timeoutMs]}; timeoutMs is the reviewer transport budget in milliseconds (integer 1-3600000, default 900000). It is independent of --protected-conversation-config/--protected-config and wins over their timeoutMs for the reviewer. It is not part of the authorized configuration digest, so a resumed run may raise it after review_transport_timeout.\n--browser-qa available|unavailable declares interactive QA capability for applicable feature carriers including browser and ios-simulator; the flag name is retained for compatibility.\nOptional --rerun-unknown-qa / --rerun-blocked-qa carry the same single-task QA recovery into a batch and require --allow-qa; they are mutually exclusive. A batch has no --mode, so each task applies the flag only when it resumes an existing run and has a QA executor; a created run or a task without QA ignores it rather than failing the whole batch. Semantics, limits and the qaRound cap are the single-task ones, unchanged.\nOptional --verification-precheck sends the written verification of the task and the collected checks back as a verification_precheck request before any handoff or review package is built. It may only block: a requirement reported unsatisfied stops the task at blocked / verification_precheck_failed with pendingAction resume and spends no review round. Passing it is not an approval, writes no receipt and does not replace the independent review. A task with no written verification is unaffected.\nOptional --hold-revision FEATURE/TASK (repeatable, launch-only, never persisted) stops that task after a changes_requested review with code revision_answer_required, before any second-round develop intent; the next launch without it resumes the revision. It only narrows what this launch does.\nBatch entry requires a clean Git main checkout (including untracked files); batch_main_dirty lists dirty files before any task or worktree starts. Serial tasks are committed automatically before batch_handoff, with task_commit recording the SHA (null if unchanged). A parallel member whose raw journal is a checkpointed blocked terminal preserves WIP on its retained branch and falls back once to serial generation 2 after ready members merge; that advance stops at batch_member_rescheduled and the next one develops generation 2. Unconfirmed members stay in their original run.\n');return 0;}
|
|
58
163
|
let bridge;
|
|
59
164
|
try{
|
|
60
|
-
|
|
61
|
-
|
|
165
|
+
let controlPolicy=null;
|
|
166
|
+
const withMode=argv[0]==='serve'&&argv[3]==='--mode'&&argv[5]==='--host-context'&&argv[7]==='--control-config';
|
|
167
|
+
if(withMode)need(['create','resume'].includes(argv[4]),'invalid_mode');
|
|
168
|
+
const contextOffset=withMode?5:3,controlOffset=withMode?7:5;
|
|
169
|
+
if(argv[0]==='serve'&&argv[controlOffset]==='--control-config'){
|
|
170
|
+
if(argv.some(value=>value.startsWith('--allow-')))throw Object.assign(new Error('invalid_arguments'),
|
|
171
|
+
{code:'invalid_arguments',reason:'新版批次不接受 --allow-*;旧批次请用原入口和参数。'});
|
|
172
|
+
controlPolicy=readControlPolicyFile(argv[controlOffset+1]);need(controlPolicy.qaFix==='disabled','invalid_arguments');
|
|
173
|
+
}
|
|
174
|
+
need(argv.length>=6&&argv[0]==='serve'&&argv[1]==='--config'&&argv[contextOffset]==='--host-context'
|
|
175
|
+
&&(controlPolicy!==null||argv[5]==='--allow-development'),'host_launch_authorization_required');
|
|
176
|
+
const hostContextId=argv[contextOffset+1];
|
|
62
177
|
const stat=fs.lstatSync(argv[2]);need(stat.isFile()&&!stat.isSymbolicLink()&&stat.size<=64*1024,'invalid_batch_config');
|
|
63
178
|
const bundle=json(JSON.parse(fs.readFileSync(argv[2],'utf8')));shape(bundle,['batch','workflows',...(Object.hasOwn(bundle,'bootstraps')?['bootstraps']:[])]);
|
|
64
179
|
const {batch,workflows,bootstraps=null}=bundle;need(Array.isArray(batch.tasks),'invalid_batch_config');
|
|
@@ -73,15 +188,29 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
73
188
|
need(keys.length===Object.keys(workflows).length&&keys.every(key=>Object.hasOwn(workflows,key)),'workflow_task_mismatch');
|
|
74
189
|
for(const key of keys)if(workflows[key]!==null)validateHostWorkflowConfiguration(workflows[key]);
|
|
75
190
|
let review=null,allowQa=false,allowBootstrap=false,runtime=null,protection=null,providerConfig=null,browserQaFlag,inputLimitRaw;
|
|
76
|
-
let rerunUnknownQa=false,rerunBlockedQa=false,verificationPrecheck=false;const
|
|
191
|
+
let rerunUnknownQa=false,rerunBlockedQa=false,verificationPrecheck=false,qaEnvironmentFailure=null;const developments=new Map(),holds=new Set();
|
|
192
|
+
const memberActions=Object.fromEntries(Object.keys(BATCH_MEMBER_ACTIONS).map(name=>[name,[]]));
|
|
77
193
|
let externalEnabled=false,externalFile,executionPolicyEnabled=false;
|
|
78
|
-
for(let index=6;index<argv.length;index++){
|
|
194
|
+
for(let index=controlPolicy?controlOffset+2:6;index<argv.length;index++){
|
|
79
195
|
const name=argv[index];
|
|
80
196
|
if(name==='--execution-optimizations'){need(!executionPolicyEnabled,'invalid_arguments');executionPolicyEnabled=true;}
|
|
81
197
|
else if(name==='--allow-qa'){need(!allowQa,'invalid_arguments');allowQa=true;}
|
|
82
198
|
else if(name==='--rerun-unknown-qa'){need(!rerunUnknownQa,'invalid_arguments');rerunUnknownQa=true;}
|
|
83
199
|
else if(name==='--rerun-blocked-qa'){need(!rerunBlockedQa,'invalid_arguments');rerunBlockedQa=true;}
|
|
84
200
|
else if(name==='--verification-precheck'){need(!verificationPrecheck,'invalid_arguments');verificationPrecheck=true;}
|
|
201
|
+
else if(name==='--qa-environment-failure'){
|
|
202
|
+
need(qaEnvironmentFailure===null&&validEnvironmentFailureReason(argv[index+1]),'invalid_arguments');qaEnvironmentFailure=argv[++index];
|
|
203
|
+
}
|
|
204
|
+
else if(actionFlags.has(name)){
|
|
205
|
+
// A recovery grant names one member; it is consumed by that member's first forwarded operation.
|
|
206
|
+
const target=argv[++index],granted=memberActions[actionFlags.get(name)];
|
|
207
|
+
if(!(typeof target==='string'&&keys.includes(target)&&!granted.includes(target)))
|
|
208
|
+
throw Object.assign(new Error('invalid_arguments'),{code:'invalid_arguments',reason:`${name} 需要一个本批次的 FEATURE/TASK,且同一任务只给一次`});
|
|
209
|
+
granted.push(target);
|
|
210
|
+
}
|
|
211
|
+
else if(Object.hasOwn(UNSUPPORTED,name)){
|
|
212
|
+
const code=UNSUPPORTED[name];throw Object.assign(new Error(code),{code,reason:UNSUPPORTED_REASON[code]});
|
|
213
|
+
}
|
|
85
214
|
else if(name==='--browser-qa'){
|
|
86
215
|
need(browserQaFlag===undefined&&typeof argv[index+1]==='string','invalid_arguments');browserQaFlag=argv[++index];
|
|
87
216
|
}
|
|
@@ -114,11 +243,15 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
114
243
|
else if(name==='--hold-revision'){
|
|
115
244
|
const held=argv[++index];need(typeof held==='string'&&keys.includes(held)&&!holds.has(held),'invalid_arguments');holds.add(held);
|
|
116
245
|
}
|
|
117
|
-
else
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
246
|
+
else need(false,'invalid_arguments');
|
|
247
|
+
}
|
|
248
|
+
if(controlPolicy){
|
|
249
|
+
allowQa=controlPolicy.qa==='run';allowBootstrap=controlPolicy.bootstrap==='write';
|
|
250
|
+
need((controlPolicy.development==='provider')===Boolean(providerConfig),'invalid_arguments');
|
|
251
|
+
need(controlPolicy.bootstrap!=='write'||bootstraps!==null,'invalid_arguments');
|
|
252
|
+
need(bootstraps===null||controlPolicy.bootstrap==='write','invalid_arguments');
|
|
253
|
+
if(providerConfig)for(const key of keys)developments.set(key,1);
|
|
254
|
+
need(!rerunUnknownQa&&!rerunBlockedQa,'supersede_unavailable');
|
|
122
255
|
}
|
|
123
256
|
const started=keys.some(key=>fs.existsSync(path.join(batch.specsDir,'.reviews','.execution',batchTaskRunId(batch.batchId,key),'state.json')));
|
|
124
257
|
// Same read-only create gate as the batch owner, before any model or policy configuration is read or frozen.
|
|
@@ -139,15 +272,15 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
139
272
|
need(!developments.size||providerConfig!==null,'protected_configuration_required');
|
|
140
273
|
// Same launch-time assertion as the single-task host, evaluated across every
|
|
141
274
|
// task whose approved contract can select a browser case.
|
|
142
|
-
readBrowserCapability(browserQaFlag,keys.flatMap(key=>workflows[key]?.qa!=null
|
|
275
|
+
readBrowserCapability(browserQaFlag,keys.flatMap(key=>(!controlPolicy||allowQa)&&workflows[key]?.qa!=null
|
|
143
276
|
&&featureHasBrowserCases(batch.specsDir,key.slice(0,key.lastIndexOf('/')),batch.codeProject)
|
|
144
277
|
?[workflows[key].qa.environment?.carrier??'browser']:[]));
|
|
145
|
-
need(!approvals.size||review!==null,'review_configuration_required');
|
|
146
278
|
// Same two guards as the single-task host. A batch has no --mode, so the
|
|
147
279
|
// per-task resume check lives in createCmAiBatch rather than here.
|
|
148
280
|
need(!(rerunUnknownQa&&rerunBlockedQa),'qa_recovery_authorization_required');
|
|
149
281
|
need(!(rerunUnknownQa||rerunBlockedQa)||allowQa,'qa_recovery_authorization_required');
|
|
150
|
-
need(
|
|
282
|
+
need(qaEnvironmentFailure===null||rerunUnknownQa||rerunBlockedQa,'qa_recovery_authorization_required');
|
|
283
|
+
need(controlPolicy||allowQa||!Object.values(workflows).some(item=>item?.qa!=null),'qa_authorization_required');
|
|
151
284
|
// Same rule as single-task create: the reviewer binding is part of every
|
|
152
285
|
// member's durable fingerprint and cannot be added on resume. A batch none
|
|
153
286
|
// of whose member runs exist yet is being created. Batches that already
|
|
@@ -156,9 +289,9 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
156
289
|
batchTaskRunId(batch.batchId,key),'state.json')));
|
|
157
290
|
if(!created&&review===null)throw Object.assign(new Error('review_configuration_required'),{code:'review_configuration_required',
|
|
158
291
|
reason:'新批次必须带 --review-config:审查配置写进每个任务运行的指纹,恢复时不能再补。先用 cm-ai-host.mjs preflight 生成 review.json;'
|
|
159
|
-
+'
|
|
292
|
+
+'普通 advance 按已有审查配置派发第 1、2 轮;来源声明不证明人工批准'});
|
|
160
293
|
// Tool replies travel on the same input lines, so they share the one limit.
|
|
161
|
-
bridge=createHostToolBridge({responseLimit:parseHostInputLimit(inputLimitRaw)});
|
|
294
|
+
bridge=createHostToolBridge({responseLimit:parseHostInputLimit(inputLimitRaw),answerTimeoutMs:HOST_ANSWER_BACKSTOP_MS});
|
|
162
295
|
// The current conversation transport accepts one outstanding host call.
|
|
163
296
|
// Queue those calls only; member runners and independent Review stay concurrent.
|
|
164
297
|
let hostCallTail=Promise.resolve();
|
|
@@ -167,17 +300,16 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
167
300
|
hostCallTail=pending.then(()=>{},()=>{});return pending;
|
|
168
301
|
}};
|
|
169
302
|
let reconciling=false;
|
|
170
|
-
const driver=createCmAiBatch({configuration:{...batch,...(externalModels?{externalModels}:{}),...(executionPolicy?{executionPolicy}:{})},logHome:path.join(batch.specsDir,'.reviews','host-log-mirror'),
|
|
303
|
+
const driver=createCmAiBatch({configuration:{...batch,...(controlPolicy?{controlPolicy}:{}),...(externalModels?{externalModels}:{}),...(executionPolicy?{executionPolicy}:{})},logHome:path.join(batch.specsDir,'.reviews','host-log-mirror'),
|
|
171
304
|
runtime:runtime??'codex',checkCommands:(providerConfig??protection)?.checkCommands??null,checkTimeoutMs:(providerConfig??protection)?.timeoutMs??60000,
|
|
172
|
-
rerunUnknownQa,rerunBlockedQa,holdRevisions:[...holds],bootstrapKeys:Object.keys(bootstraps??{}),
|
|
305
|
+
rerunUnknownQa,rerunBlockedQa,qaEnvironmentFailure,memberActions,holdRevisions:[...holds],bootstrapKeys:Object.keys(bootstraps??{}),
|
|
173
306
|
executionFor:async(definition,{parallelMember=false}={})=>{
|
|
174
307
|
await freezeBatchExecutionPolicy(batch,executionPolicy);
|
|
175
308
|
freezeBatchExternalModels(batch,externalModels);
|
|
176
309
|
const key=`${definition.feature}/${definition.identity.taskId}`;
|
|
177
|
-
const
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
{parallelMember,...(executionPolicy?{executionPolicy}:{}),...(externalModels?{externalModels,...(providerConfig?{reviewerRuntime:routes.reviewerRuntime}:{})}:{}),...(verificationPrecheck?{verificationPrecheck:true}:{}),batchWorkflowsDigest:digest(executionPolicy?{workflows,bootstraps,externalModels,executionPolicy}:externalModels?{workflows,bootstraps,externalModels}:bootstraps?{workflows,bootstraps}:workflows),qaLogHome:path.join(batch.specsDir,'.reviews','host-log-mirror'),
|
|
310
|
+
const memberReview=parallelMember?await memberReviewConfiguration(batch,definition,review,externalModels?routes.reviewerRuntime:runtime??'codex',externalModels?.providers[routes.reviewerRuntime]??null,!reconciling,Boolean(executionPolicy)):review;
|
|
311
|
+
const execution=createConversationExecution(definition,hostContextId,parallelMember?memberBridge:bridge,memberReview,null,workflows[key],allowQa,runtime??'codex',
|
|
312
|
+
{parallelMember,...(controlPolicy?{controlPolicy}:{}),...(executionPolicy?{executionPolicy}:{}),...(externalModels?{externalModels,...(providerConfig?{reviewerRuntime:routes.reviewerRuntime}:{})}:{}),...(verificationPrecheck?{verificationPrecheck:true}:{}),batchWorkflowsDigest:digest(executionPolicy?{workflows,bootstraps,externalModels,executionPolicy}:externalModels?{workflows,bootstraps,externalModels}:bootstraps?{workflows,bootstraps}:workflows),qaLogHome:path.join(batch.specsDir,'.reviews','host-log-mirror'),
|
|
181
313
|
// A protected CLI config also protects unauthorized tasks: they stay on the
|
|
182
314
|
// current-session transport but with the same sandbox checks (protected-text edits).
|
|
183
315
|
...(protection?{protection}:providerConfig?{protection:{checkCommands:providerConfig.checkCommands,timeoutMs:providerConfig.timeoutMs}}:{}),
|
|
@@ -190,13 +322,19 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
|
|
|
190
322
|
return execution;
|
|
191
323
|
}});
|
|
192
324
|
const host={async handle(request){
|
|
193
|
-
try{
|
|
325
|
+
try{
|
|
326
|
+
reconciling=request.operation==='reconcile_review';const result=await driver.handle(request);
|
|
327
|
+
if(controlPolicy&&request.operation==='status'&&result.state!=='running')
|
|
328
|
+
return {...result,controlTarget:await driver.controlTarget()};
|
|
329
|
+
return result;
|
|
330
|
+
}
|
|
331
|
+
catch(cause){const reason=boundedReason(cause);return {outcome:'blocked',code:safeCode(cause),...(reason?{reason}:{})};}
|
|
194
332
|
}};
|
|
195
333
|
const rawMode=input.isTTY&&typeof input.setRawMode==='function';if(rawMode)input.setRawMode(true);
|
|
196
334
|
try{await serveHostTransport({host,input,output,toolBridge:bridge},inputLimitRaw);}
|
|
197
335
|
finally{if(rawMode)input.setRawMode(false);}
|
|
198
336
|
return 0;
|
|
199
|
-
}catch(cause){const code=safeCode(cause);error.write(JSON.stringify({error:{code,...(['browser_capability_required','browser_capability_unavailable','invalid_arguments','review_configuration_required','protected_scope'].includes(code)
|
|
337
|
+
}catch(cause){const code=safeCode(cause);error.write(JSON.stringify({error:{code,...(['browser_capability_required','browser_capability_unavailable','invalid_arguments','review_configuration_required','protected_scope',...Object.keys(UNSUPPORTED_REASON)].includes(code)
|
|
200
338
|
&&typeof cause.reason==='string'?{reason:cause.reason}:{}),...(code==='request_too_large'?{reason:inputLimitReason(cause.limit)}:{})}})+'\n');return 1;}
|
|
201
339
|
finally{bridge?.close();}
|
|
202
340
|
}
|