@quantiya/codevibe-core 2.0.5 → 2.0.7

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 (159) hide show
  1. package/README.md +7 -5
  2. package/dist/agy-cli-contract.d.ts +14 -0
  3. package/dist/appsync/appsync-client.d.ts +59 -31
  4. package/dist/appsync/event-throttle.d.ts +33 -0
  5. package/dist/appsync/index.d.ts +3 -2
  6. package/dist/appsync/queries.d.ts +4 -2
  7. package/dist/auth/auth-telemetry.d.ts +26 -0
  8. package/dist/auth/vendor-key-cli.d.ts +49 -0
  9. package/dist/companion-mode/index.d.ts +36 -22
  10. package/dist/companion-mode/persist-preference.d.ts +1 -5
  11. package/dist/companion-mode/resolve-agent.d.ts +5 -4
  12. package/dist/config/config.d.ts +0 -5
  13. package/dist/credential-broker/__tests__/upstream-result-helpers.d.ts +21 -0
  14. package/dist/credential-broker/broker.d.ts +196 -12
  15. package/dist/credential-broker/chatgpt-config.d.ts +40 -0
  16. package/dist/credential-broker/index.d.ts +4 -1
  17. package/dist/credential-broker/oauth-account-lock.d.ts +104 -0
  18. package/dist/credential-broker/oauth-refresh.d.ts +72 -0
  19. package/dist/credential-broker/types.d.ts +165 -17
  20. package/dist/credential-broker/upstream-client.d.ts +3 -2
  21. package/dist/credential-broker/vendor-key-store.d.ts +32 -1
  22. package/dist/crypto/__tests__/encrypt-for-emit.test.d.ts +1 -0
  23. package/dist/crypto/encrypt-for-emit.d.ts +39 -0
  24. package/dist/crypto/index.d.ts +2 -0
  25. package/dist/daemon/__tests__/process-guards.test.d.ts +1 -0
  26. package/dist/daemon/index.d.ts +2 -0
  27. package/dist/daemon/process-guards.d.ts +38 -0
  28. package/dist/index.d.ts +17 -2
  29. package/dist/index.js +308 -281
  30. package/dist/keychain/keychain-manager.d.ts +25 -4
  31. package/dist/local-executor/__tests__/reviewer-rationale-flag.test.d.ts +1 -0
  32. package/dist/local-executor/class-a-sign.d.ts +15 -0
  33. package/dist/local-executor/group-decision-outcome.d.ts +11 -0
  34. package/dist/local-executor/implementor-argv.d.ts +89 -7
  35. package/dist/local-executor/local-executor-impl.d.ts +18 -7
  36. package/dist/local-executor/merge-conflict-resolve.d.ts +19 -0
  37. package/dist/local-executor/revert-reconcile.d.ts +12 -0
  38. package/dist/local-executor/reviewer-rationale-flag.d.ts +10 -0
  39. package/dist/local-executor/types.d.ts +1 -0
  40. package/dist/local-model/manager.d.ts +1 -1
  41. package/dist/local-model/ollama.d.ts +40 -0
  42. package/dist/orchestration/__tests__/detect-agents.test.d.ts +1 -0
  43. package/dist/orchestration/detect-agents.d.ts +10 -30
  44. package/dist/orchestration/index.d.ts +1 -2
  45. package/dist/orchestration-shell/__tests__/a1a-planner-offers.test.d.ts +1 -0
  46. package/dist/orchestration-shell/__tests__/a6-cli-surface.test.d.ts +1 -0
  47. package/dist/orchestration-shell/__tests__/advisory-attachments-dir-race.test.d.ts +1 -0
  48. package/dist/orchestration-shell/__tests__/advisory-multi-mention-panel.test.d.ts +1 -0
  49. package/dist/orchestration-shell/__tests__/advisory-panel-attachments.test.d.ts +1 -0
  50. package/dist/orchestration-shell/__tests__/advisory-quota-stdout-result.test.d.ts +1 -0
  51. package/dist/orchestration-shell/__tests__/agent-turn-context-batch.test.d.ts +1 -0
  52. package/dist/orchestration-shell/__tests__/bounded-shutdown.test.d.ts +1 -0
  53. package/dist/orchestration-shell/__tests__/brainstorm-quorum-wiring.test.d.ts +1 -0
  54. package/dist/orchestration-shell/__tests__/brainstorm-quorum.test.d.ts +1 -0
  55. package/dist/orchestration-shell/__tests__/cli-team-session-key.test.d.ts +1 -0
  56. package/dist/orchestration-shell/__tests__/command-intent.test.d.ts +1 -0
  57. package/dist/orchestration-shell/__tests__/context-compaction.test.d.ts +1 -0
  58. package/dist/orchestration-shell/__tests__/context-items-hosted-sync.test.d.ts +1 -0
  59. package/dist/orchestration-shell/__tests__/context-items-wiring.test.d.ts +1 -0
  60. package/dist/orchestration-shell/__tests__/context-items.test.d.ts +1 -0
  61. package/dist/orchestration-shell/__tests__/cp8-full-team-events.test.d.ts +1 -0
  62. package/dist/orchestration-shell/__tests__/cp8-team-decomposed-zk.test.d.ts +1 -0
  63. package/dist/orchestration-shell/__tests__/explicit-tty-exit.test.d.ts +1 -0
  64. package/dist/orchestration-shell/__tests__/mention-suggest.test.d.ts +1 -0
  65. package/dist/orchestration-shell/__tests__/route-browse-summarize-recovery.test.d.ts +1 -0
  66. package/dist/orchestration-shell/attachments.d.ts +58 -2
  67. package/dist/orchestration-shell/bounded-shutdown.d.ts +16 -0
  68. package/dist/orchestration-shell/brainstorm-quorum.d.ts +118 -0
  69. package/dist/orchestration-shell/cli.d.ts +97 -70
  70. package/dist/orchestration-shell/cli.js +30990 -22426
  71. package/dist/orchestration-shell/command-intent.d.ts +56 -0
  72. package/dist/orchestration-shell/components/InputBar.d.ts +6 -0
  73. package/dist/orchestration-shell/components/OrchestrationApp.d.ts +2 -0
  74. package/dist/orchestration-shell/context-compaction.d.ts +264 -0
  75. package/dist/orchestration-shell/context-items-hosted-sync.d.ts +19 -0
  76. package/dist/orchestration-shell/context-items.d.ts +408 -0
  77. package/dist/orchestration-shell/context-store.d.ts +162 -0
  78. package/dist/orchestration-shell/emit-shell-event.d.ts +34 -13
  79. package/dist/orchestration-shell/explicit-tty-exit.d.ts +18 -0
  80. package/dist/orchestration-shell/gate-prompts.d.ts +3 -3
  81. package/dist/orchestration-shell/index.d.ts +306 -37
  82. package/dist/orchestration-shell/mention-suggest.d.ts +11 -0
  83. package/dist/orchestration-shell/mode-selection.d.ts +4 -22
  84. package/dist/orchestration-shell/quorum-loop.d.ts +336 -20
  85. package/dist/orchestration-shell/task-progress.d.ts +2 -0
  86. package/dist/orchestration-shell/team-decompose.d.ts +37 -19
  87. package/dist/orchestration-shell/types.d.ts +71 -4
  88. package/dist/planner/index.d.ts +1 -1
  89. package/dist/planner/local-advisory.d.ts +12 -0
  90. package/dist/planner/local-gemma.d.ts +27 -0
  91. package/dist/planner/types.d.ts +7 -0
  92. package/dist/reviewer/index.d.ts +0 -2
  93. package/dist/reviewer/provider.d.ts +9 -6
  94. package/dist/reviewer/providers/antigravity.d.ts +2 -3
  95. package/dist/reviewer/registry.d.ts +9 -4
  96. package/dist/reviewer/token-usage.d.ts +10 -0
  97. package/dist/session/__tests__/device-registration-lease.test.d.ts +1 -0
  98. package/dist/session/__tests__/pending-session-create.test.d.ts +1 -0
  99. package/dist/session/__tests__/session-rekey-fingerprint.test.d.ts +1 -0
  100. package/dist/session/__tests__/session-resume-key-reconciliation.test.d.ts +1 -0
  101. package/dist/session/__tests__/session-resume-pending-first.test.d.ts +1 -0
  102. package/dist/session/device-key-watcher.d.ts +1 -0
  103. package/dist/session/index.d.ts +4 -2
  104. package/dist/session/pending-session-create.d.ts +61 -0
  105. package/dist/session/register-device-key.d.ts +11 -1
  106. package/dist/session/session-rekey.d.ts +4 -5
  107. package/dist/session/session-resume.d.ts +21 -1
  108. package/dist/substrate/docker.d.ts +7 -0
  109. package/dist/substrate/sandbox-exec.d.ts +17 -3
  110. package/dist/substrate/types.d.ts +32 -3
  111. package/dist/substrate-launch/apikey-bootstrap.d.ts +24 -1
  112. package/dist/substrate-launch/engage-substrate.d.ts +17 -0
  113. package/dist/substrate-launch/sanitized-env.d.ts +5 -5
  114. package/dist/tool-activity/__tests__/consolidator.test.d.ts +1 -0
  115. package/dist/tool-activity/__tests__/digest.test.d.ts +1 -0
  116. package/dist/tool-activity/__tests__/flock-rollout-lock.test.d.ts +1 -0
  117. package/dist/tool-activity/__tests__/ledger.test.d.ts +1 -0
  118. package/dist/tool-activity/__tests__/outbox.test.d.ts +1 -0
  119. package/dist/tool-activity/__tests__/replay-cursor.test.d.ts +1 -0
  120. package/dist/tool-activity/__tests__/session-map.test.d.ts +1 -0
  121. package/dist/tool-activity/__tests__/socket-rollout-lock.test.d.ts +1 -0
  122. package/dist/tool-activity/atomic-file.d.ts +27 -0
  123. package/dist/tool-activity/consolidator.d.ts +253 -0
  124. package/dist/tool-activity/digest.d.ts +4 -0
  125. package/dist/tool-activity/flock-rollout-lock.d.ts +68 -0
  126. package/dist/tool-activity/index.d.ts +9 -0
  127. package/dist/tool-activity/ledger.d.ts +274 -0
  128. package/dist/tool-activity/outbox.d.ts +60 -0
  129. package/dist/tool-activity/replay-cursor.d.ts +156 -0
  130. package/dist/tool-activity/session-map.d.ts +133 -0
  131. package/dist/tool-activity/socket-rollout-lock.d.ts +57 -0
  132. package/dist/tool-activity/types.d.ts +368 -0
  133. package/dist/types/encryption.d.ts +4 -0
  134. package/dist/types/events.d.ts +24 -4
  135. package/dist/types/session.d.ts +32 -2
  136. package/package.json +6 -5
  137. package/dist/orchestration/orchestration-cli.d.ts +0 -12
  138. package/dist/orchestration/setup-bootstrap.d.ts +0 -146
  139. package/dist/orchestration/setup-failure-recourse.d.ts +0 -23
  140. package/dist/orchestration/setup-save.d.ts +0 -47
  141. package/dist/orchestration/setup-seat-picker.d.ts +0 -72
  142. package/dist/orchestration/setup-telemetry.d.ts +0 -54
  143. package/dist/orchestration/setup-test-agents.d.ts +0 -108
  144. package/dist/orchestration/setup-types.d.ts +0 -146
  145. package/dist/orchestration/setup-wizard.d.ts +0 -57
  146. package/dist/orchestration-shell/cohort-flag.d.ts +0 -16
  147. package/dist/reviewer/providers/gemini.d.ts +0 -109
  148. /package/dist/{companion-mode/__tests__/detect-parallel.test.d.ts → appsync/__tests__/appsync-client-context-items.test.d.ts} +0 -0
  149. /package/dist/{orchestration-shell/__tests__/cli-stub-session-adapter.test.d.ts → appsync/__tests__/heartbeat-active.test.d.ts} +0 -0
  150. /package/dist/{orchestration/__tests__/setup-bootstrap.test.d.ts → appsync/__tests__/orphan-sweep-null-heartbeat.test.d.ts} +0 -0
  151. /package/dist/{orchestration/__tests__/setup-failure-recourse.test.d.ts → auth/__tests__/vendor-key-cli.test.d.ts} +0 -0
  152. /package/dist/{orchestration/__tests__/setup-save.test.d.ts → companion-mode/__tests__/mode-selected-emit.test.d.ts} +0 -0
  153. /package/dist/{orchestration/__tests__/setup-seat-picker.test.d.ts → companion-mode/__tests__/private-launcher-detection.test.d.ts} +0 -0
  154. /package/dist/{orchestration/__tests__/setup-telemetry.test.d.ts → companion-mode/__tests__/private-launcher-path.test.d.ts} +0 -0
  155. /package/dist/{orchestration/__tests__/setup-test-agents.test.d.ts → credential-broker/__tests__/broker-c4.test.d.ts} +0 -0
  156. /package/dist/{orchestration/__tests__/setup-types.test.d.ts → credential-broker/__tests__/broker-streaming.test.d.ts} +0 -0
  157. /package/dist/{orchestration/__tests__/setup-wizard.test.d.ts → credential-broker/__tests__/chatgpt-config.test.d.ts} +0 -0
  158. /package/dist/{reviewer/providers/__tests__/gemini-live-smoke.test.d.ts → credential-broker/__tests__/oauth-account-lock.test.d.ts} +0 -0
  159. /package/dist/{reviewer/providers/__tests__/gemini.test.d.ts → credential-broker/__tests__/oauth-refresh.test.d.ts} +0 -0
