@ixo/decision-oracle 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 (1118) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +794 -2
  3. package/dist/act.d.ts +87 -0
  4. package/dist/act.d.ts.map +1 -0
  5. package/dist/act.js +20 -0
  6. package/dist/act.js.map +1 -0
  7. package/dist/app.d.ts +22 -0
  8. package/dist/app.d.ts.map +1 -0
  9. package/dist/app.js +128 -0
  10. package/dist/app.js.map +1 -0
  11. package/dist/c2pa.wasm +0 -0
  12. package/dist/cli/commands/api.d.ts +50 -0
  13. package/dist/cli/commands/api.d.ts.map +1 -0
  14. package/dist/cli/commands/api.js +737 -0
  15. package/dist/cli/commands/api.js.map +1 -0
  16. package/dist/cli/commands/create-collection.d.ts +40 -0
  17. package/dist/cli/commands/create-collection.d.ts.map +1 -0
  18. package/dist/cli/commands/create-collection.js +318 -0
  19. package/dist/cli/commands/create-collection.js.map +1 -0
  20. package/dist/cli/commands/create-deed.d.ts +31 -0
  21. package/dist/cli/commands/create-deed.d.ts.map +1 -0
  22. package/dist/cli/commands/create-deed.js +208 -0
  23. package/dist/cli/commands/create-deed.js.map +1 -0
  24. package/dist/cli/commands/delegation.d.ts +26 -0
  25. package/dist/cli/commands/delegation.d.ts.map +1 -0
  26. package/dist/cli/commands/delegation.js +162 -0
  27. package/dist/cli/commands/delegation.js.map +1 -0
  28. package/dist/cli/commands/derive.d.ts +22 -0
  29. package/dist/cli/commands/derive.d.ts.map +1 -0
  30. package/dist/cli/commands/derive.js +53 -0
  31. package/dist/cli/commands/derive.js.map +1 -0
  32. package/dist/cli/commands/engine.d.ts +25 -0
  33. package/dist/cli/commands/engine.d.ts.map +1 -0
  34. package/dist/cli/commands/engine.js +107 -0
  35. package/dist/cli/commands/engine.js.map +1 -0
  36. package/dist/cli/commands/erase.d.ts +17 -0
  37. package/dist/cli/commands/erase.d.ts.map +1 -0
  38. package/dist/cli/commands/erase.js +117 -0
  39. package/dist/cli/commands/erase.js.map +1 -0
  40. package/dist/cli/commands/facts-run.d.ts +30 -0
  41. package/dist/cli/commands/facts-run.d.ts.map +1 -0
  42. package/dist/cli/commands/facts-run.js +409 -0
  43. package/dist/cli/commands/facts-run.js.map +1 -0
  44. package/dist/cli/commands/facts-scaffold.d.ts +22 -0
  45. package/dist/cli/commands/facts-scaffold.d.ts.map +1 -0
  46. package/dist/cli/commands/facts-scaffold.js +208 -0
  47. package/dist/cli/commands/facts-scaffold.js.map +1 -0
  48. package/dist/cli/commands/init.d.ts +18 -0
  49. package/dist/cli/commands/init.d.ts.map +1 -0
  50. package/dist/cli/commands/init.js +34 -0
  51. package/dist/cli/commands/init.js.map +1 -0
  52. package/dist/cli/commands/login.d.ts +9 -0
  53. package/dist/cli/commands/login.d.ts.map +1 -0
  54. package/dist/cli/commands/login.js +16 -0
  55. package/dist/cli/commands/login.js.map +1 -0
  56. package/dist/cli/commands/logout.d.ts +10 -0
  57. package/dist/cli/commands/logout.d.ts.map +1 -0
  58. package/dist/cli/commands/logout.js +28 -0
  59. package/dist/cli/commands/logout.js.map +1 -0
  60. package/dist/cli/commands/manifest.d.ts +12 -0
  61. package/dist/cli/commands/manifest.d.ts.map +1 -0
  62. package/dist/cli/commands/manifest.js +48 -0
  63. package/dist/cli/commands/manifest.js.map +1 -0
  64. package/dist/cli/commands/oracle-init.d.ts +48 -0
  65. package/dist/cli/commands/oracle-init.d.ts.map +1 -0
  66. package/dist/cli/commands/oracle-init.js +1122 -0
  67. package/dist/cli/commands/oracle-init.js.map +1 -0
  68. package/dist/cli/commands/org.d.ts +28 -0
  69. package/dist/cli/commands/org.d.ts.map +1 -0
  70. package/dist/cli/commands/org.js +309 -0
  71. package/dist/cli/commands/org.js.map +1 -0
  72. package/dist/cli/commands/protocol-review.d.ts +20 -0
  73. package/dist/cli/commands/protocol-review.d.ts.map +1 -0
  74. package/dist/cli/commands/protocol-review.js +162 -0
  75. package/dist/cli/commands/protocol-review.js.map +1 -0
  76. package/dist/cli/commands/publish-protocol.d.ts +43 -0
  77. package/dist/cli/commands/publish-protocol.d.ts.map +1 -0
  78. package/dist/cli/commands/publish-protocol.js +345 -0
  79. package/dist/cli/commands/publish-protocol.js.map +1 -0
  80. package/dist/cli/commands/register.d.ts +16 -0
  81. package/dist/cli/commands/register.d.ts.map +1 -0
  82. package/dist/cli/commands/register.js +54 -0
  83. package/dist/cli/commands/register.js.map +1 -0
  84. package/dist/cli/commands/relink.d.ts +11 -0
  85. package/dist/cli/commands/relink.d.ts.map +1 -0
  86. package/dist/cli/commands/relink.js +36 -0
  87. package/dist/cli/commands/relink.js.map +1 -0
  88. package/dist/cli/commands/rubric-fetch-form.d.ts +16 -0
  89. package/dist/cli/commands/rubric-fetch-form.d.ts.map +1 -0
  90. package/dist/cli/commands/rubric-fetch-form.js +83 -0
  91. package/dist/cli/commands/rubric-fetch-form.js.map +1 -0
  92. package/dist/cli/commands/rubric-validate.d.ts +72 -0
  93. package/dist/cli/commands/rubric-validate.d.ts.map +1 -0
  94. package/dist/cli/commands/rubric-validate.js +163 -0
  95. package/dist/cli/commands/rubric-validate.js.map +1 -0
  96. package/dist/cli/commands/scan.d.ts +13 -0
  97. package/dist/cli/commands/scan.d.ts.map +1 -0
  98. package/dist/cli/commands/scan.js +39 -0
  99. package/dist/cli/commands/scan.js.map +1 -0
  100. package/dist/cli/commands/skills.d.ts +11 -0
  101. package/dist/cli/commands/skills.d.ts.map +1 -0
  102. package/dist/cli/commands/skills.js +19 -0
  103. package/dist/cli/commands/skills.js.map +1 -0
  104. package/dist/cli/commands/submit-claim.d.ts +25 -0
  105. package/dist/cli/commands/submit-claim.d.ts.map +1 -0
  106. package/dist/cli/commands/submit-claim.js +155 -0
  107. package/dist/cli/commands/submit-claim.js.map +1 -0
  108. package/dist/cli/index.d.ts +15 -0
  109. package/dist/cli/index.d.ts.map +1 -0
  110. package/dist/cli/index.js +206 -0
  111. package/dist/cli/index.js.map +1 -0
  112. package/dist/cli/lib/agent-card-schema.d.ts +8 -0
  113. package/dist/cli/lib/agent-card-schema.d.ts.map +1 -0
  114. package/dist/cli/lib/agent-card-schema.js +169 -0
  115. package/dist/cli/lib/agent-card-schema.js.map +1 -0
  116. package/dist/cli/lib/ai-rest.d.ts +12 -0
  117. package/dist/cli/lib/ai-rest.d.ts.map +1 -0
  118. package/dist/cli/lib/ai-rest.js +36 -0
  119. package/dist/cli/lib/ai-rest.js.map +1 -0
  120. package/dist/cli/lib/args.d.ts +33 -0
  121. package/dist/cli/lib/args.d.ts.map +1 -0
  122. package/dist/cli/lib/args.js +24 -0
  123. package/dist/cli/lib/args.js.map +1 -0
  124. package/dist/cli/lib/authhub.d.ts +7 -0
  125. package/dist/cli/lib/authhub.d.ts.map +1 -0
  126. package/dist/cli/lib/authhub.js +210 -0
  127. package/dist/cli/lib/authhub.js.map +1 -0
  128. package/dist/cli/lib/chain.d.ts +264 -0
  129. package/dist/cli/lib/chain.d.ts.map +1 -0
  130. package/dist/cli/lib/chain.js +584 -0
  131. package/dist/cli/lib/chain.js.map +1 -0
  132. package/dist/cli/lib/devvars.d.ts +59 -0
  133. package/dist/cli/lib/devvars.d.ts.map +1 -0
  134. package/dist/cli/lib/devvars.js +206 -0
  135. package/dist/cli/lib/devvars.js.map +1 -0
  136. package/dist/cli/lib/engine.d.ts +54 -0
  137. package/dist/cli/lib/engine.d.ts.map +1 -0
  138. package/dist/cli/lib/engine.js +112 -0
  139. package/dist/cli/lib/engine.js.map +1 -0
  140. package/dist/cli/lib/identity-cards.d.ts +188 -0
  141. package/dist/cli/lib/identity-cards.d.ts.map +1 -0
  142. package/dist/cli/lib/identity-cards.js +261 -0
  143. package/dist/cli/lib/identity-cards.js.map +1 -0
  144. package/dist/cli/lib/matrix-account.d.ts +79 -0
  145. package/dist/cli/lib/matrix-account.d.ts.map +1 -0
  146. package/dist/cli/lib/matrix-account.js +228 -0
  147. package/dist/cli/lib/matrix-account.js.map +1 -0
  148. package/dist/cli/lib/oracle-account.d.ts +108 -0
  149. package/dist/cli/lib/oracle-account.d.ts.map +1 -0
  150. package/dist/cli/lib/oracle-account.js +207 -0
  151. package/dist/cli/lib/oracle-account.js.map +1 -0
  152. package/dist/cli/lib/project.d.ts +22 -0
  153. package/dist/cli/lib/project.d.ts.map +1 -0
  154. package/dist/cli/lib/project.js +62 -0
  155. package/dist/cli/lib/project.js.map +1 -0
  156. package/dist/cli/lib/session.d.ts +109 -0
  157. package/dist/cli/lib/session.d.ts.map +1 -0
  158. package/dist/cli/lib/session.js +354 -0
  159. package/dist/cli/lib/session.js.map +1 -0
  160. package/dist/cli/lib/workorder.d.ts +57 -0
  161. package/dist/cli/lib/workorder.d.ts.map +1 -0
  162. package/dist/cli/lib/workorder.js +101 -0
  163. package/dist/cli/lib/workorder.js.map +1 -0
  164. package/dist/config.d.ts +221 -0
  165. package/dist/config.d.ts.map +1 -0
  166. package/dist/config.js +431 -0
  167. package/dist/config.js.map +1 -0
  168. package/dist/context.d.ts +88 -0
  169. package/dist/context.d.ts.map +1 -0
  170. package/dist/context.js +9 -0
  171. package/dist/context.js.map +1 -0
  172. package/dist/contracts/api.d.ts +3367 -0
  173. package/dist/contracts/api.d.ts.map +1 -0
  174. package/dist/contracts/api.js +1303 -0
  175. package/dist/contracts/api.js.map +1 -0
  176. package/dist/contracts/capabilities.d.ts +126 -0
  177. package/dist/contracts/capabilities.d.ts.map +1 -0
  178. package/dist/contracts/capabilities.js +164 -0
  179. package/dist/contracts/capabilities.js.map +1 -0
  180. package/dist/contracts/claim-source.d.ts +98 -0
  181. package/dist/contracts/claim-source.d.ts.map +1 -0
  182. package/dist/contracts/claim-source.js +17 -0
  183. package/dist/contracts/claim-source.js.map +1 -0
  184. package/dist/contracts/errors.d.ts +150 -0
  185. package/dist/contracts/errors.d.ts.map +1 -0
  186. package/dist/contracts/errors.js +121 -0
  187. package/dist/contracts/errors.js.map +1 -0
  188. package/dist/contracts/index.d.ts +15 -0
  189. package/dist/contracts/index.d.ts.map +1 -0
  190. package/dist/contracts/index.js +11 -0
  191. package/dist/contracts/index.js.map +1 -0
  192. package/dist/contracts/payment-gate.d.ts +129 -0
  193. package/dist/contracts/payment-gate.d.ts.map +1 -0
  194. package/dist/contracts/payment-gate.js +24 -0
  195. package/dist/contracts/payment-gate.js.map +1 -0
  196. package/dist/contracts/start-api-claim.d.ts +90 -0
  197. package/dist/contracts/start-api-claim.d.ts.map +1 -0
  198. package/dist/contracts/start-api-claim.js +22 -0
  199. package/dist/contracts/start-api-claim.js.map +1 -0
  200. package/dist/contracts/webhooks.d.ts +1487 -0
  201. package/dist/contracts/webhooks.d.ts.map +1 -0
  202. package/dist/contracts/webhooks.js +71 -0
  203. package/dist/contracts/webhooks.js.map +1 -0
  204. package/dist/contracts/work-order.d.ts +29 -0
  205. package/dist/contracts/work-order.d.ts.map +1 -0
  206. package/dist/contracts/work-order.js +12 -0
  207. package/dist/contracts/work-order.js.map +1 -0
  208. package/dist/cron/ai-cost.d.ts +29 -0
  209. package/dist/cron/ai-cost.d.ts.map +1 -0
  210. package/dist/cron/ai-cost.js +80 -0
  211. package/dist/cron/ai-cost.js.map +1 -0
  212. package/dist/cron/api-lane.d.ts +39 -0
  213. package/dist/cron/api-lane.d.ts.map +1 -0
  214. package/dist/cron/api-lane.js +203 -0
  215. package/dist/cron/api-lane.js.map +1 -0
  216. package/dist/cron/backlog.d.ts +50 -0
  217. package/dist/cron/backlog.d.ts.map +1 -0
  218. package/dist/cron/backlog.js +115 -0
  219. package/dist/cron/backlog.js.map +1 -0
  220. package/dist/cron/billing.d.ts +11 -0
  221. package/dist/cron/billing.d.ts.map +1 -0
  222. package/dist/cron/billing.js +69 -0
  223. package/dist/cron/billing.js.map +1 -0
  224. package/dist/cron/collection.d.ts +50 -0
  225. package/dist/cron/collection.d.ts.map +1 -0
  226. package/dist/cron/collection.js +118 -0
  227. package/dist/cron/collection.js.map +1 -0
  228. package/dist/cron/funding.d.ts +16 -0
  229. package/dist/cron/funding.d.ts.map +1 -0
  230. package/dist/cron/funding.js +262 -0
  231. package/dist/cron/funding.js.map +1 -0
  232. package/dist/cron/payer-billing.d.ts +38 -0
  233. package/dist/cron/payer-billing.d.ts.map +1 -0
  234. package/dist/cron/payer-billing.js +119 -0
  235. package/dist/cron/payer-billing.js.map +1 -0
  236. package/dist/cron/scan.d.ts +43 -0
  237. package/dist/cron/scan.d.ts.map +1 -0
  238. package/dist/cron/scan.js +250 -0
  239. package/dist/cron/scan.js.map +1 -0
  240. package/dist/db/client.d.ts +14 -0
  241. package/dist/db/client.d.ts.map +1 -0
  242. package/dist/db/client.js +14 -0
  243. package/dist/db/client.js.map +1 -0
  244. package/dist/db/index.d.ts +7 -0
  245. package/dist/db/index.d.ts.map +1 -0
  246. package/dist/db/index.js +7 -0
  247. package/dist/db/index.js.map +1 -0
  248. package/dist/db/schema.d.ts +6738 -0
  249. package/dist/db/schema.d.ts.map +1 -0
  250. package/dist/db/schema.js +1433 -0
  251. package/dist/db/schema.js.map +1 -0
  252. package/dist/define-oracle.d.ts +32 -0
  253. package/dist/define-oracle.d.ts.map +1 -0
  254. package/dist/define-oracle.js +80 -0
  255. package/dist/define-oracle.js.map +1 -0
  256. package/dist/dev-oracle.d.ts +9 -0
  257. package/dist/dev-oracle.d.ts.map +1 -0
  258. package/dist/dev-oracle.js +19 -0
  259. package/dist/dev-oracle.js.map +1 -0
  260. package/dist/dev-worker.d.ts +10 -0
  261. package/dist/dev-worker.d.ts.map +1 -0
  262. package/dist/dev-worker.js +12 -0
  263. package/dist/dev-worker.js.map +1 -0
  264. package/dist/env.d.ts +146 -0
  265. package/dist/env.d.ts.map +1 -0
  266. package/dist/env.js +10 -0
  267. package/dist/env.js.map +1 -0
  268. package/dist/facts/exif.d.ts +43 -0
  269. package/dist/facts/exif.d.ts.map +1 -0
  270. package/dist/facts/exif.js +224 -0
  271. package/dist/facts/exif.js.map +1 -0
  272. package/dist/facts/fact.d.ts +62 -0
  273. package/dist/facts/fact.d.ts.map +1 -0
  274. package/dist/facts/fact.js +105 -0
  275. package/dist/facts/fact.js.map +1 -0
  276. package/dist/facts/geo.d.ts +55 -0
  277. package/dist/facts/geo.d.ts.map +1 -0
  278. package/dist/facts/geo.js +267 -0
  279. package/dist/facts/geo.js.map +1 -0
  280. package/dist/facts/index.d.ts +31 -0
  281. package/dist/facts/index.d.ts.map +1 -0
  282. package/dist/facts/index.js +27 -0
  283. package/dist/facts/index.js.map +1 -0
  284. package/dist/facts/linked-doc.d.ts +60 -0
  285. package/dist/facts/linked-doc.d.ts.map +1 -0
  286. package/dist/facts/linked-doc.js +101 -0
  287. package/dist/facts/linked-doc.js.map +1 -0
  288. package/dist/facts/types.d.ts +278 -0
  289. package/dist/facts/types.d.ts.map +1 -0
  290. package/dist/facts/types.js +19 -0
  291. package/dist/facts/types.js.map +1 -0
  292. package/dist/index.d.ts +25 -0
  293. package/dist/index.d.ts.map +1 -0
  294. package/dist/index.js +19 -0
  295. package/dist/index.js.map +1 -0
  296. package/dist/lib/api-lane/accept.d.ts +29 -0
  297. package/dist/lib/api-lane/accept.d.ts.map +1 -0
  298. package/dist/lib/api-lane/accept.js +218 -0
  299. package/dist/lib/api-lane/accept.js.map +1 -0
  300. package/dist/lib/api-lane/claim-list.d.ts +44 -0
  301. package/dist/lib/api-lane/claim-list.d.ts.map +1 -0
  302. package/dist/lib/api-lane/claim-list.js +92 -0
  303. package/dist/lib/api-lane/claim-list.js.map +1 -0
  304. package/dist/lib/api-lane/company.d.ts +56 -0
  305. package/dist/lib/api-lane/company.d.ts.map +1 -0
  306. package/dist/lib/api-lane/company.js +103 -0
  307. package/dist/lib/api-lane/company.js.map +1 -0
  308. package/dist/lib/api-lane/events.d.ts +21 -0
  309. package/dist/lib/api-lane/events.d.ts.map +1 -0
  310. package/dist/lib/api-lane/events.js +111 -0
  311. package/dist/lib/api-lane/events.js.map +1 -0
  312. package/dist/lib/api-lane/ids.d.ts +39 -0
  313. package/dist/lib/api-lane/ids.d.ts.map +1 -0
  314. package/dist/lib/api-lane/ids.js +78 -0
  315. package/dist/lib/api-lane/ids.js.map +1 -0
  316. package/dist/lib/api-lane/index.d.ts +16 -0
  317. package/dist/lib/api-lane/index.d.ts.map +1 -0
  318. package/dist/lib/api-lane/index.js +16 -0
  319. package/dist/lib/api-lane/index.js.map +1 -0
  320. package/dist/lib/api-lane/linked.d.ts +264 -0
  321. package/dist/lib/api-lane/linked.d.ts.map +1 -0
  322. package/dist/lib/api-lane/linked.js +272 -0
  323. package/dist/lib/api-lane/linked.js.map +1 -0
  324. package/dist/lib/api-lane/media-type.d.ts +15 -0
  325. package/dist/lib/api-lane/media-type.d.ts.map +1 -0
  326. package/dist/lib/api-lane/media-type.js +73 -0
  327. package/dist/lib/api-lane/media-type.js.map +1 -0
  328. package/dist/lib/api-lane/member-emails.d.ts +83 -0
  329. package/dist/lib/api-lane/member-emails.d.ts.map +1 -0
  330. package/dist/lib/api-lane/member-emails.js +213 -0
  331. package/dist/lib/api-lane/member-emails.js.map +1 -0
  332. package/dist/lib/api-lane/members.d.ts +42 -0
  333. package/dist/lib/api-lane/members.d.ts.map +1 -0
  334. package/dist/lib/api-lane/members.js +75 -0
  335. package/dist/lib/api-lane/members.js.map +1 -0
  336. package/dist/lib/api-lane/notify.d.ts +47 -0
  337. package/dist/lib/api-lane/notify.d.ts.map +1 -0
  338. package/dist/lib/api-lane/notify.js +240 -0
  339. package/dist/lib/api-lane/notify.js.map +1 -0
  340. package/dist/lib/api-lane/pause.d.ts +41 -0
  341. package/dist/lib/api-lane/pause.d.ts.map +1 -0
  342. package/dist/lib/api-lane/pause.js +155 -0
  343. package/dist/lib/api-lane/pause.js.map +1 -0
  344. package/dist/lib/api-lane/record.d.ts +76 -0
  345. package/dist/lib/api-lane/record.d.ts.map +1 -0
  346. package/dist/lib/api-lane/record.js +337 -0
  347. package/dist/lib/api-lane/record.js.map +1 -0
  348. package/dist/lib/api-lane/retention.d.ts +43 -0
  349. package/dist/lib/api-lane/retention.d.ts.map +1 -0
  350. package/dist/lib/api-lane/retention.js +176 -0
  351. package/dist/lib/api-lane/retention.js.map +1 -0
  352. package/dist/lib/api-lane/review.d.ts +76 -0
  353. package/dist/lib/api-lane/review.d.ts.map +1 -0
  354. package/dist/lib/api-lane/review.js +355 -0
  355. package/dist/lib/api-lane/review.js.map +1 -0
  356. package/dist/lib/api-lane/reviewers.d.ts +109 -0
  357. package/dist/lib/api-lane/reviewers.d.ts.map +1 -0
  358. package/dist/lib/api-lane/reviewers.js +755 -0
  359. package/dist/lib/api-lane/reviewers.js.map +1 -0
  360. package/dist/lib/api-lane/source-delete.d.ts +16 -0
  361. package/dist/lib/api-lane/source-delete.d.ts.map +1 -0
  362. package/dist/lib/api-lane/source-delete.js +50 -0
  363. package/dist/lib/api-lane/source-delete.js.map +1 -0
  364. package/dist/lib/api-lane/source.d.ts +19 -0
  365. package/dist/lib/api-lane/source.d.ts.map +1 -0
  366. package/dist/lib/api-lane/source.js +226 -0
  367. package/dist/lib/api-lane/source.js.map +1 -0
  368. package/dist/lib/api-lane/submitter.d.ts +22 -0
  369. package/dist/lib/api-lane/submitter.d.ts.map +1 -0
  370. package/dist/lib/api-lane/submitter.js +34 -0
  371. package/dist/lib/api-lane/submitter.js.map +1 -0
  372. package/dist/lib/api-lane/timeline.d.ts +20 -0
  373. package/dist/lib/api-lane/timeline.d.ts.map +1 -0
  374. package/dist/lib/api-lane/timeline.js +23 -0
  375. package/dist/lib/api-lane/timeline.js.map +1 -0
  376. package/dist/lib/api-lane/webhook-crypto.d.ts +44 -0
  377. package/dist/lib/api-lane/webhook-crypto.d.ts.map +1 -0
  378. package/dist/lib/api-lane/webhook-crypto.js +103 -0
  379. package/dist/lib/api-lane/webhook-crypto.js.map +1 -0
  380. package/dist/lib/api-lane/webhooks.d.ts +117 -0
  381. package/dist/lib/api-lane/webhooks.d.ts.map +1 -0
  382. package/dist/lib/api-lane/webhooks.js +503 -0
  383. package/dist/lib/api-lane/webhooks.js.map +1 -0
  384. package/dist/lib/archive.d.ts +64 -0
  385. package/dist/lib/archive.d.ts.map +1 -0
  386. package/dist/lib/archive.js +305 -0
  387. package/dist/lib/archive.js.map +1 -0
  388. package/dist/lib/bech32.d.ts +8 -0
  389. package/dist/lib/bech32.d.ts.map +1 -0
  390. package/dist/lib/bech32.js +39 -0
  391. package/dist/lib/bech32.js.map +1 -0
  392. package/dist/lib/claim-erase.d.ts +22 -0
  393. package/dist/lib/claim-erase.d.ts.map +1 -0
  394. package/dist/lib/claim-erase.js +44 -0
  395. package/dist/lib/claim-erase.js.map +1 -0
  396. package/dist/lib/cursor.d.ts +11 -0
  397. package/dist/lib/cursor.d.ts.map +1 -0
  398. package/dist/lib/cursor.js +20 -0
  399. package/dist/lib/cursor.js.map +1 -0
  400. package/dist/lib/email/send.d.ts +43 -0
  401. package/dist/lib/email/send.d.ts.map +1 -0
  402. package/dist/lib/email/send.js +71 -0
  403. package/dist/lib/email/send.js.map +1 -0
  404. package/dist/lib/email/template.d.ts +217 -0
  405. package/dist/lib/email/template.d.ts.map +1 -0
  406. package/dist/lib/email/template.js +713 -0
  407. package/dist/lib/email/template.js.map +1 -0
  408. package/dist/lib/engine/adr36.d.ts +56 -0
  409. package/dist/lib/engine/adr36.d.ts.map +1 -0
  410. package/dist/lib/engine/adr36.js +76 -0
  411. package/dist/lib/engine/adr36.js.map +1 -0
  412. package/dist/lib/engine/client.d.ts +162 -0
  413. package/dist/lib/engine/client.d.ts.map +1 -0
  414. package/dist/lib/engine/client.js +473 -0
  415. package/dist/lib/engine/client.js.map +1 -0
  416. package/dist/lib/engine/types.d.ts +1356 -0
  417. package/dist/lib/engine/types.d.ts.map +1 -0
  418. package/dist/lib/engine/types.js +562 -0
  419. package/dist/lib/engine/types.js.map +1 -0
  420. package/dist/lib/errors.d.ts +73 -0
  421. package/dist/lib/errors.d.ts.map +1 -0
  422. package/dist/lib/errors.js +96 -0
  423. package/dist/lib/errors.js.map +1 -0
  424. package/dist/lib/facts/builder.d.ts +88 -0
  425. package/dist/lib/facts/builder.d.ts.map +1 -0
  426. package/dist/lib/facts/builder.js +239 -0
  427. package/dist/lib/facts/builder.js.map +1 -0
  428. package/dist/lib/facts/ctx.d.ts +34 -0
  429. package/dist/lib/facts/ctx.d.ts.map +1 -0
  430. package/dist/lib/facts/ctx.js +51 -0
  431. package/dist/lib/facts/ctx.js.map +1 -0
  432. package/dist/lib/facts/expected.d.ts +23 -0
  433. package/dist/lib/facts/expected.d.ts.map +1 -0
  434. package/dist/lib/facts/expected.js +16 -0
  435. package/dist/lib/facts/expected.js.map +1 -0
  436. package/dist/lib/facts/fact-cache.d.ts +469 -0
  437. package/dist/lib/facts/fact-cache.d.ts.map +1 -0
  438. package/dist/lib/facts/fact-cache.js +52 -0
  439. package/dist/lib/facts/fact-cache.js.map +1 -0
  440. package/dist/lib/facts/factset.d.ts +608 -0
  441. package/dist/lib/facts/factset.d.ts.map +1 -0
  442. package/dist/lib/facts/factset.js +226 -0
  443. package/dist/lib/facts/factset.js.map +1 -0
  444. package/dist/lib/facts/producer.d.ts +190 -0
  445. package/dist/lib/facts/producer.d.ts.map +1 -0
  446. package/dist/lib/facts/producer.js +15 -0
  447. package/dist/lib/facts/producer.js.map +1 -0
  448. package/dist/lib/facts/runner.d.ts +111 -0
  449. package/dist/lib/facts/runner.d.ts.map +1 -0
  450. package/dist/lib/facts/runner.js +438 -0
  451. package/dist/lib/facts/runner.js.map +1 -0
  452. package/dist/lib/facts/stock/ai-check.d.ts +100 -0
  453. package/dist/lib/facts/stock/ai-check.d.ts.map +1 -0
  454. package/dist/lib/facts/stock/ai-check.js +526 -0
  455. package/dist/lib/facts/stock/ai-check.js.map +1 -0
  456. package/dist/lib/facts/stock/ai-inputs.d.ts +104 -0
  457. package/dist/lib/facts/stock/ai-inputs.d.ts.map +1 -0
  458. package/dist/lib/facts/stock/ai-inputs.js +332 -0
  459. package/dist/lib/facts/stock/ai-inputs.js.map +1 -0
  460. package/dist/lib/facts/stock/ai-provider.d.ts +105 -0
  461. package/dist/lib/facts/stock/ai-provider.d.ts.map +1 -0
  462. package/dist/lib/facts/stock/ai-provider.js +250 -0
  463. package/dist/lib/facts/stock/ai-provider.js.map +1 -0
  464. package/dist/lib/facts/stock/ai-unique.d.ts +85 -0
  465. package/dist/lib/facts/stock/ai-unique.d.ts.map +1 -0
  466. package/dist/lib/facts/stock/ai-unique.js +208 -0
  467. package/dist/lib/facts/stock/ai-unique.js.map +1 -0
  468. package/dist/lib/facts/stock/archive.d.ts +63 -0
  469. package/dist/lib/facts/stock/archive.d.ts.map +1 -0
  470. package/dist/lib/facts/stock/archive.js +349 -0
  471. package/dist/lib/facts/stock/archive.js.map +1 -0
  472. package/dist/lib/facts/stock/c2pa-trust-list.d.ts +16 -0
  473. package/dist/lib/facts/stock/c2pa-trust-list.d.ts.map +1 -0
  474. package/dist/lib/facts/stock/c2pa-trust-list.js +637 -0
  475. package/dist/lib/facts/stock/c2pa-trust-list.js.map +1 -0
  476. package/dist/lib/facts/stock/c2pa.d.ts +56 -0
  477. package/dist/lib/facts/stock/c2pa.d.ts.map +1 -0
  478. package/dist/lib/facts/stock/c2pa.js +234 -0
  479. package/dist/lib/facts/stock/c2pa.js.map +1 -0
  480. package/dist/lib/facts/stock/call.d.ts +91 -0
  481. package/dist/lib/facts/stock/call.d.ts.map +1 -0
  482. package/dist/lib/facts/stock/call.js +281 -0
  483. package/dist/lib/facts/stock/call.js.map +1 -0
  484. package/dist/lib/facts/stock/capability.d.ts +39 -0
  485. package/dist/lib/facts/stock/capability.d.ts.map +1 -0
  486. package/dist/lib/facts/stock/capability.js +59 -0
  487. package/dist/lib/facts/stock/capability.js.map +1 -0
  488. package/dist/lib/facts/stock/ext-source.d.ts +51 -0
  489. package/dist/lib/facts/stock/ext-source.d.ts.map +1 -0
  490. package/dist/lib/facts/stock/ext-source.js +201 -0
  491. package/dist/lib/facts/stock/ext-source.js.map +1 -0
  492. package/dist/lib/facts/stock/frequency-fact.d.ts +59 -0
  493. package/dist/lib/facts/stock/frequency-fact.d.ts.map +1 -0
  494. package/dist/lib/facts/stock/frequency-fact.js +86 -0
  495. package/dist/lib/facts/stock/frequency-fact.js.map +1 -0
  496. package/dist/lib/facts/stock/frequency.d.ts +32 -0
  497. package/dist/lib/facts/stock/frequency.d.ts.map +1 -0
  498. package/dist/lib/facts/stock/frequency.js +48 -0
  499. package/dist/lib/facts/stock/frequency.js.map +1 -0
  500. package/dist/lib/facts/stock/index.d.ts +27 -0
  501. package/dist/lib/facts/stock/index.d.ts.map +1 -0
  502. package/dist/lib/facts/stock/index.js +28 -0
  503. package/dist/lib/facts/stock/index.js.map +1 -0
  504. package/dist/lib/facts/stock/normalize.d.ts +45 -0
  505. package/dist/lib/facts/stock/normalize.d.ts.map +1 -0
  506. package/dist/lib/facts/stock/normalize.js +135 -0
  507. package/dist/lib/facts/stock/normalize.js.map +1 -0
  508. package/dist/lib/facts/stock/phash.d.ts +55 -0
  509. package/dist/lib/facts/stock/phash.d.ts.map +1 -0
  510. package/dist/lib/facts/stock/phash.js +256 -0
  511. package/dist/lib/facts/stock/phash.js.map +1 -0
  512. package/dist/lib/facts/stock/rule-defaults.d.ts +72 -0
  513. package/dist/lib/facts/stock/rule-defaults.d.ts.map +1 -0
  514. package/dist/lib/facts/stock/rule-defaults.js +55 -0
  515. package/dist/lib/facts/stock/rule-defaults.js.map +1 -0
  516. package/dist/lib/facts/stock/send.d.ts +52 -0
  517. package/dist/lib/facts/stock/send.d.ts.map +1 -0
  518. package/dist/lib/facts/stock/send.js +148 -0
  519. package/dist/lib/facts/stock/send.js.map +1 -0
  520. package/dist/lib/facts/stock/unique-score.d.ts +138 -0
  521. package/dist/lib/facts/stock/unique-score.d.ts.map +1 -0
  522. package/dist/lib/facts/stock/unique-score.js +257 -0
  523. package/dist/lib/facts/stock/unique-score.js.map +1 -0
  524. package/dist/lib/facts/stock/unique-store.d.ts +420 -0
  525. package/dist/lib/facts/stock/unique-store.d.ts.map +1 -0
  526. package/dist/lib/facts/stock/unique-store.js +328 -0
  527. package/dist/lib/facts/stock/unique-store.js.map +1 -0
  528. package/dist/lib/facts/stock/unique.d.ts +35 -0
  529. package/dist/lib/facts/stock/unique.d.ts.map +1 -0
  530. package/dist/lib/facts/stock/unique.js +327 -0
  531. package/dist/lib/facts/stock/unique.js.map +1 -0
  532. package/dist/lib/facts/tools.d.ts +57 -0
  533. package/dist/lib/facts/tools.d.ts.map +1 -0
  534. package/dist/lib/facts/tools.js +325 -0
  535. package/dist/lib/facts/tools.js.map +1 -0
  536. package/dist/lib/facts/validate.d.ts +33 -0
  537. package/dist/lib/facts/validate.d.ts.map +1 -0
  538. package/dist/lib/facts/validate.js +137 -0
  539. package/dist/lib/facts/validate.js.map +1 -0
  540. package/dist/lib/hash.d.ts +44 -0
  541. package/dist/lib/hash.d.ts.map +1 -0
  542. package/dist/lib/hash.js +80 -0
  543. package/dist/lib/hash.js.map +1 -0
  544. package/dist/lib/http/client.d.ts +113 -0
  545. package/dist/lib/http/client.d.ts.map +1 -0
  546. package/dist/lib/http/client.js +330 -0
  547. package/dist/lib/http/client.js.map +1 -0
  548. package/dist/lib/ids.d.ts +17 -0
  549. package/dist/lib/ids.d.ts.map +1 -0
  550. package/dist/lib/ids.js +26 -0
  551. package/dist/lib/ids.js.map +1 -0
  552. package/dist/lib/ixo/attachments.d.ts +116 -0
  553. package/dist/lib/ixo/attachments.d.ts.map +1 -0
  554. package/dist/lib/ixo/attachments.js +290 -0
  555. package/dist/lib/ixo/attachments.js.map +1 -0
  556. package/dist/lib/ixo/authz.d.ts +40 -0
  557. package/dist/lib/ixo/authz.d.ts.map +1 -0
  558. package/dist/lib/ixo/authz.js +113 -0
  559. package/dist/lib/ixo/authz.js.map +1 -0
  560. package/dist/lib/ixo/blocksync/index.d.ts +90 -0
  561. package/dist/lib/ixo/blocksync/index.d.ts.map +1 -0
  562. package/dist/lib/ixo/blocksync/index.js +251 -0
  563. package/dist/lib/ixo/blocksync/index.js.map +1 -0
  564. package/dist/lib/ixo/blocksync/queries.d.ts +15 -0
  565. package/dist/lib/ixo/blocksync/queries.d.ts.map +1 -0
  566. package/dist/lib/ixo/blocksync/queries.js +144 -0
  567. package/dist/lib/ixo/blocksync/queries.js.map +1 -0
  568. package/dist/lib/ixo/blocksync/types.d.ts +184 -0
  569. package/dist/lib/ixo/blocksync/types.d.ts.map +1 -0
  570. package/dist/lib/ixo/blocksync/types.js +108 -0
  571. package/dist/lib/ixo/blocksync/types.js.map +1 -0
  572. package/dist/lib/ixo/cellnode.d.ts +35 -0
  573. package/dist/lib/ixo/cellnode.d.ts.map +1 -0
  574. package/dist/lib/ixo/cellnode.js +43 -0
  575. package/dist/lib/ixo/cellnode.js.map +1 -0
  576. package/dist/lib/ixo/chain-write.d.ts +130 -0
  577. package/dist/lib/ixo/chain-write.d.ts.map +1 -0
  578. package/dist/lib/ixo/chain-write.js +460 -0
  579. package/dist/lib/ixo/chain-write.js.map +1 -0
  580. package/dist/lib/ixo/chain.d.ts +1046 -0
  581. package/dist/lib/ixo/chain.d.ts.map +1 -0
  582. package/dist/lib/ixo/chain.js +279 -0
  583. package/dist/lib/ixo/chain.js.map +1 -0
  584. package/dist/lib/ixo/claim-bot.d.ts +49 -0
  585. package/dist/lib/ixo/claim-bot.d.ts.map +1 -0
  586. package/dist/lib/ixo/claim-bot.js +141 -0
  587. package/dist/lib/ixo/claim-bot.js.map +1 -0
  588. package/dist/lib/ixo/delegation-verify.d.ts +44 -0
  589. package/dist/lib/ixo/delegation-verify.d.ts.map +1 -0
  590. package/dist/lib/ixo/delegation-verify.js +101 -0
  591. package/dist/lib/ixo/delegation-verify.js.map +1 -0
  592. package/dist/lib/ixo/did.d.ts +13 -0
  593. package/dist/lib/ixo/did.d.ts.map +1 -0
  594. package/dist/lib/ixo/did.js +85 -0
  595. package/dist/lib/ixo/did.js.map +1 -0
  596. package/dist/lib/ixo/grant-chain.d.ts +55 -0
  597. package/dist/lib/ixo/grant-chain.d.ts.map +1 -0
  598. package/dist/lib/ixo/grant-chain.js +185 -0
  599. package/dist/lib/ixo/grant-chain.js.map +1 -0
  600. package/dist/lib/ixo/identity.d.ts +32 -0
  601. package/dist/lib/ixo/identity.d.ts.map +1 -0
  602. package/dist/lib/ixo/identity.js +104 -0
  603. package/dist/lib/ixo/identity.js.map +1 -0
  604. package/dist/lib/ixo/index.d.ts +118 -0
  605. package/dist/lib/ixo/index.d.ts.map +1 -0
  606. package/dist/lib/ixo/index.js +395 -0
  607. package/dist/lib/ixo/index.js.map +1 -0
  608. package/dist/lib/ixo/payment.d.ts +104 -0
  609. package/dist/lib/ixo/payment.d.ts.map +1 -0
  610. package/dist/lib/ixo/payment.js +136 -0
  611. package/dist/lib/ixo/payment.js.map +1 -0
  612. package/dist/lib/ixo/ucan-store.d.ts +30 -0
  613. package/dist/lib/ixo/ucan-store.d.ts.map +1 -0
  614. package/dist/lib/ixo/ucan-store.js +134 -0
  615. package/dist/lib/ixo/ucan-store.js.map +1 -0
  616. package/dist/lib/ixo/ucan.d.ts +96 -0
  617. package/dist/lib/ixo/ucan.d.ts.map +1 -0
  618. package/dist/lib/ixo/ucan.js +216 -0
  619. package/dist/lib/ixo/ucan.js.map +1 -0
  620. package/dist/lib/ixo/verified-read.d.ts +43 -0
  621. package/dist/lib/ixo/verified-read.d.ts.map +1 -0
  622. package/dist/lib/ixo/verified-read.js +73 -0
  623. package/dist/lib/ixo/verified-read.js.map +1 -0
  624. package/dist/lib/ixo/vfs.d.ts +27 -0
  625. package/dist/lib/ixo/vfs.d.ts.map +1 -0
  626. package/dist/lib/ixo/vfs.js +42 -0
  627. package/dist/lib/ixo/vfs.js.map +1 -0
  628. package/dist/lib/ixo/web-did.d.ts +7 -0
  629. package/dist/lib/ixo/web-did.d.ts.map +1 -0
  630. package/dist/lib/ixo/web-did.js +9 -0
  631. package/dist/lib/ixo/web-did.js.map +1 -0
  632. package/dist/lib/logger.d.ts +34 -0
  633. package/dist/lib/logger.d.ts.map +1 -0
  634. package/dist/lib/logger.js +126 -0
  635. package/dist/lib/logger.js.map +1 -0
  636. package/dist/lib/matrix/api.d.ts +57 -0
  637. package/dist/lib/matrix/api.d.ts.map +1 -0
  638. package/dist/lib/matrix/api.js +58 -0
  639. package/dist/lib/matrix/api.js.map +1 -0
  640. package/dist/lib/matrix/client.d.ts +41 -0
  641. package/dist/lib/matrix/client.d.ts.map +1 -0
  642. package/dist/lib/matrix/client.js +104 -0
  643. package/dist/lib/matrix/client.js.map +1 -0
  644. package/dist/lib/matrix/deliver.d.ts +224 -0
  645. package/dist/lib/matrix/deliver.d.ts.map +1 -0
  646. package/dist/lib/matrix/deliver.js +788 -0
  647. package/dist/lib/matrix/deliver.js.map +1 -0
  648. package/dist/lib/matrix/events.d.ts +114 -0
  649. package/dist/lib/matrix/events.d.ts.map +1 -0
  650. package/dist/lib/matrix/events.js +143 -0
  651. package/dist/lib/matrix/events.js.map +1 -0
  652. package/dist/lib/matrix/mxid.d.ts +24 -0
  653. package/dist/lib/matrix/mxid.d.ts.map +1 -0
  654. package/dist/lib/matrix/mxid.js +47 -0
  655. package/dist/lib/matrix/mxid.js.map +1 -0
  656. package/dist/lib/metrics.d.ts +105 -0
  657. package/dist/lib/metrics.d.ts.map +1 -0
  658. package/dist/lib/metrics.js +204 -0
  659. package/dist/lib/metrics.js.map +1 -0
  660. package/dist/lib/oauth/approvals.d.ts +160 -0
  661. package/dist/lib/oauth/approvals.d.ts.map +1 -0
  662. package/dist/lib/oauth/approvals.js +273 -0
  663. package/dist/lib/oauth/approvals.js.map +1 -0
  664. package/dist/lib/oauth/standing.d.ts +152 -0
  665. package/dist/lib/oauth/standing.d.ts.map +1 -0
  666. package/dist/lib/oauth/standing.js +299 -0
  667. package/dist/lib/oauth/standing.js.map +1 -0
  668. package/dist/lib/oauth/token.d.ts +60 -0
  669. package/dist/lib/oauth/token.d.ts.map +1 -0
  670. package/dist/lib/oauth/token.js +129 -0
  671. package/dist/lib/oauth/token.js.map +1 -0
  672. package/dist/lib/payments/extend.d.ts +42 -0
  673. package/dist/lib/payments/extend.d.ts.map +1 -0
  674. package/dist/lib/payments/extend.js +98 -0
  675. package/dist/lib/payments/extend.js.map +1 -0
  676. package/dist/lib/payments/facilitator.d.ts +220 -0
  677. package/dist/lib/payments/facilitator.d.ts.map +1 -0
  678. package/dist/lib/payments/facilitator.js +451 -0
  679. package/dist/lib/payments/facilitator.js.map +1 -0
  680. package/dist/lib/payments/gate.d.ts +207 -0
  681. package/dist/lib/payments/gate.d.ts.map +1 -0
  682. package/dist/lib/payments/gate.js +481 -0
  683. package/dist/lib/payments/gate.js.map +1 -0
  684. package/dist/lib/payments/header-seal.d.ts +33 -0
  685. package/dist/lib/payments/header-seal.d.ts.map +1 -0
  686. package/dist/lib/payments/header-seal.js +76 -0
  687. package/dist/lib/payments/header-seal.js.map +1 -0
  688. package/dist/lib/payments/index.d.ts +12 -0
  689. package/dist/lib/payments/index.d.ts.map +1 -0
  690. package/dist/lib/payments/index.js +11 -0
  691. package/dist/lib/payments/index.js.map +1 -0
  692. package/dist/lib/payments/price.d.ts +25 -0
  693. package/dist/lib/payments/price.d.ts.map +1 -0
  694. package/dist/lib/payments/price.js +43 -0
  695. package/dist/lib/payments/price.js.map +1 -0
  696. package/dist/lib/payments/reconcile.d.ts +77 -0
  697. package/dist/lib/payments/reconcile.d.ts.map +1 -0
  698. package/dist/lib/payments/reconcile.js +317 -0
  699. package/dist/lib/payments/reconcile.js.map +1 -0
  700. package/dist/lib/payments/refund.d.ts +34 -0
  701. package/dist/lib/payments/refund.d.ts.map +1 -0
  702. package/dist/lib/payments/refund.js +123 -0
  703. package/dist/lib/payments/refund.js.map +1 -0
  704. package/dist/lib/payments/review-billing.d.ts +222 -0
  705. package/dist/lib/payments/review-billing.d.ts.map +1 -0
  706. package/dist/lib/payments/review-billing.js +609 -0
  707. package/dist/lib/payments/review-billing.js.map +1 -0
  708. package/dist/lib/payments/settle.d.ts +44 -0
  709. package/dist/lib/payments/settle.d.ts.map +1 -0
  710. package/dist/lib/payments/settle.js +306 -0
  711. package/dist/lib/payments/settle.js.map +1 -0
  712. package/dist/lib/payments/terms.d.ts +27 -0
  713. package/dist/lib/payments/terms.d.ts.map +1 -0
  714. package/dist/lib/payments/terms.js +21 -0
  715. package/dist/lib/payments/terms.js.map +1 -0
  716. package/dist/lib/payouts.d.ts +20 -0
  717. package/dist/lib/payouts.d.ts.map +1 -0
  718. package/dist/lib/payouts.js +30 -0
  719. package/dist/lib/payouts.js.map +1 -0
  720. package/dist/lib/readiness.d.ts +42 -0
  721. package/dist/lib/readiness.d.ts.map +1 -0
  722. package/dist/lib/readiness.js +130 -0
  723. package/dist/lib/readiness.js.map +1 -0
  724. package/dist/lib/redact.d.ts +23 -0
  725. package/dist/lib/redact.d.ts.map +1 -0
  726. package/dist/lib/redact.js +67 -0
  727. package/dist/lib/redact.js.map +1 -0
  728. package/dist/lib/register.d.ts +85 -0
  729. package/dist/lib/register.d.ts.map +1 -0
  730. package/dist/lib/register.js +390 -0
  731. package/dist/lib/register.js.map +1 -0
  732. package/dist/lib/review/attestation.d.ts +92 -0
  733. package/dist/lib/review/attestation.d.ts.map +1 -0
  734. package/dist/lib/review/attestation.js +264 -0
  735. package/dist/lib/review/attestation.js.map +1 -0
  736. package/dist/lib/review/reviewer-grant.d.ts +146 -0
  737. package/dist/lib/review/reviewer-grant.d.ts.map +1 -0
  738. package/dist/lib/review/reviewer-grant.js +359 -0
  739. package/dist/lib/review/reviewer-grant.js.map +1 -0
  740. package/dist/lib/review/tasks.d.ts +18 -0
  741. package/dist/lib/review/tasks.d.ts.map +1 -0
  742. package/dist/lib/review/tasks.js +36 -0
  743. package/dist/lib/review/tasks.js.map +1 -0
  744. package/dist/lib/sentry.d.ts +89 -0
  745. package/dist/lib/sentry.d.ts.map +1 -0
  746. package/dist/lib/sentry.js +284 -0
  747. package/dist/lib/sentry.js.map +1 -0
  748. package/dist/lib/spans.d.ts +14 -0
  749. package/dist/lib/spans.d.ts.map +1 -0
  750. package/dist/lib/spans.js +28 -0
  751. package/dist/lib/spans.js.map +1 -0
  752. package/dist/lib/tracing.d.ts +31 -0
  753. package/dist/lib/tracing.d.ts.map +1 -0
  754. package/dist/lib/tracing.js +66 -0
  755. package/dist/lib/tracing.js.map +1 -0
  756. package/dist/lib/ttl-cache.d.ts +26 -0
  757. package/dist/lib/ttl-cache.d.ts.map +1 -0
  758. package/dist/lib/ttl-cache.js +61 -0
  759. package/dist/lib/ttl-cache.js.map +1 -0
  760. package/dist/lib/validator.d.ts +19 -0
  761. package/dist/lib/validator.d.ts.map +1 -0
  762. package/dist/lib/validator.js +32 -0
  763. package/dist/lib/validator.js.map +1 -0
  764. package/dist/lib/work-order/form.d.ts +40 -0
  765. package/dist/lib/work-order/form.d.ts.map +1 -0
  766. package/dist/lib/work-order/form.js +316 -0
  767. package/dist/lib/work-order/form.js.map +1 -0
  768. package/dist/lib/work-order/index.d.ts +20 -0
  769. package/dist/lib/work-order/index.d.ts.map +1 -0
  770. package/dist/lib/work-order/index.js +66 -0
  771. package/dist/lib/work-order/index.js.map +1 -0
  772. package/dist/middleware/api/audit.d.ts +9 -0
  773. package/dist/middleware/api/audit.d.ts.map +1 -0
  774. package/dist/middleware/api/audit.js +38 -0
  775. package/dist/middleware/api/audit.js.map +1 -0
  776. package/dist/middleware/api/auth.d.ts +29 -0
  777. package/dist/middleware/api/auth.d.ts.map +1 -0
  778. package/dist/middleware/api/auth.js +105 -0
  779. package/dist/middleware/api/auth.js.map +1 -0
  780. package/dist/middleware/api/console.d.ts +92 -0
  781. package/dist/middleware/api/console.d.ts.map +1 -0
  782. package/dist/middleware/api/console.js +446 -0
  783. package/dist/middleware/api/console.js.map +1 -0
  784. package/dist/middleware/api/errors.d.ts +48 -0
  785. package/dist/middleware/api/errors.d.ts.map +1 -0
  786. package/dist/middleware/api/errors.js +133 -0
  787. package/dist/middleware/api/errors.js.map +1 -0
  788. package/dist/middleware/api/idempotency.d.ts +23 -0
  789. package/dist/middleware/api/idempotency.d.ts.map +1 -0
  790. package/dist/middleware/api/idempotency.js +158 -0
  791. package/dist/middleware/api/idempotency.js.map +1 -0
  792. package/dist/middleware/api/keys.d.ts +14 -0
  793. package/dist/middleware/api/keys.d.ts.map +1 -0
  794. package/dist/middleware/api/keys.js +66 -0
  795. package/dist/middleware/api/keys.js.map +1 -0
  796. package/dist/middleware/api/membership.d.ts +32 -0
  797. package/dist/middleware/api/membership.d.ts.map +1 -0
  798. package/dist/middleware/api/membership.js +48 -0
  799. package/dist/middleware/api/membership.js.map +1 -0
  800. package/dist/middleware/api/oauth.d.ts +28 -0
  801. package/dist/middleware/api/oauth.d.ts.map +1 -0
  802. package/dist/middleware/api/oauth.js +109 -0
  803. package/dist/middleware/api/oauth.js.map +1 -0
  804. package/dist/middleware/api/rate-limit.d.ts +23 -0
  805. package/dist/middleware/api/rate-limit.d.ts.map +1 -0
  806. package/dist/middleware/api/rate-limit.js +70 -0
  807. package/dist/middleware/api/rate-limit.js.map +1 -0
  808. package/dist/middleware/api/types.d.ts +92 -0
  809. package/dist/middleware/api/types.d.ts.map +1 -0
  810. package/dist/middleware/api/types.js +7 -0
  811. package/dist/middleware/api/types.js.map +1 -0
  812. package/dist/middleware/api/wait.d.ts +21 -0
  813. package/dist/middleware/api/wait.d.ts.map +1 -0
  814. package/dist/middleware/api/wait.js +85 -0
  815. package/dist/middleware/api/wait.js.map +1 -0
  816. package/dist/middleware/capability.d.ts +32 -0
  817. package/dist/middleware/capability.d.ts.map +1 -0
  818. package/dist/middleware/capability.js +113 -0
  819. package/dist/middleware/capability.js.map +1 -0
  820. package/dist/middleware/database.d.ts +14 -0
  821. package/dist/middleware/database.d.ts.map +1 -0
  822. package/dist/middleware/database.js +18 -0
  823. package/dist/middleware/database.js.map +1 -0
  824. package/dist/middleware/error-handler.d.ts +13 -0
  825. package/dist/middleware/error-handler.d.ts.map +1 -0
  826. package/dist/middleware/error-handler.js +127 -0
  827. package/dist/middleware/error-handler.js.map +1 -0
  828. package/dist/middleware/observability.d.ts +32 -0
  829. package/dist/middleware/observability.d.ts.map +1 -0
  830. package/dist/middleware/observability.js +134 -0
  831. package/dist/middleware/observability.js.map +1 -0
  832. package/dist/middleware/rate-limit.d.ts +16 -0
  833. package/dist/middleware/rate-limit.d.ts.map +1 -0
  834. package/dist/middleware/rate-limit.js +56 -0
  835. package/dist/middleware/rate-limit.js.map +1 -0
  836. package/dist/middleware/ucan-auth.d.ts +39 -0
  837. package/dist/middleware/ucan-auth.d.ts.map +1 -0
  838. package/dist/middleware/ucan-auth.js +278 -0
  839. package/dist/middleware/ucan-auth.js.map +1 -0
  840. package/dist/networks.d.ts +34 -0
  841. package/dist/networks.d.ts.map +1 -0
  842. package/dist/networks.js +49 -0
  843. package/dist/networks.js.map +1 -0
  844. package/dist/oracle.d.ts +193 -0
  845. package/dist/oracle.d.ts.map +1 -0
  846. package/dist/oracle.js +245 -0
  847. package/dist/oracle.js.map +1 -0
  848. package/dist/routes/health.d.ts +16 -0
  849. package/dist/routes/health.d.ts.map +1 -0
  850. package/dist/routes/health.js +29 -0
  851. package/dist/routes/health.js.map +1 -0
  852. package/dist/routes/v1/admin.d.ts +18 -0
  853. package/dist/routes/v1/admin.d.ts.map +1 -0
  854. package/dist/routes/v1/admin.js +101 -0
  855. package/dist/routes/v1/admin.js.map +1 -0
  856. package/dist/routes/v1/api/admin-claims.d.ts +14 -0
  857. package/dist/routes/v1/api/admin-claims.d.ts.map +1 -0
  858. package/dist/routes/v1/api/admin-claims.js +82 -0
  859. package/dist/routes/v1/api/admin-claims.js.map +1 -0
  860. package/dist/routes/v1/api/admin-facilitator.d.ts +20 -0
  861. package/dist/routes/v1/api/admin-facilitator.d.ts.map +1 -0
  862. package/dist/routes/v1/api/admin-facilitator.js +64 -0
  863. package/dist/routes/v1/api/admin-facilitator.js.map +1 -0
  864. package/dist/routes/v1/api/admin.d.ts +9 -0
  865. package/dist/routes/v1/api/admin.d.ts.map +1 -0
  866. package/dist/routes/v1/api/admin.js +110 -0
  867. package/dist/routes/v1/api/admin.js.map +1 -0
  868. package/dist/routes/v1/api/audit.d.ts +8 -0
  869. package/dist/routes/v1/api/audit.d.ts.map +1 -0
  870. package/dist/routes/v1/api/audit.js +56 -0
  871. package/dist/routes/v1/api/audit.js.map +1 -0
  872. package/dist/routes/v1/api/batch.d.ts +17 -0
  873. package/dist/routes/v1/api/batch.d.ts.map +1 -0
  874. package/dist/routes/v1/api/batch.js +192 -0
  875. package/dist/routes/v1/api/batch.js.map +1 -0
  876. package/dist/routes/v1/api/claims-read.d.ts +43 -0
  877. package/dist/routes/v1/api/claims-read.d.ts.map +1 -0
  878. package/dist/routes/v1/api/claims-read.js +123 -0
  879. package/dist/routes/v1/api/claims-read.js.map +1 -0
  880. package/dist/routes/v1/api/claims.d.ts +131 -0
  881. package/dist/routes/v1/api/claims.d.ts.map +1 -0
  882. package/dist/routes/v1/api/claims.js +407 -0
  883. package/dist/routes/v1/api/claims.js.map +1 -0
  884. package/dist/routes/v1/api/collections-link.d.ts +14 -0
  885. package/dist/routes/v1/api/collections-link.d.ts.map +1 -0
  886. package/dist/routes/v1/api/collections-link.js +97 -0
  887. package/dist/routes/v1/api/collections-link.js.map +1 -0
  888. package/dist/routes/v1/api/export.d.ts +48 -0
  889. package/dist/routes/v1/api/export.d.ts.map +1 -0
  890. package/dist/routes/v1/api/export.js +251 -0
  891. package/dist/routes/v1/api/export.js.map +1 -0
  892. package/dist/routes/v1/api/index.d.ts +16 -0
  893. package/dist/routes/v1/api/index.d.ts.map +1 -0
  894. package/dist/routes/v1/api/index.js +68 -0
  895. package/dist/routes/v1/api/index.js.map +1 -0
  896. package/dist/routes/v1/api/keys.d.ts +9 -0
  897. package/dist/routes/v1/api/keys.d.ts.map +1 -0
  898. package/dist/routes/v1/api/keys.js +95 -0
  899. package/dist/routes/v1/api/keys.js.map +1 -0
  900. package/dist/routes/v1/api/me.d.ts +21 -0
  901. package/dist/routes/v1/api/me.d.ts.map +1 -0
  902. package/dist/routes/v1/api/me.js +122 -0
  903. package/dist/routes/v1/api/me.js.map +1 -0
  904. package/dist/routes/v1/api/members.d.ts +17 -0
  905. package/dist/routes/v1/api/members.d.ts.map +1 -0
  906. package/dist/routes/v1/api/members.js +406 -0
  907. package/dist/routes/v1/api/members.js.map +1 -0
  908. package/dist/routes/v1/api/meta.d.ts +12 -0
  909. package/dist/routes/v1/api/meta.d.ts.map +1 -0
  910. package/dist/routes/v1/api/meta.js +59 -0
  911. package/dist/routes/v1/api/meta.js.map +1 -0
  912. package/dist/routes/v1/api/openapi.gen.d.ts +2 -0
  913. package/dist/routes/v1/api/openapi.gen.d.ts.map +1 -0
  914. package/dist/routes/v1/api/openapi.gen.js +7 -0
  915. package/dist/routes/v1/api/openapi.gen.js.map +1 -0
  916. package/dist/routes/v1/api/protocols.d.ts +22 -0
  917. package/dist/routes/v1/api/protocols.d.ts.map +1 -0
  918. package/dist/routes/v1/api/protocols.js +153 -0
  919. package/dist/routes/v1/api/protocols.js.map +1 -0
  920. package/dist/routes/v1/api/review-billing.d.ts +18 -0
  921. package/dist/routes/v1/api/review-billing.d.ts.map +1 -0
  922. package/dist/routes/v1/api/review-billing.js +196 -0
  923. package/dist/routes/v1/api/review-billing.js.map +1 -0
  924. package/dist/routes/v1/api/review.d.ts +30 -0
  925. package/dist/routes/v1/api/review.d.ts.map +1 -0
  926. package/dist/routes/v1/api/review.js +302 -0
  927. package/dist/routes/v1/api/review.js.map +1 -0
  928. package/dist/routes/v1/api/sources.d.ts +10 -0
  929. package/dist/routes/v1/api/sources.d.ts.map +1 -0
  930. package/dist/routes/v1/api/sources.js +293 -0
  931. package/dist/routes/v1/api/sources.js.map +1 -0
  932. package/dist/routes/v1/api/uploads.d.ts +37 -0
  933. package/dist/routes/v1/api/uploads.d.ts.map +1 -0
  934. package/dist/routes/v1/api/uploads.js +414 -0
  935. package/dist/routes/v1/api/uploads.js.map +1 -0
  936. package/dist/routes/v1/api/views.d.ts +18 -0
  937. package/dist/routes/v1/api/views.d.ts.map +1 -0
  938. package/dist/routes/v1/api/views.js +95 -0
  939. package/dist/routes/v1/api/views.js.map +1 -0
  940. package/dist/routes/v1/api/webhooks.d.ts +14 -0
  941. package/dist/routes/v1/api/webhooks.d.ts.map +1 -0
  942. package/dist/routes/v1/api/webhooks.js +282 -0
  943. package/dist/routes/v1/api/webhooks.js.map +1 -0
  944. package/dist/routes/v1/api/work-orders.d.ts +45 -0
  945. package/dist/routes/v1/api/work-orders.d.ts.map +1 -0
  946. package/dist/routes/v1/api/work-orders.js +171 -0
  947. package/dist/routes/v1/api/work-orders.js.map +1 -0
  948. package/dist/routes/v1/claims.d.ts +21 -0
  949. package/dist/routes/v1/claims.d.ts.map +1 -0
  950. package/dist/routes/v1/claims.js +153 -0
  951. package/dist/routes/v1/claims.js.map +1 -0
  952. package/dist/routes/v1/collections.d.ts +45 -0
  953. package/dist/routes/v1/collections.d.ts.map +1 -0
  954. package/dist/routes/v1/collections.js +201 -0
  955. package/dist/routes/v1/collections.js.map +1 -0
  956. package/dist/routes/v1/index.d.ts +13 -0
  957. package/dist/routes/v1/index.d.ts.map +1 -0
  958. package/dist/routes/v1/index.js +41 -0
  959. package/dist/routes/v1/index.js.map +1 -0
  960. package/dist/routes/v1/info.d.ts +14 -0
  961. package/dist/routes/v1/info.d.ts.map +1 -0
  962. package/dist/routes/v1/info.js +75 -0
  963. package/dist/routes/v1/info.js.map +1 -0
  964. package/dist/routes/v1/mcp/index.d.ts +33 -0
  965. package/dist/routes/v1/mcp/index.d.ts.map +1 -0
  966. package/dist/routes/v1/mcp/index.js +252 -0
  967. package/dist/routes/v1/mcp/index.js.map +1 -0
  968. package/dist/routes/v1/mcp/oauth.d.ts +27 -0
  969. package/dist/routes/v1/mcp/oauth.d.ts.map +1 -0
  970. package/dist/routes/v1/mcp/oauth.js +500 -0
  971. package/dist/routes/v1/mcp/oauth.js.map +1 -0
  972. package/dist/routes/v1/mcp/tools.d.ts +71 -0
  973. package/dist/routes/v1/mcp/tools.d.ts.map +1 -0
  974. package/dist/routes/v1/mcp/tools.js +432 -0
  975. package/dist/routes/v1/mcp/tools.js.map +1 -0
  976. package/dist/routes/v1/mcp/ui.d.ts +45 -0
  977. package/dist/routes/v1/mcp/ui.d.ts.map +1 -0
  978. package/dist/routes/v1/mcp/ui.js +454 -0
  979. package/dist/routes/v1/mcp/ui.js.map +1 -0
  980. package/dist/routes/v1/oauth.d.ts +29 -0
  981. package/dist/routes/v1/oauth.d.ts.map +1 -0
  982. package/dist/routes/v1/oauth.js +256 -0
  983. package/dist/routes/v1/oauth.js.map +1 -0
  984. package/dist/routes/v1/reviewers.d.ts +22 -0
  985. package/dist/routes/v1/reviewers.d.ts.map +1 -0
  986. package/dist/routes/v1/reviewers.js +165 -0
  987. package/dist/routes/v1/reviewers.js.map +1 -0
  988. package/dist/routes/v1/reviews.d.ts +38 -0
  989. package/dist/routes/v1/reviews.d.ts.map +1 -0
  990. package/dist/routes/v1/reviews.js +234 -0
  991. package/dist/routes/v1/reviews.js.map +1 -0
  992. package/dist/routes/v1/shared.d.ts +586 -0
  993. package/dist/routes/v1/shared.d.ts.map +1 -0
  994. package/dist/routes/v1/shared.js +229 -0
  995. package/dist/routes/v1/shared.js.map +1 -0
  996. package/dist/routes/well-known.d.ts +15 -0
  997. package/dist/routes/well-known.d.ts.map +1 -0
  998. package/dist/routes/well-known.js +35 -0
  999. package/dist/routes/well-known.js.map +1 -0
  1000. package/dist/runtime.d.ts +100 -0
  1001. package/dist/runtime.d.ts.map +1 -0
  1002. package/dist/runtime.js +144 -0
  1003. package/dist/runtime.js.map +1 -0
  1004. package/dist/testing/fake-tools.d.ts +104 -0
  1005. package/dist/testing/fake-tools.d.ts.map +1 -0
  1006. package/dist/testing/fake-tools.js +213 -0
  1007. package/dist/testing/fake-tools.js.map +1 -0
  1008. package/dist/testing/index.d.ts +54 -0
  1009. package/dist/testing/index.d.ts.map +1 -0
  1010. package/dist/testing/index.js +104 -0
  1011. package/dist/testing/index.js.map +1 -0
  1012. package/dist/testing/samples.d.ts +70 -0
  1013. package/dist/testing/samples.d.ts.map +1 -0
  1014. package/dist/testing/samples.js +92 -0
  1015. package/dist/testing/samples.js.map +1 -0
  1016. package/dist/workflows/claim-ingest.d.ts +250 -0
  1017. package/dist/workflows/claim-ingest.d.ts.map +1 -0
  1018. package/dist/workflows/claim-ingest.js +1020 -0
  1019. package/dist/workflows/claim-ingest.js.map +1 -0
  1020. package/dist/workflows/claim-source.d.ts +25 -0
  1021. package/dist/workflows/claim-source.d.ts.map +1 -0
  1022. package/dist/workflows/claim-source.js +107 -0
  1023. package/dist/workflows/claim-source.js.map +1 -0
  1024. package/dist/workflows/review-complete.d.ts +82 -0
  1025. package/dist/workflows/review-complete.d.ts.map +1 -0
  1026. package/dist/workflows/review-complete.js +455 -0
  1027. package/dist/workflows/review-complete.js.map +1 -0
  1028. package/dist/workflows/steps.d.ts +125 -0
  1029. package/dist/workflows/steps.d.ts.map +1 -0
  1030. package/dist/workflows/steps.js +325 -0
  1031. package/dist/workflows/steps.js.map +1 -0
  1032. package/docs/api.md +2595 -0
  1033. package/docs/guide.md +1525 -0
  1034. package/migrations/0000_init.sql +108 -0
  1035. package/migrations/0001_review_attestation.sql +1 -0
  1036. package/migrations/0002_decisions_facts.sql +1 -0
  1037. package/migrations/0003_api_lane.sql +171 -0
  1038. package/migrations/0004_api_v1_1.sql +19 -0
  1039. package/migrations/0005_member_notify.sql +3 -0
  1040. package/migrations/0006_source_collections.sql +16 -0
  1041. package/migrations/0007_api_settlement.sql +27 -0
  1042. package/migrations/0008_review_extend.sql +1 -0
  1043. package/migrations/0009_card_refunds.sql +4 -0
  1044. package/migrations/0010_even_scorpion.sql +16 -0
  1045. package/migrations/0011_mcp_oauth.sql +27 -0
  1046. package/migrations/0012_mcp_standing.sql +21 -0
  1047. package/migrations/0013_unknown_krista_starr.sql +2 -0
  1048. package/migrations/0014_last_carnage.sql +14 -0
  1049. package/migrations/0015_company_authority.sql +26 -0
  1050. package/migrations/0016_owner_only_links.sql +6 -0
  1051. package/migrations/0017_organisations.sql +35 -0
  1052. package/migrations/0018_remove_app_signed.sql +4 -0
  1053. package/migrations/0019_submitted_via.sql +2 -0
  1054. package/migrations/0020_drop_decision_to_pay.sql +4 -0
  1055. package/migrations/0021_manual_erase.sql +25 -0
  1056. package/migrations/0022_errored_facts.sql +1 -0
  1057. package/migrations/0023_review_billing.sql +20 -0
  1058. package/migrations/0024_pending_task_details.sql +1 -0
  1059. package/migrations/meta/0000_snapshot.json +707 -0
  1060. package/migrations/meta/0001_snapshot.json +714 -0
  1061. package/migrations/meta/0002_snapshot.json +721 -0
  1062. package/migrations/meta/0003_snapshot.json +1845 -0
  1063. package/migrations/meta/0004_snapshot.json +1969 -0
  1064. package/migrations/meta/0005_snapshot.json +1991 -0
  1065. package/migrations/meta/0006_snapshot.json +2097 -0
  1066. package/migrations/meta/0007_snapshot.json +2128 -0
  1067. package/migrations/meta/0008_snapshot.json +2133 -0
  1068. package/migrations/meta/0009_snapshot.json +2161 -0
  1069. package/migrations/meta/0010_snapshot.json +2265 -0
  1070. package/migrations/meta/0011_snapshot.json +2448 -0
  1071. package/migrations/meta/0012_snapshot.json +2577 -0
  1072. package/migrations/meta/0013_snapshot.json +2594 -0
  1073. package/migrations/meta/0014_snapshot.json +2602 -0
  1074. package/migrations/meta/0015_snapshot.json +2778 -0
  1075. package/migrations/meta/0016_snapshot.json +2778 -0
  1076. package/migrations/meta/0017_snapshot.json +2792 -0
  1077. package/migrations/meta/0018_snapshot.json +2778 -0
  1078. package/migrations/meta/0019_snapshot.json +2792 -0
  1079. package/migrations/meta/0020_snapshot.json +2785 -0
  1080. package/migrations/meta/0021_snapshot.json +2762 -0
  1081. package/migrations/meta/0022_snapshot.json +2769 -0
  1082. package/migrations/meta/0023_snapshot.json +2900 -0
  1083. package/migrations/meta/0024_snapshot.json +2907 -0
  1084. package/migrations/meta/_journal.json +181 -0
  1085. package/openapi/decision-api.yaml +12204 -0
  1086. package/package.json +123 -4
  1087. package/skills/README.md +19 -0
  1088. package/skills/add-openhands-support/SKILL.md +113 -0
  1089. package/skills/create-collection/SKILL.md +199 -0
  1090. package/skills/create-collection/reference/claims-stack.md +106 -0
  1091. package/skills/create-collection/reference/collection.md +111 -0
  1092. package/skills/create-oracle/SKILL.md +400 -0
  1093. package/skills/create-rubric/SKILL.md +130 -0
  1094. package/skills/create-rubric/reference/format-cheatsheet.md +186 -0
  1095. package/skills/create-rubric/templates/claim-form.example.json +60 -0
  1096. package/skills/decision-api-client/SKILL.md +236 -0
  1097. package/skills/decision-api-oracle/SKILL.md +336 -0
  1098. package/skills/publish-protocol/SKILL.md +151 -0
  1099. package/skills/publish-protocol/reference/publishing.md +116 -0
  1100. package/skills/reference/engine-contract.md +222 -0
  1101. package/skills/write-facts/SKILL.md +221 -0
  1102. package/skills/write-facts/reference/examples/http-vendor.ts +88 -0
  1103. package/skills/write-facts/reference/examples/price-matches-agreement.ts +67 -0
  1104. package/skills/write-facts/reference/facts-api.md +232 -0
  1105. package/templates/project/.dev.vars.example +93 -0
  1106. package/templates/project/.editorconfig +9 -0
  1107. package/templates/project/CLAUDE.md +45 -0
  1108. package/templates/project/README.md +199 -0
  1109. package/templates/project/biome.json +37 -0
  1110. package/templates/project/gitignore +29 -0
  1111. package/templates/project/package.json +32 -0
  1112. package/templates/project/src/facts/index.ts +19 -0
  1113. package/templates/project/src/index.ts +25 -0
  1114. package/templates/project/test/api-lane.test.ts +57 -0
  1115. package/templates/project/test/facts.test.ts +14 -0
  1116. package/templates/project/tsconfig.json +25 -0
  1117. package/templates/project/vitest.config.ts +13 -0
  1118. package/templates/project/wrangler.jsonc +446 -0
