@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.
Files changed (195) hide show
  1. package/dist/__tests__/cp-5-baseline-invariants.test.d.ts +1 -0
  2. package/dist/adapter/__tests__/capabilities.test.d.ts +1 -0
  3. package/dist/adapter/__tests__/contract-conformance.test.d.ts +1 -0
  4. package/dist/adapter/__tests__/packets.test.d.ts +1 -0
  5. package/dist/adapter/__tests__/progress.test.d.ts +1 -0
  6. package/dist/adapter/__tests__/registry.test.d.ts +1 -0
  7. package/dist/adapter/__tests__/smoke/claude.smoke.test.d.ts +1 -0
  8. package/dist/adapter/__tests__/smoke/codex.smoke.test.d.ts +1 -0
  9. package/dist/adapter/__tests__/smoke/gemini.smoke.test.d.ts +1 -0
  10. package/dist/adapter/capabilities.d.ts +68 -0
  11. package/dist/adapter/index.d.ts +7 -0
  12. package/dist/adapter/packets.d.ts +129 -0
  13. package/dist/adapter/progress.d.ts +93 -0
  14. package/dist/adapter/registry.d.ts +24 -0
  15. package/dist/adapter/types.d.ts +22 -0
  16. package/dist/appsync/__tests__/appsync-client-apply-user-decision.test.d.ts +1 -0
  17. package/dist/appsync/__tests__/appsync-client-classb.test.d.ts +1 -0
  18. package/dist/appsync/__tests__/appsync-client-planner.test.d.ts +1 -0
  19. package/dist/appsync/__tests__/appsync-client.test.d.ts +1 -0
  20. package/dist/appsync/appsync-client.d.ts +278 -1
  21. package/dist/appsync/index.d.ts +1 -1
  22. package/dist/appsync/queries.d.ts +8 -0
  23. package/dist/audit-keys/__tests__/audit-keys-parity.test.d.ts +1 -0
  24. package/dist/audit-keys/index.d.ts +41 -0
  25. package/dist/auth/__tests__/auth-telemetry.test.d.ts +1 -0
  26. package/dist/auth/auth-telemetry.d.ts +29 -8
  27. package/dist/companion-mode/__tests__/persist-preference.test.d.ts +1 -0
  28. package/dist/companion-mode/__tests__/resolve-agent.test.d.ts +1 -0
  29. package/dist/companion-mode/agent-picker.d.ts +9 -0
  30. package/dist/companion-mode/index.d.ts +55 -0
  31. package/dist/companion-mode/persist-preference.d.ts +24 -0
  32. package/dist/companion-mode/resolve-agent.d.ts +41 -0
  33. package/dist/index.d.ts +13 -1
  34. package/dist/index.js +253 -33
  35. package/dist/local-executor/__tests__/authority-symlink-fixture.d.ts +15 -0
  36. package/dist/local-executor/__tests__/authority.test.d.ts +1 -0
  37. package/dist/local-executor/__tests__/class-a-emit.test.d.ts +1 -0
  38. package/dist/local-executor/__tests__/class-b-consumer.integration.test.d.ts +1 -0
  39. package/dist/local-executor/__tests__/class-b-consumer.test.d.ts +1 -0
  40. package/dist/local-executor/__tests__/hook-bridge.test.d.ts +1 -0
  41. package/dist/local-executor/__tests__/local-executor.integration.test.d.ts +1 -0
  42. package/dist/local-executor/__tests__/spawn.test.d.ts +1 -0
  43. package/dist/local-executor/__tests__/verification-runner.test.d.ts +1 -0
  44. package/dist/local-executor/authority.d.ts +29 -0
  45. package/dist/local-executor/class-a-emit.d.ts +138 -0
  46. package/dist/local-executor/class-b-consumer.d.ts +121 -0
  47. package/dist/local-executor/hook-bridge.d.ts +36 -0
  48. package/dist/local-executor/index.d.ts +8 -0
  49. package/dist/local-executor/local-executor-impl.d.ts +83 -0
  50. package/dist/local-executor/spawn.d.ts +6 -0
  51. package/dist/local-executor/types.d.ts +183 -0
  52. package/dist/local-executor/verification-gates/build.d.ts +6 -0
  53. package/dist/local-executor/verification-gates/deploy-preflight.d.ts +6 -0
  54. package/dist/local-executor/verification-gates/diff-sanity.d.ts +6 -0
  55. package/dist/local-executor/verification-gates/hostile-grep.d.ts +6 -0
  56. package/dist/local-executor/verification-gates/lint.d.ts +6 -0
  57. package/dist/local-executor/verification-gates/shell-runner.d.ts +40 -0
  58. package/dist/local-executor/verification-gates/source-traceability.d.ts +6 -0
  59. package/dist/local-executor/verification-gates/tests.d.ts +6 -0
  60. package/dist/local-executor/verification-gates/typecheck.d.ts +6 -0
  61. package/dist/local-executor/verification-runner.d.ts +28 -0
  62. package/dist/orchestration/__tests__/setup-bootstrap.test.d.ts +1 -0
  63. package/dist/orchestration/__tests__/setup-failure-recourse.test.d.ts +1 -0
  64. package/dist/orchestration/__tests__/setup-save.test.d.ts +1 -0
  65. package/dist/orchestration/__tests__/setup-seat-picker.test.d.ts +1 -0
  66. package/dist/orchestration/__tests__/setup-telemetry.test.d.ts +1 -0
  67. package/dist/orchestration/__tests__/setup-test-agents.test.d.ts +1 -0
  68. package/dist/orchestration/__tests__/setup-types.test.d.ts +1 -0
  69. package/dist/orchestration/__tests__/setup-wizard.test.d.ts +1 -0
  70. package/dist/orchestration/__tests__/v1-options.test.d.ts +1 -0
  71. package/dist/orchestration/detect-agents.d.ts +57 -0
  72. package/dist/orchestration/index.d.ts +3 -0
  73. package/dist/orchestration/orchestration-cli.d.ts +12 -0
  74. package/dist/orchestration/setup-bootstrap.d.ts +146 -0
  75. package/dist/orchestration/setup-failure-recourse.d.ts +23 -0
  76. package/dist/orchestration/setup-save.d.ts +47 -0
  77. package/dist/orchestration/setup-seat-picker.d.ts +72 -0
  78. package/dist/orchestration/setup-telemetry.d.ts +54 -0
  79. package/dist/orchestration/setup-test-agents.d.ts +108 -0
  80. package/dist/orchestration/setup-types.d.ts +140 -0
  81. package/dist/orchestration/setup-wizard.d.ts +57 -0
  82. package/dist/orchestration/v1-options.d.ts +97 -0
  83. package/dist/orchestration-shell/__tests__/cli-authority-bridge.test.d.ts +1 -0
  84. package/dist/orchestration-shell/__tests__/cli-planner-stack.test.d.ts +1 -0
  85. package/dist/orchestration-shell/__tests__/cli-singleton-enforcement.test.d.ts +1 -0
  86. package/dist/orchestration-shell/__tests__/cli-stub-session-adapter.test.d.ts +1 -0
  87. package/dist/orchestration-shell/__tests__/components.test.d.ts +1 -0
  88. package/dist/orchestration-shell/__tests__/emit-shell-event.test.d.ts +1 -0
  89. package/dist/orchestration-shell/__tests__/gate-prompts.test.d.ts +1 -0
  90. package/dist/orchestration-shell/__tests__/hostile-grep.test.d.ts +1 -0
  91. package/dist/orchestration-shell/__tests__/mode-selection.test.d.ts +1 -0
  92. package/dist/orchestration-shell/__tests__/process-markers.test.d.ts +1 -0
  93. package/dist/orchestration-shell/__tests__/reducer.test.d.ts +1 -0
  94. package/dist/orchestration-shell/__tests__/runOrchestrationShell-classify-dispatch.test.d.ts +1 -0
  95. package/dist/orchestration-shell/__tests__/runOrchestrationShell-planner-wiring.test.d.ts +1 -0
  96. package/dist/orchestration-shell/__tests__/runOrchestrationShell-signal.test.d.ts +1 -0
  97. package/dist/orchestration-shell/__tests__/runOrchestrationShell.test.d.ts +1 -0
  98. package/dist/orchestration-shell/__tests__/slash-router.test.d.ts +1 -0
  99. package/dist/orchestration-shell/__tests__/sticky-preference.test.d.ts +1 -0
  100. package/dist/orchestration-shell/cli.d.ts +96 -0
  101. package/dist/orchestration-shell/cli.js +8309 -0
  102. package/dist/orchestration-shell/cohort-flag.d.ts +16 -0
  103. package/dist/orchestration-shell/components/CodeVibeLogo.d.ts +2 -0
  104. package/dist/orchestration-shell/components/ConversationPane.d.ts +7 -0
  105. package/dist/orchestration-shell/components/GatePromptEntry.d.ts +9 -0
  106. package/dist/orchestration-shell/components/InputBar.d.ts +41 -0
  107. package/dist/orchestration-shell/components/OrchestrationApp.d.ts +63 -0
  108. package/dist/orchestration-shell/components/StatusBar.d.ts +7 -0
  109. package/dist/orchestration-shell/components/nodes/AdvisoryEntry.d.ts +8 -0
  110. package/dist/orchestration-shell/components/nodes/GateStatusNode.d.ts +8 -0
  111. package/dist/orchestration-shell/components/nodes/PlannerDecisionEntry.d.ts +8 -0
  112. package/dist/orchestration-shell/components/nodes/ReviewerQuorumStatusNode.d.ts +8 -0
  113. package/dist/orchestration-shell/components/nodes/SlashOutputEntry.d.ts +8 -0
  114. package/dist/orchestration-shell/components/nodes/SubagentEventEntry.d.ts +8 -0
  115. package/dist/orchestration-shell/components/nodes/UserMessageEntry.d.ts +8 -0
  116. package/dist/orchestration-shell/emit-shell-event.d.ts +64 -0
  117. package/dist/orchestration-shell/gate-prompts.d.ts +123 -0
  118. package/dist/orchestration-shell/index.d.ts +100 -0
  119. package/dist/orchestration-shell/ink-runtime.d.ts +64 -0
  120. package/dist/orchestration-shell/mode-selection.d.ts +46 -0
  121. package/dist/orchestration-shell/non-tty-fallback.d.ts +46 -0
  122. package/dist/orchestration-shell/process-markers.d.ts +12 -0
  123. package/dist/orchestration-shell/reducer.d.ts +8 -0
  124. package/dist/orchestration-shell/slash-router.d.ts +45 -0
  125. package/dist/orchestration-shell/sticky-preference.d.ts +24 -0
  126. package/dist/orchestration-shell/store.d.ts +17 -0
  127. package/dist/orchestration-shell/types.d.ts +417 -0
  128. package/dist/planner/__tests__/cache-clarification-bypass.test.d.ts +1 -0
  129. package/dist/planner/__tests__/cache.test.d.ts +1 -0
  130. package/dist/planner/__tests__/client.test.d.ts +1 -0
  131. package/dist/planner/__tests__/health-machine-transitions.test.d.ts +1 -0
  132. package/dist/planner/__tests__/types-zod.test.d.ts +1 -0
  133. package/dist/planner/adapter.d.ts +16 -0
  134. package/dist/planner/cache.d.ts +35 -0
  135. package/dist/planner/client.d.ts +103 -0
  136. package/dist/planner/health-state.d.ts +24 -0
  137. package/dist/planner/index.d.ts +5 -0
  138. package/dist/planner/types.d.ts +113 -0
  139. package/dist/reviewer/__tests__/integration.test.d.ts +1 -0
  140. package/dist/reviewer/__tests__/mocks.test.d.ts +1 -0
  141. package/dist/reviewer/__tests__/output-parser.test.d.ts +1 -0
  142. package/dist/reviewer/__tests__/registry.test.d.ts +1 -0
  143. package/dist/reviewer/__tests__/subprocess.test.d.ts +1 -0
  144. package/dist/reviewer/index.d.ts +15 -0
  145. package/dist/reviewer/mocks.d.ts +80 -0
  146. package/dist/reviewer/output-parser.d.ts +95 -0
  147. package/dist/reviewer/provider.d.ts +153 -0
  148. package/dist/reviewer/providers/__tests__/claude-live-smoke.test.d.ts +1 -0
  149. package/dist/reviewer/providers/__tests__/claude.test.d.ts +1 -0
  150. package/dist/reviewer/providers/__tests__/codex-live-smoke.test.d.ts +1 -0
  151. package/dist/reviewer/providers/__tests__/codex.test.d.ts +1 -0
  152. package/dist/reviewer/providers/__tests__/gemini-live-smoke.test.d.ts +1 -0
  153. package/dist/reviewer/providers/__tests__/gemini.test.d.ts +1 -0
  154. package/dist/reviewer/providers/claude.d.ts +59 -0
  155. package/dist/reviewer/providers/codex.d.ts +67 -0
  156. package/dist/reviewer/providers/common.d.ts +25 -0
  157. package/dist/reviewer/providers/gemini.d.ts +108 -0
  158. package/dist/reviewer/registry.d.ts +87 -0
  159. package/dist/reviewer/subprocess.d.ts +117 -0
  160. package/dist/reviewer/types.d.ts +101 -0
  161. package/dist/session/__tests__/session-resume-service-keys.test.d.ts +1 -0
  162. package/dist/session/session-resume.d.ts +24 -0
  163. package/dist/structural-summary/__tests__/__fixtures__/fixture-helpers.d.ts +11 -0
  164. package/dist/structural-summary/__tests__/assembler.test.d.ts +1 -0
  165. package/dist/structural-summary/__tests__/generator.test.d.ts +1 -0
  166. package/dist/structural-summary/__tests__/language-detect.test.d.ts +1 -0
  167. package/dist/structural-summary/__tests__/manifest-parsers/cargo.test.d.ts +1 -0
  168. package/dist/structural-summary/__tests__/manifest-parsers/gomod.test.d.ts +1 -0
  169. package/dist/structural-summary/__tests__/manifest-parsers/gradle.test.d.ts +1 -0
  170. package/dist/structural-summary/__tests__/manifest-parsers/index.test.d.ts +1 -0
  171. package/dist/structural-summary/__tests__/manifest-parsers/npm.test.d.ts +1 -0
  172. package/dist/structural-summary/__tests__/manifest-parsers/podfile.test.d.ts +1 -0
  173. package/dist/structural-summary/__tests__/manifest-parsers/pyproject.test.d.ts +1 -0
  174. package/dist/structural-summary/__tests__/opt-in-store.test.d.ts +1 -0
  175. package/dist/structural-summary/__tests__/privacy-filter.test.d.ts +1 -0
  176. package/dist/structural-summary/__tests__/safe-file-read.test.d.ts +1 -0
  177. package/dist/structural-summary/__tests__/user-ignore-matcher.test.d.ts +1 -0
  178. package/dist/structural-summary/__tests__/walker.test.d.ts +1 -0
  179. package/dist/structural-summary/generator.d.ts +8 -0
  180. package/dist/structural-summary/index.d.ts +7 -0
  181. package/dist/structural-summary/manifest-parsers/cargo.d.ts +3 -0
  182. package/dist/structural-summary/manifest-parsers/index.d.ts +7 -0
  183. package/dist/structural-summary/manifest-parsers/npm.d.ts +3 -0
  184. package/dist/structural-summary/manifest-parsers/other.d.ts +17 -0
  185. package/dist/structural-summary/opt-in-store.d.ts +24 -0
  186. package/dist/structural-summary/privacy-filter.d.ts +110 -0
  187. package/dist/structural-summary/safe-file-read.d.ts +11 -0
  188. package/dist/structural-summary/types.d.ts +215 -0
  189. package/dist/structural-summary/user-ignore-matcher.d.ts +9 -0
  190. package/dist/structural-summary/walker.d.ts +20 -0
  191. package/dist/types/events.d.ts +17 -2
  192. package/dist/types/index.d.ts +1 -0
  193. package/dist/types/reviewer.d.ts +67 -0
  194. package/dist/types/session.d.ts +16 -0
  195. package/package.json +22 -5