@@ -66,11 +66,49 @@ export interface CopiedAttachment {
66
66
  relPath: string;
67
67
  mime: string;
68
68
  }
69
+ /**
70
+ * [#637 Stage-2 R6 HIGH] The pinned filesystem identity of the attachments dir
71
+ * (`dev`+`ino` from the validation/creation-time lstat). `O_NOFOLLOW` guards
72
+ * only the FINAL path component, so any op that RESOLVES THROUGH the dir
73
+ * (tmp-file open, rename, unlink, rmdir) must re-verify the parent dir is
74
+ * still the very same inode immediately beforehand — a concurrent swap of
75
+ * `.codevibe-attachments` to a symlink would otherwise redirect writes or
76
+ * deletions outside the repo.
77
+ */
78
+ export interface AttachmentsDirIdentity {
79
+ dev: number;
80
+ ino: number;
81
+ }
82
+ /**
83
+ * [R6 HIGH] Identity re-check immediately before a write/cleanup op that
84
+ * resolves through the attachments dir: lstat (never follows), must be a REAL
85
+ * directory with the SAME dev+ino as pinned at validation time. Any mismatch,
86
+ * missing identity, or lstat failure → false (fail CLOSED). Node has no
87
+ * openat-style fd-relative open/rename/unlink; the immediately-preceding
88
+ * re-check is the accepted approximation (the residual window is the single
89
+ * syscall gap).
90
+ */
91
+ export declare function verifyAttachmentsDirIdentity(dirPath: string, identity: AttachmentsDirIdentity | null): boolean;
69
92
  export interface PreparedAttachments {
70
93
  copiedAttachments: CopiedAttachment[];
71
94
  failedAttachments: ImageAttachment[];
72
95
  /** The brief with FAILED-copy refs rewritten to a neutral marker (no dangling ref). */
73
96
  roundBrief: string;
97
+ /**
98
+ * [#637 Stage-2 R5 LOW-3] True iff THIS call's OWN mkdir created the
99
+ * attachments dir (non-recursive — a dir raced into existence by another
100
+ * process signals EEXIST → false). The advisory caller gates its cleanup
101
+ * rmdir on this so it never removes a dir it did not create; a caller-side
102
+ * stat-before-await inference was racy.
103
+ */
104
+ createdAttachmentsDir: boolean;
105
+ /**
106
+ * [R6 HIGH] The pinned identity every copy was verified against — null when
107
+ * staging was refused or no directory could be established. Cleanup callers
108
+ * MUST pass this to `verifyAttachmentsDirIdentity` immediately before each
109
+ * unlink and the rmdir.
110
+ */
111
+ attachmentsDirIdentity: AttachmentsDirIdentity | null;
74
112
  }
