@cilow/sdk 0.2.1 → 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 (84) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +109 -492
  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 +512 -173
  32. package/dist/client.d.ts.map +1 -0
  33. package/dist/client.js +648 -504
  34. package/dist/client.js.map +1 -1
  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 +18 -109
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +16 -876
  46. package/dist/index.js.map +1 -1
  47. package/dist/types.d.ts +809 -486
  48. package/dist/types.d.ts.map +1 -0
  49. package/dist/types.js +18 -17
  50. package/dist/types.js.map +1 -1
  51. package/package.json +30 -103
  52. package/dist/client.d.mts +0 -224
  53. package/dist/client.mjs +0 -505
  54. package/dist/client.mjs.map +0 -1
  55. package/dist/index.d.mts +0 -111
  56. package/dist/index.mjs +0 -863
  57. package/dist/index.mjs.map +0 -1
  58. package/dist/providers/langchain.js +0 -821
  59. package/dist/providers/langchain.js.map +0 -1
  60. package/dist/providers/langchain.mjs +0 -816
  61. package/dist/providers/langchain.mjs.map +0 -1
  62. package/dist/providers/openai.js +0 -737
  63. package/dist/providers/openai.js.map +0 -1
  64. package/dist/providers/openai.mjs +0 -732
  65. package/dist/providers/openai.mjs.map +0 -1
  66. package/dist/providers/vercel.js +0 -866
  67. package/dist/providers/vercel.js.map +0 -1
  68. package/dist/providers/vercel.mjs +0 -860
  69. package/dist/providers/vercel.mjs.map +0 -1
  70. package/dist/react/hooks.d.mts +0 -327
  71. package/dist/react/hooks.d.ts +0 -327
  72. package/dist/react/hooks.js +0 -1183
  73. package/dist/react/hooks.js.map +0 -1
  74. package/dist/react/hooks.mjs +0 -1172
  75. package/dist/react/hooks.mjs.map +0 -1
  76. package/dist/types.d.mts +0 -494
  77. package/dist/types.mjs +0 -14
  78. package/dist/types.mjs.map +0 -1
  79. package/dist/websocket.d.mts +0 -160
  80. package/dist/websocket.d.ts +0 -160
  81. package/dist/websocket.js +0 -342
  82. package/dist/websocket.js.map +0 -1
  83. package/dist/websocket.mjs +0 -339
  84. package/dist/websocket.mjs.map +0 -1
