buckyos 0.7.5-99 → 0.7.115

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 (342) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +283 -0
  3. package/cli/README.md +73 -0
  4. package/cli/core/app.ts +564 -0
  5. package/cli/core/argv.ts +447 -0
  6. package/cli/core/auth.ts +482 -0
  7. package/cli/core/command.ts +72 -0
  8. package/cli/core/config.ts +561 -0
  9. package/cli/core/context.ts +80 -0
  10. package/cli/core/download.ts +74 -0
  11. package/cli/core/errors.ts +107 -0
  12. package/cli/core/history.ts +67 -0
  13. package/cli/core/identity.ts +425 -0
  14. package/cli/core/output.ts +113 -0
  15. package/cli/core/registry.ts +208 -0
  16. package/cli/core/repl.ts +151 -0
  17. package/cli/core/runtime.ts +207 -0
  18. package/cli/core/service.ts +77 -0
  19. package/cli/core/task.ts +189 -0
  20. package/cli/deno.json +21 -0
  21. package/cli/dist/cli.mjs +9360 -0
  22. package/cli/dist/cli.mjs.map +1 -0
  23. package/cli/fixtures/appdoc-v1.json +24 -0
  24. package/cli/fixtures/appdoc-v1.object-id +1 -0
  25. package/cli/launcher.mjs +3 -0
  26. package/cli/main.ts +8 -0
  27. package/cli/modules/app.ts +1678 -0
  28. package/cli/modules/auth.ts +50 -0
  29. package/cli/modules/core.ts +343 -0
  30. package/cli/modules/diagnostic.ts +168 -0
  31. package/cli/modules/log.ts +280 -0
  32. package/cli/modules/pikg.ts +1513 -0
  33. package/cli/modules/pikg_archive.ts +871 -0
  34. package/cli/modules/pikg_protocol.ts +1132 -0
  35. package/cli/modules/system.ts +32 -0
  36. package/cli/modules/system_config.ts +265 -0
  37. package/cli/modules/task.ts +334 -0
  38. package/cli/runtime/host.ts +397 -0
  39. package/cli/runtime/host_deno.ts +533 -0
  40. package/cli/runtime/host_node.ts +609 -0
  41. package/cli/runtime/node_entry.ts +23 -0
  42. package/cli/system_bootstrap.ts +41 -0
  43. package/cli/system_launcher.ts +25 -0
  44. package/cli/version.ts +5 -0
  45. package/dist/account.d.ts +20 -0
  46. package/dist/account.d.ts.map +1 -0
  47. package/dist/aicc_client.d.ts +714 -0
  48. package/dist/aicc_client.d.ts.map +1 -0
  49. package/dist/app_identity.d.ts +13 -0
  50. package/dist/app_identity.d.ts.map +1 -0
  51. package/dist/auth_client.d.ts +12 -0
  52. package/dist/auth_client.d.ts.map +1 -0
  53. package/dist/bns_client.d.ts +330 -0
  54. package/dist/bns_client.d.ts.map +1 -0
  55. package/dist/bns_evm_tx.d.ts +63 -0
  56. package/dist/bns_evm_tx.d.ts.map +1 -0
  57. package/dist/bns_tx_executor.d.ts +60 -0
  58. package/dist/bns_tx_executor.d.ts.map +1 -0
  59. package/dist/browser.cjs +2 -0
  60. package/dist/browser.cjs.map +1 -0
  61. package/dist/browser.d.ts +87 -0
  62. package/dist/browser.d.ts.map +1 -0
  63. package/dist/browser.mjs +226 -0
  64. package/dist/browser.mjs.map +1 -0
  65. package/dist/cert.d.ts +82 -0
  66. package/dist/cert.d.ts.map +1 -0
  67. package/dist/dev_test_keys.d.ts +32 -0
  68. package/dist/dev_test_keys.d.ts.map +1 -0
  69. package/dist/device_identity.d.ts +37 -0
  70. package/dist/device_identity.d.ts.map +1 -0
  71. package/dist/index.cjs +2 -0
  72. package/dist/index.cjs.map +1 -0
  73. package/dist/index.d.ts +91 -0
  74. package/dist/index.d.ts.map +1 -0
  75. package/dist/index.mjs +234 -0
  76. package/dist/index.mjs.map +1 -0
  77. package/dist/internal/hash_worker.d.ts +38 -0
  78. package/dist/internal/hash_worker.d.ts.map +1 -0
  79. package/dist/internal/tus_client.d.ts +2 -0
  80. package/dist/internal/tus_client.d.ts.map +1 -0
  81. package/dist/kevent_client.d.ts +71 -0
  82. package/dist/kevent_client.d.ts.map +1 -0
  83. package/dist/krpc_client.d.ts +66 -0
  84. package/dist/krpc_client.d.ts.map +1 -0
  85. package/dist/msg_center_client.d.ts +417 -0
  86. package/dist/msg_center_client.d.ts.map +1 -0
  87. package/dist/msg_queue_client.d.ts +60 -0
  88. package/dist/msg_queue_client.d.ts.map +1 -0
  89. package/dist/namelib.d.ts +185 -0
  90. package/dist/namelib.d.ts.map +1 -0
  91. package/dist/ndm_client.d.ts +392 -0
  92. package/dist/ndm_client.d.ts.map +1 -0
  93. package/dist/ndm_proxy-36879436.js +13 -0
  94. package/dist/ndm_proxy-36879436.js.map +1 -0
  95. package/dist/ndm_proxy-a719bc58.mjs +28609 -0
  96. package/dist/ndm_proxy-a719bc58.mjs.map +1 -0
  97. package/dist/ndm_proxy.d.ts +305 -0
  98. package/dist/ndm_proxy.d.ts.map +1 -0
  99. package/dist/ndn_store.d.ts +1 -0
  100. package/dist/ndn_store.d.ts.map +1 -0
  101. package/dist/ndn_types-c4672b04.js +2 -0
  102. package/dist/ndn_types-c4672b04.js.map +1 -0
  103. package/dist/ndn_types-ca94286b.mjs +3662 -0
  104. package/dist/ndn_types-ca94286b.mjs.map +1 -0
  105. package/dist/ndn_types.d.ts +416 -0
  106. package/dist/ndn_types.d.ts.map +1 -0
  107. package/dist/node.cjs +2 -0
  108. package/dist/node.cjs.map +1 -0
  109. package/dist/node.d.ts +87 -0
  110. package/dist/node.d.ts.map +1 -0
  111. package/dist/node.mjs +226 -0
  112. package/dist/node.mjs.map +1 -0
  113. package/dist/provision.cjs +92 -0
  114. package/dist/provision.cjs.map +1 -0
  115. package/dist/provision.d.ts +78 -0
  116. package/dist/provision.d.ts.map +1 -0
  117. package/dist/provision.mjs +14897 -0
  118. package/dist/provision.mjs.map +1 -0
  119. package/dist/repo_client.d.ts +102 -0
  120. package/dist/repo_client.d.ts.map +1 -0
  121. package/dist/runtime.d.ts +144 -0
  122. package/dist/runtime.d.ts.map +1 -0
  123. package/dist/sdk_core.d.ts +170 -0
  124. package/dist/sdk_core.d.ts.map +1 -0
  125. package/dist/sn_client.d.ts +415 -0
  126. package/dist/sn_client.d.ts.map +1 -0
  127. package/dist/system_config_client.d.ts +39 -0
  128. package/dist/system_config_client.d.ts.map +1 -0
  129. package/dist/task_mgr_client.d.ts +590 -0
  130. package/dist/task_mgr_client.d.ts.map +1 -0
  131. package/dist/tus_client-32d016c4.js +6 -0
  132. package/dist/tus_client-32d016c4.js.map +1 -0
  133. package/dist/tus_client-f1532e14.mjs +3179 -0
  134. package/dist/tus_client-f1532e14.mjs.map +1 -0
  135. package/dist/types.d.ts +184 -0
  136. package/dist/types.d.ts.map +1 -0
  137. package/dist/verify-hub-client.d.ts +74 -0
  138. package/dist/verify-hub-client.d.ts.map +1 -0
  139. package/dist/workflow_client.d.ts +431 -0
  140. package/dist/workflow_client.d.ts.map +1 -0
  141. package/package.json +126 -51
  142. package/_docs/1.Hello,Bucky!/1.1./350/256/251Demo/350/267/221/350/265/267/346/235/245.html +0 -671
  143. package/_docs/1.Hello,Bucky!/1.2./344/273/243/347/240/201/345/210/206/346/236/220.html +0 -781
  144. package/_docs/1.Hello,Bucky!/1.3./350/201/212/345/244/251/345/256/244demo.html +0 -1010
  145. package/_docs/1.Hello,Bucky!/1.4./350/207/252/345/267/261/345/212/250/346/211/213/346/267/273/345/212/240/344/272/233/346/226/260/345/212/237/350/203/275.html +0 -674
  146. package/_docs/1.Hello,Bucky!/1.5./351/227/256/351/242/230/350/257/212/346/226/255/344/270/216/350/260/203/350/257/225.html +0 -580
  147. package/_docs/2./346/236/204/346/236/266/2.1./346/225/264/344/275/223/346/236/266/346/236/204/344/273/213/347/273/215.html +0 -921
  148. package/_docs/2./346/236/204/346/236/266/2.2./345/267/245/347/250/213/347/233/256/345/275/225/347/273/223/346/236/204.html +0 -681
  149. package/_docs/3./345/274/200/345/217/221/346/211/213/345/206/214/3.1.Step-by-step/345/210/233/345/273/272/346/226/260/351/241/271/347/233/256.html +0 -595
  150. package/_docs/3./345/274/200/345/217/221/346/211/213/345/206/214/3.2.bucky/345/221/275/344/273/244/350/241/214/346/211/213/345/206/214.html +0 -711
  151. package/_docs/3./345/274/200/345/217/221/346/211/213/345/206/214/3.3./344/275/277/347/224/250h5debug.html +0 -562
  152. package/_docs/3./345/274/200/345/217/221/346/211/213/345/206/214/3.4.API/345/217/202/350/200/203/346/211/213/345/206/214.html +0 -920
  153. package/_docs/3./345/274/200/345/217/221/346/211/213/345/206/214/3.5./351/224/231/350/257/257/347/240/201.html +0 -592
  154. package/_docs/3./345/274/200/345/217/221/346/211/213/345/206/214/3.6./345/270/270/350/247/201/351/227/256/351/242/230.html +0 -543
  155. package/_docs/3./345/274/200/345/217/221/346/211/213/345/206/214/images/h5-ld-break.jpg +0 -0
  156. package/_docs/3./345/274/200/345/217/221/346/211/213/345/206/214/images/h5-ld-core.jpg +0 -0
  157. package/_docs/3./345/274/200/345/217/221/346/211/213/345/206/214/images/h5-ld-debug.jpg +0 -0
  158. package/_docs/3./345/274/200/345/217/221/346/211/213/345/206/214/images/h5-ld-dev.jpg +0 -0
  159. package/_docs/3./345/274/200/345/217/221/346/211/213/345/206/214/images/h5-ld-empty.jpg +0 -0
  160. package/_docs/4./344/276/213/345/255/220/4.1./344/275/277/347/224/250MySQL.html +0 -611
  161. package/_docs/4./344/276/213/345/255/220/4.2./344/275/277/347/224/250OSS/350/257/273/345/206/231/346/226/207/344/273/266.html +0 -604
  162. package/_docs/4./344/276/213/345/255/220/4.3./345/210/233/345/273/272ReactNative/351/241/271/347/233/256.html +0 -644
  163. package/_docs/4./344/276/213/345/255/220/4.4./345/210/233/345/273/272/345/276/256/344/277/241/345/260/217/347/250/213/345/272/217/351/241/271/347/233/256.html +0 -642
  164. package/_docs/4./344/276/213/345/255/220/images/mysql-config-json.jpg +0 -0
  165. package/_docs/4./344/276/213/345/255/220/images/mysql-depend.jpg +0 -0
  166. package/_docs/4./344/276/213/345/255/220/images/mysql-init.jpg +0 -0
  167. package/_docs/4./344/276/213/345/255/220/images/mysql-knowledge.jpg +0 -0
  168. package/_docs/5./347/237/245/350/257/206/345/272/223/5.1./347/220/206/350/247/243async.html +0 -541
  169. package/_docs/5./347/237/245/350/257/206/345/272/223/5.2./346/250/241/345/235/227/346/216/245/345/217/243.html +0 -683
  170. package/_docs/5./347/237/245/350/257/206/345/272/223/5.3./346/250/241/345/235/227/345/212/240/350/275/275.html +0 -612
  171. package/_docs/5./347/237/245/350/257/206/345/272/223/5.4./345/205/254/345/205/261/347/261/273/345/272/223.html +0 -597
  172. package/_docs/5./347/237/245/350/257/206/345/272/223/5.5./347/263/273/347/273/237/344/272/213/344/273/266.html +0 -628
  173. package/_docs/5./347/237/245/350/257/206/345/272/223/5.6./345/205/250/345/261/200/344/272/213/344/273/266.html +0 -569
  174. package/_docs/index.html +0 -538
  175. package/bucky/base.js +0 -6776
  176. package/bucky/core.js +0 -12142
  177. package/bucky/h5_core.js +0 -9947
  178. package/bucky/h5_ld_core.js +0 -9938
  179. package/bucky/h5_ui.js +0 -35161
  180. package/bucky/node_core.js +0 -11254
  181. package/bucky/node_ld_core.js +0 -10816
  182. package/bucky/rn_core.js +0 -9864
  183. package/bucky/rn_ld_core.js +0 -9850
  184. package/bucky/wx_core.js +0 -9902
  185. package/bucky/wx_ld_core.js +0 -9368
  186. package/demos/HelloBucky/knowledges.json +0 -40
  187. package/demos/HelloBucky/solution.json +0 -69
  188. package/demos/ReactNative/knowledges.json +0 -34
  189. package/demos/ReactNative/solution.json +0 -89
  190. package/demos/fileserver/knowledges.json +0 -38
  191. package/demos/fileserver/solution.json +0 -70
  192. package/demos/minichat/knowledges.json +0 -44
  193. package/demos/minichat/solution.json +0 -94
  194. package/demos/mysql/knowledges.json +0 -68
  195. package/demos/mysql/main.js +0 -56
  196. package/demos/mysql/solution.json +0 -69
  197. package/demos/mysqlAdvance/knowledges.json +0 -42
  198. package/demos/mysqlAdvance/solution.json +0 -72
  199. package/demos/wechat/knowledges.json +0 -38
  200. package/demos/wechat/solution.json +0 -100
  201. package/demos/wegame/knowledges.json +0 -38
  202. package/demos/wegame/solution.json +0 -100
  203. package/docs/1.Hello,Bucky!/1.1./350/256/251Demo/350/267/221/350/265/267/346/235/245.md +0 -187
  204. package/docs/1.Hello,Bucky!/1.2./344/273/243/347/240/201/345/210/206/346/236/220.md +0 -265
  205. package/docs/1.Hello,Bucky!/1.3./350/201/212/345/244/251/345/256/244demo.md +0 -569
  206. package/docs/1.Hello,Bucky!/1.4./350/207/252/345/267/261/345/212/250/346/211/213/346/267/273/345/212/240/344/272/233/346/226/260/345/212/237/350/203/275.md +0 -196
  207. package/docs/1.Hello,Bucky!/1.5./351/227/256/351/242/230/350/257/212/346/226/255/344/270/216/350/260/203/350/257/225.md +0 -67
  208. package/docs/2./346/236/204/346/236/266/2.1./346/225/264/344/275/223/346/236/266/346/236/204/344/273/213/347/273/215.md +0 -453
  209. package/docs/2./346/236/204/346/236/266/2.2./345/267/245/347/250/213/347/233/256/345/275/225/347/273/223/346/236/204.md +0 -134
  210. package/docs/3./345/274/200/345/217/221/346/211/213/345/206/214/3.1.Step-by-step/345/210/233/345/273/272/346/226/260/351/241/271/347/233/256.md +0 -43
  211. package/docs/3./345/274/200/345/217/221/346/211/213/345/206/214/3.2.bucky/345/221/275/344/273/244/350/241/214/346/211/213/345/206/214.md +0 -237
  212. package/docs/3./345/274/200/345/217/221/346/211/213/345/206/214/3.3./344/275/277/347/224/250h5debug.md +0 -63
  213. package/docs/3./345/274/200/345/217/221/346/211/213/345/206/214/3.4.API/345/217/202/350/200/203/346/211/213/345/206/214.md +0 -494
  214. package/docs/3./345/274/200/345/217/221/346/211/213/345/206/214/3.5./351/224/231/350/257/257/347/240/201.md +0 -70
  215. package/docs/3./345/274/200/345/217/221/346/211/213/345/206/214/3.6./345/270/270/350/247/201/351/227/256/351/242/230.md +0 -25
  216. package/docs/3./345/274/200/345/217/221/346/211/213/345/206/214/images/h5-ld-break.jpg +0 -0
  217. package/docs/3./345/274/200/345/217/221/346/211/213/345/206/214/images/h5-ld-core.jpg +0 -0
  218. package/docs/3./345/274/200/345/217/221/346/211/213/345/206/214/images/h5-ld-debug.jpg +0 -0
  219. package/docs/3./345/274/200/345/217/221/346/211/213/345/206/214/images/h5-ld-dev.jpg +0 -0
  220. package/docs/3./345/274/200/345/217/221/346/211/213/345/206/214/images/h5-ld-empty.jpg +0 -0
  221. package/docs/4./344/276/213/345/255/220/4.1./344/275/277/347/224/250MySQL.md +0 -102
  222. package/docs/4./344/276/213/345/255/220/4.2./344/275/277/347/224/250OSS/350/257/273/345/206/231/346/226/207/344/273/266.md +0 -111
  223. package/docs/4./344/276/213/345/255/220/4.3./345/210/233/345/273/272ReactNative/351/241/271/347/233/256.md +0 -167
  224. package/docs/4./344/276/213/345/255/220/4.4./345/210/233/345/273/272/345/276/256/344/277/241/345/260/217/347/250/213/345/272/217/351/241/271/347/233/256.md +0 -144
  225. package/docs/4./344/276/213/345/255/220/images/mysql-config-json.jpg +0 -0
  226. package/docs/4./344/276/213/345/255/220/images/mysql-depend.jpg +0 -0
  227. package/docs/4./344/276/213/345/255/220/images/mysql-init.jpg +0 -0
  228. package/docs/4./344/276/213/345/255/220/images/mysql-knowledge.jpg +0 -0
  229. package/docs/5./347/237/245/350/257/206/345/272/223/5.1./347/220/206/350/247/243async.md +0 -17
  230. package/docs/5./347/237/245/350/257/206/345/272/223/5.2./346/250/241/345/235/227/346/216/245/345/217/243.md +0 -183
  231. package/docs/5./347/237/245/350/257/206/345/272/223/5.3./346/250/241/345/235/227/345/212/240/350/275/275.md +0 -105
  232. package/docs/5./347/237/245/350/257/206/345/272/223/5.4./345/205/254/345/205/261/347/261/273/345/272/223.md +0 -86
  233. package/docs/5./347/237/245/350/257/206/345/272/223/5.5./347/263/273/347/273/237/344/272/213/344/273/266.md +0 -113
  234. package/docs/5./347/237/245/350/257/206/345/272/223/5.6./345/205/250/345/261/200/344/272/213/344/273/266.md +0 -49
  235. package/docs/index.md +0 -12
  236. package/drivers/mongo/mongo_local.js +0 -201
  237. package/drivers/mysql/mysql_local.js +0 -408
  238. package/drivers/oss/oss_local.js +0 -244
  239. package/templates/packages/nodepackage/config.json +0 -20
  240. package/templates/packages/nodepackage/config.lib.json +0 -6
  241. package/templates/packages/nodepackage/module_empty.js +0 -5
  242. package/templates/packages/nodepackage/module_example.js +0 -87
  243. package/templates/packages/nodepackage/onload.js +0 -0
  244. package/templates/packages/nodepackage_test/module_example_test.js +0 -39
  245. package/templates/projects/bucky/.gitkeep +0 -0
  246. package/templates/projects/h5/.gitkeep +0 -0
  247. package/templates/projects/h5/css/main.css +0 -23
  248. package/templates/projects/h5/img/bkg.jpg +0 -0
  249. package/templates/projects/h5/index.html +0 -37
  250. package/templates/projects/h5/main.js +0 -15
  251. package/templates/projects/node/.gitkeep +0 -0
  252. package/templates/projects/node/main.js +0 -58
  253. package/templates/projects/wx/app.js +0 -30
  254. package/templates/projects/wx/app.json +0 -12
  255. package/templates/projects/wx/app.wxss +0 -10
  256. package/templates/projects/wx/core/bucky_meta.js +0 -11
  257. package/templates/projects/wx/core/bucky_packages.js +0 -4
  258. package/templates/projects/wx/core/lib/runtime.js +0 -736
  259. package/templates/projects/wx/core/packages/.gitkeep +0 -0
  260. package/templates/projects/wx/pages/index/index.js +0 -65
  261. package/templates/projects/wx/pages/index/index.wxml +0 -10
  262. package/templates/projects/wx/pages/index/index.wxss +0 -21
  263. package/templates/projects/wx/pages/logs/logs.js +0 -14
  264. package/templates/projects/wx/pages/logs/logs.json +0 -3
  265. package/templates/projects/wx/pages/logs/logs.wxml +0 -6
  266. package/templates/projects/wx/pages/logs/logs.wxss +0 -8
  267. package/templates/projects/wx/utils/util.js +0 -21
  268. package/templates/projects/wx_game/README.md +0 -34
  269. package/templates/projects/wx_game/audio/bgm.mp3 +0 -0
  270. package/templates/projects/wx_game/audio/boom.mp3 +0 -0
  271. package/templates/projects/wx_game/audio/bullet.mp3 +0 -0
  272. package/templates/projects/wx_game/core/bucky_meta.js +0 -10
  273. package/templates/projects/wx_game/core/bucky_packages.js +0 -47
  274. package/templates/projects/wx_game/core/lib/runtime.js +0 -736
  275. package/templates/projects/wx_game/core/wx_core.js +0 -9134
  276. package/templates/projects/wx_game/game.js +0 -6
  277. package/templates/projects/wx_game/game.json +0 -3
  278. package/templates/projects/wx_game/images/Common.png +0 -0
  279. package/templates/projects/wx_game/images/bg.jpg +0 -0
  280. package/templates/projects/wx_game/images/bullet.png +0 -0
  281. package/templates/projects/wx_game/images/enemy.png +0 -0
  282. package/templates/projects/wx_game/images/explosion1.png +0 -0
  283. package/templates/projects/wx_game/images/explosion10.png +0 -0
  284. package/templates/projects/wx_game/images/explosion11.png +0 -0
  285. package/templates/projects/wx_game/images/explosion12.png +0 -0
  286. package/templates/projects/wx_game/images/explosion13.png +0 -0
  287. package/templates/projects/wx_game/images/explosion14.png +0 -0
  288. package/templates/projects/wx_game/images/explosion15.png +0 -0
  289. package/templates/projects/wx_game/images/explosion16.png +0 -0
  290. package/templates/projects/wx_game/images/explosion17.png +0 -0
  291. package/templates/projects/wx_game/images/explosion18.png +0 -0
  292. package/templates/projects/wx_game/images/explosion19.png +0 -0
  293. package/templates/projects/wx_game/images/explosion2.png +0 -0
  294. package/templates/projects/wx_game/images/explosion3.png +0 -0
  295. package/templates/projects/wx_game/images/explosion4.png +0 -0
  296. package/templates/projects/wx_game/images/explosion5.png +0 -0
  297. package/templates/projects/wx_game/images/explosion6.png +0 -0
  298. package/templates/projects/wx_game/images/explosion7.png +0 -0
  299. package/templates/projects/wx_game/images/explosion8.png +0 -0
  300. package/templates/projects/wx_game/images/explosion9.png +0 -0
  301. package/templates/projects/wx_game/images/hero.png +0 -0
  302. package/templates/projects/wx_game/js/base/animation.js +0 -112
  303. package/templates/projects/wx_game/js/base/pool.js +0 -45
  304. package/templates/projects/wx_game/js/base/sprite.js +0 -51
  305. package/templates/projects/wx_game/js/databus.js +0 -58
  306. package/templates/projects/wx_game/js/libs/symbol.js +0 -17
  307. package/templates/projects/wx_game/js/libs/weapp-adapter.js +0 -1529
  308. package/templates/projects/wx_game/js/main.js +0 -261
  309. package/templates/projects/wx_game/js/npc/enemy.js +0 -56
  310. package/templates/projects/wx_game/js/player/bullet.js +0 -36
  311. package/templates/projects/wx_game/js/player/index.js +0 -126
  312. package/templates/projects/wx_game/js/runtime/background.js +0 -61
  313. package/templates/projects/wx_game/js/runtime/gameinfo.js +0 -63
  314. package/templates/projects/wx_game/js/runtime/music.js +0 -39
  315. package/templates/projects/wx_game/project.config.json +0 -33
  316. package/tools/bucky.js +0 -9778
  317. package/tools/h5-local-debug-server/README.md +0 -14
  318. package/tools/h5-local-debug-server/config.js +0 -37
  319. package/tools/h5-local-debug-server/error.js +0 -150
  320. package/tools/h5-local-debug-server/index.js +0 -137
  321. package/tools/h5-local-debug-server/knowledge.js +0 -36
  322. package/tools/h5-local-debug-server/mongo/mongo_control.js +0 -26
  323. package/tools/h5-local-debug-server/mongo/mongo_instance.js +0 -93
  324. package/tools/h5-local-debug-server/mongo/mongo_model.js +0 -154
  325. package/tools/h5-local-debug-server/mysql/mysql_control.js +0 -45
  326. package/tools/h5-local-debug-server/mysql/mysql_instance.js +0 -53
  327. package/tools/h5-local-debug-server/mysql/mysql_model.js +0 -241
  328. package/tools/h5-local-debug-server/object_map.js +0 -25
  329. package/tools/h5-local-debug-server/oss/oss_control.js +0 -20
  330. package/tools/h5-local-debug-server/oss/oss_instance.js +0 -122
  331. package/tools/h5-local-debug-server/oss/oss_model.js +0 -104
  332. package/tools/h5-local-debug-server/package.json +0 -23
  333. package/tools/h5-local-debug-server/package_compile.js +0 -227
  334. package/tools/h5-local-debug-server/repository.js +0 -153
  335. package/tools/mysql/client.js +0 -146
  336. package/tools/mysql/mysql/config.json +0 -49
  337. package/tools/mysql/mysql/mysql.js +0 -65
  338. package/tools/mysql/mysql/onload.js +0 -1
  339. package/tools/mysql/mysql_proxy/config.json +0 -46
  340. package/tools/mysql/mysql_proxy/mysql.js +0 -108
  341. package/tools/mysql/mysql_proxy/onload.js +0 -1
  342. package/tools/node_loader.js +0 -151
