@capybara-hq/kernel 0.1.0-rc.0 → 0.1.0-rc.2
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 +10 -6
- package/dist/admin/admin.controller.d.ts +17 -17
- package/dist/admin/admin.controller.js +43 -26
- package/dist/admin/admin.module.d.ts +3 -0
- package/dist/admin/admin.module.js +22 -0
- package/dist/admin/extensions.controller.d.ts +14 -14
- package/dist/admin/extensions.controller.js +30 -17
- package/dist/admin/setup-lock.d.ts +16 -0
- package/dist/admin/setup-lock.js +47 -0
- package/dist/admin/setup.controller.d.ts +8 -8
- package/dist/admin/setup.controller.js +27 -25
- package/dist/admin/setup.service.d.ts +19 -27
- package/dist/admin/setup.service.js +61 -61
- package/dist/agents/agent-lookup.d.ts +53 -0
- package/dist/agents/agent-lookup.js +179 -0
- package/dist/agents/agents.controller.d.ts +1 -1
- package/dist/agents/agents.controller.js +14 -8
- package/dist/agents/agents.module.d.ts +7 -0
- package/dist/agents/agents.module.js +41 -0
- package/dist/agents/agents.service.d.ts +39 -58
- package/dist/agents/agents.service.js +261 -329
- package/dist/agents/definition.d.ts +8 -0
- package/dist/agents/definition.js +8 -0
- package/dist/agents/models.controller.d.ts +1 -1
- package/dist/agents/models.controller.js +2 -2
- package/dist/agents/templates.controller.d.ts +1 -1
- package/dist/agents/templates.controller.js +2 -2
- package/dist/agents/templates.d.ts +6 -8
- package/dist/agents/templates.js +20 -4
- package/dist/app.d.ts +93 -0
- package/dist/app.js +150 -0
- package/dist/catalog/admin-catalog.controller.d.ts +3 -3
- package/dist/catalog/admin-catalog.controller.js +27 -13
- package/dist/catalog/catalog-content.d.ts +185 -0
- package/dist/catalog/catalog-content.js +323 -0
- package/dist/catalog/catalog-items.d.ts +186 -0
- package/dist/catalog/catalog-items.js +410 -0
- package/dist/catalog/catalog.module.d.ts +14 -0
- package/dist/catalog/catalog.module.js +71 -0
- package/dist/catalog/catalog.service.d.ts +34 -188
- package/dist/catalog/catalog.service.js +155 -489
- package/dist/catalog/cli.d.ts +3 -2
- package/dist/catalog/cli.js +13 -31
- package/dist/catalog/job-ids.d.ts +15 -0
- package/dist/catalog/job-ids.js +15 -0
- package/dist/catalog/jobs.d.ts +27 -0
- package/dist/catalog/jobs.js +70 -0
- package/dist/catalog/locks.d.ts +24 -0
- package/dist/catalog/locks.js +63 -0
- package/dist/catalog/marketplaces.controller.d.ts +4 -4
- package/dist/catalog/marketplaces.controller.js +22 -11
- package/dist/catalog/marketplaces.service.d.ts +30 -13
- package/dist/catalog/marketplaces.service.js +330 -256
- package/dist/catalog/org-catalog.controller.d.ts +4 -3
- package/dist/catalog/org-catalog.controller.js +29 -14
- package/dist/catalog/org-catalog.service.d.ts +32 -198
- package/dist/catalog/org-catalog.service.js +159 -400
- package/dist/catalog/plugin-import.d.ts +73 -34
- package/dist/catalog/plugin-import.js +356 -217
- package/dist/catalog/plugin-install.d.ts +83 -41
- package/dist/catalog/plugin-install.js +421 -269
- package/dist/catalog/plugin-upgrade.d.ts +59 -4
- package/dist/catalog/plugin-upgrade.js +407 -282
- package/dist/catalog/requests.service.d.ts +27 -15
- package/dist/catalog/requests.service.js +201 -145
- package/dist/catalog/upgrade-targets.d.ts +4 -7
- package/dist/channels/actions.d.ts +6 -4
- package/dist/channels/actions.js +1 -1
- package/dist/channels/cards.d.ts +2 -2
- package/dist/channels/channels.module.d.ts +40 -0
- package/dist/channels/channels.module.js +128 -0
- package/dist/channels/connections.controller.d.ts +1 -1
- package/dist/channels/connections.controller.js +11 -6
- package/dist/channels/connections.service.d.ts +43 -21
- package/dist/channels/connections.service.js +236 -131
- package/dist/channels/inbound.d.ts +34 -38
- package/dist/channels/inbound.js +107 -41
- package/dist/channels/job-ids.d.ts +10 -0
- package/dist/channels/job-ids.js +10 -0
- package/dist/channels/jobs.d.ts +85 -0
- package/dist/channels/jobs.js +157 -0
- package/dist/channels/outbound.d.ts +60 -82
- package/dist/channels/outbound.js +165 -193
- package/dist/channels/supervisor.d.ts +88 -46
- package/dist/channels/supervisor.js +230 -132
- package/dist/channels/threads.d.ts +29 -8
- package/dist/channels/threads.js +71 -13
- package/dist/channels/webhook.d.ts +20 -14
- package/dist/channels/webhook.js +51 -20
- package/dist/config/load.d.ts +3 -2
- package/dist/config/load.js +3 -2
- package/dist/config/nacos-source.js +11 -2
- package/dist/config/schema.d.ts +16 -1
- package/dist/config/schema.js +54 -7
- package/dist/conversations/access.d.ts +29 -0
- package/dist/conversations/access.js +86 -0
- package/dist/conversations/artifacts.d.ts +10 -10
- package/dist/conversations/artifacts.js +35 -9
- package/dist/conversations/attachments.controller.d.ts +1 -1
- package/dist/conversations/attachments.controller.js +8 -6
- package/dist/conversations/attachments.module.d.ts +7 -0
- package/dist/conversations/attachments.module.js +25 -0
- package/dist/conversations/attachments.service.d.ts +30 -22
- package/dist/conversations/attachments.service.js +119 -46
- package/dist/conversations/conversations.controller.d.ts +8 -7
- package/dist/conversations/conversations.controller.js +59 -29
- package/dist/conversations/conversations.module.d.ts +8 -0
- package/dist/conversations/conversations.module.js +69 -0
- package/dist/conversations/conversations.service.d.ts +40 -38
- package/dist/conversations/conversations.service.js +130 -140
- package/dist/conversations/event-log.d.ts +28 -18
- package/dist/conversations/event-log.js +74 -27
- package/dist/conversations/files.d.ts +10 -10
- package/dist/conversations/files.js +37 -11
- package/dist/conversations/idem-keys.d.ts +5 -0
- package/dist/conversations/idem-keys.js +5 -0
- package/dist/conversations/job-ids.d.ts +6 -0
- package/dist/conversations/job-ids.js +6 -0
- package/dist/conversations/outputs-read.d.ts +11 -11
- package/dist/conversations/outputs-read.js +31 -7
- package/dist/conversations/queue.d.ts +48 -56
- package/dist/conversations/queue.js +13 -289
- package/dist/conversations/queue.service.d.ts +60 -0
- package/dist/conversations/queue.service.js +343 -0
- package/dist/conversations/sandbox-status.d.ts +13 -10
- package/dist/conversations/sandbox-status.js +36 -8
- package/dist/conversations/titles.d.ts +71 -24
- package/dist/conversations/titles.js +159 -62
- package/dist/ctx/bus.js +9 -3
- package/dist/ctx/create-ctx.d.ts +6 -0
- package/dist/ctx/create-ctx.js +7 -9
- package/dist/ctx/lock.d.ts +7 -3
- package/dist/ctx/lock.js +9 -20
- package/dist/ctx/queue.js +3 -2
- package/dist/ctx/secrets.d.ts +10 -2
- package/dist/ctx/secrets.js +7 -3
- package/dist/db/kernel-schema.d.ts +2 -2
- package/dist/db/pool.d.ts +5 -0
- package/dist/db/pool.js +1 -0
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +2 -0
- package/dist/evals/budget.d.ts +42 -21
- package/dist/evals/budget.js +114 -62
- package/dist/evals/evals.module.d.ts +31 -0
- package/dist/evals/evals.module.js +114 -0
- package/dist/evals/jobs.d.ts +20 -0
- package/dist/evals/jobs.js +45 -0
- package/dist/evals/run-replay.d.ts +56 -8
- package/dist/evals/run-replay.js +140 -80
- package/dist/evals/runs.controller.d.ts +1 -1
- package/dist/evals/runs.controller.js +17 -8
- package/dist/evals/runs.service.d.ts +23 -45
- package/dist/evals/runs.service.js +245 -234
- package/dist/evals/sets.controller.d.ts +1 -1
- package/dist/evals/sets.controller.js +17 -8
- package/dist/evals/sets.service.d.ts +22 -6
- package/dist/evals/sets.service.js +248 -194
- package/dist/evals/snapshot.d.ts +2 -2
- package/dist/evals/step-replay.d.ts +2 -2
- package/dist/evals/step-replay.js +1 -1
- package/dist/evals/trajectory.controller.d.ts +1 -1
- package/dist/evals/trajectory.controller.js +11 -7
- package/dist/evals/trajectory.service.d.ts +5 -4
- package/dist/evals/trajectory.service.js +30 -7
- package/dist/evals/worker.d.ts +44 -27
- package/dist/evals/worker.js +220 -120
- package/dist/extensions/admin-ops.d.ts +61 -33
- package/dist/extensions/admin-ops.js +248 -154
- package/dist/extensions/admin-view.d.ts +38 -27
- package/dist/extensions/admin-view.js +126 -55
- package/dist/extensions/approvals.d.ts +12 -8
- package/dist/extensions/approvals.js +73 -46
- package/dist/extensions/blobs.d.ts +27 -10
- package/dist/extensions/blobs.js +111 -45
- package/dist/extensions/bootstrap.d.ts +96 -42
- package/dist/extensions/bootstrap.js +303 -155
- package/dist/extensions/cli.d.ts +20 -10
- package/dist/extensions/cli.js +41 -96
- package/dist/extensions/config-issues.d.ts +7 -0
- package/dist/extensions/config-issues.js +31 -0
- package/dist/extensions/deployment-config-store.d.ts +49 -0
- package/dist/extensions/deployment-config-store.js +133 -0
- package/dist/extensions/deployment-config.d.ts +58 -67
- package/dist/extensions/deployment-config.js +202 -230
- package/dist/extensions/enabled.d.ts +5 -5
- package/dist/extensions/extensions.module.d.ts +8 -0
- package/dist/extensions/extensions.module.js +77 -0
- package/dist/extensions/hooks.d.ts +3 -2
- package/dist/extensions/hooks.js +1 -1
- package/dist/extensions/host.d.ts +72 -68
- package/dist/extensions/host.js +191 -152
- package/dist/extensions/installs.d.ts +49 -16
- package/dist/extensions/installs.js +128 -32
- package/dist/extensions/job-ids.d.ts +6 -0
- package/dist/extensions/job-ids.js +6 -0
- package/dist/extensions/lifecycle-topics.d.ts +18 -0
- package/dist/extensions/lifecycle-topics.js +18 -0
- package/dist/extensions/lifecycle.d.ts +35 -47
- package/dist/extensions/lifecycle.js +103 -39
- package/dist/extensions/locks.d.ts +33 -0
- package/dist/extensions/locks.js +86 -0
- package/dist/extensions/migrate-lock.d.ts +3 -4
- package/dist/extensions/org-config.controller.d.ts +1 -1
- package/dist/extensions/org-config.controller.js +8 -5
- package/dist/extensions/org-config.d.ts +48 -46
- package/dist/extensions/org-config.js +284 -226
- package/dist/extensions/registry.d.ts +50 -2
- package/dist/extensions/registry.js +89 -4
- package/dist/extensions/sources.d.ts +12 -8
- package/dist/extensions/sources.js +34 -13
- package/dist/files/files.module.d.ts +3 -0
- package/dist/files/files.module.js +22 -0
- package/dist/files/previewers.controller.d.ts +7 -2
- package/dist/files/previewers.controller.js +17 -9
- package/dist/files/previewers.d.ts +13 -18
- package/dist/files/previewers.js +83 -36
- package/dist/http/adapter.d.ts +3 -0
- package/dist/http/adapter.js +25 -0
- package/dist/http/api.module.d.ts +3 -110
- package/dist/http/api.module.js +47 -355
- package/dist/http/app.d.ts +11 -15
- package/dist/http/app.js +52 -47
- package/dist/http/error-filter.module.d.ts +5 -0
- package/dist/http/error-filter.module.js +18 -0
- package/dist/http/error.filter.js +2 -2
- package/dist/identity/accounts.d.ts +82 -29
- package/dist/identity/accounts.js +294 -175
- package/dist/identity/api-tokens.d.ts +11 -7
- package/dist/identity/api-tokens.js +71 -44
- package/dist/identity/audit.d.ts +7 -4
- package/dist/identity/audit.js +5 -1
- package/dist/identity/auth.controller.d.ts +11 -10
- package/dist/identity/auth.controller.js +31 -25
- package/dist/identity/auth.guard.d.ts +3 -3
- package/dist/identity/auth.guard.js +6 -4
- package/dist/identity/binding.d.ts +9 -11
- package/dist/identity/binding.js +41 -13
- package/dist/identity/enterprise-admin.d.ts +18 -12
- package/dist/identity/enterprise-admin.js +67 -13
- package/dist/identity/external-identity-lock.d.ts +17 -0
- package/dist/identity/external-identity-lock.js +39 -0
- package/dist/identity/external.d.ts +19 -15
- package/dist/identity/external.js +163 -125
- package/dist/identity/identity.module.d.ts +6 -0
- package/dist/identity/identity.module.js +56 -0
- package/dist/identity/me.controller.d.ts +16 -15
- package/dist/identity/me.controller.js +37 -31
- package/dist/identity/sessions.d.ts +12 -10
- package/dist/identity/sessions.js +74 -42
- package/dist/identity/settings.d.ts +20 -14
- package/dist/identity/settings.js +85 -57
- package/dist/identity/sso.controller.d.ts +7 -7
- package/dist/identity/sso.controller.js +13 -9
- package/dist/identity/sso.d.ts +9 -12
- package/dist/identity/sso.js +54 -24
- package/dist/inbox/inbox.module.d.ts +3 -0
- package/dist/inbox/inbox.module.js +22 -0
- package/dist/inbox/inbox.service.d.ts +7 -9
- package/dist/inbox/inbox.service.js +32 -11
- package/dist/index.d.ts +19 -12
- package/dist/index.js +13 -8
- package/dist/infra/cache/cache.module.d.ts +3 -0
- package/dist/infra/cache/cache.module.js +16 -0
- package/dist/infra/cache/cache.service.d.ts +21 -0
- package/dist/infra/cache/cache.service.js +80 -0
- package/dist/infra/cache/cacheable.decorator.d.ts +32 -0
- package/dist/infra/cache/cacheable.decorator.js +83 -0
- package/dist/infra/cli/kernel-cli.module.d.ts +66 -0
- package/dist/infra/cli/kernel-cli.module.js +165 -0
- package/dist/infra/close-within.d.ts +15 -0
- package/dist/infra/close-within.js +36 -0
- package/dist/infra/config/config.module.d.ts +13 -0
- package/dist/infra/config/config.module.js +39 -0
- package/dist/infra/config/kernel-config.service.d.ts +25 -0
- package/dist/infra/config/kernel-config.service.js +126 -0
- package/dist/infra/database/after-commit.d.ts +6 -0
- package/dist/infra/database/after-commit.js +9 -0
- package/dist/infra/database/database.module.d.ts +25 -0
- package/dist/infra/database/database.module.js +90 -0
- package/dist/infra/database/kernel-db.d.ts +22 -0
- package/dist/infra/database/kernel-db.js +65 -0
- package/dist/infra/database/transaction-host.d.ts +50 -0
- package/dist/infra/database/transaction-host.js +125 -0
- package/dist/infra/database/transactional.decorator.d.ts +15 -0
- package/dist/infra/database/transactional.decorator.js +27 -0
- package/dist/infra/database/xact-lock.d.ts +17 -0
- package/dist/infra/database/xact-lock.js +43 -0
- package/dist/infra/events/kernel-events.d.ts +96 -0
- package/dist/infra/events/kernel-events.js +65 -0
- package/dist/infra/health/health.controller.d.ts +26 -0
- package/dist/infra/health/health.controller.js +104 -0
- package/dist/infra/health/health.module.d.ts +9 -0
- package/dist/infra/health/health.module.js +24 -0
- package/dist/infra/health/health.options.d.ts +10 -0
- package/dist/infra/health/health.options.js +15 -0
- package/dist/infra/health/shutdown-state.d.ts +6 -0
- package/dist/infra/health/shutdown-state.js +2 -0
- package/dist/infra/lifecycle/graceful-shutdown.module.d.ts +6 -0
- package/dist/infra/lifecycle/graceful-shutdown.module.js +23 -0
- package/dist/infra/lifecycle/graceful-shutdown.service.d.ts +70 -0
- package/dist/infra/lifecycle/graceful-shutdown.service.js +135 -0
- package/dist/infra/lifecycle/process-guards.d.ts +52 -0
- package/dist/infra/lifecycle/process-guards.js +86 -0
- package/dist/infra/lifecycle/shutdown-signals.d.ts +30 -0
- package/dist/infra/lifecycle/shutdown-signals.js +48 -0
- package/dist/infra/lock/key-template.d.ts +13 -0
- package/dist/infra/lock/key-template.js +46 -0
- package/dist/infra/lock/lock.module.d.ts +3 -0
- package/dist/infra/lock/lock.module.js +16 -0
- package/dist/infra/lock/lock.service.d.ts +120 -0
- package/dist/infra/lock/lock.service.js +343 -0
- package/dist/infra/lock/shared-lease.d.ts +44 -0
- package/dist/infra/lock/shared-lease.js +121 -0
- package/dist/infra/lock/with-lock.decorator.d.ts +28 -0
- package/dist/infra/lock/with-lock.decorator.js +49 -0
- package/dist/infra/logging/logging.module.d.ts +16 -0
- package/dist/infra/logging/logging.module.js +34 -0
- package/dist/infra/queue/configured-processor.d.ts +18 -0
- package/dist/infra/queue/configured-processor.js +23 -0
- package/dist/infra/queue/job-failure.d.ts +18 -0
- package/dist/infra/queue/job-failure.js +26 -0
- package/dist/infra/queue/queue-shutdown.d.ts +27 -0
- package/dist/infra/queue/queue-shutdown.js +81 -0
- package/dist/infra/queue/queue.module.d.ts +16 -0
- package/dist/infra/queue/queue.module.js +61 -0
- package/dist/infra/queue/redis-connection.d.ts +7 -0
- package/dist/infra/queue/redis-connection.js +18 -0
- package/dist/infra/queue/retired-schedulers.d.ts +7 -0
- package/dist/infra/queue/retired-schedulers.js +9 -0
- package/dist/infra/queue/run-job.d.ts +16 -0
- package/dist/infra/queue/run-job.js +19 -0
- package/dist/infra/redis/redis.module.d.ts +24 -0
- package/dist/infra/redis/redis.module.js +87 -0
- package/dist/infra/schedule/cron-tick.d.ts +12 -0
- package/dist/infra/schedule/cron-tick.js +25 -0
- package/dist/infra/schedule/locked-cron.decorator.d.ts +27 -0
- package/dist/infra/schedule/locked-cron.decorator.js +53 -0
- package/dist/infra/schedule/locked-interval.d.ts +69 -0
- package/dist/infra/schedule/locked-interval.js +190 -0
- package/dist/infra/schedule/locked-tick.d.ts +90 -0
- package/dist/infra/schedule/locked-tick.js +137 -0
- package/dist/infra/schedule/schedule.module.d.ts +8 -0
- package/dist/infra/schedule/schedule.module.js +27 -0
- package/dist/infra/schedule/scheduled-runs.d.ts +69 -0
- package/dist/infra/schedule/scheduled-runs.js +163 -0
- package/dist/infra/swagger/swagger.d.ts +16 -0
- package/dist/infra/swagger/swagger.js +31 -0
- package/dist/infra/throttler/credential-throttler.d.ts +35 -0
- package/dist/infra/throttler/credential-throttler.js +77 -0
- package/dist/infra/throttler/named-throttlers.d.ts +31 -0
- package/dist/infra/throttler/named-throttlers.js +119 -0
- package/dist/infra/throttler/redis-throttler-storage.d.ts +38 -0
- package/dist/infra/throttler/redis-throttler-storage.js +130 -0
- package/dist/infra/throttler/throttler.guard.d.ts +23 -0
- package/dist/infra/throttler/throttler.guard.js +68 -0
- package/dist/infra/throttler/throttler.module.d.ts +15 -0
- package/dist/infra/throttler/throttler.module.js +53 -0
- package/dist/infra/tokens.d.ts +15 -0
- package/dist/infra/tokens.js +15 -0
- package/dist/infra/validation/create-zod-dto.d.ts +23 -0
- package/dist/infra/validation/create-zod-dto.js +35 -0
- package/dist/infra/validation/parse-with-zod.d.ts +7 -0
- package/dist/infra/validation/parse-with-zod.js +12 -0
- package/dist/infra/validation/validation.module.d.ts +3 -0
- package/dist/infra/validation/validation.module.js +16 -0
- package/dist/infra/validation/zod-params.d.ts +7 -0
- package/dist/infra/validation/zod-params.js +42 -0
- package/dist/infra/validation/zod-validation.pipe.d.ts +11 -0
- package/dist/infra/validation/zod-validation.pipe.js +31 -0
- package/dist/kernel.d.ts +9 -241
- package/dist/kernel.js +8 -1305
- package/dist/kernel.module.d.ts +17 -0
- package/dist/kernel.module.js +136 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +140 -0
- package/dist/lifecycle/kernel-lifecycle.js +451 -0
- package/dist/lifecycle/tokens.d.ts +3 -0
- package/dist/lifecycle/tokens.js +3 -0
- package/dist/log-config.d.ts +9 -0
- package/dist/log-config.js +27 -0
- package/dist/log-context.d.ts +34 -0
- package/dist/log-context.js +44 -0
- package/dist/log-loki.d.ts +34 -0
- package/dist/log-loki.js +145 -0
- package/dist/log.d.ts +41 -10
- package/dist/log.js +91 -17
- package/dist/models/models.module.d.ts +3 -0
- package/dist/models/models.module.js +24 -0
- package/dist/models/prices.d.ts +8 -2
- package/dist/models/prices.js +65 -37
- package/dist/models/purposes.controller.d.ts +1 -1
- package/dist/models/purposes.controller.js +5 -6
- package/dist/models/purposes.d.ts +35 -13
- package/dist/models/purposes.js +101 -51
- package/dist/net/public-address.js +3 -2
- package/dist/orgs/directory-sync.controller.d.ts +1 -1
- package/dist/orgs/directory-sync.controller.js +2 -2
- package/dist/orgs/directory-sync.d.ts +61 -31
- package/dist/orgs/directory-sync.js +212 -125
- package/dist/orgs/invitations.controller.d.ts +8 -8
- package/dist/orgs/invitations.controller.js +27 -26
- package/dist/orgs/invitations.service.d.ts +12 -9
- package/dist/orgs/invitations.service.js +130 -92
- package/dist/orgs/job-ids.d.ts +8 -0
- package/dist/orgs/job-ids.js +8 -0
- package/dist/orgs/members.service.d.ts +19 -12
- package/dist/orgs/members.service.js +161 -117
- package/dist/orgs/offboarding.d.ts +54 -57
- package/dist/orgs/offboarding.js +161 -71
- package/dist/orgs/org-lock.d.ts +28 -19
- package/dist/orgs/org-lock.js +81 -35
- package/dist/orgs/org.guard.d.ts +1 -1
- package/dist/orgs/org.guard.js +2 -2
- package/dist/orgs/orgs.controller.d.ts +13 -13
- package/dist/orgs/orgs.controller.js +29 -17
- package/dist/orgs/orgs.module.d.ts +6 -0
- package/dist/orgs/orgs.module.js +68 -0
- package/dist/orgs/orgs.service.d.ts +30 -19
- package/dist/orgs/orgs.service.js +139 -86
- package/dist/orgs/settings.controller.d.ts +1 -1
- package/dist/orgs/settings.controller.js +8 -6
- package/dist/orgs/settings.service.d.ts +14 -8
- package/dist/orgs/settings.service.js +75 -46
- package/dist/overrides.d.ts +56 -0
- package/dist/overrides.js +30 -0
- package/dist/roles/gateway-role.d.ts +43 -0
- package/dist/roles/gateway-role.js +98 -0
- package/dist/roles/gateway.module.d.ts +8 -0
- package/dist/roles/gateway.module.js +28 -0
- package/dist/roles/worker-role.d.ts +63 -0
- package/dist/roles/worker-role.js +144 -0
- package/dist/roles/worker.module.d.ts +14 -0
- package/dist/roles/worker.module.js +90 -0
- package/dist/runtime/abort.js +19 -2
- package/dist/runtime/checkpointer.d.ts +8 -3
- package/dist/runtime/checkpointer.js +87 -55
- package/dist/runtime/conversation-lock.d.ts +20 -11
- package/dist/runtime/conversation-lock.js +62 -72
- package/dist/runtime/hook-calls.d.ts +3 -3
- package/dist/runtime/hook-calls.js +1 -6
- package/dist/runtime/job-ids.d.ts +10 -0
- package/dist/runtime/job-ids.js +10 -0
- package/dist/runtime/langgraph-loop.js +1 -1
- package/dist/runtime/loop.d.ts +7 -0
- package/dist/runtime/loop.js +14 -0
- package/dist/runtime/maintenance-queue.d.ts +10 -0
- package/dist/runtime/maintenance-queue.js +10 -0
- package/dist/runtime/maintenance.d.ts +45 -74
- package/dist/runtime/maintenance.js +139 -136
- package/dist/runtime/model-call.d.ts +7 -4
- package/dist/runtime/model-call.js +24 -57
- package/dist/runtime/providers.d.ts +17 -6
- package/dist/runtime/providers.js +66 -25
- package/dist/runtime/quota.d.ts +17 -3
- package/dist/runtime/quota.js +27 -2
- package/dist/runtime/retired-schedulers.d.ts +7 -0
- package/dist/runtime/retired-schedulers.js +31 -0
- package/dist/runtime/run-control.d.ts +33 -0
- package/dist/runtime/run-control.js +77 -0
- package/dist/runtime/run-finish.d.ts +26 -17
- package/dist/runtime/run-finish.js +98 -51
- package/dist/runtime/run-jobs.d.ts +48 -0
- package/dist/runtime/run-jobs.js +95 -0
- package/dist/runtime/run-processors.d.ts +60 -0
- package/dist/runtime/run-processors.js +185 -0
- package/dist/runtime/run-queue.d.ts +32 -57
- package/dist/runtime/run-queue.js +291 -295
- package/dist/runtime/run-steps.d.ts +39 -0
- package/dist/runtime/run-steps.js +96 -0
- package/dist/runtime/run-worker.d.ts +121 -75
- package/dist/runtime/run-worker.js +340 -225
- package/dist/runtime/runtime.module.d.ts +10 -0
- package/dist/runtime/runtime.module.js +112 -0
- package/dist/runtime/step-log.d.ts +40 -0
- package/dist/runtime/step-log.js +94 -0
- package/dist/runtime/stream.controller.d.ts +5 -8
- package/dist/runtime/stream.controller.js +14 -12
- package/dist/runtime/stream.d.ts +24 -6
- package/dist/runtime/stream.js +78 -7
- package/dist/runtime/subagents/child.d.ts +3 -44
- package/dist/runtime/subagents/child.js +0 -79
- package/dist/runtime/subagents/definition.d.ts +4 -4
- package/dist/runtime/subagents/definition.js +2 -2
- package/dist/runtime/subagents/dispatch.d.ts +87 -6
- package/dist/runtime/subagents/dispatch.js +135 -140
- package/dist/runtime/subagents/limits.d.ts +9 -4
- package/dist/runtime/subagents/limits.js +4 -2
- package/dist/runtime/subagents/org-agents.d.ts +4 -4
- package/dist/runtime/subagents/org-agents.js +1 -1
- package/dist/runtime/subagents/progress.d.ts +2 -2
- package/dist/runtime/subagents/roster.d.ts +3 -3
- package/dist/runtime/subagents/roster.js +1 -1
- package/dist/runtime/subagents/skill-fork.d.ts +6 -7
- package/dist/runtime/subagents/skill-fork.js +16 -5
- package/dist/runtime/subagents/subagents.service.d.ts +40 -0
- package/dist/runtime/subagents/subagents.service.js +101 -0
- package/dist/runtime/usage-report.d.ts +94 -52
- package/dist/runtime/usage-report.js +200 -99
- package/dist/runtime/waits.d.ts +125 -57
- package/dist/runtime/waits.js +431 -208
- package/dist/sandbox/job-ids.d.ts +10 -0
- package/dist/sandbox/job-ids.js +10 -0
- package/dist/sandbox/jobs.d.ts +41 -0
- package/dist/sandbox/jobs.js +113 -0
- package/dist/sandbox/leases.d.ts +39 -31
- package/dist/sandbox/leases.js +117 -257
- package/dist/sandbox/providers.d.ts +19 -0
- package/dist/sandbox/providers.js +38 -0
- package/dist/sandbox/sandbox.module.d.ts +8 -0
- package/dist/sandbox/sandbox.module.js +30 -0
- package/dist/sandbox/sandbox.service.d.ts +24 -29
- package/dist/sandbox/sandbox.service.js +106 -75
- package/dist/skills/catalog.d.ts +33 -20
- package/dist/skills/catalog.js +96 -53
- package/dist/skills/changes.controller.d.ts +4 -4
- package/dist/skills/changes.controller.js +15 -9
- package/dist/skills/changes.service.d.ts +28 -18
- package/dist/skills/changes.service.js +421 -364
- package/dist/skills/invocable.controller.d.ts +1 -1
- package/dist/skills/invocable.controller.js +8 -5
- package/dist/skills/invoke.d.ts +16 -15
- package/dist/skills/invoke.js +48 -17
- package/dist/skills/skills.controller.d.ts +1 -1
- package/dist/skills/skills.controller.js +11 -6
- package/dist/skills/skills.module.d.ts +6 -0
- package/dist/skills/skills.module.js +30 -0
- package/dist/skills/skills.service.d.ts +47 -30
- package/dist/skills/skills.service.js +221 -158
- package/dist/storage/job-ids.d.ts +6 -0
- package/dist/storage/job-ids.js +6 -0
- package/dist/storage/purge.d.ts +22 -7
- package/dist/storage/purge.js +55 -3
- package/dist/storage/storage.module.d.ts +6 -0
- package/dist/storage/storage.module.js +23 -0
- package/dist/storage/storage.service.d.ts +18 -4
- package/dist/storage/storage.service.js +44 -3
- package/dist/tools/approvals.controller.d.ts +1 -1
- package/dist/tools/approvals.controller.js +12 -8
- package/dist/tools/approvals.service.d.ts +27 -25
- package/dist/tools/approvals.service.js +324 -258
- package/dist/tools/breaker.d.ts +2 -2
- package/dist/tools/breaker.js +21 -3
- package/dist/tools/builtins/ask-user.d.ts +2 -2
- package/dist/tools/builtins/ask-user.js +1 -1
- package/dist/tools/builtins/builtin-tools.d.ts +21 -0
- package/dist/tools/builtins/builtin-tools.js +80 -0
- package/dist/tools/builtins/read-tool-output.d.ts +2 -2
- package/dist/tools/builtins/read-tool-output.js +1 -1
- package/dist/tools/builtins/sandbox/bash.js +2 -2
- package/dist/tools/builtins/sandbox/common.d.ts +7 -4
- package/dist/tools/builtins/sandbox/common.js +5 -3
- package/dist/tools/builtins/sandbox/deliver.js +2 -2
- package/dist/tools/builtins/sandbox/edit.js +1 -1
- package/dist/tools/builtins/sandbox/glob.js +2 -2
- package/dist/tools/builtins/sandbox/grep.js +2 -2
- package/dist/tools/builtins/sandbox/read.js +1 -1
- package/dist/tools/builtins/sandbox/write.js +1 -1
- package/dist/tools/builtins/skill-load.d.ts +3 -3
- package/dist/tools/builtins/skill-load.js +1 -1
- package/dist/tools/canonical-json.d.ts +6 -0
- package/dist/tools/canonical-json.js +16 -0
- package/dist/tools/connector-content.controller.d.ts +1 -1
- package/dist/tools/connector-content.controller.js +11 -6
- package/dist/tools/connector-content.d.ts +12 -15
- package/dist/tools/connector-content.js +53 -18
- package/dist/tools/connectors.controller.d.ts +1 -1
- package/dist/tools/connectors.controller.js +21 -10
- package/dist/tools/connectors.service.d.ts +31 -13
- package/dist/tools/connectors.service.js +434 -344
- package/dist/tools/credentials.d.ts +17 -20
- package/dist/tools/credentials.js +55 -34
- package/dist/tools/drift.d.ts +29 -41
- package/dist/tools/drift.js +111 -79
- package/dist/tools/info.d.ts +12 -9
- package/dist/tools/info.js +33 -7
- package/dist/tools/job-ids.d.ts +13 -0
- package/dist/tools/job-ids.js +15 -0
- package/dist/tools/jobs.d.ts +24 -0
- package/dist/tools/jobs.js +69 -0
- package/dist/tools/oauth/flow-paths.d.ts +16 -0
- package/dist/tools/oauth/flow-paths.js +38 -0
- package/dist/tools/oauth/flow.d.ts +30 -30
- package/dist/tools/oauth/flow.js +109 -81
- package/dist/tools/oauth/oauth.controller.d.ts +3 -3
- package/dist/tools/oauth/oauth.controller.js +12 -9
- package/dist/tools/oauth/tokens.d.ts +11 -3
- package/dist/tools/oauth/tokens.js +15 -14
- package/dist/tools/outputs.d.ts +13 -4
- package/dist/tools/outputs.js +47 -3
- package/dist/tools/pipeline.d.ts +62 -46
- package/dist/tools/pipeline.js +145 -64
- package/dist/tools/policy.d.ts +2 -2
- package/dist/tools/questions.controller.d.ts +1 -1
- package/dist/tools/questions.controller.js +8 -5
- package/dist/tools/questions.service.d.ts +25 -24
- package/dist/tools/questions.service.js +201 -142
- package/dist/tools/registry.d.ts +30 -20
- package/dist/tools/registry.js +73 -37
- package/dist/tools/specs.d.ts +5 -4
- package/dist/tools/specs.js +3 -1
- package/dist/tools/tools.module.d.ts +10 -0
- package/dist/tools/tools.module.js +91 -0
- package/dist/ui/call-extension.d.ts +16 -0
- package/dist/ui/call-extension.js +38 -0
- package/dist/ui/embed-token.d.ts +9 -5
- package/dist/ui/embed-token.js +34 -6
- package/dist/ui/ui-stream.d.ts +22 -17
- package/dist/ui/ui-stream.js +72 -12
- package/dist/ui/ui.module.d.ts +7 -0
- package/dist/ui/ui.module.js +28 -0
- package/dist/ui/views.controller.d.ts +14 -12
- package/dist/ui/views.controller.js +32 -25
- package/dist/ui/views.d.ts +9 -57
- package/dist/ui/views.js +43 -45
- package/package.json +11 -2
- package/dist/http/health.controller.d.ts +0 -26
- package/dist/http/health.controller.js +0 -79
- package/dist/http/tokens.d.ts +0 -131
- package/dist/http/tokens.js +0 -131
- package/dist/http/zod.pipe.d.ts +0 -8
- package/dist/http/zod.pipe.js +0 -14
- package/dist/identity/rate-limit.d.ts +0 -55
- package/dist/identity/rate-limit.js +0 -121
- package/dist/sandbox/lifecycle.d.ts +0 -21
- package/dist/sandbox/lifecycle.js +0 -68
- /package/dist/http/{gateway.module.d.ts → gateway-routes.d.ts} +0 -0
- /package/dist/http/{gateway.module.js → gateway-routes.js} +0 -0
package/dist/extensions/host.js
CHANGED
|
@@ -1,25 +1,43 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
+
};
|
|
1
10
|
import { createHash } from "node:crypto";
|
|
2
11
|
import { readFile } from "node:fs/promises";
|
|
3
12
|
import { createRequire } from "node:module";
|
|
4
13
|
import { dirname, isAbsolute, join, resolve as resolvePath } from "node:path";
|
|
5
14
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
15
|
import { EXTENSION_POINT_CARDINALITY, parseExtensionPoint, SDK_VERSION, } from "@capybara-hq/plugin-sdk";
|
|
16
|
+
import { Inject, Injectable } from "@nestjs/common";
|
|
7
17
|
import { changedPaths, configFields, getPath, secretValues, setPath, unreachableSecrets, } from "../config/fields.js";
|
|
8
18
|
import { pluginSchemaName, queryEnabledPlugins, } from "../ctx/create-ctx.js";
|
|
9
19
|
import { kernelDb } from "../db/kernel-schema.js";
|
|
10
20
|
import { migrate } from "../db/migrator.js";
|
|
11
21
|
import { createDb } from "../db/pool.js";
|
|
22
|
+
import { waitWithin } from "../infra/close-within.js";
|
|
23
|
+
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
24
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
25
|
+
import { LockService } from "../infra/lock/lock.service.js";
|
|
26
|
+
import { KERNEL_LOGGER, KEYRING, REDIS, REDIS_SUBSCRIBER } from "../infra/tokens.js";
|
|
27
|
+
import { KERNEL_APP_OPTIONS } from "../lifecycle/tokens.js";
|
|
12
28
|
import { packagePath } from "../packages/tgz.js";
|
|
13
|
-
import {
|
|
29
|
+
import { EmbedTokens } from "../ui/embed-token.js";
|
|
30
|
+
import { ExtensionApprovals, planApprovals, readSnapshots, withPreApproved, } from "./approvals.js";
|
|
14
31
|
import { ExtensionBlobIntegrityError } from "./blobs.js";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
32
|
+
import { toIssues } from "./config-issues.js";
|
|
33
|
+
import { HookRegistry } from "./hooks.js";
|
|
34
|
+
import { ExtensionInstalls } from "./installs.js";
|
|
35
|
+
import { ImportTracker, importExtensionModule, ManifestMismatchError, matchesSection, setupInstance, warnUpgrades, } from "./instance.js";
|
|
19
36
|
import { permissionSetOfSection, readMigrationSql } from "./package.js";
|
|
20
37
|
import { blockingKeys, computePermissionSet, UI_VIEW_KEY_PREFIX, } from "./permission-set.js";
|
|
21
38
|
import { ExtensionRegistry } from "./registry.js";
|
|
22
39
|
import { ExtensionResolveError, resolveExtensions } from "./resolve.js";
|
|
40
|
+
import { ReplicaStatusStore, } from "./sources.js";
|
|
23
41
|
import { PackageShaMismatchError, packageRootOf } from "./sync.js";
|
|
24
42
|
/** 键排序后的 JSON(对象键顺序不影响结果);undefined 字段与 JSON.stringify 一样省略。 */
|
|
25
43
|
const canonicalJson = (v) => {
|
|
@@ -58,10 +76,6 @@ export function deploymentConfigHash(schema, config) {
|
|
|
58
76
|
return createHash("sha256").update(canonicalJson(redacted)).digest("hex").slice(0, 16);
|
|
59
77
|
}
|
|
60
78
|
const CLOSED_DURING_LOAD = "plugin host closed during load";
|
|
61
|
-
/** 撤销实例时在途调用的默认排空时限(`extensionHost.drainSeconds` 的默认值)。 */
|
|
62
|
-
const DEFAULT_DRAIN_MS = 30_000;
|
|
63
|
-
/** 运行中重新加载时 setup 的默认时限(`extensionHost.reloadSetupTimeoutSeconds` 的默认值)。 */
|
|
64
|
-
const DEFAULT_RELOAD_SETUP_TIMEOUT_MS = 60_000;
|
|
65
79
|
/** 停机时等进行中的 unload / reload 的上限(之后直接关闭 setup 中的 ctx、撤销其余实例)。 */
|
|
66
80
|
const CLOSE_LIFECYCLE_WAIT_MS = 2_000;
|
|
67
81
|
/** 部署已知插件名(配置声明 / 安装记录)缓存的有效期:路由闸门 503 / 404 用,跨副本靠它收敛。 */
|
|
@@ -212,16 +226,14 @@ function manifestOfSection(m) {
|
|
|
212
226
|
},
|
|
213
227
|
};
|
|
214
228
|
}
|
|
215
|
-
/** 内核消费的提供方能力:调用计入提供方实例的在途计数(撤销 / 升级时排空,C17)。 */
|
|
216
|
-
const TRACKED_EXTENSION_POINTS = {
|
|
217
|
-
connector: { sessions: ["open"] },
|
|
218
|
-
sandbox: {},
|
|
219
|
-
"model-provider": {},
|
|
220
|
-
};
|
|
221
229
|
/** 插件宿主:解析、校验配置、迁移、setup,并登记插件提供的能力与路由。 */
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
230
|
+
let ExtensionHost = class ExtensionHost {
|
|
231
|
+
registry;
|
|
232
|
+
installs;
|
|
233
|
+
approvals;
|
|
234
|
+
status;
|
|
235
|
+
config;
|
|
236
|
+
log;
|
|
225
237
|
/**
|
|
226
238
|
* Only resolves extensions and runs migrations in dependency order: no deployment config check, no
|
|
227
239
|
* setup, no Redis (for `capybara migrate`). Like `load()` it checks secret markers first
|
|
@@ -245,7 +257,7 @@ export class ExtensionHost {
|
|
|
245
257
|
const raw = createDb(opts.dbUrl, 1, () => { }, { connectTimeoutMs: opts.connectTimeoutMs });
|
|
246
258
|
let decisions;
|
|
247
259
|
try {
|
|
248
|
-
decisions = planApprovals(ordered, sets, await
|
|
260
|
+
decisions = planApprovals(ordered, sets, await readSnapshots(kernelDb(raw)));
|
|
249
261
|
}
|
|
250
262
|
finally {
|
|
251
263
|
await raw.destroy();
|
|
@@ -293,8 +305,6 @@ export class ExtensionHost {
|
|
|
293
305
|
permissions: sets.get(manifest.name),
|
|
294
306
|
}));
|
|
295
307
|
}
|
|
296
|
-
/** 本进程生效的插件实例(C17):消费方每次实时取,不缓存实现对象。 */
|
|
297
|
-
registry = new ExtensionRegistry();
|
|
298
308
|
/**
|
|
299
309
|
* M-1: plugin → mount points where deployment state expects `policy` hooks. A per-replica copy of PG
|
|
300
310
|
* deployment state (like the registry), rebuilt on every load / converge, never written elsewhere.
|
|
@@ -316,10 +326,6 @@ export class ExtensionHost {
|
|
|
316
326
|
imports = new ImportTracker();
|
|
317
327
|
/** 串行化 unload / reload(同一时刻只做一件,依赖方的连锁处理不交错)。 */
|
|
318
328
|
lifecycle = Promise.resolve();
|
|
319
|
-
drainMs;
|
|
320
|
-
disposeTimeoutMs;
|
|
321
|
-
reloadSetupTimeoutMs;
|
|
322
|
-
installedNames;
|
|
323
329
|
/** 安装记录里的插件名缓存(TTL + 注册表变化时作废)。 */
|
|
324
330
|
installedCache;
|
|
325
331
|
/** 本次因权限待批准(或依赖待批准插件)而未加载的插件。 */
|
|
@@ -358,53 +364,108 @@ export class ExtensionHost {
|
|
|
358
364
|
/** 已创建、尚未登记(setup 进行中)的 ctx:close() 时立即关闭,不等 setup 返回。 */
|
|
359
365
|
settingUp;
|
|
360
366
|
resolveFrom;
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
status;
|
|
364
|
-
storedConfig;
|
|
367
|
+
/** What every extension's `ctx` is built from (kernel side only; nothing Nest crosses into `ctx`). */
|
|
368
|
+
deps;
|
|
365
369
|
/** 配置声明插件的部署配置最近一次判定是否合法(后台列表用;没判定过时按启动配置校验)。 */
|
|
366
370
|
configValidity = new Map();
|
|
367
371
|
/** 已告警过的「部署配置不合法」(插件名 → 说明;每个周期都会重新判定,同一说明只告警一次)。 */
|
|
368
372
|
configWarned = new Map();
|
|
369
373
|
/**
|
|
370
|
-
*
|
|
371
|
-
* `
|
|
372
|
-
*
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
* `
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
|
|
374
|
+
* The host builds each extension's `ctx` from the injected kernel services: the pool for
|
|
375
|
+
* `ctx.db` on the extension's schema, Redis for `kv` / `lock` / `bus` and the queues, the
|
|
376
|
+
* keyring for `secrets`. The config is read per call (`extensionConfig`, the drain and setup
|
|
377
|
+
* time limits, `extensionPermissions.autoApprove`).
|
|
378
|
+
*
|
|
379
|
+
* `KERNEL_APP_OPTIONS.resolveFrom`: the directory bare package names are resolved from, default
|
|
380
|
+
* `process.cwd()`; a relative path is made absolute against the cwd at construction. Absolute
|
|
381
|
+
* paths and `file:` URL extension specifiers are used as they are; bare package names are
|
|
382
|
+
* resolved with `createRequire(<resolveFrom>/noop.js).resolve`, so an extension package's exports
|
|
383
|
+
* must expose the `default` (or `require`) condition.
|
|
384
|
+
*/
|
|
385
|
+
constructor(
|
|
386
|
+
/** The process's extension registry (one provider, shared with other domains). */
|
|
387
|
+
registry,
|
|
388
|
+
/**
|
|
389
|
+
* The deployment's desired state (one way, spec §3): install record names (with the
|
|
390
|
+
* config-declared ones the extensions "known to the deployment": routes of one not active on
|
|
391
|
+
* this replica answer 503, an unknown name 404; cached {@link KNOWN_NAMES_TTL_MS}) and each
|
|
392
|
+
* extension's effective deployment config (the startup config plus the fields stored in PG, C10).
|
|
381
393
|
*/
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
this.
|
|
386
|
-
this.
|
|
387
|
-
this.
|
|
388
|
-
this.
|
|
389
|
-
|
|
390
|
-
this.
|
|
391
|
-
const
|
|
394
|
+
installs, approvals,
|
|
395
|
+
/** 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) {
|
|
397
|
+
this.registry = registry;
|
|
398
|
+
this.installs = installs;
|
|
399
|
+
this.approvals = approvals;
|
|
400
|
+
this.status = status;
|
|
401
|
+
this.config = config;
|
|
402
|
+
this.log = log;
|
|
403
|
+
const c = config.get();
|
|
404
|
+
this.deps = {
|
|
405
|
+
db: kdb.pool,
|
|
406
|
+
dbUrl: c.db.url,
|
|
407
|
+
connectTimeoutMs: c.db.connectTimeoutMs,
|
|
408
|
+
redis,
|
|
409
|
+
busSubscriber,
|
|
410
|
+
redisUrl: c.redis.url,
|
|
411
|
+
keyring,
|
|
412
|
+
embedTokens,
|
|
413
|
+
locks,
|
|
414
|
+
runWorkers: c.roles.includes("worker"),
|
|
415
|
+
log,
|
|
416
|
+
};
|
|
392
417
|
this.hooks = new HookRegistry({
|
|
393
418
|
instances: () => this.registry.all(),
|
|
394
419
|
current: (plugin) => this.registry.current(plugin),
|
|
395
420
|
expectedPolicy: (mount) => this.expectedPolicy(mount),
|
|
396
421
|
enabledPlugins: (orgId) => this.enabledPlugins(orgId),
|
|
397
|
-
|
|
398
|
-
config: () => ({ hooks: { timeoutMs:
|
|
399
|
-
log
|
|
422
|
+
locks,
|
|
423
|
+
config: () => ({ hooks: { timeoutMs: this.config.get().hooks.timeoutMs } }),
|
|
424
|
+
log,
|
|
400
425
|
});
|
|
401
426
|
this.registry.onChange(() => {
|
|
402
427
|
this.installedCache = undefined;
|
|
403
428
|
});
|
|
404
|
-
this.
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
429
|
+
this.resolveFrom = resolvePath(options.resolveFrom ?? process.cwd());
|
|
430
|
+
}
|
|
431
|
+
/** The startup config's `extensionConfig` (file / Nacos merged with env). */
|
|
432
|
+
get extensionConfig() {
|
|
433
|
+
return this.config.get().extensionConfig;
|
|
434
|
+
}
|
|
435
|
+
/** `extensionPermissions.autoApprove` (development and trials only; see `planApprovals`). */
|
|
436
|
+
get autoApprove() {
|
|
437
|
+
return this.config.get().extensionPermissions.autoApprove;
|
|
438
|
+
}
|
|
439
|
+
/** In-flight calls of a revoked instance are drained within this (`extensionHost.drainSeconds`). */
|
|
440
|
+
drainMs() {
|
|
441
|
+
return this.config.get().extensionHost.drainSeconds * 1000;
|
|
442
|
+
}
|
|
443
|
+
/** An extension's `dispose()` time limit (`extensionHost.disposeTimeoutSeconds`). */
|
|
444
|
+
disposeTimeoutMs() {
|
|
445
|
+
return this.config.get().extensionHost.disposeTimeoutSeconds * 1000;
|
|
446
|
+
}
|
|
447
|
+
/** `setup` time limit of a reload in a running process (`extensionHost.reloadSetupTimeoutSeconds`). */
|
|
448
|
+
reloadSetupTimeoutMs() {
|
|
449
|
+
return this.config.get().extensionHost.reloadSetupTimeoutSeconds * 1000;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Records the config-declared extensions the CLI inspected (the CLI loads none): their names,
|
|
453
|
+
* manifests and permission sets for {@link declared} / {@link declaredPlugins}, and whether
|
|
454
|
+
* their deployment config is valid (the CLI merges and checks it like a replica would).
|
|
455
|
+
*/
|
|
456
|
+
noteInspected(inspected, configValid) {
|
|
457
|
+
for (const p of inspected) {
|
|
458
|
+
this.sources.set(p.manifest.name, { source: "config", sha256: null });
|
|
459
|
+
this.declaredInfo.set(p.manifest.name, {
|
|
460
|
+
source: "config",
|
|
461
|
+
manifest: p.manifest,
|
|
462
|
+
set: p.permissions,
|
|
463
|
+
});
|
|
464
|
+
const valid = configValid.get(p.manifest.name);
|
|
465
|
+
if (valid !== undefined)
|
|
466
|
+
this.configValidity.set(p.manifest.name, valid);
|
|
467
|
+
}
|
|
468
|
+
this.registry.declare(inspected.map((p) => p.manifest.name));
|
|
408
469
|
}
|
|
409
470
|
/**
|
|
410
471
|
* Imports each extension module (default export) and initializes them in dependency order; may be
|
|
@@ -464,13 +525,14 @@ export class ExtensionHost {
|
|
|
464
525
|
const ordered = resolveExtensions(ready, SDK_VERSION);
|
|
465
526
|
for (const e of entries)
|
|
466
527
|
this.sources.set(e.manifest.name, { source: "config", sha256: null });
|
|
528
|
+
this.registry.declare(entries.map((e) => e.manifest.name));
|
|
467
529
|
for (const e of entries)
|
|
468
530
|
assertSecretsReachable(e.manifest);
|
|
469
531
|
const sets = await permissionSets(ordered, dirs);
|
|
470
532
|
this.noteDeclared(ordered, sets);
|
|
471
|
-
const approvals =
|
|
533
|
+
const approvals = this.approvals;
|
|
472
534
|
if (this.autoApprove) {
|
|
473
|
-
this.
|
|
535
|
+
this.log.warn("extensionPermissions.autoApprove is ON: plugin permissions are approved automatically without review; never enable this in production");
|
|
474
536
|
}
|
|
475
537
|
const snapshots = ordered.length > 0 || p.installs ? await approvals.all() : new Map();
|
|
476
538
|
const decisions = new Map(planApprovals(ordered, sets, snapshots, {
|
|
@@ -496,7 +558,7 @@ export class ExtensionHost {
|
|
|
496
558
|
desired = await p.installs.desired();
|
|
497
559
|
}
|
|
498
560
|
catch (e) {
|
|
499
|
-
this.
|
|
561
|
+
this.log.error("cannot read extension install records; installed extensions are not loaded", {
|
|
500
562
|
err: e,
|
|
501
563
|
});
|
|
502
564
|
}
|
|
@@ -517,7 +579,7 @@ export class ExtensionHost {
|
|
|
517
579
|
await this.refreshPolicyExpectations(p.installs ? desired : []);
|
|
518
580
|
const orphans = Object.keys(this.extensionConfig).filter((k) => !this.sources.has(k));
|
|
519
581
|
if (orphans.length > 0) {
|
|
520
|
-
this.
|
|
582
|
+
this.log.warn("extensionConfig has keys for extensions that are not loaded", {
|
|
521
583
|
keys: orphans,
|
|
522
584
|
});
|
|
523
585
|
}
|
|
@@ -533,7 +595,7 @@ export class ExtensionHost {
|
|
|
533
595
|
for (const e of entries) {
|
|
534
596
|
const pkg = await packageNameOf(e.dir);
|
|
535
597
|
if (pkg === undefined) {
|
|
536
|
-
this.
|
|
598
|
+
this.log.warn("plugin module has no package.json name; its plugin name is not claimed", {
|
|
537
599
|
plugin: e.manifest.name,
|
|
538
600
|
});
|
|
539
601
|
continue;
|
|
@@ -557,12 +619,12 @@ export class ExtensionHost {
|
|
|
557
619
|
for (const o of owners) {
|
|
558
620
|
const mine = rows.find((r) => r.name === o.name);
|
|
559
621
|
if (mine && mine.package_name !== o.package_name) {
|
|
560
|
-
this.
|
|
622
|
+
this.log.warn("plugin name is owned by a different npm package; the data, secrets and approval kept under this name came from that package", { plugin: o.name, owner: o.package_name, package: mine.package_name });
|
|
561
623
|
}
|
|
562
624
|
}
|
|
563
625
|
}
|
|
564
626
|
catch (err) {
|
|
565
|
-
this.
|
|
627
|
+
this.log.warn("cannot record plugin name owners", { err });
|
|
566
628
|
}
|
|
567
629
|
}
|
|
568
630
|
/**
|
|
@@ -598,18 +660,15 @@ export class ExtensionHost {
|
|
|
598
660
|
* 插件此刻的部署配置(未校验):启动配置补上 PG 里保存的字段(C10,见构造参数 `deploymentConfig`)。
|
|
599
661
|
*/
|
|
600
662
|
async rawConfigOf(name, schema) {
|
|
601
|
-
|
|
602
|
-
if (!this.storedConfig)
|
|
603
|
-
return fileValue ?? {};
|
|
604
|
-
return this.storedConfig(name, fileValue, schema);
|
|
663
|
+
return this.installs.effectiveDeploymentConfig(name, this.extensionConfig[name], schema);
|
|
605
664
|
}
|
|
606
|
-
/**
|
|
665
|
+
/** 把一份已校验部署配置里的密钥值登记到日志打码。 */
|
|
607
666
|
reportSecrets(schema, config) {
|
|
608
|
-
if (!schema
|
|
667
|
+
if (!schema)
|
|
609
668
|
return;
|
|
610
669
|
const values = secretValues(schema, config);
|
|
611
670
|
if (values.length > 0)
|
|
612
|
-
this.
|
|
671
|
+
this.log.addSecrets(values);
|
|
613
672
|
}
|
|
614
673
|
/**
|
|
615
674
|
* 安装记录收敛到 PG 期望状态(启动第 3 步与运行中的 {@link converge} 共用,C16);`desired` 为期望启用的记录。
|
|
@@ -633,7 +692,7 @@ export class ExtensionHost {
|
|
|
633
692
|
if (taken) {
|
|
634
693
|
if (!this.warnedConflicts.has(d.name)) {
|
|
635
694
|
this.warnedConflicts.add(d.name);
|
|
636
|
-
this.
|
|
695
|
+
this.log.warn("plugin is both installed and declared in the extensions config list; using the config plugin", { plugin: d.name, installedVersion: d.version });
|
|
637
696
|
// 该名字的状态行属于生效的一方,不覆盖;在它的 detail 里记下冲突(后台能看到)
|
|
638
697
|
await this.noteStatus(d.name, `name_conflict: install record ${d.version} (${d.sha256.slice(0, 16)}) ignored; the ${taken} plugin of the same name is used`);
|
|
639
698
|
}
|
|
@@ -752,7 +811,7 @@ export class ExtensionHost {
|
|
|
752
811
|
// 4. 按拓扑序逐个:权限闸门 → 配置 → 迁移 → setup → 登记(替换旧实例)
|
|
753
812
|
const order = resolveExtensions([...base(), ...accepted.map((a) => a.manifest)], SDK_VERSION);
|
|
754
813
|
const byName = new Map(accepted.map((c) => [c.d.name, c]));
|
|
755
|
-
const approvals =
|
|
814
|
+
const approvals = this.approvals;
|
|
756
815
|
const snapshots = await approvals.all();
|
|
757
816
|
const activated = new Set();
|
|
758
817
|
for (const m of order) {
|
|
@@ -873,7 +932,7 @@ export class ExtensionHost {
|
|
|
873
932
|
if (this.loggedFailures.get(plugin) === key)
|
|
874
933
|
return;
|
|
875
934
|
this.loggedFailures.set(plugin, key);
|
|
876
|
-
this.
|
|
935
|
+
this.log.error("installed extension not loaded", {
|
|
877
936
|
plugin,
|
|
878
937
|
sha256,
|
|
879
938
|
reason,
|
|
@@ -975,13 +1034,11 @@ export class ExtensionHost {
|
|
|
975
1034
|
}
|
|
976
1035
|
/** 给已有状态行补说明;失败只记 warn。 */
|
|
977
1036
|
async noteStatus(plugin, detail) {
|
|
978
|
-
if (!this.status)
|
|
979
|
-
return;
|
|
980
1037
|
try {
|
|
981
1038
|
await this.status.note(plugin, detail);
|
|
982
1039
|
}
|
|
983
1040
|
catch (e) {
|
|
984
|
-
this.
|
|
1041
|
+
this.log.warn("cannot write plugin replica status", { plugin, err: e });
|
|
985
1042
|
}
|
|
986
1043
|
}
|
|
987
1044
|
/**
|
|
@@ -1002,13 +1059,11 @@ export class ExtensionHost {
|
|
|
1002
1059
|
else
|
|
1003
1060
|
this.installRows.set(s.plugin, { version: s.version, sha256: s.sha256 });
|
|
1004
1061
|
}
|
|
1005
|
-
if (!this.status)
|
|
1006
|
-
return;
|
|
1007
1062
|
try {
|
|
1008
1063
|
await this.status.write(s);
|
|
1009
1064
|
}
|
|
1010
1065
|
catch (e) {
|
|
1011
|
-
this.
|
|
1066
|
+
this.log.warn("cannot write plugin replica status", { plugin: s.plugin, err: e });
|
|
1012
1067
|
}
|
|
1013
1068
|
}
|
|
1014
1069
|
/**
|
|
@@ -1054,7 +1109,7 @@ export class ExtensionHost {
|
|
|
1054
1109
|
if (this.closed)
|
|
1055
1110
|
throw new Error(CLOSED_DURING_LOAD, { cause: e });
|
|
1056
1111
|
// 读不到 PG 里保存的部署配置:按待配置处理,下次 reconcile 再试
|
|
1057
|
-
this.
|
|
1112
|
+
this.log.error("cannot read the stored deployment config of plugin", {
|
|
1058
1113
|
plugin: name,
|
|
1059
1114
|
err: e,
|
|
1060
1115
|
});
|
|
@@ -1081,7 +1136,7 @@ export class ExtensionHost {
|
|
|
1081
1136
|
// 每个周期都会重新判定:同一版本、同一原因只告警一次
|
|
1082
1137
|
if (before?.version !== decision.pending.version ||
|
|
1083
1138
|
before.reason !== decision.pending.reason) {
|
|
1084
|
-
warnPending(this.
|
|
1139
|
+
warnPending(this.log, decision.pending);
|
|
1085
1140
|
}
|
|
1086
1141
|
const reason = decision.pending.reason === "dependency" ? "dependency" : "approval";
|
|
1087
1142
|
await this.writeStatus({ ...base, state: "pending", reason, detail: null });
|
|
@@ -1092,7 +1147,7 @@ export class ExtensionHost {
|
|
|
1092
1147
|
if (decision.changed) {
|
|
1093
1148
|
if (decision.autoApprove) {
|
|
1094
1149
|
await approvals.approve(name, manifest.version, a.set, { source: "auto" });
|
|
1095
|
-
this.
|
|
1150
|
+
this.log.warn("plugin permissions auto-approved (extensionPermissions.autoApprove)", {
|
|
1096
1151
|
plugin: name,
|
|
1097
1152
|
version: manifest.version,
|
|
1098
1153
|
added: decision.added,
|
|
@@ -1104,7 +1159,7 @@ export class ExtensionHost {
|
|
|
1104
1159
|
const updated = await approvals.refresh(name, manifest.version, a.set);
|
|
1105
1160
|
const merged = decision.added.filter((k) => k.startsWith(UI_VIEW_KEY_PREFIX));
|
|
1106
1161
|
if (updated && merged.length > 0 && blockingKeys(decision.added).length === 0) {
|
|
1107
|
-
this.
|
|
1162
|
+
this.log.info("plugin ui views merged into the permission snapshot", {
|
|
1108
1163
|
plugin: name,
|
|
1109
1164
|
version: manifest.version,
|
|
1110
1165
|
merged,
|
|
@@ -1121,7 +1176,7 @@ export class ExtensionHost {
|
|
|
1121
1176
|
// 待配置(C10):配置声明与安装记录都一样,内核照常启动;配置改好后下一次 reconcile 加载
|
|
1122
1177
|
if (this.configWarned.get(name) !== detail) {
|
|
1123
1178
|
this.configWarned.set(name, detail);
|
|
1124
|
-
this.
|
|
1179
|
+
this.log.warn("extension not loaded: its deployment config is missing or invalid (set it in the admin console or the startup config; it loads without a restart)", { plugin: name, source: a.source, detail });
|
|
1125
1180
|
}
|
|
1126
1181
|
retryLater();
|
|
1127
1182
|
await this.writeStatus({ ...base, state: "pending", reason: "config", detail });
|
|
@@ -1183,7 +1238,7 @@ export class ExtensionHost {
|
|
|
1183
1238
|
}
|
|
1184
1239
|
if (this.closed) {
|
|
1185
1240
|
await inst.dispose({ drainMs: 0 }).catch((err) => {
|
|
1186
|
-
this.
|
|
1241
|
+
this.log.warn("plugin context close failed", { plugin: name, err });
|
|
1187
1242
|
});
|
|
1188
1243
|
throw new Error(CLOSED_DURING_LOAD);
|
|
1189
1244
|
}
|
|
@@ -1204,7 +1259,7 @@ export class ExtensionHost {
|
|
|
1204
1259
|
retire(old) {
|
|
1205
1260
|
const p = this.disposeQuietly(old, this.drainMs()).finally(() => {
|
|
1206
1261
|
this.retiring.delete(old);
|
|
1207
|
-
this.
|
|
1262
|
+
this.log.info("previous plugin instance retired", {
|
|
1208
1263
|
plugin: old.name,
|
|
1209
1264
|
generation: old.generation,
|
|
1210
1265
|
});
|
|
@@ -1281,7 +1336,7 @@ export class ExtensionHost {
|
|
|
1281
1336
|
* `shrinkOnly`: only remove entries (a plugin no longer desired or approved), never add new ones.
|
|
1282
1337
|
*/
|
|
1283
1338
|
async refreshPolicyExpectations(desired, opts = {}) {
|
|
1284
|
-
const snapshots = await
|
|
1339
|
+
const snapshots = await this.approvals.all();
|
|
1285
1340
|
const next = new Map();
|
|
1286
1341
|
const add = (name, set) => {
|
|
1287
1342
|
const mounts = set?.permissions?.policyHooks ?? [];
|
|
@@ -1330,7 +1385,7 @@ export class ExtensionHost {
|
|
|
1330
1385
|
async activatePendingNow() {
|
|
1331
1386
|
if (this.pendingActivations.size === 0)
|
|
1332
1387
|
return [];
|
|
1333
|
-
const approvals =
|
|
1388
|
+
const approvals = this.approvals;
|
|
1334
1389
|
const snapshots = await approvals.all();
|
|
1335
1390
|
const activated = [];
|
|
1336
1391
|
/** 本次已经试过且失败的:同一次不再重试(下一次 converge 再试)。 */
|
|
@@ -1356,7 +1411,7 @@ export class ExtensionHost {
|
|
|
1356
1411
|
if (this.closed)
|
|
1357
1412
|
throw e;
|
|
1358
1413
|
// 配置声明的插件迁移 / setup 出错时 activate 抛错(启动时内核失败);运行中只记 failed
|
|
1359
|
-
this.
|
|
1414
|
+
this.log.error("approved plugin not loaded", { plugin: name, err: e });
|
|
1360
1415
|
await this.writeStatus({
|
|
1361
1416
|
plugin: name,
|
|
1362
1417
|
version: a.manifest.version,
|
|
@@ -1370,7 +1425,7 @@ export class ExtensionHost {
|
|
|
1370
1425
|
if (this.registry.current(name)) {
|
|
1371
1426
|
activated.push(name);
|
|
1372
1427
|
progress = true;
|
|
1373
|
-
this.
|
|
1428
|
+
this.log.info("approved plugin loaded", { plugin: name });
|
|
1374
1429
|
}
|
|
1375
1430
|
else {
|
|
1376
1431
|
// 加载失败(迁移、setup)或待配置:留着,下一次 converge 重试(同一次不再试)
|
|
@@ -1453,7 +1508,7 @@ export class ExtensionHost {
|
|
|
1453
1508
|
}
|
|
1454
1509
|
/** 配置声明的插件名 → 来源(安装包不能与它们重名)。 */
|
|
1455
1510
|
declared() {
|
|
1456
|
-
return
|
|
1511
|
+
return this.registry.declared();
|
|
1457
1512
|
}
|
|
1458
1513
|
/**
|
|
1459
1514
|
* Extensions enabled in the org: `extension_org_configs.enabled` plus every required bootstrap
|
|
@@ -1496,7 +1551,7 @@ export class ExtensionHost {
|
|
|
1496
1551
|
*/
|
|
1497
1552
|
async setup(spec, timeoutMs) {
|
|
1498
1553
|
if (this.imports.record(spec.manifest.name, spec.entryUrl)) {
|
|
1499
|
-
warnUpgrades(this.
|
|
1554
|
+
warnUpgrades(this.log, this.imports);
|
|
1500
1555
|
}
|
|
1501
1556
|
let ctx;
|
|
1502
1557
|
const p = setupInstance(this.loadDeps, spec.manifest, {
|
|
@@ -1534,7 +1589,7 @@ export class ExtensionHost {
|
|
|
1534
1589
|
if (this.settingUp === ctx)
|
|
1535
1590
|
this.settingUp = undefined;
|
|
1536
1591
|
await ctx?.close().catch((err) => {
|
|
1537
|
-
this.
|
|
1592
|
+
this.log.warn("plugin context close failed", { plugin: spec.manifest.name, err });
|
|
1538
1593
|
});
|
|
1539
1594
|
if (r === "closed")
|
|
1540
1595
|
throw new Error(CLOSED_DURING_LOAD);
|
|
@@ -1574,33 +1629,14 @@ export class ExtensionHost {
|
|
|
1574
1629
|
* 实时取自注册表:调用方不要缓存实现对象(插件撤销 / 升级后旧实现不再有效)。
|
|
1575
1630
|
*/
|
|
1576
1631
|
list(extensionPointName) {
|
|
1577
|
-
|
|
1578
|
-
const tracked = TRACKED_EXTENSION_POINTS[extensionPointName];
|
|
1579
|
-
for (const i of this.registry.all()) {
|
|
1580
|
-
for (const [cap, impl] of i.provided) {
|
|
1581
|
-
if (parseExtensionPoint(cap).name === extensionPointName) {
|
|
1582
|
-
out.push({
|
|
1583
|
-
plugin: i.name,
|
|
1584
|
-
capability: cap,
|
|
1585
|
-
// 内核消费的提供方调用计入实例在途计数:停用 / 升级时先排空、到时限中止(C17)
|
|
1586
|
-
impl: tracked && typeof impl === "object" && impl !== null
|
|
1587
|
-
? trackCalls(impl, i.inflight, tracked)
|
|
1588
|
-
: impl,
|
|
1589
|
-
version: i.version,
|
|
1590
|
-
configHash: i.configHash,
|
|
1591
|
-
inflight: i.inflight,
|
|
1592
|
-
});
|
|
1593
|
-
}
|
|
1594
|
-
}
|
|
1595
|
-
}
|
|
1596
|
-
return out;
|
|
1632
|
+
return this.registry.list(extensionPointName);
|
|
1597
1633
|
}
|
|
1598
1634
|
/**
|
|
1599
1635
|
* 已加载插件的部署配置(已按清单 schema 校验,含密钥),供内核调用该插件的能力时作为 `config` 传回
|
|
1600
1636
|
* (如 `identity-source@1` 的登录配置);未加载返回 undefined。不得回显到响应或日志。
|
|
1601
1637
|
*/
|
|
1602
1638
|
deploymentConfig(plugin) {
|
|
1603
|
-
return this.registry.
|
|
1639
|
+
return this.registry.deploymentConfig(plugin);
|
|
1604
1640
|
}
|
|
1605
1641
|
/**
|
|
1606
1642
|
* 本副本拿得到的插件清单里的部署级 schema(生效实例 → 配置声明 → 安装记录准备好的候选);
|
|
@@ -1640,7 +1676,7 @@ export class ExtensionHost {
|
|
|
1640
1676
|
this.configValidity.set(plugin, schema.safeParse(raw).success);
|
|
1641
1677
|
}
|
|
1642
1678
|
catch (err) {
|
|
1643
|
-
this.
|
|
1679
|
+
this.log.warn("cannot read the stored deployment config of plugin", {
|
|
1644
1680
|
plugin,
|
|
1645
1681
|
err,
|
|
1646
1682
|
});
|
|
@@ -1656,12 +1692,12 @@ export class ExtensionHost {
|
|
|
1656
1692
|
raw = await this.rawConfigOf(plugin, schema);
|
|
1657
1693
|
}
|
|
1658
1694
|
catch (err) {
|
|
1659
|
-
this.
|
|
1695
|
+
this.log.error("cannot read the stored deployment config of plugin; keeping its current config", { plugin, err });
|
|
1660
1696
|
return "invalid";
|
|
1661
1697
|
}
|
|
1662
1698
|
const r = schema.safeParse(raw);
|
|
1663
1699
|
if (!r.success) {
|
|
1664
|
-
this.
|
|
1700
|
+
this.log.warn("plugin deployment config changed but is invalid on this replica; keeping the current config", {
|
|
1665
1701
|
plugin,
|
|
1666
1702
|
detail: toIssues(r.error)
|
|
1667
1703
|
.map((i) => `${i.path || "<root>"}: ${i.message}`)
|
|
@@ -1684,7 +1720,7 @@ export class ExtensionHost {
|
|
|
1684
1720
|
this.specs.set(plugin, { ...spec, config: next, configHash });
|
|
1685
1721
|
if (changed.every((p) => hot.has(p))) {
|
|
1686
1722
|
inst.updateConfig(next, configHash);
|
|
1687
|
-
this.
|
|
1723
|
+
this.log.info("plugin deployment config updated in place (hot fields)", {
|
|
1688
1724
|
plugin,
|
|
1689
1725
|
changed,
|
|
1690
1726
|
});
|
|
@@ -1702,11 +1738,11 @@ export class ExtensionHost {
|
|
|
1702
1738
|
this.specs.set(plugin, spec);
|
|
1703
1739
|
if (this.closed)
|
|
1704
1740
|
throw err;
|
|
1705
|
-
this.
|
|
1741
|
+
this.log.error("plugin reload after a deployment config change failed; it keeps its previous instance", { plugin, changed, err });
|
|
1706
1742
|
return "reload_failed";
|
|
1707
1743
|
}
|
|
1708
1744
|
await this.cascade(fresh.manifest.provides, drainMs);
|
|
1709
|
-
this.
|
|
1745
|
+
this.log.info("plugin reloaded after a deployment config change", { plugin, changed });
|
|
1710
1746
|
return "reload";
|
|
1711
1747
|
});
|
|
1712
1748
|
}
|
|
@@ -1716,7 +1752,7 @@ export class ExtensionHost {
|
|
|
1716
1752
|
}
|
|
1717
1753
|
/** 已加载插件的清单(按加载顺序,即依赖拓扑序)。 */
|
|
1718
1754
|
manifests() {
|
|
1719
|
-
return this.registry.
|
|
1755
|
+
return this.registry.manifests();
|
|
1720
1756
|
}
|
|
1721
1757
|
/** 已加载插件的权限集合(加载时计算,清单不可变);未加载返回 undefined。 */
|
|
1722
1758
|
permissionSet(plugin) {
|
|
@@ -1756,15 +1792,13 @@ export class ExtensionHost {
|
|
|
1756
1792
|
}
|
|
1757
1793
|
/** 安装记录里的插件名(缓存,见 {@link unavailable})。 */
|
|
1758
1794
|
installed() {
|
|
1759
|
-
const load = this.installedNames;
|
|
1760
|
-
if (!load)
|
|
1761
|
-
return Promise.resolve(new Set());
|
|
1762
1795
|
const now = Date.now();
|
|
1763
1796
|
if (!this.installedCache || now - this.installedCache.at > KNOWN_NAMES_TTL_MS) {
|
|
1764
|
-
const names =
|
|
1797
|
+
const names = this.installs
|
|
1798
|
+
.installedNames()
|
|
1765
1799
|
.then((xs) => new Set(xs))
|
|
1766
1800
|
.catch((err) => {
|
|
1767
|
-
this.
|
|
1801
|
+
this.log.warn("cannot read plugin install records for the route gate", { err });
|
|
1768
1802
|
this.installedCache = undefined;
|
|
1769
1803
|
return new Set();
|
|
1770
1804
|
});
|
|
@@ -1881,7 +1915,7 @@ export class ExtensionHost {
|
|
|
1881
1915
|
reason,
|
|
1882
1916
|
detail: null,
|
|
1883
1917
|
});
|
|
1884
|
-
this.
|
|
1918
|
+
this.log.info("plugin unloaded", { plugin, generation: inst.generation, reason });
|
|
1885
1919
|
return inst;
|
|
1886
1920
|
}
|
|
1887
1921
|
/** 新建实例并原子替换、撤销旧实例(不做连锁)。 */
|
|
@@ -1917,7 +1951,7 @@ export class ExtensionHost {
|
|
|
1917
1951
|
});
|
|
1918
1952
|
if (old)
|
|
1919
1953
|
await this.disposeQuietly(old, drainMs);
|
|
1920
|
-
this.
|
|
1954
|
+
this.log.info("plugin reloaded", { plugin, generation: inst.generation });
|
|
1921
1955
|
return inst;
|
|
1922
1956
|
}
|
|
1923
1957
|
/** 生效实例按依赖拓扑排序(解析不了时退回注册表顺序)。 */
|
|
@@ -1971,7 +2005,7 @@ export class ExtensionHost {
|
|
|
1971
2005
|
catch (err) {
|
|
1972
2006
|
if (this.closed)
|
|
1973
2007
|
throw err;
|
|
1974
|
-
this.
|
|
2008
|
+
this.log.error("dependent plugin reload failed; it keeps its previous instance", {
|
|
1975
2009
|
plugin: name,
|
|
1976
2010
|
err,
|
|
1977
2011
|
});
|
|
@@ -1996,7 +2030,7 @@ export class ExtensionHost {
|
|
|
1996
2030
|
catch (err) {
|
|
1997
2031
|
if (this.closed)
|
|
1998
2032
|
throw err;
|
|
1999
|
-
this.
|
|
2033
|
+
this.log.error("plugin reload after its dependency came back failed", {
|
|
2000
2034
|
plugin: name,
|
|
2001
2035
|
err,
|
|
2002
2036
|
});
|
|
@@ -2012,7 +2046,7 @@ export class ExtensionHost {
|
|
|
2012
2046
|
await inst.dispose({ drainMs, disposeTimeoutMs: this.disposeTimeoutMs() });
|
|
2013
2047
|
}
|
|
2014
2048
|
catch (err) {
|
|
2015
|
-
this.
|
|
2049
|
+
this.log.error("plugin dispose failed", { plugin: inst.name, err });
|
|
2016
2050
|
}
|
|
2017
2051
|
}
|
|
2018
2052
|
/**
|
|
@@ -2026,32 +2060,20 @@ export class ExtensionHost {
|
|
|
2026
2060
|
this.closed = true;
|
|
2027
2061
|
this.abort.abort();
|
|
2028
2062
|
await this.migrating?.catch(() => { });
|
|
2029
|
-
|
|
2030
|
-
await
|
|
2031
|
-
this.lifecycle.catch(() => { }),
|
|
2032
|
-
new Promise((resolve) => {
|
|
2033
|
-
timer = setTimeout(resolve, opts.lifecycleWaitMs ?? CLOSE_LIFECYCLE_WAIT_MS);
|
|
2034
|
-
}),
|
|
2035
|
-
]);
|
|
2036
|
-
clearTimeout(timer);
|
|
2063
|
+
const lifecycleWaitMs = opts.lifecycleWaitMs ?? CLOSE_LIFECYCLE_WAIT_MS;
|
|
2064
|
+
await waitWithin(this.lifecycle.catch(() => { }), lifecycleWaitMs);
|
|
2037
2065
|
// 升级时被替换、后台排空中的旧实例:同样最多等 lifecycleWaitMs,之后强制撤销(中止在途调用、不再排空),
|
|
2038
2066
|
// 赶在共用资源(Redis / PG)关闭之前
|
|
2039
2067
|
if (this.retiring.size > 0) {
|
|
2040
|
-
await Promise.
|
|
2041
|
-
Promise.allSettled([...this.retiring.values()]),
|
|
2042
|
-
new Promise((resolve) => {
|
|
2043
|
-
timer = setTimeout(resolve, opts.lifecycleWaitMs ?? CLOSE_LIFECYCLE_WAIT_MS);
|
|
2044
|
-
}),
|
|
2045
|
-
]);
|
|
2046
|
-
clearTimeout(timer);
|
|
2068
|
+
await waitWithin(Promise.allSettled([...this.retiring.values()]), lifecycleWaitMs);
|
|
2047
2069
|
await Promise.allSettled([...this.retiring.keys()].map((old) => old.hurry().catch((err) => {
|
|
2048
|
-
this.
|
|
2070
|
+
this.log.warn("plugin close failed", { plugin: old.name, err });
|
|
2049
2071
|
})));
|
|
2050
2072
|
}
|
|
2051
2073
|
const settingUp = this.settingUp;
|
|
2052
2074
|
this.settingUp = undefined;
|
|
2053
2075
|
await settingUp?.close().catch((e) => {
|
|
2054
|
-
this.
|
|
2076
|
+
this.log.error("plugin close failed", { err: e });
|
|
2055
2077
|
});
|
|
2056
2078
|
for (const inst of this.registry.all().reverse()) {
|
|
2057
2079
|
this.registry.deactivate(inst.name);
|
|
@@ -2061,11 +2083,28 @@ export class ExtensionHost {
|
|
|
2061
2083
|
waitQueueJobs: true,
|
|
2062
2084
|
disposeTimeoutMs: this.disposeTimeoutMs(),
|
|
2063
2085
|
});
|
|
2064
|
-
this.
|
|
2086
|
+
this.log.info("plugin closed", { plugin: inst.name });
|
|
2065
2087
|
}
|
|
2066
2088
|
catch (e) {
|
|
2067
|
-
this.
|
|
2089
|
+
this.log.error("plugin close failed", { plugin: inst.name, err: e });
|
|
2068
2090
|
}
|
|
2069
2091
|
}
|
|
2070
2092
|
}
|
|
2071
|
-
}
|
|
2093
|
+
};
|
|
2094
|
+
ExtensionHost = __decorate([
|
|
2095
|
+
Injectable(),
|
|
2096
|
+
__param(0, Inject(ExtensionRegistry)),
|
|
2097
|
+
__param(1, Inject(ExtensionInstalls)),
|
|
2098
|
+
__param(2, Inject(ExtensionApprovals)),
|
|
2099
|
+
__param(3, Inject(ReplicaStatusStore)),
|
|
2100
|
+
__param(4, Inject(KernelConfigService)),
|
|
2101
|
+
__param(5, Inject(KernelDb)),
|
|
2102
|
+
__param(6, Inject(REDIS)),
|
|
2103
|
+
__param(7, Inject(REDIS_SUBSCRIBER)),
|
|
2104
|
+
__param(8, Inject(KEYRING)),
|
|
2105
|
+
__param(9, Inject(EmbedTokens)),
|
|
2106
|
+
__param(10, Inject(LockService)),
|
|
2107
|
+
__param(11, Inject(KERNEL_LOGGER)),
|
|
2108
|
+
__param(12, Inject(KERNEL_APP_OPTIONS))
|
|
2109
|
+
], ExtensionHost);
|
|
2110
|
+
export { ExtensionHost };
|