dsh-agent-plugins-market 0.9.0 → 0.9.2
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 +64 -154
- package/README.zh.md +74 -164
- package/assets/dsh-agent-plugins.png +0 -0
- package/client/client.js +5371 -1085
- package/client/client.js.map +1 -1
- package/lib/index.js +2 -257
- package/lib/{application → packages/market-bundle/src/application}/catalog.js +207 -41
- package/lib/{application → packages/market-bundle/src/application}/details.js +73 -29
- package/lib/packages/market-bundle/src/application/extension-inventory.js +408 -0
- package/lib/packages/market-bundle/src/application/extension-project.js +64 -0
- package/lib/packages/market-bundle/src/application/resource-inventory.js +96 -0
- package/lib/packages/market-bundle/src/application/server-config.js +9 -0
- package/lib/packages/market-bundle/src/application/suite-queries.js +86 -0
- package/lib/packages/market-bundle/src/index.js +372 -0
- package/lib/{runtime/host → packages/market-bundle/src/platform}/feedback-tool.js +2 -2
- package/lib/{runtime/host → packages/market-bundle/src/platform}/settings-namespace.js +55 -7
- package/lib/packages/market-bundle/src/platform/settings-schema.js +25 -0
- package/lib/packages/market-bundle/src/routes-extension-presets.js +161 -0
- package/lib/packages/market-bundle/src/routes-resources.js +127 -0
- package/lib/{routes.js → packages/market-bundle/src/routes.js} +225 -21
- package/lib/packages/market-bundle/src/runtime-adapters.js +57 -0
- package/lib/packages/market-bundle/src/session-extension.js +337 -0
- package/lib/{application → packages/market-catalog/src/application}/catalog-context.js +7 -4
- package/lib/{application → packages/market-catalog/src/application}/install-store.js +3 -3
- package/lib/{application → packages/market-catalog/src/application}/snapshot-cache.js +100 -11
- package/lib/{application → packages/market-catalog/src/application}/source-store.js +24 -11
- package/lib/{application → packages/market-catalog/src/application}/state/state-store.js +1 -1
- package/lib/{application → packages/market-catalog/src/application}/state/storage-migration.js +1 -1
- package/lib/packages/market-catalog/src/index.js +19 -0
- package/lib/{catalog → packages/market-catalog/src/scanning}/archive.js +1 -1
- package/lib/{catalog → packages/market-catalog/src/scanning}/codex-mcp.js +1 -1
- package/lib/{catalog → packages/market-catalog/src/scanning}/component-files.js +2 -2
- package/lib/{catalog → packages/market-catalog/src/scanning}/manifests.js +2 -2
- package/lib/{catalog → packages/market-catalog/src/scanning}/native-project.js +1 -1
- package/lib/{catalog → packages/market-catalog/src/scanning}/paths.js +1 -1
- package/lib/{catalog → packages/market-catalog/src/scanning}/plugin-variables.js +21 -1
- package/lib/{catalog → packages/market-catalog/src/scanning}/scan-resolvers.js +35 -2
- package/lib/{catalog → packages/market-catalog/src/scanning}/skills-parse.js +40 -10
- package/lib/{catalog → packages/market-catalog/src/scanning}/validate.js +15 -2
- package/lib/packages/market-contracts/src/contracts/extension-presets.js +125 -0
- package/lib/{contracts → packages/market-contracts/src/contracts}/market.js +33 -5
- package/lib/packages/market-contracts/src/contracts/mcp-overrides.js +2 -0
- package/lib/packages/market-contracts/src/contracts/resource-window.js +29 -0
- package/lib/packages/market-contracts/src/contracts/settings.js +130 -0
- package/lib/packages/market-contracts/src/contracts/surface-toggles.js +29 -0
- package/lib/packages/market-contracts/src/contracts/translation.js +28 -0
- package/lib/packages/market-contracts/src/index.js +4 -0
- package/lib/{model → packages/market-contracts/src/model}/layouts.js +11 -0
- package/lib/{application → packages/market-contracts/src/ports}/ports.js +3 -0
- package/lib/{application/mcp/mcp-redaction.js → packages/market-contracts/src/redaction.js} +17 -1
- package/lib/{application → packages/market-lsp/src/application}/lsp/lsp-direct-config.js +2 -2
- package/lib/{application → packages/market-lsp/src/application}/lsp/lsp-server-state.js +1 -1
- package/lib/{application → packages/market-lsp/src/application}/lsp/lsp-status.js +20 -3
- package/lib/{application → packages/market-lsp/src/application}/lsp/profile-seam.js +1 -1
- package/lib/packages/market-lsp/src/application/lsp/validation.js +46 -0
- package/lib/{application → packages/market-lsp/src/application}/lsp-service.js +61 -3
- package/lib/packages/market-lsp/src/index.js +8 -0
- package/lib/{runtime → packages/market-lsp/src/runtime}/lsp/lsp-mounts.js +79 -40
- package/lib/{application → packages/market-mcp/src/application}/mcp/mcp-backend.js +0 -16
- package/lib/{application → packages/market-mcp/src/application}/mcp/mcp-config.js +104 -21
- package/lib/{application → packages/market-mcp/src/application}/mcp/mcp-direct-config.js +12 -4
- package/lib/{application → packages/market-mcp/src/application}/mcp/mcp-overrides.js +4 -4
- package/lib/{application → packages/market-mcp/src/application}/mcp/mcp-status.js +49 -10
- package/lib/packages/market-mcp/src/application/mcp/validation.js +63 -0
- package/lib/{application → packages/market-mcp/src/application}/mcp-service.js +111 -91
- package/lib/packages/market-mcp/src/index.js +10 -0
- package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/bridge.js +12 -9
- package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/connection.js +1 -1
- package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/oauth.js +1 -1
- package/lib/packages/market-mcp/src/runtime/mcp/bridge/tool-ownership.js +26 -0
- package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/tools.js +1 -1
- package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/mcp-auth-record.js +35 -4
- package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/mcp-mounts.js +35 -4
- package/lib/packages/market-runtime/src/adapter-contracts.js +1 -0
- package/lib/packages/market-runtime/src/application/command-resources.js +74 -0
- package/lib/packages/market-runtime/src/application/extension-authorization.js +27 -0
- package/lib/packages/market-runtime/src/application/extension-hook-selection.js +56 -0
- package/lib/packages/market-runtime/src/application/extension-suite-declarations.js +57 -0
- package/lib/packages/market-runtime/src/application/extension-suite-selection.js +84 -0
- package/lib/packages/market-runtime/src/application/fs-probe.js +43 -0
- package/lib/packages/market-runtime/src/application/panel-resources.js +370 -0
- package/lib/{application → packages/market-runtime/src/application}/panels/user-hooks.js +2 -2
- package/lib/{application → packages/market-runtime/src/application}/panels/user-store.js +53 -13
- package/lib/{application → packages/market-runtime/src/application}/project-agent-roles.js +20 -11
- package/lib/packages/market-runtime/src/application/state/extension-presets.js +144 -0
- package/lib/packages/market-runtime/src/application/state/resource-favorites.js +90 -0
- package/lib/packages/market-runtime/src/application/state/resource-filters.js +2 -0
- package/lib/packages/market-runtime/src/application/state/surface-toggles.js +10 -0
- package/lib/packages/market-runtime/src/application/state/workspace-policy.js +56 -0
- package/lib/packages/market-runtime/src/catalog-port.js +1 -0
- package/lib/packages/market-runtime/src/extension-service.js +1 -0
- package/lib/packages/market-runtime/src/index.js +31 -0
- package/lib/{runtime → packages/market-runtime/src/runtime}/agents/agent-role-router.js +74 -79
- package/lib/packages/market-runtime/src/runtime/agents/agent-teams-seat.js +58 -0
- package/lib/{runtime → packages/market-runtime/src/runtime}/agents/subagent-catalog.js +89 -21
- package/lib/packages/market-runtime/src/runtime/agents/team-coordination.js +51 -0
- package/lib/packages/market-runtime/src/runtime/agents/teammate-role-runtime.js +241 -0
- package/lib/packages/market-runtime/src/runtime/agents/teammate-role-tool.js +130 -0
- package/lib/{runtime → packages/market-runtime/src/runtime}/core/reconcile-scheduler.js +2 -2
- package/lib/packages/market-runtime/src/runtime/core/reconciler.js +457 -0
- package/lib/packages/market-runtime/src/runtime/host/command-name-allocator.js +168 -0
- package/lib/packages/market-runtime/src/runtime/host/extension-progress.js +120 -0
- package/lib/packages/market-runtime/src/runtime/host/extension-runtime.js +405 -0
- package/lib/packages/market-runtime/src/runtime/host/extension-session-state.js +839 -0
- package/lib/packages/market-runtime/src/runtime/host/extension-tool-gates.js +96 -0
- package/lib/{runtime → packages/market-runtime/src/runtime}/host/failure-detail.js +1 -1
- package/lib/{runtime → packages/market-runtime/src/runtime}/host/host-locale.js +2 -0
- package/lib/packages/market-runtime/src/runtime/host/menu-row-identities.js +38 -0
- package/lib/packages/market-runtime/src/runtime/host/resource-filter-service.js +81 -0
- package/lib/packages/market-runtime/src/runtime/host/scoped-contributors.js +304 -0
- package/lib/packages/market-runtime/src/runtime/host/surface-toggle-service.js +15 -0
- package/lib/packages/market-runtime/src/runtime/panels/user-commands.js +211 -0
- package/lib/{runtime → packages/market-runtime/src/runtime}/panels/user-panels.js +34 -14
- package/lib/packages/market-runtime/src/runtime/surfaces/commands-mounts.js +256 -0
- package/lib/packages/market-runtime/src/runtime/surfaces/extension-hooks.js +294 -0
- package/lib/packages/market-runtime/src/runtime/surfaces/hook-dry-run.js +122 -0
- package/lib/{runtime → packages/market-runtime/src/runtime}/surfaces/hooks-mounts.js +1 -1
- package/lib/{runtime → packages/market-runtime/src/runtime}/surfaces/project-runtime.js +23 -13
- package/lib/packages/market-runtime/src/runtime/surfaces/skills-provider.js +241 -0
- package/lib/packages/market-translation/src/application/state/translation-cache.js +122 -0
- package/lib/packages/market-translation/src/application/translation/chain.js +99 -0
- package/lib/packages/market-translation/src/application/translation/document.js +384 -0
- package/lib/packages/market-translation/src/application/translation/localizer.js +642 -0
- package/lib/packages/market-translation/src/application/translation/service.js +113 -0
- package/lib/packages/market-translation/src/application/translation/unit.js +19 -0
- package/lib/packages/market-translation/src/index.js +4 -0
- package/lib/packages/market-translation/src/runtime/host/llm-translator.js +278 -0
- package/lib/packages/market-translation/src/runtime/host/machine-translator.js +152 -0
- package/lib/packages/market-translation/src/runtime/host/text-masking.js +96 -0
- package/lib/packages/market-translation/src/runtime/host/translation-providers.js +116 -0
- package/lib/types/index.d.ts +2 -130
- package/lib/types/{application → packages/market-bundle/src/application}/catalog.d.ts +117 -22
- package/lib/types/packages/market-bundle/src/application/details.d.ts +24 -0
- package/lib/types/packages/market-bundle/src/application/extension-inventory.d.ts +45 -0
- package/lib/types/packages/market-bundle/src/application/extension-project.d.ts +26 -0
- package/lib/types/packages/market-bundle/src/application/resource-inventory.d.ts +42 -0
- package/lib/types/packages/market-bundle/src/application/server-config.d.ts +9 -0
- package/lib/types/packages/market-bundle/src/application/suite-queries.d.ts +84 -0
- package/lib/types/packages/market-bundle/src/index.d.ts +125 -0
- package/lib/types/{runtime/host → packages/market-bundle/src/platform}/settings-namespace.d.ts +44 -9
- package/lib/types/{application/mcp/mcp-backend.d.ts → packages/market-bundle/src/platform/settings-schema.d.ts} +13 -28
- package/lib/types/packages/market-bundle/src/routes-extension-presets.d.ts +15 -0
- package/lib/types/packages/market-bundle/src/routes-resources.d.ts +17 -0
- package/lib/types/packages/market-bundle/src/routes.d.ts +32 -0
- package/lib/types/packages/market-bundle/src/runtime-adapters.d.ts +42 -0
- package/lib/types/packages/market-bundle/src/session-extension.d.ts +62 -0
- package/lib/types/{application → packages/market-catalog/src/application}/catalog-context.d.ts +11 -3
- package/lib/types/{application → packages/market-catalog/src/application}/install-store.d.ts +1 -1
- package/lib/types/{application → packages/market-catalog/src/application}/regions.d.ts +1 -1
- package/lib/types/{application → packages/market-catalog/src/application}/snapshot-cache.d.ts +44 -2
- package/lib/types/{application → packages/market-catalog/src/application}/source-store.d.ts +12 -3
- package/lib/types/{application → packages/market-catalog/src/application}/state/state-store.d.ts +1 -1
- package/lib/types/packages/market-catalog/src/index.d.ts +22 -0
- package/lib/types/{catalog → packages/market-catalog/src/scanning}/archive.d.ts +1 -1
- package/lib/types/{catalog → packages/market-catalog/src/scanning}/codex-mcp.d.ts +1 -1
- package/lib/types/{catalog → packages/market-catalog/src/scanning}/component-files.d.ts +1 -1
- package/lib/types/{catalog → packages/market-catalog/src/scanning}/lsp-spec.d.ts +1 -1
- package/lib/types/{catalog → packages/market-catalog/src/scanning}/manifests.d.ts +3 -3
- package/lib/types/{catalog → packages/market-catalog/src/scanning}/native-project.d.ts +2 -2
- package/lib/types/{catalog → packages/market-catalog/src/scanning}/plugin-variables.d.ts +12 -1
- package/lib/types/{catalog → packages/market-catalog/src/scanning}/project-config.d.ts +2 -2
- package/lib/types/{catalog → packages/market-catalog/src/scanning}/project-hooks.d.ts +2 -2
- package/lib/types/{catalog → packages/market-catalog/src/scanning}/scan-pipeline.d.ts +1 -1
- package/lib/types/{catalog → packages/market-catalog/src/scanning}/scan-resolvers.d.ts +3 -3
- package/lib/types/{catalog → packages/market-catalog/src/scanning}/source-catalog.d.ts +1 -1
- package/lib/types/{catalog → packages/market-catalog/src/scanning}/suite-components.d.ts +1 -1
- package/lib/types/{catalog → packages/market-catalog/src/scanning}/suite-scanner.d.ts +1 -1
- package/lib/types/{catalog → packages/market-catalog/src/scanning}/surfaces.d.ts +1 -1
- package/lib/types/{catalog → packages/market-catalog/src/scanning}/validate.d.ts +1 -1
- package/lib/types/packages/market-contracts/src/contracts/extension-presets.d.ts +237 -0
- package/lib/types/{contracts → packages/market-contracts/src/contracts}/market.d.ts +87 -16
- package/lib/types/packages/market-contracts/src/contracts/mcp-overrides.d.ts +39 -0
- package/lib/types/{contracts → packages/market-contracts/src/contracts}/mcp-status.d.ts +9 -0
- package/lib/types/packages/market-contracts/src/contracts/resource-window.d.ts +70 -0
- package/lib/types/packages/market-contracts/src/contracts/settings.d.ts +121 -0
- package/lib/types/packages/market-contracts/src/contracts/surface-toggles.d.ts +28 -0
- package/lib/types/packages/market-contracts/src/contracts/translation.d.ts +81 -0
- package/lib/types/{runtime → packages/market-contracts/src}/host/plugin-message-source.d.ts +1 -1
- package/lib/types/packages/market-contracts/src/index.d.ts +5 -0
- package/lib/types/{model → packages/market-contracts/src/model}/layouts.d.ts +7 -0
- package/lib/types/{model → packages/market-contracts/src/model}/types.d.ts +2 -2
- package/lib/types/packages/market-contracts/src/ports/ports.d.ts +183 -0
- package/lib/types/{application → packages/market-contracts/src/ports}/queries.d.ts +27 -6
- package/lib/types/{application/mcp/mcp-redaction.d.ts → packages/market-contracts/src/redaction.d.ts} +2 -0
- package/lib/types/{application → packages/market-lsp/src/application}/lsp/lsp-direct-config.d.ts +1 -1
- package/lib/types/{application → packages/market-lsp/src/application}/lsp/lsp-status.d.ts +21 -5
- package/lib/types/packages/market-lsp/src/application/lsp/validation.d.ts +8 -0
- package/lib/types/{application → packages/market-lsp/src/application}/lsp-service.d.ts +19 -6
- package/lib/types/packages/market-lsp/src/index.d.ts +8 -0
- package/lib/types/{runtime → packages/market-lsp/src/runtime}/lsp/lsp-mounts.d.ts +26 -6
- package/lib/types/packages/market-mcp/src/application/mcp/mcp-backend.d.ts +28 -0
- package/lib/types/{application → packages/market-mcp/src/application}/mcp/mcp-bridge-config.d.ts +1 -1
- package/lib/types/{application → packages/market-mcp/src/application}/mcp/mcp-config.d.ts +2 -2
- package/lib/types/{application → packages/market-mcp/src/application}/mcp/mcp-direct-config.d.ts +6 -1
- package/lib/types/{application → packages/market-mcp/src/application}/mcp/mcp-overrides.d.ts +4 -38
- package/lib/types/packages/market-mcp/src/application/mcp/mcp-status.d.ts +40 -0
- package/lib/types/{application/server-config.d.ts → packages/market-mcp/src/application/mcp/validation.d.ts} +2 -10
- package/lib/types/{application → packages/market-mcp/src/application}/mcp-service.d.ts +22 -16
- package/lib/types/packages/market-mcp/src/index.d.ts +12 -0
- package/lib/types/packages/market-mcp/src/runtime/mcp/bridge/tool-ownership.d.ts +14 -0
- package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/mcp-auth-record.d.ts +4 -0
- package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/mcp-mounts.d.ts +19 -3
- package/lib/types/packages/market-runtime/src/adapter-contracts.d.ts +89 -0
- package/lib/types/{application → packages/market-runtime/src/application}/agent-roles.d.ts +2 -0
- package/lib/types/packages/market-runtime/src/application/command-resources.d.ts +26 -0
- package/lib/types/packages/market-runtime/src/application/extension-authorization.d.ts +12 -0
- package/lib/types/packages/market-runtime/src/application/extension-hook-selection.d.ts +23 -0
- package/lib/types/packages/market-runtime/src/application/extension-suite-declarations.d.ts +10 -0
- package/lib/types/packages/market-runtime/src/application/extension-suite-selection.d.ts +30 -0
- package/lib/types/packages/market-runtime/src/application/fs-probe.d.ts +12 -0
- package/lib/types/packages/market-runtime/src/application/panel-resources.d.ts +100 -0
- package/lib/types/{application → packages/market-runtime/src/application}/panels/user-hooks.d.ts +1 -1
- package/lib/types/packages/market-runtime/src/application/project-agent-roles.d.ts +10 -0
- package/lib/types/packages/market-runtime/src/application/state/extension-presets.d.ts +24 -0
- package/lib/types/packages/market-runtime/src/application/state/resource-favorites.d.ts +9 -0
- package/lib/types/packages/market-runtime/src/application/state/resource-filters.d.ts +2 -0
- package/lib/types/packages/market-runtime/src/application/state/surface-toggles.d.ts +6 -0
- package/lib/types/packages/market-runtime/src/application/state/workspace-policy.d.ts +19 -0
- package/lib/types/packages/market-runtime/src/catalog-port.d.ts +30 -0
- package/lib/types/packages/market-runtime/src/extension-service.d.ts +14 -0
- package/lib/types/packages/market-runtime/src/index.d.ts +41 -0
- package/lib/types/{runtime → packages/market-runtime/src/runtime}/agents/agent-role-router.d.ts +66 -31
- package/lib/types/packages/market-runtime/src/runtime/agents/agent-teams-seat.d.ts +41 -0
- package/lib/types/{runtime → packages/market-runtime/src/runtime}/agents/subagent-catalog.d.ts +34 -2
- package/lib/types/packages/market-runtime/src/runtime/agents/team-coordination.d.ts +8 -0
- package/lib/types/packages/market-runtime/src/runtime/agents/teammate-role-runtime.d.ts +74 -0
- package/lib/types/packages/market-runtime/src/runtime/agents/teammate-role-tool.d.ts +6 -0
- package/lib/types/{runtime → packages/market-runtime/src/runtime}/core/reconcile-scheduler.d.ts +5 -2
- package/lib/types/packages/market-runtime/src/runtime/core/reconciler.d.ts +141 -0
- package/lib/types/packages/market-runtime/src/runtime/host/command-name-allocator.d.ts +132 -0
- package/lib/types/packages/market-runtime/src/runtime/host/extension-progress.d.ts +91 -0
- package/lib/types/packages/market-runtime/src/runtime/host/extension-runtime.d.ts +77 -0
- package/lib/types/packages/market-runtime/src/runtime/host/extension-session-state.d.ts +242 -0
- package/lib/types/packages/market-runtime/src/runtime/host/extension-tool-gates.d.ts +38 -0
- package/lib/types/{runtime → packages/market-runtime/src/runtime}/host/host-locale.d.ts +1 -1
- package/lib/types/packages/market-runtime/src/runtime/host/menu-row-identities.d.ts +50 -0
- package/lib/types/{runtime → packages/market-runtime/src/runtime}/host/model-catalog.d.ts +1 -1
- package/lib/types/packages/market-runtime/src/runtime/host/resource-filter-service.d.ts +34 -0
- package/lib/types/packages/market-runtime/src/runtime/host/scoped-contributors.d.ts +58 -0
- package/lib/types/packages/market-runtime/src/runtime/host/surface-toggle-service.d.ts +10 -0
- package/lib/types/packages/market-runtime/src/runtime/panels/user-commands.d.ts +74 -0
- package/lib/types/{runtime → packages/market-runtime/src/runtime}/panels/user-panels.d.ts +7 -1
- package/lib/types/packages/market-runtime/src/runtime/surfaces/commands-mounts.d.ts +81 -0
- package/lib/types/packages/market-runtime/src/runtime/surfaces/extension-hooks.d.ts +59 -0
- package/lib/types/packages/market-runtime/src/runtime/surfaces/hook-dry-run.d.ts +91 -0
- package/lib/types/{runtime → packages/market-runtime/src/runtime}/surfaces/hooks-mounts.d.ts +1 -1
- package/lib/types/{runtime → packages/market-runtime/src/runtime}/surfaces/project-runtime.d.ts +8 -5
- package/lib/types/packages/market-runtime/src/runtime/surfaces/skills-provider.d.ts +71 -0
- package/lib/types/packages/market-translation/src/application/state/translation-cache.d.ts +56 -0
- package/lib/types/packages/market-translation/src/application/translation/chain.d.ts +47 -0
- package/lib/types/packages/market-translation/src/application/translation/document.d.ts +54 -0
- package/lib/types/packages/market-translation/src/application/translation/localizer.d.ts +325 -0
- package/lib/types/packages/market-translation/src/application/translation/service.d.ts +89 -0
- package/lib/types/packages/market-translation/src/application/translation/unit.d.ts +35 -0
- package/lib/types/packages/market-translation/src/index.d.ts +4 -0
- package/lib/types/packages/market-translation/src/runtime/host/llm-translator.d.ts +30 -0
- package/lib/types/packages/market-translation/src/runtime/host/machine-translator.d.ts +52 -0
- package/lib/types/packages/market-translation/src/runtime/host/text-masking.d.ts +42 -0
- package/lib/types/packages/market-translation/src/runtime/host/translation-providers.d.ts +42 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +47 -10
- package/schemas/README.md +4 -4
- package/schemas/agent-plugins/spec.md +2 -2
- package/schemas/com.deepseek.harness/spec.md +1 -1
- package/schemas/skill-collection/spec.md +10 -2
- package/lib/application/panel-resources.js +0 -161
- package/lib/application/server-config.js +0 -109
- package/lib/contracts/settings.js +0 -63
- package/lib/runtime/core/reconciler.js +0 -100
- package/lib/runtime/panels/user-commands.js +0 -105
- package/lib/runtime/surfaces/commands-mounts.js +0 -186
- package/lib/runtime/surfaces/skills-provider.js +0 -160
- package/lib/types/application/details.d.ts +0 -7
- package/lib/types/application/mcp/mcp-status.d.ts +0 -24
- package/lib/types/application/panel-resources.d.ts +0 -28
- package/lib/types/application/ports.d.ts +0 -86
- package/lib/types/application/project-agent-roles.d.ts +0 -3
- package/lib/types/contracts/settings.d.ts +0 -59
- package/lib/types/routes.d.ts +0 -16
- package/lib/types/runtime/core/reconciler.d.ts +0 -58
- package/lib/types/runtime/panels/user-commands.d.ts +0 -27
- package/lib/types/runtime/surfaces/commands-mounts.d.ts +0 -48
- package/lib/types/runtime/surfaces/skills-provider.d.ts +0 -23
- /package/lib/{application → packages/market-catalog/src/application}/deadline.js +0 -0
- /package/lib/{application → packages/market-catalog/src/application}/json-file.js +0 -0
- /package/lib/{application → packages/market-catalog/src/application}/regions.js +0 -0
- /package/lib/{catalog → packages/market-catalog/src/scanning}/fs-probes.js +0 -0
- /package/lib/{catalog → packages/market-catalog/src/scanning}/git.js +0 -0
- /package/lib/{catalog → packages/market-catalog/src/scanning}/lsp-spec.js +0 -0
- /package/lib/{catalog → packages/market-catalog/src/scanning}/project-config.js +0 -0
- /package/lib/{catalog → packages/market-catalog/src/scanning}/project-hooks.js +0 -0
- /package/lib/{catalog → packages/market-catalog/src/scanning}/scan-pipeline.js +0 -0
- /package/lib/{catalog → packages/market-catalog/src/scanning}/source-catalog.js +0 -0
- /package/lib/{catalog → packages/market-catalog/src/scanning}/suite-components.js +0 -0
- /package/lib/{catalog → packages/market-catalog/src/scanning}/suite-scanner.js +0 -0
- /package/lib/{catalog → packages/market-catalog/src/scanning}/surfaces.js +0 -0
- /package/lib/{contracts → packages/market-contracts/src/contracts}/lsp-status.js +0 -0
- /package/lib/{contracts → packages/market-contracts/src/contracts}/lsp.js +0 -0
- /package/lib/{contracts → packages/market-contracts/src/contracts}/mcp-status.js +0 -0
- /package/lib/{contracts → packages/market-contracts/src/contracts}/mcp.js +0 -0
- /package/lib/{runtime → packages/market-contracts/src}/host/plugin-message-source.js +0 -0
- /package/lib/{model → packages/market-contracts/src/model}/command-names.js +0 -0
- /package/lib/{model → packages/market-contracts/src/model}/preset-source.js +0 -0
- /package/lib/{model → packages/market-contracts/src/model}/types.js +0 -0
- /package/lib/{application → packages/market-contracts/src/ports}/queries.js +0 -0
- /package/lib/{application → packages/market-mcp/src/application}/mcp/mcp-bridge-config.js +0 -0
- /package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/host-contract.js +0 -0
- /package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/host-seams.js +0 -0
- /package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/plugin-identity.js +0 -0
- /package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/projection.js +0 -0
- /package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/transport.js +0 -0
- /package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/mcp-credentials.js +0 -0
- /package/lib/{application → packages/market-runtime/src/application}/agent-roles.js +0 -0
- /package/lib/{runtime → packages/market-runtime/src/runtime}/agents/agent-role-names.js +0 -0
- /package/lib/{runtime → packages/market-runtime/src/runtime}/core/context.js +0 -0
- /package/lib/{runtime → packages/market-runtime/src/runtime}/core/mount-lifecycle.js +0 -0
- /package/lib/{runtime → packages/market-runtime/src/runtime}/core/source-auto-update.js +0 -0
- /package/lib/{runtime → packages/market-runtime/src/runtime}/core/timer-seat.js +0 -0
- /package/lib/{runtime → packages/market-runtime/src/runtime}/host/model-catalog.js +0 -0
- /package/lib/{runtime → packages/market-runtime/src/runtime}/host/shell-path.js +0 -0
- /package/lib/{runtime → packages/market-runtime/src/runtime}/host/tool-registry-observer.js +0 -0
- /package/lib/{runtime → packages/market-runtime/src/runtime}/surfaces/dynamic-context.js +0 -0
- /package/lib/types/{runtime/host → packages/market-bundle/src/platform}/feedback-tool.d.ts +0 -0
- /package/lib/types/{application → packages/market-catalog/src/application}/deadline.d.ts +0 -0
- /package/lib/types/{application → packages/market-catalog/src/application}/json-file.d.ts +0 -0
- /package/lib/types/{application → packages/market-catalog/src/application}/state/storage-migration.d.ts +0 -0
- /package/lib/types/{catalog → packages/market-catalog/src/scanning}/fs-probes.d.ts +0 -0
- /package/lib/types/{catalog → packages/market-catalog/src/scanning}/git.d.ts +0 -0
- /package/lib/types/{catalog → packages/market-catalog/src/scanning}/paths.d.ts +0 -0
- /package/lib/types/{catalog → packages/market-catalog/src/scanning}/skills-parse.d.ts +0 -0
- /package/lib/types/{contracts → packages/market-contracts/src/contracts}/lsp-status.d.ts +0 -0
- /package/lib/types/{contracts → packages/market-contracts/src/contracts}/lsp.d.ts +0 -0
- /package/lib/types/{contracts → packages/market-contracts/src/contracts}/mcp.d.ts +0 -0
- /package/lib/types/{model → packages/market-contracts/src/model}/command-names.d.ts +0 -0
- /package/lib/types/{model → packages/market-contracts/src/model}/preset-source.d.ts +0 -0
- /package/lib/types/{application → packages/market-lsp/src/application}/lsp/lsp-server-state.d.ts +0 -0
- /package/lib/types/{application → packages/market-lsp/src/application}/lsp/profile-seam.d.ts +0 -0
- /package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/bridge.d.ts +0 -0
- /package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/connection.d.ts +0 -0
- /package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/host-contract.d.ts +0 -0
- /package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/host-seams.d.ts +0 -0
- /package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/oauth.d.ts +0 -0
- /package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/plugin-identity.d.ts +0 -0
- /package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/projection.d.ts +0 -0
- /package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/tools.d.ts +0 -0
- /package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/transport.d.ts +0 -0
- /package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/mcp-credentials.d.ts +0 -0
- /package/lib/types/{application → packages/market-runtime/src/application}/panels/user-store.d.ts +0 -0
- /package/lib/types/{runtime → packages/market-runtime/src/runtime}/agents/agent-role-names.d.ts +0 -0
- /package/lib/types/{runtime → packages/market-runtime/src/runtime}/core/context.d.ts +0 -0
- /package/lib/types/{runtime → packages/market-runtime/src/runtime}/core/mount-lifecycle.d.ts +0 -0
- /package/lib/types/{runtime → packages/market-runtime/src/runtime}/core/source-auto-update.d.ts +0 -0
- /package/lib/types/{runtime → packages/market-runtime/src/runtime}/core/timer-seat.d.ts +0 -0
- /package/lib/types/{runtime → packages/market-runtime/src/runtime}/host/failure-detail.d.ts +0 -0
- /package/lib/types/{runtime → packages/market-runtime/src/runtime}/host/shell-path.d.ts +0 -0
- /package/lib/types/{runtime → packages/market-runtime/src/runtime}/host/tool-registry-observer.d.ts +0 -0
- /package/lib/types/{runtime → packages/market-runtime/src/runtime}/surfaces/dynamic-context.d.ts +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { resolveMarketSettings } from '
|
|
1
|
+
import { resolveMarketSettings } from '../../../market-contracts/src/contracts/settings.js';
|
|
2
2
|
import { FEEDBACK_TOOL_NAME, mountFeedbackTool } from './feedback-tool.js';
|
|
3
3
|
export class MarketSettingsNamespace {
|
|
4
4
|
ctx;
|
|
5
|
-
refs;
|
|
6
5
|
dataRoot;
|
|
7
6
|
locale;
|
|
8
7
|
host;
|
|
8
|
+
localePreference;
|
|
9
|
+
refs;
|
|
9
10
|
watchers = [];
|
|
10
11
|
feedbackDisposer;
|
|
11
12
|
/**
|
|
@@ -15,12 +16,25 @@ export class MarketSettingsNamespace {
|
|
|
15
16
|
* switch, or skipped because the host has no tools registry to register on.
|
|
16
17
|
*/
|
|
17
18
|
feedbackMountState;
|
|
18
|
-
constructor(ctx, refs, dataRoot, locale, host
|
|
19
|
+
constructor(ctx, refs, dataRoot, locale, host,
|
|
20
|
+
/**
|
|
21
|
+
* The host interface language, read per call. It is a reader rather than a
|
|
22
|
+
* captured string because a language switch must move the translation
|
|
23
|
+
* default without rebuilding this namespace.
|
|
24
|
+
*/
|
|
25
|
+
localePreference) {
|
|
19
26
|
this.ctx = ctx;
|
|
20
|
-
this.refs = refs;
|
|
21
27
|
this.dataRoot = dataRoot;
|
|
22
28
|
this.locale = locale;
|
|
23
29
|
this.host = host;
|
|
30
|
+
this.localePreference = localePreference;
|
|
31
|
+
// A caller may hand in a partial ref set (a test, or a config written
|
|
32
|
+
// before this field existed); an absent switch reads as its default.
|
|
33
|
+
this.refs = {
|
|
34
|
+
...refs,
|
|
35
|
+
translationEnabled: refs.translationEnabled ?? { get: () => undefined },
|
|
36
|
+
agentPresetsEnabled: refs.agentPresetsEnabled ?? { get: () => undefined }
|
|
37
|
+
};
|
|
24
38
|
}
|
|
25
39
|
/** Subscribe the runtime reactions to live settings updates. */
|
|
26
40
|
mount() {
|
|
@@ -28,17 +42,23 @@ export class MarketSettingsNamespace {
|
|
|
28
42
|
this.syncAutoUpdateSources();
|
|
29
43
|
this.syncFeedbackTool();
|
|
30
44
|
let previousBackend = this.settings().mcpEnhanced;
|
|
45
|
+
let previousTranslation = this.settings().translationEnabled;
|
|
31
46
|
const watcher = this.ctx.on('loader/volatile-update', () => {
|
|
32
47
|
const backend = this.settings().mcpEnhanced;
|
|
33
48
|
if (backend !== previousBackend) {
|
|
34
49
|
previousBackend = backend;
|
|
35
50
|
this.host.refreshMcpMounts();
|
|
36
51
|
}
|
|
52
|
+
previousTranslation = this.syncTranslationProviders(previousTranslation);
|
|
37
53
|
this.syncProjectLayouts();
|
|
38
54
|
this.syncAutoUpdateSources();
|
|
39
55
|
this.syncFeedbackTool();
|
|
40
56
|
});
|
|
41
57
|
this.watchers.push(watcher);
|
|
58
|
+
// A locale edit can change the default without changing this plugin's refs.
|
|
59
|
+
this.watchers.push(this.ctx.on('settings/document-updated', () => {
|
|
60
|
+
previousTranslation = this.syncTranslationProviders(previousTranslation);
|
|
61
|
+
}));
|
|
42
62
|
}
|
|
43
63
|
/** Release every watcher and unmount the feedback tool. */
|
|
44
64
|
dispose() {
|
|
@@ -48,7 +68,8 @@ export class MarketSettingsNamespace {
|
|
|
48
68
|
this.feedbackDisposer = undefined;
|
|
49
69
|
}
|
|
50
70
|
/**
|
|
51
|
-
* The resolved settings, from the volatile references the host updates in
|
|
71
|
+
* The resolved settings, from the volatile references the host updates in
|
|
72
|
+
* place and the interface language they resolve over.
|
|
52
73
|
*/
|
|
53
74
|
settings() {
|
|
54
75
|
return resolveMarketSettings({
|
|
@@ -56,8 +77,10 @@ export class MarketSettingsNamespace {
|
|
|
56
77
|
scanProjectLayouts: this.refs.scanProjectLayouts.get(),
|
|
57
78
|
downloadRegion: this.refs.downloadRegion.get(),
|
|
58
79
|
feedbackEnabled: this.refs.feedbackEnabled.get(),
|
|
59
|
-
autoUpdateSources: this.refs.autoUpdateSources.get()
|
|
60
|
-
|
|
80
|
+
autoUpdateSources: this.refs.autoUpdateSources.get(),
|
|
81
|
+
translationEnabled: this.refs.translationEnabled.get(),
|
|
82
|
+
agentPresetsEnabled: this.refs.agentPresetsEnabled.get()
|
|
83
|
+
}, this.localePreference());
|
|
61
84
|
}
|
|
62
85
|
/** The persisted MCP backend choice; the built-in client until the host applies a value. */
|
|
63
86
|
async backend() {
|
|
@@ -75,6 +98,31 @@ export class MarketSettingsNamespace {
|
|
|
75
98
|
async downloadRegion() {
|
|
76
99
|
return this.settings().downloadRegion;
|
|
77
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Read the live translation switch: the stored preference while the user has
|
|
103
|
+
* one, the interface language's default otherwise.
|
|
104
|
+
*/
|
|
105
|
+
translationEnabled() {
|
|
106
|
+
return this.settings().translationEnabled;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Notify the translation owner on either effective preference edge. Unrelated
|
|
110
|
+
* writes do not reset failures or disturb cached results.
|
|
111
|
+
* @param previous - whether translation was on at the last look.
|
|
112
|
+
* @returns whether it is on now, for the next comparison.
|
|
113
|
+
*/
|
|
114
|
+
syncTranslationProviders(previous) {
|
|
115
|
+
const enabled = this.settings().translationEnabled;
|
|
116
|
+
if (enabled !== previous) {
|
|
117
|
+
try {
|
|
118
|
+
this.host.syncTranslationEnabled();
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
this.ctx.logger?.error?.(`[dsh-agent-plugins-market] translation state synchronization failed: ${String(error)}`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return enabled;
|
|
125
|
+
}
|
|
78
126
|
/** Apply the background source-update switch. */
|
|
79
127
|
syncAutoUpdateSources() {
|
|
80
128
|
try {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import z from '@deepseek-ai/schemastery';
|
|
2
|
+
import { MARKET_SETTINGS_DEFAULTS } from '../../../market-contracts/src/contracts/settings.js';
|
|
3
|
+
/**
|
|
4
|
+
* Schema of the market settings namespace: the switches this plugin's config
|
|
5
|
+
* card serves, with the defaults declared to the host. The values themselves
|
|
6
|
+
* belong to {@link MARKET_SETTINGS_DEFAULTS}; this schema states them, it does
|
|
7
|
+
* not own them.
|
|
8
|
+
*
|
|
9
|
+
* `translationEnabled` deliberately declares no default. Its default follows
|
|
10
|
+
* the interface language, and a declared default would be materialized into the
|
|
11
|
+
* live config reference, where "the user never set this" and "the user turned it
|
|
12
|
+
* off" would both read `false` — the distinction the derivation rests on. With
|
|
13
|
+
* the field absent, the reference answers `undefined` until the user writes it,
|
|
14
|
+
* and {@link resolveMarketSettings} fills the language's own default in.
|
|
15
|
+
*/
|
|
16
|
+
export const MarketSettingsFields = {
|
|
17
|
+
mcpEnhanced: z.boolean().default(MARKET_SETTINGS_DEFAULTS.mcpEnhanced),
|
|
18
|
+
scanProjectLayouts: z.boolean().default(MARKET_SETTINGS_DEFAULTS.scanProjectLayouts),
|
|
19
|
+
downloadRegion: z.union([z.const('auto'), z.const('global'), z.const('china')]).default(MARKET_SETTINGS_DEFAULTS.downloadRegion),
|
|
20
|
+
feedbackEnabled: z.boolean().default(MARKET_SETTINGS_DEFAULTS.feedbackEnabled),
|
|
21
|
+
autoUpdateSources: z.boolean().default(MARKET_SETTINGS_DEFAULTS.autoUpdateSources),
|
|
22
|
+
translationEnabled: z.boolean(),
|
|
23
|
+
agentPresetsEnabled: z.boolean().default(MARKET_SETTINGS_DEFAULTS.agentPresetsEnabled)
|
|
24
|
+
};
|
|
25
|
+
export const MarketSettingsSchema = z.object(MarketSettingsFields);
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { EXTENSION_ROUTES, parseExtensionIds, parseExtensionName } from '../../market-contracts/src/contracts/extension-presets.js';
|
|
2
|
+
function id(value) {
|
|
3
|
+
if (typeof value !== 'string' || value.length === 0 || value.length > 1024)
|
|
4
|
+
throw new Error('invalid identifier');
|
|
5
|
+
return value;
|
|
6
|
+
}
|
|
7
|
+
function revision(value) {
|
|
8
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0)
|
|
9
|
+
throw new Error('invalid revision');
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
async function body(request) {
|
|
13
|
+
const chunks = [];
|
|
14
|
+
let length = 0;
|
|
15
|
+
for await (const chunk of request) {
|
|
16
|
+
const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
17
|
+
length += bytes.length;
|
|
18
|
+
if (length > 64 * 1024)
|
|
19
|
+
throw new Error('request too large');
|
|
20
|
+
chunks.push(bytes);
|
|
21
|
+
}
|
|
22
|
+
const value = JSON.parse(Buffer.concat(chunks).toString('utf8'));
|
|
23
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
24
|
+
throw new Error('invalid request body');
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
function json(response, status, value) {
|
|
28
|
+
const text = JSON.stringify(value);
|
|
29
|
+
response.writeHead(status, { 'content-type': 'application/json; charset=utf-8', 'content-length': Buffer.byteLength(text), 'cache-control': 'no-store' });
|
|
30
|
+
response.end(text);
|
|
31
|
+
}
|
|
32
|
+
function sameOrigin(request) {
|
|
33
|
+
const origin = request.headers.origin;
|
|
34
|
+
if (origin === undefined)
|
|
35
|
+
return true;
|
|
36
|
+
try {
|
|
37
|
+
return new URL(origin).host === request.headers.host;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** Mount only after session initialization has an enforcement gate. */
|
|
44
|
+
export function mountExtensionPresetRoutes(host, service) {
|
|
45
|
+
const disposers = [];
|
|
46
|
+
const add = (path, method, action) => {
|
|
47
|
+
disposers.push(host.webServer.register({
|
|
48
|
+
kind: 'exact',
|
|
49
|
+
path,
|
|
50
|
+
async handler(request, response) {
|
|
51
|
+
if (request.method !== method) {
|
|
52
|
+
json(response, 405, { ok: false, code: 'method-not-allowed', error: 'method not allowed' });
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (!sameOrigin(request)) {
|
|
56
|
+
json(response, 403, { ok: false, code: 'cross-origin', error: 'cross-origin request rejected' });
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const input = method === 'GET' ? Object.fromEntries(new URL(request.url ?? '/', 'http://localhost').searchParams) : await body(request);
|
|
61
|
+
const sessionId = await action(input);
|
|
62
|
+
const window = await service.window(sessionId);
|
|
63
|
+
json(response, 200, method === 'GET' ? window : { ok: true, window });
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
const code = typeof error === 'object' && error !== null && 'code' in error && typeof error.code === 'string' ? error.code : 'invalid-extension-request';
|
|
67
|
+
const status = code.includes('conflict') || code.includes('busy') || code.includes('not-ready') ? 409 : code.includes('not-found') ? 404 : 400;
|
|
68
|
+
json(response, status, { ok: false, code, error: error instanceof Error ? error.message : String(error) });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}));
|
|
72
|
+
};
|
|
73
|
+
add(EXTENSION_ROUTES.window, 'GET', input => Promise.resolve(id(input.sessionId)));
|
|
74
|
+
// The Hooks overview is sessionless: the route answers the read directly
|
|
75
|
+
// instead of resolving a live Agent, because hook declarations belong to
|
|
76
|
+
// the user Agent layout root, not to any one workspace.
|
|
77
|
+
disposers.push(host.webServer.register({
|
|
78
|
+
kind: 'exact',
|
|
79
|
+
path: EXTENSION_ROUTES.hooksOverview,
|
|
80
|
+
async handler(request, response) {
|
|
81
|
+
if (request.method !== 'GET') {
|
|
82
|
+
json(response, 405, { ok: false, code: 'method-not-allowed', error: 'method not allowed' });
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (!sameOrigin(request)) {
|
|
86
|
+
json(response, 403, { ok: false, code: 'cross-origin', error: 'cross-origin request rejected' });
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
if (!service.hooksOverview)
|
|
91
|
+
throw Object.assign(new Error('extension hooks overview is unavailable'), { code: 'extension-hooks-unavailable' });
|
|
92
|
+
json(response, 200, await service.hooksOverview());
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
const code = typeof error === 'object' && error !== null && 'code' in error && typeof error.code === 'string' ? error.code : 'invalid-extension-request';
|
|
96
|
+
json(response, code.includes('not-found') ? 404 : 400, { ok: false, code, error: error instanceof Error ? error.message : String(error) });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}));
|
|
100
|
+
// The hook detail modal's dry run. The body names the declaration only: the
|
|
101
|
+
// command is resolved from the scanned catalog, so a caller can never choose
|
|
102
|
+
// what runs, and the working directory is always the server's home directory.
|
|
103
|
+
disposers.push(host.webServer.register({
|
|
104
|
+
kind: 'exact',
|
|
105
|
+
path: EXTENSION_ROUTES.hookRun,
|
|
106
|
+
async handler(request, response) {
|
|
107
|
+
if (request.method !== 'POST') {
|
|
108
|
+
json(response, 405, { ok: false, code: 'method-not-allowed', error: 'method not allowed' });
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (!sameOrigin(request)) {
|
|
112
|
+
json(response, 403, { ok: false, code: 'cross-origin', error: 'cross-origin request rejected' });
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
const hookRun = service.hookRun?.bind(service);
|
|
117
|
+
if (hookRun === undefined)
|
|
118
|
+
throw Object.assign(new Error('extension hook dry run is unavailable'), { code: 'extension-hook-run-unavailable' });
|
|
119
|
+
const input = await body(request);
|
|
120
|
+
const rawIndex = input.hookIndex;
|
|
121
|
+
if (rawIndex !== undefined && (typeof rawIndex !== 'number' || !Number.isSafeInteger(rawIndex) || rawIndex < 0))
|
|
122
|
+
throw new Error('invalid hook index');
|
|
123
|
+
const hookIndex = rawIndex;
|
|
124
|
+
const sessionId = input.sessionId === undefined ? undefined : id(input.sessionId);
|
|
125
|
+
json(response, 200, await hookRun({
|
|
126
|
+
sourceId: id(input.sourceId),
|
|
127
|
+
suiteId: id(input.suiteId),
|
|
128
|
+
event: id(input.event),
|
|
129
|
+
...(hookIndex === undefined ? {} : { hookIndex }),
|
|
130
|
+
...(sessionId === undefined ? {} : { sessionId })
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
const code = typeof error === 'object' && error !== null && 'code' in error && typeof error.code === 'string' ? error.code : 'invalid-extension-request';
|
|
135
|
+
json(response, code.includes('not-found') ? 404 : 400, { ok: false, code, error: error instanceof Error ? error.message : String(error) });
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}));
|
|
139
|
+
const mutate = (path, operation) => {
|
|
140
|
+
add(path, 'POST', async (input) => {
|
|
141
|
+
const session = id(input.sessionId);
|
|
142
|
+
await operation(session, revision(input.expectedRevision), input);
|
|
143
|
+
return session;
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
const preset = (input) => ({ name: parseExtensionName(input.name), enabledIds: parseExtensionIds(input.enabledIds) });
|
|
147
|
+
mutate(EXTENSION_ROUTES.create, (session, rev, input) => service.create(session, rev, preset(input)));
|
|
148
|
+
mutate(EXTENSION_ROUTES.update, (session, rev, input) => service.update(session, rev, id(input.id), preset(input)));
|
|
149
|
+
mutate(EXTENSION_ROUTES.delete, (session, rev, input) => service.delete(session, rev, id(input.id)));
|
|
150
|
+
mutate(EXTENSION_ROUTES.default, (session, rev, input) => service.setDefault(session, rev, input.id === null ? null : id(input.id)));
|
|
151
|
+
mutate(EXTENSION_ROUTES.select, (session, rev, input) => service.select(session, rev, input.presetId === null ? null : id(input.presetId)));
|
|
152
|
+
mutate(EXTENSION_ROUTES.recover, async (session, rev) => {
|
|
153
|
+
if (!service.recover)
|
|
154
|
+
throw new Error('extension recovery is unavailable');
|
|
155
|
+
await service.recover(session, rev);
|
|
156
|
+
});
|
|
157
|
+
return () => {
|
|
158
|
+
for (const dispose of disposers)
|
|
159
|
+
dispose();
|
|
160
|
+
};
|
|
161
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { RESOURCE_ROUTES, resolveFavoriteInput } from '../../market-contracts/src/contracts/resource-window.js';
|
|
2
|
+
import { SURFACE_TOGGLE_KEYS } from '../../market-contracts/src/contracts/surface-toggles.js';
|
|
3
|
+
import { buildResourceWindow } from './application/resource-inventory.js';
|
|
4
|
+
const MAX_BODY_BYTES = 64 * 1024;
|
|
5
|
+
/** Mount the resource-window routes; returns the disposer releasing them all. */
|
|
6
|
+
export function mountResourceRoutes(hostCtx, deps) {
|
|
7
|
+
const host = hostCtx;
|
|
8
|
+
const disposers = [];
|
|
9
|
+
const get = (path, handler) => {
|
|
10
|
+
disposers.push(host.webServer.register({ kind: 'exact', path, handler }));
|
|
11
|
+
};
|
|
12
|
+
const post = (path, handler) => {
|
|
13
|
+
disposers.push(host.webServer.register({
|
|
14
|
+
kind: 'exact',
|
|
15
|
+
path,
|
|
16
|
+
handler: (request, response) => {
|
|
17
|
+
if (!sameOrigin(request)) {
|
|
18
|
+
sendJson(response, 403, { ok: false, error: 'cross-origin request rejected' });
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
void (async () => {
|
|
22
|
+
const body = await readJsonBody(request);
|
|
23
|
+
if (body === undefined) {
|
|
24
|
+
sendJson(response, 400, { ok: false, error: 'invalid JSON body' });
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const value = await handler(body, request);
|
|
29
|
+
sendJson(response, 200, { ok: true, ...value });
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
sendJson(response, 400, { ok: false, error: error instanceof Error ? error.message : String(error) });
|
|
33
|
+
}
|
|
34
|
+
})();
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
37
|
+
};
|
|
38
|
+
get(RESOURCE_ROUTES.inventory, async (_request, response) => {
|
|
39
|
+
sendJson(response, 200, await buildResourceWindow(deps));
|
|
40
|
+
});
|
|
41
|
+
post(RESOURCE_ROUTES.setEntry, async (body) => {
|
|
42
|
+
const face = body.face;
|
|
43
|
+
if (typeof face !== 'string' || !SURFACE_TOGGLE_KEYS.includes(face))
|
|
44
|
+
throw new Error('invalid resource face');
|
|
45
|
+
if (typeof body.entryId !== 'string' || body.entryId === '')
|
|
46
|
+
throw new Error('missing entry id');
|
|
47
|
+
if (typeof body.enabled !== 'boolean')
|
|
48
|
+
throw new Error('enabled must be a boolean');
|
|
49
|
+
await deps.setEntry(face, body.entryId, body.enabled);
|
|
50
|
+
return { window: await buildResourceWindow(deps) };
|
|
51
|
+
});
|
|
52
|
+
post(RESOURCE_ROUTES.applyFavorite, async (body) => {
|
|
53
|
+
if (typeof body.id !== 'string' || body.id === '')
|
|
54
|
+
throw new Error('missing favorite id');
|
|
55
|
+
await deps.applyFavorite(body.id);
|
|
56
|
+
return { window: await buildResourceWindow(deps) };
|
|
57
|
+
});
|
|
58
|
+
post(RESOURCE_ROUTES.saveFavorite, async (body) => {
|
|
59
|
+
// The snapshot is read server-side from the live workspace state, so a
|
|
60
|
+
// client cannot store a state it never had.
|
|
61
|
+
const input = resolveFavoriteInput(body);
|
|
62
|
+
if (input === undefined)
|
|
63
|
+
throw new Error('favorite name is required');
|
|
64
|
+
const favoriteId = await deps.saveFavorite(input.name);
|
|
65
|
+
return { window: await buildResourceWindow(deps), favoriteId };
|
|
66
|
+
});
|
|
67
|
+
post(RESOURCE_ROUTES.deleteFavorite, async (body) => {
|
|
68
|
+
if (typeof body.id !== 'string' || body.id === '')
|
|
69
|
+
throw new Error('missing favorite id');
|
|
70
|
+
await deps.deleteFavorite(body.id);
|
|
71
|
+
return { window: await buildResourceWindow(deps) };
|
|
72
|
+
});
|
|
73
|
+
// Follow global: the workspace drops every project-level opinion — no entry
|
|
74
|
+
// filters, all six surface switches back on — and the payload returns the
|
|
75
|
+
// plain installed inventory.
|
|
76
|
+
post(RESOURCE_ROUTES.reset, async () => {
|
|
77
|
+
await deps.resetWorkspace();
|
|
78
|
+
return { window: await buildResourceWindow(deps) };
|
|
79
|
+
});
|
|
80
|
+
return () => {
|
|
81
|
+
for (const dispose of disposers)
|
|
82
|
+
dispose();
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function sameOrigin(request) {
|
|
86
|
+
const origin = request.headers['origin'];
|
|
87
|
+
if (origin === undefined)
|
|
88
|
+
return true;
|
|
89
|
+
try {
|
|
90
|
+
return new URL(origin).host === request.headers['host'];
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/** Parses the request body; `undefined` for an oversized, unparsable, or failed read. */
|
|
97
|
+
function readJsonBody(request) {
|
|
98
|
+
return new Promise(resolve => {
|
|
99
|
+
let size = 0;
|
|
100
|
+
const chunks = [];
|
|
101
|
+
request.on('data', (chunk) => {
|
|
102
|
+
size += chunk.length;
|
|
103
|
+
if (size > MAX_BODY_BYTES) {
|
|
104
|
+
resolve(undefined);
|
|
105
|
+
request.destroy();
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
chunks.push(chunk);
|
|
109
|
+
});
|
|
110
|
+
request.on('end', () => {
|
|
111
|
+
if (size > MAX_BODY_BYTES)
|
|
112
|
+
return;
|
|
113
|
+
try {
|
|
114
|
+
resolve(JSON.parse(Buffer.concat(chunks).toString('utf8')));
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
resolve(undefined);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
request.on('error', () => resolve(undefined));
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function sendJson(response, status, payload) {
|
|
124
|
+
const body = JSON.stringify(payload);
|
|
125
|
+
response.writeHead(status, { 'content-type': 'application/json; charset=utf-8', 'content-length': Buffer.byteLength(body) });
|
|
126
|
+
response.end(body);
|
|
127
|
+
}
|