@fangorn-network/sdk 2026.5.11 → 2026.7.1-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.
Files changed (101) hide show
  1. package/README.md +219 -225
  2. package/lib/ crypto/constants.d.ts +4 -0
  3. package/lib/ crypto/constants.js +5 -0
  4. package/lib/ crypto/merkle.d.ts +10 -0
  5. package/lib/ crypto/merkle.js +34 -0
  6. package/lib/cli/cli.d.ts +0 -0
  7. package/lib/cli/cli.js +234 -235
  8. package/lib/cli/index.d.ts +13 -650
  9. package/lib/config.d.ts +45 -699
  10. package/lib/config.js +6 -22
  11. package/lib/contracts/data-registry/abi.d.ts +38 -0
  12. package/lib/contracts/data-registry/abi.js +237 -0
  13. package/lib/contracts/data-registry/index.d.ts +81 -0
  14. package/lib/contracts/data-registry/index.js +184 -0
  15. package/lib/contracts/data-registry/test.d.ts +1 -0
  16. package/lib/contracts/index.d.ts +3 -0
  17. package/lib/contracts/index.js +4 -0
  18. package/lib/crypto/aes.d.ts +26 -0
  19. package/lib/crypto/aes.js +58 -0
  20. package/lib/crypto/encryption.d.ts +53 -0
  21. package/lib/crypto/encryption.js +82 -0
  22. package/lib/crypto/rand.d.ts +5 -0
  23. package/lib/{modules/encryption → crypto}/rand.js +1 -1
  24. package/lib/{modules/encryption → crypto}/types.d.ts +1 -1
  25. package/lib/engine/blockstore.d.ts +24 -0
  26. package/lib/engine/blockstore.js +85 -0
  27. package/lib/engine/index.d.ts +180 -0
  28. package/lib/engine/index.js +367 -0
  29. package/lib/fangorn.d.ts +149 -16
  30. package/lib/fangorn.js +256 -37
  31. package/lib/harness/examples/hackmd/build-markdown-graph.d.ts +1 -0
  32. package/lib/harness/examples/hackmd/build-markdown-graph.js +17 -0
  33. package/lib/harness/index.d.ts +57 -0
  34. package/lib/harness/index.js +67 -0
  35. package/lib/index.d.ts +2 -4
  36. package/lib/index.js +1 -3
  37. package/lib/node_modules/.pnpm/@noble_ciphers@1.3.0/node_modules/@noble/ciphers/esm/_polyval.js +218 -0
  38. package/lib/node_modules/.pnpm/@noble_ciphers@1.3.0/node_modules/@noble/ciphers/esm/aes.js +261 -0
  39. package/lib/node_modules/.pnpm/@noble_ciphers@1.3.0/node_modules/@noble/ciphers/esm/utils.js +156 -0
  40. package/lib/node_modules/.pnpm/@noble_curves@1.9.7/node_modules/@noble/curves/esm/abstract/curve.js +299 -0
  41. package/lib/node_modules/.pnpm/@noble_curves@1.9.7/node_modules/@noble/curves/esm/abstract/edwards.js +532 -0
  42. package/lib/node_modules/.pnpm/@noble_curves@1.9.7/node_modules/@noble/curves/esm/abstract/modular.js +344 -0
  43. package/lib/node_modules/.pnpm/@noble_curves@1.9.7/node_modules/@noble/curves/esm/abstract/montgomery.js +137 -0
  44. package/lib/node_modules/.pnpm/@noble_curves@1.9.7/node_modules/@noble/curves/esm/ed25519.js +262 -0
  45. package/lib/node_modules/.pnpm/@noble_curves@1.9.7/node_modules/@noble/curves/esm/utils.js +150 -0
  46. package/lib/providers/storage/car.d.ts +36 -0
  47. package/lib/providers/storage/car.js +80 -0
  48. package/lib/providers/storage/pinata.d.ts +34 -2
  49. package/lib/providers/storage/pinata.js +141 -5
  50. package/lib/providers/storage/types.d.ts +31 -16
  51. package/lib/providers/storage/utils.js +2 -1
  52. package/lib/roles/repo/index.d.ts +56 -0
  53. package/lib/roles/repo/index.js +73 -0
  54. package/lib/test/car_smoke.d.ts +1 -0
  55. package/lib/test/car_smoke.js +81 -0
  56. package/lib/test/cleanup-embeddings-testdata.d.ts +1 -0
  57. package/lib/test/cleanup-embeddings-testdata.js +75 -0
  58. package/lib/test/setup-embeddings-testdata.d.ts +11 -0
  59. package/lib/test/setup-embeddings-testdata.js +155 -0
  60. package/lib/test/testbed.d.ts +39 -30
  61. package/lib/test/testbed.js +43 -129
  62. package/lib/types/index.d.ts +3 -19
  63. package/lib/utils/manifest.d.ts +23 -0
  64. package/lib/utils/manifest.js +77 -0
  65. package/package.json +99 -67
  66. package/lib/modules/encryption/actions.d.ts +0 -4
  67. package/lib/modules/encryption/actions.js +0 -18
  68. package/lib/modules/encryption/aes.d.ts +0 -10
  69. package/lib/modules/encryption/aes.js +0 -51
  70. package/lib/modules/encryption/rand.d.ts +0 -5
  71. package/lib/registries/datasource-registry/abi.d.ts +0 -156
  72. package/lib/registries/datasource-registry/abi.js +0 -194
  73. package/lib/registries/datasource-registry/index.d.ts +0 -30
  74. package/lib/registries/datasource-registry/index.js +0 -158
  75. package/lib/registries/index.d.ts +0 -3
  76. package/lib/registries/index.js +0 -4
  77. package/lib/registries/schema-registry/abi.d.ts +0 -218
  78. package/lib/registries/schema-registry/abi.js +0 -246
  79. package/lib/registries/schema-registry/index.d.ts +0 -34
  80. package/lib/registries/schema-registry/index.js +0 -179
  81. package/lib/registries/settlement-registry/abi.d.ts +0 -218
  82. package/lib/registries/settlement-registry/abi.js +0 -259
  83. package/lib/registries/settlement-registry/index.d.ts +0 -63
  84. package/lib/registries/settlement-registry/index.js +0 -325
  85. package/lib/registries/settlement-registry/types.d.ts +0 -54
  86. package/lib/roles/consumer/index.d.ts +0 -39
  87. package/lib/roles/consumer/index.js +0 -143
  88. package/lib/roles/consumer/types.d.ts +0 -47
  89. package/lib/roles/consumer/types.js +0 -1
  90. package/lib/roles/publisher/index.d.ts +0 -50
  91. package/lib/roles/publisher/index.js +0 -224
  92. package/lib/roles/publisher/types.d.ts +0 -99
  93. package/lib/roles/publisher/types.js +0 -1
  94. package/lib/roles/schema/index.d.ts +0 -18
  95. package/lib/roles/schema/index.js +0 -93
  96. package/lib/roles/schema/types.d.ts +0 -91
  97. package/lib/roles/schema/types.js +0 -1
  98. /package/lib/{modules/encryption/index.d.ts → crypto/utils.d.ts} +0 -0
  99. /package/lib/{modules/encryption/index.js → crypto/utils.js} +0 -0
  100. /package/lib/{modules/encryption/types.js → contracts/data-registry/test.js} +0 -0
  101. /package/lib/{registries/settlement-registry → crypto}/types.js +0 -0
