dashclaw 1.7.2 → 1.8.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.
Files changed (3) hide show
  1. package/README.md +226 -1
  2. package/dashclaw.js +215 -1
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Full reference for the DashClaw SDK (Node.js). For Python, see the [Python SDK docs](../sdk-python/README.md).
4
4
 
5
- Install, configure, and instrument your AI agents with 60+ methods across action recording, behavior guard, context management, session handoffs, security scanning, and more.
5
+ Install, configure, and instrument your AI agents with 78+ methods across action recording, behavior guard, context management, session handoffs, security scanning, policy testing, compliance, task routing, and more.
6
6
 
7
7
  ---
8
8
 
@@ -734,6 +734,231 @@ Push multiple data categories in a single request. Accepts connections, memory,
734
734
 
735
735
  ---
736
736
 
737
+ ## Policy Testing
738
+
739
+ Run guardrails tests, generate compliance proof reports, and import policy packs.
740
+
741
+ ### claw.testPolicies()
742
+ Run guardrails tests against all active policies. Returns pass/fail results per policy.
743
+
744
+ **Returns:** `Promise<{ results: Object[], total: number, passed: number, failed: number }>`
745
+
746
+ **Example:**
747
+ ```javascript
748
+ const report = await claw.testPolicies();
749
+ console.log(`${report.passed}/${report.total} policies passed`);
750
+ for (const r of report.results.filter(r => !r.passed)) {
751
+ console.log(`FAIL: ${r.policy} — ${r.reason}`);
752
+ }
753
+ ```
754
+
755
+ ### claw.getProofReport(options?)
756
+ Generate a compliance proof report summarizing guard decisions, policy evaluations, and audit evidence.
757
+
758
+ **Parameters:**
759
+ | Parameter | Type | Required | Description |
760
+ |-----------|------|----------|-------------|
761
+ | format | string | No | Output format: "json" (default) or "md" |
762
+
763
+ **Returns:** `Promise<{ report: Object|string }>`
764
+
765
+ ### claw.importPolicies({ pack?, yaml? })
766
+ Import a policy pack or raw YAML. Admin only. Replaces or merges into active policies.
767
+
768
+ **Parameters:**
769
+ | Parameter | Type | Required | Description |
770
+ |-----------|------|----------|-------------|
771
+ | pack | string | No | Named policy pack: enterprise-strict, smb-safe, startup-growth, development |
772
+ | yaml | string | No | Raw YAML policy definition |
773
+
774
+ **Returns:** `Promise<{ imported: number, policies: Object[] }>`
775
+
776
+ ---
777
+
778
+ ## Compliance Engine
779
+
780
+ Map policies to regulatory frameworks, run gap analysis, and generate compliance reports.
781
+
782
+ ### claw.mapCompliance(framework)
783
+ Map active policies to framework controls. Returns a control-by-control coverage matrix.
784
+
785
+ **Parameters:**
786
+ | Parameter | Type | Required | Description |
787
+ |-----------|------|----------|-------------|
788
+ | framework | string | Yes | Target framework: soc2, iso27001, gdpr, nist-ai-rmf, imda-agentic |
789
+
790
+ **Returns:** `Promise<{ framework: string, controls: Object[], coverage_pct: number }>`
791
+
792
+ **Example:**
793
+ ```javascript
794
+ const { controls, coverage_pct } = await claw.mapCompliance('soc2');
795
+ console.log(`SOC 2 coverage: ${coverage_pct}%`);
796
+ for (const ctrl of controls.filter(c => !c.covered)) {
797
+ console.log(`Gap: ${ctrl.id} — ${ctrl.name}`);
798
+ }
799
+ ```
800
+
801
+ ### claw.analyzeGaps(framework)
802
+ Run gap analysis with remediation plan. Identifies missing controls and suggests policy changes.
803
+
804
+ **Parameters:**
805
+ | Parameter | Type | Required | Description |
806
+ |-----------|------|----------|-------------|
807
+ | framework | string | Yes | Target framework: soc2, iso27001, gdpr, nist-ai-rmf, imda-agentic |
808
+
809
+ **Returns:** `Promise<{ framework: string, gaps: Object[], remediation_plan: Object[] }>`
810
+
811
+ ### claw.getComplianceReport(framework, options?)
812
+ Generate a full compliance report and save a point-in-time snapshot.
813
+
814
+ **Parameters:**
815
+ | Parameter | Type | Required | Description |
816
+ |-----------|------|----------|-------------|
817
+ | framework | string | Yes | Target framework |
818
+ | options.format | string | No | Output format: "json" (default) or "md" |
819
+
820
+ **Returns:** `Promise<{ report: Object|string, snapshot_id: string }>`
821
+
822
+ ### claw.listFrameworks()
823
+ List all available compliance frameworks with metadata.
824
+
825
+ **Returns:** `Promise<{ frameworks: Object[] }>`
826
+
827
+ ### claw.getComplianceEvidence(options?)
828
+ Get live guard decision evidence for compliance audits. Returns timestamped decision records.
829
+
830
+ **Parameters:**
831
+ | Parameter | Type | Required | Description |
832
+ |-----------|------|----------|-------------|
833
+ | options.window | string | No | Time window: "7d" (default), "30d", "90d" |
834
+
835
+ **Returns:** `Promise<{ evidence: Object[], window: string, total: number }>`
836
+
837
+ ---
838
+
839
+ ## Task Routing
840
+
841
+ Route tasks to agents based on capabilities, availability, and workload. Manage the agent pool and monitor routing health.
842
+
843
+ ### claw.listRoutingAgents(filters?)
844
+ List registered routing agents with optional status filter.
845
+
846
+ **Parameters:**
847
+ | Parameter | Type | Required | Description |
848
+ |-----------|------|----------|-------------|
849
+ | filters.status | string | No | Filter by status: available, busy, offline |
850
+
851
+ **Returns:** `Promise<{ agents: Object[], total: number }>`
852
+
853
+ ### claw.registerRoutingAgent(agent)
854
+ Register a new agent in the routing pool.
855
+
856
+ **Parameters:**
857
+ | Parameter | Type | Required | Description |
858
+ |-----------|------|----------|-------------|
859
+ | name | string | Yes | Agent display name |
860
+ | capabilities | string[] | No | List of skills/capabilities |
861
+ | maxConcurrent | number | No | Max concurrent tasks (default: 1) |
862
+ | endpoint | string | No | Agent callback endpoint URL |
863
+
864
+ **Returns:** `Promise<{ agent: Object, agent_id: string }>`
865
+
866
+ ### claw.getRoutingAgent(agentId)
867
+ Get a single routing agent with current metrics.
868
+
869
+ **Parameters:**
870
+ | Parameter | Type | Required | Description |
871
+ |-----------|------|----------|-------------|
872
+ | agentId | string | Yes | The routing agent ID |
873
+
874
+ **Returns:** `Promise<{ agent: Object, metrics: Object }>`
875
+
876
+ ### claw.updateRoutingAgentStatus(agentId, status)
877
+ Update a routing agent's availability status.
878
+
879
+ **Parameters:**
880
+ | Parameter | Type | Required | Description |
881
+ |-----------|------|----------|-------------|
882
+ | agentId | string | Yes | The routing agent ID |
883
+ | status | string | Yes | New status: available, busy, offline |
884
+
885
+ **Returns:** `Promise<{ agent: Object }>`
886
+
887
+ ### claw.deleteRoutingAgent(agentId)
888
+ Remove an agent from the routing pool.
889
+
890
+ **Parameters:**
891
+ | Parameter | Type | Required | Description |
892
+ |-----------|------|----------|-------------|
893
+ | agentId | string | Yes | The routing agent ID |
894
+
895
+ **Returns:** `Promise<{ deleted: boolean, id: string }>`
896
+
897
+ ### claw.listRoutingTasks(filters?)
898
+ List routing tasks with optional filters.
899
+
900
+ **Parameters:**
901
+ | Parameter | Type | Required | Description |
902
+ |-----------|------|----------|-------------|
903
+ | filters.status | string | No | Filter by status: pending, assigned, completed, failed |
904
+ | filters.agent_id | string | No | Filter by assigned agent |
905
+ | filters.limit | number | No | Max results (default: 50) |
906
+ | filters.offset | number | No | Pagination offset |
907
+
908
+ **Returns:** `Promise<{ tasks: Object[], total: number }>`
909
+
910
+ ### claw.submitRoutingTask(task)
911
+ Submit a task for automatic routing to the best available agent.
912
+
913
+ **Parameters:**
914
+ | Parameter | Type | Required | Description |
915
+ |-----------|------|----------|-------------|
916
+ | title | string | Yes | Task title |
917
+ | description | string | No | Detailed description |
918
+ | requiredSkills | string[] | No | Skills needed to handle this task |
919
+ | urgency | string | No | low, medium, high, critical (default: medium) |
920
+ | timeoutSeconds | number | No | Task timeout in seconds |
921
+ | maxRetries | number | No | Max retry attempts on failure |
922
+ | callbackUrl | string | No | URL to notify on completion |
923
+
924
+ **Returns:** `Promise<{ task: Object, task_id: string, assigned_agent: Object|null }>`
925
+
926
+ **Example:**
927
+ ```javascript
928
+ const { task_id, assigned_agent } = await claw.submitRoutingTask({
929
+ title: 'Analyze quarterly metrics',
930
+ description: 'Pull Q4 data and generate summary report',
931
+ requiredSkills: ['data-analysis', 'reporting'],
932
+ urgency: 'high',
933
+ timeoutSeconds: 600,
934
+ callbackUrl: 'https://hooks.example.com/task-done',
935
+ });
936
+ console.log(`Task ${task_id} assigned to ${assigned_agent?.name ?? 'queue'}`);
937
+ ```
938
+
939
+ ### claw.completeRoutingTask(taskId, result?)
940
+ Mark a routing task as completed with optional result payload.
941
+
942
+ **Parameters:**
943
+ | Parameter | Type | Required | Description |
944
+ |-----------|------|----------|-------------|
945
+ | taskId | string | Yes | The task ID |
946
+ | result | Object | No | Task result data |
947
+
948
+ **Returns:** `Promise<{ task: Object }>`
949
+
950
+ ### claw.getRoutingStats()
951
+ Get aggregate routing statistics (throughput, latency, agent utilization).
952
+
953
+ **Returns:** `Promise<{ stats: Object }>`
954
+
955
+ ### claw.getRoutingHealth()
956
+ Get routing system health status and diagnostics.
957
+
958
+ **Returns:** `Promise<{ healthy: boolean, agents: Object, tasks: Object, latency: Object }>`
959
+
960
+ ---
961
+
737
962
  ## Error Handling
