@illuminis/comprism 0.1.8 → 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 -1232
  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
@@ -1,94 +0,0 @@
1
- import type { ExecutionMode, FooterConfig, Provider } from './types';
2
- export { HOME_DIR_NAME } from '../machine/runtime/home';
3
- import { homeDir } from '../machine/runtime/home';
4
- export { homeDir };
5
- export interface ContentPolicy {
6
- /**
7
- * Store request and response text alongside the records. Default false, and
8
- * every screen and report is built to work without it. Turning it on is a
9
- * tenant's explicit decision, never a default and never a nudge.
10
- */
11
- storeText: boolean;
12
- }
13
- export interface ProviderConfig {
14
- enabled: boolean;
15
- /** Shell command printing the key on stdout. Its OUTPUT is never stored. */
16
- keyCommand?: string;
17
- }
18
- export interface Config {
19
- config_version: 1;
20
- /** Who the records are attributed to locally. Never an email by default. */
21
- user: string;
22
- mode: ExecutionMode;
23
- providers: Record<Provider, ProviderConfig>;
24
- /** Model ids the policy may consider. Empty means the whole catalog. */
25
- allowedModels: string[];
26
- /**
27
- * The model a session and the SDK dispatch unless the caller names another.
28
- *
29
- * This exists because of a real failure. The client used to dispatch the
30
- * cheapest catalog entry for whatever band the structural classifier
31
- * guessed - so a short research question was banded `simple`, answered by the
32
- * cheapest model, and the answer was the plausible-but-useless kind this
33
- * entire product exists to warn people about.
34
- *
35
- * Two things were wrong with that. It contradicted the release's own rule
36
- * that v1 observes and never alters dispatch. And it made a cost-quality
37
- * trade-off on the user's behalf using exactly the evidence the estimator
38
- * refuses to guess from - none. With no evidence, the honest default is a
39
- * capable model the user chose once, not the cheapest one we inferred.
40
- */
41
- defaultModel: string;
42
- contentPolicy: ContentPolicy;
43
- /**
44
- * Deployment context the tenant declares rather than the product infers.
45
- *
46
- * Everything here is optional and inferred from the workspace when absent.
47
- * `verification` is the one worth setting by hand: whether anything checks the
48
- * output before it reaches someone outside the company is what decides how
49
- * expensive a wrong answer is, and a person knows it where a heuristic guesses.
50
- */
51
- context: {
52
- role?: string | null;
53
- workspace?: string | null;
54
- application?: string | null;
55
- verification?: 'automated_tests' | 'human_review' | 'none' | 'unknown';
56
- };
57
- /** Port the local proxy listens on. */
58
- proxyPort: number;
59
- /**
60
- * The stats footer the proxy appends to a completed answer.
61
- *
62
- * The proxy is the only surface with no result object and no widget area, so
63
- * it is the only one that writes into the message. Turning this off restores
64
- * byte-faithful passthrough in both directions; inbound stripping still runs,
65
- * because a footer already sitting in someone's history has to come out
66
- * whether or not new ones are being written.
67
- */
68
- footer: FooterConfig;
69
- created: string;
70
- updated: string;
71
- }
72
- export type Keys = Partial<Record<Provider, string>>;
73
- /**
74
- * Create the home directory at mode 700 if it is not there.
75
- *
76
- * 700 rather than the default 755: other local accounts have no business
77
- * reading someone's work records, and a directory created world-readable is
78
- * never noticed afterwards.
79
- */
80
- export declare function ensureHome(): string;
81
- export declare function configPath(): string;
82
- export declare function defaultConfig(): Config;
83
- export declare function loadConfig(): Config;
84
- export declare function saveConfig(cfg: Config): void;
85
- /**
86
- * Resolve keys for every enabled provider. Environment first, then the
87
- * configured key command. A provider whose key does not resolve is simply not
88
- * available; that is not an error until something tries to call it.
89
- */
90
- export declare function resolveKeys(cfg: Config): Keys;
91
- export declare function availableProviders(keys: Keys): Provider[];
92
- /** Where the key for a provider would come from, for `setup` to report. */
93
- export declare function keySource(cfg: Config, provider: Provider): 'env' | 'command' | 'none';
94
- export declare function envVarName(provider: Provider): string;
package/out/lib/config.js DELETED
@@ -1,197 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.homeDir = exports.HOME_DIR_NAME = void 0;
7
- exports.ensureHome = ensureHome;
8
- exports.configPath = configPath;
9
- exports.defaultConfig = defaultConfig;
10
- exports.loadConfig = loadConfig;
11
- exports.saveConfig = saveConfig;
12
- exports.resolveKeys = resolveKeys;
13
- exports.availableProviders = availableProviders;
14
- exports.keySource = keySource;
15
- exports.envVarName = envVarName;
16
- /**
17
- * Home directory, configuration and key resolution.
18
- *
19
- * ── Keys are never written. Anywhere. ──────────────────────────────────────
20
- *
21
- * The frozen spec (0.6) says keys resolve "from env first, then config file".
22
- * This implementation keeps the first half and drops the second, deliberately,
23
- * and it is a strengthening rather than a simplification: nothing about the
24
- * mechanism changes, one storage location is removed.
25
- *
26
- * The reason is that Phase 1's acceptance list contains an absolute canary -
27
- * "keys never appear in any file or log". A config file that may hold a key
28
- * makes that test conditional on which file you look in, and a security
29
- * property that holds in most files is not a security property. So:
30
- *
31
- * 1. `ANTHROPIC_API_KEY` / `OPENAI_API_KEY` from the environment, or
32
- * 2. a `keyCommand` the user configures - a shell command that PRINTS the key
33
- * (`op read ...`, `aws secretsmanager get-secret-value ...`). The command
34
- * is stored; its output never is.
35
- *
36
- * That covers the case the config-file fallback existed for - a user who does
37
- * not want long-lived secrets in their shell profile - without the Companion
38
- * ever holding a secret at rest.
39
- */
40
- const node_fs_1 = __importDefault(require("node:fs"));
41
- const node_os_1 = __importDefault(require("node:os"));
42
- const node_path_1 = __importDefault(require("node:path"));
43
- var home_1 = require("../machine/runtime/home");
44
- Object.defineProperty(exports, "HOME_DIR_NAME", { enumerable: true, get: function () { return home_1.HOME_DIR_NAME; } });
45
- const home_2 = require("../machine/runtime/home");
46
- Object.defineProperty(exports, "homeDir", { enumerable: true, get: function () { return home_2.homeDir; } });
47
- /**
48
- * Create the home directory at mode 700 if it is not there.
49
- *
50
- * 700 rather than the default 755: other local accounts have no business
51
- * reading someone's work records, and a directory created world-readable is
52
- * never noticed afterwards.
53
- */
54
- function ensureHome() {
55
- const dir = (0, home_2.homeDir)();
56
- node_fs_1.default.mkdirSync(dir, { recursive: true, mode: 0o700 });
57
- try {
58
- node_fs_1.default.chmodSync(dir, 0o700);
59
- }
60
- catch {
61
- /* a filesystem that cannot chmod is not a reason to fail a request */
62
- }
63
- return dir;
64
- }
65
- function configPath() {
66
- return node_path_1.default.join((0, home_2.homeDir)(), 'config.json');
67
- }
68
- function defaultConfig() {
69
- const now = new Date().toISOString();
70
- return {
71
- config_version: 1,
72
- user: node_os_1.default.userInfo().username,
73
- mode: 'monitor',
74
- providers: {
75
- anthropic: { enabled: true },
76
- openai: { enabled: true },
77
- },
78
- allowedModels: [],
79
- // Balanced and capable. The band is still recorded on every decision; it
80
- // simply does not drive dispatch while the estimator has nothing to say.
81
- defaultModel: 'claude-sonnet-5',
82
- // ON by default, and the customer turns it off. Their work lives on our
83
- // servers exactly as their other business data lives on a vendor's, and a
84
- // product that cannot see the work cannot show them what finishing it cost
85
- // or improve at predicting it. Opting out is one setting on their account,
86
- // not a request they have to make of us.
87
- contentPolicy: { storeText: true },
88
- context: {},
89
- proxyPort: 8787,
90
- footer: {
91
- enabled: true,
92
- template: 'completion',
93
- // `auto` is the next capability band up on the same provider - the
94
- // comparison a person actually makes. A tenant that has mandated one
95
- // model everywhere names it here instead.
96
- baselineModel: 'auto',
97
- tenant: '',
98
- // Production by default. Localhost is opt-in for development via
99
- // COMPRISM_DEV=1, so a fresh install talks to the real tenant and a
100
- // receipt's link goes somewhere a person can actually open.
101
- portal: {
102
- useDev: process.env.COMPRISM_DEV === '1',
103
- devUrl: 'http://localhost:5182',
104
- domain: 'completionprism.illuminis.ai',
105
- },
106
- pricing: {},
107
- },
108
- created: now,
109
- updated: now,
110
- };
111
- }
112
- function loadConfig() {
113
- const p = configPath();
114
- if (!node_fs_1.default.existsSync(p))
115
- return defaultConfig();
116
- try {
117
- const raw = JSON.parse(node_fs_1.default.readFileSync(p, 'utf8'));
118
- const base = defaultConfig();
119
- return {
120
- ...base,
121
- ...raw,
122
- providers: { ...base.providers, ...(raw.providers || {}) },
123
- contentPolicy: { ...base.contentPolicy, ...(raw.contentPolicy || {}) },
124
- context: { ...base.context, ...(raw.context || {}) },
125
- footer: {
126
- ...base.footer,
127
- ...(raw.footer || {}),
128
- // Merged rather than replaced: a tenant who states their negotiated
129
- // price for one model still gets the catalog for the rest.
130
- pricing: { ...base.footer.pricing, ...(raw.footer?.pricing || {}) },
131
- },
132
- };
133
- }
134
- catch {
135
- // A corrupt config must not stop someone working. Fail open to defaults.
136
- return defaultConfig();
137
- }
138
- }
139
- function saveConfig(cfg) {
140
- ensureHome();
141
- const out = { ...cfg, updated: new Date().toISOString() };
142
- const p = configPath();
143
- node_fs_1.default.writeFileSync(p, `${JSON.stringify(out, null, 2)}\n`, { mode: 0o600 });
144
- }
145
- const ENV_VAR = {
146
- anthropic: 'ANTHROPIC_API_KEY',
147
- openai: 'OPENAI_API_KEY',
148
- };
149
- /**
150
- * Resolve keys for every enabled provider. Environment first, then the
151
- * configured key command. A provider whose key does not resolve is simply not
152
- * available; that is not an error until something tries to call it.
153
- */
154
- function resolveKeys(cfg) {
155
- const keys = {};
156
- for (const provider of Object.keys(ENV_VAR)) {
157
- if (!cfg.providers[provider]?.enabled)
158
- continue;
159
- const fromEnv = process.env[ENV_VAR[provider]];
160
- if (fromEnv && fromEnv.trim()) {
161
- keys[provider] = fromEnv.trim();
162
- continue;
163
- }
164
- // NO SHELL COMMAND IS RUN TO FETCH A KEY.
165
- //
166
- // A `keyCommand` was a stored shell line that printed a vendor credential,
167
- // and the tool used to write one automatically after importing keys from a
168
- // file. Running it meant the machine went and fetched a secret locally on
169
- // every call, which is the behavior the owner ruled out on 17 September
170
- // 2026, and it meant a settings file on a laptop contained a working
171
- // instruction for obtaining somebody's vendor credentials.
172
- //
173
- // An existing `keyCommand` left over from an older copy of the tool is now
174
- // simply ignored rather than obeyed. The field stays in the type so that
175
- // reading an older settings file does not fail; nothing acts on it.
176
- //
177
- // What remains here is the environment variable, and it has exactly ONE
178
- // job: DISCOVERY, so `comprism keys` can offer to store a key the person
179
- // already has when their ACCOUNT has none. It is never the answer to
180
- // "does this account have a key", and it is never sent with a question.
181
- }
182
- return keys;
183
- }
184
- function availableProviders(keys) {
185
- return Object.keys(keys).filter((p) => !!keys[p]);
186
- }
187
- /** Where the key for a provider would come from, for `setup` to report. */
188
- function keySource(cfg, provider) {
189
- if (process.env[ENV_VAR[provider]]?.trim())
190
- return 'env';
191
- if (cfg.providers[provider]?.keyCommand?.trim())
192
- return 'command';
193
- return 'none';
194
- }
195
- function envVarName(provider) {
196
- return ENV_VAR[provider];
197
- }
@@ -1,73 +0,0 @@
1
- export interface Connection {
2
- /** Tenant base URL, e.g. https://acme.completionprism.ai */
3
- url: string;
4
- /** Our own session token for that tenant. Never a provider key. */
5
- token: string;
6
- /**
7
- * The workspace key this machine presents on every intercepted request.
8
- *
9
- * A different object from `token` and deliberately so. The session token is
10
- * short-lived and belongs to a browser sign-in; this is a long-lived machine
11
- * credential minted for this laptop, listed in the portal beside every other
12
- * machine, and revocable on its own without signing anybody out. Without one,
13
- * the tenant refuses interception - so the install writes NO base URL at all
14
- * rather than pointing tools at a door that will turn them away.
15
- */
16
- workspaceKey?: string;
17
- /** Only needed on localhost, where there is no subdomain to resolve. */
18
- tenant?: string;
19
- /** Minutes between unattended syncs. 0 turns automatic sync off. */
20
- everyMinutes: number;
21
- /** When a sync last succeeded, so `status` can say how fresh the portal is. */
22
- lastSyncedAt?: string;
23
- /** The last failure, kept so a quiet problem is still a visible one. */
24
- lastError?: string;
25
- connectedAt: string;
26
- }
27
- export declare function connectionPath(): string;
28
- export declare function readConnection(): Connection | null;
29
- /**
30
- * Is this address a machine on somebody's desk rather than a workspace.
31
- *
32
- * Loopback, the link-local range, and the three private network ranges. A
33
- * hostname that is not an address at all is a workspace by definition, because
34
- * nobody's laptop is reachable by name from anywhere else.
35
- */
36
- export declare function isLocalAddress(url: string): boolean;
37
- /**
38
- * The fence, and it sits at the moment of WRITING rather than of reading.
39
- *
40
- * ── The incident ──────────────────────────────────────────────────────────
41
- *
42
- * On 17 September 2026 a developer's own machine had this file pointing at
43
- * `http://localhost:8009`. Nothing listened there, so every call failed, and
44
- * the product told him his account had no provider keys, no plan and no name.
45
- * Four keys were stored and active the whole time.
46
- *
47
- * Two separate mechanisms put that address there, and either alone is enough to
48
- * do it again: the workspace lookup preferred a laptop when a development
49
- * environment variable was set, and a development server answers the "where do
50
- * I sign in" question with its own laptop address, which the tool then believed.
51
- *
52
- * ── Why the fence is here and not at every read ───────────────────────────
53
- *
54
- * The bad address enters ONCE and is then believed for ever. Checking at read
55
- * time means checking in eleven places and missing one. Checking here means a
56
- * server's answer can never install a laptop address, whatever the server says,
57
- * and a person who genuinely wants one has to say so in the same breath.
58
- *
59
- * `typed` is true only when the person put the address on the command line in
60
- * this same run. Not an environment variable, not a stored file, not a server's
61
- * reply. Those are the three routes that produced the fault.
62
- */
63
- export declare function writeConnection(connection: Connection, typed?: boolean): void;
64
- export declare function clearConnection(): boolean;
65
- /** Record the outcome of a sync without disturbing anything else. */
66
- export declare function noteSync(ok: boolean, error?: string): void;
67
- /**
68
- * Why the last enrollment attempt failed, in the tenant's own words.
69
- *
70
- * A module-level value rather than a thrown error, because failing to enrol is
71
- * NOT a failure to sign in: the person is signed in either way, and the
72
- * difference is only whether this machine can ask for work yet.
73
- */
@@ -1,188 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.connectionPath = connectionPath;
7
- exports.readConnection = readConnection;
8
- exports.isLocalAddress = isLocalAddress;
9
- exports.writeConnection = writeConnection;
10
- exports.clearConnection = clearConnection;
11
- exports.noteSync = noteSync;
12
- /**
13
- * The tenant connection: told to us once, then never asked for again.
14
- *
15
- * ── Why this file exists ──────────────────────────────────────────────────
16
- *
17
- * Sync started life as a command you ran by hand with a URL and a token on the
18
- * line. That is defensible for a one-off and indefensible as a product: it
19
- * makes the person the transport. Work recorded on a laptop only reaches the
20
- * portal if somebody remembers to type something, so the portal is permanently
21
- * behind, and "why is my session not showing up" becomes the commonest question
22
- * about a product whose entire pitch is completeness.
23
- *
24
- * So the connection is stored once, and the recorder carries the records itself.
25
- *
26
- * ── What is stored, and the line that is not crossed ──────────────────────
27
- *
28
- * The endpoint, the tenant and OUR OWN session token, in a 0600 file inside the
29
- * 0700 home directory. That is a different object from a provider API key, and
30
- * the distinction is deliberate rather than convenient:
31
- *
32
- * - A provider key (Anthropic, OpenAI) is the customer's money. It is never
33
- * written to disk by this product, in any file, ever. It is resolved from
34
- * the environment or a key command at the moment it is needed.
35
- * - A tenant token is a credential for OUR api, scoped to one tenant, held by
36
- * the same person who owns the records it carries, and revocable by them.
37
- * Storing it is what makes unattended sync possible at all.
38
- *
39
- * An expired token is not worth interrupting anyone over: the recorder keeps
40
- * recording, the local store keeps its evidence, and the next `comprism connect`
41
- * catches everything up. Nothing is lost by a failed sync, because sync is
42
- * additive and never deletes the local record.
43
- */
44
- const node_fs_1 = __importDefault(require("node:fs"));
45
- const node_path_1 = __importDefault(require("node:path"));
46
- const config_1 = require("./config");
47
- function connectionPath() {
48
- return node_path_1.default.join((0, config_1.homeDir)(), 'connection.json');
49
- }
50
- function readConnection() {
51
- try {
52
- const parsed = JSON.parse(node_fs_1.default.readFileSync(connectionPath(), 'utf8'));
53
- // A machine enrolled by the one-line installer has a workspace key and no
54
- // session token, and that is a complete, usable connection: it can be
55
- // intercepted and measured. Requiring a token here silently discarded it.
56
- return parsed.url && (parsed.token || parsed.workspaceKey) ? parsed : null;
57
- }
58
- catch {
59
- return null;
60
- }
61
- }
62
- /**
63
- * Is this address a machine on somebody's desk rather than a workspace.
64
- *
65
- * Loopback, the link-local range, and the three private network ranges. A
66
- * hostname that is not an address at all is a workspace by definition, because
67
- * nobody's laptop is reachable by name from anywhere else.
68
- */
69
- function isLocalAddress(url) {
70
- let host;
71
- try {
72
- host = new URL(url).hostname.toLowerCase();
73
- }
74
- catch {
75
- // UNPARSEABLE COUNTS AS LOCAL.
76
- //
77
- // This returned false, which meant anything the URL parser could not read
78
- // was waved through as a workspace. `localhost:8009` with no scheme is
79
- // exactly such a string, and it is the form our own help text suggests. A
80
- // fence that opens when it cannot see is not a fence.
81
- return true;
82
- }
83
- // `new URL` keeps IPv6 hosts in brackets. Strip them before comparing.
84
- if (host.startsWith('[') && host.endsWith(']'))
85
- host = host.slice(1, -1);
86
- if (!host)
87
- return true;
88
- if (host === 'localhost' || host.endsWith('.local') || host.endsWith('.localhost'))
89
- return true;
90
- if (host === '::1' || host === '0:0:0:0:0:0:0:1' || host === '::')
91
- return true;
92
- // Unique local addresses, fc00::/7. Both halves of the range.
93
- if (/^f[cd][0-9a-f]{0,2}:/.test(host))
94
- return true;
95
- // IPv4-mapped IPv6, ::ffff:127.0.0.1, so the v4 rules below still apply.
96
- const mapped = /^::ffff:(\d{1,3}(?:\.\d{1,3}){3})$/.exec(host);
97
- if (mapped && mapped[1])
98
- host = mapped[1];
99
- // Every dotted form node accepts, including the short ones: `127.1` is a
100
- // loopback address and reads as a hostname to a naive four-part pattern.
101
- const parts = host.split('.');
102
- if (parts.length < 2 || parts.length > 4)
103
- return false;
104
- if (!parts.every((p) => /^\d{1,10}$/.test(p)))
105
- return false;
106
- const a = Number(parts[0] ?? '');
107
- const b = parts.length >= 3 ? Number(parts[1] ?? '') : 0;
108
- return a === 0 // 0.0.0.0 and anything in 0/8
109
- || a === 127 // loopback, including 127.1
110
- || a === 10 // private
111
- || (a === 172 && b >= 16 && b <= 31) // private
112
- || (a === 192 && b === 168) // private
113
- || (a === 169 && b === 254); // link-local
114
- }
115
- /**
116
- * The fence, and it sits at the moment of WRITING rather than of reading.
117
- *
118
- * ── The incident ──────────────────────────────────────────────────────────
119
- *
120
- * On 17 September 2026 a developer's own machine had this file pointing at
121
- * `http://localhost:8009`. Nothing listened there, so every call failed, and
122
- * the product told him his account had no provider keys, no plan and no name.
123
- * Four keys were stored and active the whole time.
124
- *
125
- * Two separate mechanisms put that address there, and either alone is enough to
126
- * do it again: the workspace lookup preferred a laptop when a development
127
- * environment variable was set, and a development server answers the "where do
128
- * I sign in" question with its own laptop address, which the tool then believed.
129
- *
130
- * ── Why the fence is here and not at every read ───────────────────────────
131
- *
132
- * The bad address enters ONCE and is then believed for ever. Checking at read
133
- * time means checking in eleven places and missing one. Checking here means a
134
- * server's answer can never install a laptop address, whatever the server says,
135
- * and a person who genuinely wants one has to say so in the same breath.
136
- *
137
- * `typed` is true only when the person put the address on the command line in
138
- * this same run. Not an environment variable, not a stored file, not a server's
139
- * reply. Those are the three routes that produced the fault.
140
- */
141
- function writeConnection(connection, typed = false) {
142
- if (!typed && isLocalAddress(connection.url)) {
143
- throw new Error(`refusing to point this machine at ${connection.url}, which is this computer `
144
- + 'rather than an organization. Pass it with --workspace if that is genuinely what you want.');
145
- }
146
- (0, config_1.ensureHome)();
147
- node_fs_1.default.writeFileSync(connectionPath(), `${JSON.stringify(connection, null, 2)}\n`, { mode: 0o600 });
148
- try {
149
- node_fs_1.default.chmodSync(connectionPath(), 0o600);
150
- }
151
- catch {
152
- /* a filesystem that cannot chmod is not a reason to fail */
153
- }
154
- }
155
- function clearConnection() {
156
- try {
157
- node_fs_1.default.rmSync(connectionPath(), { force: true });
158
- return true;
159
- }
160
- catch {
161
- return false;
162
- }
163
- }
164
- /** Record the outcome of a sync without disturbing anything else. */
165
- function noteSync(ok, error) {
166
- const connection = readConnection();
167
- if (!connection)
168
- return;
169
- if (ok) {
170
- connection.lastSyncedAt = new Date().toISOString();
171
- delete connection.lastError;
172
- }
173
- else {
174
- connection.lastError = error || 'sync failed';
175
- }
176
- // `true`: this is bookkeeping on a connection that already exists and was
177
- // already allowed. The fence is about how an address gets INSTALLED, and
178
- // refusing a sync timestamp on a machine legitimately pointed at a local
179
- // server would throw out of a background timer nobody is catching.
180
- writeConnection(connection, true);
181
- }
182
- /**
183
- * Why the last enrollment attempt failed, in the tenant's own words.
184
- *
185
- * A module-level value rather than a thrown error, because failing to enrol is
186
- * NOT a failure to sign in: the person is signed in either way, and the
187
- * difference is only whether this machine can ask for work yet.
188
- */
@@ -1,22 +0,0 @@
1
- import type { WithheldReason } from './types';
2
- export interface LocalVerdict {
3
- recommendation: string | null;
4
- withheld: WithheldReason | null;
5
- withheldDetail?: string;
6
- breakdown: Record<string, never>;
7
- tableHashes: Record<string, never>;
8
- baselineVersion: string | null;
9
- policyVersion: string;
10
- estimatorVersion: string;
11
- /** True only on a close corpus match. Every surface must flag the rest. */
12
- confident: boolean;
13
- /** Which rung of the lookup answered, carried for provenance. */
14
- rung: string | null;
15
- }
16
- export declare const POLICY_VERSION = "served-v1";
17
- export declare function decide(input: {
18
- prompt: string;
19
- callingModel?: string;
20
- contextTokens?: number;
21
- freshContext?: boolean;
22
- }): Promise<LocalVerdict>;
@@ -1,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.POLICY_VERSION = void 0;
4
- exports.decide = decide;
5
- /**
6
- * The decision, as this tool now gets it: by asking.
7
- *
8
- * ── What this replaced ────────────────────────────────────────────────────
9
- *
10
- * `estimator.ts` computed the decision here, on the customer's machine, from
11
- * tables and curves that are the product's whole method. That file stays in the
12
- * repository because our own tests read it, and it is excluded from every
13
- * published package, because a package on a public registry is readable forever
14
- * by anyone who installs it.
15
- *
16
- * So the interception paths call this instead. It asks our server and returns
17
- * the SAME SHAPE the call sites already expect, which is why swapping it in
18
- * changed one import line in each of them rather than rewriting three files.
19
- *
20
- * The maths-bearing fields come back empty on purpose. A breakdown per candidate
21
- * and the hashes of the tables consulted are the reasoning, and the reasoning
22
- * stays on the server where it is written into the server's own decision record.
23
- * The client records WHAT was decided; it no longer records how.
24
- */
25
- const gateway_1 = require("./gateway");
26
- exports.POLICY_VERSION = 'served-v1';
27
- async function decide(input) {
28
- const reply = await (0, gateway_1.ask)({
29
- intent: 'decide',
30
- prompt: input.prompt,
31
- ...(input.callingModel ? { callingModel: input.callingModel } : {}),
32
- contextTokens: input.contextTokens ?? 0,
33
- freshContext: input.freshContext ?? true,
34
- });
35
- const d = reply.decision;
36
- return {
37
- recommendation: d.model,
38
- // A server that could not decide is not an error here. Rule 10: the caller
39
- // runs what it was going to run, and the reason travels with the record.
40
- withheld: d.model ? null : 'no_decision',
41
- ...(d.rationale ? { withheldDetail: d.rationale } : {}),
42
- breakdown: {},
43
- tableHashes: {},
44
- baselineVersion: null,
45
- policyVersion: exports.POLICY_VERSION,
46
- estimatorVersion: exports.POLICY_VERSION,
47
- confident: d.confident,
48
- rung: d.rung,
49
- };
50
- }
@@ -1,25 +0,0 @@
1
- /**
2
- * Normalization before hashing: lowercase, collapse runs of whitespace, trim.
3
- *
4
- * Deliberately mild. Aggressive normalization (stripping punctuation, stemming)
5
- * would collapse genuinely different requests onto one fingerprint, and a
6
- * fingerprint collision is a chain-linking error that is invisible afterwards.
7
- */
8
- export declare function normalisePrompt(prompt: string): string;
9
- export declare function fingerprint(prompt: string): string;
10
- /**
11
- * A short, stable id. `crypto.randomUUID` would do, but ids appear in every
12
- * report and a 12-character id is legible in a terminal where a UUID is noise.
13
- */
14
- export declare function newId(prefix: string): string;
15
- /**
16
- * Context size in tokens, approximated from characters.
17
- *
18
- * Four characters per token is the industry's usual rule of thumb and it is an
19
- * approximation, not a measurement - which is why every figure derived from it
20
- * carries `derivation: 'inferred'` with this method named. The provider's own
21
- * reported token counts are used wherever they exist; this is only for the
22
- * context estimate that has to exist *before* the call is made.
23
- */
24
- export declare const APPROX_CHARS_PER_TOKEN = 4;
25
- export declare function approxTokens(text: string): number;