@illuminis/comprism 0.1.7 → 2.4.0

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 (225) hide show
  1. package/out/{graph → build/machine/codemap}/read-python.js +2 -2
  2. package/out/{executor → build/machine/executor}/diagnostics.js +1 -1
  3. package/out/{executor → build/machine/executor}/hooks.js +1 -1
  4. package/out/{executor → build/machine/executor}/sandbox.js +1 -1
  5. package/out/build/machine/line/index.js +339 -0
  6. package/out/{commands/privacy.js → build/machine/runtime/home.js} +10 -19
  7. package/out/build/machine/runtime/needs.js +89 -0
  8. package/out/{lib → build/machine/runtime}/self.js +25 -3
  9. package/out/build/machine/terminal/jobs.js +67 -0
  10. package/out/build/machine/terminal/sign-in.js +212 -0
  11. package/out/build/machine/terminal/steps.js +460 -0
  12. package/out/build/machine/terminal/voice.js +136 -0
  13. package/out/build/machine/voice/record.js +286 -0
  14. package/out/cli-start.js +128 -0
  15. package/out/machine/line/index.js +339 -0
  16. package/out/machine/runtime/self.js +22 -0
  17. package/out/machine/terminal/clipboard.js +182 -0
  18. package/out/machine/terminal/jobs.js +67 -0
  19. package/out/machine/terminal/sign-in.js +212 -0
  20. package/out/machine/terminal/steps.js +460 -0
  21. package/out/machine/terminal/voice.js +136 -0
  22. package/out/machine/voice/record.js +79 -1
  23. package/out/native/dictate +0 -0
  24. package/out/server.generated.js +6 -0
  25. package/package.json +8 -40
  26. package/README.md +0 -343
  27. package/out/agent/command.d.ts +0 -157
  28. package/out/agent/command.js +0 -454
  29. package/out/agent/render.d.ts +0 -169
  30. package/out/agent/render.js +0 -689
  31. package/out/agent/session.d.ts +0 -334
  32. package/out/agent/session.js +0 -1223
  33. package/out/commands/agents.d.ts +0 -2
  34. package/out/commands/agents.js +0 -79
  35. package/out/commands/ask.d.ts +0 -1
  36. package/out/commands/ask.js +0 -222
  37. package/out/commands/codemap.d.ts +0 -2
  38. package/out/commands/codemap.js +0 -151
  39. package/out/commands/commands-thin.d.ts +0 -39
  40. package/out/commands/commands-thin.js +0 -244
  41. package/out/commands/config.d.ts +0 -1
  42. package/out/commands/config.js +0 -138
  43. package/out/commands/cost.d.ts +0 -1
  44. package/out/commands/cost.js +0 -167
  45. package/out/commands/decisionEngine.d.ts +0 -1
  46. package/out/commands/decisionEngine.js +0 -66
  47. package/out/commands/hooks.d.ts +0 -1
  48. package/out/commands/hooks.js +0 -83
  49. package/out/commands/install.d.ts +0 -206
  50. package/out/commands/install.js +0 -738
  51. package/out/commands/instructions.d.ts +0 -1
  52. package/out/commands/instructions.js +0 -113
  53. package/out/commands/integrations.d.ts +0 -3
  54. package/out/commands/integrations.js +0 -215
  55. package/out/commands/jobs.d.ts +0 -5
  56. package/out/commands/jobs.js +0 -157
  57. package/out/commands/keys.d.ts +0 -55
  58. package/out/commands/keys.js +0 -344
  59. package/out/commands/login.d.ts +0 -9
  60. package/out/commands/login.js +0 -606
  61. package/out/commands/memory.d.ts +0 -3
  62. package/out/commands/memory.js +0 -113
  63. package/out/commands/permissions.d.ts +0 -1
  64. package/out/commands/permissions.js +0 -94
  65. package/out/commands/plugins.d.ts +0 -4
  66. package/out/commands/plugins.js +0 -192
  67. package/out/commands/privacy.d.ts +0 -1
  68. package/out/commands/providerKey.d.ts +0 -32
  69. package/out/commands/providerKey.js +0 -108
  70. package/out/commands/repl.d.ts +0 -12
  71. package/out/commands/repl.js +0 -2303
  72. package/out/commands/report.d.ts +0 -39
  73. package/out/commands/report.js +0 -115
  74. package/out/commands/review.d.ts +0 -5
  75. package/out/commands/review.js +0 -223
  76. package/out/commands/sessions.d.ts +0 -23
  77. package/out/commands/sessions.js +0 -115
  78. package/out/commands/settings.d.ts +0 -23
  79. package/out/commands/settings.js +0 -153
  80. package/out/commands/skills.d.ts +0 -21
  81. package/out/commands/skills.js +0 -207
  82. package/out/commands/unattended.d.ts +0 -7
  83. package/out/commands/unattended.js +0 -351
  84. package/out/commands/update.d.ts +0 -1
  85. package/out/commands/update.js +0 -123
  86. package/out/commands/welcome.d.ts +0 -25
  87. package/out/commands/welcome.js +0 -223
  88. package/out/commands/worktrees.d.ts +0 -5
  89. package/out/commands/worktrees.js +0 -186
  90. package/out/executor/browser.d.ts +0 -14
  91. package/out/executor/diagnostics.d.ts +0 -2
  92. package/out/executor/documents.d.ts +0 -40
  93. package/out/executor/files.d.ts +0 -2
  94. package/out/executor/git.d.ts +0 -48
  95. package/out/executor/hooks.d.ts +0 -51
  96. package/out/executor/index.d.ts +0 -45
  97. package/out/executor/notebook.d.ts +0 -2
  98. package/out/executor/paths.d.ts +0 -20
  99. package/out/executor/sandbox.d.ts +0 -40
  100. package/out/executor/shell.d.ts +0 -86
  101. package/out/executor/toolservers.d.ts +0 -20
  102. package/out/executor/worktree.d.ts +0 -9
  103. package/out/graph/build.d.ts +0 -45
  104. package/out/graph/facts.d.ts +0 -47
  105. package/out/graph/files.d.ts +0 -45
  106. package/out/graph/read-locales.d.ts +0 -29
  107. package/out/graph/read-python.d.ts +0 -11
  108. package/out/graph/read-typescript.d.ts +0 -16
  109. package/out/graph/sync.d.ts +0 -66
  110. package/out/graph/sync.js +0 -242
  111. package/out/lib/attach.d.ts +0 -106
  112. package/out/lib/attach.js +0 -396
  113. package/out/lib/clipboard.d.ts +0 -23
  114. package/out/lib/commandlist.d.ts +0 -20
  115. package/out/lib/commandlist.js +0 -58
  116. package/out/lib/config.d.ts +0 -94
  117. package/out/lib/config.js +0 -197
  118. package/out/lib/connection.d.ts +0 -73
  119. package/out/lib/connection.js +0 -188
  120. package/out/lib/decision.d.ts +0 -22
  121. package/out/lib/decision.js +0 -50
  122. package/out/lib/fingerprint.d.ts +0 -25
  123. package/out/lib/fingerprint.js +0 -58
  124. package/out/lib/gateway.d.ts +0 -427
  125. package/out/lib/gateway.js +0 -226
  126. package/out/lib/history.d.ts +0 -24
  127. package/out/lib/history.js +0 -137
  128. package/out/lib/ide.d.ts +0 -19
  129. package/out/lib/ide.js +0 -131
  130. package/out/lib/keyboard.d.ts +0 -98
  131. package/out/lib/keyboard.js +0 -390
  132. package/out/lib/lastlogin.d.ts +0 -14
  133. package/out/lib/lastlogin.js +0 -105
  134. package/out/lib/machine.d.ts +0 -21
  135. package/out/lib/machine.js +0 -91
  136. package/out/lib/notify.d.ts +0 -4
  137. package/out/lib/notify.js +0 -52
  138. package/out/lib/output.d.ts +0 -48
  139. package/out/lib/output.js +0 -108
  140. package/out/lib/picker.d.ts +0 -1
  141. package/out/lib/picker.js +0 -158
  142. package/out/lib/project-ops.d.ts +0 -19
  143. package/out/lib/project-ops.js +0 -146
  144. package/out/lib/project.d.ts +0 -28
  145. package/out/lib/prompt.d.ts +0 -37
  146. package/out/lib/prompt.js +0 -142
  147. package/out/lib/queue.d.ts +0 -13
  148. package/out/lib/queue.js +0 -116
  149. package/out/lib/readiness.d.ts +0 -22
  150. package/out/lib/readiness.js +0 -207
  151. package/out/lib/self.d.ts +0 -23
  152. package/out/lib/servicecommand.d.ts +0 -14
  153. package/out/lib/servicecommand.js +0 -74
  154. package/out/lib/sessions.d.ts +0 -19
  155. package/out/lib/sessions.js +0 -221
  156. package/out/lib/startcache.d.ts +0 -13
  157. package/out/lib/startcache.js +0 -78
  158. package/out/lib/stdin.d.ts +0 -32
  159. package/out/lib/stdin.js +0 -117
  160. package/out/lib/store.d.ts +0 -40
  161. package/out/lib/store.js +0 -138
  162. package/out/lib/sync.d.ts +0 -18
  163. package/out/lib/sync.js +0 -81
  164. package/out/lib/types.d.ts +0 -417
  165. package/out/lib/types.js +0 -21
  166. package/out/lib/ui.d.ts +0 -123
  167. package/out/lib/ui.js +0 -299
  168. package/out/lib/version.d.ts +0 -23
  169. package/out/lib/version.js +0 -46
  170. package/out/lib/voice.d.ts +0 -49
  171. package/out/lib/voice.js +0 -236
  172. package/out/lib/words.d.ts +0 -20
  173. package/out/lib/words.js +0 -27
  174. package/out/machine/codemap/build.d.ts +0 -45
  175. package/out/machine/codemap/facts.d.ts +0 -47
  176. package/out/machine/codemap/files.d.ts +0 -45
  177. package/out/machine/codemap/read-locales.d.ts +0 -29
  178. package/out/machine/codemap/read-python.d.ts +0 -11
  179. package/out/machine/codemap/read-typescript.d.ts +0 -16
  180. package/out/machine/executor/browser.d.ts +0 -14
  181. package/out/machine/executor/diagnostics.d.ts +0 -2
  182. package/out/machine/executor/documents.d.ts +0 -40
  183. package/out/machine/executor/files.d.ts +0 -2
  184. package/out/machine/executor/git.d.ts +0 -48
  185. package/out/machine/executor/hooks.d.ts +0 -51
  186. package/out/machine/executor/index.d.ts +0 -45
  187. package/out/machine/executor/notebook.d.ts +0 -2
  188. package/out/machine/executor/paths.d.ts +0 -20
  189. package/out/machine/executor/sandbox.d.ts +0 -40
  190. package/out/machine/executor/shell.d.ts +0 -86
  191. package/out/machine/executor/toolservers.d.ts +0 -20
  192. package/out/machine/executor/worktree.d.ts +0 -9
  193. package/out/machine/folder/project.d.ts +0 -28
  194. package/out/machine/runtime/home.d.ts +0 -2
  195. package/out/machine/runtime/needs.d.ts +0 -30
  196. package/out/machine/runtime/self.d.ts +0 -23
  197. package/out/machine/voice/record.d.ts +0 -38
  198. package/out/postinstall.d.ts +0 -2
  199. package/out/postinstall.js +0 -120
  200. package/out/providers/anthropic.d.ts +0 -22
  201. package/out/providers/anthropic.js +0 -80
  202. package/out/providers/index.d.ts +0 -8
  203. package/out/providers/index.js +0 -84
  204. package/out/providers/openai.d.ts +0 -11
  205. package/out/providers/openai.js +0 -57
  206. package/out/thin.d.ts +0 -2
  207. package/out/thin.js +0 -855
  208. package/scripts/read_python.py +0 -270
  209. /package/out/{graph → build/machine/codemap}/build.js +0 -0
  210. /package/out/{graph → build/machine/codemap}/facts.js +0 -0
  211. /package/out/{graph → build/machine/codemap}/files.js +0 -0
  212. /package/out/{graph → build/machine/codemap}/read-locales.js +0 -0
  213. /package/out/{graph → build/machine/codemap}/read-typescript.js +0 -0
  214. /package/out/{executor → build/machine/executor}/browser.js +0 -0
  215. /package/out/{executor → build/machine/executor}/documents.js +0 -0
  216. /package/out/{executor → build/machine/executor}/files.js +0 -0
  217. /package/out/{executor → build/machine/executor}/git.js +0 -0
  218. /package/out/{executor → build/machine/executor}/index.js +0 -0
  219. /package/out/{executor → build/machine/executor}/notebook.js +0 -0
  220. /package/out/{executor → build/machine/executor}/paths.js +0 -0
  221. /package/out/{executor → build/machine/executor}/shell.js +0 -0
  222. /package/out/{executor → build/machine/executor}/toolservers.js +0 -0
  223. /package/out/{executor → build/machine/executor}/worktree.js +0 -0
  224. /package/out/{lib → build/machine/folder}/project.js +0 -0
  225. /package/out/{lib → build/machine/terminal}/clipboard.js +0 -0
