hebbrix 2.0.2 → 2.2.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.
- package/LICENSE +21 -0
- package/README.md +23 -0
- package/dist/index.d.mts +234 -15
- package/dist/index.d.ts +234 -15
- package/dist/index.js +218 -12
- package/dist/index.mjs +213 -11
- package/package.json +8 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Hebbrix
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ Official TypeScript/JavaScript SDK for the Hebbrix api - **the only memory API w
|
|
|
14
14
|
- ✅ **Procedural Memory** - Store and execute learned skills
|
|
15
15
|
- ✅ **Working Memory** - Short-term context buffer for conversations
|
|
16
16
|
- ✅ **Memory Consolidation** - Automatic compression of episodic memories
|
|
17
|
+
- ✅ **ProofLoop** - Learn from outcomes with automatic, verifiable evidence receipts
|
|
17
18
|
- ✅ **Promise-based** - Native async/await support
|
|
18
19
|
- ✅ **Type-safe** - Complete TypeScript type definitions
|
|
19
20
|
- ✅ **Universal** - Works in Node.js and browsers
|
|
@@ -73,6 +74,28 @@ const main = async () => {
|
|
|
73
74
|
main();
|
|
74
75
|
```
|
|
75
76
|
|
|
77
|
+
## ProofLoop: search → decision → outcome → proof
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
const search = await client.searchWithProof({
|
|
81
|
+
query: 'What should the agent do next?',
|
|
82
|
+
collection_id: 'collection-42',
|
|
83
|
+
user_id: 'customer-7',
|
|
84
|
+
});
|
|
85
|
+
const decision = await client.proofloop.decide({
|
|
86
|
+
policy_key: 'agent.next_action',
|
|
87
|
+
candidates: [{ action_key: 'act' }, { action_key: 'ask' }],
|
|
88
|
+
collection_id: 'collection-42',
|
|
89
|
+
user_id: 'customer-7',
|
|
90
|
+
proof_context: search.proof_context,
|
|
91
|
+
});
|
|
92
|
+
await client.proofloop.recordOutcome(decision.decision_id, {
|
|
93
|
+
success: true,
|
|
94
|
+
idempotency_key: 'run-123-result',
|
|
95
|
+
});
|
|
96
|
+
const proof = await client.proofloop.proof(decision.decision_id);
|
|
97
|
+
```
|
|
98
|
+
|
|
76
99
|
## 📚 Complete API Guide
|
|
77
100
|
|
|
78
101
|
### 1. Authentication
|
package/dist/index.d.mts
CHANGED
|
@@ -17,7 +17,7 @@ interface User {
|
|
|
17
17
|
full_name: string;
|
|
18
18
|
is_active: boolean;
|
|
19
19
|
is_verified: boolean;
|
|
20
|
-
tier:
|
|
20
|
+
tier: "free" | "starter" | "pro" | "enterprise";
|
|
21
21
|
}
|
|
22
22
|
interface Collection {
|
|
23
23
|
id: string;
|
|
@@ -57,6 +57,49 @@ 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;
|
|
69
|
+
proof_context?: ProofContext;
|
|
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
|
+
}
|
|
81
|
+
interface ProofContext {
|
|
82
|
+
schema_version: "proofloop-context-v1";
|
|
83
|
+
context_id: string;
|
|
84
|
+
token: string;
|
|
85
|
+
manifest_digest: string;
|
|
86
|
+
evidence_manifest: Record<string, any>;
|
|
87
|
+
trace_id?: string;
|
|
88
|
+
issued_at: string;
|
|
89
|
+
expires_at: string;
|
|
90
|
+
}
|
|
91
|
+
interface ProofLoopCandidate {
|
|
92
|
+
action_key: string;
|
|
93
|
+
description?: string;
|
|
94
|
+
features?: Record<string, any>;
|
|
95
|
+
}
|
|
96
|
+
interface ProofLoopDecisionParams {
|
|
97
|
+
policy_key: string;
|
|
98
|
+
candidates: ProofLoopCandidate[];
|
|
99
|
+
proof_context?: ProofContext | string;
|
|
100
|
+
collection_id?: string;
|
|
101
|
+
user_id?: string;
|
|
102
|
+
[key: string]: any;
|
|
60
103
|
}
|
|
61
104
|
interface ReasoningSource {
|
|
62
105
|
memory_id: string;
|
|
@@ -64,9 +107,18 @@ interface ReasoningSource {
|
|
|
64
107
|
score: number;
|
|
65
108
|
}
|
|
66
109
|
interface ReasoningResponse {
|
|
67
|
-
answer: string;
|
|
110
|
+
answer: string | null;
|
|
68
111
|
sources: ReasoningSource[];
|
|
69
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;
|
|
70
122
|
reasoning_context?: Record<string, any>;
|
|
71
123
|
}
|
|
72
124
|
interface CreateCollectionParams {
|
|
@@ -80,35 +132,137 @@ interface UpdateCollectionParams {
|
|
|
80
132
|
metadata?: Record<string, any>;
|
|
81
133
|
}
|
|
82
134
|
interface CreateMemoryParams {
|
|
83
|
-
collection_id
|
|
84
|
-
content
|
|
135
|
+
collection_id?: string;
|
|
136
|
+
content?: string;
|
|
137
|
+
messages?: Array<{
|
|
138
|
+
role: string;
|
|
139
|
+
content: string;
|
|
140
|
+
}>;
|
|
85
141
|
importance?: number;
|
|
86
142
|
source_type?: string;
|
|
87
143
|
source_reference?: string;
|
|
88
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;
|
|
89
177
|
}
|
|
90
178
|
interface UpdateMemoryParams {
|
|
91
179
|
content?: string;
|
|
92
180
|
importance?: number;
|
|
93
181
|
metadata?: Record<string, any>;
|
|
182
|
+
wait_for_index?: boolean;
|
|
94
183
|
}
|
|
95
184
|
interface SearchParams {
|
|
96
185
|
query: string;
|
|
97
186
|
collection_id?: string;
|
|
98
187
|
limit?: number;
|
|
99
|
-
search_type?:
|
|
188
|
+
search_type?: "hybrid" | "vector" | "bm25" | "graph";
|
|
100
189
|
filters?: Record<string, any>;
|
|
190
|
+
user_id?: string;
|
|
191
|
+
agent_id?: string;
|
|
192
|
+
run_id?: string;
|
|
193
|
+
fast?: boolean;
|
|
194
|
+
threshold?: number;
|
|
195
|
+
include_low_confidence?: boolean;
|
|
196
|
+
group_by_source?: boolean;
|
|
197
|
+
debug?: boolean;
|
|
101
198
|
}
|
|
102
199
|
interface ReasonParams {
|
|
103
200
|
query: string;
|
|
104
201
|
collection_id?: string;
|
|
105
|
-
provider?:
|
|
202
|
+
provider?: "gemini" | "openai" | "anthropic";
|
|
106
203
|
include_steps?: boolean;
|
|
204
|
+
user_id?: string;
|
|
205
|
+
agent_id?: string;
|
|
206
|
+
run_id?: string;
|
|
207
|
+
facets?: string[];
|
|
107
208
|
}
|
|
108
209
|
interface ListParams {
|
|
109
210
|
skip?: number;
|
|
110
211
|
limit?: number;
|
|
111
212
|
}
|
|
213
|
+
interface MemoryListParams {
|
|
214
|
+
collection_id?: string;
|
|
215
|
+
user_id?: string;
|
|
216
|
+
agent_id?: string;
|
|
217
|
+
run_id?: string;
|
|
218
|
+
scope?: "all";
|
|
219
|
+
cursor?: string;
|
|
220
|
+
limit?: number;
|
|
221
|
+
include_superseded?: boolean;
|
|
222
|
+
}
|
|
223
|
+
interface CursorPage<T> {
|
|
224
|
+
items: T[];
|
|
225
|
+
next_cursor?: string | null;
|
|
226
|
+
has_more: boolean;
|
|
227
|
+
total_count: number;
|
|
228
|
+
}
|
|
229
|
+
interface MemoryJobReceipt {
|
|
230
|
+
job_id?: string;
|
|
231
|
+
status: string;
|
|
232
|
+
[key: string]: any;
|
|
233
|
+
}
|
|
234
|
+
interface CorrectionCreateParams {
|
|
235
|
+
corrected_content: string;
|
|
236
|
+
correction_type?: "preference" | "factual" | "procedural" | string;
|
|
237
|
+
original_content?: string;
|
|
238
|
+
context?: string;
|
|
239
|
+
memory_id?: string;
|
|
240
|
+
collection_id?: string;
|
|
241
|
+
user_id?: string;
|
|
242
|
+
agent_id?: string;
|
|
243
|
+
confidence?: number;
|
|
244
|
+
metadata?: Record<string, any>;
|
|
245
|
+
idempotency_key?: string;
|
|
246
|
+
}
|
|
247
|
+
interface CorrectionSearchParams {
|
|
248
|
+
query: string;
|
|
249
|
+
correction_type?: string;
|
|
250
|
+
collection_id?: string;
|
|
251
|
+
user_id?: string;
|
|
252
|
+
agent_id?: string;
|
|
253
|
+
include_global?: boolean;
|
|
254
|
+
limit?: number;
|
|
255
|
+
}
|
|
256
|
+
interface ProofLoopMetricParams {
|
|
257
|
+
policy_key: string;
|
|
258
|
+
metric_key: string;
|
|
259
|
+
name: string;
|
|
260
|
+
min_value: number;
|
|
261
|
+
max_value: number;
|
|
262
|
+
collection_id?: string;
|
|
263
|
+
user_id?: string;
|
|
264
|
+
[key: string]: any;
|
|
265
|
+
}
|
|
112
266
|
interface APIKeyResponse {
|
|
113
267
|
id: string;
|
|
114
268
|
name: string;
|
|
@@ -169,13 +323,13 @@ declare class MemoriesResource extends BaseResource {
|
|
|
169
323
|
/**
|
|
170
324
|
* Create a new memory
|
|
171
325
|
*/
|
|
172
|
-
create(params: CreateMemoryParams): Promise<
|
|
326
|
+
create(params: CreateMemoryParams): Promise<MemoryAddResponse>;
|
|
173
327
|
/**
|
|
174
328
|
* List memories
|
|
175
329
|
*/
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
330
|
+
listPage(params?: MemoryListParams): Promise<CursorPage<Memory>>;
|
|
331
|
+
/** Back-compatible one-page convenience; use listPage for cursor metadata. */
|
|
332
|
+
list(params?: MemoryListParams): Promise<Memory[]>;
|
|
179
333
|
/**
|
|
180
334
|
* Get a specific memory
|
|
181
335
|
*/
|
|
@@ -189,11 +343,26 @@ declare class MemoriesResource extends BaseResource {
|
|
|
189
343
|
*/
|
|
190
344
|
delete(memoryId: string): Promise<void>;
|
|
191
345
|
}
|
|
346
|
+
declare class MemoryJobsResource extends BaseResource {
|
|
347
|
+
get(jobId: string): Promise<MemoryJobReceipt>;
|
|
348
|
+
wait(jobId: string, options?: {
|
|
349
|
+
timeoutMs?: number;
|
|
350
|
+
pollIntervalMs?: number;
|
|
351
|
+
}): Promise<MemoryJobReceipt>;
|
|
352
|
+
}
|
|
353
|
+
declare class CorrectionsResource extends BaseResource {
|
|
354
|
+
create(params: CorrectionCreateParams): Promise<Record<string, any>>;
|
|
355
|
+
relevant(params: CorrectionSearchParams): Promise<Array<Record<string, any>>>;
|
|
356
|
+
get(correctionId: string): Promise<Record<string, any>>;
|
|
357
|
+
delete(correctionId: string): Promise<Record<string, any>>;
|
|
358
|
+
}
|
|
192
359
|
declare class SearchResource extends BaseResource {
|
|
193
360
|
/**
|
|
194
361
|
* Search memories
|
|
195
362
|
*/
|
|
196
363
|
search(params: SearchParams): Promise<SearchResult[]>;
|
|
364
|
+
/** Search while preserving the automatic ProofLoop evidence context. */
|
|
365
|
+
searchWithProof(params: SearchParams): Promise<SearchResponse>;
|
|
197
366
|
/**
|
|
198
367
|
* Find similar memories
|
|
199
368
|
*/
|
|
@@ -203,6 +372,36 @@ declare class SearchResource extends BaseResource {
|
|
|
203
372
|
*/
|
|
204
373
|
reason(params: ReasonParams): Promise<ReasoningResponse>;
|
|
205
374
|
}
|
|
375
|
+
declare class ProofLoopResource extends BaseResource {
|
|
376
|
+
/** Create a causal decision bound to search/chat evidence automatically. */
|
|
377
|
+
decide(params: ProofLoopDecisionParams): Promise<Record<string, any>>;
|
|
378
|
+
recordOutcome(decisionId: string, body: {
|
|
379
|
+
observations?: Record<string, any>[];
|
|
380
|
+
reward?: number;
|
|
381
|
+
success?: boolean;
|
|
382
|
+
idempotency_key?: string;
|
|
383
|
+
}): Promise<Record<string, any>>;
|
|
384
|
+
getDecision(decisionId: string): Promise<Record<string, any>>;
|
|
385
|
+
defineMetric(params: ProofLoopMetricParams): Promise<Record<string, any>>;
|
|
386
|
+
listMetrics(params?: {
|
|
387
|
+
policy_key?: string;
|
|
388
|
+
collection_id?: string;
|
|
389
|
+
user_id?: string;
|
|
390
|
+
}): Promise<Record<string, any>>;
|
|
391
|
+
policyInsights(policyKey: string, params?: {
|
|
392
|
+
collection_id?: string;
|
|
393
|
+
user_id?: string;
|
|
394
|
+
action_keys?: string[];
|
|
395
|
+
context?: Record<string, any>;
|
|
396
|
+
}): Promise<Record<string, any>>;
|
|
397
|
+
evaluatePolicy(policyKey: string, params?: {
|
|
398
|
+
collection_id?: string;
|
|
399
|
+
user_id?: string;
|
|
400
|
+
limit?: number;
|
|
401
|
+
}): Promise<Record<string, any>>;
|
|
402
|
+
proof(decisionId: string): Promise<Record<string, any>>;
|
|
403
|
+
publicKey(keyId?: string): Promise<Record<string, any>>;
|
|
404
|
+
}
|
|
206
405
|
declare class RLResource extends BaseResource {
|
|
207
406
|
/**
|
|
208
407
|
* Train the Memory Manager agent using RL
|
|
@@ -372,10 +571,6 @@ declare class WorldModelResource extends BaseResource {
|
|
|
372
571
|
plan(goal: string, collectionId?: string): Promise<any>;
|
|
373
572
|
}
|
|
374
573
|
|
|
375
|
-
/**
|
|
376
|
-
* Main Hebbrix client
|
|
377
|
-
*/
|
|
378
|
-
|
|
379
574
|
declare class MemoryClient {
|
|
380
575
|
private apiKey?;
|
|
381
576
|
private baseUrl;
|
|
@@ -383,6 +578,8 @@ declare class MemoryClient {
|
|
|
383
578
|
auth: AuthResource;
|
|
384
579
|
collections: CollectionsResource;
|
|
385
580
|
memories: MemoriesResource;
|
|
581
|
+
memoryJobs: MemoryJobsResource;
|
|
582
|
+
corrections: CorrectionsResource;
|
|
386
583
|
private searchResource;
|
|
387
584
|
rl: RLResource;
|
|
388
585
|
procedural: ProceduralResource;
|
|
@@ -391,6 +588,7 @@ declare class MemoryClient {
|
|
|
391
588
|
consolidation: ConsolidationResource;
|
|
392
589
|
memoryTools: MemoryToolsResource;
|
|
393
590
|
worldModel: WorldModelResource;
|
|
591
|
+
proofloop: ProofLoopResource;
|
|
394
592
|
constructor(config?: ClientConfig);
|
|
395
593
|
private getHeaders;
|
|
396
594
|
private handleError;
|
|
@@ -400,6 +598,7 @@ declare class MemoryClient {
|
|
|
400
598
|
patch<T = any>(path: string, body?: any): Promise<T>;
|
|
401
599
|
delete<T = any>(path: string): Promise<T>;
|
|
402
600
|
search(params: SearchParams): Promise<SearchResult[]>;
|
|
601
|
+
searchWithProof(params: SearchParams): Promise<SearchResponse>;
|
|
403
602
|
reason(params: ReasonParams): Promise<ReasoningResponse>;
|
|
404
603
|
}
|
|
405
604
|
|
|
@@ -427,4 +626,24 @@ declare class ServerError extends HebbrixError {
|
|
|
427
626
|
constructor(message?: string);
|
|
428
627
|
}
|
|
429
628
|
|
|
430
|
-
|
|
629
|
+
interface SafetyEnvelope {
|
|
630
|
+
no_match: boolean;
|
|
631
|
+
abstain_recommended: boolean;
|
|
632
|
+
query_confidence: number;
|
|
633
|
+
grounding: GroundingReceipt;
|
|
634
|
+
evidence_ids: string[];
|
|
635
|
+
evidence_claims?: unknown[];
|
|
636
|
+
safety_contract_version: string;
|
|
637
|
+
degraded?: boolean;
|
|
638
|
+
sdk_safety_reason?: string;
|
|
639
|
+
[key: string]: unknown;
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Validate the API-owned grounding receipt before exposing evidence to an agent.
|
|
643
|
+
* A malformed, degraded, abstaining, or ungrounded response is converted into
|
|
644
|
+
* one deterministic no-match envelope. This prevents SDK/API contract drift
|
|
645
|
+
* from turning a nearest neighbour into verified evidence.
|
|
646
|
+
*/
|
|
647
|
+
declare function enforceSearchSafety<T extends object>(response: T, rowsKey?: "results" | "sources"): T & SafetyEnvelope;
|
|
648
|
+
|
|
649
|
+
export { type APIKeyResponse, AuthResource, type AuthResponse, AuthenticationError, 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 };
|