@quantiya/codevibe-claude-plugin 1.0.36 → 1.0.37

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.
Files changed (59) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/dist/server.js +13 -13
  3. package/node_modules/@quantiya/codevibe-core/dist/appsync/__tests__/appsync-client.test.d.ts +1 -0
  4. package/node_modules/@quantiya/codevibe-core/dist/appsync/appsync-client.d.ts +139 -1
  5. package/node_modules/@quantiya/codevibe-core/dist/appsync/queries.d.ts +5 -0
  6. package/node_modules/@quantiya/codevibe-core/dist/audit-keys/__tests__/audit-keys-parity.test.d.ts +1 -0
  7. package/node_modules/@quantiya/codevibe-core/dist/audit-keys/index.d.ts +41 -0
  8. package/node_modules/@quantiya/codevibe-core/dist/auth/__tests__/auth-telemetry.test.d.ts +1 -0
  9. package/node_modules/@quantiya/codevibe-core/dist/auth/auth-telemetry.d.ts +29 -8
  10. package/node_modules/@quantiya/codevibe-core/dist/index.d.ts +4 -0
  11. package/node_modules/@quantiya/codevibe-core/dist/index.js +194 -33
  12. package/node_modules/@quantiya/codevibe-core/dist/orchestration/__tests__/setup-bootstrap.test.d.ts +1 -0
  13. package/node_modules/@quantiya/codevibe-core/dist/orchestration/__tests__/setup-failure-recourse.test.d.ts +1 -0
  14. package/node_modules/@quantiya/codevibe-core/dist/orchestration/__tests__/setup-save.test.d.ts +1 -0
  15. package/node_modules/@quantiya/codevibe-core/dist/orchestration/__tests__/setup-seat-picker.test.d.ts +1 -0
  16. package/node_modules/@quantiya/codevibe-core/dist/orchestration/__tests__/setup-telemetry.test.d.ts +1 -0
  17. package/node_modules/@quantiya/codevibe-core/dist/orchestration/__tests__/setup-test-agents.test.d.ts +1 -0
  18. package/node_modules/@quantiya/codevibe-core/dist/orchestration/__tests__/setup-types.test.d.ts +1 -0
  19. package/node_modules/@quantiya/codevibe-core/dist/orchestration/__tests__/setup-wizard.test.d.ts +1 -0
  20. package/node_modules/@quantiya/codevibe-core/dist/orchestration/__tests__/v1-options.test.d.ts +1 -0
  21. package/node_modules/@quantiya/codevibe-core/dist/orchestration/detect-agents.d.ts +56 -0
  22. package/node_modules/@quantiya/codevibe-core/dist/orchestration/index.d.ts +3 -0
  23. package/node_modules/@quantiya/codevibe-core/dist/orchestration/orchestration-cli.d.ts +12 -0
  24. package/node_modules/@quantiya/codevibe-core/dist/orchestration/setup-bootstrap.d.ts +146 -0
  25. package/node_modules/@quantiya/codevibe-core/dist/orchestration/setup-failure-recourse.d.ts +23 -0
  26. package/node_modules/@quantiya/codevibe-core/dist/orchestration/setup-save.d.ts +47 -0
  27. package/node_modules/@quantiya/codevibe-core/dist/orchestration/setup-seat-picker.d.ts +72 -0
  28. package/node_modules/@quantiya/codevibe-core/dist/orchestration/setup-telemetry.d.ts +54 -0
  29. package/node_modules/@quantiya/codevibe-core/dist/orchestration/setup-test-agents.d.ts +108 -0
  30. package/node_modules/@quantiya/codevibe-core/dist/orchestration/setup-types.d.ts +140 -0
  31. package/node_modules/@quantiya/codevibe-core/dist/orchestration/setup-wizard.d.ts +57 -0
  32. package/node_modules/@quantiya/codevibe-core/dist/orchestration/v1-options.d.ts +108 -0
  33. package/node_modules/@quantiya/codevibe-core/dist/reviewer/__tests__/integration.test.d.ts +1 -0
  34. package/node_modules/@quantiya/codevibe-core/dist/reviewer/__tests__/mocks.test.d.ts +1 -0
  35. package/node_modules/@quantiya/codevibe-core/dist/reviewer/__tests__/output-parser.test.d.ts +1 -0
  36. package/node_modules/@quantiya/codevibe-core/dist/reviewer/__tests__/registry.test.d.ts +1 -0
  37. package/node_modules/@quantiya/codevibe-core/dist/reviewer/__tests__/subprocess.test.d.ts +1 -0
  38. package/node_modules/@quantiya/codevibe-core/dist/reviewer/index.d.ts +15 -0
  39. package/node_modules/@quantiya/codevibe-core/dist/reviewer/mocks.d.ts +80 -0
  40. package/node_modules/@quantiya/codevibe-core/dist/reviewer/output-parser.d.ts +95 -0
  41. package/node_modules/@quantiya/codevibe-core/dist/reviewer/provider.d.ts +153 -0
  42. package/node_modules/@quantiya/codevibe-core/dist/reviewer/providers/__tests__/claude-live-smoke.test.d.ts +1 -0
  43. package/node_modules/@quantiya/codevibe-core/dist/reviewer/providers/__tests__/claude.test.d.ts +1 -0
  44. package/node_modules/@quantiya/codevibe-core/dist/reviewer/providers/__tests__/codex-live-smoke.test.d.ts +1 -0
  45. package/node_modules/@quantiya/codevibe-core/dist/reviewer/providers/__tests__/codex.test.d.ts +1 -0
  46. package/node_modules/@quantiya/codevibe-core/dist/reviewer/providers/__tests__/gemini-live-smoke.test.d.ts +1 -0
  47. package/node_modules/@quantiya/codevibe-core/dist/reviewer/providers/__tests__/gemini.test.d.ts +1 -0
  48. package/node_modules/@quantiya/codevibe-core/dist/reviewer/providers/claude.d.ts +59 -0
  49. package/node_modules/@quantiya/codevibe-core/dist/reviewer/providers/codex.d.ts +67 -0
  50. package/node_modules/@quantiya/codevibe-core/dist/reviewer/providers/common.d.ts +25 -0
  51. package/node_modules/@quantiya/codevibe-core/dist/reviewer/providers/gemini.d.ts +108 -0
  52. package/node_modules/@quantiya/codevibe-core/dist/reviewer/registry.d.ts +87 -0
  53. package/node_modules/@quantiya/codevibe-core/dist/reviewer/subprocess.d.ts +117 -0
  54. package/node_modules/@quantiya/codevibe-core/dist/reviewer/types.d.ts +101 -0
  55. package/node_modules/@quantiya/codevibe-core/dist/types/index.d.ts +2 -0
  56. package/node_modules/@quantiya/codevibe-core/dist/types/orchestration.d.ts +57 -0
  57. package/node_modules/@quantiya/codevibe-core/dist/types/reviewer.d.ts +67 -0
  58. package/node_modules/@quantiya/codevibe-core/dist/types/session.d.ts +16 -0
  59. package/package.json +1 -1
