crosscheck-mcp 0.2.27 → 0.2.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/embed.d.cts CHANGED
@@ -1,3 +1,62 @@
1
+ import { C as ChatMessage } from './types-BcprisDl.cjs';
2
+
3
+ /**
4
+ * A record of which engine processes are alive, and what they are RUNNING.
5
+ *
6
+ * WHY
7
+ * An engine process started weeks earlier was found still serving a pre-fix
8
+ * build while reporting the version on disk — so `crosscheck doctor` said
9
+ * "up to date" and the user kept hitting a bug that had already been fixed.
10
+ * Thirty-six such processes were once killed across twelve trees. Nothing
11
+ * reaps them and nothing notices them.
12
+ *
13
+ * The version a process REPORTS must be the one it LOADED, not the one
14
+ * currently installed. That is the whole point of writing it down at boot: a
15
+ * long-lived process cannot tell you what it is running if it re-reads the
16
+ * answer from disk every time you ask.
17
+ *
18
+ * WHY IT ONLY REPORTS
19
+ * It would be easy to kill anything older than N hours on startup. That is
20
+ * exactly what not to do here:
21
+ * - the CLI and the desktop app share this directory, so "ours" is not a
22
+ * safe inference from a name or a path;
23
+ * - a long-running process may be mid-panel, and panels cost real money;
24
+ * - a pid is reused after a process dies, so killing by a recorded pid can
25
+ * kill something unrelated that happens to have inherited the number.
26
+ * So this module writes, reads, and prunes records of processes that are
27
+ * already gone. Deciding to kill a live one is the operator's, with the
28
+ * command printed for them.
29
+ */
30
+ interface ProcRecord {
31
+ pid: number;
32
+ /** The engine version this process LOADED — not what is on disk now. */
33
+ version: string;
34
+ /** Epoch ms at boot. */
35
+ startedAt: number;
36
+ /** Parent pid at boot: the host that spawned us (Claude Code, a shell). */
37
+ ppid: number;
38
+ /** This process's session id, so a stale process can be tied to its rows. */
39
+ sessionId: string;
40
+ }
41
+ interface ProcStatus extends ProcRecord {
42
+ alive: boolean;
43
+ /** True when alive and running a version other than the one installed. */
44
+ outdated: boolean;
45
+ ageMs: number;
46
+ }
47
+ /** Is a pid still running? `kill(pid, 0)` signals nothing and throws ESRCH
48
+ * when the process is gone — EPERM means alive but owned by someone else,
49
+ * which still counts as alive. */
50
+ declare function isAlive(pid: number): boolean;
51
+ /**
52
+ * Every recorded process, with liveness. Records for dead pids are PRUNED as
53
+ * a side effect — they are the safe half of cleanup: the process is already
54
+ * gone, so deleting its note cannot hurt anything.
55
+ */
56
+ declare function listProcesses(installedVersion: string, env?: NodeJS.ProcessEnv, now?: number): ProcStatus[];
57
+ /** Directory path, for messages that tell an operator where to look. */
58
+ declare function processRegistryPath(env?: NodeJS.ProcessEnv): string;
59
+
1
60
  /** Default model per provider — matches Python's `build_providers()`. */
2
61
  declare const DEFAULT_MODELS: Readonly<Record<string, string>>;
3
62
  /**
@@ -71,6 +130,7 @@ declare const DEFAULT_EXCLUDED_PROVIDERS: readonly string[];
71
130
  * inherits `process.env`. Keeping keys out of it is what stops a user's own
72
131
  * `env | grep KEY` from printing their Anthropic key inside our app.
73
132
  */
