@axonflow/sdk 3.5.0 → 3.7.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/cjs/client.d.ts +108 -1
- package/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/client.js +241 -0
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/index.d.ts +3 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +6 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/connector.d.ts +45 -0
- package/dist/cjs/types/connector.d.ts.map +1 -1
- package/dist/cjs/types/connector.js.map +1 -1
- package/dist/cjs/types/media.d.ts +44 -0
- package/dist/cjs/types/media.d.ts.map +1 -1
- package/dist/cjs/types/policies.d.ts +8 -1
- package/dist/cjs/types/policies.d.ts.map +1 -1
- package/dist/cjs/types/policies.js +8 -0
- package/dist/cjs/types/policies.js.map +1 -1
- package/dist/cjs/types/workflows.d.ts +6 -0
- package/dist/cjs/types/workflows.d.ts.map +1 -1
- package/dist/cjs/types/workflows.js.map +1 -1
- package/dist/esm/client.d.ts +108 -1
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +241 -0
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/index.d.ts +3 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/connector.d.ts +45 -0
- package/dist/esm/types/connector.d.ts.map +1 -1
- package/dist/esm/types/connector.js.map +1 -1
- package/dist/esm/types/media.d.ts +44 -0
- package/dist/esm/types/media.d.ts.map +1 -1
- package/dist/esm/types/policies.d.ts +8 -1
- package/dist/esm/types/policies.d.ts.map +1 -1
- package/dist/esm/types/policies.js +7 -1
- package/dist/esm/types/policies.js.map +1 -1
- package/dist/esm/types/workflows.d.ts +6 -0
- package/dist/esm/types/workflows.d.ts.map +1 -1
- package/dist/esm/types/workflows.js.map +1 -1
- package/package.json +2 -2
package/dist/esm/client.js
CHANGED
|
@@ -755,6 +755,142 @@ export class AxonFlow {
|
|
|
755
755
|
async mcpExecute(options) {
|
|
756
756
|
return this.mcpQuery(options);
|
|
757
757
|
}
|
|
758
|
+
/**
|
|
759
|
+
* Validate an MCP request against configured policies without executing it.
|
|
760
|
+
* Use this when an external orchestrator (e.g., LangGraph, CrewAI) manages MCP execution
|
|
761
|
+
* but needs AxonFlow policy enforcement as a pre-execution gate.
|
|
762
|
+
*
|
|
763
|
+
* @example
|
|
764
|
+
* ```typescript
|
|
765
|
+
* const result = await axonflow.mcpCheckInput({
|
|
766
|
+
* connectorType: 'postgres',
|
|
767
|
+
* statement: 'SELECT * FROM users WHERE id = $1',
|
|
768
|
+
* parameters: { '$1': '123' },
|
|
769
|
+
* });
|
|
770
|
+
*
|
|
771
|
+
* if (!result.allowed) {
|
|
772
|
+
* console.log('Blocked:', result.block_reason);
|
|
773
|
+
* }
|
|
774
|
+
* ```
|
|
775
|
+
*
|
|
776
|
+
* @param options - Input check options including connector type and statement
|
|
777
|
+
* @returns MCPCheckInputResponse with allowed status and policy evaluation details
|
|
778
|
+
* @throws ConnectorError if the request fails (non-403 errors)
|
|
779
|
+
*/
|
|
780
|
+
async mcpCheckInput(options) {
|
|
781
|
+
const url = `${this.config.endpoint}/api/v1/mcp/check-input`;
|
|
782
|
+
const headers = {
|
|
783
|
+
'Content-Type': 'application/json',
|
|
784
|
+
...this.getAuthHeaders(),
|
|
785
|
+
};
|
|
786
|
+
const body = {
|
|
787
|
+
connector_type: options.connectorType,
|
|
788
|
+
statement: options.statement,
|
|
789
|
+
};
|
|
790
|
+
if (options.parameters) {
|
|
791
|
+
body.parameters = options.parameters;
|
|
792
|
+
}
|
|
793
|
+
if (options.operation) {
|
|
794
|
+
body.operation = options.operation;
|
|
795
|
+
}
|
|
796
|
+
if (this.config.debug) {
|
|
797
|
+
debugLog('MCP Check Input', {
|
|
798
|
+
connectorType: options.connectorType,
|
|
799
|
+
statement: options.statement.substring(0, 50),
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
const response = await fetch(url, {
|
|
803
|
+
method: 'POST',
|
|
804
|
+
headers,
|
|
805
|
+
body: JSON.stringify(body),
|
|
806
|
+
signal: AbortSignal.timeout(this.config.timeout),
|
|
807
|
+
});
|
|
808
|
+
const responseData = await response.json();
|
|
809
|
+
// 403 means policy blocked — this is a valid check response, not an error
|
|
810
|
+
if (!response.ok && response.status !== 403) {
|
|
811
|
+
throw new ConnectorError(responseData.error || 'MCP check-input failed', options.connectorType, 'check-input');
|
|
812
|
+
}
|
|
813
|
+
if (this.config.debug) {
|
|
814
|
+
debugLog('MCP Check Input result', {
|
|
815
|
+
connectorType: options.connectorType,
|
|
816
|
+
allowed: responseData.allowed,
|
|
817
|
+
policiesEvaluated: responseData.policies_evaluated,
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
return responseData;
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Validate MCP response data against configured policies.
|
|
824
|
+
* Use this when an external orchestrator manages MCP execution but needs AxonFlow
|
|
825
|
+
* policy enforcement as a post-execution gate (PII redaction, exfiltration limits).
|
|
826
|
+
*
|
|
827
|
+
* @example
|
|
828
|
+
* ```typescript
|
|
829
|
+
* const result = await axonflow.mcpCheckOutput({
|
|
830
|
+
* connectorType: 'postgres',
|
|
831
|
+
* responseData: [{ id: 1, name: 'Alice', ssn: '123-45-6789' }],
|
|
832
|
+
* rowCount: 1,
|
|
833
|
+
* });
|
|
834
|
+
*
|
|
835
|
+
* if (result.redacted_data) {
|
|
836
|
+
* console.log('Data was redacted:', result.redacted_data);
|
|
837
|
+
* }
|
|
838
|
+
* if (result.exfiltration_info && !result.exfiltration_info.within_limits) {
|
|
839
|
+
* console.log('Exfiltration limit exceeded');
|
|
840
|
+
* }
|
|
841
|
+
* ```
|
|
842
|
+
*
|
|
843
|
+
* @param options - Output check options including connector type and response data
|
|
844
|
+
* @returns MCPCheckOutputResponse with allowed status, redacted data, and policy details
|
|
845
|
+
* @throws ConnectorError if the request fails (non-403 errors)
|
|
846
|
+
*/
|
|
847
|
+
async mcpCheckOutput(options) {
|
|
848
|
+
const url = `${this.config.endpoint}/api/v1/mcp/check-output`;
|
|
849
|
+
const headers = {
|
|
850
|
+
'Content-Type': 'application/json',
|
|
851
|
+
...this.getAuthHeaders(),
|
|
852
|
+
};
|
|
853
|
+
const body = {
|
|
854
|
+
connector_type: options.connectorType,
|
|
855
|
+
};
|
|
856
|
+
if (options.responseData !== undefined) {
|
|
857
|
+
body.response_data = options.responseData;
|
|
858
|
+
}
|
|
859
|
+
if (options.message !== undefined) {
|
|
860
|
+
body.message = options.message;
|
|
861
|
+
}
|
|
862
|
+
if (options.metadata) {
|
|
863
|
+
body.metadata = options.metadata;
|
|
864
|
+
}
|
|
865
|
+
if (options.rowCount !== undefined && options.rowCount > 0) {
|
|
866
|
+
body.row_count = options.rowCount;
|
|
867
|
+
}
|
|
868
|
+
if (this.config.debug) {
|
|
869
|
+
debugLog('MCP Check Output', {
|
|
870
|
+
connectorType: options.connectorType,
|
|
871
|
+
rowCount: options.rowCount,
|
|
872
|
+
});
|
|
873
|
+
}
|
|
874
|
+
const response = await fetch(url, {
|
|
875
|
+
method: 'POST',
|
|
876
|
+
headers,
|
|
877
|
+
body: JSON.stringify(body),
|
|
878
|
+
signal: AbortSignal.timeout(this.config.timeout),
|
|
879
|
+
});
|
|
880
|
+
const responseData = await response.json();
|
|
881
|
+
// 403 means policy blocked — this is a valid check response, not an error
|
|
882
|
+
if (!response.ok && response.status !== 403) {
|
|
883
|
+
throw new ConnectorError(responseData.error || 'MCP check-output failed', options.connectorType, 'check-output');
|
|
884
|
+
}
|
|
885
|
+
if (this.config.debug) {
|
|
886
|
+
debugLog('MCP Check Output result', {
|
|
887
|
+
connectorType: options.connectorType,
|
|
888
|
+
allowed: responseData.allowed,
|
|
889
|
+
policiesEvaluated: responseData.policies_evaluated,
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
return responseData;
|
|
893
|
+
}
|
|
758
894
|
/**
|
|
759
895
|
* Generate a multi-agent execution plan from a natural language query
|
|
760
896
|
* @param query - Natural language query describing the task
|
|
@@ -4574,6 +4710,111 @@ export class AxonFlow {
|
|
|
4574
4710
|
const response = await this.orchestratorRequest('GET', '/api/v1/hitl/stats');
|
|
4575
4711
|
return response.data;
|
|
4576
4712
|
}
|
|
4713
|
+
// ============================================================================
|
|
4714
|
+
// Media Governance Config Methods (Issue #1222)
|
|
4715
|
+
// ============================================================================
|
|
4716
|
+
/**
|
|
4717
|
+
* Get the current media governance configuration for the authenticated tenant.
|
|
4718
|
+
*
|
|
4719
|
+
* Returns whether media analysis is enabled, which analyzers are allowed,
|
|
4720
|
+
* and when the config was last updated.
|
|
4721
|
+
*
|
|
4722
|
+
* @returns Media governance configuration for the tenant
|
|
4723
|
+
*
|
|
4724
|
+
* @example
|
|
4725
|
+
* ```typescript
|
|
4726
|
+
* const config = await client.getMediaGovernanceConfig();
|
|
4727
|
+
* console.log(`Media governance enabled: ${config.enabled}`);
|
|
4728
|
+
* if (config.allowedAnalyzers) {
|
|
4729
|
+
* console.log(`Allowed analyzers: ${config.allowedAnalyzers.join(', ')}`);
|
|
4730
|
+
* }
|
|
4731
|
+
* ```
|
|
4732
|
+
*/
|
|
4733
|
+
async getMediaGovernanceConfig() {
|
|
4734
|
+
if (this.config.debug) {
|
|
4735
|
+
debugLog('Getting media governance config');
|
|
4736
|
+
}
|
|
4737
|
+
const data = await this.orchestratorRequest('GET', '/api/v1/media-governance/config');
|
|
4738
|
+
// Transform snake_case response to camelCase
|
|
4739
|
+
return {
|
|
4740
|
+
tenantId: data.tenant_id,
|
|
4741
|
+
enabled: data.enabled,
|
|
4742
|
+
allowedAnalyzers: data.allowed_analyzers,
|
|
4743
|
+
updatedAt: data.updated_at,
|
|
4744
|
+
updatedBy: data.updated_by,
|
|
4745
|
+
};
|
|
4746
|
+
}
|
|
4747
|
+
/**
|
|
4748
|
+
* Update the media governance configuration for the authenticated tenant.
|
|
4749
|
+
*
|
|
4750
|
+
* Use this to enable/disable media analysis or restrict which analyzers
|
|
4751
|
+
* are available for the tenant.
|
|
4752
|
+
*
|
|
4753
|
+
* @param request - Fields to update
|
|
4754
|
+
* @returns Updated media governance configuration
|
|
4755
|
+
*
|
|
4756
|
+
* @example
|
|
4757
|
+
* ```typescript
|
|
4758
|
+
* // Disable media governance
|
|
4759
|
+
* const updated = await client.updateMediaGovernanceConfig({ enabled: false });
|
|
4760
|
+
*
|
|
4761
|
+
* // Enable with specific analyzers only
|
|
4762
|
+
* const config = await client.updateMediaGovernanceConfig({
|
|
4763
|
+
* enabled: true,
|
|
4764
|
+
* allowedAnalyzers: ['nsfw', 'pii']
|
|
4765
|
+
* });
|
|
4766
|
+
* ```
|
|
4767
|
+
*/
|
|
4768
|
+
async updateMediaGovernanceConfig(request) {
|
|
4769
|
+
if (this.config.debug) {
|
|
4770
|
+
debugLog('Updating media governance config', { request });
|
|
4771
|
+
}
|
|
4772
|
+
// Convert camelCase to snake_case for API compatibility
|
|
4773
|
+
const requestBody = {};
|
|
4774
|
+
if (request.enabled !== undefined)
|
|
4775
|
+
requestBody.enabled = request.enabled;
|
|
4776
|
+
if (request.allowedAnalyzers !== undefined)
|
|
4777
|
+
requestBody.allowed_analyzers = request.allowedAnalyzers;
|
|
4778
|
+
const data = await this.orchestratorRequest('PUT', '/api/v1/media-governance/config', requestBody);
|
|
4779
|
+
// Transform snake_case response to camelCase
|
|
4780
|
+
return {
|
|
4781
|
+
tenantId: data.tenant_id,
|
|
4782
|
+
enabled: data.enabled,
|
|
4783
|
+
allowedAnalyzers: data.allowed_analyzers,
|
|
4784
|
+
updatedAt: data.updated_at,
|
|
4785
|
+
updatedBy: data.updated_by,
|
|
4786
|
+
};
|
|
4787
|
+
}
|
|
4788
|
+
/**
|
|
4789
|
+
* Get the platform-level media governance status.
|
|
4790
|
+
*
|
|
4791
|
+
* Reports whether media governance is available on this platform instance,
|
|
4792
|
+
* the default enablement state, whether per-tenant control is supported,
|
|
4793
|
+
* and the required license tier.
|
|
4794
|
+
*
|
|
4795
|
+
* @returns Media governance platform status
|
|
4796
|
+
*
|
|
4797
|
+
* @example
|
|
4798
|
+
* ```typescript
|
|
4799
|
+
* const status = await client.getMediaGovernanceStatus();
|
|
4800
|
+
* console.log(`Available: ${status.available}`);
|
|
4801
|
+
* console.log(`Tier: ${status.tier}`);
|
|
4802
|
+
* console.log(`Per-tenant control: ${status.perTenantControl}`);
|
|
4803
|
+
* ```
|
|
4804
|
+
*/
|
|
4805
|
+
async getMediaGovernanceStatus() {
|
|
4806
|
+
if (this.config.debug) {
|
|
4807
|
+
debugLog('Getting media governance status');
|
|
4808
|
+
}
|
|
4809
|
+
const data = await this.orchestratorRequest('GET', '/api/v1/media-governance/status');
|
|
4810
|
+
// Transform snake_case response to camelCase
|
|
4811
|
+
return {
|
|
4812
|
+
available: data.available,
|
|
4813
|
+
enabledByDefault: data.enabled_by_default,
|
|
4814
|
+
perTenantControl: data.per_tenant_control,
|
|
4815
|
+
tier: data.tier,
|
|
4816
|
+
};
|
|
4817
|
+
}
|
|
4577
4818
|
/**
|
|
4578
4819
|
* Stream real-time execution status updates via Server-Sent Events (SSE).
|
|
4579
4820
|
*
|