@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
+ import {join,resolve,dirname,relative,sep,isAbsolute}from'path';import'url';import {createHash}from'crypto';import {isIP}from'net';import {existsSync,readFileSync,statSync,readdirSync,constants}from'fs';import {realpath,stat,readdir,open,lstat}from'fs/promises';import {load}from'js-yaml';var Ir=Object.defineProperty;var k=(e,n)=>()=>(e&&(n=e(e=0)),n);var gr=(e,n)=>{for(var t in n)Ir(e,t,{get:n[t],enumerable:true});};var g=k(()=>{});var R,Nn=k(()=>{g();R=class extends Error{constructor(t,i=t,r){super(i);this.code=t;this.currentRevision=r;}code;currentRevision;name="UiRuntimeError"};});function ot(e){return mr.test(e)||hr.test(e)}function ce(){throw new R("INPUT_INVALID","JSON value is not projection-safe")}function Dr(e){let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}function tt(e,n,t,i,r,o){if(n>i&&ce(),e===null||typeof e=="string"||typeof e=="boolean")return typeof e=="string"&&(_r.test(e)||Er.test(e)&&!Pr(r,o)||Tr.test(e))&&ce(),e;if(typeof e=="number")return Number.isFinite(e)||ce(),e;(typeof e!="object"||e===void 0||typeof e=="function"||typeof e=="bigint")&&ce();let a=e;t.has(a)&&ce(),t.add(a);try{if(Array.isArray(e))return e.map(c=>tt(c,n+1,t,i,r,o));Dr(a)||ce();let s={};for(let[c,d]of Object.entries(e))ot(c)&&ce(),s[c]=tt(d,n+1,t,i,[...r,c],o);return s}finally{t.delete(a);}}function de(e,n=0,t=[]){(!Number.isInteger(n)||n<0||n>br)&&ce(),(!Array.isArray(t)||t.some(r=>typeof r!="string"))&&ce();let i=tt(e,0,new Set,Nr+n,[],t);return (i===null||Array.isArray(i)||typeof i!="object")&&ce(),i}function Be(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 Pr(e,n){if(e.length===0)return false;let t=e.join(".");return n.some(i=>Be(t,i))}function He(e){try{let n=JSON.stringify(e);return n===void 0&&ce(),n}catch{ce();}}function it(e){return Array.isArray(e)?e.map(it):e!==null&&typeof e=="object"?Object.fromEntries(Object.keys(e).sort().map(n=>[n,it(e[n])])):e}function Z(e){return He(it(e))}function rt(e){return Buffer.byteLength(e,"utf8")}var mr,hr,_r,Tr,Er,Nr,br,Ne=k(()=>{g();Nn();mr=/(?:proof|token|secret|password|cookie|authorization|private[_-]?key|stack|exception|plugin[_-]?text)/i,hr=/(?:url|uri|endpoint|path|file(?:name|path)?|cwd|shell|directory|dir|folder)$/i,_r=/<\/?[A-Za-z][^>]*>/,Tr=/^(?:[A-Za-z]:[\\/]|\\\\|~[\\/]|\/)/,Er=/^(?:https?|file|ftp|ws|wss):\/\//i;Nr=8,br=4;});var bn,st=k(()=>{g();bn=["text/plain","application/json"];});var pi=k(()=>{g();st();});function ze(e){return Sr.has(e)||Lr.test(e)||Or.test(e)}var li,Sr,Lr,Or,Pn,tn,ge,at,ct,dt,pt,lt,Ue=k(()=>{g();li=["__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"],Sr=new Set(li),Lr=/(?:proof|token|secret|password|cookie|authorization|private[_-]?key|stack|exception|plugin[_-]?text)/i,Or=/(?:url|uri|endpoint|path|file(?:name|path)?|cwd|shell|directory|dir|folder)$/i;Pn=/^[A-Za-z0-9_]+$/,tn=/^[A-Za-z0-9_]+(?:\.[A-Za-z0-9_]+)*$/,ge=/^[A-Za-z][A-Za-z0-9._-]{0,127}$/,at=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/,ct=/^[A-Za-z][A-Za-z0-9._-]{0,127}$/,dt=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$/,pt=["blue","violet","emerald","amber","rose","sky","slate","indigo"],lt=["inline","panel"];});function ut(e){return typeof e=="string"&&bn.includes(e)}var ui=k(()=>{g();st();Ue();});function Mn(e){if(!ft(e))return false;let n=Object.keys(e);return !(n.some(t=>t!=="in"&&t!=="out")||n.length===0||Object.hasOwn(e,"in")&&!Rr(e.in)||Object.hasOwn(e,"out")&&!Ur(e.out))}function Rr(e){return ft(e)?Object.keys(e).every(t=>t==="mediaType"||t==="required")&&Object.hasOwn(e,"mediaType")&&ut(e.mediaType)&&(!Object.hasOwn(e,"required")||typeof e.required=="boolean"):false}function Ur(e){return ft(e)?Object.keys(e).every(t=>t==="mediaType"||t==="range")&&Object.hasOwn(e,"mediaType")&&ut(e.mediaType)&&(!Object.hasOwn(e,"range")||typeof e.range=="boolean"):false}function ft(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}var yt=k(()=>{g();pi();ui();new TextDecoder("utf-8",{fatal:true,ignoreBOM:true});});function oe(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=de(t);return createHash("sha256").update(Z(i)).digest("hex")}function It(e){return `${e.id}\0${e.version}`}function pe(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"||!kr.test(e.sourceHash)))throw new R("DEFINITION_UNSUPPORTED","UI definition source hash is invalid");if(!/^[0-9a-f]{64}$/.test(e.hash)||oe(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=>!xr(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&&At(t.resultProjection),t.content!==void 0&&!Mn(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&&At(e.stateProjection),e.summaryProjection){At(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(wr(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=>Be(t,i))))throw new R("DEFINITION_UNSUPPORTED","UI definition dataPaths are invalid")}}function wr(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=de(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=de(s.structuredContent);if(rt(He(c))>4*1024)throw new Error("fixed result size")}}catch{throw new R("DEFINITION_UNSUPPORTED","UI legacy tool metadata is not projection-safe")}}function At(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 xr(e){return e.length>0&&e.length<=128&&e!=="*"&&e!=="all"&&!/[/*]/.test(e)}var kr,Ce=k(()=>{g();Ne();Nn();yt();kr=/^[0-9a-f]{64}$/;});var fi=k(()=>{g();Ne();});var Y,Ge,gt=k(()=>{g();Y="dist/tools.json",Ge="dist/main.mjs";});var on,yi=k(()=>{g();on="window";});function Ai(e){if(!Array.isArray(e)||e.length===0)return false;let n=new Set;for(let t of e){if(!jr.some(i=>i===t)||n.has(t))return false;n.add(t);}return true}var jr,Ii=k(()=>{g();jr=["CREWX_APP_INSTANCE_ID","CREWX_THREAD_ID"];});function V(e){throw new mt(e)}function Kr(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 Yr(e,n){let t=Object.getOwnPropertyDescriptor(e,n);return (!t||!("value"in t))&&V("CSP_ORIGIN_INVALID"),t.value}function Sn(e,n){if(!Object.prototype.hasOwnProperty.call(e,n))return [];let t=Yr(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 qr(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 hi(e,n){/\s|\\/u.test(e)&&V("CSP_ORIGIN_INVALID");let t=Gr.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("[")?$r:Jr).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||!Wr.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 Zr(e){let n=e.split(".").map(Number);return ((n[0]*256+n[1])*256+n[2])*256+n[3]}function _i(e,n,t){let i=4294967295<<32-t>>>0;return (e&i)===(n&i)}function Di(e){let n=Zr(e);return _i(n,3221225472,24)?n!==3221225481&&n!==3221225482:Xr.some(([t,i])=>_i(n,t,i))}function Qr(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 es(e){let n=Qr(e),t=Number(n>>112n),i=Number(n>>96n&0xffffn);if(n>>32n===0xffffn){let r=Number(n&0xffffffffn);return Di([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 ns(e,n){let t=e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e,i=isIP(t);if(i===4)return Di(t);if(i===6)return es(t);let r=e.toLowerCase().replace(/\.$/,"");return !r||!r.includes(".")||n.has(r)?true:zr.some(o=>r===o||r.endsWith(`.${o}`))}function Ti(e){return Object.freeze([...new Set(e.map(n=>n.origin))].sort())}function Ei(e){return JSON.stringify({baseUriDomains:[],connectDomains:e.connectDomains,declared:e.declared,frameDomains:e.frameDomains,resourceDomains:[]})}function Ni(e,n={}){if(e===void 0){let A=Ei({declared:false,connectDomains:[],frameDomains:[]});return Object.freeze({declared:false,connectDomains:Object.freeze([]),frameDomains:Object.freeze([]),resourceDomains:Object.freeze([]),baseUriDomains:Object.freeze([]),cspHash:createHash("sha256").update(A,"utf8").digest("hex")})}Kr(e)||V("CSP_ORIGIN_INVALID");let t=Reflect.ownKeys(e);t.some(A=>typeof A!="string")&&V("CSP_ORIGIN_INVALID"),t.some(A=>!Hr.has(A))&&V("CSP_AXIS_UNKNOWN");let i=Sn(e,"connectDomains"),r=Sn(e,"frameDomains"),o=Sn(e,"resourceDomains"),a=Sn(e,"baseUriDomains");(o.length>0||a.length>0)&&V("CSP_AXIS_UNSUPPORTED"),(qr(e)>Vr||i.length>mi||r.length>mi||i.length+r.length>Fr||[...i,...r].some(A=>new TextEncoder().encode(A).byteLength>Br))&&V("CSP_LIMIT_EXCEEDED");let c=i.map(A=>hi(A,"connectDomains")),d=r.map(A=>hi(A,"frameDomains")),p=new Set((n.runtimeHostnames??[]).map(A=>A.toLowerCase().replace(/\.$/,"")));[...c,...d].some(A=>ns(A.hostname,p))&&V("CSP_ORIGIN_FORBIDDEN");let l={declared:true,connectDomains:Ti(c),frameDomains:Ti(d)},u=Ei(l);return Object.freeze({...l,resourceDomains:Object.freeze([]),baseUriDomains:Object.freeze([]),cspHash:createHash("sha256").update(u,"utf8").digest("hex")})}var Vr,mi,Fr,Br,Hr,zr,Gr,$r,Jr,Wr,Xr,mt,bi=k(()=>{g();Vr=4096,mi=16,Fr=32,Br=512,Hr=new Set(["connectDomains","frameDomains","resourceDomains","baseUriDomains"]),zr=["localhost","local","internal","home.arpa","test","example","invalid","onion","lan","corp","home","intranet","private","localdomain"],Gr=/^(https|wss):\/\/([^/?#]+)$/i,$r=/^\[[^\]]+\](?::[0-9]+)?$/,Jr=/^[^:\[\]]+(?::[0-9]+)?$/,Wr=/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/,Xr=[[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]],mt=class extends Error{constructor(t){super(t);this.code=t;}code;name="UiPluginCspNormalizationError"};});function sn(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 re(e,n,t,i)}function B(e,n){try{return n()}catch(t){throw t instanceof re?t.withPathPrefix(e):t}}function H(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 Ls(e,n){let t={};for(let[i,r]of Object.entries(e))i!==n&&(t[i]=r);return t}function J(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 Un(e,n=false,t=false,i=false){return rs.test(e)||!i&&as.test(e)||ss.test(e)||t&&Pi.test(e)||cs.test(e)&&!(n&&/^\s*data:/i.test(e)&&!Pi.test(e))}function Rn(e,n=new Set,t=0,i=false,r=false,o=""){if(typeof e=="string"){Un(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)=>Rn(a,n,t+1,!1,!1,sn(o,`[${s}]`)));return}H(e)||y("MANIFEST_INVALID","MANIFEST_INVALID",o);for(let[a,s]of Object.entries(e))Rn(s,n,t+1,i&&t===0&&(a==="name"||a==="description"),r,sn(o,a));}finally{n.delete(e);}}}function me(e,n){let t=e[n];return typeof t!="string"&&y("MANIFEST_INVALID"),t}function ue(e,n,t){let i=e[n];return (!Number.isSafeInteger(i)||i<t)&&y("MANIFEST_INVALID"),i}function ht(e){return os.test(e)||y("MANIFEST_INVALID"),e}function $e(e){return is.test(e)||y("TOKEN_INVALID"),e}function Os(e){return wi.test(e)||y("MANIFEST_INVALID"),e}function Rs(e){H(e)||y("MANIFEST_INVALID");let n={};for(let[t,i]of Object.entries(e)){let r=Os(t);H(i)||y("MANIFEST_INVALID");let o=i.type;if(o==="text"){J(i,["type","maxLength"]),n[r]={type:o,maxLength:ue(i,"maxLength",1)};continue}if(o==="text-list"){J(i,["type","max","itemMaxLength"]),n[r]={type:o,max:ue(i,"max",0),itemMaxLength:ue(i,"itemMaxLength",1)};continue}if(o==="step-list"){J(i,["type","min","max","labelMaxLength","detailMaxLength"]);let a=ue(i,"min",0),s=ue(i,"max",1);a>s&&y("MANIFEST_INVALID"),n[r]={type:o,min:a,max:s,labelMaxLength:ue(i,"labelMaxLength",1),detailMaxLength:ue(i,"detailMaxLength",1)};continue}typeof o=="string"&&y("SCHEMA_TYPE_UNSUPPORTED"),y("MANIFEST_INVALID");}return n}function Us(e,n,t){let i=e[n];(!i||i.type!==t)&&y("MANIFEST_INVALID");}function Ln(e,n,t){let i=me(e,"field");return wi.test(i)||y("MANIFEST_INVALID"),Us(n,i,t),i}function Cs(e,n){H(e)||y("MANIFEST_INVALID");let t=e.primitive;switch(typeof t!="string"&&y("MANIFEST_INVALID"),Ss.includes(t)||y("PRIMITIVE_UNKNOWN"),t){case "card-shell":return J(e,["primitive"]),{primitive:t};case "meta-banner":return J(e,["primitive","badgeToken","noticeToken"]),{primitive:t,badgeToken:$e(me(e,"badgeToken")),noticeToken:$e(me(e,"noticeToken"))};case "heading":return J(e,["primitive","field"]),{primitive:t,field:Ln(e,n,"text")};case "labeled-text":return J(e,["primitive","titleToken","field","variant"]),e.variant!=="callout"&&y("MANIFEST_INVALID"),{primitive:t,titleToken:$e(me(e,"titleToken")),field:Ln(e,n,"text"),variant:"callout"};case "step-flow":return J(e,["primitive","titleToken","field"]),{primitive:t,titleToken:$e(me(e,"titleToken")),field:Ln(e,n,"step-list")};case "text-list":{J(e,["primitive","titleToken","field"],["emptyToken","hideWhenEmpty"]);let i={primitive:t,titleToken:$e(me(e,"titleToken")),field:Ln(e,n,"text-list")};return U(e,"emptyToken")&&(i.emptyToken=$e(me(e,"emptyToken"))),U(e,"hideWhenEmpty")&&(typeof e.hideWhenEmpty!="boolean"&&y("MANIFEST_INVALID"),i.hideWhenEmpty=e.hideWhenEmpty),i}}return y("MANIFEST_INVALID")}function ks(e,n){return Array.isArray(e)||y("MANIFEST_INVALID"),e.map(t=>Cs(t,n))}function W(e="v2 manifest exceeds a contract limit",n,t){return y("LIMIT_EXCEEDED",e,n,t)}function le(e="initial state is not projection-safe"){return y("INITIAL_STATE_INVALID",e)}function Mi(e,n){return (typeof e!="string"||e.length===0||e.length>4096||e.trim().length===0||bs.test(e)||Ps.test(e))&&y("MANIFEST_INVALID",`${n} is invalid`),(Un(e,true,true)||ds.test(e)||ps.test(e)||ls.test(e))&&y("UNSAFE_VALUE",`${n} contains an unsafe value`),e}function _t(e,n){return (typeof e!="string"||!ge.test(e))&&y("MANIFEST_INVALID",`${n} is invalid`),e}function ws(e){return (typeof e!="string"||!at.test(e)||e==="*"||e==="all")&&y("MANIFEST_INVALID","action capability is invalid"),e}function xi(e){return (typeof e!="string"||!Ns.test(e))&&y("MANIFEST_INVALID","resource hash is invalid"),e}function Tt(e,n=new Set,t=0,i=""){if(typeof e=="string"){e.length>4096&&W("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&&W("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&&W("v2 manifest array is too long",i,"array-too-long"),e.forEach((r,o)=>Tt(r,n,t+1,sn(i,`[${o}]`)));return}H(e)||y("MANIFEST_INVALID","v2 manifest contains a non-plain object",i,"non-plain-object");for(let[r,o]of Object.entries(e))Tt(o,n,t+1,sn(i,r));}finally{n.delete(e);}}}function ji(e){return (typeof e!="string"||e.length>4096||!tn.test(e))&&(typeof e=="string"&&e.length>4096&&W("projection path is too long"),y("MANIFEST_INVALID","projection paths must be canonical exact paths")),e.split(".").some(t=>ze(t))&&y("MANIFEST_INVALID","projection paths cannot address reserved state keys"),e}function Et(e){H(e)||y("MANIFEST_INVALID","projection policy must be an object"),J(e,["allow"]),Array.isArray(e.allow)||y("MANIFEST_INVALID","projection allow must be an array"),e.allow.length>128&&W("projection allowlist is too long");let n=[],t=new Set;for(let i of e.allow){let r=ji(i);t.has(r)&&y("MANIFEST_INVALID","projection allowlist contains a duplicate path"),t.add(r),n.push(r);}return {allow:n}}function xs(e,n){if(e===void 0)return;Array.isArray(e)||y("MANIFEST_INVALID","dataPaths must be an array"),e.length>Ms&&W("dataPaths exceed the v2 limit");let t=[],i=new Set;for(let r of e){let o=ji(r);i.has(o)&&y("MANIFEST_INVALID","dataPaths contain a duplicate path"),n.some(a=>Be(o,a))||y("MANIFEST_INVALID","dataPaths must be projection-allowed"),i.add(o),t.push(o);}return t}function Je(e,n,t=Number.MAX_SAFE_INTEGER){return (!Number.isSafeInteger(e)||e<0||e>t)&&y("MANIFEST_INVALID",`${n} is invalid`),e}function Si(e,n){return (typeof e!="number"||!Number.isFinite(e))&&y("MANIFEST_INVALID",`${n} is invalid`),e}function Dt(e,n=0,t=new Set){if(typeof e=="string")return (e.length>4096||Un(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)&&W("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&&W("schema enum array is too long"),e.map(r=>Dt(r,n+1,t));H(e)||y("MANIFEST_INVALID","schema enum contains a non-plain object");let i={};for(let[r,o]of Object.entries(e))ze(r)&&y("MANIFEST_INVALID","schema enum contains a reserved key"),i[r]=Dt(o,n+1,t);return i}finally{t.delete(e);}}function js(e,n){if(e===void 0)return;Array.isArray(e)||y("MANIFEST_INVALID","schema required must be an array"),e.length>64&&W("schema required list is too long");let t=[],i=new Set;for(let r of e)(typeof r!="string"||!tn.test(r))&&y("MANIFEST_INVALID","schema required contains an invalid key"),r.length>4096&&W("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 vs(e,n){let t=n?tn:Pn;return e.length>4096&&W("schema property name is too long"),(!t.test(e)||e.split(".").some(i=>ze(i)))&&y("MANIFEST_INVALID","schema property name is invalid"),e}function Nt(e,n=0,t=false){H(e)||y("MANIFEST_INVALID","action inputSchema must be an object"),n>8&&W("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"),J(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&&W("schema enum is too long"),o.enum=e.enum.map(s=>Dt(s))),i==="string"&&(U(e,"minLength")&&(o.minLength=Je(e.minLength,"schema minLength",4096)),U(e,"maxLength")&&(o.maxLength=Je(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=Si(e.minimum,"schema minimum")),U(e,"maximum")&&(o.maximum=Si(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=Je(e.minItems,"schema minItems",128)),U(e,"maxItems")&&(o.maxItems=Je(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=Nt(e.items,n+1,false))),i==="object"){let s;if(U(e,"properties")){H(e.properties)||y("MANIFEST_INVALID","schema properties must be an object");let d=Object.entries(e.properties);d.length>64&&W("schema properties are too many"),s={};for(let[p,l]of d){let u=vs(p,t);s[u]=Nt(l,n+1,false);}o.properties=s;}U(e,"minProperties")&&(o.minProperties=Je(e.minProperties,"schema minProperties",64)),U(e,"maxProperties")&&(o.maxProperties=Je(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=js(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)&&W("action inputSchema subtree is too large"),o}function Vs(e){let n=Nt(e,0,true);return (n.type!=="object"||!n.properties)&&y("MANIFEST_INVALID","action inputSchema must declare object properties"),n}function Fs(e){if(H(e)||y("MANIFEST_INVALID","action backend must be an object"),e.type==="core"){J(e,ms);let n=e.handler;return (typeof n!="string"||!ct.test(n))&&y("MANIFEST_INVALID","core backend handler is invalid"),{type:"core",handler:n}}if(e.type==="skill"&&U(e,"entry"))return J(e,Ts),e.entry!==Ge&&y("MANIFEST_INVALID",`skill backend entry must be ${Ge}`),{type:"skill",entry:Ge};if(e.type==="skill"){J(e,hs,_s),(!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||!dt.test(i))&&y("MANIFEST_INVALID","skill backend command token is invalid"),n.push(i);let t=U(e,"env")?Hs(e.env):void 0;return {type:"skill",command:n,...t===void 0?{}:{env:t}}}y("MANIFEST_INVALID","action backend type is unsupported");}function Bs(e){H(e)||y("MANIFEST_INVALID","action must be an object"),J(e,As,Is),U(e,"_meta")&&B("_meta",()=>vi(e._meta));let n=B("actionId",()=>_t(e.actionId,"actionId"));ot(n)&&y("MANIFEST_INVALID",`actionId "${n}" is not projection-safe`,"actionId");let t=B("capability",()=>ws(e.capability)),i=e.mutation;typeof i!="boolean"&&y("MANIFEST_INVALID","action mutation must be boolean","mutation");let r=B("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=B("resultProjection",()=>Et(e.resultProjection)),s=B("backend",()=>Fs(e.backend)),c;U(e,"content")&&((s.type!=="skill"||!Mn(e.content))&&y("MANIFEST_INVALID","action content declaration is invalid","content"),c=zs(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 Hs(e){return Ai(e)||y("MANIFEST_INVALID","skill backend env is invalid"),Object.freeze([...e])}function zs(e){return Object.freeze({...e.in===void 0?{}:{in:Object.freeze({...e.in})},...e.out===void 0?{}:{out:Object.freeze({...e.out})}})}function Gs(e){return H(e)||y("INITIAL_STATE_INVALID","initialState must be an object"),J(e,Es,Ds),e.path!=="ui/state.json"&&y("MANIFEST_INVALID","initialState path is not fixed"),U(e,"hash")?{path:"ui/state.json",hash:xi(e.hash)}:{path:"ui/state.json"}}function $s(e){let n=["wasm","terminal","htmlDocuments"];return (!H(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 Js(e,n){let t;try{t=Ni(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 Ws(e,n){Rn(H(e)&&U(e,"csp")?Ls(e,"csp"):e,new Set,0,true,true),Tt(e),H(e)||y("MANIFEST_INVALID"),J(e,fs,ys),U(e,"_meta")&&B("_meta",()=>vi(e._meta)),e.manifestVersion!==2&&y("MANIFEST_INVALID");let t;U(e,"runtime")&&(t=B("runtime",()=>$s(e.runtime)));let i;U(e,"csp")&&(i=B("csp",()=>Js(e.csp,t)));let r=B("pluginId",()=>_t(e.pluginId,"pluginId")),o=B("definitionId",()=>_t(e.definitionId,"definitionId")),a=B("version",()=>ue(e,"version",1)),s=B("name",()=>Mi(e.name,"name")),c=B("description",()=>Mi(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"||!pt.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=B("entryHash",()=>xi(e.entryHash)));let u;U(e,"initialState")&&(u=B("initialState",()=>Gs(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??on)!==on||!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??on)===on&&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&&W("surfaces exceed the v2 limit","surfaces","too-many-items");let F=[],v=new Set;for(let f of e.surfaces)(typeof f!="string"||!lt.includes(f))&&y("MANIFEST_INVALID","surface is unsupported","surfaces"),v.has(f)&&y("MANIFEST_INVALID","surfaces contain a duplicate","surfaces","duplicate-item"),v.add(f),F.push(f);H(e.size)||y("MANIFEST_INVALID","size must be an object","size"),B("size",()=>J(e.size,["height"]));let P=B("size",()=>ue(e.size,"height",1));P>720&&W("size.height exceeds the v2 limit","size.height","too-large");let O=B("stateProjection",()=>Et(e.stateProjection)),z=e.summaryProjection===void 0?void 0:B("summaryProjection",()=>Et(e.summaryProjection));z!==void 0&&z.allow.some(f=>!O.allow.includes(f))&&y("MANIFEST_INVALID","summaryProjection must be a subset of stateProjection.allow","summaryProjection");let N=B("dataPaths",()=>xs(e.dataPaths,O.allow));Array.isArray(e.actions)||y("MANIFEST_INVALID","actions must be an array","actions"),e.actions.length>32&&W("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=B(T,()=>Bs(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:F,size:{height:P},stateProjection:O,...z===void 0?{}:{summaryProjection:z},...N===void 0?{}:{dataPaths:N},actions:L}}function vi(e){H(e)||y("MANIFEST_INVALID","_meta must be an object");let n=JSON.stringify(e);(n===void 0||Buffer.byteLength(n,"utf8")>gs)&&W("_meta exceeds the 4 KiB limit",void 0,"meta-too-large");}function Xs(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 bt(e,n,t,i,r,o){if(typeof e=="string"){let a=r.length>0&&o.some(s=>Be(r.join("."),s));return (e.length>4096||Un(e,false,false,a))&&le("state contains an unsafe string"),e}if(e===null||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)||le("state contains a non-finite number"),e;(e===void 0||typeof e!="object"||typeof e=="function"||typeof e=="bigint")&&le("state contains a non-JSON value"),t>8&&le("state is too deep"),n.has(e)&&le("state contains a cycle"),n.add(e);try{let a;if(Array.isArray(e))e.length>128&&le("state array is too long"),a=e.map(c=>bt(c,n,t+1,2097152,r,o));else {H(e)||le("state contains a non-plain object");let c={};for(let[d,p]of Object.entries(e))(d.length>4096||!Pn.test(d)||ze(d))&&(d.length>4096&&le("state key is too long"),le("state contains a reserved or invalid key")),c[d]=bt(p,n,t+1,2097152,[...r,d],o);a=c;}let s=JSON.stringify(a);return (s===void 0||Buffer.byteLength(s,"utf8")>i)&&le("state subtree is too large"),a}finally{n.delete(e);}}function Mt(e,n=[]){H(e)||le("initial state must be a JSON object");let t=bt(e,new Set,0,2097152,[],n);return (t===null||Array.isArray(t)||typeof t!="object")&&le(),t}function Ks(e,n={}){Rn(e),H(e)||y("MANIFEST_INVALID"),J(e,us),e.manifestVersion!==1&&y("MANIFEST_INVALID");let t=ht(me(e,"pluginId")),i=ht(me(e,"definitionId")),r=ue(e,"version",1),o=ue(e,"primitiveSet",1),a=n.supportedPrimitiveSet??ts;(!Number.isSafeInteger(a)||a<1)&&y("MANIFEST_INVALID"),o>a&&y("PRIMITIVE_SET_UNSUPPORTED"),H(e.activation)||y("MANIFEST_INVALID"),J(e.activation,["kind","language"]),e.activation.kind!=="fenced-code"&&y("MANIFEST_INVALID");let s=ht(me(e.activation,"language")),c=Rs(e.schema),d=ks(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 Ys(e,n={}){return H(e)||y("MANIFEST_INVALID"),Object.hasOwn(e,"lineage")&&y("MANIFEST_INVALID","lineage is only allowed in product bundle indexes"),e.manifestVersion===2?Ws(e,n):Ks(e,n)}function an(e,n={}){try{return Ys(e,n)}catch(t){if(t instanceof re)throw t;return y("MANIFEST_INVALID")}}function cn(e,n={}){let t=an(e,n);return t.manifestVersion===2?Xs(t):t}var ts,is,os,wi,rs,ss,as,cs,Pi,ds,ps,ls,us,fs,ys,As,Is,gs,ms,hs,_s,Ts,Es,Ds,Ns,bs,Ps,Ms,Ss,re,St=k(()=>{g();yi();Ne();yt();Ii();gt();bi();Ue();ts=1,is=/^[a-z][a-zA-Z0-9]*(\.[a-zA-Z0-9]+)+$/,os=/^[A-Za-z][A-Za-z0-9._-]{0,127}$/,wi=/^[A-Za-z][A-Za-z0-9_-]{0,63}$/,rs=/<\/?[A-Za-z][^>]*>/,ss=/^(?:[A-Za-z]:[\\/]|\\\\|~[\\/]|\/)/,as=/^(?:https?|file|ftp|ws|wss):\/\//i,cs=/^\s*(?:javascript|data):/i,Pi=/data:[^,\s]*,/i,ds=/(?:https?|file|ftp|ws|wss):\/\//i,ps=/javascript:/i,ls=/(?:^[\s]*|[\s"'(=])(?:[A-Za-z]:[\\/]|\\\\|~[\\/]|\/)(?=[^\s"'<>])[^\s"'<>]*/,us=["manifestVersion","pluginId","definitionId","version","primitiveSet","activation","schema","layout"],fs=["manifestVersion","pluginId","definitionId","version","name","description","entry","surfaces","size","stateProjection","actions"],ys=["_meta","icon","tone","entryHash","runtime","csp","initialState","usage","detailPanel","displayModes","summaryProjection","dataPaths","focusedAiDataPaths"],As=["actionId","capability","mutation","inputSchema","resultProjection","backend"],Is=["confirmation","dataInputs","content","_meta"],gs=4*1024,ms=["type","handler"],hs=["type","command"],_s=["env"],Ts=["type","entry"],Es=["path"],Ds=["hash"],Ns=/^[0-9a-f]{64}$/,bs=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/,Ps=/[\r\n]/,Ms=16,Ss=["card-shell","meta-banner","heading","labeled-text","step-flow","text-list"],re=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,sn(t,this.path),this.rule)}};});function Gi(e){return typeof e=="string"&&e.length<=Zs&&qs.test(e)}function C(e,n,t,i,r){throw new _e(e,{path:n,rule:t,...i===void 0?{}:{message:i},...r===void 0?{}:{file:r}})}function Q(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 X(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function ye(e){let n=`_meta["${Se}"]`;return e===void 0||e===""?n:e.startsWith("[")?`${n}${e}`:`${n}.${e}`}function ta(e){return e.toLowerCase().replace(/_/g,"-")}function ia(e){if(e===void 0||e==="")return "";let n=/^([^.[]+)(.*)$/.exec(e);if(!n)return ye(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 ye("definitionVersion");case "definitionId":return ye("definitionId");default:return ye(`${t}${i}`)}}function $i(e,n,t){return {path:t(e.path),rule:e.rule??ta(e.code),...e.message!==e.code?{message:e.message}:{},file:n}}function Ji(e){return JSON.parse(JSON.stringify(e))}function Rt(e,n,t=0,i=new Set){if(typeof e=="string"){e.length>4096&&C("LIMIT_EXCEEDED",n,"string-too-long"),(Qs.test(e)||ea.test(e)||na.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)=>Rt(r,`${n}[${o}]`,t+1,i));return}Q(e)||C("MANIFEST_INVALID",n,"non-plain-object");for(let[r,o]of Object.entries(e))Rt(o,n===""?r:`${n}.${r}`,t+1,i);}finally{i.delete(e);}}}function fe(e,n){return (typeof e!="string"||e.length===0)&&C("MANIFEST_INVALID",n,"string"),e}function Xe(e,n){return Q(e)||C("MANIFEST_INVALID",n,"object"),e}function oa(e,n){Array.isArray(e)||C("MANIFEST_INVALID",n,"array"),e.forEach((t,i)=>fe(t,`${n}[${i}]`));}function ra(e,n){typeof e!="boolean"&&C("MANIFEST_INVALID",n,"boolean");}function dn(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)X(e,r)||C("MANIFEST_INVALID",`${n}.${r}`,"missing-key");}function sa(e,n){switch(Rt(n,e),e){case "long_description":case "homepage":case "documentation":case "support":case "icon":case "license":fe(n,e);return;case "author":{let t=Xe(n,e);dn(t,e,["name"],["email","url"]);for(let i of Object.keys(t))fe(t[i],`${e}.${i}`);return}case "repository":{let t=Xe(n,e);dn(t,e,[],["type","url"]);for(let i of Object.keys(t))fe(t[i],`${e}.${i}`);return}case "icons":{Array.isArray(n)||C("MANIFEST_INVALID",e,"array"),n.forEach((t,i)=>{let r=`${e}[${i}]`,o=Xe(t,r);dn(o,r,["src","size"],["theme"]),fe(o.src,`${r}.src`),fe(o.size,`${r}.size`),X(o,"theme")&&fe(o.theme,`${r}.theme`);});return}case "screenshots":case "keywords":case "privacy_policies":oa(n,e);return;case "tools":{Array.isArray(n)||C("MANIFEST_INVALID",e,"array"),n.forEach((t,i)=>{let r=`${e}[${i}]`,o=Xe(t,r);dn(o,r,["name"],["description"]),fe(o.name,`${r}.name`),X(o,"description")&&fe(o.description,`${r}.description`);});return}case "prompts":{Array.isArray(n)||C("MANIFEST_INVALID",e,"array"),n.forEach((t,i)=>{let r=`${e}[${i}]`,o=Xe(t,r);dn(o,r,["name","text"],["description","arguments"]),fe(o.name,`${r}.name`),fe(o.text,`${r}.text`);});return}case "tools_generated":case "prompts_generated":ra(n,e);return;case "localization":case "compatibility":case "user_config":Xe(n,e);return;default:C("MANIFEST_INVALID",e,"unknown-key");}}function Cn(e){return typeof e=="string"&&ge.test(e)?e:void 0}function Wi(e){return Number.isSafeInteger(e)&&e>=1?e:void 0}function aa(e){let n=Cn(e.name);if(n===void 0)return;let t=e._meta,i=Q(t)?t[Se]:void 0,r=Q(i)?i:{},o=X(r,"definitionId")?Cn(r.definitionId):n,a=X(r,"definitionVersion")?Wi(r.definitionVersion):1;return {pluginId:n,...o===void 0?{}:{definitionId:o},...a===void 0?{}:{definitionVersion:a}}}function ca(e){let n=Cn(e.pluginId);if(n===void 0)return;let t=Cn(e.definitionId),i=Wi(e.version);return {pluginId:n,...t===void 0?{}:{definitionId:t},...i===void 0?{}:{definitionVersion:i}}}function wt(e){try{let n=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e));if(!Q(n))return !1;let t=n._meta;return Q(t)&&X(t,Se)}catch{return false}}function da(e,n){if(e===we)return n.builtinOnly===true;let t=n._meta,i=Q(t)?t[Se]:void 0;return Q(i)&&i.builtinOnly===true}function pa(e,n){X(e,"server")&&C("MANIFEST_INVALID","server","server-unsupported","phase 1 runs CrewX-owned Apps only");for(let s of Object.keys(e))Ct.includes(s)||C("MANIFEST_INVALID",s,"unknown-key");for(let s of kt)X(e,s)||C("MANIFEST_INVALID",s,"missing-key");e.manifest_version!==Lt&&C("MANIFEST_INVALID","manifest_version","unsupported-version",`manifest_version must be "${Lt}"`),Gi(e.version)||C("MANIFEST_INVALID","version","semver","version must be a semver.org version such as 0.1.0");let t=e._meta;Q(t)||C("MANIFEST_INVALID","_meta","object"),X(t,Se)||C("MANIFEST_INVALID",ye(),"missing-key");let i=t[Se];Q(i)||C("MANIFEST_INVALID",ye(),"object");for(let s of Object.keys(i))Ot.includes(s)||zi.includes(s)||C("MANIFEST_INVALID",ye(s),"unknown-key");for(let s of Ot)s==="actions"&&n!==void 0||X(i,s)||C("MANIFEST_INVALID",ye(s),"missing-key");if(n!==void 0&&X(i,"actions")&&C("MANIFEST_INVALID",ye("actions"),"two-truths",`actions are declared in both ${K} and ${Y}; a server.ts App keeps them in the tools file only`),la(i.actions),X(i,"definitionVersion")){let s=i.definitionVersion;(!Number.isSafeInteger(s)||s<1)&&C("MANIFEST_INVALID",ye("definitionVersion"),"positive-integer");}let r={};for(let s of Hi)X(e,s)&&(sa(s,e[s]),r[s]=Ji(e[s]));let o={};for(let[s,c]of Object.entries(t))s!==Se&&(o[s]=c);let a={manifestVersion:2,pluginId:e.name,definitionId:X(i,"definitionId")?i.definitionId:e.name,version:X(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:Ge}}))),Object.keys(o).length>0&&(a._meta=o),{v2Input:a,...Object.keys(o).length>0?{vendorMeta:o}:{},passthrough:r}}function la(e){Array.isArray(e)&&e.forEach((n,t)=>{let i=Q(n)?n.backend:void 0;Q(i)&&X(i,"entry")&&C("MANIFEST_INVALID",ye(`actions[${t}].backend.entry`),"entry-not-authorable",`an action in ${K} cannot name an entry; a server.ts App declares its actions in ${Y}`);});}function ua(e,n,t){Q(e)||C("MANIFEST_INVALID","","not-object","manifest.json must be a JSON object",K);let i;try{i=pa(e,t);}catch(a){throw a instanceof _e?new _e(a.code,{...a.reason,file:K}):a}let r;try{let a=an(i.v2Input,{mode:n.mode??"local"});a.manifestVersion!==2&&C("MANIFEST_INVALID","","v2-required"),r=a;}catch(a){throw a instanceof re?new _e(a.code,$i(a,K,ia)):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 _e("MANIFEST_INVALID",{path:`tools[${c}].name`,rule:"tool-not-action",message:"every tools[].name must be an action id",file:K})});}return {file:K,manifest:r,v2Input:i.v2Input,releaseVersion:e.version,...Object.keys(i.passthrough).length>0?{mcpb:i.passthrough}:{}}}function fa(e,n){try{let t=an(e,{mode:n.mode??"local"});if(t.manifestVersion!==2)throw new _e("MANIFEST_INVALID",{path:"manifestVersion",rule:"v2-required",message:"a workspace App requires manifestVersion 2",file:we});return {file:we,manifest:t,v2Input:e}}catch(t){throw t instanceof re?new _e(t.code,$i(t,we,i=>i??"")):t}}function Ut(e){return oe(cn(e).definition)}function Fi(e){let{entryHash:n,initialState:t,...i}=e,r={...i};return t!==void 0&&(r.initialState={path:t.path}),Ji(r)}function ya(e,n){let t=Fi(e),i=Fi(n);return [...new Set([...Object.keys(t),...Object.keys(i)])].sort().filter(o=>Z(t[o]??null)!==Z(i[o]??null))}function Aa(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 Ia(e,n){let t=ya(e,n),i=Aa(e,n),r="";try{let o=Ut(e),a=Ut(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",`${K} and ${we} normalize to different definitions${r}`+(t.length>0?`; differing fields: ${t.join(", ")}`:""));}function he(e,n,t="MANIFEST_INVALID",i){return {code:t,reason:{path:e,rule:n,...i===void 0?{}:{message:i},file:Y},files:[]}}function Bi(e){return {...he("","tools-needs-manifest-json","MANIFEST_INVALID",`${Y} is read with ${K} only`),files:e}}function ga(e,n){if(e.byteLength>n)return {failure:he("","file-too-large","LIMIT_EXCEEDED")};let t;try{t=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e));}catch{return {failure:he("","invalid-json")}}if(!Q(t))return {failure:he("","not-object","MANIFEST_INVALID",`${Y} must be a JSON object`)};for(let r of Object.keys(t))if(r!=="schemaVersion"&&r!=="actions")return {failure:he(r,"unknown-key")};for(let r of ["schemaVersion","actions"])if(!X(t,r))return {failure:he(r,"missing-key")};if(t.schemaVersion!==1)return {failure:he("schemaVersion","unsupported-version","MANIFEST_INVALID",`schemaVersion must be ${1}`)};let i=t.actions;if(!Array.isArray(i))return {failure:he("actions","array")};for(let[r,o]of i.entries()){if(!Q(o))return {failure:he(`actions[${r}]`,"object")};if(X(o,"backend"))return {failure:he(`actions[${r}].backend`,"tools-backend","MANIFEST_INVALID",`an action in ${Y} cannot carry a backend`)}}return {actions:i}}function ma(e,n){let t=n.maxBytes??262144,i=[],r=new TextDecoder("utf-8",{fatal:true});for(let o of se){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(!Q(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 xt(e,n={}){let{parsed:t,failure:i}=ma(e,n),r=se.filter(A=>e[A]!==void 0);if(i!==void 0)return {ok:false,rejection:i,parseFailure:true,builtinOnly:false};let o=e[Y],a=o===void 0?void 0:ga(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:[]}:Bi(r),parseFailure:true,builtinOnly:false};let s=t[0],c=s.file===K?aa(s.raw):ca(s.raw),d=t.some(A=>da(A.file,A.raw)),p;if(a!==void 0){let A=t.some(I=>I.file===K)?a.failure:Bi(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===K?ua(A.raw,n,p):fa(A.raw,n));l.length===2&&Ia(l[0].manifest,l[1].manifest);}catch(A){if(A instanceof _e)return {ok:false,rejection:{code:A.code,reason:A.reason,files:A.code==="MANIFEST_DUAL_MISMATCH"?[...se]:A.reason.file===void 0||A.reason.file===Y?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 K,we,se,Lt,Se,Ct,kt,Hi,Ot,zi,qs,Zs,Qs,ea,na,_e,jt=k(()=>{g();Ce();Ne();gt();Ue();St();K="manifest.json",we="ui-plugin.json",se=[K,we],Lt="0.3",Se="dev.crewx",Ct=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"]),kt=Object.freeze(["manifest_version","name","display_name","version","description","_meta"]),Hi=Object.freeze(Ct.filter(e=>e!=="server"&&!kt.includes(e))),Ot=Object.freeze(["entry","surfaces","size","stateProjection","actions"]),zi=Object.freeze(["definitionId","definitionVersion","icon","tone","entryHash","runtime","initialState","usage","detailPanel","displayModes","summaryProjection","dataPaths","focusedAiDataPaths","csp"]),qs=/^(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-]+)*))?$/,Zs=256,Qs=/<\/?[A-Za-z][^>]*>/,ea=/^\s*javascript:/i,na=/data:[^,\s]*,/i;_e=class extends Error{constructor(t,i){super(`${t}: ${i.path||"<file>"} (${i.rule})`);this.code=t;this.reason=i;}code;reason};});var Xi=k(()=>{g();fi();jt();St();Ue();});function E(e,n=e){throw new Te(e,n)}var Te,wn=k(()=>{g();Te=class extends Error{constructor(t,i=t){super(i);this.code=t;}code;name="McpAppContractError"};});var Ki=k(()=>{g();});var Yi=k(()=>{g();Ce();Ne();wn();Ki();});function Zi(e,n){return qi.add(e),n!==void 0&&ha.set(e,n),e}function Ke(e){return e!==null&&typeof e=="object"&&qi.has(e)}var qi,ha,xn=k(()=>{g();qi=new WeakSet,ha=new WeakMap;});function un(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function vt(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 no(e){if(e===null||typeof e!="object"||Object.isFrozen(e))return e;for(let n of Object.values(e))no(n);return Object.freeze(e)}function ee(e){throw new Ee("LINEAGE_INVALID",e)}function Pa(e){throw new Ee("LINEAGE_STALE",e)}function to(e){if(!un(e)||!vt(e,Ea,Da)||!un(e.actions))return ee("Lineage definition shape is invalid");for(let n of Object.values(e.actions))if(!un(n)||!vt(n,Na,ba))return ee("Lineage action definition shape is invalid");return e}function Ma(e){if(!un(e)||!vt(e,_a,Ta))return ee("Lineage entry shape is invalid");if(!Number.isSafeInteger(e.version)||e.version<1||typeof e.hash!="string"||!Qi.test(e.hash))return ee("Lineage entry identity is invalid");if(e.sourceHash!==void 0&&(typeof e.sourceHash!="string"||!Qi.test(e.sourceHash)))return ee("Lineage source hash is invalid");if(e.compat!==void 0&&e.compat!=="break")return ee("Lineage compatibility marker is invalid");let n=to(e.definition);if(n.version!==e.version)return ee("Lineage version does not match its definition");if(e.sourceHash!==void 0&&n.sourceHash!==e.sourceHash)return ee("Lineage source hash does not match its definition");let t;try{t=oe(n),pe({...n,hash:e.hash});}catch{return ee("Lineage definition is invalid")}return t!==e.hash?ee("Lineage definition hash does not match"):no({version:e.version,hash:e.hash,definition:n,...e.sourceHash===void 0?{}:{sourceHash:e.sourceHash},...e.compat===void 0?{}:{compat:e.compat}})}function eo(e){return e.stateProjection?.allow??[]}function Sa(e,n){let t=[],i=new Set(eo(n));eo(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 La(e,n){return Z(e)===Z(n)}function Vt(e,n){if(!Array.isArray(e)||e.length===0)return ee("Definition lineage is missing");if(!un(n)||typeof n.hash!="string")return ee("Current definition is invalid");let t,i;try{let{hash:s,...c}=n;i=to(c),t={...i,hash:s},pe(t);}catch{return ee("Current definition is invalid")}let r=e.map(Ma),o=r[0].definition.id;if(r.some(s=>s.definition.id!==o))return ee("Lineage definition ids do not match");if(r.some((s,c)=>c>0&&s.version<=r[c-1].version))return ee("Lineage generations are not in increasing version order");if(r.some((s,c)=>r.findIndex(d=>d.hash===s.hash)!==c))return ee("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||!La(a.definition,i))return Pa("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 Ee("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=Sa(r[s].definition,t);if(d.length>0)throw new Ee("LINEAGE_INVALID",`Lineage compatibility failed: ${d.join(", ")}`,d)}return Object.freeze({entries:Object.freeze(r),current:t})}var Ee,Qi,_a,Ta,Ea,Da,Na,ba,Ft=k(()=>{g();Ce();Ne();Ee=class extends Error{constructor(t,i=t,r=[]){super(i);this.code=t;this.violations=r;}code;violations;name="UiDefinitionLineageError"},Qi=/^[0-9a-f]{64}$/,_a=["version","hash","definition"],Ta=["sourceHash","compat"],Ea=["id","version","actions"],Da=["sourceHash","usage","detailPanel","displayModes","renderer","surfaces","stateProjection","dataPaths","summaryProjection","legacy"],Na=["capabilities"],ba=["inputKeys","dataInputs","confirmation","resultProjection","content","env"];});var io,oo,ro,so,ao=k(()=>{g();io="text/html;profile=mcp-app",oo=["crewx_app_terminal_connect","crewx_app_html_viewer_open"],ro=["crewx_listWorkspaces","crewx_queryAgent","crewx_executeAgent","crewx_getTaskResult","crewx_listTasks","crewx_listAgents","callBrowser","openTab","listTabs","closeTab"],so="text/html";});function fn(e){return typeof e=="string"&&Oa.includes(e)}function jn(e,n){return e==="card"&&n?.type==="core"&&fn(n.handler)}var Oa,vn=k(()=>{g();Oa=Object.freeze(["card.secret-env"]);});function co(e,n=[],t){if(e.content!==void 0||e.confirmation!=="none")return "denied";let i=Ra();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"&&fn(e.backend.handler)||e.backend?.type==="skill"?"approval_required":e.backend===void 0&&n.includes(e.actionId)?"allowed":"denied"}function Ra(e){return;}var po=k(()=>{g();Ce();xn();vn();});function Fa(e){return In.has(e)&&(e.initialState===void 0||In.has(e.initialState))}function Ao(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:so,entryHash:e,html:n,bytes:Object.freeze(t),...r===void 0?{}:{initialState:r}});return r!==void 0&&In.add(r),In.add(o),o}function Ba(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:Oe}),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:Oe}),n}function Re(e,n,t){return (typeof e!="string"||!fo.test(e))&&E(n,`${t} must be a safe identifier`),e}function yn(e,n,t){let i=e??t;return (typeof i!="string"||i.trim().length===0||i.length>ka)&&E("TOOL_INVALID",`${n} must be a meaningful description`),i}function Ht(e){return (typeof e!="string"||e.length===0||e.length>Ye||!/<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 An(e,n=0){try{let t=de(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 Te)throw t;E("TOOL_INVALID","MCP App inputSchema must be projection-safe JSON");}}function Ha(e){return (typeof e!="string"||e.trim().length===0||e.length>wa)&&E("TOOL_INVALID","MCP App tools require a meaningful text fallback"),e}function za(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 go(e){return (typeof e!="string"||!yo.test(e))&&E("RESOURCE_URI_INVALID","MCP App resource URI is not a registered ui:// URI"),e}function mo(e){let n=Re(e.appId,"APP_ID_INVALID","Local App id"),t=yn(e.name,"Local App name",n),i=yn(e.description,"Local App description",`${t} interactive view`),r=Hn(e.definition),o=Ht(e.html),a=Vn(e.entryHash,"Local App entry hash"),s=e.entryBytes===void 0?Array.from(new TextEncoder().encode(o)):Bn(e.entryBytes,"Local App entry bytes");(Fn(s)!==a||To(s)!==o)&&E("HTML_INVALID","Local App entry bytes do not match the HTML hash");let c=Ga(e),d=[];Array.isArray(e.actions)||E("TOOL_INVALID","Local App actions must be an array");for(let P of e.actions){let O=Re(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=Re(e.readToolName,"TOOL_ID_INVALID","Local App read tool name"),l=e.actionToolName===void 0?void 0:Re(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=Ba(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:Oe},I=[Object.freeze(A)];if(I.push(...u.map(P=>Object.freeze(P))),l!==void 0){let P={name:l,description:`${t} actions`,inputSchema:zt(e.actions),textFallback:`${t} action requests are handled by the open App instance.`,visibility:Object.freeze(["app"]),kind:"action",resourceBinding:Oe,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||!fo.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 z=co({actionId:P.actionId,confirmation:r.actions[P.actionId]?.confirmation,content:r.actions[P.actionId]?.content,backend:P.backend},e.modelActions),N=Object.freeze([...Ka(z,r.usage,P.backend)]),L={name:O,description:`${O} action`,inputSchema:An(P.inputSchema),textFallback:`${O} action requests are handled by the open App instance.`,visibility:N,kind:"action",resourceBinding:Oe,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 F=Ao(a,o,s,c===void 0?void 0:{hash:c.hash,bytes:[...c.bytes]}),v={appId:n,name:t,description:i,...e.icon===void 0?{}:{icon:Eo(e.icon)},...e.tone===void 0?{}:{tone:Do(e.tone)},builtinOnly:false,definition:r,...e.runtime===void 0?{}:{runtime:Object.freeze({...e.runtime})},resourceBinding:Oe,resource:F,tools:Object.freeze(I),toolDiagnostics:Object.freeze(h)};return q(v)}function ho(e={}){return new Bt(e)}function zt(e){if(e.length===0)return An({type:"object",properties:{},additionalProperties:false});let n=e.map(i=>i.actionId),t=new Map;for(let i of e)t.set(i.actionId,An(i.inputSchema));return An($a(n,t),Io)}function Ga(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&&de(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=Bn(e.initialStateBytes,"Initial state bytes");Fn(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=de(JSON.parse(o),0,n);}catch{E("STATE_INVALID","Initial state bytes are not projection-safe JSON");}return e.initialState!==void 0&&Z(r)!==Z(de(e.initialState,0,n))&&E("STATE_INVALID","Initial state bytes do not match the state value"),{hash:t,bytes:Object.freeze([...i])}}function $a(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 Ja(e){let n=gn(e),t=Re(n.appId,"APP_ID_INVALID","MCP App id"),i=Ht(n.html);go(n.uiUri);let r=n.definition===void 0?void 0:Hn(n.definition),o=e.provenance;o!==void 0&&(!Ke(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=>q(gn(d)))),s=q({...n,appId:t,html:i,...r===void 0?{}:{definition:r},...o===void 0?{}:{provenance:o},tools:a}),c=q({uri:s.uiUri,mimeType:io,text:i,...s.csp===void 0?{}:{_meta:{ui:{csp:s.csp}}}});return q({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 Wa(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=Re(e.appId,"APP_ID_INVALID","Local App id"),t=Hn(e.definition),i=e.provenance;i!==void 0&&(!Ke(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=Xa(e.resource),o=e.tools.map(s=>{Re(s.name,"TOOL_ID_INVALID","Local App tool name"),yn(s.description,"Local App tool description","Local App tool"),Ha(s.textFallback);let c=An(s.inputSchema,s.kind==="action"&&!("actionId"in s)?Io: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 (!va.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"),q({...s,inputSchema:c,visibility:Object.freeze(["app"])});if(s.kind==="action"){if("actionId"in s){let p=Re(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=za(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"),q({...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"),q({...s,inputSchema:c,actionIds:Object.freeze(d)})}return q({...s,inputSchema:c})}),a=q({appId:n,name:yn(e.name,"Local App name",e.appId),description:yn(e.description,"Local App description",e.name),...e.icon===void 0?{}:{icon:Eo(e.icon)},...e.tone===void 0?{}:{tone:Do(e.tone)},builtinOnly:false,definition:t,...e.runtime===void 0?{}:{runtime:Object.freeze({...e.runtime})},...i===void 0?{}:{provenance:i},resourceBinding:Oe,resource:r,tools:Object.freeze(o),toolDiagnostics:Object.freeze([...e.toolDiagnostics??[]])});return lo.has(e)?e:(lo.add(a),a)}function Xa(e){let n=Ht(e.html),t=Vn(e.entryHash,"Local App entry hash");if(Fa(e))return e;let i=Bn(e.bytes,"Local App entry bytes");(Fn(i)!==t||To(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:Bn(e.initialState.bytes,"Initial state bytes")};return r&&Fn(r.bytes)!==r.hash&&E("STATE_INVALID","Initial state bytes do not match the hash"),Ao(t,n,i,r)}function Ka(e,n,t){if(jn(n,t))return ["model"];let i=t?.type==="core"&&fn(t.handler);return e==="denied"||i?["app"]:["model","app"]}function Ya(e){return q({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:_o(e.definition),...e.provenance===void 0?{}:{provenance:e.provenance},entryHash:e.resource.entryHash,resourceBinding:Oe,tools:e.tools})}function qa(e){return q({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:_o(e.definition)},resourceBinding:Object.freeze({kind:"mcp",uri:e.uiUri}),tools:e.tools})}function Hn(e){try{if(Object.isFrozen(e))return pe(e),q(e);let n=gn(e);return pe(n),q(n)}catch(n){if(n instanceof Te)throw n;E("STATE_INVALID","UI definition is not a valid immutable definition");}}function _o(e){return q({id:e.id,version:e.version,hash:e.hash})}function Za(e){return e!==null&&typeof e=="object"&&typeof e.id=="string"&&Number.isSafeInteger(e.version)&&typeof e.hash=="string"}function uo(e,n,t){return `${e}\0${n}\0${t}`}function Vn(e,n){return (typeof e!="string"||!Ca.test(e))&&E("SERIALIZATION_INVALID",`${n} is invalid`),e}function Fn(e){return createHash("sha256").update(Uint8Array.from(e)).digest("hex")}function Bn(e,n){return (!Array.isArray(e)||e.some(t=>!Number.isInteger(t)||t<0||t>255))&&E("SERIALIZATION_INVALID",`${n} is invalid`),[...e]}function To(e){try{return new TextDecoder("utf-8",{fatal:!0}).decode(Uint8Array.from(e))}catch{E("SERIALIZATION_INVALID","UTF-8 bytes are invalid");}}function Eo(e){return (typeof e!="string"||!xa.test(e))&&E("TOOL_INVALID","MCP App icon is invalid"),e}function Do(e){return (typeof e!="string"||!ja.has(e))&&E("TOOL_INVALID","MCP App tone is invalid"),e}function gn(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(gn(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:gn(a,n),writable:true});return n.delete(t),r}function q(e,n=new Set){if(e===null||typeof e!="object"||n.has(e)||In.has(e))return e;n.add(e);for(let t of Object.values(e))q(t,n);return Object.freeze(e),e}var fo,yo,Ca,Ye,ka,wa,xa,ja,va,Oe,Va,In,lo,Io,Bt,zn=k(()=>{g();Yi();Ce();Ne();xn();wn();Ft();ao();po();vn();fo=/^[A-Za-z][A-Za-z0-9._-]{0,127}$/,yo=/^ui:\/\/crewx\/([A-Za-z][A-Za-z0-9._-]{0,127})\/([0-9a-f]{12})$/,Ca=/^[0-9a-f]{64}$/,Ye=8*1024*1024,ka=8*1024,wa=16*1024,xa=/^[a-z][a-z0-9-]{0,63}$/,ja=new Set(["blue","violet","emerald","amber","rose","sky","slate","indigo"]),va=new Set(oo),new Set(ro),Oe=Object.freeze({kind:"instance"}),Va=Object.freeze({type:"object",properties:Object.freeze({}),additionalProperties:false}),In=new WeakSet,lo=new WeakSet;Io=4;Bt=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=Ja(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(Wa),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=q({...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,qa(l)),l.definition&&this.addDefinition(l.definition);for(let l of p)this.registrationById.set(l.appId,l),this.launcherById.set(l.appId,Ya(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"||!yo.test(n)?null:this.mcpResources.get(n)??null}requireMcpAppResource(n){go(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=Ke(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(!Za(n))return null;let t=this.definitionByKey.get(It(n));if(!t||t.hash!==n.hash)return null;try{return oe(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(uo(n,t,i))??null}addDefinition(n){let t=Hn(n),i=It(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=uo(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 Qa(e){let n=mo({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 No(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=Qa(e);ho({localApps:[t],definitions:[e.definition]});}var bo=k(()=>{g();zn();});function Po(){return Object.freeze({[Gt]:{candidates:new Map,assetCatalogs:new Map,preparedCandidates:new Map}})}function ec(e){if(e===null||typeof e!="object"||!(Gt in e))throw new TypeError("scanCache must be created by createWorkspaceAppScanCache");return e[Gt]}function Mo(e,n){let t=ec(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 Gt,So=k(()=>{g();Gt=Symbol("crewx.workspace-app-scan-cache.state");});function ae(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 oc(e){if(typeof e!="string"||e.length===0||!isAbsolute(e))throw new _("READ_DENIED")}function $t(e){if(typeof e!="string"||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 Wn(e,n){let t=relative(e,n);return t===""||t!==".."&&!t.startsWith(`..${sep}`)&&!isAbsolute(t)}function Ze(e){return {dev:e.dev,ino:e.ino,size:e.size,mtimeNs:e.mtimeNs,ctimeNs:e.ctimeNs}}function Kt(e,n){return e.dev===n.dev&&e.ino===n.ino}function Yt(e,n){return Kt(e,n)&&e.size===n.size&&e.mtimeNs===n.mtimeNs&&e.ctimeNs===n.ctimeNs}async function Gn(e){oc(e);let n,t;try{n=await realpath(e),t=await stat(n,{bigint:!0});}catch(i){throw ae(i)}if(!t.isDirectory())throw new _("READ_DENIED");return {realRoot:n,identity:Ze(t)}}async function Ro(e,n,t){if(t.length<2||t[0]!=="apps"&&t[0]!=="skills")return;let i,r;try{if(i=resolve(e,t[0],t[1]),r=await realpath(i),!(await stat(r,{bigint:!0})).isDirectory())throw new _("READ_DENIED")}catch(o){throw o instanceof _?o:ae(o)}if(!Wn(n,r))throw new _("PATH_ESCAPED");return r}async function $n(e,n,t,i){let r,o,a;try{r=await lstat(e,{bigint:!0}),o=await realpath(e),a=await stat(o,{bigint:!0});}catch(s){throw ae(s)}if(!Wn(n,o)||t!==void 0&&!Wn(t,o))throw new _("PATH_ESCAPED");if(!r.isFile()||!a.isFile())throw new _("READ_DENIED");if(!Kt(i,r)||!Kt(i,a)||i.dev!==a.dev)throw new _("PATH_ESCAPED")}async function qe(e,n){let t,i;try{t=await realpath(e),i=await stat(t,{bigint:!0});}catch{throw new _("PATH_ESCAPED")}if(t!==n.realRoot||!Yt(n.identity,Ze(i)))throw new _("PATH_ESCAPED")}function rc(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 _,Xt,ic,Oo,Qe,Xn,Uo,Co,Zt=k(()=>{g();_=class extends Error{constructor(t){super(t);this.code=t;}code;name="AppDiscoveryFsError"},Xt=constants.O_NOFOLLOW,ic=constants.O_NONBLOCK,Oo=constants.O_RDONLY|(Xt??0)|(ic??0);Qe=class{async getRootIdentity(n){let t=await Gn(n);return await qe(n,t),{dev:t.identity.dev,ino:t.identity.ino,realPath:t.realRoot}}async listDirectory(n,t){let i=$t(t),r=await Gn(n),o=resolve(n,...i),a,s;try{a=await realpath(o),s=await stat(a,{bigint:!0});}catch(c){let d=ae(c);if(d.code==="NOT_FOUND")return [];throw d}if(!Wn(r.realRoot,a)||!s.isDirectory())throw new _("PATH_ESCAPED");try{let c=await readdir(a,{withFileTypes:!0,encoding:"utf8"});return await qe(n,r),c.map(rc)}catch(c){let d=ae(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(Xt===void 0)throw new _("UNSUPPORTED");let r=$t(t),o=await Gn(n),a=resolve(n,...r),s=relative(n,a);if(s===".."||s.startsWith(`..${sep}`)||isAbsolute(s))throw new _("PATH_ESCAPED");let c;try{c=await open(a,Oo);}catch(d){throw ae(d)}try{let d;try{let I=await c.stat({bigint:!0});d=Ze(I);}catch(I){throw ae(I)}if(d.size>BigInt(i))throw new _("LIMIT_EXCEEDED");if(d.size>BigInt(Number.MAX_SAFE_INTEGER))throw new _("LIMIT_EXCEEDED");await qe(n,o);let p=await Ro(n,o.realRoot,r);await $n(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 ae(h)}if(I<=0)throw new _("IDENTITY_CHANGED");u+=I;}let A;try{let I=await c.stat({bigint:!0});A=Ze(I);}catch(I){throw ae(I)}if(!Yt(d,A))throw new _("IDENTITY_CHANGED");return await $n(a,o.realRoot,p,A),await qe(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(Xt===void 0)throw new _("UNSUPPORTED");let r=$t(t),o=await Gn(n),a=resolve(n,...r),s=relative(n,a);if(s===".."||s.startsWith(`..${sep}`)||isAbsolute(s))throw new _("PATH_ESCAPED");let c;try{c=await open(a,Oo);}catch(d){throw ae(d)}try{let d;try{let u=await c.stat({bigint:!0});d=Ze(u);}catch(u){throw ae(u)}if(d.size>BigInt(i)||d.size>BigInt(Number.MAX_SAFE_INTEGER))throw new _("LIMIT_EXCEEDED");await qe(n,o);let p=await Ro(n,o.realRoot,r);await $n(a,o.realRoot,p,d);let l;try{let u=await c.stat({bigint:!0});l=Ze(u);}catch(u){throw ae(u)}if(!Yt(d,l))throw new _("IDENTITY_CHANGED");return await $n(a,o.realRoot,p,l),await qe(n,o),{...l,candidateRealPath:p??o.realRoot}}catch(d){throw d instanceof _?d:ae(d)}finally{await c.close().catch(()=>{});}}async readFileVerified(n,t,i){return this.readVerifiedFile(n,t,i)}},Xn=new Qe,Uo=Xn,Co=Qe;});function Tn(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 wo(e){return typeof e=="string"&&ge.test(e)?e:void 0}function uc(e){return e.length>0&&e!=="."&&e!==".."&&!/[\\/\u0000]/.test(e)}function je(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 fc(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 yc(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 Ac(e){return pc.decode(e)}function Ic(e){return JSON.parse(Ac(e))}function xo(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 gc(e){if(e instanceof _)return xo(e.code);if(e!==null&&typeof e=="object"&&"code"in e){let n=e.code;if(typeof n=="string")return xo(n)}}function Pe(e,n){let t=n();return Number.isFinite(t)&&Number.isFinite(e)&&t-e<=5e3}function mc(e){if(typeof e.readVerifiedFile=="function")return e.readVerifiedFile;if(typeof e.readFileVerified=="function")return e.readFileVerified}function hc(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 jo(e,n,t,i){let r=mc(e);if(!r)throw new _("READ_DENIED");return yc(await r.call(e,n,t,i))}async function ni(e,n,t){let i=hc(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(fc).filter(o=>o!==null)}function _c(e,n,t,i){return Object.freeze({code:e,...{},source:n,relativePath:t})}function Tc(e){if(!Tn(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(je))};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 Ec(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 En(e){return Object.freeze({appIds:Object.freeze([...new Set(e.map(n=>n.appId))].sort(je)),definitionIds:Object.freeze([...new Set(e.map(n=>n.definition.id))].sort(je))})}function Kn(e,n){let t=Object.keys(e).sort(je),i=[...n].sort(je);return t.length===i.length&&t.every((r,o)=>r===i[o])}function vo(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 Dc(e){let n;try{n=Ic(e);}catch{return}if(!Tn(n)||!Kn(n,["version","packages"])||n.version!==1||!Array.isArray(n.packages)||n.packages.length>ti)return;let t=new Set,i=new Set,r=0,o=[];for(let a of n.packages){if(!Tn(a))return;let s=["packageDir","appId","definition","files"],c=Object.hasOwn(a,"lineage"),d=Object.hasOwn(a,"launcher"),p=[...c?["lineage"]:[],...d?["launcher"]:[]];if(!Kn(a,[...s,...p])||d&&a.launcher!==false)return;let l=vo(a.packageDir),u=wo(a.appId);if(!l||l.length!==2||l[0]!=="apps"||!uc(l[1])||!u||t.has(a.packageDir)||!Tn(a.definition)||!Kn(a.definition,["id","version","hash"]))return;let A=wo(a.definition.id),I=a.definition.version,h=a.definition.hash;if(!A||!Number.isSafeInteger(I)||I<1||typeof h!="string"||!ei.test(h)||!Array.isArray(a.files)||a.files.length<2||a.files.length>ii)return;let b=new Set,F=[];for(let v of a.files){if(!Tn(v)||!Kn(v,["path","sha256"]))return;let P=vo(v.path);if(!P||typeof v.sha256!="string"||!ei.test(v.sha256))return;let O=P.join("/"),z=`${a.packageDir}/${O}`;if(b.has(O)||i.has(z))return;b.add(O),i.add(z),F.push(Object.freeze({path:O,sha256:v.sha256}));}if(!se.some(v=>b.has(v))||!b.has("ui/index.html")||(r+=F.length,r>ac))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(F.sort((v,P)=>je(v.path,P.path)))}));}return Object.freeze({version:1,packages:Object.freeze(o)})}function xe(e){let n=gc(e);return n==="PATH_ESCAPED"||n==="IDENTITY_CHANGED"||n==="TOCTOU"?"PATH_ESCAPED":n==="LIMIT_EXCEEDED"?"LIMIT_EXCEEDED":"BUNDLE_INTEGRITY"}async function Nc(e,n,t,i,r){let o=[],a=async(s,c)=>{if(!Pe(i,r))throw new _("LIMIT_EXCEEDED");if(c>2)throw new _("LIMIT_EXCEEDED");let d=await ni(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>ii)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(je)}function bc(e){return se.includes(e)?262144:e==="ui/index.html"?Ye:e==="ui/state.json"?2097152:e.startsWith("ui/assets/")?dc:cc}async function Vo(e,n,t,i){if(e===void 0)return {packages:[],diagnostics:[],incomplete:false,reservedIds:lc};let r=Tc(e.reservedIds),o=[],a=(f,m,T)=>_c(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"||!ei.test(e.expectedIndexHash))return o.push(a("BUNDLE_INTEGRITY","bundle-index.json")),s();let c;try{c=await jo(n,e.root,"bundle-index.json",sc);}catch(f){return o.push(a(xe(f),"bundle-index.json")),s()}let d=createHash("sha256").update(c).digest("hex");if(d!==e.expectedIndexHash)return o.push(a("BUNDLE_INTEGRITY","bundle-index.json")),s();let p=Dc(c);if(p===void 0)return o.push(a("BUNDLE_INTEGRITY","bundle-index.json")),s();if(!Ec(En(p.packages),r))return o.push(a("BUNDLE_INTEGRITY","bundle-index.json")),s([],false,d);if(!Pe(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 ni(n,e.root,"");}catch(f){return o.push(a(xe(f),"bundle-index.json")),s(p.packages.map(m=>({indexEntry:m,failureCode:xe(f)})),false,d)}if(!Pe(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 ni(n,e.root,"apps");}catch(f){return o.push(a(xe(f),"apps")),s(I(xe(f)),false,d)}if(!Pe(t,i)||b.length>ti)return o.push(a("LIMIT_EXCEEDED","apps")),s(I("LIMIT_EXCEEDED"),true,d);let F=new Map(p.packages.map(f=>[f.packageDir.slice(5),f])),v=b.filter(f=>!F.has(f.name));for(let f of v)o.push(a(f.kind==="symlink"?"PATH_ESCAPED":"BUNDLE_INTEGRITY",`apps/${f.name}`));if(v.length>0){let f=v.some(m=>m.kind==="symlink")?"PATH_ESCAPED":"BUNDLE_INTEGRITY";return s(I(f),false,d)}let P=new Set,O=new Map,z=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=z.get(T)??[];M.push(f),z.set(T,M);}for(let f of [...O.values(),...z.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(!Pe(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 Ee("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 Ee("LINEAGE_STALE","Last lineage generation does not match bundle identity");m=Vt(f.lineage,{...D.definition,hash:D.hash}).entries;}catch(D){let G=D instanceof Ee?D.code:"LINEAGE_INVALID";o.push(a(G,f.packageDir)),N.push({indexEntry:f,failureCode:G});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 Nc(n,e.root,f.packageDir,t,i);if(!Pe(t,i)){S=!0,N.push({indexEntry:f,failureCode:"LIMIT_EXCEEDED"});continue}let G=f.files.map($=>$.path);if(D.length!==G.length||D.some(($,De)=>$!==G[De])){N.push({indexEntry:f,failureCode:"BUNDLE_INTEGRITY"});continue}M=new Map;let ie;for(let $ of f.files){if(!Pe(t,i)){ie="LIMIT_EXCEEDED",S=!0;break}if(L>=Qt){ie="LIMIT_EXCEEDED";break}let De;try{De=await jo(n,e.root,`${f.packageDir}/${$.path}`,bc($.path));}catch(Ar){ie=xe(Ar);break}if(!Pe(t,i)){ie="LIMIT_EXCEEDED",S=!0;break}if(L+De.byteLength>Qt){L=Qt,ie="LIMIT_EXCEEDED";break}if(L+=De.byteLength,createHash("sha256").update(De).digest("hex")!==$.sha256){ie="BUNDLE_INTEGRITY";break}M.set($.path,De);}if(ie!==void 0){N.push({indexEntry:f,failureCode:ie});continue}}catch(D){Pe(t,i)||(S=true),N.push({indexEntry:f,failureCode:xe(D)});continue}N.push({indexEntry:f,lineage:m,files:M,...P.has(f)?{failureCode:"DUPLICATE_ID"}:{}});}return s(N,S,d)}var sc,ti,ii,ac,cc,dc,Qt,ei,pc,lc,oi=k(()=>{g();Ft();Ue();jt();zn();Zt();sc=256*1024,ti=64,ii=128,ac=ti*ii,cc=2*1024*1024,dc=8*1024*1024,Qt=32*1024*1024,ei=/^[0-9a-f]{64}$/,pc=new TextDecoder("utf-8",{fatal:true}),lc=Object.freeze({appIds:Object.freeze([]),definitionIds:Object.freeze([])});});var cr={};gr(cr,{AppDiscoveryFsError:()=>_,LOCAL_APP_TOOL_PREFIX:()=>Sc,MCP_APP_WORKSPACE_TOOL_PREFIX:()=>Lc,NodeAppDiscoveryFs:()=>Qe,NodeAppDiscoveryFsAdapter:()=>Co,WORKSPACE_APP_TOOL_PREFIX:()=>en,createWorkspaceAppScanCache:()=>Po,defaultAppDiscoveryFs:()=>Xn,defaultNodeAppDiscoveryFs:()=>Uo,deriveWorkspaceAppToolName:()=>Oc,deriveWorkspaceAppToolNames:()=>ai,discoverWorkspaceAppCandidates:()=>od,discoverWorkspaceApps:()=>ci,isWorkspacePackage:()=>Mc,productAppBundleReservations:()=>En,scanWorkspaceApps:()=>rd});function Mc(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 ai(e){if(typeof e!="string"||!ge.test(e))throw new TypeError("pluginId must be a safe UI plugin identifier");let n=`${en}${e}`.length+7<=128?e:`hash_${createHash("sha256").update(e,"utf8").digest("hex")}`;return {read:`${en}${n}_read`,action:`${en}${n}_action`}}function Oc(e,n="read"){let t=ai(e);return n==="read"?t.read:t.action}function Bo(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 Uc(e,n){return n.length===0||n==="."||n===".."||/[\\/\u0000]/.test(n)?e==="skills"?"skills":"apps":`${e==="skills"?"skills":"apps"}/${n}`}function Cc(e){return e.length>0&&e!=="."&&e!==".."&&!/[\\/\u0000]/.test(e)}function Dn(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 Zo(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 kc(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 Qo(e){return Rc.decode(e)}function wc(e){return JSON.parse(Qo(e))}function xc(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 qn(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 Ho(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 te(e){if(e instanceof _)return Ho(e.code);if(e!==null&&typeof e=="object"&&"code"in e){let n=e.code;if(typeof n=="string")return Ho(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 zo(e){return {reason:e.reason,...e.code==="MANIFEST_DUAL_MISMATCH"?{files:e.files}:{}}}function Go(e){return e==="MANIFEST_DUAL_MISMATCH"?e:er(e)}function jc(e){return er(e.code)}function er(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 nr("UiPluginValidationError",e)}}function nr(e,n){throw new Error(`Unmapped ${e} code: ${String(n)}`)}function tr(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 nr("McpAppContractError",e)}}function Me(e,n){let t=n();return Number.isFinite(t)&&Number.isFinite(e)&&t-e<=5e3}function vc(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(Bo(r)){let o=r.bin,a=typeof o=="string"?o:Bo(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=Fc(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 Fc(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 Bc(){return globalThis.performance?.now()??Date.now()}function ve(e){if(e===null||typeof e!="object"||Object.isFrozen(e))return e;for(let n of Object.values(e))ve(n);return Object.freeze(e)}function $o(e){return Object.freeze(Array.from(e))}async function Zn(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 Ko(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 Ko(e,n.root,r,i),d=await a.call(e,o.workspaceRoot,r,i);return o.candidateRealPath=d.candidateRealPath,or(s,d)&&d.size===BigInt(c.byteLength)&&!rr(d,o.scanStartedAtNs)?o.files.set(r,{relativePath:r,byteLimit:i,fingerprint:d}):o.cacheable=!1,c}catch(s){let c=se.includes(t)&&te(s)==="NOT_FOUND"&&o.directoryListings.some(p=>p.relativePath===n.relativePath&&!Qn(p.key,t)),d=t===Y&&te(s)==="NOT_FOUND"&&Hc(o.directoryListings,n.relativePath);throw !c&&!d&&(o.cacheable=false),s}}function Hc(e,n){let t=e.find(r=>r.relativePath===n);if(t===void 0)return false;if(!Qn(t.key,"dist"))return true;let i=e.find(r=>r.relativePath===`${n}/dist`);return i!==void 0&&!Qn(i.key,"tools.json")}function ir(e,n){return JSON.stringify([e.realPath,n.source,n.relativePath])}async function Gc(e,n,t,i,r,o,a,s){let c=e.fingerprintVerifiedFile,d=ir(t,i),p=r.candidates.get(d),l=i.relativePath,u;try{u=await Xo(e,n,l);}catch(S){if(te(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")&&!se.some(S=>Qn(A.key,S)))return Me(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 Xo(e,n,f);return m===void 0?void 0:{relativePath:f,key:m}}catch(m){if(te(m)==="NOT_FOUND")return;throw m}},h=await Promise.all(Jo.map(I)),b=await Promise.all(zc.map(I));if(!Me(a,s))return {timeLimitReached:true};let F=typeof c=="function"&&h.every(S=>S!==void 0),v=h.filter(S=>S!==void 0),P=[...v,...b.filter(S=>S!==void 0)],O=new Map,z=p!==void 0&&F,N;if(p!==void 0&&typeof c=="function"){let S=await Promise.all(p.files.map(async f=>{if(!Me(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 te(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"){z=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||!or(T,m.fingerprint)||rr(T,o))&&(z=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&&F&&L&&z&&N===p.candidateRealPath?{memo:p}:!F||v.length!==Jo.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 Qn(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 Xo(e,n,t){let i=sr(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(Zo);if(!o.some(a=>a===null))return JSON.stringify(o.slice().sort((a,s)=>Dn(a.name,s.name)||Dn(a.kind,s.kind)).map(a=>[a.name,a.kind]))}function or(e,n){return e.dev===n.dev&&e.ino===n.ino&&e.size===n.size&&e.mtimeNs===n.mtimeNs&&e.ctimeNs===n.ctimeNs}function rr(e,n){let t=e.mtimeNs-n;return t>=-Wo&&t<=Wo}function ri(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 $c(e,n,t){let i=createHash("sha256"),r=new TextEncoder().encode(Z(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 Jc(e,n){let t={...e.definition,sourceHash:n},i;try{i=oe(t);}catch(o){throw o instanceof R&&o.code==="INPUT_INVALID"?new re("MANIFEST_INVALID","normalized definition is invalid"):o}let r={...t,hash:i};try{pe(r);}catch{throw new re("MANIFEST_INVALID","normalized definition is invalid")}return r}function Wc(e,n){return e.actions.some(t=>t.backend.type==="core"&&t.backend.handler!=="state.set"&&!jn(n,t.backend))}function Xc(e){if(typeof e.readVerifiedFile=="function")return e.readVerifiedFile;if(typeof e.readFileVerified=="function")return e.readFileVerified}function sr(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 Ko(e,n,t,i){let r=Xc(e);if(!r)throw new _("READ_DENIED");return kc(await r.call(e,n,t,i))}async function Kc(e,n,t){let i=sr(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(Zo).filter(o=>o!==null)}function Yc(e){let n=[];for(let t of [e.reserved,e.builtin])t&&n.push(t);return e.builtins&&"listMcpApps"in e.builtins?n.push(Yo(e.builtins)):e.builtins&&n.push(e.builtins),e.builtinCatalog&&n.push(Yo(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 Yo(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 Ae(e,n){e.diagnostic||(e.diagnostic=qn(n,e.source,e.relativePath,e.identity?.pluginId));}function qc(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&&Ae(d,"RESERVED_ID");continue}for(let d of o)d.provenance===void 0&&Ae(d,"RESERVED_ID");if(a.length>1)for(let d of a)Ae(d,"DUPLICATE_ID");continue}let s=o.filter(c=>c.source==="apps");if(s.length>1){for(let c of s)Ae(c,"DUPLICATE_ID");for(let c of o.filter(d=>d.source==="skills"))Ae(c,"DUPLICATE_ID");}else for(let c of o.filter(d=>d.source==="skills"))Ae(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)Ae(a,"DUPLICATE_ID");return t}function Zc(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 Yc(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)){Ae(p,"RESERVED_ID");continue}[l.toolNames.read,l.toolNames.action].filter(A=>A!==void 0).some(A=>o.has(A))&&Ae(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{No(l),d.add(p);}catch(u){Ae(p,u instanceof Te?tr(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))&&Ae(p,"RESERVED_ID");}return d}function Qc(e){return [...e].sort((n,t)=>{let i=Fo.indexOf(n.source)-Fo.indexOf(t.source);return i!==0?i:Dn(n.relativePath,t.relativePath)})}function w(e,n,t){e.diagnostic=qn(n,e.source,e.relativePath,e.identity?.pluginId,t);}async function qo(e,n,t){let i=xt(t,{mode:"local"});if(!i.ok&&i.parseFailure){w(n,Go(i.rejection.code),zo(i.rejection));return}let r=xc(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,Go(i.rejection.code),zo(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{zt(o.actions.map(D=>({actionId:D.actionId,inputSchema:D.inputSchema})));}catch(D){if(D instanceof Te){w(n,tr(D.code));return}throw D}let s;try{s=await Zn(e,n,"ui/index.html",Ye);}catch(D){w(n,Ve(te(D),"entry"));return}if(s.byteLength>Ye){w(n,"LIMIT_EXCEEDED");return}let c;try{c=Qo(s);}catch{w(n,"ENTRY_INVALID");return}if(s.byteLength===0||c.length===0){w(n,"ENTRY_INVALID");return}let d=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 Zn(e,n,"ui/state.json",2097152);}catch(D){w(n,Ve(te(D),"initial"));return}if(l.byteLength>2097152){w(n,"LIMIT_EXCEEDED");return}try{let D=wc(l),G=o.dataPaths??[],ie=Mt(D,G);p=de(ie,0,G),He(p);}catch{w(n,"INITIAL_STATE_INVALID");return}if(u=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=cn(A),h=$c(A,s,l??new Uint8Array),b;try{b=Jc(I,h);}catch(D){if(D instanceof re){w(n,jc(D));return}throw D}let F;if(n.bundleLineage!==void 0){let D=n.bundleLineage[n.bundleLineage.length-1];if(!D){w(n,"LINEAGE_INVALID");return}let{legacy:G,...ie}=D.definition,{hash:$,...De}=b;if(Z(ie)!==Z(De)){w(n,"LINEAGE_STALE");return}if(G!==void 0&&(b={...b,legacy:G}),G!==void 0)try{b={...b,hash:oe(b)},pe(b);}catch{w(n,"LINEAGE_INVALID");return}F=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 v=ai(o.pluginId),P=o.actions.length===0?{read:v.read}:v,O=ve(I),z=ve(A),N=ve(b),L=ve({...I.handlers}),S=$o(s),f=l===void 0?void 0:$o(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:ve(i.mcpb)},relativePath:n.relativePath,manifest:z,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:ve(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:F??[]};n.candidate=Object.freeze(M),Wc(o,b.usage)&&w(n,"EXEC_DENIED");}async function ar(e,n){let t={};for(let i of se)try{t[i]=await Zn(e,n,i,262144);}catch(r){if(te(r)==="NOT_FOUND")continue;return {files:t,failure:Ve(te(r),"manifest")}}if(t[K]!==void 0)try{t[Y]=await Zn(e,n,Y,262144);}catch(i){if(te(i)!=="NOT_FOUND")return {files:t,failure:Ve(te(i),"manifest")}}return {files:t}}function si(e){return se.some(n=>e[n]!==void 0)}async function ed(e,n){let{files:t,failure:i}=await ar(e,n);if(i!==void 0){w(n,i);return}let r=t[K];return r!==void 0&&!wt(r)&&(delete t[K],delete t[Y]),si(t)?t:void 0}function nd(e,n,t,i=Pc,r=false,o=new Set){let a=Qc(e),s=qc(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 td(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 id(e,n){if(td(e))return {fs:e,options:n??{}};let t=e??n??{};return {fs:t.filesystem??t.fileSystem??t.fs??Xn,options:t}}async function ci(e,n,t){if(typeof e!="string"||e.length===0)throw new TypeError("workspaceRoot must be explicit");let{fs:i,options:r}=id(n,t),o=r.clock??Bc,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=Mo(r.scanCache,h),I.scanStartedAtNs=d;}catch(N){if(te(N)!=="NOT_FOUND")throw N}let b=I!==void 0&&r.productBundle===void 0&&s.packages.length===0&&s.diagnostics.length===0,F=new Set,v=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(!Me(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:Zi(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:vc(L)};if(p.push(T),l+=1,N.failureCode!==void 0){w(T,N.failureCode);continue}if(N.files?.has(Y)===true){w(T,"EXEC_DENIED",{reason:{path:"",rule:"bundled-tool-mode-unsupported",file:Y}});continue}let M={};for(let D of se){let G=N.files?.get(D);G!==void 0&&(M[D]=G);}if(!si(M)){w(T,"BUNDLE_INTEGRITY");continue}if(await qo(i,T,M),!Me(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 Kc(i,e,S);}catch(T){if(te(T)==="NOT_FOUND")continue;b=false,v=false,p.push({source:L,root:e,name:"",relativePath:L,diagnostic:qn(Ve(te(T),"manifest"),L,L)});continue}let m=f.filter(T=>T.kind==="directory"||T.kind==="symlink").filter(T=>Cc(T.name)).map(T=>({source:L,root:e,name:T.name,relativePath:Uc(L,T.name)})).sort((T,M)=>Dn(T.relativePath,M.relativePath));for(let T of m){let M={...T};if(p.push(M),h!==void 0?F.add(ir(h,M)):b=false,!Me(c,o)){A=true,u="time_limit";break e}let D;if(I!==void 0&&h!==void 0){try{let $=await Gc(i,e,h,M,I,d,c,o);if($.timeLimitReached){A=!0,u="time_limit";break e}M.scanContext=$.context,D=$.memo;}catch($){b=false,w(M,Ve(te($),"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,!Me(c,o)){A=true,u="time_limit";break e}continue}let G;if(L==="skills"&&(G=await ed(i,M),G===void 0)){M.diagnostic===void 0&&ri(M);continue}if(l>=64){w(M,"LIMIT_EXCEEDED");continue}if(T.relativePath.split("/").length-1>2){w(M,"LIMIT_EXCEEDED");continue}if(!Me(c,o)){A=true,u="time_limit";break e}if(l+=1,G===void 0){let $=await ar(i,M);if($.failure!==void 0||!si($.files)){w(M,$.failure??Ve("NOT_FOUND","manifest")),ri(M);continue}G=$.files;}if(await qo(i,M,G),ri(M),!Me(c,o)){A=true,u="time_limit";break e}}}if(I!==void 0&&h!==void 0){let N=[...F].sort(Dn),L=I.lastCandidateKeys,S=L!==void 0&&L.length===N.length&&L.every((m,T)=>m===N[T]);if(b=b&&S,v&&!A&&u===void 0)for(let m of I.candidates.keys())try{JSON.parse(m)[0]===h.realPath&&!F.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===F.size&&f.every(m=>F.has(m))&&!A&&u===void 0,I.lastCandidateScanUnchanged=b,v&&!A&&u===void 0&&(I.lastCandidateKeys=Object.freeze(N));}A&&p.push({source:"apps",root:e,name:"",relativePath:"apps",diagnostic:qn("DISCOVERY_TIME_LIMIT","apps","apps")});let z=Zc(p,r,P);return nd(p,u,s.indexHash,P,r.productBundle!==void 0,z)}var Pc,en,Sc,Lc,Fo,Rc,Jo,zc,Wo,od,rd,dr=k(()=>{g();Ce();Nn();Ne();Xi();Ue();zn();bo();vn();wn();So();Zt();xn();oi();oi();Pc=En([]);en="crewx_local_app_",Sc=en,Lc=en;Fo=["bundled","apps","skills"],Rc=new TextDecoder("utf-8",{fatal:true});Jo=["","/ui"],zc=["/dist"],Wo=2000000000n;od=ci,rd=ci;});g();var pr="SKILL.md",pd=/^---\s*\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/;function lr(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}function ld(e){return e.isDirectory()||e.isSymbolicLink()}function yr(e){try{return existsSync(e)&&statSync(e).isDirectory()}catch{return false}}var ud=["index.js","main.js"];function Iu(e,n){let t=join(e,"package.json");if(existsSync(t))try{let r=JSON.parse(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=resolve(e,o);if(existsSync(a))return a}}if(typeof r.main=="string"){let o=resolve(e,r.main);if(existsSync(o))return o}}catch{}let i=resolve(e,`${n}.js`);if(existsSync(i))return i;for(let r of ud){let o=resolve(e,r);if(existsSync(o))return o}}function fd(e){let n;try{n=readFileSync(e,"utf8");}catch{return {frontmatter:{},readable:false,valid:false,hasFrontmatter:false}}let t=n.match(pd);if(!t)return {frontmatter:{},readable:true,valid:true,hasFrontmatter:false};try{let i=load(t[1]??"");if(!lr(i))return {frontmatter:{},readable:!0,valid:!1,hasFrontmatter:!0};let r=lr(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 yd(e){return [join(e,pr),join(e,"skill",pr)]}function et(e,n){if(!yr(e))return null;for(let t of yd(e)){if(!existsSync(t))continue;let r=fd(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 di(e){try{return readdirSync(e,{withFileTypes:!0}).filter(ld)}catch{return []}}function Ad(e){return e.length===0||/[\\\u0000]/.test(e)?false:e.split("/").every(n=>n.length>0&&n!=="."&&n!=="..")}function ur(e,n,t){!e||n.has(e.name)||(n.add(e.name),t.push(e));}function nt(e){let n=[],t=new Set;for(let i of e)if(yr(i))for(let r of di(i)){if(r.name.startsWith("@")){let o=join(i,r.name);for(let a of di(o))ur(et(join(o,a.name),a.name),t,n);continue}ur(et(join(i,r.name),r.name),t,n);}return n.sort((i,r)=>i.name.localeCompare(r.name))}function Id(e,n){if(!Ad(e))throw new Error(`Skill not found: ${e}`);for(let i of n){let r=et(join(i,e),e);if(r)return r;for(let o of di(i)){if(!o.name.startsWith("@"))continue;let a=et(join(i,o.name,e),e);if(a)return a}}let t=nt(n).find(i=>i.name===e);if(t)return t;throw new Error(`Skill not found: ${e}`)}async function gu(e){if(!e||e.root===null)return {skills:[],diagnostics:[]};let{discoverWorkspaceApps:n}=await Promise.resolve().then(()=>(dr(),cr)),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=join(e.root,...a.split("/"));for(let c of nt([dirname(s)]))resolve(c.dir)!==resolve(s)||r.has(c.name)||(r.add(c.name),i.push(c));for(let c of [join(s,"skill"),join(s,"skills")])for(let d of nt([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 mu=nt,hu=Id;
2
+ export{nt as discover,gu as discoverBundledProductSkills,mu as discoverSkills,Iu as findEntrypoint,fd as readSkillFrontmatter,Id as resolve,hu as resolveSkill};
@@ -1 +1 @@
1
- function f(){let e=[];return {events:e,async log(t,r){e.push({event:t,payload:r});}}}function y(){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 S(){let e=200,t,r,n={},o={status(i){return e=i,o},set(i,a){return n[i]=a,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 M(){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={},a={},p={}){let g=e.find(m=>m.path===n);if(!g)return {status:404,body:{error:"Not found"},headers:{}};let l={method:r,url:n,headers:i,body:o,params:a,query:p},c=S();return await g.handler(l,c),{status:c.getStatusCode(),body:c.getJsonBody()??c.getSentBody(),headers:c.getHeaders()}}}}function P(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 a of t.keys())a.startsWith(o)&&i.push(a.slice(e.length+2));return i}}}function x(e){return P(e)}function R(){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 I(e){let t=e.instanceId??"mock-instance",r=f(),n=y(),o=M(),i=x(t),a=R(),p=[],g=[],l=[],c={run:async()=>({output:""}),...e.agentRunner},m=new AbortController,C=async u=>(p.push(u),{accepted:true}),k=async u=>(g.push(u),{accepted:true}),h=async(u,A)=>{l.push({messageId:u,patch:A});},E=async u=>({userId:u,displayName:u}),b=async()=>{},O=async()=>({messageId:"mock-proactive",sentAt:Date.now()});return {instanceId:t,installationId:e.installationId,config:e.config,capabilities:new Set(e.capabilities??[]),log:n,agentRunner:c,db:i,storage:a,audit:r,abortSignal:e.abortSignal??m.signal,httpRouter:o,router:o,inbound:C,emitEvent:k,updateMessage:h,resolveUser:E,respondSync:b,proactive:O,inboundCalls:p,emittedEvents:g,sentMessages:l}}function G(){}var v={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(v).map(([e,t])=>[e,t.models]));function B(){}export{f as createMockAudit,I as createMockContext,y as createMockLogger,M as createMockRouter,R as createMockStorage,x as createMockStore,B as resetModelsOverride,G as resetPricingOverride};
1
+ function f(){let e=[];return {events:e,async log(t,o){e.push({event:t,payload:o});}}}function h(){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 A(){let e=200,t,o,n={},i={status(r){return e=r,i},set(r,a){return n[r]=a,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 y(){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={},a={},p={}){let c=e.find(m=>m.path===n);if(!c)return {status:404,body:{error:"Not found"},headers:{}};let g={method:o,url:n,headers:r,body:i,params:a,query:p},l=A();return await c.handler(g,l),{status:l.getStatusCode(),body:l.getJsonBody()??l.getSentBody(),headers:l.getHeaders()}}}}function P(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 a of t.keys())a.startsWith(i)&&r.push(a.slice(e.length+2));return r}}}function x(e){return P(e)}function M(){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 C(e){let t=e.instanceId??"mock-instance",o=f(),n=h(),i=y(),r=x(t),a=M(),p=[],c=[],g=[],l={run:async()=>({output:""}),...e.agentRunner},m=new AbortController,w=async u=>(p.push(u),{accepted:true}),v=async u=>(c.push(u),{accepted:true}),E=async(u,R)=>{g.push({messageId:u,patch:R});},I=async u=>({userId:u,displayName:u}),b=async()=>{},O=async()=>({messageId:"mock-proactive",sentAt:Date.now()});return {instanceId:t,installationId:e.installationId,config:e.config,capabilities:new Set(e.capabilities??[]),log:n,agentRunner:l,db:r,storage:a,audit:o,abortSignal:e.abortSignal??m.signal,httpRouter:i,router:i,inbound:w,emitEvent:v,updateMessage:E,resolveUser:I,respondSync:b,proactive:O,inboundCalls:p,emittedEvents:c,sentMessages:g}}function D(){}var k={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(k).map(([e,t])=>[e,t.models]));var _=[{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(_.map(({baseModelId:e,catalogModelId:t})=>[e,t]));var G=[{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(G.map(({legacyId:e,model:t,effort:o})=>[e,o===void 0?{model:t}:{model:t,effort:o}]));function W(){}export{f as createMockAudit,C as createMockContext,h as createMockLogger,y as createMockRouter,M as createMockStorage,x as createMockStore,W as resetModelsOverride,D as resetPricingOverride};
@@ -3,6 +3,7 @@ export interface BaseEvent {
3
3
  traceId: string;
4
4
  timestamp: Date;
5
5
  }
6
+ export type ActorKind = 'human' | 'agent' | 'system' | 'unknown';
6
7
  export interface TaskStartEvent extends BaseEvent {
7
8
  agentRef: string;
8
9
  message: string;
@@ -12,15 +13,25 @@ export interface TaskStartEvent extends BaseEvent {
12
13
  provider?: string;
13
14
  codingAgentCommand?: string;
14
15
  renderedPrompt?: string;
16
+ securityKey?: string | null;
15
17
  metadata?: Record<string, unknown>;
16
18
  threadId?: string;
17
19
  platform?: Platform;
18
20
  workspaceId?: string;
21
+ projectId?: string;
19
22
  workspaceName?: string;
23
+ cwd?: string;
24
+ actorKind?: ActorKind | null;
25
+ actorId?: string | null;
20
26
  parentTaskId?: string | null;
21
27
  rootTraceId?: string;
22
28
  callerAgentId?: string | null;
23
29
  }
30
+ export interface TaskProviderInputEvent extends BaseEvent {
31
+ runEpoch: number;
32
+ input: string;
33
+ keyWrapSkipped: boolean;
34
+ }
24
35
  export interface TaskEndEvent extends BaseEvent {
25
36
  agentRef: string;
26
37
  mode: 'query' | 'execute';
@@ -29,6 +40,8 @@ export interface TaskEndEvent extends BaseEvent {
29
40
  error?: {
30
41
  code: string;
31
42
  message: string;
43
+ providerCode?: string;
44
+ mode?: string;
32
45
  };
33
46
  exitCode?: number;
34
47
  inputTokens?: number;
@@ -37,6 +50,8 @@ export interface TaskEndEvent extends BaseEvent {
37
50
  costUsd?: number;
38
51
  model?: string;
39
52
  metadata?: Record<string, unknown>;
53
+ workspaceId?: string;
54
+ workspaceName?: string;
40
55
  }
41
56
  export interface TaskOutputEvent extends BaseEvent {
42
57
  agentRef: string;
@@ -89,6 +104,7 @@ export interface CrewxEvents {
89
104
  'task:start': TaskStartEvent;
90
105
  'task:end': TaskEndEvent;
91
106
  'task:output': TaskOutputEvent;
107
+ 'task:provider-input': TaskProviderInputEvent;
92
108
  'tool:observed:before': ToolBeforeEvent;
93
109
  'tool:observed:after': ToolAfterEvent;
94
110
  'adapter:lifecycle': AdapterLifecycleEvent;
@@ -1,13 +1,20 @@
1
+ import type { AgentListSnapshot } from '../agent/agent-list-view';
1
2
  import { TypedEventEmitter } from '../events/TypedEventEmitter';
2
3
  import type { CrewxPlugin } from '../plugin';
3
4
  import type { IFsAdapter } from '../platform/IFsAdapter';
4
5
  import type { ChannelAdapterRegistration } from '../adapter/types';
5
- import type { CrewxProjectConfig, AgentConfig, CrewxOptions, QueryOptions, QueryResult, ExecuteOptions, ExecuteResult } from '../types';
6
- import type { TemplateContext } from '../template/types';
7
- import type { CustomLayoutDefinition } from '../layout/types';
8
- import type { TemplateMessage } from '../conversation/types';
6
+ import type { CrewxProjectConfig, AgentConfig, CrewxOptions, QueryOptions, QueryResult, ExecuteOptions, ExecuteResult, CanResumeSessionParams, CanResumeSessionResult } from '../types';
7
+ import type { PromptListResolver, TemplateContext } from '../template/types';
8
+ import type { CustomLayoutDefinition, LayoutCapabilities } from '../layout/types';
9
+ import type { ConversationThreadState, SemanticContinuityContext, TemplateMessage } from '../conversation/types';
9
10
  import type { HandlerOptions, CrewxHandler } from '../server/handler';
10
11
  import type { RemoteProviderConfig } from '../remote/types.js';
12
+ import type { McpAppLayoutSnapshot, McpAppStateDescriptor } from '../mcp-app/types.js';
13
+ import type { McpAppModelContext } from '../mcp-app/model-context.js';
14
+ import type { CrewxAppCatalogOptions, CrewxAppCatalogResult } from '../mcp-app/types.js';
15
+ import type { McpAppsContext } from '../mcp-app/apps-context.js';
16
+ import type { UiRuntimeFacade, UiRuntimeOptions } from '../ui-instance/types.js';
17
+ import type { CrewxEventName, CrewxEventPayload } from '../events/types';
11
18
  export interface ToolDefinition {
12
19
  name: string;
13
20
  description: string;
@@ -19,6 +26,7 @@ export type LayoutSpec = string | {
19
26
  props?: Record<string, any>;
20
27
  } | {
21
28
  template: string;
29
+ capabilities?: LayoutCapabilities;
22
30
  };
23
31
  export interface SkillEntry {
24
32
  metadata: {
@@ -28,6 +36,7 @@ export interface SkillEntry {
28
36
  };
29
37
  filePath: string;
30
38
  }
39
+ export declare function loadAgentSkills(projectRoot?: string): SkillEntry[];
31
40
  export interface RenderAgentPromptOptions {
32
41
  layout?: LayoutSpec;
33
42
  session?: {
@@ -39,6 +48,12 @@ export interface RenderAgentPromptOptions {
39
48
  vars?: Record<string, unknown>;
40
49
  skills?: SkillEntry[];
41
50
  messages?: TemplateMessage[];
51
+ semanticContinuity?: SemanticContinuityContext;
52
+ threadState?: ConversationThreadState;
53
+ mcpAppProjections?: readonly McpAppStateDescriptor[];
54
+ mcpAppModelContext?: McpAppModelContext;
55
+ appLayoutSnapshot?: McpAppLayoutSnapshot;
56
+ mcpAppAvailable?: McpAppsContext['available'];
42
57
  threadId?: string;
43
58
  }
44
59
  export declare class Crewx extends TypedEventEmitter {
@@ -57,21 +72,30 @@ export declare class Crewx extends TypedEventEmitter {
57
72
  private readonly _pendingThreads;
58
73
  private readonly _activeTasks;
59
74
  private readonly _remoteFactory?;
75
+ private readonly _taskTicketIssuer?;
60
76
  private readonly _remoteTargets;
77
+ private readonly _detachedRemoteTargets;
61
78
  private readonly _additionalArgsProvider?;
79
+ private _globalSettings?;
80
+ private readonly _callerIdentityOverrides;
62
81
  private constructor();
63
82
  private resolveFileRemoteTarget;
83
+ private _readRemoteTargetStat;
64
84
  private static loadBuiltInConfig;
65
85
  private static mergeCrewxConfig;
66
86
  static loadYaml(path: string | undefined, options?: CrewxOptions, fsAdapter?: IFsAdapter): Promise<Crewx>;
67
- static fromConfig(config: CrewxProjectConfig, options?: CrewxOptions, projectRoot?: string, fsAdapter?: IFsAdapter): Promise<Crewx>;
87
+ static fromConfig(config: CrewxProjectConfig, options?: Omit<CrewxOptions, 'taskTicketIssuer'>, projectRoot?: string, fsAdapter?: IFsAdapter): Promise<Crewx>;
68
88
  get agents(): ReadonlyMap<string, AgentConfig>;
69
89
  get config(): CrewxProjectConfig | undefined;
70
90
  get plugins(): readonly CrewxPlugin[];
71
91
  get tools(): ReadonlyMap<string, ToolDefinition>;
92
+ listApps(options?: CrewxAppCatalogOptions): Promise<CrewxAppCatalogResult>;
93
+ listWorkspaceApps(options?: CrewxAppCatalogOptions): Promise<CrewxAppCatalogResult>;
72
94
  get workspaceId(): string;
95
+ createUiRuntime(options: UiRuntimeOptions): UiRuntimeFacade;
73
96
  get workspaceName(): string;
74
97
  getAgent(agentRef: string): AgentConfig | undefined;
98
+ canResumeSession(agentRef: string, params: CanResumeSessionParams): Promise<CanResumeSessionResult>;
75
99
  getRemoteProviderConfig(providerId: string): RemoteProviderConfig | undefined;
76
100
  private computeTaskLogPath;
77
101
  registerTool(name: string, definition: Omit<ToolDefinition, 'name'>): void;
@@ -90,6 +114,14 @@ export declare class Crewx extends TypedEventEmitter {
90
114
  team?: string;
91
115
  provider?: string;
92
116
  }): AgentConfig[];
117
+ private readonly _promptListProviders;
118
+ registerPromptListProvider(resolver: PromptListResolver): void;
119
+ static readAgentListSnapshot(options: {
120
+ cwd: string;
121
+ env: Record<string, string>;
122
+ configPath?: string;
123
+ }): AgentListSnapshot;
124
+ static createAgentListPromptResolver(configPath?: string): PromptListResolver;
93
125
  renderAgentPrompt(agentId: string): string;
94
126
  renderPrompt(template: string, context?: TemplateContext): Promise<string>;
95
127
  registerLayout(name: string, template: string | CustomLayoutDefinition): void;
@@ -98,12 +130,36 @@ export declare class Crewx extends TypedEventEmitter {
98
130
  private _resolveLayoutSpec;
99
131
  private _extractLayoutId;
100
132
  private _extractLayoutProps;
133
+ private _resolveLayoutContinuityCapability;
101
134
  private _getConversationProvider;
135
+ private _filterActivityLogByTaskIds;
102
136
  private _fetchHistoryMessages;
137
+ private _resolveFreshProvider;
138
+ private _resolveLocalServerRuntime;
139
+ private _readInputBudgetPercent;
140
+ private _resolveBudgetModel;
141
+ private _resolveContextMode;
142
+ private _buildInstructionOnlyResumeManifest;
143
+ private _buildInstructionOnlyContinuity;
144
+ private _prepareInstructionOnlyResumeWithBudget;
145
+ private _activityLogEntryCounts;
146
+ private _buildUnresolvedContextBudgetManifest;
147
+ private _buildResolvedContextBudgetManifest;
148
+ private _renderFreshPromptVariant;
149
+ private _prepareFreshPromptWithBudget;
150
+ private _prepareFreshPromptWithBudgetImpl;
151
+ private _recountFreshProviderInitialInput;
152
+ private _validateFreshProviderInitialInputBudget;
103
153
  private _resolveTimeout;
154
+ private _resolveIdleTimeout;
104
155
  private _lookupCliAdapter;
156
+ private _resolveEffectiveCost;
105
157
  private _resolveEffectiveCwd;
106
158
  private _buildFileRemoteOptions;
159
+ private _registerCallerIdentityOverride;
160
+ private _clearCallerIdentityOverride;
161
+ private _rewriteCallerFacingPayload;
162
+ protected emit<K extends CrewxEventName>(event: K, payload: CrewxEventPayload<K>): void;
107
163
  private emitToolEvents;
108
164
  private emitTaskLogEntries;
109
165
  private tryParseJson;