@crewx/sdk 0.9.0-rc.14 → 0.9.0-rc.141
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.
- package/README.md +1 -1
- package/dist/account/auth-client.d.ts +61 -0
- package/dist/account/auth-json-v2.d.ts +1 -0
- package/dist/account/auth-json.d.ts +30 -0
- package/dist/account/config.d.ts +37 -0
- package/dist/account/env-bootstrap.d.ts +11 -0
- package/dist/account/errors.d.ts +24 -0
- package/dist/account/index.d.ts +12 -0
- package/dist/account/index.js +2 -0
- package/dist/account/session-manager.d.ts +47 -0
- package/dist/activity-log/builder.d.ts +59 -6
- package/dist/agent/agent-list-view.d.ts +19 -0
- package/dist/app/app.d.ts +148 -0
- package/dist/app/backend-env.d.ts +3 -0
- package/dist/app/content-media-types.d.ts +2 -0
- package/dist/app/context.d.ts +2 -0
- package/dist/app/entry.d.ts +7 -0
- package/dist/app/frame.d.ts +56 -0
- package/dist/app/index.d.ts +10 -0
- package/dist/app/index.js +10 -0
- package/dist/app/protocol.d.ts +9 -0
- package/dist/app/runtime.d.ts +21 -0
- package/dist/app/tool-mode.d.ts +3 -0
- package/dist/boxing/box.types.d.ts +4 -0
- package/dist/config/canonicalize-agent-options.d.ts +18 -0
- package/dist/config/default-agent-models.d.ts +11 -0
- package/dist/config/global-settings.d.ts +33 -0
- package/dist/config/migrate-grok-mode.d.ts +6 -0
- package/dist/config/model-compat.d.ts +31 -0
- package/dist/config/models.generated.d.ts +37 -0
- package/dist/config/models.remote.d.ts +1 -0
- package/dist/config/overdrive.d.ts +7 -0
- package/dist/config/pricing.d.ts +6 -3
- package/dist/config/pricing.generated.d.ts +4 -0
- package/dist/config/pricing.types.d.ts +4 -0
- package/dist/config/timeout.config.d.ts +4 -0
- package/dist/config/wi-boards.d.ts +19 -0
- package/dist/context-budget/continuity.d.ts +61 -0
- package/dist/context-budget/index.d.ts +141 -0
- package/dist/conversation/index.d.ts +1 -1
- package/dist/conversation/sqlite-provider.d.ts +6 -3
- package/dist/conversation/to-template-messages.d.ts +9 -0
- package/dist/conversation/types.d.ts +48 -1
- package/dist/desktop/command-runner.d.ts +4 -0
- package/dist/desktop/default-adapters.d.ts +4 -0
- package/dist/desktop/global-install.d.ts +19 -0
- package/dist/desktop/index.d.ts +3 -0
- package/dist/desktop/index.js +3 -0
- package/dist/desktop/install.d.ts +5 -0
- package/dist/desktop/lnk.d.ts +22 -0
- package/dist/desktop/manifest.d.ts +21 -0
- package/dist/desktop/types.d.ts +67 -0
- package/dist/desktop/version.d.ts +1 -0
- package/dist/desktop/windows-paths.d.ts +21 -0
- package/dist/desktop/wrapper.d.ts +18 -0
- package/dist/esm/account/index.js +2 -0
- package/dist/esm/app/index.js +10 -0
- package/dist/esm/desktop/index.js +3 -0
- package/dist/esm/index.js +1104 -226
- package/dist/esm/node/index.js +2 -0
- package/dist/esm/plugins/index.js +474 -216
- package/dist/esm/process/index.js +1 -0
- package/dist/esm/publish/index.js +2 -0
- package/dist/esm/repository/index.js +586 -213
- package/dist/esm/skills/index.js +2 -0
- package/dist/esm/testing/index.js +1 -1
- package/dist/events/types.d.ts +9 -0
- package/dist/facade/Crewx.d.ts +60 -5
- package/dist/facade/task-ticket.d.ts +14 -0
- package/dist/highlight/thread-highlight-prompt.d.ts +2 -0
- package/dist/highlight/thread-highlighter.d.ts +326 -0
- package/dist/index.browser.d.ts +17 -1
- package/dist/index.browser.js +6 -2
- package/dist/index.d.ts +125 -17
- package/dist/index.js +1104 -226
- package/dist/internal/console-decoder.d.ts +38 -0
- package/dist/internal/windows-spawn.d.ts +10 -0
- package/dist/layout/types.d.ts +18 -1
- package/dist/lifecycle/process-lease.d.ts +80 -0
- package/dist/lifecycle/process-owner.d.ts +20 -0
- package/dist/lifecycle/task-heartbeat.d.ts +41 -0
- package/dist/lifecycle/task-stop.d.ts +82 -0
- package/dist/lifecycle/update-admission.d.ts +45 -0
- package/dist/local-server/base-url.d.ts +18 -0
- package/dist/local-server/index.d.ts +8 -0
- package/dist/local-server/opencode.d.ts +8 -0
- package/dist/local-server/probe.d.ts +3 -0
- package/dist/local-server/runtime.d.ts +26 -0
- package/dist/local-server/types.d.ts +43 -0
- package/dist/mcp-app/agent-access.d.ts +26 -0
- package/dist/mcp-app/apps-context.d.ts +20 -0
- package/dist/mcp-app/bundle-provenance.d.ts +3 -0
- package/dist/mcp-app/catalog.d.ts +7 -0
- package/dist/mcp-app/content-channel.d.ts +86 -0
- package/dist/mcp-app/content-declarations.d.ts +31 -0
- package/dist/mcp-app/dev-checks.d.ts +29 -0
- package/dist/mcp-app/diagnostic-reason.d.ts +3 -0
- package/dist/mcp-app/discovery.d.ts +160 -0
- package/dist/mcp-app/errors.d.ts +7 -0
- package/dist/mcp-app/index.d.ts +33 -0
- package/dist/mcp-app/installed-app-ref.d.ts +25 -0
- package/dist/mcp-app/model-context.d.ts +29 -0
- package/dist/mcp-app/node-app-discovery-fs.d.ts +23 -0
- package/dist/mcp-app/product-bundle-assets.d.ts +27 -0
- package/dist/mcp-app/product-bundle-loader.d.ts +53 -0
- package/dist/mcp-app/projection.d.ts +14 -0
- package/dist/mcp-app/registry.d.ts +28 -0
- package/dist/mcp-app/skill-backend.d.ts +132 -0
- package/dist/mcp-app/state-set.d.ts +9 -0
- package/dist/mcp-app/types.d.ts +472 -0
- package/dist/mcp-app/workspace-app-assets.d.ts +42 -0
- package/dist/mcp-app/workspace-app-scan-cache.d.ts +24 -0
- package/dist/mcp-app/workspace-snapshot.d.ts +71 -0
- package/dist/migrations/0011_far_black_tarantula.sql +1 -0
- package/dist/migrations/0012_blue_turbo.sql +23 -0
- package/dist/migrations/0013_hesitant_adam_destine.sql +15 -0
- package/dist/migrations/0014_organic_mongu.sql +73 -0
- package/dist/migrations/0015_panoramic_gorilla_man.sql +71 -0
- package/dist/migrations/0016_fuzzy_hemingway.sql +14 -0
- package/dist/migrations/0017_project_stage_sdk_migration.sql +29 -0
- package/dist/migrations/0018_bored_jackal.sql +33 -0
- package/dist/migrations/0019_backfill_task_thread_ids.sql +74 -0
- package/dist/migrations/0020_useful_iron_lad.sql +55 -0
- package/dist/migrations/0021_dashing_peter_quill.sql +51 -0
- package/dist/migrations/0022_wandering_bucky.sql +1 -0
- package/dist/migrations/0023_red_payback.sql +1 -0
- package/dist/migrations/0024_storage_metadata.sql +262 -0
- package/dist/migrations/0025_task_heartbeat.sql +8 -0
- package/dist/migrations/0025_thread_app_instance_ledger.sql +2 -0
- package/dist/migrations/0026_mcp_action_source.sql +47 -0
- package/dist/migrations/0027_task_stop_scope_cleanup.sql +5 -0
- package/dist/migrations/0027_ui_instance_active_unique.sql +2 -0
- package/dist/migrations/0029_nice_rhino.sql +1 -0
- package/dist/migrations/0031_petite_arclight.sql +6 -0
- package/dist/migrations/0032_ui_instance_opened_by.sql +1 -0
- package/dist/migrations/0033_thread_creator_boundary_guard.sql +38 -0
- package/dist/migrations/0034_keen_fallen_one.sql +36 -0
- package/dist/migrations/0035_request_log_daily.sql +11 -0
- package/dist/migrations/0036_ui_definition_archive.sql +8 -0
- package/dist/migrations/meta/0011_snapshot.json +1342 -0
- package/dist/migrations/meta/0012_snapshot.json +1494 -0
- package/dist/migrations/meta/0013_snapshot.json +1592 -0
- package/dist/migrations/meta/0014_snapshot.json +1975 -0
- package/dist/migrations/meta/0015_snapshot.json +2315 -0
- package/dist/migrations/meta/0016_snapshot.json +2419 -0
- package/dist/migrations/meta/0017_snapshot.json +2419 -0
- package/dist/migrations/meta/0018_snapshot.json +2570 -0
- package/dist/migrations/meta/0020_snapshot.json +2895 -0
- package/dist/migrations/meta/0021_snapshot.json +3031 -0
- package/dist/migrations/meta/0022_snapshot.json +3039 -0
- package/dist/migrations/meta/0023_snapshot.json +3047 -0
- package/dist/migrations/meta/0029_snapshot.json +3206 -0
- package/dist/migrations/meta/0031_snapshot.json +3251 -0
- package/dist/migrations/meta/0034_snapshot.json +3473 -0
- package/dist/migrations/meta/0035_snapshot.json +3547 -0
- package/dist/migrations/meta/0036_snapshot.json +3591 -0
- package/dist/migrations/meta/_journal.json +182 -0
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +2 -0
- package/dist/paths.d.ts +1 -0
- package/dist/plugin/types.d.ts +1 -0
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +474 -216
- package/dist/plugins/sqlite-tracing.d.ts +46 -0
- package/dist/process/index.d.ts +2 -0
- package/dist/process/index.js +1 -0
- package/dist/process/process-control.d.ts +41 -0
- package/dist/prompt/tag-names.d.ts +22 -0
- package/dist/provider/acp/connection.d.ts +6 -0
- package/dist/provider/acp/meta.d.ts +11 -0
- package/dist/provider/bridge.d.ts +7 -1
- package/dist/provider/classify-task-error.d.ts +2 -0
- package/dist/provider/cli/adapter.types.d.ts +14 -2
- package/dist/provider/cli/adapters/agent-call.util.d.ts +1 -1
- package/dist/provider/cli/adapters/cli-knob.util.d.ts +7 -0
- package/dist/provider/cli/adapters/codex-item.d.ts +1 -0
- package/dist/provider/cli/adapters/event-timestamp.util.d.ts +1 -0
- package/dist/provider/cli/adapters/grok.d.ts +2 -0
- package/dist/provider/cli/adapters/index.d.ts +5 -0
- package/dist/provider/cli/index.d.ts +3 -2
- package/dist/provider/cli/meta.d.ts +5 -0
- package/dist/provider/cli/protocol-envelope.d.ts +3 -0
- package/dist/provider/errors.d.ts +5 -1
- package/dist/provider/idle-watchdog.d.ts +19 -0
- package/dist/provider/models.d.ts +17 -12
- package/dist/provider/order.d.ts +1 -1
- package/dist/provider/parse-usage.d.ts +6 -0
- package/dist/provider/provider-selection.d.ts +8 -0
- package/dist/provider/redact-technical-message.d.ts +1 -0
- package/dist/provider/task-error.types.d.ts +17 -0
- package/dist/publish/constants.d.ts +6 -0
- package/dist/publish/errors.d.ts +7 -0
- package/dist/publish/index.d.ts +50 -0
- package/dist/publish/index.js +2 -0
- package/dist/publish/manifest.d.ts +47 -0
- package/dist/publish/marketplace-api.constants.d.ts +1 -0
- package/dist/publish/pack.d.ts +6 -0
- package/dist/publish/scan.d.ts +9 -0
- package/dist/publish/secrets.d.ts +6 -0
- package/dist/publish/upload.d.ts +19 -0
- package/dist/remote/execution-profile.d.ts +9 -0
- package/dist/remote/index.d.ts +1 -0
- package/dist/remote/types.d.ts +28 -0
- package/dist/repository/agent-suggestion.repository.d.ts +34 -0
- package/dist/repository/base-sqlite-repository.d.ts +1 -0
- package/dist/repository/common-code.repository.d.ts +45 -0
- package/dist/repository/db.d.ts +12 -1
- package/dist/repository/index.d.ts +41 -5
- package/dist/repository/index.js +586 -213
- package/dist/repository/logs-db.d.ts +12 -0
- package/dist/repository/notification.repository.d.ts +58 -0
- package/dist/repository/project.repository.d.ts +90 -0
- package/dist/repository/request-log-mover.d.ts +70 -0
- package/dist/repository/request-log.repository.d.ts +7 -3
- package/dist/repository/storage-metadata.repository.d.ts +64 -0
- package/dist/repository/task-log-migration.d.ts +74 -0
- package/dist/repository/task-log.repository.d.ts +44 -0
- package/dist/repository/task-status.d.ts +21 -0
- package/dist/repository/task.repository.d.ts +229 -7
- package/dist/repository/thread-history.repository.d.ts +193 -0
- package/dist/repository/thread-origin-verdict.d.ts +27 -0
- package/dist/repository/thread-title.types.d.ts +29 -0
- package/dist/repository/thread.repository.d.ts +115 -7
- package/dist/repository/usage-backfill.d.ts +62 -0
- package/dist/repository/usage-from-logs.d.ts +21 -0
- package/dist/repository/workspace.repository.d.ts +3 -0
- package/dist/schema/agent-suggestions.d.ts +199 -0
- package/dist/schema/common-codes.d.ts +216 -0
- package/dist/schema/index.d.ts +13 -0
- package/dist/schema/notifications.d.ts +303 -0
- package/dist/schema/projects.d.ts +610 -0
- package/dist/schema/request-log-daily.d.ts +151 -0
- package/dist/schema/storage-metadata.d.ts +181 -0
- package/dist/schema/task-log-events.d.ts +119 -0
- package/dist/schema/tasks.d.ts +165 -0
- package/dist/schema/thread-creator-unverified.d.ts +45 -0
- package/dist/schema/thread-history.d.ts +734 -0
- package/dist/schema/threads.d.ts +59 -0
- package/dist/schema/ui-action-receipts.d.ts +358 -0
- package/dist/schema/ui-definition-archive.d.ts +63 -0
- package/dist/schema/ui-instance-repins.d.ts +222 -0
- package/dist/schema/ui-instances.d.ts +305 -0
- package/dist/schema/workspaces.d.ts +17 -0
- package/dist/skills/index.d.ts +15 -0
- package/dist/skills/index.js +2 -0
- package/dist/skills/types.d.ts +18 -0
- package/dist/task-log/anchor-child-tasks.d.ts +7 -0
- package/dist/task-log/delegation-trailer.d.ts +34 -0
- package/dist/template/engine.d.ts +2 -2
- package/dist/template/helpers/exec.browser.d.ts +4 -3
- package/dist/template/helpers/exec.d.ts +4 -3
- package/dist/template/types.d.ts +20 -0
- package/dist/testing/index.js +1 -1
- package/dist/types/index.d.ts +1574 -3
- package/dist/types/task-log.types.d.ts +3 -0
- package/dist/ui-card/index.d.ts +2 -0
- package/dist/ui-card/legacy-card-parser.d.ts +11 -0
- package/dist/ui-instance/definition.d.ts +6 -0
- package/dist/ui-instance/errors.d.ts +18 -0
- package/dist/ui-instance/index.d.ts +11 -0
- package/dist/ui-instance/json.d.ts +19 -0
- package/dist/ui-instance/lineage.d.ts +24 -0
- package/dist/ui-instance/runtime.d.ts +18 -0
- package/dist/ui-instance/store.d.ts +198 -0
- package/dist/ui-instance/types.d.ts +319 -0
- package/dist/ui-plugin/app-manifest.d.ts +64 -0
- package/dist/ui-plugin/csp.d.ts +28 -0
- package/dist/ui-plugin/index.d.ts +6 -0
- package/dist/ui-plugin/limits.d.ts +27 -0
- package/dist/ui-plugin/manifest.d.ts +3 -0
- package/dist/ui-plugin/types.d.ts +203 -0
- package/dist/ui-plugin/validator.d.ts +18 -0
- package/dist/utils/crewx-executable.d.ts +76 -0
- package/dist/utils/crewx-home.d.ts +1 -0
- package/dist/utils/env-defaults.d.ts +3 -0
- package/dist/utils/id.d.ts +1 -1
- package/dist/utils/local-identity.d.ts +2 -0
- package/dist/utils/runner-env.d.ts +3 -0
- package/dist/utils/timestamp.d.ts +1 -0
- package/dist/utils/workspace.d.ts +1 -0
- package/dist/wi/create.d.ts +48 -0
- package/dist/wi/select.d.ts +20 -0
- package/package.json +57 -3
- package/templates/agents/default.yaml +296 -128
- package/templates/documents/crewx-manual.md +138 -138
- package/templates/documents/crewx-quick-guide.md +8 -7
- package/templates/workflows/wi-default-flow.yaml +65 -0
- package/templates/workflows/wi-plan-flow.yaml +140 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var li=require('crypto'),net=require('net'),q=require('fs'),promises=require('fs/promises'),ie=require('path'),Ar=require('js-yaml'),Pr=require('os'),Dr=require('tar'),zlib=require('zlib');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var li__namespace=/*#__PURE__*/_interopNamespace(li);var q__namespace=/*#__PURE__*/_interopNamespace(q);var ie__namespace=/*#__PURE__*/_interopNamespace(ie);var Ar__namespace=/*#__PURE__*/_interopNamespace(Ar);var Pr__namespace=/*#__PURE__*/_interopNamespace(Pr);var Dr__namespace=/*#__PURE__*/_interopNamespace(Dr);var v=(e,n)=>()=>(e&&(n=e(e=0)),n);var g=v(()=>{});var O,Tn=v(()=>{g();O=class extends Error{constructor(t,i=t,o){super(i);this.code=t;this.currentRevision=o;}code;currentRevision;name="UiRuntimeError"};});function ot(e){return jr.test(e)||Fr.test(e)}function ce(){throw new O("INPUT_INVALID","JSON value is not projection-safe")}function zr(e){let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}function tt(e,n,t,i,o,r){if(n>i&&ce(),e===null||typeof e=="string"||typeof e=="boolean")return typeof e=="string"&&(Vr.test(e)||Hr.test(e)&&!Wr(o,r)||Br.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(c=>tt(c,n+1,t,i,o,r));zr(s)||ce();let a={};for(let[c,d]of Object.entries(e))ot(c)&&ce(),a[c]=tt(d,n+1,t,i,[...o,c],r);return a}finally{t.delete(s);}}function Ee(e,n=0,t=[]){(!Number.isInteger(n)||n<0||n>Gr)&&ce(),(!Array.isArray(t)||t.some(o=>typeof o!="string"))&&ce();let i=tt(e,0,new Set,$r+n,[],t);return (i===null||Array.isArray(i)||typeof i!="object")&&ce(),i}function Ge(e,n){if(!e||!n)return false;let t=e.split("."),i=n.split(".");return t.length>=i.length&&i.every((o,r)=>t[r]===o)}function Wr(e,n){if(e.length===0)return false;let t=e.join(".");return n.some(i=>Ge(t,i))}function We(e){try{let n=JSON.stringify(e);return n===void 0&&ce(),n}catch{ce();}}function it(e){return Array.isArray(e)?e.map(it):e!==null&&typeof e=="object"?Object.fromEntries(Object.keys(e).sort().map(n=>[n,it(e[n])])):e}function oe(e){return We(it(e))}function rt(e){return Buffer.byteLength(e,"utf8")}var jr,Fr,Vr,Br,Hr,$r,Gr,Te=v(()=>{g();Tn();jr=/(?: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,Vr=/<\/?[A-Za-z][^>]*>/,Br=/^(?:[A-Za-z]:[\\/]|\\\\|~[\\/]|\/)/,Hr=/^(?:https?|file|ftp|ws|wss):\/\//i;$r=8,Gr=4;});var Ai=v(()=>{g();Te();});var Pn,st=v(()=>{g();Pn=["text/plain","application/json"];});var Ii=v(()=>{g();st();});function Je(e){return Kr.has(e)||Xr.test(e)||Yr.test(e)}var gi,Kr,Xr,Yr,Nn,rn,ye,at,ct,dt,pt,lt,ke=v(()=>{g();gi=["__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"],Kr=new Set(gi),Xr=/(?:proof|token|secret|password|cookie|authorization|private[_-]?key|stack|exception|plugin[_-]?text)/i,Yr=/(?:url|uri|endpoint|path|file(?:name|path)?|cwd|shell|directory|dir|folder)$/i;Nn=/^[A-Za-z0-9_]+$/,rn=/^[A-Za-z0-9_]+(?:\.[A-Za-z0-9_]+)*$/,ye=/^[A-Za-z][A-Za-z0-9._-]{0,127}$/,at=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/,ct=/^[A-Za-z][A-Za-z0-9._-]{0,127}$/,dt=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$/,pt=["blue","violet","emerald","amber","rose","sky","slate","indigo"],lt=["inline","panel"];});function ut(e){return typeof e=="string"&&Pn.includes(e)}var mi=v(()=>{g();st();ke();});function Dn(e){if(!ft(e))return false;let n=Object.keys(e);return !(n.some(t=>t!=="in"&&t!=="out")||n.length===0||Object.hasOwn(e,"in")&&!qr(e.in)||Object.hasOwn(e,"out")&&!Zr(e.out))}function qr(e){return ft(e)?Object.keys(e).every(t=>t==="mediaType"||t==="required")&&Object.hasOwn(e,"mediaType")&&ut(e.mediaType)&&(!Object.hasOwn(e,"required")||typeof e.required=="boolean"):false}function Zr(e){return ft(e)?Object.keys(e).every(t=>t==="mediaType"||t==="range")&&Object.hasOwn(e,"mediaType")&&ut(e.mediaType)&&(!Object.hasOwn(e,"range")||typeof e.range=="boolean"):false}function ft(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}var yt=v(()=>{g();Ii();mi();new TextDecoder("utf-8",{fatal:true,ignoreBOM:true});});function pe(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(o=>o.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=Ee(t);return li.createHash("sha256").update(oe(i)).digest("hex")}function Pe(e){if(!/^\d+$/.test(String(e.version))||e.version<1||e.id.length<1||e.id.length>128)throw new O("DEFINITION_UNSUPPORTED","UI definition is invalid");if(e.sourceHash!==void 0&&(typeof e.sourceHash!="string"||!es.test(e.sourceHash)))throw new O("DEFINITION_UNSUPPORTED","UI definition source hash is invalid");if(!/^[0-9a-f]{64}$/.test(e.hash)||pe(e)!==e.hash)throw new O("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=>!ts(i)))throw new O("DEFINITION_UNSUPPORTED","UI action declaration is invalid");if(t.confirmation!==void 0&&t.confirmation!=="none"&&t.confirmation!=="native")throw new O("DEFINITION_UNSUPPORTED","UI action confirmation is invalid");if(t.inputKeys&&(!Array.isArray(t.inputKeys)||t.inputKeys.some(i=>typeof i!="string"||!i)))throw new O("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 O("DEFINITION_UNSUPPORTED","UI action data input declaration is invalid");if(t.resultProjection&&At(t.resultProjection),t.content!==void 0&&!Dn(t.content))throw new O("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 O("DEFINITION_UNSUPPORTED","UI action environment declaration is invalid")}if(e.renderer!==void 0&&(!e.renderer||e.renderer.length>128))throw new O("DEFINITION_UNSUPPORTED","UI definition renderer is invalid");if(e.surfaces&&(!Array.isArray(e.surfaces)||e.surfaces.some(n=>!n||n.length>64)))throw new O("DEFINITION_UNSUPPORTED","UI definition surfaces are invalid");if(e.usage!==void 0&&e.usage!=="card"&&e.usage!=="window")throw new O("DEFINITION_UNSUPPORTED","UI definition usage is invalid");if(e.detailPanel!==void 0&&typeof e.detailPanel!="boolean")throw new O("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 O("DEFINITION_UNSUPPORTED","UI definition displayModes are invalid");if(e.usage==="card"&&e.displayModes!==void 0)throw new O("DEFINITION_UNSUPPORTED","Card definitions cannot declare displayModes");if(e.usage==="window"&&e.detailPanel!==void 0)throw new O("DEFINITION_UNSUPPORTED","Window definitions cannot declare detailPanel");if(e.stateProjection&&At(e.stateProjection),e.summaryProjection){At(e.summaryProjection);let n=new Set(e.stateProjection?.allow??[]);if(e.summaryProjection.allow.some(t=>!n.has(t)))throw new O("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(o=>!["readTool","actionTool","hostTools","agentAccess"].includes(o)))throw new O("DEFINITION_UNSUPPORTED","UI legacy metadata is invalid");let n=new Set;for(let[o,r]of [["readTool",e.legacy.readTool],["actionTool",e.legacy.actionTool]])if(r!==void 0){if(ns(r,o==="readTool"),n.has(r.name))throw new O("DEFINITION_UNSUPPORTED","UI legacy tool names collide");n.add(r.name);}let t=e.legacy.hostTools;if(t!==void 0){if(!t||typeof t!="object"||Array.isArray(t))throw new O("DEFINITION_UNSUPPORTED","UI legacy host tools are invalid");let o={"doc.open":"crewx_app_html_viewer_open","pty.connect":"crewx_app_terminal_connect"};for(let[r,s]of Object.entries(t)){if(!Object.hasOwn(o,r)||o[r]!==s||typeof s!="string"||!/^[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(s)||n.has(s))throw new O("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(([o,r])=>!o||!Object.hasOwn(e.actions,o)||r!=="allowed"&&r!=="denied")))throw new O("DEFINITION_UNSUPPORTED","UI legacy agent access is invalid");if(e.legacy.actionTool!==void 0&&(!i||Object.keys(i).length===0))throw new O("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=>Ge(t,i))))throw new O("DEFINITION_UNSUPPORTED","UI definition dataPaths are invalid")}}function ns(e,n){if(!e||typeof e!="object"||Array.isArray(e))throw new O("DEFINITION_UNSUPPORTED","UI legacy tool metadata is invalid");let t=e,i=["name","description","inputSchema","textFallback","visibility"],o=Object.hasOwn(t,"fixedResult");if(Object.keys(t).some(r=>!i.includes(r)&&!(n&&r==="fixedResult"))||i.some(r=>!Object.hasOwn(t,r))||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(r=>r!=="model"&&r!=="app")||new Set(t.visibility).size!==t.visibility.length)throw new O("DEFINITION_UNSUPPORTED","UI legacy tool metadata is invalid");try{let r=Ee(t.inputSchema);if(r.type!==void 0&&r.type!=="object")throw new Error("schema type");if(o){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 c=Ee(a.structuredContent);if(rt(We(c))>4*1024)throw new Error("fixed result size")}}catch{throw new O("DEFINITION_UNSUPPORTED","UI legacy tool metadata is not projection-safe")}}function At(e){if(!Array.isArray(e.allow)||e.allow.some(n=>!/^[A-Za-z0-9_]+(?:\.[A-Za-z0-9_]+)*$/.test(n)))throw new O("DEFINITION_UNSUPPORTED","UI projection policy is invalid")}function ts(e){return e.length>0&&e.length<=128&&e!=="*"&&e!=="all"&&!/[/*]/.test(e)}var es,xe=v(()=>{g();Te();Tn();yt();es=/^[0-9a-f]{64}$/;});var V,Ke,It=v(()=>{g();V="dist/tools.json",Ke="dist/main.mjs";});var Re,gt=v(()=>{g();Re="window";});function hi(e){if(!Array.isArray(e)||e.length===0)return false;let n=new Set;for(let t of e){if(!is.some(i=>i===t)||n.has(t))return false;n.add(t);}return true}var is,_i=v(()=>{g();is=["CREWX_APP_INSTANCE_ID","CREWX_THREAD_ID"];});function B(e){throw new mt(e)}function As(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 Is(e,n){let t=Object.getOwnPropertyDescriptor(e,n);return (!t||!("value"in t))&&B("CSP_ORIGIN_INVALID"),t.value}function bn(e,n){if(!Object.prototype.hasOwnProperty.call(e,n))return [];let t=Is(e,n);Array.isArray(t)||B("CSP_ORIGIN_INVALID"),Reflect.ownKeys(t).some(r=>typeof r!="string"||r!=="length"&&!/^(?:0|[1-9][0-9]*)$/.test(r))&&B("CSP_ORIGIN_INVALID");let o=[];for(let r=0;r<t.length;r+=1)(!Object.prototype.hasOwnProperty.call(t,r)||typeof t[r]!="string")&&B("CSP_ORIGIN_INVALID"),o.push(t[r]);return Object.keys(t).length!==t.length&&B("CSP_ORIGIN_INVALID"),o}function gs(e){let n;try{n=JSON.stringify(e);}catch{B("CSP_ORIGIN_INVALID");}return n===void 0&&B("CSP_ORIGIN_INVALID"),new TextEncoder().encode(n).byteLength}function Pi(e,n){/\s|\\/u.test(e)&&B("CSP_ORIGIN_INVALID");let t=ps.exec(e);t||B("CSP_ORIGIN_INVALID");let i=t[1].toLowerCase(),o=t[2];(o.includes("@")||o.includes("%")||o.includes("*"))&&B("CSP_ORIGIN_INVALID"),(o.startsWith("[")?ls:us).test(o)||B("CSP_ORIGIN_INVALID"),i==="wss"&&n!=="connectDomains"&&B("CSP_ORIGIN_INVALID");let s;try{s=new URL(e);}catch{B("CSP_ORIGIN_INVALID");}(s.protocol!==`${i}:`||s.username!==""||s.password!==""||s.search!==""||s.hash!=="")&&B("CSP_ORIGIN_INVALID");let a=s.hostname.toLowerCase();if((!a||a.includes("%"))&&B("CSP_ORIGIN_INVALID"),!a.startsWith("[")){let d=a.endsWith(".")?a.slice(0,-1):a;(d.length===0||d.length>253)&&B("CSP_ORIGIN_INVALID"),d.split(".").some(A=>A.length>63||!fs.test(A))&&B("CSP_ORIGIN_INVALID");}let c=s.origin;return (c==="null"||!c.startsWith(`${i}://`))&&B("CSP_ORIGIN_INVALID"),{origin:c,hostname:a}}function ms(e){let n=e.split(".").map(Number);return ((n[0]*256+n[1])*256+n[2])*256+n[3]}function Ni(e,n,t){let i=4294967295<<32-t>>>0;return (e&i)===(n&i)}function Si(e){let n=ms(e);return Ni(n,3221225472,24)?n!==3221225481&&n!==3221225482:ys.some(([t,i])=>Ni(n,t,i))}function hs(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((r,s)=>r<<16n|BigInt(Number.parseInt(s,16)),0n)}function _s(e){let n=hs(e),t=Number(n>>112n),i=Number(n>>96n&0xffffn);if(n>>32n===0xffffn){let o=Number(n&0xffffffffn);return Si([o>>>24&255,o>>>16&255,o>>>8&255,o&255].join("."))}return t<8192||t>16383||t===8193&&i<=511||t===8193&&i===3512||t===8194||t===16383&&i<=4095}function Es(e,n){let t=e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e,i=net.isIP(t);if(i===4)return Si(t);if(i===6)return _s(t);let o=e.toLowerCase().replace(/\.$/,"");return !o||!o.includes(".")||n.has(o)?true:ds.some(r=>o===r||o.endsWith(`.${r}`))}function Di(e){return Object.freeze([...new Set(e.map(n=>n.origin))].sort())}function bi(e){return JSON.stringify({baseUriDomains:[],connectDomains:e.connectDomains,declared:e.declared,frameDomains:e.frameDomains,resourceDomains:[]})}function Mi(e,n={}){if(e===void 0){let y=bi({declared:false,connectDomains:[],frameDomains:[]});return Object.freeze({declared:false,connectDomains:Object.freeze([]),frameDomains:Object.freeze([]),resourceDomains:Object.freeze([]),baseUriDomains:Object.freeze([]),cspHash:li.createHash("sha256").update(y,"utf8").digest("hex")})}As(e)||B("CSP_ORIGIN_INVALID");let t=Reflect.ownKeys(e);t.some(y=>typeof y!="string")&&B("CSP_ORIGIN_INVALID"),t.some(y=>!cs.has(y))&&B("CSP_AXIS_UNKNOWN");let i=bn(e,"connectDomains"),o=bn(e,"frameDomains"),r=bn(e,"resourceDomains"),s=bn(e,"baseUriDomains");(r.length>0||s.length>0)&&B("CSP_AXIS_UNSUPPORTED"),(gs(e)>rs||i.length>Ti||o.length>Ti||i.length+o.length>ss||[...i,...o].some(y=>new TextEncoder().encode(y).byteLength>as))&&B("CSP_LIMIT_EXCEEDED");let c=i.map(y=>Pi(y,"connectDomains")),d=o.map(y=>Pi(y,"frameDomains")),p=new Set((n.runtimeHostnames??[]).map(y=>y.toLowerCase().replace(/\.$/,"")));[...c,...d].some(y=>Es(y.hostname,p))&&B("CSP_ORIGIN_FORBIDDEN");let A={declared:true,connectDomains:Di(c),frameDomains:Di(d)},m=bi(A);return Object.freeze({...A,resourceDomains:Object.freeze([]),baseUriDomains:Object.freeze([]),cspHash:li.createHash("sha256").update(m,"utf8").digest("hex")})}var rs,Ti,ss,as,cs,ds,ps,ls,us,fs,ys,mt,Li=v(()=>{g();rs=4096,Ti=16,ss=32,as=512,cs=new Set(["connectDomains","frameDomains","resourceDomains","baseUriDomains"]),ds=["localhost","local","internal","home.arpa","test","example","invalid","onion","lan","corp","home","intranet","private","localdomain"],ps=/^(https|wss):\/\/([^/?#]+)$/i,ls=/^\[[^\]]+\](?::[0-9]+)?$/,us=/^[^:\[\]]+(?::[0-9]+)?$/,fs=/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/,ys=[[0,8],[1681915904,10],[167772160,8],[2130706432,8],[2851995648,16],[2886729728,12],[3221225984,24],[3227017984,24],[3232235520,16],[3323068416,15],[3325256704,24],[3405803776,24],[3758096384,4],[4026531840,4]],mt=class extends Error{constructor(t){super(t);this.code=t;}code;name="UiPluginCspNormalizationError"};});function an(e,n){return n===void 0||n===""?e:e===""?n:n.startsWith("[")?`${e}${n}`:`${e}.${n}`}function f(e,n=e,t,i){throw new ne(e,n,t,i)}function z(e,n){try{return n()}catch(t){throw t instanceof ne?t.withPathPrefix(e):t}}function $(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 R(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function Xs(e,n){let t={};for(let[i,o]of Object.entries(e))i!==n&&(t[i]=o);return t}function W(e,n,t=[]){let i=new Set([...n,...t]),o=Object.keys(e).find(s=>!i.has(s));o!==void 0&&f("MANIFEST_INVALID","MANIFEST_INVALID",o,"unknown-key");let r=n.find(s=>!R(e,s));r!==void 0&&f("MANIFEST_INVALID","MANIFEST_INVALID",r,"missing-key");}function On(e,n=false,t=false,i=false){return Ds.test(e)||!i&&Ss.test(e)||bs.test(e)||t&&Oi.test(e)||Ms.test(e)&&!(n&&/^\s*data:/i.test(e)&&!Oi.test(e))}function Ln(e,n=new Set,t=0,i=false,o=false,r=""){if(typeof e=="string"){On(e,i,o)&&f("UNSAFE_VALUE","UNSAFE_VALUE",r,"unsafe-value");return}if(!(e===null||typeof e!="object")){(t>8||n.has(e))&&f("MANIFEST_INVALID","MANIFEST_INVALID",r),n.add(e);try{if(Array.isArray(e)){e.forEach((s,a)=>Ln(s,n,t+1,!1,!1,an(r,`[${a}]`)));return}$(e)||f("MANIFEST_INVALID","MANIFEST_INVALID",r);for(let[s,a]of Object.entries(e))Ln(a,n,t+1,i&&t===0&&(s==="name"||s==="description"),o,an(r,s));}finally{n.delete(e);}}}function Ae(e,n){let t=e[n];return typeof t!="string"&&f("MANIFEST_INVALID"),t}function le(e,n,t){let i=e[n];return (!Number.isSafeInteger(i)||i<t)&&f("MANIFEST_INVALID"),i}function ht(e){return Ns.test(e)||f("MANIFEST_INVALID"),e}function Xe(e){return Ps.test(e)||f("TOKEN_INVALID"),e}function Ys(e){return Fi.test(e)||f("MANIFEST_INVALID"),e}function qs(e){$(e)||f("MANIFEST_INVALID");let n={};for(let[t,i]of Object.entries(e)){let o=Ys(t);$(i)||f("MANIFEST_INVALID");let r=i.type;if(r==="text"){W(i,["type","maxLength"]),n[o]={type:r,maxLength:le(i,"maxLength",1)};continue}if(r==="text-list"){W(i,["type","max","itemMaxLength"]),n[o]={type:r,max:le(i,"max",0),itemMaxLength:le(i,"itemMaxLength",1)};continue}if(r==="step-list"){W(i,["type","min","max","labelMaxLength","detailMaxLength"]);let s=le(i,"min",0),a=le(i,"max",1);s>a&&f("MANIFEST_INVALID"),n[o]={type:r,min:s,max:a,labelMaxLength:le(i,"labelMaxLength",1),detailMaxLength:le(i,"detailMaxLength",1)};continue}typeof r=="string"&&f("SCHEMA_TYPE_UNSUPPORTED"),f("MANIFEST_INVALID");}return n}function Zs(e,n,t){let i=e[n];(!i||i.type!==t)&&f("MANIFEST_INVALID");}function Sn(e,n,t){let i=Ae(e,"field");return Fi.test(i)||f("MANIFEST_INVALID"),Zs(n,i,t),i}function Qs(e,n){$(e)||f("MANIFEST_INVALID");let t=e.primitive;switch(typeof t!="string"&&f("MANIFEST_INVALID"),Ks.includes(t)||f("PRIMITIVE_UNKNOWN"),t){case "card-shell":return W(e,["primitive"]),{primitive:t};case "meta-banner":return W(e,["primitive","badgeToken","noticeToken"]),{primitive:t,badgeToken:Xe(Ae(e,"badgeToken")),noticeToken:Xe(Ae(e,"noticeToken"))};case "heading":return W(e,["primitive","field"]),{primitive:t,field:Sn(e,n,"text")};case "labeled-text":return W(e,["primitive","titleToken","field","variant"]),e.variant!=="callout"&&f("MANIFEST_INVALID"),{primitive:t,titleToken:Xe(Ae(e,"titleToken")),field:Sn(e,n,"text"),variant:"callout"};case "step-flow":return W(e,["primitive","titleToken","field"]),{primitive:t,titleToken:Xe(Ae(e,"titleToken")),field:Sn(e,n,"step-list")};case "text-list":{W(e,["primitive","titleToken","field"],["emptyToken","hideWhenEmpty"]);let i={primitive:t,titleToken:Xe(Ae(e,"titleToken")),field:Sn(e,n,"text-list")};return R(e,"emptyToken")&&(i.emptyToken=Xe(Ae(e,"emptyToken"))),R(e,"hideWhenEmpty")&&(typeof e.hideWhenEmpty!="boolean"&&f("MANIFEST_INVALID"),i.hideWhenEmpty=e.hideWhenEmpty),i}}return f("MANIFEST_INVALID")}function ea(e,n){return Array.isArray(e)||f("MANIFEST_INVALID"),e.map(t=>Qs(t,n))}function J(e="v2 manifest exceeds a contract limit",n,t){return f("LIMIT_EXCEEDED",e,n,t)}function de(e="initial state is not projection-safe"){return f("INITIAL_STATE_INVALID",e)}function Ri(e,n){return (typeof e!="string"||e.length===0||e.length>4096||e.trim().length===0||Gs.test(e)||Ws.test(e))&&f("MANIFEST_INVALID",`${n} is invalid`),(On(e,true,true)||Ls.test(e)||Os.test(e)||Rs.test(e))&&f("UNSAFE_VALUE",`${n} contains an unsafe value`),e}function _t(e,n){return (typeof e!="string"||!ye.test(e))&&f("MANIFEST_INVALID",`${n} is invalid`),e}function na(e){return (typeof e!="string"||!at.test(e)||e==="*"||e==="all")&&f("MANIFEST_INVALID","action capability is invalid"),e}function Vi(e){return (typeof e!="string"||!$s.test(e))&&f("MANIFEST_INVALID","resource hash is invalid"),e}function Et(e,n=new Set,t=0,i=""){if(typeof e=="string"){e.length>4096&&J("v2 manifest string is too long",i,"string-too-long");return}if(!(e===null||typeof e=="boolean")){if(typeof e=="number"){Number.isFinite(e)||f("MANIFEST_INVALID","v2 manifest contains a non-finite number",i,"non-finite-number");return}(e===void 0||typeof e=="function"||typeof e=="bigint")&&f("MANIFEST_INVALID","v2 manifest contains a non-JSON value",i,"non-json-value"),typeof e!="object"&&f("MANIFEST_INVALID","MANIFEST_INVALID",i),t>8&&J("v2 manifest nesting is too deep",i,"too-deep"),n.has(e)&&f("MANIFEST_INVALID","v2 manifest contains a cycle",i,"cycle"),n.add(e);try{if(Array.isArray(e)){e.length>128&&J("v2 manifest array is too long",i,"array-too-long"),e.forEach((o,r)=>Et(o,n,t+1,an(i,`[${r}]`)));return}$(e)||f("MANIFEST_INVALID","v2 manifest contains a non-plain object",i,"non-plain-object");for(let[o,r]of Object.entries(e))Et(r,n,t+1,an(i,o));}finally{n.delete(e);}}}function Bi(e){return (typeof e!="string"||e.length>4096||!rn.test(e))&&(typeof e=="string"&&e.length>4096&&J("projection path is too long"),f("MANIFEST_INVALID","projection paths must be canonical exact paths")),e.split(".").some(t=>Je(t))&&f("MANIFEST_INVALID","projection paths cannot address reserved state keys"),e}function Tt(e){$(e)||f("MANIFEST_INVALID","projection policy must be an object"),W(e,["allow"]),Array.isArray(e.allow)||f("MANIFEST_INVALID","projection allow must be an array"),e.allow.length>128&&J("projection allowlist is too long");let n=[],t=new Set;for(let i of e.allow){let o=Bi(i);t.has(o)&&f("MANIFEST_INVALID","projection allowlist contains a duplicate path"),t.add(o),n.push(o);}return {allow:n}}function ta(e,n){if(e===void 0)return;Array.isArray(e)||f("MANIFEST_INVALID","dataPaths must be an array"),e.length>Js&&J("dataPaths exceed the v2 limit");let t=[],i=new Set;for(let o of e){let r=Bi(o);i.has(r)&&f("MANIFEST_INVALID","dataPaths contain a duplicate path"),n.some(s=>Ge(r,s))||f("MANIFEST_INVALID","dataPaths must be projection-allowed"),i.add(r),t.push(r);}return t}function Ye(e,n,t=Number.MAX_SAFE_INTEGER){return (!Number.isSafeInteger(e)||e<0||e>t)&&f("MANIFEST_INVALID",`${n} is invalid`),e}function wi(e,n){return (typeof e!="number"||!Number.isFinite(e))&&f("MANIFEST_INVALID",`${n} is invalid`),e}function Pt(e,n=0,t=new Set){if(typeof e=="string")return (e.length>4096||On(e))&&f("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)||f("MANIFEST_INVALID","schema enum contains a non-finite number"),e;(n>8||typeof e!="object"||e===void 0)&&J("schema enum is too deep"),t.has(e)&&f("MANIFEST_INVALID","schema enum contains a cycle"),t.add(e);try{if(Array.isArray(e))return e.length>128&&J("schema enum array is too long"),e.map(o=>Pt(o,n+1,t));$(e)||f("MANIFEST_INVALID","schema enum contains a non-plain object");let i={};for(let[o,r]of Object.entries(e))Je(o)&&f("MANIFEST_INVALID","schema enum contains a reserved key"),i[o]=Pt(r,n+1,t);return i}finally{t.delete(e);}}function ia(e,n){if(e===void 0)return;Array.isArray(e)||f("MANIFEST_INVALID","schema required must be an array"),e.length>64&&J("schema required list is too long");let t=[],i=new Set;for(let o of e)(typeof o!="string"||!rn.test(o))&&f("MANIFEST_INVALID","schema required contains an invalid key"),o.length>4096&&J("schema required key is too long"),i.has(o)&&f("MANIFEST_INVALID","schema required contains a duplicate key"),n&&!Object.prototype.hasOwnProperty.call(n,o)&&f("MANIFEST_INVALID","schema required references an undeclared property"),i.add(o),t.push(o);return t}function oa(e,n){let t=n?rn:Nn;return e.length>4096&&J("schema property name is too long"),(!t.test(e)||e.split(".").some(i=>Je(i)))&&f("MANIFEST_INVALID","schema property name is invalid"),e}function Nt(e,n=0,t=false){$(e)||f("MANIFEST_INVALID","action inputSchema must be an object"),n>8&&J("action inputSchema is too deep");let i=e.type;i!=="object"&&i!=="string"&&i!=="number"&&i!=="integer"&&i!=="boolean"&&i!=="array"&&i!=="null"&&(typeof i=="string"&&f("SCHEMA_TYPE_UNSUPPORTED","action inputSchema type is unsupported"),f("MANIFEST_INVALID","action inputSchema type is required"));let o=["type","enum"];i==="string"&&o.push("minLength","maxLength"),i==="array"&&o.push("minItems","maxItems","items"),i==="object"&&o.push("minProperties","maxProperties","properties","required","additionalProperties"),(i==="number"||i==="integer")&&o.push("minimum","maximum"),W(e,["type"],o.filter(a=>a!=="type"));let r={type:i};if(R(e,"enum")&&(Array.isArray(e.enum)||f("MANIFEST_INVALID","schema enum must be an array"),e.enum.length>128&&J("schema enum is too long"),r.enum=e.enum.map(a=>Pt(a))),i==="string"&&(R(e,"minLength")&&(r.minLength=Ye(e.minLength,"schema minLength",4096)),R(e,"maxLength")&&(r.maxLength=Ye(e.maxLength,"schema maxLength",4096)),r.minLength!==void 0&&r.maxLength!==void 0&&r.minLength>r.maxLength&&f("MANIFEST_INVALID","schema string length bounds are inverted")),(i==="number"||i==="integer")&&(R(e,"minimum")&&(r.minimum=wi(e.minimum,"schema minimum")),R(e,"maximum")&&(r.maximum=wi(e.maximum,"schema maximum")),r.minimum!==void 0&&r.maximum!==void 0&&r.minimum>r.maximum&&f("MANIFEST_INVALID","schema numeric bounds are inverted")),i==="array"&&(R(e,"minItems")&&(r.minItems=Ye(e.minItems,"schema minItems",128)),R(e,"maxItems")&&(r.maxItems=Ye(e.maxItems,"schema maxItems",128)),r.minItems!==void 0&&r.maxItems!==void 0&&r.minItems>r.maxItems&&f("MANIFEST_INVALID","schema array length bounds are inverted"),R(e,"items")&&(r.items=Nt(e.items,n+1,false))),i==="object"){let a;if(R(e,"properties")){$(e.properties)||f("MANIFEST_INVALID","schema properties must be an object");let d=Object.entries(e.properties);d.length>64&&J("schema properties are too many"),a={};for(let[p,A]of d){let m=oa(p,t);a[m]=Nt(A,n+1,false);}r.properties=a;}R(e,"minProperties")&&(r.minProperties=Ye(e.minProperties,"schema minProperties",64)),R(e,"maxProperties")&&(r.maxProperties=Ye(e.maxProperties,"schema maxProperties",64)),r.minProperties!==void 0&&r.maxProperties!==void 0&&r.minProperties>r.maxProperties&&f("MANIFEST_INVALID","schema object property bounds are inverted");let c=ia(e.required,a);c!==void 0&&(r.required=c),R(e,"additionalProperties")&&(e.additionalProperties!==false&&f("MANIFEST_INVALID","schema additionalProperties must be false"),r.additionalProperties=false);}let s=JSON.stringify(r);return (s===void 0||Buffer.byteLength(s,"utf8")>65536)&&J("action inputSchema subtree is too large"),r}function ra(e){let n=Nt(e,0,true);return (n.type!=="object"||!n.properties)&&f("MANIFEST_INVALID","action inputSchema must declare object properties"),n}function sa(e){if($(e)||f("MANIFEST_INVALID","action backend must be an object"),e.type==="core"){W(e,js);let n=e.handler;return (typeof n!="string"||!ct.test(n))&&f("MANIFEST_INVALID","core backend handler is invalid"),{type:"core",handler:n}}if(e.type==="skill"&&R(e,"entry"))return W(e,Bs),e.entry!==Ke&&f("MANIFEST_INVALID",`skill backend entry must be ${Ke}`),{type:"skill",entry:Ke};if(e.type==="skill"){W(e,Fs,Vs),(!Array.isArray(e.command)||e.command.length===0||e.command.length>16)&&f("MANIFEST_INVALID","skill backend command is invalid");let n=[];for(let i of e.command)(typeof i!="string"||i.length===0||i.length>256||!dt.test(i))&&f("MANIFEST_INVALID","skill backend command token is invalid"),n.push(i);let t=R(e,"env")?ca(e.env):void 0;return {type:"skill",command:n,...t===void 0?{}:{env:t}}}f("MANIFEST_INVALID","action backend type is unsupported");}function aa(e){$(e)||f("MANIFEST_INVALID","action must be an object"),W(e,ks,xs),R(e,"_meta")&&z("_meta",()=>Hi(e._meta));let n=z("actionId",()=>_t(e.actionId,"actionId"));ot(n)&&f("MANIFEST_INVALID",`actionId "${n}" is not projection-safe`,"actionId");let t=z("capability",()=>na(e.capability)),i=e.mutation;typeof i!="boolean"&&f("MANIFEST_INVALID","action mutation must be boolean","mutation");let o=z("inputSchema",()=>ra(e.inputSchema)),r;if(R(e,"dataInputs")){Array.isArray(e.dataInputs)||f("MANIFEST_INVALID","action dataInputs must be an array","dataInputs");let p=o.properties,A=new Set,m=[];for(let y of e.dataInputs)(typeof y!="string"||!R(p,y)||A.has(y))&&f("MANIFEST_INVALID","action dataInputs must be unique declared properties","dataInputs"),A.add(y),m.push(y);r=m;}let s=z("resultProjection",()=>Tt(e.resultProjection)),a=z("backend",()=>sa(e.backend)),c;R(e,"content")&&((a.type!=="skill"||!Dn(e.content))&&f("MANIFEST_INVALID","action content declaration is invalid","content"),c=da(e.content));let d;if(R(e,"confirmation")){let p=e.confirmation;p!=="none"&&p!=="native"&&f("MANIFEST_INVALID","action confirmation is invalid","confirmation"),d=p;}return {actionId:n,capability:t,mutation:i,inputSchema:o,resultProjection:s,backend:a,...c===void 0?{}:{content:c},...r===void 0?{}:{dataInputs:r},...d===void 0?{}:{confirmation:d}}}function ca(e){return hi(e)||f("MANIFEST_INVALID","skill backend env is invalid"),Object.freeze([...e])}function da(e){return Object.freeze({...e.in===void 0?{}:{in:Object.freeze({...e.in})},...e.out===void 0?{}:{out:Object.freeze({...e.out})}})}function pa(e){return $(e)||f("INITIAL_STATE_INVALID","initialState must be an object"),W(e,Hs,zs),e.path!=="ui/state.json"&&f("MANIFEST_INVALID","initialState path is not fixed"),R(e,"hash")?{path:"ui/state.json",hash:Vi(e.hash)}:{path:"ui/state.json"}}function la(e){let n=["wasm","terminal","htmlDocuments"];return (!$(e)||Object.keys(e).length===0||Object.keys(e).some(t=>!n.includes(t)||e[t]!==true))&&f("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 ua(e,n){let t;try{t=Mi(e);}catch(i){let o=i!==null&&typeof i=="object"&&"code"in i&&typeof i.code=="string"?i.code:"CSP_ORIGIN_INVALID";return f("MANIFEST_INVALID",o,void 0,o.toLowerCase().replace(/_/g,"-"))}if(t.frameDomains.length>0&&f("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&&f("MANIFEST_INVALID","runtime.terminal cannot be combined with csp.connectDomains","connectDomains","terminal-with-connect-domains"),Object.freeze({connectDomains:t.connectDomains})}function fa(e,n){Ln($(e)&&R(e,"csp")?Xs(e,"csp"):e,new Set,0,true,true),Et(e),$(e)||f("MANIFEST_INVALID"),W(e,Us,Cs),R(e,"_meta")&&z("_meta",()=>Hi(e._meta)),e.manifestVersion!==2&&f("MANIFEST_INVALID");let t;R(e,"runtime")&&(t=z("runtime",()=>la(e.runtime)));let i;R(e,"csp")&&(i=z("csp",()=>ua(e.csp,t)));let o=z("pluginId",()=>_t(e.pluginId,"pluginId")),r=z("definitionId",()=>_t(e.definitionId,"definitionId")),s=z("version",()=>le(e,"version",1)),a=z("name",()=>Ri(e.name,"name")),c=z("description",()=>Ri(e.description,"description")),d;R(e,"icon")&&((typeof e.icon!="string"||!/^[a-z][a-z0-9-]{0,63}$/.test(e.icon))&&f("MANIFEST_INVALID","icon is invalid","icon"),d=e.icon);let p;R(e,"tone")&&((typeof e.tone!="string"||!pt.includes(e.tone))&&f("MANIFEST_INVALID","tone is invalid","tone"),p=e.tone),e.entry!=="ui/index.html"&&f("MANIFEST_INVALID","entry path is not fixed","entry","fixed-value");let A;R(e,"entryHash")&&(A=z("entryHash",()=>Vi(e.entryHash)));let m;R(e,"initialState")&&(m=z("initialState",()=>pa(e.initialState)));let y;R(e,"usage")&&(e.usage!=="card"&&e.usage!=="window"&&f("MANIFEST_INVALID","usage is invalid","usage"),y=e.usage);let h;R(e,"detailPanel")&&(typeof e.detailPanel!="boolean"&&f("MANIFEST_INVALID","detailPanel is invalid","detailPanel"),h=e.detailPanel);let L;if(R(e,"displayModes")){((y??Re)!==Re||!Array.isArray(e.displayModes)||e.displayModes.length===0)&&f("MANIFEST_INVALID","displayModes are only valid for window Apps","displayModes");let l=new Set(["inline","floating","focused"]);(new Set(e.displayModes).size!==e.displayModes.length||e.displayModes.some(u=>typeof u!="string"||!l.has(u)))&&f("MANIFEST_INVALID","displayModes are invalid","displayModes"),L=e.displayModes;}(y??Re)===Re&&h!==void 0&&f("MANIFEST_INVALID","detailPanel is card-only","detailPanel");let S=n.mode??"local";S!=="local"&&S!=="installed"&&S!=="published"&&f("MANIFEST_INVALID","manifest mode is invalid"),S!=="local"&&A===void 0&&f("MANIFEST_INVALID","installed manifests require entryHash","entryHash","required-when-installed"),S!=="local"&&m!==void 0&&m.hash===void 0&&f("MANIFEST_INVALID","installed manifests require initialState.hash","initialState.hash","required-when-installed"),(!Array.isArray(e.surfaces)||e.surfaces.length===0)&&f("MANIFEST_INVALID","surfaces are invalid","surfaces"),e.surfaces.length>2&&J("surfaces exceed the v2 limit","surfaces","too-many-items");let j=[],C=new Set;for(let l of e.surfaces)(typeof l!="string"||!lt.includes(l))&&f("MANIFEST_INVALID","surface is unsupported","surfaces"),C.has(l)&&f("MANIFEST_INVALID","surfaces contain a duplicate","surfaces","duplicate-item"),C.add(l),j.push(l);$(e.size)||f("MANIFEST_INVALID","size must be an object","size"),z("size",()=>W(e.size,["height"]));let x=z("size",()=>le(e.size,"height",1));x>720&&J("size.height exceeds the v2 limit","size.height","too-large");let F=z("stateProjection",()=>Tt(e.stateProjection)),E=e.summaryProjection===void 0?void 0:z("summaryProjection",()=>Tt(e.summaryProjection));E!==void 0&&E.allow.some(l=>!F.allow.includes(l))&&f("MANIFEST_INVALID","summaryProjection must be a subset of stateProjection.allow","summaryProjection");let T=z("dataPaths",()=>ta(e.dataPaths,F.allow));Array.isArray(e.actions)||f("MANIFEST_INVALID","actions must be an array","actions"),e.actions.length>32&&J("actions exceed the v2 limit","actions","too-many-items");let U=[],D=new Set;for(let[l,u]of e.actions.entries()){let I=`actions[${l}]`,P=z(I,()=>aa(u));if(D.has(P.actionId)&&f("MANIFEST_INVALID","actions contain a duplicate actionId",`${I}.actionId`,"duplicate-item"),P.backend.type==="core"&&P.backend.handler==="state.set"){P.mutation||f("MANIFEST_INVALID","state.set actions must be mutations",`${I}.mutation`);for(let b of Object.keys(P.inputSchema.properties))F.allow.includes(b)||f("MANIFEST_INVALID","state.set input paths must be projection-allowed",`${I}.inputSchema.properties`);}D.add(P.actionId),U.push(P);}return {manifestVersion:2,pluginId:o,definitionId:r,version:s,name:a,description:c,...d===void 0?{}:{icon:d},...p===void 0?{}:{tone:p},entry:"ui/index.html",...A===void 0?{}:{entryHash:A},...t===void 0?{}:{runtime:t},...i===void 0?{}:{csp:i},...m===void 0?{}:{initialState:m},...y===void 0?{}:{usage:y},...h===void 0?{}:{detailPanel:h},...L===void 0?{}:{displayModes:L},surfaces:j,size:{height:x},stateProjection:F,...E===void 0?{}:{summaryProjection:E},...T===void 0?{}:{dataPaths:T},actions:U}}function Hi(e){$(e)||f("MANIFEST_INVALID","_meta must be an object");let n=JSON.stringify(e);(n===void 0||Buffer.byteLength(n,"utf8")>vs)&&J("_meta exceeds the 4 KiB limit",void 0,"meta-too-large");}function ya(e){let n={},t={};for(let r of e.actions){n[r.actionId]={capabilities:[r.capability],inputKeys:Object.keys(r.inputSchema.properties??{}),...r.dataInputs===void 0?{}:{dataInputs:r.dataInputs},resultProjection:r.resultProjection,...r.confirmation===void 0?{}:{confirmation:r.confirmation},...r.content===void 0?{}:{content:r.content},...r.backend.type!=="skill"||r.backend.env===void 0?{}:{env:r.backend.env}};let s=r.backend.type==="skill"||r.backend.type==="core"&&r.backend.handler==="state.set";t[r.actionId]={actionId:r.actionId,mutation:r.mutation,backend:r.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},o={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:o}}function Dt(e,n,t,i,o,r){if(typeof e=="string"){let s=o.length>0&&r.some(a=>Ge(o.join("."),a));return (e.length>4096||On(e,false,false,s))&&de("state contains an unsafe string"),e}if(e===null||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)||de("state contains a non-finite number"),e;(e===void 0||typeof e!="object"||typeof e=="function"||typeof e=="bigint")&&de("state contains a non-JSON value"),t>8&&de("state is too deep"),n.has(e)&&de("state contains a cycle"),n.add(e);try{let s;if(Array.isArray(e))e.length>128&&de("state array is too long"),s=e.map(c=>Dt(c,n,t+1,65536,o,r));else {$(e)||de("state contains a non-plain object");let c={};for(let[d,p]of Object.entries(e))(d.length>4096||!Nn.test(d)||Je(d))&&(d.length>4096&&de("state key is too long"),de("state contains a reserved or invalid key")),c[d]=Dt(p,n,t+1,65536,[...o,d],r);s=c;}let a=JSON.stringify(s);return (a===void 0||Buffer.byteLength(a,"utf8")>i)&&de("state subtree is too large"),s}finally{n.delete(e);}}function St(e,n=[]){$(e)||de("initial state must be a JSON object");let t=Dt(e,new Set,0,65536,[],n);return (t===null||Array.isArray(t)||typeof t!="object")&&de(),t}function Aa(e,n={}){Ln(e),$(e)||f("MANIFEST_INVALID"),W(e,ws),e.manifestVersion!==1&&f("MANIFEST_INVALID");let t=ht(Ae(e,"pluginId")),i=ht(Ae(e,"definitionId")),o=le(e,"version",1),r=le(e,"primitiveSet",1),s=n.supportedPrimitiveSet??Ts;(!Number.isSafeInteger(s)||s<1)&&f("MANIFEST_INVALID"),r>s&&f("PRIMITIVE_SET_UNSUPPORTED"),$(e.activation)||f("MANIFEST_INVALID"),W(e.activation,["kind","language"]),e.activation.kind!=="fenced-code"&&f("MANIFEST_INVALID");let a=ht(Ae(e.activation,"language")),c=qs(e.schema),d=ea(e.layout,c);return {manifestVersion:1,pluginId:t,definitionId:i,version:o,primitiveSet:r,activation:{kind:"fenced-code",language:a},schema:c,layout:d}}function Ia(e,n={}){return $(e)||f("MANIFEST_INVALID"),Object.hasOwn(e,"lineage")&&f("MANIFEST_INVALID","lineage is only allowed in product bundle indexes"),e.manifestVersion===2?fa(e,n):Aa(e,n)}function je(e,n={}){try{return Ia(e,n)}catch(t){if(t instanceof ne)throw t;return f("MANIFEST_INVALID")}}function cn(e,n={}){let t=je(e,n);return t.manifestVersion===2?ya(t):t}var Ts,Ps,Ns,Fi,Ds,bs,Ss,Ms,Oi,Ls,Os,Rs,ws,Us,Cs,ks,xs,vs,js,Fs,Vs,Bs,Hs,zs,$s,Gs,Ws,Js,Ks,ne,Mt=v(()=>{g();gt();Te();yt();_i();It();Li();ke();Ts=1,Ps=/^[a-z][a-zA-Z0-9]*(\.[a-zA-Z0-9]+)+$/,Ns=/^[A-Za-z][A-Za-z0-9._-]{0,127}$/,Fi=/^[A-Za-z][A-Za-z0-9_-]{0,63}$/,Ds=/<\/?[A-Za-z][^>]*>/,bs=/^(?:[A-Za-z]:[\\/]|\\\\|~[\\/]|\/)/,Ss=/^(?:https?|file|ftp|ws|wss):\/\//i,Ms=/^\s*(?:javascript|data):/i,Oi=/data:[^,\s]*,/i,Ls=/(?:https?|file|ftp|ws|wss):\/\//i,Os=/javascript:/i,Rs=/(?:^[\s]*|[\s"'(=])(?:[A-Za-z]:[\\/]|\\\\|~[\\/]|\/)(?=[^\s"'<>])[^\s"'<>]*/,ws=["manifestVersion","pluginId","definitionId","version","primitiveSet","activation","schema","layout"],Us=["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"],ks=["actionId","capability","mutation","inputSchema","resultProjection","backend"],xs=["confirmation","dataInputs","content","_meta"],vs=4*1024,js=["type","handler"],Fs=["type","command"],Vs=["env"],Bs=["type","entry"],Hs=["path"],zs=["hash"],$s=/^[0-9a-f]{64}$/,Gs=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/,Ws=/[\r\n]/,Js=16,Ks=["card-shell","meta-banner","heading","labeled-text","step-flow","text-list"],ne=class e extends Error{constructor(t,i=t,o,r){super(i);this.code=t;this.path=o;this.rule=r;}code;path;rule;name="UiPluginValidationError";withPathPrefix(t){return new e(this.code,this.message,an(t,this.path),this.rule)}};});function Ki(e){return typeof e=="string"&&e.length<=ma&&ga.test(e)}function w(e,n,t,i,o){throw new ge(e,{path:n,rule:t,...i===void 0?{}:{message:i},...o===void 0?{}:{file:o}})}function Z(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;try{let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}catch{return false}}function K(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function fe(e){let n=`_meta["${we}"]`;return e===void 0||e===""?n:e.startsWith("[")?`${n}${e}`:`${n}.${e}`}function Ta(e){return e.toLowerCase().replace(/_/g,"-")}function Pa(e){if(e===void 0||e==="")return "";let n=/^([^.[]+)(.*)$/.exec(e);if(!n)return fe(e);let[,t,i]=n;switch(t){case "pluginId":return `name${i}`;case "name":return `display_name${i}`;case "description":return `description${i}`;case "_meta":return `_meta${i}`;case "version":return fe("definitionVersion");case "definitionId":return fe("definitionId");default:return fe(`${t}${i}`)}}function Xi(e,n,t){return {path:t(e.path),rule:e.rule??Ta(e.code),...e.message!==e.code?{message:e.message}:{},file:n}}function Yi(e){return JSON.parse(JSON.stringify(e))}function Rt(e,n,t=0,i=new Set){if(typeof e=="string"){e.length>4096&&w("LIMIT_EXCEEDED",n,"string-too-long"),(ha.test(e)||_a.test(e)||Ea.test(e))&&w("UNSAFE_VALUE",n,"unsafe-value");return}if(!(e===null||typeof e=="boolean")){if(typeof e=="number"){Number.isFinite(e)||w("MANIFEST_INVALID",n,"non-finite-number");return}typeof e!="object"&&w("MANIFEST_INVALID",n,"non-json-value"),t>8&&w("LIMIT_EXCEEDED",n,"too-deep"),i.has(e)&&w("MANIFEST_INVALID",n,"cycle"),i.add(e);try{if(Array.isArray(e)){e.length>128&&w("LIMIT_EXCEEDED",n,"array-too-long"),e.forEach((o,r)=>Rt(o,`${n}[${r}]`,t+1,i));return}Z(e)||w("MANIFEST_INVALID",n,"non-plain-object");for(let[o,r]of Object.entries(e))Rt(r,n===""?o:`${n}.${o}`,t+1,i);}finally{i.delete(e);}}}function ue(e,n){return (typeof e!="string"||e.length===0)&&w("MANIFEST_INVALID",n,"string"),e}function Ze(e,n){return Z(e)||w("MANIFEST_INVALID",n,"object"),e}function Na(e,n){Array.isArray(e)||w("MANIFEST_INVALID",n,"array"),e.forEach((t,i)=>ue(t,`${n}[${i}]`));}function Da(e,n){typeof e!="boolean"&&w("MANIFEST_INVALID",n,"boolean");}function dn(e,n,t,i){for(let o of Object.keys(e))!t.includes(o)&&!i.includes(o)&&w("MANIFEST_INVALID",`${n}.${o}`,"unknown-key");for(let o of t)K(e,o)||w("MANIFEST_INVALID",`${n}.${o}`,"missing-key");}function ba(e,n){switch(Rt(n,e),e){case "long_description":case "homepage":case "documentation":case "support":case "icon":case "license":ue(n,e);return;case "author":{let t=Ze(n,e);dn(t,e,["name"],["email","url"]);for(let i of Object.keys(t))ue(t[i],`${e}.${i}`);return}case "repository":{let t=Ze(n,e);dn(t,e,[],["type","url"]);for(let i of Object.keys(t))ue(t[i],`${e}.${i}`);return}case "icons":{Array.isArray(n)||w("MANIFEST_INVALID",e,"array"),n.forEach((t,i)=>{let o=`${e}[${i}]`,r=Ze(t,o);dn(r,o,["src","size"],["theme"]),ue(r.src,`${o}.src`),ue(r.size,`${o}.size`),K(r,"theme")&&ue(r.theme,`${o}.theme`);});return}case "screenshots":case "keywords":case "privacy_policies":Na(n,e);return;case "tools":{Array.isArray(n)||w("MANIFEST_INVALID",e,"array"),n.forEach((t,i)=>{let o=`${e}[${i}]`,r=Ze(t,o);dn(r,o,["name"],["description"]),ue(r.name,`${o}.name`),K(r,"description")&&ue(r.description,`${o}.description`);});return}case "prompts":{Array.isArray(n)||w("MANIFEST_INVALID",e,"array"),n.forEach((t,i)=>{let o=`${e}[${i}]`,r=Ze(t,o);dn(r,o,["name","text"],["description","arguments"]),ue(r.name,`${o}.name`),ue(r.text,`${o}.text`);});return}case "tools_generated":case "prompts_generated":Da(n,e);return;case "localization":case "compatibility":case "user_config":Ze(n,e);return;default:w("MANIFEST_INVALID",e,"unknown-key");}}function Rn(e){return typeof e=="string"&&ye.test(e)?e:void 0}function qi(e){return Number.isSafeInteger(e)&&e>=1?e:void 0}function Sa(e){let n=Rn(e.name);if(n===void 0)return;let t=e._meta,i=Z(t)?t[we]:void 0,o=Z(i)?i:{},r=K(o,"definitionId")?Rn(o.definitionId):n,s=K(o,"definitionVersion")?qi(o.definitionVersion):1;return {pluginId:n,...r===void 0?{}:{definitionId:r},...s===void 0?{}:{definitionVersion:s}}}function Ma(e){let n=Rn(e.pluginId);if(n===void 0)return;let t=Rn(e.definitionId),i=qi(e.version);return {pluginId:n,...t===void 0?{}:{definitionId:t},...i===void 0?{}:{definitionVersion:i}}}function Ct(e){try{let n=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e));if(!Z(n))return !1;let t=n._meta;return Z(t)&&K(t,we)}catch{return false}}function La(e,n){if(e===re)return n.builtinOnly===true;let t=n._meta,i=Z(t)?t[we]:void 0;return Z(i)&&i.builtinOnly===true}function Oa(e,n){K(e,"server")&&w("MANIFEST_INVALID","server","server-unsupported","phase 1 runs CrewX-owned Apps only");for(let a of Object.keys(e))wt.includes(a)||w("MANIFEST_INVALID",a,"unknown-key");for(let a of Ut)K(e,a)||w("MANIFEST_INVALID",a,"missing-key");e.manifest_version!==Lt&&w("MANIFEST_INVALID","manifest_version","unsupported-version",`manifest_version must be "${Lt}"`),Ki(e.version)||w("MANIFEST_INVALID","version","semver","version must be a semver.org version such as 0.1.0");let t=e._meta;Z(t)||w("MANIFEST_INVALID","_meta","object"),K(t,we)||w("MANIFEST_INVALID",fe(),"missing-key");let i=t[we];Z(i)||w("MANIFEST_INVALID",fe(),"object");for(let a of Object.keys(i))Ot.includes(a)||Ji.includes(a)||w("MANIFEST_INVALID",fe(a),"unknown-key");for(let a of Ot)a==="actions"&&n!==void 0||K(i,a)||w("MANIFEST_INVALID",fe(a),"missing-key");if(n!==void 0&&K(i,"actions")&&w("MANIFEST_INVALID",fe("actions"),"two-truths",`actions are declared in both ${G} and ${V}; a server.ts App keeps them in the tools file only`),Ra(i.actions),K(i,"definitionVersion")){let a=i.definitionVersion;(!Number.isSafeInteger(a)||a<1)&&w("MANIFEST_INVALID",fe("definitionVersion"),"positive-integer");}let o={};for(let a of Wi)K(e,a)&&(ba(a,e[a]),o[a]=Yi(e[a]));let r={};for(let[a,c]of Object.entries(t))a!==we&&(r[a]=c);let s={manifestVersion:2,pluginId:e.name,definitionId:K(i,"definitionId")?i.definitionId:e.name,version:K(i,"definitionVersion")?i.definitionVersion:1,name:e.display_name,description:e.description};for(let[a,c]of Object.entries(i))a==="definitionId"||a==="definitionVersion"||(s[a]=c);return n!==void 0&&(s.actions=n.map(a=>({...a,backend:{type:"skill",entry:Ke}}))),Object.keys(r).length>0&&(s._meta=r),{v2Input:s,...Object.keys(r).length>0?{vendorMeta:r}:{},passthrough:o}}function Ra(e){Array.isArray(e)&&e.forEach((n,t)=>{let i=Z(n)?n.backend:void 0;Z(i)&&K(i,"entry")&&w("MANIFEST_INVALID",fe(`actions[${t}].backend.entry`),"entry-not-authorable",`an action in ${G} cannot name an entry; a server.ts App declares its actions in ${V}`);});}function wa(e,n,t){Z(e)||w("MANIFEST_INVALID","","not-object","manifest.json must be a JSON object",G);let i;try{i=Oa(e,t);}catch(s){throw s instanceof ge?new ge(s.code,{...s.reason,file:G}):s}let o;try{let s=je(i.v2Input,{mode:n.mode??"local"});s.manifestVersion!==2&&w("MANIFEST_INVALID","","v2-required"),o=s;}catch(s){throw s instanceof ne?new ge(s.code,Xi(s,G,Pa)):s}let r=e.tools;if(Array.isArray(r)){let s=new Set(o.actions.map(a=>a.actionId));r.forEach((a,c)=>{let d=a.name;if(!s.has(d))throw new ge("MANIFEST_INVALID",{path:`tools[${c}].name`,rule:"tool-not-action",message:"every tools[].name must be an action id",file:G})});}return {file:G,manifest:o,v2Input:i.v2Input,releaseVersion:e.version,...Object.keys(i.passthrough).length>0?{mcpb:i.passthrough}:{}}}function Ua(e,n){try{let t=je(e,{mode:n.mode??"local"});if(t.manifestVersion!==2)throw new ge("MANIFEST_INVALID",{path:"manifestVersion",rule:"v2-required",message:"a workspace App requires manifestVersion 2",file:re});return {file:re,manifest:t,v2Input:e}}catch(t){throw t instanceof ne?new ge(t.code,Xi(t,re,i=>i??"")):t}}function Qe(e){return pe(cn(e).definition)}function $i(e){let{entryHash:n,initialState:t,...i}=e,o={...i};return t!==void 0&&(o.initialState={path:t.path}),Yi(o)}function Ca(e,n){let t=$i(e),i=$i(n);return [...new Set([...Object.keys(t),...Object.keys(i)])].sort().filter(r=>oe(t[r]??null)!==oe(i[r]??null))}function ka(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 xa(e,n){let t=Ca(e,n),i=ka(e,n),o="";try{let r=Qe(e),s=Qe(n);i=i||r!==s,o=` (definition hash ${r.slice(0,12)} vs ${s.slice(0,12)})`;}catch{i=true;}t.length===0&&!i||w("MANIFEST_DUAL_MISMATCH","","dual-manifest-mismatch",`${G} and ${re} normalize to different definitions${o}`+(t.length>0?`; differing fields: ${t.join(", ")}`:""));}function Ie(e,n,t="MANIFEST_INVALID",i){return {code:t,reason:{path:e,rule:n,...i===void 0?{}:{message:i},file:V},files:[]}}function Gi(e){return {...Ie("","tools-needs-manifest-json","MANIFEST_INVALID",`${V} is read with ${G} only`),files:e}}function va(e,n){if(e.byteLength>n)return {failure:Ie("","file-too-large","LIMIT_EXCEEDED")};let t;try{t=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e));}catch{return {failure:Ie("","invalid-json")}}if(!Z(t))return {failure:Ie("","not-object","MANIFEST_INVALID",`${V} must be a JSON object`)};for(let o of Object.keys(t))if(o!=="schemaVersion"&&o!=="actions")return {failure:Ie(o,"unknown-key")};for(let o of ["schemaVersion","actions"])if(!K(t,o))return {failure:Ie(o,"missing-key")};if(t.schemaVersion!==1)return {failure:Ie("schemaVersion","unsupported-version","MANIFEST_INVALID",`schemaVersion must be ${1}`)};let i=t.actions;if(!Array.isArray(i))return {failure:Ie("actions","array")};for(let[o,r]of i.entries()){if(!Z(r))return {failure:Ie(`actions[${o}]`,"object")};if(K(r,"backend"))return {failure:Ie(`actions[${o}].backend`,"tools-backend","MANIFEST_INVALID",`an action in ${V} cannot carry a backend`)}}return {actions:i}}function ja(e,n){let t=n.maxBytes??262144,i=[],o=new TextDecoder("utf-8",{fatal:true});for(let r of X){let s=e[r];if(s===void 0)continue;if(s.byteLength>t)return {parsed:i,failure:{code:"LIMIT_EXCEEDED",reason:{path:"",rule:"file-too-large",file:r},files:[r]}};let a;try{a=JSON.parse(o.decode(s));}catch{return {parsed:i,failure:{code:"MANIFEST_INVALID",reason:{path:"",rule:"invalid-json",file:r},files:[r]}}}if(!Z(a))return {parsed:i,failure:{code:"MANIFEST_INVALID",reason:{path:"",rule:"not-object",message:`${r} must be a JSON object`,file:r},files:[r]}};i.push({file:r,raw:a});}return {parsed:i}}function Fe(e,n={}){let{parsed:t,failure:i}=ja(e,n),o=X.filter(y=>e[y]!==void 0);if(i!==void 0)return {ok:false,rejection:i,parseFailure:true,builtinOnly:false};let r=e[V],s=r===void 0?void 0:va(r,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:[]}:Gi(o),parseFailure:true,builtinOnly:false};let a=t[0],c=a.file===G?Sa(a.raw):Ma(a.raw),d=t.some(y=>La(y.file,y.raw)),p;if(s!==void 0){let y=t.some(h=>h.file===G)?s.failure:Gi(o);if(y!==void 0)return {ok:false,rejection:y,parseFailure:false,...c===void 0?{}:{identity:c},builtinOnly:d};p=s.actions;}let A=[];try{for(let y of t)A.push(y.file===G?wa(y.raw,n,p):Ua(y.raw,n));A.length===2&&xa(A[0].manifest,A[1].manifest);}catch(y){if(y instanceof ge)return {ok:false,rejection:{code:y.code,reason:y.reason,files:y.code==="MANIFEST_DUAL_MISMATCH"?[...X]:y.reason.file===void 0||y.reason.file===V?o:[y.reason.file]},parseFailure:false,...c===void 0?{}:{identity:c},builtinOnly:d};throw y}let m=A[0];return {ok:true,...m,identity:c??{pluginId:m.manifest.pluginId},files:o}}var G,re,X,Lt,we,wt,Ut,Wi,Ot,Ji,ga,ma,ha,_a,Ea,ge,wn=v(()=>{g();xe();Te();It();ke();Mt();G="manifest.json",re="ui-plugin.json",X=[G,re],Lt="0.3",we="dev.crewx",wt=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"]),Ut=Object.freeze(["manifest_version","name","display_name","version","description","_meta"]),Wi=Object.freeze(wt.filter(e=>e!=="server"&&!Ut.includes(e))),Ot=Object.freeze(["entry","surfaces","size","stateProjection","actions"]),Ji=Object.freeze(["definitionId","definitionVersion","icon","tone","entryHash","runtime","initialState","usage","detailPanel","displayModes","summaryProjection","dataPaths","focusedAiDataPaths","csp"]),ga=/^(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-]+)*))?$/,ma=256,ha=/<\/?[A-Za-z][^>]*>/,_a=/^\s*javascript:/i,Ea=/data:[^,\s]*,/i;ge=class extends Error{constructor(t,i){super(`${t}: ${i.path||"<file>"} (${i.rule})`);this.code=t;this.reason=i;}code;reason};});var kt=v(()=>{g();Ai();wn();Mt();ke();});function Cn(e,n=e){throw new Ce(e,n)}var Ce,kn=v(()=>{g();Ce=class extends Error{constructor(t,i=t){super(i);this.code=t;}code;name="McpAppContractError"};});var co=v(()=>{g();});var po=v(()=>{g();xe();Te();kn();co();});function lo(e,n){return Ya.add(e),n!==void 0&&qa.set(e,n),e}var Ya,qa,xn=v(()=>{g();Ya=new WeakSet,qa=new WeakMap;});function fn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function vt(e,n,t=[]){let i=new Set([...n,...t]),o=Object.keys(e);return n.every(r=>Object.hasOwn(e,r))&&o.every(r=>i.has(r))}function yo(e){if(e===null||typeof e!="object"||Object.isFrozen(e))return e;for(let n of Object.values(e))yo(n);return Object.freeze(e)}function Q(e){throw new me("LINEAGE_INVALID",e)}function oc(e){throw new me("LINEAGE_STALE",e)}function Ao(e){if(!fn(e)||!vt(e,ec,nc)||!fn(e.actions))return Q("Lineage definition shape is invalid");for(let n of Object.values(e.actions))if(!fn(n)||!vt(n,tc,ic))return Q("Lineage action definition shape is invalid");return e}function rc(e){if(!fn(e)||!vt(e,Za,Qa))return Q("Lineage entry shape is invalid");if(!Number.isSafeInteger(e.version)||e.version<1||typeof e.hash!="string"||!uo.test(e.hash))return Q("Lineage entry identity is invalid");if(e.sourceHash!==void 0&&(typeof e.sourceHash!="string"||!uo.test(e.sourceHash)))return Q("Lineage source hash is invalid");if(e.compat!==void 0&&e.compat!=="break")return Q("Lineage compatibility marker is invalid");let n=Ao(e.definition);if(n.version!==e.version)return Q("Lineage version does not match its definition");if(e.sourceHash!==void 0&&n.sourceHash!==e.sourceHash)return Q("Lineage source hash does not match its definition");let t;try{t=pe(n),Pe({...n,hash:e.hash});}catch{return Q("Lineage definition is invalid")}return t!==e.hash?Q("Lineage definition hash does not match"):yo({version:e.version,hash:e.hash,definition:n,...e.sourceHash===void 0?{}:{sourceHash:e.sourceHash},...e.compat===void 0?{}:{compat:e.compat}})}function fo(e){return e.stateProjection?.allow??[]}function sc(e,n){let t=[],i=new Set(fo(n));fo(e).some(a=>!i.has(a))&&t.push("S1_STATE_PROJECTION");let o=new Set(n.dataPaths??[]);(e.dataPaths??[]).some(a=>!o.has(a))&&t.push("S2_DATA_PATHS");for(let[a,c]of Object.entries(e.actions)){let d=n.actions[a];if(d&&(c.confirmation??"native")==="native"&&(d.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(c=>!a.has(c))&&t.push("S5_SUMMARY_PROJECTION");}return t}function ac(e,n){return oe(e)===oe(n)}function jt(e,n){if(!Array.isArray(e)||e.length===0)return Q("Definition lineage is missing");if(!fn(n)||typeof n.hash!="string")return Q("Current definition is invalid");let t,i;try{let{hash:a,...c}=n;i=Ao(c),t={...i,hash:a},Pe(t);}catch{return Q("Current definition is invalid")}let o=e.map(rc),r=o[0].definition.id;if(o.some(a=>a.definition.id!==r))return Q("Lineage definition ids do not match");if(o.some((a,c)=>c>0&&a.version<=o[c-1].version))return Q("Lineage generations are not in increasing version order");if(o.some((a,c)=>o.findIndex(d=>d.hash===a.hash)!==c))return Q("Lineage contains a duplicate hash");let s=o[o.length-1];if(s.version!==t.version||s.hash!==t.hash||s.definition.id!==t.id||!ac(s.definition,i))return oc("The last lineage generation does not match the current package");if(t.legacy!==void 0){let a=new Set(Object.keys(t.actions)),c=new Set;for(let p of o)if(p.sourceHash===void 0)for(let A of Object.keys(p.definition.actions))a.has(A)&&c.add(A);let d=Object.keys(t.legacy.agentAccess??{});if(d.length!==c.size||d.some(p=>!c.has(p))){let p="S4_LEGACY_AGENT_ACCESS_COMPLETE";throw new me("LINEAGE_INVALID",`Lineage compatibility failed: ${p}`,[p])}}for(let a=0;a<o.length-1;a+=1){if(o.slice(a,-1).some(p=>p.compat==="break"))continue;let d=sc(o[a].definition,t);if(d.length>0)throw new me("LINEAGE_INVALID",`Lineage compatibility failed: ${d.join(", ")}`,d)}return Object.freeze({entries:Object.freeze(o),current:t})}var me,uo,Za,Qa,ec,nc,tc,ic,Ft=v(()=>{g();xe();Te();me=class extends Error{constructor(t,i=t,o=[]){super(i);this.code=t;this.violations=o;}code;violations;name="UiDefinitionLineageError"},uo=/^[0-9a-f]{64}$/,Za=["version","hash","definition"],Qa=["sourceHash","compat"],ec=["id","version","actions"],nc=["sourceHash","usage","detailPanel","displayModes","renderer","surfaces","stateProjection","dataPaths","summaryProjection","legacy"],tc=["capabilities"],ic=["inputKeys","dataInputs","confirmation","resultProjection","content","env"];});var Io,go,mo=v(()=>{g();Io=["crewx_app_terminal_connect","crewx_app_html_viewer_open"],go=["crewx_listWorkspaces","crewx_queryAgent","crewx_executeAgent","crewx_getTaskResult","crewx_listTasks","crewx_listAgents","callBrowser","openTab","listTabs","closeTab"];});var ho=v(()=>{g();xe();xn();});function Vt(e,n=0){try{let t=Ee(e,n);return t.type!==void 0&&t.type!=="object"&&Cn("TOOL_INVALID","MCP App inputSchema must describe an object"),t}catch(t){if(t instanceof Ce)throw t;Cn("TOOL_INVALID","MCP App inputSchema must be projection-safe JSON");}}function _o(e){if(e.length===0)return Vt({type:"object",properties:{},additionalProperties:false});let n=e.map(i=>i.actionId),t=new Map;for(let i of e)t.set(i.actionId,Vt(i.inputSchema));return Vt(pc(n,t),dc)}function pc(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})}var yn,dc,Bt=v(()=>{g();po();xe();Te();xn();kn();Ft();mo();ho();yn=8*1024*1024,new Set(Io),new Set(go),dc=4;});function lc(e){if(e===null||typeof e!="object"||!(Eo in e))throw new TypeError("scanCache must be created by createWorkspaceAppScanCache");return e[Eo]}function To(e,n){let t=lc(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 Eo,Po=v(()=>{g();Eo=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 N("NOT_FOUND"):n==="ELOOP"?new N("PATH_ESCAPED"):n==="EFBIG"||n==="EOVERFLOW"?new N("LIMIT_EXCEEDED"):n==="EACCES"||n==="EPERM"||n==="ENOTDIR"?new N("READ_DENIED"):new N("READ_DENIED")}function Ac(e){if(typeof e!="string"||e.length===0||!ie.isAbsolute(e))throw new N("READ_DENIED")}function Ht(e){if(typeof e!="string"||ie.isAbsolute(e)||/[\\\u0000]/.test(e))throw new N("PATH_ESCAPED");if(e==="")return [];let n=e.split("/");if(n.some(t=>t.length===0||t==="."||t===".."))throw new N("PATH_ESCAPED");return n}function Vn(e,n){let t=ie.relative(e,n);return t===""||t!==".."&&!t.startsWith(`..${ie.sep}`)&&!ie.isAbsolute(t)}function nn(e){return {dev:e.dev,ino:e.ino,size:e.size,mtimeNs:e.mtimeNs,ctimeNs:e.ctimeNs}}function Wt(e,n){return e.dev===n.dev&&e.ino===n.ino}function Jt(e,n){return Wt(e,n)&&e.size===n.size&&e.mtimeNs===n.mtimeNs&&e.ctimeNs===n.ctimeNs}async function vn(e){Ac(e);let n,t;try{n=await promises.realpath(e),t=await promises.stat(n,{bigint:!0});}catch(i){throw ae(i)}if(!t.isDirectory())throw new N("READ_DENIED");return {realRoot:n,identity:nn(t)}}async function bo(e,n,t){if(t.length<2||t[0]!=="apps"&&t[0]!=="skills")return;let i,o;try{if(i=ie.resolve(e,t[0],t[1]),o=await promises.realpath(i),!(await promises.stat(o,{bigint:!0})).isDirectory())throw new N("READ_DENIED")}catch(r){throw r instanceof N?r:ae(r)}if(!Vn(n,o))throw new N("PATH_ESCAPED");return o}async function jn(e,n,t,i){let o,r,s;try{o=await promises.lstat(e,{bigint:!0}),r=await promises.realpath(e),s=await promises.stat(r,{bigint:!0});}catch(a){throw ae(a)}if(!Vn(n,r)||t!==void 0&&!Vn(t,r))throw new N("PATH_ESCAPED");if(!o.isFile()||!s.isFile())throw new N("READ_DENIED");if(!Wt(i,o)||!Wt(i,s)||i.dev!==s.dev)throw new N("PATH_ESCAPED")}async function en(e,n){let t,i;try{t=await promises.realpath(e),i=await promises.stat(t,{bigint:!0});}catch{throw new N("PATH_ESCAPED")}if(t!==n.realRoot||!Jt(n.identity,nn(i)))throw new N("PATH_ESCAPED")}function Ic(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 N,Gt,yc,Do,Bn,So,Xt=v(()=>{g();N=class extends Error{constructor(t){super(t);this.code=t;}code;name="AppDiscoveryFsError"},Gt=q.constants.O_NOFOLLOW,yc=q.constants.O_NONBLOCK,Do=q.constants.O_RDONLY|(Gt??0)|(yc??0);Bn=class{async getRootIdentity(n){let t=await vn(n);return await en(n,t),{dev:t.identity.dev,ino:t.identity.ino,realPath:t.realRoot}}async listDirectory(n,t){let i=Ht(t),o=await vn(n),r=ie.resolve(n,...i),s,a;try{s=await promises.realpath(r),a=await promises.stat(s,{bigint:!0});}catch(c){let d=ae(c);if(d.code==="NOT_FOUND")return [];throw d}if(!Vn(o.realRoot,s)||!a.isDirectory())throw new N("PATH_ESCAPED");try{let c=await promises.readdir(s,{withFileTypes:!0,encoding:"utf8"});return await en(n,o),c.map(Ic)}catch(c){let d=ae(c);if(d.code==="NOT_FOUND")return [];throw d}}async readdir(n,t){return this.listDirectory(n,t)}async readDirectory(n,t){return this.listDirectory(n,t)}async readVerifiedFile(n,t,i){if(!Number.isSafeInteger(i)||i<0)throw new N("READ_DENIED");if(Gt===void 0)throw new N("UNSUPPORTED");let o=Ht(t),r=await vn(n),s=ie.resolve(n,...o),a=ie.relative(n,s);if(a===".."||a.startsWith(`..${ie.sep}`)||ie.isAbsolute(a))throw new N("PATH_ESCAPED");let c;try{c=await promises.open(s,Do);}catch(d){throw ae(d)}try{let d;try{let h=await c.stat({bigint:!0});d=nn(h);}catch(h){throw ae(h)}if(d.size>BigInt(i))throw new N("LIMIT_EXCEEDED");if(d.size>BigInt(Number.MAX_SAFE_INTEGER))throw new N("LIMIT_EXCEEDED");await en(n,r);let p=await bo(n,r.realRoot,o);await jn(s,r.realRoot,p,d);let A=new Uint8Array(new ArrayBuffer(Number(d.size))),m=0;for(;m<A.byteLength;){let h;try{h=(await c.read(A,m,A.byteLength-m,m)).bytesRead;}catch(L){throw ae(L)}if(h<=0)throw new N("IDENTITY_CHANGED");m+=h;}let y;try{let h=await c.stat({bigint:!0});y=nn(h);}catch(h){throw ae(h)}if(!Jt(d,y))throw new N("IDENTITY_CHANGED");return await jn(s,r.realRoot,p,y),await en(n,r),new Uint8Array(A)}finally{await c.close().catch(()=>{});}}async fingerprintVerifiedFile(n,t,i){if(!Number.isSafeInteger(i)||i<0)throw new N("READ_DENIED");if(Gt===void 0)throw new N("UNSUPPORTED");let o=Ht(t),r=await vn(n),s=ie.resolve(n,...o),a=ie.relative(n,s);if(a===".."||a.startsWith(`..${ie.sep}`)||ie.isAbsolute(a))throw new N("PATH_ESCAPED");let c;try{c=await promises.open(s,Do);}catch(d){throw ae(d)}try{let d;try{let m=await c.stat({bigint:!0});d=nn(m);}catch(m){throw ae(m)}if(d.size>BigInt(i)||d.size>BigInt(Number.MAX_SAFE_INTEGER))throw new N("LIMIT_EXCEEDED");await en(n,r);let p=await bo(n,r.realRoot,o);await jn(s,r.realRoot,p,d);let A;try{let m=await c.stat({bigint:!0});A=nn(m);}catch(m){throw ae(m)}if(!Jt(d,A))throw new N("IDENTITY_CHANGED");return await jn(s,r.realRoot,p,A),await en(n,r),{...A,candidateRealPath:p??r.realRoot}}catch(d){throw d instanceof N?d:ae(d)}finally{await c.close().catch(()=>{});}}async readFileVerified(n,t,i){return this.readVerifiedFile(n,t,i)}},So=new Bn;});function mn(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"&&ye.test(e)?e:void 0}function Pc(e){return e.length>0&&e!=="."&&e!==".."&&!/[\\/\u0000]/.test(e)}function Be(e,n){let t=new TextEncoder().encode(e),i=new TextEncoder().encode(n),o=Math.min(t.byteLength,i.byteLength);for(let r=0;r<o;r+=1){let s=t[r]-i[r];if(s!==0)return s}return t.byteLength-i.byteLength}function Nc(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 o=n.isFile;return typeof o=="function"&&o.call(e)?{name:n.name,kind:"file"}:{name:n.name,kind:"other"}}function Dc(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 bc(e){return Ec.decode(e)}function Sc(e){return JSON.parse(bc(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 Mc(e){if(e instanceof N)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 De(e,n){let t=n();return Number.isFinite(t)&&Number.isFinite(e)&&t-e<=5e3}function Lc(e){if(typeof e.readVerifiedFile=="function")return e.readVerifiedFile;if(typeof e.readFileVerified=="function")return e.readFileVerified}function Oc(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 o=Lc(e);if(!o)throw new N("READ_DENIED");return Dc(await o.call(e,n,t,i))}async function Zt(e,n,t){let i=Oc(e);if(!i)throw new N("READ_DENIED");let o=await i.call(e,n,t);if(!Array.isArray(o))throw new N("READ_DENIED");return o.map(Nc).filter(r=>r!==null)}function Rc(e,n,t,i){return Object.freeze({code:e,...{},source:n,relativePath:t})}function wc(e){if(!mn(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,o)=>{if(!Array.isArray(i))throw new TypeError("productBundle.reservedIds."+o+" must be an array");let r=[];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."+o+" must contain non-empty strings");r.push(a);}return Object.freeze([...new Set(r)].sort(Be))};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 zn(e){return Object.freeze({appIds:Object.freeze([...new Set(e.map(n=>n.appId))].sort(Be)),definitionIds:Object.freeze([...new Set(e.map(n=>n.definition.id))].sort(Be))})}function Hn(e,n){let t=Object.keys(e).sort(Be),i=[...n].sort(Be);return t.length===i.length&&t.every((o,r)=>o===i[r])}function wo(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 Cc(e){let n;try{n=Sc(e);}catch{return}if(!mn(n)||!Hn(n,["version","packages"])||n.version!==1||!Array.isArray(n.packages)||n.packages.length>Qt)return;let t=new Set,i=new Set,o=0,r=[];for(let s of n.packages){if(!mn(s))return;let a=["packageDir","appId","definition","files"],c=Object.hasOwn(s,"lineage"),d=Object.hasOwn(s,"launcher"),p=[...c?["lineage"]:[],...d?["launcher"]:[]];if(!Hn(s,[...a,...p])||d&&s.launcher!==false)return;let A=wo(s.packageDir),m=Lo(s.appId);if(!A||A.length!==2||A[0]!=="apps"||!Pc(A[1])||!m||t.has(s.packageDir)||!mn(s.definition)||!Hn(s.definition,["id","version","hash"]))return;let y=Lo(s.definition.id),h=s.definition.version,L=s.definition.hash;if(!y||!Number.isSafeInteger(h)||h<1||typeof L!="string"||!qt.test(L)||!Array.isArray(s.files)||s.files.length<2||s.files.length>ei)return;let S=new Set,j=[];for(let C of s.files){if(!mn(C)||!Hn(C,["path","sha256"]))return;let x=wo(C.path);if(!x||typeof C.sha256!="string"||!qt.test(C.sha256))return;let F=x.join("/"),E=`${s.packageDir}/${F}`;if(S.has(F)||i.has(E))return;S.add(F),i.add(E),j.push(Object.freeze({path:F,sha256:C.sha256}));}if(!X.some(C=>S.has(C))||!S.has("ui/index.html")||(o+=j.length,o>mc))return;t.add(s.packageDir),r.push(Object.freeze({packageDir:s.packageDir,...d?{launcher:false}:{},appId:m,definition:Object.freeze({id:y,version:h,hash:L}),lineage:Array.isArray(s.lineage)?s.lineage:[],files:Object.freeze(j.sort((C,x)=>Be(C.path,x.path)))}));}return Object.freeze({version:1,packages:Object.freeze(r)})}function Ve(e){let n=Mc(e);return n==="PATH_ESCAPED"||n==="IDENTITY_CHANGED"||n==="TOCTOU"?"PATH_ESCAPED":n==="LIMIT_EXCEEDED"?"LIMIT_EXCEEDED":"BUNDLE_INTEGRITY"}async function kc(e,n,t,i,o){let r=[],s=async(a,c)=>{if(!De(i,o))throw new N("LIMIT_EXCEEDED");if(c>2)throw new N("LIMIT_EXCEEDED");let d=await Zt(e,n,a);for(let p of d){if(typeof p.name!="string"||p.name.length===0||p.name==="."||p.name===".."||/[\\/\u0000]/.test(p.name))throw new N("PATH_ESCAPED");let A=`${a}/${p.name}`;if(p.kind==="file"){if(r.push(A.slice(t.length+1)),r.length>ei)throw new N("LIMIT_EXCEEDED")}else if(p.kind==="directory")await s(A,c+1);else throw p.kind==="symlink"?new N("PATH_ESCAPED"):new N("READ_DENIED")}};return await s(t,0),r.sort(Be)}function xc(e){return X.includes(e)?262144:e==="ui/index.html"?yn:e==="ui/state.json"?65536:e.startsWith("ui/assets/")?_c:hc}async function Uo(e,n,t,i){if(e===void 0)return {packages:[],diagnostics:[],incomplete:false,reservedIds:Tc};let o=wc(e.reservedIds),r=[],s=(l,u,I)=>Rc(l,"bundled",u),a=(l=[],u=false,I)=>({...I===void 0?{}:{indexHash:I},packages:l,diagnostics:r,incomplete:u,reservedIds:o});if(typeof e.root!="string"||e.root.length===0||typeof e.expectedIndexHash!="string"||!qt.test(e.expectedIndexHash))return r.push(s("BUNDLE_INTEGRITY","bundle-index.json")),a();let c;try{c=await Ro(n,e.root,"bundle-index.json",gc);}catch(l){return r.push(s(Ve(l),"bundle-index.json")),a()}let d=li.createHash("sha256").update(c).digest("hex");if(d!==e.expectedIndexHash)return r.push(s("BUNDLE_INTEGRITY","bundle-index.json")),a();let p=Cc(c);if(p===void 0)return r.push(s("BUNDLE_INTEGRITY","bundle-index.json")),a();if(!Uc(zn(p.packages),o))return r.push(s("BUNDLE_INTEGRITY","bundle-index.json")),a([],false,d);if(!De(t,i))return r.push(s("LIMIT_EXCEEDED","bundle-index.json")),a(p.packages.map(l=>({indexEntry:l,failureCode:"LIMIT_EXCEEDED"})),true,d);let A;try{A=await Zt(n,e.root,"");}catch(l){return r.push(s(Ve(l),"bundle-index.json")),a(p.packages.map(u=>({indexEntry:u,failureCode:Ve(l)})),false,d)}if(!De(t,i))return r.push(s("LIMIT_EXCEEDED","bundle-index.json")),a(p.packages.map(l=>({indexEntry:l,failureCode:"LIMIT_EXCEEDED"})),true,d);let m=A.find(l=>l.name==="bundle-index.json"&&l.kind==="file"),y=A.find(l=>l.name==="apps"&&l.kind==="directory"),h=l=>p.packages.map(u=>({indexEntry:u,failureCode:l}));if(!m)return r.push(s("BUNDLE_INTEGRITY","bundle-index.json")),a(h("BUNDLE_INTEGRITY"),false,d);let L=A.filter(l=>l.name!=="bundle-index.json"&&l.name!=="apps");if(L.length>0){let l=L.some(u=>u.kind==="symlink")?"PATH_ESCAPED":"BUNDLE_INTEGRITY";return r.push(s(l,"bundle-index.json")),a(h("BUNDLE_INTEGRITY"),false,d)}if(A.some(l=>l.name==="apps"&&l.kind!=="directory"))return r.push(s("PATH_ESCAPED","apps")),a(h("PATH_ESCAPED"),false,d);let S=[];if(y)try{S=await Zt(n,e.root,"apps");}catch(l){return r.push(s(Ve(l),"apps")),a(h(Ve(l)),false,d)}if(!De(t,i)||S.length>Qt)return r.push(s("LIMIT_EXCEEDED","apps")),a(h("LIMIT_EXCEEDED"),true,d);let j=new Map(p.packages.map(l=>[l.packageDir.slice(5),l])),C=S.filter(l=>!j.has(l.name));for(let l of C)r.push(s(l.kind==="symlink"?"PATH_ESCAPED":"BUNDLE_INTEGRITY",`apps/${l.name}`));if(C.length>0){let l=C.some(u=>u.kind==="symlink")?"PATH_ESCAPED":"BUNDLE_INTEGRITY";return a(h(l),false,d)}let x=new Set,F=new Map,E=new Map;for(let l of p.packages){let u=F.get(l.appId)??[];u.push(l),F.set(l.appId,u);let I=`${l.definition.id}\0${String(l.definition.version)}`,P=E.get(I)??[];P.push(l),E.set(I,P);}for(let l of [...F.values(),...E.values()])if(l.length>1)for(let u of l)x.add(u);let T=[],U=c.byteLength,D=false;for(let l of p.packages){if(!De(t,i)){D=true,T.push({indexEntry:l,failureCode:"LIMIT_EXCEEDED"});continue}let u;try{let b=l.lineage[l.lineage.length-1];if(!b)throw new me("LINEAGE_INVALID","Definition lineage is missing");if(b.definition.id!==l.definition.id||b.version!==l.definition.version||b.hash!==l.definition.hash)throw new me("LINEAGE_STALE","Last lineage generation does not match bundle identity");u=jt(l.lineage,{...b.definition,hash:b.hash}).entries;}catch(b){let se=b instanceof me?b.code:"LINEAGE_INVALID";r.push(s(se,l.packageDir)),T.push({indexEntry:l,failureCode:se});continue}let I=S.find(b=>b.name===l.packageDir.slice(5));if(!y||!I){T.push({indexEntry:l,failureCode:"BUNDLE_INTEGRITY"});continue}if(I.kind!=="directory"){T.push({indexEntry:l,failureCode:I.kind==="symlink"?"PATH_ESCAPED":"BUNDLE_INTEGRITY"});continue}let P;try{let b=await kc(n,e.root,l.packageDir,t,i);if(!De(t,i)){D=!0,T.push({indexEntry:l,failureCode:"LIMIT_EXCEEDED"});continue}let se=l.files.map(he=>he.path);if(b.length!==se.length||b.some((he,_e)=>he!==se[_e])){T.push({indexEntry:l,failureCode:"BUNDLE_INTEGRITY"});continue}P=new Map;let H;for(let he of l.files){if(!De(t,i)){H="LIMIT_EXCEEDED",D=!0;break}if(U>=Yt){H="LIMIT_EXCEEDED";break}let _e;try{_e=await Ro(n,e.root,`${l.packageDir}/${he.path}`,xc(he.path));}catch(vr){H=Ve(vr);break}if(!De(t,i)){H="LIMIT_EXCEEDED",D=!0;break}if(U+_e.byteLength>Yt){U=Yt,H="LIMIT_EXCEEDED";break}if(U+=_e.byteLength,li.createHash("sha256").update(_e).digest("hex")!==he.sha256){H="BUNDLE_INTEGRITY";break}P.set(he.path,_e);}if(H!==void 0){T.push({indexEntry:l,failureCode:H});continue}}catch(b){De(t,i)||(D=true),T.push({indexEntry:l,failureCode:Ve(b)});continue}T.push({indexEntry:l,lineage:u,files:P,...x.has(l)?{failureCode:"DUPLICATE_ID"}:{}});}return a(T,D,d)}var gc,Qt,ei,mc,hc,_c,Yt,qt,Ec,Tc,ni=v(()=>{g();Ft();ke();wn();Bt();Xt();gc=256*1024,Qt=64,ei=128,mc=Qt*ei,hc=2*1024*1024,_c=8*1024*1024,Yt=32*1024*1024,qt=/^[0-9a-f]{64}$/,Ec=new TextDecoder("utf-8",{fatal:true}),Tc=Object.freeze({appIds:Object.freeze([]),definitionIds:Object.freeze([])});});function jc(e){if(typeof e!="string"||!ye.test(e))throw new TypeError("pluginId must be a safe UI plugin identifier");let n=`${ti}${e}`.length+7<=128?e:`hash_${li.createHash("sha256").update(e,"utf8").digest("hex")}`;return {read:`${ti}${n}_read`,action:`${ti}${n}_action`}}function ko(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 Vc(e,n){return n.length===0||n==="."||n===".."||/[\\/\u0000]/.test(n)?e==="skills"?"skills":"apps":`${e==="skills"?"skills":"apps"}/${n}`}function Bc(e){return e.length>0&&e!=="."&&e!==".."&&!/[\\/\u0000]/.test(e)}function hn(e,n){let t=new TextEncoder().encode(e),i=new TextEncoder().encode(n),o=Math.min(t.byteLength,i.byteLength);for(let r=0;r<o;r+=1){let s=t[r]-i[r];if(s!==0)return s}return t.byteLength-i.byteLength}function Wo(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 o=n.isFile;return typeof o=="function"&&o.call(e)?{name:n.name,kind:"file"}:{name:n.name,kind:"other"}}function Hc(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 Jo(e){return Fc.decode(e)}function zc(e){return JSON.parse(Jo(e))}function $c(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 Gn(e,n,t,i,o){let r={code:e,...i===void 0?{}:{pluginId:i},source:n,relativePath:t,...o?.reason===void 0?{}:{reason:Object.freeze({...o.reason})},...o?.files===void 0?{}:{files:Object.freeze([...o.files])}};return Object.freeze(r)}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 N)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 ze(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 vo(e){return {reason:e.reason,...e.code==="MANIFEST_DUAL_MISMATCH"?{files:e.files}:{}}}function jo(e){return e==="MANIFEST_DUAL_MISMATCH"?e:Ko(e)}function Gc(e){return Ko(e.code)}function Ko(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 Xo("UiPluginValidationError",e)}}function Xo(e,n){throw new Error(`Unmapped ${e} code: ${String(n)}`)}function Wc(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 Xo("McpAppContractError",e)}}function be(e,n){let t=n();return Number.isFinite(t)&&Number.isFinite(e)&&t-e<=5e3}function Jc(e){return {pluginId:e.appId,definitionKey:`${e.definition.id}\0${String(e.definition.version)}`}}function Kc(e,n){let t=n.get("package.json");if(t!==void 0)try{let o=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(t));if(ko(o)){let r=o.bin,s=typeof r=="string"?r:ko(r)?Object.values(r).find(a=>typeof a=="string"):void 0;for(let a of [s,o.main]){if(typeof a!="string")continue;let c=Xc(a);if(c&&n.has(c))return c}}}catch{}return [`${e.slice(e.lastIndexOf("/")+1)}.js`,"index.js","main.js"].find(o=>n.has(o))}function Xc(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 Yc(){return globalThis.performance?.now()??Date.now()}function He(e){if(e===null||typeof e!="object"||Object.isFrozen(e))return e;for(let n of Object.values(e))He(n);return Object.freeze(e)}function Fo(e){return Object.freeze(Array.from(e))}async function Wn(e,n,t,i){if(n.pinnedFiles!==void 0){let a=n.pinnedFiles.get(t);if(a===void 0)throw new N("NOT_FOUND");if(a.byteLength>i)throw new N("LIMIT_EXCEEDED");return new Uint8Array(a)}let o=`${n.relativePath}/${t}`,r=n.scanContext,s=e.fingerprintVerifiedFile;if(r===void 0||!r.cacheable||typeof s!="function")return zo(e,n.root,o,i);try{let a=r.priorFingerprints.get(o)??await s.call(e,r.workspaceRoot,o,i);r.candidateRealPath=a.candidateRealPath;let c=await zo(e,n.root,o,i),d=await s.call(e,r.workspaceRoot,o,i);return r.candidateRealPath=d.candidateRealPath,qo(a,d)&&d.size===BigInt(c.byteLength)&&!Zo(d,r.scanStartedAtNs)?r.files.set(o,{relativePath:o,byteLimit:i,fingerprint:d}):r.cacheable=!1,c}catch(a){let c=X.includes(t)&&te(a)==="NOT_FOUND"&&r.directoryListings.some(p=>p.relativePath===n.relativePath&&!Jn(p.key,t)),d=t===V&&te(a)==="NOT_FOUND"&&qc(r.directoryListings,n.relativePath);throw !c&&!d&&(r.cacheable=false),a}}function qc(e,n){let t=e.find(o=>o.relativePath===n);if(t===void 0)return false;if(!Jn(t.key,"dist"))return true;let i=e.find(o=>o.relativePath===`${n}/dist`);return i!==void 0&&!Jn(i.key,"tools.json")}function Yo(e,n){return JSON.stringify([e.realPath,n.source,n.relativePath])}async function Qc(e,n,t,i,o,r,s,a){let c=e.fingerprintVerifiedFile,d=Yo(t,i),p=o.candidates.get(d),A=i.relativePath,m;try{m=await Ho(e,n,A);}catch(D){if(te(D)!=="NOT_FOUND")throw D}let y=m===void 0?void 0:{relativePath:A,key:m};if(y!==void 0&&(i.source==="apps"||i.source==="skills")&&!X.some(D=>Jn(y.key,D)))return be(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===y.relativePath&&p.directoryListings[0]?.key===y.key&&(i.source==="apps"?p.diagnostic?.code==="MANIFEST_MISSING":p.diagnostic===void 0)&&typeof c=="function"?{memo:p}:typeof c!="function"?{}:{context:{state:o,cacheKey:d,workspaceRoot:n,scanStartedAtNs:r,directoryListings:Object.freeze([y]),priorFingerprints:new Map,files:new Map,cacheable:true}}:{timeLimitReached:true};let h=async D=>{if(D==="")return y;let l=`${i.relativePath}${D}`;try{let u=await Ho(e,n,l);return u===void 0?void 0:{relativePath:l,key:u}}catch(u){if(te(u)==="NOT_FOUND")return;throw u}},L=await Promise.all(Vo.map(h)),S=await Promise.all(Zc.map(h));if(!be(s,a))return {timeLimitReached:true};let j=typeof c=="function"&&L.every(D=>D!==void 0),C=L.filter(D=>D!==void 0),x=[...C,...S.filter(D=>D!==void 0)],F=new Map,E=p!==void 0&&j,T;if(p!==void 0&&typeof c=="function"){let D=await Promise.all(p.files.map(async l=>{if(!be(s,a))return {kind:"time",file:l};try{let u=await c.call(e,n,l.relativePath,l.byteLimit);return {kind:"fingerprint",file:l,current:u}}catch(u){return te(u)==="NOT_FOUND"?{kind:"missing",file:l}:{kind:"error",file:l,error:u}}}));if(D.some(l=>l.kind==="time"))return {timeLimitReached:true};for(let l of D){if(l.kind==="error")throw l.error;if(l.kind==="missing"){E=false;continue}if(l.kind!=="fingerprint")continue;let{file:u,current:I}=l;F.set(u.relativePath,I),T??=I.candidateRealPath,(I.candidateRealPath!==p.candidateRealPath||!qo(I,u.fingerprint)||Zo(I,r))&&(E=false);}}let U=p!==void 0&&p.directoryListings.length===x.length&&p.directoryListings.every((D,l)=>D.relativePath===x[l]?.relativePath&&D.key===x[l]?.key);return p!==void 0&&j&&U&&E&&T===p.candidateRealPath?{memo:p}:!j||C.length!==Vo.length?{}:{context:{state:o,cacheKey:d,workspaceRoot:n,scanStartedAtNs:r,directoryListings:Object.freeze(x),priorFingerprints:F,files:new Map,...T===void 0?{}:{candidateRealPath:T},cacheable:true}}}function Jn(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=Qo(e);if(typeof i!="function")return;let o=await i.call(e,n,t);if(!Array.isArray(o)||o.some(s=>typeof s=="string"))return;let r=o.map(Wo);if(!r.some(s=>s===null))return JSON.stringify(r.slice().sort((s,a)=>hn(s.name,a.name)||hn(s.kind,a.kind)).map(s=>[s.name,s.kind]))}function qo(e,n){return e.dev===n.dev&&e.ino===n.ino&&e.size===n.size&&e.mtimeNs===n.mtimeNs&&e.ctimeNs===n.ctimeNs}function Zo(e,n){let t=e.mtimeNs-n;return t>=-Bo&&t<=Bo}function ii(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,o=t||i;if(n===void 0||!n.cacheable||n.candidateRealPath===void 0&&!o||n.files.size===0&&!o)return;let r=Object.freeze({...!o&&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,r);}function ed(e,n,t){let i=li.createHash("sha256"),o=new TextEncoder().encode(oe(e)),r=s=>{let a=new Uint8Array(8);new DataView(a.buffer).setBigUint64(0,BigInt(s)),i.update(a);};return r(o.byteLength),i.update(o),r(n.byteLength),i.update(n),r(t.byteLength),i.update(t),i.digest("hex")}function nd(e,n){let t={...e.definition,sourceHash:n},i;try{i=pe(t);}catch(r){throw r instanceof O&&r.code==="INPUT_INVALID"?new ne("MANIFEST_INVALID","normalized definition is invalid"):r}let o={...t,hash:i};try{Pe(o);}catch{throw new ne("MANIFEST_INVALID","normalized definition is invalid")}return o}function td(e){return e.actions.some(n=>n.backend.type==="core"&&n.backend.handler!=="state.set")}function id(e){if(typeof e.readVerifiedFile=="function")return e.readVerifiedFile;if(typeof e.readFileVerified=="function")return e.readFileVerified}function Qo(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 o=id(e);if(!o)throw new N("READ_DENIED");return Hc(await o.call(e,n,t,i))}async function od(e,n,t){let i=Qo(e);if(!i)throw new N("READ_DENIED");let o=await i.call(e,n,t);if(!Array.isArray(o))throw new N("READ_DENIED");return o.map(Wo).filter(r=>r!==null)}function rd(e){let n=[];for(let t of [e.reserved,e.builtin])t&&n.push(t);return e.builtins&&"listMcpApps"in e.builtins?n.push($o(e.builtins)):e.builtins&&n.push(e.builtins),e.builtinCatalog&&n.push($o(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 $o(e){let n=[],t=[],i=[];for(let o of e.listMcpApps())typeof o.appId=="string"&&n.push(o.appId),o.definition&&typeof o.definition.id=="string"&&t.push(o.definition.id);for(let o of e.listMcpAppTools())typeof o.name=="string"&&i.push(o.name);return {appIds:n,definitionIds:t,toolNames:i}}function Se(e,n){e.diagnostic||(e.diagnostic=Gn(n,e.source,e.relativePath,e.identity?.pluginId));}function sd(e){let n=new Map;for(let i of e){let o=i.identity?.pluginId;if(o===void 0)continue;let r=n.get(o)??[];r.push(i),n.set(o,r);}for(let i of n.values()){if(i.length<2)continue;let o=i.filter(s=>s.provenance!==void 0);if(o.length>0){for(let s of i)s.provenance===void 0&&Se(s,"RESERVED_ID");if(o.length>1)for(let s of o)Se(s,"DUPLICATE_ID");continue}let r=i.filter(s=>s.source==="apps");if(r.length>1){for(let s of r)Se(s,"DUPLICATE_ID");for(let s of i.filter(a=>a.source==="skills"))Se(s,"DUPLICATE_ID");}else for(let s of i.filter(a=>a.source==="skills"))Se(s,"DUPLICATE_ID");}let t=new Map;for(let i of e){if(i.diagnostic?.code==="RESERVED_ID")continue;let o=i.identity?.definitionKey;if(o===void 0)continue;let r=t.get(o)??[];r.push(i),t.set(o,r);}for(let i of t.values())if(i.length>1)for(let o of i)Se(o,"DUPLICATE_ID");}function ad(e,n,t){let i=new Set,o=new Set,r=new Set,s=new Set(t.appIds),a=new Set(t.definitionIds);for(let c of rd(n)){for(let d of c.appIds??[])typeof d=="string"&&i.add(d);for(let d of c.definitionIds??[])typeof d=="string"&&o.add(d);for(let d of c.toolNames??[])typeof d=="string"&&r.add(d);}for(let c of e){let d=c.candidate;if(!d)continue;if(i.has(d.pluginId)||o.has(d.definitionId)){Se(c,"RESERVED_ID");continue}if(c.provenance===void 0&&(s.has(d.pluginId)||a.has(d.definitionId))){Se(c,"RESERVED_ID");continue}[d.toolNames.read,d.toolNames.action].filter(A=>A!==void 0).some(A=>r.has(A))&&Se(c,"DUPLICATE_ID");}}function cd(e){return [...e].sort((n,t)=>{let i=Co.indexOf(n.source)-Co.indexOf(t.source);return i!==0?i:hn(n.relativePath,t.relativePath)})}function k(e,n,t){e.diagnostic=Gn(n,e.source,e.relativePath,e.identity?.pluginId,t);}async function Go(e,n,t){let i=Fe(t,{mode:"local"});if(!i.ok&&i.parseFailure){k(n,jo(i.rejection.code),vo(i.rejection));return}let o=$c(i.identity);if(n.bundleIdentity===void 0)n.identity=o;else if(o?.pluginId!==n.bundleIdentity.appId||o.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,jo(i.rejection.code),vo(i.rejection));return}let r=i.manifest,s={pluginId:r.pluginId,definitionKey:`${r.definitionId}\0${String(r.version)}`};if(n.bundleIdentity===void 0&&(n.identity=s),r.actions.length>0)try{_o(r.actions.map(b=>({actionId:b.actionId,inputSchema:b.inputSchema})));}catch(b){if(b instanceof Ce){k(n,Wc(b.code));return}throw b}let a;try{a=await Wn(e,n,"ui/index.html",yn);}catch(b){k(n,ze(te(b),"entry"));return}if(a.byteLength>yn){k(n,"LIMIT_EXCEEDED");return}let c;try{c=Jo(a);}catch{k(n,"ENTRY_INVALID");return}if(a.byteLength===0||c.length===0){k(n,"ENTRY_INVALID");return}let d=li.createHash("sha256").update(a).digest("hex");if(r.entryHash!==void 0&&r.entryHash!==d){k(n,"ENTRY_INVALID");return}let p={},A,m;if(r.initialState!==void 0){try{A=await Wn(e,n,"ui/state.json",65536);}catch(b){k(n,ze(te(b),"initial"));return}if(A.byteLength>65536){k(n,"LIMIT_EXCEEDED");return}try{let b=zc(A),se=r.dataPaths??[],H=St(b,se);p=Ee(H,0,se),We(p);}catch{k(n,"INITIAL_STATE_INVALID");return}if(m=li.createHash("sha256").update(A).digest("hex"),r.initialState.hash!==void 0&&r.initialState.hash!==m){k(n,"INITIAL_STATE_INVALID");return}}let y={...r,entryHash:d,...r.initialState===void 0?{}:{initialState:{path:"ui/state.json",hash:m}}},h=cn(y),L=ed(y,a,A??new Uint8Array),S;try{S=nd(h,L);}catch(b){if(b instanceof ne){k(n,Gc(b));return}throw b}let j;if(n.bundleLineage!==void 0){let b=n.bundleLineage[n.bundleLineage.length-1];if(!b){k(n,"LINEAGE_INVALID");return}let{legacy:se,...H}=b.definition,{hash:he,..._e}=S;if(oe(H)!==oe(_e)){k(n,"LINEAGE_STALE");return}if(se!==void 0&&(S={...S,legacy:se}),se!==void 0)try{S={...S,hash:pe(S)},Pe(S);}catch{k(n,"LINEAGE_INVALID");return}j=n.bundleLineage;}if(n.bundleIdentity!==void 0&&n.bundleIdentity.appId!==r.pluginId){k(n,"BUNDLE_INTEGRITY");return}if(n.bundleIdentity!==void 0&&(n.bundleIdentity.definitionId!==S.id||n.bundleIdentity.version!==S.version||n.bundleIdentity.definitionHash!==S.hash)){k(n,"LINEAGE_STALE");return}let C=jc(r.pluginId),x=r.actions.length===0?{read:C.read}:C,F=He(h),E=He(y),T=He(S),U=He({...h.handlers}),D=Fo(a),l=A===void 0?void 0:Fo(A),u=Object.freeze({...n.provenance===void 0?{}:{provenance:n.provenance},entry:Object.freeze({path:"ui/index.html",hash:d,bytes:D}),...l===void 0?{}:{initialState:Object.freeze({path:"ui/state.json",hash:m,bytes:l})}}),I={appId:r.pluginId,pluginId:r.pluginId,definitionId:r.definitionId,version:r.version,...i.releaseVersion===void 0?{}:{releaseVersion:i.releaseVersion},manifestFile:i.file,...i.mcpb===void 0?{}:{mcpb:He(i.mcpb)},relativePath:n.relativePath,manifest:E,normalized:F,name:r.name,description:r.description,...r.icon===void 0?{}:{icon:r.icon},...r.tone===void 0?{}:{tone:r.tone},definition:T,handlers:U,resources:u,html:c,entryBytes:D,entryHash:d,initialState:He(p),...l===void 0?{}:{initialStateBytes:l},...m===void 0?{}:{initialStateHash:m},sourceHash:L,toolNames:Object.freeze(x)},P=n.provenance===void 0?{...I,source:n.source}:{...I,provenance:n.provenance,lineage:j??[]};n.candidate=Object.freeze(P),td(r)&&k(n,"EXEC_DENIED");}async function er(e,n){let t={};for(let i of X)try{t[i]=await Wn(e,n,i,262144);}catch(o){if(te(o)==="NOT_FOUND")continue;return {files:t,failure:ze(te(o),"manifest")}}if(t[G]!==void 0)try{t[V]=await Wn(e,n,V,262144);}catch(i){if(te(i)!=="NOT_FOUND")return {files:t,failure:ze(te(i),"manifest")}}return {files:t}}function oi(e){return X.some(n=>e[n]!==void 0)}async function dd(e,n){let{files:t,failure:i}=await er(e,n);if(i!==void 0){k(n,i);return}let o=t[G];return o!==void 0&&!Ct(o)&&(delete t[G],delete t[V]),oi(t)?t:void 0}function pd(e,n,t,i=vc,o=false){let r=cd(e);sd(r);let s=Object.freeze(r.filter(p=>p.candidate!==void 0&&p.diagnostic===void 0).map(p=>p.candidate)),a=Object.freeze(r.filter(p=>p.diagnostic!==void 0).map(p=>p.diagnostic)),c=o?Object.freeze({...t===void 0?{}:{indexHash:t},candidates:Object.freeze(r.filter(p=>p.source==="bundled"&&p.diagnostic===void 0&&t!==void 0&&p.candidate?.provenance?.indexHash===t).map(p=>p.candidate)),diagnostics:Object.freeze(a.filter(p=>p.source==="bundled").map(p=>Object.freeze({...p}))),reservedAppIds:Object.freeze([...i.appIds]),reservedDefinitionIds:Object.freeze([...i.definitionIds])}):void 0,d={apps:s,diagnostics:a,complete:n===void 0,...n===void 0?{}:{incompleteReason:n},...t===void 0?{}:{productBundleIndexHash:t},...c===void 0?{}:{productBundleSnapshotMetadata:c}};return Object.defineProperty(d,"candidates",{configurable:false,enumerable:false,get:()=>s}),Object.freeze(d)}function ld(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 ud(e,n){if(ld(e))return {fs:e,options:{}};let t=e??n??{};return {fs:t.filesystem??t.fileSystem??t.fs??So,options:t}}async function nr(e,n,t){if(typeof e!="string"||e.length===0)throw new TypeError("workspaceRoot must be explicit");let{fs:i,options:o}=ud(n,t),r=o.clock??Yc,s=r(),a=await Uo(o.productBundle,i,s,r),c=r(),d=BigInt(Date.now())*1000000n,p=[],A=0,m,y=false,h,L;if(o.scanCache!==void 0&&typeof i.getRootIdentity=="function"&&typeof i.fingerprintVerifiedFile=="function")try{L=await i.getRootIdentity(e),h=To(o.scanCache,L),h.scanStartedAtNs=d;}catch(E){if(te(E)!=="NOT_FOUND")throw E}let S=h!==void 0&&o.productBundle===void 0&&a.packages.length===0&&a.diagnostics.length===0,j=new Set,C=true;p.push(...a.diagnostics.map(E=>({source:E.source,root:o.productBundle?.root??e,name:"",relativePath:E.relativePath,diagnostic:E})));let x=a.reservedIds;a.incomplete&&(m="time_limit");for(let E of a.packages){if(!be(c,r)){y=true,m="time_limit";break}let T=E.indexEntry,U=T.packageDir,D=E.files===void 0?void 0:Kc(U,E.files),l=a.indexHash===void 0?void 0:lo(Object.freeze({kind:"bundled",launcher:T.launcher!==false,indexHash:a.indexHash,packageDir:U,appId:T.appId,definitionId:T.definition.id,version:T.definition.version,definitionHash:T.definition.hash,files:T.files}),D),u={source:"bundled",root:o.productBundle?.root??e,name:U.slice(5),relativePath:U,...l===void 0?{}:{provenance:l},...E.files===void 0?{}:{pinnedFiles:E.files},...E.lineage===void 0?{}:{bundleLineage:E.lineage},bundleIdentity:{appId:T.appId,definitionId:T.definition.id,version:T.definition.version,definitionHash:T.definition.hash},identity:Jc(T)};if(p.push(u),A+=1,E.failureCode!==void 0){k(u,E.failureCode);continue}if(E.files?.has(V)===true){k(u,"EXEC_DENIED",{reason:{path:"",rule:"bundled-tool-mode-unsupported",file:V}});continue}let I={};for(let P of X){let b=E.files?.get(P);b!==void 0&&(I[P]=b);}if(!oi(I)){k(u,"BUNDLE_INTEGRITY");continue}if(await Go(i,u,I),!be(c,r)){y=true,m="time_limit";break}}let F=[{source:"apps",directory:"apps"},{source:"skills",directory:"skills"}];e:for(let E of F){let{source:T,directory:U}=E,D;try{D=await od(i,e,U);}catch(u){if(te(u)==="NOT_FOUND")continue;S=false,C=false,p.push({source:T,root:e,name:"",relativePath:T,diagnostic:Gn(ze(te(u),"manifest"),T,T)});continue}let l=D.filter(u=>u.kind==="directory"||u.kind==="symlink").filter(u=>Bc(u.name)).map(u=>({source:T,root:e,name:u.name,relativePath:Vc(T,u.name)})).sort((u,I)=>hn(u.relativePath,I.relativePath));for(let u of l){let I={...u};if(p.push(I),L!==void 0?j.add(Yo(L,I)):S=false,!be(c,r)){y=true,m="time_limit";break e}let P;if(h!==void 0&&L!==void 0){try{let H=await Qc(i,e,L,I,h,d,c,r);if(H.timeLimitReached){y=!0,m="time_limit";break e}I.scanContext=H.context,P=H.memo;}catch(H){S=false,k(I,ze(te(H),"manifest"));continue}P===void 0&&(S=false);}if(P!==void 0){if(I.candidate=P.candidate,I.diagnostic=P.diagnostic,I.identity=P.identity,T==="skills"&&P.candidate===void 0&&P.diagnostic===void 0)continue;if(A>=64){k(I,"LIMIT_EXCEEDED");continue}if(u.relativePath.split("/").length-1>2){k(I,"LIMIT_EXCEEDED");continue}if(A+=1,!be(c,r)){y=true,m="time_limit";break e}continue}let b;if(T==="skills"&&(b=await dd(i,I),b===void 0)){I.diagnostic===void 0&&ii(I);continue}if(A>=64){k(I,"LIMIT_EXCEEDED");continue}if(u.relativePath.split("/").length-1>2){k(I,"LIMIT_EXCEEDED");continue}if(!be(c,r)){y=true,m="time_limit";break e}if(A+=1,b===void 0){let H=await er(i,I);if(H.failure!==void 0||!oi(H.files)){k(I,H.failure??ze("NOT_FOUND","manifest")),ii(I);continue}b=H.files;}if(await Go(i,I,b),ii(I),!be(c,r)){y=true,m="time_limit";break e}}}if(h!==void 0&&L!==void 0){let E=[...j].sort(hn),T=h.lastCandidateKeys,U=T!==void 0&&T.length===E.length&&T.every((l,u)=>l===E[u]);if(S=S&&U,C&&!y&&m===void 0)for(let l of h.candidates.keys())try{JSON.parse(l)[0]===L.realPath&&!j.has(l)&&h.candidates.delete(l);}catch{h.candidates.delete(l);}let D=[...h.candidates.keys()].filter(l=>{try{return JSON.parse(l)[0]===L.realPath}catch{return false}});S=S&&D.length===j.size&&D.every(l=>j.has(l))&&!y&&m===void 0,h.lastCandidateScanUnchanged=S,C&&!y&&m===void 0&&(h.lastCandidateKeys=Object.freeze(E));}return y&&p.push({source:"apps",root:e,name:"",relativePath:"apps",diagnostic:Gn("DISCOVERY_TIME_LIMIT","apps","apps")}),ad(p,o,x),pd(p,m,a.indexHash,x,o.productBundle!==void 0)}var vc,ti,Co,Fc,Vo,Zc,Bo,tr=v(()=>{g();xe();Tn();Te();kt();ke();Bt();kn();Po();Xt();xn();ni();ni();vc=zn([]),ti="crewx_local_app_";Co=["bundled","apps","skills"],Fc=new TextDecoder("utf-8",{fatal:true});Vo=["","/ui"],Zc=["/dist"],Bo=2000000000n;});g();kt();g();gt();g();var Zi="SKILL.md",za=/^---\s*\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/;function Qi(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}function $a(e){return e.isDirectory()||e.isSymbolicLink()}function oo(e){try{return q.existsSync(e)&&q.statSync(e).isDirectory()}catch{return false}}function xt(e){let n;try{n=q.readFileSync(e,"utf8");}catch{return {frontmatter:{},readable:false,valid:false,hasFrontmatter:false}}let t=n.match(za);if(!t)return {frontmatter:{},readable:true,valid:true,hasFrontmatter:false};try{let i=Ar.load(t[1]??"");if(!Qi(i))return {frontmatter:{},readable:!0,valid:!1,hasFrontmatter:!0};let o=Qi(i.metadata)?i.metadata:void 0;return {frontmatter:{...typeof i.name=="string"?{name:i.name}:{},...typeof(o?.version??i.version)=="string"?{version:o?.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 Ga(e){return [ie.join(e,Zi),ie.join(e,"skill",Zi)]}function eo(e,n){if(!oo(e))return null;for(let t of Ga(e)){if(!q.existsSync(t))continue;let o=xt(t).frontmatter;return {name:o.name??n,...o.version===void 0?{}:{version:o.version},...o.description===void 0?{}:{description:o.description},skillMdPath:t,dir:e}}return null}function no(e){try{return q.readdirSync(e,{withFileTypes:!0}).filter($a)}catch{return []}}function to(e,n,t){!e||n.has(e.name)||(n.add(e.name),t.push(e));}function ro(e){let n=[],t=new Set;for(let i of e)if(oo(i))for(let o of no(i)){if(o.name.startsWith("@")){let r=ie.join(i,o.name);for(let s of no(r))to(eo(ie.join(r,s.name),s.name),t,n);continue}to(eo(ie.join(i,o.name),o.name),t,n);}return n.sort((i,o)=>i.name.localeCompare(o.name))}g();wn();var Wa=/^[A-Za-z0-9_$.[\]"-]{0,200}$/,Ja=/^[a-z][a-z0-9-]{0,63}$/,Ka="<unknown>";function Xa(e){return typeof e=="string"&&(X.includes(e)||e===V)}function so(e){if(typeof e!="object"||e===null)return;let{file:n,path:t,rule:i}=e;if(!(typeof i!="string"||!Ja.test(i)))return {...Xa(n)?{file:n}:{},path:typeof t=="string"&&Wa.test(t)?t:Ka,rule:i}}function ao(e){if(!Array.isArray(e))return;let n=X.filter(t=>e.includes(t));return n.length>0?n:void 0}tr();var yd=/^[A-Za-z][A-Za-z0-9._-]{0,127}$/;function Xn(e){let n="screenHash"in e?e.screenHash:void 0,i=("skillHash"in e?e.skillHash:void 0)??(e.relativePath!==void 0&&e.fileBytes!==void 0?Ad(e.relativePath,e.fileBytes):void 0);if(n!==void 0&&i!==void 0){let o=JSON.stringify({screenHash:n,skillHash:i});return li.createHash("sha256").update(o,"utf8").digest("hex")}if(n!==void 0)return n;if(i!==void 0)return i;throw new TypeError("App definition hash input must contain a screenHash or skill bytes")}function Ad(e,n){let t=new TextEncoder().encode(Yn(e)),i=Id(n),o=new Uint8Array(t.byteLength+1+i.byteLength);return o.set(t,0),o[t.byteLength]=0,o.set(i,t.byteLength+1),li.createHash("sha256").update(o).digest("hex")}function Id(e){if(typeof e=="string")return new TextEncoder().encode(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("fileBytes must be UTF-8 text or bytes")}function Yn(e){if(typeof e!="string"||e.length===0||ie.isAbsolute(e)||/[\\\u0000]/.test(e))throw new TypeError("relative path must be package-relative");let n=e.split("/").filter(t=>t.length>0&&t!==".").join("/");if(!n||n.split("/").some(t=>t===".."))throw new TypeError("relative path must stay inside the package");return n}function Kn(e,n){let t=new TextEncoder().encode(e),i=new TextEncoder().encode(n),o=Math.min(t.byteLength,i.byteLength);for(let r=0;r<o;r+=1){let s=t[r]-i[r];if(s!==0)return s}return t.byteLength-i.byteLength}function rr(e,n){let t=ie.relative(e,n).split(ie.sep).join("/");return !t||t===".."||t.startsWith("../")||ie.isAbsolute(t)?null:Yn(t)}function gd(e){return e==="apps"||e.startsWith("apps/")?"apps":e==="skills"||e.startsWith("skills/")?"skills":e==="node_modules"||e.startsWith("node_modules/")?"node_modules":null}function sr(e){return Object.freeze({packageRoot:e})}function md(e){return Object.freeze({id:e.definition.id,version:e.definition.version,hash:e.definition.hash,usage:e.definition.usage??Re,...e.definition.detailPanel===void 0?{}:{detailPanel:e.definition.detailPanel},...e.definition.displayModes===void 0?{}:{displayModes:e.definition.displayModes},...e.definition.summaryProjection===void 0?{}:{summaryProjection:e.definition.summaryProjection}})}function ar(e){return {capabilities:Object.freeze([...e]),origin:"local",ownership:"unknown",shareability:"unknown",sharingAvailability:"unavailable"}}function hd(e,n){let t=e.candidate,i=t.provenance!==void 0,o=n&&!i?["screen","skill"]:["screen"],r=md(t),s=Xn(n?{screenHash:r.hash,skillHash:n.skillHash}:{screenHash:r.hash}),a=t.description||n?.skill.description||"",c=t.releaseVersion??String(t.version),d={appId:t.pluginId,name:t.name,description:a,version:c,...ar(o),definition:r,...n===void 0||i?{}:{skillName:n.skill.name},...i?{provenance:t.provenance}:{localDefinitionRef:sr(e.packageRoot)},definitionHash:s,...t.manifest.csp===void 0?{}:{connectDomains:Object.freeze([...t.manifest.csp.connectDomains])}};return {...i?{}:{packageRoot:e.packageRoot},source:i?"bundled":t.source,appId:d.appId,capabilities:o,summary:Object.freeze(d)}}function _d(e){let n=Ed(e.skill.name),t={appId:n,name:e.skill.name,description:e.skill.description??"",...e.skill.version===void 0?{}:{version:e.skill.version},...ar(["skill"]),skillName:e.skill.name,localDefinitionRef:sr(e.packageRoot),definitionHash:Xn({skillHash:e.skillHash})};return {packageRoot:e.packageRoot,source:e.source,appId:n,capabilities:["skill"],summary:Object.freeze(t)}}function Ed(e){return `skill.${e.replace(/^@/,"").replace(/\//g,".").replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,122)||"unnamed"}`}function Y(e,n,t,i,o){let r=so(o?.reason),s=ao(o?.files);return Object.freeze({code:e,source:n,relativePath:Td(t),...i===void 0?{}:{appId:i},...r===void 0?{}:{reason:r},...s===void 0?{}:{files:s}})}function Td(e){if(typeof e!="string"||e.length===0||ie.isAbsolute(e)||/[\\\u0000]/.test(e))return "<unknown>";let n=e.split("/").filter(t=>t.length>0&&t!==".").join("/");return n.split("/").some(t=>t==="..")?"<unknown>":n}function cr(e){return Y(e.code,e.source,e.relativePath,e.pluginId,e)}function Pd(e,n){let t=rr(e,n.dir);if(!t)return {diagnostic:Y("PATH_ESCAPED","node_modules","node_modules")};let i=gd(t);if(!i)return {diagnostic:Y("PATH_ESCAPED","node_modules",t)};let o=xt(n.skillMdPath);if(!o.readable)return {diagnostic:Y("SKILL_READ_FAILED",i,t)};if(!o.valid)return {diagnostic:Y("SKILL_INVALID",i,t)};let r=Nd(n.dir,n.skillMdPath);if(!r)return {diagnostic:Y("PATH_ESCAPED",i,t)};try{let s=new Uint8Array(q.readFileSync(n.skillMdPath));return {skill:n,packageRoot:t,relativeSkillPath:r,skillHash:Xn({relativePath:r,fileBytes:s}),source:i}}catch{return {diagnostic:Y("SKILL_READ_FAILED",i,t)}}}function Nd(e,n){let t=ie.relative(e,n).split(ie.sep).join("/");try{return Yn(t)}catch{return null}}function Dd(e){if(!yd.test(e.appId))return {diagnostic:Y("BUILTIN_INVALID","builtin",`builtin/${e.appId||"unknown"}`)};let n=e.definition===void 0?void 0:{id:e.definition.id,version:e.definition.version,hash:e.definition.hash,usage:e.definition.usage??Re,...e.definition.detailPanel===void 0?{}:{detailPanel:e.definition.detailPanel},...e.definition.displayModes===void 0?{}:{displayModes:e.definition.displayModes},...e.definition.summaryProjection===void 0?{}:{summaryProjection:e.definition.summaryProjection}},t=n?.hash??li.createHash("sha256").update(JSON.stringify({appId:e.appId,name:e.name,description:e.description}),"utf8").digest("hex"),i={appId:e.appId,name:e.name,description:e.description,...n===void 0?{}:{version:String(n.version),definition:n},capabilities:["screen"],origin:"builtin",ownership:"unknown",shareability:"forbidden",sharingAvailability:"unavailable",definitionHash:t};return {source:"builtin",appId:e.appId,summary:Object.freeze(i)}}function bd(e){return e.builtinCatalog}function Sd(e){let n=e.packageRoot??e.relativePath??e.packageRootPath;if(n===void 0)return null;try{return Yn(n)}catch{return null}}function Md(e){let n=e.marketplaceContentId;return typeof n=="string"&&n.length>0?n:void 0}function Ld(e,n,t){let i=n.installed??[],o=new Map;for(let s of i){let a=Sd(s);if(!a){t.push(Y("INSTALLED_IDENTITY_MISMATCH","installed","installed"));continue}let c=o.get(a);if(c&&JSON.stringify(c)!==JSON.stringify(s)){t.push(Y("INSTALLED_IDENTITY_MISMATCH","installed",a));continue}o.set(a,s);}let r=new Map;for(let s of e)s.packageRoot!==void 0&&r.set(s.packageRoot,s);for(let[s,a]of o){let c=r.get(s);if(!c){t.push(Y("INSTALLED_MISSING","installed",s,a.appId));continue}let d=Md(a);if(!d){t.push(Y("INSTALLED_CONTENT_ID_MISSING","installed",s,a.appId));continue}if(a.appId!==void 0&&a.appId!==c.appId||a.definitionHash!==void 0&&a.definitionHash!==c.summary.definitionHash){t.push(Y("INSTALLED_IDENTITY_MISMATCH","installed",s,a.appId));continue}let p={...c.summary,origin:"installed",...a.slug===void 0?{}:{slug:a.slug},marketplaceContentId:d},A=e.indexOf(c);A>=0&&(e[A]={...c,summary:Object.freeze(p)});}}function Od(e,n){let t=new Map;for(let o of e){let r=t.get(o.appId)??[];r.push(o),t.set(o.appId,r);}let i=new Set;for(let o of t.values()){if(o.length<2)continue;let r=o.some(s=>s.source==="builtin")?"builtin":o.some(s=>s.source==="bundled")?"bundled":void 0;if(r!==void 0){let s=o.filter(a=>a.source===r);for(let a of o.filter(c=>c.source!==r))i.add(a),n.push(Y("RESERVED_ID",a.source,si(a),a.appId));if(s.length>1)for(let a of s)i.add(a),n.push(Y("DUPLICATE_ID",a.source,si(a),a.appId));continue}for(let s of o)i.add(s),n.push(Y("DUPLICATE_ID",s.source,si(s),s.appId));}return e.filter(o=>!i.has(o))}function si(e){return e.packageRoot??e.summary.provenance?.packageDir??`builtin/${e.appId}`}function Rd(e,n){return e.filter(t=>!(t.code==="MANIFEST_MISSING"&&n.has(t.relativePath))).map(cr)}function wd(e){return e.filesystem}function Ud(e,n){let t=wd(e),i=e.registeredProductBundle;return {...t===void 0?{}:{filesystem:t},...e.productBundle===void 0?{}:{productBundle:e.productBundle},...n===void 0?{}:{builtinCatalog:n},...i===void 0?{}:{reservedAppIds:i.reservedAppIds,reservedDefinitionIds:i.reservedDefinitionIds}}}async function dr(e,n={}){if(typeof e!="string"||e.length===0)throw new TypeError("workspaceRoot must be explicit");if(n.productBundle!==void 0&&n.registeredProductBundle!==void 0)throw new TypeError("registeredProductBundle cannot be combined with product bundle discovery");let t=bd(n),i=await nr(e,Ud(n,t)),o=n.registeredProductBundle??i.productBundleSnapshotMetadata,r=[ie.join(e,"skills"),ie.join(e,"node_modules"),ie.join(e,"apps")],s=[],a=[],c=[],d=new Set;for(let u of r)for(let I of ro([u])){let P=rr(e,I.dir);(P===null||!d.has(P))&&(c.push(I),P!==null&&d.add(P));}for(let u of c){let I=Pd(e,u);"diagnostic"in I?s.push(I.diagnostic):a.push(I);}let p=new Map,A=n.registeredProductBundle?.indexHash,m=(n.registeredProductBundle?.candidates??[]).filter(u=>A!==void 0&&u.provenance?.indexHash===A),y=[...i.apps??i.candidates??[],...m],h=new Set(m),L=new Set(A===void 0?[]:(t?.listMcpApps()??[]).filter(u=>u.provenance?.indexHash===A).map(u=>u.appId));for(let u of y){if(h.has(u)&&u.provenance?.indexHash===A&&L.has(u.appId))continue;let I=u.provenance===void 0?`workspace\0${u.relativePath}`:`bundled\0${u.provenance.indexHash}\0${u.provenance.packageDir}`;p.set(I,{candidate:u,packageRoot:u.relativePath});}let S=new Map(a.map(u=>[u.packageRoot,u])),j=[];for(let u of p.values()){let I=u.candidate.provenance===void 0?S.get(u.packageRoot):void 0,P=hd(u,I);j.push({...P.packageRoot===void 0?{}:{packageRoot:P.packageRoot},source:P.source,appId:P.appId,summary:P.summary});}let C=new Set([...p.values()].filter(u=>u.candidate.provenance===void 0).map(u=>u.packageRoot)),x=o===void 0?new Set:new Set(i.diagnostics.filter(u=>u.code==="RESERVED_ID"&&u.source!=="bundled").map(u=>u.relativePath)),F=new Set(o?.reservedAppIds??[]);for(let u of a){let I=_d(u);if(!(C.has(u.packageRoot)||x.has(u.packageRoot))){if(F.has(I.appId)){s.push(Y("RESERVED_ID",u.source,u.packageRoot,I.appId));continue}j.push({packageRoot:I.packageRoot,source:I.source,appId:I.appId,summary:I.summary});}}let E=[...Rd(i.diagnostics,new Set(a.map(u=>u.packageRoot))),...s,...n.registeredProductBundle?.diagnostics.filter(u=>u.source==="bundled").map(cr)??[]],T=[];if(t)for(let u of t.listMcpApps()){let I=Dd(u);"diagnostic"in I?E.push(I.diagnostic):T.push(I);}let U=Od([...j,...T],E);Ld(U,n,E);let D=U.map(u=>u.summary).sort((u,I)=>Kn(u.appId,I.appId)),l=[...E].sort((u,I)=>Kn(u.relativePath,I.relativePath)||Kn(u.code,I.code)||Kn(u.appId??"",I.appId??""));return Object.freeze({items:Object.freeze(D),diagnostics:Object.freeze(l)})}g();g();g();function Cd(e){let n=o=>o.replace(/[.+^${}()|[\]\\]/g,"\\$&"),i=e.split("/").map(o=>o==="**"?".*":o.split("*").map(n).join("[^/]*"));return new RegExp(`^${i.join("\\/")}$`)}function tn(e,n){try{return Cd(n).test(e)}catch{return false}}function qn(e,...n){let t=e.split("/");if(t.length<n.length)return false;let i=t.length-n.length;return n.every((o,r)=>tn(t[i+r],o))}function kd(e,n){return e.split("/").some(t=>tn(t,n))}var pr=[{label:".env*",test:e=>tn(e,".env*")},{label:".git/",test:(e,n,t)=>t&&e===".git"},{label:"memory/",test:(e,n,t)=>t&&e==="memory"},{label:"*.key",test:e=>tn(e,"*.key")},{label:"*.pem",test:e=>tn(e,"*.pem")},{label:"auth.json",test:e=>e==="auth.json"},{label:"node_modules/",test:(e,n,t)=>t&&e==="node_modules"},{label:"conversations/",test:(e,n,t)=>t&&e==="conversations"},{label:".crewx/threads/",test:(e,n,t)=>t&&qn(n,".crewx","threads")},{label:".crewx/crewx.db",test:(e,n,t)=>!t&&qn(n,".crewx","crewx.db")},{label:".crewx/*.log",test:(e,n,t)=>!t&&qn(n,".crewx","*.log")},{label:".crewx/publish/",test:(e,n,t)=>t&&qn(n,".crewx","publish")},{label:".crewx/",test:(e,n)=>kd(n,".crewx")}];function Zn(e,n,t){for(let i of pr)if(i.test(e,n,t))return i.label;return null}function di(e){let n=[],t=[];function i(o,r,s){let a;try{a=q__namespace.readdirSync(o,{withFileTypes:!0});}catch{return}a.sort((c,d)=>c.name.localeCompare(d.name));for(let c of a){let d=r?`${r}/${c.name}`:c.name,p=ie__namespace.join(o,c.name);if(c.isSymbolicLink()){let A;try{A=q__namespace.statSync(p);}catch{t.push({path:d,rule:"symlink"});continue}if(A.isDirectory()){t.push({path:d,rule:s??"symlink-dir"});continue}let m=s??Zn(c.name,d,false);m?t.push({path:d,rule:m}):t.push({path:d,rule:"symlink"});continue}if(c.isDirectory()){let A=s??Zn(c.name,d,true);i(p,d,A);continue}if(c.isFile()){let A=s??Zn(c.name,d,false);A?t.push({path:d,rule:A}):n.push(d);}}}return i(e,"",null),n.sort(),t.sort((o,r)=>o.path<r.path?-1:o.path>r.path?1:0),{included:n,excluded:t}}g();var xd=[{rule:"token-prefix",regex:/\b(?:sk-|ghp_|xoxb-)[A-Za-z0-9_-]{10,}/},{rule:"private-key",regex:/-----BEGIN [A-Z ]*PRIVATE KEY-----/},{rule:"aws-access-key",regex:/\bAKIA[0-9A-Z]{16}\b/}];function vd(e){return e.includes(0)}function pi(e,n,t){let i=[];for(let o of n){let r=ie__namespace.join(e,o),s;try{let c=t?.get(o);s=c===void 0?q__namespace.readFileSync(r):Buffer.from(c);}catch{continue}if(vd(s))continue;s.toString("utf8").split(/\r\n|\r|\n/).forEach((c,d)=>{for(let{rule:p,regex:A}of xd)A.test(c)&&i.push({path:o,line:d+1,rule:p});});}return i}g();g();var Me=class extends Error{constructor(t,i){super(`publish: [${t}]${i?` ${i}`:""}`);this.code=t;}code;name="PublishError"};function _(e,n){return new Me(e,n)}var yr=/^[a-z0-9-]+$/,jd=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/,Fd=/^[A-Za-z_][A-Za-z0-9_]*$/;function Vd(e){let n=ie__namespace.join(e,"crewx.yaml");if(!q__namespace.existsSync(n))return {};let t;try{t=Ar__namespace.load(q__namespace.readFileSync(n,"utf8"));}catch{return {}}if(!t||typeof t!="object")return {};let i=t.metadata;if(!i||typeof i!="object")return {};let o=i;return {name:typeof o.name=="string"?o.name:void 0,version:typeof o.version=="string"?o.version:void 0,description:typeof o.description=="string"?o.description:void 0,requiredEnv:o.requiredEnv,crewxMinVersion:typeof o.crewxMinVersion=="string"?o.crewxMinVersion:void 0}}function Bd(e){return li__namespace.createHash("sha256").update(e).digest("hex")}function Ir(e){let n;try{n=q__namespace.lstatSync(e);}catch{throw _("PACKAGE_FILE_INVALID",`file is not readable: ${ie__namespace.basename(e)}`)}if(n.isSymbolicLink())throw _("PACKAGE_SYMLINK","symlink content is not publishable");if(!n.isFile())throw _("PACKAGE_FILE_INVALID","only regular files are publishable");return li__namespace.createHash("sha256").update(new Uint8Array(q__namespace.readFileSync(e))).digest("hex")}function Hd(e,n){let t=new TextEncoder().encode(e),i=new TextEncoder().encode(n),o=Math.min(t.byteLength,i.byteLength);for(let r=0;r<o;r+=1){let s=t[r]-i[r];if(s!==0)return s}return t.byteLength-i.byteLength}function gr(e){if(typeof e!="string"||e.length===0||e.includes("\\")||e.includes("\0")||ie__namespace.posix.isAbsolute(e)||e.split("/").some(n=>n===".."||n.length===0))throw _("PACKAGE_PATH_TRAVERSAL","manifest file path must be a non-empty POSIX relative path")}function zd(e){if(!/^(?:apps|skills)\/[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(e))throw _("APP_PACKAGE_ROOT_INVALID","packageRoot must be apps/<safe-id> or skills/<safe-id>")}function mr(e){if(!jd.test(e))throw new Error(`publish: invalid version "${e}" \u2014 must be semver (e.g. 1.0.0)`)}function hr(e,n,t={}){let i=Vd(e),o=i.name??ie__namespace.basename(e);if(!yr.test(o))throw new Error(`publish: invalid name "${o}" \u2014 must match ${yr} (lowercase letters, numbers, hyphen only)`);let r=t.version??i.version;if(!r)throw new Error("publish: version is required \u2014 set crewx.yaml metadata.version or pass opts.version");mr(r);let s=Array.isArray(i.requiredEnv)?i.requiredEnv:[],a=[];for(let p of s){if(typeof p!="string"||!Fd.test(p))throw new Error(`publish: requiredEnv must contain names only (no values), got "${String(p)}"`);a.push(p);}let c=n.map(p=>(gr(p),{path:p,sha256:Ir(ie__namespace.join(e,p))})).sort((p,A)=>p.path<A.path?-1:p.path>A.path?1:0),d={name:o,version:r,type:"template",description:i.description??"",files:c,requiredEnv:a};return i.crewxMinVersion&&(d.crewxMinVersion=i.crewxMinVersion),d}function $d(e){let n=e.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"");if(!n)throw _("APP_PACKAGE_ROOT_INVALID","appId cannot produce a marketplace name");return n}function _r(e,n){if(zd(n.packageRoot),!n.version)throw new Error("publish: version is required for App publishing \u2014 pass opts.version");if(mr(n.version),typeof n.description!="string")throw new Error("publish: App description must be a string");let t=[...new Set(n.capabilities)].sort();if(t.length===0||t.some(s=>s!=="screen"&&s!=="skill"))throw new Error("publish: App capabilities must contain screen or skill");let i=`${n.packageRoot}/`;if(t.includes("screen")){if(typeof n.definitionId!="string"||n.definitionId.length===0)throw _("APP_UI_MANIFEST_INVALID","screen App manifests require definitionId");let s=n.includedFiles.includes(`${i}manifest.json`),a=n.includedFiles.includes(`${i}ui-plugin.json`);if(!s&&!a)throw _("APP_UI_MANIFEST_INVALID","screen App is missing manifest.json or ui-plugin.json");if(s&&!a)throw _("APP_UI_MANIFEST_INVALID","a manifest.json App must also ship a generated ui-plugin.json");if(!n.includedFiles.includes(`${i}ui/index.html`))throw _("APP_UI_MANIFEST_INVALID","screen App is missing ui/index.html")}if(t.includes("skill")&&!n.includedFiles.includes(`${i}SKILL.md`))throw _("APP_SKILL_MISSING","skill capability requires package-root SKILL.md");let o=new Set,r=n.includedFiles.map(s=>{if(gr(s),!s.startsWith(i))throw _("PACKAGE_PATH_TRAVERSAL","App manifest file is outside packageRoot");let a=n.generatedFiles?.get(s);return a!==void 0&&o.add(s),{path:s,sha256:a===void 0?Ir(ie__namespace.join(e,s)):Bd(a),...a===void 0?{}:{generated:true}}}).sort((s,a)=>Hd(s.path,a.path));if(o.size>0&&(o.size!==1||!o.has(`${i}ui-plugin.json`)))throw new Error("publish: only the generated ui-plugin.json may be present in an App package");return {manifestVersion:1,name:$d(n.appId),version:n.version,type:"app",description:n.description,appId:n.appId,...n.definitionId===void 0?{}:{definitionId:n.definitionId},...n.definitionHash===void 0?{}:{definitionHash:n.definitionHash},capabilities:t,packageRoot:n.packageRoot,files:r,requiredEnv:[]}}g();function Er(e){return li__namespace.createHash("sha256").update(e).digest("hex")}function br(e,n){if(typeof n!="string"||n.length===0||n.includes("\\")||n.includes("\0")||ie__namespace.posix.isAbsolute(n)||n.split("/").some(o=>o===".."||o.length===0))throw _("PACKAGE_PATH_TRAVERSAL","archive paths must be non-empty POSIX relative paths");let t=ie__namespace.resolve(e),i=ie__namespace.resolve(t,...n.split("/"));if(i!==t&&!i.startsWith(`${t}${ie__namespace.sep}`))throw _("PACKAGE_PATH_TRAVERSAL","archive path escaped its root");return i}function Tr(e,n){let t=br(e,n),i;try{i=q__namespace.lstatSync(t);}catch{throw _("PACKAGE_FILE_INVALID","manifest file is missing")}if(i.isSymbolicLink())throw _("PACKAGE_SYMLINK","symlink content is not publishable");if(!i.isFile())throw _("PACKAGE_FILE_INVALID","only regular files are publishable");return new Uint8Array(q__namespace.readFileSync(t))}async function Sr(e,n,t={}){let i=ie__namespace.join(e,".crewx","publish");q__namespace.mkdirSync(i,{recursive:true});let o=ie__namespace.join(i,`${n.name}-${n.version}.tgz`),r=ie__namespace.join(i,`.${n.name}-${n.version}.${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}.tmp.tgz`),s=q__namespace.mkdtempSync(ie__namespace.join(Pr__namespace.tmpdir(),"crewx-publish-"));try{let a=new Set,c=[];for(let d of n.files){if(a.has(d.path))throw _("PACKAGE_PATH_TRAVERSAL","manifest contains duplicate file paths");a.add(d.path);let p=t.generatedFiles?.get(d.path);if(d.generated===!0&&p===void 0)throw _("PACKAGE_GENERATED_FILE_MISSING","generated manifest file bytes are missing");if(t.sourceFileHashes?.has(d.path)){let y=Tr(e,d.path);if(t.sourceFileHashes.get(d.path)!==Er(y))throw _("PACKAGE_STAGED_BYTES_MISMATCH","workspace source changed before staging")}let A=p??Tr(e,d.path);if(Er(A)!==d.sha256)throw _("PACKAGE_STAGED_BYTES_MISMATCH",`staged bytes differ for ${d.path}`);let m=br(s,d.path);q__namespace.mkdirSync(ie__namespace.dirname(m),{recursive:!0}),q__namespace.writeFileSync(m,new Uint8Array(A)),c.push(d.path);}q__namespace.writeFileSync(ie__namespace.join(s,"manifest.json"),JSON.stringify(n,null,2)),await Dr__namespace.create({gzip:!0,file:r,cwd:s,portable:!0,noMtime:!0},["manifest.json",...c]),q__namespace.renameSync(r,o);}finally{try{q__namespace.rmSync(r,{force:!0});}catch{}q__namespace.rmSync(s,{recursive:true,force:true});}return o}g();g();var on="/api/v1";var Jd=201,Kd=200,Xd=409,ui=401,Mr={APP_NAME_CONFLICT:"APP_NAME_CONFLICT",CONTENT_SUSPENDED:"PUBLISH_CONTENT_SUSPENDED",CONTENT_REJECTED:"CONTENT_REJECTED",APP_VERSION_MUST_INCREASE:"APP_VERSION_MUST_INCREASE",APP_VERSION_INVALID:"APP_VERSION_INVALID"};function Yd(){return process.env.WI013_FAKE_UPLOAD==="1"}function qd(e){let n=zlib.gunzipSync(new Uint8Array(e)),t=zlib.gzipSync(new Uint8Array(n),{level:1});if(Buffer.compare(new Uint8Array(t),new Uint8Array(e))===0)throw new Error("publish: [E_MALFORMED] Re-gzipped upload bytes are identical to the original \u2014 tamper is a no-op");return t}function Zd(e){return e.replace(/\/+$/,"")}async function _n(e){try{return await e.json()}catch{return null}}function Lr(e,n,t){let i=e;if(!i||i.success!==true||i.data===void 0)throw new Error(`publish: [E_MALFORMED] ${n} response envelope is malformed (expected { success: true, data }) \u2014 HTTP ${t}`);return i.data}function Qd(e){if(!e||typeof e!="object"||Array.isArray(e))return;let n=e;if(typeof n.contentId=="string"&&n.contentId.length>0)return n.contentId;if(!n.data||typeof n.data!="object"||Array.isArray(n.data))return;let t=n.data;return typeof t.contentId=="string"&&t.contentId.length>0?t.contentId:void 0}function ep(e){if(!e||typeof e!="object"||Array.isArray(e))return;let n=e;if(typeof n.slug=="string"&&n.slug.length>0)return n.slug;if(!n.data||typeof n.data!="object"||Array.isArray(n.data))return;let t=n.data;return typeof t.slug=="string"&&t.slug.length>0?t.slug:void 0}function Or(e,n){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,i=t.data&&typeof t.data=="object"&&!Array.isArray(t.data)?t.data:void 0,o=[t.code,t.message,i?.code,i?.message];for(let r of o){if(typeof r!="string"||!Object.prototype.hasOwnProperty.call(Mr,r))continue;let s=r,a=s==="APP_NAME_CONFLICT"?`marketplace name is already in use: ${n}`:void 0;return _(Mr[s],a)}}async function np(e){if(!e.baseUrl.trim())throw new Error("publish: [E_ENV_MISSING] Marketplace base URL is required");if(!e.accessToken.trim())throw new Error("publish: [E_AUTH_EXPIRED] A valid bearer token is required");let n=Zd(e.baseUrl),t=e.accessPolicy??"private",i=e.manifest.name,o=e.manifest.type==="app"?e.manifest:void 0,r=o!==void 0,s=o?.appId,a;try{a=await fetch(`${n}${on}/publisher/items`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({slug:i,displayName:i,description:e.manifest.description,type:e.manifest.type,version:e.manifest.version,accessPolicy:t,...s===void 0?{}:{appId:s}})});}catch{throw new Error("publish: [E_NETWORK] Submit request failed (network)")}let c=await _n(a),d=Qd(c),p=ep(c),A=r&&p!==void 0?p:i,m;if(a.status===Jd)m="created";else if(r&&a.status===Kd){if(d===void 0)throw _("PUBLISH_CONTENT_ID_MISSING","App republish did not return an opaque contentId");m="existing";}else if(a.status===Xd){if(r)throw Or(c,i)??_("APP_NAME_CONFLICT",`marketplace name is already in use: ${i}`);m="existing";}else throw a.status===ui?new Error("publish: [E_AUTH_EXPIRED] Authentication is expired or missing \u2014 please log in again (HTTP 401)"):new Error(`publish: [E_HTTP] Submit request failed \u2014 HTTP ${a.status}`);let y="not-needed",h=null;if(m==="existing"&&!r){let U;try{U=await fetch(`${n}${on}/publisher/items`,{method:"GET",headers:{Authorization:`Bearer ${e.accessToken}`}});}catch{throw new Error("publish: [E_NETWORK] Publisher items request failed (network)")}let D=await _n(U);if(U.status!==200)throw new Error(`publish: [E_HTTP] Publisher items request failed \u2014 HTTP ${U.status}`);let u=Lr(D,"publisher items",U.status)?.items;if(!Array.isArray(u))throw new Error(`publish: [E_MALFORMED] Publisher items response is malformed (expected data.items[]) \u2014 HTTP ${U.status}`);let I=u.find(P=>!P||typeof P!="object"?false:P.slug===i);if(!I||typeof I.version!="string")throw new Error(`publish: [E_MALFORMED] Publisher items response does not contain slug "${i}" \u2014 HTTP ${U.status}`);if(h=I.version,h!==e.manifest.version){let P;try{P=await fetch(`${n}${on}/publisher/items/${encodeURIComponent(i)}`,{method:"PUT",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({version:e.manifest.version})});}catch{throw new Error("publish: [E_NETWORK] Version update request failed (network)")}if(!P.ok)throw await _n(P),P.status===ui?new Error(`publish: [E_AUTH_EXPIRED] Authentication is expired or missing \u2014 please log in again (HTTP ${P.status})`):P.status===403?new Error(`publish: [E_FORBIDDEN] Version update is forbidden; only the item owner can update an existing item (HTTP ${P.status})`):new Error(`publish: [E_HTTP] Version update failed \u2014 HTTP ${P.status}`);y="applied";}}let L=q__namespace.readFileSync(e.tgzPath),S=Yd()?qd(L):L,j=new FormData;j.set("archive",new Blob([new Uint8Array(S)],{type:"application/gzip"}),`${A}-${e.manifest.version}.tgz`);let C=r&&d!==void 0?d:i,x;try{x=await fetch(`${n}${on}/publisher/items/${encodeURIComponent(C)}/upload`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`},body:j});}catch{throw new Error("publish: [E_NETWORK] Upload request failed (network)")}if(x.status===ui)throw new Error("publish: [E_AUTH_EXPIRED] Authentication is expired or missing \u2014 please log in again (HTTP 401)");if(!x.ok){let U=await _n(x);if(r){let D=Or(U,A);if(D)throw D}throw new Error(`publish: [E_HTTP] Upload request failed \u2014 HTTP ${x.status}`)}let F=await _n(x),E=Lr(F,"upload",x.status),T=typeof E.contentId=="string"&&E.contentId.length>0?E.contentId:d;if(r&&T===void 0)throw _("PUBLISH_CONTENT_ID_MISSING","App upload did not return an opaque contentId");return {slug:A,version:e.manifest.version,...T===void 0?{}:{contentId:T},artifactChecksum:E.artifactChecksum,artifactSizeBytes:E.artifactSizeBytes,submitOutcome:m,versionUpdate:y,serverVersionBefore:h}}var tp=1e4,ip=100*1024*1024;function fi(e){return li__namespace.createHash("sha256").update(e).digest("hex")}function op(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}function En(e,n){if(!n||n.includes("\\")||n.includes("\0")||ie__namespace.posix.isAbsolute(n)||n.split("/").some(r=>r===".."||r.length===0))throw _("PACKAGE_PATH_TRAVERSAL","workspace file path is not a safe relative path");let t=ie__namespace.resolve(e,...n.split("/")),i=ie__namespace.resolve(e);if(t!==i&&!t.startsWith(`${i}${ie__namespace.sep}`))throw _("PACKAGE_PATH_TRAVERSAL","workspace file path escaped the workspace root");let o;try{o=q__namespace.lstatSync(t);}catch{throw _("PACKAGE_FILE_INVALID",`workspace file is missing: ${n}`)}if(o.isSymbolicLink())throw _("PACKAGE_SYMLINK",`symlink is not publishable: ${n}`);if(!o.isFile())throw _("PACKAGE_FILE_INVALID",`not a regular file: ${n}`);return new Uint8Array(q__namespace.readFileSync(t))}function et(e,n){return e===n||e.startsWith(`${n}/`)}function rp(e,n){return e.path<n.path?-1:e.path>n.path?1:e.rule.localeCompare(n.rule)}function wr(e,n,t){let i=e??n;if(!Number.isSafeInteger(i)||i<=0)throw new Me("PACKAGE_SIZE_LIMIT",`${t} must be a positive integer`);return i}function Cr(e,n,t,i){let o=wr(t.maxFileCount??t.maxFiles,tp,"max file count"),r=wr(t.maxTotalBytes??t.maxBytes,ip,"max total bytes");if(n.length>o)throw new Me("PACKAGE_SIZE_LIMIT",`package exceeds file count limit (${o})`);let s=0;for(let a of n){let c=i?.get(a);if(c!==void 0?s+=c.byteLength:s+=En(e,a).byteLength,s>r)throw new Me("PACKAGE_SIZE_LIMIT",`package exceeds byte limit (${r})`)}}function sp(e){return e.appId!==void 0||e.expectedDefinitionHash!==void 0}function ap(e){let n=e.appId!==void 0,t=e.expectedDefinitionHash!==void 0;if(!n&&t)throw _("APP_ID_REQUIRED","appId is required with expectedDefinitionHash");if(n&&!t)throw _("APP_DEFINITION_HASH_REQUIRED","expectedDefinitionHash is required with appId");if(!n||!t)throw _("APP_ID_REQUIRED")}function cp(e,n){let t=e.filter(i=>i.appId===n);if(t.length===0)throw _("APP_NOT_FOUND",`no publishable App matches ${n}`);if(t.length!==1)throw _("APP_AMBIGUOUS",`more than one App matches ${n}`);return t[0]}function dp(e){let n=e.localDefinitionRef?.packageRoot;if(!n||!/^(?:apps|skills)\/[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(n))throw _("APP_PACKAGE_ROOT_INVALID","selected App is not rooted in apps/<safe-id> or skills/<safe-id>");return n}function pp(e,n){let t=[];for(let i of e.excluded)t.push(et(i.path,n)?i:{path:i.path,rule:"out-of-app-scope"});for(let i of e.included)et(i,n)||t.push({path:i,rule:"out-of-app-scope"});return t.sort(rp)}function yi(e){let{path:n,rule:t}=e.reason;return `${e.code} at ${n===""?"<file>":n} (${t})`+(e.files.length>0?` [${e.files.join(", ")}]`:"")}function lp(e,n,t){let i=Fe({[re]:t},{mode:"published"});if(!i.ok)throw _("APP_UI_MANIFEST_INVALID",`generated ${re} does not read: ${yi(i.rejection)}`);if(Qe(i.manifest)!==Qe(n))throw _("APP_UI_MANIFEST_INVALID",`generated ${re} normalizes to a different definition hash than the source`);let o=e[G];if(o===void 0)return;let r=e[V],s=Fe({[G]:o,[re]:t,...r===void 0?{}:{[V]:r}},{mode:"local"});if(!s.ok)throw _("APP_UI_MANIFEST_INVALID",yi(s.rejection))}function up(e,n,t,i){let o={};for(let y of X){let h=`${t}/${y}`;i.includes(h)&&(o[y]=En(e,h));}let r=`${t}/${V}`;if(o[G]!==void 0&&i.includes(r)&&(o[V]=En(e,r)),Object.keys(o).length===0)throw _("APP_UI_MANIFEST_INVALID","selected screen App has no package manifest.json or ui-plugin.json");let s=Fe(o,{mode:"local"});if(!s.ok)throw _("APP_UI_MANIFEST_INVALID",yi(s.rejection));if(s.manifest.pluginId!==n.appId)throw _("APP_DEFINITION_CONFLICT",`${s.file} identity no longer matches the selected App`);let a=o[re],c=a===void 0?void 0:fi(a),d=`${t}/ui/index.html`;if(!i.includes(d))throw _("APP_UI_MANIFEST_INVALID","screen entry is outside package scope");let p=fi(En(e,d)),A=JSON.parse(JSON.stringify(s.v2Input));if(A.entryHash=p,Object.prototype.hasOwnProperty.call(A,"initialState")){let y=A.initialState;if(!op(y)||y.path!=="ui/state.json")throw _("APP_INITIAL_STATE_OUT_OF_SCOPE","initialState must reference ui/state.json inside the package");let h=`${t}/ui/state.json`;if(!i.includes(h))throw _("APP_INITIAL_STATE_OUT_OF_SCOPE","initialState reference is outside the selected package");let L=En(e,h);A.initialState={...y,hash:fi(L)};}let m;try{let y=je(A,{mode:"published"});m=new Uint8Array(Buffer.from(JSON.stringify(y),"utf8"));}catch(y){throw y instanceof ne?_("APP_UI_MANIFEST_INVALID",y.code):_("APP_UI_MANIFEST_INVALID")}return lp(o,s.manifest,m),{bytes:m,...c===void 0?{}:{legacySourceHash:c}}}async function fp(e,n){let{included:t,excluded:i}=di(e);Cr(e,t,n);let o=hr(e,t,{version:n.version}),r=pi(e,t);return {plan:{manifest:o,included:t,excluded:i,secretFindings:r},archiveOptions:{}}}async function yp(e,n){ap(n);let t=await dr(e),i=cp(t.items,n.appId);if(i.definitionHash!==n.expectedDefinitionHash)throw _("APP_DEFINITION_CONFLICT",`definitionHash changed for ${n.appId}`);let o=dp(i),r=di(e);if(r.excluded.some(y=>et(y.path,o)&&(y.rule==="symlink"||y.rule==="symlink-dir")))throw _("PACKAGE_SYMLINK","selected App package contains a symlink");let s=r.included.filter(y=>et(y,o)),a=pp(r,o),c=new Map,d=new Map;if(i.capabilities.includes("screen")){let y=up(e,i,o,s),h=`${o}/${re}`;c.set(h,y.bytes),y.legacySourceHash!==void 0?d.set(h,y.legacySourceHash):(s.push(h),s.sort());}if(i.capabilities.includes("skill")&&!s.includes(`${o}/SKILL.md`))throw _("APP_SKILL_MISSING","skill capability requires package-root SKILL.md");Cr(e,s,n,c);let p={appId:i.appId,version:n.version??"",description:i.description,capabilities:i.capabilities,packageRoot:o,...i.definition?.id===void 0?{}:{definitionId:i.definition.id},definitionHash:i.definitionHash,includedFiles:s,generatedFiles:c},A=_r(e,p),m=pi(e,s,c);return {plan:{manifest:A,included:s,excluded:a,secretFindings:m},archiveOptions:{generatedFiles:c,sourceFileHashes:d}}}async function kr(e,n){let t=ie__namespace.resolve(e);if(sp(n))return yp(t,n);if(n.expectedDefinitionHash!==void 0)throw _("APP_ID_REQUIRED");return fp(t,n)}async function fy(e,n={}){return (await kr(e,n)).plan}function Ap(e){let n=e.map(t=>`${t.path}:${t.line} (${t.rule})`).join(", ");throw new Me("PUBLISH_SECRET_FINDINGS",`aborted \u2014 secret findings must be resolved before packing: ${n}`)}async function xr(e,n={}){let t=ie__namespace.resolve(e),i=await kr(t,n);i.plan.secretFindings.length>0&&Ap(i.plan.secretFindings);let o=await Sr(t,i.plan.manifest,i.archiveOptions);return {manifest:i.plan.manifest,tgzPath:o}}async function yy(e,n={}){return xr(e,n)}async function Ay(e,n){let t=await xr(e,n);if(t.manifest.type!=="app")throw new Error("publish: App pack unexpectedly produced a template manifest");return t}
|
|
2
|
+
exports.DEFAULT_PUBLISH_MAX_BYTES=ip;exports.DEFAULT_PUBLISH_MAX_FILES=tp;exports.EXCLUDE_RULES=pr;exports.MARKETPLACE_API_PREFIX=on;exports.PublishError=Me;exports.packApp=Ay;exports.packPublish=xr;exports.packTemplate=yy;exports.planPublish=fy;exports.uploadToMarketplace=np;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface ManifestFile {
|
|
2
|
+
path: string;
|
|
3
|
+
sha256: string;
|
|
4
|
+
generated?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface PublishTemplateManifest {
|
|
7
|
+
name: string;
|
|
8
|
+
version: string;
|
|
9
|
+
type: 'template';
|
|
10
|
+
description: string;
|
|
11
|
+
files: ManifestFile[];
|
|
12
|
+
requiredEnv: string[];
|
|
13
|
+
crewxMinVersion?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface PublishAppManifest {
|
|
16
|
+
manifestVersion: 1;
|
|
17
|
+
name: string;
|
|
18
|
+
version: string;
|
|
19
|
+
type: 'app';
|
|
20
|
+
description: string;
|
|
21
|
+
appId: string;
|
|
22
|
+
definitionId?: string;
|
|
23
|
+
definitionHash?: string;
|
|
24
|
+
capabilities: readonly ('screen' | 'skill')[];
|
|
25
|
+
packageRoot: string;
|
|
26
|
+
files: ManifestFile[];
|
|
27
|
+
requiredEnv: string[];
|
|
28
|
+
crewxMinVersion?: string;
|
|
29
|
+
}
|
|
30
|
+
export type PublishManifest = PublishTemplateManifest | PublishAppManifest;
|
|
31
|
+
export interface BuildManifestOptions {
|
|
32
|
+
version?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface BuildAppManifestOptions {
|
|
35
|
+
appId: string;
|
|
36
|
+
version: string;
|
|
37
|
+
description: string;
|
|
38
|
+
capabilities: readonly ('screen' | 'skill')[];
|
|
39
|
+
packageRoot: string;
|
|
40
|
+
definitionId?: string;
|
|
41
|
+
definitionHash?: string;
|
|
42
|
+
includedFiles: string[];
|
|
43
|
+
generatedFiles?: ReadonlyMap<string, Uint8Array>;
|
|
44
|
+
}
|
|
45
|
+
export declare function buildManifest(rootDir: string, includedFiles: string[], opts?: BuildManifestOptions): PublishManifest;
|
|
46
|
+
export declare function appMarketplaceName(appId: string): string;
|
|
47
|
+
export declare function buildAppManifest(rootDir: string, opts: BuildAppManifestOptions): PublishAppManifest;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MARKETPLACE_API_PREFIX = "/api/v1";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PublishManifest } from './manifest';
|
|
2
|
+
export interface CreateArchiveOptions {
|
|
3
|
+
generatedFiles?: ReadonlyMap<string, Uint8Array>;
|
|
4
|
+
sourceFileHashes?: ReadonlyMap<string, string>;
|
|
5
|
+
}
|
|
6
|
+
export declare function createArchive(rootDir: string, manifest: PublishManifest, options?: CreateArchiveOptions): Promise<string>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PublishManifest } from './manifest';
|
|
2
|
+
export interface PublishUploadOptions {
|
|
3
|
+
tgzPath: string;
|
|
4
|
+
manifest: PublishManifest;
|
|
5
|
+
baseUrl: string;
|
|
6
|
+
accessToken: string;
|
|
7
|
+
accessPolicy?: 'private';
|
|
8
|
+
}
|
|
9
|
+
export interface PublishUploadResult {
|
|
10
|
+
slug: string;
|
|
11
|
+
version: string;
|
|
12
|
+
contentId?: string;
|
|
13
|
+
artifactChecksum: string;
|
|
14
|
+
artifactSizeBytes: number;
|
|
15
|
+
submitOutcome: 'created' | 'existing';
|
|
16
|
+
versionUpdate: 'not-needed' | 'applied';
|
|
17
|
+
serverVersionBefore: string | null;
|
|
18
|
+
}
|
|
19
|
+
export declare function uploadToMarketplace(opts: PublishUploadOptions): Promise<PublishUploadResult>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AgentExecutionProfile } from './types.js';
|
|
2
|
+
export declare function resolveAgentExecutionProfiles(input: {
|
|
3
|
+
location: string;
|
|
4
|
+
targetAgentIds: string[];
|
|
5
|
+
}): Map<string, AgentExecutionProfile>;
|
|
6
|
+
export declare function resolveAgentExecutionProfile(input: {
|
|
7
|
+
location: string;
|
|
8
|
+
targetAgentId: string;
|
|
9
|
+
}): AgentExecutionProfile;
|
package/dist/remote/index.d.ts
CHANGED
|
@@ -5,3 +5,4 @@ export { RemoteAgentManager } from './remote-agent-manager.js';
|
|
|
5
5
|
export type { RemoteAgentManagerOptions } from './remote-agent-manager.js';
|
|
6
6
|
export { RemoteProviderRuntime, createRemoteProviderFactory, resolveFileRemoteAgent } from './remote-provider.js';
|
|
7
7
|
export type { ProviderFactoryFn, FileRemoteResolution, FileRemoteResolver } from './remote-provider.js';
|
|
8
|
+
export { resolveAgentExecutionProfile, resolveAgentExecutionProfiles, } from './execution-profile.js';
|
package/dist/remote/types.d.ts
CHANGED
|
@@ -44,6 +44,34 @@ export interface RemoteProviderConfig {
|
|
|
44
44
|
apiKey?: string;
|
|
45
45
|
headers?: Record<string, string>;
|
|
46
46
|
}
|
|
47
|
+
export type AgentExecutionProfileStatus = 'resolved' | 'pending' | 'unavailable';
|
|
48
|
+
export type AgentExecutionProfileErrorCode = 'TARGET_NOT_FOUND' | 'TARGET_AGENT_NOT_FOUND' | 'TARGET_NO_PROVIDER' | 'CHAINED_REMOTE' | 'TARGET_PARSE_FAILED' | 'TRANSPORT_ERROR';
|
|
49
|
+
export interface AgentExecutionProfileSlot {
|
|
50
|
+
provider?: string;
|
|
51
|
+
model?: string;
|
|
52
|
+
effort?: string;
|
|
53
|
+
overdrive?: {
|
|
54
|
+
provider: string;
|
|
55
|
+
model: string;
|
|
56
|
+
mode?: string;
|
|
57
|
+
effort?: string;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export interface AgentExecutionProfile {
|
|
61
|
+
status: AgentExecutionProfileStatus;
|
|
62
|
+
location?: string;
|
|
63
|
+
agentId?: string;
|
|
64
|
+
provider?: string;
|
|
65
|
+
model?: string;
|
|
66
|
+
options?: {
|
|
67
|
+
query?: AgentExecutionProfileSlot;
|
|
68
|
+
execute?: AgentExecutionProfileSlot;
|
|
69
|
+
};
|
|
70
|
+
error?: {
|
|
71
|
+
code: AgentExecutionProfileErrorCode;
|
|
72
|
+
message: string;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
47
75
|
export interface RemoteAgentQueryRequest {
|
|
48
76
|
agentId: string;
|
|
49
77
|
query: string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BaseSqliteRepository } from './base-sqlite-repository.js';
|
|
2
|
+
import { agent_suggestions } from '../schema/index.js';
|
|
3
|
+
export type AgentSuggestionRow = typeof agent_suggestions.$inferSelect;
|
|
4
|
+
export type NewAgentSuggestion = typeof agent_suggestions.$inferInsert;
|
|
5
|
+
export type SuggestionType = 'H1' | 'H3';
|
|
6
|
+
export type SuggestionStatus = 'pending' | 'applied' | 'dismissed';
|
|
7
|
+
export interface CreateAgentSuggestionInput {
|
|
8
|
+
workspaceId: string;
|
|
9
|
+
agentId: string;
|
|
10
|
+
taskId?: string | null;
|
|
11
|
+
type: SuggestionType;
|
|
12
|
+
status?: SuggestionStatus;
|
|
13
|
+
payload: string;
|
|
14
|
+
appliedCommitSha?: string | null;
|
|
15
|
+
}
|
|
16
|
+
export declare const DEFAULT_LIST_LIMIT = 50;
|
|
17
|
+
export declare class AgentSuggestionRepository extends BaseSqliteRepository {
|
|
18
|
+
private readonly dbPath?;
|
|
19
|
+
constructor(opts?: {
|
|
20
|
+
dbPath?: string;
|
|
21
|
+
dbRoot?: string;
|
|
22
|
+
});
|
|
23
|
+
resolveDbPath(): string;
|
|
24
|
+
private openHandle;
|
|
25
|
+
create(rows: CreateAgentSuggestionInput[]): {
|
|
26
|
+
ids: string[];
|
|
27
|
+
};
|
|
28
|
+
findLatestSet(workspaceId: string, agentId: string): AgentSuggestionRow[];
|
|
29
|
+
findSetByTaskId(workspaceId: string, agentId: string, taskId: string): AgentSuggestionRow[];
|
|
30
|
+
findById(workspaceId: string, agentId: string, suggestionId: string): AgentSuggestionRow | null;
|
|
31
|
+
updateStatus(id: string, status: SuggestionStatus, appliedCommitSha?: string | null): boolean;
|
|
32
|
+
listByAgent(workspaceId: string, agentId: string, limit?: number): AgentSuggestionRow[];
|
|
33
|
+
findDismissed(workspaceId: string, agentId: string, limit?: number): AgentSuggestionRow[];
|
|
34
|
+
}
|