133
+
74
134
  /**
75
135
  * Vault provider id → engine env var.
76
136
  *
@@ -151,7 +211,54 @@ type EngineEvent =
151
211
  runId: string;
152
212
  at: number;
153
213
  message: string;
214
+ }
215
+ /** ACTIVITY — one provider request went out. Emitted for EVERY model call
216
+ * a run makes, whatever the tool: panelists, the planner, workers,
217
+ * reviewers, judges, synthesis, the co-reasoner. `purpose` is the
218
+ * engine's role tag; `asked` is the start of the last user message. */
219
+ | {
220
+ type: "call.start";
221
+ runId: string;
222
+ at: number;
223
+ callId: number;
224
+ provider: string;
225
+ model: string;
226
+ purpose: string;
227
+ asked: string;
228
+ }
229
+ /** ACTIVITY — that request resolved. `text` is what the model said (capped
230
+ * at ACTIVITY_TEXT_CAP; `truncated` says so). Finished text, not a token
231
+ * stream: no adapter streams, and pretending otherwise would be a lie. */
232
+ | {
233
+ type: "call.done";
234
+ runId: string;
235
+ at: number;
236
+ callId: number;
237
+ provider: string;
238
+ model: string;
239
+ purpose: string;
240
+ ok: boolean;
241
+ ms: number;
242
+ text: string;
243
+ truncated: boolean;
244
+ error: string | null;
245
+ usage: EventUsage | null;
246
+ /** Set when the host stopped waiting (embed only): "user" from
247
+ * skip(), "timeout" from the run's per-call time limit. The request
248
+ * was aborted; the provider may still bill for work already done. */
249
+ stopped?: "user" | "timeout";
250
+ }
251
+ /** ACTIVITY — a step message from a multi-stage tool (orchestrate's
252
+ * levels, recombine). */
253
+ | {
254
+ type: "progress";
255
+ runId: string;
256
+ at: number;
257
+ message: string;
154
258
  };
259
+ /** How much of each model reply an activity event carries. Enough to read
260
+ * the back-and-forth; the full text is in the envelope. */
261
+ declare const ACTIVITY_TEXT_CAP = 8000;
155
262
  type EngineEventSink = (event: EngineEvent) => void;
156
263
  interface EmbeddedEngineOptions {
157
264
  /** Vault provider id → raw API key. Only providers present here are built.
@@ -167,6 +274,33 @@ interface EmbeddedEngineOptions {
167
274
  /** Directory to archive run transcripts into. Omit to write none. */
168
275
  transcriptsDir?: string;
169
276
  }
277
+ interface RunOptions {
278
+ /** Stop waiting on any single model call after this long (ms). The run
279
+ * continues with the answers already in. Off when 0/undefined. */
280
+ callTimeoutMs?: number;
281
+ }
282
+ interface AskOptions {
283
+ /** Vault id ("grok", not "xai"). Must be a provider this engine built. */
284
+ provider: string;
285
+ /** Model override; defaults to the provider's effective model. */
286
+ model?: string;
287
+ messages: ChatMessage[];
288
+ schema?: Record<string, unknown>;
289
+ /** Role tag for usage + the activity feed, e.g. "unify" or "code". */
290
+ purpose: string;
291
+ maxTokens?: number;
292
+ runId?: string;
293
+ onEvent?: EngineEventSink;
294
+ }
295
+ interface AskResult {
296
+ ok: boolean;
297
+ /** The model's raw reply. */
298
+ text: string;
299
+ /** Schema-validated value when a schema was given and the reply passed. */
300
+ json: unknown | null;
301
+ error: string | null;
302
+ model: string;
303
+ }
170
304
  interface EmbeddedEngine {
171
305
  readonly version: string;
172
306
  /** Providers actually built, by vault id — i.e. the ones with a usable key
@@ -176,12 +310,27 @@ interface EmbeddedEngine {
176
310
  readonly models: Readonly<Record<string, string>>;
177
311
  /** Every registered tool name. */
178
312
  listTools(): string[];
313
+ /** A tool's required input fields, from its own schema — or null if there
314
+ * is no such tool. Lets a host test its argument mapping against the
315
+ * engine instead of guessing field names (the desktop guessed five of ten
316
+ * wrong, and every one of those tools failed on missing input). */
317
+ requiredArgs(name: string): string[] | null;
179
318
  /** Invoke any tool and wait for the final envelope. No events. */
180
319
  call(name: string, args: Record<string, unknown>): Promise<unknown>;
181
320
  /** Invoke a tool, emitting lifecycle events as the panel progresses.
182
321
  * `confer` and `debate` stream; every other tool emits `run.start` and
183
322
  * `run.done` around a plain `call`, so a host can use one code path. */
184
- run(name: string, args: Record<string, unknown>, onEvent: EngineEventSink): Promise<unknown>;
323
+ run(name: string, args: Record<string, unknown>, onEvent: EngineEventSink, opts?: RunOptions): Promise<unknown>;
324
+ /** Stop waiting on one provider for the rest of a run: its in-flight
325
+ * requests are aborted and later ones (e.g. debate rounds) aren't sent.
326
+ * The run carries on with everyone else. The run's moderator is never
327
+ * stopped mid-synthesis. Returns how many in-flight calls were stopped;
328
+ * 0 (and a no-op) once the run has finished. */
329
+ skip(runId: string, provider: string): number;
330
+ /** One call to one chosen provider/model — the host's own moderator or
331
+ * coding step. With `runId` + `onEvent` it reports into that run's
332
+ * activity feed. With `schema`, returns validated JSON when it can. */
333
+ ask(opts: AskOptions): Promise<AskResult>;
185
334
  /** Flush queued telemetry. Call before the host process exits. */
186
335
  close(): Promise<void>;
187
336
  }
