@0gfoundation/0g-agentdna 0.0.0-stage → 0.2.1

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 (206) hide show
  1. package/GUIDE.md +975 -0
  2. package/LICENSE +21 -0
  3. package/MIGRATION.md +84 -0
  4. package/MIGRATION.zh.md +70 -0
  5. package/PROVIDERS.md +273 -0
  6. package/PROVIDERS.zh.md +234 -0
  7. package/README.md +334 -2
  8. package/dist/AgentClient.d.ts +312 -0
  9. package/dist/AgentClient.d.ts.map +1 -0
  10. package/dist/AgentClient.js +715 -0
  11. package/dist/AgentClient.js.map +1 -0
  12. package/dist/AgenticID.d.ts +823 -0
  13. package/dist/AgenticID.d.ts.map +1 -0
  14. package/dist/AgenticID.js +1188 -0
  15. package/dist/AgenticID.js.map +1 -0
  16. package/dist/AgenticIDClient.d.ts +68 -0
  17. package/dist/AgenticIDClient.d.ts.map +1 -0
  18. package/dist/AgenticIDClient.js +198 -0
  19. package/dist/AgenticIDClient.js.map +1 -0
  20. package/dist/AttestorClient.d.ts +465 -0
  21. package/dist/AttestorClient.d.ts.map +1 -0
  22. package/dist/AttestorClient.js +1030 -0
  23. package/dist/AttestorClient.js.map +1 -0
  24. package/dist/Providers.d.ts +72 -0
  25. package/dist/Providers.d.ts.map +1 -0
  26. package/dist/Providers.js +182 -0
  27. package/dist/Providers.js.map +1 -0
  28. package/dist/ReputationClient.d.ts +213 -0
  29. package/dist/ReputationClient.d.ts.map +1 -0
  30. package/dist/ReputationClient.js +708 -0
  31. package/dist/ReputationClient.js.map +1 -0
  32. package/dist/SandboxClient.d.ts +107 -0
  33. package/dist/SandboxClient.d.ts.map +1 -0
  34. package/dist/SandboxClient.js +200 -0
  35. package/dist/SandboxClient.js.map +1 -0
  36. package/dist/ServeProof.d.ts +161 -0
  37. package/dist/ServeProof.d.ts.map +1 -0
  38. package/dist/ServeProof.js +230 -0
  39. package/dist/ServeProof.js.map +1 -0
  40. package/dist/ServeSession.d.ts +180 -0
  41. package/dist/ServeSession.d.ts.map +1 -0
  42. package/dist/ServeSession.js +336 -0
  43. package/dist/ServeSession.js.map +1 -0
  44. package/dist/Settings.d.ts +179 -0
  45. package/dist/Settings.d.ts.map +1 -0
  46. package/dist/Settings.js +247 -0
  47. package/dist/Settings.js.map +1 -0
  48. package/dist/abi.d.ts +2216 -0
  49. package/dist/abi.d.ts.map +1 -0
  50. package/dist/abi.js +1248 -0
  51. package/dist/abi.js.map +1 -0
  52. package/dist/cli/commands/cells.d.ts +62 -0
  53. package/dist/cli/commands/cells.d.ts.map +1 -0
  54. package/dist/cli/commands/cells.js +113 -0
  55. package/dist/cli/commands/cells.js.map +1 -0
  56. package/dist/cli/commands/doctor.d.ts +15 -0
  57. package/dist/cli/commands/doctor.d.ts.map +1 -0
  58. package/dist/cli/commands/doctor.js +236 -0
  59. package/dist/cli/commands/doctor.js.map +1 -0
  60. package/dist/cli/commands/interactive.d.ts +115 -0
  61. package/dist/cli/commands/interactive.d.ts.map +1 -0
  62. package/dist/cli/commands/interactive.js +3052 -0
  63. package/dist/cli/commands/interactive.js.map +1 -0
  64. package/dist/cli/commands/list.d.ts +31 -0
  65. package/dist/cli/commands/list.d.ts.map +1 -0
  66. package/dist/cli/commands/list.js +91 -0
  67. package/dist/cli/commands/list.js.map +1 -0
  68. package/dist/cli/commands/providers.d.ts +3 -0
  69. package/dist/cli/commands/providers.d.ts.map +1 -0
  70. package/dist/cli/commands/providers.js +21 -0
  71. package/dist/cli/commands/providers.js.map +1 -0
  72. package/dist/cli/commands/settings.d.ts +22 -0
  73. package/dist/cli/commands/settings.d.ts.map +1 -0
  74. package/dist/cli/commands/settings.js +188 -0
  75. package/dist/cli/commands/settings.js.map +1 -0
  76. package/dist/cli/commands/status.d.ts +16 -0
  77. package/dist/cli/commands/status.d.ts.map +1 -0
  78. package/dist/cli/commands/status.js +148 -0
  79. package/dist/cli/commands/status.js.map +1 -0
  80. package/dist/cli/commands/update.d.ts +21 -0
  81. package/dist/cli/commands/update.d.ts.map +1 -0
  82. package/dist/cli/commands/update.js +95 -0
  83. package/dist/cli/commands/update.js.map +1 -0
  84. package/dist/cli/config.d.ts +73 -0
  85. package/dist/cli/config.d.ts.map +1 -0
  86. package/dist/cli/config.js +239 -0
  87. package/dist/cli/config.js.map +1 -0
  88. package/dist/cli/env.d.ts +36 -0
  89. package/dist/cli/env.d.ts.map +1 -0
  90. package/dist/cli/env.js +74 -0
  91. package/dist/cli/env.js.map +1 -0
  92. package/dist/cli/envelope.d.ts +33 -0
  93. package/dist/cli/envelope.d.ts.map +1 -0
  94. package/dist/cli/envelope.js +62 -0
  95. package/dist/cli/envelope.js.map +1 -0
  96. package/dist/cli/errors.d.ts +48 -0
  97. package/dist/cli/errors.d.ts.map +1 -0
  98. package/dist/cli/errors.js +81 -0
  99. package/dist/cli/errors.js.map +1 -0
  100. package/dist/cli/inference.d.ts +21 -0
  101. package/dist/cli/inference.d.ts.map +1 -0
  102. package/dist/cli/inference.js +60 -0
  103. package/dist/cli/inference.js.map +1 -0
  104. package/dist/cli/logo.d.ts +21 -0
  105. package/dist/cli/logo.d.ts.map +1 -0
  106. package/dist/cli/logo.js +131 -0
  107. package/dist/cli/logo.js.map +1 -0
  108. package/dist/cli/main.d.ts +14 -0
  109. package/dist/cli/main.d.ts.map +1 -0
  110. package/dist/cli/main.js +223 -0
  111. package/dist/cli/main.js.map +1 -0
  112. package/dist/cli/proofs.d.ts +67 -0
  113. package/dist/cli/proofs.d.ts.map +1 -0
  114. package/dist/cli/proofs.js +133 -0
  115. package/dist/cli/proofs.js.map +1 -0
  116. package/dist/cli/ref.d.ts +39 -0
  117. package/dist/cli/ref.d.ts.map +1 -0
  118. package/dist/cli/ref.js +48 -0
  119. package/dist/cli/ref.js.map +1 -0
  120. package/dist/cli/sdk.d.ts +24 -0
  121. package/dist/cli/sdk.d.ts.map +1 -0
  122. package/dist/cli/sdk.js +65 -0
  123. package/dist/cli/sdk.js.map +1 -0
  124. package/dist/cli/settings.d.ts +66 -0
  125. package/dist/cli/settings.d.ts.map +1 -0
  126. package/dist/cli/settings.js +137 -0
  127. package/dist/cli/settings.js.map +1 -0
  128. package/dist/cli/tokenize.d.ts +61 -0
  129. package/dist/cli/tokenize.d.ts.map +1 -0
  130. package/dist/cli/tokenize.js +157 -0
  131. package/dist/cli/tokenize.js.map +1 -0
  132. package/dist/cli/types.d.ts +25 -0
  133. package/dist/cli/types.d.ts.map +1 -0
  134. package/dist/cli/types.js +8 -0
  135. package/dist/cli/types.js.map +1 -0
  136. package/dist/constants.d.ts +107 -0
  137. package/dist/constants.d.ts.map +1 -0
  138. package/dist/constants.js +74 -0
  139. package/dist/constants.js.map +1 -0
  140. package/dist/context.d.ts +108 -0
  141. package/dist/context.d.ts.map +1 -0
  142. package/dist/context.js +64 -0
  143. package/dist/context.js.map +1 -0
  144. package/dist/index.d.ts +45 -0
  145. package/dist/index.d.ts.map +1 -0
  146. package/dist/index.js +118 -0
  147. package/dist/index.js.map +1 -0
  148. package/dist/provider-catalog.json +23 -0
  149. package/dist/seal.d.ts +47 -0
  150. package/dist/seal.d.ts.map +1 -0
  151. package/dist/seal.js +145 -0
  152. package/dist/seal.js.map +1 -0
  153. package/dist/secretEnv.d.ts +119 -0
  154. package/dist/secretEnv.d.ts.map +1 -0
  155. package/dist/secretEnv.js +199 -0
  156. package/dist/secretEnv.js.map +1 -0
  157. package/dist/taskHash.d.ts +39 -0
  158. package/dist/taskHash.d.ts.map +1 -0
  159. package/dist/taskHash.js +119 -0
  160. package/dist/taskHash.js.map +1 -0
  161. package/dist/types.d.ts +336 -0
  162. package/dist/types.d.ts.map +1 -0
  163. package/dist/types.js +19 -0
  164. package/dist/types.js.map +1 -0
  165. package/package.json +75 -4
  166. package/scripts/sync-providers.cjs +8 -0
  167. package/src/AgentClient.ts +897 -0
  168. package/src/AgenticID.ts +1382 -0
  169. package/src/AgenticIDClient.ts +238 -0
  170. package/src/AttestorClient.ts +1306 -0
  171. package/src/Providers.ts +176 -0
  172. package/src/ReputationClient.ts +821 -0
  173. package/src/SandboxClient.ts +227 -0
  174. package/src/ServeProof.ts +290 -0
  175. package/src/ServeSession.ts +421 -0
  176. package/src/Settings.ts +296 -0
  177. package/src/abi.ts +1282 -0
  178. package/src/cli/commands/cells.ts +107 -0
  179. package/src/cli/commands/doctor.ts +235 -0
  180. package/src/cli/commands/interactive.ts +2738 -0
  181. package/src/cli/commands/list.ts +95 -0
  182. package/src/cli/commands/providers.ts +16 -0
  183. package/src/cli/commands/settings.ts +197 -0
  184. package/src/cli/commands/status.ts +170 -0
  185. package/src/cli/commands/update.ts +86 -0
  186. package/src/cli/config.ts +225 -0
  187. package/src/cli/env.ts +90 -0
  188. package/src/cli/envelope.ts +57 -0
  189. package/src/cli/errors.ts +114 -0
  190. package/src/cli/inference.ts +57 -0
  191. package/src/cli/logo.ts +125 -0
  192. package/src/cli/main.ts +235 -0
  193. package/src/cli/proofs.ts +160 -0
  194. package/src/cli/ref.ts +58 -0
  195. package/src/cli/sdk.ts +65 -0
  196. package/src/cli/settings.ts +153 -0
  197. package/src/cli/tokenize.ts +131 -0
  198. package/src/cli/types.ts +27 -0
  199. package/src/constants.ts +106 -0
  200. package/src/context.ts +161 -0
  201. package/src/index.ts +129 -0
  202. package/src/provider-catalog.json +23 -0
  203. package/src/seal.ts +163 -0
  204. package/src/secretEnv.ts +250 -0
  205. package/src/taskHash.ts +100 -0
  206. package/src/types.ts +357 -0
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ /**
3
+ * @file tokenize.ts
4
+ * @description Splitting a REPL line into arguments, the way a shell does.
5
+ *
6
+ * Outside the REPL the user's shell does this and the CLI never sees quotes.
7
+ * Inside it, a bare `line.split(/\s+/)` made every value containing a space
8
+ * unreachable — `others={"tools": {"bash": true}}` arrived as four
9
+ * arguments, and the error message helpfully suggested quoting, which the
10
+ * splitter then handed through as literal `'` characters. Quoting has to
11
+ * actually work, or the advice is a dead end.
12
+ *
13
+ * The grammar is the small familiar one, and deliberately no larger:
14
+ *
15
+ * 'single' everything literal up to the next single quote
16
+ * "double" literal too, except `\"` and `\\`
17
+ * \x outside quotes, the next character verbatim (so `\ ` is a space)
18
+ * {…} […] a JSON literal WHERE A VALUE STARTS — copied through exactly as
19
+ * typed, to its matching close: spaces, nesting and quotes alike
20
+ *
21
+ * That last rule is what keeps a shell splitter honest about JSON. Quote
22
+ * characters are how a shell protects a value, but they are also what JSON is
23
+ * MADE of, so stripping them turns `others={"a":1}` — the unquoted form the
24
+ * help and the GUIDE print — into `others={a:1}`, which parses as nothing.
25
+ * A literal opening where a value begins (the start of a token, or right after
26
+ * an `=`) is therefore data: copied, not interpreted. Elsewhere a bracket is
27
+ * an ordinary character, so `/api/x[0]` is still one plain token.
28
+ *
29
+ * No variable expansion, no globbing, no operators — a REPL argument is data,
30
+ * and a splitter that interprets it would be a surprise, not a convenience.
31
+ * Adjacent pieces join into one token (`others='{"a": 1}'` is one word),
32
+ * which is the whole point.
33
+ *
34
+ * A command whose LAST argument is free-form text rather than a value in a
35
+ * list — `call <id> <path> <json-body>` — should not be run through this at
36
+ * all: see {@link splitHead}.
37
+ */
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.tokenize = tokenize;
40
+ exports.splitHead = splitHead;
41
+ /**
42
+ * Split a command line into tokens. An unterminated quote is NOT an error:
43
+ * the user is mid-thought at an interactive prompt, so the run of text is
44
+ * taken as written and the caller's own grammar check reports whatever is
45
+ * wrong with it — a parse error about quoting would just be noise on top.
46
+ */
47
+ function tokenize(line) {
48
+ return scan(line, Infinity).head;
49
+ }
50
+ /**
51
+ * Split off the first `n` tokens and hand the REST OF THE LINE back verbatim.
52
+ *
53
+ * The shell-style splitter is the wrong tool for an argument that is free-form
54
+ * text. `call 42 /api/x {"a": 1}` has a fixed head — command, agent, path —
55
+ * and then a body that is whatever the user typed, quotes and inner spacing
56
+ * included, on its way to an agent that will parse it. Tokenizing that and
57
+ * re-joining the pieces with a single space is a guess about what was typed;
58
+ * taking the remainder of the line is not a guess.
59
+ *
60
+ * `rest` has no leading whitespace, and is '' when the line holds no more
61
+ * than `n` tokens.
62
+ */
63
+ function splitHead(line, n) {
64
+ return scan(line, n);
65
+ }
66
+ /** The one scanner behind both entry points: it stops after `limit` tokens
67
+ * and reports whatever is left of the line untouched. */
68
+ function scan(line, limit) {
69
+ const head = [];
70
+ let cur = '';
71
+ let started = false; // distinguishes '' (a real empty token) from no token
72
+ let quote = null;
73
+ for (let i = 0; i < line.length; i++) {
74
+ const c = line[i];
75
+ if (quote === "'") {
76
+ if (c === "'")
77
+ quote = null;
78
+ else
79
+ cur += c;
80
+ continue;
81
+ }
82
+ if (quote === '"') {
83
+ if (c === '"')
84
+ quote = null;
85
+ else if (c === '\\' && (line[i + 1] === '"' || line[i + 1] === '\\'))
86
+ cur += line[++i];
87
+ else
88
+ cur += c;
89
+ continue;
90
+ }
91
+ // The head the caller asked for is complete: everything from the next
92
+ // non-space character on belongs to it verbatim.
93
+ if (!started && head.length >= limit) {
94
+ if (/\s/.test(c))
95
+ continue;
96
+ return { head, rest: line.slice(i) };
97
+ }
98
+ if (c === "'" || c === '"') {
99
+ quote = c;
100
+ started = true;
101
+ continue;
102
+ }
103
+ if ((c === '{' || c === '[') && (!started || line[i - 1] === '=')) {
104
+ const end = literalEnd(line, i);
105
+ cur += line.slice(i, end);
106
+ i = end - 1;
107
+ started = true;
108
+ continue;
109
+ }
110
+ if (c === '\\' && i + 1 < line.length) {
111
+ cur += line[++i];
112
+ started = true;
113
+ continue;
114
+ }
115
+ if (/\s/.test(c)) {
116
+ if (started) {
117
+ head.push(cur);
118
+ cur = '';
119
+ started = false;
120
+ }
121
+ continue;
122
+ }
123
+ cur += c;
124
+ started = true;
125
+ }
126
+ if (started)
127
+ head.push(cur);
128
+ return { head, rest: '' };
129
+ }
130
+ /** Index just past the `}`/`]` closing the literal that opens at `start`.
131
+ * Brackets inside a JSON string don't count. An unbalanced literal runs to
132
+ * the end of the line — the same "taken as written" treatment an
133
+ * unterminated quote gets, leaving the grammar check to report it. */
134
+ function literalEnd(line, start) {
135
+ let depth = 0;
136
+ let inString = false;
137
+ for (let i = start; i < line.length; i++) {
138
+ const c = line[i];
139
+ if (inString) {
140
+ if (c === '\\')
141
+ i++;
142
+ else if (c === '"')
143
+ inString = false;
144
+ continue;
145
+ }
146
+ if (c === '"') {
147
+ inString = true;
148
+ continue;
149
+ }
150
+ if (c === '{' || c === '[')
151
+ depth++;
152
+ else if ((c === '}' || c === ']') && --depth === 0)
153
+ return i + 1;
154
+ }
155
+ return line.length;
156
+ }
157
+ //# sourceMappingURL=tokenize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenize.js","sourceRoot":"","sources":["../../src/cli/tokenize.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;;AAQH,4BAEC;AAeD,8BAEC;AAzBD;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,IAAY;IACnC,OAAO,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC;AACnC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,SAAS,CAAC,IAAY,EAAE,CAAS;IAC/C,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AACvB,CAAC;AAED;0DAC0D;AAC1D,SAAS,IAAI,CAAC,IAAY,EAAE,KAAa;IACvC,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,OAAO,GAAG,KAAK,CAAC,CAAC,sDAAsD;IAC3E,IAAI,KAAK,GAAqB,IAAI,CAAC;IAEnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,IAAI,KAAK,KAAK,GAAG,EAAE,CAAC;YACl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C,SAAS;QAAC,CAAC;QAC7C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG;YAAE,KAAK,EAAE,CAAC;aAC/B,IAAI,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,EAAE,KAAK,KAAK,CAAC;YAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,CAAC;AACrB,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @file types.ts
3
+ * @description Shared shapes between the CLI router (main.ts) and the
4
+ * command modules under commands/.
5
+ */
6
+ import type { CliEnv } from './env';
7
+ /** Everything a command receives — commands never touch process.argv/env. */
8
+ export interface CommandContext {
9
+ /** Resolved environment variables (spec v0.03 §2.1). */
10
+ env: CliEnv;
11
+ /** True when `--json` was passed — envelope output, stdout data-only. */
12
+ json: boolean;
13
+ /** Positional args AFTER the command name (e.g. `status 33` → `['33']`). */
14
+ positionals: string[];
15
+ /** Parsed option flags relevant to stage-0 commands. */
16
+ flags: {
17
+ /** `list --mine` — owner-signed listing (needs AGENTIC_PRIVATE_KEY). */
18
+ mine: boolean;
19
+ /** `list --phase <p>` — client-side phase filter. */
20
+ phase?: string;
21
+ };
22
+ }
23
+ /** A command module: one async run(), throws CliError on failure. */
24
+ export type CommandRun = (ctx: CommandContext) => Promise<void>;
25
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/cli/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEpC,6EAA6E;AAC7E,MAAM,WAAW,cAAc;IAC7B,wDAAwD;IACxD,GAAG,EAAE,MAAM,CAAC;IACZ,yEAAyE;IACzE,IAAI,EAAE,OAAO,CAAC;IACd,4EAA4E;IAC5E,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,wDAAwD;IACxD,KAAK,EAAE;QACL,wEAAwE;QACxE,IAAI,EAAE,OAAO,CAAC;QACd,qDAAqD;QACrD,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,qEAAqE;AACrE,MAAM,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ /**
3
+ * @file types.ts
4
+ * @description Shared shapes between the CLI router (main.ts) and the
5
+ * command modules under commands/.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/cli/types.ts"],"names":[],"mappings":";AAAA;;;;GAIG"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * @file constants.ts
3
+ * @description Contract addresses, chain configuration, and ABI hashes for the 0G AgenticID protocol.
4
+ */
5
+ /**
6
+ * 0G testnet (Galileo) chain definition — a viem `Chain` (network metadata:
7
+ * chainId, native currency, RPC, explorer), not a contract address.
8
+ */
9
+ export declare const ZERO_G_TESTNET: {
10
+ readonly id: 16602;
11
+ readonly name: "0G Galileo Testnet";
12
+ readonly nativeCurrency: {
13
+ readonly name: "0G";
14
+ readonly symbol: "0G";
15
+ readonly decimals: 18;
16
+ };
17
+ readonly rpcUrls: {
18
+ readonly default: {
19
+ readonly http: readonly ["https://evmrpc-testnet.0g.ai"];
20
+ };
21
+ };
22
+ readonly blockExplorers: {
23
+ readonly default: {
24
+ readonly name: "0G Scan";
25
+ readonly url: "https://chainscan.0g.ai";
26
+ };
27
+ };
28
+ };
29
+ /**
30
+ * 0G mainnet chain definition — a viem `Chain` (values match viem's
31
+ * `zeroGMainnet`). AgenticID is now deployed on mainnet too (chain 16661);
32
+ * fromAttestor selects this automatically from /config.chain_id.
33
+ */
34
+ export declare const ZERO_G_MAINNET: {
35
+ readonly id: 16661;
36
+ readonly name: "0G Mainnet";
37
+ readonly nativeCurrency: {
38
+ readonly name: "0G";
39
+ readonly symbol: "0G";
40
+ readonly decimals: 18;
41
+ };
42
+ readonly rpcUrls: {
43
+ readonly default: {
44
+ readonly http: readonly ["https://evmrpc.0g.ai"];
45
+ };
46
+ };
47
+ readonly blockExplorers: {
48
+ readonly default: {
49
+ readonly name: "0G BlockChain Explorer";
50
+ readonly url: "https://chainscan.0g.ai";
51
+ };
52
+ };
53
+ };
54
+ /**
55
+ * Contract address set — pass one explicitly to `new AgenticID({ addresses })`.
56
+ *
57
+ * Addresses are a deployment artifact, NOT baked into the SDK: an RPC + these
58
+ * addresses fully determine the target contracts, and keeping them out of the
59
+ * library means it can't drift from what's actually deployed (a proxy upgrade or
60
+ * redeploy would silently stale a bundled constant). Copy the set you target
61
+ * from contracts/DEPLOYMENT.md §6, or load it from your own config/env.
62
+ */
63
+ export interface ContractAddresses {
64
+ /** AgenticID proxy contract address */
65
+ agenticID: `0x${string}`;
66
+ /** TEEDataVerifier proxy contract address */
67
+ teeDataVerifier: `0x${string}`;
68
+ /** VerifiedFeedbackRegistry proxy — TEE marks over the canonical 8004 reputation registry (which is discovered FROM this contract via getCanonicalReputation) */
69
+ verifiedFeedback: `0x${string}`;
70
+ /** FeedbackBatcher — EIP-7702 delegate making giveFeedback+attest atomic.
71
+ * Optional: only advertised on 7702-enabled chains; absent/zero → the SDK
72
+ * uses the sequential two-tx flow. */
73
+ feedbackBatcher?: `0x${string}`;
74
+ /** CloneGate — policy-mode cloning satellite (issue #133). Optional:
75
+ * absent/zero → setCloneAuthorizer/contract-mode clone are unavailable
76
+ * in this environment. */
77
+ cloneGate?: `0x${string}`;
78
+ /** TappRegistry — trust-root acknowledgement (ack) */
79
+ tappRegistry: `0x${string}`;
80
+ /** SandboxServing — prepaid sandbox balance (deposit) */
81
+ sandboxServing: `0x${string}`;
82
+ }
83
+ /**
84
+ * Default RPC URL for the 0G Galileo Testnet (override via `AgenticID({ rpcUrl })`).
85
+ */
86
+ export declare const RPC_URL = "https://evmrpc-testnet.0g.ai";
87
+ /**
88
+ * Chain ID for the 0G Galileo Testnet.
89
+ */
90
+ export declare const CHAIN_ID = 16602;
91
+ /**
92
+ * `waitForTransactionReceipt` options tuned for 0G: receipt availability can lag
93
+ * a few blocks after a tx lands, and the RPC occasionally 404s the tx before it
94
+ * propagates. A generous timeout + retries avoids spurious
95
+ * "transaction receipt could not be found" failures on txs that actually landed.
96
+ */
97
+ export declare const RECEIPT_WAIT: {
98
+ readonly timeout: 120000;
99
+ readonly pollingInterval: 2000;
100
+ readonly checkReplacement: false;
101
+ readonly retryCount: 60;
102
+ readonly retryDelay: 2000;
103
+ };
104
+ /** This SDK's own version. Kept in lockstep with package.json by a test —
105
+ * a runtime package.json read would break browser bundles, so a constant. */
106
+ export declare const SDK_VERSION = "0.2.1";
107
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;CAUjB,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;CAUjB,CAAC;AAEX;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAiB;IAChC,uCAAuC;IACvC,SAAS,EAAE,KAAK,MAAM,EAAE,CAAC;IACzB,6CAA6C;IAC7C,eAAe,EAAE,KAAK,MAAM,EAAE,CAAC;IAC/B,iKAAiK;IACjK,gBAAgB,EAAE,KAAK,MAAM,EAAE,CAAC;IAChC;;2CAEuC;IACvC,eAAe,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IAChC;;+BAE2B;IAC3B,SAAS,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IAC1B,sDAAsD;IACtD,YAAY,EAAE,KAAK,MAAM,EAAE,CAAC;IAC5B,yDAAyD;IACzD,cAAc,EAAE,KAAK,MAAM,EAAE,CAAC;CAC/B;AAED;;GAEG;AACH,eAAO,MAAM,OAAO,iCAAiC,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,QAAQ,QAAQ,CAAC;AAE9B;;;;;GAKG;AACH,eAAO,MAAM,YAAY;;;;;;CAiBf,CAAC;AAEX;8EAC8E;AAC9E,eAAO,MAAM,WAAW,UAAU,CAAC"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ /**
3
+ * @file constants.ts
4
+ * @description Contract addresses, chain configuration, and ABI hashes for the 0G AgenticID protocol.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.SDK_VERSION = exports.RECEIPT_WAIT = exports.CHAIN_ID = exports.RPC_URL = exports.ZERO_G_MAINNET = exports.ZERO_G_TESTNET = void 0;
8
+ /**
9
+ * 0G testnet (Galileo) chain definition — a viem `Chain` (network metadata:
10
+ * chainId, native currency, RPC, explorer), not a contract address.
11
+ */
12
+ exports.ZERO_G_TESTNET = {
13
+ id: 16602,
14
+ name: '0G Galileo Testnet',
15
+ nativeCurrency: { name: '0G', symbol: '0G', decimals: 18 },
16
+ rpcUrls: {
17
+ default: { http: ['https://evmrpc-testnet.0g.ai'] },
18
+ },
19
+ blockExplorers: {
20
+ default: { name: '0G Scan', url: 'https://chainscan.0g.ai' },
21
+ },
22
+ };
23
+ /**
24
+ * 0G mainnet chain definition — a viem `Chain` (values match viem's
25
+ * `zeroGMainnet`). AgenticID is now deployed on mainnet too (chain 16661);
26
+ * fromAttestor selects this automatically from /config.chain_id.
27
+ */
28
+ exports.ZERO_G_MAINNET = {
29
+ id: 16661,
30
+ name: '0G Mainnet',
31
+ nativeCurrency: { name: '0G', symbol: '0G', decimals: 18 },
32
+ rpcUrls: {
33
+ default: { http: ['https://evmrpc.0g.ai'] },
34
+ },
35
+ blockExplorers: {
36
+ default: { name: '0G BlockChain Explorer', url: 'https://chainscan.0g.ai' },
37
+ },
38
+ };
39
+ /**
40
+ * Default RPC URL for the 0G Galileo Testnet (override via `AgenticID({ rpcUrl })`).
41
+ */
42
+ exports.RPC_URL = 'https://evmrpc-testnet.0g.ai';
43
+ /**
44
+ * Chain ID for the 0G Galileo Testnet.
45
+ */
46
+ exports.CHAIN_ID = 16602;
47
+ /**
48
+ * `waitForTransactionReceipt` options tuned for 0G: receipt availability can lag
49
+ * a few blocks after a tx lands, and the RPC occasionally 404s the tx before it
50
+ * propagates. A generous timeout + retries avoids spurious
51
+ * "transaction receipt could not be found" failures on txs that actually landed.
52
+ */
53
+ exports.RECEIPT_WAIT = {
54
+ timeout: 120000,
55
+ pollingInterval: 2000,
56
+ // 0G's load-balanced RPC serves not-found for already-mined txs from
57
+ // lagging nodes. viem's replacement-detection branch is the real hazard:
58
+ // once `getTransaction` succeeds, a later not-found `getTransactionReceipt`
59
+ // no longer takes the retry-tolerant path — it treats the original tx as
60
+ // its own "replacement" and re-fetches the receipt WITH NO RETRY WRAPPER,
61
+ // so a single lagging node rejects the whole wait with a raw
62
+ // TransactionReceiptNotFoundError (retryCount never applies). We don't rely
63
+ // on repriced/cancelled detection, so turn the branch off: a not-found
64
+ // receipt then just waits for the next poll tick until `timeout`.
65
+ checkReplacement: false,
66
+ // Backstop for the plain not-found path (retryCount × retryDelay tolerance),
67
+ // aligned with the overall timeout (60 × 2s = 120s).
68
+ retryCount: 60,
69
+ retryDelay: 2000,
70
+ };
71
+ /** This SDK's own version. Kept in lockstep with package.json by a test —
72
+ * a runtime package.json read would break browser bundles, so a constant. */
73
+ exports.SDK_VERSION = '0.2.1';
74
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;GAGG;AACU,QAAA,cAAc,GAAG;IAC5B,EAAE,EAAE,KAAK;IACT,IAAI,EAAE,oBAAoB;IAC1B,cAAc,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC1D,OAAO,EAAE;QACP,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,8BAA8B,CAAC,EAAE;KACpD;IACD,cAAc,EAAE;QACd,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,yBAAyB,EAAE;KAC7D;CACO,CAAC;AAEX;;;;GAIG;AACU,QAAA,cAAc,GAAG;IAC5B,EAAE,EAAE,KAAK;IACT,IAAI,EAAE,YAAY;IAClB,cAAc,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC1D,OAAO,EAAE;QACP,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,sBAAsB,CAAC,EAAE;KAC5C;IACD,cAAc,EAAE;QACd,OAAO,EAAE,EAAE,IAAI,EAAE,wBAAwB,EAAE,GAAG,EAAE,yBAAyB,EAAE;KAC5E;CACO,CAAC;AAgCX;;GAEG;AACU,QAAA,OAAO,GAAG,8BAA8B,CAAC;AAEtD;;GAEG;AACU,QAAA,QAAQ,GAAG,KAAK,CAAC;AAE9B;;;;;GAKG;AACU,QAAA,YAAY,GAAG;IAC1B,OAAO,EAAE,MAAO;IAChB,eAAe,EAAE,IAAK;IACtB,qEAAqE;IACrE,yEAAyE;IACzE,4EAA4E;IAC5E,yEAAyE;IACzE,0EAA0E;IAC1E,6DAA6D;IAC7D,4EAA4E;IAC5E,uEAAuE;IACvE,kEAAkE;IAClE,gBAAgB,EAAE,KAAK;IACvB,6EAA6E;IAC7E,qDAAqD;IACrD,UAAU,EAAE,EAAE;IACd,UAAU,EAAE,IAAK;CACT,CAAC;AAEX;8EAC8E;AACjE,QAAA,WAAW,GAAG,OAAO,CAAC"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * @file context.ts
3
+ * @description Shared config + runtime context for the AgenticID facade and its
4
+ * internal per-contract clients. Constructed once; passed to each sub-client.
5
+ */
6
+ import { type Account, type Chain, type PublicClient, type WalletClient } from 'viem';
7
+ import { type ContractAddresses } from './constants';
8
+ /** Public config for `new AgenticID(config)`. */
9
+ export interface AgenticIDConfig {
10
+ /** RPC endpoint. Defaults to the 0G Galileo testnet RPC. */
11
+ rpcUrl?: string;
12
+ /** viem chain. Defaults to 0G Galileo (chainId 16602). */
13
+ chain?: Chain;
14
+ /** Contract addresses — required; passed explicitly (from DEPLOYMENT.md §6 / your config). */
15
+ addresses: ContractAddresses;
16
+ /** Attestor base URL — required for agent.deploy / agent.clone. */
17
+ attestorUrl?: string;
18
+ /**
19
+ * Signer for writes. A private key (`0x…`) or a viem `Account`. When set, the
20
+ * SDK builds the wallet client for you from the rpcUrl + chain — you don't
21
+ * need to construct one. Omit for a read-only client.
22
+ */
23
+ account?: Account | `0x${string}`;
24
+ /**
25
+ * Bring-your-own wallet client (e.g. an injected browser wallet). Optional —
26
+ * usually you just pass `account`. When set, its account is used for writes.
27
+ */
28
+ walletClient?: WalletClient;
29
+ /**
30
+ * Trust-root component appIds acknowledged by `sandbox.ack()`. Defaults to
31
+ * the standard set (attestor / kms / sandbox provider).
32
+ */
33
+ componentAppIds?: string[];
34
+ /**
35
+ * Sticky memory for the secret-env scheme (issue #166): once an attestor
36
+ * has advertised `secret_env_scheme`, its later absence is treated as
37
+ * tampering and refused (`scheme_withdrawn`) rather than silently falling
38
+ * back to a clear-text key. Every client remembers within its own
39
+ * lifetime; supply this store to remember across processes (the CLI backs
40
+ * it with a file). `seen` answers whether the URL ever advertised the
41
+ * scheme; `record` is called when it does.
42
+ */
43
+ secretEnvPin?: {
44
+ seen(attestorUrl: string): boolean | Promise<boolean>;
45
+ record(attestorUrl: string): void | Promise<void>;
46
+ };
47
+ }
48
+ /** The slice of the attestor's GET /config the SDK auto-configures from. */
49
+ export interface AttestorPublicConfig {
50
+ attestor_app_id?: string;
51
+ kms_app_id?: string;
52
+ sandbox_app_id?: string;
53
+ sandbox_endpoint?: string;
54
+ sandbox_provider_addr?: `0x${string}`;
55
+ sandbox_serving_addr?: `0x${string}`;
56
+ /** Default sealed image when a framework declares none. */
57
+ sandbox_snapshot?: string;
58
+ /** Selectable frameworks + the sealed image each needs (`image` omitted →
59
+ * `sandbox_snapshot`). The SDK resolves a deploy's image from here. */
60
+ frameworks?: Array<{
61
+ name: string;
62
+ image?: string;
63
+ }>;
64
+ /** Present when this attestor's sealed images open a sealed secret env
65
+ * (`'agent-seal-ecies-v1'`, issue #166): start/reset/retry then seal the
66
+ * inference key to the agent instead of signing it in clear. */
67
+ secret_env_scheme?: string;
68
+ inference_capabilities?: Array<{
69
+ image: string;
70
+ providers: string[];
71
+ secret_env_versions: number[];
72
+ formats?: string[];
73
+ }>;
74
+ provider_registry_schema?: number;
75
+ provider_registry_version?: number;
76
+ provider_registry_digest?: string;
77
+ }
78
+ /** Resolved context shared by the internal clients. */
79
+ export interface Ctx {
80
+ publicClient: PublicClient;
81
+ walletClient?: WalletClient;
82
+ account?: Account;
83
+ chain: Chain;
84
+ addresses: ContractAddresses;
85
+ attestorUrl?: string;
86
+ componentAppIds: string[];
87
+ /** True when the caller passed componentAppIds explicitly — explicit
88
+ * config always beats the attestor /config auto-discovery. */
89
+ componentAppIdsExplicit: boolean;
90
+ /** Lazy, cached fetch of the attestor's GET /config (null when no
91
+ * attestorUrl is configured or the fetch fails). Environment-specific
92
+ * values (component appIds, sandbox provider) default from here so
93
+ * callers don't hand-copy them per deployment — the hardcoded-default
94
+ * footgun that made ack() revert "app not found" on non-prod envs. */
95
+ attestorConfig: () => Promise<AttestorPublicConfig | null>;
96
+ /** See {@link AgenticIDConfig.secretEnvPin}. */
97
+ secretEnvPin?: {
98
+ seen(attestorUrl: string): boolean | Promise<boolean>;
99
+ record(attestorUrl: string): void | Promise<void>;
100
+ };
101
+ }
102
+ export declare function buildCtx(config: AgenticIDConfig): Ctx;
103
+ /** Guard used by write methods. */
104
+ export declare function requireWallet(ctx: Ctx): {
105
+ walletClient: WalletClient;
106
+ account: Account;
107
+ };
108
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,MAAM,CAAC;AAEd,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE9E,iDAAiD;AACjD,MAAM,WAAW,eAAe;IAC9B,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0DAA0D;IAC1D,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,8FAA8F;IAC9F,SAAS,EAAE,iBAAiB,CAAC;IAC7B,mEAAmE;IACnE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,KAAK,MAAM,EAAE,CAAC;IAClC;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE;QACb,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;QACtD,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KACnD,CAAC;CACH;AAED,4EAA4E;AAC5E,MAAM,WAAW,oBAAoB;IACnC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qBAAqB,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IACtC,oBAAoB,CAAC,EAAE,KAAK,M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AgB,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,GAAG,CA2CrD;AAED,mCAAmC;AACnC,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG;IAAE,YAAY,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAKxF"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ /**
3
+ * @file context.ts
4
+ * @description Shared config + runtime context for the AgenticID facade and its
5
+ * internal per-contract clients. Constructed once; passed to each sub-client.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.buildCtx = buildCtx;
9
+ exports.requireWallet = requireWallet;
10
+ const viem_1 = require("viem");
11
+ const accounts_1 = require("viem/accounts");
12
+ const constants_1 = require("./constants");
13
+ const DEFAULT_COMPONENT_APP_IDS = ['0g-attestor', '0g-kms', '0g-sandbox-provider'];
14
+ function buildCtx(config) {
15
+ const chain = (config.chain ?? constants_1.ZERO_G_TESTNET);
16
+ const rpcUrl = config.rpcUrl ?? constants_1.RPC_URL;
17
+ // Resolve the signer + wallet client. A bring-your-own walletClient wins; else
18
+ // build one from `account` (a private key string or a viem Account) — so the
19
+ // caller only needs to supply an RPC + a key, not a hand-built viem client.
20
+ let account;
21
+ let walletClient;
22
+ if (config.walletClient) {
23
+ walletClient = config.walletClient;
24
+ account =
25
+ config.walletClient.account ??
26
+ (typeof config.account === 'string' ? (0, accounts_1.privateKeyToAccount)(config.account) : config.account);
27
+ }
28
+ else if (config.account) {
29
+ account = typeof config.account === 'string' ? (0, accounts_1.privateKeyToAccount)(config.account) : config.account;
30
+ walletClient = (0, viem_1.createWalletClient)({ account, chain, transport: (0, viem_1.http)(rpcUrl) });
31
+ }
32
+ // One shared, memoized /config fetch per Ctx. Failure memoizes null —
33
+ // callers fall back to explicit config / built-in defaults.
34
+ let cfgPromise;
35
+ const attestorUrl = config.attestorUrl?.replace(/\/$/, '');
36
+ const attestorConfig = () => {
37
+ if (!attestorUrl)
38
+ return Promise.resolve(null);
39
+ cfgPromise ?? (cfgPromise = fetch(`${attestorUrl}/config`)
40
+ .then((r) => (r.ok ? r.json() : null))
41
+ .catch(() => null));
42
+ return cfgPromise;
43
+ };
44
+ return {
45
+ chain,
46
+ addresses: config.addresses,
47
+ attestorUrl: config.attestorUrl,
48
+ walletClient,
49
+ account,
50
+ componentAppIds: config.componentAppIds ?? DEFAULT_COMPONENT_APP_IDS,
51
+ componentAppIdsExplicit: config.componentAppIds !== undefined,
52
+ attestorConfig,
53
+ secretEnvPin: config.secretEnvPin,
54
+ publicClient: (0, viem_1.createPublicClient)({ chain, transport: (0, viem_1.http)(rpcUrl) }),
55
+ };
56
+ }
57
+ /** Guard used by write methods. */
58
+ function requireWallet(ctx) {
59
+ if (!ctx.walletClient || !ctx.account) {
60
+ throw new Error('a walletClient + account are required for write operations');
61
+ }
62
+ return { walletClient: ctx.walletClient, account: ctx.account };
63
+ }
64
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAyGH,4BA2CC;AAGD,sCAKC;AA1JD,+BAQc;AACd,4CAAoD;AACpD,2CAA8E;AA2F9E,MAAM,yBAAyB,GAAG,CAAC,aAAa,EAAE,QAAQ,EAAE,qBAAqB,CAAC,CAAC;AAEnF,SAAgB,QAAQ,CAAC,MAAuB;IAC9C,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,0BAAc,CAAU,CAAC;IACxD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,mBAAO,CAAC;IAExC,+EAA+E;IAC/E,6EAA6E;IAC7E,4EAA4E;IAC5E,IAAI,OAA4B,CAAC;IACjC,IAAI,YAAsC,CAAC;IAC3C,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;QACxB,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;QACnC,OAAO;YACL,MAAM,CAAC,YAAY,CAA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Ae,EAAE,MAAM,CAAC,eAAe,IAAI,yBAAyB;QACpE,uBAAuB,EAAE,MAAM,CAAC,eAAe,KAAK,SAAS;QAC7D,cAAc;QACd,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,YAAY,EAAE,IAAA,yBAAkB,EAAC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAA,WAAI,EAAC,MAAM,CAAC,EAAE,CAAC;KACrE,CAAC;AACJ,CAAC;AAED,mCAAmC;AACnC,SAAgB,aAAa,CAAC,GAAQ;IACpC,IAAI,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAChF,CAAC;IACD,OAAO,EAAE,YAAY,EAAE,GAAG,CAAC,YAAY,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;AAClE,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @file index.ts
3
+ * @description Entry point for 0g-agentdna.
4
+ *
5
+ * One facade (`AgentDNA`; legacy alias `AgenticID`): intent namespaces — `agent` (lifecycle:
6
+ * deploy/clone/transfer + reads + agent-seal gas) and `reputation` (serve-proof
7
+ * + feedback), and `admin` (attestor-wide provider publication) — plus top-level `ack`/`ackStatus` (trust roots) and
8
+ * `deposit`/`getBalance` (sandbox balance). Construct once with rpc + addresses.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { AgentDNA } from '@0gfoundation/0g-agentdna';
13
+ * const ag = new AgentDNA({ addresses, account }); // addresses from DEPLOYMENT.md §6 / your config
14
+ * ```
15
+ */
16
+ export { AgenticID as AgentDNA, AgenticID, AgentApi, AdminApi, ReputationApi } from './AgenticID';
17
+ export type { DeployAccepted, WaitLevel } from './AgenticID';
18
+ export { makeAgentClient } from './AgentClient';
19
+ export type { AgentClient, AgentServiceEntry, AgentRoute, ChatMessage, ChatCompletion, AgentTask } from './AgentClient';
20
+ export { mcpServices } from './AgentClient';
21
+ export { defaultIData } from './AttestorClient';
22
+ export type { DefaultIDataParams } from './AttestorClient';
23
+ export type { AgenticIDConfig as AgentDNAConfig, AgenticIDConfig } from './context';
24
+ export { SandboxClient } from './SandboxClient';
25
+ export { AgenticIDClient } from './AgenticIDClient';
26
+ export type { IntelligentDataResult } from './AgenticIDClient';
27
+ export { ReputationClient, MAX_ABS_FEEDBACK_VALUE } from './ReputationClient';
28
+ export { AttestorClient, CLONE_DOMAIN, CLONE_CONTRACT_DOMAIN, DEPLOY_DOMAIN, b64encode } from './AttestorClient';
29
+ export type { CloneParams, DeployParams, IDataInput, DeployCloneResponse } from './AttestorClient';
30
+ export { SECRET_ENV_SCHEME, SECRET_ENV_VAR, SecretEnvRefusedError, sealSecretEnv } from './secretEnv';
31
+ export type { SecretEnvMode, SecretEnvRefusalCode } from './secretEnv';
32
+ export { SETTINGS_DOMAIN, THINKING_LEVELS, SETTINGS_FIELDS, ZG_COMPUTE_PROVIDER, ROUTER_MODELS_URL, canonicalSettings, settingsAuthMessage, SettingsConflictError, sha256Hex, modelAdvisory, fetchRouterModelIds, } from './Settings';
33
+ export type { SettingsDoc, ThinkingLevel } from './Settings';
34
+ export { ServeSession, SERVE_PROOF_HEADER, parseServeProofHeader, proofFromResponse, captureProof, taskRevealOf, proofRecordingFetch, } from './ServeSession';
35
+ export type { ServeSessionOptions, ProofVerification, TaskExchange } from './ServeSession';
36
+ export { buildServeProofMessageHash, buildServeProofSigningHash, buildServeProof, signServeProof, verifyServeProofSignature, } from './ServeProof';
37
+ export type { BuildServeProofHashParams, BuildServeProofSigningHashParams } from './ServeProof';
38
+ export { taskHashOf, requestUriOf, requestUriCandidates } from './taskHash';
39
+ export type { IntelligentData, ServeProof, Feedback, FeedbackSummary, ServeData, GiveFeedbackParams, GiveFeedbackResult, TaskReveal, AppendResponseParams, ReadAllFeedbackParams, GetSummaryParams, } from './types';
40
+ export { ZERO_G_TESTNET, ZERO_G_MAINNET, RPC_URL, CHAIN_ID, RECEIPT_WAIT, } from './constants';
41
+ export type { ContractAddresses } from './constants';
42
+ export { agenticIDAbi, cloneGateAbi, standardCloneAuthorizerAbi, canonicalReputationAbi, verifiedFeedbackAbi, feedbackBatcherAbi, tappRegistryAbi, sandboxServingAbi, } from './abi';
43
+ export { listInferenceProviders, inferenceProvider, routeHash } from './Providers';
44
+ export type { InferenceProvider, InferenceFormat, InferenceModel, ProviderRegistrySnapshot, ProviderRegistryPin } from './Providers';
45
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAcH,OAAO,EAAE,SAAS,IAAI,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAClG,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACxH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,YAAY,EAAE,eAAe,IAAI,cAAc,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAGpF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,cAAc,EA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