@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,46 @@
1
+ import { OrchestrationStore } from './store';
2
+ import { ConversationEntry } from './types';
3
+ export interface RunLineLogFallbackArgs {
4
+ store: OrchestrationStore;
5
+ /** CP-1.b PlannerAdapter; CP-1.a passes a stub or `undefined`. */
6
+ plannerClient?: unknown;
7
+ /** CP-1.b cache layer; CP-1.a passes a stub or `undefined`. */
8
+ cacheLayer?: unknown;
9
+ /** CP-1.b health machine; CP-1.a passes a stub or `undefined`. */
10
+ healthMachine?: unknown;
11
+ /** CP-1.c executor; CP-1.a passes a stub or `undefined`. */
12
+ executor?: unknown;
13
+ /** Optional override for input — defaults to `process.stdin`. */
14
+ input?: NodeJS.ReadableStream;
15
+ /** Optional override for output — defaults to `process.stdout`. */
16
+ output?: NodeJS.WritableStream;
17
+ /** Optional onUserInput handler (host wires this to the slash router / planner classifier). */
18
+ onUserInput?: (text: string) => Promise<void> | void;
19
+ /**
20
+ * CP-1.b IMPL r4 H-3 — Optional abort signal so the surrounding
21
+ * shell can break the readline loop on SIGINT/SIGTERM. Aborting
22
+ * triggers a clean rl.close() so the awaiting promise resolves.
23
+ */
24
+ signal?: AbortSignal;
25
+ }
26
+ /**
27
+ * Renders a single `ConversationEntry` as a line-prefixed text string.
28
+ * Strict text only — no ANSI escapes, no colors, no `\r` rewrites.
29
+ */
30
+ export declare function renderEntryAsLine(entry: ConversationEntry): string;
31
+ /**
32
+ * Subscribes to the store and prints new conversation entries as
33
+ * line-prefixed text. Returns a promise that resolves on `EXIT` action
34
+ * (currently inferred by the store-state being a re-emission of the
35
+ * same state object after `EXIT` dispatch — the runner uses an
36
+ * `exitRequested` flag toggled by an external dispatch wrapper).
37
+ *
38
+ * CP-1.a ships the basic line-log + stdin readline loop; CP-1.b/c
39
+ * additional knobs (plannerClient, cacheLayer, executor) are accepted
40
+ * as optional args but ignored. The runner exits on:
41
+ * - The host's onUserInput throwing (propagated).
42
+ * - stdin closing (EOF).
43
+ * - `/quit` slash command (the host detects via the SLASH_OUTPUT
44
+ * action's sideEffect — the host wires `exitRequested` here).
45
+ */
46
+ export declare function runLineLogFallback(args: RunLineLogFallbackArgs): Promise<void>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The three baseline markers every subprocess inherits. `CODEVIBE_PROCESS_ROLE`
3
+ * defaults to `'implementor'`; per-subprocess role overrides via
4
+ * `withRoleMarker()`.
5
+ */
6
+ export declare function processMarkers(): Record<string, string>;
7
+ /**
8
+ * Returns `base` with `CODEVIBE_PROCESS_ROLE` overridden to `role`.
9
+ * CP-1.c will call this per-spawn (e.g., reviewer spawns set role to
10
+ * `'reviewer'`; planner-health probes to `'health_probe'`).
11
+ */
12
+ export declare function withRoleMarker(base: Record<string, string>, role: 'implementor' | 'reviewer' | 'health_probe' | 'auth_probe' | 'model_probe'): Record<string, string>;
@@ -0,0 +1,8 @@
1
+ import { OrchestrationAction, OrchestrationState } from './types';
2
+ /** Max conversation-buffer size per §5.1 line 469 ("bounded ring buffer (last 500 entries)"). */
3
+ export declare const CONVERSATION_BUFFER_MAX = 500;
4
+ /**
5
+ * Pure reducer. Returns a NEW state object on every dispatch — never
6
+ * mutates `state` in place. Map fields are cloned via `new Map(state.x)`.
7
+ */
8
+ export declare function reducer(state: OrchestrationState, action: OrchestrationAction): OrchestrationState;
@@ -0,0 +1,45 @@
1
+ import { OrchestrationAction } from './types';
2
+ /**
3
+ * Side effects a handler can request the entrypoint to dispatch.
4
+ * The router itself never touches the store — keeps slash handling
5
+ * pure for unit testing.
6
+ *
7
+ * Widened to a 3-arm union by CP-1.d per `PHASE-CP-1-D-DESIGN.md` §4.8
8
+ * (lines 1060-1066). `[ADDITIVE WIDENING — CP-1.d]` — the §16 LOCK #10
9
+ * slash-command CATALOG (names + ownership patterns) is unchanged; the
10
+ * internal side-effect kind is implementation detail of the orchestration
11
+ * shell and never crosses the AppSync boundary.
12
+ */
13
+ export type ShellAction = {
14
+ kind: 'EXIT';
15
+ } | {
16
+ kind: 'REGENERATE_STRUCTURAL_SUMMARY';
17
+ } | {
18
+ kind: 'OPT_IN_BODY_PATH';
19
+ path: string;
20
+ };
21
+ export interface SlashOutput {
22
+ /** Verbatim user input (including leading `/`). Echoed in the conversation entry. */
23
+ command: string;
24
+ /** Rendered text shown inline in `<ConversationPane>` (per §11). */
25
+ output: string;
26
+ /** Optional side effect; only `/quit` populates it in CP-1.a. */
27
+ sideEffect?: ShellAction;
28
+ }
29
+ /**
30
+ * §16 LOCK #10 + §5.1.5 + §11 row. Routes user input that starts with
31
+ * `/`. Per §17 Q3 RESOLVED disposition: EXACT-MATCH only. Unknown
32
+ * commands return a help hint.
33
+ */
34
+ export declare function routeSlashCommand(input: string): SlashOutput;
35
+ /**
36
+ * Convenience helper for callers that wire the side effect directly
37
+ * into the store. CP-1.a's `cli.ts` uses this; CP-1.b/c may dispatch
38
+ * the resulting `slash-output` action plus the side effect.
39
+ */
40
+ export declare function applySlashOutput(output: SlashOutput): {
41
+ storeAction: Extract<OrchestrationAction, {
42
+ type: 'SLASH_OUTPUT';
43
+ }>;
44
+ exit: boolean;
45
+ };
@@ -0,0 +1,24 @@
1
+ import { Mode, Tier } from './types';
2
+ /**
3
+ * Filesystem location of the sticky preference file.
4
+ */
5
+ export declare function stickyPreferenceFilePath(): string;
6
+ /**
7
+ * §2 LOCK lines 103-116. Reads the sticky preference. Returns `null`
8
+ * on every failure mode the design names:
9
+ * - file missing
10
+ * - malformed JSON
11
+ * - schema-version mismatch
12
+ * - `pickedByTier === 'PRO'` but current tier is now `FREE`
13
+ * (tier downgrade INVALIDATES the sticky)
14
+ */
15
+ export declare function readStickyPreference(currentTier?: Tier): Promise<Mode | null>;
16
+ /**
17
+ * Writes the sticky preference. Creates the parent directory if
18
+ * missing. Used by the orchestration-mode entrypoint after a user
19
+ * picks a mode via the interactive prompt.
20
+ */
21
+ export declare function writeStickyPreference(args: {
22
+ mode: Mode;
23
+ pickedByTier: 'PRO' | 'MAX';
24
+ }): Promise<void>;
@@ -0,0 +1,17 @@
1
+ import { Session } from '../types';
2
+ import { OrchestrationAction, OrchestrationState } from './types';
3
+ export interface OrchestrationStore {
4
+ getState(): OrchestrationState;
5
+ dispatch(action: OrchestrationAction): void;
6
+ /**
7
+ * Subscribe to state changes. Returns an unsubscribe fn. The
8
+ * listener fires AFTER each dispatch with the new state.
9
+ */
10
+ subscribe(listener: (state: OrchestrationState) => void): () => void;
11
+ }
12
+ export interface CreateOrchestrationStoreArgs {
13
+ session: Session;
14
+ /** Optional initial state override for tests. */
15
+ initial?: Partial<OrchestrationState>;
16
+ }
17
+ export declare function createOrchestrationStore(args: CreateOrchestrationStoreArgs): OrchestrationStore;
@@ -0,0 +1,417 @@
1
+ import { Session } from '../types/session';
2
+ import type { StructuralSummary } from '../structural-summary/types';
3
+ import type { GatePromptEnvelope } from './gate-prompts';
4
+ /**
5
+ * Engine's reply to `applyUserDecision`. Surfaced by the SDK as
6
+ * `Promise<PostDecisionAction>`. Discriminated by `kind`; payload
7
+ * fields are snake_case to match the SDK's wire-form parse.
8
+ */
9
+ export type PostDecisionAction = {
10
+ kind: 'terminate_gate';
11
+ notes: string | null;
12
+ } | {
13
+ kind: 'open_new_round';
14
+ next_round: number;
15
+ user_notes: string;
16
+ } | {
17
+ kind: 'restart_proposal';
18
+ } | {
19
+ kind: 'abort_task';
20
+ };
21
+ /**
22
+ * CP-1.a §2 LOCK. The literal union used for sticky-preference, mode
23
+ * selection, and the `MODE_SELECTED` EventType `metadata.mode` field.
24
+ */
25
+ export type Mode = 'companion' | 'orchestration';
26
+ /**
27
+ * Structural stub matching the design §6 5-action schema. CP-1.b
28
+ * replaces this with the real `PlannerDecision` from
29
+ * `codevibe-core/src/planner/adapter.ts`. CP-1.a only needs the
30
+ * SHAPE — never inspects field semantics beyond what `OrchestrationAction`
31
+ * consumes.
32
+ *
33
+ * Per §6 line 958-965: discriminated by `action`; `clarifying_question`
34
+ * present only when action === 'ask_user'; `advisory_summary` only
35
+ * when action === 'advisory_response'; `gateRequest` opaque per §6
36
+ * line 967-972 (CP-2 Stage A finalises shape).
37
+ */
38
+ export interface PlannerDecision {
39
+ action: 'start_task' | 'summarize_current_status' | 'advisory_response' | 'ask_user' | 'refuse';
40
+ rationale: string;
41
+ clarifying_question?: string;
42
+ advisory_summary?: string;
43
+ /**
44
+ * Opaque per §6 line 967-972; CP-1 NEVER inspects fields. CP-2 Stage A
45
+ * locks shape.
46
+ */
47
+ gateRequest?: Record<string, unknown>;
48
+ }
49
+ export type AgentKind = 'CLAUDE' | 'GEMINI' | 'CODEX';
50
+ /**
51
+ * Health-state surface from §8. CP-1.a stores this in
52
+ * `OrchestrationState.plannerHealth`; CP-1.b's state machine drives
53
+ * the transitions.
54
+ */
55
+ export type PlannerHealthState = 'Available' | 'Degraded' | 'Outage';
56
+ /**
57
+ * §5.1 store-shape LOCK (lines 537-545). Implementor subprocess
58
+ * lifecycle from spawn to clean exit.
59
+ */
60
+ export interface RunningTaskState {
61
+ taskId: string;
62
+ agentKind: AgentKind;
63
+ pid: number;
64
+ startedAt: string;
65
+ status: 'running' | 'cancelling' | 'completed' | 'cancelled' | 'failed';
66
+ exitCode?: number;
67
+ bypassReason?: 'deterministic_shortcut' | 'planner_outage' | 'planner_degraded_explicit_override';
68
+ }
69
+ /**
70
+ * §5.1 LOCK (lines 547-556). Single reviewer subprocess identity +
71
+ * verdict. `reviewerKind` is hand-listed per CP-1 — CP-3 Stage A
72
+ * widens to the full reviewer-registry per `[DEFERRED TECH DEBT — CP-3]`
73
+ * note at design line 774.
74
+ */
75
+ export interface ReviewerSeatState {
76
+ seatId: string;
77
+ reviewerKind: 'codex' | 'gemini' | 'claude';
78
+ status: 'queued' | 'running' | 'PASS' | 'REVISE' | 'BLOCK';
79
+ startedAt?: string;
80
+ elapsedMs?: number;
81
+ findingCount?: number;
82
+ verdictDigest?: string;
83
+ }
84
+ /**
85
+ * §5.1 LOCK (lines 558-569). Per-gate aggregate over reviewer-quorum +
86
+ * auto-revise round count. `autoReviseCap: 2 | 6` literal-union prevents
87
+ * accidental drift in implementor code per CP-0 §6 line 155 (Pro = 2,
88
+ * Max = 6).
89
+ */
90
+ export interface GateState {
91
+ gateId: string;
92
+ taskId: string;
93
+ gateKind: 'code-review' | 'merge-gate' | 'continuation-handoff';
94
+ quorumRequired: number;
95
+ quorumAchieved: number;
96
+ autoReviseRound: number;
97
+ autoReviseCap: 2 | 6;
98
+ status: 'pending' | 'in_review' | 'PASS' | 'REVISE' | 'BLOCK' | 'merge_gate_pending';
99
+ finalizedAt?: string;
100
+ }
101
+ /**
102
+ * §5.1 LOCK lines 576-583. LE-originated Class A `EXECUTION_EVENT`
103
+ * messageType payloads. Five sub-kinds per CP-0 §2.4 verbatim.
104
+ */
105
+ export interface ExecutionEventEntry {
106
+ eventId: string;
107
+ timestamp: string;
108
+ kind: 'PROCESS_SPAWNED' | 'FILE_CHANGE' | 'TOOL_USE' | 'VERIFICATION_RUN' | 'PROCESS_EXITED';
109
+ parentTaskId: string;
110
+ authorRole: 'implementor' | 'reviewer' | 'shell';
111
+ payload: Record<string, unknown>;
112
+ }
113
+ /**
114
+ * §5.1 LOCK lines 591-613. Separate Class A `EXECUTOR_REFUSAL`
115
+ * messageType per CP-0 §2.3 + §2.4. NOT an EXECUTION_EVENT sub-kind.
116
+ */
117
+ export interface RefusalEventEntry {
118
+ eventId: string;
119
+ timestamp: string;
120
+ kind: 'EXECUTOR_REFUSAL';
121
+ parentTaskId: string;
122
+ authorRole: 'shell';
123
+ payload: {
124
+ refusedMessageId: string;
125
+ refusalCategory: 'authority_scope_conflict' | 'local_permission_denied' | 'signature_invalid' | 'ulid_replay' | 'auth_revoked_local' | 'transport_authority_mismatch';
126
+ refusalDetail: string;
127
+ recommendedRecovery: 'reauthorize_locally' | 'abort_task' | 'ask_user' | 'retry_after_resync';
128
+ };
129
+ }
130
+ /**
131
+ * §5.1 LOCK lines 621-628. CP-1 placeholder; payload shape is
132
+ * `[DEFERRED TECH DEBT — CP-2]` per design.
133
+ */
134
+ export interface BypassEventEntry {
135
+ eventId: string;
136
+ timestamp: string;
137
+ kind: 'TASK_BYPASS';
138
+ parentTaskId: string;
139
+ authorRole: 'shell';
140
+ payload: {
141
+ bypassReason: string;
142
+ };
143
+ }
144
+ /**
145
+ * §5.1 LOCK lines 635-642. Mobile-replay EventType values that flow
146
+ * into the store without going through the Class A wire. `parentTaskId`
147
+ * is nullable per Stage 2 r3 Gemini M1 — `NOTIFICATION` events may be
148
+ * session-scope.
149
+ */
150
+ export interface MobileEventEntry {
151
+ eventId: string;
152
+ timestamp: string;
153
+ kind: 'USER_PROMPT' | 'ASSISTANT_RESPONSE' | 'INTERACTIVE_PROMPT' | 'NOTIFICATION';
154
+ parentTaskId: string | null;
155
+ source: 'DESKTOP' | 'MOBILE';
156
+ payload: Record<string, unknown>;
157
+ }
158
+ /**
159
+ * §5.1 LOCK line 646. Discriminated union used inside
160
+ * `ConversationEntry.subagent-event`.
161
+ */
162
+ export type EventStreamEntry = ExecutionEventEntry | RefusalEventEntry | BypassEventEntry | MobileEventEntry;
163
+ /**
164
+ * §5.1 LOCK lines 527-534. Discriminated union; every entry carries
165
+ * `final: boolean`. Non-final entries re-render in place; final entries
166
+ * freeze in scrollback (migrate from `<ConversationPane>` into `<Static>`
167
+ * per design line 441-447).
168
+ */
169
+ export type ConversationEntry = {
170
+ kind: 'user-message';
171
+ id: string;
172
+ timestamp: string;
173
+ final: true;
174
+ text: string;
175
+ } | {
176
+ kind: 'planner-decision';
177
+ id: string;
178
+ timestamp: string;
179
+ final: true;
180
+ action: PlannerDecision['action'];
181
+ rationale: string;
182
+ taskId?: string;
183
+ } | {
184
+ kind: 'subagent-event';
185
+ id: string;
186
+ timestamp: string;
187
+ final: true;
188
+ parentTaskId: string;
189
+ role: 'implementor' | 'reviewer';
190
+ event: EventStreamEntry;
191
+ } | {
192
+ kind: 'reviewer-status-node';
193
+ id: string;
194
+ timestamp: string;
195
+ final: boolean;
196
+ taskId: string;
197
+ seats: ReviewerSeatState[];
198
+ quorumStatus: 'queued' | 'running' | 'PASS' | 'REVISE' | 'BLOCK';
199
+ } | {
200
+ kind: 'gate-status-node';
201
+ id: string;
202
+ timestamp: string;
203
+ final: boolean;
204
+ taskId: string;
205
+ gate: GateState;
206
+ } | {
207
+ kind: 'slash-output';
208
+ id: string;
209
+ timestamp: string;
210
+ final: true;
211
+ command: string;
212
+ output: string;
213
+ } | {
214
+ kind: 'advisory';
215
+ id: string;
216
+ timestamp: string;
217
+ final: true;
218
+ source: 'planner' | 'shell';
219
+ text: string;
220
+ } | {
221
+ kind: 'gate-prompt';
222
+ id: string;
223
+ timestamp: string;
224
+ final: false | true;
225
+ envelope: GatePromptEnvelope;
226
+ queue: ReadonlyArray<GatePromptEnvelope>;
227
+ uiState: {
228
+ phase: 'awaiting-number';
229
+ } | {
230
+ phase: 'awaiting-notes';
231
+ decisionDraft: string;
232
+ } | {
233
+ phase: 'submitting';
234
+ } | {
235
+ phase: 'resolved';
236
+ postAction: PostDecisionAction;
237
+ resolvedBy: 'self';
238
+ };
239
+ };
240
+ /**
241
+ * §5.1 LOCK lines 485-490. Stage 2 r3 Gemini M4. Captures a
242
+ * PlannerDecision the user wants to run but cannot start yet because
243
+ * the prior task is still running.
244
+ */
245
+ export interface QueuedTask {
246
+ queuedTaskId: string;
247
+ plannerDecision: PlannerDecision;
248
+ queuedAt: string;
249
+ blockedOnTaskId?: string;
250
+ }
251
+ /**
252
+ * §5.1 LOCK lines 496-500. Codex r2 M1. Captures the original prompt
253
+ * + every clarifying question the planner has asked so far + the user's
254
+ * answers. Next USER_INPUT under `pendingClarification !== null`
255
+ * resolves the most recent question and re-routes through
256
+ * `classifyPlannerPrompt` with the full `clarifications` array.
257
+ */
258
+ export interface PendingClarification {
259
+ originalPrompt: string;
260
+ rounds: Array<{
261
+ question: string;
262
+ answer?: string;
263
+ }>;
264
+ conversationEntryId: string;
265
+ }
266
+ /**
267
+ * §5.1 LOCK lines 463-480. Owned by the orchestration-shell store.
268
+ * Bounded ring buffer on `conversation` (last 500 entries — design line
269
+ * 469).
270
+ */
271
+ export interface OrchestrationState {
272
+ session: Session;
273
+ plannerHealth: PlannerHealthState;
274
+ conversation: ConversationEntry[];
275
+ runningTasks: Map<string, RunningTaskState>;
276
+ queuedTasks: QueuedTask[];
277
+ activeReviewerSeats: Map<string, ReviewerSeatState>;
278
+ currentGate: GateState | null;
279
+ pendingClarification: PendingClarification | null;
280
+ inputHistory: string[];
281
+ /**
282
+ * `[ADDITIVE WIDENING — CP-1.d]` per `PHASE-CP-1-D-DESIGN.md` §4.8
283
+ * lines 1011-1019. `null` until session-start generation completes (or
284
+ * the `/structural-summary --regenerate` side effect refreshes it).
285
+ * sha256 is stable per `assembler.ts` canonical-replacer.
286
+ */
287
+ structuralSummary: StructuralSummary | null;
288
+ /**
289
+ * `[ADDITIVE WIDENING — CP-1.d]` per `PHASE-CP-1-D-DESIGN.md` §4.8
290
+ * lines 1011-1019. Populated when `STRUCTURAL_SUMMARY_FAILED` fires
291
+ * (fail-closed per §4.7); cleared on next successful regeneration.
292
+ */
293
+ structuralSummaryError: string | null;
294
+ }
295
+ /**
296
+ * §5.1 LOCK lines 502-513. Discriminated union over every state
297
+ * transition the reducer covers. `attachedTaskId` / `ATTACH` / `DETACH`
298
+ * variants are NOT present per §5.1.5 — `/attach` is DEFERRED to CP-1.1.
299
+ *
300
+ * [ADDITIVE WIDENING — CP-1.a, per Stage 1 r1 MEDIUM-1] CP-1.a widens the
301
+ * locked §5.1 OrchestrationAction with 5 additive surfaces (all required
302
+ * by the reducer + render pipeline; none change the locked semantics):
303
+ *
304
+ * - `PLANNER_DECISION.taskId?: string` (optional) — populates
305
+ * `state.runningTasks.taskId` when the decision spawns one. CP-1.b
306
+ * will widen further when the planner client wires the real taskId.
307
+ * - `REVIEWER_STATE_CHANGED.nodeId: string` — disambiguates which
308
+ * `kind:'reviewer-status-node'` ConversationEntry to update in place
309
+ * (multiple reviewer-quorum nodes can be live concurrently).
310
+ * - `GATE_STATE_CHANGED.nodeId: string` — same disambiguation for
311
+ * `kind:'gate-status-node'`.
312
+ * - `TASK_LIFECYCLE` (new variant) — populates `state.runningTasks`
313
+ * on spawn / cancel / completion. The design's §5.1 line 470 calls
314
+ * for `runningTasks: Map<string, RunningTaskState>` but did not name
315
+ * the action that writes to it; this is the gap-filling variant.
316
+ * - `CLEAR_PENDING_CLARIFICATION` (new variant) — invoked by `cli.ts`
317
+ * when the planner returns a non-`ask_user` decision and we need to
318
+ * clear stale clarifications. Design §5.1 says the next USER_INPUT
319
+ * resolves the question, but a non-ask_user decision returning
320
+ * out-of-band needs an explicit reset.
321
+ *
322
+ * CP-1.b/c may further widen the union. Stage A LOCK invariant: every
323
+ * NEW variant or required field is tagged here before the reducer
324
+ * consumes it.
325
+ */
326
+ export type OrchestrationAction = {
327
+ type: 'USER_INPUT';
328
+ text: string;
329
+ } | {
330
+ type: 'PLANNER_DECISION';
331
+ decision: PlannerDecision;
332
+ taskId?: string;
333
+ } | {
334
+ type: 'EVENT_RECEIVED';
335
+ event: EventStreamEntry;
336
+ role?: 'implementor' | 'reviewer';
337
+ } | {
338
+ type: 'REVIEWER_STATE_CHANGED';
339
+ nodeId: string;
340
+ seatId: string;
341
+ newState: ReviewerSeatState;
342
+ } | {
343
+ type: 'GATE_STATE_CHANGED';
344
+ nodeId: string;
345
+ gate: GateState;
346
+ } | {
347
+ type: 'PLANNER_HEALTH_CHANGED';
348
+ newState: PlannerHealthState;
349
+ } | {
350
+ type: 'SLASH_OUTPUT';
351
+ command: string;
352
+ output: string;
353
+ } | {
354
+ type: 'CLARIFICATION_ANSWERED';
355
+ answer: string;
356
+ } | {
357
+ type: 'TASK_QUEUED';
358
+ queuedTask: QueuedTask;
359
+ } | {
360
+ type: 'TASK_DEQUEUED';
361
+ queuedTaskId: string;
362
+ } | {
363
+ type: 'TASK_LIFECYCLE';
364
+ task: RunningTaskState;
365
+ } | {
366
+ type: 'CLEAR_PENDING_CLARIFICATION';
367
+ } | {
368
+ type: 'STRUCTURAL_SUMMARY_GENERATED';
369
+ summary: StructuralSummary;
370
+ elapsedMs: number;
371
+ } | {
372
+ type: 'STRUCTURAL_SUMMARY_FAILED';
373
+ error: string;
374
+ } | {
375
+ type: 'GATE_PROMPT_RECEIVED';
376
+ envelope: GatePromptEnvelope;
377
+ } | {
378
+ type: 'GATE_PROMPT_NOTES_REQUESTED';
379
+ promptEntryId: string;
380
+ decisionDraft: string;
381
+ } | {
382
+ type: 'GATE_PROMPT_SUBMIT_STARTED';
383
+ promptEntryId: string;
384
+ } | {
385
+ type: 'GATE_PROMPT_RESOLVED';
386
+ promptEntryId: string;
387
+ postAction: PostDecisionAction;
388
+ } | {
389
+ type: 'GATE_PROMPT_SUBMIT_FAILED';
390
+ promptEntryId: string;
391
+ error: string;
392
+ } | {
393
+ type: 'SHELL_ADVISORY';
394
+ text: string;
395
+ source: 'shell';
396
+ } | {
397
+ type: 'GATE_PROMPT_NOTES_CANCELLED';
398
+ promptEntryId: string;
399
+ } | {
400
+ type: 'EXIT';
401
+ };
402
+ /**
403
+ * §2 LOCK lines 108-113. `~/.codevibe/last-mode.json` shape.
404
+ */
405
+ export interface LastModeFile {
406
+ schemaVersion: 1;
407
+ mode: Mode;
408
+ pickedAt: string;
409
+ pickedByTier: 'PRO' | 'MAX';
410
+ }
411
+ /**
412
+ * Tier surface used by §2 mode-selection. Matches the runtime tiers
413
+ * carried by `getSubscriptionStatus` (FREE / PRO / MAX). CP-1.a only
414
+ * needs the literal union — the AppSync-side enum lives in
415
+ * `src/types/auth.ts` already.
416
+ */
417
+ export type Tier = 'FREE' | 'PRO' | 'MAX';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ export type { PlannerInput, PlannerDecision, PlannerProbeResult, SessionContext, BudgetHint, Clarification, CachedClassification, ClassificationKind, Tier, PlannerHealthState, PlannerHealthTransition, } from './types';
2
+ import type { PlannerInput, PlannerDecision, PlannerProbeResult } from './types';
3
+ export interface PlannerAdapter {
4
+ classify(input: PlannerInput): Promise<PlannerDecision>;
5
+ probe(): Promise<PlannerProbeResult>;
6
+ /**
7
+ * CP-1.b IMPL r2 H-3 — Bind the active session for subsequent
8
+ * `probe()` calls. Stage 2 r1 added this to `BackendPlannerClient`
9
+ * but missed declaring it on the interface, so callers — notably
10
+ * `runOrchestrationShell` — never invoked it and `probe()` threw
11
+ * "no active session" unconditionally in production.
12
+ *
13
+ * Pass `null` on session teardown to clear the binding.
14
+ */
15
+ setActiveSession(sessionId: string | null): void;
16
+ }
@@ -0,0 +1,35 @@
1
+ import type { CachedClassification } from './types';
2
+ export declare class PlannerCacheLayer {
3
+ private workflowCache;
4
+ private signatureCache;
5
+ private hydrated;
6
+ private mutex;
7
+ private cacheRoot;
8
+ constructor(cacheRoot?: string);
9
+ getWorkflowClassification(userId: string, prompt: string): Promise<CachedClassification | null>;
10
+ setWorkflowClassification(userId: string, prompt: string, c: CachedClassification): Promise<void>;
11
+ /**
12
+ * CP-1.b Stage 2 r2 M-2 — Explicit lazy-persist flush for callers
13
+ * that need to durably commit pending in-memory inserts (e.g.
14
+ * orchestration-shell on session end). LOCK #18 permits this
15
+ * trigger.
16
+ */
17
+ flush(): Promise<void>;
18
+ getSignatureClassification(userId: string, sigHash: string): CachedClassification | null;
19
+ setSignatureClassification(userId: string, sigHash: string, c: CachedClassification): void;
20
+ flushForTier(userId: string): Promise<void>;
21
+ flushAll(): Promise<void>;
22
+ purgeOnUserSwitch(newUserId: string): Promise<void>;
23
+ private hydrateWorkflowIfNeeded;
24
+ private rotateCorrupt;
25
+ private persistWorkflow;
26
+ private cacheDir;
27
+ private userIdPrefix;
28
+ private workflowFilePath;
29
+ private canonicalize;
30
+ private assertNoActionJson;
31
+ private evictLru;
32
+ private ensureCacheRoot;
33
+ private ensureDir;
34
+ private rmRecursiveSafe;
35
+ }