@@ -202,4 +351,4 @@ declare const __test_internals: {
202
351
  vaultId: typeof vaultId;
203
352
  };
204
353
 
205
- export { DEFAULT_EXCLUDED_PROVIDERS, DEFAULT_FALLBACKS, DEFAULT_MODELS, type EmbeddedEngine, type EmbeddedEngineOptions, type EngineEvent, type EngineEventSink, type EventUsage, KEY_ENV as __KEY_ENV, MODEL_ENV as __MODEL_ENV, __test_internals, createEmbeddedEngine };
354
+ export { ACTIVITY_TEXT_CAP, type AskOptions, type AskResult, DEFAULT_EXCLUDED_PROVIDERS, DEFAULT_FALLBACKS, DEFAULT_MODELS, type EmbeddedEngine, type EmbeddedEngineOptions, type EngineEvent, type EngineEventSink, type EventUsage, type ProcRecord, type ProcStatus, type RunOptions, KEY_ENV as __KEY_ENV, MODEL_ENV as __MODEL_ENV, __test_internals, createEmbeddedEngine, isAlive, listProcesses, processRegistryPath };
package/dist/embed.d.ts CHANGED
@@ -1,3 +1,62 @@
1
+ import { C as ChatMessage } from './types-BcprisDl.js';
2
+
3
+ /**
4
+ * A record of which engine processes are alive, and what they are RUNNING.
5
+ *
6
+ * WHY
7
+ * An engine process started weeks earlier was found still serving a pre-fix
8
+ * build while reporting the version on disk — so `crosscheck doctor` said
9
+ * "up to date" and the user kept hitting a bug that had already been fixed.
10
+ * Thirty-six such processes were once killed across twelve trees. Nothing
11
+ * reaps them and nothing notices them.
12
+ *
13
+ * The version a process REPORTS must be the one it LOADED, not the one
14
+ * currently installed. That is the whole point of writing it down at boot: a
15
+ * long-lived process cannot tell you what it is running if it re-reads the
16
+ * answer from disk every time you ask.
17
+ *
18
+ * WHY IT ONLY REPORTS
19
+ * It would be easy to kill anything older than N hours on startup. That is
20
+ * exactly what not to do here:
21
+ * - the CLI and the desktop app share this directory, so "ours" is not a
22
+ * safe inference from a name or a path;
23
+ * - a long-running process may be mid-panel, and panels cost real money;
24
+ * - a pid is reused after a process dies, so killing by a recorded pid can
25
+ * kill something unrelated that happens to have inherited the number.
26
+ * So this module writes, reads, and prunes records of processes that are
27
+ * already gone. Deciding to kill a live one is the operator's, with the
28
+ * command printed for them.
29
+ */
30
+ interface ProcRecord {
31
+ pid: number;
32
+ /** The engine version this process LOADED — not what is on disk now. */
33
+ version: string;
34
+ /** Epoch ms at boot. */
35
+ startedAt: number;
36
+ /** Parent pid at boot: the host that spawned us (Claude Code, a shell). */
37
+ ppid: number;
38
+ /** This process's session id, so a stale process can be tied to its rows. */
39
+ sessionId: string;
40
+ }
41
+ interface ProcStatus extends ProcRecord {
42
+ alive: boolean;
43
+ /** True when alive and running a version other than the one installed. */
44
+ outdated: boolean;
45
+ ageMs: number;
46
+ }
47
+ /** Is a pid still running? `kill(pid, 0)` signals nothing and throws ESRCH
48
+ * when the process is gone — EPERM means alive but owned by someone else,
49
+ * which still counts as alive. */
50
+ declare function isAlive(pid: number): boolean;
51
+ /**
52
+ * Every recorded process, with liveness. Records for dead pids are PRUNED as
53
+ * a side effect — they are the safe half of cleanup: the process is already
54
+ * gone, so deleting its note cannot hurt anything.
55
+ */
56
+ declare function listProcesses(installedVersion: string, env?: NodeJS.ProcessEnv, now?: number): ProcStatus[];
57
+ /** Directory path, for messages that tell an operator where to look. */
58
+ declare function processRegistryPath(env?: NodeJS.ProcessEnv): string;
59
+
1
60
  /** Default model per provider — matches Python's `build_providers()`. */
