novyx 2.10.0 → 2.12.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.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,364 @@ 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
+ }
715
+ // ========================================================================
716
+ // Agents (Runtime v2)
717
+ // ========================================================================
718
+ async createAgent(params) {
719
+ const body = {
720
+ name: params.name,
721
+ model: params.model ?? "gpt-4o-mini",
722
+ provider: params.provider ?? "openai"
723
+ };
724
+ if (params.agent_id) body.agent_id = params.agent_id;
725
+ if (params.description) body.description = params.description;
726
+ if (params.instructions) body.instructions = params.instructions;
727
+ if (params.capabilities) body.capabilities = params.capabilities;
728
+ if (params.memory_scope) body.memory_scope = params.memory_scope;
729
+ if (params.policy_profile) body.policy_profile = params.policy_profile;
730
+ if (params.config) body.config = params.config;
731
+ return this._request("POST", "/v1/agents", { body });
732
+ }
733
+ async getAgent(agentId) {
734
+ return this._request("GET", `/v1/agents/${agentId}`);
735
+ }
736
+ async listAgents(opts) {
737
+ const params = {
738
+ limit: opts?.limit ?? 100,
739
+ offset: opts?.offset ?? 0
740
+ };
741
+ if (opts?.status) params.status = opts.status;
742
+ return this._request("GET", "/v1/agents", { params });
743
+ }
744
+ async updateAgent(agentId, updates) {
745
+ return this._request("PATCH", `/v1/agents/${agentId}`, { body: updates });
746
+ }
747
+ async deleteAgent(agentId) {
748
+ return this._request("DELETE", `/v1/agents/${agentId}`);
749
+ }
750
+ // ========================================================================
751
+ // Missions (Runtime v2)
752
+ // ========================================================================
753
+ async createMission(params) {
754
+ const body = {
755
+ agent_id: params.agent_id,
756
+ goal: params.goal
757
+ };
758
+ if (params.constraints !== void 0) body.constraints = params.constraints;
759
+ if (params.success_criteria !== void 0) body.success_criteria = params.success_criteria;
760
+ if (params.allowed_capabilities !== void 0) body.allowed_capabilities = params.allowed_capabilities;
761
+ if (params.escalation_rules !== void 0) body.escalation_rules = params.escalation_rules;
762
+ if (params.stop_conditions !== void 0) body.stop_conditions = params.stop_conditions;
763
+ if (params.config !== void 0) body.config = params.config;
764
+ return this._request("POST", "/v1/missions", { body });
765
+ }
766
+ async getMission(missionId) {
767
+ return this._request("GET", `/v1/missions/${missionId}`);
768
+ }
769
+ async listMissions(opts) {
770
+ const params = {
771
+ limit: opts?.limit ?? 100,
772
+ offset: opts?.offset ?? 0
773
+ };
774
+ if (opts?.agent_id) params.agent_id = opts.agent_id;
775
+ if (opts?.status) params.status = opts.status;
776
+ return this._request("GET", "/v1/missions", { params });
777
+ }
778
+ async updateMission(missionId, updates) {
779
+ return this._request("PATCH", `/v1/missions/${missionId}`, { body: updates });
780
+ }
781
+ async deleteMission(missionId) {
782
+ return this._request("DELETE", `/v1/missions/${missionId}`);
783
+ }
784
+ async pauseMission(missionId) {
785
+ return this._request("POST", `/v1/missions/${missionId}/pause`);
786
+ }
787
+ async resumeMission(missionId) {
788
+ return this._request("POST", `/v1/missions/${missionId}/resume`);
789
+ }
790
+ async cancelMission(missionId) {
791
+ return this._request("POST", `/v1/missions/${missionId}/cancel`);
792
+ }
793
+ // ========================================================================
794
+ // Capabilities (Runtime v2)
795
+ // ========================================================================
796
+ async createCapability(params) {
797
+ const body = { name: params.name };
798
+ if (params.capability_id !== void 0) body.capability_id = params.capability_id;
799
+ if (params.description !== void 0) body.description = params.description;
800
+ if (params.tools !== void 0) body.tools = params.tools;
801
+ if (params.risk_levels !== void 0) body.risk_levels = params.risk_levels;
802
+ if (params.approval_requirements !== void 0) body.approval_requirements = params.approval_requirements;
803
+ if (params.memory_behavior !== void 0) body.memory_behavior = params.memory_behavior;
804
+ if (params.eval_rules !== void 0) body.eval_rules = params.eval_rules;
805
+ if (params.config !== void 0) body.config = params.config;
806
+ return this._request("POST", "/v1/capabilities", { body });
807
+ }
808
+ async getCapability(capabilityId) {
809
+ return this._request("GET", `/v1/capabilities/${capabilityId}`);
810
+ }
811
+ async listCapabilities(opts) {
812
+ const params = {
813
+ limit: opts?.limit ?? 100,
814
+ offset: opts?.offset ?? 0
815
+ };
816
+ if (opts?.status) params.status = opts.status;
817
+ return this._request("GET", "/v1/capabilities", { params });
818
+ }
819
+ async updateCapability(capabilityId, updates) {
820
+ return this._request("PATCH", `/v1/capabilities/${capabilityId}`, { body: updates });
821
+ }
822
+ async deleteCapability(capabilityId) {
823
+ return this._request("DELETE", `/v1/capabilities/${capabilityId}`);
824
+ }
825
+ // ========================================================================
826
+ // Checkpoints (Runtime v2)
827
+ // ========================================================================
828
+ async createCheckpoint(missionId, opts) {
829
+ const body = {};
830
+ if (opts?.label !== void 0) body.label = opts.label;
831
+ if (opts?.metadata !== void 0) body.metadata = opts.metadata;
832
+ return this._request("POST", `/v1/missions/${missionId}/checkpoints`, { body });
833
+ }
834
+ async getCheckpoint(checkpointId) {
835
+ return this._request("GET", `/v1/checkpoints/${checkpointId}`);
836
+ }
837
+ async listCheckpoints(missionId, opts) {
838
+ const params = {
839
+ limit: opts?.limit ?? 100,
840
+ offset: opts?.offset ?? 0
841
+ };
842
+ return this._request("GET", `/v1/missions/${missionId}/checkpoints`, { params });
843
+ }
844
+ async rollbackToCheckpoint(missionId, checkpointId, opts) {
845
+ const body = { checkpoint_id: checkpointId };
846
+ if (opts?.reason !== void 0) body.reason = opts.reason;
847
+ return this._request("POST", `/v1/missions/${missionId}/rollback`, { body });
848
+ }
849
+ // ========================================================================
850
+ // Interventions (Runtime v2)
851
+ // ========================================================================
852
+ async createIntervention(params) {
853
+ const body = {
854
+ intervention_type: params.intervention_type
855
+ };
856
+ if (params.mission_id !== void 0) body.mission_id = params.mission_id;
857
+ if (params.action_id !== void 0) body.action_id = params.action_id;
858
+ if (params.agent_id !== void 0) body.agent_id = params.agent_id;
859
+ if (params.rationale !== void 0) body.rationale = params.rationale;
860
+ if (params.metadata !== void 0) body.metadata = params.metadata;
861
+ return this._request("POST", "/v1/interventions", { body });
862
+ }
863
+ async getIntervention(interventionId) {
864
+ return this._request("GET", `/v1/interventions/${interventionId}`);
865
+ }
866
+ async listInterventions(opts) {
867
+ const params = {
868
+ limit: opts?.limit ?? 100,
869
+ offset: opts?.offset ?? 0
870
+ };
871
+ if (opts?.mission_id) params.mission_id = opts.mission_id;
872
+ if (opts?.agent_id) params.agent_id = opts.agent_id;
873
+ if (opts?.intervention_type) params.type = opts.intervention_type;
874
+ return this._request("GET", "/v1/interventions", { params });
875
+ }
516
876
  };
517
877
  export {
518
878
  Novyx,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "novyx",
3
- "version": "2.10.0",
3
+ "version": "2.12.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
  }