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,272 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs/promises');
|
|
4
|
+
const { constants: FS_CONSTANTS } = require('fs');
|
|
5
|
+
const crypto = require('crypto');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
|
|
8
|
+
let temporaryFileCounter = 0;
|
|
9
|
+
const NOFOLLOW_FLAG = FS_CONSTANTS.O_NOFOLLOW || 0;
|
|
10
|
+
|
|
11
|
+
function createFailure({ platform, capability, operation, error }) {
|
|
12
|
+
const result = {
|
|
13
|
+
status: 'failed',
|
|
14
|
+
platform,
|
|
15
|
+
capability,
|
|
16
|
+
operation,
|
|
17
|
+
error: error && error.message ? error.message : String(error)
|
|
18
|
+
};
|
|
19
|
+
if (error) Object.defineProperty(result, 'cause', { value: error, enumerable: false });
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function isInside(root, candidate) {
|
|
24
|
+
const relative = path.relative(path.resolve(root), path.resolve(candidate));
|
|
25
|
+
return relative === '' || (relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function isSystemAlias(current, realpath) {
|
|
29
|
+
return (current === '/var' && realpath === '/private/var') ||
|
|
30
|
+
(current === '/tmp' && realpath === '/private/tmp') ||
|
|
31
|
+
(current === '/etc' && realpath === '/private/etc');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function canonicalPath(fsImpl, target) {
|
|
35
|
+
const resolved = path.resolve(target);
|
|
36
|
+
if (typeof fsImpl.realpath !== 'function') return resolved;
|
|
37
|
+
const missing = [];
|
|
38
|
+
let current = resolved;
|
|
39
|
+
while (true) {
|
|
40
|
+
try {
|
|
41
|
+
return path.join(await fsImpl.realpath(current), ...missing.reverse());
|
|
42
|
+
} catch (error) {
|
|
43
|
+
if (error.code !== 'ENOENT') throw error;
|
|
44
|
+
const parent = path.dirname(current);
|
|
45
|
+
if (parent === current) throw error;
|
|
46
|
+
missing.push(path.basename(current));
|
|
47
|
+
current = parent;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function assertSafePath(fsImpl, target, home, labels, allowMissing = false) {
|
|
53
|
+
if (typeof fsImpl.lstat !== 'function') return;
|
|
54
|
+
const checkComponents = async value => {
|
|
55
|
+
const resolved = path.resolve(value);
|
|
56
|
+
const root = path.parse(resolved).root;
|
|
57
|
+
const parts = path.relative(root, resolved).split(path.sep).filter(Boolean);
|
|
58
|
+
let current = root;
|
|
59
|
+
let missing = false;
|
|
60
|
+
for (const part of parts) {
|
|
61
|
+
current = path.join(current, part);
|
|
62
|
+
try {
|
|
63
|
+
const stat = await fsImpl.lstat(current);
|
|
64
|
+
if (typeof stat.isSymbolicLink === 'function' && stat.isSymbolicLink()) {
|
|
65
|
+
const real = typeof fsImpl.realpath === 'function' ? await fsImpl.realpath(current) : '';
|
|
66
|
+
if (!isSystemAlias(current, real)) throw new Error(labels.pathContainsSymlink(current));
|
|
67
|
+
}
|
|
68
|
+
} catch (error) {
|
|
69
|
+
if (error.code !== 'ENOENT') throw error;
|
|
70
|
+
missing = true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (missing && !allowMissing) {
|
|
74
|
+
const error = new Error(labels.pathDoesNotExist(resolved));
|
|
75
|
+
error.code = 'ENOENT';
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
if (!home) {
|
|
80
|
+
await checkComponents(target);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
await checkComponents(home);
|
|
84
|
+
await checkComponents(target);
|
|
85
|
+
const canonicalHome = await canonicalPath(fsImpl, home);
|
|
86
|
+
const canonicalTarget = await canonicalPath(fsImpl, target);
|
|
87
|
+
if (!isInside(canonicalHome, canonicalTarget)) throw new Error(labels.mappingEscapesHome);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function createCanonicalTarget(fsImpl, target, home, labels, allowMissing) {
|
|
91
|
+
await assertSafePath(fsImpl, target, home, labels, allowMissing);
|
|
92
|
+
const canonicalHome = home ? await canonicalPath(fsImpl, home) : null;
|
|
93
|
+
const canonicalTarget = await canonicalPath(fsImpl, target);
|
|
94
|
+
const canonicalParent = await canonicalPath(fsImpl, path.dirname(target));
|
|
95
|
+
if (canonicalHome && (!isInside(canonicalHome, canonicalParent) || !isInside(canonicalHome, canonicalTarget))) {
|
|
96
|
+
throw new Error(labels.mappingEscapesHome);
|
|
97
|
+
}
|
|
98
|
+
return { target: canonicalTarget, parent: canonicalParent, home: canonicalHome };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async function revalidateCanonicalTarget(fsImpl, canonical, target, home, labels) {
|
|
102
|
+
const currentParent = await canonicalPath(fsImpl, path.dirname(target));
|
|
103
|
+
const currentTarget = await canonicalPath(fsImpl, target);
|
|
104
|
+
const currentHome = home ? await canonicalPath(fsImpl, home) : null;
|
|
105
|
+
if (currentParent !== canonical.parent || currentTarget !== canonical.target || currentHome !== canonical.home) {
|
|
106
|
+
throw new Error(labels.targetChanged);
|
|
107
|
+
}
|
|
108
|
+
await assertSafePath(fsImpl, target, home, labels, true);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function sameFileIdentity(first, second) {
|
|
112
|
+
return first && second && first.dev !== undefined && first.ino !== undefined &&
|
|
113
|
+
first.dev === second.dev && first.ino === second.ino;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function readFileByDescriptor(fsImpl, target, home, labels) {
|
|
117
|
+
const canonical = await createCanonicalTarget(fsImpl, target, home, labels, false);
|
|
118
|
+
if (typeof fsImpl.open !== 'function') throw new Error(labels.descriptorReadUnavailable);
|
|
119
|
+
const handle = await fsImpl.open(canonical.target, FS_CONSTANTS.O_RDONLY | NOFOLLOW_FLAG);
|
|
120
|
+
try {
|
|
121
|
+
const descriptorStat = typeof handle.stat === 'function'
|
|
122
|
+
? await handle.stat()
|
|
123
|
+
: (typeof fsImpl.fstat === 'function' ? await fsImpl.fstat(handle.fd) : null);
|
|
124
|
+
if (!descriptorStat) throw new Error(labels.descriptorIdentityUnavailable);
|
|
125
|
+
await revalidateCanonicalTarget(fsImpl, canonical, target, home, labels);
|
|
126
|
+
const pathStat = await fsImpl.lstat(canonical.target);
|
|
127
|
+
if (typeof pathStat.isSymbolicLink === 'function' && pathStat.isSymbolicLink()) {
|
|
128
|
+
throw new Error(labels.pathContainsSymlink(canonical.target));
|
|
129
|
+
}
|
|
130
|
+
if (!sameFileIdentity(descriptorStat, pathStat)) throw new Error(labels.targetChanged);
|
|
131
|
+
return await handle.readFile('utf8');
|
|
132
|
+
} finally {
|
|
133
|
+
await handle.close();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async function ensureDirectory(fsImpl, directory, canonicalHome, labels) {
|
|
138
|
+
if (typeof fsImpl.lstat !== 'function') {
|
|
139
|
+
await fsImpl.mkdir(directory, { recursive: true });
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const resolved = path.resolve(directory);
|
|
143
|
+
const root = path.parse(resolved).root;
|
|
144
|
+
let current = root;
|
|
145
|
+
const assertDirectory = async (component, stat) => {
|
|
146
|
+
if (typeof stat.isSymbolicLink === 'function' && stat.isSymbolicLink()) {
|
|
147
|
+
const real = typeof fsImpl.realpath === 'function' ? await fsImpl.realpath(component) : '';
|
|
148
|
+
if (!isSystemAlias(component, real)) throw new Error(labels.pathComponentNotDirectory(component));
|
|
149
|
+
} else if (typeof stat.isDirectory === 'function' && !stat.isDirectory()) {
|
|
150
|
+
throw new Error(labels.pathComponentNotDirectory(component));
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
for (const part of path.relative(root, resolved).split(path.sep).filter(Boolean)) {
|
|
154
|
+
current = path.join(current, part);
|
|
155
|
+
try {
|
|
156
|
+
await assertDirectory(current, await fsImpl.lstat(current));
|
|
157
|
+
} catch (error) {
|
|
158
|
+
if (error.code !== 'ENOENT') throw error;
|
|
159
|
+
try {
|
|
160
|
+
await fsImpl.mkdir(current, { mode: 0o700 });
|
|
161
|
+
} catch (mkdirError) {
|
|
162
|
+
if (mkdirError.code !== 'EEXIST') throw mkdirError;
|
|
163
|
+
}
|
|
164
|
+
await assertDirectory(current, await fsImpl.lstat(current));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (canonicalHome && !isInside(canonicalHome, await canonicalPath(fsImpl, resolved))) {
|
|
168
|
+
throw new Error(labels.mappingEscapesHome);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
async function atomicWrite(fsImpl, target, content, canonicalHome, labels) {
|
|
173
|
+
const parent = path.dirname(target);
|
|
174
|
+
const tempName = `.${path.basename(target)}.${process.pid}.${Date.now()}.${temporaryFileCounter++}.${crypto.randomBytes(8).toString('hex')}.tmp`;
|
|
175
|
+
let temporary;
|
|
176
|
+
let handle;
|
|
177
|
+
try {
|
|
178
|
+
const canonicalParent = await canonicalPath(fsImpl, parent);
|
|
179
|
+
if (canonicalHome && !isInside(canonicalHome, canonicalParent)) throw new Error(labels.mappingEscapesHome);
|
|
180
|
+
// Node has no portable openat/renameat2. Revalidation immediately before
|
|
181
|
+
// path-based rename bounds the unavoidable ancestor-swap window.
|
|
182
|
+
temporary = path.join(canonicalParent, tempName);
|
|
183
|
+
if (typeof fsImpl.open === 'function') {
|
|
184
|
+
handle = await fsImpl.open(temporary, 'wx', 0o600);
|
|
185
|
+
await handle.writeFile(content, 'utf8');
|
|
186
|
+
await handle.close();
|
|
187
|
+
handle = undefined;
|
|
188
|
+
} else {
|
|
189
|
+
await fsImpl.writeFile(temporary, content, { encoding: 'utf8', flag: 'wx', mode: 0o600 });
|
|
190
|
+
}
|
|
191
|
+
await assertSafePath(fsImpl, temporary, canonicalHome, labels, false);
|
|
192
|
+
if (await canonicalPath(fsImpl, temporary) !== temporary) throw new Error(labels.temporaryPathChanged);
|
|
193
|
+
await assertSafePath(fsImpl, target, canonicalHome, labels, true);
|
|
194
|
+
await revalidateCanonicalTarget(fsImpl, { target, parent: canonicalParent, home: canonicalHome }, target, canonicalHome, labels);
|
|
195
|
+
await fsImpl.rename(temporary, target);
|
|
196
|
+
} finally {
|
|
197
|
+
if (handle) { try { await handle.close(); } catch { /* best effort close */ } }
|
|
198
|
+
try {
|
|
199
|
+
if (temporary && typeof fsImpl.rm === 'function') await fsImpl.rm(temporary, { force: true });
|
|
200
|
+
else if (temporary && typeof fsImpl.unlink === 'function') await fsImpl.unlink(temporary);
|
|
201
|
+
} catch { /* preserve typed write failure */ }
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function createSecureFileDriver({
|
|
206
|
+
platform,
|
|
207
|
+
capability,
|
|
208
|
+
manifest = {},
|
|
209
|
+
fsImpl = fs,
|
|
210
|
+
labels,
|
|
211
|
+
resolveTarget,
|
|
212
|
+
deserialize = value => value,
|
|
213
|
+
serialize = value => value,
|
|
214
|
+
validateWrite = () => {}
|
|
215
|
+
} = {}) {
|
|
216
|
+
const read = async () => {
|
|
217
|
+
try {
|
|
218
|
+
const target = resolveTarget(manifest);
|
|
219
|
+
return deserialize(await readFileByDescriptor(fsImpl, target, manifest.paths && manifest.paths.home, labels));
|
|
220
|
+
} catch (error) {
|
|
221
|
+
return createFailure({ platform, capability, operation: 'read', error });
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const write = async value => {
|
|
226
|
+
try {
|
|
227
|
+
const target = resolveTarget(manifest);
|
|
228
|
+
validateWrite(value);
|
|
229
|
+
const encoded = serialize(value);
|
|
230
|
+
if (typeof encoded !== 'string') throw new Error(labels.serializedValueMustBeString);
|
|
231
|
+
const home = manifest.paths && manifest.paths.home;
|
|
232
|
+
const initial = await createCanonicalTarget(fsImpl, target, home, labels, true);
|
|
233
|
+
await ensureDirectory(fsImpl, initial.parent, initial.home, labels);
|
|
234
|
+
const canonical = await createCanonicalTarget(fsImpl, target, home, labels, true);
|
|
235
|
+
await atomicWrite(fsImpl, canonical.target, encoded, canonical.home, labels);
|
|
236
|
+
return { status: 'ok', platform, capability, operation: 'write', target };
|
|
237
|
+
} catch (error) {
|
|
238
|
+
return createFailure({ platform, capability, operation: 'write', error });
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
const remove = async () => {
|
|
243
|
+
try {
|
|
244
|
+
const target = resolveTarget(manifest);
|
|
245
|
+
const home = manifest.paths && manifest.paths.home;
|
|
246
|
+
const canonical = await createCanonicalTarget(fsImpl, target, home, labels, true);
|
|
247
|
+
await revalidateCanonicalTarget(fsImpl, canonical, target, home, labels);
|
|
248
|
+
await fsImpl.rm(canonical.target, { force: true });
|
|
249
|
+
return { status: 'ok', platform, capability, operation: 'remove', target };
|
|
250
|
+
} catch (error) {
|
|
251
|
+
return createFailure({ platform, capability, operation: 'remove', error });
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
return { platform, capability, read, write, remove };
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
module.exports = {
|
|
259
|
+
createSecureFileDriver,
|
|
260
|
+
// exported for focused internal reuse if needed by future secure drivers/tests
|
|
261
|
+
_test: {
|
|
262
|
+
createFailure,
|
|
263
|
+
isInside,
|
|
264
|
+
canonicalPath,
|
|
265
|
+
assertSafePath,
|
|
266
|
+
createCanonicalTarget,
|
|
267
|
+
revalidateCanonicalTarget,
|
|
268
|
+
readFileByDescriptor,
|
|
269
|
+
ensureDirectory,
|
|
270
|
+
atomicWrite
|
|
271
|
+
}
|
|
272
|
+
};
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const Ajv = require('ajv');
|
|
4
|
+
|
|
5
|
+
const { hasRequestCodec, hasResponseCodec } = require('../server/api/platform-api-config');
|
|
6
|
+
|
|
7
|
+
const DRIVER_IDS = new Set([
|
|
8
|
+
'unsupported',
|
|
9
|
+
'generic-jsonl',
|
|
10
|
+
'generic-filesystem',
|
|
11
|
+
'generic-openai-compatible',
|
|
12
|
+
'generic-mcp',
|
|
13
|
+
'generic-prompt',
|
|
14
|
+
'legacy:claude',
|
|
15
|
+
'legacy:codex',
|
|
16
|
+
'legacy:gemini',
|
|
17
|
+
'legacy:opencode',
|
|
18
|
+
'legacy:omp',
|
|
19
|
+
'opencode-conversion',
|
|
20
|
+
'claude-health'
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
const PATH_RESOLVER_IDS = new Set([
|
|
24
|
+
'declarative',
|
|
25
|
+
'claude',
|
|
26
|
+
'codex',
|
|
27
|
+
'gemini',
|
|
28
|
+
'opencode',
|
|
29
|
+
'omp'
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
const API_ROUTE_DESCRIPTOR_SCHEMA = {
|
|
33
|
+
type: 'object',
|
|
34
|
+
additionalProperties: false,
|
|
35
|
+
required: ['path', 'method', 'capability', 'operation', 'request', 'response'],
|
|
36
|
+
properties: {
|
|
37
|
+
path: { type: 'string', pattern: '^/(?:[a-zA-Z0-9_-]+|:[a-zA-Z][a-zA-Z0-9_]*)(?:/(?:[a-zA-Z0-9_-]+|:[a-zA-Z][a-zA-Z0-9_]*))*$' },
|
|
38
|
+
method: { enum: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'] },
|
|
39
|
+
capability: { type: 'string', pattern: '^[a-zA-Z][a-zA-Z0-9_-]*$' },
|
|
40
|
+
operation: { type: 'string', pattern: '^[a-zA-Z][a-zA-Z0-9_-]*$' },
|
|
41
|
+
request: {},
|
|
42
|
+
response: {}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const API_ROUTE_METHODS = new Set(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']);
|
|
47
|
+
|
|
48
|
+
const CAPABILITY_OPERATIONS = Object.freeze({
|
|
49
|
+
api: new Set(['getConfig', 'getConfigAuthProviders', 'getConfigCapabilities', 'getConfigResources']),
|
|
50
|
+
channels: new Set(['applyToSettings', 'bestForRestore', 'catalogMetadata', 'create', 'current', 'enabled', 'getAuth', 'getAuthQuota', 'list', 'models', 'order', 'poolStatus', 'probeModels', 'remove', 'resetHealth', 'speedTest', 'speedTestAll', 'sync', 'syncLocalAuth', 'update']),
|
|
51
|
+
health: new Set(['healthCheck']),
|
|
52
|
+
hooks: new Set(['getHooks', 'saveHooks', 'testHooks']),
|
|
53
|
+
projects: new Set(['createProject', 'deleteProject', 'listProjects', 'saveProjectOrder']),
|
|
54
|
+
sessions: new Set(['batchDelete', 'createSession', 'delete', 'fork', 'launch', 'listSessions', 'messages', 'outline', 'recent', 'saveSessionOrder', 'search', 'searchAcrossProjects', 'status']),
|
|
55
|
+
proxy: new Set(['clearLogs', 'start', 'status', 'stop']),
|
|
56
|
+
conversion: new Set(['convert', 'formats']),
|
|
57
|
+
statistics: new Set(['daily', 'summary', 'today'])
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
const schema = {
|
|
62
|
+
type: 'object',
|
|
63
|
+
required: ['key', 'label', 'command', 'capabilities'],
|
|
64
|
+
additionalProperties: false,
|
|
65
|
+
properties: {
|
|
66
|
+
key: { type: 'string', pattern: '^[a-z0-9][a-z0-9_-]*$' },
|
|
67
|
+
label: { type: 'string', minLength: 1 },
|
|
68
|
+
title: { type: 'string', minLength: 1 },
|
|
69
|
+
command: { type: 'string', minLength: 1 },
|
|
70
|
+
iconToken: { type: 'string', minLength: 1 },
|
|
71
|
+
color: { type: 'string' },
|
|
72
|
+
defaultVisible: { type: 'boolean' },
|
|
73
|
+
defaultEnabled: { type: 'boolean' },
|
|
74
|
+
sortOrder: { type: 'integer' },
|
|
75
|
+
custom: { type: 'boolean' },
|
|
76
|
+
helpLabel: { type: 'string', minLength: 1 },
|
|
77
|
+
terminalColor: { type: 'string', minLength: 1 },
|
|
78
|
+
cliSelectable: { type: 'boolean' },
|
|
79
|
+
portLabel: { type: 'string', minLength: 1 },
|
|
80
|
+
apiBasePath: { type: 'string', minLength: 1 },
|
|
81
|
+
logFile: { type: 'string', minLength: 1 },
|
|
82
|
+
logAliases: { type: 'array', items: { type: 'string', minLength: 1 } },
|
|
83
|
+
logNote: { type: 'string' },
|
|
84
|
+
logColor: { type: 'string', minLength: 1 },
|
|
85
|
+
portKey: { type: 'string', minLength: 1 },
|
|
86
|
+
defaultPort: { type: 'integer', minimum: 1 },
|
|
87
|
+
proxyMode: { enum: ['standard', 'managed'] },
|
|
88
|
+
proxyLabels: { type: 'object', additionalProperties: { type: 'string' } },
|
|
89
|
+
modelConfig: {
|
|
90
|
+
type: 'object',
|
|
91
|
+
additionalProperties: false,
|
|
92
|
+
properties: {
|
|
93
|
+
catalogKey: { type: 'string', pattern: '^[a-z0-9][a-z0-9_-]*$' }
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
agentCapabilities: {
|
|
97
|
+
type: 'object',
|
|
98
|
+
additionalProperties: false,
|
|
99
|
+
properties: {
|
|
100
|
+
projectScope: { type: 'boolean' },
|
|
101
|
+
repoOperations: { type: 'boolean' }
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
resourceTypes: { type: 'object', additionalProperties: { type: 'boolean' } },
|
|
105
|
+
skillActivation: {
|
|
106
|
+
type: 'object',
|
|
107
|
+
additionalProperties: false,
|
|
108
|
+
required: ['user', 'project'],
|
|
109
|
+
properties: {
|
|
110
|
+
user: {
|
|
111
|
+
type: 'object',
|
|
112
|
+
additionalProperties: false,
|
|
113
|
+
required: ['mode', 'format'],
|
|
114
|
+
properties: {
|
|
115
|
+
mode: { enum: ['native-copy', 'native-filter', 'unsupported'] },
|
|
116
|
+
format: { anyOf: [{ type: 'null' }, { type: 'string', pattern: '^[a-z][a-z0-9-]*-skill-v[0-9]+$' }] }
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
project: {
|
|
120
|
+
type: 'object',
|
|
121
|
+
additionalProperties: false,
|
|
122
|
+
required: ['mode', 'format'],
|
|
123
|
+
properties: {
|
|
124
|
+
mode: { enum: ['native-copy', 'native-filter', 'unsupported'] },
|
|
125
|
+
format: { anyOf: [{ type: 'null' }, { type: 'string', pattern: '^[a-z][a-z0-9-]*-skill-v[0-9]+$' }] }
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
auth: {
|
|
131
|
+
type: 'object',
|
|
132
|
+
additionalProperties: false,
|
|
133
|
+
properties: {
|
|
134
|
+
modes: {
|
|
135
|
+
type: 'array',
|
|
136
|
+
minItems: 1,
|
|
137
|
+
uniqueItems: true,
|
|
138
|
+
items: { enum: ['api_key', 'oauth', 'none'] }
|
|
139
|
+
},
|
|
140
|
+
oauth: {
|
|
141
|
+
type: 'object',
|
|
142
|
+
additionalProperties: false,
|
|
143
|
+
required: ['adapter', 'policy'],
|
|
144
|
+
properties: {
|
|
145
|
+
adapter: { type: 'string', pattern: '^[a-z][a-z0-9_-]*$' },
|
|
146
|
+
policy: { enum: ['single-enabled', 'mixed'] },
|
|
147
|
+
quota: { type: 'string', pattern: '^[a-z][a-z0-9_-]*$' }
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
promptFile: { type: ['string', 'null'] },
|
|
153
|
+
promptLabel: { type: 'string', minLength: 1 },
|
|
154
|
+
mcpFormat: { enum: ['json'] },
|
|
155
|
+
statisticsPath: { type: 'string', minLength: 1 },
|
|
156
|
+
paths: { type: 'object', additionalProperties: { type: 'string' } },
|
|
157
|
+
pathResolverId: { enum: [...PATH_RESOLVER_IDS] },
|
|
158
|
+
sessionMapping: { type: 'object', additionalProperties: { type: 'string' } },
|
|
159
|
+
sessionGlob: { type: 'string', minLength: 1 },
|
|
160
|
+
resourceMappings: { type: 'object', additionalProperties: { type: 'string' } },
|
|
161
|
+
projectResources: {
|
|
162
|
+
type: 'object',
|
|
163
|
+
additionalProperties: false,
|
|
164
|
+
required: ['instruction', 'skills', 'mcp'],
|
|
165
|
+
properties: {
|
|
166
|
+
instruction: {
|
|
167
|
+
type: 'object',
|
|
168
|
+
additionalProperties: false,
|
|
169
|
+
required: ['path'],
|
|
170
|
+
properties: {
|
|
171
|
+
path: { type: ['string', 'null'] }
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
skills: {
|
|
175
|
+
type: 'object',
|
|
176
|
+
additionalProperties: false,
|
|
177
|
+
required: ['canonicalRoot', 'readRoots'],
|
|
178
|
+
properties: {
|
|
179
|
+
canonicalRoot: { type: 'string', minLength: 1 },
|
|
180
|
+
readRoots: {
|
|
181
|
+
type: 'array',
|
|
182
|
+
minItems: 1,
|
|
183
|
+
items: { type: 'string', minLength: 1 }
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
agents: {
|
|
188
|
+
type: 'object',
|
|
189
|
+
additionalProperties: false,
|
|
190
|
+
required: ['canonicalRoot'],
|
|
191
|
+
properties: {
|
|
192
|
+
canonicalRoot: { type: ['string', 'null'] }
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
commands: {
|
|
196
|
+
type: 'object',
|
|
197
|
+
additionalProperties: false,
|
|
198
|
+
required: ['canonicalRoot', 'format'],
|
|
199
|
+
properties: {
|
|
200
|
+
canonicalRoot: { type: ['string', 'null'] },
|
|
201
|
+
format: { type: 'string', minLength: 1 }
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
plugins: {
|
|
205
|
+
type: 'object',
|
|
206
|
+
additionalProperties: false,
|
|
207
|
+
required: ['path'],
|
|
208
|
+
properties: {
|
|
209
|
+
path: { type: ['string', 'null'] },
|
|
210
|
+
format: { type: 'string', minLength: 1 }
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
mcp: {
|
|
214
|
+
type: 'object',
|
|
215
|
+
additionalProperties: false,
|
|
216
|
+
required: ['path', 'format'],
|
|
217
|
+
properties: {
|
|
218
|
+
path: { type: ['string', 'null'] },
|
|
219
|
+
format: { enum: ['none', 'claude-json', 'codex-toml', 'gemini-json', 'opencode-json', 'omp-json'] }
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
api: {
|
|
225
|
+
type: 'object',
|
|
226
|
+
additionalProperties: false,
|
|
227
|
+
required: ['prefix'],
|
|
228
|
+
properties: {
|
|
229
|
+
prefix: { type: 'string', pattern: '^[a-z0-9][a-z0-9_-]*$' },
|
|
230
|
+
rootAlias: { type: 'boolean' },
|
|
231
|
+
rootAliasPaths: {
|
|
232
|
+
type: 'array',
|
|
233
|
+
items: { type: 'string', pattern: '^[a-z][a-z0-9_-]*$' }
|
|
234
|
+
},
|
|
235
|
+
routes: {
|
|
236
|
+
type: 'array',
|
|
237
|
+
items: API_ROUTE_DESCRIPTOR_SCHEMA
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
capabilities: { type: 'object', additionalProperties: { enum: [...DRIVER_IDS] } }
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
const validate = new Ajv({ allErrors: true, strict: false }).compile(schema);
|
|
246
|
+
|
|
247
|
+
function isSafeRelativePath(value) {
|
|
248
|
+
if (typeof value !== 'string' || !value.trim()) return false;
|
|
249
|
+
const raw = value.trim().replace(/\\/g, '/');
|
|
250
|
+
if (raw.startsWith('/') || /^[a-zA-Z]:\//.test(raw) || raw.includes('\0')) return false;
|
|
251
|
+
const normalized = raw.replace(/^(\.\/)+/, '');
|
|
252
|
+
const segments = normalized.split('/');
|
|
253
|
+
return segments.every(segment => segment && segment !== '..');
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function validateProjectResources(manifest, errors) {
|
|
257
|
+
const resources = manifest?.projectResources;
|
|
258
|
+
if (!resources) return;
|
|
259
|
+
|
|
260
|
+
const instructionPath = resources.instruction?.path;
|
|
261
|
+
if (instructionPath !== null && !isSafeRelativePath(instructionPath)) {
|
|
262
|
+
errors.push({ instancePath: '/projectResources/instruction/path', message: 'must be a safe relative path or null' });
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const skills = resources.skills;
|
|
266
|
+
if (skills && !isSafeRelativePath(skills.canonicalRoot)) {
|
|
267
|
+
errors.push({ instancePath: '/projectResources/skills/canonicalRoot', message: 'must be a safe relative path' });
|
|
268
|
+
}
|
|
269
|
+
for (const [index, root] of (skills?.readRoots || []).entries()) {
|
|
270
|
+
if (!isSafeRelativePath(root)) {
|
|
271
|
+
errors.push({ instancePath: `/projectResources/skills/readRoots/${index}`, message: 'must be a safe relative path' });
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
for (const resourceType of ['agents', 'commands']) {
|
|
276
|
+
const root = resources[resourceType]?.canonicalRoot;
|
|
277
|
+
if (root !== null && root !== undefined && !isSafeRelativePath(root)) {
|
|
278
|
+
errors.push({ instancePath: `/projectResources/${resourceType}/canonicalRoot`, message: 'must be a safe relative path or null' });
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const pluginPath = resources.plugins?.path;
|
|
283
|
+
if (pluginPath !== null && pluginPath !== undefined && !isSafeRelativePath(pluginPath)) {
|
|
284
|
+
errors.push({ instancePath: '/projectResources/plugins/path', message: 'must be a safe relative path or null' });
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const mcpPath = resources.mcp?.path;
|
|
288
|
+
if (mcpPath !== null && !isSafeRelativePath(mcpPath)) {
|
|
289
|
+
errors.push({ instancePath: '/projectResources/mcp/path', message: 'must be a safe relative path or null' });
|
|
290
|
+
}
|
|
291
|
+
if (mcpPath === null && resources.mcp?.format !== 'none') {
|
|
292
|
+
errors.push({ instancePath: '/projectResources/mcp/format', message: 'must be none when mcp path is null' });
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function validateApiRoutes(manifest, errors) {
|
|
297
|
+
const api = manifest?.api;
|
|
298
|
+
if (!api?.routes) return;
|
|
299
|
+
|
|
300
|
+
const seen = new Set();
|
|
301
|
+
const firstSegments = new Set();
|
|
302
|
+
for (const [index, route] of api.routes.entries()) {
|
|
303
|
+
if (!route || typeof route !== 'object') continue;
|
|
304
|
+
const key = `${route.method} ${route.path}`;
|
|
305
|
+
if (seen.has(key)) {
|
|
306
|
+
errors.push({ instancePath: `/api/routes/${index}`, message: 'must not duplicate method and path' });
|
|
307
|
+
}
|
|
308
|
+
seen.add(key);
|
|
309
|
+
|
|
310
|
+
const [firstSegment] = String(route.path || '').split('/').filter(Boolean);
|
|
311
|
+
if (firstSegment && !firstSegment.startsWith(':')) firstSegments.add(firstSegment);
|
|
312
|
+
if (!API_ROUTE_METHODS.has(route.method)) continue;
|
|
313
|
+
if (!manifest.capabilities || !Object.prototype.hasOwnProperty.call(manifest.capabilities, route.capability)) {
|
|
314
|
+
errors.push({
|
|
315
|
+
instancePath: `/api/routes/${index}/capability`,
|
|
316
|
+
message: 'must reference a declared capability'
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
const operations = CAPABILITY_OPERATIONS[route.capability];
|
|
320
|
+
if (!operations || !operations.has(route.operation)) {
|
|
321
|
+
errors.push({
|
|
322
|
+
instancePath: `/api/routes/${index}/operation`,
|
|
323
|
+
message: `must be a supported operation for capability ${route.capability}`
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
if (!hasRequestCodec(route.request)) {
|
|
327
|
+
errors.push({
|
|
328
|
+
instancePath: `/api/routes/${index}/request`,
|
|
329
|
+
message: 'must reference a known request codec'
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
if (!hasResponseCodec(route.response)) {
|
|
333
|
+
errors.push({
|
|
334
|
+
instancePath: `/api/routes/${index}/response`,
|
|
335
|
+
message: 'must reference a known response codec'
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
for (const [index, alias] of (api.rootAliasPaths || []).entries()) {
|
|
341
|
+
if (!firstSegments.has(alias)) {
|
|
342
|
+
errors.push({
|
|
343
|
+
instancePath: `/api/rootAliasPaths/${index}`,
|
|
344
|
+
message: 'must reference a declared route path'
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
function validateManifest(manifest) {
|
|
351
|
+
const valid = validate(manifest);
|
|
352
|
+
const errors = valid ? [] : (validate.errors || []).slice();
|
|
353
|
+
const allowed = {
|
|
354
|
+
'generic-jsonl': new Set(['sessions']),
|
|
355
|
+
'generic-filesystem': new Set(['resourceSync']),
|
|
356
|
+
'generic-openai-compatible': new Set(['channels']),
|
|
357
|
+
'generic-mcp': new Set(['mcp']),
|
|
358
|
+
'generic-prompt': new Set(['prompts'])
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
for (const [capability, driver] of Object.entries(manifest && manifest.capabilities || {})) {
|
|
362
|
+
if (allowed[driver] && !allowed[driver].has(capability)) {
|
|
363
|
+
errors.push({
|
|
364
|
+
instancePath: `/capabilities/${capability}`,
|
|
365
|
+
message: `${driver} only supports ${[...allowed[driver]].join(', ')}`
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
if (driver === 'generic-mcp') {
|
|
369
|
+
if (manifest.mcpFormat !== 'json') {
|
|
370
|
+
errors.push({ instancePath: '/mcpFormat', message: 'generic-mcp requires mcpFormat json' });
|
|
371
|
+
}
|
|
372
|
+
if (typeof manifest.resourceMappings?.mcp !== 'string' || !manifest.resourceMappings.mcp.trim()) {
|
|
373
|
+
errors.push({ instancePath: '/resourceMappings/mcp', message: 'generic-mcp requires a non-empty resourceMappings.mcp' });
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (driver === 'generic-prompt' && !(
|
|
377
|
+
(typeof manifest.resourceMappings?.prompts === 'string' && manifest.resourceMappings.prompts.trim()) ||
|
|
378
|
+
(typeof manifest.promptFile === 'string' && manifest.promptFile.trim())
|
|
379
|
+
)) {
|
|
380
|
+
errors.push({
|
|
381
|
+
instancePath: '/resourceMappings/prompts',
|
|
382
|
+
message: 'generic-prompt requires a non-empty resourceMappings.prompts or promptFile'
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
validateApiRoutes(manifest, errors);
|
|
388
|
+
return { valid: errors.length === 0, errors };
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function normalizeManifestError(errors = []) {
|
|
392
|
+
return errors.map(error => {
|
|
393
|
+
const property = error.params && error.params.additionalProperty ? ` ${error.params.additionalProperty}` : '';
|
|
394
|
+
return `${error.instancePath || error.dataPath || '/'}${property} ${error.message}`;
|
|
395
|
+
}).join('; ');
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
module.exports = { DRIVER_IDS, PATH_RESOLVER_IDS, CAPABILITY_OPERATIONS, schema, validateManifest, normalizeManifestError };
|