@provenonce/sdk 0.8.0 → 0.10.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 +78 -21
- package/dist/index.d.mts +301 -23
- package/dist/index.d.ts +301 -23
- package/dist/index.js +396 -66
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +387 -67
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @provenonce/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Cryptographic identity and accountability SDK for AI agents. Chain-agnostic (Solana + Ethereum).
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -15,7 +15,7 @@ Before using the SDK, register your agent to get an API key:
|
|
|
15
15
|
```typescript
|
|
16
16
|
import { register } from '@provenonce/sdk';
|
|
17
17
|
|
|
18
|
-
//
|
|
18
|
+
// No-wallet registration (default — identity only)
|
|
19
19
|
const creds = await register('my-agent-v1', {
|
|
20
20
|
registryUrl: 'https://provenonce.io',
|
|
21
21
|
registrationSecret: process.env.REGISTRATION_SECRET, // required in production
|
|
@@ -25,6 +25,14 @@ console.log(creds.hash); // unique agent identity
|
|
|
25
25
|
console.log(creds.api_key); // use this for BeatAgent
|
|
26
26
|
console.log(creds.secret); // save — shown only once
|
|
27
27
|
|
|
28
|
+
// Solana self-custody wallet (opt-in)
|
|
29
|
+
const withWallet = await register('my-org', {
|
|
30
|
+
registryUrl: 'https://provenonce.io',
|
|
31
|
+
walletModel: 'self-custody',
|
|
32
|
+
});
|
|
33
|
+
// withWallet.wallet.address = Solana address
|
|
34
|
+
// withWallet.wallet.secret_key = SAVE — cannot be recovered
|
|
35
|
+
|
|
28
36
|
// Child registration (requires parent credentials)
|
|
29
37
|
const child = await register('worker-1', {
|
|
30
38
|
registryUrl: 'https://provenonce.io',
|
|
@@ -45,9 +53,23 @@ const agent = new BeatAgent({
|
|
|
45
53
|
});
|
|
46
54
|
|
|
47
55
|
await agent.init(); // Birth in Beat time
|
|
48
|
-
agent.startHeartbeat(); // Compute + check in continuously
|
|
49
56
|
|
|
50
|
-
//
|
|
57
|
+
// Purchase a SIGIL (cryptographic identity)
|
|
58
|
+
const sigil = await agent.purchaseSigil({
|
|
59
|
+
identityClass: 'autonomous',
|
|
60
|
+
paymentTx: 'solana-tx-signature...',
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Start heartbeating (paid liveness proofs)
|
|
64
|
+
agent.startHeartbeat();
|
|
65
|
+
|
|
66
|
+
// Get your Passport (latest lineage proof)
|
|
67
|
+
const passport = await agent.getPassport();
|
|
68
|
+
console.log(passport?.identity_class); // 'autonomous'
|
|
69
|
+
console.log(passport?.provenonce_signature); // Ed25519 signed
|
|
70
|
+
|
|
71
|
+
// Verify any proof offline — no API call needed
|
|
72
|
+
const valid = BeatAgent.verifyProofLocally(passport, authorityPubKeyHex);
|
|
51
73
|
|
|
52
74
|
agent.stopHeartbeat();
|
|
53
75
|
```
|
|
@@ -59,14 +81,16 @@ agent.stopHeartbeat();
|
|
|
59
81
|
| Method | Description |
|
|
60
82
|
|--------|-------------|
|
|
61
83
|
| `init()` | Initialize the agent's Beat chain (birth in Logical Time) |
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
64
|
-
| `startHeartbeat()` | Start autonomous
|
|
65
|
-
| `stopHeartbeat()` | Stop heartbeat
|
|
66
|
-
| `
|
|
84
|
+
| `purchaseSigil(opts)` | Purchase a SIGIL identity (required for heartbeating) |
|
|
85
|
+
| `heartbeat(opts?)` | Submit a paid heartbeat and receive a signed lineage proof |
|
|
86
|
+
| `startHeartbeat()` | Start autonomous heartbeat loop |
|
|
87
|
+
| `stopHeartbeat()` | Stop heartbeat |
|
|
88
|
+
| `getPassport()` | Get latest lineage proof (Passport) |
|
|
89
|
+
| `reissueProof(paymentTx?)` | Reissue proof without extending lineage |
|
|
67
90
|
| `requestSpawn(name?)` | Spawn a child agent (requires accumulated beats) |
|
|
68
91
|
| `getStatus()` | Get full beat status from registry |
|
|
69
92
|
| `getLocalState()` | Get local state (no network call) |
|
|
93
|
+
| `static verifyProofLocally(proof, pubKey)` | Verify a lineage proof offline |
|
|
70
94
|
|
|
71
95
|
### `BeatAgentConfig`
|
|
72
96
|
|
|
@@ -74,24 +98,57 @@ agent.stopHeartbeat();
|
|
|
74
98
|
|--------|---------|-------------|
|
|
75
99
|
| `apiKey` | *required* | API key from registration (`pvn_...`) |
|
|
76
100
|
| `registryUrl` | *required* | Provenonce registry URL |
|
|
77
|
-
| `
|
|
78
|
-
| `
|
|
79
|
-
| `onPulse` | — | Callback when heartbeat ticks |
|
|
80
|
-
| `onCheckin` | — | Callback when check-in completes |
|
|
101
|
+
| `heartbeatIntervalSec` | `300` | Seconds between automatic heartbeats |
|
|
102
|
+
| `onHeartbeat` | — | Callback when heartbeat completes |
|
|
81
103
|
| `onError` | — | Callback on error |
|
|
82
104
|
| `onStatusChange` | — | Callback when status changes |
|
|
83
105
|
| `verbose` | `false` | Enable console logging |
|
|
84
106
|
|
|
85
|
-
###
|
|
107
|
+
### `register(name, options)`
|
|
108
|
+
|
|
109
|
+
| Option | Description |
|
|
110
|
+
|--------|-------------|
|
|
111
|
+
| `registryUrl` | Registry URL (required) |
|
|
112
|
+
| `registrationSecret` | Registration gate (mainnet) |
|
|
113
|
+
| `walletModel` | `'self-custody'` or `'operator'` (opt-in wallet) |
|
|
114
|
+
| `walletChain` | `'solana'` or `'ethereum'` |
|
|
115
|
+
| `walletAddress` | Ethereum BYO address |
|
|
116
|
+
| `walletSignFn` | Signing function for BYO wallets |
|
|
117
|
+
| `parentHash` | Parent hash (child registration) |
|
|
118
|
+
| `parentApiKey` | Parent's API key (child registration) |
|
|
119
|
+
|
|
120
|
+
Returns `RegistrationResult` with `hash`, `api_key`, `secret`, `wallet?`.
|
|
121
|
+
|
|
122
|
+
**Note:** Agent names should only contain `[a-zA-Z0-9_\-. ]`. Other characters are stripped by the server before signature verification.
|
|
123
|
+
|
|
124
|
+
### Phase 2 Types
|
|
86
125
|
|
|
87
126
|
```typescript
|
|
88
|
-
import {
|
|
127
|
+
import type { Passport, LineageProof, IdentityClass, SigilResult, HeartbeatResult } from '@provenonce/sdk';
|
|
89
128
|
|
|
90
|
-
//
|
|
91
|
-
|
|
129
|
+
// Passport = LineageProof (type alias)
|
|
130
|
+
// Contains: agent_hash, agent_public_key, identity_class, lineage_chain_hash,
|
|
131
|
+
// provenonce_signature, issued_at, valid_until, etc.
|
|
92
132
|
|
|
93
|
-
//
|
|
94
|
-
|
|
133
|
+
// IdentityClass = 'narrow_task' | 'autonomous' | 'orchestrator'
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Error Handling
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
import { ProvenonceError, AuthError, RateLimitError, FrozenError, ErrorCode } from '@provenonce/sdk';
|
|
140
|
+
|
|
141
|
+
try {
|
|
142
|
+
await agent.heartbeat();
|
|
143
|
+
} catch (err) {
|
|
144
|
+
if (err instanceof RateLimitError) {
|
|
145
|
+
console.log(`Retry after ${err.retryAfterMs}ms`);
|
|
146
|
+
} else if (err instanceof FrozenError) {
|
|
147
|
+
console.log('Agent is frozen — heartbeat refused');
|
|
148
|
+
} else if (err instanceof AuthError) {
|
|
149
|
+
console.log('Invalid API key');
|
|
150
|
+
}
|
|
151
|
+
}
|
|
95
152
|
```
|
|
96
153
|
|
|
97
154
|
## Framework Integration Examples
|
|
@@ -111,5 +168,5 @@ Python examples use the REST API directly — no Python SDK needed. See [`exampl
|
|
|
111
168
|
|
|
112
169
|
- [Live prototype](https://provenonce.io)
|
|
113
170
|
- [npm package](https://www.npmjs.com/package/@provenonce/sdk)
|
|
114
|
-
- [API docs](https://provenonce.
|
|
115
|
-
- [
|
|
171
|
+
- [API docs](https://provenonce.dev)
|
|
172
|
+
- [Whitepaper](https://provenonce.dev/concepts/architecture)
|
package/dist/index.d.mts
CHANGED
|
@@ -26,6 +26,132 @@
|
|
|
26
26
|
*
|
|
27
27
|
* ═══════════════════════════════════════════════════════════
|
|
28
28
|
*/
|
|
29
|
+
/** SIGIL identity class — determines tier pricing and heartbeat volume caps */
|
|
30
|
+
type IdentityClass = 'narrow_task' | 'autonomous' | 'orchestrator';
|
|
31
|
+
/** SIGIL trust governance tier — orthogonal to identity_class (fee axis) */
|
|
32
|
+
type SigilTier = 'sov' | 'org' | 'ind' | 'eph' | 'sbx';
|
|
33
|
+
/** Substrate — what the agent runs on */
|
|
34
|
+
type Substrate = 'frontier' | 'open' | 'local' | 'symbolic' | 'hybrid' | 'human';
|
|
35
|
+
/** Substrate provider */
|
|
36
|
+
type SubstrateProvider = 'anthropic' | 'openai' | 'google' | 'meta' | 'mistral' | 'xai' | 'cohere' | 'deepseek' | 'custom';
|
|
37
|
+
/** Capability — what the agent primarily does */
|
|
38
|
+
type Capability = 'analyst' | 'executor' | 'orchestrator' | 'guardian' | 'retriever' | 'renderer' | 'witness';
|
|
39
|
+
/** Protocol — how to reach the agent */
|
|
40
|
+
type SigilProtocol = 'http' | 'grpc' | 'websocket' | 'mcp' | 'a2a' | 'custom';
|
|
41
|
+
/** Compliance regime */
|
|
42
|
+
type ComplianceRegime = 'gdpr' | 'pdpa' | 'hipaa' | 'sox' | 'aisi' | 'none' | 'custom';
|
|
43
|
+
/**
|
|
44
|
+
* Ed25519-signed lineage proof — portable, offline-verifiable credential.
|
|
45
|
+
* Also known as the agent's "passport" — a cryptographic proof of identity
|
|
46
|
+
* that can be verified offline without any API call or SOL cost.
|
|
47
|
+
*/
|
|
48
|
+
interface LineageProof {
|
|
49
|
+
agent_hash: string;
|
|
50
|
+
agent_public_key: string | null;
|
|
51
|
+
identity_class: IdentityClass;
|
|
52
|
+
registered_at_beat: number;
|
|
53
|
+
sigil_issued_at_beat: number | null;
|
|
54
|
+
last_heartbeat_beat: number;
|
|
55
|
+
lineage_chain_hash: string;
|
|
56
|
+
issued_at: number;
|
|
57
|
+
valid_until: number;
|
|
58
|
+
provenonce_signature: string;
|
|
59
|
+
}
|
|
60
|
+
/** Passport = LineageProof. The agent's portable, offline-verifiable credential. */
|
|
61
|
+
type Passport = LineageProof;
|
|
62
|
+
/** Options for purchasing a SIGIL with full namespace */
|
|
63
|
+
interface SigilPurchaseOptions {
|
|
64
|
+
identity_class: IdentityClass;
|
|
65
|
+
principal: string;
|
|
66
|
+
tier: SigilTier;
|
|
67
|
+
name?: string;
|
|
68
|
+
payment_tx: string;
|
|
69
|
+
substrate?: Substrate;
|
|
70
|
+
substrate_provider?: SubstrateProvider;
|
|
71
|
+
substrate_model?: string;
|
|
72
|
+
capability?: Capability;
|
|
73
|
+
capability_scope?: string;
|
|
74
|
+
tools?: string[];
|
|
75
|
+
modality_input?: string[];
|
|
76
|
+
modality_output?: string[];
|
|
77
|
+
protocol?: SigilProtocol;
|
|
78
|
+
endpoint?: string;
|
|
79
|
+
compliance_regime?: ComplianceRegime;
|
|
80
|
+
}
|
|
81
|
+
/** Mutable SIGIL metadata fields for PATCH updates */
|
|
82
|
+
interface SigilMutableFields {
|
|
83
|
+
substrate?: Substrate;
|
|
84
|
+
substrate_provider?: SubstrateProvider;
|
|
85
|
+
substrate_model?: string;
|
|
86
|
+
capability?: Capability;
|
|
87
|
+
capability_scope?: string;
|
|
88
|
+
generation_trigger?: string;
|
|
89
|
+
tools?: string[];
|
|
90
|
+
modality_input?: string[];
|
|
91
|
+
modality_output?: string[];
|
|
92
|
+
protocol?: SigilProtocol;
|
|
93
|
+
endpoint?: string;
|
|
94
|
+
compliance_regime?: ComplianceRegime;
|
|
95
|
+
}
|
|
96
|
+
/** Result from purchasing a SIGIL (Structured Identity Governance and Intelligent Lookup) */
|
|
97
|
+
interface SigilResult {
|
|
98
|
+
ok: boolean;
|
|
99
|
+
sigil?: {
|
|
100
|
+
sigil: string;
|
|
101
|
+
sigil_name: string;
|
|
102
|
+
principal: string;
|
|
103
|
+
tier: SigilTier;
|
|
104
|
+
identity_class: IdentityClass;
|
|
105
|
+
issued_at_beat: number;
|
|
106
|
+
birth_tx: string | null;
|
|
107
|
+
explorer_url: string | null;
|
|
108
|
+
};
|
|
109
|
+
lineage_proof?: LineageProof;
|
|
110
|
+
fee?: {
|
|
111
|
+
amount_sol: number;
|
|
112
|
+
amount_lamports: number;
|
|
113
|
+
payment_tx: string | null;
|
|
114
|
+
};
|
|
115
|
+
error?: string;
|
|
116
|
+
}
|
|
117
|
+
/** Result from updating mutable SIGIL metadata */
|
|
118
|
+
interface MetadataUpdateResult {
|
|
119
|
+
ok: boolean;
|
|
120
|
+
sigil?: string;
|
|
121
|
+
generation?: number;
|
|
122
|
+
updated_fields?: string[];
|
|
123
|
+
error?: string;
|
|
124
|
+
}
|
|
125
|
+
/** Result from offline lineage proof verification */
|
|
126
|
+
interface VerificationResult {
|
|
127
|
+
/** Overall validity: signature is valid AND not expired */
|
|
128
|
+
valid: boolean;
|
|
129
|
+
/** Ed25519 signature verification passed */
|
|
130
|
+
signatureValid: boolean;
|
|
131
|
+
/** Proof has passed its valid_until timestamp */
|
|
132
|
+
expired: boolean;
|
|
133
|
+
/** The beat index of the agent's last heartbeat */
|
|
134
|
+
lastHeartbeatBeat: number;
|
|
135
|
+
/** Beats elapsed since last heartbeat (null if currentBeat not provided) */
|
|
136
|
+
beatsSinceHeartbeat: number | null;
|
|
137
|
+
/** Human-readable warning if proof is expired or stale */
|
|
138
|
+
warning?: string;
|
|
139
|
+
}
|
|
140
|
+
/** Result from a paid heartbeat */
|
|
141
|
+
interface HeartbeatResult {
|
|
142
|
+
ok: boolean;
|
|
143
|
+
lineage_proof?: LineageProof;
|
|
144
|
+
heartbeat_count_epoch?: number;
|
|
145
|
+
billing_epoch?: number;
|
|
146
|
+
current_beat?: number;
|
|
147
|
+
fee?: {
|
|
148
|
+
amount_sol: number;
|
|
149
|
+
amount_lamports: number;
|
|
150
|
+
tier: number;
|
|
151
|
+
payment_tx: string | null;
|
|
152
|
+
};
|
|
153
|
+
error?: string;
|
|
154
|
+
}
|
|
29
155
|
interface Beat {
|
|
30
156
|
index: number;
|
|
31
157
|
hash: string;
|
|
@@ -97,8 +223,10 @@ interface RegistrationResult {
|
|
|
97
223
|
depth: number;
|
|
98
224
|
name: string;
|
|
99
225
|
metadata?: Record<string, unknown> | null;
|
|
100
|
-
|
|
101
|
-
|
|
226
|
+
/** @deprecated No Solana write at registration (D-65). Will be null. */
|
|
227
|
+
signature?: string | null;
|
|
228
|
+
/** @deprecated No Solana write at registration (D-65). Will be null. */
|
|
229
|
+
explorer_url?: string | null;
|
|
102
230
|
/** Wallet chain: 'solana', 'ethereum', or null (no wallet) */
|
|
103
231
|
wallet_chain?: string | null;
|
|
104
232
|
beat?: {
|
|
@@ -108,6 +236,11 @@ interface RegistrationResult {
|
|
|
108
236
|
};
|
|
109
237
|
/** Wallet info — only present for root agents with wallets */
|
|
110
238
|
wallet?: WalletInfo;
|
|
239
|
+
/** Next steps after registration */
|
|
240
|
+
_next_steps?: {
|
|
241
|
+
sigil?: string;
|
|
242
|
+
heartbeat?: string;
|
|
243
|
+
};
|
|
111
244
|
}
|
|
112
245
|
/**
|
|
113
246
|
* Register a new agent on the Provenonce registry.
|
|
@@ -179,14 +312,18 @@ interface BeatAgentConfig {
|
|
|
179
312
|
apiKey: string;
|
|
180
313
|
/** Provenonce registry URL */
|
|
181
314
|
registryUrl: string;
|
|
182
|
-
/** Beats to compute per pulse (default: 10) */
|
|
315
|
+
/** @deprecated Use heartbeatIntervalSec. Beats to compute per pulse (default: 10) */
|
|
183
316
|
beatsPerPulse?: number;
|
|
184
|
-
/** Seconds between automatic check-ins (default: 300 = 5min) */
|
|
317
|
+
/** @deprecated Use heartbeatIntervalSec. Seconds between automatic check-ins (default: 300 = 5min) */
|
|
185
318
|
checkinIntervalSec?: number;
|
|
186
|
-
/**
|
|
319
|
+
/** Seconds between automatic heartbeats (default: 300 = 5min). Replaces checkinIntervalSec. */
|
|
320
|
+
heartbeatIntervalSec?: number;
|
|
321
|
+
/** @deprecated VDF pulse callback. No longer used in Phase 2. */
|
|
187
322
|
onPulse?: (beats: Beat[], totalBeats: number) => void;
|
|
188
|
-
/** Callback when check-in completes */
|
|
323
|
+
/** @deprecated Use onHeartbeat. Callback when check-in completes. */
|
|
189
324
|
onCheckin?: (result: CheckinResult) => void;
|
|
325
|
+
/** Callback when heartbeat completes (Phase 2) */
|
|
326
|
+
onHeartbeat?: (result: HeartbeatResult) => void;
|
|
190
327
|
/** Callback on error */
|
|
191
328
|
onError?: (error: Error, context: string) => void;
|
|
192
329
|
/** Callback when status changes */
|
|
@@ -218,18 +355,17 @@ declare class BeatAgent {
|
|
|
218
355
|
error?: string;
|
|
219
356
|
}>;
|
|
220
357
|
/**
|
|
358
|
+
* @deprecated Phase 2: VDF computation retired (D-68). Payment is the liveness mechanism.
|
|
359
|
+
* Use heartbeat() instead. This method will be removed in the next major version.
|
|
360
|
+
*
|
|
221
361
|
* Compute N beats locally (VDF hash chain).
|
|
222
|
-
* This is the "heartbeat" — proof that the agent has lived
|
|
223
|
-
* through a specific window of computational time.
|
|
224
362
|
*/
|
|
225
363
|
pulse(count?: number): Beat[];
|
|
226
364
|
/** Internal beat computation — no status check. Used by both pulse() and resync(). */
|
|
227
365
|
private computeBeats;
|
|
228
366
|
/**
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
* "To remain on the Whitelist, an agent must periodically
|
|
232
|
-
* submit a proof of its Local Beats to the Registry."
|
|
367
|
+
* @deprecated Phase 2: VDF check-in retired (D-68). Use heartbeat() instead.
|
|
368
|
+
* This method will be removed in the next major version.
|
|
233
369
|
*/
|
|
234
370
|
checkin(): Promise<{
|
|
235
371
|
ok: boolean;
|
|
@@ -238,21 +374,19 @@ declare class BeatAgent {
|
|
|
238
374
|
}>;
|
|
239
375
|
/**
|
|
240
376
|
* Start the autonomous heartbeat loop.
|
|
241
|
-
*
|
|
242
|
-
*
|
|
377
|
+
* Phase 2: Sends paid heartbeats at regular intervals.
|
|
378
|
+
*
|
|
379
|
+
* @param paymentTxFn - Optional function that returns a payment tx for each heartbeat.
|
|
380
|
+
* If not provided, uses 'devnet-skip' (devnet only).
|
|
243
381
|
*/
|
|
244
|
-
startHeartbeat(): void;
|
|
382
|
+
startHeartbeat(paymentTxFn?: () => Promise<string> | string): void;
|
|
245
383
|
/**
|
|
246
|
-
* Stop the heartbeat
|
|
247
|
-
* Must call resync() when waking up.
|
|
384
|
+
* Stop the heartbeat loop.
|
|
248
385
|
*/
|
|
249
386
|
stopHeartbeat(): void;
|
|
250
387
|
/**
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
* "When an agent powers down, its time 'freezes.' Upon waking,
|
|
254
|
-
* it must perform a Re-Sync Challenge with the Registry to
|
|
255
|
-
* fill the 'Temporal Gap' and re-establish its provenance."
|
|
388
|
+
* @deprecated Phase 2: Resync retired (D-67). Dormancy resume is free — just call heartbeat().
|
|
389
|
+
* This method will be removed in the next major version.
|
|
256
390
|
*/
|
|
257
391
|
resync(): Promise<{
|
|
258
392
|
ok: boolean;
|
|
@@ -264,6 +398,70 @@ declare class BeatAgent {
|
|
|
264
398
|
* Requires sufficient accumulated beats (Temporal Gestation).
|
|
265
399
|
*/
|
|
266
400
|
requestSpawn(childName?: string, childHash?: string): Promise<SpawnResult>;
|
|
401
|
+
/** Cached lineage proof from the most recent heartbeat or SIGIL purchase */
|
|
402
|
+
private cachedProof;
|
|
403
|
+
/**
|
|
404
|
+
* Purchase a SIGIL (cryptographic identity) for this agent.
|
|
405
|
+
* SIGILs gate heartbeating, lineage proofs, and offline verification.
|
|
406
|
+
* One-time purchase — cannot be re-purchased.
|
|
407
|
+
*
|
|
408
|
+
* @param options - SIGIL purchase options (identity_class, principal, tier, name, payment_tx, + optional metadata)
|
|
409
|
+
*
|
|
410
|
+
* Legacy signature (deprecated):
|
|
411
|
+
* @param identityClass - 'narrow_task' | 'autonomous' | 'orchestrator'
|
|
412
|
+
* @param paymentTx - Solana transaction signature or 'devnet-skip'
|
|
413
|
+
*/
|
|
414
|
+
purchaseSigil(optionsOrClass: SigilPurchaseOptions | IdentityClass, paymentTx?: string): Promise<SigilResult>;
|
|
415
|
+
/**
|
|
416
|
+
* Update mutable SIGIL metadata fields.
|
|
417
|
+
* Requires a SIGIL. Cannot modify immutable fields.
|
|
418
|
+
*
|
|
419
|
+
* @param fields - Subset of mutable SIGIL fields to update
|
|
420
|
+
*/
|
|
421
|
+
updateMetadata(fields: Partial<SigilMutableFields>): Promise<MetadataUpdateResult>;
|
|
422
|
+
/**
|
|
423
|
+
* Send a paid heartbeat to the registry.
|
|
424
|
+
* Requires a SIGIL. Returns a signed lineage proof.
|
|
425
|
+
* This is the Phase 2 replacement for pulse() + checkin().
|
|
426
|
+
*
|
|
427
|
+
* @param paymentTx - Solana transaction signature. Omit or 'devnet-skip' on devnet.
|
|
428
|
+
* @param globalAnchor - Optional: the global anchor index to reference.
|
|
429
|
+
*/
|
|
430
|
+
heartbeat(paymentTx?: string, globalAnchor?: number): Promise<HeartbeatResult>;
|
|
431
|
+
/**
|
|
432
|
+
* Reissue a lineage proof. "Reprint, not a renewal."
|
|
433
|
+
* Does NOT create a new lineage event.
|
|
434
|
+
*
|
|
435
|
+
* @param paymentTx - Solana transaction signature. Omit or 'devnet-skip' on devnet.
|
|
436
|
+
*/
|
|
437
|
+
reissueProof(paymentTx?: string): Promise<{
|
|
438
|
+
ok: boolean;
|
|
439
|
+
lineage_proof?: LineageProof;
|
|
440
|
+
error?: string;
|
|
441
|
+
}>;
|
|
442
|
+
/**
|
|
443
|
+
* Get the latest cached lineage proof (no network call).
|
|
444
|
+
* Returns null if no proof has been obtained yet.
|
|
445
|
+
*/
|
|
446
|
+
getLatestProof(): LineageProof | null;
|
|
447
|
+
/**
|
|
448
|
+
* Get the agent's passport (alias for getLatestProof).
|
|
449
|
+
* The passport is the agent's portable, offline-verifiable credential.
|
|
450
|
+
* Returns null if no passport has been issued yet (requires SIGIL + heartbeat).
|
|
451
|
+
*/
|
|
452
|
+
getPassport(): Passport | null;
|
|
453
|
+
/**
|
|
454
|
+
* Verify a lineage proof locally using the authority public key.
|
|
455
|
+
* Offline verification — no API call, no SOL cost.
|
|
456
|
+
*
|
|
457
|
+
* Returns a VerificationResult object. The object is truthy when valid,
|
|
458
|
+
* so `if (BeatAgent.verifyProofLocally(proof, key))` still works.
|
|
459
|
+
*
|
|
460
|
+
* @param proof - The LineageProof to verify
|
|
461
|
+
* @param authorityPubKeyHex - 32-byte hex-encoded Ed25519 public key from /.well-known/provenonce-authority.json
|
|
462
|
+
* @param currentBeat - Optional current global beat index (for beatsSinceHeartbeat calculation)
|
|
463
|
+
*/
|
|
464
|
+
static verifyProofLocally(proof: LineageProof, authorityPubKeyHex: string, currentBeat?: number): VerificationResult;
|
|
267
465
|
/**
|
|
268
466
|
* Get this agent's full beat status from the registry.
|
|
269
467
|
*/
|
|
@@ -295,4 +493,84 @@ declare function computeBeatsLite(startHash: string, startIndex: number, count:
|
|
|
295
493
|
elapsed: number;
|
|
296
494
|
};
|
|
297
495
|
|
|
298
|
-
|
|
496
|
+
/**
|
|
497
|
+
* Provenonce SDK Error Classes
|
|
498
|
+
*
|
|
499
|
+
* Typed error hierarchy for programmatic error handling.
|
|
500
|
+
* All errors extend ProvenonceError for catch-all, or catch specific
|
|
501
|
+
* subclasses for fine-grained control:
|
|
502
|
+
*
|
|
503
|
+
* try {
|
|
504
|
+
* await agent.checkin();
|
|
505
|
+
* } catch (err) {
|
|
506
|
+
* if (err instanceof RateLimitError) {
|
|
507
|
+
* await sleep(err.retryAfterMs);
|
|
508
|
+
* } else if (err instanceof FrozenError) {
|
|
509
|
+
* await agent.resync();
|
|
510
|
+
* } else if (err instanceof AuthError) {
|
|
511
|
+
* console.error('Bad API key');
|
|
512
|
+
* }
|
|
513
|
+
* }
|
|
514
|
+
*/
|
|
515
|
+
/** Error codes for programmatic switching */
|
|
516
|
+
declare enum ErrorCode {
|
|
517
|
+
VALIDATION = "VALIDATION",
|
|
518
|
+
AUTH_INVALID = "AUTH_INVALID",
|
|
519
|
+
AUTH_MISSING = "AUTH_MISSING",
|
|
520
|
+
RATE_LIMITED = "RATE_LIMITED",
|
|
521
|
+
AGENT_FROZEN = "AGENT_FROZEN",
|
|
522
|
+
AGENT_NOT_INITIALIZED = "AGENT_NOT_INITIALIZED",
|
|
523
|
+
AGENT_WRONG_STATE = "AGENT_WRONG_STATE",
|
|
524
|
+
NOT_FOUND = "NOT_FOUND",
|
|
525
|
+
NETWORK_ERROR = "NETWORK_ERROR",
|
|
526
|
+
TIMEOUT = "TIMEOUT",
|
|
527
|
+
SERVER_ERROR = "SERVER_ERROR"
|
|
528
|
+
}
|
|
529
|
+
/** Base error class for all Provenonce SDK errors */
|
|
530
|
+
declare class ProvenonceError extends Error {
|
|
531
|
+
/** Machine-readable error code */
|
|
532
|
+
readonly code: ErrorCode;
|
|
533
|
+
/** HTTP status code (if from an API response) */
|
|
534
|
+
readonly statusCode?: number;
|
|
535
|
+
/** Additional context */
|
|
536
|
+
readonly details?: Record<string, unknown>;
|
|
537
|
+
constructor(message: string, code: ErrorCode, statusCode?: number, details?: Record<string, unknown>);
|
|
538
|
+
}
|
|
539
|
+
/** Thrown when input validation fails (bad config, invalid args) */
|
|
540
|
+
declare class ValidationError extends ProvenonceError {
|
|
541
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
542
|
+
}
|
|
543
|
+
/** Thrown on 401/403 — bad or missing API key */
|
|
544
|
+
declare class AuthError extends ProvenonceError {
|
|
545
|
+
constructor(message: string, code?: ErrorCode.AUTH_INVALID | ErrorCode.AUTH_MISSING, statusCode?: number);
|
|
546
|
+
}
|
|
547
|
+
/** Thrown on 429 — rate limit exceeded */
|
|
548
|
+
declare class RateLimitError extends ProvenonceError {
|
|
549
|
+
/** Milliseconds until the rate limit resets (if provided by server) */
|
|
550
|
+
readonly retryAfterMs?: number;
|
|
551
|
+
constructor(message: string, statusCode?: number, retryAfterMs?: number);
|
|
552
|
+
}
|
|
553
|
+
/** Thrown when an agent is frozen and cannot perform the requested action */
|
|
554
|
+
declare class FrozenError extends ProvenonceError {
|
|
555
|
+
constructor(message?: string);
|
|
556
|
+
}
|
|
557
|
+
/** Thrown when the agent is in the wrong state for the requested action */
|
|
558
|
+
declare class StateError extends ProvenonceError {
|
|
559
|
+
/** The agent's current state */
|
|
560
|
+
readonly currentState: string;
|
|
561
|
+
constructor(message: string, currentState: string, code?: ErrorCode);
|
|
562
|
+
}
|
|
563
|
+
/** Thrown on 404 — agent or resource not found */
|
|
564
|
+
declare class NotFoundError extends ProvenonceError {
|
|
565
|
+
constructor(message: string, statusCode?: number);
|
|
566
|
+
}
|
|
567
|
+
/** Thrown on network failures — non-JSON responses, fetch errors, timeouts */
|
|
568
|
+
declare class NetworkError extends ProvenonceError {
|
|
569
|
+
constructor(message: string, code?: ErrorCode.NETWORK_ERROR | ErrorCode.TIMEOUT);
|
|
570
|
+
}
|
|
571
|
+
/** Thrown on 5xx — unexpected server errors */
|
|
572
|
+
declare class ServerError extends ProvenonceError {
|
|
573
|
+
constructor(message: string, statusCode?: number);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
export { type AgentStatus, AuthError, type Beat, BeatAgent, type BeatAgentConfig, type Capability, type CheckinResult, type ComplianceRegime, ErrorCode, FrozenError, type HeartbeatResult, type IdentityClass, type LineageProof, type MetadataUpdateResult, NetworkError, NotFoundError, type Passport, ProvenonceError, RateLimitError, type RegistrationResult, ServerError, type SigilMutableFields, type SigilProtocol, type SigilPurchaseOptions, type SigilResult, type SigilTier, type SpawnResult, StateError, type Substrate, type SubstrateProvider, ValidationError, type VerificationResult, type WalletInfo, computeBeat, computeBeatsLite, generateWalletKeypair, register };
|