75
113
  /**
76
114
  * Per-round copy + failure-rewrite in ONE step (§7.3, rev-7). For each attachment,
@@ -80,13 +118,31 @@ export interface PreparedAttachments {
80
118
  * in `roundBrief` to `[attached image skipped]` (so no dangling ref survives). The
81
119
  * returned `roundBrief` (failures neutralized) feeds BOTH the per-agent stdin AND
82
120
  * the execute-first payload. Never throws / never hard-blocks.
121
+ *
122
+ * [#637] `destMode: 'real_worktree'` — the read-only advisory panel stages into
123
+ * the user's REAL repo (no shadow). A pre-existing symlink / non-directory at
124
+ * `.codevibe-attachments` there belongs to the USER, so the whole staging is
125
+ * REFUSED (every attachment failed, refs neutralized; the advisory proceeds
126
+ * text-only) instead of the shadow path's rm-and-recreate. Default `'shadow'`
127
+ * keeps the replacement behavior — the shadow is disposable and the entry there
128
+ * could only be implementor-planted.
83
129
  */
84
- export declare function prepareAttachmentsForSpawn(roundBrief: string, attachments: ImageAttachment[], shadowDir: string): PreparedAttachments;
130
+ export declare function prepareAttachmentsForSpawn(roundBrief: string, attachments: ImageAttachment[], shadowDir: string, opts?: {
131
+ destMode?: 'shadow' | 'real_worktree';
132
+ /**
133
+ * Injectable test seam (deterministic swap-window tests, same idiom as
134
+ * `IngestOptions.newId`): runs between the dir-identity pin and the
135
+ * per-file copies — exactly the [R6 HIGH] race window.
136
+ */
137
+ onDirEnsured?: () => void;
138
+ }): PreparedAttachments;
85
139
  /**
86
140
  * Per-agent rendering of the copied-attachment refs, appended to the brief at spawn
87
141
  * (§7.2). The stored/canonical brief is agent-NEUTRAL (`.codevibe-attachments/<id>.<ext>`);
88
142
  * this adds the agent-specific pointer: Claude/Codex → an `Attached images:` list of
89
- * relative paths (read via their Read tool); Gemini → the `@./…` form.
143
+ * relative paths (read via their Read tool); Antigravity → an absolute-path list (its
144
+ * Read tool resolves against agy's own scratch project, not the shadow cwd). (Gemini was
145
+ * SUNSET in 2026-07 and is never dispatched — its `@./…` rendering branch was removed.)
90
146
  */
