buckyos 0.7.170 → 0.7.177

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 (220) 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/aiworkspace_client.d.ts +36 -2
  22. package/dist/aiworkspace_client.d.ts.map +1 -1
  23. package/dist/app-frame.cjs +1 -1
  24. package/dist/app-frame.cjs.map +1 -1
  25. package/dist/app-frame.d.ts +56 -1
  26. package/dist/app-frame.d.ts.map +1 -1
  27. package/dist/app-frame.mjs +285 -4
  28. package/dist/app-frame.mjs.map +1 -1
  29. package/dist/browser.cjs +1 -1
  30. package/dist/browser.cjs.map +1 -1
  31. package/dist/browser.d.ts +4 -0
  32. package/dist/browser.d.ts.map +1 -1
  33. package/dist/browser.mjs +218 -194
  34. package/dist/browser.mjs.map +1 -1
  35. package/dist/content.cjs +1 -1
  36. package/dist/content.cjs.map +1 -1
  37. package/dist/content.d.ts +77 -0
  38. package/dist/content.d.ts.map +1 -1
  39. package/dist/content.mjs +65 -0
  40. package/dist/content.mjs.map +1 -1
  41. package/dist/content_objid-1aff74b6.js +2 -0
  42. package/dist/content_objid-1aff74b6.js.map +1 -0
  43. package/dist/content_objid-9232bcaf.mjs +29 -0
  44. package/dist/content_objid-9232bcaf.mjs.map +1 -0
  45. package/dist/content_objid.d.ts +15 -0
  46. package/dist/content_objid.d.ts.map +1 -0
  47. package/dist/did_object_client-6a1b108a.js +2 -0
  48. package/dist/did_object_client-6a1b108a.js.map +1 -0
  49. package/dist/did_object_client-7fa36f90.mjs +87 -0
  50. package/dist/did_object_client-7fa36f90.mjs.map +1 -0
  51. package/dist/did_object_client.d.ts +39 -0
  52. package/dist/did_object_client.d.ts.map +1 -0
  53. package/dist/executor_client-7ce0ddc7.js +13 -0
  54. package/dist/executor_client-7ce0ddc7.js.map +1 -0
  55. package/dist/{executor_client-5f4d0468.mjs → executor_client-bfc8a1e1.mjs} +308 -752
  56. package/dist/executor_client-bfc8a1e1.mjs.map +1 -0
  57. package/dist/executor_client.d.ts +129 -0
  58. package/dist/executor_client.d.ts.map +1 -1
  59. package/dist/index.cjs +1 -1
  60. package/dist/index.cjs.map +1 -1
  61. package/dist/index.d.ts +3 -0
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.mjs +218 -199
  64. package/dist/index.mjs.map +1 -1
  65. package/dist/internal/command_args.d.ts +67 -0
  66. package/dist/internal/command_args.d.ts.map +1 -0
  67. package/dist/krpc_client-26c2dc8b.js +2 -0
  68. package/dist/krpc_client-26c2dc8b.js.map +1 -0
  69. package/dist/krpc_client-673448e5.mjs +173 -0
  70. package/dist/krpc_client-673448e5.mjs.map +1 -0
  71. package/dist/krpc_client.d.ts +5 -1
  72. package/dist/krpc_client.d.ts.map +1 -1
  73. package/dist/{ndn_types-ab30fac0.mjs → ndn_types-0fac2499.mjs} +115 -215
  74. package/dist/ndn_types-0fac2499.mjs.map +1 -0
  75. package/dist/ndn_types-5b138882.js +2 -0
  76. package/dist/ndn_types-5b138882.js.map +1 -0
  77. package/dist/node.cjs +1 -1
  78. package/dist/node.cjs.map +1 -1
  79. package/dist/node.mjs +201 -194
  80. package/dist/node.mjs.map +1 -1
  81. package/dist/object_url-8fb5a7bf.js +2 -0
  82. package/dist/object_url-8fb5a7bf.js.map +1 -0
  83. package/dist/object_url-f72c1704.mjs +412 -0
  84. package/dist/object_url-f72c1704.mjs.map +1 -0
  85. package/dist/openai-ae2978de.mjs +163 -0
  86. package/dist/openai-ae2978de.mjs.map +1 -0
  87. package/dist/openai-f560d518.js +2 -0
  88. package/dist/openai-f560d518.js.map +1 -0
  89. package/dist/provision.cjs +6 -6
  90. package/dist/provision.cjs.map +1 -1
  91. package/dist/provision.mjs +4 -3
  92. package/dist/provision.mjs.map +1 -1
  93. package/dist/site_manager-11a7a468.mjs +6410 -0
  94. package/dist/site_manager-11a7a468.mjs.map +1 -0
  95. package/dist/site_manager-334b1a51.js +2 -0
  96. package/dist/site_manager-334b1a51.js.map +1 -0
  97. package/dist/{tus_client-b231b248.js → tus_client-809c90ab.js} +2 -2
  98. package/dist/{tus_client-b231b248.js.map → tus_client-809c90ab.js.map} +1 -1
  99. package/dist/{tus_client-d1ffe2d6.mjs → tus_client-893a3287.mjs} +2 -2
  100. package/dist/{tus_client-d1ffe2d6.mjs.map → tus_client-893a3287.mjs.map} +1 -1
  101. package/dist/xllm/core/action_parser.d.ts +15 -0
  102. package/dist/xllm/core/action_parser.d.ts.map +1 -0
  103. package/dist/xllm/core/behavior_loop.d.ts +20 -0
  104. package/dist/xllm/core/behavior_loop.d.ts.map +1 -0
  105. package/dist/xllm/core/behavior_result.d.ts +11 -0
  106. package/dist/xllm/core/behavior_result.d.ts.map +1 -0
  107. package/dist/xllm/core/config.d.ts +62 -0
  108. package/dist/xllm/core/config.d.ts.map +1 -0
  109. package/dist/xllm/core/context_window.d.ts +15 -0
  110. package/dist/xllm/core/context_window.d.ts.map +1 -0
  111. package/dist/xllm/core/deps.d.ts +97 -0
  112. package/dist/xllm/core/deps.d.ts.map +1 -0
  113. package/dist/xllm/core/errors.d.ts +94 -0
  114. package/dist/xllm/core/errors.d.ts.map +1 -0
  115. package/dist/xllm/core/interrupt.d.ts +31 -0
  116. package/dist/xllm/core/interrupt.d.ts.map +1 -0
  117. package/dist/xllm/core/json.d.ts +11 -0
  118. package/dist/xllm/core/json.d.ts.map +1 -0
  119. package/dist/xllm/core/json_check.d.ts +17 -0
  120. package/dist/xllm/core/json_check.d.ts.map +1 -0
  121. package/dist/xllm/core/loop.d.ts +135 -0
  122. package/dist/xllm/core/loop.d.ts.map +1 -0
  123. package/dist/xllm/core/messages.d.ts +18 -0
  124. package/dist/xllm/core/messages.d.ts.map +1 -0
  125. package/dist/xllm/core/observer.d.ts +14 -0
  126. package/dist/xllm/core/observer.d.ts.map +1 -0
  127. package/dist/xllm/core/open_runtime.d.ts +22 -0
  128. package/dist/xllm/core/open_runtime.d.ts.map +1 -0
  129. package/dist/xllm/core/prepare.d.ts +54 -0
  130. package/dist/xllm/core/prepare.d.ts.map +1 -0
  131. package/dist/xllm/core/prompt.d.ts +40 -0
  132. package/dist/xllm/core/prompt.d.ts.map +1 -0
  133. package/dist/xllm/core/protocol.d.ts +15 -0
  134. package/dist/xllm/core/protocol.d.ts.map +1 -0
  135. package/dist/xllm/core/result.d.ts +12 -0
  136. package/dist/xllm/core/result.d.ts.map +1 -0
  137. package/dist/xllm/core/run.d.ts +198 -0
  138. package/dist/xllm/core/run.d.ts.map +1 -0
  139. package/dist/xllm/core/rust_text.d.ts +20 -0
  140. package/dist/xllm/core/rust_text.d.ts.map +1 -0
  141. package/dist/xllm/core/site_policy.d.ts +5 -0
  142. package/dist/xllm/core/site_policy.d.ts.map +1 -0
  143. package/dist/xllm/core/store.d.ts +60 -0
  144. package/dist/xllm/core/store.d.ts.map +1 -0
  145. package/dist/xllm/core/suspension.d.ts +13 -0
  146. package/dist/xllm/core/suspension.d.ts.map +1 -0
  147. package/dist/xllm/core/tokenizer.d.ts +8 -0
  148. package/dist/xllm/core/tokenizer.d.ts.map +1 -0
  149. package/dist/xllm/core/types.d.ts +826 -0
  150. package/dist/xllm/core/types.d.ts.map +1 -0
  151. package/dist/xllm/core/xml.d.ts +19 -0
  152. package/dist/xllm/core/xml.d.ts.map +1 -0
  153. package/dist/xllm/dev/openai.d.ts +17 -0
  154. package/dist/xllm/dev/openai.d.ts.map +1 -0
  155. package/dist/xllm/dev/scripted.d.ts +46 -0
  156. package/dist/xllm/dev/scripted.d.ts.map +1 -0
  157. package/dist/xllm/dev.d.ts +5 -0
  158. package/dist/xllm/dev.d.ts.map +1 -0
  159. package/dist/xllm/hosts/browser/store.d.ts +41 -0
  160. package/dist/xllm/hosts/browser/store.d.ts.map +1 -0
  161. package/dist/xllm/hosts/deno/deno_api.d.ts +103 -0
  162. package/dist/xllm/hosts/deno/deno_api.d.ts.map +1 -0
  163. package/dist/xllm/hosts/deno/identity.d.ts +29 -0
  164. package/dist/xllm/hosts/deno/identity.d.ts.map +1 -0
  165. package/dist/xllm/hosts/deno/index.d.ts +47 -0
  166. package/dist/xllm/hosts/deno/index.d.ts.map +1 -0
  167. package/dist/xllm/hosts/deno/native_runtime.d.ts +93 -0
  168. package/dist/xllm/hosts/deno/native_runtime.d.ts.map +1 -0
  169. package/dist/xllm/hosts/deno/native_tools.d.ts +105 -0
  170. package/dist/xllm/hosts/deno/native_tools.d.ts.map +1 -0
  171. package/dist/xllm/hosts/deno/provider.d.ts +13 -0
  172. package/dist/xllm/hosts/deno/provider.d.ts.map +1 -0
  173. package/dist/xllm/hosts/deno/store.d.ts +60 -0
  174. package/dist/xllm/hosts/deno/store.d.ts.map +1 -0
  175. package/dist/xllm/index.d.ts +48 -0
  176. package/dist/xllm/index.d.ts.map +1 -0
  177. package/dist/xllm/providers/aicc.d.ts +22 -0
  178. package/dist/xllm/providers/aicc.d.ts.map +1 -0
  179. package/dist/xllm/providers/timeout.d.ts +12 -0
  180. package/dist/xllm/providers/timeout.d.ts.map +1 -0
  181. package/dist/xllm/runtime/compress.d.ts +149 -0
  182. package/dist/xllm/runtime/compress.d.ts.map +1 -0
  183. package/dist/xllm/runtime/did_object_resources.d.ts +21 -0
  184. package/dist/xllm/runtime/did_object_resources.d.ts.map +1 -0
  185. package/dist/xllm/runtime/hints.d.ts +23 -0
  186. package/dist/xllm/runtime/hints.d.ts.map +1 -0
  187. package/dist/xllm/runtime/site.d.ts +22 -0
  188. package/dist/xllm/runtime/site.d.ts.map +1 -0
  189. package/dist/xllm/runtime/site_manager.d.ts +38 -0
  190. package/dist/xllm/runtime/site_manager.d.ts.map +1 -0
  191. package/dist/xllm/runtime/site_tools.d.ts +76 -0
  192. package/dist/xllm/runtime/site_tools.d.ts.map +1 -0
  193. package/dist/xllm/runtime/step_renderer.d.ts +54 -0
  194. package/dist/xllm/runtime/step_renderer.d.ts.map +1 -0
  195. package/dist/xllm/runtime/task_model.d.ts +64 -0
  196. package/dist/xllm/runtime/task_model.d.ts.map +1 -0
  197. package/dist/xllm/runtime/tool_result.d.ts +39 -0
  198. package/dist/xllm/runtime/tool_result.d.ts.map +1 -0
  199. package/dist/xllm/runtime/types.d.ts +99 -0
  200. package/dist/xllm/runtime/types.d.ts.map +1 -0
  201. package/dist/xllm.cjs +2 -0
  202. package/dist/xllm.cjs.map +1 -0
  203. package/dist/xllm.mjs +1167 -0
  204. package/dist/xllm.mjs.map +1 -0
  205. package/dist/xllm_deno.cjs +2 -0
  206. package/dist/xllm_deno.cjs.map +1 -0
  207. package/dist/xllm_deno.mjs +2487 -0
  208. package/dist/xllm_deno.mjs.map +1 -0
  209. package/dist/xllm_dev.cjs +2 -0
  210. package/dist/xllm_dev.cjs.map +1 -0
  211. package/dist/xllm_dev.mjs +70 -0
  212. package/dist/xllm_dev.mjs.map +1 -0
  213. package/package.json +22 -1
  214. package/src/internal/command_args.ts +268 -0
  215. package/dist/executor_client-1ee523cf.js +0 -13
  216. package/dist/executor_client-1ee523cf.js.map +0 -1
  217. package/dist/executor_client-5f4d0468.mjs.map +0 -1
  218. package/dist/ndn_types-8c2696d5.js +0 -2
  219. package/dist/ndn_types-8c2696d5.js.map +0 -1
  220. package/dist/ndn_types-ab30fac0.mjs.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,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+B,iBAAxB8H,EAAYhI,QAAuBgI,EAAYhI,QAAUwC,EAAcwF,EAAYhI,SACvFiI,GAAA,EACV,MACF,IAAK,QACH/H,EAAO8H,EAAYvL,QACTwL,GAAA,EACV,MACF,IAAK,YACCD,EAAY3K,gBACP6C,EAAA,+BAA+B8H,EAAYjK,SACxCkK,GAAA,IAEH/H,EAAA,eAAe8H,EAAYjK,SACxBkK,GAAA,GAEZ,MACF,IAAK,aACI/H,EAAA8H,EAAY3K,eAAiB,gCAAgC2K,EAAYjK,SAAW,kBAAkBiK,EAAYjK,SAC/GkK,GAAA,EAMd,MAAO,CAAEL,KAAM,OAAQ5H,QAAS,CAHYiI,EACxC,CAAEhI,KAAM,cAAe6H,QAASC,EAAQ/H,QAAS,CAAC,CAAEC,KAAM,OAAQC,SAASgI,UAAU,GACrF,CAAEjI,KAAM,cAAe6H,QAASC,EAAQ/H,QAAS,CAAC,CAAEC,KAAM,OAAQC,WAExE,2BA3CO,SAA0B6F,GAC/B,MAAMoC,EAAIpC,EAAStJ,QACf,IAAC0L,GAAgB,cAAXA,EAAEP,KAA6B,MAAA,iDAA2CO,WAAGP,OACvF,IAAA,MAAW7H,KAAKoI,EAAEnI,SAAW,GAAI,CAC/B,IAAK,CAAC,OAAQ,QAAS,WAAY,WAAY,WAAY,kBAAkBgD,SAASjD,EAAEE,MAC/E,MAAA,iBAAiBF,EAAEE,0BAE5B,GAAe,aAAXF,EAAEE,OAAwBN,EAASI,EAAE+H,SAAW,IAAY,MAAA,2BAClE,CAEF"}
