@ornexus/neocortex 4.60.71 → 4.60.73
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/dist/release-source.json +1 -1
- package/dist/sbom.cdx.json +1211 -1217
- package/install.ps1 +1 -1
- package/install.sh +1 -1
- package/package.json +2 -2
- package/packages/client/dist/adapters/adapter-registry.js +108 -1
- package/packages/client/dist/adapters/antigravity-adapter.js +77 -2
- package/packages/client/dist/adapters/claude-code-adapter.js +79 -3
- package/packages/client/dist/adapters/codex-adapter.js +80 -2
- package/packages/client/dist/adapters/cursor-adapter.js +115 -4
- package/packages/client/dist/adapters/gemini-adapter.js +71 -2
- package/packages/client/dist/adapters/grok-adapter.js +42 -2
- package/packages/client/dist/adapters/index.js +22 -1
- package/packages/client/dist/adapters/platform-detector.js +212 -1
- package/packages/client/dist/adapters/target-adapter.js +12 -0
- package/packages/client/dist/adapters/vscode-adapter.js +72 -2
- package/packages/client/dist/agent/refresh-stubs.js +417 -2
- package/packages/client/dist/agent/update-agent-yaml.js +102 -1
- package/packages/client/dist/agent/update-description.js +251 -1
- package/packages/client/dist/cache/crypto-utils.js +78 -1
- package/packages/client/dist/cache/encrypted-cache.js +108 -1
- package/packages/client/dist/cache/in-memory-asset-cache.js +73 -1
- package/packages/client/dist/cache/index.js +13 -1
- package/packages/client/dist/cache/protected-pi-boundary.js +44 -1
- package/packages/client/dist/checkpoint/checkpoint-client-reader.js +127 -2
- package/packages/client/dist/checkpoint/index.js +11 -1
- package/packages/client/dist/checkpoint/shared-checkpoint-types.js +32 -1
- package/packages/client/dist/cli.js +358 -5
- package/packages/client/dist/commands/activate.js +394 -8
- package/packages/client/dist/commands/architecture-answers.js +274 -7
- package/packages/client/dist/commands/architecture-memory-terminal.js +253 -4
- package/packages/client/dist/commands/architecture-non-ui-continuation.js +100 -1
- package/packages/client/dist/commands/architecture-root-binding.js +51 -1
- package/packages/client/dist/commands/cache-status.js +112 -2
- package/packages/client/dist/commands/config.js +88 -1
- package/packages/client/dist/commands/doctor.js +635 -2
- package/packages/client/dist/commands/invoke.js +7200 -143
- package/packages/client/dist/commands/legacy-epic-terminal.js +71 -1
- package/packages/client/dist/commands/legacy-story-branch.js +96 -1
- package/packages/client/dist/commands/legacy-story-pr.js +276 -1
- package/packages/client/dist/commands/mutation-qa-checkpoint.js +285 -5
- package/packages/client/dist/commands/mutation-qa-gate.js +54 -1
- package/packages/client/dist/commands/mutation-qa-git.js +41 -1
- package/packages/client/dist/commands/mutation-qa-policy.js +102 -1
- package/packages/client/dist/commands/mutation-qa-run.js +219 -3
- package/packages/client/dist/commands/mutation-qa-verdict.js +149 -1
- package/packages/client/dist/commands/mutation-qa.js +220 -1
- package/packages/client/dist/commands/native-agent.js +136 -2
- package/packages/client/dist/commands/planning-diagnosis.js +43 -1
- package/packages/client/dist/commands/planning-generation.js +53 -1
- package/packages/client/dist/commands/planning-memory.js +40 -1
- package/packages/client/dist/commands/planning-research.js +42 -1
- package/packages/client/dist/commands/private-session.js +75 -1
- package/packages/client/dist/commands/property-qa.js +139 -1
- package/packages/client/dist/commands/qa-control.js +16 -1
- package/packages/client/dist/commands/qa-scan-browser-launch.js +55 -1
- package/packages/client/dist/commands/qa-scan-browser-route.js +28 -1
- package/packages/client/dist/commands/qa-scan-capture.js +663 -5
- package/packages/client/dist/commands/qa-scan-discovery.js +376 -3
- package/packages/client/dist/commands/qa-scan-review.js +826 -5
- package/packages/client/dist/commands/qa-synthetic-backend-capture.js +266 -1
- package/packages/client/dist/commands/qa-synthetic-backend-review.js +297 -1
- package/packages/client/dist/commands/qa-synthetic-backend.js +340 -2
- package/packages/client/dist/commands/qa-synthetic-broker-port.js +85 -1
- package/packages/client/dist/commands/qa-synthetic-browser.js +39 -1
- package/packages/client/dist/commands/refactor-characterization.js +671 -21
- package/packages/client/dist/commands/refactor-commit.js +399 -13
- package/packages/client/dist/commands/refactor-control.js +142 -3
- package/packages/client/dist/commands/refactor-cpp-assertions.js +93 -3
- package/packages/client/dist/commands/refactor-review.js +283 -5
- package/packages/client/dist/commands/refactor-root.js +588 -7
- package/packages/client/dist/commands/refresh-memory.js +156 -3
- package/packages/client/dist/commands/shared-architecture-non-ui.js +24 -1
- package/packages/client/dist/commands/story-checkpoint.js +171 -1
- package/packages/client/dist/config/profile-directory.js +13 -1
- package/packages/client/dist/config/resolver-selection.js +278 -1
- package/packages/client/dist/config/secure-config.js +281 -12
- package/packages/client/dist/config.js +223 -2
- package/packages/client/dist/constants.js +25 -1
- package/packages/client/dist/context/context-collector.js +222 -2
- package/packages/client/dist/context/context-sanitizer.js +145 -1
- package/packages/client/dist/continuity/autonomous-governance.js +285 -1
- package/packages/client/dist/continuity/continuity-client-state-store.js +1587 -1
- package/packages/client/dist/continuity/invoke-hooks.js +129 -1
- package/packages/client/dist/continuity/migrations/001-initial-schema.js +12 -2
- package/packages/client/dist/continuity/migrations/002-processing-output-summary-indexes.js +12 -2
- package/packages/client/dist/continuity/migrations/003-headless-execution-attempts.js +12 -2
- package/packages/client/dist/continuity/migrations/004-outbox-delivery-state.js +12 -2
- package/packages/client/dist/continuity/migrations/005-bounded-headless-queue.js +12 -2
- package/packages/client/dist/continuity/migrations/006-native-agent-dispatches.js +10 -2
- package/packages/client/dist/continuity/native-agent-store.js +69 -1
- package/packages/client/dist/continuity/native-agent-types.js +90 -1
- package/packages/client/dist/continuity/outbox.js +117 -1
- package/packages/client/dist/continuity/runner-bootstrap-policy.js +172 -1
- package/packages/client/dist/continuity/sqlite-store.d.ts +22 -1
- package/packages/client/dist/continuity/sqlite-store.js +2612 -81
- package/packages/client/dist/effects/invoke-effect-gateways.js +62 -1
- package/packages/client/dist/errors/error-messages.js +228 -2
- package/packages/client/dist/errors/frontmatter-diagnostics.js +125 -1
- package/packages/client/dist/evidence/collector.js +347 -1
- package/packages/client/dist/evidence/index.js +1 -1
- package/packages/client/dist/evidence/types.js +2 -0
- package/packages/client/dist/fs/atomic-state-replace.js +152 -1
- package/packages/client/dist/generated/command-registry.generated.js +4076 -1
- package/packages/client/dist/generated/public-projections.generated.js +149 -1
- package/packages/client/dist/git/direct-yolo-c01-retry.js +138 -4
- package/packages/client/dist/git/direct-yolo-checkpoint.js +1234 -4
- package/packages/client/dist/git/epic-operational-state.d.ts +198 -0
- package/packages/client/dist/git/epic-operational-state.js +672 -0
- package/packages/client/dist/git/git-lifecycle-step-ids.js +14 -1
- package/packages/client/dist/git/git-lifecycle-store.d.ts +9 -1
- package/packages/client/dist/git/git-lifecycle-store.js +1981 -9
- package/packages/client/dist/git/legacy-story-branch-checkpoint.js +259 -9
- package/packages/client/dist/git/legacy-story-branch-setup.js +348 -4
- package/packages/client/dist/git/legacy-story-pr.js +3538 -70
- package/packages/client/dist/git/secure-filesystem-boundary.js +182 -5
- package/packages/client/dist/graph-retrieval/pre-command-hook.js +284 -1
- package/packages/client/dist/graph-retrieval/shared-graph-retrieval-contract.js +237 -1
- package/packages/client/dist/i18n/first-run.js +60 -2
- package/packages/client/dist/index.js +47 -1
- package/packages/client/dist/invocation/invoke-input.js +24 -1
- package/packages/client/dist/license/index.js +5 -1
- package/packages/client/dist/license/license-client.js +304 -1
- package/packages/client/dist/machine/fingerprint.js +163 -2
- package/packages/client/dist/machine/index.js +5 -1
- package/packages/client/dist/memory/project-memory-path-scope.js +62 -1
- package/packages/client/dist/memory/project-memory-writer.js +1007 -40
- package/packages/client/dist/memory/shared-project-memory-types.js +253 -2
- package/packages/client/dist/migrations/epic-lifecycle-backfill.d.ts +97 -0
- package/packages/client/dist/migrations/epic-lifecycle-backfill.js +1060 -0
- package/packages/client/dist/migrations/project-identity-capability.js +50 -1
- package/packages/client/dist/migrations/project-identity.js +493 -7
- package/packages/client/dist/migrations/state-json.d.ts +22 -0
- package/packages/client/dist/migrations/state-json.js +393 -4
- package/packages/client/dist/policy/architecture-policy.js +184 -2
- package/packages/client/dist/policy/index.js +7 -1
- package/packages/client/dist/policy/shared-policy-types.js +38 -0
- package/packages/client/dist/policy/subagent-approval-policy.js +55 -1
- package/packages/client/dist/private-execution/clean-baseline.js +279 -2
- package/packages/client/dist/private-execution/codex-executor.js +574 -4
- package/packages/client/dist/private-execution/codex-host-runtime.js +137 -1
- package/packages/client/dist/private-execution/codex-lifecycle-guard.js +97 -1
- package/packages/client/dist/private-execution/codex-scoped-permissions.js +128 -1
- package/packages/client/dist/private-execution/delivery.js +410 -13
- package/packages/client/dist/private-execution/diagnosis-root-review.js +294 -2
- package/packages/client/dist/private-execution/frozen-handoff.js +19 -6
- package/packages/client/dist/private-execution/implementation-validation.js +106 -2
- package/packages/client/dist/private-execution/isolated-admission.js +1432 -23
- package/packages/client/dist/private-execution/isolated-session.js +725 -5
- package/packages/client/dist/private-execution/isolated-workspace.js +122 -1
- package/packages/client/dist/private-execution/pact-consumer-runtime.js +409 -3
- package/packages/client/dist/private-execution/pact-test-source.js +258 -1
- package/packages/client/dist/private-execution/pact-toolchain.js +290 -3
- package/packages/client/dist/private-execution/pact-write-set.js +172 -1
- package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.js +406 -5
- package/packages/client/dist/private-execution/planning-generation-checkpoint.js +462 -5
- package/packages/client/dist/private-execution/planning-memory-checkpoint.js +139 -3
- package/packages/client/dist/private-execution/planning-research-checkpoint.js +325 -4
- package/packages/client/dist/private-execution/private-report-store.js +42 -1
- package/packages/client/dist/private-execution/property-test-candidate.js +103 -1
- package/packages/client/dist/private-execution/property-test-choices.js +147 -3
- package/packages/client/dist/private-execution/property-test-plan.js +271 -7
- package/packages/client/dist/private-execution/property-test-review.js +258 -4
- package/packages/client/dist/private-execution/property-test-runtime.js +372 -9
- package/packages/client/dist/private-execution/property-test-source.js +139 -1
- package/packages/client/dist/private-execution/root-checkpoint.js +80 -1
- package/packages/client/dist/private-execution/root-memory-git-evidence.js +135 -3
- package/packages/client/dist/private-execution/root-memory-recovery.js +93 -1
- package/packages/client/dist/private-execution/root-memory-request.js +29 -1
- package/packages/client/dist/private-execution/root-memory-scope.js +178 -1
- package/packages/client/dist/private-execution/root-memory-writer.js +102 -1
- package/packages/client/dist/private-execution/session-lease.js +63 -1
- package/packages/client/dist/private-execution/shared-private-admission-types.js +50 -1
- package/packages/client/dist/private-execution/shared-project-validation.js +66 -1
- package/packages/client/dist/private-execution/shared-root-memory-types.js +61 -1
- package/packages/client/dist/private-execution/ux-source-validation.js +372 -1
- package/packages/client/dist/private-execution/ux-write-set.js +191 -2
- package/packages/client/dist/registry/registry-reconciliation.js +234 -1
- package/packages/client/dist/resilience/circuit-breaker.js +170 -1
- package/packages/client/dist/resilience/degradation-manager.js +164 -1
- package/packages/client/dist/resilience/freshness-indicator.js +100 -1
- package/packages/client/dist/resilience/index.js +8 -1
- package/packages/client/dist/resilience/recovery-detector.js +74 -1
- package/packages/client/dist/resolvers/asset-resolver.js +13 -0
- package/packages/client/dist/resolvers/local-resolver.js +255 -8
- package/packages/client/dist/resolvers/remote-resolver.js +233 -1
- package/packages/client/dist/runner/binary.js +404 -1
- package/packages/client/dist/runner/cli.js +1571 -17
- package/packages/client/dist/runner/headless/adapters.js +49 -1
- package/packages/client/dist/runner/headless/claude-code-adapter.js +79 -1
- package/packages/client/dist/runner/headless/continuous-story-workspace.js +1628 -11
- package/packages/client/dist/runner/headless/epic-git-reconciliation-inventory.js +69 -1
- package/packages/client/dist/runner/headless/epic-merge-candidate-qa.js +110 -2
- package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.js +1236 -8
- package/packages/client/dist/runner/headless/epic-terminal-git-runner.js +318 -2
- package/packages/client/dist/runner/headless/fake-adapter.js +62 -1
- package/packages/client/dist/runner/headless/managed-profile.js +132 -1
- package/packages/client/dist/runner/headless/opencode-adapter.js +145 -2
- package/packages/client/dist/runner/headless/prepared-story-bundle.js +43 -1
- package/packages/client/dist/runner/headless/resolver.js +231 -1
- package/packages/client/dist/runner/headless/run-yolo.js +885 -1
- package/packages/client/dist/runner/headless/run-yoloop.js +2574 -2
- package/packages/client/dist/runner/headless/types.js +574 -2
- package/packages/client/dist/runner/local-console.js +396 -13
- package/packages/client/dist/runner/portal-sync-worker.js +1487 -1
- package/packages/client/dist/runner/project-identity.js +106 -1
- package/packages/client/dist/runner/scheduler.js +995 -7
- package/packages/client/dist/runner-cli.js +18 -2
- package/packages/client/dist/state/invocation-shape.js +13 -1
- package/packages/client/dist/state/project-state-snapshot.d.ts +8 -0
- package/packages/client/dist/state/project-state-snapshot.js +1731 -1
- package/packages/client/dist/state/state-json-repair.js +785 -3
- package/packages/client/dist/state/structural-dag-projection.js +118 -1
- package/packages/client/dist/telemetry/index.js +5 -1
- package/packages/client/dist/telemetry/offline-queue.js +131 -1
- package/packages/client/dist/tier/index.js +5 -1
- package/packages/client/dist/tier/tier-aware-client.js +405 -1
- package/packages/client/dist/types/index.js +38 -1
- package/packages/client/dist/version.js +27 -1
- package/packages/client/dist/yolo/change-evidence-collector.js +126 -1
- package/packages/client/dist/yolo/invoke-envelope-capability.js +62 -1
- package/packages/client/dist/yolo/spec-envelope-collector.js +184 -5
- package/packages/client/dist/yoloop/discovery-hook.js +300 -2
- package/packages/client/dist/yoloop/index.js +8 -1
- package/packages/client/dist/yoloop/invoke-hooks.js +669 -12
- package/packages/client/dist/yoloop/shared-discover-epics.js +1007 -1
- package/packages/client/dist/yoloop/shared-yoloop-types.d.ts +65 -1
- package/packages/client/dist/yoloop/shared-yoloop-types.js +33 -1
- package/packages/client/dist/yoloop/target-normalization.js +180 -1
- package/packages/client/dist/yoloop/yoloop-client-state-store.d.ts +8 -0
- package/packages/client/dist/yoloop/yoloop-client-state-store.js +1920 -1
- package/packages/shared/dist/yolo/spec-envelope.js +3 -6
- package/targets-stubs/antigravity/gemini.md +1 -1
- package/targets-stubs/antigravity/skill/SKILL.md +1 -1
- package/targets-stubs/claude-code/neocortex-root.agent.yaml +1 -1
- package/targets-stubs/claude-code/neocortex-root.md +2 -2
- package/targets-stubs/claude-code/neocortex.agent.yaml +1 -1
- package/targets-stubs/claude-code/neocortex.md +2 -2
- package/targets-stubs/codex/AGENTS.md +1 -1
- package/targets-stubs/cursor/agent.md +2 -2
- package/targets-stubs/gemini-cli/agent.md +2 -2
- package/targets-stubs/opencode/neocortex-root.md +1 -1
- package/targets-stubs/vscode/neocortex.agent.md +2 -2
|
@@ -1,2 +1,145 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @license FSL-1.1
|
|
3
|
+
* Copyright (c) 2026 OrNexus AI
|
|
4
|
+
*
|
|
5
|
+
* P190.04 -- trusted OpenCode headless adapter interface.
|
|
6
|
+
*/
|
|
7
|
+
import { checkTrustedHeadlessRuntimeBinary } from '../binary.js';
|
|
8
|
+
import { HEADLESS_REASON_CODES, adapterAvailabilityFailure, adapterAvailabilitySuccess, createRejectedExecutionResult, createUnavailableExecutionResult, hashPublicValue, normalizeHeadlessCommandResult, redaction, runHeadlessCommand, validateHeadlessAdapterExecutionInput, } from './types.js';
|
|
9
|
+
import { governedPreflightFailureResult, preflightManagedHeadlessProfile, withGovernedHeadlessEvidence, } from './managed-profile.js';
|
|
10
|
+
const OPENCODE_ADAPTER_ID = 'opencode';
|
|
11
|
+
const OPENCODE_COMMAND = 'opencode';
|
|
12
|
+
const OPENCODE_AGENT_PROFILE = 'neocortex';
|
|
13
|
+
const VERSION_EVIDENCE_MAX_CHARS = 2_000;
|
|
14
|
+
const VERSION_EVIDENCE_MAX_BYTES = 2_000;
|
|
15
|
+
const UNSAFE_VERSION_EVIDENCE_PATTERN = /(https?:\/\/\S+|(?:^|\s)(?:\/(?:home|Users|media|mnt|tmp|var|etc|private)\/\S+|[A-Za-z]:\\\S+)|ghp_[A-Za-z0-9_]+|sk-[A-Za-z0-9_-]+|-----BEGIN [A-Z ]*PRIVATE KEY-----|authorization\s*:|password\s*=|token\s*=|api[_-]?key\s*=|license[_-]?key\s*=|raw[_-]?(?:logs?)\s*[:=]|transcript|stack\s*trace|stderr:|stdout:|system prompt|workflow body|step body|PROTECTED_|PRIVATE_INTERNALS|CUSTOMER_PII|\bPII\b|VENDOR_CORPUS|\bPRIVATE\b)/i;
|
|
16
|
+
const CLAUDE_CODE_PRODUCT_PATTERN = /\b(?:Claude\s+Code|claude-code|@anthropic-ai\/claude-code)\b/i;
|
|
17
|
+
const VERSION_SEMVER_PATTERN = /\bv?\d+\.\d+\.\d+(?:[-+][0-9A-Za-z][0-9A-Za-z.-]*)?\b/;
|
|
18
|
+
export function createOpenCodeHeadlessAdapter() {
|
|
19
|
+
return {
|
|
20
|
+
id: OPENCODE_ADAPTER_ID,
|
|
21
|
+
displayName: 'OpenCode Headless Adapter',
|
|
22
|
+
async checkAvailability(options = {}) {
|
|
23
|
+
return checkRuntimeAvailability(OPENCODE_ADAPTER_ID, OPENCODE_COMMAND, options, {
|
|
24
|
+
realpathBasenamePolicy: 'opencode-npm-native',
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
buildInvocation(input) {
|
|
28
|
+
const validation = validateHeadlessAdapterExecutionInput(input, OPENCODE_ADAPTER_ID);
|
|
29
|
+
if (!validation.ok)
|
|
30
|
+
return validation;
|
|
31
|
+
return {
|
|
32
|
+
ok: true,
|
|
33
|
+
invocation: {
|
|
34
|
+
adapterId: OPENCODE_ADAPTER_ID,
|
|
35
|
+
commandName: OPENCODE_COMMAND,
|
|
36
|
+
args: buildOpenCodeArgs(validation.prompt, validation.input.modelId),
|
|
37
|
+
promptHash: validation.promptHash,
|
|
38
|
+
...(validation.input.modelId ? { modelId: validation.input.modelId } : {}),
|
|
39
|
+
timeoutMs: validation.input.timeoutMs ?? 10 * 60 * 1000,
|
|
40
|
+
publicSafe: true,
|
|
41
|
+
},
|
|
42
|
+
publicSafe: true,
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
async execute(input, options = {}) {
|
|
46
|
+
const validation = validateHeadlessAdapterExecutionInput(input, OPENCODE_ADAPTER_ID);
|
|
47
|
+
if (!validation.ok)
|
|
48
|
+
return createRejectedExecutionResult(OPENCODE_ADAPTER_ID, OPENCODE_ADAPTER_ID, validation);
|
|
49
|
+
const preflight = preflightManagedHeadlessProfile(OPENCODE_ADAPTER_ID, options);
|
|
50
|
+
if (!preflight.ok)
|
|
51
|
+
return governedPreflightFailureResult(OPENCODE_ADAPTER_ID, validation.input, preflight);
|
|
52
|
+
if (options.signal?.aborted) {
|
|
53
|
+
return withGovernedHeadlessEvidence(normalizeHeadlessCommandResult(OPENCODE_ADAPTER_ID, validation.input, {
|
|
54
|
+
exitCode: null, signal: 'SIGTERM', timedOut: false, cancelled: true, durationMs: 0,
|
|
55
|
+
stdout: '', stderr: '', stdoutBytes: 0, stderrBytes: 0,
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
const availability = await this.checkAvailability(options);
|
|
59
|
+
if (!availability.ok)
|
|
60
|
+
return withGovernedHeadlessEvidence(createUnavailableExecutionResult(OPENCODE_ADAPTER_ID, validation.input, availability));
|
|
61
|
+
const invocation = this.buildInvocation(validation.input);
|
|
62
|
+
if (!invocation.ok)
|
|
63
|
+
return createRejectedExecutionResult(OPENCODE_ADAPTER_ID, OPENCODE_ADAPTER_ID, invocation);
|
|
64
|
+
const runner = options.commandRunner ?? runHeadlessCommand;
|
|
65
|
+
const result = await runner(availability.executablePath ?? OPENCODE_COMMAND, invocation.invocation.args, {
|
|
66
|
+
cwd: options.cwd,
|
|
67
|
+
env: options.env,
|
|
68
|
+
timeoutMs: invocation.invocation.timeoutMs,
|
|
69
|
+
maxOutputBytes: options.maxOutputBytes,
|
|
70
|
+
signal: options.signal,
|
|
71
|
+
...(validation.input.receipt?.jobId ? { localConsole: { projectRoot: options.cwd, jobId: validation.input.receipt.jobId, attemptId: validation.input.receipt.attemptId, executionId: validation.input.receipt.executionId, publicSafe: true } } : {}),
|
|
72
|
+
});
|
|
73
|
+
return withGovernedHeadlessEvidence(normalizeHeadlessCommandResult(OPENCODE_ADAPTER_ID, validation.input, result));
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export async function checkRuntimeAvailability(adapterId, commandName, options, policy = {}) {
|
|
78
|
+
const trust = checkTrustedHeadlessRuntimeBinary({
|
|
79
|
+
commandName,
|
|
80
|
+
env: options.env,
|
|
81
|
+
platform: options.platform,
|
|
82
|
+
commandLocator: options.commandLocator,
|
|
83
|
+
realpathBasenamePolicy: policy.realpathBasenamePolicy,
|
|
84
|
+
});
|
|
85
|
+
if (!trust.ok) {
|
|
86
|
+
return adapterAvailabilityFailure(adapterId, commandName, trust.reasonCode === HEADLESS_REASON_CODES.ADAPTER_UNAVAILABLE
|
|
87
|
+
? HEADLESS_REASON_CODES.ADAPTER_UNAVAILABLE
|
|
88
|
+
: HEADLESS_REASON_CODES.RUNTIME_UNTRUSTED, trust.publicSummary, trust.redactionSummary);
|
|
89
|
+
}
|
|
90
|
+
const runner = options.versionRunner ?? options.commandRunner ?? runHeadlessCommand;
|
|
91
|
+
const version = await runner(trust.executablePath, ['--version'], {
|
|
92
|
+
env: options.env,
|
|
93
|
+
timeoutMs: 5_000,
|
|
94
|
+
maxOutputBytes: 2_000,
|
|
95
|
+
});
|
|
96
|
+
const evidence = validateRuntimeVersionEvidence(version, policy.versionEvidence ?? 'generic-public');
|
|
97
|
+
if (!evidence.ok) {
|
|
98
|
+
return adapterAvailabilityFailure(adapterId, commandName, HEADLESS_REASON_CODES.ADAPTER_UNAVAILABLE, evidence.publicSummary, evidence.redactionSummary);
|
|
99
|
+
}
|
|
100
|
+
return adapterAvailabilitySuccess(adapterId, commandName, trustedAvailabilitySummary(commandName, policy.versionEvidence), {
|
|
101
|
+
executablePath: trust.executablePath,
|
|
102
|
+
versionText: evidence.versionText,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function validateRuntimeVersionEvidence(version, requirement) {
|
|
106
|
+
const versionText = normalizeVersionEvidenceText(`${version.stdout}\n${version.stderr}`.trim());
|
|
107
|
+
const redactionSummary = versionText
|
|
108
|
+
? [redaction('runtimeVersion', 'raw_log', hashPublicValue(versionText))]
|
|
109
|
+
: [redaction('runtimeVersion', 'missing', 'value-denied')];
|
|
110
|
+
if (version.timedOut
|
|
111
|
+
|| version.exitCode !== 0
|
|
112
|
+
|| versionText.length === 0
|
|
113
|
+
|| versionText.length > VERSION_EVIDENCE_MAX_CHARS
|
|
114
|
+
|| version.stdoutBytes + version.stderrBytes > VERSION_EVIDENCE_MAX_BYTES
|
|
115
|
+
|| UNSAFE_VERSION_EVIDENCE_PATTERN.test(versionText)) {
|
|
116
|
+
return {
|
|
117
|
+
ok: false,
|
|
118
|
+
publicSummary: 'Headless runtime version check did not return a bounded public result.',
|
|
119
|
+
redactionSummary,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
if (requirement === 'claude-code' && (!CLAUDE_CODE_PRODUCT_PATTERN.test(versionText) || !VERSION_SEMVER_PATTERN.test(versionText))) {
|
|
123
|
+
return {
|
|
124
|
+
ok: false,
|
|
125
|
+
publicSummary: 'Headless runtime version check did not return bounded Claude Code product/version evidence.',
|
|
126
|
+
redactionSummary,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
return { ok: true, versionText };
|
|
130
|
+
}
|
|
131
|
+
function normalizeVersionEvidenceText(value) {
|
|
132
|
+
return value.replace(/\s+/g, ' ').trim();
|
|
133
|
+
}
|
|
134
|
+
function trustedAvailabilitySummary(commandName, requirement) {
|
|
135
|
+
if (requirement === 'claude-code')
|
|
136
|
+
return `Trusted ${commandName} runtime is available with bounded Claude Code version evidence.`;
|
|
137
|
+
return `Trusted ${commandName} runtime is available.`;
|
|
138
|
+
}
|
|
139
|
+
function buildOpenCodeArgs(prompt, modelId) {
|
|
140
|
+
const args = ['run', '--standalone', '--agent', OPENCODE_AGENT_PROFILE, '--auto'];
|
|
141
|
+
if (modelId)
|
|
142
|
+
args.push('--model', modelId);
|
|
143
|
+
args.push('--', prompt);
|
|
144
|
+
return args;
|
|
145
|
+
}
|
|
@@ -1 +1,43 @@
|
|
|
1
|
-
|
|
1
|
+
/** P208.05 -- client enforcement for phased plans and branchless bundles. */
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { validateYoloopPreparationBundle } from '../../../../shared/dist/yoloop/wave-decision-receipt.js';
|
|
4
|
+
export function validatePhasedYoloopPlan(plan) {
|
|
5
|
+
const errors = [];
|
|
6
|
+
const phases = Array.isArray(plan.phases) ? plan.phases.filter(isRecord) : [];
|
|
7
|
+
const budgets = isRecord(plan.budgets) ? plan.budgets : {};
|
|
8
|
+
if (plan.version !== 2 || !isHash(plan.graphRevision))
|
|
9
|
+
errors.push('phased-plan-invalid');
|
|
10
|
+
if (budgets.maxWriteConcurrency !== 1)
|
|
11
|
+
errors.push('writer-concurrency-invalid');
|
|
12
|
+
for (const phase of phases) {
|
|
13
|
+
if (!Number.isInteger(phase.maxConcurrency) || Number(phase.maxConcurrency) < 1)
|
|
14
|
+
errors.push('phase-concurrency-invalid');
|
|
15
|
+
const mutatesEpicCheckout = phase.mutatesEpicCheckout === true || phase.mutatesEpicWorktree === true;
|
|
16
|
+
if (mutatesEpicCheckout && (phase.maxConcurrency !== 1 || !['epic-writer-lease', 'commit-range'].includes(String(phase.isolation))))
|
|
17
|
+
errors.push('mutating-phase-not-serialized');
|
|
18
|
+
}
|
|
19
|
+
const required = ['read-only-analysis', 'isolated-build-test', 'patch-preparation', 'single-writer-integration', 'story-checkpoint-review'];
|
|
20
|
+
if (required.some((kind) => !phases.some((phase) => phase.kind === kind)))
|
|
21
|
+
errors.push('phase-missing');
|
|
22
|
+
const receiptIds = Array.isArray(plan.decisionReceiptIds) ? plan.decisionReceiptIds : [];
|
|
23
|
+
if (receiptIds.length === 0 || receiptIds.some((id) => !isHash(id)))
|
|
24
|
+
errors.push('decision-receipt-invalid');
|
|
25
|
+
const preparationConcurrency = Math.max(1, ...phases.filter((phase) => phase.mutatesEpicCheckout !== true && phase.mutatesEpicWorktree !== true).map((phase) => Number(phase.maxConcurrency) || 1));
|
|
26
|
+
return { ok: errors.length === 0, preparationConcurrency, childExecutionConcurrency: 1, reasonCodes: [...new Set(errors)].sort() };
|
|
27
|
+
}
|
|
28
|
+
export function admitPreparedStoryBundle(input) {
|
|
29
|
+
const errors = [...validateYoloopPreparationBundle(input.bundle, input.expected)];
|
|
30
|
+
if (input.bundle.claimRevision !== input.expected.claimRevision)
|
|
31
|
+
errors.push('bundle-claims-stale');
|
|
32
|
+
if (!sameStrings(input.bundle.authorizedWriteSet, input.expected.authorizedWriteSet ?? []))
|
|
33
|
+
errors.push('bundle-write-set-stale');
|
|
34
|
+
const digest = createHash('sha256').update(input.payload).digest('hex');
|
|
35
|
+
if (digest !== input.bundle.bundleDigest)
|
|
36
|
+
errors.push('bundle-payload-digest-mismatch');
|
|
37
|
+
if (!input.writerLease || input.writerLease.ownerStoryId !== input.bundle.storyId || input.writerLease.expiresAt <= input.expected.nowIso)
|
|
38
|
+
errors.push('bundle-writer-lease-missing');
|
|
39
|
+
return [...new Set(errors)].sort();
|
|
40
|
+
}
|
|
41
|
+
function isRecord(value) { return Boolean(value) && typeof value === 'object' && !Array.isArray(value); }
|
|
42
|
+
function isHash(value) { return typeof value === 'string' && /^[a-f0-9]{40,64}$/.test(value); }
|
|
43
|
+
function sameStrings(left, right) { return left.length === right.length && left.every((value, index) => value === right[index]); }
|
|
@@ -1 +1,231 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @license FSL-1.1
|
|
3
|
+
* Copyright (c) 2026 OrNexus AI
|
|
4
|
+
*
|
|
5
|
+
* P190.04 -- deterministic headless runtime/model resolver.
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
8
|
+
import { homedir } from 'node:os';
|
|
9
|
+
import { isAbsolute, join, resolve } from 'node:path';
|
|
10
|
+
import { HEADLESS_REASON_CODES, boundPublicSummary, isHeadlessAdapterId, isSafeHeadlessModelId, redaction, } from './types.js';
|
|
11
|
+
const DEFAULT_FALLBACK_HINT = Object.freeze({
|
|
12
|
+
runtimeId: 'opencode',
|
|
13
|
+
source: 'fallback',
|
|
14
|
+
publicSafe: true,
|
|
15
|
+
});
|
|
16
|
+
const DEFAULT_CONFIG_RELATIVE_PATH = '.neocortex/headless-runtime.json';
|
|
17
|
+
const DEFAULT_CONFIG_MAX_BYTES = 8 * 1024;
|
|
18
|
+
const RUNTIME_HINT_ALLOWED_KEYS = new Set(['runtimeId', 'modelId', 'source', 'reasonCode', 'publicSafe']);
|
|
19
|
+
const UNSAFE_HINT_KEY_PATTERN = /(raw|prompt|private|secret|token|password|authorization|api[_-]?key|license|argv|args|executable|binary|shell|cwd|command|path|url|vendor|stdout|stderr|transcript|workflow|step|customer|pii)/i;
|
|
20
|
+
export function resolveHeadlessRuntime(input = {}) {
|
|
21
|
+
const registry = input.registry ?? DEFAULT_REGISTRY_LIKE;
|
|
22
|
+
const candidates = buildCandidateList(input);
|
|
23
|
+
const normalized = [];
|
|
24
|
+
const redactions = [];
|
|
25
|
+
for (const candidate of candidates) {
|
|
26
|
+
if (candidate.value === undefined)
|
|
27
|
+
continue;
|
|
28
|
+
const result = normalizeCandidate(candidate, registry);
|
|
29
|
+
if (!result.ok)
|
|
30
|
+
return result.resolution;
|
|
31
|
+
redactions.push(...result.candidate.redactions);
|
|
32
|
+
normalized.push(result.candidate);
|
|
33
|
+
}
|
|
34
|
+
const runtimeCandidate = normalized.find((candidate) => candidate.runtimeId);
|
|
35
|
+
const modelCandidate = normalized.find((candidate) => candidate.modelId);
|
|
36
|
+
if (!runtimeCandidate?.runtimeId) {
|
|
37
|
+
return {
|
|
38
|
+
ok: false,
|
|
39
|
+
runtimeSource: 'unresolved',
|
|
40
|
+
reasonCode: HEADLESS_REASON_CODES.RUNTIME_UNRESOLVED,
|
|
41
|
+
reasonCodes: [HEADLESS_REASON_CODES.RUNTIME_UNRESOLVED],
|
|
42
|
+
publicSummary: 'Headless runtime could not be resolved from explicit, origin, default or fallback sources.',
|
|
43
|
+
redactionSummary: redactions,
|
|
44
|
+
publicSafe: true,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const reasonCode = sourceReasonCode(runtimeCandidate.source);
|
|
48
|
+
return {
|
|
49
|
+
ok: true,
|
|
50
|
+
runtimeId: runtimeCandidate.runtimeId,
|
|
51
|
+
...(modelCandidate?.modelId ? { modelId: modelCandidate.modelId } : {}),
|
|
52
|
+
runtimeSource: runtimeCandidate.source,
|
|
53
|
+
...(modelCandidate?.source ? { modelSource: modelCandidate.source } : {}),
|
|
54
|
+
reasonCode,
|
|
55
|
+
reasonCodes: [reasonCode],
|
|
56
|
+
publicSummary: `Resolved headless runtime from ${runtimeCandidate.source} source.`,
|
|
57
|
+
redactionSummary: redactions,
|
|
58
|
+
publicSafe: true,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export function loadHeadlessRuntimeDefaults(options = {}) {
|
|
62
|
+
const maxBytes = options.maxBytes ?? DEFAULT_CONFIG_MAX_BYTES;
|
|
63
|
+
const candidates = boundedDefaultPaths(options);
|
|
64
|
+
for (const candidate of candidates) {
|
|
65
|
+
if (!existsSync(candidate.path))
|
|
66
|
+
continue;
|
|
67
|
+
try {
|
|
68
|
+
const stat = statSync(candidate.path);
|
|
69
|
+
if (!stat.isFile() || stat.size > maxBytes) {
|
|
70
|
+
return defaultsFailure('Default headless runtime config was not a bounded file.', 'defaultConfig', 'unbounded_file');
|
|
71
|
+
}
|
|
72
|
+
const parsed = JSON.parse(readFileSync(candidate.path, 'utf8'));
|
|
73
|
+
const defaults = extractDefaults(parsed);
|
|
74
|
+
if (!defaults)
|
|
75
|
+
return defaultsFailure('Default headless runtime config did not contain a public object.', 'defaultConfig', 'unsafe_key');
|
|
76
|
+
return {
|
|
77
|
+
ok: true,
|
|
78
|
+
defaults: { ...defaults, source: 'default', publicSafe: true },
|
|
79
|
+
source: candidate.kind,
|
|
80
|
+
reasonCodes: [HEADLESS_REASON_CODES.RUNTIME_DEFAULT],
|
|
81
|
+
publicSummary: `Loaded ${candidate.kind} headless runtime defaults.`,
|
|
82
|
+
publicSafe: true,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return defaultsFailure('Default headless runtime config could not be parsed safely.', 'defaultConfig', 'unsafe_key');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
ok: true,
|
|
91
|
+
defaults: undefined,
|
|
92
|
+
reasonCodes: [],
|
|
93
|
+
publicSummary: 'No headless runtime defaults were found; resolver will continue without guessing.',
|
|
94
|
+
publicSafe: true,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function buildCandidateList(input) {
|
|
98
|
+
const candidates = [
|
|
99
|
+
{ source: 'explicit', value: input.explicit },
|
|
100
|
+
{ source: 'origin', value: input.origin },
|
|
101
|
+
];
|
|
102
|
+
for (const value of normalizeDefaults(input))
|
|
103
|
+
candidates.push({ source: 'default', value });
|
|
104
|
+
if (input.projectDefault !== undefined)
|
|
105
|
+
candidates.push({ source: 'default', value: input.projectDefault });
|
|
106
|
+
if (input.userDefault !== undefined)
|
|
107
|
+
candidates.push({ source: 'default', value: input.userDefault });
|
|
108
|
+
if (input.fallback !== false)
|
|
109
|
+
candidates.push({ source: 'fallback', value: input.fallback ?? DEFAULT_FALLBACK_HINT });
|
|
110
|
+
return candidates;
|
|
111
|
+
}
|
|
112
|
+
function normalizeDefaults(input) {
|
|
113
|
+
if (input.defaults === undefined)
|
|
114
|
+
return [];
|
|
115
|
+
return Array.isArray(input.defaults) ? input.defaults : [input.defaults];
|
|
116
|
+
}
|
|
117
|
+
function normalizeCandidate(candidate, registry) {
|
|
118
|
+
const value = unwrapDefaultLookup(candidate.value);
|
|
119
|
+
if (value === undefined)
|
|
120
|
+
return { ok: true, candidate: { source: candidate.source, redactions: [] } };
|
|
121
|
+
if (!isRecord(value)) {
|
|
122
|
+
return candidateFailure(HEADLESS_REASON_CODES.RUNTIME_UNTRUSTED, 'Headless runtime hint must be a public object.', candidate.source, [redaction('runtime', 'unsafe_key', 'value-denied')]);
|
|
123
|
+
}
|
|
124
|
+
const redactions = [];
|
|
125
|
+
for (const key of Object.keys(value)) {
|
|
126
|
+
if (!RUNTIME_HINT_ALLOWED_KEYS.has(key) || UNSAFE_HINT_KEY_PATTERN.test(key)) {
|
|
127
|
+
redactions.push(redaction(`runtime.${key}`, 'unsafe_key', 'key-denied'));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (value.publicSafe !== true)
|
|
131
|
+
redactions.push(redaction('runtime.publicSafe', 'unsafe_key', 'value-denied'));
|
|
132
|
+
const source = typeof value.source === 'string' ? value.source : candidate.source;
|
|
133
|
+
if (source !== candidate.source)
|
|
134
|
+
redactions.push(redaction('runtime.source', 'unsafe_key', 'value-denied'));
|
|
135
|
+
const runtimeText = typeof value.runtimeId === 'string' ? value.runtimeId : undefined;
|
|
136
|
+
const modelText = typeof value.modelId === 'string' ? value.modelId : undefined;
|
|
137
|
+
let runtimeId;
|
|
138
|
+
if (runtimeText !== undefined) {
|
|
139
|
+
if (!isSafeRuntimeId(runtimeText) || !isHeadlessAdapterId(runtimeText) || !registry.hasAdapter(runtimeText)) {
|
|
140
|
+
redactions.push(redaction('runtime.runtimeId', 'unsafe_key', 'value-denied'));
|
|
141
|
+
return candidateFailure(HEADLESS_REASON_CODES.RUNTIME_UNTRUSTED, 'Headless runtime was not trusted or allowlisted.', candidate.source, redactions);
|
|
142
|
+
}
|
|
143
|
+
runtimeId = runtimeText;
|
|
144
|
+
}
|
|
145
|
+
let modelId;
|
|
146
|
+
if (modelText !== undefined) {
|
|
147
|
+
if (!isSafeHeadlessModelId(modelText)) {
|
|
148
|
+
redactions.push(redaction('runtime.modelId', 'unsafe_key', 'value-denied'));
|
|
149
|
+
return candidateFailure(HEADLESS_REASON_CODES.MODEL_REJECTED, 'Headless model id failed bounded public-safety validation.', candidate.source, redactions);
|
|
150
|
+
}
|
|
151
|
+
modelId = modelText;
|
|
152
|
+
}
|
|
153
|
+
if (redactions.length > 0) {
|
|
154
|
+
return candidateFailure(HEADLESS_REASON_CODES.RUNTIME_UNTRUSTED, 'Headless runtime hint failed public-safety validation.', candidate.source, redactions);
|
|
155
|
+
}
|
|
156
|
+
return { ok: true, candidate: { source: candidate.source, ...(runtimeId ? { runtimeId } : {}), ...(modelId ? { modelId } : {}), redactions: [] } };
|
|
157
|
+
}
|
|
158
|
+
function unwrapDefaultLookup(value) {
|
|
159
|
+
if (isRecord(value) && value.ok === true && 'defaults' in value)
|
|
160
|
+
return value.defaults;
|
|
161
|
+
return value;
|
|
162
|
+
}
|
|
163
|
+
function candidateFailure(reasonCode, publicSummary, source, redactions) {
|
|
164
|
+
return {
|
|
165
|
+
ok: false,
|
|
166
|
+
resolution: {
|
|
167
|
+
ok: false,
|
|
168
|
+
runtimeSource: 'unresolved',
|
|
169
|
+
reasonCode,
|
|
170
|
+
reasonCodes: [reasonCode],
|
|
171
|
+
publicSummary: boundPublicSummary(`${publicSummary} Source=${source}.`),
|
|
172
|
+
redactionSummary: redactions,
|
|
173
|
+
publicSafe: true,
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function sourceReasonCode(source) {
|
|
178
|
+
switch (source) {
|
|
179
|
+
case 'explicit': return HEADLESS_REASON_CODES.RUNTIME_EXPLICIT;
|
|
180
|
+
case 'origin': return HEADLESS_REASON_CODES.RUNTIME_ORIGIN;
|
|
181
|
+
case 'default': return HEADLESS_REASON_CODES.RUNTIME_DEFAULT;
|
|
182
|
+
case 'fallback': return HEADLESS_REASON_CODES.RUNTIME_FALLBACK;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function boundedDefaultPaths(options) {
|
|
186
|
+
const paths = [];
|
|
187
|
+
const projectRoot = normalizeAbsoluteDirectory(options.projectRoot);
|
|
188
|
+
if (projectRoot)
|
|
189
|
+
paths.push({ kind: 'project', path: join(projectRoot, DEFAULT_CONFIG_RELATIVE_PATH) });
|
|
190
|
+
const home = normalizeAbsoluteDirectory(options.homeDir ?? homedir());
|
|
191
|
+
if (home)
|
|
192
|
+
paths.push({ kind: 'user', path: join(home, DEFAULT_CONFIG_RELATIVE_PATH) });
|
|
193
|
+
return paths;
|
|
194
|
+
}
|
|
195
|
+
function normalizeAbsoluteDirectory(value) {
|
|
196
|
+
if (!value || /[\r\n\0]/.test(value))
|
|
197
|
+
return undefined;
|
|
198
|
+
const absolute = isAbsolute(value) ? value : resolve(value);
|
|
199
|
+
return isAbsolute(absolute) ? absolute : undefined;
|
|
200
|
+
}
|
|
201
|
+
function extractDefaults(parsed) {
|
|
202
|
+
if (!isRecord(parsed))
|
|
203
|
+
return undefined;
|
|
204
|
+
const candidate = isRecord(parsed.headless) ? parsed.headless : parsed;
|
|
205
|
+
return {
|
|
206
|
+
...(typeof candidate.runtimeId === 'string' ? { runtimeId: candidate.runtimeId } : {}),
|
|
207
|
+
...(typeof candidate.modelId === 'string' ? { modelId: candidate.modelId } : {}),
|
|
208
|
+
publicSafe: true,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function defaultsFailure(publicSummary, field, reason) {
|
|
212
|
+
return {
|
|
213
|
+
ok: false,
|
|
214
|
+
reasonCode: HEADLESS_REASON_CODES.RUNTIME_UNTRUSTED,
|
|
215
|
+
reasonCodes: [HEADLESS_REASON_CODES.RUNTIME_UNTRUSTED],
|
|
216
|
+
publicSummary,
|
|
217
|
+
redactionSummary: [redaction(field, reason, 'value-denied')],
|
|
218
|
+
publicSafe: true,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
function isSafeRuntimeId(value) {
|
|
222
|
+
return /^[A-Za-z0-9][A-Za-z0-9._:-]{0,79}$/.test(value) && !/[\/\s;&|`$<>]/.test(value);
|
|
223
|
+
}
|
|
224
|
+
function isRecord(value) {
|
|
225
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
226
|
+
}
|
|
227
|
+
const DEFAULT_REGISTRY_LIKE = Object.freeze({
|
|
228
|
+
hasAdapter(id) {
|
|
229
|
+
return isHeadlessAdapterId(id);
|
|
230
|
+
},
|
|
231
|
+
});
|