wicked-core-ts 0.7.18 → 0.7.20

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 (2) hide show
  1. package/index.d.ts +85 -12
  2. package/package.json +6 -6
package/index.d.ts CHANGED
@@ -103,6 +103,26 @@ export declare class Core {
103
103
  * as a JSON array of `AgenticCli` — pass straight into `launchRun`'s `clisJson`.
104
104
  */
105
105
  static registryRoster(): string
106
+ /**
107
+ * EVENT nodes on the estate store at `dbPath` — the shared store the emit seam writes
108
+ * governance events to (`WICKED_ESTATE_DB`; wicked-crew#495) — as a JSON number string, over
109
+ * a READ-ONLY connection (never the single-writer actor's handle; the store must already
110
+ * exist). crew's `GET /diagnostics` reports it as `governance.records.total` and derives
111
+ * `sinceBoot` from a boot baseline; an addon without this static answers `null` there.
112
+ */
113
+ static eventStoreCount(dbPath: string): Promise<string>
114
+ /**
115
+ * Replay a dead-letter outbox — the emit seam's NDJSON spool (`WICKED_APPS_EMIT_DEADLETTER`)
116
+ * of governance events it could not store — into the estate store at `dbPath`, writing each
117
+ * record as the EVENT node it should have been with its original `ts` restored
118
+ * (`wicked_apps_core::emit::replay_outbox`). Opens the store read-write (creating it if
119
+ * missing — the caller creates the parent directory). IDEMPOTENT: a replayed node's id is the
120
+ * spool line's content hash plus its original stamp, so the same line replayed twice lands
121
+ * once. Resolves to the JSON report `{ read, replayed, already_present, failed: [{ line,
122
+ * reason }] }`; a failed entry carries its ORIGINAL line so the caller can keep it
123
+ * dead-lettered. Behind `wicked-crew governance replay`.
124
+ */
125
+ static replayEmitOutbox(outboxPath: string, dbPath: string): Promise<string>
106
126
  /**
107
127
  * Subscribe to the live [`CoreEvent`] stream. `callback` follows the Node error-first
108
128
  * convention — `(err, eventJson)` — and is invoked once per event with the event serialized as
@@ -119,21 +139,33 @@ export declare class Core {
119
139
  /** Liveness probe — emits a `Heartbeat` to subscribers and resolves once the actor acks (`"ok"`). */
120
140
  ping(): Promise<string>
121
141
  /**
122
- * Open a chat: eagerly warm one ACP session per seat (crew#165 / core#13). Resolves to a
123
- * JSON array of per-seat outcomes `[{cliKey, ok, error?}]`; `chatSessionReady`/`chatSessionFailed`
124
- * also stream to subscribers. Blocking handshakes run on the task pool, not the JS thread.
142
+ * Open a chat: eagerly warm one ACP session per seat (crew#165 / core#13) in a SCOPE
143
+ * (wicked-core#410 / wicked-crew#502). `cwd` is the seats' working directory — the chat's
144
+ * scratch root; omitted, a private `<tmp>/wicked-core-chat-<id>` of the chat's own, NEVER this
145
+ * process's cwd. `scopeJson` is `{"codeGraphDb"?: string|null, "readRoots"?: string[]}`: the
146
+ * estate graph the seats' READ-ONLY estate MCP is bound to (omitted/null ⇒ no estate MCP) and
147
+ * the repository roots in scope (advertised to a claude seat as `additionalDirectories`,
148
+ * recorded for every seat). Resolves to a JSON array of per-seat outcomes
149
+ * `[{cliKey, ok, error?}]`; `chatSessionReady`/`chatSessionFailed` also stream to
150
+ * subscribers. Blocking handshakes run on the task pool, not the JS thread.
125
151
  */
126
- chatOpen(chatId: string, clisJson: string, cwd?: string | undefined | null): Promise<string>
152
+ chatOpen(chatId: string, clisJson: string, cwd?: string | undefined | null, scopeJson?: string | undefined | null): Promise<string>
127
153
  /**
128
154
  * Fan a message out to the chat's warm seats (all, or `targets_json` subset). Ack-fast:
129
155
  * resolves to the JSON array of seats targeted; replies stream as `chatDelta`/`chatReply`.
156
+ * `cwd` is accepted for wire compatibility and IGNORED (wicked-core#410): every turn runs in
157
+ * the scope recorded at `chatOpen` — a per-message working directory was the F-067 leak.
130
158
  */
131
159
  chatSend(chatId: string, text: string, targetsJson?: string | undefined | null, cwd?: string | undefined | null): Promise<string>
132
160
  /** The seats currently warm for a chat — JSON array of cli keys. */
133
161
  chatSeats(chatId: string): Promise<string>
134
162
  /**
135
163
  * Every chat currently holding pool state — JSON array of
136
- * `[{chatId, seats, idleSecs}]`, sorted by id.
164
+ * `[{chatId, seats, idleSecs, cwd, codeGraphDb, readRoots}]`, sorted by id. `cwd` /
165
+ * `codeGraphDb` / `readRoots` are the scope recorded at `chatOpen` (wicked-core#410): where the
166
+ * seats run, the estate graph their read-only estate MCP is bound to (`null` ⇒ none), and the
167
+ * repository roots in scope (`[]` when none); `cwd` is `null` only for a pool entry whose scope
168
+ * is gone (a chat mid-close).
137
169
  *
138
170
  * Each warm seat pins an ACP bridge plus an agent child (~520 MB resident) and clients mint
139
171
  * chat ids freely, so without this an accumulation is invisible until the host runs out of
@@ -240,8 +272,15 @@ export declare class Core {
240
272
  unitTranscript(unitId: string): Promise<string>
241
273
  /**
242
274
  * A run's recorded event history, oldest first, as a JSON array. Each entry is the SAME tagged
243
- * object the `/ws` stream carries ([`CoreEvent::to_json`]) plus a capture-time `ts` (epoch millis)
244
- * and an ordering `seq`.
275
+ * object the `/ws` stream carries ([`CoreEvent::to_json`]) plus the durable log's envelope — a
276
+ * capture-time `ts` (epoch millis) and an ordering `seq`; `RecordedEventJson` is the shape.
277
+ *
278
+ * Ordering contract (wicked-core#408): `seq` is strictly increasing within a run for the run's
279
+ * whole life, ACROSS daemon restarts — the engine continues a run's `seq` from its persisted
280
+ * log rather than from 0 — so the array is in emission order and its last entry is the run's
281
+ * latest event. The first entry a restarted engine records for a run carries
282
+ * `daemonRestarted: true` (absent everywhere else). `ts` may repeat within a burst; never order
283
+ * by it.
245
284
  *
246
285
  * The read half of FINDING-014: an evidence bundle assembled after a run must read what actually
247
286
  * happened rather than re-derive pseudo-events from unit records, which cannot recover what it
@@ -526,9 +565,10 @@ export declare class Core {
526
565
  * `core.db`), which holds run/governance nodes but none of a repo's domain/requirement nodes, so
527
566
  * it reports a vacuous `coverage: 1.0` over an empty denominator and cannot name a repo. This
528
567
  * resolves the repo from the registry, opens its `code_graph_db` (the engine-resolved path
529
- * every consumer shares — the legacy in-tree `<root>/.codegraph/estate.db` for a repo that
530
- * already has one, else the estate home's `<estate_root>/<key>/estate.db`; see wicked-core's
531
- * `code_graph.rs` ADR), and recomputes over it. An unknown `repo_ref` is an
568
+ * every consumer shares — `<daemon state home>/repo-graphs/<key>/estate.db`, never inside the
569
+ * checkout; see wicked-core's `code_graph.rs` ADR, core#406), and recomputes over it. The
570
+ * daemon's own store path is handed along so the repo graph resolves under THIS daemon's
571
+ * state home off the actor thread. An unknown `repo_ref` is an
532
572
  * ERROR, never a silent vacuous report — the caller must name a real repo.
533
573
  * Resolves to the coverage report as a JSON string (`ts_return_type` pins it — the crew adapter
534
574
  * used to cast away an `unknown` here; #225 review).
@@ -613,8 +653,19 @@ export declare class Subscription {
613
653
  * PTY terminal sessions emit `terminalOpened` `{id, cwd}`, `terminalOutput` `{id, seq, bytesB64}`
614
654
  * (raw output base64-encoded in `bytesB64`), and `terminalExited` `{id, status}`.
615
655
  * Gate evidence (wicked-core F-036/F-039): evaluatorMutatedWorktree {session, ord, attempt, cli,
616
- * phase, beforeTree, afterTree, headMoved, changed} and repoChecksEvaluated {session,
617
- * ord, attempt, passed, criterion, checks, skipped}.
656
+ * phase, beforeTree, afterTree, headMoved, changed, restored, restoreError} and
657
+ * repoChecksEvaluated {session, ord, attempt, passed, criterion, checks, skipped}.
658
+ * core#431 additions: gateEvaluated carries `judgeCli: string | null` + `judgeDistinct: boolean |
659
+ * null` (who rendered agentVerdict); worktreeRestored {session, ord, attempt, cli, phase, tree,
660
+ * head, discarded, suggestionRef} (the creator's tree was put back after an evaluator mutation;
661
+ * the discarded edit is pinned under suggestionRef);
662
+ * deliverLiftEvaluated {session, ord, attempt, outcome: 'unchanged'|'lifted'|'conflict'|'skipped'|'failed',
663
+ * baseRef, baseBefore, baseAfter, treeBefore, treeAfter, conflicts, note} (the deliver phase's
664
+ * lift onto the remote tip, re-verified when it changed the tree); evaluatorToolCallDenied
665
+ * {session, ord, attempt, cli, carrier, tool, kind, path, reason} (a write-class tool call an
666
+ * executes_code:false phase made was refused at the ACP permission boundary); runBaseResolved
667
+ * {session, baseRef, baseCommit, localHead, behind, fetched, lifted, note} (which base a fresh
668
+ * run worktree was minted from).
618
669
  */
619
670
  export interface CoreEventJson {
620
671
  type: string
@@ -655,4 +706,26 @@ export interface UnitDistributedEventJson extends CoreEventJson {
655
706
  */
656
707
  seatConstraint: string | null
657
708
  }
709
+
710
+ /**
711
+ * One entry of the JSON array {@link Core.runEvents} resolves: the `/ws` frame ({@link CoreEventJson})
712
+ * plus the durable log's envelope. Ordering contract (wicked-core#408): `seq` is strictly increasing
713
+ * within a run for the run's WHOLE life — across daemon restarts, not just within one process — so
714
+ * the array is in emission order and its last entry is the run's latest event. `ts` is capture time
715
+ * (epoch millis) and may repeat within a burst; never order by it. The first entry a restarted
716
+ * engine records for a run carries `daemonRestarted: true` (absent everywhere else), marking the
717
+ * boundary for consumers that keep per-run state across the gap. All three are envelope-only: the
718
+ * live `/ws` frame carries none of them.
719
+ */
720
+ export interface RecordedEventJson extends CoreEventJson {
721
+ /** Capture-time epoch millis. May repeat within a burst — not an order. */
722
+ ts: number
723
+ /**
724
+ * Strictly increasing within the run, across daemon restarts. NOT the per-terminal `seq` of
725
+ * `terminalOutput` frames — those are streaming chunks and are never recorded.
726
+ */
727
+ seq: number
728
+ /** Present, and `true`, only on the first entry a restarted engine recorded for this run. */
729
+ daemonRestarted?: true
730
+ }
658
731
  // ─── end hand-authored ───
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wicked-core-ts",
3
- "version": "0.7.18",
3
+ "version": "0.7.20",
4
4
  "description": "Node/TypeScript bindings (napi-rs) for wicked-core: drive the in-process orchestration engine from JS/TS.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -43,11 +43,11 @@
43
43
  "typecheck": "tsc --noEmit -p types-test/tsconfig.json"
44
44
  },
45
45
  "optionalDependencies": {
46
- "wicked-core-ts-darwin-arm64": "0.7.18",
47
- "wicked-core-ts-darwin-x64": "0.7.18",
48
- "wicked-core-ts-linux-arm64-gnu": "0.7.18",
49
- "wicked-core-ts-linux-x64-gnu": "0.7.18",
50
- "wicked-core-ts-win32-x64-msvc": "0.7.18"
46
+ "wicked-core-ts-darwin-arm64": "0.7.20",
47
+ "wicked-core-ts-darwin-x64": "0.7.20",
48
+ "wicked-core-ts-linux-arm64-gnu": "0.7.20",
49
+ "wicked-core-ts-linux-x64-gnu": "0.7.20",
50
+ "wicked-core-ts-win32-x64-msvc": "0.7.20"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@napi-rs/cli": "^2.18.4",