@axonflow/sdk 4.1.0 → 4.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/README.md +1 -1
- package/dist/cjs/adapters/langgraph.d.ts +284 -0
- package/dist/cjs/adapters/langgraph.d.ts.map +1 -0
- package/dist/cjs/adapters/langgraph.js +364 -0
- package/dist/cjs/adapters/langgraph.js.map +1 -0
- package/dist/cjs/client.d.ts +82 -2
- package/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/client.js +173 -2
- 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/telemetry.js +1 -1
- package/dist/cjs/telemetry.js.map +1 -1
- package/dist/cjs/types/gateway.d.ts +65 -0
- package/dist/cjs/types/gateway.d.ts.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/adapters/langgraph.d.ts +284 -0
- package/dist/esm/adapters/langgraph.d.ts.map +1 -0
- package/dist/esm/adapters/langgraph.js +358 -0
- package/dist/esm/adapters/langgraph.js.map +1 -0
- package/dist/esm/client.d.ts +82 -2
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +173 -2
- 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 +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/telemetry.js +1 -1
- package/dist/esm/telemetry.js.map +1 -1
- package/dist/esm/types/gateway.d.ts +65 -0
- package/dist/esm/types/gateway.d.ts.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +1 -1
package/dist/esm/client.js
CHANGED
|
@@ -153,12 +153,12 @@ export class AxonFlow {
|
|
|
153
153
|
* });
|
|
154
154
|
* ```
|
|
155
155
|
*
|
|
156
|
-
* See: https://docs.getaxonflow.com/sdk/gateway-mode
|
|
156
|
+
* See: https://docs.getaxonflow.com/docs/sdk/gateway-mode
|
|
157
157
|
*/
|
|
158
158
|
async protect(aiCall) {
|
|
159
159
|
console.warn('[AxonFlow] protect() is deprecated and will be removed in a future version. ' +
|
|
160
160
|
'Use Gateway Mode (getPolicyApprovedContext + auditLLMCall) or Proxy Mode (proxyLLMCall) instead. ' +
|
|
161
|
-
'See: https://docs.getaxonflow.com/sdk/gateway-mode');
|
|
161
|
+
'See: https://docs.getaxonflow.com/docs/sdk/gateway-mode');
|
|
162
162
|
try {
|
|
163
163
|
// Extract request details from the AI call
|
|
164
164
|
const aiRequest = await this.extractRequest(aiCall);
|
|
@@ -1495,6 +1495,177 @@ export class AxonFlow {
|
|
|
1495
1495
|
};
|
|
1496
1496
|
}
|
|
1497
1497
|
// ============================================================================
|
|
1498
|
+
// Circuit Breaker Observability Methods
|
|
1499
|
+
// ============================================================================
|
|
1500
|
+
/**
|
|
1501
|
+
* Get all active circuit breaker circuits.
|
|
1502
|
+
*
|
|
1503
|
+
* Returns the current state of all open/half-open circuits across
|
|
1504
|
+
* the platform, including emergency stop status.
|
|
1505
|
+
*
|
|
1506
|
+
* @returns Promise resolving to circuit breaker status
|
|
1507
|
+
*
|
|
1508
|
+
* @example
|
|
1509
|
+
* ```typescript
|
|
1510
|
+
* const status = await axonflow.getCircuitBreakerStatus();
|
|
1511
|
+
* console.log(`Active circuits: ${status.count}`);
|
|
1512
|
+
* console.log(`Emergency stop: ${status.emergencyStopActive}`);
|
|
1513
|
+
* for (const circuit of status.activeCircuits) {
|
|
1514
|
+
* console.log(`${circuit.scope}/${circuit.scopeId}: ${circuit.state}`);
|
|
1515
|
+
* }
|
|
1516
|
+
* ```
|
|
1517
|
+
*/
|
|
1518
|
+
async getCircuitBreakerStatus() {
|
|
1519
|
+
const response = await this.orchestratorRequest('GET', '/api/v1/circuit-breaker/status');
|
|
1520
|
+
const data = response.data;
|
|
1521
|
+
return {
|
|
1522
|
+
activeCircuits: (data.active_circuits || []).map(c => ({
|
|
1523
|
+
id: c.id,
|
|
1524
|
+
scope: c.scope,
|
|
1525
|
+
scopeId: c.scope_id,
|
|
1526
|
+
orgId: c.org_id,
|
|
1527
|
+
state: c.state,
|
|
1528
|
+
tripReason: c.trip_reason,
|
|
1529
|
+
trippedBy: c.tripped_by,
|
|
1530
|
+
trippedAt: c.tripped_at,
|
|
1531
|
+
expiresAt: c.expires_at,
|
|
1532
|
+
errorCount: c.error_count,
|
|
1533
|
+
violationCount: c.violation_count,
|
|
1534
|
+
})),
|
|
1535
|
+
count: data.count,
|
|
1536
|
+
emergencyStopActive: data.emergency_stop_active,
|
|
1537
|
+
};
|
|
1538
|
+
}
|
|
1539
|
+
/**
|
|
1540
|
+
* Get circuit breaker history for audit trail.
|
|
1541
|
+
*
|
|
1542
|
+
* Returns historical circuit breaker events including trips, resets,
|
|
1543
|
+
* and manual interventions. Useful for compliance reporting.
|
|
1544
|
+
*
|
|
1545
|
+
* @param limit - Maximum number of history entries to return
|
|
1546
|
+
* @returns Promise resolving to circuit breaker history
|
|
1547
|
+
*
|
|
1548
|
+
* @example
|
|
1549
|
+
* ```typescript
|
|
1550
|
+
* const history = await axonflow.getCircuitBreakerHistory(50);
|
|
1551
|
+
* for (const entry of history.history) {
|
|
1552
|
+
* console.log(`${entry.trippedAt}: ${entry.scope}/${entry.scopeId} - ${entry.state}`);
|
|
1553
|
+
* }
|
|
1554
|
+
* ```
|
|
1555
|
+
*/
|
|
1556
|
+
async getCircuitBreakerHistory(limit) {
|
|
1557
|
+
const params = new URLSearchParams();
|
|
1558
|
+
if (limit !== undefined)
|
|
1559
|
+
params.set('limit', String(limit));
|
|
1560
|
+
const queryString = params.toString();
|
|
1561
|
+
const path = `/api/v1/circuit-breaker/history${queryString ? `?${queryString}` : ''}`;
|
|
1562
|
+
const response = await this.orchestratorRequest('GET', path);
|
|
1563
|
+
const data = response.data;
|
|
1564
|
+
return {
|
|
1565
|
+
history: (data.history || []).map(h => ({
|
|
1566
|
+
id: h.id,
|
|
1567
|
+
orgId: h.org_id,
|
|
1568
|
+
scope: h.scope,
|
|
1569
|
+
scopeId: h.scope_id,
|
|
1570
|
+
state: h.state,
|
|
1571
|
+
tripReason: h.trip_reason,
|
|
1572
|
+
trippedBy: h.tripped_by,
|
|
1573
|
+
trippedByEmail: h.tripped_by_email,
|
|
1574
|
+
tripComment: h.trip_comment,
|
|
1575
|
+
trippedAt: h.tripped_at,
|
|
1576
|
+
expiresAt: h.expires_at,
|
|
1577
|
+
resetBy: h.reset_by,
|
|
1578
|
+
resetAt: h.reset_at,
|
|
1579
|
+
errorCount: h.error_count,
|
|
1580
|
+
violationCount: h.violation_count,
|
|
1581
|
+
})),
|
|
1582
|
+
count: data.count,
|
|
1583
|
+
};
|
|
1584
|
+
}
|
|
1585
|
+
/**
|
|
1586
|
+
* Get circuit breaker config (global or tenant-specific).
|
|
1587
|
+
*
|
|
1588
|
+
* Returns the effective circuit breaker configuration, including
|
|
1589
|
+
* any tenant-specific overrides.
|
|
1590
|
+
*
|
|
1591
|
+
* @param tenantId - Optional tenant ID to get tenant-specific config
|
|
1592
|
+
* @returns Promise resolving to circuit breaker config
|
|
1593
|
+
*
|
|
1594
|
+
* @example
|
|
1595
|
+
* ```typescript
|
|
1596
|
+
* // Get global config
|
|
1597
|
+
* const globalConfig = await axonflow.getCircuitBreakerConfig();
|
|
1598
|
+
* console.log(`Error threshold: ${globalConfig.errorThreshold}`);
|
|
1599
|
+
*
|
|
1600
|
+
* // Get tenant-specific config
|
|
1601
|
+
* const tenantConfig = await axonflow.getCircuitBreakerConfig('tenant-123');
|
|
1602
|
+
* ```
|
|
1603
|
+
*/
|
|
1604
|
+
async getCircuitBreakerConfig(tenantId) {
|
|
1605
|
+
const params = new URLSearchParams();
|
|
1606
|
+
if (tenantId !== undefined)
|
|
1607
|
+
params.set('tenant_id', tenantId);
|
|
1608
|
+
const queryString = params.toString();
|
|
1609
|
+
const path = `/api/v1/circuit-breaker/config${queryString ? `?${queryString}` : ''}`;
|
|
1610
|
+
const response = await this.orchestratorRequest('GET', path);
|
|
1611
|
+
const data = response.data;
|
|
1612
|
+
return {
|
|
1613
|
+
source: data.source,
|
|
1614
|
+
errorThreshold: data.error_threshold,
|
|
1615
|
+
violationThreshold: data.violation_threshold,
|
|
1616
|
+
windowSeconds: data.window_seconds,
|
|
1617
|
+
defaultTimeoutSeconds: data.default_timeout_seconds,
|
|
1618
|
+
maxTimeoutSeconds: data.max_timeout_seconds,
|
|
1619
|
+
enableAutoRecovery: data.enable_auto_recovery,
|
|
1620
|
+
tenantId: data.tenant_id,
|
|
1621
|
+
overrides: data.overrides,
|
|
1622
|
+
};
|
|
1623
|
+
}
|
|
1624
|
+
/**
|
|
1625
|
+
* Update per-tenant circuit breaker config.
|
|
1626
|
+
*
|
|
1627
|
+
* Allows customizing circuit breaker thresholds for a specific tenant.
|
|
1628
|
+
* Only provided fields will be updated; others retain their current values.
|
|
1629
|
+
*
|
|
1630
|
+
* @param config - Configuration update with tenant ID and fields to change
|
|
1631
|
+
* @returns Promise resolving to confirmation with tenant ID and message
|
|
1632
|
+
*
|
|
1633
|
+
* @example
|
|
1634
|
+
* ```typescript
|
|
1635
|
+
* const result = await axonflow.updateCircuitBreakerConfig({
|
|
1636
|
+
* tenantId: 'tenant-123',
|
|
1637
|
+
* errorThreshold: 10,
|
|
1638
|
+
* windowSeconds: 120,
|
|
1639
|
+
* });
|
|
1640
|
+
* console.log(result.message); // "config updated"
|
|
1641
|
+
* ```
|
|
1642
|
+
*/
|
|
1643
|
+
async updateCircuitBreakerConfig(config) {
|
|
1644
|
+
if (!config.tenantId) {
|
|
1645
|
+
throw new ConfigurationError('tenantId is required');
|
|
1646
|
+
}
|
|
1647
|
+
const body = {
|
|
1648
|
+
tenant_id: config.tenantId,
|
|
1649
|
+
};
|
|
1650
|
+
if (config.errorThreshold !== undefined)
|
|
1651
|
+
body.error_threshold = config.errorThreshold;
|
|
1652
|
+
if (config.violationThreshold !== undefined)
|
|
1653
|
+
body.violation_threshold = config.violationThreshold;
|
|
1654
|
+
if (config.windowSeconds !== undefined)
|
|
1655
|
+
body.window_seconds = config.windowSeconds;
|
|
1656
|
+
if (config.defaultTimeoutSeconds !== undefined)
|
|
1657
|
+
body.default_timeout_seconds = config.defaultTimeoutSeconds;
|
|
1658
|
+
if (config.maxTimeoutSeconds !== undefined)
|
|
1659
|
+
body.max_timeout_seconds = config.maxTimeoutSeconds;
|
|
1660
|
+
if (config.enableAutoRecovery !== undefined)
|
|
1661
|
+
body.enable_auto_recovery = config.enableAutoRecovery;
|
|
1662
|
+
const response = await this.orchestratorRequest('PUT', '/api/v1/circuit-breaker/config', body);
|
|
1663
|
+
return {
|
|
1664
|
+
tenantId: response.data.tenant_id,
|
|
1665
|
+
message: response.data.message,
|
|
1666
|
+
};
|
|
1667
|
+
}
|
|
1668
|
+
// ============================================================================
|
|
1498
1669
|
// Audit Log Read Methods
|
|
1499
1670
|
// ============================================================================
|
|
1500
1671
|
/**
|