91
147
  export declare function renderAttachmentsForAgent(agent: string, copied: CopiedAttachment[], workdir?: string): string;
92
148
  /**
@@ -0,0 +1,16 @@
1
+ export type ShutdownDeadlineClass = 'normal' | 'signal';
2
+ export interface BoundedSharedShutdownOperation {
3
+ wait: (deadlineClass?: ShutdownDeadlineClass) => Promise<void>;
4
+ }
5
+ export interface BoundedSharedShutdownOperationOptions {
6
+ start: () => Promise<void>;
7
+ normalTimeoutMs: number;
8
+ signalTimeoutMs: number;
9
+ onTimeout?: (deadlineClass: ShutdownDeadlineClass, timeoutMs: number) => void;
10
+ }
11
+ /**
12
+ * Starts one shutdown operation and gives normal and signal callers one shared
13
+ * absolute timeout each. Repeated callers never restart either the operation or
14
+ * their deadline, so nested teardown paths cannot multiply the exit latency.
15
+ */
16
+ export declare function createBoundedSharedShutdownOperation(options: BoundedSharedShutdownOperationOptions): BoundedSharedShutdownOperation;
@@ -0,0 +1,118 @@
1
+ import type { Tier } from './types';
2
+ import type { CommandIntentTarget } from './command-intent';
3
+ /**
4
+ * The frontier panel's active-set members. This is the intersection of the
5
+ * `@`-mention vocabulary (`command-intent.ts` — Gemini is excluded from direct
6
+ * mentions) with the review quorum's ACTIVE_AGENT_KINDS (`detectInstalledAgents`
7
+ * probes exactly these three; Gemini is legacy-readable but not new-routable).
8
+ */
9
+ export type BrainstormPanelActiveAgent = 'CLAUDE' | 'CODEX' | 'ANTIGRAVITY';
10
+ /**
11
+ * OQ-BRAINSTORM-COST resolution: the frontier brainstorm panel is **Max-only**
12
+ * ("Max-only panel?"). Firing frontier agents per turn is expensive; the default
13
+ * interactive brainstorm remains the local 12B (`routeBrainstorm`), available to
14
+ * Pro/Max. The panel (both `@all` broadcast AND a directed `@agent` frontier
15
+ * routing) is gated here.
16
+ */
17
+ export declare const BRAINSTORM_PANEL_MIN_TIER: Tier;
18
+ /**
19
+ * The resolved panel active set, mirroring the review quorum's
20
+ * "installed ∧ non-quota-walled ∧ tier-permitted" intersection
21
+ * (quorum-loop `getDetectedAgents()` + `pickAutoContinuationTarget`).
22
+ */
23
+ export type BrainstormPanelResolution = {
24
+ kind: 'ready';
25
+ activeAgents: BrainstormPanelActiveAgent[];
26
+ } | {
27
+ kind: 'tier_gated';
28
+ } | {
29
+ kind: 'no_agents';
30
+ } | {
31
+ kind: 'all_quota_walled';
32
+ walled: BrainstormPanelActiveAgent[];
33
+ };
34
+ /**
35
+ * Resolve which frontier agents fire for this brainstorm turn.
36
+ *
37
+ * Order of gates (each fails to a distinct, user-legible reason):
38
+ * 1. **Tier** — below Max → `tier_gated` (no agent is spawned).
39
+ * 2. **Target ∩ installed** — an `@all` broadcast targets every installed
40
+ * panel agent; a directed `@claude`/`@codex`/`@agy` targets exactly that one
41
+ * IF installed. Empty → `no_agents`.
42
+ * 3. **Minus quota-walled** — subtract the session's quota-exhausted set (the
43
+ * way `pickAutoContinuationTarget` subtracts `quotaFailedAgentsByTask`). If
44
+ * every candidate is walled → `all_quota_walled` (nothing fires).
45
+ *
46
+ * Pure: the caller supplies the already-detected installed set and the walled
47
+ * set (both live in index.ts's session-scoped state).
48
+ */
49
+ export declare function resolveBrainstormPanel(input: {
50
+ tier: Tier;
51
+ target: CommandIntentTarget;
52
+ /**
53
+ * [#637] ALL mention targets of a multi-mention turn (ordered, de-duplicated —
54
+ * `extractAllAgentMentionIntents`). When present it supersedes `target` for
55
+ * the active-set computation: the candidates are the mentioned agents ∩
56
+ * installed IN MENTION ORDER, and any `'ALL'` member means the whole installed
57
+ * set (existing `@all` semantics win). `target` stays the FIRST mention — the
58
+ * frozen `CommandIntentEnvelope`'s. Absent/single-element → prior behavior.
59
+ */
60
+ targets?: readonly CommandIntentTarget[];
61
+ detectedAgents: readonly BrainstormPanelActiveAgent[];
62
+ quotaWalled: ReadonlySet<BrainstormPanelActiveAgent>;
63
+ }): BrainstormPanelResolution;
64
+ /**
65
+ * The ContextItem `author.agent_id` for a panel agent — the lowercase mention id
66
+ * (§4 example: `'claude' | 'codex' | 'gemini' | 'agy'`). The rehydration render
67
+ * shows this verbatim as the attribution label ("claude: …", "agy: …"), so a
68
+ * later `@claude "critique the above"` sees WHO said what.
69
+ */
70
+ export declare function agentIdForAuthor(agent: BrainstormPanelActiveAgent): 'claude' | 'codex' | 'agy';
71
+ /**
72
+ * §8.2 — surface the active-set count/identities UP FRONT so the fan-out cost is
73
+ * visible before it fires (the design's "→ Opus 4.8 · GPT-5.5 · Gemini 5.5").
74
+ * The display names come from the caller (index.ts `agentDisplayName`) so the
75
+ * mapping stays single-sourced.
76
+ */
77
+ export declare function renderBrainstormPanelHeader(activeAgents: readonly BrainstormPanelActiveAgent[], displayName: (agent: BrainstormPanelActiveAgent) => string): string;
78
+ /**
79
+ * Below Max: the frontier panel is fenced, but the local model still
80
+ * brainstorms. No frontier agent was called and no code was changed.
81
+ */
82
+ export declare function brainstormTierGateMessage(target: CommandIntentTarget): string;
83
+ /**
84
+ * Every candidate for this mention is currently quota-walled for the session.
85
+ */
86
+ export declare function brainstormAllQuotaWalledMessage(walled: readonly BrainstormPanelActiveAgent[], displayName: (agent: BrainstormPanelActiveAgent) => string): string;
87
+ /**
88
+ * [A1g] Stage-2 (Codex round-2 HIGH) — the CLOSED-LABEL notice for a single
89
+ * brainstorm-panel cell that FAILED (a spawn/exec error, a quota wall, OR the
90
+ * absolute-ceiling timeout — #635). This is the ONLY per-agent failure text that
91
+ * enters the panel section, which the turn-mirror mirrors to mobile as
92
+ * ASSISTANT_RESPONSE. The substantive diagnostic (the sanitized advisory fallback
93
+ * / raw error) MUST NOT ride this section — it stays desktop-local via
94
+ * `logger.warn` (the WIRE is what the ZK invariant governs, NOT the local log
95
+ * file, which never leaves the machine). The invariant is stricter than
96
+ * ZK-on-wire (the mirror is E2E-encrypted regardless): only a BOUNDED enum label
97
+ * is surfaced on the wire, never the agent's diagnostic. Three labels only —
98
+ * quota-wall vs timeout vs generic failure — so no free-form detail can leak
99
+ * through. [#635] the `'quota_walled'`/`'failed'` strings are preserved VERBATIM
100
+ * from the prior 2-label version; only `'timed_out'` is new.
101
+ */
102
+ export type BrainstormPanelFailureReason = 'quota_walled' | 'timed_out' | 'failed';
103
+ export declare function brainstormPanelFailureNotice(reason: BrainstormPanelFailureReason): string;
104
+ /**
105
+ * Compose the panel brief fed to each frontier agent: the typed-store
106
+ * "idea-so-far + open-questions" projection (rendered by
107
+ * `renderRehydratedSessionContext(role:'brainstorm')`, so it carries prior
108
+ * attributed panel turns) as a labeled PREFIX, then the current request. The
109
+ * projection is PRIOR context only — the current turn is authored into the store
110
+ * AFTER this turn completes (the mirror chokepoint), so there is no overlap.
111
+ *
112
+ * Empty `priorContext` (fresh session / unverifiable chain — fail-closed to
113
+ * NOTHING) degrades to just the request, exactly as today.
114
+ */
115
+ export declare function composeBrainstormPanelBrief(input: {
116
+ priorContext: string;
117
+ requestBrief: string;
118
+ }): string;
@@ -1,6 +1,7 @@
1
1
  import { AppSyncClient } from '../appsync';
