@cilow/sdk 0.2.0 → 0.3.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 (53) hide show
  1. package/LICENSE +201 -21
  2. package/README.md +109 -279
  3. package/dist/abstain.d.ts +43 -0
  4. package/dist/abstain.d.ts.map +1 -0
  5. package/dist/abstain.js +42 -0
  6. package/dist/abstain.js.map +1 -0
  7. package/dist/adapters/anthropic.d.ts +57 -0
  8. package/dist/adapters/anthropic.d.ts.map +1 -0
  9. package/dist/adapters/anthropic.js +57 -0
  10. package/dist/adapters/anthropic.js.map +1 -0
  11. package/dist/adapters/index.d.ts +16 -0
  12. package/dist/adapters/index.d.ts.map +1 -0
  13. package/dist/adapters/index.js +16 -0
  14. package/dist/adapters/index.js.map +1 -0
  15. package/dist/adapters/langchain.d.ts +62 -0
  16. package/dist/adapters/langchain.d.ts.map +1 -0
  17. package/dist/adapters/langchain.js +68 -0
  18. package/dist/adapters/langchain.js.map +1 -0
  19. package/dist/adapters/memory.d.ts +105 -0
  20. package/dist/adapters/memory.d.ts.map +1 -0
  21. package/dist/adapters/memory.js +105 -0
  22. package/dist/adapters/memory.js.map +1 -0
  23. package/dist/adapters/openai.d.ts +56 -0
  24. package/dist/adapters/openai.d.ts.map +1 -0
  25. package/dist/adapters/openai.js +64 -0
  26. package/dist/adapters/openai.js.map +1 -0
  27. package/dist/adapters/remaining.d.ts +52 -0
  28. package/dist/adapters/remaining.d.ts.map +1 -0
  29. package/dist/adapters/remaining.js +67 -0
  30. package/dist/adapters/remaining.js.map +1 -0
  31. package/dist/client.d.ts +563 -0
  32. package/dist/client.d.ts.map +1 -0
  33. package/dist/client.js +653 -0
  34. package/dist/client.js.map +1 -0
  35. package/dist/errors.d.ts +25 -0
  36. package/dist/errors.d.ts.map +1 -0
  37. package/dist/errors.js +28 -0
  38. package/dist/errors.js.map +1 -0
  39. package/dist/hash.d.ts +13 -0
  40. package/dist/hash.d.ts.map +1 -0
  41. package/dist/hash.js +92 -0
  42. package/dist/hash.js.map +1 -0
  43. package/dist/index.d.ts +17 -404
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +17 -482
  46. package/dist/index.js.map +1 -0
  47. package/dist/types.d.ts +817 -0
  48. package/dist/types.d.ts.map +1 -0
  49. package/dist/types.js +19 -0
  50. package/dist/types.js.map +1 -0
  51. package/package.json +32 -46
  52. package/dist/index.d.mts +0 -407
  53. package/dist/index.mjs +0 -449
