@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
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
2
2
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
3
3
|
import type { KernelLogger } from "../log.js";
|
|
4
|
+
import { EffectiveConfigs } from "./effective-config.js";
|
|
4
5
|
import { OrgExtensionConfigs } from "./org-config.js";
|
|
5
6
|
import { ExtensionRegistry } from "./registry.js";
|
|
6
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* The outcome of {@link ExtensionPointDefaults.resolve}: the provider with its org config and its
|
|
9
|
+
* effective deployment config for the org (layering spec A §6), both to pass back to it.
|
|
10
|
+
*/
|
|
7
11
|
export type PointResolution<T> = {
|
|
8
12
|
ok: true;
|
|
9
13
|
extension: string;
|
|
10
14
|
impl: T;
|
|
11
15
|
orgConfig: unknown;
|
|
16
|
+
config: unknown;
|
|
12
17
|
} | {
|
|
13
18
|
ok: false;
|
|
14
19
|
reason: "none" | "ambiguous";
|
|
@@ -26,8 +31,8 @@ export interface OrgPointDefaultView {
|
|
|
26
31
|
/**
|
|
27
32
|
* The org default provider of an `org-default` extension point (web tools spec §6). Per call,
|
|
28
33
|
* never cached in process: the candidates are the providers loaded on this replica that are
|
|
29
|
-
* enabled in the org, whose org config
|
|
30
|
-
* return false. One candidate is used as is; several need the org's stored default
|
|
34
|
+
* enabled in the org, whose org config and effective deployment config for the org (layering spec
|
|
35
|
+
* A §6) are valid, and whose `configured()` (when present) does not return false. One candidate is used as is; several need the org's stored default
|
|
31
36
|
* (`capybara.org_extension_point_defaults`), else the choice is ambiguous. A stored default that
|
|
32
37
|
* is not a candidate (disabled, uninstalled, unconfigured) stays and counts again once it is one.
|
|
33
38
|
*/
|
|
@@ -36,11 +41,13 @@ export declare class ExtensionPointDefaults {
|
|
|
36
41
|
readonly txHost: TransactionHost;
|
|
37
42
|
private readonly registry;
|
|
38
43
|
private readonly orgConfigs;
|
|
44
|
+
private readonly effective;
|
|
39
45
|
private readonly log;
|
|
40
|
-
constructor(kdb: KernelDb, txHost: TransactionHost, registry: Pick<ExtensionRegistry, "list">, orgConfigs: Pick<OrgExtensionConfigs, "get">, log: KernelLogger);
|
|
46
|
+
constructor(kdb: KernelDb, txHost: TransactionHost, registry: Pick<ExtensionRegistry, "list">, orgConfigs: Pick<OrgExtensionConfigs, "get">, effective: Pick<EffectiveConfigs, "get">, log: KernelLogger);
|
|
41
47
|
/**
|
|
42
48
|
* The provider of `point` (the name without the major, e.g. `web-search`) for `orgId`, with the
|
|
43
|
-
* org's decrypted config to pass back to it. Throws when the
|
|
49
|
+
* org's decrypted config and the effective deployment config to pass back to it. Throws when the
|
|
50
|
+
* point has no `selection`.
|
|
44
51
|
*/
|
|
45
52
|
resolve<T>(orgId: string, point: string): Promise<PointResolution<T>>;
|
|
46
53
|
/** Every `org-default` point with its candidates, stored default and effective provider. */
|
|
@@ -15,6 +15,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
|
|
|
15
15
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
16
16
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
17
17
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
18
|
+
import { EffectiveConfigs } from "./effective-config.js";
|
|
18
19
|
import { enabledExtensionsQuery, isExtensionEnabled } from "./enabled.js";
|
|
19
20
|
import { OrgExtensionConfigs } from "./org-config.js";
|
|
20
21
|
import { ExtensionRegistry } from "./registry.js";
|
|
@@ -28,8 +29,8 @@ const hasSelection = (point) => EXTENSION_POINTS[point]?.selection === "org-defa
|
|
|
28
29
|
/**
|
|
29
30
|
* The org default provider of an `org-default` extension point (web tools spec §6). Per call,
|
|
30
31
|
* never cached in process: the candidates are the providers loaded on this replica that are
|
|
31
|
-
* enabled in the org, whose org config
|
|
32
|
-
* return false. One candidate is used as is; several need the org's stored default
|
|
32
|
+
* enabled in the org, whose org config and effective deployment config for the org (layering spec
|
|
33
|
+
* A §6) are valid, and whose `configured()` (when present) does not return false. One candidate is used as is; several need the org's stored default
|
|
33
34
|
* (`capybara.org_extension_point_defaults`), else the choice is ambiguous. A stored default that
|
|
34
35
|
* is not a candidate (disabled, uninstalled, unconfigured) stays and counts again once it is one.
|
|
35
36
|
*/
|
|
@@ -38,17 +39,20 @@ let ExtensionPointDefaults = class ExtensionPointDefaults {
|
|
|
38
39
|
txHost;
|
|
39
40
|
registry;
|
|
40
41
|
orgConfigs;
|
|
42
|
+
effective;
|
|
41
43
|
log;
|
|
42
|
-
constructor(kdb, txHost, registry, orgConfigs, log) {
|
|
44
|
+
constructor(kdb, txHost, registry, orgConfigs, effective, log) {
|
|
43
45
|
this.kdb = kdb;
|
|
44
46
|
this.txHost = txHost;
|
|
45
47
|
this.registry = registry;
|
|
46
48
|
this.orgConfigs = orgConfigs;
|
|
49
|
+
this.effective = effective;
|
|
47
50
|
this.log = log;
|
|
48
51
|
}
|
|
49
52
|
/**
|
|
50
53
|
* The provider of `point` (the name without the major, e.g. `web-search`) for `orgId`, with the
|
|
51
|
-
* org's decrypted config to pass back to it. Throws when the
|
|
54
|
+
* org's decrypted config and the effective deployment config to pass back to it. Throws when the
|
|
55
|
+
* point has no `selection`.
|
|
52
56
|
*/
|
|
53
57
|
async resolve(orgId, point) {
|
|
54
58
|
if (!hasSelection(point)) {
|
|
@@ -59,7 +63,13 @@ let ExtensionPointDefaults = class ExtensionPointDefaults {
|
|
|
59
63
|
if (!chosen.ok)
|
|
60
64
|
return chosen;
|
|
61
65
|
const c = chosen.candidate;
|
|
62
|
-
return {
|
|
66
|
+
return {
|
|
67
|
+
ok: true,
|
|
68
|
+
extension: c.extension,
|
|
69
|
+
impl: c.impl,
|
|
70
|
+
orgConfig: c.orgConfig,
|
|
71
|
+
config: c.config,
|
|
72
|
+
};
|
|
63
73
|
}
|
|
64
74
|
/** Every `org-default` point with its candidates, stored default and effective provider. */
|
|
65
75
|
async list(orgId) {
|
|
@@ -145,11 +155,28 @@ let ExtensionPointDefaults = class ExtensionPointDefaults {
|
|
|
145
155
|
}
|
|
146
156
|
if (!cfg?.enabled)
|
|
147
157
|
continue;
|
|
148
|
-
|
|
158
|
+
// spec A §6: an org whose effective config is not valid gets no call from this extension
|
|
159
|
+
let effective;
|
|
160
|
+
try {
|
|
161
|
+
effective = await this.effective.get(orgId, extension);
|
|
162
|
+
}
|
|
163
|
+
catch (err) {
|
|
164
|
+
this.log.warn("org default provider: provider excluded, cannot read its effective config", {
|
|
165
|
+
orgId,
|
|
166
|
+
point,
|
|
167
|
+
extension,
|
|
168
|
+
err,
|
|
169
|
+
});
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (!effective.ok)
|
|
173
|
+
continue;
|
|
174
|
+
const configured = impl
|
|
175
|
+
.configured;
|
|
149
176
|
if (typeof configured === "function") {
|
|
150
177
|
let ok;
|
|
151
178
|
try {
|
|
152
|
-
ok = configured.call(impl, cfg.config) !== false;
|
|
179
|
+
ok = configured.call(impl, cfg.config, effective.config) !== false;
|
|
153
180
|
}
|
|
154
181
|
catch (err) {
|
|
155
182
|
this.log.warn("org default provider: provider excluded, configured() threw", {
|
|
@@ -163,7 +190,7 @@ let ExtensionPointDefaults = class ExtensionPointDefaults {
|
|
|
163
190
|
if (!ok)
|
|
164
191
|
continue;
|
|
165
192
|
}
|
|
166
|
-
out.push({ extension, impl, orgConfig: cfg.config });
|
|
193
|
+
out.push({ extension, impl, orgConfig: cfg.config, config: effective.config });
|
|
167
194
|
}
|
|
168
195
|
return out.sort((a, b) => (a.extension < b.extension ? -1 : a.extension > b.extension ? 1 : 0));
|
|
169
196
|
}
|
|
@@ -191,7 +218,8 @@ ExtensionPointDefaults = __decorate([
|
|
|
191
218
|
__param(1, Inject(TransactionHost)),
|
|
192
219
|
__param(2, Inject(ExtensionRegistry)),
|
|
193
220
|
__param(3, Inject(OrgExtensionConfigs)),
|
|
194
|
-
__param(4, Inject(
|
|
221
|
+
__param(4, Inject(EffectiveConfigs)),
|
|
222
|
+
__param(5, Inject(KERNEL_LOGGER))
|
|
195
223
|
], ExtensionPointDefaults);
|
|
196
224
|
export { ExtensionPointDefaults };
|
|
197
225
|
/** Rules 2-4 of spec §6: one candidate → it; several → the stored default if a candidate. */
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { type ExtensionManifest } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
/** 插件依赖解析失败(信息列出插件名与能力名)。 */
|
|
3
3
|
export declare class ExtensionResolveError extends Error {
|
|
4
|
-
|
|
4
|
+
/** Error code of the failure, when it has one. */
|
|
5
|
+
readonly code?: string | undefined;
|
|
6
|
+
constructor(message: string,
|
|
7
|
+
/** Error code of the failure, when it has one. */
|
|
8
|
+
code?: string | undefined);
|
|
5
9
|
}
|
|
6
10
|
/**
|
|
7
11
|
* 校验 sdk 范围、依赖满足度、单选能力唯一性与无环,返回按依赖拓扑排序后的列表(同层保持输入顺序)。
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { EXTENSION_POINT_CARDINALITY, OBJECT_STORE_EXTENSION_POINT, parseExtensionPoint, } from "@capybara-hq/plugin-sdk";
|
|
1
|
+
import { EXTENSION_POINT_CARDINALITY, EXTENSION_POINTS, OBJECT_STORE_EXTENSION_POINT, parseExtensionPoint, } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import semver from "semver";
|
|
3
3
|
/** 插件依赖解析失败(信息列出插件名与能力名)。 */
|
|
4
4
|
export class ExtensionResolveError extends Error {
|
|
5
|
-
|
|
5
|
+
code;
|
|
6
|
+
constructor(message,
|
|
7
|
+
/** Error code of the failure, when it has one. */
|
|
8
|
+
code) {
|
|
6
9
|
super(message);
|
|
10
|
+
this.code = code;
|
|
7
11
|
this.name = "ExtensionResolveError";
|
|
8
12
|
}
|
|
9
13
|
}
|
|
@@ -23,6 +27,15 @@ export function resolveExtensions(manifests, sdkVersion) {
|
|
|
23
27
|
throw new ExtensionResolveError(`plugin ${m.name}: sdk range "${m.sdk}" is not satisfied by SDK_VERSION ${sdkVersion}`);
|
|
24
28
|
}
|
|
25
29
|
}
|
|
30
|
+
for (const m of manifests) {
|
|
31
|
+
for (const ref of m.provides) {
|
|
32
|
+
const { name, major } = parseExtensionPoint(ref);
|
|
33
|
+
const majors = EXTENSION_POINTS[name]?.majors;
|
|
34
|
+
if (majors && !majors.includes(major)) {
|
|
35
|
+
throw new ExtensionResolveError(`Plugin ${m.name} provides ${ref}, which this kernel no longer supports; upgrade it to a version that provides ${name}@${Math.max(...majors)}.`, "extension.unsupported_extension_point");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
26
39
|
const providers = new Map();
|
|
27
40
|
for (const m of manifests) {
|
|
28
41
|
for (const cap of m.provides)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The extension state the model domain reads below the host: the install records with their
|
|
3
|
+
* packages and approvals, and each extension's effective config per org. Apart from
|
|
4
|
+
* `ExtensionsModule` so the model provider registry (and the `ctx.models` broker the host injects)
|
|
5
|
+
* can depend on it without a module cycle (writing-kernel-api: a cycle is cut by moving the shared
|
|
6
|
+
* part into its own provider both sides inject). `ExtensionsModule` re-exports it.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ExtensionStateModule {
|
|
9
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Module } from "@nestjs/common";
|
|
8
|
+
import { SuperAdminLockModule } from "../identity/super-admin.js";
|
|
9
|
+
import { OrgLockModule } from "../orgs/org-lock.js";
|
|
10
|
+
import { StorageModule } from "../storage/storage.module.js";
|
|
11
|
+
import { ExtensionApprovals } from "./approvals.js";
|
|
12
|
+
import { ExtensionBlobs } from "./blobs.js";
|
|
13
|
+
import { EffectiveConfigs } from "./effective-config.js";
|
|
14
|
+
import { ExtensionInstalls } from "./installs.js";
|
|
15
|
+
import { ExtensionRegistryModule } from "./registry.js";
|
|
16
|
+
/**
|
|
17
|
+
* The extension state the model domain reads below the host: the install records with their
|
|
18
|
+
* packages and approvals, and each extension's effective config per org. Apart from
|
|
19
|
+
* `ExtensionsModule` so the model provider registry (and the `ctx.models` broker the host injects)
|
|
20
|
+
* can depend on it without a module cycle (writing-kernel-api: a cycle is cut by moving the shared
|
|
21
|
+
* part into its own provider both sides inject). `ExtensionsModule` re-exports it.
|
|
22
|
+
*/
|
|
23
|
+
let ExtensionStateModule = class ExtensionStateModule {
|
|
24
|
+
};
|
|
25
|
+
ExtensionStateModule = __decorate([
|
|
26
|
+
Module({
|
|
27
|
+
imports: [ExtensionRegistryModule, SuperAdminLockModule, OrgLockModule, StorageModule],
|
|
28
|
+
providers: [ExtensionApprovals, ExtensionBlobs, ExtensionInstalls, EffectiveConfigs],
|
|
29
|
+
exports: [
|
|
30
|
+
ExtensionRegistryModule,
|
|
31
|
+
ExtensionApprovals,
|
|
32
|
+
ExtensionBlobs,
|
|
33
|
+
ExtensionInstalls,
|
|
34
|
+
EffectiveConfigs,
|
|
35
|
+
],
|
|
36
|
+
})
|
|
37
|
+
], ExtensionStateModule);
|
|
38
|
+
export { ExtensionStateModule };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type FilePreviewer, type Logger, type UiView } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { ConversationFiles } from "../conversations/files.js";
|
|
3
|
+
import { EffectiveConfigs } from "../extensions/effective-config.js";
|
|
3
4
|
import { ExtensionHost } from "../extensions/host.js";
|
|
4
5
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
5
6
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
@@ -39,7 +40,7 @@ export declare class PreviewerRegistry {
|
|
|
39
40
|
readonly txHost: TransactionHost;
|
|
40
41
|
private readonly timeoutMs;
|
|
41
42
|
private readonly d;
|
|
42
|
-
constructor(kdb: Pick<KernelDb, "db">, host: Pick<ExtensionHost, "list" | "enabledPlugins">, files: Pick<ConversationFiles, "file">, storage: Pick<StorageService, "kernel">, log: Pick<Logger, "warn">, txHost: TransactionHost, timeoutMs?: number);
|
|
43
|
+
constructor(kdb: Pick<KernelDb, "db">, host: Pick<ExtensionHost, "list" | "enabledPlugins">, files: Pick<ConversationFiles, "file">, storage: Pick<StorageService, "kernel">, effective: Pick<EffectiveConfigs, "get">, log: Pick<Logger, "warn">, txHost: TransactionHost, timeoutMs?: number);
|
|
43
44
|
/** Every previewer loaded on this replica, in provider order (load order, then list order). */
|
|
44
45
|
private loaded;
|
|
45
46
|
/** The org's previewers (enabled extensions only) in its order, disabled ones included. */
|
|
@@ -65,6 +66,12 @@ export declare class PreviewerRegistry {
|
|
|
65
66
|
private putIn;
|
|
66
67
|
/** Previewers that take this file (viewer must read the conversation), in the org's order. */
|
|
67
68
|
forFile(orgId: string, conversationId: string, viewer: string, fileId: string): Promise<PreviewerItem[]>;
|
|
69
|
+
/**
|
|
70
|
+
* The org's enabled previewers that take the file, each with its extension's effective config
|
|
71
|
+
* for the org. An extension whose effective config is not valid in the org (or cannot be read)
|
|
72
|
+
* previews nothing there (layering spec A §6): its previewers are left out, so the next one or a
|
|
73
|
+
* built-in takes the file.
|
|
74
|
+
*/
|
|
68
75
|
private accepting;
|
|
69
76
|
/**
|
|
70
77
|
* Renders a view previewer for one file: 404 `ui.not_found` when it does not take the file (or is
|
package/dist/files/previewers.js
CHANGED
|
@@ -12,6 +12,7 @@ import { Inject, Injectable, Optional } from "@nestjs/common";
|
|
|
12
12
|
import { sql } from "kysely";
|
|
13
13
|
import { ConversationFiles } from "../conversations/files.js";
|
|
14
14
|
import { ApiError } from "../errors.js";
|
|
15
|
+
import { EffectiveConfigs } from "../extensions/effective-config.js";
|
|
15
16
|
import { ExtensionHost } from "../extensions/host.js";
|
|
16
17
|
import { audit } from "../identity/audit.js";
|
|
17
18
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
@@ -71,7 +72,7 @@ let PreviewerRegistry = class PreviewerRegistry {
|
|
|
71
72
|
txHost;
|
|
72
73
|
timeoutMs;
|
|
73
74
|
d;
|
|
74
|
-
constructor(kdb, host, files, storage, log, txHost, timeoutMs = FILE_PREVIEW_TIMEOUT_MS) {
|
|
75
|
+
constructor(kdb, host, files, storage, effective, log, txHost, timeoutMs = FILE_PREVIEW_TIMEOUT_MS) {
|
|
75
76
|
this.txHost = txHost;
|
|
76
77
|
this.timeoutMs = timeoutMs;
|
|
77
78
|
this.d = {
|
|
@@ -82,6 +83,7 @@ let PreviewerRegistry = class PreviewerRegistry {
|
|
|
82
83
|
enabledPlugins: (orgId) => host.enabledPlugins(orgId),
|
|
83
84
|
files,
|
|
84
85
|
storage,
|
|
86
|
+
effective,
|
|
85
87
|
log,
|
|
86
88
|
};
|
|
87
89
|
}
|
|
@@ -186,8 +188,33 @@ let PreviewerRegistry = class PreviewerRegistry {
|
|
|
186
188
|
const file = await this.d.files.file(orgId, conversationId, viewer, fileId);
|
|
187
189
|
return (await this.accepting(orgId, file)).map(item);
|
|
188
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* The org's enabled previewers that take the file, each with its extension's effective config
|
|
193
|
+
* for the org. An extension whose effective config is not valid in the org (or cannot be read)
|
|
194
|
+
* previews nothing there (layering spec A §6): its previewers are left out, so the next one or a
|
|
195
|
+
* built-in takes the file.
|
|
196
|
+
*/
|
|
189
197
|
async accepting(orgId, file) {
|
|
190
|
-
|
|
198
|
+
const taking = (await this.ordered(orgId)).filter((l) => !l.disabled && previewerAccepts(l.previewer, file));
|
|
199
|
+
const configs = new Map();
|
|
200
|
+
for (const plugin of new Set(taking.map((l) => l.plugin))) {
|
|
201
|
+
try {
|
|
202
|
+
const e = await this.d.effective.get(orgId, plugin);
|
|
203
|
+
configs.set(plugin, e.ok ? { config: e.config } : null);
|
|
204
|
+
}
|
|
205
|
+
catch (err) {
|
|
206
|
+
this.d.log.warn("file previewer left out: cannot read its effective config", {
|
|
207
|
+
orgId,
|
|
208
|
+
plugin,
|
|
209
|
+
err,
|
|
210
|
+
});
|
|
211
|
+
configs.set(plugin, null);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return taking.flatMap((l) => {
|
|
215
|
+
const c = configs.get(l.plugin);
|
|
216
|
+
return c ? [{ ...l, config: c.config }] : [];
|
|
217
|
+
});
|
|
191
218
|
}
|
|
192
219
|
/**
|
|
193
220
|
* Renders a view previewer for one file: 404 `ui.not_found` when it does not take the file (or is
|
|
@@ -224,6 +251,7 @@ let PreviewerRegistry = class PreviewerRegistry {
|
|
|
224
251
|
accountId: t.accountId,
|
|
225
252
|
conversationId: t.conversationId,
|
|
226
253
|
locale: t.locale,
|
|
254
|
+
config: l.config,
|
|
227
255
|
signal: s,
|
|
228
256
|
file: {
|
|
229
257
|
id: file.id,
|
|
@@ -289,9 +317,10 @@ PreviewerRegistry = __decorate([
|
|
|
289
317
|
__param(1, Inject(ExtensionHost)),
|
|
290
318
|
__param(2, Inject(ConversationFiles)),
|
|
291
319
|
__param(3, Inject(StorageService)),
|
|
292
|
-
__param(4, Inject(
|
|
293
|
-
__param(5, Inject(
|
|
294
|
-
__param(6,
|
|
295
|
-
__param(
|
|
320
|
+
__param(4, Inject(EffectiveConfigs)),
|
|
321
|
+
__param(5, Inject(KERNEL_LOGGER)),
|
|
322
|
+
__param(6, Inject(TransactionHost)),
|
|
323
|
+
__param(7, Optional()),
|
|
324
|
+
__param(7, Inject(FILE_PREVIEW_TIMEOUT))
|
|
296
325
|
], PreviewerRegistry);
|
|
297
326
|
export { PreviewerRegistry };
|
package/dist/http/api.module.js
CHANGED
|
@@ -13,25 +13,30 @@ import { SetupController } from "../admin/setup.controller.js";
|
|
|
13
13
|
import { AgentsController } from "../agents/agents.controller.js";
|
|
14
14
|
import { AgentsModule } from "../agents/agents.module.js";
|
|
15
15
|
import { ModelsController } from "../agents/models.controller.js";
|
|
16
|
+
import { PendingConnectorsController } from "../agents/pending-connectors.controller.js";
|
|
16
17
|
import { ReadinessController } from "../agents/readiness.controller.js";
|
|
17
|
-
import { AgentTemplatesController } from "../agents/templates.controller.js";
|
|
18
|
+
import { AgentSaveAsTemplateController, AgentTemplatesController, } from "../agents/templates.controller.js";
|
|
18
19
|
import { BackgroundController } from "../background/background.controller.js";
|
|
19
20
|
import { BackgroundModule } from "../background/background.module.js";
|
|
20
21
|
import { AdminCatalogController } from "../catalog/admin-catalog.controller.js";
|
|
21
22
|
import { CatalogModule } from "../catalog/catalog.module.js";
|
|
22
|
-
import {
|
|
23
|
+
import { AdminComponentsController, OrgComponentsController, } from "../catalog/component-scope.controller.js";
|
|
24
|
+
import { MarketplacesController, OrgMarketplacesController, } from "../catalog/marketplaces.controller.js";
|
|
23
25
|
import { AdminCatalogRequestsController, OrgCatalogController, } from "../catalog/org-catalog.controller.js";
|
|
26
|
+
import { OrgExtensionConfigsController, OrgExtensionOverridesController, OrgExtensionToolSwitchesController, } from "../catalog/org-extension.controller.js";
|
|
27
|
+
import { OrgOwnedPluginsController, OrgPluginUploadsController, } from "../catalog/org-plugin-uploads.controller.js";
|
|
24
28
|
import { ChannelsModule } from "../channels/channels.module.js";
|
|
25
29
|
import { ChannelConnectionsController } from "../channels/connections.controller.js";
|
|
26
30
|
import { AttachmentsController } from "../conversations/attachments.controller.js";
|
|
27
31
|
import { ConversationsController } from "../conversations/conversations.controller.js";
|
|
28
32
|
import { ConversationsModule } from "../conversations/conversations.module.js";
|
|
33
|
+
import { EnvironmentsController } from "../environments/environments.controller.js";
|
|
34
|
+
import { EnvironmentsModule } from "../environments/environments.module.js";
|
|
29
35
|
import { EvalsModule } from "../evals/evals.module.js";
|
|
30
36
|
import { EvalRunsController } from "../evals/runs.controller.js";
|
|
31
37
|
import { EvalSetsController } from "../evals/sets.controller.js";
|
|
32
38
|
import { TrajectoryController } from "../evals/trajectory.controller.js";
|
|
33
39
|
import { ExtensionsModule } from "../extensions/extensions.module.js";
|
|
34
|
-
import { OrgExtensionConfigsController } from "../extensions/org-config.controller.js";
|
|
35
40
|
import { ExtensionPointDefaultsController } from "../extensions/point-defaults.controller.js";
|
|
36
41
|
import { FilesModule } from "../files/files.module.js";
|
|
37
42
|
import { FilePreviewersController } from "../files/previewers.controller.js";
|
|
@@ -41,6 +46,8 @@ import { IdentityModule } from "../identity/identity.module.js";
|
|
|
41
46
|
import { MeController } from "../identity/me.controller.js";
|
|
42
47
|
import { BindController, MeIdentitiesController, SsoController, } from "../identity/sso.controller.js";
|
|
43
48
|
import { InboxModule } from "../inbox/inbox.module.js";
|
|
49
|
+
import { PlatformInboxController } from "../inbox/platform-inbox.controller.js";
|
|
50
|
+
import { ModelEnablementController } from "../models/enablement.controller.js";
|
|
44
51
|
import { ModelsModule } from "../models/models.module.js";
|
|
45
52
|
import { ModelPurposesController } from "../models/purposes.controller.js";
|
|
46
53
|
import { DirectorySyncController } from "../orgs/directory-sync.controller.js";
|
|
@@ -58,6 +65,7 @@ import { StorageModule } from "../storage/storage.module.js";
|
|
|
58
65
|
import { ApprovalsController, ToolGrantsController } from "../tools/approvals.controller.js";
|
|
59
66
|
import { ConnectorContentController } from "../tools/connector-content.controller.js";
|
|
60
67
|
import { ConnectorsController } from "../tools/connectors.controller.js";
|
|
68
|
+
import { ExtensionToolsController } from "../tools/extension-tools.controller.js";
|
|
61
69
|
import { OAuthCallbackController, OAuthConnectController, } from "../tools/oauth/oauth.controller.js";
|
|
62
70
|
import { QuestionsController } from "../tools/questions.controller.js";
|
|
63
71
|
import { ToolsModule } from "../tools/tools.module.js";
|
|
@@ -74,26 +82,36 @@ const CONTROLLERS = [
|
|
|
74
82
|
AdminController,
|
|
75
83
|
AdminExtensionsController,
|
|
76
84
|
AdminCatalogController,
|
|
85
|
+
AdminComponentsController,
|
|
77
86
|
MarketplacesController,
|
|
87
|
+
OrgMarketplacesController,
|
|
78
88
|
OrgExtensionConfigsController,
|
|
89
|
+
OrgExtensionOverridesController,
|
|
90
|
+
OrgExtensionToolSwitchesController,
|
|
79
91
|
AgentsController,
|
|
80
92
|
AgentTemplatesController,
|
|
93
|
+
AgentSaveAsTemplateController,
|
|
94
|
+
PendingConnectorsController,
|
|
81
95
|
ModelsController,
|
|
96
|
+
ModelEnablementController,
|
|
82
97
|
ReadinessController,
|
|
83
98
|
ConversationsController,
|
|
84
99
|
BackgroundController,
|
|
100
|
+
EnvironmentsController,
|
|
85
101
|
AttachmentsController,
|
|
86
102
|
SkillsController,
|
|
87
103
|
SkillChangesController,
|
|
88
104
|
AgentSkillsController,
|
|
89
105
|
InvocableSkillsController,
|
|
90
106
|
InboxController,
|
|
107
|
+
PlatformInboxController,
|
|
91
108
|
ConversationStreamController,
|
|
92
109
|
ConnectorContentController,
|
|
93
110
|
ConnectorsController,
|
|
94
111
|
ApprovalsController,
|
|
95
112
|
ToolGrantsController,
|
|
96
113
|
QuestionsController,
|
|
114
|
+
ExtensionToolsController,
|
|
97
115
|
OAuthConnectController,
|
|
98
116
|
OAuthCallbackController,
|
|
99
117
|
SsoController,
|
|
@@ -109,6 +127,9 @@ const CONTROLLERS = [
|
|
|
109
127
|
EvalRunsController,
|
|
110
128
|
ModelPurposesController,
|
|
111
129
|
OrgCatalogController,
|
|
130
|
+
OrgPluginUploadsController,
|
|
131
|
+
OrgOwnedPluginsController,
|
|
132
|
+
OrgComponentsController,
|
|
112
133
|
AdminCatalogRequestsController,
|
|
113
134
|
];
|
|
114
135
|
/**
|
|
@@ -134,6 +155,7 @@ ApiModule = __decorate([
|
|
|
134
155
|
AgentsModule,
|
|
135
156
|
ConversationsModule,
|
|
136
157
|
BackgroundModule,
|
|
158
|
+
EnvironmentsModule,
|
|
137
159
|
RuntimeModule,
|
|
138
160
|
ChannelsModule,
|
|
139
161
|
EvalsModule,
|
package/dist/http/app.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export interface CreateHttpAppOptions {
|
|
|
45
45
|
replicaId?: string | undefined;
|
|
46
46
|
/**
|
|
47
47
|
* The size limit for package uploads ({@link PACKAGE_UPLOAD_ROUTES}: extension packages and
|
|
48
|
-
*
|
|
48
|
+
* platform catalog packages, `application/octet-stream`), i.e. `packages.maxBytes`. The route
|
|
49
49
|
* bodyLimit is one byte more: a package exactly one byte over reaches the handler and returns
|
|
50
50
|
* `extension.package_too_large`; larger ones are refused by Fastify itself (413
|
|
51
51
|
* `payload_too_large`).
|
|
@@ -56,11 +56,20 @@ export interface CreateHttpAppOptions {
|
|
|
56
56
|
export declare const EXTENSION_PACKAGE_UPLOAD_ROUTE = "/api/v1/admin/extensions/packages/file";
|
|
57
57
|
/** The plugin package upload route of the catalog import (Fastify route template). */
|
|
58
58
|
export declare const CATALOG_UPLOAD_ROUTE = "/api/v1/admin/catalog/import/file";
|
|
59
|
+
/** The platform skill version upload route (a skill package zip as the raw body). */
|
|
60
|
+
export declare const COMPONENT_SKILL_UPLOAD_ROUTE = "/api/v1/admin/components/skill/:id/versions";
|
|
59
61
|
/**
|
|
60
62
|
* The upload routes that take raw bytes (`application/octet-stream`, limit `packages.maxBytes`,
|
|
61
|
-
* the
|
|
63
|
+
* the super admin is authenticated before the body is read).
|
|
62
64
|
*/
|
|
63
65
|
export declare const PACKAGE_UPLOAD_ROUTES: ReadonlySet<string>;
|
|
66
|
+
/** An org admin's plugin package upload (spec §14, ruling P3-7; a tgz as the raw body). */
|
|
67
|
+
export declare const ORG_PLUGIN_UPLOAD_ROUTE = "/api/v1/orgs/:orgId/catalog/uploads/file";
|
|
68
|
+
/**
|
|
69
|
+
* The org routes that take raw package bytes (limit `packages.maxBytes`): before the body is read
|
|
70
|
+
* the caller is authenticated as a person with the org role of `catalog.upload` (ruling P3-29).
|
|
71
|
+
*/
|
|
72
|
+
export declare const ORG_PACKAGE_UPLOAD_ROUTES: ReadonlySet<string>;
|
|
64
73
|
/**
|
|
65
74
|
* Sets up the Fastify side of the kernel's Nest application (built by `buildKernelApp` from
|
|
66
75
|
* `KernelModule`, which provides the health endpoints and the API) without connecting to anything,
|
package/dist/http/app.js
CHANGED
|
@@ -3,9 +3,11 @@ import fastifyCookie from "@fastify/cookie";
|
|
|
3
3
|
import { ApiError, errorBody } from "../errors.js";
|
|
4
4
|
import { AccountsService } from "../identity/accounts.js";
|
|
5
5
|
import { ApiTokenService } from "../identity/api-tokens.js";
|
|
6
|
-
import {
|
|
6
|
+
import { authenticateOrgUploader, authorizeSuperAdmin, } from "../identity/auth.guard.js";
|
|
7
7
|
import { SessionService } from "../identity/sessions.js";
|
|
8
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
8
9
|
import { withLogContext } from "../log-context.js";
|
|
10
|
+
import { authorizeOrgAction } from "../orgs/org.guard.js";
|
|
9
11
|
import { redactPath } from "./error.filter.js";
|
|
10
12
|
import { registerGatewayRoutes } from "./gateway-routes.js";
|
|
11
13
|
import { createPluginRouter, registerPluginDispatch, staticRouteTable, } from "./plugin-dispatch.js";
|
|
@@ -13,14 +15,24 @@ import { createPluginRouter, registerPluginDispatch, staticRouteTable, } from ".
|
|
|
13
15
|
export const EXTENSION_PACKAGE_UPLOAD_ROUTE = "/api/v1/admin/extensions/packages/file";
|
|
14
16
|
/** The plugin package upload route of the catalog import (Fastify route template). */
|
|
15
17
|
export const CATALOG_UPLOAD_ROUTE = "/api/v1/admin/catalog/import/file";
|
|
18
|
+
/** The platform skill version upload route (a skill package zip as the raw body). */
|
|
19
|
+
export const COMPONENT_SKILL_UPLOAD_ROUTE = "/api/v1/admin/components/skill/:id/versions";
|
|
16
20
|
/**
|
|
17
21
|
* The upload routes that take raw bytes (`application/octet-stream`, limit `packages.maxBytes`,
|
|
18
|
-
* the
|
|
22
|
+
* the super admin is authenticated before the body is read).
|
|
19
23
|
*/
|
|
20
24
|
export const PACKAGE_UPLOAD_ROUTES = new Set([
|
|
21
25
|
EXTENSION_PACKAGE_UPLOAD_ROUTE,
|
|
22
26
|
CATALOG_UPLOAD_ROUTE,
|
|
27
|
+
COMPONENT_SKILL_UPLOAD_ROUTE,
|
|
23
28
|
]);
|
|
29
|
+
/** An org admin's plugin package upload (spec §14, ruling P3-7; a tgz as the raw body). */
|
|
30
|
+
export const ORG_PLUGIN_UPLOAD_ROUTE = "/api/v1/orgs/:orgId/catalog/uploads/file";
|
|
31
|
+
/**
|
|
32
|
+
* The org routes that take raw package bytes (limit `packages.maxBytes`): before the body is read
|
|
33
|
+
* the caller is authenticated as a person with the org role of `catalog.upload` (ruling P3-29).
|
|
34
|
+
*/
|
|
35
|
+
export const ORG_PACKAGE_UPLOAD_ROUTES = new Set([ORG_PLUGIN_UPLOAD_ROUTE]);
|
|
24
36
|
/** Paths without an access log line (probes). */
|
|
25
37
|
const QUIET_PATHS = new Set(["/healthz", "/readyz"]);
|
|
26
38
|
/**
|
|
@@ -92,11 +104,12 @@ export async function createHttpApp(opts, app) {
|
|
|
92
104
|
if (LARGE_BODY_ROUTES.has(r.url) && [r.method].flat().includes("POST")) {
|
|
93
105
|
r.bodyLimit = LARGE_BODY_LIMIT;
|
|
94
106
|
}
|
|
95
|
-
|
|
107
|
+
const upload = PACKAGE_UPLOAD_ROUTES.has(r.url) || ORG_PACKAGE_UPLOAD_ROUTES.has(r.url);
|
|
108
|
+
if (upload && opts.packageMaxBytes !== undefined) {
|
|
96
109
|
r.bodyLimit = opts.packageMaxBytes + 1;
|
|
97
110
|
}
|
|
98
111
|
});
|
|
99
|
-
//
|
|
112
|
+
// 读请求体之前:包上传(插件包、平台目录包)先认证(未认证 / 非超级管理员的大请求体不读进内存);其余内核路由不收
|
|
100
113
|
// application/octet-stream(415)。插件路由 /plugins/* 在自己的作用域里收任何类型,不受影响
|
|
101
114
|
let authServices;
|
|
102
115
|
const services = () => {
|
|
@@ -119,7 +132,20 @@ export async function createHttpApp(opts, app) {
|
|
|
119
132
|
return;
|
|
120
133
|
if (req.method === "POST" && PACKAGE_UPLOAD_ROUTES.has(req.routeOptions.url ?? "")) {
|
|
121
134
|
try {
|
|
122
|
-
await
|
|
135
|
+
await authorizeSuperAdmin(req, services());
|
|
136
|
+
}
|
|
137
|
+
catch (e) {
|
|
138
|
+
return sendError(reply, e, req.method, req.url);
|
|
139
|
+
}
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (req.method === "POST" && ORG_PACKAGE_UPLOAD_ROUTES.has(req.routeOptions.url ?? "")) {
|
|
143
|
+
try {
|
|
144
|
+
// the org admin role before the body (ruling P3-29): no one else makes the kernel buffer
|
|
145
|
+
// a package-sized body
|
|
146
|
+
const principal = await authenticateOrgUploader(req, services());
|
|
147
|
+
const orgId = req.params.orgId ?? "";
|
|
148
|
+
await authorizeOrgAction(app.get(KernelDb, { strict: false }).db, principal, orgId, "catalog.upload");
|
|
123
149
|
}
|
|
124
150
|
catch (e) {
|
|
125
151
|
return sendError(reply, e, req.method, req.url);
|
|
@@ -45,7 +45,10 @@ export declare function createPluginRouter(routes: Route[]): PluginRouter;
|
|
|
45
45
|
* - `req.signal` aborts only when the client disconnects before the response is written (not on
|
|
46
46
|
* normal completion); long-lived handlers use it to unsubscribe;
|
|
47
47
|
* - a throwing handler is logged (path redacted with `redactPath`) and returns 500 `internal` (the
|
|
48
|
-
* error message is not echoed).
|
|
48
|
+
* error message is not echoed), except a `model.hook_denied` `ApiError` that escaped from
|
|
49
|
+
* `ctx.models.embed` (an organization policy hook denied the call, spec B §5.4): a deliberate
|
|
50
|
+
* outcome, not a failure, so it answers 403 `model.hook_denied` with a generic message (the
|
|
51
|
+
* routes are unauthenticated: the policy extension's name and reason are not echoed).
|
|
49
52
|
* - Fastify's own errors (a body over 1 MiB and so on) are mapped to the error envelope by the
|
|
50
53
|
* scope's error handler: 4xx by the common error code table (413 `payload_too_large`, 415
|
|
51
54
|
* `unsupported_media_type` and so on), 5xx are logged and return `internal`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Readable } from "node:stream";
|
|
2
2
|
import FindMyWay from "find-my-way";
|
|
3
|
-
import { errorBody } from "../errors.js";
|
|
3
|
+
import { ApiError, ERROR_CODES, errorBody } from "../errors.js";
|
|
4
4
|
import { ACCESS_COOKIE, REFRESH_COOKIE } from "../identity/cookies.js";
|
|
5
5
|
import { codeForStatus, redactPath } from "./error.filter.js";
|
|
6
6
|
/** 插件路由都在此前缀下(ctx.http.route 已加 `/plugins/<name>` 前缀)。 */
|
|
@@ -47,7 +47,10 @@ export function createPluginRouter(routes) {
|
|
|
47
47
|
* - `req.signal` aborts only when the client disconnects before the response is written (not on
|
|
48
48
|
* normal completion); long-lived handlers use it to unsubscribe;
|
|
49
49
|
* - a throwing handler is logged (path redacted with `redactPath`) and returns 500 `internal` (the
|
|
50
|
-
* error message is not echoed).
|
|
50
|
+
* error message is not echoed), except a `model.hook_denied` `ApiError` that escaped from
|
|
51
|
+
* `ctx.models.embed` (an organization policy hook denied the call, spec B §5.4): a deliberate
|
|
52
|
+
* outcome, not a failure, so it answers 403 `model.hook_denied` with a generic message (the
|
|
53
|
+
* routes are unauthenticated: the policy extension's name and reason are not echoed).
|
|
51
54
|
* - Fastify's own errors (a body over 1 MiB and so on) are mapped to the error envelope by the
|
|
52
55
|
* scope's error handler: 4xx by the common error code table (413 `payload_too_large`, 415
|
|
53
56
|
* `unsupported_media_type` and so on), 5xx are logged and return `internal`.
|
|
@@ -108,6 +111,15 @@ export async function registerPluginDispatch(fastify, getTable, log) {
|
|
|
108
111
|
res = await pluginHandler(webReq);
|
|
109
112
|
}
|
|
110
113
|
catch (err) {
|
|
114
|
+
if (err instanceof ApiError && err.code === "model.hook_denied") {
|
|
115
|
+
log.warn("plugin handler refused: a policy hook denied its model call", {
|
|
116
|
+
method: req.method,
|
|
117
|
+
path: redactPath(path),
|
|
118
|
+
});
|
|
119
|
+
return reply
|
|
120
|
+
.code(ERROR_CODES["model.hook_denied"])
|
|
121
|
+
.send(errorBody(err.code, "An organization policy denied this model call"));
|
|
122
|
+
}
|
|
111
123
|
log.error("plugin handler failed", { method: req.method, path: redactPath(path), err });
|
|
112
124
|
return reply.code(500).send(errorBody("internal", "Internal error"));
|
|
113
125
|
}
|