2
2
  import { Session } from '../types';
3
3
  import { Mode, Tier } from './types';
4
+ import { type ModeSelectionDeps } from './mode-selection';
4
5
  import { type RunOrchestrationShellArgs } from './index';
5
6
  import { type ShellEventEmit } from './emit-shell-event';
6
7
  import { BackendPlannerClient, PlannerCacheLayer, PlannerHealthMachine, type LocalGemmaAdvisoryRunner, type LocalGemmaPlannerRunner } from '../planner';
@@ -15,46 +16,13 @@ import { type VerdictClassifier } from '../reviewer/verdict-classifier';
15
16
  import { type LocalModelArtifactConfig, type LocalModelCommand, type LocalModelEntitlement, type LocalModelStore } from '../local-model/manager';
16
17
  import { type LocalModelState } from '../local-model/state';
17
18
  /**
18
- * CP-1.b IMPL r5 H-1 — Sentinel error thrown by the stub-session
19
- * planner adapter. `handleShellUserInput` catches this typed class and
20
- * routes it through the explicit error renderer (SLASH_OUTPUT) so the
21
- * user sees an actionable message in the conversation pane instead of
22
- * a silent log line. Stub sessions (sessionId prefix `cp1a-local-` or
23
- * empty `encryptedKeys`) cannot reach the Lambda — `encryptedKeys` is
24
- * missing, the keychain resolver returns null, and the planner client
25
- * throws "session key unresolved" deep inside classify(). Surfacing
26
- * that as a typed error at the adapter boundary is cleaner than the
27
- * generic Error from `BackendPlannerClient.classify()`.
19
+ * Sentinel error rendered by the shell when the configured local planner
20
+ * runtime is unavailable. Session bootstrap failures are handled before the
21
+ * TUI opens and never use this planner-level error path.
28
22
  */
