@crewx/sdk 0.9.0-rc.15 → 0.9.0-rc.150

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 (293) 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 +56 -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 +61 -0
  39. package/dist/context-budget/index.d.ts +141 -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 +48 -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 +1137 -226
  60. package/dist/esm/node/index.js +2 -0
  61. package/dist/esm/plugins/index.js +498 -216
  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 +606 -209
  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 +9 -0
  68. package/dist/facade/Crewx.d.ts +60 -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 +17 -1
  73. package/dist/index.browser.js +6 -2
  74. package/dist/index.d.ts +127 -17
  75. package/dist/index.js +1137 -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/apps-context.d.ts +20 -0
  92. package/dist/mcp-app/bundle-provenance.d.ts +3 -0
  93. package/dist/mcp-app/candidate-registration.d.ts +4 -0
  94. package/dist/mcp-app/catalog.d.ts +7 -0
  95. package/dist/mcp-app/content-channel.d.ts +86 -0
  96. package/dist/mcp-app/content-declarations.d.ts +31 -0
  97. package/dist/mcp-app/dev-checks.d.ts +29 -0
  98. package/dist/mcp-app/diagnostic-reason.d.ts +3 -0
  99. package/dist/mcp-app/discovery.d.ts +161 -0
  100. package/dist/mcp-app/errors.d.ts +7 -0
  101. package/dist/mcp-app/index.d.ts +33 -0
  102. package/dist/mcp-app/installed-app-ref.d.ts +25 -0
  103. package/dist/mcp-app/model-context.d.ts +29 -0
  104. package/dist/mcp-app/node-app-discovery-fs.d.ts +23 -0
  105. package/dist/mcp-app/product-bundle-assets.d.ts +27 -0
  106. package/dist/mcp-app/product-bundle-loader.d.ts +53 -0
  107. package/dist/mcp-app/projection.d.ts +14 -0
  108. package/dist/mcp-app/registry.d.ts +28 -0
  109. package/dist/mcp-app/skill-backend.d.ts +132 -0
  110. package/dist/mcp-app/state-set.d.ts +9 -0
  111. package/dist/mcp-app/types.d.ts +472 -0
  112. package/dist/mcp-app/workspace-app-assets.d.ts +42 -0
  113. package/dist/mcp-app/workspace-app-scan-cache.d.ts +24 -0
  114. package/dist/mcp-app/workspace-snapshot.d.ts +71 -0
  115. package/dist/migrations/0011_far_black_tarantula.sql +1 -0
  116. package/dist/migrations/0012_blue_turbo.sql +23 -0
  117. package/dist/migrations/0013_hesitant_adam_destine.sql +15 -0
  118. package/dist/migrations/0014_organic_mongu.sql +73 -0
  119. package/dist/migrations/0015_panoramic_gorilla_man.sql +71 -0
  120. package/dist/migrations/0016_fuzzy_hemingway.sql +14 -0
  121. package/dist/migrations/0017_project_stage_sdk_migration.sql +29 -0
  122. package/dist/migrations/0018_bored_jackal.sql +33 -0
  123. package/dist/migrations/0019_backfill_task_thread_ids.sql +74 -0
  124. package/dist/migrations/0020_useful_iron_lad.sql +55 -0
  125. package/dist/migrations/0021_dashing_peter_quill.sql +51 -0
  126. package/dist/migrations/0022_wandering_bucky.sql +1 -0
  127. package/dist/migrations/0023_red_payback.sql +1 -0
  128. package/dist/migrations/0024_storage_metadata.sql +262 -0
  129. package/dist/migrations/0025_task_heartbeat.sql +8 -0
  130. package/dist/migrations/0025_thread_app_instance_ledger.sql +2 -0
  131. package/dist/migrations/0026_mcp_action_source.sql +47 -0
  132. package/dist/migrations/0027_task_stop_scope_cleanup.sql +5 -0
  133. package/dist/migrations/0027_ui_instance_active_unique.sql +2 -0
  134. package/dist/migrations/0029_nice_rhino.sql +1 -0
  135. package/dist/migrations/0031_petite_arclight.sql +6 -0
  136. package/dist/migrations/0032_ui_instance_opened_by.sql +1 -0
  137. package/dist/migrations/0033_thread_creator_boundary_guard.sql +38 -0
  138. package/dist/migrations/0034_keen_fallen_one.sql +36 -0
  139. package/dist/migrations/0035_request_log_daily.sql +11 -0
  140. package/dist/migrations/0036_ui_definition_archive.sql +8 -0
  141. package/dist/migrations/0037_ui_instance_agent_open_request.sql +1 -0
  142. package/dist/migrations/0038_task_rating.sql +3 -0
  143. package/dist/migrations/meta/0011_snapshot.json +1342 -0
  144. package/dist/migrations/meta/0012_snapshot.json +1494 -0
  145. package/dist/migrations/meta/0013_snapshot.json +1592 -0
  146. package/dist/migrations/meta/0014_snapshot.json +1975 -0
  147. package/dist/migrations/meta/0015_snapshot.json +2315 -0
  148. package/dist/migrations/meta/0016_snapshot.json +2419 -0
  149. package/dist/migrations/meta/0017_snapshot.json +2419 -0
  150. package/dist/migrations/meta/0018_snapshot.json +2570 -0
  151. package/dist/migrations/meta/0020_snapshot.json +2895 -0
  152. package/dist/migrations/meta/0021_snapshot.json +3031 -0
  153. package/dist/migrations/meta/0022_snapshot.json +3039 -0
  154. package/dist/migrations/meta/0023_snapshot.json +3047 -0
  155. package/dist/migrations/meta/0029_snapshot.json +3206 -0
  156. package/dist/migrations/meta/0031_snapshot.json +3251 -0
  157. package/dist/migrations/meta/0034_snapshot.json +3473 -0
  158. package/dist/migrations/meta/0035_snapshot.json +3547 -0
  159. package/dist/migrations/meta/0036_snapshot.json +3591 -0
  160. package/dist/migrations/meta/0037_snapshot.json +3598 -0
  161. package/dist/migrations/meta/0038_snapshot.json +3626 -0
  162. package/dist/migrations/meta/_journal.json +196 -0
  163. package/dist/node/index.d.ts +1 -0
  164. package/dist/node/index.js +2 -0
  165. package/dist/paths.d.ts +1 -0
  166. package/dist/plugin/types.d.ts +1 -0
  167. package/dist/plugins/index.d.ts +1 -1
  168. package/dist/plugins/index.js +498 -216
  169. package/dist/plugins/sqlite-tracing.d.ts +46 -0
  170. package/dist/process/index.d.ts +2 -0
  171. package/dist/process/index.js +1 -0
  172. package/dist/process/process-control.d.ts +41 -0
  173. package/dist/prompt/tag-names.d.ts +22 -0
  174. package/dist/provider/acp/connection.d.ts +6 -0
  175. package/dist/provider/acp/meta.d.ts +11 -0
  176. package/dist/provider/bridge.d.ts +7 -1
  177. package/dist/provider/classify-task-error.d.ts +2 -0
  178. package/dist/provider/cli/adapter.types.d.ts +14 -2
  179. package/dist/provider/cli/adapters/agent-call.util.d.ts +1 -1
  180. package/dist/provider/cli/adapters/cli-knob.util.d.ts +7 -0
  181. package/dist/provider/cli/adapters/codex-item.d.ts +1 -0
  182. package/dist/provider/cli/adapters/event-timestamp.util.d.ts +1 -0
  183. package/dist/provider/cli/adapters/grok.d.ts +2 -0
  184. package/dist/provider/cli/adapters/index.d.ts +5 -0
  185. package/dist/provider/cli/index.d.ts +3 -2
  186. package/dist/provider/cli/meta.d.ts +5 -0
  187. package/dist/provider/cli/protocol-envelope.d.ts +3 -0
  188. package/dist/provider/errors.d.ts +5 -1
  189. package/dist/provider/idle-watchdog.d.ts +19 -0
  190. package/dist/provider/models.d.ts +17 -12
  191. package/dist/provider/order.d.ts +1 -1
  192. package/dist/provider/parse-usage.d.ts +6 -0
  193. package/dist/provider/provider-selection.d.ts +8 -0
  194. package/dist/provider/redact-technical-message.d.ts +1 -0
  195. package/dist/provider/task-error.types.d.ts +17 -0
  196. package/dist/publish/constants.d.ts +6 -0
  197. package/dist/publish/errors.d.ts +7 -0
  198. package/dist/publish/index.d.ts +50 -0
  199. package/dist/publish/index.js +2 -0
  200. package/dist/publish/manifest.d.ts +47 -0
  201. package/dist/publish/marketplace-api.constants.d.ts +1 -0
  202. package/dist/publish/pack.d.ts +6 -0
  203. package/dist/publish/scan.d.ts +9 -0
  204. package/dist/publish/secrets.d.ts +6 -0
  205. package/dist/publish/upload.d.ts +19 -0
  206. package/dist/remote/execution-profile.d.ts +9 -0
  207. package/dist/remote/index.d.ts +1 -0
  208. package/dist/remote/types.d.ts +28 -0
  209. package/dist/repository/agent-suggestion.repository.d.ts +34 -0
  210. package/dist/repository/base-sqlite-repository.d.ts +1 -0
  211. package/dist/repository/common-code.repository.d.ts +45 -0
  212. package/dist/repository/db.d.ts +12 -1
  213. package/dist/repository/index.d.ts +43 -5
  214. package/dist/repository/index.js +606 -209
  215. package/dist/repository/logs-db.d.ts +12 -0
  216. package/dist/repository/notification.repository.d.ts +58 -0
  217. package/dist/repository/project.repository.d.ts +90 -0
  218. package/dist/repository/request-log-mover.d.ts +70 -0
  219. package/dist/repository/request-log.repository.d.ts +7 -3
  220. package/dist/repository/storage-metadata.repository.d.ts +64 -0
  221. package/dist/repository/task-log-migration.d.ts +74 -0
  222. package/dist/repository/task-log.repository.d.ts +44 -0
  223. package/dist/repository/task-status.d.ts +21 -0
  224. package/dist/repository/task.repository.d.ts +275 -7
  225. package/dist/repository/thread-history.repository.d.ts +193 -0
  226. package/dist/repository/thread-origin-verdict.d.ts +27 -0
  227. package/dist/repository/thread-title.types.d.ts +29 -0
  228. package/dist/repository/thread.repository.d.ts +115 -7
  229. package/dist/repository/usage-backfill.d.ts +62 -0
  230. package/dist/repository/usage-from-logs.d.ts +21 -0
  231. package/dist/repository/workspace.repository.d.ts +3 -0
  232. package/dist/schema/agent-suggestions.d.ts +199 -0
  233. package/dist/schema/common-codes.d.ts +216 -0
  234. package/dist/schema/index.d.ts +13 -0
  235. package/dist/schema/notifications.d.ts +303 -0
  236. package/dist/schema/projects.d.ts +610 -0
  237. package/dist/schema/request-log-daily.d.ts +151 -0
  238. package/dist/schema/storage-metadata.d.ts +181 -0
  239. package/dist/schema/task-log-events.d.ts +119 -0
  240. package/dist/schema/tasks.d.ts +203 -0
  241. package/dist/schema/thread-creator-unverified.d.ts +45 -0
  242. package/dist/schema/thread-history.d.ts +734 -0
  243. package/dist/schema/threads.d.ts +59 -0
  244. package/dist/schema/ui-action-receipts.d.ts +358 -0
  245. package/dist/schema/ui-definition-archive.d.ts +63 -0
  246. package/dist/schema/ui-instance-repins.d.ts +222 -0
  247. package/dist/schema/ui-instances.d.ts +324 -0
  248. package/dist/schema/workspaces.d.ts +17 -0
  249. package/dist/skills/index.d.ts +15 -0
  250. package/dist/skills/index.js +2 -0
  251. package/dist/skills/types.d.ts +18 -0
  252. package/dist/task-log/anchor-child-tasks.d.ts +7 -0
  253. package/dist/task-log/delegation-trailer.d.ts +34 -0
  254. package/dist/template/engine.d.ts +2 -2
  255. package/dist/template/helpers/exec.browser.d.ts +4 -3
  256. package/dist/template/helpers/exec.d.ts +4 -3
  257. package/dist/template/types.d.ts +20 -0
  258. package/dist/testing/index.js +1 -1
  259. package/dist/types/index.d.ts +1574 -3
  260. package/dist/types/task-log.types.d.ts +3 -0
  261. package/dist/ui-card/index.d.ts +2 -0
  262. package/dist/ui-card/legacy-card-parser.d.ts +11 -0
  263. package/dist/ui-instance/definition.d.ts +6 -0
  264. package/dist/ui-instance/errors.d.ts +18 -0
  265. package/dist/ui-instance/index.d.ts +11 -0
  266. package/dist/ui-instance/json.d.ts +19 -0
  267. package/dist/ui-instance/lineage.d.ts +24 -0
  268. package/dist/ui-instance/runtime.d.ts +18 -0
  269. package/dist/ui-instance/store.d.ts +210 -0
  270. package/dist/ui-instance/types.d.ts +327 -0
  271. package/dist/ui-plugin/app-manifest.d.ts +64 -0
  272. package/dist/ui-plugin/csp.d.ts +28 -0
  273. package/dist/ui-plugin/index.d.ts +6 -0
  274. package/dist/ui-plugin/limits.d.ts +27 -0
  275. package/dist/ui-plugin/manifest.d.ts +3 -0
  276. package/dist/ui-plugin/types.d.ts +203 -0
  277. package/dist/ui-plugin/validator.d.ts +18 -0
  278. package/dist/utils/crewx-executable.d.ts +76 -0
  279. package/dist/utils/crewx-home.d.ts +1 -0
  280. package/dist/utils/env-defaults.d.ts +3 -0
  281. package/dist/utils/id.d.ts +1 -1
  282. package/dist/utils/local-identity.d.ts +2 -0
  283. package/dist/utils/runner-env.d.ts +3 -0
  284. package/dist/utils/timestamp.d.ts +1 -0
  285. package/dist/utils/workspace.d.ts +1 -0
  286. package/dist/wi/create.d.ts +48 -0
  287. package/dist/wi/select.d.ts +20 -0
  288. package/package.json +57 -3
  289. package/templates/agents/default.yaml +296 -128
  290. package/templates/documents/crewx-manual.md +138 -138
  291. package/templates/documents/crewx-quick-guide.md +8 -7
  292. package/templates/workflows/wi-default-flow.yaml +65 -0
  293. 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 pr=Object.defineProperty;var w=(e,n)=>()=>(e&&(n=e(e=0)),n);var lr=(e,n)=>{for(var t in n)pr(e,t,{get:n[t],enumerable:true});};var g=w(()=>{});var R,En=w(()=>{g();R=class extends Error{constructor(t,i=t,r){super(i);this.code=t;this.currentRevision=r;}code;currentRevision;name="UiRuntimeError"};});function et(e){return ur.test(e)||fr.test(e)}function ce(){throw new R("INPUT_INVALID","JSON value is not projection-safe")}function gr(e){let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}function Zn(e,n,t,i,r,o){if(n>i&&ce(),e===null||typeof e=="string"||typeof e=="boolean")return typeof e=="string"&&(yr.test(e)||Ir.test(e)&&!_r(r,o)||Ar.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 s=e;t.has(s)&&ce(),t.add(s);try{if(Array.isArray(e))return e.map(d=>Zn(d,n+1,t,i,r,o));gr(s)||ce();let a={};for(let[d,c]of Object.entries(e))et(d)&&ce(),a[d]=Zn(c,n+1,t,i,[...r,d],o);return a}finally{t.delete(s);}}function de(e,n=0,t=[]){(!Number.isInteger(n)||n<0||n>hr)&&ce(),(!Array.isArray(t)||t.some(r=>typeof r!="string"))&&ce();let i=Zn(e,0,new Set,mr+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 _r(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 Qn(e){return Array.isArray(e)?e.map(Qn):e!==null&&typeof e=="object"?Object.fromEntries(Object.keys(e).sort().map(n=>[n,Qn(e[n])])):e}function Z(e){return He(Qn(e))}function nt(e){return Buffer.byteLength(e,"utf8")}var ur,fr,yr,Ar,Ir,mr,hr,Ne=w(()=>{g();En();ur=/(?:proof|token|secret|password|cookie|authorization|private[_-]?key|stack|exception|plugin[_-]?text)/i,fr=/(?:url|uri|endpoint|path|file(?:name|path)?|cwd|shell|directory|dir|folder)$/i,yr=/<\/?[A-Za-z][^>]*>/,Ar=/^(?:[A-Za-z]:[\\/]|\\\\|~[\\/]|\/)/,Ir=/^(?:https?|file|ftp|ws|wss):\/\//i;mr=8,hr=4;});var Dn,tt=w(()=>{g();Dn=["text/plain","application/json"];});var ai=w(()=>{g();tt();});function ze(e){return Er.has(e)||Dr.test(e)||Nr.test(e)}var ci,Er,Dr,Nr,Nn,tn,ge,it,ot,rt,st,at,Ue=w(()=>{g();ci=["__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"],Er=new Set(ci),Dr=/(?:proof|token|secret|password|cookie|authorization|private[_-]?key|stack|exception|plugin[_-]?text)/i,Nr=/(?:url|uri|endpoint|path|file(?:name|path)?|cwd|shell|directory|dir|folder)$/i;Nn=/^[A-Za-z0-9_]+$/,tn=/^[A-Za-z0-9_]+(?:\.[A-Za-z0-9_]+)*$/,ge=/^[A-Za-z][A-Za-z0-9._-]{0,127}$/,it=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/,ot=/^[A-Za-z][A-Za-z0-9._-]{0,127}$/,rt=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$/,st=["blue","violet","emerald","amber","rose","sky","slate","indigo"],at=["inline","panel"];});function ct(e){return typeof e=="string"&&Dn.includes(e)}var di=w(()=>{g();tt();Ue();});function bn(e){if(!dt(e))return false;let n=Object.keys(e);return !(n.some(t=>t!=="in"&&t!=="out")||n.length===0||Object.hasOwn(e,"in")&&!br(e.in)||Object.hasOwn(e,"out")&&!Pr(e.out))}function br(e){return dt(e)?Object.keys(e).every(t=>t==="mediaType"||t==="required")&&Object.hasOwn(e,"mediaType")&&ct(e.mediaType)&&(!Object.hasOwn(e,"required")||typeof e.required=="boolean"):false}function Pr(e){return dt(e)?Object.keys(e).every(t=>t==="mediaType"||t==="range")&&Object.hasOwn(e,"mediaType")&&ct(e.mediaType)&&(!Object.hasOwn(e,"range")||typeof e.range=="boolean"):false}function dt(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}var pt=w(()=>{g();ai();di();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 ut(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"||!Sr.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=>!Or(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&&lt(t.resultProjection),t.content!==void 0&&!bn(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&&lt(e.stateProjection),e.summaryProjection){lt(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(Lr(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,s]of Object.entries(t)){if(!Object.hasOwn(r,o)||r[o]!==s||typeof s!="string"||!/^[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(s)||n.has(s))throw new R("DEFINITION_UNSUPPORTED","UI legacy host tools are invalid");n.add(s);}}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 Lr(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 s=t.fixedResult;if(!s||typeof s!="object"||Array.isArray(s))throw new Error("fixed result");let a=s;if(Object.keys(a).sort().join(",")!=="argsPolicy,structuredContent"||a.argsPolicy!=="empty-only"&&a.argsPolicy!=="ignore"||!a.structuredContent||typeof a.structuredContent!="object"||Array.isArray(a.structuredContent))throw new Error("fixed result");let d=de(a.structuredContent);if(nt(He(d))>4*1024)throw new Error("fixed result size")}}catch{throw new R("DEFINITION_UNSUPPORTED","UI legacy tool metadata is not projection-safe")}}function lt(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 Or(e){return e.length>0&&e.length<=128&&e!=="*"&&e!=="all"&&!/[/*]/.test(e)}var Sr,Ce=w(()=>{g();Ne();En();pt();Sr=/^[0-9a-f]{64}$/;});var pi=w(()=>{g();Ne();});var q,Ge,ft=w(()=>{g();q="dist/tools.json",Ge="dist/main.mjs";});var on,li=w(()=>{g();on="window";});function ui(e){if(!Array.isArray(e)||e.length===0)return false;let n=new Set;for(let t of e){if(!Rr.some(i=>i===t)||n.has(t))return false;n.add(t);}return true}var Rr,fi=w(()=>{g();Rr=["CREWX_APP_INSTANCE_ID","CREWX_THREAD_ID"];});function V(e){throw new yt(e)}function zr(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 Gr(e,n){let t=Object.getOwnPropertyDescriptor(e,n);return (!t||!("value"in t))&&V("CSP_ORIGIN_INVALID"),t.value}function Pn(e,n){if(!Object.prototype.hasOwnProperty.call(e,n))return [];let t=Gr(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 $r(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 Ii(e,n){/\s|\\/u.test(e)&&V("CSP_ORIGIN_INVALID");let t=vr.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("[")?Vr:Fr).test(r)||V("CSP_ORIGIN_INVALID"),i==="wss"&&n!=="connectDomains"&&V("CSP_ORIGIN_INVALID");let s;try{s=new URL(e);}catch{V("CSP_ORIGIN_INVALID");}(s.protocol!==`${i}:`||s.username!==""||s.password!==""||s.search!==""||s.hash!=="")&&V("CSP_ORIGIN_INVALID");let a=s.hostname.toLowerCase();if((!a||a.includes("%"))&&V("CSP_ORIGIN_INVALID"),!a.startsWith("[")){let c=a.endsWith(".")?a.slice(0,-1):a;(c.length===0||c.length>253)&&V("CSP_ORIGIN_INVALID"),c.split(".").some(l=>l.length>63||!Br.test(l))&&V("CSP_ORIGIN_INVALID");}let d=s.origin;return (d==="null"||!d.startsWith(`${i}://`))&&V("CSP_ORIGIN_INVALID"),{origin:d,hostname:a}}function Jr(e){let n=e.split(".").map(Number);return ((n[0]*256+n[1])*256+n[2])*256+n[3]}function gi(e,n,t){let i=4294967295<<32-t>>>0;return (e&i)===(n&i)}function _i(e){let n=Jr(e);return gi(n,3221225472,24)?n!==3221225481&&n!==3221225482:Hr.some(([t,i])=>gi(n,t,i))}function Wr(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,s)=>o<<16n|BigInt(Number.parseInt(s,16)),0n)}function Xr(e){let n=Wr(e),t=Number(n>>112n),i=Number(n>>96n&0xffffn);if(n>>32n===0xffffn){let r=Number(n&0xffffffffn);return _i([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 Kr(e,n){let t=e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e,i=isIP(t);if(i===4)return _i(t);if(i===6)return Xr(t);let r=e.toLowerCase().replace(/\.$/,"");return !r||!r.includes(".")||n.has(r)?true:jr.some(o=>r===o||r.endsWith(`.${o}`))}function mi(e){return Object.freeze([...new Set(e.map(n=>n.origin))].sort())}function hi(e){return JSON.stringify({baseUriDomains:[],connectDomains:e.connectDomains,declared:e.declared,frameDomains:e.frameDomains,resourceDomains:[]})}function Ti(e,n={}){if(e===void 0){let A=hi({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")})}zr(e)||V("CSP_ORIGIN_INVALID");let t=Reflect.ownKeys(e);t.some(A=>typeof A!="string")&&V("CSP_ORIGIN_INVALID"),t.some(A=>!xr.has(A))&&V("CSP_AXIS_UNKNOWN");let i=Pn(e,"connectDomains"),r=Pn(e,"frameDomains"),o=Pn(e,"resourceDomains"),s=Pn(e,"baseUriDomains");(o.length>0||s.length>0)&&V("CSP_AXIS_UNSUPPORTED"),($r(e)>Cr||i.length>Ai||r.length>Ai||i.length+r.length>kr||[...i,...r].some(A=>new TextEncoder().encode(A).byteLength>wr))&&V("CSP_LIMIT_EXCEEDED");let d=i.map(A=>Ii(A,"connectDomains")),c=r.map(A=>Ii(A,"frameDomains")),p=new Set((n.runtimeHostnames??[]).map(A=>A.toLowerCase().replace(/\.$/,"")));[...d,...c].some(A=>Kr(A.hostname,p))&&V("CSP_ORIGIN_FORBIDDEN");let l={declared:true,connectDomains:mi(d),frameDomains:mi(c)},u=hi(l);return Object.freeze({...l,resourceDomains:Object.freeze([]),baseUriDomains:Object.freeze([]),cspHash:createHash("sha256").update(u,"utf8").digest("hex")})}var Cr,Ai,kr,wr,xr,jr,vr,Vr,Fr,Br,Hr,yt,Ei=w(()=>{g();Cr=4096,Ai=16,kr=32,wr=512,xr=new Set(["connectDomains","frameDomains","resourceDomains","baseUriDomains"]),jr=["localhost","local","internal","home.arpa","test","example","invalid","onion","lan","corp","home","intranet","private","localdomain"],vr=/^(https|wss):\/\/([^/?#]+)$/i,Vr=/^\[[^\]]+\](?::[0-9]+)?$/,Fr=/^[^:\[\]]+(?::[0-9]+)?$/,Br=/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/,Hr=[[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]],yt=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 Ds(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(s=>!i.has(s));r!==void 0&&y("MANIFEST_INVALID","MANIFEST_INVALID",r,"unknown-key");let o=n.find(s=>!U(e,s));o!==void 0&&y("MANIFEST_INVALID","MANIFEST_INVALID",o,"missing-key");}function On(e,n=false,t=false,i=false){return Qr.test(e)||!i&&ns.test(e)||es.test(e)||t&&Di.test(e)||ts.test(e)&&!(n&&/^\s*data:/i.test(e)&&!Di.test(e))}function Ln(e,n=new Set,t=0,i=false,r=false,o=""){if(typeof e=="string"){On(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((s,a)=>Ln(s,n,t+1,!1,!1,sn(o,`[${a}]`)));return}H(e)||y("MANIFEST_INVALID","MANIFEST_INVALID",o);for(let[s,a]of Object.entries(e))Ln(a,n,t+1,i&&t===0&&(s==="name"||s==="description"),r,sn(o,s));}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 At(e){return Zr.test(e)||y("MANIFEST_INVALID"),e}function $e(e){return qr.test(e)||y("TOKEN_INVALID"),e}function Ns(e){return Ui.test(e)||y("MANIFEST_INVALID"),e}function bs(e){H(e)||y("MANIFEST_INVALID");let n={};for(let[t,i]of Object.entries(e)){let r=Ns(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 s=ue(i,"min",0),a=ue(i,"max",1);s>a&&y("MANIFEST_INVALID"),n[r]={type:o,min:s,max:a,labelMaxLength:ue(i,"labelMaxLength",1),detailMaxLength:ue(i,"detailMaxLength",1)};continue}typeof o=="string"&&y("SCHEMA_TYPE_UNSUPPORTED"),y("MANIFEST_INVALID");}return n}function Ps(e,n,t){let i=e[n];(!i||i.type!==t)&&y("MANIFEST_INVALID");}function Mn(e,n,t){let i=me(e,"field");return Ui.test(i)||y("MANIFEST_INVALID"),Ps(n,i,t),i}function Ms(e,n){H(e)||y("MANIFEST_INVALID");let t=e.primitive;switch(typeof t!="string"&&y("MANIFEST_INVALID"),Es.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:Mn(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:Mn(e,n,"text"),variant:"callout"};case "step-flow":return J(e,["primitive","titleToken","field"]),{primitive:t,titleToken:$e(me(e,"titleToken")),field:Mn(e,n,"step-list")};case "text-list":{J(e,["primitive","titleToken","field"],["emptyToken","hideWhenEmpty"]);let i={primitive:t,titleToken:$e(me(e,"titleToken")),field:Mn(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 Ss(e,n){return Array.isArray(e)||y("MANIFEST_INVALID"),e.map(t=>Ms(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 Ni(e,n){return (typeof e!="string"||e.length===0||e.length>4096||e.trim().length===0||hs.test(e)||_s.test(e))&&y("MANIFEST_INVALID",`${n} is invalid`),(On(e,true,true)||is.test(e)||os.test(e)||rs.test(e))&&y("UNSAFE_VALUE",`${n} contains an unsafe value`),e}function It(e,n){return (typeof e!="string"||!ge.test(e))&&y("MANIFEST_INVALID",`${n} is invalid`),e}function Ls(e){return (typeof e!="string"||!it.test(e)||e==="*"||e==="all")&&y("MANIFEST_INVALID","action capability is invalid"),e}function Ci(e){return (typeof e!="string"||!ms.test(e))&&y("MANIFEST_INVALID","resource hash is invalid"),e}function gt(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)=>gt(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))gt(o,n,t+1,sn(i,r));}finally{n.delete(e);}}}function ki(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 mt(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=ki(i);t.has(r)&&y("MANIFEST_INVALID","projection allowlist contains a duplicate path"),t.add(r),n.push(r);}return {allow:n}}function Os(e,n){if(e===void 0)return;Array.isArray(e)||y("MANIFEST_INVALID","dataPaths must be an array"),e.length>Ts&&W("dataPaths exceed the v2 limit");let t=[],i=new Set;for(let r of e){let o=ki(r);i.has(o)&&y("MANIFEST_INVALID","dataPaths contain a duplicate path"),n.some(s=>Be(o,s))||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 bi(e,n){return (typeof e!="number"||!Number.isFinite(e))&&y("MANIFEST_INVALID",`${n} is invalid`),e}function ht(e,n=0,t=new Set){if(typeof e=="string")return (e.length>4096||On(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=>ht(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]=ht(o,n+1,t);return i}finally{t.delete(e);}}function Rs(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 Us(e,n){let t=n?tn:Nn;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 _t(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(a=>a!=="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(a=>ht(a))),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=bi(e.minimum,"schema minimum")),U(e,"maximum")&&(o.maximum=bi(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=_t(e.items,n+1,false))),i==="object"){let a;if(U(e,"properties")){H(e.properties)||y("MANIFEST_INVALID","schema properties must be an object");let c=Object.entries(e.properties);c.length>64&&W("schema properties are too many"),a={};for(let[p,l]of c){let u=Us(p,t);a[u]=_t(l,n+1,false);}o.properties=a;}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 d=Rs(e.required,a);d!==void 0&&(o.required=d),U(e,"additionalProperties")&&(e.additionalProperties!==false&&y("MANIFEST_INVALID","schema additionalProperties must be false"),o.additionalProperties=false);}let s=JSON.stringify(o);return (s===void 0||Buffer.byteLength(s,"utf8")>65536)&&W("action inputSchema subtree is too large"),o}function Cs(e){let n=_t(e,0,true);return (n.type!=="object"||!n.properties)&&y("MANIFEST_INVALID","action inputSchema must declare object properties"),n}function ks(e){if(H(e)||y("MANIFEST_INVALID","action backend must be an object"),e.type==="core"){J(e,us);let n=e.handler;return (typeof n!="string"||!ot.test(n))&&y("MANIFEST_INVALID","core backend handler is invalid"),{type:"core",handler:n}}if(e.type==="skill"&&U(e,"entry"))return J(e,As),e.entry!==Ge&&y("MANIFEST_INVALID",`skill backend entry must be ${Ge}`),{type:"skill",entry:Ge};if(e.type==="skill"){J(e,fs,ys),(!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||!rt.test(i))&&y("MANIFEST_INVALID","skill backend command token is invalid"),n.push(i);let t=U(e,"env")?xs(e.env):void 0;return {type:"skill",command:n,...t===void 0?{}:{env:t}}}y("MANIFEST_INVALID","action backend type is unsupported");}function ws(e){H(e)||y("MANIFEST_INVALID","action must be an object"),J(e,ds,ps),U(e,"_meta")&&B("_meta",()=>wi(e._meta));let n=B("actionId",()=>It(e.actionId,"actionId"));et(n)&&y("MANIFEST_INVALID",`actionId "${n}" is not projection-safe`,"actionId");let t=B("capability",()=>Ls(e.capability)),i=e.mutation;typeof i!="boolean"&&y("MANIFEST_INVALID","action mutation must be boolean","mutation");let r=B("inputSchema",()=>Cs(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 s=B("resultProjection",()=>mt(e.resultProjection)),a=B("backend",()=>ks(e.backend)),d;U(e,"content")&&((a.type!=="skill"||!bn(e.content))&&y("MANIFEST_INVALID","action content declaration is invalid","content"),d=js(e.content));let c;if(U(e,"confirmation")){let p=e.confirmation;p!=="none"&&p!=="native"&&y("MANIFEST_INVALID","action confirmation is invalid","confirmation"),c=p;}return {actionId:n,capability:t,mutation:i,inputSchema:r,resultProjection:s,backend:a,...d===void 0?{}:{content:d},...o===void 0?{}:{dataInputs:o},...c===void 0?{}:{confirmation:c}}}function xs(e){return ui(e)||y("MANIFEST_INVALID","skill backend env is invalid"),Object.freeze([...e])}function js(e){return Object.freeze({...e.in===void 0?{}:{in:Object.freeze({...e.in})},...e.out===void 0?{}:{out:Object.freeze({...e.out})}})}function vs(e){return H(e)||y("INITIAL_STATE_INVALID","initialState must be an object"),J(e,Is,gs),e.path!=="ui/state.json"&&y("MANIFEST_INVALID","initialState path is not fixed"),U(e,"hash")?{path:"ui/state.json",hash:Ci(e.hash)}:{path:"ui/state.json"}}function Vs(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 Fs(e,n){let t;try{t=Ti(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 Bs(e,n){Ln(H(e)&&U(e,"csp")?Ds(e,"csp"):e,new Set,0,true,true),gt(e),H(e)||y("MANIFEST_INVALID"),J(e,as,cs),U(e,"_meta")&&B("_meta",()=>wi(e._meta)),e.manifestVersion!==2&&y("MANIFEST_INVALID");let t;U(e,"runtime")&&(t=B("runtime",()=>Vs(e.runtime)));let i;U(e,"csp")&&(i=B("csp",()=>Fs(e.csp,t)));let r=B("pluginId",()=>It(e.pluginId,"pluginId")),o=B("definitionId",()=>It(e.definitionId,"definitionId")),s=B("version",()=>ue(e,"version",1)),a=B("name",()=>Ni(e.name,"name")),d=B("description",()=>Ni(e.description,"description")),c;U(e,"icon")&&((typeof e.icon!="string"||!/^[a-z][a-z0-9-]{0,63}$/.test(e.icon))&&y("MANIFEST_INVALID","icon is invalid","icon"),c=e.icon);let p;U(e,"tone")&&((typeof e.tone!="string"||!st.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",()=>Ci(e.entryHash)));let u;U(e,"initialState")&&(u=B("initialState",()=>vs(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=[],x=new Set;for(let f of e.surfaces)(typeof f!="string"||!at.includes(f))&&y("MANIFEST_INVALID","surface is unsupported","surfaces"),x.has(f)&&y("MANIFEST_INVALID","surfaces contain a duplicate","surfaces","duplicate-item"),x.add(f),F.push(f);H(e.size)||y("MANIFEST_INVALID","size must be an object","size"),B("size",()=>J(e.size,["height"]));let M=B("size",()=>ue(e.size,"height",1));M>720&&W("size.height exceeds the v2 limit","size.height","too-large");let O=B("stateProjection",()=>mt(e.stateProjection)),z=e.summaryProjection===void 0?void 0:B("summaryProjection",()=>mt(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",()=>Os(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}]`,P=B(T,()=>ws(m));if(S.has(P.actionId)&&y("MANIFEST_INVALID","actions contain a duplicate actionId",`${T}.actionId`,"duplicate-item"),P.backend.type==="core"&&P.backend.handler==="state.set"){P.mutation||y("MANIFEST_INVALID","state.set actions must be mutations",`${T}.mutation`);for(let D of Object.keys(P.inputSchema.properties))O.allow.includes(D)||y("MANIFEST_INVALID","state.set input paths must be projection-allowed",`${T}.inputSchema.properties`);}S.add(P.actionId),L.push(P);}return {manifestVersion:2,pluginId:r,definitionId:o,version:s,name:a,description:d,...c===void 0?{}:{icon:c},...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:M},stateProjection:O,...z===void 0?{}:{summaryProjection:z},...N===void 0?{}:{dataPaths:N},actions:L}}function wi(e){H(e)||y("MANIFEST_INVALID","_meta must be an object");let n=JSON.stringify(e);(n===void 0||Buffer.byteLength(n,"utf8")>ls)&&W("_meta exceeds the 4 KiB limit",void 0,"meta-too-large");}function Hs(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 s=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:s?"allowed":"denied",...s?{}:{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 Tt(e,n,t,i,r,o){if(typeof e=="string"){let s=r.length>0&&o.some(a=>Be(r.join("."),a));return (e.length>4096||On(e,false,false,s))&&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 s;if(Array.isArray(e))e.length>128&&le("state array is too long"),s=e.map(d=>Tt(d,n,t+1,65536,r,o));else {H(e)||le("state contains a non-plain object");let d={};for(let[c,p]of Object.entries(e))(c.length>4096||!Nn.test(c)||ze(c))&&(c.length>4096&&le("state key is too long"),le("state contains a reserved or invalid key")),d[c]=Tt(p,n,t+1,65536,[...r,c],o);s=d;}let a=JSON.stringify(s);return (a===void 0||Buffer.byteLength(a,"utf8")>i)&&le("state subtree is too large"),s}finally{n.delete(e);}}function Dt(e,n=[]){H(e)||le("initial state must be a JSON object");let t=Tt(e,new Set,0,65536,[],n);return (t===null||Array.isArray(t)||typeof t!="object")&&le(),t}function zs(e,n={}){Ln(e),H(e)||y("MANIFEST_INVALID"),J(e,ss),e.manifestVersion!==1&&y("MANIFEST_INVALID");let t=At(me(e,"pluginId")),i=At(me(e,"definitionId")),r=ue(e,"version",1),o=ue(e,"primitiveSet",1),s=n.supportedPrimitiveSet??Yr;(!Number.isSafeInteger(s)||s<1)&&y("MANIFEST_INVALID"),o>s&&y("PRIMITIVE_SET_UNSUPPORTED"),H(e.activation)||y("MANIFEST_INVALID"),J(e.activation,["kind","language"]),e.activation.kind!=="fenced-code"&&y("MANIFEST_INVALID");let a=At(me(e.activation,"language")),d=bs(e.schema),c=Ss(e.layout,d);return {manifestVersion:1,pluginId:t,definitionId:i,version:r,primitiveSet:o,activation:{kind:"fenced-code",language:a},schema:d,layout:c}}function Gs(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?Bs(e,n):zs(e,n)}function an(e,n={}){try{return Gs(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?Hs(t):t}var Yr,qr,Zr,Ui,Qr,es,ns,ts,Di,is,os,rs,ss,as,cs,ds,ps,ls,us,fs,ys,As,Is,gs,ms,hs,_s,Ts,Es,re,Nt=w(()=>{g();li();Ne();pt();fi();ft();Ei();Ue();Yr=1,qr=/^[a-z][a-zA-Z0-9]*(\.[a-zA-Z0-9]+)+$/,Zr=/^[A-Za-z][A-Za-z0-9._-]{0,127}$/,Ui=/^[A-Za-z][A-Za-z0-9_-]{0,63}$/,Qr=/<\/?[A-Za-z][^>]*>/,es=/^(?:[A-Za-z]:[\\/]|\\\\|~[\\/]|\/)/,ns=/^(?:https?|file|ftp|ws|wss):\/\//i,ts=/^\s*(?:javascript|data):/i,Di=/data:[^,\s]*,/i,is=/(?:https?|file|ftp|ws|wss):\/\//i,os=/javascript:/i,rs=/(?:^[\s]*|[\s"'(=])(?:[A-Za-z]:[\\/]|\\\\|~[\\/]|\/)(?=[^\s"'<>])[^\s"'<>]*/,ss=["manifestVersion","pluginId","definitionId","version","primitiveSet","activation","schema","layout"],as=["manifestVersion","pluginId","definitionId","version","name","description","entry","surfaces","size","stateProjection","actions"],cs=["_meta","icon","tone","entryHash","runtime","csp","initialState","usage","detailPanel","displayModes","summaryProjection","dataPaths","focusedAiDataPaths"],ds=["actionId","capability","mutation","inputSchema","resultProjection","backend"],ps=["confirmation","dataInputs","content","_meta"],ls=4*1024,us=["type","handler"],fs=["type","command"],ys=["env"],As=["type","entry"],Is=["path"],gs=["hash"],ms=/^[0-9a-f]{64}$/,hs=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/,_s=/[\r\n]/,Ts=16,Es=["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 Bi(e){return typeof e=="string"&&e.length<=Js&&$s.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 Ys(e){return e.toLowerCase().replace(/_/g,"-")}function qs(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 Hi(e,n,t){return {path:t(e.path),rule:e.rule??Ys(e.code),...e.message!==e.code?{message:e.message}:{},file:n}}function zi(e){return JSON.parse(JSON.stringify(e))}function Mt(e,n,t=0,i=new Set){if(typeof e=="string"){e.length>4096&&C("LIMIT_EXCEEDED",n,"string-too-long"),(Ws.test(e)||Xs.test(e)||Ks.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)=>Mt(r,`${n}[${o}]`,t+1,i));return}Q(e)||C("MANIFEST_INVALID",n,"non-plain-object");for(let[r,o]of Object.entries(e))Mt(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 Zs(e,n){Array.isArray(e)||C("MANIFEST_INVALID",n,"array"),e.forEach((t,i)=>fe(t,`${n}[${i}]`));}function Qs(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 ea(e,n){switch(Mt(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":Zs(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":Qs(n,e);return;case "localization":case "compatibility":case "user_config":Xe(n,e);return;default:C("MANIFEST_INVALID",e,"unknown-key");}}function Rn(e){return typeof e=="string"&&ge.test(e)?e:void 0}function Gi(e){return Number.isSafeInteger(e)&&e>=1?e:void 0}function na(e){let n=Rn(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")?Rn(r.definitionId):n,s=X(r,"definitionVersion")?Gi(r.definitionVersion):1;return {pluginId:n,...o===void 0?{}:{definitionId:o},...s===void 0?{}:{definitionVersion:s}}}function ta(e){let n=Rn(e.pluginId);if(n===void 0)return;let t=Rn(e.definitionId),i=Gi(e.version);return {pluginId:n,...t===void 0?{}:{definitionId:t},...i===void 0?{}:{definitionVersion:i}}}function Rt(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 ia(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 oa(e,n){X(e,"server")&&C("MANIFEST_INVALID","server","server-unsupported","phase 1 runs CrewX-owned Apps only");for(let a of Object.keys(e))Lt.includes(a)||C("MANIFEST_INVALID",a,"unknown-key");for(let a of Ot)X(e,a)||C("MANIFEST_INVALID",a,"missing-key");e.manifest_version!==bt&&C("MANIFEST_INVALID","manifest_version","unsupported-version",`manifest_version must be "${bt}"`),Bi(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 a of Object.keys(i))Pt.includes(a)||Fi.includes(a)||C("MANIFEST_INVALID",ye(a),"unknown-key");for(let a of Pt)a==="actions"&&n!==void 0||X(i,a)||C("MANIFEST_INVALID",ye(a),"missing-key");if(n!==void 0&&X(i,"actions")&&C("MANIFEST_INVALID",ye("actions"),"two-truths",`actions are declared in both ${K} and ${q}; a server.ts App keeps them in the tools file only`),ra(i.actions),X(i,"definitionVersion")){let a=i.definitionVersion;(!Number.isSafeInteger(a)||a<1)&&C("MANIFEST_INVALID",ye("definitionVersion"),"positive-integer");}let r={};for(let a of Vi)X(e,a)&&(ea(a,e[a]),r[a]=zi(e[a]));let o={};for(let[a,d]of Object.entries(t))a!==Se&&(o[a]=d);let s={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[a,d]of Object.entries(i))a==="definitionId"||a==="definitionVersion"||(s[a]=d);return n!==void 0&&(s.actions=n.map(a=>({...a,backend:{type:"skill",entry:Ge}}))),Object.keys(o).length>0&&(s._meta=o),{v2Input:s,...Object.keys(o).length>0?{vendorMeta:o}:{},passthrough:r}}function ra(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 ${q}`);});}function sa(e,n,t){Q(e)||C("MANIFEST_INVALID","","not-object","manifest.json must be a JSON object",K);let i;try{i=oa(e,t);}catch(s){throw s instanceof _e?new _e(s.code,{...s.reason,file:K}):s}let r;try{let s=an(i.v2Input,{mode:n.mode??"local"});s.manifestVersion!==2&&C("MANIFEST_INVALID","","v2-required"),r=s;}catch(s){throw s instanceof re?new _e(s.code,Hi(s,K,qs)):s}let o=e.tools;if(Array.isArray(o)){let s=new Set(r.actions.map(a=>a.actionId));o.forEach((a,d)=>{let c=a.name;if(!s.has(c))throw new _e("MANIFEST_INVALID",{path:`tools[${d}].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 aa(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,Hi(t,we,i=>i??"")):t}}function St(e){return oe(cn(e).definition)}function ji(e){let{entryHash:n,initialState:t,...i}=e,r={...i};return t!==void 0&&(r.initialState={path:t.path}),zi(r)}function ca(e,n){let t=ji(e),i=ji(n);return [...new Set([...Object.keys(t),...Object.keys(i)])].sort().filter(o=>Z(t[o]??null)!==Z(i[o]??null))}function da(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 pa(e,n){let t=ca(e,n),i=da(e,n),r="";try{let o=St(e),s=St(n);i=i||o!==s,r=` (definition hash ${o.slice(0,12)} vs ${s.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:q},files:[]}}function vi(e){return {...he("","tools-needs-manifest-json","MANIFEST_INVALID",`${q} is read with ${K} only`),files:e}}function la(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",`${q} 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 ${q} cannot carry a backend`)}}return {actions:i}}function ua(e,n){let t=n.maxBytes??262144,i=[],r=new TextDecoder("utf-8",{fatal:true});for(let o of se){let s=e[o];if(s===void 0)continue;if(s.byteLength>t)return {parsed:i,failure:{code:"LIMIT_EXCEEDED",reason:{path:"",rule:"file-too-large",file:o},files:[o]}};let a;try{a=JSON.parse(r.decode(s));}catch{return {parsed:i,failure:{code:"MANIFEST_INVALID",reason:{path:"",rule:"invalid-json",file:o},files:[o]}}}if(!Q(a))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:a});}return {parsed:i}}function Ut(e,n={}){let{parsed:t,failure:i}=ua(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[q],s=o===void 0?void 0:la(o,n.maxBytes??262144);if(t.length===0)return {ok:false,rejection:s===void 0?{code:"MANIFEST_INVALID",reason:{path:"",rule:"no-manifest-file",message:"neither manifest.json nor ui-plugin.json is present"},files:[]}:vi(r),parseFailure:true,builtinOnly:false};let a=t[0],d=a.file===K?na(a.raw):ta(a.raw),c=t.some(A=>ia(A.file,A.raw)),p;if(s!==void 0){let A=t.some(I=>I.file===K)?s.failure:vi(r);if(A!==void 0)return {ok:false,rejection:A,parseFailure:false,...d===void 0?{}:{identity:d},builtinOnly:c};p=s.actions;}let l=[];try{for(let A of t)l.push(A.file===K?sa(A.raw,n,p):aa(A.raw,n));l.length===2&&pa(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===q?r:[A.reason.file]},parseFailure:false,...d===void 0?{}:{identity:d},builtinOnly:c};throw A}let u=l[0];return {ok:true,...u,identity:d??{pluginId:u.manifest.pluginId},files:r}}var K,we,se,bt,Se,Lt,Ot,Vi,Pt,Fi,$s,Js,Ws,Xs,Ks,_e,Ct=w(()=>{g();Ce();Ne();ft();Ue();Nt();K="manifest.json",we="ui-plugin.json",se=[K,we],bt="0.3",Se="dev.crewx",Lt=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"]),Ot=Object.freeze(["manifest_version","name","display_name","version","description","_meta"]),Vi=Object.freeze(Lt.filter(e=>e!=="server"&&!Ot.includes(e))),Pt=Object.freeze(["entry","surfaces","size","stateProjection","actions"]),Fi=Object.freeze(["definitionId","definitionVersion","icon","tone","entryHash","runtime","initialState","usage","detailPanel","displayModes","summaryProjection","dataPaths","focusedAiDataPaths","csp"]),$s=/^(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-]+)*))?$/,Js=256,Ws=/<\/?[A-Za-z][^>]*>/,Xs=/^\s*javascript:/i,Ks=/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 $i=w(()=>{g();pi();Ct();Nt();Ue();});function E(e,n=e){throw new Te(e,n)}var Te,Cn=w(()=>{g();Te=class extends Error{constructor(t,i=t){super(i);this.code=t;}code;name="McpAppContractError"};});var Ji=w(()=>{g();});var Wi=w(()=>{g();Ce();Ne();Cn();Ji();});function Ki(e,n){return Xi.add(e),n!==void 0&&fa.set(e,n),e}function Ke(e){return e!==null&&typeof e=="object"&&Xi.has(e)}var Xi,fa,kn=w(()=>{g();Xi=new WeakSet,fa=new WeakMap;});function un(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function kt(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 Zi(e){if(e===null||typeof e!="object"||Object.isFrozen(e))return e;for(let n of Object.values(e))Zi(n);return Object.freeze(e)}function ee(e){throw new Ee("LINEAGE_INVALID",e)}function _a(e){throw new Ee("LINEAGE_STALE",e)}function Qi(e){if(!un(e)||!kt(e,Ia,ga)||!un(e.actions))return ee("Lineage definition shape is invalid");for(let n of Object.values(e.actions))if(!un(n)||!kt(n,ma,ha))return ee("Lineage action definition shape is invalid");return e}function Ta(e){if(!un(e)||!kt(e,ya,Aa))return ee("Lineage entry shape is invalid");if(!Number.isSafeInteger(e.version)||e.version<1||typeof e.hash!="string"||!Yi.test(e.hash))return ee("Lineage entry identity is invalid");if(e.sourceHash!==void 0&&(typeof e.sourceHash!="string"||!Yi.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=Qi(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"):Zi({version:e.version,hash:e.hash,definition:n,...e.sourceHash===void 0?{}:{sourceHash:e.sourceHash},...e.compat===void 0?{}:{compat:e.compat}})}function qi(e){return e.stateProjection?.allow??[]}function Ea(e,n){let t=[],i=new Set(qi(n));qi(e).some(a=>!i.has(a))&&t.push("S1_STATE_PROJECTION");let r=new Set(n.dataPaths??[]);(e.dataPaths??[]).some(a=>!r.has(a))&&t.push("S2_DATA_PATHS");for(let[a,d]of Object.entries(e.actions)){let c=n.actions[a];if(c&&(d.confirmation??"native")==="native"&&(c.confirmation??"native")!=="native"){t.push("S3_ACTION_CONFIRMATION");break}}Object.keys(e.legacy?.agentAccess??{}).some(a=>!Object.hasOwn(n.actions,a))&&t.push("S4_LEGACY_AGENT_ACTIONS");let s=e.summaryProjection?.allow;if(s!==void 0){let a=new Set(n.summaryProjection?.allow??[]);s.some(d=>!a.has(d))&&t.push("S5_SUMMARY_PROJECTION");}return t}function Da(e,n){return Z(e)===Z(n)}function wt(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:a,...d}=n;i=Qi(d),t={...i,hash:a},pe(t);}catch{return ee("Current definition is invalid")}let r=e.map(Ta),o=r[0].definition.id;if(r.some(a=>a.definition.id!==o))return ee("Lineage definition ids do not match");if(r.some((a,d)=>d>0&&a.version<=r[d-1].version))return ee("Lineage generations are not in increasing version order");if(r.some((a,d)=>r.findIndex(c=>c.hash===a.hash)!==d))return ee("Lineage contains a duplicate hash");let s=r[r.length-1];if(s.version!==t.version||s.hash!==t.hash||s.definition.id!==t.id||!Da(s.definition,i))return _a("The last lineage generation does not match the current package");if(t.legacy!==void 0){let a=new Set(Object.keys(t.actions)),d=new Set;for(let p of r)if(p.sourceHash===void 0)for(let l of Object.keys(p.definition.actions))a.has(l)&&d.add(l);let c=Object.keys(t.legacy.agentAccess??{});if(c.length!==d.size||c.some(p=>!d.has(p))){let p="S4_LEGACY_AGENT_ACCESS_COMPLETE";throw new Ee("LINEAGE_INVALID",`Lineage compatibility failed: ${p}`,[p])}}for(let a=0;a<r.length-1;a+=1){if(r.slice(a,-1).some(p=>p.compat==="break"))continue;let c=Ea(r[a].definition,t);if(c.length>0)throw new Ee("LINEAGE_INVALID",`Lineage compatibility failed: ${c.join(", ")}`,c)}return Object.freeze({entries:Object.freeze(r),current:t})}var Ee,Yi,ya,Aa,Ia,ga,ma,ha,xt=w(()=>{g();Ce();Ne();Ee=class extends Error{constructor(t,i=t,r=[]){super(i);this.code=t;this.violations=r;}code;violations;name="UiDefinitionLineageError"},Yi=/^[0-9a-f]{64}$/,ya=["version","hash","definition"],Aa=["sourceHash","compat"],Ia=["id","version","actions"],ga=["sourceHash","usage","detailPanel","displayModes","renderer","surfaces","stateProjection","dataPaths","summaryProjection","legacy"],ma=["capabilities"],ha=["inputKeys","dataInputs","confirmation","resultProjection","content","env"];});var eo,no,to,jt,io=w(()=>{g();eo="text/html;profile=mcp-app",no=["crewx_app_terminal_connect","crewx_app_html_viewer_open"],to=["crewx_listWorkspaces","crewx_queryAgent","crewx_executeAgent","crewx_getTaskResult","crewx_listTasks","crewx_listAgents","callBrowser","openTab","listTabs","closeTab"],jt="text/html";});function oo(e,n=[],t){if(e.content!==void 0||e.confirmation!=="none")return "denied";let i=Na();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==="skill"?"approval_required":e.backend===void 0&&n.includes(e.actionId)?"allowed":"denied"}function Na(e){return;}var ro=w(()=>{g();Ce();kn();});function Ca(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"||!ao.test(e))&&E(n,`${t} must be a safe identifier`),e}function fn(e,n,t){let i=e??t;return (typeof i!="string"||i.trim().length===0||i.length>Ma)&&E("TOOL_INVALID",`${n} must be a meaningful description`),i}function Vt(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 yn(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 ka(e){return (typeof e!="string"||e.trim().length===0||e.length>Sa)&&E("TOOL_INVALID","MCP App tools require a meaningful text fallback"),e}function wa(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 lo(e){return (typeof e!="string"||!co.test(e))&&E("RESOURCE_URI_INVALID","MCP App resource URI is not a registered ui:// URI"),e}function uo(e){let n=Re(e.appId,"APP_ID_INVALID","Local App id"),t=fn(e.name,"Local App name",n),i=fn(e.description,"Local App description",`${t} interactive view`),r=vn(e.definition),o=Vt(e.html),s=wn(e.entryHash,"Local App entry hash"),a=e.entryBytes===void 0?Array.from(new TextEncoder().encode(o)):jn(e.entryBytes,"Local App entry bytes");(xn(a)!==s||Ao(a)!==o)&&E("HTML_INVALID","Local App entry bytes do not match the HTML hash");let d=xa(e),c=[];Array.isArray(e.actions)||E("TOOL_INVALID","Local App actions must be an array");for(let M of e.actions){let O=Re(M.actionId,"TOOL_ID_INVALID","Local App action id");(c.includes(O)||!Object.prototype.hasOwnProperty.call(r.actions,O))&&E("TOOL_INVALID",`Local App action is not declared by the UI definition: ${O}`),c.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");c.length===0&&l!==void 0&&E("TOOL_INVALID","A static local App cannot register an action tool"),c.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=Ca(e.runtime);u.some(M=>M.name===p||M.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:Ua,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(M=>Object.freeze(M))),l!==void 0){let M={name:l,description:`${t} actions`,inputSchema:Ft(e.actions),textFallback:`${t} action requests are handled by the open App instance.`,visibility:Object.freeze(["app"]),kind:"action",resourceBinding:Oe,actionIds:Object.freeze([...c])};I.push(Object.freeze(M));}let h=[],b=new Set(I.map(M=>M.name));if(l!==void 0)for(let M of e.actions){let O=`${l}__${M.actionId}`;if(O.length>128||!ao.test(O)){h.push(Object.freeze({toolName:O,actionId:M.actionId,reason:"name_too_long"}));continue}if(b.has(O)){h.push(Object.freeze({toolName:O,actionId:M.actionId,reason:"name_collision"}));continue}let z=oo({actionId:M.actionId,confirmation:r.actions[M.actionId]?.confirmation,content:r.actions[M.actionId]?.content,backend:M.backend},e.modelActions),N=Object.freeze(z==="denied"?["app"]:["model","app"]),L={name:O,description:`${O} action`,inputSchema:yn(M.inputSchema),textFallback:`${O} action requests are handled by the open App instance.`,visibility:N,kind:"action",resourceBinding:Oe,actionId:M.actionId,actionIds:Object.freeze([M.actionId]),_meta:Object.freeze({ui:Object.freeze({visibility:N})})};I.push(Object.freeze(L)),b.add(O);}let F={mimeType:jt,entryHash:s,html:o,bytes:Object.freeze([...a]),...d===void 0?{}:{initialState:Object.freeze({hash:d.hash,bytes:Object.freeze([...d.bytes])})}},x={appId:n,name:t,description:i,...e.icon===void 0?{}:{icon:Io(e.icon)},...e.tone===void 0?{}:{tone:go(e.tone)},builtinOnly:false,definition:r,...e.runtime===void 0?{}:{runtime:Object.freeze({...e.runtime})},resourceBinding:Oe,resource:Object.freeze(F),tools:Object.freeze(I),toolDiagnostics:Object.freeze(h)};return Y(x)}function fo(e={}){return new vt(e)}function Ft(e){if(e.length===0)return yn({type:"object",properties:{},additionalProperties:false});let n=e.map(i=>i.actionId),t=new Map;for(let i of e)t.set(i.actionId,yn(i.inputSchema));return yn(ja(n,t),po)}function xa(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=wn(e.initialStateHash,"Initial state hash"),i=jn(e.initialStateBytes,"Initial state bytes");xn(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 ja(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 va(e){let n=An(e),t=Re(n.appId,"APP_ID_INVALID","MCP App id"),i=Vt(n.html);lo(n.uiUri);let r=n.definition===void 0?void 0:vn(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 s=Object.freeze(n.tools.map(c=>Y(An(c)))),a=Y({...n,appId:t,html:i,...r===void 0?{}:{definition:r},...o===void 0?{}:{provenance:o},tools:s}),d=Y({uri:a.uiUri,mimeType:eo,text:i,...a.csp===void 0?{}:{_meta:{ui:{csp:a.csp}}}});return Y({appId:t,name:a.name,description:a.description,...a.icon===void 0?{}:{icon:a.icon},...a.tone===void 0?{}:{tone:a.tone},builtinOnly:a.builtinOnly,uiUri:a.uiUri,...r===void 0?{}:{definition:r},resourceBinding:Object.freeze({kind:"mcp",uri:a.uiUri}),resource:d,tools:s,descriptor:a})}function Va(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=vn(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=Vt(e.resource.html),o=wn(e.resource.entryHash,"Local App entry hash"),s=jn(e.resource.bytes,"Local App entry bytes");(xn(s)!==o||Ao(s)!==r)&&E("HTML_INVALID","Local App entry bytes do not match the HTML hash");let a=e.resource.initialState===void 0?void 0:{hash:wn(e.resource.initialState.hash,"Initial state hash"),bytes:jn(e.resource.initialState.bytes,"Initial state bytes")};a&&xn(a.bytes)!==a.hash&&E("STATE_INVALID","Initial state bytes do not match the hash");let d=e.tools.map(c=>{Re(c.name,"TOOL_ID_INVALID","Local App tool name"),fn(c.description,"Local App tool description","Local App tool"),ka(c.textFallback);let p=yn(c.inputSchema,c.kind==="action"&&!("actionId"in c)?po:0);if((c.resourceBinding.kind!=="instance"||Object.prototype.hasOwnProperty.call(c,"resourceUri"))&&E("TOOL_INVALID","Local App tools cannot carry an MCP resource URI"),c.kind==="host")return (!Ra.has(c.name)||c.visibility.length!==1||c.visibility[0]!=="app"||Object.prototype.hasOwnProperty.call(c,"actionId"))&&E("TOOL_INVALID","Local App Host tools must use an allow-listed name and app-only visibility"),Y({...c,inputSchema:p,visibility:Object.freeze(["app"])});if(c.kind==="action"){if("actionId"in c){let u=Re(c.actionId,"TOOL_ID_INVALID","Local App action id");Object.prototype.hasOwnProperty.call(t.actions,u)||E("TOOL_INVALID","Local App action tool references an undeclared action");let A=wa(c._meta.ui.visibility);return JSON.stringify(A)!==JSON.stringify(c.visibility)&&E("TOOL_INVALID","Local App action metadata visibility must match the tool visibility"),Y({...c,actionId:u,actionIds:Object.freeze([u]),inputSchema:p,visibility:A,_meta:{ui:{visibility:A}}})}let l=[...c.actionIds];return (l.length===0||l.some(u=>!Object.prototype.hasOwnProperty.call(t.actions,u)))&&E("TOOL_INVALID","Local App action tool references an undeclared action"),Y({...c,inputSchema:p,actionIds:Object.freeze(l)})}return Y({...c,inputSchema:p})});return Y({appId:n,name:fn(e.name,"Local App name",e.appId),description:fn(e.description,"Local App description",e.name),...e.icon===void 0?{}:{icon:Io(e.icon)},...e.tone===void 0?{}:{tone:go(e.tone)},builtinOnly:false,definition:t,...e.runtime===void 0?{}:{runtime:Object.freeze({...e.runtime})},...i===void 0?{}:{provenance:i},resourceBinding:Oe,resource:Y({mimeType:jt,entryHash:o,html:r,bytes:Object.freeze([...s]),...a===void 0?{}:{initialState:Object.freeze({hash:a.hash,bytes:Object.freeze([...a.bytes])})}}),tools:Object.freeze(d),toolDiagnostics:Object.freeze([...e.toolDiagnostics??[]])})}function Fa(e){return Y({appId:e.appId,name:e.name,description:e.description,...e.icon===void 0?{}:{icon:e.icon},...e.tone===void 0?{}:{tone:e.tone},builtinOnly:false,definition:yo(e.definition),...e.provenance===void 0?{}:{provenance:e.provenance},entryHash:e.resource.entryHash,resourceBinding:Oe,tools:e.tools})}function Ba(e){return Y({appId:e.appId,name:e.name,description:e.description,...e.icon===void 0?{}:{icon:e.icon},...e.tone===void 0?{}:{tone:e.tone},builtinOnly:e.builtinOnly,uiUri:e.uiUri,...e.definition===void 0?{}:{definition:yo(e.definition)},resourceBinding:Object.freeze({kind:"mcp",uri:e.uiUri}),tools:e.tools})}function vn(e){try{if(Object.isFrozen(e))return pe(e),Y(e);let n=An(e);return pe(n),Y(n)}catch(n){if(n instanceof Te)throw n;E("STATE_INVALID","UI definition is not a valid immutable definition");}}function yo(e){return Y({id:e.id,version:e.version,hash:e.hash})}function Ha(e){return e!==null&&typeof e=="object"&&typeof e.id=="string"&&Number.isSafeInteger(e.version)&&typeof e.hash=="string"}function so(e,n,t){return `${e}\0${n}\0${t}`}function wn(e,n){return (typeof e!="string"||!Pa.test(e))&&E("SERIALIZATION_INVALID",`${n} is invalid`),e}function xn(e){return createHash("sha256").update(Uint8Array.from(e)).digest("hex")}function jn(e,n){return (!Array.isArray(e)||e.some(t=>!Number.isInteger(t)||t<0||t>255))&&E("SERIALIZATION_INVALID",`${n} is invalid`),[...e]}function Ao(e){try{return new TextDecoder("utf-8",{fatal:!0}).decode(Uint8Array.from(e))}catch{E("SERIALIZATION_INVALID","UTF-8 bytes are invalid");}}function Io(e){return (typeof e!="string"||!La.test(e))&&E("TOOL_INVALID","MCP App icon is invalid"),e}function go(e){return (typeof e!="string"||!Oa.has(e))&&E("TOOL_INVALID","MCP App tone is invalid"),e}function An(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 s of e)o.push(An(s,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,s]of Object.entries(e))Object.defineProperty(r,o,{configurable:true,enumerable:true,value:An(s,n),writable:true});return n.delete(t),r}function Y(e,n=new Set){if(e===null||typeof e!="object"||n.has(e))return e;n.add(e);for(let t of Object.values(e))Y(t,n);return Object.freeze(e),e}var ao,co,Pa,Ye,Ma,Sa,La,Oa,Ra,Oe,Ua,po,vt,Vn=w(()=>{g();Wi();Ce();Ne();kn();Cn();xt();io();ro();ao=/^[A-Za-z][A-Za-z0-9._-]{0,127}$/,co=/^ui:\/\/crewx\/([A-Za-z][A-Za-z0-9._-]{0,127})\/([0-9a-f]{12})$/,Pa=/^[0-9a-f]{64}$/,Ye=8*1024*1024,Ma=8*1024,Sa=16*1024,La=/^[a-z][a-z0-9-]{0,63}$/,Oa=new Set(["blue","violet","emerald","amber","rose","sky","slate","indigo"]),Ra=new Set(no),new Set(to),Oe=Object.freeze({kind:"instance"}),Ua=Object.freeze({type:"object",properties:Object.freeze({}),additionalProperties:false});po=4;vt=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=[],s=new Set,a=new Set;for(let l of t?.listMcpApps()??[]){let u=va(l);s.has(u.appId)&&E("APP_ID_CONFLICT",`MCP App id is already registered: ${u.appId}`),s.add(u.appId);let A=u.tools;for(let I of A)a.has(I.name)&&E("TOOL_ID_CONFLICT",`MCP App tool name is already registered: ${I.name}`),a.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 d=(n.localApps??n.locals??[]).map(Va),c=new Set(d.flatMap(l=>l.tools.filter(u=>!(u.kind==="action"&&"actionId"in u)).map(u=>u.name))),p=[];for(let l of d){let u=l;s.has(u.appId)&&E("APP_ID_CONFLICT",`MCP App id is already registered: ${u.appId}`),s.add(u.appId);let A=[],I=[...u.toolDiagnostics??[]];for(let h of u.tools){if(a.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&&c.has(h.name)){I.push(Object.freeze({toolName:h.name,actionId:h.actionId,reason:"name_collision"}));continue}a.add(h.name),this.localToolByName.set(h.name,h),A.push(h);}(A.length!==u.tools.length||I.length!==(u.toolDiagnostics?.length??0))&&(u=Y({...u,tools:Object.freeze(A),toolDiagnostics:Object.freeze(I)})),p.push(u),this.localById.set(u.appId,u);}for(let l of i)this.registrationById.set(l.appId,l),this.launcherById.set(l.appId,Ba(l)),l.definition&&this.addDefinition(l.definition);for(let l of p)this.registrationById.set(l.appId,l),this.launcherById.set(l.appId,Fa(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"||!co.test(n)?null:this.mcpResources.get(n)??null}requireMcpAppResource(n){lo(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}))}getLauncher(n){return this.launcherById.get(n)??null}resolveDefinition(n){if(!Ha(n))return null;let t=this.definitionByKey.get(ut(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(so(n,t,i))??null}addDefinition(n){let t=vn(n),i=ut(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=so(n.definitionId,n.version,n.actionId);this.handlerByKey.has(t)&&E("TOOL_INVALID",`Duplicate UI action handler registration: ${t}`),this.handlerByKey.set(t,Object.freeze({...n}));}};});function za(e){let n=uo({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 mo(e){let n=e.normalized.manifest.actions;if(n.some(i=>i.backend.type==="skill")&&n.some(i=>i.backend.type==="core"))throw new Error("Mixed workspace App execution models");let t=za(e);fo({localApps:[t],definitions:[e.definition]});}var ho=w(()=>{g();Vn();});function _o(){return Object.freeze({[Bt]:{candidates:new Map,assetCatalogs:new Map}})}function Ga(e){if(e===null||typeof e!="object"||!(Bt in e))throw new TypeError("scanCache must be created by createWorkspaceAppScanCache");return e[Bt]}function To(e,n){let t=Ga(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.lastCandidateScanUnchanged=void 0,t.lastCandidateKeys=void 0,t.scanStartedAtNs=void 0,t.lastAssetCatalogsUnchanged=void 0,t.lastSnapshot=void 0,t.lastSnapshotBuildInputs=void 0),t.rootIdentity=n,t}var Bt,Eo=w(()=>{g();Bt=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 Xa(e){if(typeof e!="string"||e.length===0||!isAbsolute(e))throw new _("READ_DENIED")}function Ht(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 zn(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 Jt(e,n){return e.dev===n.dev&&e.ino===n.ino}function Wt(e,n){return Jt(e,n)&&e.size===n.size&&e.mtimeNs===n.mtimeNs&&e.ctimeNs===n.ctimeNs}async function Fn(e){Xa(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 bo(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(!zn(n,r))throw new _("PATH_ESCAPED");return r}async function Bn(e,n,t,i){let r,o,s;try{r=await lstat(e,{bigint:!0}),o=await realpath(e),s=await stat(o,{bigint:!0});}catch(a){throw ae(a)}if(!zn(n,o)||t!==void 0&&!zn(t,o))throw new _("PATH_ESCAPED");if(!r.isFile()||!s.isFile())throw new _("READ_DENIED");if(!Jt(i,r)||!Jt(i,s)||i.dev!==s.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||!Wt(n.identity,Ze(i)))throw new _("PATH_ESCAPED")}function Ka(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 _,$t,Wa,No,Qe,Gn,Po,Mo,Kt=w(()=>{g();_=class extends Error{constructor(t){super(t);this.code=t;}code;name="AppDiscoveryFsError"},$t=constants.O_NOFOLLOW,Wa=constants.O_NONBLOCK,No=constants.O_RDONLY|($t??0)|(Wa??0);Qe=class{async getRootIdentity(n){let t=await Fn(n);return await qe(n,t),{dev:t.identity.dev,ino:t.identity.ino,realPath:t.realRoot}}async listDirectory(n,t){let i=Ht(t),r=await Fn(n),o=resolve(n,...i),s,a;try{s=await realpath(o),a=await stat(s,{bigint:!0});}catch(d){let c=ae(d);if(c.code==="NOT_FOUND")return [];throw c}if(!zn(r.realRoot,s)||!a.isDirectory())throw new _("PATH_ESCAPED");try{let d=await readdir(s,{withFileTypes:!0,encoding:"utf8"});return await qe(n,r),d.map(Ka)}catch(d){let c=ae(d);if(c.code==="NOT_FOUND")return [];throw c}}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($t===void 0)throw new _("UNSUPPORTED");let r=Ht(t),o=await Fn(n),s=resolve(n,...r),a=relative(n,s);if(a===".."||a.startsWith(`..${sep}`)||isAbsolute(a))throw new _("PATH_ESCAPED");let d;try{d=await open(s,No);}catch(c){throw ae(c)}try{let c;try{let I=await d.stat({bigint:!0});c=Ze(I);}catch(I){throw ae(I)}if(c.size>BigInt(i))throw new _("LIMIT_EXCEEDED");if(c.size>BigInt(Number.MAX_SAFE_INTEGER))throw new _("LIMIT_EXCEEDED");await qe(n,o);let p=await bo(n,o.realRoot,r);await Bn(s,o.realRoot,p,c);let l=new Uint8Array(new ArrayBuffer(Number(c.size))),u=0;for(;u<l.byteLength;){let I;try{I=(await d.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 d.stat({bigint:!0});A=Ze(I);}catch(I){throw ae(I)}if(!Wt(c,A))throw new _("IDENTITY_CHANGED");return await Bn(s,o.realRoot,p,A),await qe(n,o),new Uint8Array(l)}finally{await d.close().catch(()=>{});}}async fingerprintVerifiedFile(n,t,i){if(!Number.isSafeInteger(i)||i<0)throw new _("READ_DENIED");if($t===void 0)throw new _("UNSUPPORTED");let r=Ht(t),o=await Fn(n),s=resolve(n,...r),a=relative(n,s);if(a===".."||a.startsWith(`..${sep}`)||isAbsolute(a))throw new _("PATH_ESCAPED");let d;try{d=await open(s,No);}catch(c){throw ae(c)}try{let c;try{let u=await d.stat({bigint:!0});c=Ze(u);}catch(u){throw ae(u)}if(c.size>BigInt(i)||c.size>BigInt(Number.MAX_SAFE_INTEGER))throw new _("LIMIT_EXCEEDED");await qe(n,o);let p=await bo(n,o.realRoot,r);await Bn(s,o.realRoot,p,c);let l;try{let u=await d.stat({bigint:!0});l=Ze(u);}catch(u){throw ae(u)}if(!Wt(c,l))throw new _("IDENTITY_CHANGED");return await Bn(s,o.realRoot,p,l),await qe(n,o),{...l,candidateRealPath:p??o.realRoot}}catch(c){throw c instanceof _?c:ae(c)}finally{await d.close().catch(()=>{});}}async readFileVerified(n,t,i){return this.readVerifiedFile(n,t,i)}},Gn=new Qe,Po=Gn,Mo=Qe;});function hn(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 Lo(e){return typeof e=="string"&&ge.test(e)?e:void 0}function tc(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 s=t[o]-i[o];if(s!==0)return s}return t.byteLength-i.byteLength}function ic(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 oc(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 rc(e){return ec.decode(e)}function sc(e){return JSON.parse(rc(e))}function Oo(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 ac(e){if(e instanceof _)return Oo(e.code);if(e!==null&&typeof e=="object"&&"code"in e){let n=e.code;if(typeof n=="string")return Oo(n)}}function Pe(e,n){let t=n();return Number.isFinite(t)&&Number.isFinite(e)&&t-e<=5e3}function cc(e){if(typeof e.readVerifiedFile=="function")return e.readVerifiedFile;if(typeof e.readFileVerified=="function")return e.readFileVerified}function dc(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 Ro(e,n,t,i){let r=cc(e);if(!r)throw new _("READ_DENIED");return oc(await r.call(e,n,t,i))}async function Zt(e,n,t){let i=dc(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(ic).filter(o=>o!==null)}function pc(e,n,t,i){return Object.freeze({code:e,...{},source:n,relativePath:t})}function lc(e){if(!hn(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 s=0;s<i.length;s+=1){let a=i[s];if(typeof a!="string"||a.length===0)throw new TypeError("productBundle.reservedIds."+r+" must contain non-empty strings");o.push(a);}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 uc(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 _n(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 $n(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 Uo(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 fc(e){let n;try{n=sc(e);}catch{return}if(!hn(n)||!$n(n,["version","packages"])||n.version!==1||!Array.isArray(n.packages)||n.packages.length>Qt)return;let t=new Set,i=new Set,r=0,o=[];for(let s of n.packages){if(!hn(s))return;let a=["packageDir","appId","definition","files"],d=Object.hasOwn(s,"lineage"),c=Object.hasOwn(s,"launcher"),p=[...d?["lineage"]:[],...c?["launcher"]:[]];if(!$n(s,[...a,...p])||c&&s.launcher!==false)return;let l=Uo(s.packageDir),u=Lo(s.appId);if(!l||l.length!==2||l[0]!=="apps"||!tc(l[1])||!u||t.has(s.packageDir)||!hn(s.definition)||!$n(s.definition,["id","version","hash"]))return;let A=Lo(s.definition.id),I=s.definition.version,h=s.definition.hash;if(!A||!Number.isSafeInteger(I)||I<1||typeof h!="string"||!qt.test(h)||!Array.isArray(s.files)||s.files.length<2||s.files.length>ei)return;let b=new Set,F=[];for(let x of s.files){if(!hn(x)||!$n(x,["path","sha256"]))return;let M=Uo(x.path);if(!M||typeof x.sha256!="string"||!qt.test(x.sha256))return;let O=M.join("/"),z=`${s.packageDir}/${O}`;if(b.has(O)||i.has(z))return;b.add(O),i.add(z),F.push(Object.freeze({path:O,sha256:x.sha256}));}if(!se.some(x=>b.has(x))||!b.has("ui/index.html")||(r+=F.length,r>qa))return;t.add(s.packageDir),o.push(Object.freeze({packageDir:s.packageDir,...c?{launcher:false}:{},appId:u,definition:Object.freeze({id:A,version:I,hash:h}),lineage:Array.isArray(s.lineage)?s.lineage:[],files:Object.freeze(F.sort((x,M)=>je(x.path,M.path)))}));}return Object.freeze({version:1,packages:Object.freeze(o)})}function xe(e){let n=ac(e);return n==="PATH_ESCAPED"||n==="IDENTITY_CHANGED"||n==="TOCTOU"?"PATH_ESCAPED":n==="LIMIT_EXCEEDED"?"LIMIT_EXCEEDED":"BUNDLE_INTEGRITY"}async function yc(e,n,t,i,r){let o=[],s=async(a,d)=>{if(!Pe(i,r))throw new _("LIMIT_EXCEEDED");if(d>2)throw new _("LIMIT_EXCEEDED");let c=await Zt(e,n,a);for(let p of c){if(typeof p.name!="string"||p.name.length===0||p.name==="."||p.name===".."||/[\\/\u0000]/.test(p.name))throw new _("PATH_ESCAPED");let l=`${a}/${p.name}`;if(p.kind==="file"){if(o.push(l.slice(t.length+1)),o.length>ei)throw new _("LIMIT_EXCEEDED")}else if(p.kind==="directory")await s(l,d+1);else throw p.kind==="symlink"?new _("PATH_ESCAPED"):new _("READ_DENIED")}};return await s(t,0),o.sort(je)}function Ac(e){return se.includes(e)?262144:e==="ui/index.html"?Ye:e==="ui/state.json"?65536:e.startsWith("ui/assets/")?Qa:Za}async function Co(e,n,t,i){if(e===void 0)return {packages:[],diagnostics:[],incomplete:false,reservedIds:nc};let r=lc(e.reservedIds),o=[],s=(f,m,T)=>pc(f,"bundled",m),a=(f=[],m=false,T)=>({...T===void 0?{}:{indexHash:T},packages:f,diagnostics:o,incomplete:m,reservedIds:r});if(typeof e.root!="string"||e.root.length===0||typeof e.expectedIndexHash!="string"||!qt.test(e.expectedIndexHash))return o.push(s("BUNDLE_INTEGRITY","bundle-index.json")),a();let d;try{d=await Ro(n,e.root,"bundle-index.json",Ya);}catch(f){return o.push(s(xe(f),"bundle-index.json")),a()}let c=createHash("sha256").update(d).digest("hex");if(c!==e.expectedIndexHash)return o.push(s("BUNDLE_INTEGRITY","bundle-index.json")),a();let p=fc(d);if(p===void 0)return o.push(s("BUNDLE_INTEGRITY","bundle-index.json")),a();if(!uc(_n(p.packages),r))return o.push(s("BUNDLE_INTEGRITY","bundle-index.json")),a([],false,c);if(!Pe(t,i))return o.push(s("LIMIT_EXCEEDED","bundle-index.json")),a(p.packages.map(f=>({indexEntry:f,failureCode:"LIMIT_EXCEEDED"})),true,c);let l;try{l=await Zt(n,e.root,"");}catch(f){return o.push(s(xe(f),"bundle-index.json")),a(p.packages.map(m=>({indexEntry:m,failureCode:xe(f)})),false,c)}if(!Pe(t,i))return o.push(s("LIMIT_EXCEEDED","bundle-index.json")),a(p.packages.map(f=>({indexEntry:f,failureCode:"LIMIT_EXCEEDED"})),true,c);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(s("BUNDLE_INTEGRITY","bundle-index.json")),a(I("BUNDLE_INTEGRITY"),false,c);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(s(f,"bundle-index.json")),a(I("BUNDLE_INTEGRITY"),false,c)}if(l.some(f=>f.name==="apps"&&f.kind!=="directory"))return o.push(s("PATH_ESCAPED","apps")),a(I("PATH_ESCAPED"),false,c);let b=[];if(A)try{b=await Zt(n,e.root,"apps");}catch(f){return o.push(s(xe(f),"apps")),a(I(xe(f)),false,c)}if(!Pe(t,i)||b.length>Qt)return o.push(s("LIMIT_EXCEEDED","apps")),a(I("LIMIT_EXCEEDED"),true,c);let F=new Map(p.packages.map(f=>[f.packageDir.slice(5),f])),x=b.filter(f=>!F.has(f.name));for(let f of x)o.push(s(f.kind==="symlink"?"PATH_ESCAPED":"BUNDLE_INTEGRITY",`apps/${f.name}`));if(x.length>0){let f=x.some(m=>m.kind==="symlink")?"PATH_ESCAPED":"BUNDLE_INTEGRITY";return a(I(f),false,c)}let M=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)}`,P=z.get(T)??[];P.push(f),z.set(T,P);}for(let f of [...O.values(),...z.values()])if(f.length>1)for(let m of f)M.add(m);let N=[],L=d.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=wt(f.lineage,{...D.definition,hash:D.hash}).entries;}catch(D){let G=D instanceof Ee?D.code:"LINEAGE_INVALID";o.push(s(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 P;try{let D=await yc(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}P=new Map;let ie;for(let $ of f.files){if(!Pe(t,i)){ie="LIMIT_EXCEEDED",S=!0;break}if(L>=Yt){ie="LIMIT_EXCEEDED";break}let De;try{De=await Ro(n,e.root,`${f.packageDir}/${$.path}`,Ac($.path));}catch(dr){ie=xe(dr);break}if(!Pe(t,i)){ie="LIMIT_EXCEEDED",S=!0;break}if(L+De.byteLength>Yt){L=Yt,ie="LIMIT_EXCEEDED";break}if(L+=De.byteLength,createHash("sha256").update(De).digest("hex")!==$.sha256){ie="BUNDLE_INTEGRITY";break}P.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:P,...M.has(f)?{failureCode:"DUPLICATE_ID"}:{}});}return a(N,S,c)}var Ya,Qt,ei,qa,Za,Qa,Yt,qt,ec,nc,ni=w(()=>{g();xt();Ue();Ct();Vn();Kt();Ya=256*1024,Qt=64,ei=128,qa=Qt*ei,Za=2*1024*1024,Qa=8*1024*1024,Yt=32*1024*1024,qt=/^[0-9a-f]{64}$/,ec=new TextDecoder("utf-8",{fatal:true}),nc=Object.freeze({appIds:Object.freeze([]),definitionIds:Object.freeze([])});});var tr={};lr(tr,{AppDiscoveryFsError:()=>_,LOCAL_APP_TOOL_PREFIX:()=>mc,MCP_APP_WORKSPACE_TOOL_PREFIX:()=>hc,NodeAppDiscoveryFs:()=>Qe,NodeAppDiscoveryFsAdapter:()=>Mo,WORKSPACE_APP_TOOL_PREFIX:()=>en,createWorkspaceAppScanCache:()=>_o,defaultAppDiscoveryFs:()=>Gn,defaultNodeAppDiscoveryFs:()=>Po,deriveWorkspaceAppToolName:()=>_c,deriveWorkspaceAppToolNames:()=>oi,discoverWorkspaceAppCandidates:()=>Xc,discoverWorkspaceApps:()=>ri,isWorkspacePackage:()=>gc,productAppBundleReservations:()=>_n,scanWorkspaceApps:()=>Kc});function gc(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 oi(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 _c(e,n="read"){let t=oi(e);return n==="read"?t.read:t.action}function wo(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 Ec(e,n){return n.length===0||n==="."||n===".."||/[\\/\u0000]/.test(n)?e==="skills"?"skills":"apps":`${e==="skills"?"skills":"apps"}/${n}`}function Dc(e){return e.length>0&&e!=="."&&e!==".."&&!/[\\/\u0000]/.test(e)}function Tn(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 s=t[o]-i[o];if(s!==0)return s}return t.byteLength-i.byteLength}function Jo(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 Nc(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 Wo(e){return Tc.decode(e)}function bc(e){return JSON.parse(Wo(e))}function Pc(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 Wn(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 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 te(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 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 jo(e){return {reason:e.reason,...e.code==="MANIFEST_DUAL_MISMATCH"?{files:e.files}:{}}}function vo(e){return e==="MANIFEST_DUAL_MISMATCH"?e:Xo(e)}function Mc(e){return Xo(e.code)}function Xo(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 Ko("UiPluginValidationError",e)}}function Ko(e,n){throw new Error(`Unmapped ${e} code: ${String(n)}`)}function Yo(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 Ko("McpAppContractError",e)}}function Me(e,n){let t=n();return Number.isFinite(t)&&Number.isFinite(e)&&t-e<=5e3}function Sc(e){return {pluginId:e.appId,definitionKey:`${e.definition.id}\0${String(e.definition.version)}`}}function Lc(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(wo(r)){let o=r.bin,s=typeof o=="string"?o:wo(o)?Object.values(o).find(a=>typeof a=="string"):void 0;for(let a of [s,r.main]){if(typeof a!="string")continue;let d=Oc(a);if(d&&n.has(d))return d}}}catch{}return [`${e.slice(e.lastIndexOf("/")+1)}.js`,"index.js","main.js"].find(r=>n.has(r))}function Oc(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 Rc(){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 Vo(e){return Object.freeze(Array.from(e))}async function Xn(e,n,t,i){if(n.pinnedFiles!==void 0){let a=n.pinnedFiles.get(t);if(a===void 0)throw new _("NOT_FOUND");if(a.byteLength>i)throw new _("LIMIT_EXCEEDED");return new Uint8Array(a)}let r=`${n.relativePath}/${t}`,o=n.scanContext,s=e.fingerprintVerifiedFile;if(o===void 0||!o.cacheable||typeof s!="function")return zo(e,n.root,r,i);try{let a=o.priorFingerprints.get(r)??await s.call(e,o.workspaceRoot,r,i);o.candidateRealPath=a.candidateRealPath;let d=await zo(e,n.root,r,i),c=await s.call(e,o.workspaceRoot,r,i);return o.candidateRealPath=c.candidateRealPath,Zo(a,c)&&c.size===BigInt(d.byteLength)&&!Qo(c,o.scanStartedAtNs)?o.files.set(r,{relativePath:r,byteLimit:i,fingerprint:c}):o.cacheable=!1,d}catch(a){let d=se.includes(t)&&te(a)==="NOT_FOUND"&&o.directoryListings.some(p=>p.relativePath===n.relativePath&&!Kn(p.key,t)),c=t===q&&te(a)==="NOT_FOUND"&&Uc(o.directoryListings,n.relativePath);throw !d&&!c&&(o.cacheable=false),a}}function Uc(e,n){let t=e.find(r=>r.relativePath===n);if(t===void 0)return false;if(!Kn(t.key,"dist"))return true;let i=e.find(r=>r.relativePath===`${n}/dist`);return i!==void 0&&!Kn(i.key,"tools.json")}function qo(e,n){return JSON.stringify([e.realPath,n.source,n.relativePath])}async function kc(e,n,t,i,r,o,s,a){let d=e.fingerprintVerifiedFile,c=qo(t,i),p=r.candidates.get(c),l=i.relativePath,u;try{u=await Ho(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=>Kn(A.key,S)))return Me(s,a)?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 d=="function"?{memo:p}:typeof d!="function"?{}:{context:{state:r,cacheKey:c,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 Ho(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(Fo.map(I)),b=await Promise.all(Cc.map(I));if(!Me(s,a))return {timeLimitReached:true};let F=typeof d=="function"&&h.every(S=>S!==void 0),x=h.filter(S=>S!==void 0),M=[...x,...b.filter(S=>S!==void 0)],O=new Map,z=p!==void 0&&F,N;if(p!==void 0&&typeof d=="function"){let S=await Promise.all(p.files.map(async f=>{if(!Me(s,a))return {kind:"time",file:f};try{let m=await d.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||!Zo(T,m.fingerprint)||Qo(T,o))&&(z=false);}}let L=p!==void 0&&p.directoryListings.length===M.length&&p.directoryListings.every((S,f)=>S.relativePath===M[f]?.relativePath&&S.key===M[f]?.key);return p!==void 0&&F&&L&&z&&N===p.candidateRealPath?{memo:p}:!F||x.length!==Fo.length?{}:{context:{state:r,cacheKey:c,workspaceRoot:n,scanStartedAtNs:o,directoryListings:Object.freeze(M),priorFingerprints:O,files:new Map,...N===void 0?{}:{candidateRealPath:N},cacheable:true}}}function Kn(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 Ho(e,n,t){let i=er(e);if(typeof i!="function")return;let r=await i.call(e,n,t);if(!Array.isArray(r)||r.some(s=>typeof s=="string"))return;let o=r.map(Jo);if(!o.some(s=>s===null))return JSON.stringify(o.slice().sort((s,a)=>Tn(s.name,a.name)||Tn(s.kind,a.kind)).map(s=>[s.name,s.kind]))}function Zo(e,n){return e.dev===n.dev&&e.ino===n.ino&&e.size===n.size&&e.mtimeNs===n.mtimeNs&&e.ctimeNs===n.ctimeNs}function Qo(e,n){let t=e.mtimeNs-n;return t>=-Bo&&t<=Bo}function ti(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 wc(e,n,t){let i=createHash("sha256"),r=new TextEncoder().encode(Z(e)),o=s=>{let a=new Uint8Array(8);new DataView(a.buffer).setBigUint64(0,BigInt(s)),i.update(a);};return o(r.byteLength),i.update(r),o(n.byteLength),i.update(n),o(t.byteLength),i.update(t),i.digest("hex")}function xc(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 jc(e){return e.actions.some(n=>n.backend.type==="core"&&n.backend.handler!=="state.set")}function vc(e){if(typeof e.readVerifiedFile=="function")return e.readVerifiedFile;if(typeof e.readFileVerified=="function")return e.readFileVerified}function er(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 zo(e,n,t,i){let r=vc(e);if(!r)throw new _("READ_DENIED");return Nc(await r.call(e,n,t,i))}async function Vc(e,n,t){let i=er(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(Jo).filter(o=>o!==null)}function Fc(e){let n=[];for(let t of [e.reserved,e.builtin])t&&n.push(t);return e.builtins&&"listMcpApps"in e.builtins?n.push(Go(e.builtins)):e.builtins&&n.push(e.builtins),e.builtinCatalog&&n.push(Go(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 Go(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=Wn(n,e.source,e.relativePath,e.identity?.pluginId));}function Bc(e,n){let t=new Set,i=new Map;for(let o of e){let s=o.identity?.pluginId;if(s===void 0)continue;let a=i.get(s)??[];a.push(o),i.set(s,a);}for(let o of i.values()){if(o.length<2)continue;let s=o.filter(d=>d.provenance!==void 0);if(s.length>0){let d=o.find(c=>n.has(c));if(d){for(let c of s)t.add(c);for(let c of o)c!==d&&c.provenance===void 0&&Ae(c,"RESERVED_ID");continue}for(let c of o)c.provenance===void 0&&Ae(c,"RESERVED_ID");if(s.length>1)for(let c of s)Ae(c,"DUPLICATE_ID");continue}let a=o.filter(d=>d.source==="apps");if(a.length>1){for(let d of a)Ae(d,"DUPLICATE_ID");for(let d of o.filter(c=>c.source==="skills"))Ae(d,"DUPLICATE_ID");}else for(let d of o.filter(c=>c.source==="skills"))Ae(d,"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(d=>d.provenance!==void 0))continue;let s=o.identity?.definitionKey;if(s===void 0)continue;let a=r.get(s)??[];a.push(o),r.set(s,a);}for(let o of r.values())if(o.length>1)for(let s of o)Ae(s,"DUPLICATE_ID");return t}function Hc(e,n,t){let i=new Set,r=new Set,o=new Set,s=new Set([...t.appIds,...n.productBundleReservationMetadata?.reservedAppIds??[]]),a=new Set([...t.definitionIds,...n.productBundleReservationMetadata?.reservedDefinitionIds??[]]);for(let p of Fc(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 d=[...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)],c=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&&d.some(u=>u.pluginId===l.pluginId)&&!(a.has(l.definitionId)&&!d.some(u=>u.pluginId===l.pluginId&&u.definitionId===l.definitionId))&&!d.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{mo(l),c.add(p);}catch(u){Ae(p,u instanceof Te?Yo(u.code):"EXEC_DENIED");}}for(let p of e){let l=p.candidate;l&&p.provenance===void 0&&!c.has(p)&&(s.has(l.pluginId)||a.has(l.definitionId))&&Ae(p,"RESERVED_ID");}return c}function zc(e){return [...e].sort((n,t)=>{let i=ko.indexOf(n.source)-ko.indexOf(t.source);return i!==0?i:Tn(n.relativePath,t.relativePath)})}function k(e,n,t){e.diagnostic=Wn(n,e.source,e.relativePath,e.identity?.pluginId,t);}async function $o(e,n,t){let i=Ut(t,{mode:"local"});if(!i.ok&&i.parseFailure){k(n,vo(i.rejection.code),jo(i.rejection));return}let r=Pc(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)}`){k(n,"BUNDLE_INTEGRITY");return}if(!i.ok&&i.builtinOnly){k(n,"RESERVED_ID");return}if(!i.ok){k(n,vo(i.rejection.code),jo(i.rejection));return}let o=i.manifest,s={pluginId:o.pluginId,definitionKey:`${o.definitionId}\0${String(o.version)}`};if(n.bundleIdentity===void 0&&(n.identity=s),o.actions.length>0)try{Ft(o.actions.map(D=>({actionId:D.actionId,inputSchema:D.inputSchema})));}catch(D){if(D instanceof Te){k(n,Yo(D.code));return}throw D}let a;try{a=await Xn(e,n,"ui/index.html",Ye);}catch(D){k(n,Ve(te(D),"entry"));return}if(a.byteLength>Ye){k(n,"LIMIT_EXCEEDED");return}let d;try{d=Wo(a);}catch{k(n,"ENTRY_INVALID");return}if(a.byteLength===0||d.length===0){k(n,"ENTRY_INVALID");return}let c=createHash("sha256").update(a).digest("hex");if(o.entryHash!==void 0&&o.entryHash!==c){k(n,"ENTRY_INVALID");return}let p={},l,u;if(o.initialState!==void 0){try{l=await Xn(e,n,"ui/state.json",65536);}catch(D){k(n,Ve(te(D),"initial"));return}if(l.byteLength>65536){k(n,"LIMIT_EXCEEDED");return}try{let D=bc(l),G=o.dataPaths??[],ie=Dt(D,G);p=de(ie,0,G),He(p);}catch{k(n,"INITIAL_STATE_INVALID");return}if(u=createHash("sha256").update(l).digest("hex"),o.initialState.hash!==void 0&&o.initialState.hash!==u){k(n,"INITIAL_STATE_INVALID");return}}let A={...o,entryHash:c,...o.initialState===void 0?{}:{initialState:{path:"ui/state.json",hash:u}}},I=cn(A),h=wc(A,a,l??new Uint8Array),b;try{b=xc(I,h);}catch(D){if(D instanceof re){k(n,Mc(D));return}throw D}let F;if(n.bundleLineage!==void 0){let D=n.bundleLineage[n.bundleLineage.length-1];if(!D){k(n,"LINEAGE_INVALID");return}let{legacy:G,...ie}=D.definition,{hash:$,...De}=b;if(Z(ie)!==Z(De)){k(n,"LINEAGE_STALE");return}if(G!==void 0&&(b={...b,legacy:G}),G!==void 0)try{b={...b,hash:oe(b)},pe(b);}catch{k(n,"LINEAGE_INVALID");return}F=n.bundleLineage;}if(n.bundleIdentity!==void 0&&n.bundleIdentity.appId!==o.pluginId){k(n,"BUNDLE_INTEGRITY");return}if(n.bundleIdentity!==void 0&&(n.bundleIdentity.definitionId!==b.id||n.bundleIdentity.version!==b.version||n.bundleIdentity.definitionHash!==b.hash)){k(n,"LINEAGE_STALE");return}let x=oi(o.pluginId),M=o.actions.length===0?{read:x.read}:x,O=ve(I),z=ve(A),N=ve(b),L=ve({...I.handlers}),S=Vo(a),f=l===void 0?void 0:Vo(l),m=Object.freeze({...n.provenance===void 0?{}:{provenance:n.provenance},entry:Object.freeze({path:"ui/index.html",hash:c,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:d,entryBytes:S,entryHash:c,initialState:ve(p),...f===void 0?{}:{initialStateBytes:f},...u===void 0?{}:{initialStateHash:u},sourceHash:h,toolNames:Object.freeze(M)},P=n.provenance===void 0?{...T,source:n.source}:{...T,provenance:n.provenance,lineage:F??[]};n.candidate=Object.freeze(P),jc(o)&&k(n,"EXEC_DENIED");}async function nr(e,n){let t={};for(let i of se)try{t[i]=await Xn(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[q]=await Xn(e,n,q,262144);}catch(i){if(te(i)!=="NOT_FOUND")return {files:t,failure:Ve(te(i),"manifest")}}return {files:t}}function ii(e){return se.some(n=>e[n]!==void 0)}async function Gc(e,n){let{files:t,failure:i}=await nr(e,n);if(i!==void 0){k(n,i);return}let r=t[K];return r!==void 0&&!Rt(r)&&(delete t[K],delete t[q]),ii(t)?t:void 0}function $c(e,n,t,i=Ic,r=false,o=new Set){let s=zc(e),a=Bc(s,o),d=Object.freeze(s.filter(u=>u.candidate!==void 0&&u.diagnostic===void 0&&!a.has(u)).map(u=>u.candidate)),c=Object.freeze(s.filter(u=>u.diagnostic!==void 0).map(u=>u.diagnostic)),p=r?Object.freeze({...t===void 0?{}:{indexHash:t},candidates:Object.freeze(s.filter(u=>u.source==="bundled"&&u.diagnostic===void 0&&t!==void 0&&u.candidate?.provenance?.indexHash===t).map(u=>u.candidate)),diagnostics:Object.freeze(c.filter(u=>u.source==="bundled").map(u=>Object.freeze({...u}))),reservedAppIds:Object.freeze([...i.appIds]),reservedDefinitionIds:Object.freeze([...i.definitionIds])}):void 0,l={apps:d,diagnostics:c,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:()=>d}),Object.freeze(l)}function Jc(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 Wc(e,n){if(Jc(e))return {fs:e,options:n??{}};let t=e??n??{};return {fs:t.filesystem??t.fileSystem??t.fs??Gn,options:t}}async function ri(e,n,t){if(typeof e!="string"||e.length===0)throw new TypeError("workspaceRoot must be explicit");let{fs:i,options:r}=Wc(n,t),o=r.clock??Rc,s=o(),a=await Co(r.productBundle,i,s,o),d=o(),c=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=To(r.scanCache,h),I.scanStartedAtNs=c;}catch(N){if(te(N)!=="NOT_FOUND")throw N}let b=I!==void 0&&r.productBundle===void 0&&a.packages.length===0&&a.diagnostics.length===0,F=new Set,x=true;p.push(...a.diagnostics.map(N=>({source:N.source,root:r.productBundle?.root??e,name:"",relativePath:N.relativePath,diagnostic:N})));let M=a.reservedIds;a.incomplete&&(u="time_limit");for(let N of a.packages){if(!Me(d,o)){A=true,u="time_limit";break}let L=N.indexEntry,S=L.packageDir,f=N.files===void 0?void 0:Lc(S,N.files),m=a.indexHash===void 0?void 0:Ki(Object.freeze({kind:"bundled",launcher:L.launcher!==false,indexHash:a.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:Sc(L)};if(p.push(T),l+=1,N.failureCode!==void 0){k(T,N.failureCode);continue}if(N.files?.has(q)===true){k(T,"EXEC_DENIED",{reason:{path:"",rule:"bundled-tool-mode-unsupported",file:q}});continue}let P={};for(let D of se){let G=N.files?.get(D);G!==void 0&&(P[D]=G);}if(!ii(P)){k(T,"BUNDLE_INTEGRITY");continue}if(await $o(i,T,P),!Me(d,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 Vc(i,e,S);}catch(T){if(te(T)==="NOT_FOUND")continue;b=false,x=false,p.push({source:L,root:e,name:"",relativePath:L,diagnostic:Wn(Ve(te(T),"manifest"),L,L)});continue}let m=f.filter(T=>T.kind==="directory"||T.kind==="symlink").filter(T=>Dc(T.name)).map(T=>({source:L,root:e,name:T.name,relativePath:Ec(L,T.name)})).sort((T,P)=>Tn(T.relativePath,P.relativePath));for(let T of m){let P={...T};if(p.push(P),h!==void 0?F.add(qo(h,P)):b=false,!Me(d,o)){A=true,u="time_limit";break e}let D;if(I!==void 0&&h!==void 0){try{let $=await kc(i,e,h,P,I,c,d,o);if($.timeLimitReached){A=!0,u="time_limit";break e}P.scanContext=$.context,D=$.memo;}catch($){b=false,k(P,Ve(te($),"manifest"));continue}D===void 0&&(b=false);}if(D!==void 0){if(P.candidate=D.candidate,P.diagnostic=D.diagnostic,P.identity=D.identity,L==="skills"&&D.candidate===void 0&&D.diagnostic===void 0)continue;if(l>=64){k(P,"LIMIT_EXCEEDED");continue}if(T.relativePath.split("/").length-1>2){k(P,"LIMIT_EXCEEDED");continue}if(l+=1,!Me(d,o)){A=true,u="time_limit";break e}continue}let G;if(L==="skills"&&(G=await Gc(i,P),G===void 0)){P.diagnostic===void 0&&ti(P);continue}if(l>=64){k(P,"LIMIT_EXCEEDED");continue}if(T.relativePath.split("/").length-1>2){k(P,"LIMIT_EXCEEDED");continue}if(!Me(d,o)){A=true,u="time_limit";break e}if(l+=1,G===void 0){let $=await nr(i,P);if($.failure!==void 0||!ii($.files)){k(P,$.failure??Ve("NOT_FOUND","manifest")),ti(P);continue}G=$.files;}if(await $o(i,P,G),ti(P),!Me(d,o)){A=true,u="time_limit";break e}}}if(I!==void 0&&h!==void 0){let N=[...F].sort(Tn),L=I.lastCandidateKeys,S=L!==void 0&&L.length===N.length&&L.every((m,T)=>m===N[T]);if(b=b&&S,x&&!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,x&&!A&&u===void 0&&(I.lastCandidateKeys=Object.freeze(N));}A&&p.push({source:"apps",root:e,name:"",relativePath:"apps",diagnostic:Wn("DISCOVERY_TIME_LIMIT","apps","apps")});let z=Hc(p,r,M);return $c(p,u,a.indexHash,M,r.productBundle!==void 0,z)}var Ic,en,mc,hc,ko,Tc,Fo,Cc,Bo,Xc,Kc,ir=w(()=>{g();Ce();En();Ne();$i();Ue();Vn();ho();Cn();Eo();Kt();kn();ni();ni();Ic=_n([]);en="crewx_local_app_",mc=en,hc=en;ko=["bundled","apps","skills"],Tc=new TextDecoder("utf-8",{fatal:true});Fo=["","/ui"],Cc=["/dist"],Bo=2000000000n;Xc=ri,Kc=ri;});g();var or="SKILL.md",ed=/^---\s*\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/;function rr(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}function nd(e){return e.isDirectory()||e.isSymbolicLink()}function cr(e){try{return existsSync(e)&&statSync(e).isDirectory()}catch{return false}}var td=["index.js","main.js"];function nu(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(s=>typeof s=="string");if(o){let s=resolve(e,o);if(existsSync(s))return s}}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 td){let o=resolve(e,r);if(existsSync(o))return o}}function id(e){let n;try{n=readFileSync(e,"utf8");}catch{return {frontmatter:{},readable:false,valid:false,hasFrontmatter:false}}let t=n.match(ed);if(!t)return {frontmatter:{},readable:true,valid:true,hasFrontmatter:false};try{let i=load(t[1]??"");if(!rr(i))return {frontmatter:{},readable:!0,valid:!1,hasFrontmatter:!0};let r=rr(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 od(e){return [join(e,or),join(e,"skill",or)]}function Yn(e,n){if(!cr(e))return null;for(let t of od(e)){if(!existsSync(t))continue;let r=id(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 si(e){try{return readdirSync(e,{withFileTypes:!0}).filter(nd)}catch{return []}}function rd(e){return e.length===0||/[\\\u0000]/.test(e)?false:e.split("/").every(n=>n.length>0&&n!=="."&&n!=="..")}function sr(e,n,t){!e||n.has(e.name)||(n.add(e.name),t.push(e));}function qn(e){let n=[],t=new Set;for(let i of e)if(cr(i))for(let r of si(i)){if(r.name.startsWith("@")){let o=join(i,r.name);for(let s of si(o))sr(Yn(join(o,s.name),s.name),t,n);continue}sr(Yn(join(i,r.name),r.name),t,n);}return n.sort((i,r)=>i.name.localeCompare(r.name))}function sd(e,n){if(!rd(e))throw new Error(`Skill not found: ${e}`);for(let i of n){let r=Yn(join(i,e),e);if(r)return r;for(let o of si(i)){if(!o.name.startsWith("@"))continue;let s=Yn(join(i,o.name,e),e);if(s)return s}}let t=qn(n).find(i=>i.name===e);if(t)return t;throw new Error(`Skill not found: ${e}`)}async function tu(e){if(!e||e.root===null)return {skills:[],diagnostics:[]};let{discoverWorkspaceApps:n}=await Promise.resolve().then(()=>(ir(),tr)),t=await n(e.root,{productBundle:e}),i=[],r=new Set;for(let o of t.apps){let s=o.provenance?.kind==="bundled"?o.provenance.packageDir:void 0;if(!s)continue;let a=join(e.root,...s.split("/"));for(let d of qn([dirname(a)]))resolve(d.dir)!==resolve(a)||r.has(d.name)||(r.add(d.name),i.push(d));for(let d of [join(a,"skill"),join(a,"skills")])for(let c of qn([d]))r.has(c.name)||(r.add(c.name),i.push(c));}return {skills:i.sort((o,s)=>o.name.localeCompare(s.name)),diagnostics:t.diagnostics.filter(o=>o.source==="bundled")}}var iu=qn,ou=sd;
2
+ export{qn as discover,tu as discoverBundledProductSkills,iu as discoverSkills,nu as findEntrypoint,id as readSkillFrontmatter,sd as resolve,ou 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,v=async u=>(p.push(u),{accepted:true}),w=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:v,emitEvent:w,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-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-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 U(){}export{f as createMockAudit,C as createMockContext,h as createMockLogger,y as createMockRouter,M as createMockStorage,x as createMockStore,U 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;
@@ -16,7 +17,11 @@ export interface TaskStartEvent extends BaseEvent {
16
17
  threadId?: string;
17
18
  platform?: Platform;
18
19
  workspaceId?: string;
20
+ projectId?: string;
19
21
  workspaceName?: string;
22
+ cwd?: string;
23
+ actorKind?: ActorKind | null;
24
+ actorId?: string | null;
20
25
  parentTaskId?: string | null;
21
26
  rootTraceId?: string;
22
27
  callerAgentId?: string | null;
@@ -29,6 +34,8 @@ export interface TaskEndEvent extends BaseEvent {
29
34
  error?: {
30
35
  code: string;
31
36
  message: string;
37
+ providerCode?: string;
38
+ mode?: string;
32
39
  };
33
40
  exitCode?: number;
34
41
  inputTokens?: number;
@@ -37,6 +44,8 @@ export interface TaskEndEvent extends BaseEvent {
37
44
  costUsd?: number;
38
45
  model?: string;
39
46
  metadata?: Record<string, unknown>;
47
+ workspaceId?: string;
48
+ workspaceName?: string;
40
49
  }
41
50
  export interface TaskOutputEvent extends BaseEvent {
42
51
  agentRef: string;
@@ -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 { 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,11 @@ 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
+ mcpAppAvailable?: McpAppsContext['available'];
42
56
  threadId?: string;
43
57
  }
44
58
  export declare class Crewx extends TypedEventEmitter {
@@ -57,21 +71,30 @@ export declare class Crewx extends TypedEventEmitter {
57
71
  private readonly _pendingThreads;
58
72
  private readonly _activeTasks;
59
73
  private readonly _remoteFactory?;
74
+ private readonly _taskTicketIssuer?;
60
75
  private readonly _remoteTargets;
76
+ private readonly _detachedRemoteTargets;
61
77
  private readonly _additionalArgsProvider?;
78
+ private _globalSettings?;
79
+ private readonly _callerIdentityOverrides;
62
80
  private constructor();
63
81
  private resolveFileRemoteTarget;
82
+ private _readRemoteTargetStat;
64
83
  private static loadBuiltInConfig;
65
84
  private static mergeCrewxConfig;
66
85
  static loadYaml(path: string | undefined, options?: CrewxOptions, fsAdapter?: IFsAdapter): Promise<Crewx>;
67
- static fromConfig(config: CrewxProjectConfig, options?: CrewxOptions, projectRoot?: string, fsAdapter?: IFsAdapter): Promise<Crewx>;
86
+ static fromConfig(config: CrewxProjectConfig, options?: Omit<CrewxOptions, 'taskTicketIssuer'>, projectRoot?: string, fsAdapter?: IFsAdapter): Promise<Crewx>;
68
87
  get agents(): ReadonlyMap<string, AgentConfig>;
69
88
  get config(): CrewxProjectConfig | undefined;
70
89
  get plugins(): readonly CrewxPlugin[];
71
90
  get tools(): ReadonlyMap<string, ToolDefinition>;
91
+ listApps(options?: CrewxAppCatalogOptions): Promise<CrewxAppCatalogResult>;
92
+ listWorkspaceApps(options?: CrewxAppCatalogOptions): Promise<CrewxAppCatalogResult>;
72
93
  get workspaceId(): string;
94
+ createUiRuntime(options: UiRuntimeOptions): UiRuntimeFacade;
73
95
  get workspaceName(): string;
74
96
  getAgent(agentRef: string): AgentConfig | undefined;
97
+ canResumeSession(agentRef: string, params: CanResumeSessionParams): Promise<CanResumeSessionResult>;
75
98
  getRemoteProviderConfig(providerId: string): RemoteProviderConfig | undefined;
76
99
  private computeTaskLogPath;
77
100
  registerTool(name: string, definition: Omit<ToolDefinition, 'name'>): void;
@@ -90,6 +113,14 @@ export declare class Crewx extends TypedEventEmitter {
90
113
  team?: string;
91
114
  provider?: string;
92
115
  }): AgentConfig[];
116
+ private readonly _promptListProviders;
117
+ registerPromptListProvider(resolver: PromptListResolver): void;
118
+ static readAgentListSnapshot(options: {
119
+ cwd: string;
120
+ env: Record<string, string>;
121
+ configPath?: string;
122
+ }): AgentListSnapshot;
123
+ static createAgentListPromptResolver(configPath?: string): PromptListResolver;
93
124
  renderAgentPrompt(agentId: string): string;
94
125
  renderPrompt(template: string, context?: TemplateContext): Promise<string>;
95
126
  registerLayout(name: string, template: string | CustomLayoutDefinition): void;
@@ -98,12 +129,36 @@ export declare class Crewx extends TypedEventEmitter {
98
129
  private _resolveLayoutSpec;
99
130
  private _extractLayoutId;
100
131
  private _extractLayoutProps;
132
+ private _resolveLayoutContinuityCapability;
101
133
  private _getConversationProvider;
134
+ private _filterActivityLogByTaskIds;
102
135
  private _fetchHistoryMessages;
136
+ private _resolveFreshProvider;
137
+ private _resolveLocalServerRuntime;
138
+ private _readInputBudgetPercent;
139
+ private _resolveBudgetModel;
140
+ private _resolveContextMode;
141
+ private _buildInstructionOnlyResumeManifest;
142
+ private _buildInstructionOnlyContinuity;
143
+ private _prepareInstructionOnlyResumeWithBudget;
144
+ private _activityLogEntryCounts;
145
+ private _buildUnresolvedContextBudgetManifest;
146
+ private _buildResolvedContextBudgetManifest;
147
+ private _renderFreshPromptVariant;
148
+ private _prepareFreshPromptWithBudget;
149
+ private _prepareFreshPromptWithBudgetImpl;
150
+ private _recountFreshProviderInitialInput;
151
+ private _validateFreshProviderInitialInputBudget;
103
152
  private _resolveTimeout;
153
+ private _resolveIdleTimeout;
104
154
  private _lookupCliAdapter;
155
+ private _resolveEffectiveCost;
105
156
  private _resolveEffectiveCwd;
106
157
  private _buildFileRemoteOptions;
158
+ private _registerCallerIdentityOverride;
159
+ private _clearCallerIdentityOverride;
160
+ private _rewriteCallerFacingPayload;
161
+ protected emit<K extends CrewxEventName>(event: K, payload: CrewxEventPayload<K>): void;
107
162
  private emitToolEvents;
108
163
  private emitTaskLogEntries;
109
164
  private tryParseJson;
@@ -0,0 +1,14 @@
1
+ export interface TaskTicketRequest {
2
+ readonly taskId: string;
3
+ readonly agentId: string;
4
+ readonly threadId: string;
5
+ readonly workspaceId: string;
6
+ readonly runEpoch: number;
7
+ }
8
+ export interface TaskTicketGrant {
9
+ readonly ticket: string;
10
+ readonly endpoint: string;
11
+ readonly workspaceSlug: string;
12
+ }
13
+ export type TaskTicketIssuer = (request: TaskTicketRequest) => Promise<TaskTicketGrant | null>;
14
+ export declare function resolveTaskTicketEnv(issuer: TaskTicketIssuer | undefined, request: TaskTicketRequest, parentEnv?: NodeJS.ProcessEnv): Promise<Record<string, string>>;
@@ -0,0 +1,2 @@
1
+ export declare const THREAD_HIGHLIGHT_PROMPT_INSTRUCTIONS: string;
2
+ export declare const THREAD_HIGHLIGHT_CONSOLIDATION_PROMPT_INSTRUCTIONS: string;