buckyos 0.7.169 → 0.7.175

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 (233) hide show
  1. package/cli/core/app.ts +2 -0
  2. package/cli/core/argv.ts +45 -239
  3. package/cli/core/command.ts +3 -35
  4. package/cli/dist/cli.mjs +2151 -673
  5. package/cli/dist/cli.mjs.map +1 -1
  6. package/cli/modules/agent.ts +3 -1
  7. package/cli/modules/app.ts +13 -2
  8. package/cli/modules/pikg.ts +70 -1
  9. package/cli/modules/runtime.ts +497 -0
  10. package/cli/modules/skill.ts +583 -161
  11. package/cli/modules/skill_lint.ts +462 -0
  12. package/cli/version.ts +1 -1
  13. package/dist/account-7a7bde6f.mjs +105 -0
  14. package/dist/account-7a7bde6f.mjs.map +1 -0
  15. package/dist/account-b12ac6b9.js +2 -0
  16. package/dist/account-b12ac6b9.js.map +1 -0
  17. package/dist/aicc-67851c41.mjs +582 -0
  18. package/dist/aicc-67851c41.mjs.map +1 -0
  19. package/dist/aicc-ccb36ef7.js +2 -0
  20. package/dist/aicc-ccb36ef7.js.map +1 -0
  21. package/dist/app-frame.cjs +1 -1
  22. package/dist/app-frame.cjs.map +1 -1
  23. package/dist/app-frame.mjs +1 -0
  24. package/dist/app-frame.mjs.map +1 -1
  25. package/dist/browser.cjs +1 -1
  26. package/dist/browser.cjs.map +1 -1
  27. package/dist/browser.d.ts +3 -1
  28. package/dist/browser.d.ts.map +1 -1
  29. package/dist/browser.mjs +223 -212
  30. package/dist/browser.mjs.map +1 -1
  31. package/dist/content.cjs +1 -1
  32. package/dist/content.cjs.map +1 -1
  33. package/dist/content.d.ts +2 -1
  34. package/dist/content.d.ts.map +1 -1
  35. package/dist/content.mjs +32 -167
  36. package/dist/content.mjs.map +1 -1
  37. package/dist/content_mime-dc80d960.js +2 -0
  38. package/dist/content_mime-dc80d960.js.map +1 -0
  39. package/dist/content_mime-e42d5f8d.mjs +335 -0
  40. package/dist/content_mime-e42d5f8d.mjs.map +1 -0
  41. package/dist/content_mime.d.ts +18 -0
  42. package/dist/content_mime.d.ts.map +1 -1
  43. package/dist/did_object_client-6a1b108a.js +2 -0
  44. package/dist/did_object_client-6a1b108a.js.map +1 -0
  45. package/dist/did_object_client-7fa36f90.mjs +87 -0
  46. package/dist/did_object_client-7fa36f90.mjs.map +1 -0
  47. package/dist/did_object_client.d.ts +39 -0
  48. package/dist/did_object_client.d.ts.map +1 -0
  49. package/dist/{executor_client-a32bc377.mjs → executor_client-c620d25c.mjs} +1794 -844
  50. package/dist/executor_client-c620d25c.mjs.map +1 -0
  51. package/dist/executor_client-d4439d54.js +13 -0
  52. package/dist/executor_client-d4439d54.js.map +1 -0
  53. package/dist/executor_client.d.ts +129 -0
  54. package/dist/executor_client.d.ts.map +1 -1
  55. package/dist/file_meta.d.ts +26 -0
  56. package/dist/file_meta.d.ts.map +1 -0
  57. package/dist/index.cjs +1 -1
  58. package/dist/index.cjs.map +1 -1
  59. package/dist/index.d.ts +3 -1
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.mjs +228 -217
  62. package/dist/index.mjs.map +1 -1
  63. package/dist/internal/command_args.d.ts +67 -0
  64. package/dist/internal/command_args.d.ts.map +1 -0
  65. package/dist/krpc_client-26c2dc8b.js +2 -0
  66. package/dist/krpc_client-26c2dc8b.js.map +1 -0
  67. package/dist/krpc_client-673448e5.mjs +173 -0
  68. package/dist/krpc_client-673448e5.mjs.map +1 -0
  69. package/dist/krpc_client.d.ts +5 -1
  70. package/dist/krpc_client.d.ts.map +1 -1
  71. package/dist/msg_center_client.d.ts +2 -1
  72. package/dist/msg_center_client.d.ts.map +1 -1
  73. package/dist/namelib.d.ts.map +1 -1
  74. package/dist/ndm_client.d.ts +7 -0
  75. package/dist/ndm_client.d.ts.map +1 -1
  76. package/dist/ndn.d.ts +3 -0
  77. package/dist/ndn.d.ts.map +1 -0
  78. package/dist/{namelib-b41b10cc.mjs → ndn_types-0fac2499.mjs} +3096 -2816
  79. package/dist/ndn_types-0fac2499.mjs.map +1 -0
  80. package/dist/ndn_types-5b138882.js +2 -0
  81. package/dist/ndn_types-5b138882.js.map +1 -0
  82. package/dist/ndn_types.d.ts +268 -16
  83. package/dist/ndn_types.d.ts.map +1 -1
  84. package/dist/node.cjs +1 -1
  85. package/dist/node.cjs.map +1 -1
  86. package/dist/node.d.ts +1 -1
  87. package/dist/node.d.ts.map +1 -1
  88. package/dist/node.mjs +220 -212
  89. package/dist/node.mjs.map +1 -1
  90. package/dist/object_url-8fb5a7bf.js +2 -0
  91. package/dist/object_url-8fb5a7bf.js.map +1 -0
  92. package/dist/object_url-f72c1704.mjs +412 -0
  93. package/dist/object_url-f72c1704.mjs.map +1 -0
  94. package/dist/openai-ae2978de.mjs +163 -0
  95. package/dist/openai-ae2978de.mjs.map +1 -0
  96. package/dist/openai-f560d518.js +2 -0
  97. package/dist/openai-f560d518.js.map +1 -0
  98. package/dist/provision.cjs +6 -6
  99. package/dist/provision.cjs.map +1 -1
  100. package/dist/provision.d.ts +1 -2
  101. package/dist/provision.d.ts.map +1 -1
  102. package/dist/provision.mjs +4 -31
  103. package/dist/provision.mjs.map +1 -1
  104. package/dist/repo_client.d.ts +2 -1
  105. package/dist/repo_client.d.ts.map +1 -1
  106. package/dist/site_manager-11a7a468.mjs +6410 -0
  107. package/dist/site_manager-11a7a468.mjs.map +1 -0
  108. package/dist/site_manager-334b1a51.js +2 -0
  109. package/dist/site_manager-334b1a51.js.map +1 -0
  110. package/dist/{tus_client-4f7254e9.js → tus_client-809c90ab.js} +2 -2
  111. package/dist/{tus_client-4f7254e9.js.map → tus_client-809c90ab.js.map} +1 -1
  112. package/dist/{tus_client-04080b1e.mjs → tus_client-893a3287.mjs} +2 -2
  113. package/dist/{tus_client-04080b1e.mjs.map → tus_client-893a3287.mjs.map} +1 -1
  114. package/dist/xllm/core/action_parser.d.ts +15 -0
  115. package/dist/xllm/core/action_parser.d.ts.map +1 -0
  116. package/dist/xllm/core/behavior_loop.d.ts +20 -0
  117. package/dist/xllm/core/behavior_loop.d.ts.map +1 -0
  118. package/dist/xllm/core/behavior_result.d.ts +11 -0
  119. package/dist/xllm/core/behavior_result.d.ts.map +1 -0
  120. package/dist/xllm/core/config.d.ts +62 -0
  121. package/dist/xllm/core/config.d.ts.map +1 -0
  122. package/dist/xllm/core/context_window.d.ts +15 -0
  123. package/dist/xllm/core/context_window.d.ts.map +1 -0
  124. package/dist/xllm/core/deps.d.ts +97 -0
  125. package/dist/xllm/core/deps.d.ts.map +1 -0
  126. package/dist/xllm/core/errors.d.ts +94 -0
  127. package/dist/xllm/core/errors.d.ts.map +1 -0
  128. package/dist/xllm/core/interrupt.d.ts +31 -0
  129. package/dist/xllm/core/interrupt.d.ts.map +1 -0
  130. package/dist/xllm/core/json.d.ts +11 -0
  131. package/dist/xllm/core/json.d.ts.map +1 -0
  132. package/dist/xllm/core/json_check.d.ts +17 -0
  133. package/dist/xllm/core/json_check.d.ts.map +1 -0
  134. package/dist/xllm/core/loop.d.ts +135 -0
  135. package/dist/xllm/core/loop.d.ts.map +1 -0
  136. package/dist/xllm/core/messages.d.ts +18 -0
  137. package/dist/xllm/core/messages.d.ts.map +1 -0
  138. package/dist/xllm/core/observer.d.ts +14 -0
  139. package/dist/xllm/core/observer.d.ts.map +1 -0
  140. package/dist/xllm/core/open_runtime.d.ts +22 -0
  141. package/dist/xllm/core/open_runtime.d.ts.map +1 -0
  142. package/dist/xllm/core/prepare.d.ts +54 -0
  143. package/dist/xllm/core/prepare.d.ts.map +1 -0
  144. package/dist/xllm/core/prompt.d.ts +40 -0
  145. package/dist/xllm/core/prompt.d.ts.map +1 -0
  146. package/dist/xllm/core/protocol.d.ts +15 -0
  147. package/dist/xllm/core/protocol.d.ts.map +1 -0
  148. package/dist/xllm/core/result.d.ts +12 -0
  149. package/dist/xllm/core/result.d.ts.map +1 -0
  150. package/dist/xllm/core/run.d.ts +198 -0
  151. package/dist/xllm/core/run.d.ts.map +1 -0
  152. package/dist/xllm/core/rust_text.d.ts +20 -0
  153. package/dist/xllm/core/rust_text.d.ts.map +1 -0
  154. package/dist/xllm/core/site_policy.d.ts +5 -0
  155. package/dist/xllm/core/site_policy.d.ts.map +1 -0
  156. package/dist/xllm/core/store.d.ts +60 -0
  157. package/dist/xllm/core/store.d.ts.map +1 -0
  158. package/dist/xllm/core/suspension.d.ts +13 -0
  159. package/dist/xllm/core/suspension.d.ts.map +1 -0
  160. package/dist/xllm/core/tokenizer.d.ts +8 -0
  161. package/dist/xllm/core/tokenizer.d.ts.map +1 -0
  162. package/dist/xllm/core/types.d.ts +826 -0
  163. package/dist/xllm/core/types.d.ts.map +1 -0
  164. package/dist/xllm/core/xml.d.ts +19 -0
  165. package/dist/xllm/core/xml.d.ts.map +1 -0
  166. package/dist/xllm/dev/openai.d.ts +17 -0
  167. package/dist/xllm/dev/openai.d.ts.map +1 -0
  168. package/dist/xllm/dev/scripted.d.ts +46 -0
  169. package/dist/xllm/dev/scripted.d.ts.map +1 -0
  170. package/dist/xllm/dev.d.ts +5 -0
  171. package/dist/xllm/dev.d.ts.map +1 -0
  172. package/dist/xllm/hosts/browser/store.d.ts +41 -0
  173. package/dist/xllm/hosts/browser/store.d.ts.map +1 -0
  174. package/dist/xllm/hosts/deno/deno_api.d.ts +103 -0
  175. package/dist/xllm/hosts/deno/deno_api.d.ts.map +1 -0
  176. package/dist/xllm/hosts/deno/identity.d.ts +29 -0
  177. package/dist/xllm/hosts/deno/identity.d.ts.map +1 -0
  178. package/dist/xllm/hosts/deno/index.d.ts +47 -0
  179. package/dist/xllm/hosts/deno/index.d.ts.map +1 -0
  180. package/dist/xllm/hosts/deno/native_runtime.d.ts +93 -0
  181. package/dist/xllm/hosts/deno/native_runtime.d.ts.map +1 -0
  182. package/dist/xllm/hosts/deno/native_tools.d.ts +105 -0
  183. package/dist/xllm/hosts/deno/native_tools.d.ts.map +1 -0
  184. package/dist/xllm/hosts/deno/provider.d.ts +13 -0
  185. package/dist/xllm/hosts/deno/provider.d.ts.map +1 -0
  186. package/dist/xllm/hosts/deno/store.d.ts +60 -0
  187. package/dist/xllm/hosts/deno/store.d.ts.map +1 -0
  188. package/dist/xllm/index.d.ts +48 -0
  189. package/dist/xllm/index.d.ts.map +1 -0
  190. package/dist/xllm/providers/aicc.d.ts +22 -0
  191. package/dist/xllm/providers/aicc.d.ts.map +1 -0
  192. package/dist/xllm/providers/timeout.d.ts +12 -0
  193. package/dist/xllm/providers/timeout.d.ts.map +1 -0
  194. package/dist/xllm/runtime/compress.d.ts +149 -0
  195. package/dist/xllm/runtime/compress.d.ts.map +1 -0
  196. package/dist/xllm/runtime/did_object_resources.d.ts +21 -0
  197. package/dist/xllm/runtime/did_object_resources.d.ts.map +1 -0
  198. package/dist/xllm/runtime/hints.d.ts +23 -0
  199. package/dist/xllm/runtime/hints.d.ts.map +1 -0
  200. package/dist/xllm/runtime/site.d.ts +22 -0
  201. package/dist/xllm/runtime/site.d.ts.map +1 -0
  202. package/dist/xllm/runtime/site_manager.d.ts +38 -0
  203. package/dist/xllm/runtime/site_manager.d.ts.map +1 -0
  204. package/dist/xllm/runtime/site_tools.d.ts +76 -0
  205. package/dist/xllm/runtime/site_tools.d.ts.map +1 -0
  206. package/dist/xllm/runtime/step_renderer.d.ts +54 -0
  207. package/dist/xllm/runtime/step_renderer.d.ts.map +1 -0
  208. package/dist/xllm/runtime/task_model.d.ts +64 -0
  209. package/dist/xllm/runtime/task_model.d.ts.map +1 -0
  210. package/dist/xllm/runtime/tool_result.d.ts +39 -0
  211. package/dist/xllm/runtime/tool_result.d.ts.map +1 -0
  212. package/dist/xllm/runtime/types.d.ts +99 -0
  213. package/dist/xllm/runtime/types.d.ts.map +1 -0
  214. package/dist/xllm.cjs +2 -0
  215. package/dist/xllm.cjs.map +1 -0
  216. package/dist/xllm.mjs +1167 -0
  217. package/dist/xllm.mjs.map +1 -0
  218. package/dist/xllm_deno.cjs +2 -0
  219. package/dist/xllm_deno.cjs.map +1 -0
  220. package/dist/xllm_deno.mjs +2487 -0
  221. package/dist/xllm_deno.mjs.map +1 -0
  222. package/dist/xllm_dev.cjs +2 -0
  223. package/dist/xllm_dev.cjs.map +1 -0
  224. package/dist/xllm_dev.mjs +70 -0
  225. package/dist/xllm_dev.mjs.map +1 -0
  226. package/package.json +22 -1
  227. package/src/internal/command_args.ts +268 -0
  228. package/dist/executor_client-a32bc377.mjs.map +0 -1
  229. package/dist/executor_client-e026942b.js +0 -13
  230. package/dist/executor_client-e026942b.js.map +0 -1
  231. package/dist/namelib-b41b10cc.mjs.map +0 -1
  232. package/dist/namelib-f8ff0045.js +0 -2
  233. package/dist/namelib-f8ff0045.js.map +0 -1
