@capybara-hq/kernel 0.1.0-rc.4 → 0.1.0-rc.6
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 +51 -14
- package/dist/admin/admin.controller.js +60 -19
- package/dist/admin/extensions.controller.d.ts +16 -2
- package/dist/admin/extensions.controller.js +26 -6
- 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 +16 -0
- package/dist/agents/agent-lookup.js +11 -0
- package/dist/agents/agents.controller.d.ts +76 -1
- package/dist/agents/agents.controller.js +90 -11
- package/dist/agents/agents.module.d.ts +4 -1
- package/dist/agents/agents.module.js +32 -6
- package/dist/agents/agents.service.d.ts +54 -23
- package/dist/agents/agents.service.js +180 -76
- package/dist/agents/definition.d.ts +49 -0
- package/dist/agents/definition.js +45 -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/models.controller.d.ts +34 -5
- package/dist/agents/models.controller.js +50 -6
- 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/readiness.controller.d.ts +5 -5
- package/dist/agents/readiness.controller.js +6 -6
- 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 +475 -52
- package/dist/background/background.module.js +8 -1
- package/dist/background/finish.d.ts +3 -2
- package/dist/background/launch-lock.d.ts +4 -3
- package/dist/background/launch-lock.js +4 -3
- package/dist/background/poll.job.d.ts +9 -6
- package/dist/background/poll.job.js +30 -22
- package/dist/background/session.d.ts +13 -2
- package/dist/background/session.js +13 -0
- package/dist/background/stop.d.ts +12 -6
- package/dist/background/stop.js +57 -39
- package/dist/background/store.d.ts +18 -6
- package/dist/background/store.js +12 -6
- package/dist/background/tasks.service.d.ts +15 -5
- package/dist/background/tasks.service.js +42 -17
- package/dist/background/wake-rules.d.ts +27 -18
- package/dist/background/wake-rules.js +52 -22
- package/dist/background/wake.d.ts +13 -11
- package/dist/background/wake.js +20 -14
- 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/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 +622 -82
- 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 +1147 -1136
- 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 +20 -2
- package/dist/channels/channels.module.js +2 -0
- 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/config/docs.js +3 -1
- package/dist/config/schema.d.ts +10 -2
- package/dist/config/schema.js +70 -22
- package/dist/conversations/access.d.ts +6 -4
- package/dist/conversations/access.js +27 -5
- package/dist/conversations/agent-tree.d.ts +46 -0
- package/dist/conversations/agent-tree.js +92 -0
- package/dist/conversations/conversations.controller.d.ts +43 -18
- package/dist/conversations/conversations.controller.js +79 -38
- package/dist/conversations/conversations.module.d.ts +1 -1
- package/dist/conversations/conversations.module.js +7 -7
- package/dist/conversations/conversations.service.d.ts +73 -15
- package/dist/conversations/conversations.service.js +115 -35
- package/dist/conversations/environment-status.d.ts +24 -0
- package/dist/conversations/environment-status.js +71 -0
- package/dist/conversations/event-log.d.ts +20 -5
- package/dist/conversations/event-log.js +60 -0
- package/dist/conversations/events.d.ts +84 -2
- package/dist/conversations/events.js +91 -17
- package/dist/conversations/queue.service.d.ts +1 -1
- package/dist/conversations/queue.service.js +5 -0
- package/dist/conversations/titles.d.ts +5 -3
- package/dist/conversations/titles.js +21 -8
- package/dist/conversations/tree.d.ts +17 -0
- package/dist/conversations/tree.js +42 -0
- package/dist/ctx/create-ctx.d.ts +20 -1
- package/dist/ctx/create-ctx.js +38 -7
- package/dist/db/kernel-schema.d.ts +386 -18
- 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 +85 -2
- package/dist/errors.js +85 -2
- package/dist/evals/reconstruct.d.ts +18 -9
- package/dist/evals/reconstruct.js +26 -7
- package/dist/evals/run-replay.d.ts +4 -2
- package/dist/evals/run-replay.js +20 -6
- package/dist/evals/runs.service.d.ts +2 -1
- package/dist/evals/runs.service.js +13 -12
- package/dist/evals/step-replay.d.ts +4 -6
- package/dist/evals/step-replay.js +4 -3
- 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 +65 -42
- package/dist/extensions/admin-view.d.ts +37 -10
- package/dist/extensions/admin-view.js +103 -20
- 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-hash.d.ts +10 -0
- package/dist/extensions/config-hash.js +38 -0
- package/dist/extensions/deployment-config.d.ts +28 -5
- package/dist/extensions/deployment-config.js +48 -7
- package/dist/extensions/effective-config.d.ts +127 -0
- package/dist/extensions/effective-config.js +368 -0
- package/dist/extensions/extensions.module.js +11 -11
- package/dist/extensions/hooks.d.ts +37 -4
- package/dist/extensions/hooks.js +82 -16
- package/dist/extensions/host.d.ts +24 -10
- package/dist/extensions/host.js +49 -54
- package/dist/extensions/installs.d.ts +20 -8
- package/dist/extensions/installs.js +37 -15
- package/dist/extensions/org-config.d.ts +75 -6
- package/dist/extensions/org-config.js +184 -32
- 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/permission-view.d.ts +16 -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.d.ts +12 -5
- package/dist/extensions/point-defaults.js +37 -9
- package/dist/extensions/resolve.d.ts +5 -1
- package/dist/extensions/resolve.js +15 -2
- package/dist/extensions/state.module.d.ts +9 -0
- package/dist/extensions/state.module.js +38 -0
- package/dist/files/previewers.d.ts +8 -1
- package/dist/files/previewers.js +35 -6
- package/dist/http/api.module.js +25 -3
- package/dist/http/app.d.ts +11 -2
- package/dist/http/app.js +31 -5
- package/dist/http/plugin-dispatch.d.ts +4 -1
- package/dist/http/plugin-dispatch.js +14 -2
- 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.guard.d.ts +13 -5
- package/dist/identity/auth.guard.js +26 -9
- package/dist/identity/identity.module.d.ts +1 -1
- package/dist/identity/identity.module.js +4 -4
- package/dist/identity/me.controller.js +1 -1
- package/dist/identity/principal.d.ts +3 -3
- package/dist/identity/principal.js +3 -3
- 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 +1 -1
- package/dist/index.js +1 -1
- package/dist/infra/cli/kernel-cli.module.js +9 -1
- package/dist/infra/config/kernel-config.service.js +24 -1
- 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/queue/add-job-once.d.ts +14 -0
- package/dist/infra/queue/add-job-once.js +16 -0
- 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/models/embeddings.d.ts +82 -0
- package/dist/models/embeddings.js +326 -0
- package/dist/models/enablement.controller.d.ts +40 -0
- package/dist/models/enablement.controller.js +74 -0
- package/dist/models/enablement.d.ts +99 -0
- package/dist/models/enablement.js +263 -0
- package/dist/models/models.module.d.ts +5 -1
- package/dist/models/models.module.js +16 -4
- 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 +37 -12
- package/dist/models/purposes.js +63 -17
- package/dist/orgs/directory-sync.d.ts +14 -5
- package/dist/orgs/directory-sync.js +41 -17
- package/dist/orgs/offboarding.d.ts +9 -7
- package/dist/orgs/offboarding.js +28 -17
- 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 +15 -3
- package/dist/orgs/settings.service.js +6 -2
- 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 +1405 -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 +9 -1
- package/dist/runtime/context/build.d.ts +6 -4
- package/dist/runtime/context/build.js +26 -7
- package/dist/runtime/context/claude-tools.d.ts +2 -1
- package/dist/runtime/context/claude-tools.js +5 -4
- package/dist/runtime/context/compaction.js +9 -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.d.ts +8 -1
- package/dist/runtime/hook-calls.js +40 -7
- package/dist/runtime/langgraph-loop.d.ts +3 -1
- package/dist/runtime/langgraph-loop.js +35 -17
- package/dist/runtime/loop.d.ts +32 -4
- package/dist/runtime/maintenance.d.ts +7 -4
- package/dist/runtime/maintenance.js +23 -8
- package/dist/runtime/model-call.d.ts +38 -11
- package/dist/runtime/model-call.js +97 -24
- package/dist/runtime/providers.d.ts +146 -32
- package/dist/runtime/providers.js +321 -67
- 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 +37 -3
- package/dist/runtime/run-queue.js +188 -11
- package/dist/runtime/run-worker.d.ts +12 -6
- package/dist/runtime/run-worker.js +58 -35
- package/dist/runtime/runtime.module.js +3 -0
- package/dist/runtime/step-log.d.ts +9 -4
- package/dist/runtime/step-log.js +8 -5
- 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 +46 -32
- 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-jobs.d.ts +88 -0
- package/dist/runtime/usage-report-jobs.js +158 -0
- package/dist/runtime/usage-report.d.ts +33 -38
- package/dist/runtime/usage-report.js +169 -96
- package/dist/runtime/waits.d.ts +140 -37
- package/dist/runtime/waits.js +394 -106
- 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 +4 -3
- package/dist/sandbox/sandbox.service.d.ts +229 -134
- package/dist/sandbox/sandbox.service.js +630 -409
- 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 +23 -4
- package/dist/tools/builtin-names.d.ts +21 -5
- package/dist/tools/builtin-names.js +30 -5
- 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 +6 -2
- package/dist/tools/builtins/builtin-tools.js +37 -12
- 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.js +13 -3
- package/dist/tools/builtins/sandbox/common.d.ts +43 -24
- package/dist/tools/builtins/sandbox/common.js +80 -45
- 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 +1 -1
- package/dist/tools/builtins/sandbox/index.js +1 -1
- package/dist/tools/builtins/sandbox/read.js +1 -1
- package/dist/tools/builtins/sandbox/task-output.d.ts +14 -3
- package/dist/tools/builtins/sandbox/task-output.js +30 -5
- package/dist/tools/builtins/sandbox/task-stop.js +2 -1
- 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/extract.js +5 -1
- package/dist/tools/builtins/web/fetch.js +1 -0
- package/dist/tools/builtins/web/search.js +1 -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/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 +193 -364
- package/dist/tools/policy.d.ts +1 -1
- package/dist/tools/policy.js +36 -16
- package/dist/tools/registry.d.ts +98 -5
- package/dist/tools/registry.js +87 -9
- package/dist/tools/tools.module.js +12 -2
- package/dist/ui/views.d.ts +2 -1
- package/dist/ui/views.js +17 -3
- package/package.json +3 -3
- 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/src/migrations/0089_model_kinds_usage.sql +38 -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 -32
- package/dist/extensions/org-config.controller.js +0 -70
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,9 +27,11 @@ 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
|
+
* - a target's kind must equal the purpose's kind; an org's override must be enabled in the org on
|
|
33
|
+
* save (a deployment default: not disabled on the platform), and an effective target disabled in
|
|
34
|
+
* the org (by either layer) counts as unconfigured there (spec B §5.3);参数按目标模型自己的声明严格校验;
|
|
33
35
|
* - 每次都查 PG,不在进程内缓存(多副本下改映射立即生效)。`ctx.models` 仍预留,插件暂不能调用。
|
|
34
36
|
*/
|
|
35
37
|
/**
|
|
@@ -49,19 +51,28 @@ export const KERNEL_PURPOSES = [
|
|
|
49
51
|
{
|
|
50
52
|
purpose: "subagent_fast",
|
|
51
53
|
kind: "chat",
|
|
52
|
-
label: { zh: "
|
|
54
|
+
label: { zh: "子智能体:快速", en: "Sub-agent: fast" },
|
|
53
55
|
},
|
|
54
56
|
{
|
|
55
57
|
purpose: "subagent_standard",
|
|
56
58
|
kind: "chat",
|
|
57
|
-
label: { zh: "
|
|
59
|
+
label: { zh: "子智能体:标准", en: "Sub-agent: standard" },
|
|
58
60
|
},
|
|
59
61
|
{
|
|
60
62
|
purpose: "subagent_capable",
|
|
61
63
|
kind: "chat",
|
|
62
|
-
label: { zh: "
|
|
64
|
+
label: { zh: "子智能体:最强", en: "Sub-agent: capable" },
|
|
63
65
|
},
|
|
64
66
|
];
|
|
67
|
+
/** {@link PurposeListing}s of `views`, the display names read in one call. */
|
|
68
|
+
export async function withDeclaredByNames(views, names) {
|
|
69
|
+
const plugins = views.map((v) => v.declaredBy).filter((d) => d !== "kernel");
|
|
70
|
+
const found = await names.many(plugins);
|
|
71
|
+
return views.map((v) => ({
|
|
72
|
+
...v,
|
|
73
|
+
declaredByName: v.declaredBy === "kernel" ? null : (found.get(v.declaredBy) ?? null),
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
65
76
|
/** `PUT …/model-purposes/:purpose` 的 body:设映射,或 `target: null` 清除。 */
|
|
66
77
|
export const PURPOSE_PUT = z
|
|
67
78
|
.object({
|
|
@@ -180,11 +191,17 @@ let ModelPurposesService = class ModelPurposesService {
|
|
|
180
191
|
async list(orgId) {
|
|
181
192
|
return this.views(this.declared(), orgId);
|
|
182
193
|
}
|
|
183
|
-
/**
|
|
184
|
-
|
|
194
|
+
/**
|
|
195
|
+
* 校验目标:模型可解析且启用(an org's override for the org, a deployment default in the
|
|
196
|
+
* platform view)、its kind is the purpose's `kind`、参数按它的声明严格通过。
|
|
197
|
+
*/
|
|
198
|
+
async check(orgId, target, kind) {
|
|
185
199
|
let info;
|
|
186
200
|
try {
|
|
187
|
-
|
|
201
|
+
info =
|
|
202
|
+
orgId === null
|
|
203
|
+
? await this.providers.platformInfo(target.model, { kind: "callable" })
|
|
204
|
+
: (await this.providers.resolve(orgId, target.model, { kind: "callable" })).info;
|
|
188
205
|
}
|
|
189
206
|
catch (e) {
|
|
190
207
|
if (e instanceof ProviderListError)
|
|
@@ -194,6 +211,14 @@ let ModelPurposesService = class ModelPurposesService {
|
|
|
194
211
|
}
|
|
195
212
|
throw e;
|
|
196
213
|
}
|
|
214
|
+
if (info.kind !== kind) {
|
|
215
|
+
throw invalid([
|
|
216
|
+
{
|
|
217
|
+
path: "target.model",
|
|
218
|
+
message: `this purpose needs ${kind === "embedding" ? "an" : "a"} ${kind} model, not ${info.kind}`,
|
|
219
|
+
},
|
|
220
|
+
]);
|
|
221
|
+
}
|
|
197
222
|
const issues = paramIssues("target.params", info.parameters, target.params);
|
|
198
223
|
if (issues.length > 0)
|
|
199
224
|
throw invalid(issues);
|
|
@@ -201,12 +226,12 @@ let ModelPurposesService = class ModelPurposesService {
|
|
|
201
226
|
async set(orgId, purpose, target, actor, actorTokenId) {
|
|
202
227
|
const decl = this.find(purpose);
|
|
203
228
|
if (target)
|
|
204
|
-
await this.check(target);
|
|
229
|
+
await this.check(orgId, target, decl.kind);
|
|
205
230
|
await this.write(orgId, purpose, target, actor, actorTokenId);
|
|
206
231
|
const [view] = await this.views([decl], orgId ?? undefined);
|
|
207
232
|
return view;
|
|
208
233
|
}
|
|
209
|
-
/** The mapping write of {@link set}, under the
|
|
234
|
+
/** The mapping write of {@link set}, under the super admin or org lock. */
|
|
210
235
|
async write(orgId, purpose, target, actor, actorTokenId) {
|
|
211
236
|
if (orgId === null)
|
|
212
237
|
await this.adminLock.lockAndAuthorize(actor);
|
|
@@ -243,7 +268,7 @@ let ModelPurposesService = class ModelPurposesService {
|
|
|
243
268
|
detail: { scope: orgId === null ? "deployment" : "org", target },
|
|
244
269
|
});
|
|
245
270
|
}
|
|
246
|
-
/** 设置(或 `null`
|
|
271
|
+
/** 设置(或 `null` 清除)部署默认;只有超级管理员(事务内复核)。 */
|
|
247
272
|
setDefault(purpose, target, actor, actorTokenId) {
|
|
248
273
|
return this.set(null, purpose, target, actor, actorTokenId);
|
|
249
274
|
}
|
|
@@ -251,12 +276,33 @@ let ModelPurposesService = class ModelPurposesService {
|
|
|
251
276
|
setOrg(orgId, purpose, target, actor, actorTokenId) {
|
|
252
277
|
return this.set(orgId, purpose, target, actor, actorTokenId);
|
|
253
278
|
}
|
|
254
|
-
/**
|
|
279
|
+
/**
|
|
280
|
+
* 生效的映射:组织覆盖,否则部署默认;都没有 → `model.unconfigured`;用途未声明 → `model.purpose_unknown`。
|
|
281
|
+
* An effective target the org cannot use counts as unconfigured there (spec B §5.3): checked in
|
|
282
|
+
* the registry's org view, so a model the platform or the org disabled, a provider off or needing
|
|
283
|
+
* configuration in the org, a model gone from the org's list or of another kind than the purpose
|
|
284
|
+
* all give `model.unconfigured`. A provider whose list fails (`ProviderListError`) keeps the
|
|
285
|
+
* mapping: the call that follows resolves the model again and fails there, retryably, so paths
|
|
286
|
+
* that only read the mapping (sub-agent tiers, eval start, `ctx.models.describe`) do not fail on
|
|
287
|
+
* a transient list error.
|
|
288
|
+
*/
|
|
255
289
|
async resolve(orgId, purpose) {
|
|
256
|
-
const
|
|
290
|
+
const decl = this.find(purpose);
|
|
291
|
+
const [view] = await this.views([decl], orgId);
|
|
257
292
|
if (!view?.effective) {
|
|
258
293
|
throw new ApiError("model.unconfigured", `No model is configured for the "${purpose}" purpose`);
|
|
259
294
|
}
|
|
295
|
+
try {
|
|
296
|
+
await this.providers.resolve(orgId, view.effective.model, { kind: decl.kind });
|
|
297
|
+
}
|
|
298
|
+
catch (e) {
|
|
299
|
+
if (e instanceof ProviderListError)
|
|
300
|
+
return view.effective;
|
|
301
|
+
if (e instanceof ApiError && e.code === "agent.model_unavailable") {
|
|
302
|
+
throw new ApiError("model.unconfigured", `The model configured for the "${purpose}" purpose is not available in this organization`);
|
|
303
|
+
}
|
|
304
|
+
throw e;
|
|
305
|
+
}
|
|
260
306
|
return view.effective;
|
|
261
307
|
}
|
|
262
308
|
/** The target a {@link chat} call on `purpose` uses: the mapping, else `fallback` when unmapped. */
|
|
@@ -277,7 +323,7 @@ let ModelPurposesService = class ModelPurposesService {
|
|
|
277
323
|
*/
|
|
278
324
|
async chatLimits(orgId, purpose, opts = {}) {
|
|
279
325
|
const target = await this.chatTarget(orgId, purpose, opts.fallback);
|
|
280
|
-
const { info } = await this.providers.resolve(target.model);
|
|
326
|
+
const { info } = await this.providers.resolve(orgId, target.model);
|
|
281
327
|
return { contextWindow: info.contextWindow, maxOutputTokens: info.maxOutputTokens };
|
|
282
328
|
}
|
|
283
329
|
/**
|
|
@@ -292,7 +338,7 @@ let ModelPurposesService = class ModelPurposesService {
|
|
|
292
338
|
*/
|
|
293
339
|
async chat(orgId, purpose, req, signal, opts = {}) {
|
|
294
340
|
const target = await this.chatTarget(orgId, purpose, opts.fallback);
|
|
295
|
-
const { provider, info } = await this.providers.resolve(target.model);
|
|
341
|
+
const { provider, info } = await this.providers.resolve(orgId, target.model);
|
|
296
342
|
const request = {
|
|
297
343
|
...req,
|
|
298
344
|
model: info.id,
|
|
@@ -332,7 +378,7 @@ ModelPurposesService = __decorate([
|
|
|
332
378
|
__param(2, Inject(KernelConfigService)),
|
|
333
379
|
__param(3, Inject(ProviderRegistry)),
|
|
334
380
|
__param(4, Inject(TransactionHost)),
|
|
335
|
-
__param(5, Inject(
|
|
381
|
+
__param(5, Inject(SuperAdminLock)),
|
|
336
382
|
__param(6, Inject(OrgLock))
|
|
337
383
|
], ModelPurposesService);
|
|
338
384
|
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);
|
|
@@ -95,7 +95,9 @@ export declare class Offboarding {
|
|
|
95
95
|
* 以及成员关系自身的 `directory:<插件>` 来源,不论此人当初是不是由通讯录加入(手动重新加入后再被移出也不会被同步加回);
|
|
96
96
|
* 同步不再把此人加回,直到有人手动重新加入({@link MembersService.add} 删除排除);
|
|
97
97
|
* 8. 审计 `org.member.offboarded`;
|
|
98
|
-
* 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).
|
|
99
101
|
*/
|
|
100
102
|
offboard(orgId: string, accountId: string, reason: OffboardReason, actor?: {
|
|
101
103
|
actorAccountId?: string;
|
|
@@ -106,8 +108,8 @@ export declare class Offboarding {
|
|
|
106
108
|
/**
|
|
107
109
|
* After the commit (callers register it with the infra `afterCommit` inside their transaction):
|
|
108
110
|
* writes the session revocation markers, publishes the cancelled events, stops the person's
|
|
109
|
-
* runs in the org and schedules destroying their
|
|
110
|
-
*
|
|
111
|
+
* runs in the org and schedules destroying their environments. A failing step only logs a
|
|
112
|
+
* warning.
|
|
111
113
|
*/
|
|
112
114
|
afterOffboard(r: OffboardResult): Promise<void>;
|
|
113
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) {
|
|
@@ -95,7 +96,9 @@ let Offboarding = class Offboarding {
|
|
|
95
96
|
* 以及成员关系自身的 `directory:<插件>` 来源,不论此人当初是不是由通讯录加入(手动重新加入后再被移出也不会被同步加回);
|
|
96
97
|
* 同步不再把此人加回,直到有人手动重新加入({@link MembersService.add} 删除排除);
|
|
97
98
|
* 8. 审计 `org.member.offboarded`;
|
|
98
|
-
* 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).
|
|
99
102
|
*/
|
|
100
103
|
async offboard(orgId, accountId, reason, actor = {}) {
|
|
101
104
|
const deleted = await this.db
|
|
@@ -210,6 +213,8 @@ let Offboarding = class Offboarding {
|
|
|
210
213
|
.where("deleted_at", "is", null)
|
|
211
214
|
.returning("id")
|
|
212
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);
|
|
213
218
|
const threads = await this.db
|
|
214
219
|
.updateTable("channel_threads")
|
|
215
220
|
.set({ archived_at: sql `now()` })
|
|
@@ -254,13 +259,19 @@ let Offboarding = class Offboarding {
|
|
|
254
259
|
.where("id", "in", queueConversations)
|
|
255
260
|
.execute();
|
|
256
261
|
}
|
|
257
|
-
const
|
|
258
|
-
.
|
|
259
|
-
.
|
|
260
|
-
.
|
|
261
|
-
.where("
|
|
262
|
-
.where("
|
|
263
|
-
.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)
|
|
264
275
|
.execute();
|
|
265
276
|
await audit(this.db.db, {
|
|
266
277
|
...(actor.actorAccountId !== undefined && { actorAccountId: actor.actorAccountId }),
|
|
@@ -282,7 +293,7 @@ let Offboarding = class Offboarding {
|
|
|
282
293
|
channelThreadsArchived: Number(threads.numUpdatedRows),
|
|
283
294
|
toolGrantsDeleted: Number(grants.numDeletedRows),
|
|
284
295
|
...(excluded.length > 0 && { directoryExcluded: excluded }),
|
|
285
|
-
...(
|
|
296
|
+
...(environments.length > 0 && { environmentsDeleted: environments.length }),
|
|
286
297
|
...(queued.length > 0 && { queuedMessagesDeleted: queued.length }),
|
|
287
298
|
},
|
|
288
299
|
});
|
|
@@ -296,7 +307,7 @@ let Offboarding = class Offboarding {
|
|
|
296
307
|
status: r.status,
|
|
297
308
|
})),
|
|
298
309
|
newOwnerId: agents.length > 0 ? owner.account_id : null,
|
|
299
|
-
|
|
310
|
+
environments: environments.map((r) => r.id),
|
|
300
311
|
queueConversations,
|
|
301
312
|
};
|
|
302
313
|
}
|
|
@@ -325,8 +336,8 @@ let Offboarding = class Offboarding {
|
|
|
325
336
|
/**
|
|
326
337
|
* After the commit (callers register it with the infra `afterCommit` inside their transaction):
|
|
327
338
|
* writes the session revocation markers, publishes the cancelled events, stops the person's
|
|
328
|
-
* runs in the org and schedules destroying their
|
|
329
|
-
*
|
|
339
|
+
* runs in the org and schedules destroying their environments. A failing step only logs a
|
|
340
|
+
* warning.
|
|
330
341
|
*/
|
|
331
342
|
async afterOffboard(r) {
|
|
332
343
|
const { sessions, log, eventLog } = this;
|
|
@@ -354,13 +365,13 @@ let Offboarding = class Offboarding {
|
|
|
354
365
|
}
|
|
355
366
|
for (const run of r.runs)
|
|
356
367
|
await this.stopRun(run);
|
|
357
|
-
if (r.
|
|
368
|
+
if (r.environments.length > 0) {
|
|
358
369
|
try {
|
|
359
|
-
await this.sandboxJobs.destroy(r.
|
|
370
|
+
await this.sandboxJobs.destroy(r.environments);
|
|
360
371
|
}
|
|
361
372
|
catch (err) {
|
|
362
|
-
log.warn("offboarding: cannot schedule
|
|
363
|
-
count: r.
|
|
373
|
+
log.warn("offboarding: cannot schedule environment destruction", {
|
|
374
|
+
count: r.environments.length,
|
|
364
375
|
err,
|
|
365
376
|
});
|
|
366
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)),
|
package/dist/orgs/org.guard.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type CanActivate, type ExecutionContext } from "@nestjs/common";
|
|
2
2
|
import { Reflector } from "@nestjs/core";
|
|
3
|
+
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
4
|
+
import { type Principal } from "../identity/principal.js";
|
|
3
5
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
4
6
|
import { type OrgAction as Action, type OrgRole } from "./roles.js";
|
|
5
7
|
/** OrgGuard 放在请求上的组织上下文。 */
|
|
@@ -21,6 +23,14 @@ export declare const ORG_ACTION_KEY = "capybara:org:action";
|
|
|
21
23
|
export declare function OrgAction(action: Action): MethodDecorator & ClassDecorator;
|
|
22
24
|
/** 参数装饰器:取 OrgGuard 放在 `req.org` 上的 `{ orgId, role }`。 */
|
|
23
25
|
export declare const CurrentOrg: () => ParameterDecorator;
|
|
26
|
+
/**
|
|
27
|
+
* The org role check of {@link OrgGuard}, read live from PG: the caller's role in `orgId` (a
|
|
28
|
+
* person's membership, a service token's own org and role) allows `action`, else 404
|
|
29
|
+
* `org.not_found` (missing, soft-deleted, not a member: existence is not disclosed) or 403
|
|
30
|
+
* `forbidden` (HUMAN_ONLY for a service token, role too low). Also run before the body of an org
|
|
31
|
+
* package upload is read (ruling P3-29).
|
|
32
|
+
*/
|
|
33
|
+
export declare function authorizeOrgAction(db: Pick<KernelSchemaDb, "selectFrom">, p: Principal, orgId: string, action: Action): Promise<OrgRole>;
|
|
24
34
|
/**
|
|
25
35
|
* 组织守卫:每个请求实时从 PG 读组织与成员角色(不缓存)。
|
|
26
36
|
* - 组织不存在、已软删除、或调用者不是成员 → 404 `org.not_found`(不泄露组织是否存在)。
|