@fangorn-network/sdk 0.1.0 → 0.1.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 +1 -1
- package/lib/cli/cli.js +126 -325
- package/lib/cli/index.d.ts +2 -3
- package/lib/cli/index.js +10 -15
- package/lib/cli/sell.d.ts +28 -0
- package/lib/cli/sell.js +95 -0
- package/lib/cli/stage.d.ts +19 -0
- package/lib/cli/stage.js +94 -0
- package/lib/config.d.ts +71 -81
- package/lib/config.js +22 -38
- package/lib/contracts/data-registry/abi.d.ts +195 -19
- package/lib/contracts/data-registry/abi.js +409 -206
- package/lib/contracts/data-registry/index.d.ts +126 -2
- package/lib/contracts/data-registry/index.js +174 -1
- package/lib/contracts/index.d.ts +4 -7
- package/lib/contracts/index.js +4 -7
- package/lib/contracts/logs.d.ts +1 -1
- package/lib/contracts/logs.js +1 -1
- package/lib/contracts/{membership-registry → settlement-registry}/abi.d.ts +301 -636
- package/lib/contracts/settlement-registry/abi.js +962 -0
- package/lib/contracts/settlement-registry/index.d.ts +143 -0
- package/lib/contracts/settlement-registry/index.js +213 -0
- package/lib/crypto/aes.d.ts +2 -2
- package/lib/crypto/aes.js +4 -4
- package/lib/crypto/encryption.d.ts +8 -109
- package/lib/crypto/encryption.js +16 -114
- package/lib/crypto/paid.d.ts +104 -0
- package/lib/crypto/paid.js +147 -0
- package/lib/engine/car.d.ts +5 -1
- package/lib/engine/car.js +2 -2
- package/lib/engine/index.d.ts +33 -14
- package/lib/engine/index.js +98 -41
- package/lib/engine/records.d.ts +19 -8
- package/lib/engine/records.js +81 -7
- package/lib/engine/test-helpers.d.ts +2 -3
- package/lib/engine/test-helpers.js +7 -5
- package/lib/erc8004.js +6 -6
- package/lib/fangorn.d.ts +65 -86
- package/lib/fangorn.js +115 -153
- package/lib/feed.d.ts +7 -8
- package/lib/feed.js +7 -8
- package/lib/index.d.ts +10 -13
- package/lib/index.js +10 -13
- package/lib/providers/storage/signed-url.d.ts +2 -10
- package/lib/providers/storage/signed-url.js +5 -15
- package/lib/providers/storage/types.d.ts +1 -1
- package/lib/providers/storage/utils.js +5 -3
- package/lib/test/key-server.d.ts +12 -0
- package/lib/test/key-server.js +30 -0
- package/lib/test/mem-registry.d.ts +14 -19
- package/lib/test/mem-registry.js +44 -37
- package/lib/test/sdk-suite.d.ts +1 -4
- package/lib/test/sdk-suite.js +16 -87
- package/lib/test/testbed.d.ts +12 -22
- package/lib/test/testbed.js +29 -56
- package/lib/types/index.d.ts +6 -11
- package/package.json +1 -1
- package/lib/contracts/app-registry/abi.d.ts +0 -1265
- package/lib/contracts/app-registry/abi.js +0 -1454
- package/lib/contracts/app-registry/index.d.ts +0 -161
- package/lib/contracts/app-registry/index.js +0 -274
- package/lib/contracts/membership-registry/abi.js +0 -1333
- package/lib/contracts/membership-registry/index.d.ts +0 -79
- package/lib/contracts/membership-registry/index.js +0 -104
- package/lib/contracts/types.d.ts +0 -10
- package/lib/contracts/types.js +0 -12
- package/lib/harness/examples/hackmd/build-markdown-graph.d.ts +0 -1
- package/lib/harness/examples/hackmd/build-markdown-graph.js +0 -17
- package/lib/harness/index.d.ts +0 -58
- package/lib/harness/index.js +0 -73
- package/lib/registry.d.ts +0 -118
- package/lib/registry.js +0 -184
package/lib/fangorn.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { AppConfig } from "./config.js";
|
|
2
1
|
import { PreparedTx } from "./contracts/write.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { Registry } from "./contracts/data-registry/index.js";
|
|
3
|
+
import { SettlementRegistryClient } from "./contracts/settlement-registry/index.js";
|
|
5
4
|
import "./contracts/index.js";
|
|
6
|
-
import { Registry } from "./registry.js";
|
|
7
5
|
import { MetadataStorage } from "./providers/storage/types.js";
|
|
8
|
-
import { CommitDiff, FangornEngine, RecordInput, RepoContents, RepoDiff } from "./engine/index.js";
|
|
9
|
-
import {
|
|
6
|
+
import { CommitDiff, FangornEngine, RecordInput, RepoContents, RepoDiff, SignedUpdate } from "./engine/index.js";
|
|
7
|
+
import { NetworkConfig } from "./config.js";
|
|
10
8
|
import { FangornCreateOptions, StorageConfig } from "./types/index.js";
|
|
11
|
-
import {
|
|
9
|
+
import { AgentCard as AgentCard$1 } from "./erc8004.js";
|
|
10
|
+
import { CommitFeed } from "./feed.js";
|
|
12
11
|
import { Hash, Hex, WalletClient } from "viem";
|
|
13
12
|
import { CID } from "multiformats/cid";
|
|
14
13
|
|
|
@@ -23,10 +22,6 @@ interface RepoChange extends RepoDiff {
|
|
|
23
22
|
}
|
|
24
23
|
interface SubscribeOptions {
|
|
25
24
|
repo: string;
|
|
26
|
-
/**
|
|
27
|
-
* Under an app, the stream follows what the app presents (its members' updates,
|
|
28
|
-
* less exclusions); with no app, every update the publisher commits.
|
|
29
|
-
*/
|
|
30
25
|
/** Publisher whose repo to watch (defaults to this wallet's address). */
|
|
31
26
|
owner?: Hex;
|
|
32
27
|
/**
|
|
@@ -40,10 +35,19 @@ interface SubscribeOptions {
|
|
|
40
35
|
/** Abort to stop the subscription and release the watch. */
|
|
41
36
|
signal?: AbortSignal;
|
|
42
37
|
}
|
|
43
|
-
/** The A2A extension a Fangorn app's agent card carries: it names the app the card speaks for. */
|
|
44
|
-
declare const FANGORN_APP_EXTENSION = "https://fangorn.network/a2a/app/v1";
|
|
45
38
|
/**
|
|
46
|
-
* The
|
|
39
|
+
* The A2A extension a repo's agent card carries. Its params name the repo the
|
|
40
|
+
* card speaks for: `{ chainId, dataRegistry, publisher, repo }`.
|
|
41
|
+
*/
|
|
42
|
+
declare const FANGORN_REPO_EXTENSION = "https://fangorn.network/a2a/repo/v1";
|
|
43
|
+
/**
|
|
44
|
+
* The record that binds a repo to its agent card: `{ url }`, at this id in the
|
|
45
|
+
* repo. Only the publisher can commit it, so it plays the part an on-chain
|
|
46
|
+
* pointer would.
|
|
47
|
+
*/
|
|
48
|
+
declare const CARD_RECORD = "@card";
|
|
49
|
+
/**
|
|
50
|
+
* The part of an A2A agent card `discoverCard` reads. A card's other fields
|
|
47
51
|
* (skills, endpoints and so on) pass through untouched.
|
|
48
52
|
*/
|
|
49
53
|
interface AgentCard {
|
|
@@ -62,8 +66,7 @@ declare class Fangorn {
|
|
|
62
66
|
private readonly ctx;
|
|
63
67
|
private _engine;
|
|
64
68
|
private _feed;
|
|
65
|
-
private
|
|
66
|
-
private _membership;
|
|
69
|
+
private _settlement;
|
|
67
70
|
/**
|
|
68
71
|
* The repo cache
|
|
69
72
|
* Insertion order = LRU order
|
|
@@ -136,7 +139,6 @@ declare class Fangorn {
|
|
|
136
139
|
records?: RecordInput[];
|
|
137
140
|
deletes?: string[];
|
|
138
141
|
parent?: string;
|
|
139
|
-
message: string;
|
|
140
142
|
/** Snapshot semantics: the staged records replace the repo's previous contents. */
|
|
141
143
|
replace?: boolean;
|
|
142
144
|
}): Promise<{
|
|
@@ -164,7 +166,6 @@ declare class Fangorn {
|
|
|
164
166
|
repo: string;
|
|
165
167
|
records?: RecordInput[];
|
|
166
168
|
deletes?: string[];
|
|
167
|
-
message: string;
|
|
168
169
|
/** Snapshot semantics: the staged records replace the repo's contents. */
|
|
169
170
|
replace?: boolean;
|
|
170
171
|
}): Promise<{
|
|
@@ -187,13 +188,16 @@ declare class Fangorn {
|
|
|
187
188
|
txHash: string;
|
|
188
189
|
onChainTip: string;
|
|
189
190
|
}>;
|
|
191
|
+
/**
|
|
192
|
+
* `push`, signed instead of sent: anyone holding the result can settle it with
|
|
193
|
+
* `relayPush`, paying the gas.
|
|
194
|
+
*/
|
|
195
|
+
signPush(repo: string, commitCid: string): Promise<SignedUpdate>;
|
|
196
|
+
relayPush(signed: SignedUpdate): Promise<Hash>;
|
|
190
197
|
/** The owner's current on-chain tip for a repo, or null if they have none. */
|
|
191
198
|
onChainTip(owner: Hex, repo: string): Promise<string | null>;
|
|
192
199
|
/**
|
|
193
|
-
* A publisher's repo
|
|
194
|
-
* the publisher's latest head, or, under an app, nothing unless the app
|
|
195
|
-
* presents the publisher (provides its storage) and excludes neither it nor
|
|
196
|
-
* the repo.
|
|
200
|
+
* A publisher's repo at its latest head, cached against that head.
|
|
197
201
|
*
|
|
198
202
|
* Reading a repo walks its whole record tree from the root. The tip is one
|
|
199
203
|
* cheap contract read and only moves on publish, so it doubles as the cache
|
|
@@ -209,21 +213,16 @@ declare class Fangorn {
|
|
|
209
213
|
tip: string | null;
|
|
210
214
|
contents: RepoContents;
|
|
211
215
|
}>;
|
|
212
|
-
/** The commit
|
|
213
|
-
private
|
|
214
|
-
/** Does `app` present `ref`: it presents the publisher, and excludes neither it nor the repo? */
|
|
215
|
-
private presentsRepo;
|
|
216
|
+
/** The commit at a repo's head, or null for a repo never written. */
|
|
217
|
+
private headCommit;
|
|
216
218
|
/**
|
|
217
|
-
* Every (publisher, repo)
|
|
218
|
-
* what it excludes — the app's directory, from ONE `getLogs` over the update
|
|
219
|
-
* log, kept to the publishers the app presents.
|
|
220
|
-
*
|
|
221
|
-
* ponytail: reads every publisher's updates and drops non-members, so it costs
|
|
222
|
-
* what the network writes, not what the app holds. Filter on-chain by the
|
|
223
|
-
* app's members (a `publisher` topic list) once that is too slow.
|
|
219
|
+
* Every (publisher, repo) at its latest head, from one scan of the update log.
|
|
224
220
|
* Narrow it with `repo` (every publisher's `docs`) or `owner`, filtered on-chain.
|
|
221
|
+
*
|
|
222
|
+
* ponytail: scans the whole log from `fromBlock`; an indexer's sub-log once
|
|
223
|
+
* that is too slow.
|
|
225
224
|
*/
|
|
226
|
-
|
|
225
|
+
repos(opts?: {
|
|
227
226
|
repo?: string;
|
|
228
227
|
owner?: Hex;
|
|
229
228
|
fromBlock?: bigint;
|
|
@@ -234,36 +233,38 @@ declare class Fangorn {
|
|
|
234
233
|
blockNumber: bigint;
|
|
235
234
|
}[]>;
|
|
236
235
|
/**
|
|
237
|
-
* Resolve
|
|
236
|
+
* Resolve a repo from its agent card URL alone, and prove the card speaks for it.
|
|
238
237
|
*
|
|
239
|
-
* The card names its
|
|
240
|
-
* anyone can serve a card that names any
|
|
241
|
-
* the
|
|
238
|
+
* The card names its repo in the `FANGORN_REPO_EXTENSION` A2A extension, but
|
|
239
|
+
* anyone can serve a card that names any repo. So the card is trusted only if
|
|
240
|
+
* the repo's `@card` record, which only its publisher can commit, points
|
|
242
241
|
* back at this exact URL. The comparison is exact string equality, so a
|
|
243
242
|
* trailing slash or a different host counts as a different card.
|
|
244
|
-
*
|
|
245
|
-
* Doesn't touch this client's app. Pass `appId` to `setAppId` to read under it.
|
|
246
243
|
*/
|
|
247
|
-
|
|
244
|
+
discoverCard(cardUrl: string): Promise<{
|
|
248
245
|
card: AgentCard;
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
repos: string[];
|
|
246
|
+
publisher: Hex;
|
|
247
|
+
repo: string;
|
|
252
248
|
}>;
|
|
249
|
+
/** The card URL a repo's `@card` record points at, or undefined for none. */
|
|
250
|
+
cardOf(publisher: Hex, repo: string): Promise<string | undefined>;
|
|
253
251
|
/**
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
* wants the same feed — a server fanning out to connections, say.
|
|
252
|
+
* Point one of your repos at its agent card, by committing its `@card` record.
|
|
253
|
+
* Returns the transaction, or undefined if it already points there.
|
|
257
254
|
*/
|
|
258
|
-
|
|
255
|
+
setCard(repo: string, cardUrl: string): Promise<Hash | undefined>;
|
|
256
|
+
/**
|
|
257
|
+
* `subscribeAll` as ONE shared, ref-counted subscription (see `CommitFeed`), for
|
|
258
|
+
* anywhere more than one consumer wants the same stream.
|
|
259
|
+
*/
|
|
260
|
+
feed(opts?: {
|
|
259
261
|
pollingInterval?: number;
|
|
260
|
-
}):
|
|
262
|
+
}): CommitFeed;
|
|
261
263
|
/** Walk commit history from `head` (newest first). */
|
|
262
264
|
log(head: string, max?: number): AsyncGenerator<{
|
|
263
265
|
cid: string;
|
|
264
266
|
parent: string | null;
|
|
265
267
|
epoch: number;
|
|
266
|
-
message: string;
|
|
267
268
|
root: string;
|
|
268
269
|
}>;
|
|
269
270
|
/** Show a commit and what it changed vs. its parent. */
|
|
@@ -282,19 +283,17 @@ declare class Fangorn {
|
|
|
282
283
|
*/
|
|
283
284
|
subscribe(opts: SubscribeOptions): AsyncGenerator<RepoChange>;
|
|
284
285
|
/**
|
|
285
|
-
* Stream changes
|
|
286
|
-
*
|
|
287
|
-
* `owner` (one publisher's whole app footprint). With no app, every update by
|
|
288
|
-
* anyone: a firehose.
|
|
286
|
+
* Stream changes to every repo of every publisher. Narrow it with `repo`
|
|
287
|
+
* (every publisher's `docs`) or `owner` (one publisher's repos).
|
|
289
288
|
*/
|
|
290
|
-
|
|
289
|
+
subscribeAll(opts?: Omit<SubscribeOptions, "repo"> & {
|
|
291
290
|
repo?: string;
|
|
292
291
|
}): AsyncGenerator<RepoChange>;
|
|
293
|
-
/** Shared catch-up-then-live loop behind `subscribe` and `
|
|
292
|
+
/** Shared catch-up-then-live loop behind `subscribe` and `subscribeAll`. */
|
|
294
293
|
private streamCommits;
|
|
295
294
|
/**
|
|
296
|
-
* Resolve a log entry into a repo change, or null if
|
|
297
|
-
*
|
|
295
|
+
* Resolve a log entry into a repo change, or null if the repo's records did
|
|
296
|
+
* not change.
|
|
298
297
|
*
|
|
299
298
|
* The commit itself names its repo, which must be the one the entry was
|
|
300
299
|
* logged under, or the publisher settled a commit for one repo against
|
|
@@ -306,27 +305,21 @@ declare class Fangorn {
|
|
|
306
305
|
* dropped entry changed.
|
|
307
306
|
*/
|
|
308
307
|
private toRepoChange;
|
|
309
|
-
getConfig():
|
|
310
|
-
/** Heads
|
|
308
|
+
getConfig(): NetworkConfig;
|
|
309
|
+
/** Heads and the update log: the registry of WHITEPAPER_1 §3.2. */
|
|
311
310
|
getRegistry(): Registry;
|
|
311
|
+
getSettlementRegistry(): SettlementRegistryClient;
|
|
312
312
|
/**
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
* The owner accepts a publisher (`acceptPublisher()`); from then its uploads
|
|
316
|
-
* bill the app's subscription, and the app presents its repos.
|
|
317
|
-
*/
|
|
318
|
-
getAppRegistry(): AppRegistryClient;
|
|
319
|
-
getMembershipRegistry(): MembershipRegistryClient;
|
|
320
|
-
/**
|
|
321
|
-
* Register the app as an ERC-8004 agent from its card, and point the app at the card
|
|
322
|
-
* (owner only). The registration file is pinned with this client's storage, so a
|
|
313
|
+
* Register a repo as an ERC-8004 agent from its card, and point the repo at
|
|
314
|
+
* the card (`setCard`). The registration file is pinned with this client's storage, so a
|
|
323
315
|
* browser wallet on signed-URL storage needs no Pinata JWT.
|
|
324
316
|
*
|
|
325
317
|
* `update` re-files an agent already minted (its token id) from the card as it is
|
|
326
318
|
* now, minting nothing. `skipRegister` only binds the card. A binding that already
|
|
327
319
|
* points at `cardUrl` is left alone.
|
|
328
320
|
*/
|
|
329
|
-
registerAgent(cardUrl: string, opts
|
|
321
|
+
registerAgent(cardUrl: string, opts: {
|
|
322
|
+
repo: string;
|
|
330
323
|
mcp?: string;
|
|
331
324
|
update?: bigint;
|
|
332
325
|
skipRegister?: boolean;
|
|
@@ -335,20 +328,6 @@ declare class Fangorn {
|
|
|
335
328
|
agentId?: bigint;
|
|
336
329
|
txHash?: Hash;
|
|
337
330
|
}>;
|
|
338
|
-
/** The app this client reads and publishes under, or undefined for none. */
|
|
339
|
-
getAppId(): Hex | undefined;
|
|
340
|
-
private requireApp;
|
|
341
|
-
/**
|
|
342
|
-
* Point this client at a different app — by name (`"my-app"`) or by app id —
|
|
343
|
-
* or at none, without rebuilding it. Every read, publish and subscription
|
|
344
|
-
* after this call is in the new context.
|
|
345
|
-
*
|
|
346
|
-
* Repo reads are dropped from the cache (its keys are app-agnostic) and
|
|
347
|
-
* the shared `appFeed` is released: a feed watches one app's commit stream, so
|
|
348
|
-
* the next `appFeed()` opens a fresh subscription. Generators already running
|
|
349
|
-
* from `subscribe`/`subscribeApp` keep their original filter until aborted.
|
|
350
|
-
*/
|
|
351
|
-
setAppId(nameOrId: string | undefined): void;
|
|
352
331
|
getStorage(): MetadataStorage;
|
|
353
332
|
/**
|
|
354
333
|
* Swap the storage backend at runtime — e.g. move from access-worker signed
|
|
@@ -360,4 +339,4 @@ declare class Fangorn {
|
|
|
360
339
|
getAddress(): Hex;
|
|
361
340
|
}
|
|
362
341
|
//#endregion
|
|
363
|
-
export { AgentCard,
|
|
342
|
+
export { AgentCard, CARD_RECORD, FANGORN_REPO_EXTENSION, Fangorn, RepoChange, SubscribeOptions };
|