hebbrix 2.3.1 → 2.4.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 +7 -0
- package/README.md +1 -1
- package/dist/index.d.mts +50 -2
- package/dist/index.d.ts +50 -2
- package/dist/index.js +73 -3
- package/dist/index.mjs +73 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.4.0 — 2026-09-07
|
|
4
|
+
|
|
5
|
+
- Add typed Evidence Loop methods for owner-managed verifiers, durable episodes, actual-execution claims, protected outcome delivery and evidence assessments.
|
|
6
|
+
- Preserve incomplete outcomes, scope, replay and permission receipts. Verifier errors never fall back to caller-reported outcomes.
|
|
7
|
+
- Reject malformed, ambiguous or unknown evidence contracts before exposing unsupported synthesis; retain valid degraded evidence with its abstention signal.
|
|
8
|
+
- Protected ledger methods require the connected Evidence Loop backend, separately scoped verifier credentials and external execution/outcome checks. They do not grant permission or execute actions.
|
|
9
|
+
|
|
3
10
|
## 2.3.1 — 2026-08-27
|
|
4
11
|
|
|
5
12
|
- Make single-memory `wait_for_index` a client-enforced readiness contract:
|
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -101,12 +101,48 @@ interface ProofLoopCandidate {
|
|
|
101
101
|
}
|
|
102
102
|
interface ProofLoopDecisionParams {
|
|
103
103
|
policy_key: string;
|
|
104
|
+
episode_id?: string;
|
|
104
105
|
candidates: ProofLoopCandidate[];
|
|
105
106
|
proof_context?: ProofContext | string;
|
|
106
107
|
collection_id?: string;
|
|
107
108
|
user_id?: string;
|
|
108
109
|
[key: string]: any;
|
|
109
110
|
}
|
|
111
|
+
interface EvidenceScope {
|
|
112
|
+
policy_key: string;
|
|
113
|
+
collection_id?: string;
|
|
114
|
+
user_id?: string;
|
|
115
|
+
}
|
|
116
|
+
interface VerifierRegistration extends EvidenceScope {
|
|
117
|
+
api_key_id: string;
|
|
118
|
+
source_system: string;
|
|
119
|
+
metric_keys: string[];
|
|
120
|
+
}
|
|
121
|
+
interface EpisodeCreateParams extends EvidenceScope {
|
|
122
|
+
verifier_id: string;
|
|
123
|
+
idempotency_key: string;
|
|
124
|
+
}
|
|
125
|
+
interface ExecutionClaim {
|
|
126
|
+
attempt_id: string;
|
|
127
|
+
status: "started" | "completed" | "failed" | "interrupted" | "blocked";
|
|
128
|
+
actual_action_key: string;
|
|
129
|
+
arguments_digest: string;
|
|
130
|
+
evidence_digest?: string;
|
|
131
|
+
occurred_at?: string;
|
|
132
|
+
}
|
|
133
|
+
interface VerifiedOutcomeDelivery {
|
|
134
|
+
decision_id: string;
|
|
135
|
+
source_event_id: string;
|
|
136
|
+
evidence_digest: string;
|
|
137
|
+
execution_digest: string;
|
|
138
|
+
observations: Array<{
|
|
139
|
+
metric_key: string;
|
|
140
|
+
value: number;
|
|
141
|
+
confidence?: number;
|
|
142
|
+
is_final?: boolean;
|
|
143
|
+
observed_at: string;
|
|
144
|
+
}>;
|
|
145
|
+
}
|
|
110
146
|
interface ReasoningSource {
|
|
111
147
|
memory_id: string;
|
|
112
148
|
content: string;
|
|
@@ -465,7 +501,7 @@ declare class SearchResource extends BaseResource {
|
|
|
465
501
|
reason(params: ReasonParams): Promise<ReasoningResponse>;
|
|
466
502
|
}
|
|
467
503
|
declare class ProofLoopResource extends BaseResource {
|
|
468
|
-
/**
|
|
504
|
+
/** Record a recommendation; this never authorizes execution or proves causality. */
|
|
469
505
|
decide(params: ProofLoopDecisionParams): Promise<Record<string, any>>;
|
|
470
506
|
recordOutcome(decisionId: string, body: {
|
|
471
507
|
observations?: Record<string, any>[];
|
|
@@ -474,6 +510,18 @@ declare class ProofLoopResource extends BaseResource {
|
|
|
474
510
|
idempotency_key?: string;
|
|
475
511
|
}): Promise<Record<string, any>>;
|
|
476
512
|
getDecision(decisionId: string): Promise<Record<string, any>>;
|
|
513
|
+
/** Owner-session administration. Use a separate client for the verifier key. */
|
|
514
|
+
registerVerifier(params: VerifierRegistration): Promise<Record<string, any>>;
|
|
515
|
+
revokeVerifier(verifierId: string): Promise<Record<string, any>>;
|
|
516
|
+
createEpisode(params: EpisodeCreateParams): Promise<Record<string, any>>;
|
|
517
|
+
getEpisode(episodeId: string, offset?: number): Promise<Record<string, any>>;
|
|
518
|
+
closeEpisode(episodeId: string, status: "completed" | "interrupted"): Promise<Record<string, any>>;
|
|
519
|
+
/** Append an execution claim. This method does not execute a tool. */
|
|
520
|
+
recordExecution(decisionId: string, claim: ExecutionClaim): Promise<Record<string, any>>;
|
|
521
|
+
assessment(decisionId: string, evidenceOffset?: number): Promise<Record<string, any>>;
|
|
522
|
+
verifierEvidence(verifierId: string, decisionId: string): Promise<Record<string, any>>;
|
|
523
|
+
/** Deliver using the dedicated source credential, after checking execution independently. */
|
|
524
|
+
deliverVerifiedOutcomes(verifierId: string, delivery: VerifiedOutcomeDelivery): Promise<Record<string, any>>;
|
|
477
525
|
defineMetric(params: ProofLoopMetricParams): Promise<Record<string, any>>;
|
|
478
526
|
listMetrics(params?: {
|
|
479
527
|
policy_key?: string;
|
|
@@ -807,4 +855,4 @@ interface SafetyEnvelope {
|
|
|
807
855
|
*/
|
|
808
856
|
declare function enforceSearchSafety<T extends object>(response: T, rowsKey?: "results" | "sources"): T & SafetyEnvelope;
|
|
809
857
|
|
|
810
|
-
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, EntitlementError, type EvidenceClaim, type GroundingReceipt, HebbrixError, IndexingAbortedError, IndexingTerminalError, IndexingTimeoutError, IndexingWaitError, type IndexingWaitErrorOptions, 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, enforceSearchSafety };
|
|
858
|
+
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, EntitlementError, type EpisodeCreateParams, type EvidenceClaim, type EvidenceScope, type ExecutionClaim, type GroundingReceipt, HebbrixError, IndexingAbortedError, IndexingTerminalError, IndexingTimeoutError, IndexingWaitError, type IndexingWaitErrorOptions, 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, type VerifiedOutcomeDelivery, type VerifierRegistration, WorkingMemoryResource, enforceSearchSafety };
|
package/dist/index.d.ts
CHANGED
|
@@ -101,12 +101,48 @@ interface ProofLoopCandidate {
|
|
|
101
101
|
}
|
|
102
102
|
interface ProofLoopDecisionParams {
|
|
103
103
|
policy_key: string;
|
|
104
|
+
episode_id?: string;
|
|
104
105
|
candidates: ProofLoopCandidate[];
|
|
105
106
|
proof_context?: ProofContext | string;
|
|
106
107
|
collection_id?: string;
|
|
107
108
|
user_id?: string;
|
|
108
109
|
[key: string]: any;
|
|
109
110
|
}
|
|
111
|
+
interface EvidenceScope {
|
|
112
|
+
policy_key: string;
|
|
113
|
+
collection_id?: string;
|
|
114
|
+
user_id?: string;
|
|
115
|
+
}
|
|
116
|
+
interface VerifierRegistration extends EvidenceScope {
|
|
117
|
+
api_key_id: string;
|
|
118
|
+
source_system: string;
|
|
119
|
+
metric_keys: string[];
|
|
120
|
+
}
|
|
121
|
+
interface EpisodeCreateParams extends EvidenceScope {
|
|
122
|
+
verifier_id: string;
|
|
123
|
+
idempotency_key: string;
|
|
124
|
+
}
|
|
125
|
+
interface ExecutionClaim {
|
|
126
|
+
attempt_id: string;
|
|
127
|
+
status: "started" | "completed" | "failed" | "interrupted" | "blocked";
|
|
128
|
+
actual_action_key: string;
|
|
129
|
+
arguments_digest: string;
|
|
130
|
+
evidence_digest?: string;
|
|
131
|
+
occurred_at?: string;
|
|
132
|
+
}
|
|
133
|
+
interface VerifiedOutcomeDelivery {
|
|
134
|
+
decision_id: string;
|
|
135
|
+
source_event_id: string;
|
|
136
|
+
evidence_digest: string;
|
|
137
|
+
execution_digest: string;
|
|
138
|
+
observations: Array<{
|
|
139
|
+
metric_key: string;
|
|
140
|
+
value: number;
|
|
141
|
+
confidence?: number;
|
|
142
|
+
is_final?: boolean;
|
|
143
|
+
observed_at: string;
|
|
144
|
+
}>;
|
|
145
|
+
}
|
|
110
146
|
interface ReasoningSource {
|
|
111
147
|
memory_id: string;
|
|
112
148
|
content: string;
|
|
@@ -465,7 +501,7 @@ declare class SearchResource extends BaseResource {
|
|
|
465
501
|
reason(params: ReasonParams): Promise<ReasoningResponse>;
|
|
466
502
|
}
|
|
467
503
|
declare class ProofLoopResource extends BaseResource {
|
|
468
|
-
/**
|
|
504
|
+
/** Record a recommendation; this never authorizes execution or proves causality. */
|
|
469
505
|
decide(params: ProofLoopDecisionParams): Promise<Record<string, any>>;
|
|
470
506
|
recordOutcome(decisionId: string, body: {
|
|
471
507
|
observations?: Record<string, any>[];
|
|
@@ -474,6 +510,18 @@ declare class ProofLoopResource extends BaseResource {
|
|
|
474
510
|
idempotency_key?: string;
|
|
475
511
|
}): Promise<Record<string, any>>;
|
|
476
512
|
getDecision(decisionId: string): Promise<Record<string, any>>;
|
|
513
|
+
/** Owner-session administration. Use a separate client for the verifier key. */
|
|
514
|
+
registerVerifier(params: VerifierRegistration): Promise<Record<string, any>>;
|
|
515
|
+
revokeVerifier(verifierId: string): Promise<Record<string, any>>;
|
|
516
|
+
createEpisode(params: EpisodeCreateParams): Promise<Record<string, any>>;
|
|
517
|
+
getEpisode(episodeId: string, offset?: number): Promise<Record<string, any>>;
|
|
518
|
+
closeEpisode(episodeId: string, status: "completed" | "interrupted"): Promise<Record<string, any>>;
|
|
519
|
+
/** Append an execution claim. This method does not execute a tool. */
|
|
520
|
+
recordExecution(decisionId: string, claim: ExecutionClaim): Promise<Record<string, any>>;
|
|
521
|
+
assessment(decisionId: string, evidenceOffset?: number): Promise<Record<string, any>>;
|
|
522
|
+
verifierEvidence(verifierId: string, decisionId: string): Promise<Record<string, any>>;
|
|
523
|
+
/** Deliver using the dedicated source credential, after checking execution independently. */
|
|
524
|
+
deliverVerifiedOutcomes(verifierId: string, delivery: VerifiedOutcomeDelivery): Promise<Record<string, any>>;
|
|
477
525
|
defineMetric(params: ProofLoopMetricParams): Promise<Record<string, any>>;
|
|
478
526
|
listMetrics(params?: {
|
|
479
527
|
policy_key?: string;
|
|
@@ -807,4 +855,4 @@ interface SafetyEnvelope {
|
|
|
807
855
|
*/
|
|
808
856
|
declare function enforceSearchSafety<T extends object>(response: T, rowsKey?: "results" | "sources"): T & SafetyEnvelope;
|
|
809
857
|
|
|
810
|
-
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, EntitlementError, type EvidenceClaim, type GroundingReceipt, HebbrixError, IndexingAbortedError, IndexingTerminalError, IndexingTimeoutError, IndexingWaitError, type IndexingWaitErrorOptions, 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, enforceSearchSafety };
|
|
858
|
+
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, EntitlementError, type EpisodeCreateParams, type EvidenceClaim, type EvidenceScope, type ExecutionClaim, type GroundingReceipt, HebbrixError, IndexingAbortedError, IndexingTerminalError, IndexingTimeoutError, IndexingWaitError, type IndexingWaitErrorOptions, 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, type VerifiedOutcomeDelivery, type VerifierRegistration, WorkingMemoryResource, enforceSearchSafety };
|
package/dist/index.js
CHANGED
|
@@ -61,7 +61,7 @@ var REQUIRED_FIELDS = [
|
|
|
61
61
|
function enforceSearchSafety(response, rowsKey = "results") {
|
|
62
62
|
const data = { ...response };
|
|
63
63
|
const rawRows = data[rowsKey];
|
|
64
|
-
const rows = Array.isArray(rawRows) ? rawRows
|
|
64
|
+
const rows = Array.isArray(rawRows) ? rawRows : [];
|
|
65
65
|
const missing = REQUIRED_FIELDS.filter(
|
|
66
66
|
(field) => !Object.prototype.hasOwnProperty.call(data, field)
|
|
67
67
|
);
|
|
@@ -76,6 +76,22 @@ function enforceSearchSafety(response, rowsKey = "results") {
|
|
|
76
76
|
reason = "invalid_grounding_receipt";
|
|
77
77
|
} else if (!Array.isArray(data.evidence_ids)) {
|
|
78
78
|
reason = "invalid_evidence_ids";
|
|
79
|
+
} else if (data.safety_contract_version !== "search-safety-v1") {
|
|
80
|
+
reason = "unsupported_safety_contract_version";
|
|
81
|
+
} else if (!Array.isArray(rawRows)) {
|
|
82
|
+
reason = "invalid_evidence_rows";
|
|
83
|
+
} else if (data.evidence_ids.some((id) => typeof id !== "string" || !id.trim())) {
|
|
84
|
+
reason = "invalid_evidence_ids";
|
|
85
|
+
} else if (new Set(data.evidence_ids).size !== data.evidence_ids.length) {
|
|
86
|
+
reason = "duplicate_evidence_ids";
|
|
87
|
+
} else if (rows.some((row) => {
|
|
88
|
+
if (!row || typeof row !== "object" || Array.isArray(row)) return true;
|
|
89
|
+
const id = "memory_id" in row ? row.memory_id : row.id;
|
|
90
|
+
return typeof id !== "string" || !id.trim() || "memory_id" in row && "id" in row && row.memory_id !== row.id;
|
|
91
|
+
})) {
|
|
92
|
+
reason = "invalid_evidence_row_identity";
|
|
93
|
+
} else if (rows.length === 0 && data.no_match === false) {
|
|
94
|
+
reason = "no_evidence_rows";
|
|
79
95
|
} else {
|
|
80
96
|
const evidenceIds = new Set(data.evidence_ids.map(String));
|
|
81
97
|
const rowIds = rows.map((row) => row.memory_id ?? row.id).filter((value) => typeof value === "string" && value.length > 0);
|
|
@@ -93,6 +109,10 @@ function enforceSearchSafety(response, rowsKey = "results") {
|
|
|
93
109
|
data.query_confidence = 0;
|
|
94
110
|
data.evidence_ids = [];
|
|
95
111
|
data.evidence_claims = [];
|
|
112
|
+
if (rowsKey === "sources") {
|
|
113
|
+
data.answer = null;
|
|
114
|
+
data.citations = [];
|
|
115
|
+
}
|
|
96
116
|
if (reason) {
|
|
97
117
|
data.sdk_safety_reason = reason;
|
|
98
118
|
data.grounding = { status: "no_grounded_match", reason };
|
|
@@ -710,7 +730,7 @@ var SearchResource = class extends BaseResource {
|
|
|
710
730
|
}
|
|
711
731
|
};
|
|
712
732
|
var ProofLoopResource = class extends BaseResource {
|
|
713
|
-
/**
|
|
733
|
+
/** Record a recommendation; this never authorizes execution or proves causality. */
|
|
714
734
|
async decide(params) {
|
|
715
735
|
const context = params.proof_context;
|
|
716
736
|
const token = typeof context === "string" ? context : context?.token;
|
|
@@ -729,6 +749,56 @@ var ProofLoopResource = class extends BaseResource {
|
|
|
729
749
|
async getDecision(decisionId) {
|
|
730
750
|
return this.client.get(`/v1/learning/decisions/${decisionId}`);
|
|
731
751
|
}
|
|
752
|
+
/** Owner-session administration. Use a separate client for the verifier key. */
|
|
753
|
+
async registerVerifier(params) {
|
|
754
|
+
return this.client.post("/v1/learning/verifiers", params);
|
|
755
|
+
}
|
|
756
|
+
async revokeVerifier(verifierId) {
|
|
757
|
+
return this.client.post(
|
|
758
|
+
`/v1/learning/verifiers/${encodeURIComponent(verifierId)}/revoke`,
|
|
759
|
+
{}
|
|
760
|
+
);
|
|
761
|
+
}
|
|
762
|
+
async createEpisode(params) {
|
|
763
|
+
return this.client.post("/v1/learning/episodes", params);
|
|
764
|
+
}
|
|
765
|
+
async getEpisode(episodeId, offset = 0) {
|
|
766
|
+
return this.client.get(
|
|
767
|
+
`/v1/learning/episodes/${encodeURIComponent(episodeId)}`,
|
|
768
|
+
{ offset }
|
|
769
|
+
);
|
|
770
|
+
}
|
|
771
|
+
async closeEpisode(episodeId, status) {
|
|
772
|
+
return this.client.post(
|
|
773
|
+
`/v1/learning/episodes/${encodeURIComponent(episodeId)}/close`,
|
|
774
|
+
{ status }
|
|
775
|
+
);
|
|
776
|
+
}
|
|
777
|
+
/** Append an execution claim. This method does not execute a tool. */
|
|
778
|
+
async recordExecution(decisionId, claim) {
|
|
779
|
+
return this.client.post(
|
|
780
|
+
`/v1/learning/decisions/${encodeURIComponent(decisionId)}/executions`,
|
|
781
|
+
claim
|
|
782
|
+
);
|
|
783
|
+
}
|
|
784
|
+
async assessment(decisionId, evidenceOffset = 0) {
|
|
785
|
+
return this.client.get(
|
|
786
|
+
`/v1/learning/decisions/${encodeURIComponent(decisionId)}/assessment`,
|
|
787
|
+
{ evidence_offset: evidenceOffset }
|
|
788
|
+
);
|
|
789
|
+
}
|
|
790
|
+
async verifierEvidence(verifierId, decisionId) {
|
|
791
|
+
return this.client.get(
|
|
792
|
+
`/v1/learning/verifiers/${encodeURIComponent(verifierId)}/decisions/${encodeURIComponent(decisionId)}`
|
|
793
|
+
);
|
|
794
|
+
}
|
|
795
|
+
/** Deliver using the dedicated source credential, after checking execution independently. */
|
|
796
|
+
async deliverVerifiedOutcomes(verifierId, delivery) {
|
|
797
|
+
return this.client.post(
|
|
798
|
+
`/v1/learning/verifiers/${encodeURIComponent(verifierId)}/events`,
|
|
799
|
+
delivery
|
|
800
|
+
);
|
|
801
|
+
}
|
|
732
802
|
async defineMetric(params) {
|
|
733
803
|
return this.client.post("/v1/learning/metrics", params);
|
|
734
804
|
}
|
|
@@ -1079,7 +1149,7 @@ var MemoryClient = class {
|
|
|
1079
1149
|
getHeaders() {
|
|
1080
1150
|
const headers = {
|
|
1081
1151
|
"Content-Type": "application/json",
|
|
1082
|
-
"User-Agent": "hebbrix-typescript/2.
|
|
1152
|
+
"User-Agent": "hebbrix-typescript/2.4.0"
|
|
1083
1153
|
};
|
|
1084
1154
|
if (this.apiKey) {
|
|
1085
1155
|
headers["Authorization"] = `Bearer ${this.apiKey}`;
|
package/dist/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ var REQUIRED_FIELDS = [
|
|
|
10
10
|
function enforceSearchSafety(response, rowsKey = "results") {
|
|
11
11
|
const data = { ...response };
|
|
12
12
|
const rawRows = data[rowsKey];
|
|
13
|
-
const rows = Array.isArray(rawRows) ? rawRows
|
|
13
|
+
const rows = Array.isArray(rawRows) ? rawRows : [];
|
|
14
14
|
const missing = REQUIRED_FIELDS.filter(
|
|
15
15
|
(field) => !Object.prototype.hasOwnProperty.call(data, field)
|
|
16
16
|
);
|
|
@@ -25,6 +25,22 @@ function enforceSearchSafety(response, rowsKey = "results") {
|
|
|
25
25
|
reason = "invalid_grounding_receipt";
|
|
26
26
|
} else if (!Array.isArray(data.evidence_ids)) {
|
|
27
27
|
reason = "invalid_evidence_ids";
|
|
28
|
+
} else if (data.safety_contract_version !== "search-safety-v1") {
|
|
29
|
+
reason = "unsupported_safety_contract_version";
|
|
30
|
+
} else if (!Array.isArray(rawRows)) {
|
|
31
|
+
reason = "invalid_evidence_rows";
|
|
32
|
+
} else if (data.evidence_ids.some((id) => typeof id !== "string" || !id.trim())) {
|
|
33
|
+
reason = "invalid_evidence_ids";
|
|
34
|
+
} else if (new Set(data.evidence_ids).size !== data.evidence_ids.length) {
|
|
35
|
+
reason = "duplicate_evidence_ids";
|
|
36
|
+
} else if (rows.some((row) => {
|
|
37
|
+
if (!row || typeof row !== "object" || Array.isArray(row)) return true;
|
|
38
|
+
const id = "memory_id" in row ? row.memory_id : row.id;
|
|
39
|
+
return typeof id !== "string" || !id.trim() || "memory_id" in row && "id" in row && row.memory_id !== row.id;
|
|
40
|
+
})) {
|
|
41
|
+
reason = "invalid_evidence_row_identity";
|
|
42
|
+
} else if (rows.length === 0 && data.no_match === false) {
|
|
43
|
+
reason = "no_evidence_rows";
|
|
28
44
|
} else {
|
|
29
45
|
const evidenceIds = new Set(data.evidence_ids.map(String));
|
|
30
46
|
const rowIds = rows.map((row) => row.memory_id ?? row.id).filter((value) => typeof value === "string" && value.length > 0);
|
|
@@ -42,6 +58,10 @@ function enforceSearchSafety(response, rowsKey = "results") {
|
|
|
42
58
|
data.query_confidence = 0;
|
|
43
59
|
data.evidence_ids = [];
|
|
44
60
|
data.evidence_claims = [];
|
|
61
|
+
if (rowsKey === "sources") {
|
|
62
|
+
data.answer = null;
|
|
63
|
+
data.citations = [];
|
|
64
|
+
}
|
|
45
65
|
if (reason) {
|
|
46
66
|
data.sdk_safety_reason = reason;
|
|
47
67
|
data.grounding = { status: "no_grounded_match", reason };
|
|
@@ -659,7 +679,7 @@ var SearchResource = class extends BaseResource {
|
|
|
659
679
|
}
|
|
660
680
|
};
|
|
661
681
|
var ProofLoopResource = class extends BaseResource {
|
|
662
|
-
/**
|
|
682
|
+
/** Record a recommendation; this never authorizes execution or proves causality. */
|
|
663
683
|
async decide(params) {
|
|
664
684
|
const context = params.proof_context;
|
|
665
685
|
const token = typeof context === "string" ? context : context?.token;
|
|
@@ -678,6 +698,56 @@ var ProofLoopResource = class extends BaseResource {
|
|
|
678
698
|
async getDecision(decisionId) {
|
|
679
699
|
return this.client.get(`/v1/learning/decisions/${decisionId}`);
|
|
680
700
|
}
|
|
701
|
+
/** Owner-session administration. Use a separate client for the verifier key. */
|
|
702
|
+
async registerVerifier(params) {
|
|
703
|
+
return this.client.post("/v1/learning/verifiers", params);
|
|
704
|
+
}
|
|
705
|
+
async revokeVerifier(verifierId) {
|
|
706
|
+
return this.client.post(
|
|
707
|
+
`/v1/learning/verifiers/${encodeURIComponent(verifierId)}/revoke`,
|
|
708
|
+
{}
|
|
709
|
+
);
|
|
710
|
+
}
|
|
711
|
+
async createEpisode(params) {
|
|
712
|
+
return this.client.post("/v1/learning/episodes", params);
|
|
713
|
+
}
|
|
714
|
+
async getEpisode(episodeId, offset = 0) {
|
|
715
|
+
return this.client.get(
|
|
716
|
+
`/v1/learning/episodes/${encodeURIComponent(episodeId)}`,
|
|
717
|
+
{ offset }
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
async closeEpisode(episodeId, status) {
|
|
721
|
+
return this.client.post(
|
|
722
|
+
`/v1/learning/episodes/${encodeURIComponent(episodeId)}/close`,
|
|
723
|
+
{ status }
|
|
724
|
+
);
|
|
725
|
+
}
|
|
726
|
+
/** Append an execution claim. This method does not execute a tool. */
|
|
727
|
+
async recordExecution(decisionId, claim) {
|
|
728
|
+
return this.client.post(
|
|
729
|
+
`/v1/learning/decisions/${encodeURIComponent(decisionId)}/executions`,
|
|
730
|
+
claim
|
|
731
|
+
);
|
|
732
|
+
}
|
|
733
|
+
async assessment(decisionId, evidenceOffset = 0) {
|
|
734
|
+
return this.client.get(
|
|
735
|
+
`/v1/learning/decisions/${encodeURIComponent(decisionId)}/assessment`,
|
|
736
|
+
{ evidence_offset: evidenceOffset }
|
|
737
|
+
);
|
|
738
|
+
}
|
|
739
|
+
async verifierEvidence(verifierId, decisionId) {
|
|
740
|
+
return this.client.get(
|
|
741
|
+
`/v1/learning/verifiers/${encodeURIComponent(verifierId)}/decisions/${encodeURIComponent(decisionId)}`
|
|
742
|
+
);
|
|
743
|
+
}
|
|
744
|
+
/** Deliver using the dedicated source credential, after checking execution independently. */
|
|
745
|
+
async deliverVerifiedOutcomes(verifierId, delivery) {
|
|
746
|
+
return this.client.post(
|
|
747
|
+
`/v1/learning/verifiers/${encodeURIComponent(verifierId)}/events`,
|
|
748
|
+
delivery
|
|
749
|
+
);
|
|
750
|
+
}
|
|
681
751
|
async defineMetric(params) {
|
|
682
752
|
return this.client.post("/v1/learning/metrics", params);
|
|
683
753
|
}
|
|
@@ -1028,7 +1098,7 @@ var MemoryClient = class {
|
|
|
1028
1098
|
getHeaders() {
|
|
1029
1099
|
const headers = {
|
|
1030
1100
|
"Content-Type": "application/json",
|
|
1031
|
-
"User-Agent": "hebbrix-typescript/2.
|
|
1101
|
+
"User-Agent": "hebbrix-typescript/2.4.0"
|
|
1032
1102
|
};
|
|
1033
1103
|
if (this.apiKey) {
|
|
1034
1104
|
headers["Authorization"] = `Bearer ${this.apiKey}`;
|