package/out/lib/ui.js DELETED
@@ -1,299 +0,0 @@
1
- "use strict";
2
- /**
3
- * Terminal presentation.
4
- *
5
- * This is a developer product, so the terminal IS the interface, and it gets the
6
- * same care a screen would. Three rules hold it together:
7
- *
8
- * 1. **The brand shows up here.** The prism spectrum and the illuminis palette
9
- * are the same ones the portal and the documents use, rendered in 24-bit
10
- * color where the terminal supports it.
11
- * 2. **Color is never the only signal.** Every state that matters also has a
12
- * glyph and a word, so the output survives `NO_COLOR`, a pipe, a CI log and
13
- * a color-blind reader unchanged.
14
- * 3. **Nothing here is decoration for its own sake.** Every panel answers a
15
- * question the person actually has: what did that cost, what was wasted,
16
- * and how sure are we of the number.
17
- */
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.LiveIndicator = exports.c = void 0;
20
- exports.width = width;
21
- exports.spectrumAt = spectrumAt;
22
- exports.cellArt = cellArt;
23
- exports.prismRule = prismRule;
24
- exports.banner = banner;
25
- exports.money = money;
26
- exports.clip = clip;
27
- exports.pad = pad;
28
- exports.padLeft = padLeft;
29
- exports.stripAnsi = stripAnsi;
30
- exports.kpiCards = kpiCards;
31
- exports.paretoBars = paretoBars;
32
- exports.table = table;
33
- exports.receipt = receipt;
34
- exports.ok = ok;
35
- exports.warn = warn;
36
- exports.fail = fail;
37
- exports.info = info;
38
- const isTty = process.stdout.isTTY === true;
39
- /** Decided when drawn, not when loaded, so `--plain`, `plain true` and
40
- * `theme plain` applied at start up take effect (manual 6.10, 6.12). */
41
- const noColor = () => !!process.env.NO_COLOR || process.env.TERM === 'dumb';
42
- const useColorNow = () => isTty && !noColor();
43
- /** Plain mode: no color and nothing redrawn; every update is a new line. */
44
- const plainNow = () => process.env.COMPRISM_PLAIN === '1' || !isTty;
45
- const light = () => process.env.COMPRISM_THEME === 'light';
46
- function width() {
47
- return Math.min(process.stdout.columns || 88, 100);
48
- }
49
- // ── palette ─────────────────────────────────────────────────────────────────
50
- // illuminis brand, from branding/brand.toml. Deep navy is unreadable on a dark
51
- // terminal, so the terminal palette leans on the two blues and the purple.
52
- const rgb = (r, g, b) => (s) => useColorNow() ? `\x1b[38;2;${r};${g};${b}m${s}\x1b[0m` : s;
53
- exports.c = {
54
- blue: rgb(59, 111, 181), // primary_blue #3B6FB5
55
- deep: rgb(31, 77, 120), // heading_blue #1F4D78
56
- purple: rgb(107, 91, 167), // purple_accent #6B5BA7
57
- green: rgb(22, 163, 74), // success #16A34A
58
- amber: rgb(217, 119, 6), // warning #D97706
59
- red: rgb(220, 38, 38), // error #DC2626
60
- muted: rgb(158, 158, 158), // muted_text #9E9E9E
61
- // Light on a dark terminal, dark on a light one (manual 6.10).
62
- text: (s) => (light() ? rgb(40, 44, 52)(s) : rgb(214, 219, 228)(s)),
63
- bold: (s) => (useColorNow() ? `\x1b[1m${s}\x1b[0m` : s),
64
- dim: (s) => (useColorNow() ? `\x1b[2m${s}\x1b[0m` : s),
65
- };
66
- /** The prism: white light entering, a spectrum leaving. The brand in one line. */
67
- const SPECTRUM = [
68
- [59, 111, 181],
69
- [79, 105, 186],
70
- [99, 98, 184],
71
- [123, 92, 175],
72
- [150, 90, 160],
73
- [176, 92, 138],
74
- [201, 101, 112],
75
- [217, 119, 6],
76
- ];
77
- /**
78
- * Any glyph, in one of the eight spectrum colors.
79
- *
80
- * Exported so the logo and the rule under it are drawn from the SAME eight
81
- * values. Two hand-picked palettes in one product drift apart within a release,
82
- * and the brand is the one thing a customer notices before the engine.
83
- */
84
- function spectrumAt(index, glyph) {
85
- if (!useColorNow())
86
- return glyph;
87
- const [r, g, b] = SPECTRUM[Math.abs(index) % SPECTRUM.length];
88
- return `\x1b[38;2;${r};${g};${b}m${glyph}\x1b[0m`;
89
- }
90
- /**
91
- * A small picture, one pixel to a character cell, each pixel a colored space.
92
- *
93
- * A cell's background is painted edge to edge by every terminal, so the
94
- * picture has no seams. Half block glyphs pack two pixels into a cell but
95
- * leave thin gaps and offsets in some fonts, which made the mark look broken
96
- * in the macOS Terminal (owner, 28 September 2026). Each row of `pixels` is
97
- * six hex digits per pixel, `......` for a clear one. Returns nothing without
98
- * color, because the picture is only color.
99
- */
100
- function cellArt(pixels) {
101
- if (!useColorNow())
102
- return [];
103
- return pixels.map((row) => {
104
- let line = '';
105
- for (let x = 0; x < row.length / 6; x++) {
106
- const hex = row.slice(x * 6, x * 6 + 6);
107
- if (hex === '......') {
108
- line += ' ';
109
- continue;
110
- }
111
- const rgb = [0, 2, 4].map((k) => parseInt(hex.slice(k, k + 2), 16)).join(';');
112
- line += `\x1b[48;2;${rgb}m \x1b[0m`;
113
- }
114
- return line;
115
- });
116
- }
117
- function prismRule(w = width()) {
118
- if (!useColorNow())
119
- return '-'.repeat(w);
120
- const seg = Math.max(1, Math.floor(w / SPECTRUM.length));
121
- let out = '';
122
- for (let i = 0; i < SPECTRUM.length; i++) {
123
- const [r, g, b] = SPECTRUM[i];
124
- const len = i === SPECTRUM.length - 1 ? w - seg * (SPECTRUM.length - 1) : seg;
125
- out += `\x1b[38;2;${r};${g};${b}m${'━'.repeat(Math.max(0, len))}`;
126
- }
127
- return `${out}\x1b[0m`;
128
- }
129
- function banner(subtitle) {
130
- const lines = [
131
- '',
132
- ` ${exports.c.bold(exports.c.blue('◣'))}${exports.c.bold(exports.c.purple('◥'))} ${exports.c.bold('CompletionPrism')} ${exports.c.dim('comprism')}`,
133
- subtitle ? ` ${exports.c.muted(subtitle)}` : '',
134
- prismRule(),
135
- ].filter(Boolean);
136
- return lines.join('\n');
137
- }
138
- // ── primitives ──────────────────────────────────────────────────────────────
139
- function money(v) {
140
- if (v === null)
141
- return 'unpriced';
142
- if (v === 0)
143
- return '$0.00';
144
- if (v < 0.01)
145
- return `$${v.toFixed(5)}`;
146
- if (v < 1)
147
- return `$${v.toFixed(4)}`;
148
- return `$${v.toFixed(2)}`;
149
- }
150
- /** Clip to a visible width, with an ellipsis, so a card never bleeds. */
151
- function clip(s, n) {
152
- const visible = stripAnsi(s);
153
- if (visible.length <= n)
154
- return s;
155
- return `${visible.slice(0, Math.max(0, n - 1))}\u2026`;
156
- }
157
- function pad(s, n) {
158
- const visible = stripAnsi(s);
159
- return visible.length >= n ? s : s + ' '.repeat(n - visible.length);
160
- }
161
- function padLeft(s, n) {
162
- const visible = stripAnsi(s);
163
- return visible.length >= n ? s : ' '.repeat(n - visible.length) + s;
164
- }
165
- function stripAnsi(s) {
166
- // eslint-disable-next-line no-control-regex
167
- return s.replace(/\x1b\[[0-9;]*m/g, '');
168
- }
169
- /**
170
- * A row of KPI cards - the same shape the portal's summary tab uses, so the two
171
- * surfaces read as one product rather than two tools that happen to share a name.
172
- */
173
- function kpiCards(cards) {
174
- const w = width();
175
- const cardW = Math.max(18, Math.floor((w - (cards.length - 1) * 2) / cards.length));
176
- const tone = (t) => t === 'good' ? exports.c.green : t === 'warn' ? exports.c.amber : exports.c.text;
177
- const top = cards.map(() => `┌${'─'.repeat(cardW - 2)}┐`).join(' ');
178
- const inner = cardW - 4;
179
- const label = cards
180
- .map((k) => `│ ${pad(exports.c.muted(clip(k.label.toUpperCase(), inner)), inner)} │`)
181
- .join(' ');
182
- const value = cards
183
- .map((k) => `│ ${pad(exports.c.bold(tone(k.tone)(clip(k.value, inner))), inner)} │`)
184
- .join(' ');
185
- const note = cards
186
- .map((k) => `│ ${pad(exports.c.dim(clip(k.note || '', inner)), inner)} │`)
187
- .join(' ');
188
- const bottom = cards.map(() => `└${'─'.repeat(cardW - 2)}┘`).join(' ');
189
- return [top, label, value, note, bottom].join('\n');
190
- }
191
- /**
192
- * A Pareto bar: sorted descending with a running cumulative share.
193
- *
194
- * Pareto rather than a plain bar chart because the question a spend screen has
195
- * to answer is not "how much did each cost" but "how few of these carry most of
196
- * the bill" - the answer is usually two or three, and that is the whole insight.
197
- */
198
- function paretoBars(rows, opts = {}) {
199
- const unit = opts.unit || ((v) => v.toFixed(2));
200
- const sorted = [...rows].sort((a, b) => b.value - a.value);
201
- const total = sorted.reduce((s, r) => s + r.value, 0) || 1;
202
- const labelW = Math.max(...sorted.map((r) => r.label.length), 8);
203
- const barW = opts.barWidth || Math.max(12, Math.min(34, width() - labelW - 30));
204
- const max = sorted[0]?.value || 1;
205
- let cumulative = 0;
206
- const out = [];
207
- for (const r of sorted) {
208
- cumulative += r.value;
209
- const share = (cumulative / total) * 100;
210
- const filled = Math.max(r.value > 0 ? 1 : 0, Math.round((r.value / max) * barW));
211
- const bar = exports.c.blue('█'.repeat(filled)) + exports.c.dim('·'.repeat(Math.max(0, barW - filled)));
212
- out.push(` ${pad(exports.c.text(r.label), labelW)} ${bar} ${padLeft(unit(r.value), 10)} ${exports.c.dim(`${padLeft(share.toFixed(0), 3)}% cum`)}${r.sub ? ` ${exports.c.dim(r.sub)}` : ''}`);
213
- }
214
- return out.join('\n');
215
- }
216
- function table(headers, rows) {
217
- const widths = headers.map((h, i) => Math.max(stripAnsi(h).length, ...rows.map((r) => stripAnsi(r[i] || '').length)));
218
- const head = ` ${headers.map((h, i) => pad(exports.c.muted(h.toUpperCase()), widths[i])).join(' ')}`;
219
- const sep = ` ${widths.map((w) => exports.c.dim('─'.repeat(w))).join(' ')}`;
220
- const body = rows.map((r) => ` ${r.map((cell, i) => pad(cell, widths[i])).join(' ')}`);
221
- return [head, sep, ...body].join('\n');
222
- }
223
- // ── the live indicator ──────────────────────────────────────────────────────
224
- /**
225
- * The thing that makes it visible that something is between the person and the
226
- * provider.
227
- *
228
- * Without this, an instrumented session looks exactly like an uninstrumented
229
- * one, and a product nobody can see is a product nobody renews. It shows the
230
- * work as it happens - characterising, dispatching, recording - and then gets
231
- * out of the way, leaving the answer and a one-line receipt.
232
- */
233
- class LiveIndicator {
234
- shown = false;
235
- // No animation of its own. A glyph turning on a timer looks like work
236
- // whether or not anything is happening; the line changes only when the
237
- // caller has something new to say, and in plain mode each change is a new
238
- // line rather than a redraw (manual 6.12).
239
- start(label) {
240
- this.draw(label);
241
- }
242
- update(label) {
243
- this.draw(label);
244
- }
245
- draw(label) {
246
- if (plainNow()) {
247
- process.stdout.write(` ${label}\n`);
248
- return;
249
- }
250
- process.stdout.write(`\r ${exports.c.purple('◠')} ${exports.c.dim(label)} `);
251
- this.shown = true;
252
- }
253
- stop() {
254
- if (this.shown && !plainNow())
255
- process.stdout.write(`\r${' '.repeat(width())}\r`);
256
- this.shown = false;
257
- }
258
- }
259
- exports.LiveIndicator = LiveIndicator;
260
- /**
261
- * The receipt, rendered by the client and never injected into the conversation.
262
- *
263
- * Injected text is re-sent on every later turn, so a receipt in the message
264
- * array is a line item the customer pays for again on every turn for the rest of
265
- * the session. It belongs on the screen, not in the context window.
266
- */
267
- function receipt(r) {
268
- const parts = [];
269
- parts.push(`${exports.c.purple('◈')} ${exports.c.bold(r.model)}`);
270
- parts.push(exports.c.dim('·'));
271
- parts.push(`${r.inputTokens ?? '?'}${exports.c.dim(' in')} ${r.outputTokens ?? '?'}${exports.c.dim(' out')}`);
272
- parts.push(exports.c.dim('·'));
273
- parts.push(exports.c.bold(money(r.costUsd)));
274
- parts.push(exports.c.dim('·'));
275
- parts.push(exports.c.dim(`${(r.latencyMs / 1000).toFixed(1)}s`));
276
- parts.push(exports.c.dim('·'));
277
- parts.push(exports.c.dim(`${r.tier}`));
278
- const lines = [` ${parts.join(' ')}`];
279
- if (r.remediated) {
280
- lines.push(` ${exports.c.amber('↑')} ${exports.c.amber('weak answer repaired')} ${exports.c.dim(`- ${r.attempts} attempts, ${money(r.wastedUsd)} spent on the attempt that failed`)}`);
281
- }
282
- lines.push(` ${exports.c.green('✓')} ${exports.c.dim('recorded:')} ${exports.c.dim('ledger row, decision record, fingerprint only - no request text stored')}`);
283
- if (r.withheld) {
284
- lines.push(` ${exports.c.muted('○')} ${exports.c.dim(`no recommendation (${r.withheld.replace(/_/g, ' ')}) - request ran untouched`)}`);
285
- }
286
- return lines.join('\n');
287
- }
288
- function ok(msg) {
289
- return ` ${exports.c.green('✓')} ${msg}`;
290
- }
291
- function warn(msg) {
292
- return ` ${exports.c.amber('!')} ${msg}`;
293
- }
294
- function fail(msg) {
295
- return ` ${exports.c.red('✗')} ${msg}`;
296
- }
297
- function info(msg) {
298
- return ` ${exports.c.blue('▸')} ${msg}`;
299
- }
@@ -1,23 +0,0 @@
1
- /**
2
- * Every version string the Companion stamps onto a record.
3
- *
4
- * Ground rule 3: a derived record without the version of the code that produced
5
- * it cannot be restated and cannot serve as evidence. These are bumped when the
6
- * behavior behind them changes, never on a whim, because consumers select by
7
- * version and old records keep meaning what they meant.
8
- */
9
- export declare const COMPRISM_VERSION: string;
10
- /** The structural classifier. Bump when a signal is added, removed or retuned. */
11
- export declare const CLASSIFIER_VERSION = "structural-v1";
12
- /**
13
- * The dispatch policy.
14
- *
15
- * `naive` is the honest name for what this release does: the first eligible
16
- * candidate for the structural band, with no estimate consulted. When the model
17
- * program delivers tables, decisions made under this version stay permanently
18
- * distinguishable from decisions made under a learned one - which is exactly
19
- * why the version is on the record rather than in a changelog.
20
- */
21
- export declare const POLICY_VERSION = "naive-v1";
22
- /** The estimator interface. Inert in this release: no tables, no recommendation. */
23
- export declare const ESTIMATOR_VERSION = "inert-v1";
@@ -1,46 +0,0 @@
1
- "use strict";
2
- /**
3
- * Every version string the Companion stamps onto a record.
4
- *
5
- * Ground rule 3: a derived record without the version of the code that produced
6
- * it cannot be restated and cannot serve as evidence. These are bumped when the
7
- * behavior behind them changes, never on a whim, because consumers select by
8
- * version and old records keep meaning what they meant.
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.ESTIMATOR_VERSION = exports.POLICY_VERSION = exports.CLASSIFIER_VERSION = exports.COMPRISM_VERSION = void 0;
12
- /**
13
- * The package version. Stamped on every row the Companion writes.
14
- *
15
- * Read from the package's own manifest rather than typed here. It was typed
16
- * here once, and a published 0.1.1 went on reporting itself as 0.1.0 to every
17
- * customer and onto every record it wrote, which is the one number a version
18
- * stamp exists to get right. A literal drifts the moment `npm version` runs;
19
- * the manifest cannot.
20
- */
21
- function packageVersion() {
22
- try {
23
- // Two levels up from out/lib, which is where the manifest sits in both the
24
- // built package and a checkout.
25
- // eslint-disable-next-line @typescript-eslint/no-var-requires
26
- return String(require('../../package.json').version || '0.0.0');
27
- }
28
- catch {
29
- return '0.0.0';
30
- }
31
- }
32
- exports.COMPRISM_VERSION = packageVersion();
33
- /** The structural classifier. Bump when a signal is added, removed or retuned. */
34
- exports.CLASSIFIER_VERSION = 'structural-v1';
35
- /**
36
- * The dispatch policy.
37
- *
38
- * `naive` is the honest name for what this release does: the first eligible
39
- * candidate for the structural band, with no estimate consulted. When the model
40
- * program delivers tables, decisions made under this version stay permanently
41
- * distinguishable from decisions made under a learned one - which is exactly
42
- * why the version is on the record rather than in a changelog.
43
- */
44
- exports.POLICY_VERSION = 'naive-v1';
45
- /** The estimator interface. Inert in this release: no tables, no recommendation. */
46
- exports.ESTIMATOR_VERSION = 'inert-v1';
@@ -1,49 +0,0 @@
1
- export { discard, missing, recorder, start } from '../machine/voice/record';
2
- export type { Recorder, Recording } from '../machine/voice/record';
3
- /** Live dictation in progress, on the Mac's own recogniser. */
4
- export interface LiveDictation {
5
- /** The loudness now, 0 to 1. */
6
- level: () => number;
7
- /** The words so far. */
8
- words: () => string;
9
- /** Stop listening and get the final words, or null when it could not listen. */
10
- stop: () => Promise<string | null>;
11
- /** Why it could not listen, when it could not. */
12
- problem: () => string;
13
- }
14
- /**
15
- * Words as they are spoken, the way the web app shows them.
16
- *
17
- * Nothing is recorded to a file and nothing leaves the machine: the Mac's own
18
- * recogniser listens and reports what it hears, several times a second.
19
- * Returns null where there is no helper, and the caller records and has the
20
- * server write it down instead, as before.
21
- */
22
- export declare function listenLive(language?: string): LiveDictation | null;
23
- /**
24
- * How loud the last tenth of a second was, from 0 to 1.
25
- *
26
- * Read off the file as it is written, so somebody speaking sees the meter move
27
- * and knows they are being heard, before a single word has come back. Sixteen
28
- * bit mono at 16 kHz is 3,200 bytes a tenth of a second.
29
- */
30
- export declare function level(file: string): number;
31
- /**
32
- * What has been said so far, as a WAV file a transcriber can read.
33
- *
34
- * The recorder writes the header's lengths only when it stops, so a copy taken
35
- * mid recording claims no audio at all. The copy gets the lengths of what is
36
- * actually there. Returns null until there is at least half a second to send.
37
- */
38
- export declare function soFar(file: string): string | null;
39
- /**
40
- * The words in a recording, according to our server.
41
- *
42
- * Every refusal comes back as a sentence somebody can act on, because the
43
- * commonest one by far is a tenant holding only an Anthropic key, and
44
- * "transcription failed" would send that person looking at their microphone.
45
- */
46
- export declare function transcribe(baseUrl: string, credential: string, file: string): Promise<{
47
- text: string;
48
- provider: string;
49
- }>;
package/out/lib/voice.js DELETED
@@ -1,236 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.start = exports.recorder = exports.missing = exports.discard = void 0;
37
- exports.listenLive = listenLive;
38
- exports.level = level;
39
- exports.soFar = soFar;
40
- exports.transcribe = transcribe;
41
- /**
42
- * Saying a request instead of typing it.
43
- *
44
- * ── The split, and why it is where it is ──────────────────────────────────
45
- *
46
- * This file records. It does not transcribe, and it never will: the published
47
- * package holds no model logic, no vendor address and no provider key, and a
48
- * ship check enforces that. The recording goes to our server, the server asks a
49
- * vendor, and the words come back. See `services/transcription.py`.
50
- *
51
- * ── Recording without adding a dependency ─────────────────────────────────
52
- *
53
- * This package has no dependencies at all, deliberately, and a microphone
54
- * library would be the first - a compiled one, on every customer's laptop, for
55
- * a feature most of them will use occasionally. So it drives a recording tool
56
- * the machine already has.
57
- *
58
- * That is an honest trade and it has a cost worth stating: macOS ships no
59
- * command line recorder, so on a Mac with neither ffmpeg nor sox this does not
60
- * work. The answer to that is to say so in one sentence naming the one command
61
- * that fixes it, which is what `missing` returns. What it must never do is fail
62
- * quietly and leave somebody holding a key wondering whether we heard them.
63
- *
64
- * ── Stopping ──────────────────────────────────────────────────────────────
65
- *
66
- * Every one of these tools writes a WAV header that is only correct once the
67
- * recording ends properly, so stopping means an interrupt and then WAITING for
68
- * the tool to finish writing. Killing it outright leaves a file whose header
69
- * claims a length it does not have, which every transcriber reads as silence.
70
- */
71
- const node_child_process_1 = require("node:child_process");
72
- const fs = __importStar(require("node:fs"));
73
- const path = __importStar(require("node:path"));
74
- const gateway_1 = require("./gateway");
75
- var record_1 = require("../machine/voice/record");
76
- Object.defineProperty(exports, "discard", { enumerable: true, get: function () { return record_1.discard; } });
77
- Object.defineProperty(exports, "missing", { enumerable: true, get: function () { return record_1.missing; } });
78
- Object.defineProperty(exports, "recorder", { enumerable: true, get: function () { return record_1.recorder; } });
79
- Object.defineProperty(exports, "start", { enumerable: true, get: function () { return record_1.start; } });
80
- /** The helper built beside this file on a Mac, when there is one. */
81
- function helper() {
82
- if (process.platform !== 'darwin')
83
- return null;
84
- const p = path.join(__dirname, '..', 'native', 'dictate');
85
- return fs.existsSync(p) ? p : null;
86
- }
87
- /**
88
- * Words as they are spoken, the way the web app shows them.
89
- *
90
- * Nothing is recorded to a file and nothing leaves the machine: the Mac's own
91
- * recogniser listens and reports what it hears, several times a second.
92
- * Returns null where there is no helper, and the caller records and has the
93
- * server write it down instead, as before.
94
- */
95
- function listenLive(language = 'en-US') {
96
- const bin = helper();
97
- if (!bin)
98
- return null;
99
- const child = (0, node_child_process_1.spawn)(bin, [language], { stdio: ['pipe', 'pipe', 'ignore'] });
100
- let loud = 0;
101
- let heard = '';
102
- let final = null;
103
- let why = '';
104
- let rest = '';
105
- const ended = new Promise((resolve) => child.once('close', () => resolve()));
106
- child.stdout?.on('data', (chunk) => {
107
- rest += chunk.toString('utf8');
108
- const lines = rest.split('\n');
109
- rest = lines.pop() ?? '';
110
- for (const line of lines) {
111
- const kind = line.slice(0, 1);
112
- const text = line.slice(2);
113
- if (kind === 'L')
114
- loud = Number(text) || 0;
115
- else if (kind === 'P')
116
- heard = text;
117
- else if (kind === 'F')
118
- final = text;
119
- else if (kind === 'E')
120
- why = text;
121
- }
122
- });
123
- // The helper never outlives the session.
124
- const abandon = () => { try {
125
- child.kill('SIGKILL');
126
- }
127
- catch { /* gone */ } };
128
- process.once('exit', abandon);
129
- return {
130
- level: () => loud,
131
- words: () => heard,
132
- problem: () => why,
133
- stop: async () => {
134
- // Closing its input is "Enter was pressed": it says its final words and ends.
135
- try {
136
- child.stdin?.end();
137
- }
138
- catch { /* gone */ }
139
- const timeout = new Promise((resolve) => setTimeout(resolve, 4000).unref());
140
- await Promise.race([ended, timeout]);
141
- abandon();
142
- process.off('exit', abandon);
143
- if (why && !final && !heard)
144
- return null;
145
- return (final ?? heard).trim();
146
- },
147
- };
148
- }
149
- /** Where the samples start in a WAV file this recorder wrote, or -1. */
150
- function dataStart(buf) {
151
- const at = buf.indexOf('data', 12, 'ascii');
152
- return at < 0 ? -1 : at + 8;
153
- }
154
- /**
155
- * How loud the last tenth of a second was, from 0 to 1.
156
- *
157
- * Read off the file as it is written, so somebody speaking sees the meter move
158
- * and knows they are being heard, before a single word has come back. Sixteen
159
- * bit mono at 16 kHz is 3,200 bytes a tenth of a second.
160
- */
161
- function level(file) {
162
- try {
163
- const size = fs.statSync(file).size;
164
- const n = 3200;
165
- if (size < 44 + n)
166
- return 0;
167
- const fd = fs.openSync(file, 'r');
168
- const buf = Buffer.alloc(n);
169
- fs.readSync(fd, buf, 0, n, size - n - (size - 44) % 2);
170
- fs.closeSync(fd);
171
- let sum = 0;
172
- for (let i = 0; i + 1 < n; i += 2) {
173
- const s = buf.readInt16LE(i) / 32768;
174
- sum += s * s;
175
- }
176
- const rms = Math.sqrt(sum / (n / 2));
177
- // Speech sits roughly between -50 dB (quiet room) and -10 dB (close and loud).
178
- const db = 20 * Math.log10(rms || 1e-9);
179
- return Math.max(0, Math.min(1, (db + 50) / 40));
180
- }
181
- catch {
182
- return 0;
183
- }
184
- }
185
- /**
186
- * What has been said so far, as a WAV file a transcriber can read.
187
- *
188
- * The recorder writes the header's lengths only when it stops, so a copy taken
189
- * mid recording claims no audio at all. The copy gets the lengths of what is
190
- * actually there. Returns null until there is at least half a second to send.
191
- */
192
- function soFar(file) {
193
- try {
194
- const buf = fs.readFileSync(file);
195
- const start = dataStart(buf);
196
- if (start < 0 || buf.length - start < 16000)
197
- return null;
198
- const usable = buf.length - ((buf.length - start) % 2);
199
- const copy = Buffer.from(buf.subarray(0, usable));
200
- copy.writeUInt32LE(usable - 8, 4);
201
- copy.writeUInt32LE(usable - start, start - 4);
202
- const out = path.join(path.dirname(file), 'so-far.wav');
203
- fs.writeFileSync(out, copy);
204
- return out;
205
- }
206
- catch {
207
- return null;
208
- }
209
- }
210
- /**
211
- * The words in a recording, according to our server.
212
- *
213
- * Every refusal comes back as a sentence somebody can act on, because the
214
- * commonest one by far is a tenant holding only an Anthropic key, and
215
- * "transcription failed" would send that person looking at their microphone.
216
- */
217
- async function transcribe(baseUrl, credential, file) {
218
- const form = new FormData();
219
- form.append('audio', new Blob([fs.readFileSync(file)], { type: 'audio/wav' }), 'said.wav');
220
- // Permission first, from the one service, which also names the address. The
221
- // recording itself does not travel through that door: a JSON request is the
222
- // wrong shape for audio. The decision is made there and nowhere else.
223
- const granted = await (0, gateway_1.ask)({ intent: 'transcribe', prompt: '' });
224
- const pass = granted.ok && granted.served !== false ? granted.upload : null;
225
- if (granted.ok && granted.served !== false && !pass) {
226
- throw new Error(granted.message || 'your organization would not allow that recording');
227
- }
228
- const where = pass?.upload_path || '/api/v1/agent/transcribe';
229
- const res = await fetch(`${baseUrl.replace(/\/+$/, '')}${where}${pass?.ticket ? `?ticket=${encodeURIComponent(pass.ticket)}` : ''}`, { method: 'POST', headers: { Authorization: `Bearer ${credential}` }, body: form });
230
- if (!res.ok) {
231
- const body = await res.json().catch(() => ({}));
232
- throw new Error(body.detail || `The server said ${res.status}.`);
233
- }
234
- const row = await res.json();
235
- return { text: row.text, provider: row.provider };
236
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * The few words the published command line tool says on its own, in one place.
3
- *
4
- * Everything about the work arrives from the service already worded (rule 17).
5
- * What is left here is what the tool must say when the service, a file or the
6
- * operating system gives it nothing to say: a refused address, a file it cannot
7
- * read, a call that failed without a reason. Same shape as the editor's
8
- * `i18n.ts` and the desktop app's `labels.js`.
9
- */
10
- declare const EN: {
11
- readonly connectorNotStarted: "the connector could not be started";
12
- readonly addressRefused: "the organization address was refused";
13
- readonly fileNotFound: "not found: {{file}}";
14
- readonly fileNoPermission: "cannot read {{file}}: permission denied";
15
- readonly providerCallFailed: "provider call failed";
16
- readonly somethingWrong: "something went wrong";
17
- };
18
- export type WordKey = keyof typeof EN;
19
- export declare function word(key: WordKey, vars?: Record<string, string | number>): string;
20
- export {};