indusagi-coding-agent 0.2.3 → 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 (260) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE +661 -0
  3. package/README.md +95 -1
  4. package/dist/entry.js +3205 -1585
  5. package/dist/guardrails.js +47 -515
  6. package/dist/index.js +3232 -1671
  7. package/package.json +8 -7
  8. package/dist/types/addons/addons.test.d.ts +0 -21
  9. package/dist/types/addons/contract.d.ts +0 -640
  10. package/dist/types/addons/dispatch/event-dispatcher.d.ts +0 -140
  11. package/dist/types/addons/dispatch/index.d.ts +0 -23
  12. package/dist/types/addons/dispatch/tool-interceptor.d.ts +0 -128
  13. package/dist/types/addons/host.d.ts +0 -246
  14. package/dist/types/addons/index.d.ts +0 -51
  15. package/dist/types/addons/manifest.d.ts +0 -56
  16. package/dist/types/addons/sandbox.d.ts +0 -103
  17. package/dist/types/addons/surface.d.ts +0 -42
  18. package/dist/types/boot/auth-vault.d.ts +0 -29
  19. package/dist/types/boot/boot.d.ts +0 -26
  20. package/dist/types/boot/boot.test.d.ts +0 -15
  21. package/dist/types/boot/contract.d.ts +0 -236
  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 -89
  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/session-persist.test.d.ts +0 -10
  41. package/dist/types/boot/runners/session.d.ts +0 -65
  42. package/dist/types/boot/runners/session.test.d.ts +0 -10
  43. package/dist/types/boot/stages.d.ts +0 -92
  44. package/dist/types/boot/upgrade/apply.d.ts +0 -45
  45. package/dist/types/boot/upgrade/index.d.ts +0 -13
  46. package/dist/types/boot/upgrade/upgrades.d.ts +0 -126
  47. package/dist/types/briefing/briefing.test.d.ts +0 -15
  48. package/dist/types/briefing/compose.d.ts +0 -37
  49. package/dist/types/briefing/context-docs.d.ts +0 -38
  50. package/dist/types/briefing/context-docs.test.d.ts +0 -18
  51. package/dist/types/briefing/contract.d.ts +0 -686
  52. package/dist/types/briefing/index.d.ts +0 -29
  53. package/dist/types/briefing/macros.d.ts +0 -206
  54. package/dist/types/briefing/skills.d.ts +0 -67
  55. package/dist/types/capability-deck/bridge-ledger/index.d.ts +0 -25
  56. package/dist/types/capability-deck/bridge-ledger/key.d.ts +0 -65
  57. package/dist/types/capability-deck/bridge-ledger/ledger.d.ts +0 -129
  58. package/dist/types/capability-deck/bridge-ledger/network.d.ts +0 -115
  59. package/dist/types/capability-deck/builtin-bridge.d.ts +0 -114
  60. package/dist/types/capability-deck/capability-deck.test.d.ts +0 -18
  61. package/dist/types/capability-deck/cards/bg-process-card.d.ts +0 -99
  62. package/dist/types/capability-deck/cards/index.d.ts +0 -37
  63. package/dist/types/capability-deck/cards/memory-card.d.ts +0 -68
  64. package/dist/types/capability-deck/cards/plan-file.d.ts +0 -56
  65. package/dist/types/capability-deck/cards/plan-tools.d.ts +0 -97
  66. package/dist/types/capability-deck/cards/plan-tools.test.d.ts +0 -9
  67. package/dist/types/capability-deck/cards/saas-card.d.ts +0 -78
  68. package/dist/types/capability-deck/cards/task-card.d.ts +0 -106
  69. package/dist/types/capability-deck/cards/todo-card.d.ts +0 -78
  70. package/dist/types/capability-deck/cards/workflow-card.d.ts +0 -55
  71. package/dist/types/capability-deck/cards/workflow-card.test.d.ts +0 -12
  72. package/dist/types/capability-deck/checkpoint.int.test.d.ts +0 -25
  73. package/dist/types/capability-deck/contract.d.ts +0 -317
  74. package/dist/types/capability-deck/index.d.ts +0 -46
  75. package/dist/types/capability-deck/manifest.d.ts +0 -60
  76. package/dist/types/capability-deck/provision.d.ts +0 -76
  77. package/dist/types/capability-deck/read-edit-gate.int.test.d.ts +0 -21
  78. package/dist/types/channels/channels.test.d.ts +0 -15
  79. package/dist/types/channels/contract.d.ts +0 -489
  80. package/dist/types/channels/framer.d.ts +0 -49
  81. package/dist/types/channels/index.d.ts +0 -24
  82. package/dist/types/channels/link/dialog.d.ts +0 -138
  83. package/dist/types/channels/link/driver.d.ts +0 -81
  84. package/dist/types/channels/link/index.d.ts +0 -13
  85. package/dist/types/channels/link/server.d.ts +0 -70
  86. package/dist/types/channels/oneshot.d.ts +0 -37
  87. package/dist/types/channels/ops.d.ts +0 -89
  88. package/dist/types/channels/session-ops.d.ts +0 -80
  89. package/dist/types/conductor/bash-guard.d.ts +0 -106
  90. package/dist/types/conductor/bash-guard.test.d.ts +0 -17
  91. package/dist/types/conductor/catalog/catalog.d.ts +0 -87
  92. package/dist/types/conductor/catalog/index.d.ts +0 -14
  93. package/dist/types/conductor/catalog/matcher.d.ts +0 -47
  94. package/dist/types/conductor/conductor.d.ts +0 -189
  95. package/dist/types/conductor/conductor.test.d.ts +0 -10
  96. package/dist/types/conductor/contract.d.ts +0 -774
  97. package/dist/types/conductor/diagnostics.d.ts +0 -183
  98. package/dist/types/conductor/diagnostics.test.d.ts +0 -10
  99. package/dist/types/conductor/index.d.ts +0 -26
  100. package/dist/types/conductor/permission-gate.integration.test.d.ts +0 -22
  101. package/dist/types/conductor/permission-wiring.test.d.ts +0 -14
  102. package/dist/types/conductor/permissions.d.ts +0 -217
  103. package/dist/types/conductor/permissions.test.d.ts +0 -12
  104. package/dist/types/conductor/plan-mode.integration.test.d.ts +0 -23
  105. package/dist/types/conductor/post-edit-diagnostics.test.d.ts +0 -13
  106. package/dist/types/conductor/signal-hub/hub.d.ts +0 -83
  107. package/dist/types/conductor/signal-hub/index.d.ts +0 -19
  108. package/dist/types/conductor/signal-hub/translate.d.ts +0 -77
  109. package/dist/types/conductor/skill-parse/index.d.ts +0 -10
  110. package/dist/types/conductor/skill-parse/parse.d.ts +0 -67
  111. package/dist/types/conductor/submit.test.d.ts +0 -28
  112. package/dist/types/conductor/transcript-store/index.d.ts +0 -16
  113. package/dist/types/conductor/transcript-store/serialize.d.ts +0 -106
  114. package/dist/types/conductor/transcript-store/serialize.test.d.ts +0 -10
  115. package/dist/types/conductor/transcript-store/store.d.ts +0 -188
  116. package/dist/types/console/components/AgentsView.d.ts +0 -41
  117. package/dist/types/console/components/BackgroundAgents.d.ts +0 -63
  118. package/dist/types/console/components/BackgroundAgents.test.d.ts +0 -8
  119. package/dist/types/console/components/Banner.d.ts +0 -110
  120. package/dist/types/console/components/Composer.d.ts +0 -37
  121. package/dist/types/console/components/StatusBar.d.ts +0 -42
  122. package/dist/types/console/components/TerminalConsole.d.ts +0 -32
  123. package/dist/types/console/components/WorkingIndicator.d.ts +0 -44
  124. package/dist/types/console/components/WorkingIndicator.test.d.ts +0 -9
  125. package/dist/types/console/components/banner-sweep.d.ts +0 -55
  126. package/dist/types/console/components/banner.test.d.ts +0 -9
  127. package/dist/types/console/components/welcome.d.ts +0 -115
  128. package/dist/types/console/components/welcome.test.d.ts +0 -9
  129. package/dist/types/console/console.test.d.ts +0 -19
  130. package/dist/types/console/contract.d.ts +0 -598
  131. package/dist/types/console/index.d.ts +0 -34
  132. package/dist/types/console/input/complete.d.ts +0 -120
  133. package/dist/types/console/input/dir-reader.d.ts +0 -28
  134. package/dist/types/console/input/index.d.ts +0 -24
  135. package/dist/types/console/input/input.test.d.ts +0 -14
  136. package/dist/types/console/input/keymap.d.ts +0 -193
  137. package/dist/types/console/input/paste.d.ts +0 -131
  138. package/dist/types/console/mount.d.ts +0 -53
  139. package/dist/types/console/overlays/approval-queue.d.ts +0 -71
  140. package/dist/types/console/overlays/approval.d.ts +0 -104
  141. package/dist/types/console/overlays/approval.test.d.ts +0 -17
  142. package/dist/types/console/overlays/auth.d.ts +0 -31
  143. package/dist/types/console/overlays/boards.d.ts +0 -55
  144. package/dist/types/console/overlays/host.d.ts +0 -45
  145. package/dist/types/console/overlays/index.d.ts +0 -15
  146. package/dist/types/console/overlays/pickers.d.ts +0 -37
  147. package/dist/types/console/overlays/sessions.d.ts +0 -29
  148. package/dist/types/console/reducer.d.ts +0 -51
  149. package/dist/types/console/slash/builtins.d.ts +0 -33
  150. package/dist/types/console/slash/commands/dynamic.d.ts +0 -57
  151. package/dist/types/console/slash/commands/dynamic.test.d.ts +0 -9
  152. package/dist/types/console/slash/commands/integrations.d.ts +0 -28
  153. package/dist/types/console/slash/commands/integrations.test.d.ts +0 -18
  154. package/dist/types/console/slash/commands/shared.d.ts +0 -72
  155. package/dist/types/console/slash/commands/transcript.d.ts +0 -24
  156. package/dist/types/console/slash/commands/transcript.test.d.ts +0 -10
  157. package/dist/types/console/slash/commands/workbench.d.ts +0 -21
  158. package/dist/types/console/slash/commands/workbench.test.d.ts +0 -10
  159. package/dist/types/console/slash/index.d.ts +0 -34
  160. package/dist/types/console/slash/registry.d.ts +0 -90
  161. package/dist/types/console/slash/resolve.d.ts +0 -109
  162. package/dist/types/console/slash/slash.test.d.ts +0 -18
  163. package/dist/types/console/startup.d.ts +0 -119
  164. package/dist/types/console/theme/adapter.d.ts +0 -79
  165. package/dist/types/console/theme/index.d.ts +0 -18
  166. package/dist/types/console/theme/palette.d.ts +0 -77
  167. package/dist/types/console/theme/resolve.d.ts +0 -45
  168. package/dist/types/console/theme/theme.test.d.ts +0 -16
  169. package/dist/types/console/theme/tokens.d.ts +0 -62
  170. package/dist/types/entry.d.ts +0 -17
  171. package/dist/types/guardrails.d.ts +0 -33
  172. package/dist/types/index.d.ts +0 -24
  173. package/dist/types/insight/channel.d.ts +0 -45
  174. package/dist/types/insight/contract.d.ts +0 -411
  175. package/dist/types/insight/index.d.ts +0 -26
  176. package/dist/types/insight/insight.test.d.ts +0 -17
  177. package/dist/types/insight/recorder.d.ts +0 -63
  178. package/dist/types/insight/redaction.d.ts +0 -44
  179. package/dist/types/insight/replay.d.ts +0 -77
  180. package/dist/types/insight/sampling.d.ts +0 -84
  181. package/dist/types/insight/serialize.d.ts +0 -54
  182. package/dist/types/insight/sinks/console.d.ts +0 -36
  183. package/dist/types/insight/sinks/file.d.ts +0 -37
  184. package/dist/types/insight/sinks/index.d.ts +0 -16
  185. package/dist/types/insight/sinks/stream.d.ts +0 -53
  186. package/dist/types/kit/clipboard-image.d.ts +0 -40
  187. package/dist/types/kit/external-editor.d.ts +0 -35
  188. package/dist/types/kit/image.d.ts +0 -102
  189. package/dist/types/kit/index.d.ts +0 -29
  190. package/dist/types/kit/kit.test.d.ts +0 -13
  191. package/dist/types/kit/shell.d.ts +0 -50
  192. package/dist/types/kit/tool-fetch.d.ts +0 -165
  193. package/dist/types/launch/catalog.d.ts +0 -51
  194. package/dist/types/launch/contract.d.ts +0 -387
  195. package/dist/types/launch/credentials.d.ts +0 -112
  196. package/dist/types/launch/index.d.ts +0 -28
  197. package/dist/types/launch/invocation/attachments.d.ts +0 -72
  198. package/dist/types/launch/invocation/flags.d.ts +0 -59
  199. package/dist/types/launch/invocation/index.d.ts +0 -23
  200. package/dist/types/launch/invocation/read.d.ts +0 -52
  201. package/dist/types/launch/invocation/usage.d.ts +0 -25
  202. package/dist/types/launch/launch.test.d.ts +0 -20
  203. package/dist/types/launch/oauth.d.ts +0 -101
  204. package/dist/types/launch/packages.d.ts +0 -75
  205. package/dist/types/launch/packages.test.d.ts +0 -15
  206. package/dist/types/launch/pickers.d.ts +0 -97
  207. package/dist/types/runtime-bridge/bridges/_drive.d.ts +0 -74
  208. package/dist/types/runtime-bridge/bridges/builtins.d.ts +0 -77
  209. package/dist/types/runtime-bridge/bridges/claude-cli.d.ts +0 -37
  210. package/dist/types/runtime-bridge/bridges/codex-cli.d.ts +0 -27
  211. package/dist/types/runtime-bridge/bridges/index.d.ts +0 -15
  212. package/dist/types/runtime-bridge/bridges/indusagi-cli.d.ts +0 -36
  213. package/dist/types/runtime-bridge/broker.d.ts +0 -182
  214. package/dist/types/runtime-bridge/contract.d.ts +0 -436
  215. package/dist/types/runtime-bridge/index.d.ts +0 -21
  216. package/dist/types/runtime-bridge/runtime-bridge.test.d.ts +0 -17
  217. package/dist/types/runtime-bridge/sink.d.ts +0 -59
  218. package/dist/types/sessions/contract.d.ts +0 -79
  219. package/dist/types/sessions/index.d.ts +0 -11
  220. package/dist/types/sessions/library.d.ts +0 -95
  221. package/dist/types/sessions/sessions.test.d.ts +0 -11
  222. package/dist/types/settings/contract.d.ts +0 -175
  223. package/dist/types/settings/index.d.ts +0 -13
  224. package/dist/types/settings/manager.d.ts +0 -109
  225. package/dist/types/settings/settings.test.d.ts +0 -16
  226. package/dist/types/transcript-export/index.d.ts +0 -20
  227. package/dist/types/transcript-export/publish.d.ts +0 -81
  228. package/dist/types/transcript-export/sgr.d.ts +0 -90
  229. package/dist/types/transcript-export/template.d.ts +0 -64
  230. package/dist/types/transcript-export/theme-bridge.d.ts +0 -99
  231. package/dist/types/transcript-export/transcript-export.test.d.ts +0 -16
  232. package/dist/types/window-budget/budget/estimate.d.ts +0 -47
  233. package/dist/types/window-budget/budget/gate.d.ts +0 -37
  234. package/dist/types/window-budget/budget/index.d.ts +0 -14
  235. package/dist/types/window-budget/budget/slice.d.ts +0 -38
  236. package/dist/types/window-budget/condenser.d.ts +0 -73
  237. package/dist/types/window-budget/contract.d.ts +0 -182
  238. package/dist/types/window-budget/index.d.ts +0 -17
  239. package/dist/types/window-budget/microcompact.d.ts +0 -68
  240. package/dist/types/window-budget/microcompact.test.d.ts +0 -16
  241. package/dist/types/window-budget/rehydrate.d.ts +0 -56
  242. package/dist/types/window-budget/summarize/condense.d.ts +0 -70
  243. package/dist/types/window-budget/summarize/index.d.ts +0 -12
  244. package/dist/types/window-budget/summarize/prompt.d.ts +0 -56
  245. package/dist/types/window-budget/window-budget.test.d.ts +0 -18
  246. package/dist/types/workflow-engine/agent-runner.d.ts +0 -105
  247. package/dist/types/workflow-engine/agent-runner.test.d.ts +0 -8
  248. package/dist/types/workflow-engine/display.d.ts +0 -148
  249. package/dist/types/workflow-engine/display.test.d.ts +0 -1
  250. package/dist/types/workflow-engine/engine.d.ts +0 -183
  251. package/dist/types/workflow-engine/engine.test.d.ts +0 -1
  252. package/dist/types/workflow-engine/index.d.ts +0 -21
  253. package/dist/types/workflow-engine/parse.d.ts +0 -64
  254. package/dist/types/workflow-engine/parse.test.d.ts +0 -1
  255. package/dist/types/workflow-engine/structured-output.d.ts +0 -51
  256. package/dist/types/workflow-engine/structured-output.test.d.ts +0 -1
  257. package/dist/types/workspace/brand.d.ts +0 -26
  258. package/dist/types/workspace/index.d.ts +0 -11
  259. package/dist/types/workspace/locator.d.ts +0 -50
  260. package/dist/types/workspace/runtime-detect.d.ts +0 -56
