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.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,364 @@ 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
+ }
748
+ // ========================================================================
749
+ // Agents (Runtime v2)
750
+ // ========================================================================
751
+ async createAgent(params) {
752
+ const body = {
753
+ name: params.name,
754
+ model: params.model ?? "gpt-4o-mini",
755
+ provider: params.provider ?? "openai"
756
+ };
757
+ if (params.agent_id) body.agent_id = params.agent_id;
758
+ if (params.description) body.description = params.description;
759
+ if (params.instructions) body.instructions = params.instructions;
760
+ if (params.capabilities) body.capabilities = params.capabilities;
761
+ if (params.memory_scope) body.memory_scope = params.memory_scope;
762
+ if (params.policy_profile) body.policy_profile = params.policy_profile;
763
+ if (params.config) body.config = params.config;
764
+ return this._request("POST", "/v1/agents", { body });
765
+ }
766
+ async getAgent(agentId) {
767
+ return this._request("GET", `/v1/agents/${agentId}`);
768
+ }
769
+ async listAgents(opts) {
770
+ const params = {
771
+ limit: opts?.limit ?? 100,
772
+ offset: opts?.offset ?? 0
773
+ };
774
+ if (opts?.status) params.status = opts.status;
775
+ return this._request("GET", "/v1/agents", { params });
776
+ }
777
+ async updateAgent(agentId, updates) {
778
+ return this._request("PATCH", `/v1/agents/${agentId}`, { body: updates });
779
+ }
780
+ async deleteAgent(agentId) {
781
+ return this._request("DELETE", `/v1/agents/${agentId}`);
782
+ }
783
+ // ========================================================================
784
+ // Missions (Runtime v2)
785
+ // ========================================================================
786
+ async createMission(params) {
787
+ const body = {
788
+ agent_id: params.agent_id,
789
+ goal: params.goal
790
+ };
791
+ if (params.constraints !== void 0) body.constraints = params.constraints;
792
+ if (params.success_criteria !== void 0) body.success_criteria = params.success_criteria;
793
+ if (params.allowed_capabilities !== void 0) body.allowed_capabilities = params.allowed_capabilities;
794
+ if (params.escalation_rules !== void 0) body.escalation_rules = params.escalation_rules;
795
+ if (params.stop_conditions !== void 0) body.stop_conditions = params.stop_conditions;
796
+ if (params.config !== void 0) body.config = params.config;
797
+ return this._request("POST", "/v1/missions", { body });
798
+ }
799
+ async getMission(missionId) {
800
+ return this._request("GET", `/v1/missions/${missionId}`);
801
+ }
802
+ async listMissions(opts) {
803
+ const params = {
804
+ limit: opts?.limit ?? 100,
805
+ offset: opts?.offset ?? 0
806
+ };
807
+ if (opts?.agent_id) params.agent_id = opts.agent_id;
808
+ if (opts?.status) params.status = opts.status;
809
+ return this._request("GET", "/v1/missions", { params });
810
+ }
811
+ async updateMission(missionId, updates) {
812
+ return this._request("PATCH", `/v1/missions/${missionId}`, { body: updates });
813
+ }
814
+ async deleteMission(missionId) {
815
+ return this._request("DELETE", `/v1/missions/${missionId}`);
816
+ }
817
+ async pauseMission(missionId) {
818
+ return this._request("POST", `/v1/missions/${missionId}/pause`);
819
+ }
820
+ async resumeMission(missionId) {
821
+ return this._request("POST", `/v1/missions/${missionId}/resume`);
822
+ }
823
+ async cancelMission(missionId) {
824
+ return this._request("POST", `/v1/missions/${missionId}/cancel`);
825
+ }
826
+ // ========================================================================
827
+ // Capabilities (Runtime v2)
828
+ // ========================================================================
829
+ async createCapability(params) {
830
+ const body = { name: params.name };
831
+ if (params.capability_id !== void 0) body.capability_id = params.capability_id;
832
+ if (params.description !== void 0) body.description = params.description;
833
+ if (params.tools !== void 0) body.tools = params.tools;
834
+ if (params.risk_levels !== void 0) body.risk_levels = params.risk_levels;
835
+ if (params.approval_requirements !== void 0) body.approval_requirements = params.approval_requirements;
836
+ if (params.memory_behavior !== void 0) body.memory_behavior = params.memory_behavior;
837
+ if (params.eval_rules !== void 0) body.eval_rules = params.eval_rules;
838
+ if (params.config !== void 0) body.config = params.config;
839
+ return this._request("POST", "/v1/capabilities", { body });
840
+ }
841
+ async getCapability(capabilityId) {
842
+ return this._request("GET", `/v1/capabilities/${capabilityId}`);
843
+ }
844
+ async listCapabilities(opts) {
845
+ const params = {
846
+ limit: opts?.limit ?? 100,
847
+ offset: opts?.offset ?? 0
848
+ };
849
+ if (opts?.status) params.status = opts.status;
850
+ return this._request("GET", "/v1/capabilities", { params });
851
+ }
852
+ async updateCapability(capabilityId, updates) {
853
+ return this._request("PATCH", `/v1/capabilities/${capabilityId}`, { body: updates });
854
+ }
855
+ async deleteCapability(capabilityId) {
856
+ return this._request("DELETE", `/v1/capabilities/${capabilityId}`);
857
+ }
858
+ // ========================================================================
859
+ // Checkpoints (Runtime v2)
860
+ // ========================================================================
861
+ async createCheckpoint(missionId, opts) {
862
+ const body = {};
863
+ if (opts?.label !== void 0) body.label = opts.label;
864
+ if (opts?.metadata !== void 0) body.metadata = opts.metadata;
865
+ return this._request("POST", `/v1/missions/${missionId}/checkpoints`, { body });
866
+ }
867
+ async getCheckpoint(checkpointId) {
868
+ return this._request("GET", `/v1/checkpoints/${checkpointId}`);
869
+ }
870
+ async listCheckpoints(missionId, opts) {
871
+ const params = {
872
+ limit: opts?.limit ?? 100,
873
+ offset: opts?.offset ?? 0
874
+ };
875
+ return this._request("GET", `/v1/missions/${missionId}/checkpoints`, { params });
876
+ }
877
+ async rollbackToCheckpoint(missionId, checkpointId, opts) {
878
+ const body = { checkpoint_id: checkpointId };
879
+ if (opts?.reason !== void 0) body.reason = opts.reason;
880
+ return this._request("POST", `/v1/missions/${missionId}/rollback`, { body });
881
+ }
882
+ // ========================================================================
883
+ // Interventions (Runtime v2)
884
+ // ========================================================================
885
+ async createIntervention(params) {
886
+ const body = {
887
+ intervention_type: params.intervention_type
888
+ };
889
+ if (params.mission_id !== void 0) body.mission_id = params.mission_id;
890
+ if (params.action_id !== void 0) body.action_id = params.action_id;
891
+ if (params.agent_id !== void 0) body.agent_id = params.agent_id;
892
+ if (params.rationale !== void 0) body.rationale = params.rationale;
893
+ if (params.metadata !== void 0) body.metadata = params.metadata;
894
+ return this._request("POST", "/v1/interventions", { body });
895
+ }
896
+ async getIntervention(interventionId) {
897
+ return this._request("GET", `/v1/interventions/${interventionId}`);
898
+ }
899
+ async listInterventions(opts) {
900
+ const params = {
901
+ limit: opts?.limit ?? 100,
902
+ offset: opts?.offset ?? 0
903
+ };
904
+ if (opts?.mission_id) params.mission_id = opts.mission_id;
905
+ if (opts?.agent_id) params.agent_id = opts.agent_id;
906
+ if (opts?.intervention_type) params.type = opts.intervention_type;
907
+ return this._request("GET", "/v1/interventions", { params });
908
+ }
549
909
  };
550
910
  // Annotate the CommonJS export names for ESM import in node:
551
911
  0 && (module.exports = {