@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
@@ -1,4 +1,5 @@
1
- import { CreateEventInput, CreateSessionInput, UpdateSessionInput, UpdateEventStatusInput, Event, Session, EventSource, DeviceKey, GrantSessionKeyInput } from '../types';
1
+ import { CreateEventInput, CreateSessionInput, UpdateSessionInput, UpdateEventStatusInput, Event, Session, EventSource, DeviceKey, GrantSessionKeyInput, UpdateReviewerPolicyInput, UserReviewerPolicySnapshot } from '../types';
2
+ import type { PostDecisionAction } from '../orchestration-shell/types';
2
3
  /**
3
4
  * Download URL response
4
5
  */
@@ -6,6 +7,47 @@ export interface DownloadUrlResponse {
6
7
  downloadUrl: string;
7
8
  expiresAt: string;
8
9
  }
10
+ /**
11
+ * CP-1.b IMPL r2 M-4 — Typed GraphQL error that preserves AppSync's
12
+ * `errorType` and `extensions` fields, alongside the human-readable
13
+ * `message`. Stage 2 r1's `graphqlRequest()` threw a plain
14
+ * `Error("GraphQL error: <message>")` and silently dropped
15
+ * `errorType`, which broke `BackendPlannerClient.classifyTransportError`
16
+ * (it discriminates on `err.errorType` to separate
17
+ * `BudgetExceeded` / `TierGateRejected` from provider-health failures).
18
+ *
19
+ * Callers may catch this class to inspect `errorType` directly. Code
20
+ * paths that still parse error.message will continue to work because
21
+ * the message is unchanged ("GraphQL error: <message>").
22
+ */
23
+ export declare class AppSyncGraphQLError extends Error {
24
+ readonly errorType?: string;
25
+ readonly extensions?: unknown;
26
+ readonly path?: unknown;
27
+ constructor(opts: {
28
+ message: string;
29
+ errorType?: string;
30
+ extensions?: unknown;
31
+ path?: unknown;
32
+ });
33
+ }
34
+ /**
35
+ * Discriminator for the most recent `authenticateWithStoredTokens()`
36
+ * failure. Lets callers distinguish a genuine "no tokens / refresh
37
+ * rejected" outcome from a transient network failure during the
38
+ * Cognito refresh-token POST.
39
+ *
40
+ * Stage 2 round-1 Codex M1: the production refresh path returns
41
+ * `false` on every error (including network blow-ups inside
42
+ * `callCognitoRefresh`'s catch block), so the wizard's auth-vs-network
43
+ * heuristic — which only ran on caught throws — never fired in
44
+ * production. Recording the kind on every false-return path lets
45
+ * `setup-bootstrap.ts:defaultClientFactory()` route network-shaped
46
+ * refresh failures to `subscription_status_network` (per §6 row
47
+ * "transient 5xx during refresh") instead of misleading the user with
48
+ * a "not signed in" abort.
49
+ */
50
+ export type AuthFailureKind = 'no_tokens' | 'refresh_auth_rejected' | 'refresh_network';
9
51
  /**
10
52
  * AppSync GraphQL client with WebSocket subscriptions
11
53
  */
