omnicell-router 0.2.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -10
- package/README.zh-CN.md +57 -8
- package/RELEASING.md +6 -0
- package/RELEASING.zh-CN.md +5 -0
- package/backend/dist/auth/api-keys.d.ts +14 -2
- package/backend/dist/auth/api-keys.js +26 -14
- package/backend/dist/auth/model-access.d.ts +27 -10
- package/backend/dist/auth/model-access.js +34 -17
- package/backend/dist/capture/migrate/engine.d.ts +38 -0
- package/backend/dist/capture/migrate/engine.js +307 -0
- package/backend/dist/capture/migrate/index.d.ts +18 -0
- package/backend/dist/capture/migrate/index.js +18 -0
- package/backend/dist/capture/migrate/migrator.d.ts +113 -0
- package/backend/dist/capture/migrate/migrator.js +16 -0
- package/backend/dist/capture/migrate/registry.d.ts +16 -0
- package/backend/dist/capture/migrate/registry.js +19 -0
- package/backend/dist/capture/migrate/steps/v1-to-v2.d.ts +86 -0
- package/backend/dist/capture/migrate/steps/v1-to-v2.js +396 -0
- package/backend/dist/capture/recorder.d.ts +422 -272
- package/backend/dist/capture/recorder.js +873 -417
- package/backend/dist/capture/turn-boundary.d.ts +17 -0
- package/backend/dist/capture/turn-boundary.js +31 -0
- package/backend/dist/cli/clients/base.d.ts +158 -23
- package/backend/dist/cli/clients/base.js +150 -4
- package/backend/dist/cli/clients/claude.d.ts +3 -2
- package/backend/dist/cli/clients/claude.js +4 -3
- package/backend/dist/cli/clients/codex.d.ts +3 -2
- package/backend/dist/cli/clients/codex.js +4 -3
- package/backend/dist/cli/clients/core-adapters.d.ts +25 -0
- package/backend/dist/cli/clients/core-adapters.js +44 -0
- package/backend/dist/cli/clients/dsh.d.ts +5 -3
- package/backend/dist/cli/clients/dsh.js +29 -18
- package/backend/dist/cli/clients/grok.d.ts +53 -0
- package/backend/dist/cli/clients/grok.js +249 -0
- package/backend/dist/cli/clients/index.d.ts +28 -19
- package/backend/dist/cli/clients/index.js +156 -58
- package/backend/dist/cli/clients/kimi.d.ts +75 -0
- package/backend/dist/cli/clients/kimi.js +316 -0
- package/backend/dist/cli/clients/launcher.d.ts +48 -0
- package/backend/dist/cli/clients/launcher.js +41 -0
- package/backend/dist/cli/clients/omp.d.ts +43 -0
- package/backend/dist/cli/clients/omp.js +537 -0
- package/backend/dist/cli/clients/openclaw.d.ts +55 -0
- package/backend/dist/cli/clients/openclaw.js +525 -0
- package/backend/dist/cli/clients/opencode.d.ts +7 -20
- package/backend/dist/cli/clients/opencode.js +32 -159
- package/backend/dist/cli/clients/pi.d.ts +7 -21
- package/backend/dist/cli/clients/pi.js +87 -229
- package/backend/dist/cli/clients/plugin-adapters.d.ts +20 -0
- package/backend/dist/cli/clients/plugin-adapters.js +88 -0
- package/backend/dist/cli/clients/reserved.d.ts +51 -0
- package/backend/dist/cli/clients/reserved.js +53 -0
- package/backend/dist/cli/clients/workbuddy.d.ts +31 -0
- package/backend/dist/cli/clients/workbuddy.js +259 -0
- package/backend/dist/cli/daemon.d.ts +105 -27
- package/backend/dist/cli/daemon.js +509 -151
- package/backend/dist/cli/index.d.ts +6 -1
- package/backend/dist/cli/index.js +238 -22
- package/backend/dist/cli/paths.d.ts +86 -0
- package/backend/dist/cli/paths.js +269 -0
- package/backend/dist/cli/shim.d.ts +47 -1
- package/backend/dist/cli/shim.js +180 -13
- package/backend/dist/cli/types.d.ts +102 -16
- package/backend/dist/cli/types.js +5 -4
- package/backend/dist/compression/caveman-prompts.d.ts +1 -1
- package/backend/dist/compression/caveman.d.ts +2 -16
- package/backend/dist/compression/caveman.js +25 -37
- package/backend/dist/compression/headroom.d.ts +4 -3
- package/backend/dist/compression/headroom.js +2 -2
- package/backend/dist/compression/index.d.ts +5 -26
- package/backend/dist/compression/index.js +79 -17
- package/backend/dist/compression/tool-output.d.ts +2 -20
- package/backend/dist/compression/tool-output.js +40 -47
- package/backend/dist/config/comments-en.d.ts +17 -0
- package/backend/dist/config/comments-en.js +232 -0
- package/backend/dist/config/comments-zh.d.ts +10 -0
- package/backend/dist/config/comments-zh.js +217 -0
- package/backend/dist/config/defaults.d.ts +190 -2
- package/backend/dist/config/defaults.js +191 -2
- package/backend/dist/config/env-archive.js +77 -38
- package/backend/dist/config/env.d.ts +4 -0
- package/backend/dist/config/env.js +16 -0
- package/backend/dist/config/index.d.ts +48 -12
- package/backend/dist/config/index.js +794 -368
- package/backend/dist/config/layout.d.ts +29 -0
- package/backend/dist/config/layout.js +86 -0
- package/backend/dist/config/migrations/v0-to-v1.d.ts +105 -0
- package/backend/dist/config/migrations/v0-to-v1.js +78 -0
- package/backend/dist/config/migrations/v1-to-v2.d.ts +14 -0
- package/backend/dist/config/migrations/v1-to-v2.js +41 -0
- package/backend/dist/config/migrations/v2-to-v3.d.ts +34 -0
- package/backend/dist/config/migrations/v2-to-v3.js +66 -0
- package/backend/dist/config/migrations/v3-to-v4.d.ts +34 -0
- package/backend/dist/config/migrations/v3-to-v4.js +61 -0
- package/backend/dist/config/runtime.d.ts +13 -0
- package/backend/dist/config/runtime.js +26 -0
- package/backend/dist/config/schema.d.ts +28 -0
- package/backend/dist/config/schema.js +98 -0
- package/backend/dist/config/types.d.ts +501 -84
- package/backend/dist/forward-proxy/access-log.d.ts +173 -0
- package/backend/dist/forward-proxy/access-log.js +657 -0
- package/backend/dist/forward-proxy/ca-trust.d.ts +42 -0
- package/backend/dist/forward-proxy/ca-trust.js +242 -0
- package/backend/dist/forward-proxy/ca.d.ts +66 -2
- package/backend/dist/forward-proxy/ca.js +146 -11
- package/backend/dist/forward-proxy/caller-context.d.ts +18 -0
- package/backend/dist/forward-proxy/caller-context.js +20 -0
- package/backend/dist/forward-proxy/egress.d.ts +104 -0
- package/backend/dist/forward-proxy/egress.js +280 -0
- package/backend/dist/forward-proxy/h2-forward.d.ts +66 -0
- package/backend/dist/forward-proxy/h2-forward.js +526 -0
- package/backend/dist/forward-proxy/index.d.ts +13 -1
- package/backend/dist/forward-proxy/index.js +148 -7
- package/backend/dist/forward-proxy/interceptor.d.ts +16 -13
- package/backend/dist/forward-proxy/interceptor.js +35 -57
- package/backend/dist/forward-proxy/relay.d.ts +21 -1
- package/backend/dist/forward-proxy/relay.js +48 -1
- package/backend/dist/forward-proxy/rules.d.ts +148 -0
- package/backend/dist/forward-proxy/rules.js +280 -0
- package/backend/dist/forward-proxy/server.d.ts +102 -9
- package/backend/dist/forward-proxy/server.js +1310 -305
- package/backend/dist/forward-proxy/sni.d.ts +29 -7
- package/backend/dist/forward-proxy/sni.js +109 -47
- package/backend/dist/forward-proxy/system-proxy.d.ts +72 -0
- package/backend/dist/forward-proxy/system-proxy.js +303 -0
- package/backend/dist/forward-proxy/upstream-tls.d.ts +46 -0
- package/backend/dist/forward-proxy/upstream-tls.js +105 -0
- package/backend/dist/forward-proxy/ws-frames.d.ts +45 -0
- package/backend/dist/forward-proxy/ws-frames.js +153 -0
- package/backend/dist/harness/common/catalog-registry.d.ts +63 -0
- package/backend/dist/harness/common/catalog-registry.js +77 -0
- package/backend/dist/harness/common/github.d.ts +6 -0
- package/backend/dist/harness/common/github.js +13 -0
- package/backend/dist/harness/common/market.d.ts +590 -0
- package/backend/dist/harness/common/market.js +1079 -0
- package/backend/dist/harness/common/marketplace-rescan-scheduler.d.ts +24 -0
- package/backend/dist/harness/common/marketplace-rescan-scheduler.js +62 -0
- package/backend/dist/harness/{catalog-npm.d.ts → common/npm-catalog.d.ts} +5 -5
- package/backend/dist/harness/{catalog-npm.js → common/npm-catalog.js} +7 -7
- package/backend/dist/harness/common/npm-source.d.ts +29 -0
- package/backend/dist/harness/common/npm-source.js +121 -0
- package/backend/dist/harness/common/pypi-source.d.ts +28 -0
- package/backend/dist/harness/common/pypi-source.js +71 -0
- package/backend/dist/harness/common/source-views.d.ts +22 -0
- package/backend/dist/harness/common/source-views.js +25 -0
- package/backend/dist/harness/{stars.d.ts → common/stars.d.ts} +1 -1
- package/backend/dist/harness/{stars.js → common/stars.js} +2 -2
- package/backend/dist/harness/common/text.d.ts +11 -0
- package/backend/dist/harness/common/text.js +18 -0
- package/backend/dist/harness/config-file.d.ts +14 -1
- package/backend/dist/harness/config-file.js +38 -0
- package/backend/dist/harness/db-probe.d.ts +29 -0
- package/backend/dist/harness/db-probe.js +270 -0
- package/backend/dist/harness/detail.d.ts +10 -1
- package/backend/dist/harness/detail.js +144 -7
- package/backend/dist/harness/host/adapters/amp.d.ts +19 -0
- package/backend/dist/harness/host/adapters/amp.js +21 -0
- package/backend/dist/harness/host/adapters/antigravity.d.ts +18 -0
- package/backend/dist/harness/host/adapters/antigravity.js +21 -0
- package/backend/dist/harness/host/adapters/base.d.ts +225 -0
- package/backend/dist/harness/host/adapters/base.js +521 -0
- package/backend/dist/harness/host/adapters/claude.d.ts +54 -0
- package/backend/dist/harness/host/adapters/claude.js +145 -0
- package/backend/dist/harness/host/adapters/cline.d.ts +18 -0
- package/backend/dist/harness/host/adapters/cline.js +20 -0
- package/backend/dist/harness/host/adapters/codex.d.ts +54 -0
- package/backend/dist/harness/host/adapters/codex.js +133 -0
- package/backend/dist/harness/host/adapters/cursor.d.ts +18 -0
- package/backend/dist/harness/host/adapters/cursor.js +24 -0
- package/backend/dist/harness/host/adapters/declarative.d.ts +22 -0
- package/backend/dist/harness/host/adapters/declarative.js +38 -0
- package/backend/dist/harness/host/adapters/dsh.d.ts +76 -0
- package/backend/dist/harness/host/adapters/dsh.js +253 -0
- package/backend/dist/harness/host/adapters/factory.d.ts +36 -0
- package/backend/dist/harness/host/adapters/factory.js +34 -0
- package/backend/dist/harness/host/adapters/gemini-cli.d.ts +17 -0
- package/backend/dist/harness/host/adapters/gemini-cli.js +19 -0
- package/backend/dist/harness/host/adapters/grok.d.ts +66 -0
- package/backend/dist/harness/host/adapters/grok.js +136 -0
- package/backend/dist/harness/{adapters → host/adapters}/index.d.ts +18 -5
- package/backend/dist/harness/{adapters → host/adapters}/index.js +73 -5
- package/backend/dist/harness/host/adapters/kimi.d.ts +30 -0
- package/backend/dist/harness/host/adapters/kimi.js +59 -0
- package/backend/dist/harness/host/adapters/omp.d.ts +55 -0
- package/backend/dist/harness/host/adapters/omp.js +90 -0
- package/backend/dist/harness/host/adapters/openclaw.d.ts +54 -0
- package/backend/dist/harness/host/adapters/openclaw.js +141 -0
- package/backend/dist/harness/host/adapters/opencode.d.ts +24 -0
- package/backend/dist/harness/host/adapters/opencode.js +48 -0
- package/backend/dist/harness/host/adapters/pi.d.ts +27 -0
- package/backend/dist/harness/host/adapters/pi.js +58 -0
- package/backend/dist/harness/host/adapters/types.d.ts +395 -0
- package/backend/dist/harness/host/adapters/types.js +17 -0
- package/backend/dist/harness/host/adapters/universal.d.ts +14 -0
- package/backend/dist/harness/host/adapters/universal.js +18 -0
- package/backend/dist/harness/host/adapters/windsurf.d.ts +20 -0
- package/backend/dist/harness/host/adapters/windsurf.js +22 -0
- package/backend/dist/harness/host/adapters/zed.d.ts +12 -0
- package/backend/dist/harness/host/adapters/zed.js +14 -0
- package/backend/dist/harness/host/claude-mcp-runtime.d.ts +6 -0
- package/backend/dist/harness/host/claude-mcp-runtime.js +56 -0
- package/backend/dist/harness/{discover.d.ts → host/discover.d.ts} +54 -18
- package/backend/dist/harness/{discover.js → host/discover.js} +314 -53
- package/backend/dist/harness/{drift.d.ts → host/drift.d.ts} +1 -1
- package/backend/dist/harness/{drift.js → host/drift.js} +1 -1
- package/backend/dist/harness/host/grok-mcp-runtime.d.ts +6 -0
- package/backend/dist/harness/host/grok-mcp-runtime.js +56 -0
- package/backend/dist/harness/{hosts.d.ts → host/hosts.d.ts} +3 -3
- package/backend/dist/harness/{hosts.js → host/hosts.js} +7 -2
- package/backend/dist/harness/host/index.d.ts +10 -0
- package/backend/dist/harness/host/index.js +12 -0
- package/backend/dist/harness/host/install-log.d.ts +22 -0
- package/backend/dist/harness/host/install-log.js +106 -0
- package/backend/dist/harness/{install.d.ts → host/install.d.ts} +32 -13
- package/backend/dist/harness/{install.js → host/install.js} +133 -50
- package/backend/dist/harness/host/inventory.d.ts +30 -0
- package/backend/dist/harness/{inventory.js → host/inventory.js} +107 -16
- package/backend/dist/harness/host/kimi-mcp-runtime.d.ts +6 -0
- package/backend/dist/harness/host/kimi-mcp-runtime.js +84 -0
- package/backend/dist/harness/{ledger.d.ts → host/ledger.d.ts} +1 -1
- package/backend/dist/harness/{ledger.js → host/ledger.js} +3 -3
- package/backend/dist/harness/{maintenance.d.ts → host/maintenance.d.ts} +23 -6
- package/backend/dist/harness/{maintenance.js → host/maintenance.js} +355 -63
- package/backend/dist/harness/{manifest.d.ts → host/manifest.d.ts} +11 -2
- package/backend/dist/harness/{manifest.js → host/manifest.js} +76 -15
- package/backend/dist/harness/host/marketplace-sync.d.ts +64 -0
- package/backend/dist/harness/host/marketplace-sync.js +231 -0
- package/backend/dist/harness/host/mcp-cli.d.ts +44 -0
- package/backend/dist/harness/host/mcp-cli.js +545 -0
- package/backend/dist/harness/host/mcp-edit.d.ts +89 -0
- package/backend/dist/harness/host/mcp-edit.js +342 -0
- package/backend/dist/harness/host/mcp-entry.d.ts +100 -0
- package/backend/dist/harness/host/mcp-entry.js +435 -0
- package/backend/dist/harness/host/mcp-inspector.d.ts +125 -0
- package/backend/dist/harness/host/mcp-inspector.js +634 -0
- package/backend/dist/harness/host/mcp-registry.d.ts +66 -0
- package/backend/dist/harness/host/mcp-registry.js +331 -0
- package/backend/dist/harness/host/mcp-runtime.d.ts +19 -0
- package/backend/dist/harness/host/mcp-runtime.js +22 -0
- package/backend/dist/harness/host/opencode-mcp-runtime.d.ts +7 -0
- package/backend/dist/harness/host/opencode-mcp-runtime.js +73 -0
- package/backend/dist/harness/{probe.d.ts → host/probe.d.ts} +4 -4
- package/backend/dist/harness/{probe.js → host/probe.js} +8 -8
- package/backend/dist/harness/{registry.d.ts → host/registry.d.ts} +1 -1
- package/backend/dist/harness/host/registry.js +28 -0
- package/backend/dist/harness/host/request.d.ts +56 -0
- package/backend/dist/harness/host/request.js +1 -0
- package/backend/dist/harness/{sources → host/resolvers}/clawhub.d.ts +1 -1
- package/backend/dist/harness/{sources → host/resolvers}/clawhub.js +1 -1
- package/backend/dist/harness/host/resolvers/git-marketplace.d.ts +16 -0
- package/backend/dist/harness/host/resolvers/git-marketplace.js +53 -0
- package/backend/dist/harness/{sources → host/resolvers}/github.d.ts +1 -1
- package/backend/dist/harness/{sources → host/resolvers}/github.js +2 -2
- package/backend/dist/harness/host/resolvers/npm.d.ts +2 -0
- package/backend/dist/harness/{sources → host/resolvers}/npm.js +16 -10
- package/backend/dist/harness/host/resolvers/pypi.d.ts +2 -0
- package/backend/dist/harness/host/resolvers/pypi.js +100 -0
- package/backend/dist/harness/host/scopes.d.ts +11 -0
- package/backend/dist/harness/host/scopes.js +12 -0
- package/backend/dist/harness/host/timeouts.d.ts +8 -0
- package/backend/dist/harness/host/timeouts.js +8 -0
- package/backend/dist/harness/host/writers/kimi-web.d.ts +70 -0
- package/backend/dist/harness/host/writers/kimi-web.js +222 -0
- package/backend/dist/harness/host/writers/mcp.d.ts +119 -0
- package/backend/dist/harness/host/writers/mcp.js +359 -0
- package/backend/dist/harness/host/writers/plugin.d.ts +176 -0
- package/backend/dist/harness/host/writers/plugin.js +528 -0
- package/backend/dist/harness/{writers → host/writers}/skill.d.ts +3 -3
- package/backend/dist/harness/{writers → host/writers}/skill.js +6 -3
- package/backend/dist/harness/lang.d.ts +14 -0
- package/backend/dist/harness/lang.js +33 -0
- package/backend/dist/harness/net.d.ts +33 -0
- package/backend/dist/harness/net.js +63 -0
- package/backend/dist/harness/plugin/adapters/antigravity.d.ts +11 -0
- package/backend/dist/harness/plugin/adapters/antigravity.js +14 -0
- package/backend/dist/harness/plugin/adapters/base.d.ts +107 -0
- package/backend/dist/harness/plugin/adapters/base.js +454 -0
- package/backend/dist/harness/plugin/adapters/claude.d.ts +28 -0
- package/backend/dist/harness/plugin/adapters/claude.js +63 -0
- package/backend/dist/harness/plugin/adapters/codex.d.ts +13 -0
- package/backend/dist/harness/plugin/adapters/codex.js +16 -0
- package/backend/dist/harness/plugin/adapters/cursor.d.ts +13 -0
- package/backend/dist/harness/plugin/adapters/cursor.js +16 -0
- package/backend/dist/harness/plugin/adapters/dsh-plugin-net.d.ts +20 -0
- package/backend/dist/harness/plugin/adapters/dsh-plugin-net.js +371 -0
- package/backend/dist/harness/plugin/adapters/dsh.d.ts +22 -0
- package/backend/dist/harness/plugin/adapters/dsh.js +50 -0
- package/backend/dist/harness/plugin/adapters/factory.d.ts +11 -0
- package/backend/dist/harness/plugin/adapters/factory.js +19 -0
- package/backend/dist/harness/plugin/adapters/gemini.d.ts +12 -0
- package/backend/dist/harness/plugin/adapters/gemini.js +22 -0
- package/backend/dist/harness/plugin/adapters/grok.d.ts +15 -0
- package/backend/dist/harness/plugin/adapters/grok.js +23 -0
- package/backend/dist/harness/plugin/adapters/index.d.ts +41 -0
- package/backend/dist/harness/plugin/adapters/index.js +143 -0
- package/backend/dist/harness/plugin/adapters/kimi.d.ts +6 -0
- package/backend/dist/harness/plugin/adapters/kimi.js +35 -0
- package/backend/dist/harness/plugin/adapters/omp.d.ts +19 -0
- package/backend/dist/harness/plugin/adapters/omp.js +26 -0
- package/backend/dist/harness/plugin/adapters/openclaw.d.ts +20 -0
- package/backend/dist/harness/plugin/adapters/openclaw.js +36 -0
- package/backend/dist/harness/plugin/adapters/pi-dev.d.ts +124 -0
- package/backend/dist/harness/plugin/adapters/pi-dev.js +420 -0
- package/backend/dist/harness/plugin/adapters/pi-github.d.ts +18 -0
- package/backend/dist/harness/plugin/adapters/pi-github.js +27 -0
- package/backend/dist/harness/plugin/adapters/universal.d.ts +11 -0
- package/backend/dist/harness/plugin/adapters/universal.js +18 -0
- package/backend/dist/harness/plugin/builtin.d.ts +13 -0
- package/backend/dist/harness/plugin/builtin.js +34 -0
- package/backend/dist/harness/plugin/catalog.d.ts +30 -0
- package/backend/dist/harness/plugin/catalog.js +200 -0
- package/backend/dist/harness/plugin/index.d.ts +9 -0
- package/backend/dist/harness/plugin/index.js +9 -0
- package/backend/dist/harness/plugin/types.d.ts +164 -0
- package/backend/dist/harness/plugin/types.js +1 -0
- package/backend/dist/harness/{clawhub.d.ts → skill/clawhub.d.ts} +28 -5
- package/backend/dist/harness/{clawhub.js → skill/clawhub.js} +170 -5
- package/backend/dist/harness/skill/skills-sh.d.ts +47 -0
- package/backend/dist/harness/skill/skills-sh.js +270 -0
- package/backend/dist/harness/skill/sources.d.ts +41 -0
- package/backend/dist/harness/skill/sources.js +131 -0
- package/backend/dist/harness/spi.d.ts +11 -7
- package/backend/dist/harness/tcp-reach.d.ts +30 -0
- package/backend/dist/harness/tcp-reach.js +61 -0
- package/backend/dist/harness/translation.d.ts +31 -13
- package/backend/dist/harness/translation.js +212 -62
- package/backend/dist/harness/types.d.ts +61 -16
- package/backend/dist/index.js +170 -16
- package/backend/dist/ir/adapters/anthropic-messages-stream.d.ts +18 -0
- package/backend/dist/ir/adapters/anthropic-messages-stream.js +266 -0
- package/backend/dist/ir/adapters/anthropic-messages.d.ts +30 -0
- package/backend/dist/ir/adapters/anthropic-messages.js +870 -0
- package/backend/dist/ir/adapters/google-gemini-stream.d.ts +22 -0
- package/backend/dist/ir/adapters/google-gemini-stream.js +246 -0
- package/backend/dist/ir/adapters/google-gemini.d.ts +9 -0
- package/backend/dist/ir/adapters/google-gemini.js +450 -0
- package/backend/dist/ir/adapters/openai-chat-stream.d.ts +41 -0
- package/backend/dist/ir/adapters/openai-chat-stream.js +369 -0
- package/backend/dist/ir/adapters/openai-chat.d.ts +17 -0
- package/backend/dist/ir/adapters/openai-chat.js +670 -0
- package/backend/dist/ir/adapters/openai-responses-output.d.ts +50 -0
- package/backend/dist/ir/adapters/openai-responses-output.js +353 -0
- package/backend/dist/ir/adapters/openai-responses-stream.d.ts +12 -0
- package/backend/dist/ir/adapters/openai-responses-stream.js +193 -0
- package/backend/dist/ir/adapters/openai-responses.d.ts +14 -0
- package/backend/dist/ir/adapters/openai-responses.js +670 -0
- package/backend/dist/ir/capabilities.d.ts +41 -0
- package/backend/dist/ir/capabilities.js +147 -0
- package/backend/dist/ir/errors.d.ts +23 -0
- package/backend/dist/ir/errors.js +31 -0
- package/backend/dist/ir/index.d.ts +5 -0
- package/backend/dist/ir/index.js +5 -0
- package/backend/dist/ir/media.d.ts +2 -0
- package/backend/dist/ir/media.js +2 -0
- package/backend/dist/ir/stream.d.ts +17 -0
- package/backend/dist/ir/stream.js +250 -0
- package/backend/dist/ir/types.d.ts +523 -0
- package/backend/dist/ir/types.js +19 -0
- package/backend/dist/ir/validate.d.ts +18 -0
- package/backend/dist/ir/validate.js +272 -0
- package/backend/dist/metrics/request-cost.d.ts +3 -11
- package/backend/dist/metrics/request-cost.js +9 -27
- package/backend/dist/observability/failure-events.d.ts +20 -4
- package/backend/dist/observability/failure-events.js +9 -1
- package/backend/dist/observability/http-exchange.d.ts +75 -27
- package/backend/dist/observability/http-exchange.js +136 -39
- package/backend/dist/observability/request-identity.d.ts +40 -0
- package/backend/dist/observability/request-identity.js +102 -0
- package/backend/dist/observability/traffic-live-hidden.d.ts +24 -0
- package/backend/dist/observability/traffic-live-hidden.js +82 -0
- package/backend/dist/observability/upstream-body-redaction.d.ts +23 -0
- package/backend/dist/observability/upstream-body-redaction.js +72 -0
- package/backend/dist/observability/upstream-events.d.ts +16 -10
- package/backend/dist/observability/upstream-events.js +17 -11
- package/backend/dist/opencode/agents.d.ts +10 -2
- package/backend/dist/opencode/agents.js +22 -3
- package/backend/dist/opencode/catalog/auto-pull.d.ts +35 -1
- package/backend/dist/opencode/catalog/auto-pull.js +169 -33
- package/backend/dist/opencode/catalog/ocr-store.d.ts +6 -6
- package/backend/dist/opencode/catalog/ocr-store.js +2 -2
- package/backend/dist/opencode/catalog/overrides-store.d.ts +6 -5
- package/backend/dist/opencode/catalog/overrides-store.js +28 -3
- package/backend/dist/opencode/catalog/repository.d.ts +4 -0
- package/backend/dist/opencode/catalog/repository.js +19 -0
- package/backend/dist/opencode/catalog/sources/models-dev.d.ts +4 -0
- package/backend/dist/opencode/catalog/sources/models-dev.js +15 -4
- package/backend/dist/opencode/catalog/types.d.ts +10 -7
- package/backend/dist/opencode/connector.d.ts +2 -2
- package/backend/dist/opencode/connector.js +2 -2
- package/backend/dist/opencode/credentials/def-materialize.d.ts +0 -5
- package/backend/dist/opencode/credentials/def-materialize.js +149 -11
- package/backend/dist/opencode/credentials/ocr-store.d.ts +18 -0
- package/backend/dist/opencode/credentials/ocr-store.js +88 -7
- package/backend/dist/opencode/credentials/opencode-v2-store.d.ts +24 -13
- package/backend/dist/opencode/credentials/opencode-v2-store.js +70 -29
- package/backend/dist/opencode/credentials/paths.d.ts +8 -0
- package/backend/dist/opencode/credentials/paths.js +10 -0
- package/backend/dist/opencode/credentials/sync.d.ts +1 -1
- package/backend/dist/opencode/credentials/sync.js +4 -4
- package/backend/dist/opencode/credentials/types.d.ts +40 -4
- package/backend/dist/opencode/probe.d.ts +9 -5
- package/backend/dist/opencode/probe.js +68 -15
- package/backend/dist/opencode/provider-defs.js +59 -2
- package/backend/dist/opencode/provider-package.d.ts +31 -0
- package/backend/dist/opencode/provider-package.js +70 -0
- package/backend/dist/opencode/user-config.d.ts +11 -17
- package/backend/dist/opencode/user-config.js +42 -66
- package/backend/dist/pipeline/credential-selection.d.ts +13 -0
- package/backend/dist/pipeline/credential-selection.js +29 -1
- package/backend/dist/pipeline/directives.d.ts +14 -22
- package/backend/dist/pipeline/directives.js +122 -68
- package/backend/dist/pipeline/orchestrator.d.ts +42 -7
- package/backend/dist/pipeline/orchestrator.js +736 -235
- package/backend/dist/pipeline/prompt-optimizer.d.ts +6 -13
- package/backend/dist/pipeline/prompt-optimizer.js +9 -52
- package/backend/dist/pipeline/streaming-posture.d.ts +29 -0
- package/backend/dist/pipeline/streaming-posture.js +27 -0
- package/backend/dist/pipeline/tool-pairing.d.ts +10 -0
- package/backend/dist/pipeline/tool-pairing.js +90 -0
- package/backend/dist/plugins/builtin/model-gateway.d.ts +30 -0
- package/backend/dist/plugins/builtin/model-gateway.js +98 -0
- package/backend/dist/plugins/config.d.ts +41 -0
- package/backend/dist/plugins/config.js +113 -0
- package/backend/dist/plugins/gateways.d.ts +98 -0
- package/backend/dist/plugins/gateways.js +151 -0
- package/backend/dist/plugins/host.d.ts +203 -0
- package/backend/dist/plugins/host.js +1310 -0
- package/backend/dist/plugins/manifest.d.ts +43 -0
- package/backend/dist/plugins/manifest.js +462 -0
- package/backend/dist/plugins/pack.d.ts +32 -0
- package/backend/dist/plugins/pack.js +222 -0
- package/backend/dist/plugins/seed.d.ts +53 -0
- package/backend/dist/plugins/seed.js +136 -0
- package/backend/dist/plugins/types.d.ts +721 -0
- package/backend/dist/plugins/types.js +1 -0
- package/backend/dist/projects/store.d.ts +56 -0
- package/backend/dist/projects/store.js +194 -0
- package/backend/dist/projects/types.d.ts +12 -0
- package/backend/dist/projects/types.js +1 -0
- package/backend/dist/protocols/chat-compat.d.ts +2 -0
- package/backend/dist/protocols/chat-compat.js +137 -0
- package/backend/dist/protocols/systemone/convert.d.ts +5 -4
- package/backend/dist/protocols/systemone/convert.js +72 -26
- package/backend/dist/protocols/systemone/decide.js +128 -51
- package/backend/dist/protocols/systemone/native.d.ts +1 -1
- package/backend/dist/protocols/systemone/native.js +6 -6
- package/backend/dist/providers/anthropic.js +6 -6
- package/backend/dist/providers/base.d.ts +8 -47
- package/backend/dist/providers/boot-direct.d.ts +20 -2
- package/backend/dist/providers/boot-direct.js +72 -23
- package/backend/dist/providers/compat/tool-markup-leak.d.ts +41 -0
- package/backend/dist/providers/compat/tool-markup-leak.js +57 -0
- package/backend/dist/providers/compat/tool-markup-recovery.d.ts +27 -0
- package/backend/dist/providers/compat/tool-markup-recovery.js +831 -0
- package/backend/dist/providers/dispatch.d.ts +5 -8
- package/backend/dist/providers/dispatch.js +18 -12
- package/backend/dist/providers/executors/anthropic-messages.d.ts +12 -0
- package/backend/dist/providers/executors/anthropic-messages.js +56 -0
- package/backend/dist/providers/executors/dispatch.d.ts +14 -0
- package/backend/dist/providers/executors/dispatch.js +71 -0
- package/backend/dist/providers/executors/google-gemini.d.ts +12 -0
- package/backend/dist/providers/executors/google-gemini.js +53 -0
- package/backend/dist/providers/executors/http-json.d.ts +19 -0
- package/backend/dist/providers/executors/http-json.js +125 -0
- package/backend/dist/providers/executors/http-stream.d.ts +53 -0
- package/backend/dist/providers/executors/http-stream.js +472 -0
- package/backend/dist/providers/executors/openai-chat.d.ts +13 -0
- package/backend/dist/providers/executors/openai-chat.js +89 -0
- package/backend/dist/providers/executors/openai-responses.d.ts +12 -0
- package/backend/dist/providers/executors/openai-responses.js +71 -0
- package/backend/dist/providers/executors/plugin-adapter.d.ts +9 -0
- package/backend/dist/providers/executors/plugin-adapter.js +31 -0
- package/backend/dist/providers/google.js +6 -6
- package/backend/dist/providers/openai-compatible.js +13 -13
- package/backend/dist/providers/opencode-proxy.js +6 -6
- package/backend/dist/providers/plugin-wires.d.ts +34 -0
- package/backend/dist/providers/plugin-wires.js +82 -0
- package/backend/dist/providers/pool-refresh.d.ts +14 -0
- package/backend/dist/providers/pool-refresh.js +13 -0
- package/backend/dist/providers/protocol.d.ts +4 -0
- package/backend/dist/providers/protocol.js +61 -0
- package/backend/dist/providers/provider-takedown.d.ts +59 -0
- package/backend/dist/providers/provider-takedown.js +135 -0
- package/backend/dist/providers/registry.d.ts +37 -21
- package/backend/dist/providers/registry.js +204 -109
- package/backend/dist/providers/responses.d.ts +4 -2
- package/backend/dist/providers/responses.js +12 -9
- package/backend/dist/providers/vocabulary.d.ts +24 -6
- package/backend/dist/providers/vocabulary.js +75 -33
- package/backend/dist/providers/wire.d.ts +12 -17
- package/backend/dist/providers/wire.js +43 -91
- package/backend/dist/proxy/manual-node-spec.d.ts +92 -0
- package/backend/dist/proxy/manual-node-spec.js +408 -0
- package/backend/dist/proxy/mihomo-binary.d.ts +39 -0
- package/backend/dist/proxy/mihomo-binary.js +267 -0
- package/backend/dist/proxy/mihomo-client.d.ts +94 -0
- package/backend/dist/proxy/mihomo-client.js +294 -0
- package/backend/dist/proxy/mihomo-config.d.ts +40 -0
- package/backend/dist/proxy/mihomo-config.js +152 -0
- package/backend/dist/proxy/mihomo-pac.d.ts +26 -0
- package/backend/dist/proxy/mihomo-pac.js +60 -0
- package/backend/dist/proxy/mihomo-rules-import.d.ts +43 -0
- package/backend/dist/proxy/mihomo-rules-import.js +193 -0
- package/backend/dist/proxy/mihomo-sidecar.d.ts +65 -0
- package/backend/dist/proxy/mihomo-sidecar.js +515 -0
- package/backend/dist/quota/engine.d.ts +9 -2
- package/backend/dist/quota/engine.js +19 -1
- package/backend/dist/quota/prober.d.ts +8 -4
- package/backend/dist/quota/prober.js +9 -10
- package/backend/dist/ratelimit/rate-limiter.d.ts +119 -6
- package/backend/dist/ratelimit/rate-limiter.js +358 -20
- package/backend/dist/ratelimit/window-store.d.ts +34 -0
- package/backend/dist/ratelimit/window-store.js +70 -0
- package/backend/dist/resilience/breaker-state.js +8 -1
- package/backend/dist/resilience/circuit-breaker-manager.d.ts +229 -132
- package/backend/dist/resilience/circuit-breaker-manager.js +566 -297
- package/backend/dist/resilience/circuit-breaker.d.ts +11 -0
- package/backend/dist/resilience/circuit-breaker.js +39 -7
- package/backend/dist/resilience/error-classifier.d.ts +31 -3
- package/backend/dist/resilience/error-classifier.js +159 -31
- package/backend/dist/resilience/health-prober.d.ts +21 -4
- package/backend/dist/resilience/health-prober.js +100 -18
- package/backend/dist/resilience/types.d.ts +56 -9
- package/backend/dist/resilience/types.js +1 -1
- package/backend/dist/router/index.d.ts +6 -29
- package/backend/dist/router/index.js +15 -61
- package/backend/dist/router/layer2-decision.d.ts +2 -2
- package/backend/dist/router/layer2-decision.js +22 -19
- package/backend/dist/router/request-traits.d.ts +4 -11
- package/backend/dist/router/request-traits.js +5 -13
- package/backend/dist/routes/console.js +1948 -253
- package/backend/dist/routes/environments.d.ts +3 -2
- package/backend/dist/routes/environments.js +8 -4
- package/backend/dist/routes/harness.d.ts +3 -1
- package/backend/dist/routes/harness.js +1164 -355
- package/backend/dist/routes/mihomo.d.ts +5 -0
- package/backend/dist/routes/mihomo.js +882 -0
- package/backend/dist/routes/projects.d.ts +2 -0
- package/backend/dist/routes/projects.js +90 -0
- package/backend/dist/routes/responses.d.ts +20 -1
- package/backend/dist/routes/responses.js +65 -3
- package/backend/dist/routes/translation.d.ts +9 -0
- package/backend/dist/routes/translation.js +155 -0
- package/backend/dist/server.d.ts +0 -15
- package/backend/dist/server.js +388 -105
- package/backend/dist/session/resp-store.d.ts +18 -49
- package/backend/dist/session/resp-store.js +114 -122
- package/backend/dist/session/session-manager.d.ts +237 -81
- package/backend/dist/session/session-manager.js +445 -180
- package/backend/dist/session/session-row.d.ts +157 -0
- package/backend/dist/session/session-row.js +120 -0
- package/backend/dist/surfaces/anthropic.d.ts +1 -15
- package/backend/dist/surfaces/anthropic.js +63 -44
- package/backend/dist/surfaces/chat-pipeline.d.ts +8 -4
- package/backend/dist/surfaces/chat-pipeline.js +102 -35
- package/backend/dist/surfaces/chat.d.ts +1 -9
- package/backend/dist/surfaces/chat.js +52 -29
- package/backend/dist/surfaces/decision-pipeline.js +26 -18
- package/backend/dist/surfaces/gateway-chat.d.ts +53 -0
- package/backend/dist/surfaces/gateway-chat.js +204 -0
- package/backend/dist/surfaces/ocr-headers.d.ts +25 -4
- package/backend/dist/surfaces/ocr-headers.js +52 -6
- package/backend/dist/surfaces/responses.d.ts +9 -1
- package/backend/dist/surfaces/responses.js +141 -141
- package/backend/dist/surfaces/systemone-probe.js +1 -1
- package/backend/dist/surfaces/systemone.d.ts +1 -1
- package/backend/dist/surfaces/systemone.js +1 -1
- package/backend/dist/surfaces/table.d.ts +15 -0
- package/backend/dist/surfaces/table.js +15 -0
- package/backend/dist/surfaces/transport-backpressure.d.ts +46 -0
- package/backend/dist/surfaces/transport-backpressure.js +122 -0
- package/backend/dist/surfaces/transport-fastify.js +92 -21
- package/backend/dist/surfaces/transport-node-http.js +92 -18
- package/backend/dist/surfaces/types.d.ts +74 -12
- package/backend/dist/trace/persist.d.ts +5 -0
- package/backend/dist/trace/persist.js +185 -24
- package/backend/dist/trace/tracker.d.ts +153 -16
- package/backend/dist/trace/tracker.js +77 -27
- package/backend/dist/translation/index.d.ts +151 -0
- package/backend/dist/translation/index.js +735 -0
- package/backend/dist/types/openai.d.ts +82 -1
- package/backend/dist/types/router.d.ts +71 -6
- package/backend/dist/types/router.js +33 -1
- package/backend/dist/update/check.d.ts +43 -0
- package/backend/dist/update/check.js +126 -0
- package/backend/dist/utils/chat-sse.d.ts +2 -22
- package/backend/dist/utils/chat-sse.js +1 -69
- package/backend/dist/utils/chat-stream.d.ts +2 -1
- package/backend/dist/utils/client-envelope.d.ts +108 -0
- package/backend/dist/utils/client-envelope.js +305 -0
- package/backend/dist/utils/event-ring.d.ts +8 -1
- package/backend/dist/utils/event-ring.js +13 -5
- package/backend/dist/utils/harness-profiles.d.ts +51 -0
- package/backend/dist/utils/harness-profiles.js +70 -0
- package/backend/dist/utils/percentile.d.ts +16 -0
- package/backend/dist/utils/percentile.js +29 -0
- package/backend/dist/utils/popularity.d.ts +4 -0
- package/backend/dist/utils/popularity.js +33 -0
- package/backend/dist/utils/probe-interval.d.ts +12 -0
- package/backend/dist/utils/probe-interval.js +16 -0
- package/backend/dist/utils/proxy-node.d.ts +13 -0
- package/backend/dist/utils/proxy-node.js +471 -0
- package/backend/dist/utils/proxy.d.ts +12 -0
- package/backend/dist/utils/proxy.js +44 -4
- package/backend/dist/utils/run-command.d.ts +42 -0
- package/backend/dist/utils/run-command.js +93 -0
- package/backend/dist/utils/self-url.d.ts +13 -0
- package/backend/dist/utils/self-url.js +90 -2
- package/backend/dist/utils/semver.d.ts +22 -0
- package/backend/dist/utils/semver.js +75 -0
- package/backend/dist/utils/stream-relay.d.ts +35 -0
- package/backend/dist/utils/stream-relay.js +1 -0
- package/backend/dist/utils/upstream-url-guard.d.ts +15 -0
- package/backend/dist/utils/upstream-url-guard.js +107 -0
- package/backend/dist/validator/parser.d.ts +2 -5
- package/backend/dist/validator/parser.js +12 -16
- package/backend/dist/validator/schema-assertion.d.ts +3 -2
- package/backend/dist/validator/schema-assertion.js +53 -8
- package/bin/ocr.js +2 -2
- package/frontend/dist/assets/index-CLvxJjp_.js +1476 -0
- package/frontend/dist/assets/index-CQSLGFTV.css +1 -0
- package/frontend/dist/assets/qoder.color-tVX5GCcD.svg +5 -0
- package/frontend/dist/index.html +2 -2
- package/frontend/dist/provider-logos/302ai.svg +7 -0
- package/frontend/dist/provider-logos/NOTICE.txt +39 -0
- package/frontend/dist/provider-logos/abacus.svg +14 -0
- package/frontend/dist/provider-logos/abliteration-ai.svg +6 -0
- package/frontend/dist/provider-logos/above.svg +3 -0
- package/frontend/dist/provider-logos/agentrouter.svg +4 -0
- package/frontend/dist/provider-logos/agnes.svg +1 -0
- package/frontend/dist/provider-logos/ai-router.svg +5 -0
- package/frontend/dist/provider-logos/ai21.svg +3 -0
- package/frontend/dist/provider-logos/aiand.svg +4 -0
- package/frontend/dist/provider-logos/aihubmix.svg +3 -0
- package/frontend/dist/provider-logos/aimlapi.svg +3 -0
- package/frontend/dist/provider-logos/ainetcafe.svg +1 -0
- package/frontend/dist/provider-logos/aixy.svg +4 -0
- package/frontend/dist/provider-logos/aki-io.svg +8 -0
- package/frontend/dist/provider-logos/alibaba-cn.svg +3 -0
- package/frontend/dist/provider-logos/alibaba-coding-plan-cn.svg +3 -0
- package/frontend/dist/provider-logos/alibaba-coding-plan.svg +3 -0
- package/frontend/dist/provider-logos/alibaba-token-plan-cn.svg +1 -0
- package/frontend/dist/provider-logos/alibaba-token-plan.svg +1 -0
- package/frontend/dist/provider-logos/alibaba.svg +3 -0
- package/frontend/dist/provider-logos/amazon-bedrock.svg +3 -0
- package/frontend/dist/provider-logos/ambient.svg +3 -0
- package/frontend/dist/provider-logos/amd.svg +3 -0
- package/frontend/dist/provider-logos/anthropic.svg +3 -0
- package/frontend/dist/provider-logos/anyapi.svg +3 -0
- package/frontend/dist/provider-logos/arcee.svg +3 -0
- package/frontend/dist/provider-logos/atomic-chat.svg +1 -0
- package/frontend/dist/provider-logos/auriko.svg +6 -0
- package/frontend/dist/provider-logos/azure-cognitive-services.svg +3 -0
- package/frontend/dist/provider-logos/azure.svg +3 -0
- package/frontend/dist/provider-logos/bailing.svg +3 -0
- package/frontend/dist/provider-logos/baseten.svg +3 -0
- package/frontend/dist/provider-logos/bee.svg +1 -0
- package/frontend/dist/provider-logos/berget.svg +3 -0
- package/frontend/dist/provider-logos/blueclaw.svg +3 -0
- package/frontend/dist/provider-logos/bothub.svg +33 -0
- package/frontend/dist/provider-logos/boundless.svg +12 -0
- package/frontend/dist/provider-logos/cerebras.svg +4 -0
- package/frontend/dist/provider-logos/chutes.svg +24 -0
- package/frontend/dist/provider-logos/clarifai.svg +3 -0
- package/frontend/dist/provider-logos/claudinio.svg +19 -0
- package/frontend/dist/provider-logos/cline-pass.svg +24 -0
- package/frontend/dist/provider-logos/cloudferro-sherlock.svg +5 -0
- package/frontend/dist/provider-logos/cloudflare-ai-gateway.svg +4 -0
- package/frontend/dist/provider-logos/cloudflare-workers-ai.svg +4 -0
- package/frontend/dist/provider-logos/cohere.svg +5 -0
- package/frontend/dist/provider-logos/commandcode.svg +11 -0
- package/frontend/dist/provider-logos/coralbricks.svg +6 -0
- package/frontend/dist/provider-logos/cortecs.svg +24 -0
- package/frontend/dist/provider-logos/crossmodel.svg +5 -0
- package/frontend/dist/provider-logos/crusoe.svg +23 -0
- package/frontend/dist/provider-logos/daoxe.svg +3 -0
- package/frontend/dist/provider-logos/databricks.svg +3 -0
- package/frontend/dist/provider-logos/deepinfra.svg +4 -0
- package/frontend/dist/provider-logos/deepseek.svg +3 -0
- package/frontend/dist/provider-logos/digitalocean.svg +6 -0
- package/frontend/dist/provider-logos/dinference.svg +1 -0
- package/frontend/dist/provider-logos/drun.svg +8 -0
- package/frontend/dist/provider-logos/ebcloud.svg +8 -0
- package/frontend/dist/provider-logos/echo.svg +7 -0
- package/frontend/dist/provider-logos/edenai.svg +8 -0
- package/frontend/dist/provider-logos/empiriolabs.svg +1 -0
- package/frontend/dist/provider-logos/engy.svg +1 -0
- package/frontend/dist/provider-logos/evroc.svg +3 -0
- package/frontend/dist/provider-logos/fastrouter.svg +3 -0
- package/frontend/dist/provider-logos/fireworks-ai.svg +3 -0
- package/frontend/dist/provider-logos/freemodel.svg +3 -0
- package/frontend/dist/provider-logos/friendli.svg +3 -0
- package/frontend/dist/provider-logos/frogbot.svg +36 -0
- package/frontend/dist/provider-logos/github-copilot.svg +3 -0
- package/frontend/dist/provider-logos/gitlab.svg +3 -0
- package/frontend/dist/provider-logos/gmicloud.svg +24 -0
- package/frontend/dist/provider-logos/google-vertex-anthropic.svg +10 -0
- package/frontend/dist/provider-logos/google-vertex.svg +10 -0
- package/frontend/dist/provider-logos/google.svg +3 -0
- package/frontend/dist/provider-logos/greenpt.svg +6 -0
- package/frontend/dist/provider-logos/groq.svg +3 -0
- package/frontend/dist/provider-logos/helicone.svg +6 -0
- package/frontend/dist/provider-logos/hetzner.svg +3 -0
- package/frontend/dist/provider-logos/hopper.svg +4 -0
- package/frontend/dist/provider-logos/hpc-ai.svg +446 -0
- package/frontend/dist/provider-logos/huggingface.svg +3 -0
- package/frontend/dist/provider-logos/hyper.svg +20 -0
- package/frontend/dist/provider-logos/impossibl.svg +3 -0
- package/frontend/dist/provider-logos/inception.svg +14 -0
- package/frontend/dist/provider-logos/inceptron.svg +14 -0
- package/frontend/dist/provider-logos/inco.svg +3 -0
- package/frontend/dist/provider-logos/infer.svg +4 -0
- package/frontend/dist/provider-logos/inference.svg +3 -0
- package/frontend/dist/provider-logos/inferx.svg +5 -0
- package/frontend/dist/provider-logos/infomaniak.svg +3 -0
- package/frontend/dist/provider-logos/io-net.svg +5 -0
- package/frontend/dist/provider-logos/iteracompute.svg +7 -0
- package/frontend/dist/provider-logos/jalapeno.svg +8 -0
- package/frontend/dist/provider-logos/jiekou.svg +4 -0
- package/frontend/dist/provider-logos/kenari.svg +4 -0
- package/frontend/dist/provider-logos/kilo.svg +4 -0
- package/frontend/dist/provider-logos/kimi-code-plan-cn.svg +3 -0
- package/frontend/dist/provider-logos/kimi-code-plan-global.svg +3 -0
- package/frontend/dist/provider-logos/klokintegration.svg +11 -0
- package/frontend/dist/provider-logos/kosmik.svg +28 -0
- package/frontend/dist/provider-logos/kuae-cloud-coding-plan.svg +3 -0
- package/frontend/dist/provider-logos/lilac.svg +6 -0
- package/frontend/dist/provider-logos/liquid.svg +1 -0
- package/frontend/dist/provider-logos/llmgateway-providers.svg +6 -0
- package/frontend/dist/provider-logos/llmgateway.svg +6 -0
- package/frontend/dist/provider-logos/llmtech.svg +6 -0
- package/frontend/dist/provider-logos/llmtr.svg +12 -0
- package/frontend/dist/provider-logos/lmstudio.svg +3 -0
- package/frontend/dist/provider-logos/longcat.svg +6 -0
- package/frontend/dist/provider-logos/lowrouter.svg +8 -0
- package/frontend/dist/provider-logos/lucidquery.svg +3 -0
- package/frontend/dist/provider-logos/lynkr.svg +1 -0
- package/frontend/dist/provider-logos/meganova.svg +3 -0
- package/frontend/dist/provider-logos/melious.svg +3 -0
- package/frontend/dist/provider-logos/merge-gateway.svg +4 -0
- package/frontend/dist/provider-logos/meta.svg +3 -0
- package/frontend/dist/provider-logos/minimax-cn-coding-plan.svg +3 -0
- package/frontend/dist/provider-logos/minimax-cn.svg +3 -0
- package/frontend/dist/provider-logos/minimax-coding-plan.svg +3 -0
- package/frontend/dist/provider-logos/minimax.svg +3 -0
- package/frontend/dist/provider-logos/mistral.svg +3 -0
- package/frontend/dist/provider-logos/mixlayer.svg +9 -0
- package/frontend/dist/provider-logos/moark.svg +3 -0
- package/frontend/dist/provider-logos/modal.svg +3 -0
- package/frontend/dist/provider-logos/model-oracle-ai.svg +11 -0
- package/frontend/dist/provider-logos/modelis.svg +1 -0
- package/frontend/dist/provider-logos/modelscope.svg +5 -0
- package/frontend/dist/provider-logos/modular.svg +3 -0
- package/frontend/dist/provider-logos/moonshotai-cn.svg +3 -0
- package/frontend/dist/provider-logos/moonshotai.svg +3 -0
- package/frontend/dist/provider-logos/morph.svg +24 -0
- package/frontend/dist/provider-logos/munito-eu.svg +1 -0
- package/frontend/dist/provider-logos/munito.svg +1 -0
- package/frontend/dist/provider-logos/nan.svg +1 -0
- package/frontend/dist/provider-logos/nano-gpt.svg +3 -0
- package/frontend/dist/provider-logos/nearai.svg +1 -0
- package/frontend/dist/provider-logos/nebius.svg +4 -0
- package/frontend/dist/provider-logos/neon.svg +3 -0
- package/frontend/dist/provider-logos/neosmith.svg +6 -0
- package/frontend/dist/provider-logos/neuralwatt.svg +27 -0
- package/frontend/dist/provider-logos/nova.svg +3 -0
- package/frontend/dist/provider-logos/novita-ai.svg +10 -0
- package/frontend/dist/provider-logos/nvidia.svg +3 -0
- package/frontend/dist/provider-logos/oci.svg +3 -0
- package/frontend/dist/provider-logos/ofox.svg +5 -0
- package/frontend/dist/provider-logos/ollama-cloud.svg +7 -0
- package/frontend/dist/provider-logos/openai.svg +3 -0
- package/frontend/dist/provider-logos/opencode-go.svg +4 -0
- package/frontend/dist/provider-logos/opencode.svg +4 -0
- package/frontend/dist/provider-logos/openreason.svg +8 -0
- package/frontend/dist/provider-logos/openrouter.svg +5 -0
- package/frontend/dist/provider-logos/opper.svg +3 -0
- package/frontend/dist/provider-logos/orcarouter.svg +2 -0
- package/frontend/dist/provider-logos/ovhcloud.svg +3 -0
- package/frontend/dist/provider-logos/pareto.svg +5 -0
- package/frontend/dist/provider-logos/pendra.svg +10 -0
- package/frontend/dist/provider-logos/perplexity-agent.svg +3 -0
- package/frontend/dist/provider-logos/perplexity.svg +3 -0
- package/frontend/dist/provider-logos/pioneer.svg +3 -0
- package/frontend/dist/provider-logos/poe.svg +7 -0
- package/frontend/dist/provider-logos/poolside.svg +3 -0
- package/frontend/dist/provider-logos/prime.svg +7 -0
- package/frontend/dist/provider-logos/privatemode-ai.svg +5 -0
- package/frontend/dist/provider-logos/qihang-ai.svg +9 -0
- package/frontend/dist/provider-logos/qiniu-ai.svg +7 -0
- package/frontend/dist/provider-logos/qvac.svg +6 -0
- package/frontend/dist/provider-logos/reflection.svg +3 -0
- package/frontend/dist/provider-logos/regolo-ai.svg +46 -0
- package/frontend/dist/provider-logos/requesty.svg +24 -0
- package/frontend/dist/provider-logos/routing-run.svg +4 -0
- package/frontend/dist/provider-logos/runinfra.svg +10 -0
- package/frontend/dist/provider-logos/sakana.svg +24 -0
- package/frontend/dist/provider-logos/salad-cloud.svg +15 -0
- package/frontend/dist/provider-logos/sambanova.svg +26 -0
- package/frontend/dist/provider-logos/sap-ai-core.svg +24 -0
- package/frontend/dist/provider-logos/sarvam.svg +24 -0
- package/frontend/dist/provider-logos/scaleway.svg +5 -0
- package/frontend/dist/provider-logos/scnet-token-plan.svg +8 -0
- package/frontend/dist/provider-logos/scx-ai.svg +1 -0
- package/frontend/dist/provider-logos/sensenova.svg +18 -0
- package/frontend/dist/provider-logos/siliconflow-cn.svg +3 -0
- package/frontend/dist/provider-logos/siliconflow.svg +3 -0
- package/frontend/dist/provider-logos/snowflake-cortex.svg +3 -0
- package/frontend/dist/provider-logos/stackit.svg +4 -0
- package/frontend/dist/provider-logos/standardcompute.svg +5 -0
- package/frontend/dist/provider-logos/stepfun-ai-step-plan.svg +16 -0
- package/frontend/dist/provider-logos/stepfun-ai.svg +16 -0
- package/frontend/dist/provider-logos/stepfun-step-plan.svg +16 -0
- package/frontend/dist/provider-logos/stepfun.svg +16 -0
- package/frontend/dist/provider-logos/subconscious.svg +3 -0
- package/frontend/dist/provider-logos/submodel.svg +3 -0
- package/frontend/dist/provider-logos/synthetic.svg +24 -0
- package/frontend/dist/provider-logos/tempr.svg +4 -0
- package/frontend/dist/provider-logos/tencent-coding-plan.svg +5 -0
- package/frontend/dist/provider-logos/tencent-token-plan.svg +3 -0
- package/frontend/dist/provider-logos/tencent-tokenhub.svg +3 -0
- package/frontend/dist/provider-logos/tensorx.svg +6 -0
- package/frontend/dist/provider-logos/the-grid-ai.svg +14 -0
- package/frontend/dist/provider-logos/thinkingmachines.svg +3 -0
- package/frontend/dist/provider-logos/tinfoil.svg +3 -0
- package/frontend/dist/provider-logos/togetherai.svg +4 -0
- package/frontend/dist/provider-logos/tokengo.svg +3 -0
- package/frontend/dist/provider-logos/tokenrouter.svg +4 -0
- package/frontend/dist/provider-logos/trustedrouter.svg +4 -0
- package/frontend/dist/provider-logos/umans-ai-coding-plan.svg +29 -0
- package/frontend/dist/provider-logos/umans-ai.svg +29 -0
- package/frontend/dist/provider-logos/unorouter.svg +7 -0
- package/frontend/dist/provider-logos/upstage.svg +24 -0
- package/frontend/dist/provider-logos/vancine.svg +6 -0
- package/frontend/dist/provider-logos/venice.svg +4 -0
- package/frontend/dist/provider-logos/vercel.svg +3 -0
- package/frontend/dist/provider-logos/vispark.svg +3 -0
- package/frontend/dist/provider-logos/vivgrid.svg +4 -0
- package/frontend/dist/provider-logos/volcengine-coding-plan.svg +1 -0
- package/frontend/dist/provider-logos/volcengine.svg +1 -0
- package/frontend/dist/provider-logos/vultr.svg +6 -0
- package/frontend/dist/provider-logos/wafer.ai.svg +3 -0
- package/frontend/dist/provider-logos/wallaby.svg +4 -0
- package/frontend/dist/provider-logos/wally.svg +1 -0
- package/frontend/dist/provider-logos/wandb.svg +6 -0
- package/frontend/dist/provider-logos/watsonx.svg +5 -0
- package/frontend/dist/provider-logos/xai.svg +3 -0
- package/frontend/dist/provider-logos/xiaomi-token-plan-ams.svg +3 -0
- package/frontend/dist/provider-logos/xiaomi-token-plan-cn.svg +3 -0
- package/frontend/dist/provider-logos/xiaomi-token-plan-sgp.svg +3 -0
- package/frontend/dist/provider-logos/xiaomi.svg +3 -0
- package/frontend/dist/provider-logos/xpersona.svg +8 -0
- package/frontend/dist/provider-logos/zai-coding-plan.svg +3 -0
- package/frontend/dist/provider-logos/zai.svg +3 -0
- package/frontend/dist/provider-logos/zeldoc.svg +3 -0
- package/frontend/dist/provider-logos/zenifra.svg +4 -0
- package/frontend/dist/provider-logos/zenmux.svg +4 -0
- package/frontend/dist/provider-logos/zhipuai-coding-plan.svg +3 -0
- package/frontend/dist/provider-logos/zhipuai.svg +3 -0
- package/package.json +13 -5
- package/backend/dist/cli/clients/opencode-proxy.d.ts +0 -16
- package/backend/dist/cli/clients/opencode-proxy.js +0 -372
- package/backend/dist/forward-proxy/bypass.d.ts +0 -20
- package/backend/dist/forward-proxy/bypass.js +0 -28
- package/backend/dist/harness/adapters/amp.d.ts +0 -2
- package/backend/dist/harness/adapters/amp.js +0 -7
- package/backend/dist/harness/adapters/claude.d.ts +0 -2
- package/backend/dist/harness/adapters/claude.js +0 -7
- package/backend/dist/harness/adapters/cline.d.ts +0 -2
- package/backend/dist/harness/adapters/cline.js +0 -6
- package/backend/dist/harness/adapters/codex.d.ts +0 -2
- package/backend/dist/harness/adapters/codex.js +0 -6
- package/backend/dist/harness/adapters/cursor.d.ts +0 -5
- package/backend/dist/harness/adapters/cursor.js +0 -10
- package/backend/dist/harness/adapters/declarative.d.ts +0 -62
- package/backend/dist/harness/adapters/declarative.js +0 -202
- package/backend/dist/harness/adapters/dsh.d.ts +0 -5
- package/backend/dist/harness/adapters/dsh.js +0 -6
- package/backend/dist/harness/adapters/gemini-cli.d.ts +0 -2
- package/backend/dist/harness/adapters/gemini-cli.js +0 -7
- package/backend/dist/harness/adapters/github-copilot.d.ts +0 -5
- package/backend/dist/harness/adapters/github-copilot.js +0 -10
- package/backend/dist/harness/adapters/opencode.d.ts +0 -2
- package/backend/dist/harness/adapters/opencode.js +0 -55
- package/backend/dist/harness/adapters/pi.d.ts +0 -1
- package/backend/dist/harness/adapters/pi.js +0 -22
- package/backend/dist/harness/adapters/types.d.ts +0 -174
- package/backend/dist/harness/adapters/types.js +0 -12
- package/backend/dist/harness/adapters/universal.d.ts +0 -6
- package/backend/dist/harness/adapters/universal.js +0 -10
- package/backend/dist/harness/adapters/windsurf.d.ts +0 -2
- package/backend/dist/harness/adapters/windsurf.js +0 -10
- package/backend/dist/harness/adapters/zed.d.ts +0 -2
- package/backend/dist/harness/adapters/zed.js +0 -6
- package/backend/dist/harness/awesome-opencode.d.ts +0 -40
- package/backend/dist/harness/awesome-opencode.js +0 -75
- package/backend/dist/harness/browse.d.ts +0 -202
- package/backend/dist/harness/browse.js +0 -1214
- package/backend/dist/harness/inventory.d.ts +0 -10
- package/backend/dist/harness/opencode-cafe.d.ts +0 -40
- package/backend/dist/harness/opencode-cafe.js +0 -85
- package/backend/dist/harness/opencode-ecosystem.d.ts +0 -34
- package/backend/dist/harness/opencode-ecosystem.js +0 -246
- package/backend/dist/harness/pi-dev.d.ts +0 -81
- package/backend/dist/harness/pi-dev.js +0 -187
- package/backend/dist/harness/registry.js +0 -26
- package/backend/dist/harness/scopes.d.ts +0 -21
- package/backend/dist/harness/scopes.js +0 -22
- package/backend/dist/harness/skills-sh.d.ts +0 -109
- package/backend/dist/harness/skills-sh.js +0 -178
- package/backend/dist/harness/smithery.d.ts +0 -64
- package/backend/dist/harness/smithery.js +0 -146
- package/backend/dist/harness/sources/awesome-opencode.d.ts +0 -11
- package/backend/dist/harness/sources/awesome-opencode.js +0 -39
- package/backend/dist/harness/sources/mcp-official.d.ts +0 -2
- package/backend/dist/harness/sources/mcp-official.js +0 -110
- package/backend/dist/harness/sources/npm.d.ts +0 -2
- package/backend/dist/harness/sources/opencode-cafe.d.ts +0 -11
- package/backend/dist/harness/sources/opencode-cafe.js +0 -41
- package/backend/dist/harness/sources/smithery.d.ts +0 -2
- package/backend/dist/harness/sources/smithery.js +0 -81
- package/backend/dist/harness/writers/extension.d.ts +0 -116
- package/backend/dist/harness/writers/extension.js +0 -219
- package/backend/dist/harness/writers/mcp.d.ts +0 -72
- package/backend/dist/harness/writers/mcp.js +0 -195
- package/backend/dist/observability/trace-id.d.ts +0 -40
- package/backend/dist/observability/trace-id.js +0 -134
- package/frontend/dist/assets/index-1o7qI-KJ.css +0 -1
- package/frontend/dist/assets/index-DvXKvNxl.js +0 -962
- package/frontend/dist/assets/inter-cyrillic-800-normal-C7MGvYyJ.woff2 +0 -0
- package/frontend/dist/assets/inter-cyrillic-800-normal-CCHyn08d.woff +0 -0
- package/frontend/dist/assets/inter-cyrillic-ext-800-normal-BZOjs1Xv.woff2 +0 -0
- package/frontend/dist/assets/inter-cyrillic-ext-800-normal-Ca-gJeZY.woff +0 -0
- package/frontend/dist/assets/inter-greek-800-normal-BU00tryP.woff +0 -0
- package/frontend/dist/assets/inter-greek-800-normal-CLIouy3y.woff2 +0 -0
- package/frontend/dist/assets/inter-greek-ext-800-normal-B--PVpEC.woff2 +0 -0
- package/frontend/dist/assets/inter-greek-ext-800-normal-DUe57HfS.woff +0 -0
- package/frontend/dist/assets/inter-latin-800-normal-BYj_oED-.woff2 +0 -0
- package/frontend/dist/assets/inter-latin-800-normal-D1mf63XC.woff +0 -0
- package/frontend/dist/assets/inter-latin-ext-800-normal-BOMpwxm3.woff +0 -0
- package/frontend/dist/assets/inter-latin-ext-800-normal-DZJjya6U.woff2 +0 -0
- package/frontend/dist/assets/inter-vietnamese-800-normal-Cm7tD1pz.woff2 +0 -0
- package/frontend/dist/assets/inter-vietnamese-800-normal-DDlpr_Ee.woff +0 -0
- /package/backend/dist/harness/{adapters → host/adapters}/skills-paths.d.ts +0 -0
- /package/backend/dist/harness/{adapters → host/adapters}/skills-paths.js +0 -0
- /package/backend/dist/harness/{skill-md.d.ts → skill/skill-md.d.ts} +0 -0
- /package/backend/dist/harness/{skill-md.js → skill/skill-md.js} +0 -0
|
@@ -0,0 +1,1079 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { getOcrHomeDir } from '../../cli/paths.js';
|
|
4
|
+
import { createBackup, safeWriteJson } from '../../cli/clients/base.js';
|
|
5
|
+
import { githubHeaders } from './github.js';
|
|
6
|
+
import { skillDirs } from '../tree.js';
|
|
7
|
+
import { fetchWithRetry } from '../net.js';
|
|
8
|
+
/** Views registered by their own module. `browseSource` prefers the view the caller passed, but a
|
|
9
|
+
* caller holding a hand-built view (tests, a future adapter) still gets its source's adapter. */
|
|
10
|
+
const browseViews = new Map();
|
|
11
|
+
export function registerBrowseView(view) {
|
|
12
|
+
browseViews.set(view.id, view);
|
|
13
|
+
}
|
|
14
|
+
export function getBrowseView(id) {
|
|
15
|
+
return browseViews.get(id);
|
|
16
|
+
}
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
// Browse cache + dispatch
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
/** The shared 60 s read-through window: a quota shield for anonymous upstreams, never a
|
|
21
|
+
* correctness contract. Keys are prefixed `<sourceId>|` so one source's family can be dropped
|
|
22
|
+
* without touching another's. */
|
|
23
|
+
export const CACHE_TTL_MS = 60_000;
|
|
24
|
+
/** The slow window for an upstream read that only moves over days (a leaderboard, a reviewed
|
|
25
|
+
* snapshot, a repository README): one declaration, because three readers share the same
|
|
26
|
+
* "10 minutes is fresh enough" policy and three local copies would drift apart. */
|
|
27
|
+
export const SLOW_CACHE_TTL_MS = 10 * 60_000;
|
|
28
|
+
export const cache = new Map();
|
|
29
|
+
/** Drop ONE source's entries from the shared window (key prefix `<sourceId>|`). */
|
|
30
|
+
export function clearPrefix(prefix) {
|
|
31
|
+
for (const key of [...cache.keys()])
|
|
32
|
+
if (key.startsWith(prefix))
|
|
33
|
+
cache.delete(key);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Per-source private caches (a cursor chain, a page-number map) register here so the generic
|
|
37
|
+
* refresh/reset verbs reach them without this module importing any harness file.
|
|
38
|
+
*/
|
|
39
|
+
const evictors = new Map();
|
|
40
|
+
export function registerBrowseCache(sourceId, evict) {
|
|
41
|
+
evictors.set(sourceId, evict);
|
|
42
|
+
}
|
|
43
|
+
/** Drop the whole browse cache (tests, and any caller that cannot name one source): the TTL is a
|
|
44
|
+
* rate-limit shield, not a correctness contract. */
|
|
45
|
+
export function resetBrowseCache() {
|
|
46
|
+
cache.clear();
|
|
47
|
+
for (const evict of evictors.values())
|
|
48
|
+
evict();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Drop ONE source's cached pages, so the next read asks upstream again.
|
|
52
|
+
*
|
|
53
|
+
* Only an explicit operator refresh reaches here (`browseSource(..., { refresh: true })`): the 60 s
|
|
54
|
+
* window exists to shield the anonymous quota, and a forced re-read is the one caller that means
|
|
55
|
+
* "that window is stale, ask now". It is narrowed to one source on purpose — refreshing ClawHub must
|
|
56
|
+
* not discard the pi.dev window another tab just warmed.
|
|
57
|
+
*/
|
|
58
|
+
export function evictBrowseCache(sourceId) {
|
|
59
|
+
clearPrefix(`${sourceId}|`);
|
|
60
|
+
evictors.get(sourceId)?.();
|
|
61
|
+
}
|
|
62
|
+
/** One browse request, dispatched by the source's OWN browse function. The source's declared sorts
|
|
63
|
+
* are the only orders that travel upstream — the facade never invents an ordering. */
|
|
64
|
+
export async function browseSource(source, query, limit, opts = {}) {
|
|
65
|
+
const page = Math.max(opts.page ?? 1, 1);
|
|
66
|
+
const sort = opts.sort && source.sorts?.includes(opts.sort) ? opts.sort : source.sorts?.[0];
|
|
67
|
+
if (!source.enabled) {
|
|
68
|
+
return {
|
|
69
|
+
ok: false,
|
|
70
|
+
code: 'unavailable',
|
|
71
|
+
reason: 'unavailable',
|
|
72
|
+
message: source.unavailableReason ?? `${source.label} is unavailable`,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const adapter = source.browse ?? browseViews.get(source.id)?.browse;
|
|
76
|
+
if (!adapter) {
|
|
77
|
+
return { ok: false, code: 'unsupported_source', reason: 'unsupportedSource', message: `no browse adapter for '${source.id}' yet` };
|
|
78
|
+
}
|
|
79
|
+
// A forced re-read drops this source's window BEFORE the adapter computes its cache key, so the
|
|
80
|
+
// adapter's own read-through starts from an empty family and genuinely asks upstream.
|
|
81
|
+
if (opts.refresh)
|
|
82
|
+
evictBrowseCache(source.id);
|
|
83
|
+
return adapter(query, limit, page, sort, opts.fetchImpl);
|
|
84
|
+
}
|
|
85
|
+
// ---------------------------------------------------------------------------
|
|
86
|
+
// Operator-added git sources: config + snapshots
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
/**
|
|
89
|
+
* Operator-added git marketplace sources (ADR-0015 §D6 "git-repo source type").
|
|
90
|
+
*
|
|
91
|
+
* A marketplace is ANY git repository the operator points at — a Claude-style
|
|
92
|
+
* `.claude-plugin/marketplace.json` catalog (the format grok / Goose clone), or a
|
|
93
|
+
* bare skills repository. The probe finds ONE canonical layer regardless of layout:
|
|
94
|
+
*
|
|
95
|
+
* 1. a pinned extension layer (`pi-extension`, `.claude-plugin`, …) when the operator named one;
|
|
96
|
+
* 2. a manifest-declared source directory wins (the author's intent, `plugins[].source`);
|
|
97
|
+
* 3. no manifest → the whole tree is scanned for `SKILL.md` directories.
|
|
98
|
+
*
|
|
99
|
+
* Per-harness adapter litter (`.codex-plugin/`, `.openclaw/skills/`, hooks, commands, rules) is
|
|
100
|
+
* layout noise: it never becomes a row and never enters an install payload. Dedup matters —
|
|
101
|
+
* generated copies (e.g. an `.openclaw/skills/` mirror of the canonical `skills/`) would surface
|
|
102
|
+
* the same skill twice, so a bare-tree scan keeps the SHORTEST path per normalized name and the
|
|
103
|
+
* manifest path wins by construction (it narrows the scan scope).
|
|
104
|
+
*
|
|
105
|
+
* Persistence is harness-domain state, owned here like the manifest and the applies ledger:
|
|
106
|
+
* - config `<ocrHome>/harness/plugin-market.json` — the operator's source list,
|
|
107
|
+
* bucketed per harness (`shared` = no pin, read by every served tab)
|
|
108
|
+
* - snapshots `<ocrHome>/harness/marketplaces/<slug>.json` — latest probe + bounded history
|
|
109
|
+
*
|
|
110
|
+
* A rescan (opt-in, per source) re-probes and diffs against the last snapshot: it REPORTS
|
|
111
|
+
* additions/removals/pin movement, it never rewrites installed copies — an upgrade still goes
|
|
112
|
+
* through the install route and its gates.
|
|
113
|
+
*/
|
|
114
|
+
/**
|
|
115
|
+
* Normalize an operator-supplied extension directory. `null` means "scan the whole repository";
|
|
116
|
+
* an object means the value was refused and names why. The grammar is deliberately narrow: the
|
|
117
|
+
* value is joined into a raw.githubusercontent URL, so absolute paths, drive letters, backslashes
|
|
118
|
+
* and `..` segments are refused rather than rewritten.
|
|
119
|
+
*/
|
|
120
|
+
export function normalizeExtensionDir(raw) {
|
|
121
|
+
if (raw === undefined || raw === null)
|
|
122
|
+
return null;
|
|
123
|
+
if (typeof raw !== 'string')
|
|
124
|
+
return { error: 'extensionDir must be a string' };
|
|
125
|
+
let value = raw.trim().replace(/\\/g, '/');
|
|
126
|
+
if (!value)
|
|
127
|
+
return null;
|
|
128
|
+
value = value.replace(/^\.\//, '').replace(/\/+$/, '');
|
|
129
|
+
if (!value)
|
|
130
|
+
return null;
|
|
131
|
+
if (value.startsWith('/') || /^[a-zA-Z]:/.test(value)) {
|
|
132
|
+
return { error: `extensionDir '${raw}' must be repository-relative` };
|
|
133
|
+
}
|
|
134
|
+
if (!/^[\w./-]+$/.test(value) || value.split('/').some((s) => s === '' || s === '.' || s === '..')) {
|
|
135
|
+
return { error: `invalid extensionDir '${raw}'` };
|
|
136
|
+
}
|
|
137
|
+
return value;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Operator input for a GitHub repository, normalized to `owner/repo`.
|
|
141
|
+
*
|
|
142
|
+
* The console's add-source box takes whatever the operator pasted: a full URL, a `github.com/...`
|
|
143
|
+
* reference, a `git@github.com:owner/repo.git` clone line, npm-style `github:owner/repo`, or the
|
|
144
|
+
* bare `owner/repo` pair. ONE parser decides all of it, so the skill axis and every plugin adapter
|
|
145
|
+
* accept exactly the same spellings instead of drifting apart. Deep links (a path below the repo)
|
|
146
|
+
* stay refused: that path is what `extensionDir` names, and silently dropping it would register a
|
|
147
|
+
* different layer than the one the operator pointed at.
|
|
148
|
+
*/
|
|
149
|
+
const GITHUB_REPO_INPUT = /^(?:(?:https?:\/\/)?(?:www\.)?github\.com[/:]|git@github\.com:|github:)?([\w.-]+)\/([\w.-]+?)(?:\.git)?\/?(?:[?#].*)?$/i;
|
|
150
|
+
export function githubRepoFromInput(value) {
|
|
151
|
+
const match = GITHUB_REPO_INPUT.exec(value.trim());
|
|
152
|
+
return match ? `${match[1]}/${match[2]}` : null;
|
|
153
|
+
}
|
|
154
|
+
/** A slug fragment for one extension directory (`pi-extension`, `claude-plugin`) — used only when
|
|
155
|
+
* the repo basename is already taken by another layer of the same repository. */
|
|
156
|
+
function extensionDirToken(dir) {
|
|
157
|
+
return dir
|
|
158
|
+
.toLowerCase()
|
|
159
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
160
|
+
.replace(/^-+|-+$/g, '')
|
|
161
|
+
.slice(0, 24) || 'layer';
|
|
162
|
+
}
|
|
163
|
+
function pluginMarketFile() {
|
|
164
|
+
return path.join(getOcrHomeDir(), 'harness', 'plugin-market.json');
|
|
165
|
+
}
|
|
166
|
+
function skillMarketFile() {
|
|
167
|
+
return path.join(getOcrHomeDir(), 'harness', 'skill-market.json');
|
|
168
|
+
}
|
|
169
|
+
function mcpMarketFile() {
|
|
170
|
+
return path.join(getOcrHomeDir(), 'harness', 'mcp-market.json');
|
|
171
|
+
}
|
|
172
|
+
/** The flat list both files replaced (one array with a `harness` field per entry). Read ONCE, then
|
|
173
|
+
* renamed: a downgraded build must not keep writing a second, silently divergent store. */
|
|
174
|
+
function legacyMarketplacesFile() {
|
|
175
|
+
return path.join(getOcrHomeDir(), 'harness', 'marketplaces.json');
|
|
176
|
+
}
|
|
177
|
+
/** Bucket for sources that pin no harness (the only bucket on the skill axis). */
|
|
178
|
+
const SHARED_BUCKET = 'shared';
|
|
179
|
+
/** Drop the in-memory scope markers on write: the file (and the bucket) carries them. */
|
|
180
|
+
function stripScope(entry) {
|
|
181
|
+
const { harness: _harness, axis: _axis, ...rest } = entry;
|
|
182
|
+
return rest;
|
|
183
|
+
}
|
|
184
|
+
/** Validate + normalize one persisted record; `axis` is the file and `scope` the bucket it came
|
|
185
|
+
* from — both win over whatever the record itself claims. */
|
|
186
|
+
function normalizeStoredEntry(raw, axis, scope) {
|
|
187
|
+
if (!raw || typeof raw.slug !== 'string' || typeof raw.repo !== 'string')
|
|
188
|
+
return null;
|
|
189
|
+
const { harness: _harness, axis: _axis, ...rest } = raw;
|
|
190
|
+
const scoped = normalizeExtensionDir(raw.extensionDir);
|
|
191
|
+
return {
|
|
192
|
+
...rest,
|
|
193
|
+
...(raw.type === 'npm' || raw.type === 'pypi' ? { type: raw.type } : { type: 'github' }),
|
|
194
|
+
extensionDir: typeof scoped === 'string' ? scoped : null,
|
|
195
|
+
...(scope ? { harness: scope } : {}),
|
|
196
|
+
axis,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
export function snapshotPath(slug, harness) {
|
|
200
|
+
if (harness) {
|
|
201
|
+
const harnessDir = path.join(getOcrHomeDir(), 'harness', 'marketplaces', harness);
|
|
202
|
+
const target = path.join(harnessDir, `${slug}.json`);
|
|
203
|
+
const fallback = path.join(getOcrHomeDir(), 'harness', 'marketplaces', `${slug}.json`);
|
|
204
|
+
if (fs.existsSync(target) || !fs.existsSync(fallback)) {
|
|
205
|
+
return target;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const globalPath = path.join(getOcrHomeDir(), 'harness', 'marketplaces', `${slug}.json`);
|
|
209
|
+
if (!fs.existsSync(globalPath)) {
|
|
210
|
+
try {
|
|
211
|
+
const parent = path.join(getOcrHomeDir(), 'harness', 'marketplaces');
|
|
212
|
+
if (fs.existsSync(parent)) {
|
|
213
|
+
for (const sub of fs.readdirSync(parent)) {
|
|
214
|
+
const subFile = path.join(parent, sub, `${slug}.json`);
|
|
215
|
+
if (fs.existsSync(subFile) && fs.statSync(subFile).isFile()) {
|
|
216
|
+
return subFile;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
catch { }
|
|
222
|
+
}
|
|
223
|
+
return globalPath;
|
|
224
|
+
}
|
|
225
|
+
/** History cap: enough to see a source's drift, small enough to never matter on disk. */
|
|
226
|
+
const SNAPSHOT_HISTORY_MAX = 20;
|
|
227
|
+
/** Row cap per source — a directory listing, not a crawler. */
|
|
228
|
+
const ROWS_MAX = 30;
|
|
229
|
+
/** Slug grammar: `mp-<slug>` must satisfy the install key's sourceId grammar (`^[a-z][/w-]*$`). */
|
|
230
|
+
const SLUG_RE = /^[a-z0-9][a-z0-9-]{0,38}$/;
|
|
231
|
+
const REPO_RE = /^[\w.-]+\/[\w.-]+$/;
|
|
232
|
+
const DEFAULT_RESCAN_INTERVAL_MS = 86_400_000;
|
|
233
|
+
/** Adapter directories that mean "the author shipped a per-harness form" (detection only). */
|
|
234
|
+
const ADAPTER_DIR_HINTS = [
|
|
235
|
+
{ prefix: '.claude-plugin/', label: 'claude' },
|
|
236
|
+
{ prefix: '.grok-plugin/', label: 'grok' },
|
|
237
|
+
{ prefix: '.codex-plugin/', label: 'codex' },
|
|
238
|
+
{ prefix: '.kimi-plugin/', label: 'kimi' },
|
|
239
|
+
{ prefix: '.qoder-plugin/', label: 'qoder' },
|
|
240
|
+
{ prefix: '.devin-plugin/', label: 'devin' },
|
|
241
|
+
{ prefix: '.antigravity-plugin/', label: 'antigravity' },
|
|
242
|
+
{ prefix: '.factory-plugin/', label: 'factory' },
|
|
243
|
+
{ prefix: '.agents/plugins/', label: 'goose' },
|
|
244
|
+
{ prefix: '.opencode/', label: 'opencode' },
|
|
245
|
+
{ prefix: '.cursor/', label: 'cursor' },
|
|
246
|
+
{ prefix: '.cursor-plugin/', label: 'cursor' },
|
|
247
|
+
{ prefix: '.clinerules/', label: 'cline' },
|
|
248
|
+
{ prefix: '.openclaw/', label: 'openclaw' },
|
|
249
|
+
{ prefix: 'pi-extension/', label: 'pi' },
|
|
250
|
+
{ prefix: 'gemini-extension.json', label: 'gemini-cli' },
|
|
251
|
+
{ prefix: 'hooks/', label: 'hooks' },
|
|
252
|
+
{ prefix: 'commands/', label: 'commands' },
|
|
253
|
+
];
|
|
254
|
+
// ---------------------------------------------------------------------------
|
|
255
|
+
// Config store
|
|
256
|
+
// ---------------------------------------------------------------------------
|
|
257
|
+
/** Plugin axis: one bucket per harness plus `shared`; a bucket IS the scope. */
|
|
258
|
+
function readPluginEntries() {
|
|
259
|
+
try {
|
|
260
|
+
const parsed = JSON.parse(fs.readFileSync(pluginMarketFile(), 'utf8'));
|
|
261
|
+
const entries = [];
|
|
262
|
+
for (const [bucket, list] of Object.entries(parsed)) {
|
|
263
|
+
if (!Array.isArray(list))
|
|
264
|
+
continue;
|
|
265
|
+
const scope = bucket === SHARED_BUCKET ? undefined : bucket;
|
|
266
|
+
for (const raw of list) {
|
|
267
|
+
const entry = normalizeStoredEntry(raw, 'plugin', scope);
|
|
268
|
+
if (entry)
|
|
269
|
+
entries.push(entry);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return entries;
|
|
273
|
+
}
|
|
274
|
+
catch {
|
|
275
|
+
return [];
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/** MCP axis: ONE shared scope. A package source names a registry read whose launch is
|
|
279
|
+
* host-neutral (only the landing file differs), so every MCP-capable harness reads the same
|
|
280
|
+
* entries. Legacy per-harness buckets are accepted as shared on read and flattened by the next
|
|
281
|
+
* write — a source added before the amendment must not disappear from sibling tabs. */
|
|
282
|
+
function readMcpEntries() {
|
|
283
|
+
try {
|
|
284
|
+
const parsed = JSON.parse(fs.readFileSync(mcpMarketFile(), 'utf8'));
|
|
285
|
+
const entries = [];
|
|
286
|
+
for (const list of Object.values(parsed)) {
|
|
287
|
+
if (!Array.isArray(list))
|
|
288
|
+
continue;
|
|
289
|
+
for (const raw of list) {
|
|
290
|
+
const entry = normalizeStoredEntry(raw, 'mcp');
|
|
291
|
+
if (entry)
|
|
292
|
+
entries.push(entry);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return entries;
|
|
296
|
+
}
|
|
297
|
+
catch {
|
|
298
|
+
return [];
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
/** Skill axis: one shared bucket — a skill is global, so a harness key here would be a lie. */
|
|
302
|
+
function readSkillEntries() {
|
|
303
|
+
try {
|
|
304
|
+
const parsed = JSON.parse(fs.readFileSync(skillMarketFile(), 'utf8'));
|
|
305
|
+
const list = Array.isArray(parsed) ? parsed : Array.isArray(parsed.shared) ? parsed.shared : [];
|
|
306
|
+
return list
|
|
307
|
+
.map((raw) => normalizeStoredEntry(raw, 'skill'))
|
|
308
|
+
.filter((entry) => entry !== null);
|
|
309
|
+
}
|
|
310
|
+
catch {
|
|
311
|
+
return [];
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
/** Read entries tolerantly: unknown fields are preserved, malformed extension scopes are dropped
|
|
315
|
+
* (a source registered before scoping existed keeps its whole-repository scan). */
|
|
316
|
+
function readConfigFile() {
|
|
317
|
+
if (!fs.existsSync(pluginMarketFile()) && !fs.existsSync(skillMarketFile()) && !fs.existsSync(mcpMarketFile())) {
|
|
318
|
+
const migrated = migrateLegacyStore();
|
|
319
|
+
if (migrated)
|
|
320
|
+
return { marketplaces: migrated };
|
|
321
|
+
}
|
|
322
|
+
return { marketplaces: [...readSkillEntries(), ...readPluginEntries(), ...readMcpEntries()] };
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* One-time upgrade from the flat `marketplaces.json` list. Each entry lands in the axis that
|
|
326
|
+
* would have SHOWN it before the split: a harness pin is a plugin source by construction, and an
|
|
327
|
+
* unpinned source with skill rows but no plugin rows was a skill source (snapshot inference, since
|
|
328
|
+
* the old file stored no axis). The legacy file is then renamed, never deleted: a downgraded build
|
|
329
|
+
* must not keep writing a second, silently divergent store.
|
|
330
|
+
*/
|
|
331
|
+
function migrateLegacyStore() {
|
|
332
|
+
let legacy;
|
|
333
|
+
try {
|
|
334
|
+
legacy = JSON.parse(fs.readFileSync(legacyMarketplacesFile(), 'utf8'));
|
|
335
|
+
}
|
|
336
|
+
catch {
|
|
337
|
+
return null;
|
|
338
|
+
}
|
|
339
|
+
if (!Array.isArray(legacy.marketplaces))
|
|
340
|
+
return null;
|
|
341
|
+
const migrated = [];
|
|
342
|
+
for (const raw of legacy.marketplaces) {
|
|
343
|
+
const entry = normalizeStoredEntry(raw, 'plugin', typeof raw?.harness === 'string' ? raw.harness : undefined);
|
|
344
|
+
if (!entry)
|
|
345
|
+
continue;
|
|
346
|
+
if (!entry.harness) {
|
|
347
|
+
const snap = latestSnapshot(entry.slug, null);
|
|
348
|
+
if (snap && snap.plugins.length === 0 && snap.rows.length > 0)
|
|
349
|
+
entry.axis = 'skill';
|
|
350
|
+
}
|
|
351
|
+
migrated.push(entry);
|
|
352
|
+
}
|
|
353
|
+
writeConfigFile(migrated);
|
|
354
|
+
try {
|
|
355
|
+
const legacyFile = legacyMarketplacesFile();
|
|
356
|
+
fs.renameSync(legacyFile, legacyFile.replace(/\.json$/, '.legacy.json'));
|
|
357
|
+
}
|
|
358
|
+
catch {
|
|
359
|
+
// best-effort: the new files are already written; the old one is then simply stale
|
|
360
|
+
}
|
|
361
|
+
return migrated;
|
|
362
|
+
}
|
|
363
|
+
/** Deterministic layout: the shared bucket first, then harness buckets alphabetically. */
|
|
364
|
+
function orderedBuckets(buckets) {
|
|
365
|
+
const ordered = { [SHARED_BUCKET]: buckets[SHARED_BUCKET] ?? [] };
|
|
366
|
+
for (const bucket of Object.keys(buckets).filter((key) => key !== SHARED_BUCKET).sort()) {
|
|
367
|
+
ordered[bucket] = buckets[bucket] ?? [];
|
|
368
|
+
}
|
|
369
|
+
return ordered;
|
|
370
|
+
}
|
|
371
|
+
function writeConfigFile(entries) {
|
|
372
|
+
const write = (file, data) => {
|
|
373
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
374
|
+
if (fs.existsSync(file))
|
|
375
|
+
createBackup(file);
|
|
376
|
+
safeWriteJson(file, data);
|
|
377
|
+
};
|
|
378
|
+
const pluginBuckets = { [SHARED_BUCKET]: [] };
|
|
379
|
+
const mcpBuckets = { [SHARED_BUCKET]: [] };
|
|
380
|
+
for (const entry of entries) {
|
|
381
|
+
if (entry.axis === 'skill')
|
|
382
|
+
continue;
|
|
383
|
+
// The MCP axis has no harness scope: a package source is read by every capable tab, so it
|
|
384
|
+
// always lands in `shared` and any legacy pin is flattened here.
|
|
385
|
+
const bucket = entry.axis === 'mcp' ? SHARED_BUCKET : (entry.harness ?? SHARED_BUCKET);
|
|
386
|
+
const target = entry.axis === 'mcp' ? mcpBuckets : pluginBuckets;
|
|
387
|
+
(target[bucket] ??= []).push(stripScope(entry));
|
|
388
|
+
}
|
|
389
|
+
write(pluginMarketFile(), orderedBuckets(pluginBuckets));
|
|
390
|
+
write(mcpMarketFile(), orderedBuckets(mcpBuckets));
|
|
391
|
+
write(skillMarketFile(), {
|
|
392
|
+
[SHARED_BUCKET]: entries.filter((entry) => entry.axis === 'skill').map(stripScope),
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
export function listMarketplaceEntries(harness) {
|
|
396
|
+
const all = readConfigFile().marketplaces;
|
|
397
|
+
if (!harness)
|
|
398
|
+
return all;
|
|
399
|
+
return all.filter((e) => !e.harness || e.harness === harness);
|
|
400
|
+
}
|
|
401
|
+
export function getMarketplaceEntry(slug, harness) {
|
|
402
|
+
const entries = readConfigFile().marketplaces;
|
|
403
|
+
if (harness) {
|
|
404
|
+
return entries.find((e) => e.slug === slug && (!e.harness || e.harness === harness));
|
|
405
|
+
}
|
|
406
|
+
return entries.find((e) => e.slug === slug);
|
|
407
|
+
}
|
|
408
|
+
/** The sourceId grammar name for a slug (`mp-<slug>`). */
|
|
409
|
+
export function marketplaceSourceId(slug) {
|
|
410
|
+
return `mp-${slug}`;
|
|
411
|
+
}
|
|
412
|
+
export function validateSlug(slug) {
|
|
413
|
+
if (!SLUG_RE.test(slug))
|
|
414
|
+
return `invalid slug '${slug}' (expected ${SLUG_RE})`;
|
|
415
|
+
if (listMarketplaceEntries().some((e) => e.slug === slug))
|
|
416
|
+
return `slug '${slug}' is already configured`;
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Name the scope that already holds a repository. A layer-pinned entry serves exactly ONE harness,
|
|
421
|
+
* a shared entry serves every harness whose form its snapshot recorded — so only the pin is stated
|
|
422
|
+
* as an owner, and the layer is always stated (it is why a sibling tab lists nothing).
|
|
423
|
+
*/
|
|
424
|
+
function duplicateOwner(entry) {
|
|
425
|
+
const owner = entry.harness ? ` for ${entry.harness}` : '';
|
|
426
|
+
const layer = entry.extensionDir ? ` (layer ${entry.extensionDir})` : '';
|
|
427
|
+
return `${owner}${layer}`;
|
|
428
|
+
}
|
|
429
|
+
/** The repository's own slug candidate: its lowercase basename, punctuation folded to dashes. */
|
|
430
|
+
function slugBase(repo) {
|
|
431
|
+
return (repo
|
|
432
|
+
.replace(/\/\*$/, '')
|
|
433
|
+
.split('/')
|
|
434
|
+
.pop()
|
|
435
|
+
?.toLowerCase()
|
|
436
|
+
.replace(/^@/, '')
|
|
437
|
+
.replace(/[^a-z0-9-]/g, '-')
|
|
438
|
+
.replace(/^-+|-+$/g, '') || 'source');
|
|
439
|
+
}
|
|
440
|
+
/** `base` plus one disambiguating token (`<base>-<token>`), suffixed if the store already has it. */
|
|
441
|
+
function derivedSlug(base, token, taken) {
|
|
442
|
+
let candidate = `${base}-${token}`.slice(0, 40).replace(/-+$/g, '');
|
|
443
|
+
for (let i = 2; taken.has(candidate); i++)
|
|
444
|
+
candidate = `${base}-${token}-${i}`.slice(0, 40).replace(/-+$/g, '');
|
|
445
|
+
return candidate;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Pick the slug for a (repo, extension directory) pair. The repo basename is the slug; when that
|
|
449
|
+
* basename already names ANOTHER layer of the same repository, the layer joins the slug
|
|
450
|
+
* (`ponytail-pi-extension`), so one repo can ship a pi form and a claude form as two sources.
|
|
451
|
+
* Re-registering the same (repo, directory) pair is a conflict, never a silent second entry.
|
|
452
|
+
*
|
|
453
|
+
* The duplicate answer is STORE-WIDE, never per harness: a slug is one `mp-<slug>` sourceId for
|
|
454
|
+
* the whole registry (`host/registry.ts` resolves it without a harness, and the skill axis
|
|
455
|
+
* addresses entries by slug alone). `code` lets a caller act on the CAUSE — `repo_taken` is the
|
|
456
|
+
* repository itself, which a second harness answers with its OWN scoped source
|
|
457
|
+
* (`resolveScopedSlug`) instead of a twin slug. The message names the holding entry's pin and
|
|
458
|
+
* layer, because the tab the operator is working in lists only its own scope.
|
|
459
|
+
*/
|
|
460
|
+
export function resolveSlug(repo, extensionDir) {
|
|
461
|
+
const base = slugBase(repo);
|
|
462
|
+
const entries = listMarketplaceEntries();
|
|
463
|
+
const dir = extensionDir ?? null;
|
|
464
|
+
const exact = entries.find((e) => e.repo === repo && (e.extensionDir ?? null) === dir);
|
|
465
|
+
if (exact) {
|
|
466
|
+
return {
|
|
467
|
+
ok: false,
|
|
468
|
+
code: 'repo_taken',
|
|
469
|
+
params: { repo, slug: exact.slug, ...(exact.harness ? { harness: exact.harness } : {}), ...(exact.extensionDir ? { layer: exact.extensionDir } : {}) },
|
|
470
|
+
message: `'${repo}'${dir ? ` (${dir})` : ''} is already configured as '${exact.slug}'${duplicateOwner(exact)}`,
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
const layerHolder = entries.find((e) => e.repo === repo);
|
|
474
|
+
if (!dir && layerHolder) {
|
|
475
|
+
// The same repository under another layer: a layer-less add is ONE repository twice in the
|
|
476
|
+
// global store, so the answer names the entry that already carries it.
|
|
477
|
+
return {
|
|
478
|
+
ok: false,
|
|
479
|
+
code: 'repo_taken',
|
|
480
|
+
params: { repo, slug: layerHolder.slug, ...(layerHolder.harness ? { harness: layerHolder.harness } : {}), ...(layerHolder.extensionDir ? { layer: layerHolder.extensionDir } : {}) },
|
|
481
|
+
message: `'${repo}' is already configured as '${layerHolder.slug}'${duplicateOwner(layerHolder)}`,
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
const taken = new Set(entries.map((e) => e.slug));
|
|
485
|
+
if (!taken.has(base) && !layerHolder)
|
|
486
|
+
return { ok: true, slug: base };
|
|
487
|
+
// Another layer of the same repo: the extension directory disambiguates. A different repository
|
|
488
|
+
// that happens to share a basename keeps the historical conflict (never silently aliased).
|
|
489
|
+
if (!dir) {
|
|
490
|
+
const holder = entries.find((e) => e.slug === base);
|
|
491
|
+
return {
|
|
492
|
+
ok: false,
|
|
493
|
+
code: 'slug_taken',
|
|
494
|
+
params: { repo: holder?.repo ?? repo, slug: base },
|
|
495
|
+
message: `slug '${base}' is already configured${holder ? ` by '${holder.repo}'` : ''}`,
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
const candidate = derivedSlug(base, extensionDirToken(dir), taken);
|
|
499
|
+
if (!SLUG_RE.test(candidate)) {
|
|
500
|
+
return { ok: false, code: 'slug_unavailable', params: { repo, slug: base }, message: `cannot derive a slug for '${repo}' (${dir})` };
|
|
501
|
+
}
|
|
502
|
+
return { ok: true, slug: candidate };
|
|
503
|
+
}
|
|
504
|
+
/** `resolveSlug`'s refusal codes as console reasons (ADR-0015 §D11): the two duplicate causes stay
|
|
505
|
+
* distinct so the message names the occupying repository instead of echoing a slug. Shared by the
|
|
506
|
+
* plugin and skill registration paths — the collision logic is one store rule, not two. */
|
|
507
|
+
export const SLUG_FAILURE_REASON = {
|
|
508
|
+
repo_taken: 'already_configured',
|
|
509
|
+
slug_taken: 'slug_taken',
|
|
510
|
+
slug_unavailable: 'invalid_source',
|
|
511
|
+
};
|
|
512
|
+
/**
|
|
513
|
+
* The slug for a repository that ANOTHER harness already carries and this one wants its own copy
|
|
514
|
+
* of: no extension layer is named, so the HARNESS is the disambiguating token
|
|
515
|
+
* (`mp-<repo>-<harness>`). A harness-scoped source is a distinct identity — it is enabled, synced
|
|
516
|
+
* and removed on its own tab — while the slug stays one `mp-` id for the whole store.
|
|
517
|
+
*/
|
|
518
|
+
export function resolveScopedSlug(repo, harness) {
|
|
519
|
+
const base = slugBase(repo);
|
|
520
|
+
const taken = new Set(listMarketplaceEntries().map((e) => e.slug));
|
|
521
|
+
const candidate = derivedSlug(base, extensionDirToken(harness), taken);
|
|
522
|
+
if (!SLUG_RE.test(candidate))
|
|
523
|
+
return { ok: false, message: `cannot derive a slug for '${repo}' (${harness})` };
|
|
524
|
+
return { ok: true, slug: candidate };
|
|
525
|
+
}
|
|
526
|
+
export function addMarketplaceEntry(input) {
|
|
527
|
+
const scoped = normalizeExtensionDir(input.extensionDir);
|
|
528
|
+
const entry = {
|
|
529
|
+
slug: input.slug,
|
|
530
|
+
catalog: input.catalog?.trim() || 'default',
|
|
531
|
+
repo: input.repo,
|
|
532
|
+
type: input.type === 'npm' || input.type === 'pypi' ? input.type : 'github',
|
|
533
|
+
enabled: true,
|
|
534
|
+
addedAt: Date.now(),
|
|
535
|
+
rescan: {
|
|
536
|
+
enabled: input.rescan?.enabled === true,
|
|
537
|
+
intervalMs: clampInterval(input.rescan?.intervalMs),
|
|
538
|
+
},
|
|
539
|
+
...(input.harness ? { harness: input.harness } : {}),
|
|
540
|
+
extensionDir: typeof scoped === 'string' ? scoped : null,
|
|
541
|
+
axis: input.axis === 'skill' || input.axis === 'mcp' ? input.axis : 'plugin',
|
|
542
|
+
};
|
|
543
|
+
const entries = readConfigFile().marketplaces;
|
|
544
|
+
// One slug = one `mp-<slug>` sourceId for the WHOLE store (see `resolveSlug`): a twin under
|
|
545
|
+
// another harness would resolve to whichever entry the registry reads first.
|
|
546
|
+
const clash = entries.find((e) => e.slug === input.slug);
|
|
547
|
+
if (clash) {
|
|
548
|
+
throw new Error(`slug '${input.slug}' is already configured${clash.harness ? ` for ${clash.harness}` : ''}`);
|
|
549
|
+
}
|
|
550
|
+
entries.push(entry);
|
|
551
|
+
writeConfigFile(entries);
|
|
552
|
+
return entry;
|
|
553
|
+
}
|
|
554
|
+
export function updateMarketplaceEntry(slug, patch, harness) {
|
|
555
|
+
const entries = readConfigFile().marketplaces;
|
|
556
|
+
const entry = entries.find((e) => e.slug === slug && (!harness || !e.harness || e.harness === harness));
|
|
557
|
+
if (!entry)
|
|
558
|
+
return null;
|
|
559
|
+
if (typeof patch.enabled === 'boolean')
|
|
560
|
+
entry.enabled = patch.enabled;
|
|
561
|
+
if (typeof patch.catalog === 'string')
|
|
562
|
+
entry.catalog = patch.catalog.trim() || 'default';
|
|
563
|
+
if (patch.rescan) {
|
|
564
|
+
if (typeof patch.rescan.enabled === 'boolean')
|
|
565
|
+
entry.rescan.enabled = patch.rescan.enabled;
|
|
566
|
+
if (patch.rescan.intervalMs !== undefined)
|
|
567
|
+
entry.rescan.intervalMs = clampInterval(patch.rescan.intervalMs);
|
|
568
|
+
}
|
|
569
|
+
writeConfigFile(entries);
|
|
570
|
+
return entry;
|
|
571
|
+
}
|
|
572
|
+
/** Removing a source is config-level only: installed copies keep their manifest records and are
|
|
573
|
+
* uninstalled through the normal removal route — the ledger carries the provenance. */
|
|
574
|
+
export function removeMarketplaceEntry(slug, harness) {
|
|
575
|
+
const entries = readConfigFile().marketplaces;
|
|
576
|
+
const target = entries.find((e) => e.slug === slug && (!harness || !e.harness || e.harness === harness));
|
|
577
|
+
if (!target)
|
|
578
|
+
return false;
|
|
579
|
+
writeConfigFile(entries.filter((e) => e !== target));
|
|
580
|
+
try {
|
|
581
|
+
// MCP owns ONE global snapshot (a legacy pin may still have left a harness copy); every other
|
|
582
|
+
// axis keeps its snapshot beside the scope that wrote it.
|
|
583
|
+
fs.rmSync(snapshotPath(slug, target.axis === 'mcp' ? null : harness), { force: true });
|
|
584
|
+
if (target.axis === 'mcp' && harness)
|
|
585
|
+
fs.rmSync(snapshotPath(slug, harness), { force: true });
|
|
586
|
+
}
|
|
587
|
+
catch {
|
|
588
|
+
// snapshot cleanup is best-effort; the config removal already committed
|
|
589
|
+
}
|
|
590
|
+
return true;
|
|
591
|
+
}
|
|
592
|
+
function clampInterval(ms) {
|
|
593
|
+
if (typeof ms !== 'number' || !Number.isFinite(ms))
|
|
594
|
+
return DEFAULT_RESCAN_INTERVAL_MS;
|
|
595
|
+
return Math.min(Math.max(Math.round(ms), 60_000), 30 * 86_400_000);
|
|
596
|
+
}
|
|
597
|
+
// ---------------------------------------------------------------------------
|
|
598
|
+
// Snapshot store
|
|
599
|
+
// ---------------------------------------------------------------------------
|
|
600
|
+
export function latestSnapshot(slug, harness) {
|
|
601
|
+
try {
|
|
602
|
+
const parsed = JSON.parse(fs.readFileSync(snapshotPath(slug, harness), 'utf8'));
|
|
603
|
+
return parsed.latest ?? null;
|
|
604
|
+
}
|
|
605
|
+
catch {
|
|
606
|
+
return null;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
export function snapshotHistory(slug, harness) {
|
|
610
|
+
try {
|
|
611
|
+
const parsed = JSON.parse(fs.readFileSync(snapshotPath(slug, harness), 'utf8'));
|
|
612
|
+
return Array.isArray(parsed.history) ? parsed.history : [];
|
|
613
|
+
}
|
|
614
|
+
catch {
|
|
615
|
+
return [];
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
function writeSnapshot(snapshot, harness) {
|
|
619
|
+
const file = snapshotPath(snapshot.slug, harness);
|
|
620
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
621
|
+
const history = [snapshot, ...snapshotHistory(snapshot.slug, harness)]
|
|
622
|
+
// The history dedupes on (sha, rows) — a rescan that saw no change replaces the head instead
|
|
623
|
+
// of appending a twin.
|
|
624
|
+
.filter((s, i, all) => i === 0 || all.findIndex((p) => p.sha === s.sha && rowsFingerprint(s.rows) === rowsFingerprint(p.rows)) === i)
|
|
625
|
+
.slice(0, SNAPSHOT_HISTORY_MAX);
|
|
626
|
+
if (fs.existsSync(file))
|
|
627
|
+
createBackup(file);
|
|
628
|
+
safeWriteJson(file, { latest: snapshot, history });
|
|
629
|
+
}
|
|
630
|
+
function rowsFingerprint(rows) {
|
|
631
|
+
return rows.map((r) => `${r.dir}:${r.name}`).sort().join('|');
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Persist an npm source's packages in the SAME snapshot store the git sources use, so browse and
|
|
635
|
+
* harvest answer from local bytes either way. An npm source has no commit pin, no star count and no
|
|
636
|
+
* repository tree: `sha` stays empty and the packages ARE the plugin rows.
|
|
637
|
+
*/
|
|
638
|
+
export function writeNpmSourceSnapshot(slug, packages, harness) {
|
|
639
|
+
const snapshot = {
|
|
640
|
+
slug,
|
|
641
|
+
probedAt: Date.now(),
|
|
642
|
+
sha: '',
|
|
643
|
+
stars: null,
|
|
644
|
+
pushedAt: null,
|
|
645
|
+
manifest: null,
|
|
646
|
+
extensionDir: null,
|
|
647
|
+
plugins: packages.map((pkg) => ({ name: pkg.name, source: '', description: pkg.description })),
|
|
648
|
+
mcps: [],
|
|
649
|
+
// An npm package serves every runtime that has a package-manager landing — no detection is
|
|
650
|
+
// possible (and none is claimed): the rows carry no host restriction.
|
|
651
|
+
hosts: [],
|
|
652
|
+
marketplace: null,
|
|
653
|
+
authorAdapters: [],
|
|
654
|
+
unsupported: [],
|
|
655
|
+
rows: [],
|
|
656
|
+
};
|
|
657
|
+
writeSnapshot(snapshot, harness);
|
|
658
|
+
return snapshot;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Persist an MCP source's single package in the same snapshot store. An MCP source is ONE package
|
|
662
|
+
* (no scope listing), so the snapshot holds one `mcps` row and no plugin rows: browse reads the
|
|
663
|
+
* package metadata, while the install handle (`<npm|pypi>:<name>`) stays version-free so every
|
|
664
|
+
* install resolves and pins the version current at that moment.
|
|
665
|
+
*/
|
|
666
|
+
export function writeMcpSourceSnapshot(slug, pkg, harness) {
|
|
667
|
+
const snapshot = {
|
|
668
|
+
slug,
|
|
669
|
+
probedAt: Date.now(),
|
|
670
|
+
sha: '',
|
|
671
|
+
stars: null,
|
|
672
|
+
pushedAt: null,
|
|
673
|
+
manifest: null,
|
|
674
|
+
extensionDir: null,
|
|
675
|
+
plugins: [],
|
|
676
|
+
mcps: [pkg],
|
|
677
|
+
hosts: [],
|
|
678
|
+
marketplace: null,
|
|
679
|
+
authorAdapters: [],
|
|
680
|
+
unsupported: [],
|
|
681
|
+
rows: [],
|
|
682
|
+
};
|
|
683
|
+
writeSnapshot(snapshot, harness);
|
|
684
|
+
return snapshot;
|
|
685
|
+
}
|
|
686
|
+
/** The probe's raw GitHub reads share the market retry policy (one helper, §D6): a repository
|
|
687
|
+
* tree plus one `SKILL.md` per directory is a long walk, so a stalled socket must fail the read
|
|
688
|
+
* inside the documented budget instead of hanging the request. */
|
|
689
|
+
async function ghJson(url, fetchImpl) {
|
|
690
|
+
try {
|
|
691
|
+
const res = await fetchWithRetry(url, { headers: githubHeaders() }, undefined, { fetchImpl });
|
|
692
|
+
if (!res.ok)
|
|
693
|
+
return null;
|
|
694
|
+
return (await res.json());
|
|
695
|
+
}
|
|
696
|
+
catch {
|
|
697
|
+
return null;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
async function ghText(url, fetchImpl) {
|
|
701
|
+
try {
|
|
702
|
+
const res = await fetchWithRetry(url, { headers: githubHeaders() }, undefined, { fetchImpl });
|
|
703
|
+
if (!res.ok)
|
|
704
|
+
return null;
|
|
705
|
+
return await res.text();
|
|
706
|
+
}
|
|
707
|
+
catch {
|
|
708
|
+
return null;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
/** Minimal SKILL.md frontmatter reader: `name` plus a `description` folded to one line. */
|
|
712
|
+
export function readFrontmatter(text) {
|
|
713
|
+
const match = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text);
|
|
714
|
+
if (!match)
|
|
715
|
+
return { name: null, description: null };
|
|
716
|
+
const body = match[1];
|
|
717
|
+
let name = null;
|
|
718
|
+
let description = null;
|
|
719
|
+
const lines = body.split(/\r?\n/);
|
|
720
|
+
for (let i = 0; i < lines.length; i++) {
|
|
721
|
+
const nameMatch = /^name:\s*(.+?)\s*$/.exec(lines[i]);
|
|
722
|
+
if (nameMatch) {
|
|
723
|
+
name = nameMatch[1].replace(/^["']|["']$/g, '');
|
|
724
|
+
continue;
|
|
725
|
+
}
|
|
726
|
+
const descMatch = /^description:\s*(>[-+]?\s*|\|[-+]?\s*|(.+?)\s*)$/.exec(lines[i]);
|
|
727
|
+
if (descMatch) {
|
|
728
|
+
const inline = descMatch[2];
|
|
729
|
+
const parts = [];
|
|
730
|
+
if (inline)
|
|
731
|
+
parts.push(inline);
|
|
732
|
+
// Folded/literal block scalars: continuation lines are indented deeper than the key.
|
|
733
|
+
for (let j = i + 1; j < lines.length && (/^\s/.test(lines[j]) || lines[j] === ''); j++) {
|
|
734
|
+
if (lines[j].trim())
|
|
735
|
+
parts.push(lines[j].trim());
|
|
736
|
+
i = j;
|
|
737
|
+
}
|
|
738
|
+
description = parts.join(' ').trim() || null;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
return { name, description };
|
|
742
|
+
}
|
|
743
|
+
/** Normalize one probe result into rows: scan scope → SKILL.md dirs → frontmatter titles. */
|
|
744
|
+
export async function rowsForScope(repo, sha, scopeDirs, tree, fetchImpl) {
|
|
745
|
+
const dirs = skillDirs(tree)
|
|
746
|
+
.filter((d) => (scopeDirs ? scopeDirs.some((scope) => (scope === '' ? true : d === scope || d.startsWith(`${scope}/`))) : true))
|
|
747
|
+
// Shortest path first: the dedupe below keeps the canonical copy over generated mirrors.
|
|
748
|
+
.sort((a, b) => a.length - b.length || a.localeCompare(b));
|
|
749
|
+
const rows = [];
|
|
750
|
+
const seen = new Set();
|
|
751
|
+
for (const dir of dirs) {
|
|
752
|
+
if (rows.length >= ROWS_MAX)
|
|
753
|
+
break;
|
|
754
|
+
const base = dir.split('/').pop() ?? dir;
|
|
755
|
+
if (seen.has(base))
|
|
756
|
+
continue;
|
|
757
|
+
const url = `https://raw.githubusercontent.com/${repo}/${sha}/${dir}/SKILL.md`;
|
|
758
|
+
const text = await ghText(url, fetchImpl);
|
|
759
|
+
const frontmatter = text ? readFrontmatter(text) : { name: null, description: null };
|
|
760
|
+
seen.add(base);
|
|
761
|
+
rows.push({
|
|
762
|
+
dir,
|
|
763
|
+
name: base,
|
|
764
|
+
title: frontmatter.name ?? base,
|
|
765
|
+
description: frontmatter.description,
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
return rows;
|
|
769
|
+
}
|
|
770
|
+
export async function probeMarketplace(entry, fetchImpl = fetch, opts = {}) {
|
|
771
|
+
if (!REPO_RE.test(entry.repo))
|
|
772
|
+
return { ok: false, code: 'bad_request', message: `invalid repo '${entry.repo}'` };
|
|
773
|
+
const scoped = normalizeExtensionDir(entry.extensionDir);
|
|
774
|
+
if (scoped !== null && typeof scoped !== 'string')
|
|
775
|
+
return { ok: false, code: 'bad_request', message: scoped.error };
|
|
776
|
+
const explicitDir = scoped;
|
|
777
|
+
const fallback = explicitDir === null && opts.defaultExtensionDir ? normalizeExtensionDir(opts.defaultExtensionDir) : null;
|
|
778
|
+
const defaultDir = typeof fallback === 'string' ? fallback : null;
|
|
779
|
+
const api = `https://api.github.com/repos/${entry.repo}`;
|
|
780
|
+
const meta = await ghJson(api, fetchImpl);
|
|
781
|
+
if (!meta)
|
|
782
|
+
return { ok: false, code: 'unavailable', message: `cannot read https://github.com/${entry.repo}` };
|
|
783
|
+
const head = await ghJson(`${api}/commits/${encodeURIComponent(meta.default_branch)}`, fetchImpl);
|
|
784
|
+
if (!head)
|
|
785
|
+
return { ok: false, code: 'unavailable', message: 'cannot read HEAD commit' };
|
|
786
|
+
const treeRes = await ghJson(`${api}/git/trees/${head.sha}?recursive=1`, fetchImpl);
|
|
787
|
+
if (!treeRes || !Array.isArray(treeRes.tree))
|
|
788
|
+
return { ok: false, code: 'unavailable', message: 'cannot read the git tree' };
|
|
789
|
+
const tree = treeRes.tree;
|
|
790
|
+
const present = (dir) => tree.some((e) => e.path === dir || e.path.startsWith(`${dir}/`));
|
|
791
|
+
const raw = (file) => `https://raw.githubusercontent.com/${entry.repo}/${head.sha}/${file}`;
|
|
792
|
+
// A pinned layer must exist: silently scanning the repo root instead would harvest another
|
|
793
|
+
// harness's form and report success over a directory the operator asked for but never got.
|
|
794
|
+
if (explicitDir && !present(explicitDir)) {
|
|
795
|
+
return { ok: false, code: 'missing_dir', message: `'${entry.repo}' has no '${explicitDir}' directory` };
|
|
796
|
+
}
|
|
797
|
+
const probes = opts.hosts && opts.hosts.length > 0
|
|
798
|
+
? opts.hosts
|
|
799
|
+
: [
|
|
800
|
+
{
|
|
801
|
+
harness: entry.harness ?? 'claude',
|
|
802
|
+
dir: defaultDir,
|
|
803
|
+
options: opts,
|
|
804
|
+
},
|
|
805
|
+
];
|
|
806
|
+
// SUPPORT IS DETECTED, not declared: a harness supports the repository when its own form
|
|
807
|
+
// directory exists OR its own root manifest sits at the repo root (for a manifest every
|
|
808
|
+
// repository ships, only when its CONTENT really is that harness's form). The two are a UNION:
|
|
809
|
+
// kimi publishes the canonical `kimi.plugin.json` with `.kimi-plugin/` as the fallback, and
|
|
810
|
+
// openclaw publishes `openclaw.plugin.json` beside `.openclaw/` — consulting only the directory
|
|
811
|
+
// would refuse the layout the vendor documents first.
|
|
812
|
+
const detected = [];
|
|
813
|
+
for (const probe of probes) {
|
|
814
|
+
if (probe.dir && present(probe.dir)) {
|
|
815
|
+
detected.push(probe);
|
|
816
|
+
continue;
|
|
817
|
+
}
|
|
818
|
+
const reader = probe.options.manifest;
|
|
819
|
+
if (!reader?.atRoot)
|
|
820
|
+
continue;
|
|
821
|
+
if (!tree.some((e) => e.path === reader.file && e.type === 'blob'))
|
|
822
|
+
continue;
|
|
823
|
+
if (reader.detect) {
|
|
824
|
+
const text = await ghText(raw(reader.file), fetchImpl);
|
|
825
|
+
let declared = null;
|
|
826
|
+
try {
|
|
827
|
+
declared = text ? JSON.parse(text) : null;
|
|
828
|
+
}
|
|
829
|
+
catch {
|
|
830
|
+
declared = null; // a broken manifest is not a manifest
|
|
831
|
+
}
|
|
832
|
+
if (!declared || !reader.detect(declared))
|
|
833
|
+
continue;
|
|
834
|
+
}
|
|
835
|
+
detected.push(probe);
|
|
836
|
+
}
|
|
837
|
+
/** Read ONE host's form. The layer is the operator pin, else that host's own published dir. */
|
|
838
|
+
const readForm = async (probe) => {
|
|
839
|
+
const hostOpts = probe.options;
|
|
840
|
+
const layer = explicitDir ?? (probe.dir && present(probe.dir) ? probe.dir : null);
|
|
841
|
+
let manifest = null;
|
|
842
|
+
let plugins = [];
|
|
843
|
+
let scopeDirs = null;
|
|
844
|
+
for (const manifestPath of hostOpts.catalog?.paths(layer) ?? []) {
|
|
845
|
+
if (!tree.some((e) => e.path === manifestPath && e.type === 'blob'))
|
|
846
|
+
continue;
|
|
847
|
+
const text = await ghText(raw(manifestPath), fetchImpl);
|
|
848
|
+
if (!text)
|
|
849
|
+
continue;
|
|
850
|
+
const parsed = hostOpts.catalog.parse(text);
|
|
851
|
+
if (!parsed.ok)
|
|
852
|
+
continue; // an unparseable file is not a manifest — try the next family member
|
|
853
|
+
manifest = { name: parsed.name, description: parsed.description, path: manifestPath };
|
|
854
|
+
plugins = parsed.plugins.slice(0, ROWS_MAX);
|
|
855
|
+
// `dirs: []` (all sources external) narrows to NOTHING: a whole-tree scan would surface
|
|
856
|
+
// mirror copies the author never meant as installable.
|
|
857
|
+
scopeDirs = parsed.dirs;
|
|
858
|
+
break;
|
|
859
|
+
}
|
|
860
|
+
let manifestScope = null;
|
|
861
|
+
let repoScoped = false;
|
|
862
|
+
const reader = hostOpts.manifest;
|
|
863
|
+
const declaredPath = reader ? (reader.atRoot ? reader.file : layer ? `${layer}/${reader.file}` : null) : null;
|
|
864
|
+
if (!manifest && !plugins.length && declaredPath && tree.some((e) => e.path === declaredPath && e.type === 'blob')) {
|
|
865
|
+
const text = await ghText(raw(declaredPath), fetchImpl);
|
|
866
|
+
let declared = null;
|
|
867
|
+
try {
|
|
868
|
+
declared = text ? JSON.parse(text) : null;
|
|
869
|
+
}
|
|
870
|
+
catch {
|
|
871
|
+
declared = null; // a broken manifest is not a manifest
|
|
872
|
+
}
|
|
873
|
+
const read = declared ? reader.read(declared) : null;
|
|
874
|
+
if (read) {
|
|
875
|
+
plugins = [{ name: read.name, source: reader.base === 'layer' ? (layer ?? '') : '', description: read.description }];
|
|
876
|
+
manifestScope = declared && reader.scope ? reader.scope(declared) : null;
|
|
877
|
+
repoScoped = reader.base === 'repo';
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
if (!manifest && !plugins.length && hostOpts.directoryPlugin && layer) {
|
|
881
|
+
plugins = [
|
|
882
|
+
{
|
|
883
|
+
name: entry.repo.split('/').pop() ?? entry.repo,
|
|
884
|
+
source: hostOpts.directoryPlugin.base === 'layer' ? layer : '',
|
|
885
|
+
description: null,
|
|
886
|
+
},
|
|
887
|
+
];
|
|
888
|
+
repoScoped = hostOpts.directoryPlugin.base === 'repo';
|
|
889
|
+
}
|
|
890
|
+
if (!manifest && plugins.length === 0)
|
|
891
|
+
return null;
|
|
892
|
+
return { harness: probe.harness, layer, manifest, plugins, scopeDirs, manifestScope, repoScoped };
|
|
893
|
+
};
|
|
894
|
+
// Detected forms first; the registrant/pinned host is the fallback (a skills-only repo has no
|
|
895
|
+
// form at all and is answered by the whole-tree `SKILL.md` scan below).
|
|
896
|
+
const candidates = [...detected, ...probes.filter((probe) => !detected.includes(probe))];
|
|
897
|
+
let form = null;
|
|
898
|
+
for (const probe of candidates) {
|
|
899
|
+
form = await readForm(probe);
|
|
900
|
+
if (form)
|
|
901
|
+
break;
|
|
902
|
+
}
|
|
903
|
+
const primaryHarness = form?.harness ?? detected[0]?.harness ?? probes[0].harness;
|
|
904
|
+
// Marketplace/plugin NAMES the install command needs (`<plugin>@<marketplace>`). Read from the
|
|
905
|
+
// converged catalog only — a directory-keyed harness keeps its own row shape.
|
|
906
|
+
let marketplaceName = form?.manifest?.name ?? null;
|
|
907
|
+
if (opts.nameReader) {
|
|
908
|
+
for (const probe of detected) {
|
|
909
|
+
if (!probe.dir)
|
|
910
|
+
continue;
|
|
911
|
+
const namePath = `${probe.dir}/marketplace.json`;
|
|
912
|
+
if (!tree.some((e) => e.path === namePath && e.type === 'blob'))
|
|
913
|
+
continue;
|
|
914
|
+
const text = await ghText(raw(namePath), fetchImpl);
|
|
915
|
+
const parsed = text ? opts.nameReader.parse(text) : { ok: false };
|
|
916
|
+
if (!parsed.ok)
|
|
917
|
+
continue;
|
|
918
|
+
marketplaceName ??= parsed.name;
|
|
919
|
+
if (form && form.plugins.length > 0 && !form.manifest) {
|
|
920
|
+
const rootPlugin = parsed.plugins.find((p) => p.source === '' || p.source === '.') ?? parsed.plugins[0];
|
|
921
|
+
if (rootPlugin)
|
|
922
|
+
form.plugins = [{ ...form.plugins[0], name: rootPlugin.name }];
|
|
923
|
+
}
|
|
924
|
+
break;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
// An EXPLICIT layer pin keeps the historical per-harness scope (the operator asked for one
|
|
928
|
+
// harness's form); an unpinned source is detected across every served harness. NOTHING detected
|
|
929
|
+
// is not support: the honest answer is an empty list ("publishes no form", which the console
|
|
930
|
+
// renders as `none`). Blaming a host here would claim a form the repository never published —
|
|
931
|
+
// and the first served harness would answer for every SKILL.md-only tree.
|
|
932
|
+
const hosts = explicitDir
|
|
933
|
+
? [primaryHarness]
|
|
934
|
+
: [...new Set(detected.map((probe) => probe.harness))];
|
|
935
|
+
const extensionDir = form?.layer ?? explicitDir ?? (defaultDir && present(defaultDir) ? defaultDir : null);
|
|
936
|
+
// A repo-rooted plugin form (codex, cursor, …) does not turn the layer into the scan scope: its
|
|
937
|
+
// rows are the repository's own `skills` tree, while a layer-rooted form scans the layer itself.
|
|
938
|
+
// The skill axis overrides every narrowing: its source is any repository publishing SKILL.md.
|
|
939
|
+
const scope = opts.wholeTreeSkills
|
|
940
|
+
? null
|
|
941
|
+
: (form?.scopeDirs ?? form?.manifestScope ?? (form?.repoScoped ? null : extensionDir ? [extensionDir] : null));
|
|
942
|
+
const rows = await rowsForScope(entry.repo, head.sha, scope, tree, fetchImpl);
|
|
943
|
+
const previous = latestSnapshot(entry.slug, entry.harness);
|
|
944
|
+
const diff = {
|
|
945
|
+
probedAt: Date.now(),
|
|
946
|
+
shaChanged: previous ? previous.sha !== head.sha : false,
|
|
947
|
+
added: rows.filter((r) => !previous?.rows.some((p) => p.dir === r.dir)).map((r) => r.title),
|
|
948
|
+
removed: (previous?.rows ?? []).filter((p) => !rows.some((r) => r.dir === p.dir)).map((p) => p.title),
|
|
949
|
+
};
|
|
950
|
+
const authorAdapters = [...new Set(ADAPTER_DIR_HINTS.filter((h) => tree.some((e) => e.path.startsWith(h.prefix))).map((h) => h.label))];
|
|
951
|
+
const unsupported = [];
|
|
952
|
+
const pushShape = (shape, count) => {
|
|
953
|
+
if (count > 0)
|
|
954
|
+
unsupported.push({ shape, count });
|
|
955
|
+
};
|
|
956
|
+
pushShape('commands', tree.filter((e) => e.type === 'blob' && /\/commands\/.+/.test(e.path)).length);
|
|
957
|
+
pushShape('hooks', tree.filter((e) => e.type === 'blob' && e.path.startsWith('hooks/') && /\.(js|mjs|cjs|ps1|sh)$/.test(e.path)).length);
|
|
958
|
+
pushShape('opencode-plugins', tree.filter((e) => e.type === 'blob' && e.path.startsWith('.opencode/plugins/')).length);
|
|
959
|
+
const snapshot = {
|
|
960
|
+
slug: entry.slug,
|
|
961
|
+
probedAt: diff.probedAt,
|
|
962
|
+
sha: head.sha,
|
|
963
|
+
stars: typeof meta.stargazers_count === 'number' ? meta.stargazers_count : null,
|
|
964
|
+
pushedAt: typeof meta.pushed_at === 'string' ? meta.pushed_at : null,
|
|
965
|
+
manifest: form?.manifest ?? null,
|
|
966
|
+
extensionDir,
|
|
967
|
+
plugins: form?.plugins ?? [],
|
|
968
|
+
hosts,
|
|
969
|
+
marketplace: marketplaceName ?? entry.repo.split('/').pop() ?? entry.repo,
|
|
970
|
+
authorAdapters,
|
|
971
|
+
unsupported,
|
|
972
|
+
rows,
|
|
973
|
+
...(previous ? { lastDiff: diff } : {}),
|
|
974
|
+
};
|
|
975
|
+
// A dry-run probe (checkSource on a NOT-yet-registered repo) reports without leaving state.
|
|
976
|
+
if (opts.persist !== false)
|
|
977
|
+
writeSnapshot(snapshot, entry.harness);
|
|
978
|
+
return { ok: true, snapshot };
|
|
979
|
+
}
|
|
980
|
+
/** Entries whose rescan is armed and due. Called by the scheduler tick in `server.ts`.
|
|
981
|
+
* Package sources (`npm` / `pypi`) are excluded: their freshness is a registry read owned by the
|
|
982
|
+
* source's own rescan route, and handing one to the git prober would only ever answer `bad_request`. */
|
|
983
|
+
export function dueMarketplaceEntries(now = Date.now()) {
|
|
984
|
+
return listMarketplaceEntries()
|
|
985
|
+
.filter((e) => e.enabled && e.rescan.enabled && (e.type ?? 'github') === 'github')
|
|
986
|
+
.map((entry) => ({ entry, snapshot: latestSnapshot(entry.slug) }))
|
|
987
|
+
.filter(({ entry, snapshot }) => !snapshot || now - snapshot.probedAt >= entry.rescan.intervalMs);
|
|
988
|
+
}
|
|
989
|
+
/** Browse rows for one source, from the latest snapshot (a stale snapshot answers; the market is a
|
|
990
|
+
* cache view, the rescan loop owns freshness). Filter + page are local — the source declares no
|
|
991
|
+
* server-side order beyond `name`. */
|
|
992
|
+
export function browseMarketplace(slug, opts = {}) {
|
|
993
|
+
const entry = getMarketplaceEntry(slug);
|
|
994
|
+
if (!entry)
|
|
995
|
+
return { ok: false, code: 'unknown_source', message: `unknown marketplace '${slug}'` };
|
|
996
|
+
const snapshot = latestSnapshot(slug);
|
|
997
|
+
if (!snapshot)
|
|
998
|
+
return { ok: false, code: 'never_probed', message: `source '${slug}' has not been probed yet` };
|
|
999
|
+
const query = (opts.query ?? '').trim().toLowerCase();
|
|
1000
|
+
const matched = snapshot.rows
|
|
1001
|
+
.filter((r) => !query || r.title.toLowerCase().includes(query) || (r.description ?? '').toLowerCase().includes(query))
|
|
1002
|
+
.sort((a, b) => a.title.localeCompare(b.title));
|
|
1003
|
+
const pageSize = opts.pageSize ?? 24;
|
|
1004
|
+
const page = Math.max(1, opts.page ?? 1);
|
|
1005
|
+
const items = matched.slice((page - 1) * pageSize, page * pageSize).map((r) => ({
|
|
1006
|
+
dir: r.dir,
|
|
1007
|
+
key: `${marketplaceSourceId(slug)}:${entry.repo}#${r.dir}`,
|
|
1008
|
+
name: r.name,
|
|
1009
|
+
title: r.title,
|
|
1010
|
+
description: r.description,
|
|
1011
|
+
}));
|
|
1012
|
+
return { ok: true, items, total: matched.length, hasMore: page * pageSize < matched.length };
|
|
1013
|
+
}
|
|
1014
|
+
// ---------------------------------------------------------------------------
|
|
1015
|
+
// Federated tier: live directories answered per source section
|
|
1016
|
+
// ---------------------------------------------------------------------------
|
|
1017
|
+
/** Per-source latency ceiling — the facade owns the page's worst-case wait. */
|
|
1018
|
+
const SECTION_TIMEOUT_MS = 8_000;
|
|
1019
|
+
/**
|
|
1020
|
+
* Ask live federated sources for one page and return one labeled section per source. The tier is
|
|
1021
|
+
* shared by every market: which views participate is the adapter's declaration
|
|
1022
|
+
* (`BasePluginMarketAdapter.federatedViews()`), never a module-level id list.
|
|
1023
|
+
*
|
|
1024
|
+
* Co-ordering honesty: a merged global sort across heterogeneous sources is only honest when every
|
|
1025
|
+
* participant serves the SAME key, which the live directories cannot do; each answer therefore
|
|
1026
|
+
* stays in the source's native order with its own total, and the facade never interleaves them.
|
|
1027
|
+
* Failures and timeouts degrade to a labeled note, never a throw.
|
|
1028
|
+
*/
|
|
1029
|
+
export async function federatedSections(harness, q, opts, fetchImpl, views) {
|
|
1030
|
+
const jobs = views.map(async (view) => {
|
|
1031
|
+
try {
|
|
1032
|
+
const result = await withTimeout(browseSource(view, q, opts.pageSize, { harness, page: opts.page, fetchImpl }), SECTION_TIMEOUT_MS, `${view.label} did not answer within ${SECTION_TIMEOUT_MS / 1000}s`);
|
|
1033
|
+
if (!result.ok)
|
|
1034
|
+
return { sourceId: view.id, label: view.label, rows: [], note: result.message };
|
|
1035
|
+
return {
|
|
1036
|
+
sourceId: view.id,
|
|
1037
|
+
label: view.label,
|
|
1038
|
+
rows: result.items.filter((i) => i.installKind === 'plugin').map((i) => toCatalogRow(i, view.hosts ?? [])),
|
|
1039
|
+
...(result.total !== undefined ? { total: result.total, totalExact: result.totalScope !== 'window' } : {}),
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
catch (e) {
|
|
1043
|
+
return {
|
|
1044
|
+
sourceId: view.id,
|
|
1045
|
+
label: view.label,
|
|
1046
|
+
rows: [],
|
|
1047
|
+
note: e instanceof Error ? e.message : `${view.label} failed`,
|
|
1048
|
+
};
|
|
1049
|
+
}
|
|
1050
|
+
});
|
|
1051
|
+
return Promise.all(jobs);
|
|
1052
|
+
}
|
|
1053
|
+
/** The ONE `MarketItem` → `CatalogRow` conversion shared by the federated tier and a harness's own
|
|
1054
|
+
* live search. `hosts` is the source view's host claim (empty for an unclaimed directory). */
|
|
1055
|
+
export function toCatalogRow(item, hosts = []) {
|
|
1056
|
+
return {
|
|
1057
|
+
// The MarketItem key IS the portable install handle (`npm:<pkg>`); it doubles as the merge key.
|
|
1058
|
+
key: item.key,
|
|
1059
|
+
name: item.name,
|
|
1060
|
+
summary: item.description,
|
|
1061
|
+
stars: item.stars,
|
|
1062
|
+
updatedAt: item.updatedAt ? Date.parse(item.updatedAt) || null : null,
|
|
1063
|
+
sourceId: item.sourceId,
|
|
1064
|
+
surfaces: [item.sourceId],
|
|
1065
|
+
hosts,
|
|
1066
|
+
repo: item.repo ?? null,
|
|
1067
|
+
// A live directory row carries no marketplace manifest of its own; it installs via its key.
|
|
1068
|
+
marketplace: item.marketplace ?? null,
|
|
1069
|
+
catalog: item.catalog ?? 'default',
|
|
1070
|
+
channel: item.channel ?? item.sourceId,
|
|
1071
|
+
categories: item.categories ?? [],
|
|
1072
|
+
};
|
|
1073
|
+
}
|
|
1074
|
+
function withTimeout(p, ms, message) {
|
|
1075
|
+
return new Promise((resolve, reject) => {
|
|
1076
|
+
const timer = setTimeout(() => reject(new Error(message)), ms);
|
|
1077
|
+
p.then((v) => { clearTimeout(timer); resolve(v); }, (e) => { clearTimeout(timer); reject(e); });
|
|
1078
|
+
});
|
|
1079
|
+
}
|