hebbrix 2.1.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,27 @@
1
+ # Changelog
2
+
3
+ ## 2.2.1 — 2026-08-26
4
+
5
+ - Preserve bearer authentication, content type, user agent, idempotency, and
6
+ caller-supplied headers on every request.
7
+ - Handle `204`, empty, and non-JSON successful responses without attempting an
8
+ unconditional JSON parse.
9
+ - Preserve valid evidence-bound search rows during a degraded or abstaining
10
+ server response while retaining the safety metadata; malformed and explicit
11
+ no-match envelopes still fail closed.
12
+ - Preserve caller-provided abort signals while retaining the default timeout.
13
+ - Add `temporal.deleteFact(factId)` for tenant-scoped, idempotent cleanup of
14
+ facts created through the temporal API.
15
+ - Align procedure create/list/get/update/execute/delete with the canonical
16
+ `/v1/procedures` REST and OpenAPI contract, including empty `204` deletion.
17
+ - Add explicit synchronous/asynchronous batch readiness receipts and
18
+ `waitForBatchSearchable`, which polls every accepted memory, propagates
19
+ terminal failures, respects deadlines, and supports cancellation.
20
+
21
+ The supported server/SDK release pair is published by the server OpenAPI
22
+ document in `info.x-hebbrix-sdk-compatibility`. Patch releases preserve the
23
+ public API within the same major version.
24
+
25
+ ## 2.2.0
26
+
27
+ - Added the GA scoped memory, corrections, search proof, and ProofLoop surface.
package/README.md CHANGED
@@ -50,8 +50,22 @@ const main = async () => {
50
50
  collection_id: collection.id,
51
51
  content: 'User prefers dark mode and loves TypeScript',
52
52
  importance: 0.9,
53
+ wait_for_index: true,
53
54
  });
54
55
 
56
+ // Batch writes have an explicit two-mode contract. With wait_for_index=true,
57
+ // success means every item is searchable; a server deadline rejects with a
58
+ // retryable error instead of returning a misleading successful 202.
59
+ const batch = await client.memories.createBatch({
60
+ memories: [{ content: 'First fact' }, { content: 'Second fact' }],
61
+ collection_id: collection.id,
62
+ wait_for_index: true,
63
+ idempotency_key: 'import-42',
64
+ });
65
+
66
+ // For fire-and-forget batches, poll every item (with timeout/cancellation):
67
+ // await client.memories.waitForBatchSearchable(batch, { signal });
68
+
55
69
  // Search memories
