@crewx/sdk 0.9.0-rc.16 → 0.9.0-rc.160

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 (304) hide show
  1. package/README.md +1 -1
  2. package/dist/account/auth-client.d.ts +61 -0
  3. package/dist/account/auth-json-v2.d.ts +1 -0
  4. package/dist/account/auth-json.d.ts +30 -0
  5. package/dist/account/config.d.ts +37 -0
  6. package/dist/account/env-bootstrap.d.ts +11 -0
  7. package/dist/account/errors.d.ts +24 -0
  8. package/dist/account/index.d.ts +12 -0
  9. package/dist/account/index.js +2 -0
  10. package/dist/account/session-manager.d.ts +47 -0
  11. package/dist/activity-log/builder.d.ts +59 -6
  12. package/dist/agent/agent-list-view.d.ts +19 -0
  13. package/dist/app/app.d.ts +148 -0
  14. package/dist/app/backend-env.d.ts +3 -0
  15. package/dist/app/content-media-types.d.ts +2 -0
  16. package/dist/app/context.d.ts +2 -0
  17. package/dist/app/entry.d.ts +7 -0
  18. package/dist/app/frame.d.ts +55 -0
  19. package/dist/app/index.d.ts +10 -0
  20. package/dist/app/index.js +10 -0
  21. package/dist/app/protocol.d.ts +9 -0
  22. package/dist/app/runtime.d.ts +21 -0
  23. package/dist/app/tool-mode.d.ts +3 -0
  24. package/dist/boxing/box.types.d.ts +4 -0
  25. package/dist/config/canonicalize-agent-options.d.ts +18 -0
  26. package/dist/config/default-agent-models.d.ts +11 -0
  27. package/dist/config/global-settings.d.ts +33 -0
  28. package/dist/config/migrate-grok-mode.d.ts +6 -0
  29. package/dist/config/model-compat.d.ts +31 -0
  30. package/dist/config/models.generated.d.ts +37 -0
  31. package/dist/config/models.remote.d.ts +1 -0
  32. package/dist/config/overdrive.d.ts +7 -0
  33. package/dist/config/pricing.d.ts +6 -3
  34. package/dist/config/pricing.generated.d.ts +4 -0
  35. package/dist/config/pricing.types.d.ts +4 -0
  36. package/dist/config/timeout.config.d.ts +4 -0
  37. package/dist/config/wi-boards.d.ts +19 -0
  38. package/dist/context-budget/continuity.d.ts +63 -0
  39. package/dist/context-budget/index.d.ts +142 -0
  40. package/dist/conversation/index.d.ts +1 -1
  41. package/dist/conversation/sqlite-provider.d.ts +6 -3
  42. package/dist/conversation/to-template-messages.d.ts +9 -0
  43. package/dist/conversation/types.d.ts +58 -1
  44. package/dist/desktop/command-runner.d.ts +4 -0
  45. package/dist/desktop/default-adapters.d.ts +4 -0
  46. package/dist/desktop/global-install.d.ts +19 -0
  47. package/dist/desktop/index.d.ts +3 -0
  48. package/dist/desktop/index.js +3 -0
  49. package/dist/desktop/install.d.ts +5 -0
  50. package/dist/desktop/lnk.d.ts +22 -0
  51. package/dist/desktop/manifest.d.ts +21 -0
  52. package/dist/desktop/types.d.ts +67 -0
  53. package/dist/desktop/version.d.ts +1 -0
  54. package/dist/desktop/windows-paths.d.ts +21 -0
  55. package/dist/desktop/wrapper.d.ts +18 -0
  56. package/dist/esm/account/index.js +2 -0
  57. package/dist/esm/app/index.js +10 -0
  58. package/dist/esm/desktop/index.js +3 -0
  59. package/dist/esm/index.js +1126 -224
  60. package/dist/esm/node/index.js +2 -0
  61. package/dist/esm/plugins/index.js +496 -214
  62. package/dist/esm/process/index.js +1 -0
  63. package/dist/esm/publish/index.js +2 -0
  64. package/dist/esm/repository/index.js +608 -211
  65. package/dist/esm/skills/index.js +2 -0
  66. package/dist/esm/testing/index.js +1 -1
  67. package/dist/events/types.d.ts +16 -0
  68. package/dist/facade/Crewx.d.ts +61 -5
  69. package/dist/facade/task-ticket.d.ts +14 -0
  70. package/dist/highlight/thread-highlight-prompt.d.ts +2 -0
  71. package/dist/highlight/thread-highlighter.d.ts +326 -0
  72. package/dist/index.browser.d.ts +19 -1
  73. package/dist/index.browser.js +6 -2
  74. package/dist/index.d.ts +131 -17
  75. package/dist/index.js +1128 -226
  76. package/dist/internal/console-decoder.d.ts +38 -0
  77. package/dist/internal/windows-spawn.d.ts +10 -0
  78. package/dist/layout/types.d.ts +18 -1
  79. package/dist/lifecycle/process-lease.d.ts +80 -0
  80. package/dist/lifecycle/process-owner.d.ts +20 -0
  81. package/dist/lifecycle/task-heartbeat.d.ts +41 -0
  82. package/dist/lifecycle/task-stop.d.ts +82 -0
  83. package/dist/lifecycle/update-admission.d.ts +45 -0
  84. package/dist/local-server/base-url.d.ts +18 -0
  85. package/dist/local-server/index.d.ts +8 -0
  86. package/dist/local-server/opencode.d.ts +8 -0
  87. package/dist/local-server/probe.d.ts +3 -0
  88. package/dist/local-server/runtime.d.ts +26 -0
  89. package/dist/local-server/types.d.ts +43 -0
  90. package/dist/mcp-app/agent-access.d.ts +26 -0
  91. package/dist/mcp-app/app-handoff.d.ts +109 -0
  92. package/dist/mcp-app/apps-context.d.ts +32 -0
  93. package/dist/mcp-app/bundle-provenance.d.ts +3 -0
  94. package/dist/mcp-app/candidate-registration.d.ts +4 -0
  95. package/dist/mcp-app/card-handler.d.ts +7 -0
  96. package/dist/mcp-app/catalog.d.ts +7 -0
  97. package/dist/mcp-app/content-channel.d.ts +86 -0
  98. package/dist/mcp-app/content-declarations.d.ts +31 -0
  99. package/dist/mcp-app/dev-checks.d.ts +29 -0
  100. package/dist/mcp-app/diagnostic-reason.d.ts +3 -0
  101. package/dist/mcp-app/discovery.d.ts +161 -0
  102. package/dist/mcp-app/errors.d.ts +7 -0
  103. package/dist/mcp-app/index.d.ts +37 -0
  104. package/dist/mcp-app/installed-app-ref.d.ts +25 -0
  105. package/dist/mcp-app/model-context.d.ts +29 -0
  106. package/dist/mcp-app/node-app-discovery-fs.d.ts +23 -0
  107. package/dist/mcp-app/product-bundle-assets.d.ts +27 -0
  108. package/dist/mcp-app/product-bundle-loader.d.ts +53 -0
  109. package/dist/mcp-app/projection.d.ts +14 -0
  110. package/dist/mcp-app/prompt-cards.d.ts +28 -0
  111. package/dist/mcp-app/registry.d.ts +28 -0
  112. package/dist/mcp-app/skill-backend.d.ts +132 -0
  113. package/dist/mcp-app/state-set.d.ts +9 -0
  114. package/dist/mcp-app/types.d.ts +488 -0
  115. package/dist/mcp-app/workspace-app-assets.d.ts +42 -0
  116. package/dist/mcp-app/workspace-app-scan-cache.d.ts +27 -0
  117. package/dist/mcp-app/workspace-snapshot.d.ts +72 -0
  118. package/dist/migrations/0011_far_black_tarantula.sql +1 -0
  119. package/dist/migrations/0012_blue_turbo.sql +23 -0
  120. package/dist/migrations/0013_hesitant_adam_destine.sql +15 -0
  121. package/dist/migrations/0014_organic_mongu.sql +73 -0
  122. package/dist/migrations/0015_panoramic_gorilla_man.sql +71 -0
  123. package/dist/migrations/0016_fuzzy_hemingway.sql +14 -0
  124. package/dist/migrations/0017_project_stage_sdk_migration.sql +29 -0
  125. package/dist/migrations/0018_bored_jackal.sql +33 -0
  126. package/dist/migrations/0019_backfill_task_thread_ids.sql +74 -0
  127. package/dist/migrations/0020_useful_iron_lad.sql +55 -0
  128. package/dist/migrations/0021_dashing_peter_quill.sql +51 -0
  129. package/dist/migrations/0022_wandering_bucky.sql +1 -0
  130. package/dist/migrations/0023_red_payback.sql +1 -0
  131. package/dist/migrations/0024_storage_metadata.sql +262 -0
  132. package/dist/migrations/0025_task_heartbeat.sql +8 -0
  133. package/dist/migrations/0025_thread_app_instance_ledger.sql +2 -0
  134. package/dist/migrations/0026_mcp_action_source.sql +47 -0
  135. package/dist/migrations/0027_task_stop_scope_cleanup.sql +5 -0
  136. package/dist/migrations/0027_ui_instance_active_unique.sql +2 -0
  137. package/dist/migrations/0029_nice_rhino.sql +1 -0
  138. package/dist/migrations/0031_petite_arclight.sql +6 -0
  139. package/dist/migrations/0032_ui_instance_opened_by.sql +1 -0
  140. package/dist/migrations/0033_thread_creator_boundary_guard.sql +38 -0
  141. package/dist/migrations/0034_keen_fallen_one.sql +36 -0
  142. package/dist/migrations/0035_request_log_daily.sql +11 -0
  143. package/dist/migrations/0036_ui_definition_archive.sql +8 -0
  144. package/dist/migrations/0037_ui_instance_agent_open_request.sql +1 -0
  145. package/dist/migrations/0038_task_rating.sql +3 -0
  146. package/dist/migrations/0039_aspiring_purifiers.sql +9 -0
  147. package/dist/migrations/0040_task_provider_inputs.sql +53 -0
  148. package/dist/migrations/meta/0011_snapshot.json +1342 -0
  149. package/dist/migrations/meta/0012_snapshot.json +1494 -0
  150. package/dist/migrations/meta/0013_snapshot.json +1592 -0
  151. package/dist/migrations/meta/0014_snapshot.json +1975 -0
  152. package/dist/migrations/meta/0015_snapshot.json +2315 -0
  153. package/dist/migrations/meta/0016_snapshot.json +2419 -0
  154. package/dist/migrations/meta/0017_snapshot.json +2419 -0
  155. package/dist/migrations/meta/0018_snapshot.json +2570 -0
  156. package/dist/migrations/meta/0020_snapshot.json +2895 -0
  157. package/dist/migrations/meta/0021_snapshot.json +3031 -0
  158. package/dist/migrations/meta/0022_snapshot.json +3039 -0
  159. package/dist/migrations/meta/0023_snapshot.json +3047 -0
  160. package/dist/migrations/meta/0029_snapshot.json +3206 -0
  161. package/dist/migrations/meta/0031_snapshot.json +3251 -0
  162. package/dist/migrations/meta/0034_snapshot.json +3473 -0
  163. package/dist/migrations/meta/0035_snapshot.json +3547 -0
  164. package/dist/migrations/meta/0036_snapshot.json +3591 -0
  165. package/dist/migrations/meta/0037_snapshot.json +3598 -0
  166. package/dist/migrations/meta/0038_snapshot.json +3626 -0
  167. package/dist/migrations/meta/0039_snapshot.json +3684 -0
  168. package/dist/migrations/meta/0040_snapshot.json +3759 -0
  169. package/dist/migrations/meta/_journal.json +210 -0
  170. package/dist/node/index.d.ts +1 -0
  171. package/dist/node/index.js +2 -0
  172. package/dist/paths.d.ts +1 -0
  173. package/dist/plugin/types.d.ts +1 -0
  174. package/dist/plugins/index.d.ts +1 -1
  175. package/dist/plugins/index.js +496 -214
  176. package/dist/plugins/sqlite-tracing.d.ts +46 -0
  177. package/dist/process/index.d.ts +2 -0
  178. package/dist/process/index.js +1 -0
  179. package/dist/process/process-control.d.ts +41 -0
  180. package/dist/prompt/tag-names.d.ts +22 -0
  181. package/dist/provider/acp/connection.d.ts +6 -0
  182. package/dist/provider/acp/meta.d.ts +11 -0
  183. package/dist/provider/bridge.d.ts +7 -1
  184. package/dist/provider/classify-task-error.d.ts +2 -0
  185. package/dist/provider/cli/adapter.types.d.ts +14 -2
  186. package/dist/provider/cli/adapters/agent-call.util.d.ts +1 -1
  187. package/dist/provider/cli/adapters/cli-knob.util.d.ts +7 -0
  188. package/dist/provider/cli/adapters/codex-item.d.ts +1 -0
  189. package/dist/provider/cli/adapters/event-timestamp.util.d.ts +1 -0
  190. package/dist/provider/cli/adapters/grok.d.ts +2 -0
  191. package/dist/provider/cli/adapters/index.d.ts +5 -0
  192. package/dist/provider/cli/index.d.ts +3 -2
  193. package/dist/provider/cli/meta.d.ts +5 -0
  194. package/dist/provider/cli/protocol-envelope.d.ts +3 -0
  195. package/dist/provider/errors.d.ts +5 -1
  196. package/dist/provider/idle-watchdog.d.ts +19 -0
  197. package/dist/provider/models.d.ts +17 -12
  198. package/dist/provider/order.d.ts +1 -1
  199. package/dist/provider/parse-usage.d.ts +6 -0
  200. package/dist/provider/provider-selection.d.ts +8 -0
  201. package/dist/provider/redact-technical-message.d.ts +1 -0
  202. package/dist/provider/task-error.types.d.ts +17 -0
  203. package/dist/publish/constants.d.ts +6 -0
  204. package/dist/publish/errors.d.ts +7 -0
  205. package/dist/publish/index.d.ts +50 -0
  206. package/dist/publish/index.js +2 -0
  207. package/dist/publish/manifest.d.ts +47 -0
  208. package/dist/publish/marketplace-api.constants.d.ts +1 -0
  209. package/dist/publish/pack.d.ts +6 -0
  210. package/dist/publish/scan.d.ts +10 -0
  211. package/dist/publish/secrets.d.ts +6 -0
  212. package/dist/publish/upload.d.ts +19 -0
  213. package/dist/remote/execution-profile.d.ts +9 -0
  214. package/dist/remote/index.d.ts +1 -0
  215. package/dist/remote/types.d.ts +28 -0
  216. package/dist/repository/agent-send-history.repository.d.ts +23 -0
  217. package/dist/repository/agent-suggestion.repository.d.ts +34 -0
  218. package/dist/repository/base-sqlite-repository.d.ts +1 -0
  219. package/dist/repository/common-code.repository.d.ts +45 -0
  220. package/dist/repository/db.d.ts +12 -1
  221. package/dist/repository/index.d.ts +49 -6
  222. package/dist/repository/index.js +608 -211
  223. package/dist/repository/logs-db.d.ts +12 -0
  224. package/dist/repository/notification.repository.d.ts +58 -0
  225. package/dist/repository/project.repository.d.ts +90 -0
  226. package/dist/repository/request-log-mover.d.ts +70 -0
  227. package/dist/repository/request-log.repository.d.ts +7 -3
  228. package/dist/repository/storage-metadata.repository.d.ts +64 -0
  229. package/dist/repository/task-log-migration.d.ts +74 -0
  230. package/dist/repository/task-log.repository.d.ts +44 -0
  231. package/dist/repository/task-status.d.ts +21 -0
  232. package/dist/repository/task.repository.d.ts +300 -7
  233. package/dist/repository/thread-history.repository.d.ts +193 -0
  234. package/dist/repository/thread-origin-verdict.d.ts +27 -0
  235. package/dist/repository/thread-title.types.d.ts +29 -0
  236. package/dist/repository/thread.repository.d.ts +118 -7
  237. package/dist/repository/usage-backfill.d.ts +62 -0
  238. package/dist/repository/usage-from-logs.d.ts +21 -0
  239. package/dist/repository/workspace.repository.d.ts +3 -0
  240. package/dist/schema/agent-send-history.d.ts +85 -0
  241. package/dist/schema/agent-suggestions.d.ts +199 -0
  242. package/dist/schema/common-codes.d.ts +216 -0
  243. package/dist/schema/index.d.ts +15 -0
  244. package/dist/schema/notifications.d.ts +303 -0
  245. package/dist/schema/projects.d.ts +610 -0
  246. package/dist/schema/request-log-daily.d.ts +151 -0
  247. package/dist/schema/storage-metadata.d.ts +181 -0
  248. package/dist/schema/task-log-events.d.ts +119 -0
  249. package/dist/schema/task-provider-inputs.d.ts +100 -0
  250. package/dist/schema/tasks.d.ts +1058 -1
  251. package/dist/schema/thread-creator-unverified.d.ts +45 -0
  252. package/dist/schema/thread-history.d.ts +734 -0
  253. package/dist/schema/threads.d.ts +59 -0
  254. package/dist/schema/ui-action-receipts.d.ts +358 -0
  255. package/dist/schema/ui-definition-archive.d.ts +63 -0
  256. package/dist/schema/ui-instance-repins.d.ts +222 -0
  257. package/dist/schema/ui-instances.d.ts +324 -0
  258. package/dist/schema/workspaces.d.ts +17 -0
  259. package/dist/skills/index.d.ts +15 -0
  260. package/dist/skills/index.js +2 -0
  261. package/dist/skills/types.d.ts +18 -0
  262. package/dist/task-log/anchor-child-tasks.d.ts +7 -0
  263. package/dist/task-log/delegation-trailer.d.ts +34 -0
  264. package/dist/template/engine.d.ts +2 -2
  265. package/dist/template/helpers/exec.browser.d.ts +4 -3
  266. package/dist/template/helpers/exec.d.ts +4 -3
  267. package/dist/template/helpers/format-conversation.d.ts +1 -0
  268. package/dist/template/types.d.ts +20 -0
  269. package/dist/testing/index.js +1 -1
  270. package/dist/types/index.d.ts +1578 -3
  271. package/dist/types/task-log.types.d.ts +3 -0
  272. package/dist/ui-card/index.d.ts +2 -0
  273. package/dist/ui-card/legacy-card-parser.d.ts +11 -0
  274. package/dist/ui-instance/definition.d.ts +6 -0
  275. package/dist/ui-instance/errors.d.ts +18 -0
  276. package/dist/ui-instance/index.d.ts +11 -0
  277. package/dist/ui-instance/json.d.ts +19 -0
  278. package/dist/ui-instance/lineage.d.ts +24 -0
  279. package/dist/ui-instance/runtime.d.ts +19 -0
  280. package/dist/ui-instance/store.d.ts +213 -0
  281. package/dist/ui-instance/types.d.ts +329 -0
  282. package/dist/ui-plugin/app-manifest.d.ts +64 -0
  283. package/dist/ui-plugin/csp.d.ts +28 -0
  284. package/dist/ui-plugin/index.d.ts +6 -0
  285. package/dist/ui-plugin/limits.d.ts +27 -0
  286. package/dist/ui-plugin/manifest.d.ts +3 -0
  287. package/dist/ui-plugin/types.d.ts +203 -0
  288. package/dist/ui-plugin/validator.d.ts +18 -0
  289. package/dist/utils/crewx-executable.d.ts +76 -0
  290. package/dist/utils/crewx-home.d.ts +1 -0
  291. package/dist/utils/env-defaults.d.ts +3 -0
  292. package/dist/utils/id.d.ts +1 -1
  293. package/dist/utils/local-identity.d.ts +2 -0
  294. package/dist/utils/runner-env.d.ts +3 -0
  295. package/dist/utils/timestamp.d.ts +1 -0
  296. package/dist/utils/workspace.d.ts +1 -0
  297. package/dist/wi/create.d.ts +48 -0
  298. package/dist/wi/select.d.ts +20 -0
  299. package/package.json +57 -3
  300. package/templates/agents/default.yaml +303 -128
  301. package/templates/documents/crewx-manual.md +138 -138
  302. package/templates/documents/crewx-quick-guide.md +8 -7
  303. package/templates/workflows/wi-default-flow.yaml +65 -0
  304. package/templates/workflows/wi-plan-flow.yaml +140 -0