package/dist/types.d.ts CHANGED
@@ -1,494 +1,817 @@
1
1
  /**
2
- * Cilow SDK TypeScript Type Definitions
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.
3
4
  *
4
- * Comprehensive type definitions for the Cilow memory system.
5
- */
6
- /**
7
- * Memory tier classification based on access frequency and recency
8
- */
9
- type MemoryTier = 'hot' | 'warm' | 'cold';
10
- /**
11
- * Memory status for lifecycle management
12
- */
13
- type MemoryStatus = 'active' | 'archived' | 'deleted';
14
- /**
15
- * Core memory entity representing a stored piece of information
16
- */
17
- interface Memory {
18
- /** Unique identifier for the memory */
19
- id: string;
20
- /** The content of the memory */
21
- content: string;
22
- /** Tags for categorization and filtering */
23
- tags: string[];
24
- /** User ID associated with this memory */
25
- userId?: string;
26
- /** Session ID for grouping related memories */
27
- sessionId?: string;
28
- /** Current tier classification */
29
- tier: MemoryTier;
30
- /** Memory status */
31
- status: MemoryStatus;
32
- /** Access count for prioritization */
33
- accessCount: number;
34
- /** Token count for the content */
35
- tokenCount: number;
36
- /** Embedding vector (if available) */
37
- embedding?: number[];
38
- /** Additional metadata */
39
- metadata: Record<string, unknown>;
40
- /** ISO timestamp of creation */
41
- createdAt: string;
42
- /** ISO timestamp of last update */
43
- updatedAt: string;
44
- /** ISO timestamp of last access */
45
- lastAccessedAt: string;
46
- }
47
- /**
48
- * Minimal memory representation for list operations
49
- */
50
- interface MemorySummary {
51
- id: string;
52
- content: string;
53
- tags: string[];
54
- tier: MemoryTier;
55
- createdAt: string;
56
- }
57
- /**
58
- * Options for creating a new memory
59
- */
60
- interface CreateMemoryOptions {
61
- /** Tags to apply to the memory */
62
- tags?: string[];
63
- /** User ID to associate */
64
- userId?: string;
65
- /** Session ID for grouping */
66
- sessionId?: string;
67
- /** Additional metadata */
68
- metadata?: Record<string, unknown>;
69
- /** Force a specific tier */
70
- tier?: MemoryTier;
71
- }
72
- /**
73
- * Options for updating a memory
74
- */
75
- interface UpdateMemoryOptions {
76
- /** New content */
77
- content?: string;
78
- /** New tags (replaces existing) */
79
- tags?: string[];
80
- /** Updated metadata (merged with existing) */
81
- metadata?: Record<string, unknown>;
82
- /** Force tier change */
83
- tier?: MemoryTier;
84
- }
85
- /**
86
- * Search result containing a memory and its relevance score
87
- */
88
- interface SearchResult {
89
- /** The matching memory */
90
- memory: Memory;
91
- /** Relevance score (0.0 - 1.0) */
92
- score: number;
93
- /** Matched terms or phrases */
94
- matchedTerms?: string[];
95
- /** Highlighted content snippets */
96
- highlights?: string[];
97
- }
98
- /**
99
- * Search query parameters
100
- */
101
- interface SearchQuery {
102
- /** The search text */
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;
103
110
  text: string;
104
- /** Maximum number of results */
105
- limit?: number;
106
- /** Minimum relevance score threshold (0.0 - 1.0) */
107
- minRelevance?: number;
108
- /** Filter by tags (AND logic) */
109
- tags?: string[];
110
- /** Filter by user ID */
111
- userId?: string;
112
- /** Filter by session ID */
113
- sessionId?: string;
114
- /** Filter by tier */
115
- tier?: MemoryTier;
116
- /** Filter by date range - start */
117
- createdAfter?: string;
118
- /** Filter by date range - end */
119
- createdBefore?: string;
120
- /** Include archived memories */
121
- includeArchived?: boolean;
122
- /** Search mode */
123
- mode?: 'semantic' | 'keyword' | 'hybrid';
124
- }
125
- /**
126
- * Advanced search options for complex queries
127
- */
128
- interface AdvancedSearchOptions extends SearchQuery {
129
- /** Boost recent memories */
130
- recencyBoost?: number;
131
- /** Boost frequently accessed memories */
132
- frequencyBoost?: number;
133
- /** Required tags (must have all) */
134
- requiredTags?: string[];
135
- /** Excluded tags (must not have any) */
136
- excludedTags?: string[];
137
- /** Metadata filters */
138
- metadataFilters?: Record<string, unknown>;
139
- /** Custom reranking function name */
140
- reranker?: string;
141
- }
142
- /**
143
- * Node in the memory knowledge graph
144
- */
145
- interface GraphNode {
146
- /** Unique node identifier */
147
- id: string;
148
- /** Node type/label */
149
- type: string;
150
- /** Display name */
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 {
151
258
  name: string;
152
- /** Node properties */
153
- properties: Record<string, unknown>;
154
- /** Associated memory IDs */
155
- memoryIds: string[];
156
- /** Creation timestamp */
157
- createdAt: string;
158
- /** Last update timestamp */
159
- updatedAt: string;
160
- }
161
- /**
162
- * Edge connecting two nodes in the graph
163
- */
164
- interface GraphEdge {
165
- /** Unique edge identifier */
166
- id: string;
167
- /** Source node ID */
168
- sourceId: string;
169
- /** Target node ID */
170
- targetId: string;
171
- /** Relationship type */
172
- type: string;
173
- /** Edge weight/strength */
174
- weight: number;
175
- /** Edge properties */
176
- properties: Record<string, unknown>;
177
- /** Creation timestamp */
178
- createdAt: string;
179
- }
180
- /**
181
- * Subgraph result for graph traversal queries
182
- */
183
- interface GraphSubgraph {
184
- /** Nodes in the subgraph */
185
- nodes: GraphNode[];
186
- /** Edges in the subgraph */
187
- edges: GraphEdge[];
188
- /** Central node ID (if applicable) */
189
- centerId?: string;
190
- }
191
- /**
192
- * Options for graph traversal
193
- */
194
- interface GraphTraversalOptions {
195
- /** Starting node ID */
196
- startNodeId: string;
197
- /** Maximum traversal depth */
198
- maxDepth?: number;
199
- /** Filter by relationship types */
200
- relationshipTypes?: string[];
201
- /** Maximum nodes to return */
202
- limit?: number;
203
- /** Traversal direction */
204
- direction?: 'outbound' | 'inbound' | 'both';
205
- }
206
- /**
207
- * Memory system statistics
208
- */
209
- interface MemoryStats {
210
- /** Total number of memories */
211
- totalMemories: number;
212
- /** Number of hot tier memories */
213
- hotMemories: number;
214
- /** Number of warm tier memories */
215
- warmMemories: number;
216
- /** Number of cold tier memories */
217
- coldMemories: number;
218
- /** Total token count across all memories */
219
- totalTokens: number;
220
- /** Average tokens per memory */
221
- averageTokensPerMemory: number;
222
- /** Number of unique users */
223
- uniqueUsers: number;
224
- /** Number of unique sessions */
225
- uniqueSessions: number;
226
- /** Total number of tags */
227
- totalTags: number;
228
- /** Storage size in bytes */
229
- storageSizeBytes: number;
230
- /** Stats generation timestamp */
231
- generatedAt: string;
232
- }
233
- /**
234
- * Tag with usage count
235
- */
236
- interface TagCount {
237
- /** Tag name */
238
- tag: string;
239
- /** Usage count */
240
- count: number;
241
- }
242
- /**
243
- * User activity statistics
244
- */
245
- interface UserStats {
246
- /** User ID */
247
- userId: string;
248
- /** Number of memories */
249
- memoryCount: number;
250
- /** Total tokens used */
251
- totalTokens: number;
252
- /** Number of sessions */
253
- sessionCount: number;
254
- /** First activity timestamp */
255
- firstActivityAt: string;
256
- /** Last activity timestamp */
257
- lastActivityAt: string;
258
- }
259
- /**
260
- * Base event type
261
- */
262
- interface BaseEvent {
263
- /** Event type identifier */
264
- type: string;
265
- /** Event timestamp */
266
- timestamp: string;
267
- /** Correlation ID for tracking */
268
- correlationId?: string;
269
- }
270
- /**
271
- * Memory created event
272
- */
273
- interface MemoryCreatedEvent extends BaseEvent {
274
- type: 'memory.created';
275
- /** The created memory */
276
- memory: Memory;
277
- }
278
- /**
279
- * Memory updated event
280
- */
281
- interface MemoryUpdatedEvent extends BaseEvent {
282
- type: 'memory.updated';
283
- /** The updated memory */
284
- memory: Memory;
285
- /** Changed fields */
286
- changedFields: string[];
287
- }
288
- /**
289
- * Memory deleted event
290
- */
291
- interface MemoryDeletedEvent extends BaseEvent {
292
- type: 'memory.deleted';
293
- /** Deleted memory ID */
294
- memoryId: string;
295
- }
296
- /**
297
- * Memory tier changed event
298
- */
299
- interface MemoryTierChangedEvent extends BaseEvent {
300
- type: 'memory.tier_changed';
301
- /** Memory ID */
302
- memoryId: string;
303
- /** Previous tier */
304
- previousTier: MemoryTier;
305
- /** New tier */
306
- newTier: MemoryTier;
307
- }
308
- /**
309
- * Graph node created event
310
- */
311
- interface GraphNodeCreatedEvent extends BaseEvent {
312
- type: 'graph.node_created';
313
- /** The created node */
314
- node: GraphNode;
315
- }
316
- /**
317
- * Graph edge created event
318
- */
319
- interface GraphEdgeCreatedEvent extends BaseEvent {
320
- type: 'graph.edge_created';
321
- /** The created edge */
322
- edge: GraphEdge;
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;
323
375
  }
324
- /**
325
- * Connection status event
326
- */
327
- interface ConnectionStatusEvent extends BaseEvent {
328
- type: 'connection.status';
329
- /** Connection status */
330
- status: 'connected' | 'disconnected' | 'reconnecting';
331
- /** Reason for status change */
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`). */
332
407
  reason?: string;
333
- }
334
- /**
335
- * Union type of all events
336
- */
337
- type CilowEvent = MemoryCreatedEvent | MemoryUpdatedEvent | MemoryDeletedEvent | MemoryTierChangedEvent | GraphNodeCreatedEvent | GraphEdgeCreatedEvent | ConnectionStatusEvent;
338
- /**
339
- * Pagination parameters
340
- */
341
- interface PaginationParams {
342
- /** Number of items per page */
343
- limit?: number;
344
- /** Offset for pagination */
345
- offset?: number;
346
- /** Cursor for cursor-based pagination */
347
- cursor?: string;
348
- }
349
- /**
350
- * Paginated response wrapper
351
- */
352
- interface PaginatedResponse<T> {
353
- /** Items in this page */
354
- items: T[];
355
- /** Total count of items */
356
- total: number;
357
- /** Current offset */
358
- offset: number;
359
- /** Items per page */
360
- limit: number;
361
- /** Cursor for next page */
362
- nextCursor?: string;
363
- /** Whether there are more items */
364
- hasMore: boolean;
365
- }
366
- /**
367
- * API error response
368
- */
369
- interface ApiError {
370
- /** Error code */
371
- code: string;
372
- /** Human-readable error message */
373
- message: string;
374
- /** Additional error details */
375
- details?: Record<string, unknown>;
376
- /** Request ID for debugging */
377
- requestId?: string;
378
- }
379
- /**
380
- * Health check response
381
- */
382
- interface HealthCheck {
383
- /** Service status */
384
- status: 'healthy' | 'degraded' | 'unhealthy';
385
- /** Service version */
386
- version: string;
387
- /** Uptime in seconds */
388
- uptimeSeconds: number;
389
- /** Component statuses */
390
- components: {
391
- name: string;
392
- status: 'healthy' | 'degraded' | 'unhealthy';
393
- latencyMs?: number;
394
- }[];
395
- }
396
- /**
397
- * Client configuration options
398
- */
399
- interface CilowConfig {
400
- /** Base URL of the Cilow API */
401
- apiUrl: string;
402
- /** API key for authentication */
403
- apiKey: string;
404
- /** Request timeout in milliseconds */
405
- timeout?: number;
406
- /** Number of retry attempts for failed requests */
407
- retries?: number;
408
- /** Custom headers to include in requests */
409
- headers?: Record<string, string>;
410
- /** Enable debug logging */
411
- debug?: boolean;
412
- }
413
- /**
414
- * WebSocket configuration options
415
- */
416
- interface WebSocketConfig {
417
- /** WebSocket URL (defaults to apiUrl with ws:// protocol) */
418
- wsUrl?: string;
419
- /** Reconnection attempts */
420
- reconnectAttempts?: number;
421
- /** Reconnection delay in milliseconds */
422
- reconnectDelay?: number;
423
- /** Heartbeat interval in milliseconds */
424
- heartbeatInterval?: number;
425
- /** Message queue size for offline buffering */
426
- messageQueueSize?: number;
427
- }
428
- /**
429
- * Combined configuration for full client
430
- */
431
- interface FullCilowConfig extends CilowConfig, WebSocketConfig {
432
- /** Default user ID for all operations */
433
- defaultUserId?: string;
434
- /** Default session ID */
435
- defaultSessionId?: string;
436
- /** Default tags to apply */
437
- defaultTags?: string[];
438
- }
439
- /**
440
- * Context result for AI integrations
441
- */
442
- interface ContextResult {
443
- /** Formatted context string */
444
- context: string;
445
- /** Number of memories used */
446
- memoriesUsed: number;
447
- /** Estimated token count */
448
- estimatedTokens: number;
449
- /** Memory IDs included */
450
- memoryIds: string[];
451
- /** Search scores */
452
- scores: number[];
453
- }
454
- /**
455
- * Conversation turn for storing dialogues
456
- */
457
- interface ConversationTurn {
458
- /** User's message */
459
- userMessage: string;
460
- /** Assistant's response */
461
- assistantResponse: string;
462
- /** Session ID */
463
- sessionId?: string;
464
- /** Additional metadata */
465
- metadata?: Record<string, unknown>;
466
- }
467
- /**
468
- * Batch operation result
469
- */
470
- interface BatchResult<T> {
471
- /** Successful operations */
472
- succeeded: T[];
473
- /** Failed operations with errors */
474
- failed: {
475
- item: T;
476
- error: string;
477
- }[];
478
- /** Total operations attempted */
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[];
479
815
  total: number;
480
816
  }
481
- /**
482
- * Check if an event is a memory event
483
- */
484
- declare function isMemoryEvent(event: CilowEvent): event is MemoryCreatedEvent | MemoryUpdatedEvent | MemoryDeletedEvent;
485
- /**
486
- * Check if an event is a graph event
487
- */
488
- declare function isGraphEvent(event: CilowEvent): event is GraphNodeCreatedEvent | GraphEdgeCreatedEvent;
489
- /**
490
- * Check if an object is an API error
491
- */
492
- declare function isApiError(obj: unknown): obj is ApiError;
493
-
494
- export { type AdvancedSearchOptions, type ApiError, type BaseEvent, type BatchResult, type CilowConfig, type CilowEvent, type ConnectionStatusEvent, type ContextResult, type ConversationTurn, type CreateMemoryOptions, type FullCilowConfig, type GraphEdge, type GraphEdgeCreatedEvent, type GraphNode, type GraphNodeCreatedEvent, type GraphSubgraph, type GraphTraversalOptions, type HealthCheck, type Memory, type MemoryCreatedEvent, type MemoryDeletedEvent, type MemoryStats, type MemoryStatus, type MemorySummary, type MemoryTier, type MemoryTierChangedEvent, type MemoryUpdatedEvent, type PaginatedResponse, type PaginationParams, type SearchQuery, type SearchResult, type TagCount, type UpdateMemoryOptions, type UserStats, type WebSocketConfig, isApiError, isGraphEvent, isMemoryEvent };
817
+ //# sourceMappingURL=types.d.ts.map