@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,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deployWithInference = deployWithInference;
4
+ exports.configuredInferenceKey = configuredInferenceKey;
5
+ exports.requireConfiguredInferenceKey = requireConfiguredInferenceKey;
6
+ exports.agentInferenceProvider = agentInferenceProvider;
7
+ exports.requiresProviderReset = requiresProviderReset;
8
+ const config_1 = require("./config");
9
+ const errors_1 = require("./errors");
10
+ const Providers_1 = require("../Providers");
11
+ /** Deploy using the current registry's routing requirements. Called after
12
+ * the wizard's prompts/preflight so an edited compute route is rechecked. */
13
+ async function deployWithInference(ag, params) {
14
+ const definition = (await ag.agent.refreshProviders()).find((p) => p.id === params.provider);
15
+ if (!definition)
16
+ throw new errors_1.CliError('INFERENCE_PROVIDER_UNSUPPORTED', `unknown provider: ${params.provider}`);
17
+ const mintFirst = (0, Providers_1.requiresMintFirst)(definition);
18
+ await ag.agent.assertProviderSupported(params.provider, { framework: params.framework });
19
+ const deployment = await ag.agent.deploy({
20
+ name: params.name,
21
+ description: 'deployed from 0g-agentdna',
22
+ framework: params.framework,
23
+ inference: { provider: params.provider, model: params.model },
24
+ ...(params.provision && !mintFirst ? { sandbox: { apiKey: params.apiKey } } : {}),
25
+ });
26
+ const mint = await ag.agent.waitForMint(deployment.sealId, { timeoutMs: 180000 });
27
+ if (mintFirst) {
28
+ await ag.agent.setSettings(deployment.sealId, { provider: params.provider, model: params.model }, { baseVersion: 0 });
29
+ if (params.provision)
30
+ await ag.agent.start(deployment.sealId, {
31
+ provider: params.provider, framework: params.framework, apiKey: params.apiKey, secretEnv: 'sealed',
32
+ });
33
+ }
34
+ return { deployment, agentId: String(mint.agentId ?? mint) };
35
+ }
36
+ function configuredInferenceKey(provider, env = process.env) {
37
+ if (!/^[a-z0-9][a-z0-9-]{0,63}$/.test(provider))
38
+ throw new errors_1.CliError('BAD_FLAG', 'invalid inference provider ID');
39
+ return (0, config_1.inferenceKeyFromEnv)(provider, env) || (0, config_1.loadApiKey)(provider, env);
40
+ }
41
+ function requireConfiguredInferenceKey(provider, env = process.env) {
42
+ const key = configuredInferenceKey(provider, env);
43
+ if (!key)
44
+ throw new errors_1.CliError('INFERENCE_KEY_REQUIRED', `no API key registered for ${provider}`, {
45
+ remedy: `run login and register the ${provider} key, then repeat the command`,
46
+ });
47
+ return key;
48
+ }
49
+ /** A failed owner settings read must not select a different provider or key. */
50
+ async function agentInferenceProvider(ag, sealId) {
51
+ const { settings } = await ag.agent.getSettings(sealId);
52
+ const provider = settings?.provider ?? '0g-compute';
53
+ if (!/^[a-z0-9][a-z0-9-]{0,63}$/.test(provider))
54
+ throw new errors_1.CliError('BAD_FLAG', 'invalid inference provider ID');
55
+ return provider;
56
+ }
57
+ function requiresProviderReset(error) {
58
+ return /CREDENTIAL_PROVIDER_MISMATCH|CREDENTIAL_ROUTE_MISMATCH|PROVIDER_BOUND_CREDENTIAL_REQUIRED/.test(error instanceof Error ? error.message : String(error));
59
+ }
60
+ //# sourceMappingURL=inference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inference.js","sourceRoot":"","sources":["../../src/cli/inference.ts"],"names":[],"mappings":";;AAQA,kDAuBC;AAED,wDAGC;AAED,sEAMC;AAGD,wDAKC;AAED,sDAEC;AAtDD,qCAA2D;AAC3D,qCAAoC;AACpC,4CAAiD;AAEjD;6EAC6E;AACtE,KAAK,UAAU,mBAAmB,CAAC,EAAa,EAAE,MAGxD;IACC,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC7F,IAAI,CAAC,UAAU;QAAE,MAAM,IAAI,iBAAQ,CAAC,gCAAgC,EAAE,qBAAqB,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC9G,MAAM,SAAS,GAAG,IAAA,6BAAiB,EAAC,UAAU,CAAC,CAAC;IAChD,MAAM,EAAE,CAAC,KAAK,CAAC,uBAAuB,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;IACzF,MAAM,UAAU,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC;QACvC,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,WAAW,EAAE,2BAA2B;QACxC,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,SAAS,EAAE,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AC,QAAQ,EAAE,GAAG,CAAC,IAAI,IAAA,mBAAU,EAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;AACzE,CAAC;AAED,SAAgB,6BAA6B,CAAC,QAAgB,EAAE,MAAyB,OAAO,CAAC,GAAG;IAClG,MAAM,GAAG,GAAG,sBAAsB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAClD,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,iBAAQ,CAAC,wBAAwB,EAAE,6BAA6B,QAAQ,EAAE,EAAE;YAC9F,MAAM,EAAE,8BAA8B,QAAQ,+BAA+B;SAC9E,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACb,CAAC;AAED,gFAAgF;AACzE,KAAK,UAAU,sBAAsB,CAAC,EAAa,EAAE,MAAY;IACtE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACxD,MAAM,QAAQ,GAAG,QAAQ,EAAE,QAAQ,IAAI,YAAY,CAAC;IACpD,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,QAAQ,CAAC;QAAE,MAAM,IAAI,iBAAQ,CAAC,UAAU,EAAE,+BAA+B,CAAC,CAAC;IACjH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAgB,qBAAqB,CAAC,KAAc;IAClD,OAAO,2FAA2F,CAAC,IAAI,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAClK,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @file logo.ts
3
+ * @description Splash logo for the interactive shell: the panda (with
4
+ * bamboo) from the deterministic avatar generator — a faithful pixel port
5
+ * of `gen_panda` in attestor/crates/shared/src/avatar.rs ("Pretty SHA").
6
+ * Fixed pixels and colors here: this is the shell's mascot, not a
7
+ * seed-derived identity avatar.
8
+ *
9
+ * Rendered with half-block characters (▀/▄, two pixel rows per text
10
+ * line) in 256-color ANSI → 16 columns × 8 lines. Callers must gate on
11
+ * TTY/NO_COLOR and fall back to a plain banner.
12
+ */
13
+ /**
14
+ * Render a Pretty-SHA avatar SVG (the attestor's /avatar/:seed.svg — a
15
+ * 16×16 background rect plus 1×1 pixel rects) as 8 ANSI-256 half-block
16
+ * lines. Returns null when the SVG doesn't look like one.
17
+ */
18
+ export declare function svgPixelLines(svg: string): string[] | null;
19
+ /** The panda as 8 ANSI lines (each ends reset, no trailing newline). */
20
+ export declare function pandaLines(): string[];
21
+ //# sourceMappingURL=logo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logo.d.ts","sourceRoot":"","sources":["../../src/cli/logo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAmEH;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAoB1D;AAOD,wEAAwE;AACxE,wBAAgB,UAAU,IAAI,MAAM,EAAE,CAarC"}
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ /**
3
+ * @file logo.ts
4
+ * @description Splash logo for the interactive shell: the panda (with
5
+ * bamboo) from the deterministic avatar generator — a faithful pixel port
6
+ * of `gen_panda` in attestor/crates/shared/src/avatar.rs ("Pretty SHA").
7
+ * Fixed pixels and colors here: this is the shell's mascot, not a
8
+ * seed-derived identity avatar.
9
+ *
10
+ * Rendered with half-block characters (▀/▄, two pixel rows per text
11
+ * line) in 256-color ANSI → 16 columns × 8 lines. Callers must gate on
12
+ * TTY/NO_COLOR and fall back to a plain banner.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.svgPixelLines = svgPixelLines;
16
+ exports.pandaLines = pandaLines;
17
+ const GS = 16;
18
+ /** avatar.rs palette indexes used by the panda, mapped to ANSI-256. */
19
+ const ANSI256 = {
20
+ 0: 71, // bamboo (avatar.rs "body" slot; green here)
21
+ 3: 236, // shadow — the panda's black
22
+ 5: 231, // white
23
+ 7: 217, // soft — cheeks / paw pads
24
+ };
25
+ function pandaGrid() {
26
+ const g = Array.from({ length: GS }, () => Array(GS).fill(null));
27
+ const sp = (c, r, v) => {
28
+ if (r >= 0 && r < GS && c >= 0 && c < GS)
29
+ g[r][c] = v;
30
+ };
31
+ const fr = (c, r, w, h, v) => {
32
+ for (let i = r; i < r + h; i++)
33
+ for (let j = c; j < c + w; j++)
34
+ sp(j, i, v);
35
+ };
36
+ // gen_panda, verbatim (with_bamboo = true).
37
+ fr(3, 1, 3, 2, 3);
38
+ fr(10, 1, 3, 2, 3);
39
+ fr(2, 2, 12, 7, 5);
40
+ fr(4, 3, 8, 5, 7);
41
+ fr(3, 3, 4, 3, 3);
42
+ fr(9, 3, 4, 3, 3);
43
+ sp(5, 4, 5);
44
+ sp(6, 4, 3);
45
+ sp(9, 4, 5);
46
+ sp(10, 4, 3);
47
+ fr(6, 7, 2, 1, 3);
48
+ fr(7, 8, 2, 1, 3);
49
+ sp(6, 9, 3);
50
+ sp(7, 9, 3);
51
+ sp(8, 9, 3);
52
+ sp(9, 9, 3);
53
+ fr(2, 9, 12, 6, 5);
54
+ fr(2, 10, 2, 4, 3);
55
+ fr(12, 10, 2, 4, 3);
56
+ fr(3, 14, 4, 2, 3);
57
+ fr(9, 14, 4, 2, 3);
58
+ sp(3, 15, 7);
59
+ sp(4, 15, 7);
60
+ sp(9, 15, 7);
61
+ sp(10, 15, 7);
62
+ fr(0, 5, 2, 10, 0);
63
+ sp(0, 7, 3);
64
+ sp(0, 9, 3);
65
+ sp(0, 11, 3);
66
+ sp(0, 13, 3);
67
+ sp(2, 11, 3);
68
+ sp(3, 12, 3);
69
+ return g;
70
+ }
71
+ /** Nearest xterm-256 color-cube index for a #rrggbb hex — the same plain
72
+ * 256-color escapes the panda uses, so no truecolor dependency anywhere. */
73
+ function hexTo256(h) {
74
+ const lvl = (v) => (v < 48 ? 0 : v < 115 ? 1 : Math.min(5, Math.round((v - 35) / 40)));
75
+ const r = lvl(parseInt(h.slice(1, 3), 16));
76
+ const g = lvl(parseInt(h.slice(3, 5), 16));
77
+ const b = lvl(parseInt(h.slice(5, 7), 16));
78
+ return 16 + 36 * r + 6 * g + b;
79
+ }
80
+ /**
81
+ * Render a Pretty-SHA avatar SVG (the attestor's /avatar/:seed.svg — a
82
+ * 16×16 background rect plus 1×1 pixel rects) as 8 ANSI-256 half-block
83
+ * lines. Returns null when the SVG doesn't look like one.
84
+ */
85
+ function svgPixelLines(svg) {
86
+ const bg = svg.match(/<rect width="16" height="16" fill="(#[0-9a-fA-F]{6})"\/>/);
87
+ if (!bg)
88
+ return null;
89
+ const grid = Array.from({ length: GS }, () => Array(GS).fill(bg[1]));
90
+ const re = /<rect x="(\d+)" y="(\d+)" width="1" height="1" fill="(#[0-9a-fA-F]{6})"\/>/g;
91
+ let m;
92
+ let n = 0;
93
+ while ((m = re.exec(svg))) {
94
+ const x = Number(m[1]);
95
+ const y = Number(m[2]);
96
+ if (x < GS && y < GS) {
97
+ grid[y][x] = m[3];
98
+ n++;
99
+ }
100
+ }
101
+ if (!n)
102
+ return null;
103
+ const lines = [];
104
+ for (let r = 0; r < GS; r += 2) {
105
+ let line = '';
106
+ for (let c = 0; c < GS; c++)
107
+ line += `\x1b[38;5;${hexTo256(grid[r][c])}m\x1b[48;5;${hexTo256(grid[r + 1][c])}m▀`;
108
+ lines.push(`${line}\x1b[0m`);
109
+ }
110
+ return lines;
111
+ }
112
+ /** Splash background tile — the light tint a real Pretty-SHA avatar gets
113
+ * (make_bg lands around L=0.92), so the panda renders as the same solid
114
+ * 16×8 tile the agent avatars do. */
115
+ const SPLASH_BG = 254;
116
+ /** The panda as 8 ANSI lines (each ends reset, no trailing newline). */
117
+ function pandaLines() {
118
+ const g = pandaGrid();
119
+ const lines = [];
120
+ for (let r = 0; r < GS; r += 2) {
121
+ let line = '';
122
+ for (let c = 0; c < GS; c++) {
123
+ const top = g[r][c] != null ? ANSI256[g[r][c]] : SPLASH_BG;
124
+ const bot = g[r + 1][c] != null ? ANSI256[g[r + 1][c]] : SPLASH_BG;
125
+ line += `\x1b[38;5;${top}m\x1b[48;5;${bot}m▀`;
126
+ }
127
+ lines.push(`${line}\x1b[0m`);
128
+ }
129
+ return lines;
130
+ }
131
+ //# sourceMappingURL=logo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logo.js","sourceRoot":"","sources":["../../src/cli/logo.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AAwEH,sCAoBC;AAQD,gCAaC;AA/GD,MAAM,EAAE,GAAG,EAAE,CAAC;AAGd,uEAAuE;AACvE,MAAM,OAAO,GAA2B;IACtC,CAAC,EAAE,EAAE,EAAE,6CAA6C;IACpD,CAAC,EAAE,GAAG,EAAE,6BAA6B;IACrC,CAAC,EAAE,GAAG,EAAE,QAAQ;IAChB,CAAC,EAAE,GAAG,EAAE,2BAA2B;CACpC,CAAC;AAEF,SAAS,SAAS;IAChB,MAAM,CAAC,GAAS,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,KAAK,CAAgB,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACtF,MAAM,EAAE,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,EAAE;QAC7C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE;YAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACxD,CAAC,CAAC;IACF,MAAM,EAAE,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,EAAE;QACnE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE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AC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/B,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5B,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACrE,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YAC7E,IAAI,IAAI,aAAa,GAAG,cAAc,GAAG,IAAI,CAAC;QAChD,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,SAAS,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @file main.ts
4
+ * @description Entry point of `0g-agentdna` — the diagnostics CLI that ships
5
+ * inside @0gfoundation/0g-agentdna (`bin` in package.json; no extra install,
6
+ * no extra deps — arg parsing is node:util's parseArgs).
7
+ *
8
+ * This file owns: argv parsing, command routing, `--help`/`--version`, and
9
+ * the single error boundary that turns any thrown CliError into the
10
+ * envelope/exit-code contract (spec v0.03 §2.2–2.3). Commands own everything
11
+ * else and never touch process.argv or process.exit.
12
+ */
13
+ export {};
14
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG"}
@@ -0,0 +1,223 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * @file main.ts
5
+ * @description Entry point of `0g-agentdna` — the diagnostics CLI that ships
6
+ * inside @0gfoundation/0g-agentdna (`bin` in package.json; no extra install,
7
+ * no extra deps — arg parsing is node:util's parseArgs).
8
+ *
9
+ * This file owns: argv parsing, command routing, `--help`/`--version`, and
10
+ * the single error boundary that turns any thrown CliError into the
11
+ * envelope/exit-code contract (spec v0.03 §2.2–2.3). Commands own everything
12
+ * else and never touch process.argv or process.exit.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const node_util_1 = require("node:util");
16
+ const node_fs_1 = require("node:fs");
17
+ const node_path_1 = require("node:path");
18
+ const errors_1 = require("./errors");
19
+ const envelope_1 = require("./envelope");
20
+ const env_1 = require("./env");
21
+ const doctor_1 = require("./commands/doctor");
22
+ const status_1 = require("./commands/status");
23
+ const list_1 = require("./commands/list");
24
+ const update_1 = require("./commands/update");
25
+ const settings_1 = require("./commands/settings");
26
+ const providers_1 = require("./commands/providers");
27
+ const interactive_1 = require("./commands/interactive");
28
+ /** Diagnostics subcommands. Anything else (bare, or a leading agent ref)
29
+ * routes to the default interactive shell. */
30
+ const COMMANDS = { doctor: doctor_1.run, status: status_1.run, list: list_1.run, update: update_1.run, settings: settings_1.run, providers: providers_1.run };
31
+ // Help is written for LLM consumption as much as for humans: exact syntax,
32
+ // env contract, exit-code semantics, runnable examples — it is the ground
33
+ // truth an agent plans against (spec v0.03 §2.4).
34
+ const HELP = `0g-agentdna — 0G AgentDNA CLI for the AgenticID protocol
35
+ (ships with @0gfoundation/0g-agentdna; no separate install)
36
+
37
+ USAGE
38
+ 0g-agentdna [agent] [options] interactive chat (default)
39
+ 0g-agentdna <command> [options] diagnostics
40
+
41
+ INTERACTIVE (default — no command)
42
+ 0g-agentdna Open the manager REPL. Its commands:
43
+ list agents on this attestor (* = yours)
44
+ use <agentId|seal> enter YOUR agent's session, in
45
+ ANY phase (lifecycle is inside)
46
+ hello <agentId|seal> any agent's public /hello
47
+ (identity + services + proof;
48
+ banks a rating ticket if a
49
+ wallet is configured)
50
+ call <id> [path] use an agent's service (banks
51
+ a rating ticket)
52
+ rate <id> [score] rate an agent on-chain, spending
53
+ a ticket from call/hello (<1h)
54
+ deploy new-agent wizard, then chat
55
+ start/stop/reset <id> lifecycle without entering
56
+ the session (reset asks the
57
+ framework + key)
58
+ settings <id> [k=v] show/change the agent's
59
+ configuration document
60
+ balance prepaid balance + burn rate
61
+ deposit [og] fund the prepaid balance
62
+ withdraw [og] refund prepaid funds (time-
63
+ locked; bare claims)
64
+ ack acknowledge the TEE trust
65
+ root (implicit in deploy/
66
+ start/reset)
67
+ login guided setup: attestor URL,
68
+ owner key, provider, inference key (Enter
69
+ keeps current; keys echo *)
70
+ whoami · help · quit
71
+ 0g-agentdna <agent> Shortcut: use that agent directly, then drop to
72
+ the manager REPL on /back.
73
+
74
+ In a session: type to talk; Esc / Ctrl-C interrupts
75
+ the turn in flight (and cancels a /start or /reset
76
+ wait). Slash: /hello /balance /topup [og] /stop
77
+ /start /reset /settings [k=v] /agentlog [n]
78
+ /startuplog [n] /back (or /unuse) /quit. The framework (for /reset
79
+ and the chat model selector) is picked by you, never
80
+ guessed. Config persists to ~/.config/0g-agentdna
81
+ (config.json + credentials at 0600); AGENTIC_* env
82
+ vars always override the files.
83
+
84
+ COMMANDS
85
+ doctor Check every deploy prerequisite (attestor reachable, RPC,
86
+ wallet, gas, trust-root ack, sandbox balance). Each failing
87
+ item prints a remedy. Exit 0 all green; exit 3 otherwise,
88
+ carrying the FIRST failing check's code. Diagnostics only:
89
+ the ack/deposit remedies are transactions (they need gas)
90
+ executed via the deploy console or the SDK, not this CLI.
91
+ status <agent> One agent's full picture: phase, agentId/sealId/agentSeal,
92
+ url, failure reason. <agent> is a decimal agentId (33) or a
93
+ 0x… sealId — the CLI converts between them for you.
94
+ list List deployments. --mine (owner-signed, needs
95
+ AGENTIC_PRIVATE_KEY) adds owner-only fields such as the
96
+ failure reason and sandboxId.
97
+ settings <agent> [k=v …]
98
+ Show the agent's configuration document (which model it
99
+ thinks with, and how hard); with key=value assignments,
100
+ change it. Keys: provider, model, thinking (low|high|max),
101
+ others (opaque JSON for that framework's own knobs —
102
+ quote it: others='{"a": 1}'). Assignments merge into the
103
+ stored document; an empty value (thinking=) clears a field.
104
+ The document is the owner's, so BOTH reading and writing
105
+ are owner-signed and need AGENTIC_PRIVATE_KEY. A write is a
106
+ compare-and-swap against the version just read: if another
107
+ client changed the document meanwhile, it is refused (exit
108
+ 3, SETTINGS_CONFLICT) rather than overwriting them. The
109
+ model advisory uses its provider catalog. Provider changes
110
+ need a matching key and image support, then require reset.
111
+ providers Read the platform provider registry (--json for export).
112
+ update Self-update: compare against the npm registry and
113
+ npm install -g the latest (a git-checkout/npm-link copy
114
+ is reported, not overwritten). --json only reports.
115
+
116
+ OPTIONS
117
+ --json Machine output: stdout carries exactly one
118
+ {ok, data | error} envelope; all progress goes to stderr.
119
+ error = {code, message, remedy?, details?}. Bigints are
120
+ decimal strings; absent values are null, not omitted.
121
+ doctor packs its per-check results (status pass|fail|skip)
122
+ under (data|error.details).checks.
123
+ --mine (list) only deployments owned by AGENTIC_PRIVATE_KEY.
124
+ --phase <p> (list) filter: deploying|running|stopped|offline|failed.
125
+ --help Show this help.
126
+ --version Print the package version (identical to the SDK's).
127
+
128
+ ENVIRONMENT
129
+ AGENTIC_ATTESTOR_URL required. Attestor base URL — one URL selects the
130
+ whole environment (contracts, RPC, appIds).
131
+ AGENTIC_PRIVATE_KEY optional. Owner key (0x… hex). Env only — there is
132
+ deliberately no flag for it.
133
+ AGENTIC_RPC_URL optional. Overrides the RPC the attestor advertises.
134
+ AGENTIC_API_KEY optional. Inference key for deploy/reset; overrides
135
+ the one stored by login.
136
+ AGENTIC_VERIFIED_FEEDBACK_ADDR / AGENTIC_FEEDBACK_BATCHER_ADDR
137
+ optional. Reputation-pair address overrides for
138
+ attestors whose /config doesn't advertise them yet.
139
+ The registry must be the one the agents' sealed
140
+ proxy signs serve-proofs for, or every proof fails
141
+ verification.
142
+
143
+ EXIT CODES
144
+ 0 success · 1 unknown · 2 usage error (incl. unknown command/agent — branch
145
+ on error.code to tell them apart) · 3 fixable precondition (run the error's
146
+ remedy, then retry) · 4 timeout (check again later) · 5 auth (stop)
147
+
148
+ EXAMPLES
149
+ 0g-agentdna # deploy a new agent and chat
150
+ 0g-agentdna 286 # attach to agent 286 and chat
151
+ 0g-agentdna doctor
152
+ 0g-agentdna status 33
153
+ 0g-agentdna settings 286
154
+ 0g-agentdna settings 286 model=0gm-1.0-35b-a3b thinking=high
155
+ 0g-agentdna list --mine --phase failed --json | jq -r '.data[].sealId'`;
156
+ /** Package version, read at runtime from the SDK's own package.json
157
+ * (dist/cli/main.js → ../../package.json). */
158
+ function packageVersion() {
159
+ const raw = (0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, '..', '..', 'package.json'), 'utf8');
160
+ return JSON.parse(raw).version;
161
+ }
162
+ async function main() {
163
+ // parseArgs throws on unknown/malformed flags — surfaced as exit 2 below.
164
+ const { values, positionals } = (0, node_util_1.parseArgs)({
165
+ args: process.argv.slice(2),
166
+ allowPositionals: true,
167
+ strict: true,
168
+ options: {
169
+ json: { type: 'boolean', default: false },
170
+ help: { type: 'boolean', default: false },
171
+ version: { type: 'boolean', default: false },
172
+ mine: { type: 'boolean', default: false },
173
+ phase: { type: 'string' },
174
+ },
175
+ });
176
+ if (values.version) {
177
+ (0, envelope_1.print)(packageVersion());
178
+ return errors_1.EXIT.OK;
179
+ }
180
+ if (values.help) {
181
+ (0, envelope_1.print)(HELP);
182
+ return errors_1.EXIT.OK;
183
+ }
184
+ // Claude-Code-style default: bare `0g-agentdna` (or with just an agent
185
+ // ref, e.g. `0g-agentdna 286`) enters the interactive chat. The
186
+ // diagnostics commands (doctor/status/list) are the only reserved words;
187
+ // an agentId is decimal and a sealId is 0x…, so neither collides with a
188
+ // command name — anything that isn't a known command routes to chat.
189
+ const [first, ...rest] = positionals;
190
+ const isCommand = !!first && first in COMMANDS;
191
+ const run = isCommand ? COMMANDS[first] : interactive_1.run;
192
+ const ctx = {
193
+ env: (0, env_1.readEnv)(),
194
+ json: values.json,
195
+ positionals: isCommand ? rest : positionals,
196
+ flags: { mine: values.mine, phase: values.phase },
197
+ };
198
+ await run(ctx);
199
+ return errors_1.EXIT.OK;
200
+ }
201
+ // Single error boundary. `--json` is detected from raw argv so the envelope
202
+ // contract holds even when parseArgs itself is what threw.
203
+ // `process.exitCode` (not `process.exit()`): exit() can truncate stdout when
204
+ // it's a pipe — a natural exit drains the write buffers first, which the
205
+ // envelope contract depends on.
206
+ const wantJson = process.argv.includes('--json');
207
+ main()
208
+ .then((code) => {
209
+ process.exitCode = code;
210
+ })
211
+ .catch((e) => {
212
+ // node:util's parseArgs errors carry ERR_PARSE_ARGS_* codes — usage, exit 2.
213
+ const nodeCode = e.code ?? '';
214
+ // Own wording, not node:util's raw parseArgs prose (its "place it at the
215
+ // end of the command after '--'" advice means nothing to end users).
216
+ const err = nodeCode.startsWith('ERR_PARSE_ARGS')
217
+ ? new errors_1.CliError('BAD_FLAG', nodeCode === 'ERR_PARSE_ARGS_UNKNOWN_OPTION'
218
+ ? `unknown flag: ${(e.message.match(/'(--?[^']+)'/) ?? [])[1] ?? '(see --help)'}`
219
+ : 'malformed command-line arguments', { remedy: '0g-agentdna --help' })
220
+ : (0, errors_1.toCliError)(e);
221
+ process.exitCode = (0, envelope_1.emitError)(err, wantJson);
222
+ });
223
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;GAUG;;AAEH,yCAAsC;AACtC,qCAAuC;AACvC,yCAAiC;AACjC,qCAAsD;AACtD,yCAA8C;AAC9C,+BAAgC;AAEhC,8CAA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AAQ,CAAC,QAAQ,CAAC,CAAC;AACjD,IAAI,EAAE;KACH,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;IACb,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;AAC1B,CAAC,CAAC;KACD,KAAK,CAAC,CAAC,CAAU,EAAE,EAAE;IACpB,6EAA6E;IAC7E,MAAM,QAAQ,GAAI,CAAuB,CAAC,IAAI,IAAI,EAAE,CAAC;IACrD,yEAAyE;IACzE,qEAAqE;IACrE,MAAM,GAAG,GACP,QAAQ,CAAC,UAAU,CAAC,gBAAgB,CAAC;QACnC,CAAC,CAAC,IAAI,iBAAQ,CACV,UAAU,EACV,QAAQ,KAAK,+BAA+B;YAC1C,CAAC,CAAC,iBAAiB,CAAE,CAAW,CAAC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,cAAc,EAAE;YAC5F,CAAC,CAAC,kCAAkC,EACtC,EAAE,MAAM,EAAE,oBAAoB,EAAE,CACjC;QACH,CAAC,CAAC,IAAA,mBAAU,EAAC,CAAC,CAAC,CAAC;IACpB,OAAO,CAAC,QAAQ,GAAG,IAAA,oBAAS,EAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AAC9C,CAAC,CAAC,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @file proofs.ts
3
+ * @description The proof jar: locally saved serve-proofs ("tickets") captured
4
+ * from agent interactions, so `rate` can spend a ticket from an interaction
5
+ * that already happened — including rating an agent that has since gone
6
+ * offline. Physics of a ticket: expires one hour after issuance (the sealed
7
+ * proxy sets the deadline; the chain enforces it), single-use (signature is
8
+ * the nonce), and redeemable ONLY by the wallet named in `submitter` — so a
9
+ * jar entry leaking is harmless to anyone else.
10
+ *
11
+ * Stored next to the CLI config (`proofs.json`, 0600 out of caution). Each
12
+ * entry carries the proof AND the task-receipt materials (method/uri/body
13
+ * hashes/status) captured from the same interaction, so submission can open
14
+ * the taskHash commitment on-chain (TEE-verified endpoint).
15
+ */
16
+ import type { ServeProof, TaskReveal } from '../types';
17
+ import type { ProofVerification } from '../ServeSession';
18
+ /** A saved ticket: the proof plus its receipt materials and provenance. */
19
+ export interface SavedProof {
20
+ agentId: string;
21
+ submitter: `0x${string}`;
22
+ endpoint: string;
23
+ capturedAt: number;
24
+ deadline: number;
25
+ proof: {
26
+ agentId: string;
27
+ submitter: `0x${string}`;
28
+ timestamp: string;
29
+ deadline: string;
30
+ taskHash: `0x${string}`;
31
+ dataHashes: `0x${string}`[];
32
+ frameworkHash: `0x${string}`;
33
+ signature: `0x${string}`;
34
+ validator?: `0x${string}`;
35
+ };
36
+ task: TaskReveal;
37
+ }
38
+ /** Bank a ticket (append — one proof backs one rating, several interactions
39
+ * with one agent yield several independently spendable tickets). */
40
+ export declare function saveProof(proof: ServeProof, task: TaskReveal, endpoint: string): void;
41
+ /** All unexpired tickets for (agentId, wallet), newest first — with a
42
+ * mining-time margin so a ticket seconds from expiry isn't offered. */
43
+ export declare function listProofs(agentId: bigint, wallet: `0x${string}`, marginSeconds?: number): SavedProof[];
44
+ /** Burn ONE spent (or refused) ticket, identified by its unique signature. */
45
+ export declare function removeProof(signature: `0x${string}`): void;
46
+ /**
47
+ * Whether the registry would redeem this ticket, judged on exactly what
48
+ * VerifiedFeedbackRegistry checks: not expired, and a signature that verifies
49
+ * against the registry configured here. `dataOnChain` is NOT one of them —
50
+ * the registry never compares a proof's dataHashes with the agent's current
51
+ * iData (it records them as the version that served), so a ticket whose
52
+ * agent has since committed new state still redeems. `rate` shows that case
53
+ * as an informational note, not a failure.
54
+ */
55
+ export declare function ticketRedeemable(v: Pick<ProofVerification, 'notExpired' | 'registryMatches' | 'signerMatches'>): boolean;
56
+ /**
57
+ * What `rate` does with a ticket that is not `ticketRedeemable`.
58
+ * `'burn'` only on a defect of the ticket itself — expired, or a signature
59
+ * that does not verify against the registry it names. `'keep'` when the
60
+ * failure is this side's configuration (no registry configured, or the
61
+ * ticket names a different one): the ticket may still redeem once that is
62
+ * fixed. `dataOnChain` never burns a ticket (see `ticketRedeemable`).
63
+ */
64
+ export declare function ticketDisposition(v: Pick<ProofVerification, 'notExpired' | 'registryMatches' | 'signerMatches'>): 'burn' | 'keep';
65
+ /** Rehydrate the bigint fields for SDK submission. */
66
+ export declare function toServeProof(e: SavedProof): ServeProof;
67
+ //# sourceMappingURL=proofs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proofs.d.ts","sourceRoot":"","sources":["../../src/cli/proofs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGzD,2EAA2E;AAC3E,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,KAAK,MAAM,EAAE,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE;QACL,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,KAAK,MAAM,EAAE,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAC/E,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAC;QAAC,UAAU,EAAE,KAAK,MAAM,EAAE,EAAE,CAAC;QAAC,aAAa,EAAE,KAAK,MAAM,EAAE,CAAC;QACnF,SAAS,EAAE,KAAK,MAAM,EAAE,CAAC;QACzB,SAAS,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;KAC3B,CAAC;IACF,IAAI,EAAE,UAAU,CAAC;CAClB;AA2BD;qEACqE;AACrE,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG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