novyx 2.10.0 → 2.11.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/dist/index.d.mts CHANGED
@@ -30,6 +30,8 @@ interface NovyxConfig {
30
30
  apiUrl?: string;
31
31
  timeout?: number;
32
32
  agentId?: string;
33
+ controlUrl?: string;
34
+ controlApiKey?: string;
33
35
  }
34
36
  interface Edge {
35
37
  edge_id: string;
@@ -217,6 +219,88 @@ interface CortexInsightsResult {
217
219
  insights: CortexInsight[];
218
220
  total: number;
219
221
  }
222
+ interface EvalScoreBreakdown {
223
+ recall_consistency: number;
224
+ drift_score: number;
225
+ conflict_score: number;
226
+ staleness_score: number;
227
+ }
228
+ interface EvalRunResult {
229
+ eval_id: string;
230
+ health_score: number;
231
+ passed?: boolean;
232
+ breakdown: EvalScoreBreakdown;
233
+ total_memories: number;
234
+ created_at: string;
235
+ }
236
+ interface EvalHistoryResult {
237
+ entries: EvalRunResult[];
238
+ total_count: number;
239
+ has_more: boolean;
240
+ }
241
+ interface EvalBaseline {
242
+ baseline_id: string;
243
+ query: string;
244
+ expected_observation: string;
245
+ created_at: string;
246
+ }
247
+ interface EvalBaselineListResult {
248
+ baselines: EvalBaseline[];
249
+ total_count: number;
250
+ }
251
+ interface MemoryDraft {
252
+ draft_id: string;
253
+ observation: string;
254
+ context?: string;
255
+ tags: string[];
256
+ importance: number;
257
+ status: string;
258
+ created_at: string;
259
+ parent_id?: string;
260
+ branch_name?: string;
261
+ }
262
+ interface DraftDiffResult {
263
+ draft_id: string;
264
+ changes: Record<string, any>;
265
+ }
266
+ interface ContextSpace {
267
+ space_id: string;
268
+ name: string;
269
+ description?: string;
270
+ owner_tenant_id: string;
271
+ allowed_agent_ids: string[];
272
+ allowed_tenant_ids: string[];
273
+ tags: string[];
274
+ created_at: string;
275
+ }
276
+ interface Approval {
277
+ approval_id: string;
278
+ action: string;
279
+ connector?: string;
280
+ agent_id?: string;
281
+ status: string;
282
+ submitted_at?: string;
283
+ risk_score?: number;
284
+ }
285
+ interface ApprovalListResult {
286
+ approvals: Approval[];
287
+ total: number;
288
+ }
289
+ interface PolicyInfo {
290
+ name: string;
291
+ enabled: boolean;
292
+ description: string;
293
+ }
294
+ interface PoliciesResult {
295
+ policies: PolicyInfo[];
296
+ mode: string;
297
+ connectors: string[];
298
+ approval_modes: string[];
299
+ }
300
+ interface StreamStatusResult {
301
+ connections: number;
302
+ event_bus: Record<string, any>;
303
+ }
220
304
 
221
305
  declare class NovyxSession {
222
306
  private client;
@@ -266,6 +350,8 @@ declare class Novyx {
266
350
  private apiUrl;
267
351
  private timeout;
268
352
  private agentId?;
353
+ private controlUrl?;
354
+ private controlApiKey?;
269
355
  constructor(config: NovyxConfig);
270
356
  private _validateKey;
271
357
  private _request;
@@ -407,6 +493,89 @@ declare class Novyx {
407
493
  limit?: number;
408
494
  offset?: number;
409
495
  }): Promise<CortexInsightsResult>;
496
+ draftMemory(observation: string, opts?: {
497
+ tags?: string[];
498
+ context?: string;
499
+ importance?: number;
500
+ confidence?: number;
501
+ agent_id?: string;
502
+ space_id?: string;
503
+ branch_name?: string;
504
+ }): Promise<MemoryDraft>;
505
+ memoryDrafts(opts?: {
506
+ status?: string;
507
+ branch_name?: string;
508
+ limit?: number;
509
+ offset?: number;
510
+ }): Promise<{
511
+ drafts: MemoryDraft[];
512
+ total: number;
513
+ }>;
514
+ memoryDraft(draftId: string): Promise<MemoryDraft>;
515
+ draftDiff(draftId: string): Promise<DraftDiffResult>;
516
+ mergeDraft(draftId: string): Promise<Record<string, any>>;
517
+ rejectDraft(draftId: string, reason?: string): Promise<Record<string, any>>;
518
+ memoryBranches(): Promise<{
519
+ branches: string[];
520
+ }>;
521
+ mergeBranch(branchName: string): Promise<Record<string, any>>;
522
+ rejectBranch(branchName: string, reason?: string): Promise<Record<string, any>>;
523
+ createSpace(name: string, opts?: {
524
+ description?: string;
525
+ allowed_agent_ids?: string[];
526
+ allowed_tenant_ids?: string[];
527
+ tags?: string[];
528
+ }): Promise<ContextSpace>;
529
+ listSpaces(opts?: {
530
+ limit?: number;
531
+ offset?: number;
532
+ }): Promise<{
533
+ spaces: ContextSpace[];
534
+ total: number;
535
+ }>;
536
+ getSpace(spaceId: string): Promise<ContextSpace>;
537
+ updateSpace(spaceId: string, updates: Record<string, any>): Promise<ContextSpace>;
538
+ deleteSpace(spaceId: string): Promise<Record<string, any>>;
539
+ spaceMemories(spaceId: string, opts?: {
540
+ limit?: number;
541
+ offset?: number;
542
+ }): Promise<Memory[]>;
543
+ evalRun(opts?: {
544
+ min_score?: number;
545
+ }): Promise<EvalRunResult>;
546
+ evalGate(minScore: number): Promise<EvalRunResult>;
547
+ evalHistory(opts?: {
548
+ limit?: number;
549
+ offset?: number;
550
+ }): Promise<EvalHistoryResult>;
551
+ evalDrift(days?: number): Promise<Record<string, any>>;
552
+ evalBaselineCreate(query: string, expectedObservation: string): Promise<EvalBaseline>;
553
+ evalBaselines(): Promise<EvalBaselineListResult>;
554
+ evalBaselineDelete(baselineId: string): Promise<Record<string, any>>;
555
+ listApprovals(opts?: {
556
+ limit?: number;
557
+ status_filter?: string;
558
+ }): Promise<ApprovalListResult>;
559
+ approveAction(approvalId: string, opts?: {
560
+ decision?: string;
561
+ reason?: string;
562
+ approver_id?: string;
563
+ }): Promise<Record<string, any>>;
564
+ listPolicies(): Promise<PoliciesResult>;
565
+ explainAction(actionId: string): Promise<Record<string, any>>;
566
+ streamStatus(): Promise<StreamStatusResult>;
567
+ memoryHealth(): Promise<Record<string, any>>;
568
+ private _controlRequest;
569
+ /** Submit an action to Novyx Control for governed execution. */
570
+ actionSubmit(connector: string, operation: string, payload: Record<string, any>): Promise<any>;
571
+ /** Get the status of a Control action. */
572
+ actionStatus(actionId: string): Promise<any>;
573
+ /** List recent Control actions. */
574
+ actionList(opts?: {
575
+ status?: string;
576
+ }): Promise<any>;
577
+ /** Check the current Control policy profile. */
578
+ policyCheck(): Promise<any>;
410
579
  }
411
580
 
412
581
  declare class NovyxError extends Error {
package/dist/index.d.ts CHANGED
@@ -30,6 +30,8 @@ interface NovyxConfig {
30
30
  apiUrl?: string;
31
31
  timeout?: number;
32
32
  agentId?: string;
33
+ controlUrl?: string;
34
+ controlApiKey?: string;
33
35
  }
34
36
  interface Edge {
35
37
  edge_id: string;
@@ -217,6 +219,88 @@ interface CortexInsightsResult {
217
219
  insights: CortexInsight[];
218
220
  total: number;
219
221
  }
222
+ interface EvalScoreBreakdown {
223
+ recall_consistency: number;
224
+ drift_score: number;
225
+ conflict_score: number;
226
+ staleness_score: number;
227
+ }
228
+ interface EvalRunResult {
229
+ eval_id: string;
230
+ health_score: number;
231
+ passed?: boolean;
232
+ breakdown: EvalScoreBreakdown;
233
+ total_memories: number;
234
+ created_at: string;
235
+ }
236
+ interface EvalHistoryResult {
237
+ entries: EvalRunResult[];
238
+ total_count: number;
239
+ has_more: boolean;
240
+ }
241
+ interface EvalBaseline {
242
+ baseline_id: string;
243
+ query: string;
244
+ expected_observation: string;
245
+ created_at: string;
246
+ }
247
+ interface EvalBaselineListResult {
248
+ baselines: EvalBaseline[];
249
+ total_count: number;
250
+ }
251
+ interface MemoryDraft {
252
+ draft_id: string;
253
+ observation: string;
254
+ context?: string;
255
+ tags: string[];
256
+ importance: number;
257
+ status: string;
258
+ created_at: string;
259
+ parent_id?: string;
260
+ branch_name?: string;
261
+ }
262
+ interface DraftDiffResult {
263
+ draft_id: string;
264
+ changes: Record<string, any>;
265
+ }
266
+ interface ContextSpace {
267
+ space_id: string;
268
+ name: string;
269
+ description?: string;
270
+ owner_tenant_id: string;
271
+ allowed_agent_ids: string[];
272
+ allowed_tenant_ids: string[];
273
+ tags: string[];
274
+ created_at: string;
275
+ }
276
+ interface Approval {
277
+ approval_id: string;
278
+ action: string;
279
+ connector?: string;
280
+ agent_id?: string;
281
+ status: string;
282
+ submitted_at?: string;
283
+ risk_score?: number;
284
+ }
285
+ interface ApprovalListResult {
286
+ approvals: Approval[];
287
+ total: number;
288
+ }
289
+ interface PolicyInfo {
290
+ name: string;
291
+ enabled: boolean;
292
+ description: string;
293
+ }
294
+ interface PoliciesResult {
295
+ policies: PolicyInfo[];
296
+ mode: string;
297
+ connectors: string[];
298
+ approval_modes: string[];
299
+ }
300
+ interface StreamStatusResult {
301
+ connections: number;
302
+ event_bus: Record<string, any>;
303
+ }
220
304
 
221
305
  declare class NovyxSession {
222
306
  private client;
@@ -266,6 +350,8 @@ declare class Novyx {
266
350
  private apiUrl;
267
351
  private timeout;
268
352
  private agentId?;
353
+ private controlUrl?;
354
+ private controlApiKey?;
269
355
  constructor(config: NovyxConfig);
270
356
  private _validateKey;
271
357
  private _request;
@@ -407,6 +493,89 @@ declare class Novyx {
407
493
  limit?: number;
408
494
  offset?: number;
409
495
  }): Promise<CortexInsightsResult>;
496
+ draftMemory(observation: string, opts?: {
497
+ tags?: string[];
498
+ context?: string;
499
+ importance?: number;
500
+ confidence?: number;
501
+ agent_id?: string;
502
+ space_id?: string;
503
+ branch_name?: string;
504
+ }): Promise<MemoryDraft>;
505
+ memoryDrafts(opts?: {
506
+ status?: string;
507
+ branch_name?: string;
508
+ limit?: number;
509
+ offset?: number;
510
+ }): Promise<{
511
+ drafts: MemoryDraft[];
512
+ total: number;
513
+ }>;
514
+ memoryDraft(draftId: string): Promise<MemoryDraft>;
515
+ draftDiff(draftId: string): Promise<DraftDiffResult>;
516
+ mergeDraft(draftId: string): Promise<Record<string, any>>;
517
+ rejectDraft(draftId: string, reason?: string): Promise<Record<string, any>>;
518
+ memoryBranches(): Promise<{
519
+ branches: string[];
520
+ }>;
521
+ mergeBranch(branchName: string): Promise<Record<string, any>>;
522
+ rejectBranch(branchName: string, reason?: string): Promise<Record<string, any>>;
523
+ createSpace(name: string, opts?: {
524
+ description?: string;
525
+ allowed_agent_ids?: string[];
526
+ allowed_tenant_ids?: string[];
527
+ tags?: string[];
528
+ }): Promise<ContextSpace>;
529
+ listSpaces(opts?: {
530
+ limit?: number;
531
+ offset?: number;
532
+ }): Promise<{
533
+ spaces: ContextSpace[];
534
+ total: number;
535
+ }>;
536
+ getSpace(spaceId: string): Promise<ContextSpace>;
537
+ updateSpace(spaceId: string, updates: Record<string, any>): Promise<ContextSpace>;
538
+ deleteSpace(spaceId: string): Promise<Record<string, any>>;
539
+ spaceMemories(spaceId: string, opts?: {
540
+ limit?: number;
541
+ offset?: number;
542
+ }): Promise<Memory[]>;
543
+ evalRun(opts?: {
544
+ min_score?: number;
545
+ }): Promise<EvalRunResult>;
546
+ evalGate(minScore: number): Promise<EvalRunResult>;
547
+ evalHistory(opts?: {
548
+ limit?: number;
549
+ offset?: number;
550
+ }): Promise<EvalHistoryResult>;
551
+ evalDrift(days?: number): Promise<Record<string, any>>;
552
+ evalBaselineCreate(query: string, expectedObservation: string): Promise<EvalBaseline>;
553
+ evalBaselines(): Promise<EvalBaselineListResult>;
554
+ evalBaselineDelete(baselineId: string): Promise<Record<string, any>>;
555
+ listApprovals(opts?: {
556
+ limit?: number;
557
+ status_filter?: string;
558
+ }): Promise<ApprovalListResult>;
559
+ approveAction(approvalId: string, opts?: {
560
+ decision?: string;
561
+ reason?: string;
562
+ approver_id?: string;
563
+ }): Promise<Record<string, any>>;
564
+ listPolicies(): Promise<PoliciesResult>;
565
+ explainAction(actionId: string): Promise<Record<string, any>>;
566
+ streamStatus(): Promise<StreamStatusResult>;
567
+ memoryHealth(): Promise<Record<string, any>>;
568
+ private _controlRequest;
569
+ /** Submit an action to Novyx Control for governed execution. */
570
+ actionSubmit(connector: string, operation: string, payload: Record<string, any>): Promise<any>;
571
+ /** Get the status of a Control action. */
572
+ actionStatus(actionId: string): Promise<any>;
573
+ /** List recent Control actions. */
574
+ actionList(opts?: {
575
+ status?: string;
576
+ }): Promise<any>;
577
+ /** Check the current Control policy profile. */
578
+ policyCheck(): Promise<any>;
410
579
  }
411
580
 
412
581
  declare class NovyxError extends Error {
package/dist/index.js CHANGED
@@ -109,6 +109,8 @@ var Novyx = class {
109
109
  this.apiUrl = (config.apiUrl ?? "https://novyx-ram-api.fly.dev").replace(/\/+$/, "");
110
110
  this.timeout = config.timeout ?? 30;
111
111
  this.agentId = config.agentId;
112
+ this.controlUrl = config.controlUrl?.replace(/\/+$/, "");
113
+ this.controlApiKey = config.controlApiKey;
112
114
  this._validateKey();
113
115
  }
114
116
  _validateKey() {
@@ -546,6 +548,203 @@ var Novyx = class {
546
548
  params: { limit: opts?.limit ?? 20, offset: opts?.offset ?? 0 }
547
549
  });
548
550
  }
551
+ // ========================================================================
552
+ // Drafts & Branches
553
+ // ========================================================================
554
+ async draftMemory(observation, opts) {
555
+ const body = { observation };
556
+ if (opts?.tags) body.tags = opts.tags;
557
+ if (opts?.context) body.context = opts.context;
558
+ if (opts?.importance !== void 0) body.importance = opts.importance;
559
+ if (opts?.confidence !== void 0) body.confidence = opts.confidence;
560
+ if (opts?.agent_id) body.agent_id = opts.agent_id;
561
+ if (opts?.space_id) body.space_id = opts.space_id;
562
+ if (opts?.branch_name) body.branch_name = opts.branch_name;
563
+ return this._request("POST", "/v1/memory-drafts", { body });
564
+ }
565
+ async memoryDrafts(opts) {
566
+ const params = {
567
+ limit: opts?.limit ?? 50,
568
+ offset: opts?.offset ?? 0
569
+ };
570
+ if (opts?.status) params.status = opts.status;
571
+ if (opts?.branch_name) params.branch_name = opts.branch_name;
572
+ return this._request("GET", "/v1/memory-drafts", { params });
573
+ }
574
+ async memoryDraft(draftId) {
575
+ return this._request("GET", `/v1/memory-drafts/${draftId}`);
576
+ }
577
+ async draftDiff(draftId) {
578
+ return this._request("GET", `/v1/memory-drafts/${draftId}/diff`);
579
+ }
580
+ async mergeDraft(draftId) {
581
+ return this._request("POST", `/v1/memory-drafts/${draftId}/merge`);
582
+ }
583
+ async rejectDraft(draftId, reason) {
584
+ const body = {};
585
+ if (reason) body.reason = reason;
586
+ return this._request("POST", `/v1/memory-drafts/${draftId}/reject`, { body });
587
+ }
588
+ async memoryBranches() {
589
+ return this._request("GET", "/v1/memory-drafts/branches");
590
+ }
591
+ async mergeBranch(branchName) {
592
+ return this._request("POST", `/v1/memory-drafts/branches/${branchName}/merge`);
593
+ }
594
+ async rejectBranch(branchName, reason) {
595
+ const body = {};
596
+ if (reason) body.reason = reason;
597
+ return this._request("POST", `/v1/memory-drafts/branches/${branchName}/reject`, { body });
598
+ }
599
+ // ========================================================================
600
+ // Context Spaces
601
+ // ========================================================================
602
+ async createSpace(name, opts) {
603
+ const body = { name };
604
+ if (opts?.description) body.description = opts.description;
605
+ if (opts?.allowed_agent_ids) body.allowed_agent_ids = opts.allowed_agent_ids;
606
+ if (opts?.allowed_tenant_ids) body.allowed_tenant_ids = opts.allowed_tenant_ids;
607
+ if (opts?.tags) body.tags = opts.tags;
608
+ return this._request("POST", "/v1/context-spaces", { body });
609
+ }
610
+ async listSpaces(opts) {
611
+ return this._request("GET", "/v1/context-spaces", {
612
+ params: { limit: opts?.limit ?? 50, offset: opts?.offset ?? 0 }
613
+ });
614
+ }
615
+ async getSpace(spaceId) {
616
+ return this._request("GET", `/v1/context-spaces/${spaceId}`);
617
+ }
618
+ async updateSpace(spaceId, updates) {
619
+ return this._request("PUT", `/v1/context-spaces/${spaceId}`, { body: updates });
620
+ }
621
+ async deleteSpace(spaceId) {
622
+ return this._request("DELETE", `/v1/context-spaces/${spaceId}`);
623
+ }
624
+ async spaceMemories(spaceId, opts) {
625
+ const result = await this._request("GET", `/v1/context-spaces/${spaceId}/memories`, {
626
+ params: { limit: opts?.limit ?? 100, offset: opts?.offset ?? 0 }
627
+ });
628
+ return result.memories ?? result;
629
+ }
630
+ // ========================================================================
631
+ // Eval
632
+ // ========================================================================
633
+ async evalRun(opts) {
634
+ const body = {};
635
+ if (opts?.min_score !== void 0) body.min_score = opts.min_score;
636
+ return this._request("POST", "/v1/eval/run", { body });
637
+ }
638
+ async evalGate(minScore) {
639
+ return this._request("POST", "/v1/eval/gate", {
640
+ body: { min_score: minScore }
641
+ });
642
+ }
643
+ async evalHistory(opts) {
644
+ return this._request("GET", "/v1/eval/history", {
645
+ params: { limit: opts?.limit ?? 50, offset: opts?.offset ?? 0 }
646
+ });
647
+ }
648
+ async evalDrift(days = 7) {
649
+ return this._request("GET", "/v1/eval/drift", { params: { days } });
650
+ }
651
+ async evalBaselineCreate(query, expectedObservation) {
652
+ return this._request("POST", "/v1/eval/baselines", {
653
+ body: { query, expected_observation: expectedObservation }
654
+ });
655
+ }
656
+ async evalBaselines() {
657
+ return this._request("GET", "/v1/eval/baselines");
658
+ }
659
+ async evalBaselineDelete(baselineId) {
660
+ return this._request("DELETE", `/v1/eval/baselines/${baselineId}`);
661
+ }
662
+ // ========================================================================
663
+ // Approvals
664
+ // ========================================================================
665
+ async listApprovals(opts) {
666
+ const params = { limit: opts?.limit ?? 50 };
667
+ if (opts?.status_filter) params.status_filter = opts.status_filter;
668
+ return this._request("GET", "/v1/approvals", { params });
669
+ }
670
+ async approveAction(approvalId, opts) {
671
+ const params = { decision: opts?.decision ?? "approve" };
672
+ if (opts?.reason) params.reason = opts.reason;
673
+ if (opts?.approver_id) params.approver_id = opts.approver_id;
674
+ return this._request("POST", `/v1/approvals/${approvalId}/decision`, { params });
675
+ }
676
+ async listPolicies() {
677
+ return this._request("GET", "/v1/control/policies");
678
+ }
679
+ // ========================================================================
680
+ // Explain Action
681
+ // ========================================================================
682
+ async explainAction(actionId) {
683
+ return this._request("GET", `/v1/actions/${actionId}/explain`);
684
+ }
685
+ // ========================================================================
686
+ // Streams
687
+ // ========================================================================
688
+ async streamStatus() {
689
+ return this._request("GET", "/v1/streams/status");
690
+ }
691
+ // ========================================================================
692
+ // Memory Health
693
+ // ========================================================================
694
+ async memoryHealth() {
695
+ return this._request("GET", "/v1/memories/stats");
696
+ }
697
+ // =========================================================================
698
+ // Control — Governed agent actions (requires controlUrl)
699
+ // =========================================================================
700
+ async _controlRequest(method, endpoint, opts) {
701
+ if (!this.controlUrl) {
702
+ throw new NovyxError("Control not configured. Pass controlUrl to Novyx().");
703
+ }
704
+ const url = new URL(`${this.controlUrl}${endpoint}`);
705
+ if (opts?.params) {
706
+ for (const [k, v] of Object.entries(opts.params)) {
707
+ if (v !== void 0 && v !== null) url.searchParams.set(k, String(v));
708
+ }
709
+ }
710
+ const headers = {
711
+ "Authorization": `Bearer ${this.controlApiKey || ""}`
712
+ };
713
+ if (opts?.body) headers["Content-Type"] = "application/json";
714
+ const controller = new AbortController();
715
+ const timer = setTimeout(() => controller.abort(), this.timeout * 1e3);
716
+ try {
717
+ const res = await fetch(url.toString(), {
718
+ method,
719
+ headers,
720
+ body: opts?.body ? JSON.stringify(opts.body) : void 0,
721
+ signal: controller.signal
722
+ });
723
+ if (!res.ok) {
724
+ const text = await res.text().catch(() => "");
725
+ throw new NovyxError(`Control API error ${res.status}: ${text}`);
726
+ }
727
+ return await res.json();
728
+ } finally {
729
+ clearTimeout(timer);
730
+ }
731
+ }
732
+ /** Submit an action to Novyx Control for governed execution. */
733
+ async actionSubmit(connector, operation, payload) {
734
+ return this._controlRequest("POST", `/v1/actions/${connector}/${operation}`, { body: payload });
735
+ }
736
+ /** Get the status of a Control action. */
737
+ async actionStatus(actionId) {
738
+ return this._controlRequest("GET", `/v1/actions/${actionId}`);
739
+ }
740
+ /** List recent Control actions. */
741
+ async actionList(opts) {
742
+ return this._controlRequest("GET", "/v1/actions", { params: opts });
743
+ }
744
+ /** Check the current Control policy profile. */
745
+ async policyCheck() {
746
+ return this._controlRequest("GET", "/v1/control/policies");
747
+ }
549
748
  };
550
749
  // Annotate the CommonJS export names for ESM import in node:
551
750
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -76,6 +76,8 @@ var Novyx = class {
76
76
  this.apiUrl = (config.apiUrl ?? "https://novyx-ram-api.fly.dev").replace(/\/+$/, "");
77
77
  this.timeout = config.timeout ?? 30;
78
78
  this.agentId = config.agentId;
79
+ this.controlUrl = config.controlUrl?.replace(/\/+$/, "");
80
+ this.controlApiKey = config.controlApiKey;
79
81
  this._validateKey();
80
82
  }
81
83
  _validateKey() {
@@ -513,6 +515,203 @@ var Novyx = class {
513
515
  params: { limit: opts?.limit ?? 20, offset: opts?.offset ?? 0 }
514
516
  });
515
517
  }
518
+ // ========================================================================
519
+ // Drafts & Branches
520
+ // ========================================================================
521
+ async draftMemory(observation, opts) {
522
+ const body = { observation };
523
+ if (opts?.tags) body.tags = opts.tags;
524
+ if (opts?.context) body.context = opts.context;
525
+ if (opts?.importance !== void 0) body.importance = opts.importance;
526
+ if (opts?.confidence !== void 0) body.confidence = opts.confidence;
527
+ if (opts?.agent_id) body.agent_id = opts.agent_id;
528
+ if (opts?.space_id) body.space_id = opts.space_id;
529
+ if (opts?.branch_name) body.branch_name = opts.branch_name;
530
+ return this._request("POST", "/v1/memory-drafts", { body });
531
+ }
532
+ async memoryDrafts(opts) {
533
+ const params = {
534
+ limit: opts?.limit ?? 50,
535
+ offset: opts?.offset ?? 0
536
+ };
537
+ if (opts?.status) params.status = opts.status;
538
+ if (opts?.branch_name) params.branch_name = opts.branch_name;
539
+ return this._request("GET", "/v1/memory-drafts", { params });
540
+ }
541
+ async memoryDraft(draftId) {
542
+ return this._request("GET", `/v1/memory-drafts/${draftId}`);
543
+ }
544
+ async draftDiff(draftId) {
545
+ return this._request("GET", `/v1/memory-drafts/${draftId}/diff`);
546
+ }
547
+ async mergeDraft(draftId) {
548
+ return this._request("POST", `/v1/memory-drafts/${draftId}/merge`);
549
+ }
550
+ async rejectDraft(draftId, reason) {
551
+ const body = {};
552
+ if (reason) body.reason = reason;
553
+ return this._request("POST", `/v1/memory-drafts/${draftId}/reject`, { body });
554
+ }
555
+ async memoryBranches() {
556
+ return this._request("GET", "/v1/memory-drafts/branches");
557
+ }
558
+ async mergeBranch(branchName) {
559
+ return this._request("POST", `/v1/memory-drafts/branches/${branchName}/merge`);
560
+ }
561
+ async rejectBranch(branchName, reason) {
562
+ const body = {};
563
+ if (reason) body.reason = reason;
564
+ return this._request("POST", `/v1/memory-drafts/branches/${branchName}/reject`, { body });
565
+ }
566
+ // ========================================================================
567
+ // Context Spaces
568
+ // ========================================================================
569
+ async createSpace(name, opts) {
570
+ const body = { name };
571
+ if (opts?.description) body.description = opts.description;
572
+ if (opts?.allowed_agent_ids) body.allowed_agent_ids = opts.allowed_agent_ids;
573
+ if (opts?.allowed_tenant_ids) body.allowed_tenant_ids = opts.allowed_tenant_ids;
574
+ if (opts?.tags) body.tags = opts.tags;
575
+ return this._request("POST", "/v1/context-spaces", { body });
576
+ }
577
+ async listSpaces(opts) {
578
+ return this._request("GET", "/v1/context-spaces", {
579
+ params: { limit: opts?.limit ?? 50, offset: opts?.offset ?? 0 }
580
+ });
581
+ }
582
+ async getSpace(spaceId) {
583
+ return this._request("GET", `/v1/context-spaces/${spaceId}`);
584
+ }
585
+ async updateSpace(spaceId, updates) {
586
+ return this._request("PUT", `/v1/context-spaces/${spaceId}`, { body: updates });
587
+ }
588
+ async deleteSpace(spaceId) {
589
+ return this._request("DELETE", `/v1/context-spaces/${spaceId}`);
590
+ }
591
+ async spaceMemories(spaceId, opts) {
592
+ const result = await this._request("GET", `/v1/context-spaces/${spaceId}/memories`, {
593
+ params: { limit: opts?.limit ?? 100, offset: opts?.offset ?? 0 }
594
+ });
595
+ return result.memories ?? result;
596
+ }
597
+ // ========================================================================
598
+ // Eval
599
+ // ========================================================================
600
+ async evalRun(opts) {
601
+ const body = {};
602
+ if (opts?.min_score !== void 0) body.min_score = opts.min_score;
603
+ return this._request("POST", "/v1/eval/run", { body });
604
+ }
605
+ async evalGate(minScore) {
606
+ return this._request("POST", "/v1/eval/gate", {
607
+ body: { min_score: minScore }
608
+ });
609
+ }
610
+ async evalHistory(opts) {
611
+ return this._request("GET", "/v1/eval/history", {
612
+ params: { limit: opts?.limit ?? 50, offset: opts?.offset ?? 0 }
613
+ });
614
+ }
615
+ async evalDrift(days = 7) {
616
+ return this._request("GET", "/v1/eval/drift", { params: { days } });
617
+ }
618
+ async evalBaselineCreate(query, expectedObservation) {
619
+ return this._request("POST", "/v1/eval/baselines", {
620
+ body: { query, expected_observation: expectedObservation }
621
+ });
622
+ }
623
+ async evalBaselines() {
624
+ return this._request("GET", "/v1/eval/baselines");
625
+ }
626
+ async evalBaselineDelete(baselineId) {
627
+ return this._request("DELETE", `/v1/eval/baselines/${baselineId}`);
628
+ }
629
+ // ========================================================================
630
+ // Approvals
631
+ // ========================================================================
632
+ async listApprovals(opts) {
633
+ const params = { limit: opts?.limit ?? 50 };
634
+ if (opts?.status_filter) params.status_filter = opts.status_filter;
635
+ return this._request("GET", "/v1/approvals", { params });
636
+ }
637
+ async approveAction(approvalId, opts) {
638
+ const params = { decision: opts?.decision ?? "approve" };
639
+ if (opts?.reason) params.reason = opts.reason;
640
+ if (opts?.approver_id) params.approver_id = opts.approver_id;
641
+ return this._request("POST", `/v1/approvals/${approvalId}/decision`, { params });
642
+ }
643
+ async listPolicies() {
644
+ return this._request("GET", "/v1/control/policies");
645
+ }
646
+ // ========================================================================
647
+ // Explain Action
648
+ // ========================================================================
649
+ async explainAction(actionId) {
650
+ return this._request("GET", `/v1/actions/${actionId}/explain`);
651
+ }
652
+ // ========================================================================
653
+ // Streams
654
+ // ========================================================================
655
+ async streamStatus() {
656
+ return this._request("GET", "/v1/streams/status");
657
+ }
658
+ // ========================================================================
659
+ // Memory Health
660
+ // ========================================================================
661
+ async memoryHealth() {
662
+ return this._request("GET", "/v1/memories/stats");
663
+ }
664
+ // =========================================================================
665
+ // Control — Governed agent actions (requires controlUrl)
666
+ // =========================================================================
667
+ async _controlRequest(method, endpoint, opts) {
668
+ if (!this.controlUrl) {
669
+ throw new NovyxError("Control not configured. Pass controlUrl to Novyx().");
670
+ }
671
+ const url = new URL(`${this.controlUrl}${endpoint}`);
672
+ if (opts?.params) {
673
+ for (const [k, v] of Object.entries(opts.params)) {
674
+ if (v !== void 0 && v !== null) url.searchParams.set(k, String(v));
675
+ }
676
+ }
677
+ const headers = {
678
+ "Authorization": `Bearer ${this.controlApiKey || ""}`
679
+ };
680
+ if (opts?.body) headers["Content-Type"] = "application/json";
681
+ const controller = new AbortController();
682
+ const timer = setTimeout(() => controller.abort(), this.timeout * 1e3);
683
+ try {
684
+ const res = await fetch(url.toString(), {
685
+ method,
686
+ headers,
687
+ body: opts?.body ? JSON.stringify(opts.body) : void 0,
688
+ signal: controller.signal
689
+ });
690
+ if (!res.ok) {
691
+ const text = await res.text().catch(() => "");
692
+ throw new NovyxError(`Control API error ${res.status}: ${text}`);
693
+ }
694
+ return await res.json();
695
+ } finally {
696
+ clearTimeout(timer);
697
+ }
698
+ }
699
+ /** Submit an action to Novyx Control for governed execution. */
700
+ async actionSubmit(connector, operation, payload) {
701
+ return this._controlRequest("POST", `/v1/actions/${connector}/${operation}`, { body: payload });
702
+ }
703
+ /** Get the status of a Control action. */
704
+ async actionStatus(actionId) {
705
+ return this._controlRequest("GET", `/v1/actions/${actionId}`);
706
+ }
707
+ /** List recent Control actions. */
708
+ async actionList(opts) {
709
+ return this._controlRequest("GET", "/v1/actions", { params: opts });
710
+ }
711
+ /** Check the current Control policy profile. */
712
+ async policyCheck() {
713
+ return this._controlRequest("GET", "/v1/control/policies");
714
+ }
516
715
  };
517
716
  export {
518
717
  Novyx,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "novyx",
3
- "version": "2.10.0",
3
+ "version": "2.11.0",
4
4
  "description": "Novyx SDK - Persistent memory, rollback, and audit trail for AI agents",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -28,6 +28,7 @@
28
28
  "typescript": "^5.3.0",
29
29
  "vitest": "^1.0.0"
30
30
  },
31
+ "homepage": "https://novyxlabs.com",
31
32
  "license": "MIT",
32
33
  "author": "Novyx Labs"
33
34
  }