@capybara-hq/kernel 0.0.0-stage → 0.1.0-rc.1
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/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +20 -2
- package/bootstrap.json +26 -0
- package/dist/admin/admin.controller.d.ts +139 -0
- package/dist/admin/admin.controller.js +238 -0
- package/dist/admin/extensions.controller.d.ts +100 -0
- package/dist/admin/extensions.controller.js +226 -0
- package/dist/admin/setup.controller.d.ts +36 -0
- package/dist/admin/setup.controller.js +106 -0
- package/dist/admin/setup.service.d.ts +47 -0
- package/dist/admin/setup.service.js +90 -0
- package/dist/agents/agents.controller.d.ts +205 -0
- package/dist/agents/agents.controller.js +144 -0
- package/dist/agents/agents.service.d.ts +177 -0
- package/dist/agents/agents.service.js +677 -0
- package/dist/agents/definition.d.ts +198 -0
- package/dist/agents/definition.js +152 -0
- package/dist/agents/models.controller.d.ts +13 -0
- package/dist/agents/models.controller.js +31 -0
- package/dist/agents/templates.controller.d.ts +15 -0
- package/dist/agents/templates.controller.js +37 -0
- package/dist/agents/templates.d.ts +83 -0
- package/dist/agents/templates.js +173 -0
- package/dist/catalog/admin-catalog.controller.d.ts +143 -0
- package/dist/catalog/admin-catalog.controller.js +245 -0
- package/dist/catalog/catalog.service.d.ts +430 -0
- package/dist/catalog/catalog.service.js +882 -0
- package/dist/catalog/claude/agents.d.ts +27 -0
- package/dist/catalog/claude/agents.js +270 -0
- package/dist/catalog/claude/commands.d.ts +50 -0
- package/dist/catalog/claude/commands.js +179 -0
- package/dist/catalog/claude/manifest.d.ts +69 -0
- package/dist/catalog/claude/manifest.js +134 -0
- package/dist/catalog/claude/marketplace.d.ts +35 -0
- package/dist/catalog/claude/marketplace.js +194 -0
- package/dist/catalog/claude/mcp.d.ts +33 -0
- package/dist/catalog/claude/mcp.js +226 -0
- package/dist/catalog/claude/report.d.ts +86 -0
- package/dist/catalog/claude/report.js +121 -0
- package/dist/catalog/claude/translate.d.ts +56 -0
- package/dist/catalog/claude/translate.js +857 -0
- package/dist/catalog/cli.d.ts +46 -0
- package/dist/catalog/cli.js +211 -0
- package/dist/catalog/git-source.d.ts +127 -0
- package/dist/catalog/git-source.js +520 -0
- package/dist/catalog/marketplace-fetch.d.ts +99 -0
- package/dist/catalog/marketplace-fetch.js +203 -0
- package/dist/catalog/marketplaces.controller.d.ts +97 -0
- package/dist/catalog/marketplaces.controller.js +197 -0
- package/dist/catalog/marketplaces.service.d.ts +340 -0
- package/dist/catalog/marketplaces.service.js +1217 -0
- package/dist/catalog/org-catalog.controller.d.ts +128 -0
- package/dist/catalog/org-catalog.controller.js +277 -0
- package/dist/catalog/org-catalog.service.d.ts +246 -0
- package/dist/catalog/org-catalog.service.js +625 -0
- package/dist/catalog/plugin-import.d.ts +436 -0
- package/dist/catalog/plugin-import.js +1069 -0
- package/dist/catalog/plugin-install.d.ts +447 -0
- package/dist/catalog/plugin-install.js +1333 -0
- package/dist/catalog/plugin-package.d.ts +143 -0
- package/dist/catalog/plugin-package.js +382 -0
- package/dist/catalog/plugin-upgrade.d.ts +222 -0
- package/dist/catalog/plugin-upgrade.js +1219 -0
- package/dist/catalog/requests.service.d.ts +162 -0
- package/dist/catalog/requests.service.js +504 -0
- package/dist/catalog/schema-path.d.ts +7 -0
- package/dist/catalog/schema-path.js +63 -0
- package/dist/catalog/upgrade-targets.d.ts +59 -0
- package/dist/catalog/upgrade-targets.js +90 -0
- package/dist/catalog/versions.d.ts +31 -0
- package/dist/catalog/versions.js +44 -0
- package/dist/channels/actions.d.ts +37 -0
- package/dist/channels/actions.js +121 -0
- package/dist/channels/cards.d.ts +44 -0
- package/dist/channels/cards.js +156 -0
- package/dist/channels/connections.controller.d.ts +59 -0
- package/dist/channels/connections.controller.js +115 -0
- package/dist/channels/connections.service.d.ts +187 -0
- package/dist/channels/connections.service.js +534 -0
- package/dist/channels/features.d.ts +12 -0
- package/dist/channels/features.js +22 -0
- package/dist/channels/inbound.d.ts +120 -0
- package/dist/channels/inbound.js +332 -0
- package/dist/channels/outbound.d.ts +140 -0
- package/dist/channels/outbound.js +1126 -0
- package/dist/channels/phrases.d.ts +100 -0
- package/dist/channels/phrases.js +81 -0
- package/dist/channels/supervisor.d.ts +182 -0
- package/dist/channels/supervisor.js +625 -0
- package/dist/channels/threads.d.ts +29 -0
- package/dist/channels/threads.js +104 -0
- package/dist/channels/webhook-url.d.ts +16 -0
- package/dist/channels/webhook-url.js +34 -0
- package/dist/channels/webhook.controller.d.ts +19 -0
- package/dist/channels/webhook.controller.js +72 -0
- package/dist/channels/webhook.d.ts +73 -0
- package/dist/channels/webhook.js +274 -0
- package/dist/config/docs.d.ts +9 -0
- package/dist/config/docs.js +85 -0
- package/dist/config/env.d.ts +6 -0
- package/dist/config/env.js +73 -0
- package/dist/config/fields.d.ts +42 -0
- package/dist/config/fields.js +214 -0
- package/dist/config/file-source.d.ts +3 -0
- package/dist/config/file-source.js +31 -0
- package/dist/config/load.d.ts +20 -0
- package/dist/config/load.js +98 -0
- package/dist/config/nacos-source.d.ts +31 -0
- package/dist/config/nacos-source.js +229 -0
- package/dist/config/schema.d.ts +237 -0
- package/dist/config/schema.js +1192 -0
- package/dist/config/sources.d.ts +18 -0
- package/dist/config/sources.js +59 -0
- package/dist/config/types.d.ts +9 -0
- package/dist/config/types.js +7 -0
- package/dist/conversations/artifacts.d.ts +52 -0
- package/dist/conversations/artifacts.js +137 -0
- package/dist/conversations/attachments.controller.d.ts +28 -0
- package/dist/conversations/attachments.controller.js +96 -0
- package/dist/conversations/attachments.service.d.ts +180 -0
- package/dist/conversations/attachments.service.js +578 -0
- package/dist/conversations/conversations.controller.d.ts +288 -0
- package/dist/conversations/conversations.controller.js +607 -0
- package/dist/conversations/conversations.service.d.ts +321 -0
- package/dist/conversations/conversations.service.js +754 -0
- package/dist/conversations/event-log.d.ts +122 -0
- package/dist/conversations/event-log.js +259 -0
- package/dist/conversations/events.d.ts +856 -0
- package/dist/conversations/events.js +639 -0
- package/dist/conversations/files.d.ts +92 -0
- package/dist/conversations/files.js +213 -0
- package/dist/conversations/outputs-read.d.ts +34 -0
- package/dist/conversations/outputs-read.js +37 -0
- package/dist/conversations/queue.d.ts +169 -0
- package/dist/conversations/queue.js +527 -0
- package/dist/conversations/sandbox-status.d.ts +21 -0
- package/dist/conversations/sandbox-status.js +24 -0
- package/dist/conversations/selection.d.ts +46 -0
- package/dist/conversations/selection.js +75 -0
- package/dist/conversations/titles.d.ts +93 -0
- package/dist/conversations/titles.js +423 -0
- package/dist/ctx/bus.d.ts +16 -0
- package/dist/ctx/bus.js +101 -0
- package/dist/ctx/create-ctx.d.ts +109 -0
- package/dist/ctx/create-ctx.js +592 -0
- package/dist/ctx/kv.d.ts +4 -0
- package/dist/ctx/kv.js +31 -0
- package/dist/ctx/lock.d.ts +4 -0
- package/dist/ctx/lock.js +39 -0
- package/dist/ctx/namespace.d.ts +6 -0
- package/dist/ctx/namespace.js +12 -0
- package/dist/ctx/queue.d.ts +25 -0
- package/dist/ctx/queue.js +151 -0
- package/dist/ctx/secrets.d.ts +45 -0
- package/dist/ctx/secrets.js +175 -0
- package/dist/db/kernel-schema.d.ts +1122 -0
- package/dist/db/kernel-schema.js +5 -0
- package/dist/db/migrator.d.ts +28 -0
- package/dist/db/migrator.js +140 -0
- package/dist/db/pool.d.ts +21 -0
- package/dist/db/pool.js +28 -0
- package/dist/db/sql-statements.d.ts +34 -0
- package/dist/db/sql-statements.js +168 -0
- package/dist/errors.d.ts +211 -0
- package/dist/errors.js +213 -0
- package/dist/evals/budget.d.ts +61 -0
- package/dist/evals/budget.js +181 -0
- package/dist/evals/diff.d.ts +55 -0
- package/dist/evals/diff.js +133 -0
- package/dist/evals/judge.d.ts +53 -0
- package/dist/evals/judge.js +149 -0
- package/dist/evals/plan.d.ts +47 -0
- package/dist/evals/plan.js +77 -0
- package/dist/evals/reconstruct.d.ts +137 -0
- package/dist/evals/reconstruct.js +322 -0
- package/dist/evals/recorded-tools.d.ts +54 -0
- package/dist/evals/recorded-tools.js +167 -0
- package/dist/evals/run-replay.d.ts +86 -0
- package/dist/evals/run-replay.js +502 -0
- package/dist/evals/runs.controller.d.ts +100 -0
- package/dist/evals/runs.controller.js +199 -0
- package/dist/evals/runs.service.d.ts +275 -0
- package/dist/evals/runs.service.js +836 -0
- package/dist/evals/sets.controller.d.ts +61 -0
- package/dist/evals/sets.controller.js +183 -0
- package/dist/evals/sets.service.d.ts +128 -0
- package/dist/evals/sets.service.js +558 -0
- package/dist/evals/snapshot.d.ts +76 -0
- package/dist/evals/snapshot.js +207 -0
- package/dist/evals/step-replay.d.ts +113 -0
- package/dist/evals/step-replay.js +181 -0
- package/dist/evals/trajectory.controller.d.ts +41 -0
- package/dist/evals/trajectory.controller.js +88 -0
- package/dist/evals/trajectory.d.ts +144 -0
- package/dist/evals/trajectory.js +338 -0
- package/dist/evals/trajectory.service.d.ts +108 -0
- package/dist/evals/trajectory.service.js +323 -0
- package/dist/evals/worker.d.ts +101 -0
- package/dist/evals/worker.js +790 -0
- package/dist/extensions/admin-ops.d.ts +105 -0
- package/dist/extensions/admin-ops.js +353 -0
- package/dist/extensions/admin-view.d.ts +79 -0
- package/dist/extensions/admin-view.js +327 -0
- package/dist/extensions/approvals.d.ts +119 -0
- package/dist/extensions/approvals.js +205 -0
- package/dist/extensions/blobs.d.ts +45 -0
- package/dist/extensions/blobs.js +160 -0
- package/dist/extensions/bootstrap.d.ts +176 -0
- package/dist/extensions/bootstrap.js +535 -0
- package/dist/extensions/cli.d.ts +61 -0
- package/dist/extensions/cli.js +165 -0
- package/dist/extensions/config-json-schema.d.ts +9 -0
- package/dist/extensions/config-json-schema.js +73 -0
- package/dist/extensions/deployment-config.d.ts +138 -0
- package/dist/extensions/deployment-config.js +394 -0
- package/dist/extensions/enabled.d.ts +31 -0
- package/dist/extensions/enabled.js +55 -0
- package/dist/extensions/hooks.d.ts +161 -0
- package/dist/extensions/hooks.js +425 -0
- package/dist/extensions/host.d.ts +577 -0
- package/dist/extensions/host.js +2071 -0
- package/dist/extensions/inflight.d.ts +69 -0
- package/dist/extensions/inflight.js +277 -0
- package/dist/extensions/installs.d.ts +166 -0
- package/dist/extensions/installs.js +253 -0
- package/dist/extensions/instance.d.ts +167 -0
- package/dist/extensions/instance.js +329 -0
- package/dist/extensions/ledger.d.ts +30 -0
- package/dist/extensions/ledger.js +50 -0
- package/dist/extensions/lifecycle.d.ts +80 -0
- package/dist/extensions/lifecycle.js +152 -0
- package/dist/extensions/migrate-lock.d.ts +51 -0
- package/dist/extensions/migrate-lock.js +100 -0
- package/dist/extensions/org-config.controller.d.ts +24 -0
- package/dist/extensions/org-config.controller.js +59 -0
- package/dist/extensions/org-config.d.ts +169 -0
- package/dist/extensions/org-config.js +520 -0
- package/dist/extensions/package.d.ts +115 -0
- package/dist/extensions/package.js +246 -0
- package/dist/extensions/permission-set.d.ts +117 -0
- package/dist/extensions/permission-set.js +184 -0
- package/dist/extensions/permission-view.d.ts +194 -0
- package/dist/extensions/permission-view.js +284 -0
- package/dist/extensions/registry.d.ts +24 -0
- package/dist/extensions/registry.js +56 -0
- package/dist/extensions/resolve.d.ts +12 -0
- package/dist/extensions/resolve.js +71 -0
- package/dist/extensions/sources.d.ts +69 -0
- package/dist/extensions/sources.js +120 -0
- package/dist/extensions/sync.d.ts +40 -0
- package/dist/extensions/sync.js +242 -0
- package/dist/files/previewers.controller.d.ts +46 -0
- package/dist/files/previewers.controller.js +105 -0
- package/dist/files/previewers.d.ts +100 -0
- package/dist/files/previewers.js +250 -0
- package/dist/http/api.module.d.ts +114 -0
- package/dist/http/api.module.js +448 -0
- package/dist/http/app.d.ts +77 -0
- package/dist/http/app.js +220 -0
- package/dist/http/error.filter.d.ts +21 -0
- package/dist/http/error.filter.js +85 -0
- package/dist/http/gateway.module.d.ts +15 -0
- package/dist/http/gateway.module.js +13 -0
- package/dist/http/health.controller.d.ts +26 -0
- package/dist/http/health.controller.js +79 -0
- package/dist/http/nest-logger.d.ts +20 -0
- package/dist/http/nest-logger.js +28 -0
- package/dist/http/plugin-dispatch.d.ts +68 -0
- package/dist/http/plugin-dispatch.js +200 -0
- package/dist/http/tokens.d.ts +131 -0
- package/dist/http/tokens.js +131 -0
- package/dist/http/zod.pipe.d.ts +8 -0
- package/dist/http/zod.pipe.js +14 -0
- package/dist/identity/accounts.d.ts +93 -0
- package/dist/identity/accounts.js +367 -0
- package/dist/identity/api-tokens.d.ts +73 -0
- package/dist/identity/api-tokens.js +197 -0
- package/dist/identity/audit.d.ts +23 -0
- package/dist/identity/audit.js +41 -0
- package/dist/identity/auth.controller.d.ts +40 -0
- package/dist/identity/auth.controller.js +130 -0
- package/dist/identity/auth.guard.d.ts +41 -0
- package/dist/identity/auth.guard.js +162 -0
- package/dist/identity/binding.d.ts +47 -0
- package/dist/identity/binding.js +84 -0
- package/dist/identity/cookies.d.ts +16 -0
- package/dist/identity/cookies.js +32 -0
- package/dist/identity/credential-check.d.ts +17 -0
- package/dist/identity/credential-check.js +24 -0
- package/dist/identity/enterprise-admin.d.ts +14 -0
- package/dist/identity/enterprise-admin.js +27 -0
- package/dist/identity/external.d.ts +106 -0
- package/dist/identity/external.js +337 -0
- package/dist/identity/hash.d.ts +2 -0
- package/dist/identity/hash.js +3 -0
- package/dist/identity/login.d.ts +6 -0
- package/dist/identity/login.js +20 -0
- package/dist/identity/me.controller.d.ts +61 -0
- package/dist/identity/me.controller.js +159 -0
- package/dist/identity/passwords.d.ts +6 -0
- package/dist/identity/passwords.js +37 -0
- package/dist/identity/principal.d.ts +56 -0
- package/dist/identity/principal.js +38 -0
- package/dist/identity/rate-limit.d.ts +55 -0
- package/dist/identity/rate-limit.js +121 -0
- package/dist/identity/sessions.d.ts +84 -0
- package/dist/identity/sessions.js +306 -0
- package/dist/identity/settings.d.ts +121 -0
- package/dist/identity/settings.js +248 -0
- package/dist/identity/sso.controller.d.ts +59 -0
- package/dist/identity/sso.controller.js +192 -0
- package/dist/identity/sso.d.ts +83 -0
- package/dist/identity/sso.js +202 -0
- package/dist/inbox/inbox.service.d.ts +43 -0
- package/dist/inbox/inbox.service.js +57 -0
- package/dist/index.d.ts +69 -0
- package/dist/index.js +67 -0
- package/dist/kernel.d.ts +259 -0
- package/dist/kernel.js +1326 -0
- package/dist/log-config.d.ts +9 -0
- package/dist/log-config.js +27 -0
- package/dist/log-context.d.ts +32 -0
- package/dist/log-context.js +40 -0
- package/dist/log-loki.d.ts +34 -0
- package/dist/log-loki.js +145 -0
- package/dist/log.d.ts +79 -0
- package/dist/log.js +303 -0
- package/dist/models/prices.d.ts +53 -0
- package/dist/models/prices.js +121 -0
- package/dist/models/purposes.controller.d.ts +19 -0
- package/dist/models/purposes.controller.js +56 -0
- package/dist/models/purposes.d.ts +140 -0
- package/dist/models/purposes.js +267 -0
- package/dist/net/proxy.d.ts +44 -0
- package/dist/net/proxy.js +162 -0
- package/dist/net/public-address.d.ts +60 -0
- package/dist/net/public-address.js +272 -0
- package/dist/net/safe-fetch.d.ts +38 -0
- package/dist/net/safe-fetch.js +140 -0
- package/dist/orgs/directory-sync.controller.d.ts +14 -0
- package/dist/orgs/directory-sync.controller.js +40 -0
- package/dist/orgs/directory-sync.d.ts +166 -0
- package/dist/orgs/directory-sync.js +558 -0
- package/dist/orgs/invitations.controller.d.ts +58 -0
- package/dist/orgs/invitations.controller.js +137 -0
- package/dist/orgs/invitations.service.d.ts +80 -0
- package/dist/orgs/invitations.service.js +217 -0
- package/dist/orgs/members.service.d.ts +63 -0
- package/dist/orgs/members.service.js +234 -0
- package/dist/orgs/offboarding.d.ts +141 -0
- package/dist/orgs/offboarding.js +398 -0
- package/dist/orgs/org-lock.d.ts +32 -0
- package/dist/orgs/org-lock.js +46 -0
- package/dist/orgs/org.guard.d.ts +35 -0
- package/dist/orgs/org.guard.js +95 -0
- package/dist/orgs/orgs.controller.d.ts +78 -0
- package/dist/orgs/orgs.controller.js +192 -0
- package/dist/orgs/orgs.service.d.ts +61 -0
- package/dist/orgs/orgs.service.js +209 -0
- package/dist/orgs/roles.d.ts +13 -0
- package/dist/orgs/roles.js +58 -0
- package/dist/orgs/settings.controller.d.ts +20 -0
- package/dist/orgs/settings.controller.js +53 -0
- package/dist/orgs/settings.service.d.ts +120 -0
- package/dist/orgs/settings.service.js +178 -0
- package/dist/packages/npm.d.ts +50 -0
- package/dist/packages/npm.js +218 -0
- package/dist/packages/provenance.d.ts +47 -0
- package/dist/packages/provenance.js +147 -0
- package/dist/packages/tgz.d.ts +76 -0
- package/dist/packages/tgz.js +225 -0
- package/dist/runtime/abort.d.ts +32 -0
- package/dist/runtime/abort.js +71 -0
- package/dist/runtime/checkpointer.d.ts +32 -0
- package/dist/runtime/checkpointer.js +243 -0
- package/dist/runtime/context/build.d.ts +254 -0
- package/dist/runtime/context/build.js +693 -0
- package/dist/runtime/context/claude-tools.d.ts +11 -0
- package/dist/runtime/context/claude-tools.js +24 -0
- package/dist/runtime/context/compaction.d.ts +26 -0
- package/dist/runtime/context/compaction.js +195 -0
- package/dist/runtime/context/pairing.d.ts +11 -0
- package/dist/runtime/context/pairing.js +82 -0
- package/dist/runtime/context/reminders.d.ts +5 -0
- package/dist/runtime/context/reminders.js +11 -0
- package/dist/runtime/context/skills.d.ts +105 -0
- package/dist/runtime/context/skills.js +283 -0
- package/dist/runtime/context/tokens.d.ts +19 -0
- package/dist/runtime/context/tokens.js +104 -0
- package/dist/runtime/conversation-lock.d.ts +40 -0
- package/dist/runtime/conversation-lock.js +97 -0
- package/dist/runtime/hook-calls.d.ts +84 -0
- package/dist/runtime/hook-calls.js +136 -0
- package/dist/runtime/langgraph-loop.d.ts +52 -0
- package/dist/runtime/langgraph-loop.js +247 -0
- package/dist/runtime/loop.d.ts +93 -0
- package/dist/runtime/loop.js +7 -0
- package/dist/runtime/maintenance.d.ts +80 -0
- package/dist/runtime/maintenance.js +148 -0
- package/dist/runtime/media-cache.d.ts +21 -0
- package/dist/runtime/media-cache.js +51 -0
- package/dist/runtime/model-call.d.ts +176 -0
- package/dist/runtime/model-call.js +1049 -0
- package/dist/runtime/providers.d.ts +86 -0
- package/dist/runtime/providers.js +224 -0
- package/dist/runtime/quota.d.ts +29 -0
- package/dist/runtime/quota.js +70 -0
- package/dist/runtime/run-finish.d.ts +45 -0
- package/dist/runtime/run-finish.js +69 -0
- package/dist/runtime/run-queue.d.ts +121 -0
- package/dist/runtime/run-queue.js +493 -0
- package/dist/runtime/run-worker.d.ts +138 -0
- package/dist/runtime/run-worker.js +806 -0
- package/dist/runtime/stream.controller.d.ts +34 -0
- package/dist/runtime/stream.controller.js +122 -0
- package/dist/runtime/stream.d.ts +63 -0
- package/dist/runtime/stream.js +262 -0
- package/dist/runtime/subagents/child.d.ts +80 -0
- package/dist/runtime/subagents/child.js +225 -0
- package/dist/runtime/subagents/definition.d.ts +103 -0
- package/dist/runtime/subagents/definition.js +392 -0
- package/dist/runtime/subagents/dispatch.d.ts +69 -0
- package/dist/runtime/subagents/dispatch.js +502 -0
- package/dist/runtime/subagents/limits.d.ts +23 -0
- package/dist/runtime/subagents/limits.js +34 -0
- package/dist/runtime/subagents/org-agents.d.ts +50 -0
- package/dist/runtime/subagents/org-agents.js +70 -0
- package/dist/runtime/subagents/preamble.d.ts +7 -0
- package/dist/runtime/subagents/preamble.js +11 -0
- package/dist/runtime/subagents/progress.d.ts +26 -0
- package/dist/runtime/subagents/progress.js +36 -0
- package/dist/runtime/subagents/roster.d.ts +55 -0
- package/dist/runtime/subagents/roster.js +111 -0
- package/dist/runtime/subagents/skill-fork.d.ts +123 -0
- package/dist/runtime/subagents/skill-fork.js +259 -0
- package/dist/runtime/usage-report.d.ts +163 -0
- package/dist/runtime/usage-report.js +551 -0
- package/dist/runtime/waits.d.ts +233 -0
- package/dist/runtime/waits.js +883 -0
- package/dist/sandbox/leases.d.ts +169 -0
- package/dist/sandbox/leases.js +515 -0
- package/dist/sandbox/lifecycle.d.ts +21 -0
- package/dist/sandbox/lifecycle.js +68 -0
- package/dist/sandbox/sandbox.service.d.ts +249 -0
- package/dist/sandbox/sandbox.service.js +908 -0
- package/dist/skills/catalog.d.ts +149 -0
- package/dist/skills/catalog.js +405 -0
- package/dist/skills/changes.controller.d.ts +56 -0
- package/dist/skills/changes.controller.js +136 -0
- package/dist/skills/changes.service.d.ts +175 -0
- package/dist/skills/changes.service.js +805 -0
- package/dist/skills/invocable.controller.d.ts +23 -0
- package/dist/skills/invocable.controller.js +50 -0
- package/dist/skills/invocation-keys.d.ts +23 -0
- package/dist/skills/invocation-keys.js +44 -0
- package/dist/skills/invoke.d.ts +135 -0
- package/dist/skills/invoke.js +286 -0
- package/dist/skills/package.d.ts +87 -0
- package/dist/skills/package.js +227 -0
- package/dist/skills/skills.controller.d.ts +40 -0
- package/dist/skills/skills.controller.js +110 -0
- package/dist/skills/skills.service.d.ts +192 -0
- package/dist/skills/skills.service.js +567 -0
- package/dist/storage/prefix.d.ts +36 -0
- package/dist/storage/prefix.js +104 -0
- package/dist/storage/purge.d.ts +27 -0
- package/dist/storage/purge.js +75 -0
- package/dist/storage/storage.service.d.ts +44 -0
- package/dist/storage/storage.service.js +145 -0
- package/dist/text.d.ts +13 -0
- package/dist/text.js +13 -0
- package/dist/tools/approvals.controller.d.ts +53 -0
- package/dist/tools/approvals.controller.js +128 -0
- package/dist/tools/approvals.service.d.ts +172 -0
- package/dist/tools/approvals.service.js +568 -0
- package/dist/tools/breaker.d.ts +28 -0
- package/dist/tools/breaker.js +72 -0
- package/dist/tools/builtins/agent.d.ts +81 -0
- package/dist/tools/builtins/agent.js +223 -0
- package/dist/tools/builtins/ask-user.d.ts +28 -0
- package/dist/tools/builtins/ask-user.js +139 -0
- package/dist/tools/builtins/read-tool-output.d.ts +18 -0
- package/dist/tools/builtins/read-tool-output.js +108 -0
- package/dist/tools/builtins/sandbox/bash.d.ts +16 -0
- package/dist/tools/builtins/sandbox/bash.js +137 -0
- package/dist/tools/builtins/sandbox/common.d.ts +116 -0
- package/dist/tools/builtins/sandbox/common.js +306 -0
- package/dist/tools/builtins/sandbox/deliver.d.ts +5 -0
- package/dist/tools/builtins/sandbox/deliver.js +180 -0
- package/dist/tools/builtins/sandbox/edit.d.ts +4 -0
- package/dist/tools/builtins/sandbox/edit.js +98 -0
- package/dist/tools/builtins/sandbox/glob-match.d.ts +25 -0
- package/dist/tools/builtins/sandbox/glob-match.js +240 -0
- package/dist/tools/builtins/sandbox/glob.d.ts +4 -0
- package/dist/tools/builtins/sandbox/glob.js +104 -0
- package/dist/tools/builtins/sandbox/grep.d.ts +9 -0
- package/dist/tools/builtins/sandbox/grep.js +133 -0
- package/dist/tools/builtins/sandbox/index.d.ts +12 -0
- package/dist/tools/builtins/sandbox/index.js +27 -0
- package/dist/tools/builtins/sandbox/names.d.ts +7 -0
- package/dist/tools/builtins/sandbox/names.js +20 -0
- package/dist/tools/builtins/sandbox/read.d.ts +8 -0
- package/dist/tools/builtins/sandbox/read.js +121 -0
- package/dist/tools/builtins/sandbox/write.d.ts +4 -0
- package/dist/tools/builtins/sandbox/write.js +88 -0
- package/dist/tools/builtins/skill-load.d.ts +53 -0
- package/dist/tools/builtins/skill-load.js +446 -0
- package/dist/tools/builtins/skill-write.d.ts +59 -0
- package/dist/tools/builtins/skill-write.js +244 -0
- package/dist/tools/builtins/tool-search.d.ts +31 -0
- package/dist/tools/builtins/tool-search.js +171 -0
- package/dist/tools/connector-content.controller.d.ts +34 -0
- package/dist/tools/connector-content.controller.js +78 -0
- package/dist/tools/connector-content.d.ts +104 -0
- package/dist/tools/connector-content.js +267 -0
- package/dist/tools/connectors.controller.d.ts +210 -0
- package/dist/tools/connectors.controller.js +234 -0
- package/dist/tools/connectors.service.d.ts +303 -0
- package/dist/tools/connectors.service.js +1102 -0
- package/dist/tools/credentials.d.ts +139 -0
- package/dist/tools/credentials.js +351 -0
- package/dist/tools/drift.d.ts +141 -0
- package/dist/tools/drift.js +539 -0
- package/dist/tools/elicitation.d.ts +81 -0
- package/dist/tools/elicitation.js +266 -0
- package/dist/tools/endpoint.d.ts +18 -0
- package/dist/tools/endpoint.js +115 -0
- package/dist/tools/info.d.ts +67 -0
- package/dist/tools/info.js +113 -0
- package/dist/tools/naming.d.ts +27 -0
- package/dist/tools/naming.js +47 -0
- package/dist/tools/oauth/discovery.d.ts +65 -0
- package/dist/tools/oauth/discovery.js +307 -0
- package/dist/tools/oauth/flow.d.ts +63 -0
- package/dist/tools/oauth/flow.js +237 -0
- package/dist/tools/oauth/oauth.controller.d.ts +31 -0
- package/dist/tools/oauth/oauth.controller.js +95 -0
- package/dist/tools/oauth/tokens.d.ts +111 -0
- package/dist/tools/oauth/tokens.js +258 -0
- package/dist/tools/outputs.d.ts +61 -0
- package/dist/tools/outputs.js +156 -0
- package/dist/tools/pipeline.d.ts +322 -0
- package/dist/tools/pipeline.js +1236 -0
- package/dist/tools/policy.d.ts +60 -0
- package/dist/tools/policy.js +236 -0
- package/dist/tools/questions.controller.d.ts +24 -0
- package/dist/tools/questions.controller.js +58 -0
- package/dist/tools/questions.service.d.ts +103 -0
- package/dist/tools/questions.service.js +295 -0
- package/dist/tools/redact.d.ts +20 -0
- package/dist/tools/redact.js +60 -0
- package/dist/tools/registry.d.ts +246 -0
- package/dist/tools/registry.js +481 -0
- package/dist/tools/resources.d.ts +16 -0
- package/dist/tools/resources.js +76 -0
- package/dist/tools/specs.d.ts +14 -0
- package/dist/tools/specs.js +31 -0
- package/dist/tools/validate.d.ts +20 -0
- package/dist/tools/validate.js +183 -0
- package/dist/tools/view.d.ts +43 -0
- package/dist/tools/view.js +225 -0
- package/dist/ui/embed-token.d.ts +31 -0
- package/dist/ui/embed-token.js +132 -0
- package/dist/ui/registry.d.ts +58 -0
- package/dist/ui/registry.js +90 -0
- package/dist/ui/ui-stream.d.ts +37 -0
- package/dist/ui/ui-stream.js +162 -0
- package/dist/ui/views.controller.d.ts +81 -0
- package/dist/ui/views.controller.js +261 -0
- package/dist/ui/views.d.ts +155 -0
- package/dist/ui/views.js +306 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.js +6 -0
- package/package.json +69 -3
- package/src/migrations/0001_init.sql +8 -0
- package/src/migrations/0002_secrets.sql +8 -0
- package/src/migrations/0003_identity.sql +117 -0
- package/src/migrations/0004_plugin_org_config_nullable.sql +3 -0
- package/src/migrations/0005_agents.sql +27 -0
- package/src/migrations/0006_conversations.sql +37 -0
- package/src/migrations/0007_checkpoints.sql +26 -0
- package/src/migrations/0008_runs_trigger_seq.sql +3 -0
- package/src/migrations/0009_runs_active_unique.sql +4 -0
- package/src/migrations/0010_tools.sql +125 -0
- package/src/migrations/0011_approvals_spec.sql +10 -0
- package/src/migrations/0012_run_waits.sql +24 -0
- package/src/migrations/0013_app_tools_source.sql +4 -0
- package/src/migrations/0014_tool_specs.sql +8 -0
- package/src/migrations/0015_tool_drift.sql +20 -0
- package/src/migrations/0016_plugin_permissions.sql +11 -0
- package/src/migrations/0017_identity_sources.sql +6 -0
- package/src/migrations/0018_channels.sql +74 -0
- package/src/migrations/0019_identity_trust.sql +17 -0
- package/src/migrations/0020_channel_card_lookup.sql +10 -0
- package/src/migrations/0021_org_storage_purge.sql +9 -0
- package/src/migrations/0022_attachments.sql +29 -0
- package/src/migrations/0023_sandboxes.sql +37 -0
- package/src/migrations/0024_skills.sql +46 -0
- package/src/migrations/0025_skills_catalog_idx.sql +6 -0
- package/src/migrations/0026_skill_changes.sql +34 -0
- package/src/migrations/0027_model_prices.sql +18 -0
- package/src/migrations/0028_evals.sql +105 -0
- package/src/migrations/0029_model_purposes.sql +18 -0
- package/src/migrations/0030_plugin_installs.sql +73 -0
- package/src/migrations/0031_plugin_snapshot_source.sql +6 -0
- package/src/migrations/0032_plugin_deployment_configs.sql +10 -0
- package/src/migrations/0033_rename_apps_to_connectors.sql +25 -0
- package/src/migrations/0034_directory.sql +49 -0
- package/src/migrations/0035_catalogs.sql +40 -0
- package/src/migrations/0036_app_import_staging.sql +17 -0
- package/src/migrations/0037_directory_installs.sql +92 -0
- package/src/migrations/0038_channel_inbound_mode.sql +6 -0
- package/src/migrations/0039_channel_card_pending.sql +8 -0
- package/src/migrations/0040_usage_report_sweep.sql +10 -0
- package/src/migrations/0041_rename_plugins_to_extensions.sql +38 -0
- package/src/migrations/0042_rename_directory_to_catalog.sql +80 -0
- package/src/migrations/0043_rename_app_installs_to_plugin_installs.sql +20 -0
- package/src/migrations/0044_catalog_one_kind.sql +90 -0
- package/src/migrations/0045_plugin_dependencies.sql +9 -0
- package/src/migrations/0046_git_sources.sql +25 -0
- package/src/migrations/0047_marketplace_entry_heads.sql +7 -0
- package/src/migrations/0048_marketplace_entry_trees.sql +8 -0
- package/src/migrations/0049_plugin_upgrades.sql +37 -0
- package/src/migrations/0050_bootstrap.sql +53 -0
- package/src/migrations/0051_claude_compat.sql +26 -0
- package/src/migrations/0052_conversations_account_agent_idx.sql +5 -0
- package/src/migrations/0053_subagents.sql +73 -0
- package/src/migrations/0054_subagent_wait_expiry.sql +7 -0
- package/src/migrations/0055_subagent_parent_indexes.sql +10 -0
- package/src/migrations/0056_approval_reason.sql +3 -0
- package/src/migrations/0057_conversation_titles.sql +11 -0
- package/src/migrations/0058_conversation_selection.sql +4 -0
- package/src/migrations/0059_conversation_queue.sql +22 -0
- package/src/migrations/0060_file_previewers.sql +10 -0
- package/src/migrations/0061_queue_selection.sql +5 -0
- package/src/migrations/0062_queued_skill.sql +8 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { isSafePackagePath, PLUGIN_MANIFEST_LIMITS } from "@capybara-hq/plugin-sdk";
|
|
3
|
+
import { contentDigest, PluginPackageError } from "../plugin-package.js";
|
|
4
|
+
import { printable } from "./report.js";
|
|
5
|
+
/**
|
|
6
|
+
* Lenient reading of Claude Code's plugin files (`.claude-plugin/plugin.json`, `.mcp.json`,
|
|
7
|
+
* `hooks/hooks.json`; format: spec Appendix A, re-checked against the Claude Code plugins
|
|
8
|
+
* reference on 2026-10-26). Claude's format is open-ended and keeps gaining fields, so there is no
|
|
9
|
+
* schema: every value is type-checked where it is used, and a wrong type is a report item, never
|
|
10
|
+
* an exception (spec §8.1).
|
|
11
|
+
*/
|
|
12
|
+
/** Claude Code's plugin manifest. */
|
|
13
|
+
export const CLAUDE_PLUGIN_FILE = ".claude-plugin/plugin.json";
|
|
14
|
+
/**
|
|
15
|
+
* Component fields a marketplace entry may carry (stored in `ClaudeEntryOverlay.components`). The
|
|
16
|
+
* first six are the ones Claude's `strict` rule appends or rejects; the rest apply only to a plugin
|
|
17
|
+
* without its own `plugin.json` (the entry is then the manifest).
|
|
18
|
+
*/
|
|
19
|
+
export const CLAUDE_STRICT_COMPONENT_KEYS = [
|
|
20
|
+
"skills",
|
|
21
|
+
"commands",
|
|
22
|
+
"agents",
|
|
23
|
+
"hooks",
|
|
24
|
+
"outputStyles",
|
|
25
|
+
"themes",
|
|
26
|
+
];
|
|
27
|
+
export const CLAUDE_COMPONENT_KEYS = [
|
|
28
|
+
...CLAUDE_STRICT_COMPONENT_KEYS,
|
|
29
|
+
"mcpServers",
|
|
30
|
+
"lspServers",
|
|
31
|
+
"userConfig",
|
|
32
|
+
"channels",
|
|
33
|
+
"monitors",
|
|
34
|
+
"workflows",
|
|
35
|
+
"experimental",
|
|
36
|
+
"settings",
|
|
37
|
+
];
|
|
38
|
+
export const isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
39
|
+
/** JSON with object keys sorted (code unit order) at every level. */
|
|
40
|
+
const canonicalJson = (v) => Array.isArray(v)
|
|
41
|
+
? `[${v.map(canonicalJson).join(",")}]`
|
|
42
|
+
: isObj(v)
|
|
43
|
+
? `{${Object.keys(v)
|
|
44
|
+
.sort()
|
|
45
|
+
.map((k) => `${JSON.stringify(k)}:${canonicalJson(v[k])}`)
|
|
46
|
+
.join(",")}}`
|
|
47
|
+
: (JSON.stringify(v) ?? "null");
|
|
48
|
+
/**
|
|
49
|
+
* The content digest of a Claude Code plugin (Decision 5, Review Focus 5): {@link contentDigest}
|
|
50
|
+
* of the files as read, never of the translated tree, so it does not depend on the translator.
|
|
51
|
+
* When the marketplace entry carries component fields, they decide what is imported (Claude's
|
|
52
|
+
* `strict` rule), so `strict` and the components (canonical JSON) are folded in: an entry-only
|
|
53
|
+
* change at the same version is other content (`+git.<sha12>` / `+sha256.<12>`), not
|
|
54
|
+
* `catalog.version_exists`. An entry without components gives the files' own digest, the same as
|
|
55
|
+
* a direct git import of the plugin. Entry display fields (description, author) are listing data
|
|
56
|
+
* and are not folded in, as for a Capybara marketplace.
|
|
57
|
+
*
|
|
58
|
+
* Phase D (spec §8.3): `translatorRevision` (the translation's, set only when the tree has a
|
|
59
|
+
* command, a manual-only or a forked skill, whose translation phase D changed) is folded in last,
|
|
60
|
+
* so re-importing such a plugin at an already imported version records `+sha256.<12>` with the
|
|
61
|
+
* new skills, while every other plugin keeps its digest.
|
|
62
|
+
*/
|
|
63
|
+
export function claudeContentDigest(files, overlay, translatorRevision) {
|
|
64
|
+
let digest = contentDigest(files);
|
|
65
|
+
if (overlay !== undefined && Object.keys(overlay.components).length > 0) {
|
|
66
|
+
const entry = canonicalJson({ strict: overlay.strict, components: overlay.components });
|
|
67
|
+
digest = createHash("sha256").update(`${digest}\0claude-entry\0${entry}`).digest("hex");
|
|
68
|
+
}
|
|
69
|
+
if (translatorRevision === undefined)
|
|
70
|
+
return digest;
|
|
71
|
+
return createHash("sha256")
|
|
72
|
+
.update(`${digest}\0claude-translator\0${translatorRevision}`)
|
|
73
|
+
.digest("hex");
|
|
74
|
+
}
|
|
75
|
+
export const decodeUtf8 = (data) => {
|
|
76
|
+
try {
|
|
77
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(data);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
/** Reads a JSON file with the plugin manifest's size cap; never throws. */
|
|
84
|
+
export function readJsonFile(data) {
|
|
85
|
+
const max = PLUGIN_MANIFEST_LIMITS.manifestChars;
|
|
86
|
+
if (data.byteLength > max * 4)
|
|
87
|
+
return { problem: `larger than ${max} characters` };
|
|
88
|
+
const text = decodeUtf8(data);
|
|
89
|
+
if (text === undefined)
|
|
90
|
+
return { problem: "not valid UTF-8 text" };
|
|
91
|
+
if (text.length > max)
|
|
92
|
+
return { problem: `larger than ${max} characters` };
|
|
93
|
+
try {
|
|
94
|
+
return { value: JSON.parse(text.startsWith("") ? text.slice(1) : text) };
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return { problem: "not valid JSON" };
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/** Cuts a string to `max` code points (trimmed). */
|
|
101
|
+
export const cut = (s, max) => [...s.trim()].slice(0, max).join("");
|
|
102
|
+
/** A short, printable rendering of an untrusted key for the report (see {@link printable}). */
|
|
103
|
+
export const showName = (s) => cut(printable(s), 200) || "?";
|
|
104
|
+
/**
|
|
105
|
+
* Resolves a component path of a Claude manifest (`./x`, or `.` / `./` for the root where
|
|
106
|
+
* `allowRoot`) to a path relative to the plugin root (`""` is the root). A non-string, a path
|
|
107
|
+
* without `./` or the root where it is not allowed is a `{ problem }` (the caller reports it); a
|
|
108
|
+
* path that leaves the root, or is not a safe relative path at all, refuses the import naming it
|
|
109
|
+
* (spec §8.1: paths stay inside the root).
|
|
110
|
+
*/
|
|
111
|
+
export function componentPath(p, where, allowRoot = false) {
|
|
112
|
+
if (typeof p !== "string")
|
|
113
|
+
return { problem: "must be a path string" };
|
|
114
|
+
if (allowRoot && (p === "." || p === "./"))
|
|
115
|
+
return { rel: "" };
|
|
116
|
+
const leaves = p.startsWith("/") || p.split(/[/\\]/).includes("..");
|
|
117
|
+
if (!leaves && !p.startsWith("./")) {
|
|
118
|
+
return { problem: `path ${JSON.stringify(showName(p))} must start with "./"` };
|
|
119
|
+
}
|
|
120
|
+
const rest = p.slice(2).replace(/\/+$/, "");
|
|
121
|
+
if (!leaves && rest === "") {
|
|
122
|
+
return allowRoot
|
|
123
|
+
? { rel: "" }
|
|
124
|
+
: { problem: `path ${JSON.stringify(showName(p))} must not be the plugin root` };
|
|
125
|
+
}
|
|
126
|
+
if (leaves || !isSafePackagePath(rest)) {
|
|
127
|
+
throw new PluginPackageError("catalog.invalid_manifest", [
|
|
128
|
+
`${where}: path ${JSON.stringify(showName(p))} leaves the plugin root or is not a safe relative path`,
|
|
129
|
+
]);
|
|
130
|
+
}
|
|
131
|
+
return { rel: rest };
|
|
132
|
+
}
|
|
133
|
+
/** A string or an array as a list (anything else is `null`). */
|
|
134
|
+
export const asList = (v) => Array.isArray(v) ? v : v === undefined ? [] : typeof v === "string" || isObj(v) ? [v] : null;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type MarketplaceManifest } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { type ClaudeEntryOverlay } from "./manifest.js";
|
|
3
|
+
export { CLAUDE_PLUGIN_FILE } from "./manifest.js";
|
|
4
|
+
/**
|
|
5
|
+
* Claude Code's `.claude-plugin/marketplace.json` (spec §5.1, Appendix A; re-checked against the
|
|
6
|
+
* Claude Code marketplace reference on 2026-10-26) read as a Capybara marketplace: each entry
|
|
7
|
+
* becomes a {@link MarketplaceEntry} with a Capybara source, and its component fields and `strict`
|
|
8
|
+
* flag go to a {@link ClaudeEntryOverlay} that the import applies. Claude validates each entry on
|
|
9
|
+
* its own, so an entry Capybara cannot store is skipped with a reason, never fails the marketplace.
|
|
10
|
+
*/
|
|
11
|
+
/** Claude Code's marketplace manifest in a git repository. */
|
|
12
|
+
export declare const CLAUDE_MARKETPLACE_FILE = ".claude-plugin/marketplace.json";
|
|
13
|
+
/** Why an entry of a marketplace could not be stored (shown on the marketplace). */
|
|
14
|
+
export type MarketplaceSkipReason = "claude_npm_unpinned" | "claude_source_unsupported" | "invalid_name" | "invalid_entry";
|
|
15
|
+
/** Result of {@link parseClaudeMarketplace}. */
|
|
16
|
+
export interface ClaudeMarketplace {
|
|
17
|
+
manifest: MarketplaceManifest;
|
|
18
|
+
/** Entry name -> overlay. */
|
|
19
|
+
overlays: Map<string, ClaudeEntryOverlay>;
|
|
20
|
+
skipped: {
|
|
21
|
+
name: string;
|
|
22
|
+
reason: MarketplaceSkipReason;
|
|
23
|
+
}[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Parses a Claude Code `marketplace.json` value. A top level that is not an object, or has no
|
|
27
|
+
* `name` or `plugins` array, is `{ errors }`; each entry that cannot be stored is in `skipped`.
|
|
28
|
+
* The produced manifest passes `parseMarketplaceManifest` (a root path entry is `{ path: "." }`,
|
|
29
|
+
* as for a single-plugin repository).
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseClaudeMarketplace(json: unknown, o: {
|
|
32
|
+
allowInsecureLoopback: boolean;
|
|
33
|
+
}): ClaudeMarketplace | {
|
|
34
|
+
errors: string[];
|
|
35
|
+
};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { CATALOG_ITEM_NAME_RE, isSafePackagePath, parseMarketplaceManifest, SEMVER_VERSION_RE, } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { expandGitUrl } from "../git-source.js";
|
|
3
|
+
import { CLAUDE_COMPONENT_KEYS, cut, isObj, showName, } from "./manifest.js";
|
|
4
|
+
export { CLAUDE_PLUGIN_FILE } from "./manifest.js";
|
|
5
|
+
/**
|
|
6
|
+
* Claude Code's `.claude-plugin/marketplace.json` (spec §5.1, Appendix A; re-checked against the
|
|
7
|
+
* Claude Code marketplace reference on 2026-10-26) read as a Capybara marketplace: each entry
|
|
8
|
+
* becomes a {@link MarketplaceEntry} with a Capybara source, and its component fields and `strict`
|
|
9
|
+
* flag go to a {@link ClaudeEntryOverlay} that the import applies. Claude validates each entry on
|
|
10
|
+
* its own, so an entry Capybara cannot store is skipped with a reason, never fails the marketplace.
|
|
11
|
+
*/
|
|
12
|
+
/** Claude Code's marketplace manifest in a git repository. */
|
|
13
|
+
export const CLAUDE_MARKETPLACE_FILE = ".claude-plugin/marketplace.json";
|
|
14
|
+
const SHA_RE = /^[0-9a-f]{40}$/;
|
|
15
|
+
const HTTPS_RE = /^https:\/\/\S+$/;
|
|
16
|
+
const LOOPBACK_RE = /^http:\/\/(?:127\.\d{1,3}\.\d{1,3}\.\d{1,3}|localhost|\[::1\])(?::\d{1,5})?(?:\/\S*)?$/;
|
|
17
|
+
const SUMMARY_MAX = 280;
|
|
18
|
+
/** Most entries read; the rest are one skipped row. */
|
|
19
|
+
const MAX_ENTRIES = 5000;
|
|
20
|
+
/** `./a/b/`, `a/b` -> `a/b`; `.`, `./` -> `.`; null when it leaves the repository. */
|
|
21
|
+
function repoRelative(p) {
|
|
22
|
+
const rest = p.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
23
|
+
if (rest === "" || rest === ".")
|
|
24
|
+
return ".";
|
|
25
|
+
return isSafePackagePath(rest) ? rest : null;
|
|
26
|
+
}
|
|
27
|
+
function mapSource(raw, pluginRoot, loopback) {
|
|
28
|
+
if (typeof raw === "string") {
|
|
29
|
+
// A bare name resolves under metadata.pluginRoot; anything else needs "./" (or is ".").
|
|
30
|
+
const bare = raw !== "." && !raw.startsWith("./") && !raw.includes("/");
|
|
31
|
+
if (bare && pluginRoot === null)
|
|
32
|
+
return { skip: "invalid_entry" };
|
|
33
|
+
if (!bare && raw !== "." && !raw.startsWith("./"))
|
|
34
|
+
return { skip: "invalid_entry" };
|
|
35
|
+
const rel = repoRelative(bare ? `${pluginRoot}/${raw}` : raw);
|
|
36
|
+
if (rel === null)
|
|
37
|
+
return { skip: "invalid_entry" };
|
|
38
|
+
return { source: { path: rel === "." ? "." : `./${rel}` } };
|
|
39
|
+
}
|
|
40
|
+
if (!isObj(raw) || typeof raw.source !== "string")
|
|
41
|
+
return { skip: "invalid_entry" };
|
|
42
|
+
const okUrl = (u) => HTTPS_RE.test(u) || (loopback && LOOPBACK_RE.test(u));
|
|
43
|
+
const pin = () => {
|
|
44
|
+
const out = {};
|
|
45
|
+
if (raw.ref !== undefined) {
|
|
46
|
+
if (typeof raw.ref !== "string" || raw.ref === "" || raw.ref.length > 256)
|
|
47
|
+
return null;
|
|
48
|
+
out.ref = raw.ref;
|
|
49
|
+
}
|
|
50
|
+
if (raw.sha !== undefined) {
|
|
51
|
+
if (typeof raw.sha !== "string" || !SHA_RE.test(raw.sha))
|
|
52
|
+
return null;
|
|
53
|
+
out.commit = raw.sha;
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
};
|
|
57
|
+
switch (raw.source) {
|
|
58
|
+
case "github": {
|
|
59
|
+
if (typeof raw.repo !== "string")
|
|
60
|
+
return { skip: "invalid_entry" };
|
|
61
|
+
const url = expandGitUrl(raw.repo);
|
|
62
|
+
const p = pin();
|
|
63
|
+
if (url === raw.repo || p === null)
|
|
64
|
+
return { skip: "invalid_entry" };
|
|
65
|
+
return { source: { git: { url, ...p } } };
|
|
66
|
+
}
|
|
67
|
+
case "url":
|
|
68
|
+
case "git-subdir": {
|
|
69
|
+
if (typeof raw.url !== "string" || raw.url === "")
|
|
70
|
+
return { skip: "invalid_entry" };
|
|
71
|
+
const url = raw.source === "git-subdir" ? expandGitUrl(raw.url) : raw.url;
|
|
72
|
+
if (!okUrl(url))
|
|
73
|
+
return { skip: "claude_source_unsupported" };
|
|
74
|
+
const p = pin();
|
|
75
|
+
if (p === null)
|
|
76
|
+
return { skip: "invalid_entry" };
|
|
77
|
+
if (raw.source === "url")
|
|
78
|
+
return { source: { git: { url, ...p } } };
|
|
79
|
+
if (typeof raw.path !== "string")
|
|
80
|
+
return { skip: "invalid_entry" };
|
|
81
|
+
const path = repoRelative(raw.path);
|
|
82
|
+
if (path === null)
|
|
83
|
+
return { skip: "invalid_entry" };
|
|
84
|
+
return { source: { git: { url, path, ...p } } };
|
|
85
|
+
}
|
|
86
|
+
case "npm":
|
|
87
|
+
return { skip: "claude_npm_unpinned" };
|
|
88
|
+
default:
|
|
89
|
+
// archive (a zip; Capybara reads tgz archives only), command, and anything newer
|
|
90
|
+
return { skip: "claude_source_unsupported" };
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Parses a Claude Code `marketplace.json` value. A top level that is not an object, or has no
|
|
95
|
+
* `name` or `plugins` array, is `{ errors }`; each entry that cannot be stored is in `skipped`.
|
|
96
|
+
* The produced manifest passes `parseMarketplaceManifest` (a root path entry is `{ path: "." }`,
|
|
97
|
+
* as for a single-plugin repository).
|
|
98
|
+
*/
|
|
99
|
+
export function parseClaudeMarketplace(json, o) {
|
|
100
|
+
if (!isObj(json))
|
|
101
|
+
return { errors: ["marketplace.json must be a JSON object"] };
|
|
102
|
+
const errors = [];
|
|
103
|
+
const name = typeof json.name === "string" ? cut(json.name, 100) : "";
|
|
104
|
+
if (name === "")
|
|
105
|
+
errors.push("name is required");
|
|
106
|
+
if (!Array.isArray(json.plugins))
|
|
107
|
+
errors.push("plugins must be an array");
|
|
108
|
+
if (errors.length > 0)
|
|
109
|
+
return { errors };
|
|
110
|
+
const metadata = isObj(json.metadata) ? json.metadata : {};
|
|
111
|
+
const rootRaw = typeof metadata.pluginRoot === "string" ? metadata.pluginRoot : null;
|
|
112
|
+
const pluginRoot = rootRaw === null ? null : repoRelative(rootRaw);
|
|
113
|
+
const ownerName = isObj(json.owner) && typeof json.owner.name === "string"
|
|
114
|
+
? cut(json.owner.name, 100) || undefined
|
|
115
|
+
: undefined;
|
|
116
|
+
const descRaw = typeof json.description === "string" ? json.description : metadata.description;
|
|
117
|
+
const description = typeof descRaw === "string" ? cut(descRaw, 1024) : "";
|
|
118
|
+
const plugins = [];
|
|
119
|
+
const overlays = new Map();
|
|
120
|
+
const skipped = [];
|
|
121
|
+
const all = json.plugins;
|
|
122
|
+
all.slice(0, MAX_ENTRIES).forEach((raw, i) => {
|
|
123
|
+
if (!isObj(raw) || typeof raw.name !== "string" || raw.name === "") {
|
|
124
|
+
skipped.push({ name: `plugins[${i}]`, reason: "invalid_entry" });
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const en = raw.name;
|
|
128
|
+
if (!CATALOG_ITEM_NAME_RE.test(en)) {
|
|
129
|
+
skipped.push({ name: showName(en), reason: "invalid_name" });
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (overlays.has(en)) {
|
|
133
|
+
skipped.push({ name: en, reason: "invalid_entry" });
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const mapped = mapSource(raw.source, pluginRoot, o.allowInsecureLoopback);
|
|
137
|
+
if ("skip" in mapped) {
|
|
138
|
+
skipped.push({ name: en, reason: mapped.skip });
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const summary = typeof raw.description === "string" && cut(raw.description, SUMMARY_MAX) !== ""
|
|
142
|
+
? cut(raw.description, SUMMARY_MAX)
|
|
143
|
+
: `Claude Code plugin ${en}`;
|
|
144
|
+
const entry = {
|
|
145
|
+
name: en,
|
|
146
|
+
summary: { en: summary },
|
|
147
|
+
...(typeof raw.version === "string" &&
|
|
148
|
+
SEMVER_VERSION_RE.test(raw.version) &&
|
|
149
|
+
raw.version.length <= 256 && { version: raw.version }),
|
|
150
|
+
...(typeof raw.homepage === "string" &&
|
|
151
|
+
HTTPS_RE.test(raw.homepage) &&
|
|
152
|
+
raw.homepage.length <= 2000 && { homepage: raw.homepage }),
|
|
153
|
+
source: mapped.source,
|
|
154
|
+
};
|
|
155
|
+
// Each entry is checked on its own (a root path stands in as "./x": the SDK has no root form).
|
|
156
|
+
const probe = parseMarketplaceManifest({
|
|
157
|
+
schemaVersion: 1,
|
|
158
|
+
name: "probe",
|
|
159
|
+
plugins: [
|
|
160
|
+
"path" in entry.source && entry.source.path === "."
|
|
161
|
+
? { ...entry, source: { path: "./x" } }
|
|
162
|
+
: entry,
|
|
163
|
+
],
|
|
164
|
+
}, { allowInsecureLoopback: o.allowInsecureLoopback });
|
|
165
|
+
if ("errors" in probe) {
|
|
166
|
+
skipped.push({ name: en, reason: "invalid_entry" });
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const components = {};
|
|
170
|
+
for (const k of CLAUDE_COMPONENT_KEYS)
|
|
171
|
+
if (raw[k] !== undefined)
|
|
172
|
+
components[k] = raw[k];
|
|
173
|
+
const author = isObj(raw.author) && typeof raw.author.name === "string" ? cut(raw.author.name, 100) : "";
|
|
174
|
+
const publisher = author !== "" ? author : ownerName;
|
|
175
|
+
plugins.push(entry);
|
|
176
|
+
overlays.set(en, {
|
|
177
|
+
strict: raw.strict !== false,
|
|
178
|
+
components,
|
|
179
|
+
...(publisher !== undefined && { publisher }),
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
if (all.length > MAX_ENTRIES) {
|
|
183
|
+
// one row for the rest, so the cut is visible on the marketplace
|
|
184
|
+
skipped.push({ name: `plugins[${MAX_ENTRIES}…${all.length - 1}]`, reason: "invalid_entry" });
|
|
185
|
+
}
|
|
186
|
+
const manifest = {
|
|
187
|
+
schemaVersion: 1,
|
|
188
|
+
name,
|
|
189
|
+
...(ownerName !== undefined && { owner: { name: ownerName } }),
|
|
190
|
+
...(description !== "" && { description }),
|
|
191
|
+
plugins,
|
|
192
|
+
};
|
|
193
|
+
return { manifest, overlays, skipped };
|
|
194
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type ConnectorTemplateFile } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { type TranslationItem } from "./report.js";
|
|
3
|
+
/**
|
|
4
|
+
* Claude Code MCP servers -> connector templates for `connector-mcp` (spec §8.3). Only remote
|
|
5
|
+
* Streamable HTTP servers translate (`type` `http` / `streamable-http`, or a `url` without a type);
|
|
6
|
+
* `sse`, `ws`, stdio and `.mcpb` / `.dxt` bundles are reported as unsupported transports. `${VAR}`
|
|
7
|
+
* in headers become the auth fields an org fills at install; nothing secret is ever copied into a
|
|
8
|
+
* template, and every generated file passes `parseConnectorTemplateFile`.
|
|
9
|
+
*/
|
|
10
|
+
/** The connector extension and kind the generated templates target. */
|
|
11
|
+
export declare const CLAUDE_MCP_CONNECTOR: {
|
|
12
|
+
readonly plugin: "connector-mcp";
|
|
13
|
+
readonly connector: "mcp";
|
|
14
|
+
};
|
|
15
|
+
/** Directory of the generated template files in the translated tree. */
|
|
16
|
+
export declare const GENERATED_CONNECTORS_DIR = ".capybara-generated/connectors";
|
|
17
|
+
/** Options of {@link mcpServerTemplates}. */
|
|
18
|
+
export interface McpTemplateOptions {
|
|
19
|
+
/** Where each server was declared (path relative to the plugin root), for the report. */
|
|
20
|
+
paths?: ReadonlyMap<string, string>;
|
|
21
|
+
/** Accept `http://` loopback URLs (tests; `marketplaces.allowInsecureLoopback`). */
|
|
22
|
+
allowInsecureLoopback?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Translates a merged map of Claude MCP servers (name -> config, later declarations already
|
|
26
|
+
* applied) into connector template files keyed by template id, plus the report items. `plugin` is
|
|
27
|
+
* the Claude plugin's name (used in the template description). At most
|
|
28
|
+
* `PLUGIN_MANIFEST_LIMITS.connectorTemplates` templates; the rest are "too many servers".
|
|
29
|
+
*/
|
|
30
|
+
export declare function mcpServerTemplates(servers: ReadonlyMap<string, unknown> | Record<string, unknown>, plugin: string, opts?: McpTemplateOptions): {
|
|
31
|
+
files: Map<string, ConnectorTemplateFile>;
|
|
32
|
+
items: TranslationItem[];
|
|
33
|
+
};
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { CATALOG_ITEM_NAME_RE, PLUGIN_MANIFEST_LIMITS, parseConnectorTemplateFile, } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { credentialQueryParams } from "../../tools/endpoint.js";
|
|
3
|
+
import { cut, isObj, showName } from "./manifest.js";
|
|
4
|
+
import { item } from "./report.js";
|
|
5
|
+
/**
|
|
6
|
+
* Claude Code MCP servers -> connector templates for `connector-mcp` (spec §8.3). Only remote
|
|
7
|
+
* Streamable HTTP servers translate (`type` `http` / `streamable-http`, or a `url` without a type);
|
|
8
|
+
* `sse`, `ws`, stdio and `.mcpb` / `.dxt` bundles are reported as unsupported transports. `${VAR}`
|
|
9
|
+
* in headers become the auth fields an org fills at install; nothing secret is ever copied into a
|
|
10
|
+
* template, and every generated file passes `parseConnectorTemplateFile`.
|
|
11
|
+
*/
|
|
12
|
+
/** The connector extension and kind the generated templates target. */
|
|
13
|
+
export const CLAUDE_MCP_CONNECTOR = { plugin: "connector-mcp", connector: "mcp" };
|
|
14
|
+
/** Directory of the generated template files in the translated tree. */
|
|
15
|
+
export const GENERATED_CONNECTORS_DIR = ".capybara-generated/connectors";
|
|
16
|
+
const VAR_RE = /\$\{([^}:]+)(?::-([^}]*))?\}/g;
|
|
17
|
+
const WHOLE_VAR_RE = /^\$\{([^}:]+)\}$/;
|
|
18
|
+
const BEARER_VAR_RE = /^Bearer \$\{([^}:]+)\}$/;
|
|
19
|
+
const LOOPBACK = new Set(["127.0.0.1", "localhost", "[::1]"]);
|
|
20
|
+
/** `My Server` -> `my-server`; empty -> `mcp`; at most 64 characters, a valid template id. */
|
|
21
|
+
function slug(name) {
|
|
22
|
+
const s = name
|
|
23
|
+
.toLowerCase()
|
|
24
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
25
|
+
.replace(/^-+|-+$/g, "")
|
|
26
|
+
.slice(0, 60)
|
|
27
|
+
.replace(/-+$/, "");
|
|
28
|
+
return s === "" ? "mcp" : s;
|
|
29
|
+
}
|
|
30
|
+
const transportOf = (cfg) => {
|
|
31
|
+
const t = cfg.type;
|
|
32
|
+
if (typeof t === "string")
|
|
33
|
+
return t;
|
|
34
|
+
if (typeof cfg.url === "string")
|
|
35
|
+
return null;
|
|
36
|
+
if (cfg.command !== undefined)
|
|
37
|
+
return "stdio";
|
|
38
|
+
return "unknown";
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Translates a merged map of Claude MCP servers (name -> config, later declarations already
|
|
42
|
+
* applied) into connector template files keyed by template id, plus the report items. `plugin` is
|
|
43
|
+
* the Claude plugin's name (used in the template description). At most
|
|
44
|
+
* `PLUGIN_MANIFEST_LIMITS.connectorTemplates` templates; the rest are "too many servers".
|
|
45
|
+
*/
|
|
46
|
+
export function mcpServerTemplates(servers, plugin, opts = {}) {
|
|
47
|
+
const files = new Map();
|
|
48
|
+
const items = [];
|
|
49
|
+
const entries = servers instanceof Map ? [...servers] : Object.entries(servers);
|
|
50
|
+
for (const [rawName, cfg] of entries) {
|
|
51
|
+
const name = showName(rawName);
|
|
52
|
+
const path = opts.paths?.get(rawName);
|
|
53
|
+
const at = path !== undefined ? { path } : {};
|
|
54
|
+
const invalid = (reason) => items.push(item("mcp_invalid", "mcpServer", name, { ...at, detail: { reason } }));
|
|
55
|
+
if (!isObj(cfg)) {
|
|
56
|
+
invalid("the server configuration is not an object");
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const transport = transportOf(cfg);
|
|
60
|
+
if (transport !== null && transport !== "http" && transport !== "streamable-http") {
|
|
61
|
+
items.push(item("mcp_unsupported_transport", "mcpServer", name, {
|
|
62
|
+
...at,
|
|
63
|
+
detail: { transport: showName(transport) },
|
|
64
|
+
}));
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (typeof cfg.url !== "string" || cfg.url === "") {
|
|
68
|
+
invalid("url must be a string");
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (files.size >= PLUGIN_MANIFEST_LIMITS.connectorTemplates) {
|
|
72
|
+
invalid("too many servers");
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const pending = [];
|
|
76
|
+
if (transport === null)
|
|
77
|
+
pending.push(item("mcp_type_assumed", "mcpServer", name, at));
|
|
78
|
+
// URL: ${VAR:-default} takes the default and makes url editable; a bare ${VAR} cannot be valid.
|
|
79
|
+
let editable = false;
|
|
80
|
+
let bare = undefined;
|
|
81
|
+
const url = cfg.url.replace(VAR_RE, (_m, v, def) => {
|
|
82
|
+
if (def === undefined) {
|
|
83
|
+
bare ??= v;
|
|
84
|
+
return "";
|
|
85
|
+
}
|
|
86
|
+
editable = true;
|
|
87
|
+
pending.push(item("mcp_url_variable", "mcpServer", name, {
|
|
88
|
+
...at,
|
|
89
|
+
detail: { variable: showName(v), default: showName(def) },
|
|
90
|
+
}));
|
|
91
|
+
return def;
|
|
92
|
+
});
|
|
93
|
+
if (bare !== undefined) {
|
|
94
|
+
items.push(item("mcp_url_variable", "mcpServer", name, {
|
|
95
|
+
...at,
|
|
96
|
+
detail: { variable: showName(bare) },
|
|
97
|
+
}));
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
let parsedUrl;
|
|
101
|
+
try {
|
|
102
|
+
parsedUrl = new URL(url);
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
parsedUrl = undefined;
|
|
106
|
+
}
|
|
107
|
+
const urlOk = parsedUrl !== undefined &&
|
|
108
|
+
(parsedUrl.protocol === "https:" ||
|
|
109
|
+
(opts.allowInsecureLoopback === true &&
|
|
110
|
+
parsedUrl.protocol === "http:" &&
|
|
111
|
+
LOOPBACK.has(parsedUrl.hostname)));
|
|
112
|
+
if (!urlOk) {
|
|
113
|
+
invalid("url must be an https URL");
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
// the endpoint is visible to every connector user: no credential may ride in the URL
|
|
117
|
+
const u = parsedUrl;
|
|
118
|
+
if (u.username !== "" || u.password !== "") {
|
|
119
|
+
invalid("the url must not contain a user name or password");
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
const secretParams = credentialQueryParams(u);
|
|
123
|
+
if (secretParams.length > 0) {
|
|
124
|
+
invalid(`the url query parameter ${secretParams.map((k) => JSON.stringify(showName(k))).join(", ")} looks like a credential`);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
// Headers: literal ones stay in the endpoint preset; ${VAR} ones become the auth fields.
|
|
128
|
+
const literal = {};
|
|
129
|
+
const vars = [];
|
|
130
|
+
let problem;
|
|
131
|
+
if (cfg.headers !== undefined) {
|
|
132
|
+
if (!isObj(cfg.headers))
|
|
133
|
+
problem = "headers must be an object";
|
|
134
|
+
else {
|
|
135
|
+
for (const [h, v] of Object.entries(cfg.headers)) {
|
|
136
|
+
if (h === "__proto__") {
|
|
137
|
+
problem = "the header name __proto__ is not allowed";
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
if (typeof v !== "string") {
|
|
141
|
+
problem = `header ${showName(h)} must be a string`;
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
const bearer = BEARER_VAR_RE.exec(v);
|
|
145
|
+
const whole = WHOLE_VAR_RE.exec(v);
|
|
146
|
+
if (bearer && h.toLowerCase() === "authorization") {
|
|
147
|
+
vars.push({ header: h, variable: bearer[1], bearer: true });
|
|
148
|
+
}
|
|
149
|
+
else if (whole) {
|
|
150
|
+
vars.push({ header: h, variable: whole[1], bearer: false });
|
|
151
|
+
}
|
|
152
|
+
else if (v.includes("${")) {
|
|
153
|
+
problem = `header ${showName(h)} mixes text and a variable`;
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
else
|
|
157
|
+
literal[h] = v;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (problem === undefined && cfg.headersHelper !== undefined) {
|
|
162
|
+
problem = "headersHelper runs a command to produce headers";
|
|
163
|
+
}
|
|
164
|
+
const oauth = cfg.oauth !== undefined;
|
|
165
|
+
if (problem === undefined && oauth && vars.length > 0) {
|
|
166
|
+
problem = "the server declares both oauth and credential headers";
|
|
167
|
+
}
|
|
168
|
+
if (problem !== undefined) {
|
|
169
|
+
invalid(problem);
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
let auth;
|
|
173
|
+
const first = vars[0];
|
|
174
|
+
if (oauth) {
|
|
175
|
+
auth = { type: "oauth_code", ownership: "personal", discovery: "mcp", client: "dcr" };
|
|
176
|
+
}
|
|
177
|
+
else if (first === undefined) {
|
|
178
|
+
auth = { type: "none" };
|
|
179
|
+
pending.push(item("mcp_auth_none", "mcpServer", name, at));
|
|
180
|
+
}
|
|
181
|
+
else if (vars.length === 1 && first.bearer) {
|
|
182
|
+
auth = { type: "bearer", ownership: "personal" };
|
|
183
|
+
}
|
|
184
|
+
else if (vars.length === 1) {
|
|
185
|
+
auth = { type: "api_key", ownership: "personal", in: "header", name: first.header };
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
auth = { type: "headers", ownership: "personal", names: vars.map((v) => v.header) };
|
|
189
|
+
}
|
|
190
|
+
for (const v of vars) {
|
|
191
|
+
pending.push(item("mcp_header_variable", "mcpServer", name, {
|
|
192
|
+
...at,
|
|
193
|
+
detail: { header: showName(v.header), variable: showName(v.variable) },
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
196
|
+
const file = {
|
|
197
|
+
displayName: { zh: cut(name, 100), en: cut(name, 100) },
|
|
198
|
+
description: cut(`Remote MCP server ${name} from Claude Code plugin ${plugin}`, 1024),
|
|
199
|
+
template: {
|
|
200
|
+
plugin: CLAUDE_MCP_CONNECTOR.plugin,
|
|
201
|
+
connector: CLAUDE_MCP_CONNECTOR.connector,
|
|
202
|
+
endpoint: { url, ...(Object.keys(literal).length > 0 && { headers: literal }) },
|
|
203
|
+
...(editable && { editableEndpoint: ["url"] }),
|
|
204
|
+
auth,
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
const parsed = parseConnectorTemplateFile(file);
|
|
208
|
+
if ("errors" in parsed) {
|
|
209
|
+
invalid(parsed.errors[0] ?? "the generated template is not valid");
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
let id = slug(rawName);
|
|
213
|
+
for (let n = 2; files.has(id); n++)
|
|
214
|
+
id = `${slug(rawName).slice(0, 60)}-${n}`;
|
|
215
|
+
if (!CATALOG_ITEM_NAME_RE.test(id)) {
|
|
216
|
+
invalid("no valid template id");
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
files.set(id, parsed);
|
|
220
|
+
items.push(item("mcp_template", "mcpServer", name, {
|
|
221
|
+
path: `${GENERATED_CONNECTORS_DIR}/${id}.json`,
|
|
222
|
+
detail: { template: id, auth: String(auth.type) },
|
|
223
|
+
}), ...pending);
|
|
224
|
+
}
|
|
225
|
+
return { files, items };
|
|
226
|
+
}
|