@@ -250,6 +250,38 @@ export interface AiwsRunReport {
250
250
  assumptions?: string[];
251
251
  analysis?: Record<string, unknown>;
252
252
  }
253
+ /** One request of `doc.stage` / `doc.commit` stays under the service's 8 MiB body limit. */
254
+ export declare const AIWS_COMMIT_PART_BYTES: number;
255
+ /** What one Commit may hold once its parts are assembled (aiworkspace-core `Limits`). */
256
+ export declare const AIWS_COMMIT_MAX_BYTES: number;
257
+ export declare const AIWS_COMMIT_MAX_OPERATIONS = 50000;
258
+ export type AiwsCall = (method: string, params: Record<string, unknown>) => Promise<unknown>;
259
+ export interface AiwsCommitPartsOptions {
260
+ /** Largest serialized size of the operations of one request (default `AIWS_COMMIT_PART_BYTES`). */
261
+ partBytes?: number;
262
+ /** Called before request `part` of `total` is sent (1-based; the last one is the commit itself). Only when
263
+ * the Commit is sent in more than one request. */
264
+ onPart?: (part: number, total: number) => void;
265
+ /** `doc.prepare` instead of `doc.commit` (the parts it stages expire on their own). */
266
+ method?: 'doc.commit' | 'doc.prepare';
267
+ }
268
+ /** `operations` cut into runs of at most `partBytes` serialized bytes, in order; an operation larger than that
269
+ * is a run of its own. */
270
+ export declare function splitCommitOperations<T>(operations: T[], partBytes?: number): T[][];
271
+ /** Whether a Commit of these operations is within what the service assembles (`null`), or which limit it passes. */
272
+ export declare function commitOverLimit(operations: unknown[]): {
273
+ limit: 'operations' | 'bytes';
274
+ value: number;
275
+ max: number;
276
+ } | null;
277
+ /**
278
+ * Send one Commit, whatever its size: a request whose operations fit `partBytes` is one `doc.commit`; a larger one
279
+ * has its leading parts held by `doc.stage` and the last part sent as `doc.commit { staged: [digests] }`, which the
280
+ * service assembles into the same single Commit (one transaction, one undo unit). Every call stages all parts again,
281
+ * so resending the same request after an unknown result is safe. The three-state result is returned as it is; a
282
+ * refused `doc.stage` comes back as a `rejected` result.
283
+ */
284
+ export declare function commitWithParts<T = Record<string, unknown>>(call: AiwsCall, request: Record<string, unknown>, options?: AiwsCommitPartsOptions): Promise<T>;
253
285
  /**
254
286
  * kRPC client of the AI Workspace service (`/kapi/aiworkspace`). Every method takes the business result out of
255
287
  * `result` and throws `AiwsFailure` on `{ ok: false }`; commits return the three-state result as it is.
@@ -268,9 +300,11 @@ export declare class AiWorkspaceClient {
268
300
  read(workspace_id: string, entity_id: string, selector?: Record<string, unknown>): Promise<Record<string, unknown>>;
269
301
  query(workspace_id: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
270
302
  outline(workspace_id: string): Promise<Record<string, unknown>>;
303
+ private raw;
271
304
  prepare(workspace_id: string, request: Record<string, unknown>): Promise<Record<string, unknown>>;
272
- /** The three-state commit result (`status: accepted | conflict | rejected`), never thrown. */
273
- commit(workspace_id: string, request: Record<string, unknown>): Promise<Record<string, unknown>>;
305
+ /** The three-state commit result (`status: accepted | conflict | rejected`), never thrown. One call per Commit
306
+ * whatever its size (up to `AIWS_COMMIT_MAX_BYTES` / `AIWS_COMMIT_MAX_OPERATIONS`): a large one is sent in parts. */
307
+ commit(workspace_id: string, request: Record<string, unknown>, options?: Pick<AiwsCommitPartsOptions, 'partBytes' | 'onPart'>): Promise<Record<string, unknown>>;
274
308
  getSubmission(workspace_id: string, epoch: string, idempotency_key: string): Promise<Record<string, unknown>>;