@@ -15,6 +57,24 @@ export declare class AppSyncClient {
15
57
  private currentEmail;
16
58
  private tokens;
17
59
  private activeSubscriptions;
60
+ /**
61
+ * Set by `authenticateWithStoredTokens()` on every false-return path
62
+ * (and reset to `null` on success). Read by callers (e.g., the
63
+ * wizard's `defaultClientFactory`) to discriminate auth-rejection
64
+ * vs network-failure without re-running the auth call. Stage 2
65
+ * round-1 Codex M1.
66
+ */
67
+ private lastAuthFailureKind;
68
+ /**
69
+ * Sentinel set inside `performRefresh` / `callCognitoRefresh` when
70
+ * the refresh round-trip fails with a network-shaped error (DNS,
71
+ * socket reset, fetch failed, 5xx). Reset to `false` at the start
72
+ * of each `performRefresh`. Read by `authenticateWithStoredTokens`
73
+ * to classify a `refreshTokens()=false` return as
74
+ * `refresh_network` vs `refresh_auth_rejected`. Internal — never
75
+ * exposed.
76
+ */
77
+ private lastRefreshNetworkError;
18
78
  private pendingRefresh;
19
79
  private lastRefreshFailureAt;
20
80
  private static readonly REFRESH_BACKOFF_MS;
@@ -30,6 +90,30 @@ export declare class AppSyncClient {
30
90
  * Get the current authenticated user email
31
91
  */
32
92
  getCurrentUserEmail(): string | null;
93
+ /**
94
+ * Returns the kind of the most recent
95
+ * `authenticateWithStoredTokens()` failure, or `null` if the call
96
+ * succeeded (or has never been called).
97
+ *
98
+ * Stage 2 round-1 Codex M1. Callers (today: `setup-bootstrap.ts
99
+ * :defaultClientFactory`) use this to distinguish network blow-ups
100
+ * during the Cognito refresh-token POST from genuine auth
101
+ * rejections. The wizard maps `'refresh_network'` to
102
+ * `subscription_status_network` (don't tell a signed-in user to
103
+ * re-login when their tokens are valid and the network is broken)
104
+ * and the other two kinds to `not_signed_in` (preserves
105
+ * pre-Codex-M1 behavior).
106
+ */
107
+ getLastAuthFailureKind(): AuthFailureKind | null;
108
+ /**
109
+ * Heuristic — does the error message look like a transient network
110
+ * failure rather than an auth-token rejection? Mirrors
111
+ * `setup-bootstrap.ts:isNetworkLikeError` byte-for-byte so the same
112
+ * classifier runs both inside the client (for refresh-path
113
+ * discrimination) and at the bootstrap boundary (for caught-throw
114
+ * routing). Stage 2 round-1 Codex M1.
115
+ */
116
+ private static isNetworkLikeMessage;
33
117
  /**
34
118
  * Authenticate using stored OAuth tokens from keychain
35
119
  */
@@ -158,6 +242,26 @@ export declare class AppSyncClient {
158
242
  * List user device keys
159
243
  */
160
244
  listUserDeviceKeys(): Promise<DeviceKey[]>;
245
+ /**
246
+ * CP-1.b IMPL r4 H-2 — list BACKEND_SERVICE device keys per design
247
+ * §4.9 schema delta bullet 5 + §6.1 service-device flow.
248
+ *
249
+ * Returns every device row with `kind = BACKEND_SERVICE` regardless of
250
+ * the caller's `userId` (the only such row in CP-1.b is the
251
+ * planner-proxy's ECDH P-256 keypair under `deviceId =
252
+ * planner-proxy-{env}`). Callers union this list with
253
+ * `listUserDeviceKeys()` when minting `encryptedKeys[]` for new
254
+ * sessions so the planner-proxy Lambda can decrypt session-bound
255
+ * payloads via ECDH+HKDF against its own private key.
256
+ *
257
+ * The backend resolver is auth-mode widened (`@aws_cognito_user_pools
258
+ * @aws_iam`) — Cognito callers query for the planner-proxy public key
259
+ * at session-creation time; IAM callers (planner-proxy bootstrap) may
260
+ * also call. The CDK-backed GSI `kind-deviceId-index` partitions the
261
+ * device-keys table by `kind`, so this is a single GSI query, not a
262
+ * full scan.
263
+ */
264
+ listServiceDeviceKeys(): Promise<DeviceKey[]>;
161
265
  /**
162
266
  * Register device key
163
267
  */
@@ -178,6 +282,142 @@ export declare class AppSyncClient {
178
282
  * Get attachment download URL
179
283
  */
180
284
  getAttachmentDownloadUrl(s3Key: string): Promise<DownloadUrlResponse>;
285
+ /**
286
+ * Plugin startup pushes the user's locally-detected agents
287
+ * (`CLAUDE` / `GEMINI` / `CODEX`). Idempotent — safe to call every
288
+ * launch. Backend stores in `User.availableAgents`; used later to
289
+ * derive tier-default reviewer seat assignments.
290
+ */
291
+ updateAvailableAgents(agents: Array<'CLAUDE' | 'GEMINI' | 'CODEX'>): Promise<UserReviewerPolicySnapshot>;
292
+ /**
293
+ * CP-5.c — push the per-agent capability snapshot. Dual-write
294
+ * alongside `updateAvailableAgents` per LOCK #C5-C-4 (the legacy
295
+ * field stays for V1 client backward compat; this surface carries
296
+ * the full 9-field record per AgentKind).
297
+ *
298
+ * `capabilities` is serialized to JSON before transit (AppSync
299
+ * accepts `AWSJSON` as a stringified payload). Backend Lambda
300
+ * persists to `Users.adapterCapabilities` and returns the updated
301
+ * User row.
302
+ */
303
+ updateAdapterCapabilities(capabilities: unknown[]): Promise<UserReviewerPolicySnapshot>;
304
+ /**
305
+ * Persist the user's orchestration opt-in default and/or custom
306
+ * reviewer panel. Backend validates seat-count against tier, seat_id
307
+ * uniqueness + range, and role uniqueness. Throws on validation
308
+ * failure — error message is user-facing (surfaced to the
309
+ * configure-reviewers wizard).
310
+ */
311
+ updateReviewerPolicy(input: UpdateReviewerPolicyInput): Promise<UserReviewerPolicySnapshot>;
312
+ /**
313
+ * Fetch the user's subscription tier + status. Used by the Phase 3.a
314
+ * setup wizard (#190) at bootstrap to gate Free → upgrade interstitial
315
+ * and to size the seat budget (Pro=2, Max=3).
316
+ *
317
+ * Backend resolver returns a default FREE row when the user has no
318
+ * Users-table entry yet (Lambda resolver — lambda/subscription/index.ts).
319
+ * Network failure / auth expiry surface as graphqlRequest exceptions.
320
+ */
321
+ getSubscriptionStatus(): Promise<{
322
+ tier: 'FREE' | 'PRO' | 'MAX';
323
+ status: 'ACTIVE' | 'EXPIRED' | 'GRACE_PERIOD' | 'BILLING_RETRY';
324
+ expiresAt: string | null;
325
+ }>;
326
+ /**
327
+ * CP-1.b IMPL r4 H-1 — `classifyPlannerPrompt` AppSync mutation.
328
+ *
329
+ * Implements `PlannerAppSyncTransport.classifyPlannerPrompt` from
330
+ * `codevibe-core/src/planner/client.ts`. Encrypted-input wire shape
331
+ * is locked at design §4.10 + §4.11: `prompt` is raw base64 AES-GCM
332
+ * ciphertext under the session key; `clarifications`, `sessionContext`,
333
+ * `budgetHint` are AWSJSON envelope strings of the form
334
+ * `'{"encrypted":"<base64 ciphertext>"}'`. Response `decision` is RAW
335
+ * base64 ciphertext (NOT envelope-wrapped) per LOCK #27.
336
+ *
337
+ * Typed errors (`BudgetExceeded`, `TierGateRejected`, etc.) surface
338
+ * via `AppSyncGraphQLError.errorType` so the planner client can
339
+ * discriminate policy events from provider-health failures per
340
+ * Stage 2 r2 M-3.
341
+ */
342
+ classifyPlannerPrompt(input: {
343
+ sessionId: string;
344
+ prompt: string;
345
+ clarifications: string;
346
+ sessionContext: string;
347
+ budgetHint: string;
348
+ }): Promise<{
349
+ decision: string;
350
+ cacheHit: boolean;
351
+ cacheKind: string | null;
352
+ serverLatencyMs: number;
353
+ providerUsed: string;
354
+ }>;
355
+ /**
356
+ * CP-1.b IMPL r4 H-1 — `pingPlanner` AppSync mutation.
357
+ *
358
+ * Implements `PlannerAppSyncTransport.pingPlanner`. Separate mutation
359
+ * from `classifyPlannerPrompt` per Stage A LOCK #31. Input carries
360
+ * only `sessionId` (no encryption, no clarifications, no budgetHint).
361
+ * Response shape `{ ok, ms }` ONLY (no `providerHealthState` —
362
+ * shell-side `PlannerHealthMachine` is the sole authority).
363
+ */
364
+ pingPlanner(input: {
365
+ sessionId: string;
366
+ }): Promise<{
367
+ ok: boolean;
368
+ ms: number;
369
+ }>;
370
+ /**
371
+ * CP-8 min Stage 1 R1 HIGH-1 closure (Hendry-approved 2026-05-19).
372
+ *
373
+ * Submits an orchestration gate-prompt decision (Path A FinalApproval
374
+ * or Path B Halted-resolution) to the engine and returns the typed
375
+ * `PostDecisionAction` reply.
376
+ *
377
+ * **Implementation deviation from `PHASE-CP-8-MIN-DESIGN.md` #C8M-6
378
+ * literal wording:** the design says "use `@quantiya/quorum-core`'s
379
+ * `applyUserDecision` SDK method." codevibe-core deliberately does
380
+ * NOT depend on `@quantiya/quorum-core` at runtime — see the
381
+ * structural-typing pattern at `src/orchestration/v1-options.ts:44-47`.
382
+ * The locked INVARIANT of #C8M-6 ("single typed transport surface,
383
+ * no direct GraphQL in the orchestration-shell tree") is honored by
384
+ * exposing this method here on codevibe-core's own AppSyncClient,
385
+ * which is THE desktop-side transport surface. Shape mirrors the
386
+ * quorum-core SDK at `client.ts:464-504` byte-for-byte:
387
+ * - Wraps `notes` (when present) in `EncryptedPayloadInput`
388
+ * (AES-256-GCM under the session key, base64 ciphertext +
389
+ * `sessionId` + `keyVersion`).
390
+ * - Uppercases `decision` to UPPER_SNAKE wire enum (matches the
391
+ * SDK's `toWireEnum` pattern).
392
+ * - Parses the `payload` AWSJSON string to the 4-variant
393
+ * `PostDecisionAction` discriminated union.
394
+ *
395
+ * See `PHASE-CP-8-MIN-DESIGN.md` §4 #C8M-6 deviation footer for the
396
+ * sealed rationale.
397
+ *
398
+ * @param input Caller passes the lowercase TS `decision` kind (one of
399
+ * the 7 `UserDecisionKind` values). Encoding to wire
400
+ * UPPER_SNAKE happens here.
401
+ * @param sessionKeyBase64 Optional. REQUIRED only when `input.notes`
402
+ * is provided — used to AES-GCM-encrypt the notes plaintext
403
+ * under the session key. When `notes` is undefined, this
404
+ * parameter is ignored.
405
+ * @returns Parsed `{ decision, postAction }` per the engine's reply.
406
+ * `decision` is echoed in lowercase TS form for caller
407
+ * ergonomics (e.g. dispatcher routing without re-mapping the
408
+ * UPPER_SNAKE wire value).
409
+ */
410
+ applyUserDecision(input: {
411
+ gateId: string;
412
+ taskId: string;
413
+ sessionId: string;
414
+ currentRound: number;
415
+ decision: string;
416
+ notes?: string;
417
+ }, sessionKeyBase64?: string): Promise<{
418
+ decision: string;
419
+ postAction: PostDecisionAction;
420
+ }>;
181
421
  /**
182
422
  * Subscribe to events for a session
183
423
  */
@@ -306,4 +546,41 @@ export declare class AppSyncClient {
306
546
  * Cleanup all subscriptions and heartbeats
307
547
  */
308
548
  cleanupSubscriptions(): void;
549
+ /**
550
+ * Parse a raw `ClassBPacket.packetJson` AWSJSON string into the typed
551
+ * discriminated-union packet. Throws `Error` on malformed input — the caller
552
+ * (subscription handler in CP-2) bridges this to `onError` per §7.2.
553
+ *
554
+ * Exposed for unit testing per design §7.4 row 1
555
+ * (`appsync_client_subscribeToClassBPackets_parses_packetJson_into_typed_packet`).
556
+ */
557
+ parseClassBPacketPayload(packetJson: string): unknown;
558
+ /**
559
+ * Subscribe to AppSync `onClassBPacket(userId)` and dispatch typed packets
560
+ * to `onPacket`. Errors during parsing OR transport are forwarded to
561
+ * `onError`. Returns an unsubscribe handle.
562
+ *
563
+ * CP-1.e ships the handler surface + parser; full WebSocket wiring on the
564
+ * `subscribeToEvents`-style two-phase reconnect engine completes in CP-2
565
+ * Stage A when the hosted producer side comes online. Until then the method
566
+ * registers the handler and returns a working unsubscribe — callers (the
567
+ * orchestration shell) can wire it during CP-1.e bootstrap with no
568
+ * behavioral change once CP-2 lights up the wire.
569
+ */
570
+ subscribeToClassBPackets(userId: string, handlers: {
571
+ onPacket: (packet: unknown) => void | Promise<void>;
572
+ onError?: (err: Error) => void;
573
+ }): {
574
+ unsubscribe: () => Promise<void>;
575
+ };
576
+ /**
577
+ * Test seam — deliver a raw envelope payload to the registered handler.
578
+ * Used by §7.4 unit tests to assert parse + forward semantics without
579
+ * standing up a real WebSocket. Production code path (CP-2) will call the
580
+ * same internal flow.
581
+ *
582
+ * @internal
583
+ */
584
+ _deliverClassBPacketForTests(userId: string, rawPacketJson: string): Promise<void>;
585
+ private readonly classBPacketHandlers;
309
586
  }
@@ -1,2 +1,2 @@
1
- export { AppSyncClient, DownloadUrlResponse } from './appsync-client';
1
+ export { AppSyncClient, AppSyncGraphQLError, DownloadUrlResponse } from './appsync-client';
2
2
  export { queries, mutations, subscriptions } from './queries';
@@ -2,6 +2,7 @@ export declare const queries: {
2
2
  getSession: string;
3
3
  listEvents: string;
4
4
  listUserDeviceKeys: string;
5
+ listServiceDeviceKeys: string;
5
6
  /**
6
7
  * Minimal session listing used by the orphan-sweep path. Only the
7
8
  * fields needed to decide whether a session row is stale — sessionId
@@ -10,6 +11,7 @@ export declare const queries: {
10
11
  * check.
11
12
  */
12
13
  listSessions: string;
14
+ getSubscriptionStatus: string;
13
15
  };
14
16
  export declare const mutations: {
15
17
  createSession: string;
@@ -19,6 +21,12 @@ export declare const mutations: {
19
21
  registerDeviceKey: string;
20
22
  grantSessionKey: string;
21
23
  getAttachmentDownloadUrl: string;
24
+ updateAvailableAgents: string;
25
+ updateAdapterCapabilities: string;
26
+ updateReviewerPolicy: string;
27
+ classifyPlannerPrompt: string;
28
+ pingPlanner: string;
29
+ applyUserDecision: string;
22
30
  };
23
31
  export declare const subscriptions: {
24
32
  onEventCreated: string;
@@ -0,0 +1,41 @@
1
+ export type Uuid = string;
2
+ /**
3
+ * `TaskCreated` — one per task lifecycle. Identity: `(task_id, kind)`.
4
+ */
5
+ export declare function dedupKeyForTaskCreated(taskId: Uuid): string;
6
+ /**
7
+ * `TaskTerminated` — one per task lifecycle. Identity: `(task_id, kind)`.
8
+ */
9
+ export declare function dedupKeyForTaskTerminated(taskId: Uuid): string;
10
+ /**
11
+ * `ProgressEvent` — keyed on `(task_id, kind, caller_event_id)`.
12
+ *
13
+ * `callerEventId` is REQUIRED (no `Option<&str>` fallback per the
14
+ * 2f.2 §5.2 lock). Callers without a stable id must invent one
15
+ * (e.g., a UUID at emit time); silently deriving from payload
16
+ * bytes would re-introduce the dedup-drift bug the lock prevents.
17
+ */
18
+ export declare function dedupKeyForProgressEvent(taskId: Uuid, callerEventId: string): string;
19
+ /**
20
+ * `ToolUse` — keyed on `(task_id, kind, caller_event_id)`. Same
21
+ * REQUIRED-not-optional rule as `dedupKeyForProgressEvent`.
22
+ */
23
+ export declare function dedupKeyForToolUse(taskId: Uuid, callerEventId: string): string;
24
+ /**
25
+ * `DestructiveActionEscalated` — keyed on `(gate_id, kind, action_id)`.
26
+ *
27
+ * Multiple destructive actions can be escalated within one gate
28
+ * (e.g., a turn that proposes both `rm -rf` and `git push --force`).
29
+ * `actionId` is the engine's internal id for the specific
30
+ * destructive call (NOT the gate, NOT the round).
31
+ */
32
+ export declare function dedupKeyForDestructiveActionEscalated(gateId: Uuid, actionId: string): string;
33
+ /**
34
+ * `FlagBadApproval` — keyed on `(flagged_entry_id, kind)`.
35
+ *
36
+ * A user flagging the same prior approval twice should dedupe to
37
+ * one flag. The Rust formula identifies the flag by the audit
38
+ * entry being flagged (not by a synthesized "bad-approval id"
39
+ * passed alongside).
40
+ */
41
+ export declare function dedupKeyForFlagBadApproval(flaggedEntryId: Uuid): string;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,11 +1,15 @@
1
1
  /**
2
2
  * Typed taxonomy of auth-flow failure reasons.
3
3
  *
4
- * Every value is a sanitized enum literal — never a raw error message,
5
- * never a truncated user input, never any byte from Cognito's response.
6
- * Adding a new failure mode means extending this union; the compiler
7
- * then forces every emit site to either use a known value or produce
8
- * a type error.
4
+ * Every value in THIS union is a sanitized enum literal — never a raw
5
+ * error message, never a truncated user input, never any byte from
6
+ * Cognito's response. Adding a new failure mode means extending this
7
+ * union; the compiler then forces every emit site to either use a known
8
+ * value or produce a type error.
9
+ *
10
+ * (Note: the `error_fragment` parameter on the auth_failed beacon DOES
11
+ * carry redacted error material — see `sanitizeAuthErrorFragment`. The
12
+ * `reason` taxonomy below remains the analytics-safe primary key.)
9
13
  *
10
14
  * Keep values snake_case to match GA4 custom-dimension conventions
11
15
  * used elsewhere in the codebase (`step`, `source`, `reason`).
@@ -29,6 +33,20 @@ export type AuthStage = 'server_start' | 'browser_open' | 'awaiting_callback' |
29
33
  * address.
30
34
  */
31
35
  export declare function fireAuthCompletedBeacon(userId: string): Promise<void>;
36
+ /**
37
+ * Bytes 0-99 of the sanitized fragment (GA4 dim: error_fragment).
38
+ * See `sanitizeAuthErrorFragmentFull` for the redaction contract.
39
+ */
40
+ export declare function sanitizeAuthErrorFragment(msg: string): string;
41
+ /**
42
+ * Bytes 100-199 of the sanitized fragment (GA4 dim: error_fragment_2).
43
+ * Returns empty string when the redacted message is ≤100 chars (the
44
+ * typical short-error case), which is what we want — no
45
+ * `error_fragment_2` param fires unless there's something past byte
46
+ * 100 worth carrying. Works around GA4 Measurement Protocol's 100-char
47
+ * per-param limit.
48
+ */
49
+ export declare function sanitizeAuthErrorFragmentTail(msg: string): string;
32
50
  /**
33
51
  * Fire the `auth_failed` failure beacon with a sanitized `reason`
34
52
  * literal. Optional `httpStatus` captures the numeric HTTP status
@@ -45,9 +63,12 @@ export declare function fireAuthCompletedBeacon(userId: string): Promise<void>;
45
63
  * `reason: 'unknown'`. The outer `auth-cli` catch passes the first
46
64
  * portion of `error.message` here so the next analytics pass can
47
65
  * see what's hiding in `unknown` and we can ship a typed reason in
48
- * a follow-up. Sanitized inside: ANSI escape sequences stripped,
49
- * newlines/tabs/quotes/backslashes replaced with spaces, non-ASCII
50
- * dropped, then split into two GA4 dimensions to work around the
66
+ * a follow-up. Sanitized inside via `sanitizeAuthErrorFragment` (head)
67
+ * + `sanitizeAuthErrorFragmentTail` (tail) — ANSI stripped, $HOME /
68
+ * USERPROFILE / `/Users/<name>/` / `/home/<name>/` / email substrings
69
+ * redacted (Windows backslashes normalized first so `C:\Users\Alice\…`
70
+ * matches the same path regex as POSIX form), control + non-ASCII
71
+ * bytes dropped, then split into two GA4 dimensions to work around the
51
72
  * Measurement Protocol 100-char per-param limit:
52
73
  * - `error_fragment` = bytes 0-99
53
74
  * - `error_fragment_2` = bytes 100-199 (only set when input >100 chars)
@@ -0,0 +1,9 @@
1
+ import { DetectedAgent } from './resolve-agent';
2
+ export interface PickAgentArgs {
3
+ healthy: DetectedAgent[];
4
+ defaultIndex: number;
5
+ /** Test seam — override stdin/stdout. */
6
+ input?: NodeJS.ReadableStream;
7
+ output?: NodeJS.WritableStream;
8
+ }
9
+ export declare function pickAgent(args: PickAgentArgs): Promise<DetectedAgent>;
@@ -0,0 +1,55 @@
1
+ import { DetectableAgent } from '../orchestration/detect-agents';
2
+ import type { ShellEventEmit } from '../orchestration-shell/emit-shell-event';
3
+ import type { Session } from '../types';
4
+ export declare class NoAgentInstalledError extends Error {
5
+ constructor(message: string);
6
+ }
7
+ export interface CompanionArgs {
8
+ /** Optional `--agent <kind>` CLI override. */
9
+ agent?: DetectableAgent;
10
+ /** Args to pass through to the agent wrapper. */
11
+ passthrough: string[];
12
+ /** When set, clears the persisted preference before resolving. */
13
+ forgetAgent?: boolean;
14
+ /**
15
+ * Session context for §3 emitShellEvent fan-out. When provided
16
+ * together with `emitter`, MODE_SELECTED is emitted before the exec
17
+ * handoff. When either is omitted, the emit is skipped — Companion
18
+ * Mode is functional without it because the cohort flag gates every
19
+ * emit anyway (CP-1.a default OFF). Per Stage 1 r1 HIGH-3.
20
+ */
21
+ session?: Session;
22
+ /**
23
+ * Bound emitter (typically `createShellEventEmitter(appsyncClient)`).
24
+ * Required for the MODE_SELECTED emit when `session` is also set.
25
+ */
26
+ emitter?: (args: ShellEventEmit) => Promise<void>;
27
+ /** Test seam — override the `execFileSync` handoff. */
28
+ execFile?: (binPath: string, args: string[], options: {
29
+ stdio: 'inherit';
30
+ }) => void;
31
+ /** Test seam — override `detectInstalledAgents`. */
32
+ detect?: () => DetectableAgent[];
33
+ /** Test seam — override bin-path resolver (real impl uses `command -v`). */
34
+ resolveBinPath?: (kind: DetectableAgent) => string | null;
35
+ /**
36
+ * Test seam — override the `<wrapper> --version` 2s health-probe
37
+ * (§4 line 280). Real impl spawns the wrapper with a SIGKILL on
38
+ * timeout. Per Stage 2 r1 Codex MEDIUM-2.
39
+ */
40
+ versionProbe?: (binPath: string) => Promise<boolean>;
41
+ }
42
+ /**
43
+ * §4 LOCK lines 232-273. Detect → resolve → persist → exec.
44
+ *
45
+ * On a TTY with multiple agents, this calls `pickAgent` for the
46
+ * interactive readline picker. The function does NOT mount the Ink
47
+ * TUI — Companion Mode does not need it (the picker hands terminal
48
+ * control directly to the wrapper).
49
+ *
50
+ * NOTE: the function returns when the test seam `execFile` is
51
+ * provided; in production the `execFileSync` call replaces the process
52
+ * (`stdio: 'inherit'`) so `process.exit(0)` is unreachable but kept
53
+ * as a defensive fallback (§4 line 273).
54
+ */
55
+ export declare function runCompanionMode(args: CompanionArgs): Promise<void>;
@@ -0,0 +1,24 @@
1
+ export declare function companionPreferenceFilePath(): string;
2
+ export interface CompanionPreference {
3
+ lastAgent: 'CLAUDE' | 'GEMINI' | 'CODEX';
4
+ lastUsedAt: string;
5
+ }
6
+ /**
7
+ * §4 lines 304-316 LOCK. Reads + validates the preference file.
8
+ * Returns `null` on every failure mode named in the design:
9
+ * - file missing
10
+ * - loose permissions (any group/world bits set)
11
+ * - malformed JSON
12
+ * - schema mismatch
13
+ */
14
+ export declare function readCompanionPreference(): Promise<CompanionPreference | null>;
15
+ /**
16
+ * Writes the preference file with mode 0600. Creates parent dir if
17
+ * missing. Self-heals loose perms (writes 0o600 explicitly on every
18
+ * write).
19
+ */
20
+ export declare function persistCompanionPreference(pref: CompanionPreference): Promise<void>;
21
+ /**
22
+ * Clears the preference file (used by `--forget-agent` flag per §4).
23
+ */
24
+ export declare function clearCompanionPreference(): Promise<void>;
@@ -0,0 +1,41 @@
1
+ import { DetectableAgent } from '../orchestration/detect-agents';
2
+ export interface DetectedAgent {
3
+ kind: DetectableAgent;
4
+ binPath: string;
5
+ healthy: boolean;
6
+ }
7
+ export interface ResolveAgentArgs {
8
+ /** Healthy agents detected on PATH. */
9
+ healthy: DetectedAgent[];
10
+ /** `--agent` CLI flag override (if any). */
11
+ flag?: DetectableAgent;
12
+ /** Persisted preference from `readCompanionPreference()` (if any). */
13
+ preferred?: DetectableAgent;
14
+ }
15
+ export interface ResolveAgentResult {
16
+ /** When a single resolved agent exists. */
17
+ agent?: DetectedAgent;
18
+ /** When multiple healthy agents exist and the picker should run. */
19
+ needsPicker?: {
20
+ healthy: DetectedAgent[];
21
+ defaultIndex: number;
22
+ };
23
+ /** When the flag asked for an agent that's not healthy. */
24
+ flagMissing?: {
25
+ requested: DetectableAgent;
26
+ };
27
+ }
28
+ /**
29
+ * §4 resolution order LOCK:
30
+ * 1. flag > preference > picker > single-agent fast-path
31
+ *
32
+ * - If `flag` is set and a matching healthy agent exists → return it.
33
+ * - If `flag` is set and no matching healthy agent → `flagMissing`.
34
+ * - Single-agent fast-path: exactly 1 healthy agent → return it
35
+ * (regardless of preference).
36
+ * - Multiple healthy + `preferred` set + matches → picker with that
37
+ * row pre-selected (caller may decide to auto-accept).
38
+ * - Multiple healthy + no preference → picker with first row
39
+ * pre-selected.
40
+ */
41
+ export declare function resolveAgent(args: ResolveAgentArgs): ResolveAgentResult;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { KeychainManager, keychainManager, KeychainError } from './keychain';
2
2
  export { CryptoService, cryptoService, CryptoError, ENCRYPTION_VERSION } from './crypto';
3
- export { AppSyncClient, DownloadUrlResponse } from './appsync';
3
+ export { AppSyncClient, AppSyncGraphQLError, DownloadUrlResponse } from './appsync';
4
4
  export { queries, mutations, subscriptions } from './appsync';
5
5
  export { AuthService, authService } from './auth';
6
6
  export { runAuthCli } from './auth';
@@ -13,4 +13,16 @@ export { parseInteractivePrompt, normalizeSnapshot, } from './prompt-parser';
13
13
  export type { ParsedInteractivePrompt, PromptKind, InteractivePromptOption, } from './prompt-parser';
14
14
  export { resumeOrCreateSession, prepareSessionEncryption, rekeySessionForNewDevices, startDeviceKeyWatcher, registerDeviceEncryptionKey, } from './session';
15
15
  export type { ResumeOrCreateSessionInput, ResumeOrCreateSessionResult } from './session';
16
+ export { detectInstalledAgents, pushDetectedAgents, applyPerSessionOrchestrationOverride, runOrchestrationCli, V1_ORCHESTRATION_PROMPT_KIND, V1_ORCHESTRATION_OPTIONS, mapOptionNumberToUserDecisionKind, mapOptionToUserDecisionKind, } from './orchestration';
17
+ export type { DetectableAgent, V1OrchestrationOption, V1UserDecisionKind, } from './orchestration';
18
+ export * as Reviewer from './reviewer';
19
+ export * as AuditKeys from './audit-keys';
16
20
  export * from './types';
21
+ export * as Planner from './planner';
22
+ export * as StructuralSummary from './structural-summary';
23
+ export { runOrchestrationShell } from './orchestration-shell';
24
+ export { runCompanionMode } from './companion-mode';
25
+ export { pickMode, TierError } from './orchestration-shell';
26
+ export { emitShellEvent, createShellEventEmitter } from './orchestration-shell';
27
+ export { processMarkers, withRoleMarker } from './orchestration-shell';
28
+ export type { Mode, Tier, PlannerDecision, AgentKind, PlannerHealthState, OrchestrationState, OrchestrationAction, ConversationEntry, RunningTaskState, ReviewerSeatState, GateState, ExecutionEventEntry, RefusalEventEntry, BypassEventEntry, MobileEventEntry, EventStreamEntry, QueuedTask, PendingClarification, LastModeFile, } from './orchestration-shell';