@@ -0,0 +1,2 @@
1
+ "use strict";const e=require("./krpc_client-26c2dc8b.js");class t extends Error{constructor(e){super(n(e)),this.name="LLMComputeException",this.error=e}}function r(e,r){return new t({kind:"provider",failure:e,message:r})}function n(e){switch(e.kind){case"timeout":return"llm timeout";case"cancelled":return"llm cancelled";case"provider":return`llm provider failed (${r=e.failure,"object"==typeof r?`Refused { code: ${JSON.stringify(r.refused.code)} }`:{transient:"Transient",permanent:"Permanent",unknown:"Unknown",context_limit:"ContextLimit"}[r]}): ${e.message}`;case"output_parse":return`llm output parse failed: ${e.message}`;case"policy_rejected":return`policy rejected: ${e.message}`;case"tool_failed":return`tool \`${e.tool}\` failed: ${e.message}`;case"tool_runtime":return`tool \`${e.tool}\` dispatch failed (effect_unknown=${e.effect_unknown}): ${e.message}`;case"checkpoint":return`checkpoint ${t=e.stage,{before_inference:"BeforeInference",before_tool_call:"BeforeToolCall",outcome_boundary:"OutcomeBoundary"}[t]} failed: ${e.message}`;case"snapshot_corrupted":return`snapshot corrupted: ${e.message}`;case"internal":return`internal: ${e.message}`}var t,r}class o extends Error{constructor(e){super(function(e){switch(e.kind){case"config":return`config error: ${e.file}: ${e.field}: ${e.reason}`;case"input":return`input error: ${e.message}`;case"capability":return`capability error: ${e.message}`;case"runtime_mismatch":return`runtime mismatch: ${e.message}`;case"recovery_blocked":return`RecoveryBlocked: ${e.message}`;case"tools":return`tools error: ${e.message}`;case"template":return`template error in ${e.origin}: ${e.reason}`;case"run_not_found":return`run \`${e.run_id}\` not found under ${e.runs_dir}`;case"run_busy":return`run \`${e.run_id}\` is being executed by another process`;case"workdir_busy":return`working directory ${e.workdir} already has a tool-enabled run \`${e.run_id}\` executing; wait for it or use another directory`;case"run_terminal":return`run \`${e.run_id}\` is terminal (${e.status}); ${e.hint}`;case"not_resumable":return`run \`${e.run_id}\` cannot be resumed: ${e.reason}`;case"corrupted_run":return`run \`${e.run_id}\` record is corrupted: ${e.reason}`;case"storage":return`storage error: ${e.message}`;case"extract":return`result extraction failed: ${e.message}`;case"compressor":return`context compaction failed: ${e.message}`;case"other":return e.message}}(e)),this.name="XllmError",this.detail=e}get kind(){return this.detail.kind}static config(e,t,r){return new o({kind:"config",file:e,field:t,reason:r})}static input(e){return new o({kind:"input",message:e})}static capability(e){return new o({kind:"capability",message:e})}static runtimeMismatch(e){return new o({kind:"runtime_mismatch",message:e})}static tools(e){return new o({kind:"tools",message:e})}static template(e,t){return new o({kind:"template",origin:e,reason:t})}static notResumable(e,t){return new o({kind:"not_resumable",run_id:e,reason:t})}static storage(e){return new o({kind:"storage",message:e})}static other(e){return new o({kind:"other",message:e})}}function s(e){return e>=9&&e<=13||32===e||133===e||160===e||5760===e||e>=8192&&e<=8202||8232===e||8233===e||8239===e||8287===e||12288===e}function i(e){let t=0;for(;t<e.length&&s(e.charCodeAt(t));)t++;return 0===t?e:e.slice(t)}function a(e){let t=e.length;for(;t>0&&s(e.charCodeAt(t-1));)t--;return t===e.length?e:e.slice(0,t)}function c(e){return i(a(e))}function u(e,t){const r=e.charCodeAt(t);return r>=55296&&r<=56319&&t+1<e.length&&56320==(64512&e.charCodeAt(t+1))}function l(e){let t="";for(const r of e.content)"text"===r.type&&(""!==t&&(t+="\n"),t+=r.text);return t}function d(e,t){let r=0,n=0;for(;r<e.length&&n<t.length;){const o=e.codePointAt(r),s=t.codePointAt(n);if(o!==s)return o-s;r+=o>65535?2:1,n+=s>65535?2:1}return e.length-r-(t.length-n)}function p(e,t){if(null==e)return"null";if("string"==typeof e)return JSON.stringify(e);if("number"==typeof e)return function(e){if(!Number.isFinite(e))return"null";if(Number.isInteger(e)&&e>-(2**63)&&e<2**64)return String(e);const[t,r]=Math.abs(e).toExponential().split("e"),n=t.replace(".",""),o=n.length,s=Number(r);let i;return i=s>=-5&&s<=15?o-1<=s?`${n}${"0".repeat(s+1-o)}.0`:s>=0?`${n.slice(0,s+1)}.${n.slice(s+1)}`:`0.${"0".repeat(-s-1)}${n}`:`${o>1?`${n[0]}.${n.slice(1)}`:n}e${s<0?"-":"+"}${Math.abs(s)}`,e<0?`-${i}`:i}(e);if("boolean"==typeof e)return e?"true":"false";const r=void 0===t?void 0:`${t} `;if(Array.isArray(e)){if(0===e.length)return"[]";const n=e.map((e=>p(e,r)));return void 0===r?`[${n.join(",")}]`:`[${r}${n.join(`,${r}`)}${t}]`}const n=Object.keys(e).filter((t=>void 0!==e[t])).sort(d);if(0===n.length)return"{}";const o=n.map((t=>`${JSON.stringify(t)}:${void 0===r?"":" "}${p(e[t],r)}`));return void 0===r?`{${o.join(",")}}`:`{${r}${o.join(`,${r}`)}${t}}`}function f(e,t=!1){return p(e,t?"\n":void 0)}function m(e){return void 0===e?"null":f(JSON.parse(JSON.stringify(e)))}function _(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const g=["input_tokens","output_tokens","total_tokens","cache_read_input_tokens","cache_write_input_tokens","cache_write_1h_input_tokens","reasoning_tokens","image_units","audio_seconds","video_seconds","reference_images","request_units","characters","audio_input_tokens","image_input_tokens","audio_output_tokens","image_output_tokens"];const h=["quota_exhausted","quota_budget_exceeded","resource_not_permitted","attribution_unavailable"];function $(){return{type:"object",additionalProperties:!0}}function k(e){return{refused:{code:e}}}function x(e){const t=e.code;if(t&&h.includes(t))return k(t);if("quota_unavailable"===t)return"transient";const r=_(e.details)?e.details.http_status:void 0;return"context_length_exceeded"===t||413===r?"context_limit":"timeout"===t||!0===e.retriable?"transient":void 0}function y(t,n){const o=`${t}: ${n instanceof Error?n.message:String(n)}`,s="object"==typeof n&&null!==n?n.code:void 0;if("string"!=typeof s||!s)return r("unknown",o);const i=n.data,a=_(i)?i:void 0,c=x({...a,code:s});if(c)return r(c,o);if(s===e.RPC_HTTP_ERROR_CODE){const e="number"==typeof(null==a?void 0:a.status)?a.status:void 0;return r(413===e?"context_limit":408===e||504===e?"transient":401===e||403===e?k("credentials"):"unknown",o)}return s===e.RPC_TRANSPORT_ERROR_CODE?r("transient",o):r("unknown",o)}const v={tool_call:"tool_call",json_schema:"json_schema",web_search:"web_search",vision:"vision",image_generation:"image_generation",streaming:"streaming"};exports.AiccLlmClient=class{constructor(e){this.client=e}async infer(e){var n;const o=e.allow_tool_calls?e.tool_specs.map((e=>({type:"function",name:e.name,description:e.description,args_json_schema:e.args_schema}))):[],s={};for(const t of e.disable_capabilities){const e=v[t];e&&(s[e]=!0)}let i;e.force_json&&(i=void 0!==e.json_schema?{type:"json_schema",json_schema:{name:"llm_response",schema:e.json_schema}}:{type:"json_schema",json_schema:{name:"llm_response",schema:{type:"object",additionalProperties:!0},strict:!1}});const a={messages:e.messages,...o.length?{tools:o}:{},...i?{response_format:i}:{},...void 0!==e.temperature?{temperature:e.temperature}:{},...void 0!==e.max_completion_tokens?{max_output_tokens:e.max_completion_tokens}:{},...e.trace_id?{trace_id:e.trace_id}:{},execution_mode:"immediate"},c=e.model_alias.includes("@"),u=c?"chat.completions.create":"helper.llm_chat";let l;try{if(c){const t={exact_model:e.model_alias,...a};l=await this.client.chatCompletionsCreate(t)}else{const t={};e.allow_tool_calls&&o.length>0&&(t.tool_call=!0),e.force_json&&(t.json_schema=!0);const r={logical_model:e.model_alias,...a,...Object.keys(t).length?{requirements:t}:{},...Object.keys(s).length?{disable:s}:{}};l=await this.client.helperLlmChat(r)}}catch(d){if(d instanceof t)throw d;throw y(`aicc ${u} failed`,d)}if("succeeded"===l.status){if(!l.message)throw r("unknown",`aicc ${u} succeeded but message is empty`);const e={message:l.message};l.usage&&(e.usage=l.usage),l.cost&&(e.cost=l.cost),l.finish_reason&&(e.finish_reason=l.finish_reason),l.provider_task_ref&&(e.provider_task_ref=l.provider_task_ref);const t=null==(n=l.route_trace)?void 0:n.final_model;return t&&(e.extra={model:t}),e}if("failed"===l.status){throw r((l.error&&x(l.error))??"unknown",`aicc ${u} failed${d=l.error,d?` (${d.code}: ${d.message})`:""}: task_id=${l.task_id}, event_ref=${l.event_ref??""}`)}var d;throw r("permanent",`aicc ${u} returned async task \`${l.task_id}\`; xllm does not poll async tasks — use a synchronous-capable model`)}},exports.LLMComputeException=t,exports.XllmError=o,exports.addRecordUsage=function(e,t){const r={...e??{}};for(const n of["input_tokens","output_tokens","total_tokens","request_units"])void 0!==t[n]&&(r[n]=(r[n]??0)+t[n]);return r},exports.aiccProviderFailure=x,exports.anyJsonObjectSchema=$,exports.asComputeError=function(e){return e instanceof t?e.error:{kind:"provider",failure:"unknown",message:e instanceof Error?e.message:String(e)}},exports.canonicalJson=m,exports.charCount=function(e){let t=0;for(let r=0;r<e.length;r+=u(e,r)?2:1)t++;return t},exports.charOffset=function(e,t){let r=0;for(let n=0;n<t&&r<e.length;n++)r+=u(e,r)?2:1;return r},exports.cloneJson=function(e){return void 0===e?e:JSON.parse(JSON.stringify(e))},exports.collapseWhitespace=function(e){const t=[];let r=-1;for(let n=0;n<e.length;n++)s(e.charCodeAt(n))?(r>=0&&t.push(e.slice(r,n)),r=-1):r<0&&(r=n);return r>=0&&t.push(e.slice(r)),t.join(" ")},exports.compareCodePoints=d,exports.computeErrorMessage=n,exports.errorSource=function(e){switch(e.kind){case"timeout":case"cancelled":case"provider":return"provider";case"output_parse":return"llm_output";case"policy_rejected":case"tool_failed":return"tool";case"tool_runtime":case"checkpoint":return"runtime";case"snapshot_corrupted":return"snapshot";case"internal":return"internal"}},exports.infraRetrySafe=function(e){switch(e.kind){case"timeout":case"checkpoint":return!0;case"provider":return"transient"===e.failure;case"tool_runtime":return!e.effect_unknown;default:return!1}},exports.isObject=_,exports.jsonEqual=function(e,t){return m(e)===m(t)},exports.llmCorrectable=function(e){return"output_parse"===e.kind||"policy_rejected"===e.kind||"tool_failed"===e.kind},exports.mergeUsage=function(e,t){const r={};for(const i of g){const n=e[i],o=t[i];void 0===n&&void 0===o||(r[i]=(n??0)+(o??0))}const n=(o=e.cost,s=t.cost,o&&s?o.currency===s.currency?{amount:o.amount+s.amount,currency:o.currency}:void 0:o??s);var o,s;return n&&(r.cost=n),r},exports.nowMs=function(){return Date.now()},exports.providerError=r,exports.providerErrorFromRpc=y,exports.refusedCode=function(e){return"object"==typeof e?e.refused.code:void 0},exports.rustTextContent=l,exports.rustTrim=c,exports.rustTrimEnd=a,exports.rustTrimStart=i,exports.serdeJson=f,exports.textContent=function(e){return l(e)},exports.textMessage=function(e,t){return{role:e,content:[{type:"text",text:t}]}},exports.toolCalls=function(e){const t=[];for(const r of e.content)"tool_use"===r.type&&t.push({name:r.name,args:r.args??{},call_id:r.call_id});return t},exports.toolObservationMessage=function(e,t){let r,n;switch(t.kind){case"success":r="string"==typeof t.content?t.content:m(t.content),n=!1;break;case"error":r=t.message,n=!0;break;case"cancelled":t.effect_unknown?(r=`[cancelled, result unknown] ${t.reason}`,n=!0):(r=`[cancelled] ${t.reason}`,n=!1);break;case"unresolved":r=t.effect_unknown?`[unresolved: result unknown] ${t.reason}`:`[not executed] ${t.reason}`,n=!0}return{role:"tool",content:[n?{type:"tool_result",call_id:e,content:[{type:"text",text:r}],is_error:!0}:{type:"tool_result",call_id:e,content:[{type:"text",text:r}]}]}},exports.validateResponse=function(e){const t=e.message;if(!t||"assistant"!==t.role)return`invalid block response_message for role ${null==t?void 0:t.role}`;for(const r of t.content??[]){if(!["text","image","document","tool_use","thinking","provider_state"].includes(r.type))return`invalid block ${r.type} for role assistant`;if("tool_use"===r.type&&!c(r.call_id??""))return"tool call without call_id"}};
2
+ //# sourceMappingURL=aicc-ccb36ef7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aicc-ccb36ef7.js","sources":["../src/xllm/core/errors.ts","../src/xllm/core/rust_text.ts","../src/xllm/core/json.ts","../src/xllm/core/messages.ts","../src/xllm/providers/aicc.ts"],"sourcesContent":["import type { CheckpointStage, ErrorSource, LLMComputeError, ProviderFailure, RunStatus } from './types'\n\n// ------------------------------------------------------------ LLMComputeError\n\n/** A rejected `LlmClient.infer` (or any waist dependency) carries its `LLMComputeError`. */\nexport class LLMComputeException extends Error {\n readonly error: LLMComputeError\n\n constructor(error: LLMComputeError) {\n super(computeErrorMessage(error))\n this.name = 'LLMComputeException'\n this.error = error\n }\n}\n\nexport function providerError(failure: ProviderFailure, message: string): LLMComputeException {\n return new LLMComputeException({ kind: 'provider', failure, message })\n}\n\n/** What a dependency rejected with, as an `LLMComputeError`. A foreign error is a provider failure of unknown class. */\nexport function asComputeError(error: unknown): LLMComputeError {\n if (error instanceof LLMComputeException) return error.error\n const message = error instanceof Error ? error.message : String(error)\n return { kind: 'provider', failure: 'unknown', message }\n}\n\nfunction failureDebug(failure: ProviderFailure): string {\n if (typeof failure === 'object') return `Refused { code: ${JSON.stringify(failure.refused.code)} }`\n return { transient: 'Transient', permanent: 'Permanent', unknown: 'Unknown', context_limit: 'ContextLimit' }[failure]\n}\n\nfunction stageDebug(stage: CheckpointStage): string {\n return { before_inference: 'BeforeInference', before_tool_call: 'BeforeToolCall', outcome_boundary: 'OutcomeBoundary' }[stage]\n}\n\n/** Same text as Rust's `Display for LLMComputeError` (run.json `last_error.message`). */\nexport function computeErrorMessage(e: LLMComputeError): string {\n switch (e.kind) {\n case 'timeout': return 'llm timeout'\n case 'cancelled': return 'llm cancelled'\n case 'provider': return `llm provider failed (${failureDebug(e.failure)}): ${e.message}`\n case 'output_parse': return `llm output parse failed: ${e.message}`\n case 'policy_rejected': return `policy rejected: ${e.message}`\n case 'tool_failed': return `tool \\`${e.tool}\\` failed: ${e.message}`\n case 'tool_runtime': return `tool \\`${e.tool}\\` dispatch failed (effect_unknown=${e.effect_unknown}): ${e.message}`\n case 'checkpoint': return `checkpoint ${stageDebug(e.stage)} failed: ${e.message}`\n case 'snapshot_corrupted': return `snapshot corrupted: ${e.message}`\n case 'internal': return `internal: ${e.message}`\n }\n}\n\nexport function errorSource(e: LLMComputeError): ErrorSource {\n switch (e.kind) {\n case 'timeout': case 'cancelled': case 'provider': return 'provider'\n case 'output_parse': return 'llm_output'\n case 'policy_rejected': case 'tool_failed': return 'tool'\n case 'tool_runtime': case 'checkpoint': return 'runtime'\n case 'snapshot_corrupted': return 'snapshot'\n case 'internal': return 'internal'\n }\n}\n\n/** Feeding the error back to the model is a meaningful recovery; everything else ends the run. */\nexport function llmCorrectable(e: LLMComputeError): boolean {\n return e.kind === 'output_parse' || e.kind === 'policy_rejected' || e.kind === 'tool_failed'\n}\n\nexport function infraRetrySafe(e: LLMComputeError): boolean {\n switch (e.kind) {\n case 'timeout': case 'checkpoint': return true\n case 'provider': return e.failure === 'transient'\n case 'tool_runtime': return !e.effect_unknown\n default: return false\n }\n}\n\nexport function refusedCode(failure: ProviderFailure): string | undefined {\n return typeof failure === 'object' ? failure.refused.code : undefined\n}\n\n// ------------------------------------------------------------------ XllmError\n\n/** Pre-run errors of the SDK (`XllmError` in Rust): once a run exists, results come back as a `RunOutcome`. */\nexport type XllmErrorDetail =\n | { kind: 'config'; file: string; field: string; reason: string }\n | { kind: 'input'; message: string }\n | { kind: 'capability'; message: string }\n | { kind: 'runtime_mismatch'; message: string }\n | { kind: 'recovery_blocked'; message: string }\n | { kind: 'tools'; message: string }\n | { kind: 'template'; origin: string; reason: string }\n | { kind: 'run_not_found'; run_id: string; runs_dir: string }\n | { kind: 'run_busy'; run_id: string }\n | { kind: 'workdir_busy'; workdir: string; run_id: string }\n | { kind: 'run_terminal'; run_id: string; status: RunStatus; hint: string }\n | { kind: 'not_resumable'; run_id: string; reason: string }\n | { kind: 'corrupted_run'; run_id: string; reason: string }\n | { kind: 'storage'; message: string }\n | { kind: 'extract'; message: string }\n | { kind: 'compressor'; message: string }\n | { kind: 'other'; message: string }\n\nexport type XllmErrorKind = XllmErrorDetail['kind']\n\nfunction xllmErrorMessage(d: XllmErrorDetail): string {\n switch (d.kind) {\n case 'config': return `config error: ${d.file}: ${d.field}: ${d.reason}`\n case 'input': return `input error: ${d.message}`\n case 'capability': return `capability error: ${d.message}`\n case 'runtime_mismatch': return `runtime mismatch: ${d.message}`\n case 'recovery_blocked': return `RecoveryBlocked: ${d.message}`\n case 'tools': return `tools error: ${d.message}`\n case 'template': return `template error in ${d.origin}: ${d.reason}`\n case 'run_not_found': return `run \\`${d.run_id}\\` not found under ${d.runs_dir}`\n case 'run_busy': return `run \\`${d.run_id}\\` is being executed by another process`\n case 'workdir_busy':\n return `working directory ${d.workdir} already has a tool-enabled run \\`${d.run_id}\\` executing; wait for it or use another directory`\n case 'run_terminal': return `run \\`${d.run_id}\\` is terminal (${d.status}); ${d.hint}`\n case 'not_resumable': return `run \\`${d.run_id}\\` cannot be resumed: ${d.reason}`\n case 'corrupted_run': return `run \\`${d.run_id}\\` record is corrupted: ${d.reason}`\n case 'storage': return `storage error: ${d.message}`\n case 'extract': return `result extraction failed: ${d.message}`\n case 'compressor': return `context compaction failed: ${d.message}`\n case 'other': return d.message\n }\n}\n\nexport class XllmError extends Error {\n readonly detail: XllmErrorDetail\n\n constructor(detail: XllmErrorDetail) {\n super(xllmErrorMessage(detail))\n this.name = 'XllmError'\n this.detail = detail\n }\n\n get kind(): XllmErrorKind {\n return this.detail.kind\n }\n\n static config(file: string, field: string, reason: string): XllmError {\n return new XllmError({ kind: 'config', file, field, reason })\n }\n\n static input(message: string): XllmError {\n return new XllmError({ kind: 'input', message })\n }\n\n static capability(message: string): XllmError {\n return new XllmError({ kind: 'capability', message })\n }\n\n static runtimeMismatch(message: string): XllmError {\n return new XllmError({ kind: 'runtime_mismatch', message })\n }\n\n static tools(message: string): XllmError {\n return new XllmError({ kind: 'tools', message })\n }\n\n static template(origin: string, reason: string): XllmError {\n return new XllmError({ kind: 'template', origin, reason })\n }\n\n static notResumable(runId: string, reason: string): XllmError {\n return new XllmError({ kind: 'not_resumable', run_id: runId, reason })\n }\n\n static storage(message: string): XllmError {\n return new XllmError({ kind: 'storage', message })\n }\n\n static other(message: string): XllmError {\n return new XllmError({ kind: 'other', message })\n }\n}\n","// Rust string and JSON semantics for text the model sees: trimming with\n// Rust's whitespace set (`char::is_whitespace` differs from JS `trim` in\n// U+0085 and U+FEFF), lengths in Unicode scalar values, JSON written the way\n// serde_json writes it (keys in code point order, serde's number layout).\n\nimport type { AiMessage, JsonValue } from './types'\n\n/** `char::is_whitespace` (Unicode White_Space); every such char is a single UTF-16 unit. */\nfunction isRustWhitespace(c: number): boolean {\n return (c >= 0x09 && c <= 0x0d) || c === 0x20 || c === 0x85 || c === 0xa0 || c === 0x1680 || (c >= 0x2000 && c <= 0x200a) ||\n c === 0x2028 || c === 0x2029 || c === 0x202f || c === 0x205f || c === 0x3000\n}\n\n/** `str::trim_start`. */\nexport function rustTrimStart(s: string): string {\n let i = 0\n while (i < s.length && isRustWhitespace(s.charCodeAt(i))) i++\n return i === 0 ? s : s.slice(i)\n}\n\n/** `str::trim_end`. */\nexport function rustTrimEnd(s: string): string {\n let j = s.length\n while (j > 0 && isRustWhitespace(s.charCodeAt(j - 1))) j--\n return j === s.length ? s : s.slice(0, j)\n}\n\n/** `str::trim`. */\nexport function rustTrim(s: string): string {\n return rustTrimStart(rustTrimEnd(s))\n}\n\n/** `s.split_whitespace().collect::<Vec<_>>().join(\" \")`. */\nexport function collapseWhitespace(s: string): string {\n const words: string[] = []\n let start = -1\n for (let i = 0; i < s.length; i++) {\n if (isRustWhitespace(s.charCodeAt(i))) {\n if (start >= 0) words.push(s.slice(start, i))\n start = -1\n } else if (start < 0) {\n start = i\n }\n }\n if (start >= 0) words.push(s.slice(start))\n return words.join(' ')\n}\n\nfunction isPairAt(s: string, i: number): boolean {\n const c = s.charCodeAt(i)\n return c >= 0xd800 && c <= 0xdbff && i + 1 < s.length && (s.charCodeAt(i + 1) & 0xfc00) === 0xdc00\n}\n\n/** UTF-16 offset after the first `n` chars (Unicode scalar values) of `s`; `s.length` when it has fewer. */\nexport function charOffset(s: string, n: number): number {\n let i = 0\n for (let k = 0; k < n && i < s.length; k++) i += isPairAt(s, i) ? 2 : 1\n return i\n}\n\n/** `str::chars().count()`. */\nexport function charCount(s: string): number {\n let n = 0\n for (let i = 0; i < s.length; i += isPairAt(s, i) ? 2 : 1) n++\n return n\n}\n\n/** `AiMessage::text_content`: text blocks joined by `\\n`, a separator only once something was written. */\nexport function rustTextContent(message: AiMessage): string {\n let out = ''\n for (const b of message.content) {\n if (b.type !== 'text') continue\n if (out !== '') out += '\\n'\n out += b.text\n }\n return out\n}\n\n/** Order of Rust `String` (UTF-8 bytes, i.e. code points). */\nexport function compareCodePoints(a: string, b: string): number {\n let i = 0\n let j = 0\n while (i < a.length && j < b.length) {\n const x = a.codePointAt(i) as number\n const y = b.codePointAt(j) as number\n if (x !== y) return x - y\n i += x > 0xffff ? 2 : 1\n j += y > 0xffff ? 2 : 1\n }\n return (a.length - i) - (b.length - j)\n}\n\n/**\n * A number as serde_json writes the value it parsed from this number's JSON\n * text: an integer in the i64 / u64 range as is, anything else as an f64 in\n * the layout of serde_json's formatter (zmij): fixed notation for decimal\n * exponents -5..=15 (`0.00001`, `3.0`), else `1e+21` / `2.5e-7`.\n */\nfunction serdeNumber(n: number): string {\n if (!Number.isFinite(n)) return 'null'\n // -2^63 itself prints as -9223372036854776000, below i64::MIN: serde reads an f64.\n if (Number.isInteger(n) && n > -(2 ** 63) && n < 2 ** 64) return String(n)\n const [mantissa, exponent] = Math.abs(n).toExponential().split('e')\n const digits = mantissa.replace('.', '')\n const length = digits.length\n const e = Number(exponent)\n let s: string\n if (e >= -5 && e <= 15) {\n if (length - 1 <= e) s = `${digits}${'0'.repeat(e + 1 - length)}.0`\n else if (e >= 0) s = `${digits.slice(0, e + 1)}.${digits.slice(e + 1)}`\n else s = `0.${'0'.repeat(-e - 1)}${digits}`\n } else {\n s = `${length > 1 ? `${digits[0]}.${digits.slice(1)}` : digits}e${e < 0 ? '-' : '+'}${Math.abs(e)}`\n }\n return n < 0 ? `-${s}` : s\n}\n\nfunction writeJson(v: JsonValue | undefined, indent: string | undefined): string {\n if (v === null || v === undefined) return 'null'\n if (typeof v === 'string') return JSON.stringify(v)\n if (typeof v === 'number') return serdeNumber(v)\n if (typeof v === 'boolean') return v ? 'true' : 'false'\n const inner = indent === undefined ? undefined : `${indent} `\n if (Array.isArray(v)) {\n if (v.length === 0) return '[]'\n const items = v.map(x => writeJson(x, inner))\n return inner === undefined ? `[${items.join(',')}]` : `[${inner}${items.join(`,${inner}`)}${indent}]`\n }\n const keys = Object.keys(v).filter(k => v[k] !== undefined).sort(compareCodePoints)\n if (keys.length === 0) return '{}'\n const items = keys.map(k => `${JSON.stringify(k)}:${inner === undefined ? '' : ' '}${writeJson(v[k], inner)}`)\n return inner === undefined ? `{${items.join(',')}}` : `{${inner}${items.join(`,${inner}`)}${indent}}`\n}\n\n/** `serde_json::to_string` (or `to_string_pretty`) of a `Value`: keys in Rust's order, numbers as serde prints them. */\nexport function serdeJson(value: JsonValue, pretty = false): string {\n return writeJson(value, pretty ? '\\n' : undefined)\n}\n\n","// JSON helpers. serde_json (without `preserve_order`) writes object keys in\n// code point order; `canonicalJson` writes JSON exactly as serde_json does,\n// so lengths, comparisons and model-visible text match the Rust side.\n\nimport type { JsonValue } from './types'\nimport { serdeJson } from './rust_text'\n\n/** `serde_json::to_string` of the value (after a JSON round trip, so `toJSON` and `undefined` behave as in JSON). */\nexport function canonicalJson(value: unknown): string {\n if (value === undefined) return 'null'\n return serdeJson(JSON.parse(JSON.stringify(value)) as JsonValue)\n}\n\n/** Deep copy of a JSON value (drops `undefined` members like serialization does). */\nexport function cloneJson<T>(value: T): T {\n return value === undefined ? value : JSON.parse(JSON.stringify(value))\n}\n\n/** Structural equality of two JSON values, `undefined` members ignored. */\nexport function jsonEqual(a: unknown, b: unknown): boolean {\n return canonicalJson(a) === canonicalJson(b)\n}\n\nexport function isObject(v: unknown): v is { [key: string]: JsonValue } {\n return typeof v === 'object' && v !== null && !Array.isArray(v)\n}\n","import type { AiCost, AiMessage, AiRole } from '../../aicc_client'\nimport type { AiResponse, AiToolCall, AiUsage, JsonValue, Observation } from './types'\nimport { canonicalJson } from './json'\nimport { rustTextContent, rustTrim } from './rust_text'\n\nexport function nowMs(): number {\n return Date.now()\n}\n\nexport function textMessage(role: AiRole, text: string): AiMessage {\n return { role, content: [{ type: 'text', text }] }\n}\n\n/** All text blocks joined by `\\n` (`AiMessage::text_content`). */\nexport function textContent(message: AiMessage): string {\n return rustTextContent(message)\n}\n\n/** Tool-use blocks as calls, in message order (`AiMessage::tool_calls`). */\nexport function toolCalls(message: AiMessage): AiToolCall[] {\n const out: AiToolCall[] = []\n for (const b of message.content) {\n if (b.type === 'tool_use') out.push({ name: b.name, args: b.args ?? {}, call_id: b.call_id })\n }\n return out\n}\n\n/** `AiResponse::validate`: an assistant message with blocks allowed for the role and tool calls with ids. */\nexport function validateResponse(response: AiResponse): string | undefined {\n const m = response.message\n if (!m || m.role !== 'assistant') return `invalid block response_message for role ${m?.role}`\n for (const b of m.content ?? []) {\n if (!['text', 'image', 'document', 'tool_use', 'thinking', 'provider_state'].includes(b.type)) {\n return `invalid block ${b.type} for role assistant`\n }\n if (b.type === 'tool_use' && !rustTrim(b.call_id ?? '')) return 'tool call without call_id'\n }\n return undefined\n}\n\n/** The tool-role message carrying one observation back to the model. */\nexport function toolObservationMessage(callId: string, observation: Observation): AiMessage {\n let text: string\n let isError: boolean\n switch (observation.kind) {\n case 'success':\n text = typeof observation.content === 'string' ? observation.content : canonicalJson(observation.content)\n isError = false\n break\n case 'error':\n text = observation.message\n isError = true\n break\n case 'cancelled':\n if (observation.effect_unknown) {\n text = `[cancelled, result unknown] ${observation.reason}`\n isError = true\n } else {\n text = `[cancelled] ${observation.reason}`\n isError = false\n }\n break\n case 'unresolved':\n text = observation.effect_unknown ? `[unresolved: result unknown] ${observation.reason}` : `[not executed] ${observation.reason}`\n isError = true\n break\n }\n const block: AiMessage['content'][number] = isError\n ? { type: 'tool_result', call_id: callId, content: [{ type: 'text', text }], is_error: true }\n : { type: 'tool_result', call_id: callId, content: [{ type: 'text', text }] }\n return { role: 'tool', content: [block] }\n}\n\nconst USAGE_COUNTERS: (keyof AiUsage)[] = [\n 'input_tokens', 'output_tokens', 'total_tokens', 'cache_read_input_tokens', 'cache_write_input_tokens',\n 'cache_write_1h_input_tokens', 'reasoning_tokens', 'image_units', 'audio_seconds', 'video_seconds', 'reference_images',\n 'request_units', 'characters', 'audio_input_tokens', 'image_input_tokens', 'audio_output_tokens', 'image_output_tokens',\n]\n\n/** Sum of two usages (`merge_usage`): counters add, `cost` adds per currency, `reported_cost` is dropped. */\nexport function mergeUsage(left: AiUsage, right: AiUsage): AiUsage {\n const out: AiUsage = {}\n for (const k of USAGE_COUNTERS) {\n const a = left[k] as number | undefined\n const b = right[k] as number | undefined\n if (a !== undefined || b !== undefined) (out as Record<string, number>)[k] = (a ?? 0) + (b ?? 0)\n }\n const cost = addCost(left.cost, right.cost)\n if (cost) out.cost = cost\n return out\n}\n\nfunction addCost(a?: AiCost, b?: AiCost): AiCost | undefined {\n if (a && b) return a.currency === b.currency ? { amount: a.amount + b.amount, currency: a.currency } : undefined\n return a ?? b\n}\n\n/** `add_usage` of the run record: input / output / total tokens and request units. */\nexport function addRecordUsage(base: AiUsage | undefined, extra: AiUsage): AiUsage {\n const cur: AiUsage = { ...(base ?? {}) }\n for (const k of ['input_tokens', 'output_tokens', 'total_tokens', 'request_units'] as const) {\n if (extra[k] !== undefined) cur[k] = (cur[k] ?? 0) + (extra[k] as number)\n }\n return cur\n}\n\nexport function argsOf(args: Record<string, JsonValue> | undefined): Record<string, JsonValue> {\n return args ?? {}\n}\n","// AICC as an `LlmClient` (Rust `AiccLlmClient`). The client is the page's own\n// `AiccClient` (`getAiccClient()`): calls run under the page's session; xllm\n// never touches it.\n//\n// Error table (same order as Rust `aicc_provider_failure` /\n// `provider_error_from_rpc`, no matching on message text):\n// quota_exhausted / quota_budget_exceeded / resource_not_permitted /\n// attribution_unavailable → refused { code }\n// quota_unavailable → transient\n// context_length_exceeded, http_status 413 → context_limit\n// timeout, retriable → transient\n// kRPC http_error: 413 → context_limit, 408 / 504 → transient,\n// 401 / 403 → refused { credentials }, other → unknown\n// transport failure → transient\n// anything else → unknown\n\nimport type {\n AiccClient, AiccError, AiToolSpec, HelperModelRequirement, LlmChatHelperRequest, LlmChatInvokeRequest,\n LlmChatInvokeResponse, LlmResponseFormat, ModelDisable,\n} from '../../aicc_client'\nimport { RPC_HTTP_ERROR_CODE, RPC_TRANSPORT_ERROR_CODE } from '../../krpc_client'\nimport type { RPCError } from '../../krpc_client'\nimport type { AiResponse, JsonValue, LlmClient, LlmInferenceRequest, ProviderFailure } from '../core/types'\nimport { LLMComputeException, providerError } from '../core/errors'\nimport { isObject } from '../core/json'\n\nexport const REFUSED_QUOTA_EXHAUSTED = 'quota_exhausted'\nexport const REFUSED_QUOTA_BUDGET_EXCEEDED = 'quota_budget_exceeded'\nexport const REFUSED_RESOURCE_NOT_PERMITTED = 'resource_not_permitted'\nexport const REFUSED_ATTRIBUTION_UNAVAILABLE = 'attribution_unavailable'\n/** The service refused the caller's credentials: sign in again, then resume. */\nexport const REFUSED_CREDENTIALS = 'credentials'\n\nconst REFUSAL_CODES = [REFUSED_QUOTA_EXHAUSTED, REFUSED_QUOTA_BUDGET_EXCEEDED, REFUSED_RESOURCE_NOT_PERMITTED, REFUSED_ATTRIBUTION_UNAVAILABLE]\n\n/** `force_json` without a schema: any JSON object (a bare `{\"type\":\"object\"}` gets `{}` from Gemini). */\nexport function anyJsonObjectSchema(): JsonValue {\n return { type: 'object', additionalProperties: true }\n}\n\nfunction refused(code: string): ProviderFailure {\n return { refused: { code } }\n}\n\n/** Failure class of an AICC error, `undefined` when the error does not say. */\nexport function aiccProviderFailure(error: Partial<AiccError>): ProviderFailure | undefined {\n const code = error.code as string | undefined\n if (code && REFUSAL_CODES.includes(code)) return refused(code)\n if (code === 'quota_unavailable') return 'transient'\n const httpStatus = isObject(error.details) ? error.details.http_status : undefined\n if (code === 'context_length_exceeded' || httpStatus === 413) return 'context_limit'\n if (code === 'timeout' || error.retriable === true) return 'transient'\n return undefined\n}\n\n/** A failed AICC call (a rejected kRPC call) as a provider error. */\nexport function providerErrorFromRpc(context: string, err: unknown): LLMComputeException {\n const message = err instanceof Error ? err.message : String(err)\n const text = `${context}: ${message}`\n // Read the structured fields of an `RPCError` without `instanceof`: the\n // page's AICC client may come from another bundle of this SDK.\n const code = typeof err === 'object' && err !== null ? (err as Partial<RPCError>).code : undefined\n if (typeof code !== 'string' || !code) return providerError('unknown', text)\n const rawData = (err as Partial<RPCError>).data\n const data = isObject(rawData) ? rawData : undefined\n const fromAicc = aiccProviderFailure({ ...(data as Partial<AiccError> | undefined), code: code as AiccError['code'] })\n if (fromAicc) return providerError(fromAicc, text)\n if (code === RPC_HTTP_ERROR_CODE) {\n const status = typeof data?.status === 'number' ? data.status : undefined\n if (status === 413) return providerError('context_limit', text)\n if (status === 408 || status === 504) return providerError('transient', text)\n if (status === 401 || status === 403) return providerError(refused(REFUSED_CREDENTIALS), text)\n return providerError('unknown', text)\n }\n if (code === RPC_TRANSPORT_ERROR_CODE) return providerError('transient', text)\n return providerError('unknown', text)\n}\n\nconst DISABLE_FEATURES: Record<string, keyof ModelDisable> = {\n tool_call: 'tool_call', json_schema: 'json_schema', web_search: 'web_search', vision: 'vision',\n image_generation: 'image_generation', streaming: 'streaming',\n}\n\nfunction aiccErrorText(e: AiccError | undefined): string {\n return e ? ` (${e.code}: ${e.message})` : ''\n}\n\n/** `LlmClient` over the page's AICC client. */\nexport class AiccLlmClient implements LlmClient {\n constructor(private readonly client: AiccClient) {}\n\n async infer(req: LlmInferenceRequest): Promise<AiResponse> {\n const tools: AiToolSpec[] = req.allow_tool_calls\n ? req.tool_specs.map(s => ({ type: 'function', name: s.name, description: s.description, args_json_schema: s.args_schema }))\n : []\n const disable: ModelDisable = {}\n for (const f of req.disable_capabilities) {\n const key = DISABLE_FEATURES[f]\n if (key) (disable as Record<string, boolean>)[key] = true\n }\n let responseFormat: LlmResponseFormat | undefined\n if (req.force_json) {\n responseFormat = req.json_schema !== undefined\n ? { type: 'json_schema', json_schema: { name: 'llm_response', schema: req.json_schema } }\n : { type: 'json_schema', json_schema: { name: 'llm_response', schema: anyJsonObjectSchema(), strict: false } }\n }\n const common = {\n messages: req.messages,\n ...(tools.length ? { tools } : {}),\n ...(responseFormat ? { response_format: responseFormat } : {}),\n ...(req.temperature !== undefined ? { temperature: req.temperature } : {}),\n ...(req.max_completion_tokens !== undefined ? { max_output_tokens: req.max_completion_tokens } : {}),\n ...(req.trace_id ? { trace_id: req.trace_id } : {}),\n execution_mode: 'immediate' as const,\n }\n const exact = req.model_alias.includes('@')\n const method = exact ? 'chat.completions.create' : 'helper.llm_chat'\n let response: LlmChatInvokeResponse\n try {\n if (exact) {\n const r: LlmChatInvokeRequest = { exact_model: req.model_alias, ...common }\n response = await this.client.chatCompletionsCreate(r)\n } else {\n const requirements: HelperModelRequirement = {}\n if (req.allow_tool_calls && tools.length > 0) requirements.tool_call = true\n if (req.force_json) requirements.json_schema = true\n const r: LlmChatHelperRequest = {\n logical_model: req.model_alias, ...common,\n ...(Object.keys(requirements).length ? { requirements } : {}),\n ...(Object.keys(disable).length ? { disable } : {}),\n }\n response = await this.client.helperLlmChat(r)\n }\n } catch (e) {\n if (e instanceof LLMComputeException) throw e\n throw providerErrorFromRpc(`aicc ${method} failed`, e)\n }\n if (response.status === 'succeeded') {\n if (!response.message) throw providerError('unknown', `aicc ${method} succeeded but message is empty`)\n const out: AiResponse = { message: response.message }\n if (response.usage) out.usage = response.usage\n if (response.cost) out.cost = response.cost\n if (response.finish_reason) out.finish_reason = response.finish_reason\n if (response.provider_task_ref) out.provider_task_ref = response.provider_task_ref\n const model = response.route_trace?.final_model\n if (model) out.extra = { model }\n return out\n }\n if (response.status === 'failed') {\n const failure = (response.error && aiccProviderFailure(response.error)) ?? 'unknown'\n throw providerError(failure,\n `aicc ${method} failed${aiccErrorText(response.error)}: task_id=${response.task_id}, event_ref=${response.event_ref ?? ''}`)\n }\n throw providerError('permanent',\n `aicc ${method} returned async task \\`${response.task_id}\\`; xllm does not poll async tasks — use a synchronous-capable model`)\n }\n}\n"],"names":["LLMComputeException","Error","constructor","error","super","computeErrorMessage","this","name","providerError","failure","message","kind","e","JSON","stringify","refused","code","transient","permanent","unknown","context_limit","tool","effect_unknown","stage","before_inference","before_tool_call","outcome_boundary","XllmError","detail","d","file","field","reason","origin","run_id","runs_dir","workdir","status","hint","xllmErrorMessage","config","input","capability","runtimeMismatch","tools","template","notResumable","runId","storage","other","isRustWhitespace","c","rustTrimStart","s","i","length","charCodeAt","slice","rustTrimEnd","j","rustTrim","isPairAt","rustTextContent","out","b","content","type","text","compareCodePoints","a","x","codePointAt","y","writeJson","v","indent","n","Number","isFinite","isInteger","String","mantissa","exponent","Math","abs","toExponential","split","digits","replace","repeat","serdeNumber","inner","Array","isArray","items","map","join","keys","Object","filter","k","sort","serdeJson","value","pretty","canonicalJson","parse","isObject","USAGE_COUNTERS","REFUSAL_CODES","anyJsonObjectSchema","additionalProperties","aiccProviderFailure","includes","httpStatus","details","http_status","retriable","providerErrorFromRpc","context","err","rawData","data","fromAicc","RPC_HTTP_ERROR_CODE","RPC_TRANSPORT_ERROR_CODE","DISABLE_FEATURES","tool_call","json_schema","web_search","vision","image_generation","streaming","client","infer","req","allow_tool_calls","tool_specs","description","args_json_schema","args_schema","disable","f","disable_capabilities","key","responseFormat","force_json","schema","strict","common","messages","response_format","temperature","max_completion_tokens","max_output_tokens","trace_id","execution_mode","exact","model_alias","method","response","r","exact_model","chatCompletionsCreate","requirements","logical_model","helperLlmChat","usage","cost","finish_reason","provider_task_ref","model","_a","route_trace","final_model","extra","task_id","event_ref","base","cur","words","start","push","left","right","currency","amount","Date","now","role","args","call_id","callId","observation","isError","is_error","m"],"mappings":"0DAKO,MAAMA,UAA4BC,MAGvC,WAAAC,CAAYC,GACJC,MAAAC,EAAoBF,IAC1BG,KAAKC,KAAO,sBACZD,KAAKH,MAAQA,CACf,EAGc,SAAAK,EAAcC,EAA0BC,GACtD,OAAO,IAAIV,EAAoB,CAAEW,KAAM,WAAYF,UAASC,WAC9D,CAmBO,SAASL,EAAoBO,GAClC,OAAQA,EAAED,MACR,IAAK,UAAkB,MAAA,cACvB,IAAK,YAAoB,MAAA,gBACzB,IAAK,WAAY,MAAO,wBAdNF,EAc2CG,EAAEH,QAb1C,iBAAZA,EAA6B,mBAAmBI,KAAKC,UAAUL,EAAQM,QAAQC,UACnF,CAAEC,UAAW,YAAaC,UAAW,YAAaC,QAAS,UAAWC,cAAe,gBAAiBX,QAY9BG,EAAEF,UAC/E,IAAK,eAAuB,MAAA,4BAA4BE,EAAEF,UAC1D,IAAK,kBAA0B,MAAA,oBAAoBE,EAAEF,UACrD,IAAK,cAAe,MAAO,UAAUE,EAAES,kBAAkBT,EAAEF,UAC3D,IAAK,eAAuB,MAAA,UAAUE,EAAES,0CAA0CT,EAAEU,oBAAoBV,EAAEF,UAC1G,IAAK,aAAc,MAAO,cAdVa,EAcmCX,EAAEW,MAbhD,CAAEC,iBAAkB,kBAAmBC,iBAAkB,iBAAkBC,iBAAkB,mBAAoBH,cAa/CX,EAAEF,UACzE,IAAK,qBAA6B,MAAA,uBAAuBE,EAAEF,UAC3D,IAAK,WAAmB,MAAA,aAAaE,EAAEF,UAhB3C,IAAoBa,EALEd,CAuBtB,CA8EO,MAAMkB,UAAkB1B,MAG7B,WAAAC,CAAY0B,GACJxB,MA3BV,SAA0ByB,GACxB,OAAQA,EAAElB,MACR,IAAK,SAAiB,MAAA,iBAAiBkB,EAAEC,SAASD,EAAEE,UAAUF,EAAEG,SAChE,IAAK,QAAgB,MAAA,gBAAg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I,EAAE+H,SAAW,IAAY,MAAA,2BAClE,CAEF"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./content.cjs"),t=(e,t,i={})=>({protocol:"buckyos.app-frame",version:1,type:e,payload:t,...i}),i=e=>{if(!e||"object"!=typeof e)return!1;const t=e;return"buckyos.app-frame"===t.protocol&&1===t.version&&"string"==typeof t.type&&!!t.payload&&"object"==typeof t.payload};const s="buckyos.preview-embed",n=(e,t)=>({protocol:s,version:1,type:e,payload:t}),o=e=>{const t=e;return!!t&&t.protocol===s&&1===t.version&&"string"==typeof t.type&&!!t.payload&&"object"==typeof t.payload},r="/embed/preview";exports.AppFrameClient=class{constructor(e){if(this.options=e,this.listener=e=>{this.receive(e)},this.origin=new URL(e.shellOrigin).origin,this.nonce=new URLSearchParams(window.location.hash.slice(1)).get("bfp"),window.addEventListener("message",this.listener),window.parent!==window&&this.nonce){const i=()=>window.parent.postMessage(t("frame.hello",{nonce:this.nonce,appCapabilities:[...e.onOpen?["open"]:[],...e.onBeforeClose?["beforeClose"]:[],...e.onBack?["back"]:[]]}),this.origin);i(),this.helloTimer=setInterval(i,250),this.helloDeadline=setTimeout((()=>clearInterval(this.helloTimer)),1500)}}async receive(s){var n,o,r,a,l,p,c,d,h,u,f,w,y,m;if(s.source!==window.parent||s.origin!==this.origin||!i(s.data))return;const g=s.data,v=g.payload;if("frame.init"===g.type){if(!this.nonce||v.nonce!==this.nonce||"string"!=typeof v.locale||!v.theme||"string"!=typeof v.windowId||v.launch&&!e.isOpenRequest(v.launch))return;return clearInterval(this.helloTimer),clearTimeout(this.helloDeadline),this.init=v,this.title=void 0,this.focused=void 0,void(null==(o=(n=this.options).onInit)||o.call(n,this.init))}if(!this.init)return;const b=e=>window.parent.postMessage(t(g.type+"Result",e,{replyTo:g.id}),this.origin);try{"frame.open"===g.type&&e.isOpenRequest(v.request)&&b(await(null==(a=(r=this.options).onOpen)?void 0:a.call(r,v.request))??{accepted:!1}),"frame.beforeClose"===g.type&&b({decision:await(null==(p=(l=this.options).onBeforeClose)?void 0:p.call(l,v.reason))??"allow"}),"frame.back"===g.type&&b({handled:await(null==(d=(c=this.options).onBack)?void 0:d.call(c))??!1}),"frame.themeChanged"!==g.type||"dark"!==v.mode&&"light"!==v.mode||null==(u=(h=this.options).onTheme)||u.call(h,v),"frame.localeChanged"===g.type&&"string"==typeof v.locale&&(null==(w=(f=this.options).onLocale)||w.call(f,v.locale)),"frame.focusChanged"===g.type&&this.focused!==(!0===v.focused)&&(this.focused=!0===v.focused,null==(m=(y=this.options).onFocus)||m.call(y,this.focused))}catch{"frame.open"===g.type&&b({accepted:!1,fallback:"preview"}),"frame.beforeClose"===g.type&&b({decision:"deny"})}}send(e,i){this.init&&window.parent.postMessage(t(e,i),this.origin)}setTitle(e,t=!1){const i=JSON.stringify([e,t]);this.init&&i!==this.title&&(this.title=i,this.send("window.setTitle",{title:e,dirty:t}))}requestClose(){this.send("window.requestClose",{})}openContent(t,i="default",s={}){const n=s.hints??{};return this.init?(this.send("content.open",{request:t,target:i,newWindow:!0===s.newWindow,hints:n}),!0):!!this.options.systemOrigin&&(window.open(e.systemOpenUrl(this.options.systemOrigin,{request:t,target:i,hints:n,from:this.options.appId}),"_blank","noopener"),!0)}dispose(){clearInterval(this.helloTimer),clearTimeout(this.helloDeadline),window.removeEventListener("message",this.listener)}},exports.AppFrameHost=class{constructor(e){this.options=e,this.ready=!1,this.capabilities=[],this.pending=new Map,this.listener=e=>this.receive(e),this.opens=[],window.addEventListener("message",this.listener)}receive(t){var s,n,o,r,a,l,p,c;if(t.source!==this.options.target()||t.origin!==this.options.origin||!i(t.data))return;const d=t.data,h=d.payload;if("frame.hello"===d.type){if(h.nonce!==this.options.init.nonce||!Array.isArray(h.appCapabilities))return;return this.ready=!0,this.capabilities=h.appCapabilities.filter((e=>"string"==typeof e)),this.send("frame.init",this.options.init),void 0!==this.focused&&this.send("frame.focusChanged",{focused:this.focused}),void(null==(n=(s=this.options).onReady)||n.call(s))}if(this.ready)if(d.replyTo){const e=this.pending.get(d.replyTo);e&&d.type===e.type+"Result"&&(clearTimeout(e.timer),this.pending.delete(d.replyTo),e.resolve(d.payload))}else if("window.setTitle"===d.type&&"string"==typeof h.title&&(null==(r=(o=this.options).onTitle)||r.call(o,h.title.slice(0,256),!0===h.dirty)),"window.requestClose"===d.type&&(null==(l=(a=this.options).onRequestClose)||l.call(a)),"content.open"===d.type&&("default"===h.target||"preview"===h.target||"chooser"===h.target)){const t={...h.request,requestId:crypto.randomUUID()};if(!e.isOpenRequest(t))return;if(this.opens=this.opens.filter((e=>e>Date.now()-1e4)),this.opens.length>=5)return;this.opens.push(Date.now()),null==(c=(p=this.options).onContentOpen)||c.call(p,t,h.target,{newWindow:!0===h.newWindow,hints:e.readContentHints(h.hints)})}}update(e){this.options.init={...this.options.init,...e}}setFocused(e){this.focused!==e&&(this.focused=e,this.send("frame.focusChanged",{focused:e}))}send(e,i){var s;this.ready&&(null==(s=this.options.target())||s.postMessage(t(e,i),this.options.origin))}request(e,i,s=3e3){if(!this.ready)return Promise.reject(new Error("App frame is not ready"));const n=crypto.randomUUID();return new Promise(((o,r)=>{var a;const l=setTimeout((()=>{this.pending.delete(n),r(new Error("App frame timed out"))}),s);this.pending.set(n,{resolve:o,reject:r,timer:l,type:e}),null==(a=this.options.target())||a.postMessage(t(e,i,{id:n}),this.options.origin)}))}async open(e){return this.capabilities.includes("open")?await this.request("frame.open",{request:e}):{accepted:!1}}async beforeClose(e="user"){if(!this.ready||!this.capabilities.includes("beforeClose"))return"allow";const t=await this.request("frame.beforeClose",{reason:e});return"allow"===t.decision||"pending"===t.decision?t.decision:"deny"}async back(){return!!this.capabilities.includes("back")&&!0===(await this.request("frame.back",{})).handled}dispose(){window.removeEventListener("message",this.listener),this.pending.forEach((e=>{clearTimeout(e.timer),e.reject(new Error("App frame disposed"))})),this.pending.clear(),this.ready=!1}},exports.PREVIEW_EMBED_PATH=r,exports.PreviewEmbed=class{constructor(e){this.options=e,this.nonce=crypto.randomUUID(),this.listener=e=>this.receive(e),this.origin=new URL(e.systemOrigin).origin,this.init=e.init,this.url=`${this.origin}${r}#bpe=${this.nonce}&po=${encodeURIComponent(window.location.origin)}`,window.addEventListener("message",this.listener)}post(e,t){var i,s;null==(s=null==(i=this.options.frame())?void 0:i.contentWindow)||s.postMessage(n(e,t),this.origin)}receive(t){var i,s,n,r,a,l,p;if(t.origin!==this.origin||t.source!==(null==(i=this.options.frame())?void 0:i.contentWindow)||!o(t.data))return;const{type:c,payload:d}=t.data;if("embed.hello"!==c){if("embed.state"===c&&("loading"===d.status||"ready"===d.status||"error"===d.status)){const e=d.error;null==(n=(s=this.options).onState)||n.call(s,{status:d.status,error:e&&"string"==typeof e.kind&&"string"==typeof e.code?{kind:e.kind,code:e.code}:void 0,title:"string"==typeof d.title?d.title.slice(0,256):void 0,mediaType:"string"==typeof d.mediaType?d.mediaType.slice(0,128):void 0})}if("embed.openWith"===c){const t=d.request;t&&e.isTransferableRef(t.source)&&(void 0===t.session||e.isTransferableSession(t.session))&&(null==(a=(r=this.options).onOpenWith)||a.call(r,{request:{source:t.source,session:t.session},hints:e.readContentHints(d.hints)}))}"embed.exit"===c&&(null==(p=(l=this.options).onExit)||p.call(l))}else d.nonce===this.nonce&&this.post("embed.init",{...this.init,nonce:this.nonce})}update(e){this.init={...this.init,...e},this.post("embed.update",e)}dispose(){window.removeEventListener("message",this.listener)}},exports.PreviewEmbedHost=class{constructor(e){this.options=e,this.ready=!1,this.listener=e=>this.receive(e);const t=new URLSearchParams(window.location.hash.slice(1));this.nonce=t.get("bpe");let i=null;try{i=new URL(t.get("po")??"").origin}catch{}if(this.parentOrigin=window.parent!==window&&this.nonce&&i&&e.accept(i)?i:null,!this.parentOrigin)return;window.addEventListener("message",this.listener);const s=()=>window.parent.postMessage(n("embed.hello",{nonce:this.nonce}),this.parentOrigin);s(),this.hello=setInterval((()=>{this.ready||s()}),250)}receive(t){var i,s;if(t.source!==window.parent||t.origin!==this.parentOrigin||!o(t.data))return;const{type:n,payload:r}=t.data;if("embed.init"===n){if(r.nonce!==this.nonce||(a=r.source,!(e.isTransferableRef(a)||a&&"object"==typeof a&&"blob"===a.kind&&"undefined"!=typeof Blob&&a.blob instanceof Blob&&"string"==typeof a.name))||void 0!==r.session&&!e.isTransferableSession(r.session)||"string"!=typeof r.locale)return;return this.ready=!0,clearInterval(this.hello),void this.options.onInit({nonce:String(r.nonce),source:r.source,session:r.session,theme:"dark"===r.theme?"dark":"light",locale:r.locale})}var a;if("embed.update"===n&&this.ready){const e={};"dark"!==r.theme&&"light"!==r.theme||(e.theme=r.theme),"string"==typeof r.locale&&(e.locale=r.locale),null==(s=(i=this.options).onUpdate)||s.call(i,e)}}post(e,t){this.ready&&this.parentOrigin&&window.parent.postMessage(n(e,t),this.parentOrigin)}state(e){this.post("embed.state",e)}openWith(e){this.post("embed.openWith",e)}exit(){this.post("embed.exit",{})}dispose(){clearInterval(this.hello),window.removeEventListener("message",this.listener)}},exports.embedderOrigin=function(e){var t;if(window.parent===window)return null;const i=[null==(t=window.location.ancestorOrigins)?void 0:t[0],document.referrer];for(const s of i)if(s)try{const t=new URL(s).origin;if(e(t))return t}catch{}return null},exports.originInZone=(e,t)=>{try{const i=new URL(e);return i.protocol===window.location.protocol&&(i.hostname===t||i.hostname.endsWith(`.${t}`))}catch{return!1}};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./content.cjs");require("./content_mime-dc80d960.js");const t=(e,t,i={})=>({protocol:"buckyos.app-frame",version:1,type:e,payload:t,...i}),i=e=>{if(!e||"object"!=typeof e)return!1;const t=e;return"buckyos.app-frame"===t.protocol&&1===t.version&&"string"==typeof t.type&&!!t.payload&&"object"==typeof t.payload};const s="buckyos.preview-embed",n=(e,t)=>({protocol:s,version:1,type:e,payload:t}),o=e=>{const t=e;return!!t&&t.protocol===s&&1===t.version&&"string"==typeof t.type&&!!t.payload&&"object"==typeof t.payload},r="/embed/preview";exports.AppFrameClient=class{constructor(e){if(this.options=e,this.listener=e=>{this.receive(e)},this.origin=new URL(e.shellOrigin).origin,this.nonce=new URLSearchParams(window.location.hash.slice(1)).get("bfp"),window.addEventListener("message",this.listener),window.parent!==window&&this.nonce){const i=()=>window.parent.postMessage(t("frame.hello",{nonce:this.nonce,appCapabilities:[...e.onOpen?["open"]:[],...e.onBeforeClose?["beforeClose"]:[],...e.onBack?["back"]:[]]}),this.origin);i(),this.helloTimer=setInterval(i,250),this.helloDeadline=setTimeout((()=>clearInterval(this.helloTimer)),1500)}}async receive(s){var n,o,r,a,l,p,c,d,h,u,f,m,w,y;if(s.source!==window.parent||s.origin!==this.origin||!i(s.data))return;const g=s.data,v=g.payload;if("frame.init"===g.type){if(!this.nonce||v.nonce!==this.nonce||"string"!=typeof v.locale||!v.theme||"string"!=typeof v.windowId||v.launch&&!e.isOpenRequest(v.launch))return;return clearInterval(this.helloTimer),clearTimeout(this.helloDeadline),this.init=v,this.title=void 0,this.focused=void 0,void(null==(o=(n=this.options).onInit)||o.call(n,this.init))}if(!this.init)return;const b=e=>window.parent.postMessage(t(g.type+"Result",e,{replyTo:g.id}),this.origin);try{"frame.open"===g.type&&e.isOpenRequest(v.request)&&b(await(null==(a=(r=this.options).onOpen)?void 0:a.call(r,v.request))??{accepted:!1}),"frame.beforeClose"===g.type&&b({decision:await(null==(p=(l=this.options).onBeforeClose)?void 0:p.call(l,v.reason))??"allow"}),"frame.back"===g.type&&b({handled:await(null==(d=(c=this.options).onBack)?void 0:d.call(c))??!1}),"frame.themeChanged"!==g.type||"dark"!==v.mode&&"light"!==v.mode||null==(u=(h=this.options).onTheme)||u.call(h,v),"frame.localeChanged"===g.type&&"string"==typeof v.locale&&(null==(m=(f=this.options).onLocale)||m.call(f,v.locale)),"frame.focusChanged"===g.type&&this.focused!==(!0===v.focused)&&(this.focused=!0===v.focused,null==(y=(w=this.options).onFocus)||y.call(w,this.focused))}catch{"frame.open"===g.type&&b({accepted:!1,fallback:"preview"}),"frame.beforeClose"===g.type&&b({decision:"deny"})}}send(e,i){this.init&&window.parent.postMessage(t(e,i),this.origin)}setTitle(e,t=!1){const i=JSON.stringify([e,t]);this.init&&i!==this.title&&(this.title=i,this.send("window.setTitle",{title:e,dirty:t}))}requestClose(){this.send("window.requestClose",{})}openContent(t,i="default",s={}){const n=s.hints??{};return this.init?(this.send("content.open",{request:t,target:i,newWindow:!0===s.newWindow,hints:n}),!0):!!this.options.systemOrigin&&(window.open(e.systemOpenUrl(this.options.systemOrigin,{request:t,target:i,hints:n,from:this.options.appId}),"_blank","noopener"),!0)}dispose(){clearInterval(this.helloTimer),clearTimeout(this.helloDeadline),window.removeEventListener("message",this.listener)}},exports.AppFrameHost=class{constructor(e){this.options=e,this.ready=!1,this.capabilities=[],this.pending=new Map,this.listener=e=>this.receive(e),this.opens=[],window.addEventListener("message",this.listener)}receive(t){var s,n,o,r,a,l,p,c;if(t.source!==this.options.target()||t.origin!==this.options.origin||!i(t.data))return;const d=t.data,h=d.payload;if("frame.hello"===d.type){if(h.nonce!==this.options.init.nonce||!Array.isArray(h.appCapabilities))return;return this.ready=!0,this.capabilities=h.appCapabilities.filter((e=>"string"==typeof e)),this.send("frame.init",this.options.init),void 0!==this.focused&&this.send("frame.focusChanged",{focused:this.focused}),void(null==(n=(s=this.options).onReady)||n.call(s))}if(this.ready)if(d.replyTo){const e=this.pending.get(d.replyTo);e&&d.type===e.type+"Result"&&(clearTimeout(e.timer),this.pending.delete(d.replyTo),e.resolve(d.payload))}else if("window.setTitle"===d.type&&"string"==typeof h.title&&(null==(r=(o=this.options).onTitle)||r.call(o,h.title.slice(0,256),!0===h.dirty)),"window.requestClose"===d.type&&(null==(l=(a=this.options).onRequestClose)||l.call(a)),"content.open"===d.type&&("default"===h.target||"preview"===h.target||"chooser"===h.target)){const t={...h.request,requestId:crypto.randomUUID()};if(!e.isOpenRequest(t))return;if(this.opens=this.opens.filter((e=>e>Date.now()-1e4)),this.opens.length>=5)return;this.opens.push(Date.now()),null==(c=(p=this.options).onContentOpen)||c.call(p,t,h.target,{newWindow:!0===h.newWindow,hints:e.readContentHints(h.hints)})}}update(e){this.options.init={...this.options.init,...e}}setFocused(e){this.focused!==e&&(this.focused=e,this.send("frame.focusChanged",{focused:e}))}send(e,i){var s;this.ready&&(null==(s=this.options.target())||s.postMessage(t(e,i),this.options.origin))}request(e,i,s=3e3){if(!this.ready)return Promise.reject(new Error("App frame is not ready"));const n=crypto.randomUUID();return new Promise(((o,r)=>{var a;const l=setTimeout((()=>{this.pending.delete(n),r(new Error("App frame timed out"))}),s);this.pending.set(n,{resolve:o,reject:r,timer:l,type:e}),null==(a=this.options.target())||a.postMessage(t(e,i,{id:n}),this.options.origin)}))}async open(e){return this.capabilities.includes("open")?await this.request("frame.open",{request:e}):{accepted:!1}}async beforeClose(e="user"){if(!this.ready||!this.capabilities.includes("beforeClose"))return"allow";const t=await this.request("frame.beforeClose",{reason:e});return"allow"===t.decision||"pending"===t.decision?t.decision:"deny"}async back(){return!!this.capabilities.includes("back")&&!0===(await this.request("frame.back",{})).handled}dispose(){window.removeEventListener("message",this.listener),this.pending.forEach((e=>{clearTimeout(e.timer),e.reject(new Error("App frame disposed"))})),this.pending.clear(),this.ready=!1}},exports.PREVIEW_EMBED_PATH=r,exports.PreviewEmbed=class{constructor(e){this.options=e,this.nonce=crypto.randomUUID(),this.listener=e=>this.receive(e),this.origin=new URL(e.systemOrigin).origin,this.init=e.init,this.url=`${this.origin}${r}#bpe=${this.nonce}&po=${encodeURIComponent(window.location.origin)}`,window.addEventListener("message",this.listener)}post(e,t){var i,s;null==(s=null==(i=this.options.frame())?void 0:i.contentWindow)||s.postMessage(n(e,t),this.origin)}receive(t){var i,s,n,r,a,l,p;if(t.origin!==this.origin||t.source!==(null==(i=this.options.frame())?void 0:i.contentWindow)||!o(t.data))return;const{type:c,payload:d}=t.data;if("embed.hello"!==c){if("embed.state"===c&&("loading"===d.status||"ready"===d.status||"error"===d.status)){const e=d.error;null==(n=(s=this.options).onState)||n.call(s,{status:d.status,error:e&&"string"==typeof e.kind&&"string"==typeof e.code?{kind:e.kind,code:e.code}:void 0,title:"string"==typeof d.title?d.title.slice(0,256):void 0,mediaType:"string"==typeof d.mediaType?d.mediaType.slice(0,128):void 0})}if("embed.openWith"===c){const t=d.request;t&&e.isTransferableRef(t.source)&&(void 0===t.session||e.isTransferableSession(t.session))&&(null==(a=(r=this.options).onOpenWith)||a.call(r,{request:{source:t.source,session:t.session},hints:e.readContentHints(d.hints)}))}"embed.exit"===c&&(null==(p=(l=this.options).onExit)||p.call(l))}else d.nonce===this.nonce&&this.post("embed.init",{...this.init,nonce:this.nonce})}update(e){this.init={...this.init,...e},this.post("embed.update",e)}dispose(){window.removeEventListener("message",this.listener)}},exports.PreviewEmbedHost=class{constructor(e){this.options=e,this.ready=!1,this.listener=e=>this.receive(e);const t=new URLSearchParams(window.location.hash.slice(1));this.nonce=t.get("bpe");let i=null;try{i=new URL(t.get("po")??"").origin}catch{}if(this.parentOrigin=window.parent!==window&&this.nonce&&i&&e.accept(i)?i:null,!this.parentOrigin)return;window.addEventListener("message",this.listener);const s=()=>window.parent.postMessage(n("embed.hello",{nonce:this.nonce}),this.parentOrigin);s(),this.hello=setInterval((()=>{this.ready||s()}),250)}receive(t){var i,s;if(t.source!==window.parent||t.origin!==this.parentOrigin||!o(t.data))return;const{type:n,payload:r}=t.data;if("embed.init"===n){if(r.nonce!==this.nonce||(a=r.source,!(e.isTransferableRef(a)||a&&"object"==typeof a&&"blob"===a.kind&&"undefined"!=typeof Blob&&a.blob instanceof Blob&&"string"==typeof a.name))||void 0!==r.session&&!e.isTransferableSession(r.session)||"string"!=typeof r.locale)return;return this.ready=!0,clearInterval(this.hello),void this.options.onInit({nonce:String(r.nonce),source:r.source,session:r.session,theme:"dark"===r.theme?"dark":"light",locale:r.locale})}var a;if("embed.update"===n&&this.ready){const e={};"dark"!==r.theme&&"light"!==r.theme||(e.theme=r.theme),"string"==typeof r.locale&&(e.locale=r.locale),null==(s=(i=this.options).onUpdate)||s.call(i,e)}}post(e,t){this.ready&&this.parentOrigin&&window.parent.postMessage(n(e,t),this.parentOrigin)}state(e){this.post("embed.state",e)}openWith(e){this.post("embed.openWith",e)}exit(){this.post("embed.exit",{})}dispose(){clearInterval(this.hello),window.removeEventListener("message",this.listener)}},exports.embedderOrigin=function(e){var t;if(window.parent===window)return null;const i=[null==(t=window.location.ancestorOrigins)?void 0:t[0],document.referrer];for(const s of i)if(s)try{const t=new URL(s).origin;if(e(t))return t}catch{}return null},exports.originInZone=(e,t)=>{try{const i=new URL(e);return i.protocol===window.location.protocol&&(i.hostname===t||i.hostname.endsWith(`.${t}`))}catch{return!1}};
2
2
  //# sourceMappingURL=app-frame.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"app-frame.cjs","sources":["../src/app-frame.ts"],"sourcesContent":["import { isOpenRequest, isTransferableRef, isTransferableSession, readContentHints, systemOpenUrl, type ContentHints, type ContentOpenTarget, type OpenRequest, type TransferableContentRef, type TransferableSessionContext } from './content'\nexport interface AppFrameMessage<T extends string = string, P = unknown> {\n protocol: 'buckyos.app-frame'; version: 1; type: T; id?: string; replyTo?: string; payload: P\n}\nexport interface FrameInit {\n nonce: string\n windowId: string\n formFactor: 'desktop' | 'mobile'\n theme: { mode: 'light' | 'dark'; accent?: string }\n locale: string\n launch?: OpenRequest\n shellCapabilities: string[]\n}\nexport type CloseDecision = 'allow' | 'deny' | 'pending'\nconst envelope = (type: string, payload: unknown, extra: { id?: string; replyTo?: string } = {}): AppFrameMessage =>\n ({ protocol: 'buckyos.app-frame', version: 1, type, payload, ...extra })\nconst isMessage = (value: unknown): value is AppFrameMessage => {\n if (!value || typeof value !== 'object') return false\n const v = value as AppFrameMessage\n return v.protocol === 'buckyos.app-frame' && v.version === 1 && typeof v.type === 'string' && !!v.payload && typeof v.payload === 'object'\n}\nexport class AppFrameHost {\n ready = false\n capabilities: string[] = []\n private pending = new Map<string, { resolve: (v: unknown) => void; reject: (e: Error) => void; timer: ReturnType<typeof setTimeout>; type: string }>()\n private listener = (event: MessageEvent) => this.receive(event)\n private opens: number[] = []\n constructor(private options: {\n target: () => Window | null; origin: string; init: FrameInit\n onReady?: () => void\n onTitle?: (title: string, dirty: boolean) => void\n onRequestClose?: () => void\n onContentOpen?: (request: OpenRequest, target: ContentOpenTarget, options: { newWindow: boolean; hints: ContentHints }) => void\n }) { window.addEventListener('message', this.listener) }\n private focused?: boolean\n private receive(event: MessageEvent): void {\n if (event.source !== this.options.target() || event.origin !== this.options.origin || !isMessage(event.data)) return\n const m = event.data\n const p = m.payload as Record<string, unknown>\n if (m.type === 'frame.hello') {\n if (p.nonce !== this.options.init.nonce || !Array.isArray(p.appCapabilities)) return\n this.ready = true\n this.capabilities = p.appCapabilities.filter((c): c is string => typeof c === 'string')\n this.send('frame.init', this.options.init)\n if (this.focused !== undefined) this.send('frame.focusChanged', { focused: this.focused })\n this.options.onReady?.()\n return\n }\n if (!this.ready) return\n if (m.replyTo) {\n const pending = this.pending.get(m.replyTo)\n if (pending && m.type === pending.type + 'Result') {\n clearTimeout(pending.timer); this.pending.delete(m.replyTo); pending.resolve(m.payload)\n }\n return\n }\n if (m.type === 'window.setTitle' && typeof p.title === 'string') this.options.onTitle?.(p.title.slice(0, 256), p.dirty === true)\n if (m.type === 'window.requestClose') this.options.onRequestClose?.()\n if (m.type === 'content.open' && (p.target === 'default' || p.target === 'preview' || p.target === 'chooser')) {\n const request = { ...(p.request as object), requestId: crypto.randomUUID() }\n if (!isOpenRequest(request)) return\n this.opens = this.opens.filter(t => t > Date.now() - 10000)\n if (this.opens.length >= 5) return\n this.opens.push(Date.now())\n this.options.onContentOpen?.(request, p.target, { newWindow: p.newWindow === true, hints: readContentHints(p.hints) })\n }\n }\n update(init: Partial<FrameInit>): void { this.options.init = { ...this.options.init, ...init } }\n /** Reports whether the App's window is the focused one; only a change is sent. */\n setFocused(focused: boolean): void {\n if (this.focused === focused) return\n this.focused = focused\n this.send('frame.focusChanged', { focused })\n }\n send(type: string, payload: unknown): void {\n if (this.ready) this.options.target()?.postMessage(envelope(type, payload), this.options.origin)\n }\n request(type: string, payload: unknown, timeout = 3000): Promise<unknown> {\n if (!this.ready) return Promise.reject(new Error('App frame is not ready'))\n const id = crypto.randomUUID()\n return new Promise((resolve, reject) => {\n const timer = setTimeout(() => { this.pending.delete(id); reject(new Error('App frame timed out')) }, timeout)\n this.pending.set(id, { resolve, reject, timer, type })\n this.options.target()?.postMessage(envelope(type, payload, { id }), this.options.origin)\n })\n }\n async open(request: OpenRequest): Promise<{ accepted: boolean; fallback?: 'preview' }> {\n if (!this.capabilities.includes('open')) return { accepted: false }\n return await this.request('frame.open', { request }) as { accepted: boolean; fallback?: 'preview' }\n }\n async beforeClose(reason: 'user' | 'logout' | 'shell' = 'user'): Promise<CloseDecision> {\n if (!this.ready || !this.capabilities.includes('beforeClose')) return 'allow'\n const r = await this.request('frame.beforeClose', { reason }) as { decision?: CloseDecision }\n return r.decision === 'allow' || r.decision === 'pending' ? r.decision : 'deny'\n }\n async back(): Promise<boolean> {\n if (!this.capabilities.includes('back')) return false\n return (await this.request('frame.back', {}) as { handled?: boolean }).handled === true\n }\n dispose(): void {\n window.removeEventListener('message', this.listener)\n this.pending.forEach(p => { clearTimeout(p.timer); p.reject(new Error('App frame disposed')) })\n this.pending.clear(); this.ready = false\n }\n}\n/**\n * Origin of the window embedding this page, when `accept` admits it. `location.ancestorOrigins` names the real\n * parent even after the frame navigated through other pages (a sign-in round trip); the referrer is the fallback.\n */\nexport function embedderOrigin(accept: (origin: string) => boolean): string | null {\n if (window.parent === window) return null\n const candidates = [window.location.ancestorOrigins?.[0], document.referrer]\n for (const candidate of candidates) {\n if (!candidate) continue\n try {\n const origin = new URL(candidate).origin\n if (accept(origin)) return origin\n } catch {}\n }\n return null\n}\nexport const originInZone = (origin: string, zoneHost: string): boolean => {\n try {\n const url = new URL(origin)\n return url.protocol === window.location.protocol && (url.hostname === zoneHost || url.hostname.endsWith(`.${zoneHost}`))\n } catch { return false }\n}\nexport class AppFrameClient {\n init?: FrameInit\n private title?: string\n private focused?: boolean\n private helloTimer?: ReturnType<typeof setInterval>\n private helloDeadline?: ReturnType<typeof setTimeout>\n private readonly nonce: string | null\n private readonly origin: string\n private readonly listener = (event: MessageEvent) => { void this.receive(event) }\n constructor(private options: {\n shellOrigin: string\n /** The Zone's system entry (its root origin): where content is opened when this page is not embedded in the shell. */\n systemOrigin?: string\n /** This App's id, so the system does not offer the content back to it. */\n appId?: string\n onInit?: (init: FrameInit) => void\n onOpen?: (request: OpenRequest) => Promise<{ accepted: boolean; fallback?: 'preview' }> | { accepted: boolean; fallback?: 'preview' }\n onBeforeClose?: (reason: 'user' | 'logout' | 'shell') => Promise<CloseDecision> | CloseDecision\n onBack?: () => Promise<boolean> | boolean\n onTheme?: (theme: FrameInit['theme']) => void\n onLocale?: (locale: string) => void\n onFocus?: (focused: boolean) => void\n }) {\n this.origin = new URL(options.shellOrigin).origin\n this.nonce = new URLSearchParams(window.location.hash.slice(1)).get('bfp')\n window.addEventListener('message', this.listener)\n if (window.parent !== window && this.nonce) {\n const hello = () => window.parent.postMessage(envelope('frame.hello', { nonce: this.nonce, appCapabilities: [\n ...options.onOpen ? ['open'] : [], ...options.onBeforeClose ? ['beforeClose'] : [], ...options.onBack ? ['back'] : [],\n ] }), this.origin)\n hello()\n this.helloTimer = setInterval(hello, 250)\n this.helloDeadline = setTimeout(() => clearInterval(this.helloTimer), 1500)\n }\n }\n private async receive(event: MessageEvent): Promise<void> {\n if (event.source !== window.parent || event.origin !== this.origin || !isMessage(event.data)) return\n const m = event.data\n const p = m.payload as Record<string, unknown>\n if (m.type === 'frame.init') {\n if (!this.nonce || p.nonce !== this.nonce || typeof p.locale !== 'string' || !p.theme || typeof p.windowId !== 'string' || p.launch && !isOpenRequest(p.launch)) return\n clearInterval(this.helloTimer); clearTimeout(this.helloDeadline)\n this.init = p as unknown as FrameInit\n this.title = undefined; this.focused = undefined\n this.options.onInit?.(this.init)\n return\n }\n if (!this.init) return\n const reply = (payload: unknown) => window.parent.postMessage(envelope(m.type + 'Result', payload, { replyTo: m.id }), this.origin)\n try {\n if (m.type === 'frame.open' && isOpenRequest(p.request)) reply(await this.options.onOpen?.(p.request) ?? { accepted: false })\n if (m.type === 'frame.beforeClose') reply({ decision: await this.options.onBeforeClose?.(p.reason as 'user') ?? 'allow' })\n if (m.type === 'frame.back') reply({ handled: await this.options.onBack?.() ?? false })\n if (m.type === 'frame.themeChanged' && (p.mode === 'dark' || p.mode === 'light')) this.options.onTheme?.(p as FrameInit['theme'])\n if (m.type === 'frame.localeChanged' && typeof p.locale === 'string') this.options.onLocale?.(p.locale)\n if (m.type === 'frame.focusChanged' && this.focused !== (p.focused === true)) { this.focused = p.focused === true; this.options.onFocus?.(this.focused) }\n } catch {\n if (m.type === 'frame.open') reply({ accepted: false, fallback: 'preview' })\n if (m.type === 'frame.beforeClose') reply({ decision: 'deny' })\n }\n }\n send(type: string, payload: unknown): void {\n if (this.init) window.parent.postMessage(envelope(type, payload), this.origin)\n }\n setTitle(title: string, dirty = false): void {\n const key = JSON.stringify([title, dirty])\n if (!this.init || key === this.title) return\n this.title = key\n this.send('window.setTitle', { title, dirty })\n }\n requestClose(): void { this.send('window.requestClose', {}) }\n /**\n * Asks the system to open content: with its default app, in Preview, or by letting the user choose (`chooser`).\n * Embedded in the shell the request goes over the frame; in a standalone tab it opens the Zone's system entry\n * (`systemOrigin`) in a new tab. Returns false when neither is available.\n */\n openContent(request: Omit<OpenRequest, 'requestId'>, target: ContentOpenTarget = 'default', options: { newWindow?: boolean; hints?: ContentHints } = {}): boolean {\n const hints = options.hints ?? {}\n if (this.init) { this.send('content.open', { request, target, newWindow: options.newWindow === true, hints }); return true }\n if (!this.options.systemOrigin) return false\n window.open(systemOpenUrl(this.options.systemOrigin, { request, target, hints, from: this.options.appId }), '_blank', 'noopener')\n return true\n }\n dispose(): void { clearInterval(this.helloTimer); clearTimeout(this.helloDeadline); window.removeEventListener('message', this.listener) }\n}\n\n/**\n * Preview embed protocol (`buckyos.preview-embed` v1): an App shows the system Preview component inside its own UI.\n * The App frames `<systemOrigin>/embed/preview` (component only, no shell) and hands it a content reference; the\n * system page reads the content with its own Zone-root session, so no token crosses origins. Open With goes back\n * through the App to the shell (`AppFrameClient.openContent(…, 'chooser')`).\n */\nexport type PreviewEmbedSource = TransferableContentRef | { kind: 'blob'; blob: Blob; name: string }\nexport interface PreviewEmbedInit {\n nonce: string\n source: PreviewEmbedSource\n session?: TransferableSessionContext\n theme: 'light' | 'dark'\n locale: string\n}\nexport interface PreviewEmbedState {\n status: 'loading' | 'ready' | 'error'\n /** Preview error kind (`unsupported`, `not-found`, `permission-denied`, `timeout`, `error`, …) and code. */\n error?: { kind: string; code: string }\n title?: string\n mediaType?: string\n}\nexport interface PreviewEmbedOpenWith { request: Omit<OpenRequest, 'requestId'>; hints: ContentHints }\nconst PREVIEW_EMBED = 'buckyos.preview-embed'\nconst embedEnvelope = (type: string, payload: unknown) => ({ protocol: PREVIEW_EMBED, version: 1, type, payload })\nconst isEmbedMessage = (value: unknown): value is { type: string; payload: Record<string, unknown> } => {\n const v = value as { protocol?: unknown; version?: unknown; type?: unknown; payload?: unknown } | null\n return !!v && v.protocol === PREVIEW_EMBED && v.version === 1 && typeof v.type === 'string' && !!v.payload && typeof v.payload === 'object'\n}\nconst isEmbedSource = (value: unknown): value is PreviewEmbedSource =>\n isTransferableRef(value) || (!!value && typeof value === 'object' && (value as { kind?: unknown }).kind === 'blob' &&\n typeof Blob !== 'undefined' && (value as { blob?: unknown }).blob instanceof Blob && typeof (value as { name?: unknown }).name === 'string')\nexport const PREVIEW_EMBED_PATH = '/embed/preview'\n\n/** App side: owns the iframe that shows the system Preview. */\nexport class PreviewEmbed {\n readonly url: string\n private readonly nonce = crypto.randomUUID()\n private readonly origin: string\n private readonly listener = (event: MessageEvent) => this.receive(event)\n private init: Omit<PreviewEmbedInit, 'nonce'>\n constructor(private options: {\n systemOrigin: string\n frame: () => HTMLIFrameElement | null\n init: Omit<PreviewEmbedInit, 'nonce'>\n onState?: (state: PreviewEmbedState) => void\n onOpenWith?: (open: PreviewEmbedOpenWith) => void\n onExit?: () => void\n }) {\n this.origin = new URL(options.systemOrigin).origin\n this.init = options.init\n this.url = `${this.origin}${PREVIEW_EMBED_PATH}#bpe=${this.nonce}&po=${encodeURIComponent(window.location.origin)}`\n window.addEventListener('message', this.listener)\n }\n private post(type: string, payload: unknown): void {\n this.options.frame()?.contentWindow?.postMessage(embedEnvelope(type, payload), this.origin)\n }\n private receive(event: MessageEvent): void {\n if (event.origin !== this.origin || event.source !== this.options.frame()?.contentWindow || !isEmbedMessage(event.data)) return\n const { type, payload: p } = event.data\n if (type === 'embed.hello') { if (p.nonce === this.nonce) this.post('embed.init', { ...this.init, nonce: this.nonce }); return }\n if (type === 'embed.state' && (p.status === 'loading' || p.status === 'ready' || p.status === 'error')) {\n const error = p.error as { kind?: unknown; code?: unknown } | undefined\n this.options.onState?.({ status: p.status,\n error: error && typeof error.kind === 'string' && typeof error.code === 'string' ? { kind: error.kind, code: error.code } : undefined,\n title: typeof p.title === 'string' ? p.title.slice(0, 256) : undefined, mediaType: typeof p.mediaType === 'string' ? p.mediaType.slice(0, 128) : undefined })\n }\n if (type === 'embed.openWith') {\n const request = p.request as Omit<OpenRequest, 'requestId'> | undefined\n if (request && isTransferableRef(request.source) && (request.session === undefined || isTransferableSession(request.session))) {\n this.options.onOpenWith?.({ request: { source: request.source, session: request.session }, hints: readContentHints(p.hints) })\n }\n }\n if (type === 'embed.exit') this.options.onExit?.()\n }\n update(patch: Partial<Pick<PreviewEmbedInit, 'theme' | 'locale'>>): void {\n this.init = { ...this.init, ...patch }\n this.post('embed.update', patch)\n }\n dispose(): void { window.removeEventListener('message', this.listener) }\n}\n\n/** System side: the component-only page at `PREVIEW_EMBED_PATH`. Accepts one embedding App whose origin `accept` admits. */\nexport class PreviewEmbedHost {\n readonly parentOrigin: string | null\n private readonly nonce: string | null\n private ready = false\n private readonly hello?: ReturnType<typeof setInterval>\n private readonly listener = (event: MessageEvent) => this.receive(event)\n constructor(private options: {\n accept: (origin: string) => boolean\n onInit: (init: PreviewEmbedInit) => void\n onUpdate?: (patch: Partial<Pick<PreviewEmbedInit, 'theme' | 'locale'>>) => void\n }) {\n const params = new URLSearchParams(window.location.hash.slice(1))\n this.nonce = params.get('bpe')\n let parentOrigin: string | null = null\n try { parentOrigin = new URL(params.get('po') ?? '').origin } catch {}\n this.parentOrigin = window.parent !== window && this.nonce && parentOrigin && options.accept(parentOrigin) ? parentOrigin : null\n if (!this.parentOrigin) return\n window.addEventListener('message', this.listener)\n const hello = () => window.parent.postMessage(embedEnvelope('embed.hello', { nonce: this.nonce }), this.parentOrigin!)\n hello()\n this.hello = setInterval(() => { if (!this.ready) hello() }, 250)\n }\n private receive(event: MessageEvent): void {\n if (event.source !== window.parent || event.origin !== this.parentOrigin || !isEmbedMessage(event.data)) return\n const { type, payload: p } = event.data\n if (type === 'embed.init') {\n if (p.nonce !== this.nonce || !isEmbedSource(p.source) || (p.session !== undefined && !isTransferableSession(p.session)) || typeof p.locale !== 'string') return\n this.ready = true; clearInterval(this.hello)\n this.options.onInit({ nonce: String(p.nonce), source: p.source, session: p.session as TransferableSessionContext | undefined, theme: p.theme === 'dark' ? 'dark' : 'light', locale: p.locale })\n return\n }\n if (type === 'embed.update' && this.ready) {\n const patch: Partial<Pick<PreviewEmbedInit, 'theme' | 'locale'>> = {}\n if (p.theme === 'dark' || p.theme === 'light') patch.theme = p.theme\n if (typeof p.locale === 'string') patch.locale = p.locale\n this.options.onUpdate?.(patch)\n }\n }\n private post(type: string, payload: unknown): void {\n if (this.ready && this.parentOrigin) window.parent.postMessage(embedEnvelope(type, payload), this.parentOrigin)\n }\n state(state: PreviewEmbedState): void { this.post('embed.state', state) }\n openWith(open: PreviewEmbedOpenWith): void { this.post('embed.openWith', open) }\n exit(): void { this.post('embed.exit', {}) }\n dispose(): void { clearInterval(this.hello); window.removeEventListener('message', this.listener) }\n}\n"],"names":["envelope","type","payload","extra","protocol","version","isMessage","value","v","PREVIEW_EMBED","embedEnvelope","isEmbedMessage","PREVIEW_EMBED_PATH","constructor","options","this","listener","event","receive","origin","URL","shellOrigin","nonce","URLSearchParams","window","location","hash","slice","get","addEventListener","parent","hello","postMessage","appCapabilities","onOpen","onBeforeClose","onBack","helloTimer","setInterval","helloDeadline","setTimeout","clearInterval","source","data","m","p","locale","theme","windowId","launch","isOpenRequest","clearTimeout","init","title","focused","_b","_a","onInit","call","reply","replyTo","id","request","_d","_c","accepted","decision","_f","_e","reason","handled","_h","_g","mode","_j","_i","onTheme","_l","_k","onLocale","_n","_m","onFocus","fallback","send","setTitle","dirty","key","JSON","stringify","requestClose","openContent","target","hints","newWindow","systemOrigin","open","systemOpenUrl","from","appId","dispose","removeEventListener","ready","capabilities","pending","Map","opens","Array","isArray","filter","c","onReady","timer","delete","resolve","onTitle","onRequestClose","requestId","crypto","randomUUID","t","Date","now","length","push","onContentOpen","readContentHints","update","setFocused","timeout","Promise","reject","Error","set","includes","beforeClose","r","back","forEach","clear","url","encodeURIComponent","post","frame","contentWindow","status","error","onState","kind","code","mediaType","isTransferableRef","session","isTransferableSession","onOpenWith","onExit","patch","params","parentOrigin","accept","Blob","blob","name","String","onUpdate","state","openWith","exit","candidates","ancestorOrigins","document","referrer","candidate","zoneHost","hostname","endsWith"],"mappings":"iHAcMA,EAAW,CAACC,EAAcC,EAAkBC,EAA2C,CAAA,KAAA,CACxFC,SAAU,oBAAqBC,QAAS,EAAGJ,OAAMC,aAAYC,IAC5DG,EAAaC,IACb,IAACA,GAA0B,iBAAVA,EAA2B,OAAA,EAChD,MAAMC,EAAID,EACV,MAAsB,sBAAfC,EAAEJ,UAAkD,IAAdI,EAAEH,SAAmC,iBAAXG,EAAEP,QAAuBO,EAAEN,SAAgC,iBAAdM,EAAEN,OAAY,EAwNpI,MAAMO,EAAgB,wBAChBC,EAAgB,CAACT,EAAcC,KAAsB,CAAEE,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,SAAWN,OAAe,OAAA,KAC/B,MAAAgJ,EAAa,CAAC,OAAAhH,EAAOhC,OAAAC,SAASgJ,sBAAkB,EAAAjH,EAAA,GAAIkH,SAASC,UACnE,IAAA,MAAWC,KAAaJ,EACtB,GAAKI,EACD,IACF,MAAMzJ,EAAS,IAAIC,IAAIwJ,GAAWzJ,OAClC,GAAI4I,EAAO5I,GAAgB,OAAAA,CAAA,CACrB,MAAC,CAEJ,OAAA,IACT,uBAC4B,CAACA,EAAgB0J,KACvC,IACI,MAAAjC,EAAM,IAAIxH,IAAID,GACpB,OAAOyH,EAAIxI,WAAaoB,OAAOC,SAASrB,WAAawI,EAAIkC,WAAaD,GAAYjC,EAAIkC,SAASC,SAAS,IAAIF,KAAU,CAChH,MAAS,OAAA,CAAM"}
1
+ {"version":3,"file":"app-frame.cjs","sources":["../src/app-frame.ts"],"sourcesContent":["import { isOpenRequest, isTransferableRef, isTransferableSession, readContentHints, systemOpenUrl, type ContentHints, type ContentOpenTarget, type OpenRequest, type TransferableContentRef, type TransferableSessionContext } from './content'\nexport interface AppFrameMessage<T extends string = string, P = unknown> {\n protocol: 'buckyos.app-frame'; version: 1; type: T; id?: string; replyTo?: string; payload: P\n}\nexport interface FrameInit {\n nonce: string\n windowId: string\n formFactor: 'desktop' | 'mobile'\n theme: { mode: 'light' | 'dark'; accent?: string }\n locale: string\n launch?: OpenRequest\n shellCapabilities: string[]\n}\nexport type CloseDecision = 'allow' | 'deny' | 'pending'\nconst envelope = (type: string, payload: unknown, extra: { id?: string; replyTo?: string } = {}): AppFrameMessage =>\n ({ protocol: 'buckyos.app-frame', version: 1, type, payload, ...extra })\nconst isMessage = (value: unknown): value is AppFrameMessage => {\n if (!value || typeof value !== 'object') return false\n const v = value as AppFrameMessage\n return v.protocol === 'buckyos.app-frame' && v.version === 1 && typeof v.type === 'string' && !!v.payload && typeof v.payload === 'object'\n}\nexport class AppFrameHost {\n ready = false\n capabilities: string[] = []\n private pending = new Map<string, { resolve: (v: unknown) => void; reject: (e: Error) => void; timer: ReturnType<typeof setTimeout>; type: string }>()\n private listener = (event: MessageEvent) => this.receive(event)\n private opens: number[] = []\n constructor(private options: {\n target: () => Window | null; origin: string; init: FrameInit\n onReady?: () => void\n onTitle?: (title: string, dirty: boolean) => void\n onRequestClose?: () => void\n onContentOpen?: (request: OpenRequest, target: ContentOpenTarget, options: { newWindow: boolean; hints: ContentHints }) => void\n }) { window.addEventListener('message', this.listener) }\n private focused?: boolean\n private receive(event: MessageEvent): void {\n if (event.source !== this.options.target() || event.origin !== this.options.origin || !isMessage(event.data)) return\n const m = event.data\n const p = m.payload as Record<string, unknown>\n if (m.type === 'frame.hello') {\n if (p.nonce !== this.options.init.nonce || !Array.isArray(p.appCapabilities)) return\n this.ready = true\n this.capabilities = p.appCapabilities.filter((c): c is string => typeof c === 'string')\n this.send('frame.init', this.options.init)\n if (this.focused !== undefined) this.send('frame.focusChanged', { focused: this.focused })\n this.options.onReady?.()\n return\n }\n if (!this.ready) return\n if (m.replyTo) {\n const pending = this.pending.get(m.replyTo)\n if (pending && m.type === pending.type + 'Result') {\n clearTimeout(pending.timer); this.pending.delete(m.replyTo); pending.resolve(m.payload)\n }\n return\n }\n if (m.type === 'window.setTitle' && typeof p.title === 'string') this.options.onTitle?.(p.title.slice(0, 256), p.dirty === true)\n if (m.type === 'window.requestClose') this.options.onRequestClose?.()\n if (m.type === 'content.open' && (p.target === 'default' || p.target === 'preview' || p.target === 'chooser')) {\n const request = { ...(p.request as object), requestId: crypto.randomUUID() }\n if (!isOpenRequest(request)) return\n this.opens = this.opens.filter(t => t > Date.now() - 10000)\n if (this.opens.length >= 5) return\n this.opens.push(Date.now())\n this.options.onContentOpen?.(request, p.target, { newWindow: p.newWindow === true, hints: readContentHints(p.hints) })\n }\n }\n update(init: Partial<FrameInit>): void { this.options.init = { ...this.options.init, ...init } }\n /** Reports whether the App's window is the focused one; only a change is sent. */\n setFocused(focused: boolean): void {\n if (this.focused === focused) return\n this.focused = focused\n this.send('frame.focusChanged', { focused })\n }\n send(type: string, payload: unknown): void {\n if (this.ready) this.options.target()?.postMessage(envelope(type, payload), this.options.origin)\n }\n request(type: string, payload: unknown, timeout = 3000): Promise<unknown> {\n if (!this.ready) return Promise.reject(new Error('App frame is not ready'))\n const id = crypto.randomUUID()\n return new Promise((resolve, reject) => {\n const timer = setTimeout(() => { this.pending.delete(id); reject(new Error('App frame timed out')) }, timeout)\n this.pending.set(id, { resolve, reject, timer, type })\n this.options.target()?.postMessage(envelope(type, payload, { id }), this.options.origin)\n })\n }\n async open(request: OpenRequest): Promise<{ accepted: boolean; fallback?: 'preview' }> {\n if (!this.capabilities.includes('open')) return { accepted: false }\n return await this.request('frame.open', { request }) as { accepted: boolean; fallback?: 'preview' }\n }\n async beforeClose(reason: 'user' | 'logout' | 'shell' = 'user'): Promise<CloseDecision> {\n if (!this.ready || !this.capabilities.includes('beforeClose')) return 'allow'\n const r = await this.request('frame.beforeClose', { reason }) as { decision?: CloseDecision }\n return r.decision === 'allow' || r.decision === 'pending' ? r.decision : 'deny'\n }\n async back(): Promise<boolean> {\n if (!this.capabilities.includes('back')) return false\n return (await this.request('frame.back', {}) as { handled?: boolean }).handled === true\n }\n dispose(): void {\n window.removeEventListener('message', this.listener)\n this.pending.forEach(p => { clearTimeout(p.timer); p.reject(new Error('App frame disposed')) })\n this.pending.clear(); this.ready = false\n }\n}\n/**\n * Origin of the window embedding this page, when `accept` admits it. `location.ancestorOrigins` names the real\n * parent even after the frame navigated through other pages (a sign-in round trip); the referrer is the fallback.\n */\nexport function embedderOrigin(accept: (origin: string) => boolean): string | null {\n if (window.parent === window) return null\n const candidates = [window.location.ancestorOrigins?.[0], document.referrer]\n for (const candidate of candidates) {\n if (!candidate) continue\n try {\n const origin = new URL(candidate).origin\n if (accept(origin)) return origin\n } catch {}\n }\n return null\n}\nexport const originInZone = (origin: string, zoneHost: string): boolean => {\n try {\n const url = new URL(origin)\n return url.protocol === window.location.protocol && (url.hostname === zoneHost || url.hostname.endsWith(`.${zoneHost}`))\n } catch { return false }\n}\nexport class AppFrameClient {\n init?: FrameInit\n private title?: string\n private focused?: boolean\n private helloTimer?: ReturnType<typeof setInterval>\n private helloDeadline?: ReturnType<typeof setTimeout>\n private readonly nonce: string | null\n private readonly origin: string\n private readonly listener = (event: MessageEvent) => { void this.receive(event) }\n constructor(private options: {\n shellOrigin: string\n /** The Zone's system entry (its root origin): where content is opened when this page is not embedded in the shell. */\n systemOrigin?: string\n /** This App's id, so the system does not offer the content back to it. */\n appId?: string\n onInit?: (init: FrameInit) => void\n onOpen?: (request: OpenRequest) => Promise<{ accepted: boolean; fallback?: 'preview' }> | { accepted: boolean; fallback?: 'preview' }\n onBeforeClose?: (reason: 'user' | 'logout' | 'shell') => Promise<CloseDecision> | CloseDecision\n onBack?: () => Promise<boolean> | boolean\n onTheme?: (theme: FrameInit['theme']) => void\n onLocale?: (locale: string) => void\n onFocus?: (focused: boolean) => void\n }) {\n this.origin = new URL(options.shellOrigin).origin\n this.nonce = new URLSearchParams(window.location.hash.slice(1)).get('bfp')\n window.addEventListener('message', this.listener)\n if (window.parent !== window && this.nonce) {\n const hello = () => window.parent.postMessage(envelope('frame.hello', { nonce: this.nonce, appCapabilities: [\n ...options.onOpen ? ['open'] : [], ...options.onBeforeClose ? ['beforeClose'] : [], ...options.onBack ? ['back'] : [],\n ] }), this.origin)\n hello()\n this.helloTimer = setInterval(hello, 250)\n this.helloDeadline = setTimeout(() => clearInterval(this.helloTimer), 1500)\n }\n }\n private async receive(event: MessageEvent): Promise<void> {\n if (event.source !== window.parent || event.origin !== this.origin || !isMessage(event.data)) return\n const m = event.data\n const p = m.payload as Record<string, unknown>\n if (m.type === 'frame.init') {\n if (!this.nonce || p.nonce !== this.nonce || typeof p.locale !== 'string' || !p.theme || typeof p.windowId !== 'string' || p.launch && !isOpenRequest(p.launch)) return\n clearInterval(this.helloTimer); clearTimeout(this.helloDeadline)\n this.init = p as unknown as FrameInit\n this.title = undefined; this.focused = undefined\n this.options.onInit?.(this.init)\n return\n }\n if (!this.init) return\n const reply = (payload: unknown) => window.parent.postMessage(envelope(m.type + 'Result', payload, { replyTo: m.id }), this.origin)\n try {\n if (m.type === 'frame.open' && isOpenRequest(p.request)) reply(await this.options.onOpen?.(p.request) ?? { accepted: false })\n if (m.type === 'frame.beforeClose') reply({ decision: await this.options.onBeforeClose?.(p.reason as 'user') ?? 'allow' })\n if (m.type === 'frame.back') reply({ handled: await this.options.onBack?.() ?? false })\n if (m.type === 'frame.themeChanged' && (p.mode === 'dark' || p.mode === 'light')) this.options.onTheme?.(p as FrameInit['theme'])\n if (m.type === 'frame.localeChanged' && typeof p.locale === 'string') this.options.onLocale?.(p.locale)\n if (m.type === 'frame.focusChanged' && this.focused !== (p.focused === true)) { this.focused = p.focused === true; this.options.onFocus?.(this.focused) }\n } catch {\n if (m.type === 'frame.open') reply({ accepted: false, fallback: 'preview' })\n if (m.type === 'frame.beforeClose') reply({ decision: 'deny' })\n }\n }\n send(type: string, payload: unknown): void {\n if (this.init) window.parent.postMessage(envelope(type, payload), this.origin)\n }\n setTitle(title: string, dirty = false): void {\n const key = JSON.stringify([title, dirty])\n if (!this.init || key === this.title) return\n this.title = key\n this.send('window.setTitle', { title, dirty })\n }\n requestClose(): void { this.send('window.requestClose', {}) }\n /**\n * Asks the system to open content: with its default app, in Preview, or by letting the user choose (`chooser`).\n * Embedded in the shell the request goes over the frame; in a standalone tab it opens the Zone's system entry\n * (`systemOrigin`) in a new tab. Returns false when neither is available.\n */\n openContent(request: Omit<OpenRequest, 'requestId'>, target: ContentOpenTarget = 'default', options: { newWindow?: boolean; hints?: ContentHints } = {}): boolean {\n const hints = options.hints ?? {}\n if (this.init) { this.send('content.open', { request, target, newWindow: options.newWindow === true, hints }); return true }\n if (!this.options.systemOrigin) return false\n window.open(systemOpenUrl(this.options.systemOrigin, { request, target, hints, from: this.options.appId }), '_blank', 'noopener')\n return true\n }\n dispose(): void { clearInterval(this.helloTimer); clearTimeout(this.helloDeadline); window.removeEventListener('message', this.listener) }\n}\n\n/**\n * Preview embed protocol (`buckyos.preview-embed` v1): an App shows the system Preview component inside its own UI.\n * The App frames `<systemOrigin>/embed/preview` (component only, no shell) and hands it a content reference; the\n * system page reads the content with its own Zone-root session, so no token crosses origins. Open With goes back\n * through the App to the shell (`AppFrameClient.openContent(…, 'chooser')`).\n */\nexport type PreviewEmbedSource = TransferableContentRef | { kind: 'blob'; blob: Blob; name: string }\nexport interface PreviewEmbedInit {\n nonce: string\n source: PreviewEmbedSource\n session?: TransferableSessionContext\n theme: 'light' | 'dark'\n locale: string\n}\nexport interface PreviewEmbedState {\n status: 'loading' | 'ready' | 'error'\n /** Preview error kind (`unsupported`, `not-found`, `permission-denied`, `timeout`, `error`, …) and code. */\n error?: { kind: string; code: string }\n title?: string\n mediaType?: string\n}\nexport interface PreviewEmbedOpenWith { request: Omit<OpenRequest, 'requestId'>; hints: ContentHints }\nconst PREVIEW_EMBED = 'buckyos.preview-embed'\nconst embedEnvelope = (type: string, payload: unknown) => ({ protocol: PREVIEW_EMBED, version: 1, type, payload })\nconst isEmbedMessage = (value: unknown): value is { type: string; payload: Record<string, unknown> } => {\n const v = value as { protocol?: unknown; version?: unknown; type?: unknown; payload?: unknown } | null\n return !!v && v.protocol === PREVIEW_EMBED && v.version === 1 && typeof v.type === 'string' && !!v.payload && typeof v.payload === 'object'\n}\nconst isEmbedSource = (value: unknown): value is PreviewEmbedSource =>\n isTransferableRef(value) || (!!value && typeof value === 'object' && (value as { kind?: unknown }).kind === 'blob' &&\n typeof Blob !== 'undefined' && (value as { blob?: unknown }).blob instanceof Blob && typeof (value as { name?: unknown }).name === 'string')\nexport const PREVIEW_EMBED_PATH = '/embed/preview'\n\n/** App side: owns the iframe that shows the system Preview. */\nexport class PreviewEmbed {\n readonly url: string\n private readonly nonce = crypto.randomUUID()\n private readonly origin: string\n private readonly listener = (event: MessageEvent) => this.receive(event)\n private init: Omit<PreviewEmbedInit, 'nonce'>\n constructor(private options: {\n systemOrigin: string\n frame: () => HTMLIFrameElement | null\n init: Omit<PreviewEmbedInit, 'nonce'>\n onState?: (state: PreviewEmbedState) => void\n onOpenWith?: (open: PreviewEmbedOpenWith) => void\n onExit?: () => void\n }) {\n this.origin = new URL(options.systemOrigin).origin\n this.init = options.init\n this.url = `${this.origin}${PREVIEW_EMBED_PATH}#bpe=${this.nonce}&po=${encodeURIComponent(window.location.origin)}`\n window.addEventListener('message', this.listener)\n }\n private post(type: string, payload: unknown): void {\n this.options.frame()?.contentWindow?.postMessage(embedEnvelope(type, payload), this.origin)\n }\n private receive(event: MessageEvent): void {\n if (event.origin !== this.origin || event.source !== this.options.frame()?.contentWindow || !isEmbedMessage(event.data)) return\n const { type, payload: p } = event.data\n if (type === 'embed.hello') { if (p.nonce === this.nonce) this.post('embed.init', { ...this.init, nonce: this.nonce }); return }\n if (type === 'embed.state' && (p.status === 'loading' || p.status === 'ready' || p.status === 'error')) {\n const error = p.error as { kind?: unknown; code?: unknown } | undefined\n this.options.onState?.({ status: p.status,\n error: error && typeof error.kind === 'string' && typeof error.code === 'string' ? { kind: error.kind, code: error.code } : undefined,\n title: typeof p.title === 'string' ? p.title.slice(0, 256) : undefined, mediaType: typeof p.mediaType === 'string' ? p.mediaType.slice(0, 128) : undefined })\n }\n if (type === 'embed.openWith') {\n const request = p.request as Omit<OpenRequest, 'requestId'> | undefined\n if (request && isTransferableRef(request.source) && (request.session === undefined || isTransferableSession(request.session))) {\n this.options.onOpenWith?.({ request: { source: request.source, session: request.session }, hints: readContentHints(p.hints) })\n }\n }\n if (type === 'embed.exit') this.options.onExit?.()\n }\n update(patch: Partial<Pick<PreviewEmbedInit, 'theme' | 'locale'>>): void {\n this.init = { ...this.init, ...patch }\n this.post('embed.update', patch)\n }\n dispose(): void { window.removeEventListener('message', this.listener) }\n}\n\n/** System side: the component-only page at `PREVIEW_EMBED_PATH`. Accepts one embedding App whose origin `accept` admits. */\nexport class PreviewEmbedHost {\n readonly parentOrigin: string | null\n private readonly nonce: string | null\n private ready = false\n private readonly hello?: ReturnType<typeof setInterval>\n private readonly listener = (event: MessageEvent) => this.receive(event)\n constructor(private options: {\n accept: (origin: string) => boolean\n onInit: (init: PreviewEmbedInit) => void\n onUpdate?: (patch: Partial<Pick<PreviewEmbedInit, 'theme' | 'locale'>>) => void\n }) {\n const params = new URLSearchParams(window.location.hash.slice(1))\n this.nonce = params.get('bpe')\n let parentOrigin: string | null = null\n try { parentOrigin = new URL(params.get('po') ?? '').origin } catch {}\n this.parentOrigin = window.parent !== window && this.nonce && parentOrigin && options.accept(parentOrigin) ? parentOrigin : null\n if (!this.parentOrigin) return\n window.addEventListener('message', this.listener)\n const hello = () => window.parent.postMessage(embedEnvelope('embed.hello', { nonce: this.nonce }), this.parentOrigin!)\n hello()\n this.hello = setInterval(() => { if (!this.ready) hello() }, 250)\n }\n private receive(event: MessageEvent): void {\n if (event.source !== window.parent || event.origin !== this.parentOrigin || !isEmbedMessage(event.data)) return\n const { type, payload: p } = event.data\n if (type === 'embed.init') {\n if (p.nonce !== this.nonce || !isEmbedSource(p.source) || (p.session !== undefined && !isTransferableSession(p.session)) || typeof p.locale !== 'string') return\n this.ready = true; clearInterval(this.hello)\n this.options.onInit({ nonce: String(p.nonce), source: p.source, session: p.session as TransferableSessionContext | undefined, theme: p.theme === 'dark' ? 'dark' : 'light', locale: p.locale })\n return\n }\n if (type === 'embed.update' && this.ready) {\n const patch: Partial<Pick<PreviewEmbedInit, 'theme' | 'locale'>> = {}\n if (p.theme === 'dark' || p.theme === 'light') patch.theme = p.theme\n if (typeof p.locale === 'string') patch.locale = p.locale\n this.options.onUpdate?.(patch)\n }\n }\n private post(type: string, payload: unknown): void {\n if (this.ready && this.parentOrigin) window.parent.postMessage(embedEnvelope(type, payload), this.parentOrigin)\n }\n state(state: PreviewEmbedState): void { this.post('embed.state', state) }\n openWith(open: PreviewEmbedOpenWith): void { this.post('embed.openWith', open) }\n exit(): void { this.post('embed.exit', {}) }\n dispose(): void { clearInterval(this.hello); window.removeEventListener('message', this.listener) }\n}\n"],"names":["envelope","type","payload","extra","protocol","version","isMessage","value","v","PREVIEW_EMBED","embedEnvelope","isEmbedMessage","PREVIEW_EMBED_PATH","constructor","options","this","listener","event","receive","origin","URL","shellOrigin","nonce","URLSearchParams","window","location","hash","slice","get","addEventListener","parent","hello","postMessage","appCapabilities","onOpen","onBeforeClose","onBack","helloTimer","setInterval","helloDeadline","setTimeout","clearInterval","source","data","m","p","locale","theme","windowId","launch","isOpenRequest","clearTimeout","init","title","focused","_b","_a","onInit","call","reply","replyTo","id","request","_d","_c","accepted","decision","_f","_e","reason","handled","_h","_g","mode","_j","_i","onTheme","_l","_k","onLocale","_n","_m","onFocus","fallback","send","setTitle","dirty","key","JSON","stringify","requestClose","openContent","target","hints","newWindow","systemOrigin","open","systemOpenUrl","from","appId","dispose","removeEventListener","ready","capabilities","pending","Map","opens","Array","isArray","filter","c","onReady","timer","delete","resolve","onTitle","onRequestClose","requestId","crypto","randomUUID","t","Date","now","length","push","onContentOpen","readContentHints","update","setFocused","timeout","Promise","reject","Error","set","includes","beforeClose","r","back","forEach","clear","url","encodeURIComponent","post","frame","contentWindow","status","error","onState","kind","code","mediaType","isTransferableRef","session","isTransferableSession","onOpenWith","onExit","patch","params","parentOrigin","accept","Blob","blob","name","String","onUpdate","state","openWith","exit","candidates","ancestorOrigins","document","referrer","candidate","zoneHost","hostname","endsWith"],"mappings":"uJAcA,MAAMA,EAAW,CAACC,EAAcC,EAAkBC,EAA2C,CAAA,KAAA,CACxFC,SAAU,oBAAqBC,QAAS,EAAGJ,OAAMC,aAAYC,IAC5DG,EAAaC,IACb,IAACA,GAA0B,iBAAVA,EAA2B,OAAA,EAChD,MAAMC,EAAID,EACV,MAAsB,sBAAfC,EAAEJ,UAAkD,IAAdI,EAAEH,SAAmC,iBAAXG,EAAEP,QAAuBO,EAAEN,SAAgC,iBAAdM,EAAEN,OAAY,EAwNpI,MAAMO,EAAgB,wBAChBC,EAAgB,CAACT,EAAcC,K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AAIvI,OAAOM,SAAWN,OAAe,OAAA,KAC/B,MAAAgJ,EAAa,CAAC,OAAAhH,EAAOhC,OAAAC,SAASgJ,sBAAkB,EAAAjH,EAAA,GAAIkH,SAASC,UACnE,IAAA,MAAWC,KAAaJ,EACtB,GAAKI,EACD,IACF,MAAMzJ,EAAS,IAAIC,IAAIwJ,GAAWzJ,OAClC,GAAI4I,EAAO5I,GAAgB,OAAAA,CAAA,CACrB,MAAC,CAEJ,OAAA,IACT,uBAC4B,CAACA,EAAgB0J,KACvC,IACI,MAAAjC,EAAM,IAAIxH,IAAID,GACpB,OAAOyH,EAAIxI,WAAaoB,OAAOC,SAASrB,WAAawI,EAAIkC,WAAaD,GAAYjC,EAAIkC,SAASC,SAAS,IAAIF,KAAU,CAChH,MAAS,OAAA,CAAM"}
@@ -1,4 +1,5 @@
1
1
  import { isOpenRequest, readContentHints, systemOpenUrl, isTransferableRef, isTransferableSession } from "./content.mjs";
2
+ import "./content_mime-e42d5f8d.mjs";
2
3
  const envelope = (type, payload, extra = {}) => ({ protocol: "buckyos.app-frame", version: 1, type, payload, ...extra });
3
4
  const isMessage = (value) => {
4
5
  if (!value || typeof value !== "object")
@@ -1 +1 @@
1
- {"version":3,"file":"app-frame.mjs","sources":["../src/app-frame.ts"],"sourcesContent":["import { isOpenRequest, isTransferableRef, isTransferableSession, readContentHints, systemOpenUrl, type ContentHints, type ContentOpenTarget, type OpenRequest, type TransferableContentRef, type TransferableSessionContext } from './content'\nexport interface AppFrameMessage<T extends string = string, P = unknown> {\n protocol: 'buckyos.app-frame'; version: 1; type: T; id?: string; replyTo?: string; payload: P\n}\nexport interface FrameInit {\n nonce: string\n windowId: string\n formFactor: 'desktop' | 'mobile'\n theme: { mode: 'light' | 'dark'; accent?: string }\n locale: string\n launch?: OpenRequest\n shellCapabilities: string[]\n}\nexport type CloseDecision = 'allow' | 'deny' | 'pending'\nconst envelope = (type: string, payload: unknown, extra: { id?: string; replyTo?: string } = {}): AppFrameMessage =>\n ({ protocol: 'buckyos.app-frame', version: 1, type, payload, ...extra })\nconst isMessage = (value: unknown): value is AppFrameMessage => {\n if (!value || typeof value !== 'object') return false\n const v = value as AppFrameMessage\n return v.protocol === 'buckyos.app-frame' && v.version === 1 && typeof v.type === 'string' && !!v.payload && typeof v.payload === 'object'\n}\nexport class AppFrameHost {\n ready = false\n capabilities: string[] = []\n private pending = new Map<string, { resolve: (v: unknown) => void; reject: (e: Error) => void; timer: ReturnType<typeof setTimeout>; type: string }>()\n private listener = (event: MessageEvent) => this.receive(event)\n private opens: number[] = []\n constructor(private options: {\n target: () => Window | null; origin: string; init: FrameInit\n onReady?: () => void\n onTitle?: (title: string, dirty: boolean) => void\n onRequestClose?: () => void\n onContentOpen?: (request: OpenRequest, target: ContentOpenTarget, options: { newWindow: boolean; hints: ContentHints }) => void\n }) { window.addEventListener('message', this.listener) }\n private focused?: boolean\n private receive(event: MessageEvent): void {\n if (event.source !== this.options.target() || event.origin !== this.options.origin || !isMessage(event.data)) return\n const m = event.data\n const p = m.payload as Record<string, unknown>\n if (m.type === 'frame.hello') {\n if (p.nonce !== this.options.init.nonce || !Array.isArray(p.appCapabilities)) return\n this.ready = true\n this.capabilities = p.appCapabilities.filter((c): c is string => typeof c === 'string')\n this.send('frame.init', this.options.init)\n if (this.focused !== undefined) this.send('frame.focusChanged', { focused: this.focused })\n this.options.onReady?.()\n return\n }\n if (!this.ready) return\n if (m.replyTo) {\n const pending = this.pending.get(m.replyTo)\n if (pending && m.type === pending.type + 'Result') {\n clearTimeout(pending.timer); this.pending.delete(m.replyTo); pending.resolve(m.payload)\n }\n return\n }\n if (m.type === 'window.setTitle' && typeof p.title === 'string') this.options.onTitle?.(p.title.slice(0, 256), p.dirty === true)\n if (m.type === 'window.requestClose') this.options.onRequestClose?.()\n if (m.type === 'content.open' && (p.target === 'default' || p.target === 'preview' || p.target === 'chooser')) {\n const request = { ...(p.request as object), requestId: crypto.randomUUID() }\n if (!isOpenRequest(request)) return\n this.opens = this.opens.filter(t => t > Date.now() - 10000)\n if (this.opens.length >= 5) return\n this.opens.push(Date.now())\n this.options.onContentOpen?.(request, p.target, { newWindow: p.newWindow === true, hints: readContentHints(p.hints) })\n }\n }\n update(init: Partial<FrameInit>): void { this.options.init = { ...this.options.init, ...init } }\n /** Reports whether the App's window is the focused one; only a change is sent. */\n setFocused(focused: boolean): void {\n if (this.focused === focused) return\n this.focused = focused\n this.send('frame.focusChanged', { focused })\n }\n send(type: string, payload: unknown): void {\n if (this.ready) this.options.target()?.postMessage(envelope(type, payload), this.options.origin)\n }\n request(type: string, payload: unknown, timeout = 3000): Promise<unknown> {\n if (!this.ready) return Promise.reject(new Error('App frame is not ready'))\n const id = crypto.randomUUID()\n return new Promise((resolve, reject) => {\n const timer = setTimeout(() => { this.pending.delete(id); reject(new Error('App frame timed out')) }, timeout)\n this.pending.set(id, { resolve, reject, timer, type })\n this.options.target()?.postMessage(envelope(type, payload, { id }), this.options.origin)\n })\n }\n async open(request: OpenRequest): Promise<{ accepted: boolean; fallback?: 'preview' }> {\n if (!this.capabilities.includes('open')) return { accepted: false }\n return await this.request('frame.open', { request }) as { accepted: boolean; fallback?: 'preview' }\n }\n async beforeClose(reason: 'user' | 'logout' | 'shell' = 'user'): Promise<CloseDecision> {\n if (!this.ready || !this.capabilities.includes('beforeClose')) return 'allow'\n const r = await this.request('frame.beforeClose', { reason }) as { decision?: CloseDecision }\n return r.decision === 'allow' || r.decision === 'pending' ? r.decision : 'deny'\n }\n async back(): Promise<boolean> {\n if (!this.capabilities.includes('back')) return false\n return (await this.request('frame.back', {}) as { handled?: boolean }).handled === true\n }\n dispose(): void {\n window.removeEventListener('message', this.listener)\n this.pending.forEach(p => { clearTimeout(p.timer); p.reject(new Error('App frame disposed')) })\n this.pending.clear(); this.ready = false\n }\n}\n/**\n * Origin of the window embedding this page, when `accept` admits it. `location.ancestorOrigins` names the real\n * parent even after the frame navigated through other pages (a sign-in round trip); the referrer is the fallback.\n */\nexport function embedderOrigin(accept: (origin: string) => boolean): string | null {\n if (window.parent === window) return null\n const candidates = [window.location.ancestorOrigins?.[0], document.referrer]\n for (const candidate of candidates) {\n if (!candidate) continue\n try {\n const origin = new URL(candidate).origin\n if (accept(origin)) return origin\n } catch {}\n }\n return null\n}\nexport const originInZone = (origin: string, zoneHost: string): boolean => {\n try {\n const url = new URL(origin)\n return url.protocol === window.location.protocol && (url.hostname === zoneHost || url.hostname.endsWith(`.${zoneHost}`))\n } catch { return false }\n}\nexport class AppFrameClient {\n init?: FrameInit\n private title?: string\n private focused?: boolean\n private helloTimer?: ReturnType<typeof setInterval>\n private helloDeadline?: ReturnType<typeof setTimeout>\n private readonly nonce: string | null\n private readonly origin: string\n private readonly listener = (event: MessageEvent) => { void this.receive(event) }\n constructor(private options: {\n shellOrigin: string\n /** The Zone's system entry (its root origin): where content is opened when this page is not embedded in the shell. */\n systemOrigin?: string\n /** This App's id, so the system does not offer the content back to it. */\n appId?: string\n onInit?: (init: FrameInit) => void\n onOpen?: (request: OpenRequest) => Promise<{ accepted: boolean; fallback?: 'preview' }> | { accepted: boolean; fallback?: 'preview' }\n onBeforeClose?: (reason: 'user' | 'logout' | 'shell') => Promise<CloseDecision> | CloseDecision\n onBack?: () => Promise<boolean> | boolean\n onTheme?: (theme: FrameInit['theme']) => void\n onLocale?: (locale: string) => void\n onFocus?: (focused: boolean) => void\n }) {\n this.origin = new URL(options.shellOrigin).origin\n this.nonce = new URLSearchParams(window.location.hash.slice(1)).get('bfp')\n window.addEventListener('message', this.listener)\n if (window.parent !== window && this.nonce) {\n const hello = () => window.parent.postMessage(envelope('frame.hello', { nonce: this.nonce, appCapabilities: [\n ...options.onOpen ? ['open'] : [], ...options.onBeforeClose ? ['beforeClose'] : [], ...options.onBack ? ['back'] : [],\n ] }), this.origin)\n hello()\n this.helloTimer = setInterval(hello, 250)\n this.helloDeadline = setTimeout(() => clearInterval(this.helloTimer), 1500)\n }\n }\n private async receive(event: MessageEvent): Promise<void> {\n if (event.source !== window.parent || event.origin !== this.origin || !isMessage(event.data)) return\n const m = event.data\n const p = m.payload as Record<string, unknown>\n if (m.type === 'frame.init') {\n if (!this.nonce || p.nonce !== this.nonce || typeof p.locale !== 'string' || !p.theme || typeof p.windowId !== 'string' || p.launch && !isOpenRequest(p.launch)) return\n clearInterval(this.helloTimer); clearTimeout(this.helloDeadline)\n this.init = p as unknown as FrameInit\n this.title = undefined; this.focused = undefined\n this.options.onInit?.(this.init)\n return\n }\n if (!this.init) return\n const reply = (payload: unknown) => window.parent.postMessage(envelope(m.type + 'Result', payload, { replyTo: m.id }), this.origin)\n try {\n if (m.type === 'frame.open' && isOpenRequest(p.request)) reply(await this.options.onOpen?.(p.request) ?? { accepted: false })\n if (m.type === 'frame.beforeClose') reply({ decision: await this.options.onBeforeClose?.(p.reason as 'user') ?? 'allow' })\n if (m.type === 'frame.back') reply({ handled: await this.options.onBack?.() ?? false })\n if (m.type === 'frame.themeChanged' && (p.mode === 'dark' || p.mode === 'light')) this.options.onTheme?.(p as FrameInit['theme'])\n if (m.type === 'frame.localeChanged' && typeof p.locale === 'string') this.options.onLocale?.(p.locale)\n if (m.type === 'frame.focusChanged' && this.focused !== (p.focused === true)) { this.focused = p.focused === true; this.options.onFocus?.(this.focused) }\n } catch {\n if (m.type === 'frame.open') reply({ accepted: false, fallback: 'preview' })\n if (m.type === 'frame.beforeClose') reply({ decision: 'deny' })\n }\n }\n send(type: string, payload: unknown): void {\n if (this.init) window.parent.postMessage(envelope(type, payload), this.origin)\n }\n setTitle(title: string, dirty = false): void {\n const key = JSON.stringify([title, dirty])\n if (!this.init || key === this.title) return\n this.title = key\n this.send('window.setTitle', { title, dirty })\n }\n requestClose(): void { this.send('window.requestClose', {}) }\n /**\n * Asks the system to open content: with its default app, in Preview, or by letting the user choose (`chooser`).\n * Embedded in the shell the request goes over the frame; in a standalone tab it opens the Zone's system entry\n * (`systemOrigin`) in a new tab. Returns false when neither is available.\n */\n openContent(request: Omit<OpenRequest, 'requestId'>, target: ContentOpenTarget = 'default', options: { newWindow?: boolean; hints?: ContentHints } = {}): boolean {\n const hints = options.hints ?? {}\n if (this.init) { this.send('content.open', { request, target, newWindow: options.newWindow === true, hints }); return true }\n if (!this.options.systemOrigin) return false\n window.open(systemOpenUrl(this.options.systemOrigin, { request, target, hints, from: this.options.appId }), '_blank', 'noopener')\n return true\n }\n dispose(): void { clearInterval(this.helloTimer); clearTimeout(this.helloDeadline); window.removeEventListener('message', this.listener) }\n}\n\n/**\n * Preview embed protocol (`buckyos.preview-embed` v1): an App shows the system Preview component inside its own UI.\n * The App frames `<systemOrigin>/embed/preview` (component only, no shell) and hands it a content reference; the\n * system page reads the content with its own Zone-root session, so no token crosses origins. Open With goes back\n * through the App to the shell (`AppFrameClient.openContent(…, 'chooser')`).\n */\nexport type PreviewEmbedSource = TransferableContentRef | { kind: 'blob'; blob: Blob; name: string }\nexport interface PreviewEmbedInit {\n nonce: string\n source: PreviewEmbedSource\n session?: TransferableSessionContext\n theme: 'light' | 'dark'\n locale: string\n}\nexport interface PreviewEmbedState {\n status: 'loading' | 'ready' | 'error'\n /** Preview error kind (`unsupported`, `not-found`, `permission-denied`, `timeout`, `error`, …) and code. */\n error?: { kind: string; code: string }\n title?: string\n mediaType?: string\n}\nexport interface PreviewEmbedOpenWith { request: Omit<OpenRequest, 'requestId'>; hints: ContentHints }\nconst PREVIEW_EMBED = 'buckyos.preview-embed'\nconst embedEnvelope = (type: string, payload: unknown) => ({ protocol: PREVIEW_EMBED, version: 1, type, payload })\nconst isEmbedMessage = (value: unknown): value is { type: string; payload: Record<string, unknown> } => {\n const v = value as { protocol?: unknown; version?: unknown; type?: unknown; payload?: unknown } | null\n return !!v && v.protocol === PREVIEW_EMBED && v.version === 1 && typeof v.type === 'string' && !!v.payload && typeof v.payload === 'object'\n}\nconst isEmbedSource = (value: unknown): value is PreviewEmbedSource =>\n isTransferableRef(value) || (!!value && typeof value === 'object' && (value as { kind?: unknown }).kind === 'blob' &&\n typeof Blob !== 'undefined' && (value as { blob?: unknown }).blob instanceof Blob && typeof (value as { name?: unknown }).name === 'string')\nexport const PREVIEW_EMBED_PATH = '/embed/preview'\n\n/** App side: owns the iframe that shows the system Preview. */\nexport class PreviewEmbed {\n readonly url: string\n private readonly nonce = crypto.randomUUID()\n private readonly origin: string\n private readonly listener = (event: MessageEvent) => this.receive(event)\n private init: Omit<PreviewEmbedInit, 'nonce'>\n constructor(private options: {\n systemOrigin: string\n frame: () => HTMLIFrameElement | null\n init: Omit<PreviewEmbedInit, 'nonce'>\n onState?: (state: PreviewEmbedState) => void\n onOpenWith?: (open: PreviewEmbedOpenWith) => void\n onExit?: () => void\n }) {\n this.origin = new URL(options.systemOrigin).origin\n this.init = options.init\n this.url = `${this.origin}${PREVIEW_EMBED_PATH}#bpe=${this.nonce}&po=${encodeURIComponent(window.location.origin)}`\n window.addEventListener('message', this.listener)\n }\n private post(type: string, payload: unknown): void {\n this.options.frame()?.contentWindow?.postMessage(embedEnvelope(type, payload), this.origin)\n }\n private receive(event: MessageEvent): void {\n if (event.origin !== this.origin || event.source !== this.options.frame()?.contentWindow || !isEmbedMessage(event.data)) return\n const { type, payload: p } = event.data\n if (type === 'embed.hello') { if (p.nonce === this.nonce) this.post('embed.init', { ...this.init, nonce: this.nonce }); return }\n if (type === 'embed.state' && (p.status === 'loading' || p.status === 'ready' || p.status === 'error')) {\n const error = p.error as { kind?: unknown; code?: unknown } | undefined\n this.options.onState?.({ status: p.status,\n error: error && typeof error.kind === 'string' && typeof error.code === 'string' ? { kind: error.kind, code: error.code } : undefined,\n title: typeof p.title === 'string' ? p.title.slice(0, 256) : undefined, mediaType: typeof p.mediaType === 'string' ? p.mediaType.slice(0, 128) : undefined })\n }\n if (type === 'embed.openWith') {\n const request = p.request as Omit<OpenRequest, 'requestId'> | undefined\n if (request && isTransferableRef(request.source) && (request.session === undefined || isTransferableSession(request.session))) {\n this.options.onOpenWith?.({ request: { source: request.source, session: request.session }, hints: readContentHints(p.hints) })\n }\n }\n if (type === 'embed.exit') this.options.onExit?.()\n }\n update(patch: Partial<Pick<PreviewEmbedInit, 'theme' | 'locale'>>): void {\n this.init = { ...this.init, ...patch }\n this.post('embed.update', patch)\n }\n dispose(): void { window.removeEventListener('message', this.listener) }\n}\n\n/** System side: the component-only page at `PREVIEW_EMBED_PATH`. Accepts one embedding App whose origin `accept` admits. */\nexport class PreviewEmbedHost {\n readonly parentOrigin: string | null\n private readonly nonce: string | null\n private ready = false\n private readonly hello?: ReturnType<typeof setInterval>\n private readonly listener = (event: MessageEvent) => this.receive(event)\n constructor(private options: {\n accept: (origin: string) => boolean\n onInit: (init: PreviewEmbedInit) => void\n onUpdate?: (patch: Partial<Pick<PreviewEmbedInit, 'theme' | 'locale'>>) => void\n }) {\n const params = new URLSearchParams(window.location.hash.slice(1))\n this.nonce = params.get('bpe')\n let parentOrigin: string | null = null\n try { parentOrigin = new URL(params.get('po') ?? '').origin } catch {}\n this.parentOrigin = window.parent !== window && this.nonce && parentOrigin && options.accept(parentOrigin) ? parentOrigin : null\n if (!this.parentOrigin) return\n window.addEventListener('message', this.listener)\n const hello = () => window.parent.postMessage(embedEnvelope('embed.hello', { nonce: this.nonce }), this.parentOrigin!)\n hello()\n this.hello = setInterval(() => { if (!this.ready) hello() }, 250)\n }\n private receive(event: MessageEvent): void {\n if (event.source !== window.parent || event.origin !== this.parentOrigin || !isEmbedMessage(event.data)) return\n const { type, payload: p } = event.data\n if (type === 'embed.init') {\n if (p.nonce !== this.nonce || !isEmbedSource(p.source) || (p.session !== undefined && !isTransferableSession(p.session)) || typeof p.locale !== 'string') return\n this.ready = true; clearInterval(this.hello)\n this.options.onInit({ nonce: String(p.nonce), source: p.source, session: p.session as TransferableSessionContext | undefined, theme: p.theme === 'dark' ? 'dark' : 'light', locale: p.locale })\n return\n }\n if (type === 'embed.update' && this.ready) {\n const patch: Partial<Pick<PreviewEmbedInit, 'theme' | 'locale'>> = {}\n if (p.theme === 'dark' || p.theme === 'light') patch.theme = p.theme\n if (typeof p.locale === 'string') patch.locale = p.locale\n this.options.onUpdate?.(patch)\n }\n }\n private post(type: string, payload: unknown): void {\n if (this.ready && this.parentOrigin) window.parent.postMessage(embedEnvelope(type, payload), this.parentOrigin)\n }\n state(state: PreviewEmbedState): void { this.post('embed.state', state) }\n openWith(open: PreviewEmbedOpenWith): void { this.post('embed.openWith', open) }\n exit(): void { this.post('embed.exit', {}) }\n dispose(): void { clearInterval(this.hello); window.removeEventListener('message', this.listener) }\n}\n"],"names":[],"mappings":";AAcA,MAAM,WAAW,CAAC,MAAc,SAAkB,QAA2C,CAAA,OAC1F,EAAE,UAAU,qBAAqB,SAAS,GAAG,MAAM,SAAS,GAAG,MAAM;AACxE,MAAM,YAAY,CAAC,UAA6C;AAC1D,MAAA,CAAC,SAAS,OAAO,UAAU;AAAiB,WAAA;AAChD,QAAM,IAAI;AACV,SAAO,EAAE,aAAa,uBAAuB,EAAE,YAAY,KAAK,OAAO,EAAE,SAAS,YAAY,CAAC,CAAC,EAAE,WAAW,OAAO,EAAE,YAAY;AACpI;AACO,MAAM,aAAa;AAAA,EAMxB,YAAoB,SAMjB;AANiB,SAAA,UAAA;AALZ,SAAA,QAAA;AACR,SAAA,eAAyB;AACjB,SAAA,8BAAc;AACtB,SAAQ,WAAW,CAAC,UAAwB,KAAK,QAAQ,KAAK;AAC9D,SAAQ,QAAkB;AAOd,WAAA,iBAAiB,WAAW,KAAK,QAAQ;AAAA,EAAE;AAAA,EAE/C,QAAQ,OAA2B;;AACzC,QAAI,MAAM,WAAW,KAAK,QAAQ,OAAY,KAAA,MAAM,WAAW,KAAK,QAAQ,UAAU,CAAC,UAAU,MAAM,IAAI;AAAG;AAC9G,UAAM,IAAI,MAAM;AAChB,UAAM,IAAI,EAAE;AACR,QAAA,EAAE,SAAS,eAAe;AACxB,UAAA,EAAE,UAAU,KAAK,QAAQ,KAAK,SAAS,CAAC,MAAM,QAAQ,EAAE,eAAe;AAAG;AAC9E,WAAK,QAAQ;AACR,WAAA,eAAe,EAAE,gBAAgB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entHints, systemOpenUrl, type ContentHints, type ContentOpenTarget, type OpenRequest, type TransferableContentRef, type TransferableSessionContext } from './content'\nexport interface AppFrameMessage<T extends string = string, P = unknown> {\n protocol: 'buckyos.app-frame'; version: 1; type: T; id?: string; replyTo?: string; payload: P\n}\nexport interface FrameInit {\n nonce: string\n windowId: string\n formFactor: 'desktop' | 'mobile'\n theme: { mode: 'light' | 'dark'; accent?: string }\n locale: string\n launch?: OpenRequest\n shellCapabilities: string[]\n}\nexport type CloseDecision = 'allow' | 'deny' | 'pending'\nconst envelope = (type: string, payload: unknown, extra: { id?: string; replyTo?: string } = {}): AppFrameMessage =>\n ({ protocol: 'buckyos.app-frame', version: 1, type, payload, ...extra })\nconst isMessage = (value: unknown): value is AppFrameMessage => {\n if (!value || typeof value !== 'object') return false\n const v = value as AppFrameMessage\n return v.protocol === 'buckyos.app-frame' && v.version === 1 && typeof v.type === 'string' && !!v.payload && typeof v.payload === 'object'\n}\nexport class AppFrameHost {\n ready = false\n capabilities: string[] = []\n private pending = new Map<string, { resolve: (v: unknown) => void; reject: (e: Error) => void; timer: ReturnType<typeof setTimeout>; type: string }>()\n private listener = (event: MessageEvent) => this.receive(event)\n private opens: number[] = []\n constructor(private options: {\n target: () => Window | null; origin: string; init: FrameInit\n onReady?: () => void\n onTitle?: (title: string, dirty: boolean) => void\n onRequestClose?: () => void\n onContentOpen?: (request: OpenRequest, target: ContentOpenTarget, options: { newWindow: boolean; hints: ContentHints }) => void\n }) { window.addEventListener('message', this.listener) }\n private focused?: boolean\n private receive(event: MessageEvent): void {\n if (event.source !== this.options.target() || event.origin !== this.options.origin || !isMessage(event.data)) return\n const m = event.data\n const p = m.payload as Record<string, unknown>\n if (m.type === 'frame.hello') {\n if (p.nonce !== this.options.init.nonce || !Array.isArray(p.appCapabilities)) return\n this.ready = true\n this.capabilities = p.appCapabilities.filter((c): c is string => typeof c === 'string')\n this.send('frame.init', this.options.init)\n if (this.focused !== undefined) this.send('frame.focusChanged', { focused: this.focused })\n this.options.onReady?.()\n return\n }\n if (!this.ready) return\n if (m.replyTo) {\n const pending = this.pending.get(m.replyTo)\n if (pending && m.type === pending.type + 'Result') {\n clearTimeout(pending.timer); this.pending.delete(m.replyTo); pending.resolve(m.payload)\n }\n return\n }\n if (m.type === 'window.setTitle' && typeof p.title === 'string') this.options.onTitle?.(p.title.slice(0, 256), p.dirty === true)\n if (m.type === 'window.requestClose') this.options.onRequestClose?.()\n if (m.type === 'content.open' && (p.target === 'default' || p.target === 'preview' || p.target === 'chooser')) {\n const request = { ...(p.request as object), requestId: crypto.randomUUID() }\n if (!isOpenRequest(request)) return\n this.opens = this.opens.filter(t => t > Date.now() - 10000)\n if (this.opens.length >= 5) return\n this.opens.push(Date.now())\n this.options.onContentOpen?.(request, p.target, { newWindow: p.newWindow === true, hints: readContentHints(p.hints) })\n }\n }\n update(init: Partial<FrameInit>): void { this.options.init = { ...this.options.init, ...init } }\n /** Reports whether the App's window is the focused one; only a change is sent. */\n setFocused(focused: boolean): void {\n if (this.focused === focused) return\n this.focused = focused\n this.send('frame.focusChanged', { focused })\n }\n send(type: string, payload: unknown): void {\n if (this.ready) this.options.target()?.postMessage(envelope(type, payload), this.options.origin)\n }\n request(type: string, payload: unknown, timeout = 3000): Promise<unknown> {\n if (!this.ready) return Promise.reject(new Error('App frame is not ready'))\n const id = crypto.randomUUID()\n return new Promise((resolve, reject) => {\n const timer = setTimeout(() => { this.pending.delete(id); reject(new Error('App frame timed out')) }, timeout)\n this.pending.set(id, { resolve, reject, timer, type })\n this.options.target()?.postMessage(envelope(type, payload, { id }), this.options.origin)\n })\n }\n async open(request: OpenRequest): Promise<{ accepted: boolean; fallback?: 'preview' }> {\n if (!this.capabilities.includes('open')) return { accepted: false }\n return await this.request('frame.open', { request }) as { accepted: boolean; fallback?: 'preview' }\n }\n async beforeClose(reason: 'user' | 'logout' | 'shell' = 'user'): Promise<CloseDecision> {\n if (!this.ready || !this.capabilities.includes('beforeClose')) return 'allow'\n const r = await this.request('frame.beforeClose', { reason }) as { decision?: CloseDecision }\n return r.decision === 'allow' || r.decision === 'pending' ? r.decision : 'deny'\n }\n async back(): Promise<boolean> {\n if (!this.capabilities.includes('back')) return false\n return (await this.request('frame.back', {}) as { handled?: boolean }).handled === true\n }\n dispose(): void {\n window.removeEventListener('message', this.listener)\n this.pending.forEach(p => { clearTimeout(p.timer); p.reject(new Error('App frame disposed')) })\n this.pending.clear(); this.ready = false\n }\n}\n/**\n * Origin of the window embedding this page, when `accept` admits it. `location.ancestorOrigins` names the real\n * parent even after the frame navigated through other pages (a sign-in round trip); the referrer is the fallback.\n */\nexport function embedderOrigin(accept: (origin: string) => boolean): string | null {\n if (window.parent === window) return null\n const candidates = [window.location.ancestorOrigins?.[0], document.referrer]\n for (const candidate of candidates) {\n if (!candidate) continue\n try {\n const origin = new URL(candidate).origin\n if (accept(origin)) return origin\n } catch {}\n }\n return null\n}\nexport const originInZone = (origin: string, zoneHost: string): boolean => {\n try {\n const url = new URL(origin)\n return url.protocol === window.location.protocol && (url.hostname === zoneHost || url.hostname.endsWith(`.${zoneHost}`))\n } catch { return false }\n}\nexport class AppFrameClient {\n init?: FrameInit\n private title?: string\n private focused?: boolean\n private helloTimer?: ReturnType<typeof setInterval>\n private helloDeadline?: ReturnType<typeof setTimeout>\n private readonly nonce: string | null\n private readonly origin: string\n private readonly listener = (event: MessageEvent) => { void this.receive(event) }\n constructor(private options: {\n shellOrigin: string\n /** The Zone's system entry (its root origin): where content is opened when this page is not embedded in the shell. */\n systemOrigin?: string\n /** This App's id, so the system does not offer the content back to it. */\n appId?: string\n onInit?: (init: FrameInit) => void\n onOpen?: (request: OpenRequest) => Promise<{ accepted: boolean; fallback?: 'preview' }> | { accepted: boolean; fallback?: 'preview' }\n onBeforeClose?: (reason: 'user' | 'logout' | 'shell') => Promise<CloseDecision> | CloseDecision\n onBack?: () => Promise<boolean> | boolean\n onTheme?: (theme: FrameInit['theme']) => void\n onLocale?: (locale: string) => void\n onFocus?: (focused: boolean) => void\n }) {\n this.origin = new URL(options.shellOrigin).origin\n this.nonce = new URLSearchParams(window.location.hash.slice(1)).get('bfp')\n window.addEventListener('message', this.listener)\n if (window.parent !== window && this.nonce) {\n const hello = () => window.parent.postMessage(envelope('frame.hello', { nonce: this.nonce, appCapabilities: [\n ...options.onOpen ? ['open'] : [], ...options.onBeforeClose ? ['beforeClose'] : [], ...options.onBack ? ['back'] : [],\n ] }), this.origin)\n hello()\n this.helloTimer = setInterval(hello, 250)\n this.helloDeadline = setTimeout(() => clearInterval(this.helloTimer), 1500)\n }\n }\n private async receive(event: MessageEvent): Promise<void> {\n if (event.source !== window.parent || event.origin !== this.origin || !isMessage(event.data)) return\n const m = event.data\n const p = m.payload as Record<string, unknown>\n if (m.type === 'frame.init') {\n if (!this.nonce || p.nonce !== this.nonce || typeof p.locale !== 'string' || !p.theme || typeof p.windowId !== 'string' || p.launch && !isOpenRequest(p.launch)) return\n clearInterval(this.helloTimer); clearTimeout(this.helloDeadline)\n this.init = p as unknown as FrameInit\n this.title = undefined; this.focused = undefined\n this.options.onInit?.(this.init)\n return\n }\n if (!this.init) return\n const reply = (payload: unknown) => window.parent.postMessage(envelope(m.type + 'Result', payload, { replyTo: m.id }), this.origin)\n try {\n if (m.type === 'frame.open' && isOpenRequest(p.request)) reply(await this.options.onOpen?.(p.request) ?? { accepted: false })\n if (m.type === 'frame.beforeClose') reply({ decision: await this.options.onBeforeClose?.(p.reason as 'user') ?? 'allow' })\n if (m.type === 'frame.back') reply({ handled: await this.options.onBack?.() ?? false })\n if (m.type === 'frame.themeChanged' && (p.mode === 'dark' || p.mode === 'light')) this.options.onTheme?.(p as FrameInit['theme'])\n if (m.type === 'frame.localeChanged' && typeof p.locale === 'string') this.options.onLocale?.(p.locale)\n if (m.type === 'frame.focusChanged' && this.focused !== (p.focused === true)) { this.focused = p.focused === true; this.options.onFocus?.(this.focused) }\n } catch {\n if (m.type === 'frame.open') reply({ accepted: false, fallback: 'preview' })\n if (m.type === 'frame.beforeClose') reply({ decision: 'deny' })\n }\n }\n send(type: string, payload: unknown): void {\n if (this.init) window.parent.postMessage(envelope(type, payload), this.origin)\n }\n setTitle(title: string, dirty = false): void {\n const key = JSON.stringify([title, dirty])\n if (!this.init || key === this.title) return\n this.title = key\n this.send('window.setTitle', { title, dirty })\n }\n requestClose(): void { this.send('window.requestClose', {}) }\n /**\n * Asks the system to open content: with its default app, in Preview, or by letting the user choose (`chooser`).\n * Embedded in the shell the request goes over the frame; in a standalone tab it opens the Zone's system entry\n * (`systemOrigin`) in a new tab. Returns false when neither is available.\n */\n openContent(request: Omit<OpenRequest, 'requestId'>, target: ContentOpenTarget = 'default', options: { newWindow?: boolean; hints?: ContentHints } = {}): boolean {\n const hints = options.hints ?? {}\n if (this.init) { this.send('content.open', { request, target, newWindow: options.newWindow === true, hints }); return true }\n if (!this.options.systemOrigin) return false\n window.open(systemOpenUrl(this.options.systemOrigin, { request, target, hints, from: this.options.appId }), '_blank', 'noopener')\n return true\n }\n dispose(): void { clearInterval(this.helloTimer); clearTimeout(this.helloDeadline); window.removeEventListener('message', this.listener) }\n}\n\n/**\n * Preview embed protocol (`buckyos.preview-embed` v1): an App shows the system Preview component inside its own UI.\n * The App frames `<systemOrigin>/embed/preview` (component only, no shell) and hands it a content reference; the\n * system page reads the content with its own Zone-root session, so no token crosses origins. Open With goes back\n * through the App to the shell (`AppFrameClient.openContent(…, 'chooser')`).\n */\nexport type PreviewEmbedSource = TransferableContentRef | { kind: 'blob'; blob: Blob; name: string }\nexport interface PreviewEmbedInit {\n nonce: string\n source: PreviewEmbedSource\n session?: TransferableSessionContext\n theme: 'light' | 'dark'\n locale: string\n}\nexport interface PreviewEmbedState {\n status: 'loading' | 'ready' | 'error'\n /** Preview error kind (`unsupported`, `not-found`, `permission-denied`, `timeout`, `error`, …) and code. */\n error?: { kind: string; code: string }\n title?: string\n mediaType?: string\n}\nexport interface PreviewEmbedOpenWith { request: Omit<OpenRequest, 'requestId'>; hints: ContentHints }\nconst PREVIEW_EMBED = 'buckyos.preview-embed'\nconst embedEnvelope = (type: string, payload: unknown) => ({ protocol: PREVIEW_EMBED, version: 1, type, payload })\nconst isEmbedMessage = (value: unknown): value is { type: string; payload: Record<string, unknown> } => {\n const v = value as { protocol?: unknown; version?: unknown; type?: unknown; payload?: unknown } | null\n return !!v && v.protocol === PREVIEW_EMBED && v.version === 1 && typeof v.type === 'string' && !!v.payload && typeof v.payload === 'object'\n}\nconst isEmbedSource = (value: unknown): value is PreviewEmbedSource =>\n isTransferableRef(value) || (!!value && typeof value === 'object' && (value as { kind?: unknown }).kind === 'blob' &&\n typeof Blob !== 'undefined' && (value as { blob?: unknown }).blob instanceof Blob && typeof (value as { name?: unknown }).name === 'string')\nexport const PREVIEW_EMBED_PATH = '/embed/preview'\n\n/** App side: owns the iframe that shows the system Preview. */\nexport class PreviewEmbed {\n readonly url: string\n private readonly nonce = crypto.randomUUID()\n private readonly origin: string\n private readonly listener = (event: MessageEvent) => this.receive(event)\n private init: Omit<PreviewEmbedInit, 'nonce'>\n constructor(private options: {\n systemOrigin: string\n frame: () => HTMLIFrameElement | null\n init: Omit<PreviewEmbedInit, 'nonce'>\n onState?: (state: PreviewEmbedState) => void\n onOpenWith?: (open: PreviewEmbedOpenWith) => void\n onExit?: () => void\n }) {\n this.origin = new URL(options.systemOrigin).origin\n this.init = options.init\n this.url = `${this.origin}${PREVIEW_EMBED_PATH}#bpe=${this.nonce}&po=${encodeURIComponent(window.location.origin)}`\n window.addEventListener('message', this.listener)\n }\n private post(type: string, payload: unknown): void {\n this.options.frame()?.contentWindow?.postMessage(embedEnvelope(type, payload), this.origin)\n }\n private receive(event: MessageEvent): void {\n if (event.origin !== this.origin || event.source !== this.options.frame()?.contentWindow || !isEmbedMessage(event.data)) return\n const { type, payload: p } = event.data\n if (type === 'embed.hello') { if (p.nonce === this.nonce) this.post('embed.init', { ...this.init, nonce: this.nonce }); return }\n if (type === 'embed.state' && (p.status === 'loading' || p.status === 'ready' || p.status === 'error')) {\n const error = p.error as { kind?: unknown; code?: unknown } | undefined\n this.options.onState?.({ status: p.status,\n error: error && typeof error.kind === 'string' && typeof error.code === 'string' ? { kind: error.kind, code: error.code } : undefined,\n title: typeof p.title === 'string' ? p.title.slice(0, 256) : undefined, mediaType: typeof p.mediaType === 'string' ? p.mediaType.slice(0, 128) : undefined })\n }\n if (type === 'embed.openWith') {\n const request = p.request as Omit<OpenRequest, 'requestId'> | undefined\n if (request && isTransferableRef(request.source) && (request.session === undefined || isTransferableSession(request.session))) {\n this.options.onOpenWith?.({ request: { source: request.source, session: request.session }, hints: readContentHints(p.hints) })\n }\n }\n if (type === 'embed.exit') this.options.onExit?.()\n }\n update(patch: Partial<Pick<PreviewEmbedInit, 'theme' | 'locale'>>): void {\n this.init = { ...this.init, ...patch }\n this.post('embed.update', patch)\n }\n dispose(): void { window.removeEventListener('message', this.listener) }\n}\n\n/** System side: the component-only page at `PREVIEW_EMBED_PATH`. Accepts one embedding App whose origin `accept` admits. */\nexport class PreviewEmbedHost {\n readonly parentOrigin: string | null\n private readonly nonce: string | null\n private ready = false\n private readonly hello?: ReturnType<typeof setInterval>\n private readonly listener = (event: MessageEvent) => this.receive(event)\n constructor(private options: {\n accept: (origin: string) => boolean\n onInit: (init: PreviewEmbedInit) => void\n onUpdate?: (patch: Partial<Pick<PreviewEmbedInit, 'theme' | 'locale'>>) => void\n }) {\n const params = new URLSearchParams(window.location.hash.slice(1))\n this.nonce = params.get('bpe')\n let parentOrigin: string | null = null\n try { parentOrigin = new URL(params.get('po') ?? '').origin } catch {}\n this.parentOrigin = window.parent !== window && this.nonce && parentOrigin && options.accept(parentOrigin) ? parentOrigin : null\n if (!this.parentOrigin) return\n window.addEventListener('message', this.listener)\n const hello = () => window.parent.postMessage(embedEnvelope('embed.hello', { nonce: this.nonce }), this.parentOrigin!)\n hello()\n this.hello = setInterval(() => { if (!this.ready) hello() }, 250)\n }\n private receive(event: MessageEvent): void {\n if (event.source !== window.parent || event.origin !== this.parentOrigin || !isEmbedMessage(event.data)) return\n const { type, payload: p } = event.data\n if (type === 'embed.init') {\n if (p.nonce !== this.nonce || !isEmbedSource(p.source) || (p.session !== undefined && !isTransferableSession(p.session)) || typeof p.locale !== 'string') return\n this.ready = true; clearInterval(this.hello)\n this.options.onInit({ nonce: String(p.nonce), source: p.source, session: p.session as TransferableSessionContext | undefined, theme: p.theme === 'dark' ? 'dark' : 'light', locale: p.locale })\n return\n }\n if (type === 'embed.update' && this.ready) {\n const patch: Partial<Pick<PreviewEmbedInit, 'theme' | 'locale'>> = {}\n if (p.theme === 'dark' || p.theme === 'light') patch.theme = p.theme\n if (typeof p.locale === 'string') patch.locale = p.locale\n this.options.onUpdate?.(patch)\n }\n }\n private post(type: string, payload: unknown): void {\n if (this.ready && this.parentOrigin) window.parent.postMessage(embedEnvelope(type, payload), this.parentOrigin)\n }\n state(state: PreviewEmbedState): void { this.post('embed.state', state) }\n openWith(open: PreviewEmbedOpenWith): void { this.post('embed.openWith', open) }\n exit(): void { this.post('embed.exit', {}) }\n dispose(): void { clearInterval(this.hello); window.removeEventListener('message', this.listener) }\n}\n"],"names":[],"mappings":";;AAcA,MAAM,WAAW,CAAC,MAAc,SAAkB,QAA2C,CAAA,OAC1F,EAAE,UAAU,qBAAqB,SAAS,GAAG,MAAM,SAAS,GAAG,MAAM;AACxE,MAAM,YAAY,CAAC,UAA6C;AAC1D,MAAA,CAAC,SAAS,OAAO,UAAU;AAAiB,WAAA;AAChD,QAAM,IAAI;AACV,SAAO,EAAE,aAAa,uBAAuB,EAAE,YAAY,KAAK,OAAO,EAAE,SAAS,YAAY,CAAC,CAAC,EAAE,WAAW,OAAO,EAAE,YAAY;AACpI;AACO,MAAM,aAAa;AAAA,EAMxB,YAAoB,SAMjB;AANiB,SAAA,UAAA;AALZ,SAAA,QAAA;AACR,SAAA,eAAyB;AACjB,SAAA,8BAAc;AACtB,SAAQ,WAAW,CAAC,UAAwB,KAAK,QAAQ,KAAK;AAC9D,SAAQ,QAAkB;AAOd,W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AA,EACA,MAAM,OAAgC;AAAO,SAAA,KAAK,eAAe,KAAK;AAAA,EAAE;AAAA,EACxE,SAAS,MAAkC;AAAO,SAAA,KAAK,kBAAkB,IAAI;AAAA,EAAE;AAAA,EAC/E,OAAa;AAAO,SAAA,KAAK,cAAc,CAAA,CAAE;AAAA,EAAE;AAAA,EAC3C,UAAgB;AAAE,kBAAc,KAAK,KAAK;AAAU,WAAA,oBAAoB,WAAW,KAAK,QAAQ;AAAA,EAAE;AACpG;"}
package/dist/browser.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./executor_client-e026942b.js"),t=require("./namelib-f8ff0045.js"),o=e.createSDKModule("browser"),_=o.buckyos,s=o.initBuckyOS,r=o.getBuckyOSConfig,E=o.getRuntimeType,A=o.getAppId,T=o.getAppDid,p=o.getAppInstanceId,S=o.getAppDataDir,n=o.getKEventClient,i=o.createEventReader,C=o.create_event_reader,I=o.subscribeKEvent,x=o.attachEvent,a=o.removeEvent,O=o.getAccountInfo,D=o.getCurrentIdentity,R=o.loginByPassword,N=o.loginByBrowserSSO,c=o.loginByRuntimeSession,l=o.login,M=o.logout,u=o.getAppSetting,d=o.setAppSetting,P=o.getCurrentWalletUser,L=o.resolve_did,H=o.walletSignWithActiveDid,g=o.openExternalUrl,K=o.getZoneHostName,k=o.getZoneServiceURL,U=o.getServiceRpcClient,m=o.getVerifyHubClient,y=o.getSystemConfigClient,B=o.getTaskManagerClient,F=o.getWorkflowClient;exports.ACCESS_DENIED_ERROR_CODE=e.ACCESS_DENIED_ERROR_CODE,exports.AGENT_DELEGATE_TASK_SCHEMA_ID=e.AGENT_DELEGATE_TASK_SCHEMA_ID,exports.AICC_AI_METHODS=e.AICC_AI_METHODS,exports.AICC_COMPUTE_TASK_SCHEMA_ID=e.AICC_COMPUTE_TASK_SCHEMA_ID,exports.AICC_CORE_METHODS=e.AICC_CORE_METHODS,exports.AICC_EXECUTION_MODES=e.AICC_EXECUTION_MODES,exports.AICC_FEATURES=e.AICC_FEATURES,exports.AICC_MANAGEMENT_METHODS=e.AICC_MANAGEMENT_METHODS,exports.AICC_METHODS=e.AICC_METHODS,exports.AICC_POLICY_REFUSAL_CODES=e.AICC_POLICY_REFUSAL_CODES,exports.AICC_QUOTA_METHODS=e.AICC_QUOTA_METHODS,exports.AICC_SERVICE_SERVICE_NAME=e.AICC_SERVICE_SERVICE_NAME,exports.AICC_SERVICE_SERVICE_PORT=e.AICC_SERVICE_SERVICE_PORT,exports.AICC_SERVICE_UNIQUE_ID=e.AICC_SERVICE_UNIQUE_ID,exports.ANONYMOUS_IDENTITY=e.ANONYMOUS_IDENTITY,exports.APP_INSTALL_TASK_SCHEMA_ID=e.APP_INSTALL_TASK_SCHEMA_ID,exports.APP_LOGIN_EXCHANGE_METHOD=e.APP_LOGIN_EXCHANGE_METHOD,exports.APP_LOGIN_ISSUE_METHOD=e.APP_LOGIN_ISSUE_METHOD,exports.APP_LOGIN_SETTINGS_GET_METHOD=e.APP_LOGIN_SETTINGS_GET_METHOD,exports.APP_LOGIN_SETTINGS_SET_METHOD=e.APP_LOGIN_SETTINGS_SET_METHOD,exports.APP_START_TASK_SCHEMA_ID=e.APP_START_TASK_SCHEMA_ID,exports.APP_UNINSTALL_TASK_SCHEMA_ID=e.APP_UNINSTALL_TASK_SCHEMA_ID,exports.APP_UPDATE_BATCH_TASK_SCHEMA_ID=e.APP_UPDATE_BATCH_TASK_SCHEMA_ID,exports.APP_UPDATE_TASK_SCHEMA_ID=e.APP_UPDATE_TASK_SCHEMA_ID,exports.AiccClient=e.AiccClient,exports.BNS_DNS_TXT_DEFAULT_TTL=e.BNS_DNS_TXT_DEFAULT_TTL,exports.BNS_DNS_TXT_DOC_TYPE=e.BNS_DNS_TXT_DOC_TYPE,exports.BNS_EVM_DEFAULT_GAS_LIMIT=e.BNS_EVM_DEFAULT_GAS_LIMIT,exports.BNS_EVM_DEFAULT_MAX_FEE_PER_GAS=e.BNS_EVM_DEFAULT_MAX_FEE_PER_GAS,exports.BNS_EVM_DEFAULT_MAX_PRIORITY_FEE_PER_GAS=e.BNS_EVM_DEFAULT_MAX_PRIORITY_FEE_PER_GAS,exports.BNS_MAX_INLINE_DOCUMENT_BYTES=e.BNS_MAX_INLINE_DOCUMENT_BYTES,exports.BNS_PUBLISH_DOCUMENT_ABI=e.BNS_PUBLISH_DOCUMENT_ABI,exports.BS_SERVICE_TASK_MANAGER=e.BS_SERVICE_TASK_MANAGER,exports.BS_SERVICE_VERIFY_HUB=e.BS_SERVICE_VERIFY_HUB,exports.BnsEvmTxBuilder=e.BnsEvmTxBuilder,exports.BnsEvmTxError=e.BnsEvmTxError,exports.BnsTxExecutor=e.BnsTxExecutor,exports.BnsTxExecutorError=e.BnsTxExecutorError,exports.BuckyOSSDK=e.BuckyOSSDK,exports.CONTACT_CHANGED_EVENT_PATTERN=e.CONTACT_CHANGED_EVENT_PATTERN,exports.CONTACT_TAG_HOMESTATION_FOLLOWING=e.CONTACT_TAG_HOMESTATION_FOLLOWING,exports.CONTACT_TAG_ZONE_AGENT=e.CONTACT_TAG_ZONE_AGENT,exports.CONTACT_TAG_ZONE_USER=e.CONTACT_TAG_ZONE_USER,exports.DEFAULT_CHILD_CONTROL_POLICY=e.DEFAULT_CHILD_CONTROL_POLICY,exports.DEFAULT_JUMP_BASE_URL=e.DEFAULT_JUMP_BASE_URL,exports.DENY_REASONS=e.DENY_REASONS,exports.DOWNLOAD_TASK_SCHEMA_ID=e.DOWNLOAD_TASK_SCHEMA_ID,exports.EXTERNAL_PRINCIPAL_CLAIM=e.EXTERNAL_PRINCIPAL_CLAIM,exports.ExecutorClient=e.ExecutorClient,exports.ExecutorCommandStream=e.ExecutorCommandStream,exports.ExecutorStreamError=e.ExecutorStreamError,exports.FRIEND_INTENT=e.FRIEND_INTENT,exports.HUMAN_APPROVAL_SCHEMA_ID=e.HUMAN_APPROVAL_SCHEMA_ID,exports.HUMAN_INPUT_TASK_SCHEMA_ID=e.HUMAN_INPUT_TASK_SCHEMA_ID,exports.JUMP_ACTION_PATHS=e.JUMP_ACTION_PATHS,exports.KEventClient=e.KEventClient,exports.KEventReader=e.KEventReader,exports.MsgCenterClient=e.MsgCenterClient,exports.MsgQueueClient=e.MsgQueueClient,exports.NOTIFY_ACTION_ANSWER=e.NOTIFY_ACTION_ANSWER,exports.NOTIFY_ACTION_DISMISS=e.NOTIFY_ACTION_DISMISS,exports.NOTIFY_CHOICE_CONTROL_ID=e.NOTIFY_CHOICE_CONTROL_ID,exports.NOTIFY_DATA_VERSION=e.NOTIFY_DATA_VERSION,exports.NOTIFY_DELIVERED_INTENT=e.NOTIFY_DELIVERED_INTENT,exports.NOTIFY_INTENT=e.NOTIFY_INTENT,exports.NOTIFY_LINK_PATH=e.NOTIFY_LINK_PATH,exports.NOTIFY_SESSION_PREFIX=e.NOTIFY_SESSION_PREFIX,exports.NOTIFY_TEXT_CONTROL_ID=e.NOTIFY_TEXT_CONTROL_ID,exports.OPENDAN_ASYNC_TOOL_TASK_SCHEMA_ID=e.OPENDAN_ASYNC_TOOL_TASK_SCHEMA_ID,exports.OPENDAN_COMMAND_TASK_SCHEMA_ID=e.OPENDAN_COMMAND_TASK_SCHEMA_ID,exports.RAW_TASK_SCHEMA_ID=e.RAW_TASK_SCHEMA_ID,exports.RPCError=e.RPCError,exports.RepoClient=e.RepoClient,exports.RuntimeType=e.RuntimeType,exports.SCHEDULER_DISPATCH_THUNK_TASK_SCHEMA_ID=e.SCHEDULER_DISPATCH_THUNK_TASK_SCHEMA_ID,exports.StorageDomain=e.StorageDomain,exports.SystemConfigClient=e.SystemConfigClient,exports.TASK_ERR_ALREADY_COMPLETED=e.TASK_ERR_ALREADY_COMPLETED,exports.TASK_ERR_CONTROL_ALREADY_PENDING=e.TASK_ERR_CONTROL_ALREADY_PENDING,exports.TASK_ERR_CONTROL_NOT_AVAILABLE=e.TASK_ERR_CONTROL_NOT_AVAILABLE,exports.TASK_ERR_IDEMPOTENCY_CONFLICT=e.TASK_ERR_IDEMPOTENCY_CONFLICT,exports.TASK_ERR_INPUT_SCHEMA_MISMATCH=e.TASK_ERR_INPUT_SCHEMA_MISMATCH,exports.TASK_ERR_INVALID_PHASE=e.TASK_ERR_INVALID_PHASE,exports.TASK_ERR_NOT_FOUND=e.TASK_ERR_NOT_FOUND,exports.TASK_ERR_PERMISSION_DENIED=e.TASK_ERR_PERMISSION_DENIED,exports.TASK_ERR_RESULT_SCHEMA_MISMATCH=e.TASK_ERR_RESULT_SCHEMA_MISMATCH,exports.TASK_ERR_REVISION_CONFLICT=e.TASK_ERR_REVISION_CONFLICT,exports.TASK_ERR_SCHEMA_NOT_FOUND=e.TASK_ERR_SCHEMA_NOT_FOUND,exports.TASK_ERR_STALE_RUNNER_EPOCH=e.TASK_ERR_STALE_RUNNER_EPOCH,exports.TASK_MANAGER_SERVICE_NAME=e.TASK_MANAGER_SERVICE_NAME,exports.TASK_MANAGER_SERVICE_PORT=e.TASK_MANAGER_SERVICE_PORT,exports.TASK_MANAGER_SERVICE_UNIQUE_ID=e.TASK_MANAGER_SERVICE_UNIQUE_ID,exports.TASK_MGR_ERROR_CODES=e.TASK_MGR_ERROR_CODES,exports.TASK_POLICY_PRESET_COLLABORATIVE_TREE_V1=e.TASK_POLICY_PRESET_COLLABORATIVE_TREE_V1,exports.TOOL_EXEC_BASH_TASK_SCHEMA_ID=e.TOOL_EXEC_BASH_TASK_SCHEMA_ID,exports.TaskAction=e.TaskAction,exports.TaskControlAction=e.TaskControlAction,exports.TaskDataScope=e.TaskDataScope,exports.TaskEventType=e.TaskEventType,exports.TaskExecutorKind=e.TaskExecutorKind,exports.TaskGrantScope=e.TaskGrantScope,exports.TaskManagerClient=e.TaskManagerClient,exports.TaskOutcome=e.TaskOutcome,exports.TaskPhase=e.TaskPhase,exports.TaskWaitReasonKind=e.TaskWaitReasonKind,exports.USER_GROUP_REF_PREFIX=e.USER_GROUP_REF_PREFIX,exports.USER_TYPE_GROUP_REF_PREFIX=e.USER_TYPE_GROUP_REF_PREFIX,exports.VerifyHubClient=e.VerifyHubClient,exports.WEB3_BRIDGE_HOST=e.WEB3_BRIDGE_HOST,exports.WELL_KNOWN_CONTACT_TAGS=e.WELL_KNOWN_CONTACT_TAGS,exports.WORKFLOW_EXECUTE_RPC_TASK_SCHEMA_ID=e.WORKFLOW_EXECUTE_RPC_TASK_SCHEMA_ID,exports.WORKFLOW_MAP_SHARD_TASK_SCHEMA_ID=e.WORKFLOW_MAP_SHARD_TASK_SCHEMA_ID,exports.WORKFLOW_RUN_TARGET_TASK_SCHEMA_ID=e.WORKFLOW_RUN_TARGET_TASK_SCHEMA_ID,exports.WORKFLOW_RUN_TREE_TASK_SCHEMA_ID=e.WORKFLOW_RUN_TREE_TASK_SCHEMA_ID,exports.WORKFLOW_SCHEDULE_TASK_SCHEMA_ID=e.WORKFLOW_SCHEDULE_TASK_SCHEMA_ID,exports.WORKFLOW_SEND_MESSAGE_TASK_SCHEMA_ID=e.WORKFLOW_SEND_MESSAGE_TASK_SCHEMA_ID,exports.WORKFLOW_SERVICE_NAME=e.WORKFLOW_SERVICE_NAME,exports.WORKFLOW_STEP_TASK_SCHEMA_ID=e.WORKFLOW_STEP_TASK_SCHEMA_ID,exports.WORKFLOW_THUNK_TASK_SCHEMA_ID=e.WORKFLOW_THUNK_TASK_SCHEMA_ID,exports.WorkflowClient=e.WorkflowClient,exports.WorkflowDefinitionStatus=e.WorkflowDefinitionStatus,exports.WorkflowErrorCode=e.WorkflowErrorCode,exports.WorkflowHumanActionKind=e.WorkflowHumanActionKind,exports.WorkflowJoinMode=e.WorkflowJoinMode,exports.WorkflowNodeRunState=e.WorkflowNodeRunState,exports.WorkflowOutputMode=e.WorkflowOutputMode,exports.WorkflowRequestError=e.WorkflowRequestError,exports.WorkflowRetryFallback=e.WorkflowRetryFallback,exports.WorkflowRunStatus=e.WorkflowRunStatus,exports.WorkflowScheduledTaskFireStatus=e.WorkflowScheduledTaskFireStatus,exports.WorkflowScheduledTaskMisfirePolicy=e.WorkflowScheduledTaskMisfirePolicy,exports.WorkflowScheduledTaskStatus=e.WorkflowScheduledTaskStatus,exports.WorkflowStepType=e.WorkflowStepType,exports.ZONE_USER_TYPES=e.ZONE_USER_TYPES,exports.accessDenialOf=e.accessDenialOf,exports.aiccMessageFirstText=e.aiccMessageFirstText,exports.aiccMessageTextContent=e.aiccMessageTextContent,exports.aiccRefusalOf=e.aiccRefusalOf,exports.aiccTextMessage=e.aiccTextMessage,exports.answerNotify=e.answerNotify,exports.appDidFromId=e.appDidFromId,exports.appIdFromDid=e.appIdFromDid,exports.baselineTaskControlProfile=e.baselineTaskControlProfile,exports.bns=e.bns_client,exports.bucket=e.bucket_client,exports.buildJumpUrl=e.buildJumpUrl,exports.commitNotifyAnswer=e.commitNotifyAnswer,exports.completeAppAccessTokenLogin=e.completeAppAccessTokenLogin,exports.contactTagApp=e.contactTagApp,exports.contactTagKind=e.contactTagKind,exports.createAppInstanceId=e.createAppInstanceId,exports.createSDKModule=e.createSDKModule,exports.decisionRequirements=e.decisionRequirements,exports.decodeBnsPublishDocumentCalldata=e.decodeBnsPublishDocumentCalldata,exports.encodeExecutorControl=e.encodeExecutorControl,exports.getActiveRuntimeType=e.getActiveRuntimeType,exports.getActiveSessionToken=e.getActiveSessionToken,exports.getActiveZoneGatewayOrigin=e.getActiveZoneGatewayOrigin,exports.getCurrentWalletUserFromHost=e.getCurrentWalletUserFromHost,exports.identityAllows=e.identityAllows,exports.identityKey=e.identityKey,exports.inputPrompt=e.inputPrompt,exports.isAiccAiMethod=e.isAiccAiMethod,exports.isExternalPrincipal=e.isExternalPrincipal,exports.isNotifyClosed=e.isNotifyClosed,exports.isTerminalTaskPhase=e.isTerminalTaskPhase,exports.isUserGroupRefTag=e.isUserGroupRefTag,exports.issueAppCustomerLink=e.issueAppCustomerLink,exports.issueAppLoginCode=e.issueAppLoginCode,exports.loginByAppAccessToken=e.loginByAppAccessToken,exports.mailboxAddress=e.mailboxAddress,exports.mailboxResource=e.mailboxResource,exports.msgMachineData=e.msgMachineData,exports.ndm=e.ndm_client,exports.ndm_proxy=e.ndm_proxy,exports.normalizeZoneHostname=e.normalizeZoneHostname,exports.notifyAnswerToTaskResult=e.notifyAnswerToTaskResult,exports.notifyCategoryFromSessionId=e.notifyCategoryFromSessionId,exports.notifyCategorySessionId=e.notifyCategorySessionId,exports.notifyMessageData=e.notifyMessageData,exports.notifyUrl=e.notifyUrl,exports.objectUrl=e.object_url,exports.parseAccessDenial=e.parseAccessDenial,exports.parseAppId=e.parseAppId,exports.parseAppInstanceId=e.parseAppInstanceId,exports.parseAppLoginExchangeResult=e.parseAppLoginExchangeResult,exports.parseCurrentIdentity=e.parseCurrentIdentity,exports.parseSessionTokenClaims=e.parseSessionTokenClaims,exports.parseVideoPrompt=e.parseVideoPrompt,exports.parseZoneUserType=e.parseZoneUserType,exports.promptOptions=e.promptOptions,exports.randomAppLoginNonce=e.randomAppLoginNonce,exports.resolveDidFromHost=e.resolveDidFromHost,exports.sn=e.sn_client,exports.taskMgrErrorCode=e.taskMgrErrorCode,exports.taskMgrTaskEventPath=e.taskMgrTaskEventPath,exports.taskMgrTreeEventPath=e.taskMgrTreeEventPath,exports.validateAiccMessage=e.validateAiccMessage,exports.validateDecisionAnswers=e.validateDecisionAnswers,exports.validateDecisionRequest=e.validateDecisionRequest,exports.validateNotifyAnswer=e.validateNotifyAnswer,exports.validateVideoEdit=e.validateVideoEdit,exports.validateVideoGeneration=e.validateVideoGeneration,exports.validateVideoOutput=e.validateVideoOutput,exports.videoGenerationRequirement=e.videoGenerationRequirement,exports.waitNotify=e.waitNotify,exports.walletUserHasSnAccount=e.walletUserHasSnAccount,exports.zoneActionUrl=e.zoneActionUrl,exports.DID_OBJECT_SERVICE_ID=t.DID_OBJECT_SERVICE_ID,exports.DID_OBJECT_SERVICE_TYPE=t.DID_OBJECT_SERVICE_TYPE,exports.NODE_IDENTITY_SCHEMA_V2=t.NODE_IDENTITY_SCHEMA_V2,exports.getDidIdentifier=t.getDidIdentifier,exports.getDidMethod=t.getDidMethod,exports.hashPassword=t.hashPassword,exports.isBuckyOSAgentDocument=t.isBuckyOSAgentDocument,exports.isBuckyOSDIDObjectCard=t.isBuckyOSDIDObjectCard,exports.isBuckyOSDeviceDocument=t.isBuckyOSDeviceDocument,exports.isBuckyOSDeviceMiniDocument=t.isBuckyOSDeviceMiniDocument,exports.isBuckyOSLocalNodeIdentityConfig=t.isBuckyOSLocalNodeIdentityConfig,exports.isBuckyOSOwnerDocument=t.isBuckyOSOwnerDocument,exports.isBuckyOSZoneBootDocument=t.isBuckyOSZoneBootDocument,exports.isBuckyOSZoneConfig=t.isBuckyOSZoneConfig,exports.isBuckyOSZoneDocument=t.isBuckyOSZoneDocument,exports.isW3CDIDDocumentBase=t.isW3CDIDDocumentBase,exports.namelib=t.namelib,exports.ndn=t.ndn_types,exports.parseBuckyOSDIDDocument=t.parseBuckyOSDIDDocument,exports.parseBuckyOSDeviceMiniDocument=t.parseBuckyOSDeviceMiniDocument,exports.parseBuckyOSOwnerDocument=t.parseBuckyOSOwnerDocument,exports.parseW3CDIDDocumentBase=t.parseW3CDIDDocumentBase,exports.attachEvent=x,exports.buckyos=_,exports.createEventReader=i,exports.create_event_reader=C,exports.getAccountInfo=O,exports.getAppDataDir=S,exports.getAppDid=T,exports.getAppId=A,exports.getAppInstanceId=p,exports.getAppSetting=u,exports.getBuckyOSConfig=r,exports.getCurrentIdentity=D,exports.getCurrentWalletUser=P,exports.getKEventClient=n,exports.getRuntimeType=E,exports.getServiceRpcClient=U,exports.getSystemConfigClient=y,exports.getTaskManagerClient=B,exports.getVerifyHubClient=m,exports.getWorkflowClient=F,exports.getZoneHostName=K,exports.getZoneServiceURL=k,exports.initBuckyOS=s,exports.login=l,exports.loginByBrowserSSO=N,exports.loginByPassword=R,exports.loginByRuntimeSession=c,exports.logout=M,exports.openExternalUrl=g,exports.removeEvent=a,exports.resolve_did=L,exports.setAppSetting=d,exports.subscribeKEvent=I,exports.walletSignWithActiveDid=H;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./executor_client-d4439d54.js"),t=require("./account-b12ac6b9.js"),o=require("./ndn_types-5b138882.js"),_=require("./object_url-8fb5a7bf.js"),r=require("./did_object_client-6a1b108a.js"),s=require("./krpc_client-26c2dc8b.js");require("./content_mime-dc80d960.js");const E=e.createSDKModule("browser"),A=E.buckyos,T=E.initBuckyOS,S=E.getBuckyOSConfig,p=E.getRuntimeType,n=E.getAppId,i=E.getAppDid,C=E.getAppInstanceId,I=E.getAppDataDir,O=E.getKEventClient,x=E.createEventReader,a=E.create_event_reader,R=E.subscribeKEvent,D=E.attachEvent,N=E.removeEvent,c=E.getAccountInfo,M=E.getCurrentIdentity,l=E.loginByPassword,u=E.loginByBrowserSSO,d=E.loginByRuntimeSession,P=E.login,L=E.logout,H=E.getAppSetting,g=E.setAppSetting,K=E.getCurrentWalletUser,U=E.resolve_did,k=E.walletSignWithActiveDid,m=E.openExternalUrl,y=E.getZoneHostName,B=E.getZoneServiceURL,F=E.getServiceRpcClient,W=E.getVerifyHubClient,f=E.getSystemConfigClient,G=E.getTaskManagerClient,v=E.getWorkflowClient;exports.ACCESS_DENIED_ERROR_CODE=e.ACCESS_DENIED_ERROR_CODE,exports.AGENT_DELEGATE_TASK_SCHEMA_ID=e.AGENT_DELEGATE_TASK_SCHEMA_ID,exports.AICC_AI_METHODS=e.AICC_AI_METHODS,exports.AICC_COMPUTE_TASK_SCHEMA_ID=e.AICC_COMPUTE_TASK_SCHEMA_ID,exports.AICC_CORE_METHODS=e.AICC_CORE_METHODS,exports.AICC_EXECUTION_MODES=e.AICC_EXECUTION_MODES,exports.AICC_FEATURES=e.AICC_FEATURES,exports.AICC_MANAGEMENT_METHODS=e.AICC_MANAGEMENT_METHODS,exports.AICC_METHODS=e.AICC_METHODS,exports.AICC_POLICY_REFUSAL_CODES=e.AICC_POLICY_REFUSAL_CODES,exports.AICC_QUOTA_METHODS=e.AICC_QUOTA_METHODS,exports.AICC_SERVICE_SERVICE_NAME=e.AICC_SERVICE_SERVICE_NAME,exports.AICC_SERVICE_SERVICE_PORT=e.AICC_SERVICE_SERVICE_PORT,exports.AICC_SERVICE_UNIQUE_ID=e.AICC_SERVICE_UNIQUE_ID,exports.ANONYMOUS_IDENTITY=e.ANONYMOUS_IDENTITY,exports.APP_INSTALL_TASK_SCHEMA_ID=e.APP_INSTALL_TASK_SCHEMA_ID,exports.APP_LOGIN_EXCHANGE_METHOD=e.APP_LOGIN_EXCHANGE_METHOD,exports.APP_LOGIN_ISSUE_METHOD=e.APP_LOGIN_ISSUE_METHOD,exports.APP_LOGIN_SETTINGS_GET_METHOD=e.APP_LOGIN_SETTINGS_GET_METHOD,exports.APP_LOGIN_SETTINGS_SET_METHOD=e.APP_LOGIN_SETTINGS_SET_METHOD,exports.APP_START_TASK_SCHEMA_ID=e.APP_START_TASK_SCHEMA_ID,exports.APP_UNINSTALL_TASK_SCHEMA_ID=e.APP_UNINSTALL_TASK_SCHEMA_ID,exports.APP_UPDATE_BATCH_TASK_SCHEMA_ID=e.APP_UPDATE_BATCH_TASK_SCHEMA_ID,exports.APP_UPDATE_TASK_SCHEMA_ID=e.APP_UPDATE_TASK_SCHEMA_ID,exports.AiccClient=e.AiccClient,exports.BNS_DNS_TXT_DEFAULT_TTL=e.BNS_DNS_TXT_DEFAULT_TTL,exports.BNS_DNS_TXT_DOC_TYPE=e.BNS_DNS_TXT_DOC_TYPE,exports.BNS_EVM_DEFAULT_GAS_LIMIT=e.BNS_EVM_DEFAULT_GAS_LIMIT,exports.BNS_EVM_DEFAULT_MAX_FEE_PER_GAS=e.BNS_EVM_DEFAULT_MAX_FEE_PER_GAS,exports.BNS_EVM_DEFAULT_MAX_PRIORITY_FEE_PER_GAS=e.BNS_EVM_DEFAULT_MAX_PRIORITY_FEE_PER_GAS,exports.BNS_MAX_INLINE_DOCUMENT_BYTES=e.BNS_MAX_INLINE_DOCUMENT_BYTES,exports.BNS_PUBLISH_DOCUMENT_ABI=e.BNS_PUBLISH_DOCUMENT_ABI,exports.BS_SERVICE_TASK_MANAGER=e.BS_SERVICE_TASK_MANAGER,exports.BS_SERVICE_VERIFY_HUB=e.BS_SERVICE_VERIFY_HUB,exports.BnsEvmTxBuilder=e.BnsEvmTxBuilder,exports.BnsEvmTxError=e.BnsEvmTxError,exports.BnsTxExecutor=e.BnsTxExecutor,exports.BnsTxExecutorError=e.BnsTxExecutorError,exports.BuckyOSSDK=e.BuckyOSSDK,exports.COMPUTER_ELEMENT_ACTIONS=e.COMPUTER_ELEMENT_ACTIONS,exports.COMPUTER_ELEMENT_STATES=e.COMPUTER_ELEMENT_STATES,exports.COMPUTER_ROLES=e.COMPUTER_ROLES,exports.COMPUTER_SEMANTIC_FORMAT=e.COMPUTER_SEMANTIC_FORMAT,exports.CONTACT_CHANGED_EVENT_PATTERN=e.CONTACT_CHANGED_EVENT_PATTERN,exports.CONTACT_TAG_HOMESTATION_FOLLOWING=e.CONTACT_TAG_HOMESTATION_FOLLOWING,exports.CONTACT_TAG_ZONE_AGENT=e.CONTACT_TAG_ZONE_AGENT,exports.CONTACT_TAG_ZONE_USER=e.CONTACT_TAG_ZONE_USER,exports.DEFAULT_CHILD_CONTROL_POLICY=e.DEFAULT_CHILD_CONTROL_POLICY,exports.DEFAULT_JUMP_BASE_URL=e.DEFAULT_JUMP_BASE_URL,exports.DENY_REASONS=e.DENY_REASONS,exports.DOWNLOAD_TASK_SCHEMA_ID=e.DOWNLOAD_TASK_SCHEMA_ID,exports.EXTERNAL_PRINCIPAL_CLAIM=e.EXTERNAL_PRINCIPAL_CLAIM,exports.ExecutorClient=e.ExecutorClient,exports.ExecutorCommandStream=e.ExecutorCommandStream,exports.ExecutorStreamError=e.ExecutorStreamError,exports.FRIEND_INTENT=e.FRIEND_INTENT,exports.HUMAN_APPROVAL_SCHEMA_ID=e.HUMAN_APPROVAL_SCHEMA_ID,exports.HUMAN_INPUT_TASK_SCHEMA_ID=e.HUMAN_INPUT_TASK_SCHEMA_ID,exports.JUMP_ACTION_PATHS=e.JUMP_ACTION_PATHS,exports.KEventClient=e.KEventClient,exports.KEventReader=e.KEventReader,exports.MsgCenterClient=e.MsgCenterClient,exports.MsgQueueClient=e.MsgQueueClient,exports.NOTIFY_ACTION_ANSWER=e.NOTIFY_ACTION_ANSWER,exports.NOTIFY_ACTION_DISMISS=e.NOTIFY_ACTION_DISMISS,exports.NOTIFY_CHOICE_CONTROL_ID=e.NOTIFY_CHOICE_CONTROL_ID,exports.NOTIFY_DATA_VERSION=e.NOTIFY_DATA_VERSION,exports.NOTIFY_DELIVERED_INTENT=e.NOTIFY_DELIVERED_INTENT,exports.NOTIFY_INTENT=e.NOTIFY_INTENT,exports.NOTIFY_LINK_PATH=e.NOTIFY_LINK_PATH,exports.NOTIFY_SESSION_PREFIX=e.NOTIFY_SESSION_PREFIX,exports.NOTIFY_TEXT_CONTROL_ID=e.NOTIFY_TEXT_CONTROL_ID,exports.OPENDAN_ASYNC_TOOL_TASK_SCHEMA_ID=e.OPENDAN_ASYNC_TOOL_TASK_SCHEMA_ID,exports.OPENDAN_COMMAND_TASK_SCHEMA_ID=e.OPENDAN_COMMAND_TASK_SCHEMA_ID,exports.RAW_TASK_SCHEMA_ID=e.RAW_TASK_SCHEMA_ID,exports.RepoClient=e.RepoClient,exports.RuntimeType=e.RuntimeType,exports.SCHEDULER_DISPATCH_THUNK_TASK_SCHEMA_ID=e.SCHEDULER_DISPATCH_THUNK_TASK_SCHEMA_ID,exports.StorageDomain=e.StorageDomain,exports.SystemConfigClient=e.SystemConfigClient,exports.TASK_ERR_ALREADY_COMPLETED=e.TASK_ERR_ALREADY_COMPLETED,exports.TASK_ERR_CONTROL_ALREADY_PENDING=e.TASK_ERR_CONTROL_ALREADY_PENDING,exports.TASK_ERR_CONTROL_NOT_AVAILABLE=e.TASK_ERR_CONTROL_NOT_AVAILABLE,exports.TASK_ERR_IDEMPOTENCY_CONFLICT=e.TASK_ERR_IDEMPOTENCY_CONFLICT,exports.TASK_ERR_INPUT_SCHEMA_MISMATCH=e.TASK_ERR_INPUT_SCHEMA_MISMATCH,exports.TASK_ERR_INVALID_PHASE=e.TASK_ERR_INVALID_PHASE,exports.TASK_ERR_NOT_FOUND=e.TASK_ERR_NOT_FOUND,exports.TASK_ERR_PERMISSION_DENIED=e.TASK_ERR_PERMISSION_DENIED,exports.TASK_ERR_RESULT_SCHEMA_MISMATCH=e.TASK_ERR_RESULT_SCHEMA_MISMATCH,exports.TASK_ERR_REVISION_CONFLICT=e.TASK_ERR_REVISION_CONFLICT,exports.TASK_ERR_SCHEMA_NOT_FOUND=e.TASK_ERR_SCHEMA_NOT_FOUND,exports.TASK_ERR_STALE_RUNNER_EPOCH=e.TASK_ERR_STALE_RUNNER_EPOCH,exports.TASK_MANAGER_SERVICE_NAME=e.TASK_MANAGER_SERVICE_NAME,exports.TASK_MANAGER_SERVICE_PORT=e.TASK_MANAGER_SERVICE_PORT,exports.TASK_MANAGER_SERVICE_UNIQUE_ID=e.TASK_MANAGER_SERVICE_UNIQUE_ID,exports.TASK_MGR_ERROR_CODES=e.TASK_MGR_ERROR_CODES,exports.TASK_POLICY_PRESET_COLLABORATIVE_TREE_V1=e.TASK_POLICY_PRESET_COLLABORATIVE_TREE_V1,exports.TOOL_EXEC_BASH_TASK_SCHEMA_ID=e.TOOL_EXEC_BASH_TASK_SCHEMA_ID,exports.TaskAction=e.TaskAction,exports.TaskControlAction=e.TaskControlAction,exports.TaskDataScope=e.TaskDataScope,exports.TaskEventType=e.TaskEventType,exports.TaskExecutorKind=e.TaskExecutorKind,exports.TaskGrantScope=e.TaskGrantScope,exports.TaskManagerClient=e.TaskManagerClient,exports.TaskOutcome=e.TaskOutcome,exports.TaskPhase=e.TaskPhase,exports.TaskWaitReasonKind=e.TaskWaitReasonKind,exports.USER_GROUP_REF_PREFIX=e.USER_GROUP_REF_PREFIX,exports.USER_TYPE_GROUP_REF_PREFIX=e.USER_TYPE_GROUP_REF_PREFIX,exports.VerifyHubClient=e.VerifyHubClient,exports.WEB3_BRIDGE_HOST=e.WEB3_BRIDGE_HOST,exports.WELL_KNOWN_CONTACT_TAGS=e.WELL_KNOWN_CONTACT_TAGS,exports.WORKFLOW_EXECUTE_RPC_TASK_SCHEMA_ID=e.WORKFLOW_EXECUTE_RPC_TASK_SCHEMA_ID,exports.WORKFLOW_MAP_SHARD_TASK_SCHEMA_ID=e.WORKFLOW_MAP_SHARD_TASK_SCHEMA_ID,exports.WORKFLOW_RUN_TARGET_TASK_SCHEMA_ID=e.WORKFLOW_RUN_TARGET_TASK_SCHEMA_ID,exports.WORKFLOW_RUN_TREE_TASK_SCHEMA_ID=e.WORKFLOW_RUN_TREE_TASK_SCHEMA_ID,exports.WORKFLOW_SCHEDULE_TASK_SCHEMA_ID=e.WORKFLOW_SCHEDULE_TASK_SCHEMA_ID,exports.WORKFLOW_SEND_MESSAGE_TASK_SCHEMA_ID=e.WORKFLOW_SEND_MESSAGE_TASK_SCHEMA_ID,exports.WORKFLOW_SERVICE_NAME=e.WORKFLOW_SERVICE_NAME,exports.WORKFLOW_STEP_TASK_SCHEMA_ID=e.WORKFLOW_STEP_TASK_SCHEMA_ID,exports.WORKFLOW_THUNK_TASK_SCHEMA_ID=e.WORKFLOW_THUNK_TASK_SCHEMA_ID,exports.WorkflowClient=e.WorkflowClient,exports.WorkflowDefinitionStatus=e.WorkflowDefinitionStatus,exports.WorkflowErrorCode=e.WorkflowErrorCode,exports.WorkflowHumanActionKind=e.WorkflowHumanActionKind,exports.WorkflowJoinMode=e.WorkflowJoinMode,exports.WorkflowNodeRunState=e.WorkflowNodeRunState,exports.WorkflowOutputMode=e.WorkflowOutputMode,exports.WorkflowRequestError=e.WorkflowRequestError,exports.WorkflowRetryFallback=e.WorkflowRetryFallback,exports.WorkflowRunStatus=e.WorkflowRunStatus,exports.WorkflowScheduledTaskFireStatus=e.WorkflowScheduledTaskFireStatus,exports.WorkflowScheduledTaskMisfirePolicy=e.WorkflowScheduledTaskMisfirePolicy,exports.WorkflowScheduledTaskStatus=e.WorkflowScheduledTaskStatus,exports.WorkflowStepType=e.WorkflowStepType,exports.ZONE_USER_TYPES=e.ZONE_USER_TYPES,exports.accessDenialOf=e.accessDenialOf,exports.aiccMessageFirstText=e.aiccMessageFirstText,exports.aiccMessageTextContent=e.aiccMessageTextContent,exports.aiccRefusalOf=e.aiccRefusalOf,exports.aiccTextMessage=e.aiccTextMessage,exports.answerNotify=e.answerNotify,exports.appDidFromId=e.appDidFromId,exports.appIdFromDid=e.appIdFromDid,exports.baselineTaskControlProfile=e.baselineTaskControlProfile,exports.bns=e.bns_client,exports.bucket=e.bucket_client,exports.buildJumpUrl=e.buildJumpUrl,exports.commitNotifyAnswer=e.commitNotifyAnswer,exports.completeAppAccessTokenLogin=e.completeAppAccessTokenLogin,exports.contactTagApp=e.contactTagApp,exports.contactTagKind=e.contactTagKind,exports.createAppInstanceId=e.createAppInstanceId,exports.createSDKModule=e.createSDKModule,exports.decisionRequirements=e.decisionRequirements,exports.decodeBnsPublishDocumentCalldata=e.decodeBnsPublishDocumentCalldata,exports.encodeExecutorControl=e.encodeExecutorControl,exports.getActiveRuntimeType=e.getActiveRuntimeType,exports.getActiveSessionToken=e.getActiveSessionToken,exports.getActiveZoneGatewayOrigin=e.getActiveZoneGatewayOrigin,exports.getCurrentWalletUserFromHost=e.getCurrentWalletUserFromHost,exports.identityAllows=e.identityAllows,exports.identityKey=e.identityKey,exports.inputPrompt=e.inputPrompt,exports.isAiccAiMethod=e.isAiccAiMethod,exports.isExternalPrincipal=e.isExternalPrincipal,exports.isNotifyClosed=e.isNotifyClosed,exports.isTerminalTaskPhase=e.isTerminalTaskPhase,exports.isUserGroupRefTag=e.isUserGroupRefTag,exports.issueAppCustomerLink=e.issueAppCustomerLink,exports.issueAppLoginCode=e.issueAppLoginCode,exports.loginByAppAccessToken=e.loginByAppAccessToken,exports.mailboxAddress=e.mailboxAddress,exports.mailboxResource=e.mailboxResource,exports.msgMachineData=e.msgMachineData,exports.ndm=e.ndm_client,exports.ndm_proxy=e.ndm_proxy,exports.ndn=e.ndn,exports.normalizeZoneHostname=e.normalizeZoneHostname,exports.notifyAnswerToTaskResult=e.notifyAnswerToTaskResult,exports.notifyCategoryFromSessionId=e.notifyCategoryFromSessionId,exports.notifyCategorySessionId=e.notifyCategorySessionId,exports.notifyMessageData=e.notifyMessageData,exports.notifyUrl=e.notifyUrl,exports.parseAccessDenial=e.parseAccessDenial,exports.parseAppId=e.parseAppId,exports.parseAppInstanceId=e.parseAppInstanceId,exports.parseAppLoginExchangeResult=e.parseAppLoginExchangeResult,exports.parseCurrentIdentity=e.parseCurrentIdentity,exports.parseSessionTokenClaims=e.parseSessionTokenClaims,exports.parseVideoPrompt=e.parseVideoPrompt,exports.parseZoneUserType=e.parseZoneUserType,exports.promptOptions=e.promptOptions,exports.randomAppLoginNonce=e.randomAppLoginNonce,exports.resolveDidFromHost=e.resolveDidFromHost,exports.sn=e.sn_client,exports.taskMgrErrorCode=e.taskMgrErrorCode,exports.taskMgrTaskEventPath=e.taskMgrTaskEventPath,exports.taskMgrTreeEventPath=e.taskMgrTreeEventPath,exports.validateAiccMessage=e.validateAiccMessage,exports.validateDecisionAnswers=e.validateDecisionAnswers,exports.validateDecisionRequest=e.validateDecisionRequest,exports.validateNotifyAnswer=e.validateNotifyAnswer,exports.validateVideoEdit=e.validateVideoEdit,exports.validateVideoGeneration=e.validateVideoGeneration,exports.validateVideoOutput=e.validateVideoOutput,exports.videoGenerationRequirement=e.videoGenerationRequirement,exports.waitNotify=e.waitNotify,exports.walletUserHasSnAccount=e.walletUserHasSnAccount,exports.zoneActionUrl=e.zoneActionUrl,exports.hashPassword=t.hashPassword,exports.DID_OBJECT_SERVICE_ID=o.DID_OBJECT_SERVICE_ID,exports.DID_OBJECT_SERVICE_TYPE=o.DID_OBJECT_SERVICE_TYPE,exports.NODE_IDENTITY_SCHEMA_V2=o.NODE_IDENTITY_SCHEMA_V2,exports.getDidIdentifier=o.getDidIdentifier,exports.getDidMethod=o.getDidMethod,exports.isBuckyOSAgentDocument=o.isBuckyOSAgentDocument,exports.isBuckyOSDIDObjectCard=o.isBuckyOSDIDObjectCard,exports.isBuckyOSDeviceDocument=o.isBuckyOSDeviceDocument,exports.isBuckyOSDeviceMiniDocument=o.isBuckyOSDeviceMiniDocument,exports.isBuckyOSLocalNodeIdentityConfig=o.isBuckyOSLocalNodeIdentityConfig,exports.isBuckyOSOwnerDocument=o.isBuckyOSOwnerDocument,exports.isBuckyOSZoneBootDocument=o.isBuckyOSZoneBootDocument,exports.isBuckyOSZoneConfig=o.isBuckyOSZoneConfig,exports.isBuckyOSZoneDocument=o.isBuckyOSZoneDocument,exports.isW3CDIDDocumentBase=o.isW3CDIDDocumentBase,exports.namelib=o.namelib,exports.parseBuckyOSDIDDocument=o.parseBuckyOSDIDDocument,exports.parseBuckyOSDeviceMiniDocument=o.parseBuckyOSDeviceMiniDocument,exports.parseBuckyOSOwnerDocument=o.parseBuckyOSOwnerDocument,exports.parseW3CDIDDocumentBase=o.parseW3CDIDDocumentBase,exports.objectUrl=_.object_url,exports.DIDObjectClient=r.DIDObjectClient,exports.DIDObjectError=r.DIDObjectError,exports.RPCError=s.RPCError,exports.attachEvent=D,exports.buckyos=A,exports.createEventReader=x,exports.create_event_reader=a,exports.getAccountInfo=c,exports.getAppDataDir=I,exports.getAppDid=i,exports.getAppId=n,exports.getAppInstanceId=C,exports.getAppSetting=H,exports.getBuckyOSConfig=S,exports.getCurrentIdentity=M,exports.getCurrentWalletUser=K,exports.getKEventClient=O,exports.getRuntimeType=p,exports.getServiceRpcClient=F,exports.getSystemConfigClient=f,exports.getTaskManagerClient=G,exports.getVerifyHubClient=W,exports.getWorkflowClient=v,exports.getZoneHostName=y,exports.getZoneServiceURL=B,exports.initBuckyOS=T,exports.login=P,exports.loginByBrowserSSO=u,exports.loginByPassword=l,exports.loginByRuntimeSession=d,exports.logout=L,exports.openExternalUrl=m,exports.removeEvent=N,exports.resolve_did=U,exports.setAppSetting=g,exports.subscribeKEvent=R,exports.walletSignWithActiveDid=k;
2
2
  //# sourceMappingURL=browser.cjs.map