@fangorn-network/sdk 2026.10.19-dev → 2026.10.21-dev

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.
@@ -20,10 +20,6 @@ interface StoredRecord {
20
20
  type: RecordType;
21
21
  payload: Record<string, unknown>;
22
22
  }
23
- interface RecordSchema {
24
- type: RecordType;
25
- requiredFields: string[];
26
- }
27
23
  /** A decoded commit, γ = (e, parent, root) plus its repo name, message and CAR (see CommitBlock). */
28
24
  type CommitObject = CommitBlock;
29
25
  interface RepoContents {
@@ -36,15 +32,6 @@ interface RepoDiff {
36
32
  /** Ids of records that are gone. */
37
33
  deletes: string[];
38
34
  }
39
- /**
40
- * Per-repo record schemas. Types without a registered schema are
41
- * accepted as-is (permissive by default); register one to require fields.
42
- */
43
- declare class SchemaRegistry {
44
- private schemas;
45
- register(repo: RepoName, schema: RecordSchema): void;
46
- validate(repo: RepoName, type: RecordType, payload: Record<string, unknown>): boolean;
47
- }
48
35
  /**
49
36
  * Upper bound on a repo name's length. The name is stored in every commit
50
37
  * block, so this is just a sanity bound keeping that block small and
@@ -90,7 +77,6 @@ interface CreateCommitOptions {
90
77
  }
91
78
  declare class FangornEngine {
92
79
  private storage;
93
- private schemas;
94
80
  private registry;
95
81
  /**
96
82
  * Local block cache. Written blocks land here immediately; remote blocks
@@ -100,7 +86,7 @@ declare class FangornEngine {
100
86
  private cache;
101
87
  /** Commits whose CAR has already been loaded into the cache. */
102
88
  private loadedCars;
103
- constructor(storage: MetadataStorage, schemas: SchemaRegistry, registry: Registry);
89
+ constructor(storage: MetadataStorage, registry: Registry);
104
90
  /**
105
91
  * Reconstructs the CID a commit's raw digest hex refers to. The contract only
106
92
  * stores the bare 32-byte sha256 digest (see commitStateRoot), so rebuilding
@@ -198,4 +184,4 @@ declare class FangornEngine {
198
184
  readRecord(publisher: Address, repo: RepoName, id: string): Promise<StoredRecord | null>;
199
185
  }
200
186
  //#endregion
201
- export { CommitDiff, CommitObject, CreateCommitOptions, FangornEngine, MAX_REPO_NAME_LENGTH, RecordInput, RecordSchema, RecordType, type Ref, RepoContents, RepoDiff, RepoName, SchemaRegistry, StoredRecord, assertValidRepoName, rootHexFromCid };
187
+ export { CommitDiff, CommitObject, CreateCommitOptions, FangornEngine, MAX_REPO_NAME_LENGTH, RecordInput, RecordType, type Ref, RepoContents, RepoDiff, RepoName, StoredRecord, assertValidRepoName, rootHexFromCid };
@@ -7,20 +7,6 @@ import { sha256 } from "multiformats/hashes/sha2";
7
7
  import * as Digest from "multiformats/hashes/digest";
8
8
 
9
9
  //#region src/engine/index.ts
10
- /**
11
- * Per-repo record schemas. Types without a registered schema are
12
- * accepted as-is (permissive by default); register one to require fields.
13
- */
14
- var SchemaRegistry = class {
15
- schemas = /* @__PURE__ */ new Map();
16
- register(repo, schema) {
17
- this.schemas.set(`${repo}|${schema.type}`, schema);
18
- }
19
- validate(repo, type, payload) {
20
- const schema = this.schemas.get(`${repo}|${type}`);
21
- return !schema || schema.requiredFields.every((field) => field in payload);
22
- }
23
- };
24
10
  const ZERO_BYTES32 = ZERO_HEAD;
25
11
  /**
26
12
  * Upper bound on a repo name's length. The name is stored in every commit
@@ -52,9 +38,8 @@ var FangornEngine = class {
52
38
  cache = /* @__PURE__ */ new Map();
53
39
  /** Commits whose CAR has already been loaded into the cache. */
54
40
  loadedCars = /* @__PURE__ */ new Set();
55
- constructor(storage, schemas, registry) {
41
+ constructor(storage, registry) {
56
42
  this.storage = storage;
57
- this.schemas = schemas;
58
43
  this.registry = registry;
59
44
  }
60
45
  /**
@@ -165,7 +150,6 @@ var FangornEngine = class {
165
150
  const id = r.id ?? randomUUID();
166
151
  assertValidRecordId(id);
167
152
  if (id in recordCids) throw new Error(`record id ${id} staged twice`);
168
- if (!this.schemas.validate(repo, r.type, r.payload)) throw new Error(`Schema violation for record type [${r.type}] in repo [${repo}]`);
169
153
  const block = await encodeBlock({
170
154
  id,
171
155
  type: r.type,
@@ -333,4 +317,4 @@ var FangornEngine = class {
333
317
  };
334
318
 
335
319
  //#endregion
336
- export { FangornEngine, MAX_REPO_NAME_LENGTH, SchemaRegistry, assertValidRepoName, rootHexFromCid };
320
+ export { FangornEngine, MAX_REPO_NAME_LENGTH, assertValidRepoName, rootHexFromCid };
package/lib/fangorn.d.ts CHANGED
@@ -5,10 +5,10 @@ import { MembershipRegistryClient } from "./contracts/membership-registry/index.
5
5
  import "./contracts/index.js";
6
6
  import { Registry } from "./registry.js";
7
7
  import { MetadataStorage } from "./providers/storage/types.js";
8
- import { CommitDiff, FangornEngine, RecordInput, RepoContents, RepoDiff, SchemaRegistry } from "./engine/index.js";
8
+ import { CommitDiff, FangornEngine, RecordInput, RepoContents, RepoDiff } from "./engine/index.js";
9
9
  import { FangornCreateOptions, StorageConfig } from "./types/index.js";
10
10
  import { AppFeed } from "./feed.js";
11
- import * as viem0 from "viem";
11
+ import * as viem5646 from "viem";
12
12
  import { Hex, WalletClient } from "viem";
13
13
  import { CID } from "multiformats/cid";
14
14
 
@@ -61,7 +61,6 @@ interface AgentCard {
61
61
  declare class Fangorn {
62
62
  private readonly ctx;
63
63
  private _engine;
64
- private readonly _schemas;
65
64
  private _feed;
66
65
  private _apps;
67
66
  private _membership;
@@ -72,8 +71,6 @@ declare class Fangorn {
72
71
  private readonly nsCache;
73
72
  private constructor();
74
73
  get engine(): FangornEngine;
75
- /** Per-repo record schemas. Unregistered types are accepted as-is. */
76
- get schemas(): SchemaRegistry;
77
74
  /**
78
75
  * Static creation of a new Fangorn client
79
76
  *
@@ -87,7 +84,7 @@ declare class Fangorn {
87
84
  * head still names them as history.
88
85
  */
89
86
  reset(repo: string): Promise<{
90
- txHash: viem0.Hash;
87
+ txHash: viem5646.Hash;
91
88
  onChainTip: CID;
92
89
  }>;
93
90
  /** Stage records into one commit on top of `base`. */
package/lib/fangorn.js CHANGED
@@ -5,7 +5,7 @@ import { AppRegistryClient } from "./contracts/app-registry/index.js";
5
5
  import { MembershipRegistryClient } from "./contracts/membership-registry/index.js";
6
6
  import "./contracts/index.js";
7
7
  import { ChainRegistry, ZERO_HEAD, repoExcluded } from "./registry.js";
8
- import { FangornEngine, SchemaRegistry, assertValidRepoName, rootHexFromCid } from "./engine/index.js";
8
+ import { FangornEngine, assertValidRepoName, rootHexFromCid } from "./engine/index.js";
9
9
  import { AppFeed } from "./feed.js";
10
10
  import { createPublicClient, createWalletClient, http } from "viem";
11
11
  import { privateKeyToAccount } from "viem/accounts";
@@ -37,7 +37,6 @@ const FANGORN_APP_EXTENSION = "https://fangorn.network/a2a/app/v1";
37
37
  var Fangorn = class Fangorn {
38
38
  ctx;
39
39
  _engine = null;
40
- _schemas = new SchemaRegistry();
41
40
  _feed = null;
42
41
  _apps = null;
43
42
  _membership = null;
@@ -51,13 +50,9 @@ var Fangorn = class Fangorn {
51
50
  }
52
51
  get engine() {
53
52
  if (!this.ctx.metadataStorage) throw new Error("fangorn.engine requires storage configurations. Pass { pinata: { ... } } to Fangorn.create()");
54
- this._engine ??= new FangornEngine(this.ctx.metadataStorage, this._schemas, this.ctx.registry);
53
+ this._engine ??= new FangornEngine(this.ctx.metadataStorage, this.ctx.registry);
55
54
  return this._engine;
56
55
  }
57
- /** Per-repo record schemas. Unregistered types are accepted as-is. */
58
- get schemas() {
59
- return this._schemas;
60
- }
61
56
  /**
62
57
  * Static creation of a new Fangorn client
63
58
  *
@@ -560,7 +555,7 @@ var Fangorn = class Fangorn {
560
555
  * bill the app's subscription, and the app presents its repos.
561
556
  */
562
557
  getAppRegistry() {
563
- this._apps ??= new AppRegistryClient(this.ctx.config.appRegistryContractAddress, this.ctx.appId, this.ctx.publicClient, this.ctx.walletClient);
558
+ this._apps ??= new AppRegistryClient(this.ctx.config.appRegistryContractAddress, this.ctx.appId, this.ctx.publicClient, this.ctx.walletClient, this.ctx.config.logWindow);
564
559
  return this._apps;
565
560
  }
566
561
  getMembershipRegistry() {
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AppConfig, FangornConfig, SupportedNetworks, appId, nonBlank, toAppId } from "./config.js";
1
+ import { AppConfig, BaseSepoliaConfig, FangornConfig, SupportedNetworks, appId, nonBlank, toAppId } from "./config.js";
2
2
  import { APP_REGISTRY_ABI } from "./contracts/app-registry/abi.js";
3
3
  import { PublisherStatus } from "./contracts/types.js";
4
4
  import { PreparedTx } from "./contracts/write.js";
@@ -17,4 +17,4 @@ import { AssetProcessor, BuildAssetGraphOptions, CommitFileGraph, Edge, FileFaca
17
17
  import { PinataBackend } from "./providers/storage/pinata.js";
18
18
  import { DEFAULT_SIGNED_URL_WORKER, SignedUrlBackend, SignedUrlSigner } from "./providers/storage/signed-url.js";
19
19
  import { MAX_UPLOAD_ATTEMPTS, deserialize, fetchRawByCid, isTransientUpload, retrieveByCid, serialize, withUploadRetry } from "./providers/storage/utils.js";
20
- export { APP_REGISTRY_ABI, AccessRequest, AccessSigner, AgentCard, AppAccess, AppAgentLog, AppConfig, AppFeed, AppRegistryClient, AssetProcessor, BuildAssetGraphOptions, ChainRegistry, ChainRegistryConfig, ClaimArgs, CommitFileGraph, DATA_REGISTRY_ABI, DEFAULT_SIGNED_URL_WORKER, DecryptHandleParams, EPOCH_SECONDS, Edge, EncryptAndUploadParams, Exclusion, FANGORN_APP_EXTENSION, Fangorn, FangornConfig, FangornContext, FangornCreateOptions, FileFacade, GADGET_SELF_HKDF_V1, GADGET_WORKER_USDC_V1, Gadget, HandleFieldInput, JoinArgs, LogFilter, MAX_UPLOAD_ATTEMPTS, MEMBERSHIP_REGISTRY_ABI, MembershipPayment, MembershipRegistryClient, PinataBackend, PreparedTx, ProcessorResult, PublisherStatus, Registry, RepoChange, RepoRef, SignedUrlBackend, SignedUrlSigner, StorageConfig, SubscribeOptions, SupportedNetworks, UpdateEntry, Vertex, X25519_PUBKEY_LENGTH, ZERO_HEAD, accessMessageHash, appId, buildAccessRequest, buildAssetGraph, buildMarkdownGraph, covers, decryptHandle, deserialize, encryptAndUpload, epochOf, exclusionId, extractMarkdownLinks, fetchRawByCid, isTransientUpload, joinNonce, membershipScope, membershipTokenId, nonBlank, repoExcluded, repoId, retrieveByCid, seal, sealSelf, serialize, sha256Hex, toAppId, unseal, unsealSelf, withUploadRetry };
20
+ export { APP_REGISTRY_ABI, AccessRequest, AccessSigner, AgentCard, AppAccess, AppAgentLog, AppConfig, AppFeed, AppRegistryClient, AssetProcessor, BaseSepoliaConfig, BuildAssetGraphOptions, ChainRegistry, ChainRegistryConfig, ClaimArgs, CommitFileGraph, DATA_REGISTRY_ABI, DEFAULT_SIGNED_URL_WORKER, DecryptHandleParams, EPOCH_SECONDS, Edge, EncryptAndUploadParams, Exclusion, FANGORN_APP_EXTENSION, Fangorn, FangornConfig, FangornContext, FangornCreateOptions, FileFacade, GADGET_SELF_HKDF_V1, GADGET_WORKER_USDC_V1, Gadget, HandleFieldInput, JoinArgs, LogFilter, MAX_UPLOAD_ATTEMPTS, MEMBERSHIP_REGISTRY_ABI, MembershipPayment, MembershipRegistryClient, PinataBackend, PreparedTx, ProcessorResult, PublisherStatus, Registry, RepoChange, RepoRef, SignedUrlBackend, SignedUrlSigner, StorageConfig, SubscribeOptions, SupportedNetworks, UpdateEntry, Vertex, X25519_PUBKEY_LENGTH, ZERO_HEAD, accessMessageHash, appId, buildAccessRequest, buildAssetGraph, buildMarkdownGraph, covers, decryptHandle, deserialize, encryptAndUpload, epochOf, exclusionId, extractMarkdownLinks, fetchRawByCid, isTransientUpload, joinNonce, membershipScope, membershipTokenId, nonBlank, repoExcluded, repoId, retrieveByCid, seal, sealSelf, serialize, sha256Hex, toAppId, unseal, unsealSelf, withUploadRetry };
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { FangornConfig, SupportedNetworks, appId, nonBlank, toAppId } from "./config.js";
1
+ import { BaseSepoliaConfig, FangornConfig, SupportedNetworks, appId, nonBlank, toAppId } from "./config.js";
2
2
  import { DEFAULT_SIGNED_URL_WORKER, SignedUrlBackend } from "./providers/storage/signed-url.js";
3
3
  import { MAX_UPLOAD_ATTEMPTS, deserialize, fetchRawByCid, isTransientUpload, retrieveByCid, serialize, withUploadRetry } from "./providers/storage/utils.js";
4
4
  import { PinataBackend } from "./providers/storage/pinata.js";
@@ -16,4 +16,4 @@ import { FANGORN_APP_EXTENSION, Fangorn } from "./fangorn.js";
16
16
  import { buildAssetGraph, buildMarkdownGraph, extractMarkdownLinks } from "./harness/index.js";
17
17
  import { GADGET_SELF_HKDF_V1, GADGET_WORKER_USDC_V1, X25519_PUBKEY_LENGTH, accessMessageHash, buildAccessRequest, decryptHandle, encryptAndUpload, seal, sealSelf, sha256Hex, unseal, unsealSelf } from "./crypto/encryption.js";
18
18
 
19
- export { APP_REGISTRY_ABI, AppFeed, AppRegistryClient, ChainRegistry, DATA_REGISTRY_ABI, DEFAULT_SIGNED_URL_WORKER, EPOCH_SECONDS, FANGORN_APP_EXTENSION, Fangorn, FangornConfig, GADGET_SELF_HKDF_V1, GADGET_WORKER_USDC_V1, MAX_UPLOAD_ATTEMPTS, MEMBERSHIP_REGISTRY_ABI, MembershipRegistryClient, PinataBackend, PublisherStatus, SignedUrlBackend, SupportedNetworks, X25519_PUBKEY_LENGTH, ZERO_HEAD, accessMessageHash, appId, buildAccessRequest, buildAssetGraph, buildMarkdownGraph, covers, decryptHandle, deserialize, encryptAndUpload, epochOf, exclusionId, extractMarkdownLinks, fetchRawByCid, isTransientUpload, joinNonce, membershipScope, membershipTokenId, nonBlank, repoExcluded, repoId, retrieveByCid, seal, sealSelf, serialize, sha256Hex, toAppId, unseal, unsealSelf, withUploadRetry };
19
+ export { APP_REGISTRY_ABI, AppFeed, AppRegistryClient, BaseSepoliaConfig, ChainRegistry, DATA_REGISTRY_ABI, DEFAULT_SIGNED_URL_WORKER, EPOCH_SECONDS, FANGORN_APP_EXTENSION, Fangorn, FangornConfig, GADGET_SELF_HKDF_V1, GADGET_WORKER_USDC_V1, MAX_UPLOAD_ATTEMPTS, MEMBERSHIP_REGISTRY_ABI, MembershipRegistryClient, PinataBackend, PublisherStatus, SignedUrlBackend, SupportedNetworks, X25519_PUBKEY_LENGTH, ZERO_HEAD, accessMessageHash, appId, buildAccessRequest, buildAssetGraph, buildMarkdownGraph, covers, decryptHandle, deserialize, encryptAndUpload, epochOf, exclusionId, extractMarkdownLinks, fetchRawByCid, isTransientUpload, joinNonce, membershipScope, membershipTokenId, nonBlank, repoExcluded, repoId, retrieveByCid, seal, sealSelf, serialize, sha256Hex, toAppId, unseal, unsealSelf, withUploadRetry };
package/lib/registry.d.ts CHANGED
@@ -75,6 +75,7 @@ declare function exclusionId(x: Exclusion): Hex;
75
75
  interface ChainRegistryConfig {
76
76
  dataRegistryContractAddress: Address;
77
77
  appRegistryContractAddress: Address;
78
+ logWindow?: bigint;
78
79
  }
79
80
  /**
80
81
  * The registry on the contracts: H and U in the DataRegistry; membership, X and C
@@ -96,6 +97,7 @@ declare class ChainRegistry implements Registry {
96
97
  private walletClient?;
97
98
  private readonly data;
98
99
  private readonly apps;
100
+ private readonly logWindow?;
99
101
  constructor(config: ChainRegistryConfig, publicClient: PublicClient, walletClient?: WalletClient | undefined);
100
102
  epoch(): Promise<number>;
101
103
  head(ref: RepoRef): Promise<Hex>;
package/lib/registry.js CHANGED
@@ -58,11 +58,13 @@ function exclusionId(x) {
58
58
  var ChainRegistry = class {
59
59
  data;
60
60
  apps;
61
+ logWindow;
61
62
  constructor(config, publicClient, walletClient) {
62
63
  this.publicClient = publicClient;
63
64
  this.walletClient = walletClient;
64
65
  this.data = config.dataRegistryContractAddress;
65
66
  this.apps = config.appRegistryContractAddress;
67
+ this.logWindow = config.logWindow;
66
68
  }
67
69
  async epoch() {
68
70
  return epochOf((await this.publicClient.getBlock()).timestamp);
@@ -141,7 +143,7 @@ var ChainRegistry = class {
141
143
  fromBlock,
142
144
  toBlock,
143
145
  strict: true
144
- }))).sort((a, b) => a.blockNumber === b.blockNumber ? a.logIndex - b.logIndex : a.blockNumber < b.blockNumber ? -1 : 1).map(toEntry);
146
+ }), this.logWindow)).sort((a, b) => a.blockNumber === b.blockNumber ? a.logIndex - b.logIndex : a.blockNumber < b.blockNumber ? -1 : 1).map(toEntry);
145
147
  }
146
148
  watch(filter, onEntry, onError, pollingInterval) {
147
149
  return this.publicClient.watchContractEvent({