29
23
  export declare class PlannerUnavailableError extends Error {
30
24
  constructor(msg: string);
31
25
  }
32
- /**
33
- * CP-1.b IMPL r5 H-1 — Stub-session planner adapter.
34
- *
35
- * CP-1.a still ships a fake `cp1a-local-*` session with no
36
- * `encryptedKeys[]`. The production `BackendPlannerClient` cannot
37
- * classify against that session — the Lambda requires E2E-encrypted
38
- * payloads, which requires the session key, which the keychain
39
- * resolver cannot derive without `encryptedKeys`.
40
- *
41
- * Rather than wire up the production stack and let it fail with a
42
- * generic "session key unresolved" Error deep inside classify(), we
43
- * detect stub sessions at bootstrap and construct this adapter, which
44
- * throws a typed `PlannerUnavailableError` on classify(). The shell's
45
- * `handleShellUserInput` catches this and renders an actionable
46
- * message to the user (`PLANNER_UNAVAILABLE: <reason>`). CP-1.c lands
47
- * the real session bootstrap (resumeOrCreateSession + AppSync) and
48
- * this adapter is no longer wired in.
49
- */
50
- export declare class PlannerUnavailableAdapter implements PlannerAdapter {
51
- private readonly reason;
52
- private activeSessionId;
53
- constructor(reason: string);
54
- classify(_input: PlannerInput): Promise<PlannerDecision>;
55
- probe(): Promise<PlannerProbeResult>;
56
- setActiveSession(sessionId: string | null): void;
57
- }
58
26
  /**
59
27
  * Local-LLM planner placeholder for the Gemma QAT migration slice. This adapter
60
28
  * is intentionally local-only: it never calls AppSync planner mutations or any
@@ -68,21 +36,38 @@ export declare class LocalModelPlannerUnavailableAdapter implements PlannerAdapt
68
36
  probe(): Promise<PlannerProbeResult>;
69
37
  setActiveSession(_sessionId: string | null): void;
70
38
  }
71
- /**
72
- * CP-1.b IMPL r5 H-1 — Detect a CP-1.a stub session. Two signals:
73
- * (a) `sessionId` starts with `cp1a-local-` (the
74
- * `buildStubSession()` prefix).
75
- * (b) `session.encryptedKeys` is empty / missing (any session
76
- * lacking E2E keys cannot route through the Lambda).
77
- *
78
- * Either signal triggers the stub-session adapter. The (b) gate is
79
- * a defensive fallback for the case where CP-1.c starts a real
80
- * session bootstrap but `prepareSessionEncryption()` returns null
81
- * (no device keys registered): the planner is genuinely unavailable
82
- * until the user registers a device key.
83
- */
84
- export declare function isStubSession(session: Session): boolean;
85
- export declare function buildStubSessionShellArgs(args: Omit<RunOrchestrationShellArgs, 'disableStructuralContextRefresh'>): RunOrchestrationShellArgs;
39
+ export type OrchestrationSessionBootstrapFailureKind = 'auth_required' | 'backend_unavailable' | 'encryption_unavailable' | 'session_limit' | 'session_create_failed';
40
+ /** An orchestration shell cannot exist without an admitted encrypted session. */
41
+ export declare class OrchestrationSessionBootstrapError extends Error {
42
+ readonly kind: OrchestrationSessionBootstrapFailureKind;
43
+ readonly cause?: unknown;
44
+ constructor(kind: OrchestrationSessionBootstrapFailureKind, message: string, cause?: unknown);
45
+ }
46
+ export declare function classifyOrchestrationSessionBootstrapError(error: unknown): OrchestrationSessionBootstrapError;
47
+ export declare class CliAuthenticationError extends Error {
48
+ readonly kind: 'auth_required' | 'auth_unavailable' | 'credential_storage_unavailable';
49
+ readonly cause?: unknown;
50
+ constructor(kind: 'auth_required' | 'auth_unavailable' | 'credential_storage_unavailable', message: string, cause?: unknown);
51
+ }
52
+ /** Subscription verification is mandatory before either product mode starts. */
53
+ export declare class CliEntitlementError extends Error {
54
+ readonly kind: "entitlement_unavailable";
55
+ readonly cause?: unknown;
56
+ constructor(message: string, cause?: unknown);
57
+ }
58
+ /** Both Companion and Orchestration require a verified signed-in account. */
59
+ export declare function requireCliAuthentication(client: Pick<AppSyncClient, 'authenticateWithStoredTokens' | 'getLastAuthFailureKind'>): Promise<void>;
60
+ export interface ParsedCliArgs {
61
+ agent?: 'CLAUDE' | 'CODEX' | 'ANTIGRAVITY';
62
+ help: boolean;
63
+ passthrough: string[];
64
+ }
65
+ export declare class CliUsageError extends Error {
66
+ constructor(message: string);
67
+ }
68
+ export declare function parseCliArgs(argv: string[]): ParsedCliArgs;
69
+ /** Resolve the product mode without opening the mode picker for --agent. */
70
+ export declare function resolveLaunchMode(args: Pick<ParsedCliArgs, 'agent'>, tier: Tier, deps?: ModeSelectionDeps): Promise<Mode>;
86
71
  /**
87
72
  * CP-1.f §3.C.19 — resolve a REAL backend session for the orchestration loop
88
73
  * (closes #513). When authenticated:
@@ -96,19 +81,45 @@ export declare function buildStubSessionShellArgs(args: Omit<RunOrchestrationShe
96
81
  * `Session.encryptedKeys` (can decrypt encProposal/verdict) AND the local
97
82
  * key cache is warm. Stage-1 FIX 1 — replaces the prior crypto-dropping
98
83
  * `createSession` reimplementation that hung the loop ("no session key").
99
- * Falls back to `buildStubSession()` when unauthenticated / offline / on any
100
- * error — the stub-session guards downstream keep that path fully usable.
84
+ * Authentication, encryption, and backend admission are hard prerequisites.
85
+ * Failures propagate to `main`, which exits before opening the shell.
101
86
  *
102
87
  * The tier is resolved here too (§3.C.19): a `CODEVIBE_TIER` env override wins
103
- * (the dev/dogfood lever), else `getSubscriptionStatus`, else FREE (fail-closed
104
- * — Orchestration Mode is never surfaced to Free).
88
+ * (the dev/dogfood lever), otherwise `getSubscriptionStatus` must succeed.
105
89
  */
