indusagi-coding-agent 0.2.4 → 0.2.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.
Files changed (266) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +95 -1
  3. package/dist/entry.js +1559 -1100
  4. package/dist/guardrails.js +26 -509
  5. package/dist/index.js +1581 -1155
  6. package/package.json +8 -7
  7. package/dist/types/addons/addons.test.d.ts +0 -21
  8. package/dist/types/addons/contract.d.ts +0 -640
  9. package/dist/types/addons/dispatch/event-dispatcher.d.ts +0 -140
  10. package/dist/types/addons/dispatch/index.d.ts +0 -23
  11. package/dist/types/addons/dispatch/tool-interceptor.d.ts +0 -128
  12. package/dist/types/addons/host.d.ts +0 -246
  13. package/dist/types/addons/index.d.ts +0 -51
  14. package/dist/types/addons/manifest.d.ts +0 -56
  15. package/dist/types/addons/sandbox.d.ts +0 -103
  16. package/dist/types/addons/surface.d.ts +0 -42
  17. package/dist/types/boot/auth-vault.d.ts +0 -29
  18. package/dist/types/boot/boot.d.ts +0 -26
  19. package/dist/types/boot/boot.test.d.ts +0 -15
  20. package/dist/types/boot/contract.d.ts +0 -236
  21. package/dist/types/boot/heap.d.ts +0 -31
  22. package/dist/types/boot/index.d.ts +0 -20
  23. package/dist/types/boot/invocation.d.ts +0 -40
  24. package/dist/types/boot/invocation.test.d.ts +0 -8
  25. package/dist/types/boot/runners/addon-wiring.d.ts +0 -103
  26. package/dist/types/boot/runners/addon-wiring.test.d.ts +0 -19
  27. package/dist/types/boot/runners/checkpoint.d.ts +0 -133
  28. package/dist/types/boot/runners/checkpoint.test.d.ts +0 -12
  29. package/dist/types/boot/runners/delegate-runner.d.ts +0 -109
  30. package/dist/types/boot/runners/delegate-runner.test.d.ts +0 -13
  31. package/dist/types/boot/runners/index.d.ts +0 -13
  32. package/dist/types/boot/runners/link-runner.d.ts +0 -20
  33. package/dist/types/boot/runners/memdir.d.ts +0 -103
  34. package/dist/types/boot/runners/memdir.test.d.ts +0 -12
  35. package/dist/types/boot/runners/oneshot-runner.d.ts +0 -19
  36. package/dist/types/boot/runners/read-state.d.ts +0 -82
  37. package/dist/types/boot/runners/read-state.test.d.ts +0 -10
  38. package/dist/types/boot/runners/registry.d.ts +0 -30
  39. package/dist/types/boot/runners/repl-runner.d.ts +0 -19
  40. package/dist/types/boot/runners/server-mode.d.ts +0 -71
  41. package/dist/types/boot/runners/session-persist.test.d.ts +0 -10
  42. package/dist/types/boot/runners/session.d.ts +0 -88
  43. package/dist/types/boot/runners/session.test.d.ts +0 -15
  44. package/dist/types/boot/server-token.d.ts +0 -97
  45. package/dist/types/boot/stages.d.ts +0 -92
  46. package/dist/types/boot/upgrade/apply.d.ts +0 -45
  47. package/dist/types/boot/upgrade/index.d.ts +0 -13
  48. package/dist/types/boot/upgrade/upgrades.d.ts +0 -126
  49. package/dist/types/briefing/briefing.test.d.ts +0 -15
  50. package/dist/types/briefing/compose.d.ts +0 -37
  51. package/dist/types/briefing/context-docs.d.ts +0 -38
  52. package/dist/types/briefing/context-docs.test.d.ts +0 -18
  53. package/dist/types/briefing/contract.d.ts +0 -686
  54. package/dist/types/briefing/index.d.ts +0 -29
  55. package/dist/types/briefing/macros.d.ts +0 -206
  56. package/dist/types/briefing/skills.d.ts +0 -67
  57. package/dist/types/capability-deck/bridge-ledger/index.d.ts +0 -25
  58. package/dist/types/capability-deck/bridge-ledger/key.d.ts +0 -65
  59. package/dist/types/capability-deck/bridge-ledger/ledger.d.ts +0 -129
  60. package/dist/types/capability-deck/bridge-ledger/network.d.ts +0 -115
  61. package/dist/types/capability-deck/builtin-bridge.d.ts +0 -114
  62. package/dist/types/capability-deck/capability-deck.test.d.ts +0 -18
  63. package/dist/types/capability-deck/cards/bg-process-card.d.ts +0 -99
  64. package/dist/types/capability-deck/cards/index.d.ts +0 -37
  65. package/dist/types/capability-deck/cards/memory-card.d.ts +0 -68
  66. package/dist/types/capability-deck/cards/plan-file.d.ts +0 -56
  67. package/dist/types/capability-deck/cards/plan-tools.d.ts +0 -97
  68. package/dist/types/capability-deck/cards/plan-tools.test.d.ts +0 -9
  69. package/dist/types/capability-deck/cards/saas-card.d.ts +0 -78
  70. package/dist/types/capability-deck/cards/task-card.d.ts +0 -106
  71. package/dist/types/capability-deck/cards/todo-card.d.ts +0 -78
  72. package/dist/types/capability-deck/cards/workflow-card.d.ts +0 -55
  73. package/dist/types/capability-deck/cards/workflow-card.test.d.ts +0 -12
  74. package/dist/types/capability-deck/checkpoint.int.test.d.ts +0 -25
  75. package/dist/types/capability-deck/contract.d.ts +0 -318
  76. package/dist/types/capability-deck/index.d.ts +0 -46
  77. package/dist/types/capability-deck/manifest.d.ts +0 -60
  78. package/dist/types/capability-deck/provision.d.ts +0 -76
  79. package/dist/types/capability-deck/read-edit-gate.int.test.d.ts +0 -21
  80. package/dist/types/channels/channels.test.d.ts +0 -15
  81. package/dist/types/channels/contract.d.ts +0 -489
  82. package/dist/types/channels/framer.d.ts +0 -49
  83. package/dist/types/channels/index.d.ts +0 -24
  84. package/dist/types/channels/link/dialog.d.ts +0 -138
  85. package/dist/types/channels/link/driver.d.ts +0 -81
  86. package/dist/types/channels/link/index.d.ts +0 -13
  87. package/dist/types/channels/link/server.d.ts +0 -70
  88. package/dist/types/channels/oneshot.d.ts +0 -37
  89. package/dist/types/channels/ops.d.ts +0 -89
  90. package/dist/types/channels/session-ops.d.ts +0 -80
  91. package/dist/types/conductor/bash-guard.d.ts +0 -106
  92. package/dist/types/conductor/bash-guard.test.d.ts +0 -17
  93. package/dist/types/conductor/catalog/catalog.d.ts +0 -87
  94. package/dist/types/conductor/catalog/index.d.ts +0 -14
  95. package/dist/types/conductor/catalog/matcher.d.ts +0 -47
  96. package/dist/types/conductor/conductor.d.ts +0 -213
  97. package/dist/types/conductor/conductor.test.d.ts +0 -10
  98. package/dist/types/conductor/contract.d.ts +0 -838
  99. package/dist/types/conductor/diagnostics.d.ts +0 -183
  100. package/dist/types/conductor/diagnostics.test.d.ts +0 -10
  101. package/dist/types/conductor/index.d.ts +0 -26
  102. package/dist/types/conductor/permission-gate.integration.test.d.ts +0 -22
  103. package/dist/types/conductor/permission-wiring.test.d.ts +0 -14
  104. package/dist/types/conductor/permissions.d.ts +0 -287
  105. package/dist/types/conductor/permissions.test.d.ts +0 -12
  106. package/dist/types/conductor/plan-mode.integration.test.d.ts +0 -23
  107. package/dist/types/conductor/post-edit-diagnostics.test.d.ts +0 -18
  108. package/dist/types/conductor/quota-error.d.ts +0 -35
  109. package/dist/types/conductor/signal-hub/hub.d.ts +0 -83
  110. package/dist/types/conductor/signal-hub/index.d.ts +0 -19
  111. package/dist/types/conductor/signal-hub/translate.d.ts +0 -77
  112. package/dist/types/conductor/skill-parse/index.d.ts +0 -10
  113. package/dist/types/conductor/skill-parse/parse.d.ts +0 -67
  114. package/dist/types/conductor/submit.test.d.ts +0 -28
  115. package/dist/types/conductor/transcript-store/index.d.ts +0 -16
  116. package/dist/types/conductor/transcript-store/serialize.d.ts +0 -106
  117. package/dist/types/conductor/transcript-store/serialize.test.d.ts +0 -10
  118. package/dist/types/conductor/transcript-store/store.d.ts +0 -188
  119. package/dist/types/console/auth-status.d.ts +0 -28
  120. package/dist/types/console/components/AgentsView.d.ts +0 -41
  121. package/dist/types/console/components/BackgroundAgents.d.ts +0 -63
  122. package/dist/types/console/components/BackgroundAgents.test.d.ts +0 -8
  123. package/dist/types/console/components/Banner.d.ts +0 -110
  124. package/dist/types/console/components/Composer.d.ts +0 -37
  125. package/dist/types/console/components/StatusBar.d.ts +0 -42
  126. package/dist/types/console/components/TerminalConsole.d.ts +0 -27
  127. package/dist/types/console/components/WorkingIndicator.d.ts +0 -44
  128. package/dist/types/console/components/WorkingIndicator.test.d.ts +0 -9
  129. package/dist/types/console/components/banner-sweep.d.ts +0 -55
  130. package/dist/types/console/components/banner.test.d.ts +0 -9
  131. package/dist/types/console/components/welcome.d.ts +0 -115
  132. package/dist/types/console/components/welcome.test.d.ts +0 -9
  133. package/dist/types/console/console.test.d.ts +0 -19
  134. package/dist/types/console/contract.d.ts +0 -611
  135. package/dist/types/console/index.d.ts +0 -34
  136. package/dist/types/console/input/complete.d.ts +0 -120
  137. package/dist/types/console/input/dir-reader.d.ts +0 -28
  138. package/dist/types/console/input/index.d.ts +0 -24
  139. package/dist/types/console/input/input.test.d.ts +0 -14
  140. package/dist/types/console/input/keymap.d.ts +0 -193
  141. package/dist/types/console/input/paste.d.ts +0 -183
  142. package/dist/types/console/mount.d.ts +0 -53
  143. package/dist/types/console/overlays/approval-queue.d.ts +0 -88
  144. package/dist/types/console/overlays/approval.d.ts +0 -104
  145. package/dist/types/console/overlays/approval.test.d.ts +0 -17
  146. package/dist/types/console/overlays/auth.d.ts +0 -31
  147. package/dist/types/console/overlays/boards.d.ts +0 -55
  148. package/dist/types/console/overlays/host.d.ts +0 -45
  149. package/dist/types/console/overlays/index.d.ts +0 -15
  150. package/dist/types/console/overlays/pickers.d.ts +0 -37
  151. package/dist/types/console/overlays/sessions.d.ts +0 -29
  152. package/dist/types/console/reducer.d.ts +0 -51
  153. package/dist/types/console/slash/builtins.d.ts +0 -33
  154. package/dist/types/console/slash/commands/dynamic.d.ts +0 -57
  155. package/dist/types/console/slash/commands/dynamic.test.d.ts +0 -9
  156. package/dist/types/console/slash/commands/integrations.d.ts +0 -28
  157. package/dist/types/console/slash/commands/integrations.test.d.ts +0 -18
  158. package/dist/types/console/slash/commands/shared.d.ts +0 -72
  159. package/dist/types/console/slash/commands/transcript.d.ts +0 -24
  160. package/dist/types/console/slash/commands/transcript.test.d.ts +0 -10
  161. package/dist/types/console/slash/commands/workbench.d.ts +0 -21
  162. package/dist/types/console/slash/commands/workbench.test.d.ts +0 -10
  163. package/dist/types/console/slash/index.d.ts +0 -34
  164. package/dist/types/console/slash/registry.d.ts +0 -90
  165. package/dist/types/console/slash/resolve.d.ts +0 -109
  166. package/dist/types/console/slash/slash.test.d.ts +0 -18
  167. package/dist/types/console/startup.d.ts +0 -119
  168. package/dist/types/console/theme/adapter.d.ts +0 -79
  169. package/dist/types/console/theme/index.d.ts +0 -18
  170. package/dist/types/console/theme/palette.d.ts +0 -77
  171. package/dist/types/console/theme/resolve.d.ts +0 -45
  172. package/dist/types/console/theme/theme.test.d.ts +0 -16
  173. package/dist/types/console/theme/tokens.d.ts +0 -62
  174. package/dist/types/entry.d.ts +0 -17
  175. package/dist/types/guardrails.d.ts +0 -33
  176. package/dist/types/index.d.ts +0 -24
  177. package/dist/types/insight/channel.d.ts +0 -45
  178. package/dist/types/insight/contract.d.ts +0 -411
  179. package/dist/types/insight/index.d.ts +0 -26
  180. package/dist/types/insight/insight.test.d.ts +0 -17
  181. package/dist/types/insight/recorder.d.ts +0 -63
  182. package/dist/types/insight/redaction.d.ts +0 -44
  183. package/dist/types/insight/replay.d.ts +0 -77
  184. package/dist/types/insight/sampling.d.ts +0 -84
  185. package/dist/types/insight/serialize.d.ts +0 -54
  186. package/dist/types/insight/sinks/console.d.ts +0 -36
  187. package/dist/types/insight/sinks/file.d.ts +0 -37
  188. package/dist/types/insight/sinks/index.d.ts +0 -16
  189. package/dist/types/insight/sinks/stream.d.ts +0 -53
  190. package/dist/types/kit/clipboard-image.d.ts +0 -40
  191. package/dist/types/kit/external-editor.d.ts +0 -35
  192. package/dist/types/kit/image.d.ts +0 -102
  193. package/dist/types/kit/index.d.ts +0 -29
  194. package/dist/types/kit/kit.test.d.ts +0 -13
  195. package/dist/types/kit/shell.d.ts +0 -50
  196. package/dist/types/kit/tool-fetch.d.ts +0 -165
  197. package/dist/types/launch/catalog.d.ts +0 -51
  198. package/dist/types/launch/contract.d.ts +0 -387
  199. package/dist/types/launch/credentials.d.ts +0 -112
  200. package/dist/types/launch/index.d.ts +0 -28
  201. package/dist/types/launch/invocation/attachments.d.ts +0 -72
  202. package/dist/types/launch/invocation/flags.d.ts +0 -59
  203. package/dist/types/launch/invocation/index.d.ts +0 -23
  204. package/dist/types/launch/invocation/read.d.ts +0 -52
  205. package/dist/types/launch/invocation/usage.d.ts +0 -25
  206. package/dist/types/launch/launch.test.d.ts +0 -20
  207. package/dist/types/launch/login.d.ts +0 -68
  208. package/dist/types/launch/oauth.d.ts +0 -101
  209. package/dist/types/launch/oauth.test.d.ts +0 -20
  210. package/dist/types/launch/packages.d.ts +0 -75
  211. package/dist/types/launch/packages.test.d.ts +0 -15
  212. package/dist/types/launch/pickers.d.ts +0 -97
  213. package/dist/types/runtime-bridge/bridges/_drive.d.ts +0 -74
  214. package/dist/types/runtime-bridge/bridges/builtins.d.ts +0 -77
  215. package/dist/types/runtime-bridge/bridges/claude-cli.d.ts +0 -37
  216. package/dist/types/runtime-bridge/bridges/codex-cli.d.ts +0 -27
  217. package/dist/types/runtime-bridge/bridges/index.d.ts +0 -15
  218. package/dist/types/runtime-bridge/bridges/indusagi-cli.d.ts +0 -36
  219. package/dist/types/runtime-bridge/broker.d.ts +0 -182
  220. package/dist/types/runtime-bridge/contract.d.ts +0 -436
  221. package/dist/types/runtime-bridge/index.d.ts +0 -21
  222. package/dist/types/runtime-bridge/runtime-bridge.test.d.ts +0 -17
  223. package/dist/types/runtime-bridge/sink.d.ts +0 -59
  224. package/dist/types/sessions/contract.d.ts +0 -79
  225. package/dist/types/sessions/index.d.ts +0 -11
  226. package/dist/types/sessions/library.d.ts +0 -95
  227. package/dist/types/sessions/sessions.test.d.ts +0 -11
  228. package/dist/types/settings/contract.d.ts +0 -175
  229. package/dist/types/settings/index.d.ts +0 -13
  230. package/dist/types/settings/manager.d.ts +0 -109
  231. package/dist/types/settings/settings.test.d.ts +0 -16
  232. package/dist/types/transcript-export/index.d.ts +0 -20
  233. package/dist/types/transcript-export/publish.d.ts +0 -81
  234. package/dist/types/transcript-export/sgr.d.ts +0 -90
  235. package/dist/types/transcript-export/template.d.ts +0 -64
  236. package/dist/types/transcript-export/theme-bridge.d.ts +0 -99
  237. package/dist/types/transcript-export/transcript-export.test.d.ts +0 -16
  238. package/dist/types/window-budget/budget/estimate.d.ts +0 -47
  239. package/dist/types/window-budget/budget/gate.d.ts +0 -37
  240. package/dist/types/window-budget/budget/index.d.ts +0 -14
  241. package/dist/types/window-budget/budget/slice.d.ts +0 -38
  242. package/dist/types/window-budget/condenser.d.ts +0 -73
  243. package/dist/types/window-budget/contract.d.ts +0 -182
  244. package/dist/types/window-budget/index.d.ts +0 -17
  245. package/dist/types/window-budget/microcompact.d.ts +0 -68
  246. package/dist/types/window-budget/microcompact.test.d.ts +0 -16
  247. package/dist/types/window-budget/rehydrate.d.ts +0 -56
  248. package/dist/types/window-budget/summarize/condense.d.ts +0 -76
  249. package/dist/types/window-budget/summarize/index.d.ts +0 -12
  250. package/dist/types/window-budget/summarize/prompt.d.ts +0 -56
  251. package/dist/types/window-budget/window-budget.test.d.ts +0 -18
  252. package/dist/types/workflow-engine/agent-runner.d.ts +0 -124
  253. package/dist/types/workflow-engine/agent-runner.test.d.ts +0 -8
  254. package/dist/types/workflow-engine/display.d.ts +0 -148
  255. package/dist/types/workflow-engine/display.test.d.ts +0 -1
  256. package/dist/types/workflow-engine/engine.d.ts +0 -183
  257. package/dist/types/workflow-engine/engine.test.d.ts +0 -1
  258. package/dist/types/workflow-engine/index.d.ts +0 -21
  259. package/dist/types/workflow-engine/parse.d.ts +0 -64
  260. package/dist/types/workflow-engine/parse.test.d.ts +0 -1
  261. package/dist/types/workflow-engine/structured-output.d.ts +0 -51
  262. package/dist/types/workflow-engine/structured-output.test.d.ts +0 -1
  263. package/dist/types/workspace/brand.d.ts +0 -26
  264. package/dist/types/workspace/index.d.ts +0 -11
  265. package/dist/types/workspace/locator.d.ts +0 -50
  266. package/dist/types/workspace/runtime-detect.d.ts +0 -56
