hebbrix 2.2.1 → 2.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.
- package/CHANGELOG.md +15 -0
- package/README.md +61 -748
- package/dist/index.d.mts +88 -37
- package/dist/index.d.ts +88 -37
- package/dist/index.js +196 -131
- package/dist/index.mjs +194 -130
- package/package.json +3 -7
package/dist/index.mjs
CHANGED
|
@@ -52,6 +52,72 @@ function enforceSearchSafety(response, rowsKey = "results") {
|
|
|
52
52
|
return data;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
// src/errors.ts
|
|
56
|
+
var HebbrixError = class _HebbrixError extends Error {
|
|
57
|
+
constructor(message, statusCode, options = {}) {
|
|
58
|
+
super(message);
|
|
59
|
+
this.name = "HebbrixError";
|
|
60
|
+
this.statusCode = statusCode;
|
|
61
|
+
this.code = options.code;
|
|
62
|
+
this.requestId = options.requestId;
|
|
63
|
+
this.details = options.details;
|
|
64
|
+
Object.setPrototypeOf(this, _HebbrixError.prototype);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var EntitlementError = class _EntitlementError extends HebbrixError {
|
|
68
|
+
constructor(message, statusCode, options = {}) {
|
|
69
|
+
super(message, statusCode, options);
|
|
70
|
+
this.name = "EntitlementError";
|
|
71
|
+
Object.setPrototypeOf(this, _EntitlementError.prototype);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var IndexingTimeoutError = class _IndexingTimeoutError extends Error {
|
|
75
|
+
constructor(message, receipt) {
|
|
76
|
+
super(message);
|
|
77
|
+
this.name = "IndexingTimeoutError";
|
|
78
|
+
this.receipt = { ...receipt };
|
|
79
|
+
this.memoryIds = [...receipt.memory_ids || []];
|
|
80
|
+
this.statusUrl = receipt.status_url;
|
|
81
|
+
Object.setPrototypeOf(this, _IndexingTimeoutError.prototype);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var AuthenticationError = class _AuthenticationError extends HebbrixError {
|
|
85
|
+
constructor(message = "Authentication failed", options = {}) {
|
|
86
|
+
super(message, 401, options);
|
|
87
|
+
this.name = "AuthenticationError";
|
|
88
|
+
Object.setPrototypeOf(this, _AuthenticationError.prototype);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
var ValidationError = class _ValidationError extends HebbrixError {
|
|
92
|
+
constructor(message, errors, options = {}) {
|
|
93
|
+
super(message, 422, options);
|
|
94
|
+
this.name = "ValidationError";
|
|
95
|
+
this.errors = errors;
|
|
96
|
+
Object.setPrototypeOf(this, _ValidationError.prototype);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
var NotFoundError = class _NotFoundError extends HebbrixError {
|
|
100
|
+
constructor(message = "Resource not found", options = {}) {
|
|
101
|
+
super(message, 404, options);
|
|
102
|
+
this.name = "NotFoundError";
|
|
103
|
+
Object.setPrototypeOf(this, _NotFoundError.prototype);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
var RateLimitError = class _RateLimitError extends HebbrixError {
|
|
107
|
+
constructor(message = "Rate limit exceeded", options = {}) {
|
|
108
|
+
super(message, 429, options);
|
|
109
|
+
this.name = "RateLimitError";
|
|
110
|
+
Object.setPrototypeOf(this, _RateLimitError.prototype);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
var ServerError = class _ServerError extends HebbrixError {
|
|
114
|
+
constructor(message = "Internal server error", options = {}) {
|
|
115
|
+
super(message, 500, options);
|
|
116
|
+
this.name = "ServerError";
|
|
117
|
+
Object.setPrototypeOf(this, _ServerError.prototype);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
55
121
|
// src/resources.ts
|
|
56
122
|
var BaseResource = class {
|
|
57
123
|
constructor(client) {
|
|
@@ -148,9 +214,9 @@ var MemoriesResource = class extends BaseResource {
|
|
|
148
214
|
}
|
|
149
215
|
/**
|
|
150
216
|
* Create up to 100 memories with one unambiguous readiness contract.
|
|
151
|
-
* `wait_for_index=true` resolves only for a fully searchable batch
|
|
152
|
-
*
|
|
153
|
-
*
|
|
217
|
+
* `wait_for_index=true` resolves only for a fully searchable batch. A durable
|
|
218
|
+
* server-side 202 is polled to the caller's deadline; expiry raises a typed
|
|
219
|
+
* `IndexingTimeoutError` carrying the original durable receipt.
|
|
154
220
|
*/
|
|
155
221
|
async createBatch(params) {
|
|
156
222
|
if (!params.memories?.length || params.memories.length > 100) {
|
|
@@ -159,7 +225,13 @@ var MemoriesResource = class extends BaseResource {
|
|
|
159
225
|
if (params.memories.some((item) => !item.content?.trim())) {
|
|
160
226
|
throw new TypeError("every batch memory must contain non-empty content");
|
|
161
227
|
}
|
|
162
|
-
const {
|
|
228
|
+
const {
|
|
229
|
+
idempotency_key,
|
|
230
|
+
signal,
|
|
231
|
+
index_timeout_ms,
|
|
232
|
+
index_poll_interval_ms,
|
|
233
|
+
...body
|
|
234
|
+
} = params;
|
|
163
235
|
const receipt = await this.client.request(
|
|
164
236
|
"POST",
|
|
165
237
|
"/v1/memories/batch",
|
|
@@ -169,10 +241,12 @@ var MemoriesResource = class extends BaseResource {
|
|
|
169
241
|
signal
|
|
170
242
|
}
|
|
171
243
|
);
|
|
172
|
-
if (params.wait_for_index && !
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
244
|
+
if (params.wait_for_index && !receipt.searchable) {
|
|
245
|
+
return this.waitForBatchSearchable(receipt, {
|
|
246
|
+
timeoutMs: index_timeout_ms,
|
|
247
|
+
pollIntervalMs: index_poll_interval_ms,
|
|
248
|
+
signal
|
|
249
|
+
});
|
|
176
250
|
}
|
|
177
251
|
return receipt;
|
|
178
252
|
}
|
|
@@ -213,7 +287,10 @@ var MemoriesResource = class extends BaseResource {
|
|
|
213
287
|
};
|
|
214
288
|
}
|
|
215
289
|
if (Date.now() >= deadline) {
|
|
216
|
-
throw new
|
|
290
|
+
throw new IndexingTimeoutError(
|
|
291
|
+
`batch was not searchable within ${timeoutMs}ms; the write is durable`,
|
|
292
|
+
receipt
|
|
293
|
+
);
|
|
217
294
|
}
|
|
218
295
|
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
219
296
|
}
|
|
@@ -407,8 +484,7 @@ var RLResource = class extends BaseResource {
|
|
|
407
484
|
* Train the Memory Manager agent using RL
|
|
408
485
|
*/
|
|
409
486
|
async trainMemoryManager(params) {
|
|
410
|
-
return this.client.post("/rl/train/memory-manager", {
|
|
411
|
-
collection_id: params.collection_id,
|
|
487
|
+
return this.client.post("/v1/rl/train/memory-manager", {
|
|
412
488
|
num_episodes: params.num_episodes || 100,
|
|
413
489
|
...params
|
|
414
490
|
});
|
|
@@ -417,8 +493,7 @@ var RLResource = class extends BaseResource {
|
|
|
417
493
|
* Train the Answer Agent using RL
|
|
418
494
|
*/
|
|
419
495
|
async trainAnswerAgent(params) {
|
|
420
|
-
return this.client.post("/rl/train/answer-agent", {
|
|
421
|
-
collection_id: params.collection_id,
|
|
496
|
+
return this.client.post("/v1/rl/train/answer-agent", {
|
|
422
497
|
num_episodes: params.num_episodes || 100,
|
|
423
498
|
...params
|
|
424
499
|
});
|
|
@@ -427,13 +502,13 @@ var RLResource = class extends BaseResource {
|
|
|
427
502
|
* Get RL training metrics
|
|
428
503
|
*/
|
|
429
504
|
async getMetrics() {
|
|
430
|
-
return this.client.get("/rl/metrics");
|
|
505
|
+
return this.client.get("/v1/rl/metrics");
|
|
431
506
|
}
|
|
432
507
|
/**
|
|
433
508
|
* Evaluate a trained RL agent
|
|
434
509
|
*/
|
|
435
510
|
async evaluate(agentType, collectionId) {
|
|
436
|
-
return this.client.post("/rl/evaluate", {
|
|
511
|
+
return this.client.post("/v1/rl/evaluate", {
|
|
437
512
|
agent_type: agentType,
|
|
438
513
|
collection_id: collectionId
|
|
439
514
|
});
|
|
@@ -519,12 +594,15 @@ var TemporalResource = class extends BaseResource {
|
|
|
519
594
|
* Add a temporal fact to the knowledge graph
|
|
520
595
|
*/
|
|
521
596
|
async addFact(params) {
|
|
522
|
-
return this.client.post("/temporal/facts", {
|
|
597
|
+
return this.client.post("/v1/temporal/facts", {
|
|
523
598
|
subject: params.subject,
|
|
599
|
+
subject_type: params.subject_type || "ENTITY",
|
|
524
600
|
predicate: params.predicate,
|
|
525
601
|
object: params.object,
|
|
602
|
+
object_type: params.object_type || "ENTITY",
|
|
526
603
|
valid_from: params.valid_from,
|
|
527
604
|
valid_until: params.valid_until,
|
|
605
|
+
observed_at: params.observed_at,
|
|
528
606
|
confidence: params.confidence || 1,
|
|
529
607
|
source_memory_id: params.source_memory_id,
|
|
530
608
|
metadata: params.metadata || {}
|
|
@@ -534,33 +612,79 @@ var TemporalResource = class extends BaseResource {
|
|
|
534
612
|
* Query temporal facts
|
|
535
613
|
*/
|
|
536
614
|
async queryFacts(params) {
|
|
537
|
-
|
|
538
|
-
subject
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
615
|
+
if (!params.subject) {
|
|
616
|
+
throw new TypeError("subject is required by the temporal query contract");
|
|
617
|
+
}
|
|
618
|
+
let rows;
|
|
619
|
+
if (params.at_time) {
|
|
620
|
+
const response = await this.queryAtTime({
|
|
621
|
+
subject: params.subject,
|
|
622
|
+
predicate: params.predicate,
|
|
623
|
+
timestamp: params.at_time
|
|
624
|
+
});
|
|
625
|
+
rows = response.facts || [];
|
|
626
|
+
} else if (params.predicate) {
|
|
627
|
+
const response = await this.history(
|
|
628
|
+
params.subject,
|
|
629
|
+
params.predicate
|
|
630
|
+
);
|
|
631
|
+
rows = response.history || [];
|
|
632
|
+
} else {
|
|
633
|
+
throw new TypeError("predicate or at_time is required");
|
|
634
|
+
}
|
|
635
|
+
return params.object === void 0 ? rows : rows.filter((row) => row.object === params.object);
|
|
636
|
+
}
|
|
637
|
+
async queryAtTime(params) {
|
|
638
|
+
return this.client.post("/v1/temporal/facts/query-at-time", params);
|
|
639
|
+
}
|
|
640
|
+
async history(subject, predicate, limit = 50) {
|
|
641
|
+
return this.client.get("/v1/temporal/facts/history", {
|
|
642
|
+
subject,
|
|
643
|
+
predicate,
|
|
644
|
+
limit
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
async conflicts(subject, predicate) {
|
|
648
|
+
return this.client.get("/v1/temporal/facts/conflicts", {
|
|
649
|
+
subject,
|
|
650
|
+
predicate
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
async invalidate(subject, predicate, object) {
|
|
654
|
+
return this.client.post("/v1/temporal/facts/invalidate", {
|
|
655
|
+
subject,
|
|
656
|
+
predicate,
|
|
657
|
+
object
|
|
542
658
|
});
|
|
543
659
|
}
|
|
544
660
|
/**
|
|
545
661
|
* Query knowledge state at a specific point in time
|
|
546
662
|
*/
|
|
547
663
|
async pointInTime(timestamp, entity) {
|
|
548
|
-
|
|
664
|
+
if (!entity) {
|
|
665
|
+
throw new TypeError("entity is required and maps to the canonical subject");
|
|
666
|
+
}
|
|
667
|
+
return this.queryAtTime({
|
|
549
668
|
timestamp,
|
|
550
|
-
entity
|
|
669
|
+
subject: entity
|
|
551
670
|
});
|
|
552
671
|
}
|
|
553
672
|
/** Permanently delete a tenant-scoped temporal fact by stable ID. */
|
|
554
673
|
async deleteFact(factId) {
|
|
555
|
-
return this.client.delete(`/temporal/facts/${factId}`);
|
|
674
|
+
return this.client.delete(`/v1/temporal/facts/${factId}`);
|
|
556
675
|
}
|
|
557
676
|
};
|
|
558
677
|
var WorkingMemoryResource = class extends BaseResource {
|
|
678
|
+
constructor(client) {
|
|
679
|
+
super(client);
|
|
680
|
+
this.sessionId = `sdk-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
681
|
+
}
|
|
559
682
|
/**
|
|
560
683
|
* Add item to working memory buffer
|
|
561
684
|
*/
|
|
562
685
|
async add(params) {
|
|
563
|
-
return this.client.post("/working-memory", {
|
|
686
|
+
return this.client.post("/v1/working-memory/add", {
|
|
687
|
+
session_id: params.session_id || this.sessionId,
|
|
564
688
|
role: params.role,
|
|
565
689
|
content: params.content,
|
|
566
690
|
metadata: params.metadata || {}
|
|
@@ -569,48 +693,40 @@ var WorkingMemoryResource = class extends BaseResource {
|
|
|
569
693
|
/**
|
|
570
694
|
* Get current working memory context
|
|
571
695
|
*/
|
|
572
|
-
async getContext() {
|
|
573
|
-
return this.client.get(
|
|
696
|
+
async getContext(sessionId = this.sessionId, includeCompressed = false) {
|
|
697
|
+
return this.client.get(`/v1/working-memory/context/${sessionId}`, {
|
|
698
|
+
include_compressed: includeCompressed
|
|
699
|
+
});
|
|
574
700
|
}
|
|
575
701
|
/**
|
|
576
702
|
* Compress working memory buffer
|
|
577
703
|
*/
|
|
578
|
-
async compress() {
|
|
579
|
-
return this.client.post(
|
|
704
|
+
async compress(sessionId = this.sessionId) {
|
|
705
|
+
return this.client.post(`/v1/working-memory/compress/${sessionId}`);
|
|
580
706
|
}
|
|
581
707
|
/**
|
|
582
708
|
* Clear working memory buffer
|
|
583
709
|
*/
|
|
584
|
-
async clear() {
|
|
585
|
-
return this.client.delete(
|
|
710
|
+
async clear(sessionId = this.sessionId) {
|
|
711
|
+
return this.client.delete(`/v1/working-memory/clear/${sessionId}`);
|
|
586
712
|
}
|
|
587
713
|
};
|
|
588
714
|
var ConsolidationResource = class extends BaseResource {
|
|
589
715
|
/**
|
|
590
716
|
* Trigger memory consolidation
|
|
591
717
|
*/
|
|
592
|
-
async consolidate(collectionId,
|
|
593
|
-
return this.client.post("/consolidation/consolidate", {
|
|
718
|
+
async consolidate(collectionId, lookbackDays = 7, utilityThreshold = 0.3) {
|
|
719
|
+
return this.client.post("/v1/consolidation/consolidate", {
|
|
594
720
|
collection_id: collectionId,
|
|
595
|
-
|
|
721
|
+
lookback_days: lookbackDays,
|
|
722
|
+
utility_threshold: utilityThreshold
|
|
596
723
|
});
|
|
597
724
|
}
|
|
598
725
|
/**
|
|
599
726
|
* Get consolidation statistics
|
|
600
727
|
*/
|
|
601
728
|
async getStats(collectionId) {
|
|
602
|
-
return this.client.get(
|
|
603
|
-
collection_id: collectionId
|
|
604
|
-
});
|
|
605
|
-
}
|
|
606
|
-
/**
|
|
607
|
-
* Archive old memories
|
|
608
|
-
*/
|
|
609
|
-
async archive(collectionId, beforeDate) {
|
|
610
|
-
return this.client.post("/consolidation/archive", {
|
|
611
|
-
collection_id: collectionId,
|
|
612
|
-
before_date: beforeDate
|
|
613
|
-
});
|
|
729
|
+
return this.client.get(`/v1/consolidation/stats/${collectionId}`);
|
|
614
730
|
}
|
|
615
731
|
};
|
|
616
732
|
var MemoryToolsResource = class extends BaseResource {
|
|
@@ -618,100 +734,38 @@ var MemoryToolsResource = class extends BaseResource {
|
|
|
618
734
|
* Replace memory content
|
|
619
735
|
*/
|
|
620
736
|
async replace(params) {
|
|
621
|
-
return this.client.post("/memory-tools/replace", {
|
|
737
|
+
return this.client.post("/v1/memory-tools/replace", {
|
|
622
738
|
memory_id: params.memory_id,
|
|
739
|
+
old_content: params.old_content,
|
|
623
740
|
new_content: params.new_content,
|
|
624
|
-
|
|
741
|
+
collection_id: params.collection_id
|
|
625
742
|
});
|
|
626
743
|
}
|
|
627
744
|
/**
|
|
628
745
|
* Insert new memory at position
|
|
629
746
|
*/
|
|
630
747
|
async insert(params) {
|
|
631
|
-
|
|
748
|
+
const metadata = { ...params.metadata || {} };
|
|
749
|
+
if (params.position !== void 0) metadata.requested_position = params.position;
|
|
750
|
+
if (params.reason !== void 0) metadata.reason = params.reason;
|
|
751
|
+
return this.client.post("/v1/memory-tools/insert", {
|
|
632
752
|
collection_id: params.collection_id,
|
|
633
753
|
content: params.content,
|
|
634
|
-
|
|
635
|
-
|
|
754
|
+
importance: params.importance ?? 0.5,
|
|
755
|
+
metadata
|
|
636
756
|
});
|
|
637
757
|
}
|
|
638
758
|
/**
|
|
639
759
|
* Re-evaluate memory in light of new information
|
|
640
760
|
*/
|
|
641
|
-
async rethink(memoryId,
|
|
642
|
-
return this.client.post("/memory-tools/rethink", {
|
|
761
|
+
async rethink(memoryId, collectionId) {
|
|
762
|
+
return this.client.post("/v1/memory-tools/rethink", {
|
|
643
763
|
memory_id: memoryId,
|
|
644
|
-
query
|
|
645
|
-
});
|
|
646
|
-
}
|
|
647
|
-
};
|
|
648
|
-
var WorldModelResource = class extends BaseResource {
|
|
649
|
-
/**
|
|
650
|
-
* Simulate retrieval without actually retrieving
|
|
651
|
-
*/
|
|
652
|
-
async imagineRetrieval(query, collectionId) {
|
|
653
|
-
return this.client.post("/world-model/imagine-retrieval", {
|
|
654
|
-
query,
|
|
655
|
-
collection_id: collectionId
|
|
656
|
-
});
|
|
657
|
-
}
|
|
658
|
-
/**
|
|
659
|
-
* Plan memory operations to achieve goal
|
|
660
|
-
*/
|
|
661
|
-
async plan(goal, collectionId) {
|
|
662
|
-
return this.client.post("/world-model/plan", {
|
|
663
|
-
goal,
|
|
664
764
|
collection_id: collectionId
|
|
665
765
|
});
|
|
666
766
|
}
|
|
667
767
|
};
|
|
668
768
|
|
|
669
|
-
// src/errors.ts
|
|
670
|
-
var HebbrixError = class _HebbrixError extends Error {
|
|
671
|
-
constructor(message, statusCode) {
|
|
672
|
-
super(message);
|
|
673
|
-
this.name = "HebbrixError";
|
|
674
|
-
this.statusCode = statusCode;
|
|
675
|
-
Object.setPrototypeOf(this, _HebbrixError.prototype);
|
|
676
|
-
}
|
|
677
|
-
};
|
|
678
|
-
var AuthenticationError = class _AuthenticationError extends HebbrixError {
|
|
679
|
-
constructor(message = "Authentication failed") {
|
|
680
|
-
super(message, 401);
|
|
681
|
-
this.name = "AuthenticationError";
|
|
682
|
-
Object.setPrototypeOf(this, _AuthenticationError.prototype);
|
|
683
|
-
}
|
|
684
|
-
};
|
|
685
|
-
var ValidationError = class _ValidationError extends HebbrixError {
|
|
686
|
-
constructor(message, errors) {
|
|
687
|
-
super(message, 422);
|
|
688
|
-
this.name = "ValidationError";
|
|
689
|
-
this.errors = errors;
|
|
690
|
-
Object.setPrototypeOf(this, _ValidationError.prototype);
|
|
691
|
-
}
|
|
692
|
-
};
|
|
693
|
-
var NotFoundError = class _NotFoundError extends HebbrixError {
|
|
694
|
-
constructor(message = "Resource not found") {
|
|
695
|
-
super(message, 404);
|
|
696
|
-
this.name = "NotFoundError";
|
|
697
|
-
Object.setPrototypeOf(this, _NotFoundError.prototype);
|
|
698
|
-
}
|
|
699
|
-
};
|
|
700
|
-
var RateLimitError = class _RateLimitError extends HebbrixError {
|
|
701
|
-
constructor(message = "Rate limit exceeded") {
|
|
702
|
-
super(message, 429);
|
|
703
|
-
this.name = "RateLimitError";
|
|
704
|
-
Object.setPrototypeOf(this, _RateLimitError.prototype);
|
|
705
|
-
}
|
|
706
|
-
};
|
|
707
|
-
var ServerError = class _ServerError extends HebbrixError {
|
|
708
|
-
constructor(message = "Internal server error") {
|
|
709
|
-
super(message, 500);
|
|
710
|
-
this.name = "ServerError";
|
|
711
|
-
Object.setPrototypeOf(this, _ServerError.prototype);
|
|
712
|
-
}
|
|
713
|
-
};
|
|
714
|
-
|
|
715
769
|
// src/client.ts
|
|
716
770
|
var MemoryClient = class {
|
|
717
771
|
constructor(config = {}) {
|
|
@@ -731,13 +785,12 @@ var MemoryClient = class {
|
|
|
731
785
|
this.workingMemory = new WorkingMemoryResource(this);
|
|
732
786
|
this.consolidation = new ConsolidationResource(this);
|
|
733
787
|
this.memoryTools = new MemoryToolsResource(this);
|
|
734
|
-
this.worldModel = new WorldModelResource(this);
|
|
735
788
|
this.proofloop = new ProofLoopResource(this);
|
|
736
789
|
}
|
|
737
790
|
getHeaders() {
|
|
738
791
|
const headers = {
|
|
739
792
|
"Content-Type": "application/json",
|
|
740
|
-
"User-Agent": "hebbrix-typescript/2.
|
|
793
|
+
"User-Agent": "hebbrix-typescript/2.3.0"
|
|
741
794
|
};
|
|
742
795
|
if (this.apiKey) {
|
|
743
796
|
headers["Authorization"] = `Bearer ${this.apiKey}`;
|
|
@@ -746,21 +799,31 @@ var MemoryClient = class {
|
|
|
746
799
|
}
|
|
747
800
|
handleError(response, data) {
|
|
748
801
|
const statusCode = response.status;
|
|
749
|
-
const
|
|
750
|
-
const
|
|
802
|
+
const envelope = data?.error || data?.detail || {};
|
|
803
|
+
const nested = envelope?.message;
|
|
804
|
+
const details = nested && typeof nested === "object" ? nested : envelope;
|
|
805
|
+
const message = details?.message || (typeof nested === "string" ? nested : void 0) || response.statusText;
|
|
806
|
+
const code = details?.code || envelope?.code;
|
|
807
|
+
const requestId = details?.request_id || envelope?.request_id || response.headers.get("X-Request-ID") || void 0;
|
|
751
808
|
if (statusCode === 401) {
|
|
752
|
-
throw new AuthenticationError(message);
|
|
809
|
+
throw new AuthenticationError(message, { code, requestId, details });
|
|
753
810
|
} else if (statusCode === 404) {
|
|
754
|
-
throw new NotFoundError(message);
|
|
811
|
+
throw new NotFoundError(message, { code, requestId, details });
|
|
755
812
|
} else if (statusCode === 422) {
|
|
756
813
|
const errors = data?.error?.details || [];
|
|
757
|
-
throw new ValidationError(message, errors);
|
|
814
|
+
throw new ValidationError(message, errors, { code, requestId, details });
|
|
758
815
|
} else if (statusCode === 429) {
|
|
759
|
-
throw new RateLimitError(message);
|
|
816
|
+
throw new RateLimitError(message, { code, requestId, details });
|
|
760
817
|
} else if (statusCode >= 500) {
|
|
761
|
-
throw new ServerError(message);
|
|
818
|
+
throw new ServerError(message, { code, requestId, details });
|
|
819
|
+
} else if ((statusCode === 402 || statusCode === 403) && (String(code || "").includes("ENTITLEMENT") || ["feature_not_available", "tier_upgrade_required"].includes(details?.error))) {
|
|
820
|
+
throw new EntitlementError(message, statusCode, {
|
|
821
|
+
code,
|
|
822
|
+
requestId,
|
|
823
|
+
details
|
|
824
|
+
});
|
|
762
825
|
} else {
|
|
763
|
-
throw new HebbrixError(message, statusCode);
|
|
826
|
+
throw new HebbrixError(message, statusCode, { code, requestId, details });
|
|
764
827
|
}
|
|
765
828
|
}
|
|
766
829
|
async request(method, path, options = {}) {
|
|
@@ -841,7 +904,9 @@ export {
|
|
|
841
904
|
CollectionsResource,
|
|
842
905
|
ConsolidationResource,
|
|
843
906
|
CorrectionsResource,
|
|
907
|
+
EntitlementError,
|
|
844
908
|
HebbrixError,
|
|
909
|
+
IndexingTimeoutError,
|
|
845
910
|
MemoriesResource,
|
|
846
911
|
MemoryClient,
|
|
847
912
|
MemoryJobsResource,
|
|
@@ -856,6 +921,5 @@ export {
|
|
|
856
921
|
TemporalResource,
|
|
857
922
|
ValidationError,
|
|
858
923
|
WorkingMemoryResource,
|
|
859
|
-
WorldModelResource,
|
|
860
924
|
enforceSearchSafety
|
|
861
925
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hebbrix",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.3.0",
|
|
4
|
+
"description": "Typed TypeScript client for Hebbrix memory, retrieval, and outcome-learning APIs",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -46,12 +46,8 @@
|
|
|
46
46
|
],
|
|
47
47
|
"author": "Hebbrix Team <support@hebbrix.com>",
|
|
48
48
|
"license": "MIT",
|
|
49
|
-
"repository": {
|
|
50
|
-
"type": "git",
|
|
51
|
-
"url": "git+https://github.com/Hebbrix/hebbrix-typescript.git"
|
|
52
|
-
},
|
|
53
49
|
"bugs": {
|
|
54
|
-
"url": "https://
|
|
50
|
+
"url": "https://www.hebbrix.com/contact"
|
|
55
51
|
},
|
|
56
52
|
"homepage": "https://hebbrix.com",
|
|
57
53
|
"publishConfig": {
|