2
61
  declare const DEFAULT_MODELS: Readonly<Record<string, string>>;
3
62
  /**
@@ -71,6 +130,7 @@ declare const DEFAULT_EXCLUDED_PROVIDERS: readonly string[];
71
130
  * inherits `process.env`. Keeping keys out of it is what stops a user's own
72
131
  * `env | grep KEY` from printing their Anthropic key inside our app.
73
132
  */
133
+
74
134
  /**
75
135
  * Vault provider id → engine env var.
76
136
  *
@@ -151,7 +211,54 @@ type EngineEvent =
151
211
  runId: string;
152
212
  at: number;
153
213
  message: string;
214
+ }
215
+ /** ACTIVITY — one provider request went out. Emitted for EVERY model call
216
+ * a run makes, whatever the tool: panelists, the planner, workers,
217
+ * reviewers, judges, synthesis, the co-reasoner. `purpose` is the
218
+ * engine's role tag; `asked` is the start of the last user message. */
219
+ | {
220
+ type: "call.start";
221
+ runId: string;
222
+ at: number;
223
+ callId: number;
224
+ provider: string;
225
+ model: string;
226
+ purpose: string;
227
+ asked: string;
228
+ }
229
+ /** ACTIVITY — that request resolved. `text` is what the model said (capped
230
+ * at ACTIVITY_TEXT_CAP; `truncated` says so). Finished text, not a token
231
+ * stream: no adapter streams, and pretending otherwise would be a lie. */
232
+ | {
233
+ type: "call.done";
234
+ runId: string;
235
+ at: number;
236
+ callId: number;
237
+ provider: string;
238
+ model: string;
239
+ purpose: string;
240
+ ok: boolean;
241
+ ms: number;
242
+ text: string;
243
+ truncated: boolean;
244
+ error: string | null;
245
+ usage: EventUsage | null;
246
+ /** Set when the host stopped waiting (embed only): "user" from
247
+ * skip(), "timeout" from the run's per-call time limit. The request
248
+ * was aborted; the provider may still bill for work already done. */
249
+ stopped?: "user" | "timeout";
250
+ }
251
+ /** ACTIVITY — a step message from a multi-stage tool (orchestrate's
252
+ * levels, recombine). */
253
+ | {
254
+ type: "progress";
255
+ runId: string;
256
+ at: number;
257
+ message: string;
154
258
  };
259
+ /** How much of each model reply an activity event carries. Enough to read
260
+ * the back-and-forth; the full text is in the envelope. */
261
+ declare const ACTIVITY_TEXT_CAP = 8000;
155
262
  type EngineEventSink = (event: EngineEvent) => void;
156
263
  interface EmbeddedEngineOptions {
157
264
  /** Vault provider id → raw API key. Only providers present here are built.
@@ -167,6 +274,33 @@ interface EmbeddedEngineOptions {
167
274
  /** Directory to archive run transcripts into. Omit to write none. */
168
275
  transcriptsDir?: string;
169
276
  }