@@ -0,0 +1,817 @@
1
+ /**
2
+ * Wire types for the Cilow JSON-RPC API. These mirror `crates/cilow-api/src/wire.rs`
3
+ * 1:1 so the SDK is a faithful, typed view of the engine's contract.
4
+ *
5
+ * Important conventions from the engine:
6
+ * - Entity ids are 128-bit and cross the wire as DECIMAL STRINGS (never lossy floats).
7
+ * - All times (`observed_at`, `as_of`, `now`, `at`, `valid_from`, `valid_until`) are
8
+ * raw epoch MICROSECONDS (µs), not milliseconds.
9
+ * - Over HTTP, `scope` is server-stamped from the bearer token; a client-supplied
10
+ * scope is ignored. It is still accepted here for parity with the stdio MCP transport.
11
+ */
12
+ /** The 6-level tenant scope. Over HTTP this is server-stamped from the token; all levels default to 0. */
13
+ export interface Scope {
14
+ org?: number;
15
+ project?: number;
16
+ user?: number;
17
+ agent?: number;
18
+ task?: number;
19
+ session?: number;
20
+ /** Track A1: git-style branch (0/omitted = main). Prefer the `branch` NAME option on
21
+ * remember/recall/answer over setting this numeric id directly. */
22
+ branch?: number;
23
+ }
24
+ export type AnswerabilityStatus = "answerable" | "partial" | "conflicting" | "stale" | "denied" | "insufficient";
25
+ export type MemoryProposalStatus = "pending" | "accepted" | "rejected";
26
+ export interface Workspace {
27
+ workspace_id: string;
28
+ name: string;
29
+ org: number;
30
+ user: number;
31
+ project: number;
32
+ created_at: number;
33
+ }
34
+ export interface EvidenceCoordinate {
35
+ byte_start?: number;
36
+ byte_end?: number;
37
+ page?: number;
38
+ time_start_ms?: number;
39
+ time_end_ms?: number;
40
+ symbol?: string;
41
+ json_pointer?: string;
42
+ }
43
+ export interface EvidenceRevision {
44
+ evidence_id: string;
45
+ workspace_id: string;
46
+ source_id: string;
47
+ source_revision: string;
48
+ raw_sha256: string;
49
+ blob_id: string;
50
+ mime: string;
51
+ coordinates: EvidenceCoordinate[];
52
+ trust: "untrusted" | "user_provided" | "tool_observed" | "operator_verified";
53
+ acl_principals: string[];
54
+ valid_from: number;
55
+ valid_to?: number;
56
+ transaction_time: number;
57
+ current: boolean;
58
+ supersedes?: string;
59
+ derived_claims: string[];
60
+ excerpt: string;
61
+ metadata: Record<string, string>;
62
+ }
63
+ export interface CitationRef {
64
+ evidence_id: string;
65
+ source_id: string;
66
+ source_revision: string;
67
+ blob_id: string;
68
+ coordinates: EvidenceCoordinate[];
69
+ excerpt: string;
70
+ }
71
+ export interface ContextProgram {
72
+ program_id: string;
73
+ workspace_id: string;
74
+ query: string;
75
+ answerability: AnswerabilityStatus;
76
+ reason: string;
77
+ token_budget: number;
78
+ packed_tokens: number;
79
+ citations: CitationRef[];
80
+ counterevidence: CitationRef[];
81
+ unresolved_questions: string[];
82
+ instruction_boundary: "data_only";
83
+ allowed_tools: string[];
84
+ }
85
+ export interface CandidateEnvelope {
86
+ query_id: string;
87
+ tenant_scope_digest: string;
88
+ as_of: number;
89
+ evidence_revision_id: string;
90
+ source_id: string;
91
+ source_revision: string;
92
+ byte_start: number;
93
+ byte_end: number;
94
+ content_sha256: string;
95
+ temporal_eligibility: boolean;
96
+ retrieval_lane: string;
97
+ retrieval_scores: Record<string, number>;
98
+ model_generation: string;
99
+ index_generation: string;
100
+ }
101
+ export interface SelectedFragmentV2 {
102
+ fragment_id: string;
103
+ evidence_revision_id: string;
104
+ source_id: string;
105
+ source_revision: string;
106
+ byte_start: number;
107
+ byte_end: number;
108
+ source_content_sha256: string;
109
+ fragment_sha256: string;
110
+ text: string;
111
+ exact_tokens: number;
112
+ }
113
+ export interface ContextProgramV2 {
114
+ schema_version: string;
115
+ program_id: string;
116
+ query_id: string;
117
+ workspace_id: string;
118
+ tenant_scope_digest: string;
119
+ query: string;
120
+ as_of: number;
121
+ answerability: AnswerabilityStatus;
122
+ reason: string;
123
+ model_id: string;
124
+ tokenizer_id: string;
125
+ tokenizer_sha256: string;
126
+ prompt_template_id: string;
127
+ prompt_template_sha256: string;
128
+ model_context_token_budget: number;
129
+ model_context_tokens: number;
130
+ audit_payload_byte_budget: number;
131
+ audit_payload_bytes: number;
132
+ candidate_policy: {
133
+ depth: number;
134
+ lanes: string[];
135
+ temporal_policy: string;
136
+ compiler_policy: string;
137
+ };
138
+ candidate_ids: string[];
139
+ selected_fragments: SelectedFragmentV2[];
140
+ composition_plan: Array<Record<string, unknown>>;
141
+ composition_outputs: Array<Record<string, unknown>>;
142
+ final_context: string;
143
+ final_context_sha256: string;
144
+ gate: {
145
+ score_family: string;
146
+ threshold: number | null;
147
+ score: number;
148
+ decision: string;
149
+ calibration_state: string;
150
+ };
151
+ versions: {
152
+ model_id: string;
153
+ index_generation: string;
154
+ compiler_version: string;
155
+ calibrator_version: string;
156
+ tokenizer_id: string;
157
+ };
158
+ receipt_id: string;
159
+ premise_ids: string[];
160
+ artifact_sha256: string;
161
+ instruction_boundary: "data_only";
162
+ }
163
+ export interface ContextTrace {
164
+ trace_id: string;
165
+ program_id: string;
166
+ workspace_id: string;
167
+ query: string;
168
+ candidates: Array<{
169
+ evidence_id: string;
170
+ score: number;
171
+ current: boolean;
172
+ authorized: boolean;
173
+ }>;
174
+ selected_evidence_ids: string[];
175
+ exclusions: Array<{
176
+ evidence_id: string;
177
+ reason: string;
178
+ }>;
179
+ gate: Record<string, string>;
180
+ latency_ms: number;
181
+ estimated_cost_usd: number;
182
+ }
183
+ export interface AgentEpisode {
184
+ episode_id: string;
185
+ workspace_id: string;
186
+ actor_id: string;
187
+ summary: string;
188
+ evidence_ids: string[];
189
+ occurred_at: number;
190
+ }
191
+ export interface MemoryProposal {
192
+ proposal_id: string;
193
+ workspace_id: string;
194
+ author_id: string;
195
+ episode_id: string;
196
+ subject: string;
197
+ predicate: string;
198
+ value: string;
199
+ evidence_ids: string[];
200
+ status: MemoryProposalStatus;
201
+ proposed_at: number;
202
+ verifier_id?: string;
203
+ decision_reason?: string;
204
+ }
205
+ export interface TruthRevision {
206
+ truth_revision_id: string;
207
+ proposal_id: string;
208
+ workspace_id: string;
209
+ verifier_id: string;
210
+ subject: string;
211
+ predicate: string;
212
+ value: string;
213
+ evidence_ids: string[];
214
+ projection_source_id?: string;
215
+ valid_from: number;
216
+ transaction_time: number;
217
+ active: boolean;
218
+ }
219
+ export interface WorkspaceResponse {
220
+ ok: boolean;
221
+ workspace?: Workspace;
222
+ error?: string;
223
+ }
224
+ export interface EvidenceResponse {
225
+ ok: boolean;
226
+ evidence?: EvidenceRevision;
227
+ error?: string;
228
+ }
229
+ export interface InvestigateResponse {
230
+ ok: boolean;
231
+ program?: ContextProgram;
232
+ trace?: ContextTrace;
233
+ error?: string;
234
+ }
235
+ export interface CompileContextResponse {
236
+ ok: boolean;
237
+ program?: ContextProgramV2;
238
+ error?: string;
239
+ }
240
+ export interface TraceResponse {
241
+ ok: boolean;
242
+ trace?: ContextTrace;
243
+ error?: string;
244
+ }
245
+ export interface EpisodeResponse {
246
+ ok: boolean;
247
+ episode?: AgentEpisode;
248
+ error?: string;
249
+ }
250
+ export interface MemoryResponse {
251
+ ok: boolean;
252
+ proposal?: MemoryProposal;
253
+ truth_revision?: TruthRevision;
254
+ error?: string;
255
+ }
256
+ /** Track A1 — one git-style branch: its name, numeric id (decimal string), parent, fork instant. */
257
+ export interface Branch {
258
+ name: string;
259
+ /** Numeric branch id as a decimal string (`"0"` = main). */
260
+ branch: string;
261
+ /** Parent branch's numeric id as a decimal string (`"0"` = forked from main). */
262
+ parent: string;
263
+ /** Fork instant in epoch µs; omitted for main (no fork point). */
264
+ fork_time?: number;
265
+ }
266
+ /** Track A1 — the result of `fork`. `ok=false` ⇒ rejected (see `error`); nothing was created. */
267
+ export interface ForkResponse {
268
+ ok: boolean;
269
+ /** The created branch (absent on error). */
270
+ branch?: Branch;
271
+ /** Failure reason when `ok=false`. */
272
+ error?: string;
273
+ }
274
+ /** A `(subject, predicate, object)` triple to remember / ingest. */
275
+ export interface Fact {
276
+ subject: string;
277
+ predicate: string;
278
+ object: string;
279
+ /** Multi-value opt-out of supersession: `true` ⇒ a new value for this `(subject, predicate)`
280
+ * COEXISTS with the old one (tags, skills) instead of superseding it. Mirrors `WireFact.multi`. */
281
+ multi?: boolean;
282
+ }
283
+ /** Provenance kind of a write. `operator` (a direct agent assertion) is the default + highest-trust. */
284
+ export type Source = "tool_call" | "structured_import" | "operator" | "llm";
285
+ /**
286
+ * The MACHINE-readable abstain code carried on an abstaining `recall`/`answer`. Mirrors
287
+ * `crates/cilow-truth/src/conformal.rs::AbstainReason::code()` 1:1. The agent-control-flow split:
288
+ * - `below_threshold` / `no_candidates` — a CALIBRATED abstain: memory genuinely lacks grounded
289
+ * context for this query. Do NOT fabricate past it; ask the user or search elsewhere.
290
+ * - `provider_unavailable` — an INFRASTRUCTURE abstain: the embedding provider failed, so the
291
+ * semantic read could not run. Memory MAY hold the answer — retry when it recovers.
292
+ * Branch with `isCalibratedAbstain` / `isInfrastructureAbstain` (see `./abstain.js`) instead of
293
+ * matching strings by hand.
294
+ */
295
+ export type ReasonCode = "below_threshold" | "no_candidates" | "provider_unavailable";
296
+ /**
297
+ * WHICH LAYER STOPPED THE ANSWER (`answer` / `context_pack`, engine ≥ 2026-09-06). Mirrors
298
+ * `crates/cilow-api/src/wire.rs::TerminalLayer` 1:1. Only set when `abstained`.
299
+ * - `structural` — nothing was retrieved at all: the fact is not in memory.
300
+ * - `gate` — candidates existed but the conformal gate / a structural check refused.
301
+ * - `provider` — an embedding or reader provider was unreachable: RETRY.
302
+ * - `reader` — the reader read the context and judged it insufficient.
303
+ * - `verifier` — the reader answered but the answer-side verification failed.
304
+ */
305
+ export type TerminalLayer = "structural" | "gate" | "provider" | "reader" | "verifier";
306
+ export declare const TERMINAL_LAYERS: readonly TerminalLayer[];
307
+ /** The structure facet of an {@link Evidence} unit — present iff the claim lane contributed. */
308
+ export interface EvidenceStructure {
309
+ /** Entity id as a decimal string (128-bit, lossless). */
310
+ entity: string;
311
+ predicate: number;
312
+ entity_label?: string;
313
+ predicate_label?: string;
314
+ valid_from: number;
315
+ /** Absent = still valid. */
316
+ valid_until?: number;
317
+ is_current: boolean;
318
+ }
319
+ /** Where an {@link Evidence} unit came from. Every lane fills this. */
320
+ export interface EvidenceProvenance {
321
+ source_id?: string;
322
+ session?: number;
323
+ in_session?: boolean;
324
+ observed_at?: number;
325
+ document_id?: string;
326
+ }
327
+ /**
328
+ * One unit of the UNIFIED EVIDENCE VIEW on `answer` / `context_pack`: the claim, span, and verbatim
329
+ * lanes collapsed into one list, deduplicated by text and ordered by fused cross-lane rank.
330
+ * `origins` names the lanes that produced it (`structured` | `semantic` | `lexical`); a unit two
331
+ * lanes agree on carries both and outranks a unit that is merely top of one lane. Present on
332
+ * answers AND abstains — an abstain can still carry evidence worth reading.
333
+ */
334
+ export interface Evidence {
335
+ text: string;
336
+ origins: string[];
337
+ structure?: EvidenceStructure;
338
+ provenance?: EvidenceProvenance;
339
+ /** The fused reciprocal-rank score (RRF, K = 60) this unit was ordered by. */
340
+ fused: number;
341
+ }
342
+ /** Wire result of `remember`. When `ok` is false nothing was written (see `error`). */
343
+ export interface RememberResponse {
344
+ claims_emitted: number;
345
+ inserted: number;
346
+ merged: number;
347
+ superseded: number;
348
+ conflicted: number;
349
+ deduped: boolean;
350
+ nodes_indexed: number;
351
+ edges_added: number;
352
+ entities_registered: string[];
353
+ attributes_registered: string[];
354
+ /** `false` ⇒ write failed; nothing durable. Defaults true on older servers. */
355
+ ok?: boolean;
356
+ /** Failure reason when `ok` is false, or CF projection lag warning. */
357
+ error?: string;
358
+ /** Typed causal edges minted post-write. */
359
+ causal_edges?: number;
360
+ /** CF-store projection put failures (log durable; CF may lag). */
361
+ cf_projection_errors?: number;
362
+ }
363
+ /** A packed claim returned by `recall`. */
364
+ export interface Claim {
365
+ /** Entity id as a decimal string (128-bit, lossless). */
366
+ entity: string;
367
+ /** Predicate id (numeric). */
368
+ predicate: number;
369
+ /** Human-readable predicate name, e.g. `employer`. Absent if unknown. */
370
+ predicate_label?: string;
371
+ /** Human-readable entity surface form, e.g. `Maya Chen`. Absent if not recorded. */
372
+ entity_label?: string;
373
+ value: string;
374
+ score: number;
375
+ }
376
+ /** The assembly receipt: which path answered and the configured gate values. */
377
+ export interface Receipt {
378
+ intent: string;
379
+ path: string;
380
+ /** Canonical entity id (decimal string), if an anchor resolved. */
381
+ canonical_entity?: string;
382
+ /** Alias-class members unioned into the read (decimal strings). */
383
+ class_members: string[];
384
+ /** Best candidate's nonconformity score. */
385
+ best_nonconformity?: number;
386
+ /** The calibrated conformal threshold. */
387
+ q_hat?: number;
388
+ /** `q̂ − n` — ≥0 answered, <0 abstained. */
389
+ margin?: number;
390
+ }
391
+ /**
392
+ * The result of a `recall`. THE ABSTENTION CONTRACT: when `abstained` is true the
393
+ * engine is telling you it does not know — `claims` is empty and `reason` explains.
394
+ * DO NOT fabricate past an abstain.
395
+ */
396
+ export interface RecallResponse {
397
+ abstained: boolean;
398
+ /**
399
+ * The recall trace id — pass it to `feedback` to reshape exactly the claims this read
400
+ * surfaced (the outcome-feedback loop). `0` if the read was not traced; a live wire recall
401
+ * always traces.
402
+ */
403
+ trace_id: number;
404
+ /** The packed claims (empty on an abstain). */
405
+ claims: Claim[];
406
+ /** The human-facing abstain reason (only set when `abstained`). */
407
+ reason?: string;
408
+ /**
409
+ * The MACHINE-readable abstain code an agent branches on (see `ReasonCode`). Only set when
410
+ * `abstained`. Prefer `isCalibratedAbstain` / `isInfrastructureAbstain` over matching by hand.
411
+ */
412
+ reason_code?: ReasonCode;
413
+ receipt: Receipt;
414
+ }
415
+ /** A citation backing an `answer`. */
416
+ export interface Citation {
417
+ entity: string;
418
+ predicate: number;
419
+ predicate_label?: string;
420
+ entity_label?: string;
421
+ value: string;
422
+ /** Present truth. Missing on the wire means not current (do not treat as live). */
423
+ is_current?: boolean;
424
+ /** Byte/page coordinate into retained source (T8). */
425
+ coordinate?: {
426
+ byte_start?: number;
427
+ byte_end?: number;
428
+ page?: number;
429
+ time_start_ms?: number;
430
+ time_end_ms?: number;
431
+ symbol?: string;
432
+ json_pointer?: string;
433
+ };
434
+ document_id?: string;
435
+ }
436
+ /** Anthropic Citations API part (`type: char_location` / `page_location`). */
437
+ export interface CitationPart {
438
+ type: "char_location" | "page_location" | string;
439
+ cited_text: string;
440
+ document_index: number;
441
+ document_title?: string;
442
+ start_char_index?: number;
443
+ end_char_index?: number;
444
+ start_page_number?: number;
445
+ end_page_number?: number;
446
+ }
447
+ /**
448
+ * The result of an `answer`. When `abstained` is true, `text` is the honored abstain
449
+ * message and `citations` is empty — an agent MUST NOT treat it as fact.
450
+ */
451
+ /**
452
+ * The reader model's ACTUAL billed token ledger for a live `answer` — the honest OUTPUT side of the
453
+ * token-efficiency metric. `prompt_tokens` is the input the reader model actually billed (provider ground
454
+ * truth; reconcile against `AnswerResponse.packed_tokens`, a coarse word×1.3 ESTIMATE over claim values),
455
+ * `completion_tokens` is the output it produced. Absent when no live reader ran (no billed tokens).
456
+ */
457
+ export interface ReaderUsage {
458
+ prompt_tokens: number;
459
+ completion_tokens: number;
460
+ }
461
+ export interface AnswerResponse {
462
+ text: string;
463
+ abstained: boolean;
464
+ citations: Citation[];
465
+ /** The recall trace id — pass it to `feedback`. `0`/absent if not traced; a live answer traces. */
466
+ trace_id?: number;
467
+ /** The human-facing abstain reason (only set when `abstained`). */
468
+ reason?: string;
469
+ /**
470
+ * The MACHINE-readable abstain code (see `ReasonCode`) — frozen-contract parity with `RecallResponse`.
471
+ * Only set when `abstained`. Prefer `isCalibratedAbstain` / `isInfrastructureAbstain`.
472
+ */
473
+ reason_code?: ReasonCode;
474
+ /** The engine's INPUT-context token estimate (word×1.3 over claim values). */
475
+ packed_tokens?: number;
476
+ /**
477
+ * TOKEN LEDGER: the reader model's ACTUAL billed input+output tokens. Present only when a live reader
478
+ * ran; absent on deterministic / non-live / abstain paths (no billed tokens).
479
+ */
480
+ reader_usage?: ReaderUsage;
481
+ grounding?: string;
482
+ pack_sufficient?: boolean | null;
483
+ as_of?: number;
484
+ citation_parts?: CitationPart[];
485
+ /** The routed query intent (parity with `ContextPackResponse.intent`). Absent on older servers. */
486
+ intent?: string;
487
+ /** Which layer stopped the answer (see `TerminalLayer`). Only set when `abstained`. */
488
+ terminal_layer?: TerminalLayer;
489
+ /** The unified evidence view (see `Evidence`). Present on answers AND abstains. */
490
+ evidence?: Evidence[];
491
+ }
492
+ /** One bitemporal timeline entry for an entity. */
493
+ export interface TimelineEntry {
494
+ predicate: number;
495
+ predicate_label?: string;
496
+ value: string;
497
+ /** Valid-from instant (epoch µs). */
498
+ valid_from: number;
499
+ /** Valid-until instant (epoch µs); open intervals use the max sentinel. */
500
+ valid_until: number;
501
+ /** Whether this version is active as-of the requested `at`. */
502
+ active: boolean;
503
+ }
504
+ export interface TrackEntityResponse {
505
+ /** The resolved entity id (decimal string). */
506
+ entity: string;
507
+ /** The canonical id of the alias class (decimal string). */
508
+ canonical: string;
509
+ /** The alias-class members (decimal strings). */
510
+ class: string[];
511
+ }
512
+ /** The outcome an agent reports on a traced recall. */
513
+ export type Outcome = "positive" | "negative";
514
+ /**
515
+ * The result of a `feedback`. When `applied` is FALSE the feedback was REJECTED and nothing
516
+ * was mutated — `error` says why: `"unknown_trace"` (the trace expired from the bounded cache
517
+ * or never existed) or `"cross_tenant"` (the scope did not match the traced recall).
518
+ * When `applied` is true, the IPW-Beta update ran and the abstain gate's q̂ self-tuned toward
519
+ * `realized_coverage`.
520
+ */
521
+ export interface FeedbackResponse {
522
+ applied: boolean;
523
+ /** Machine-checkable rejection kind when `applied` is false: `"unknown_trace"` | `"cross_tenant"`. */
524
+ error?: string;
525
+ /** How many cited claims were re-weighted (≤ the number cited; a stale citation is skipped). */
526
+ claims_updated: number;
527
+ /** How many cited claims could not be matched in the store (stale citations). */
528
+ claims_missed: number;
529
+ /** True iff the outcome was `"positive"` (reinforce) vs `"negative"` (down-weight). */
530
+ positive: boolean;
531
+ /** The conformal calibrator's realized coverage after this outcome (what q̂ self-tunes toward). */
532
+ realized_coverage?: number;
533
+ }
534
+ /**
535
+ * The result of a `consolidate` — the counts of what the idle-time episodic→semantic pass did.
536
+ * Retire-not-delete: as-of-T history is preserved.
537
+ */
538
+ export interface ConsolidateResponse {
539
+ /** Active claims promoted episodic→semantic (corroboration ≥ threshold). */
540
+ promoted: number;
541
+ /** Transition summaries synthesized from supersession chains (e.g. "NY→SF" as one claim). */
542
+ transitions: number;
543
+ /** Stale, never-recalled claims whose salience was decayed (confidence lowered, history kept). */
544
+ decayed: number;
545
+ }
546
+ /**
547
+ * The result of `remember_text` (free prose → extracted facts → claims). When `ok` is false the text
548
+ * could not be read (`error` says why) and nothing was written.
549
+ */
550
+ export interface RememberTextResponse {
551
+ ok: boolean;
552
+ /** Facts the reader extracted from the prose and wrote as claims. */
553
+ facts_ingested: number;
554
+ /**
555
+ * The exact triples the reader extracted and wrote, in write order. TRANSPARENCY: the reader may
556
+ * anchor a fact to a subject other than your `subjectHint`, so inspect these to know which entities
557
+ * were created — a later `forget(subjectHint)` only retires that subject's claims, not a sibling
558
+ * subject the reader chose. Empty on error.
559
+ */
560
+ facts: Fact[];
561
+ /** The underlying claim-write receipt (zeroed on error). */
562
+ remember: RememberResponse;
563
+ /** Human-readable failure reason when `ok` is false. */
564
+ error?: string;
565
+ }
566
+ /**
567
+ * The result of `ingest_image` (image → VLM caption + facts → claims, recallable by a text query).
568
+ * `ok = false` ⇒ the image could not be read (`error` says why) and nothing was written.
569
+ */
570
+ export interface IngestImageResponse {
571
+ ok: boolean;
572
+ /** The VLM caption read off the image (empty on error). */
573
+ caption: string;
574
+ /** Facts written = the caption fact + every extracted fact. */
575
+ facts_ingested: number;
576
+ /**
577
+ * The exact triples written, in write order: the `(subjectHint, "caption", caption)` fact first, then
578
+ * every extracted fact. TRANSPARENCY: inspect to see which entities the reader created. Empty on error.
579
+ */
580
+ facts: Fact[];
581
+ remember: RememberResponse;
582
+ error?: string;
583
+ }
584
+ /**
585
+ * The result of `ingest_audio` (audio → transcript + facts → claims, recallable by a text query).
586
+ * `ok = false` ⇒ the clip could not be read (`error` says why) and nothing was written.
587
+ */
588
+ export interface IngestAudioResponse {
589
+ ok: boolean;
590
+ /** The transcript read off the clip (empty on error). */
591
+ transcript: string;
592
+ /** Facts written = the transcript fact + every extracted fact. */
593
+ facts_ingested: number;
594
+ /**
595
+ * The exact triples written, in write order: the `(subjectHint, "transcript", transcript)` fact first,
596
+ * then every extracted fact. TRANSPARENCY: inspect to see which entities the reader created. Empty on error.
597
+ */
598
+ facts: Fact[];
599
+ remember: RememberResponse;
600
+ error?: string;
601
+ }
602
+ /**
603
+ * The result of `ingest_pdf` (the hybrid document path: text layer + page vision → claims, recallable by
604
+ * a text query). `ok = false` ⇒ the PDF could not be read (`error` says why) and nothing was written.
605
+ */
606
+ export interface IngestPdfResponse {
607
+ ok: boolean;
608
+ /** The extracted text layer (for reference; the recallable memory is the facts). Empty on error. */
609
+ text: string;
610
+ /** How many pages the vision half read (0 when the reader does not rasterize). */
611
+ pages_read: number;
612
+ /** Facts written = text-layer facts + per-page (caption + facts). */
613
+ facts_ingested: number;
614
+ /** The exact triples written, in write order. TRANSPARENCY: see which entities the reader created. */
615
+ facts: Fact[];
616
+ remember: RememberResponse;
617
+ error?: string;
618
+ }
619
+ /**
620
+ * The result of `ingest_structured` (CSV/JSON → claims, deterministically, no LLM).
621
+ * `ok = false` ⇒ the data could not be parsed (`error` says why) and nothing was written.
622
+ */
623
+ export interface IngestStructuredResponse {
624
+ ok: boolean;
625
+ /** Facts written = one per non-empty (subject, column/key, value). */
626
+ facts_ingested: number;
627
+ /** The exact triples written. TRANSPARENCY: see every entity/predicate/value parsed. */
628
+ facts: Fact[];
629
+ remember: RememberResponse;
630
+ error?: string;
631
+ }
632
+ /**
633
+ * The result of `ingest_any` — the universal NEVER-REJECT front door. `ok = false` ONLY for
634
+ * malformed arguments (both/neither of content_base64|text, bad base64) — never for content:
635
+ * unknown bytes, reader failures, and denied URL fetches are all `ok = true` with the degrade
636
+ * reported in `reader_error`. The original is always retained (`blob_id` = hex sha256; absent =
637
+ * oversize-skipped or a link-only URL ingest).
638
+ */
639
+ export interface IngestAnyResponse {
640
+ ok: boolean;
641
+ /** Canonical raw evidence id for this save, when bytes were retained (currently the same as blob_id). */
642
+ raw_id?: string;
643
+ /** Raw/projection lifecycle status: derived/degraded/deduped/failed today; pending_derivation for async saves. */
644
+ status: string;
645
+ /** Future write trace id hook. */
646
+ trace_id?: number;
647
+ /** What the content was sniffed as ("image/png", "url", "unknown", ...). */
648
+ detected: string;
649
+ /** The reader family that derived claims ("image"/"audio"/"pdf"/"text"/"structured"); absent = unknown/failed. */
650
+ routed?: string;
651
+ /** The retained original's hex sha256 (for a URL: the fetched snapshot's). */
652
+ blob_id?: string;
653
+ /** True iff the bytes were already retained by this tenant (no second copy appended). */
654
+ blob_deduped: boolean;
655
+ /** TAG_BLOB chunk frames holding the original. */
656
+ chunks: number;
657
+ /** The scope-folded document entity id (decimal string) the metadata claims hang off. */
658
+ document_entity: string;
659
+ /** Mention edges minted by this ingest. */
660
+ mention_edges: number;
661
+ /** Total facts written (metadata claims + routed reader claims). */
662
+ facts_ingested: number;
663
+ /** The exact triples written, in write order (metadata first). */
664
+ facts: Fact[];
665
+ /** Why routing degraded, when it did. The ingest is still a SUCCESS. */
666
+ reader_error?: string;
667
+ /** True iff this exact ingest already ran (idempotent no-op; the reader was not re-run). */
668
+ deduped: boolean;
669
+ remember: RememberResponse;
670
+ /** Model/provider stamps that participated in derivation, when reported. */
671
+ model_ids: string[];
672
+ /** Edge policy decision for the write. */
673
+ policy_decision: string;
674
+ /** Mock-reader hint, when the server detects a deterministic mock extraction path. */
675
+ hint?: string;
676
+ /** Argument failure when `ok = false`. */
677
+ error?: string;
678
+ }
679
+ /**
680
+ * The result of `forget` (retire-not-delete) or erase (OF1 destructive). `claims_retired = 0`
681
+ * is a clean no-op for retire. On erase, non-zero `spans_erased` / `claim_vectors_tombstoned` /
682
+ * `cached_embeddings_erased` mean those lanes were destroyed. Not a complete Art.17 claim.
683
+ */
684
+ export interface ForgetResponse {
685
+ claims_retired: number;
686
+ entity?: string;
687
+ spans_erased?: number;
688
+ cached_embeddings_erased?: number;
689
+ claim_vectors_tombstoned?: number;
690
+ erased?: boolean;
691
+ }
692
+ /**
693
+ * Result of `context_pack` — injectible pack + citations; no free-form synthesis (D2).
694
+ * When session trunk is on (`CILOW_SESSION_TRUNK=1` and `scope.session != 0`), `trunk` is the
695
+ * stable multi-turn prefix and `suffix` the free score-ordered tail.
696
+ */
697
+ export interface ContextPackResponse {
698
+ pack: string;
699
+ trunk?: string;
700
+ suffix?: string;
701
+ trunk_len: number;
702
+ suffix_len: number;
703
+ citations: Citation[];
704
+ claims: Claim[];
705
+ abstained: boolean;
706
+ grounding: string;
707
+ grounded: boolean;
708
+ packed_tokens: number;
709
+ intent: string;
710
+ reason?: string;
711
+ reason_code?: ReasonCode;
712
+ trace_id?: number;
713
+ best_nonconformity?: number;
714
+ q_hat?: number;
715
+ margin?: number;
716
+ pack_sufficient?: boolean | null;
717
+ as_of?: number;
718
+ citation_parts?: CitationPart[];
719
+ /** Which layer stopped the pack (see `TerminalLayer`). Only set when `abstained`. */
720
+ terminal_layer?: TerminalLayer;
721
+ /** The unified evidence view (see `Evidence`). Present on packs AND abstains. */
722
+ evidence?: Evidence[];
723
+ }
724
+ /**
725
+ * Result of `ingest` — the one write door. The server dispatches on the content FORM (`mcp.rs`
726
+ * `"save" | "ingest_any" | "ingest"` arm): `facts` ride the `remember` path and answer with a
727
+ * `RememberResponse`; `text` / bytes / a URL ride the never-reject `ingest_any` path and answer with
728
+ * an `IngestAnyResponse`. This shape unifies the two receipts:
729
+ * - `kind` — which path ran.
730
+ * - `remember` — always present: the structured write receipt (for content, the nested reader receipt).
731
+ * - `content` — the raw-durable receipt (`blob_id` / `detected` / `routed` / `reader_error`); absent for facts.
732
+ * - `facts_ingested` — facts: `claims_emitted`; content: `facts_ingested`.
733
+ * - `source_id` — the idempotency key the SDK actually SENT (a content hash when you passed none).
734
+ * `ok = false` means nothing durable was written (see `error`). A reader degrade on the content path
735
+ * is `ok = true` with `content.reader_error` set (the never-reject contract).
736
+ */
737
+ export interface IngestResponse {
738
+ kind: "facts" | "content";
739
+ source_id: string;
740
+ ok: boolean;
741
+ facts_ingested: number;
742
+ deduped: boolean;
743
+ remember: RememberResponse;
744
+ content?: IngestAnyResponse;
745
+ /** Content path only — facts writes are not traced today. */
746
+ trace_id?: number;
747
+ error?: string;
748
+ }
749
+ /** One cited claim in an `ExplainReport` (`graph_types.rs::ExplainCited`), labels resolved server-side. */
750
+ export interface ExplainCited {
751
+ entity_label?: string;
752
+ predicate_label?: string;
753
+ value: string;
754
+ /** The inclusion probability the claim was recalled under (the IPW denominator `feedback` re-weights by). */
755
+ inclusion_pi: number;
756
+ }
757
+ /**
758
+ * The `explain` report (`graph_types.rs::ExplainReport`) — the trust surface: WHY a traced read
759
+ * surfaced what it surfaced and how close it ran to the grounding threshold.
760
+ * `best_nonconformity <= q_hat` is what "grounded" means (see `isGrounded`); `q_hat` is the tenant's
761
+ * threshold at explain time and `target_alpha` the per-intent miscoverage target the read was decided at.
762
+ */
763
+ export interface ExplainReport {
764
+ abstained: boolean;
765
+ /** The best candidate's realized nonconformity (lower = better grounded). Absent/null on an abstain. */
766
+ best_nonconformity?: number | null;
767
+ q_hat: number;
768
+ target_alpha: number;
769
+ cited: ExplainCited[];
770
+ }
771
+ /**
772
+ * Result of `explain` (`wire.rs::ExplainResponse`). `found = false` is IN-BAND, not an exception:
773
+ * `error` is `unknown_trace` (expired from the bounded cache or never existed) or `cross_tenant`
774
+ * (the same opaque guard `feedback` applies). `report` is present iff `found`. Read-only — explaining
775
+ * never consumes the feedback trace.
776
+ */
777
+ export interface ExplainResponse {
778
+ found: boolean;
779
+ error?: "unknown_trace" | "cross_tenant" | string;
780
+ report?: ExplainReport;
781
+ }
782
+ /** One retained blob's metadata on the wire (no bytes — call `blobGet` for those). */
783
+ export interface BlobInfo {
784
+ /** Hex sha256 content address. */
785
+ blob_id: string;
786
+ mime: string;
787
+ byte_len: number;
788
+ source_id: string;
789
+ observed_at: number;
790
+ metadata: Array<[string, string]>;
791
+ /** Number of stored chunks (large blobs are chunked). */
792
+ chunks: number;
793
+ }
794
+ /**
795
+ * The result of `blobGet`. `found:false` with no `error` ⇒ ordinary tenant miss. `error` in
796
+ * {invalid_id, invalid_range, storage, corrupt} ⇒ a RANGE read failed — never treat as absence.
797
+ * On a range read `byte_len` is the returned window and `total_len` the complete blob length.
798
+ */
799
+ export interface BlobGetResponse {
800
+ found: boolean;
801
+ data_base64?: string;
802
+ mime?: string;
803
+ byte_len?: number;
804
+ total_len?: number;
805
+ error?: string;
806
+ }
807
+ /** The result of `blobMeta`. `found:false` ⇒ this tenant retains no such blob. */
808
+ export interface BlobMetaResponse {
809
+ found: boolean;
810
+ info?: BlobInfo;
811
+ }
812
+ /** The result of `blobList` — this tenant's retained originals, deterministically ordered. */
813
+ export interface BlobListResponse {
814
+ blobs: BlobInfo[];
815
+ total: number;
816
+ }
817
+ //# sourceMappingURL=types.d.ts.map