@@ -1,224 +0,0 @@
1
- //#region src/roles/publisher/index.ts
2
- var PublisherRole = class {
3
- pendingEntries = /* @__PURE__ */ new Map();
4
- schemaCache = /* @__PURE__ */ new Map();
5
- constructor(dataSourceRegistry, schemaRegistry, storage, walletClient, config) {
6
- this.dataSourceRegistry = dataSourceRegistry;
7
- this.schemaRegistry = schemaRegistry;
8
- this.storage = storage;
9
- this.walletClient = walletClient;
10
- this.config = config;
11
- }
12
- /**
13
- * Validate and stage schema-conformant records, then commit to storage
14
- * and publish on-chain.
15
- */
16
- async upload(params, price) {
17
- const { records, schemaName, options } = params;
18
- const { schema, schemaId } = await this.resolveSchema(schemaName);
19
- for (const record of records) {
20
- this.validateRecord(record, schema);
21
- const entry = this.resolveRecord(record, schema, price);
22
- this.pendingEntries.set(record.name, entry);
23
- }
24
- return this.commit(schemaId, price, options?.overwrite ?? false);
25
- }
26
- stage(entry) {
27
- this.pendingEntries.set(entry.name, entry);
28
- }
29
- remove(name) {
30
- return this.pendingEntries.delete(name);
31
- }
32
- getPending() {
33
- return Array.from(this.pendingEntries.values());
34
- }
35
- clearPending() {
36
- this.pendingEntries.clear();
37
- }
38
- /**
39
- * Serialize all staged entries into manifests, upload to storage,
40
- * and publish each manifest CID on-chain.
41
- */
42
- async commit(schemaId, price, overwrite) {
43
- const owner = this.requireAccount();
44
- if (this.pendingEntries.size === 0) throw new Error("Nothing to commit. Stage at least one record.");
45
- let entries = Array.from(this.pendingEntries.values());
46
- if (!overwrite) {
47
- entries = await this.filterNewEntries(owner, schemaId, entries);
48
- if (entries.length === 0) {
49
- this.pendingEntries.clear();
50
- throw new Error("All staged entries already exist on-chain. Use overwrite: true to force re-publish.");
51
- }
52
- }
53
- const results = [];
54
- for (const entry of entries) {
55
- const manifest = {
56
- version: 2,
57
- schemaId,
58
- entries: [entry]
59
- };
60
- const manifestUri = await this.storage.put(manifest, { name: `manifest:${schemaId}:${entry.name}` });
61
- await this.dataSourceRegistry.publish(manifestUri, schemaId, entry.name, price);
62
- results.push({
63
- entry,
64
- manifestUri
65
- });
66
- }
67
- this.pendingEntries.clear();
68
- return {
69
- manifestUri: results[results.length - 1]?.manifestUri ?? "",
70
- schemaId,
71
- owner,
72
- entryCount: results.length
73
- };
74
- }
75
- async getManifest(schemaId, name) {
76
- const owner = this.requireAccount();
77
- try {
78
- const ds = await this.dataSourceRegistry.get(owner, schemaId, name);
79
- if (!ds.manifestCid || ds.manifestCid === "") return void 0;
80
- return await this.storage.get(ds.manifestCid);
81
- } catch {
82
- return;
83
- }
84
- }
85
- async getEntry(schemaId, name) {
86
- const manifest = await this.getManifest(schemaId, name);
87
- if (!manifest) throw new Error(`No manifest found for schemaId ${schemaId} / name ${name}`);
88
- const entry = manifest.entries.find((e) => e.name === name);
89
- if (!entry) throw new Error(`Entry not found: "${name}"`);
90
- return entry;
91
- }
92
- requireAccount() {
93
- const address = this.walletClient.account?.address;
94
- if (!address) throw new Error("No account connected to wallet client");
95
- return address;
96
- }
97
- resolveSchema(name) {
98
- if (!this.schemaCache.has(name)) {
99
- const p = Promise.all([this.schemaRegistry.getSchema(name), this.schemaRegistry.schemaId(name)]).then(async ([{ specCid }, schemaId]) => {
100
- return {
101
- schema: (await this.storage.get(specCid)).definition,
102
- schemaId
103
- };
104
- }).catch((err) => {
105
- this.schemaCache.delete(name);
106
- throw err;
107
- });
108
- this.schemaCache.set(name, p);
109
- }
110
- const cached = this.schemaCache.get(name);
111
- if (!cached) throw new Error(`Schema not found in cache: ${name}`);
112
- return cached;
113
- }
114
- /**
115
- * Resolve a PublishRecord into a ManifestEntry.
116
- * Handle fields are passed through directly; plain fields stored inline.
117
- */
118
- resolveRecord(record, schema, price) {
119
- const resolvedFields = {};
120
- for (const [fieldName] of Object.entries(schema)) {
121
- const value = record.fields[fieldName];
122
- if (isHandleFieldInput(value)) resolvedFields[fieldName] = {
123
- "@type": "handle",
124
- uri: value.uri,
125
- workerUrl: value.workerUrl,
126
- price: price.toString()
127
- };
128
- else resolvedFields[fieldName] = value;
129
- }
130
- return {
131
- name: record.name,
132
- fields: resolvedFields
133
- };
134
- }
135
- validateRecord(record, schema) {
136
- const errors = [];
137
- for (const [fieldName, fieldDef] of Object.entries(schema)) this.validateField(record.name, fieldName, fieldDef, record.fields[fieldName], errors);
138
- for (const fieldName of Object.keys(record.fields)) if (!(fieldName in schema)) console.warn(`Record "${record.name}": field "${fieldName}" is not in the schema and will be ignored`);
139
- if (errors.length > 0) throw new Error(`Validation failed for record "${record.name}":\n` + errors.map((e) => ` • ${e}`).join("\n"));
140
- }
141
- validateField(name, fieldName, fieldDef, value, errors) {
142
- if (isHandleFieldInput(value)) return;
143
- const rawType = fieldDef["@type"];
144
- const nullable = rawType.includes("| null");
145
- const baseType = rawType.replace("| null", "").trim();
146
- if (value === null) {
147
- if (!nullable) errors.push(`"${fieldName}" is required (non-nullable), got null`);
148
- return;
149
- }
150
- switch (baseType) {
151
- case "string":
152
- if (typeof value !== "string") errors.push(`"${fieldName}" must be a string, got ${typeof value}`);
153
- break;
154
- case "number":
155
- if (typeof value !== "number") errors.push(`"${fieldName}" must be a number, got ${typeof value}`);
156
- break;
157
- case "boolean":
158
- if (typeof value !== "boolean") errors.push(`"${fieldName}" must be a boolean, got ${typeof value}`);
159
- break;
160
- case "bytes":
161
- if (!(value instanceof Uint8Array)) errors.push(`"${fieldName}" must be Uint8Array`);
162
- break;
163
- case "array": {
164
- if (!Array.isArray(value)) {
165
- errors.push(`"${fieldName}" must be an array, got ${typeof value}`);
166
- break;
167
- }
168
- const itemDef = fieldDef.items;
169
- if (!itemDef) break;
170
- if ("@type" in itemDef) value.forEach((item, i) => {
171
- this.validateField(name, `${fieldName}[${i.toString()}]`, itemDef, item, errors);
172
- });
173
- else value.forEach((item, i) => {
174
- if (typeof item !== "object" || Array.isArray(item) || item === null) {
175
- errors.push(`"${fieldName}[${i.toString()}]" must be an object`);
176
- return;
177
- }
178
- for (const [subField, subDef] of Object.entries(itemDef)) this.validateField(name, `${fieldName}[${i.toString()}].${subField}`, subDef, item[subField], errors);
179
- });
180
- break;
181
- }
182
- case "object": {
183
- if (typeof value !== "object" || Array.isArray(value)) {
184
- errors.push(`"${fieldName}" must be an object, got ${typeof value}`);
185
- break;
186
- }
187
- const itemsDef = fieldDef.items;
188
- if (itemsDef && !("@type" in itemsDef)) for (const [subField, subDef] of Object.entries(itemsDef)) this.validateField(name, `${fieldName}.${subField}`, subDef, value[subField], errors);
189
- break;
190
- }
191
- default: console.warn(`Record "${name}" field "${fieldName}": unknown @type "${baseType}", skipping validation`);
192
- }
193
- }
194
- /**
195
- * Return only entries whose names do not already exist on-chain
196
- * for this (owner, schemaId) pair.
197
- */
198
- async filterNewEntries(owner, schemaId, pendingEntries) {
199
- const results = await Promise.allSettled(pendingEntries.map(async (entry) => {
200
- try {
201
- const ds = await this.dataSourceRegistry.get(owner, schemaId, entry.name);
202
- return {
203
- entry,
204
- exists: ds.manifestCid && ds.manifestCid !== ""
205
- };
206
- } catch {
207
- return {
208
- entry,
209
- exists: false
210
- };
211
- }
212
- }));
213
- const newEntries = [];
214
- for (const result of results) if (result.status === "fulfilled" && !result.value.exists) newEntries.push(result.value.entry);
215
- else if (result.status === "rejected") console.warn("Failed to check entry existence, including conservatively:", result.reason);
216
- return newEntries;
217
- }
218
- };
219
- function isHandleFieldInput(value) {
220
- return typeof value === "object" && value !== null && "@type" in value && value["@type"] === "handle";
221
- }
222
-
223
- //#endregion
224
- export { PublisherRole };
@@ -1,99 +0,0 @@
1
- import { Address, Hex } from "viem";
2
-
3
- //#region src/roles/publisher/types.d.ts
4
-
5
- /**
6
- * A single field value supplied by the publisher.
7
- * Supports primitives, nullable variants, arrays, objects, and handle fields.
8
- */
9
- type FieldInput = null | string | number | boolean | Uint8Array | string[] | number[] | boolean[] | null[] | FieldInputObject | FieldInputObject[] | HandleFieldInput | HandleArray;
10
- interface FieldInputObject {
11
- [key: string]: FieldInput;
12
- }
13
- interface HandleArray {
14
- "@type": "array";
15
- items: HandleFieldInput[];
16
- }
17
- interface ResolvedHandleArray {
18
- "@type": "array";
19
- items: ResolvedHandleField[];
20
- }
21
- /**
22
- * A field whose content already lives in a storage backend.
23
- * The publisher supplies the URI directly — no encrypt/store step occurs.
24
- * Examples:
25
- * "r2://tracks/song.mp3"
26
- * "ipfs://QmXyz..." [future]
27
- */
28
- interface HandleFieldInput {
29
- "@type": "handle";
30
- uri: string;
31
- workerUrl: string;
32
- }
33
- /**
34
- * One schema-conformant record to publish.
35
- * `name` uniquely identifies this record within (owner, schemaId) —
36
- * it maps to the resourceId in the SettlementRegistry.
37
- */
38
- interface PublishRecord {
39
- name: string;
40
- fields: Record<string, FieldInput>;
41
- }
42
- /**
43
- * A resolved handle field — points to content in a storage backend.
44
- * The URI scheme identifies the backend:
45
- * r2:// → Fangorn access worker (requires settlement proof)
46
- * ipfs:// → public IPFS gateway [future]
47
- */
48
- interface ResolvedHandleField {
49
- "@type": "handle";
50
- uri: string;
51
- workerUrl: string;
52
- price: string;
53
- }
54
- /** A resolved plain field, stored inline in the manifest */
55
- type ResolvedPlainField = null | string | number | boolean | Uint8Array | string[] | number[] | boolean[] | null[] | ResolvedObject | ResolvedObject[];
56
- interface ResolvedObject {
57
- [key: string]: ResolvedPlainField;
58
- }
59
- type ResolvedField = ResolvedPlainField | ResolvedHandleField | ResolvedHandleArray;
60
- /**
61
- * A manifest entry; one schema-conformant record with all fields resolved.
62
- * Plain fields are readable by anyone directly from the manifest.
63
- * Handle fields require the consumer to fetch via the appropriate backend.
64
- */
65
- interface ManifestEntry {
66
- name: string;
67
- fields: Record<string, ResolvedField>;
68
- }
69
- interface Manifest {
70
- version: 2;
71
- schemaId: Hex;
72
- entries: ManifestEntry[];
73
- }
74
- interface UploadParams {
75
- records: PublishRecord[];
76
- /**
77
- * The unique name of the schema the records must conform to.
78
- */
79
- schemaName: string;
80
- /**
81
- * Configurable gas for the on-chain publish call.
82
- */
83
- gas?: bigint;
84
- options?: {
85
- /**
86
- * When false (default) existing entries are preserved.
87
- * When true the manifest is fully replaced.
88
- */
89
- overwrite?: boolean;
90
- };
91
- }
92
- interface CommitResult {
93
- manifestUri: string;
94
- schemaId: Hex;
95
- owner: Address;
96
- entryCount: number;
97
- }
98
- //#endregion
99
- export { CommitResult, FieldInput, FieldInputObject, HandleArray, HandleFieldInput, Manifest, ManifestEntry, PublishRecord, ResolvedField, ResolvedHandleArray, ResolvedHandleField, ResolvedObject, ResolvedPlainField, UploadParams };
@@ -1 +0,0 @@
1
- export { };
@@ -1,18 +0,0 @@
1
- import { SchemaRegistry } from "../../registries/schema-registry/index.js";
2
- import { MetadataStorage } from "../../providers/storage/types.js";
3
- import { EncryptedField, FieldDefinition, FieldType, HandleField, NullableType, PlainField, RegisterAgentParams, RegisterSchemaParams, RegisteredAgent, RegisteredSchema, ScalarType, SchemaBlobV1, SchemaDefinition, SchemaRoleConfig } from "./types.js";
4
- import { WalletClient } from "viem";
5
-
6
- //#region src/roles/schema/index.d.ts
7
- declare class SchemaRole {
8
- private readonly schemaRegistry;
9
- private readonly storage;
10
- private readonly walletClient;
11
- constructor(schemaRegistry: SchemaRegistry, storage: MetadataStorage, walletClient: WalletClient);
12
- register(params: RegisterSchemaParams): Promise<RegisteredSchema>;
13
- get(nameOrId: string): Promise<RegisteredSchema | undefined>;
14
- validate(data: Record<string, unknown>, definition: SchemaDefinition): string[];
15
- private requireAccount;
16
- }
17
- //#endregion
18
- export { EncryptedField, FieldDefinition, FieldType, HandleField, NullableType, PlainField, RegisterAgentParams, RegisterSchemaParams, RegisteredAgent, RegisteredSchema, ScalarType, SchemaBlobV1, SchemaDefinition, SchemaRole, SchemaRoleConfig };
@@ -1,93 +0,0 @@
1
- //#region src/roles/schema/index.ts
2
- var SchemaRole = class {
3
- constructor(schemaRegistry, storage, walletClient) {
4
- this.schemaRegistry = schemaRegistry;
5
- this.storage = storage;
6
- this.walletClient = walletClient;
7
- }
8
- async register(params) {
9
- const owner = this.requireAccount();
10
- const blob = {
11
- version: 1,
12
- name: params.name,
13
- owner,
14
- agentId: params.agentId,
15
- definition: params.definition,
16
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
17
- };
18
- const schemaCid = await this.storage.put(blob, { name: `schema:${params.name}` });
19
- const { schemaId } = await this.schemaRegistry.registerSchema(params.name, schemaCid, params.agentId);
20
- return {
21
- schemaId,
22
- schemaCid,
23
- definition: params.definition,
24
- name: params.name,
25
- agentId: params.agentId,
26
- owner
27
- };
28
- }
29
- async get(nameOrId) {
30
- try {
31
- const schemaId = await this.schemaRegistry.schemaId(typeof nameOrId === "string" && !/^0x[0-9a-fA-F]{64}$/.test(nameOrId) ? nameOrId : nameOrId);
32
- const record = await this.schemaRegistry.getSchema(nameOrId);
33
- if (!record.specCid) return void 0;
34
- const blob = await this.storage.get(record.specCid);
35
- return {
36
- schemaId,
37
- schemaCid: record.specCid,
38
- definition: blob.definition,
39
- name: blob.name,
40
- agentId: blob.agentId,
41
- owner: blob.owner
42
- };
43
- } catch (e) {
44
- console.error(e);
45
- return;
46
- }
47
- }
48
- validate(data, definition) {
49
- const errors = [];
50
- for (const [field, fieldDef] of Object.entries(definition)) {
51
- const value = data[field];
52
- if (value === void 0 || value === null) {
53
- errors.push(`Missing required field: "${field}"`);
54
- continue;
55
- }
56
- switch (fieldDef["@type"]) {
57
- case "string":
58
- if (typeof value !== "string") errors.push(`Field "${field}" must be a string, got ${typeof value}`);
59
- break;
60
- case "number":
61
- if (typeof value !== "number") errors.push(`Field "${field}" must be a number, got ${typeof value}`);
62
- break;
63
- case "boolean":
64
- if (typeof value !== "boolean") errors.push(`Field "${field}" must be a boolean, got ${typeof value}`);
65
- break;
66
- case "bytes":
67
- if (!(value instanceof Uint8Array) && !ArrayBuffer.isView(value)) errors.push(`Field "${field}" must be bytes (Uint8Array)`);
68
- break;
69
- case "handle":
70
- if (typeof value.uri !== "string") errors.push(`Field "${field}" is a handle — expected { uri: string }`);
71
- break;
72
- case "array": {
73
- if (!Array.isArray(value)) {
74
- errors.push(`Field "${field}" must be an array, got ${typeof value}`);
75
- break;
76
- }
77
- const items = fieldDef.items;
78
- value.forEach((item, i) => errors.push(...this.validate({ [`${field}[${i.toString()}]`]: item }, { [`${field}[${i.toString()}]`]: items })));
79
- break;
80
- }
81
- }
82
- }
83
- return errors;
84
- }
85
- requireAccount() {
86
- const address = this.walletClient.account?.address;
87
- if (!address) throw new Error("No account connected to wallet client");
88
- return address;
89
- }
90
- };
91
-
92
- //#endregion
93
- export { SchemaRole };
@@ -1,91 +0,0 @@
1
- import { Hex } from "viem";
2
-
3
- //#region src/roles/schema/types.d.ts
4
- type ScalarType = "string" | "number" | "boolean" | "bytes";
5
- type NullableType = `${ScalarType} | null` | "array | null" | "object | null";
6
- type FieldType = ScalarType | "array" | "object" | NullableType;
7
- type PlainField = {
8
- "@type": ScalarType | NullableType;
9
- } | {
10
- "@type": "array" | "array | null";
11
- items: FieldDefinition;
12
- } | {
13
- "@type": "object" | "object | null";
14
- items: Record<string, FieldDefinition>;
15
- };
16
- interface EncryptedField {
17
- "@type": "encrypted";
18
- /** Gadget identifier — resolved against the GadgetRegistry at publish time */
19
- gadget: string;
20
- /** Populated by a publisher after encryption, not defined by the schema owner */
21
- handle?: {
22
- cid: string;
23
- gateway: string;
24
- };
25
- }
26
- interface HandleField {
27
- "@type": "handle";
28
- }
29
- interface EncryptedField {
30
- "@type": "encrypted";
31
- gadget: string;
32
- handle?: {
33
- cid: string;
34
- gateway: string;
35
- };
36
- }
37
- interface FieldDefinition {
38
- "@type": string;
39
- "@description"?: string;
40
- items?: FieldDefinition | Record<string, FieldDefinition>;
41
- }
42
- type SchemaDefinition = Record<string, FieldDefinition>;
43
- interface RegisterAgentParams {
44
- name: string;
45
- description: string;
46
- /** Optional A2A agent card URL e.g. https://example.com/.well-known/agentcard.json */
47
- a2aUrl?: string;
48
- /** Optional MCP endpoint URL */
49
- mcpEndpoint?: string;
50
- /** Optional ENS name */
51
- ens?: string;
52
- }
53
- interface RegisterSchemaParams {
54
- definition: SchemaDefinition;
55
- agentId: string;
56
- name: string;
57
- }
58
- interface RegisteredAgent {
59
- agentId: string;
60
- }
61
- interface RegisteredSchema {
62
- schemaId: Hex;
63
- schemaCid: string;
64
- definition: SchemaDefinition;
65
- name: string;
66
- agentId: string;
67
- owner: Hex;
68
- }
69
- interface SchemaBlobV1 {
70
- version: 1;
71
- name: string;
72
- owner: Hex;
73
- agentId: string;
74
- definition: SchemaDefinition;
75
- createdAt: string;
76
- }
77
- interface SchemaRoleConfig {
78
- chainId: number;
79
- rpcUrl: string;
80
- privateKey: Hex;
81
- pinataJwt: string;
82
- /** Optional — override ERC-8004 registry addresses per chainId */
83
- registryOverrides?: Record<number, {
84
- IDENTITY: string;
85
- REPUTATION: string;
86
- }>;
87
- /** Optional — override subgraph URLs per chainId */
88
- subgraphOverrides?: Record<number, string>;
89
- }
90
- //#endregion
91
- export { EncryptedField, FieldDefinition, FieldType, HandleField, NullableType, PlainField, RegisterAgentParams, RegisterSchemaParams, RegisteredAgent, RegisteredSchema, ScalarType, SchemaBlobV1, SchemaDefinition, SchemaRoleConfig };
@@ -1 +0,0 @@
1
- export { };