@capybara-hq/kernel 0.0.0-stage → 0.1.0-rc.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/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +20 -2
- package/bootstrap.json +22 -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 +1125 -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 +223 -0
- package/dist/config/schema.js +1151 -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 +422 -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 +150 -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 +210 -0
- package/dist/errors.js +212 -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 +789 -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 +149 -0
- package/dist/extensions/bootstrap.js +441 -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 +170 -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 +67 -0
- package/dist/index.js +65 -0
- package/dist/kernel.d.ts +256 -0
- package/dist/kernel.js +1326 -0
- package/dist/log.d.ts +48 -0
- package/dist/log.js +229 -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 +271 -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 +147 -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 +805 -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 +550 -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 +114 -0
- package/dist/tools/builtins/sandbox/common.js +304 -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 +67 -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,73 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** JSON Schema 无法表达的 zod 类型:降级为 `{}` 并标注 `x-unsupported`。 */
|
|
3
|
+
const UNSUPPORTED = new Set([
|
|
4
|
+
"bigint",
|
|
5
|
+
"date",
|
|
6
|
+
"symbol",
|
|
7
|
+
"undefined",
|
|
8
|
+
"void",
|
|
9
|
+
"nan",
|
|
10
|
+
"map",
|
|
11
|
+
"set",
|
|
12
|
+
"function",
|
|
13
|
+
"promise",
|
|
14
|
+
"custom",
|
|
15
|
+
"file",
|
|
16
|
+
]);
|
|
17
|
+
/**
|
|
18
|
+
* 把插件配置 schema 转成 JSON Schema(供界面渲染表单):
|
|
19
|
+
* - `secret()` 字段带 `"x-secret": true`(去掉 zod 附带的 `secret` 元数据键);
|
|
20
|
+
* - 无法表达的类型为 `{ "x-unsupported": true }`,不抛错;
|
|
21
|
+
* - 以输入侧形态输出(含 default),不带 `$schema`。
|
|
22
|
+
*/
|
|
23
|
+
export function configToJsonSchema(schema) {
|
|
24
|
+
const out = z.toJSONSchema(schema, {
|
|
25
|
+
io: "input",
|
|
26
|
+
unrepresentable: "any",
|
|
27
|
+
override: (ctx) => {
|
|
28
|
+
const js = ctx.jsonSchema;
|
|
29
|
+
const def = ctx.zodSchema._zod.def;
|
|
30
|
+
if (js.secret === true) {
|
|
31
|
+
delete js.secret;
|
|
32
|
+
js["x-secret"] = true;
|
|
33
|
+
}
|
|
34
|
+
if (UNSUPPORTED.has(def.type))
|
|
35
|
+
js["x-unsupported"] = true;
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
delete out.$schema;
|
|
39
|
+
scrubSecrets(out);
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
/** 会泄露取值的关键字:密钥字段一律不输出。 */
|
|
43
|
+
const VALUE_KEYWORDS = ["default", "examples", "const", "enum"];
|
|
44
|
+
/** 值为「名字 -> 子 schema」映射的关键字:其键是用户字段名,不是关键字。 */
|
|
45
|
+
const SCHEMA_MAPS = new Set(["properties", "patternProperties", "$defs", "definitions"]);
|
|
46
|
+
/**
|
|
47
|
+
* 递归清掉密钥节点及其所有后代上会暴露取值的关键字(`inSecret` 随递归下传);无环(输出为纯 JSON 树)。
|
|
48
|
+
* 只有 schema 关键字 default / examples / const / enum 的值被当作数据跳过;
|
|
49
|
+
* `properties` 等映射里的键是字段名,名为 default / enum 的字段照常遍历。
|
|
50
|
+
*/
|
|
51
|
+
function scrubSecrets(node, inSecret = false) {
|
|
52
|
+
if (Array.isArray(node)) {
|
|
53
|
+
for (const n of node)
|
|
54
|
+
scrubSecrets(n, inSecret);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (typeof node !== "object" || node === null)
|
|
58
|
+
return;
|
|
59
|
+
const o = node;
|
|
60
|
+
const secret = inSecret || o["x-secret"] === true;
|
|
61
|
+
if (secret)
|
|
62
|
+
for (const k of VALUE_KEYWORDS)
|
|
63
|
+
delete o[k];
|
|
64
|
+
for (const [k, v] of Object.entries(o)) {
|
|
65
|
+
if (SCHEMA_MAPS.has(k) && typeof v === "object" && v !== null) {
|
|
66
|
+
for (const child of Object.values(v))
|
|
67
|
+
scrubSecrets(child, secret);
|
|
68
|
+
}
|
|
69
|
+
else if (!VALUE_KEYWORDS.includes(k)) {
|
|
70
|
+
scrubSecrets(v, secret);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { type Transaction } from "kysely";
|
|
2
|
+
import type { core } from "zod";
|
|
3
|
+
import { type ConfigSourceKind } from "../config/sources.js";
|
|
4
|
+
import { type Keyring } from "../ctx/secrets.js";
|
|
5
|
+
import type { KernelDatabase, KernelDb } from "../db/kernel-schema.js";
|
|
6
|
+
import { type JsonSchema } from "./config-json-schema.js";
|
|
7
|
+
import { type ConfigIssue } from "./org-config.js";
|
|
8
|
+
type Trx = Transaction<KernelDatabase>;
|
|
9
|
+
type Obj = Record<string, unknown>;
|
|
10
|
+
/** 部署级插件配置的密钥存在 `capybara.secrets` 的这个 org_id 下(不是真实组织;namespace `kernel`)。 */
|
|
11
|
+
export declare const DEPLOYMENT_SECRETS_ORG = "_deployment";
|
|
12
|
+
/**
|
|
13
|
+
* 部署配置保存之后(kernel bus 主题,频道 `cap:kernel:plugin-deployment-config`,payload `{ plugin }`):
|
|
14
|
+
* 各副本重读并校验——只改了 hot 字段就地替换,改了非 hot 字段重新加载实例,不合法保持当前值并告警;
|
|
15
|
+
* 插件此刻待配置时,下一次 reconcile 加载它。
|
|
16
|
+
*/
|
|
17
|
+
export declare const PLUGIN_DEPLOYMENT_CONFIG_TOPIC = "plugin-deployment-config";
|
|
18
|
+
export type { ConfigIssue };
|
|
19
|
+
/** 后台一个部署配置字段:来源、是否只读;非密钥字段给出生效值,密钥字段只给 `set`。 */
|
|
20
|
+
export interface DeploymentConfigField {
|
|
21
|
+
path: string;
|
|
22
|
+
secret: boolean;
|
|
23
|
+
hot: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* `env` / `file` / `nacos`:启动配置给了(只读);`db`:后台保存的值;`default`:schema 默认值;`unset`:没有值。
|
|
26
|
+
*/
|
|
27
|
+
source: ConfigSourceKind | "db" | "default" | "unset";
|
|
28
|
+
readonly: boolean;
|
|
29
|
+
/** 非密钥字段的生效值(没有值时省略)。 */
|
|
30
|
+
value?: unknown;
|
|
31
|
+
/** 密钥字段是否已设置(任何来源);值永不回显。 */
|
|
32
|
+
set?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** The response of `GET / PUT /api/v1/admin/extensions/:name/config`. */
|
|
35
|
+
export interface DeploymentConfigView {
|
|
36
|
+
plugin: string;
|
|
37
|
+
version: string;
|
|
38
|
+
/** 插件声明了部署级配置。 */
|
|
39
|
+
configurable: boolean;
|
|
40
|
+
fields: DeploymentConfigField[];
|
|
41
|
+
/** 部署级 schema 的 JSON Schema(密钥字段带 `x-secret`);本副本拿不到模块(未加载的安装记录)时为 null。 */
|
|
42
|
+
schema: JsonSchema | null;
|
|
43
|
+
/** 生效配置按 schema 校验通过(`validated` 为 false 时没有校验,恒为 true,界面不要据此显示「合法」)。 */
|
|
44
|
+
valid: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* 本副本拿到了插件模块的 zod schema、`valid` / `issues` 是真实校验结果。false:未加载的安装记录,
|
|
47
|
+
* 字段按包内静态清单给出,没有校验(加载时才校验,不合法则待配置)。
|
|
48
|
+
*/
|
|
49
|
+
validated: boolean;
|
|
50
|
+
/** 校验失败的原因(只有路径与说明,不含值)。 */
|
|
51
|
+
issues: ConfigIssue[];
|
|
52
|
+
}
|
|
53
|
+
/** 一个插件的部署级配置描述:真实模块的 zod schema(有的话)与字段清单。 */
|
|
54
|
+
export interface DeploymentSchemaInfo {
|
|
55
|
+
version: string;
|
|
56
|
+
schema?: core.$ZodType | undefined;
|
|
57
|
+
fields: {
|
|
58
|
+
path: string;
|
|
59
|
+
secret: boolean;
|
|
60
|
+
hot: boolean;
|
|
61
|
+
}[];
|
|
62
|
+
}
|
|
63
|
+
/** 由 zod schema 得出字段清单(`configFields`:对象路径上的叶子,secret 向下继承)。 */
|
|
64
|
+
export declare function schemaFields(schema: core.$ZodType | undefined): DeploymentSchemaInfo["fields"];
|
|
65
|
+
/**
|
|
66
|
+
* 合并一个插件的部署配置(C10 的优先级:环境变量 > 文件 / Nacos > PG > schema 默认值):以启动配置
|
|
67
|
+
* (`fileValue`,已含环境变量)为底,逐字段补上 PG 里保存、而启动配置没有覆盖的值。按字段合并:启动配置给了的字段
|
|
68
|
+
* 整个以它为准(不与 PG 的值深合并)。`fields` 为字段点路径(没有 schema 时用 PG 值的叶子路径)。默认值由校验补上。
|
|
69
|
+
*/
|
|
70
|
+
export declare function mergeDeploymentConfig(stored: Obj, fileValue: unknown, fields?: string[]): unknown;
|
|
71
|
+
/**
|
|
72
|
+
* PG 里一个插件保存的部署配置(非密钥字段 + 解密的密钥字段,按点路径放回对象)。只并入 `secretPaths`(当前
|
|
73
|
+
* schema 里是密钥的字段)的密钥:旧版本留下、现在已不是密钥或已删掉的字段不解密、不并入(否则会被当成明文回显
|
|
74
|
+
* 或保存)。
|
|
75
|
+
*/
|
|
76
|
+
export declare function readStoredDeploymentConfig(db: KernelDb | Trx, keyring: Keyring, plugin: string, opts: {
|
|
77
|
+
forUpdate?: boolean;
|
|
78
|
+
secretPaths: readonly string[];
|
|
79
|
+
}): Promise<Obj>;
|
|
80
|
+
/** 字段清单里的密钥字段路径。 */
|
|
81
|
+
export declare const secretPathsOf: (fields: DeploymentSchemaInfo["fields"]) => string[];
|
|
82
|
+
export interface ExtensionDeploymentConfigDeps {
|
|
83
|
+
db: KernelDb;
|
|
84
|
+
keyring: Keyring;
|
|
85
|
+
/** 启动配置里的 `extensionConfig`(文件 / Nacos 与环境变量合并后)。 */
|
|
86
|
+
fileConfig: () => Record<string, unknown>;
|
|
87
|
+
/** 启动配置各字段的来源(见 `extensionConfigSources`);这些字段只读。 */
|
|
88
|
+
sources: Record<string, Record<string, ConfigSourceKind>>;
|
|
89
|
+
/** The extension's deployment config description; undefined when the deployment does not know the extension (`extension.not_found`). */
|
|
90
|
+
schemaOf: (plugin: string) => Promise<DeploymentSchemaInfo | undefined>;
|
|
91
|
+
/** 保存提交后发布 {@link PLUGIN_DEPLOYMENT_CONFIG_TOPIC};失败只告警(各副本的周期 reconcile 会重读生效插件的部署配置兜底)。 */
|
|
92
|
+
bus?: {
|
|
93
|
+
publish(topic: string, payload: unknown): Promise<void>;
|
|
94
|
+
};
|
|
95
|
+
/** 本副本立即应用(不等 bus 消息回到自己;其他副本经 bus)。失败只记 error。 */
|
|
96
|
+
applyLocal?: (plugin: string) => Promise<unknown>;
|
|
97
|
+
/** 经手的密钥值(提交后),内核传 `log.addSecrets`。 */
|
|
98
|
+
onSecrets?: (values: string[]) => void;
|
|
99
|
+
log: {
|
|
100
|
+
warn(msg: string, fields?: Record<string, unknown>): void;
|
|
101
|
+
error(msg: string, fields?: Record<string, unknown>): void;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Deployment-level extension config (D8 / C10): non-secret fields are stored in
|
|
106
|
+
* `extension_deployment_configs`, each secret field encrypted in `capybara.secrets` (namespace
|
|
107
|
+
* `kernel`, org `_deployment`, key `plugin-deployment-config:<plugin>:<path>`). Fields present in the
|
|
108
|
+
* startup config (file / Nacos / env) are read-only and show their source; the effective value
|
|
109
|
+
* follows {@link mergeDeploymentConfig}. No in-process state, shared by every replica.
|
|
110
|
+
* Secret values are never echoed: responses only say "set", audits only record which paths changed.
|
|
111
|
+
*/
|
|
112
|
+
export declare class ExtensionDeploymentConfigService {
|
|
113
|
+
private readonly d;
|
|
114
|
+
constructor(d: ExtensionDeploymentConfigDeps);
|
|
115
|
+
/** 插件的生效部署配置(未校验):启动配置为底,补上 PG 里保存的字段。`schema` 给出时按它的字段合并。 */
|
|
116
|
+
effective(plugin: string, fileValue: unknown, schema?: core.$ZodType): Promise<unknown>;
|
|
117
|
+
/** Admin view; an extension unknown to the deployment -> `extension.not_found`. */
|
|
118
|
+
view(plugin: string): Promise<DeploymentConfigView>;
|
|
119
|
+
/**
|
|
120
|
+
* Saves some fields: `values` keyed by field dot path, `null` = clear (back to the default),
|
|
121
|
+
* omitted = unchanged.
|
|
122
|
+
* - Unknown to the deployment -> `extension.not_found`; no deployment config, unknown field, or
|
|
123
|
+
* invalid after merging (except a problem in a read-only startup-config field itself) ->
|
|
124
|
+
* `extension.config_invalid` (details carry only paths and messages);
|
|
125
|
+
* - a field present in the startup config (file / Nacos / env) -> 409 `extension.config_readonly`.
|
|
126
|
+
* In a transaction, first `lockEnterpriseAdminsAndAuthorize` (re-checks the enterprise admin under
|
|
127
|
+
* the lock), then an advisory lock per extension; audit `extension.deployment_config_updated`
|
|
128
|
+
* (detail only `changedPaths`). After the commit publishes {@link PLUGIN_DEPLOYMENT_CONFIG_TOPIC} and
|
|
129
|
+
* applies it on this replica right away.
|
|
130
|
+
*/
|
|
131
|
+
put(plugin: string, values: Record<string, unknown>, actor: string, actorTokenId?: string): Promise<DeploymentConfigView>;
|
|
132
|
+
private info;
|
|
133
|
+
private render;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* 本副本拿不到模块时(未加载的安装记录)按包内审阅过的静态清单给出字段(没有 zod schema:不校验,加载时再校验)。
|
|
137
|
+
*/
|
|
138
|
+
export declare function staticDeploymentSchema(db: KernelDb, plugin: string): Promise<DeploymentSchemaInfo | undefined>;
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from "node:util";
|
|
2
|
+
import { sql } from "kysely";
|
|
3
|
+
import { configFields, describeSchema, getPath, secretValues } from "../config/fields.js";
|
|
4
|
+
import { fieldSource } from "../config/sources.js";
|
|
5
|
+
import { createSecrets } from "../ctx/secrets.js";
|
|
6
|
+
import { ApiError } from "../errors.js";
|
|
7
|
+
import { audit } from "../identity/audit.js";
|
|
8
|
+
import { lockEnterpriseAdminsAndAuthorize } from "../identity/enterprise-admin.js";
|
|
9
|
+
import { configToJsonSchema } from "./config-json-schema.js";
|
|
10
|
+
import { toIssues } from "./org-config.js";
|
|
11
|
+
/** 部署级插件配置的密钥存在 `capybara.secrets` 的这个 org_id 下(不是真实组织;namespace `kernel`)。 */
|
|
12
|
+
export const DEPLOYMENT_SECRETS_ORG = "_deployment";
|
|
13
|
+
/** 内核自己的 secrets 命名空间(`kernel` 是保留插件名)。 */
|
|
14
|
+
const SECRETS_NAMESPACE = "kernel";
|
|
15
|
+
const SECRET_KEY_PREFIX = "plugin-deployment-config:";
|
|
16
|
+
const secretKey = (plugin, path) => `${SECRET_KEY_PREFIX}${plugin}:${path}`;
|
|
17
|
+
/**
|
|
18
|
+
* 部署配置保存之后(kernel bus 主题,频道 `cap:kernel:plugin-deployment-config`,payload `{ plugin }`):
|
|
19
|
+
* 各副本重读并校验——只改了 hot 字段就地替换,改了非 hot 字段重新加载实例,不合法保持当前值并告警;
|
|
20
|
+
* 插件此刻待配置时,下一次 reconcile 加载它。
|
|
21
|
+
*/
|
|
22
|
+
export const PLUGIN_DEPLOYMENT_CONFIG_TOPIC = "plugin-deployment-config";
|
|
23
|
+
/** 由 zod schema 得出字段清单(`configFields`:对象路径上的叶子,secret 向下继承)。 */
|
|
24
|
+
export function schemaFields(schema) {
|
|
25
|
+
if (!schema)
|
|
26
|
+
return [];
|
|
27
|
+
return configFields(schema).map((f) => ({
|
|
28
|
+
path: f.path,
|
|
29
|
+
secret: f.meta?.secret === true,
|
|
30
|
+
hot: f.meta?.hot === true,
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
const isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
34
|
+
/** 按点路径设值,缺失的中间对象自动创建;中间节点不是对象时放弃。 */
|
|
35
|
+
function setDeep(obj, path, value) {
|
|
36
|
+
const segs = path.split(".");
|
|
37
|
+
let node = obj;
|
|
38
|
+
for (const seg of segs.slice(0, -1)) {
|
|
39
|
+
const next = node[seg];
|
|
40
|
+
if (next === undefined)
|
|
41
|
+
node[seg] = {};
|
|
42
|
+
else if (!isObj(next))
|
|
43
|
+
return;
|
|
44
|
+
node = node[seg];
|
|
45
|
+
}
|
|
46
|
+
node[segs[segs.length - 1]] = value;
|
|
47
|
+
}
|
|
48
|
+
/** 按点路径删除键;删完变空的中间对象一并删掉。 */
|
|
49
|
+
function deleteDeep(obj, path) {
|
|
50
|
+
const segs = path.split(".");
|
|
51
|
+
const chain = [obj];
|
|
52
|
+
let node = obj;
|
|
53
|
+
for (const seg of segs.slice(0, -1)) {
|
|
54
|
+
if (!isObj(node))
|
|
55
|
+
return;
|
|
56
|
+
node = node[seg];
|
|
57
|
+
if (!isObj(node))
|
|
58
|
+
return;
|
|
59
|
+
chain.push(node);
|
|
60
|
+
}
|
|
61
|
+
delete chain[chain.length - 1][segs[segs.length - 1]];
|
|
62
|
+
for (let i = chain.length - 1; i > 0; i--) {
|
|
63
|
+
if (Object.keys(chain[i]).length > 0)
|
|
64
|
+
break;
|
|
65
|
+
delete chain[i - 1][segs[i - 1]];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** 叶子点路径(对象递归;其余都是叶子)。 */
|
|
69
|
+
function leafPaths(value, prefix = "", out = []) {
|
|
70
|
+
if (isObj(value)) {
|
|
71
|
+
for (const [k, v] of Object.entries(value))
|
|
72
|
+
leafPaths(v, prefix ? `${prefix}.${k}` : k, out);
|
|
73
|
+
}
|
|
74
|
+
else if (prefix !== "")
|
|
75
|
+
out.push(prefix);
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
78
|
+
/** 启动配置(文件 / 环境变量合并后的值)是否覆盖了这个字段:给了它、它下面的值,或在祖先上给了非对象值。 */
|
|
79
|
+
function coveredBy(fileValue, path) {
|
|
80
|
+
let node = fileValue;
|
|
81
|
+
for (const seg of path.split(".")) {
|
|
82
|
+
if (node === undefined)
|
|
83
|
+
return false;
|
|
84
|
+
if (!isObj(node))
|
|
85
|
+
return true;
|
|
86
|
+
node = node[seg];
|
|
87
|
+
}
|
|
88
|
+
return node !== undefined;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* 合并一个插件的部署配置(C10 的优先级:环境变量 > 文件 / Nacos > PG > schema 默认值):以启动配置
|
|
92
|
+
* (`fileValue`,已含环境变量)为底,逐字段补上 PG 里保存、而启动配置没有覆盖的值。按字段合并:启动配置给了的字段
|
|
93
|
+
* 整个以它为准(不与 PG 的值深合并)。`fields` 为字段点路径(没有 schema 时用 PG 值的叶子路径)。默认值由校验补上。
|
|
94
|
+
*/
|
|
95
|
+
export function mergeDeploymentConfig(stored, fileValue, fields = leafPaths(stored)) {
|
|
96
|
+
if (fileValue !== undefined && !isObj(fileValue))
|
|
97
|
+
return fileValue;
|
|
98
|
+
const out = structuredClone(fileValue ?? {});
|
|
99
|
+
for (const path of fields) {
|
|
100
|
+
const v = getPath(stored, path);
|
|
101
|
+
if (v === undefined || coveredBy(fileValue, path))
|
|
102
|
+
continue;
|
|
103
|
+
setDeep(out, path, structuredClone(v));
|
|
104
|
+
}
|
|
105
|
+
return out;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* PG 里一个插件保存的部署配置(非密钥字段 + 解密的密钥字段,按点路径放回对象)。只并入 `secretPaths`(当前
|
|
109
|
+
* schema 里是密钥的字段)的密钥:旧版本留下、现在已不是密钥或已删掉的字段不解密、不并入(否则会被当成明文回显
|
|
110
|
+
* 或保存)。
|
|
111
|
+
*/
|
|
112
|
+
export async function readStoredDeploymentConfig(db, keyring, plugin, opts) {
|
|
113
|
+
let q = db
|
|
114
|
+
.selectFrom("extension_deployment_configs")
|
|
115
|
+
.select("config")
|
|
116
|
+
.where("plugin", "=", plugin);
|
|
117
|
+
if (opts.forUpdate)
|
|
118
|
+
q = q.forUpdate();
|
|
119
|
+
const row = await q.executeTakeFirst();
|
|
120
|
+
const out = structuredClone(row?.config ?? {});
|
|
121
|
+
const prefix = secretKey(plugin, "");
|
|
122
|
+
const wanted = new Set(opts.secretPaths);
|
|
123
|
+
if (wanted.size === 0)
|
|
124
|
+
return out;
|
|
125
|
+
const keys = await db
|
|
126
|
+
.selectFrom("secrets")
|
|
127
|
+
.select("key")
|
|
128
|
+
.where("namespace", "=", SECRETS_NAMESPACE)
|
|
129
|
+
.where("org_id", "=", DEPLOYMENT_SECRETS_ORG)
|
|
130
|
+
.execute();
|
|
131
|
+
const secrets = createSecrets(db, keyring, SECRETS_NAMESPACE);
|
|
132
|
+
for (const { key } of keys) {
|
|
133
|
+
if (!key.startsWith(prefix) || !wanted.has(key.slice(prefix.length)))
|
|
134
|
+
continue;
|
|
135
|
+
const v = await secrets.get(DEPLOYMENT_SECRETS_ORG, key);
|
|
136
|
+
if (v !== null)
|
|
137
|
+
setDeep(out, key.slice(prefix.length), JSON.parse(v));
|
|
138
|
+
}
|
|
139
|
+
return out;
|
|
140
|
+
}
|
|
141
|
+
/** 字段清单里的密钥字段路径。 */
|
|
142
|
+
export const secretPathsOf = (fields) => fields.filter((f) => f.secret).map((f) => f.path);
|
|
143
|
+
/** JSON Schema 转换按 schema 对象缓存(清单不可变)。 */
|
|
144
|
+
const jsonSchemaCache = new WeakMap();
|
|
145
|
+
function jsonSchemaOf(schema) {
|
|
146
|
+
let js = jsonSchemaCache.get(schema);
|
|
147
|
+
if (!js) {
|
|
148
|
+
js = configToJsonSchema(schema);
|
|
149
|
+
jsonSchemaCache.set(schema, js);
|
|
150
|
+
}
|
|
151
|
+
return structuredClone(js);
|
|
152
|
+
}
|
|
153
|
+
/** 某字段 zod 叶子上的默认值(整份配置不合法、校验没能补上默认值时,视图仍按它显示)。 */
|
|
154
|
+
function defaultOf(schema, path) {
|
|
155
|
+
const f = configFields(schema).find((x) => x.path === path);
|
|
156
|
+
if (!f)
|
|
157
|
+
return { has: false };
|
|
158
|
+
const d = describeSchema(f.schema);
|
|
159
|
+
return d.hasDefault ? { has: true, value: d.defaultValue } : { has: false };
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Deployment-level extension config (D8 / C10): non-secret fields are stored in
|
|
163
|
+
* `extension_deployment_configs`, each secret field encrypted in `capybara.secrets` (namespace
|
|
164
|
+
* `kernel`, org `_deployment`, key `plugin-deployment-config:<plugin>:<path>`). Fields present in the
|
|
165
|
+
* startup config (file / Nacos / env) are read-only and show their source; the effective value
|
|
166
|
+
* follows {@link mergeDeploymentConfig}. No in-process state, shared by every replica.
|
|
167
|
+
* Secret values are never echoed: responses only say "set", audits only record which paths changed.
|
|
168
|
+
*/
|
|
169
|
+
export class ExtensionDeploymentConfigService {
|
|
170
|
+
d;
|
|
171
|
+
constructor(d) {
|
|
172
|
+
this.d = d;
|
|
173
|
+
}
|
|
174
|
+
/** 插件的生效部署配置(未校验):启动配置为底,补上 PG 里保存的字段。`schema` 给出时按它的字段合并。 */
|
|
175
|
+
async effective(plugin, fileValue, schema) {
|
|
176
|
+
const stored = await readStoredDeploymentConfig(this.d.db, this.d.keyring, plugin, {
|
|
177
|
+
secretPaths: secretPathsOf(schemaFields(schema)),
|
|
178
|
+
});
|
|
179
|
+
const fields = schema ? configFields(schema).map((f) => f.path) : undefined;
|
|
180
|
+
return mergeDeploymentConfig(stored, fileValue, fields);
|
|
181
|
+
}
|
|
182
|
+
/** Admin view; an extension unknown to the deployment -> `extension.not_found`. */
|
|
183
|
+
async view(plugin) {
|
|
184
|
+
const info = await this.info(plugin);
|
|
185
|
+
const stored = await this.d.db
|
|
186
|
+
.transaction()
|
|
187
|
+
.setIsolationLevel("repeatable read")
|
|
188
|
+
.setAccessMode("read only")
|
|
189
|
+
.execute((t) => readStoredDeploymentConfig(t, this.d.keyring, plugin, {
|
|
190
|
+
secretPaths: secretPathsOf(info.fields),
|
|
191
|
+
}));
|
|
192
|
+
return this.render(plugin, info, stored);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Saves some fields: `values` keyed by field dot path, `null` = clear (back to the default),
|
|
196
|
+
* omitted = unchanged.
|
|
197
|
+
* - Unknown to the deployment -> `extension.not_found`; no deployment config, unknown field, or
|
|
198
|
+
* invalid after merging (except a problem in a read-only startup-config field itself) ->
|
|
199
|
+
* `extension.config_invalid` (details carry only paths and messages);
|
|
200
|
+
* - a field present in the startup config (file / Nacos / env) -> 409 `extension.config_readonly`.
|
|
201
|
+
* In a transaction, first `lockEnterpriseAdminsAndAuthorize` (re-checks the enterprise admin under
|
|
202
|
+
* the lock), then an advisory lock per extension; audit `extension.deployment_config_updated`
|
|
203
|
+
* (detail only `changedPaths`). After the commit publishes {@link PLUGIN_DEPLOYMENT_CONFIG_TOPIC} and
|
|
204
|
+
* applies it on this replica right away.
|
|
205
|
+
*/
|
|
206
|
+
async put(plugin, values, actor, actorTokenId) {
|
|
207
|
+
const info = await this.info(plugin);
|
|
208
|
+
if (info.fields.length === 0) {
|
|
209
|
+
throw new ApiError("extension.config_invalid", `Extension ${plugin} has no deployment config`);
|
|
210
|
+
}
|
|
211
|
+
const byPath = new Map(info.fields.map((f) => [f.path, f]));
|
|
212
|
+
const unknown = Object.keys(values).filter((p) => !byPath.has(p));
|
|
213
|
+
if (unknown.length > 0) {
|
|
214
|
+
throw new ApiError("extension.config_invalid", `Unknown deployment config fields for extension ${plugin}`, unknown.map((path) => ({ path, message: "unknown field" })));
|
|
215
|
+
}
|
|
216
|
+
const sources = this.d.sources[plugin];
|
|
217
|
+
const readonly = Object.keys(values).filter((p) => fieldSource(sources, p) !== undefined);
|
|
218
|
+
if (readonly.length > 0) {
|
|
219
|
+
throw new ApiError("extension.config_readonly", `These deployment config fields of extension ${plugin} are set in the startup config (file, Nacos or environment) and are read-only here: ${readonly.join(", ")}`, readonly.map((path) => ({ path, source: fieldSource(sources, path) })));
|
|
220
|
+
}
|
|
221
|
+
const fileValue = this.d.fileConfig()[plugin];
|
|
222
|
+
const fieldPaths = info.fields.map((f) => f.path);
|
|
223
|
+
let saved;
|
|
224
|
+
let changed = [];
|
|
225
|
+
await this.d.db.transaction().execute(async (t) => {
|
|
226
|
+
await lockEnterpriseAdminsAndAuthorize(t, actor);
|
|
227
|
+
await sql `SELECT pg_advisory_xact_lock(hashtext(${`capybara.plugin-deployment-config:${plugin}`}))`.execute(t);
|
|
228
|
+
const before = await readStoredDeploymentConfig(t, this.d.keyring, plugin, {
|
|
229
|
+
forUpdate: true,
|
|
230
|
+
secretPaths: secretPathsOf(info.fields),
|
|
231
|
+
});
|
|
232
|
+
const next = structuredClone(before);
|
|
233
|
+
for (const [path, v] of Object.entries(values)) {
|
|
234
|
+
if (v === null)
|
|
235
|
+
deleteDeep(next, path);
|
|
236
|
+
else
|
|
237
|
+
setDeep(next, path, structuredClone(v));
|
|
238
|
+
}
|
|
239
|
+
if (info.schema) {
|
|
240
|
+
const r = info.schema.safeParse(mergeDeploymentConfig(next, fileValue, fieldPaths));
|
|
241
|
+
if (!r.success) {
|
|
242
|
+
// 启动配置里只读字段自己的问题这里改不了(照样保存,插件保持待配置),其余拒绝
|
|
243
|
+
const issues = toIssues(r.error).filter((i) => i.path === "" || fieldSource(sources, i.path) === undefined);
|
|
244
|
+
if (issues.length > 0) {
|
|
245
|
+
throw new ApiError("extension.config_invalid", `Invalid deployment config for extension ${plugin}`, issues);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
changed = Object.keys(values)
|
|
250
|
+
.filter((p) => !isDeepStrictEqual(getPath(before, p), getPath(next, p)))
|
|
251
|
+
.sort();
|
|
252
|
+
saved = next;
|
|
253
|
+
if (changed.length === 0)
|
|
254
|
+
return;
|
|
255
|
+
const plain = structuredClone(next);
|
|
256
|
+
const secrets = createSecrets(t, this.d.keyring, SECRETS_NAMESPACE);
|
|
257
|
+
for (const f of info.fields) {
|
|
258
|
+
if (!f.secret)
|
|
259
|
+
continue;
|
|
260
|
+
deleteDeep(plain, f.path);
|
|
261
|
+
if (!(f.path in values))
|
|
262
|
+
continue;
|
|
263
|
+
const v = getPath(next, f.path);
|
|
264
|
+
if (v === undefined)
|
|
265
|
+
await secrets.delete(DEPLOYMENT_SECRETS_ORG, secretKey(plugin, f.path));
|
|
266
|
+
else
|
|
267
|
+
await secrets.set(DEPLOYMENT_SECRETS_ORG, secretKey(plugin, f.path), JSON.stringify(v));
|
|
268
|
+
}
|
|
269
|
+
await t
|
|
270
|
+
.insertInto("extension_deployment_configs")
|
|
271
|
+
.values({ plugin, config: JSON.stringify(plain), updated_by: actor })
|
|
272
|
+
.onConflict((oc) => oc.column("plugin").doUpdateSet({
|
|
273
|
+
config: JSON.stringify(plain),
|
|
274
|
+
updated_by: actor,
|
|
275
|
+
updated_at: new Date(),
|
|
276
|
+
}))
|
|
277
|
+
.execute();
|
|
278
|
+
await audit(t, {
|
|
279
|
+
actorAccountId: actor,
|
|
280
|
+
...(actorTokenId !== undefined && { actorTokenId }),
|
|
281
|
+
action: "extension.deployment_config_updated",
|
|
282
|
+
target: plugin,
|
|
283
|
+
detail: { changedPaths: changed },
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
const stored = saved ?? {};
|
|
287
|
+
if (info.schema && this.d.onSecrets) {
|
|
288
|
+
const values = secretValues(info.schema, mergeDeploymentConfig(stored, fileValue, fieldPaths));
|
|
289
|
+
if (values.length > 0)
|
|
290
|
+
this.d.onSecrets(values);
|
|
291
|
+
}
|
|
292
|
+
if (changed.length > 0) {
|
|
293
|
+
try {
|
|
294
|
+
await this.d.bus?.publish(PLUGIN_DEPLOYMENT_CONFIG_TOPIC, { plugin });
|
|
295
|
+
}
|
|
296
|
+
catch (err) {
|
|
297
|
+
this.d.log.warn("cannot publish plugin-deployment-config after saving", { plugin, err });
|
|
298
|
+
}
|
|
299
|
+
try {
|
|
300
|
+
await this.d.applyLocal?.(plugin);
|
|
301
|
+
}
|
|
302
|
+
catch (err) {
|
|
303
|
+
this.d.log.error("applying the plugin deployment config on this replica failed", {
|
|
304
|
+
plugin,
|
|
305
|
+
err,
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return this.render(plugin, info, stored);
|
|
310
|
+
}
|
|
311
|
+
async info(plugin) {
|
|
312
|
+
const info = await this.d.schemaOf(plugin);
|
|
313
|
+
if (!info) {
|
|
314
|
+
throw new ApiError("extension.not_found", `Extension ${plugin} is not known to this deployment`);
|
|
315
|
+
}
|
|
316
|
+
return info;
|
|
317
|
+
}
|
|
318
|
+
render(plugin, info, stored) {
|
|
319
|
+
const fileValue = this.d.fileConfig()[plugin];
|
|
320
|
+
const sources = this.d.sources[plugin];
|
|
321
|
+
const raw = mergeDeploymentConfig(stored, fileValue, info.fields.map((f) => f.path));
|
|
322
|
+
let effective = raw;
|
|
323
|
+
let valid = true;
|
|
324
|
+
let issues = [];
|
|
325
|
+
if (info.schema) {
|
|
326
|
+
const r = info.schema.safeParse(raw);
|
|
327
|
+
if (r.success)
|
|
328
|
+
effective = r.data;
|
|
329
|
+
else {
|
|
330
|
+
valid = false;
|
|
331
|
+
issues = toIssues(r.error);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
const fields = info.fields.map((f) => {
|
|
335
|
+
const from = fieldSource(sources, f.path);
|
|
336
|
+
let value = getPath(effective, f.path);
|
|
337
|
+
let source;
|
|
338
|
+
if (from !== undefined)
|
|
339
|
+
source = from;
|
|
340
|
+
else if (getPath(stored, f.path) !== undefined)
|
|
341
|
+
source = "db";
|
|
342
|
+
else {
|
|
343
|
+
const d = info.schema ? defaultOf(info.schema, f.path) : { has: false };
|
|
344
|
+
if (value === undefined && d.has)
|
|
345
|
+
value = d.value;
|
|
346
|
+
source = value === undefined ? "unset" : "default";
|
|
347
|
+
}
|
|
348
|
+
const base = {
|
|
349
|
+
path: f.path,
|
|
350
|
+
secret: f.secret,
|
|
351
|
+
hot: f.hot,
|
|
352
|
+
source,
|
|
353
|
+
readonly: from !== undefined,
|
|
354
|
+
};
|
|
355
|
+
if (f.secret)
|
|
356
|
+
return { ...base, set: value !== undefined };
|
|
357
|
+
return value === undefined ? base : { ...base, value: structuredClone(value) };
|
|
358
|
+
});
|
|
359
|
+
return {
|
|
360
|
+
plugin,
|
|
361
|
+
version: info.version,
|
|
362
|
+
configurable: info.fields.length > 0,
|
|
363
|
+
fields,
|
|
364
|
+
schema: info.schema ? jsonSchemaOf(info.schema) : null,
|
|
365
|
+
valid,
|
|
366
|
+
validated: info.schema !== undefined,
|
|
367
|
+
issues,
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* 本副本拿不到模块时(未加载的安装记录)按包内审阅过的静态清单给出字段(没有 zod schema:不校验,加载时再校验)。
|
|
373
|
+
*/
|
|
374
|
+
export async function staticDeploymentSchema(db, plugin) {
|
|
375
|
+
const row = await db
|
|
376
|
+
.selectFrom("extension_installs")
|
|
377
|
+
.innerJoin("extension_packages", "extension_packages.sha256", "extension_installs.sha256")
|
|
378
|
+
.select(["extension_installs.version", "extension_packages.section"])
|
|
379
|
+
.where("extension_installs.name", "=", plugin)
|
|
380
|
+
.executeTakeFirst();
|
|
381
|
+
if (!row)
|
|
382
|
+
return undefined;
|
|
383
|
+
// new rows hold the plugin's extension section, pre-0.1.0 rows the old capybara section; both
|
|
384
|
+
// carry the static manifest
|
|
385
|
+
const section = row.section;
|
|
386
|
+
return {
|
|
387
|
+
version: row.version,
|
|
388
|
+
fields: (section.manifest.config?.deployment ?? []).map((f) => ({
|
|
389
|
+
path: f.path,
|
|
390
|
+
secret: f.secret,
|
|
391
|
+
hot: f.hot,
|
|
392
|
+
})),
|
|
393
|
+
};
|
|
394
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { KernelDb } from "../db/kernel-schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* Which extensions an organization has enabled. Two sources, and every reader goes through these
|
|
4
|
+
* helpers so none of them misses one:
|
|
5
|
+
* - `extension_org_configs.enabled` (the org's own switch);
|
|
6
|
+
* - every required bootstrap plugin (`extension_installs.required`, package ecosystem spec §7):
|
|
7
|
+
* enabled in every org, existing and future, without an org config row, whatever such a row says.
|
|
8
|
+
* Neither checks that the extension is loaded on this replica or enabled on the deployment; callers
|
|
9
|
+
* that need that check it themselves, as before. `db` may be a transaction.
|
|
10
|
+
*/
|
|
11
|
+
/** The names of the extensions enabled in `orgId` (a subquery with one column, `plugin`). */
|
|
12
|
+
export declare function enabledExtensionsQuery(db: KernelDb, orgId: string): import("kysely").SelectQueryBuilder<import("../db/kernel-schema.js").KernelDatabase & {
|
|
13
|
+
eoc: import("../db/kernel-schema.js").ExtensionOrgConfigsTable;
|
|
14
|
+
}, "eoc", {
|
|
15
|
+
plugin: string;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Every (org, extension) pair that is enabled, for queries that join it (columns `org_id`,
|
|
19
|
+
* `plugin`): `.innerJoin(enabledExtensionsByOrg(db).as("en"), (j) => j.onRef("en.org_id", …)…)`.
|
|
20
|
+
* Soft-deleted orgs are included, as their org config rows are; callers filter `orgs.deleted_at`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function enabledExtensionsByOrg(db: KernelDb): import("kysely").SelectQueryBuilder<import("../db/kernel-schema.js").KernelDatabase & {
|
|
23
|
+
eoc: import("../db/kernel-schema.js").ExtensionOrgConfigsTable;
|
|
24
|
+
}, "eoc", {
|
|
25
|
+
org_id: string;
|
|
26
|
+
plugin: string;
|
|
27
|
+
}>;
|
|
28
|
+
/** Whether `plugin` is enabled in `orgId` (see the file header). */
|
|
29
|
+
export declare function isExtensionEnabled(db: KernelDb, orgId: string, plugin: string): Promise<boolean>;
|
|
30
|
+
/** The names of the required bootstrap plugins (installed with `required`). */
|
|
31
|
+
export declare function requiredExtensions(db: KernelDb): Promise<Set<string>>;
|