@@ -0,0 +1,1122 @@
1
+ /**
2
+ * `decision-oracle oracle init` — provision the WHOLE oracle: its wallet, its chain identity, its Matrix
3
+ * account and its on-chain entity with its full public identity (profile, domain card, agent card),
4
+ * in thirteen steps that each re-decide themselves against LIVE state. Every oracle built with the
5
+ * kit carries all of it (owner, 2026-10-01); `--logo` is the one optional input, and its absence is
6
+ * said out loud because the portal and the console then show a placeholder.
7
+ *
8
+ * decision-oracle oracle init --protocol did:ixo:entity:… --kit-url https://my-oracle.example.com \
9
+ * [--network devnet] [--env-file .dev.vars] [--logo <url>] [--openhands [--price-pay <n>]] \
10
+ * [--only <step>] [--relogin] [--yes]
11
+ *
12
+ * Dry run by default: every step prints `do` or `skip (<why>)` and NOTHING is signed, created or
13
+ * written. `--yes` runs the same thirteen decisions and executes them. Re-running is always safe —
14
+ * the skip decision comes from the chain, the homeserver and the entity themselves, never from a
15
+ * marker this command wrote, so a partial failure, a redeploy or a second provider running it twice
16
+ * all converge on the same state.
17
+ *
18
+ * 1 fund the AuthHub session tops ORACLE_ADDRESS up to FUND_UIXO (it pays for MsgEvaluateClaim)
19
+ * 2 iid the oracle's OWN wallet creates `did:ixo:<ORACLE_ADDRESS>` + its `#matrix` service
20
+ * 3 key … and adds the SERVICE_ED25519_MNEMONIC key, so UCANs minted as that DID resolve
21
+ * 4 matrix … and creates + logs into the oracle's Matrix account (ORACLE_MATRIX_ACCESS_TOKEN)
22
+ * 5 entity the session creates the oracle ENTITY (services + protocol edge inline)
23
+ * 6 orz … its `#orz` authz config (the portal's entity→account bridge)
24
+ * 7 profile … its `#pro` profile, built from the RUNNING oracle's `GET /v1/info`
25
+ * 8 domain … its `#dmn` domain card (the portal's shape; added, or replaced when it drifted)
26
+ * 9 acard … its `#acard` Agent Card (validated against the engine's schema; same rule)
27
+ * 10 linked … the oracle→protocol edge, 11 service the `#eval` endpoint, 12 backlink the way back
28
+ * 13 index the domain indexer is told the entity exists — AFTER `domain`, so it reads the card
29
+ * (skipped when it already holds the anchored card; a failure is a warning, never fatal)
30
+ *
31
+ * TWO signers, deliberately. Steps 2–4 are the ORACLE's own identity: only its key may write its own
32
+ * IID document, and only its key can prove the address to the rooms bot. Everything else is the
33
+ * AuthHub session, which OWNS the entity it creates (`ownerAddress`/`ownerDid`/`controller`) — that
34
+ * owner does not have to be the oracle's runtime identity, and the oracle's `ORACLE_ADDRESS` still
35
+ * needs its own `EvaluateClaimAuthorization` on any collection. So the oracle's mnemonics
36
+ * (`ORACLE_SECP_MNEMONIC`, `SERVICE_ED25519_MNEMONIC`) are required only by steps 2–4: a deployed
37
+ * oracle whose keys live only in its worker secrets still runs `--only orz|profile|domain|acard…`
38
+ * on the session alone, from the public vars and `/v1/info`.
39
+ *
40
+ * No `--entity` flag: the entity is found by THIS ORACLE, never by its owner — one session may own
41
+ * the entities of several oracles. `ORACLE_ENTITY_DID`, when set, pins it (checked to be an oracle
42
+ * entity the session owns); otherwise it is the session's oracle entity whose `#orz` grants
43
+ * `ORACLE_ADDRESS` (the portal's own entity→account bridge, so it survives a moved host), else whose
44
+ * `#eval` is `--kit-url` (written inline by `entity`, so a run that died before `orz` still finds
45
+ * it). See `resolveOracleEntity`. `--only <step>` runs exactly one step, for debugging a stuck run.
46
+ */
47
+ import { resolve } from "node:path";
48
+ import process from "node:process";
49
+ import { cidForBytes } from "../../lib/hash.js";
50
+ import { deriveServiceKey } from "../../lib/ixo/identity.js";
51
+ import { mxidFromDid } from "../../lib/matrix/mxid.js";
52
+ import { NETWORKS } from "../../networks.js";
53
+ import { evaluationFeeFor } from "../../oracle.js";
54
+ import { parse } from "../lib/args.js";
55
+ import { addLinkedEntityMsg, addLinkedResourceMsg, addServiceMsg, broadcast, confirm, deleteLinkedResourceMsg, deleteServiceMsg, entityDidFromEvents, fail, ownedOracleEntities, resolveEntity, resolveNetwork, STANDARD_FEE, sessionDocSigner, sha256Hex, uploadDoc, } from "../lib/chain.js";
56
+ import { readProjectEnv } from "../lib/devvars.js";
57
+ import { agentCardSchema, buildAgentCard, buildDomainCard, cardDrifted, fetchDoc, fetchJson, mergeCard, validateAgentCard, } from "../lib/identity-cards.js";
58
+ import { appendDevVar, createMatrixAccount, matrixLogin, matrixPassword, matrixWhoami, roomsBotUrl, setDisplayName, } from "../lib/matrix-account.js";
59
+ import { ed25519VerificationId, entityDocument, fundMsg, iidDocumentMsg, iidExists, oracleWalletSigner, spendableUixo, verificationMethodMsg, } from "../lib/oracle-account.js";
60
+ import { buildSigner } from "../lib/session.js";
61
+ const STEPS = [
62
+ "fund",
63
+ "iid",
64
+ "key",
65
+ "matrix",
66
+ "entity",
67
+ "orz",
68
+ "profile",
69
+ "domain",
70
+ "acard",
71
+ "linked",
72
+ "service",
73
+ "backlink",
74
+ "index",
75
+ ];
76
+ /** The vars every step reads before anything runs — a project missing one is not provisionable. */
77
+ const REQUIRED_VARS = ["ORACLE_ADDRESS", "ORACLE_DID", "ORACLE_MATRIX_USER_ID"];
78
+ /** Gas for the oracle's own `MsgEvaluateClaim` txs — the oracle pays its own chain fees, never the
79
+ * AuthHub session's. 1 IXO (`STANDARD_FEE` in `../lib/chain.ts` charges 150000uixo per tx this CLI
80
+ * signs), so one top-up funds several of those before the wallet needs another. */
81
+ const FUND_UIXO = "1000000";
82
+ /**
83
+ * The oracle's `#eval` service becomes a permanent, publicly-discoverable chain record — so plain
84
+ * `http` is only tolerated for a localhost endpoint (a devnet dry run against `wrangler dev`), never
85
+ * for anything a real portal would resolve.
86
+ */
87
+ function resolveKitUrl(value) {
88
+ let url;
89
+ try {
90
+ url = new URL(value);
91
+ }
92
+ catch {
93
+ fail(`--kit-url '${value}' is not a valid URL`);
94
+ }
95
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
96
+ fail(`--kit-url must be http or https, got '${url.protocol}'`);
97
+ }
98
+ const isLocalhost = url.hostname === "localhost" || url.hostname === "127.0.0.1" || url.hostname === "::1";
99
+ if (url.protocol === "http:" && !isLocalhost) {
100
+ fail(`--kit-url '${value}' uses plain http for a non-localhost host — use https ` +
101
+ "(plain http is only allowed for localhost, e.g. a local `wrangler dev` dry run)");
102
+ }
103
+ return value;
104
+ }
105
+ function resolveStep(value) {
106
+ if (value === undefined)
107
+ return undefined;
108
+ const step = STEPS.find((s) => s === value);
109
+ if (!step)
110
+ fail(`unknown --only '${value}' (${STEPS.join("|")})`);
111
+ return step;
112
+ }
113
+ /** One of the oracle's own keys, for the step that acts as the oracle — or a loud stop naming it. */
114
+ function oracleKey(ctx, value, envVar, step) {
115
+ return (value ??
116
+ fail(`step '${step}' acts as the oracle itself and needs ${envVar} — set it in ${ctx.envFileLabel} ` +
117
+ "(only iid, key and matrix use the oracle's keys; every other step runs on the AuthHub session)"));
118
+ }
119
+ /**
120
+ * Planned before the entity exists — a dry run on a fresh oracle, where there is nothing to read
121
+ * yet and the answer is always `do`. Reaching the `run` means `--only` skipped the step that
122
+ * creates the entity, which is a mistake worth saying out loud rather than half-doing.
123
+ */
124
+ const afterEntity = (what) => ({
125
+ detail: `${what} — after the entity is created`,
126
+ run: async () => fail("no oracle entity yet — run `oracle init` without --only (or --only entity first)"),
127
+ });
128
+ /**
129
+ * Every step that decides from entity state reads the entity's IID document from the CHAIN, never
130
+ * blocksync — observed live on devnet: the indexer listed a resource 15+ minutes late while the
131
+ * chain had it, and a lagging "not anchored yet" makes a re-run broadcast a duplicate the chain
132
+ * rejects outright (`duplicated resource id {id}#pro`). Blocksync is left with only the two
133
+ * questions the document cannot answer: which entity an address owns, and who owns the protocol.
134
+ *
135
+ * Absent is not a skip-reason here — the entity DID came from a creation tx or from blocksync, so
136
+ * "no document" means the wrong network or a chain that lost it, and guessing either way would
137
+ * broadcast against the wrong entity.
138
+ */
139
+ async function entityState(ctx, did) {
140
+ return ((await entityDocument(ctx.rpc, did)) ??
141
+ fail(`${did} has no IID document on ${ctx.network} (${ctx.rpc}) — wrong --network?`));
142
+ }
143
+ /** Every HTTP call whose failure is only a skip or a warning (the kit probe, the `#orz` doc, the
144
+ * indexer) carries this deadline: a `wrangler dev` still booting accepts the socket and answers
145
+ * nothing, which hung a live dry run for 32 minutes — an optional call must never do that. */
146
+ const HTTP_TIMEOUT_MS = 10_000;
147
+ /**
148
+ * The `granteeAddress` inside an already-anchored `#orz` document — what binds an entity to this
149
+ * oracle (`resolveOracleEntity`), and what a STALE one (the oracle identity was rotated after `#orz`
150
+ * was anchored) is caught by. `null` when the doc names no grantee; `undefined` when it cannot be
151
+ * READ (media down, a timeout) — which is not an answer: an unreadable `#orz` may be this oracle's.
152
+ */
153
+ async function orzGrantee(orz) {
154
+ const doc = (await fetchDoc(orz))?.json;
155
+ if (!doc || typeof doc !== "object")
156
+ return undefined;
157
+ return typeof doc.granteeAddress === "string" ? doc.granteeAddress : null;
158
+ }
159
+ /**
160
+ * What binds an entity to THIS oracle, or null when nothing does: `#orz.granteeAddress ===
161
+ * ORACLE_ADDRESS` — the portal's own entity→account bridge, keyed on the oracle's runtime identity,
162
+ * so a moved host still matches — else `#eval === --kit-url`, which `entity` writes inline (a run
163
+ * that died before `orz` anchored). An `#orz` that cannot be READ is not "not ours": the run stops
164
+ * rather than mint a second entity for an oracle whose own `#orz` was down for a moment.
165
+ */
166
+ async function bindingOf(ctx, did, doc) {
167
+ const orz = doc.linkedResource.find((r) => r.id.endsWith("#orz"));
168
+ const grantee = orz ? await orzGrantee(orz) : null;
169
+ if (grantee === ctx.address)
170
+ return `#orz grants ${ctx.address}`;
171
+ if (doc.service.some((s) => s.id.endsWith("#eval") && s.serviceEndpoint === ctx.kitUrl)) {
172
+ return `#eval is ${ctx.kitUrl}`;
173
+ }
174
+ if (grantee === undefined) {
175
+ fail(`can't decide which entity is this oracle's — the #orz of ${did} could not be read; retry (or set ORACLE_ENTITY_DID)`);
176
+ }
177
+ return null;
178
+ }
179
+ /**
180
+ * Which oracle entity is THIS oracle's — never "the one the session owns": an AuthHub session may
181
+ * own several oracles' entities, and picking up another's would make every later step skip on (or
182
+ * write onto) the wrong one.
183
+ *
184
+ * - `ORACLE_ENTITY_DID` set ⇒ that one, after checking it is an oracle entity the session owns,
185
+ * that the chain has its document AND that it is bound to this oracle (`bindingOf`) — a pin
186
+ * naming a sibling oracle's entity fails loudly, never a write onto it.
187
+ * - else the session's oracle entities, each read from the CHAIN, matched by `bindingOf` — the
188
+ * `#orz` link first, the `#eval` one only when no entity has the first.
189
+ * - two candidates on the same link ⇒ refuse and ask for the pin; guessing would write onto one
190
+ * of them at random.
191
+ */
192
+ async function resolveOracleEntity(ctx, pinned) {
193
+ const owned = await ownedOracleEntities(ctx.blocksync, ctx.signer.address);
194
+ if (pinned) {
195
+ if (!owned.some((e) => e.id === pinned)) {
196
+ fail(`ORACLE_ENTITY_DID ${pinned} is not an oracle entity owned by this session (${ctx.signer.address}) on ${ctx.network} — wrong session, wrong network, or the indexer has not caught up with a just-created entity`);
197
+ }
198
+ const binding = await bindingOf(ctx, pinned, await entityState(ctx, pinned));
199
+ if (!binding) {
200
+ fail(`ORACLE_ENTITY_DID ${pinned} is not this oracle's — its #orz does not grant ${ctx.address} and its #eval is not ${ctx.kitUrl}; refusing to write to another oracle's entity`);
201
+ }
202
+ return { did: pinned, binding: `ORACLE_ENTITY_DID, ${binding}` };
203
+ }
204
+ const byAddress = [];
205
+ const byKitUrl = [];
206
+ for (const { id } of owned) {
207
+ const doc = await entityDocument(ctx.rpc, id);
208
+ if (!doc)
209
+ continue;
210
+ const binding = await bindingOf(ctx, id, doc);
211
+ if (binding?.startsWith("#orz"))
212
+ byAddress.push(id);
213
+ else if (binding)
214
+ byKitUrl.push(id);
215
+ }
216
+ const [matches, binding] = byAddress.length > 0
217
+ ? [byAddress, `#orz grants ${ctx.address}`]
218
+ : [byKitUrl, `#eval is ${ctx.kitUrl}`];
219
+ if (matches.length > 1) {
220
+ fail(`${matches.length} oracle entities owned by this session are bound to this oracle (${binding}): ${matches.join(", ")} — set ORACLE_ENTITY_DID to the one to provision`);
221
+ }
222
+ return matches[0] ? { did: matches[0], binding } : undefined;
223
+ }
224
+ /** Printed wherever a logo would go: optional (owner), but the portal and the console show a
225
+ * placeholder without one. */
226
+ const NO_LOGO = "no --logo: the portal and the console show a placeholder — pass --logo <url>";
227
+ /** The OpenHands per-review price: what the running oracle publishes, else `--price-pay`. */
228
+ function openhandsPrice(ctx, info) {
229
+ return (info.apiMicroUsd ??
230
+ ctx.pricePayMicroUsd ??
231
+ fail(`--openhands needs a price: ${ctx.kitUrl}/v1/info publishes no pricing.api for ${ctx.protocolDid} — pass --price-pay <n>`));
232
+ }
233
+ async function cardSource(ctx, info) {
234
+ return {
235
+ entityDid: ctx.entityDid ?? fail("no oracle entity to card"),
236
+ issuerDid: ctx.signer.did,
237
+ name: info.name,
238
+ description: info.description,
239
+ kitUrl: ctx.kitUrl,
240
+ ...(ctx.logo ? { logo: ctx.logo } : {}),
241
+ ...(info.evaluationFee ? { evaluationFee: info.evaluationFee } : {}),
242
+ ...(ctx.openhands ? { openhands: { amountMicroUsd: openhandsPrice(ctx, info) } } : {}),
243
+ ...(await ctx
244
+ .apiPrice()
245
+ .then((amountMicroUsd) => (amountMicroUsd === null ? {} : { api: { amountMicroUsd } }))),
246
+ };
247
+ }
248
+ /**
249
+ * A document still on Matrix media is re-anchored onto the Vault by the next run (the doc's own
250
+ * bytes, merged as usual): writes left Matrix media, which may stop answering unauthenticated
251
+ * reads. Reading it stays supported (`readLinkedDoc`); only where it lives changes.
252
+ */
253
+ const onMatrixMedia = (r) => r.serviceEndpoint.includes("/_matrix/media/");
254
+ /**
255
+ * The `domain` / `acard` decision: add the card when there is none; skip when every field the KIT
256
+ * owns already says what we would write (`cardDrifted`); else REPLACE it (delete + add, one tx) with
257
+ * the kit's fields MERGED onto the live card, so a provider's own additions survive. A card that
258
+ * cannot be read is left alone with a warning. Read from the chain's document, like every
259
+ * entity-state decision. `check` sees the card that would actually be written.
260
+ */
261
+ async function cardPlan(ctx, card, resource, check = () => { }) {
262
+ const entityDid = ctx.entityDid ?? fail("no oracle entity to card");
263
+ const entity = await entityState(ctx, entityDid);
264
+ const anchored = entity.linkedResource.find((r) => r.id.endsWith(resource.fragment));
265
+ // Read by its address only: the proof is judged below, where a stale one is repaired.
266
+ const served = anchored ? await fetchDoc({ serviceEndpoint: anchored.serviceEndpoint }) : null;
267
+ const live = served?.json ?? null;
268
+ if (anchored && (live === null || typeof live !== "object")) {
269
+ // Unreadable is not "drifted": replacing a card we could not read would overwrite whatever the
270
+ // provider put there on the strength of a timeout.
271
+ return {
272
+ detail: `⚠ ${resource.fragment} on ${entityDid} could not be read (${anchored.serviceEndpoint}) — left as is; re-run to retry`,
273
+ };
274
+ }
275
+ const logo = Boolean(ctx.logo);
276
+ const liveCard = live;
277
+ const drifted = liveCard !== null && cardDrifted(resource.fragment, liveCard, card, logo);
278
+ // The proof must be the CID of the bytes served (ixo-oracles-cli's convention): a card anchored
279
+ // with a sha256-hex proof, or whose media changed under it, is re-anchored even when its content
280
+ // is current — nothing else would ever repair it.
281
+ const proofOk = served !== null && anchored?.proof === (await cidForBytes(served.bytes));
282
+ const moving = anchored !== undefined && onMatrixMedia(anchored);
283
+ if (liveCard && !drifted && proofOk && !moving) {
284
+ return { detail: `${resource.fragment} on ${entityDid} already carries this card` };
285
+ }
286
+ const doc = liveCard ? mergeCard(resource.fragment, liveCard, card, logo) : card;
287
+ check(doc);
288
+ const { label, ...rest } = resource;
289
+ const why = !liveCard
290
+ ? "add"
291
+ : drifted
292
+ ? "replace (drifted; merged onto the live card)"
293
+ : !proofOk
294
+ ? `replace (proof ${anchored?.proof} is not the CID of its bytes)`
295
+ : "replace (moves off Matrix media)";
296
+ return {
297
+ detail: `${why} ${label} — uploaded as ${ctx.signer.did}`,
298
+ run: () => anchorDoc(ctx, { ...rest, doc, identityDoc: true, replace: anchored?.id }),
299
+ };
300
+ }
301
+ // --- the steps ------------------------------------------------------------------------------------
302
+ const PLAN = {
303
+ /** 1. The oracle's wallet pays its own chain fees — without this it cannot sign anything. */
304
+ async fund(ctx) {
305
+ const balance = await spendableUixo(ctx.rpc, ctx.address);
306
+ const want = BigInt(FUND_UIXO);
307
+ if (balance >= want) {
308
+ return { detail: `${ctx.address} holds ${balance}uixo (≥ ${want}uixo)` };
309
+ }
310
+ return {
311
+ detail: `send ${want}uixo → ${ctx.address} (holds ${balance}uixo)`,
312
+ run: async () => {
313
+ const msg = await fundMsg(ctx.signer.address, ctx.address, FUND_UIXO);
314
+ confirm({
315
+ network: ctx.network,
316
+ signer: ctx.signer.address,
317
+ action: "MsgSend (fund the oracle's own wallet)",
318
+ lines: [`to: ${ctx.address}`, `amount: ${FUND_UIXO}uixo`],
319
+ fee: STANDARD_FEE,
320
+ }, ctx.yes);
321
+ const { hash } = await broadcast(ctx.signer, [msg], "oracle-init: fund");
322
+ console.log(`✓ sent ${FUND_UIXO}uixo → ${ctx.address} (tx ${hash})`);
323
+ },
324
+ };
325
+ },
326
+ /** 2. `did:ixo:<ORACLE_ADDRESS>` itself — what the claim bot and the UCAN Store resolve us by. */
327
+ async iid(ctx) {
328
+ const { exists } = await iidExists(ctx.rpc, ctx.did);
329
+ if (exists)
330
+ return { detail: `${ctx.did} already has an IID document` };
331
+ return {
332
+ detail: `MsgCreateIidDocument ${ctx.did} + service #matrix → ${ctx.matrixBase}`,
333
+ run: async () => {
334
+ const msg = await iidDocumentMsg(ctx.did, ctx.address, oracleKey(ctx, ctx.oracleSigner, "ORACLE_SECP_MNEMONIC", "iid").pubkey, ctx.matrixBase);
335
+ confirm({
336
+ network: ctx.network,
337
+ signer: `${ctx.address} (the ORACLE's own wallet)`,
338
+ action: "MsgCreateIidDocument (the oracle's account DID)",
339
+ lines: [`did: ${ctx.did}`, `service #matrix: ${ctx.matrixBase}`],
340
+ fee: STANDARD_FEE,
341
+ }, ctx.yes);
342
+ const { transactionHash } = await oracleKey(ctx, ctx.oracleSigner, "ORACLE_SECP_MNEMONIC", "iid").signAndBroadcast([msg], "oracle-init: iid");
343
+ console.log(`✓ IID document ${ctx.did} created (tx ${transactionHash})`);
344
+ },
345
+ };
346
+ },
347
+ /** 3. The Ed25519 key every UCAN this oracle mints as its did:ixo is signed with. */
348
+ async key(ctx) {
349
+ const edPublicKey = oracleKey(ctx, ctx.edPublicKey, "SERVICE_ED25519_MNEMONIC", "key");
350
+ const vmId = ed25519VerificationId(ctx.did, edPublicKey);
351
+ const { verificationMethodIds } = await iidExists(ctx.rpc, ctx.did);
352
+ if (verificationMethodIds.includes(vmId)) {
353
+ return { detail: `${vmId} is already a verification method` };
354
+ }
355
+ return {
356
+ detail: `MsgAddVerification ${vmId} (authentication + assertionMethod)`,
357
+ run: async () => {
358
+ const msg = await verificationMethodMsg(ctx.did, ctx.address, edPublicKey);
359
+ confirm({
360
+ network: ctx.network,
361
+ signer: `${ctx.address} (the ORACLE's own wallet)`,
362
+ action: "MsgAddVerification (the SERVICE_ED25519_MNEMONIC key)",
363
+ lines: [`did: ${ctx.did}`, `verification method: ${vmId}`],
364
+ fee: STANDARD_FEE,
365
+ }, ctx.yes);
366
+ const { transactionHash } = await oracleKey(ctx, ctx.oracleSigner, "ORACLE_SECP_MNEMONIC", "key").signAndBroadcast([msg], "oracle-init: key");
367
+ console.log(`✓ Ed25519 verification method added (tx ${transactionHash})`);
368
+ },
369
+ };
370
+ },
371
+ /** 4. The Matrix account the review-card lane posts as — the only producer of its access token. */
372
+ async matrix(ctx) {
373
+ // `matrixWhoami` answers null for ANY non-2xx (a rotated token, but also a homeserver blip), so
374
+ // null means "log in again", never "there is no account" — creation is idempotent anyway.
375
+ let why;
376
+ if (ctx.relogin)
377
+ why = "--relogin";
378
+ else if (!ctx.token)
379
+ why = `no ORACLE_MATRIX_ACCESS_TOKEN in ${ctx.envFileLabel}`;
380
+ else {
381
+ const who = await matrixWhoami(ctx.matrixBase, ctx.token);
382
+ if (who === ctx.mxid) {
383
+ return { detail: `${ctx.envFileLabel} holds a live token for ${ctx.mxid}` };
384
+ }
385
+ why =
386
+ who === null
387
+ ? `the homeserver did not answer for ${ctx.envFileLabel}'s token (rotated, or a blip) — re-login`
388
+ : `${ctx.envFileLabel}'s token belongs to ${who} — re-login`;
389
+ }
390
+ return {
391
+ detail: `${why}: create-if-absent + log in as ${ctx.mxid}, token → ${ctx.envFileLabel} (a re-login mints a new Matrix device)`,
392
+ run: async () => {
393
+ confirm({
394
+ network: ctx.network,
395
+ signer: `${ctx.address} (signs the rooms bot's challenge)`,
396
+ action: "create + log in to the oracle's own Matrix account",
397
+ lines: [
398
+ `account: ${ctx.mxid}`,
399
+ `rooms bot: ${roomsBotUrl(ctx.matrixBase)}`,
400
+ `access token → ${ctx.envFileLabel} (never printed)`,
401
+ ],
402
+ }, ctx.yes);
403
+ const secpMnemonic = oracleKey(ctx, ctx.secpMnemonic, "ORACLE_SECP_MNEMONIC", "matrix");
404
+ const password = matrixPassword(secpMnemonic);
405
+ await createMatrixAccount({ log: (message) => console.log(` ${message}`) }, {
406
+ homeserverUrl: ctx.matrixBase,
407
+ address: ctx.address,
408
+ secpMnemonic,
409
+ password,
410
+ });
411
+ const token = await matrixLogin(ctx.matrixBase, ctx.mxid, password);
412
+ appendDevVar(ctx.envFile, "ORACLE_MATRIX_ACCESS_TOKEN", token);
413
+ ctx.token = token;
414
+ // The display name is what a reviewer sees on the oracle's cards. The running oracle knows
415
+ // its own; before it is deployed, the MXID is at least unambiguous.
416
+ const info = await ctx.kitInfo();
417
+ await setDisplayName(ctx.matrixBase, token, ctx.mxid, info?.name ?? ctx.mxid);
418
+ console.log(`✓ ${ctx.mxid} ready — ORACLE_MATRIX_ACCESS_TOKEN written to ${ctx.envFileLabel}`);
419
+ console.log(" set it deployed with: wrangler secret put ORACLE_MATRIX_ACCESS_TOKEN");
420
+ },
421
+ };
422
+ },
423
+ /** 5. The entity — one tx carrying both services and the protocol edge. */
424
+ async entity(ctx) {
425
+ if (ctx.entityDid) {
426
+ return { detail: `${ctx.entityDid} is this oracle's (${ctx.entityBinding})` };
427
+ }
428
+ return {
429
+ detail: `MsgCreateEntity (oracle) owned by ${ctx.signer.did}, carrying #matrix, #eval and the protocol edge — none of this session's oracle entities is bound to this oracle (#orz granting ${ctx.address}, or #eval at ${ctx.kitUrl}); if you created one moments ago, wait for the indexer before --yes or a second entity is minted`,
430
+ run: async () => {
431
+ ctx.entityDid = await createOracleEntity(ctx);
432
+ },
433
+ };
434
+ },
435
+ /** 6. `#orz` — how the portal maps this entity to the account that holds its claim authz. */
436
+ async orz(ctx) {
437
+ if (!ctx.entityDid)
438
+ return afterEntity("#orz oracleAuthZConfig");
439
+ const entity = await entityState(ctx, ctx.entityDid);
440
+ const anchored = entity.linkedResource.find((r) => r.id.endsWith("#orz"));
441
+ if (anchored) {
442
+ // The address the portal grants claim authz to is baked into the anchored bytes, so rotating
443
+ // the oracle identity leaves the OLD one on chain and this step still says "already". The
444
+ // chain has no update for a LinkedResource and `MsgDeleteLinkedResource` is out of scope, so
445
+ // the most a re-run can do is name it.
446
+ const grantee = await orzGrantee(anchored);
447
+ if (typeof grantee === "string" && grantee !== ctx.address) {
448
+ return {
449
+ detail: `⚠ #orz on ${ctx.entityDid} grants ${grantee}, not ORACLE_ADDRESS ${ctx.address} — re-anchoring it is manual (this command cannot replace a LinkedResource)`,
450
+ };
451
+ }
452
+ if (!onMatrixMedia(anchored))
453
+ return { detail: `#orz already on ${ctx.entityDid}` };
454
+ const live = (await fetchDoc(anchored))?.json ?? null;
455
+ if (live === null || typeof live !== "object") {
456
+ return {
457
+ detail: `⚠ #orz on ${ctx.entityDid} could not be read (${anchored.serviceEndpoint}) — left as is; re-run to retry`,
458
+ };
459
+ }
460
+ return {
461
+ detail: `replace #orz (moves off Matrix media, same document) — uploaded as ${ctx.signer.did}`,
462
+ run: () => anchorDoc(ctx, {
463
+ fragment: "#orz",
464
+ type: anchored.type,
465
+ description: anchored.description || "Oracle AuthZ Config",
466
+ filename: "authz.json",
467
+ doc: live,
468
+ memo: "orz",
469
+ replace: anchored.id,
470
+ }),
471
+ };
472
+ }
473
+ return {
474
+ detail: `#orz oracleAuthZConfig → granteeAddress ${ctx.address}`,
475
+ run: async () => {
476
+ // qiforge `src/utils/entity.ts:142-193` (`createAuthZConfig`), field for field — the doc at
477
+ // :155-175, the resource's own fields at :183-192. The two load-bearing ones are
478
+ // `granteeAddress` (the portal resolves the oracle's auth DID from it) and
479
+ // `requiredPermissions` (what its Grant-Role flow offers to grant).
480
+ const doc = {
481
+ "@context": [
482
+ "https://schema.org",
483
+ {
484
+ ixo: "https://w3id.org/ixo/context/v1",
485
+ oracle: { "@id": ctx.entityDid, "@type": "@id" },
486
+ },
487
+ ],
488
+ "@type": "Service",
489
+ "@id": "oracle:OracleAuthorization",
490
+ name: "OracleAuthorization",
491
+ description: "OracleAuthorization",
492
+ serviceType: "OracleClaimAuthorizationService",
493
+ requiredPermissions: ["/ixo.claims.v1beta1.MsgCreateClaimAuthorization"],
494
+ granteeAddress: ctx.address,
495
+ granterAddress: "",
496
+ // Decorative (the name a portal shows lives in `#pro`), so an undeployed oracle anchors
497
+ // "" rather than blocking the step on a kit that isn't up yet.
498
+ oracleName: (await ctx.kitInfo())?.name ?? "",
499
+ };
500
+ await anchorDoc(ctx, {
501
+ fragment: "#orz",
502
+ type: "oracleAuthZConfig",
503
+ // Decorative — the LinkedResource description, not a lookup key. qiforge anchors the typo
504
+ // "Orale AuthZ Config" (ixo-oracles-cli src/utils/entity.ts:190); we keep the correct
505
+ // spelling, matching the portal's own producer (impacts-x-web entityCreation.ts:316).
506
+ description: "Oracle AuthZ Config",
507
+ filename: "authz.json",
508
+ doc,
509
+ memo: "orz",
510
+ });
511
+ },
512
+ };
513
+ },
514
+ /** 7. `#pro` — the name/description a portal lists, taken from the oracle that is actually running. */
515
+ async profile(ctx) {
516
+ if (!ctx.entityDid)
517
+ return afterEntity("#pro profile");
518
+ const entity = await entityState(ctx, ctx.entityDid);
519
+ const anchored = entity.linkedResource.find((r) => r.id.endsWith("#pro"));
520
+ if (anchored) {
521
+ // Add-only, with ONE exception: a `--logo` the live profile does not carry. The portal's
522
+ // avatar is `#pro.logo`, so a logo passed after the first run would otherwise never show.
523
+ // The live profile is the base — everything else in it (a hand-edited name, a location)
524
+ // stays exactly as it is.
525
+ const moving = onMatrixMedia(anchored);
526
+ if (!ctx.logo && !moving)
527
+ return { detail: `#pro already on ${ctx.entityDid}` };
528
+ const live = (await fetchDoc(anchored))?.json ?? null;
529
+ if (live === null || typeof live !== "object") {
530
+ return {
531
+ detail: `⚠ #pro on ${ctx.entityDid} could not be read (${anchored.serviceEndpoint}) — left as is; re-run to retry`,
532
+ };
533
+ }
534
+ const profile = live;
535
+ const logo = ctx.logo || profile.logo;
536
+ if (profile.logo === logo && !moving) {
537
+ return { detail: `#pro already on ${ctx.entityDid}, with logo ${ctx.logo}` };
538
+ }
539
+ return {
540
+ detail: `${profile.logo === logo
541
+ ? "replace #pro (moves off Matrix media, same profile)"
542
+ : `replace #pro logo: ${String(profile.logo || "(none)")} → ${ctx.logo} (merged onto the live profile)`} — uploaded as ${ctx.signer.did}`,
543
+ run: () => anchorDoc(ctx, {
544
+ fragment: "#pro",
545
+ type: "Settings",
546
+ description: "Profile",
547
+ filename: "profile.json",
548
+ doc: { ...profile, logo },
549
+ memo: "profile",
550
+ identityDoc: true,
551
+ replace: anchored.id,
552
+ }),
553
+ };
554
+ }
555
+ const info = await ctx.kitInfo();
556
+ if (!info) {
557
+ // Not a failure: the profile is the one step that needs the oracle deployed, and every other
558
+ // step still has to run for a provider who is doing this before their first deploy.
559
+ return { detail: `${ctx.kitUrl}/v1/info not reachable — re-run after deploy` };
560
+ }
561
+ return {
562
+ detail: `#pro Settings → "${info.name}" from ${ctx.kitUrl}/v1/info — uploaded as ${ctx.signer.did}`,
563
+ run: async () => {
564
+ // qiforge `src/utils/entity.ts:477-525` (`addProfile`) — the doc at :490-506, the resource's
565
+ // own fields at :515-524. `orgName`/`brand`/`location`/`image` are qiforge's separate
566
+ // prompts; the oracle's own `/v1/info` is the only source here, so the names are all it and
567
+ // the rest are empty (a portal reads them as absent either way).
568
+ const doc = {
569
+ "@context": {
570
+ ixo: "https://w3id.org/ixo/ns/protocol/",
571
+ "@id": "@type",
572
+ type: "@type",
573
+ "@protected": false,
574
+ },
575
+ id: "ixo:entity#profile",
576
+ type: "profile",
577
+ orgName: info.name,
578
+ name: info.name,
579
+ image: "",
580
+ logo: ctx.logo,
581
+ brand: info.name,
582
+ location: "",
583
+ description: info.description,
584
+ };
585
+ await anchorDoc(ctx, {
586
+ fragment: "#pro",
587
+ type: "Settings",
588
+ description: "Profile",
589
+ filename: "profile.json",
590
+ doc,
591
+ memo: "profile",
592
+ identityDoc: true,
593
+ });
594
+ },
595
+ };
596
+ },
597
+ /** 8. `#dmn` — the domain card the indexer, the portal and the console list this oracle by. */
598
+ async domain(ctx) {
599
+ if (!ctx.entityDid)
600
+ return afterEntity("#dmn domainCard");
601
+ const info = await ctx.kitInfo();
602
+ if (!info)
603
+ return { detail: `${ctx.kitUrl}/v1/info not reachable — re-run after deploy` };
604
+ const card = buildDomainCard(await cardSource(ctx, info));
605
+ return cardPlan(ctx, card, {
606
+ fragment: "#dmn",
607
+ type: "domainCard",
608
+ description: "Domain Card",
609
+ filename: "domainCard.json",
610
+ memo: "domain",
611
+ label: `#dmn domainCard "${info.name}"${ctx.logo ? ` (logo ${ctx.logo})` : ` (${NO_LOGO})`}`,
612
+ });
613
+ },
614
+ /** 9. `#acard` — the Agent Card the portal's contract flow reads (`fetchAgentCard`). */
615
+ async acard(ctx) {
616
+ if (!ctx.entityDid)
617
+ return afterEntity("#acard agentCard");
618
+ const info = await ctx.kitInfo();
619
+ if (!info)
620
+ return { detail: `${ctx.kitUrl}/v1/info not reachable — re-run after deploy` };
621
+ const card = buildAgentCard(await cardSource(ctx, info));
622
+ if (card.credentialSubject.services.length === 0) {
623
+ return {
624
+ detail: `nothing to card — ${ctx.kitUrl} publishes no evaluation pricing and no Decision API price for ${ctx.protocolDid}`,
625
+ };
626
+ }
627
+ const { schema, source } = await agentCardSchema(NETWORKS[ctx.network].engineHost);
628
+ const services = card.credentialSubject.services.map((s) => s.id).join(", ");
629
+ return cardPlan(ctx, card, {
630
+ fragment: "#acard",
631
+ type: "agentCard",
632
+ description: "Agent Card",
633
+ filename: "agentCard.json",
634
+ memo: "acard",
635
+ label: `#acard agentCard "${info.name}" (services: ${services})`,
636
+ },
637
+ // Before anything is planned, let alone uploaded — and on the card that would really be
638
+ // written, the provider's merged-in services included: a card the engine refuses to parse is
639
+ // a bug here (or schema drift), and anchoring it would put an unreadable card in front of
640
+ // every portal that lists this oracle.
641
+ (doc) => {
642
+ const errors = validateAgentCard(doc, schema);
643
+ if (errors.length > 0) {
644
+ fail(`the Agent Card fails ${source}:\n${errors.map((e) => ` - ${e}`).join("\n")}`);
645
+ }
646
+ });
647
+ },
648
+ /** 10. The oracle→protocol edge the portal's marketplace query filters on. */
649
+ async linked(ctx) {
650
+ if (!ctx.entityDid)
651
+ return afterEntity(`linkedEntity → ${ctx.protocolDid} (protocol)`);
652
+ const entityDid = ctx.entityDid;
653
+ // The LIVE entity, never a value carried from step 5: this is what makes the step correct
654
+ // whether the edge arrived inline with creation or is missing from an oracle made years ago.
655
+ const entity = await entityState(ctx, entityDid);
656
+ if (entity.linkedEntity.some((le) => le.id === ctx.protocolDid && le.relationship === "protocol")) {
657
+ return { detail: `edge → ${ctx.protocolDid} already on ${entityDid}` };
658
+ }
659
+ return {
660
+ detail: `MsgAddLinkedEntity → ${ctx.protocolDid} (${ctx.protocolType}, relationship: protocol)`,
661
+ run: async () => {
662
+ const msg = await addLinkedEntityMsg(entityDid, { id: ctx.protocolDid, type: ctx.protocolType, relationship: "protocol", service: "" }, ctx.signer.address);
663
+ confirm({
664
+ network: ctx.network,
665
+ signer: ctx.signer.address,
666
+ action: "MsgAddLinkedEntity (oracle → protocol)",
667
+ lines: [
668
+ `oracle: ${entityDid}`,
669
+ `protocol: ${ctx.protocolDid} (${ctx.protocolType})`,
670
+ "relationship: protocol",
671
+ ],
672
+ fee: STANDARD_FEE,
673
+ }, ctx.yes);
674
+ const { hash } = await broadcast(ctx.signer, [msg], "oracle-init: linked");
675
+ console.log(`✓ linkedEntity → ${ctx.protocolDid} added (tx ${hash})`);
676
+ },
677
+ };
678
+ },
679
+ /** 11. `#eval` — the endpoint a commissioner's portal calls. Re-pointable, not just creatable. */
680
+ async service(ctx) {
681
+ if (!ctx.entityDid)
682
+ return afterEntity(`#eval EvalOracleAPI → ${ctx.kitUrl}`);
683
+ const entityDid = ctx.entityDid;
684
+ const entity = await entityState(ctx, entityDid);
685
+ const current = entity.service.find((s) => s.id.endsWith("#eval"));
686
+ if (current?.serviceEndpoint === ctx.kitUrl) {
687
+ return { detail: `#eval already points at ${ctx.kitUrl}` };
688
+ }
689
+ const service = { id: "{id}#eval", type: "EvalOracleAPI", serviceEndpoint: ctx.kitUrl };
690
+ return {
691
+ detail: current
692
+ ? `re-point #eval: ${current.serviceEndpoint} → ${ctx.kitUrl}`
693
+ : `#eval EvalOracleAPI → ${ctx.kitUrl}`,
694
+ run: async () => {
695
+ // A moved oracle (a real domain after a dry run on a tunnel) needs the OLD service gone, and
696
+ // the chain has no "update": delete + add, in ONE tx, exactly as qiforge's `updateOracleDomain`
697
+ // does (`src/utils/entity.ts:199-256`) — split across two txs the entity would briefly have
698
+ // no endpoint at all.
699
+ const msgs = current
700
+ ? [
701
+ await deleteServiceMsg(entityDid, "{id}#eval", ctx.signer.address),
702
+ await addServiceMsg(entityDid, service, ctx.signer.address),
703
+ ]
704
+ : [await addServiceMsg(entityDid, service, ctx.signer.address)];
705
+ confirm({
706
+ network: ctx.network,
707
+ signer: ctx.signer.address,
708
+ action: current ? "MsgDeleteService + MsgAddService (#eval)" : "MsgAddService (#eval)",
709
+ lines: [
710
+ `oracle: ${entityDid}`,
711
+ ...(current ? [`current serviceEndpoint: ${current.serviceEndpoint}`] : []),
712
+ `serviceEndpoint: ${ctx.kitUrl}`,
713
+ ],
714
+ fee: STANDARD_FEE,
715
+ }, ctx.yes);
716
+ const { hash } = await broadcast(ctx.signer, msgs, "oracle-init: service");
717
+ console.log(`✓ #eval → ${ctx.kitUrl} (tx ${hash})`);
718
+ },
719
+ };
720
+ },
721
+ /**
722
+ * 12. The PROTOCOL's edge back to the oracle. The portal's Authorization tab lists an entity's
723
+ * oracles from exactly this, so the link has to exist in BOTH directions for its action blocks to
724
+ * work — and it is signed by the session, which must therefore own the protocol.
725
+ */
726
+ async backlink(ctx) {
727
+ if (!ctx.entityDid)
728
+ return afterEntity(`linkedEntity → this oracle on ${ctx.protocolDid}`);
729
+ const entityDid = ctx.entityDid;
730
+ const protocol = await entityState(ctx, ctx.protocolDid);
731
+ if (protocol.linkedEntity.some((le) => le.id === entityDid && le.relationship === "oracle")) {
732
+ return { detail: `edge → ${entityDid} already on ${ctx.protocolDid}` };
733
+ }
734
+ const edge = { id: entityDid, type: "oracle", relationship: "oracle", service: "" };
735
+ // The one question the IID document does not answer: the entity module's `owner` is not a field
736
+ // on it (`controller` is who may write the document, which a transfer need not have moved), so
737
+ // the "is it ours to sign?" half stays a blocksync read — a stale answer here costs a wrong
738
+ // message, never a duplicate broadcast.
739
+ const { owner } = await resolveEntity(ctx.blocksync, ctx.protocolDid);
740
+ if (owner !== ctx.signer.address) {
741
+ // Not ours to sign: say exactly what the protocol's owner has to add.
742
+ return {
743
+ detail: `${ctx.protocolDid} is owned by ${owner ?? "(unknown)"}, not this session — ask them to add: ${JSON.stringify(edge)}`,
744
+ };
745
+ }
746
+ return {
747
+ detail: `MsgAddLinkedEntity on ${ctx.protocolDid} → ${entityDid} (relationship: oracle)`,
748
+ run: async () => {
749
+ const msg = await addLinkedEntityMsg(ctx.protocolDid, edge, ctx.signer.address);
750
+ confirm({
751
+ network: ctx.network,
752
+ signer: ctx.signer.address,
753
+ action: "MsgAddLinkedEntity (protocol → oracle, the back-link)",
754
+ lines: [`protocol: ${ctx.protocolDid}`, `oracle: ${entityDid}`, "relationship: oracle"],
755
+ fee: STANDARD_FEE,
756
+ }, ctx.yes);
757
+ const { hash } = await broadcast(ctx.signer, [msg], "oracle-init: backlink");
758
+ console.log(`✓ linkedEntity → ${entityDid} added on the protocol (tx ${hash})`);
759
+ },
760
+ };
761
+ },
762
+ /**
763
+ * 13. Tell the domain indexer the entity exists — qiforge `src/utils/entity.ts:549-579`. Last, so
764
+ * it reads the `#dmn` the `domain` step just anchored. Skipped when the indexer already serves
765
+ * THAT card, finished: its `blockchain_version_id` is the anchored `#dmn` resource's proof
766
+ * (domain-indexer `types/indexed-entity.ts`) and its `status` is `completed` — so a changed card,
767
+ * or one still `pending`/`processing`, always re-submits. A dry run asks the indexer nothing: its
768
+ * `GET /domain-cards/:did` is not a pure read (it stamps `last_accessed_at`), so the check waits
769
+ * for `--yes`.
770
+ */
771
+ async index(ctx) {
772
+ const base = NETWORKS[ctx.network].domainIndexer;
773
+ const url = `${base}/index`;
774
+ if (!ctx.entityDid)
775
+ return afterEntity(`POST ${url}`);
776
+ const entityDid = ctx.entityDid;
777
+ const dmn = (await entityState(ctx, entityDid)).linkedResource.find((r) => r.id.endsWith("#dmn"));
778
+ if (dmn && ctx.yes) {
779
+ const indexed = (await fetchJson(`${base}/domain-cards/${encodeURIComponent(entityDid)}`));
780
+ if (indexed?.blockchain_version_id === dmn.proof && indexed.status === "completed") {
781
+ return { detail: `the indexer already serves the anchored #dmn (proof ${dmn.proof})` };
782
+ }
783
+ }
784
+ const check = dmn && !ctx.yes ? " — whether the indexer already serves this #dmn is checked on --yes" : "";
785
+ return {
786
+ detail: `POST ${url} { did: ${entityDid} }${dmn ? check : " — no #dmn anchored yet"}`,
787
+ run: async () => {
788
+ // A warning, never fatal (qiforge's own `log.warn`): the indexer is a convenience, the
789
+ // chain record is the truth, and nothing this command did needs undoing if it is down.
790
+ try {
791
+ const res = await fetch(url, {
792
+ method: "POST",
793
+ headers: { accept: "application/json", "content-type": "application/json" },
794
+ body: JSON.stringify({ did: entityDid }),
795
+ signal: AbortSignal.timeout(HTTP_TIMEOUT_MS),
796
+ });
797
+ if (!res.ok) {
798
+ console.log(`⚠ domain indexer refused ${entityDid}: ${res.status} ${await res.text()}`);
799
+ return;
800
+ }
801
+ console.log(`✓ ${entityDid} submitted to the domain indexer`);
802
+ }
803
+ catch (err) {
804
+ console.log(`⚠ domain indexer unreachable (${err instanceof Error ? err.message : String(err)})`);
805
+ }
806
+ },
807
+ };
808
+ },
809
+ };
810
+ // --- the writes the steps share -------------------------------------------------------------------
811
+ async function createOracleEntity(ctx) {
812
+ const { customMessages, ixo, utils } = await import("@ixo/impactxclient-sdk");
813
+ const now = Date.now();
814
+ confirm({
815
+ network: ctx.network,
816
+ signer: ctx.signer.address,
817
+ action: "MsgCreateEntity (oracle)",
818
+ lines: [
819
+ `owner: ${ctx.signer.did} (the AuthHub session that ran this — see the header comment)`,
820
+ `relayerNode: ${NETWORKS[ctx.network].relayerNodeDid}`,
821
+ `service #matrix: ${ctx.matrixBase}`,
822
+ `service #eval: ${ctx.kitUrl}`,
823
+ `linkedEntity → protocol: ${ctx.protocolDid} (${ctx.protocolType}, relationship: protocol)`,
824
+ ],
825
+ fee: STANDARD_FEE,
826
+ }, ctx.yes);
827
+ const msg = {
828
+ typeUrl: "/ixo.entity.v1beta1.MsgCreateEntity",
829
+ value: ixo.entity.v1beta1.MsgCreateEntity.fromPartial({
830
+ entityType: "oracle",
831
+ entityStatus: 0,
832
+ context: [],
833
+ // The exact shape `createEntity` (lib/chain.ts) uses for a protocol entity — the two entity
834
+ // kinds this CLI creates stay identical here.
835
+ verification: customMessages.iid.createIidVerificationMethods({
836
+ did: ctx.signer.did,
837
+ pubkey: await ctx.signer.getPubkey(),
838
+ address: ctx.signer.address,
839
+ controller: ctx.signer.did,
840
+ type: "secp",
841
+ }),
842
+ controller: [ctx.signer.did],
843
+ ownerAddress: ctx.signer.address,
844
+ ownerDid: ctx.signer.did,
845
+ relayerNode: NETWORKS[ctx.network].relayerNodeDid,
846
+ // Both services AND the protocol edge go in the SAME tx as creation — a fresh oracle needs
847
+ // exactly one broadcast, never a create-then-patch dance (`MsgCreateEntity.fromPartial`
848
+ // recurses `Service.fromPartial`/`LinkedEntity.fromPartial` over these plain objects itself).
849
+ service: [
850
+ { id: "{id}#matrix", type: "MatrixHomeServer", serviceEndpoint: ctx.matrixBase },
851
+ { id: "{id}#eval", type: "EvalOracleAPI", serviceEndpoint: ctx.kitUrl },
852
+ ],
853
+ linkedEntity: [
854
+ { id: ctx.protocolDid, type: ctx.protocolType, relationship: "protocol", service: "" },
855
+ ],
856
+ // An entity with no window is not shown by the portal — qiforge's own now → +100y
857
+ // (`src/utils/entity.ts:107-110`).
858
+ startDate: utils.proto.toTimestamp(new Date(now)),
859
+ endDate: utils.proto.toTimestamp(new Date(now + 100 * 365 * 24 * 60 * 60 * 1000)),
860
+ }),
861
+ };
862
+ const { hash, res } = await broadcast(ctx.signer, [msg], "oracle-init: entity");
863
+ const entityDid = entityDidFromEvents(res.events);
864
+ if (!entityDid)
865
+ fail(`entity created (tx ${hash}) but the DID could not be read from tx events`);
866
+ console.log(`✓ oracle entity created: ${entityDid} (tx ${hash})`);
867
+ // Pinned BEFORE anything else can fail: blocksync lists a new entity minutes late, so a re-run
868
+ // after a failure further down would find no entity bound to this oracle and mint a second one.
869
+ // With the pin, the re-run takes the `ORACLE_ENTITY_DID` path instead.
870
+ appendDevVar(ctx.envFile, "ORACLE_ENTITY_DID", entityDid);
871
+ ctx.entityPinned = true;
872
+ console.log(` ORACLE_ENTITY_DID written to ${ctx.envFileLabel} — a re-run uses it`);
873
+ // Every step after this one reads the LIVE entity to decide whether to write, so the document has
874
+ // to be readable first or they would all re-add what the creation tx already carried. The tx is
875
+ // committed by now, so the chain answers immediately — the retry is only for the node behind the
876
+ // RPC endpoint being a beat behind the one that accepted the broadcast.
877
+ for (let attempt = 0; attempt < 3; attempt++) {
878
+ if (attempt > 0)
879
+ await new Promise((r) => setTimeout(r, 1000));
880
+ if (await entityDocument(ctx.rpc, entityDid))
881
+ return entityDid;
882
+ }
883
+ fail(`entity ${entityDid} created but its IID document is not readable on ${ctx.rpc} yet — re-run \`oracle init --yes\` to finish the remaining steps`);
884
+ }
885
+ /**
886
+ * Store a JSON document on the IXO Vault (else the IPFS gateway — `uploadDoc`), signed as the
887
+ * entity's OWNER, the AuthHub session, and anchor it as a `LinkedResource`. Two writes, two confirm
888
+ * gates, one step.
889
+ */
890
+ async function anchorDoc(ctx, resource) {
891
+ const entityDid = ctx.entityDid ?? fail("no oracle entity to anchor onto");
892
+ const bytes = new TextEncoder().encode(JSON.stringify(resource.doc));
893
+ confirm({
894
+ network: ctx.network,
895
+ signer: ctx.signer.did,
896
+ action: `upload ${resource.filename} to the IXO Vault (else the IPFS gateway)`,
897
+ lines: [`${bytes.byteLength} bytes → ${resource.fragment} on ${entityDid}`],
898
+ }, ctx.yes);
899
+ const { url, cid } = await uploadDoc(ctx.network, sessionDocSigner(ctx.signer), bytes, resource.filename, resource.identityDoc ? "application/ld+json" : "application/json");
900
+ const proof = resource.identityDoc ? cid : await sha256Hex(bytes);
901
+ const add = await addLinkedResourceMsg(entityDid, {
902
+ id: `{id}${resource.fragment}`,
903
+ type: resource.type,
904
+ description: resource.description,
905
+ mediaType: "application/json",
906
+ serviceEndpoint: url,
907
+ proof,
908
+ encrypted: "false",
909
+ right: "",
910
+ }, ctx.signer.address);
911
+ const msgs = resource.replace
912
+ ? [await deleteLinkedResourceMsg(entityDid, resource.replace, ctx.signer.address), add]
913
+ : [add];
914
+ confirm({
915
+ network: ctx.network,
916
+ signer: ctx.signer.address,
917
+ action: resource.replace
918
+ ? `MsgDeleteLinkedResource + MsgAddLinkedResource ${resource.fragment} (${resource.type})`
919
+ : `MsgAddLinkedResource ${resource.fragment} (${resource.type})`,
920
+ lines: [
921
+ `entity: ${entityDid}`,
922
+ ...(resource.replace ? [`replacing: ${resource.replace}`] : []),
923
+ `serviceEndpoint: ${url}`,
924
+ `proof: ${proof}`,
925
+ ],
926
+ fee: STANDARD_FEE,
927
+ }, ctx.yes);
928
+ const { hash } = await broadcast(ctx.signer, msgs, `oracle-init: ${resource.memo}`);
929
+ console.log(`✓ ${resource.fragment} ${resource.type} anchored (tx ${hash})`);
930
+ }
931
+ // --- the command ----------------------------------------------------------------------------------
932
+ export async function run(argv) {
933
+ const { values } = parse(argv, {
934
+ options: {
935
+ protocol: { type: "string" },
936
+ "kit-url": { type: "string" },
937
+ network: { type: "string" },
938
+ "env-file": { type: "string" },
939
+ logo: { type: "string" },
940
+ openhands: { type: "boolean" },
941
+ "price-pay": { type: "string" },
942
+ only: { type: "string" },
943
+ relogin: { type: "boolean" },
944
+ yes: { type: "boolean" },
945
+ },
946
+ });
947
+ const protocolDid = values.protocol ?? fail("--protocol <did> is required");
948
+ const kitUrl = resolveKitUrl(values["kit-url"] ?? fail("--kit-url <http(s) url> is required"));
949
+ const network = resolveNetwork(values.network);
950
+ const only = resolveStep(values.only);
951
+ const yes = values.yes === true;
952
+ const openhands = values.openhands === true;
953
+ const pricePay = values["price-pay"];
954
+ if (pricePay !== undefined && !openhands)
955
+ fail("--price-pay only prices --openhands");
956
+ const pricePayMicroUsd = pricePay === undefined
957
+ ? undefined
958
+ : /^\d+(\.\d{1,6})?$/.test(pricePay) && Number(pricePay) > 0
959
+ ? Math.round(Number(pricePay) * 1_000_000)
960
+ : fail(`--price-pay must be a positive PAY amount (1 PAY = 1 USD), got '${pricePay}'`);
961
+ // ---- the oracle's own identity, from the project's own config files ----------------------------
962
+ const envFileLabel = values["env-file"] ?? ".dev.vars";
963
+ const envFile = resolve(process.cwd(), envFileLabel);
964
+ const env = (() => {
965
+ try {
966
+ return readProjectEnv(process.cwd(), { envFile: values["env-file"] });
967
+ }
968
+ catch (err) {
969
+ return fail(err instanceof Error ? err.message : String(err));
970
+ }
971
+ })();
972
+ const missing = REQUIRED_VARS.filter((key) => !env[key]);
973
+ if (missing.length > 0) {
974
+ fail(`missing ${missing.join(", ")} — set them in wrangler.jsonc "vars" or ${envFileLabel} ` +
975
+ "(`decision-oracle derive` prints the identity lines)");
976
+ }
977
+ const address = env.ORACLE_ADDRESS;
978
+ const did = `did:ixo:${address}`;
979
+ const matrixBase = NETWORKS[network].matrix.replace(/\/+$/, "");
980
+ const mxid = mxidFromDid(did, new URL(matrixBase).hostname);
981
+ // Both are DERIVED values a provider pasted in by hand — if either disagrees with ORACLE_ADDRESS,
982
+ // this command would write the wrong DID on chain or log into the wrong Matrix account, so they
983
+ // are checked before anything at all runs. (`ORACLE_ADDRESS` vs the mnemonic is asserted offline
984
+ // by `oracleWalletSigner` just below.)
985
+ if (env.ORACLE_DID !== did) {
986
+ fail(`ORACLE_DID (${env.ORACLE_DID}) is not ORACLE_ADDRESS's DID (${did})`);
987
+ }
988
+ if (env.ORACLE_MATRIX_USER_ID !== mxid) {
989
+ fail(`ORACLE_MATRIX_USER_ID (${env.ORACLE_MATRIX_USER_ID}) is not ${network}'s MXID for ${did} — expected ${mxid}`);
990
+ }
991
+ const signer = await buildSigner(network);
992
+ // Optional, but still asserted against ORACLE_ADDRESS up front whenever present.
993
+ const secpMnemonic = env.ORACLE_SECP_MNEMONIC || undefined;
994
+ const oracleSigner = secpMnemonic
995
+ ? await oracleWalletSigner(network, secpMnemonic, address)
996
+ : undefined;
997
+ const edPublicKey = env.SERVICE_ED25519_MNEMONIC
998
+ ? (await deriveServiceKey(env.SERVICE_ED25519_MNEMONIC)).publicKeyRaw
999
+ : undefined;
1000
+ // Blocksync/RPC endpoints come ONLY from `NETWORKS[network]` (the `--network` flag), never the env
1001
+ // file — see the identical note in `create-collection`/`publish-protocol`.
1002
+ const blocksync = NETWORKS[network].blocksync;
1003
+ const protocolEntity = await resolveEntity(blocksync, protocolDid);
1004
+ if (!protocolEntity.type) {
1005
+ fail(`protocol ${protocolDid} did not resolve on blocksync (indexer lag? wrong network/DID?)`);
1006
+ }
1007
+ let info;
1008
+ let apiPrice;
1009
+ const ctx = {
1010
+ network,
1011
+ yes,
1012
+ relogin: values.relogin === true,
1013
+ logo: values.logo ?? "",
1014
+ openhands,
1015
+ pricePayMicroUsd,
1016
+ kitUrl,
1017
+ blocksync,
1018
+ rpc: NETWORKS[network].rpc,
1019
+ matrixBase,
1020
+ address,
1021
+ did,
1022
+ mxid,
1023
+ secpMnemonic,
1024
+ edPublicKey,
1025
+ envFile,
1026
+ envFileLabel,
1027
+ token: env.ORACLE_MATRIX_ACCESS_TOKEN,
1028
+ signer,
1029
+ oracleSigner,
1030
+ protocolDid,
1031
+ protocolType: protocolEntity.type,
1032
+ entityDid: undefined,
1033
+ entityBinding: "",
1034
+ entityPinned: false,
1035
+ kitInfo: () =>
1036
+ // A deadline, not just a catch: a `wrangler dev` mid-boot accepts the socket and answers
1037
+ // nothing, which hung a live dry run for 32 minutes — a timeout reads as "not deployed yet",
1038
+ // the same as a refused connection.
1039
+ (info ??= fetch(`${kitUrl}/v1/info`, { signal: AbortSignal.timeout(HTTP_TIMEOUT_MS) })
1040
+ .then(async (res) => {
1041
+ if (!res.ok)
1042
+ return null;
1043
+ const body = (await res.json());
1044
+ if (typeof body.name !== "string")
1045
+ return null;
1046
+ const { evaluation, byProtocol, api } = body.pricing ?? {};
1047
+ const apiMicroUsd = api
1048
+ ? (api.byProtocol?.[protocolDid] ?? api.amountMicroUsd)
1049
+ : undefined;
1050
+ return {
1051
+ name: body.name,
1052
+ description: typeof body.description === "string" ? body.description : "",
1053
+ ...(evaluation
1054
+ ? { evaluationFee: evaluationFeeFor({ evaluation, byProtocol }, protocolDid) }
1055
+ : {}),
1056
+ ...(apiMicroUsd !== undefined ? { apiMicroUsd } : {}),
1057
+ };
1058
+ })
1059
+ // Not deployed yet, or down — every caller here treats that as "no info", never a failure.
1060
+ .catch(() => null)),
1061
+ // The lane's public catalogue answers iff API_LANE is on (otherwise the lane's own 404), and
1062
+ // its `price` IS `publishedPrice` — `byProtocol`, then `amountMicroUsd`, then the
1063
+ // `API_PRICE_USD_CENTS` var — resolved by the running oracle itself, so the card can never
1064
+ // advertise a price the facilitator would refuse.
1065
+ apiPrice: () => (apiPrice ??= fetch(`${kitUrl}/v1/api/protocols`, {
1066
+ signal: AbortSignal.timeout(HTTP_TIMEOUT_MS),
1067
+ })
1068
+ .then(async (res) => {
1069
+ if (!res.ok)
1070
+ return null;
1071
+ const { items } = (await res.json());
1072
+ return items?.find((i) => i.protocolDid === protocolDid)?.price?.amountMicroUsd ?? null;
1073
+ })
1074
+ .catch(() => null)),
1075
+ };
1076
+ // The pin is per deployment: `env.<network>.vars` when wrangler.jsonc declares that env (where a
1077
+ // provider keeps each network's entity), else the top-level vars — `.dev.vars` winning either way.
1078
+ const pinned = (() => {
1079
+ try {
1080
+ return readProjectEnv(process.cwd(), { envFile: values["env-file"], env: network })
1081
+ .ORACLE_ENTITY_DID;
1082
+ }
1083
+ catch {
1084
+ return env.ORACLE_ENTITY_DID;
1085
+ }
1086
+ })();
1087
+ const bound = await resolveOracleEntity(ctx, pinned || undefined);
1088
+ ctx.entityDid = bound?.did;
1089
+ ctx.entityBinding = bound?.binding ?? "";
1090
+ ctx.entityPinned = bound?.binding.startsWith("ORACLE_ENTITY_DID") ?? false;
1091
+ console.log(`signer : ${signer.address} (${network})`);
1092
+ console.log(`oracle : ${did}`);
1093
+ console.log(`entity : ${ctx.entityDid ? `${ctx.entityDid} (${ctx.entityBinding})` : "(none yet)"}\n`);
1094
+ for (const step of only ? [only] : STEPS) {
1095
+ const plan = await PLAN[step](ctx);
1096
+ console.log(` ${step.padEnd(10)}${(plan.run ? "do" : "skip").padEnd(4)} ${plan.detail}`);
1097
+ if (yes)
1098
+ await plan.run?.();
1099
+ }
1100
+ if (!yes) {
1101
+ console.log("\n DRY RUN — nothing signed, created or written. Re-run with --yes to execute.");
1102
+ }
1103
+ console.log("\n════ oracle ════");
1104
+ console.log(`oracle entity DID : ${ctx.entityDid ?? "(not created yet)"}`);
1105
+ if (ctx.entityDid && !ctx.entityPinned) {
1106
+ console.log(` set ORACLE_ENTITY_DID="${ctx.entityDid}" (a wrangler.jsonc var) — it pins this entity for every later run, and the review card names it`);
1107
+ }
1108
+ if (!ctx.logo) {
1109
+ // Optional by the owner's call, but never silently: the full identity is mandatory, and a
1110
+ // card without a logo is the one part of it a provider can still improve.
1111
+ console.log("\n⚠ recommended: --logo <https url> — without it the domain card carries no logo, and the portal and the console show a placeholder");
1112
+ }
1113
+ if (ctx.entityDid) {
1114
+ // The portal's marketplace query verbatim (impacts-x-web `gqlEvalOraclesByProtocol`): the edge
1115
+ // filter lives under `iidById`, not on `entities` directly.
1116
+ console.log("\nverify on blocksync (the portal's marketplace filter — oracles linked to this protocol):");
1117
+ console.log(` query { entities(filter: { type: { in: ["oracle", "oracle/evaluation"] }, iidById: { linkedEntity: { contains: [{ id: "${protocolDid}", relationship: "protocol" }] } } }) { nodes { id } } }`);
1118
+ }
1119
+ console.log("");
1120
+ return 0;
1121
+ }
1122
+ //# sourceMappingURL=oracle-init.js.map