@astrasyncai/verification-gateway 5.4.0 → 5.4.2
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/adapter-interface/interface.d.mts +2 -3
- package/dist/adapter-interface/interface.d.ts +2 -3
- package/dist/adapters/express.d.mts +63 -4
- package/dist/adapters/express.d.ts +63 -4
- package/dist/adapters/express.js +9 -2
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +9 -2
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/mcp.d.mts +396 -4
- package/dist/adapters/mcp.d.ts +396 -4
- package/dist/adapters/mcp.js +9 -2
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +9 -2
- package/dist/adapters/mcp.mjs.map +1 -1
- package/dist/adapters/nextjs.d.mts +22 -4
- package/dist/adapters/nextjs.d.ts +22 -4
- package/dist/adapters/nextjs.js +9 -2
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +9 -2
- package/dist/adapters/nextjs.mjs.map +1 -1
- package/dist/adapters/sdk.d.mts +157 -3
- package/dist/adapters/sdk.d.ts +157 -3
- package/dist/adapters/sdk.js +35 -15
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +35 -15
- package/dist/adapters/sdk.mjs.map +1 -1
- package/dist/agent/index.d.mts +224 -3
- package/dist/agent/index.d.ts +224 -3
- package/dist/agent/index.js +1 -1
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/index.mjs +1 -1
- package/dist/agent/index.mjs.map +1 -1
- package/dist/bin/astrasync-claude-hook.js +9 -2
- package/dist/bin/astrasync-codex-hook.js +9 -2
- package/dist/bin/astrasync-guard.js +9 -2
- package/dist/bin/astrasync.js +9 -2
- package/dist/browser/background.js +9 -2
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +9 -2
- package/dist/browser/background.mjs.map +1 -1
- package/dist/browser/browser-adapter.d.mts +1 -5
- package/dist/browser/browser-adapter.d.ts +1 -5
- package/dist/claude-code/claude-code-adapter.d.mts +1 -5
- package/dist/claude-code/claude-code-adapter.d.ts +1 -5
- package/dist/cli/index.d.mts +1 -5
- package/dist/cli/index.d.ts +1 -5
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +1 -1
- package/dist/cli/index.mjs.map +1 -1
- package/dist/codex/index.d.mts +1 -5
- package/dist/codex/index.d.ts +1 -5
- package/dist/codex/index.js +9 -2
- package/dist/codex/index.js.map +1 -1
- package/dist/codex/index.mjs +9 -2
- package/dist/codex/index.mjs.map +1 -1
- package/dist/cursor/cursor-adapter.d.mts +1 -5
- package/dist/cursor/cursor-adapter.d.ts +1 -5
- package/dist/cursor/extension.d.mts +1 -5
- package/dist/cursor/extension.d.ts +1 -5
- package/dist/cursor/extension.js +9 -2
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +9 -2
- package/dist/cursor/extension.mjs.map +1 -1
- package/dist/edge-config.d.mts +1 -1
- package/dist/edge-config.d.ts +1 -1
- package/dist/edge-config.js +1 -1
- package/dist/edge-config.js.map +1 -1
- package/dist/edge-config.mjs +1 -1
- package/dist/edge-config.mjs.map +1 -1
- package/dist/edge-core/index.d.mts +1 -1
- package/dist/edge-core/index.d.ts +1 -1
- package/dist/edge-core/index.js +9 -2
- package/dist/edge-core/index.js.map +1 -1
- package/dist/edge-core/index.mjs +9 -2
- package/dist/edge-core/index.mjs.map +1 -1
- package/dist/gateway/gateway.d.mts +2 -3
- package/dist/gateway/gateway.d.ts +2 -3
- package/dist/gateway/gateway.js +9 -2
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +9 -2
- package/dist/gateway/gateway.mjs.map +1 -1
- package/dist/git-trigger/git-hooks.d.mts +253 -3
- package/dist/git-trigger/git-hooks.d.ts +253 -3
- package/dist/index.d.mts +4506 -42
- package/dist/index.d.ts +4506 -42
- package/dist/index.js +35 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -15
- package/dist/index.mjs.map +1 -1
- package/dist/interface-q1WrMsB1.d.mts +365 -0
- package/dist/interface-q1WrMsB1.d.ts +365 -0
- package/dist/local-evaluator/evaluator.d.mts +2 -3
- package/dist/local-evaluator/evaluator.d.ts +2 -3
- package/dist/registration/index.js +1 -1
- package/dist/registration/index.js.map +1 -1
- package/dist/registration/index.mjs +1 -1
- package/dist/registration/index.mjs.map +1 -1
- package/dist/transport/index.d.mts +1324 -4
- package/dist/transport/index.d.ts +1324 -4
- package/dist/transport/index.js +1 -1
- package/dist/transport/index.js.map +1 -1
- package/dist/transport/index.mjs +1 -1
- package/dist/transport/index.mjs.map +1 -1
- package/dist/{types-DGh2akuh.d.ts → types-BRz2U0Pn.d.ts} +2 -2
- package/dist/{types-76TB0fxW.d.ts → types-BU04qAAR.d.mts} +59 -213
- package/dist/{types-CD1F9fmp.d.mts → types-BU04qAAR.d.ts} +59 -213
- package/dist/types-Bd2O3eX1.d.mts +769 -0
- package/dist/types-BfILnheI.d.mts +189 -0
- package/dist/types-BfILnheI.d.ts +189 -0
- package/dist/{types-z_RNjHWm.d.mts → types-CfBpm3w5.d.mts} +2 -2
- package/dist/types-DMChboN_.d.ts +769 -0
- package/dist/ui/index.d.mts +1 -2
- package/dist/ui/index.d.ts +1 -2
- package/dist/verify.d.mts +1 -1
- package/dist/verify.d.ts +1 -1
- package/dist/verify.js +9 -2
- package/dist/verify.js.map +1 -1
- package/dist/verify.mjs +9 -2
- package/dist/verify.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/express-BIAT2pe0.d.mts +0 -69
- package/dist/express-D3Tf-b23.d.ts +0 -69
- package/dist/index-BVJkTyIF.d.mts +0 -248
- package/dist/index-By021oSN.d.mts +0 -1469
- package/dist/index-DaMXZabg.d.ts +0 -248
- package/dist/index-iJ9_DdLk.d.ts +0 -1469
- package/dist/mcp-BqfTDZLh.d.mts +0 -397
- package/dist/mcp-OrVOrH-s.d.ts +0 -397
- package/dist/nextjs-DGJXzWst.d.mts +0 -28
- package/dist/nextjs-xM-jdNrX.d.ts +0 -28
- package/dist/sdk-C1IOA5LE.d.ts +0 -173
- package/dist/sdk-C6_-6D-9.d.mts +0 -173
|
@@ -1,8 +1,258 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { V as VerificationDecision, P as PDLSSContext } from '../types-z_RNjHWm.mjs';
|
|
3
|
-
import '../types-CD1F9fmp.mjs';
|
|
1
|
+
import { T as TokenGuidance, b as CounterpartyType } from '../types-Bd2O3eX1.mjs';
|
|
4
2
|
import '../metadata-capture.mjs';
|
|
5
3
|
|
|
4
|
+
/**
|
|
5
|
+
* AstraSync Gateway - Types for gateway modes, local evaluation, and adapter interface.
|
|
6
|
+
*/
|
|
7
|
+
type GatewayMode = 'online' | 'local' | 'hybrid';
|
|
8
|
+
/**
|
|
9
|
+
* Posture controls whether the gateway actively blocks or just monitors.
|
|
10
|
+
* - active: Evaluate and enforce decisions (block/allow/review)
|
|
11
|
+
* - passive: Evaluate and log but never block (telemetry-only mode)
|
|
12
|
+
*/
|
|
13
|
+
type GatewayPosture = 'active' | 'passive';
|
|
14
|
+
interface AstraSyncGatewayConfig {
|
|
15
|
+
mode: GatewayMode;
|
|
16
|
+
/** Enforcement posture: 'active' blocks actions, 'passive' logs only (default: 'active') */
|
|
17
|
+
posture?: GatewayPosture;
|
|
18
|
+
/** AstraSync API base URL (required for online/hybrid modes) */
|
|
19
|
+
apiBaseUrl?: string;
|
|
20
|
+
/** API key for authenticating with AstraSync (required for online/hybrid modes) */
|
|
21
|
+
apiKey?: string;
|
|
22
|
+
/**
|
|
23
|
+
* ASTRA- agent id this gateway acts as. Attached to hybrid sync entries and
|
|
24
|
+
* used as the default identity for online verification when the caller
|
|
25
|
+
* passes no per-call astraId.
|
|
26
|
+
*/
|
|
27
|
+
agentId?: string;
|
|
28
|
+
/** Path to local PDLSS policy YAML file (required for local/hybrid modes) */
|
|
29
|
+
policyFile?: string;
|
|
30
|
+
/** Inline policy object (alternative to policyFile) */
|
|
31
|
+
policy?: LocalPolicy;
|
|
32
|
+
/** Sync interval in seconds for hybrid mode (default: 3600) */
|
|
33
|
+
syncInterval?: number;
|
|
34
|
+
/** Cache verification results TTL in seconds (default: 300) */
|
|
35
|
+
cacheTtl?: number;
|
|
36
|
+
/** Enable debug logging */
|
|
37
|
+
debug?: boolean;
|
|
38
|
+
/** Enable trace logging to .astrasync/traces/ (default: false) */
|
|
39
|
+
traceEnabled?: boolean;
|
|
40
|
+
/** Trace log directory (default: .astrasync/traces/) */
|
|
41
|
+
tracePath?: string;
|
|
42
|
+
/** Minimum trust score for standard access (online/hybrid) */
|
|
43
|
+
minTrustScore?: number;
|
|
44
|
+
/** Minimum trust score for full access (online/hybrid) */
|
|
45
|
+
minTrustScoreForFull?: number;
|
|
46
|
+
/** Custom headers to send with API requests */
|
|
47
|
+
customHeaders?: Record<string, string>;
|
|
48
|
+
/** Counterparty URL for analytics */
|
|
49
|
+
counterpartyUrl?: string;
|
|
50
|
+
/** Counterparty type for analytics */
|
|
51
|
+
counterpartyType?: CounterpartyType;
|
|
52
|
+
}
|
|
53
|
+
interface PDLSSContext {
|
|
54
|
+
/** Purpose category (e.g. email.send, shell.exec, file.read) */
|
|
55
|
+
purpose: string;
|
|
56
|
+
/** Specific action within purpose */
|
|
57
|
+
action: string;
|
|
58
|
+
/** Target resource, recipient, or counterparty */
|
|
59
|
+
target: string;
|
|
60
|
+
/** Types of data access (read, write, delete) */
|
|
61
|
+
dataAccess?: string[];
|
|
62
|
+
/** Network domains/IPs being accessed */
|
|
63
|
+
networkAccess?: string[];
|
|
64
|
+
/** Resource type (customer, order, file, directory, process) */
|
|
65
|
+
resourceType?: string;
|
|
66
|
+
/** Risk factors for this action */
|
|
67
|
+
riskFactors?: RiskFactor[];
|
|
68
|
+
/** Transaction value (if financial) */
|
|
69
|
+
transactionValue?: number;
|
|
70
|
+
/** Currency for transaction */
|
|
71
|
+
currency?: string;
|
|
72
|
+
/** Additional metadata */
|
|
73
|
+
metadata?: Record<string, unknown>;
|
|
74
|
+
}
|
|
75
|
+
interface RiskFactor {
|
|
76
|
+
type: 'financial' | 'data_sensitivity' | 'privilege_escalation' | 'network_scope' | 'destructive';
|
|
77
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
78
|
+
detail: string;
|
|
79
|
+
}
|
|
80
|
+
interface VerificationDecision {
|
|
81
|
+
recommendation: 'ALLOW' | 'DENY' | 'MANUAL_REVIEW';
|
|
82
|
+
reason: string;
|
|
83
|
+
trustScore?: number;
|
|
84
|
+
tokenGuidance?: TokenGuidance;
|
|
85
|
+
sessionId?: string;
|
|
86
|
+
/**
|
|
87
|
+
* PDLSS dimensions that were evaluated. `true` = the dimension was
|
|
88
|
+
* configured in the policy and therefore ran; `false` = the dimension is
|
|
89
|
+
* absent from the policy and was skipped — NOT "failed" (a failed
|
|
90
|
+
* dimension never produces an ALLOW; this field is only set on ALLOW).
|
|
91
|
+
*/
|
|
92
|
+
evaluatedDimensions?: {
|
|
93
|
+
purpose: boolean;
|
|
94
|
+
scope: boolean;
|
|
95
|
+
limits: boolean;
|
|
96
|
+
riskThresholds: boolean;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
interface LocalPolicy {
|
|
100
|
+
version: string;
|
|
101
|
+
name: string;
|
|
102
|
+
description?: string;
|
|
103
|
+
purposes: LocalPurposeRule[];
|
|
104
|
+
scope?: LocalScope;
|
|
105
|
+
limits?: LocalLimits;
|
|
106
|
+
riskThresholds?: LocalRiskThresholds;
|
|
107
|
+
selfInstantiation?: LocalSelfInstantiation;
|
|
108
|
+
}
|
|
109
|
+
interface LocalPurposeRule {
|
|
110
|
+
id: string;
|
|
111
|
+
allowed: boolean;
|
|
112
|
+
targets?: string[];
|
|
113
|
+
blockedPatterns?: string[];
|
|
114
|
+
requiresApproval?: boolean;
|
|
115
|
+
}
|
|
116
|
+
interface LocalScope {
|
|
117
|
+
allowedDomains?: string[];
|
|
118
|
+
blockedDomains?: string[];
|
|
119
|
+
blockedResources?: string[];
|
|
120
|
+
}
|
|
121
|
+
interface LocalLimits {
|
|
122
|
+
/**
|
|
123
|
+
* Autonomous Limit — a transaction value at or below this is granted without
|
|
124
|
+
* escalation. A value in the band `[autonomousThreshold, maxTransactionAmount)`
|
|
125
|
+
* requires human approval (step-up → MANUAL_REVIEW), mirroring the backend
|
|
126
|
+
* `checkWithinLimits` ladder. When omitted there is no autonomous band: every
|
|
127
|
+
* positive value below the Hard Limit is granted (legacy flat-cap behaviour).
|
|
128
|
+
*/
|
|
129
|
+
autonomousThreshold?: number;
|
|
130
|
+
/**
|
|
131
|
+
* Hard Limit — a transaction value at or above this is denied outright. (Named
|
|
132
|
+
* `maxTransactionAmount` for backward compatibility with existing local policy
|
|
133
|
+
* files; it is the SDK equivalent of the backend `approvalThreshold`.)
|
|
134
|
+
*/
|
|
135
|
+
maxTransactionAmount?: number;
|
|
136
|
+
maxRequestsPerHour?: number;
|
|
137
|
+
currency?: string;
|
|
138
|
+
}
|
|
139
|
+
interface LocalRiskThresholds {
|
|
140
|
+
autoAllow: {
|
|
141
|
+
min: number;
|
|
142
|
+
max: number;
|
|
143
|
+
};
|
|
144
|
+
requireApproval: {
|
|
145
|
+
min: number;
|
|
146
|
+
max: number;
|
|
147
|
+
};
|
|
148
|
+
autoBlock: {
|
|
149
|
+
min: number;
|
|
150
|
+
max: number;
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
interface LocalSelfInstantiation {
|
|
154
|
+
/** Whether sub-agent spawning is allowed */
|
|
155
|
+
allowed: boolean;
|
|
156
|
+
/** Maximum depth of sub-agent chain */
|
|
157
|
+
maxDepth?: number;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Hybrid Mode — Local evaluation for speed, async API sync for trust scoring.
|
|
162
|
+
*
|
|
163
|
+
* Immediate: local PDLSS evaluation (< 1ms)
|
|
164
|
+
* Async: queued API verification for audit trail and trust score updates
|
|
165
|
+
*
|
|
166
|
+
* Queue entries are persisted to disk so they survive process restarts.
|
|
167
|
+
*/
|
|
168
|
+
|
|
169
|
+
interface FlushOptions {
|
|
170
|
+
/** Max entries to attempt this flush (default: all pending). */
|
|
171
|
+
limit?: number;
|
|
172
|
+
/**
|
|
173
|
+
* Per-entry time budget in ms. A timed-out entry stays pending (no retry
|
|
174
|
+
* penalty — slow network is not a failure) and ends the flush early.
|
|
175
|
+
* Stateless callers (the Claude Code hook) use this to keep sync off the
|
|
176
|
+
* tool-call critical path.
|
|
177
|
+
*/
|
|
178
|
+
perEntryTimeoutMs?: number;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* AstraSyncGateway — Primary API surface for agent verification.
|
|
183
|
+
*
|
|
184
|
+
* Supports three operational modes:
|
|
185
|
+
* - online: Full API-based verification with trust scoring and audit trail
|
|
186
|
+
* - local: Offline PDLSS evaluation using a local policy file (no account required)
|
|
187
|
+
* - hybrid: Local eval for speed + async API sync for trust scoring
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```typescript
|
|
191
|
+
* // Local mode (free, no account)
|
|
192
|
+
* const gateway = new AstraSyncGateway({ mode: 'local', policyFile: './policy.yaml' });
|
|
193
|
+
* const decision = await gateway.evaluate(context);
|
|
194
|
+
*
|
|
195
|
+
* // Online mode (paid, full features)
|
|
196
|
+
* const gateway = new AstraSyncGateway({ mode: 'online', apiKey: 'key' });
|
|
197
|
+
* const decision = await gateway.evaluate(context);
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
|
|
201
|
+
declare class AstraSyncGateway {
|
|
202
|
+
private config;
|
|
203
|
+
private evaluator;
|
|
204
|
+
private syncQueue;
|
|
205
|
+
private traceLogger;
|
|
206
|
+
private initialized;
|
|
207
|
+
constructor(config: AstraSyncGatewayConfig);
|
|
208
|
+
private validateConfig;
|
|
209
|
+
/**
|
|
210
|
+
* Initialize the gateway (loads policy files, starts sync queues).
|
|
211
|
+
* Called automatically on first evaluate() if not called manually.
|
|
212
|
+
*/
|
|
213
|
+
initialize(): Promise<void>;
|
|
214
|
+
/**
|
|
215
|
+
* Graceful shutdown. Flushes sync queue and cleans up resources.
|
|
216
|
+
* Stateless callers (hooks) pass bounded flush options so sync never
|
|
217
|
+
* sits on a tool call's critical path.
|
|
218
|
+
*/
|
|
219
|
+
shutdown(options?: {
|
|
220
|
+
syncFlush?: FlushOptions;
|
|
221
|
+
}): Promise<void>;
|
|
222
|
+
/**
|
|
223
|
+
* Evaluate an action against the verification policy.
|
|
224
|
+
* Routes to the appropriate mode handler.
|
|
225
|
+
*
|
|
226
|
+
* In passive posture, evaluation runs but always returns ALLOW
|
|
227
|
+
* (the real decision is logged for telemetry).
|
|
228
|
+
*/
|
|
229
|
+
evaluate(context: PDLSSContext, astraId?: string): Promise<VerificationDecision>;
|
|
230
|
+
/**
|
|
231
|
+
* Get the current mode.
|
|
232
|
+
*/
|
|
233
|
+
get mode(): AstraSyncGatewayConfig['mode'];
|
|
234
|
+
/**
|
|
235
|
+
* Get the current posture (active or passive).
|
|
236
|
+
*/
|
|
237
|
+
get posture(): 'active' | 'passive';
|
|
238
|
+
/**
|
|
239
|
+
* Switch modes at runtime (e.g. after upgrade from free to paid).
|
|
240
|
+
*/
|
|
241
|
+
switchMode(newMode: AstraSyncGatewayConfig['mode'], additionalConfig?: Partial<AstraSyncGatewayConfig>): Promise<void>;
|
|
242
|
+
/**
|
|
243
|
+
* Get sync queue status (hybrid mode only).
|
|
244
|
+
*/
|
|
245
|
+
getSyncStatus(): {
|
|
246
|
+
pending: number;
|
|
247
|
+
total: number;
|
|
248
|
+
} | null;
|
|
249
|
+
/**
|
|
250
|
+
* Record a tool call the calling adapter saw but did not govern
|
|
251
|
+
* (unmapped tool, skipTools, MCP with governMcp off). Trace-only.
|
|
252
|
+
*/
|
|
253
|
+
logSkippedTool(toolName: string, reason: string): void;
|
|
254
|
+
}
|
|
255
|
+
|
|
6
256
|
/**
|
|
7
257
|
* Git Trigger — Enterprise git push / PR verification
|
|
8
258
|
*
|
|
@@ -1,8 +1,258 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { V as VerificationDecision, P as PDLSSContext } from '../types-DGh2akuh.js';
|
|
3
|
-
import '../types-76TB0fxW.js';
|
|
1
|
+
import { T as TokenGuidance, b as CounterpartyType } from '../types-DMChboN_.js';
|
|
4
2
|
import '../metadata-capture.js';
|
|
5
3
|
|
|
4
|
+
/**
|
|
5
|
+
* AstraSync Gateway - Types for gateway modes, local evaluation, and adapter interface.
|
|
6
|
+
*/
|
|
7
|
+
type GatewayMode = 'online' | 'local' | 'hybrid';
|
|
8
|
+
/**
|
|
9
|
+
* Posture controls whether the gateway actively blocks or just monitors.
|
|
10
|
+
* - active: Evaluate and enforce decisions (block/allow/review)
|
|
11
|
+
* - passive: Evaluate and log but never block (telemetry-only mode)
|
|
12
|
+
*/
|
|
13
|
+
type GatewayPosture = 'active' | 'passive';
|
|
14
|
+
interface AstraSyncGatewayConfig {
|
|
15
|
+
mode: GatewayMode;
|
|
16
|
+
/** Enforcement posture: 'active' blocks actions, 'passive' logs only (default: 'active') */
|
|
17
|
+
posture?: GatewayPosture;
|
|
18
|
+
/** AstraSync API base URL (required for online/hybrid modes) */
|
|
19
|
+
apiBaseUrl?: string;
|
|
20
|
+
/** API key for authenticating with AstraSync (required for online/hybrid modes) */
|
|
21
|
+
apiKey?: string;
|
|
22
|
+
/**
|
|
23
|
+
* ASTRA- agent id this gateway acts as. Attached to hybrid sync entries and
|
|
24
|
+
* used as the default identity for online verification when the caller
|
|
25
|
+
* passes no per-call astraId.
|
|
26
|
+
*/
|
|
27
|
+
agentId?: string;
|
|
28
|
+
/** Path to local PDLSS policy YAML file (required for local/hybrid modes) */
|
|
29
|
+
policyFile?: string;
|
|
30
|
+
/** Inline policy object (alternative to policyFile) */
|
|
31
|
+
policy?: LocalPolicy;
|
|
32
|
+
/** Sync interval in seconds for hybrid mode (default: 3600) */
|
|
33
|
+
syncInterval?: number;
|
|
34
|
+
/** Cache verification results TTL in seconds (default: 300) */
|
|
35
|
+
cacheTtl?: number;
|
|
36
|
+
/** Enable debug logging */
|
|
37
|
+
debug?: boolean;
|
|
38
|
+
/** Enable trace logging to .astrasync/traces/ (default: false) */
|
|
39
|
+
traceEnabled?: boolean;
|
|
40
|
+
/** Trace log directory (default: .astrasync/traces/) */
|
|
41
|
+
tracePath?: string;
|
|
42
|
+
/** Minimum trust score for standard access (online/hybrid) */
|
|
43
|
+
minTrustScore?: number;
|
|
44
|
+
/** Minimum trust score for full access (online/hybrid) */
|
|
45
|
+
minTrustScoreForFull?: number;
|
|
46
|
+
/** Custom headers to send with API requests */
|
|
47
|
+
customHeaders?: Record<string, string>;
|
|
48
|
+
/** Counterparty URL for analytics */
|
|
49
|
+
counterpartyUrl?: string;
|
|
50
|
+
/** Counterparty type for analytics */
|
|
51
|
+
counterpartyType?: CounterpartyType;
|
|
52
|
+
}
|
|
53
|
+
interface PDLSSContext {
|
|
54
|
+
/** Purpose category (e.g. email.send, shell.exec, file.read) */
|
|
55
|
+
purpose: string;
|
|
56
|
+
/** Specific action within purpose */
|
|
57
|
+
action: string;
|
|
58
|
+
/** Target resource, recipient, or counterparty */
|
|
59
|
+
target: string;
|
|
60
|
+
/** Types of data access (read, write, delete) */
|
|
61
|
+
dataAccess?: string[];
|
|
62
|
+
/** Network domains/IPs being accessed */
|
|
63
|
+
networkAccess?: string[];
|
|
64
|
+
/** Resource type (customer, order, file, directory, process) */
|
|
65
|
+
resourceType?: string;
|
|
66
|
+
/** Risk factors for this action */
|
|
67
|
+
riskFactors?: RiskFactor[];
|
|
68
|
+
/** Transaction value (if financial) */
|
|
69
|
+
transactionValue?: number;
|
|
70
|
+
/** Currency for transaction */
|
|
71
|
+
currency?: string;
|
|
72
|
+
/** Additional metadata */
|
|
73
|
+
metadata?: Record<string, unknown>;
|
|
74
|
+
}
|
|
75
|
+
interface RiskFactor {
|
|
76
|
+
type: 'financial' | 'data_sensitivity' | 'privilege_escalation' | 'network_scope' | 'destructive';
|
|
77
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
78
|
+
detail: string;
|
|
79
|
+
}
|
|
80
|
+
interface VerificationDecision {
|
|
81
|
+
recommendation: 'ALLOW' | 'DENY' | 'MANUAL_REVIEW';
|
|
82
|
+
reason: string;
|
|
83
|
+
trustScore?: number;
|
|
84
|
+
tokenGuidance?: TokenGuidance;
|
|
85
|
+
sessionId?: string;
|
|
86
|
+
/**
|
|
87
|
+
* PDLSS dimensions that were evaluated. `true` = the dimension was
|
|
88
|
+
* configured in the policy and therefore ran; `false` = the dimension is
|
|
89
|
+
* absent from the policy and was skipped — NOT "failed" (a failed
|
|
90
|
+
* dimension never produces an ALLOW; this field is only set on ALLOW).
|
|
91
|
+
*/
|
|
92
|
+
evaluatedDimensions?: {
|
|
93
|
+
purpose: boolean;
|
|
94
|
+
scope: boolean;
|
|
95
|
+
limits: boolean;
|
|
96
|
+
riskThresholds: boolean;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
interface LocalPolicy {
|
|
100
|
+
version: string;
|
|
101
|
+
name: string;
|
|
102
|
+
description?: string;
|
|
103
|
+
purposes: LocalPurposeRule[];
|
|
104
|
+
scope?: LocalScope;
|
|
105
|
+
limits?: LocalLimits;
|
|
106
|
+
riskThresholds?: LocalRiskThresholds;
|
|
107
|
+
selfInstantiation?: LocalSelfInstantiation;
|
|
108
|
+
}
|
|
109
|
+
interface LocalPurposeRule {
|
|
110
|
+
id: string;
|
|
111
|
+
allowed: boolean;
|
|
112
|
+
targets?: string[];
|
|
113
|
+
blockedPatterns?: string[];
|
|
114
|
+
requiresApproval?: boolean;
|
|
115
|
+
}
|
|
116
|
+
interface LocalScope {
|
|
117
|
+
allowedDomains?: string[];
|
|
118
|
+
blockedDomains?: string[];
|
|
119
|
+
blockedResources?: string[];
|
|
120
|
+
}
|
|
121
|
+
interface LocalLimits {
|
|
122
|
+
/**
|
|
123
|
+
* Autonomous Limit — a transaction value at or below this is granted without
|
|
124
|
+
* escalation. A value in the band `[autonomousThreshold, maxTransactionAmount)`
|
|
125
|
+
* requires human approval (step-up → MANUAL_REVIEW), mirroring the backend
|
|
126
|
+
* `checkWithinLimits` ladder. When omitted there is no autonomous band: every
|
|
127
|
+
* positive value below the Hard Limit is granted (legacy flat-cap behaviour).
|
|
128
|
+
*/
|
|
129
|
+
autonomousThreshold?: number;
|
|
130
|
+
/**
|
|
131
|
+
* Hard Limit — a transaction value at or above this is denied outright. (Named
|
|
132
|
+
* `maxTransactionAmount` for backward compatibility with existing local policy
|
|
133
|
+
* files; it is the SDK equivalent of the backend `approvalThreshold`.)
|
|
134
|
+
*/
|
|
135
|
+
maxTransactionAmount?: number;
|
|
136
|
+
maxRequestsPerHour?: number;
|
|
137
|
+
currency?: string;
|
|
138
|
+
}
|
|
139
|
+
interface LocalRiskThresholds {
|
|
140
|
+
autoAllow: {
|
|
141
|
+
min: number;
|
|
142
|
+
max: number;
|
|
143
|
+
};
|
|
144
|
+
requireApproval: {
|
|
145
|
+
min: number;
|
|
146
|
+
max: number;
|
|
147
|
+
};
|
|
148
|
+
autoBlock: {
|
|
149
|
+
min: number;
|
|
150
|
+
max: number;
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
interface LocalSelfInstantiation {
|
|
154
|
+
/** Whether sub-agent spawning is allowed */
|
|
155
|
+
allowed: boolean;
|
|
156
|
+
/** Maximum depth of sub-agent chain */
|
|
157
|
+
maxDepth?: number;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Hybrid Mode — Local evaluation for speed, async API sync for trust scoring.
|
|
162
|
+
*
|
|
163
|
+
* Immediate: local PDLSS evaluation (< 1ms)
|
|
164
|
+
* Async: queued API verification for audit trail and trust score updates
|
|
165
|
+
*
|
|
166
|
+
* Queue entries are persisted to disk so they survive process restarts.
|
|
167
|
+
*/
|
|
168
|
+
|
|
169
|
+
interface FlushOptions {
|
|
170
|
+
/** Max entries to attempt this flush (default: all pending). */
|
|
171
|
+
limit?: number;
|
|
172
|
+
/**
|
|
173
|
+
* Per-entry time budget in ms. A timed-out entry stays pending (no retry
|
|
174
|
+
* penalty — slow network is not a failure) and ends the flush early.
|
|
175
|
+
* Stateless callers (the Claude Code hook) use this to keep sync off the
|
|
176
|
+
* tool-call critical path.
|
|
177
|
+
*/
|
|
178
|
+
perEntryTimeoutMs?: number;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* AstraSyncGateway — Primary API surface for agent verification.
|
|
183
|
+
*
|
|
184
|
+
* Supports three operational modes:
|
|
185
|
+
* - online: Full API-based verification with trust scoring and audit trail
|
|
186
|
+
* - local: Offline PDLSS evaluation using a local policy file (no account required)
|
|
187
|
+
* - hybrid: Local eval for speed + async API sync for trust scoring
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```typescript
|
|
191
|
+
* // Local mode (free, no account)
|
|
192
|
+
* const gateway = new AstraSyncGateway({ mode: 'local', policyFile: './policy.yaml' });
|
|
193
|
+
* const decision = await gateway.evaluate(context);
|
|
194
|
+
*
|
|
195
|
+
* // Online mode (paid, full features)
|
|
196
|
+
* const gateway = new AstraSyncGateway({ mode: 'online', apiKey: 'key' });
|
|
197
|
+
* const decision = await gateway.evaluate(context);
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
|
|
201
|
+
declare class AstraSyncGateway {
|
|
202
|
+
private config;
|
|
203
|
+
private evaluator;
|
|
204
|
+
private syncQueue;
|
|
205
|
+
private traceLogger;
|
|
206
|
+
private initialized;
|
|
207
|
+
constructor(config: AstraSyncGatewayConfig);
|
|
208
|
+
private validateConfig;
|
|
209
|
+
/**
|
|
210
|
+
* Initialize the gateway (loads policy files, starts sync queues).
|
|
211
|
+
* Called automatically on first evaluate() if not called manually.
|
|
212
|
+
*/
|
|
213
|
+
initialize(): Promise<void>;
|
|
214
|
+
/**
|
|
215
|
+
* Graceful shutdown. Flushes sync queue and cleans up resources.
|
|
216
|
+
* Stateless callers (hooks) pass bounded flush options so sync never
|
|
217
|
+
* sits on a tool call's critical path.
|
|
218
|
+
*/
|
|
219
|
+
shutdown(options?: {
|
|
220
|
+
syncFlush?: FlushOptions;
|
|
221
|
+
}): Promise<void>;
|
|
222
|
+
/**
|
|
223
|
+
* Evaluate an action against the verification policy.
|
|
224
|
+
* Routes to the appropriate mode handler.
|
|
225
|
+
*
|
|
226
|
+
* In passive posture, evaluation runs but always returns ALLOW
|
|
227
|
+
* (the real decision is logged for telemetry).
|
|
228
|
+
*/
|
|
229
|
+
evaluate(context: PDLSSContext, astraId?: string): Promise<VerificationDecision>;
|
|
230
|
+
/**
|
|
231
|
+
* Get the current mode.
|
|
232
|
+
*/
|
|
233
|
+
get mode(): AstraSyncGatewayConfig['mode'];
|
|
234
|
+
/**
|
|
235
|
+
* Get the current posture (active or passive).
|
|
236
|
+
*/
|
|
237
|
+
get posture(): 'active' | 'passive';
|
|
238
|
+
/**
|
|
239
|
+
* Switch modes at runtime (e.g. after upgrade from free to paid).
|
|
240
|
+
*/
|
|
241
|
+
switchMode(newMode: AstraSyncGatewayConfig['mode'], additionalConfig?: Partial<AstraSyncGatewayConfig>): Promise<void>;
|
|
242
|
+
/**
|
|
243
|
+
* Get sync queue status (hybrid mode only).
|
|
244
|
+
*/
|
|
245
|
+
getSyncStatus(): {
|
|
246
|
+
pending: number;
|
|
247
|
+
total: number;
|
|
248
|
+
} | null;
|
|
249
|
+
/**
|
|
250
|
+
* Record a tool call the calling adapter saw but did not govern
|
|
251
|
+
* (unmapped tool, skipTools, MCP with governMcp off). Trace-only.
|
|
252
|
+
*/
|
|
253
|
+
logSkippedTool(toolName: string, reason: string): void;
|
|
254
|
+
}
|
|
255
|
+
|
|
6
256
|
/**
|
|
7
257
|
* Git Trigger — Enterprise git push / PR verification
|
|
8
258
|
*
|