novyx 2.12.0 → 3.2.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 +114 -3
- package/dist/index.d.ts +114 -3
- package/dist/index.js +161 -4
- package/dist/index.mjs +161 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -623,13 +623,124 @@ declare class Novyx {
|
|
|
623
623
|
reason?: string;
|
|
624
624
|
approver_id?: string;
|
|
625
625
|
}): Promise<Record<string, any>>;
|
|
626
|
-
listPolicies(
|
|
626
|
+
listPolicies(opts?: {
|
|
627
|
+
agent_id?: string;
|
|
628
|
+
}): Promise<PoliciesResult>;
|
|
629
|
+
/**
|
|
630
|
+
* Create or update a custom Control policy.
|
|
631
|
+
*
|
|
632
|
+
* Tier requirements:
|
|
633
|
+
* - draft_policies (Starter+) for any custom policy
|
|
634
|
+
* - agent_scoped_policies (Pro+) when agent_id is set
|
|
635
|
+
*
|
|
636
|
+
* @example
|
|
637
|
+
* await nx.createPolicy({
|
|
638
|
+
* name: "pii_protection",
|
|
639
|
+
* description: "Block PII exposure",
|
|
640
|
+
* rules: [
|
|
641
|
+
* {
|
|
642
|
+
* match: "(ssn|social.security|passport)",
|
|
643
|
+
* severity: "critical",
|
|
644
|
+
* reason: "PII detected: {match}",
|
|
645
|
+
* },
|
|
646
|
+
* ],
|
|
647
|
+
* whitelisted_domains: ["internal.company.com"],
|
|
648
|
+
* });
|
|
649
|
+
*/
|
|
650
|
+
createPolicy(params: {
|
|
651
|
+
name: string;
|
|
652
|
+
rules: Array<Record<string, any>>;
|
|
653
|
+
description?: string;
|
|
654
|
+
step_types?: string[];
|
|
655
|
+
whitelisted_domains?: string[];
|
|
656
|
+
enabled?: boolean;
|
|
657
|
+
agent_id?: string;
|
|
658
|
+
}): Promise<Record<string, any>>;
|
|
659
|
+
/**
|
|
660
|
+
* Get a single policy by name and scope.
|
|
661
|
+
*
|
|
662
|
+
* The same policy name can exist at both tenant-wide (no agent_id) and
|
|
663
|
+
* agent-scoped levels independently. Specify which one you want.
|
|
664
|
+
*/
|
|
665
|
+
getPolicy(policyName: string, opts?: {
|
|
666
|
+
agent_id?: string;
|
|
667
|
+
}): Promise<Record<string, any>>;
|
|
668
|
+
/**
|
|
669
|
+
* Update an existing custom policy. Increments version.
|
|
670
|
+
* agent_id targets the agent-scoped version; omit to update tenant-wide.
|
|
671
|
+
*/
|
|
672
|
+
updatePolicy(policyName: string, params: {
|
|
673
|
+
rules: Array<Record<string, any>>;
|
|
674
|
+
description?: string;
|
|
675
|
+
step_types?: string[];
|
|
676
|
+
whitelisted_domains?: string[];
|
|
677
|
+
enabled?: boolean;
|
|
678
|
+
agent_id?: string;
|
|
679
|
+
}): Promise<Record<string, any>>;
|
|
680
|
+
/**
|
|
681
|
+
* Disable a custom policy (soft delete).
|
|
682
|
+
* Built-in policies cannot be deleted.
|
|
683
|
+
*/
|
|
684
|
+
deletePolicy(policyName: string, opts?: {
|
|
685
|
+
agent_id?: string;
|
|
686
|
+
}): Promise<Record<string, any>>;
|
|
687
|
+
/**
|
|
688
|
+
* Aggregated governance stats over the audit chain.
|
|
689
|
+
*
|
|
690
|
+
* Returns totals (evaluations, executed, pending_review, approved, denied),
|
|
691
|
+
* violations broken down by policy and agent, and a time-series of activity.
|
|
692
|
+
*
|
|
693
|
+
* Tier: governance_dashboard feature (Starter+).
|
|
694
|
+
*
|
|
695
|
+
* @example
|
|
696
|
+
* const dash = await nx.governanceDashboard({ window: "7d" });
|
|
697
|
+
* console.log(dash.totals);
|
|
698
|
+
*/
|
|
699
|
+
governanceDashboard(opts?: {
|
|
700
|
+
window?: "24h" | "7d" | "30d";
|
|
701
|
+
bucket?: "hour" | "day";
|
|
702
|
+
}): Promise<Record<string, any>>;
|
|
703
|
+
/**
|
|
704
|
+
* Per-agent violation history from the audit chain.
|
|
705
|
+
*
|
|
706
|
+
* Tier: governance_dashboard feature (Starter+).
|
|
707
|
+
*/
|
|
708
|
+
agentViolations(agentId: string, opts?: {
|
|
709
|
+
limit?: number;
|
|
710
|
+
since?: string;
|
|
711
|
+
until?: string;
|
|
712
|
+
}): Promise<Record<string, any>>;
|
|
627
713
|
explainAction(actionId: string): Promise<Record<string, any>>;
|
|
628
714
|
streamStatus(): Promise<StreamStatusResult>;
|
|
629
715
|
memoryHealth(): Promise<Record<string, any>>;
|
|
630
716
|
private _controlRequest;
|
|
631
717
|
/** Submit an action to Novyx Control for governed execution. */
|
|
718
|
+
/**
|
|
719
|
+
* Submit a governed action envelope to a separate Novyx Control instance.
|
|
720
|
+
* Legacy path. For the main Novyx Cloud governance flow, use `submitAction()`.
|
|
721
|
+
*/
|
|
632
722
|
actionSubmit(connector: string, operation: string, payload: Record<string, any>): Promise<any>;
|
|
723
|
+
/**
|
|
724
|
+
* Submit an action to the main Novyx Cloud governance flow.
|
|
725
|
+
*
|
|
726
|
+
* Evaluates against built-in + custom YAML policies (tenant-wide and
|
|
727
|
+
* optionally agent-scoped) via `POST /v1/actions` on the main API.
|
|
728
|
+
* Returns one of three statuses:
|
|
729
|
+
* - `"allowed"` — passed all policies
|
|
730
|
+
* - `"blocked"` — critical violation, action stopped
|
|
731
|
+
* - `"pending_review"` — high-severity violation routed to approval queue
|
|
732
|
+
*
|
|
733
|
+
* @example
|
|
734
|
+
* const result = await nx.submitAction("send_invoice", { amount: 50000 }, {
|
|
735
|
+
* agent_id: "billing-bot",
|
|
736
|
+
* });
|
|
737
|
+
* if (result.status === "pending_review") {
|
|
738
|
+
* console.log(`Awaiting approval: ${result.policy_result.action_id}`);
|
|
739
|
+
* }
|
|
740
|
+
*/
|
|
741
|
+
submitAction(action: string, params?: Record<string, any>, opts?: {
|
|
742
|
+
agent_id?: string;
|
|
743
|
+
}): Promise<Record<string, any>>;
|
|
633
744
|
/** Get the status of a Control action. */
|
|
634
745
|
actionStatus(actionId: string): Promise<any>;
|
|
635
746
|
/** List recent Control actions. */
|
|
@@ -640,10 +751,10 @@ declare class Novyx {
|
|
|
640
751
|
policyCheck(): Promise<any>;
|
|
641
752
|
createAgent(params: {
|
|
642
753
|
name: string;
|
|
754
|
+
provider: "openai" | "anthropic" | "litellm";
|
|
755
|
+
model: string;
|
|
643
756
|
agent_id?: string;
|
|
644
757
|
description?: string;
|
|
645
|
-
model?: string;
|
|
646
|
-
provider?: string;
|
|
647
758
|
instructions?: string;
|
|
648
759
|
capabilities?: string[];
|
|
649
760
|
memory_scope?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -623,13 +623,124 @@ declare class Novyx {
|
|
|
623
623
|
reason?: string;
|
|
624
624
|
approver_id?: string;
|
|
625
625
|
}): Promise<Record<string, any>>;
|
|
626
|
-
listPolicies(
|
|
626
|
+
listPolicies(opts?: {
|
|
627
|
+
agent_id?: string;
|
|
628
|
+
}): Promise<PoliciesResult>;
|
|
629
|
+
/**
|
|
630
|
+
* Create or update a custom Control policy.
|
|
631
|
+
*
|
|
632
|
+
* Tier requirements:
|
|
633
|
+
* - draft_policies (Starter+) for any custom policy
|
|
634
|
+
* - agent_scoped_policies (Pro+) when agent_id is set
|
|
635
|
+
*
|
|
636
|
+
* @example
|
|
637
|
+
* await nx.createPolicy({
|
|
638
|
+
* name: "pii_protection",
|
|
639
|
+
* description: "Block PII exposure",
|
|
640
|
+
* rules: [
|
|
641
|
+
* {
|
|
642
|
+
* match: "(ssn|social.security|passport)",
|
|
643
|
+
* severity: "critical",
|
|
644
|
+
* reason: "PII detected: {match}",
|
|
645
|
+
* },
|
|
646
|
+
* ],
|
|
647
|
+
* whitelisted_domains: ["internal.company.com"],
|
|
648
|
+
* });
|
|
649
|
+
*/
|
|
650
|
+
createPolicy(params: {
|
|
651
|
+
name: string;
|
|
652
|
+
rules: Array<Record<string, any>>;
|
|
653
|
+
description?: string;
|
|
654
|
+
step_types?: string[];
|
|
655
|
+
whitelisted_domains?: string[];
|
|
656
|
+
enabled?: boolean;
|
|
657
|
+
agent_id?: string;
|
|
658
|
+
}): Promise<Record<string, any>>;
|
|
659
|
+
/**
|
|
660
|
+
* Get a single policy by name and scope.
|
|
661
|
+
*
|
|
662
|
+
* The same policy name can exist at both tenant-wide (no agent_id) and
|
|
663
|
+
* agent-scoped levels independently. Specify which one you want.
|
|
664
|
+
*/
|
|
665
|
+
getPolicy(policyName: string, opts?: {
|
|
666
|
+
agent_id?: string;
|
|
667
|
+
}): Promise<Record<string, any>>;
|
|
668
|
+
/**
|
|
669
|
+
* Update an existing custom policy. Increments version.
|
|
670
|
+
* agent_id targets the agent-scoped version; omit to update tenant-wide.
|
|
671
|
+
*/
|
|
672
|
+
updatePolicy(policyName: string, params: {
|
|
673
|
+
rules: Array<Record<string, any>>;
|
|
674
|
+
description?: string;
|
|
675
|
+
step_types?: string[];
|
|
676
|
+
whitelisted_domains?: string[];
|
|
677
|
+
enabled?: boolean;
|
|
678
|
+
agent_id?: string;
|
|
679
|
+
}): Promise<Record<string, any>>;
|
|
680
|
+
/**
|
|
681
|
+
* Disable a custom policy (soft delete).
|
|
682
|
+
* Built-in policies cannot be deleted.
|
|
683
|
+
*/
|
|
684
|
+
deletePolicy(policyName: string, opts?: {
|
|
685
|
+
agent_id?: string;
|
|
686
|
+
}): Promise<Record<string, any>>;
|
|
687
|
+
/**
|
|
688
|
+
* Aggregated governance stats over the audit chain.
|
|
689
|
+
*
|
|
690
|
+
* Returns totals (evaluations, executed, pending_review, approved, denied),
|
|
691
|
+
* violations broken down by policy and agent, and a time-series of activity.
|
|
692
|
+
*
|
|
693
|
+
* Tier: governance_dashboard feature (Starter+).
|
|
694
|
+
*
|
|
695
|
+
* @example
|
|
696
|
+
* const dash = await nx.governanceDashboard({ window: "7d" });
|
|
697
|
+
* console.log(dash.totals);
|
|
698
|
+
*/
|
|
699
|
+
governanceDashboard(opts?: {
|
|
700
|
+
window?: "24h" | "7d" | "30d";
|
|
701
|
+
bucket?: "hour" | "day";
|
|
702
|
+
}): Promise<Record<string, any>>;
|
|
703
|
+
/**
|
|
704
|
+
* Per-agent violation history from the audit chain.
|
|
705
|
+
*
|
|
706
|
+
* Tier: governance_dashboard feature (Starter+).
|
|
707
|
+
*/
|
|
708
|
+
agentViolations(agentId: string, opts?: {
|
|
709
|
+
limit?: number;
|
|
710
|
+
since?: string;
|
|
711
|
+
until?: string;
|
|
712
|
+
}): Promise<Record<string, any>>;
|
|
627
713
|
explainAction(actionId: string): Promise<Record<string, any>>;
|
|
628
714
|
streamStatus(): Promise<StreamStatusResult>;
|
|
629
715
|
memoryHealth(): Promise<Record<string, any>>;
|
|
630
716
|
private _controlRequest;
|
|
631
717
|
/** Submit an action to Novyx Control for governed execution. */
|
|
718
|
+
/**
|
|
719
|
+
* Submit a governed action envelope to a separate Novyx Control instance.
|
|
720
|
+
* Legacy path. For the main Novyx Cloud governance flow, use `submitAction()`.
|
|
721
|
+
*/
|
|
632
722
|
actionSubmit(connector: string, operation: string, payload: Record<string, any>): Promise<any>;
|
|
723
|
+
/**
|
|
724
|
+
* Submit an action to the main Novyx Cloud governance flow.
|
|
725
|
+
*
|
|
726
|
+
* Evaluates against built-in + custom YAML policies (tenant-wide and
|
|
727
|
+
* optionally agent-scoped) via `POST /v1/actions` on the main API.
|
|
728
|
+
* Returns one of three statuses:
|
|
729
|
+
* - `"allowed"` — passed all policies
|
|
730
|
+
* - `"blocked"` — critical violation, action stopped
|
|
731
|
+
* - `"pending_review"` — high-severity violation routed to approval queue
|
|
732
|
+
*
|
|
733
|
+
* @example
|
|
734
|
+
* const result = await nx.submitAction("send_invoice", { amount: 50000 }, {
|
|
735
|
+
* agent_id: "billing-bot",
|
|
736
|
+
* });
|
|
737
|
+
* if (result.status === "pending_review") {
|
|
738
|
+
* console.log(`Awaiting approval: ${result.policy_result.action_id}`);
|
|
739
|
+
* }
|
|
740
|
+
*/
|
|
741
|
+
submitAction(action: string, params?: Record<string, any>, opts?: {
|
|
742
|
+
agent_id?: string;
|
|
743
|
+
}): Promise<Record<string, any>>;
|
|
633
744
|
/** Get the status of a Control action. */
|
|
634
745
|
actionStatus(actionId: string): Promise<any>;
|
|
635
746
|
/** List recent Control actions. */
|
|
@@ -640,10 +751,10 @@ declare class Novyx {
|
|
|
640
751
|
policyCheck(): Promise<any>;
|
|
641
752
|
createAgent(params: {
|
|
642
753
|
name: string;
|
|
754
|
+
provider: "openai" | "anthropic" | "litellm";
|
|
755
|
+
model: string;
|
|
643
756
|
agent_id?: string;
|
|
644
757
|
description?: string;
|
|
645
|
-
model?: string;
|
|
646
|
-
provider?: string;
|
|
647
758
|
instructions?: string;
|
|
648
759
|
capabilities?: string[];
|
|
649
760
|
memory_scope?: string;
|
package/dist/index.js
CHANGED
|
@@ -673,8 +673,129 @@ var Novyx = class {
|
|
|
673
673
|
if (opts?.approver_id) params.approver_id = opts.approver_id;
|
|
674
674
|
return this._request("POST", `/v1/approvals/${approvalId}/decision`, { params });
|
|
675
675
|
}
|
|
676
|
-
|
|
677
|
-
|
|
676
|
+
// ========================================================================
|
|
677
|
+
// Novyx Control — Policy CRUD (Phase 1 + Phase 5)
|
|
678
|
+
// ========================================================================
|
|
679
|
+
async listPolicies(opts) {
|
|
680
|
+
const params = {};
|
|
681
|
+
if (opts?.agent_id) params.agent_id = opts.agent_id;
|
|
682
|
+
return this._request(
|
|
683
|
+
"GET",
|
|
684
|
+
"/v1/control/policies",
|
|
685
|
+
Object.keys(params).length > 0 ? { params } : void 0
|
|
686
|
+
);
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* Create or update a custom Control policy.
|
|
690
|
+
*
|
|
691
|
+
* Tier requirements:
|
|
692
|
+
* - draft_policies (Starter+) for any custom policy
|
|
693
|
+
* - agent_scoped_policies (Pro+) when agent_id is set
|
|
694
|
+
*
|
|
695
|
+
* @example
|
|
696
|
+
* await nx.createPolicy({
|
|
697
|
+
* name: "pii_protection",
|
|
698
|
+
* description: "Block PII exposure",
|
|
699
|
+
* rules: [
|
|
700
|
+
* {
|
|
701
|
+
* match: "(ssn|social.security|passport)",
|
|
702
|
+
* severity: "critical",
|
|
703
|
+
* reason: "PII detected: {match}",
|
|
704
|
+
* },
|
|
705
|
+
* ],
|
|
706
|
+
* whitelisted_domains: ["internal.company.com"],
|
|
707
|
+
* });
|
|
708
|
+
*/
|
|
709
|
+
async createPolicy(params) {
|
|
710
|
+
const body = {
|
|
711
|
+
name: params.name,
|
|
712
|
+
description: params.description ?? "",
|
|
713
|
+
rules: params.rules,
|
|
714
|
+
enabled: params.enabled ?? true
|
|
715
|
+
};
|
|
716
|
+
if (params.step_types !== void 0) body.step_types = params.step_types;
|
|
717
|
+
if (params.whitelisted_domains !== void 0) body.whitelisted_domains = params.whitelisted_domains;
|
|
718
|
+
if (params.agent_id !== void 0) body.agent_id = params.agent_id;
|
|
719
|
+
return this._request("POST", "/v1/control/policies", { body });
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Get a single policy by name and scope.
|
|
723
|
+
*
|
|
724
|
+
* The same policy name can exist at both tenant-wide (no agent_id) and
|
|
725
|
+
* agent-scoped levels independently. Specify which one you want.
|
|
726
|
+
*/
|
|
727
|
+
async getPolicy(policyName, opts) {
|
|
728
|
+
const params = {};
|
|
729
|
+
if (opts?.agent_id) params.agent_id = opts.agent_id;
|
|
730
|
+
return this._request(
|
|
731
|
+
"GET",
|
|
732
|
+
`/v1/control/policies/${policyName}`,
|
|
733
|
+
Object.keys(params).length > 0 ? { params } : void 0
|
|
734
|
+
);
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Update an existing custom policy. Increments version.
|
|
738
|
+
* agent_id targets the agent-scoped version; omit to update tenant-wide.
|
|
739
|
+
*/
|
|
740
|
+
async updatePolicy(policyName, params) {
|
|
741
|
+
const body = {
|
|
742
|
+
name: policyName,
|
|
743
|
+
description: params.description ?? "",
|
|
744
|
+
rules: params.rules,
|
|
745
|
+
enabled: params.enabled ?? true
|
|
746
|
+
};
|
|
747
|
+
if (params.step_types !== void 0) body.step_types = params.step_types;
|
|
748
|
+
if (params.whitelisted_domains !== void 0) body.whitelisted_domains = params.whitelisted_domains;
|
|
749
|
+
if (params.agent_id !== void 0) body.agent_id = params.agent_id;
|
|
750
|
+
return this._request("PUT", `/v1/control/policies/${policyName}`, { body });
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Disable a custom policy (soft delete).
|
|
754
|
+
* Built-in policies cannot be deleted.
|
|
755
|
+
*/
|
|
756
|
+
async deletePolicy(policyName, opts) {
|
|
757
|
+
const params = {};
|
|
758
|
+
if (opts?.agent_id) params.agent_id = opts.agent_id;
|
|
759
|
+
return this._request(
|
|
760
|
+
"DELETE",
|
|
761
|
+
`/v1/control/policies/${policyName}`,
|
|
762
|
+
Object.keys(params).length > 0 ? { params } : void 0
|
|
763
|
+
);
|
|
764
|
+
}
|
|
765
|
+
// ========================================================================
|
|
766
|
+
// Novyx Control — Governance Dashboard (Phase 4)
|
|
767
|
+
// ========================================================================
|
|
768
|
+
/**
|
|
769
|
+
* Aggregated governance stats over the audit chain.
|
|
770
|
+
*
|
|
771
|
+
* Returns totals (evaluations, executed, pending_review, approved, denied),
|
|
772
|
+
* violations broken down by policy and agent, and a time-series of activity.
|
|
773
|
+
*
|
|
774
|
+
* Tier: governance_dashboard feature (Starter+).
|
|
775
|
+
*
|
|
776
|
+
* @example
|
|
777
|
+
* const dash = await nx.governanceDashboard({ window: "7d" });
|
|
778
|
+
* console.log(dash.totals);
|
|
779
|
+
*/
|
|
780
|
+
async governanceDashboard(opts) {
|
|
781
|
+
const params = { window: opts?.window ?? "7d" };
|
|
782
|
+
if (opts?.bucket !== void 0) params.bucket = opts.bucket;
|
|
783
|
+
return this._request("GET", "/v1/control/dashboard", { params });
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* Per-agent violation history from the audit chain.
|
|
787
|
+
*
|
|
788
|
+
* Tier: governance_dashboard feature (Starter+).
|
|
789
|
+
*/
|
|
790
|
+
async agentViolations(agentId, opts) {
|
|
791
|
+
const params = { limit: opts?.limit ?? 50 };
|
|
792
|
+
if (opts?.since !== void 0) params.since = opts.since;
|
|
793
|
+
if (opts?.until !== void 0) params.until = opts.until;
|
|
794
|
+
return this._request(
|
|
795
|
+
"GET",
|
|
796
|
+
`/v1/control/agents/${agentId}/violations`,
|
|
797
|
+
{ params }
|
|
798
|
+
);
|
|
678
799
|
}
|
|
679
800
|
// ========================================================================
|
|
680
801
|
// Explain Action
|
|
@@ -730,9 +851,36 @@ var Novyx = class {
|
|
|
730
851
|
}
|
|
731
852
|
}
|
|
732
853
|
/** Submit an action to Novyx Control for governed execution. */
|
|
854
|
+
/**
|
|
855
|
+
* Submit a governed action envelope to a separate Novyx Control instance.
|
|
856
|
+
* Legacy path. For the main Novyx Cloud governance flow, use `submitAction()`.
|
|
857
|
+
*/
|
|
733
858
|
async actionSubmit(connector, operation, payload) {
|
|
734
859
|
return this._controlRequest("POST", `/v1/actions/${connector}/${operation}`, { body: payload });
|
|
735
860
|
}
|
|
861
|
+
/**
|
|
862
|
+
* Submit an action to the main Novyx Cloud governance flow.
|
|
863
|
+
*
|
|
864
|
+
* Evaluates against built-in + custom YAML policies (tenant-wide and
|
|
865
|
+
* optionally agent-scoped) via `POST /v1/actions` on the main API.
|
|
866
|
+
* Returns one of three statuses:
|
|
867
|
+
* - `"allowed"` — passed all policies
|
|
868
|
+
* - `"blocked"` — critical violation, action stopped
|
|
869
|
+
* - `"pending_review"` — high-severity violation routed to approval queue
|
|
870
|
+
*
|
|
871
|
+
* @example
|
|
872
|
+
* const result = await nx.submitAction("send_invoice", { amount: 50000 }, {
|
|
873
|
+
* agent_id: "billing-bot",
|
|
874
|
+
* });
|
|
875
|
+
* if (result.status === "pending_review") {
|
|
876
|
+
* console.log(`Awaiting approval: ${result.policy_result.action_id}`);
|
|
877
|
+
* }
|
|
878
|
+
*/
|
|
879
|
+
async submitAction(action, params = {}, opts) {
|
|
880
|
+
const body = { action, params };
|
|
881
|
+
if (opts?.agent_id !== void 0) body.agent_id = opts.agent_id;
|
|
882
|
+
return this._request("POST", "/v1/actions", { body });
|
|
883
|
+
}
|
|
736
884
|
/** Get the status of a Control action. */
|
|
737
885
|
async actionStatus(actionId) {
|
|
738
886
|
return this._controlRequest("GET", `/v1/actions/${actionId}`);
|
|
@@ -749,10 +897,19 @@ var Novyx = class {
|
|
|
749
897
|
// Agents (Runtime v2)
|
|
750
898
|
// ========================================================================
|
|
751
899
|
async createAgent(params) {
|
|
900
|
+
const validProviders = ["openai", "anthropic", "litellm"];
|
|
901
|
+
if (!validProviders.includes(params.provider)) {
|
|
902
|
+
throw new Error(
|
|
903
|
+
`Unknown provider '${params.provider}'. Choose 'openai', 'anthropic', or 'litellm' (use litellm for Gemini, Mistral, Cohere, etc.).`
|
|
904
|
+
);
|
|
905
|
+
}
|
|
906
|
+
if (!params.model) {
|
|
907
|
+
throw new Error("model is required");
|
|
908
|
+
}
|
|
752
909
|
const body = {
|
|
753
910
|
name: params.name,
|
|
754
|
-
model: params.model
|
|
755
|
-
provider: params.provider
|
|
911
|
+
model: params.model,
|
|
912
|
+
provider: params.provider
|
|
756
913
|
};
|
|
757
914
|
if (params.agent_id) body.agent_id = params.agent_id;
|
|
758
915
|
if (params.description) body.description = params.description;
|
package/dist/index.mjs
CHANGED
|
@@ -640,8 +640,129 @@ var Novyx = class {
|
|
|
640
640
|
if (opts?.approver_id) params.approver_id = opts.approver_id;
|
|
641
641
|
return this._request("POST", `/v1/approvals/${approvalId}/decision`, { params });
|
|
642
642
|
}
|
|
643
|
-
|
|
644
|
-
|
|
643
|
+
// ========================================================================
|
|
644
|
+
// Novyx Control — Policy CRUD (Phase 1 + Phase 5)
|
|
645
|
+
// ========================================================================
|
|
646
|
+
async listPolicies(opts) {
|
|
647
|
+
const params = {};
|
|
648
|
+
if (opts?.agent_id) params.agent_id = opts.agent_id;
|
|
649
|
+
return this._request(
|
|
650
|
+
"GET",
|
|
651
|
+
"/v1/control/policies",
|
|
652
|
+
Object.keys(params).length > 0 ? { params } : void 0
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Create or update a custom Control policy.
|
|
657
|
+
*
|
|
658
|
+
* Tier requirements:
|
|
659
|
+
* - draft_policies (Starter+) for any custom policy
|
|
660
|
+
* - agent_scoped_policies (Pro+) when agent_id is set
|
|
661
|
+
*
|
|
662
|
+
* @example
|
|
663
|
+
* await nx.createPolicy({
|
|
664
|
+
* name: "pii_protection",
|
|
665
|
+
* description: "Block PII exposure",
|
|
666
|
+
* rules: [
|
|
667
|
+
* {
|
|
668
|
+
* match: "(ssn|social.security|passport)",
|
|
669
|
+
* severity: "critical",
|
|
670
|
+
* reason: "PII detected: {match}",
|
|
671
|
+
* },
|
|
672
|
+
* ],
|
|
673
|
+
* whitelisted_domains: ["internal.company.com"],
|
|
674
|
+
* });
|
|
675
|
+
*/
|
|
676
|
+
async createPolicy(params) {
|
|
677
|
+
const body = {
|
|
678
|
+
name: params.name,
|
|
679
|
+
description: params.description ?? "",
|
|
680
|
+
rules: params.rules,
|
|
681
|
+
enabled: params.enabled ?? true
|
|
682
|
+
};
|
|
683
|
+
if (params.step_types !== void 0) body.step_types = params.step_types;
|
|
684
|
+
if (params.whitelisted_domains !== void 0) body.whitelisted_domains = params.whitelisted_domains;
|
|
685
|
+
if (params.agent_id !== void 0) body.agent_id = params.agent_id;
|
|
686
|
+
return this._request("POST", "/v1/control/policies", { body });
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* Get a single policy by name and scope.
|
|
690
|
+
*
|
|
691
|
+
* The same policy name can exist at both tenant-wide (no agent_id) and
|
|
692
|
+
* agent-scoped levels independently. Specify which one you want.
|
|
693
|
+
*/
|
|
694
|
+
async getPolicy(policyName, opts) {
|
|
695
|
+
const params = {};
|
|
696
|
+
if (opts?.agent_id) params.agent_id = opts.agent_id;
|
|
697
|
+
return this._request(
|
|
698
|
+
"GET",
|
|
699
|
+
`/v1/control/policies/${policyName}`,
|
|
700
|
+
Object.keys(params).length > 0 ? { params } : void 0
|
|
701
|
+
);
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* Update an existing custom policy. Increments version.
|
|
705
|
+
* agent_id targets the agent-scoped version; omit to update tenant-wide.
|
|
706
|
+
*/
|
|
707
|
+
async updatePolicy(policyName, params) {
|
|
708
|
+
const body = {
|
|
709
|
+
name: policyName,
|
|
710
|
+
description: params.description ?? "",
|
|
711
|
+
rules: params.rules,
|
|
712
|
+
enabled: params.enabled ?? true
|
|
713
|
+
};
|
|
714
|
+
if (params.step_types !== void 0) body.step_types = params.step_types;
|
|
715
|
+
if (params.whitelisted_domains !== void 0) body.whitelisted_domains = params.whitelisted_domains;
|
|
716
|
+
if (params.agent_id !== void 0) body.agent_id = params.agent_id;
|
|
717
|
+
return this._request("PUT", `/v1/control/policies/${policyName}`, { body });
|
|
718
|
+
}
|
|
719
|
+
/**
|
|
720
|
+
* Disable a custom policy (soft delete).
|
|
721
|
+
* Built-in policies cannot be deleted.
|
|
722
|
+
*/
|
|
723
|
+
async deletePolicy(policyName, opts) {
|
|
724
|
+
const params = {};
|
|
725
|
+
if (opts?.agent_id) params.agent_id = opts.agent_id;
|
|
726
|
+
return this._request(
|
|
727
|
+
"DELETE",
|
|
728
|
+
`/v1/control/policies/${policyName}`,
|
|
729
|
+
Object.keys(params).length > 0 ? { params } : void 0
|
|
730
|
+
);
|
|
731
|
+
}
|
|
732
|
+
// ========================================================================
|
|
733
|
+
// Novyx Control — Governance Dashboard (Phase 4)
|
|
734
|
+
// ========================================================================
|
|
735
|
+
/**
|
|
736
|
+
* Aggregated governance stats over the audit chain.
|
|
737
|
+
*
|
|
738
|
+
* Returns totals (evaluations, executed, pending_review, approved, denied),
|
|
739
|
+
* violations broken down by policy and agent, and a time-series of activity.
|
|
740
|
+
*
|
|
741
|
+
* Tier: governance_dashboard feature (Starter+).
|
|
742
|
+
*
|
|
743
|
+
* @example
|
|
744
|
+
* const dash = await nx.governanceDashboard({ window: "7d" });
|
|
745
|
+
* console.log(dash.totals);
|
|
746
|
+
*/
|
|
747
|
+
async governanceDashboard(opts) {
|
|
748
|
+
const params = { window: opts?.window ?? "7d" };
|
|
749
|
+
if (opts?.bucket !== void 0) params.bucket = opts.bucket;
|
|
750
|
+
return this._request("GET", "/v1/control/dashboard", { params });
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Per-agent violation history from the audit chain.
|
|
754
|
+
*
|
|
755
|
+
* Tier: governance_dashboard feature (Starter+).
|
|
756
|
+
*/
|
|
757
|
+
async agentViolations(agentId, opts) {
|
|
758
|
+
const params = { limit: opts?.limit ?? 50 };
|
|
759
|
+
if (opts?.since !== void 0) params.since = opts.since;
|
|
760
|
+
if (opts?.until !== void 0) params.until = opts.until;
|
|
761
|
+
return this._request(
|
|
762
|
+
"GET",
|
|
763
|
+
`/v1/control/agents/${agentId}/violations`,
|
|
764
|
+
{ params }
|
|
765
|
+
);
|
|
645
766
|
}
|
|
646
767
|
// ========================================================================
|
|
647
768
|
// Explain Action
|
|
@@ -697,9 +818,36 @@ var Novyx = class {
|
|
|
697
818
|
}
|
|
698
819
|
}
|
|
699
820
|
/** Submit an action to Novyx Control for governed execution. */
|
|
821
|
+
/**
|
|
822
|
+
* Submit a governed action envelope to a separate Novyx Control instance.
|
|
823
|
+
* Legacy path. For the main Novyx Cloud governance flow, use `submitAction()`.
|
|
824
|
+
*/
|
|
700
825
|
async actionSubmit(connector, operation, payload) {
|
|
701
826
|
return this._controlRequest("POST", `/v1/actions/${connector}/${operation}`, { body: payload });
|
|
702
827
|
}
|
|
828
|
+
/**
|
|
829
|
+
* Submit an action to the main Novyx Cloud governance flow.
|
|
830
|
+
*
|
|
831
|
+
* Evaluates against built-in + custom YAML policies (tenant-wide and
|
|
832
|
+
* optionally agent-scoped) via `POST /v1/actions` on the main API.
|
|
833
|
+
* Returns one of three statuses:
|
|
834
|
+
* - `"allowed"` — passed all policies
|
|
835
|
+
* - `"blocked"` — critical violation, action stopped
|
|
836
|
+
* - `"pending_review"` — high-severity violation routed to approval queue
|
|
837
|
+
*
|
|
838
|
+
* @example
|
|
839
|
+
* const result = await nx.submitAction("send_invoice", { amount: 50000 }, {
|
|
840
|
+
* agent_id: "billing-bot",
|
|
841
|
+
* });
|
|
842
|
+
* if (result.status === "pending_review") {
|
|
843
|
+
* console.log(`Awaiting approval: ${result.policy_result.action_id}`);
|
|
844
|
+
* }
|
|
845
|
+
*/
|
|
846
|
+
async submitAction(action, params = {}, opts) {
|
|
847
|
+
const body = { action, params };
|
|
848
|
+
if (opts?.agent_id !== void 0) body.agent_id = opts.agent_id;
|
|
849
|
+
return this._request("POST", "/v1/actions", { body });
|
|
850
|
+
}
|
|
703
851
|
/** Get the status of a Control action. */
|
|
704
852
|
async actionStatus(actionId) {
|
|
705
853
|
return this._controlRequest("GET", `/v1/actions/${actionId}`);
|
|
@@ -716,10 +864,19 @@ var Novyx = class {
|
|
|
716
864
|
// Agents (Runtime v2)
|
|
717
865
|
// ========================================================================
|
|
718
866
|
async createAgent(params) {
|
|
867
|
+
const validProviders = ["openai", "anthropic", "litellm"];
|
|
868
|
+
if (!validProviders.includes(params.provider)) {
|
|
869
|
+
throw new Error(
|
|
870
|
+
`Unknown provider '${params.provider}'. Choose 'openai', 'anthropic', or 'litellm' (use litellm for Gemini, Mistral, Cohere, etc.).`
|
|
871
|
+
);
|
|
872
|
+
}
|
|
873
|
+
if (!params.model) {
|
|
874
|
+
throw new Error("model is required");
|
|
875
|
+
}
|
|
719
876
|
const body = {
|
|
720
877
|
name: params.name,
|
|
721
|
-
model: params.model
|
|
722
|
-
provider: params.provider
|
|
878
|
+
model: params.model,
|
|
879
|
+
provider: params.provider
|
|
723
880
|
};
|
|
724
881
|
if (params.agent_id) body.agent_id = params.agent_id;
|
|
725
882
|
if (params.description) body.description = params.description;
|