@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/models/purposes.js
CHANGED
|
@@ -14,7 +14,7 @@ import { ModelRef, paramIssues } from "../agents/definition.js";
|
|
|
14
14
|
import { ApiError } from "../errors.js";
|
|
15
15
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
16
16
|
import { audit } from "../identity/audit.js";
|
|
17
|
-
import {
|
|
17
|
+
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
18
18
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
19
19
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
20
20
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
@@ -27,7 +27,7 @@ import { ProviderListError, ProviderRegistry } from "../runtime/providers.js";
|
|
|
27
27
|
/**
|
|
28
28
|
* 模型用途映射(C9):内核与插件按「用途」取模型,不在代码里写死模型。
|
|
29
29
|
* - 用途 = 内核用途 {@link KERNEL_PURPOSES}(目前只有评委 `eval`),或已加载插件 `permissions.models` 声明的;
|
|
30
|
-
* - 映射 = 部署默认(`org_id` 为 null
|
|
30
|
+
* - 映射 = 部署默认(`org_id` 为 null,超级管理员设)+ 组织覆盖(组织管理员设,`org.models.manage`);
|
|
31
31
|
* 生效的映射先取组织覆盖、再取部署默认,都没有 → `model.unconfigured`;
|
|
32
32
|
* - 目标模型按部署范围解析(与运行时一致),参数按目标模型自己的声明严格校验;不做模型白名单;
|
|
33
33
|
* - 每次都查 PG,不在进程内缓存(多副本下改映射立即生效)。`ctx.models` 仍预留,插件暂不能调用。
|
|
@@ -41,22 +41,36 @@ export const KERNEL_PURPOSES = [
|
|
|
41
41
|
{ purpose: "eval", kind: "chat", label: { zh: "评测评委", en: "Eval judge" } },
|
|
42
42
|
/** Conversation titles (UI refresh B); unmapped → the conversation's current chat model. */
|
|
43
43
|
{ purpose: "title", kind: "chat", label: { zh: "会话标题", en: "Conversation titles" } },
|
|
44
|
+
/**
|
|
45
|
+
* The `WebFetch` extraction call (web tools spec §5); unmapped → the calling conversation's
|
|
46
|
+
* current chat model (a sub-agent's call: the sub-agent's).
|
|
47
|
+
*/
|
|
48
|
+
{ purpose: "web_fetch", kind: "chat", label: { zh: "网页提取", en: "Web page extraction" } },
|
|
44
49
|
{
|
|
45
50
|
purpose: "subagent_fast",
|
|
46
51
|
kind: "chat",
|
|
47
|
-
label: { zh: "
|
|
52
|
+
label: { zh: "子智能体:快速", en: "Sub-agent: fast" },
|
|
48
53
|
},
|
|
49
54
|
{
|
|
50
55
|
purpose: "subagent_standard",
|
|
51
56
|
kind: "chat",
|
|
52
|
-
label: { zh: "
|
|
57
|
+
label: { zh: "子智能体:标准", en: "Sub-agent: standard" },
|
|
53
58
|
},
|
|
54
59
|
{
|
|
55
60
|
purpose: "subagent_capable",
|
|
56
61
|
kind: "chat",
|
|
57
|
-
label: { zh: "
|
|
62
|
+
label: { zh: "子智能体:最强", en: "Sub-agent: capable" },
|
|
58
63
|
},
|
|
59
64
|
];
|
|
65
|
+
/** {@link PurposeListing}s of `views`, the display names read in one call. */
|
|
66
|
+
export async function withDeclaredByNames(views, names) {
|
|
67
|
+
const plugins = views.map((v) => v.declaredBy).filter((d) => d !== "kernel");
|
|
68
|
+
const found = await names.many(plugins);
|
|
69
|
+
return views.map((v) => ({
|
|
70
|
+
...v,
|
|
71
|
+
declaredByName: v.declaredBy === "kernel" ? null : (found.get(v.declaredBy) ?? null),
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
60
74
|
/** `PUT …/model-purposes/:purpose` 的 body:设映射,或 `target: null` 清除。 */
|
|
61
75
|
export const PURPOSE_PUT = z
|
|
62
76
|
.object({
|
|
@@ -201,7 +215,7 @@ let ModelPurposesService = class ModelPurposesService {
|
|
|
201
215
|
const [view] = await this.views([decl], orgId ?? undefined);
|
|
202
216
|
return view;
|
|
203
217
|
}
|
|
204
|
-
/** The mapping write of {@link set}, under the
|
|
218
|
+
/** The mapping write of {@link set}, under the super admin or org lock. */
|
|
205
219
|
async write(orgId, purpose, target, actor, actorTokenId) {
|
|
206
220
|
if (orgId === null)
|
|
207
221
|
await this.adminLock.lockAndAuthorize(actor);
|
|
@@ -238,7 +252,7 @@ let ModelPurposesService = class ModelPurposesService {
|
|
|
238
252
|
detail: { scope: orgId === null ? "deployment" : "org", target },
|
|
239
253
|
});
|
|
240
254
|
}
|
|
241
|
-
/** 设置(或 `null`
|
|
255
|
+
/** 设置(或 `null` 清除)部署默认;只有超级管理员(事务内复核)。 */
|
|
242
256
|
setDefault(purpose, target, actor, actorTokenId) {
|
|
243
257
|
return this.set(null, purpose, target, actor, actorTokenId);
|
|
244
258
|
}
|
|
@@ -254,6 +268,27 @@ let ModelPurposesService = class ModelPurposesService {
|
|
|
254
268
|
}
|
|
255
269
|
return view.effective;
|
|
256
270
|
}
|
|
271
|
+
/** The target a {@link chat} call on `purpose` uses: the mapping, else `fallback` when unmapped. */
|
|
272
|
+
async chatTarget(orgId, purpose, fallback) {
|
|
273
|
+
try {
|
|
274
|
+
return await this.resolve(orgId, purpose);
|
|
275
|
+
}
|
|
276
|
+
catch (e) {
|
|
277
|
+
if (!(e instanceof ApiError && e.code === "model.unconfigured") || !fallback)
|
|
278
|
+
throw e;
|
|
279
|
+
return fallback;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* The limits of the model a {@link chat} call on `purpose` would use now (the same mapping and
|
|
284
|
+
* `fallback` rule): its context window and output cap, so a caller can size its request (e.g.
|
|
285
|
+
* the `WebFetch` page) before the call. Fails as `chat` does before sending.
|
|
286
|
+
*/
|
|
287
|
+
async chatLimits(orgId, purpose, opts = {}) {
|
|
288
|
+
const target = await this.chatTarget(orgId, purpose, opts.fallback);
|
|
289
|
+
const { info } = await this.providers.resolve(target.model);
|
|
290
|
+
return { contextWindow: info.contextWindow, maxOutputTokens: info.maxOutputTokens };
|
|
291
|
+
}
|
|
257
292
|
/**
|
|
258
293
|
* 按用途发一次对话请求:解析映射、按目标模型的声明宽松处理参数(补默认值,与运行时一致),用 `consumeModelStream`
|
|
259
294
|
* 收完(只有流空闲看门狗)。输出上限取 `min(req.maxOutputTokens, 目标模型的 maxOutputTokens)`。
|
|
@@ -261,22 +296,17 @@ let ModelPurposesService = class ModelPurposesService {
|
|
|
261
296
|
* `opts.fallback`: the target used when the purpose is not mapped (`model.unconfigured`).
|
|
262
297
|
* `opts.beforeSend`: called with the resolved target and the final request just before sending;
|
|
263
298
|
* what it throws is thrown as is (a pre-send failure, e.g. a denied `model.request` hook).
|
|
299
|
+
* `opts.paramDefaults`: values for parameters the target does not set, kept only where the
|
|
300
|
+
* target model declares the key and the value fits it (e.g. `thinking: "off"` for a short call).
|
|
264
301
|
*/
|
|
265
302
|
async chat(orgId, purpose, req, signal, opts = {}) {
|
|
266
|
-
|
|
267
|
-
try {
|
|
268
|
-
target = await this.resolve(orgId, purpose);
|
|
269
|
-
}
|
|
270
|
-
catch (e) {
|
|
271
|
-
if (!(e instanceof ApiError && e.code === "model.unconfigured") || !opts.fallback)
|
|
272
|
-
throw e;
|
|
273
|
-
target = opts.fallback;
|
|
274
|
-
}
|
|
303
|
+
const target = await this.chatTarget(orgId, purpose, opts.fallback);
|
|
275
304
|
const { provider, info } = await this.providers.resolve(target.model);
|
|
276
305
|
const request = {
|
|
277
306
|
...req,
|
|
278
307
|
model: info.id,
|
|
279
|
-
|
|
308
|
+
// undeclared or unfitting defaults are dropped like any other parameter
|
|
309
|
+
params: sanitizeParams(info.parameters, { ...opts.paramDefaults, ...target.params }).value,
|
|
280
310
|
// 输出上限不超过目标模型自己的上限(与运行时 assembleModelRequest 一致)
|
|
281
311
|
maxOutputTokens: Math.min(req.maxOutputTokens, info.maxOutputTokens),
|
|
282
312
|
};
|
|
@@ -311,7 +341,7 @@ ModelPurposesService = __decorate([
|
|
|
311
341
|
__param(2, Inject(KernelConfigService)),
|
|
312
342
|
__param(3, Inject(ProviderRegistry)),
|
|
313
343
|
__param(4, Inject(TransactionHost)),
|
|
314
|
-
__param(5, Inject(
|
|
344
|
+
__param(5, Inject(SuperAdminLock)),
|
|
315
345
|
__param(6, Inject(OrgLock))
|
|
316
346
|
], ModelPurposesService);
|
|
317
347
|
export { ModelPurposesService };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Queue } from "bullmq";
|
|
2
2
|
import type { Redis } from "ioredis";
|
|
3
|
+
import { EffectiveConfigs } from "../extensions/effective-config.js";
|
|
3
4
|
import { OrgExtensionConfigs } from "../extensions/org-config.js";
|
|
4
5
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
5
6
|
import { ExternalIdentities } from "../identity/external.js";
|
|
@@ -35,9 +36,11 @@ export declare const DIRECTORY_MAX_PAGES = 10000;
|
|
|
35
36
|
export type DirectorySyncTrigger = "schedule" | "changed" | "manual";
|
|
36
37
|
/**
|
|
37
38
|
* 不同步的原因(陈旧任务、插件已停用 / 配置不再有效、组织已删除、另一同步在跑;`not_configured`:插件的
|
|
38
|
-
* `Directory.configured` 说这份组织配置没配好通讯录,Ruling A28
|
|
39
|
+
* `Directory.configured` 说这份组织配置没配好通讯录,Ruling A28,静默跳过)。`needs_config`: the
|
|
40
|
+
* extension's effective deployment config for the org is not valid (layering spec A §6): skipped
|
|
41
|
+
* silently like `not_configured`; the org admin sees the extension as needing configuration.
|
|
39
42
|
*/
|
|
40
|
-
export type DirectorySkipReason = "plugin_unavailable" | "org_not_found" | "not_enabled" | "config_invalid" | "not_configured" | "locked";
|
|
43
|
+
export type DirectorySkipReason = "plugin_unavailable" | "org_not_found" | "not_enabled" | "config_invalid" | "not_configured" | "needs_config" | "locked";
|
|
41
44
|
export type DirectorySyncResult = {
|
|
42
45
|
status: "skipped";
|
|
43
46
|
reason: DirectorySkipReason;
|
|
@@ -122,18 +125,23 @@ export declare class DirectorySync {
|
|
|
122
125
|
private readonly redis;
|
|
123
126
|
private readonly registry;
|
|
124
127
|
private readonly orgConfigs;
|
|
128
|
+
private readonly effective;
|
|
125
129
|
private readonly external;
|
|
126
130
|
private readonly offboarding;
|
|
127
131
|
private readonly orgLock;
|
|
128
132
|
private readonly queue;
|
|
129
133
|
readonly lockService: LockService;
|
|
130
134
|
readonly log: KernelLogger;
|
|
131
|
-
constructor(db: KernelDb, txHost: TransactionHost, redis: Redis, registry: Pick<ExtensionRegistry, "list">, orgConfigs: Pick<OrgExtensionConfigs, "get">, external: Pick<ExternalIdentities, "resolve">, offboarding: Pick<Offboarding, "offboard" | "afterOffboard">, orgLock: OrgLock, queue: Pick<Queue, "add">, lockService: LockService, log: KernelLogger);
|
|
135
|
+
constructor(db: KernelDb, txHost: TransactionHost, redis: Redis, registry: Pick<ExtensionRegistry, "list">, orgConfigs: Pick<OrgExtensionConfigs, "get">, effective: Pick<EffectiveConfigs, "get">, external: Pick<ExternalIdentities, "resolve">, offboarding: Pick<Offboarding, "offboard" | "afterOffboard">, orgLock: OrgLock, queue: Pick<Queue, "add">, lockService: LockService, log: KernelLogger);
|
|
132
136
|
/** A `directory-sync` job (dispatched by `MaintenanceProcessor`). */
|
|
133
137
|
runSyncJob(data: SyncJobData): Promise<void>;
|
|
134
138
|
/** 插件提供的 `directory@1`;未加载或不提供时 undefined。 */
|
|
135
139
|
private provider;
|
|
136
|
-
/**
|
|
140
|
+
/**
|
|
141
|
+
* The org exists, the extension provides a directory, is enabled in the org, its org config
|
|
142
|
+
* satisfies the schema (reuses the `OrgExtensionConfigs.get` validation) and its effective
|
|
143
|
+
* deployment config for the org is valid (layering spec A §6).
|
|
144
|
+
*/
|
|
137
145
|
private eligible;
|
|
138
146
|
/**
|
|
139
147
|
* 投递一次 `directory_changed` 同步(按分钟桶去重);返回 job id。入站 `directory_changed` 经
|
|
@@ -146,7 +154,8 @@ export declare class DirectorySync {
|
|
|
146
154
|
* Manual trigger by an admin: re-checks `org.members.manage` live under the org row lock, then that
|
|
147
155
|
* the extension can sync (does not provide a directory -> `extension.not_found`, not enabled ->
|
|
148
156
|
* `extension.not_enabled`, config no longer valid -> `extension.config_invalid`, the extension says
|
|
149
|
-
* the directory is not configured -> `directory.not_configured`, Ruling A28
|
|
157
|
+
* the directory is not configured -> `directory.not_configured`, Ruling A28; the effective config
|
|
158
|
+
* is not valid in the org -> `extension.needs_config`, layering spec A §6), and enqueues a sync
|
|
150
159
|
* job with a unique id.
|
|
151
160
|
*/
|
|
152
161
|
request(orgId: string, plugin: string, actorAccountId: string, actorTokenId?: string): Promise<{
|
|
@@ -12,6 +12,7 @@ import { DIRECTORY_EXTENSION_POINT, } from "@capybara-hq/plugin-sdk";
|
|
|
12
12
|
import { getQueueToken } from "@nestjs/bullmq";
|
|
13
13
|
import { Inject, Injectable } from "@nestjs/common";
|
|
14
14
|
import { ApiError } from "../errors.js";
|
|
15
|
+
import { EffectiveConfigs } from "../extensions/effective-config.js";
|
|
15
16
|
import { enabledExtensionsByOrg } from "../extensions/enabled.js";
|
|
16
17
|
import { OrgExtensionConfigs } from "../extensions/org-config.js";
|
|
17
18
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
@@ -80,6 +81,8 @@ export function directorySyncJobId(orgId, plugin, trigger, now = new Date()) {
|
|
|
80
81
|
return `${base}-manual-${randomUUID()}`;
|
|
81
82
|
}
|
|
82
83
|
}
|
|
84
|
+
/** Skips that log nothing and enqueue nothing: Ruling A28 and an org needing configuration. */
|
|
85
|
+
const silentSkip = (reason) => reason === "not_configured" || reason === "needs_config";
|
|
83
86
|
/** 组织已删除(同步途中):停止本轮。 */
|
|
84
87
|
class OrgGone extends Error {
|
|
85
88
|
}
|
|
@@ -122,18 +125,20 @@ let DirectorySync = class DirectorySync {
|
|
|
122
125
|
redis;
|
|
123
126
|
registry;
|
|
124
127
|
orgConfigs;
|
|
128
|
+
effective;
|
|
125
129
|
external;
|
|
126
130
|
offboarding;
|
|
127
131
|
orgLock;
|
|
128
132
|
queue;
|
|
129
133
|
lockService;
|
|
130
134
|
log;
|
|
131
|
-
constructor(db, txHost, redis, registry, orgConfigs, external, offboarding, orgLock, queue, lockService, log) {
|
|
135
|
+
constructor(db, txHost, redis, registry, orgConfigs, effective, external, offboarding, orgLock, queue, lockService, log) {
|
|
132
136
|
this.db = db;
|
|
133
137
|
this.txHost = txHost;
|
|
134
138
|
this.redis = redis;
|
|
135
139
|
this.registry = registry;
|
|
136
140
|
this.orgConfigs = orgConfigs;
|
|
141
|
+
this.effective = effective;
|
|
137
142
|
this.external = external;
|
|
138
143
|
this.offboarding = offboarding;
|
|
139
144
|
this.orgLock = orgLock;
|
|
@@ -144,8 +149,8 @@ let DirectorySync = class DirectorySync {
|
|
|
144
149
|
/** A `directory-sync` job (dispatched by `MaintenanceProcessor`). */
|
|
145
150
|
async runSyncJob(data) {
|
|
146
151
|
const r = await this.sync(data.orgId, data.plugin, data);
|
|
147
|
-
// 通讯录未配置(Ruling A28
|
|
148
|
-
if (r.status === "skipped" && r.reason
|
|
152
|
+
// 通讯录未配置(Ruling A28)and an org needing configuration (spec A §6) are skipped silently
|
|
153
|
+
if (r.status === "skipped" && !silentSkip(r.reason)) {
|
|
149
154
|
this.log.info("directory sync skipped", {
|
|
150
155
|
orgId: data.orgId,
|
|
151
156
|
plugin: data.plugin,
|
|
@@ -159,7 +164,11 @@ let DirectorySync = class DirectorySync {
|
|
|
159
164
|
.list("directory")
|
|
160
165
|
.find((e) => e.plugin === plugin && e.capability === DIRECTORY_EXTENSION_POINT)?.impl;
|
|
161
166
|
}
|
|
162
|
-
/**
|
|
167
|
+
/**
|
|
168
|
+
* The org exists, the extension provides a directory, is enabled in the org, its org config
|
|
169
|
+
* satisfies the schema (reuses the `OrgExtensionConfigs.get` validation) and its effective
|
|
170
|
+
* deployment config for the org is valid (layering spec A §6).
|
|
171
|
+
*/
|
|
163
172
|
async eligible(orgId, plugin) {
|
|
164
173
|
const directory = this.provider(plugin);
|
|
165
174
|
if (!directory)
|
|
@@ -186,11 +195,21 @@ let DirectorySync = class DirectorySync {
|
|
|
186
195
|
}
|
|
187
196
|
if (!cfg?.enabled)
|
|
188
197
|
return { ok: false, reason: "not_enabled" };
|
|
198
|
+
let effective;
|
|
199
|
+
try {
|
|
200
|
+
effective = await this.effective.get(orgId, plugin);
|
|
201
|
+
}
|
|
202
|
+
catch (err) {
|
|
203
|
+
this.log.warn("directory sync: cannot read the effective config", { orgId, plugin, err });
|
|
204
|
+
return { ok: false, reason: "config_invalid" };
|
|
205
|
+
}
|
|
206
|
+
if (!effective.ok)
|
|
207
|
+
return { ok: false, reason: "needs_config" };
|
|
189
208
|
// Ruling A28:插件说通讯录没配好(组织只用它的别的能力)→ 不同步;插件实现出错按未配置处理
|
|
190
209
|
if (directory.configured !== undefined) {
|
|
191
210
|
let configured = false;
|
|
192
211
|
try {
|
|
193
|
-
configured = directory.configured(cfg.config) === true;
|
|
212
|
+
configured = directory.configured(cfg.config, effective.config) === true;
|
|
194
213
|
}
|
|
195
214
|
catch {
|
|
196
215
|
configured = false;
|
|
@@ -198,7 +217,7 @@ let DirectorySync = class DirectorySync {
|
|
|
198
217
|
if (!configured)
|
|
199
218
|
return { ok: false, reason: "not_configured" };
|
|
200
219
|
}
|
|
201
|
-
return { ok: true, directory, orgConfig: cfg.config };
|
|
220
|
+
return { ok: true, directory, orgConfig: cfg.config, config: effective.config };
|
|
202
221
|
}
|
|
203
222
|
/**
|
|
204
223
|
* 投递一次 `directory_changed` 同步(按分钟桶去重);返回 job id。入站 `directory_changed` 经
|
|
@@ -207,7 +226,7 @@ let DirectorySync = class DirectorySync {
|
|
|
207
226
|
*/
|
|
208
227
|
async enqueue(orgId, plugin, now = new Date()) {
|
|
209
228
|
const e = await this.eligible(orgId, plugin);
|
|
210
|
-
if (!e.ok && e.reason
|
|
229
|
+
if (!e.ok && silentSkip(e.reason))
|
|
211
230
|
return undefined;
|
|
212
231
|
return this.addJob(orgId, plugin, "changed", directorySyncJobId(orgId, plugin, "changed", now));
|
|
213
232
|
}
|
|
@@ -234,7 +253,8 @@ let DirectorySync = class DirectorySync {
|
|
|
234
253
|
* Manual trigger by an admin: re-checks `org.members.manage` live under the org row lock, then that
|
|
235
254
|
* the extension can sync (does not provide a directory -> `extension.not_found`, not enabled ->
|
|
236
255
|
* `extension.not_enabled`, config no longer valid -> `extension.config_invalid`, the extension says
|
|
237
|
-
* the directory is not configured -> `directory.not_configured`, Ruling A28
|
|
256
|
+
* the directory is not configured -> `directory.not_configured`, Ruling A28; the effective config
|
|
257
|
+
* is not valid in the org -> `extension.needs_config`, layering spec A §6), and enqueues a sync
|
|
238
258
|
* job with a unique id.
|
|
239
259
|
*/
|
|
240
260
|
async request(orgId, plugin, actorAccountId, actorTokenId) {
|
|
@@ -252,6 +272,8 @@ let DirectorySync = class DirectorySync {
|
|
|
252
272
|
throw new ApiError("extension.config_invalid", `Invalid organization config for extension ${plugin}`);
|
|
253
273
|
case "not_configured":
|
|
254
274
|
throw new ApiError("directory.not_configured", `The directory of extension ${plugin} is not configured for this organization`);
|
|
275
|
+
case "needs_config":
|
|
276
|
+
throw new ApiError("extension.needs_config", `Extension ${plugin} needs configuration in this organization`);
|
|
255
277
|
}
|
|
256
278
|
}
|
|
257
279
|
const jobId = await this.addJob(orgId, plugin, "manual", directorySyncJobId(orgId, plugin, "manual"), { accountId: actorAccountId, tokenId: actorTokenId });
|
|
@@ -324,7 +346,7 @@ let DirectorySync = class DirectorySync {
|
|
|
324
346
|
// 锁丢了(续租失败、过期后被他人取得):停止本轮,不再移除任何人
|
|
325
347
|
const signal = lease.lost;
|
|
326
348
|
try {
|
|
327
|
-
return await this.run(orgId, plugin, e.directory, e.orgConfig, signal, opts);
|
|
349
|
+
return await this.run(orgId, plugin, e.directory, e.orgConfig, e.config, signal, opts);
|
|
328
350
|
}
|
|
329
351
|
finally {
|
|
330
352
|
await lease.release().catch(() => { });
|
|
@@ -346,7 +368,7 @@ let DirectorySync = class DirectorySync {
|
|
|
346
368
|
this.log.warn("directory sync: cannot enqueue follow-up sync", { orgId, plugin, err });
|
|
347
369
|
}
|
|
348
370
|
}
|
|
349
|
-
async run(orgId, plugin, directory, orgConfig, signal, opts) {
|
|
371
|
+
async run(orgId, plugin, directory, orgConfig, config, signal, opts) {
|
|
350
372
|
const source = `directory:${plugin}`;
|
|
351
373
|
const counts = { added: 0, removed: 0, skippedLastOwner: 0, failed: 0, total: 0 };
|
|
352
374
|
/** 本轮仍在职的账号(只在本次任务内使用)。 */
|
|
@@ -363,6 +385,7 @@ let DirectorySync = class DirectorySync {
|
|
|
363
385
|
signal.throwIfAborted();
|
|
364
386
|
const r = await directory.listMembers({
|
|
365
387
|
orgConfig,
|
|
388
|
+
config,
|
|
366
389
|
...(cursor !== undefined && { cursor }),
|
|
367
390
|
signal: AbortSignal.any([signal, AbortSignal.timeout(DIRECTORY_PAGE_TIMEOUT_MS)]),
|
|
368
391
|
});
|
|
@@ -409,7 +432,7 @@ let DirectorySync = class DirectorySync {
|
|
|
409
432
|
if (!still.ok) {
|
|
410
433
|
partial = true;
|
|
411
434
|
// 途中通讯录配置被清空(Ruling A28):照样不移除,但不记警告
|
|
412
|
-
if (still.reason
|
|
435
|
+
if (!silentSkip(still.reason)) {
|
|
413
436
|
this.log.warn("directory sync: plugin no longer eligible before removals", {
|
|
414
437
|
orgId,
|
|
415
438
|
plugin,
|
|
@@ -609,12 +632,13 @@ DirectorySync = __decorate([
|
|
|
609
632
|
__param(2, Inject(REDIS)),
|
|
610
633
|
__param(3, Inject(ExtensionRegistry)),
|
|
611
634
|
__param(4, Inject(OrgExtensionConfigs)),
|
|
612
|
-
__param(5, Inject(
|
|
613
|
-
__param(6, Inject(
|
|
614
|
-
__param(7, Inject(
|
|
615
|
-
__param(8, Inject(
|
|
616
|
-
__param(9, Inject(
|
|
617
|
-
__param(10, Inject(
|
|
635
|
+
__param(5, Inject(EffectiveConfigs)),
|
|
636
|
+
__param(6, Inject(ExternalIdentities)),
|
|
637
|
+
__param(7, Inject(Offboarding)),
|
|
638
|
+
__param(8, Inject(OrgLock)),
|
|
639
|
+
__param(9, Inject(getQueueToken(MAINTENANCE_QUEUE_NAME))),
|
|
640
|
+
__param(10, Inject(LockService)),
|
|
641
|
+
__param(11, Inject(KERNEL_LOGGER))
|
|
618
642
|
], DirectorySync);
|
|
619
643
|
export { DirectorySync };
|
|
620
644
|
/** The hourly directory scan ({@link DirectorySync.scan}), once per tick across replicas; a worker-role job (`WorkerModule`). */
|
|
@@ -30,8 +30,8 @@ export interface OffboardResult {
|
|
|
30
30
|
runs: InFlightRun[];
|
|
31
31
|
/** 负责的 agent 转交给的所有者;没有转交时为 null。 */
|
|
32
32
|
newOwnerId: string | null;
|
|
33
|
-
/**
|
|
34
|
-
|
|
33
|
+
/** The person's environments in the org, soft-deleted here; destroyed by a job after commit. */
|
|
34
|
+
environments: string[];
|
|
35
35
|
/** Conversations whose queued messages were deleted (`changed: queue` after commit). */
|
|
36
36
|
queueConversations: string[];
|
|
37
37
|
}
|
|
@@ -66,7 +66,7 @@ export declare class Offboarding {
|
|
|
66
66
|
private readonly redis;
|
|
67
67
|
private readonly registry;
|
|
68
68
|
private readonly eventLog;
|
|
69
|
-
/** The departed member's
|
|
69
|
+
/** The departed member's environments: one-off maintenance jobs, destroyed by a worker. */
|
|
70
70
|
private readonly sandboxJobs;
|
|
71
71
|
/** Stops the departed member's runs (`by: null`, a system action). */
|
|
72
72
|
private readonly runs;
|
|
@@ -75,7 +75,7 @@ export declare class Offboarding {
|
|
|
75
75
|
private readonly questions;
|
|
76
76
|
readonly log: KernelLogger;
|
|
77
77
|
constructor(db: KernelDb, txHost: TransactionHost, sessions: Pick<SessionService, "markRevoked">, redis: Pick<Redis, "set" | "exists">, registry: Pick<ExtensionRegistry, "list">, eventLog: Pick<EventLog, "notify" | "publishChanged">,
|
|
78
|
-
/** The departed member's
|
|
78
|
+
/** The departed member's environments: one-off maintenance jobs, destroyed by a worker. */
|
|
79
79
|
sandboxJobs: Pick<SandboxJobs, "destroy">,
|
|
80
80
|
/** Stops the departed member's runs (`by: null`, a system action). */
|
|
81
81
|
runs: OffboardingRunControl, credentials: Pick<Credentials, "clearAccount">, approvals: Pick<ApprovalsService, "cancelPendingFor">, questions: Pick<QuestionsService, "cancelPendingFor">, log: KernelLogger);
|
|
@@ -83,7 +83,9 @@ export declare class Offboarding {
|
|
|
83
83
|
* In the caller's transaction (`mandatory`: the caller holds the org row lock, order org row →
|
|
84
84
|
* membership, and did the "last owner" checks):
|
|
85
85
|
* 1. 删除成员关系(非成员 → `member.not_found`;删后组织没有 owner → `org.last_owner`),清空指向该组织的会话当前组织;
|
|
86
|
-
* 2.
|
|
86
|
+
* 2. Removal and directory offboarding revoke **every** session and personal token of the
|
|
87
|
+
* account (both are account-wide, so conservatively all); a person who leaves (`left`) keeps
|
|
88
|
+
* them, and the session's current org is cleared (the membership check ends the access);
|
|
87
89
|
* 3. 删除其在该组织所有连接器上的个人凭据;
|
|
88
90
|
* 4. 取消其作为处理人的 pending 审批与提问(写 cancelled 事件),记下此人在该组织进行中的运行(提交后中止);
|
|
89
91
|
* 5. 其负责的该组织 agent 转给组织所有者(最早加入的 owner)并置 `needs_reassignment = true`;
|
|
@@ -93,7 +95,9 @@ export declare class Offboarding {
|
|
|
93
95
|
* 以及成员关系自身的 `directory:<插件>` 来源,不论此人当初是不是由通讯录加入(手动重新加入后再被移出也不会被同步加回);
|
|
94
96
|
* 同步不再把此人加回,直到有人手动重新加入({@link MembersService.add} 删除排除);
|
|
95
97
|
* 8. 审计 `org.member.offboarded`;
|
|
96
|
-
* 9.
|
|
98
|
+
* 9. Soft-deletes the person's environments in the org and clears their default row (the
|
|
99
|
+
* instances and files are destroyed after the commit, best effort; the hourly sweep finishes
|
|
100
|
+
* any left).
|
|
97
101
|
*/
|
|
98
102
|
offboard(orgId: string, accountId: string, reason: OffboardReason, actor?: {
|
|
99
103
|
actorAccountId?: string;
|
|
@@ -104,8 +108,8 @@ export declare class Offboarding {
|
|
|
104
108
|
/**
|
|
105
109
|
* After the commit (callers register it with the infra `afterCommit` inside their transaction):
|
|
106
110
|
* writes the session revocation markers, publishes the cancelled events, stops the person's
|
|
107
|
-
* runs in the org and schedules destroying their
|
|
108
|
-
*
|
|
111
|
+
* runs in the org and schedules destroying their environments. A failing step only logs a
|
|
112
|
+
* warning.
|
|
109
113
|
*/
|
|
110
114
|
afterOffboard(r: OffboardResult): Promise<void>;
|
|
111
115
|
/**
|
package/dist/orgs/offboarding.js
CHANGED
|
@@ -10,6 +10,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { DIRECTORY_EXTENSION_POINT } from "@capybara-hq/plugin-sdk";
|
|
11
11
|
import { Inject, Injectable } from "@nestjs/common";
|
|
12
12
|
import { sql } from "kysely";
|
|
13
|
+
import { retargetSetupRequests } from "../agents/pending-connector-requests.js";
|
|
13
14
|
import { EventLog } from "../conversations/event-log.js";
|
|
14
15
|
import { ApiError } from "../errors.js";
|
|
15
16
|
import { enabledExtensionsQuery } from "../extensions/enabled.js";
|
|
@@ -62,7 +63,7 @@ let Offboarding = class Offboarding {
|
|
|
62
63
|
questions;
|
|
63
64
|
log;
|
|
64
65
|
constructor(db, txHost, sessions, redis, registry, eventLog,
|
|
65
|
-
/** The departed member's
|
|
66
|
+
/** The departed member's environments: one-off maintenance jobs, destroyed by a worker. */
|
|
66
67
|
sandboxJobs,
|
|
67
68
|
/** Stops the departed member's runs (`by: null`, a system action). */
|
|
68
69
|
runs, credentials, approvals, questions, log) {
|
|
@@ -83,7 +84,9 @@ let Offboarding = class Offboarding {
|
|
|
83
84
|
* In the caller's transaction (`mandatory`: the caller holds the org row lock, order org row →
|
|
84
85
|
* membership, and did the "last owner" checks):
|
|
85
86
|
* 1. 删除成员关系(非成员 → `member.not_found`;删后组织没有 owner → `org.last_owner`),清空指向该组织的会话当前组织;
|
|
86
|
-
* 2.
|
|
87
|
+
* 2. Removal and directory offboarding revoke **every** session and personal token of the
|
|
88
|
+
* account (both are account-wide, so conservatively all); a person who leaves (`left`) keeps
|
|
89
|
+
* them, and the session's current org is cleared (the membership check ends the access);
|
|
87
90
|
* 3. 删除其在该组织所有连接器上的个人凭据;
|
|
88
91
|
* 4. 取消其作为处理人的 pending 审批与提问(写 cancelled 事件),记下此人在该组织进行中的运行(提交后中止);
|
|
89
92
|
* 5. 其负责的该组织 agent 转给组织所有者(最早加入的 owner)并置 `needs_reassignment = true`;
|
|
@@ -93,7 +96,9 @@ let Offboarding = class Offboarding {
|
|
|
93
96
|
* 以及成员关系自身的 `directory:<插件>` 来源,不论此人当初是不是由通讯录加入(手动重新加入后再被移出也不会被同步加回);
|
|
94
97
|
* 同步不再把此人加回,直到有人手动重新加入({@link MembersService.add} 删除排除);
|
|
95
98
|
* 8. 审计 `org.member.offboarded`;
|
|
96
|
-
* 9.
|
|
99
|
+
* 9. Soft-deletes the person's environments in the org and clears their default row (the
|
|
100
|
+
* instances and files are destroyed after the commit, best effort; the hourly sweep finishes
|
|
101
|
+
* any left).
|
|
97
102
|
*/
|
|
98
103
|
async offboard(orgId, accountId, reason, actor = {}) {
|
|
99
104
|
const deleted = await this.db
|
|
@@ -150,21 +155,29 @@ let Offboarding = class Offboarding {
|
|
|
150
155
|
.where("account_id", "=", accountId)
|
|
151
156
|
.where("current_org_id", "=", orgId)
|
|
152
157
|
.execute();
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
.
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
.
|
|
158
|
+
// A person who leaves keeps their sign-in and personal tokens: the org guard reads the
|
|
159
|
+
// membership on every request, so access to this org ends with the row above, and their other
|
|
160
|
+
// orgs keep working. Removal and directory offboarding revoke both (account-wide, conservative).
|
|
161
|
+
const revoke = reason !== "left";
|
|
162
|
+
const sessions = revoke
|
|
163
|
+
? await this.db
|
|
164
|
+
.updateTable("sessions")
|
|
165
|
+
.set({ revoked_at: sql `now()` })
|
|
166
|
+
.where("account_id", "=", accountId)
|
|
167
|
+
.where("revoked_at", "is", null)
|
|
168
|
+
.returning("id")
|
|
169
|
+
.execute()
|
|
170
|
+
: [];
|
|
171
|
+
const tokens = revoke
|
|
172
|
+
? await this.db
|
|
173
|
+
.updateTable("api_tokens")
|
|
174
|
+
.set({ revoked_at: sql `now()` })
|
|
175
|
+
.where("kind", "=", "personal")
|
|
176
|
+
.where("account_id", "=", accountId)
|
|
177
|
+
.where("revoked_at", "is", null)
|
|
178
|
+
.returning("id")
|
|
179
|
+
.execute()
|
|
180
|
+
: [];
|
|
168
181
|
// in this transaction (the approvals and questions services join it: `mandatory`)
|
|
169
182
|
const credentials = await this.credentials.clearAccount(orgId, accountId);
|
|
170
183
|
const approvals = await this.approvals.cancelPendingFor(orgId, accountId);
|
|
@@ -200,6 +213,8 @@ let Offboarding = class Offboarding {
|
|
|
200
213
|
.where("deleted_at", "is", null)
|
|
201
214
|
.returning("id")
|
|
202
215
|
.execute();
|
|
216
|
+
// their connector setup requests follow them to the org owner (ruling P4-T6-4)
|
|
217
|
+
await retargetSetupRequests(this.db.db, agents.map((a) => a.id), owner.account_id);
|
|
203
218
|
const threads = await this.db
|
|
204
219
|
.updateTable("channel_threads")
|
|
205
220
|
.set({ archived_at: sql `now()` })
|
|
@@ -244,13 +259,19 @@ let Offboarding = class Offboarding {
|
|
|
244
259
|
.where("id", "in", queueConversations)
|
|
245
260
|
.execute();
|
|
246
261
|
}
|
|
247
|
-
const
|
|
248
|
-
.
|
|
249
|
-
.
|
|
250
|
-
.
|
|
251
|
-
.where("
|
|
252
|
-
.where("
|
|
253
|
-
.where("
|
|
262
|
+
const environments = await this.db
|
|
263
|
+
.updateTable("environments")
|
|
264
|
+
.set({ deleted_at: sql `now()`, updated_at: sql `now()` })
|
|
265
|
+
.where("org_id", "=", orgId)
|
|
266
|
+
.where("owner_kind", "=", "personal")
|
|
267
|
+
.where("owner_account_id", "=", accountId)
|
|
268
|
+
.where("deleted_at", "is", null)
|
|
269
|
+
.returning("id")
|
|
270
|
+
.execute();
|
|
271
|
+
await this.db
|
|
272
|
+
.deleteFrom("environment_defaults")
|
|
273
|
+
.where("org_id", "=", orgId)
|
|
274
|
+
.where("account_id", "=", accountId)
|
|
254
275
|
.execute();
|
|
255
276
|
await audit(this.db.db, {
|
|
256
277
|
...(actor.actorAccountId !== undefined && { actorAccountId: actor.actorAccountId }),
|
|
@@ -272,7 +293,7 @@ let Offboarding = class Offboarding {
|
|
|
272
293
|
channelThreadsArchived: Number(threads.numUpdatedRows),
|
|
273
294
|
toolGrantsDeleted: Number(grants.numDeletedRows),
|
|
274
295
|
...(excluded.length > 0 && { directoryExcluded: excluded }),
|
|
275
|
-
...(
|
|
296
|
+
...(environments.length > 0 && { environmentsDeleted: environments.length }),
|
|
276
297
|
...(queued.length > 0 && { queuedMessagesDeleted: queued.length }),
|
|
277
298
|
},
|
|
278
299
|
});
|
|
@@ -286,7 +307,7 @@ let Offboarding = class Offboarding {
|
|
|
286
307
|
status: r.status,
|
|
287
308
|
})),
|
|
288
309
|
newOwnerId: agents.length > 0 ? owner.account_id : null,
|
|
289
|
-
|
|
310
|
+
environments: environments.map((r) => r.id),
|
|
290
311
|
queueConversations,
|
|
291
312
|
};
|
|
292
313
|
}
|
|
@@ -315,8 +336,8 @@ let Offboarding = class Offboarding {
|
|
|
315
336
|
/**
|
|
316
337
|
* After the commit (callers register it with the infra `afterCommit` inside their transaction):
|
|
317
338
|
* writes the session revocation markers, publishes the cancelled events, stops the person's
|
|
318
|
-
* runs in the org and schedules destroying their
|
|
319
|
-
*
|
|
339
|
+
* runs in the org and schedules destroying their environments. A failing step only logs a
|
|
340
|
+
* warning.
|
|
320
341
|
*/
|
|
321
342
|
async afterOffboard(r) {
|
|
322
343
|
const { sessions, log, eventLog } = this;
|
|
@@ -344,13 +365,13 @@ let Offboarding = class Offboarding {
|
|
|
344
365
|
}
|
|
345
366
|
for (const run of r.runs)
|
|
346
367
|
await this.stopRun(run);
|
|
347
|
-
if (r.
|
|
368
|
+
if (r.environments.length > 0) {
|
|
348
369
|
try {
|
|
349
|
-
await this.sandboxJobs.destroy(r.
|
|
370
|
+
await this.sandboxJobs.destroy(r.environments);
|
|
350
371
|
}
|
|
351
372
|
catch (err) {
|
|
352
|
-
log.warn("offboarding: cannot schedule
|
|
353
|
-
count: r.
|
|
373
|
+
log.warn("offboarding: cannot schedule environment destruction", {
|
|
374
|
+
count: r.environments.length,
|
|
354
375
|
err,
|
|
355
376
|
});
|
|
356
377
|
}
|
package/dist/orgs/org-lock.d.ts
CHANGED
|
@@ -35,6 +35,11 @@ export declare class OrgLock {
|
|
|
35
35
|
org: LockedOrg;
|
|
36
36
|
role: OrgRole;
|
|
37
37
|
}>;
|
|
38
|
+
/**
|
|
39
|
+
* {@link lockAndAuthorize} for an account; for the kernel itself (`null`: a job acting for no
|
|
40
|
+
* person, such as the plugin scope sync) only the lock, since no role applies.
|
|
41
|
+
*/
|
|
42
|
+
lockFor(orgId: string, actor: string | null, action: OrgAction): Promise<void>;
|
|
38
43
|
}
|
|
39
44
|
/** The one {@link OrgLock}: identity (service tokens), orgs and the other domains import it. */
|
|
40
45
|
export declare class OrgLockModule {
|
package/dist/orgs/org-lock.js
CHANGED
|
@@ -67,6 +67,16 @@ let OrgLock = class OrgLock {
|
|
|
67
67
|
}
|
|
68
68
|
return { org, role: m.role };
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* {@link lockAndAuthorize} for an account; for the kernel itself (`null`: a job acting for no
|
|
72
|
+
* person, such as the plugin scope sync) only the lock, since no role applies.
|
|
73
|
+
*/
|
|
74
|
+
async lockFor(orgId, actor, action) {
|
|
75
|
+
if (actor === null)
|
|
76
|
+
await this.lock(orgId);
|
|
77
|
+
else
|
|
78
|
+
await this.lockAndAuthorize(orgId, actor, action);
|
|
79
|
+
}
|
|
70
80
|
};
|
|
71
81
|
__decorate([
|
|
72
82
|
Transactional({ propagation: "mandatory" })
|
|
@@ -77,6 +87,9 @@ __decorate([
|
|
|
77
87
|
__decorate([
|
|
78
88
|
Transactional({ propagation: "mandatory" })
|
|
79
89
|
], OrgLock.prototype, "lockAndAuthorize", null);
|
|
90
|
+
__decorate([
|
|
91
|
+
Transactional({ propagation: "mandatory" })
|
|
92
|
+
], OrgLock.prototype, "lockFor", null);
|
|
80
93
|
OrgLock = __decorate([
|
|
81
94
|
Injectable(),
|
|
82
95
|
__param(0, Inject(KernelDb)),
|