coding-tool-x 3.8.4 → 3.8.6
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/CHANGELOG.md +15 -0
- package/README.md +86 -15
- package/dist/web/assets/AgentsDrawer-Db9wAyaZ.js +1 -0
- package/dist/web/assets/AgentsDrawer-Pw2k-ZAa.css +1 -0
- package/dist/web/assets/Analytics-C4gMzv7g.js +1 -0
- package/dist/web/assets/Analytics-CyHhR126.css +1 -0
- package/dist/web/assets/AssetPathField-Bd_nMFu3.js +1 -0
- package/dist/web/assets/ChatHistoryDrawer-B2qBQs9L.css +1 -0
- package/dist/web/assets/ChatHistoryDrawer-CwzJHyNP.js +1 -0
- package/dist/web/assets/CollapseItem-CTCfSiue.js +1 -0
- package/dist/web/assets/CommandsDrawer-BZJxlPvV.css +1 -0
- package/dist/web/assets/CommandsDrawer-vDghB1U9.js +1 -0
- package/dist/web/assets/ConfigExportDrawer-C-XDvlHc.js +1 -0
- package/dist/web/assets/ConfigExportDrawer-dwruRKWr.css +1 -0
- package/dist/web/assets/ConfigTemplates-CYY8XRED.js +1 -0
- package/dist/web/assets/ConfigTemplatesDrawer-BfDi8yO3.css +1 -0
- package/dist/web/assets/ConfigTemplatesDrawer-CbsJp76X.js +1 -0
- package/dist/web/assets/ConfigTemplatesPanel-CWyPtk67.css +1 -0
- package/dist/web/assets/ConfigTemplatesPanel-liMSTh7s.js +1 -0
- package/dist/web/assets/Divider-D28g1gwj.js +1 -0
- package/dist/web/assets/DrawerContent-ChXgZ1Xm.js +1 -0
- package/dist/web/assets/FavoritesDrawer-CG9eI9Ay.css +1 -0
- package/dist/web/assets/FavoritesDrawer-D6QSiYaL.js +1 -0
- package/dist/web/assets/GatewayConvertDrawer-CuNlf7AC.css +1 -0
- package/dist/web/assets/GatewayConvertDrawer-RvET6iNG.js +1 -0
- package/dist/web/assets/Home-CSuFuJ9Y.css +1 -0
- package/dist/web/assets/Home-P8eseZcf.js +1 -0
- package/dist/web/assets/MarkdownEditor-CYmLGYju.js +1 -0
- package/dist/web/assets/MarkdownEditor-qfVgSre_.css +1 -0
- package/dist/web/assets/McpDrawer-C0dnsZhQ.css +1 -0
- package/dist/web/assets/McpDrawer-Ch3bkKIq.js +1 -0
- package/dist/web/assets/McpFormDrawer-BRbDcawn.css +1 -0
- package/dist/web/assets/McpFormDrawer-BcTlgSpN.js +1 -0
- package/dist/web/assets/PluginManager-Dh2o0xkZ.js +1 -0
- package/dist/web/assets/PluginsDrawer-DM3QjprE.css +1 -0
- package/dist/web/assets/PluginsDrawer-deKQ5u3I.js +1 -0
- package/dist/web/assets/PluginsPanel-BofsgQgj.js +1 -0
- package/dist/web/assets/PluginsPanel-D6ZqITcR.css +1 -0
- package/dist/web/assets/ProjectList-677RLZ8O.css +1 -0
- package/dist/web/assets/ProjectList-DhSWJHTA.js +1 -0
- package/dist/web/assets/PromptsDrawer-BIgiYCEQ.css +1 -0
- package/dist/web/assets/PromptsDrawer-Cfb2FeeU.js +1 -0
- package/dist/web/assets/RecentSessionsDrawer-3eXamJhr.js +1 -0
- package/dist/web/assets/RecentSessionsDrawer-CKFsOYDM.css +1 -0
- package/dist/web/assets/SessionCard-CW0eHURI.js +1 -0
- package/dist/web/assets/SessionCard-aM2NHu6i.css +1 -0
- package/dist/web/assets/SessionList-BpYRz1cX.css +1 -0
- package/dist/web/assets/SessionList-DQfyDGWU.js +1 -0
- package/dist/web/assets/SettingsDrawer-Dw5NUgHC.css +1 -0
- package/dist/web/assets/SettingsDrawer-u_vwUuPS.js +1 -0
- package/dist/web/assets/SkillManager-C0GCT2Kb.css +1 -0
- package/dist/web/assets/SkillManager-DHMprJLA.js +1 -0
- package/dist/web/assets/SkillsDrawer-BCNme-aJ.css +1 -0
- package/dist/web/assets/SkillsDrawer-CkF3BpyC.js +1 -0
- package/dist/web/assets/SkillsPanel-B3Nm5j32.css +1 -0
- package/dist/web/assets/SkillsPanel-DWE4pFGx.js +1 -0
- package/dist/web/assets/SpeedTestDrawer-BgfG1Ked.js +1 -0
- package/dist/web/assets/SpeedTestDrawer-Dc0WToJ_.css +1 -0
- package/dist/web/assets/Upload-CNwaGOws.js +1 -0
- package/dist/web/assets/WorkspaceDrawer-Br5CeCzL.js +1 -0
- package/dist/web/assets/WorkspaceDrawer-CGnMu9p1.css +1 -0
- package/dist/web/assets/WorkspaceManager-B2O8-qIw.js +1 -0
- package/dist/web/assets/WorkspacePanel-5oDKit3c.js +1 -0
- package/dist/web/assets/WorkspacePanel-D0-zHTHP.css +1 -0
- package/dist/web/assets/_plugin-vue_export-helper-BeLZJZij.js +1 -0
- package/dist/web/assets/client-UDwXBP9i.js +1 -0
- package/dist/web/assets/clipboard-B46yyoz_.js +1 -0
- package/dist/web/assets/headers-cf-QapUq.js +1 -0
- package/dist/web/assets/icons-B2Vg-IOC.js +1 -0
- package/dist/web/assets/index-BMAUPq5K.js +2 -0
- package/dist/web/assets/index-Bi1MQHYX.css +1 -0
- package/dist/web/assets/light-Cp0t7v32.js +1 -0
- package/dist/web/assets/markdown-u082bbtj.js +1 -0
- package/dist/web/assets/platforms-CBkB45JP.js +1 -0
- package/dist/web/assets/platforms-FTpjxAT6.js +1 -0
- package/dist/web/assets/project-config-B2baPzYL.js +1 -0
- package/dist/web/assets/sessions-Cmy31slD.js +1 -0
- package/dist/web/assets/sessions-yC_oVVh8.js +1 -0
- package/dist/web/assets/skill-repo-input-B_fkGlUK.js +1 -0
- package/dist/web/assets/use-lock-html-scroll-DXIqmUW4.js +1 -0
- package/dist/web/assets/use-message-DoLM8C1C.js +1 -0
- package/dist/web/assets/useResponsiveDrawer-jbmqZuJs.js +1 -0
- package/dist/web/assets/vendors-D0c_0KLP.js +1 -0
- package/dist/web/assets/vue-vendor-BqZbbXHA.js +1 -0
- package/dist/web/assets/workspaces-mjyPVGS8.js +1 -0
- package/dist/web/assets/xml-CgY3RMlX.js +1 -0
- package/dist/web/index.html +12 -8
- package/docs/native-log-memory-2026-09-16.md +43 -0
- package/docs/superpowers/plans/2026-08-26-configuration-driven-cli-platform.md +1578 -0
- package/docs/superpowers/plans/2026-08-30-project-scoped-config-control.md +1260 -0
- package/docs/superpowers/plans/2026-09-01-omp-skill-refresh-boundary.md +213 -0
- package/docs/superpowers/plans/2026-09-01-realtime-logs-panel.md +125 -0
- package/docs/superpowers/plans/2026-09-02-config-driven-platform-boundary.md +86 -0
- package/docs/superpowers/plans/2026-09-02-platform-implementation-drivers.md +508 -0
- package/docs/superpowers/plans/2026-09-03-cli-platform-correctness-boundary.md +760 -0
- package/docs/superpowers/plans/2026-09-03-dependency-security-remediation.md +133 -0
- package/docs/superpowers/plans/2026-09-04-model-catalog-pricing-sync.md +1078 -0
- package/docs/superpowers/plans/2026-09-05-codex-project-scan-500.md +128 -0
- package/docs/superpowers/plans/2026-09-06-project-skill-path-fix.md +97 -0
- package/docs/superpowers/specs/2026-08-26-configuration-driven-cli-platform-design.md +408 -0
- package/docs/superpowers/specs/2026-08-30-project-scoped-config-control-design.md +467 -0
- package/docs/superpowers/specs/2026-09-01-claude-session-content-repair-design.md +111 -0
- package/docs/superpowers/specs/2026-09-01-omp-skill-refresh-boundary-design.md +83 -0
- package/docs/superpowers/specs/2026-09-01-realtime-logs-panel-design.md +27 -0
- package/docs/superpowers/specs/2026-09-02-config-driven-platform-boundary-design.md +64 -0
- package/docs/superpowers/specs/2026-09-02-platform-implementation-driver-boundary-design.md +123 -0
- package/docs/superpowers/specs/2026-09-03-cli-platform-correctness-boundary-design.md +249 -0
- package/docs/superpowers/specs/2026-09-03-dependency-security-remediation-design.md +87 -0
- package/docs/superpowers/specs/2026-09-04-model-catalog-pricing-sync-design.md +301 -0
- package/docs/superpowers/specs/2026-09-05-codex-project-scan-500-design.md +24 -0
- package/package.json +8 -4
- package/src/commands/channels.js +88 -191
- package/src/commands/cli-type.js +19 -11
- package/src/commands/daemon.js +104 -32
- package/src/commands/doctor.js +16 -9
- package/src/commands/export-config.js +23 -5
- package/src/commands/list.js +130 -52
- package/src/commands/logs.js +44 -27
- package/src/commands/platform-command-registry.js +78 -0
- package/src/commands/plugin.js +11 -5
- package/src/commands/port-config.js +34 -52
- package/src/commands/proxy-control.js +207 -145
- package/src/commands/proxy.js +2 -2
- package/src/commands/resume.js +87 -91
- package/src/commands/search.js +137 -67
- package/src/commands/stats.js +30 -22
- package/src/commands/switch.js +1 -1
- package/src/commands/toggle-proxy.js +94 -111
- package/src/commands/ui.js +67 -6
- package/src/commands/workspace.js +90 -8
- package/src/config/default.js +6 -53
- package/src/config/loader.js +61 -24
- package/src/config/model-metadata.js +49 -59
- package/src/config/model-metadata.json +4095 -99
- package/src/config/paths.js +181 -8
- package/src/index.js +134 -71
- package/src/platforms/access.js +196 -0
- package/src/{server/services → platforms}/agents-service.js +354 -197
- package/src/platforms/channel-auth-registry.js +165 -0
- package/src/platforms/channel-auth-service.js +107 -0
- package/src/{server/services → platforms}/commands-service.js +195 -115
- package/src/platforms/driver-registry.js +59 -0
- package/src/platforms/drivers/claude/api-operations.js +62 -0
- package/src/{server/services/channels.js → platforms/drivers/claude/channels-implementation.js} +131 -33
- package/src/platforms/drivers/claude/channels.js +39 -0
- package/src/{server/services/config-sync-service.js → platforms/drivers/claude/config-sync.js} +29 -5
- package/src/{server/services → platforms/drivers/claude}/health-check.js +4 -4
- package/src/platforms/drivers/claude/health.js +22 -0
- package/src/platforms/drivers/claude/mcp.js +9 -0
- package/src/{server/services/settings-manager.js → platforms/drivers/claude/native-config-implementation.js} +13 -4
- package/src/platforms/drivers/claude/native-config.js +46 -0
- package/src/platforms/drivers/claude/native-logs.js +72 -0
- package/src/{server/services/claude-openai-gateway.js → platforms/drivers/claude/openai-gateway.js} +8 -65
- package/src/platforms/drivers/claude/project-config.js +21 -0
- package/src/platforms/drivers/claude/projects.js +62 -0
- package/src/platforms/drivers/claude/prompts.js +9 -0
- package/src/{server/proxy-server.js → platforms/drivers/claude/proxy-implementation.js} +41 -278
- package/src/platforms/drivers/claude/proxy.js +16 -0
- package/src/platforms/drivers/claude/resource-sync.js +9 -0
- package/src/platforms/drivers/claude/session-history-adapter.js +313 -0
- package/src/{server/services/sessions.js → platforms/drivers/claude/sessions-implementation.js} +145 -35
- package/src/platforms/drivers/claude/sessions.js +76 -0
- package/src/{server/services/claude-statistics-service.js → platforms/drivers/claude/statistics-implementation.js} +2 -2
- package/src/platforms/drivers/claude/statistics.js +16 -0
- package/src/{server/services/claude-wire.js → platforms/drivers/claude/wire.js} +1 -1
- package/src/platforms/drivers/codex/api-operations.js +9 -0
- package/src/{server/services/codex-channels.js → platforms/drivers/codex/channels-implementation.js} +149 -14
- package/src/platforms/drivers/codex/channels.js +45 -0
- package/src/{server/services/codex-config.js → platforms/drivers/codex/config.js} +12 -2
- package/src/{server/services/codex-env-manager.js → platforms/drivers/codex/env-manager.js} +1 -1
- package/src/platforms/drivers/codex/mcp.js +9 -0
- package/src/{server/services/codex-settings-manager.js → platforms/drivers/codex/native-config-implementation.js} +15 -6
- package/src/platforms/drivers/codex/native-config.js +47 -0
- package/src/platforms/drivers/codex/native-logs.js +166 -0
- package/src/platforms/drivers/codex/project-config.js +21 -0
- package/src/platforms/drivers/codex/projects.js +26 -0
- package/src/platforms/drivers/codex/prompts.js +9 -0
- package/src/{server/codex-proxy-server.js → platforms/drivers/codex/proxy-implementation.js} +30 -233
- package/src/platforms/drivers/codex/proxy.js +16 -0
- package/src/platforms/drivers/codex/resource-sync.js +9 -0
- package/src/{server/services/session-history-adapters/codex.js → platforms/drivers/codex/session-history-adapter.js} +37 -23
- package/src/{server/services/codex-sessions.js → platforms/drivers/codex/sessions-implementation.js} +81 -75
- package/src/platforms/drivers/codex/sessions.js +36 -0
- package/src/{server/services/codex-statistics-service.js → platforms/drivers/codex/statistics-implementation.js} +2 -2
- package/src/platforms/drivers/codex/statistics.js +16 -0
- package/src/platforms/drivers/gemini/api-operations.js +9 -0
- package/src/{server/services/gemini-channels.js → platforms/drivers/gemini/channels-implementation.js} +202 -37
- package/src/platforms/drivers/gemini/channels.js +39 -0
- package/src/{server/services/gemini-config.js → platforms/drivers/gemini/config.js} +12 -2
- package/src/platforms/drivers/gemini/mcp.js +9 -0
- package/src/{server/services/gemini-settings-manager.js → platforms/drivers/gemini/native-config-implementation.js} +14 -5
- package/src/platforms/drivers/gemini/native-config.js +39 -0
- package/src/platforms/drivers/gemini/native-logs.js +180 -0
- package/src/platforms/drivers/gemini/project-config.js +21 -0
- package/src/platforms/drivers/gemini/projects.js +26 -0
- package/src/platforms/drivers/gemini/prompts.js +9 -0
- package/src/{server/gemini-proxy-server.js → platforms/drivers/gemini/proxy-implementation.js} +36 -267
- package/src/platforms/drivers/gemini/proxy.js +16 -0
- package/src/platforms/drivers/gemini/resource-sync.js +9 -0
- package/src/{server/services/session-history-adapters/gemini.js → platforms/drivers/gemini/session-history-adapter.js} +70 -18
- package/src/{server/services/gemini-sessions.js → platforms/drivers/gemini/sessions-implementation.js} +53 -37
- package/src/platforms/drivers/gemini/sessions.js +47 -0
- package/src/{server/services/gemini-statistics-service.js → platforms/drivers/gemini/statistics-implementation.js} +2 -2
- package/src/platforms/drivers/gemini/statistics.js +16 -0
- package/src/{server/services/gemini-wire.js → platforms/drivers/gemini/wire.js} +1 -1
- package/src/platforms/drivers/generic-filesystem.js +166 -0
- package/src/platforms/drivers/generic-jsonl.js +141 -0
- package/src/platforms/drivers/generic-mcp.js +44 -0
- package/src/platforms/drivers/generic-openai-compatible.js +45 -0
- package/src/platforms/drivers/generic-prompt.js +41 -0
- package/src/platforms/drivers/legacy.js +677 -0
- package/src/platforms/drivers/native-config-snapshot.js +125 -0
- package/src/platforms/drivers/native-log-utils.js +1292 -0
- package/src/platforms/drivers/notification-hooks.js +578 -0
- package/src/{server/api/omp-config.js → platforms/drivers/omp/api-operations.js} +52 -64
- package/src/{server/services/omp-auth-provider-worker.js → platforms/drivers/omp/auth-provider-worker.js} +1 -1
- package/src/{server/services/omp-auth-providers.js → platforms/drivers/omp/auth-providers.js} +1 -1
- package/src/{server/services/omp-channels.js → platforms/drivers/omp/channels-implementation.js} +166 -39
- package/src/platforms/drivers/omp/channels.js +58 -0
- package/src/{server/services/omp-config.js → platforms/drivers/omp/config.js} +53 -13
- package/src/{server/services/omp-gateway-routing.js → platforms/drivers/omp/gateway-routing.js} +14 -7
- package/src/{server/services/omp-gateway.js → platforms/drivers/omp/gateway.js} +4 -262
- package/src/platforms/drivers/omp/mcp.js +9 -0
- package/src/{server/services/omp-settings-manager.js → platforms/drivers/omp/native-config-implementation.js} +75 -10
- package/src/platforms/drivers/omp/native-config.js +46 -0
- package/src/platforms/drivers/omp/native-logs.js +52 -0
- package/src/{server/services/omp-native-plugin-adapter.js → platforms/drivers/omp/native-plugin-adapter.js} +91 -4
- package/src/platforms/drivers/omp/project-config.js +29 -0
- package/src/platforms/drivers/omp/projects.js +20 -0
- package/src/platforms/drivers/omp/prompts.js +9 -0
- package/src/{server/omp-proxy-server.js → platforms/drivers/omp/proxy-implementation.js} +6 -15
- package/src/platforms/drivers/omp/proxy.js +16 -0
- package/src/platforms/drivers/omp/resource-sync.js +9 -0
- package/src/{server/services/session-history-adapters/omp.js → platforms/drivers/omp/session-history-adapter.js} +42 -18
- package/src/{server/services/omp-sessions.js → platforms/drivers/omp/sessions-implementation.js} +130 -94
- package/src/platforms/drivers/omp/sessions.js +36 -0
- package/src/{server/services/omp-skill-discovery.js → platforms/drivers/omp/skill-discovery.js} +159 -32
- package/src/{server/services/omp-skill-settings-service.js → platforms/drivers/omp/skill-settings.js} +1 -1
- package/src/{server/services/omp-statistics-service.js → platforms/drivers/omp/statistics-implementation.js} +3 -3
- package/src/platforms/drivers/omp/statistics.js +16 -0
- package/src/platforms/drivers/opencode/api-operations.js +9 -0
- package/src/{server/services/opencode-channels.js → platforms/drivers/opencode/channels-implementation.js} +28 -9
- package/src/platforms/drivers/opencode/channels.js +40 -0
- package/src/platforms/drivers/opencode/conversion.js +41 -0
- package/src/{server/services/opencode-gateway-converter.js → platforms/drivers/opencode/gateway-converter.js} +1 -1
- package/src/platforms/drivers/opencode/mcp.js +9 -0
- package/src/{server/services/opencode-settings-manager.js → platforms/drivers/opencode/native-config-implementation.js} +17 -6
- package/src/platforms/drivers/opencode/native-config.js +26 -0
- package/src/platforms/drivers/opencode/native-logs.js +133 -0
- package/src/platforms/drivers/opencode/project-config.js +98 -0
- package/src/platforms/drivers/opencode/projects.js +20 -0
- package/src/platforms/drivers/opencode/prompts.js +9 -0
- package/src/{server/opencode-proxy-server.js → platforms/drivers/opencode/proxy-implementation.js} +27 -362
- package/src/platforms/drivers/opencode/proxy.js +16 -0
- package/src/platforms/drivers/opencode/resource-sync.js +9 -0
- package/src/{server/services/opencode-sessions.js → platforms/drivers/opencode/sessions-implementation.js} +211 -64
- package/src/platforms/drivers/opencode/sessions.js +48 -0
- package/src/{server/services/opencode-statistics-service.js → platforms/drivers/opencode/statistics-implementation.js} +2 -2
- package/src/platforms/drivers/opencode/statistics.js +16 -0
- package/src/platforms/drivers/secure-file-driver.js +272 -0
- package/src/platforms/drivers/unsupported.js +7 -0
- package/src/platforms/manifest-schema.js +398 -0
- package/src/platforms/manifests/claude.json +489 -0
- package/src/platforms/manifests/codex.json +448 -0
- package/src/platforms/manifests/gemini.json +447 -0
- package/src/platforms/manifests/omp.json +496 -0
- package/src/platforms/manifests/opencode.json +422 -0
- package/src/{server/services → platforms}/native-oauth-adapters.js +98 -418
- package/src/{server/services → platforms}/notification-hooks.js +190 -1023
- package/src/platforms/oauth-credentials-service.js +635 -0
- package/src/platforms/path-resolver.js +179 -0
- package/src/platforms/platform-path-context.js +305 -0
- package/src/platforms/registry.js +248 -0
- package/src/platforms/remote-notification-providers.js +678 -0
- package/src/platforms/runtime.js +259 -0
- package/src/{server/services/session-history-adapters/index.js → platforms/session-history-adapters.js} +8 -1
- package/src/plugins/plugin-loader.js +2 -2
- package/src/plugins/plugin-manager.js +2 -2
- package/src/plugins/registry.js +27 -10
- package/src/reset-config.js +21 -5
- package/src/server/api/agents.js +46 -72
- package/src/server/api/commands.js +16 -6
- package/src/server/api/config-registry.js +206 -59
- package/src/server/api/config-sync.js +3 -2
- package/src/server/api/config-templates.js +20 -4
- package/src/server/api/config.js +111 -102
- package/src/server/api/convert.js +54 -178
- package/src/server/api/dashboard.js +168 -102
- package/src/server/api/hooks.js +1 -1
- package/src/server/api/mcp.js +224 -84
- package/src/server/api/platform-api-config.js +102 -0
- package/src/server/api/platform-route-factory.js +215 -0
- package/src/server/api/platform-routes.js +26 -0
- package/src/server/api/platforms.js +110 -0
- package/src/server/api/plugins.js +57 -57
- package/src/server/api/project-config.js +168 -0
- package/src/server/api/prompts.js +58 -45
- package/src/server/api/settings.js +55 -8
- package/src/server/api/skills.js +262 -133
- package/src/server/api/ui-config.js +2 -2
- package/src/server/api/validation-errors.js +18 -4
- package/src/server/api/workspaces.js +47 -12
- package/src/server/index.js +164 -213
- package/src/server/platform-context.js +81 -0
- package/src/server/services/channel-balance.js +133 -24
- package/src/server/services/channel-health.js +21 -6
- package/src/server/services/channel-scheduler.js +29 -39
- package/src/server/services/channel-sync-utils.js +23 -13
- package/src/server/services/config-export-service.js +350 -319
- package/src/server/services/config-registry-service.js +280 -54
- package/src/server/services/config-sync-manager.js +172 -944
- package/src/server/services/config-templates-service.js +419 -353
- package/src/server/services/control-manifest-store.js +206 -0
- package/src/server/services/dashboard-snapshot-worker.js +656 -100
- package/src/server/services/effective-control-service.js +557 -0
- package/src/server/services/local-resource-index.js +314 -0
- package/src/server/services/mcp-service.js +607 -977
- package/src/server/services/model-detector.js +15 -10
- package/src/server/services/native-log-channel-resolver.js +214 -0
- package/src/server/services/native-log-observer.js +291 -0
- package/src/server/services/network-access.js +12 -2
- package/src/server/services/platform-catalog.js +82 -0
- package/src/server/services/platform-resolution.js +32 -29
- package/src/server/services/plugins-service.js +376 -122
- package/src/server/services/project-config-service.js +550 -0
- package/src/server/services/project-path-validation.js +31 -0
- package/src/server/services/prompts-service.js +267 -233
- package/src/server/services/proxy-runtime.js +7 -4
- package/src/server/services/remote-credential-cache.js +43 -0
- package/src/server/services/repo-scanner-base.js +182 -75
- package/src/server/services/request-logger.js +7 -4
- package/src/server/services/session-history-index.js +876 -214
- package/src/server/services/session-history-worker.js +228 -33
- package/src/server/services/session-snapshot-worker.js +124 -34
- package/src/server/services/session-snapshots.js +4 -2
- package/src/server/services/skill-artifact-store.js +355 -0
- package/src/server/services/skill-format-adapters.js +65 -0
- package/src/server/services/skill-projection-service.js +323 -0
- package/src/server/services/skill-refresh-task-service.js +275 -0
- package/src/server/services/skill-service.js +2020 -677
- package/src/server/services/snapshot-cache.js +30 -8
- package/src/server/services/speed-test.js +8 -8
- package/src/server/services/sqlite-connection.js +19 -3
- package/src/server/services/statistics-service.js +240 -57
- package/src/server/services/ui-config.js +107 -76
- package/src/server/services/usage-log-utils.js +98 -0
- package/src/server/services/web-build.js +1 -1
- package/src/server/services/workspace-service.js +59 -29
- package/src/server/utils/pricing.js +10 -19
- package/src/server/websocket-server.js +153 -28
- package/src/{server/services/base → shared}/base-channel-service.js +156 -28
- package/src/shared/capability-driver.js +104 -0
- package/src/shared/channel-auth-policy.js +27 -0
- package/src/shared/channel-driver.js +161 -0
- package/src/shared/driver-factories/api.js +180 -0
- package/src/shared/driver-factories/mcp.js +244 -0
- package/src/shared/driver-factories/projects.js +121 -0
- package/src/shared/driver-factories/prompts.js +58 -0
- package/src/shared/driver-factories/resource-sync.js +375 -0
- package/src/shared/driver-result.js +78 -0
- package/src/shared/mcp-format.js +189 -0
- package/src/shared/platforms.js +104 -167
- package/src/shared/project-config.js +512 -0
- package/src/shared/proxy-driver.js +57 -0
- package/src/{server/services/base → shared}/response-usage-parser.js +8 -4
- package/src/ui/menu.js +91 -67
- package/src/utils/port-helper.js +35 -19
- package/src/utils/session.js +1 -1
- package/dist/web/assets/Analytics-COEUXmd4.js +0 -25
- package/dist/web/assets/Analytics-RNn1BUbG.css +0 -1
- package/dist/web/assets/ConfigTemplates-DLLkS53H.js +0 -1
- package/dist/web/assets/Home-DCEyLzwX.js +0 -1
- package/dist/web/assets/Home-DYVy4cGZ.css +0 -1
- package/dist/web/assets/PluginManager-Oe1ZHoMO.js +0 -1
- package/dist/web/assets/ProjectList-CWjuAFof.js +0 -1
- package/dist/web/assets/ProjectList-VeMNXfgO.css +0 -1
- package/dist/web/assets/SessionList-C4chCPxK.css +0 -1
- package/dist/web/assets/SessionList-v3ehGg9U.js +0 -1
- package/dist/web/assets/SkillManager-BsX8Qpj0.css +0 -1
- package/dist/web/assets/SkillManager-DUF_qP5S.js +0 -1
- package/dist/web/assets/WorkspaceManager-CjAWBosO.js +0 -1
- package/dist/web/assets/icons-nGdSKQn2.js +0 -1
- package/dist/web/assets/index-D5hyHPj7.js +0 -2
- package/dist/web/assets/index-bJRG3RXH.css +0 -1
- package/dist/web/assets/markdown-BNJfEgCA.js +0 -1
- package/dist/web/assets/markdown-BfC0goYb.css +0 -10
- package/dist/web/assets/naive-ui-BALVpMgd.js +0 -1
- package/dist/web/assets/vendors-DQA4Hw9v.js +0 -7
- package/dist/web/assets/vue-vendor-B5RqjEjQ.js +0 -45
- package/src/config/model-pricing.js +0 -35
- package/src/server/api/channels.js +0 -439
- package/src/server/api/claude-hooks.js +0 -56
- package/src/server/api/claude-statistics.js +0 -57
- package/src/server/api/codex-channels.js +0 -491
- package/src/server/api/codex-projects.js +0 -117
- package/src/server/api/codex-proxy.js +0 -293
- package/src/server/api/codex-sessions.js +0 -652
- package/src/server/api/codex-statistics.js +0 -57
- package/src/server/api/gemini-channels.js +0 -392
- package/src/server/api/gemini-projects.js +0 -103
- package/src/server/api/gemini-proxy.js +0 -231
- package/src/server/api/gemini-sessions.js +0 -550
- package/src/server/api/gemini-statistics.js +0 -57
- package/src/server/api/health-check.js +0 -31
- package/src/server/api/oauth-credentials.js +0 -198
- package/src/server/api/omp-channels.js +0 -575
- package/src/server/api/omp-projects.js +0 -88
- package/src/server/api/omp-proxy.js +0 -125
- package/src/server/api/omp-sessions.js +0 -386
- package/src/server/api/omp-statistics.js +0 -40
- package/src/server/api/opencode-channels.js +0 -471
- package/src/server/api/opencode-projects.js +0 -110
- package/src/server/api/opencode-proxy.js +0 -354
- package/src/server/api/opencode-sessions.js +0 -466
- package/src/server/api/opencode-statistics.js +0 -57
- package/src/server/api/projects.js +0 -120
- package/src/server/api/proxy.js +0 -330
- package/src/server/api/sessions.js +0 -810
- package/src/server/services/oauth-credentials-service.js +0 -945
- package/src/server/services/omp-session-log-observer.js +0 -138
- package/src/server/services/opencode-gateway-adapters.js +0 -43
- package/src/server/services/project-snapshots.js +0 -59
- package/src/server/services/proxy-log-helper.js +0 -298
- package/src/server/services/session-cache.js +0 -127
- package/src/server/services/session-converter.js +0 -582
- package/src/server/services/session-history-adapters/claude.js +0 -235
- /package/src/{server/services/claude-token-recovery.js → platforms/drivers/claude/token-recovery.js} +0 -0
- /package/src/{server/services/codex-parser.js → platforms/drivers/codex/parser.js} +0 -0
- /package/src/{server/services/codex-speed-test-template.json → platforms/drivers/codex/speed-test-template.json} +0 -0
- /package/src/{server/services/codex-wire.js → platforms/drivers/codex/wire.js} +0 -0
- /package/src/{server/services/omp-auth-gateway-client.js → platforms/drivers/omp/auth-gateway-client.js} +0 -0
- /package/src/{server/services/opencode-normalization.js → platforms/drivers/opencode/normalization.js} +0 -0
- /package/src/{server/services → shared}/config-artifact-paths.js +0 -0
- /package/src/{server/services/base → shared}/proxy-utils.js +0 -0
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { DEFAULT_CONTROL_MANIFEST } = require('./control-manifest-store');
|
|
6
|
+
|
|
7
|
+
const VALID_SCOPES = new Set(['user', 'project']);
|
|
8
|
+
const VALID_TRUST = new Set(['pending', 'approved', 'blocked', 'needs_review']);
|
|
9
|
+
const VALID_MCP_TRUST = new Set(['pending', 'approved', 'blocked']);
|
|
10
|
+
const VALID_MCP_RISK_TIERS = new Set(['read_only', 'local_exec', 'external_write']);
|
|
11
|
+
const VALID_ARTIFACT_STATES = new Set(['ready', 'metadata_only', 'stale', 'missing', 'pending', 'orphaned', 'failed', 'unsupported']);
|
|
12
|
+
const VALID_MCP_TRANSPORTS = new Set(['stdio', 'streamable_http', 'sse']);
|
|
13
|
+
const SKILL_CONTROL_KEYS = new Set([
|
|
14
|
+
'kind', 'controlKey', 'platform', 'scope', 'projectPath', 'sourceKey', 'source', 'artifact',
|
|
15
|
+
'targetDirectory', 'cached', 'enabled', 'trust', 'projection', 'managed', 'lastError',
|
|
16
|
+
'createdAt', 'updatedAt', 'name', 'description', 'sourceProvider', 'sourceScope',
|
|
17
|
+
'fullDirectory', 'revision', 'repoId', 'repoProvider', 'repoOwner', 'repoName',
|
|
18
|
+
'repoBranch', 'repoDirectory', 'repoHost', 'repoProjectPath', 'repoLocalPath', 'repoUrl',
|
|
19
|
+
'readmeUrl', 'license', 'readonly', 'protected', 'isLocal'
|
|
20
|
+
]);
|
|
21
|
+
const FORBIDDEN_SECRET_KEYS = new Set([
|
|
22
|
+
'env',
|
|
23
|
+
'environment',
|
|
24
|
+
'envvars',
|
|
25
|
+
'experimentalenvironment',
|
|
26
|
+
'headers',
|
|
27
|
+
'httpheaders',
|
|
28
|
+
'token',
|
|
29
|
+
'accesstoken',
|
|
30
|
+
'password',
|
|
31
|
+
'secret',
|
|
32
|
+
'secretvalue',
|
|
33
|
+
'authorization',
|
|
34
|
+
'apikey',
|
|
35
|
+
'privatekey',
|
|
36
|
+
'credential',
|
|
37
|
+
'credentials',
|
|
38
|
+
'clientsecret',
|
|
39
|
+
'bearertokenenvvar',
|
|
40
|
+
'auth',
|
|
41
|
+
'oauth',
|
|
42
|
+
'serverspec',
|
|
43
|
+
'command',
|
|
44
|
+
'args',
|
|
45
|
+
'url'
|
|
46
|
+
]);
|
|
47
|
+
|
|
48
|
+
function deriveMcpPolicy({ transport = 'stdio', scope = 'user' } = {}) {
|
|
49
|
+
const normalizedTransport = VALID_MCP_TRANSPORTS.has(transport) ? transport : 'stdio';
|
|
50
|
+
const remote = normalizedTransport !== 'stdio';
|
|
51
|
+
return {
|
|
52
|
+
transport: normalizedTransport,
|
|
53
|
+
riskTier: remote ? 'external_write' : 'local_exec',
|
|
54
|
+
egressProfile: remote
|
|
55
|
+
? (scope === 'project' ? 'project-network' : 'network')
|
|
56
|
+
: (scope === 'project' ? 'project-local-process' : 'local-process')
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function isPlainObject(value) {
|
|
61
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function clone(value) {
|
|
65
|
+
return JSON.parse(JSON.stringify(value));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function normalizedSecretKey(key) {
|
|
69
|
+
return String(key).replace(/[_-]/g, '').toLowerCase();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function assertNoSecretValues(value, label = 'control entry') {
|
|
73
|
+
if (Array.isArray(value)) {
|
|
74
|
+
value.forEach(item => assertNoSecretValues(item, label));
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (!isPlainObject(value)) return;
|
|
78
|
+
|
|
79
|
+
for (const [key, child] of Object.entries(value)) {
|
|
80
|
+
if (FORBIDDEN_SECRET_KEYS.has(normalizedSecretKey(key))) {
|
|
81
|
+
throw new Error(`${label} contains forbidden secret or server field: ${key}`);
|
|
82
|
+
}
|
|
83
|
+
assertNoSecretValues(child, label);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function sanitizeSkillEntry(entry) {
|
|
88
|
+
assertNoSecretValues(entry, 'Skill control entry');
|
|
89
|
+
const safe = Object.fromEntries(
|
|
90
|
+
Object.entries(entry).filter(([key]) => SKILL_CONTROL_KEYS.has(key))
|
|
91
|
+
);
|
|
92
|
+
return safe;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function normalizeProjectPath(projectPath) {
|
|
96
|
+
if (typeof projectPath !== 'string' || !path.isAbsolute(projectPath)) {
|
|
97
|
+
throw new Error('Project scope requires a canonical absolute projectPath');
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
return fs.realpathSync(projectPath);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
throw new Error('Project scope requires an existing canonical projectPath', { cause: error });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function normalizeScope(scope = 'user', projectPath = null) {
|
|
107
|
+
if (!VALID_SCOPES.has(scope)) {
|
|
108
|
+
throw new Error('Invalid scope: expected "user" or "project"');
|
|
109
|
+
}
|
|
110
|
+
if (scope === 'user') {
|
|
111
|
+
if (projectPath !== null && projectPath !== undefined) {
|
|
112
|
+
throw new Error('User scope cannot include projectPath');
|
|
113
|
+
}
|
|
114
|
+
return { scope, projectPath: null };
|
|
115
|
+
}
|
|
116
|
+
return { scope, projectPath: normalizeProjectPath(projectPath) };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function sourceKeyFor(entry = {}) {
|
|
120
|
+
if (entry.sourceKey) return String(entry.sourceKey);
|
|
121
|
+
const source = isPlainObject(entry.source) ? entry.source : {};
|
|
122
|
+
const sourceKind = source.kind || entry.source || 'unknown';
|
|
123
|
+
const repoId = source.repoId || source.repoUrl || '';
|
|
124
|
+
const fullDirectory = source.fullDirectory || entry.fullDirectory || entry.targetDirectory || entry.directory || entry.name || '';
|
|
125
|
+
return [sourceKind, repoId, fullDirectory].map(value => String(value || '')).join(':');
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function skillIdentity(entry = {}) {
|
|
129
|
+
return `${entry.platform || ''}:${sourceKeyFor(entry)}`;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
function buildControlKey(entry, scope, projectPath) {
|
|
134
|
+
const location = scope === 'project' ? projectPath : 'user';
|
|
135
|
+
return entry.controlKey || `skill:${entry.platform}:${scope}:${location}:${sourceKeyFor(entry)}`;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function ensureMap(manifest, key) {
|
|
139
|
+
if (!isPlainObject(manifest[key])) manifest[key] = {};
|
|
140
|
+
return manifest[key];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
class EffectiveControlService {
|
|
144
|
+
constructor({ store, projection = null, clock = () => Date.now() } = {}) {
|
|
145
|
+
if (!store || typeof store.read !== 'function' || typeof store.write !== 'function') {
|
|
146
|
+
throw new Error('EffectiveControlService requires a control manifest store');
|
|
147
|
+
}
|
|
148
|
+
this.store = store;
|
|
149
|
+
this.projection = projection;
|
|
150
|
+
this.clock = clock;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
_scopeOptions(options = {}) {
|
|
154
|
+
return normalizeScope(options.scope || 'user', options.projectPath ?? null);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
_skillTargetKey(entry) {
|
|
158
|
+
return [
|
|
159
|
+
entry.platform || '',
|
|
160
|
+
entry.targetDirectory || ''
|
|
161
|
+
].join(':');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
_readScope(scopeOptions) {
|
|
165
|
+
return this.store.read(scopeOptions);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
_writeScope(scopeOptions, manifest) {
|
|
169
|
+
manifest.updatedAt = this.clock();
|
|
170
|
+
return this.store.write(scopeOptions, manifest);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
_normalizeSkill(entry = {}) {
|
|
174
|
+
if (!isPlainObject(entry) || entry.kind !== 'skill') {
|
|
175
|
+
throw new Error('Invalid Skill control entry');
|
|
176
|
+
}
|
|
177
|
+
const safeEntry = sanitizeSkillEntry(entry);
|
|
178
|
+
const scopeOptions = normalizeScope(safeEntry.scope || 'user', safeEntry.projectPath ?? null);
|
|
179
|
+
if (!safeEntry.platform || typeof safeEntry.platform !== 'string') {
|
|
180
|
+
throw new Error('Skill control entry requires platform');
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const now = this.clock();
|
|
184
|
+
const artifact = isPlainObject(safeEntry.artifact) ? clone(safeEntry.artifact) : null;
|
|
185
|
+
if (artifact && !VALID_ARTIFACT_STATES.has(artifact.state)) artifact.state = 'missing';
|
|
186
|
+
const normalized = clone({
|
|
187
|
+
...safeEntry,
|
|
188
|
+
controlKey: buildControlKey(safeEntry, scopeOptions.scope, scopeOptions.projectPath),
|
|
189
|
+
sourceKey: sourceKeyFor(safeEntry),
|
|
190
|
+
scope: scopeOptions.scope,
|
|
191
|
+
projectPath: scopeOptions.projectPath,
|
|
192
|
+
managed: true,
|
|
193
|
+
cached: safeEntry.cached !== false,
|
|
194
|
+
enabled: safeEntry.enabled === true,
|
|
195
|
+
trust: VALID_TRUST.has(safeEntry.trust) ? safeEntry.trust : 'pending',
|
|
196
|
+
artifact,
|
|
197
|
+
projection: isPlainObject(safeEntry.projection)
|
|
198
|
+
? safeEntry.projection
|
|
199
|
+
: { mode: 'unsupported', state: 'unsupported', path: null, updatedAt: null },
|
|
200
|
+
createdAt: safeEntry.createdAt || now,
|
|
201
|
+
updatedAt: now,
|
|
202
|
+
lastError: safeEntry.lastError || null
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
if (normalized.trust !== 'approved') normalized.enabled = false;
|
|
206
|
+
if (normalized.trust === 'blocked') {
|
|
207
|
+
normalized.projection = { ...normalized.projection, state: 'blocked', updatedAt: now };
|
|
208
|
+
}
|
|
209
|
+
return normalized;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
_normalizeMcp(entry = {}) {
|
|
213
|
+
if (!isPlainObject(entry) || entry.kind !== 'mcp') {
|
|
214
|
+
throw new Error('Invalid MCP control entry');
|
|
215
|
+
}
|
|
216
|
+
assertNoSecretValues(entry, 'MCP control entry');
|
|
217
|
+
const scopeOptions = normalizeScope(entry.scope || 'user', entry.projectPath ?? null);
|
|
218
|
+
if (!entry.platform || typeof entry.platform !== 'string') {
|
|
219
|
+
throw new Error('MCP control entry requires platform');
|
|
220
|
+
}
|
|
221
|
+
const now = this.clock();
|
|
222
|
+
const policy = deriveMcpPolicy({
|
|
223
|
+
transport: entry.transport,
|
|
224
|
+
scope: scopeOptions.scope
|
|
225
|
+
});
|
|
226
|
+
return clone({
|
|
227
|
+
...entry,
|
|
228
|
+
controlKey: String(entry.controlKey || `mcp:${entry.platform}:${scopeOptions.scope}:${entry.name || now}`),
|
|
229
|
+
kind: 'mcp',
|
|
230
|
+
...policy,
|
|
231
|
+
platform: entry.platform,
|
|
232
|
+
scope: scopeOptions.scope,
|
|
233
|
+
projectPath: scopeOptions.projectPath,
|
|
234
|
+
managed: entry.managed !== false,
|
|
235
|
+
enabled: entry.enabled === true,
|
|
236
|
+
trust: VALID_MCP_TRUST.has(entry.trust) ? entry.trust : 'pending',
|
|
237
|
+
secretRefs: Array.isArray(entry.secretRefs) ? entry.secretRefs.map(ref => String(ref)) : [],
|
|
238
|
+
createdAt: entry.createdAt || now,
|
|
239
|
+
updatedAt: now
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
registerSkill(entry) {
|
|
244
|
+
const normalized = this._normalizeSkill(entry);
|
|
245
|
+
const scopeOptions = { scope: normalized.scope, projectPath: normalized.projectPath };
|
|
246
|
+
const manifest = this._readScope(scopeOptions);
|
|
247
|
+
const skills = ensureMap(manifest, 'skills');
|
|
248
|
+
const identity = skillIdentity(normalized);
|
|
249
|
+
|
|
250
|
+
for (const [key, existing] of Object.entries(skills)) {
|
|
251
|
+
if (key !== normalized.controlKey && existing && skillIdentity(existing) === identity) {
|
|
252
|
+
delete skills[key];
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
skills[normalized.controlKey] = normalized;
|
|
256
|
+
this._writeScope(scopeOptions, manifest);
|
|
257
|
+
return clone(normalized);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
getSkill(controlKey, options = {}) {
|
|
261
|
+
if (!controlKey) return null;
|
|
262
|
+
const scopeOptions = this._scopeOptions(options);
|
|
263
|
+
const manifest = this._readScope(scopeOptions);
|
|
264
|
+
const entry = manifest.skills?.[controlKey];
|
|
265
|
+
return entry ? clone(entry) : null;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
_updateSkill(controlKey, scopeOptions, updater) {
|
|
269
|
+
const manifest = this._readScope(scopeOptions);
|
|
270
|
+
const skills = ensureMap(manifest, 'skills');
|
|
271
|
+
const current = skills[controlKey];
|
|
272
|
+
if (!current) throw new Error('Skill control entry not found');
|
|
273
|
+
if (current.scope !== scopeOptions.scope) {
|
|
274
|
+
throw new Error('Skill control entry scope does not match the request');
|
|
275
|
+
}
|
|
276
|
+
if (scopeOptions.scope === 'project' && current.projectPath !== scopeOptions.projectPath) {
|
|
277
|
+
throw new Error('Skill control entry projectPath does not match the request');
|
|
278
|
+
}
|
|
279
|
+
if (scopeOptions.scope === 'user' && current.projectPath !== null) {
|
|
280
|
+
throw new Error('User Skill control entry cannot include projectPath');
|
|
281
|
+
}
|
|
282
|
+
const next = updater(clone(current));
|
|
283
|
+
skills[controlKey] = next;
|
|
284
|
+
this._writeScope(scopeOptions, manifest);
|
|
285
|
+
return clone(next);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
setSkillEnabled({ platform = null, controlKey, scope = 'user', projectPath = null, enabled } = {}) {
|
|
289
|
+
const scopeOptions = normalizeScope(scope, projectPath);
|
|
290
|
+
const requested = enabled === true;
|
|
291
|
+
const manifest = this._readScope(scopeOptions);
|
|
292
|
+
const current = manifest.skills?.[controlKey];
|
|
293
|
+
if (!current) throw new Error('Skill control entry not found');
|
|
294
|
+
if (platform && current.platform !== platform) {
|
|
295
|
+
throw new Error('Skill control entry platform does not match the request');
|
|
296
|
+
}
|
|
297
|
+
if (current.scope !== scopeOptions.scope) {
|
|
298
|
+
throw new Error('Skill control entry scope does not match the request');
|
|
299
|
+
}
|
|
300
|
+
if (scopeOptions.scope === 'project' && current.projectPath !== scopeOptions.projectPath) {
|
|
301
|
+
throw new Error('Skill control entry projectPath does not match the request');
|
|
302
|
+
}
|
|
303
|
+
if (scopeOptions.scope === 'user' && current.projectPath !== null) {
|
|
304
|
+
throw new Error('User Skill control entry cannot include projectPath');
|
|
305
|
+
}
|
|
306
|
+
if (requested && current.trust === 'blocked') {
|
|
307
|
+
return { ...clone(current), status: 'blocked' };
|
|
308
|
+
}
|
|
309
|
+
if (requested && current.trust !== 'approved') {
|
|
310
|
+
return { ...clone(current), status: 'needs_approval' };
|
|
311
|
+
}
|
|
312
|
+
const conflictPool = scopeOptions.scope === 'project'
|
|
313
|
+
? this.getEffectiveSnapshot({
|
|
314
|
+
platform: current.platform,
|
|
315
|
+
scope: scopeOptions.scope,
|
|
316
|
+
projectPath: scopeOptions.projectPath
|
|
317
|
+
}).skills.active
|
|
318
|
+
: Object.values(manifest.skills || {});
|
|
319
|
+
const conflicts = conflictPool
|
|
320
|
+
.filter(entry => (
|
|
321
|
+
entry?.controlKey !== controlKey
|
|
322
|
+
&& entry?.managed === true
|
|
323
|
+
&& entry.enabled === true
|
|
324
|
+
&& entry.trust === 'approved'
|
|
325
|
+
&& entry.artifact?.state === 'ready'
|
|
326
|
+
&& this._skillTargetKey(entry) === this._skillTargetKey(current)
|
|
327
|
+
))
|
|
328
|
+
.map(entry => entry);
|
|
329
|
+
if (requested && conflicts.length > 0) {
|
|
330
|
+
return {
|
|
331
|
+
...clone(current),
|
|
332
|
+
status: 'conflict',
|
|
333
|
+
conflictWith: conflicts.map(entry => entry.controlKey)
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
const projectionOwner = current.projection?.sourceKey;
|
|
337
|
+
const preserveProjection = !requested && (
|
|
338
|
+
conflicts.length > 0
|
|
339
|
+
|| (projectionOwner && projectionOwner !== current.sourceKey)
|
|
340
|
+
);
|
|
341
|
+
|
|
342
|
+
const next = {
|
|
343
|
+
...clone(current),
|
|
344
|
+
enabled: requested,
|
|
345
|
+
projection: {
|
|
346
|
+
...(current.projection || {}),
|
|
347
|
+
state: requested ? 'enabled' : 'disabled',
|
|
348
|
+
updatedAt: this.clock()
|
|
349
|
+
},
|
|
350
|
+
updatedAt: this.clock()
|
|
351
|
+
};
|
|
352
|
+
try {
|
|
353
|
+
const projectionResult = requested
|
|
354
|
+
? this.projection?.enable?.(next)
|
|
355
|
+
: (preserveProjection ? null : this.projection?.disable?.(next));
|
|
356
|
+
if (projectionResult && typeof projectionResult.then !== 'function') {
|
|
357
|
+
if (projectionResult.status === 'conflict' || projectionResult.state === 'conflict') {
|
|
358
|
+
const conflicted = {
|
|
359
|
+
...next,
|
|
360
|
+
enabled: false,
|
|
361
|
+
projection: { ...next.projection, ...clone(projectionResult) },
|
|
362
|
+
status: 'conflict'
|
|
363
|
+
};
|
|
364
|
+
manifest.skills[controlKey] = conflicted;
|
|
365
|
+
this._writeScope(scopeOptions, manifest);
|
|
366
|
+
return clone(conflicted);
|
|
367
|
+
}
|
|
368
|
+
if (projectionResult.status === 'unsupported' || projectionResult.state === 'unsupported') {
|
|
369
|
+
return { ...clone(current), projection: clone(projectionResult), status: 'unsupported' };
|
|
370
|
+
}
|
|
371
|
+
next.projection = { ...next.projection, ...projectionResult };
|
|
372
|
+
}
|
|
373
|
+
} catch (error) {
|
|
374
|
+
next.enabled = false;
|
|
375
|
+
next.projection = { ...next.projection, state: 'error', updatedAt: this.clock() };
|
|
376
|
+
next.lastError = error.message;
|
|
377
|
+
next.status = 'projection_failed';
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
manifest.skills[controlKey] = next;
|
|
381
|
+
this._writeScope(scopeOptions, manifest);
|
|
382
|
+
return clone(next);
|
|
383
|
+
}
|
|
384
|
+
setSkillTrust({ platform = null, controlKey, scope = 'user', projectPath = null, trust } = {}) {
|
|
385
|
+
if (!VALID_TRUST.has(trust)) throw new Error('Invalid Skill trust state');
|
|
386
|
+
const scopeOptions = normalizeScope(scope, projectPath);
|
|
387
|
+
return this._updateSkill(controlKey, scopeOptions, current => {
|
|
388
|
+
if (platform && current.platform !== platform) {
|
|
389
|
+
throw new Error('Skill control entry platform does not match the request');
|
|
390
|
+
}
|
|
391
|
+
const next = { ...current, trust };
|
|
392
|
+
if (trust !== 'approved') {
|
|
393
|
+
next.enabled = false;
|
|
394
|
+
next.projection = {
|
|
395
|
+
...(current.projection || {}),
|
|
396
|
+
state: trust === 'blocked' ? 'blocked' : 'disabled',
|
|
397
|
+
updatedAt: this.clock()
|
|
398
|
+
};
|
|
399
|
+
try {
|
|
400
|
+
const projectionResult = this.projection?.disable?.(next);
|
|
401
|
+
if (projectionResult && typeof projectionResult.then !== 'function') {
|
|
402
|
+
next.projection = { ...next.projection, ...projectionResult };
|
|
403
|
+
}
|
|
404
|
+
} catch (error) {
|
|
405
|
+
next.projection = { ...next.projection, state: 'error', status: 'error', updatedAt: this.clock() };
|
|
406
|
+
next.lastError = error.message;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return next;
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
registerMcp(entry) {
|
|
414
|
+
const normalized = this._normalizeMcp(entry);
|
|
415
|
+
const scopeOptions = { scope: normalized.scope, projectPath: normalized.projectPath };
|
|
416
|
+
const manifest = this._readScope(scopeOptions);
|
|
417
|
+
const mcp = ensureMap(manifest, 'mcp');
|
|
418
|
+
mcp[normalized.controlKey] = normalized;
|
|
419
|
+
this._writeScope(scopeOptions, manifest);
|
|
420
|
+
return clone(normalized);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
getMcp(controlKey, options = {}) {
|
|
424
|
+
if (!controlKey) return null;
|
|
425
|
+
const scopeOptions = this._scopeOptions(options);
|
|
426
|
+
const manifest = this._readScope(scopeOptions);
|
|
427
|
+
const entry = manifest.mcp?.[controlKey];
|
|
428
|
+
return entry ? clone(entry) : null;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
removeMcp({ controlKey, scope = 'user', projectPath = null } = {}) {
|
|
432
|
+
const scopeOptions = normalizeScope(scope, projectPath);
|
|
433
|
+
const manifest = this._readScope(scopeOptions);
|
|
434
|
+
if (!manifest.mcp || !Object.prototype.hasOwnProperty.call(manifest.mcp, controlKey)) return false;
|
|
435
|
+
delete manifest.mcp[controlKey];
|
|
436
|
+
this._writeScope(scopeOptions, manifest);
|
|
437
|
+
return true;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
setMcpPolicy({ platform = null, controlKey, scope = 'user', projectPath = null, enabled, trust } = {}) {
|
|
441
|
+
const scopeOptions = normalizeScope(scope, projectPath);
|
|
442
|
+
const manifest = this._readScope(scopeOptions);
|
|
443
|
+
const current = manifest.mcp?.[controlKey];
|
|
444
|
+
if (!current) throw new Error('MCP control entry not found');
|
|
445
|
+
if (platform && current.platform !== platform) {
|
|
446
|
+
throw new Error('MCP control entry platform does not match the request');
|
|
447
|
+
}
|
|
448
|
+
if (trust !== undefined && !VALID_MCP_TRUST.has(trust)) throw new Error('Invalid MCP trust state');
|
|
449
|
+
if (enabled === true && (trust || current.trust) !== 'approved') {
|
|
450
|
+
return { ...clone(current), status: (trust || current.trust) === 'blocked' ? 'blocked' : 'needs_approval' };
|
|
451
|
+
}
|
|
452
|
+
const next = {
|
|
453
|
+
...current,
|
|
454
|
+
...(enabled !== undefined ? { enabled: enabled === true } : {}),
|
|
455
|
+
...(trust !== undefined ? { trust } : {}),
|
|
456
|
+
updatedAt: this.clock()
|
|
457
|
+
};
|
|
458
|
+
if (next.trust !== 'approved') next.enabled = false;
|
|
459
|
+
manifest.mcp[controlKey] = next;
|
|
460
|
+
this._writeScope(scopeOptions, manifest);
|
|
461
|
+
return clone(next);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
getEffectiveSnapshot({ platform, scope = 'user', projectPath = null } = {}) {
|
|
465
|
+
const scopeOptions = normalizeScope(scope, projectPath);
|
|
466
|
+
const requestedManifest = this._readScope(scopeOptions);
|
|
467
|
+
const requested = Object.values(requestedManifest.skills || {})
|
|
468
|
+
.filter(entry => (
|
|
469
|
+
entry
|
|
470
|
+
&& entry.platform === platform
|
|
471
|
+
&& entry.scope === scopeOptions.scope
|
|
472
|
+
&& (scopeOptions.scope === 'user' ? entry.projectPath === null : entry.projectPath === scopeOptions.projectPath)
|
|
473
|
+
));
|
|
474
|
+
|
|
475
|
+
if (scopeOptions.scope === 'user') {
|
|
476
|
+
return {
|
|
477
|
+
skills: { active: requested.map(clone), inherited: [] },
|
|
478
|
+
mcp: {
|
|
479
|
+
active: Object.values(requestedManifest.mcp || {})
|
|
480
|
+
.filter(entry => entry && entry.platform === platform && entry.scope === 'user' && entry.projectPath === null)
|
|
481
|
+
.map(clone),
|
|
482
|
+
inherited: []
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
const userManifest = this._readScope({ scope: 'user', projectPath: null });
|
|
488
|
+
const userSkills = Object.values(userManifest.skills || {})
|
|
489
|
+
.filter(entry => entry && entry.platform === platform && entry.scope === 'user' && entry.projectPath === null);
|
|
490
|
+
const projectIdentities = new Set(requested.map(skillIdentity));
|
|
491
|
+
const active = [
|
|
492
|
+
...requested,
|
|
493
|
+
...userSkills.filter(entry => !projectIdentities.has(skillIdentity(entry)))
|
|
494
|
+
];
|
|
495
|
+
|
|
496
|
+
const userMcp = Object.values(userManifest.mcp || {})
|
|
497
|
+
.filter(entry => entry && entry.platform === platform && entry.scope === 'user' && entry.projectPath === null);
|
|
498
|
+
const projectMcp = Object.values(requestedManifest.mcp || {})
|
|
499
|
+
.filter(entry => entry && entry.platform === platform && entry.scope === 'project' && entry.projectPath === scopeOptions.projectPath);
|
|
500
|
+
const projectMcpKeys = new Set(projectMcp.map(entry => entry.controlKey));
|
|
501
|
+
return {
|
|
502
|
+
skills: { active: active.map(clone), inherited: userSkills.map(clone) },
|
|
503
|
+
mcp: {
|
|
504
|
+
active: [
|
|
505
|
+
...projectMcp,
|
|
506
|
+
...userMcp.filter(entry => !projectMcpKeys.has(entry.controlKey))
|
|
507
|
+
].map(clone),
|
|
508
|
+
inherited: userMcp.map(clone)
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
reconcile({ platform, scope = 'user', projectPath = null } = {}) {
|
|
514
|
+
const snapshot = this.getEffectiveSnapshot({ platform, scope, projectPath });
|
|
515
|
+
const results = [];
|
|
516
|
+
const owners = new Map();
|
|
517
|
+
for (const entry of snapshot.skills.active) {
|
|
518
|
+
if (!entry.managed || !entry.enabled || entry.trust !== 'approved' || entry.artifact?.state !== 'ready') continue;
|
|
519
|
+
const targetKey = this._skillTargetKey(entry);
|
|
520
|
+
if (owners.has(targetKey)) {
|
|
521
|
+
results.push({
|
|
522
|
+
controlKey: entry.controlKey,
|
|
523
|
+
status: 'conflict',
|
|
524
|
+
conflictWith: owners.get(targetKey)
|
|
525
|
+
});
|
|
526
|
+
continue;
|
|
527
|
+
}
|
|
528
|
+
try {
|
|
529
|
+
const projection = this.projection?.enable?.(entry);
|
|
530
|
+
if (projection?.status === 'unsupported' || projection?.state === 'unsupported') {
|
|
531
|
+
results.push({ controlKey: entry.controlKey, status: 'unsupported' });
|
|
532
|
+
continue;
|
|
533
|
+
}
|
|
534
|
+
if (projection?.status === 'conflict' || projection?.state === 'conflict') {
|
|
535
|
+
results.push({
|
|
536
|
+
controlKey: entry.controlKey,
|
|
537
|
+
status: 'conflict',
|
|
538
|
+
conflictWith: projection.conflictWith || 'unknown'
|
|
539
|
+
});
|
|
540
|
+
continue;
|
|
541
|
+
}
|
|
542
|
+
owners.set(targetKey, entry.controlKey);
|
|
543
|
+
results.push({ controlKey: entry.controlKey, status: 'enabled' });
|
|
544
|
+
} catch (error) {
|
|
545
|
+
results.push({ controlKey: entry.controlKey, status: 'error', error: error.message });
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
return { ...snapshot, projection: results };
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
module.exports = {
|
|
552
|
+
EffectiveControlService,
|
|
553
|
+
VALID_SCOPES,
|
|
554
|
+
VALID_TRUST,
|
|
555
|
+
deriveMcpPolicy,
|
|
556
|
+
DEFAULT_CONTROL_MANIFEST
|
|
557
|
+
};
|