277
+ interface RunOptions {
278
+ /** Stop waiting on any single model call after this long (ms). The run
279
+ * continues with the answers already in. Off when 0/undefined. */
280
+ callTimeoutMs?: number;
281
+ }
282
+ interface AskOptions {
283
+ /** Vault id ("grok", not "xai"). Must be a provider this engine built. */
284
+ provider: string;
285
+ /** Model override; defaults to the provider's effective model. */
286
+ model?: string;
287
+ messages: ChatMessage[];
288
+ schema?: Record<string, unknown>;
289
+ /** Role tag for usage + the activity feed, e.g. "unify" or "code". */
290
+ purpose: string;
291
+ maxTokens?: number;
292
+ runId?: string;
293
+ onEvent?: EngineEventSink;
294
+ }
295
+ interface AskResult {
296
+ ok: boolean;
297
+ /** The model's raw reply. */
298
+ text: string;
299
+ /** Schema-validated value when a schema was given and the reply passed. */
300
+ json: unknown | null;
301
+ error: string | null;
302
+ model: string;
303
+ }
170
304
  interface EmbeddedEngine {
171
305
  readonly version: string;
172
306
  /** Providers actually built, by vault id — i.e. the ones with a usable key
@@ -176,12 +310,27 @@ interface EmbeddedEngine {
176
310
  readonly models: Readonly<Record<string, string>>;
177
311
  /** Every registered tool name. */
178
312
  listTools(): string[];
313
+ /** A tool's required input fields, from its own schema — or null if there
314
+ * is no such tool. Lets a host test its argument mapping against the
315
+ * engine instead of guessing field names (the desktop guessed five of ten
316
+ * wrong, and every one of those tools failed on missing input). */
317
+ requiredArgs(name: string): string[] | null;
179
318
  /** Invoke any tool and wait for the final envelope. No events. */
180
319
  call(name: string, args: Record<string, unknown>): Promise<unknown>;
181
320
  /** Invoke a tool, emitting lifecycle events as the panel progresses.
182
321
  * `confer` and `debate` stream; every other tool emits `run.start` and
183
322
  * `run.done` around a plain `call`, so a host can use one code path. */
184
- run(name: string, args: Record<string, unknown>, onEvent: EngineEventSink): Promise<unknown>;
323
+ run(name: string, args: Record<string, unknown>, onEvent: EngineEventSink, opts?: RunOptions): Promise<unknown>;
324
+ /** Stop waiting on one provider for the rest of a run: its in-flight
325
+ * requests are aborted and later ones (e.g. debate rounds) aren't sent.
326
+ * The run carries on with everyone else. The run's moderator is never
327
+ * stopped mid-synthesis. Returns how many in-flight calls were stopped;
328
+ * 0 (and a no-op) once the run has finished. */
329
+ skip(runId: string, provider: string): number;
330
+ /** One call to one chosen provider/model — the host's own moderator or
331
+ * coding step. With `runId` + `onEvent` it reports into that run's
332
+ * activity feed. With `schema`, returns validated JSON when it can. */
333
+ ask(opts: AskOptions): Promise<AskResult>;
185
334
  /** Flush queued telemetry. Call before the host process exits. */
186
335
  close(): Promise<void>;
187
336
  }
@@ -202,4 +351,4 @@ declare const __test_internals: {
202
351
  vaultId: typeof vaultId;
203
352
  };
204
353
 
205
- export { DEFAULT_EXCLUDED_PROVIDERS, DEFAULT_FALLBACKS, DEFAULT_MODELS, type EmbeddedEngine, type EmbeddedEngineOptions, type EngineEvent, type EngineEventSink, type EventUsage, KEY_ENV as __KEY_ENV, MODEL_ENV as __MODEL_ENV, __test_internals, createEmbeddedEngine };
354
+ export { ACTIVITY_TEXT_CAP, type AskOptions, type AskResult, DEFAULT_EXCLUDED_PROVIDERS, DEFAULT_FALLBACKS, DEFAULT_MODELS, type EmbeddedEngine, type EmbeddedEngineOptions, type EngineEvent, type EngineEventSink, type EventUsage, type ProcRecord, type ProcStatus, type RunOptions, KEY_ENV as __KEY_ENV, MODEL_ENV as __MODEL_ENV, __test_internals, createEmbeddedEngine, isAlive, listProcesses, processRegistryPath };