@codeam/shared 2.75.3 → 2.75.5

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.
package/dist/index.d.mts CHANGED
@@ -142,14 +142,6 @@ declare function tryGetContextWindow(model: string | null): number | undefined;
142
142
 
143
143
  type AgentId = 'claude' | 'codex' | 'copilot' | 'coderabbit' | 'cursor' | 'aider' | 'gemini' | 'kimi' | 'opencode';
144
144
  type AgentAuthKind = 'oauth_token' | 'api_key' | 'setup_token';
145
- /**
146
- * The agent kinds Headroom (the token-compression proxy) can actually
147
- * wrap/route — the exact subcommands `headroom init --global <kind>`
148
- * accepts. NOT an alias of {@link AgentId}: cursor / gemini / aider run
149
- * native (Headroom disabled) because `headroom init` has no recipe that
150
- * routes them.
151
- */
152
- type HeadroomKind = 'claude' | 'codex' | 'copilot';
153
145
  interface AgentAuth {
154
146
  kind: AgentAuthKind;
155
147
  /** API key plain, or JSON serialized for oauth_token. Interpretation depends on the agent. */
@@ -201,20 +193,6 @@ interface AgentMetadata {
201
193
  enabled: boolean;
202
194
  supportedAuthKinds: AgentAuthKind[];
203
195
  preferredAuthKind: AgentAuthKind;
204
- /**
205
- * Whether Headroom can wrap/route this agent (claude / codex / copilot
206
- * only). Canonical truth previously scattered across two prefix-matching
207
- * predicates: `isHeadroomSupportedAgent` (CLI `host-agent.ts`) and
208
- * `isHeadroomWrappableAgent` (api-v2 `codespaces/headroom.ts`). When
209
- * false the agent MUST run native — wrapping an unsupported agent
210
- * mislaunches it as Claude (the 2026-06 Cursor incident).
211
- */
212
- headroomWrappable: boolean;
213
- /**
214
- * The `headroom init --global <kind>` subcommand for this agent.
215
- * Present iff {@link headroomWrappable} is true.
216
- */
217
- headroomKind?: HeadroomKind;
218
196
  /**
219
197
  * Whether the agent runs over ACP (Agent Client Protocol) in the CLI —
220
198
  * mirrors which agents have an entry in the CLI's ACP adapter registry
@@ -330,31 +308,6 @@ declare const TERMINAL_AGENT_PREFIX = "__terminal__:";
330
308
  * - fall back to anything. Unknown in → `null` out.
331
309
  */
332
310
  declare function normalizeAgentId(raw: string): AgentId | null;
333
- /**
334
- * The `headroom init --global <kind>` subcommand for an agent id, derived
335
- * from the registry's `headroomKind` flags — or `null` for unknown or
336
- * non-wrappable agents (cursor / gemini / aider / anything else).
337
- *
338
- * ⚠️ NEVER falls back to `'claude'`. The historical CLI fallback is how
339
- * the 2026-06 Cursor incident happened: an unsupported agent slipped
340
- * through, defaulted to `claude`, and `headroom wrap claude` launched
341
- * Claude Code instead of the user's agent. Callers that genuinely need a
342
- * default (e.g. picking an init subcommand AFTER the wrappable gate has
343
- * already passed) apply it themselves — see the CLI's
344
- * `agentIdToHeadroomKind` wrapper.
345
- *
346
- * Matching mirrors the historical predicates on BOTH sides (CLI
347
- * `isHeadroomSupportedAgent`, api-v2 `isHeadroomWrappableAgent`):
348
- * case-insensitive, `_`/`-` tolerant, prefix match — so `claude_code`,
349
- * `Claude-Code`, `codex_cli`, `copilot-cli` all resolve.
350
- */
351
- declare function headroomKindFor(agentId: string): HeadroomKind | null;
352
- /**
353
- * Registry-derived replacement for the two scattered predicates
354
- * (`isHeadroomSupportedAgent` in the CLI, `isHeadroomWrappableAgent` in
355
- * api-v2). Accepts both id spaces (`claude_code` and `claude`).
356
- */
357
- declare function isHeadroomWrappable(agentId: string): boolean;
358
311
 
359
312
  /**
360
313
  * Canonical per-agent CLI **install** snippets.
@@ -909,13 +862,22 @@ declare function skillHasRail(id: SkillId, rail: SkillRail): boolean;
909
862
  * Repo-agnostic on purpose: it governs how the agent works on the USER's own
910
863
  * project, so it must never mention CodeAgent-internal workflow (issue tracker,
911
864
  * our branch/deploy rules, our infrastructure).
865
+ *
866
+ * ⚠️ The answering section comes FIRST, and that order is load-bearing: on the
867
+ * non-Claude rail this text is a prompt preface read top-down, and it governs
868
+ * EVERY reply, whereas the working/safety rules only bite on tasks that change
869
+ * code. Our surface is a phone — a desktop-length answer is unreadable on it,
870
+ * and length is a cost the user pays on every single turn. It is deliberately
871
+ * "concise by DEFAULT", never "always short": an explicit request for depth
872
+ * must still get a full answer, or the standard would contradict the rules
873
+ * below that require sharing a plan and showing the evidence.
912
874
  */
913
875
  /** Idempotency marker wrapping the block appended to an agent's instruction file. */
914
876
  declare const AGENT_STANDARD_MARKER = "<!-- codeam:agent-standard -->";
915
877
  /** The standard, clean markdown (no markers) — used verbatim as a prompt preface. */
916
- declare const AGENT_STANDARD_TEXT = "# Working standard\n\nYou are an AI coding agent working on the user's project through CodeAgent Mobile. Follow this standard on every task.\n\n## How to work\n- **Understand before acting.** Restate the goal, read the relevant code, and be clear on what \"done\" looks like before changing anything.\n- **Plan first for anything non-trivial** (3+ steps or a design decision): outline the approach and the files you'll touch, and share it before implementing. Skip the ceremony for small, obvious fixes.\n- **Ground every claim in reality** \u2014 the actual code, tests, or output, never guesswork. If you are unsure, say so and verify.\n- **Ask when intent is genuinely ambiguous** \u2014 one sharp question. At a real fork, give a recommendation, not a survey of every option.\n- **Stay in scope.** Solve what was asked; no \"while I'm here\" refactors or speculative abstractions. Note unrelated issues instead of acting on them.\n- **Favor the simplest solution that fully solves the problem.** Fix root causes, not symptoms \u2014 no temporary patches and no defensive code for cases that can't happen.\n- **Verify your work and show the evidence** \u2014 run the project's tests, linters, and build, and read the output. \"It runs\" is not \"it's done.\"\n- **Match the project's existing style, structure, and conventions.** Comment only the non-obvious WHY, briefly \u2014 don't narrate the code.\n- **Stop when stuck.** If the same fix fails twice, step back and reconsider the approach rather than repeating variations.\n\n## Safety\n- **Never expose or exfiltrate** secrets, credentials, tokens, or customer data, and never print a credential's value.\n- **Treat destructive or irreversible actions as needing explicit confirmation** \u2014 force-push, history rewrite, bulk deletes, hard resets, dropping data. Don't run them unprompted.\n- **Don't push to a shared/default branch or make outward-facing changes** unless the user asked for it.\n- **Report honestly when you finish**: what you changed, what you verified, and anything you could not.";
878
+ declare const AGENT_STANDARD_TEXT = "# Working standard\n\nYou are an AI coding agent working on the user's project through CodeAgent Mobile. Follow this standard on every task.\n\n## How to answer \u2014 you are being read on a PHONE\n\nYour reply is read on a narrow screen, often one-handed, often while the user is doing something else. Length is a cost they pay. Write accordingly.\n\n- **Lead with the answer.** First line = the result, the decision, or what changed. No preamble, no restating the request, no \"Great question!\", no narrating what you are about to do.\n- **Default to a few sentences.** Most replies fit in 1-2 short paragraphs or 3-6 tight bullets. A long reply is a deliberate choice you make because the task genuinely needs it \u2014 not the default.\n- **Say it once.** No summary of the summary, no closing paragraph that repeats the opening, no \"let me know if you need anything else\".\n- **Cut every word that carries no information** \u2014 hedges, filler adverbs, throat-clearing, and praise for the question.\n- **Expand when asked.** \"Explain in detail\", \"walk me through it\", \"why?\" are requests for depth: give it fully. Brevity is the default, not a ceiling.\n\n**Formatting for a narrow screen:**\n- Short paragraphs (1-3 sentences). Bullets over prose for anything that is a list. Never a wall of text.\n- **No wide tables** \u2014 they force horizontal scrolling and become unreadable. Use bullets, or at most two columns.\n- Code blocks only when the user needs the exact characters (a command to run, the changed lines). Show the relevant lines, not the whole file. Keep lines short so they don't wrap badly.\n- File references as `path/to/file.ts:42`, not pasted paths inside long prose.\n- Bold sparingly, for the one thing that matters in a block. Headings only when the reply genuinely has multiple sections.\n- No ASCII art, no banners, no decorative separators, no emoji unless the user uses them first.\n\n**Compress evidence, don't drop it.** Report the outcome, not the transcript: \"tests: 128/128 green\", \"build failed \u2014 `TS2322` in `api/client.ts:80`\". Paste raw output only when the user needs to read it themselves, and only the relevant lines.\n\n## How to work\n- **Understand before acting.** Restate the goal, read the relevant code, and be clear on what \"done\" looks like before changing anything.\n- **Plan first for anything non-trivial** (3+ steps or a design decision): outline the approach and the files you'll touch, and share it before implementing. Skip the ceremony for small, obvious fixes.\n- **Ground every claim in reality** \u2014 the actual code, tests, or output, never guesswork. If you are unsure, say so and verify.\n- **Ask when intent is genuinely ambiguous** \u2014 one sharp question. At a real fork, give a recommendation, not a survey of every option.\n- **Stay in scope.** Solve what was asked; no \"while I'm here\" refactors or speculative abstractions. Note unrelated issues instead of acting on them.\n- **Favor the simplest solution that fully solves the problem.** Fix root causes, not symptoms \u2014 no temporary patches and no defensive code for cases that can't happen.\n- **Verify your work and show the evidence** \u2014 run the project's tests, linters, and build, and read the output. \"It runs\" is not \"it's done.\"\n- **Match the project's existing style, structure, and conventions.** Comment only the non-obvious WHY, briefly \u2014 don't narrate the code.\n- **Stop when stuck.** If the same fix fails twice, step back and reconsider the approach rather than repeating variations.\n\n## Safety\n- **Never expose or exfiltrate** secrets, credentials, tokens, or customer data, and never print a credential's value.\n- **Treat destructive or irreversible actions as needing explicit confirmation** \u2014 force-push, history rewrite, bulk deletes, hard resets, dropping data. Don't run them unprompted.\n- **Don't push to a shared/default branch or make outward-facing changes** unless the user asked for it.\n- **Report honestly when you finish**: what you changed, what you verified, and anything you could not.";
917
879
  /** Marker-wrapped block for an idempotent append to an agent's instruction file. */
918
- declare const AGENT_STANDARD_BLOCK = "<!-- codeam:agent-standard -->\n# Working standard\n\nYou are an AI coding agent working on the user's project through CodeAgent Mobile. Follow this standard on every task.\n\n## How to work\n- **Understand before acting.** Restate the goal, read the relevant code, and be clear on what \"done\" looks like before changing anything.\n- **Plan first for anything non-trivial** (3+ steps or a design decision): outline the approach and the files you'll touch, and share it before implementing. Skip the ceremony for small, obvious fixes.\n- **Ground every claim in reality** \u2014 the actual code, tests, or output, never guesswork. If you are unsure, say so and verify.\n- **Ask when intent is genuinely ambiguous** \u2014 one sharp question. At a real fork, give a recommendation, not a survey of every option.\n- **Stay in scope.** Solve what was asked; no \"while I'm here\" refactors or speculative abstractions. Note unrelated issues instead of acting on them.\n- **Favor the simplest solution that fully solves the problem.** Fix root causes, not symptoms \u2014 no temporary patches and no defensive code for cases that can't happen.\n- **Verify your work and show the evidence** \u2014 run the project's tests, linters, and build, and read the output. \"It runs\" is not \"it's done.\"\n- **Match the project's existing style, structure, and conventions.** Comment only the non-obvious WHY, briefly \u2014 don't narrate the code.\n- **Stop when stuck.** If the same fix fails twice, step back and reconsider the approach rather than repeating variations.\n\n## Safety\n- **Never expose or exfiltrate** secrets, credentials, tokens, or customer data, and never print a credential's value.\n- **Treat destructive or irreversible actions as needing explicit confirmation** \u2014 force-push, history rewrite, bulk deletes, hard resets, dropping data. Don't run them unprompted.\n- **Don't push to a shared/default branch or make outward-facing changes** unless the user asked for it.\n- **Report honestly when you finish**: what you changed, what you verified, and anything you could not.\n<!-- codeam:agent-standard -->";
880
+ declare const AGENT_STANDARD_BLOCK = "<!-- codeam:agent-standard -->\n# Working standard\n\nYou are an AI coding agent working on the user's project through CodeAgent Mobile. Follow this standard on every task.\n\n## How to answer \u2014 you are being read on a PHONE\n\nYour reply is read on a narrow screen, often one-handed, often while the user is doing something else. Length is a cost they pay. Write accordingly.\n\n- **Lead with the answer.** First line = the result, the decision, or what changed. No preamble, no restating the request, no \"Great question!\", no narrating what you are about to do.\n- **Default to a few sentences.** Most replies fit in 1-2 short paragraphs or 3-6 tight bullets. A long reply is a deliberate choice you make because the task genuinely needs it \u2014 not the default.\n- **Say it once.** No summary of the summary, no closing paragraph that repeats the opening, no \"let me know if you need anything else\".\n- **Cut every word that carries no information** \u2014 hedges, filler adverbs, throat-clearing, and praise for the question.\n- **Expand when asked.** \"Explain in detail\", \"walk me through it\", \"why?\" are requests for depth: give it fully. Brevity is the default, not a ceiling.\n\n**Formatting for a narrow screen:**\n- Short paragraphs (1-3 sentences). Bullets over prose for anything that is a list. Never a wall of text.\n- **No wide tables** \u2014 they force horizontal scrolling and become unreadable. Use bullets, or at most two columns.\n- Code blocks only when the user needs the exact characters (a command to run, the changed lines). Show the relevant lines, not the whole file. Keep lines short so they don't wrap badly.\n- File references as `path/to/file.ts:42`, not pasted paths inside long prose.\n- Bold sparingly, for the one thing that matters in a block. Headings only when the reply genuinely has multiple sections.\n- No ASCII art, no banners, no decorative separators, no emoji unless the user uses them first.\n\n**Compress evidence, don't drop it.** Report the outcome, not the transcript: \"tests: 128/128 green\", \"build failed \u2014 `TS2322` in `api/client.ts:80`\". Paste raw output only when the user needs to read it themselves, and only the relevant lines.\n\n## How to work\n- **Understand before acting.** Restate the goal, read the relevant code, and be clear on what \"done\" looks like before changing anything.\n- **Plan first for anything non-trivial** (3+ steps or a design decision): outline the approach and the files you'll touch, and share it before implementing. Skip the ceremony for small, obvious fixes.\n- **Ground every claim in reality** \u2014 the actual code, tests, or output, never guesswork. If you are unsure, say so and verify.\n- **Ask when intent is genuinely ambiguous** \u2014 one sharp question. At a real fork, give a recommendation, not a survey of every option.\n- **Stay in scope.** Solve what was asked; no \"while I'm here\" refactors or speculative abstractions. Note unrelated issues instead of acting on them.\n- **Favor the simplest solution that fully solves the problem.** Fix root causes, not symptoms \u2014 no temporary patches and no defensive code for cases that can't happen.\n- **Verify your work and show the evidence** \u2014 run the project's tests, linters, and build, and read the output. \"It runs\" is not \"it's done.\"\n- **Match the project's existing style, structure, and conventions.** Comment only the non-obvious WHY, briefly \u2014 don't narrate the code.\n- **Stop when stuck.** If the same fix fails twice, step back and reconsider the approach rather than repeating variations.\n\n## Safety\n- **Never expose or exfiltrate** secrets, credentials, tokens, or customer data, and never print a credential's value.\n- **Treat destructive or irreversible actions as needing explicit confirmation** \u2014 force-push, history rewrite, bulk deletes, hard resets, dropping data. Don't run them unprompted.\n- **Don't push to a shared/default branch or make outward-facing changes** unless the user asked for it.\n- **Report honestly when you finish**: what you changed, what you verified, and anything you could not.\n<!-- codeam:agent-standard -->";
919
881
 
920
882
  /**
921
883
  * Native ACP guardrails — the shared policy model.
@@ -1704,148 +1666,6 @@ interface BeadsActionRequest {
1704
1666
  projectKey?: string;
1705
1667
  }
1706
1668
 
1707
- /**
1708
- * Headroom budget configuration and command types.
1709
- * Used by the CLI to enable/disable cost-saving Headroom token compression
1710
- * and track spending against configured budgets.
1711
- *
1712
- * CANONICAL WIRE OWNER: this file (`@codeam/shared`) owns the wire
1713
- * protocol, per the cross-repo rule. The backend repo keeps hand-synced
1714
- * MIRRORS (`codeagent-mobile/packages/shared/src/types/headroom.ts` for
1715
- * mobile/landing, `codeagent-mobile/apps/api-v2/src/common/types/headroom.ts`
1716
- * for the backend); a drift-check script at
1717
- * `codeagent-mobile/scripts/check-shared-drift` compares them.
1718
- */
1719
- type HeadroomBudgetPeriod = 'hourly' | 'daily' | 'monthly';
1720
- /**
1721
- * Install-progress milestone emitted on the `headroom_progress` SSE event while
1722
- * a session is provisioning Headroom on-demand. Must stay byte-for-byte aligned
1723
- * with the backend's `HEADROOM_STEPS` validator
1724
- * (`apps/api-v2/src/headroom/headroom.controller.ts`) and the mobile store —
1725
- * the backend 400s (`INVALID_STEP`) on any value outside this set. Note
1726
- * `'provisioning'` is a `HeadroomStatus['state']`, NOT a step.
1727
- */
1728
- type HeadroomStep = 'pip' | 'model' | 'init' | 'proxy' | 'ready';
1729
- /**
1730
- * Command sent via relay to enable/disable/configure Headroom budget settings.
1731
- * The `agentId` field is included because PairedSession has no agentId server-side,
1732
- * so the relay command carries it for the CLI handler to guard on.
1733
- */
1734
- interface HeadroomBudgetCommand {
1735
- budgetEnabled: boolean;
1736
- budgetUsd?: number;
1737
- budgetPeriod?: HeadroomBudgetPeriod;
1738
- agentId?: string;
1739
- }
1740
- /**
1741
- * Budget usage fields appended to the savings payload that the Headroom reporter
1742
- * sends to the backend. Tracks spending in the current budget period.
1743
- */
1744
- interface HeadroomBudgetUsage {
1745
- periodSpendUsd?: number;
1746
- budgetUsd?: number;
1747
- budgetPeriod?: HeadroomBudgetPeriod;
1748
- /** True iff this turn pushed periodSpendUsd to or past budgetUsd. */
1749
- budgetReached?: boolean;
1750
- }
1751
- /**
1752
- * Headroom cost-saving state for a session — carried on the `headroom_status`
1753
- * SSE event and snapshotted by the backend into Redis `headroom:<sessionId>`.
1754
- * Mirrored byte-for-byte in `apps/api-v2/src/common/types/headroom.ts`.
1755
- */
1756
- interface HeadroomStatus {
1757
- state: 'enabled' | 'disabled' | 'error' | 'provisioning';
1758
- running?: boolean;
1759
- agent?: string;
1760
- savings?: number;
1761
- error?: string;
1762
- }
1763
- /** One provider/model slice inside a rollup bucket. */
1764
- interface HeadroomUsageSlice {
1765
- /** Tokens Headroom removed in this bucket (a DELTA, not cumulative). */
1766
- tokens_saved: number;
1767
- compression_savings_usd_delta: number;
1768
- total_input_tokens_delta: number;
1769
- total_input_cost_usd_delta: number;
1770
- }
1771
- /**
1772
- * One rollup bucket. ⚠️ The `*_delta` fields (and `tokens_saved`) are
1773
- * PER-BUCKET; the bare `total_*` fields are the CUMULATIVE value at the
1774
- * bucket's end. Chart the deltas, show the totals as headline figures.
1775
- */
1776
- interface HeadroomUsageBucket {
1777
- /** Bucket start, UTC ISO-8601. */
1778
- timestamp: string;
1779
- tokens_saved: number;
1780
- compression_savings_usd_delta: number;
1781
- total_tokens_saved: number;
1782
- compression_savings_usd: number;
1783
- total_input_tokens_delta: number;
1784
- total_input_tokens: number;
1785
- total_input_cost_usd_delta: number;
1786
- total_input_cost_usd: number;
1787
- by_provider: Record<string, HeadroomUsageSlice>;
1788
- by_model: Record<string, HeadroomUsageSlice>;
1789
- }
1790
- type HeadroomUsageGranularity = 'hourly' | 'daily' | 'weekly' | 'monthly';
1791
- /** Lifetime / current-window totals. */
1792
- interface HeadroomUsageTotals {
1793
- requests: number;
1794
- tokens_saved: number;
1795
- compression_savings_usd: number;
1796
- total_input_tokens: number;
1797
- total_input_cost_usd: number;
1798
- }
1799
- /**
1800
- * The token-usage report the CLI relays for the `headroom_usage` command — a
1801
- * TRIMMED projection of the proxy's `GET /stats-history` (schema_version 3,
1802
- * verified live against headroom 0.27.0).
1803
- *
1804
- * ⚠️ Trimmed ON THE BOX before it ever leaves, for three reasons:
1805
- * - the raw response is ~150 KB (and `history_mode=full` is ~1.1 MB) — too
1806
- * heavy for the command relay; dropping the raw `history[]` and capping the
1807
- * hourly series brings it to ~23 KB.
1808
- * - `history[]` carries CUMULATIVE counters that would have to be diffed,
1809
- * while `series[]` already provides per-bucket deltas AND the
1810
- * `by_model` / `by_provider` breakdown (richer than Headroom's own CSV
1811
- * export, which has no model column).
1812
- * - the proxy's `storage_path` leaks a local filesystem path (including the
1813
- * OS username) and is stripped.
1814
- */
1815
- interface HeadroomUsageReport {
1816
- /** Headroom's own payload schema version (3 at time of writing). */
1817
- schemaVersion: number;
1818
- /** When the proxy generated the snapshot (UTC ISO-8601). */
1819
- generatedAt: string;
1820
- /** Proxy version that produced it, when known. */
1821
- proxyVersion?: string;
1822
- /** Durable, all-time totals across proxy restarts. */
1823
- lifetime: HeadroomUsageTotals;
1824
- /** The proxy's current display session (rolls over after inactivity). */
1825
- currentSession?: HeadroomUsageTotals & {
1826
- savings_percent?: number;
1827
- started_at?: string | null;
1828
- last_activity_at?: string | null;
1829
- };
1830
- /** Rollups. `hourly` is capped to the most recent buckets to bound size. */
1831
- series: Partial<Record<HeadroomUsageGranularity, HeadroomUsageBucket[]>>;
1832
- /** The proxy's retention policy, so the UI can state the window honestly. */
1833
- retention?: {
1834
- max_history_points?: number;
1835
- max_history_age_days?: number;
1836
- };
1837
- }
1838
- /** Result of the `headroom_usage` relay command. */
1839
- interface HeadroomUsageResult {
1840
- /** False when the proxy isn't reachable / Headroom isn't active here. */
1841
- available: boolean;
1842
- report?: HeadroomUsageReport;
1843
- /** Human-readable reason when `available` is false. */
1844
- error?: string;
1845
- }
1846
- /** Relay command type for pulling the token-usage report. */
1847
- declare const HEADROOM_USAGE_COMMAND = "headroom_usage";
1848
-
1849
1669
  /**
1850
1670
  * Session agent switch — wire types for the `switch_agent` relay command and
1851
1671
  * its progress/status SSE events.
@@ -2026,84 +1846,6 @@ interface SquadStatsResult {
2026
1846
  /** Per-agent specialty blurbs for the team preamble. Copy, not routing. */
2027
1847
  declare const SQUAD_SPECIALTIES: Readonly<Partial<Record<AgentId, string>>>;
2028
1848
 
2029
- /**
2030
- * Headroom provisioning manifest — the SINGLE source of truth for what a
2031
- * Headroom install consists of, rendered by every provisioning surface:
2032
- *
2033
- * - codespace bootstrap (bash composer in the backend repo,
2034
- * `apps/api-v2/src/codespaces/github-ssh.service.ts` — adopts in PR-2),
2035
- * - self-hosted deploy (TS installer, CLI `commands/host-agent.ts`
2036
- * `setupHeadroomForSelfHosted`),
2037
- * - on-demand local sessions ("Session add-ons → Cost-saving", CLI
2038
- * `services/headroom/configure.ts`).
2039
- *
2040
- * Values are DATA-first (arrays/records, plus tiny pure renderers) so both
2041
- * the TS installer and a bash composer can interpolate from them. Renderers
2042
- * are byte-exact with the literals they replaced — guarded by
2043
- * `packages/shared/__tests__/headroom-manifest.test.ts`.
2044
- *
2045
- * ⚠️ The extras matter: `[proxy,code]` pulls the ONNX compression engines
2046
- * (Kompress + tree-sitter CodeCompressor). NEVER add `[ml]` — that's
2047
- * multi-GB PyTorch, and a broken/cold torch wedges every prompt at
2048
- * "Thinking…". The models are pre-downloaded at provision time because the
2049
- * proxy eager-loads with `allow_download=False` and a cold cache defers the
2050
- * ~840 MB download to the first prompt (blowing the agent's ~90 s idle
2051
- * timeout).
2052
- */
2053
- /** Local proxy port the agent's config is routed to. */
2054
- declare const HEADROOM_PROXY_PORT = 8787;
2055
- /**
2056
- * Env that pins the ONNX backend on the proxy process — never imports
2057
- * torch. Spread into the proxy launch env on every surface.
2058
- */
2059
- declare const HEADROOM_BACKEND_ENV: {
2060
- readonly HEADROOM_KOMPRESS_BACKEND: "onnx_cpu";
2061
- };
2062
- /**
2063
- * The proxy's HTTP/server companion packages, installed alongside the
2064
- * `headroom-ai[...]` package. The COMPRESSION ENGINES come from the
2065
- * headroom-ai extras — NOT this list.
2066
- */
2067
- declare const HEADROOM_PIP_COMPANIONS: readonly string[];
2068
- /** The three provisioning surfaces (see module doc). */
2069
- type HeadroomSurface = 'codespace' | 'selfHosted' | 'onDemand';
2070
- /**
2071
- * pip extras per surface. `onDemand` additionally ships `image`
2072
- * (image-compression support, added with the Session add-ons path in
2073
- * codeam-cli@2.49.0); the older codespace/self-hosted install strings
2074
- * remain `[proxy,code]` byte-for-byte.
2075
- */
2076
- declare const HEADROOM_EXTRAS_BY_SURFACE: Readonly<Record<HeadroomSurface, readonly string[]>>;
2077
- /** `headroom-ai[<extras>]` — the pip requirement string. */
2078
- declare function headroomPipPackage(extras: readonly string[]): string;
2079
- /** One HuggingFace repo to pre-warm into the HF cache at provision time. */
2080
- interface HeadroomModelSpec {
2081
- repo: string;
2082
- /** `snapshot_download(..., allow_patterns=[…])` filter. */
2083
- allowPatterns: readonly string[];
2084
- }
2085
- /**
2086
- * The two HF repos Kompress needs. kompress-v2-base is the ONNX model
2087
- * (skip its .pt/.safetensors torch artifacts); ModernBERT-base is the
2088
- * TOKENIZER ONLY (skip its model weights).
2089
- */
2090
- declare const HEADROOM_MODELS: readonly HeadroomModelSpec[];
2091
- /** Formatting knob so each surface can stay byte-identical to its
2092
- * historical literal (the CLI joins patterns with `,`, the codespace
2093
- * bash composer with `, `). */
2094
- interface HeadroomPythonRenderOpts {
2095
- /** Put a space after the commas between allow_patterns entries. */
2096
- spaceAfterComma?: boolean;
2097
- }
2098
- /** Render one `snapshot_download(...)` python line for a model. */
2099
- declare function headroomSnapshotDownloadLine(model: HeadroomModelSpec, opts?: HeadroomPythonRenderOpts): string;
2100
- /**
2101
- * The full model pre-download python snippet (import + one
2102
- * `snapshot_download` per model), newline-joined — what the surfaces pass
2103
- * to `python -c` / a heredoc.
2104
- */
2105
- declare function headroomModelPredownloadScript(opts?: HeadroomPythonRenderOpts): string;
2106
-
2107
1849
  /**
2108
1850
  * Canonical names of the per-user SSE bus events (`/api/users/me/stream`).
2109
1851
  *
@@ -2148,7 +1890,6 @@ declare const USER_EVENTS: {
2148
1890
  readonly CREDENTIAL_INVALID: "credential_invalid";
2149
1891
  readonly CODESPACE_WAKING: "codespace_waking";
2150
1892
  readonly CODESPACE_BILLING_BLOCKED: "codespace_billing_blocked";
2151
- readonly COST_SAVING_UPDATED: "cost_saving_updated";
2152
1893
  readonly COMMAND_COMPLETED: "command_completed";
2153
1894
  readonly AI_SUMMARY_PENDING: "ai_summary_pending";
2154
1895
  readonly AI_SUMMARY_READY: "ai_summary_ready";
@@ -2190,10 +1931,7 @@ declare const USER_EVENTS: {
2190
1931
  * a box never creates. */
2191
1932
  readonly FLEET_BOX_READY: "fleet_box_ready";
2192
1933
  readonly REFERRAL_REWARD_EARNED: "referral_reward_earned";
2193
- readonly HEADROOM_PROGRESS: "headroom_progress";
2194
- readonly HEADROOM_STATUS: "headroom_status";
2195
1934
  readonly BEADS_STATUS: "beads_status";
2196
- readonly LINKED_AGENT_HEADROOM_BUDGET_UPDATED: "linked_agent_headroom_budget_updated";
2197
1935
  readonly CLI_UPDATE_AVAILABLE: "cli_update_available";
2198
1936
  readonly AGENT_INSTALL_PROGRESS: "agent_install_progress";
2199
1937
  readonly AGENT_INSTALL_FAILED: "agent_install_failed";
@@ -2228,6 +1966,14 @@ declare const USER_EVENTS: {
2228
1966
  * debits: those are one per agent hop, and the client already walks its
2229
1967
  * own balance down as metered usage streams in. */
2230
1968
  readonly CREDITS_CHANGED: "credits_changed";
1969
+ /** La recarga automatica NO se hizo, y el motivo significa algo para el
1970
+ * usuario (enfriamiento, tope diario o mensual, pausada, apagada).
1971
+ * ⚠️ Existe porque antes el saldo llegaba a cero EN SILENCIO: la sesion se
1972
+ * paraba y no habia una sola pista de por que no se habia recargado sola
1973
+ * (2026-09-17). Los motivos internos —`duplicate_intent` y compañia— no se
1974
+ * publican: no dicen nada a quien los lee. El CLI no lo consume; vive aqui
1975
+ * porque este fichero es la fuente del espejo que valida `shared-type-drift`. */
1976
+ readonly AUTO_RECHARGE_BLOCKED: "auto_recharge_blocked";
2231
1977
  };
2232
1978
  type UserEventName = (typeof USER_EVENTS)[keyof typeof USER_EVENTS];
2233
1979
 
@@ -2243,4 +1989,4 @@ type UserEventName = (typeof USER_EVENTS)[keyof typeof USER_EVENTS];
2243
1989
  */
2244
1990
  declare const PREVIEW_DETECT_PROMPT: string;
2245
1991
 
2246
- export { AGENT_REGISTRY, AGENT_STANDARD_BLOCK, AGENT_STANDARD_MARKER, AGENT_STANDARD_TEXT, type AgentAuth, type AgentAuthKind, type AgentId, type AgentMetadata, type AgentMode, type AgentModel, type AgentReviewFinding, type AgentReviewPlan, type AgentReviewReport, type AnswerResolvedEvent, type AwaitingAnswerEvent, type AwaitingAnswerOption, type BeadsActionCommand, type BeadsActionKind, type BeadsActionPayload, type BeadsActionRequest, type BeadsActionType, type BeadsConfigureAction, type BeadsDependencyDto, type BeadsDependencyKind, type BeadsIngestPayload, type BeadsIssueDto, type BeadsIssueStatus, type BeadsMemoryDto, type BeadsProjectDto, type BeadsProvisioningPayload, type BeadsProvisioningStatus, type BeadsSnapshotDto, type BeadsStatus, type BeadsStatusState, type BeadsStatusSummary, type BlameLineWire, type BrokeredIntegrationToken, CODER_PROMPT, type ChromeStep, type ChromeToolType, type CommitEntryWire, DEFAULT_API_BASE_URL, DEFAULT_GUARDRAIL_POLICY, DEP_TO_INTEGRATION, DEV_API_BASE_URL, type DerivedCredentialSource, type EnvVar, type FileBlameEvent, type FileChangeStatus, type FileChangedEvent, type FileHistoryEvent, type FileReviewStatus, GUARDRAIL_CATEGORIES, GUARDRAIL_CATEGORY_META, GUARDRAIL_CONFIGURE_COMMAND, GUARDRAIL_DISPOSITIONS, type GuardrailCategory, type GuardrailCategoryMeta, type GuardrailDisposition, type GuardrailPolicy, HANDOFF_FENCE_TAG, HEADROOM_BACKEND_ENV, HEADROOM_EXTRAS_BY_SURFACE, HEADROOM_MODELS, HEADROOM_PIP_COMPANIONS, HEADROOM_PROXY_PORT, HEADROOM_USAGE_COMMAND, HEARTBEAT_INTERVAL_MS_DEFAULT, HOUSE_AGENT_ID, HOUSE_AGENT_NAME, HOUSE_AGENT_PROVIDER, HOUSE_AGENT_SUBTITLE, HOUSE_AGENT_VENDOR, type HandoffProposal, type HandoffResolution, type HeadroomBudgetCommand, type HeadroomBudgetPeriod, type HeadroomBudgetUsage, type HeadroomKind, type HeadroomModelSpec, type HeadroomPythonRenderOpts, type HeadroomStatus, type HeadroomStep, type HeadroomSurface, type HeadroomUsageBucket, type HeadroomUsageGranularity, type HeadroomUsageReport, type HeadroomUsageResult, type HeadroomUsageSlice, type HeadroomUsageTotals, type HunkLineType, INSTALL_SNIPPETS, INTEGRATION_BRANDING, INTEGRATION_REGISTRY, INTERNAL_TO_PUBLIC, type InputSuggestionChunk, type IntegrationApiKeyField, type IntegrationAuthKind, type IntegrationBranding, type IntegrationCategory, type IntegrationDefinition, type IntegrationDelivery, type IntegrationHealth, type IntegrationId, type IntegrationMcpDelivery, type IntegrationStatus, type IntegrationsManifest, type IntegrationsManifestEntry, LINKED_AGENT_IDS, type LinkedAgentId, MANAGED_AGENT_ENV, MANAGED_AGENT_SUBTITLE, MANAGED_PROVIDER_DISPLAY_NAMES, MANAGED_PROVIDER_IDS, MODEL_CONTEXT_WINDOW, MODEL_PRICING, type ManagedProviderId, type MissingService, type ModelPricing, type NormalizedMessage, OBSERVER_BRIDGE_PORT, PACK_ACTION_COMMAND, PACK_REGISTRY, PACK_START_COMMAND, PACK_STATUS_COMMAND, PACK_WORKFLOW_ARTICLE, PREVIEW_DETECT_PROMPT, PROTOCOL_VERSION, PUBLIC_TO_INTERNAL, type PackActionKind, type PackActionPayload, type PackDefinition, type PackHandoffRecord, type PackId, type PackRunState, type PackRunStatus, type PackStageDef, type PackStageState, type PackStageStatus, type PackStartPayload, type PendingReviewHunkEvent, type PendingReviewHunkLine, type PrCheck, type PrRef, type PrReviewEntry, type PrReviewVerdict, type PreviewDetection, type PreviewErrorStage, type PreviewState, type PreviewStatus, type PullRequestDetail, type PullRequestSummary, QA_PROMPT, REVIEWER_PROMPT, type RemoteCommand, type RepoStack, type RepoStackDetection, SKILL_REGISTRY, SPECIFIER_PROMPT, SQUAD_CONFIGURE_COMMAND, SQUAD_HOP_BUDGET_DEFAULT, SQUAD_HOP_BUDGET_MAX, SQUAD_HOP_BUDGET_MIN, SQUAD_SPECIALTIES, SQUAD_STATS_COMMAND, SSE_SOCKET_TIMEOUT_MS, STACK_TO_RECOMMENDED, SWITCH_AGENT_COMMAND, type SelectPrompt, type SkillDefinition, type SkillDelivery, type SkillFileDelivery, type SkillId, type SkillRail, type SkillsManifest, type SkillsManifestEntry, type SquadAutoConfig, type SquadConfigurePayload, type SquadConfigureResult, type SquadMemberActivity, type SquadRosterAgent, type SquadRosterData, type SquadStatsResult, type StartTaskFailedResult, type StartTaskPayload, type StreamingChunkEvent, type StreamingChunkKind, type SwitchAgentCommand, type SwitchAgentResult, type SwitchAgentStatus, type SwitchAgentStep, TERMINAL_AGENT_PREFIX, UNKNOWN_MODEL_PRICING, UPCOMING_INTEGRATION_IDS, USER_EVENTS, type UserEventName, clampHopBudget, classifyStack, detectedIntegrationsFromDeps, getAgent, getContextWindow, getEnabledAgents, getEnabledIntegrations, getIntegration, getIntegrationBranding, getIntegrationsByCategory, getPackDefinition, getPricing, getSkillDefinition, headroomKindFor, headroomModelPredownloadScript, headroomPipPackage, headroomSnapshotDownloadLine, installableAgentIds, internalToPublic, isGuardrailDisposition, isHeadroomWrappable, isKnownAgentId, isKnownIntegrationId, isKnownModel, isLinkedAgentId, isManagedProviderId, isNoopInstallSnippet, isPackId, isSkillId, normalizeAgentId, normalizeGuardrailPolicy, publicToInternal, recommendForDeps, renderToLines, resolveApiBaseUrl, skillHasRail, toRemoteCommand, tryGetContextWindow };
1992
+ export { AGENT_REGISTRY, AGENT_STANDARD_BLOCK, AGENT_STANDARD_MARKER, AGENT_STANDARD_TEXT, type AgentAuth, type AgentAuthKind, type AgentId, type AgentMetadata, type AgentMode, type AgentModel, type AgentReviewFinding, type AgentReviewPlan, type AgentReviewReport, type AnswerResolvedEvent, type AwaitingAnswerEvent, type AwaitingAnswerOption, type BeadsActionCommand, type BeadsActionKind, type BeadsActionPayload, type BeadsActionRequest, type BeadsActionType, type BeadsConfigureAction, type BeadsDependencyDto, type BeadsDependencyKind, type BeadsIngestPayload, type BeadsIssueDto, type BeadsIssueStatus, type BeadsMemoryDto, type BeadsProjectDto, type BeadsProvisioningPayload, type BeadsProvisioningStatus, type BeadsSnapshotDto, type BeadsStatus, type BeadsStatusState, type BeadsStatusSummary, type BlameLineWire, type BrokeredIntegrationToken, CODER_PROMPT, type ChromeStep, type ChromeToolType, type CommitEntryWire, DEFAULT_API_BASE_URL, DEFAULT_GUARDRAIL_POLICY, DEP_TO_INTEGRATION, DEV_API_BASE_URL, type DerivedCredentialSource, type EnvVar, type FileBlameEvent, type FileChangeStatus, type FileChangedEvent, type FileHistoryEvent, type FileReviewStatus, GUARDRAIL_CATEGORIES, GUARDRAIL_CATEGORY_META, GUARDRAIL_CONFIGURE_COMMAND, GUARDRAIL_DISPOSITIONS, type GuardrailCategory, type GuardrailCategoryMeta, type GuardrailDisposition, type GuardrailPolicy, HANDOFF_FENCE_TAG, HEARTBEAT_INTERVAL_MS_DEFAULT, HOUSE_AGENT_ID, HOUSE_AGENT_NAME, HOUSE_AGENT_PROVIDER, HOUSE_AGENT_SUBTITLE, HOUSE_AGENT_VENDOR, type HandoffProposal, type HandoffResolution, type HunkLineType, INSTALL_SNIPPETS, INTEGRATION_BRANDING, INTEGRATION_REGISTRY, INTERNAL_TO_PUBLIC, type InputSuggestionChunk, type IntegrationApiKeyField, type IntegrationAuthKind, type IntegrationBranding, type IntegrationCategory, type IntegrationDefinition, type IntegrationDelivery, type IntegrationHealth, type IntegrationId, type IntegrationMcpDelivery, type IntegrationStatus, type IntegrationsManifest, type IntegrationsManifestEntry, LINKED_AGENT_IDS, type LinkedAgentId, MANAGED_AGENT_ENV, MANAGED_AGENT_SUBTITLE, MANAGED_PROVIDER_DISPLAY_NAMES, MANAGED_PROVIDER_IDS, MODEL_CONTEXT_WINDOW, MODEL_PRICING, type ManagedProviderId, type MissingService, type ModelPricing, type NormalizedMessage, OBSERVER_BRIDGE_PORT, PACK_ACTION_COMMAND, PACK_REGISTRY, PACK_START_COMMAND, PACK_STATUS_COMMAND, PACK_WORKFLOW_ARTICLE, PREVIEW_DETECT_PROMPT, PROTOCOL_VERSION, PUBLIC_TO_INTERNAL, type PackActionKind, type PackActionPayload, type PackDefinition, type PackHandoffRecord, type PackId, type PackRunState, type PackRunStatus, type PackStageDef, type PackStageState, type PackStageStatus, type PackStartPayload, type PendingReviewHunkEvent, type PendingReviewHunkLine, type PrCheck, type PrRef, type PrReviewEntry, type PrReviewVerdict, type PreviewDetection, type PreviewErrorStage, type PreviewState, type PreviewStatus, type PullRequestDetail, type PullRequestSummary, QA_PROMPT, REVIEWER_PROMPT, type RemoteCommand, type RepoStack, type RepoStackDetection, SKILL_REGISTRY, SPECIFIER_PROMPT, SQUAD_CONFIGURE_COMMAND, SQUAD_HOP_BUDGET_DEFAULT, SQUAD_HOP_BUDGET_MAX, SQUAD_HOP_BUDGET_MIN, SQUAD_SPECIALTIES, SQUAD_STATS_COMMAND, SSE_SOCKET_TIMEOUT_MS, STACK_TO_RECOMMENDED, SWITCH_AGENT_COMMAND, type SelectPrompt, type SkillDefinition, type SkillDelivery, type SkillFileDelivery, type SkillId, type SkillRail, type SkillsManifest, type SkillsManifestEntry, type SquadAutoConfig, type SquadConfigurePayload, type SquadConfigureResult, type SquadMemberActivity, type SquadRosterAgent, type SquadRosterData, type SquadStatsResult, type StartTaskFailedResult, type StartTaskPayload, type StreamingChunkEvent, type StreamingChunkKind, type SwitchAgentCommand, type SwitchAgentResult, type SwitchAgentStatus, type SwitchAgentStep, TERMINAL_AGENT_PREFIX, UNKNOWN_MODEL_PRICING, UPCOMING_INTEGRATION_IDS, USER_EVENTS, type UserEventName, clampHopBudget, classifyStack, detectedIntegrationsFromDeps, getAgent, getContextWindow, getEnabledAgents, getEnabledIntegrations, getIntegration, getIntegrationBranding, getIntegrationsByCategory, getPackDefinition, getPricing, getSkillDefinition, installableAgentIds, internalToPublic, isGuardrailDisposition, isKnownAgentId, isKnownIntegrationId, isKnownModel, isLinkedAgentId, isManagedProviderId, isNoopInstallSnippet, isPackId, isSkillId, normalizeAgentId, normalizeGuardrailPolicy, publicToInternal, recommendForDeps, renderToLines, resolveApiBaseUrl, skillHasRail, toRemoteCommand, tryGetContextWindow };