106
90
  export declare function resumeOrCreateSession(appsyncClient: AppSyncClient, deps?: {
107
91
  resolveSessionIdFn?: (client: AppSyncClient) => Promise<string | null>;
92
+ /** Already verified by CLI startup; avoids a contradictory second lookup. */
93
+ tier?: Tier;
94
+ /** Claims lifecycle responsibility immediately after backend admission. */
95
+ onAdmitted?: (session: Session) => void;
108
96
  }): Promise<{
109
97
  session: Session;
110
98
  tier: Tier;
111
99
  }>;
100
+ export declare function resolveCliTier(appsyncClient: AppSyncClient): Promise<Tier>;
101
+ /** Production startup boundary: preserve actionable typed tier failures. */
102
+ export declare function resolveCliTierForStartup(appsyncClient: AppSyncClient, writeError?: (message: string) => void): Promise<Tier | null>;
103
+ export interface AdmittedSessionOwnershipController {
104
+ /** Synchronous admission edge; safe to call from the pending-ledger helper. */
105
+ onAdmitted(session: Session): void;
106
+ /** Run post-admission startup until the shell accepts teardown ownership. */
107
+ run<T>(launch: (acceptOwnership: () => void) => Promise<T>): Promise<T>;
108
+ /** Close a failed bootstrap and retire any session already admitted. */
109
+ abort(): Promise<void>;
110
+ }
111
+ /**
112
+ * Install lifecycle ownership before admission begins. The pending-create path
113
+ * calls `onAdmitted` immediately after response validation, before any further
114
+ * keychain or ledger await, closing the post-admission cleanup/signal window.
115
+ */
116
+ export declare function createAdmittedSessionOwnershipController(appsyncClient: AppSyncClient): AdmittedSessionOwnershipController;
117
+ /** Test/consumer convenience for a session that has already been admitted. */
118
+ export declare function runWithAdmittedSessionOwnership<T>(args: {
119
+ appsyncClient: AppSyncClient;
120
+ session: Session;
121
+ launch: (acceptOwnership: () => void) => Promise<T>;
122
+ }): Promise<T>;
112
123
  /**
113
124
  * CP-8 Slice C (#570) — parse a top-level `audit show <task-id> [--json]
114
125
  * [--session <id>]` subcommand from the raw argv. Returns null when the argv is
@@ -124,7 +135,6 @@ export interface ParsedAuditArgs {
124
135
  export declare function parseAuditArgs(argv: string[]): ParsedAuditArgs | null;
125
136
  export interface ParsedModelArgs {
126
137
  command: LocalModelCommand | 'help';
127
- viaWithLocalModelFlag: boolean;
128
138
  }
129
139
  /**
130
140
  * Parse local-model meta commands before mode selection. These commands must
@@ -220,7 +230,7 @@ export declare function main(argv: string[]): Promise<number>;
220
230
  *
221
231
  * Exported for unit tests; production callers go through `main()`.
222
232
  */