@@ -0,0 +1,56 @@
1
+ import { Logger } from '../logger';
2
+ import { AppSyncClient } from '../appsync';
3
+ export type DetectableAgent = 'CLAUDE' | 'GEMINI' | 'CODEX';
4
+ /**
5
+ * Returns the subset of agents present on PATH. Uses `command -v`
6
+ * (POSIX-standard) rather than `which` for portability across macOS
7
+ * and Linux. Runs synchronously — the whole probe is <10ms in practice
8
+ * even when agents are absent.
9
+ *
10
+ * Safe to call repeatedly; no caching here because the set of
11
+ * installed agents CAN change between plugin launches (user installs
12
+ * a new agent) and the caller decides how often to re-probe.
13
+ */
14
+ export declare function detectInstalledAgents(): DetectableAgent[];
15
+ /**
16
+ * Detect-and-push convenience for plugin daemon startup. All three
17
+ * plugins (Claude, Gemini, Codex) call this once at start(). Runs
18
+ * the local PATH probe, then pushes the set to the backend via
19
+ * updateAvailableAgents. Idempotent — the backend dedupes and stores.
20
+ * Non-fatal on the network failure path (caller should `.catch()`
21
+ * and log but not abort startup — Quorum 2.0 auto-enable degrades
22
+ * to "use last-pushed agent set" when the mutation fails).
23
+ *
24
+ * @param client AppSyncClient that's already been authenticated via
25
+ * authenticateWithStoredTokens()
26
+ * @param log Logger — warn-level when no agents detected, info
27
+ * on success
28
+ */
29
+ export declare function pushDetectedAgents(client: AppSyncClient, log: Pick<Logger, 'info' | 'warn'>): Promise<void>;
30
+ /**
31
+ * Quorum 2.0 (2f.0.a.6) per-session orchestration CLI override applier.
32
+ * All three plugin wrappers (`codevibe-claude`, `codevibe-gemini`,
33
+ * `codevibe-codex`) export `CODEVIBE_ORCHESTRATION_OVERRIDE=true|false`
34
+ * to the tmux env when the user passes `--orchestration` /
35
+ * `--no-orchestration`. The daemon inherits this via the hook env
36
+ * chain and calls THIS function after every session-creation site
37
+ * to pin the per-session decision — wins outright over the server's
38
+ * User.orchestrationEnabledDefault auto-populate.
39
+ *
40
+ * Called from each plugin's daemon at every session-creation call
41
+ * site. Claude has one (handleSessionStart covers new + /resume
42
+ * because Claude Code fires SessionStart on /resume). Gemini has
43
+ * two (handleSessionStart + switchToResumedSession — /resume doesn't
44
+ * fire SessionStart in Gemini). Codex has two (createLaunchSession
45
+ * + handleSessionStarted — launch session gets replaced by runtime
46
+ * session_meta).
47
+ *
48
+ * Non-fatal on error — a failed override doesn't block session setup;
49
+ * the server's auto-populate decision stands and the user can flip
50
+ * the session via mobile toggle after the fact.
51
+ *
52
+ * @param client AppSyncClient authenticated for the session's owner
53
+ * @param sessionId Backend session ID (post-resumeOrCreateSession)
54
+ * @param log Logger
55
+ */
56
+ 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, mapV1KindToWire, 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 {};
@@ -0,0 +1,108 @@
1
+ import { WizardSeatPick, WizardStepFailureReason } from './setup-types.js';
2
+ import type { ReviewerSpec, ReviewerVerdict } from '../reviewer/index.js';
3
+ /**
4
+ * Canned proposal — byte-identical across all installations. Locked
5
+ * 2026-05-03 per PHASE-3-A-DESIGN.md §3. Do NOT edit without going
6
+ * through a re-review of the entire Test My Agents protocol; the
7
+ * prose is part of the wizard's contract test surface (the new-contract
8
+ * row at PHASE-3-A-DESIGN.md:495 asserts byte-identicality).
9
+ *
10
+ * The proposal is intentionally trivial + read-only. The wizard does
11
+ * NOT actually create /tmp/quorum_test_hello.py — APPROVE is the
12
+ * expected outcome from a working reviewer.
13
+ */
14
+ export declare const CANNED_PROPOSAL = "## Problem\nAdd a one-line Python \"Hello, World\" script to a new file.\n\n## Proposal\nCreate a single Python file at /tmp/quorum_test_hello.py containing the\nsingle line: print(\"hello world\")\n\n## Implementation Plan\n1. Create the file at /tmp/quorum_test_hello.py\n2. Write print(\"hello world\") on line 1 followed by a trailing newline\n3. Make no other changes\n\n## Expected Outputs\n- /tmp/quorum_test_hello.py \u2014 exists, contains the single-line script\n";
15
+ /**
16
+ * Per-seat timeout. PHASE-3-A-DESIGN.md §6 "Timeout (60s/seat)".
17
+ * Conservative — gives a slow CLI room to start + respond on a
18
+ * cold-spawned reviewer process. Shorter would pollute the failure
19
+ * recourse menu with false positives on first-run latency.
20
+ */
21
+ export declare const PER_SEAT_TIMEOUT_MS = 60000;
22
+ /**
23
+ * Per-seat outcome rendered by the wizard. Returned by
24
+ * `runTestMyAgents` in the `seatOutcomes` array so the recourse menu
25
+ * can display each seat's status individually (per §3 "per-seat
26
+ * outputs ... are tagged with the seat ID and rendered together").
27
+ */
28
+ export interface SeatOutcome {
29
+ seatId: number;
30
+ agent: WizardSeatPick['agent'];
31
+ role: WizardSeatPick['role'];
32
+ /** Wall-clock seconds elapsed for this seat's evaluate() call. */
33
+ elapsedSeconds: number;
34
+ /** Discriminated outcome — APPROVE plus the 6 failure shapes. */
35
+ result: {
36
+ kind: 'approve';
37
+ } | {
38
+ kind: 'revise';
39
+ } | {
40
+ kind: 'reject';
41
+ } | {
42
+ kind: 'escalate';
43
+ } | {
44
+ kind: 'parse_failure';
45
+ } | {
46
+ kind: 'spawn_failure';
47
+ reason: string;
48
+ } | {
49
+ kind: 'timeout';
50
+ elapsedMs: number;
51
+ } | {
52
+ kind: 'unknown_error';
53
+ message: string;
54
+ };
55
+ }
56
+ export type TestMyAgentsResult = {
57
+ ok: true;
58
+ seatOutcomes: SeatOutcome[];
59
+ } | {
60
+ ok: false;
61
+ reason: WizardStepFailureReason;
62
+ canSaveAnyway: boolean;
63
+ seatOutcomes: SeatOutcome[];
64
+ };
65
+ /**
66
+ * Inputs for `runTestMyAgents`. The registry factory is injected so
67
+ * tests can swap in a mock; production passes
68
+ * `createSubprocessReviewerRegistry`.
69
+ */
70
+ export interface TestMyAgentsDeps {
71
+ wizardRunId: string;
72
+ seats: WizardSeatPick[];
73
+ registryFactory?: () => {
74
+ evaluate: (spec: ReviewerSpec, gateId: string) => Promise<ReviewerVerdict>;
75
+ };
76
+ /**
77
+ * Status renderer. Tests pass a buffer; production passes a function
78
+ * that writes to process.stdout. Each call gets one line (no
79
+ * trailing newline added — caller controls).
80
+ */
81
+ write?: (line: string) => void;
82
+ /**
83
+ * Test seam: a synthetic gateId. Phase 3.a's wizard is wholly
84
+ * client-side (PHASE-3-A-DESIGN.md §5 "Wizard never spawns through
85
+ * OrchestrationClient.connect()"), so the gateId is a local
86
+ * synthetic UUID — providers echo it back on the verdict but the
87
+ * wizard does not persist it. Tests can pin a known value.
88
+ */
89
+ gateId?: string;
90
+ }
91
+ /**
92
+ * Run Step 2. Emits `wizard_step_started`, dispatches all seats in
93
+ * parallel via Promise.allSettled, classifies each outcome, emits
94
+ * `wizard_step_completed` (all APPROVE) or `wizard_step_failed` with
95
+ * the worst-blocker reason. Returns per-seat outcomes for the
96
+ * wizard's recourse renderer.
97
+ */
98
+ export declare function runTestMyAgents(deps: TestMyAgentsDeps): Promise<TestMyAgentsResult>;
99
+ /**
100
+ * Render a per-failure-kind explanatory sentence per the §6 outcome
101
+ * table + §1 line 140 "Display the structured error describing what
102
+ * failed" requirement. The wizard prints this before the recourse
103
+ * menu so users see WHY each non-APPROVE seat failed, not just a
104
+ * status line.
105
+ *
106
+ * R1 round-1 M3 (resolved 2026-05-08).
107
+ */
108
+ export declare function humanizeStep2Failures(outcomes: SeatOutcome[]): string[];