@capybara-hq/kernel 0.1.0-rc.3 → 0.1.0-rc.5
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/bootstrap.json +61 -5
- package/dist/admin/admin.controller.d.ts +47 -16
- package/dist/admin/admin.controller.js +44 -19
- package/dist/admin/extensions.controller.d.ts +24 -3
- package/dist/admin/extensions.controller.js +48 -8
- package/dist/admin/setup-lock.d.ts +1 -1
- package/dist/admin/setup-lock.js +1 -1
- package/dist/admin/setup.controller.d.ts +1 -1
- package/dist/admin/setup.controller.js +1 -1
- package/dist/admin/setup.service.d.ts +4 -4
- package/dist/admin/setup.service.js +8 -8
- package/dist/agents/agent-lookup.d.ts +19 -0
- package/dist/agents/agent-lookup.js +21 -0
- package/dist/agents/agent-profile.service.d.ts +29 -0
- package/dist/agents/agent-profile.service.js +117 -0
- package/dist/agents/agents.controller.d.ts +168 -3
- package/dist/agents/agents.controller.js +201 -12
- package/dist/agents/agents.module.d.ts +4 -1
- package/dist/agents/agents.module.js +36 -6
- package/dist/agents/agents.service.d.ts +64 -27
- package/dist/agents/agents.service.js +199 -74
- package/dist/agents/definition.d.ts +53 -0
- package/dist/agents/definition.js +55 -0
- package/dist/agents/from-template.d.ts +106 -0
- package/dist/agents/from-template.js +649 -0
- package/dist/agents/from-template.service.d.ts +60 -0
- package/dist/agents/from-template.service.js +161 -0
- package/dist/agents/instruction-files.d.ts +60 -0
- package/dist/agents/instruction-files.js +111 -0
- package/dist/agents/models.controller.d.ts +9 -3
- package/dist/agents/models.controller.js +19 -4
- package/dist/agents/org-templates.d.ts +176 -0
- package/dist/agents/org-templates.js +827 -0
- package/dist/agents/pending-connector-requests.d.ts +77 -0
- package/dist/agents/pending-connector-requests.js +215 -0
- package/dist/agents/pending-connectors.controller.d.ts +39 -0
- package/dist/agents/pending-connectors.controller.js +91 -0
- package/dist/agents/pending-connectors.service.d.ts +62 -0
- package/dist/agents/pending-connectors.service.js +282 -0
- package/dist/agents/profile.d.ts +96 -0
- package/dist/agents/profile.js +51 -0
- package/dist/agents/readiness.controller.d.ts +26 -0
- package/dist/agents/readiness.controller.js +56 -0
- package/dist/agents/templates.controller.d.ts +86 -5
- package/dist/agents/templates.controller.js +171 -7
- package/dist/agents/templates.d.ts +127 -23
- package/dist/agents/templates.js +476 -53
- package/dist/background/background.controller.d.ts +38 -0
- package/dist/background/background.controller.js +87 -0
- package/dist/background/background.module.d.ts +10 -0
- package/dist/background/background.module.js +39 -0
- package/dist/background/finish.d.ts +44 -0
- package/dist/background/finish.js +94 -0
- package/dist/background/launch-lock.d.ts +15 -0
- package/dist/background/launch-lock.js +40 -0
- package/dist/background/launch.d.ts +36 -0
- package/dist/background/launch.js +70 -0
- package/dist/background/poll.job.d.ts +56 -0
- package/dist/background/poll.job.js +190 -0
- package/dist/background/render.d.ts +23 -0
- package/dist/background/render.js +48 -0
- package/dist/background/session.d.ts +48 -0
- package/dist/background/session.js +79 -0
- package/dist/background/status.d.ts +35 -0
- package/dist/background/status.js +57 -0
- package/dist/background/stop.d.ts +68 -0
- package/dist/background/stop.js +243 -0
- package/dist/background/store.d.ts +162 -0
- package/dist/background/store.js +357 -0
- package/dist/background/store.module.d.ts +6 -0
- package/dist/background/store.module.js +22 -0
- package/dist/background/tasks.service.d.ts +77 -0
- package/dist/background/tasks.service.js +211 -0
- package/dist/background/wake-rules.d.ts +66 -0
- package/dist/background/wake-rules.js +113 -0
- package/dist/background/wake.d.ts +30 -0
- package/dist/background/wake.js +63 -0
- package/dist/catalog/admin-catalog.controller.d.ts +129 -30
- package/dist/catalog/admin-catalog.controller.js +213 -42
- package/dist/catalog/catalog-content.d.ts +58 -32
- package/dist/catalog/catalog-content.js +34 -8
- package/dist/catalog/catalog-import.module.d.ts +7 -0
- package/dist/catalog/catalog-import.module.js +60 -0
- package/dist/catalog/catalog-items.d.ts +111 -7
- package/dist/catalog/catalog-items.js +279 -13
- package/dist/catalog/catalog-scope.service.d.ts +260 -0
- package/dist/catalog/catalog-scope.service.js +1116 -0
- package/dist/catalog/catalog.module.d.ts +7 -9
- package/dist/catalog/catalog.module.js +41 -31
- package/dist/catalog/catalog.service.d.ts +101 -29
- package/dist/catalog/catalog.service.js +104 -106
- package/dist/catalog/claude/agents.js +2 -0
- package/dist/catalog/cli.d.ts +11 -1
- package/dist/catalog/cli.js +26 -1
- package/dist/catalog/component-promotion.d.ts +96 -0
- package/dist/catalog/component-promotion.js +395 -0
- package/dist/catalog/component-scope.controller.d.ts +152 -0
- package/dist/catalog/component-scope.controller.js +287 -0
- package/dist/catalog/component-scope.service.d.ts +303 -0
- package/dist/catalog/component-scope.service.js +936 -0
- package/dist/catalog/component-state.d.ts +174 -0
- package/dist/catalog/component-state.js +437 -0
- package/dist/catalog/job-ids.d.ts +30 -0
- package/dist/catalog/job-ids.js +25 -0
- package/dist/catalog/marketplace-fetch.d.ts +1 -1
- package/dist/catalog/marketplaces.controller.d.ts +22 -5
- package/dist/catalog/marketplaces.controller.js +56 -7
- package/dist/catalog/marketplaces.service.d.ts +54 -14
- package/dist/catalog/marketplaces.service.js +71 -22
- package/dist/catalog/org-catalog.controller.d.ts +125 -34
- package/dist/catalog/org-catalog.controller.js +181 -65
- package/dist/catalog/org-catalog.service.d.ts +65 -33
- package/dist/catalog/org-catalog.service.js +324 -157
- package/dist/catalog/org-extension-switch.d.ts +41 -0
- package/dist/catalog/org-extension-switch.js +115 -0
- package/dist/catalog/org-extension.controller.d.ts +119 -0
- package/dist/catalog/org-extension.controller.js +266 -0
- package/dist/catalog/org-plugin-uploads.controller.d.ts +98 -0
- package/dist/catalog/org-plugin-uploads.controller.js +213 -0
- package/dist/catalog/org-plugin-uploads.d.ts +63 -0
- package/dist/catalog/org-plugin-uploads.js +116 -0
- package/dist/catalog/owned-items.d.ts +184 -0
- package/dist/catalog/owned-items.js +789 -0
- package/dist/catalog/owned-plugin-cleanup.d.ts +56 -0
- package/dist/catalog/owned-plugin-cleanup.js +194 -0
- package/dist/catalog/ownership.d.ts +172 -0
- package/dist/catalog/ownership.js +326 -0
- package/dist/catalog/platform-components.d.ts +221 -0
- package/dist/catalog/platform-components.js +761 -0
- package/dist/catalog/platform-migration.d.ts +115 -0
- package/dist/catalog/platform-migration.js +582 -0
- package/dist/catalog/plugin-import.d.ts +178 -34
- package/dist/catalog/plugin-import.js +623 -83
- package/dist/catalog/plugin-install.d.ts +185 -41
- package/dist/catalog/plugin-install.js +758 -126
- package/dist/catalog/plugin-upgrade.d.ts +260 -225
- package/dist/catalog/plugin-upgrade.js +1148 -1137
- package/dist/catalog/request-rules.d.ts +65 -0
- package/dist/catalog/request-rules.js +217 -0
- package/dist/catalog/requests.service.d.ts +193 -118
- package/dist/catalog/requests.service.js +526 -343
- package/dist/catalog/reserved-names.d.ts +8 -0
- package/dist/catalog/reserved-names.js +42 -0
- package/dist/catalog/scope-orgs.d.ts +21 -0
- package/dist/catalog/scope-orgs.js +67 -0
- package/dist/catalog/scope-state.d.ts +35 -0
- package/dist/catalog/scope-state.js +87 -0
- package/dist/catalog/scope-sync-workers.d.ts +7 -0
- package/dist/catalog/scope-sync-workers.js +29 -0
- package/dist/catalog/scope-sync.d.ts +176 -0
- package/dist/catalog/scope-sync.js +576 -0
- package/dist/catalog/scope.d.ts +42 -0
- package/dist/catalog/scope.js +42 -0
- package/dist/catalog/unshare.d.ts +22 -0
- package/dist/catalog/unshare.js +118 -0
- package/dist/channels/actions.js +1 -0
- package/dist/channels/cards.js +21 -3
- package/dist/channels/channels.module.js +2 -0
- package/dist/channels/connections.service.d.ts +16 -1
- package/dist/channels/connections.service.js +38 -4
- package/dist/channels/inbound.d.ts +9 -1
- package/dist/channels/inbound.js +67 -5
- package/dist/channels/phrases.d.ts +35 -0
- package/dist/channels/phrases.js +29 -0
- package/dist/channels/threads.d.ts +5 -0
- package/dist/channels/threads.js +8 -0
- package/dist/config/docs.js +3 -1
- package/dist/config/schema.d.ts +24 -2
- package/dist/config/schema.js +145 -19
- package/dist/conversations/access.d.ts +6 -4
- package/dist/conversations/access.js +29 -5
- package/dist/conversations/agent-tree.d.ts +46 -0
- package/dist/conversations/agent-tree.js +92 -0
- package/dist/conversations/attachments.service.d.ts +30 -0
- package/dist/conversations/attachments.service.js +130 -5
- package/dist/conversations/conversations.controller.d.ts +79 -23
- package/dist/conversations/conversations.controller.js +141 -50
- package/dist/conversations/conversations.module.d.ts +1 -1
- package/dist/conversations/conversations.module.js +10 -7
- package/dist/conversations/conversations.service.d.ts +108 -9
- package/dist/conversations/conversations.service.js +237 -30
- package/dist/conversations/environment-status.d.ts +24 -0
- package/dist/conversations/environment-status.js +71 -0
- package/dist/conversations/event-log.d.ts +21 -6
- package/dist/conversations/event-log.js +70 -1
- package/dist/conversations/events.d.ts +140 -0
- package/dist/conversations/events.js +142 -13
- package/dist/conversations/queue.d.ts +3 -1
- package/dist/conversations/queue.js +13 -2
- package/dist/conversations/queue.service.d.ts +1 -1
- package/dist/conversations/queue.service.js +8 -1
- package/dist/conversations/titles.d.ts +12 -3
- package/dist/conversations/titles.js +36 -8
- package/dist/conversations/tree.d.ts +17 -0
- package/dist/conversations/tree.js +42 -0
- package/dist/ctx/create-ctx.d.ts +5 -0
- package/dist/ctx/create-ctx.js +15 -5
- package/dist/db/kernel-schema.d.ts +420 -20
- package/dist/db/pool.d.ts +5 -0
- package/dist/db/pool.js +3 -0
- package/dist/environments/access.d.ts +41 -0
- package/dist/environments/access.js +77 -0
- package/dist/environments/conversation-environments.d.ts +61 -0
- package/dist/environments/conversation-environments.js +170 -0
- package/dist/environments/dto.d.ts +25 -0
- package/dist/environments/dto.js +12 -0
- package/dist/environments/environments.controller.d.ts +33 -0
- package/dist/environments/environments.controller.js +110 -0
- package/dist/environments/environments.module.d.ts +8 -0
- package/dist/environments/environments.module.js +27 -0
- package/dist/environments/environments.service.d.ts +153 -0
- package/dist/environments/environments.service.js +541 -0
- package/dist/environments/legacy-cleanup.job.d.ts +34 -0
- package/dist/environments/legacy-cleanup.job.js +141 -0
- package/dist/errors.d.ts +90 -2
- package/dist/errors.js +90 -2
- package/dist/evals/reconstruct.d.ts +18 -9
- package/dist/evals/reconstruct.js +26 -7
- package/dist/evals/run-replay.d.ts +7 -2
- package/dist/evals/run-replay.js +42 -7
- package/dist/evals/step-replay.d.ts +2 -5
- package/dist/evals/step-replay.js +13 -7
- package/dist/evals/trajectory.js +1 -1
- package/dist/evals/trajectory.service.d.ts +8 -3
- package/dist/evals/trajectory.service.js +26 -14
- package/dist/evals/worker.d.ts +5 -5
- package/dist/evals/worker.js +9 -3
- package/dist/extensions/admin-ops.d.ts +36 -10
- package/dist/extensions/admin-ops.js +67 -42
- package/dist/extensions/admin-view.d.ts +39 -10
- package/dist/extensions/admin-view.js +111 -20
- package/dist/extensions/blobs.js +1 -0
- package/dist/extensions/bootstrap.d.ts +17 -4
- package/dist/extensions/bootstrap.js +70 -9
- package/dist/extensions/cli.d.ts +12 -0
- package/dist/extensions/cli.js +11 -2
- package/dist/extensions/config-issues.d.ts +13 -1
- package/dist/extensions/config-issues.js +22 -5
- package/dist/extensions/config-json-schema.d.ts +43 -7
- package/dist/extensions/config-json-schema.js +124 -58
- package/dist/extensions/deployment-config-store.d.ts +6 -0
- package/dist/extensions/deployment-config.d.ts +78 -8
- package/dist/extensions/deployment-config.js +172 -34
- package/dist/extensions/display-name.d.ts +22 -0
- package/dist/extensions/display-name.js +77 -0
- package/dist/extensions/effective-config.d.ts +127 -0
- package/dist/extensions/effective-config.js +368 -0
- package/dist/extensions/extensions.module.js +14 -2
- package/dist/extensions/hooks.d.ts +37 -4
- package/dist/extensions/hooks.js +82 -16
- package/dist/extensions/host.d.ts +45 -2
- package/dist/extensions/host.js +112 -16
- package/dist/extensions/installs.d.ts +20 -8
- package/dist/extensions/installs.js +37 -15
- package/dist/extensions/org-config.d.ts +81 -6
- package/dist/extensions/org-config.js +195 -44
- package/dist/extensions/org-levels.d.ts +37 -0
- package/dist/extensions/org-levels.js +71 -0
- package/dist/extensions/org-overrides.d.ts +151 -0
- package/dist/extensions/org-overrides.js +524 -0
- package/dist/extensions/package.d.ts +14 -1
- package/dist/extensions/package.js +51 -2
- package/dist/extensions/permission-view.d.ts +19 -4
- package/dist/extensions/permission-view.js +4 -4
- package/dist/extensions/plugin-items.d.ts +21 -0
- package/dist/extensions/plugin-items.js +42 -0
- package/dist/extensions/point-defaults.controller.d.ts +34 -0
- package/dist/extensions/point-defaults.controller.js +71 -0
- package/dist/extensions/point-defaults.d.ts +71 -0
- package/dist/extensions/point-defaults.js +234 -0
- package/dist/extensions/registry.d.ts +1 -1
- package/dist/extensions/registry.js +2 -0
- package/dist/extensions/resolve.d.ts +5 -1
- package/dist/extensions/resolve.js +15 -2
- package/dist/files/previewers.d.ts +8 -1
- package/dist/files/previewers.js +35 -6
- package/dist/http/api.module.js +31 -3
- package/dist/http/app.d.ts +11 -2
- package/dist/http/app.js +31 -5
- package/dist/http/nest-logger.d.ts +6 -5
- package/dist/http/nest-logger.js +24 -10
- package/dist/identity/accounts.d.ts +29 -29
- package/dist/identity/accounts.js +47 -47
- package/dist/identity/audit.d.ts +2 -1
- package/dist/identity/auth.controller.js +9 -5
- package/dist/identity/auth.guard.d.ts +13 -5
- package/dist/identity/auth.guard.js +26 -9
- package/dist/identity/cookies.d.ts +20 -5
- package/dist/identity/cookies.js +44 -6
- package/dist/identity/identity.module.d.ts +1 -1
- package/dist/identity/identity.module.js +4 -4
- package/dist/identity/me.controller.d.ts +5 -1
- package/dist/identity/me.controller.js +12 -3
- package/dist/identity/principal.d.ts +3 -3
- package/dist/identity/principal.js +3 -3
- package/dist/identity/sessions.d.ts +12 -0
- package/dist/identity/sessions.js +45 -0
- package/dist/identity/settings.d.ts +22 -11
- package/dist/identity/settings.js +53 -18
- package/dist/identity/{enterprise-admin.d.ts → super-admin.d.ts} +5 -5
- package/dist/identity/{enterprise-admin.js → super-admin.js} +24 -24
- package/dist/inbox/inbox.module.d.ts +4 -1
- package/dist/inbox/inbox.module.js +7 -3
- package/dist/inbox/inbox.service.d.ts +62 -3
- package/dist/inbox/inbox.service.js +74 -4
- package/dist/inbox/org-notices.d.ts +63 -0
- package/dist/inbox/org-notices.js +91 -0
- package/dist/inbox/platform-inbox.controller.d.ts +23 -0
- package/dist/inbox/platform-inbox.controller.js +58 -0
- package/dist/inbox/platform-inbox.service.d.ts +151 -0
- package/dist/inbox/platform-inbox.service.js +263 -0
- package/dist/inbox/platform-notices.d.ts +19 -0
- package/dist/inbox/platform-notices.js +9 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/infra/cli/kernel-cli.module.js +9 -1
- package/dist/infra/config/kernel-config.service.js +27 -1
- package/dist/infra/database/database.module.js +1 -0
- package/dist/infra/database/xact-lock.d.ts +1 -1
- package/dist/infra/database/xact-lock.js +1 -1
- package/dist/infra/events/kernel-events.d.ts +19 -2
- package/dist/infra/lifecycle/process-guards.js +4 -0
- package/dist/infra/logging/logging.module.d.ts +4 -2
- package/dist/infra/logging/logging.module.js +24 -6
- package/dist/infra/queue/add-job-once.d.ts +14 -0
- package/dist/infra/queue/add-job-once.js +16 -0
- package/dist/infra/queue/redis-connection.d.ts +6 -0
- package/dist/infra/queue/redis-connection.js +7 -0
- package/dist/infra/redis/redis.module.js +6 -2
- package/dist/infra/tokens.d.ts +6 -1
- package/dist/infra/tokens.js +6 -1
- package/dist/kernel.module.js +6 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +1 -1
- package/dist/lifecycle/kernel-lifecycle.js +4 -4
- package/dist/log.d.ts +13 -1
- package/dist/log.js +93 -17
- package/dist/models/prices.d.ts +5 -5
- package/dist/models/prices.js +4 -4
- package/dist/models/purposes.controller.d.ts +6 -4
- package/dist/models/purposes.controller.js +13 -7
- package/dist/models/purposes.d.ts +43 -9
- package/dist/models/purposes.js +48 -18
- package/dist/orgs/directory-sync.d.ts +14 -5
- package/dist/orgs/directory-sync.js +41 -17
- package/dist/orgs/offboarding.d.ts +12 -8
- package/dist/orgs/offboarding.js +54 -33
- package/dist/orgs/org-lock.d.ts +5 -0
- package/dist/orgs/org-lock.js +13 -0
- package/dist/orgs/org.guard.d.ts +10 -0
- package/dist/orgs/org.guard.js +43 -32
- package/dist/orgs/orgs.module.js +3 -0
- package/dist/orgs/orgs.service.d.ts +20 -7
- package/dist/orgs/orgs.service.js +32 -12
- package/dist/orgs/roles.d.ts +1 -1
- package/dist/orgs/roles.js +5 -1
- package/dist/orgs/settings.controller.d.ts +1 -1
- package/dist/orgs/settings.service.d.ts +20 -3
- package/dist/orgs/settings.service.js +19 -4
- package/dist/overrides.d.ts +3 -0
- package/dist/overrides.js +2 -0
- package/dist/platform/actor.d.ts +48 -0
- package/dist/platform/actor.js +100 -0
- package/dist/platform/agent-docs.d.ts +18 -0
- package/dist/platform/agent-docs.js +59 -0
- package/dist/platform/availability.d.ts +14 -0
- package/dist/platform/availability.js +43 -0
- package/dist/platform/errors.d.ts +11 -0
- package/dist/platform/errors.js +26 -0
- package/dist/platform/exclusions.d.ts +12 -0
- package/dist/platform/exclusions.js +1387 -0
- package/dist/platform/method.d.ts +6 -0
- package/dist/platform/method.js +15 -0
- package/dist/platform/operation.d.ts +92 -0
- package/dist/platform/operation.js +35 -0
- package/dist/platform/ops/agent-templates.ops.d.ts +14 -0
- package/dist/platform/ops/agent-templates.ops.js +92 -0
- package/dist/platform/ops/agents.ops.d.ts +19 -0
- package/dist/platform/ops/agents.ops.js +294 -0
- package/dist/platform/ops/connectors.ops.d.ts +15 -0
- package/dist/platform/ops/connectors.ops.js +126 -0
- package/dist/platform/ops/errors.d.ts +11 -0
- package/dist/platform/ops/errors.js +22 -0
- package/dist/platform/ops/extensions.ops.d.ts +19 -0
- package/dist/platform/ops/extensions.ops.js +116 -0
- package/dist/platform/ops/marketplaces.ops.d.ts +16 -0
- package/dist/platform/ops/marketplaces.ops.js +157 -0
- package/dist/platform/ops/paging.d.ts +14 -0
- package/dist/platform/ops/paging.js +20 -0
- package/dist/platform/ops/platform.ops.d.ts +23 -0
- package/dist/platform/ops/platform.ops.js +158 -0
- package/dist/platform/ops/plugins.ops.d.ts +33 -0
- package/dist/platform/ops/plugins.ops.js +377 -0
- package/dist/platform/ops/requests.ops.d.ts +14 -0
- package/dist/platform/ops/requests.ops.js +153 -0
- package/dist/platform/ops/role.d.ts +4 -0
- package/dist/platform/ops/role.js +10 -0
- package/dist/platform/ops/skills.ops.d.ts +13 -0
- package/dist/platform/ops/skills.ops.js +98 -0
- package/dist/platform/ops/summary.d.ts +10 -0
- package/dist/platform/ops/summary.js +18 -0
- package/dist/platform/platform-ops.module.d.ts +7 -0
- package/dist/platform/platform-ops.module.js +55 -0
- package/dist/platform/platform.module.d.ts +8 -0
- package/dist/platform/platform.module.js +25 -0
- package/dist/platform/redact-orgs.d.ts +7 -0
- package/dist/platform/redact-orgs.js +52 -0
- package/dist/platform/registry.d.ts +30 -0
- package/dist/platform/registry.js +111 -0
- package/dist/roles/worker-role.d.ts +6 -4
- package/dist/roles/worker-role.js +14 -7
- package/dist/roles/worker.module.d.ts +1 -1
- package/dist/roles/worker.module.js +15 -1
- package/dist/runtime/context/build.d.ts +11 -7
- package/dist/runtime/context/build.js +46 -19
- package/dist/runtime/context/claude-tools.d.ts +3 -1
- package/dist/runtime/context/claude-tools.js +8 -6
- package/dist/runtime/context/compaction.js +13 -0
- package/dist/runtime/context/reminders.d.ts +2 -0
- package/dist/runtime/context/reminders.js +2 -0
- package/dist/runtime/context/skills.js +9 -2
- package/dist/runtime/context/tool-changes.d.ts +27 -0
- package/dist/runtime/context/tool-changes.js +60 -0
- package/dist/runtime/hook-calls.js +2 -0
- package/dist/runtime/langgraph-loop.d.ts +3 -1
- package/dist/runtime/langgraph-loop.js +36 -17
- package/dist/runtime/loop.d.ts +34 -5
- package/dist/runtime/maintenance.d.ts +9 -4
- package/dist/runtime/maintenance.js +35 -8
- package/dist/runtime/model-call.d.ts +46 -8
- package/dist/runtime/model-call.js +72 -21
- package/dist/runtime/providers.d.ts +6 -0
- package/dist/runtime/providers.js +8 -0
- package/dist/runtime/run-control.d.ts +11 -1
- package/dist/runtime/run-control.js +12 -0
- package/dist/runtime/run-drafts.d.ts +85 -0
- package/dist/runtime/run-drafts.js +230 -0
- package/dist/runtime/run-jobs.d.ts +3 -5
- package/dist/runtime/run-jobs.js +3 -7
- package/dist/runtime/run-queue.d.ts +59 -2
- package/dist/runtime/run-queue.js +311 -38
- package/dist/runtime/run-worker.d.ts +11 -5
- package/dist/runtime/run-worker.js +69 -33
- package/dist/runtime/runtime.module.js +11 -3
- package/dist/runtime/step-log.d.ts +15 -4
- package/dist/runtime/step-log.js +24 -7
- package/dist/runtime/stream.controller.d.ts +23 -1
- package/dist/runtime/stream.controller.js +60 -3
- package/dist/runtime/stream.d.ts +4 -1
- package/dist/runtime/stream.js +27 -3
- package/dist/runtime/subagents/child.d.ts +55 -7
- package/dist/runtime/subagents/child.js +105 -7
- package/dist/runtime/subagents/definition.d.ts +12 -3
- package/dist/runtime/subagents/definition.js +44 -28
- package/dist/runtime/subagents/deliveries.d.ts +71 -0
- package/dist/runtime/subagents/deliveries.js +228 -0
- package/dist/runtime/subagents/dispatch.d.ts +115 -26
- package/dist/runtime/subagents/dispatch.js +212 -141
- package/dist/runtime/subagents/limits.d.ts +24 -5
- package/dist/runtime/subagents/limits.js +40 -6
- package/dist/runtime/subagents/messages.d.ts +95 -0
- package/dist/runtime/subagents/messages.js +328 -0
- package/dist/runtime/subagents/preamble.d.ts +4 -4
- package/dist/runtime/subagents/preamble.js +9 -7
- package/dist/runtime/subagents/progress.d.ts +8 -6
- package/dist/runtime/subagents/progress.js +11 -6
- package/dist/runtime/subagents/render.d.ts +30 -0
- package/dist/runtime/subagents/render.js +53 -0
- package/dist/runtime/subagents/roster.d.ts +24 -7
- package/dist/runtime/subagents/roster.js +47 -11
- package/dist/runtime/subagents/skill-fork.d.ts +3 -2
- package/dist/runtime/subagents/skill-fork.js +8 -4
- package/dist/runtime/subagents/status.d.ts +14 -0
- package/dist/runtime/subagents/status.js +23 -0
- package/dist/runtime/subagents/subagents.service.d.ts +7 -4
- package/dist/runtime/subagents/subagents.service.js +11 -6
- package/dist/runtime/usage-report.d.ts +2 -1
- package/dist/runtime/usage-report.js +19 -13
- package/dist/runtime/waits.d.ts +145 -36
- package/dist/runtime/waits.js +423 -109
- package/dist/sandbox/jobs.d.ts +40 -13
- package/dist/sandbox/jobs.js +57 -20
- package/dist/sandbox/leases.d.ts +37 -54
- package/dist/sandbox/leases.js +71 -115
- package/dist/sandbox/providers.d.ts +2 -2
- package/dist/sandbox/providers.js +1 -1
- package/dist/sandbox/sandbox.module.d.ts +3 -2
- package/dist/sandbox/sandbox.module.js +10 -4
- package/dist/sandbox/sandbox.service.d.ts +282 -129
- package/dist/sandbox/sandbox.service.js +736 -381
- package/dist/skills/catalog.d.ts +3 -2
- package/dist/skills/catalog.js +21 -43
- package/dist/skills/changes.controller.d.ts +7 -0
- package/dist/skills/changes.controller.js +19 -1
- package/dist/skills/invoke.js +8 -3
- package/dist/skills/package.d.ts +20 -1
- package/dist/skills/package.js +28 -1
- package/dist/skills/skills.controller.d.ts +39 -4
- package/dist/skills/skills.controller.js +88 -10
- package/dist/skills/skills.module.js +10 -1
- package/dist/skills/skills.service.d.ts +106 -26
- package/dist/skills/skills.service.js +421 -75
- package/dist/skills/usable.d.ts +81 -0
- package/dist/skills/usable.js +379 -0
- package/dist/tools/approvals.service.d.ts +20 -2
- package/dist/tools/approvals.service.js +25 -4
- package/dist/tools/builtin-names.d.ts +41 -7
- package/dist/tools/builtin-names.js +59 -7
- package/dist/tools/builtins/agent.d.ts +23 -21
- package/dist/tools/builtins/agent.js +62 -55
- package/dist/tools/builtins/builtin-tools.d.ts +19 -1
- package/dist/tools/builtins/builtin-tools.js +59 -2
- package/dist/tools/builtins/handback.d.ts +28 -0
- package/dist/tools/builtins/handback.js +53 -0
- package/dist/tools/builtins/platform.d.ts +34 -0
- package/dist/tools/builtins/platform.js +362 -0
- package/dist/tools/builtins/sandbox/bash.d.ts +1 -1
- package/dist/tools/builtins/sandbox/bash.js +241 -4
- package/dist/tools/builtins/sandbox/common.d.ts +69 -27
- package/dist/tools/builtins/sandbox/common.js +87 -48
- package/dist/tools/builtins/sandbox/deliver.js +1 -1
- package/dist/tools/builtins/sandbox/edit.js +2 -2
- package/dist/tools/builtins/sandbox/glob.js +2 -2
- package/dist/tools/builtins/sandbox/grep.js +2 -4
- package/dist/tools/builtins/sandbox/index.d.ts +3 -1
- package/dist/tools/builtins/sandbox/index.js +7 -1
- package/dist/tools/builtins/sandbox/read.js +1 -1
- package/dist/tools/builtins/sandbox/task-output.d.ts +74 -0
- package/dist/tools/builtins/sandbox/task-output.js +329 -0
- package/dist/tools/builtins/sandbox/task-stop.d.ts +10 -0
- package/dist/tools/builtins/sandbox/task-stop.js +113 -0
- package/dist/tools/builtins/sandbox/write.js +2 -2
- package/dist/tools/builtins/send-message.d.ts +56 -0
- package/dist/tools/builtins/send-message.js +100 -0
- package/dist/tools/builtins/skill-load.d.ts +22 -14
- package/dist/tools/builtins/skill-load.js +86 -57
- package/dist/tools/builtins/skill-write.js +1 -1
- package/dist/tools/builtins/web/errors.d.ts +8 -0
- package/dist/tools/builtins/web/errors.js +53 -0
- package/dist/tools/builtins/web/extract.d.ts +62 -0
- package/dist/tools/builtins/web/extract.js +271 -0
- package/dist/tools/builtins/web/fetch.d.ts +55 -0
- package/dist/tools/builtins/web/fetch.js +175 -0
- package/dist/tools/builtins/web/index.d.ts +13 -0
- package/dist/tools/builtins/web/index.js +12 -0
- package/dist/tools/builtins/web/page-cache.d.ts +25 -0
- package/dist/tools/builtins/web/page-cache.js +77 -0
- package/dist/tools/builtins/web/search.d.ts +25 -0
- package/dist/tools/builtins/web/search.js +210 -0
- package/dist/tools/builtins/web/url.d.ts +17 -0
- package/dist/tools/builtins/web/url.js +43 -0
- package/dist/tools/connectors.controller.d.ts +10 -0
- package/dist/tools/connectors.controller.js +12 -0
- package/dist/tools/connectors.service.d.ts +46 -5
- package/dist/tools/connectors.service.js +94 -15
- package/dist/tools/extension-tools.controller.d.ts +14 -0
- package/dist/tools/extension-tools.controller.js +37 -0
- package/dist/tools/info.d.ts +42 -1
- package/dist/tools/info.js +64 -1
- package/dist/tools/oauth/flow-paths.d.ts +1 -1
- package/dist/tools/oauth/flow-paths.js +1 -1
- package/dist/tools/org-tool-switches.d.ts +74 -0
- package/dist/tools/org-tool-switches.js +184 -0
- package/dist/tools/pipeline.d.ts +46 -40
- package/dist/tools/pipeline.js +202 -364
- package/dist/tools/policy.d.ts +1 -1
- package/dist/tools/policy.js +36 -16
- package/dist/tools/registry.d.ts +120 -8
- package/dist/tools/registry.js +112 -19
- package/dist/tools/tools.module.js +24 -2
- package/dist/tools/validate.js +1 -1
- package/dist/ui/views.d.ts +2 -1
- package/dist/ui/views.js +17 -3
- package/package.json +3 -3
- package/src/migrations/0064_account_last_org.sql +7 -0
- package/src/migrations/0065_conversation_archive.sql +8 -0
- package/src/migrations/0066_extension_display_name.sql +4 -0
- package/src/migrations/0067_agent_profiles.sql +20 -0
- package/src/migrations/0068_agent_avatar_uploads.sql +7 -0
- package/src/migrations/0069_attachments_agent_idx.sql +3 -0
- package/src/migrations/0070_background_tasks.sql +37 -0
- package/src/migrations/0071_background_tasks_reserve.sql +6 -0
- package/src/migrations/0072_background_tasks_stopping.sql +5 -0
- package/src/migrations/0073_org_extension_point_defaults.sql +11 -0
- package/src/migrations/0074_subagent_tree.sql +50 -0
- package/src/migrations/0075_plugin_scope.sql +61 -0
- package/src/migrations/0076_skills_created_by_nullable.sql +6 -0
- package/src/migrations/0077_scope_requests.sql +52 -0
- package/src/migrations/0078_scope_grant_switches.sql +18 -0
- package/src/migrations/0079_scope_live_install_switches.sql +19 -0
- package/src/migrations/0080_rename_enterprise_admin.sql +18 -0
- package/src/migrations/0081_platform_components.sql +129 -0
- package/src/migrations/0082_platform_migration.sql +33 -0
- package/src/migrations/0083_plugin_scope_sync_failures.sql +15 -0
- package/src/migrations/0084_org_owned_items.sql +85 -0
- package/src/migrations/0085_agent_templates_phase4.sql +45 -0
- package/src/migrations/0086_org_layering.sql +30 -0
- package/src/migrations/0087_approval_summary.sql +6 -0
- package/src/migrations/0088_environments.sql +80 -0
- package/dist/catalog/upgrade-targets.d.ts +0 -56
- package/dist/catalog/upgrade-targets.js +0 -90
- package/dist/conversations/sandbox-status.d.ts +0 -24
- package/dist/conversations/sandbox-status.js +0 -52
- package/dist/extensions/org-config.controller.d.ts +0 -24
- package/dist/extensions/org-config.controller.js +0 -62
package/dist/extensions/hooks.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { HOOKS_AVAILABLE, POLICY_HOOKS, } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { NEEDS_CONFIG_REASON } from "./effective-config.js";
|
|
2
3
|
import { ExtensionUnloadedError } from "./inflight.js";
|
|
3
4
|
/** Default of `hooks.timeoutMs` (used when a host is built without kernel config, e.g. in tests). */
|
|
4
5
|
export const DEFAULT_HOOK_TIMEOUT_MS = 5000;
|
|
@@ -13,6 +14,18 @@ export const OBSERVE_INFLIGHT_MAX = 64;
|
|
|
13
14
|
export const EMPTY_DENY_REASON = "(no reason given)";
|
|
14
15
|
/** Warnings about a plugin's hooks are logged at most once per plugin, mount and kind in this window. */
|
|
15
16
|
const WARN_WINDOW_MS = 60_000;
|
|
17
|
+
/**
|
|
18
|
+
* Thrown by a `usage.report` handler wrapper (see {@link HookRegistry.handlers}) instead of calling
|
|
19
|
+
* a handler whose extension's effective config is not valid in the payload's organization.
|
|
20
|
+
*/
|
|
21
|
+
export class HookNeedsConfigError extends Error {
|
|
22
|
+
plugin;
|
|
23
|
+
constructor(plugin) {
|
|
24
|
+
super(`extension ${plugin} ${NEEDS_CONFIG_REASON}`);
|
|
25
|
+
this.plugin = plugin;
|
|
26
|
+
this.name = "HookNeedsConfigError";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
16
29
|
const AVAILABLE = new Set(HOOKS_AVAILABLE);
|
|
17
30
|
const POLICY = new Set(POLICY_HOOKS);
|
|
18
31
|
/** Error text that never throws itself (a hostile `message` getter or `toString`). */
|
|
@@ -110,7 +123,12 @@ const clipDetail = (s) => clipText(s, HOOK_DETAIL_MAX_CHARS);
|
|
|
110
123
|
* If a plugin the organization enabled is expected to run policy hooks on the mount (deployment
|
|
111
124
|
* state, `expectedPolicy`) but is not loaded on this replica, deny with a generic reason
|
|
112
125
|
* (`hook_error`, `notLoaded`) without running any policy hook (M-1: fail closed). Observe hooks
|
|
113
|
-
* of plugins that are not loaded are simply missing.
|
|
126
|
+
* of plugins that are not loaded are simply missing. Then each enabled plugin with a hook on the
|
|
127
|
+
* mount gets its effective config for the organization (layering spec A §6; one read per plugin
|
|
128
|
+
* and call, failing like the lookup above). A plugin whose config is not valid behaves as one
|
|
129
|
+
* that is not loaded: with a policy hook on the mount the call is denied (`hook_error`,
|
|
130
|
+
* `needsConfig`) without running any policy hook, and its observe hooks are skipped. Every
|
|
131
|
+
* hook is called with `{ config }` as its third argument.
|
|
114
132
|
* 3. Policy hooks run serially by plugin name (registration order within a plugin), each limited
|
|
115
133
|
* by `hooks.timeoutMs` (read on every run, hot). `{ deny }`, an error or a timeout stops the chain
|
|
116
134
|
* and denies (`deny` / `hook_error` / `timeout`). A policy hook cut off by its instance being
|
|
@@ -156,13 +174,18 @@ export class HookRegistry {
|
|
|
156
174
|
}
|
|
157
175
|
/**
|
|
158
176
|
* `usage.report` handlers by plugin name (delivered by the usage queue, not by {@link run}); each
|
|
159
|
-
* call runs through the instance's `inflight.run
|
|
177
|
+
* call runs through the instance's `inflight.run` with the plugin's effective config for the
|
|
178
|
+
* payload's organization, and throws {@link HookNeedsConfigError} without calling the handler
|
|
179
|
+
* when that config is not valid (layering spec A §6).
|
|
160
180
|
*/
|
|
161
181
|
handlers(mount) {
|
|
162
182
|
return this.entries(mount).map(({ src, hook }) => ({
|
|
163
183
|
plugin: src.name,
|
|
164
184
|
handler: (payload, signal) => src.inflight.run(signal, async (s) => {
|
|
165
|
-
await
|
|
185
|
+
const effective = await this.d.effectiveConfig(payload.orgId, src.name);
|
|
186
|
+
if (!effective.ok)
|
|
187
|
+
throw new HookNeedsConfigError(src.name);
|
|
188
|
+
await hook.handler(payload, s, { config: effective.config });
|
|
166
189
|
}),
|
|
167
190
|
}));
|
|
168
191
|
}
|
|
@@ -177,6 +200,8 @@ export class HookRegistry {
|
|
|
177
200
|
let enabled;
|
|
178
201
|
let frozen;
|
|
179
202
|
let missing;
|
|
203
|
+
/** Effective config per enabled plugin with a hook here; null = not valid in the org. */
|
|
204
|
+
const configs = new Map();
|
|
180
205
|
try {
|
|
181
206
|
const abort = abortOf(signal);
|
|
182
207
|
try {
|
|
@@ -194,6 +219,19 @@ export class HookRegistry {
|
|
|
194
219
|
}
|
|
195
220
|
if (!all.some((e) => enabled.has(e.src.name)))
|
|
196
221
|
return { allowed: true };
|
|
222
|
+
for (const name of new Set(all.map((e) => e.src.name).filter((n) => enabled.has(n)))) {
|
|
223
|
+
const abortCfg = abortOf(signal);
|
|
224
|
+
try {
|
|
225
|
+
const e = await Promise.race([
|
|
226
|
+
this.d.effectiveConfig(payload.orgId, name),
|
|
227
|
+
abortCfg.aborted,
|
|
228
|
+
]);
|
|
229
|
+
configs.set(name, e.ok ? { config: e.config } : null);
|
|
230
|
+
}
|
|
231
|
+
finally {
|
|
232
|
+
abortCfg.cleanup();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
197
235
|
// Cost: one clone + deep-freeze per call. The model.request payload carries no media bytes
|
|
198
236
|
// (hookRequestOf, I-3), so it stays small. Freezing in place would freeze the logged object.
|
|
199
237
|
// The clone is skipped when has() is false or no enabled plugin has a hook on this mount.
|
|
@@ -207,7 +245,7 @@ export class HookRegistry {
|
|
|
207
245
|
if (firstPolicy !== undefined) {
|
|
208
246
|
// R10: no plugin ran; the named plugin is only the first policy plugin on this mount, so
|
|
209
247
|
// the detail says so instead of blaming it
|
|
210
|
-
const detail = clipDetail(`Hooks could not run (organization lookup or payload copy failed) before any plugin was called; ${firstPolicy} is named only as the first policy plugin on ${mount}: ${raw}`);
|
|
248
|
+
const detail = clipDetail(`Hooks could not run (organization lookup, config read or payload copy failed) before any plugin was called; ${firstPolicy} is named only as the first policy plugin on ${mount}: ${raw}`);
|
|
211
249
|
this.d.log.warn("plugin hooks could not run; denying the call", {
|
|
212
250
|
mount,
|
|
213
251
|
firstPolicyPlugin: firstPolicy,
|
|
@@ -227,9 +265,19 @@ export class HookRegistry {
|
|
|
227
265
|
}
|
|
228
266
|
return { allowed: true };
|
|
229
267
|
}
|
|
230
|
-
const active = all.filter((e) => enabled.has(e.src.name));
|
|
268
|
+
const active = all.filter((e) => enabled.has(e.src.name) && configs.get(e.src.name));
|
|
231
269
|
const timeoutMs = this.d.config().hooks.timeoutMs;
|
|
232
|
-
|
|
270
|
+
// spec A §6: a policy plugin without a valid config in the org behaves as one not loaded
|
|
271
|
+
const needy = [
|
|
272
|
+
...new Set(all
|
|
273
|
+
.filter((e) => e.hook.mode === "policy" && configs.get(e.src.name) === null)
|
|
274
|
+
.map((e) => e.src.name)),
|
|
275
|
+
];
|
|
276
|
+
let outcome = missing.length > 0
|
|
277
|
+
? this.notLoadedDenial(mount, missing)
|
|
278
|
+
: needy.length > 0
|
|
279
|
+
? this.needsConfigDenial(mount, needy)
|
|
280
|
+
: { allowed: true };
|
|
233
281
|
// policy hooks grouped per plugin (entries are sorted, so groups are contiguous)
|
|
234
282
|
const groups = [];
|
|
235
283
|
for (const e of active) {
|
|
@@ -242,7 +290,8 @@ export class HookRegistry {
|
|
|
242
290
|
groups.push({ src: e.src, hooks: [e.hook] });
|
|
243
291
|
}
|
|
244
292
|
for (const g of outcome.allowed ? groups : []) {
|
|
245
|
-
const
|
|
293
|
+
const call = configs.get(g.src.name);
|
|
294
|
+
const denied = await this.runPolicies(mount, g.src, g.hooks, frozen, call, signal, timeoutMs);
|
|
246
295
|
if (denied) {
|
|
247
296
|
outcome = denied;
|
|
248
297
|
break;
|
|
@@ -251,8 +300,10 @@ export class HookRegistry {
|
|
|
251
300
|
// observe hooks are resolved again now: if the plugin was upgraded while the policy hooks ran,
|
|
252
301
|
// the current generation observes (the retiring one no longer accepts calls)
|
|
253
302
|
for (const e of this.entries(mount)) {
|
|
254
|
-
|
|
255
|
-
|
|
303
|
+
const call = configs.get(e.src.name);
|
|
304
|
+
// no config read for it (not valid in the org, or a plugin that appeared meanwhile): skipped
|
|
305
|
+
if (e.hook.mode === "observe" && enabled.has(e.src.name) && call) {
|
|
306
|
+
this.dispatchObserve(mount, e.src, e.hook, frozen, call, signal);
|
|
256
307
|
}
|
|
257
308
|
}
|
|
258
309
|
return outcome;
|
|
@@ -277,6 +328,21 @@ export class HookRegistry {
|
|
|
277
328
|
notLoaded: true,
|
|
278
329
|
};
|
|
279
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* The layering spec A §6 denial: `needy` (sorted) are enabled policy plugins whose effective
|
|
333
|
+
* config is not valid in the organization. Generic model-visible reason, as for M-1.
|
|
334
|
+
*/
|
|
335
|
+
needsConfigDenial(mount, needy) {
|
|
336
|
+
const plugin = needy[0];
|
|
337
|
+
return {
|
|
338
|
+
allowed: false,
|
|
339
|
+
plugin,
|
|
340
|
+
reason: unavailableReason(plugin),
|
|
341
|
+
cause: "hook_error",
|
|
342
|
+
detail: `extension ${needy.join(", ")} declares a policy hook on ${mount} but ${NEEDS_CONFIG_REASON}; the call was denied without running any policy hook`,
|
|
343
|
+
needsConfig: true,
|
|
344
|
+
};
|
|
345
|
+
}
|
|
280
346
|
/** Active entries of a mount point, sorted by plugin name (stable: registration order within). */
|
|
281
347
|
entries(mount) {
|
|
282
348
|
return this.d
|
|
@@ -285,14 +351,14 @@ export class HookRegistry {
|
|
|
285
351
|
.sort((a, b) => (a.src.name < b.src.name ? -1 : a.src.name > b.src.name ? 1 : 0));
|
|
286
352
|
}
|
|
287
353
|
/** One plugin's policy hooks in registration order; reruns once on a newer generation if revoked. */
|
|
288
|
-
async runPolicies(mount, src, hooks, payload, signal, timeoutMs, rerun = false) {
|
|
354
|
+
async runPolicies(mount, src, hooks, payload, call, signal, timeoutMs, rerun = false) {
|
|
289
355
|
const plugin = src.name;
|
|
290
356
|
for (const hook of hooks) {
|
|
291
357
|
if (signal.aborted)
|
|
292
358
|
throw signal.reason;
|
|
293
359
|
let r;
|
|
294
360
|
try {
|
|
295
|
-
r = await src.inflight.run(signal, (s) => this.call(hook, payload, s, timeoutMs));
|
|
361
|
+
r = await src.inflight.run(signal, (s) => this.call(hook, payload, call, s, timeoutMs));
|
|
296
362
|
}
|
|
297
363
|
catch (err) {
|
|
298
364
|
if (signal.aborted)
|
|
@@ -301,7 +367,7 @@ export class HookRegistry {
|
|
|
301
367
|
const cur = this.d.current(plugin);
|
|
302
368
|
if (!rerun && cur && cur !== src) {
|
|
303
369
|
const again = cur.hooks.filter((h) => h.mount === mount && h.mode === "policy");
|
|
304
|
-
return this.runPolicies(mount, cur, again, payload, signal, timeoutMs, true);
|
|
370
|
+
return this.runPolicies(mount, cur, again, payload, call, signal, timeoutMs, true);
|
|
305
371
|
}
|
|
306
372
|
}
|
|
307
373
|
r = { kind: "error", message: errMsg(err) };
|
|
@@ -338,7 +404,7 @@ export class HookRegistry {
|
|
|
338
404
|
return undefined;
|
|
339
405
|
}
|
|
340
406
|
/** Fire-and-forget observe call through the instance's in-flight tracker, capped per plugin. */
|
|
341
|
-
dispatchObserve(mount, src, hook, payload, signal) {
|
|
407
|
+
dispatchObserve(mount, src, hook, payload, call, signal) {
|
|
342
408
|
const plugin = src.name;
|
|
343
409
|
const n = this.observing.get(plugin) ?? 0;
|
|
344
410
|
if (n >= OBSERVE_INFLIGHT_MAX) {
|
|
@@ -349,7 +415,7 @@ export class HookRegistry {
|
|
|
349
415
|
this.observing.set(plugin, n + 1);
|
|
350
416
|
void (async () => {
|
|
351
417
|
try {
|
|
352
|
-
const r = await src.inflight.run(signal, (s) => this.call(hook, payload, s, timeoutMs));
|
|
418
|
+
const r = await src.inflight.run(signal, (s) => this.call(hook, payload, call, s, timeoutMs));
|
|
353
419
|
if (r.kind === "error" || r.kind === "timeout") {
|
|
354
420
|
await this.warnOnce(plugin, mount, "failed", "plugin observe hook failed; the call continued", r.kind === "timeout" ? `timed out after ${timeoutMs} ms` : r.message);
|
|
355
421
|
}
|
|
@@ -371,7 +437,7 @@ export class HookRegistry {
|
|
|
371
437
|
* Calls one handler with its own signal (aborted on timeout or when `s` aborts). Rejects with
|
|
372
438
|
* `s.reason` when `s` aborts first, so callers can tell an abort from a hook failure.
|
|
373
439
|
*/
|
|
374
|
-
async call(hook, payload, s, timeoutMs) {
|
|
440
|
+
async call(hook, payload, call, s, timeoutMs) {
|
|
375
441
|
const ac = new AbortController();
|
|
376
442
|
const onAbort = () => ac.abort(s.reason);
|
|
377
443
|
if (s.aborted)
|
|
@@ -385,7 +451,7 @@ export class HookRegistry {
|
|
|
385
451
|
timer = setTimeout(() => resolve("timeout"), timeoutMs);
|
|
386
452
|
});
|
|
387
453
|
const handled = Promise.resolve()
|
|
388
|
-
.then(() => hook.handler(payload, ac.signal))
|
|
454
|
+
.then(() => hook.handler(payload, ac.signal, { config: call.config }))
|
|
389
455
|
.then((v) => ({ v }), (err) => ({ err }));
|
|
390
456
|
const result = await Promise.race([handled, timedOut, abort.aborted]);
|
|
391
457
|
if (result === "timeout") {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ExtensionManifest, type ExtensionPointRef, type ToolHandler, type ToolSpec, type UiContribution } from "@capybara-hq/plugin-sdk";
|
|
1
|
+
import { type ExtensionManifest, type ExtensionPointRef, type LocalizedName, type ToolHandler, type ToolSpec, type UiContribution } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import type { Redis } from "ioredis";
|
|
3
3
|
import type { core } from "zod";
|
|
4
4
|
import type { KernelAppOptions } from "../app.js";
|
|
@@ -13,6 +13,7 @@ import type { KernelLogger } from "../log.js";
|
|
|
13
13
|
import { EmbedTokens } from "../ui/embed-token.js";
|
|
14
14
|
import type { UiActionHandler, UiRender } from "../ui/registry.js";
|
|
15
15
|
import { ExtensionApprovals, type PendingExtension } from "./approvals.js";
|
|
16
|
+
import { EffectiveConfigs } from "./effective-config.js";
|
|
16
17
|
import { HookRegistry } from "./hooks.js";
|
|
17
18
|
import type { InflightTracker } from "./inflight.js";
|
|
18
19
|
import { type DesiredExtension, ExtensionInstalls } from "./installs.js";
|
|
@@ -46,6 +47,8 @@ export interface InspectedExtension {
|
|
|
46
47
|
dir: string;
|
|
47
48
|
/** 规范化的权限集合,见 {@link computePermissionSet}。 */
|
|
48
49
|
permissions: PermissionSet;
|
|
50
|
+
/** The plugin.json `displayName` of the module's plugin directory, if any. */
|
|
51
|
+
displayName: LocalizedName | null;
|
|
49
52
|
}
|
|
50
53
|
/**
|
|
51
54
|
* 插件两级配置 schema 中的每个 `secret()` 都必须标在对象路径的字段上(见 `unreachableSecrets`),
|
|
@@ -84,6 +87,8 @@ export interface DeclaredExtensionInfo {
|
|
|
84
87
|
configurable: boolean;
|
|
85
88
|
/** 启动配置里的部署配置按 schema 校验通过(没有 schema 时恒为 true)。 */
|
|
86
89
|
configValid: boolean;
|
|
90
|
+
/** The plugin.json `displayName` of the module's plugin directory, if any. */
|
|
91
|
+
displayName: LocalizedName | null;
|
|
87
92
|
}
|
|
88
93
|
/** The extension sources of {@link ExtensionHost.load}, loaded in this order (see {@link ExtensionSource}). */
|
|
89
94
|
export interface ExtensionLoadPlan {
|
|
@@ -108,6 +113,11 @@ export declare class ExtensionHost {
|
|
|
108
113
|
private readonly status;
|
|
109
114
|
private readonly config;
|
|
110
115
|
private readonly log;
|
|
116
|
+
/**
|
|
117
|
+
* Each hook call's effective config for its organization, and the providers excluded from an
|
|
118
|
+
* org's point resolution (layering spec A §6).
|
|
119
|
+
*/
|
|
120
|
+
private readonly effective;
|
|
111
121
|
/**
|
|
112
122
|
* Only resolves extensions and runs migrations in dependency order: no deployment config check, no
|
|
113
123
|
* setup, no Redis (for `capybara migrate`). Like `load()` it checks secret markers first
|
|
@@ -191,6 +201,11 @@ export declare class ExtensionHost {
|
|
|
191
201
|
private readonly retiring;
|
|
192
202
|
/** 配置声明插件的清单与权限集合(含未加载的;后台列表与网页批准用)。 */
|
|
193
203
|
private readonly declaredInfo;
|
|
204
|
+
/**
|
|
205
|
+
* Config-declared extensions' display names, read from their plugin directory's plugin.json at
|
|
206
|
+
* load (from the startup config, the same on every replica; never written elsewhere).
|
|
207
|
+
*/
|
|
208
|
+
private readonly declaredDisplayNames;
|
|
194
209
|
/** 导入过的插件名 → 来源与包(含未加载的;重名被跳过的一方不在这里)。 */
|
|
195
210
|
private readonly sources;
|
|
196
211
|
private didLoad;
|
|
@@ -210,6 +225,8 @@ export declare class ExtensionHost {
|
|
|
210
225
|
private readonly configValidity;
|
|
211
226
|
/** 已告警过的「部署配置不合法」(插件名 → 说明;每个周期都会重新判定,同一说明只告警一次)。 */
|
|
212
227
|
private readonly configWarned;
|
|
228
|
+
/** `<name>@<version>` whose invalid config UI hints were warned about (a log dedupe only). */
|
|
229
|
+
private readonly configUiWarned;
|
|
213
230
|
/**
|
|
214
231
|
* The host builds each extension's `ctx` from the injected kernel services: the pool for
|
|
215
232
|
* `ctx.db` on the extension's schema, Redis for `kv` / `lock` / `bus` and the queues, the
|
|
@@ -233,7 +250,12 @@ export declare class ExtensionHost {
|
|
|
233
250
|
*/
|
|
234
251
|
installs: ExtensionInstalls, approvals: ExtensionApprovals,
|
|
235
252
|
/** This replica's load status table (`extension_replica_status`): every load result writes a row. */
|
|
236
|
-
status: ReplicaStatusStore, config: KernelConfigService, kdb: KernelDb, redis: Redis, busSubscriber: BusSubscriber, keyring: Keyring, embedTokens: EmbedTokens, locks: LockService, log: KernelLogger, options: Pick<KernelAppOptions, "resolveFrom"
|
|
253
|
+
status: ReplicaStatusStore, config: KernelConfigService, kdb: KernelDb, redis: Redis, busSubscriber: BusSubscriber, keyring: Keyring, embedTokens: EmbedTokens, locks: LockService, log: KernelLogger, options: Pick<KernelAppOptions, "resolveFrom">,
|
|
254
|
+
/**
|
|
255
|
+
* Each hook call's effective config for its organization, and the providers excluded from an
|
|
256
|
+
* org's point resolution (layering spec A §6).
|
|
257
|
+
*/
|
|
258
|
+
effective: Pick<EffectiveConfigs, "get">);
|
|
237
259
|
/** The startup config's `extensionConfig` (file / Nacos merged with env). */
|
|
238
260
|
private get extensionConfig();
|
|
239
261
|
/** `extensionPermissions.autoApprove` (development and trials only; see `planApprovals`). */
|
|
@@ -290,6 +312,11 @@ export declare class ExtensionHost {
|
|
|
290
312
|
* `plugin host closed during load` at the next checkpoint.
|
|
291
313
|
*/
|
|
292
314
|
load(plan: string[] | ExtensionLoadPlan): Promise<void>;
|
|
315
|
+
/**
|
|
316
|
+
* Records each config-declared extension's display name from its plugin directory's plugin.json
|
|
317
|
+
* (spec §2.2); an invalid plugin.json only warns (no display name).
|
|
318
|
+
*/
|
|
319
|
+
private noteDisplayNames;
|
|
293
320
|
/**
|
|
294
321
|
* Config-declared extensions also take their name (I4, an addition to Ruling P3): the
|
|
295
322
|
* name is inserted into `extension_name_owners` with its npm package name (left alone when present).
|
|
@@ -356,6 +383,15 @@ export declare class ExtensionHost {
|
|
|
356
383
|
* - 缺的能力没有任何提供方 → 与此前一样抛错(内核启动失败)。
|
|
357
384
|
*/
|
|
358
385
|
private loadDeferred;
|
|
386
|
+
/**
|
|
387
|
+
* Checks the config UI hints of a loaded module's deployment and org schemas (spec §4.1). Invalid
|
|
388
|
+
* hints never fail the load: the form schemas drop their `x-ui` (`configFormSchema`), one warning
|
|
389
|
+
* per `<name>@<version>` is logged, and the returned text goes into the status detail (null when
|
|
390
|
+
* every hint is valid). The packer refuses such a package; this covers hand-made ones. It never
|
|
391
|
+
* throws (it runs after the instance is active, before its status row is written): a conversion
|
|
392
|
+
* that throws is warned about and reported in the detail the same way.
|
|
393
|
+
*/
|
|
394
|
+
private checkConfigUi;
|
|
359
395
|
/** 给已有状态行补说明;失败只记 warn。 */
|
|
360
396
|
private noteStatus;
|
|
361
397
|
/**
|
|
@@ -464,6 +500,13 @@ export declare class ExtensionHost {
|
|
|
464
500
|
* (如 `identity-source@1` 的登录配置);未加载返回 undefined。不得回显到响应或日志。
|
|
465
501
|
*/
|
|
466
502
|
deploymentConfig(plugin: string): unknown;
|
|
503
|
+
/**
|
|
504
|
+
* The raw (unparsed) deployment config of a running extension: the startup config merged with
|
|
505
|
+
* the PG values, as the host reads it before parsing (secrets included; never echo it). An org
|
|
506
|
+
* copy is applied to this and parsed once (layering spec A §6), so schema transforms are not
|
|
507
|
+
* run twice. Without a running instance, the stored values without a schema.
|
|
508
|
+
*/
|
|
509
|
+
rawDeploymentConfig(plugin: string): Promise<unknown>;
|
|
467
510
|
/**
|
|
468
511
|
* 本副本拿得到的插件清单里的部署级 schema(生效实例 → 配置声明 → 安装记录准备好的候选);
|
|
469
512
|
* 都没有返回 undefined(如未加载的安装记录:调用方改用包内静态清单)。
|
package/dist/extensions/host.js
CHANGED
|
@@ -30,10 +30,13 @@ import { EmbedTokens } from "../ui/embed-token.js";
|
|
|
30
30
|
import { ExtensionApprovals, planApprovals, readSnapshots, withPreApproved, } from "./approvals.js";
|
|
31
31
|
import { ExtensionBlobIntegrityError } from "./blobs.js";
|
|
32
32
|
import { toIssues } from "./config-issues.js";
|
|
33
|
+
import { configFormSchema, describeConfigUiProblems } from "./config-json-schema.js";
|
|
34
|
+
import { EffectiveConfigs } from "./effective-config.js";
|
|
33
35
|
import { HookRegistry } from "./hooks.js";
|
|
34
36
|
import { ExtensionInstalls } from "./installs.js";
|
|
35
37
|
import { ImportTracker, importExtensionModule, ManifestMismatchError, matchesSection, setupInstance, warnUpgrades, } from "./instance.js";
|
|
36
|
-
import {
|
|
38
|
+
import { parseLoadGate } from "./org-levels.js";
|
|
39
|
+
import { declaredDisplayName, permissionSetOfSection, readMigrationSql } from "./package.js";
|
|
37
40
|
import { blockingKeys, computePermissionSet, UI_VIEW_KEY_PREFIX, } from "./permission-set.js";
|
|
38
41
|
import { ExtensionRegistry } from "./registry.js";
|
|
39
42
|
import { ExtensionResolveError, resolveExtensions } from "./resolve.js";
|
|
@@ -171,7 +174,7 @@ function warnPending(log, p) {
|
|
|
171
174
|
: "extension not loaded: a required extension point is only provided by extensions awaiting permission approval", { plugin: p.plugin, version: p.version, blockedBy: p.blockedBy });
|
|
172
175
|
return;
|
|
173
176
|
}
|
|
174
|
-
log.warn("extension not loaded: permissions awaiting approval (
|
|
177
|
+
log.warn("extension not loaded: permissions awaiting approval (a super admin approves it in the admin console, or run `capybara extensions review`, then `capybara extensions approve <name>`; running replicas load it without a restart)", { plugin: p.plugin, version: p.version, reason: p.reason, added: p.added, removed: p.removed });
|
|
175
178
|
}
|
|
176
179
|
/**
|
|
177
180
|
* 跑单个插件的迁移(`migrationsDir` 为迁移目录的绝对路径;没有迁移时为 undefined);返回已应用的文件,
|
|
@@ -234,6 +237,7 @@ let ExtensionHost = class ExtensionHost {
|
|
|
234
237
|
status;
|
|
235
238
|
config;
|
|
236
239
|
log;
|
|
240
|
+
effective;
|
|
237
241
|
/**
|
|
238
242
|
* Only resolves extensions and runs migrations in dependency order: no deployment config check, no
|
|
239
243
|
* setup, no Redis (for `capybara migrate`). Like `load()` it checks secret markers first
|
|
@@ -298,12 +302,18 @@ let ExtensionHost = class ExtensionHost {
|
|
|
298
302
|
for (const manifest of ordered)
|
|
299
303
|
assertSecretsReachable(manifest);
|
|
300
304
|
const sets = await permissionSets(ordered, dirs);
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
manifest
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
305
|
+
const out = [];
|
|
306
|
+
for (const manifest of ordered) {
|
|
307
|
+
const dir = dirs.get(manifest.name);
|
|
308
|
+
out.push({
|
|
309
|
+
source: "config",
|
|
310
|
+
manifest,
|
|
311
|
+
dir,
|
|
312
|
+
permissions: sets.get(manifest.name),
|
|
313
|
+
displayName: (await declaredDisplayName(dir, manifest.name)).displayName ?? null,
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
return out;
|
|
307
317
|
}
|
|
308
318
|
/**
|
|
309
319
|
* M-1: plugin → mount points where deployment state expects `policy` hooks. A per-replica copy of PG
|
|
@@ -351,6 +361,11 @@ let ExtensionHost = class ExtensionHost {
|
|
|
351
361
|
retiring = new Map();
|
|
352
362
|
/** 配置声明插件的清单与权限集合(含未加载的;后台列表与网页批准用)。 */
|
|
353
363
|
declaredInfo = new Map();
|
|
364
|
+
/**
|
|
365
|
+
* Config-declared extensions' display names, read from their plugin directory's plugin.json at
|
|
366
|
+
* load (from the startup config, the same on every replica; never written elsewhere).
|
|
367
|
+
*/
|
|
368
|
+
declaredDisplayNames = new Map();
|
|
354
369
|
/** 导入过的插件名 → 来源与包(含未加载的;重名被跳过的一方不在这里)。 */
|
|
355
370
|
sources = new Map();
|
|
356
371
|
didLoad = false;
|
|
@@ -370,6 +385,8 @@ let ExtensionHost = class ExtensionHost {
|
|
|
370
385
|
configValidity = new Map();
|
|
371
386
|
/** 已告警过的「部署配置不合法」(插件名 → 说明;每个周期都会重新判定,同一说明只告警一次)。 */
|
|
372
387
|
configWarned = new Map();
|
|
388
|
+
/** `<name>@<version>` whose invalid config UI hints were warned about (a log dedupe only). */
|
|
389
|
+
configUiWarned = new Set();
|
|
373
390
|
/**
|
|
374
391
|
* The host builds each extension's `ctx` from the injected kernel services: the pool for
|
|
375
392
|
* `ctx.db` on the extension's schema, Redis for `kv` / `lock` / `bus` and the queues, the
|
|
@@ -393,13 +410,19 @@ let ExtensionHost = class ExtensionHost {
|
|
|
393
410
|
*/
|
|
394
411
|
installs, approvals,
|
|
395
412
|
/** This replica's load status table (`extension_replica_status`): every load result writes a row. */
|
|
396
|
-
status, config, kdb, redis, busSubscriber, keyring, embedTokens, locks, log, options
|
|
413
|
+
status, config, kdb, redis, busSubscriber, keyring, embedTokens, locks, log, options,
|
|
414
|
+
/**
|
|
415
|
+
* Each hook call's effective config for its organization, and the providers excluded from an
|
|
416
|
+
* org's point resolution (layering spec A §6).
|
|
417
|
+
*/
|
|
418
|
+
effective) {
|
|
397
419
|
this.registry = registry;
|
|
398
420
|
this.installs = installs;
|
|
399
421
|
this.approvals = approvals;
|
|
400
422
|
this.status = status;
|
|
401
423
|
this.config = config;
|
|
402
424
|
this.log = log;
|
|
425
|
+
this.effective = effective;
|
|
403
426
|
const c = config.get();
|
|
404
427
|
this.deps = {
|
|
405
428
|
db: kdb.pool,
|
|
@@ -419,6 +442,7 @@ let ExtensionHost = class ExtensionHost {
|
|
|
419
442
|
current: (plugin) => this.registry.current(plugin),
|
|
420
443
|
expectedPolicy: (mount) => this.expectedPolicy(mount),
|
|
421
444
|
enabledPlugins: (orgId) => this.enabledPlugins(orgId),
|
|
445
|
+
effectiveConfig: (orgId, plugin) => effective.get(orgId, plugin),
|
|
422
446
|
locks,
|
|
423
447
|
config: () => ({ hooks: { timeoutMs: this.config.get().hooks.timeoutMs } }),
|
|
424
448
|
log,
|
|
@@ -461,6 +485,8 @@ let ExtensionHost = class ExtensionHost {
|
|
|
461
485
|
manifest: p.manifest,
|
|
462
486
|
set: p.permissions,
|
|
463
487
|
});
|
|
488
|
+
if (p.displayName)
|
|
489
|
+
this.declaredDisplayNames.set(p.manifest.name, p.displayName);
|
|
464
490
|
const valid = configValid.get(p.manifest.name);
|
|
465
491
|
if (valid !== undefined)
|
|
466
492
|
this.configValidity.set(p.manifest.name, valid);
|
|
@@ -516,6 +542,7 @@ let ExtensionHost = class ExtensionHost {
|
|
|
516
542
|
this.installLoader = p.installs;
|
|
517
543
|
const entries = await importEntries(p.config ?? [], this.resolveFrom);
|
|
518
544
|
await this.claimNames(entries);
|
|
545
|
+
await this.noteDisplayNames(entries);
|
|
519
546
|
const dirs = new Map(entries.map((e) => [e.manifest.name, e.dir]));
|
|
520
547
|
const urls = new Map(entries.map((e) => [e.manifest.name, e.url]));
|
|
521
548
|
// 有安装记录时:配置声明的插件若 requires 只能由安装记录满足,先挑出来,等安装记录加载完再解析与加载
|
|
@@ -584,6 +611,23 @@ let ExtensionHost = class ExtensionHost {
|
|
|
584
611
|
});
|
|
585
612
|
}
|
|
586
613
|
}
|
|
614
|
+
/**
|
|
615
|
+
* Records each config-declared extension's display name from its plugin directory's plugin.json
|
|
616
|
+
* (spec §2.2); an invalid plugin.json only warns (no display name).
|
|
617
|
+
*/
|
|
618
|
+
async noteDisplayNames(entries) {
|
|
619
|
+
for (const e of entries) {
|
|
620
|
+
const { displayName, problem } = await declaredDisplayName(e.dir, e.manifest.name);
|
|
621
|
+
if (displayName)
|
|
622
|
+
this.declaredDisplayNames.set(e.manifest.name, displayName);
|
|
623
|
+
if (problem !== undefined) {
|
|
624
|
+
this.log.warn("plugin.json of a config-declared extension is invalid; no display name", {
|
|
625
|
+
plugin: e.manifest.name,
|
|
626
|
+
problem,
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
587
631
|
/**
|
|
588
632
|
* Config-declared extensions also take their name (I4, an addition to Ruling P3): the
|
|
589
633
|
* name is inserted into `extension_name_owners` with its npm package name (left alone when present).
|
|
@@ -1032,6 +1076,39 @@ let ExtensionHost = class ExtensionHost {
|
|
|
1032
1076
|
});
|
|
1033
1077
|
}
|
|
1034
1078
|
}
|
|
1079
|
+
/**
|
|
1080
|
+
* Checks the config UI hints of a loaded module's deployment and org schemas (spec §4.1). Invalid
|
|
1081
|
+
* hints never fail the load: the form schemas drop their `x-ui` (`configFormSchema`), one warning
|
|
1082
|
+
* per `<name>@<version>` is logged, and the returned text goes into the status detail (null when
|
|
1083
|
+
* every hint is valid). The packer refuses such a package; this covers hand-made ones. It never
|
|
1084
|
+
* throws (it runs after the instance is active, before its status row is written): a conversion
|
|
1085
|
+
* that throws is warned about and reported in the detail the same way.
|
|
1086
|
+
*/
|
|
1087
|
+
checkConfigUi(manifest) {
|
|
1088
|
+
const parts = [];
|
|
1089
|
+
for (const level of ["deployment", "org"]) {
|
|
1090
|
+
const schema = manifest.config?.[level];
|
|
1091
|
+
if (!schema)
|
|
1092
|
+
continue;
|
|
1093
|
+
try {
|
|
1094
|
+
const { problems } = configFormSchema(schema, level);
|
|
1095
|
+
if (problems.length > 0)
|
|
1096
|
+
parts.push(describeConfigUiProblems(level, problems));
|
|
1097
|
+
}
|
|
1098
|
+
catch (err) {
|
|
1099
|
+
parts.push(`${level} config UI hints could not be checked (${err instanceof Error ? err.message : String(err)})`);
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
if (parts.length === 0)
|
|
1103
|
+
return null;
|
|
1104
|
+
const detail = parts.join("; ");
|
|
1105
|
+
const key = `${manifest.name}@${manifest.version}`;
|
|
1106
|
+
if (!this.configUiWarned.has(key)) {
|
|
1107
|
+
this.configUiWarned.add(key);
|
|
1108
|
+
this.log.warn("extension config UI hints are invalid and ignored: its config forms show plain fields", { plugin: manifest.name, version: manifest.version, detail });
|
|
1109
|
+
}
|
|
1110
|
+
return detail;
|
|
1111
|
+
}
|
|
1035
1112
|
/** 给已有状态行补说明;失败只记 warn。 */
|
|
1036
1113
|
async noteStatus(plugin, detail) {
|
|
1037
1114
|
try {
|
|
@@ -1123,7 +1200,9 @@ let ExtensionHost = class ExtensionHost {
|
|
|
1123
1200
|
return undefined;
|
|
1124
1201
|
}
|
|
1125
1202
|
let config = raw;
|
|
1126
|
-
|
|
1203
|
+
// the load gate (spec A §5.4a): overridable fields may stay empty on the platform, so
|
|
1204
|
+
// `ctx.config` may lack them; hidden and read-only fields must be complete
|
|
1205
|
+
const parsed = readConfig && schema ? parseLoadGate(schema, raw) : undefined;
|
|
1127
1206
|
if (a.source !== "install")
|
|
1128
1207
|
this.configValidity.set(name, parsed?.success ?? true);
|
|
1129
1208
|
if (decision.action === "pending") {
|
|
@@ -1247,7 +1326,12 @@ let ExtensionHost = class ExtensionHost {
|
|
|
1247
1326
|
this.unloadedForDependency.delete(name);
|
|
1248
1327
|
const old = this.registry.activate(inst);
|
|
1249
1328
|
this.loggedFailures.delete(name);
|
|
1250
|
-
await this.writeStatus({
|
|
1329
|
+
await this.writeStatus({
|
|
1330
|
+
...base,
|
|
1331
|
+
state: "loaded",
|
|
1332
|
+
reason: null,
|
|
1333
|
+
detail: this.checkConfigUi(manifest),
|
|
1334
|
+
});
|
|
1251
1335
|
if (old)
|
|
1252
1336
|
this.retire(old);
|
|
1253
1337
|
return inst;
|
|
@@ -1293,7 +1377,8 @@ let ExtensionHost = class ExtensionHost {
|
|
|
1293
1377
|
permissions: d.set,
|
|
1294
1378
|
configurable: schema !== undefined,
|
|
1295
1379
|
configValid: this.configValidity.get(name) ??
|
|
1296
|
-
(schema ? schema
|
|
1380
|
+
(schema ? parseLoadGate(schema, this.extensionConfig[name] ?? {}).success : true),
|
|
1381
|
+
displayName: this.declaredDisplayNames.get(name) ?? null,
|
|
1297
1382
|
};
|
|
1298
1383
|
});
|
|
1299
1384
|
}
|
|
@@ -1531,6 +1616,7 @@ let ExtensionHost = class ExtensionHost {
|
|
|
1531
1616
|
.all()
|
|
1532
1617
|
.flatMap((i) => i.provided.has(ref) ? [{ plugin: i.name, impl: i.provided.get(ref) }] : []),
|
|
1533
1618
|
enabledPlugins: (orgId) => this.enabledPlugins(orgId),
|
|
1619
|
+
configOk: async (orgId, plugin) => (await this.effective.get(orgId, plugin)).ok,
|
|
1534
1620
|
};
|
|
1535
1621
|
get loadDeps() {
|
|
1536
1622
|
return {
|
|
@@ -1638,6 +1724,15 @@ let ExtensionHost = class ExtensionHost {
|
|
|
1638
1724
|
deploymentConfig(plugin) {
|
|
1639
1725
|
return this.registry.deploymentConfig(plugin);
|
|
1640
1726
|
}
|
|
1727
|
+
/**
|
|
1728
|
+
* The raw (unparsed) deployment config of a running extension: the startup config merged with
|
|
1729
|
+
* the PG values, as the host reads it before parsing (secrets included; never echo it). An org
|
|
1730
|
+
* copy is applied to this and parsed once (layering spec A §6), so schema transforms are not
|
|
1731
|
+
* run twice. Without a running instance, the stored values without a schema.
|
|
1732
|
+
*/
|
|
1733
|
+
rawDeploymentConfig(plugin) {
|
|
1734
|
+
return this.rawConfigOf(plugin, this.registry.current(plugin)?.manifest.config?.deployment);
|
|
1735
|
+
}
|
|
1641
1736
|
/**
|
|
1642
1737
|
* 本副本拿得到的插件清单里的部署级 schema(生效实例 → 配置声明 → 安装记录准备好的候选);
|
|
1643
1738
|
* 都没有返回 undefined(如未加载的安装记录:调用方改用包内静态清单)。
|
|
@@ -1673,7 +1768,7 @@ let ExtensionHost = class ExtensionHost {
|
|
|
1673
1768
|
if (schema) {
|
|
1674
1769
|
try {
|
|
1675
1770
|
const raw = await this.rawConfigOf(plugin, schema);
|
|
1676
|
-
this.configValidity.set(plugin, schema
|
|
1771
|
+
this.configValidity.set(plugin, parseLoadGate(schema, raw).success);
|
|
1677
1772
|
}
|
|
1678
1773
|
catch (err) {
|
|
1679
1774
|
this.log.warn("cannot read the stored deployment config of plugin", {
|
|
@@ -1695,7 +1790,7 @@ let ExtensionHost = class ExtensionHost {
|
|
|
1695
1790
|
this.log.error("cannot read the stored deployment config of plugin; keeping its current config", { plugin, err });
|
|
1696
1791
|
return "invalid";
|
|
1697
1792
|
}
|
|
1698
|
-
const r = schema
|
|
1793
|
+
const r = parseLoadGate(schema, raw);
|
|
1699
1794
|
if (!r.success) {
|
|
1700
1795
|
this.log.warn("plugin deployment config changed but is invalid on this replica; keeping the current config", {
|
|
1701
1796
|
plugin,
|
|
@@ -1947,7 +2042,7 @@ let ExtensionHost = class ExtensionHost {
|
|
|
1947
2042
|
source: inst.source,
|
|
1948
2043
|
state: "loaded",
|
|
1949
2044
|
reason: null,
|
|
1950
|
-
detail:
|
|
2045
|
+
detail: this.checkConfigUi(spec.manifest),
|
|
1951
2046
|
});
|
|
1952
2047
|
if (old)
|
|
1953
2048
|
await this.disposeQuietly(old, drainMs);
|
|
@@ -2105,6 +2200,7 @@ ExtensionHost = __decorate([
|
|
|
2105
2200
|
__param(9, Inject(EmbedTokens)),
|
|
2106
2201
|
__param(10, Inject(LockService)),
|
|
2107
2202
|
__param(11, Inject(KERNEL_LOGGER)),
|
|
2108
|
-
__param(12, Inject(KERNEL_APP_OPTIONS))
|
|
2203
|
+
__param(12, Inject(KERNEL_APP_OPTIONS)),
|
|
2204
|
+
__param(13, Inject(EffectiveConfigs))
|
|
2109
2205
|
], ExtensionHost);
|
|
2110
2206
|
export { ExtensionHost };
|