sneakoscope 7.1.0 → 7.3.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/README.md +9 -1
- package/config/architecture-budgets.v1.json +1 -8
- package/crates/sks-core/Cargo.lock +225 -1
- package/crates/sks-core/Cargo.toml +8 -1
- package/crates/sks-core/src/main.rs +7 -1
- package/crates/sks-core/src/search/files.rs +114 -0
- package/crates/sks-core/src/search/mod.rs +274 -0
- package/crates/sks-core/src/search/text.rs +175 -0
- package/dist/bin/sks-dispatch.js +4 -3
- package/dist/cli/command-manifest-lite.js +177 -6
- package/dist/cli/command-registry.js +42 -8
- package/dist/cli/help.js +30 -0
- package/dist/cli/install-helpers-codex-lb-config.js +9 -6
- package/dist/cli/install-helpers-codex-lb-selftest-chain.js +1 -1
- package/dist/cli/install-helpers-install-support.js +1 -1
- package/dist/cli/install-helpers.js +19 -9
- package/dist/cli/router.js +16 -3
- package/dist/commands/codex-app.js +40 -5
- package/dist/commands/doctor-profile.js +78 -0
- package/dist/commands/doctor.js +29 -69
- package/dist/commands/search.js +4 -0
- package/dist/config/skills-manifest.json +53 -60
- package/dist/core/agent-bridge/agent-manifest.js +22 -26
- package/dist/core/agent-bridge/host-capability-policy.js +109 -8
- package/dist/core/agent-bridge/host-capability-runtime.js +178 -50
- package/dist/core/agent-guidance/directive-registry.js +123 -0
- package/dist/core/agents/agent-effort-policy.js +45 -6
- package/dist/core/agents/agent-worker-pipeline.js +1 -3
- package/dist/core/agents/native-worker-backend-router.js +43 -19
- package/dist/core/auto-review.js +1 -3
- package/dist/core/code-structure.js +282 -19
- package/dist/core/codex/codex-config-guard.js +14 -4
- package/dist/core/codex/codex-config-toml.js +1 -3
- package/dist/core/codex-app/codex-agent-role-sync.js +1 -3
- package/dist/core/codex-app/codex-app-fast-ui-repair.js +14 -1
- package/dist/core/codex-app/codex-app-types.js +2 -3
- package/dist/core/codex-app/codex-desktop-routing-ownership.js +91 -0
- package/dist/core/codex-app/codex-hook-approval-probe.js +1 -3
- package/dist/core/codex-app/codex-hook-lifecycle.js +1 -3
- package/dist/core/codex-app/codex-init-deep.js +22 -10
- package/dist/core/codex-app/codex-model-catalog.js +384 -0
- package/dist/core/codex-app/codex-models-cache.js +160 -0
- package/dist/core/codex-app/desktop-routing-snapshot.js +233 -0
- package/dist/core/codex-app/glm-profile-installer.js +1 -3
- package/dist/core/codex-app/mcp-manager.js +1 -3
- package/dist/core/codex-app/menubar/constants.js +3 -0
- package/dist/core/codex-app/menubar/installer.js +11 -1
- package/dist/core/codex-app/multi-provider-router-support.js +202 -0
- package/dist/core/codex-app/multi-provider-router.js +379 -0
- package/dist/core/codex-app/openrouter-activate.js +189 -26
- package/dist/core/codex-app/openrouter-base-instructions.js +1 -0
- package/dist/core/codex-app/openrouter-model-catalog.js +217 -0
- package/dist/core/codex-app/role-model-catalog-priority.js +61 -0
- package/dist/core/codex-app.js +30 -6
- package/dist/core/codex-compat/codex-hook-semantic-validator.js +1 -3
- package/dist/core/codex-control/codex-app-server-v2-client.js +39 -2
- package/dist/core/codex-lb/codex-lb-env.js +1 -3
- package/dist/core/codex-lb/codex-lb-tool-catalog.js +6 -1
- package/dist/core/codex-native/codex-native-feature-broker.js +2 -6
- package/dist/core/codex-native/codex-native-interop-policy.js +1 -3
- package/dist/core/codex-native/codex-native-reference-cache.js +1 -3
- package/dist/core/codex-native/codex-native-reference-source.js +1 -3
- package/dist/core/codex-native/codex-native-repair-transaction.js +1 -3
- package/dist/core/codex-native/core-skill-manifest.js +3 -2
- package/dist/core/codex-native/native-capability-repair-matrix.js +1 -3
- package/dist/core/codex-plugins/codex-plugin-repair.js +1 -3
- package/dist/core/codex-runtime/codex-desktop-config-policy.js +4 -4
- package/dist/core/commands/agent-bridge-command.js +24 -3
- package/dist/core/commands/image-ux-review-command.js +5 -11
- package/dist/core/commands/menubar-command.js +1 -1
- package/dist/core/commands/naruto-command.js +40 -13
- package/dist/core/commands/pipeline-command.js +5 -2
- package/dist/core/commands/release-command.js +63 -1
- package/dist/core/commands/remote-command.js +18 -0
- package/dist/core/commands/search-command.js +151 -0
- package/dist/core/commands/telegram-command.js +251 -108
- package/dist/core/commands/uninstall-command.js +1 -1
- package/dist/core/config/secret-preservation.js +1 -3
- package/dist/core/context7-client.js +2 -1
- package/dist/core/db-review.js +704 -0
- package/dist/core/db-safety.js +17 -23
- package/dist/core/doctor/browser-use-repair.js +1 -3
- package/dist/core/doctor/codex-startup-config-repair.js +1 -3
- package/dist/core/doctor/computer-use-repair.js +1 -3
- package/dist/core/doctor/context7-mcp-repair.js +1 -3
- package/dist/core/doctor/current-project-guidance.js +1 -3
- package/dist/core/doctor/doctor-codex-startup-repair.js +1 -3
- package/dist/core/doctor/doctor-dirty-planner.js +2 -2
- package/dist/core/doctor/doctor-native-capability-repair.js +1 -3
- package/dist/core/doctor/doctor-transaction.js +1 -3
- package/dist/core/doctor/imagegen-repair.js +1 -3
- package/dist/core/doctor/legacy-global-hook-cleanup.js +1 -3
- package/dist/core/doctor/mcp-transport-collision-repair.js +1 -3
- package/dist/core/doctor/retired-managed-residue-private.js +1 -3
- package/dist/core/doctor/supabase-mcp-repair.js +1 -3
- package/dist/core/engineering-sanity-review.js +186 -0
- package/dist/core/errors/message.js +3 -0
- package/dist/core/evidence/evidence-schema.js +1 -3
- package/dist/core/feature-fixtures.js +1 -0
- package/dist/core/feature-registry.js +1 -3
- package/dist/core/fsx.js +13 -0
- package/dist/core/git-hygiene/shared-memory-publish.js +1 -3
- package/dist/core/git-hygiene/validators.js +1 -3
- package/dist/core/harness-guard.js +21 -3
- package/dist/core/hooks-runtime/hook-context.js +2 -2
- package/dist/core/image-ux-review/imagegen-adapter.js +52 -56
- package/dist/core/image-ux-review/real-callout-extractor.js +6 -1
- package/dist/core/image-ux-review.js +3 -5
- package/dist/core/imagegen/codex-lb-imagegen-target.js +70 -0
- package/dist/core/imagegen/imagegen-capability.js +11 -11
- package/dist/core/imagegen/imagegen-evidence.js +32 -0
- package/dist/core/init/skills.js +9 -11
- package/dist/core/init.js +4 -6
- package/dist/core/json/records.js +9 -0
- package/dist/core/json-schema-validator.js +1 -3
- package/dist/core/lean-engineering-policy.js +54 -0
- package/dist/core/loops/loop-continuation-enforcer.js +1 -3
- package/dist/core/mad-sks/sql-plane/mcp-executor.js +2 -1
- package/dist/core/mad-sks/sql-plane/policy.js +2 -1
- package/dist/core/managed-assets/managed-assets-manifest.js +4 -3
- package/dist/core/mcp-config/codex-cli-adapter.js +1 -3
- package/dist/core/mcp-config/config-reader.js +2 -3
- package/dist/core/mcp-config/guarded-patch.js +1 -1
- package/dist/core/mcp-config/health-check.js +2 -1
- package/dist/core/mcp-config/mutation.js +1 -1
- package/dist/core/mcp-config/restore.js +1 -1
- package/dist/core/mcp-config/secret-policy.js +1 -3
- package/dist/core/migration/migration-transaction-journal.js +3 -3
- package/dist/core/naruto/naruto-concurrency-governor.js +2 -2
- package/dist/core/perf/import-graph-budget.js +91 -1
- package/dist/core/pipeline/pipeline-plan-writer.js +1 -1
- package/dist/core/pipeline-internals/runtime-core.js +121 -23
- package/dist/core/pipeline-internals/runtime-gates.js +193 -4
- package/dist/core/pipeline.js +1 -1
- package/dist/core/ppt-review/slide-imagegen-review.js +7 -7
- package/dist/core/ppt.js +3 -3
- package/dist/core/product-design-app-server.js +2 -1
- package/dist/core/proof/fake-real-proof-policy.js +1 -3
- package/dist/core/proof/root-cause-policy.js +1 -3
- package/dist/core/proof/validation.js +1 -3
- package/dist/core/provider/model-router.js +4 -0
- package/dist/core/provider/provider-context.js +1 -3
- package/dist/core/providers/openrouter/openrouter-account.js +1 -3
- package/dist/core/quality/helper-dedup.js +0 -0
- package/dist/core/recallpulse.js +1 -1
- package/dist/core/release/file-ownership.js +26 -17
- package/dist/core/release/macos-menubar-proof.js +59 -1
- package/dist/core/release/main-push-guard.js +288 -24
- package/dist/core/release/main-push-receipt.js +10 -45
- package/dist/core/release/package-size-budget.js +1 -1
- package/dist/core/release/release-gate-contract.js +2 -0
- package/dist/core/release/release-pack-receipt.js +1 -1
- package/dist/core/release/release-proof-io.js +33 -0
- package/dist/core/release/release-upgrade-baseline.js +9 -0
- package/dist/core/release/runtime-script-pack-closure.js +153 -4
- package/dist/core/release/stage-publish.js +194 -0
- package/dist/core/remote/index.js +2 -0
- package/dist/core/remote/local-worker-client.js +35 -0
- package/dist/core/remote/machine-registry.js +18 -13
- package/dist/core/remote/owner-proof.js +1 -3
- package/dist/core/remote/protocol.js +1 -3
- package/dist/core/remote/readiness.js +1 -3
- package/dist/core/remote/session-binding.js +153 -0
- package/dist/core/remote/session-index.js +1 -3
- package/dist/core/remote/types.js +1 -0
- package/dist/core/remote/worker.js +228 -14
- package/dist/core/responses-stream.js +151 -0
- package/dist/core/routes/dollar-manifest-lite.js +1 -1
- package/dist/core/routes.js +8 -8
- package/dist/core/rust-accelerator.js +12 -2
- package/dist/core/safety/ssot-guard.js +1 -3
- package/dist/core/search/benchmark.js +358 -0
- package/dist/core/search/cache.js +65 -0
- package/dist/core/search/context.js +144 -0
- package/dist/core/search/doctor.js +74 -0
- package/dist/core/search/files.js +192 -0
- package/dist/core/search/index.js +5 -0
- package/dist/core/search/ipc.js +64 -0
- package/dist/core/search/provider.js +142 -0
- package/dist/core/search/rust-bridge.js +24 -0
- package/dist/core/search/structure.js +230 -0
- package/dist/core/search/symbol.js +272 -0
- package/dist/core/search/text.js +146 -0
- package/dist/core/search/types.js +22 -0
- package/dist/core/search/typescript-ls.js +215 -0
- package/dist/core/search-visibility/discovery.js +1 -3
- package/dist/core/skill-forge.js +1 -1
- package/dist/core/stop-gate/gate-evaluator.js +3 -3
- package/dist/core/stop-gate/stop-gate-check.js +1 -3
- package/dist/core/structured-output-adapter.js +62 -2
- package/dist/core/subagents/agent-catalog.js +56 -43
- package/dist/core/subagents/model-policy.js +17 -7
- package/dist/core/subagents/naruto-proof-projection.js +2 -6
- package/dist/core/subagents/official-subagent-config.js +1 -3
- package/dist/core/subagents/official-subagent-preparation.js +73 -10
- package/dist/core/subagents/official-subagent-prompt.js +85 -18
- package/dist/core/subagents/official-subagent-runner.js +10 -5
- package/dist/core/subagents/role-model-preferences.js +202 -44
- package/dist/core/subagents/subagent-evidence.js +1 -3
- package/dist/core/subagents/thread-budget.js +1 -1
- package/dist/core/subagents/triwiki-attention.js +1 -5
- package/dist/core/telegram/config.js +29 -12
- package/dist/core/telegram/hub.js +8 -2
- package/dist/core/telegram/index.js +2 -0
- package/dist/core/telegram/messages.js +8 -2
- package/dist/core/telegram/runtime-projection.js +8 -5
- package/dist/core/telegram/runtime.js +19 -9
- package/dist/core/telegram/service.js +181 -0
- package/dist/core/telegram/setup.js +220 -0
- package/dist/core/text/regex.js +3 -0
- package/dist/core/text/strings.js +6 -0
- package/dist/core/triwiki-wrongness/image-wrongness.js +1 -3
- package/dist/core/triwiki-wrongness/wrongness-ledger.js +1 -3
- package/dist/core/triwiki-wrongness/wrongness-proof-linker.js +1 -3
- package/dist/core/triwiki-wrongness/wrongness-retrieval.js +1 -3
- package/dist/core/triwiki-wrongness/wrongness-schema.js +1 -3
- package/dist/core/triwiki-wrongness/wrongness-trust-policy.js +1 -3
- package/dist/core/trust-kernel/completion-contract.js +1 -3
- package/dist/core/trust-kernel/route-contract.js +1 -3
- package/dist/core/update/update-migration-state.js +1 -3
- package/dist/core/update-check.js +20 -6
- package/dist/core/verification/diff-quality.js +3 -4
- package/dist/core/verification/impact-scan.js +36 -89
- package/dist/core/verification/mistake-rule-compiler.js +17 -4
- package/dist/core/version-manager.js +3 -20
- package/dist/core/version.js +1 -1
- package/dist/native/sks-menubar/Sources/ControlCenterWindowController.swift +23 -3
- package/dist/native/sks-menubar/Sources/ControlKit.swift +102 -0
- package/dist/native/sks-menubar/Sources/DiagnosticsViewController.swift +23 -11
- package/dist/native/sks-menubar/Sources/MCPServersViewController.swift +7 -3
- package/dist/native/sks-menubar/Sources/OperationCoordinator.swift +17 -1
- package/dist/native/sks-menubar/Sources/OverviewViewController.swift +22 -15
- package/dist/native/sks-menubar/Sources/ProcessClient.swift +15 -5
- package/dist/native/sks-menubar/Sources/ProvidersMultiProvider.swift +324 -0
- package/dist/native/sks-menubar/Sources/ProvidersOpenRouter.swift +154 -214
- package/dist/native/sks-menubar/Sources/ProvidersRoleModels.swift +252 -0
- package/dist/native/sks-menubar/Sources/ProvidersViewController.swift +77 -71
- package/dist/native/sks-menubar/Sources/RemoteTelegramViewController.swift +167 -51
- package/dist/native/sks-menubar/Sources/SettingsViewController.swift +14 -5
- package/dist/native/sks-menubar/Sources/SidebarItem.swift +15 -1
- package/dist/native/sks-menubar/Sources/StatusItemController.swift +2 -2
- package/dist/native/sks-menubar/Sources/UpdatesViewController.swift +16 -12
- package/dist/scripts/agent-guidance-dedup-check.js +23 -0
- package/dist/scripts/agent-message-bus-reader-check.js +1 -1
- package/dist/scripts/all-feature-deep-completion-check.js +1 -1
- package/dist/scripts/appshots-thread-attachment-discovery-check.js +1 -1
- package/dist/scripts/architecture-guard-check.js +1 -2
- package/dist/scripts/certificate-sla-check.js +1 -1
- package/dist/scripts/cli-output-consistency-check.js +1 -1
- package/dist/scripts/codex-0-134-runner-truth-check.js +1 -1
- package/dist/scripts/codex-0138-capability-artifact-check.js +1 -1
- package/dist/scripts/codex-0138-capability-check.js +1 -1
- package/dist/scripts/codex-0138-doctor-check.js +1 -1
- package/dist/scripts/codex-0138-feature-probes-check.js +1 -1
- package/dist/scripts/codex-0144-app-server-v2-check.js +1 -1
- package/dist/scripts/codex-0144-binary-identity-check.js +1 -1
- package/dist/scripts/codex-0144-capability-check.js +1 -1
- package/dist/scripts/codex-0144-core-real-probes-check.js +1 -1
- package/dist/scripts/codex-0144-manifest-check.js +1 -1
- package/dist/scripts/codex-0144-policy-check.js +1 -1
- package/dist/scripts/codex-0144-thread-store-check.js +1 -1
- package/dist/scripts/codex-agent-role-rich-content-check.js +2 -2
- package/dist/scripts/codex-agent-role-sync-check.js +2 -2
- package/dist/scripts/codex-agent-type-routing-check.js +2 -2
- package/dist/scripts/codex-app-execution-profile-check.js +2 -2
- package/dist/scripts/codex-app-handoff-check.js +1 -1
- package/dist/scripts/codex-app-handoff-launch-check.js +1 -1
- package/dist/scripts/codex-control-tool-output-continuity-audit-check.js +1 -1
- package/dist/scripts/codex-lb-fast-ui-preservation-check.js +1 -3
- package/dist/scripts/codex-native-feature-broker-blackbox.js +2 -2
- package/dist/scripts/codex-native-feature-broker-check.js +2 -2
- package/dist/scripts/{sks-3-1-6-directive-check-lib.js → codex-native-gate-lib.js} +5 -5
- package/dist/scripts/codex-native-harness-compat-check.js +2 -2
- package/dist/scripts/codex-native-hook-lifecycle-proof-check.js +2 -2
- package/dist/scripts/codex-plugin-app-template-policy-check.js +1 -1
- package/dist/scripts/codex-sdk-backend-router-check.js +1 -1
- package/dist/scripts/codex-sdk-capability-check.js +1 -1
- package/dist/scripts/context7-evidence-dedupe-check.js +1 -1
- package/dist/scripts/core-skill-card-schema-check.js +1 -1
- package/dist/scripts/core-skill-deployment-snapshot-check.js +1 -1
- package/dist/scripts/core-skill-heldout-validation-check.js +1 -1
- package/dist/scripts/core-skill-no-inference-optimizer-check.js +1 -1
- package/dist/scripts/core-skill-patch-check.js +1 -1
- package/dist/scripts/core-skill-route-runtime-integration-check.js +1 -1
- package/dist/scripts/current-command-surface-check.js +1 -1
- package/dist/scripts/current-surface-update-e2e-check.js +4 -1
- package/dist/scripts/current-upgrade-matrix-check.js +1 -1
- package/dist/scripts/dfix-fixture-check.js +1 -1
- package/dist/scripts/dfix-patch-handoff-check.js +1 -1
- package/dist/scripts/dfix-verification-check.js +1 -1
- package/dist/scripts/dfix-verification-recommendation-check.js +1 -1
- package/dist/scripts/docs-truthfulness-check.js +16 -3
- package/dist/scripts/doctor-codex-app-harness-check.js +2 -2
- package/dist/scripts/evidence-flagship-coverage-check.js +1 -1
- package/dist/scripts/{sks-1-18-gate-lib.js → gate-lib.js} +1 -1
- package/dist/scripts/gate-policy-audit-check.js +4 -1
- package/dist/scripts/git-worktree-checkpoint-check.js +1 -1
- package/dist/scripts/git-worktree-cross-rebase-check.js +1 -1
- package/dist/scripts/git-worktree-diff-envelope-check.js +1 -1
- package/dist/scripts/git-worktree-dirty-lock-check.js +1 -1
- package/dist/scripts/git-worktree-dirty-main-detection-check.js +1 -1
- package/dist/scripts/git-worktree-integration-primary-check.js +1 -1
- package/dist/scripts/git-worktree-manifest-append-check.js +1 -1
- package/dist/scripts/git-worktree-untracked-diff-check.js +1 -1
- package/dist/scripts/harness-benchmark-check.js +1 -1
- package/dist/scripts/helper-dedup-check.js +62 -0
- package/dist/scripts/hook-latency-budget-check.js +1 -1
- package/dist/scripts/image-artifact-path-contract-check.js +1 -1
- package/dist/scripts/imagegen-real-smoke-check.js +2 -5
- package/dist/scripts/installed-package-smoke-check.js +1 -1
- package/dist/scripts/legacy-gate-inventory-check.js +1 -1
- package/dist/scripts/legacy-gate-purge-check.js +1 -1
- package/dist/scripts/legacy-strong-inventory-check.js +1 -1
- package/dist/scripts/lib/codex-sdk-gate-lib.js +1 -1
- package/dist/scripts/mad-sks-launch-sql-plane-boundary-check.js +1 -1
- package/dist/scripts/mad-sks-sql-plane-capability-check.js +1 -1
- package/dist/scripts/mad-sks-sql-plane-lifecycle-hook-decision-check.js +1 -1
- package/dist/scripts/mad-sks-sql-plane-result-lifecycle-check.js +1 -1
- package/dist/scripts/managed-config-merge-check.js +1 -1
- package/dist/scripts/mcp-plugin-inventory-check.js +1 -1
- package/dist/scripts/model-call-concurrency-check.js +1 -1
- package/dist/scripts/mutation-callsite-coverage-check.js +1 -1
- package/dist/scripts/naruto-ssot-gate-aliases-check.js +1 -1
- package/dist/scripts/naruto-ssot-pipeline-default-check.js +1 -1
- package/dist/scripts/naruto-ssot-route-normalization-check.js +1 -1
- package/dist/scripts/naruto-ssot-routing-check.js +1 -1
- package/dist/scripts/naruto-worktree-coding-blackbox.js +1 -1
- package/dist/scripts/native-capability-repair-matrix-check.js +1 -1
- package/dist/scripts/native-image-generation-repair-check.js +1 -1
- package/dist/scripts/official-subagent-workflow-check.js +3 -3
- package/dist/scripts/package-published-contract-check.js +37 -4
- package/dist/scripts/packlist-performance-check.js +17 -1
- package/dist/scripts/pipeline-codex-native-doctor-mad-routing-real-blackbox.js +1 -3
- package/dist/scripts/ppt-real-export-adapter-check.js +1 -1
- package/dist/scripts/ppt-real-imagegen-wiring-check.js +1 -1
- package/dist/scripts/ppt-reexport-rereview-check.js +1 -1
- package/dist/scripts/prepublish-fast-check.js +1 -1
- package/dist/scripts/probe-memoization-check.js +2 -2
- package/dist/scripts/prompt-placeholder-guard-check.js +1 -1
- package/dist/scripts/qa-loop-app-handoff-capability-check.js +1 -1
- package/dist/scripts/qa-loop-app-handoff-check.js +1 -1
- package/dist/scripts/qa-loop-app-handoff-cli-check.js +1 -1
- package/dist/scripts/qa-loop-app-handoff-confirmation-check.js +1 -1
- package/dist/scripts/qa-loop-app-handoff-gate-lifecycle-check.js +1 -1
- package/dist/scripts/qa-loop-app-handoff-launch-check.js +1 -1
- package/dist/scripts/qa-loop-app-handoff-status-lifecycle-check.js +1 -1
- package/dist/scripts/qa-loop-budget-policy-check.js +1 -1
- package/dist/scripts/qa-loop-effort-escalation-check.js +1 -1
- package/dist/scripts/qa-loop-execution-profile-routing-check.js +2 -2
- package/dist/scripts/qa-loop-image-path-exposure-check.js +1 -1
- package/dist/scripts/qa-loop-image-path-prompt-injection-check.js +1 -1
- package/dist/scripts/{sks-1-12-real-execution-check-lib.js → real-execution-check-lib.js} +1 -1
- package/dist/scripts/release-affected-selector-check.js +1 -1
- package/dist/scripts/release-aggressive-resource-governor-check.js +1 -1
- package/dist/scripts/release-cache-glob-hashing-check.js +1 -1
- package/dist/scripts/release-cache-input-classifier-check.js +1 -1
- package/dist/scripts/release-cache-neutralization-report-check.js +1 -1
- package/dist/scripts/release-cache-version-neutral-fixture-check.js +1 -1
- package/dist/scripts/release-dynamic-presets-check.js +2 -2
- package/dist/scripts/release-full-parallelism-blackbox.js +1 -1
- package/dist/scripts/release-gate-batch-runner-check.js +1 -1
- package/dist/scripts/release-gate-budget-check.js +1 -1
- package/dist/scripts/release-gate-dag-runner-check.js +1 -1
- package/dist/scripts/release-latency-slo-check.js +1 -1
- package/dist/scripts/release-metadata-check.js +256 -2
- package/dist/scripts/release-parallel-speed-budget-check.js +1 -1
- package/dist/scripts/release-proof-truth-check.js +1 -1
- package/dist/scripts/release-provenance-check.js +4 -2
- package/dist/scripts/release-runtime-truth-matrix-check.js +1 -1
- package/dist/scripts/research-blueprint-densifier-check.js +1 -1
- package/dist/scripts/research-claim-builder-check.js +1 -1
- package/dist/scripts/research-complete-package-fixture-check.js +1 -1
- package/dist/scripts/research-execution-profile-routing-check.js +2 -2
- package/dist/scripts/research-final-reviewer-blackbox.js +1 -1
- package/dist/scripts/{sks-3-1-4-directive-check-lib.js → runtime-domain-gate-lib.js} +2 -2
- package/dist/scripts/runtime-proof-summary-check.js +1 -1
- package/dist/scripts/runtime-script-pack-closure-check.js +7 -1
- package/dist/scripts/scheduler-batch-dispatch-check.js +1 -1
- package/dist/scripts/scheduler-parallel-proof-consistency-check.js +1 -1
- package/dist/scripts/scheduler-utilization-integral-check.js +1 -1
- package/dist/scripts/search-visibility-gate-lib.js +1 -1
- package/dist/scripts/secret-preservation-check.js +1 -1
- package/dist/scripts/seo-geo-geo-disambiguation-check.js +1 -1
- package/dist/scripts/seo-geo-skill-rich-content-check.js +1 -1
- package/dist/scripts/side-effect-runtime-report-check.js +1 -1
- package/dist/scripts/{sks-3-1-8-check-lib.js → skill-fixture-check-lib.js} +1 -1
- package/dist/scripts/skill-name-canonicalizer-check.js +1 -1
- package/dist/scripts/skills-manifest-continuity-check.js +1 -1
- package/dist/scripts/sks-uninstall-regression-check.js +1 -1
- package/dist/scripts/sksd-daemon-check.js +1 -1
- package/dist/scripts/super-search-provider-interface-check.js +1 -1
- package/dist/scripts/triwiki-cache-key-check.js +1 -1
- package/dist/scripts/triwiki-proof-bank-blackbox.js +2 -2
- package/dist/scripts/triwiki-proof-bank-check.js +1 -1
- package/dist/scripts/triwiki-proof-card-check.js +1 -1
- package/dist/scripts/type-surface-codex-app-check.js +2 -2
- package/dist/scripts/{sks-3-1-5-directive-check-lib.js → typed-routing-gate-lib.js} +2 -2
- package/dist/scripts/ultra-router-auto-router-check.js +1 -1
- package/dist/scripts/ux-review-extract-wires-real-extractor-check.js +1 -1
- package/dist/scripts/ux-review-patch-diff-recheck-check.js +1 -1
- package/dist/scripts/ux-review-run-wires-imagegen-check.js +9 -2
- package/package.json +5 -7
- package/release-gates.v2.json +66 -11
- package/runtime-required-scripts.json +138 -14
- package/config/bench-baseline.json +0 -7
- package/dist/core/codex-app/sks-menubar.js +0 -1
- package/dist/core/release/release-closure-contract.js +0 -30
- package/dist/core/release/release-closure-helpers.js +0 -293
- package/dist/core/release/release-closure-validation.js +0 -284
- package/dist/core/release/release-closure.js +0 -163
- package/dist/scripts/build-dist.js +0 -124
- package/dist/scripts/build-once-runner-check.js +0 -6
- package/dist/scripts/canonical-test-runner.js +0 -234
- package/dist/scripts/changelog-check.js +0 -45
- package/dist/scripts/check-architecture.js +0 -295
- package/dist/scripts/check-cli-entrypoint.js +0 -41
- package/dist/scripts/check-command-module-budget.js +0 -77
- package/dist/scripts/check-feature-quality.js +0 -51
- package/dist/scripts/check-legacy-free.js +0 -64
- package/dist/scripts/check-pipeline-budget.js +0 -49
- package/dist/scripts/check-pipeline-runtime.js +0 -16
- package/dist/scripts/check-publish-tag.js +0 -56
- package/dist/scripts/check-route-modularity.js +0 -72
- package/dist/scripts/codex-0140-capability-check.js +0 -14
- package/dist/scripts/codex-0140-feature-probes-check.js +0 -23
- package/dist/scripts/codex-permission-profiles-check.js +0 -34
- package/dist/scripts/codex-project-config-policy-splitter-check.js +0 -49
- package/dist/scripts/competitor-scorecard-check.js +0 -24
- package/dist/scripts/core-skill-no-drift-check.js +0 -23
- package/dist/scripts/db-route-materialization-check.js +0 -32
- package/dist/scripts/doctor-context7-mcp-repair-blackbox.js +0 -15
- package/dist/scripts/doctor-fastpath-check.js +0 -25
- package/dist/scripts/doctor-fix-production-blackbox.js +0 -35
- package/dist/scripts/doctor-idempotence-check.js +0 -6
- package/dist/scripts/doctor-ops-semantics-check.js +0 -83
- package/dist/scripts/doctor-startup-config-repair-blackbox.js +0 -18
- package/dist/scripts/doctor-supabase-mcp-repair-blackbox.js +0 -13
- package/dist/scripts/ensure-bin-executable.js +0 -16
- package/dist/scripts/fsx-hotpath-check.js +0 -9
- package/dist/scripts/high-risk-contracts-check.js +0 -183
- package/dist/scripts/hook-latency-quantum-check.js +0 -120
- package/dist/scripts/import-graph-budget-check.js +0 -9
- package/dist/scripts/mcp-tool-naming-parity-check.js +0 -14
- package/dist/scripts/naruto-codex-e2e-check.js +0 -105
- package/dist/scripts/naruto-write-e2e-check.js +0 -31
- package/dist/scripts/native-capability-postcheck-check.js +0 -16
- package/dist/scripts/ops-diagnostics-bundle-check.js +0 -11
- package/dist/scripts/parallel-production-smoke-check.js +0 -20
- package/dist/scripts/perf-budget-check.js +0 -12
- package/dist/scripts/project-skill-dedupe-blackbox.js +0 -62
- package/dist/scripts/release-dag-full-coverage-check.js +0 -98
- package/dist/scripts/release-dist-freshness-check.js +0 -6
- package/dist/scripts/release-file-ownership-check.js +0 -35
- package/dist/scripts/release-gate-script-parity-check.js +0 -148
- package/dist/scripts/release-macos-menubar-proof.js +0 -167
- package/dist/scripts/release-main-push-guard.js +0 -37
- package/dist/scripts/release-main-push-receipt.js +0 -43
- package/dist/scripts/release-metadata-1-19-check.js +0 -257
- package/dist/scripts/release-version-truth-check.js +0 -138
- package/dist/scripts/retention-apply-smoke-check.js +0 -19
- package/dist/scripts/retention-budget-check.js +0 -6
- package/dist/scripts/retention-dry-run-check.js +0 -8
- package/dist/scripts/rollback-recovery-smoke-check.js +0 -70
- package/dist/scripts/route-intent-regression-check.js +0 -42
- package/dist/scripts/runtime-current-terminal-check.js +0 -108
- package/dist/scripts/runtime-dist-parity-check.js +0 -76
- package/dist/scripts/runtime-no-src-mjs-check.js +0 -30
- package/dist/scripts/runtime-ts-rust-boundary-check.js +0 -58
- package/dist/scripts/runtime-ts-source-of-truth-check.js +0 -53
- package/dist/scripts/secret-preservation-guard-check.js +0 -36
- package/dist/scripts/seo-marketing-truthfulness-check.js +0 -98
- package/dist/scripts/seo-metadata-sync-check.js +0 -60
- package/dist/scripts/sizecheck.js +0 -148
- package/dist/scripts/sks-menubar-install-check.js +0 -333
- package/dist/scripts/supabase-secret-preservation-blackbox.js +0 -28
- package/dist/scripts/super-search-live-smoke-check.js +0 -115
- package/dist/scripts/super-search-local-http-smoke-check.js +0 -16
- package/dist/scripts/super-search-offline-contract-check.js +0 -43
- package/dist/scripts/update-fastpath-check.js +0 -28
- package/dist/scripts/update-preserves-supabase-keys-blackbox.js +0 -26
- package/dist/scripts/upgrade-migration-matrix-check.js +0 -351
- package/dist/scripts/write-build-manifest.js +0 -70
- package/dist/scripts/zellij-capability-check.js +0 -13
- package/dist/scripts/zellij-developer-controls-check.js +0 -16
- package/dist/scripts/zellij-doctor-readiness-check.js +0 -49
- package/dist/scripts/zellij-dynamic-pane-lifecycle-check.js +0 -19
- package/dist/scripts/zellij-fake-adapter-check.js +0 -31
- package/dist/scripts/zellij-first-slot-down-stack-check.js +0 -20
- package/dist/scripts/zellij-first-slot-down-stack-real-check.js +0 -348
- package/dist/scripts/zellij-homebrew-policy-check.js +0 -3
- package/dist/scripts/zellij-initial-main-only-blackbox.js +0 -21
- package/dist/scripts/zellij-lane-renderer-check.js +0 -78
- package/dist/scripts/zellij-launch-command-truth-check.js +0 -62
- package/dist/scripts/zellij-layout-valid-check.js +0 -120
- package/dist/scripts/zellij-pane-creation-lock-metrics-check.js +0 -10
- package/dist/scripts/zellij-pane-lock-concurrency-blackbox.js +0 -78
- package/dist/scripts/zellij-pane-lock-does-not-block-worker-check.js +0 -12
- package/dist/scripts/zellij-pane-lock-open-worker-integration-blackbox.js +0 -134
- package/dist/scripts/zellij-qa-app-handoff-status-check.js +0 -7
- package/dist/scripts/zellij-right-column-geometry-proof.js +0 -158
- package/dist/scripts/zellij-right-column-headless-overflow-check.js +0 -20
- package/dist/scripts/zellij-right-column-manager-check.js +0 -24
- package/dist/scripts/zellij-self-heal-check.js +0 -3
- package/dist/scripts/zellij-self-heal-dry-run-check.js +0 -3
- package/dist/scripts/zellij-self-heal-status-contract-check.js +0 -3
- package/dist/scripts/zellij-self-heal-typed-blackbox.js +0 -3
- package/dist/scripts/zellij-slot-column-anchor-check.js +0 -65
- package/dist/scripts/zellij-slot-column-anchor-telemetry-check.js +0 -8
- package/dist/scripts/zellij-slot-only-ui-check.js +0 -29
- package/dist/scripts/zellij-slot-pane-renderer-check.js +0 -149
- package/dist/scripts/zellij-slot-pane-stale-detection-check.js +0 -65
- package/dist/scripts/zellij-slot-pane-telemetry-renderer-check.js +0 -11
- package/dist/scripts/zellij-slot-renderer-proof-semantics-check.js +0 -58
- package/dist/scripts/zellij-slot-telemetry-check.js +0 -38
- package/dist/scripts/zellij-slot-telemetry-incremental-check.js +0 -46
- package/dist/scripts/zellij-slot-telemetry-live-flush-check.js +0 -55
- package/dist/scripts/zellij-slot-telemetry-performance-check.js +0 -32
- package/dist/scripts/zellij-slot-telemetry-real-blackbox.js +0 -19
- package/dist/scripts/zellij-slot-telemetry-renderer-check.js +0 -11
- package/dist/scripts/zellij-slot-telemetry-runtime-check.js +0 -23
- package/dist/scripts/zellij-spawn-on-demand-layout-check.js +0 -45
- package/dist/scripts/zellij-stacked-capability-routing-check.js +0 -9
- package/dist/scripts/zellij-stacked-fallback-integration-blackbox.js +0 -78
- package/dist/scripts/zellij-stacked-version-matrix-check.js +0 -29
- package/dist/scripts/zellij-stacked-version-parser-check.js +0 -19
- package/dist/scripts/zellij-ui-design-check.js +0 -92
- package/dist/scripts/zellij-update-missing-self-heal-check.js +0 -3
- package/dist/scripts/zellij-update-prompt-matrix-check.js +0 -16
- package/dist/scripts/zellij-update-prompt-mode-check.js +0 -18
- package/dist/scripts/zellij-update-prompt-safety-check.js +0 -8
- package/dist/scripts/zellij-worker-pane-manager-check.js +0 -108
- package/dist/scripts/zellij-worker-pane-manager-single-owner-check.js +0 -47
- package/dist/scripts/zellij-worker-pane-real-ui-blackbox.js +0 -199
- /package/dist/scripts/{sks-1-11-gate-lib.js → sks-cli-gate-lib.js} +0 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import fsp from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { nowIso, readJson, writeJsonAtomic } from '../fsx.js';
|
|
4
|
+
import { withFileLock } from '../locks/file-lock.js';
|
|
5
|
+
import { REMOTE_CODEX_SESSION_BINDINGS_SCHEMA } from './types.js';
|
|
6
|
+
const IDENTIFIER_RE = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,159}$/;
|
|
7
|
+
const THREAD_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,199}$/;
|
|
8
|
+
export function remoteCodexSessionBindingsPath(projectRoot) {
|
|
9
|
+
return path.join(path.resolve(projectRoot), '.sneakoscope', 'remote', 'codex-session-bindings.json');
|
|
10
|
+
}
|
|
11
|
+
export class RemoteCodexSessionBindingStore {
|
|
12
|
+
file;
|
|
13
|
+
lockPath;
|
|
14
|
+
constructor(file) {
|
|
15
|
+
this.file = path.resolve(file);
|
|
16
|
+
this.lockPath = `${this.file}.lock`;
|
|
17
|
+
}
|
|
18
|
+
async list() {
|
|
19
|
+
const value = await readJson(this.file, {
|
|
20
|
+
schema: REMOTE_CODEX_SESSION_BINDINGS_SCHEMA,
|
|
21
|
+
bindings: []
|
|
22
|
+
});
|
|
23
|
+
if (value.schema !== REMOTE_CODEX_SESSION_BINDINGS_SCHEMA || !Array.isArray(value.bindings)) {
|
|
24
|
+
throw new Error('remote_codex_session_bindings_invalid');
|
|
25
|
+
}
|
|
26
|
+
return value.bindings.map(validateBinding);
|
|
27
|
+
}
|
|
28
|
+
async find(sessionId) {
|
|
29
|
+
return (await this.list()).find((binding) => binding.session_id === sessionId) ?? null;
|
|
30
|
+
}
|
|
31
|
+
async upsert(input) {
|
|
32
|
+
return withFileLock({ lockPath: this.lockPath, timeoutMs: 5_000, staleMs: 30_000 }, async () => {
|
|
33
|
+
const bindings = await this.list();
|
|
34
|
+
const index = bindings.findIndex((binding) => binding.session_id === input.session_id);
|
|
35
|
+
const current = index >= 0 ? bindings[index] : null;
|
|
36
|
+
const at = nowIso();
|
|
37
|
+
const next = validateBinding({
|
|
38
|
+
...input,
|
|
39
|
+
created_at: input.created_at ?? current?.created_at ?? at,
|
|
40
|
+
updated_at: at
|
|
41
|
+
});
|
|
42
|
+
if (current && (current.machine_id !== next.machine_id
|
|
43
|
+
|| current.project_id !== next.project_id
|
|
44
|
+
|| path.resolve(current.project_root) !== path.resolve(next.project_root))) {
|
|
45
|
+
throw new Error('remote_codex_session_binding_scope_conflict');
|
|
46
|
+
}
|
|
47
|
+
if (index >= 0)
|
|
48
|
+
bindings[index] = next;
|
|
49
|
+
else
|
|
50
|
+
bindings.push(next);
|
|
51
|
+
await writeJsonAtomic(this.file, {
|
|
52
|
+
schema: REMOTE_CODEX_SESSION_BINDINGS_SCHEMA,
|
|
53
|
+
bindings
|
|
54
|
+
});
|
|
55
|
+
await fsp.chmod(this.file, 0o600).catch(() => undefined);
|
|
56
|
+
return next;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async updateTurn(sessionId, turnId, status) {
|
|
60
|
+
const current = await this.find(sessionId);
|
|
61
|
+
if (!current)
|
|
62
|
+
throw new Error(`remote_codex_session_binding_unknown:${sessionId}`);
|
|
63
|
+
if (!current.codex_thread_id)
|
|
64
|
+
throw new Error(`remote_codex_session_binding_thread_pending:${sessionId}`);
|
|
65
|
+
return this.recordTurn(sessionId, current.codex_thread_id, turnId, status);
|
|
66
|
+
}
|
|
67
|
+
async recordTurn(sessionId, codexThreadId, turnId, status) {
|
|
68
|
+
const current = await this.find(sessionId);
|
|
69
|
+
if (!current)
|
|
70
|
+
throw new Error(`remote_codex_session_binding_unknown:${sessionId}`);
|
|
71
|
+
return this.upsert({
|
|
72
|
+
...current,
|
|
73
|
+
codex_thread_id: codexThreadId,
|
|
74
|
+
last_turn_id: turnId,
|
|
75
|
+
last_turn_status: status
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export function remoteCodexBindingSessionRow(binding) {
|
|
80
|
+
const threadReady = Boolean(binding.codex_thread_id);
|
|
81
|
+
return {
|
|
82
|
+
session_id: binding.session_id,
|
|
83
|
+
mission_id: null,
|
|
84
|
+
route: 'telegram-codex',
|
|
85
|
+
phase: binding.last_turn_status === 'failed' ? 'BLOCKED' : 'READY',
|
|
86
|
+
generation: 1,
|
|
87
|
+
updated_at: binding.updated_at,
|
|
88
|
+
session_state: threadReady ? 'idle' : 'pending_first_turn',
|
|
89
|
+
codex_thread_id: binding.codex_thread_id,
|
|
90
|
+
codex_thread_state: threadReady ? 'ready' : 'pending_first_turn',
|
|
91
|
+
dedicated_telegram_thread: true
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export async function readRemoteCodexBindingSnapshot(binding) {
|
|
95
|
+
const threadReady = Boolean(binding.codex_thread_id);
|
|
96
|
+
const branch = await import('../fsx.js').then(({ runProcess }) => runProcess('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { cwd: binding.project_root, timeoutMs: 5_000, maxOutputBytes: 8 * 1024 })).catch(() => null);
|
|
97
|
+
return {
|
|
98
|
+
schema: 'sks.remote-session-snapshot.v1',
|
|
99
|
+
machine_id: binding.machine_id,
|
|
100
|
+
project_id: binding.project_id,
|
|
101
|
+
session_id: binding.session_id,
|
|
102
|
+
mission_id: null,
|
|
103
|
+
route: 'telegram-codex',
|
|
104
|
+
phase: binding.last_turn_status === 'failed' ? 'BLOCKED' : 'READY',
|
|
105
|
+
generation: 1,
|
|
106
|
+
updated_at: binding.updated_at,
|
|
107
|
+
project: {
|
|
108
|
+
name: path.basename(binding.project_root),
|
|
109
|
+
branch: branch?.code === 0 ? String(branch.stdout || '').trim() || null : null
|
|
110
|
+
},
|
|
111
|
+
session_state: threadReady ? 'idle' : 'pending_first_turn',
|
|
112
|
+
execution_terminal: false,
|
|
113
|
+
completion_proof_status: 'not_applicable',
|
|
114
|
+
machine_gates_status: 'not_applicable',
|
|
115
|
+
machine_gates_pass: false,
|
|
116
|
+
trust_status: 'not_applicable',
|
|
117
|
+
completion_verified: false,
|
|
118
|
+
proof_paths: null,
|
|
119
|
+
codex_thread_id: binding.codex_thread_id,
|
|
120
|
+
codex_thread_state: threadReady ? 'ready' : 'pending_first_turn',
|
|
121
|
+
last_turn_id: binding.last_turn_id ?? null,
|
|
122
|
+
last_turn_status: binding.last_turn_status ?? null,
|
|
123
|
+
dedicated_telegram_thread: true
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function validateBinding(value) {
|
|
127
|
+
if (!value || typeof value !== 'object')
|
|
128
|
+
throw new Error('remote_codex_session_binding_object_required');
|
|
129
|
+
if (!IDENTIFIER_RE.test(String(value.session_id || '')))
|
|
130
|
+
throw new Error('remote_codex_session_binding_session_id_invalid');
|
|
131
|
+
if (!IDENTIFIER_RE.test(String(value.machine_id || '')))
|
|
132
|
+
throw new Error('remote_codex_session_binding_machine_id_invalid');
|
|
133
|
+
if (!IDENTIFIER_RE.test(String(value.project_id || '')))
|
|
134
|
+
throw new Error('remote_codex_session_binding_project_id_invalid');
|
|
135
|
+
if (!path.isAbsolute(String(value.project_root || '')))
|
|
136
|
+
throw new Error('remote_codex_session_binding_project_root_invalid');
|
|
137
|
+
if (value.codex_thread_id !== null && !THREAD_ID_RE.test(String(value.codex_thread_id || ''))) {
|
|
138
|
+
throw new Error('remote_codex_session_binding_thread_id_invalid');
|
|
139
|
+
}
|
|
140
|
+
if (!Number.isFinite(Date.parse(String(value.created_at || ''))))
|
|
141
|
+
throw new Error('remote_codex_session_binding_created_at_invalid');
|
|
142
|
+
if (!Number.isFinite(Date.parse(String(value.updated_at || ''))))
|
|
143
|
+
throw new Error('remote_codex_session_binding_updated_at_invalid');
|
|
144
|
+
if (value.last_turn_id && !THREAD_ID_RE.test(value.last_turn_id))
|
|
145
|
+
throw new Error('remote_codex_session_binding_last_turn_id_invalid');
|
|
146
|
+
if (value.last_turn_status && !['completed', 'failed', 'interrupted'].includes(value.last_turn_status)) {
|
|
147
|
+
throw new Error('remote_codex_session_binding_last_turn_status_invalid');
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
...value,
|
|
151
|
+
project_root: path.resolve(value.project_root)
|
|
152
|
+
};
|
|
153
|
+
}
|
|
@@ -2,6 +2,7 @@ import path from 'node:path';
|
|
|
2
2
|
import { readJson } from '../fsx.js';
|
|
3
3
|
import { findRemoteMachine, isLexicallyWithinAllowedRoot } from './machine-registry.js';
|
|
4
4
|
import { REMOTE_SESSION_INDEX_SCHEMA } from './types.js';
|
|
5
|
+
import { asRecordOrNull as asRecord } from '../json/records.js';
|
|
5
6
|
const IDENTIFIER_RE = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,159}$/;
|
|
6
7
|
export function remoteSessionIndexPath(projectRoot) {
|
|
7
8
|
return path.join(path.resolve(projectRoot), '.sneakoscope', 'remote', 'session-index.json');
|
|
@@ -68,9 +69,6 @@ export function findRemoteSessionTarget(index, machineId, projectId) {
|
|
|
68
69
|
throw new Error(`remote_session_target_unknown:${machineId}:${projectId}`);
|
|
69
70
|
return target;
|
|
70
71
|
}
|
|
71
|
-
function asRecord(value) {
|
|
72
|
-
return value !== null && typeof value === 'object' && !Array.isArray(value) ? value : null;
|
|
73
|
-
}
|
|
74
72
|
function stringValue(value) {
|
|
75
73
|
return typeof value === 'string' ? value.trim() : '';
|
|
76
74
|
}
|
|
@@ -8,3 +8,4 @@ export const REMOTE_OWNER_PROOF_SCHEMA = 'sks.remote-owner-proof.v1';
|
|
|
8
8
|
export const REMOTE_R2_APPROVAL_SCHEMA = 'sks.remote-r2-approval.v1';
|
|
9
9
|
export const REMOTE_EVENT_SCHEMA = 'sks.remote-event.v1';
|
|
10
10
|
export const REMOTE_SESSION_INDEX_SCHEMA = 'sks.remote-session-index.v1';
|
|
11
|
+
export const REMOTE_CODEX_SESSION_BINDINGS_SCHEMA = 'sks.remote-codex-session-bindings.v1';
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
1
2
|
import fsp from 'node:fs/promises';
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import { createCodexAppServerV2Client } from '../codex-control/codex-app-server-v2-client.js';
|
|
4
5
|
import { RemoteAuditLog, RemoteCommandLedger, RemoteEventJournal, remoteRuntimePaths } from './audit-idempotency.js';
|
|
5
6
|
import { cancelOwnedSession, parseRemoteCancelPayload, RemoteOwnerProofError, RemoteOwnerProofStore } from './owner-proof.js';
|
|
6
7
|
import { RemoteProtocolError, workerErrorResponse, workerSuccessResponse } from './protocol.js';
|
|
8
|
+
import { RemoteCodexSessionBindingStore, readRemoteCodexBindingSnapshot, remoteCodexBindingSessionRow, remoteCodexSessionBindingsPath } from './session-binding.js';
|
|
7
9
|
import { listRemoteSessionRows, readRemoteSessionView, readRemoteSessionSnapshot, remoteSessionGeneration, remoteSessionRecord } from './session-snapshot.js';
|
|
8
10
|
import { REMOTE_COMMAND_RECEIPT_SCHEMA } from './types.js';
|
|
11
|
+
import { asRecordOrNull as asRecord } from '../json/records.js';
|
|
9
12
|
export class RemoteWorkerExecutionError extends Error {
|
|
10
13
|
code;
|
|
11
14
|
delivery;
|
|
12
15
|
retryable;
|
|
13
|
-
constructor(code, delivery = '
|
|
16
|
+
constructor(code, delivery = 'not_dispatched', retryable = false) {
|
|
14
17
|
super(code);
|
|
15
18
|
this.code = code;
|
|
16
19
|
this.delivery = delivery;
|
|
@@ -26,6 +29,7 @@ export class RemoteWorker {
|
|
|
26
29
|
audit;
|
|
27
30
|
events;
|
|
28
31
|
owners;
|
|
32
|
+
bindings;
|
|
29
33
|
codexClientFactory;
|
|
30
34
|
inspectProcess;
|
|
31
35
|
killProcess;
|
|
@@ -39,6 +43,7 @@ export class RemoteWorker {
|
|
|
39
43
|
this.audit = options.audit ?? new RemoteAuditLog(paths.audit);
|
|
40
44
|
this.events = options.events ?? new RemoteEventJournal(paths.events, { lockPath: paths.eventLock });
|
|
41
45
|
this.owners = options.owners ?? new RemoteOwnerProofStore(paths.owners);
|
|
46
|
+
this.bindings = options.bindings ?? new RemoteCodexSessionBindingStore(remoteCodexSessionBindingsPath(this.root));
|
|
42
47
|
this.codexClientFactory = options.codexClientFactory ?? defaultCodexClientFactory;
|
|
43
48
|
this.inspectProcess = options.inspectProcess;
|
|
44
49
|
this.killProcess = options.killProcess;
|
|
@@ -59,7 +64,22 @@ export class RemoteWorker {
|
|
|
59
64
|
});
|
|
60
65
|
}
|
|
61
66
|
if (request.type === 'list_sessions') {
|
|
62
|
-
|
|
67
|
+
const [sessions, bindings] = await Promise.all([
|
|
68
|
+
listRemoteSessionRows(this.root),
|
|
69
|
+
this.bindings.list()
|
|
70
|
+
]);
|
|
71
|
+
const bindingRows = [];
|
|
72
|
+
for (const binding of bindings) {
|
|
73
|
+
try {
|
|
74
|
+
await this.assertCodexBinding(binding);
|
|
75
|
+
bindingRows.push(remoteCodexBindingSessionRow(binding));
|
|
76
|
+
}
|
|
77
|
+
catch { }
|
|
78
|
+
}
|
|
79
|
+
const bindingIds = new Set(bindingRows.map((row) => String(row.session_id)));
|
|
80
|
+
return workerSuccessResponse(request, {
|
|
81
|
+
sessions: [...bindingRows, ...sessions.filter((row) => !bindingIds.has(String(row.session_id)))]
|
|
82
|
+
});
|
|
63
83
|
}
|
|
64
84
|
if (request.type === 'read_snapshot') {
|
|
65
85
|
try {
|
|
@@ -158,7 +178,7 @@ export class RemoteWorker {
|
|
|
158
178
|
session_id: envelope.session_id,
|
|
159
179
|
kind: envelope.kind,
|
|
160
180
|
status: 'failed',
|
|
161
|
-
side_effect_applied: false,
|
|
181
|
+
side_effect_applied: executionError.delivery === 'not_dispatched' ? false : 'unknown',
|
|
162
182
|
completed_at: new Date(this.now()).toISOString(),
|
|
163
183
|
error: {
|
|
164
184
|
code: executionError.code,
|
|
@@ -204,20 +224,51 @@ export class RemoteWorker {
|
|
|
204
224
|
}
|
|
205
225
|
async executeCommand(envelope) {
|
|
206
226
|
if (envelope.kind === 'read') {
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
227
|
+
const binding = envelope.session_id ? await this.bindings.find(envelope.session_id) : null;
|
|
228
|
+
let result;
|
|
229
|
+
if (binding) {
|
|
230
|
+
await this.assertCodexBinding(binding);
|
|
231
|
+
result = {
|
|
232
|
+
...(await readRemoteCodexBindingSnapshot(binding)),
|
|
233
|
+
requested_view: String(envelope.payload.view ?? 'status')
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
result = envelope.session_id
|
|
238
|
+
? await readRemoteSessionView({
|
|
239
|
+
root: this.root,
|
|
240
|
+
machineId: this.machine.id,
|
|
241
|
+
projectId: this.projectId,
|
|
242
|
+
sessionId: envelope.session_id,
|
|
243
|
+
view: String(envelope.payload.view ?? 'status')
|
|
244
|
+
})
|
|
245
|
+
: { sessions: await listRemoteSessionRows(this.root) };
|
|
246
|
+
}
|
|
216
247
|
return { result, sideEffectApplied: false };
|
|
217
248
|
}
|
|
218
249
|
const sessionId = envelope.session_id;
|
|
219
250
|
if (!sessionId)
|
|
220
251
|
throw new RemoteWorkerExecutionError('command_session_id_required');
|
|
252
|
+
const binding = await this.bindings.find(sessionId);
|
|
253
|
+
if (binding) {
|
|
254
|
+
await this.assertCodexBinding(binding);
|
|
255
|
+
if (envelope.kind === 'verify') {
|
|
256
|
+
return {
|
|
257
|
+
result: { ...(await readRemoteCodexBindingSnapshot(binding)), requested_view: 'verify' },
|
|
258
|
+
sideEffectApplied: false
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
if (envelope.kind === 'input') {
|
|
262
|
+
const text = String(envelope.payload.text ?? '').trim();
|
|
263
|
+
if (!text || Buffer.byteLength(text) > 16 * 1024)
|
|
264
|
+
throw new RemoteWorkerExecutionError('input_text_invalid');
|
|
265
|
+
return {
|
|
266
|
+
result: await this.runDedicatedCodexTurn(binding, text),
|
|
267
|
+
sideEffectApplied: true
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
throw new RemoteWorkerExecutionError('dedicated_codex_cancel_unavailable');
|
|
271
|
+
}
|
|
221
272
|
const session = await remoteSessionRecord(this.root, sessionId).catch((err) => {
|
|
222
273
|
throw new RemoteWorkerExecutionError(errorMessage(err));
|
|
223
274
|
});
|
|
@@ -249,8 +300,11 @@ export class RemoteWorker {
|
|
|
249
300
|
});
|
|
250
301
|
try {
|
|
251
302
|
await client.initialize();
|
|
303
|
+
if (!client.steerTurn)
|
|
304
|
+
throw new Error('codex_turn_steer_unavailable');
|
|
252
305
|
await client.steerTurn({
|
|
253
306
|
threadId: owner.codex_thread_id,
|
|
307
|
+
clientUserMessageId: crypto.randomUUID(),
|
|
254
308
|
expectedTurnId: owner.active_turn_id,
|
|
255
309
|
input: [{ type: 'text', text, text_elements: [] }]
|
|
256
310
|
});
|
|
@@ -292,6 +346,11 @@ export class RemoteWorker {
|
|
|
292
346
|
throw new RemoteWorkerExecutionError('session_binding_generation_stale');
|
|
293
347
|
}
|
|
294
348
|
async prepareCancel(sessionId, commandId) {
|
|
349
|
+
const binding = await this.bindings.find(sessionId);
|
|
350
|
+
if (binding) {
|
|
351
|
+
await this.assertCodexBinding(binding);
|
|
352
|
+
throw new RemoteWorkerExecutionError('dedicated_codex_cancel_unavailable');
|
|
353
|
+
}
|
|
295
354
|
const session = await remoteSessionRecord(this.root, sessionId).catch((err) => {
|
|
296
355
|
throw new RemoteWorkerExecutionError(errorMessage(err));
|
|
297
356
|
});
|
|
@@ -312,6 +371,11 @@ export class RemoteWorker {
|
|
|
312
371
|
};
|
|
313
372
|
}
|
|
314
373
|
async readSnapshot(sessionId) {
|
|
374
|
+
const binding = await this.bindings.find(sessionId);
|
|
375
|
+
if (binding) {
|
|
376
|
+
await this.assertCodexBinding(binding);
|
|
377
|
+
return readRemoteCodexBindingSnapshot(binding);
|
|
378
|
+
}
|
|
315
379
|
return readRemoteSessionSnapshot({
|
|
316
380
|
root: this.root,
|
|
317
381
|
machineId: this.machine.id,
|
|
@@ -319,9 +383,151 @@ export class RemoteWorker {
|
|
|
319
383
|
sessionId
|
|
320
384
|
});
|
|
321
385
|
}
|
|
386
|
+
async assertCodexBinding(binding) {
|
|
387
|
+
if (binding.machine_id !== this.machine.id)
|
|
388
|
+
throw new RemoteWorkerExecutionError('session_binding_machine_mismatch');
|
|
389
|
+
if (binding.project_id !== this.projectId)
|
|
390
|
+
throw new RemoteWorkerExecutionError('session_binding_project_mismatch');
|
|
391
|
+
const [bindingRoot, workerRoot] = await Promise.all([
|
|
392
|
+
fsp.realpath(binding.project_root).catch(() => null),
|
|
393
|
+
fsp.realpath(this.root).catch(() => null)
|
|
394
|
+
]);
|
|
395
|
+
if (!bindingRoot || !workerRoot || bindingRoot !== workerRoot) {
|
|
396
|
+
throw new RemoteWorkerExecutionError('session_binding_root_mismatch');
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
async runDedicatedCodexTurn(binding, text) {
|
|
400
|
+
const client = await this.codexClientFactory(this.root).catch(() => {
|
|
401
|
+
throw new RemoteWorkerExecutionError('codex_app_server_unavailable', 'not_dispatched', true);
|
|
402
|
+
});
|
|
403
|
+
const threadWasPersisted = Boolean(binding.codex_thread_id);
|
|
404
|
+
let threadId = binding.codex_thread_id;
|
|
405
|
+
let turnId = null;
|
|
406
|
+
try {
|
|
407
|
+
await client.initialize();
|
|
408
|
+
if (!client.resumeThread || !client.startTurn || !client.readThread || !client.waitForTurnCompletion) {
|
|
409
|
+
throw new RemoteWorkerExecutionError('codex_app_server_session_api_unavailable', 'not_dispatched', false);
|
|
410
|
+
}
|
|
411
|
+
if (threadId) {
|
|
412
|
+
try {
|
|
413
|
+
const resumed = asRecord(await client.resumeThread({
|
|
414
|
+
threadId,
|
|
415
|
+
cwd: this.root,
|
|
416
|
+
approvalPolicy: 'never',
|
|
417
|
+
sandbox: 'workspace-write'
|
|
418
|
+
}));
|
|
419
|
+
const resumedThread = asRecord(resumed?.thread);
|
|
420
|
+
if (String(resumedThread?.id ?? '') !== threadId)
|
|
421
|
+
throw new Error('codex_thread_resume_mismatch');
|
|
422
|
+
const status = asRecord(resumedThread?.status);
|
|
423
|
+
const statusType = String(status?.type ?? '');
|
|
424
|
+
if (statusType === 'active') {
|
|
425
|
+
throw new RemoteWorkerExecutionError('codex_thread_busy', 'not_dispatched', true);
|
|
426
|
+
}
|
|
427
|
+
if (statusType !== 'idle') {
|
|
428
|
+
throw new RemoteWorkerExecutionError('codex_thread_not_ready', 'not_dispatched', true);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
catch (err) {
|
|
432
|
+
if (err instanceof RemoteWorkerExecutionError)
|
|
433
|
+
throw err;
|
|
434
|
+
const missingRollout = isMissingCodexRolloutError(err);
|
|
435
|
+
if (binding.last_turn_id) {
|
|
436
|
+
throw new RemoteWorkerExecutionError(missingRollout ? 'codex_thread_history_missing' : 'codex_thread_resume_failed', 'not_dispatched', !missingRollout);
|
|
437
|
+
}
|
|
438
|
+
if (!missingRollout) {
|
|
439
|
+
throw new RemoteWorkerExecutionError('codex_thread_resume_failed', 'not_dispatched', true);
|
|
440
|
+
}
|
|
441
|
+
threadId = null;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
if (!threadId) {
|
|
445
|
+
if (!client.startThread) {
|
|
446
|
+
throw new RemoteWorkerExecutionError('codex_app_server_session_api_unavailable', 'not_dispatched', false);
|
|
447
|
+
}
|
|
448
|
+
const started = asRecord(await client.startThread({
|
|
449
|
+
cwd: this.root,
|
|
450
|
+
approvalPolicy: 'never',
|
|
451
|
+
sandbox: 'workspace-write',
|
|
452
|
+
threadSource: 'sks-telegram',
|
|
453
|
+
baseInstructions: 'This is a dedicated private Telegram coding thread. Work only inside the configured project workspace, never expose secrets, and return a concise user-facing final response for each turn.'
|
|
454
|
+
}).catch(() => {
|
|
455
|
+
throw new RemoteWorkerExecutionError('codex_thread_start_failed', 'not_dispatched', true);
|
|
456
|
+
}));
|
|
457
|
+
threadId = stringValue(asRecord(started?.thread)?.id);
|
|
458
|
+
if (!threadId)
|
|
459
|
+
throw new Error('codex_thread_start_missing_id');
|
|
460
|
+
}
|
|
461
|
+
const started = asRecord(await client.startTurn({
|
|
462
|
+
threadId,
|
|
463
|
+
cwd: this.root,
|
|
464
|
+
approvalPolicy: 'never',
|
|
465
|
+
sandboxPolicy: {
|
|
466
|
+
type: 'workspaceWrite',
|
|
467
|
+
writableRoots: [this.root],
|
|
468
|
+
networkAccess: false
|
|
469
|
+
},
|
|
470
|
+
clientUserMessageId: crypto.randomUUID(),
|
|
471
|
+
input: [{ type: 'text', text, text_elements: [] }]
|
|
472
|
+
}));
|
|
473
|
+
turnId = stringValue(asRecord(started?.turn)?.id);
|
|
474
|
+
if (!turnId)
|
|
475
|
+
throw new Error('codex_turn_id_missing');
|
|
476
|
+
await client.waitForTurnCompletion(threadId, turnId, 30 * 60_000);
|
|
477
|
+
const read = asRecord(await client.readThread(threadId, true));
|
|
478
|
+
const thread = asRecord(read?.thread);
|
|
479
|
+
if (String(thread?.id ?? '') !== threadId)
|
|
480
|
+
throw new Error('codex_thread_read_mismatch');
|
|
481
|
+
const turns = Array.isArray(thread?.turns) ? thread.turns.map(asRecord).filter(Boolean) : [];
|
|
482
|
+
const turn = turns.find((candidate) => String(candidate.id ?? '') === turnId);
|
|
483
|
+
if (!turn)
|
|
484
|
+
throw new Error('codex_completed_turn_missing');
|
|
485
|
+
const turnStatus = String(turn.status ?? '');
|
|
486
|
+
if (turnStatus !== 'completed') {
|
|
487
|
+
if (threadWasPersisted) {
|
|
488
|
+
await this.bindings.recordTurn(binding.session_id, threadId, turnId, turnStatus === 'interrupted' ? 'interrupted' : 'failed');
|
|
489
|
+
}
|
|
490
|
+
throw new RemoteWorkerExecutionError('codex_turn_failed', 'acknowledged', false);
|
|
491
|
+
}
|
|
492
|
+
const items = Array.isArray(turn.items) ? turn.items.map(asRecord).filter(Boolean) : [];
|
|
493
|
+
const agentMessages = items
|
|
494
|
+
.filter((item) => item.type === 'agentMessage' && typeof item.text === 'string')
|
|
495
|
+
.map((item) => ({ phase: String(item.phase ?? ''), text: String(item.text).trim() }))
|
|
496
|
+
.filter((item) => Boolean(item.text));
|
|
497
|
+
const finalMessage = agentMessages
|
|
498
|
+
.filter((item) => item.phase === 'final_answer')
|
|
499
|
+
.map((item) => item.text)
|
|
500
|
+
.at(-1) ?? agentMessages
|
|
501
|
+
.map((item) => item.text)
|
|
502
|
+
.filter(Boolean)
|
|
503
|
+
.at(-1);
|
|
504
|
+
if (!finalMessage)
|
|
505
|
+
throw new Error('codex_final_agent_message_missing');
|
|
506
|
+
await this.bindings.recordTurn(binding.session_id, threadId, turnId, 'completed');
|
|
507
|
+
return {
|
|
508
|
+
accepted: true,
|
|
509
|
+
control: 'codex_app_server_v2',
|
|
510
|
+
thread_id: threadId,
|
|
511
|
+
turn_id: turnId,
|
|
512
|
+
turn_status: 'completed',
|
|
513
|
+
final_response: finalMessage.slice(0, 16_000)
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
catch (err) {
|
|
517
|
+
if (err instanceof RemoteWorkerExecutionError)
|
|
518
|
+
throw err;
|
|
519
|
+
if (threadWasPersisted && turnId && threadId) {
|
|
520
|
+
await this.bindings.recordTurn(binding.session_id, threadId, turnId, 'failed').catch(() => undefined);
|
|
521
|
+
}
|
|
522
|
+
throw new RemoteWorkerExecutionError(turnId ? 'codex_turn_failed' : 'input_delivery_unknown', turnId ? 'acknowledged' : 'unknown', false);
|
|
523
|
+
}
|
|
524
|
+
finally {
|
|
525
|
+
await client.close().catch(() => undefined);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
322
528
|
}
|
|
323
529
|
async function defaultCodexClientFactory(cwd) {
|
|
324
|
-
const created = await createCodexAppServerV2Client({ cwd, requestedBy: 'remote-
|
|
530
|
+
const created = await createCodexAppServerV2Client({ cwd, requestedBy: 'remote-worker' });
|
|
325
531
|
return created.client;
|
|
326
532
|
}
|
|
327
533
|
function normalizeExecutionError(err) {
|
|
@@ -331,7 +537,7 @@ function normalizeExecutionError(err) {
|
|
|
331
537
|
return new RemoteWorkerExecutionError(err.code);
|
|
332
538
|
if (err instanceof RemoteProtocolError)
|
|
333
539
|
return new RemoteWorkerExecutionError(err.code);
|
|
334
|
-
return new RemoteWorkerExecutionError('remote_command_failed');
|
|
540
|
+
return new RemoteWorkerExecutionError('remote_command_failed', 'unknown');
|
|
335
541
|
}
|
|
336
542
|
function errorCode(err) {
|
|
337
543
|
if (err instanceof RemoteWorkerExecutionError || err instanceof RemoteOwnerProofError || err instanceof RemoteProtocolError)
|
|
@@ -341,3 +547,11 @@ function errorCode(err) {
|
|
|
341
547
|
function errorMessage(err) {
|
|
342
548
|
return err instanceof Error ? err.message : String(err);
|
|
343
549
|
}
|
|
550
|
+
function stringValue(value) {
|
|
551
|
+
const text = typeof value === 'string' ? value.trim() : '';
|
|
552
|
+
return text || null;
|
|
553
|
+
}
|
|
554
|
+
function isMissingCodexRolloutError(error) {
|
|
555
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
556
|
+
return /no rollout found for thread id|thread(?:\/resume)?:? (?:thread )?(?:not found|not loaded)/i.test(message);
|
|
557
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
export function parseResponsesSseEvents(text) {
|
|
2
|
+
const events = [];
|
|
3
|
+
for (const line of String(text || '').split(/\r?\n/)) {
|
|
4
|
+
if (!line.startsWith('data:'))
|
|
5
|
+
continue;
|
|
6
|
+
const data = line.slice('data:'.length).trim();
|
|
7
|
+
if (!data || data === '[DONE]')
|
|
8
|
+
continue;
|
|
9
|
+
try {
|
|
10
|
+
events.push(JSON.parse(data));
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return events;
|
|
16
|
+
}
|
|
17
|
+
export function streamedOutputItems(events) {
|
|
18
|
+
const byId = new Map();
|
|
19
|
+
const anonymous = [];
|
|
20
|
+
for (const event of events) {
|
|
21
|
+
if (String(event?.type || '') !== 'response.output_item.done')
|
|
22
|
+
continue;
|
|
23
|
+
const item = event?.item;
|
|
24
|
+
if (!item || typeof item !== 'object')
|
|
25
|
+
continue;
|
|
26
|
+
const id = item.id ? String(item.id) : '';
|
|
27
|
+
if (id)
|
|
28
|
+
byId.set(id, item);
|
|
29
|
+
else
|
|
30
|
+
anonymous.push(item);
|
|
31
|
+
}
|
|
32
|
+
return [...byId.values(), ...anonymous];
|
|
33
|
+
}
|
|
34
|
+
export function findStreamedImageOutput(events) {
|
|
35
|
+
let partial = null;
|
|
36
|
+
let final = null;
|
|
37
|
+
for (const event of events) {
|
|
38
|
+
const type = String(event?.type || '');
|
|
39
|
+
const item = event?.item;
|
|
40
|
+
if (item && String(item.type || '') === 'image_generation_call') {
|
|
41
|
+
const b64 = b64Of(item.result) || b64Of(item.b64_json);
|
|
42
|
+
if (b64)
|
|
43
|
+
final = { id: item.id || event?.item_id || null, b64, partial: false };
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (/image_generation_call/.test(type)) {
|
|
47
|
+
const b64 = b64Of(event?.result) || b64Of(event?.b64_json);
|
|
48
|
+
if (b64) {
|
|
49
|
+
final = { id: event?.item_id || event?.id || null, b64, partial: false };
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const partialB64 = b64Of(event?.partial_image_b64);
|
|
53
|
+
if (partialB64)
|
|
54
|
+
partial = { id: event?.item_id || null, b64: partialB64, partial: true };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return final || partial;
|
|
58
|
+
}
|
|
59
|
+
export function imageGenerationCallOutputs(payload) {
|
|
60
|
+
return (Array.isArray(payload?.output) ? payload.output : [])
|
|
61
|
+
.filter((output) => String(output?.type || '') === 'image_generation_call');
|
|
62
|
+
}
|
|
63
|
+
export function hasImageGenerationResult(payload) {
|
|
64
|
+
return imageGenerationCallOutputs(payload)
|
|
65
|
+
.some((output) => Boolean(b64Of(output?.result) || b64Of(output?.result?.b64_json) || b64Of(output?.b64_json)));
|
|
66
|
+
}
|
|
67
|
+
export function parseResponsesSsePayload(text) {
|
|
68
|
+
const events = parseResponsesSseEvents(text);
|
|
69
|
+
if (!events.length)
|
|
70
|
+
return null;
|
|
71
|
+
const eventTypes = events.map((event) => event?.type || null);
|
|
72
|
+
const failed = events.find((event) => event?.type === 'response.failed' || event?.response?.status === 'failed');
|
|
73
|
+
if (failed) {
|
|
74
|
+
return {
|
|
75
|
+
object: 'response.sse',
|
|
76
|
+
status: 'failed',
|
|
77
|
+
error: failed?.response?.error || failed?.error || { message: 'responses_sse_failed' },
|
|
78
|
+
events: eventTypes
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const streamedImage = findStreamedImageOutput(events);
|
|
82
|
+
const recovered = recoveredOutput(streamedOutputItems(events), streamedImage);
|
|
83
|
+
const completed = [...events].reverse().find((event) => event?.type === 'response.completed' && event?.response);
|
|
84
|
+
if (completed?.response) {
|
|
85
|
+
const output = Array.isArray(completed.response.output) ? completed.response.output : [];
|
|
86
|
+
if (output.length) {
|
|
87
|
+
if (hasImageGenerationResult(completed.response) || !streamedImage)
|
|
88
|
+
return completed.response;
|
|
89
|
+
return {
|
|
90
|
+
...completed.response,
|
|
91
|
+
output: [...output, streamedImageItem(streamedImage)],
|
|
92
|
+
image_output_recovered_from_stream: true,
|
|
93
|
+
image_output_partial_frame: streamedImage.partial
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
if (!recovered.length)
|
|
97
|
+
return completed.response;
|
|
98
|
+
return {
|
|
99
|
+
...completed.response,
|
|
100
|
+
output: recovered,
|
|
101
|
+
output_recovered_from_stream: true,
|
|
102
|
+
...(streamedImage
|
|
103
|
+
? { image_output_recovered_from_stream: true, image_output_partial_frame: streamedImage.partial }
|
|
104
|
+
: {})
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
if (recovered.length) {
|
|
108
|
+
return {
|
|
109
|
+
object: 'response.sse',
|
|
110
|
+
status: 'completed',
|
|
111
|
+
output: recovered,
|
|
112
|
+
output_recovered_from_stream: true,
|
|
113
|
+
...(streamedImage
|
|
114
|
+
? { image_output_recovered_from_stream: true, image_output_partial_frame: streamedImage.partial }
|
|
115
|
+
: {}),
|
|
116
|
+
events: eventTypes
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
return { object: 'response.sse', status: 'unknown', events: eventTypes };
|
|
120
|
+
}
|
|
121
|
+
export function responsesOutputText(payload) {
|
|
122
|
+
const direct = typeof payload?.output_text === 'string' ? payload.output_text : '';
|
|
123
|
+
if (direct)
|
|
124
|
+
return direct;
|
|
125
|
+
const parts = [];
|
|
126
|
+
for (const output of Array.isArray(payload?.output) ? payload.output : []) {
|
|
127
|
+
for (const content of Array.isArray(output?.content) ? output.content : []) {
|
|
128
|
+
if (typeof content?.text === 'string' && content.text)
|
|
129
|
+
parts.push(content.text);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return parts.join('');
|
|
133
|
+
}
|
|
134
|
+
function recoveredOutput(items, streamedImage) {
|
|
135
|
+
const output = [...items];
|
|
136
|
+
const hasImage = output.some((item) => String(item?.type || '') === 'image_generation_call' && b64Of(item?.result));
|
|
137
|
+
if (streamedImage && !hasImage)
|
|
138
|
+
output.push(streamedImageItem(streamedImage));
|
|
139
|
+
return output;
|
|
140
|
+
}
|
|
141
|
+
function streamedImageItem(image) {
|
|
142
|
+
return {
|
|
143
|
+
id: image.id,
|
|
144
|
+
type: 'image_generation_call',
|
|
145
|
+
status: image.partial ? 'partial' : 'completed',
|
|
146
|
+
result: image.b64
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function b64Of(value) {
|
|
150
|
+
return typeof value === 'string' && value.length > 0 ? value : null;
|
|
151
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { normalizeDollarSkillName, prefixKnownSksDollarReferences, sksPrefixedDollarCommand } from './dollar-prefix.js';
|
|
2
|
-
const NARUTO_DESCRIPTION = '$Naruto is the lightweight Codex official subagent workflow and the default for non-trivial execution. The Sol Max parent dynamically scales useful independent children from a bounded
|
|
2
|
+
const NARUTO_DESCRIPTION = '$Naruto is the lightweight Codex official subagent workflow and the default for non-trivial execution. The Sol Max parent dynamically scales useful independent children from a bounded four/six/eight starting policy up to the safe capacity ceiling (default 12); max_threads is a cap, never a target. Healthy host CPU/memory/API budget may raise the automatic count toward that ceiling, and live pressure may shrink it. Capacity is the minimum of ready DAG width, disjoint ownership, verifier/tool capacity, reserved thread slots, and positive marginal usefulness. Child routing is fixed to Luna Max mechanical, Sol High implementation, Sol Max judgment, and Terra Medium long-context/Computer Use/Browser/ImageGen execution. Duplicate slices and overlapping writes are blocked; explicit --agents remains authoritative.';
|
|
3
3
|
const COMPUTER_USE_DESCRIPTION = 'Maximum-speed Codex Computer Use lane for native macOS, desktop-app, OS-settings, and non-web visual tasks only. Browser, localhost, website, webapp, and web-based app verification must route through Codex Chrome Extension readiness first.';
|
|
4
4
|
const DOLLAR_COMMANDS_LITE_BASE = [
|
|
5
5
|
{ command: '$DFix', route: 'fast direct fix', description: 'Tiny simple direct edits such as copy, labels, typos, wording, spacing, colors, or clearly scoped one-line changes. Bypasses the general SKS pipeline and runs an ultralight, no-record task-list path.' },
|