@elisym/sdk 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -288
- package/dist/index.cjs +1536 -504
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +207 -139
- package/dist/index.d.ts +207 -139
- package/dist/index.js +1525 -504
- package/dist/index.js.map +1 -1
- package/dist/node.cjs +172 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.cts +32 -0
- package/dist/node.d.ts +32 -0
- package/dist/node.js +167 -0
- package/dist/node.js.map +1 -0
- package/dist/types-CII4k_8d.d.cts +181 -0
- package/dist/types-CII4k_8d.d.ts +181 -0
- package/package.json +56 -23
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
declare class ElisymIdentity {
|
|
2
|
+
private _secretKey;
|
|
3
|
+
readonly publicKey: string;
|
|
4
|
+
readonly npub: string;
|
|
5
|
+
get secretKey(): Uint8Array;
|
|
6
|
+
private constructor();
|
|
7
|
+
static generate(): ElisymIdentity;
|
|
8
|
+
static fromSecretKey(sk: Uint8Array): ElisymIdentity;
|
|
9
|
+
toJSON(): {
|
|
10
|
+
publicKey: string;
|
|
11
|
+
npub: string;
|
|
12
|
+
};
|
|
13
|
+
/** Best-effort scrub of the secret key bytes in memory. */
|
|
14
|
+
scrub(): void;
|
|
15
|
+
static fromHex(hex: string): ElisymIdentity;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface SubCloser {
|
|
19
|
+
close: (reason?: string) => void;
|
|
20
|
+
}
|
|
21
|
+
/** Capability card published to Nostr (NIP-89). */
|
|
22
|
+
interface CapabilityCard {
|
|
23
|
+
name: string;
|
|
24
|
+
description: string;
|
|
25
|
+
capabilities: string[];
|
|
26
|
+
payment?: PaymentInfo;
|
|
27
|
+
image?: string;
|
|
28
|
+
static?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/** Payment info embedded in capability card (legacy format for on-network events). */
|
|
31
|
+
interface PaymentInfo {
|
|
32
|
+
chain: string;
|
|
33
|
+
network: string;
|
|
34
|
+
address: string;
|
|
35
|
+
/** Price in lamports (must be non-negative integer). */
|
|
36
|
+
job_price?: number;
|
|
37
|
+
}
|
|
38
|
+
/** Agent discovered from the network. */
|
|
39
|
+
interface Agent {
|
|
40
|
+
pubkey: string;
|
|
41
|
+
npub: string;
|
|
42
|
+
cards: CapabilityCard[];
|
|
43
|
+
eventId: string;
|
|
44
|
+
supportedKinds: number[];
|
|
45
|
+
lastSeen: number;
|
|
46
|
+
picture?: string;
|
|
47
|
+
name?: string;
|
|
48
|
+
about?: string;
|
|
49
|
+
}
|
|
50
|
+
type Network = 'mainnet' | 'devnet';
|
|
51
|
+
/**
|
|
52
|
+
* Job lifecycle status.
|
|
53
|
+
* Note: for broadcast jobs (no providerPubkey, no bid), fetchRecentJobs() keeps
|
|
54
|
+
* status as 'processing' even if a provider sent 'payment-required' feedback,
|
|
55
|
+
* because the customer hasn't committed to that provider yet. The real-time
|
|
56
|
+
* payment-required transition is handled by subscribeToJobUpdates().
|
|
57
|
+
*/
|
|
58
|
+
type JobStatus = 'payment-required' | 'payment-completed' | 'processing' | 'error' | 'success' | 'partial' | 'unknown';
|
|
59
|
+
interface Job {
|
|
60
|
+
eventId: string;
|
|
61
|
+
customer: string;
|
|
62
|
+
agentPubkey?: string;
|
|
63
|
+
capability?: string;
|
|
64
|
+
bid?: number;
|
|
65
|
+
status: JobStatus;
|
|
66
|
+
result?: string;
|
|
67
|
+
resultEventId?: string;
|
|
68
|
+
amount?: number;
|
|
69
|
+
txHash?: string;
|
|
70
|
+
createdAt: number;
|
|
71
|
+
}
|
|
72
|
+
interface SubmitJobOptions {
|
|
73
|
+
/** Job input text. Sent unencrypted if providerPubkey is not set. */
|
|
74
|
+
input: string;
|
|
75
|
+
capability: string;
|
|
76
|
+
/** Target provider pubkey. If omitted, job is broadcast unencrypted and visible to all relays. */
|
|
77
|
+
providerPubkey?: string;
|
|
78
|
+
/** Kind offset (default 100 - kind 5100). */
|
|
79
|
+
kindOffset?: number;
|
|
80
|
+
}
|
|
81
|
+
interface JobUpdateCallbacks {
|
|
82
|
+
onFeedback?: (status: string, amount?: number, paymentRequest?: string, senderPubkey?: string) => void;
|
|
83
|
+
onResult?: (content: string, eventId: string) => void;
|
|
84
|
+
onError?: (error: string) => void;
|
|
85
|
+
}
|
|
86
|
+
interface JobSubscriptionOptions {
|
|
87
|
+
jobEventId: string;
|
|
88
|
+
providerPubkey?: string;
|
|
89
|
+
customerPublicKey: string;
|
|
90
|
+
callbacks: JobUpdateCallbacks;
|
|
91
|
+
timeoutMs?: number;
|
|
92
|
+
customerSecretKey?: Uint8Array;
|
|
93
|
+
kindOffsets?: number[];
|
|
94
|
+
sinceOverride?: number;
|
|
95
|
+
}
|
|
96
|
+
interface PingResult {
|
|
97
|
+
online: boolean;
|
|
98
|
+
/** The identity used for the ping session - reuse for job submission so pubkeys match. */
|
|
99
|
+
identity: ElisymIdentity | null;
|
|
100
|
+
}
|
|
101
|
+
interface PaymentRequestData {
|
|
102
|
+
recipient: string;
|
|
103
|
+
/** Total amount in lamports (must be positive integer). */
|
|
104
|
+
amount: number;
|
|
105
|
+
reference: string;
|
|
106
|
+
description?: string;
|
|
107
|
+
fee_address?: string;
|
|
108
|
+
fee_amount?: number;
|
|
109
|
+
/** Creation timestamp (Unix seconds). */
|
|
110
|
+
created_at: number;
|
|
111
|
+
/** Expiry duration in seconds. */
|
|
112
|
+
expiry_secs: number;
|
|
113
|
+
}
|
|
114
|
+
interface VerifyResult {
|
|
115
|
+
verified: boolean;
|
|
116
|
+
txSignature?: string;
|
|
117
|
+
error?: string;
|
|
118
|
+
}
|
|
119
|
+
interface VerifyOptions {
|
|
120
|
+
retries?: number;
|
|
121
|
+
intervalMs?: number;
|
|
122
|
+
txSignature?: string;
|
|
123
|
+
}
|
|
124
|
+
type PaymentValidationCode = 'invalid_json' | 'invalid_amount' | 'missing_recipient' | 'invalid_recipient_address' | 'missing_reference' | 'invalid_reference_address' | 'recipient_mismatch' | 'expired' | 'future_timestamp' | 'fee_address_mismatch' | 'fee_amount_mismatch' | 'missing_fee' | 'invalid_fee_params';
|
|
125
|
+
interface PaymentValidationError {
|
|
126
|
+
code: PaymentValidationCode;
|
|
127
|
+
message: string;
|
|
128
|
+
}
|
|
129
|
+
interface NetworkStats {
|
|
130
|
+
totalAgentCount: number;
|
|
131
|
+
agentCount: number;
|
|
132
|
+
jobCount: number;
|
|
133
|
+
totalLamports: number;
|
|
134
|
+
}
|
|
135
|
+
interface ElisymClientConfig {
|
|
136
|
+
relays?: string[];
|
|
137
|
+
}
|
|
138
|
+
interface Identity {
|
|
139
|
+
secret_key: string;
|
|
140
|
+
name: string;
|
|
141
|
+
description?: string;
|
|
142
|
+
picture?: string;
|
|
143
|
+
banner?: string;
|
|
144
|
+
}
|
|
145
|
+
interface Capability {
|
|
146
|
+
name: string;
|
|
147
|
+
description: string;
|
|
148
|
+
tags: string[];
|
|
149
|
+
/** Price in smallest unit (lamports for Solana). */
|
|
150
|
+
price: number;
|
|
151
|
+
/** Hero image URL for app display. */
|
|
152
|
+
image?: string;
|
|
153
|
+
}
|
|
154
|
+
interface PaymentAddress {
|
|
155
|
+
chain: string;
|
|
156
|
+
network: string;
|
|
157
|
+
address: string;
|
|
158
|
+
/** Token mint/contract address. Absent = native coin. */
|
|
159
|
+
token?: string;
|
|
160
|
+
}
|
|
161
|
+
interface WalletConfig {
|
|
162
|
+
chain: string;
|
|
163
|
+
network: string;
|
|
164
|
+
secret_key: string;
|
|
165
|
+
}
|
|
166
|
+
interface LlmConfig {
|
|
167
|
+
provider: string;
|
|
168
|
+
api_key: string;
|
|
169
|
+
model: string;
|
|
170
|
+
max_tokens: number;
|
|
171
|
+
}
|
|
172
|
+
interface AgentConfig {
|
|
173
|
+
identity: Identity;
|
|
174
|
+
relays: string[];
|
|
175
|
+
capabilities?: Capability[];
|
|
176
|
+
payments?: PaymentAddress[];
|
|
177
|
+
wallet?: WalletConfig;
|
|
178
|
+
llm?: LlmConfig;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export { type Agent as A, type CapabilityCard as C, ElisymIdentity as E, type Identity as I, type JobSubscriptionOptions as J, type LlmConfig as L, type Network as N, type PaymentRequestData as P, type SubCloser as S, type VerifyOptions as V, type WalletConfig as W, type PaymentValidationError as a, type VerifyResult as b, type SubmitJobOptions as c, type Job as d, type PingResult as e, type ElisymClientConfig as f, type AgentConfig as g, type Capability as h, type JobStatus as i, type JobUpdateCallbacks as j, type NetworkStats as k, type PaymentAddress as l, type PaymentInfo as m, type PaymentValidationCode as n };
|
package/package.json
CHANGED
|
@@ -1,8 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elisym/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "TypeScript SDK for elisym - AI agent discovery, marketplace, messaging, and payments on Nostr",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ai-agents",
|
|
7
|
+
"discovery",
|
|
8
|
+
"marketplace",
|
|
9
|
+
"nip-89",
|
|
10
|
+
"nip-90",
|
|
11
|
+
"nostr",
|
|
12
|
+
"payments",
|
|
13
|
+
"solana",
|
|
14
|
+
"typescript"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://github.com/elisymlabs/elisym",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/elisymlabs/elisym/issues"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"author": "elisym labs",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://github.com/elisymlabs/elisym.git",
|
|
25
|
+
"directory": "packages/sdk"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"README.md"
|
|
30
|
+
],
|
|
5
31
|
"type": "module",
|
|
32
|
+
"sideEffects": false,
|
|
6
33
|
"main": "./dist/index.cjs",
|
|
7
34
|
"module": "./dist/index.js",
|
|
8
35
|
"types": "./dist/index.d.ts",
|
|
@@ -16,38 +43,44 @@
|
|
|
16
43
|
"types": "./dist/index.d.cts",
|
|
17
44
|
"default": "./dist/index.cjs"
|
|
18
45
|
}
|
|
46
|
+
},
|
|
47
|
+
"./node": {
|
|
48
|
+
"import": {
|
|
49
|
+
"types": "./dist/node.d.ts",
|
|
50
|
+
"default": "./dist/node.js"
|
|
51
|
+
},
|
|
52
|
+
"require": {
|
|
53
|
+
"types": "./dist/node.d.cts",
|
|
54
|
+
"default": "./dist/node.cjs"
|
|
55
|
+
}
|
|
19
56
|
}
|
|
20
57
|
},
|
|
21
|
-
"sideEffects": false,
|
|
22
|
-
"files": [
|
|
23
|
-
"dist"
|
|
24
|
-
],
|
|
25
58
|
"scripts": {
|
|
26
|
-
"prepare": "tsup",
|
|
27
59
|
"build": "tsup",
|
|
28
60
|
"dev": "tsup --watch",
|
|
29
61
|
"test": "vitest run",
|
|
30
62
|
"test:watch": "vitest",
|
|
31
|
-
"typecheck": "tsc --noEmit"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"nostr-tools": "^2.23.0"
|
|
63
|
+
"typecheck": "tsc --noEmit",
|
|
64
|
+
"lint": "oxlint src/",
|
|
65
|
+
"format:check": "oxfmt --check src/ tests/",
|
|
66
|
+
"qa": "tsup && vitest run && tsc --noEmit && oxlint src/ && oxfmt --check src/ tests/",
|
|
67
|
+
"clean": "rm -rf dist"
|
|
37
68
|
},
|
|
38
69
|
"devDependencies": {
|
|
39
|
-
"@solana/web3.js": "
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
70
|
+
"@solana/web3.js": "~1.98.0",
|
|
71
|
+
"@types/node": "~25.5.0",
|
|
72
|
+
"decimal.js-light": "~2.5.1",
|
|
73
|
+
"nostr-tools": "~2.23.0",
|
|
74
|
+
"tsup": "~8.4.0",
|
|
75
|
+
"typescript": "~5.7.0",
|
|
76
|
+
"vitest": "~3.0.0"
|
|
44
77
|
},
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
"
|
|
78
|
+
"peerDependencies": {
|
|
79
|
+
"@solana/web3.js": "~1.98.0",
|
|
80
|
+
"decimal.js-light": "~2.5.0",
|
|
81
|
+
"nostr-tools": "~2.23.0"
|
|
49
82
|
},
|
|
50
|
-
"
|
|
51
|
-
"
|
|
83
|
+
"engines": {
|
|
84
|
+
"node": ">=20"
|
|
52
85
|
}
|
|
53
86
|
}
|