@capybara-hq/kernel 0.1.0-rc.3 → 0.1.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bootstrap.json +61 -5
- package/dist/admin/admin.controller.d.ts +47 -16
- package/dist/admin/admin.controller.js +44 -19
- package/dist/admin/extensions.controller.d.ts +24 -3
- package/dist/admin/extensions.controller.js +48 -8
- package/dist/admin/setup-lock.d.ts +1 -1
- package/dist/admin/setup-lock.js +1 -1
- package/dist/admin/setup.controller.d.ts +1 -1
- package/dist/admin/setup.controller.js +1 -1
- package/dist/admin/setup.service.d.ts +4 -4
- package/dist/admin/setup.service.js +8 -8
- package/dist/agents/agent-lookup.d.ts +19 -0
- package/dist/agents/agent-lookup.js +21 -0
- package/dist/agents/agent-profile.service.d.ts +29 -0
- package/dist/agents/agent-profile.service.js +117 -0
- package/dist/agents/agents.controller.d.ts +168 -3
- package/dist/agents/agents.controller.js +201 -12
- package/dist/agents/agents.module.d.ts +4 -1
- package/dist/agents/agents.module.js +36 -6
- package/dist/agents/agents.service.d.ts +64 -27
- package/dist/agents/agents.service.js +199 -74
- package/dist/agents/definition.d.ts +53 -0
- package/dist/agents/definition.js +55 -0
- package/dist/agents/from-template.d.ts +106 -0
- package/dist/agents/from-template.js +649 -0
- package/dist/agents/from-template.service.d.ts +60 -0
- package/dist/agents/from-template.service.js +161 -0
- package/dist/agents/instruction-files.d.ts +60 -0
- package/dist/agents/instruction-files.js +111 -0
- package/dist/agents/models.controller.d.ts +9 -3
- package/dist/agents/models.controller.js +19 -4
- package/dist/agents/org-templates.d.ts +176 -0
- package/dist/agents/org-templates.js +827 -0
- package/dist/agents/pending-connector-requests.d.ts +77 -0
- package/dist/agents/pending-connector-requests.js +215 -0
- package/dist/agents/pending-connectors.controller.d.ts +39 -0
- package/dist/agents/pending-connectors.controller.js +91 -0
- package/dist/agents/pending-connectors.service.d.ts +62 -0
- package/dist/agents/pending-connectors.service.js +282 -0
- package/dist/agents/profile.d.ts +96 -0
- package/dist/agents/profile.js +51 -0
- package/dist/agents/readiness.controller.d.ts +26 -0
- package/dist/agents/readiness.controller.js +56 -0
- package/dist/agents/templates.controller.d.ts +86 -5
- package/dist/agents/templates.controller.js +171 -7
- package/dist/agents/templates.d.ts +127 -23
- package/dist/agents/templates.js +476 -53
- package/dist/background/background.controller.d.ts +38 -0
- package/dist/background/background.controller.js +87 -0
- package/dist/background/background.module.d.ts +10 -0
- package/dist/background/background.module.js +39 -0
- package/dist/background/finish.d.ts +44 -0
- package/dist/background/finish.js +94 -0
- package/dist/background/launch-lock.d.ts +15 -0
- package/dist/background/launch-lock.js +40 -0
- package/dist/background/launch.d.ts +36 -0
- package/dist/background/launch.js +70 -0
- package/dist/background/poll.job.d.ts +56 -0
- package/dist/background/poll.job.js +190 -0
- package/dist/background/render.d.ts +23 -0
- package/dist/background/render.js +48 -0
- package/dist/background/session.d.ts +48 -0
- package/dist/background/session.js +79 -0
- package/dist/background/status.d.ts +35 -0
- package/dist/background/status.js +57 -0
- package/dist/background/stop.d.ts +68 -0
- package/dist/background/stop.js +243 -0
- package/dist/background/store.d.ts +162 -0
- package/dist/background/store.js +357 -0
- package/dist/background/store.module.d.ts +6 -0
- package/dist/background/store.module.js +22 -0
- package/dist/background/tasks.service.d.ts +77 -0
- package/dist/background/tasks.service.js +211 -0
- package/dist/background/wake-rules.d.ts +66 -0
- package/dist/background/wake-rules.js +113 -0
- package/dist/background/wake.d.ts +30 -0
- package/dist/background/wake.js +63 -0
- package/dist/catalog/admin-catalog.controller.d.ts +129 -30
- package/dist/catalog/admin-catalog.controller.js +213 -42
- package/dist/catalog/catalog-content.d.ts +58 -32
- package/dist/catalog/catalog-content.js +34 -8
- package/dist/catalog/catalog-import.module.d.ts +7 -0
- package/dist/catalog/catalog-import.module.js +60 -0
- package/dist/catalog/catalog-items.d.ts +111 -7
- package/dist/catalog/catalog-items.js +279 -13
- package/dist/catalog/catalog-scope.service.d.ts +260 -0
- package/dist/catalog/catalog-scope.service.js +1116 -0
- package/dist/catalog/catalog.module.d.ts +7 -9
- package/dist/catalog/catalog.module.js +41 -31
- package/dist/catalog/catalog.service.d.ts +101 -29
- package/dist/catalog/catalog.service.js +104 -106
- package/dist/catalog/claude/agents.js +2 -0
- package/dist/catalog/cli.d.ts +11 -1
- package/dist/catalog/cli.js +26 -1
- package/dist/catalog/component-promotion.d.ts +96 -0
- package/dist/catalog/component-promotion.js +395 -0
- package/dist/catalog/component-scope.controller.d.ts +152 -0
- package/dist/catalog/component-scope.controller.js +287 -0
- package/dist/catalog/component-scope.service.d.ts +303 -0
- package/dist/catalog/component-scope.service.js +936 -0
- package/dist/catalog/component-state.d.ts +174 -0
- package/dist/catalog/component-state.js +437 -0
- package/dist/catalog/job-ids.d.ts +30 -0
- package/dist/catalog/job-ids.js +25 -0
- package/dist/catalog/marketplace-fetch.d.ts +1 -1
- package/dist/catalog/marketplaces.controller.d.ts +22 -5
- package/dist/catalog/marketplaces.controller.js +56 -7
- package/dist/catalog/marketplaces.service.d.ts +54 -14
- package/dist/catalog/marketplaces.service.js +71 -22
- package/dist/catalog/org-catalog.controller.d.ts +125 -34
- package/dist/catalog/org-catalog.controller.js +181 -65
- package/dist/catalog/org-catalog.service.d.ts +65 -33
- package/dist/catalog/org-catalog.service.js +324 -157
- package/dist/catalog/org-extension-switch.d.ts +41 -0
- package/dist/catalog/org-extension-switch.js +115 -0
- package/dist/catalog/org-extension.controller.d.ts +119 -0
- package/dist/catalog/org-extension.controller.js +266 -0
- package/dist/catalog/org-plugin-uploads.controller.d.ts +98 -0
- package/dist/catalog/org-plugin-uploads.controller.js +213 -0
- package/dist/catalog/org-plugin-uploads.d.ts +63 -0
- package/dist/catalog/org-plugin-uploads.js +116 -0
- package/dist/catalog/owned-items.d.ts +184 -0
- package/dist/catalog/owned-items.js +789 -0
- package/dist/catalog/owned-plugin-cleanup.d.ts +56 -0
- package/dist/catalog/owned-plugin-cleanup.js +194 -0
- package/dist/catalog/ownership.d.ts +172 -0
- package/dist/catalog/ownership.js +326 -0
- package/dist/catalog/platform-components.d.ts +221 -0
- package/dist/catalog/platform-components.js +761 -0
- package/dist/catalog/platform-migration.d.ts +115 -0
- package/dist/catalog/platform-migration.js +582 -0
- package/dist/catalog/plugin-import.d.ts +178 -34
- package/dist/catalog/plugin-import.js +623 -83
- package/dist/catalog/plugin-install.d.ts +185 -41
- package/dist/catalog/plugin-install.js +758 -126
- package/dist/catalog/plugin-upgrade.d.ts +260 -225
- package/dist/catalog/plugin-upgrade.js +1148 -1137
- package/dist/catalog/request-rules.d.ts +65 -0
- package/dist/catalog/request-rules.js +217 -0
- package/dist/catalog/requests.service.d.ts +193 -118
- package/dist/catalog/requests.service.js +526 -343
- package/dist/catalog/reserved-names.d.ts +8 -0
- package/dist/catalog/reserved-names.js +42 -0
- package/dist/catalog/scope-orgs.d.ts +21 -0
- package/dist/catalog/scope-orgs.js +67 -0
- package/dist/catalog/scope-state.d.ts +35 -0
- package/dist/catalog/scope-state.js +87 -0
- package/dist/catalog/scope-sync-workers.d.ts +7 -0
- package/dist/catalog/scope-sync-workers.js +29 -0
- package/dist/catalog/scope-sync.d.ts +176 -0
- package/dist/catalog/scope-sync.js +576 -0
- package/dist/catalog/scope.d.ts +42 -0
- package/dist/catalog/scope.js +42 -0
- package/dist/catalog/unshare.d.ts +22 -0
- package/dist/catalog/unshare.js +118 -0
- package/dist/channels/actions.js +1 -0
- package/dist/channels/cards.js +21 -3
- package/dist/channels/channels.module.js +2 -0
- package/dist/channels/connections.service.d.ts +16 -1
- package/dist/channels/connections.service.js +38 -4
- package/dist/channels/inbound.d.ts +9 -1
- package/dist/channels/inbound.js +67 -5
- package/dist/channels/phrases.d.ts +35 -0
- package/dist/channels/phrases.js +29 -0
- package/dist/channels/threads.d.ts +5 -0
- package/dist/channels/threads.js +8 -0
- package/dist/config/docs.js +3 -1
- package/dist/config/schema.d.ts +24 -2
- package/dist/config/schema.js +145 -19
- package/dist/conversations/access.d.ts +6 -4
- package/dist/conversations/access.js +29 -5
- package/dist/conversations/agent-tree.d.ts +46 -0
- package/dist/conversations/agent-tree.js +92 -0
- package/dist/conversations/attachments.service.d.ts +30 -0
- package/dist/conversations/attachments.service.js +130 -5
- package/dist/conversations/conversations.controller.d.ts +79 -23
- package/dist/conversations/conversations.controller.js +141 -50
- package/dist/conversations/conversations.module.d.ts +1 -1
- package/dist/conversations/conversations.module.js +10 -7
- package/dist/conversations/conversations.service.d.ts +108 -9
- package/dist/conversations/conversations.service.js +237 -30
- package/dist/conversations/environment-status.d.ts +24 -0
- package/dist/conversations/environment-status.js +71 -0
- package/dist/conversations/event-log.d.ts +21 -6
- package/dist/conversations/event-log.js +70 -1
- package/dist/conversations/events.d.ts +140 -0
- package/dist/conversations/events.js +142 -13
- package/dist/conversations/queue.d.ts +3 -1
- package/dist/conversations/queue.js +13 -2
- package/dist/conversations/queue.service.d.ts +1 -1
- package/dist/conversations/queue.service.js +8 -1
- package/dist/conversations/titles.d.ts +12 -3
- package/dist/conversations/titles.js +36 -8
- package/dist/conversations/tree.d.ts +17 -0
- package/dist/conversations/tree.js +42 -0
- package/dist/ctx/create-ctx.d.ts +5 -0
- package/dist/ctx/create-ctx.js +15 -5
- package/dist/db/kernel-schema.d.ts +420 -20
- package/dist/db/pool.d.ts +5 -0
- package/dist/db/pool.js +3 -0
- package/dist/environments/access.d.ts +41 -0
- package/dist/environments/access.js +77 -0
- package/dist/environments/conversation-environments.d.ts +61 -0
- package/dist/environments/conversation-environments.js +170 -0
- package/dist/environments/dto.d.ts +25 -0
- package/dist/environments/dto.js +12 -0
- package/dist/environments/environments.controller.d.ts +33 -0
- package/dist/environments/environments.controller.js +110 -0
- package/dist/environments/environments.module.d.ts +8 -0
- package/dist/environments/environments.module.js +27 -0
- package/dist/environments/environments.service.d.ts +153 -0
- package/dist/environments/environments.service.js +541 -0
- package/dist/environments/legacy-cleanup.job.d.ts +34 -0
- package/dist/environments/legacy-cleanup.job.js +141 -0
- package/dist/errors.d.ts +90 -2
- package/dist/errors.js +90 -2
- package/dist/evals/reconstruct.d.ts +18 -9
- package/dist/evals/reconstruct.js +26 -7
- package/dist/evals/run-replay.d.ts +7 -2
- package/dist/evals/run-replay.js +42 -7
- package/dist/evals/step-replay.d.ts +2 -5
- package/dist/evals/step-replay.js +13 -7
- package/dist/evals/trajectory.js +1 -1
- package/dist/evals/trajectory.service.d.ts +8 -3
- package/dist/evals/trajectory.service.js +26 -14
- package/dist/evals/worker.d.ts +5 -5
- package/dist/evals/worker.js +9 -3
- package/dist/extensions/admin-ops.d.ts +36 -10
- package/dist/extensions/admin-ops.js +67 -42
- package/dist/extensions/admin-view.d.ts +39 -10
- package/dist/extensions/admin-view.js +111 -20
- package/dist/extensions/blobs.js +1 -0
- package/dist/extensions/bootstrap.d.ts +17 -4
- package/dist/extensions/bootstrap.js +70 -9
- package/dist/extensions/cli.d.ts +12 -0
- package/dist/extensions/cli.js +11 -2
- package/dist/extensions/config-issues.d.ts +13 -1
- package/dist/extensions/config-issues.js +22 -5
- package/dist/extensions/config-json-schema.d.ts +43 -7
- package/dist/extensions/config-json-schema.js +124 -58
- package/dist/extensions/deployment-config-store.d.ts +6 -0
- package/dist/extensions/deployment-config.d.ts +78 -8
- package/dist/extensions/deployment-config.js +172 -34
- package/dist/extensions/display-name.d.ts +22 -0
- package/dist/extensions/display-name.js +77 -0
- package/dist/extensions/effective-config.d.ts +127 -0
- package/dist/extensions/effective-config.js +368 -0
- package/dist/extensions/extensions.module.js +14 -2
- package/dist/extensions/hooks.d.ts +37 -4
- package/dist/extensions/hooks.js +82 -16
- package/dist/extensions/host.d.ts +45 -2
- package/dist/extensions/host.js +112 -16
- package/dist/extensions/installs.d.ts +20 -8
- package/dist/extensions/installs.js +37 -15
- package/dist/extensions/org-config.d.ts +81 -6
- package/dist/extensions/org-config.js +195 -44
- package/dist/extensions/org-levels.d.ts +37 -0
- package/dist/extensions/org-levels.js +71 -0
- package/dist/extensions/org-overrides.d.ts +151 -0
- package/dist/extensions/org-overrides.js +524 -0
- package/dist/extensions/package.d.ts +14 -1
- package/dist/extensions/package.js +51 -2
- package/dist/extensions/permission-view.d.ts +19 -4
- package/dist/extensions/permission-view.js +4 -4
- package/dist/extensions/plugin-items.d.ts +21 -0
- package/dist/extensions/plugin-items.js +42 -0
- package/dist/extensions/point-defaults.controller.d.ts +34 -0
- package/dist/extensions/point-defaults.controller.js +71 -0
- package/dist/extensions/point-defaults.d.ts +71 -0
- package/dist/extensions/point-defaults.js +234 -0
- package/dist/extensions/registry.d.ts +1 -1
- package/dist/extensions/registry.js +2 -0
- package/dist/extensions/resolve.d.ts +5 -1
- package/dist/extensions/resolve.js +15 -2
- package/dist/files/previewers.d.ts +8 -1
- package/dist/files/previewers.js +35 -6
- package/dist/http/api.module.js +31 -3
- package/dist/http/app.d.ts +11 -2
- package/dist/http/app.js +31 -5
- package/dist/http/nest-logger.d.ts +6 -5
- package/dist/http/nest-logger.js +24 -10
- package/dist/identity/accounts.d.ts +29 -29
- package/dist/identity/accounts.js +47 -47
- package/dist/identity/audit.d.ts +2 -1
- package/dist/identity/auth.controller.js +9 -5
- package/dist/identity/auth.guard.d.ts +13 -5
- package/dist/identity/auth.guard.js +26 -9
- package/dist/identity/cookies.d.ts +20 -5
- package/dist/identity/cookies.js +44 -6
- package/dist/identity/identity.module.d.ts +1 -1
- package/dist/identity/identity.module.js +4 -4
- package/dist/identity/me.controller.d.ts +5 -1
- package/dist/identity/me.controller.js +12 -3
- package/dist/identity/principal.d.ts +3 -3
- package/dist/identity/principal.js +3 -3
- package/dist/identity/sessions.d.ts +12 -0
- package/dist/identity/sessions.js +45 -0
- package/dist/identity/settings.d.ts +22 -11
- package/dist/identity/settings.js +53 -18
- package/dist/identity/{enterprise-admin.d.ts → super-admin.d.ts} +5 -5
- package/dist/identity/{enterprise-admin.js → super-admin.js} +24 -24
- package/dist/inbox/inbox.module.d.ts +4 -1
- package/dist/inbox/inbox.module.js +7 -3
- package/dist/inbox/inbox.service.d.ts +62 -3
- package/dist/inbox/inbox.service.js +74 -4
- package/dist/inbox/org-notices.d.ts +63 -0
- package/dist/inbox/org-notices.js +91 -0
- package/dist/inbox/platform-inbox.controller.d.ts +23 -0
- package/dist/inbox/platform-inbox.controller.js +58 -0
- package/dist/inbox/platform-inbox.service.d.ts +151 -0
- package/dist/inbox/platform-inbox.service.js +263 -0
- package/dist/inbox/platform-notices.d.ts +19 -0
- package/dist/inbox/platform-notices.js +9 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/infra/cli/kernel-cli.module.js +9 -1
- package/dist/infra/config/kernel-config.service.js +27 -1
- package/dist/infra/database/database.module.js +1 -0
- package/dist/infra/database/xact-lock.d.ts +1 -1
- package/dist/infra/database/xact-lock.js +1 -1
- package/dist/infra/events/kernel-events.d.ts +19 -2
- package/dist/infra/lifecycle/process-guards.js +4 -0
- package/dist/infra/logging/logging.module.d.ts +4 -2
- package/dist/infra/logging/logging.module.js +24 -6
- package/dist/infra/queue/add-job-once.d.ts +14 -0
- package/dist/infra/queue/add-job-once.js +16 -0
- package/dist/infra/queue/redis-connection.d.ts +6 -0
- package/dist/infra/queue/redis-connection.js +7 -0
- package/dist/infra/redis/redis.module.js +6 -2
- package/dist/infra/tokens.d.ts +6 -1
- package/dist/infra/tokens.js +6 -1
- package/dist/kernel.module.js +6 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +1 -1
- package/dist/lifecycle/kernel-lifecycle.js +4 -4
- package/dist/log.d.ts +13 -1
- package/dist/log.js +93 -17
- package/dist/models/prices.d.ts +5 -5
- package/dist/models/prices.js +4 -4
- package/dist/models/purposes.controller.d.ts +6 -4
- package/dist/models/purposes.controller.js +13 -7
- package/dist/models/purposes.d.ts +43 -9
- package/dist/models/purposes.js +48 -18
- package/dist/orgs/directory-sync.d.ts +14 -5
- package/dist/orgs/directory-sync.js +41 -17
- package/dist/orgs/offboarding.d.ts +12 -8
- package/dist/orgs/offboarding.js +54 -33
- package/dist/orgs/org-lock.d.ts +5 -0
- package/dist/orgs/org-lock.js +13 -0
- package/dist/orgs/org.guard.d.ts +10 -0
- package/dist/orgs/org.guard.js +43 -32
- package/dist/orgs/orgs.module.js +3 -0
- package/dist/orgs/orgs.service.d.ts +20 -7
- package/dist/orgs/orgs.service.js +32 -12
- package/dist/orgs/roles.d.ts +1 -1
- package/dist/orgs/roles.js +5 -1
- package/dist/orgs/settings.controller.d.ts +1 -1
- package/dist/orgs/settings.service.d.ts +20 -3
- package/dist/orgs/settings.service.js +19 -4
- package/dist/overrides.d.ts +3 -0
- package/dist/overrides.js +2 -0
- package/dist/platform/actor.d.ts +48 -0
- package/dist/platform/actor.js +100 -0
- package/dist/platform/agent-docs.d.ts +18 -0
- package/dist/platform/agent-docs.js +59 -0
- package/dist/platform/availability.d.ts +14 -0
- package/dist/platform/availability.js +43 -0
- package/dist/platform/errors.d.ts +11 -0
- package/dist/platform/errors.js +26 -0
- package/dist/platform/exclusions.d.ts +12 -0
- package/dist/platform/exclusions.js +1387 -0
- package/dist/platform/method.d.ts +6 -0
- package/dist/platform/method.js +15 -0
- package/dist/platform/operation.d.ts +92 -0
- package/dist/platform/operation.js +35 -0
- package/dist/platform/ops/agent-templates.ops.d.ts +14 -0
- package/dist/platform/ops/agent-templates.ops.js +92 -0
- package/dist/platform/ops/agents.ops.d.ts +19 -0
- package/dist/platform/ops/agents.ops.js +294 -0
- package/dist/platform/ops/connectors.ops.d.ts +15 -0
- package/dist/platform/ops/connectors.ops.js +126 -0
- package/dist/platform/ops/errors.d.ts +11 -0
- package/dist/platform/ops/errors.js +22 -0
- package/dist/platform/ops/extensions.ops.d.ts +19 -0
- package/dist/platform/ops/extensions.ops.js +116 -0
- package/dist/platform/ops/marketplaces.ops.d.ts +16 -0
- package/dist/platform/ops/marketplaces.ops.js +157 -0
- package/dist/platform/ops/paging.d.ts +14 -0
- package/dist/platform/ops/paging.js +20 -0
- package/dist/platform/ops/platform.ops.d.ts +23 -0
- package/dist/platform/ops/platform.ops.js +158 -0
- package/dist/platform/ops/plugins.ops.d.ts +33 -0
- package/dist/platform/ops/plugins.ops.js +377 -0
- package/dist/platform/ops/requests.ops.d.ts +14 -0
- package/dist/platform/ops/requests.ops.js +153 -0
- package/dist/platform/ops/role.d.ts +4 -0
- package/dist/platform/ops/role.js +10 -0
- package/dist/platform/ops/skills.ops.d.ts +13 -0
- package/dist/platform/ops/skills.ops.js +98 -0
- package/dist/platform/ops/summary.d.ts +10 -0
- package/dist/platform/ops/summary.js +18 -0
- package/dist/platform/platform-ops.module.d.ts +7 -0
- package/dist/platform/platform-ops.module.js +55 -0
- package/dist/platform/platform.module.d.ts +8 -0
- package/dist/platform/platform.module.js +25 -0
- package/dist/platform/redact-orgs.d.ts +7 -0
- package/dist/platform/redact-orgs.js +52 -0
- package/dist/platform/registry.d.ts +30 -0
- package/dist/platform/registry.js +111 -0
- package/dist/roles/worker-role.d.ts +6 -4
- package/dist/roles/worker-role.js +14 -7
- package/dist/roles/worker.module.d.ts +1 -1
- package/dist/roles/worker.module.js +15 -1
- package/dist/runtime/context/build.d.ts +11 -7
- package/dist/runtime/context/build.js +46 -19
- package/dist/runtime/context/claude-tools.d.ts +3 -1
- package/dist/runtime/context/claude-tools.js +8 -6
- package/dist/runtime/context/compaction.js +13 -0
- package/dist/runtime/context/reminders.d.ts +2 -0
- package/dist/runtime/context/reminders.js +2 -0
- package/dist/runtime/context/skills.js +9 -2
- package/dist/runtime/context/tool-changes.d.ts +27 -0
- package/dist/runtime/context/tool-changes.js +60 -0
- package/dist/runtime/hook-calls.js +2 -0
- package/dist/runtime/langgraph-loop.d.ts +3 -1
- package/dist/runtime/langgraph-loop.js +36 -17
- package/dist/runtime/loop.d.ts +34 -5
- package/dist/runtime/maintenance.d.ts +9 -4
- package/dist/runtime/maintenance.js +35 -8
- package/dist/runtime/model-call.d.ts +46 -8
- package/dist/runtime/model-call.js +72 -21
- package/dist/runtime/providers.d.ts +6 -0
- package/dist/runtime/providers.js +8 -0
- package/dist/runtime/run-control.d.ts +11 -1
- package/dist/runtime/run-control.js +12 -0
- package/dist/runtime/run-drafts.d.ts +85 -0
- package/dist/runtime/run-drafts.js +230 -0
- package/dist/runtime/run-jobs.d.ts +3 -5
- package/dist/runtime/run-jobs.js +3 -7
- package/dist/runtime/run-queue.d.ts +59 -2
- package/dist/runtime/run-queue.js +311 -38
- package/dist/runtime/run-worker.d.ts +11 -5
- package/dist/runtime/run-worker.js +69 -33
- package/dist/runtime/runtime.module.js +11 -3
- package/dist/runtime/step-log.d.ts +15 -4
- package/dist/runtime/step-log.js +24 -7
- package/dist/runtime/stream.controller.d.ts +23 -1
- package/dist/runtime/stream.controller.js +60 -3
- package/dist/runtime/stream.d.ts +4 -1
- package/dist/runtime/stream.js +27 -3
- package/dist/runtime/subagents/child.d.ts +55 -7
- package/dist/runtime/subagents/child.js +105 -7
- package/dist/runtime/subagents/definition.d.ts +12 -3
- package/dist/runtime/subagents/definition.js +44 -28
- package/dist/runtime/subagents/deliveries.d.ts +71 -0
- package/dist/runtime/subagents/deliveries.js +228 -0
- package/dist/runtime/subagents/dispatch.d.ts +115 -26
- package/dist/runtime/subagents/dispatch.js +212 -141
- package/dist/runtime/subagents/limits.d.ts +24 -5
- package/dist/runtime/subagents/limits.js +40 -6
- package/dist/runtime/subagents/messages.d.ts +95 -0
- package/dist/runtime/subagents/messages.js +328 -0
- package/dist/runtime/subagents/preamble.d.ts +4 -4
- package/dist/runtime/subagents/preamble.js +9 -7
- package/dist/runtime/subagents/progress.d.ts +8 -6
- package/dist/runtime/subagents/progress.js +11 -6
- package/dist/runtime/subagents/render.d.ts +30 -0
- package/dist/runtime/subagents/render.js +53 -0
- package/dist/runtime/subagents/roster.d.ts +24 -7
- package/dist/runtime/subagents/roster.js +47 -11
- package/dist/runtime/subagents/skill-fork.d.ts +3 -2
- package/dist/runtime/subagents/skill-fork.js +8 -4
- package/dist/runtime/subagents/status.d.ts +14 -0
- package/dist/runtime/subagents/status.js +23 -0
- package/dist/runtime/subagents/subagents.service.d.ts +7 -4
- package/dist/runtime/subagents/subagents.service.js +11 -6
- package/dist/runtime/usage-report.d.ts +2 -1
- package/dist/runtime/usage-report.js +19 -13
- package/dist/runtime/waits.d.ts +145 -36
- package/dist/runtime/waits.js +423 -109
- package/dist/sandbox/jobs.d.ts +40 -13
- package/dist/sandbox/jobs.js +57 -20
- package/dist/sandbox/leases.d.ts +37 -54
- package/dist/sandbox/leases.js +71 -115
- package/dist/sandbox/providers.d.ts +2 -2
- package/dist/sandbox/providers.js +1 -1
- package/dist/sandbox/sandbox.module.d.ts +3 -2
- package/dist/sandbox/sandbox.module.js +10 -4
- package/dist/sandbox/sandbox.service.d.ts +282 -129
- package/dist/sandbox/sandbox.service.js +736 -381
- package/dist/skills/catalog.d.ts +3 -2
- package/dist/skills/catalog.js +21 -43
- package/dist/skills/changes.controller.d.ts +7 -0
- package/dist/skills/changes.controller.js +19 -1
- package/dist/skills/invoke.js +8 -3
- package/dist/skills/package.d.ts +20 -1
- package/dist/skills/package.js +28 -1
- package/dist/skills/skills.controller.d.ts +39 -4
- package/dist/skills/skills.controller.js +88 -10
- package/dist/skills/skills.module.js +10 -1
- package/dist/skills/skills.service.d.ts +106 -26
- package/dist/skills/skills.service.js +421 -75
- package/dist/skills/usable.d.ts +81 -0
- package/dist/skills/usable.js +379 -0
- package/dist/tools/approvals.service.d.ts +20 -2
- package/dist/tools/approvals.service.js +25 -4
- package/dist/tools/builtin-names.d.ts +41 -7
- package/dist/tools/builtin-names.js +59 -7
- package/dist/tools/builtins/agent.d.ts +23 -21
- package/dist/tools/builtins/agent.js +62 -55
- package/dist/tools/builtins/builtin-tools.d.ts +19 -1
- package/dist/tools/builtins/builtin-tools.js +59 -2
- package/dist/tools/builtins/handback.d.ts +28 -0
- package/dist/tools/builtins/handback.js +53 -0
- package/dist/tools/builtins/platform.d.ts +34 -0
- package/dist/tools/builtins/platform.js +362 -0
- package/dist/tools/builtins/sandbox/bash.d.ts +1 -1
- package/dist/tools/builtins/sandbox/bash.js +241 -4
- package/dist/tools/builtins/sandbox/common.d.ts +69 -27
- package/dist/tools/builtins/sandbox/common.js +87 -48
- package/dist/tools/builtins/sandbox/deliver.js +1 -1
- package/dist/tools/builtins/sandbox/edit.js +2 -2
- package/dist/tools/builtins/sandbox/glob.js +2 -2
- package/dist/tools/builtins/sandbox/grep.js +2 -4
- package/dist/tools/builtins/sandbox/index.d.ts +3 -1
- package/dist/tools/builtins/sandbox/index.js +7 -1
- package/dist/tools/builtins/sandbox/read.js +1 -1
- package/dist/tools/builtins/sandbox/task-output.d.ts +74 -0
- package/dist/tools/builtins/sandbox/task-output.js +329 -0
- package/dist/tools/builtins/sandbox/task-stop.d.ts +10 -0
- package/dist/tools/builtins/sandbox/task-stop.js +113 -0
- package/dist/tools/builtins/sandbox/write.js +2 -2
- package/dist/tools/builtins/send-message.d.ts +56 -0
- package/dist/tools/builtins/send-message.js +100 -0
- package/dist/tools/builtins/skill-load.d.ts +22 -14
- package/dist/tools/builtins/skill-load.js +86 -57
- package/dist/tools/builtins/skill-write.js +1 -1
- package/dist/tools/builtins/web/errors.d.ts +8 -0
- package/dist/tools/builtins/web/errors.js +53 -0
- package/dist/tools/builtins/web/extract.d.ts +62 -0
- package/dist/tools/builtins/web/extract.js +271 -0
- package/dist/tools/builtins/web/fetch.d.ts +55 -0
- package/dist/tools/builtins/web/fetch.js +175 -0
- package/dist/tools/builtins/web/index.d.ts +13 -0
- package/dist/tools/builtins/web/index.js +12 -0
- package/dist/tools/builtins/web/page-cache.d.ts +25 -0
- package/dist/tools/builtins/web/page-cache.js +77 -0
- package/dist/tools/builtins/web/search.d.ts +25 -0
- package/dist/tools/builtins/web/search.js +210 -0
- package/dist/tools/builtins/web/url.d.ts +17 -0
- package/dist/tools/builtins/web/url.js +43 -0
- package/dist/tools/connectors.controller.d.ts +10 -0
- package/dist/tools/connectors.controller.js +12 -0
- package/dist/tools/connectors.service.d.ts +46 -5
- package/dist/tools/connectors.service.js +94 -15
- package/dist/tools/extension-tools.controller.d.ts +14 -0
- package/dist/tools/extension-tools.controller.js +37 -0
- package/dist/tools/info.d.ts +42 -1
- package/dist/tools/info.js +64 -1
- package/dist/tools/oauth/flow-paths.d.ts +1 -1
- package/dist/tools/oauth/flow-paths.js +1 -1
- package/dist/tools/org-tool-switches.d.ts +74 -0
- package/dist/tools/org-tool-switches.js +184 -0
- package/dist/tools/pipeline.d.ts +46 -40
- package/dist/tools/pipeline.js +202 -364
- package/dist/tools/policy.d.ts +1 -1
- package/dist/tools/policy.js +36 -16
- package/dist/tools/registry.d.ts +120 -8
- package/dist/tools/registry.js +112 -19
- package/dist/tools/tools.module.js +24 -2
- package/dist/tools/validate.js +1 -1
- package/dist/ui/views.d.ts +2 -1
- package/dist/ui/views.js +17 -3
- package/package.json +3 -3
- package/src/migrations/0064_account_last_org.sql +7 -0
- package/src/migrations/0065_conversation_archive.sql +8 -0
- package/src/migrations/0066_extension_display_name.sql +4 -0
- package/src/migrations/0067_agent_profiles.sql +20 -0
- package/src/migrations/0068_agent_avatar_uploads.sql +7 -0
- package/src/migrations/0069_attachments_agent_idx.sql +3 -0
- package/src/migrations/0070_background_tasks.sql +37 -0
- package/src/migrations/0071_background_tasks_reserve.sql +6 -0
- package/src/migrations/0072_background_tasks_stopping.sql +5 -0
- package/src/migrations/0073_org_extension_point_defaults.sql +11 -0
- package/src/migrations/0074_subagent_tree.sql +50 -0
- package/src/migrations/0075_plugin_scope.sql +61 -0
- package/src/migrations/0076_skills_created_by_nullable.sql +6 -0
- package/src/migrations/0077_scope_requests.sql +52 -0
- package/src/migrations/0078_scope_grant_switches.sql +18 -0
- package/src/migrations/0079_scope_live_install_switches.sql +19 -0
- package/src/migrations/0080_rename_enterprise_admin.sql +18 -0
- package/src/migrations/0081_platform_components.sql +129 -0
- package/src/migrations/0082_platform_migration.sql +33 -0
- package/src/migrations/0083_plugin_scope_sync_failures.sql +15 -0
- package/src/migrations/0084_org_owned_items.sql +85 -0
- package/src/migrations/0085_agent_templates_phase4.sql +45 -0
- package/src/migrations/0086_org_layering.sql +30 -0
- package/src/migrations/0087_approval_summary.sql +6 -0
- package/src/migrations/0088_environments.sql +80 -0
- package/dist/catalog/upgrade-targets.d.ts +0 -56
- package/dist/catalog/upgrade-targets.js +0 -90
- package/dist/conversations/sandbox-status.d.ts +0 -24
- package/dist/conversations/sandbox-status.js +0 -52
- package/dist/extensions/org-config.controller.d.ts +0 -24
- package/dist/extensions/org-config.controller.js +0 -62
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { domainToASCII } from "node:url";
|
|
2
|
+
import { ToolError, } from "@capybara-hq/plugin-sdk";
|
|
3
|
+
import { BUILTIN } from "../../builtin-names.js";
|
|
4
|
+
import { webToolError } from "./errors.js";
|
|
5
|
+
/** The extension point name (without the major) the provider is resolved from. */
|
|
6
|
+
const POINT = "web-search";
|
|
7
|
+
/**
|
|
8
|
+
* The fixed spec (web tools spec §3.1). No date and nothing per org or provider: `specHash` stays
|
|
9
|
+
* the same across days and providers, so remembered grants survive both and replays match the log.
|
|
10
|
+
* The date is the first line of every result instead.
|
|
11
|
+
*/
|
|
12
|
+
export const WEB_SEARCH_SPEC = {
|
|
13
|
+
name: BUILTIN.WebSearch,
|
|
14
|
+
// Display only (the tool row; not in the fingerprint, never sent to the model).
|
|
15
|
+
keyArgs: ["query"],
|
|
16
|
+
description: "Search the web and get a list of results with title, URL and a short snippet. Use it for " +
|
|
17
|
+
"information newer than your training data, or to check whether something you know is still " +
|
|
18
|
+
"current. Then use WebFetch to read the pages you need. Do not use it for questions you can " +
|
|
19
|
+
"answer reliably without the web. Cite the sources you use.",
|
|
20
|
+
inputSchema: {
|
|
21
|
+
type: "object",
|
|
22
|
+
properties: {
|
|
23
|
+
query: {
|
|
24
|
+
type: "string",
|
|
25
|
+
minLength: 2,
|
|
26
|
+
maxLength: 500,
|
|
27
|
+
description: "The search query.",
|
|
28
|
+
},
|
|
29
|
+
allowed_domains: {
|
|
30
|
+
type: "array",
|
|
31
|
+
items: { type: "string", minLength: 1, maxLength: 253 },
|
|
32
|
+
maxItems: 50,
|
|
33
|
+
description: "Only return results from these domains (hostnames such as example.com; subdomains " +
|
|
34
|
+
"are included). Do not combine with blocked_domains.",
|
|
35
|
+
},
|
|
36
|
+
blocked_domains: {
|
|
37
|
+
type: "array",
|
|
38
|
+
items: { type: "string", minLength: 1, maxLength: 253 },
|
|
39
|
+
maxItems: 50,
|
|
40
|
+
description: "Never return results from these domains (hostnames such as example.com; subdomains " +
|
|
41
|
+
"are included). Do not combine with allowed_domains.",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
required: ["query"],
|
|
45
|
+
additionalProperties: false,
|
|
46
|
+
},
|
|
47
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
48
|
+
};
|
|
49
|
+
/** The last line of a result with entries (Claude Code tells the model to list its sources). */
|
|
50
|
+
const CITE_LINE = "Cite the sources you use as markdown links in your answer.";
|
|
51
|
+
/** Why the tool is unavailable in an org (web tools spec §3.4; English, actionable). */
|
|
52
|
+
function unavailableText(reason) {
|
|
53
|
+
if (reason === "none") {
|
|
54
|
+
return "No web search provider is enabled in this organization; ask an org admin to enable one.";
|
|
55
|
+
}
|
|
56
|
+
return "Several web search providers are enabled and none is the default; ask an org admin to choose one in the organization settings.";
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A domain entry as a bare lowercase ASCII hostname: tolerates a scheme, a path, a port, a leading
|
|
60
|
+
* `*.` / `.` and a trailing dot; a Unicode (IDN) name becomes its punycode form, as result hosts
|
|
61
|
+
* are (WHATWG URL parsing). Empty when nothing is left.
|
|
62
|
+
*/
|
|
63
|
+
function normalizeDomain(entry) {
|
|
64
|
+
let d = entry.trim().toLowerCase();
|
|
65
|
+
d = d.replace(/^[a-z][a-z0-9+.-]*:\/\//, "");
|
|
66
|
+
d = d.replace(/[/?#].*$/, "").replace(/:\d+$/, "");
|
|
67
|
+
d = d.replace(/^\*\./, "").replace(/^\.+/, "").replace(/\.+$/, "");
|
|
68
|
+
if (d === "")
|
|
69
|
+
return d;
|
|
70
|
+
// domainToASCII is "" for a name IDNA rejects: keep the entry as given (it matches no host)
|
|
71
|
+
return domainToASCII(d) || d;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A domain list normalized; undefined when absent or empty (no filter). A list whose entries all
|
|
75
|
+
* normalize to nothing stays an empty list, which no host matches.
|
|
76
|
+
*/
|
|
77
|
+
const normalizeDomains = (list) => list === undefined || list.length === 0
|
|
78
|
+
? undefined
|
|
79
|
+
: [...new Set(list.map(normalizeDomain).filter((d) => d !== ""))];
|
|
80
|
+
/** Whether `host` is `domain` or one of its subdomains. */
|
|
81
|
+
const covers = (domain, host) => host === domain || host.endsWith(`.${domain}`);
|
|
82
|
+
const oneLine = (s) => s.replace(/\s+/g, " ").trim();
|
|
83
|
+
/**
|
|
84
|
+
* The provider's results the model may see (web tools spec §7.2): an absolute http(s) URL, a
|
|
85
|
+
* non-empty title, each URL once, within the domain lists, at most `max`. The kernel filters even
|
|
86
|
+
* when the provider honored the domain hints.
|
|
87
|
+
*/
|
|
88
|
+
function usable(results, allowed, blocked, max) {
|
|
89
|
+
const seen = new Set();
|
|
90
|
+
const out = [];
|
|
91
|
+
for (const r of results) {
|
|
92
|
+
if (out.length >= max)
|
|
93
|
+
break;
|
|
94
|
+
if (typeof r?.url !== "string" || typeof r.title !== "string")
|
|
95
|
+
continue;
|
|
96
|
+
const title = oneLine(r.title);
|
|
97
|
+
if (title === "")
|
|
98
|
+
continue;
|
|
99
|
+
let u;
|
|
100
|
+
try {
|
|
101
|
+
// no base: a relative URL throws
|
|
102
|
+
u = new URL(r.url.trim());
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (u.protocol !== "https:" && u.protocol !== "http:")
|
|
108
|
+
continue;
|
|
109
|
+
const host = u.hostname.toLowerCase().replace(/\.$/, "");
|
|
110
|
+
if (host === "")
|
|
111
|
+
continue;
|
|
112
|
+
if (allowed !== undefined && !allowed.some((d) => covers(d, host)))
|
|
113
|
+
continue;
|
|
114
|
+
if (blocked?.some((d) => covers(d, host)))
|
|
115
|
+
continue;
|
|
116
|
+
if (seen.has(u.href))
|
|
117
|
+
continue;
|
|
118
|
+
seen.add(u.href);
|
|
119
|
+
const date = typeof r.publishedAt === "string" ? /^\d{4}-\d{2}-\d{2}/.exec(r.publishedAt.trim()) : null;
|
|
120
|
+
const snippet = typeof r.snippet === "string" ? oneLine(r.snippet) : "";
|
|
121
|
+
out.push({
|
|
122
|
+
title,
|
|
123
|
+
url: u.href,
|
|
124
|
+
...(date !== null && { date: date[0] }),
|
|
125
|
+
...(snippet !== "" && { snippet }),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return out;
|
|
129
|
+
}
|
|
130
|
+
/** The model-visible result (web tools spec §3.1): the date line first, then the entries. */
|
|
131
|
+
function resultText(day, entries) {
|
|
132
|
+
const head = `Search date: ${day} (UTC).`;
|
|
133
|
+
if (entries.length === 0)
|
|
134
|
+
return `${head}\n\nNo results.`;
|
|
135
|
+
const blocks = entries.map((e, i) => [
|
|
136
|
+
`${i + 1}. ${e.title}`,
|
|
137
|
+
` URL: ${e.url}`,
|
|
138
|
+
...(e.date !== undefined ? [` Published: ${e.date}`] : []),
|
|
139
|
+
...(e.snippet !== undefined ? [` ${e.snippet}`] : []),
|
|
140
|
+
].join("\n"));
|
|
141
|
+
return [head, ...blocks, CITE_LINE].join("\n\n");
|
|
142
|
+
}
|
|
143
|
+
/** The query in the display summary: one line, at most this many code points. */
|
|
144
|
+
const DISPLAY_QUERY_MAX = 120;
|
|
145
|
+
function displayQuery(query) {
|
|
146
|
+
const cps = [...oneLine(query)];
|
|
147
|
+
return cps.length > DISPLAY_QUERY_MAX
|
|
148
|
+
? `${cps.slice(0, DISPLAY_QUERY_MAX - 1).join("")}…`
|
|
149
|
+
: cps.join("");
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* The builtin `WebSearch` (web tools spec §3.1): searches with the org's `web-search@1` provider
|
|
153
|
+
* (`ExtensionPointDefaults`, resolved per call and per step, never cached), asking it for
|
|
154
|
+
* `web.search.maxResults` results with the domain lists as hints and the org's config, then
|
|
155
|
+
* filters the results again. Default `ask`; unavailable when the org has no provider or several
|
|
156
|
+
* without a default.
|
|
157
|
+
*/
|
|
158
|
+
export function webSearchTool(deps) {
|
|
159
|
+
const now = deps.now ?? (() => new Date());
|
|
160
|
+
return {
|
|
161
|
+
spec: WEB_SEARCH_SPEC,
|
|
162
|
+
defaultPolicy: "ask",
|
|
163
|
+
async unavailable({ orgId }) {
|
|
164
|
+
const r = await deps.points.resolve(orgId, POINT);
|
|
165
|
+
return r.ok ? null : unavailableText(r.reason);
|
|
166
|
+
},
|
|
167
|
+
async run(input, ctx) {
|
|
168
|
+
const { query, allowed_domains, blocked_domains } = input;
|
|
169
|
+
if (allowed_domains !== undefined && blocked_domains !== undefined) {
|
|
170
|
+
throw new ToolError("Pass either allowed_domains or blocked_domains, not both; call WebSearch again with one of them.");
|
|
171
|
+
}
|
|
172
|
+
const allowed = normalizeDomains(allowed_domains);
|
|
173
|
+
const blocked = normalizeDomains(blocked_domains);
|
|
174
|
+
// the provider may have changed since the step resolved the tool: resolve again
|
|
175
|
+
const resolved = await deps.points.resolve(ctx.orgId, POINT);
|
|
176
|
+
if (!resolved.ok)
|
|
177
|
+
throw new ToolError(unavailableText(resolved.reason));
|
|
178
|
+
const max = deps.config.get().web.search.maxResults;
|
|
179
|
+
const day = now().toISOString().slice(0, 10);
|
|
180
|
+
let results;
|
|
181
|
+
try {
|
|
182
|
+
const out = await resolved.impl.search({
|
|
183
|
+
query,
|
|
184
|
+
...(allowed !== undefined && allowed.length > 0 && { allowedDomains: allowed }),
|
|
185
|
+
...(blocked !== undefined && blocked.length > 0 && { blockedDomains: blocked }),
|
|
186
|
+
maxResults: max,
|
|
187
|
+
orgConfig: resolved.orgConfig,
|
|
188
|
+
config: resolved.config,
|
|
189
|
+
signal: ctx.signal,
|
|
190
|
+
});
|
|
191
|
+
results = Array.isArray(out?.results) ? out.results : [];
|
|
192
|
+
}
|
|
193
|
+
catch (e) {
|
|
194
|
+
webToolError(e, "search");
|
|
195
|
+
}
|
|
196
|
+
const entries = usable(results, allowed, blocked, max);
|
|
197
|
+
const q = displayQuery(query);
|
|
198
|
+
const n = entries.length;
|
|
199
|
+
return {
|
|
200
|
+
content: [{ type: "text", text: resultText(day, entries) }],
|
|
201
|
+
display: {
|
|
202
|
+
summary: {
|
|
203
|
+
zh: `搜索网页:${q}(${n} 条结果)`,
|
|
204
|
+
en: `Searched the web: ${q} (${n} result${n === 1 ? "" : "s"})`,
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** The longest URL `WebFetch` accepts, in characters (Claude Code's limit; web tools spec §7.1). */
|
|
2
|
+
export declare const MAX_FETCH_URL_CHARS = 2000;
|
|
3
|
+
/** The outcome of {@link normalizeFetchUrl}: the URL to fetch, or a model-visible error. */
|
|
4
|
+
export type FetchUrlCheck = {
|
|
5
|
+
ok: true;
|
|
6
|
+
url: string;
|
|
7
|
+
} | {
|
|
8
|
+
ok: false;
|
|
9
|
+
error: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A `WebFetch` URL checked and normalized (web tools spec §7.1): absolute http(s), `http:`
|
|
13
|
+
* upgraded to `https:`, no user name or password, at most {@link MAX_FETCH_URL_CHARS} characters
|
|
14
|
+
* (before and after normalization), and a host that can name a public internet host. Pure, no DNS: a public name that resolves to a
|
|
15
|
+
* private address is the provider's to refuse. Errors are English and tell the model what to pass.
|
|
16
|
+
*/
|
|
17
|
+
export declare function normalizeFetchUrl(raw: string): FetchUrlCheck;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { isPublicHostname } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
/** The longest URL `WebFetch` accepts, in characters (Claude Code's limit; web tools spec §7.1). */
|
|
3
|
+
export const MAX_FETCH_URL_CHARS = 2000;
|
|
4
|
+
const fail = (error) => ({ ok: false, error });
|
|
5
|
+
/**
|
|
6
|
+
* A `WebFetch` URL checked and normalized (web tools spec §7.1): absolute http(s), `http:`
|
|
7
|
+
* upgraded to `https:`, no user name or password, at most {@link MAX_FETCH_URL_CHARS} characters
|
|
8
|
+
* (before and after normalization), and a host that can name a public internet host. Pure, no DNS: a public name that resolves to a
|
|
9
|
+
* private address is the provider's to refuse. Errors are English and tell the model what to pass.
|
|
10
|
+
*/
|
|
11
|
+
export function normalizeFetchUrl(raw) {
|
|
12
|
+
const input = raw.trim();
|
|
13
|
+
// a cheap guard before parsing; the normalized URL is checked again below
|
|
14
|
+
if (input.length > MAX_FETCH_URL_CHARS) {
|
|
15
|
+
return fail(`Pass a URL of at most ${MAX_FETCH_URL_CHARS} characters.`);
|
|
16
|
+
}
|
|
17
|
+
let u;
|
|
18
|
+
try {
|
|
19
|
+
// no base: a relative URL throws
|
|
20
|
+
u = new URL(input);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return fail("Pass a full absolute URL, such as https://example.com/page.");
|
|
24
|
+
}
|
|
25
|
+
if (u.protocol !== "https:" && u.protocol !== "http:") {
|
|
26
|
+
return fail("Pass an https URL; only http and https URLs can be fetched.");
|
|
27
|
+
}
|
|
28
|
+
if (u.username !== "" || u.password !== "") {
|
|
29
|
+
return fail("Pass the URL without a user name or password.");
|
|
30
|
+
}
|
|
31
|
+
u.protocol = "https:";
|
|
32
|
+
// `u.hostname` is WHATWG-normalized (lowercased, IDNA, numeric IPv4 forms such as `0x7f.0.0.1`
|
|
33
|
+
// rewritten to dotted decimal, IPv6 in brackets), which is what isPublicHostname expects: never
|
|
34
|
+
// pass it a hand-parsed host.
|
|
35
|
+
if (!isPublicHostname(u.hostname)) {
|
|
36
|
+
return fail("Pass a full public https URL; this host is private or local.");
|
|
37
|
+
}
|
|
38
|
+
// the limit is on the URL as fetched: the upgrade, IDNA and percent-encoding can lengthen it
|
|
39
|
+
if (u.href.length > MAX_FETCH_URL_CHARS) {
|
|
40
|
+
return fail(`Pass a URL of at most ${MAX_FETCH_URL_CHARS} characters.`);
|
|
41
|
+
}
|
|
42
|
+
return { ok: true, url: u.href };
|
|
43
|
+
}
|
|
@@ -174,6 +174,16 @@ export declare class ConnectorsController {
|
|
|
174
174
|
list(org: OrgContext): Promise<{
|
|
175
175
|
connectors: ConnectorSummary[];
|
|
176
176
|
}>;
|
|
177
|
+
/**
|
|
178
|
+
* The connector kinds the org can create connectors of, each with the plugin providing it (the
|
|
179
|
+
* install wizard offers only these; an empty list means no connector extension is enabled).
|
|
180
|
+
*/
|
|
181
|
+
kinds(org: OrgContext): Promise<{
|
|
182
|
+
kinds: {
|
|
183
|
+
kind: string;
|
|
184
|
+
plugin: string;
|
|
185
|
+
}[];
|
|
186
|
+
}>;
|
|
177
187
|
create(principal: Principal, org: OrgContext, body: z.infer<typeof CreateBody>): Promise<{
|
|
178
188
|
connector: ConnectorDetail;
|
|
179
189
|
issues: ToolIssue[];
|
|
@@ -99,6 +99,13 @@ let ConnectorsController = class ConnectorsController {
|
|
|
99
99
|
async list(org) {
|
|
100
100
|
return { connectors: (await this.connectors.list(org.orgId)).map((a) => forViewer(org, a)) };
|
|
101
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* The connector kinds the org can create connectors of, each with the plugin providing it (the
|
|
104
|
+
* install wizard offers only these; an empty list means no connector extension is enabled).
|
|
105
|
+
*/
|
|
106
|
+
async kinds(org) {
|
|
107
|
+
return { kinds: await this.connectors.kinds(org.orgId) };
|
|
108
|
+
}
|
|
102
109
|
async create(principal, org, body) {
|
|
103
110
|
const p = requireUser(principal);
|
|
104
111
|
return this.connectors.create(org.orgId, p.account.id, body, patTokenId(p));
|
|
@@ -156,6 +163,11 @@ __decorate([
|
|
|
156
163
|
OrgAction("connectors.use"),
|
|
157
164
|
__param(0, CurrentOrg())
|
|
158
165
|
], ConnectorsController.prototype, "list", null);
|
|
166
|
+
__decorate([
|
|
167
|
+
Get("kinds"),
|
|
168
|
+
OrgAction("connectors.manage"),
|
|
169
|
+
__param(0, CurrentOrg())
|
|
170
|
+
], ConnectorsController.prototype, "kinds", null);
|
|
159
171
|
__decorate([
|
|
160
172
|
Post(),
|
|
161
173
|
OrgAction("connectors.manage"),
|
|
@@ -15,6 +15,8 @@ type ToolSource = "connector" | "resources";
|
|
|
15
15
|
export interface ConnectorToolView {
|
|
16
16
|
name: string;
|
|
17
17
|
key: string;
|
|
18
|
+
/** The reviewed definition's display-only title (`ToolSpec.title`), or null. */
|
|
19
|
+
title: string | null;
|
|
18
20
|
description: string;
|
|
19
21
|
inputSchema: Record<string, unknown>;
|
|
20
22
|
annotations: ToolAnnotations | null;
|
|
@@ -59,6 +61,11 @@ export interface ConnectorSummary {
|
|
|
59
61
|
endpoint: unknown;
|
|
60
62
|
auth: ConnectorAuth;
|
|
61
63
|
status: "active" | "disabled";
|
|
64
|
+
/**
|
|
65
|
+
* The platform connector template it was made from (`connectors.platform_template_id`), null for
|
|
66
|
+
* a custom one: the web offers it for a pending connector of that template (ruling P4-7).
|
|
67
|
+
*/
|
|
68
|
+
platformTemplateId: string | null;
|
|
62
69
|
createdBy: string;
|
|
63
70
|
createdAt: Date;
|
|
64
71
|
updatedAt: Date;
|
|
@@ -79,7 +86,7 @@ export interface CreateConnectorInput {
|
|
|
79
86
|
auth: ConnectorAuth;
|
|
80
87
|
credential?: unknown;
|
|
81
88
|
/**
|
|
82
|
-
* Install from
|
|
89
|
+
* Install from a platform catalog connector template (T26, filled in by the catalog service,
|
|
83
90
|
* not accepted over HTTP): the connector records its source item and version, the item policy is
|
|
84
91
|
* re-checked in the transaction (a template inside an app passes the app item); once the tool
|
|
85
92
|
* snapshot exists, `defaultToolPolicies` set the default policies (`policy_source 'template'`).
|
|
@@ -87,6 +94,17 @@ export interface CreateConnectorInput {
|
|
|
87
94
|
* (`catalog.custom_disabled`).
|
|
88
95
|
*/
|
|
89
96
|
template?: ConnectorTemplateRef | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* The name and slug are chosen under the org lock (one more connector from a template, ruling
|
|
99
|
+
* P4-T6-10; not accepted over HTTP; `slug` must be absent): the first free of `name` (else
|
|
100
|
+
* `display`) with its derived slug, then `<display> 2` with `_2`, `3` with `_3`, … (a given
|
|
101
|
+
* `name` is kept, only its slug suffixed), among the org's live connectors and the installed
|
|
102
|
+
* plugins' names. Chosen after the outbound calls, so a race never repeats them.
|
|
103
|
+
*/
|
|
104
|
+
slugDefault?: {
|
|
105
|
+
display: string;
|
|
106
|
+
name?: string | undefined;
|
|
107
|
+
} | undefined;
|
|
90
108
|
}
|
|
91
109
|
/** 连接器来自哪个目录条目的哪个模板。 */
|
|
92
110
|
export interface ConnectorTemplateRef {
|
|
@@ -97,10 +115,16 @@ export interface ConnectorTemplateRef {
|
|
|
97
115
|
defaultToolPolicies?: Record<string, ToolPolicy> | undefined;
|
|
98
116
|
/** The item whose policy approves this install (a dependency's template: the installed plugin). */
|
|
99
117
|
approvedBy?: string | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* One more connector from a platform connector template (ruling P4-T6-8): the template must be
|
|
120
|
+
* on in the org, re-checked under the org lock (`component.off` / `component.not_found`).
|
|
121
|
+
*/
|
|
122
|
+
mustBeOn?: boolean | undefined;
|
|
100
123
|
}
|
|
101
124
|
/**
|
|
102
|
-
* A connector updated to another version of its catalog template (
|
|
103
|
-
*
|
|
125
|
+
* A connector updated to another version of its catalog template (the platform plugin update fans
|
|
126
|
+
* a changed template out to every connector with its `platform_template_id`, ruling E2): only
|
|
127
|
+
* template-owned fields change (endpoint preset, auth preset, default tool
|
|
104
128
|
* policies still at the template default); the name, slug, status, tools and credentials stay,
|
|
105
129
|
* unless `resetCredentials`.
|
|
106
130
|
*/
|
|
@@ -199,6 +223,11 @@ export declare class ConnectorsService {
|
|
|
199
223
|
*/
|
|
200
224
|
private parseEndpoint;
|
|
201
225
|
private slugTaken;
|
|
226
|
+
/**
|
|
227
|
+
* The first free default name and slug ({@link CreateConnectorInput.slugDefault}), read in the
|
|
228
|
+
* caller's transaction under the org lock.
|
|
229
|
+
*/
|
|
230
|
+
private freeName;
|
|
202
231
|
private resolveSlug;
|
|
203
232
|
/**
|
|
204
233
|
* OAuth 连接器安装前的准备(A16):授权码流按 `discovery` 取端点(MCP 发现或手填)、按 `client` 动态注册或用请求里
|
|
@@ -231,7 +260,7 @@ export declare class ConnectorsService {
|
|
|
231
260
|
/** The org-locked, re-checked insert of {@link create} (the outbound checks ran before). */
|
|
232
261
|
private createIn;
|
|
233
262
|
/**
|
|
234
|
-
* Checks a template update before anything is written (
|
|
263
|
+
* Checks a template update before anything is written (the platform plugin update): the endpoint
|
|
235
264
|
* against the connector's schema, and with `resetCredentials` the new credential's shape, or for
|
|
236
265
|
* OAuth the client setup (discovery, dynamic registration or the client credentials token; an
|
|
237
266
|
* outbound failure -> 502 `connector.connect_failed`). Writes nothing.
|
|
@@ -247,6 +276,16 @@ export declare class ConnectorsService {
|
|
|
247
276
|
* Audits `connector.template_applied`. Deleted / missing -> `connector.not_found`.
|
|
248
277
|
*/
|
|
249
278
|
applyTemplateIn(orgId: string, connectorId: string, actorAccountId: string, p: PreparedTemplateUpdate, actorTokenId?: string): Promise<void>;
|
|
279
|
+
/** Refuses a loaded kind whose extension is not enabled in the org (the same notion as {@link kinds}). */
|
|
280
|
+
private assertKindAvailable;
|
|
281
|
+
/**
|
|
282
|
+
* The connector kinds the org can create connectors of (the install wizard's protocol step): a
|
|
283
|
+
* kind is listed when its `connector@1` extension is loaded and enabled in the org.
|
|
284
|
+
*/
|
|
285
|
+
kinds(orgId: string): Promise<{
|
|
286
|
+
kind: string;
|
|
287
|
+
plugin: string;
|
|
288
|
+
}[]>;
|
|
250
289
|
/**
|
|
251
290
|
* Previews a connector (Ruling A20, for the install wizard): after checking the connector, the
|
|
252
291
|
* endpoint (credential pattern check included) and the credential shape, reads the endpoint
|
|
@@ -275,7 +314,9 @@ export declare class ConnectorsService {
|
|
|
275
314
|
* 在调用方事务里软删除连接器(调用方已锁组织行并按需复核角色;应用安装的回滚与卸载用):删全部凭据与授权,
|
|
276
315
|
* 审计 `connector.deleted`(`reason` 并进 detail)。已删除 / 不存在 → `connector.not_found`。
|
|
277
316
|
*/
|
|
278
|
-
removeIn(orgId: string, connectorId: string,
|
|
317
|
+
removeIn(orgId: string, connectorId: string,
|
|
318
|
+
/** null: the kernel itself (the plugin scope sync uninstalling a plugin). */
|
|
319
|
+
actorAccountId: string | null, actorTokenId?: string, reason?: string): Promise<void>;
|
|
279
320
|
/**
|
|
280
321
|
* 重新 listTools 并按漂移检测的规则比对写入(见 drift.ts):新增 / 定义变化的工具待复核(旧定义保留供对比),
|
|
281
322
|
* 消失的工具停用;连接器从未拍过快照时首个快照直接启用。
|
|
@@ -12,7 +12,8 @@ import { connectorToolKey, ToolError, } from "@capybara-hq/plugin-sdk";
|
|
|
12
12
|
import { Inject, Injectable } from "@nestjs/common";
|
|
13
13
|
import { sql } from "kysely";
|
|
14
14
|
import { z } from "zod";
|
|
15
|
-
import {
|
|
15
|
+
import { connectorTemplateState } from "../catalog/component-state.js";
|
|
16
|
+
import { assertItemInstallable } from "../catalog/request-rules.js";
|
|
16
17
|
import { ApiError } from "../errors.js";
|
|
17
18
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
18
19
|
import { audit } from "../identity/audit.js";
|
|
@@ -142,6 +143,34 @@ let ConnectorsService = class ConnectorsService {
|
|
|
142
143
|
.executeTakeFirst();
|
|
143
144
|
return row !== undefined;
|
|
144
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* The first free default name and slug ({@link CreateConnectorInput.slugDefault}), read in the
|
|
148
|
+
* caller's transaction under the org lock.
|
|
149
|
+
*/
|
|
150
|
+
async freeName(t, orgId, d) {
|
|
151
|
+
const base = deriveSlug(d.name ?? d.display) ?? deriveSlug(d.display);
|
|
152
|
+
if (base === null) {
|
|
153
|
+
throw fail("slug", `Cannot derive a slug from the name; provide one. ${SLUG_RULE}`);
|
|
154
|
+
}
|
|
155
|
+
const taken = new Set((await t
|
|
156
|
+
.selectFrom("connectors")
|
|
157
|
+
.select("slug")
|
|
158
|
+
.where("org_id", "=", orgId)
|
|
159
|
+
.where("deleted_at", "is", null)
|
|
160
|
+
.execute()).map((r) => r.slug));
|
|
161
|
+
for (const m of this.extensions.manifests())
|
|
162
|
+
taken.add(m.name);
|
|
163
|
+
for (let n = 1;; n++) {
|
|
164
|
+
const suffix = n === 1 ? "" : `_${n}`;
|
|
165
|
+
const slug = `${base.slice(0, 24 - suffix.length).replace(/_+$/, "")}${suffix}`;
|
|
166
|
+
if (!isValidSlug(slug) || taken.has(slug))
|
|
167
|
+
continue;
|
|
168
|
+
const nth = ` ${n}`;
|
|
169
|
+
const name = d.name ??
|
|
170
|
+
(n === 1 ? d.display : `${[...d.display].slice(0, 80 - nth.length).join("")}${nth}`);
|
|
171
|
+
return { name: [...name].slice(0, 80).join(""), slug };
|
|
172
|
+
}
|
|
173
|
+
}
|
|
145
174
|
resolveSlug(input) {
|
|
146
175
|
if (input.slug !== undefined) {
|
|
147
176
|
if (!isValidSlug(input.slug))
|
|
@@ -253,7 +282,8 @@ let ConnectorsService = class ConnectorsService {
|
|
|
253
282
|
checkCreateInput(actorAccountId, input) {
|
|
254
283
|
const slug = this.resolveSlug(input);
|
|
255
284
|
const endpoint = this.parseEndpoint(input.connector, input.endpoint);
|
|
256
|
-
|
|
285
|
+
// a defaulted slug skips plugin names itself (`freeName`)
|
|
286
|
+
if (!input.slugDefault && this.extensions.manifests().some((m) => m.name === slug)) {
|
|
257
287
|
throw fail("slug", `Slug "${slug}" is the name of an installed plugin; choose another`);
|
|
258
288
|
}
|
|
259
289
|
const auth = input.auth;
|
|
@@ -311,21 +341,21 @@ let ConnectorsService = class ConnectorsService {
|
|
|
311
341
|
// 自建被禁止时先拒绝(事务里再复核一次):不该为此触发外连
|
|
312
342
|
if (!input.template)
|
|
313
343
|
await assertCustomAllowed(this.db, "customConnectors");
|
|
344
|
+
await this.assertKindAvailable(orgId, input.connector);
|
|
314
345
|
const { slug, endpoint, owner, secret } = this.checkCreateInput(actorAccountId, input);
|
|
315
346
|
const id = randomUUID();
|
|
316
347
|
const auth = input.auth;
|
|
317
348
|
const publicUrl = this.config.get().http.publicUrl;
|
|
318
|
-
// 先做不需要连接的检查:冲突的 slug 不该触发一次外连
|
|
319
|
-
if (await this.slugTaken(this.db, orgId, slug)) {
|
|
349
|
+
// 先做不需要连接的检查:冲突的 slug 不该触发一次外连 (a defaulted slug is chosen under the lock)
|
|
350
|
+
if (!input.slugDefault && (await this.slugTaken(this.db, orgId, slug))) {
|
|
320
351
|
throw new ApiError("connector.slug_taken", "Connector slug is already taken");
|
|
321
352
|
}
|
|
322
353
|
const oauth = isOAuth(auth)
|
|
323
354
|
? await this.prepareOAuth(auth, endpoint, input.credential, publicUrl)
|
|
324
355
|
: undefined;
|
|
325
|
-
let
|
|
326
|
-
let issues = [];
|
|
356
|
+
let listed;
|
|
327
357
|
if (auth.type !== "oauth_code") {
|
|
328
|
-
|
|
358
|
+
listed = await this.drift.listTools(input.connector, endpoint, async () => {
|
|
329
359
|
if (auth.type === "none")
|
|
330
360
|
return { headers: {} };
|
|
331
361
|
if (oauth?.tokens) {
|
|
@@ -335,7 +365,6 @@ let ConnectorsService = class ConnectorsService {
|
|
|
335
365
|
throw new CredentialMissing(id, auth.ownership);
|
|
336
366
|
return this.credentials.injectionFor(id, auth, secret);
|
|
337
367
|
}, { orgId, slug });
|
|
338
|
-
({ rows, issues } = snapshot(slug, listed.specs, listed.resources));
|
|
339
368
|
}
|
|
340
369
|
return this.createIn(orgId, actorAccountId, input, actorTokenId, {
|
|
341
370
|
id,
|
|
@@ -344,13 +373,12 @@ let ConnectorsService = class ConnectorsService {
|
|
|
344
373
|
owner,
|
|
345
374
|
secret,
|
|
346
375
|
oauth,
|
|
347
|
-
|
|
348
|
-
issues,
|
|
376
|
+
listed,
|
|
349
377
|
});
|
|
350
378
|
}
|
|
351
379
|
/** The org-locked, re-checked insert of {@link create} (the outbound checks ran before). */
|
|
352
380
|
async createIn(orgId, actorAccountId, input, actorTokenId, c) {
|
|
353
|
-
const { id,
|
|
381
|
+
const { id, endpoint, owner, secret, oauth } = c;
|
|
354
382
|
const auth = input.auth;
|
|
355
383
|
const t = this.db;
|
|
356
384
|
await this.orgLock.lockAndAuthorize(orgId, actorAccountId, "connectors.manage");
|
|
@@ -359,22 +387,53 @@ let ConnectorsService = class ConnectorsService {
|
|
|
359
387
|
}
|
|
360
388
|
else
|
|
361
389
|
await assertCustomAllowed(t, "customConnectors");
|
|
362
|
-
|
|
390
|
+
let slug = c.slug;
|
|
391
|
+
let name = input.name;
|
|
392
|
+
if (input.slugDefault)
|
|
393
|
+
({ slug, name } = await this.freeName(t, orgId, input.slugDefault));
|
|
394
|
+
else if (await this.slugTaken(t, orgId, slug)) {
|
|
363
395
|
throw new ApiError("connector.slug_taken", "Connector slug is already taken");
|
|
364
396
|
}
|
|
397
|
+
// the snapshot's keys name the final slug
|
|
398
|
+
const { rows, issues } = c.listed === undefined
|
|
399
|
+
? { rows: [], issues: [] }
|
|
400
|
+
: snapshot(slug, c.listed.specs, c.listed.resources);
|
|
401
|
+
// A connector made from a platform connector template stays linked to it (ruling E2)
|
|
402
|
+
const tpl = input.template;
|
|
403
|
+
const platformTemplate = tpl?.templateId !== undefined
|
|
404
|
+
? await t
|
|
405
|
+
.selectFrom("platform_connector_templates")
|
|
406
|
+
.select("id")
|
|
407
|
+
.where("catalog_item_id", "=", tpl.itemId)
|
|
408
|
+
.where("template_id", "=", tpl.templateId)
|
|
409
|
+
.where("deleted_at", "is", null)
|
|
410
|
+
.executeTakeFirst()
|
|
411
|
+
: undefined;
|
|
412
|
+
if (tpl?.mustBeOn) {
|
|
413
|
+
const state = platformTemplate === undefined
|
|
414
|
+
? "absent"
|
|
415
|
+
: await connectorTemplateState(t, orgId, platformTemplate.id);
|
|
416
|
+
if (state === "absent") {
|
|
417
|
+
throw new ApiError("component.not_found", "The connector template does not exist or is not available in this organization");
|
|
418
|
+
}
|
|
419
|
+
if (state === "off") {
|
|
420
|
+
throw new ApiError("component.off", "This connector template is off in this organization; switch it (or its plugin) on first");
|
|
421
|
+
}
|
|
422
|
+
}
|
|
365
423
|
await t
|
|
366
424
|
.insertInto("connectors")
|
|
367
425
|
.values({
|
|
368
426
|
id,
|
|
369
427
|
org_id: orgId,
|
|
370
428
|
slug,
|
|
371
|
-
name
|
|
429
|
+
name,
|
|
372
430
|
connector: input.connector,
|
|
373
431
|
endpoint: JSON.stringify(endpoint),
|
|
374
432
|
auth: JSON.stringify(auth),
|
|
375
433
|
created_by: actorAccountId,
|
|
376
434
|
catalog_item_id: input.template?.itemId ?? null,
|
|
377
435
|
catalog_version: input.template?.version ?? null,
|
|
436
|
+
platform_template_id: platformTemplate?.id ?? null,
|
|
378
437
|
// 授权码连接器安装时没有快照:模板的默认策略留到首个快照时应用
|
|
379
438
|
template_tool_policies: input.template?.defaultToolPolicies
|
|
380
439
|
? JSON.stringify(input.template.defaultToolPolicies)
|
|
@@ -418,7 +477,7 @@ let ConnectorsService = class ConnectorsService {
|
|
|
418
477
|
return { connector: await this.detail(t, orgId, id, actorAccountId), issues };
|
|
419
478
|
}
|
|
420
479
|
/**
|
|
421
|
-
* Checks a template update before anything is written (
|
|
480
|
+
* Checks a template update before anything is written (the platform plugin update): the endpoint
|
|
422
481
|
* against the connector's schema, and with `resetCredentials` the new credential's shape, or for
|
|
423
482
|
* OAuth the client setup (discovery, dynamic registration or the client credentials token; an
|
|
424
483
|
* outbound failure -> 502 `connector.connect_failed`). Writes nothing.
|
|
@@ -534,6 +593,21 @@ let ConnectorsService = class ConnectorsService {
|
|
|
534
593
|
},
|
|
535
594
|
});
|
|
536
595
|
}
|
|
596
|
+
/** Refuses a loaded kind whose extension is not enabled in the org (the same notion as {@link kinds}). */
|
|
597
|
+
async assertKindAvailable(orgId, kind) {
|
|
598
|
+
if (!this.registry.findConnector(kind))
|
|
599
|
+
return; // unknown kinds fail in parseEndpoint
|
|
600
|
+
if (!(await this.registry.connectorKindAvailable(orgId, kind))) {
|
|
601
|
+
throw new ApiError("connector.kind_unavailable", `Connector kind "${kind}" is not enabled for this organization; enable its plugin first`);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* The connector kinds the org can create connectors of (the install wizard's protocol step): a
|
|
606
|
+
* kind is listed when its `connector@1` extension is loaded and enabled in the org.
|
|
607
|
+
*/
|
|
608
|
+
kinds(orgId) {
|
|
609
|
+
return this.registry.connectorKindsFor(orgId);
|
|
610
|
+
}
|
|
537
611
|
/**
|
|
538
612
|
* Previews a connector (Ruling A20, for the install wizard): after checking the connector, the
|
|
539
613
|
* endpoint (credential pattern check included) and the credential shape, reads the endpoint
|
|
@@ -548,6 +622,7 @@ let ConnectorsService = class ConnectorsService {
|
|
|
548
622
|
async preview(orgId, input) {
|
|
549
623
|
// 部署禁止组织自建连接器时也不替组织去连任意端点(目录安装不走预览)
|
|
550
624
|
await assertCustomAllowed(this.db, "customConnectors");
|
|
625
|
+
await this.assertKindAvailable(orgId, input.connector);
|
|
551
626
|
const endpoint = this.parseEndpoint(input.connector, input.endpoint);
|
|
552
627
|
const connector = this.registry.findConnector(input.connector);
|
|
553
628
|
if (!connector)
|
|
@@ -684,6 +759,7 @@ let ConnectorsService = class ConnectorsService {
|
|
|
684
759
|
endpoint: endpointView(r.endpoint),
|
|
685
760
|
auth: r.auth,
|
|
686
761
|
status: r.status,
|
|
762
|
+
platformTemplateId: r.platform_template_id ?? null,
|
|
687
763
|
createdBy: r.created_by,
|
|
688
764
|
createdAt: r.created_at,
|
|
689
765
|
updatedAt: r.updated_at,
|
|
@@ -721,6 +797,7 @@ let ConnectorsService = class ConnectorsService {
|
|
|
721
797
|
return {
|
|
722
798
|
name: t.name,
|
|
723
799
|
key: connectorToolKey(r.slug, t.name),
|
|
800
|
+
title: typeof spec.title === "string" ? spec.title : null,
|
|
724
801
|
description: spec.description,
|
|
725
802
|
inputSchema: spec.inputSchema,
|
|
726
803
|
annotations: spec.annotations ?? null,
|
|
@@ -891,7 +968,9 @@ let ConnectorsService = class ConnectorsService {
|
|
|
891
968
|
* 在调用方事务里软删除连接器(调用方已锁组织行并按需复核角色;应用安装的回滚与卸载用):删全部凭据与授权,
|
|
892
969
|
* 审计 `connector.deleted`(`reason` 并进 detail)。已删除 / 不存在 → `connector.not_found`。
|
|
893
970
|
*/
|
|
894
|
-
async removeIn(orgId, connectorId,
|
|
971
|
+
async removeIn(orgId, connectorId,
|
|
972
|
+
/** null: the kernel itself (the plugin scope sync uninstalling a plugin). */
|
|
973
|
+
actorAccountId, actorTokenId, reason) {
|
|
895
974
|
const t = this.db;
|
|
896
975
|
const app = await this.row(t, orgId, connectorId, true);
|
|
897
976
|
await t
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type OrgContext } from "../orgs/org.guard.js";
|
|
2
|
+
import { type ExtensionToolsOffer, OrgExtensionTools } from "./info.js";
|
|
3
|
+
/**
|
|
4
|
+
* `GET /api/v1/orgs/:orgId/tools/extensions` (`agents.use`) → `{ extensions }`: the tools of the
|
|
5
|
+
* extensions enabled in the org, grouped by extension, for the agent form's Tools section (it adds
|
|
6
|
+
* or removes `{kind:"plugin",plugin,name}` references). Display only; nothing here is model-visible.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ExtensionToolsController {
|
|
9
|
+
private readonly tools;
|
|
10
|
+
constructor(tools: OrgExtensionTools);
|
|
11
|
+
extensions(org: OrgContext): Promise<{
|
|
12
|
+
extensions: ExtensionToolsOffer[];
|
|
13
|
+
}>;
|
|
14
|
+
}
|