@@ -1,71 +0,0 @@
1
- /**
2
- * Boot helper: decide whether a provider runs in **server mode** (Case B).
3
- *
4
- * A model turn takes one of three paths (see LOGIN_GATEWAY_PLAN.md §1):
5
- * - **A. Local key** — a usable key for the provider is stored in the on-disk
6
- * auth vault (or exported in the environment). The framework calls the
7
- * provider directly; behaviour is unchanged and this module returns
8
- * `{ serverMode: false }`.
9
- * - **B. Server tier** — the provider is gateway-eligible, the user has **no**
10
- * usable local key, and they hold a **valid server token**. The session token
11
- * is vended as the provider "key" and the model is re-routed through the indus
12
- * gateway. This module returns `{ serverMode: true, token }`.
13
- * - **C. Blocked** — no local key and no valid token: `{ serverMode: false }`
14
- * (the resolver then falls through to the framework's own env lookup, which
15
- * surfaces the usual "no API key" guidance pointing at `indus login`).
16
- *
17
- * The two consumers in {@link file://./session.ts} call this with the SAME
18
- * `(ctx, provider, vault)` triple so the key-resolver fallback and the
19
- * gateway-base-url computation always agree on whether server mode is active.
20
- */
21
- import type { BootContext } from "../contract";
22
- import type { AuthVault } from "../../launch/contract";
23
- /**
24
- * The outcome of {@link resolveServerMode}: whether the provider should route
25
- * through the gateway this run, and (when so) the session token to hand back as
26
- * the provider api key.
27
- */
28
- export interface ServerModeResult {
29
- /** `true` => bind the gateway base url and use {@link token} as the key. */
30
- serverMode: boolean;
31
- /** The session token (`access_token`) to vend as the key, when `serverMode`. */
32
- token?: string;
33
- }
34
- /**
35
- * Whether `provider` may be routed through the indus gateway. Excludes the
36
- * non-portable providers (vertex / bedrock / codex) and the deferred opencode
37
- * `anthropic-messages` api per the §B.4 caveat.
38
- */
39
- export declare function isGatewayEligibleProvider(provider: string): boolean;
40
- /** The server-tier provider slugs (for default-model selection / listing). */
41
- export declare function serverTierProviders(): readonly string[];
42
- /**
43
- * Decide whether `provider` runs in server mode for this session.
44
- *
45
- * Server mode is active when ALL hold:
46
- * 1. {@link isGatewayEligibleProvider}(provider) — excludes vertex/bedrock/codex
47
- * and the deferred opencode `anthropic-messages` api (§B.4);
48
- * 2. no EXPLICIT local key — the vault holds no usable key for the provider
49
- * (an ambient env var is intentionally ignored for server-tier providers);
50
- * 3. {@link hasValidServerToken}() — a stored, non-expired server token exists.
51
- *
52
- * Returns `{ serverMode: false }` whenever any condition fails, so the
53
- * local-key (Case A) path is preserved byte-for-byte: the resolver then returns
54
- * `undefined` and no gateway base url is bound.
55
- *
56
- * @param _ctx the boot context (reserved for future per-run policy; the vault is
57
- * passed explicitly so callers share one instance)
58
- * @param provider the framework provider slug to evaluate
59
- * @param vault the on-disk credential vault to probe for a local key
60
- */
61
- export declare function resolveServerMode(_ctx: BootContext, provider: string, vault: AuthVault): Promise<ServerModeResult>;
62
- /**
63
- * Build the per-provider gateway base-url map for THIS session: for every
64
- * gateway-eligible provider currently in server mode (no explicit local key +
65
- * valid token), map `provider -> ${INDUS_SERVER_URL}/gateway/${provider}`.
66
- *
67
- * The conductor consults this map at EVERY model bind — including a runtime
68
- * `/model` switch — so selecting ANY server-tier model (not just the one the
69
- * session launched on) routes through the gateway. Empty when nothing qualifies.
70
- */
71
- export declare function resolveServerGatewayUrls(ctx: BootContext, vault: AuthVault): Promise<Record<string, string>>;
@@ -1,10 +0,0 @@
1
- /**
2
- * Integration test for session persistence + resume.
3
- *
4
- * Proves the loop that `-r` / `-c` depend on: a conductor built with a
5
- * `sessionsDir` writes the transcript to a cwd-scoped `.ndjson` on disk, the
6
- * {@link SessionLibrary} (what the resume flags read) finds it, and a fresh
7
- * conductor can `resume` it by id. Before this wiring the conductor defaulted to
8
- * an in-memory store, so nothing was ever saved and resume found nothing.
9
- */
10
- export {};
@@ -1,88 +0,0 @@
1
- /**
2
- * Boot helper: assemble a {@link SessionConductor} for a non-interactive runner.
3
- *
4
- * Both the oneshot and the link runners drive a live conductor; this module owns
5
- * the one place that turns a {@link BootContext} into one, so the two runners do
6
- * not each re-derive the model id and session options. The model is taken from
7
- * the invocation when supplied, else resolved to the catalog default through the
8
- * {@link ModelMatcher}; the conductor itself is built lazily so no framework agent
9
- * is constructed until the first turn runs.
10
- */
11
- import { type AgentTool, type ApprovalResolver, type CanUseToolFn, type PermissionMode, type PermissionRule, type SessionConductor } from "../../conductor";
12
- import { type MemoryStore } from "../../capability-deck";
13
- import { type DelegateRunner } from "../../capability-deck/cards/task-card";
14
- import type { WorkflowAgentRunner } from "../../workflow-engine";
15
- import { type CheckpointStore } from "./checkpoint";
16
- import { type ContextDoc, type SkillCard } from "../../briefing";
17
- import type { BootContext, Invocation } from "../contract";
18
- /**
19
- * Resolve the model id for this run.
20
- *
21
- * Precedence: an explicit `--model` selector wins; otherwise a current model of a
22
- * provider the user has authenticated for (so a fresh launch lands on a model the
23
- * stored key can actually call); otherwise the catalog default.
24
- *
25
- * @param ctx the boot context carrying the parsed invocation
26
- * @returns the canonical model id to bind the session to
27
- */
28
- export declare function resolveModelId(ctx: BootContext): string;
29
- /**
30
- * Gather the on-disk skill cards the model may invoke this run: walk the project
31
- * and user `.indusagi/skills` roots and drop any card flagged
32
- * `disable-model-invocation` (those stay loadable explicitly, but the model is
33
- * not told about them). A filesystem walk error degrades to an empty list so a
34
- * bad/unreadable skills dir never sinks the session.
35
- */
36
- export declare function gatherModelSkills(cwd: string): SkillCard[];
37
- export declare function selectTools(cwd: string, inv: Invocation, runner?: DelegateRunner, memoryStore?: MemoryStore, checkpoint?: CheckpointStore, workflowRunner?: WorkflowAgentRunner): AgentTool[];
38
- /**
39
- * Compose the run's system prompt: `--system` replaces the built-in briefing,
40
- * `--append-system` adds a trailing block, and both compose (override then
41
- * append). With neither, it is the tool-aware built-in briefing.
42
- */
43
- export declare function composeSystem(tools: AgentTool[], inv: Invocation, cwd: string, skills?: readonly SkillCard[], memoryDoc?: ContextDoc): string;
44
- /**
45
- * The cwd-scoped session directory under the workspace `sessions/` root.
46
- *
47
- * Sessions are partitioned per working directory (so `--continue` means "the most
48
- * recent session in THIS directory"). The cwd is slugged — every non-alphanumeric
49
- * run collapsed to a single dash — and wrapped in `--…--` markers, matching the
50
- * on-disk layout. Both the conductor (writer) and {@link SessionLibrary} (reader)
51
- * must agree on this, so it lives here and is shared by the repl runner.
52
- *
53
- * @param sessionsRoot the workspace `sessions/` directory
54
- * @param cwd the run's working directory
55
- */
56
- export declare function sessionScopeDir(sessionsRoot: string, cwd: string): string;
57
- /**
58
- * Build the `canUseTool` gate factory for a boot run.
59
- *
60
- * The factory receives a getter onto the conductor's LIVE permission mode plus the
61
- * conductor's stable approval delegate, and returns the gate that reads them. The
62
- * delegate is threaded straight into `requestApproval`: on a NON-interactive boot
63
- * (oneshot / link) no resolver is ever installed, so the delegate denies and an
64
- * `ask` decision deterministically denies with an actionable message. The
65
- * interactive (React) console installs its overlay resolver via the conductor's
66
- * `setApprovalResolver` AFTER mount, at which point the SAME delegate begins
67
- * routing `ask` decisions to the overlay — no rebuild, fully additive.
68
- *
69
- * `rules` is the session's LIVE mutable rule list: the gate re-scans it on every
70
- * call, and an `allow-always` approval appends into it (via `appendAllowRule`
71
- * below), so the approval is remembered for the remainder of the session — and
72
- * ONLY the session; nothing is ever written back to settings. Every gate the
73
- * factory mints (and every sub-agent gate built over the same array) sees the
74
- * appended rules immediately.
75
- *
76
- * Exported for the boot tests; product callers go through
77
- * {@link buildSessionConductor}.
78
- */
79
- export declare function buildPermissionGate(rules: PermissionRule[], mode: PermissionMode, tools: readonly AgentTool[], planReachable?: boolean): ((currentMode: () => PermissionMode, requestApproval?: ApprovalResolver) => CanUseToolFn) | undefined;
80
- export declare function buildSessionConductor(ctx: BootContext): Promise<SessionConductor>;
81
- /**
82
- * The prompts a oneshot run submits: the positional first prompt when present,
83
- * plus any pass-through tokens that survived flag parsing. Empty when the
84
- * invocation carried no request text (the caller decides what to do then).
85
- *
86
- * @param ctx the boot context carrying the parsed invocation
87
- */
88
- export declare function oneshotPrompts(ctx: BootContext): string[];
@@ -1,15 +0,0 @@
1
- /**
2
- * Skills-surface wiring (#7 / fixes #11) + the boot permission-gate factory.
3
- *
4
- * Proves the chain that makes on-disk `SKILL.md` cards visible to the model:
5
- * `gatherModelSkills` walks `cwd/.indusagi/skills`, drops any card flagged
6
- * `disable-model-invocation`, and the survivors render into the briefing's
7
- * `<available_skills>` block via `composeSystem`. A `--system` override must NOT
8
- * carry the skills block (it replaces the whole prompt).
9
- *
10
- * `buildPermissionGate` is pinned here too: default mode ALWAYS builds a gate
11
- * (only a rule-less bypass boot with plan unreachable goes gate-free), and the
12
- * factory wires `appendAllowRule` into the live rule list so an `allow-always`
13
- * approval is remembered for the remainder of the session (B2).
14
- */
15
- export {};
@@ -1,97 +0,0 @@
1
- /**
2
- * Server-token store — the boot-layer persistence for the indus device-login
3
- * session token. This is the app side of the login + model-gateway contract: a
4
- * successful `indus login` device flow writes the better-auth session token
5
- * here, and the key resolver later reads it back to drive "server mode" (Case B
6
- * — no local provider key, but a valid server session, so requests are routed
7
- * through the indus-server gateway with the session token as the api key).
8
- *
9
- * The token lives in a single JSON file under the app's profile directory
10
- * (`~/.indusagi/agent/server-token.json`) — deliberately NOT the framework's
11
- * `~/.better-auth` location, so the CLI session is isolated from any other
12
- * tooling. As with the credential vault, the file is tiny and access is
13
- * interactive, so we read / write the whole file each time and tolerate a
14
- * missing or malformed file as "no token".
15
- *
16
- * Ported from supercli `server/src/lib/token.ts`; the load-bearing detail is the
17
- * `expires_in` (seconds, from the device-flow response) → `expires_at` (absolute
18
- * ISO timestamp, on disk) conversion, which lets {@link isServerTokenExpired}
19
- * decide freshness without re-deriving the clock offset.
20
- */
21
- /**
22
- * Root of the indus-server. Used to build the gateway base URL and the
23
- * device-login endpoints. Any trailing slash(es) are stripped so callers can
24
- * append paths with a single separator.
25
- */
26
- export declare const INDUS_SERVER_URL: string;
27
- /** The app profile directory that holds the server session token. */
28
- export declare const CONFIG_DIR: string;
29
- /** Absolute path of the JSON file the session token is persisted to. */
30
- export declare const TOKEN_FILE: string;
31
- /** On-disk token shape (what {@link storeServerToken} writes / {@link getServerToken} returns). */
32
- export interface TokenData {
33
- /** The better-auth session token, used as the gateway api key in server mode. */
34
- access_token: string;
35
- /** Optional refresh token, when the device flow returns one. */
36
- refresh_token?: string;
37
- /** Token scheme; defaults to `"Bearer"`. */
38
- token_type: string;
39
- /** Optional granted scope string. */
40
- scope?: string;
41
- /** Absolute expiry as an ISO string, or null when the token has no expiry. */
42
- expires_at: string | null;
43
- /** When this record was written, as an ISO string. */
44
- created_at: string;
45
- }
46
- /** Device-flow response shape accepted by {@link storeServerToken} (`expires_in` → `expires_at`). */
47
- export interface ServerTokenInput {
48
- /** The better-auth session token. */
49
- access_token: string;
50
- /** Optional refresh token. */
51
- refresh_token?: string;
52
- /** Token scheme; defaults to `"Bearer"` when omitted. */
53
- token_type?: string;
54
- /** Optional granted scope string. */
55
- scope?: string;
56
- /** Lifetime in seconds, relative to now; converted to an absolute `expires_at`. */
57
- expires_in?: number;
58
- }
59
- /**
60
- * Read the stored session token, tolerating a missing or malformed file as
61
- * "no token".
62
- *
63
- * @returns the parsed {@link TokenData}, or `null` when nothing is stored.
64
- */
65
- export declare function getServerToken(): Promise<TokenData | null>;
66
- /**
67
- * Persist a session token from a device-flow response, converting the relative
68
- * `expires_in` (seconds) into an absolute `expires_at` ISO timestamp and
69
- * defaulting `token_type` to `"Bearer"`. Creates the profile directory if
70
- * needed and writes the file with owner-only permissions.
71
- *
72
- * @param token the device-flow token payload.
73
- * @returns `true` on success, `false` if the write failed.
74
- */
75
- export declare function storeServerToken(token: ServerTokenInput): Promise<boolean>;
76
- /**
77
- * Remove the stored session token (used by `indus logout`). A missing file is
78
- * treated as nothing-to-do.
79
- *
80
- * @returns `true` when a file was deleted, `false` when none existed / removal failed.
81
- */
82
- export declare function clearServerToken(): Promise<boolean>;
83
- /**
84
- * Decide whether a token is expired. A token counts as expired when it is
85
- * absent, has no `expires_at`, or has under 5 minutes of life remaining (the
86
- * margin keeps a long turn from racing the expiry boundary).
87
- *
88
- * @param token the token to inspect (or `null`).
89
- * @returns `true` when the token is missing or stale.
90
- */
91
- export declare function isServerTokenExpired(token: TokenData | null): boolean;
92
- /**
93
- * Convenience predicate: there is a stored token and it is not expired.
94
- *
95
- * @returns `true` when a usable (fresh) session token is on disk.
96
- */
97
- export declare function hasValidServerToken(): Promise<boolean>;
@@ -1,92 +0,0 @@
1
- /**
2
- * Boot stage pipeline — the ordered list of {@link Stage} transforms that turn a
3
- * bare {@link BootContext} (argv + workspace + brand) into a fully-resolved one
4
- * (parsed invocation, materialised directories, applied upgrades, resolved
5
- * startup resources, selected runner).
6
- *
7
- * The pipeline is data, not control flow: {@link STAGES} lists each step in order,
8
- * and {@link runStages} folds an *immutable* context through them — every stage
9
- * receives a context and returns its successor (built by spreading, never by
10
- * mutating). A stage may be async; the fold awaits each in turn so ordering and
11
- * side-effect sequencing are deterministic.
12
- *
13
- * Stage order and intent:
14
- * 1. `locate-workspace` — materialise the resolved {@link Workspace} on disk
15
- * (`createWorkspace` + `ensureDirs`). Pure path computation already happened
16
- * when the initial context was built; this stage only `mkdir`s.
17
- * 2. `apply-upgrades` — fold the idempotent {@link applyUpgrades} registry
18
- * over the workspace (a no-op on an already-current profile).
19
- * 3. `build-invocation` — parse `argv` into the typed {@link Invocation}.
20
- * 4. `resolve-resources` — best-effort construct the framework
21
- * settings/auth/model graph; degrade to a minimal object if the framework
22
- * pieces are unavailable.
23
- * 5. `select-runner` — no-op transform that exists for symmetry and tracing
24
- * (the actual dispatch happens in {@link "./boot"} after the pipeline, so the
25
- * selected runner can own the exit code). Kept in the list so the ordered
26
- * pipeline reads as the full launch sequence.
27
- */
28
- import type { BootContext, Stage } from "./contract";
29
- /**
30
- * Materialise the resolved workspace directories on disk.
31
- *
32
- * The {@link BootContext.workspace} was already computed (pure) when the initial
33
- * context was assembled; this stage only ensures the directory subset exists so
34
- * later stages and runners can write into it. Returns the same context (the
35
- * workspace record is unchanged — only the filesystem side-effects happen here).
36
- */
37
- declare const locateWorkspace: Stage;
38
- /**
39
- * Run any pending one-time profile upgrades, idempotently.
40
- *
41
- * Folds the upgrade registry over the workspace. The driver is non-fatal: a step
42
- * that fails is reported and retried on a later launch, never aborting boot. The
43
- * context is returned unchanged (upgrades touch the filesystem, not the context).
44
- */
45
- declare const upgrade: Stage;
46
- /**
47
- * Parse `argv` into the typed {@link Invocation} and thread it onto the context.
48
- *
49
- * The initial context carries a placeholder invocation (the bootstrapper cannot
50
- * know the mode before parsing); this stage replaces it with the real parse.
51
- */
52
- declare const buildInvocation: Stage;
53
- /**
54
- * Best-effort assembly of the startup resource graph.
55
- *
56
- * Where the rebuilt framework owns a concept, the field is constructed from it:
57
- * {@link StartupResources.settings} from the framework's `DEFAULT_SETTINGS`, and
58
- * {@link StartupResources.models} from the framework's `ModelRegistry`. The
59
- * credential graph has no framework type yet, so it is an empty placeholder until
60
- * Phase 2. If a framework piece cannot be loaded, the stage degrades to a minimal
61
- * resources object built from empty literals rather than failing the boot — the
62
- * shape is what later phases depend on, and they fill it in.
63
- */
64
- declare const resolveResources: Stage;
65
- /**
66
- * Marker / tracing stage for runner selection.
67
- *
68
- * The real dispatch is performed by {@link "./boot"} after the pipeline so the
69
- * chosen runner can own the process exit code; this stage exists to keep the
70
- * ordered pipeline a faithful description of the launch sequence and to give the
71
- * selection step a name for tracing. It returns the context unchanged.
72
- */
73
- declare const selectRunnerStage: Stage;
74
- /**
75
- * The launch pipeline, in execution order. Folded by {@link runStages}.
76
- */
77
- export declare const STAGES: readonly Stage[];
78
- /**
79
- * Fold an ordered list of {@link Stage} transforms over an immutable
80
- * {@link BootContext}.
81
- *
82
- * Each stage receives the current context and returns its successor; the result
83
- * of one stage is the input to the next. Awaits every stage so async ordering is
84
- * deterministic. The input `initial` is never mutated — stages produce new
85
- * contexts by spreading.
86
- *
87
- * @param initial The seed context (argv + workspace + brand + placeholder fields).
88
- * @param stages The ordered transforms to apply; defaults to {@link STAGES}.
89
- * @returns The fully-resolved context after every stage has run.
90
- */
91
- export declare function runStages(initial: BootContext, stages?: readonly Stage[]): Promise<BootContext>;
92
- export { locateWorkspace, upgrade, buildInvocation, resolveResources, selectRunnerStage, };
@@ -1,45 +0,0 @@
1
- /**
2
- * Upgrade driver — folds the ordered {@link UPGRADES} registry over a
3
- * {@link Workspace}, exactly once per step.
4
- *
5
- * The driver is the only place that knows about the *marker file*: a small JSON
6
- * record under the profile directory listing the ids of upgrades that have
7
- * already run. Each registry step is skipped if its id is present in the marker;
8
- * otherwise it is applied and, on success, its id is appended and the marker is
9
- * persisted. A step that throws is *not* recorded (so it is retried next launch)
10
- * and is reported as a warning rather than aborting the remaining steps — one
11
- * bad migration must never wedge startup.
12
- *
13
- * The result is purely informational: {@link UpgradeReport.applied} lists ids run
14
- * *this* invocation (empty on an already-current profile), and
15
- * {@link UpgradeReport.warnings} carries human-readable notes for any step that
16
- * failed. Callers typically log both and continue.
17
- */
18
- import type { Workspace } from "../contract";
19
- /**
20
- * The outcome of an {@link applyUpgrades} pass.
21
- *
22
- * - `applied` — ids of upgrades that ran successfully *this* invocation, in
23
- * apply order. Empty when the profile was already current.
24
- * - `warnings` — one entry per step that threw, naming the step and its error.
25
- * Non-fatal: applying continues past a failed step.
26
- */
27
- export interface UpgradeReport {
28
- /** Ids successfully applied during this call, in order. */
29
- readonly applied: string[];
30
- /** Human-readable notes for steps that failed (non-fatal). */
31
- readonly warnings: string[];
32
- }
33
- /**
34
- * Apply every not-yet-applied upgrade in {@link UPGRADES}, in registry order,
35
- * recording each success in the marker file so it never runs again.
36
- *
37
- * Steps already named in the marker are skipped. A step that throws is recorded
38
- * as a warning, left unmarked (so it is retried on a later launch), and does not
39
- * block the remaining steps. The marker is rewritten after each success, so a
40
- * crash mid-pass still preserves the progress made so far.
41
- *
42
- * @param ws The resolved, absolute on-disk layout to upgrade.
43
- * @returns The ids applied this pass and any non-fatal warnings.
44
- */
45
- export declare function applyUpgrades(ws: Workspace): Promise<UpgradeReport>;
@@ -1,13 +0,0 @@
1
- /**
2
- * Upgrade subsystem — public barrel.
3
- *
4
- * Surfaces the ordered, idempotent profile-upgrade registry and its driver.
5
- * Boot consumers import {@link applyUpgrades} to run pending one-time migrations
6
- * and the {@link UPGRADES} registry / {@link Upgrade} type for inspection and
7
- * testing. The marker-file bookkeeping is an internal detail of the driver and
8
- * is not re-exported.
9
- */
10
- export type { Upgrade } from "./upgrades";
11
- export { UPGRADES, foldCredentials, reshelveTranscripts, relocateBinaries, renamePromptDir, projectTranscriptDirName, } from "./upgrades";
12
- export type { UpgradeReport } from "./apply";
13
- export { applyUpgrades } from "./apply";
@@ -1,126 +0,0 @@
1
- /**
2
- * Upgrade registry — the ordered, idempotent catalog of one-time profile
3
- * migrations.
4
- *
5
- * This module replaces a bag of magic constants and inlined `try/catch`
6
- * migration blocks with a *registry*: an explicit, ordered list of named
7
- * {@link Upgrade} steps. Each step owns a stable {@link Upgrade.id}, a one-line
8
- * {@link Upgrade.describe}, and an idempotent {@link Upgrade.apply}. The driver
9
- * ({@link "./apply"}) folds over the list in order, recording the ids it has run
10
- * in a marker file so a step never runs twice — re-running the whole registry on
11
- * an already-upgraded profile is a no-op.
12
- *
13
- * Idempotence contract (every step must honor it):
14
- * - Detect "already done" cheaply and return early without side effects.
15
- * - Treat a *missing* source (the thing being migrated from) as success — the
16
- * profile is either fresh or already past this point.
17
- * - Never destroy data: relocations move-or-skip, never overwrite a live
18
- * destination; the legacy source is suffixed, not deleted.
19
- *
20
- * The seeded steps fold the legacy on-disk layout into the current one:
21
- * 1. {@link foldCredentials} — legacy split auth → one secure `auth.json`.
22
- * 2. {@link reshelveTranscripts} — loose session files → per-cwd `sessions/`.
23
- * 3. {@link relocateBinaries} — managed `fd`/`rg` helpers → the `bin/` dir.
24
- * 4. {@link renamePromptDir} — legacy `commands/` dir → `prompts/`.
25
- *
26
- * Session-directory encoding note: step 2 must place a transcript under the
27
- * *same* per-cwd directory name the framework's session manager would compute.
28
- * The framework publishes no standalone encoder for that name (the encoding is
29
- * private to its session manager), so this module uses a clearly-named local
30
- * helper, {@link projectTranscriptDirName}, rather than re-deriving the
31
- * framework's private per-cwd directory encoding. If the framework later exports
32
- * an encoder, swap the helper for the import without touching the step logic.
33
- */
34
- import type { Workspace } from "../contract";
35
- /**
36
- * One ordered, idempotent profile-layout upgrade.
37
- *
38
- * An upgrade is pure data plus one async effect. The registry order is the
39
- * apply order; the {@link id} is the durable key recorded in the marker file
40
- * once {@link apply} completes, so it must be stable across releases (renaming an
41
- * id re-runs the step). {@link apply} must be safe to invoke against a profile in
42
- * any state — fresh, partially-migrated, or fully-migrated.
43
- */
44
- export interface Upgrade {
45
- /** Durable identifier recorded once this step has run. Never rename. */
46
- readonly id: string;
47
- /** One-line human summary for logs and `--verbose` output. */
48
- readonly describe: string;
49
- /**
50
- * Perform the upgrade against the resolved {@link Workspace}. Must be
51
- * idempotent: detect "already applied" and return without side effects.
52
- *
53
- * @param ws The resolved, absolute on-disk layout.
54
- */
55
- apply(ws: Workspace): Promise<void>;
56
- }
57
- /**
58
- * Compute the per-project transcript sub-directory *name* for a working
59
- * directory.
60
- *
61
- * This deliberately does not reproduce the framework session manager's private
62
- * encoding character-for-character; the framework exposes no public encoder to
63
- * import, so this is the documented local fallback. It produces a single,
64
- * filesystem-safe directory leaf that is stable for a given absolute `cwd`:
65
- * path separators, drive colons, and any other non-portable characters collapse
66
- * to a single token, and a short content hash is appended so two distinct paths
67
- * that happen to fold to the same token never collide.
68
- *
69
- * The output is used only when *relocating a loose legacy transcript* into the
70
- * sessions tree; live sessions are always created by the framework itself, so
71
- * this helper never competes with the framework for the canonical name.
72
- *
73
- * @param cwd Absolute working directory the transcript belongs to.
74
- * @returns A safe directory leaf such as `proj-Users-me-app-1a2b3c4d`.
75
- */
76
- export declare function projectTranscriptDirName(cwd: string): string;
77
- /**
78
- * Fold a legacy split credential layout — a standalone `oauth.json` plus an
79
- * `apiKeys` block embedded in `settings.json` — into the single consolidated
80
- * `auth.json`, written with owner-only (`0o600`-equivalent) permissions.
81
- *
82
- * Idempotent: if `auth.json` already exists, nothing is touched. After a
83
- * successful fold the legacy `oauth.json` is suffixed (`oauth.json.retired`) and
84
- * the `apiKeys` block is removed from `settings.json`, so a second run finds no
85
- * legacy sources and the existing `auth.json` short-circuits it regardless.
86
- */
87
- export declare const foldCredentials: Upgrade;
88
- /**
89
- * Relocate loose `*.jsonl` transcripts that were written directly under the
90
- * profile root (a legacy layout) into the structured per-cwd sessions tree:
91
- * `sessions/<projectDirName>/<file>`.
92
- *
93
- * A loose file is recognized as a transcript by a first-line header of
94
- * `type: "session"`. The destination project directory is derived from the
95
- * header's recorded `cwd` via {@link projectTranscriptDirName} (the framework
96
- * owns no public encoder to delegate to — see this module's header). Each move
97
- * is skip-on-clobber, so re-running never overwrites an already-relocated
98
- * transcript, and once no loose transcripts remain the step is a pure no-op.
99
- */
100
- export declare const reshelveTranscripts: Upgrade;
101
- /**
102
- * Relocate the managed native helper binaries (`fd`, `rg`, and their Windows
103
- * `.exe` forms) from the legacy `tools/` directory into the canonical managed
104
- * `bin/` directory ({@link Workspace.binDir}).
105
- *
106
- * Each binary is moved skip-on-clobber and independently, so a partially-moved
107
- * state self-heals on the next run and an already-relocated layout (or a fresh
108
- * install with no legacy `tools/`) is a no-op.
109
- */
110
- export declare const relocateBinaries: Upgrade;
111
- /**
112
- * Rename the legacy command-template directory (`commands/`) to the current
113
- * prompt-template directory ({@link Workspace.promptsDir}).
114
- *
115
- * Idempotent: if the destination already exists the rename is skipped (the
116
- * profile is already on the current layout), and if the legacy directory is
117
- * absent there is nothing to do. The rename is whole-directory and
118
- * non-destructive — a live `prompts/` is never replaced.
119
- */
120
- export declare const renamePromptDir: Upgrade;
121
- /**
122
- * The ordered list of upgrades. Apply order is array order; ids are the durable
123
- * marker keys. Append new steps to the end — never reorder or rename existing
124
- * ids, as that would re-run already-applied migrations.
125
- */
126
- export declare const UPGRADES: readonly Upgrade[];
@@ -1,15 +0,0 @@
1
- /**
2
- * Briefing subsystem — Phase 9 behavioral tests.
3
- *
4
- * Three concerns, exercised purely (the only I/O is one temp `SKILL.md`):
5
- * 1. {@link composeBriefing} — the declarative section pipeline emits the
6
- * ordered sections rendered in this rebuild's OWN voice (we assert on our
7
- * section headings and re-authored guidance, never on any carried-over
8
- * upstream sentence).
9
- * 2. {@link scanMacroBody} / {@link applyMacros} — the single-pass `$arg`
10
- * scanner substitutes `$name` and `${name}` forms in one left-to-right scan
11
- * and leaves unknown tokens as literal text.
12
- * 3. {@link loadSkillCards} — a sample `SKILL.md` under a tmpdir parses into a
13
- * validated CapabilityCard.
14
- */
15
- export {};
@@ -1,37 +0,0 @@
1
- /**
2
- * Briefing composer — the declarative system-prompt pipeline.
3
- *
4
- * The system prompt is assembled from an ordered list of {@link BriefingSection}
5
- * descriptors, not a string template with `{{TOKEN}}` holes. Each section decides
6
- * for itself whether it contributes to a given {@link BriefingContext} (its
7
- * `applies` predicate) and renders its own fragment (its `render`). The composer
8
- * is a small reducer: it walks the recipe in order, keeps the applicable
9
- * sections, renders them, drops empties, and joins with blank-line gaps. Adding,
10
- * removing, or reordering a section is a data edit to {@link BRIEFING_SECTIONS},
11
- * never a change to the composer.
12
- *
13
- * Every guideline, tool note, and heading below is authored for this rebuild.
14
- * The *set* of sections (role, tools, working guidance, task tracking, delegates,
15
- * connectors, project context, skills, footer) follows the well-known coding-
16
- * agent shape; the wording is the briefing's own.
17
- */
18
- import type { Briefing, BriefingContext, BriefingInputs } from "./contract";
19
- /**
20
- * The default briefing recipe, in render order. Swap or reorder entries to
21
- * reshape the prompt without touching {@link composeBriefing}.
22
- */
23
- export declare const BRIEFING_SECTIONS: Briefing;
24
- /**
25
- * Fold a section recipe and a context into the final briefing string.
26
- *
27
- * Accepts either a plain {@link BriefingContext} (using the default
28
- * {@link BRIEFING_SECTIONS} recipe) or a full {@link BriefingInputs} bundle that
29
- * names its own sections and optional `prelude` / `append` text. The composer
30
- * keeps each section whose `applies` predicate is satisfied (or absent), renders
31
- * it, discards empty fragments, and joins the rest with blank-line gaps. Optional
32
- * `prelude` and `append` bracket the rendered sections.
33
- *
34
- * @param input either the render context, or a full inputs bundle
35
- * @returns the assembled system-prompt string
36
- */
37
- export declare function composeBriefing(input: BriefingContext | BriefingInputs): string;
@@ -1,38 +0,0 @@
1
- /**
2
- * Project-context document loader — gathers repository convention files
3
- * (CLAUDE.md / AGENTS.md and brand variants) into {@link ContextDoc}s that the
4
- * briefing's `PROJECT_CONTEXT_SECTION` inlines under `# Project context`.
5
- *
6
- * The walk runs the ancestor chain from the filesystem root down to the cwd, so
7
- * the cwd's own files land LAST in the returned array — and since the renderer
8
- * treats array order as priority order, the closest (most specific) file wins.
9
- * The home directory is scanned after the chain as a global fallback. Each file
10
- * may pull additional files inline via `@import` references (bounded to a depth
11
- * of {@link DEFAULT_MAX_IMPORT_DEPTH} with a per-walk realpath guard so cycles
12
- * and symlink loops cannot recurse or hang).
13
- *
14
- * The whole body is wrapped so that a permissions error on one ancestor, a
15
- * binary file, or a malformed tree degrades to `[]` rather than crashing boot —
16
- * repo conventions are a best-effort enrichment, never a hard dependency.
17
- */
18
- import type { ContextDoc } from "./contract";
19
- /** Options for {@link gatherContextDocs}. Every field is optional. */
20
- export interface GatherContextDocsOptions {
21
- /** Maximum `@import` recursion depth. Defaults to {@link DEFAULT_MAX_IMPORT_DEPTH}. */
22
- readonly maxImportDepth?: number;
23
- /** Maximum bytes retained per document body (post-trim). Defaults to {@link DEFAULT_MAX_BYTES_PER_DOC}. */
24
- readonly maxBytesPerDoc?: number;
25
- }
26
- /**
27
- * Gather the repository's project-context documents into an ordered
28
- * {@link ContextDoc} array for the briefing.
29
- *
30
- * Order: the ancestor chain from root → cwd (so cwd's files land last = highest
31
- * priority), then the home directory as a global fallback. Within each directory
32
- * the {@link CANDIDATE_FILES} are read in their listed order. Each file may pull
33
- * `@import` children inline (depth-bounded, cycle-guarded). De-duplication is by
34
- * realpath, so a file reachable through two roots is inlined once.
35
- *
36
- * Never throws: any failure in the walk yields the docs gathered so far (or `[]`).
37
- */
38
- export declare function gatherContextDocs(cwd: string, home: string, opts?: GatherContextDocsOptions): readonly ContextDoc[];