738
963
 
739
964
  All SDK methods throw on non-2xx responses. Errors include `status` (HTTP code) and `details` (when available).
package/dashclaw.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Full-featured agent toolkit for the DashClaw platform.
4
4
  * Zero-dependency ESM SDK — requires Node 18+ (native fetch).
5
5
  *
6
- * 60+ methods across 13+ categories:
6
+ * 78+ methods across 16+ categories:
7
7
  * - Action Recording (7)
8
8
  * - Loops & Assumptions (7)
9
9
  * - Signals (1)
@@ -17,6 +17,9 @@
17
17
  * - Agent Messaging (9)
18
18
  * - Behavior Guard (2)
19
19
  * - Bulk Sync (1)
20
+ * - Policy Testing (3)
21
+ * - Compliance Engine (5)
22
+ * - Task Routing (10)
20
23
  */
21
24
 
22
25
  class DashClaw {
@@ -1533,6 +1536,217 @@ class DashClaw {
1533
1536
  return this._request(`/api/guard?${params}`, 'GET');
1534
1537
  }
1535
1538
 
1539
+ // ══════════════════════════════════════════════════════════
1540
+ // Category 14: Policy Testing (3 methods)
1541
+ // ══════════════════════════════════════════════════════════
1542
+
1543
+ /**
1544
+ * Run guardrails tests against all active policies for this org.
1545
+ * @returns {Promise<{success: boolean, total_policies: number, total_tests: number, passed: number, failed: number, details: Object[]}>}
1546
+ */
1547
+ async testPolicies() {
1548
+ return this._request('/api/policies/test', 'POST', {
1549
+ agent_id: this.agentId,
1550
+ });
1551
+ }
1552
+
1553
+ /**
1554
+ * Generate a compliance proof report from active policies.
1555
+ * @param {Object} [options]
1556
+ * @param {string} [options.format='json'] - 'json' or 'md'
1557
+ * @returns {Promise<Object|string>}
1558
+ */
1559
+ async getProofReport(options = {}) {
1560
+ const params = new URLSearchParams();
1561
+ if (options.format) params.set('format', options.format);
1562
+ return this._request(`/api/policies/proof?${params}`, 'GET');
1563
+ }
1564
+
1565
+ /**
1566
+ * Import a policy pack or raw YAML into the org's guard policies.
1567
+ * Requires admin role.
1568
+ * @param {Object} options
1569
+ * @param {string} [options.pack] - Pack name: enterprise-strict, smb-safe, startup-growth, development
1570
+ * @param {string} [options.yaml] - Raw YAML string of policies to import
1571
+ * @returns {Promise<{imported: number, skipped: number, errors: string[], policies: Object[]}>}
1572
+ */
1573
+ async importPolicies({ pack, yaml } = {}) {
1574
+ return this._request('/api/policies/import', 'POST', { pack, yaml });
1575
+ }
1576
+
1577
+ // ══════════════════════════════════════════════════════════
1578
+ // Category 15: Compliance Engine (5 methods)
1579
+ // ══════════════════════════════════════════════════════════
1580
+
1581
+ /**
1582
+ * Map active policies to a compliance framework's controls.
1583
+ * @param {string} framework - Framework ID: soc2, iso27001, gdpr, nist-ai-rmf, imda-agentic
1584
+ * @returns {Promise<Object>} Compliance map with controls, coverage, and gaps
1585
+ */
1586
+ async mapCompliance(framework) {
1587
+ return this._request(`/api/compliance/map?framework=${encodeURIComponent(framework)}`, 'GET');
1588
+ }
1589
+
1590
+ /**
1591
+ * Run gap analysis on a compliance framework mapping.
1592
+ * @param {string} framework - Framework ID
1593
+ * @returns {Promise<Object>} Gap analysis with remediation plan and risk assessment
1594
+ */
1595
+ async analyzeGaps(framework) {
1596
+ return this._request(`/api/compliance/gaps?framework=${encodeURIComponent(framework)}`, 'GET');
1597
+ }
1598
+
1599
+ /**
1600
+ * Generate a full compliance report (markdown or JSON) and save a snapshot.
1601
+ * @param {string} framework - Framework ID
1602
+ * @param {Object} [options]
1603
+ * @param {string} [options.format='json'] - 'json' or 'md'
1604
+ * @returns {Promise<Object>}
1605
+ */
1606
+ async getComplianceReport(framework, options = {}) {
1607
+ const params = new URLSearchParams({ framework });
1608
+ if (options.format) params.set('format', options.format);
1609
+ return this._request(`/api/compliance/report?${params}`, 'GET');
1610
+ }
1611
+
1612
+ /**
1613
+ * List available compliance frameworks.
1614
+ * @returns {Promise<{frameworks: Object[]}>}
1615
+ */
1616
+ async listFrameworks() {
1617
+ return this._request('/api/compliance/frameworks', 'GET');
1618
+ }
1619
+
1620
+ /**
1621
+ * Get live compliance evidence from guard decisions and action records.
1622
+ * @param {Object} [options]
1623
+ * @param {string} [options.window='30d'] - Time window (e.g., '7d', '30d', '90d')
1624
+ * @returns {Promise<{evidence: Object}>}
1625
+ */
1626
+ async getComplianceEvidence(options = {}) {
1627
+ const params = new URLSearchParams();
1628
+ if (options.window) params.set('window', options.window);
1629
+ return this._request(`/api/compliance/evidence?${params}`, 'GET');
1630
+ }
1631
+
1632
+ // ══════════════════════════════════════════════════════════
1633
+ // Category 16: Task Routing (10 methods)
1634
+ // ══════════════════════════════════════════════════════════
1635
+
1636
+ /**
1637
+ * List routing agents registered in this org.
1638
+ * @param {Object} [filters]
1639
+ * @param {string} [filters.status] - Filter by status: available, busy, offline
1640
+ * @returns {Promise<{agents: Object[]}>}
1641
+ */
1642
+ async listRoutingAgents(filters = {}) {
1643
+ const params = new URLSearchParams();
1644
+ if (filters.status) params.set('status', filters.status);
1645
+ return this._request(`/api/routing/agents?${params}`, 'GET');
1646
+ }
1647
+
1648
+ /**
1649
+ * Register an agent for task routing.
1650
+ * @param {Object} agent
1651
+ * @param {string} agent.name - Agent name
1652
+ * @param {Array} [agent.capabilities] - Skills/capabilities (strings or {skill, priority} objects)
1653
+ * @param {number} [agent.maxConcurrent=3] - Max concurrent tasks
1654
+ * @param {string} [agent.endpoint] - Webhook endpoint for task dispatch
1655
+ * @returns {Promise<{agent: Object}>}
1656
+ */
1657
+ async registerRoutingAgent(agent) {
1658
+ return this._request('/api/routing/agents', 'POST', agent);
1659
+ }
1660
+
1661
+ /**
1662
+ * Get a single routing agent by ID.
1663
+ * @param {string} agentId - Routing agent ID
1664
+ * @returns {Promise<{agent: Object, metrics: Object[]}>}
1665
+ */
1666
+ async getRoutingAgent(agentId) {
1667
+ return this._request(`/api/routing/agents/${encodeURIComponent(agentId)}`, 'GET');
1668
+ }
1669
+
1670
+ /**
1671
+ * Update routing agent status.
1672
+ * @param {string} agentId - Routing agent ID
1673
+ * @param {string} status - New status: available, busy, offline
1674
+ * @returns {Promise<{agent: Object}>}
1675
+ */
1676
+ async updateRoutingAgentStatus(agentId, status) {
1677
+ return this._request(`/api/routing/agents/${encodeURIComponent(agentId)}`, 'PATCH', { status });
1678
+ }
1679
+
1680
+ /**
1681
+ * Unregister (delete) a routing agent.
1682
+ * @param {string} agentId - Routing agent ID
1683
+ * @returns {Promise<{deleted: Object}>}
1684
+ */
1685
+ async deleteRoutingAgent(agentId) {
1686
+ return this._request(`/api/routing/agents/${encodeURIComponent(agentId)}`, 'DELETE');
1687
+ }
1688
+
1689
+ /**
1690
+ * List routing tasks with optional filters.
1691
+ * @param {Object} [filters]
1692
+ * @param {string} [filters.status] - Filter by status
1693
+ * @param {string} [filters.assignedTo] - Filter by assigned agent
1694
+ * @param {number} [filters.limit=50] - Max results
1695
+ * @returns {Promise<{tasks: Object[]}>}
1696
+ */
1697
+ async listRoutingTasks(filters = {}) {
1698
+ const params = new URLSearchParams();
1699
+ if (filters.status) params.set('status', filters.status);
1700
+ if (filters.assignedTo) params.set('assigned_to', filters.assignedTo);
1701
+ if (filters.limit) params.set('limit', String(filters.limit));
1702
+ return this._request(`/api/routing/tasks?${params}`, 'GET');
1703
+ }
1704
+
1705
+ /**
1706
+ * Submit a task for auto-routing to the best available agent.
1707
+ * @param {Object} task
1708
+ * @param {string} task.title - Task title
1709
+ * @param {string} [task.description] - Task description
1710
+ * @param {string[]} [task.requiredSkills] - Skills needed to complete this task
1711
+ * @param {string} [task.urgency='normal'] - Urgency: low, normal, high, critical
1712
+ * @param {number} [task.timeoutSeconds=3600] - Timeout in seconds
1713
+ * @param {number} [task.maxRetries=2] - Max retry attempts
1714
+ * @param {string} [task.callbackUrl] - Webhook URL for task completion callback
1715
+ * @returns {Promise<{task: Object, routing: Object}>}
1716
+ */
1717
+ async submitRoutingTask(task) {
1718
+ return this._request('/api/routing/tasks', 'POST', task);
1719
+ }
1720
+
1721
+ /**
1722
+ * Complete a routing task.
1723
+ * @param {string} taskId - Task ID
1724
+ * @param {Object} [result]
1725
+ * @param {boolean} [result.success=true] - Whether task succeeded
1726
+ * @param {Object} [result.result] - Task result data
1727
+ * @param {string} [result.error] - Error message if failed
1728
+ * @returns {Promise<{task: Object, routing: Object}>}
1729
+ */
1730
+ async completeRoutingTask(taskId, result = {}) {
1731
+ return this._request(`/api/routing/tasks/${encodeURIComponent(taskId)}/complete`, 'POST', result);
1732
+ }
1733
+
1734
+ /**
1735
+ * Get routing statistics for the org.
1736
+ * @returns {Promise<{agents: Object, tasks: Object, routing: Object}>}
1737
+ */
1738
+ async getRoutingStats() {
1739
+ return this._request('/api/routing/stats', 'GET');
1740
+ }
1741
+
1742
+ /**
1743
+ * Get routing system health status.
1744
+ * @returns {Promise<{status: string, agents: Object, tasks: Object}>}
1745
+ */
1746
+ async getRoutingHealth() {
1747
+ return this._request('/api/routing/health', 'GET');
1748
+ }
1749
+
1536
1750
  // ─── Bulk Sync ────────────────────────────────────────────
1537
1751
 
1538
1752
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dashclaw",
3
- "version": "1.7.2",
4
- "description": "Full-featured agent toolkit for the DashClaw platform. 60+ methods for action recording, context management, session handoffs, security scanning, behavior guard, bulk sync, and more.",
3
+ "version": "1.8.0",
4
+ "description": "Full-featured agent toolkit for the DashClaw platform. 78+ methods for action recording, context management, session handoffs, security scanning, behavior guard, compliance, task routing, bulk sync, and more.",
5
5
  "type": "module",
6
6
  "publishConfig": {
7
7
  "access": "public"