@@ -1,63 +0,0 @@
1
- /**
2
- * Recorder — the trail/probe factory at the head of the pipeline.
3
- *
4
- * {@link createRecorder} returns the single {@link Recorder} the agent talks to.
5
- * Opening a trail consults the {@link SampleGate}: a sampled-out trail collapses
6
- * to {@link NOOP_HANDLE} (and its whole probe subtree is free), while a sampled-in
7
- * trail mints a {@link TrailId}, a root {@link Probe}, and emits an `open`
8
- * {@link Signal} onto the {@link SignalChannel}. Each live {@link ProbeHandle}
9
- * carries closures that derive the next frozen probe value on `note` / `fail` /
10
- * `close` and push the matching signal; `child` mints a sub-probe sharing the
11
- * trail. The contract's forgiving lifecycle is honoured here: `note` / `child` /
12
- * `fail` are no-ops after `close`, and `close` is idempotent (first call wins).
13
- *
14
- * The recorder runs every probe through a {@link SecretRedactor} just before the
15
- * signal hits the channel, so no sink ever sees an unscrubbed value. Ids are
16
- * minted from `node:crypto` random bytes at the W3C-derived widths in
17
- * {@link ID_WIDTHS}; nothing here imports the framework.
18
- */
19
- import { SignalChannel } from "./channel";
20
- import { ProbeFault, ProbeId, Recorder, SampleGate, SecretRedactor, Sink, TrailId } from "./contract";
21
- /** Mint a fresh 128-bit {@link TrailId} (32 hex chars). */
22
- export declare function mintTrailId(): TrailId;
23
- /** Mint a fresh 64-bit {@link ProbeId} (16 hex chars). */
24
- export declare function mintProbeId(): ProbeId;
25
- /** Construction options for {@link createRecorder}. */
26
- export interface RecorderOptions {
27
- /** Service name stamped on the recorder (e.g. for a dashboard panel). */
28
- readonly service?: string;
29
- /** Master switch; a disabled recorder is all no-ops regardless of the gate. */
30
- readonly enabled?: boolean;
31
- /** Admission gate; defaults to {@link alwaysGate} when enabled. */
32
- readonly gate?: SampleGate;
33
- /** Attribute processor run before signals reach a sink; defaults to passthrough. */
34
- readonly redactor?: SecretRedactor;
35
- /** Sinks attached at construction; each drains an independent stream. */
36
- readonly sinks?: readonly Sink[];
37
- /** Clock source, in epoch ms; defaults to {@link Date.now}. Useful for tests. */
38
- readonly now?: () => number;
39
- }
40
- /**
41
- * A {@link Recorder} that also exposes its underlying {@link SignalChannel}.
42
- *
43
- * Tests and the pipeline can attach extra streams after construction; the agent
44
- * only ever sees the {@link Recorder} face.
45
- */
46
- export interface InsightRecorder extends Recorder {
47
- /** The channel every live handle emits onto; one stream per attached sink. */
48
- readonly channel: SignalChannel;
49
- }
50
- /**
51
- * Create the recorder at the head of the insight pipeline.
52
- *
53
- * @param options see {@link RecorderOptions}
54
- * @returns a live {@link InsightRecorder}
55
- */
56
- export declare function createRecorder(options?: RecorderOptions): InsightRecorder;
57
- /**
58
- * Coerce an arbitrary thrown value into a serializable {@link ProbeFault}.
59
- *
60
- * An `Error` contributes its message, constructor name, and stack; any other
61
- * value is rendered to a string message. The result is a plain frozen record.
62
- */
63
- export declare function faultOf(error: unknown): ProbeFault;
@@ -1,44 +0,0 @@
1
- /**
2
- * Secret redaction — the attribute processor the pipeline runs before a sink.
3
- *
4
- * A {@link SecretRedactor} (contract) walks a probe's attribute bag and its
5
- * fault, replacing sensitive values with the {@link REDACTED_TOKEN}. Three things
6
- * can trigger a redaction:
7
- *
8
- * 1. a *key-path* match — the attribute key (or a nested object key) looks like
9
- * a secret holder (`apiKey`, `password`, `authorization`, ...);
10
- * 2. a *value* match — a string looks like a credential regardless of its key
11
- * (a bearer token, an `sk-` key, a private-key block, ...);
12
- * 3. an *omit* — a key listed in {@link RedactionOptions.omitKeys} is dropped
13
- * from the output entirely rather than tokenized.
14
- *
15
- * The scrubber is *streaming* in the sense that it walks structures depth-first,
16
- * tracking the current key as it descends so nested secrets (`{ http: { headers:
17
- * { authorization: "..." } } }`) are caught by key without the caller flattening
18
- * anything. Output is always freshly allocated and frozen; the input probe is
19
- * never mutated. The default rule set and token are the agent's own — they do not
20
- * mirror any upstream redactor.
21
- */
22
- import { RedactionOptions, RedactionRule, SecretRedactor } from "./contract";
23
- /**
24
- * The agent's own default redaction rule set.
25
- *
26
- * One key rule covering every secret-bearing key fragment, plus one value rule
27
- * per credential shape. Exposed so callers can extend rather than replace it.
28
- */
29
- export declare const DEFAULT_REDACTION_RULES: readonly RedactionRule[];
30
- /**
31
- * Build a {@link SecretRedactor} from a rule set and options.
32
- *
33
- * @param rules the redaction rules to apply, in order; defaults to
34
- * {@link DEFAULT_REDACTION_RULES}
35
- * @param options length cap and key omissions; see {@link RedactionOptions}
36
- * @returns a frozen redactor; its `scrub*` methods never mutate their inputs
37
- */
38
- export declare function createRedactor(rules?: readonly RedactionRule[], options?: RedactionOptions): SecretRedactor;
39
- /**
40
- * A ready-built redactor using the agent's default rules and default caps.
41
- *
42
- * The pipeline installs this when redaction is enabled but unconfigured.
43
- */
44
- export declare const DEFAULT_REDACTOR: SecretRedactor;
@@ -1,77 +0,0 @@
1
- /**
2
- * Replay — read an NDJSON trace file back into probes and trails.
3
- *
4
- * The file sink writes one {@link TraceRecord} per line; replay is the inverse.
5
- * It parses a chunk or line stream, validates each record, and exposes the
6
- * recovered probes in three increasingly cooked forms:
7
- *
8
- * - {@link replaySignals} — the raw {@link Signal} stream, in file order;
9
- * - {@link replayProbes} — the final probe value per id (close wins over open),
10
- * which is what you usually want for offline analysis;
11
- * - {@link replayTrails} — the probes grouped into per-trail trees, each with a
12
- * root and a parent->children map, ready to render.
13
- *
14
- * Replay never imports the framework and performs no recording — it is a pure
15
- * reader over the durable format pinned in `serialize.ts`. A malformed line is,
16
- * by default, skipped rather than fatal, so a trace truncated by a crash still
17
- * yields everything written before the break.
18
- */
19
- import { Probe, ProbeId, Signal, TrailId } from "./contract";
20
- import { TraceRecord } from "./serialize";
21
- /** A source of raw bytes/text chunks (a file read stream, stdin, a buffer). */
22
- export type ChunkSource = AsyncIterable<string | Uint8Array> | Iterable<string | Uint8Array>;
23
- /** Options shared by the replay readers. */
24
- export interface ReplayOptions {
25
- /** Throw on a malformed line instead of skipping it; defaults to `false`. */
26
- readonly strict?: boolean;
27
- }
28
- /**
29
- * Split a chunk source into complete text lines.
30
- *
31
- * Buffers across chunks, splits on `\n` only, and emits a trailing unterminated
32
- * line at end-of-stream so a final non-newline frame is not dropped.
33
- */
34
- export declare function readLines(source: ChunkSource): AsyncGenerator<string, void, unknown>;
35
- /**
36
- * Decode a chunk source into a stream of validated {@link TraceRecord}s.
37
- *
38
- * Malformed JSON or a record failing the shape check is skipped (or rethrown
39
- * when `strict`).
40
- */
41
- export declare function readRecords(source: ChunkSource, options?: ReplayOptions): AsyncGenerator<TraceRecord, void, unknown>;
42
- /** Reconstruct the {@link Signal} stream from a chunk source, in file order. */
43
- export declare function replaySignals(source: ChunkSource, options?: ReplayOptions): AsyncGenerator<Signal, void, unknown>;
44
- /**
45
- * Collapse a trace into the final value of each probe, keyed by id.
46
- *
47
- * Records arrive in lifecycle order (open -> update* -> close); the last record
48
- * for an id wins, so a closed probe supersedes its open. The returned map
49
- * preserves first-seen insertion order.
50
- */
51
- export declare function replayProbes(source: ChunkSource, options?: ReplayOptions): Promise<Map<ProbeId, Probe>>;
52
- /** One reconstructed trail: its root probe plus the parent->children index. */
53
- export interface ReplayedTrail {
54
- /** The trail id every probe in this tree shares. */
55
- readonly trailId: TrailId;
56
- /** The root probe (parentId === null), or `null` if the root was never seen. */
57
- readonly root: Probe | null;
58
- /** Every probe in the trail, keyed by id, in first-seen order. */
59
- readonly probes: ReadonlyMap<ProbeId, Probe>;
60
- /** Child probe ids per parent id; roots are listed under the empty key. */
61
- readonly children: ReadonlyMap<ProbeId | null, readonly ProbeId[]>;
62
- /** Whether every probe in the trail reached a terminal state. */
63
- readonly complete: boolean;
64
- }
65
- /**
66
- * Group a trace into per-trail trees.
67
- *
68
- * Each {@link ReplayedTrail} carries its probes, a parent->children adjacency
69
- * map (so a renderer can walk the tree without re-scanning), the located root,
70
- * and a completeness flag. Trails appear in the order their first probe was
71
- * seen.
72
- *
73
- * @param source the NDJSON chunk source
74
- * @param options see {@link ReplayOptions}
75
- * @returns one {@link ReplayedTrail} per distinct trail id
76
- */
77
- export declare function replayTrails(source: ChunkSource, options?: ReplayOptions): Promise<ReplayedTrail[]>;
@@ -1,84 +0,0 @@
1
- /**
2
- * Sampling — the admission gate that decides which trails are recorded.
3
- *
4
- * A {@link SampleGate} (declared in the contract) returns a per-trail verdict:
5
- * `true` keeps the trail (live handles), `false` collapses the whole trail to
6
- * {@link NOOP_HANDLE}. This module supplies the three concrete gates the recorder
7
- * draws from:
8
- *
9
- * - {@link alwaysGate} — admit every trail (the default when sampling is off);
10
- * - {@link neverGate} — reject every trail (a disabled recorder);
11
- * - {@link ratioGate} — admit a deterministic fraction, keyed on the trail id.
12
- *
13
- * The ratio gate is the interesting one. It must be *sticky per trail* — a probe
14
- * may never disagree with its trail about being sampled — so the verdict is a
15
- * pure function of the trail id, not a coin flip. We fold the id into a 32-bit
16
- * value with an FNV-1a hash, project it onto the unit interval, and compare
17
- * against the configured fraction. The same id always yields the same verdict on
18
- * any machine, which also makes head-based sampling agree across a distributed
19
- * trail without coordination.
20
- */
21
- import { FixedGates, SampleGate, TrailId } from "./contract";
22
- /** A gate that admits every trail. Shared, frozen, allocation-free. */
23
- export declare const alwaysGate: SampleGate;
24
- /** A gate that rejects every trail. Shared, frozen, allocation-free. */
25
- export declare const neverGate: SampleGate;
26
- /** The two well-known fixed gates, bundled for the recorder fallback. */
27
- export declare const FIXED_GATES: FixedGates;
28
- /**
29
- * Fold a string into a 32-bit unsigned hash with FNV-1a.
30
- *
31
- * Chosen for being tiny, dependency-free, and well-distributed over short hex
32
- * ids. The result is forced unsigned with `>>> 0` so the projection onto the
33
- * unit interval never sees a negative numerator.
34
- *
35
- * @param text the string to hash (a trail id, in practice)
36
- * @returns a 32-bit unsigned integer
37
- */
38
- export declare function hash32(text: string): number;
39
- /**
40
- * Project a trail id onto the unit interval `[0, 1)`.
41
- *
42
- * The same id always lands on the same point, which is what makes a
43
- * {@link ratioGate} verdict deterministic and sticky.
44
- *
45
- * @param trailId the trail id to score
46
- * @returns a fraction in `[0, 1)`
47
- */
48
- export declare function trailScore(trailId: TrailId): number;
49
- /**
50
- * A sampling gate that admits a deterministic fraction of trails.
51
- *
52
- * Unlike {@link alwaysGate} / {@link neverGate}, this gate needs the *trail id*
53
- * to render a sticky verdict, but {@link SampleGate.admit} is handed only the
54
- * root name. The recorder therefore mints the trail id first and consults
55
- * {@link verdict} directly; {@link RatioGate.admit} is kept as a name-only
56
- * fallback (it folds the name instead) so the type still satisfies
57
- * {@link SampleGate}.
58
- */
59
- export interface RatioGate extends SampleGate {
60
- /** The admitted fraction, clamped to `[0, 1]`. */
61
- readonly fraction: number;
62
- /** The sticky, id-keyed verdict the recorder actually consults. */
63
- verdict(trailId: TrailId): boolean;
64
- }
65
- /**
66
- * Build a {@link RatioGate} admitting roughly `fraction` of all trails.
67
- *
68
- * The verdict is `trailScore(id) < fraction`, so a fraction of `0.1` admits the
69
- * trails whose hashed id lands in the lowest tenth of the unit interval — about
70
- * a tenth of trails, deterministically. Edge fractions short-circuit to the
71
- * fixed gates: `<= 0` is {@link neverGate} behaviour and `>= 1` is
72
- * {@link alwaysGate} behaviour, with no hashing.
73
- *
74
- * @param fraction the admitted share, clamped to `[0, 1]`
75
- * @returns a frozen {@link RatioGate}
76
- */
77
- export declare function ratioGate(fraction: number): RatioGate;
78
- /**
79
- * Narrow a {@link SampleGate} to a {@link RatioGate}.
80
- *
81
- * Lets the recorder prefer the id-keyed {@link RatioGate.verdict} when the gate
82
- * exposes it, falling back to the name-only {@link SampleGate.admit} otherwise.
83
- */
84
- export declare function isRatioGate(gate: SampleGate): gate is RatioGate;
@@ -1,54 +0,0 @@
1
- /**
2
- * Serialization — the on-disk NDJSON record shape shared by the file sink and
3
- * the replay reader.
4
- *
5
- * A {@link Signal} is already JSON-ish, but persisting it verbatim would bury the
6
- * useful fields (phase, ids, timing) inside a nested probe. A {@link TraceRecord}
7
- * is the flat, self-describing line we actually write: one JSON object per line,
8
- * carrying the phase, the full probe, and the emission clock. The file sink
9
- * encodes a record per signal; {@link replay} parses records back into probes.
10
- *
11
- * Keeping the record format in one module guarantees the writer and the reader
12
- * never drift: there is exactly one {@link encodeRecord} and one
13
- * {@link decodeRecord}, and both sides import them.
14
- */
15
- import { ClosedProbe, Probe, Signal, SignalPhase } from "./contract";
16
- /** Schema version stamped on every record, so a future reader can branch. */
17
- export declare const RECORD_VERSION: 1;
18
- /**
19
- * One persisted trace line.
20
- *
21
- * Flat and self-describing: a reader needs nothing but the line to reconstruct
22
- * the signal. The `probe` is a {@link ClosedProbe} when `phase === "close"`.
23
- */
24
- export interface TraceRecord {
25
- /** Record schema version; see {@link RECORD_VERSION}. */
26
- readonly v: typeof RECORD_VERSION;
27
- /** The signal phase this record carries. */
28
- readonly phase: SignalPhase;
29
- /** The probe value at the moment the signal fired. */
30
- readonly probe: Probe;
31
- /** Emission clock, epoch ms. */
32
- readonly at: number;
33
- }
34
- /** Line feed (U+000A): the one and only record boundary. */
35
- export declare const LINE_FEED = "\n";
36
- /** Project a {@link Signal} onto its flat {@link TraceRecord}. */
37
- export declare function signalToRecord(signal: Signal): TraceRecord;
38
- /**
39
- * Encode a signal as one separator-safe NDJSON line.
40
- *
41
- * @returns the JSON line terminated by a single line feed
42
- */
43
- export declare function encodeRecord(signal: Signal): string;
44
- /**
45
- * Parse one NDJSON line into a {@link TraceRecord}.
46
- *
47
- * @throws SyntaxError when the line is not valid JSON
48
- * @returns the decoded record (callers validate the shape before trusting it)
49
- */
50
- export declare function decodeRecord(line: string): TraceRecord;
51
- /** Whether a decoded record's probe is a terminal {@link ClosedProbe}. */
52
- export declare function recordIsClose(record: TraceRecord): record is TraceRecord & {
53
- probe: ClosedProbe;
54
- };
@@ -1,36 +0,0 @@
1
- /**
2
- * Console sink — drains signals to a writable, one human-readable line each.
3
- *
4
- * The simplest terminal {@link Sink}: it pulls the {@link SignalStream} and
5
- * prints a compact line per signal — phase, kind, name, ids, and (on close) the
6
- * outcome and duration. Open and update lines are dimmed; close lines are
7
- * coloured by outcome. Colour is opt-in and degrades to plain text when the
8
- * target is not a TTY, so piping the output stays clean.
9
- *
10
- * The writer is injected (defaulting to `process.stdout`) so tests can capture
11
- * lines without touching the real terminal.
12
- */
13
- import { Sink } from "../contract";
14
- /** The minimal writable face the console sink needs. */
15
- export interface LineWriter {
16
- /** Append a chunk; the sink always supplies a newline-terminated line. */
17
- write(chunk: string): unknown;
18
- /** Whether the target is an interactive terminal (enables colour). */
19
- readonly isTTY?: boolean;
20
- }
21
- /** Construction options for {@link createConsoleSink}. */
22
- export interface ConsoleSinkOptions {
23
- /** Where lines go; defaults to `process.stdout`. */
24
- readonly writer?: LineWriter;
25
- /** Force colour on/off; defaults to the writer's TTY state. */
26
- readonly color?: boolean;
27
- /** Sink id; defaults to `"console"`. */
28
- readonly id?: string;
29
- }
30
- /**
31
- * Build a {@link Sink} that prints each signal as one line.
32
- *
33
- * @param options see {@link ConsoleSinkOptions}
34
- * @returns a console {@link Sink}
35
- */
36
- export declare function createConsoleSink(options?: ConsoleSinkOptions): Sink;
@@ -1,37 +0,0 @@
1
- /**
2
- * File sink — drains signals to an append-only NDJSON trace file.
3
- *
4
- * Each signal becomes one {@link TraceRecord} line via {@link encodeRecord}; the
5
- * file is opened for append (created if absent) and every record is flushed to
6
- * the OS write buffer as it arrives, so a crash mid-trail still leaves a readable
7
- * prefix that {@link replay} can parse. The handle is closed when the stream is
8
- * exhausted.
9
- *
10
- * The file is the durable counterpart to the ephemeral stream sink: what the
11
- * file sink writes, the replay reader reads back, with the record format pinned
12
- * in `serialize.ts` so the two never disagree.
13
- */
14
- import { Sink } from "../contract";
15
- /** Construction options for {@link createFileSink}. */
16
- export interface FileSinkOptions {
17
- /** Filesystem path the NDJSON trace is appended to. */
18
- readonly path: string;
19
- /** Sink id; defaults to `"file"`. */
20
- readonly id?: string;
21
- /** Create the parent directory if missing; defaults to `true`. */
22
- readonly mkdirp?: boolean;
23
- /** Truncate the file on open instead of appending; defaults to `false`. */
24
- readonly truncate?: boolean;
25
- }
26
- /**
27
- * Build a {@link Sink} that appends one NDJSON record per signal to a file.
28
- *
29
- * The file is opened lazily on the first drained signal (so constructing a sink
30
- * that is never used touches no disk), then closed when the stream ends or
31
- * throws. `mkdirp` ensures the parent directory exists; `truncate` starts a
32
- * fresh file rather than appending.
33
- *
34
- * @param options see {@link FileSinkOptions}
35
- * @returns a file {@link Sink}
36
- */
37
- export declare function createFileSink(options: FileSinkOptions): Sink;
@@ -1,16 +0,0 @@
1
- /**
2
- * Sinks barrel — the terminal consumers of a {@link Signal} stream.
3
- *
4
- * Three concrete {@link Sink} factories, each of which drains an independent
5
- * {@link SignalStream} obtained from the recorder's channel:
6
- *
7
- * - {@link createConsoleSink} — one human line per signal to a TTY / writer;
8
- * - {@link createFileSink} — append-only NDJSON to a path (durable);
9
- * - {@link createStreamSink} — NDJSON forwarded to an injected byte writer;
10
- * - {@link createCollectorSink} — an in-memory array (tests / inspection).
11
- *
12
- * All four are framework-agnostic and share the record format in `serialize.ts`.
13
- */
14
- export { createConsoleSink, type ConsoleSinkOptions, type LineWriter, } from "./console";
15
- export { createFileSink, type FileSinkOptions, } from "./file";
16
- export { createStreamSink, createCollectorSink, type StreamSinkOptions, type SignalWriter, type CollectorSink, } from "./stream";
@@ -1,53 +0,0 @@
1
- /**
2
- * Stream sink — forwards signals to a network/byte stream, or collects them.
3
- *
4
- * Two shapes share this module because both are "drain into something live":
5
- *
6
- * - {@link createStreamSink} writes each signal as an NDJSON line to an
7
- * injected byte/string writer (a socket, a child pipe, an SSE response),
8
- * using the same record format as the file sink;
9
- * - {@link createCollectorSink} appends every signal to an in-memory array, the
10
- * trivial test/inspection sink.
11
- *
12
- * Neither owns a transport: the byte writer is injected, so the same sink feeds a
13
- * TCP socket, an HTTP chunked body, or an in-process pair without code change.
14
- */
15
- import { Signal, Sink } from "../contract";
16
- /** The minimal push-style writer the stream sink forwards lines to. */
17
- export interface SignalWriter {
18
- /** Append one already-encoded NDJSON line. May be async. */
19
- write(line: string): unknown | Promise<unknown>;
20
- /** Optional end-of-stream hook, called once the source is exhausted. */
21
- end?(): unknown | Promise<unknown>;
22
- }
23
- /** Construction options for {@link createStreamSink}. */
24
- export interface StreamSinkOptions {
25
- /** Where encoded lines are forwarded. */
26
- readonly writer: SignalWriter;
27
- /** Sink id; defaults to `"stream"`. */
28
- readonly id?: string;
29
- /** Call `writer.end()` when the source stream ends; defaults to `true`. */
30
- readonly endOnFinish?: boolean;
31
- }
32
- /**
33
- * Build a {@link Sink} that forwards each signal as an NDJSON line to a writer.
34
- *
35
- * @param options see {@link StreamSinkOptions}
36
- * @returns a stream {@link Sink}
37
- */
38
- export declare function createStreamSink(options: StreamSinkOptions): Sink;
39
- /** A collector {@link Sink} plus the live array it fills. */
40
- export interface CollectorSink extends Sink {
41
- /** Every signal drained so far, in arrival order. */
42
- readonly signals: readonly Signal[];
43
- }
44
- /**
45
- * Build an in-memory {@link Sink} that accumulates every drained signal.
46
- *
47
- * The handiest sink for tests and one-shot inspection: drain a recorder's stream
48
- * through it, then read {@link CollectorSink.signals}.
49
- *
50
- * @param id sink id; defaults to `"collector"`
51
- * @returns a {@link CollectorSink}
52
- */
53
- export declare function createCollectorSink(id?: string): CollectorSink;
@@ -1,40 +0,0 @@
1
- /**
2
- * Clipboard-image kit — pull a raster image off the OS clipboard and stage it
3
- * on disk as a temp PNG, returning the path the composer can splice into a
4
- * prompt.
5
- *
6
- * The terminal can only carry text, so an image on the clipboard cannot ride a
7
- * normal paste. Instead this helper shells out to the platform's clipboard
8
- * tool, captures the raw bytes, writes them to a temp file, and hands back the
9
- * path — the agent then attaches the file by reference.
10
- *
11
- * Platform strategy (each is the conventional tool for its OS):
12
- * - **macOS** — `pngpaste -` dumps a clipboard image to stdout; when it is not
13
- * installed we fall back to an `osascript` one-liner that asks the clipboard
14
- * for its «class PNGf» data and base64-encodes it.
15
- * - **Linux/Wayland** — `wl-paste --type image/png` writes the image to stdout.
16
- * - **Linux/X11** — `xclip -selection clipboard -t image/png -o` does the same.
17
- *
18
- * Every spawn is best-effort: a missing tool, a non-zero exit, or an empty
19
- * clipboard all collapse to `null` so the caller can warn rather than throw. The
20
- * `child_process` / `fs` / `os` builtins are the only dependencies; nothing here
21
- * touches the framework or a sibling subsystem.
22
- */
23
- /** Options for {@link readClipboardImage} — injectable so tests stay hermetic. */
24
- export interface ClipboardImageOptions {
25
- /** Override the host platform (defaults to `process.platform`). */
26
- readonly platform?: NodeJS.Platform;
27
- /** Override the environment consulted for the Wayland probe. */
28
- readonly env?: NodeJS.ProcessEnv;
29
- /** Override the temp directory the captured PNG is written to. */
30
- readonly dir?: string;
31
- }
32
- /**
33
- * Pull an image off the OS clipboard, write it to a temp PNG, and return the
34
- * file path — or `null` when no image is on the clipboard, the platform's tool
35
- * is missing, or the write fails.
36
- *
37
- * The returned path is unique per call (millisecond + random suffix) so two
38
- * pastes never collide. The caller owns the temp file thereafter.
39
- */
40
- export declare function readClipboardImage(options?: ClipboardImageOptions): string | null;
@@ -1,35 +0,0 @@
1
- /**
2
- * External-editor kit — hand the composer buffer off to the user's `$EDITOR`,
3
- * wait for them to close it, and read the edited text back.
4
- *
5
- * Composing a long prompt at a single-line terminal caret is painful; this
6
- * helper stages the current buffer in a temp file, launches the configured
7
- * editor against it with the terminal shared (so vi/nano/etc. take over the
8
- * screen), blocks until the editor exits, then reads the file back as the new
9
- * buffer.
10
- *
11
- * The editor is resolved from `$VISUAL`, then `$EDITOR`, then a `vi` fallback —
12
- * the conventional precedence. The spawn is synchronous and inherits stdio so
13
- * the editor owns the real terminal; on return the temp file is removed. Any
14
- * failure (no editor that runs, a non-zero exit, an unreadable file) yields
15
- * `null` and the caller keeps the original buffer.
16
- *
17
- * Only `child_process` / `fs` / `os` builtins are used; nothing here depends on
18
- * the framework or a sibling subsystem.
19
- */
20
- /** Options for {@link openInExternalEditor} — injectable so tests stay hermetic. */
21
- export interface ExternalEditorOptions {
22
- /** Override the environment consulted for `$VISUAL` / `$EDITOR`. */
23
- readonly env?: NodeJS.ProcessEnv;
24
- /** Override the temp directory the scratch file is written to. */
25
- readonly dir?: string;
26
- }
27
- /**
28
- * Stage `buffer` in a temp file, open it in the user's editor sharing this
29
- * terminal, block until the editor exits, and return the edited text — or
30
- * `null` when the editor could not run or exited non-zero.
31
- *
32
- * A single trailing newline (most editors add one on save) is stripped so the
33
- * round-trip does not silently grow the buffer. The temp file is always removed.
34
- */
35
- export declare function openInExternalEditor(buffer: string, options?: ExternalEditorOptions): string | null;
@@ -1,102 +0,0 @@
1
- /**
2
- * Image kit — magic-byte sniffing for the two raster formats the agent ships
3
- * support for, plus a tiny asset-naming helper.
4
- *
5
- * This is a leaf utility: framework-agnostic, dependency-free (Node builtins
6
- * only), and pure apart from the byte reads it is handed. Two unrelated jobs
7
- * live here because both are small and both are about turning opaque bytes /
8
- * platform tuples into a stable name:
9
- *
10
- * - {@link sniffImageFormat} / {@link detectImageMediaType} classify a byte
11
- * buffer as PNG or JPEG by inspecting its leading signature bytes. The
12
- * signatures are an interface-dictated constant — they are fixed by the PNG
13
- * and JFIF/EXIF container specifications, not a choice we make.
14
- * - {@link resolveAssetName} renders a release-asset file name from a small
15
- * template by substituting platform / architecture / version tokens, so a
16
- * provisioner can locate the right download for the host without a per-tool
17
- * switch.
18
- *
19
- * Nothing here performs I/O: callers read the bytes (a file head, a clipboard
20
- * blob, a fetched body) and pass them in. That keeps the module trivially
21
- * testable and usable from any host.
22
- */
23
- /**
24
- * The raster image formats this kit can recognise from their leading bytes.
25
- *
26
- * Deliberately tiny — the agent only ever needs to tell PNG and JPEG apart for
27
- * its attachment / clipboard paths; anything else is reported as `unknown`
28
- * rather than guessed.
29
- */
30
- export type ImageFormat = "png" | "jpeg";
31
- /**
32
- * The IANA media types {@link ImageFormat} values map to.
33
- *
34
- * Used when a recognised format must be handed to the framework attachment
35
- * model, which speaks media-type strings.
36
- */
37
- export type ImageMediaType = "image/png" | "image/jpeg";
38
- /** The widest signature checked, so a caller knows the minimum head to read. */
39
- export declare const IMAGE_SNIFF_BYTES: number;
40
- /**
41
- * A byte source this module can read a leading window from.
42
- *
43
- * Both a Node `Uint8Array` / `Buffer` and a plain number array satisfy this, so
44
- * a caller never has to convert before sniffing.
45
- */
46
- export type ByteSource = ArrayLike<number>;
47
- /**
48
- * Classify a byte buffer as PNG or JPEG by its leading signature.
49
- *
50
- * Reads at most {@link IMAGE_SNIFF_BYTES} bytes from the front of `bytes` and
51
- * returns the matching {@link ImageFormat}, or `null` when neither signature
52
- * matches (an empty buffer, a truncated head, or any other format). Pure: it
53
- * inspects the buffer and allocates nothing.
54
- *
55
- * @param bytes the leading bytes of a candidate image (a file head is enough)
56
- */
57
- export declare function sniffImageFormat(bytes: ByteSource): ImageFormat | null;
58
- /** Map a recognised {@link ImageFormat} to its IANA media type. */
59
- export declare function mediaTypeForImageFormat(format: ImageFormat): ImageMediaType;
60
- /**
61
- * Detect the media type of a byte buffer, or `null` when unrecognised.
62
- *
63
- * A convenience over {@link sniffImageFormat} for callers that speak media-type
64
- * strings (e.g. the framework attachment model) rather than the internal
65
- * {@link ImageFormat} tag.
66
- *
67
- * @param bytes the leading bytes of a candidate image
68
- */
69
- export declare function detectImageMediaType(bytes: ByteSource): ImageMediaType | null;
70
- /** Whether `bytes` is a buffer this kit recognises as a supported image. */
71
- export declare function isSupportedImage(bytes: ByteSource): boolean;
72
- /**
73
- * The platform / architecture / version facts a {@link resolveAssetName}
74
- * template can interpolate.
75
- *
76
- * Field names mirror the substitution tokens; every member is optional so a
77
- * template that only references some of them can be rendered from a partial
78
- * context (a missing token resolves to an empty string).
79
- */
80
- export interface AssetNameContext {
81
- /** The host operating system, e.g. `"darwin"` / `"linux"` / `"win32"`. */
82
- readonly platform?: string;
83
- /** The host CPU architecture, e.g. `"arm64"` / `"x64"`. */
84
- readonly arch?: string;
85
- /** The release version, e.g. `"1.2.3"` (with or without a leading `v`). */
86
- readonly version?: string;
87
- /** The bare tool / binary name, e.g. `"fd"` / `"rg"`. */
88
- readonly name?: string;
89
- }
90
- /**
91
- * Render a release-asset file name from a `{token}` template.
92
- *
93
- * Replaces each `{platform}` / `{arch}` / `{version}` / `{name}` occurrence with
94
- * the matching {@link AssetNameContext} field (an absent field becomes the empty
95
- * string), leaving every other character verbatim. This lets a provisioner
96
- * declare one template per tool — e.g. `"{name}-{version}-{arch}-{platform}.tar.gz"`
97
- * — instead of branching on the host. Pure string work, no I/O.
98
- *
99
- * @param template the asset-name pattern with `{token}` placeholders
100
- * @param context the platform / arch / version / name facts to substitute
101
- */
102
- export declare function resolveAssetName(template: string, context: AssetNameContext): string;