@astrasyncai/verification-gateway 2.4.0 → 2.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/README.md +137 -22
- package/dist/adapter-interface/interface.d.mts +2 -2
- package/dist/adapter-interface/interface.d.ts +2 -2
- package/dist/adapters/express.d.mts +2 -2
- package/dist/adapters/express.d.ts +2 -2
- package/dist/adapters/express.js +37 -7
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +37 -7
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/mcp.d.mts +1 -1
- package/dist/adapters/mcp.d.ts +1 -1
- package/dist/adapters/mcp.js +37 -7
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +37 -7
- package/dist/adapters/mcp.mjs.map +1 -1
- package/dist/adapters/nextjs.d.mts +2 -2
- package/dist/adapters/nextjs.d.ts +2 -2
- package/dist/adapters/nextjs.js +30 -4
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +30 -4
- package/dist/adapters/nextjs.mjs.map +1 -1
- package/dist/adapters/sdk.d.mts +2 -2
- package/dist/adapters/sdk.d.ts +2 -2
- package/dist/adapters/sdk.js +30 -4
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +30 -4
- package/dist/adapters/sdk.mjs.map +1 -1
- package/dist/agent/index.d.mts +2 -2
- package/dist/agent/index.d.ts +2 -2
- package/dist/bin/astrasync.js +163 -4
- package/dist/browser/background.js +30 -4
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +30 -4
- package/dist/browser/background.mjs.map +1 -1
- package/dist/browser/browser-adapter.d.mts +2 -2
- package/dist/browser/browser-adapter.d.ts +2 -2
- package/dist/cli/index.d.mts +2 -2
- package/dist/cli/index.d.ts +2 -2
- package/dist/cursor/cursor-adapter.d.mts +2 -2
- package/dist/cursor/cursor-adapter.d.ts +2 -2
- package/dist/cursor/extension.d.mts +2 -2
- package/dist/cursor/extension.d.ts +2 -2
- package/dist/cursor/extension.js +30 -4
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +30 -4
- package/dist/cursor/extension.mjs.map +1 -1
- package/dist/{express-4Vau6x6X.d.mts → express-DneHiMhu.d.mts} +1 -1
- package/dist/{express-Nq-wWICa.d.ts → express-DsiaQRFt.d.ts} +1 -1
- package/dist/gateway/gateway.d.mts +2 -2
- package/dist/gateway/gateway.d.ts +2 -2
- package/dist/gateway/gateway.js +30 -4
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +30 -4
- package/dist/gateway/gateway.mjs.map +1 -1
- package/dist/git-trigger/git-hooks.d.mts +2 -2
- package/dist/git-trigger/git-hooks.d.ts +2 -2
- package/dist/{index-DkyPV14Y.d.mts → index-C9yWlQ2Y.d.mts} +1 -1
- package/dist/{index-DiToN8gh.d.mts → index-DAGm-Sgf.d.mts} +1 -1
- package/dist/{index-B-EovXnY.d.ts → index-Dd4alF0l.d.ts} +1 -1
- package/dist/{index-CxwCN7AC.d.ts → index-NZiKvrtE.d.ts} +1 -1
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +37 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -7
- package/dist/index.mjs.map +1 -1
- package/dist/local-evaluator/evaluator.d.mts +2 -2
- package/dist/local-evaluator/evaluator.d.ts +2 -2
- package/dist/{nextjs-DO_4crcp.d.ts → nextjs-B4WmoiVm.d.ts} +1 -1
- package/dist/{nextjs-BTR7Oix-.d.mts → nextjs-vUuVCaBP.d.mts} +1 -1
- package/dist/registration/index.d.mts +174 -7
- package/dist/registration/index.d.ts +174 -7
- package/dist/registration/index.js +171 -6
- package/dist/registration/index.js.map +1 -1
- package/dist/registration/index.mjs +167 -5
- package/dist/registration/index.mjs.map +1 -1
- package/dist/{sdk-TnHXD-Oh.d.ts → sdk-BvWp4q2q.d.ts} +1 -1
- package/dist/{sdk-DSLCyXIX.d.mts → sdk-Cixo6pTV.d.mts} +1 -1
- package/dist/transport/index.d.mts +2 -2
- package/dist/transport/index.d.ts +2 -2
- package/dist/{types-pU2O0BFq.d.mts → types-C_e1IZdU.d.mts} +1 -1
- package/dist/{types-BVp22KkN.d.mts → types-DLai3jly.d.mts} +16 -13
- package/dist/{types-BVp22KkN.d.ts → types-DLai3jly.d.ts} +16 -13
- package/dist/{types-DVCWReEN.d.ts → types-IUzu-A4u.d.ts} +1 -1
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LocalPolicy, P as PDLSSContext, V as VerificationDecision, a as LocalPurposeRule } from '../types-
|
|
2
|
-
import '../types-
|
|
1
|
+
import { L as LocalPolicy, P as PDLSSContext, V as VerificationDecision, a as LocalPurposeRule } from '../types-C_e1IZdU.mjs';
|
|
2
|
+
import '../types-DLai3jly.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Local PDLSS Evaluator
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LocalPolicy, P as PDLSSContext, V as VerificationDecision, a as LocalPurposeRule } from '../types-
|
|
2
|
-
import '../types-
|
|
1
|
+
import { L as LocalPolicy, P as PDLSSContext, V as VerificationDecision, a as LocalPurposeRule } from '../types-IUzu-A4u.js';
|
|
2
|
+
import '../types-DLai3jly.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Local PDLSS Evaluator
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as next_server from 'next/server';
|
|
2
2
|
import { NextRequest } from 'next/server';
|
|
3
|
-
import { N as NextJsMiddlewareOptions } from './types-
|
|
3
|
+
import { N as NextJsMiddlewareOptions } from './types-DLai3jly.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Create Next.js middleware for agent verification.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as next_server from 'next/server';
|
|
2
2
|
import { NextRequest } from 'next/server';
|
|
3
|
-
import { N as NextJsMiddlewareOptions } from './types-
|
|
3
|
+
import { N as NextJsMiddlewareOptions } from './types-DLai3jly.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Create Next.js middleware for agent verification.
|
|
@@ -9,11 +9,27 @@ interface AstraSyncConfig {
|
|
|
9
9
|
/** secp256k1 private key for crypto signing. Used WITH apiKey or email+password. */
|
|
10
10
|
privateKey?: string;
|
|
11
11
|
/**
|
|
12
|
-
* Base URL for the AstraSync API.
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* Base URL for the AstraSync API. Pass the bare ORIGIN — the SDK appends
|
|
13
|
+
* `/api/agents/...` for each call.
|
|
14
|
+
*
|
|
15
|
+
* - Production: `https://astrasync.ai` (default)
|
|
16
|
+
* - Staging: `https://staging.astrasync.ai`
|
|
17
|
+
*
|
|
18
|
+
* A trailing `/api` is tolerated for compatibility with the
|
|
19
|
+
* `GatewayConfig.apiBaseUrl` convention used by the verification gateway
|
|
20
|
+
* — if you pass `https://astrasync.ai/api` the SDK strips the suffix and
|
|
21
|
+
* emits a one-time console.warn so you can fix the source.
|
|
22
|
+
*
|
|
23
|
+
* Defaults to the `ASTRASYNC_API_URL` env var, then production.
|
|
15
24
|
*/
|
|
16
25
|
baseUrl?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Suppress the one-time console.warn emitted on baseUrl normalization,
|
|
28
|
+
* deprecation, or other non-fatal SDK conditions. Default: `false`
|
|
29
|
+
* (warnings emit). Set `true` in test runners or where logs are
|
|
30
|
+
* structured.
|
|
31
|
+
*/
|
|
32
|
+
silent?: boolean;
|
|
17
33
|
}
|
|
18
34
|
/**
|
|
19
35
|
* Multi-protocol declarations the agent participates in.
|
|
@@ -93,6 +109,12 @@ interface RegisterOptions {
|
|
|
93
109
|
name: string;
|
|
94
110
|
description?: string;
|
|
95
111
|
agentType?: string;
|
|
112
|
+
/**
|
|
113
|
+
* URL where your agent's verification-gateway SDK is mounted for runtime
|
|
114
|
+
* challenges. Optional — if omitted, your agent declares no runtime-challenge
|
|
115
|
+
* support and some counterparties may decline access requests. Mirrors the
|
|
116
|
+
* webUI "API endpoint" field.
|
|
117
|
+
*/
|
|
96
118
|
apiEndpoint?: string;
|
|
97
119
|
model?: ModelConfig;
|
|
98
120
|
framework?: FrameworkConfig;
|
|
@@ -101,7 +123,59 @@ interface RegisterOptions {
|
|
|
101
123
|
metadata?: Record<string, unknown>;
|
|
102
124
|
pdlss?: PDLSSConfig;
|
|
103
125
|
}
|
|
104
|
-
/**
|
|
126
|
+
/**
|
|
127
|
+
* Optional blocking-mode flags for `register()`. When `waitForApproval` is
|
|
128
|
+
* true and the backend returns 202 pending, the SDK polls until the request
|
|
129
|
+
* resolves (approved → returns Agent; denied/expired → throws; timeout →
|
|
130
|
+
* throws). The default is non-blocking: the SDK returns the pending result
|
|
131
|
+
* immediately and the caller handles polling itself.
|
|
132
|
+
*/
|
|
133
|
+
interface WaitForApprovalOptions {
|
|
134
|
+
/** Block until the request resolves. Default: false. */
|
|
135
|
+
waitForApproval?: boolean;
|
|
136
|
+
/** How long to wait in blocking mode. Default: 600_000ms (10 min). */
|
|
137
|
+
timeoutMs?: number;
|
|
138
|
+
/** Poll cadence in blocking mode. Default: 5000ms. */
|
|
139
|
+
pollIntervalMs?: number;
|
|
140
|
+
/** Called once per poll while still pending; useful for progress UX. */
|
|
141
|
+
onPending?: (event: {
|
|
142
|
+
requestId: string;
|
|
143
|
+
ageMs: number;
|
|
144
|
+
}) => void;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Discriminated registration result.
|
|
148
|
+
*
|
|
149
|
+
* - `active`: synchronous path (crypto-keypair signature verified, or
|
|
150
|
+
* email+password auth). `agent` is the live record.
|
|
151
|
+
* - `pending_approval`: API-key auth path. The owner has been notified by
|
|
152
|
+
* email and a dashboard alert. Poll `pollUrl` or call
|
|
153
|
+
* `sdk.pollRegistration(requestId)` to track progress, or re-call
|
|
154
|
+
* `register` with `waitForApproval: true` to block.
|
|
155
|
+
*/
|
|
156
|
+
type RegisterResult = {
|
|
157
|
+
status: 'active';
|
|
158
|
+
agent: AgentRecord;
|
|
159
|
+
} | {
|
|
160
|
+
status: 'pending_approval';
|
|
161
|
+
requestId: string;
|
|
162
|
+
expiresAt: string;
|
|
163
|
+
pollUrl: string;
|
|
164
|
+
message?: string;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Response shape from `pollRegistration(requestId)` and the internal poll
|
|
168
|
+
* loop. State `pending` means still awaiting owner; the others are terminal.
|
|
169
|
+
*/
|
|
170
|
+
interface PollRegistrationResult {
|
|
171
|
+
state: 'pending' | 'approved' | 'denied' | 'expired';
|
|
172
|
+
agent?: AgentRecord;
|
|
173
|
+
reason?: string;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Response from agent registration (raw 201 body). Use {@link RegisterResult}
|
|
177
|
+
* for the consumer-facing shape returned from `sdk.register()`.
|
|
178
|
+
*/
|
|
105
179
|
interface RegistrationResponse {
|
|
106
180
|
success: boolean;
|
|
107
181
|
message: string;
|
|
@@ -109,6 +183,15 @@ interface RegistrationResponse {
|
|
|
109
183
|
agent: AgentRecord;
|
|
110
184
|
};
|
|
111
185
|
}
|
|
186
|
+
/** Raw 202 body — internal type, exposed via {@link RegisterResult}. */
|
|
187
|
+
interface PendingRegistrationResponse {
|
|
188
|
+
success: true;
|
|
189
|
+
status: 'pending_approval';
|
|
190
|
+
requestId: string;
|
|
191
|
+
expiresAt: string;
|
|
192
|
+
pollUrl: string;
|
|
193
|
+
message?: string;
|
|
194
|
+
}
|
|
112
195
|
/** Agent record from the API. */
|
|
113
196
|
interface AgentRecord {
|
|
114
197
|
kyaAgentId: string;
|
|
@@ -175,9 +258,59 @@ declare class AstraSync {
|
|
|
175
258
|
constructor(config?: AstraSyncConfig);
|
|
176
259
|
/**
|
|
177
260
|
* Register a new AI agent on the AstraSync KYA Platform.
|
|
178
|
-
*
|
|
261
|
+
*
|
|
262
|
+
* The backend response depends on auth context:
|
|
263
|
+
* - **Crypto-keypair signed** (`privateKey` configured): synchronous 201,
|
|
264
|
+
* returns `{ status: 'active', agent }`.
|
|
265
|
+
* - **API-key only** (no signature): 202 pending, returns
|
|
266
|
+
* `{ status: 'pending_approval', requestId, pollUrl, expiresAt }`. The
|
|
267
|
+
* owner is notified by email and a dashboard alert is emitted; the agent
|
|
268
|
+
* becomes active only after the owner approves.
|
|
269
|
+
*
|
|
270
|
+
* Blocking mode: pass `{ waitForApproval: true }` to have the SDK poll the
|
|
271
|
+
* request until it resolves, then return the live agent record. The promise
|
|
272
|
+
* rejects with `RegistrationDeniedError`, `RegistrationExpiredError`, or
|
|
273
|
+
* `RegistrationTimeoutError` on the corresponding terminal states.
|
|
274
|
+
*
|
|
275
|
+
* @example Non-blocking (default — best for serverless / scheduled agents):
|
|
276
|
+
* ```typescript
|
|
277
|
+
* const result = await sdk.register({ name, pdlss });
|
|
278
|
+
* if (result.status === 'pending_approval') {
|
|
279
|
+
* storeRequestId(result.requestId);
|
|
280
|
+
* return; // function exits; resume later via pollRegistration()
|
|
281
|
+
* }
|
|
282
|
+
* ```
|
|
283
|
+
*
|
|
284
|
+
* @example Blocking (best for long-running services + CLI):
|
|
285
|
+
* ```typescript
|
|
286
|
+
* const agent = await sdk.register({
|
|
287
|
+
* name, pdlss, waitForApproval: true, timeoutMs: 600_000,
|
|
288
|
+
* onPending: ({ ageMs }) => console.log(`waiting ${ageMs}ms`),
|
|
289
|
+
* });
|
|
290
|
+
* ```
|
|
179
291
|
*/
|
|
180
|
-
register(options: RegisterOptions): Promise<
|
|
292
|
+
register(options: RegisterOptions & WaitForApprovalOptions): Promise<RegisterResult | AgentRecord>;
|
|
293
|
+
/**
|
|
294
|
+
* Poll the current state of a pending-approval registration request.
|
|
295
|
+
*
|
|
296
|
+
* Useful for caller-driven polling when `waitForApproval: false` (the
|
|
297
|
+
* default). The endpoint is unauthenticated — pass the `requestId` that
|
|
298
|
+
* was returned from the 202 response.
|
|
299
|
+
*
|
|
300
|
+
* @returns `state: 'pending'` while awaiting; `'approved'` carries the
|
|
301
|
+
* minted agent in `agent`; `'denied'` may carry the owner's
|
|
302
|
+
* `reason`; `'expired'` is terminal after 14 days.
|
|
303
|
+
*/
|
|
304
|
+
pollRegistration(requestId: string): Promise<PollRegistrationResult>;
|
|
305
|
+
/**
|
|
306
|
+
* Block until a pending registration request resolves to a terminal state.
|
|
307
|
+
* Resolves to the live `AgentRecord` on approval; rejects with the matching
|
|
308
|
+
* Registration*Error on deny/expire/timeout. Usually called via
|
|
309
|
+
* `register({ waitForApproval: true })`, but exposed for callers that want
|
|
310
|
+
* to fire-and-forget the initial register call and resume waiting later
|
|
311
|
+
* (e.g. after restoring a stored `requestId` on cold start).
|
|
312
|
+
*/
|
|
313
|
+
waitForApproval(requestId: string, options?: WaitForApprovalOptions): Promise<AgentRecord>;
|
|
181
314
|
/**
|
|
182
315
|
* Look up an agent's public profile by ASTRA ID or UUID.
|
|
183
316
|
*/
|
|
@@ -187,6 +320,12 @@ declare class AstraSync {
|
|
|
187
320
|
*/
|
|
188
321
|
health(): Promise<HealthResponse>;
|
|
189
322
|
private request;
|
|
323
|
+
/**
|
|
324
|
+
* Variant of {@link request} that also returns the HTTP status code, so
|
|
325
|
+
* callers can branch on 201 vs 202 (or other success codes) without losing
|
|
326
|
+
* type information about the response body.
|
|
327
|
+
*/
|
|
328
|
+
private requestWithStatus;
|
|
190
329
|
private getAuthToken;
|
|
191
330
|
/**
|
|
192
331
|
* Sign a request using secp256k1 (ethers.js).
|
|
@@ -214,5 +353,33 @@ declare class KYDRequiredError extends AstraSyncError {
|
|
|
214
353
|
declare class AuthenticationError extends AstraSyncError {
|
|
215
354
|
constructor(message: string);
|
|
216
355
|
}
|
|
356
|
+
/**
|
|
357
|
+
* Thrown by `register({ waitForApproval: true })` when the owner denies the
|
|
358
|
+
* pending registration request. The `reason` field, when present, mirrors the
|
|
359
|
+
* deny note the owner left in the dashboard.
|
|
360
|
+
*/
|
|
361
|
+
declare class RegistrationDeniedError extends AstraSyncError {
|
|
362
|
+
readonly requestId: string;
|
|
363
|
+
readonly reason?: string;
|
|
364
|
+
constructor(requestId: string, reason?: string);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Thrown by `register({ waitForApproval: true })` when the pending request
|
|
368
|
+
* passes its 14-day TTL with no owner decision. The agent must re-submit.
|
|
369
|
+
*/
|
|
370
|
+
declare class RegistrationExpiredError extends AstraSyncError {
|
|
371
|
+
readonly requestId: string;
|
|
372
|
+
constructor(requestId: string);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Thrown by `register({ waitForApproval: true })` when the caller's local
|
|
376
|
+
* `timeoutMs` elapses before the owner makes a decision. The request is still
|
|
377
|
+
* live server-side — poll `pollRegistration(requestId)` to resume waiting, or
|
|
378
|
+
* call `waitForApproval` again with a longer timeout.
|
|
379
|
+
*/
|
|
380
|
+
declare class RegistrationTimeoutError extends AstraSyncError {
|
|
381
|
+
readonly requestId: string;
|
|
382
|
+
constructor(requestId: string);
|
|
383
|
+
}
|
|
217
384
|
|
|
218
|
-
export { type AgentProtocol, type AgentRecord, AstraSync, type AstraSyncConfig, AstraSyncError, AuthenticationError, type FrameworkConfig, type HealthResponse, KYDRequiredError, type ModelConfig, type PDLSSConfig, type PDLSSDuration, type PDLSSLimits, type PDLSSPurpose, type PDLSSScope, type PDLSSSelfInstantiation, type RegisterOptions, type RegistrationResponse, type VerifyResponse };
|
|
385
|
+
export { type AgentProtocol, type AgentRecord, AstraSync, type AstraSyncConfig, AstraSyncError, AuthenticationError, type FrameworkConfig, type HealthResponse, KYDRequiredError, type ModelConfig, type PDLSSConfig, type PDLSSDuration, type PDLSSLimits, type PDLSSPurpose, type PDLSSScope, type PDLSSSelfInstantiation, type PendingRegistrationResponse, type PollRegistrationResult, type RegisterOptions, type RegisterResult, RegistrationDeniedError, RegistrationExpiredError, type RegistrationResponse, RegistrationTimeoutError, type VerifyResponse, type WaitForApprovalOptions };
|
|
@@ -9,11 +9,27 @@ interface AstraSyncConfig {
|
|
|
9
9
|
/** secp256k1 private key for crypto signing. Used WITH apiKey or email+password. */
|
|
10
10
|
privateKey?: string;
|
|
11
11
|
/**
|
|
12
|
-
* Base URL for the AstraSync API.
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* Base URL for the AstraSync API. Pass the bare ORIGIN — the SDK appends
|
|
13
|
+
* `/api/agents/...` for each call.
|
|
14
|
+
*
|
|
15
|
+
* - Production: `https://astrasync.ai` (default)
|
|
16
|
+
* - Staging: `https://staging.astrasync.ai`
|
|
17
|
+
*
|
|
18
|
+
* A trailing `/api` is tolerated for compatibility with the
|
|
19
|
+
* `GatewayConfig.apiBaseUrl` convention used by the verification gateway
|
|
20
|
+
* — if you pass `https://astrasync.ai/api` the SDK strips the suffix and
|
|
21
|
+
* emits a one-time console.warn so you can fix the source.
|
|
22
|
+
*
|
|
23
|
+
* Defaults to the `ASTRASYNC_API_URL` env var, then production.
|
|
15
24
|
*/
|
|
16
25
|
baseUrl?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Suppress the one-time console.warn emitted on baseUrl normalization,
|
|
28
|
+
* deprecation, or other non-fatal SDK conditions. Default: `false`
|
|
29
|
+
* (warnings emit). Set `true` in test runners or where logs are
|
|
30
|
+
* structured.
|
|
31
|
+
*/
|
|
32
|
+
silent?: boolean;
|
|
17
33
|
}
|
|
18
34
|
/**
|
|
19
35
|
* Multi-protocol declarations the agent participates in.
|
|
@@ -93,6 +109,12 @@ interface RegisterOptions {
|
|
|
93
109
|
name: string;
|
|
94
110
|
description?: string;
|
|
95
111
|
agentType?: string;
|
|
112
|
+
/**
|
|
113
|
+
* URL where your agent's verification-gateway SDK is mounted for runtime
|
|
114
|
+
* challenges. Optional — if omitted, your agent declares no runtime-challenge
|
|
115
|
+
* support and some counterparties may decline access requests. Mirrors the
|
|
116
|
+
* webUI "API endpoint" field.
|
|
117
|
+
*/
|
|
96
118
|
apiEndpoint?: string;
|
|
97
119
|
model?: ModelConfig;
|
|
98
120
|
framework?: FrameworkConfig;
|
|
@@ -101,7 +123,59 @@ interface RegisterOptions {
|
|
|
101
123
|
metadata?: Record<string, unknown>;
|
|
102
124
|
pdlss?: PDLSSConfig;
|
|
103
125
|
}
|
|
104
|
-
/**
|
|
126
|
+
/**
|
|
127
|
+
* Optional blocking-mode flags for `register()`. When `waitForApproval` is
|
|
128
|
+
* true and the backend returns 202 pending, the SDK polls until the request
|
|
129
|
+
* resolves (approved → returns Agent; denied/expired → throws; timeout →
|
|
130
|
+
* throws). The default is non-blocking: the SDK returns the pending result
|
|
131
|
+
* immediately and the caller handles polling itself.
|
|
132
|
+
*/
|
|
133
|
+
interface WaitForApprovalOptions {
|
|
134
|
+
/** Block until the request resolves. Default: false. */
|
|
135
|
+
waitForApproval?: boolean;
|
|
136
|
+
/** How long to wait in blocking mode. Default: 600_000ms (10 min). */
|
|
137
|
+
timeoutMs?: number;
|
|
138
|
+
/** Poll cadence in blocking mode. Default: 5000ms. */
|
|
139
|
+
pollIntervalMs?: number;
|
|
140
|
+
/** Called once per poll while still pending; useful for progress UX. */
|
|
141
|
+
onPending?: (event: {
|
|
142
|
+
requestId: string;
|
|
143
|
+
ageMs: number;
|
|
144
|
+
}) => void;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Discriminated registration result.
|
|
148
|
+
*
|
|
149
|
+
* - `active`: synchronous path (crypto-keypair signature verified, or
|
|
150
|
+
* email+password auth). `agent` is the live record.
|
|
151
|
+
* - `pending_approval`: API-key auth path. The owner has been notified by
|
|
152
|
+
* email and a dashboard alert. Poll `pollUrl` or call
|
|
153
|
+
* `sdk.pollRegistration(requestId)` to track progress, or re-call
|
|
154
|
+
* `register` with `waitForApproval: true` to block.
|
|
155
|
+
*/
|
|
156
|
+
type RegisterResult = {
|
|
157
|
+
status: 'active';
|
|
158
|
+
agent: AgentRecord;
|
|
159
|
+
} | {
|
|
160
|
+
status: 'pending_approval';
|
|
161
|
+
requestId: string;
|
|
162
|
+
expiresAt: string;
|
|
163
|
+
pollUrl: string;
|
|
164
|
+
message?: string;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Response shape from `pollRegistration(requestId)` and the internal poll
|
|
168
|
+
* loop. State `pending` means still awaiting owner; the others are terminal.
|
|
169
|
+
*/
|
|
170
|
+
interface PollRegistrationResult {
|
|
171
|
+
state: 'pending' | 'approved' | 'denied' | 'expired';
|
|
172
|
+
agent?: AgentRecord;
|
|
173
|
+
reason?: string;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Response from agent registration (raw 201 body). Use {@link RegisterResult}
|
|
177
|
+
* for the consumer-facing shape returned from `sdk.register()`.
|
|
178
|
+
*/
|
|
105
179
|
interface RegistrationResponse {
|
|
106
180
|
success: boolean;
|
|
107
181
|
message: string;
|
|
@@ -109,6 +183,15 @@ interface RegistrationResponse {
|
|
|
109
183
|
agent: AgentRecord;
|
|
110
184
|
};
|
|
111
185
|
}
|
|
186
|
+
/** Raw 202 body — internal type, exposed via {@link RegisterResult}. */
|
|
187
|
+
interface PendingRegistrationResponse {
|
|
188
|
+
success: true;
|
|
189
|
+
status: 'pending_approval';
|
|
190
|
+
requestId: string;
|
|
191
|
+
expiresAt: string;
|
|
192
|
+
pollUrl: string;
|
|
193
|
+
message?: string;
|
|
194
|
+
}
|
|
112
195
|
/** Agent record from the API. */
|
|
113
196
|
interface AgentRecord {
|
|
114
197
|
kyaAgentId: string;
|
|
@@ -175,9 +258,59 @@ declare class AstraSync {
|
|
|
175
258
|
constructor(config?: AstraSyncConfig);
|
|
176
259
|
/**
|
|
177
260
|
* Register a new AI agent on the AstraSync KYA Platform.
|
|
178
|
-
*
|
|
261
|
+
*
|
|
262
|
+
* The backend response depends on auth context:
|
|
263
|
+
* - **Crypto-keypair signed** (`privateKey` configured): synchronous 201,
|
|
264
|
+
* returns `{ status: 'active', agent }`.
|
|
265
|
+
* - **API-key only** (no signature): 202 pending, returns
|
|
266
|
+
* `{ status: 'pending_approval', requestId, pollUrl, expiresAt }`. The
|
|
267
|
+
* owner is notified by email and a dashboard alert is emitted; the agent
|
|
268
|
+
* becomes active only after the owner approves.
|
|
269
|
+
*
|
|
270
|
+
* Blocking mode: pass `{ waitForApproval: true }` to have the SDK poll the
|
|
271
|
+
* request until it resolves, then return the live agent record. The promise
|
|
272
|
+
* rejects with `RegistrationDeniedError`, `RegistrationExpiredError`, or
|
|
273
|
+
* `RegistrationTimeoutError` on the corresponding terminal states.
|
|
274
|
+
*
|
|
275
|
+
* @example Non-blocking (default — best for serverless / scheduled agents):
|
|
276
|
+
* ```typescript
|
|
277
|
+
* const result = await sdk.register({ name, pdlss });
|
|
278
|
+
* if (result.status === 'pending_approval') {
|
|
279
|
+
* storeRequestId(result.requestId);
|
|
280
|
+
* return; // function exits; resume later via pollRegistration()
|
|
281
|
+
* }
|
|
282
|
+
* ```
|
|
283
|
+
*
|
|
284
|
+
* @example Blocking (best for long-running services + CLI):
|
|
285
|
+
* ```typescript
|
|
286
|
+
* const agent = await sdk.register({
|
|
287
|
+
* name, pdlss, waitForApproval: true, timeoutMs: 600_000,
|
|
288
|
+
* onPending: ({ ageMs }) => console.log(`waiting ${ageMs}ms`),
|
|
289
|
+
* });
|
|
290
|
+
* ```
|
|
179
291
|
*/
|
|
180
|
-
register(options: RegisterOptions): Promise<
|
|
292
|
+
register(options: RegisterOptions & WaitForApprovalOptions): Promise<RegisterResult | AgentRecord>;
|
|
293
|
+
/**
|
|
294
|
+
* Poll the current state of a pending-approval registration request.
|
|
295
|
+
*
|
|
296
|
+
* Useful for caller-driven polling when `waitForApproval: false` (the
|
|
297
|
+
* default). The endpoint is unauthenticated — pass the `requestId` that
|
|
298
|
+
* was returned from the 202 response.
|
|
299
|
+
*
|
|
300
|
+
* @returns `state: 'pending'` while awaiting; `'approved'` carries the
|
|
301
|
+
* minted agent in `agent`; `'denied'` may carry the owner's
|
|
302
|
+
* `reason`; `'expired'` is terminal after 14 days.
|
|
303
|
+
*/
|
|
304
|
+
pollRegistration(requestId: string): Promise<PollRegistrationResult>;
|
|
305
|
+
/**
|
|
306
|
+
* Block until a pending registration request resolves to a terminal state.
|
|
307
|
+
* Resolves to the live `AgentRecord` on approval; rejects with the matching
|
|
308
|
+
* Registration*Error on deny/expire/timeout. Usually called via
|
|
309
|
+
* `register({ waitForApproval: true })`, but exposed for callers that want
|
|
310
|
+
* to fire-and-forget the initial register call and resume waiting later
|
|
311
|
+
* (e.g. after restoring a stored `requestId` on cold start).
|
|
312
|
+
*/
|
|
313
|
+
waitForApproval(requestId: string, options?: WaitForApprovalOptions): Promise<AgentRecord>;
|
|
181
314
|
/**
|
|
182
315
|
* Look up an agent's public profile by ASTRA ID or UUID.
|
|
183
316
|
*/
|
|
@@ -187,6 +320,12 @@ declare class AstraSync {
|
|
|
187
320
|
*/
|
|
188
321
|
health(): Promise<HealthResponse>;
|
|
189
322
|
private request;
|
|
323
|
+
/**
|
|
324
|
+
* Variant of {@link request} that also returns the HTTP status code, so
|
|
325
|
+
* callers can branch on 201 vs 202 (or other success codes) without losing
|
|
326
|
+
* type information about the response body.
|
|
327
|
+
*/
|
|
328
|
+
private requestWithStatus;
|
|
190
329
|
private getAuthToken;
|
|
191
330
|
/**
|
|
192
331
|
* Sign a request using secp256k1 (ethers.js).
|
|
@@ -214,5 +353,33 @@ declare class KYDRequiredError extends AstraSyncError {
|
|
|
214
353
|
declare class AuthenticationError extends AstraSyncError {
|
|
215
354
|
constructor(message: string);
|
|
216
355
|
}
|
|
356
|
+
/**
|
|
357
|
+
* Thrown by `register({ waitForApproval: true })` when the owner denies the
|
|
358
|
+
* pending registration request. The `reason` field, when present, mirrors the
|
|
359
|
+
* deny note the owner left in the dashboard.
|
|
360
|
+
*/
|
|
361
|
+
declare class RegistrationDeniedError extends AstraSyncError {
|
|
362
|
+
readonly requestId: string;
|
|
363
|
+
readonly reason?: string;
|
|
364
|
+
constructor(requestId: string, reason?: string);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Thrown by `register({ waitForApproval: true })` when the pending request
|
|
368
|
+
* passes its 14-day TTL with no owner decision. The agent must re-submit.
|
|
369
|
+
*/
|
|
370
|
+
declare class RegistrationExpiredError extends AstraSyncError {
|
|
371
|
+
readonly requestId: string;
|
|
372
|
+
constructor(requestId: string);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Thrown by `register({ waitForApproval: true })` when the caller's local
|
|
376
|
+
* `timeoutMs` elapses before the owner makes a decision. The request is still
|
|
377
|
+
* live server-side — poll `pollRegistration(requestId)` to resume waiting, or
|
|
378
|
+
* call `waitForApproval` again with a longer timeout.
|
|
379
|
+
*/
|
|
380
|
+
declare class RegistrationTimeoutError extends AstraSyncError {
|
|
381
|
+
readonly requestId: string;
|
|
382
|
+
constructor(requestId: string);
|
|
383
|
+
}
|
|
217
384
|
|
|
218
|
-
export { type AgentProtocol, type AgentRecord, AstraSync, type AstraSyncConfig, AstraSyncError, AuthenticationError, type FrameworkConfig, type HealthResponse, KYDRequiredError, type ModelConfig, type PDLSSConfig, type PDLSSDuration, type PDLSSLimits, type PDLSSPurpose, type PDLSSScope, type PDLSSSelfInstantiation, type RegisterOptions, type RegistrationResponse, type VerifyResponse };
|
|
385
|
+
export { type AgentProtocol, type AgentRecord, AstraSync, type AstraSyncConfig, AstraSyncError, AuthenticationError, type FrameworkConfig, type HealthResponse, KYDRequiredError, type ModelConfig, type PDLSSConfig, type PDLSSDuration, type PDLSSLimits, type PDLSSPurpose, type PDLSSScope, type PDLSSSelfInstantiation, type PendingRegistrationResponse, type PollRegistrationResult, type RegisterOptions, type RegisterResult, RegistrationDeniedError, RegistrationExpiredError, type RegistrationResponse, RegistrationTimeoutError, type VerifyResponse, type WaitForApprovalOptions };
|