@@ -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[];
@@ -0,0 +1,140 @@
1
+ import type { ReviewerRole as PolicyReviewerRole } from '../reviewer/types.js';
2
+ import type { AgentKind } from '../reviewer/types.js';
3
+ import { AgentType } from '../types/session.js';
4
+ import { ReviewerRole as SchemaReviewerRole } from '../types/reviewer.js';
5
+ /**
6
+ * Tier returned by `getSubscriptionStatus`. Drives seat budget +
7
+ * tier-gate at bootstrap.
8
+ *
9
+ * UPPERCASE wire format matches `codevibe-backend/graphql/schema.graphql:209`
10
+ * (`enum SubscriptionTier { FREE PRO MAX }`).
11
+ */
12
+ export type WizardTier = 'FREE' | 'PRO' | 'MAX';
13
+ /**
14
+ * Tier-aware seat budget. Mirrors
15
+ * `codevibe-backend/lambda/user-management/index.ts:184-188`'s
16
+ * `REVIEWER_SEAT_COUNT` map. Free has no seats — orchestration is not
17
+ * permitted at that tier; the wizard short-circuits at bootstrap with
18
+ * the §6 upgrade interstitial.
19
+ */
20
+ export declare const SEAT_BUDGET: Record<WizardTier, number | null>;
21
+ /**
22
+ * The 3-role lock from PHASE-3-A-DESIGN.md: the wizard offers ONLY
23
+ * `architecture` / `correctness` / `security`. The schema's
24
+ * `ReviewerRole` enum at `codevibe-backend/graphql/schema.graphql:167-177`
25
+ * still has 9 variants for backward compat / 2.0.x custom-roles
26
+ * (#80) — but the wizard NEVER sends a non-3-role seat to
27
+ * `updateReviewerPolicy`.
28
+ *
29
+ * snake_case matches `codevibe-core/src/reviewer/types.ts:52-61` (the
30
+ * reviewer-module wire). The wizard converts to AppSync UPPERCASE at
31
+ * the save boundary via `roleToAppSync()`.
32
+ */
33
+ export declare const WIZARD_ROLES: readonly ["architecture", "correctness", "security"];
34
+ export type WizardRole = (typeof WIZARD_ROLES)[number];
35
+ /**
36
+ * Tier-aware default role for each seat (§1 "Default-role fallback").
37
+ * Seat 0 = architecture, Seat 1 = correctness, Seat 2 = security.
38
+ * When the canonical default is already taken by a previous seat, the
39
+ * wizard falls back to the first remaining role in canonical order.
40
+ */
41
+ export declare const DEFAULT_ROLE_BY_SEAT: WizardRole[];
42
+ /**
43
+ * Canonical agent ordering used for wizard defaults. The first
44
+ * installed agent in this order is the default for each seat unless
45
+ * the user picks otherwise.
46
+ */
47
+ export declare const AGENT_PRIORITY: AgentKind[];
48
+ /**
49
+ * The wizard's terminal outcomes. Drives `wizard_completed` /
50
+ * `wizard_aborted` GA4 events and the exit code.
51
+ */
52
+ export type WizardOutcome = {
53
+ kind: 'ok';
54
+ saved: true;
55
+ seats: ReadonlyArray<WizardSeatPick>;
56
+ } | {
57
+ kind: 'saved_after_test_warning';
58
+ saved: true;
59
+ seats: ReadonlyArray<WizardSeatPick>;
60
+ } | {
61
+ kind: 'aborted';
62
+ reason: WizardAbortReason;
63
+ lastStep: WizardStep;
64
+ };
65
+ /**
66
+ * Reasons the wizard exited without saving. Mirror the
67
+ * `wizard_aborted.reason` taxonomy in PHASE-3-A-DESIGN.md §7.
68
+ */
69
+ export type WizardAbortReason = 'ctrl_c' | 'tier_gate_free' | 'no_clis' | 'step_user_exit' | 'step_save_failed_exit' | 'auth_expired' | 'bootstrap_failure';
70
+ /**
71
+ * Wizard step taxonomy — used for `wizard_step_started`/`completed`/
72
+ * `failed` and `wizard_aborted.last_step`.
73
+ */
74
+ export type WizardStep = 'bootstrap' | 'seat_assignment' | 'test_my_agents' | 'save';
75
+ /**
76
+ * Per-step `wizard_step_failed.reason` codes. Mirror the table in
77
+ * PHASE-3-A-DESIGN.md §7. Each step has its own bounded reason set;
78
+ * `seat_assignment` has no failure modes (the picker filters out
79
+ * invalid choices UI-side).
80
+ */
81
+ export type WizardStepFailureReason = 'tier_gate_free' | 'not_signed_in' | 'subscription_status_network' | 'no_clis_installed' | 'test_revise' | 'test_reject' | 'test_escalate' | 'test_parse_failure' | 'test_spawn_failure' | 'test_timeout' | 'update_policy_network' | 'update_policy_5xx' | 'update_policy_throttle' | 'auth_token_expired';
82
+ /**
83
+ * One seat the user picked in Step 1. The wizard converts these to
84
+ * `ReviewerAgentSpecInput[]` at save time by uppercase-mapping role +
85
+ * agent (the schema's wire form).
86
+ */
87
+ export interface WizardSeatPick {
88
+ seatId: number;
89
+ agent: AgentKind;
90
+ role: WizardRole;
91
+ }
92
+ /**
93
+ * Latency bucket for GA4 `latency_bucket_s` / `total_latency_bucket_s`
94
+ * dimensions. Bounded set — keeps GA4 cardinality tractable per R2
95
+ * round-1 MEDIUM (PHASE-3-A-DESIGN.md §7).
96
+ */
97
+ export type LatencyBucket = '<2' | '2-5' | '5-10' | '10-30' | '30+';
98
+ /**
99
+ * Categorical bucket for "how many agents are installed" /
100
+ * "how many seats". Locked at "1" / "2" / "3" — there is no "4+"
101
+ * because Max is the ceiling.
102
+ */
103
+ export type CountBucket = '1' | '2' | '3';
104
+ /**
105
+ * Entry point identifier — distinguishes meta CLI invocation from
106
+ * each plugin's alias (`codevibe-{claude,gemini,codex} orchestration setup`).
107
+ */
108
+ export type WizardEntry = 'meta_cli' | 'claude_alias' | 'gemini_alias' | 'codex_alias';
109
+ /**
110
+ * Bucket a wall-clock duration into one of the 5 latency-bucket values.
111
+ * Used by telemetry for per-step + total-wizard timing dimensions.
112
+ */
113
+ export declare function bucketLatencySeconds(seconds: number): LatencyBucket;
114
+ /**
115
+ * Bucket an integer count into "1" / "2" / "3", clamping anything
116
+ * higher to "3". Used for `seats_bucket`, `agents_distinct_bucket`,
117
+ * `roles_distinct_bucket`, `installed_agents_bucket`.
118
+ */
119
+ export declare function bucketCount(n: number): CountBucket;
120
+ /**
121
+ * Map a wizard role (snake_case) to the reviewer-module's snake_case
122
+ * `ReviewerRole` literal type — used when building a `ReviewerSpec`
123
+ * for `createSubprocessReviewerRegistry().evaluate()`. Pass-through
124
+ * because `WizardRole` is a strict subset of `PolicyReviewerRole`.
125
+ */
126
+ export declare function roleToReviewerSpec(role: WizardRole): PolicyReviewerRole;
127
+ /**
128
+ * Map a wizard role (snake_case) to the AppSync schema's UPPERCASE
129
+ * `ReviewerRole` enum — used when building a `ReviewerAgentSpecInput`
130
+ * for the `updateReviewerPolicy` mutation. The wizard locks to 3
131
+ * roles, so this mapping is exhaustive over `WizardRole` and never
132
+ * produces one of the 6 non-3-role variants.
133
+ */
134
+ export declare function roleToAppSync(role: WizardRole): SchemaReviewerRole;
135
+ /**
136
+ * Map AgentKind (lowercase reviewer-module wire) to the AppSync
137
+ * `AgentType` enum (UPPERCASE). Used at save time when building the
138
+ * `ReviewerAgentSpecInput[]` for `updateReviewerPolicy`.
139
+ */
140
+ export declare function agentToAppSync(agent: AgentKind): AgentType;
@@ -0,0 +1,57 @@
1
+ import { DetectableAgent } from './detect-agents.js';
2
+ import { WizardEntry } from './setup-types.js';
3
+ import { PickerIO } from './setup-seat-picker.js';
4
+ import { AppSyncClient } from '../appsync/appsync-client.js';
5
+ import type { ReviewerSpec, ReviewerVerdict } from '../reviewer/index.js';
6
+ /**
7
+ * Parse `--entry=<value>` from argv. Defaults to `meta_cli` if absent
8
+ * or invalid. Plugin wrappers pass `--entry=claude_alias` /
9
+ * `gemini_alias` / `codex_alias` per the §4 alias contract.
10
+ */
11
+ export declare function parseEntry(argv: string[]): WizardEntry;
12
+ /**
13
+ * Injectable dependencies for `runSetupWizardWithDeps`. Factored out
14
+ * so unit tests can drive the whole state machine deterministically
15
+ * (no real readline, no real subprocess spawn, no real network).
16
+ *
17
+ * Production callers use `runSetupWizard`, which wires the production
18
+ * deps + calls `process.exit(result.exitCode)`.
19
+ */
20
+ export interface SetupWizardDeps {
21
+ /** Builds an authenticated AppSyncClient or returns null if unauthenticated. */
22
+ clientFactory: () => Promise<AppSyncClient | null>;
23
+ /** Returns the subset of agents present on PATH. */
24
+ agentDetector: () => DetectableAgent[];
25
+ /** Optional reviewer registry (Step 2). Default: real subprocess registry. */
26
+ registryFactory?: () => {
27
+ evaluate: (spec: ReviewerSpec, gateId: string) => Promise<ReviewerVerdict>;
28
+ };
29
+ /** Output writer — writes the line as-is (caller controls newlines). */
30
+ write: (line: string) => void;
31
+ /** Build a fresh PickerIO + close handle for the next interactive prompt. */
32
+ createPickerIO: () => {
33
+ io: PickerIO;
34
+ close: () => void;
35
+ };
36
+ }
37
+ /**
38
+ * Result of the wizard's state machine. The public `runSetupWizard`
39
+ * wrapper translates this to a `process.exit(exitCode)`.
40
+ */
41
+ export interface SetupWizardResult {
42
+ exitCode: number;
43
+ }
44
+ /**
45
+ * Production entry point. Called from `runOrchestrationCli` when
46
+ * `argv[3] === 'setup'`. Builds production deps + calls process.exit
47
+ * with the wizard's exit code. Drives the full state machine via
48
+ * `runSetupWizardWithDeps`.
49
+ */
50
+ export declare function runSetupWizard(argv: string[]): Promise<void>;
51
+ /**
52
+ * Testable wizard core. Exits with code 0 on success or any user-
53
+ * initiated abort; exit 1 on a failure the user couldn't recover
54
+ * from in the recourse loop. SIGINT is registered + cleaned up
55
+ * around the call (no-op for tests when SIGINT is never fired).
56
+ */
57
+ export declare function runSetupWizardWithDeps(argv: string[], deps: SetupWizardDeps): Promise<SetupWizardResult>;
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Discriminator value emitted by the engine on
3
+ * `metadata.prompt_kind` for orchestration-escalated gate prompts.
4
+ *
5
+ * Sources of truth (any drift breaks the V1 bridge):
6
+ * - Engine emit: codevibe-core-rs `appsync_emit.rs:847-862`
7
+ * (`build_metadata_json` — emits exactly 5 keys: `tool_name`,
8
+ * `payload`, `prompt_kind`, `summary`, `timeline`).
9
+ * - iOS branch: MessageBubble.swift `extractInteractivePromptOptions`.
10
+ * - Android branch: MessageBubble.kt `extractOptions`.
11
+ */
12
+ export declare const V1_ORCHESTRATION_PROMPT_KIND: "orchestration_escalated_gate";
13
+ /**
14
+ * V1 user-decision kind (3-position subset of the 5-kind enum).
15
+ *
16
+ * Lowercase snake_case matches `@quantiya/quorum-core`'s `UserDecisionKind`
17
+ * caller-facing type at `codevibe-core-rs/packages/quorum-core/src/types.ts:232-238`.
18
+ * The quorum-core SDK's `applyUserDecision` mutator accepts this lowercase
19
+ * form and internally uppercases via `toWireEnum` before AppSync wire-send
20
+ * (`client.ts:244-246` + line 474). Plugins pass lowercase; the SDK is the
21
+ * conversion layer.
22
+ *
23
+ * iOS + Android pin UPPERCASE in their own enums because they call AppSync
24
+ * GraphQL directly via Amplify (no SDK conversion layer in their path).
25
+ * Both are correct at their respective layers.
26
+ *
27
+ * The two `_WITH_NOTES` variants from the full 5-kind enum are V2 — they
28
+ * require a `notes: EncryptedPayloadInput` value alongside the kind, and
29
+ * V1's "type a number" UX has no notes-input surface. They are deliberately
30
+ * EXCLUDED from this union; `mapOptionNumberToUserDecisionKind` cannot
31
+ * return them.
32
+ */
33
+ export type V1UserDecisionKind = 'accept' | 'reject_restart' | 'abort_task';
34
+ /**
35
+ * One row of the V1 orchestration option table.
36
+ *
37
+ * `number` is a string (`"1"` / `"2"` / `"3"`) to match iOS' tuple shape
38
+ * `(number: String, text: String)` and the existing
39
+ * `InteractivePromptOption` shape elsewhere in the mobile renderers.
40
+ */
41
+ export interface V1OrchestrationOption {
42
+ readonly number: string;
43
+ readonly label: string;
44
+ readonly kind: V1UserDecisionKind;
45
+ }
46
+ /**
47
+ * The V1 hardcoded 3-position option table.
48
+ *
49
+ * Order is LOAD-BEARING — `V1_ORCHESTRATION_OPTIONS[i].kind` is the kind
50
+ * sent to the server when the user types option-number `i+1`. Drift from
51
+ * iOS / Android = wrong `UserDecisionKind` on the wire (engine has no
52
+ * server-side validation).
53
+ *
54
+ * position 1 -> accept -> "Accept"
55
+ * position 2 -> reject_restart -> "Reject (restart proposal)"
56
+ * position 3 -> abort_task -> "Abort task"
57
+ *
58
+ * (Kind values are lowercase to match the SDK caller-facing type — see
59
+ * the header comment on the SDK conversion layer. iOS + Android pin
60
+ * UPPERCASE in their own constant tables because they hit AppSync
61
+ * directly without the SDK.)
62
+ *
63
+ * Frozen with `as const` so callers cannot mutate the array nor swap
64
+ * entries in place at runtime.
65
+ */
66
+ export declare const V1_ORCHESTRATION_OPTIONS: readonly [
67
+ V1OrchestrationOption,
68
+ V1OrchestrationOption,
69
+ V1OrchestrationOption
70
+ ];
71
+ /**
72
+ * Map a 1-based option number typed by the user to the matching V1
73
+ * `UserDecisionKind`. Returns `null` for ANY number outside 1..3 —
74
+ * callers MUST surface an error and abort the submit on null (the
75
+ * engine would reject `_WITH_NOTES` kinds without a notes payload in
76
+ * V1, and ANY out-of-range number means the user hit a typo, an
77
+ * accidental keystroke, or a malformed prompt).
78
+ *
79
+ * Out-of-range MUST return null — NOT fall back to `ACCEPT` or any
80
+ * default. A silent fallback would silently destroy or accept the
81
+ * user's work without their consent. Pinned by the
82
+ * `out-of-range returns null` test.
83
+ *
84
+ * @param optionNumber 1-based option position as typed by the user.
85
+ * @returns The matching `V1UserDecisionKind`, or `null` when out of range.
86
+ */
87
+ export declare function mapOptionNumberToUserDecisionKind(optionNumber: number): V1UserDecisionKind | null;
88
+ /**
89
+ * Shorter alias of `mapOptionNumberToUserDecisionKind`. Matches the helper
90
+ * name used in `PHASE-3-B-MOBILE-V1-BRIDGE-DESIGN.md` §3.1 + §6 Test 9 +
91
+ * §8 source-map row (`mapOptionToUserDecisionKind`). Both names point at
92
+ * the same function — pick whichever reads cleaner at the call site.
93
+ *
94
+ * Plugins can `import { mapOptionToUserDecisionKind }` per the design
95
+ * doc's call-site example at §3.1.
96
+ */
97
+ export declare const mapOptionToUserDecisionKind: typeof mapOptionNumberToUserDecisionKind;
@@ -0,0 +1,96 @@
1
+ import { AppSyncClient } from '../appsync';
2
+ import { Session } from '../types';
3
+ import { type ShellEventEmit } from './emit-shell-event';
4
+ import { BackendPlannerClient, PlannerCacheLayer, PlannerHealthMachine } from '../planner';
5
+ import type { PlannerAdapter, PlannerInput, PlannerDecision, PlannerProbeResult } from '../planner/adapter';
6
+ /**
7
+ * CP-1.b IMPL r5 H-1 — Sentinel error thrown by the stub-session
8
+ * planner adapter. `handleShellUserInput` catches this typed class and
9
+ * routes it through the explicit error renderer (SLASH_OUTPUT) so the
10
+ * user sees an actionable message in the conversation pane instead of
11
+ * a silent log line. Stub sessions (sessionId prefix `cp1a-local-` or
12
+ * empty `encryptedKeys`) cannot reach the Lambda — `encryptedKeys` is
13
+ * missing, the keychain resolver returns null, and the planner client
14
+ * throws "session key unresolved" deep inside classify(). Surfacing
15
+ * that as a typed error at the adapter boundary is cleaner than the
16
+ * generic Error from `BackendPlannerClient.classify()`.
17
+ */
18
+ export declare class PlannerUnavailableError extends Error {
19
+ constructor(msg: string);
20
+ }
21
+ /**
22
+ * CP-1.b IMPL r5 H-1 — Stub-session planner adapter.
23
+ *
24
+ * CP-1.a still ships a fake `cp1a-local-*` session with no
25
+ * `encryptedKeys[]`. The production `BackendPlannerClient` cannot
26
+ * classify against that session — the Lambda requires E2E-encrypted
27
+ * payloads, which requires the session key, which the keychain
28
+ * resolver cannot derive without `encryptedKeys`.
29
+ *
30
+ * Rather than wire up the production stack and let it fail with a
31
+ * generic "session key unresolved" Error deep inside classify(), we
32
+ * detect stub sessions at bootstrap and construct this adapter, which
33
+ * throws a typed `PlannerUnavailableError` on classify(). The shell's
34
+ * `handleShellUserInput` catches this and renders an actionable
35
+ * message to the user (`PLANNER_UNAVAILABLE: <reason>`). CP-1.c lands
36
+ * the real session bootstrap (resumeOrCreateSession + AppSync) and
37
+ * this adapter is no longer wired in.
38
+ */
39
+ export declare class PlannerUnavailableAdapter implements PlannerAdapter {
40
+ private readonly reason;
41
+ private activeSessionId;
42
+ constructor(reason: string);
43
+ classify(_input: PlannerInput): Promise<PlannerDecision>;
44
+ probe(): Promise<PlannerProbeResult>;
45
+ setActiveSession(sessionId: string | null): void;
46
+ }
47
+ /**
48
+ * CP-1.b IMPL r5 H-1 — Detect a CP-1.a stub session. Two signals:
49
+ * (a) `sessionId` starts with `cp1a-local-` (the
50
+ * `buildStubSession()` prefix).
51
+ * (b) `session.encryptedKeys` is empty / missing (any session
52
+ * lacking E2E keys cannot route through the Lambda).
53
+ *
54
+ * Either signal triggers the stub-session adapter. The (b) gate is
55
+ * a defensive fallback for the case where CP-1.c starts a real
56
+ * session bootstrap but `prepareSessionEncryption()` returns null
57
+ * (no device keys registered): the planner is genuinely unavailable
58
+ * until the user registers a device key.
59
+ */
60
+ export declare function isStubSession(session: Session): boolean;
61
+ export declare function main(argv: string[]): Promise<number>;
62
+ /**
63
+ * CP-1.b IMPL r4 H-1 — Production planner stack factory.
64
+ *
65
+ * Builds the full BackendPlannerClient + PlannerCacheLayer +
66
+ * PlannerHealthMachine chain so the orchestration shell can call
67
+ * `plannerAdapter.classify()` on natural-language input.
68
+ *
69
+ * Co-located with the CLI bootstrap (NOT inside `runOrchestrationShell`)
70
+ * because the shell accepts an injected adapter for tests; the
71
+ * production bootstrap site is the single canonical instantiation
72
+ * point.
73
+ *
74
+ * Exported for unit tests; production callers go through `main()`.
75
+ */
76
+ export declare function buildProductionPlannerStack(appsyncClient: AppSyncClient, emitter: (args: ShellEventEmit) => Promise<void>): {
77
+ adapter: BackendPlannerClient;
78
+ cache: PlannerCacheLayer;
79
+ health: PlannerHealthMachine;
80
+ };
81
+ import { HookBridge } from '../local-executor/hook-bridge';
82
+ export interface BridgeRefusalArgs {
83
+ refusedMessageId: string;
84
+ shellContent: string;
85
+ shellMetadata?: Record<string, unknown>;
86
+ }
87
+ /**
88
+ * Wrap any async operation that may throw `AuthorityError`; on refusal, emit
89
+ * the two-channel refusal pair (LOCK #C4-3) via the supplied HookBridge and
90
+ * re-throw. Non-AuthorityError exceptions propagate unchanged.
91
+ *
92
+ * The HookBridge passed in MUST be the same instance the orchestration shell
93
+ * uses for plugin-hook ingestion — both paths share the audit-before-shell
94
+ * ordering invariant via the bridge's `bridgeAuthorityRefusal` method.
95
+ */
96
+ export declare function bridgeAuthorityErrorToShellRefusal<T>(bridge: HookBridge, refusalArgs: BridgeRefusalArgs, fn: () => Promise<T>): Promise<T>;