@0gfoundation/0g-agentdna 0.0.0-stage → 0.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 (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 +34 -0
  53. package/dist/cli/commands/cells.d.ts.map +1 -0
  54. package/dist/cli/commands/cells.js +66 -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 +107 -0
  61. package/dist/cli/commands/interactive.d.ts.map +1 -0
  62. package/dist/cli/commands/interactive.js +3034 -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 +115 -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 +61 -0
  179. package/src/cli/commands/doctor.ts +235 -0
  180. package/src/cli/commands/interactive.ts +2715 -0
  181. package/src/cli/commands/list.ts +117 -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
package/dist/index.js ADDED
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ /**
3
+ * @file index.ts
4
+ * @description Entry point for 0g-agentdna.
5
+ *
6
+ * One facade (`AgentDNA`; legacy alias `AgenticID`): intent namespaces — `agent` (lifecycle:
7
+ * deploy/clone/transfer + reads + agent-seal gas) and `reputation` (serve-proof
8
+ * + feedback), and `admin` (attestor-wide provider publication) — plus top-level `ack`/`ackStatus` (trust roots) and
9
+ * `deposit`/`getBalance` (sandbox balance). Construct once with rpc + addresses.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { AgentDNA } from '@0gfoundation/0g-agentdna';
14
+ * const ag = new AgentDNA({ addresses, account }); // addresses from DEPLOYMENT.md §6 / your config
15
+ * ```
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.RPC_URL = exports.ZERO_G_MAINNET = exports.ZERO_G_TESTNET = exports.requestUriCandidates = exports.requestUriOf = exports.taskHashOf = exports.verifyServeProofSignature = exports.signServeProof = exports.buildServeProof = exports.buildServeProofSigningHash = exports.buildServeProofMessageHash = exports.proofRecordingFetch = exports.taskRevealOf = exports.captureProof = exports.proofFromResponse = exports.parseServeProofHeader = exports.SERVE_PROOF_HEADER = exports.ServeSession = exports.fetchRouterModelIds = exports.modelAdvisory = exports.sha256Hex = exports.SettingsConflictError = exports.settingsAuthMessage = exports.canonicalSettings = exports.ROUTER_MODELS_URL = exports.ZG_COMPUTE_PROVIDER = exports.SETTINGS_FIELDS = exports.THINKING_LEVELS = exports.SETTINGS_DOMAIN = exports.sealSecretEnv = exports.SecretEnvRefusedError = exports.SECRET_ENV_VAR = exports.SECRET_ENV_SCHEME = exports.b64encode = exports.DEPLOY_DOMAIN = exports.CLONE_CONTRACT_DOMAIN = exports.CLONE_DOMAIN = exports.AttestorClient = exports.MAX_ABS_FEEDBACK_VALUE = exports.ReputationClient = exports.AgenticIDClient = exports.SandboxClient = exports.defaultIData = exports.mcpServices = exports.makeAgentClient = exports.ReputationApi = exports.AdminApi = exports.AgentApi = exports.AgenticID = exports.AgentDNA = void 0;
19
+ exports.routeHash = exports.inferenceProvider = exports.listInferenceProviders = exports.sandboxServingAbi = exports.tappRegistryAbi = exports.feedbackBatcherAbi = exports.verifiedFeedbackAbi = exports.canonicalReputationAbi = exports.standardCloneAuthorizerAbi = exports.cloneGateAbi = exports.agenticIDAbi = exports.RECEIPT_WAIT = exports.CHAIN_ID = void 0;
20
+ // Node < 18 has no global fetch; without this guard the first bootstrap
21
+ // (fromAttestor) or chain read fails with a bare "fetch is not defined" from
22
+ // deep in the call stack. package.json `engines` isn't enforced by npm by
23
+ // default, so turn the miss into an actionable message at import time.
24
+ if (typeof globalThis.fetch !== 'function') {
25
+ throw new Error('0g-agentdna requires a global fetch (Node >= 18). ' +
26
+ 'On Node < 18 either upgrade Node or polyfill globalThis.fetch.');
27
+ }
28
+ // ── Facade + namespaces ──
29
+ var AgenticID_1 = require("./AgenticID");
30
+ Object.defineProperty(exports, "AgentDNA", { enumerable: true, get: function () { return AgenticID_1.AgenticID; } });
31
+ Object.defineProperty(exports, "AgenticID", { enumerable: true, get: function () { return AgenticID_1.AgenticID; } });
32
+ Object.defineProperty(exports, "AgentApi", { enumerable: true, get: function () { return AgenticID_1.AgentApi; } });
33
+ Object.defineProperty(exports, "AdminApi", { enumerable: true, get: function () { return AgenticID_1.AdminApi; } });
34
+ Object.defineProperty(exports, "ReputationApi", { enumerable: true, get: function () { return AgenticID_1.ReputationApi; } });
35
+ var AgentClient_1 = require("./AgentClient");
36
+ Object.defineProperty(exports, "makeAgentClient", { enumerable: true, get: function () { return AgentClient_1.makeAgentClient; } });
37
+ var AgentClient_2 = require("./AgentClient");
38
+ Object.defineProperty(exports, "mcpServices", { enumerable: true, get: function () { return AgentClient_2.mcpServices; } });
39
+ var AttestorClient_1 = require("./AttestorClient");
40
+ Object.defineProperty(exports, "defaultIData", { enumerable: true, get: function () { return AttestorClient_1.defaultIData; } });
41
+ // ── Namespace implementation classes (advanced / typing) ──
42
+ var SandboxClient_1 = require("./SandboxClient");
43
+ Object.defineProperty(exports, "SandboxClient", { enumerable: true, get: function () { return SandboxClient_1.SandboxClient; } });
44
+ var AgenticIDClient_1 = require("./AgenticIDClient");
45
+ Object.defineProperty(exports, "AgenticIDClient", { enumerable: true, get: function () { return AgenticIDClient_1.AgenticIDClient; } });
46
+ var ReputationClient_1 = require("./ReputationClient");
47
+ Object.defineProperty(exports, "ReputationClient", { enumerable: true, get: function () { return ReputationClient_1.ReputationClient; } });
48
+ Object.defineProperty(exports, "MAX_ABS_FEEDBACK_VALUE", { enumerable: true, get: function () { return ReputationClient_1.MAX_ABS_FEEDBACK_VALUE; } });
49
+ var AttestorClient_2 = require("./AttestorClient");
50
+ Object.defineProperty(exports, "AttestorClient", { enumerable: true, get: function () { return AttestorClient_2.AttestorClient; } });
51
+ Object.defineProperty(exports, "CLONE_DOMAIN", { enumerable: true, get: function () { return AttestorClient_2.CLONE_DOMAIN; } });
52
+ Object.defineProperty(exports, "CLONE_CONTRACT_DOMAIN", { enumerable: true, get: function () { return AttestorClient_2.CLONE_CONTRACT_DOMAIN; } });
53
+ Object.defineProperty(exports, "DEPLOY_DOMAIN", { enumerable: true, get: function () { return AttestorClient_2.DEPLOY_DOMAIN; } });
54
+ Object.defineProperty(exports, "b64encode", { enumerable: true, get: function () { return AttestorClient_2.b64encode; } });
55
+ // Sealed secret env (issue #166): the inference key sealed to the agent's
56
+ // agentSeal key instead of riding the signed envelope in clear.
57
+ var secretEnv_1 = require("./secretEnv");
58
+ Object.defineProperty(exports, "SECRET_ENV_SCHEME", { enumerable: true, get: function () { return secretEnv_1.SECRET_ENV_SCHEME; } });
59
+ Object.defineProperty(exports, "SECRET_ENV_VAR", { enumerable: true, get: function () { return secretEnv_1.SECRET_ENV_VAR; } });
60
+ Object.defineProperty(exports, "SecretEnvRefusedError", { enumerable: true, get: function () { return secretEnv_1.SecretEnvRefusedError; } });
61
+ Object.defineProperty(exports, "sealSecretEnv", { enumerable: true, get: function () { return secretEnv_1.sealSecretEnv; } });
62
+ // ── Owner settings (the opaque-to-attestor configuration document) ──
63
+ var Settings_1 = require("./Settings");
64
+ Object.defineProperty(exports, "SETTINGS_DOMAIN", { enumerable: true, get: function () { return Settings_1.SETTINGS_DOMAIN; } });
65
+ Object.defineProperty(exports, "THINKING_LEVELS", { enumerable: true, get: function () { return Settings_1.THINKING_LEVELS; } });
66
+ Object.defineProperty(exports, "SETTINGS_FIELDS", { enumerable: true, get: function () { return Settings_1.SETTINGS_FIELDS; } });
67
+ Object.defineProperty(exports, "ZG_COMPUTE_PROVIDER", { enumerable: true, get: function () { return Settings_1.ZG_COMPUTE_PROVIDER; } });
68
+ Object.defineProperty(exports, "ROUTER_MODELS_URL", { enumerable: true, get: function () { return Settings_1.ROUTER_MODELS_URL; } });
69
+ Object.defineProperty(exports, "canonicalSettings", { enumerable: true, get: function () { return Settings_1.canonicalSettings; } });
70
+ Object.defineProperty(exports, "settingsAuthMessage", { enumerable: true, get: function () { return Settings_1.settingsAuthMessage; } });
71
+ Object.defineProperty(exports, "SettingsConflictError", { enumerable: true, get: function () { return Settings_1.SettingsConflictError; } });
72
+ Object.defineProperty(exports, "sha256Hex", { enumerable: true, get: function () { return Settings_1.sha256Hex; } });
73
+ Object.defineProperty(exports, "modelAdvisory", { enumerable: true, get: function () { return Settings_1.modelAdvisory; } });
74
+ Object.defineProperty(exports, "fetchRouterModelIds", { enumerable: true, get: function () { return Settings_1.fetchRouterModelIds; } });
75
+ // ── Reputation: serve-proof transport + verification ──
76
+ var ServeSession_1 = require("./ServeSession");
77
+ Object.defineProperty(exports, "ServeSession", { enumerable: true, get: function () { return ServeSession_1.ServeSession; } });
78
+ Object.defineProperty(exports, "SERVE_PROOF_HEADER", { enumerable: true, get: function () { return ServeSession_1.SERVE_PROOF_HEADER; } });
79
+ Object.defineProperty(exports, "parseServeProofHeader", { enumerable: true, get: function () { return ServeSession_1.parseServeProofHeader; } });
80
+ Object.defineProperty(exports, "proofFromResponse", { enumerable: true, get: function () { return ServeSession_1.proofFromResponse; } });
81
+ Object.defineProperty(exports, "captureProof", { enumerable: true, get: function () { return ServeSession_1.captureProof; } });
82
+ Object.defineProperty(exports, "taskRevealOf", { enumerable: true, get: function () { return ServeSession_1.taskRevealOf; } });
83
+ Object.defineProperty(exports, "proofRecordingFetch", { enumerable: true, get: function () { return ServeSession_1.proofRecordingFetch; } });
84
+ // ── ServeProof utilities ──
85
+ var ServeProof_1 = require("./ServeProof");
86
+ Object.defineProperty(exports, "buildServeProofMessageHash", { enumerable: true, get: function () { return ServeProof_1.buildServeProofMessageHash; } });
87
+ Object.defineProperty(exports, "buildServeProofSigningHash", { enumerable: true, get: function () { return ServeProof_1.buildServeProofSigningHash; } });
88
+ Object.defineProperty(exports, "buildServeProof", { enumerable: true, get: function () { return ServeProof_1.buildServeProof; } });
89
+ Object.defineProperty(exports, "signServeProof", { enumerable: true, get: function () { return ServeProof_1.signServeProof; } });
90
+ Object.defineProperty(exports, "verifyServeProofSignature", { enumerable: true, get: function () { return ServeProof_1.verifyServeProofSignature; } });
91
+ var taskHash_1 = require("./taskHash");
92
+ Object.defineProperty(exports, "taskHashOf", { enumerable: true, get: function () { return taskHash_1.taskHashOf; } });
93
+ Object.defineProperty(exports, "requestUriOf", { enumerable: true, get: function () { return taskHash_1.requestUriOf; } });
94
+ Object.defineProperty(exports, "requestUriCandidates", { enumerable: true, get: function () { return taskHash_1.requestUriCandidates; } });
95
+ // ── Constants ──
96
+ // Protocol-level, stable. Contract addresses are NOT exported — they're a
97
+ // deployment artifact (see contracts/DEPLOYMENT.md §6); pass them explicitly.
98
+ var constants_1 = require("./constants");
99
+ Object.defineProperty(exports, "ZERO_G_TESTNET", { enumerable: true, get: function () { return constants_1.ZERO_G_TESTNET; } });
100
+ Object.defineProperty(exports, "ZERO_G_MAINNET", { enumerable: true, get: function () { return constants_1.ZERO_G_MAINNET; } });
101
+ Object.defineProperty(exports, "RPC_URL", { enumerable: true, get: function () { return constants_1.RPC_URL; } });
102
+ Object.defineProperty(exports, "CHAIN_ID", { enumerable: true, get: function () { return constants_1.CHAIN_ID; } });
103
+ Object.defineProperty(exports, "RECEIPT_WAIT", { enumerable: true, get: function () { return constants_1.RECEIPT_WAIT; } });
104
+ // ── ABIs (advanced usage) ──
105
+ var abi_1 = require("./abi");
106
+ Object.defineProperty(exports, "agenticIDAbi", { enumerable: true, get: function () { return abi_1.agenticIDAbi; } });
107
+ Object.defineProperty(exports, "cloneGateAbi", { enumerable: true, get: function () { return abi_1.cloneGateAbi; } });
108
+ Object.defineProperty(exports, "standardCloneAuthorizerAbi", { enumerable: true, get: function () { return abi_1.standardCloneAuthorizerAbi; } });
109
+ Object.defineProperty(exports, "canonicalReputationAbi", { enumerable: true, get: function () { return abi_1.canonicalReputationAbi; } });
110
+ Object.defineProperty(exports, "verifiedFeedbackAbi", { enumerable: true, get: function () { return abi_1.verifiedFeedbackAbi; } });
111
+ Object.defineProperty(exports, "feedbackBatcherAbi", { enumerable: true, get: function () { return abi_1.feedbackBatcherAbi; } });
112
+ Object.defineProperty(exports, "tappRegistryAbi", { enumerable: true, get: function () { return abi_1.tappRegistryAbi; } });
113
+ Object.defineProperty(exports, "sandboxServingAbi", { enumerable: true, get: function () { return abi_1.sandboxServingAbi; } });
114
+ var Providers_1 = require("./Providers");
115
+ Object.defineProperty(exports, "listInferenceProviders", { enumerable: true, get: function () { return Providers_1.listInferenceProviders; } });
116
+ Object.defineProperty(exports, "inferenceProvider", { enumerable: true, get: function () { return Providers_1.inferenceProvider; } });
117
+ Object.defineProperty(exports, "routeHash", { enumerable: true, get: function () { return Providers_1.routeHash; } });
118
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH,wEAAwE;AACxE,6EAA6E;AAC7E,0EAA0E;AAC1E,uEAAuE;AACvE,IAAI,OAAQ,UAAkC,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;IACpE,MAAM,IAAI,KAAK,CACb,oDAAoD;QAClD,gEAAgE,CACnE,CAAC;AACJ,CAAC;AAED,4BAA4B;AAC5B,yCAAkG;AAAzF,qGAAA,SAAS,OAAY;AAAE,sGAAA,SAAS,OAAA;AAAE,qGAAA,QAAQ,OAAA;AAAE,qGAAA,QAAQ,OAAA;AAAE,0GAAA,aAAa,OAAA;AAE5E,6CAAgD;AAAvC,8GAAA,eAAe,OAAA;AAExB,6CAA4C;AAAnC,0GA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AA4E;AAAnE,sGAAA,UAAU,OAAA;AAAE,wGAAA,YAAY,OAAA;AAAE,gHAAA,oBAAoB,OAAA;AAiBvD,kBAAkB;AAClB,0EAA0E;AAC1E,8EAA8E;AAC9E,yCAMqB;AALnB,2GAAA,cAAc,OAAA;AACd,2GAAA,cAAc,OAAA;AACd,oGAAA,OAAO,OAAA;AACP,qGAAA,QAAQ,OAAA;AACR,yGAAA,YAAY,OAAA;AAId,8BAA8B;AAC9B,6BASe;AARb,mGAAA,YAAY,OAAA;AACZ,mGAAA,YAAY,OAAA;AACZ,iHAAA,0BAA0B,OAAA;AAC1B,6GAAA,sBAAsB,OAAA;AACtB,0GAAA,mBAAmB,OAAA;AACnB,yGAAA,kBAAkB,OAAA;AAClB,sGAAA,eAAe,OAAA;AACf,wGAAA,iBAAiB,OAAA;AAGnB,yCAAmF;AAA1E,mHAAA,sBAAsB,OAAA;AAAE,8GAAA,iBAAiB,OAAA;AAAE,sGAAA,SAAS,OAAA"}
@@ -0,0 +1,23 @@
1
+ [
2
+ {
3
+ "id": "0g-compute",
4
+ "name": "0G Compute",
5
+ "formats": ["openai", "anthropic"],
6
+ "defaultFormat": "openai",
7
+ "endpoints": {
8
+ "openai": "https://router-api.0g.ai/v1",
9
+ "anthropic": "https://router-api.0g.ai"
10
+ },
11
+ "modelCatalog": "https://router-api.0g.ai/v1/models",
12
+ "compatibility": {
13
+ "requiresStringContent": true,
14
+ "supportsStore": false,
15
+ "supportsDeveloperRole": false,
16
+ "supportsUsageInStreaming": false,
17
+ "supportsStrictMode": false,
18
+ "maxTokensField": "max_tokens"
19
+ }
20
+ },
21
+ { "id": "openai", "name": "OpenAI", "native": true, "formats": ["openai"] },
22
+ { "id": "anthropic", "name": "Anthropic", "native": true, "formats": ["anthropic"] }
23
+ ]
package/dist/seal.d.ts ADDED
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @file seal.ts
3
+ * @description viem Account backed by the sealed container's sign socket —
4
+ * how an AGENT uses the SDK as an owner (nested agents).
5
+ *
6
+ * Inside a sealed container the agentSeal private key lives only in the
7
+ * sealed Go process; the agent reaches it through a unix-socket signer
8
+ * (`SEAL_SIGN_SOCK`, three endpoints: personal_sign / typed_data /
9
+ * transaction — see sealed/internal/proxy/sign.go). This module bridges
10
+ * that signer into a viem `Account`, so the whole SDK works unchanged:
11
+ *
12
+ * import { AgentDNA } from '@0gfoundation/0g-agentdna';
13
+ * import { sealAccount } from '@0gfoundation/0g-agentdna/seal';
14
+ * const ag = await AgentDNA.fromAttestor(url, { account: await sealAccount() });
15
+ *
16
+ * Node-only (unix sockets); import from the `/seal` subpath so browser
17
+ * bundles of the main entry stay node-free.
18
+ */
19
+ import type { Address, LocalAccount } from 'viem';
20
+ export interface SealAccountOptions {
21
+ /** Unix socket path. Default: $SEAL_SIGN_SOCK, then /run/seal-sign.sock. */
22
+ socketPath?: string;
23
+ /**
24
+ * The agentSeal address. Default: $AGENT_SEAL (exported into the agent's
25
+ * environment by the sealed runtime); as a last resort the adapter probes
26
+ * the socket with one personal_sign and uses the address it reports.
27
+ */
28
+ address?: Address;
29
+ }
30
+ /**
31
+ * A viem `LocalAccount` whose signatures come from the sealed container's
32
+ * sign socket. Pass it wherever the SDK takes `account` — the SDK's
33
+ * contract: no method ever needs a raw private key, all signing flows
34
+ * through the viem Account interface, so this account IS full ownership.
35
+ *
36
+ * Unsupported on purpose (the socket signs legacy + EIP-1559 only): tx
37
+ * types eip2930/eip4844/eip7702 and access lists — those throw an explicit
38
+ * error rather than mis-signing.
39
+ *
40
+ * Deliberately absent, and must stay so: raw-hash signing (`sign({ hash })`)
41
+ * and any EIP-191 version 0x00 path. The socket's preimages are only
42
+ * personal_sign (0x19 0x45), typed data (0x19 0x01) and transactions it
43
+ * encodes itself; ServeProofs are signed over a 0x19 0x00 digest that only
44
+ * the sealed proxy produces, so this account cannot forge one.
45
+ */
46
+ export declare function sealAccount(opts?: SealAccountOptions): Promise<LocalAccount>;
47
+ //# sourceMappingURL=seal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seal.d.ts","sourceRoot":"","sources":["../src/seal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAO,YAAY,EAAE,MAAM,MAAM,CAAC;AAEvD,MAAM,WAAW,kBAAkB;IACjC,4EAA4E;IAC5E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AA+CD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,WAAW,CAAC,IAAI,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,CAmElF"}
package/dist/seal.js ADDED
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+ /**
3
+ * @file seal.ts
4
+ * @description viem Account backed by the sealed container's sign socket —
5
+ * how an AGENT uses the SDK as an owner (nested agents).
6
+ *
7
+ * Inside a sealed container the agentSeal private key lives only in the
8
+ * sealed Go process; the agent reaches it through a unix-socket signer
9
+ * (`SEAL_SIGN_SOCK`, three endpoints: personal_sign / typed_data /
10
+ * transaction — see sealed/internal/proxy/sign.go). This module bridges
11
+ * that signer into a viem `Account`, so the whole SDK works unchanged:
12
+ *
13
+ * import { AgentDNA } from '@0gfoundation/0g-agentdna';
14
+ * import { sealAccount } from '@0gfoundation/0g-agentdna/seal';
15
+ * const ag = await AgentDNA.fromAttestor(url, { account: await sealAccount() });
16
+ *
17
+ * Node-only (unix sockets); import from the `/seal` subpath so browser
18
+ * bundles of the main entry stay node-free.
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.sealAccount = sealAccount;
22
+ const node_http_1 = require("node:http");
23
+ const accounts_1 = require("viem/accounts");
24
+ /** POST a JSON body to the sign socket; JSON response or a typed error. */
25
+ function sockPost(socketPath, path, body) {
26
+ // JSON.stringify with a bigint guard — a stray bigint (e.g. a typed-data
27
+ // domain chainId) must become a number/string, not a TypeError.
28
+ const payload = JSON.stringify(body, (_k, v) => (typeof v === 'bigint' ? v.toString() : v));
29
+ return new Promise((resolve, reject) => {
30
+ const req = (0, node_http_1.request)({ socketPath, path, method: 'POST', headers: { 'content-type': 'application/json' } }, (res) => {
31
+ let raw = '';
32
+ res.setEncoding('utf8');
33
+ res.on('data', (c) => (raw += c));
34
+ res.on('end', () => {
35
+ let parsed = null;
36
+ try {
37
+ parsed = JSON.parse(raw);
38
+ }
39
+ catch { /* non-JSON error body */ }
40
+ if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300 && parsed) {
41
+ resolve(parsed);
42
+ }
43
+ else {
44
+ const detail = parsed?.error ?? raw.trim() ?? '';
45
+ reject(new Error(`seal sign socket ${path}: HTTP ${res.statusCode}${detail ? ` — ${detail}` : ''}`));
46
+ }
47
+ });
48
+ });
49
+ req.on('error', (e) => reject(new Error(`seal sign socket ${path}: ${e.message} (socket: ${socketPath} — are you inside a sealed container?)`)));
50
+ req.end(payload);
51
+ });
52
+ }
53
+ /** The EIP712Domain type entry the geth-side hasher requires inside `types`. */
54
+ function eip712DomainType(domain) {
55
+ const fields = [];
56
+ if (domain.name !== undefined)
57
+ fields.push({ name: 'name', type: 'string' });
58
+ if (domain.version !== undefined)
59
+ fields.push({ name: 'version', type: 'string' });
60
+ if (domain.chainId !== undefined)
61
+ fields.push({ name: 'chainId', type: 'uint256' });
62
+ if (domain.verifyingContract !== undefined)
63
+ fields.push({ name: 'verifyingContract', type: 'address' });
64
+ if (domain.salt !== undefined)
65
+ fields.push({ name: 'salt', type: 'bytes32' });
66
+ return fields;
67
+ }
68
+ const dec = (v) => v === undefined ? undefined : v.toString(10);
69
+ /**
70
+ * A viem `LocalAccount` whose signatures come from the sealed container's
71
+ * sign socket. Pass it wherever the SDK takes `account` — the SDK's
72
+ * contract: no method ever needs a raw private key, all signing flows
73
+ * through the viem Account interface, so this account IS full ownership.
74
+ *
75
+ * Unsupported on purpose (the socket signs legacy + EIP-1559 only): tx
76
+ * types eip2930/eip4844/eip7702 and access lists — those throw an explicit
77
+ * error rather than mis-signing.
78
+ *
79
+ * Deliberately absent, and must stay so: raw-hash signing (`sign({ hash })`)
80
+ * and any EIP-191 version 0x00 path. The socket's preimages are only
81
+ * personal_sign (0x19 0x45), typed data (0x19 0x01) and transactions it
82
+ * encodes itself; ServeProofs are signed over a 0x19 0x00 digest that only
83
+ * the sealed proxy produces, so this account cannot forge one.
84
+ */
85
+ async function sealAccount(opts) {
86
+ const socketPath = opts?.socketPath ?? process.env.SEAL_SIGN_SOCK ?? '/run/seal-sign.sock';
87
+ let address = opts?.address ?? process.env.AGENT_SEAL;
88
+ if (!address) {
89
+ // Last resort: one probe signature — the socket reports its address.
90
+ const probe = await sockPost(socketPath, '/sign/personal_sign', { message: 'agenticid-sdk: sealAccount address probe' });
91
+ address = probe.address;
92
+ }
93
+ return (0, accounts_1.toAccount)({
94
+ address,
95
+ async signMessage({ message }) {
96
+ // viem's two input shapes map to the socket's two body fields; mixing
97
+ // them up signs a DIFFERENT message (utf8 of "0x…" vs the raw bytes).
98
+ const body = typeof message === 'string'
99
+ ? { message }
100
+ : { message_hex: typeof message.raw === 'string' ? message.raw : `0x${Buffer.from(message.raw).toString('hex')}` };
101
+ const res = await sockPost(socketPath, '/sign/personal_sign', body);
102
+ return res.signature;
103
+ },
104
+ async signTransaction(tx) {
105
+ const type = tx.type ?? (tx.maxFeePerGas !== undefined ? 'eip1559' : 'legacy');
106
+ if (type !== 'eip1559' && type !== 'legacy') {
107
+ throw new Error(`sealAccount: tx type "${type}" not supported by the seal sign socket (legacy + eip1559 only)`);
108
+ }
109
+ if ('accessList' in tx && tx.accessList?.length) {
110
+ throw new Error('sealAccount: accessList not supported by the seal sign socket');
111
+ }
112
+ if (tx.chainId === undefined || tx.nonce === undefined || tx.gas === undefined) {
113
+ throw new Error('sealAccount: signTransaction needs chainId, nonce and gas — prepare the request first (viem prepareTransactionRequest)');
114
+ }
115
+ const body = {
116
+ chain_id: tx.chainId.toString(10),
117
+ nonce: tx.nonce,
118
+ to: tx.to ?? '',
119
+ value: dec(tx.value) ?? '0',
120
+ data: tx.data ?? '',
121
+ gas_limit: Number(tx.gas),
122
+ type: type === 'eip1559' ? 'dynamic' : 'legacy',
123
+ ...(type === 'eip1559'
124
+ ? { max_fee_per_gas: dec(tx.maxFeePerGas), max_priority_fee_per_gas: dec(tx.maxPriorityFeePerGas) }
125
+ : { gas_price: dec(tx.gasPrice) }),
126
+ };
127
+ const res = await sockPost(socketPath, '/sign/transaction', body);
128
+ return res.raw_tx; // already the serialized signed tx
129
+ },
130
+ async signTypedData(typedData) {
131
+ const { domain = {}, types, primaryType, message } = typedData;
132
+ // geth's apitypes hasher requires the EIP712Domain entry INSIDE types;
133
+ // viem convention omits it — inject one derived from the domain fields.
134
+ const body = {
135
+ domain,
136
+ primaryType,
137
+ message,
138
+ types: { EIP712Domain: eip712DomainType(domain), ...types },
139
+ };
140
+ const res = await sockPost(socketPath, '/sign/typed_data', body);
141
+ return res.signature;
142
+ },
143
+ });
144
+ }
145
+ //# sourceMappingURL=seal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seal.js","sourceRoot":"","sources":["../src/seal.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;AA8EH,kCAmEC;AA/ID,yCAAmD;AACnD,4CAA0C;AAc1C,2EAA2E;AAC3E,SAAS,QAAQ,CAAC,UAAkB,EAAE,IAAY,EAAE,IAAa;IAC/D,yEAAyE;IACzE,gEAAgE;IAChE,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5F,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,GAAG,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AAC,aAAa,CAAC,SAAS;YAC3B,MAAM,EAAE,MAAM,GAAG,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,SAEpD,CAAC;YACF,uEAAuE;YACvE,wEAAwE;YACxE,MAAM,IAAI,GAAG;gBACX,MAAM;gBACN,WAAW;gBACX,OAAO;gBACP,KAAK,EAAE,EAAE,YAAY,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,EAAE;aAC5D,CAAC;YACF,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,UAAU,EAAE,kBAAkB,EAAE,IAAI,CAAC,CAAC;YACjE,OAAO,GAAG,CAAC,SAAgB,CAAC;QAC9B,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * @file secretEnv.ts
3
+ * @description Seal an owner's secret env (today: the inference API key) to an
4
+ * agent's agentSeal public key, so it never appears in clear in the envelope
5
+ * the owner's wallet signs (issue #166).
6
+ *
7
+ * The sandbox "create" envelope is signed with EIP-191 `personal_sign`, and a
8
+ * wallet shows that message verbatim. With the key in `env.API_KEY`, the
9
+ * prompt displayed it, and every hop that relays the envelope (an
10
+ * integrator's proxy, the attestor's job store, the sandbox provider) held it
11
+ * in clear. Sealed instead, the envelope carries
12
+ *
13
+ * env.SEAL_SECRET_ENV = base64( ECIES(agentSeal_pub, {"v":1,"owner",env}) )
14
+ *
15
+ * The owner still signs exactly the bytes the container receives; those bytes
16
+ * are ciphertext that only agentSeal_priv opens (the sealed container after
17
+ * `/provision`, and the attestor's KMS derivation). The container checks that
18
+ * `owner` is the agent's live on-chain owner before applying it.
19
+ *
20
+ * Who seals: the SDK seals `apiKey` itself on start/reset/retry. When an
21
+ * integrator supplies the key (its own billed account) and a user signs, the
22
+ * integrator's server seals it with `sealApiKey` and hands the browser only
23
+ * the ciphertext, which the browser passes as `sealedSecretEnv`. The key then
24
+ * never reaches the user's browser at all.
25
+ *
26
+ * ECIES is the eciesjs-compatible scheme the attestor and sealed already use
27
+ * for `sealedKeys`: secp256k1 ECDH, HKDF-SHA256 over
28
+ * `ephemeralPub(65) ‖ sharedPoint(65)` (no salt, no info), AES-256-GCM with a
29
+ * 16-byte nonce; wire format `ephemeralPub(65) ‖ nonce(16) ‖ tag(16) ‖ ct`.
30
+ */
31
+ import { type Address, type Hex } from 'viem';
32
+ /** `GET /config` value that says this attestor's sealed images open a secret env. */
33
+ export declare const SECRET_ENV_SCHEME = "agent-seal-ecies-v1";
34
+ /** The container env var that carries the sealed secret env. */
35
+ export declare const SECRET_ENV_VAR = "SEAL_SECRET_ENV";
36
+ /**
37
+ * How `start` / `reset` / `retry` / `deploy` deliver the inference key:
38
+ * - `'auto'` (default): sealed to the agent when the attestor advertises
39
+ * `secret_env_scheme` and the agent exists already; otherwise in clear
40
+ * (older attestors, and a one-shot `deploy` with `sandbox`, whose agent
41
+ * does not exist yet when the envelope is signed).
42
+ * - `'sealed'`: sealed or throw — the wallet prompt never shows the key.
43
+ * - `'plaintext'`: legacy `env.API_KEY` in clear, for a sealed image built
44
+ * before `SEAL_SECRET_ENV` existed.
45
+ */
46
+ export type SecretEnvMode = 'auto' | 'sealed' | 'plaintext';
47
+ /** Why a secret-env step refused. Every refusal happens before anything is
48
+ * signed or sent. */
49
+ export type SecretEnvRefusalCode =
50
+ /** `secretEnv` is not 'auto' | 'sealed' | 'plaintext'. */
51
+ 'provider_binding_unsupported' | 'invalid_mode'
52
+ /** Both `apiKey` and `sealedSecretEnv`, or `sealedSecretEnv` with 'plaintext'. */
53
+ | 'conflicting_inputs'
54
+ /** A required input is missing or malformed (e.g. `sealApiKey` without a key or a valid owner). */
55
+ | 'invalid_input'
56
+ /** The call signs before the agent exists (one-shot deploy), so nothing can be sealed to it. */
57
+ | 'sealed_needs_agent'
58
+ /** GET /config could not be read, so the SDK cannot tell whether sealing is supported. */
59
+ | 'config_unreadable'
60
+ /** The attestor does not advertise `secret_env_scheme`. */
61
+ | 'scheme_unsupported'
62
+ /** GET /agent-seal-pubkey failed (network error or non-2xx). */
63
+ | 'pubkey_unavailable'
64
+ /** The served agentSeal public key is not a valid secp256k1 point. */
65
+ | 'pubkey_invalid'
66
+ /** The served key belongs to another seal, another agent_seal_addr, or not to the on-chain agentSeal. */
67
+ | 'pubkey_mismatch'
68
+ /** A chain read needed for a check failed. */
69
+ | 'chain_read_failed'
70
+ /** `owner` is not the agent's on-chain owner, so its container would refuse the secret. */
71
+ | 'owner_mismatch'
72
+ /** `sealedSecretEnv` is not an ECIES ciphertext in the expected wire format. */
73
+ | 'invalid_sealed_secret_env'
74
+ /** This attestor advertised `secret_env_scheme` before and no longer does.
75
+ * For `'auto'` that is indistinguishable from a relaying proxy stripping
76
+ * the field to force a clear-text key, so the SDK refuses instead of
77
+ * downgrading (a sticky pin, per client and — via `secretEnvPin` — per
78
+ * machine). A deliberate operator rollback is expressed by the caller as
79
+ * `secretEnv: 'plaintext'`. */
80
+ | 'scheme_withdrawn';
81
+ /**
82
+ * A secret-env refusal. `signed` is always false: the SDK checks everything
83
+ * before it asks the wallet to sign and before it posts anything, so an
84
+ * integrator can treat this error as "nothing left the process".
85
+ */
86
+ export declare class SecretEnvRefusedError extends Error {
87
+ readonly code: SecretEnvRefusalCode;
88
+ readonly signed: false;
89
+ constructor(code: SecretEnvRefusalCode, message: string, options?: {
90
+ cause?: unknown;
91
+ });
92
+ }
93
+ /** Cryptographic random bytes: WebCrypto in browsers and Node >= 19, the
94
+ * node:crypto fallback on Node 18 (the engines floor). */
95
+ export declare function randomBytes(n: number): Uint8Array;
96
+ /** Ethereum address of a secp256k1 public key (compressed or uncompressed). */
97
+ export declare function publicKeyToAddress(pubkey: Uint8Array): Address;
98
+ /** eciesjs-compatible ECIES encryption to a secp256k1 public key (33 or 65 bytes). */
99
+ export declare function eciesEncrypt(recipientPubkey: Uint8Array, plaintext: Uint8Array): Uint8Array;
100
+ /**
101
+ * Seal `env` for one agent. `agentSealPubkey` is the agent's agentSeal public
102
+ * key (hex, compressed or uncompressed); `owner` is the address that will sign
103
+ * the envelope (the container requires it to be the agent's on-chain owner).
104
+ * Returns the base64 value for `env.SEAL_SECRET_ENV`.
105
+ */
106
+ export declare function sealSecretEnv(agentSealPubkey: Hex, owner: Address, env: Record<string, string>, provider?: string, routeHash?: string, registry?: import('./Providers').ProviderRegistryPin): string;
107
+ /** Parse and validate an agentSeal public key served by the attestor; returns
108
+ * its canonical compressed hex. Throws on anything that is not a curve point. */
109
+ export declare function parseAgentSealPubkey(pubkey: string): Hex;
110
+ /**
111
+ * Check that `value` has the shape `sealSecretEnv` produces (standard base64
112
+ * of `ephemeralPub(65) ‖ nonce(16) ‖ tag(16) ‖ ct`, with a valid ephemeral
113
+ * point) and return it trimmed. The SDK cannot decrypt it, so this does not
114
+ * prove which agent it was sealed to; it stops a caller from signing
115
+ * something that is plainly not a sealed secret (a raw key passed by
116
+ * mistake, say) into the envelope.
117
+ */
118
+ export declare function checkSealedSecretEnv(value: string): string;
119
+ //# sourceMappingURL=secretEnv.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secretEnv.d.ts","sourceRoot":"","sources":["../src/secretEnv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAMH,OAAO,EAA4C,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAExF,qFAAqF;AACrF,eAAO,MAAM,iBAAiB,wBAAwB,CAAC;AACvD,gEAAgE;AAChE,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,CAAC;AAE5D;sBACsB;AACtB,MAAM,MAAM,oBAAoB;AAC9B,0DAA0D;AACxD,8BAA8B,GAC9B,cAAc;AAChB,kFAAkF;GAChF,oBAAoB;AACtB,mGAAmG;GACjG,eAAe;AACjB,gGAAgG;GAC9F,oBAAoB;AACtB,0FAA0F;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