56
70
  const results = await client.search({
57
71
  query: 'What programming language does user like?',
@@ -322,6 +336,8 @@ const updated = await client.procedural.update(procedure.id, {
322
336
 
323
337
  // Delete procedure
324
338
  await client.procedural.delete(procedure.id);
339
+ // DELETE is tenant-scoped and idempotent: deleted, absent, and foreign IDs all
340
+ // return 204 without revealing whether another tenant owns the identifier.
325
341
  ```
326
342
 
327
343
  ### 8. Temporal Knowledge Graphs
package/dist/index.d.mts CHANGED
@@ -57,8 +57,27 @@ interface SearchResponse {
57
57
  total: number;
58
58
  search_type: string;
59
59
  processing_time_ms: number;
60
+ no_match: boolean;
61
+ abstain_recommended: boolean;
62
+ query_confidence: number;
63
+ grounding: GroundingReceipt;
64
+ evidence_ids: string[];
65
+ evidence_claims?: EvidenceClaim[];
66
+ safety_contract_version: string;
67
+ degraded?: boolean;
68
+ sdk_safety_reason?: string;
60
69
  proof_context?: ProofContext;
61
70
  }
71
+ interface GroundingReceipt {
72
+ status: string;
73
+ reason?: string;
74
+ contract_version?: string;
75
+ [key: string]: unknown;
76
+ }
77
+ interface EvidenceClaim {
78
+ memory_id: string;
79
+ claims: Record<string, unknown>;
80
+ }
62
81
  interface ProofContext {
63
82
  schema_version: "proofloop-context-v1";
64
83
  context_id: string;
@@ -88,9 +107,18 @@ interface ReasoningSource {
88
107
  score: number;
89
108
  }
90
109
  interface ReasoningResponse {
91
- answer: string;
110
+ answer: string | null;
92
111
  sources: ReasoningSource[];
93
112
  metadata: Record<string, any>;
113
+ no_match: boolean;
114
+ abstain_recommended: boolean;
115
+ query_confidence: number;
116
+ grounding: GroundingReceipt;
117
+ evidence_ids: string[];
118
+ evidence_claims?: EvidenceClaim[];
119
+ safety_contract_version: string;
120
+ degraded?: boolean;
121
+ sdk_safety_reason?: string;
94
122
  reasoning_context?: Record<string, any>;
95
123
  }
96
124
  interface CreateCollectionParams {
@@ -104,17 +132,93 @@ interface UpdateCollectionParams {
104
132
  metadata?: Record<string, any>;
105
133
  }
106
134
  interface CreateMemoryParams {
107
- collection_id: string;
108
- content: string;
135
+ collection_id?: string;
136
+ content?: string;
137
+ messages?: Array<{
138
+ role: string;
139
+ content: string;
140
+ }>;
109
141
  importance?: number;
110
142
  source_type?: string;
111
143
  source_reference?: string;
112
144
  metadata?: Record<string, any>;
145
+ infer?: boolean;
146
+ user_id?: string;
147
+ agent_id?: string;
148
+ run_id?: string;
149
+ app_id?: string;
150
+ namespace?: string;
151
+ wait_for_index?: boolean;
152
+ async_dispatch?: boolean;
153
+ title?: string;
154
+ tags?: string[];
155
+ source?: string;
156
+ /** Stable retry key sent as the Idempotency-Key transport header. */
157
+ idempotency_key?: string;
158
+ }
159
+ interface MemoryAddResult {
160
+ id: string;
161
+ memory_id?: string;
162
+ event: "ADD" | "UPDATE" | "NOOP" | string;
163
+ memory?: string;
164
+ reason?: string;
165
+ }
166
+ interface MemoryAddResponse {
167
+ results: MemoryAddResult[];
168
+ collection_id?: string;
169
+ processing_status: string;
170
+ searchable: boolean;
171
+ outbox_event_id?: string;
172
+ status_url?: string;
173
+ job_id?: string;
174
+ created_count: number;
175
+ updated_count: number;
176
+ skipped_count: number;
177
+ }
178
+ interface BatchMemoryItemParams {
179
+ content: string;
180
+ collection_id?: string;
181
+ importance?: number;
182
+ user_id?: string;
183
+ agent_id?: string;
184
+ run_id?: string;
185
+ tags?: string[];
186
+ metadata?: Record<string, any>;
187
+ }
188
+ interface BatchMemoryCreateParams {
189
+ memories: BatchMemoryItemParams[];
190
+ collection_id?: string;
191
+ user_id?: string;
192
+ agent_id?: string;
193
+ run_id?: string;
194
+ app_id?: string;
195
+ namespace?: string;
196
+ wait_for_index?: boolean;
197
+ /** Stable retry key sent as the Idempotency-Key transport header. */
198
+ idempotency_key?: string;
199
+ /** Optional caller cancellation signal; it is never serialized. */
200
+ signal?: AbortSignal;
201
+ }
202
+ interface BatchMemoryResponse {
203
+ created: number;
204
+ failed: number;
205
+ memory_ids: string[];
206
+ errors: string[];
207
+ results: Array<{
208
+ id: string;
209
+ memory_id?: string;
210
+ processing_status: string;
211
+ }>;
212
+ processing_status: string;
213
+ searchable: boolean;
214
+ outbox_event_id?: string;
215
+ status_url?: string;
113
216
  }
114
217
  interface UpdateMemoryParams {
115
218
  content?: string;
116
219
  importance?: number;
117
220
  metadata?: Record<string, any>;
221
+ wait_for_index?: boolean;
118
222
  }
119
223
  interface SearchParams {
120
224
  query: string;
@@ -123,17 +227,81 @@ interface SearchParams {
123
227
  search_type?: "hybrid" | "vector" | "bm25" | "graph";
124
228
  filters?: Record<string, any>;
125
229
  user_id?: string;
230
+ agent_id?: string;
231
+ run_id?: string;
232
+ fast?: boolean;
233
+ threshold?: number;
234
+ include_low_confidence?: boolean;
235
+ group_by_source?: boolean;
236
+ debug?: boolean;
126
237
  }
127
238
  interface ReasonParams {
128
239
  query: string;
129
240
  collection_id?: string;
130
241
  provider?: "gemini" | "openai" | "anthropic";
131
242
  include_steps?: boolean;
243
+ user_id?: string;
244
+ agent_id?: string;
245
+ run_id?: string;
246
+ facets?: string[];
132
247
  }
133
248
  interface ListParams {
134
249
  skip?: number;
135
250
  limit?: number;
136
251
  }
252
+ interface MemoryListParams {
253
+ collection_id?: string;
254
+ user_id?: string;
255
+ agent_id?: string;
256
+ run_id?: string;
257
+ scope?: "all";
258
+ cursor?: string;
259
+ limit?: number;
260
+ include_superseded?: boolean;
261
+ }
262
+ interface CursorPage<T> {
263
+ items: T[];
264
+ next_cursor?: string | null;
265
+ has_more: boolean;
266
+ total_count: number;
267
+ }
268
+ interface MemoryJobReceipt {
269
+ job_id?: string;
270
+ status: string;
271
+ [key: string]: any;
272
+ }
273
+ interface CorrectionCreateParams {
274
+ corrected_content: string;
275
+ correction_type?: "preference" | "factual" | "procedural" | string;
276
+ original_content?: string;
277
+ context?: string;
278
+ memory_id?: string;
279
+ collection_id?: string;
280
+ user_id?: string;
281
+ agent_id?: string;
282
+ confidence?: number;
283
+ metadata?: Record<string, any>;
284
+ idempotency_key?: string;
285
+ }
286
+ interface CorrectionSearchParams {
287
+ query: string;
288
+ correction_type?: string;
289
+ collection_id?: string;
290
+ user_id?: string;
291
+ agent_id?: string;
292
+ include_global?: boolean;
293
+ limit?: number;
294
+ }
295
+ interface ProofLoopMetricParams {
296
+ policy_key: string;
297
+ metric_key: string;
298
+ name: string;
299
+ min_value: number;
300
+ max_value: number;
301
+ collection_id?: string;
302
+ user_id?: string;
303
+ [key: string]: any;
304
+ }
137
305
  interface APIKeyResponse {
138
306
  id: string;
139
307
  name: string;
@@ -194,13 +362,26 @@ declare class MemoriesResource extends BaseResource {
194
362
  /**
195
363
  * Create a new memory
196
364
  */
197
- create(params: CreateMemoryParams): Promise<Memory>;
365
+ create(params: CreateMemoryParams): Promise<MemoryAddResponse>;
366
+ /**
367
+ * Create up to 100 memories with one unambiguous readiness contract.
368
+ * `wait_for_index=true` resolves only for a fully searchable batch; a server
369
+ * deadline or indexing failure rejects the request instead of returning a
370
+ * successful processing receipt.
371
+ */
372
+ createBatch(params: BatchMemoryCreateParams): Promise<BatchMemoryResponse>;
373
+ /** Poll every item in an asynchronous batch receipt until it is searchable. */
374
+ waitForBatchSearchable(receipt: BatchMemoryResponse, options?: {
375
+ timeoutMs?: number;
376
+ pollIntervalMs?: number;
377
+ signal?: AbortSignal;
378
+ }): Promise<BatchMemoryResponse>;
198
379
  /**
199
380
  * List memories
200
381
  */
201
- list(params?: ListParams & {
202
- collection_id?: string;
203
- }): Promise<Memory[]>;
382
+ listPage(params?: MemoryListParams): Promise<CursorPage<Memory>>;
383
+ /** Back-compatible one-page convenience; use listPage for cursor metadata. */
384
+ list(params?: MemoryListParams): Promise<Memory[]>;
204
385
  /**
205
386
  * Get a specific memory
206
387
  */
@@ -214,6 +395,19 @@ declare class MemoriesResource extends BaseResource {
214
395
  */
215
396
  delete(memoryId: string): Promise<void>;
216
397
  }
398
+ declare class MemoryJobsResource extends BaseResource {
399
+ get(jobId: string): Promise<MemoryJobReceipt>;
400
+ wait(jobId: string, options?: {
401
+ timeoutMs?: number;
402
+ pollIntervalMs?: number;
403
+ }): Promise<MemoryJobReceipt>;
404
+ }
405
+ declare class CorrectionsResource extends BaseResource {
406
+ create(params: CorrectionCreateParams): Promise<Record<string, any>>;
407
+ relevant(params: CorrectionSearchParams): Promise<Array<Record<string, any>>>;
408
+ get(correctionId: string): Promise<Record<string, any>>;
409
+ delete(correctionId: string): Promise<Record<string, any>>;
410
+ }
217
411
  declare class SearchResource extends BaseResource {
218
412
  /**
219
413
  * Search memories
@@ -239,8 +433,26 @@ declare class ProofLoopResource extends BaseResource {
239
433
  success?: boolean;
240
434
  idempotency_key?: string;
241
435
  }): Promise<Record<string, any>>;
436
+ getDecision(decisionId: string): Promise<Record<string, any>>;
437
+ defineMetric(params: ProofLoopMetricParams): Promise<Record<string, any>>;
438
+ listMetrics(params?: {
439
+ policy_key?: string;
440
+ collection_id?: string;
441
+ user_id?: string;
442
+ }): Promise<Record<string, any>>;
443
+ policyInsights(policyKey: string, params?: {
444
+ collection_id?: string;
445
+ user_id?: string;
446
+ action_keys?: string[];
447
+ context?: Record<string, any>;
448
+ }): Promise<Record<string, any>>;
449
+ evaluatePolicy(policyKey: string, params?: {
450
+ collection_id?: string;
451
+ user_id?: string;
452
+ limit?: number;
453
+ }): Promise<Record<string, any>>;
242
454
  proof(decisionId: string): Promise<Record<string, any>>;
243
- publicKey(): Promise<Record<string, any>>;
455
+ publicKey(keyId?: string): Promise<Record<string, any>>;
244
456
  }
245
457
  declare class RLResource extends BaseResource {
246
458
  /**
@@ -269,6 +481,7 @@ declare class RLResource extends BaseResource {
269
481
  evaluate(agentType: string, collectionId?: string): Promise<any>;
270
482
  }
271
483
  declare class ProceduralResource extends BaseResource {
484
+ private unwrapProcedure;
272
485
  /**
273
486
  * Create a new procedure
274
487
  */
@@ -340,6 +553,8 @@ declare class TemporalResource extends BaseResource {
340
553
  * Query knowledge state at a specific point in time
341
554
  */
342
555
  pointInTime(timestamp: string, entity?: string): Promise<any>;
556
+ /** Permanently delete a tenant-scoped temporal fact by stable ID. */
557
+ deleteFact(factId: string): Promise<any>;
343
558
  }
344
559
  declare class WorkingMemoryResource extends BaseResource {
345
560
  /**
@@ -418,6 +633,8 @@ declare class MemoryClient {
418
633
  auth: AuthResource;
419
634
  collections: CollectionsResource;
420
635
  memories: MemoriesResource;
636
+ memoryJobs: MemoryJobsResource;
637
+ corrections: CorrectionsResource;
421
638
  private searchResource;
422
639
  rl: RLResource;
423
640
  procedural: ProceduralResource;
@@ -464,4 +681,24 @@ declare class ServerError extends HebbrixError {
464
681
  constructor(message?: string);
465
682
  }
466
683
 
467
- export { type APIKeyResponse, AuthResource, type AuthResponse, AuthenticationError, type ClientConfig, type Collection, CollectionsResource, ConsolidationResource, type CreateCollectionParams, type CreateMemoryParams, HebbrixError, type ListParams, MemoriesResource, type Memory, MemoryClient, MemoryToolsResource, type MemoryWithMetadata, NotFoundError, ProceduralResource, type ProofContext, type ProofLoopCandidate, type ProofLoopDecisionParams, ProofLoopResource, RLResource, RateLimitError, type ReasonParams, type ReasoningResponse, type ReasoningSource, type SearchParams, SearchResource, type SearchResponse, type SearchResult, ServerError, TemporalResource, type UpdateCollectionParams, type UpdateMemoryParams, type User, ValidationError, WorkingMemoryResource, WorldModelResource };
684
+ interface SafetyEnvelope {
685
+ no_match: boolean;
686
+ abstain_recommended: boolean;
687
+ query_confidence: number;
688
+ grounding: GroundingReceipt;
689
+ evidence_ids: string[];
690
+ evidence_claims?: unknown[];
691
+ safety_contract_version: string;
692
+ degraded?: boolean;
693
+ sdk_safety_reason?: string;
694
+ [key: string]: unknown;
695
+ }
696
+ /**
697
+ * Validate the API-owned grounding receipt before exposing evidence to an agent.
698
+ * A malformed or explicit no-match response is converted into one deterministic
699
+ * no-match envelope. Degraded, evidence-bound rows remain visible together with
700
+ * the API's abstention signal so the SDK cannot introduce a false negative.
701
+ */
702
+ declare function enforceSearchSafety<T extends object>(response: T, rowsKey?: "results" | "sources"): T & SafetyEnvelope;
703
+
704
+ export { type APIKeyResponse, AuthResource, type AuthResponse, AuthenticationError, type BatchMemoryCreateParams, type BatchMemoryItemParams, type BatchMemoryResponse, type ClientConfig, type Collection, CollectionsResource, ConsolidationResource, type CorrectionCreateParams, type CorrectionSearchParams, CorrectionsResource, type CreateCollectionParams, type CreateMemoryParams, type CursorPage, type EvidenceClaim, type GroundingReceipt, HebbrixError, type ListParams, MemoriesResource, type Memory, type MemoryAddResponse, type MemoryAddResult, MemoryClient, type MemoryJobReceipt, MemoryJobsResource, type MemoryListParams, MemoryToolsResource, type MemoryWithMetadata, NotFoundError, ProceduralResource, type ProofContext, type ProofLoopCandidate, type ProofLoopDecisionParams, type ProofLoopMetricParams, ProofLoopResource, RLResource, RateLimitError, type ReasonParams, type ReasoningResponse, type ReasoningSource, type SafetyEnvelope, type SearchParams, SearchResource, type SearchResponse, type SearchResult, ServerError, TemporalResource, type UpdateCollectionParams, type UpdateMemoryParams, type User, ValidationError, WorkingMemoryResource, WorldModelResource, enforceSearchSafety };