@@ -0,0 +1,564 @@
1
+ import type { GlobalOptions } from './argv.ts'
2
+ import { parseCommandArgs, parseDuration, parseInvocation, validateSchema } from './argv.ts'
3
+ import { AuthenticationSession, type SessionController } from './auth.ts'
4
+ import type { RegisteredCommand } from './command.ts'
5
+ import {
6
+ type ConfigStore,
7
+ type Environment,
8
+ type ImplicitDeviceIdentity,
9
+ localResolvedConfig,
10
+ readEnvironment,
11
+ resolveConfig,
12
+ type ResolvedConfig,
13
+ } from './config.ts'
14
+ import type { CommandContext } from './context.ts'
15
+ import { EXIT_PERMISSION, EXIT_SUCCESS, normalizeError, ToolError, UsageError } from './errors.ts'
16
+ import { applyImplicitDeviceIdentity, identityCandidateView } from './identity.ts'
17
+ import { errorEnvelope, renderError, renderSuccess, successEnvelope } from './output.ts'
18
+ import { CommandRegistry } from './registry.ts'
19
+ import { runRepl } from './repl.ts'
20
+ import {
21
+ BuckyOSRuntimeAdapter,
22
+ BuckyOSServiceClientRegistry,
23
+ InteractiveSession,
24
+ type RuntimeAdapter,
25
+ type ServiceClientRegistry,
26
+ } from './runtime.ts'
27
+ import { createAuthModule } from '../modules/auth.ts'
28
+ import { createCoreModules } from '../modules/core.ts'
29
+ import { createSystemModule } from '../modules/system.ts'
30
+ import { createSystemConfigModule } from '../modules/system_config.ts'
31
+ import { createPikgModule, type PikgModuleDependencies } from '../modules/pikg.ts'
32
+ import { type AppModuleDependencies, createAppModule } from '../modules/app.ts'
33
+ import { createDiagnosticModule, type DiagnosticModuleDependencies } from '../modules/diagnostic.ts'
34
+ import { createLogModule, type LogModuleDependencies } from '../modules/log.ts'
35
+ import { createTaskModule } from '../modules/task.ts'
36
+ import {
37
+ distributionManifestView,
38
+ getHost,
39
+ policyView,
40
+ readDistributionManifest,
41
+ } from '../runtime/host.ts'
42
+ import { PROTOCOL_VERSION, SDK_VERSION, TOOL_VERSION } from '../version.ts'
43
+
44
+ export const VERSION = TOOL_VERSION
45
+
46
+ export interface ToolStdio {
47
+ stdout(value: string): Promise<void>
48
+ stderr(value: string): Promise<void>
49
+ readStdin(): Promise<string>
50
+ prompt?(message: string): Promise<string | null>
51
+ inputIsTerminal?(): boolean
52
+ }
53
+
54
+ export interface ApplicationDependencies {
55
+ environment?: Environment
56
+ cwd?: string
57
+ homeDir?: string
58
+ stdio?: ToolStdio
59
+ createAuthentication?: (config: ResolvedConfig) => SessionController
60
+ runtime?: RuntimeAdapter
61
+ createClients?: (
62
+ config: ResolvedConfig,
63
+ authentication: SessionController,
64
+ ) => ServiceClientRegistry
65
+ confirmDeviceIdentity?: (identity: ImplicitDeviceIdentity) => Promise<boolean>
66
+ repl?: typeof runRepl
67
+ pikg?: PikgModuleDependencies
68
+ app?: AppModuleDependencies
69
+ log?: LogModuleDependencies
70
+ diagnostic?: DiagnosticModuleDependencies
71
+ }
72
+
73
+ export class BuckyOSToolApplication {
74
+ readonly registry: CommandRegistry
75
+ readonly #environment: Environment
76
+ readonly #cwd: string
77
+ readonly #homeDir?: string
78
+ readonly #stdio: ToolStdio
79
+ readonly #createAuthentication: (config: ResolvedConfig) => SessionController
80
+ readonly #runtime: RuntimeAdapter
81
+ readonly #createClients: (
82
+ config: ResolvedConfig,
83
+ authentication: SessionController,
84
+ ) => ServiceClientRegistry
85
+ readonly #confirmDeviceIdentity: (identity: ImplicitDeviceIdentity) => Promise<boolean>
86
+ readonly #repl: typeof runRepl
87
+
88
+ constructor(dependencies: ApplicationDependencies = {}) {
89
+ this.registry = createRegistry(
90
+ dependencies.pikg,
91
+ dependencies.app,
92
+ dependencies.log,
93
+ dependencies.diagnostic,
94
+ )
95
+ this.#environment = dependencies.environment ?? readEnvironment()
96
+ this.#cwd = dependencies.cwd ?? getHost().cwd()
97
+ this.#homeDir = dependencies.homeDir
98
+ this.#stdio = dependencies.stdio ?? defaultStdio()
99
+ this.#createAuthentication = dependencies.createAuthentication ??
100
+ ((config) => new AuthenticationSession(config, this.#environment))
101
+ this.#runtime = dependencies.runtime ?? new BuckyOSRuntimeAdapter()
102
+ this.#createClients = dependencies.createClients ??
103
+ ((config, authentication) => new BuckyOSServiceClientRegistry(config, authentication))
104
+ this.#confirmDeviceIdentity = dependencies.confirmDeviceIdentity ?? confirmDeviceIdentity
105
+ this.#repl = dependencies.repl ?? runRepl
106
+ }
107
+
108
+ async run(argv: string[]): Promise<number> {
109
+ let fallbackTraceId: string = crypto.randomUUID()
110
+ try {
111
+ const invocation = parseInvocation(argv)
112
+ fallbackTraceId = invocation.global.traceId ?? fallbackTraceId
113
+ if (invocation.global.version) {
114
+ if (invocation.module) {
115
+ throw new UsageError('ARGUMENT_CONFLICT', '--version cannot be combined with a command')
116
+ }
117
+ if (invocation.global.verbose) {
118
+ const distributionManifest = await readDistributionManifest()
119
+ let identityCandidates: Record<string, unknown>
120
+ try {
121
+ const setup = await resolveConfig(invocation.global, this.#environment, {
122
+ cwd: this.#cwd,
123
+ homeDir: this.#homeDir,
124
+ })
125
+ setup.resolved = await applyImplicitDeviceIdentity(
126
+ setup.resolved,
127
+ this.#environment,
128
+ )
129
+ identityCandidates = await identityCandidateView(
130
+ setup.resolved,
131
+ this.#environment,
132
+ )
133
+ } catch (error) {
134
+ const normalized = normalizeError(error)
135
+ identityCandidates = { mode: 'unavailable', error: normalized.code }
136
+ }
137
+ await this.#stdio.stdout(`${
138
+ JSON.stringify(
139
+ {
140
+ buckyos: distributionManifest?.buckyos_version ?? null,
141
+ buckyos_build_id: distributionManifest?.build_id ?? null,
142
+ tool_version: TOOL_VERSION,
143
+ sdk_version: SDK_VERSION,
144
+ protocol_version: PROTOCOL_VERSION,
145
+ target_zone: invocation.global.zone ?? getHost().env('BUCKYOS_TOOL_ZONE') ?? null,
146
+ compatibility: 'not-checked',
147
+ ...policyView(getHost()),
148
+ identity_candidates: identityCandidates,
149
+ distribution_manifest: distributionManifestView(distributionManifest),
150
+ },
151
+ null,
152
+ 2,
153
+ )
154
+ }\n`)
155
+ } else {
156
+ await this.#stdio.stdout(`buckyos ${VERSION}\n`)
157
+ }
158
+ return EXIT_SUCCESS
159
+ }
160
+ if (invocation.global.cli) {
161
+ return await this.#runInteractive(invocation.global, invocation.module, invocation.verb)
162
+ }
163
+ if (!invocation.module) {
164
+ if (invocation.global.help) {
165
+ await this.#stdio.stdout(`${topLevelHelp(this.registry)}\n`)
166
+ return EXIT_SUCCESS
167
+ }
168
+ throw new UsageError('COMMAND_REQUIRED', 'a module and verb are required')
169
+ }
170
+ if (!invocation.verb || invocation.verb === '--help' || invocation.verb === '-h') {
171
+ await this.#stdio.stdout(`${moduleHelp(this.registry, invocation.module)}\n`)
172
+ return EXIT_SUCCESS
173
+ }
174
+
175
+ const command = this.registry.get(invocation.module, invocation.verb)
176
+ if (
177
+ invocation.global.help || invocation.actionArgv.includes('--help') ||
178
+ invocation.actionArgv.includes('-h')
179
+ ) {
180
+ await this.#stdio.stdout(`${commandHelp(this.registry, command)}\n`)
181
+ return EXIT_SUCCESS
182
+ }
183
+ const setup = await this.#resolveForCommand(command, invocation.global)
184
+ const inputObject = invocation.global.input
185
+ ? await this.#readInputObject(invocation.global.input)
186
+ : undefined
187
+ const parsed = parseCommandArgs(command, invocation.actionArgv, inputObject)
188
+ if (setup.resolved.output === 'raw' && !command.supportsRawOutput) {
189
+ throw new UsageError(
190
+ 'RAW_OUTPUT_UNSUPPORTED',
191
+ `${command.module} ${command.verb} does not support raw output`,
192
+ )
193
+ }
194
+ const session = command.requiresSession
195
+ ? await this.#createSession(setup.resolved)
196
+ : undefined
197
+ return await this.#executeAndEmit(
198
+ command,
199
+ parsed.input,
200
+ setup.resolved,
201
+ setup.store,
202
+ session,
203
+ false,
204
+ new AbortController().signal,
205
+ )
206
+ } catch (error) {
207
+ const normalized = normalizeError(error)
208
+ const envelope = errorEnvelope(normalized, { command: 'core', trace_id: fallbackTraceId })
209
+ await this.#stdio.stdout(`${renderError(envelope, 'json')}\n`)
210
+ return normalized.exitCode
211
+ }
212
+ }
213
+
214
+ async #runInteractive(global: GlobalOptions, module?: string, verb?: string): Promise<number> {
215
+ if (module || verb) {
216
+ throw new UsageError('ARGUMENT_CONFLICT', '--cli cannot be combined with a module or verb')
217
+ }
218
+ if (global.nonInteractive) {
219
+ throw new UsageError('ARGUMENT_CONFLICT', '--cli conflicts with --non-interactive')
220
+ }
221
+ for (
222
+ const [name, value] of [
223
+ ['input', global.input],
224
+ ['timeout', global.timeout],
225
+ ['trace-id', global.traceId],
226
+ ['idempotency-key', global.idempotencyKey],
227
+ ['wait', global.wait],
228
+ ['yes', global.yes],
229
+ ] as const
230
+ ) {
231
+ if (value !== undefined) {
232
+ throw new UsageError(
233
+ 'ARGUMENT_CONFLICT',
234
+ `--${name} is command-scoped and cannot be set when entering --cli`,
235
+ )
236
+ }
237
+ }
238
+ const setup = await resolveConfig(global, this.#environment, {
239
+ interactive: true,
240
+ cwd: this.#cwd,
241
+ homeDir: this.#homeDir,
242
+ })
243
+ setup.resolved = await applyImplicitDeviceIdentity(setup.resolved, this.#environment)
244
+ const session = await this.#createSession(setup.resolved)
245
+ await this.#repl({
246
+ registry: this.registry,
247
+ config: setup.resolved,
248
+ configStore: setup.store,
249
+ session,
250
+ execute: async (tokens, signal) =>
251
+ await this.#executeInteractiveLine(tokens, signal, setup.resolved, setup.store, session),
252
+ })
253
+ return EXIT_SUCCESS
254
+ }
255
+
256
+ async #executeInteractiveLine(
257
+ tokens: string[],
258
+ signal: AbortSignal,
259
+ frozen: ResolvedConfig,
260
+ store: ConfigStore,
261
+ session: InteractiveSession,
262
+ ): Promise<void> {
263
+ if (tokens.length < 2) throw new UsageError('COMMAND_REQUIRED', 'enter <module> <verb>')
264
+ const command = this.registry.get(tokens[0], tokens[1])
265
+ const actionArgv = tokens.slice(2)
266
+ if (actionArgv.includes('--help') || actionArgv.includes('-h')) {
267
+ await this.#stdio.stdout(`${commandHelp(this.registry, command)}\n`)
268
+ return
269
+ }
270
+ const preliminary = parseCommandArgs(command, actionArgv, undefined, true, true)
271
+ if (preliminary.scoped.input === '-') {
272
+ throw new UsageError('STDIN_UNAVAILABLE', '--input - is not available inside --cli')
273
+ }
274
+ const inputObject = preliminary.scoped.input
275
+ ? await this.#readInputObject(preliminary.scoped.input)
276
+ : undefined
277
+ const parsed = parseCommandArgs(command, actionArgv, inputObject, true)
278
+ const config: ResolvedConfig = {
279
+ ...frozen,
280
+ output: parsed.scoped.output ?? frozen.output,
281
+ timeoutMs: parsed.scoped.timeout ? parseDuration(parsed.scoped.timeout) : frozen.timeoutMs,
282
+ traceId: parsed.scoped.traceId,
283
+ idempotencyKey: parsed.scoped.idempotencyKey,
284
+ wait: parsed.scoped.wait ?? false,
285
+ yes: parsed.scoped.yes ?? false,
286
+ }
287
+ if (config.output === 'raw' && !command.supportsRawOutput) {
288
+ throw new UsageError(
289
+ 'RAW_OUTPUT_UNSUPPORTED',
290
+ `${command.module} ${command.verb} does not support raw output`,
291
+ )
292
+ }
293
+ await this.#executeAndEmit(command, parsed.input, config, store, session, true, signal)
294
+ }
295
+
296
+ async #executeAndEmit(
297
+ command: RegisteredCommand,
298
+ input: Record<string, unknown>,
299
+ config: ResolvedConfig,
300
+ store: ConfigStore,
301
+ session: InteractiveSession | undefined,
302
+ interactive: boolean,
303
+ signal: AbortSignal,
304
+ ): Promise<number> {
305
+ const traceId = config.traceId ?? crypto.randomUUID()
306
+ const startedAt = Date.now()
307
+ try {
308
+ if (command.requiresSession && !session) {
309
+ throw new ToolError('AUTH_REQUIRED', 'authenticated session is required', 3)
310
+ }
311
+ if (command.requiresSession) await session!.authentication.ensureValid()
312
+ const principal = session?.authentication.current().principal ?? {
313
+ id: 'local',
314
+ appId: 'buckyos-tool',
315
+ authentication: 'mock' as const,
316
+ }
317
+ const context: CommandContext = {
318
+ command: { module: command.module, verb: command.verb },
319
+ definition: command,
320
+ connection: session?.connection ?? {
321
+ zone: config.zone ?? 'local',
322
+ endpoint: config.endpoint ?? 'local://',
323
+ defaultProtocol: config.defaultProtocol,
324
+ },
325
+ principal,
326
+ clients: session?.clients ?? unavailableClients,
327
+ output: { format: config.output },
328
+ traceId,
329
+ idempotencyKey: config.idempotencyKey,
330
+ deadline: Date.now() + config.timeoutMs,
331
+ signal,
332
+ cwd: this.#cwd,
333
+ io: {
334
+ stdout: (value) => this.#stdio.stdout(value),
335
+ stderr: (value) => this.#stdio.stderr(value),
336
+ prompt: (message) => this.#stdio.prompt?.(message) ?? Promise.resolve(null),
337
+ inputIsTerminal: this.#stdio.inputIsTerminal?.() ?? false,
338
+ },
339
+ interactive,
340
+ confirmed: config.yes,
341
+ config,
342
+ configStore: store,
343
+ session: session?.authentication,
344
+ }
345
+ const data = await command.handler(context, input)
346
+ try {
347
+ validateSchema(data, command.outputSchema, 'output')
348
+ } catch (error) {
349
+ throw new ToolError(
350
+ 'INVALID_HANDLER_OUTPUT',
351
+ error instanceof Error ? error.message : String(error),
352
+ 9,
353
+ )
354
+ }
355
+ const envelope = successEnvelope(data, {
356
+ command: `${command.module}.${command.verb}`,
357
+ trace_id: traceId,
358
+ duration_ms: Date.now() - startedAt,
359
+ })
360
+ await this.#stdio.stdout(
361
+ `${renderSuccess(envelope, config.output)}${config.output === 'raw' ? '' : '\n'}`,
362
+ )
363
+ return EXIT_SUCCESS
364
+ } catch (error) {
365
+ const normalized = normalizeError(error)
366
+ const envelope = errorEnvelope(normalized, {
367
+ command: `${command.module}.${command.verb}`,
368
+ trace_id: traceId,
369
+ duration_ms: Date.now() - startedAt,
370
+ })
371
+ await this.#stdio.stdout(`${renderError(envelope, config.output)}\n`)
372
+ if (config.verbose) await this.#stdio.stderr(`diagnostic: ${normalized.code}\n`)
373
+ return normalized.exitCode
374
+ }
375
+ }
376
+
377
+ async #resolveForCommand(
378
+ command: RegisteredCommand,
379
+ global: GlobalOptions,
380
+ ): Promise<{ resolved: ResolvedConfig; store: ConfigStore }> {
381
+ if (command.requiresSession || (command.module === 'config' && command.verb === 'check')) {
382
+ const setup = await resolveConfig(global, this.#environment, {
383
+ cwd: this.#cwd,
384
+ homeDir: this.#homeDir,
385
+ })
386
+ if (command.requiresSession) {
387
+ setup.resolved = await applyImplicitDeviceIdentity(setup.resolved, this.#environment)
388
+ }
389
+ return setup
390
+ }
391
+ return localResolvedConfig(global, this.#environment, {
392
+ cwd: this.#cwd,
393
+ homeDir: this.#homeDir,
394
+ })
395
+ }
396
+
397
+ async #createSession(config: ResolvedConfig): Promise<InteractiveSession> {
398
+ await this.#approveImplicitDeviceIdentity(config)
399
+ const authentication = this.#createAuthentication(config)
400
+ return await InteractiveSession.create(
401
+ config,
402
+ authentication,
403
+ this.#runtime,
404
+ this.#createClients(config, authentication),
405
+ )
406
+ }
407
+
408
+ async #approveImplicitDeviceIdentity(config: ResolvedConfig): Promise<void> {
409
+ const identity = config.implicitDeviceIdentity
410
+ if (!identity || config.yes) return
411
+ if (config.nonInteractive) {
412
+ throw new ToolError(
413
+ 'CONFIRMATION_REQUIRED',
414
+ 'using the current device identity requires --yes in non-interactive mode',
415
+ EXIT_PERMISSION,
416
+ false,
417
+ { identity: identity.did },
418
+ )
419
+ }
420
+ if (!await this.#confirmDeviceIdentity(identity)) {
421
+ throw new ToolError(
422
+ 'CONFIRMATION_DECLINED',
423
+ 'current device identity confirmation was declined',
424
+ EXIT_PERMISSION,
425
+ false,
426
+ { identity: identity.did },
427
+ )
428
+ }
429
+ }
430
+
431
+ async #readInputObject(path: string): Promise<Record<string, unknown>> {
432
+ let raw: string
433
+ try {
434
+ raw = path === '-' ? await this.#stdio.readStdin() : await getHost().readTextFile(path)
435
+ } catch (error) {
436
+ throw new UsageError(
437
+ 'INPUT_READ_FAILED',
438
+ `failed to read input: ${error instanceof Error ? error.message : String(error)}`,
439
+ )
440
+ }
441
+ let parsed: unknown
442
+ try {
443
+ parsed = JSON.parse(raw)
444
+ } catch {
445
+ throw new UsageError('INVALID_INPUT_JSON', 'input is not valid JSON')
446
+ }
447
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
448
+ throw new UsageError('INVALID_INPUT_JSON', 'input JSON must be an object')
449
+ }
450
+ return parsed as Record<string, unknown>
451
+ }
452
+ }
453
+
454
+ export function createRegistry(
455
+ pikgDependencies?: PikgModuleDependencies,
456
+ appDependencies?: AppModuleDependencies,
457
+ logDependencies?: LogModuleDependencies,
458
+ diagnosticDependencies?: DiagnosticModuleDependencies,
459
+ ): CommandRegistry {
460
+ const registry = new CommandRegistry()
461
+ for (const module of createCoreModules(registry)) registry.register(module)
462
+ registry.register(createAuthModule())
463
+ registry.register(createPikgModule(pikgDependencies))
464
+ registry.register(createSystemModule())
465
+ registry.register(createSystemConfigModule())
466
+ registry.register(createAppModule(appDependencies))
467
+ registry.register(createTaskModule())
468
+ registry.register(createLogModule(logDependencies))
469
+ registry.register(createDiagnosticModule(diagnosticDependencies))
470
+ return registry
471
+ }
472
+
473
+ const unavailableClients: ServiceClientRegistry = {
474
+ call: () => Promise.reject(new ToolError('INTERNAL_ERROR', 'service clients are unavailable', 9)),
475
+ }
476
+
477
+ function topLevelHelp(registry: CommandRegistry): string {
478
+ return [
479
+ `BuckyOS Tool ${VERSION}`,
480
+ '',
481
+ 'Usage:',
482
+ ' buckyos [global-options] <module> <verb> [primary-selector] [action-options]',
483
+ ' buckyos [session-options] --cli',
484
+ '',
485
+ 'Modules:',
486
+ ...registry.modules().map((module) => ` ${module.name.padEnd(12)} ${module.summary}`),
487
+ '',
488
+ 'Global options:',
489
+ ' --config-dir <path> --profile <name> --zone <host-or-did>',
490
+ ' --endpoint <url> --identity <did-or-name>',
491
+ ' --session-token <token> | --session-token-file <path>',
492
+ ' Prefer --session-token-file for automation; argv tokens may appear in process listings.',
493
+ ' --output <json|jsonl|table|text|raw> --input <path|->',
494
+ ' --timeout <duration> --trace-id <id> --non-interactive --yes',
495
+ ' --cli --help --version',
496
+ '',
497
+ 'Use `buckyos command describe <module> <verb>` for machine-readable schemas.',
498
+ ].join('\n')
499
+ }
500
+
501
+ function moduleHelp(registry: CommandRegistry, moduleName: string): string {
502
+ const module = registry.modules().find((candidate) => candidate.name === moduleName)
503
+ if (!module) throw new UsageError('UNKNOWN_MODULE', `unknown module: ${moduleName}`)
504
+ return [
505
+ `${module.name}: ${module.summary}`,
506
+ '',
507
+ 'Commands:',
508
+ ...module.commands.map((command) => ` ${command.verb.padEnd(18)} ${command.summary}`),
509
+ ].join('\n')
510
+ }
511
+
512
+ function commandHelp(registry: CommandRegistry, command: RegisteredCommand): string {
513
+ return [
514
+ command.summary,
515
+ '',
516
+ `Usage: ${registry.syntax(command)}`,
517
+ ...(command.description ? ['', command.description] : []),
518
+ ...((command.positionals?.length ?? 0) > 0
519
+ ? [
520
+ '',
521
+ 'Arguments:',
522
+ ...command.positionals!.map((position) =>
523
+ ` ${position.name.padEnd(20)} ${position.description}`
524
+ ),
525
+ ]
526
+ : []),
527
+ ...((command.options?.length ?? 0) > 0
528
+ ? [
529
+ '',
530
+ 'Options:',
531
+ ...command.options!.map((option) => ` --${option.name.padEnd(18)} ${option.description}`),
532
+ ]
533
+ : []),
534
+ ...((command.examples?.length ?? 0) > 0
535
+ ? ['', 'Examples:', ...command.examples!.map((example) => ` ${example}`)]
536
+ : []),
537
+ ].join('\n')
538
+ }
539
+
540
+ function defaultStdio(): ToolStdio {
541
+ return {
542
+ stdout: async (value) => await getHost().stdout(value),
543
+ stderr: async (value) => await getHost().stderr(value),
544
+ readStdin: async () => await getHost().readStdin(),
545
+ prompt: async (message) => await getHost().readLine(message),
546
+ inputIsTerminal: () => getHost().inputIsTerminal(),
547
+ }
548
+ }
549
+
550
+ async function confirmDeviceIdentity(identity: ImplicitDeviceIdentity): Promise<boolean> {
551
+ if (!getHost().inputIsTerminal()) {
552
+ throw new ToolError(
553
+ 'CONFIRMATION_REQUIRED',
554
+ 'using the current device identity requires an interactive terminal or --yes',
555
+ EXIT_PERMISSION,
556
+ false,
557
+ { identity: identity.did },
558
+ )
559
+ }
560
+ const prompt = `Use current device identity ${identity.name} (${identity.did})? ` +
561
+ 'This identity may have broad privileges. Continue? [y/N] '
562
+ const answer = (await getHost().readLine(prompt))?.trim() ?? ''
563
+ return answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes'
564
+ }