@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
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AstraSync Universal Verification Gateway Types
|
|
3
|
+
*
|
|
4
|
+
* TypeScript type definitions for agent verification across all counterparty types.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Types of counterparties that can integrate the gateway
|
|
9
|
+
*/
|
|
10
|
+
type CounterpartyType = 'agent' | 'api' | 'mcp_server' | 'website' | 'other' | 'unknown';
|
|
11
|
+
/**
|
|
12
|
+
* Token guidance returned from verify-access.
|
|
13
|
+
*
|
|
14
|
+
* `recommendedRateLimit` carries `requestsPerMinute` and `currency` only.
|
|
15
|
+
* `maxTransactionValue` was removed in v2.2.4 — it leaked the agent's
|
|
16
|
+
* spending headroom to the merchant, which is a price-discrimination signal
|
|
17
|
+
* (a merchant could see the agent's autonomous threshold and price the
|
|
18
|
+
* transaction just under it to capture surplus). The agent's SDK receives
|
|
19
|
+
* its own limits separately for client-side budgeting; the merchant's
|
|
20
|
+
* decision doesn't need amount info.
|
|
21
|
+
*/
|
|
22
|
+
interface TokenGuidance {
|
|
23
|
+
recommendedScopes: string[];
|
|
24
|
+
recommendedTtlSeconds: number;
|
|
25
|
+
recommendedRateLimit?: {
|
|
26
|
+
requestsPerMinute: number;
|
|
27
|
+
currency?: string;
|
|
28
|
+
};
|
|
29
|
+
jurisdictionConstraints?: string[];
|
|
30
|
+
delegationAllowed: boolean;
|
|
31
|
+
maxDelegationDepth?: number;
|
|
32
|
+
safetyDefaults: {
|
|
33
|
+
writePrivilegesRequested: boolean;
|
|
34
|
+
shortLivedTokenRecommended: boolean;
|
|
35
|
+
scopeConvention: 'astrasync-canonical';
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* AstraSync Gateway - Types for gateway modes, local evaluation, and adapter interface.
|
|
41
|
+
*/
|
|
42
|
+
type GatewayMode = 'online' | 'local' | 'hybrid';
|
|
43
|
+
/**
|
|
44
|
+
* Posture controls whether the gateway actively blocks or just monitors.
|
|
45
|
+
* - active: Evaluate and enforce decisions (block/allow/review)
|
|
46
|
+
* - passive: Evaluate and log but never block (telemetry-only mode)
|
|
47
|
+
*/
|
|
48
|
+
type GatewayPosture = 'active' | 'passive';
|
|
49
|
+
interface AstraSyncGatewayConfig {
|
|
50
|
+
mode: GatewayMode;
|
|
51
|
+
/** Enforcement posture: 'active' blocks actions, 'passive' logs only (default: 'active') */
|
|
52
|
+
posture?: GatewayPosture;
|
|
53
|
+
/** AstraSync API base URL (required for online/hybrid modes) */
|
|
54
|
+
apiBaseUrl?: string;
|
|
55
|
+
/** API key for authenticating with AstraSync (required for online/hybrid modes) */
|
|
56
|
+
apiKey?: string;
|
|
57
|
+
/**
|
|
58
|
+
* ASTRA- agent id this gateway acts as. Attached to hybrid sync entries and
|
|
59
|
+
* used as the default identity for online verification when the caller
|
|
60
|
+
* passes no per-call astraId.
|
|
61
|
+
*/
|
|
62
|
+
agentId?: string;
|
|
63
|
+
/** Path to local PDLSS policy YAML file (required for local/hybrid modes) */
|
|
64
|
+
policyFile?: string;
|
|
65
|
+
/** Inline policy object (alternative to policyFile) */
|
|
66
|
+
policy?: LocalPolicy;
|
|
67
|
+
/** Sync interval in seconds for hybrid mode (default: 3600) */
|
|
68
|
+
syncInterval?: number;
|
|
69
|
+
/** Cache verification results TTL in seconds (default: 300) */
|
|
70
|
+
cacheTtl?: number;
|
|
71
|
+
/** Enable debug logging */
|
|
72
|
+
debug?: boolean;
|
|
73
|
+
/** Enable trace logging to .astrasync/traces/ (default: false) */
|
|
74
|
+
traceEnabled?: boolean;
|
|
75
|
+
/** Trace log directory (default: .astrasync/traces/) */
|
|
76
|
+
tracePath?: string;
|
|
77
|
+
/** Minimum trust score for standard access (online/hybrid) */
|
|
78
|
+
minTrustScore?: number;
|
|
79
|
+
/** Minimum trust score for full access (online/hybrid) */
|
|
80
|
+
minTrustScoreForFull?: number;
|
|
81
|
+
/** Custom headers to send with API requests */
|
|
82
|
+
customHeaders?: Record<string, string>;
|
|
83
|
+
/** Counterparty URL for analytics */
|
|
84
|
+
counterpartyUrl?: string;
|
|
85
|
+
/** Counterparty type for analytics */
|
|
86
|
+
counterpartyType?: CounterpartyType;
|
|
87
|
+
}
|
|
88
|
+
interface PDLSSContext {
|
|
89
|
+
/** Purpose category (e.g. email.send, shell.exec, file.read) */
|
|
90
|
+
purpose: string;
|
|
91
|
+
/** Specific action within purpose */
|
|
92
|
+
action: string;
|
|
93
|
+
/** Target resource, recipient, or counterparty */
|
|
94
|
+
target: string;
|
|
95
|
+
/** Types of data access (read, write, delete) */
|
|
96
|
+
dataAccess?: string[];
|
|
97
|
+
/** Network domains/IPs being accessed */
|
|
98
|
+
networkAccess?: string[];
|
|
99
|
+
/** Resource type (customer, order, file, directory, process) */
|
|
100
|
+
resourceType?: string;
|
|
101
|
+
/** Risk factors for this action */
|
|
102
|
+
riskFactors?: RiskFactor[];
|
|
103
|
+
/** Transaction value (if financial) */
|
|
104
|
+
transactionValue?: number;
|
|
105
|
+
/** Currency for transaction */
|
|
106
|
+
currency?: string;
|
|
107
|
+
/** Additional metadata */
|
|
108
|
+
metadata?: Record<string, unknown>;
|
|
109
|
+
}
|
|
110
|
+
interface RiskFactor {
|
|
111
|
+
type: 'financial' | 'data_sensitivity' | 'privilege_escalation' | 'network_scope' | 'destructive';
|
|
112
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
113
|
+
detail: string;
|
|
114
|
+
}
|
|
115
|
+
interface VerificationDecision {
|
|
116
|
+
recommendation: 'ALLOW' | 'DENY' | 'MANUAL_REVIEW';
|
|
117
|
+
reason: string;
|
|
118
|
+
trustScore?: number;
|
|
119
|
+
tokenGuidance?: TokenGuidance;
|
|
120
|
+
sessionId?: string;
|
|
121
|
+
/**
|
|
122
|
+
* PDLSS dimensions that were evaluated. `true` = the dimension was
|
|
123
|
+
* configured in the policy and therefore ran; `false` = the dimension is
|
|
124
|
+
* absent from the policy and was skipped — NOT "failed" (a failed
|
|
125
|
+
* dimension never produces an ALLOW; this field is only set on ALLOW).
|
|
126
|
+
*/
|
|
127
|
+
evaluatedDimensions?: {
|
|
128
|
+
purpose: boolean;
|
|
129
|
+
scope: boolean;
|
|
130
|
+
limits: boolean;
|
|
131
|
+
riskThresholds: boolean;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
interface LocalPolicy {
|
|
135
|
+
version: string;
|
|
136
|
+
name: string;
|
|
137
|
+
description?: string;
|
|
138
|
+
purposes: LocalPurposeRule[];
|
|
139
|
+
scope?: LocalScope;
|
|
140
|
+
limits?: LocalLimits;
|
|
141
|
+
riskThresholds?: LocalRiskThresholds;
|
|
142
|
+
selfInstantiation?: LocalSelfInstantiation;
|
|
143
|
+
}
|
|
144
|
+
interface LocalPurposeRule {
|
|
145
|
+
id: string;
|
|
146
|
+
allowed: boolean;
|
|
147
|
+
targets?: string[];
|
|
148
|
+
blockedPatterns?: string[];
|
|
149
|
+
requiresApproval?: boolean;
|
|
150
|
+
}
|
|
151
|
+
interface LocalScope {
|
|
152
|
+
allowedDomains?: string[];
|
|
153
|
+
blockedDomains?: string[];
|
|
154
|
+
blockedResources?: string[];
|
|
155
|
+
}
|
|
156
|
+
interface LocalLimits {
|
|
157
|
+
/**
|
|
158
|
+
* Autonomous Limit — a transaction value at or below this is granted without
|
|
159
|
+
* escalation. A value in the band `[autonomousThreshold, maxTransactionAmount)`
|
|
160
|
+
* requires human approval (step-up → MANUAL_REVIEW), mirroring the backend
|
|
161
|
+
* `checkWithinLimits` ladder. When omitted there is no autonomous band: every
|
|
162
|
+
* positive value below the Hard Limit is granted (legacy flat-cap behaviour).
|
|
163
|
+
*/
|
|
164
|
+
autonomousThreshold?: number;
|
|
165
|
+
/**
|
|
166
|
+
* Hard Limit — a transaction value at or above this is denied outright. (Named
|
|
167
|
+
* `maxTransactionAmount` for backward compatibility with existing local policy
|
|
168
|
+
* files; it is the SDK equivalent of the backend `approvalThreshold`.)
|
|
169
|
+
*/
|
|
170
|
+
maxTransactionAmount?: number;
|
|
171
|
+
maxRequestsPerHour?: number;
|
|
172
|
+
currency?: string;
|
|
173
|
+
}
|
|
174
|
+
interface LocalRiskThresholds {
|
|
175
|
+
autoAllow: {
|
|
176
|
+
min: number;
|
|
177
|
+
max: number;
|
|
178
|
+
};
|
|
179
|
+
requireApproval: {
|
|
180
|
+
min: number;
|
|
181
|
+
max: number;
|
|
182
|
+
};
|
|
183
|
+
autoBlock: {
|
|
184
|
+
min: number;
|
|
185
|
+
max: number;
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
interface LocalSelfInstantiation {
|
|
189
|
+
/** Whether sub-agent spawning is allowed */
|
|
190
|
+
allowed: boolean;
|
|
191
|
+
/** Maximum depth of sub-agent chain */
|
|
192
|
+
maxDepth?: number;
|
|
193
|
+
}
|
|
194
|
+
interface AgentAction {
|
|
195
|
+
/** Raw action data from the platform */
|
|
196
|
+
raw: unknown;
|
|
197
|
+
/** Platform identifier (e.g. 'openclaw-cli', 'cursor', 'browser') */
|
|
198
|
+
platform: string;
|
|
199
|
+
/** Timestamp of the action */
|
|
200
|
+
timestamp: Date;
|
|
201
|
+
}
|
|
202
|
+
interface InterceptResult {
|
|
203
|
+
/** Whether the action was intercepted */
|
|
204
|
+
intercepted: boolean;
|
|
205
|
+
/** Extracted PDLSS context (if intercepted) */
|
|
206
|
+
context?: PDLSSContext;
|
|
207
|
+
/** Reason for not intercepting (if not intercepted) */
|
|
208
|
+
skipReason?: string;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Hybrid Mode — Local evaluation for speed, async API sync for trust scoring.
|
|
213
|
+
*
|
|
214
|
+
* Immediate: local PDLSS evaluation (< 1ms)
|
|
215
|
+
* Async: queued API verification for audit trail and trust score updates
|
|
216
|
+
*
|
|
217
|
+
* Queue entries are persisted to disk so they survive process restarts.
|
|
218
|
+
*/
|
|
219
|
+
|
|
220
|
+
interface FlushOptions {
|
|
221
|
+
/** Max entries to attempt this flush (default: all pending). */
|
|
222
|
+
limit?: number;
|
|
223
|
+
/**
|
|
224
|
+
* Per-entry time budget in ms. A timed-out entry stays pending (no retry
|
|
225
|
+
* penalty — slow network is not a failure) and ends the flush early.
|
|
226
|
+
* Stateless callers (the Claude Code hook) use this to keep sync off the
|
|
227
|
+
* tool-call critical path.
|
|
228
|
+
*/
|
|
229
|
+
perEntryTimeoutMs?: number;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* AstraSyncGateway — Primary API surface for agent verification.
|
|
234
|
+
*
|
|
235
|
+
* Supports three operational modes:
|
|
236
|
+
* - online: Full API-based verification with trust scoring and audit trail
|
|
237
|
+
* - local: Offline PDLSS evaluation using a local policy file (no account required)
|
|
238
|
+
* - hybrid: Local eval for speed + async API sync for trust scoring
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```typescript
|
|
242
|
+
* // Local mode (free, no account)
|
|
243
|
+
* const gateway = new AstraSyncGateway({ mode: 'local', policyFile: './policy.yaml' });
|
|
244
|
+
* const decision = await gateway.evaluate(context);
|
|
245
|
+
*
|
|
246
|
+
* // Online mode (paid, full features)
|
|
247
|
+
* const gateway = new AstraSyncGateway({ mode: 'online', apiKey: 'key' });
|
|
248
|
+
* const decision = await gateway.evaluate(context);
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
|
|
252
|
+
declare class AstraSyncGateway {
|
|
253
|
+
private config;
|
|
254
|
+
private evaluator;
|
|
255
|
+
private syncQueue;
|
|
256
|
+
private traceLogger;
|
|
257
|
+
private initialized;
|
|
258
|
+
constructor(config: AstraSyncGatewayConfig);
|
|
259
|
+
private validateConfig;
|
|
260
|
+
/**
|
|
261
|
+
* Initialize the gateway (loads policy files, starts sync queues).
|
|
262
|
+
* Called automatically on first evaluate() if not called manually.
|
|
263
|
+
*/
|
|
264
|
+
initialize(): Promise<void>;
|
|
265
|
+
/**
|
|
266
|
+
* Graceful shutdown. Flushes sync queue and cleans up resources.
|
|
267
|
+
* Stateless callers (hooks) pass bounded flush options so sync never
|
|
268
|
+
* sits on a tool call's critical path.
|
|
269
|
+
*/
|
|
270
|
+
shutdown(options?: {
|
|
271
|
+
syncFlush?: FlushOptions;
|
|
272
|
+
}): Promise<void>;
|
|
273
|
+
/**
|
|
274
|
+
* Evaluate an action against the verification policy.
|
|
275
|
+
* Routes to the appropriate mode handler.
|
|
276
|
+
*
|
|
277
|
+
* In passive posture, evaluation runs but always returns ALLOW
|
|
278
|
+
* (the real decision is logged for telemetry).
|
|
279
|
+
*/
|
|
280
|
+
evaluate(context: PDLSSContext, astraId?: string): Promise<VerificationDecision>;
|
|
281
|
+
/**
|
|
282
|
+
* Get the current mode.
|
|
283
|
+
*/
|
|
284
|
+
get mode(): AstraSyncGatewayConfig['mode'];
|
|
285
|
+
/**
|
|
286
|
+
* Get the current posture (active or passive).
|
|
287
|
+
*/
|
|
288
|
+
get posture(): 'active' | 'passive';
|
|
289
|
+
/**
|
|
290
|
+
* Switch modes at runtime (e.g. after upgrade from free to paid).
|
|
291
|
+
*/
|
|
292
|
+
switchMode(newMode: AstraSyncGatewayConfig['mode'], additionalConfig?: Partial<AstraSyncGatewayConfig>): Promise<void>;
|
|
293
|
+
/**
|
|
294
|
+
* Get sync queue status (hybrid mode only).
|
|
295
|
+
*/
|
|
296
|
+
getSyncStatus(): {
|
|
297
|
+
pending: number;
|
|
298
|
+
total: number;
|
|
299
|
+
} | null;
|
|
300
|
+
/**
|
|
301
|
+
* Record a tool call the calling adapter saw but did not govern
|
|
302
|
+
* (unmapped tool, skipTools, MCP with governMcp off). Trace-only.
|
|
303
|
+
*/
|
|
304
|
+
logSkippedTool(toolName: string, reason: string): void;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* PlatformAdapter Interface
|
|
309
|
+
*
|
|
310
|
+
* The contract that Layer 4 platform adapters implement.
|
|
311
|
+
* Agent-side interception: governs what agents are allowed to do before they do it.
|
|
312
|
+
*
|
|
313
|
+
* Each adapter is 200-500 lines of platform-specific code.
|
|
314
|
+
* All verification logic lives in the gateway — adapters just translate
|
|
315
|
+
* between the platform's world and AstraSync's world.
|
|
316
|
+
*/
|
|
317
|
+
|
|
318
|
+
interface AdapterConfig {
|
|
319
|
+
/** The AstraSyncGateway instance (handles mode routing) */
|
|
320
|
+
gateway: AstraSyncGateway;
|
|
321
|
+
/** Platform-specific configuration */
|
|
322
|
+
adapterOptions: Record<string, unknown>;
|
|
323
|
+
}
|
|
324
|
+
interface PlatformAdapter {
|
|
325
|
+
/**
|
|
326
|
+
* Interface version for compatibility checking.
|
|
327
|
+
* Current version: 1.
|
|
328
|
+
*/
|
|
329
|
+
readonly interfaceVersion: number;
|
|
330
|
+
/**
|
|
331
|
+
* Platform-specific initialization.
|
|
332
|
+
* Load config, register hooks, establish connections.
|
|
333
|
+
*/
|
|
334
|
+
initialize(config: AdapterConfig): Promise<void>;
|
|
335
|
+
/**
|
|
336
|
+
* Graceful shutdown.
|
|
337
|
+
* Drain in-flight verifications, deregister hooks, close connections.
|
|
338
|
+
*/
|
|
339
|
+
shutdown(): Promise<void>;
|
|
340
|
+
/**
|
|
341
|
+
* Intercept an agent action before execution.
|
|
342
|
+
*
|
|
343
|
+
* How this works depends on the platform:
|
|
344
|
+
* - CLI adapter: proxy server captures outbound request
|
|
345
|
+
* - Browser adapter: content script intercepts DOM interaction
|
|
346
|
+
* - Express: middleware captures inbound request
|
|
347
|
+
*/
|
|
348
|
+
interceptAction(action: AgentAction): Promise<InterceptResult>;
|
|
349
|
+
/**
|
|
350
|
+
* Extract PDLSS-compatible context from a platform-specific action.
|
|
351
|
+
* Maps platform-native action format to the universal PDLSSContext.
|
|
352
|
+
*/
|
|
353
|
+
extractContext(action: AgentAction): PDLSSContext;
|
|
354
|
+
/**
|
|
355
|
+
* Enforce the verification decision in a platform-specific way.
|
|
356
|
+
*
|
|
357
|
+
* How this works depends on the platform:
|
|
358
|
+
* - CLI: block command / allow command / prompt for approval
|
|
359
|
+
* - Browser: block navigation / show confirmation dialog
|
|
360
|
+
* - Express: return 403 / pass through / inject headers
|
|
361
|
+
*/
|
|
362
|
+
enforceDecision(decision: VerificationDecision): Promise<void>;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
export { type AdapterConfig as A, type InterceptResult as I, type LocalPolicy as L, type PDLSSContext as P, type VerificationDecision as V, type AgentAction as a, AstraSyncGateway as b, type LocalPurposeRule as c, type LocalRiskThresholds as d, type LocalScope as e, type PlatformAdapter as f };
|