223
- export declare function buildProductionPlannerStack(appsyncClient: AppSyncClient, emitter: (args: ShellEventEmit) => Promise<void>): {
233
+ export declare function buildProductionPlannerStack(appsyncClient: AppSyncClient, emitter: (args: ShellEventEmit) => Promise<unknown>): {
224
234
  adapter: BackendPlannerClient;
225
235
  cache: PlannerCacheLayer;
226
236
  health: PlannerHealthMachine;
@@ -247,6 +257,11 @@ export interface BuildTeamLocalExecutorResult {
247
257
  * `BuildQuorumLoopExecutorResult.policyRejectionTap`).
248
258
  */
249
259
  policyRejectionTap: PolicyRejectionTap;
260
+ /**
261
+ * A1e (P3 slice-wiring REMAP) — the dispatch-context tap holder (see
262
+ * `BuildQuorumLoopExecutorResult.dispatchContextTap`).
263
+ */
264
+ dispatchContextTap: DispatchContextTap;
250
265
  /**
251
266
  * PHASE-589/469 W3.2 — the two-phase group-escalation decision deps (WITHOUT
252
267
  * the store; `runOrchestrationShell` completes it). Threaded into
@@ -288,6 +303,24 @@ export interface PolicyRejectionTap {
288
303
  recommendedRecovery: string;
289
304
  }) => void;
290
305
  }
306
+ /**
307
+ * A1e (P3 slice-wiring REMAP) — the dispatch-context tap holder (mirrors
308
+ * `progressTap`). `cli.ts` builds it with an inert `fn` (returns `''` — no
309
+ * block); the QuorumLoop's `projectDispatchContext` calls
310
+ * `dispatchContextTap.fn(input)`, and `runOrchestrationShell` installs the
311
+ * real composer (`composeDispatchContextBlock` — the resolved `context_ref`
312
+ * slice + the fresh-only `repo_state` overview + the §8.3 background
313
+ * re-delegation hook) at startup, where the shell's generator/tier/session
314
+ * scope lives. Until then (and for non-loop sessions) the projection is
315
+ * inert and the implementor stdin is byte-identical to pre-A1e.
316
+ */
317
+ export interface DispatchContextTap {
318
+ fn: (input: {
319
+ taskId: string;
320
+ agent: string;
321
+ roundNumber: number;
322
+ }) => Promise<string>;
323
+ }
291
324
  /**
292
325
  * [Gemma classifier · D11 + §Wiring] Resolve the reviewer verdict classifier
293
326
  * threaded onto `QuorumLoopDeps.classifyVerdict`.
@@ -318,6 +351,11 @@ export interface BuildQuorumLoopExecutorResult {
318
351
  * (a classified `SHELL_ADVISORY`).
319
352
  */
320
353
  policyRejectionTap: PolicyRejectionTap;
354
+ /**
355
+ * A1e (P3 slice-wiring REMAP) — the dispatch-context tap holder. `cli.ts`
356
+ * threads it into `runOrchestrationShell`, which installs the real composer.
357
+ */
358
+ dispatchContextTap: DispatchContextTap;
321
359
  }
322
360
  /**
323
361
  * CP-1.f §3.C — Stage-2 r2 (Codex) FIX B. Construct the SINGLE-TASK QuorumLoop +
@@ -345,7 +383,7 @@ export interface BuildQuorumLoopExecutorResult {
345
383
  export declare function buildQuorumLoopExecutor(args: {
346
384
  appsyncClient: AppSyncClient;
347
385
  session: Session;
348
- emitter: (args: ShellEventEmit) => Promise<void>;
386
+ emitter: (args: ShellEventEmit) => Promise<unknown>;
349
387
  /** CP-1.f LOCK RP-6 — host-detected agents threaded into the loop. */
350
388
  detectedAgents?: string[];
351
389
  /** #585 auto-continuation (Max) — the resolved tier, threaded to the loop. */
@@ -357,17 +395,6 @@ export declare function buildQuorumLoopExecutor(args: {
357
395
  */
358
396
  classifyRunner?: LocalGemmaPlannerRunner | null;
359
397
  }): Promise<BuildQuorumLoopExecutorResult>;
360
- /**
361
- * PHASE-589+469 W2 (#TC-5) — map an LE hook-bridge event to the chokepoint's
362
- * `ShellEventEmit`. The team-result summary (`ASSISTANT_RESPONSE`, from
363
- * `emitGroupConvergence`) KEEPS its type AND forwards `content` (the
364
- * light-markdown digest the phone renders); `LOCAL_AUTHORITY_REFUSAL` maps 1:1;
365
- * every other type is coerced to `NOTIFICATION` (audit fallback — those never
366
- * occur on the team paths). Exported so the #TC-5 test drives the REAL mapping
367
- * (not a reproduction): a regression that dropped the `ASSISTANT_RESPONSE` type
368
- * or its `content` — which would silently make the mobile summary dead — is
369
- * caught here.
370
- */
371
398
  export declare function mapTeamLeEventToShellEmit(e: Parameters<LEEmitShellEventFn>[0]): ShellEventEmit;
372
399
  /**
373
400
  * Construct the team-mode LocalExecutorImpl + the store-tap holder. Returns the
@@ -379,7 +406,7 @@ export declare function mapTeamLeEventToShellEmit(e: Parameters<LEEmitShellEvent
379
406
  export declare function buildTeamLocalExecutor(args: {
380
407
  appsyncClient: AppSyncClient;
381
408
  session: Session;
382
- emitter: (args: ShellEventEmit) => Promise<void>;
409
+ emitter: (args: ShellEventEmit) => Promise<unknown>;
383
410
  initialScope: AuthorityScope;
384
411
  /** CP-1.f LOCK RP-6 — host-detected agents threaded into the loop. */
385
412
  detectedAgents?: string[];