275
309
  /** Changes after `after_seq` (`filter.detail: "touched"` for the touched entities only). */
276
310
  getChanges(workspace_id: string, epoch: string, after_seq: number, opts?: {
@@ -1 +1 @@
1
- {"version":3,"file":"aiworkspace_client.d.ts","sourceRoot":"","sources":["../src/aiworkspace_client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE/C,eAAO,MAAM,wBAAwB,gBAAgB,CAAA;AAErD,2HAA2H;AAC3H,MAAM,WAAW,SAAS;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE;AAClH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,CAAC,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAA;AAEhF,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC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AC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,EAAE,MAAM;IAGxG,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAG9E,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;IAG9D,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gBACzE,MAAM;iBAAW,MAAM;mBAAa,MAAM;qBAAe,MAAM;kBAAY,MAAM;;IAE9G,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAGtG,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa;IACrD,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;IAGvF,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAC/C"}
@@ -1,2 +1,2 @@
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}};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./content.cjs");require("./content_mime-dc80d960.js");const t=t=>e.SYSTEM_DIALOG_ERROR_CODES.includes(t)?t:"protocol",i=(e,t,i={})=>({protocol:"buckyos.app-frame",version:1,type:e,payload:t,...i}),o=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 n="buckyos.preview-embed",s=(e,t,i=n)=>({protocol:i,version:1,type:e,payload:t}),r=(e,t=n)=>{const i=e;return!!i&&i.protocol===t&&1===i.version&&"string"==typeof i.type&&!!i.payload&&"object"==typeof i.payload},a="/embed/preview";const l="buckyos.sysdlg-embed",d="/embed/sysdlg/select";let c=!1;function p(i,o,n={}){var a,p;if(null==(a=n.signal)?void 0:a.aborted)return Promise.reject(new e.SystemDialogError("closed"));if(c)return Promise.reject(new e.SystemDialogError("busy"));c=!0;const h=new URL(i).origin,u=n.locale??navigator.language??"en",m=n.theme??((null==(p=window.matchMedia)?void 0:p.call(window,"(prefers-color-scheme: dark)").matches)?"dark":"light"),g=u.toLowerCase().startsWith("zh");return new Promise(((i,a)=>{var p;const y=document.body,f=document.documentElement,w=document.activeElement instanceof HTMLElement?document.activeElement:null,b={x:window.scrollX,y:window.scrollY},v={body:y.getAttribute("style"),html:f.getAttribute("style")},E=Array.from(y.children).filter((e=>e instanceof HTMLElement)).map((e=>({el:e,inert:e.inert,hidden:e.getAttribute("aria-hidden")}))),T=document.createElement("div");let L;T.setAttribute("data-buckyos-sysdlg","select"),T.setAttribute("role","dialog"),T.setAttribute("aria-modal","true"),T.setAttribute("aria-label",g?"文件选择器":"File picker"),T.style.cssText="position:fixed;inset:0;height:100vh;height:100dvh;z-index:2147483647;background:rgba(0,0,0,.32);display:flex;align-items:center;justify-content:center";let k,x="",C=!1;const O=e=>{T.contains(e.target)||(e.stopPropagation(),e.preventDefault())},A=["keydown","pointerdown","mousedown","touchstart","wheel"],S=()=>{var e;return!C&&(C=!0,c=!1,clearTimeout(k),window.removeEventListener("message",M),null==(e=n.signal)||e.removeEventListener("abort",R),"inert"in HTMLElement.prototype||A.forEach((e=>document.removeEventListener(e,O,!0))),T.remove(),E.forEach((({el:e,inert:t,hidden:i})=>{e.inert=t,null===i?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",i)})),null===v.body?y.removeAttribute("style"):y.setAttribute("style",v.body),null===v.html?f.removeAttribute("style"):f.setAttribute("style",v.html),window.scrollTo(b.x,b.y),null==w||w.focus({preventScroll:!0}),!0)},D=t=>{S()&&a(new e.SystemDialogError(t))},R=()=>D("closed"),I=()=>{null==L||L.remove(),L=void 0;const e=document.createElement("div");e.setAttribute("role","alert"),e.style.cssText=`max-width:22rem;margin:1rem;padding:1.25rem;border-radius:16px;font:14px/1.6 system-ui,sans-serif;background:${"dark"===m?"#1f2329":"#fff"};color:${"dark"===m?"#f2f3f5":"#1f2329"};box-shadow:0 24px 64px rgba(0,0,0,.24)`;const t=document.createElement("p");t.style.margin="0 0 1rem",t.textContent=g?"无法加载文件选择器":"Unable to load the file picker";const i=document.createElement("div");i.style.cssText="display:flex;gap:.5rem;justify-content:flex-end";const o=(e,t)=>{const o=document.createElement("button");return o.type="button",o.textContent=e,o.style.cssText="min-height:2.25rem;padding:0 1rem;font:inherit;border-radius:999px;border:1px solid currentColor;background:transparent;color:inherit;cursor:pointer",o.addEventListener("click",t),i.append(o),o};o(g?"取消":"Cancel",(()=>D("load_failed")));const n=o(g?"重试":"Retry",(()=>{e.remove(),U()}));e.append(t,i),T.append(e),n.focus()},U=()=>{x=crypto.randomUUID(),L=document.createElement("iframe"),L.title=g?"文件选择器":"File picker",L.style.cssText="position:absolute;inset:0;width:100%;height:100%;border:0;background:transparent;color-scheme:normal",L.setAttribute("allowtransparency","true"),L.addEventListener("error",I),L.src=`${h}${d}#bse=${x}&po=${encodeURIComponent(window.location.origin)}`,T.append(L),k=setTimeout(I,1e4)},M=n=>{var a;if(!L||n.origin!==h||n.source!==L.contentWindow||!r(n.data,l))return;const{type:d,payload:c}=n.data;if("embed.hello"===d){if(c.nonce!==x)return;clearTimeout(k),null==(a=L.contentWindow)||a.postMessage(s("embed.init",{nonce:x,params:o,theme:m,locale:u},l),h),L.focus()}if("embed.error"===d&&D(t(c.code)),"embed.result"===d){const t=e.readSelectDialogResult(c.result,{allowLocal:!0===o.allowLocal});t?(e=>{S()&&i(e)})(t):D("protocol")}};window.addEventListener("message",M),null==(p=n.signal)||p.addEventListener("abort",R,{once:!0}),"inert"in HTMLElement.prototype?E.forEach((({el:e})=>{e.inert=!0})):(E.forEach((({el:e})=>e.setAttribute("aria-hidden","true"))),A.forEach((e=>document.addEventListener(e,O,!0)))),f.style.overflow="hidden",y.style.position="fixed",y.style.top=-b.y+"px",y.style.left=-b.x+"px",y.style.right="0",y.style.overflow="hidden",y.append(T),U()}))}exports.AppFrameClient=class{constructor(e){if(this.options=e,this.listener=e=>{this.receive(e)},this.dialogs=new Map,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 t=()=>window.parent.postMessage(i("frame.hello",{nonce:this.nonce,appCapabilities:[...e.onOpen?["open"]:[],...e.onBeforeClose?["beforeClose"]:[],...e.onBack?["back"]:[]]}),this.origin);t(),this.helloTimer=setInterval(t,250),this.helloDeadline=setTimeout((()=>clearInterval(this.helloTimer)),1500)}}async receive(n){var s,r,a,l,d,c,p,h,u,m,g,y,f,w;if(n.source!==window.parent||n.origin!==this.origin||!o(n.data))return;const b=n.data,v=b.payload;if("frame.init"===b.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==(r=(s=this.options).onInit)||r.call(s,this.init))}if(!this.init)return;if("sysdlg.openResult"===b.type){const i=b.replyTo?this.dialogs.get(b.replyTo):void 0;if(!i)return;if(this.dialogs.delete(b.replyTo),!0!==v.ok)return i.reject(new e.SystemDialogError(t(v.code)));const o=e.readSelectDialogResult(v.result,{allowLocal:i.allowLocal});return void(o?i.resolve(o):i.reject(new e.SystemDialogError("protocol")))}const E=e=>window.parent.postMessage(i(b.type+"Result",e,{replyTo:b.id}),this.origin);try{"frame.open"===b.type&&e.isOpenRequest(v.request)&&E(await(null==(l=(a=this.options).onOpen)?void 0:l.call(a,v.request))??{accepted:!1}),"frame.beforeClose"===b.type&&E({decision:await(null==(c=(d=this.options).onBeforeClose)?void 0:c.call(d,v.reason))??"allow"}),"frame.back"===b.type&&E({handled:await(null==(h=(p=this.options).onBack)?void 0:h.call(p))??!1}),"frame.themeChanged"!==b.type||"dark"!==v.mode&&"light"!==v.mode||null==(m=(u=this.options).onTheme)||m.call(u,v),"frame.localeChanged"===b.type&&"string"==typeof v.locale&&(null==(y=(g=this.options).onLocale)||y.call(g,v.locale)),"frame.focusChanged"===b.type&&this.focused!==(!0===v.focused)&&(this.focused=!0===v.focused,null==(w=(f=this.options).onFocus)||w.call(f,this.focused))}catch{"frame.open"===b.type&&E({accepted:!1,fallback:"preview"}),"frame.beforeClose"===b.type&&E({decision:"deny"})}}send(e,t){this.init&&window.parent.postMessage(i(e,t),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",o={}){const n=o.hints??{};return this.init?(this.send("content.open",{request:t,target:i,newWindow:!0===o.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)}selectContent(t={},o={}){var n,s;if(this.init){if(!this.init.shellCapabilities.includes(e.SELECT_DIALOG_PATH))return Promise.reject(new e.SystemDialogError("unsupported"));if(this.dialogs.size)return Promise.reject(new e.SystemDialogError("busy"));const o=crypto.randomUUID();return new Promise(((n,s)=>{this.dialogs.set(o,{resolve:n,reject:s,allowLocal:!0===t.allowLocal}),window.parent.postMessage(i("sysdlg.open",{path:e.SELECT_DIALOG_PATH,params:t},{id:o}),this.origin)}))}if(!this.options.systemOrigin)return Promise.reject(new e.SystemDialogError("unsupported"));const r=this.embedAbort=new AbortController;return null==(n=o.signal)||n.addEventListener("abort",(()=>r.abort()),{once:!0}),(null==(s=o.signal)?void 0:s.aborted)&&r.abort(),p(this.options.systemOrigin,t,{...o,signal:r.signal})}dispose(){var t;clearInterval(this.helloTimer),clearTimeout(this.helloDeadline),window.removeEventListener("message",this.listener),this.dialogs.forEach((t=>t.reject(new e.SystemDialogError("closed")))),this.dialogs.clear(),null==(t=this.embedAbort)||t.abort()}},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=[],this.dialogOpen=!1,window.addEventListener("message",this.listener)}async systemDialog(t,o,n){const s=e=>{var o;this.ready&&(null==(o=this.options.target())||o.postMessage(i("sysdlg.openResult",e,{replyTo:t}),this.options.origin))};if(!this.options.onSystemDialog||"string"!=typeof o)return s({ok:!1,code:"unsupported"});if(this.dialogOpen)return s({ok:!1,code:"busy"});this.dialogOpen=!0;try{s(await this.options.onSystemDialog(o,n))}catch(r){s({ok:!1,code:r instanceof e.SystemDialogError?r.code:"closed"})}finally{this.dialogOpen=!1}}receive(t){var i,n,s,r,a,l,d,c;if(t.source!==this.options.target()||t.origin!==this.options.origin||!o(t.data))return;const p=t.data,h=p.payload;if("frame.hello"===p.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=(i=this.options).onReady)||n.call(i))}if(this.ready)if(p.replyTo){const e=this.pending.get(p.replyTo);e&&p.type===e.type+"Result"&&(clearTimeout(e.timer),this.pending.delete(p.replyTo),e.resolve(p.payload))}else if("window.setTitle"===p.type&&"string"==typeof h.title&&(null==(r=(s=this.options).onTitle)||r.call(s,h.title.slice(0,256),!0===h.dirty)),"window.requestClose"===p.type&&(null==(l=(a=this.options).onRequestClose)||l.call(a)),"sysdlg.open"===p.type&&"string"==typeof p.id&&this.systemDialog(p.id,h.path,h.params),"content.open"===p.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=(d=this.options).onContentOpen)||c.call(d,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,t){var o;this.ready&&(null==(o=this.options.target())||o.postMessage(i(e,t),this.options.origin))}request(e,t,o=3e3){if(!this.ready)return Promise.reject(new Error("App frame is not ready"));const n=crypto.randomUUID();return new Promise(((s,r)=>{var a;const l=setTimeout((()=>{this.pending.delete(n),r(new Error("App frame timed out"))}),o);this.pending.set(n,{resolve:s,reject:r,timer:l,type:e}),null==(a=this.options.target())||a.postMessage(i(e,t,{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=a,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}${a}#bpe=${this.nonce}&po=${encodeURIComponent(window.location.origin)}`,window.addEventListener("message",this.listener)}post(e,t){var i,o;null==(o=null==(i=this.options.frame())?void 0:i.contentWindow)||o.postMessage(s(e,t),this.origin)}receive(t){var i,o,n,s,a,l,d;if(t.origin!==this.origin||t.source!==(null==(i=this.options.frame())?void 0:i.contentWindow)||!r(t.data))return;const{type:c,payload:p}=t.data;if("embed.hello"!==c){if("embed.state"===c&&("loading"===p.status||"ready"===p.status||"error"===p.status)){const e=p.error;null==(n=(o=this.options).onState)||n.call(o,{status:p.status,error:e&&"string"==typeof e.kind&&"string"==typeof e.code?{kind:e.kind,code:e.code}:void 0,title:"string"==typeof p.title?p.title.slice(0,256):void 0,mediaType:"string"==typeof p.mediaType?p.mediaType.slice(0,128):void 0})}if("embed.openWith"===c){const t=p.request;t&&e.isTransferableRef(t.source)&&(void 0===t.session||e.isTransferableSession(t.session))&&(null==(a=(s=this.options).onOpenWith)||a.call(s,{request:{source:t.source,session:t.session},hints:e.readContentHints(p.hints)}))}"embed.exit"===c&&(null==(d=(l=this.options).onExit)||d.call(l))}else p.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 o=()=>window.parent.postMessage(s("embed.hello",{nonce:this.nonce}),this.parentOrigin);o(),this.hello=setInterval((()=>{this.ready||o()}),250)}receive(t){var i,o;if(t.source!==window.parent||t.origin!==this.parentOrigin||!r(t.data))return;const{type:n,payload:s}=t.data;if("embed.init"===n){if(s.nonce!==this.nonce||(a=s.source,!(e.isTransferableRef(a)||a&&"object"==typeof a&&"blob"===a.kind&&"undefined"!=typeof Blob&&a.blob instanceof Blob&&"string"==typeof a.name))||void 0!==s.session&&!e.isTransferableSession(s.session)||"string"!=typeof s.locale)return;return this.ready=!0,clearInterval(this.hello),void this.options.onInit({nonce:String(s.nonce),source:s.source,session:s.session,theme:"dark"===s.theme?"dark":"light",locale:s.locale})}var a;if("embed.update"===n&&this.ready){const e={};"dark"!==s.theme&&"light"!==s.theme||(e.theme=s.theme),"string"==typeof s.locale&&(e.locale=s.locale),null==(o=(i=this.options).onUpdate)||o.call(i,e)}}post(e,t){this.ready&&this.parentOrigin&&window.parent.postMessage(s(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.SELECT_EMBED_PATH=d,exports.SelectEmbedHost=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("bse");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 o=()=>window.parent.postMessage(s("embed.hello",{nonce:this.nonce},l),this.parentOrigin);o(),this.hello=setInterval((()=>{this.ready||o()}),250)}receive(e){if(e.source!==window.parent||e.origin!==this.parentOrigin||!r(e.data,l))return;const{type:t,payload:i}=e.data;"embed.init"!==t||this.ready||i.nonce!==this.nonce||"string"!=typeof i.locale||(this.ready=!0,clearInterval(this.hello),this.options.onInit({nonce:String(i.nonce),params:i.params,theme:"dark"===i.theme?"dark":"light",locale:i.locale}))}post(e,t){this.ready&&this.parentOrigin&&window.parent.postMessage(s(e,t,l),this.parentOrigin)}result(e){this.post("embed.result",{result:e})}error(e){this.post("embed.error",{code:e})}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 o of i)if(o)try{const t=new URL(o).origin;if(e(t))return t}catch{}return null},exports.openSelectEmbed=p,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":"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,KAAsB,CAAEE,SAAUK,EAAeJ,QAAS,EAAGJ,OAAMC,YAClGS,EAAkBJ,IACtB,MAAMC,EAAID,EACV,QAASC,GAAKA,EAAEJ,WAAaK,GAA+B,IAAdD,EAAEH,SAAmC,iBAAXG,EAAEP,QAAuBO,EAAEN,SAAgC,iBAAdM,EAAEN,OAAY,EAKxHU,EAAqB,wCArH3B,MASL,WAAAC,CAAoBC,GAiBlB,GAjBkBC,KAAAD,QAAAA,EADHC,KAAAC,SAAYC,IAA+BF,KAAKG,QAAQD,EAAK,EAe5EF,KAAKI,OAAS,IAAIC,IAAIN,EAAQO,aAAaF,OACtCJ,KAAAO,MAAQ,IAAIC,gBAAgBC,OAAOC,SAASC,KAAKC,MAAM,IAAIC,IAAI,OAC7DJ,OAAAK,iBAAiB,UAAWd,KAAKC,UACpCQ,OAAOM,SAAWN,QAAUT,KAAKO,MAAO,CACpC,MAAAS,EAAQ,IAAMP,OAAOM,OAAOE,YAAYhC,EAAS,cAAe,CAAEsB,MAAOP,KAAKO,MAAOW,gBAAiB,IACvGnB,EAAQoB,OAAS,CAAC,QAAU,MAAOpB,EAAQqB,cAAgB,CAAC,eAAiB,MAAOrB,EAAQsB,OAA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,EAAAzC,KAAAD,SAAQsJ,WAAW7G,EAAAG,KAAAF,EAAAoG,EAC1B,CACF,CACQ,IAAAd,CAAK7I,EAAcC,GACrBa,KAAKuF,OAASvF,KAAK+I,cAActI,OAAOM,OAAOE,YAAYtB,EAAcT,EAAMC,GAAUa,KAAK+I,aACpG,CACA,KAAAO,CAAMA,GAAuCtJ,KAAA+H,KAAK,cAAeuB,EAAO,CACxE,QAAAC,CAAStE,GAAyCjF,KAAA+H,KAAK,iBAAkB9C,EAAM,CAC/E,IAAAuE,GAAoBxJ,KAAA+H,KAAK,aAAc,CAAA,EAAI,CAC3C,OAAA1C,GAAkB3D,cAAc1B,KAAKgB,OAAeP,OAAA6E,oBAAoB,UAAWtF,KAAKC,SAAU,0BAtO7F,SAAwB+I,SAC7B,GAAIvI,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
+ {"version":3,"file":"app-frame.cjs","sources":["../src/app-frame.ts"],"sourcesContent":["import { isOpenRequest, isTransferableRef, isTransferableSession, readContentHints, readSelectDialogResult, systemOpenUrl, SELECT_DIALOG_PATH, SystemDialogError, SYSTEM_DIALOG_ERROR_CODES, type ContentHints, type ContentOpenTarget, type OpenRequest, type SelectDialogParams, type SelectDialogResult, type SystemDialogErrorCode, type TransferableContentRef, type TransferableSessionContext } from './content'\nexport type SystemDialogReply = { ok: true; result: unknown } | { ok: false; code: SystemDialogErrorCode }\nconst dialogErrorCode = (value: unknown): SystemDialogErrorCode =>\n SYSTEM_DIALOG_ERROR_CODES.includes(value as SystemDialogErrorCode) ? value as SystemDialogErrorCode : 'protocol'\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 /** Shows a system dialog the App asked for (`sysdlg.open`). `params` is untrusted input: validate it. */\n onSystemDialog?: (path: string, params: unknown) => Promise<SystemDialogReply>\n }) { window.addEventListener('message', this.listener) }\n private focused?: boolean\n private dialogOpen = false\n private async systemDialog(id: string, path: unknown, params: unknown): Promise<void> {\n const reply = (payload: SystemDialogReply) => { if (this.ready) this.options.target()?.postMessage(envelope('sysdlg.openResult', payload, { replyTo: id }), this.options.origin) }\n if (!this.options.onSystemDialog || typeof path !== 'string') return reply({ ok: false, code: 'unsupported' })\n if (this.dialogOpen) return reply({ ok: false, code: 'busy' })\n this.dialogOpen = true\n try { reply(await this.options.onSystemDialog(path, params)) }\n catch (error) { reply({ ok: false, code: error instanceof SystemDialogError ? error.code : 'closed' }) }\n finally { this.dialogOpen = false }\n }\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 === 'sysdlg.open' && typeof m.id === 'string') void this.systemDialog(m.id, p.path, p.params)\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 private dialogs = new Map<string, { resolve: (result: SelectDialogResult) => void; reject: (error: Error) => void; allowLocal: boolean }>()\n private embedAbort?: AbortController\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 if (m.type === 'sysdlg.openResult') {\n const pending = m.replyTo ? this.dialogs.get(m.replyTo) : undefined\n if (!pending) return\n this.dialogs.delete(m.replyTo!)\n if (p.ok !== true) return pending.reject(new SystemDialogError(dialogErrorCode(p.code)))\n const result = readSelectDialogResult(p.result, { allowLocal: pending.allowLocal })\n if (result) pending.resolve(result)\n else pending.reject(new SystemDialogError('protocol'))\n return\n }\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 /**\n * Shows the system file picker (`sysdlg/select`) and resolves with what the user chose; cancelling resolves with\n * `{ action: 'cancelled' }`. Embedded in the shell the shell draws the dialog over this App's window; in a\n * standalone tab the picker page of the Zone's system entry (`systemOrigin`) is framed over this page. Rejects\n * with a `SystemDialogError` when no picker is available or the request did not complete.\n */\n selectContent(params: SelectDialogParams = {}, options: { signal?: AbortSignal; theme?: 'light' | 'dark'; locale?: string } = {}): Promise<SelectDialogResult> {\n if (this.init) {\n if (!this.init.shellCapabilities.includes(SELECT_DIALOG_PATH)) return Promise.reject(new SystemDialogError('unsupported'))\n if (this.dialogs.size) return Promise.reject(new SystemDialogError('busy'))\n const id = crypto.randomUUID()\n return new Promise((resolve, reject) => {\n this.dialogs.set(id, { resolve, reject, allowLocal: params.allowLocal === true })\n window.parent.postMessage(envelope('sysdlg.open', { path: SELECT_DIALOG_PATH, params }, { id }), this.origin)\n })\n }\n if (!this.options.systemOrigin) return Promise.reject(new SystemDialogError('unsupported'))\n const abort = this.embedAbort = new AbortController()\n options.signal?.addEventListener('abort', () => abort.abort(), { once: true })\n if (options.signal?.aborted) abort.abort()\n return openSelectEmbed(this.options.systemOrigin, params, { ...options, signal: abort.signal })\n }\n dispose(): void {\n clearInterval(this.helloTimer); clearTimeout(this.helloDeadline); window.removeEventListener('message', this.listener)\n this.dialogs.forEach(pending => pending.reject(new SystemDialogError('closed')))\n this.dialogs.clear(); this.embedAbort?.abort()\n }\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) => ({ protocol, version: 1, type, payload })\nconst isEmbedMessage = (value: unknown, protocol = PREVIEW_EMBED): 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 === protocol && 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\n/**\n * System dialog embed protocol (`buckyos.sysdlg-embed` v1): a standalone App page (no shell) shows the system file\n * picker by framing `<systemOrigin>/embed/sysdlg/select` over itself. The handshake is the Preview embed's\n * (`embed.hello` → `embed.init`); the system page browses with its own Zone-root session and answers with\n * `embed.result`. No token crosses origins, and every message names its exact target origin.\n */\nconst SYSDLG_EMBED = 'buckyos.sysdlg-embed'\nexport const SELECT_EMBED_PATH = '/embed/sysdlg/select'\nexport interface SelectEmbedInit { nonce: string; params: unknown; theme: 'light' | 'dark'; locale: string }\nlet selectEmbedOpen = false\n\n/** App side of `buckyos.sysdlg-embed`: the full-page layer that frames the picker. One at a time per page. */\nexport function openSelectEmbed(systemOrigin: string, params: SelectDialogParams, options: { signal?: AbortSignal; theme?: 'light' | 'dark'; locale?: string } = {}): Promise<SelectDialogResult> {\n if (options.signal?.aborted) return Promise.reject(new SystemDialogError('closed'))\n if (selectEmbedOpen) return Promise.reject(new SystemDialogError('busy'))\n selectEmbedOpen = true\n const origin = new URL(systemOrigin).origin\n const locale = options.locale ?? navigator.language ?? 'en'\n const theme = options.theme ?? (window.matchMedia?.('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')\n const zh = locale.toLowerCase().startsWith('zh')\n return new Promise((resolve, reject) => {\n const body = document.body\n const html = document.documentElement\n const focused = document.activeElement instanceof HTMLElement ? document.activeElement : null\n const scroll = { x: window.scrollX, y: window.scrollY }\n const saved = { body: body.getAttribute('style'), html: html.getAttribute('style') }\n const siblings = Array.from(body.children).filter((el): el is HTMLElement => el instanceof HTMLElement)\n .map(el => ({ el, inert: el.inert, hidden: el.getAttribute('aria-hidden') }))\n const root = document.createElement('div')\n root.setAttribute('data-buckyos-sysdlg', 'select')\n root.setAttribute('role', 'dialog'); root.setAttribute('aria-modal', 'true')\n root.setAttribute('aria-label', zh ? '文件选择器' : 'File picker')\n root.style.cssText = 'position:fixed;inset:0;height:100vh;height:100dvh;z-index:2147483647;background:rgba(0,0,0,.32);display:flex;align-items:center;justify-content:center'\n let frame: HTMLIFrameElement | undefined\n let nonce = ''\n let timer: ReturnType<typeof setTimeout> | undefined\n let done = false\n const block = (event: Event) => { if (!root.contains(event.target as Node)) { event.stopPropagation(); event.preventDefault() } }\n const blocked = ['keydown', 'pointerdown', 'mousedown', 'touchstart', 'wheel'] as const\n const cleanup = () => {\n if (done) return false\n done = true; selectEmbedOpen = false\n clearTimeout(timer)\n window.removeEventListener('message', receive)\n options.signal?.removeEventListener('abort', abort)\n if (!('inert' in HTMLElement.prototype)) blocked.forEach(type => document.removeEventListener(type, block, true))\n root.remove()\n siblings.forEach(({ el, inert, hidden }) => { el.inert = inert; if (hidden === null) el.removeAttribute('aria-hidden'); else el.setAttribute('aria-hidden', hidden) })\n if (saved.body === null) body.removeAttribute('style'); else body.setAttribute('style', saved.body)\n if (saved.html === null) html.removeAttribute('style'); else html.setAttribute('style', saved.html)\n window.scrollTo(scroll.x, scroll.y)\n focused?.focus({ preventScroll: true })\n return true\n }\n const finish = (result: SelectDialogResult) => { if (cleanup()) resolve(result) }\n const fail = (code: SystemDialogErrorCode) => { if (cleanup()) reject(new SystemDialogError(code)) }\n const abort = () => fail('closed')\n const showFailure = () => {\n frame?.remove(); frame = undefined\n const panel = document.createElement('div')\n panel.setAttribute('role', 'alert')\n panel.style.cssText = `max-width:22rem;margin:1rem;padding:1.25rem;border-radius:16px;font:14px/1.6 system-ui,sans-serif;background:${theme === 'dark' ? '#1f2329' : '#fff'};color:${theme === 'dark' ? '#f2f3f5' : '#1f2329'};box-shadow:0 24px 64px rgba(0,0,0,.24)`\n const text = document.createElement('p')\n text.style.margin = '0 0 1rem'\n text.textContent = zh ? '无法加载文件选择器' : 'Unable to load the file picker'\n const actions = document.createElement('div')\n actions.style.cssText = 'display:flex;gap:.5rem;justify-content:flex-end'\n const button = (label: string, action: () => void) => {\n const el = document.createElement('button')\n el.type = 'button'; el.textContent = label\n el.style.cssText = 'min-height:2.25rem;padding:0 1rem;font:inherit;border-radius:999px;border:1px solid currentColor;background:transparent;color:inherit;cursor:pointer'\n el.addEventListener('click', action); actions.append(el); return el\n }\n button(zh ? '取消' : 'Cancel', () => fail('load_failed'))\n const retry = button(zh ? '重试' : 'Retry', () => { panel.remove(); load() })\n panel.append(text, actions); root.append(panel); retry.focus()\n }\n const load = () => {\n nonce = crypto.randomUUID()\n frame = document.createElement('iframe')\n frame.title = zh ? '文件选择器' : 'File picker'\n frame.style.cssText = 'position:absolute;inset:0;width:100%;height:100%;border:0;background:transparent;color-scheme:normal'\n frame.setAttribute('allowtransparency', 'true')\n frame.addEventListener('error', showFailure)\n frame.src = `${origin}${SELECT_EMBED_PATH}#bse=${nonce}&po=${encodeURIComponent(window.location.origin)}`\n root.append(frame)\n timer = setTimeout(showFailure, 10000)\n }\n const receive = (event: MessageEvent) => {\n if (!frame || event.origin !== origin || event.source !== frame.contentWindow || !isEmbedMessage(event.data, SYSDLG_EMBED)) return\n const { type, payload: p } = event.data\n if (type === 'embed.hello') {\n if (p.nonce !== nonce) return\n clearTimeout(timer)\n frame.contentWindow?.postMessage(embedEnvelope('embed.init', { nonce, params, theme, locale } satisfies SelectEmbedInit, SYSDLG_EMBED), origin)\n frame.focus()\n }\n if (type === 'embed.error') fail(dialogErrorCode(p.code))\n if (type === 'embed.result') {\n const result = readSelectDialogResult(p.result, { allowLocal: params.allowLocal === true })\n if (result) finish(result)\n else fail('protocol')\n }\n }\n window.addEventListener('message', receive)\n options.signal?.addEventListener('abort', abort, { once: true })\n if ('inert' in HTMLElement.prototype) siblings.forEach(({ el }) => { el.inert = true })\n else { siblings.forEach(({ el }) => el.setAttribute('aria-hidden', 'true')); blocked.forEach(type => document.addEventListener(type, block, true)) }\n // `overflow: hidden` alone does not stop the page behind from scrolling on iOS; pinning the body does.\n html.style.overflow = 'hidden'\n body.style.position = 'fixed'; body.style.top = `${-scroll.y}px`; body.style.left = `${-scroll.x}px`; body.style.right = '0'; body.style.overflow = 'hidden'\n body.append(root)\n load()\n })\n}\n\n/** System side: the picker page at `SELECT_EMBED_PATH`. Works only for an embedding page whose origin `accept` admits. */\nexport class SelectEmbedHost {\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: { accept: (origin: string) => boolean; onInit: (init: SelectEmbedInit) => void }) {\n const params = new URLSearchParams(window.location.hash.slice(1))\n this.nonce = params.get('bse')\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 }, SYSDLG_EMBED), 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, SYSDLG_EMBED)) return\n const { type, payload: p } = event.data\n if (type !== 'embed.init' || this.ready || p.nonce !== this.nonce || typeof p.locale !== 'string') return\n this.ready = true; clearInterval(this.hello)\n this.options.onInit({ nonce: String(p.nonce), params: p.params, theme: p.theme === 'dark' ? 'dark' : 'light', locale: p.locale })\n }\n private post(type: string, payload: unknown): void {\n if (this.ready && this.parentOrigin) window.parent.postMessage(embedEnvelope(type, payload, SYSDLG_EMBED), this.parentOrigin)\n }\n result(result: SelectDialogResult): void { this.post('embed.result', { result }) }\n error(code: SystemDialogErrorCode): void { this.post('embed.error', { code }) }\n dispose(): void { clearInterval(this.hello); window.removeEventListener('message', this.listener) }\n}\n"],"names":["dialogErrorCode","value","SYSTEM_DIALOG_ERROR_CODES","includes","envelope","type","payload","extra","protocol","version","isMessage","v","PREVIEW_EMBED","embedEnvelope","isEmbedMessage","PREVIEW_EMBED_PATH","SYSDLG_EMBED","SELECT_EMBED_PATH","selectEmbedOpen","openSelectEmbed","systemOrigin","params","options","_a","signal","aborted","Promise","reject","SystemDialogError","origin","URL","locale","navigator","language","theme","_b","window","matchMedia","call","matches","zh","toLowerCase","startsWith","resolve","body","document","html","documentElement","focused","activeElement","HTMLElement","scroll","x","scrollX","y","scrollY","saved","getAttribute","siblings","Array","from","children","filter","el","map","inert","hidden","root","createElement","frame","setAttribute","style","cssText","timer","nonce","done","block","event","contains","target","stopPropagation","preventDefault","blocked","cleanup","clearTimeout","removeEventListener","receive","abort","prototype","forEach","remove","removeAttribute","scrollTo","focus","preventScroll","fail","code","showFailure","panel","text","margin","textContent","actions","button","label","action","addEventListener","append","retry","load","crypto","randomUUID","title","src","encodeURIComponent","location","setTimeout","source","contentWindow","data","p","postMessage","result","readSelectDialogResult","allowLocal","finish","once","overflow","position","top","left","right","constructor","this","listener","dialogs","Map","shellOrigin","URLSearchParams","hash","slice","get","parent","hello","appCapabilities","onOpen","onBeforeClose","onBack","helloTimer","setInterval","helloDeadline","clearInterval","m","windowId","launch","isOpenRequest","init","onInit","pending","replyTo","delete","ok","reply","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","hints","newWindow","open","systemOpenUrl","appId","selectContent","shellCapabilities","SELECT_DIALOG_PATH","size","set","path","embedAbort","AbortController","dispose","clear","ready","capabilities","opens","dialogOpen","systemDialog","onSystemDialog","error","isArray","c","onReady","onTitle","onRequestClose","requestId","t","Date","now","length","push","onContentOpen","readContentHints","update","setFocused","timeout","Error","beforeClose","r","back","url","post","status","onState","kind","mediaType","isTransferableRef","session","isTransferableSession","onOpenWith","onExit","patch","parentOrigin","accept","Blob","blob","name","String","onUpdate","state","openWith","exit","candidates","ancestorOrigins","referrer","candidate","zoneHost","hostname","endsWith"],"mappings":"uJAEA,MAAMA,EAAmBC,GACvBC,4BAA0BC,SAASF,GA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