sneakoscope 6.1.0 → 6.1.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 +28 -11
- package/crates/sks-core/Cargo.lock +1 -1
- package/crates/sks-core/Cargo.toml +1 -1
- package/dist/bin/fast-inline.js +18 -9
- package/dist/bin/sks-dispatch.js +2 -2
- package/dist/cli/args.js +2 -0
- package/dist/cli/command-manifest-lite.js +2 -3
- package/dist/cli/command-registry.js +3 -4
- package/dist/cli/help-fast.js +1 -1
- package/dist/cli/install-helpers.js +108 -303
- package/dist/cli/install-tool-helpers.js +287 -0
- package/dist/cli/router.js +40 -4
- package/dist/commands/codex-lb.js +51 -20
- package/dist/commands/codex.js +39 -1
- package/dist/commands/doctor.js +242 -20
- package/dist/commands/tmux.js +5 -1
- package/dist/commands/zellij-monitor-pane.js +2 -0
- package/dist/commands/zellij-viewport-pane.js +3 -1
- package/dist/commands/zellij.js +1 -1
- package/dist/config/skills-manifest.json +59 -59
- package/dist/core/agent-bridge/agent-manifest.js +48 -0
- package/dist/core/agents/agent-command-surface.js +2 -1
- package/dist/core/agents/agent-effort-policy.js +30 -38
- package/dist/core/agents/agent-plan.js +100 -21
- package/dist/core/agents/agent-role-config.js +43 -46
- package/dist/core/agents/agent-runner-codex-exec.js +16 -3
- package/dist/core/agents/agent-schema.js +3 -2
- package/dist/core/agents/native-cli-session-swarm.js +1 -1
- package/dist/core/agents/zellij-right-lane-cockpit.js +2 -2
- package/dist/core/codex/agent-config-file-repair.js +94 -193
- package/dist/core/codex/codex-cli-update.js +723 -0
- package/dist/core/codex/codex-config-guard.js +7 -2
- package/dist/core/codex/codex-project-config-policy.js +3 -6
- package/dist/core/codex/codex-startup-config-postcheck.js +52 -42
- package/dist/core/codex-adapter.js +35 -22
- package/dist/core/codex-app/codex-agent-role-sync.js +13 -54
- package/dist/core/codex-app/codex-app-launcher.js +48 -17
- package/dist/core/codex-app/codex-app-restart.js +23 -2
- package/dist/core/codex-app/sks-menubar.js +128 -2
- package/dist/core/codex-control/codex-0139-image-path-real-probe.js +15 -4
- package/dist/core/codex-control/codex-0139-web-search-probe.js +17 -6
- package/dist/core/codex-control/codex-lb-launch-recovery.js +278 -0
- package/dist/core/codex-control/codex-reliability-shield.js +89 -29
- package/dist/core/codex-control/codex-sdk-adapter.js +44 -8
- package/dist/core/codex-control/codex-task-runner.js +62 -9
- package/dist/core/codex-control/python-codex-sdk-adapter.js +30 -3
- package/dist/core/codex-exec-output-schema.js +35 -6
- package/dist/core/codex-lb/codex-lb-env.js +1 -1
- package/dist/core/codex-lb/codex-lb-tool-output-recovery.js +291 -0
- package/dist/core/codex-native/codex-native-feature-broker.js +9 -16
- package/dist/core/codex-native/codex-native-repair-transaction.js +1 -1
- package/dist/core/codex-native/core-skill-manifest.js +8 -4
- package/dist/core/codex-runtime/codex-desktop-config-policy.js +2 -3
- package/dist/core/commands/agent-bridge-command.js +23 -2
- package/dist/core/commands/agent-command.js +19 -5
- package/dist/core/commands/basic-cli.js +47 -6
- package/dist/core/commands/command-utils.js +1 -1
- package/dist/core/commands/mad-sks-command.js +33 -8
- package/dist/core/commands/naruto-command.js +643 -1156
- package/dist/core/commands/research-command.js +293 -231
- package/dist/core/commands/run-command.js +100 -23
- package/dist/core/commands/team-command.js +2 -3
- package/dist/core/commands/team-legacy-observe-command.js +94 -359
- package/dist/core/db-safety.js +2 -2
- package/dist/core/decision-lattice.js +6 -6
- package/dist/core/doctor/codex-startup-config-repair.js +8 -3
- package/dist/core/doctor/doctor-codex-startup-repair.js +6 -141
- package/dist/core/feature-fixture-executor.js +71 -7
- package/dist/core/feature-fixture-runner.js +53 -12
- package/dist/core/feature-fixtures.js +47 -14
- package/dist/core/feature-registry.js +28 -27
- package/dist/core/harness-conflicts.js +18 -9
- package/dist/core/hooks-runtime/hook-io.js +8 -4
- package/dist/core/hooks-runtime/light-turn.js +70 -0
- package/dist/core/hooks-runtime/payload-signals.js +270 -0
- package/dist/core/hooks-runtime/team-digest.js +0 -1
- package/dist/core/hooks-runtime/tool-output-quarantine.js +93 -0
- package/dist/core/hooks-runtime.js +411 -258
- package/dist/core/init/skills.js +16 -30
- package/dist/core/init.js +144 -36
- package/dist/core/managed-assets/managed-assets-manifest.js +417 -10
- package/dist/core/mission.js +24 -1
- package/dist/core/pipeline-internals/runtime-core.js +570 -177
- package/dist/core/pipeline-internals/runtime-gates.js +174 -48
- package/dist/core/preflight/parallel-preflight-engine.js +50 -1
- package/dist/core/proof/route-proof-gate.js +7 -2
- package/dist/core/proof-field.js +1 -1
- package/dist/core/provider/model-router.js +33 -31
- package/dist/core/recallpulse/policy.js +12 -28
- package/dist/core/recallpulse.js +11 -6
- package/dist/core/release/npm-pack-proof.js +247 -0
- package/dist/core/release/package-dist-snapshot.js +151 -0
- package/dist/core/release/package-size-budget.js +5 -0
- package/dist/core/release/release-authorization-snapshot.js +115 -0
- package/dist/core/release/release-gate-affected-selector.js +14 -2
- package/dist/core/release/release-gate-cache-v2.js +30 -0
- package/dist/core/release/release-gate-contract.js +161 -0
- package/dist/core/release/release-gate-dag.js +1 -0
- package/dist/core/release/release-real-contract.js +90 -10
- package/dist/core/release-parallel-full-coverage.js +31 -143
- package/dist/core/research/claim-evidence-matrix.js +41 -6
- package/dist/core/research/experiment-plan.js +14 -10
- package/dist/core/research/falsification.js +9 -2
- package/dist/core/research/implementation-blueprint-densifier.js +82 -60
- package/dist/core/research/implementation-blueprint.js +32 -26
- package/dist/core/research/mock-result.js +122 -11
- package/dist/core/research/replication-pack.js +15 -8
- package/dist/core/research/research-adversarial-review.js +1068 -0
- package/dist/core/research/research-claim-builder.js +69 -17
- package/dist/core/research/research-claim-synthesizer.js +343 -0
- package/dist/core/research/research-cycle-runner.js +53 -3
- package/dist/core/research/research-falsification-runner.js +176 -0
- package/dist/core/research/research-final-reviewer.js +44 -125
- package/dist/core/research/research-realistic-report.js +14 -6
- package/dist/core/research/research-review-artifact-digest.js +66 -0
- package/dist/core/research/research-source-evidence.js +144 -0
- package/dist/core/research/research-source-layer-catalog.js +68 -0
- package/dist/core/research/research-source-ledger-merge.js +250 -12
- package/dist/core/research/research-source-shards.js +26 -70
- package/dist/core/research/research-stage-runner.js +237 -247
- package/dist/core/research/research-super-search.js +184 -0
- package/dist/core/research/research-synthesis-prompt.js +20 -1
- package/dist/core/research/research-synthesis-writer.js +86 -5
- package/dist/core/research/research-work-graph.js +25 -18
- package/dist/core/research/source-quality-report.js +21 -0
- package/dist/core/research.js +429 -280
- package/dist/core/routes/constants.js +1 -1
- package/dist/core/routes/dollar-manifest-lite.js +11 -11
- package/dist/core/routes.js +90 -63
- package/dist/core/runtime/task-profile.js +66 -0
- package/dist/core/runtime/verification-budget.js +12 -0
- package/dist/core/security/high-risk-contracts.js +6 -6
- package/dist/core/stop-gate/stop-gate-check.js +49 -12
- package/dist/core/subagents/agent-catalog.js +215 -0
- package/dist/core/subagents/model-policy.js +118 -0
- package/dist/core/subagents/naruto-help-contract.js +40 -0
- package/dist/core/subagents/official-subagent-config.js +488 -0
- package/dist/core/subagents/official-subagent-preparation.js +251 -0
- package/dist/core/subagents/official-subagent-prompt.js +137 -0
- package/dist/core/subagents/official-subagent-runner.js +129 -0
- package/dist/core/subagents/subagent-evidence.js +663 -0
- package/dist/core/subagents/terminology.js +16 -0
- package/dist/core/subagents/thread-budget.js +21 -0
- package/dist/core/subagents/triwiki-attention.js +65 -0
- package/dist/core/super-search/runtime-helpers.js +173 -19
- package/dist/core/super-search/runtime.js +140 -15
- package/dist/core/super-search/source-records.js +49 -8
- package/dist/core/team-review-policy.js +15 -0
- package/dist/core/triwiki/triwiki-module-card.js +1 -1
- package/dist/core/triwiki-wrongness/wrongness-ledger.js +9 -2
- package/dist/core/version-manager.js +51 -1
- package/dist/core/version.js +1 -1
- package/dist/core/work-order-ledger.js +40 -1
- package/dist/core/zellij/zellij-fake-adapter.js +3 -1
- package/dist/core/zellij/zellij-launcher.js +37 -8
- package/dist/core/zellij/zellij-layout-builder.js +14 -5
- package/dist/core/zellij/zellij-official-subagent-activity.js +477 -0
- package/dist/core/zellij/zellij-official-subagent-telemetry.js +264 -0
- package/dist/core/zellij/zellij-slot-pane-renderer.js +17 -5
- package/dist/core/zellij/zellij-slot-telemetry.js +15 -3
- package/dist/core/zellij/zellij-ui-mode.js +1 -1
- package/dist/core/zellij/zellij-viewport-binder.js +3 -0
- package/dist/scripts/agent-role-config-repair-check.js +14 -16
- package/dist/scripts/architecture-guard-check.js +8 -1
- package/dist/scripts/check-route-modularity.js +0 -1
- package/dist/scripts/check-ts-contracts.js +1 -1
- package/dist/scripts/codex-control-all-pipelines-check.js +7 -3
- package/dist/scripts/codex-control-tool-output-continuity-audit-check.js +27 -0
- package/dist/scripts/codex-native-agent-role-content-check.js +15 -7
- package/dist/scripts/codex-native-repair-transaction-check.js +3 -1
- package/dist/scripts/codex-sdk-all-pipelines-check.js +7 -4
- package/dist/scripts/codex-sdk-research-pipeline-check.js +30 -8
- package/dist/scripts/db-route-materialization-check.js +33 -0
- package/dist/scripts/docs-truthfulness-check.js +3 -1
- package/dist/scripts/doctor-codex-startup-repair-check.js +12 -15
- package/dist/scripts/doctor-fix-production-blackbox.js +12 -2
- package/dist/scripts/doctor-startup-config-repair-blackbox.js +8 -2
- package/dist/scripts/doctor-startup-config-repair-check.js +12 -2
- package/dist/scripts/install-update-preserves-config-check.js +6 -1
- package/dist/scripts/mad-sks-app-ui-no-mutation-check.js +0 -1
- package/dist/scripts/managed-role-manifest-parity-check.js +5 -4
- package/dist/scripts/naruto-codex-e2e-check.js +14 -7
- package/dist/scripts/naruto-shadow-clone-swarm-check.js +4 -201
- package/dist/scripts/npm-publish-performance-check.js +20 -12
- package/dist/scripts/official-subagent-workflow-check.js +145 -0
- package/dist/scripts/package-published-contract-check.js +6 -29
- package/dist/scripts/packlist-performance-check.js +17 -3
- package/dist/scripts/parallel-verification-engine-check.js +2 -2
- package/dist/scripts/prepublish-release-check-or-fast.js +23 -86
- package/dist/scripts/release-affected-selector-check.js +74 -1
- package/dist/scripts/release-check-stamp.js +153 -248
- package/dist/scripts/release-dag-full-coverage-check.js +7 -15
- package/dist/scripts/release-dynamic-presets-check.js +2 -1
- package/dist/scripts/release-gate-dag-runner-check.js +0 -1
- package/dist/scripts/release-gate-dag-runner.js +12 -1
- package/dist/scripts/release-gate-existence-audit.js +1 -2
- package/dist/scripts/release-parallel-full-coverage-check.js +12 -6
- package/dist/scripts/release-parallel-speed-budget-check.js +18 -2
- package/dist/scripts/release-real-check.js +26 -4
- package/dist/scripts/release-registry-check.js +61 -16
- package/dist/scripts/research-blueprint-densifier-check.js +2 -2
- package/dist/scripts/research-real-cycle-no-legacy-final-md-check.js +11 -7
- package/dist/scripts/sizecheck.js +2 -2
- package/dist/scripts/sks-3-1-4-directive-check-lib.js +8 -2
- package/dist/scripts/sks-3-1-5-directive-check-lib.js +3 -2
- package/dist/scripts/sks-3-1-6-directive-check-lib.js +5 -3
- package/dist/scripts/sks-menubar-install-check.js +8 -0
- package/dist/scripts/trust-fixture-check.js +32 -10
- package/dist/scripts/wrongness-fixture-check.js +1 -1
- package/dist/scripts/zellij-layout-valid-check.js +5 -5
- package/dist/scripts/zellij-spawn-on-demand-layout-check.js +3 -3
- package/docs/demo.tape +1 -1
- package/infra-harness-gates.json +1486 -0
- package/package.json +13 -10
- package/release-gates.v2.json +4060 -0
- package/runtime-required-scripts.json +9 -0
- package/dist/commands/db.js +0 -6
- package/dist/core/commands/db-command.js +0 -146
- package/dist/core/research/prompt.js +0 -15
- package/dist/scripts/codex-control-tool-call-sequence-repair-check.js +0 -14
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import fsp from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { nowIso, randomId, writeJsonAtomic, writeTextAtomic } from '../fsx.js';
|
|
4
|
+
import { classifyTaskProfile } from '../runtime/task-profile.js';
|
|
5
|
+
import { chooseVerificationBudget } from '../runtime/verification-budget.js';
|
|
6
|
+
import { buildOfficialSubagentPrompt } from './official-subagent-prompt.js';
|
|
7
|
+
import { readOfficialSubagentConfig } from './official-subagent-config.js';
|
|
8
|
+
import { NARUTO_PARENT_EFFORT, NARUTO_PARENT_MODEL } from './model-policy.js';
|
|
9
|
+
import { officialSubagentFanoutPolicy, officialSubagentRolePlan, recommendOfficialSubagentRoles } from './agent-catalog.js';
|
|
10
|
+
import { resolveSubagentThreadBudget } from './thread-budget.js';
|
|
11
|
+
import { readBoundedTriwikiAttention } from './triwiki-attention.js';
|
|
12
|
+
import { SUBAGENT_EVIDENCE_FILENAME, SUBAGENT_EVENT_LOG_FILENAME, SUBAGENT_PARENT_SUMMARY_FILENAME, normalizeSubagentParentSummary, writeSubagentEvidence } from './subagent-evidence.js';
|
|
13
|
+
export const NARUTO_RESULT_SCHEMA = 'sks.naruto-subagent-workflow.v1';
|
|
14
|
+
export const SUBAGENT_PLAN_FILENAME = 'subagent-plan.json';
|
|
15
|
+
export const NARUTO_SUMMARY_FILENAME = 'naruto-summary.json';
|
|
16
|
+
export const NARUTO_GATE_FILENAME = 'naruto-gate.json';
|
|
17
|
+
export async function prepareOfficialSubagentMission(input) {
|
|
18
|
+
const goal = String(input.goal || '').trim();
|
|
19
|
+
const mode = input.mode === 'naruto' ? 'naruto' : 'generic';
|
|
20
|
+
const taskProfile = classifyTaskProfile(goal);
|
|
21
|
+
const suggestedAgents = recommendOfficialSubagentRoles({
|
|
22
|
+
description: goal,
|
|
23
|
+
readOnly: input.readOnly === true,
|
|
24
|
+
requiresWrite: input.readOnly !== true
|
|
25
|
+
});
|
|
26
|
+
const officialConfig = await readOfficialSubagentConfig(input.root);
|
|
27
|
+
const triwikiAttention = await readBoundedTriwikiAttention(input.root);
|
|
28
|
+
const requestedExplicit = input.requestedSubagentsExplicit ?? input.requestedSubagents !== undefined;
|
|
29
|
+
const selectedFanoutPolicy = officialSubagentFanoutPolicy({
|
|
30
|
+
...(input.requestedSubagents === undefined ? {} : { requestedSubagents: input.requestedSubagents }),
|
|
31
|
+
requestedExplicit,
|
|
32
|
+
taskProfile,
|
|
33
|
+
suggestedRoles: suggestedAgents,
|
|
34
|
+
goal
|
|
35
|
+
});
|
|
36
|
+
const budget = resolveSubagentThreadBudget({
|
|
37
|
+
requested: selectedFanoutPolicy.requested_subagents,
|
|
38
|
+
configuredMaxThreads: input.maxThreads ?? officialConfig.maxThreads
|
|
39
|
+
});
|
|
40
|
+
const verification = chooseVerificationBudget({ taskProfile, changedFiles: [] });
|
|
41
|
+
const workflowRunId = String(input.workflowRunId || '').trim()
|
|
42
|
+
|| `${mode === 'naruto' ? 'naruto' : 'official'}-${Date.now().toString(36)}-${randomId(8)}`;
|
|
43
|
+
const fanoutPolicy = {
|
|
44
|
+
...selectedFanoutPolicy,
|
|
45
|
+
requested_subagents: budget.requestedSubagents
|
|
46
|
+
};
|
|
47
|
+
const observedParentModel = String(input.observedParentModel || '').trim() || null;
|
|
48
|
+
const parentModelMatch = observedParentModel ? observedParentModelMatchesPolicy(observedParentModel) : null;
|
|
49
|
+
const delegationGoal = input.readOnly
|
|
50
|
+
? `${goal}\n\nConstraint: run every delegated slice in read-only mode. Do not edit files.`
|
|
51
|
+
: goal;
|
|
52
|
+
const delegationPrompt = buildOfficialSubagentPrompt({
|
|
53
|
+
goal: delegationGoal,
|
|
54
|
+
slices: [],
|
|
55
|
+
requestedSubagents: budget.requestedSubagents,
|
|
56
|
+
requestedSubagentsExplicit: requestedExplicit,
|
|
57
|
+
maxThreads: budget.maxThreads,
|
|
58
|
+
decompositionStatus: 'parent_required',
|
|
59
|
+
triwikiAttention,
|
|
60
|
+
recommendedAgents: suggestedAgents
|
|
61
|
+
});
|
|
62
|
+
const configBlockers = officialConfig.blockers.map((blocker) => `official_subagent_config:${blocker}`);
|
|
63
|
+
const plan = {
|
|
64
|
+
schema: 'sks.subagent-plan.v1',
|
|
65
|
+
mission_id: input.missionId,
|
|
66
|
+
route: input.route,
|
|
67
|
+
workflow: 'official_codex_subagent',
|
|
68
|
+
workflow_run_id: workflowRunId,
|
|
69
|
+
session_scope: input.sessionScope || null,
|
|
70
|
+
goal,
|
|
71
|
+
read_only: input.readOnly === true,
|
|
72
|
+
task_profile: taskProfile,
|
|
73
|
+
decomposition_status: 'parent_required',
|
|
74
|
+
delegation_prompt: delegationPrompt,
|
|
75
|
+
requested_subagents: budget.requestedSubagents,
|
|
76
|
+
requested_subagents_explicit: requestedExplicit,
|
|
77
|
+
max_threads: budget.maxThreads,
|
|
78
|
+
first_wave: budget.firstWave,
|
|
79
|
+
wave_count: budget.waveCount,
|
|
80
|
+
max_depth: budget.maxDepth,
|
|
81
|
+
config_source: input.maxThreads === undefined ? officialConfig.sources.maxThreads : 'cli',
|
|
82
|
+
config_sources: officialConfig.sources,
|
|
83
|
+
config_blockers: officialConfig.blockers,
|
|
84
|
+
triwiki_attention: triwikiAttention,
|
|
85
|
+
suggested_agents: suggestedAgents,
|
|
86
|
+
fanout_policy: fanoutPolicy,
|
|
87
|
+
slices: [],
|
|
88
|
+
parent_model_policy: NARUTO_PARENT_MODEL,
|
|
89
|
+
observed_parent_model: observedParentModel,
|
|
90
|
+
parent_model_match: parentModelMatch,
|
|
91
|
+
parent: {
|
|
92
|
+
model: NARUTO_PARENT_MODEL,
|
|
93
|
+
model_reasoning_effort: NARUTO_PARENT_EFFORT
|
|
94
|
+
},
|
|
95
|
+
agents: officialSubagentRolePlan(),
|
|
96
|
+
verification_budget: verification,
|
|
97
|
+
verification_checks: [],
|
|
98
|
+
verification: { budget: verification },
|
|
99
|
+
legacy_process_swarm_used: false,
|
|
100
|
+
created_at: nowIso()
|
|
101
|
+
};
|
|
102
|
+
const cleanup = [
|
|
103
|
+
fsp.rm(path.join(input.dir, SUBAGENT_PARENT_SUMMARY_FILENAME), { force: true }),
|
|
104
|
+
fsp.rm(path.join(input.dir, SUBAGENT_EVIDENCE_FILENAME), { force: true })
|
|
105
|
+
];
|
|
106
|
+
if (mode === 'naruto') {
|
|
107
|
+
cleanup.push(fsp.rm(path.join(input.dir, NARUTO_SUMMARY_FILENAME), { force: true }), fsp.rm(path.join(input.dir, NARUTO_GATE_FILENAME), { force: true }));
|
|
108
|
+
}
|
|
109
|
+
await Promise.all(cleanup);
|
|
110
|
+
await writeTextAtomic(path.join(input.dir, SUBAGENT_EVENT_LOG_FILENAME), '');
|
|
111
|
+
await writeJsonAtomic(path.join(input.dir, SUBAGENT_PLAN_FILENAME), plan);
|
|
112
|
+
const evidence = await writeSubagentEvidence(input.dir, {
|
|
113
|
+
requestedSubagents: budget.requestedSubagents,
|
|
114
|
+
events: [],
|
|
115
|
+
parentSummaryPresent: false,
|
|
116
|
+
workflowStatus: 'delegation_context_ready',
|
|
117
|
+
preparationOnly: input.preparationOnly !== false,
|
|
118
|
+
runId: workflowRunId,
|
|
119
|
+
additionalBlockers: configBlockers
|
|
120
|
+
});
|
|
121
|
+
if (mode === 'naruto') {
|
|
122
|
+
const blockers = uniqueStrings([
|
|
123
|
+
...evidence.blockers,
|
|
124
|
+
...configBlockers,
|
|
125
|
+
...(parentModelMatch === false ? [`parent_model_mismatch:${observedParentModel}`] : [])
|
|
126
|
+
]);
|
|
127
|
+
await writeJsonAtomic(path.join(input.dir, NARUTO_SUMMARY_FILENAME), buildNarutoSummary({
|
|
128
|
+
missionId: input.missionId,
|
|
129
|
+
workflowRunId,
|
|
130
|
+
budget,
|
|
131
|
+
evidence,
|
|
132
|
+
verification,
|
|
133
|
+
status: 'delegation_context_ready',
|
|
134
|
+
ok: false,
|
|
135
|
+
blockers,
|
|
136
|
+
sessionKey: input.sessionScope || null,
|
|
137
|
+
observedParentModel,
|
|
138
|
+
parentModelMatch
|
|
139
|
+
}));
|
|
140
|
+
await writeNarutoGate(input.dir, {
|
|
141
|
+
missionId: input.missionId,
|
|
142
|
+
workflowRunId,
|
|
143
|
+
evidence,
|
|
144
|
+
passed: false,
|
|
145
|
+
blockers,
|
|
146
|
+
configBlockers,
|
|
147
|
+
observedParentModel,
|
|
148
|
+
parentModelMatch
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
plan,
|
|
153
|
+
evidence,
|
|
154
|
+
budget,
|
|
155
|
+
verification,
|
|
156
|
+
taskProfile,
|
|
157
|
+
delegationPrompt,
|
|
158
|
+
workflowRunId,
|
|
159
|
+
officialConfig,
|
|
160
|
+
triwikiAttention,
|
|
161
|
+
suggestedAgents,
|
|
162
|
+
fanoutPolicy,
|
|
163
|
+
configBlockers,
|
|
164
|
+
observedParentModel,
|
|
165
|
+
parentModelMatch
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
export function buildNarutoSummary(input) {
|
|
169
|
+
const parentSummary = normalizeSubagentParentSummary(input.parentSummary);
|
|
170
|
+
return {
|
|
171
|
+
schema: NARUTO_RESULT_SCHEMA,
|
|
172
|
+
ok: input.ok === true,
|
|
173
|
+
completion_evidence: input.ok === true,
|
|
174
|
+
status: input.status,
|
|
175
|
+
route: '$Naruto',
|
|
176
|
+
workflow: 'official_codex_subagent',
|
|
177
|
+
workflow_run_id: input.workflowRunId || input.evidence?.run_id || null,
|
|
178
|
+
mission_id: input.missionId,
|
|
179
|
+
parent: {
|
|
180
|
+
model: NARUTO_PARENT_MODEL,
|
|
181
|
+
model_reasoning_effort: NARUTO_PARENT_EFFORT,
|
|
182
|
+
observed_model: input.observedParentModel || null,
|
|
183
|
+
observed_model_match: input.parentModelMatch ?? null
|
|
184
|
+
},
|
|
185
|
+
requested_subagents: input.budget.requestedSubagents,
|
|
186
|
+
max_threads: input.budget.maxThreads,
|
|
187
|
+
max_depth: input.budget.maxDepth,
|
|
188
|
+
started_subagents: Number(input.evidence?.started_threads || 0),
|
|
189
|
+
completed_subagents: Number(input.evidence?.completed_threads || 0),
|
|
190
|
+
failed_subagents: Number(input.evidence?.failed_threads || 0),
|
|
191
|
+
agents: officialSubagentRolePlan(),
|
|
192
|
+
verification: {
|
|
193
|
+
budget: input.verification,
|
|
194
|
+
checks: []
|
|
195
|
+
},
|
|
196
|
+
parent_summary_present: Boolean(input.parentSummary),
|
|
197
|
+
parent_summary: parentSummary.summary,
|
|
198
|
+
parent_thread_outcomes: parentSummary.raw?.thread_outcomes || [],
|
|
199
|
+
app_session: input.appSession === true,
|
|
200
|
+
session_scope: input.sessionKey || null,
|
|
201
|
+
blockers: uniqueStrings(input.blockers || input.evidence?.blockers || []),
|
|
202
|
+
legacy_process_swarm_used: false,
|
|
203
|
+
updated_at: nowIso()
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
export async function writeNarutoGate(dir, input) {
|
|
207
|
+
await writeJsonAtomic(path.join(dir, NARUTO_GATE_FILENAME), buildNarutoGateResult(input));
|
|
208
|
+
}
|
|
209
|
+
export function buildNarutoGateResult(input) {
|
|
210
|
+
const passed = input.passed === true;
|
|
211
|
+
const requested = Number(input.evidence?.requested_subagents || 0);
|
|
212
|
+
const completed = Number(input.evidence?.completed_threads || 0);
|
|
213
|
+
const failed = Number(input.evidence?.failed_threads || 0);
|
|
214
|
+
return {
|
|
215
|
+
schema: 'sks.naruto-gate.v1',
|
|
216
|
+
route: '$Naruto',
|
|
217
|
+
workflow: 'official_codex_subagent',
|
|
218
|
+
workflow_run_id: input.workflowRunId || input.evidence?.run_id || null,
|
|
219
|
+
mission_id: input.missionId,
|
|
220
|
+
parent_model_policy: NARUTO_PARENT_MODEL,
|
|
221
|
+
observed_parent_model: input.observedParentModel || null,
|
|
222
|
+
parent_model_match: input.parentModelMatch ?? null,
|
|
223
|
+
status: passed ? 'passed' : 'blocked',
|
|
224
|
+
passed,
|
|
225
|
+
terminal: passed,
|
|
226
|
+
terminal_state: passed ? 'completed' : 'blocked',
|
|
227
|
+
subagent_plan_ready: true,
|
|
228
|
+
official_subagent_evidence: input.evidence?.ok === true,
|
|
229
|
+
session_cleanup: failed === 0 && requested > 0 && completed >= requested,
|
|
230
|
+
subagent_evidence_ready: input.evidence?.ok === true,
|
|
231
|
+
requested_subagents: requested || null,
|
|
232
|
+
started_subagents: Number(input.evidence?.started_threads || 0),
|
|
233
|
+
completed_subagents: Number(input.evidence?.completed_threads || 0),
|
|
234
|
+
failed_subagents: Number(input.evidence?.failed_threads || 0),
|
|
235
|
+
parent_summary_present: input.evidence?.parent_summary_present === true,
|
|
236
|
+
event_sources: input.evidence?.event_sources || [],
|
|
237
|
+
native_process_proof_required: false,
|
|
238
|
+
legacy_process_swarm_used: false,
|
|
239
|
+
config_blockers: uniqueStrings(input.configBlockers || []),
|
|
240
|
+
blockers: uniqueStrings(input.blockers || input.evidence?.blockers || []),
|
|
241
|
+
missing_fields: uniqueStrings(input.blockers || input.evidence?.blockers || []),
|
|
242
|
+
updated_at: nowIso()
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function observedParentModelMatchesPolicy(model) {
|
|
246
|
+
return model.toLowerCase() === NARUTO_PARENT_MODEL || /gpt[-_. ]?5\.6[-_. ]?sol|\bsol(?:\s+max)?\b/i.test(model);
|
|
247
|
+
}
|
|
248
|
+
function uniqueStrings(values) {
|
|
249
|
+
return [...new Set(values.map((value) => String(value || '').trim()).filter(Boolean))];
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=official-subagent-preparation.js.map
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { HARD_NARUTO_MAX_THREADS } from './thread-budget.js';
|
|
2
|
+
import { MAX_AUTOMATIC_REVIEWER_COUNT, MAX_AUTOMATIC_SUBAGENT_COUNT, officialSubagentRoleCatalog, selectOfficialSubagentRole } from './agent-catalog.js';
|
|
3
|
+
export function buildOfficialSubagentPrompt(input) {
|
|
4
|
+
const maxThreads = clampThreads(input.maxThreads);
|
|
5
|
+
const requestedSubagents = normalizeRequestedSubagents(input.requestedSubagents, input.slices.length);
|
|
6
|
+
const waveCount = requestedSubagents === 0 ? 0 : Math.ceil(requestedSubagents / maxThreads);
|
|
7
|
+
const parentDecompositionRequired = input.decompositionStatus === 'parent_required';
|
|
8
|
+
const requestedPolicy = input.requestedSubagentsExplicit === true
|
|
9
|
+
? `${requestedSubagents} (explicit operator request)`
|
|
10
|
+
: `${requestedSubagents} (risk-based automatic count; one child is the safe default; keep the plan and evidence count exact)`;
|
|
11
|
+
const triwiki = renderBoundedTriwikiAttention(input.triwikiAttention);
|
|
12
|
+
const catalog = renderAgentCatalog(input.recommendedAgents);
|
|
13
|
+
const rows = input.slices.map((slice, index) => {
|
|
14
|
+
const agentName = slice.agent || selectOfficialSubagentRole({
|
|
15
|
+
title: slice.title,
|
|
16
|
+
description: slice.description,
|
|
17
|
+
role: slice.kind,
|
|
18
|
+
...(slice.paths === undefined ? {} : { paths: slice.paths }),
|
|
19
|
+
readOnly: slice.readOnly === true,
|
|
20
|
+
requiresWrite: slice.readOnly !== true
|
|
21
|
+
});
|
|
22
|
+
const mode = slice.readOnly ? 'read-only' : 'use the parent permission mode';
|
|
23
|
+
const paths = (slice.paths || []).map((entry) => String(entry).trim()).filter(Boolean);
|
|
24
|
+
return [
|
|
25
|
+
`${index + 1}. [${slice.id}] use custom agent \`${agentName}\``,
|
|
26
|
+
` title: ${slice.title}`,
|
|
27
|
+
` task: ${slice.description}`,
|
|
28
|
+
` mode: ${mode}`,
|
|
29
|
+
` paths: ${paths.join(', ') || 'assigned by parent'}`
|
|
30
|
+
].join('\n');
|
|
31
|
+
}).join('\n');
|
|
32
|
+
return `
|
|
33
|
+
Use a Codex subagent workflow for the independent slices below.
|
|
34
|
+
|
|
35
|
+
Parent agent:
|
|
36
|
+
- model policy: gpt-5.6-sol with max reasoning
|
|
37
|
+
- owns decomposition, integration, and final answer
|
|
38
|
+
- do not do duplicate work already delegated
|
|
39
|
+
|
|
40
|
+
Subagent rules:
|
|
41
|
+
- use only Codex official subagent threads; do not launch shell workers, a custom scheduler, a worker pool, or model fanout
|
|
42
|
+
- select the narrowest matching project custom agent by its description; the custom agent name is the spawn type
|
|
43
|
+
- use \`worker\` with gpt-5.6-luna and max reasoning only for clear, bounded, repeatable work
|
|
44
|
+
- use \`expert\` with gpt-5.6-sol and max reasoning only as the read-only judgment fallback
|
|
45
|
+
- automatic fan-out is selected before execution: one by default, two only for explicit parallel work or independent risk domains,
|
|
46
|
+
and at most ${MAX_AUTOMATIC_SUBAGENT_COUNT} for critical multi-domain risk; never spawn beyond the requested count
|
|
47
|
+
- automatic reviewer-only fan-out is capped at ${MAX_AUTOMATIC_REVIEWER_COUNT} for ordinary work; critical multi-domain review may use the overall cap of ${MAX_AUTOMATIC_SUBAGENT_COUNT}
|
|
48
|
+
- requested subagents: ${requestedPolicy}
|
|
49
|
+
- max open agent threads: ${maxThreads}
|
|
50
|
+
- planned waves: ${waveCount}
|
|
51
|
+
- max depth: 1
|
|
52
|
+
- subagents must not spawn subagents
|
|
53
|
+
- parallel writes require disjoint paths
|
|
54
|
+
- if paths overlap, run those slices serially
|
|
55
|
+
- wait for every requested subagent before integrating
|
|
56
|
+
- close completed threads after collecting results
|
|
57
|
+
${parentDecompositionRequired ? `- decomposition status: parent_required
|
|
58
|
+
- before spawning, decompose the goal into independent, non-overlapping slices
|
|
59
|
+
- do not invent write scopes merely to reach the requested count
|
|
60
|
+
${input.requestedSubagentsExplicit === true
|
|
61
|
+
? '- the explicit operator count is authoritative; if it cannot be defended safely, block and report instead of silently changing it'
|
|
62
|
+
: '- if fewer defensible slices exist, reduce the delegation plan and requested count before execution; never increase automatically beyond the selected count'}` : '- decomposition status: ready'}
|
|
63
|
+
|
|
64
|
+
Central TriWiki context:
|
|
65
|
+
${triwiki}
|
|
66
|
+
|
|
67
|
+
Project custom agent catalog:
|
|
68
|
+
${catalog}
|
|
69
|
+
|
|
70
|
+
Goal:
|
|
71
|
+
${String(input.goal || '').trim()}
|
|
72
|
+
|
|
73
|
+
Slices:
|
|
74
|
+
${rows || '(parent decomposition required before any subagent is spawned)'}
|
|
75
|
+
|
|
76
|
+
Final parent output:
|
|
77
|
+
- return one JSON object as the final message; prose outside that object is not completion evidence
|
|
78
|
+
- use this exact schema so SKS can correlate every stopped agent thread with a trustworthy parent outcome:
|
|
79
|
+
{
|
|
80
|
+
"schema": "sks.subagent-parent-summary.v1",
|
|
81
|
+
"status": "completed|blocked|failed",
|
|
82
|
+
"summary": "Completion Summary: concise integrated result. Honest Mode: goal/evidence/checks/gaps assessment.",
|
|
83
|
+
"thread_outcomes": [
|
|
84
|
+
{ "thread_id": "official agent/thread id", "status": "completed|blocked|failed", "summary": "slice result" }
|
|
85
|
+
],
|
|
86
|
+
"changed_files": [],
|
|
87
|
+
"verification": [],
|
|
88
|
+
"blockers": []
|
|
89
|
+
}
|
|
90
|
+
- include one thread_outcomes row for every requested subagent; a SubagentStop event alone never proves success
|
|
91
|
+
- keep completion summary and Honest Mode wording inside the JSON fields; do not add prose outside the object
|
|
92
|
+
`.trim();
|
|
93
|
+
}
|
|
94
|
+
function renderBoundedTriwikiAttention(value) {
|
|
95
|
+
if (!value?.available || value.anchors.length === 0) {
|
|
96
|
+
return [
|
|
97
|
+
'- no bounded attention anchors are available; rely on current scoped sources',
|
|
98
|
+
'- do not compensate by making every subagent reread the entire repository or full TriWiki pack'
|
|
99
|
+
].join('\n');
|
|
100
|
+
}
|
|
101
|
+
const anchors = value.anchors.map((anchor) => ({
|
|
102
|
+
id: anchor.id,
|
|
103
|
+
claim_hash: anchor.claim_hash,
|
|
104
|
+
source_hash: anchor.source_hash,
|
|
105
|
+
hydrate_hint: anchor.hydrate_hint
|
|
106
|
+
}));
|
|
107
|
+
return [
|
|
108
|
+
`- consume these ${anchors.length} attention.use_first anchors before broad discovery`,
|
|
109
|
+
'- hydrate a referenced source only when its anchor is relevant to the assigned slice or a risky decision',
|
|
110
|
+
'- do not inject the full context pack or make each subagent repeat repository-wide context discovery',
|
|
111
|
+
`- bounded anchors: ${JSON.stringify(anchors)}`
|
|
112
|
+
].join('\n');
|
|
113
|
+
}
|
|
114
|
+
function renderAgentCatalog(recommended) {
|
|
115
|
+
const preferred = new Set((recommended || []).map(String));
|
|
116
|
+
const included = new Set(['worker', 'implementation_specialist', 'expert', ...preferred]);
|
|
117
|
+
return officialSubagentRoleCatalog()
|
|
118
|
+
.filter((role) => included.has(role.name))
|
|
119
|
+
.map((role) => {
|
|
120
|
+
const marker = preferred.has(role.name) ? ' [suggested for this goal]' : '';
|
|
121
|
+
return `- \`${role.name}\`${marker}: ${role.model}/${role.model_reasoning_effort}, ${role.sandbox_mode}; ${role.description}`;
|
|
122
|
+
})
|
|
123
|
+
.join('\n');
|
|
124
|
+
}
|
|
125
|
+
function clampThreads(value) {
|
|
126
|
+
const parsed = Number(value);
|
|
127
|
+
if (!Number.isFinite(parsed))
|
|
128
|
+
return 1;
|
|
129
|
+
return Math.max(1, Math.min(HARD_NARUTO_MAX_THREADS, Math.floor(parsed)));
|
|
130
|
+
}
|
|
131
|
+
function normalizeRequestedSubagents(value, fallback) {
|
|
132
|
+
const parsed = value === undefined || value === null || value === '' ? fallback : Number(value);
|
|
133
|
+
if (!Number.isFinite(parsed))
|
|
134
|
+
return Math.max(0, Math.min(HARD_NARUTO_MAX_THREADS, fallback));
|
|
135
|
+
return Math.max(0, Math.min(HARD_NARUTO_MAX_THREADS, Math.floor(parsed)));
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=official-subagent-prompt.js.map
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import fsp from 'node:fs/promises';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { runProcess } from '../fsx.js';
|
|
5
|
+
import { NARUTO_PARENT_EFFORT, NARUTO_PARENT_MODEL } from './model-policy.js';
|
|
6
|
+
import { inspectCodexLbCliLaunchRecovery } from '../codex-control/codex-lb-launch-recovery.js';
|
|
7
|
+
export const OFFICIAL_SUBAGENT_WORKFLOW_SCHEMA = 'sks.subagent-workflow.v1';
|
|
8
|
+
export function detectCodexAppSession(env = process.env) {
|
|
9
|
+
if (env.SKS_NARUTO_STANDALONE_CLI === '1')
|
|
10
|
+
return false;
|
|
11
|
+
if (env.SKS_NARUTO_APP_SESSION === '1')
|
|
12
|
+
return true;
|
|
13
|
+
return Boolean(env.CODEX_THREAD_ID);
|
|
14
|
+
}
|
|
15
|
+
export function codexAppSessionKey(env = process.env) {
|
|
16
|
+
if (!detectCodexAppSession(env))
|
|
17
|
+
return null;
|
|
18
|
+
const threadId = String(env.CODEX_THREAD_ID || '').trim();
|
|
19
|
+
return threadId || null;
|
|
20
|
+
}
|
|
21
|
+
export function buildOfficialSubagentCodexArgs(input) {
|
|
22
|
+
return [
|
|
23
|
+
'exec',
|
|
24
|
+
'-m', NARUTO_PARENT_MODEL,
|
|
25
|
+
'-c', `model_reasoning_effort="${NARUTO_PARENT_EFFORT}"`,
|
|
26
|
+
'-c', `agents.max_threads=${Math.max(1, Math.floor(input.maxThreads))}`,
|
|
27
|
+
'-c', 'agents.max_depth=1',
|
|
28
|
+
'--output-last-message', input.parentSummaryFile,
|
|
29
|
+
input.prompt
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
export async function runOfficialSubagentWorkflow(input) {
|
|
33
|
+
const base = {
|
|
34
|
+
schema: OFFICIAL_SUBAGENT_WORKFLOW_SCHEMA,
|
|
35
|
+
workflow: 'official_codex_subagent',
|
|
36
|
+
requested_subagents: input.requestedSubagents,
|
|
37
|
+
max_threads: input.maxThreads,
|
|
38
|
+
max_depth: 1,
|
|
39
|
+
parent_model: NARUTO_PARENT_MODEL,
|
|
40
|
+
parent_reasoning_effort: NARUTO_PARENT_EFFORT,
|
|
41
|
+
session_scope: input.sessionKey || null,
|
|
42
|
+
legacy_process_swarm_used: false
|
|
43
|
+
};
|
|
44
|
+
if (input.appSession) {
|
|
45
|
+
return {
|
|
46
|
+
...base,
|
|
47
|
+
ok: false,
|
|
48
|
+
status: 'delegation_context_ready',
|
|
49
|
+
prepared: true,
|
|
50
|
+
additionalContext: input.prompt,
|
|
51
|
+
completion_evidence: false,
|
|
52
|
+
note: 'The current Codex parent must spawn and await the official subagents. Preparation is not completion evidence.'
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const childEnv = {
|
|
56
|
+
...(input.env || {}),
|
|
57
|
+
SKS_NARUTO_STANDALONE_CLI: '0',
|
|
58
|
+
SKS_NARUTO_PARENT_LAUNCH: '1',
|
|
59
|
+
...(input.missionId ? { SKS_NARUTO_PARENT_MISSION_ID: input.missionId } : {})
|
|
60
|
+
};
|
|
61
|
+
const parentSummaryFile = path.join(os.tmpdir(), `sks-naruto-parent-summary-${process.pid}-${Date.now()}.txt`);
|
|
62
|
+
const args = buildOfficialSubagentCodexArgs({
|
|
63
|
+
prompt: input.prompt,
|
|
64
|
+
maxThreads: input.maxThreads,
|
|
65
|
+
parentSummaryFile
|
|
66
|
+
});
|
|
67
|
+
const toolOutputRecovery = await inspectCodexLbCliLaunchRecovery({
|
|
68
|
+
root: input.root,
|
|
69
|
+
env: { ...process.env, ...childEnv },
|
|
70
|
+
cliArgs: args.slice(0, -1)
|
|
71
|
+
});
|
|
72
|
+
if (!toolOutputRecovery.ok) {
|
|
73
|
+
return {
|
|
74
|
+
...base,
|
|
75
|
+
ok: false,
|
|
76
|
+
status: 'tool_output_recovery_blocked',
|
|
77
|
+
prepared: false,
|
|
78
|
+
codex_exit_code: null,
|
|
79
|
+
parent_summary: null,
|
|
80
|
+
parent_summary_file: null,
|
|
81
|
+
tool_output_recovery: toolOutputRecovery,
|
|
82
|
+
blockers: toolOutputRecovery.blockers,
|
|
83
|
+
operator_actions: toolOutputRecovery.operator_actions,
|
|
84
|
+
completion_evidence: false
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
await fsp.mkdir(path.dirname(parentSummaryFile), { recursive: true });
|
|
88
|
+
const execute = input.runProcessImpl || runProcess;
|
|
89
|
+
let processResult;
|
|
90
|
+
try {
|
|
91
|
+
processResult = await execute(input.codexBin || 'codex', args, {
|
|
92
|
+
cwd: input.root,
|
|
93
|
+
timeoutMs: input.timeoutMs || 60 * 60 * 1000,
|
|
94
|
+
maxOutputBytes: 256 * 1024,
|
|
95
|
+
env: childEnv
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
processResult = {
|
|
100
|
+
code: -1,
|
|
101
|
+
stdout: '',
|
|
102
|
+
stderr: String(error?.message || error),
|
|
103
|
+
stdoutBytes: 0,
|
|
104
|
+
stderrBytes: 0,
|
|
105
|
+
truncated: false,
|
|
106
|
+
timedOut: false
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
const parentSummary = await fsp.readFile(parentSummaryFile, 'utf8').catch(() => '');
|
|
110
|
+
await fsp.rm(parentSummaryFile, { force: true }).catch(() => undefined);
|
|
111
|
+
return {
|
|
112
|
+
...base,
|
|
113
|
+
ok: processResult.code === 0,
|
|
114
|
+
status: processResult.code === 0 ? 'parent_completed' : 'parent_failed',
|
|
115
|
+
codex_exit_code: processResult.code,
|
|
116
|
+
parent_summary: parentSummary.trim() || null,
|
|
117
|
+
parent_summary_file: null,
|
|
118
|
+
tool_output_recovery: toolOutputRecovery,
|
|
119
|
+
process: {
|
|
120
|
+
pid: processResult.pid || null,
|
|
121
|
+
timed_out: processResult.timedOut,
|
|
122
|
+
stdout_tail: processResult.stdout,
|
|
123
|
+
stderr_tail: processResult.stderr,
|
|
124
|
+
output_truncated: processResult.truncated
|
|
125
|
+
},
|
|
126
|
+
completion_evidence: false
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=official-subagent-runner.js.map
|