#!/usr/bin/env node import { C as CliNameLiteral, a6 as VoteThreshold, B as VotingStrategy, F as ErrorPolicy, a7 as NoQuorumPolicy } from './consensus-vote-types-DkRs8FbB.js'; import { z } from 'zod'; /** * nexus-agents/audit - Authentic Vote Record (#3897, model revised #3927) * * A committed, append-only, tamper-EVIDENT record of a completed * `consensus_vote`, persisted at vote time so the authority-ladder promotion * gate (`scripts/check-authority-tier-drift.ts`, #3895) can rest authenticity * on a tamper-evident record set instead of on hand-transcribed YAML. * * MODEL: TAMPER-EVIDENT RECORD SET + MONOTONIC SEQUENCE (NOT a linear hash * chain). #3927 (design vote 7-0, Option B). The original #3897 design was a * LINEAR HASH CHAIN: each record's `hash` folded in the prior record's hash, so * the order of file lines was load-bearing. That model cannot survive a * concurrent-branch git merge — two branches that each append a record from the * same tip produce two records claiming the same `previousHash`, and any * merge-concatenation breaks the back-link check. The revised model treats the * ledger as an UNORDERED SET of self-hashed records plus a monotonic `sequence` * number: each record's hash is POSITION-INDEPENDENT (covers `sequence` but NOT * `previousHash`), so it is stable across merges and reorders. `previousHash` * is retained ADVISORILY for audit texture but does NOT participate in * verification. Omission is detected via SEQUENCE GAPS; concurrent forks (two * records sharing a sequence) are a BENIGN signal, not a failure. * * KNOWN GAP IN OMISSION DETECTION (#4011): sequence-gap detection only catches an * omission that leaves a HOLE in the `0..maxSeq` run. It does NOT catch the * deletion of a FORK PARTNER — when a sequence is shared by ≥2 records and one is * removed, the surviving partner still occupies that sequence, so no gap appears * and verification still returns `ok`. So a concurrent fork that resolved * `approved` + `rejected` can have its `rejected` partner silently dropped. This * is consistent with the residual-trust boundary (records are author-typed; * a signature is OPTIONAL until the #3927 item 4 phase-3 cutover): a commit-access * actor could equally have just never written the rejecting record, so this grants * no new capability. Closing it (cross-checking `forks`/`recordCount`, or * requiring fork partners to be co-present) is only meaningful once signing raises * the overall bar, and folds into #3927 item 4. See the audit-hash-chain threat * model for the disclosed boundary. * * SIGNATURE (#3927 item 4, phases 1-2). A record MAY carry `signature`: a * detached `ssh-keygen -Y sign` signature, namespace * {@link VOTE_RECORD_SIGNATURE_NAMESPACE}, over the record's committed `hash` * string. It is OUTSIDE the self-hash (it is made over the hash) and is * verified separately by `vote-record-signature.ts` against the committed * `governance/allowed_signers`. `verifyVoteRecordSet` does NOT check it: the * set verifier answers "was any record edited", the signature verifier answers * "did a listed key sign this hash", and the gate reports the two side by side. * What a signature proves is key ACCESS from the signing environment, not a * human's presence — see the threat model and #6257. * * WHY A DEDICATED PAYLOAD-COVERING HASH (and not the audit-event head hash). * The audit-event chain (`computeEventHash` in audit-logger.ts) hashes only the * stable HEAD fields (id/timestamp/category/action/outcome/actor/previousHash) * and intentionally NOT `metadata` — so riding a tier-transition-style metadata * payload would leave the vote `decision`/`approvalPercentage` OUTSIDE the * hash: an attacker could flip `rejected`→`approved` in the metadata without * breaking any hash. That defeats the whole point of #3897. This record instead * folds EVERY authenticity-bearing field — the proposal content hash, the * decision, the approval percentage, the vote counts, the per-voter summary, * and the `sequence` — into the self-hash, so editing any of them is detected * as a `hash_mismatch`. This is the tamper-evidence MVP; cryptographic * signing/provenance (binding the record to a key) is DEFERRED (#3897 follow-up). * * NOTE: the separate audit-event/tier-transition chain (`audit-logger.ts`) IS * still a real linear hash chain — it has a single-writer runtime and never * merges concurrent branches, so the chain model holds there. Only THIS ledger * (a multi-branch committable artifact) was converted to a record set. * * @module audit/vote-record */ /** * The `{pr, headSha}` binding of a PR-ratification vote (#5130 step 1, schema * 1.10). `pr` is the PR number the panel ratified; `headSha` is the full head * commit the panel saw. Exported for the `consensus_vote` input schema and the * caller-commits append script, so producer, record and script validate the * same shape. */ declare const VoteRecordPrBindingSchema: z.ZodObject<{ pr: z.ZodNumber; headSha: z.ZodString; }, z.core.$strict>; type VoteRecordPrBinding = z.infer; /** * nexus-agents/cli - Mode Detector * * Automatic detection of nexus-agents invocation mode based on * environment variables, TTY state, and explicit flags. * * (Source: Node.js 22.x TTY documentation) * (Source: MCP Protocol 2025-11-25 - client detection patterns) */ /** * Server mode for nexus-agents. * - server: MCP server only (responds to MCP client calls) * - orchestrator: CLI orchestrator (calls external CLIs like Gemini, Codex) * - mesh: Not yet implemented — reserved for future bidirectional mode */ type ServerMode = 'server' | 'orchestrator' | 'mesh'; /** * nexus-agents CLI Types * * Type definitions and constants for the CLI. * * @module cli-types */ /** * Exit codes for the CLI. */ declare const EXIT_CODES: { readonly SUCCESS: 0; readonly SERVER_START_FAILED: 1; readonly SHUTDOWN_ERROR: 2; readonly INVALID_ARGS: 3; /** Subcommand is stubbed / advertised but not implemented (#2727). */ readonly NOT_IMPLEMENTED: 4; }; /** * CLI command types that can be executed. */ type CliCommand = 'server' | 'help' | 'version' | 'hello' | 'config' | 'expert' | 'workflow' | 'doctor' | 'verify' | 'review' | 'routing-audit' | 'orchestrate' | 'system-review' | 'vote' | 'index' | 'research' | 'validation' | 'learning-metrics' | 'swe-bench' | 'atbench' | 'setup' | 'hooks' | 'demo' | 'sprint' | 'session' | 'evaluate' | 'issue' | 'fitness-audit' | 'release-notes' | 'release-validate' | 'release-announce' | 'scaffold' | 'visualize' | 'capabilities' | 'status' | 'memory-benchmark' | 'auth' | 'scenario' | 'warm-up' | 'e2e-eval' | 'routing-ab' | 'memory-eval' | 'health' | 'init' | 'validate' | 'registry' | 'login' | 'usage' | 'migrate' | 'tour' | 'improvement-review' | 'auto-remediate' | 'remediation-review' | 'mode' | 'jobs'; /** * Parsed CLI arguments and command. */ interface ParsedCliArgs { command: CliCommand; subcommand?: string; options: { help: boolean; version: boolean; verbose: boolean; interactive: boolean; all: boolean; mode: ServerMode; output?: string; force: boolean; format: string; input?: string; dryRun: boolean; banditStats: boolean; setup: boolean; skipChecks: boolean; task?: string; model?: CliNameLiteral; maxTokens?: number; maxCostUsd?: number; engine?: 'router' | 'puppeteer'; learn?: boolean; policyPath?: string; maxSteps?: number; createIssue: boolean; fix: boolean; proposal?: string; /** Legacy spelling of the bar; `strategy` wins when both are given (#6227). */ threshold?: VoteThreshold; /** #6227 — `--strategy`, the tool's own enum, passed to the engine as the MCP tool passes it. */ strategy?: VotingStrategy; /** #6227 — `--ratifies-pr @`, already parsed into the record's binding shape. */ ratifiesPr?: VoteRecordPrBinding; quick: boolean; timeoutMs?: number; /** #2630 — see `applyErrorPolicy`. */ errorPolicy?: ErrorPolicy; /** #4135 — how the vote command maps a `no_quorum` decision. Default `fail`. */ onNoQuorum?: NoQuorumPolicy; /** #4472 / #4941 — repeatable `--option`, the named alternatives to tally. */ options?: string[]; /** #6110 — `--project`, the project the panel judges (replaces `nexus-agents` in the prompts). */ project?: string; variant?: 'lite' | 'verified' | 'full'; limit?: number; instance?: string[]; resume: boolean; concurrency?: number; mcp?: boolean; predictions?: string; cacheLevel?: string; maxWorkers?: string; runId?: string; outputDir?: string; fixture?: string; llmScoring?: boolean; period?: number; export?: string; noTrends?: boolean; nonInteractive: boolean; skipMcp: boolean; skipRules: boolean; skipHooks: boolean; skipConfig: boolean; skipOpencode: boolean; skipGemini: boolean; skipCodex: boolean; scope?: 'user' | 'project'; customApi?: string; customApiKey?: string; customModel?: string; mock: boolean; deep: boolean; /** * Run the `serves` readiness level: a real completion per adapter (#4376). * * Opt-in because it spends generation quota. The default run proves * `installed` and `authenticated` only, and reports `serves` as * not-attempted rather than assuming it. */ live: boolean; json?: boolean; source?: string; portable?: boolean; gitignore?: boolean; mcpConfig?: boolean; install?: boolean; uninstall?: boolean; opencode?: string; validate?: boolean; evaluator?: string; owner?: string; note?: string; sound?: boolean; unsound?: boolean; }; positionals: string[]; } /** * nexus-agents CLI Commands * * Command dispatch and routing for the CLI. * * @module cli-commands * * File structure: * - Validators in cli-commands-validators.ts (Issue #272) * - Usage text in cli-commands-usage.ts * - Command handlers in cli-commands-handlers.ts (Issue #285) */ /** * Prints help text to stdout. * * Default output hides maintainer commands (benchmarks, release tooling, deep * diagnostics). Pass `--all` to include them. See `cli-command-catalog.ts` for * the audience classification. */ declare function printHelp(args?: ParsedCliArgs): void; /** * Prints version information to stdout. */ declare function printVersion(): void; /** * nexus-agents CLI * * CLI entry point for Nexus Agents MCP server. * Supports commands for server operation, configuration, and expert management. * * (Source: MCP Protocol 2025-11-25) * (Source: Node.js 22.x parseArgs documentation) */ /** * Parses CLI arguments and determines the command to run. * * @param args - Command line arguments (defaults to process.argv.slice(2)) * @returns Parsed CLI arguments with command and options */ declare function parseCliArgs(args?: string[]): ParsedCliArgs; export { type CliCommand, EXIT_CODES, type ParsedCliArgs, type ServerMode, parseCliArgs, printHelp, printVersion };