@quantiya/codevibe-core 1.0.23 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/cp-5-baseline-invariants.test.d.ts +1 -0
- package/dist/adapter/__tests__/capabilities.test.d.ts +1 -0
- package/dist/adapter/__tests__/contract-conformance.test.d.ts +1 -0
- package/dist/adapter/__tests__/packets.test.d.ts +1 -0
- package/dist/adapter/__tests__/progress.test.d.ts +1 -0
- package/dist/adapter/__tests__/registry.test.d.ts +1 -0
- package/dist/adapter/__tests__/smoke/claude.smoke.test.d.ts +1 -0
- package/dist/adapter/__tests__/smoke/codex.smoke.test.d.ts +1 -0
- package/dist/adapter/__tests__/smoke/gemini.smoke.test.d.ts +1 -0
- package/dist/adapter/capabilities.d.ts +68 -0
- package/dist/adapter/index.d.ts +7 -0
- package/dist/adapter/packets.d.ts +129 -0
- package/dist/adapter/progress.d.ts +93 -0
- package/dist/adapter/registry.d.ts +24 -0
- package/dist/adapter/types.d.ts +22 -0
- package/dist/appsync/__tests__/appsync-client-apply-user-decision.test.d.ts +1 -0
- package/dist/appsync/__tests__/appsync-client-classb.test.d.ts +1 -0
- package/dist/appsync/__tests__/appsync-client-planner.test.d.ts +1 -0
- package/dist/appsync/__tests__/appsync-client.test.d.ts +1 -0
- package/dist/appsync/appsync-client.d.ts +278 -1
- package/dist/appsync/index.d.ts +1 -1
- package/dist/appsync/queries.d.ts +8 -0
- package/dist/audit-keys/__tests__/audit-keys-parity.test.d.ts +1 -0
- package/dist/audit-keys/index.d.ts +41 -0
- package/dist/auth/__tests__/auth-telemetry.test.d.ts +1 -0
- package/dist/auth/auth-telemetry.d.ts +29 -8
- package/dist/companion-mode/__tests__/persist-preference.test.d.ts +1 -0
- package/dist/companion-mode/__tests__/resolve-agent.test.d.ts +1 -0
- package/dist/companion-mode/agent-picker.d.ts +9 -0
- package/dist/companion-mode/index.d.ts +55 -0
- package/dist/companion-mode/persist-preference.d.ts +24 -0
- package/dist/companion-mode/resolve-agent.d.ts +41 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.js +253 -33
- package/dist/local-executor/__tests__/authority-symlink-fixture.d.ts +15 -0
- package/dist/local-executor/__tests__/authority.test.d.ts +1 -0
- package/dist/local-executor/__tests__/class-a-emit.test.d.ts +1 -0
- package/dist/local-executor/__tests__/class-b-consumer.integration.test.d.ts +1 -0
- package/dist/local-executor/__tests__/class-b-consumer.test.d.ts +1 -0
- package/dist/local-executor/__tests__/hook-bridge.test.d.ts +1 -0
- package/dist/local-executor/__tests__/local-executor.integration.test.d.ts +1 -0
- package/dist/local-executor/__tests__/spawn.test.d.ts +1 -0
- package/dist/local-executor/__tests__/verification-runner.test.d.ts +1 -0
- package/dist/local-executor/authority.d.ts +29 -0
- package/dist/local-executor/class-a-emit.d.ts +138 -0
- package/dist/local-executor/class-b-consumer.d.ts +121 -0
- package/dist/local-executor/hook-bridge.d.ts +36 -0
- package/dist/local-executor/index.d.ts +8 -0
- package/dist/local-executor/local-executor-impl.d.ts +83 -0
- package/dist/local-executor/spawn.d.ts +6 -0
- package/dist/local-executor/types.d.ts +183 -0
- package/dist/local-executor/verification-gates/build.d.ts +6 -0
- package/dist/local-executor/verification-gates/deploy-preflight.d.ts +6 -0
- package/dist/local-executor/verification-gates/diff-sanity.d.ts +6 -0
- package/dist/local-executor/verification-gates/hostile-grep.d.ts +6 -0
- package/dist/local-executor/verification-gates/lint.d.ts +6 -0
- package/dist/local-executor/verification-gates/shell-runner.d.ts +40 -0
- package/dist/local-executor/verification-gates/source-traceability.d.ts +6 -0
- package/dist/local-executor/verification-gates/tests.d.ts +6 -0
- package/dist/local-executor/verification-gates/typecheck.d.ts +6 -0
- package/dist/local-executor/verification-runner.d.ts +28 -0
- package/dist/orchestration/__tests__/setup-bootstrap.test.d.ts +1 -0
- package/dist/orchestration/__tests__/setup-failure-recourse.test.d.ts +1 -0
- package/dist/orchestration/__tests__/setup-save.test.d.ts +1 -0
- package/dist/orchestration/__tests__/setup-seat-picker.test.d.ts +1 -0
- package/dist/orchestration/__tests__/setup-telemetry.test.d.ts +1 -0
- package/dist/orchestration/__tests__/setup-test-agents.test.d.ts +1 -0
- package/dist/orchestration/__tests__/setup-types.test.d.ts +1 -0
- package/dist/orchestration/__tests__/setup-wizard.test.d.ts +1 -0
- package/dist/orchestration/__tests__/v1-options.test.d.ts +1 -0
- package/dist/orchestration/detect-agents.d.ts +57 -0
- package/dist/orchestration/index.d.ts +3 -0
- package/dist/orchestration/orchestration-cli.d.ts +12 -0
- package/dist/orchestration/setup-bootstrap.d.ts +146 -0
- package/dist/orchestration/setup-failure-recourse.d.ts +23 -0
- package/dist/orchestration/setup-save.d.ts +47 -0
- package/dist/orchestration/setup-seat-picker.d.ts +72 -0
- package/dist/orchestration/setup-telemetry.d.ts +54 -0
- package/dist/orchestration/setup-test-agents.d.ts +108 -0
- package/dist/orchestration/setup-types.d.ts +140 -0
- package/dist/orchestration/setup-wizard.d.ts +57 -0
- package/dist/orchestration/v1-options.d.ts +97 -0
- package/dist/orchestration-shell/__tests__/cli-authority-bridge.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/cli-planner-stack.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/cli-singleton-enforcement.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/cli-stub-session-adapter.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/components.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/emit-shell-event.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/gate-prompts.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/hostile-grep.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/mode-selection.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/process-markers.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/reducer.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/runOrchestrationShell-classify-dispatch.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/runOrchestrationShell-planner-wiring.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/runOrchestrationShell-signal.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/runOrchestrationShell.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/slash-router.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/sticky-preference.test.d.ts +1 -0
- package/dist/orchestration-shell/cli.d.ts +96 -0
- package/dist/orchestration-shell/cli.js +8309 -0
- package/dist/orchestration-shell/cohort-flag.d.ts +16 -0
- package/dist/orchestration-shell/components/CodeVibeLogo.d.ts +2 -0
- package/dist/orchestration-shell/components/ConversationPane.d.ts +7 -0
- package/dist/orchestration-shell/components/GatePromptEntry.d.ts +9 -0
- package/dist/orchestration-shell/components/InputBar.d.ts +41 -0
- package/dist/orchestration-shell/components/OrchestrationApp.d.ts +63 -0
- package/dist/orchestration-shell/components/StatusBar.d.ts +7 -0
- package/dist/orchestration-shell/components/nodes/AdvisoryEntry.d.ts +8 -0
- package/dist/orchestration-shell/components/nodes/GateStatusNode.d.ts +8 -0
- package/dist/orchestration-shell/components/nodes/PlannerDecisionEntry.d.ts +8 -0
- package/dist/orchestration-shell/components/nodes/ReviewerQuorumStatusNode.d.ts +8 -0
- package/dist/orchestration-shell/components/nodes/SlashOutputEntry.d.ts +8 -0
- package/dist/orchestration-shell/components/nodes/SubagentEventEntry.d.ts +8 -0
- package/dist/orchestration-shell/components/nodes/UserMessageEntry.d.ts +8 -0
- package/dist/orchestration-shell/emit-shell-event.d.ts +64 -0
- package/dist/orchestration-shell/gate-prompts.d.ts +123 -0
- package/dist/orchestration-shell/index.d.ts +100 -0
- package/dist/orchestration-shell/ink-runtime.d.ts +64 -0
- package/dist/orchestration-shell/mode-selection.d.ts +46 -0
- package/dist/orchestration-shell/non-tty-fallback.d.ts +46 -0
- package/dist/orchestration-shell/process-markers.d.ts +12 -0
- package/dist/orchestration-shell/reducer.d.ts +8 -0
- package/dist/orchestration-shell/slash-router.d.ts +45 -0
- package/dist/orchestration-shell/sticky-preference.d.ts +24 -0
- package/dist/orchestration-shell/store.d.ts +17 -0
- package/dist/orchestration-shell/types.d.ts +417 -0
- package/dist/planner/__tests__/cache-clarification-bypass.test.d.ts +1 -0
- package/dist/planner/__tests__/cache.test.d.ts +1 -0
- package/dist/planner/__tests__/client.test.d.ts +1 -0
- package/dist/planner/__tests__/health-machine-transitions.test.d.ts +1 -0
- package/dist/planner/__tests__/types-zod.test.d.ts +1 -0
- package/dist/planner/adapter.d.ts +16 -0
- package/dist/planner/cache.d.ts +35 -0
- package/dist/planner/client.d.ts +103 -0
- package/dist/planner/health-state.d.ts +24 -0
- package/dist/planner/index.d.ts +5 -0
- package/dist/planner/types.d.ts +113 -0
- package/dist/reviewer/__tests__/integration.test.d.ts +1 -0
- package/dist/reviewer/__tests__/mocks.test.d.ts +1 -0
- package/dist/reviewer/__tests__/output-parser.test.d.ts +1 -0
- package/dist/reviewer/__tests__/registry.test.d.ts +1 -0
- package/dist/reviewer/__tests__/subprocess.test.d.ts +1 -0
- package/dist/reviewer/index.d.ts +15 -0
- package/dist/reviewer/mocks.d.ts +80 -0
- package/dist/reviewer/output-parser.d.ts +95 -0
- package/dist/reviewer/provider.d.ts +153 -0
- package/dist/reviewer/providers/__tests__/claude-live-smoke.test.d.ts +1 -0
- package/dist/reviewer/providers/__tests__/claude.test.d.ts +1 -0
- package/dist/reviewer/providers/__tests__/codex-live-smoke.test.d.ts +1 -0
- package/dist/reviewer/providers/__tests__/codex.test.d.ts +1 -0
- package/dist/reviewer/providers/__tests__/gemini-live-smoke.test.d.ts +1 -0
- package/dist/reviewer/providers/__tests__/gemini.test.d.ts +1 -0
- package/dist/reviewer/providers/claude.d.ts +59 -0
- package/dist/reviewer/providers/codex.d.ts +67 -0
- package/dist/reviewer/providers/common.d.ts +25 -0
- package/dist/reviewer/providers/gemini.d.ts +108 -0
- package/dist/reviewer/registry.d.ts +87 -0
- package/dist/reviewer/subprocess.d.ts +117 -0
- package/dist/reviewer/types.d.ts +101 -0
- package/dist/session/__tests__/session-resume-service-keys.test.d.ts +1 -0
- package/dist/session/session-resume.d.ts +24 -0
- package/dist/structural-summary/__tests__/__fixtures__/fixture-helpers.d.ts +11 -0
- package/dist/structural-summary/__tests__/assembler.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/generator.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/language-detect.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/manifest-parsers/cargo.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/manifest-parsers/gomod.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/manifest-parsers/gradle.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/manifest-parsers/index.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/manifest-parsers/npm.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/manifest-parsers/podfile.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/manifest-parsers/pyproject.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/opt-in-store.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/privacy-filter.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/safe-file-read.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/user-ignore-matcher.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/walker.test.d.ts +1 -0
- package/dist/structural-summary/generator.d.ts +8 -0
- package/dist/structural-summary/index.d.ts +7 -0
- package/dist/structural-summary/manifest-parsers/cargo.d.ts +3 -0
- package/dist/structural-summary/manifest-parsers/index.d.ts +7 -0
- package/dist/structural-summary/manifest-parsers/npm.d.ts +3 -0
- package/dist/structural-summary/manifest-parsers/other.d.ts +17 -0
- package/dist/structural-summary/opt-in-store.d.ts +24 -0
- package/dist/structural-summary/privacy-filter.d.ts +110 -0
- package/dist/structural-summary/safe-file-read.d.ts +11 -0
- package/dist/structural-summary/types.d.ts +215 -0
- package/dist/structural-summary/user-ignore-matcher.d.ts +9 -0
- package/dist/structural-summary/walker.d.ts +20 -0
- package/dist/types/events.d.ts +17 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/reviewer.d.ts +67 -0
- package/dist/types/session.d.ts +16 -0
- package/package.json +22 -5
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { spawn as nodeSpawn } from 'node:child_process';
|
|
2
|
+
import type { GateRunResult } from '../verification-runner';
|
|
3
|
+
export declare const VERIFICATION_RUNNER_ROLE = "verification_runner";
|
|
4
|
+
export interface ShellRunArgs {
|
|
5
|
+
/** Command to execute (e.g. "cargo", "npm", "git"). */
|
|
6
|
+
command: string;
|
|
7
|
+
/** Arguments to pass to the command. */
|
|
8
|
+
args: string[];
|
|
9
|
+
/** Working directory — caller (gate wrapper) MUST pass the repo root. */
|
|
10
|
+
cwd: string;
|
|
11
|
+
/** Per-gate timeout budget in milliseconds. Required (LOCK #C3E-4). */
|
|
12
|
+
timeoutMs: number;
|
|
13
|
+
/** Optional extra env overrides on top of the marker injection. */
|
|
14
|
+
extraEnv?: Record<string, string>;
|
|
15
|
+
/** Optional clock seam for tests. Defaults to Date.now. */
|
|
16
|
+
nowMs?: () => number;
|
|
17
|
+
/**
|
|
18
|
+
* Test seam — injects a fake spawner. Production callers leave this
|
|
19
|
+
* undefined and the real `child_process.spawn` is used. The seam returns
|
|
20
|
+
* a minimal interface (write events, exit event) so test fixtures
|
|
21
|
+
* don't have to model the full Node ChildProcess surface.
|
|
22
|
+
*/
|
|
23
|
+
spawnFn?: typeof nodeSpawn;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Run a single command-line under the verification-runner marker. Returns
|
|
27
|
+
* a `GateRunResult` matching what verification-runner.ts consumes.
|
|
28
|
+
*
|
|
29
|
+
* Captures FULL stdout/stderr (the runner truncates per LOCK #C3E-1) and
|
|
30
|
+
* fires the timeout race per LOCK #C3E-4. On timeout, the subprocess is
|
|
31
|
+
* killed (SIGKILL) and `timedOut: true` is set so the runner can apply
|
|
32
|
+
* the wire-form `exit_code = 124` regardless of what the platform
|
|
33
|
+
* returned for the killed process.
|
|
34
|
+
*
|
|
35
|
+
* NOTE: this primitive does NOT participate in authority enforcement.
|
|
36
|
+
* The orchestration shell establishes the authority scope BEFORE the
|
|
37
|
+
* verification runner is invoked, and the gates themselves operate on
|
|
38
|
+
* the user's own working tree which is implicitly readable.
|
|
39
|
+
*/
|
|
40
|
+
export declare function runShellCommand(args: ShellRunArgs): Promise<GateRunResult>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ClassAEmitter, ClassAEmitterContext, VerificationGateKind, VerificationResultPayload } from './class-a-emit';
|
|
2
|
+
export declare const DEFAULT_GATE_TIMEOUT_MS = 300000;
|
|
3
|
+
export declare const TIMEOUT_EXIT_CODE = 124;
|
|
4
|
+
export declare const SUMMARY_CAP_BYTES = 4096;
|
|
5
|
+
export interface VerificationGateRequest {
|
|
6
|
+
gateId: string;
|
|
7
|
+
taskId: string;
|
|
8
|
+
sessionId: string;
|
|
9
|
+
gateKinds: VerificationGateKind[];
|
|
10
|
+
cwd: string;
|
|
11
|
+
timeoutMsOverride?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface GateRunResult {
|
|
14
|
+
exitCode: number;
|
|
15
|
+
stdout: string;
|
|
16
|
+
stderr: string;
|
|
17
|
+
durationMs: number;
|
|
18
|
+
timedOut?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface VerificationRunnerDeps {
|
|
21
|
+
emitter: ClassAEmitter;
|
|
22
|
+
classAContext: ClassAEmitterContext;
|
|
23
|
+
nowMs?: () => number;
|
|
24
|
+
onResultEmitted?: (result: VerificationResultPayload) => void;
|
|
25
|
+
}
|
|
26
|
+
export declare function runVerificationGates(req: VerificationGateRequest, deps: VerificationRunnerDeps): Promise<VerificationResultPayload[]>;
|
|
27
|
+
export declare function truncateUtf8Safe(input: string, maxBytes: number): string;
|
|
28
|
+
export declare const NO_OP_PASS: GateRunResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Logger } from '../logger';
|
|
2
|
+
import { AppSyncClient } from '../appsync';
|
|
3
|
+
import { CapabilityRegistry } from '../adapter/capabilities';
|
|
4
|
+
export type DetectableAgent = 'CLAUDE' | 'GEMINI' | 'CODEX';
|
|
5
|
+
/**
|
|
6
|
+
* Returns the subset of agents present on PATH. Uses `command -v`
|
|
7
|
+
* (POSIX-standard) rather than `which` for portability across macOS
|
|
8
|
+
* and Linux. Runs synchronously — the whole probe is <10ms in practice
|
|
9
|
+
* even when agents are absent.
|
|
10
|
+
*
|
|
11
|
+
* Safe to call repeatedly; no caching here because the set of
|
|
12
|
+
* installed agents CAN change between plugin launches (user installs
|
|
13
|
+
* a new agent) and the caller decides how often to re-probe.
|
|
14
|
+
*/
|
|
15
|
+
export declare function detectInstalledAgents(): DetectableAgent[];
|
|
16
|
+
/**
|
|
17
|
+
* Detect-and-push convenience for plugin daemon startup. All three
|
|
18
|
+
* plugins (Claude, Gemini, Codex) call this once at start(). Runs
|
|
19
|
+
* the local PATH probe, then pushes the set to the backend via
|
|
20
|
+
* updateAvailableAgents. Idempotent — the backend dedupes and stores.
|
|
21
|
+
* Non-fatal on the network failure path (caller should `.catch()`
|
|
22
|
+
* and log but not abort startup — Quorum 2.0 auto-enable degrades
|
|
23
|
+
* to "use last-pushed agent set" when the mutation fails).
|
|
24
|
+
*
|
|
25
|
+
* @param client AppSyncClient that's already been authenticated via
|
|
26
|
+
* authenticateWithStoredTokens()
|
|
27
|
+
* @param log Logger — warn-level when no agents detected, info
|
|
28
|
+
* on success
|
|
29
|
+
*/
|
|
30
|
+
export declare function pushDetectedAgents(client: AppSyncClient, log: Pick<Logger, 'info' | 'warn'>, capabilityRegistry?: CapabilityRegistry, detectFn?: () => DetectableAgent[]): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Quorum 2.0 (2f.0.a.6) per-session orchestration CLI override applier.
|
|
33
|
+
* All three plugin wrappers (`codevibe-claude`, `codevibe-gemini`,
|
|
34
|
+
* `codevibe-codex`) export `CODEVIBE_ORCHESTRATION_OVERRIDE=true|false`
|
|
35
|
+
* to the tmux env when the user passes `--orchestration` /
|
|
36
|
+
* `--no-orchestration`. The daemon inherits this via the hook env
|
|
37
|
+
* chain and calls THIS function after every session-creation site
|
|
38
|
+
* to pin the per-session decision — wins outright over the server's
|
|
39
|
+
* User.orchestrationEnabledDefault auto-populate.
|
|
40
|
+
*
|
|
41
|
+
* Called from each plugin's daemon at every session-creation call
|
|
42
|
+
* site. Claude has one (handleSessionStart covers new + /resume
|
|
43
|
+
* because Claude Code fires SessionStart on /resume). Gemini has
|
|
44
|
+
* two (handleSessionStart + switchToResumedSession — /resume doesn't
|
|
45
|
+
* fire SessionStart in Gemini). Codex has two (createLaunchSession
|
|
46
|
+
* + handleSessionStarted — launch session gets replaced by runtime
|
|
47
|
+
* session_meta).
|
|
48
|
+
*
|
|
49
|
+
* Non-fatal on error — a failed override doesn't block session setup;
|
|
50
|
+
* the server's auto-populate decision stands and the user can flip
|
|
51
|
+
* the session via mobile toggle after the fact.
|
|
52
|
+
*
|
|
53
|
+
* @param client AppSyncClient authenticated for the session's owner
|
|
54
|
+
* @param sessionId Backend session ID (post-resumeOrCreateSession)
|
|
55
|
+
* @param log Logger
|
|
56
|
+
*/
|
|
57
|
+
export declare function applyPerSessionOrchestrationOverride(client: AppSyncClient, sessionId: string, log: Pick<Logger, 'info' | 'warn'>): Promise<void>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { detectInstalledAgents, pushDetectedAgents, applyPerSessionOrchestrationOverride, type DetectableAgent, } from './detect-agents';
|
|
2
|
+
export { runOrchestrationCli } from './orchestration-cli';
|
|
3
|
+
export { V1_ORCHESTRATION_PROMPT_KIND, V1_ORCHESTRATION_OPTIONS, mapOptionNumberToUserDecisionKind, mapOptionToUserDecisionKind, type V1OrchestrationOption, type V1UserDecisionKind, } from './v1-options';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dispatch for the `orchestration` subcommand. Called by runAuthCli
|
|
3
|
+
* when it sees `argv[2] === 'orchestration'`. Supports five sub-actions:
|
|
4
|
+
* enable — set orchestrationEnabledDefault = true
|
|
5
|
+
* disable — set orchestrationEnabledDefault = false
|
|
6
|
+
* status — print current policy snapshot + installed agents
|
|
7
|
+
* configure — interactive wizard (toggle + panel customization)
|
|
8
|
+
* setup — Phase 3.a (#190) 3-step locked setup wizard with Test
|
|
9
|
+
* My Agents (locked role taxonomy: architecture /
|
|
10
|
+
* correctness / security)
|
|
11
|
+
*/
|
|
12
|
+
export declare function runOrchestrationCli(argv: string[]): Promise<void>;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { AppSyncClient } from '../appsync/appsync-client.js';
|
|
2
|
+
import { DetectableAgent } from './detect-agents.js';
|
|
3
|
+
import { CountBucket, WizardEntry, WizardTier } from './setup-types.js';
|
|
4
|
+
import type { AgentKind } from '../reviewer/types.js';
|
|
5
|
+
import type { UserReviewerPolicySnapshot } from '../types/reviewer.js';
|
|
6
|
+
/**
|
|
7
|
+
* Thrown by `defaultClientFactory` when `authenticateWithStoredTokens`
|
|
8
|
+
* returns false AND the most recent failure kind is `'refresh_network'`
|
|
9
|
+
* (transient 5xx / DNS / socket-reset during the Cognito refresh-token
|
|
10
|
+
* POST). The wizard's `runBootstrap` catch routes this to
|
|
11
|
+
* `subscription_status_network` — same recourse as
|
|
12
|
+
* `getSubscriptionStatus` blowing up, but distinct from a genuine
|
|
13
|
+
* `not_signed_in` (which we still surface as `not_signed_in` so the
|
|
14
|
+
* user is told to re-authenticate).
|
|
15
|
+
*
|
|
16
|
+
* Stage 2 round-1 Codex M1. The error message is intentionally
|
|
17
|
+
* network-shaped so the existing `isNetworkLikeError(message)` regex
|
|
18
|
+
* also matches — defense in depth in case a future caller throws this
|
|
19
|
+
* outside the bootstrap path.
|
|
20
|
+
*/
|
|
21
|
+
export declare class AuthRefreshNetworkError extends Error {
|
|
22
|
+
constructor(cause: string);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Successful bootstrap output. The wizard's state machine consumes
|
|
26
|
+
* this to seed Step 1 (seat assignment).
|
|
27
|
+
*
|
|
28
|
+
* R1/R2 round-1 finding M1+L3+M6 (resolved 2026-05-08): the
|
|
29
|
+
* authenticated `client` and the user's `email` are exposed here so
|
|
30
|
+
* the wizard can render `✓ Signed in as <email>` per design §1
|
|
31
|
+
* lines 47-50 and avoid double-authenticating before save.
|
|
32
|
+
*/
|
|
33
|
+
export interface BootstrapResult {
|
|
34
|
+
tier: WizardTier;
|
|
35
|
+
/** Pro=2, Max=3. Free can't reach success (tier-gated above). */
|
|
36
|
+
seatBudget: number;
|
|
37
|
+
/** Lower-cased agent kinds detected on PATH, in canonical order. */
|
|
38
|
+
installedAgents: AgentKind[];
|
|
39
|
+
/** Pre-bucketed for telemetry; saved here so Step 1's emit doesn't recompute. */
|
|
40
|
+
installedAgentsBucket: CountBucket;
|
|
41
|
+
/**
|
|
42
|
+
* The authenticated AppSyncClient. Wizard reuses this for the save
|
|
43
|
+
* step rather than re-running `authenticateWithStoredTokens()` —
|
|
44
|
+
* eliminates the auth-evicted-between-bootstrap-and-save telemetry
|
|
45
|
+
* gap (R1 round-1 M1) and the wasteful double-auth (R1 round-1 L3).
|
|
46
|
+
*/
|
|
47
|
+
client: AppSyncClient;
|
|
48
|
+
/**
|
|
49
|
+
* Email of the signed-in user (Cognito `email` claim), or null if
|
|
50
|
+
* the claim is not present. Used by the wizard's bootstrap-summary
|
|
51
|
+
* UI per design §1 lines 47-50.
|
|
52
|
+
*/
|
|
53
|
+
userEmail: string | null;
|
|
54
|
+
/**
|
|
55
|
+
* Stage 2 round-1 Codex M2: the user's saved reviewer policy at
|
|
56
|
+
* bootstrap time, so the wizard can pre-populate seat-picker
|
|
57
|
+
* defaults on a re-run instead of always falling back to the
|
|
58
|
+
* tier-default agent / role priority. `null` when the snapshot
|
|
59
|
+
* fetch failed (the wizard then proceeds without saved-defaults —
|
|
60
|
+
* the canonical priority order is the fallback).
|
|
61
|
+
*
|
|
62
|
+
* Fetched via the existing `updateAvailableAgents` mutation, which
|
|
63
|
+
* is idempotent + already called by every plugin startup
|
|
64
|
+
* (`appsync-client.ts:721-724`). The wizard repeating it is safe
|
|
65
|
+
* and avoids introducing a new wire contract just to read three
|
|
66
|
+
* fields back.
|
|
67
|
+
*/
|
|
68
|
+
savedPolicy: UserReviewerPolicySnapshot | null;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Failure shape — discriminated by `kind`. The wizard surfaces a
|
|
72
|
+
* user-facing message and exits with code 1; telemetry is fired by
|
|
73
|
+
* `runBootstrap()` before the result is returned (so callers don't
|
|
74
|
+
* re-fire on their failure path).
|
|
75
|
+
*/
|
|
76
|
+
export type BootstrapFailure = {
|
|
77
|
+
kind: 'tier_gate_free';
|
|
78
|
+
tier: 'FREE';
|
|
79
|
+
} | {
|
|
80
|
+
kind: 'not_signed_in';
|
|
81
|
+
} | {
|
|
82
|
+
kind: 'subscription_status_network';
|
|
83
|
+
cause: string;
|
|
84
|
+
} | {
|
|
85
|
+
kind: 'no_clis_installed';
|
|
86
|
+
};
|
|
87
|
+
export type BootstrapOutput = {
|
|
88
|
+
ok: true;
|
|
89
|
+
result: BootstrapResult;
|
|
90
|
+
} | {
|
|
91
|
+
ok: false;
|
|
92
|
+
failure: BootstrapFailure;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Inputs for `runBootstrap`. Threads the wizard run id through so
|
|
96
|
+
* telemetry events stitch by `wizard_run_id`.
|
|
97
|
+
*
|
|
98
|
+
* `clientFactory` is injected so tests can swap in a mock AppSync
|
|
99
|
+
* client; production passes `defaultClientFactory`.
|
|
100
|
+
*
|
|
101
|
+
* `agentDetector` defaults to `detectInstalledAgents` (the production
|
|
102
|
+
* PATH walk) but is swappable for unit tests.
|
|
103
|
+
*
|
|
104
|
+
* `entry` is threaded in so `runBootstrap` can fire `wizard_started`
|
|
105
|
+
* itself — Stage 2 round-1 Codex M3 moved the emit from the wizard
|
|
106
|
+
* (where it skipped Free / no_clis users) into bootstrap (where it
|
|
107
|
+
* fires post-tier-and-agents-known, before any gate).
|
|
108
|
+
*/
|
|
109
|
+
export interface BootstrapDeps {
|
|
110
|
+
wizardRunId: string;
|
|
111
|
+
clientFactory: () => Promise<AppSyncClient | null>;
|
|
112
|
+
agentDetector: () => DetectableAgent[];
|
|
113
|
+
entry: WizardEntry;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Production client factory. Builds an AppSyncClient and authenticates
|
|
117
|
+
* with stored tokens. Returns null on `'no_tokens'` /
|
|
118
|
+
* `'refresh_auth_rejected'` (the wizard maps both to `not_signed_in`);
|
|
119
|
+
* THROWS `AuthRefreshNetworkError` on `'refresh_network'` so the
|
|
120
|
+
* wizard's `runBootstrap` catch routes the user to
|
|
121
|
+
* `subscription_status_network` instead of mistakenly telling a
|
|
122
|
+
* signed-in user to re-login when their refresh-token POST hit a
|
|
123
|
+
* transient 5xx.
|
|
124
|
+
*
|
|
125
|
+
* Stage 2 round-1 Codex M1: pre-fix, `authenticateWithStoredTokens`
|
|
126
|
+
* returned false on every error path, including network failures
|
|
127
|
+
* inside `callCognitoRefresh`'s catch block; the bootstrap's
|
|
128
|
+
* `isNetworkLikeError` check only ran on caught throws and so never
|
|
129
|
+
* fired in production for refresh-network failures.
|
|
130
|
+
*/
|
|
131
|
+
export declare function defaultClientFactory(): Promise<AppSyncClient | null>;
|
|
132
|
+
/**
|
|
133
|
+
* Run Step 0. Emits `wizard_step_started{step:'bootstrap'}` on entry,
|
|
134
|
+
* then either `wizard_step_completed` on success OR
|
|
135
|
+
* `wizard_step_failed` + `wizard_aborted` on failure. Returns the
|
|
136
|
+
* `BootstrapOutput` in either case so the caller can render UX before
|
|
137
|
+
* exiting.
|
|
138
|
+
*
|
|
139
|
+
* Stage 2 round-1 Codex M3: `wizard_started` is emitted from here,
|
|
140
|
+
* post-tier-and-agents-known, BEFORE the tier-gate / no-CLIs check.
|
|
141
|
+
* Free + no_clis users now fire `wizard_started` (so analytics has
|
|
142
|
+
* the funnel-entry numerator); auth/network bootstrap-aborts skip
|
|
143
|
+
* `wizard_started` (no tier known) and surface as
|
|
144
|
+
* `wizard_aborted{auth_expired | bootstrap_failure}` instead.
|
|
145
|
+
*/
|
|
146
|
+
export declare function runBootstrap(deps: BootstrapDeps): Promise<BootstrapOutput>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { PickerIO } from './setup-seat-picker.js';
|
|
2
|
+
export type Step2Choice = 'retry' | 'save_anyway' | 'exit';
|
|
3
|
+
export type Step3Choice = 'retry' | 'exit';
|
|
4
|
+
/**
|
|
5
|
+
* Render the Step 2 recourse menu after a Test My Agents failure.
|
|
6
|
+
* Loops on invalid input. Returns the user's choice. The caller is
|
|
7
|
+
* responsible for emitting `wizard_aborted` if `exit` is chosen.
|
|
8
|
+
*
|
|
9
|
+
* `canSaveAnyway` controls whether the `[s]` option is offered. When
|
|
10
|
+
* false (spawn_failure / timeout), only `[r]` and `[x]` are accepted.
|
|
11
|
+
*/
|
|
12
|
+
export declare function askStep2Recourse(io: PickerIO, canSaveAnyway: boolean): Promise<Step2Choice>;
|
|
13
|
+
/**
|
|
14
|
+
* Render the Step 3 recourse menu after a save failure. The caller's
|
|
15
|
+
* retry loop preserves the in-memory `seats` state so retry is free.
|
|
16
|
+
*
|
|
17
|
+
* `recoverable` honors the §6 outcome table: when false
|
|
18
|
+
* (auth_token_expired), `[r]` is suppressed because retry can only
|
|
19
|
+
* fail again — the user must re-run `codevibe login` and start a new
|
|
20
|
+
* wizard. The recourse menu collapses to a single `[x] exit` choice
|
|
21
|
+
* with a re-auth instruction line. (R1 round-1 M3 / R2 round-1 M4.)
|
|
22
|
+
*/
|
|
23
|
+
export declare function askStep3Recourse(io: PickerIO, recoverable?: boolean): Promise<Step3Choice>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { AppSyncClient } from '../appsync/appsync-client.js';
|
|
2
|
+
import { WizardSeatPick, WizardStepFailureReason } from './setup-types.js';
|
|
3
|
+
export type SaveResult = {
|
|
4
|
+
ok: true;
|
|
5
|
+
} | {
|
|
6
|
+
ok: false;
|
|
7
|
+
reason: WizardStepFailureReason;
|
|
8
|
+
/**
|
|
9
|
+
* Whether `[r] retry` makes sense for this failure. Network /
|
|
10
|
+
* 5xx / throttle are retryable (transient). auth_token_expired
|
|
11
|
+
* is NOT retryable in-process — the user must re-run `codevibe
|
|
12
|
+
* login` and start a new wizard run.
|
|
13
|
+
*/
|
|
14
|
+
recoverable: boolean;
|
|
15
|
+
};
|
|
16
|
+
export interface SaveDeps {
|
|
17
|
+
wizardRunId: string;
|
|
18
|
+
client: AppSyncClient;
|
|
19
|
+
seats: WizardSeatPick[];
|
|
20
|
+
/**
|
|
21
|
+
* Whether the user reached this step via "save anyway" after a
|
|
22
|
+
* Test My Agents warning. Drives the wizard_completed.outcome
|
|
23
|
+
* value at the wizard's terminal exit (`'ok' | 'saved_after_test_warning'`).
|
|
24
|
+
* Not used here — Step 3 just persists; the top-level wizard
|
|
25
|
+
* threads the outcome value into the final `wizard_completed` event.
|
|
26
|
+
*/
|
|
27
|
+
savedAfterTestWarning: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Run Step 3. Emits `wizard_step_started{step:'save'}` on entry,
|
|
31
|
+
* `wizard_step_completed` on success, or `wizard_step_failed` with
|
|
32
|
+
* the classified reason. Returns a SaveResult the wizard's recourse
|
|
33
|
+
* loop consumes.
|
|
34
|
+
*/
|
|
35
|
+
export declare function runSave(deps: SaveDeps): Promise<SaveResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Classify a thrown error from `updateReviewerPolicy` into one of the
|
|
38
|
+
* §7 save-step reason codes. Best-effort matching against the AppSync
|
|
39
|
+
* client's error message conventions:
|
|
40
|
+
* - 401 / "Unauthorized" / "Token expired" → auth_token_expired
|
|
41
|
+
* - 429 / "Throttling" / "Rate exceeded" → update_policy_throttle
|
|
42
|
+
* - 5xx / "Internal" / "InternalServerError" → update_policy_5xx
|
|
43
|
+
* - everything else (fetch threw, ECONNRESET, DNS) → update_policy_network
|
|
44
|
+
*
|
|
45
|
+
* Exposed for tests to assert classification mapping.
|
|
46
|
+
*/
|
|
47
|
+
export declare function classifySaveError(err: unknown): WizardStepFailureReason;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as readline from 'readline';
|
|
2
|
+
import { WizardSeatPick, WizardRole } from './setup-types.js';
|
|
3
|
+
import type { AgentKind } from '../reviewer/types.js';
|
|
4
|
+
/**
|
|
5
|
+
* One entry in the optional `savedSeats` array — the user's previously
|
|
6
|
+
* persisted reviewer policy, threaded in by the wizard on a re-run so
|
|
7
|
+
* the picker pre-fills per-seat agent + role defaults. Stage 2 round-1
|
|
8
|
+
* Codex M2.
|
|
9
|
+
*
|
|
10
|
+
* Stale entries (agent no longer installed, role not in
|
|
11
|
+
* `WIZARD_ROLES`, role already taken by a previous seat) are silently
|
|
12
|
+
* ignored — the picker falls back to the canonical priority defaults
|
|
13
|
+
* for that seat.
|
|
14
|
+
*/
|
|
15
|
+
export interface SavedSeatHint {
|
|
16
|
+
seatId: number;
|
|
17
|
+
agent: AgentKind;
|
|
18
|
+
role: WizardRole;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Reader/writer abstraction so tests can drive the picker with
|
|
22
|
+
* scripted answers instead of an interactive readline. Production
|
|
23
|
+
* passes a Node readline.Interface; tests pass a fake.
|
|
24
|
+
*/
|
|
25
|
+
export interface PickerIO {
|
|
26
|
+
/** Render a line to the user. No newline appended; pass '\n' if needed. */
|
|
27
|
+
write: (line: string) => void;
|
|
28
|
+
/** Prompt the user and return the trimmed answer (without trailing newline). */
|
|
29
|
+
ask: (prompt: string) => Promise<string>;
|
|
30
|
+
}
|
|
31
|
+
export interface SeatPickerDeps {
|
|
32
|
+
wizardRunId: string;
|
|
33
|
+
installedAgents: AgentKind[];
|
|
34
|
+
seatBudget: number;
|
|
35
|
+
io: PickerIO;
|
|
36
|
+
/**
|
|
37
|
+
* Optional per-seat hints from the user's saved reviewer policy
|
|
38
|
+
* (Stage 2 round-1 Codex M2). When present and valid (agent
|
|
39
|
+
* installed; role still available for that seat), the picker uses
|
|
40
|
+
* the hint as the default instead of the canonical
|
|
41
|
+
* AGENT_PRIORITY / DEFAULT_ROLE_BY_SEAT priority.
|
|
42
|
+
*
|
|
43
|
+
* Indexed by `seatId` (NOT array position) — the implementation
|
|
44
|
+
* looks up `savedSeats.find(s => s.seatId === seatId)` so absent /
|
|
45
|
+
* out-of-order entries are fine.
|
|
46
|
+
*/
|
|
47
|
+
savedSeats?: ReadonlyArray<SavedSeatHint>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Run Step 1. Returns the user's per-seat picks. Caller is
|
|
51
|
+
* responsible for closing the readline interface.
|
|
52
|
+
*/
|
|
53
|
+
export declare function runSeatPicker(deps: SeatPickerDeps): Promise<WizardSeatPick[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Default-role-fallback rule (PHASE-3-A-DESIGN.md §1). Seat 0 wants
|
|
56
|
+
* `architecture`, Seat 1 wants `correctness`, Seat 2 wants `security`.
|
|
57
|
+
* If the canonical pick is gone (taken by a previous seat), fall
|
|
58
|
+
* back to the first remaining role in canonical order.
|
|
59
|
+
*
|
|
60
|
+
* Stage 2 round-1 Codex M2: when `savedRole` is provided AND that
|
|
61
|
+
* role is in `WIZARD_ROLES` AND it's still in `availableRoles` (not
|
|
62
|
+
* taken by a previous seat), use it as the default instead of the
|
|
63
|
+
* canonical-default-by-seat priority. Stale saved values (role
|
|
64
|
+
* already taken, or a non-3-role value from a 2.0.x custom-roles
|
|
65
|
+
* future expansion) are silently ignored.
|
|
66
|
+
*/
|
|
67
|
+
export declare function pickDefaultRole(seatId: number, availableRoles: ReadonlyArray<WizardRole>, savedRole?: WizardRole): WizardRole;
|
|
68
|
+
/**
|
|
69
|
+
* Build a `PickerIO` from a Node readline interface. Production
|
|
70
|
+
* callers use this; tests construct their own `PickerIO` directly.
|
|
71
|
+
*/
|
|
72
|
+
export declare function readlinePickerIO(rl: readline.Interface): PickerIO;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { WizardStep, WizardStepFailureReason, WizardAbortReason, WizardEntry, WizardTier, CountBucket, LatencyBucket } from './setup-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Generate a fresh `wizard_run_id` for one wizard invocation. Returned
|
|
4
|
+
* by `runSetupWizard()` entry and threaded into every emit call.
|
|
5
|
+
*
|
|
6
|
+
* v4 UUID — uses Node's crypto.randomUUID when available (Node 14.17+);
|
|
7
|
+
* otherwise falls back to a manual v4 derivation. Either path produces
|
|
8
|
+
* a 36-char hex-with-dashes string suitable for the GA4 custom-dimension
|
|
9
|
+
* `wizard_run_id` registered in `register-custom-dimensions.py`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function newWizardRunId(): string;
|
|
12
|
+
export declare function emitWizardStarted(args: {
|
|
13
|
+
wizardRunId: string;
|
|
14
|
+
tier: WizardTier;
|
|
15
|
+
entry: WizardEntry;
|
|
16
|
+
installedAgentsBucket: CountBucket;
|
|
17
|
+
}): Promise<void>;
|
|
18
|
+
export declare function emitWizardStepStarted(args: {
|
|
19
|
+
wizardRunId: string;
|
|
20
|
+
step: WizardStep;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
export declare function emitWizardStepCompleted(args: {
|
|
23
|
+
wizardRunId: string;
|
|
24
|
+
step: WizardStep;
|
|
25
|
+
latencyBucket: LatencyBucket;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
export declare function emitWizardStepFailed(args: {
|
|
28
|
+
wizardRunId: string;
|
|
29
|
+
step: WizardStep;
|
|
30
|
+
reason: WizardStepFailureReason;
|
|
31
|
+
latencyBucket: LatencyBucket;
|
|
32
|
+
}): Promise<void>;
|
|
33
|
+
export declare function emitWizardCompleted(args: {
|
|
34
|
+
wizardRunId: string;
|
|
35
|
+
outcome: 'ok' | 'saved_after_test_warning';
|
|
36
|
+
tier: WizardTier;
|
|
37
|
+
seatsBucket: CountBucket;
|
|
38
|
+
agentsDistinctBucket: CountBucket;
|
|
39
|
+
rolesDistinctBucket: CountBucket;
|
|
40
|
+
totalLatencyBucket: LatencyBucket;
|
|
41
|
+
}): Promise<void>;
|
|
42
|
+
export declare function emitWizardAborted(args: {
|
|
43
|
+
wizardRunId: string;
|
|
44
|
+
reason: WizardAbortReason;
|
|
45
|
+
lastStep: WizardStep;
|
|
46
|
+
}): Promise<void>;
|
|
47
|
+
type BeaconRecord = {
|
|
48
|
+
name: string;
|
|
49
|
+
params: Record<string, string | number>;
|
|
50
|
+
};
|
|
51
|
+
type BeaconSink = (record: BeaconRecord) => void;
|
|
52
|
+
export declare function __setBeaconSink(sink: BeaconSink): void;
|
|
53
|
+
export declare function __resetBeaconSink(): void;
|
|
54
|
+
export {};
|