hebbrix 2.3.1 → 2.5.0-rc.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 +16 -0
- package/README.md +7 -1
- package/dist/index.d.mts +203 -2
- package/dist/index.d.ts +203 -2
- package/dist/index.js +157 -3
- package/dist/index.mjs +156 -3
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.5.0-rc.1 — 2026-09-09 (prerelease, npm `next`)
|
|
4
|
+
|
|
5
|
+
- Add typed native experience program, job, review, revision, policy activation
|
|
6
|
+
and one-use execution-permission transports.
|
|
7
|
+
- Preserve separate credentials, opaque evidence, uncertainty and authorization
|
|
8
|
+
receipts; never convert recommendations into execution permission.
|
|
9
|
+
- Require the matching `b5c6d7e8f959` backend, not yet deployed to public
|
|
10
|
+
production. Stable 2.4.0 remains the production recommendation.
|
|
11
|
+
|
|
12
|
+
## 2.4.0 — 2026-09-07
|
|
13
|
+
|
|
14
|
+
- Add typed Evidence Loop methods for owner-managed verifiers, durable episodes, actual-execution claims, protected outcome delivery and evidence assessments.
|
|
15
|
+
- Preserve incomplete outcomes, scope, replay and permission receipts. Verifier errors never fall back to caller-reported outcomes.
|
|
16
|
+
- Reject malformed, ambiguous or unknown evidence contracts before exposing unsupported synthesis; retain valid degraded evidence with its abstention signal.
|
|
17
|
+
- 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.
|
|
18
|
+
|
|
3
19
|
## 2.3.1 — 2026-08-27
|
|
4
20
|
|
|
5
21
|
- Make single-memory `wait_for_index` a client-enforced readiness contract:
|
package/README.md
CHANGED
|
@@ -5,8 +5,14 @@ outcome-learning APIs.
|
|
|
5
5
|
|
|
6
6
|
## Install
|
|
7
7
|
|
|
8
|
+
This branch is the **2.5.0-rc.1 prerelease**, published under npm `next`.
|
|
9
|
+
Native experience operations require backend schema `b5c6d7e8f959`, which is not
|
|
10
|
+
yet deployed to the public production API. Keep `2.4.0` for the current stable
|
|
11
|
+
deployment. Installing this SDK does not grant execution permission or establish
|
|
12
|
+
that an agent learns better outcomes.
|
|
13
|
+
|
|
8
14
|
```bash
|
|
9
|
-
npm install hebbrix@2.
|
|
15
|
+
npm install hebbrix@2.5.0-rc.1
|
|
10
16
|
```
|
|
11
17
|
|
|
12
18
|
Node.js 16+ and modern browsers are supported.
|
package/dist/index.d.mts
CHANGED
|
@@ -101,12 +101,84 @@ 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 ExperienceAssessmentParams {
|
|
122
|
+
collection_id?: string | null;
|
|
123
|
+
user_id?: string | null;
|
|
124
|
+
context: Record<string, unknown>;
|
|
125
|
+
candidate: {
|
|
126
|
+
schema_version?: "experience-candidate-v1";
|
|
127
|
+
policy_key: string;
|
|
128
|
+
action_key: string;
|
|
129
|
+
lesson: string;
|
|
130
|
+
applicability: {
|
|
131
|
+
schema_version?: "experience-applicability-v1";
|
|
132
|
+
required: Record<string, string | number | boolean>;
|
|
133
|
+
};
|
|
134
|
+
sources: Array<{
|
|
135
|
+
decision_id: string;
|
|
136
|
+
evidence_revision: number;
|
|
137
|
+
bundle_digest: string;
|
|
138
|
+
}>;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
interface ExperienceContextParams {
|
|
142
|
+
memory_collection_id: string;
|
|
143
|
+
evidence_collection_id?: string | null;
|
|
144
|
+
user_id?: string | null;
|
|
145
|
+
agent_id?: string | null;
|
|
146
|
+
run_id?: string | null;
|
|
147
|
+
policy_key: string;
|
|
148
|
+
references: Array<{
|
|
149
|
+
memory_id: string;
|
|
150
|
+
record_digest: string;
|
|
151
|
+
}>;
|
|
152
|
+
context: Record<string, unknown>;
|
|
153
|
+
max_context_bytes?: number;
|
|
154
|
+
}
|
|
155
|
+
interface EpisodeCreateParams extends EvidenceScope {
|
|
156
|
+
verifier_id: string;
|
|
157
|
+
idempotency_key: string;
|
|
158
|
+
}
|
|
159
|
+
interface ExecutionClaim {
|
|
160
|
+
attempt_id: string;
|
|
161
|
+
status: "started" | "completed" | "failed" | "interrupted" | "blocked";
|
|
162
|
+
actual_action_key: string;
|
|
163
|
+
arguments_digest: string;
|
|
164
|
+
evidence_digest?: string;
|
|
165
|
+
occurred_at?: string;
|
|
166
|
+
}
|
|
167
|
+
interface VerifiedOutcomeDelivery {
|
|
168
|
+
/** Optional source claims; their canonical digest must match evidence_digest. */
|
|
169
|
+
evidence_document?: Record<string, unknown>;
|
|
170
|
+
decision_id: string;
|
|
171
|
+
source_event_id: string;
|
|
172
|
+
evidence_digest: string;
|
|
173
|
+
execution_digest: string;
|
|
174
|
+
observations: Array<{
|
|
175
|
+
metric_key: string;
|
|
176
|
+
value: number;
|
|
177
|
+
confidence?: number;
|
|
178
|
+
is_final?: boolean;
|
|
179
|
+
observed_at: string;
|
|
180
|
+
}>;
|
|
181
|
+
}
|
|
110
182
|
interface ReasoningSource {
|
|
111
183
|
memory_id: string;
|
|
112
184
|
content: string;
|
|
@@ -465,7 +537,7 @@ declare class SearchResource extends BaseResource {
|
|
|
465
537
|
reason(params: ReasonParams): Promise<ReasoningResponse>;
|
|
466
538
|
}
|
|
467
539
|
declare class ProofLoopResource extends BaseResource {
|
|
468
|
-
/**
|
|
540
|
+
/** Record a recommendation; this never authorizes execution or proves causality. */
|
|
469
541
|
decide(params: ProofLoopDecisionParams): Promise<Record<string, any>>;
|
|
470
542
|
recordOutcome(decisionId: string, body: {
|
|
471
543
|
observations?: Record<string, any>[];
|
|
@@ -474,6 +546,22 @@ declare class ProofLoopResource extends BaseResource {
|
|
|
474
546
|
idempotency_key?: string;
|
|
475
547
|
}): Promise<Record<string, any>>;
|
|
476
548
|
getDecision(decisionId: string): Promise<Record<string, any>>;
|
|
549
|
+
/** Owner-session administration. Use a separate client for the verifier key. */
|
|
550
|
+
registerVerifier(params: VerifierRegistration): Promise<Record<string, any>>;
|
|
551
|
+
revokeVerifier(verifierId: string): Promise<Record<string, any>>;
|
|
552
|
+
createEpisode(params: EpisodeCreateParams): Promise<Record<string, any>>;
|
|
553
|
+
getEpisode(episodeId: string, offset?: number): Promise<Record<string, any>>;
|
|
554
|
+
closeEpisode(episodeId: string, status: "completed" | "interrupted"): Promise<Record<string, any>>;
|
|
555
|
+
/** Append an execution claim. This method does not execute a tool. */
|
|
556
|
+
recordExecution(decisionId: string, claim: ExecutionClaim): Promise<Record<string, any>>;
|
|
557
|
+
assessment(decisionId: string, evidenceOffset?: number): Promise<Record<string, any>>;
|
|
558
|
+
/** Revalidate a hypothesis against current source evidence; never permission to act. */
|
|
559
|
+
assessExperience(params: ExperienceAssessmentParams): Promise<Record<string, any>>;
|
|
560
|
+
/** Revalidate selected stored hypotheses; never grants execution permission. */
|
|
561
|
+
experienceContext(params: ExperienceContextParams): Promise<Record<string, any>>;
|
|
562
|
+
verifierEvidence(verifierId: string, decisionId: string): Promise<Record<string, any>>;
|
|
563
|
+
/** Deliver using the dedicated source credential, after checking execution independently. */
|
|
564
|
+
deliverVerifiedOutcomes(verifierId: string, delivery: VerifiedOutcomeDelivery): Promise<Record<string, any>>;
|
|
477
565
|
defineMetric(params: ProofLoopMetricParams): Promise<Record<string, any>>;
|
|
478
566
|
listMetrics(params?: {
|
|
479
567
|
policy_key?: string;
|
|
@@ -668,6 +756,118 @@ declare class MemoryToolsResource extends BaseResource {
|
|
|
668
756
|
rethink(memoryId: string, collectionId: string): Promise<any>;
|
|
669
757
|
}
|
|
670
758
|
|
|
759
|
+
/** Native workflow transport. Separate owner, worker and reviewer credentials.
|
|
760
|
+
* No provider call or autonomous tool execution is started by this resource.
|
|
761
|
+
*/
|
|
762
|
+
|
|
763
|
+
interface ReflectionConfig {
|
|
764
|
+
model: string;
|
|
765
|
+
applicability_keys: string[];
|
|
766
|
+
maximum_attempts: number;
|
|
767
|
+
budget_microusd: number;
|
|
768
|
+
per_attempt_microusd: number;
|
|
769
|
+
lease_seconds?: number;
|
|
770
|
+
}
|
|
771
|
+
interface ExperienceProgramInput {
|
|
772
|
+
collection_id?: string;
|
|
773
|
+
memory_collection_id: string;
|
|
774
|
+
user_id?: string;
|
|
775
|
+
agent_id?: string;
|
|
776
|
+
run_id?: string;
|
|
777
|
+
policy_key: string;
|
|
778
|
+
worker_key_id: string;
|
|
779
|
+
reviewer_key_id?: string;
|
|
780
|
+
source_since?: string;
|
|
781
|
+
config: ReflectionConfig;
|
|
782
|
+
}
|
|
783
|
+
interface ReflectionOutput {
|
|
784
|
+
schema_version?: "experience-reflection-output-v1";
|
|
785
|
+
hypotheses: Array<{
|
|
786
|
+
advice: string;
|
|
787
|
+
rationale: string;
|
|
788
|
+
limitations: string;
|
|
789
|
+
future_verification: string;
|
|
790
|
+
}>;
|
|
791
|
+
insufficient_evidence_reason?: string | null;
|
|
792
|
+
}
|
|
793
|
+
interface LessonReviewInput {
|
|
794
|
+
expected_sequence: number;
|
|
795
|
+
expected_digest: string | null;
|
|
796
|
+
candidate_digest: string;
|
|
797
|
+
verdict: "eligible" | "blocked" | "retracted";
|
|
798
|
+
rationale: string;
|
|
799
|
+
}
|
|
800
|
+
interface LessonRevisionInput extends Omit<LessonReviewInput, "verdict"> {
|
|
801
|
+
request_key: string;
|
|
802
|
+
hypothesis: ReflectionOutput["hypotheses"][number];
|
|
803
|
+
}
|
|
804
|
+
type ReflectionUncertainty = "provider_failure" | "invalid_provider_output" | "completion_delivery_uncertain";
|
|
805
|
+
declare class ExperienceWorkflowResource {
|
|
806
|
+
private client;
|
|
807
|
+
constructor(client: MemoryClient);
|
|
808
|
+
definePermission(id: string, policy: {
|
|
809
|
+
actor_key_id: string;
|
|
810
|
+
tool_key: string;
|
|
811
|
+
target_digest: string;
|
|
812
|
+
action_keys: string[];
|
|
813
|
+
maximum_argument_bytes: number;
|
|
814
|
+
maximum_dispatches: number;
|
|
815
|
+
permit_seconds: number;
|
|
816
|
+
capability_contract: string;
|
|
817
|
+
}): Promise<any>;
|
|
818
|
+
activatePermission(id: string, activation: {
|
|
819
|
+
policy_id: string | null;
|
|
820
|
+
expected_sequence: number;
|
|
821
|
+
expected_digest: string | null;
|
|
822
|
+
rationale: string;
|
|
823
|
+
}): Promise<any>;
|
|
824
|
+
permissionState(id: string): Promise<any>;
|
|
825
|
+
issuePermit(id: string, input: {
|
|
826
|
+
lesson_id: string;
|
|
827
|
+
decision_id: string;
|
|
828
|
+
request_key: string;
|
|
829
|
+
invocation: {
|
|
830
|
+
tool_key: string;
|
|
831
|
+
target: Record<string, unknown>;
|
|
832
|
+
arguments: Record<string, unknown>;
|
|
833
|
+
};
|
|
834
|
+
}): Promise<any>;
|
|
835
|
+
dispatchPermit(id: string, invocationDigest: string): Promise<any>;
|
|
836
|
+
permit(id: string): Promise<any>;
|
|
837
|
+
register(input: ExperienceProgramInput): Promise<any>;
|
|
838
|
+
program(id: string): Promise<any>;
|
|
839
|
+
stop(id: string): Promise<any>;
|
|
840
|
+
claim(id: string, requestKey: string): Promise<any>;
|
|
841
|
+
job(id: string): Promise<any>;
|
|
842
|
+
/** A dispatch grant is single-use. Never retry a provider call after uncertainty. */
|
|
843
|
+
dispatch(id: string, input: {
|
|
844
|
+
input_digest: string;
|
|
845
|
+
request_digest: string;
|
|
846
|
+
}): Promise<any>;
|
|
847
|
+
complete(id: string, input: {
|
|
848
|
+
output: ReflectionOutput;
|
|
849
|
+
request_digest: string;
|
|
850
|
+
provider_response_digest: string;
|
|
851
|
+
reported_microusd: number;
|
|
852
|
+
}): Promise<any>;
|
|
853
|
+
uncertain(id: string, requestDigest: string, reason: ReflectionUncertainty): Promise<any>;
|
|
854
|
+
lessons(id: string, params?: {
|
|
855
|
+
after_id?: string;
|
|
856
|
+
limit?: number;
|
|
857
|
+
}): Promise<any>;
|
|
858
|
+
reviewQueue(id: string, params?: {
|
|
859
|
+
after_id?: string;
|
|
860
|
+
limit?: number;
|
|
861
|
+
}): Promise<any>;
|
|
862
|
+
lesson(id: string): Promise<any>;
|
|
863
|
+
review(id: string, input: LessonReviewInput): Promise<any>;
|
|
864
|
+
revise(id: string, input: LessonRevisionInput): Promise<any>;
|
|
865
|
+
reviews(id: string, params?: {
|
|
866
|
+
after_sequence?: number;
|
|
867
|
+
limit?: number;
|
|
868
|
+
}): Promise<any>;
|
|
869
|
+
}
|
|
870
|
+
|
|
671
871
|
declare class MemoryClient {
|
|
672
872
|
private apiKey?;
|
|
673
873
|
private baseUrl;
|
|
@@ -685,6 +885,7 @@ declare class MemoryClient {
|
|
|
685
885
|
consolidation: ConsolidationResource;
|
|
686
886
|
memoryTools: MemoryToolsResource;
|
|
687
887
|
proofloop: ProofLoopResource;
|
|
888
|
+
experiences: ExperienceWorkflowResource;
|
|
688
889
|
constructor(config?: ClientConfig);
|
|
689
890
|
private getHeaders;
|
|
690
891
|
private handleError;
|
|
@@ -807,4 +1008,4 @@ interface SafetyEnvelope {
|
|
|
807
1008
|
*/
|
|
808
1009
|
declare function enforceSearchSafety<T extends object>(response: T, rowsKey?: "results" | "sources"): T & SafetyEnvelope;
|
|
809
1010
|
|
|
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 };
|
|
1011
|
+
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 ExperienceAssessmentParams, type ExperienceContextParams, type ExperienceProgramInput, ExperienceWorkflowResource, type GroundingReceipt, HebbrixError, IndexingAbortedError, IndexingTerminalError, IndexingTimeoutError, IndexingWaitError, type IndexingWaitErrorOptions, type LessonReviewInput, type LessonRevisionInput, 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 ReflectionConfig, type ReflectionOutput, type ReflectionUncertainty, 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,84 @@ 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 ExperienceAssessmentParams {
|
|
122
|
+
collection_id?: string | null;
|
|
123
|
+
user_id?: string | null;
|
|
124
|
+
context: Record<string, unknown>;
|
|
125
|
+
candidate: {
|
|
126
|
+
schema_version?: "experience-candidate-v1";
|
|
127
|
+
policy_key: string;
|
|
128
|
+
action_key: string;
|
|
129
|
+
lesson: string;
|
|
130
|
+
applicability: {
|
|
131
|
+
schema_version?: "experience-applicability-v1";
|
|
132
|
+
required: Record<string, string | number | boolean>;
|
|
133
|
+
};
|
|
134
|
+
sources: Array<{
|
|
135
|
+
decision_id: string;
|
|
136
|
+
evidence_revision: number;
|
|
137
|
+
bundle_digest: string;
|
|
138
|
+
}>;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
interface ExperienceContextParams {
|
|
142
|
+
memory_collection_id: string;
|
|
143
|
+
evidence_collection_id?: string | null;
|
|
144
|
+
user_id?: string | null;
|
|
145
|
+
agent_id?: string | null;
|
|
146
|
+
run_id?: string | null;
|
|
147
|
+
policy_key: string;
|
|
148
|
+
references: Array<{
|
|
149
|
+
memory_id: string;
|
|
150
|
+
record_digest: string;
|
|
151
|
+
}>;
|
|
152
|
+
context: Record<string, unknown>;
|
|
153
|
+
max_context_bytes?: number;
|
|
154
|
+
}
|
|
155
|
+
interface EpisodeCreateParams extends EvidenceScope {
|
|
156
|
+
verifier_id: string;
|
|
157
|
+
idempotency_key: string;
|
|
158
|
+
}
|
|
159
|
+
interface ExecutionClaim {
|
|
160
|
+
attempt_id: string;
|
|
161
|
+
status: "started" | "completed" | "failed" | "interrupted" | "blocked";
|
|
162
|
+
actual_action_key: string;
|
|
163
|
+
arguments_digest: string;
|
|
164
|
+
evidence_digest?: string;
|
|
165
|
+
occurred_at?: string;
|
|
166
|
+
}
|
|
167
|
+
interface VerifiedOutcomeDelivery {
|
|
168
|
+
/** Optional source claims; their canonical digest must match evidence_digest. */
|
|
169
|
+
evidence_document?: Record<string, unknown>;
|
|
170
|
+
decision_id: string;
|
|
171
|
+
source_event_id: string;
|
|
172
|
+
evidence_digest: string;
|
|
173
|
+
execution_digest: string;
|
|
174
|
+
observations: Array<{
|
|
175
|
+
metric_key: string;
|
|
176
|
+
value: number;
|
|
177
|
+
confidence?: number;
|
|
178
|
+
is_final?: boolean;
|
|
179
|
+
observed_at: string;
|
|
180
|
+
}>;
|
|
181
|
+
}
|
|
110
182
|
interface ReasoningSource {
|
|
111
183
|
memory_id: string;
|
|
112
184
|
content: string;
|
|
@@ -465,7 +537,7 @@ declare class SearchResource extends BaseResource {
|
|
|
465
537
|
reason(params: ReasonParams): Promise<ReasoningResponse>;
|
|
466
538
|
}
|
|
467
539
|
declare class ProofLoopResource extends BaseResource {
|
|
468
|
-
/**
|
|
540
|
+
/** Record a recommendation; this never authorizes execution or proves causality. */
|
|
469
541
|
decide(params: ProofLoopDecisionParams): Promise<Record<string, any>>;
|
|
470
542
|
recordOutcome(decisionId: string, body: {
|
|
471
543
|
observations?: Record<string, any>[];
|
|
@@ -474,6 +546,22 @@ declare class ProofLoopResource extends BaseResource {
|
|
|
474
546
|
idempotency_key?: string;
|
|
475
547
|
}): Promise<Record<string, any>>;
|
|
476
548
|
getDecision(decisionId: string): Promise<Record<string, any>>;
|
|
549
|
+
/** Owner-session administration. Use a separate client for the verifier key. */
|
|
550
|
+
registerVerifier(params: VerifierRegistration): Promise<Record<string, any>>;
|
|
551
|
+
revokeVerifier(verifierId: string): Promise<Record<string, any>>;
|
|
552
|
+
createEpisode(params: EpisodeCreateParams): Promise<Record<string, any>>;
|
|
553
|
+
getEpisode(episodeId: string, offset?: number): Promise<Record<string, any>>;
|
|
554
|
+
closeEpisode(episodeId: string, status: "completed" | "interrupted"): Promise<Record<string, any>>;
|
|
555
|
+
/** Append an execution claim. This method does not execute a tool. */
|
|
556
|
+
recordExecution(decisionId: string, claim: ExecutionClaim): Promise<Record<string, any>>;
|
|
557
|
+
assessment(decisionId: string, evidenceOffset?: number): Promise<Record<string, any>>;
|
|
558
|
+
/** Revalidate a hypothesis against current source evidence; never permission to act. */
|
|
559
|
+
assessExperience(params: ExperienceAssessmentParams): Promise<Record<string, any>>;
|
|
560
|
+
/** Revalidate selected stored hypotheses; never grants execution permission. */
|
|
561
|
+
experienceContext(params: ExperienceContextParams): Promise<Record<string, any>>;
|
|
562
|
+
verifierEvidence(verifierId: string, decisionId: string): Promise<Record<string, any>>;
|
|
563
|
+
/** Deliver using the dedicated source credential, after checking execution independently. */
|
|
564
|
+
deliverVerifiedOutcomes(verifierId: string, delivery: VerifiedOutcomeDelivery): Promise<Record<string, any>>;
|
|
477
565
|
defineMetric(params: ProofLoopMetricParams): Promise<Record<string, any>>;
|
|
478
566
|
listMetrics(params?: {
|
|
479
567
|
policy_key?: string;
|
|
@@ -668,6 +756,118 @@ declare class MemoryToolsResource extends BaseResource {
|
|
|
668
756
|
rethink(memoryId: string, collectionId: string): Promise<any>;
|
|
669
757
|
}
|
|
670
758
|
|
|
759
|
+
/** Native workflow transport. Separate owner, worker and reviewer credentials.
|
|
760
|
+
* No provider call or autonomous tool execution is started by this resource.
|
|
761
|
+
*/
|
|
762
|
+
|
|
763
|
+
interface ReflectionConfig {
|
|
764
|
+
model: string;
|
|
765
|
+
applicability_keys: string[];
|
|
766
|
+
maximum_attempts: number;
|
|
767
|
+
budget_microusd: number;
|
|
768
|
+
per_attempt_microusd: number;
|
|
769
|
+
lease_seconds?: number;
|
|
770
|
+
}
|
|
771
|
+
interface ExperienceProgramInput {
|
|
772
|
+
collection_id?: string;
|
|
773
|
+
memory_collection_id: string;
|
|
774
|
+
user_id?: string;
|
|
775
|
+
agent_id?: string;
|
|
776
|
+
run_id?: string;
|
|
777
|
+
policy_key: string;
|
|
778
|
+
worker_key_id: string;
|
|
779
|
+
reviewer_key_id?: string;
|
|
780
|
+
source_since?: string;
|
|
781
|
+
config: ReflectionConfig;
|
|
782
|
+
}
|
|
783
|
+
interface ReflectionOutput {
|
|
784
|
+
schema_version?: "experience-reflection-output-v1";
|
|
785
|
+
hypotheses: Array<{
|
|
786
|
+
advice: string;
|
|
787
|
+
rationale: string;
|
|
788
|
+
limitations: string;
|
|
789
|
+
future_verification: string;
|
|
790
|
+
}>;
|
|
791
|
+
insufficient_evidence_reason?: string | null;
|
|
792
|
+
}
|
|
793
|
+
interface LessonReviewInput {
|
|
794
|
+
expected_sequence: number;
|
|
795
|
+
expected_digest: string | null;
|
|
796
|
+
candidate_digest: string;
|
|
797
|
+
verdict: "eligible" | "blocked" | "retracted";
|
|
798
|
+
rationale: string;
|
|
799
|
+
}
|
|
800
|
+
interface LessonRevisionInput extends Omit<LessonReviewInput, "verdict"> {
|
|
801
|
+
request_key: string;
|
|
802
|
+
hypothesis: ReflectionOutput["hypotheses"][number];
|
|
803
|
+
}
|
|
804
|
+
type ReflectionUncertainty = "provider_failure" | "invalid_provider_output" | "completion_delivery_uncertain";
|
|
805
|
+
declare class ExperienceWorkflowResource {
|
|
806
|
+
private client;
|
|
807
|
+
constructor(client: MemoryClient);
|
|
808
|
+
definePermission(id: string, policy: {
|
|
809
|
+
actor_key_id: string;
|
|
810
|
+
tool_key: string;
|
|
811
|
+
target_digest: string;
|
|
812
|
+
action_keys: string[];
|
|
813
|
+
maximum_argument_bytes: number;
|
|
814
|
+
maximum_dispatches: number;
|
|
815
|
+
permit_seconds: number;
|
|
816
|
+
capability_contract: string;
|
|
817
|
+
}): Promise<any>;
|
|
818
|
+
activatePermission(id: string, activation: {
|
|
819
|
+
policy_id: string | null;
|
|
820
|
+
expected_sequence: number;
|
|
821
|
+
expected_digest: string | null;
|
|
822
|
+
rationale: string;
|
|
823
|
+
}): Promise<any>;
|
|
824
|
+
permissionState(id: string): Promise<any>;
|
|
825
|
+
issuePermit(id: string, input: {
|
|
826
|
+
lesson_id: string;
|
|
827
|
+
decision_id: string;
|
|
828
|
+
request_key: string;
|
|
829
|
+
invocation: {
|
|
830
|
+
tool_key: string;
|
|
831
|
+
target: Record<string, unknown>;
|
|
832
|
+
arguments: Record<string, unknown>;
|
|
833
|
+
};
|
|
834
|
+
}): Promise<any>;
|
|
835
|
+
dispatchPermit(id: string, invocationDigest: string): Promise<any>;
|
|
836
|
+
permit(id: string): Promise<any>;
|
|
837
|
+
register(input: ExperienceProgramInput): Promise<any>;
|
|
838
|
+
program(id: string): Promise<any>;
|
|
839
|
+
stop(id: string): Promise<any>;
|
|
840
|
+
claim(id: string, requestKey: string): Promise<any>;
|
|
841
|
+
job(id: string): Promise<any>;
|
|
842
|
+
/** A dispatch grant is single-use. Never retry a provider call after uncertainty. */
|
|
843
|
+
dispatch(id: string, input: {
|
|
844
|
+
input_digest: string;
|
|
845
|
+
request_digest: string;
|
|
846
|
+
}): Promise<any>;
|
|
847
|
+
complete(id: string, input: {
|
|
848
|
+
output: ReflectionOutput;
|
|
849
|
+
request_digest: string;
|
|
850
|
+
provider_response_digest: string;
|
|
851
|
+
reported_microusd: number;
|
|
852
|
+
}): Promise<any>;
|
|
853
|
+
uncertain(id: string, requestDigest: string, reason: ReflectionUncertainty): Promise<any>;
|
|
854
|
+
lessons(id: string, params?: {
|
|
855
|
+
after_id?: string;
|
|
856
|
+
limit?: number;
|
|
857
|
+
}): Promise<any>;
|
|
858
|
+
reviewQueue(id: string, params?: {
|
|
859
|
+
after_id?: string;
|
|
860
|
+
limit?: number;
|
|
861
|
+
}): Promise<any>;
|
|
862
|
+
lesson(id: string): Promise<any>;
|
|
863
|
+
review(id: string, input: LessonReviewInput): Promise<any>;
|
|
864
|
+
revise(id: string, input: LessonRevisionInput): Promise<any>;
|
|
865
|
+
reviews(id: string, params?: {
|
|
866
|
+
after_sequence?: number;
|
|
867
|
+
limit?: number;
|
|
868
|
+
}): Promise<any>;
|
|
869
|
+
}
|
|
870
|
+
|
|
671
871
|
declare class MemoryClient {
|
|
672
872
|
private apiKey?;
|
|
673
873
|
private baseUrl;
|
|
@@ -685,6 +885,7 @@ declare class MemoryClient {
|
|
|
685
885
|
consolidation: ConsolidationResource;
|
|
686
886
|
memoryTools: MemoryToolsResource;
|
|
687
887
|
proofloop: ProofLoopResource;
|
|
888
|
+
experiences: ExperienceWorkflowResource;
|
|
688
889
|
constructor(config?: ClientConfig);
|
|
689
890
|
private getHeaders;
|
|
690
891
|
private handleError;
|
|
@@ -807,4 +1008,4 @@ interface SafetyEnvelope {
|
|
|
807
1008
|
*/
|
|
808
1009
|
declare function enforceSearchSafety<T extends object>(response: T, rowsKey?: "results" | "sources"): T & SafetyEnvelope;
|
|
809
1010
|
|
|
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 };
|
|
1011
|
+
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 ExperienceAssessmentParams, type ExperienceContextParams, type ExperienceProgramInput, ExperienceWorkflowResource, type GroundingReceipt, HebbrixError, IndexingAbortedError, IndexingTerminalError, IndexingTimeoutError, IndexingWaitError, type IndexingWaitErrorOptions, type LessonReviewInput, type LessonRevisionInput, 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 ReflectionConfig, type ReflectionOutput, type ReflectionUncertainty, 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
|
@@ -26,6 +26,7 @@ __export(index_exports, {
|
|
|
26
26
|
ConsolidationResource: () => ConsolidationResource,
|
|
27
27
|
CorrectionsResource: () => CorrectionsResource,
|
|
28
28
|
EntitlementError: () => EntitlementError,
|
|
29
|
+
ExperienceWorkflowResource: () => ExperienceWorkflowResource,
|
|
29
30
|
HebbrixError: () => HebbrixError,
|
|
30
31
|
IndexingAbortedError: () => IndexingAbortedError,
|
|
31
32
|
IndexingTerminalError: () => IndexingTerminalError,
|
|
@@ -61,7 +62,7 @@ var REQUIRED_FIELDS = [
|
|
|
61
62
|
function enforceSearchSafety(response, rowsKey = "results") {
|
|
62
63
|
const data = { ...response };
|
|
63
64
|
const rawRows = data[rowsKey];
|
|
64
|
-
const rows = Array.isArray(rawRows) ? rawRows
|
|
65
|
+
const rows = Array.isArray(rawRows) ? rawRows : [];
|
|
65
66
|
const missing = REQUIRED_FIELDS.filter(
|
|
66
67
|
(field) => !Object.prototype.hasOwnProperty.call(data, field)
|
|
67
68
|
);
|
|
@@ -76,6 +77,22 @@ function enforceSearchSafety(response, rowsKey = "results") {
|
|
|
76
77
|
reason = "invalid_grounding_receipt";
|
|
77
78
|
} else if (!Array.isArray(data.evidence_ids)) {
|
|
78
79
|
reason = "invalid_evidence_ids";
|
|
80
|
+
} else if (data.safety_contract_version !== "search-safety-v1") {
|
|
81
|
+
reason = "unsupported_safety_contract_version";
|
|
82
|
+
} else if (!Array.isArray(rawRows)) {
|
|
83
|
+
reason = "invalid_evidence_rows";
|
|
84
|
+
} else if (data.evidence_ids.some((id) => typeof id !== "string" || !id.trim())) {
|
|
85
|
+
reason = "invalid_evidence_ids";
|
|
86
|
+
} else if (new Set(data.evidence_ids).size !== data.evidence_ids.length) {
|
|
87
|
+
reason = "duplicate_evidence_ids";
|
|
88
|
+
} else if (rows.some((row) => {
|
|
89
|
+
if (!row || typeof row !== "object" || Array.isArray(row)) return true;
|
|
90
|
+
const id = "memory_id" in row ? row.memory_id : row.id;
|
|
91
|
+
return typeof id !== "string" || !id.trim() || "memory_id" in row && "id" in row && row.memory_id !== row.id;
|
|
92
|
+
})) {
|
|
93
|
+
reason = "invalid_evidence_row_identity";
|
|
94
|
+
} else if (rows.length === 0 && data.no_match === false) {
|
|
95
|
+
reason = "no_evidence_rows";
|
|
79
96
|
} else {
|
|
80
97
|
const evidenceIds = new Set(data.evidence_ids.map(String));
|
|
81
98
|
const rowIds = rows.map((row) => row.memory_id ?? row.id).filter((value) => typeof value === "string" && value.length > 0);
|
|
@@ -93,6 +110,10 @@ function enforceSearchSafety(response, rowsKey = "results") {
|
|
|
93
110
|
data.query_confidence = 0;
|
|
94
111
|
data.evidence_ids = [];
|
|
95
112
|
data.evidence_claims = [];
|
|
113
|
+
if (rowsKey === "sources") {
|
|
114
|
+
data.answer = null;
|
|
115
|
+
data.citations = [];
|
|
116
|
+
}
|
|
96
117
|
if (reason) {
|
|
97
118
|
data.sdk_safety_reason = reason;
|
|
98
119
|
data.grounding = { status: "no_grounded_match", reason };
|
|
@@ -710,7 +731,7 @@ var SearchResource = class extends BaseResource {
|
|
|
710
731
|
}
|
|
711
732
|
};
|
|
712
733
|
var ProofLoopResource = class extends BaseResource {
|
|
713
|
-
/**
|
|
734
|
+
/** Record a recommendation; this never authorizes execution or proves causality. */
|
|
714
735
|
async decide(params) {
|
|
715
736
|
const context = params.proof_context;
|
|
716
737
|
const token = typeof context === "string" ? context : context?.token;
|
|
@@ -729,6 +750,64 @@ var ProofLoopResource = class extends BaseResource {
|
|
|
729
750
|
async getDecision(decisionId) {
|
|
730
751
|
return this.client.get(`/v1/learning/decisions/${decisionId}`);
|
|
731
752
|
}
|
|
753
|
+
/** Owner-session administration. Use a separate client for the verifier key. */
|
|
754
|
+
async registerVerifier(params) {
|
|
755
|
+
return this.client.post("/v1/learning/verifiers", params);
|
|
756
|
+
}
|
|
757
|
+
async revokeVerifier(verifierId) {
|
|
758
|
+
return this.client.post(
|
|
759
|
+
`/v1/learning/verifiers/${encodeURIComponent(verifierId)}/revoke`,
|
|
760
|
+
{}
|
|
761
|
+
);
|
|
762
|
+
}
|
|
763
|
+
async createEpisode(params) {
|
|
764
|
+
return this.client.post("/v1/learning/episodes", params);
|
|
765
|
+
}
|
|
766
|
+
async getEpisode(episodeId, offset = 0) {
|
|
767
|
+
return this.client.get(
|
|
768
|
+
`/v1/learning/episodes/${encodeURIComponent(episodeId)}`,
|
|
769
|
+
{ offset }
|
|
770
|
+
);
|
|
771
|
+
}
|
|
772
|
+
async closeEpisode(episodeId, status) {
|
|
773
|
+
return this.client.post(
|
|
774
|
+
`/v1/learning/episodes/${encodeURIComponent(episodeId)}/close`,
|
|
775
|
+
{ status }
|
|
776
|
+
);
|
|
777
|
+
}
|
|
778
|
+
/** Append an execution claim. This method does not execute a tool. */
|
|
779
|
+
async recordExecution(decisionId, claim) {
|
|
780
|
+
return this.client.post(
|
|
781
|
+
`/v1/learning/decisions/${encodeURIComponent(decisionId)}/executions`,
|
|
782
|
+
claim
|
|
783
|
+
);
|
|
784
|
+
}
|
|
785
|
+
async assessment(decisionId, evidenceOffset = 0) {
|
|
786
|
+
return this.client.get(
|
|
787
|
+
`/v1/learning/decisions/${encodeURIComponent(decisionId)}/assessment`,
|
|
788
|
+
{ evidence_offset: evidenceOffset }
|
|
789
|
+
);
|
|
790
|
+
}
|
|
791
|
+
/** Revalidate a hypothesis against current source evidence; never permission to act. */
|
|
792
|
+
async assessExperience(params) {
|
|
793
|
+
return this.client.post("/v1/learning/experiences/assess", params);
|
|
794
|
+
}
|
|
795
|
+
/** Revalidate selected stored hypotheses; never grants execution permission. */
|
|
796
|
+
async experienceContext(params) {
|
|
797
|
+
return this.client.post("/v1/learning/experiences/context", params);
|
|
798
|
+
}
|
|
799
|
+
async verifierEvidence(verifierId, decisionId) {
|
|
800
|
+
return this.client.get(
|
|
801
|
+
`/v1/learning/verifiers/${encodeURIComponent(verifierId)}/decisions/${encodeURIComponent(decisionId)}`
|
|
802
|
+
);
|
|
803
|
+
}
|
|
804
|
+
/** Deliver using the dedicated source credential, after checking execution independently. */
|
|
805
|
+
async deliverVerifiedOutcomes(verifierId, delivery) {
|
|
806
|
+
return this.client.post(
|
|
807
|
+
`/v1/learning/verifiers/${encodeURIComponent(verifierId)}/events`,
|
|
808
|
+
delivery
|
|
809
|
+
);
|
|
810
|
+
}
|
|
732
811
|
async defineMetric(params) {
|
|
733
812
|
return this.client.post("/v1/learning/metrics", params);
|
|
734
813
|
}
|
|
@@ -1055,6 +1134,79 @@ var MemoryToolsResource = class extends BaseResource {
|
|
|
1055
1134
|
}
|
|
1056
1135
|
};
|
|
1057
1136
|
|
|
1137
|
+
// src/experience-workflow.ts
|
|
1138
|
+
var root = "/v1/learning/experiences";
|
|
1139
|
+
var resource = (kind, id) => `${root}/${kind}/${encodeURIComponent(id)}`;
|
|
1140
|
+
var ExperienceWorkflowResource = class {
|
|
1141
|
+
constructor(client) {
|
|
1142
|
+
this.client = client;
|
|
1143
|
+
}
|
|
1144
|
+
definePermission(id, policy) {
|
|
1145
|
+
return this.client.post(`${resource("programs", id)}/permission-policies`, policy);
|
|
1146
|
+
}
|
|
1147
|
+
activatePermission(id, activation) {
|
|
1148
|
+
return this.client.post(`${resource("programs", id)}/permission-activation`, activation);
|
|
1149
|
+
}
|
|
1150
|
+
permissionState(id) {
|
|
1151
|
+
return this.client.get(`${resource("programs", id)}/permission-state`);
|
|
1152
|
+
}
|
|
1153
|
+
issuePermit(id, input) {
|
|
1154
|
+
return this.client.post(`${resource("programs", id)}/permits`, input);
|
|
1155
|
+
}
|
|
1156
|
+
dispatchPermit(id, invocationDigest) {
|
|
1157
|
+
return this.client.post(`${resource("permits", id)}/dispatch`, { invocation_digest: invocationDigest });
|
|
1158
|
+
}
|
|
1159
|
+
permit(id) {
|
|
1160
|
+
return this.client.get(resource("permits", id));
|
|
1161
|
+
}
|
|
1162
|
+
register(input) {
|
|
1163
|
+
return this.client.post(`${root}/programs`, input);
|
|
1164
|
+
}
|
|
1165
|
+
program(id) {
|
|
1166
|
+
return this.client.get(resource("programs", id));
|
|
1167
|
+
}
|
|
1168
|
+
stop(id) {
|
|
1169
|
+
return this.client.post(`${resource("programs", id)}/stop`);
|
|
1170
|
+
}
|
|
1171
|
+
claim(id, requestKey) {
|
|
1172
|
+
return this.client.post(`${resource("programs", id)}/claim`, { request_key: requestKey });
|
|
1173
|
+
}
|
|
1174
|
+
job(id) {
|
|
1175
|
+
return this.client.get(resource("jobs", id));
|
|
1176
|
+
}
|
|
1177
|
+
/** A dispatch grant is single-use. Never retry a provider call after uncertainty. */
|
|
1178
|
+
dispatch(id, input) {
|
|
1179
|
+
return this.client.post(`${resource("jobs", id)}/dispatch`, input);
|
|
1180
|
+
}
|
|
1181
|
+
complete(id, input) {
|
|
1182
|
+
return this.client.post(`${resource("jobs", id)}/complete`, input);
|
|
1183
|
+
}
|
|
1184
|
+
uncertain(id, requestDigest, reason) {
|
|
1185
|
+
return this.client.post(`${resource("jobs", id)}/uncertain`, {
|
|
1186
|
+
request_digest: requestDigest,
|
|
1187
|
+
reason
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
lessons(id, params = {}) {
|
|
1191
|
+
return this.client.get(`${resource("programs", id)}/lessons`, params);
|
|
1192
|
+
}
|
|
1193
|
+
reviewQueue(id, params = {}) {
|
|
1194
|
+
return this.client.get(`${resource("programs", id)}/review-queue`, params);
|
|
1195
|
+
}
|
|
1196
|
+
lesson(id) {
|
|
1197
|
+
return this.client.get(resource("lessons", id));
|
|
1198
|
+
}
|
|
1199
|
+
review(id, input) {
|
|
1200
|
+
return this.client.post(`${resource("lessons", id)}/reviews`, input);
|
|
1201
|
+
}
|
|
1202
|
+
revise(id, input) {
|
|
1203
|
+
return this.client.post(`${resource("lessons", id)}/revisions`, input);
|
|
1204
|
+
}
|
|
1205
|
+
reviews(id, params = {}) {
|
|
1206
|
+
return this.client.get(`${resource("lessons", id)}/reviews`, params);
|
|
1207
|
+
}
|
|
1208
|
+
};
|
|
1209
|
+
|
|
1058
1210
|
// src/client.ts
|
|
1059
1211
|
var MemoryClient = class {
|
|
1060
1212
|
constructor(config = {}) {
|
|
@@ -1075,11 +1227,12 @@ var MemoryClient = class {
|
|
|
1075
1227
|
this.consolidation = new ConsolidationResource(this);
|
|
1076
1228
|
this.memoryTools = new MemoryToolsResource(this);
|
|
1077
1229
|
this.proofloop = new ProofLoopResource(this);
|
|
1230
|
+
this.experiences = new ExperienceWorkflowResource(this);
|
|
1078
1231
|
}
|
|
1079
1232
|
getHeaders() {
|
|
1080
1233
|
const headers = {
|
|
1081
1234
|
"Content-Type": "application/json",
|
|
1082
|
-
"User-Agent": "hebbrix-typescript/2.
|
|
1235
|
+
"User-Agent": "hebbrix-typescript/2.5.0-rc.1"
|
|
1083
1236
|
};
|
|
1084
1237
|
if (this.apiKey) {
|
|
1085
1238
|
headers["Authorization"] = `Bearer ${this.apiKey}`;
|
|
@@ -1216,6 +1369,7 @@ var MemoryClient = class {
|
|
|
1216
1369
|
ConsolidationResource,
|
|
1217
1370
|
CorrectionsResource,
|
|
1218
1371
|
EntitlementError,
|
|
1372
|
+
ExperienceWorkflowResource,
|
|
1219
1373
|
HebbrixError,
|
|
1220
1374
|
IndexingAbortedError,
|
|
1221
1375
|
IndexingTerminalError,
|
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,64 @@ 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
|
+
/** Revalidate a hypothesis against current source evidence; never permission to act. */
|
|
740
|
+
async assessExperience(params) {
|
|
741
|
+
return this.client.post("/v1/learning/experiences/assess", params);
|
|
742
|
+
}
|
|
743
|
+
/** Revalidate selected stored hypotheses; never grants execution permission. */
|
|
744
|
+
async experienceContext(params) {
|
|
745
|
+
return this.client.post("/v1/learning/experiences/context", params);
|
|
746
|
+
}
|
|
747
|
+
async verifierEvidence(verifierId, decisionId) {
|
|
748
|
+
return this.client.get(
|
|
749
|
+
`/v1/learning/verifiers/${encodeURIComponent(verifierId)}/decisions/${encodeURIComponent(decisionId)}`
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
/** Deliver using the dedicated source credential, after checking execution independently. */
|
|
753
|
+
async deliverVerifiedOutcomes(verifierId, delivery) {
|
|
754
|
+
return this.client.post(
|
|
755
|
+
`/v1/learning/verifiers/${encodeURIComponent(verifierId)}/events`,
|
|
756
|
+
delivery
|
|
757
|
+
);
|
|
758
|
+
}
|
|
681
759
|
async defineMetric(params) {
|
|
682
760
|
return this.client.post("/v1/learning/metrics", params);
|
|
683
761
|
}
|
|
@@ -1004,6 +1082,79 @@ var MemoryToolsResource = class extends BaseResource {
|
|
|
1004
1082
|
}
|
|
1005
1083
|
};
|
|
1006
1084
|
|
|
1085
|
+
// src/experience-workflow.ts
|
|
1086
|
+
var root = "/v1/learning/experiences";
|
|
1087
|
+
var resource = (kind, id) => `${root}/${kind}/${encodeURIComponent(id)}`;
|
|
1088
|
+
var ExperienceWorkflowResource = class {
|
|
1089
|
+
constructor(client) {
|
|
1090
|
+
this.client = client;
|
|
1091
|
+
}
|
|
1092
|
+
definePermission(id, policy) {
|
|
1093
|
+
return this.client.post(`${resource("programs", id)}/permission-policies`, policy);
|
|
1094
|
+
}
|
|
1095
|
+
activatePermission(id, activation) {
|
|
1096
|
+
return this.client.post(`${resource("programs", id)}/permission-activation`, activation);
|
|
1097
|
+
}
|
|
1098
|
+
permissionState(id) {
|
|
1099
|
+
return this.client.get(`${resource("programs", id)}/permission-state`);
|
|
1100
|
+
}
|
|
1101
|
+
issuePermit(id, input) {
|
|
1102
|
+
return this.client.post(`${resource("programs", id)}/permits`, input);
|
|
1103
|
+
}
|
|
1104
|
+
dispatchPermit(id, invocationDigest) {
|
|
1105
|
+
return this.client.post(`${resource("permits", id)}/dispatch`, { invocation_digest: invocationDigest });
|
|
1106
|
+
}
|
|
1107
|
+
permit(id) {
|
|
1108
|
+
return this.client.get(resource("permits", id));
|
|
1109
|
+
}
|
|
1110
|
+
register(input) {
|
|
1111
|
+
return this.client.post(`${root}/programs`, input);
|
|
1112
|
+
}
|
|
1113
|
+
program(id) {
|
|
1114
|
+
return this.client.get(resource("programs", id));
|
|
1115
|
+
}
|
|
1116
|
+
stop(id) {
|
|
1117
|
+
return this.client.post(`${resource("programs", id)}/stop`);
|
|
1118
|
+
}
|
|
1119
|
+
claim(id, requestKey) {
|
|
1120
|
+
return this.client.post(`${resource("programs", id)}/claim`, { request_key: requestKey });
|
|
1121
|
+
}
|
|
1122
|
+
job(id) {
|
|
1123
|
+
return this.client.get(resource("jobs", id));
|
|
1124
|
+
}
|
|
1125
|
+
/** A dispatch grant is single-use. Never retry a provider call after uncertainty. */
|
|
1126
|
+
dispatch(id, input) {
|
|
1127
|
+
return this.client.post(`${resource("jobs", id)}/dispatch`, input);
|
|
1128
|
+
}
|
|
1129
|
+
complete(id, input) {
|
|
1130
|
+
return this.client.post(`${resource("jobs", id)}/complete`, input);
|
|
1131
|
+
}
|
|
1132
|
+
uncertain(id, requestDigest, reason) {
|
|
1133
|
+
return this.client.post(`${resource("jobs", id)}/uncertain`, {
|
|
1134
|
+
request_digest: requestDigest,
|
|
1135
|
+
reason
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1138
|
+
lessons(id, params = {}) {
|
|
1139
|
+
return this.client.get(`${resource("programs", id)}/lessons`, params);
|
|
1140
|
+
}
|
|
1141
|
+
reviewQueue(id, params = {}) {
|
|
1142
|
+
return this.client.get(`${resource("programs", id)}/review-queue`, params);
|
|
1143
|
+
}
|
|
1144
|
+
lesson(id) {
|
|
1145
|
+
return this.client.get(resource("lessons", id));
|
|
1146
|
+
}
|
|
1147
|
+
review(id, input) {
|
|
1148
|
+
return this.client.post(`${resource("lessons", id)}/reviews`, input);
|
|
1149
|
+
}
|
|
1150
|
+
revise(id, input) {
|
|
1151
|
+
return this.client.post(`${resource("lessons", id)}/revisions`, input);
|
|
1152
|
+
}
|
|
1153
|
+
reviews(id, params = {}) {
|
|
1154
|
+
return this.client.get(`${resource("lessons", id)}/reviews`, params);
|
|
1155
|
+
}
|
|
1156
|
+
};
|
|
1157
|
+
|
|
1007
1158
|
// src/client.ts
|
|
1008
1159
|
var MemoryClient = class {
|
|
1009
1160
|
constructor(config = {}) {
|
|
@@ -1024,11 +1175,12 @@ var MemoryClient = class {
|
|
|
1024
1175
|
this.consolidation = new ConsolidationResource(this);
|
|
1025
1176
|
this.memoryTools = new MemoryToolsResource(this);
|
|
1026
1177
|
this.proofloop = new ProofLoopResource(this);
|
|
1178
|
+
this.experiences = new ExperienceWorkflowResource(this);
|
|
1027
1179
|
}
|
|
1028
1180
|
getHeaders() {
|
|
1029
1181
|
const headers = {
|
|
1030
1182
|
"Content-Type": "application/json",
|
|
1031
|
-
"User-Agent": "hebbrix-typescript/2.
|
|
1183
|
+
"User-Agent": "hebbrix-typescript/2.5.0-rc.1"
|
|
1032
1184
|
};
|
|
1033
1185
|
if (this.apiKey) {
|
|
1034
1186
|
headers["Authorization"] = `Bearer ${this.apiKey}`;
|
|
@@ -1164,6 +1316,7 @@ export {
|
|
|
1164
1316
|
ConsolidationResource,
|
|
1165
1317
|
CorrectionsResource,
|
|
1166
1318
|
EntitlementError,
|
|
1319
|
+
ExperienceWorkflowResource,
|
|
1167
1320
|
HebbrixError,
|
|
1168
1321
|
IndexingAbortedError,
|
|
1169
1322
|
IndexingTerminalError,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hebbrix",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0-rc.1",
|
|
4
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",
|
|
@@ -55,7 +55,8 @@
|
|
|
55
55
|
},
|
|
56
56
|
"homepage": "https://docs.hebbrix.com",
|
|
57
57
|
"publishConfig": {
|
|
58
|
-
"access": "public"
|
|
58
|
+
"access": "public",
|
|
59
|
+
"tag": "next"
|
|
59
60
|
},
|
|
60
61
|
"devDependencies": {
|
|
61
62
|
"@types/node": "^20.10.0",
|