@@ -0,0 +1,2 @@
1
+ 'use strict';var crypto=require('crypto'),net=require('net'),fs$1=require('fs'),promises=require('fs/promises'),path=require('path'),jsYaml=require('js-yaml');var Ar=Object.defineProperty;var k=(e,n)=>()=>(e&&(n=e(e=0)),n);var Ir=(e,n)=>{for(var t in n)Ar(e,t,{get:n[t],enumerable:true});};var g=k(()=>{});var R,Dn=k(()=>{g();R=class extends Error{constructor(t,i=t,r){super(i);this.code=t;this.currentRevision=r;}code;currentRevision;name="UiRuntimeError"};});function it(e){return gr.test(e)||mr.test(e)}function ae(){throw new R("INPUT_INVALID","JSON value is not projection-safe")}function Er(e){let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}function nt(e,n,t,i,r,o){if(n>i&&ae(),e===null||typeof e=="string"||typeof e=="boolean")return typeof e=="string"&&(hr.test(e)||Tr.test(e)&&!br(r,o)||_r.test(e))&&ae(),e;if(typeof e=="number")return Number.isFinite(e)||ae(),e;(typeof e!="object"||e===void 0||typeof e=="function"||typeof e=="bigint")&&ae();let a=e;t.has(a)&&ae(),t.add(a);try{if(Array.isArray(e))return e.map(c=>nt(c,n+1,t,i,r,o));Er(a)||ae();let s={};for(let[c,d]of Object.entries(e))it(c)&&ae(),s[c]=nt(d,n+1,t,i,[...r,c],o);return s}finally{t.delete(a);}}function ce(e,n=0,t=[]){(!Number.isInteger(n)||n<0||n>Nr)&&ae(),(!Array.isArray(t)||t.some(r=>typeof r!="string"))&&ae();let i=nt(e,0,new Set,Dr+n,[],t);return (i===null||Array.isArray(i)||typeof i!="object")&&ae(),i}function Fe(e,n){if(!e||!n)return false;let t=e.split("."),i=n.split(".");return t.length>=i.length&&i.every((r,o)=>t[o]===r)}function br(e,n){if(e.length===0)return false;let t=e.join(".");return n.some(i=>Fe(t,i))}function Be(e){try{let n=JSON.stringify(e);return n===void 0&&ae(),n}catch{ae();}}function tt(e){return Array.isArray(e)?e.map(tt):e!==null&&typeof e=="object"?Object.fromEntries(Object.keys(e).sort().map(n=>[n,tt(e[n])])):e}function q(e){return Be(tt(e))}function ot(e){return Buffer.byteLength(e,"utf8")}var gr,mr,hr,_r,Tr,Dr,Nr,De=k(()=>{g();Dn();gr=/(?:proof|token|secret|password|cookie|authorization|private[_-]?key|stack|exception|plugin[_-]?text)/i,mr=/(?:url|uri|endpoint|path|file(?:name|path)?|cwd|shell|directory|dir|folder)$/i,hr=/<\/?[A-Za-z][^>]*>/,_r=/^(?:[A-Za-z]:[\\/]|\\\\|~[\\/]|\/)/,Tr=/^(?:https?|file|ftp|ws|wss):\/\//i;Dr=8,Nr=4;});var Nn,rt=k(()=>{g();Nn=["text/plain","application/json"];});var di=k(()=>{g();rt();});function He(e){return Mr.has(e)||Sr.test(e)||Lr.test(e)}var pi,Mr,Sr,Lr,bn,nn,Ie,st,at,ct,dt,pt,Re=k(()=>{g();pi=["__proto__","prototype","constructor","proof","token","secret","password","cookie","authorization","private_key","private-key","stack","exception","plugin_text","url","uri","endpoint","path","filename","filepath","cwd","shell","directory","dir","folder"],Mr=new Set(pi),Sr=/(?:proof|token|secret|password|cookie|authorization|private[_-]?key|stack|exception|plugin[_-]?text)/i,Lr=/(?:url|uri|endpoint|path|file(?:name|path)?|cwd|shell|directory|dir|folder)$/i;bn=/^[A-Za-z0-9_]+$/,nn=/^[A-Za-z0-9_]+(?:\.[A-Za-z0-9_]+)*$/,Ie=/^[A-Za-z][A-Za-z0-9._-]{0,127}$/,st=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/,at=/^[A-Za-z][A-Za-z0-9._-]{0,127}$/,ct=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$/,dt=["blue","violet","emerald","amber","rose","sky","slate","indigo"],pt=["inline","panel"];});function lt(e){return typeof e=="string"&&Nn.includes(e)}var li=k(()=>{g();rt();Re();});function Pn(e){if(!ut(e))return false;let n=Object.keys(e);return !(n.some(t=>t!=="in"&&t!=="out")||n.length===0||Object.hasOwn(e,"in")&&!Or(e.in)||Object.hasOwn(e,"out")&&!Rr(e.out))}function Or(e){return ut(e)?Object.keys(e).every(t=>t==="mediaType"||t==="required")&&Object.hasOwn(e,"mediaType")&&lt(e.mediaType)&&(!Object.hasOwn(e,"required")||typeof e.required=="boolean"):false}function Rr(e){return ut(e)?Object.keys(e).every(t=>t==="mediaType"||t==="range")&&Object.hasOwn(e,"mediaType")&&lt(e.mediaType)&&(!Object.hasOwn(e,"range")||typeof e.range=="boolean"):false}function ut(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}var ft=k(()=>{g();di();li();new TextDecoder("utf-8",{fatal:true,ignoreBOM:true});});function ie(e){let t=e.renderer!==void 0||e.surfaces!==void 0||e.stateProjection!==void 0||e.dataPaths!==void 0||e.usage!==void 0||e.detailPanel!==void 0||e.displayModes!==void 0||e.summaryProjection!==void 0||e.legacy!==void 0||Object.values(e.actions).some(r=>r.resultProjection!==void 0)?{id:e.id,version:e.version,...e.renderer===void 0?{}:{renderer:e.renderer},...e.surfaces===void 0?{}:{surfaces:e.surfaces},...e.stateProjection===void 0?{}:{stateProjection:e.stateProjection},...e.dataPaths===void 0?{}:{dataPaths:e.dataPaths},...e.summaryProjection===void 0?{}:{summaryProjection:e.summaryProjection},...e.legacy===void 0?{}:{legacy:e.legacy},...e.usage===void 0?{}:{usage:e.usage},...e.detailPanel===void 0?{}:{detailPanel:e.detailPanel},...e.displayModes===void 0?{}:{displayModes:e.displayModes},...e.sourceHash===void 0?{}:{sourceHash:e.sourceHash},actions:e.actions}:e.sourceHash===void 0?{id:e.id,version:e.version,actions:e.actions}:{id:e.id,version:e.version,sourceHash:e.sourceHash,actions:e.actions},i=ce(t);return crypto.createHash("sha256").update(q(i)).digest("hex")}function At(e){return `${e.id}\0${e.version}`}function de(e){if(!/^\d+$/.test(String(e.version))||e.version<1||e.id.length<1||e.id.length>128)throw new R("DEFINITION_UNSUPPORTED","UI definition is invalid");if(e.sourceHash!==void 0&&(typeof e.sourceHash!="string"||!Cr.test(e.sourceHash)))throw new R("DEFINITION_UNSUPPORTED","UI definition source hash is invalid");if(!/^[0-9a-f]{64}$/.test(e.hash)||ie(e)!==e.hash)throw new R("DEFINITION_UNSUPPORTED","UI definition hash is invalid");for(let[n,t]of Object.entries(e.actions)){if(!n||!Array.isArray(t.capabilities)||t.capabilities.some(i=>!wr(i)))throw new R("DEFINITION_UNSUPPORTED","UI action declaration is invalid");if(t.confirmation!==void 0&&t.confirmation!=="none"&&t.confirmation!=="native")throw new R("DEFINITION_UNSUPPORTED","UI action confirmation is invalid");if(t.inputKeys&&(!Array.isArray(t.inputKeys)||t.inputKeys.some(i=>typeof i!="string"||!i)))throw new R("DEFINITION_UNSUPPORTED","UI action input declaration is invalid");if(t.dataInputs!==void 0&&(!Array.isArray(t.dataInputs)||new Set(t.dataInputs).size!==t.dataInputs.length||t.dataInputs.some(i=>typeof i!="string"||!i||t.inputKeys!==void 0&&!t.inputKeys.includes(i))))throw new R("DEFINITION_UNSUPPORTED","UI action data input declaration is invalid");if(t.resultProjection&&yt(t.resultProjection),t.content!==void 0&&!Pn(t.content))throw new R("DEFINITION_UNSUPPORTED","UI action content declaration is invalid");if(t.env!==void 0&&(!Array.isArray(t.env)||t.env.length===0||new Set(t.env).size!==t.env.length||t.env.some(i=>i!=="CREWX_APP_INSTANCE_ID"&&i!=="CREWX_THREAD_ID")))throw new R("DEFINITION_UNSUPPORTED","UI action environment declaration is invalid")}if(e.renderer!==void 0&&(!e.renderer||e.renderer.length>128))throw new R("DEFINITION_UNSUPPORTED","UI definition renderer is invalid");if(e.surfaces&&(!Array.isArray(e.surfaces)||e.surfaces.some(n=>!n||n.length>64)))throw new R("DEFINITION_UNSUPPORTED","UI definition surfaces are invalid");if(e.usage!==void 0&&e.usage!=="card"&&e.usage!=="window")throw new R("DEFINITION_UNSUPPORTED","UI definition usage is invalid");if(e.detailPanel!==void 0&&typeof e.detailPanel!="boolean")throw new R("DEFINITION_UNSUPPORTED","UI definition detailPanel is invalid");if(e.displayModes&&(!Array.isArray(e.displayModes)||e.displayModes.length===0||new Set(e.displayModes).size!==e.displayModes.length||e.displayModes.some(n=>n!=="inline"&&n!=="floating"&&n!=="focused")))throw new R("DEFINITION_UNSUPPORTED","UI definition displayModes are invalid");if(e.usage==="card"&&e.displayModes!==void 0)throw new R("DEFINITION_UNSUPPORTED","Card definitions cannot declare displayModes");if(e.usage==="window"&&e.detailPanel!==void 0)throw new R("DEFINITION_UNSUPPORTED","Window definitions cannot declare detailPanel");if(e.stateProjection&&yt(e.stateProjection),e.summaryProjection){yt(e.summaryProjection);let n=new Set(e.stateProjection?.allow??[]);if(e.summaryProjection.allow.some(t=>!n.has(t)))throw new R("DEFINITION_UNSUPPORTED","UI summary projection exceeds state projection")}if(e.legacy!==void 0){if(!e.legacy||typeof e.legacy!="object"||Array.isArray(e.legacy)||Object.keys(e.legacy).some(r=>!["readTool","actionTool","hostTools","agentAccess"].includes(r)))throw new R("DEFINITION_UNSUPPORTED","UI legacy metadata is invalid");let n=new Set;for(let[r,o]of [["readTool",e.legacy.readTool],["actionTool",e.legacy.actionTool]])if(o!==void 0){if(kr(o,r==="readTool"),n.has(o.name))throw new R("DEFINITION_UNSUPPORTED","UI legacy tool names collide");n.add(o.name);}let t=e.legacy.hostTools;if(t!==void 0){if(!t||typeof t!="object"||Array.isArray(t))throw new R("DEFINITION_UNSUPPORTED","UI legacy host tools are invalid");let r={"doc.open":"crewx_app_html_viewer_open","pty.connect":"crewx_app_terminal_connect"};for(let[o,a]of Object.entries(t)){if(!Object.hasOwn(r,o)||r[o]!==a||typeof a!="string"||!/^[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(a)||n.has(a))throw new R("DEFINITION_UNSUPPORTED","UI legacy host tools are invalid");n.add(a);}}let i=e.legacy.agentAccess;if(i!==void 0&&(!i||typeof i!="object"||Array.isArray(i)||Object.entries(i).some(([r,o])=>!r||!Object.hasOwn(e.actions,r)||o!=="allowed"&&o!=="denied")))throw new R("DEFINITION_UNSUPPORTED","UI legacy agent access is invalid");if(e.legacy.actionTool!==void 0&&(!i||Object.keys(i).length===0))throw new R("DEFINITION_UNSUPPORTED","UI legacy action tool requires its complete agent access map")}if(e.dataPaths!==void 0){let n=new Set(["__proto__","prototype","constructor"]);if(!Array.isArray(e.dataPaths)||e.dataPaths.length>16||new Set(e.dataPaths).size!==e.dataPaths.length||e.dataPaths.some(t=>typeof t!="string"||!/^[A-Za-z0-9_]+(?:\.[A-Za-z0-9_]+)*$/.test(t)||t.split(".").some(i=>n.has(i))||!(e.stateProjection?.allow??[]).some(i=>Fe(t,i))))throw new R("DEFINITION_UNSUPPORTED","UI definition dataPaths are invalid")}}function kr(e,n){if(!e||typeof e!="object"||Array.isArray(e))throw new R("DEFINITION_UNSUPPORTED","UI legacy tool metadata is invalid");let t=e,i=["name","description","inputSchema","textFallback","visibility"],r=Object.hasOwn(t,"fixedResult");if(Object.keys(t).some(o=>!i.includes(o)&&!(n&&o==="fixedResult"))||i.some(o=>!Object.hasOwn(t,o))||typeof t.name!="string"||!/^[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(t.name)||typeof t.description!="string"||t.description.trim().length===0||t.description.length>8192||typeof t.textFallback!="string"||t.textFallback.trim().length===0||t.textFallback.length>16384||!t.inputSchema||typeof t.inputSchema!="object"||Array.isArray(t.inputSchema)||!Array.isArray(t.visibility)||t.visibility.length===0||t.visibility.some(o=>o!=="model"&&o!=="app")||new Set(t.visibility).size!==t.visibility.length)throw new R("DEFINITION_UNSUPPORTED","UI legacy tool metadata is invalid");try{let o=ce(t.inputSchema);if(o.type!==void 0&&o.type!=="object")throw new Error("schema type");if(r){if(!n)throw new Error("fixed result location");let a=t.fixedResult;if(!a||typeof a!="object"||Array.isArray(a))throw new Error("fixed result");let s=a;if(Object.keys(s).sort().join(",")!=="argsPolicy,structuredContent"||s.argsPolicy!=="empty-only"&&s.argsPolicy!=="ignore"||!s.structuredContent||typeof s.structuredContent!="object"||Array.isArray(s.structuredContent))throw new Error("fixed result");let c=ce(s.structuredContent);if(ot(Be(c))>4*1024)throw new Error("fixed result size")}}catch{throw new R("DEFINITION_UNSUPPORTED","UI legacy tool metadata is not projection-safe")}}function yt(e){if(!Array.isArray(e.allow)||e.allow.some(n=>!/^[A-Za-z0-9_]+(?:\.[A-Za-z0-9_]+)*$/.test(n)))throw new R("DEFINITION_UNSUPPORTED","UI projection policy is invalid")}function wr(e){return e.length>0&&e.length<=128&&e!=="*"&&e!=="all"&&!/[/*]/.test(e)}var Cr,Ue=k(()=>{g();De();Dn();ft();Cr=/^[0-9a-f]{64}$/;});var ui=k(()=>{g();De();});var K,ze,It=k(()=>{g();K="dist/tools.json",ze="dist/main.mjs";});var tn,fi=k(()=>{g();tn="window";});function yi(e){if(!Array.isArray(e)||e.length===0)return false;let n=new Set;for(let t of e){if(!xr.some(i=>i===t)||n.has(t))return false;n.add(t);}return true}var xr,Ai=k(()=>{g();xr=["CREWX_APP_INSTANCE_ID","CREWX_THREAD_ID"];});function v(e){throw new gt(e)}function Xr(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;try{let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}catch{return false}}function Kr(e,n){let t=Object.getOwnPropertyDescriptor(e,n);return (!t||!("value"in t))&&v("CSP_ORIGIN_INVALID"),t.value}function Mn(e,n){if(!Object.prototype.hasOwnProperty.call(e,n))return [];let t=Kr(e,n);Array.isArray(t)||v("CSP_ORIGIN_INVALID"),Reflect.ownKeys(t).some(o=>typeof o!="string"||o!=="length"&&!/^(?:0|[1-9][0-9]*)$/.test(o))&&v("CSP_ORIGIN_INVALID");let r=[];for(let o=0;o<t.length;o+=1)(!Object.prototype.hasOwnProperty.call(t,o)||typeof t[o]!="string")&&v("CSP_ORIGIN_INVALID"),r.push(t[o]);return Object.keys(t).length!==t.length&&v("CSP_ORIGIN_INVALID"),r}function Yr(e){let n;try{n=JSON.stringify(e);}catch{v("CSP_ORIGIN_INVALID");}return n===void 0&&v("CSP_ORIGIN_INVALID"),new TextEncoder().encode(n).byteLength}function mi(e,n){/\s|\\/u.test(e)&&v("CSP_ORIGIN_INVALID");let t=zr.exec(e);t||v("CSP_ORIGIN_INVALID");let i=t[1].toLowerCase(),r=t[2];(r.includes("@")||r.includes("%")||r.includes("*"))&&v("CSP_ORIGIN_INVALID"),(r.startsWith("[")?Gr:$r).test(r)||v("CSP_ORIGIN_INVALID"),i==="wss"&&n!=="connectDomains"&&v("CSP_ORIGIN_INVALID");let a;try{a=new URL(e);}catch{v("CSP_ORIGIN_INVALID");}(a.protocol!==`${i}:`||a.username!==""||a.password!==""||a.search!==""||a.hash!=="")&&v("CSP_ORIGIN_INVALID");let s=a.hostname.toLowerCase();if((!s||s.includes("%"))&&v("CSP_ORIGIN_INVALID"),!s.startsWith("[")){let d=s.endsWith(".")?s.slice(0,-1):s;(d.length===0||d.length>253)&&v("CSP_ORIGIN_INVALID"),d.split(".").some(l=>l.length>63||!Jr.test(l))&&v("CSP_ORIGIN_INVALID");}let c=a.origin;return (c==="null"||!c.startsWith(`${i}://`))&&v("CSP_ORIGIN_INVALID"),{origin:c,hostname:s}}function qr(e){let n=e.split(".").map(Number);return ((n[0]*256+n[1])*256+n[2])*256+n[3]}function hi(e,n,t){let i=4294967295<<32-t>>>0;return (e&i)===(n&i)}function Ei(e){let n=qr(e);return hi(n,3221225472,24)?n!==3221225481&&n!==3221225482:Wr.some(([t,i])=>hi(n,t,i))}function Zr(e){let n=e.indexOf("::"),t=(n<0?e:e.slice(0,n)).split(":").filter(Boolean),i=n<0?[]:e.slice(n+2).split(":").filter(Boolean);return (n<0?t:[...t,...Array(8-t.length-i.length).fill("0"),...i]).reduce((o,a)=>o<<16n|BigInt(Number.parseInt(a,16)),0n)}function Qr(e){let n=Zr(e),t=Number(n>>112n),i=Number(n>>96n&0xffffn);if(n>>32n===0xffffn){let r=Number(n&0xffffffffn);return Ei([r>>>24&255,r>>>16&255,r>>>8&255,r&255].join("."))}return t<8192||t>16383||t===8193&&i<=511||t===8193&&i===3512||t===8194||t===16383&&i<=4095}function es(e,n){let t=e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e,i=net.isIP(t);if(i===4)return Ei(t);if(i===6)return Qr(t);let r=e.toLowerCase().replace(/\.$/,"");return !r||!r.includes(".")||n.has(r)?true:Hr.some(o=>r===o||r.endsWith(`.${o}`))}function _i(e){return Object.freeze([...new Set(e.map(n=>n.origin))].sort())}function Ti(e){return JSON.stringify({baseUriDomains:[],connectDomains:e.connectDomains,declared:e.declared,frameDomains:e.frameDomains,resourceDomains:[]})}function Di(e,n={}){if(e===void 0){let A=Ti({declared:false,connectDomains:[],frameDomains:[]});return Object.freeze({declared:false,connectDomains:Object.freeze([]),frameDomains:Object.freeze([]),resourceDomains:Object.freeze([]),baseUriDomains:Object.freeze([]),cspHash:crypto.createHash("sha256").update(A,"utf8").digest("hex")})}Xr(e)||v("CSP_ORIGIN_INVALID");let t=Reflect.ownKeys(e);t.some(A=>typeof A!="string")&&v("CSP_ORIGIN_INVALID"),t.some(A=>!Br.has(A))&&v("CSP_AXIS_UNKNOWN");let i=Mn(e,"connectDomains"),r=Mn(e,"frameDomains"),o=Mn(e,"resourceDomains"),a=Mn(e,"baseUriDomains");(o.length>0||a.length>0)&&v("CSP_AXIS_UNSUPPORTED"),(Yr(e)>vr||i.length>gi||r.length>gi||i.length+r.length>Vr||[...i,...r].some(A=>new TextEncoder().encode(A).byteLength>Fr))&&v("CSP_LIMIT_EXCEEDED");let c=i.map(A=>mi(A,"connectDomains")),d=r.map(A=>mi(A,"frameDomains")),p=new Set((n.runtimeHostnames??[]).map(A=>A.toLowerCase().replace(/\.$/,"")));[...c,...d].some(A=>es(A.hostname,p))&&v("CSP_ORIGIN_FORBIDDEN");let l={declared:true,connectDomains:_i(c),frameDomains:_i(d)},u=Ti(l);return Object.freeze({...l,resourceDomains:Object.freeze([]),baseUriDomains:Object.freeze([]),cspHash:crypto.createHash("sha256").update(u,"utf8").digest("hex")})}var vr,gi,Vr,Fr,Br,Hr,zr,Gr,$r,Jr,Wr,gt,Ni=k(()=>{g();vr=4096,gi=16,Vr=32,Fr=512,Br=new Set(["connectDomains","frameDomains","resourceDomains","baseUriDomains"]),Hr=["localhost","local","internal","home.arpa","test","example","invalid","onion","lan","corp","home","intranet","private","localdomain"],zr=/^(https|wss):\/\/([^/?#]+)$/i,Gr=/^\[[^\]]+\](?::[0-9]+)?$/,$r=/^[^:\[\]]+(?::[0-9]+)?$/,Jr=/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/,Wr=[[0,8],[1681915904,10],[167772160,8],[2130706432,8],[2851995648,16],[2886729728,12],[3221225984,24],[3227017984,24],[3232235520,16],[3323068416,15],[3325256704,24],[3405803776,24],[3758096384,4],[4026531840,4]],gt=class extends Error{constructor(t){super(t);this.code=t;}code;name="UiPluginCspNormalizationError"};});function rn(e,n){return n===void 0||n===""?e:e===""?n:n.startsWith("[")?`${e}${n}`:`${e}.${n}`}function y(e,n=e,t,i){throw new oe(e,n,t,i)}function F(e,n){try{return n()}catch(t){throw t instanceof oe?t.withPathPrefix(e):t}}function B(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;try{let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}catch{return false}}function U(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function Ss(e,n){let t={};for(let[i,r]of Object.entries(e))i!==n&&(t[i]=r);return t}function $(e,n,t=[]){let i=new Set([...n,...t]),r=Object.keys(e).find(a=>!i.has(a));r!==void 0&&y("MANIFEST_INVALID","MANIFEST_INVALID",r,"unknown-key");let o=n.find(a=>!U(e,a));o!==void 0&&y("MANIFEST_INVALID","MANIFEST_INVALID",o,"missing-key");}function Rn(e,n=false,t=false,i=false){return os.test(e)||!i&&ss.test(e)||rs.test(e)||t&&bi.test(e)||as.test(e)&&!(n&&/^\s*data:/i.test(e)&&!bi.test(e))}function On(e,n=new Set,t=0,i=false,r=false,o=""){if(typeof e=="string"){Rn(e,i,r)&&y("UNSAFE_VALUE","UNSAFE_VALUE",o,"unsafe-value");return}if(!(e===null||typeof e!="object")){(t>8||n.has(e))&&y("MANIFEST_INVALID","MANIFEST_INVALID",o),n.add(e);try{if(Array.isArray(e)){e.forEach((a,s)=>On(a,n,t+1,!1,!1,rn(o,`[${s}]`)));return}B(e)||y("MANIFEST_INVALID","MANIFEST_INVALID",o);for(let[a,s]of Object.entries(e))On(s,n,t+1,i&&t===0&&(a==="name"||a==="description"),r,rn(o,a));}finally{n.delete(e);}}}function ge(e,n){let t=e[n];return typeof t!="string"&&y("MANIFEST_INVALID"),t}function le(e,n,t){let i=e[n];return (!Number.isSafeInteger(i)||i<t)&&y("MANIFEST_INVALID"),i}function mt(e){return is.test(e)||y("MANIFEST_INVALID"),e}function Ge(e){return ts.test(e)||y("TOKEN_INVALID"),e}function Ls(e){return ki.test(e)||y("MANIFEST_INVALID"),e}function Os(e){B(e)||y("MANIFEST_INVALID");let n={};for(let[t,i]of Object.entries(e)){let r=Ls(t);B(i)||y("MANIFEST_INVALID");let o=i.type;if(o==="text"){$(i,["type","maxLength"]),n[r]={type:o,maxLength:le(i,"maxLength",1)};continue}if(o==="text-list"){$(i,["type","max","itemMaxLength"]),n[r]={type:o,max:le(i,"max",0),itemMaxLength:le(i,"itemMaxLength",1)};continue}if(o==="step-list"){$(i,["type","min","max","labelMaxLength","detailMaxLength"]);let a=le(i,"min",0),s=le(i,"max",1);a>s&&y("MANIFEST_INVALID"),n[r]={type:o,min:a,max:s,labelMaxLength:le(i,"labelMaxLength",1),detailMaxLength:le(i,"detailMaxLength",1)};continue}typeof o=="string"&&y("SCHEMA_TYPE_UNSUPPORTED"),y("MANIFEST_INVALID");}return n}function Rs(e,n,t){let i=e[n];(!i||i.type!==t)&&y("MANIFEST_INVALID");}function Sn(e,n,t){let i=ge(e,"field");return ki.test(i)||y("MANIFEST_INVALID"),Rs(n,i,t),i}function Us(e,n){B(e)||y("MANIFEST_INVALID");let t=e.primitive;switch(typeof t!="string"&&y("MANIFEST_INVALID"),Ms.includes(t)||y("PRIMITIVE_UNKNOWN"),t){case "card-shell":return $(e,["primitive"]),{primitive:t};case "meta-banner":return $(e,["primitive","badgeToken","noticeToken"]),{primitive:t,badgeToken:Ge(ge(e,"badgeToken")),noticeToken:Ge(ge(e,"noticeToken"))};case "heading":return $(e,["primitive","field"]),{primitive:t,field:Sn(e,n,"text")};case "labeled-text":return $(e,["primitive","titleToken","field","variant"]),e.variant!=="callout"&&y("MANIFEST_INVALID"),{primitive:t,titleToken:Ge(ge(e,"titleToken")),field:Sn(e,n,"text"),variant:"callout"};case "step-flow":return $(e,["primitive","titleToken","field"]),{primitive:t,titleToken:Ge(ge(e,"titleToken")),field:Sn(e,n,"step-list")};case "text-list":{$(e,["primitive","titleToken","field"],["emptyToken","hideWhenEmpty"]);let i={primitive:t,titleToken:Ge(ge(e,"titleToken")),field:Sn(e,n,"text-list")};return U(e,"emptyToken")&&(i.emptyToken=Ge(ge(e,"emptyToken"))),U(e,"hideWhenEmpty")&&(typeof e.hideWhenEmpty!="boolean"&&y("MANIFEST_INVALID"),i.hideWhenEmpty=e.hideWhenEmpty),i}}return y("MANIFEST_INVALID")}function Cs(e,n){return Array.isArray(e)||y("MANIFEST_INVALID"),e.map(t=>Us(t,n))}function J(e="v2 manifest exceeds a contract limit",n,t){return y("LIMIT_EXCEEDED",e,n,t)}function pe(e="initial state is not projection-safe"){return y("INITIAL_STATE_INVALID",e)}function Pi(e,n){return (typeof e!="string"||e.length===0||e.length>4096||e.trim().length===0||Ns.test(e)||bs.test(e))&&y("MANIFEST_INVALID",`${n} is invalid`),(Rn(e,true,true)||cs.test(e)||ds.test(e)||ps.test(e))&&y("UNSAFE_VALUE",`${n} contains an unsafe value`),e}function ht(e,n){return (typeof e!="string"||!Ie.test(e))&&y("MANIFEST_INVALID",`${n} is invalid`),e}function ks(e){return (typeof e!="string"||!st.test(e)||e==="*"||e==="all")&&y("MANIFEST_INVALID","action capability is invalid"),e}function wi(e){return (typeof e!="string"||!Ds.test(e))&&y("MANIFEST_INVALID","resource hash is invalid"),e}function _t(e,n=new Set,t=0,i=""){if(typeof e=="string"){e.length>4096&&J("v2 manifest string is too long",i,"string-too-long");return}if(!(e===null||typeof e=="boolean")){if(typeof e=="number"){Number.isFinite(e)||y("MANIFEST_INVALID","v2 manifest contains a non-finite number",i,"non-finite-number");return}(e===void 0||typeof e=="function"||typeof e=="bigint")&&y("MANIFEST_INVALID","v2 manifest contains a non-JSON value",i,"non-json-value"),typeof e!="object"&&y("MANIFEST_INVALID","MANIFEST_INVALID",i),t>8&&J("v2 manifest nesting is too deep",i,"too-deep"),n.has(e)&&y("MANIFEST_INVALID","v2 manifest contains a cycle",i,"cycle"),n.add(e);try{if(Array.isArray(e)){e.length>128&&J("v2 manifest array is too long",i,"array-too-long"),e.forEach((r,o)=>_t(r,n,t+1,rn(i,`[${o}]`)));return}B(e)||y("MANIFEST_INVALID","v2 manifest contains a non-plain object",i,"non-plain-object");for(let[r,o]of Object.entries(e))_t(o,n,t+1,rn(i,r));}finally{n.delete(e);}}}function xi(e){return (typeof e!="string"||e.length>4096||!nn.test(e))&&(typeof e=="string"&&e.length>4096&&J("projection path is too long"),y("MANIFEST_INVALID","projection paths must be canonical exact paths")),e.split(".").some(t=>He(t))&&y("MANIFEST_INVALID","projection paths cannot address reserved state keys"),e}function Tt(e){B(e)||y("MANIFEST_INVALID","projection policy must be an object"),$(e,["allow"]),Array.isArray(e.allow)||y("MANIFEST_INVALID","projection allow must be an array"),e.allow.length>128&&J("projection allowlist is too long");let n=[],t=new Set;for(let i of e.allow){let r=xi(i);t.has(r)&&y("MANIFEST_INVALID","projection allowlist contains a duplicate path"),t.add(r),n.push(r);}return {allow:n}}function ws(e,n){if(e===void 0)return;Array.isArray(e)||y("MANIFEST_INVALID","dataPaths must be an array"),e.length>Ps&&J("dataPaths exceed the v2 limit");let t=[],i=new Set;for(let r of e){let o=xi(r);i.has(o)&&y("MANIFEST_INVALID","dataPaths contain a duplicate path"),n.some(a=>Fe(o,a))||y("MANIFEST_INVALID","dataPaths must be projection-allowed"),i.add(o),t.push(o);}return t}function $e(e,n,t=Number.MAX_SAFE_INTEGER){return (!Number.isSafeInteger(e)||e<0||e>t)&&y("MANIFEST_INVALID",`${n} is invalid`),e}function Mi(e,n){return (typeof e!="number"||!Number.isFinite(e))&&y("MANIFEST_INVALID",`${n} is invalid`),e}function Et(e,n=0,t=new Set){if(typeof e=="string")return (e.length>4096||Rn(e))&&y("UNSAFE_VALUE","schema enum contains an unsafe string"),e;if(e===null||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)||y("MANIFEST_INVALID","schema enum contains a non-finite number"),e;(n>8||typeof e!="object"||e===void 0)&&J("schema enum is too deep"),t.has(e)&&y("MANIFEST_INVALID","schema enum contains a cycle"),t.add(e);try{if(Array.isArray(e))return e.length>128&&J("schema enum array is too long"),e.map(r=>Et(r,n+1,t));B(e)||y("MANIFEST_INVALID","schema enum contains a non-plain object");let i={};for(let[r,o]of Object.entries(e))He(r)&&y("MANIFEST_INVALID","schema enum contains a reserved key"),i[r]=Et(o,n+1,t);return i}finally{t.delete(e);}}function xs(e,n){if(e===void 0)return;Array.isArray(e)||y("MANIFEST_INVALID","schema required must be an array"),e.length>64&&J("schema required list is too long");let t=[],i=new Set;for(let r of e)(typeof r!="string"||!nn.test(r))&&y("MANIFEST_INVALID","schema required contains an invalid key"),r.length>4096&&J("schema required key is too long"),i.has(r)&&y("MANIFEST_INVALID","schema required contains a duplicate key"),n&&!Object.prototype.hasOwnProperty.call(n,r)&&y("MANIFEST_INVALID","schema required references an undeclared property"),i.add(r),t.push(r);return t}function js(e,n){let t=n?nn:bn;return e.length>4096&&J("schema property name is too long"),(!t.test(e)||e.split(".").some(i=>He(i)))&&y("MANIFEST_INVALID","schema property name is invalid"),e}function Dt(e,n=0,t=false){B(e)||y("MANIFEST_INVALID","action inputSchema must be an object"),n>8&&J("action inputSchema is too deep");let i=e.type;i!=="object"&&i!=="string"&&i!=="number"&&i!=="integer"&&i!=="boolean"&&i!=="array"&&i!=="null"&&(typeof i=="string"&&y("SCHEMA_TYPE_UNSUPPORTED","action inputSchema type is unsupported"),y("MANIFEST_INVALID","action inputSchema type is required"));let r=["type","enum"];i==="string"&&r.push("minLength","maxLength"),i==="array"&&r.push("minItems","maxItems","items"),i==="object"&&r.push("minProperties","maxProperties","properties","required","additionalProperties"),(i==="number"||i==="integer")&&r.push("minimum","maximum"),$(e,["type"],r.filter(s=>s!=="type"));let o={type:i};if(U(e,"enum")&&(Array.isArray(e.enum)||y("MANIFEST_INVALID","schema enum must be an array"),e.enum.length>128&&J("schema enum is too long"),o.enum=e.enum.map(s=>Et(s))),i==="string"&&(U(e,"minLength")&&(o.minLength=$e(e.minLength,"schema minLength",4096)),U(e,"maxLength")&&(o.maxLength=$e(e.maxLength,"schema maxLength",4096)),o.minLength!==void 0&&o.maxLength!==void 0&&o.minLength>o.maxLength&&y("MANIFEST_INVALID","schema string length bounds are inverted")),(i==="number"||i==="integer")&&(U(e,"minimum")&&(o.minimum=Mi(e.minimum,"schema minimum")),U(e,"maximum")&&(o.maximum=Mi(e.maximum,"schema maximum")),o.minimum!==void 0&&o.maximum!==void 0&&o.minimum>o.maximum&&y("MANIFEST_INVALID","schema numeric bounds are inverted")),i==="array"&&(U(e,"minItems")&&(o.minItems=$e(e.minItems,"schema minItems",128)),U(e,"maxItems")&&(o.maxItems=$e(e.maxItems,"schema maxItems",128)),o.minItems!==void 0&&o.maxItems!==void 0&&o.minItems>o.maxItems&&y("MANIFEST_INVALID","schema array length bounds are inverted"),U(e,"items")&&(o.items=Dt(e.items,n+1,false))),i==="object"){let s;if(U(e,"properties")){B(e.properties)||y("MANIFEST_INVALID","schema properties must be an object");let d=Object.entries(e.properties);d.length>64&&J("schema properties are too many"),s={};for(let[p,l]of d){let u=js(p,t);s[u]=Dt(l,n+1,false);}o.properties=s;}U(e,"minProperties")&&(o.minProperties=$e(e.minProperties,"schema minProperties",64)),U(e,"maxProperties")&&(o.maxProperties=$e(e.maxProperties,"schema maxProperties",64)),o.minProperties!==void 0&&o.maxProperties!==void 0&&o.minProperties>o.maxProperties&&y("MANIFEST_INVALID","schema object property bounds are inverted");let c=xs(e.required,s);c!==void 0&&(o.required=c),U(e,"additionalProperties")&&(e.additionalProperties!==false&&y("MANIFEST_INVALID","schema additionalProperties must be false"),o.additionalProperties=false);}let a=JSON.stringify(o);return (a===void 0||Buffer.byteLength(a,"utf8")>2097152)&&J("action inputSchema subtree is too large"),o}function vs(e){let n=Dt(e,0,true);return (n.type!=="object"||!n.properties)&&y("MANIFEST_INVALID","action inputSchema must declare object properties"),n}function Vs(e){if(B(e)||y("MANIFEST_INVALID","action backend must be an object"),e.type==="core"){$(e,gs);let n=e.handler;return (typeof n!="string"||!at.test(n))&&y("MANIFEST_INVALID","core backend handler is invalid"),{type:"core",handler:n}}if(e.type==="skill"&&U(e,"entry"))return $(e,_s),e.entry!==ze&&y("MANIFEST_INVALID",`skill backend entry must be ${ze}`),{type:"skill",entry:ze};if(e.type==="skill"){$(e,ms,hs),(!Array.isArray(e.command)||e.command.length===0||e.command.length>16)&&y("MANIFEST_INVALID","skill backend command is invalid");let n=[];for(let i of e.command)(typeof i!="string"||i.length===0||i.length>256||!ct.test(i))&&y("MANIFEST_INVALID","skill backend command token is invalid"),n.push(i);let t=U(e,"env")?Bs(e.env):void 0;return {type:"skill",command:n,...t===void 0?{}:{env:t}}}y("MANIFEST_INVALID","action backend type is unsupported");}function Fs(e){B(e)||y("MANIFEST_INVALID","action must be an object"),$(e,ys,As),U(e,"_meta")&&F("_meta",()=>ji(e._meta));let n=F("actionId",()=>ht(e.actionId,"actionId"));it(n)&&y("MANIFEST_INVALID",`actionId "${n}" is not projection-safe`,"actionId");let t=F("capability",()=>ks(e.capability)),i=e.mutation;typeof i!="boolean"&&y("MANIFEST_INVALID","action mutation must be boolean","mutation");let r=F("inputSchema",()=>vs(e.inputSchema)),o;if(U(e,"dataInputs")){Array.isArray(e.dataInputs)||y("MANIFEST_INVALID","action dataInputs must be an array","dataInputs");let p=r.properties,l=new Set,u=[];for(let A of e.dataInputs)(typeof A!="string"||!U(p,A)||l.has(A))&&y("MANIFEST_INVALID","action dataInputs must be unique declared properties","dataInputs"),l.add(A),u.push(A);o=u;}let a=F("resultProjection",()=>Tt(e.resultProjection)),s=F("backend",()=>Vs(e.backend)),c;U(e,"content")&&((s.type!=="skill"||!Pn(e.content))&&y("MANIFEST_INVALID","action content declaration is invalid","content"),c=Hs(e.content));let d;if(U(e,"confirmation")){let p=e.confirmation;p!=="none"&&p!=="native"&&y("MANIFEST_INVALID","action confirmation is invalid","confirmation"),d=p;}return {actionId:n,capability:t,mutation:i,inputSchema:r,resultProjection:a,backend:s,...c===void 0?{}:{content:c},...o===void 0?{}:{dataInputs:o},...d===void 0?{}:{confirmation:d}}}function Bs(e){return yi(e)||y("MANIFEST_INVALID","skill backend env is invalid"),Object.freeze([...e])}function Hs(e){return Object.freeze({...e.in===void 0?{}:{in:Object.freeze({...e.in})},...e.out===void 0?{}:{out:Object.freeze({...e.out})}})}function zs(e){return B(e)||y("INITIAL_STATE_INVALID","initialState must be an object"),$(e,Ts,Es),e.path!=="ui/state.json"&&y("MANIFEST_INVALID","initialState path is not fixed"),U(e,"hash")?{path:"ui/state.json",hash:wi(e.hash)}:{path:"ui/state.json"}}function Gs(e){let n=["wasm","terminal","htmlDocuments"];return (!B(e)||Object.keys(e).length===0||Object.keys(e).some(t=>!n.includes(t)||e[t]!==true))&&y("MANIFEST_INVALID","runtime must contain only known capability flags set to true"),{...e.wasm===true?{wasm:true}:{},...e.terminal===true?{terminal:true}:{},...e.htmlDocuments===true?{htmlDocuments:true}:{}}}function $s(e,n){let t;try{t=Di(e);}catch(i){let r=i!==null&&typeof i=="object"&&"code"in i&&typeof i.code=="string"?i.code:"CSP_ORIGIN_INVALID";return y("MANIFEST_INVALID",r,void 0,r.toLowerCase().replace(/_/g,"-"))}if(t.frameDomains.length>0&&y("MANIFEST_INVALID","external origins in csp are not enabled in this rollout",void 0,"csp-not-enabled"),t.connectDomains.length!==0)return n?.terminal===true&&y("MANIFEST_INVALID","runtime.terminal cannot be combined with csp.connectDomains","connectDomains","terminal-with-connect-domains"),Object.freeze({connectDomains:t.connectDomains})}function Js(e,n){On(B(e)&&U(e,"csp")?Ss(e,"csp"):e,new Set,0,true,true),_t(e),B(e)||y("MANIFEST_INVALID"),$(e,us,fs),U(e,"_meta")&&F("_meta",()=>ji(e._meta)),e.manifestVersion!==2&&y("MANIFEST_INVALID");let t;U(e,"runtime")&&(t=F("runtime",()=>Gs(e.runtime)));let i;U(e,"csp")&&(i=F("csp",()=>$s(e.csp,t)));let r=F("pluginId",()=>ht(e.pluginId,"pluginId")),o=F("definitionId",()=>ht(e.definitionId,"definitionId")),a=F("version",()=>le(e,"version",1)),s=F("name",()=>Pi(e.name,"name")),c=F("description",()=>Pi(e.description,"description")),d;U(e,"icon")&&((typeof e.icon!="string"||!/^[a-z][a-z0-9-]{0,63}$/.test(e.icon))&&y("MANIFEST_INVALID","icon is invalid","icon"),d=e.icon);let p;U(e,"tone")&&((typeof e.tone!="string"||!dt.includes(e.tone))&&y("MANIFEST_INVALID","tone is invalid","tone"),p=e.tone),e.entry!=="ui/index.html"&&y("MANIFEST_INVALID","entry path is not fixed","entry","fixed-value");let l;U(e,"entryHash")&&(l=F("entryHash",()=>wi(e.entryHash)));let u;U(e,"initialState")&&(u=F("initialState",()=>zs(e.initialState)));let A;U(e,"usage")&&(e.usage!=="card"&&e.usage!=="window"&&y("MANIFEST_INVALID","usage is invalid","usage"),A=e.usage);let I;U(e,"detailPanel")&&(typeof e.detailPanel!="boolean"&&y("MANIFEST_INVALID","detailPanel is invalid","detailPanel"),I=e.detailPanel);let h;if(U(e,"displayModes")){((A??tn)!==tn||!Array.isArray(e.displayModes)||e.displayModes.length===0)&&y("MANIFEST_INVALID","displayModes are only valid for window Apps","displayModes");let f=new Set(["inline","floating","focused"]);(new Set(e.displayModes).size!==e.displayModes.length||e.displayModes.some(m=>typeof m!="string"||!f.has(m)))&&y("MANIFEST_INVALID","displayModes are invalid","displayModes"),h=e.displayModes;}(A??tn)===tn&&I!==void 0&&y("MANIFEST_INVALID","detailPanel is card-only","detailPanel");let b=n.mode??"local";b!=="local"&&b!=="installed"&&b!=="published"&&y("MANIFEST_INVALID","manifest mode is invalid"),b!=="local"&&l===void 0&&y("MANIFEST_INVALID","installed manifests require entryHash","entryHash","required-when-installed"),b!=="local"&&u!==void 0&&u.hash===void 0&&y("MANIFEST_INVALID","installed manifests require initialState.hash","initialState.hash","required-when-installed"),(!Array.isArray(e.surfaces)||e.surfaces.length===0)&&y("MANIFEST_INVALID","surfaces are invalid","surfaces"),e.surfaces.length>2&&J("surfaces exceed the v2 limit","surfaces","too-many-items");let V=[],j=new Set;for(let f of e.surfaces)(typeof f!="string"||!pt.includes(f))&&y("MANIFEST_INVALID","surface is unsupported","surfaces"),j.has(f)&&y("MANIFEST_INVALID","surfaces contain a duplicate","surfaces","duplicate-item"),j.add(f),V.push(f);B(e.size)||y("MANIFEST_INVALID","size must be an object","size"),F("size",()=>$(e.size,["height"]));let P=F("size",()=>le(e.size,"height",1));P>720&&J("size.height exceeds the v2 limit","size.height","too-large");let O=F("stateProjection",()=>Tt(e.stateProjection)),H=e.summaryProjection===void 0?void 0:F("summaryProjection",()=>Tt(e.summaryProjection));H!==void 0&&H.allow.some(f=>!O.allow.includes(f))&&y("MANIFEST_INVALID","summaryProjection must be a subset of stateProjection.allow","summaryProjection");let N=F("dataPaths",()=>ws(e.dataPaths,O.allow));Array.isArray(e.actions)||y("MANIFEST_INVALID","actions must be an array","actions"),e.actions.length>32&&J("actions exceed the v2 limit","actions","too-many-items");let L=[],S=new Set;for(let[f,m]of e.actions.entries()){let T=`actions[${f}]`,M=F(T,()=>Fs(m));if(S.has(M.actionId)&&y("MANIFEST_INVALID","actions contain a duplicate actionId",`${T}.actionId`,"duplicate-item"),M.backend.type==="core"&&M.backend.handler==="state.set"){M.mutation||y("MANIFEST_INVALID","state.set actions must be mutations",`${T}.mutation`);for(let D of Object.keys(M.inputSchema.properties))O.allow.includes(D)||y("MANIFEST_INVALID","state.set input paths must be projection-allowed",`${T}.inputSchema.properties`);}S.add(M.actionId),L.push(M);}return {manifestVersion:2,pluginId:r,definitionId:o,version:a,name:s,description:c,...d===void 0?{}:{icon:d},...p===void 0?{}:{tone:p},entry:"ui/index.html",...l===void 0?{}:{entryHash:l},...t===void 0?{}:{runtime:t},...i===void 0?{}:{csp:i},...u===void 0?{}:{initialState:u},...A===void 0?{}:{usage:A},...I===void 0?{}:{detailPanel:I},...h===void 0?{}:{displayModes:h},surfaces:V,size:{height:P},stateProjection:O,...H===void 0?{}:{summaryProjection:H},...N===void 0?{}:{dataPaths:N},actions:L}}function ji(e){B(e)||y("MANIFEST_INVALID","_meta must be an object");let n=JSON.stringify(e);(n===void 0||Buffer.byteLength(n,"utf8")>Is)&&J("_meta exceeds the 4 KiB limit",void 0,"meta-too-large");}function Ws(e){let n={},t={};for(let o of e.actions){n[o.actionId]={capabilities:[o.capability],inputKeys:Object.keys(o.inputSchema.properties??{}),...o.dataInputs===void 0?{}:{dataInputs:o.dataInputs},resultProjection:o.resultProjection,...o.confirmation===void 0?{}:{confirmation:o.confirmation},...o.content===void 0?{}:{content:o.content},...o.backend.type!=="skill"||o.backend.env===void 0?{}:{env:o.backend.env}};let a=o.backend.type==="skill"||o.backend.type==="core"&&o.backend.handler==="state.set";t[o.actionId]={actionId:o.actionId,mutation:o.mutation,backend:o.backend,launchPolicy:a?"allowed":"denied",...a?{}:{denialCode:"EXEC_DENIED"}};}let i={id:e.definitionId,version:e.version,renderer:"sandbox-html",...e.usage===void 0?{}:{usage:e.usage},...e.detailPanel===void 0?{}:{detailPanel:e.detailPanel},...e.displayModes===void 0?{}:{displayModes:e.displayModes},surfaces:e.surfaces,stateProjection:e.stateProjection,...e.summaryProjection===void 0?{}:{summaryProjection:e.summaryProjection},...e.dataPaths===void 0?{}:{dataPaths:e.dataPaths},actions:n},r={entry:{path:"ui/index.html",...e.entryHash===void 0?{}:{hash:e.entryHash}},...e.initialState===void 0?{}:{initialState:e.initialState}};return {manifest:e,definition:i,handlers:t,resources:r}}function Nt(e,n,t,i,r,o){if(typeof e=="string"){let a=r.length>0&&o.some(s=>Fe(r.join("."),s));return (e.length>4096||Rn(e,false,false,a))&&pe("state contains an unsafe string"),e}if(e===null||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)||pe("state contains a non-finite number"),e;(e===void 0||typeof e!="object"||typeof e=="function"||typeof e=="bigint")&&pe("state contains a non-JSON value"),t>8&&pe("state is too deep"),n.has(e)&&pe("state contains a cycle"),n.add(e);try{let a;if(Array.isArray(e))e.length>128&&pe("state array is too long"),a=e.map(c=>Nt(c,n,t+1,2097152,r,o));else {B(e)||pe("state contains a non-plain object");let c={};for(let[d,p]of Object.entries(e))(d.length>4096||!bn.test(d)||He(d))&&(d.length>4096&&pe("state key is too long"),pe("state contains a reserved or invalid key")),c[d]=Nt(p,n,t+1,2097152,[...r,d],o);a=c;}let s=JSON.stringify(a);return (s===void 0||Buffer.byteLength(s,"utf8")>i)&&pe("state subtree is too large"),a}finally{n.delete(e);}}function Pt(e,n=[]){B(e)||pe("initial state must be a JSON object");let t=Nt(e,new Set,0,2097152,[],n);return (t===null||Array.isArray(t)||typeof t!="object")&&pe(),t}function Xs(e,n={}){On(e),B(e)||y("MANIFEST_INVALID"),$(e,ls),e.manifestVersion!==1&&y("MANIFEST_INVALID");let t=mt(ge(e,"pluginId")),i=mt(ge(e,"definitionId")),r=le(e,"version",1),o=le(e,"primitiveSet",1),a=n.supportedPrimitiveSet??ns;(!Number.isSafeInteger(a)||a<1)&&y("MANIFEST_INVALID"),o>a&&y("PRIMITIVE_SET_UNSUPPORTED"),B(e.activation)||y("MANIFEST_INVALID"),$(e.activation,["kind","language"]),e.activation.kind!=="fenced-code"&&y("MANIFEST_INVALID");let s=mt(ge(e.activation,"language")),c=Os(e.schema),d=Cs(e.layout,c);return {manifestVersion:1,pluginId:t,definitionId:i,version:r,primitiveSet:o,activation:{kind:"fenced-code",language:s},schema:c,layout:d}}function Ks(e,n={}){return B(e)||y("MANIFEST_INVALID"),Object.hasOwn(e,"lineage")&&y("MANIFEST_INVALID","lineage is only allowed in product bundle indexes"),e.manifestVersion===2?Js(e,n):Xs(e,n)}function sn(e,n={}){try{return Ks(e,n)}catch(t){if(t instanceof oe)throw t;return y("MANIFEST_INVALID")}}function an(e,n={}){let t=sn(e,n);return t.manifestVersion===2?Ws(t):t}var ns,ts,is,ki,os,rs,ss,as,bi,cs,ds,ps,ls,us,fs,ys,As,Is,gs,ms,hs,_s,Ts,Es,Ds,Ns,bs,Ps,Ms,oe,Mt=k(()=>{g();fi();De();ft();Ai();It();Ni();Re();ns=1,ts=/^[a-z][a-zA-Z0-9]*(\.[a-zA-Z0-9]+)+$/,is=/^[A-Za-z][A-Za-z0-9._-]{0,127}$/,ki=/^[A-Za-z][A-Za-z0-9_-]{0,63}$/,os=/<\/?[A-Za-z][^>]*>/,rs=/^(?:[A-Za-z]:[\\/]|\\\\|~[\\/]|\/)/,ss=/^(?:https?|file|ftp|ws|wss):\/\//i,as=/^\s*(?:javascript|data):/i,bi=/data:[^,\s]*,/i,cs=/(?:https?|file|ftp|ws|wss):\/\//i,ds=/javascript:/i,ps=/(?:^[\s]*|[\s"'(=])(?:[A-Za-z]:[\\/]|\\\\|~[\\/]|\/)(?=[^\s"'<>])[^\s"'<>]*/,ls=["manifestVersion","pluginId","definitionId","version","primitiveSet","activation","schema","layout"],us=["manifestVersion","pluginId","definitionId","version","name","description","entry","surfaces","size","stateProjection","actions"],fs=["_meta","icon","tone","entryHash","runtime","csp","initialState","usage","detailPanel","displayModes","summaryProjection","dataPaths","focusedAiDataPaths"],ys=["actionId","capability","mutation","inputSchema","resultProjection","backend"],As=["confirmation","dataInputs","content","_meta"],Is=4*1024,gs=["type","handler"],ms=["type","command"],hs=["env"],_s=["type","entry"],Ts=["path"],Es=["hash"],Ds=/^[0-9a-f]{64}$/,Ns=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/,bs=/[\r\n]/,Ps=16,Ms=["card-shell","meta-banner","heading","labeled-text","step-flow","text-list"],oe=class e extends Error{constructor(t,i=t,r,o){super(i);this.code=t;this.path=r;this.rule=o;}code;path;rule;name="UiPluginValidationError";withPathPrefix(t){return new e(this.code,this.message,rn(t,this.path),this.rule)}};});function zi(e){return typeof e=="string"&&e.length<=qs&&Ys.test(e)}function C(e,n,t,i,r){throw new he(e,{path:n,rule:t,...i===void 0?{}:{message:i},...r===void 0?{}:{file:r}})}function Z(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;try{let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}catch{return false}}function W(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function fe(e){let n=`_meta["${Me}"]`;return e===void 0||e===""?n:e.startsWith("[")?`${n}${e}`:`${n}.${e}`}function na(e){return e.toLowerCase().replace(/_/g,"-")}function ta(e){if(e===void 0||e==="")return "";let n=/^([^.[]+)(.*)$/.exec(e);if(!n)return fe(e);let[,t,i]=n;switch(t){case "pluginId":return `name${i}`;case "name":return `display_name${i}`;case "description":return `description${i}`;case "_meta":return `_meta${i}`;case "version":return fe("definitionVersion");case "definitionId":return fe("definitionId");default:return fe(`${t}${i}`)}}function Gi(e,n,t){return {path:t(e.path),rule:e.rule??na(e.code),...e.message!==e.code?{message:e.message}:{},file:n}}function $i(e){return JSON.parse(JSON.stringify(e))}function Ot(e,n,t=0,i=new Set){if(typeof e=="string"){e.length>4096&&C("LIMIT_EXCEEDED",n,"string-too-long"),(Zs.test(e)||Qs.test(e)||ea.test(e))&&C("UNSAFE_VALUE",n,"unsafe-value");return}if(!(e===null||typeof e=="boolean")){if(typeof e=="number"){Number.isFinite(e)||C("MANIFEST_INVALID",n,"non-finite-number");return}typeof e!="object"&&C("MANIFEST_INVALID",n,"non-json-value"),t>8&&C("LIMIT_EXCEEDED",n,"too-deep"),i.has(e)&&C("MANIFEST_INVALID",n,"cycle"),i.add(e);try{if(Array.isArray(e)){e.length>128&&C("LIMIT_EXCEEDED",n,"array-too-long"),e.forEach((r,o)=>Ot(r,`${n}[${o}]`,t+1,i));return}Z(e)||C("MANIFEST_INVALID",n,"non-plain-object");for(let[r,o]of Object.entries(e))Ot(o,n===""?r:`${n}.${r}`,t+1,i);}finally{i.delete(e);}}}function ue(e,n){return (typeof e!="string"||e.length===0)&&C("MANIFEST_INVALID",n,"string"),e}function We(e,n){return Z(e)||C("MANIFEST_INVALID",n,"object"),e}function ia(e,n){Array.isArray(e)||C("MANIFEST_INVALID",n,"array"),e.forEach((t,i)=>ue(t,`${n}[${i}]`));}function oa(e,n){typeof e!="boolean"&&C("MANIFEST_INVALID",n,"boolean");}function cn(e,n,t,i){for(let r of Object.keys(e))!t.includes(r)&&!i.includes(r)&&C("MANIFEST_INVALID",`${n}.${r}`,"unknown-key");for(let r of t)W(e,r)||C("MANIFEST_INVALID",`${n}.${r}`,"missing-key");}function ra(e,n){switch(Ot(n,e),e){case "long_description":case "homepage":case "documentation":case "support":case "icon":case "license":ue(n,e);return;case "author":{let t=We(n,e);cn(t,e,["name"],["email","url"]);for(let i of Object.keys(t))ue(t[i],`${e}.${i}`);return}case "repository":{let t=We(n,e);cn(t,e,[],["type","url"]);for(let i of Object.keys(t))ue(t[i],`${e}.${i}`);return}case "icons":{Array.isArray(n)||C("MANIFEST_INVALID",e,"array"),n.forEach((t,i)=>{let r=`${e}[${i}]`,o=We(t,r);cn(o,r,["src","size"],["theme"]),ue(o.src,`${r}.src`),ue(o.size,`${r}.size`),W(o,"theme")&&ue(o.theme,`${r}.theme`);});return}case "screenshots":case "keywords":case "privacy_policies":ia(n,e);return;case "tools":{Array.isArray(n)||C("MANIFEST_INVALID",e,"array"),n.forEach((t,i)=>{let r=`${e}[${i}]`,o=We(t,r);cn(o,r,["name"],["description"]),ue(o.name,`${r}.name`),W(o,"description")&&ue(o.description,`${r}.description`);});return}case "prompts":{Array.isArray(n)||C("MANIFEST_INVALID",e,"array"),n.forEach((t,i)=>{let r=`${e}[${i}]`,o=We(t,r);cn(o,r,["name","text"],["description","arguments"]),ue(o.name,`${r}.name`),ue(o.text,`${r}.text`);});return}case "tools_generated":case "prompts_generated":oa(n,e);return;case "localization":case "compatibility":case "user_config":We(n,e);return;default:C("MANIFEST_INVALID",e,"unknown-key");}}function Un(e){return typeof e=="string"&&Ie.test(e)?e:void 0}function Ji(e){return Number.isSafeInteger(e)&&e>=1?e:void 0}function sa(e){let n=Un(e.name);if(n===void 0)return;let t=e._meta,i=Z(t)?t[Me]:void 0,r=Z(i)?i:{},o=W(r,"definitionId")?Un(r.definitionId):n,a=W(r,"definitionVersion")?Ji(r.definitionVersion):1;return {pluginId:n,...o===void 0?{}:{definitionId:o},...a===void 0?{}:{definitionVersion:a}}}function aa(e){let n=Un(e.pluginId);if(n===void 0)return;let t=Un(e.definitionId),i=Ji(e.version);return {pluginId:n,...t===void 0?{}:{definitionId:t},...i===void 0?{}:{definitionVersion:i}}}function kt(e){try{let n=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e));if(!Z(n))return !1;let t=n._meta;return Z(t)&&W(t,Me)}catch{return false}}function ca(e,n){if(e===ke)return n.builtinOnly===true;let t=n._meta,i=Z(t)?t[Me]:void 0;return Z(i)&&i.builtinOnly===true}function da(e,n){W(e,"server")&&C("MANIFEST_INVALID","server","server-unsupported","phase 1 runs CrewX-owned Apps only");for(let s of Object.keys(e))Ut.includes(s)||C("MANIFEST_INVALID",s,"unknown-key");for(let s of Ct)W(e,s)||C("MANIFEST_INVALID",s,"missing-key");e.manifest_version!==St&&C("MANIFEST_INVALID","manifest_version","unsupported-version",`manifest_version must be "${St}"`),zi(e.version)||C("MANIFEST_INVALID","version","semver","version must be a semver.org version such as 0.1.0");let t=e._meta;Z(t)||C("MANIFEST_INVALID","_meta","object"),W(t,Me)||C("MANIFEST_INVALID",fe(),"missing-key");let i=t[Me];Z(i)||C("MANIFEST_INVALID",fe(),"object");for(let s of Object.keys(i))Lt.includes(s)||Hi.includes(s)||C("MANIFEST_INVALID",fe(s),"unknown-key");for(let s of Lt)s==="actions"&&n!==void 0||W(i,s)||C("MANIFEST_INVALID",fe(s),"missing-key");if(n!==void 0&&W(i,"actions")&&C("MANIFEST_INVALID",fe("actions"),"two-truths",`actions are declared in both ${X} and ${K}; a server.ts App keeps them in the tools file only`),pa(i.actions),W(i,"definitionVersion")){let s=i.definitionVersion;(!Number.isSafeInteger(s)||s<1)&&C("MANIFEST_INVALID",fe("definitionVersion"),"positive-integer");}let r={};for(let s of Bi)W(e,s)&&(ra(s,e[s]),r[s]=$i(e[s]));let o={};for(let[s,c]of Object.entries(t))s!==Me&&(o[s]=c);let a={manifestVersion:2,pluginId:e.name,definitionId:W(i,"definitionId")?i.definitionId:e.name,version:W(i,"definitionVersion")?i.definitionVersion:1,name:e.display_name,description:e.description};for(let[s,c]of Object.entries(i))s==="definitionId"||s==="definitionVersion"||(a[s]=c);return n!==void 0&&(a.actions=n.map(s=>({...s,backend:{type:"skill",entry:ze}}))),Object.keys(o).length>0&&(a._meta=o),{v2Input:a,...Object.keys(o).length>0?{vendorMeta:o}:{},passthrough:r}}function pa(e){Array.isArray(e)&&e.forEach((n,t)=>{let i=Z(n)?n.backend:void 0;Z(i)&&W(i,"entry")&&C("MANIFEST_INVALID",fe(`actions[${t}].backend.entry`),"entry-not-authorable",`an action in ${X} cannot name an entry; a server.ts App declares its actions in ${K}`);});}function la(e,n,t){Z(e)||C("MANIFEST_INVALID","","not-object","manifest.json must be a JSON object",X);let i;try{i=da(e,t);}catch(a){throw a instanceof he?new he(a.code,{...a.reason,file:X}):a}let r;try{let a=sn(i.v2Input,{mode:n.mode??"local"});a.manifestVersion!==2&&C("MANIFEST_INVALID","","v2-required"),r=a;}catch(a){throw a instanceof oe?new he(a.code,Gi(a,X,ta)):a}let o=e.tools;if(Array.isArray(o)){let a=new Set(r.actions.map(s=>s.actionId));o.forEach((s,c)=>{let d=s.name;if(!a.has(d))throw new he("MANIFEST_INVALID",{path:`tools[${c}].name`,rule:"tool-not-action",message:"every tools[].name must be an action id",file:X})});}return {file:X,manifest:r,v2Input:i.v2Input,releaseVersion:e.version,...Object.keys(i.passthrough).length>0?{mcpb:i.passthrough}:{}}}function ua(e,n){try{let t=sn(e,{mode:n.mode??"local"});if(t.manifestVersion!==2)throw new he("MANIFEST_INVALID",{path:"manifestVersion",rule:"v2-required",message:"a workspace App requires manifestVersion 2",file:ke});return {file:ke,manifest:t,v2Input:e}}catch(t){throw t instanceof oe?new he(t.code,Gi(t,ke,i=>i??"")):t}}function Rt(e){return ie(an(e).definition)}function Vi(e){let{entryHash:n,initialState:t,...i}=e,r={...i};return t!==void 0&&(r.initialState={path:t.path}),$i(r)}function fa(e,n){let t=Vi(e),i=Vi(n);return [...new Set([...Object.keys(t),...Object.keys(i)])].sort().filter(o=>q(t[o]??null)!==q(i[o]??null))}function ya(e,n){return e.entryHash!==void 0&&n.entryHash!==void 0&&e.entryHash!==n.entryHash||e.initialState?.hash!==void 0&&n.initialState?.hash!==void 0&&e.initialState.hash!==n.initialState.hash}function Aa(e,n){let t=fa(e,n),i=ya(e,n),r="";try{let o=Rt(e),a=Rt(n);i=i||o!==a,r=` (definition hash ${o.slice(0,12)} vs ${a.slice(0,12)})`;}catch{i=true;}t.length===0&&!i||C("MANIFEST_DUAL_MISMATCH","","dual-manifest-mismatch",`${X} and ${ke} normalize to different definitions${r}`+(t.length>0?`; differing fields: ${t.join(", ")}`:""));}function me(e,n,t="MANIFEST_INVALID",i){return {code:t,reason:{path:e,rule:n,...i===void 0?{}:{message:i},file:K},files:[]}}function Fi(e){return {...me("","tools-needs-manifest-json","MANIFEST_INVALID",`${K} is read with ${X} only`),files:e}}function Ia(e,n){if(e.byteLength>n)return {failure:me("","file-too-large","LIMIT_EXCEEDED")};let t;try{t=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e));}catch{return {failure:me("","invalid-json")}}if(!Z(t))return {failure:me("","not-object","MANIFEST_INVALID",`${K} must be a JSON object`)};for(let r of Object.keys(t))if(r!=="schemaVersion"&&r!=="actions")return {failure:me(r,"unknown-key")};for(let r of ["schemaVersion","actions"])if(!W(t,r))return {failure:me(r,"missing-key")};if(t.schemaVersion!==1)return {failure:me("schemaVersion","unsupported-version","MANIFEST_INVALID",`schemaVersion must be ${1}`)};let i=t.actions;if(!Array.isArray(i))return {failure:me("actions","array")};for(let[r,o]of i.entries()){if(!Z(o))return {failure:me(`actions[${r}]`,"object")};if(W(o,"backend"))return {failure:me(`actions[${r}].backend`,"tools-backend","MANIFEST_INVALID",`an action in ${K} cannot carry a backend`)}}return {actions:i}}function ga(e,n){let t=n.maxBytes??262144,i=[],r=new TextDecoder("utf-8",{fatal:true});for(let o of re){let a=e[o];if(a===void 0)continue;if(a.byteLength>t)return {parsed:i,failure:{code:"LIMIT_EXCEEDED",reason:{path:"",rule:"file-too-large",file:o},files:[o]}};let s;try{s=JSON.parse(r.decode(a));}catch{return {parsed:i,failure:{code:"MANIFEST_INVALID",reason:{path:"",rule:"invalid-json",file:o},files:[o]}}}if(!Z(s))return {parsed:i,failure:{code:"MANIFEST_INVALID",reason:{path:"",rule:"not-object",message:`${o} must be a JSON object`,file:o},files:[o]}};i.push({file:o,raw:s});}return {parsed:i}}function wt(e,n={}){let{parsed:t,failure:i}=ga(e,n),r=re.filter(A=>e[A]!==void 0);if(i!==void 0)return {ok:false,rejection:i,parseFailure:true,builtinOnly:false};let o=e[K],a=o===void 0?void 0:Ia(o,n.maxBytes??262144);if(t.length===0)return {ok:false,rejection:a===void 0?{code:"MANIFEST_INVALID",reason:{path:"",rule:"no-manifest-file",message:"neither manifest.json nor ui-plugin.json is present"},files:[]}:Fi(r),parseFailure:true,builtinOnly:false};let s=t[0],c=s.file===X?sa(s.raw):aa(s.raw),d=t.some(A=>ca(A.file,A.raw)),p;if(a!==void 0){let A=t.some(I=>I.file===X)?a.failure:Fi(r);if(A!==void 0)return {ok:false,rejection:A,parseFailure:false,...c===void 0?{}:{identity:c},builtinOnly:d};p=a.actions;}let l=[];try{for(let A of t)l.push(A.file===X?la(A.raw,n,p):ua(A.raw,n));l.length===2&&Aa(l[0].manifest,l[1].manifest);}catch(A){if(A instanceof he)return {ok:false,rejection:{code:A.code,reason:A.reason,files:A.code==="MANIFEST_DUAL_MISMATCH"?[...re]:A.reason.file===void 0||A.reason.file===K?r:[A.reason.file]},parseFailure:false,...c===void 0?{}:{identity:c},builtinOnly:d};throw A}let u=l[0];return {ok:true,...u,identity:c??{pluginId:u.manifest.pluginId},files:r}}var X,ke,re,St,Me,Ut,Ct,Bi,Lt,Hi,Ys,qs,Zs,Qs,ea,he,xt=k(()=>{g();Ue();De();It();Re();Mt();X="manifest.json",ke="ui-plugin.json",re=[X,ke],St="0.3",Me="dev.crewx",Ut=Object.freeze(["manifest_version","name","display_name","version","description","long_description","author","repository","homepage","documentation","support","icon","icons","screenshots","localization","server","tools","tools_generated","prompts","prompts_generated","keywords","license","privacy_policies","compatibility","user_config","_meta"]),Ct=Object.freeze(["manifest_version","name","display_name","version","description","_meta"]),Bi=Object.freeze(Ut.filter(e=>e!=="server"&&!Ct.includes(e))),Lt=Object.freeze(["entry","surfaces","size","stateProjection","actions"]),Hi=Object.freeze(["definitionId","definitionVersion","icon","tone","entryHash","runtime","initialState","usage","detailPanel","displayModes","summaryProjection","dataPaths","focusedAiDataPaths","csp"]),Ys=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,qs=256,Zs=/<\/?[A-Za-z][^>]*>/,Qs=/^\s*javascript:/i,ea=/data:[^,\s]*,/i;he=class extends Error{constructor(t,i){super(`${t}: ${i.path||"<file>"} (${i.rule})`);this.code=t;this.reason=i;}code;reason};});var Wi=k(()=>{g();ui();xt();Mt();Re();});function E(e,n=e){throw new _e(e,n)}var _e,kn=k(()=>{g();_e=class extends Error{constructor(t,i=t){super(i);this.code=t;}code;name="McpAppContractError"};});var Xi=k(()=>{g();});var Ki=k(()=>{g();Ue();De();kn();Xi();});function qi(e,n){return Yi.add(e),n!==void 0&&ma.set(e,n),e}function Xe(e){return e!==null&&typeof e=="object"&&Yi.has(e)}var Yi,ma,wn=k(()=>{g();Yi=new WeakSet,ma=new WeakMap;});function ln(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function jt(e,n,t=[]){let i=new Set([...n,...t]),r=Object.keys(e);return n.every(o=>Object.hasOwn(e,o))&&r.every(o=>i.has(o))}function eo(e){if(e===null||typeof e!="object"||Object.isFrozen(e))return e;for(let n of Object.values(e))eo(n);return Object.freeze(e)}function Q(e){throw new Te("LINEAGE_INVALID",e)}function ba(e){throw new Te("LINEAGE_STALE",e)}function no(e){if(!ln(e)||!jt(e,Ta,Ea)||!ln(e.actions))return Q("Lineage definition shape is invalid");for(let n of Object.values(e.actions))if(!ln(n)||!jt(n,Da,Na))return Q("Lineage action definition shape is invalid");return e}function Pa(e){if(!ln(e)||!jt(e,ha,_a))return Q("Lineage entry shape is invalid");if(!Number.isSafeInteger(e.version)||e.version<1||typeof e.hash!="string"||!Zi.test(e.hash))return Q("Lineage entry identity is invalid");if(e.sourceHash!==void 0&&(typeof e.sourceHash!="string"||!Zi.test(e.sourceHash)))return Q("Lineage source hash is invalid");if(e.compat!==void 0&&e.compat!=="break")return Q("Lineage compatibility marker is invalid");let n=no(e.definition);if(n.version!==e.version)return Q("Lineage version does not match its definition");if(e.sourceHash!==void 0&&n.sourceHash!==e.sourceHash)return Q("Lineage source hash does not match its definition");let t;try{t=ie(n),de({...n,hash:e.hash});}catch{return Q("Lineage definition is invalid")}return t!==e.hash?Q("Lineage definition hash does not match"):eo({version:e.version,hash:e.hash,definition:n,...e.sourceHash===void 0?{}:{sourceHash:e.sourceHash},...e.compat===void 0?{}:{compat:e.compat}})}function Qi(e){return e.stateProjection?.allow??[]}function Ma(e,n){let t=[],i=new Set(Qi(n));Qi(e).some(s=>!i.has(s))&&t.push("S1_STATE_PROJECTION");let r=new Set(n.dataPaths??[]);(e.dataPaths??[]).some(s=>!r.has(s))&&t.push("S2_DATA_PATHS");for(let[s,c]of Object.entries(e.actions)){let d=n.actions[s];if(d&&(c.confirmation??"native")==="native"&&(d.confirmation??"native")!=="native"){t.push("S3_ACTION_CONFIRMATION");break}}Object.keys(e.legacy?.agentAccess??{}).some(s=>!Object.hasOwn(n.actions,s))&&t.push("S4_LEGACY_AGENT_ACTIONS");let a=e.summaryProjection?.allow;if(a!==void 0){let s=new Set(n.summaryProjection?.allow??[]);a.some(c=>!s.has(c))&&t.push("S5_SUMMARY_PROJECTION");}return t}function Sa(e,n){return q(e)===q(n)}function vt(e,n){if(!Array.isArray(e)||e.length===0)return Q("Definition lineage is missing");if(!ln(n)||typeof n.hash!="string")return Q("Current definition is invalid");let t,i;try{let{hash:s,...c}=n;i=no(c),t={...i,hash:s},de(t);}catch{return Q("Current definition is invalid")}let r=e.map(Pa),o=r[0].definition.id;if(r.some(s=>s.definition.id!==o))return Q("Lineage definition ids do not match");if(r.some((s,c)=>c>0&&s.version<=r[c-1].version))return Q("Lineage generations are not in increasing version order");if(r.some((s,c)=>r.findIndex(d=>d.hash===s.hash)!==c))return Q("Lineage contains a duplicate hash");let a=r[r.length-1];if(a.version!==t.version||a.hash!==t.hash||a.definition.id!==t.id||!Sa(a.definition,i))return ba("The last lineage generation does not match the current package");if(t.legacy!==void 0){let s=new Set(Object.keys(t.actions)),c=new Set;for(let p of r)if(p.sourceHash===void 0)for(let l of Object.keys(p.definition.actions))s.has(l)&&c.add(l);let d=Object.keys(t.legacy.agentAccess??{});if(d.length!==c.size||d.some(p=>!c.has(p))){let p="S4_LEGACY_AGENT_ACCESS_COMPLETE";throw new Te("LINEAGE_INVALID",`Lineage compatibility failed: ${p}`,[p])}}for(let s=0;s<r.length-1;s+=1){if(r.slice(s,-1).some(p=>p.compat==="break"))continue;let d=Ma(r[s].definition,t);if(d.length>0)throw new Te("LINEAGE_INVALID",`Lineage compatibility failed: ${d.join(", ")}`,d)}return Object.freeze({entries:Object.freeze(r),current:t})}var Te,Zi,ha,_a,Ta,Ea,Da,Na,Vt=k(()=>{g();Ue();De();Te=class extends Error{constructor(t,i=t,r=[]){super(i);this.code=t;this.violations=r;}code;violations;name="UiDefinitionLineageError"},Zi=/^[0-9a-f]{64}$/,ha=["version","hash","definition"],_a=["sourceHash","compat"],Ta=["id","version","actions"],Ea=["sourceHash","usage","detailPanel","displayModes","renderer","surfaces","stateProjection","dataPaths","summaryProjection","legacy"],Da=["capabilities"],Na=["inputKeys","dataInputs","confirmation","resultProjection","content","env"];});var to,io,oo,ro,so=k(()=>{g();to="text/html;profile=mcp-app",io=["crewx_app_terminal_connect","crewx_app_html_viewer_open"],oo=["crewx_listWorkspaces","crewx_queryAgent","crewx_executeAgent","crewx_getTaskResult","crewx_listTasks","crewx_listAgents","callBrowser","openTab","listTabs","closeTab"],ro="text/html";});function un(e){return typeof e=="string"&&La.includes(e)}function xn(e,n){return e==="card"&&n?.type==="core"&&un(n.handler)}var La,jn=k(()=>{g();La=Object.freeze(["card.secret-env"]);});function ao(e,n=[],t){if(e.content!==void 0||e.confirmation!=="none")return "denied";let i=Oa();return i&&Object.hasOwn(i,e.actionId)?i[e.actionId]:e.backend?.type==="core"&&e.backend.handler.startsWith("host.")?"denied":e.backend?.type==="core"&&e.backend.handler==="state.set"?"allowed":e.backend?.type==="core"&&un(e.backend.handler)||e.backend?.type==="skill"?"approval_required":e.backend===void 0&&n.includes(e.actionId)?"allowed":"denied"}function Oa(e){return;}var co=k(()=>{g();Ue();wn();jn();});function Va(e){return An.has(e)&&(e.initialState===void 0||An.has(e.initialState))}function yo(e,n,t,i){let r=i===void 0?void 0:Object.freeze({hash:i.hash,bytes:Object.freeze(i.bytes)}),o=Object.freeze({mimeType:ro,entryHash:e,html:n,bytes:Object.freeze(t),...r===void 0?{}:{initialState:r}});return r!==void 0&&An.add(r),An.add(o),o}function Fa(e){let n=[];return e?.terminal===true&&n.push({name:"crewx_app_terminal_connect",description:"Open a local-only terminal session for this App.",inputSchema:{type:"object",properties:{workspace:{type:"string"},threadId:{type:"string"},instanceId:{type:"string"}},required:["threadId","instanceId"],additionalProperties:false},textFallback:"A local terminal connection is ready for this App.",visibility:Object.freeze(["app"]),kind:"host",resourceBinding:Le}),e?.htmlDocuments===true&&n.push({name:"crewx_app_html_viewer_open",description:"List workspace HTML documents or open one through a short-lived Host capability.",inputSchema:{type:"object",properties:{workspace:{type:"string"},threadId:{type:"string"},instanceId:{type:"string"},operation:{type:"string",enum:["list","open"]},documentId:{type:"string"}},required:["threadId","instanceId","operation"],additionalProperties:false},textFallback:"Workspace HTML documents are available through this App.",visibility:Object.freeze(["app"]),kind:"host",resourceBinding:Le}),n}function Oe(e,n,t){return (typeof e!="string"||!uo.test(e))&&E(n,`${t} must be a safe identifier`),e}function fn(e,n,t){let i=e??t;return (typeof i!="string"||i.trim().length===0||i.length>Ca)&&E("TOOL_INVALID",`${n} must be a meaningful description`),i}function Bt(e){return (typeof e!="string"||e.length===0||e.length>Ke||!/<html(?:\s|>)/i.test(e)||!/<\/html\s*>/i.test(e))&&E("HTML_INVALID","MCP App HTML must be a non-empty HTML document"),e}function yn(e,n=0){try{let t=ce(e,n);return t.type!==void 0&&t.type!=="object"&&E("TOOL_INVALID","MCP App inputSchema must describe an object"),t}catch(t){if(t instanceof _e)throw t;E("TOOL_INVALID","MCP App inputSchema must be projection-safe JSON");}}function Ba(e){return (typeof e!="string"||e.trim().length===0||e.length>ka)&&E("TOOL_INVALID","MCP App tools require a meaningful text fallback"),e}function Ha(e){e===void 0&&E("TOOL_INVALID","MCP App tool visibility is required");let n=[...e];return (n.length===0||n.some(t=>t!=="model"&&t!=="app")||new Set(n).size!==n.length)&&E("TOOL_INVALID","MCP App tool visibility must contain model and/or app once"),n}function Io(e){return (typeof e!="string"||!fo.test(e))&&E("RESOURCE_URI_INVALID","MCP App resource URI is not a registered ui:// URI"),e}function go(e){let n=Oe(e.appId,"APP_ID_INVALID","Local App id"),t=fn(e.name,"Local App name",n),i=fn(e.description,"Local App description",`${t} interactive view`),r=Bn(e.definition),o=Bt(e.html),a=vn(e.entryHash,"Local App entry hash"),s=e.entryBytes===void 0?Array.from(new TextEncoder().encode(o)):Fn(e.entryBytes,"Local App entry bytes");(Vn(s)!==a||_o(s)!==o)&&E("HTML_INVALID","Local App entry bytes do not match the HTML hash");let c=za(e),d=[];Array.isArray(e.actions)||E("TOOL_INVALID","Local App actions must be an array");for(let P of e.actions){let O=Oe(P.actionId,"TOOL_ID_INVALID","Local App action id");(d.includes(O)||!Object.prototype.hasOwnProperty.call(r.actions,O))&&E("TOOL_INVALID",`Local App action is not declared by the UI definition: ${O}`),d.push(O);}let p=Oe(e.readToolName,"TOOL_ID_INVALID","Local App read tool name"),l=e.actionToolName===void 0?void 0:Oe(e.actionToolName,"TOOL_ID_INVALID","Local App action tool name");d.length===0&&l!==void 0&&E("TOOL_INVALID","A static local App cannot register an action tool"),d.length>0&&l===void 0&&E("TOOL_INVALID","A stateful local App requires an action tool name"),l!==void 0&&l===p&&E("TOOL_ID_CONFLICT",`Local App read and action tools share a name: ${p}`);let u=Fa(e.runtime);u.some(P=>P.name===p||P.name===l)&&E("TOOL_ID_CONFLICT","Local App read or action tool conflicts with a requested Host capability");let A={name:p,description:`${t} current state`,inputSchema:va,textFallback:`${t} current state is available through its open instance.`,visibility:Object.freeze(["model","app"]),kind:"read",resourceBinding:Le},I=[Object.freeze(A)];if(I.push(...u.map(P=>Object.freeze(P))),l!==void 0){let P={name:l,description:`${t} actions`,inputSchema:Ht(e.actions),textFallback:`${t} action requests are handled by the open App instance.`,visibility:Object.freeze(["app"]),kind:"action",resourceBinding:Le,actionIds:Object.freeze([...d])};I.push(Object.freeze(P));}let h=[],b=new Set(I.map(P=>P.name));if(l!==void 0)for(let P of e.actions){let O=`${l}__${P.actionId}`;if(O.length>128||!uo.test(O)){h.push(Object.freeze({toolName:O,actionId:P.actionId,reason:"name_too_long"}));continue}if(b.has(O)){h.push(Object.freeze({toolName:O,actionId:P.actionId,reason:"name_collision"}));continue}let H=ao({actionId:P.actionId,confirmation:r.actions[P.actionId]?.confirmation,content:r.actions[P.actionId]?.content,backend:P.backend},e.modelActions),N=Object.freeze([...Xa(H,r.usage,P.backend)]),L={name:O,description:`${O} action`,inputSchema:yn(P.inputSchema),textFallback:`${O} action requests are handled by the open App instance.`,visibility:N,kind:"action",resourceBinding:Le,actionId:P.actionId,actionIds:Object.freeze([P.actionId]),_meta:Object.freeze({ui:Object.freeze({visibility:N})})};I.push(Object.freeze(L)),b.add(O);}let V=yo(a,o,s,c===void 0?void 0:{hash:c.hash,bytes:[...c.bytes]}),j={appId:n,name:t,description:i,...e.icon===void 0?{}:{icon:To(e.icon)},...e.tone===void 0?{}:{tone:Eo(e.tone)},builtinOnly:false,definition:r,...e.runtime===void 0?{}:{runtime:Object.freeze({...e.runtime})},resourceBinding:Le,resource:V,tools:Object.freeze(I),toolDiagnostics:Object.freeze(h)};return Y(j)}function mo(e={}){return new Ft(e)}function Ht(e){if(e.length===0)return yn({type:"object",properties:{},additionalProperties:false});let n=e.map(i=>i.actionId),t=new Map;for(let i of e)t.set(i.actionId,yn(i.inputSchema));return yn(Ga(n,t),Ao)}function za(e){let n=e.definition.dataPaths??[];if(e.initialStateBytes===void 0){e.initialStateHash!==void 0&&E("STATE_INVALID","Initial state hash has no bytes"),e.initialState!==void 0&&ce(e.initialState,0,n);return}e.initialStateHash===void 0&&E("STATE_INVALID","Initial state bytes require a hash");let t=vn(e.initialStateHash,"Initial state hash"),i=Fn(e.initialStateBytes,"Initial state bytes");Vn(i)!==t&&E("STATE_INVALID","Initial state bytes do not match the hash");let r;try{let o=new TextDecoder("utf-8",{fatal:!0}).decode(Uint8Array.from(i));r=ce(JSON.parse(o),0,n);}catch{E("STATE_INVALID","Initial state bytes are not projection-safe JSON");}return e.initialState!==void 0&&q(r)!==q(ce(e.initialState,0,n))&&E("STATE_INVALID","Initial state bytes do not match the state value"),{hash:t,bytes:Object.freeze([...i])}}function Ga(e,n){let t=e.map(i=>({type:"object",properties:{actionId:{type:"string",const:i},input:n.get(i)??{type:"object"}},required:["actionId","input"],additionalProperties:false}));return Object.freeze({type:"object",oneOf:Object.freeze(t),properties:Object.freeze({actionId:Object.freeze({type:"string",enum:Object.freeze([...e])}),input:Object.freeze({type:"object"})}),required:Object.freeze(["actionId","input"]),additionalProperties:false})}function $a(e){let n=In(e),t=Oe(n.appId,"APP_ID_INVALID","MCP App id"),i=Bt(n.html);Io(n.uiUri);let r=n.definition===void 0?void 0:Bn(n.definition),o=e.provenance;o!==void 0&&(!Xe(o)||o.appId!==t||o.definitionId!==r?.id||o.version!==r?.version||o.definitionHash!==r?.hash)&&E("TOOL_INVALID","Product App built-in registration provenance is not verified");let a=Object.freeze(n.tools.map(d=>Y(In(d)))),s=Y({...n,appId:t,html:i,...r===void 0?{}:{definition:r},...o===void 0?{}:{provenance:o},tools:a}),c=Y({uri:s.uiUri,mimeType:to,text:i,...s.csp===void 0?{}:{_meta:{ui:{csp:s.csp}}}});return Y({appId:t,name:s.name,description:s.description,...s.icon===void 0?{}:{icon:s.icon},...s.tone===void 0?{}:{tone:s.tone},builtinOnly:s.builtinOnly,uiUri:s.uiUri,...r===void 0?{}:{definition:r},resourceBinding:Object.freeze({kind:"mcp",uri:s.uiUri}),resource:c,tools:a,descriptor:s})}function Ja(e){(e.resourceBinding.kind!=="instance"||e.builtinOnly!==false)&&E("STATE_INVALID","Local App registration binding is invalid"),Object.prototype.hasOwnProperty.call(e,"uiUri")&&E("STATE_INVALID","Local App registration cannot contain uiUri");let n=Oe(e.appId,"APP_ID_INVALID","Local App id"),t=Bn(e.definition),i=e.provenance;i!==void 0&&(!Xe(i)||i.appId!==n||i.definitionId!==t.id||i.version!==t.version||i.definitionHash!==t.hash)&&E("TOOL_INVALID","Product App local registration provenance is not verified");let r=Wa(e.resource),o=e.tools.map(s=>{Oe(s.name,"TOOL_ID_INVALID","Local App tool name"),fn(s.description,"Local App tool description","Local App tool"),Ba(s.textFallback);let c=yn(s.inputSchema,s.kind==="action"&&!("actionId"in s)?Ao:0);if((s.resourceBinding.kind!=="instance"||Object.prototype.hasOwnProperty.call(s,"resourceUri"))&&E("TOOL_INVALID","Local App tools cannot carry an MCP resource URI"),s.kind==="host")return (!ja.has(s.name)||s.visibility.length!==1||s.visibility[0]!=="app"||Object.prototype.hasOwnProperty.call(s,"actionId"))&&E("TOOL_INVALID","Local App Host tools must use an allow-listed name and app-only visibility"),Y({...s,inputSchema:c,visibility:Object.freeze(["app"])});if(s.kind==="action"){if("actionId"in s){let p=Oe(s.actionId,"TOOL_ID_INVALID","Local App action id");Object.prototype.hasOwnProperty.call(t.actions,p)||E("TOOL_INVALID","Local App action tool references an undeclared action");let l=Ha(s._meta.ui.visibility);return JSON.stringify(l)!==JSON.stringify(s.visibility)&&E("TOOL_INVALID","Local App action metadata visibility must match the tool visibility"),Y({...s,actionId:p,actionIds:Object.freeze([p]),inputSchema:c,visibility:l,_meta:{ui:{visibility:l}}})}let d=[...s.actionIds];return (d.length===0||d.some(p=>!Object.prototype.hasOwnProperty.call(t.actions,p)))&&E("TOOL_INVALID","Local App action tool references an undeclared action"),Y({...s,inputSchema:c,actionIds:Object.freeze(d)})}return Y({...s,inputSchema:c})}),a=Y({appId:n,name:fn(e.name,"Local App name",e.appId),description:fn(e.description,"Local App description",e.name),...e.icon===void 0?{}:{icon:To(e.icon)},...e.tone===void 0?{}:{tone:Eo(e.tone)},builtinOnly:false,definition:t,...e.runtime===void 0?{}:{runtime:Object.freeze({...e.runtime})},...i===void 0?{}:{provenance:i},resourceBinding:Le,resource:r,tools:Object.freeze(o),toolDiagnostics:Object.freeze([...e.toolDiagnostics??[]])});return po.has(e)?e:(po.add(a),a)}function Wa(e){let n=Bt(e.html),t=vn(e.entryHash,"Local App entry hash");if(Va(e))return e;let i=Fn(e.bytes,"Local App entry bytes");(Vn(i)!==t||_o(i)!==n)&&E("HTML_INVALID","Local App entry bytes do not match the HTML hash");let r=e.initialState===void 0?void 0:{hash:vn(e.initialState.hash,"Initial state hash"),bytes:Fn(e.initialState.bytes,"Initial state bytes")};return r&&Vn(r.bytes)!==r.hash&&E("STATE_INVALID","Initial state bytes do not match the hash"),yo(t,n,i,r)}function Xa(e,n,t){if(xn(n,t))return ["model"];let i=t?.type==="core"&&un(t.handler);return e==="denied"||i?["app"]:["model","app"]}function Ka(e){return Y({appId:e.appId,name:e.name,description:e.description,...e.icon===void 0?{}:{icon:e.icon},...e.tone===void 0?{}:{tone:e.tone},builtinOnly:false,definition:ho(e.definition),...e.provenance===void 0?{}:{provenance:e.provenance},entryHash:e.resource.entryHash,resourceBinding:Le,tools:e.tools})}function Ya(e){return Y({appId:e.appId,name:e.name,description:e.description,...e.icon===void 0?{}:{icon:e.icon},...e.tone===void 0?{}:{tone:e.tone},builtinOnly:e.builtinOnly,uiUri:e.uiUri,...e.definition===void 0?{}:{definition:ho(e.definition)},resourceBinding:Object.freeze({kind:"mcp",uri:e.uiUri}),tools:e.tools})}function Bn(e){try{if(Object.isFrozen(e))return de(e),Y(e);let n=In(e);return de(n),Y(n)}catch(n){if(n instanceof _e)throw n;E("STATE_INVALID","UI definition is not a valid immutable definition");}}function ho(e){return Y({id:e.id,version:e.version,hash:e.hash})}function qa(e){return e!==null&&typeof e=="object"&&typeof e.id=="string"&&Number.isSafeInteger(e.version)&&typeof e.hash=="string"}function lo(e,n,t){return `${e}\0${n}\0${t}`}function vn(e,n){return (typeof e!="string"||!Ua.test(e))&&E("SERIALIZATION_INVALID",`${n} is invalid`),e}function Vn(e){return crypto.createHash("sha256").update(Uint8Array.from(e)).digest("hex")}function Fn(e,n){return (!Array.isArray(e)||e.some(t=>!Number.isInteger(t)||t<0||t>255))&&E("SERIALIZATION_INVALID",`${n} is invalid`),[...e]}function _o(e){try{return new TextDecoder("utf-8",{fatal:!0}).decode(Uint8Array.from(e))}catch{E("SERIALIZATION_INVALID","UTF-8 bytes are invalid");}}function To(e){return (typeof e!="string"||!wa.test(e))&&E("TOOL_INVALID","MCP App icon is invalid"),e}function Eo(e){return (typeof e!="string"||!xa.has(e))&&E("TOOL_INVALID","MCP App tone is invalid"),e}function In(e,n=new Map){if(e===null||typeof e!="object")return e;let t=e;if(n.has(t)&&E("SERIALIZATION_INVALID","MCP App value contains a cycle"),Array.isArray(e)){let o=[];n.set(t,o);for(let a of e)o.push(In(a,n));return n.delete(t),o}let i;try{i=Object.getPrototypeOf(e);}catch{E("SERIALIZATION_INVALID","MCP App value cannot be cloned");}i!==Object.prototype&&i!==null&&E("SERIALIZATION_INVALID","MCP App value must be plain JSON");let r={};n.set(t,r);for(let[o,a]of Object.entries(e))Object.defineProperty(r,o,{configurable:true,enumerable:true,value:In(a,n),writable:true});return n.delete(t),r}function Y(e,n=new Set){if(e===null||typeof e!="object"||n.has(e)||An.has(e))return e;n.add(e);for(let t of Object.values(e))Y(t,n);return Object.freeze(e),e}var uo,fo,Ua,Ke,Ca,ka,wa,xa,ja,Le,va,An,po,Ao,Ft,Hn=k(()=>{g();Ki();Ue();De();wn();kn();Vt();so();co();jn();uo=/^[A-Za-z][A-Za-z0-9._-]{0,127}$/,fo=/^ui:\/\/crewx\/([A-Za-z][A-Za-z0-9._-]{0,127})\/([0-9a-f]{12})$/,Ua=/^[0-9a-f]{64}$/,Ke=8*1024*1024,Ca=8*1024,ka=16*1024,wa=/^[a-z][a-z0-9-]{0,63}$/,xa=new Set(["blue","violet","emerald","amber","rose","sky","slate","indigo"]),ja=new Set(io),new Set(oo),Le=Object.freeze({kind:"instance"}),va=Object.freeze({type:"object",properties:Object.freeze({}),additionalProperties:false}),An=new WeakSet,po=new WeakSet;Ao=4;Ft=class{builtinApps;localApps;builtinDescriptors;builtinTools;mcpResources=new Map;localById=new Map;registrationById=new Map;launcherById=new Map;definitionByKey=new Map;handlerByKey=new Map;mcpToolByName=new Map;localToolByName=new Map;constructor(n){let t=n.builtins??n.builtin,i=[],r=[],o=[],a=new Set,s=new Set;for(let l of t?.listMcpApps()??[]){let u=$a(l);a.has(u.appId)&&E("APP_ID_CONFLICT",`MCP App id is already registered: ${u.appId}`),a.add(u.appId);let A=u.tools;for(let I of A)s.has(I.name)&&E("TOOL_ID_CONFLICT",`MCP App tool name is already registered: ${I.name}`),s.add(I.name),this.mcpToolByName.set(I.name,I),o.push(I);this.mcpResources.set(u.resource.uri,u.resource),i.push(u),r.push(u.descriptor);}let c=(n.localApps??n.locals??[]).map(Ja),d=new Set(c.flatMap(l=>l.tools.filter(u=>!(u.kind==="action"&&"actionId"in u)).map(u=>u.name))),p=[];for(let l of c){let u=l;a.has(u.appId)&&E("APP_ID_CONFLICT",`MCP App id is already registered: ${u.appId}`),a.add(u.appId);let A=[],I=[...u.toolDiagnostics??[]];for(let h of u.tools){if(s.has(h.name)){if(h.kind==="host"&&this.localToolByName.get(h.name)?.kind==="host"){A.push(h);continue}if(h.kind==="action"&&"actionId"in h){I.push(Object.freeze({toolName:h.name,actionId:h.actionId,reason:"name_collision"}));continue}E("TOOL_ID_CONFLICT",`MCP App tool name is already registered: ${h.name}`);}if(h.kind==="action"&&"actionId"in h&&d.has(h.name)){I.push(Object.freeze({toolName:h.name,actionId:h.actionId,reason:"name_collision"}));continue}s.add(h.name),this.localToolByName.set(h.name,h),A.push(h);}(A.length!==u.tools.length||I.length!==(u.toolDiagnostics?.length??0))&&(u=Y({...u,tools:Object.freeze(A),toolDiagnostics:Object.freeze(I)})),p.push(u),this.localById.set(u.appId,u);}for(let l of i)this.registrationById.set(l.appId,l),this.launcherById.set(l.appId,Ya(l)),l.definition&&this.addDefinition(l.definition);for(let l of p)this.registrationById.set(l.appId,l),this.launcherById.set(l.appId,Ka(l)),this.addDefinition(l.definition);for(let l of n.definitions??[])this.addDefinition(l);for(let l of n.handlers??[])this.addHandler(l);this.builtinApps=Object.freeze(i),this.localApps=Object.freeze(p),this.builtinDescriptors=Object.freeze(r),this.builtinTools=Object.freeze(o);}getMcpApp(n){return this.builtinApps.find(t=>t.appId===n)?.descriptor??null}listMcpApps(){return this.builtinDescriptors}listMcpAppTools(){return this.builtinTools}resolveMcpAppTool(n){return this.mcpToolByName.get(n)??null}resolveMcpAppResource(n){return typeof n!="string"||!fo.test(n)?null:this.mcpResources.get(n)??null}requireMcpAppResource(n){Io(n);let t=this.mcpResources.get(n);return t||E("RESOURCE_NOT_FOUND",`MCP App resource is not registered: ${n}`),t}listLocalMcpApps(){return this.localApps}getLocalMcpApp(n){return this.localById.get(n)??null}listLocalMcpAppTools(){return Object.freeze([...this.localToolByName.values()])}resolveLocalMcpAppTool(n){return this.localToolByName.get(n)??null}resolveLocalMcpAppResource(n,t){let i=this.localById.get(n);return !i||t!==void 0&&i.definition.hash!==t?null:i.resource}listRegistrations(){return Object.freeze([...this.builtinApps,...this.localApps])}getRegistration(n){return this.registrationById.get(n)??null}listLaunchers(){return Object.freeze([...this.launcherById.values()].filter(n=>{let t=this.registrationById.get(n.appId),i=t?"descriptor"in t?t.descriptor.provenance:t.provenance:void 0,r=Xe(i)&&i.launcher===false;return t?.definition?.usage!=="card"&&!r}))}listCardApps(){return Object.freeze([...this.launcherById.values()].filter(n=>this.registrationById.get(n.appId)?.definition?.usage==="card"))}getLauncher(n){return this.launcherById.get(n)??null}resolveDefinition(n){if(!qa(n))return null;let t=this.definitionByKey.get(At(n));if(!t||t.hash!==n.hash)return null;try{return ie(t)===t.hash?t:null}catch{return null}}resolveActionHandler(n,t,i){return typeof n!="string"||typeof i!="string"||!Number.isSafeInteger(t)?null:this.handlerByKey.get(lo(n,t,i))??null}addDefinition(n){let t=Bn(n),i=At(t),r=this.definitionByKey.get(i);r&&r.hash!==t.hash&&E("STATE_INVALID",`UI definition generation conflicts: ${i}`),r||this.definitionByKey.set(i,t);}addHandler(n){(!n||typeof n.definitionId!="string"||typeof n.actionId!="string"||!Number.isSafeInteger(n.version)||n.version<1||typeof n.handle!="function")&&E("STATE_INVALID","UI action handler registration is invalid");let t=lo(n.definitionId,n.version,n.actionId);this.handlerByKey.has(t)&&E("TOOL_INVALID",`Duplicate UI action handler registration: ${t}`),this.handlerByKey.set(t,Object.freeze({...n}));}};});function Za(e){let n=go({appId:e.appId,name:e.name,description:e.description,...e.icon===void 0?{}:{icon:e.icon},...e.tone===void 0?{}:{tone:e.tone},...e.normalized.manifest.runtime===void 0?{}:{runtime:e.normalized.manifest.runtime},definition:e.definition,html:e.html,entryHash:e.entryHash,entryBytes:e.entryBytes,initialState:e.initialState,...e.initialStateHash===void 0?{}:{initialStateHash:e.initialStateHash},...e.initialStateBytes===void 0?{}:{initialStateBytes:e.initialStateBytes},readToolName:e.toolNames.read,...e.toolNames.action===void 0?{}:{actionToolName:e.toolNames.action},actions:e.normalized.manifest.actions.map(i=>({actionId:i.actionId,inputSchema:i.inputSchema,backend:i.backend}))});return e.provenance===void 0?n:Object.freeze({...n,provenance:e.provenance})}function Do(e){let n=e.normalized.manifest.actions;if(n.some(i=>i.backend.type==="skill")&&n.some(i=>i.backend.type==="core"))throw new Error("Mixed workspace App execution models");let t=Za(e);mo({localApps:[t],definitions:[e.definition]});}var No=k(()=>{g();Hn();});function bo(){return Object.freeze({[zt]:{candidates:new Map,assetCatalogs:new Map,preparedCandidates:new Map}})}function Qa(e){if(e===null||typeof e!="object"||!(zt in e))throw new TypeError("scanCache must be created by createWorkspaceAppScanCache");return e[zt]}function Po(e,n){let t=Qa(e),i=t.rootIdentity;return i!==void 0&&(i.dev!==n.dev||i.ino!==n.ino||i.realPath!==n.realPath)&&(t.candidates.clear(),t.assetCatalogs.clear(),t.preparedCandidates.clear(),t.lastCandidateScanUnchanged=void 0,t.lastCandidateKeys=void 0,t.scanStartedAtNs=void 0,t.lastAssetCatalogsUnchanged=void 0,t.lastSnapshot=void 0,t.lastSnapshotBuildInputs=void 0,t.lastSnapshotCandidates=void 0,t.lastSnapshotCatalogFingerprint=void 0),t.rootIdentity=n,t}var zt,Mo=k(()=>{g();zt=Symbol("crewx.workspace-app-scan-cache.state");});function se(e){let n=typeof e=="object"&&e!==null&&"code"in e?String(e.code):"";return n==="ENOENT"?new _("NOT_FOUND"):n==="ELOOP"?new _("PATH_ESCAPED"):n==="EFBIG"||n==="EOVERFLOW"?new _("LIMIT_EXCEEDED"):n==="EACCES"||n==="EPERM"||n==="ENOTDIR"?new _("READ_DENIED"):new _("READ_DENIED")}function ic(e){if(typeof e!="string"||e.length===0||!path.isAbsolute(e))throw new _("READ_DENIED")}function Gt(e){if(typeof e!="string"||path.isAbsolute(e)||/[\\\u0000]/.test(e))throw new _("PATH_ESCAPED");if(e==="")return [];let n=e.split("/");if(n.some(t=>t.length===0||t==="."||t===".."))throw new _("PATH_ESCAPED");return n}function Jn(e,n){let t=path.relative(e,n);return t===""||t!==".."&&!t.startsWith(`..${path.sep}`)&&!path.isAbsolute(t)}function qe(e){return {dev:e.dev,ino:e.ino,size:e.size,mtimeNs:e.mtimeNs,ctimeNs:e.ctimeNs}}function Xt(e,n){return e.dev===n.dev&&e.ino===n.ino}function Kt(e,n){return Xt(e,n)&&e.size===n.size&&e.mtimeNs===n.mtimeNs&&e.ctimeNs===n.ctimeNs}async function zn(e){ic(e);let n,t;try{n=await promises.realpath(e),t=await promises.stat(n,{bigint:!0});}catch(i){throw se(i)}if(!t.isDirectory())throw new _("READ_DENIED");return {realRoot:n,identity:qe(t)}}async function Oo(e,n,t){if(t.length<2||t[0]!=="apps"&&t[0]!=="skills")return;let i,r;try{if(i=path.resolve(e,t[0],t[1]),r=await promises.realpath(i),!(await promises.stat(r,{bigint:!0})).isDirectory())throw new _("READ_DENIED")}catch(o){throw o instanceof _?o:se(o)}if(!Jn(n,r))throw new _("PATH_ESCAPED");return r}async function Gn(e,n,t,i){let r,o,a;try{r=await promises.lstat(e,{bigint:!0}),o=await promises.realpath(e),a=await promises.stat(o,{bigint:!0});}catch(s){throw se(s)}if(!Jn(n,o)||t!==void 0&&!Jn(t,o))throw new _("PATH_ESCAPED");if(!r.isFile()||!a.isFile())throw new _("READ_DENIED");if(!Xt(i,r)||!Xt(i,a)||i.dev!==a.dev)throw new _("PATH_ESCAPED")}async function Ye(e,n){let t,i;try{t=await promises.realpath(e),i=await promises.stat(t,{bigint:!0});}catch{throw new _("PATH_ESCAPED")}if(t!==n.realRoot||!Kt(n.identity,qe(i)))throw new _("PATH_ESCAPED")}function oc(e){return e.isSymbolicLink()?{name:e.name,kind:"symlink"}:e.isDirectory()?{name:e.name,kind:"directory"}:e.isFile()?{name:e.name,kind:"file"}:{name:e.name,kind:"other"}}var _,Wt,tc,Lo,Ze,Wn,Ro,Uo,qt=k(()=>{g();_=class extends Error{constructor(t){super(t);this.code=t;}code;name="AppDiscoveryFsError"},Wt=fs$1.constants.O_NOFOLLOW,tc=fs$1.constants.O_NONBLOCK,Lo=fs$1.constants.O_RDONLY|(Wt??0)|(tc??0);Ze=class{async getRootIdentity(n){let t=await zn(n);return await Ye(n,t),{dev:t.identity.dev,ino:t.identity.ino,realPath:t.realRoot}}async listDirectory(n,t){let i=Gt(t),r=await zn(n),o=path.resolve(n,...i),a,s;try{a=await promises.realpath(o),s=await promises.stat(a,{bigint:!0});}catch(c){let d=se(c);if(d.code==="NOT_FOUND")return [];throw d}if(!Jn(r.realRoot,a)||!s.isDirectory())throw new _("PATH_ESCAPED");try{let c=await promises.readdir(a,{withFileTypes:!0,encoding:"utf8"});return await Ye(n,r),c.map(oc)}catch(c){let d=se(c);if(d.code==="NOT_FOUND")return [];throw d}}async readdir(n,t){return this.listDirectory(n,t)}async readDirectory(n,t){return this.listDirectory(n,t)}async readVerifiedFile(n,t,i){if(!Number.isSafeInteger(i)||i<0)throw new _("READ_DENIED");if(Wt===void 0)throw new _("UNSUPPORTED");let r=Gt(t),o=await zn(n),a=path.resolve(n,...r),s=path.relative(n,a);if(s===".."||s.startsWith(`..${path.sep}`)||path.isAbsolute(s))throw new _("PATH_ESCAPED");let c;try{c=await promises.open(a,Lo);}catch(d){throw se(d)}try{let d;try{let I=await c.stat({bigint:!0});d=qe(I);}catch(I){throw se(I)}if(d.size>BigInt(i))throw new _("LIMIT_EXCEEDED");if(d.size>BigInt(Number.MAX_SAFE_INTEGER))throw new _("LIMIT_EXCEEDED");await Ye(n,o);let p=await Oo(n,o.realRoot,r);await Gn(a,o.realRoot,p,d);let l=new Uint8Array(new ArrayBuffer(Number(d.size))),u=0;for(;u<l.byteLength;){let I;try{I=(await c.read(l,u,l.byteLength-u,u)).bytesRead;}catch(h){throw se(h)}if(I<=0)throw new _("IDENTITY_CHANGED");u+=I;}let A;try{let I=await c.stat({bigint:!0});A=qe(I);}catch(I){throw se(I)}if(!Kt(d,A))throw new _("IDENTITY_CHANGED");return await Gn(a,o.realRoot,p,A),await Ye(n,o),new Uint8Array(l)}finally{await c.close().catch(()=>{});}}async fingerprintVerifiedFile(n,t,i){if(!Number.isSafeInteger(i)||i<0)throw new _("READ_DENIED");if(Wt===void 0)throw new _("UNSUPPORTED");let r=Gt(t),o=await zn(n),a=path.resolve(n,...r),s=path.relative(n,a);if(s===".."||s.startsWith(`..${path.sep}`)||path.isAbsolute(s))throw new _("PATH_ESCAPED");let c;try{c=await promises.open(a,Lo);}catch(d){throw se(d)}try{let d;try{let u=await c.stat({bigint:!0});d=qe(u);}catch(u){throw se(u)}if(d.size>BigInt(i)||d.size>BigInt(Number.MAX_SAFE_INTEGER))throw new _("LIMIT_EXCEEDED");await Ye(n,o);let p=await Oo(n,o.realRoot,r);await Gn(a,o.realRoot,p,d);let l;try{let u=await c.stat({bigint:!0});l=qe(u);}catch(u){throw se(u)}if(!Kt(d,l))throw new _("IDENTITY_CHANGED");return await Gn(a,o.realRoot,p,l),await Ye(n,o),{...l,candidateRealPath:p??o.realRoot}}catch(d){throw d instanceof _?d:se(d)}finally{await c.close().catch(()=>{});}}async readFileVerified(n,t,i){return this.readVerifiedFile(n,t,i)}},Wn=new Ze,Ro=Wn,Uo=Ze;});function _n(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;try{let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}catch{return false}}function ko(e){return typeof e=="string"&&Ie.test(e)?e:void 0}function lc(e){return e.length>0&&e!=="."&&e!==".."&&!/[\\/\u0000]/.test(e)}function xe(e,n){let t=new TextEncoder().encode(e),i=new TextEncoder().encode(n),r=Math.min(t.byteLength,i.byteLength);for(let o=0;o<r;o+=1){let a=t[o]-i[o];if(a!==0)return a}return t.byteLength-i.byteLength}function uc(e){if(typeof e=="string")return {name:e,kind:"directory"};if(e===null||typeof e!="object")return null;let n=e;if(typeof n.name!="string")return null;if(n.kind==="file"||n.kind==="directory"||n.kind==="symlink"||n.kind==="other")return {name:n.name,kind:n.kind};if(n.type==="file"||n.type==="directory"||n.type==="symlink"||n.type==="other")return {name:n.name,kind:n.type};let t=n.isDirectory;if(typeof t=="function"&&t.call(e))return {name:n.name,kind:"directory"};let i=n.isSymbolicLink;if(typeof i=="function"&&i.call(e))return {name:n.name,kind:"symlink"};let r=n.isFile;return typeof r=="function"&&r.call(e)?{name:n.name,kind:"file"}:{name:n.name,kind:"other"}}function fc(e){if(e instanceof Uint8Array)return new Uint8Array(e);if(e instanceof ArrayBuffer)return new Uint8Array(e.slice(0));if(Array.isArray(e)&&e.every(n=>Number.isInteger(n)&&n>=0&&n<=255))return Uint8Array.from(e);throw new TypeError("filesystem port returned an invalid byte array")}function yc(e){return dc.decode(e)}function Ac(e){return JSON.parse(yc(e))}function wo(e){switch(e){case "ENOENT":return "NOT_FOUND";case "ELOOP":case "EXDEV":return "PATH_ESCAPED";case "EFBIG":case "EOVERFLOW":return "LIMIT_EXCEEDED";case "EACCES":case "EPERM":case "ENOTDIR":return "READ_DENIED";default:return e}}function Ic(e){if(e instanceof _)return wo(e.code);if(e!==null&&typeof e=="object"&&"code"in e){let n=e.code;if(typeof n=="string")return wo(n)}}function be(e,n){let t=n();return Number.isFinite(t)&&Number.isFinite(e)&&t-e<=5e3}function gc(e){if(typeof e.readVerifiedFile=="function")return e.readVerifiedFile;if(typeof e.readFileVerified=="function")return e.readFileVerified}function mc(e){if(typeof e.listDirectory=="function")return e.listDirectory;if(typeof e.readDirectory=="function")return e.readDirectory;if(typeof e.readdir=="function")return e.readdir}async function xo(e,n,t,i){let r=gc(e);if(!r)throw new _("READ_DENIED");return fc(await r.call(e,n,t,i))}async function ei(e,n,t){let i=mc(e);if(!i)throw new _("READ_DENIED");let r=await i.call(e,n,t);if(!Array.isArray(r))throw new _("READ_DENIED");return r.map(uc).filter(o=>o!==null)}function hc(e,n,t,i){return Object.freeze({code:e,...{},source:n,relativePath:t})}function _c(e){if(!_n(e))throw new TypeError("productBundle.reservedIds must be an object with appIds and definitionIds arrays");try{let n=Reflect.ownKeys(e);if(n.length!==2||!n.includes("appIds")||!n.includes("definitionIds"))throw new TypeError("productBundle.reservedIds must contain exactly appIds and definitionIds");let t=(i,r)=>{if(!Array.isArray(i))throw new TypeError("productBundle.reservedIds."+r+" must be an array");let o=[];for(let a=0;a<i.length;a+=1){let s=i[a];if(typeof s!="string"||s.length===0)throw new TypeError("productBundle.reservedIds."+r+" must contain non-empty strings");o.push(s);}return Object.freeze([...new Set(o)].sort(xe))};return Object.freeze({appIds:t(e.appIds,"appIds"),definitionIds:t(e.definitionIds,"definitionIds")})}catch(n){throw n instanceof TypeError?n:new TypeError("productBundle.reservedIds must be a valid reservation object")}}function Tc(e,n){return e.appIds.length===n.appIds.length&&e.appIds.every((t,i)=>t===n.appIds[i])&&e.definitionIds.length===n.definitionIds.length&&e.definitionIds.every((t,i)=>t===n.definitionIds[i])}function Tn(e){return Object.freeze({appIds:Object.freeze([...new Set(e.map(n=>n.appId))].sort(xe)),definitionIds:Object.freeze([...new Set(e.map(n=>n.definition.id))].sort(xe))})}function Xn(e,n){let t=Object.keys(e).sort(xe),i=[...n].sort(xe);return t.length===i.length&&t.every((r,o)=>r===i[o])}function jo(e){if(typeof e!="string"||e.length===0||e.startsWith("/")||/[\\\u0000]/.test(e))return;let n=e.split("/");if(!n.some(t=>t.length===0||t==="."||t===".."))return n}function Ec(e){let n;try{n=Ac(e);}catch{return}if(!_n(n)||!Xn(n,["version","packages"])||n.version!==1||!Array.isArray(n.packages)||n.packages.length>ni)return;let t=new Set,i=new Set,r=0,o=[];for(let a of n.packages){if(!_n(a))return;let s=["packageDir","appId","definition","files"],c=Object.hasOwn(a,"lineage"),d=Object.hasOwn(a,"launcher"),p=[...c?["lineage"]:[],...d?["launcher"]:[]];if(!Xn(a,[...s,...p])||d&&a.launcher!==false)return;let l=jo(a.packageDir),u=ko(a.appId);if(!l||l.length!==2||l[0]!=="apps"||!lc(l[1])||!u||t.has(a.packageDir)||!_n(a.definition)||!Xn(a.definition,["id","version","hash"]))return;let A=ko(a.definition.id),I=a.definition.version,h=a.definition.hash;if(!A||!Number.isSafeInteger(I)||I<1||typeof h!="string"||!Qt.test(h)||!Array.isArray(a.files)||a.files.length<2||a.files.length>ti)return;let b=new Set,V=[];for(let j of a.files){if(!_n(j)||!Xn(j,["path","sha256"]))return;let P=jo(j.path);if(!P||typeof j.sha256!="string"||!Qt.test(j.sha256))return;let O=P.join("/"),H=`${a.packageDir}/${O}`;if(b.has(O)||i.has(H))return;b.add(O),i.add(H),V.push(Object.freeze({path:O,sha256:j.sha256}));}if(!re.some(j=>b.has(j))||!b.has("ui/index.html")||(r+=V.length,r>sc))return;t.add(a.packageDir),o.push(Object.freeze({packageDir:a.packageDir,...d?{launcher:false}:{},appId:u,definition:Object.freeze({id:A,version:I,hash:h}),lineage:Array.isArray(a.lineage)?a.lineage:[],files:Object.freeze(V.sort((j,P)=>xe(j.path,P.path)))}));}return Object.freeze({version:1,packages:Object.freeze(o)})}function we(e){let n=Ic(e);return n==="PATH_ESCAPED"||n==="IDENTITY_CHANGED"||n==="TOCTOU"?"PATH_ESCAPED":n==="LIMIT_EXCEEDED"?"LIMIT_EXCEEDED":"BUNDLE_INTEGRITY"}async function Dc(e,n,t,i,r){let o=[],a=async(s,c)=>{if(!be(i,r))throw new _("LIMIT_EXCEEDED");if(c>2)throw new _("LIMIT_EXCEEDED");let d=await ei(e,n,s);for(let p of d){if(typeof p.name!="string"||p.name.length===0||p.name==="."||p.name===".."||/[\\/\u0000]/.test(p.name))throw new _("PATH_ESCAPED");let l=`${s}/${p.name}`;if(p.kind==="file"){if(o.push(l.slice(t.length+1)),o.length>ti)throw new _("LIMIT_EXCEEDED")}else if(p.kind==="directory")await a(l,c+1);else throw p.kind==="symlink"?new _("PATH_ESCAPED"):new _("READ_DENIED")}};return await a(t,0),o.sort(xe)}function Nc(e){return re.includes(e)?262144:e==="ui/index.html"?Ke:e==="ui/state.json"?2097152:e.startsWith("ui/assets/")?cc:ac}async function vo(e,n,t,i){if(e===void 0)return {packages:[],diagnostics:[],incomplete:false,reservedIds:pc};let r=_c(e.reservedIds),o=[],a=(f,m,T)=>hc(f,"bundled",m),s=(f=[],m=false,T)=>({...T===void 0?{}:{indexHash:T},packages:f,diagnostics:o,incomplete:m,reservedIds:r});if(typeof e.root!="string"||e.root.length===0||typeof e.expectedIndexHash!="string"||!Qt.test(e.expectedIndexHash))return o.push(a("BUNDLE_INTEGRITY","bundle-index.json")),s();let c;try{c=await xo(n,e.root,"bundle-index.json",rc);}catch(f){return o.push(a(we(f),"bundle-index.json")),s()}let d=crypto.createHash("sha256").update(c).digest("hex");if(d!==e.expectedIndexHash)return o.push(a("BUNDLE_INTEGRITY","bundle-index.json")),s();let p=Ec(c);if(p===void 0)return o.push(a("BUNDLE_INTEGRITY","bundle-index.json")),s();if(!Tc(Tn(p.packages),r))return o.push(a("BUNDLE_INTEGRITY","bundle-index.json")),s([],false,d);if(!be(t,i))return o.push(a("LIMIT_EXCEEDED","bundle-index.json")),s(p.packages.map(f=>({indexEntry:f,failureCode:"LIMIT_EXCEEDED"})),true,d);let l;try{l=await ei(n,e.root,"");}catch(f){return o.push(a(we(f),"bundle-index.json")),s(p.packages.map(m=>({indexEntry:m,failureCode:we(f)})),false,d)}if(!be(t,i))return o.push(a("LIMIT_EXCEEDED","bundle-index.json")),s(p.packages.map(f=>({indexEntry:f,failureCode:"LIMIT_EXCEEDED"})),true,d);let u=l.find(f=>f.name==="bundle-index.json"&&f.kind==="file"),A=l.find(f=>f.name==="apps"&&f.kind==="directory"),I=f=>p.packages.map(m=>({indexEntry:m,failureCode:f}));if(!u)return o.push(a("BUNDLE_INTEGRITY","bundle-index.json")),s(I("BUNDLE_INTEGRITY"),false,d);let h=l.filter(f=>f.name!=="bundle-index.json"&&f.name!=="apps");if(h.length>0){let f=h.some(m=>m.kind==="symlink")?"PATH_ESCAPED":"BUNDLE_INTEGRITY";return o.push(a(f,"bundle-index.json")),s(I("BUNDLE_INTEGRITY"),false,d)}if(l.some(f=>f.name==="apps"&&f.kind!=="directory"))return o.push(a("PATH_ESCAPED","apps")),s(I("PATH_ESCAPED"),false,d);let b=[];if(A)try{b=await ei(n,e.root,"apps");}catch(f){return o.push(a(we(f),"apps")),s(I(we(f)),false,d)}if(!be(t,i)||b.length>ni)return o.push(a("LIMIT_EXCEEDED","apps")),s(I("LIMIT_EXCEEDED"),true,d);let V=new Map(p.packages.map(f=>[f.packageDir.slice(5),f])),j=b.filter(f=>!V.has(f.name));for(let f of j)o.push(a(f.kind==="symlink"?"PATH_ESCAPED":"BUNDLE_INTEGRITY",`apps/${f.name}`));if(j.length>0){let f=j.some(m=>m.kind==="symlink")?"PATH_ESCAPED":"BUNDLE_INTEGRITY";return s(I(f),false,d)}let P=new Set,O=new Map,H=new Map;for(let f of p.packages){let m=O.get(f.appId)??[];m.push(f),O.set(f.appId,m);let T=`${f.definition.id}\0${String(f.definition.version)}`,M=H.get(T)??[];M.push(f),H.set(T,M);}for(let f of [...O.values(),...H.values()])if(f.length>1)for(let m of f)P.add(m);let N=[],L=c.byteLength,S=false;for(let f of p.packages){if(!be(t,i)){S=true,N.push({indexEntry:f,failureCode:"LIMIT_EXCEEDED"});continue}let m;try{let D=f.lineage[f.lineage.length-1];if(!D)throw new Te("LINEAGE_INVALID","Definition lineage is missing");if(D.definition.id!==f.definition.id||D.version!==f.definition.version||D.hash!==f.definition.hash)throw new Te("LINEAGE_STALE","Last lineage generation does not match bundle identity");m=vt(f.lineage,{...D.definition,hash:D.hash}).entries;}catch(D){let z=D instanceof Te?D.code:"LINEAGE_INVALID";o.push(a(z,f.packageDir)),N.push({indexEntry:f,failureCode:z});continue}let T=b.find(D=>D.name===f.packageDir.slice(5));if(!A||!T){N.push({indexEntry:f,failureCode:"BUNDLE_INTEGRITY"});continue}if(T.kind!=="directory"){N.push({indexEntry:f,failureCode:T.kind==="symlink"?"PATH_ESCAPED":"BUNDLE_INTEGRITY"});continue}let M;try{let D=await Dc(n,e.root,f.packageDir,t,i);if(!be(t,i)){S=!0,N.push({indexEntry:f,failureCode:"LIMIT_EXCEEDED"});continue}let z=f.files.map(G=>G.path);if(D.length!==z.length||D.some((G,Ee)=>G!==z[Ee])){N.push({indexEntry:f,failureCode:"BUNDLE_INTEGRITY"});continue}M=new Map;let te;for(let G of f.files){if(!be(t,i)){te="LIMIT_EXCEEDED",S=!0;break}if(L>=Zt){te="LIMIT_EXCEEDED";break}let Ee;try{Ee=await xo(n,e.root,`${f.packageDir}/${G.path}`,Nc(G.path));}catch(yr){te=we(yr);break}if(!be(t,i)){te="LIMIT_EXCEEDED",S=!0;break}if(L+Ee.byteLength>Zt){L=Zt,te="LIMIT_EXCEEDED";break}if(L+=Ee.byteLength,crypto.createHash("sha256").update(Ee).digest("hex")!==G.sha256){te="BUNDLE_INTEGRITY";break}M.set(G.path,Ee);}if(te!==void 0){N.push({indexEntry:f,failureCode:te});continue}}catch(D){be(t,i)||(S=true),N.push({indexEntry:f,failureCode:we(D)});continue}N.push({indexEntry:f,lineage:m,files:M,...P.has(f)?{failureCode:"DUPLICATE_ID"}:{}});}return s(N,S,d)}var rc,ni,ti,sc,ac,cc,Zt,Qt,dc,pc,ii=k(()=>{g();Vt();Re();xt();Hn();qt();rc=256*1024,ni=64,ti=128,sc=ni*ti,ac=2*1024*1024,cc=8*1024*1024,Zt=32*1024*1024,Qt=/^[0-9a-f]{64}$/,dc=new TextDecoder("utf-8",{fatal:true}),pc=Object.freeze({appIds:Object.freeze([]),definitionIds:Object.freeze([])});});var ar={};Ir(ar,{AppDiscoveryFsError:()=>_,LOCAL_APP_TOOL_PREFIX:()=>Mc,MCP_APP_WORKSPACE_TOOL_PREFIX:()=>Sc,NodeAppDiscoveryFs:()=>Ze,NodeAppDiscoveryFsAdapter:()=>Uo,WORKSPACE_APP_TOOL_PREFIX:()=>Qe,createWorkspaceAppScanCache:()=>bo,defaultAppDiscoveryFs:()=>Wn,defaultNodeAppDiscoveryFs:()=>Ro,deriveWorkspaceAppToolName:()=>Lc,deriveWorkspaceAppToolNames:()=>si,discoverWorkspaceAppCandidates:()=>id,discoverWorkspaceApps:()=>ai,isWorkspacePackage:()=>Pc,productAppBundleReservations:()=>Tn,scanWorkspaceApps:()=>od});function Pc(e,n){let t=n.split("/");return t.length===2&&t[0]===e&&/^[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(t[1])}function si(e){if(typeof e!="string"||!Ie.test(e))throw new TypeError("pluginId must be a safe UI plugin identifier");let n=`${Qe}${e}`.length+7<=128?e:`hash_${crypto.createHash("sha256").update(e,"utf8").digest("hex")}`;return {read:`${Qe}${n}_read`,action:`${Qe}${n}_action`}}function Lc(e,n="read"){let t=si(e);return n==="read"?t.read:t.action}function Fo(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;try{let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}catch{return false}}function Rc(e,n){return n.length===0||n==="."||n===".."||/[\\/\u0000]/.test(n)?e==="skills"?"skills":"apps":`${e==="skills"?"skills":"apps"}/${n}`}function Uc(e){return e.length>0&&e!=="."&&e!==".."&&!/[\\/\u0000]/.test(e)}function En(e,n){let t=new TextEncoder().encode(e),i=new TextEncoder().encode(n),r=Math.min(t.byteLength,i.byteLength);for(let o=0;o<r;o+=1){let a=t[o]-i[o];if(a!==0)return a}return t.byteLength-i.byteLength}function qo(e){if(typeof e=="string")return {name:e,kind:"directory"};if(e===null||typeof e!="object")return null;let n=e;if(typeof n.name!="string")return null;if(n.kind==="file"||n.kind==="directory"||n.kind==="symlink"||n.kind==="other")return {name:n.name,kind:n.kind};if(n.type==="file"||n.type==="directory"||n.type==="symlink"||n.type==="other")return {name:n.name,kind:n.type};let t=n.isDirectory;if(typeof t=="function"&&t.call(e))return {name:n.name,kind:"directory"};let i=n.isSymbolicLink;if(typeof i=="function"&&i.call(e))return {name:n.name,kind:"symlink"};let r=n.isFile;return typeof r=="function"&&r.call(e)?{name:n.name,kind:"file"}:{name:n.name,kind:"other"}}function Cc(e){if(e instanceof Uint8Array)return new Uint8Array(e);if(e instanceof ArrayBuffer)return new Uint8Array(e.slice(0));if(Array.isArray(e)&&e.every(n=>Number.isInteger(n)&&n>=0&&n<=255))return Uint8Array.from(e);throw new TypeError("filesystem port returned an invalid byte array")}function Zo(e){return Oc.decode(e)}function kc(e){return JSON.parse(Zo(e))}function wc(e){if(e===void 0)return;let n=e.definitionId!==void 0&&e.definitionVersion!==void 0?`${e.definitionId}\0${String(e.definitionVersion)}`:void 0;return {pluginId:e.pluginId,...n===void 0?{}:{definitionKey:n}}}function Yn(e,n,t,i,r){let o={code:e,...i===void 0?{}:{pluginId:i},source:n,relativePath:t,...r?.reason===void 0?{}:{reason:Object.freeze({...r.reason})},...r?.files===void 0?{}:{files:Object.freeze([...r.files])}};return Object.freeze(o)}function Bo(e){switch(e){case "ENOENT":return "NOT_FOUND";case "ELOOP":case "EXDEV":return "PATH_ESCAPED";case "EFBIG":case "EOVERFLOW":return "LIMIT_EXCEEDED";case "EACCES":case "EPERM":case "ENOTDIR":return "READ_DENIED";default:return e}}function ne(e){if(e instanceof _)return Bo(e.code);if(e!==null&&typeof e=="object"&&"code"in e){let n=e.code;if(typeof n=="string")return Bo(n)}}function ve(e,n){return e==="PATH_ESCAPED"||e==="IDENTITY_CHANGED"||e==="TOCTOU"?"PATH_ESCAPED":e==="LIMIT_EXCEEDED"?"LIMIT_EXCEEDED":n==="manifest"&&e==="NOT_FOUND"?"MANIFEST_MISSING":n==="entry"?"ENTRY_INVALID":n==="initial"?"INITIAL_STATE_INVALID":"MANIFEST_INVALID"}function Ho(e){return {reason:e.reason,...e.code==="MANIFEST_DUAL_MISMATCH"?{files:e.files}:{}}}function zo(e){return e==="MANIFEST_DUAL_MISMATCH"?e:Qo(e)}function xc(e){return Qo(e.code)}function Qo(e){switch(e){case "MANIFEST_INVALID":case "PRIMITIVE_UNKNOWN":case "PRIMITIVE_SET_UNSUPPORTED":case "SCHEMA_TYPE_UNSUPPORTED":case "TOKEN_INVALID":case "UNSAFE_VALUE":return "MANIFEST_INVALID";case "LIMIT_EXCEEDED":return "LIMIT_EXCEEDED";case "INITIAL_STATE_INVALID":return "INITIAL_STATE_INVALID";default:return er("UiPluginValidationError",e)}}function er(e,n){throw new Error(`Unmapped ${e} code: ${String(n)}`)}function nr(e){switch(e){case "APP_ID_INVALID":case "TOOL_ID_INVALID":case "RESOURCE_URI_INVALID":case "TOOL_INVALID":case "SERIALIZATION_INVALID":return "MANIFEST_INVALID";case "APP_ID_CONFLICT":case "TOOL_ID_CONFLICT":return "DUPLICATE_ID";case "RESOURCE_NOT_FOUND":case "HTML_INVALID":return "ENTRY_INVALID";case "STATE_INVALID":case "STATE_PROJECTION_INVALID":case "BUTTON_INVALID":return "INITIAL_STATE_INVALID";default:return er("McpAppContractError",e)}}function Pe(e,n){let t=n();return Number.isFinite(t)&&Number.isFinite(e)&&t-e<=5e3}function jc(e){return {pluginId:e.appId,definitionKey:`${e.definition.id}\0${String(e.definition.version)}`}}function vc(e,n){let t=n.get("package.json");if(t!==void 0)try{let r=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(t));if(Fo(r)){let o=r.bin,a=typeof o=="string"?o:Fo(o)?Object.values(o).find(s=>typeof s=="string"):void 0;for(let s of [a,r.main]){if(typeof s!="string")continue;let c=Vc(s);if(c&&n.has(c))return c}}}catch{}return [`${e.slice(e.lastIndexOf("/")+1)}.js`,"index.js","main.js"].find(r=>n.has(r))}function Vc(e){if(e.startsWith("/")||e.includes("\\")||e.includes("\0"))return;let n=e.split("/").filter(t=>t!==".");if(!(n.length===0||n.some(t=>t.length===0||t==="..")))return n.join("/")}function Fc(){return globalThis.performance?.now()??Date.now()}function je(e){if(e===null||typeof e!="object"||Object.isFrozen(e))return e;for(let n of Object.values(e))je(n);return Object.freeze(e)}function Go(e){return Object.freeze(Array.from(e))}async function qn(e,n,t,i){if(n.pinnedFiles!==void 0){let s=n.pinnedFiles.get(t);if(s===void 0)throw new _("NOT_FOUND");if(s.byteLength>i)throw new _("LIMIT_EXCEEDED");return new Uint8Array(s)}let r=`${n.relativePath}/${t}`,o=n.scanContext,a=e.fingerprintVerifiedFile;if(o===void 0||!o.cacheable||typeof a!="function")return Xo(e,n.root,r,i);try{let s=o.priorFingerprints.get(r)??await a.call(e,o.workspaceRoot,r,i);o.candidateRealPath=s.candidateRealPath;let c=await Xo(e,n.root,r,i),d=await a.call(e,o.workspaceRoot,r,i);return o.candidateRealPath=d.candidateRealPath,ir(s,d)&&d.size===BigInt(c.byteLength)&&!or(d,o.scanStartedAtNs)?o.files.set(r,{relativePath:r,byteLimit:i,fingerprint:d}):o.cacheable=!1,c}catch(s){let c=re.includes(t)&&ne(s)==="NOT_FOUND"&&o.directoryListings.some(p=>p.relativePath===n.relativePath&&!Zn(p.key,t)),d=t===K&&ne(s)==="NOT_FOUND"&&Bc(o.directoryListings,n.relativePath);throw !c&&!d&&(o.cacheable=false),s}}function Bc(e,n){let t=e.find(r=>r.relativePath===n);if(t===void 0)return false;if(!Zn(t.key,"dist"))return true;let i=e.find(r=>r.relativePath===`${n}/dist`);return i!==void 0&&!Zn(i.key,"tools.json")}function tr(e,n){return JSON.stringify([e.realPath,n.source,n.relativePath])}async function zc(e,n,t,i,r,o,a,s){let c=e.fingerprintVerifiedFile,d=tr(t,i),p=r.candidates.get(d),l=i.relativePath,u;try{u=await Wo(e,n,l);}catch(S){if(ne(S)!=="NOT_FOUND")throw S}let A=u===void 0?void 0:{relativePath:l,key:u};if(A!==void 0&&(i.source==="apps"||i.source==="skills")&&!re.some(S=>Zn(A.key,S)))return Pe(a,s)?p!==void 0&&p.candidate===void 0&&p.candidateRealPath===void 0&&p.files.length===0&&p.directoryListings.length===1&&p.directoryListings[0]?.relativePath===A.relativePath&&p.directoryListings[0]?.key===A.key&&(i.source==="apps"?p.diagnostic?.code==="MANIFEST_MISSING":p.diagnostic===void 0)&&typeof c=="function"?{memo:p}:typeof c!="function"?{}:{context:{state:r,cacheKey:d,workspaceRoot:n,scanStartedAtNs:o,directoryListings:Object.freeze([A]),priorFingerprints:new Map,files:new Map,cacheable:true}}:{timeLimitReached:true};let I=async S=>{if(S==="")return A;let f=`${i.relativePath}${S}`;try{let m=await Wo(e,n,f);return m===void 0?void 0:{relativePath:f,key:m}}catch(m){if(ne(m)==="NOT_FOUND")return;throw m}},h=await Promise.all($o.map(I)),b=await Promise.all(Hc.map(I));if(!Pe(a,s))return {timeLimitReached:true};let V=typeof c=="function"&&h.every(S=>S!==void 0),j=h.filter(S=>S!==void 0),P=[...j,...b.filter(S=>S!==void 0)],O=new Map,H=p!==void 0&&V,N;if(p!==void 0&&typeof c=="function"){let S=await Promise.all(p.files.map(async f=>{if(!Pe(a,s))return {kind:"time",file:f};try{let m=await c.call(e,n,f.relativePath,f.byteLimit);return {kind:"fingerprint",file:f,current:m}}catch(m){return ne(m)==="NOT_FOUND"?{kind:"missing",file:f}:{kind:"error",file:f,error:m}}}));if(S.some(f=>f.kind==="time"))return {timeLimitReached:true};for(let f of S){if(f.kind==="error")throw f.error;if(f.kind==="missing"){H=false;continue}if(f.kind!=="fingerprint")continue;let{file:m,current:T}=f;O.set(m.relativePath,T),N??=T.candidateRealPath,(T.candidateRealPath!==p.candidateRealPath||!ir(T,m.fingerprint)||or(T,o))&&(H=false);}}let L=p!==void 0&&p.directoryListings.length===P.length&&p.directoryListings.every((S,f)=>S.relativePath===P[f]?.relativePath&&S.key===P[f]?.key);return p!==void 0&&V&&L&&H&&N===p.candidateRealPath?{memo:p}:!V||j.length!==$o.length?{}:{context:{state:r,cacheKey:d,workspaceRoot:n,scanStartedAtNs:o,directoryListings:Object.freeze(P),priorFingerprints:O,files:new Map,...N===void 0?{}:{candidateRealPath:N},cacheable:true}}}function Zn(e,n){try{let t=JSON.parse(e);return Array.isArray(t)&&t.some(i=>Array.isArray(i)&&i[0]===n)}catch{return true}}async function Wo(e,n,t){let i=rr(e);if(typeof i!="function")return;let r=await i.call(e,n,t);if(!Array.isArray(r)||r.some(a=>typeof a=="string"))return;let o=r.map(qo);if(!o.some(a=>a===null))return JSON.stringify(o.slice().sort((a,s)=>En(a.name,s.name)||En(a.kind,s.kind)).map(a=>[a.name,a.kind]))}function ir(e,n){return e.dev===n.dev&&e.ino===n.ino&&e.size===n.size&&e.mtimeNs===n.mtimeNs&&e.ctimeNs===n.ctimeNs}function or(e,n){let t=e.mtimeNs-n;return t>=-Jo&&t<=Jo}function oi(e){let n=e.scanContext,t=e.source==="skills"&&e.candidate===void 0&&e.diagnostic===void 0&&n?.files.size===0,i=e.source==="apps"&&e.candidate===void 0&&e.diagnostic?.code==="MANIFEST_MISSING"&&n?.files.size===0,r=t||i;if(n===void 0||!n.cacheable||n.candidateRealPath===void 0&&!r||n.files.size===0&&!r)return;let o=Object.freeze({...!r&&n.candidateRealPath!==void 0?{candidateRealPath:n.candidateRealPath}:{},directoryListings:n.directoryListings,files:Object.freeze([...n.files.values()]),...e.candidate===void 0?{}:{candidate:e.candidate},...e.diagnostic===void 0?{}:{diagnostic:e.diagnostic},...e.identity===void 0?{}:{identity:e.identity},...e.provenance===void 0?{}:{provenance:e.provenance}});n.state.candidates.set(n.cacheKey,o);}function Gc(e,n,t){let i=crypto.createHash("sha256"),r=new TextEncoder().encode(q(e)),o=a=>{let s=new Uint8Array(8);new DataView(s.buffer).setBigUint64(0,BigInt(a)),i.update(s);};return o(r.byteLength),i.update(r),o(n.byteLength),i.update(n),o(t.byteLength),i.update(t),i.digest("hex")}function $c(e,n){let t={...e.definition,sourceHash:n},i;try{i=ie(t);}catch(o){throw o instanceof R&&o.code==="INPUT_INVALID"?new oe("MANIFEST_INVALID","normalized definition is invalid"):o}let r={...t,hash:i};try{de(r);}catch{throw new oe("MANIFEST_INVALID","normalized definition is invalid")}return r}function Jc(e,n){return e.actions.some(t=>t.backend.type==="core"&&t.backend.handler!=="state.set"&&!xn(n,t.backend))}function Wc(e){if(typeof e.readVerifiedFile=="function")return e.readVerifiedFile;if(typeof e.readFileVerified=="function")return e.readFileVerified}function rr(e){if(typeof e.listDirectory=="function")return e.listDirectory;if(typeof e.readDirectory=="function")return e.readDirectory;if(typeof e.readdir=="function")return e.readdir}async function Xo(e,n,t,i){let r=Wc(e);if(!r)throw new _("READ_DENIED");return Cc(await r.call(e,n,t,i))}async function Xc(e,n,t){let i=rr(e);if(!i)throw new _("READ_DENIED");let r=await i.call(e,n,t);if(!Array.isArray(r))throw new _("READ_DENIED");return r.map(qo).filter(o=>o!==null)}function Kc(e){let n=[];for(let t of [e.reserved,e.builtin])t&&n.push(t);return e.builtins&&"listMcpApps"in e.builtins?n.push(Ko(e.builtins)):e.builtins&&n.push(e.builtins),e.builtinCatalog&&n.push(Ko(e.builtinCatalog)),n.push({...e.reservedAppIds===void 0?{}:{appIds:e.reservedAppIds},...e.reservedDefinitionIds===void 0?{}:{definitionIds:e.reservedDefinitionIds},...e.reservedToolNames===void 0?{}:{toolNames:e.reservedToolNames}}),n}function Ko(e){let n=[],t=[],i=[];for(let r of e.listMcpApps())typeof r.appId=="string"&&n.push(r.appId),r.definition&&typeof r.definition.id=="string"&&t.push(r.definition.id);for(let r of e.listMcpAppTools())typeof r.name=="string"&&i.push(r.name);return {appIds:n,definitionIds:t,toolNames:i}}function ye(e,n){e.diagnostic||(e.diagnostic=Yn(n,e.source,e.relativePath,e.identity?.pluginId));}function Yc(e,n){let t=new Set,i=new Map;for(let o of e){let a=o.identity?.pluginId;if(a===void 0)continue;let s=i.get(a)??[];s.push(o),i.set(a,s);}for(let o of i.values()){if(o.length<2)continue;let a=o.filter(c=>c.provenance!==void 0);if(a.length>0){let c=o.find(d=>n.has(d));if(c){for(let d of a)t.add(d);for(let d of o)d!==c&&d.provenance===void 0&&ye(d,"RESERVED_ID");continue}for(let d of o)d.provenance===void 0&&ye(d,"RESERVED_ID");if(a.length>1)for(let d of a)ye(d,"DUPLICATE_ID");continue}let s=o.filter(c=>c.source==="apps");if(s.length>1){for(let c of s)ye(c,"DUPLICATE_ID");for(let c of o.filter(d=>d.source==="skills"))ye(c,"DUPLICATE_ID");}else for(let c of o.filter(d=>d.source==="skills"))ye(c,"DUPLICATE_ID");}let r=new Map;for(let o of e){if(o.diagnostic?.code==="RESERVED_ID"||t.has(o)||o.provenance===void 0&&!n.has(o)&&i.get(o.identity?.pluginId??"")?.some(c=>c.provenance!==void 0))continue;let a=o.identity?.definitionKey;if(a===void 0)continue;let s=r.get(a)??[];s.push(o),r.set(a,s);}for(let o of r.values())if(o.length>1)for(let a of o)ye(a,"DUPLICATE_ID");return t}function qc(e,n,t){let i=new Set,r=new Set,o=new Set,a=new Set([...t.appIds,...n.productBundleReservationMetadata?.reservedAppIds??[]]),s=new Set([...t.definitionIds,...n.productBundleReservationMetadata?.reservedDefinitionIds??[]]);for(let p of Kc(n)){for(let l of p.appIds??[])typeof l=="string"&&i.add(l);for(let l of p.definitionIds??[])typeof l=="string"&&r.add(l);for(let l of p.toolNames??[])typeof l=="string"&&o.add(l);}for(let p of e){let l=p.candidate;if(!l)continue;if(i.has(l.pluginId)||r.has(l.definitionId)){ye(p,"RESERVED_ID");continue}[l.toolNames.read,l.toolNames.action].filter(A=>A!==void 0).some(A=>o.has(A))&&ye(p,"DUPLICATE_ID");}let c=[...e.filter(p=>p.provenance!==void 0&&p.diagnostic===void 0).flatMap(p=>p.candidate?[p.candidate]:[]),...(n.productBundleReservationMetadata?.candidates??[]).filter(p=>n.productBundleReservationMetadata?.indexHash!==void 0&&p.provenance?.indexHash===n.productBundleReservationMetadata.indexHash)],d=new Set;for(let p of e){let l=p.candidate;if(!(!l||p.diagnostic||p.source!=="apps"||p.provenance!==void 0)&&e.filter(u=>u.source==="apps"&&u.identity?.pluginId===l.pluginId).length===1&&c.some(u=>u.pluginId===l.pluginId)&&!(s.has(l.definitionId)&&!c.some(u=>u.pluginId===l.pluginId&&u.definitionId===l.definitionId))&&!c.some(u=>u.pluginId!==l.pluginId&&u.definitionId===l.definitionId)&&!e.some(u=>u.identity?.pluginId!==l.pluginId&&u.identity?.definitionKey===`${l.definitionId}\0${l.version}`&&u.diagnostic?.code!=="RESERVED_ID"))try{Do(l),d.add(p);}catch(u){ye(p,u instanceof _e?nr(u.code):"EXEC_DENIED");}}for(let p of e){let l=p.candidate;l&&p.provenance===void 0&&!d.has(p)&&(a.has(l.pluginId)||s.has(l.definitionId))&&ye(p,"RESERVED_ID");}return d}function Zc(e){return [...e].sort((n,t)=>{let i=Vo.indexOf(n.source)-Vo.indexOf(t.source);return i!==0?i:En(n.relativePath,t.relativePath)})}function w(e,n,t){e.diagnostic=Yn(n,e.source,e.relativePath,e.identity?.pluginId,t);}async function Yo(e,n,t){let i=wt(t,{mode:"local"});if(!i.ok&&i.parseFailure){w(n,zo(i.rejection.code),Ho(i.rejection));return}let r=wc(i.identity);if(n.bundleIdentity===void 0)n.identity=r;else if(r?.pluginId!==n.bundleIdentity.appId||r.definitionKey!==`${n.bundleIdentity.definitionId}\0${String(n.bundleIdentity.version)}`){w(n,"BUNDLE_INTEGRITY");return}if(!i.ok&&i.builtinOnly){w(n,"RESERVED_ID");return}if(!i.ok){w(n,zo(i.rejection.code),Ho(i.rejection));return}let o=i.manifest,a={pluginId:o.pluginId,definitionKey:`${o.definitionId}\0${String(o.version)}`};if(n.bundleIdentity===void 0&&(n.identity=a),o.actions.length>0)try{Ht(o.actions.map(D=>({actionId:D.actionId,inputSchema:D.inputSchema})));}catch(D){if(D instanceof _e){w(n,nr(D.code));return}throw D}let s;try{s=await qn(e,n,"ui/index.html",Ke);}catch(D){w(n,ve(ne(D),"entry"));return}if(s.byteLength>Ke){w(n,"LIMIT_EXCEEDED");return}let c;try{c=Zo(s);}catch{w(n,"ENTRY_INVALID");return}if(s.byteLength===0||c.length===0){w(n,"ENTRY_INVALID");return}let d=crypto.createHash("sha256").update(s).digest("hex");if(o.entryHash!==void 0&&o.entryHash!==d){w(n,"ENTRY_INVALID");return}let p={},l,u;if(o.initialState!==void 0){try{l=await qn(e,n,"ui/state.json",2097152);}catch(D){w(n,ve(ne(D),"initial"));return}if(l.byteLength>2097152){w(n,"LIMIT_EXCEEDED");return}try{let D=kc(l),z=o.dataPaths??[],te=Pt(D,z);p=ce(te,0,z),Be(p);}catch{w(n,"INITIAL_STATE_INVALID");return}if(u=crypto.createHash("sha256").update(l).digest("hex"),o.initialState.hash!==void 0&&o.initialState.hash!==u){w(n,"INITIAL_STATE_INVALID");return}}let A={...o,entryHash:d,...o.initialState===void 0?{}:{initialState:{path:"ui/state.json",hash:u}}},I=an(A),h=Gc(A,s,l??new Uint8Array),b;try{b=$c(I,h);}catch(D){if(D instanceof oe){w(n,xc(D));return}throw D}let V;if(n.bundleLineage!==void 0){let D=n.bundleLineage[n.bundleLineage.length-1];if(!D){w(n,"LINEAGE_INVALID");return}let{legacy:z,...te}=D.definition,{hash:G,...Ee}=b;if(q(te)!==q(Ee)){w(n,"LINEAGE_STALE");return}if(z!==void 0&&(b={...b,legacy:z}),z!==void 0)try{b={...b,hash:ie(b)},de(b);}catch{w(n,"LINEAGE_INVALID");return}V=n.bundleLineage;}if(n.bundleIdentity!==void 0&&n.bundleIdentity.appId!==o.pluginId){w(n,"BUNDLE_INTEGRITY");return}if(n.bundleIdentity!==void 0&&(n.bundleIdentity.definitionId!==b.id||n.bundleIdentity.version!==b.version||n.bundleIdentity.definitionHash!==b.hash)){w(n,"LINEAGE_STALE");return}let j=si(o.pluginId),P=o.actions.length===0?{read:j.read}:j,O=je(I),H=je(A),N=je(b),L=je({...I.handlers}),S=Go(s),f=l===void 0?void 0:Go(l),m=Object.freeze({...n.provenance===void 0?{}:{provenance:n.provenance},entry:Object.freeze({path:"ui/index.html",hash:d,bytes:S}),...f===void 0?{}:{initialState:Object.freeze({path:"ui/state.json",hash:u,bytes:f})}}),T={appId:o.pluginId,pluginId:o.pluginId,definitionId:o.definitionId,version:o.version,...i.releaseVersion===void 0?{}:{releaseVersion:i.releaseVersion},manifestFile:i.file,...i.mcpb===void 0?{}:{mcpb:je(i.mcpb)},relativePath:n.relativePath,manifest:H,normalized:O,name:o.name,description:o.description,...o.icon===void 0?{}:{icon:o.icon},...o.tone===void 0?{}:{tone:o.tone},definition:N,handlers:L,resources:m,html:c,entryBytes:S,entryHash:d,initialState:je(p),...f===void 0?{}:{initialStateBytes:f},...u===void 0?{}:{initialStateHash:u},sourceHash:h,toolNames:Object.freeze(P)},M=n.provenance===void 0?{...T,source:n.source}:{...T,provenance:n.provenance,lineage:V??[]};n.candidate=Object.freeze(M),Jc(o,b.usage)&&w(n,"EXEC_DENIED");}async function sr(e,n){let t={};for(let i of re)try{t[i]=await qn(e,n,i,262144);}catch(r){if(ne(r)==="NOT_FOUND")continue;return {files:t,failure:ve(ne(r),"manifest")}}if(t[X]!==void 0)try{t[K]=await qn(e,n,K,262144);}catch(i){if(ne(i)!=="NOT_FOUND")return {files:t,failure:ve(ne(i),"manifest")}}return {files:t}}function ri(e){return re.some(n=>e[n]!==void 0)}async function Qc(e,n){let{files:t,failure:i}=await sr(e,n);if(i!==void 0){w(n,i);return}let r=t[X];return r!==void 0&&!kt(r)&&(delete t[X],delete t[K]),ri(t)?t:void 0}function ed(e,n,t,i=bc,r=false,o=new Set){let a=Zc(e),s=Yc(a,o),c=Object.freeze(a.filter(u=>u.candidate!==void 0&&u.diagnostic===void 0&&!s.has(u)).map(u=>u.candidate)),d=Object.freeze(a.filter(u=>u.diagnostic!==void 0).map(u=>u.diagnostic)),p=r?Object.freeze({...t===void 0?{}:{indexHash:t},candidates:Object.freeze(a.filter(u=>u.source==="bundled"&&u.diagnostic===void 0&&t!==void 0&&u.candidate?.provenance?.indexHash===t).map(u=>u.candidate)),diagnostics:Object.freeze(d.filter(u=>u.source==="bundled").map(u=>Object.freeze({...u}))),reservedAppIds:Object.freeze([...i.appIds]),reservedDefinitionIds:Object.freeze([...i.definitionIds])}):void 0,l={apps:c,diagnostics:d,complete:n===void 0,...n===void 0?{}:{incompleteReason:n},...t===void 0?{}:{productBundleIndexHash:t},...p===void 0?{}:{productBundleSnapshotMetadata:p}};return Object.defineProperty(l,"candidates",{configurable:false,enumerable:false,get:()=>c}),Object.freeze(l)}function nd(e){if(e===null||typeof e!="object"&&typeof e!="function")return false;let n=e;return typeof n.readVerifiedFile=="function"||typeof n.readFileVerified=="function"||typeof n.listDirectory=="function"||typeof n.readDirectory=="function"||typeof n.readdir=="function"}function td(e,n){if(nd(e))return {fs:e,options:n??{}};let t=e??n??{};return {fs:t.filesystem??t.fileSystem??t.fs??Wn,options:t}}async function ai(e,n,t){if(typeof e!="string"||e.length===0)throw new TypeError("workspaceRoot must be explicit");let{fs:i,options:r}=td(n,t),o=r.clock??Fc,a=o(),s=await vo(r.productBundle,i,a,o),c=o(),d=BigInt(Date.now())*1000000n,p=[],l=0,u,A=false,I,h;if(r.scanCache!==void 0&&typeof i.getRootIdentity=="function"&&typeof i.fingerprintVerifiedFile=="function")try{h=await i.getRootIdentity(e),I=Po(r.scanCache,h),I.scanStartedAtNs=d;}catch(N){if(ne(N)!=="NOT_FOUND")throw N}let b=I!==void 0&&r.productBundle===void 0&&s.packages.length===0&&s.diagnostics.length===0,V=new Set,j=true;p.push(...s.diagnostics.map(N=>({source:N.source,root:r.productBundle?.root??e,name:"",relativePath:N.relativePath,diagnostic:N})));let P=s.reservedIds;s.incomplete&&(u="time_limit");for(let N of s.packages){if(!Pe(c,o)){A=true,u="time_limit";break}let L=N.indexEntry,S=L.packageDir,f=N.files===void 0?void 0:vc(S,N.files),m=s.indexHash===void 0?void 0:qi(Object.freeze({kind:"bundled",launcher:L.launcher!==false,indexHash:s.indexHash,packageDir:S,appId:L.appId,definitionId:L.definition.id,version:L.definition.version,definitionHash:L.definition.hash,files:L.files}),f),T={source:"bundled",root:r.productBundle?.root??e,name:S.slice(5),relativePath:S,...m===void 0?{}:{provenance:m},...N.files===void 0?{}:{pinnedFiles:N.files},...N.lineage===void 0?{}:{bundleLineage:N.lineage},bundleIdentity:{appId:L.appId,definitionId:L.definition.id,version:L.definition.version,definitionHash:L.definition.hash},identity:jc(L)};if(p.push(T),l+=1,N.failureCode!==void 0){w(T,N.failureCode);continue}if(N.files?.has(K)===true){w(T,"EXEC_DENIED",{reason:{path:"",rule:"bundled-tool-mode-unsupported",file:K}});continue}let M={};for(let D of re){let z=N.files?.get(D);z!==void 0&&(M[D]=z);}if(!ri(M)){w(T,"BUNDLE_INTEGRITY");continue}if(await Yo(i,T,M),!Pe(c,o)){A=true,u="time_limit";break}}let O=[{source:"apps",directory:"apps"},{source:"skills",directory:"skills"}];e:for(let N of O){let{source:L,directory:S}=N,f;try{f=await Xc(i,e,S);}catch(T){if(ne(T)==="NOT_FOUND")continue;b=false,j=false,p.push({source:L,root:e,name:"",relativePath:L,diagnostic:Yn(ve(ne(T),"manifest"),L,L)});continue}let m=f.filter(T=>T.kind==="directory"||T.kind==="symlink").filter(T=>Uc(T.name)).map(T=>({source:L,root:e,name:T.name,relativePath:Rc(L,T.name)})).sort((T,M)=>En(T.relativePath,M.relativePath));for(let T of m){let M={...T};if(p.push(M),h!==void 0?V.add(tr(h,M)):b=false,!Pe(c,o)){A=true,u="time_limit";break e}let D;if(I!==void 0&&h!==void 0){try{let G=await zc(i,e,h,M,I,d,c,o);if(G.timeLimitReached){A=!0,u="time_limit";break e}M.scanContext=G.context,D=G.memo;}catch(G){b=false,w(M,ve(ne(G),"manifest"));continue}D===void 0&&(b=false);}if(D!==void 0){if(M.candidate=D.candidate,M.diagnostic=D.diagnostic,M.identity=D.identity,L==="skills"&&D.candidate===void 0&&D.diagnostic===void 0)continue;if(l>=64){w(M,"LIMIT_EXCEEDED");continue}if(T.relativePath.split("/").length-1>2){w(M,"LIMIT_EXCEEDED");continue}if(l+=1,!Pe(c,o)){A=true,u="time_limit";break e}continue}let z;if(L==="skills"&&(z=await Qc(i,M),z===void 0)){M.diagnostic===void 0&&oi(M);continue}if(l>=64){w(M,"LIMIT_EXCEEDED");continue}if(T.relativePath.split("/").length-1>2){w(M,"LIMIT_EXCEEDED");continue}if(!Pe(c,o)){A=true,u="time_limit";break e}if(l+=1,z===void 0){let G=await sr(i,M);if(G.failure!==void 0||!ri(G.files)){w(M,G.failure??ve("NOT_FOUND","manifest")),oi(M);continue}z=G.files;}if(await Yo(i,M,z),oi(M),!Pe(c,o)){A=true,u="time_limit";break e}}}if(I!==void 0&&h!==void 0){let N=[...V].sort(En),L=I.lastCandidateKeys,S=L!==void 0&&L.length===N.length&&L.every((m,T)=>m===N[T]);if(b=b&&S,j&&!A&&u===void 0)for(let m of I.candidates.keys())try{JSON.parse(m)[0]===h.realPath&&!V.has(m)&&I.candidates.delete(m);}catch{I.candidates.delete(m);}let f=[...I.candidates.keys()].filter(m=>{try{return JSON.parse(m)[0]===h.realPath}catch{return false}});b=b&&f.length===V.size&&f.every(m=>V.has(m))&&!A&&u===void 0,I.lastCandidateScanUnchanged=b,j&&!A&&u===void 0&&(I.lastCandidateKeys=Object.freeze(N));}A&&p.push({source:"apps",root:e,name:"",relativePath:"apps",diagnostic:Yn("DISCOVERY_TIME_LIMIT","apps","apps")});let H=qc(p,r,P);return ed(p,u,s.indexHash,P,r.productBundle!==void 0,H)}var bc,Qe,Mc,Sc,Vo,Oc,$o,Hc,Jo,id,od,cr=k(()=>{g();Ue();Dn();De();Wi();Re();Hn();No();jn();kn();Mo();qt();wn();ii();ii();bc=Tn([]);Qe="crewx_local_app_",Mc=Qe,Sc=Qe;Vo=["bundled","apps","skills"],Oc=new TextDecoder("utf-8",{fatal:true});$o=["","/ui"],Hc=["/dist"],Jo=2000000000n;id=ai,od=ai;});g();var dr="SKILL.md",dd=/^---\s*\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/;function pr(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}function pd(e){return e.isDirectory()||e.isSymbolicLink()}function fr(e){try{return fs$1.existsSync(e)&&fs$1.statSync(e).isDirectory()}catch{return false}}var ld=["index.js","main.js"];function lu(e,n){let t=path.join(e,"package.json");if(fs$1.existsSync(t))try{let r=JSON.parse(fs$1.readFileSync(t,"utf8"));if(r.bin){let o=typeof r.bin=="string"?r.bin:Object.values(r.bin).find(a=>typeof a=="string");if(o){let a=path.resolve(e,o);if(fs$1.existsSync(a))return a}}if(typeof r.main=="string"){let o=path.resolve(e,r.main);if(fs$1.existsSync(o))return o}}catch{}let i=path.resolve(e,`${n}.js`);if(fs$1.existsSync(i))return i;for(let r of ld){let o=path.resolve(e,r);if(fs$1.existsSync(o))return o}}function ud(e){let n;try{n=fs$1.readFileSync(e,"utf8");}catch{return {frontmatter:{},readable:false,valid:false,hasFrontmatter:false}}let t=n.match(dd);if(!t)return {frontmatter:{},readable:true,valid:true,hasFrontmatter:false};try{let i=jsYaml.load(t[1]??"");if(!pr(i))return {frontmatter:{},readable:!0,valid:!1,hasFrontmatter:!0};let r=pr(i.metadata)?i.metadata:void 0;return {frontmatter:{...typeof i.name=="string"?{name:i.name}:{},...typeof(r?.version??i.version)=="string"?{version:r?.version??i.version}:{},...typeof i.description=="string"?{description:i.description}:{}},readable:!0,valid:!0,hasFrontmatter:!0}}catch{return {frontmatter:{},readable:true,valid:false,hasFrontmatter:true}}}function fd(e){return [path.join(e,dr),path.join(e,"skill",dr)]}function Qn(e,n){if(!fr(e))return null;for(let t of fd(e)){if(!fs$1.existsSync(t))continue;let r=ud(t).frontmatter;return {name:r.name??n,...r.version===void 0?{}:{version:r.version},...r.description===void 0?{}:{description:r.description},skillMdPath:t,dir:e}}return null}function ci(e){try{return fs$1.readdirSync(e,{withFileTypes:!0}).filter(pd)}catch{return []}}function yd(e){return e.length===0||/[\\\u0000]/.test(e)?false:e.split("/").every(n=>n.length>0&&n!=="."&&n!=="..")}function lr(e,n,t){!e||n.has(e.name)||(n.add(e.name),t.push(e));}function et(e){let n=[],t=new Set;for(let i of e)if(fr(i))for(let r of ci(i)){if(r.name.startsWith("@")){let o=path.join(i,r.name);for(let a of ci(o))lr(Qn(path.join(o,a.name),a.name),t,n);continue}lr(Qn(path.join(i,r.name),r.name),t,n);}return n.sort((i,r)=>i.name.localeCompare(r.name))}function Ad(e,n){if(!yd(e))throw new Error(`Skill not found: ${e}`);for(let i of n){let r=Qn(path.join(i,e),e);if(r)return r;for(let o of ci(i)){if(!o.name.startsWith("@"))continue;let a=Qn(path.join(i,o.name,e),e);if(a)return a}}let t=et(n).find(i=>i.name===e);if(t)return t;throw new Error(`Skill not found: ${e}`)}async function uu(e){if(!e||e.root===null)return {skills:[],diagnostics:[]};let{discoverWorkspaceApps:n}=await Promise.resolve().then(()=>(cr(),ar)),t=await n(e.root,{productBundle:e}),i=[],r=new Set;for(let o of t.apps){let a=o.provenance?.kind==="bundled"?o.provenance.packageDir:void 0;if(!a)continue;let s=path.join(e.root,...a.split("/"));for(let c of et([path.dirname(s)]))path.resolve(c.dir)!==path.resolve(s)||r.has(c.name)||(r.add(c.name),i.push(c));for(let c of [path.join(s,"skill"),path.join(s,"skills")])for(let d of et([c]))r.has(d.name)||(r.add(d.name),i.push(d));}return {skills:i.sort((o,a)=>o.name.localeCompare(a.name)),diagnostics:t.diagnostics.filter(o=>o.source==="bundled")}}var fu=et,yu=Ad;
2
+ exports.discover=et;exports.discoverBundledProductSkills=uu;exports.discoverSkills=fu;exports.findEntrypoint=lu;exports.readSkillFrontmatter=ud;exports.resolve=Ad;exports.resolveSkill=yu;
@@ -0,0 +1,18 @@
1
+ export interface SkillDefinition {
2
+ readonly name: string;
3
+ readonly version?: string;
4
+ readonly description?: string;
5
+ readonly skillMdPath: string;
6
+ readonly dir: string;
7
+ }
8
+ export interface SkillFrontmatter {
9
+ readonly name?: string;
10
+ readonly version?: string;
11
+ readonly description?: string;
12
+ }
13
+ export interface SkillFrontmatterReadResult {
14
+ readonly frontmatter: SkillFrontmatter;
15
+ readonly readable: boolean;
16
+ readonly valid: boolean;
17
+ readonly hasFrontmatter: boolean;
18
+ }
@@ -0,0 +1,7 @@
1
+ import type { TaskLogEntry } from '../types/task-log.types.js';
2
+ export interface AnchorChildInput {
3
+ taskId: string;
4
+ agentId: string;
5
+ readonly [key: string]: unknown;
6
+ }
7
+ export declare function anchorChildTasks(entries: TaskLogEntry[], children: AnchorChildInput[]): TaskLogEntry[];
@@ -0,0 +1,34 @@
1
+ export declare const DELEGATION_RESULT_PREFIX = "[[crewx:delegation-result ";
2
+ export declare const DELEGATION_RESULT_MARKER = "[[crewx:delegation-result";
3
+ declare const DELEGATION_SCHEMA: 1;
4
+ export interface DelegationResult {
5
+ schema: typeof DELEGATION_SCHEMA;
6
+ taskId?: string;
7
+ agentId?: string;
8
+ isError: boolean;
9
+ }
10
+ export interface DelegationResultInput {
11
+ taskId?: string;
12
+ agentId?: string;
13
+ isError: boolean;
14
+ schema?: typeof DELEGATION_SCHEMA;
15
+ }
16
+ export interface ParsedDelegationResult {
17
+ result: DelegationResult | null;
18
+ resultPreview: string;
19
+ hasReservedLine: boolean;
20
+ }
21
+ export interface ConsumedDelegationResult {
22
+ resultPreview: string;
23
+ isError: boolean;
24
+ delegationResult?: DelegationResult | null;
25
+ }
26
+ export declare function formatDelegationResult(input: DelegationResultInput): string;
27
+ export declare function parseDelegationResult(output: string): ParsedDelegationResult;
28
+ export declare function stripDelegationResult(output: string): string;
29
+ export declare function consumeDelegationResult(output: string, providerIsError: boolean): ConsumedDelegationResult;
30
+ export declare const formatDelegationTrailer: typeof formatDelegationResult;
31
+ export declare const parseDelegationTrailer: typeof parseDelegationResult;
32
+ export declare const stripDelegationTrailer: typeof stripDelegationResult;
33
+ export declare function isDelegationResult(value: unknown): value is DelegationResult;
34
+ export {};
@@ -1,9 +1,9 @@
1
- import type { TemplateContext, TemplateEngineOptions } from './types';
1
+ import type { TemplateContext, TemplateEngineOptions, TemplateRenderOptions } from './types';
2
2
  export declare class TemplateEngine {
3
3
  private readonly hbs;
4
4
  private readonly execPolicy;
5
5
  private readonly execEnabled;
6
6
  constructor(options?: TemplateEngineOptions);
7
7
  private registerHelpers;
8
- render(template: string, context?: TemplateContext): Promise<string>;
8
+ render(template: string, context?: TemplateContext, options?: TemplateRenderOptions): Promise<string>;
9
9
  }
@@ -1,4 +1,5 @@
1
- import type { ExecPolicy } from '../types';
1
+ import type { ExecPolicy, ExecReuseScope } from '../types';
2
+ export declare const EXEC_REUSE_SCOPE_DATA_KEY: unique symbol;
2
3
  export declare function getSanitizedEnv(): Record<string, string>;
3
4
  export declare function validateCommand(_command: string): void;
4
5
  export declare function isBuiltinAllowed(_command: string): boolean;
@@ -7,9 +8,9 @@ export declare function isAllowed(_command: string, _policy: ExecPolicy): boolea
7
8
  export declare function setAuditVerbose(_enabled: boolean): void;
8
9
  export declare function logExecAudit(_entry: {
9
10
  command: string;
10
- status: 'allowed' | 'denied' | 'error';
11
+ status: 'allowed' | 'denied' | 'error' | 'reused' | 'in-process';
11
12
  allowed_by?: string;
12
13
  reason?: string;
13
14
  duration_ms?: number;
14
15
  }): void;
15
- export declare function executeCommand(_command: string, _policy: ExecPolicy): string;
16
+ export declare function executeCommand(_command: string, _policy: ExecPolicy, _reuseScope?: ExecReuseScope): string;
@@ -1,4 +1,5 @@
1
- import type { ExecPolicy } from '../types';
1
+ import type { ExecPolicy, ExecReuseScope } from '../types';
2
+ export declare const EXEC_REUSE_SCOPE_DATA_KEY: unique symbol;
2
3
  export declare function getSanitizedEnv(): Record<string, string>;
3
4
  export declare function validateCommand(command: string): void;
4
5
  export declare function isBuiltinAllowed(command: string): boolean;
@@ -7,9 +8,9 @@ export declare function isAllowed(command: string, policy: ExecPolicy): boolean;
7
8
  export declare function setAuditVerbose(enabled: boolean): void;
8
9
  export declare function logExecAudit(entry: {
9
10
  command: string;
10
- status: 'allowed' | 'denied' | 'error';
11
+ status: 'allowed' | 'denied' | 'error' | 'reused' | 'in-process';
11
12
  allowed_by?: string;
12
13
  reason?: string;
13
14
  duration_ms?: number;
14
15
  }): void;
15
- export declare function executeCommand(command: string, policy: ExecPolicy): string;
16
+ export declare function executeCommand(command: string, policy: ExecPolicy, reuseScope?: ExecReuseScope): string;
@@ -2,6 +2,7 @@ export interface FormatConversationBlockContext {
2
2
  messages: any[];
3
3
  platform: string;
4
4
  messagesCount: number;
5
+ hasAppMessages: boolean;
5
6
  agentIds: string[];
6
7
  primaryAgentId: string;
7
8
  currentAgentId: string;
@@ -19,3 +19,23 @@ export interface TemplateEngineOptions {
19
19
  execPolicy?: ExecPolicy;
20
20
  execEnabled?: boolean;
21
21
  }
22
+ export interface ExecReuseMetrics {
23
+ actualCalls: number;
24
+ reusedCalls: number;
25
+ actualMs: number;
26
+ reusedMs: number;
27
+ inProcessCalls: number;
28
+ inProcessMs: number;
29
+ }
30
+ export type PromptListResolver = (argv: readonly string[], ctx: {
31
+ cwd: string;
32
+ env: Record<string, string>;
33
+ }) => string | undefined;
34
+ export interface ExecReuseScope {
35
+ readonly cache: Map<string, string>;
36
+ readonly metrics: ExecReuseMetrics;
37
+ readonly listResolver?: PromptListResolver;
38
+ }
39
+ export interface TemplateRenderOptions {
40
+ execReuseScope?: ExecReuseScope;
41
+ }
@@ -1 +1 @@
1
- 'use strict';function m(){let e=[];return {events:e,async log(t,r){e.push({event:t,payload:r});}}}function f(){let e={debug:[],info:[],warn:[],error:[]};return {entries:e,debug(t,r){e.debug.push({msg:t,meta:r});},info(t,r){e.info.push({msg:t,meta:r});},warn(t,r){e.warn.push({msg:t,meta:r});},error(t,r){e.error.push({msg:t,meta:r});}}}function A(){let e=200,t,r,n={},o={status(i){return e=i,o},set(i,d){return n[i]=d,o},send(i){return r=i,o},json(i){return t=i,o},end(){return o},getStatusCode:()=>e,getJsonBody:()=>t,getSentBody:()=>r,getHeaders:()=>({...n})};return o}function y(){let e=[];return {routes:e,registerRoute(r,n,o){e.push({path:r,handler:n,opts:o});},async simulate(r,n,o=Buffer.alloc(0),i={},d={},g={}){let c=e.find(l=>l.path===n);if(!c)return {status:404,body:{error:"Not found"},headers:{}};let p={method:r,url:n,headers:i,body:o,params:d,query:g},u=A();return await c.handler(p,u),{status:u.getStatusCode(),body:u.getJsonBody()??u.getSentBody(),headers:u.getHeaders()}}}}function R(e){let t=new Map,r=n=>n.startsWith(`${e}::`)?n:`${e}::${n}`;return {async get(n){let o=t.get(r(n));return o?o.value:void 0},async set(n,o){t.set(r(n),{value:o});},async delete(n){return t.delete(r(n))},async list(n){let o=n?r(n):`${e}::`,i=[];for(let d of t.keys())d.startsWith(o)&&i.push(d.slice(e.length+2));return i}}}function M(e){return R(e)}function x(){let e=new Map;return {blobs:e,async put(t,r,n){return e.set(t,{data:r,contentType:n}),t},async get(t){let r=e.get(t);return r?r.data:void 0},async delete(t){return e.delete(t)}}}function S(e){let t=e.instanceId??"mock-instance",r=m(),n=f(),o=y(),i=M(t),d=x(),g=[],c=[],p=[],u={run:async()=>({output:""}),...e.agentRunner},l=new AbortController,v=async a=>(g.push(a),{accepted:true}),C=async a=>(c.push(a),{accepted:true}),k=async(a,O)=>{p.push({messageId:a,patch:O});},h=async a=>({userId:a,displayName:a}),E=async()=>{},b=async()=>({messageId:"mock-proactive",sentAt:Date.now()});return {instanceId:t,installationId:e.installationId,config:e.config,capabilities:new Set(e.capabilities??[]),log:n,agentRunner:u,db:i,storage:d,audit:r,abortSignal:e.abortSignal??l.signal,httpRouter:o,router:o,inbound:v,emitEvent:C,updateMessage:k,resolveUser:h,respondSync:E,proactive:b,inboundCalls:g,emittedEvents:c,sentMessages:p}}function L(){}var P={claude:{models:[{id:"claude-fable-5",name:"Claude Fable 5"},{id:"claude-sonnet-5",name:"Claude Sonnet 5"},{id:"claude-opus-4-8[1m]",name:"Claude Opus 4.8 (Extended)"},{id:"claude-opus-4-8",name:"Claude Opus 4.8"},{id:"claude-opus-4-7[1m]",name:"Claude Opus 4.7 (Extended)"},{id:"claude-opus-4-7",name:"Claude Opus 4.7"},{id:"claude-opus-4-6[1m]",name:"Claude Opus 4.6 (Extended)"},{id:"claude-opus-4-6",name:"Claude Opus 4.6"},{id:"claude-sonnet-4-6[1m]",name:"Claude Sonnet 4.6 (Extended)"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6"},{id:"claude-haiku-4-5",name:"Claude Haiku 4.5"}],modes:[{id:"default",name:"Default"},{id:"acceptEdits",name:"Accept Edits"},{id:"plan",name:"Plan"},{id:"auto",name:"Auto"},{id:"dontAsk",name:"Don't Ask"},{id:"bypassPermissions",name:"Bypass Permissions"}],effort:[],modelOverrides:{}},codex:{models:[{id:"gpt-5.5",name:"GPT-5.5"},{id:"gpt-5.4",name:"GPT-5.4"},{id:"gpt-5.4-mini",name:"GPT-5.4 Mini"},{id:"gpt-5.3-codex",name:"GPT-5.3 Codex"},{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark"}],modes:[{id:"agent",name:"Agent"},{id:"read-only",name:"Read Only"},{id:"plan",name:"Plan"},{id:"agent-full-access",name:"Agent Full Access"},{id:"yolo",name:"YOLO"}],effort:["minimal","low","medium","high"],modelOverrides:{"gpt-5.5":{effort:["minimal","low","medium","high","xhigh"],defaultEffort:"high"}}},copilot:{models:[{id:"auto",name:"Auto"},{id:"claude-sonnet-5",name:"Claude Sonnet 5"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6"},{id:"gpt-5.5",name:"GPT-5.5"},{id:"gpt-5.4",name:"GPT-5.4"},{id:"gemini-3.1-pro",name:"Gemini 3.1 Pro"}],modes:[{id:"interactive",name:"Interactive"},{id:"plan",name:"Plan"},{id:"autopilot",name:"Autopilot"}],effort:["none","low","medium","high","xhigh","max"],modelOverrides:{}},antigravity:{models:[{id:"Gemini 3.5 Flash (Medium)",name:"Gemini 3.5 Flash (Medium)"},{id:"Gemini 3.5 Flash (High)",name:"Gemini 3.5 Flash (High)"},{id:"Gemini 3.5 Flash (Low)",name:"Gemini 3.5 Flash (Low)"},{id:"Gemini 3.1 Pro (Low)",name:"Gemini 3.1 Pro (Low)"},{id:"Gemini 3.1 Pro (High)",name:"Gemini 3.1 Pro (High)"},{id:"Claude Sonnet 4.6 (Thinking)",name:"Claude Sonnet 4.6 (Thinking)"},{id:"Claude Opus 4.6 (Thinking)",name:"Claude Opus 4.6 (Thinking)"},{id:"GPT-OSS 120B (Medium)",name:"GPT-OSS 120B (Medium)"}],modes:[],effort:[],modelOverrides:{}}};Object.fromEntries(Object.entries(P).map(([e,t])=>[e,t.models]));function T(){}exports.createMockAudit=m;exports.createMockContext=S;exports.createMockLogger=f;exports.createMockRouter=y;exports.createMockStorage=x;exports.createMockStore=M;exports.resetModelsOverride=T;exports.resetPricingOverride=L;
1
+ 'use strict';function m(){let e=[];return {events:e,async log(t,o){e.push({event:t,payload:o});}}}function f(){let e={debug:[],info:[],warn:[],error:[]};return {entries:e,debug(t,o){e.debug.push({msg:t,meta:o});},info(t,o){e.info.push({msg:t,meta:o});},warn(t,o){e.warn.push({msg:t,meta:o});},error(t,o){e.error.push({msg:t,meta:o});}}}function R(){let e=200,t,o,n={},i={status(r){return e=r,i},set(r,d){return n[r]=d,i},send(r){return o=r,i},json(r){return t=r,i},end(){return i},getStatusCode:()=>e,getJsonBody:()=>t,getSentBody:()=>o,getHeaders:()=>({...n})};return i}function h(){let e=[];return {routes:e,registerRoute(o,n,i){e.push({path:o,handler:n,opts:i});},async simulate(o,n,i=Buffer.alloc(0),r={},d={},c={}){let l=e.find(g=>g.path===n);if(!l)return {status:404,body:{error:"Not found"},headers:{}};let p={method:o,url:n,headers:r,body:i,params:d,query:c},u=R();return await l.handler(p,u),{status:u.getStatusCode(),body:u.getJsonBody()??u.getSentBody(),headers:u.getHeaders()}}}}function M(e){let t=new Map,o=n=>n.startsWith(`${e}::`)?n:`${e}::${n}`;return {async get(n){let i=t.get(o(n));return i?i.value:void 0},async set(n,i){t.set(o(n),{value:i});},async delete(n){return t.delete(o(n))},async list(n){let i=n?o(n):`${e}::`,r=[];for(let d of t.keys())d.startsWith(i)&&r.push(d.slice(e.length+2));return r}}}function y(e){return M(e)}function x(){let e=new Map;return {blobs:e,async put(t,o,n){return e.set(t,{data:o,contentType:n}),t},async get(t){let o=e.get(t);return o?o.data:void 0},async delete(t){return e.delete(t)}}}function A(e){let t=e.instanceId??"mock-instance",o=m(),n=f(),i=h(),r=y(t),d=x(),c=[],l=[],p=[],u={run:async()=>({output:""}),...e.agentRunner},g=new AbortController,k=async a=>(c.push(a),{accepted:true}),w=async a=>(l.push(a),{accepted:true}),v=async(a,O)=>{p.push({messageId:a,patch:O});},E=async a=>({userId:a,displayName:a}),I=async()=>{},b=async()=>({messageId:"mock-proactive",sentAt:Date.now()});return {instanceId:t,installationId:e.installationId,config:e.config,capabilities:new Set(e.capabilities??[]),log:n,agentRunner:u,db:r,storage:d,audit:o,abortSignal:e.abortSignal??g.signal,httpRouter:i,router:i,inbound:k,emitEvent:w,updateMessage:v,resolveUser:E,respondSync:I,proactive:b,inboundCalls:c,emittedEvents:l,sentMessages:p}}function L(){}var P={claude:{models:[{id:"claude-fable-5-1",name:"Claude Fable 5.1",contextWindowTokens:1e6,tier:"flagship",recommended:true},{id:"claude-fable-5",name:"Claude Fable 5",contextWindowTokens:1e6,tier:"flagship"},{id:"claude-opus-5-5",name:"Claude Opus 5.5",contextWindowTokens:1e6,tier:"flagship",recommended:true},{id:"claude-opus-5",name:"Claude Opus 5",contextWindowTokens:1e6,tier:"flagship"},{id:"claude-sonnet-5-5",name:"Claude Sonnet 5.5",contextWindowTokens:1e6,tier:"balanced",recommended:true},{id:"claude-sonnet-5",name:"Claude Sonnet 5",contextWindowTokens:1e6,tier:"balanced"},{id:"claude-opus-4-8[1m]",name:"Claude Opus 4.8",contextWindowTokens:1e6,tier:"flagship"},{id:"claude-opus-4-7[1m]",name:"Claude Opus 4.7",contextWindowTokens:1e6,tier:"flagship"},{id:"claude-opus-4-6[1m]",name:"Claude Opus 4.6",contextWindowTokens:1e6,tier:"flagship"},{id:"claude-sonnet-4-6[1m]",name:"Claude Sonnet 4.6",contextWindowTokens:1e6,tier:"balanced"},{id:"claude-haiku-5-5",name:"Claude Haiku 5.5",contextWindowTokens:1e6,tier:"speed"},{id:"claude-haiku-4-5",name:"Claude Haiku 4.5",contextWindowTokens:2e5,tier:"speed"}],modes:[{id:"default",name:"Default",description:"Uses Claude's default permission handling with normal approval prompts."},{id:"acceptEdits",name:"Accept Edits",description:"Allows file edits without approval; other permission checks remain in place."},{id:"plan",name:"Plan",description:"Keeps Claude in plan mode so it can inspect and propose changes without applying them."},{id:"dontAsk",name:"Don't Ask",description:"Does not ask for permissions; only pre-approved tool actions can proceed."},{id:"bypassPermissions",name:"Bypass Permissions",description:"Bypasses Claude permission checks so tools can run without approval prompts."}],effort:["low","medium","high"],modelOverrides:{"claude-fable-5-1":{effort:["low","medium","high","xhigh","max"],defaultEffort:"high"},"claude-fable-5":{effort:["low","medium","high","xhigh","max"],defaultEffort:"high"},"claude-opus-5-5":{effort:["low","medium","high","xhigh","max"],defaultEffort:"medium"},"claude-opus-5":{effort:["low","medium","high","xhigh","max"],defaultEffort:"high"},"claude-sonnet-5-5":{effort:["low","medium","high","xhigh","max"],defaultEffort:"high"},"claude-sonnet-5":{effort:["low","medium","high","xhigh","max"],defaultEffort:"high"},"claude-opus-4-8[1m]":{effort:["low","medium","high","xhigh","max"],defaultEffort:"high"},"claude-opus-4-7[1m]":{effort:["low","medium","high","xhigh","max"],defaultEffort:"high"},"claude-opus-4-6[1m]":{effort:["low","medium","high","max"],defaultEffort:"high"},"claude-sonnet-4-6[1m]":{effort:["low","medium","high","max"],defaultEffort:"high"},"claude-haiku-5-5":{effort:["low","medium","high","xhigh","max"],defaultEffort:"medium"},"claude-haiku-4-5":{effort:[]}},providerOptions:[]},codex:{models:[{id:"gpt-6-astra",name:"GPT-6 Astra",contextWindowTokens:105e4,tier:"flagship"},{id:"gpt-6.1-sol",name:"GPT-6.1 Sol",contextWindowTokens:105e4,tier:"balanced",recommended:true},{id:"gpt-6-sol",name:"GPT-6 Sol",contextWindowTokens:105e4,tier:"balanced"},{id:"gpt-6-luna",name:"GPT-6 Luna",contextWindowTokens:105e4,tier:"speed",recommended:true},{id:"gpt-5.6-sol",name:"GPT-5.6 Sol",contextWindowTokens:105e4,tier:"flagship"},{id:"gpt-5.6-terra",name:"GPT-5.6 Terra",contextWindowTokens:105e4,tier:"balanced"},{id:"gpt-5.6-luna",name:"GPT-5.6 Luna",contextWindowTokens:105e4,tier:"speed"}],modes:[{id:"agent",name:"Agent",description:"Uses the workspace-write sandbox; can read and modify workspace files without full machine access."},{id:"read-only",name:"Read Only",description:"Uses the read-only sandbox; can inspect files but cannot write to the workspace."},{id:"plan",name:"Plan",description:"Uses the read-only sandbox for planning and inspection; cannot write to the workspace."},{id:"agent-full-access",name:"Agent Full Access",description:"Bypasses approvals and the sandbox; can access and modify files beyond the workspace."},{id:"yolo",name:"YOLO",description:"Bypasses approvals and the sandbox for unrestricted execution and full filesystem access."}],effort:["minimal","low","medium","high"],modelOverrides:{"gpt-6-astra":{effort:["low","medium","high","xhigh","max"],defaultEffort:"xhigh"},"gpt-6.1-sol":{effort:["low","medium","high","xhigh","max"],defaultEffort:"high"},"gpt-6-sol":{effort:["none","low","medium","high","xhigh","max"],defaultEffort:"max"},"gpt-6-luna":{effort:["none","low","medium","high","xhigh","max"],defaultEffort:"medium"},"gpt-5.6-sol":{effort:["low","medium","high","xhigh","max","ultra"],defaultEffort:"xhigh"},"gpt-5.6-terra":{effort:["low","medium","high","xhigh","max","ultra"],defaultEffort:"high"},"gpt-5.6-luna":{effort:["low","medium","high","xhigh","max"],defaultEffort:"high"},"gpt-5.5":{effort:["low","medium","high","xhigh"],defaultEffort:"high"}},providerOptions:[]},opencode:{models:[],modes:[{id:"plan",name:"Plan",description:"Uses the plan agent without --auto; planning follows standard approval behavior."},{id:"plan-auto",name:"Plan \xB7 Auto",description:"Uses the plan agent with --auto; planning uses automatic approvals."},{id:"build",name:"Build",description:"Uses the build agent without --auto; work follows standard approval behavior."},{id:"build-auto",name:"Build \xB7 Auto",description:"Uses the build agent with --auto; work uses automatic approvals."}],effort:[],modelOverrides:{},providerOptions:[]},copilot:{models:[{id:"auto",name:"Auto"},{id:"claude-sonnet-5",name:"Claude Sonnet 5",contextWindowTokens:1e6,tier:"balanced"}],modes:[{id:"interactive",name:"Interactive",description:"Passes --mode interactive; tool access follows Copilot's interactive mode behavior."},{id:"plan",name:"Plan",description:"Passes --mode plan; planning and permission behavior follow Copilot's plan mode."},{id:"autopilot",name:"Autopilot",description:"Passes --mode autopilot; execution behavior follows Copilot's autonomous mode."}],effort:["none","low","medium","high","xhigh","max"],modelOverrides:{},providerOptions:[]},antigravity:{models:[{id:"gemini-3.7-flash",name:"Gemini 3.7 Flash",contextWindowTokens:1048576,tier:"balanced"},{id:"gemini-3.6-flash",name:"Gemini 3.6 Flash",contextWindowTokens:1048576,tier:"balanced"},{id:"gemini-3.1-pro",name:"Gemini 3.1 Pro",contextWindowTokens:1048576,tier:"flagship"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",contextWindowTokens:1e6,tier:"balanced"},{id:"claude-opus-4-6-thinking",name:"Claude Opus 4.6 Thinking",contextWindowTokens:1e6,tier:"flagship"},{id:"gpt-oss-120b",name:"GPT-OSS 120B",contextWindowTokens:128e3,tier:"balanced"}],modes:[{id:"default",name:"Default",description:"Uses Antigravity's default permission handling. No extra permission flags are passed."},{id:"plan",name:"Plan",description:"Passes --mode plan. This turns on /plan; it is not a Claude-style permission mode."},{id:"acceptEdits",name:"Accept Edits",description:"Passes --mode accept-edits."},{id:"bypassPermissions",name:"Bypass Permissions",description:"Passes --dangerously-skip-permissions so tools can run without approval prompts."}],effort:["low","medium","high"],modelOverrides:{"gemini-3.7-flash":{effort:["low","medium","high"],defaultEffort:"medium"},"gemini-3.6-flash":{effort:["low","medium","high"],defaultEffort:"medium"},"gemini-3.5-flash":{effort:["low","medium","high"],defaultEffort:"medium"},"gemini-3.1-pro":{effort:["low","high"],defaultEffort:"high"},"claude-sonnet-4-6":{effort:[]},"claude-opus-4-6-thinking":{effort:[]},"gpt-oss-120b":{effort:["medium"],defaultEffort:"medium"}},providerOptions:[]},grok:{models:[{id:"grok-4.7",name:"Grok 4.7",contextWindowTokens:5e5,tier:"flagship",recommended:true},{id:"grok-4.6",name:"Grok 4.6",contextWindowTokens:5e5,tier:"flagship"},{id:"grok-4.5",name:"Grok 4.5",contextWindowTokens:5e5,tier:"flagship"}],modes:[{id:"default",name:"Default",description:"Uses Grok's default permission handling."},{id:"acceptEdits",name:"Accept Edits",description:"Allows file edits without changing the selected sandbox profile."},{id:"auto",name:"Auto",description:"Uses Grok automatic permission handling."},{id:"dontAsk",name:"Don't Ask",description:"Does not ask for permission before tool execution."},{id:"bypassPermissions",name:"Bypass Permissions",description:"Bypasses Grok permission checks for tool execution."},{id:"plan",name:"Plan",description:"Keeps Grok in planning mode without applying changes."}],effort:["low","medium","high"],modelOverrides:{"grok-4.7":{effort:["low","medium","high","xhigh"],defaultEffort:"high"},"grok-4.6":{effort:["low","medium","high","xhigh"],defaultEffort:"high"},"grok-4.5":{effort:["low","medium","high"],defaultEffort:"high"}},providerOptions:[{key:"alwaysApprove",type:"boolean"},{key:"sandbox",type:"enum",values:["workspace","read-only","off"]}]}};Object.fromEntries(Object.entries(P).map(([e,t])=>[e,t.models]));var D=[{baseModelId:"claude-opus-4-8",catalogModelId:"claude-opus-4-8[1m]"},{baseModelId:"claude-opus-4-7",catalogModelId:"claude-opus-4-7[1m]"},{baseModelId:"claude-opus-4-6",catalogModelId:"claude-opus-4-6[1m]"},{baseModelId:"claude-sonnet-4-6",catalogModelId:"claude-sonnet-4-6[1m]"}];new Map(D.map(({baseModelId:e,catalogModelId:t})=>[e,t]));var _=[{legacyId:"Gemini 3.7 Flash (High)",model:"gemini-3.7-flash",effort:"high"},{legacyId:"Gemini 3.7 Flash (Medium)",model:"gemini-3.7-flash",effort:"medium"},{legacyId:"Gemini 3.7 Flash (Low)",model:"gemini-3.7-flash",effort:"low"},{legacyId:"Gemini 3.6 Flash (High)",model:"gemini-3.6-flash",effort:"high"},{legacyId:"Gemini 3.6 Flash (Medium)",model:"gemini-3.6-flash",effort:"medium"},{legacyId:"Gemini 3.6 Flash (Low)",model:"gemini-3.6-flash",effort:"low"},{legacyId:"Gemini 3.5 Flash (Medium)",model:"gemini-3.5-flash",effort:"medium"},{legacyId:"Gemini 3.5 Flash (High)",model:"gemini-3.5-flash",effort:"high"},{legacyId:"Gemini 3.5 Flash (Low)",model:"gemini-3.5-flash",effort:"low"},{legacyId:"Gemini 3.1 Pro (Low)",model:"gemini-3.1-pro",effort:"low"},{legacyId:"Gemini 3.1 Pro (High)",model:"gemini-3.1-pro",effort:"high"},{legacyId:"Claude Sonnet 4.6 (Thinking)",model:"claude-sonnet-4-6"},{legacyId:"Claude Opus 4.6 (Thinking)",model:"claude-opus-4-6-thinking"},{legacyId:"GPT-OSS 120B (Medium)",model:"gpt-oss-120b",effort:"medium"},{legacyId:"gemini-3.7-flash-high",model:"gemini-3.7-flash",effort:"high"},{legacyId:"gemini-3.7-flash-medium",model:"gemini-3.7-flash",effort:"medium"},{legacyId:"gemini-3.7-flash-low",model:"gemini-3.7-flash",effort:"low"},{legacyId:"gemini-3.6-flash-high",model:"gemini-3.6-flash",effort:"high"},{legacyId:"gemini-3.6-flash-medium",model:"gemini-3.6-flash",effort:"medium"},{legacyId:"gemini-3.6-flash-low",model:"gemini-3.6-flash",effort:"low"},{legacyId:"gemini-3.5-flash-high",model:"gemini-3.5-flash",effort:"high"},{legacyId:"gemini-3.5-flash-medium",model:"gemini-3.5-flash",effort:"medium"},{legacyId:"gemini-3.5-flash-low",model:"gemini-3.5-flash",effort:"low"},{legacyId:"gemini-3.1-pro-high",model:"gemini-3.1-pro",effort:"high"},{legacyId:"gemini-3.1-pro-low",model:"gemini-3.1-pro",effort:"low"},{legacyId:"gpt-oss-120b-medium",model:"gpt-oss-120b",effort:"medium"}];new Map(_.map(({legacyId:e,model:t,effort:o})=>[e,o===void 0?{model:t}:{model:t,effort:o}]));function B(){}exports.createMockAudit=m;exports.createMockContext=A;exports.createMockLogger=f;exports.createMockRouter=h;exports.createMockStorage=x;exports.createMockStore=y;exports.resetModelsOverride=B;exports.resetPricingOverride=L;