@capybara-hq/kernel 0.1.0-rc.2 → 0.1.0-rc.21
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 +94 -5
- package/dist/admin/admin-agents.controller.d.ts +28 -0
- package/dist/admin/admin-agents.controller.js +79 -0
- package/dist/admin/admin-connectors.controller.d.ts +29 -0
- package/dist/admin/admin-connectors.controller.js +79 -0
- package/dist/admin/admin-items.schemas.d.ts +42 -0
- package/dist/admin/admin-items.schemas.js +48 -0
- package/dist/admin/admin.controller.d.ts +52 -80
- package/dist/admin/admin.controller.js +112 -81
- package/dist/admin/admin.module.d.ts +4 -1
- package/dist/admin/admin.module.js +50 -4
- package/dist/admin/admin.schemas.d.ts +69 -0
- package/dist/admin/admin.schemas.js +53 -0
- package/dist/admin/audit.controller.d.ts +14 -0
- package/dist/admin/audit.controller.js +42 -0
- package/dist/admin/audit.schemas.d.ts +8 -0
- package/dist/admin/audit.schemas.js +17 -0
- package/dist/admin/extensions.controller.d.ts +34 -3
- package/dist/admin/extensions.controller.js +66 -8
- package/dist/admin/extensions.schemas.d.ts +7 -0
- package/dist/admin/extensions.schemas.js +10 -0
- package/dist/admin/health.service.d.ts +104 -0
- package/dist/admin/health.service.js +246 -0
- package/dist/admin/limit-defaults.d.ts +20 -0
- package/dist/admin/limit-defaults.js +10 -0
- package/dist/admin/overview.controller.d.ts +31 -0
- package/dist/admin/overview.controller.js +78 -0
- package/dist/admin/overview.schemas.d.ts +8 -0
- package/dist/admin/overview.schemas.js +13 -0
- package/dist/admin/overview.service.d.ts +112 -0
- package/dist/admin/overview.service.js +223 -0
- package/dist/admin/platform-audit.service.d.ts +41 -0
- package/dist/admin/platform-audit.service.js +70 -0
- 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/admin/usage.service.d.ts +149 -0
- package/dist/admin/usage.service.js +321 -0
- package/dist/agents/admin-agents.d.ts +92 -0
- package/dist/agents/admin-agents.js +170 -0
- package/dist/agents/agent-lookup.d.ts +24 -0
- package/dist/agents/agent-lookup.js +46 -2
- package/dist/agents/agent-profile.service.d.ts +31 -0
- package/dist/agents/agent-profile.service.js +122 -0
- package/dist/agents/agents.controller.d.ts +53 -168
- package/dist/agents/agents.controller.js +163 -34
- package/dist/agents/agents.module.d.ts +6 -2
- package/dist/agents/agents.module.js +41 -7
- package/dist/agents/agents.schemas.d.ts +392 -0
- package/dist/agents/agents.schemas.js +126 -0
- package/dist/agents/agents.service.d.ts +121 -36
- package/dist/agents/agents.service.js +411 -121
- package/dist/agents/definition.d.ts +142 -21
- package/dist/agents/definition.js +389 -43
- package/dist/agents/from-template.d.ts +106 -0
- package/dist/agents/from-template.js +680 -0
- package/dist/agents/from-template.service.d.ts +72 -0
- package/dist/agents/from-template.service.js +178 -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 +44 -6
- package/dist/agents/models.controller.js +84 -8
- package/dist/agents/org-templates.d.ts +186 -0
- package/dist/agents/org-templates.js +876 -0
- package/dist/agents/pending-connector-requests.d.ts +79 -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 +114 -0
- package/dist/agents/profile.js +55 -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 +77 -5
- package/dist/agents/templates.controller.js +153 -7
- package/dist/agents/templates.d.ts +127 -23
- package/dist/agents/templates.js +482 -44
- package/dist/agents/templates.schemas.d.ts +20 -0
- package/dist/agents/templates.schemas.js +45 -0
- package/dist/background/background.controller.d.ts +38 -0
- package/dist/background/background.controller.js +88 -0
- package/dist/background/background.module.d.ts +10 -0
- package/dist/background/background.module.js +39 -0
- package/dist/background/background.schemas.d.ts +10 -0
- package/dist/background/background.schemas.js +16 -0
- package/dist/background/finish.d.ts +44 -0
- package/dist/background/finish.js +95 -0
- package/dist/background/launch-lock.d.ts +15 -0
- package/dist/background/launch-lock.js +40 -0
- package/dist/background/launch.d.ts +42 -0
- package/dist/background/launch.js +77 -0
- package/dist/background/poll.job.d.ts +56 -0
- package/dist/background/poll.job.js +195 -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 +80 -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 +244 -0
- package/dist/background/store.d.ts +167 -0
- package/dist/background/store.js +361 -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 +109 -0
- package/dist/background/tasks.service.js +271 -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 +136 -52
- package/dist/catalog/admin-catalog.controller.js +275 -65
- package/dist/catalog/admin-catalog.schemas.d.ts +82 -0
- package/dist/catalog/admin-catalog.schemas.js +99 -0
- package/dist/catalog/appearance.schemas.d.ts +10 -0
- package/dist/catalog/appearance.schemas.js +20 -0
- package/dist/catalog/appearance.service.d.ts +105 -0
- package/dist/catalog/appearance.service.js +306 -0
- package/dist/catalog/catalog-content.d.ts +122 -35
- package/dist/catalog/catalog-content.js +122 -14
- package/dist/catalog/catalog-files.d.ts +42 -0
- package/dist/catalog/catalog-files.js +89 -0
- package/dist/catalog/catalog-import.module.d.ts +7 -0
- package/dist/catalog/catalog-import.module.js +63 -0
- package/dist/catalog/catalog-items.d.ts +122 -7
- package/dist/catalog/catalog-items.js +301 -13
- package/dist/catalog/catalog-scope.service.d.ts +293 -0
- package/dist/catalog/catalog-scope.service.js +1236 -0
- package/dist/catalog/catalog.module.d.ts +7 -9
- package/dist/catalog/catalog.module.js +47 -31
- package/dist/catalog/catalog.service.d.ts +122 -31
- package/dist/catalog/catalog.service.js +177 -105
- package/dist/catalog/claude/agents.js +15 -10
- package/dist/catalog/claude/translate.js +3 -0
- package/dist/catalog/cli.d.ts +11 -1
- package/dist/catalog/cli.js +29 -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 +102 -0
- package/dist/catalog/component-scope.controller.js +257 -0
- package/dist/catalog/component-scope.schemas.d.ts +118 -0
- package/dist/catalog/component-scope.schemas.js +97 -0
- package/dist/catalog/component-scope.service.d.ts +394 -0
- package/dist/catalog/component-scope.service.js +1133 -0
- package/dist/catalog/component-state.d.ts +207 -0
- package/dist/catalog/component-state.js +484 -0
- package/dist/catalog/git-source.d.ts +9 -1
- package/dist/catalog/git-source.js +29 -2
- 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/marketplace-icons.d.ts +64 -0
- package/dist/catalog/marketplace-icons.js +131 -0
- package/dist/catalog/marketplaces.controller.d.ts +50 -41
- package/dist/catalog/marketplaces.controller.js +130 -46
- package/dist/catalog/marketplaces.schemas.d.ts +48 -0
- package/dist/catalog/marketplaces.schemas.js +53 -0
- package/dist/catalog/marketplaces.service.d.ts +110 -17
- package/dist/catalog/marketplaces.service.js +337 -29
- package/dist/catalog/org-catalog.controller.d.ts +114 -62
- package/dist/catalog/org-catalog.controller.js +191 -98
- package/dist/catalog/org-catalog.schemas.d.ts +104 -0
- package/dist/catalog/org-catalog.schemas.js +107 -0
- package/dist/catalog/org-catalog.service.d.ts +72 -33
- package/dist/catalog/org-catalog.service.js +367 -158
- 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 +133 -0
- package/dist/catalog/org-extension.controller.js +313 -0
- package/dist/catalog/org-extension.schemas.d.ts +15 -0
- package/dist/catalog/org-extension.schemas.js +22 -0
- package/dist/catalog/org-plugin-uploads.controller.d.ts +77 -0
- package/dist/catalog/org-plugin-uploads.controller.js +200 -0
- package/dist/catalog/org-plugin-uploads.d.ts +71 -0
- package/dist/catalog/org-plugin-uploads.js +122 -0
- package/dist/catalog/org-plugin-uploads.schemas.d.ts +20 -0
- package/dist/catalog/org-plugin-uploads.schemas.js +32 -0
- package/dist/catalog/owned-items.d.ts +188 -0
- package/dist/catalog/owned-items.js +808 -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 +243 -0
- package/dist/catalog/platform-components.js +872 -0
- package/dist/catalog/platform-migration.d.ts +115 -0
- package/dist/catalog/platform-migration.js +583 -0
- package/dist/catalog/plugin-import.d.ts +254 -47
- package/dist/catalog/plugin-import.js +810 -112
- package/dist/catalog/plugin-install.d.ts +205 -42
- package/dist/catalog/plugin-install.js +828 -126
- package/dist/catalog/plugin-package.d.ts +43 -4
- package/dist/catalog/plugin-package.js +194 -7
- package/dist/catalog/plugin-upgrade.d.ts +308 -225
- package/dist/catalog/plugin-upgrade.js +1325 -1131
- package/dist/catalog/request-rules.d.ts +65 -0
- package/dist/catalog/request-rules.js +217 -0
- package/dist/catalog/requests.service.d.ts +194 -118
- package/dist/catalog/requests.service.js +530 -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 +119 -0
- package/dist/channels/actions.js +10 -3
- package/dist/channels/cards.d.ts +36 -10
- package/dist/channels/cards.js +100 -25
- package/dist/channels/channels.module.js +13 -2
- package/dist/channels/channels.schemas.d.ts +41 -0
- package/dist/channels/channels.schemas.js +40 -0
- package/dist/channels/connections.controller.d.ts +46 -37
- package/dist/channels/connections.controller.js +76 -34
- package/dist/channels/connections.service.d.ts +102 -10
- package/dist/channels/connections.service.js +271 -24
- package/dist/channels/inbound.d.ts +11 -1
- package/dist/channels/inbound.js +87 -7
- package/dist/channels/outbound.d.ts +14 -1
- package/dist/channels/outbound.js +64 -15
- package/dist/channels/phrases.d.ts +33 -2
- package/dist/channels/phrases.js +29 -1
- package/dist/channels/supervisor.d.ts +2 -0
- package/dist/channels/supervisor.js +4 -0
- package/dist/channels/threads.d.ts +5 -0
- package/dist/channels/threads.js +8 -0
- package/dist/channels/webhook.d.ts +21 -1
- package/dist/channels/webhook.js +39 -4
- package/dist/client/client-access.service.d.ts +102 -0
- package/dist/client/client-access.service.js +303 -0
- package/dist/client/client-builds.service.d.ts +109 -0
- package/dist/client/client-builds.service.js +229 -0
- package/dist/client/client-delivery.controller.d.ts +25 -0
- package/dist/client/client-delivery.controller.js +66 -0
- package/dist/client/client-files.d.ts +48 -0
- package/dist/client/client-files.js +136 -0
- package/dist/client/client-reports.cron.d.ts +13 -0
- package/dist/client/client-reports.cron.js +42 -0
- package/dist/client/client-reports.service.d.ts +30 -0
- package/dist/client/client-reports.service.js +102 -0
- package/dist/client/client-sign-in.service.d.ts +21 -0
- package/dist/client/client-sign-in.service.js +49 -0
- package/dist/client/client.controller.d.ts +49 -0
- package/dist/client/client.controller.js +129 -0
- package/dist/client/client.module.d.ts +8 -0
- package/dist/client/client.module.js +28 -0
- package/dist/client/client.schemas.d.ts +61 -0
- package/dist/client/client.schemas.js +27 -0
- package/dist/config/docs.js +5 -1
- package/dist/config/schema.d.ts +35 -2
- package/dist/config/schema.js +216 -21
- 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/artifacts.d.ts +1 -1
- package/dist/conversations/artifacts.js +1 -1
- 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 -44
- package/dist/conversations/conversations.controller.js +133 -82
- package/dist/conversations/conversations.module.d.ts +1 -1
- package/dist/conversations/conversations.module.js +10 -7
- package/dist/conversations/conversations.schemas.d.ts +52 -0
- package/dist/conversations/conversations.schemas.js +79 -0
- package/dist/conversations/conversations.service.d.ts +161 -13
- package/dist/conversations/conversations.service.js +329 -57
- package/dist/conversations/device-status.d.ts +24 -0
- package/dist/conversations/device-status.js +71 -0
- package/dist/conversations/event-log.d.ts +45 -9
- package/dist/conversations/event-log.js +113 -6
- package/dist/conversations/events.d.ts +255 -9
- package/dist/conversations/events.js +250 -34
- package/dist/conversations/message-context.d.ts +79 -0
- package/dist/conversations/message-context.js +145 -0
- package/dist/conversations/queue.d.ts +5 -2
- package/dist/conversations/queue.js +24 -4
- package/dist/conversations/queue.service.d.ts +2 -2
- package/dist/conversations/queue.service.js +21 -3
- package/dist/conversations/titles.d.ts +12 -3
- package/dist/conversations/titles.js +40 -16
- package/dist/conversations/tree.d.ts +17 -0
- package/dist/conversations/tree.js +42 -0
- package/dist/ctx/create-ctx.d.ts +48 -5
- package/dist/ctx/create-ctx.js +174 -34
- package/dist/db/kernel-schema.d.ts +668 -27
- package/dist/db/pool.d.ts +5 -0
- package/dist/db/pool.js +3 -0
- package/dist/devices/access.d.ts +66 -0
- package/dist/devices/access.js +113 -0
- package/dist/devices/conversation-devices.d.ts +75 -0
- package/dist/devices/conversation-devices.js +230 -0
- package/dist/devices/devices.controller.d.ts +36 -0
- package/dist/devices/devices.controller.js +124 -0
- package/dist/devices/devices.module.d.ts +8 -0
- package/dist/devices/devices.module.js +34 -0
- package/dist/devices/devices.schemas.d.ts +3 -0
- package/dist/devices/devices.schemas.js +14 -0
- package/dist/devices/devices.service.d.ts +251 -0
- package/dist/devices/devices.service.js +791 -0
- package/dist/devices/dto.d.ts +25 -0
- package/dist/devices/dto.js +12 -0
- package/dist/devices/label.d.ts +11 -0
- package/dist/devices/label.js +25 -0
- package/dist/devices/legacy-cleanup.job.d.ts +34 -0
- package/dist/devices/legacy-cleanup.job.js +141 -0
- package/dist/errors.d.ts +215 -3
- package/dist/errors.js +215 -3
- package/dist/evals/evals.module.js +11 -2
- package/dist/evals/evals.schemas.d.ts +110 -0
- package/dist/evals/evals.schemas.js +107 -0
- package/dist/evals/reconstruct.d.ts +18 -9
- package/dist/evals/reconstruct.js +36 -10
- package/dist/evals/recorded-tools.d.ts +37 -1
- package/dist/evals/recorded-tools.js +120 -10
- package/dist/evals/run-replay.d.ts +20 -3
- package/dist/evals/run-replay.js +78 -14
- package/dist/evals/runs.controller.d.ts +2 -57
- package/dist/evals/runs.controller.js +1 -42
- package/dist/evals/runs.service.d.ts +8 -7
- package/dist/evals/runs.service.js +45 -30
- package/dist/evals/sets.controller.d.ts +2 -28
- package/dist/evals/sets.controller.js +1 -31
- package/dist/evals/sets.service.d.ts +7 -7
- package/dist/evals/sets.service.js +23 -17
- package/dist/evals/snapshot.d.ts +3 -2
- package/dist/evals/snapshot.js +17 -4
- package/dist/evals/step-replay.d.ts +4 -6
- package/dist/evals/step-replay.js +16 -9
- package/dist/evals/trajectory.d.ts +5 -3
- package/dist/evals/trajectory.js +4 -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 +81 -14
- package/dist/extensions/admin-ops.js +181 -47
- package/dist/extensions/admin-view.d.ts +57 -10
- package/dist/extensions/admin-view.js +249 -27
- package/dist/extensions/approvals.d.ts +12 -2
- package/dist/extensions/blobs.d.ts +14 -1
- package/dist/extensions/blobs.js +49 -5
- package/dist/extensions/bootstrap.d.ts +85 -10
- package/dist/extensions/bootstrap.js +215 -36
- 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/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 +94 -9
- package/dist/extensions/deployment-config.js +255 -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 +133 -0
- package/dist/extensions/effective-config.js +379 -0
- package/dist/extensions/extensions.module.js +31 -12
- package/dist/extensions/guide-places.d.ts +68 -0
- package/dist/extensions/guide-places.js +152 -0
- package/dist/extensions/hooks.d.ts +37 -4
- package/dist/extensions/hooks.js +82 -16
- package/dist/extensions/host.d.ts +105 -12
- package/dist/extensions/host.js +372 -87
- package/dist/extensions/installs.d.ts +30 -9
- package/dist/extensions/installs.js +57 -16
- package/dist/extensions/instance.d.ts +17 -2
- package/dist/extensions/instance.js +21 -0
- package/dist/extensions/ledger.d.ts +1 -1
- package/dist/extensions/locks.d.ts +12 -0
- package/dist/extensions/locks.js +26 -0
- package/dist/extensions/org-config.d.ts +97 -7
- package/dist/extensions/org-config.js +215 -45
- 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 +18 -4
- package/dist/extensions/package.js +56 -3
- package/dist/extensions/permission-set.d.ts +35 -5
- package/dist/extensions/permission-set.js +36 -5
- package/dist/extensions/permission-view.d.ts +106 -13
- package/dist/extensions/permission-view.js +33 -15
- package/dist/extensions/plugin-guides.d.ts +282 -0
- package/dist/extensions/plugin-guides.js +554 -0
- package/dist/extensions/plugin-icons.d.ts +54 -0
- package/dist/extensions/plugin-icons.js +125 -0
- 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 +28 -0
- package/dist/extensions/point-defaults.controller.js +69 -0
- package/dist/extensions/point-defaults.d.ts +73 -0
- package/dist/extensions/point-defaults.js +236 -0
- package/dist/extensions/point-defaults.schemas.d.ts +9 -0
- package/dist/extensions/point-defaults.schemas.js +14 -0
- package/dist/extensions/registry.d.ts +1 -1
- package/dist/extensions/registry.js +2 -0
- package/dist/extensions/resolve.d.ts +51 -1
- package/dist/extensions/resolve.js +85 -3
- package/dist/extensions/single-provider.d.ts +92 -0
- package/dist/extensions/single-provider.js +180 -0
- package/dist/extensions/sources.d.ts +13 -2
- package/dist/extensions/sources.js +2 -0
- package/dist/extensions/state.module.d.ts +9 -0
- package/dist/extensions/state.module.js +46 -0
- package/dist/extensions/unavailable.d.ts +50 -0
- package/dist/extensions/unavailable.js +115 -0
- package/dist/files/previewers.controller.js +2 -3
- package/dist/files/previewers.d.ts +10 -3
- package/dist/files/previewers.js +40 -11
- package/dist/files/previewers.schemas.d.ts +10 -0
- package/dist/files/previewers.schemas.js +9 -0
- package/dist/http/api.module.js +76 -4
- package/dist/http/app.d.ts +11 -2
- package/dist/http/app.js +31 -5
- package/dist/http/gateway-routes.d.ts +7 -3
- package/dist/http/gateway-routes.js +6 -3
- package/dist/http/nest-logger.d.ts +6 -5
- package/dist/http/nest-logger.js +24 -10
- package/dist/http/plugin-dispatch.d.ts +4 -1
- package/dist/http/plugin-dispatch.js +14 -2
- package/dist/identity/accounts.d.ts +77 -31
- package/dist/identity/accounts.js +133 -52
- 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 +35 -9
- package/dist/identity/cookies.d.ts +26 -5
- package/dist/identity/cookies.js +58 -6
- package/dist/identity/identity.module.d.ts +1 -1
- package/dist/identity/identity.module.js +7 -4
- package/dist/identity/initial-passwords.controller.d.ts +22 -0
- package/dist/identity/initial-passwords.controller.js +49 -0
- package/dist/identity/initial-passwords.d.ts +61 -0
- package/dist/identity/initial-passwords.job.d.ts +16 -0
- package/dist/identity/initial-passwords.job.js +46 -0
- package/dist/identity/initial-passwords.js +159 -0
- package/dist/identity/me.controller.d.ts +17 -1
- package/dist/identity/me.controller.js +45 -4
- package/dist/identity/me.schemas.d.ts +24 -0
- package/dist/identity/me.schemas.js +25 -0
- package/dist/identity/principal.d.ts +11 -3
- package/dist/identity/principal.js +11 -3
- package/dist/identity/sessions.d.ts +12 -0
- package/dist/identity/sessions.js +45 -0
- package/dist/identity/settings.d.ts +99 -12
- package/dist/identity/settings.js +234 -25
- 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/identity/write-actor.d.ts +11 -0
- package/dist/identity/write-actor.js +7 -0
- package/dist/inbox/inbox.module.d.ts +4 -1
- package/dist/inbox/inbox.module.js +7 -3
- package/dist/inbox/inbox.schemas.d.ts +8 -0
- package/dist/inbox/inbox.schemas.js +11 -0
- package/dist/inbox/inbox.service.d.ts +64 -4
- 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 +157 -0
- package/dist/inbox/platform-inbox.service.js +281 -0
- package/dist/inbox/platform-notices.d.ts +19 -0
- package/dist/inbox/platform-notices.js +9 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +7 -1
- package/dist/infra/cli/kernel-cli.module.js +9 -1
- package/dist/infra/config/kernel-config.service.js +32 -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 +31 -3
- package/dist/infra/lifecycle/process-guards.js +4 -0
- package/dist/infra/lock/lock.service.d.ts +8 -0
- package/dist/infra/lock/lock.service.js +27 -0
- package/dist/infra/logging/logging.module.d.ts +4 -2
- package/dist/infra/logging/logging.module.js +24 -6
- package/dist/infra/presence/presence.module.d.ts +6 -0
- package/dist/infra/presence/presence.module.js +22 -0
- package/dist/infra/presence/replica-presence.d.ts +87 -0
- package/dist/infra/presence/replica-presence.js +189 -0
- 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/throttler/named-throttlers.d.ts +12 -0
- package/dist/infra/throttler/named-throttlers.js +67 -0
- package/dist/infra/throttler/throttler.guard.js +1 -1
- package/dist/infra/tokens.d.ts +6 -1
- package/dist/infra/tokens.js +6 -1
- package/dist/kernel.module.js +15 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +9 -3
- package/dist/lifecycle/kernel-lifecycle.js +51 -11
- package/dist/local-devices/device-auth.controller.d.ts +42 -0
- package/dist/local-devices/device-auth.controller.js +116 -0
- package/dist/local-devices/device-auth.d.ts +119 -0
- package/dist/local-devices/device-auth.js +401 -0
- package/dist/local-devices/device-auth.module.d.ts +7 -0
- package/dist/local-devices/device-auth.module.js +25 -0
- package/dist/local-devices/device-routes.d.ts +36 -0
- package/dist/local-devices/device-routes.js +90 -0
- package/dist/local-devices/dto.d.ts +66 -0
- package/dist/local-devices/dto.js +44 -0
- package/dist/local-devices/keys.d.ts +25 -0
- package/dist/local-devices/keys.js +25 -0
- package/dist/local-devices/local-device-gateway.d.ts +134 -0
- package/dist/local-devices/local-device-gateway.js +542 -0
- package/dist/local-devices/local-device-provider.d.ts +89 -0
- package/dist/local-devices/local-device-provider.js +151 -0
- package/dist/local-devices/local-devices.module.d.ts +16 -0
- package/dist/local-devices/local-devices.module.js +44 -0
- package/dist/local-devices/machines.d.ts +118 -0
- package/dist/local-devices/machines.js +366 -0
- package/dist/local-devices/relay.d.ts +100 -0
- package/dist/local-devices/relay.js +373 -0
- package/dist/local-devices/targets.d.ts +28 -0
- package/dist/local-devices/targets.js +73 -0
- package/dist/log.d.ts +13 -1
- package/dist/log.js +93 -17
- 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 +101 -0
- package/dist/models/enablement.js +264 -0
- package/dist/models/models.module.d.ts +5 -1
- package/dist/models/models.module.js +16 -4
- package/dist/models/org-models.schemas.d.ts +8 -0
- package/dist/models/org-models.schemas.js +22 -0
- package/dist/models/prices.d.ts +8 -6
- package/dist/models/prices.js +11 -9
- package/dist/models/purposes.controller.d.ts +6 -4
- package/dist/models/purposes.controller.js +13 -7
- package/dist/models/purposes.d.ts +72 -14
- package/dist/models/purposes.js +115 -34
- 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.controller.d.ts +2 -5
- package/dist/orgs/orgs.controller.js +3 -6
- package/dist/orgs/orgs.module.js +3 -0
- package/dist/orgs/orgs.schemas.d.ts +8 -0
- package/dist/orgs/orgs.schemas.js +16 -0
- package/dist/orgs/orgs.service.d.ts +23 -8
- package/dist/orgs/orgs.service.js +38 -16
- 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 +66 -6
- package/dist/orgs/settings.service.js +89 -10
- package/dist/overrides.d.ts +16 -1
- package/dist/overrides.js +10 -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 +28 -0
- package/dist/platform/errors.js +65 -0
- package/dist/platform/exclusions.d.ts +11 -0
- package/dist/platform/exclusions.js +774 -0
- package/dist/platform/method.d.ts +6 -0
- package/dist/platform/method.js +15 -0
- package/dist/platform/operation.d.ts +169 -0
- package/dist/platform/operation.js +102 -0
- package/dist/platform/ops/accounts.ops.d.ts +32 -0
- package/dist/platform/ops/accounts.ops.js +291 -0
- package/dist/platform/ops/admin-items.ops.d.ts +37 -0
- package/dist/platform/ops/admin-items.ops.js +278 -0
- package/dist/platform/ops/admin.ops.d.ts +38 -0
- package/dist/platform/ops/admin.ops.js +497 -0
- package/dist/platform/ops/agent-skills.ops.d.ts +50 -0
- package/dist/platform/ops/agent-skills.ops.js +509 -0
- package/dist/platform/ops/agent-templates.ops.d.ts +17 -0
- package/dist/platform/ops/agent-templates.ops.js +272 -0
- package/dist/platform/ops/agents.ops.d.ts +37 -0
- package/dist/platform/ops/agents.ops.js +730 -0
- package/dist/platform/ops/approvals.ops.d.ts +30 -0
- package/dist/platform/ops/approvals.ops.js +116 -0
- package/dist/platform/ops/background.ops.d.ts +14 -0
- package/dist/platform/ops/background.ops.js +134 -0
- package/dist/platform/ops/catalog-admin.ops.d.ts +92 -0
- package/dist/platform/ops/catalog-admin.ops.js +682 -0
- package/dist/platform/ops/channels.ops.d.ts +16 -0
- package/dist/platform/ops/channels.ops.js +195 -0
- package/dist/platform/ops/components.ops.d.ts +46 -0
- package/dist/platform/ops/components.ops.js +854 -0
- package/dist/platform/ops/connectors.ops.d.ts +17 -0
- package/dist/platform/ops/connectors.ops.js +190 -0
- package/dist/platform/ops/conversations.ops.d.ts +30 -0
- package/dist/platform/ops/conversations.ops.js +470 -0
- package/dist/platform/ops/devices.ops.d.ts +26 -0
- package/dist/platform/ops/devices.ops.js +311 -0
- package/dist/platform/ops/errors.d.ts +16 -0
- package/dist/platform/ops/errors.js +30 -0
- package/dist/platform/ops/evals.ops.d.ts +28 -0
- package/dist/platform/ops/evals.ops.js +783 -0
- package/dist/platform/ops/extensions-admin.ops.d.ts +25 -0
- package/dist/platform/ops/extensions-admin.ops.js +372 -0
- package/dist/platform/ops/extensions.ops.d.ts +25 -0
- package/dist/platform/ops/extensions.ops.js +347 -0
- package/dist/platform/ops/inbox.ops.d.ts +25 -0
- package/dist/platform/ops/inbox.ops.js +381 -0
- package/dist/platform/ops/marketplaces.ops.d.ts +22 -0
- package/dist/platform/ops/marketplaces.ops.js +466 -0
- package/dist/platform/ops/models.ops.d.ts +25 -0
- package/dist/platform/ops/models.ops.js +232 -0
- package/dist/platform/ops/org-plugins.ops.d.ts +35 -0
- package/dist/platform/ops/org-plugins.ops.js +388 -0
- package/dist/platform/ops/org-settings.ops.d.ts +18 -0
- package/dist/platform/ops/org-settings.ops.js +127 -0
- package/dist/platform/ops/orgs.ops.d.ts +28 -0
- package/dist/platform/ops/orgs.ops.js +298 -0
- package/dist/platform/ops/other-orgs.d.ts +20 -0
- package/dist/platform/ops/other-orgs.js +72 -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 +30 -0
- package/dist/platform/ops/platform.ops.js +231 -0
- package/dist/platform/ops/plugins.ops.d.ts +35 -0
- package/dist/platform/ops/plugins.ops.js +476 -0
- package/dist/platform/ops/previewers.ops.d.ts +14 -0
- package/dist/platform/ops/previewers.ops.js +109 -0
- package/dist/platform/ops/requests.ops.d.ts +14 -0
- package/dist/platform/ops/requests.ops.js +191 -0
- package/dist/platform/ops/role.d.ts +4 -0
- package/dist/platform/ops/role.js +10 -0
- package/dist/platform/ops/setup.ops.d.ts +24 -0
- package/dist/platform/ops/setup.ops.js +212 -0
- package/dist/platform/ops/skills.ops.d.ts +17 -0
- package/dist/platform/ops/skills.ops.js +160 -0
- package/dist/platform/ops/summary.d.ts +10 -0
- package/dist/platform/ops/summary.js +18 -0
- package/dist/platform/ops/themes.ops.d.ts +14 -0
- package/dist/platform/ops/themes.ops.js +47 -0
- package/dist/platform/ops/ui.ops.d.ts +8 -0
- package/dist/platform/ops/ui.ops.js +41 -0
- package/dist/platform/ops/unavailable.d.ts +23 -0
- package/dist/platform/ops/unavailable.js +118 -0
- package/dist/platform/parity.d.ts +33 -0
- package/dist/platform/parity.js +272 -0
- package/dist/platform/platform-ops.module.d.ts +43 -0
- package/dist/platform/platform-ops.module.js +142 -0
- package/dist/platform/platform.module.d.ts +8 -0
- package/dist/platform/platform.module.js +25 -0
- package/dist/platform/registry.d.ts +30 -0
- package/dist/platform/registry.js +111 -0
- package/dist/platform/route-schemas.d.ts +18 -0
- package/dist/platform/route-schemas.js +85 -0
- package/dist/roles/gateway-role.d.ts +18 -3
- package/dist/roles/gateway-role.js +33 -5
- package/dist/roles/gateway.module.d.ts +2 -1
- package/dist/roles/gateway.module.js +6 -3
- 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 +21 -1
- package/dist/runtime/context/build.d.ts +21 -13
- package/dist/runtime/context/build.js +106 -29
- package/dist/runtime/context/claude-tools.d.ts +4 -1
- package/dist/runtime/context/claude-tools.js +13 -12
- package/dist/runtime/context/compaction.js +24 -1
- package/dist/runtime/context/device-paths.d.ts +40 -0
- package/dist/runtime/context/device-paths.js +48 -0
- package/dist/runtime/context/legacy-text.d.ts +22 -0
- package/dist/runtime/context/legacy-text.js +37 -0
- package/dist/runtime/context/reminders.d.ts +2 -0
- package/dist/runtime/context/reminders.js +2 -0
- package/dist/runtime/context/run-context.d.ts +65 -0
- package/dist/runtime/context/run-context.js +215 -0
- package/dist/runtime/context/skills.d.ts +29 -11
- package/dist/runtime/context/skills.js +46 -32
- 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 +36 -17
- package/dist/runtime/loop.d.ts +35 -6
- package/dist/runtime/maintenance.d.ts +9 -4
- package/dist/runtime/maintenance.js +35 -8
- package/dist/runtime/model-call.d.ts +54 -11
- package/dist/runtime/model-call.js +105 -28
- package/dist/runtime/providers.d.ts +149 -29
- package/dist/runtime/providers.js +332 -63
- package/dist/runtime/run-context.service.d.ts +65 -0
- package/dist/runtime/run-context.service.js +236 -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-finish.d.ts +1 -1
- package/dist/runtime/run-jobs.d.ts +3 -5
- package/dist/runtime/run-jobs.js +7 -9
- package/dist/runtime/run-queue.d.ts +62 -5
- package/dist/runtime/run-queue.js +313 -40
- package/dist/runtime/run-worker.d.ts +19 -8
- package/dist/runtime/run-worker.js +105 -44
- package/dist/runtime/runtime.module.js +13 -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 +31 -26
- package/dist/runtime/subagents/definition.js +89 -142
- package/dist/runtime/subagents/deliveries.d.ts +71 -0
- package/dist/runtime/subagents/deliveries.js +228 -0
- package/dist/runtime/subagents/dispatch.d.ts +116 -27
- package/dist/runtime/subagents/dispatch.js +213 -142
- 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/org-agents.js +2 -1
- 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 +25 -8
- package/dist/runtime/subagents/roster.js +48 -12
- package/dist/runtime/subagents/skill-fork.d.ts +4 -3
- package/dist/runtime/subagents/skill-fork.js +9 -5
- 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 +9 -6
- package/dist/runtime/subagents/subagents.service.js +13 -8
- 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 +35 -39
- package/dist/runtime/usage-report.js +171 -97
- package/dist/runtime/waits.d.ts +148 -39
- package/dist/runtime/waits.js +426 -112
- 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 +34 -7
- package/dist/sandbox/providers.js +54 -9
- package/dist/sandbox/sandbox-file-reader.d.ts +35 -0
- package/dist/sandbox/sandbox-file-reader.js +98 -0
- package/dist/sandbox/sandbox.module.d.ts +3 -2
- package/dist/sandbox/sandbox.module.js +10 -4
- package/dist/sandbox/sandbox.service.d.ts +345 -132
- package/dist/sandbox/sandbox.service.js +883 -399
- package/dist/sandbox/unreachable.d.ts +30 -0
- package/dist/sandbox/unreachable.js +108 -0
- package/dist/setup/kernel-checks.d.ts +91 -0
- package/dist/setup/kernel-checks.js +295 -0
- package/dist/setup/oauth-token-probe.d.ts +47 -0
- package/dist/setup/oauth-token-probe.js +108 -0
- package/dist/setup/redact-check.d.ts +18 -0
- package/dist/setup/redact-check.js +46 -0
- package/dist/setup/setup-check-registry.d.ts +86 -0
- package/dist/setup/setup-check-registry.js +75 -0
- package/dist/setup/setup-checks.controller.d.ts +28 -0
- package/dist/setup/setup-checks.controller.js +78 -0
- package/dist/setup/setup-checks.schemas.d.ts +38 -0
- package/dist/setup/setup-checks.schemas.js +43 -0
- package/dist/setup/setup-checks.service.d.ts +144 -0
- package/dist/setup/setup-checks.service.js +683 -0
- package/dist/setup/setup-guides.controller.d.ts +18 -0
- package/dist/setup/setup-guides.controller.js +48 -0
- package/dist/setup/setup-guides.schemas.d.ts +10 -0
- package/dist/setup/setup-guides.schemas.js +6 -0
- package/dist/setup/setup-guides.service.d.ts +126 -0
- package/dist/setup/setup-guides.service.js +315 -0
- package/dist/setup/setup.module.d.ts +8 -0
- package/dist/setup/setup.module.js +31 -0
- package/dist/skills/agent-skills.controller.d.ts +48 -0
- package/dist/skills/agent-skills.controller.js +131 -0
- package/dist/skills/agent-skills.service.d.ts +262 -0
- package/dist/skills/agent-skills.service.js +996 -0
- package/dist/skills/catalog.d.ts +14 -11
- package/dist/skills/catalog.js +32 -50
- package/dist/skills/changes.controller.d.ts +12 -22
- package/dist/skills/changes.controller.js +27 -56
- package/dist/skills/changes.service.d.ts +69 -115
- package/dist/skills/changes.service.js +249 -598
- package/dist/skills/conversation-catalog.d.ts +53 -0
- package/dist/skills/conversation-catalog.js +149 -0
- package/dist/skills/invocable.controller.d.ts +1 -1
- package/dist/skills/invocable.controller.js +2 -2
- package/dist/skills/invocation-keys.d.ts +1 -1
- package/dist/skills/invocation-keys.js +1 -1
- package/dist/skills/invoke.d.ts +3 -3
- package/dist/skills/invoke.js +21 -8
- package/dist/skills/package.d.ts +15 -1
- package/dist/skills/package.js +14 -1
- package/dist/skills/skills.controller.d.ts +32 -6
- package/dist/skills/skills.controller.js +64 -11
- package/dist/skills/skills.module.js +25 -3
- package/dist/skills/skills.schemas.d.ts +44 -0
- package/dist/skills/skills.schemas.js +68 -0
- package/dist/skills/skills.service.d.ts +123 -26
- package/dist/skills/skills.service.js +493 -76
- package/dist/skills/usable.d.ts +82 -0
- package/dist/skills/usable.js +388 -0
- package/dist/themes/render-css.d.ts +13 -0
- package/dist/themes/render-css.js +135 -0
- package/dist/themes/theme-delivery.service.d.ts +36 -0
- package/dist/themes/theme-delivery.service.js +116 -0
- package/dist/themes/theme-state.d.ts +116 -0
- package/dist/themes/theme-state.js +221 -0
- package/dist/themes/theme-usage.d.ts +61 -0
- package/dist/themes/theme-usage.js +98 -0
- package/dist/themes/themes-public.controller.d.ts +33 -0
- package/dist/themes/themes-public.controller.js +98 -0
- package/dist/themes/themes.controller.d.ts +13 -0
- package/dist/themes/themes.controller.js +38 -0
- package/dist/themes/themes.module.d.ts +3 -0
- package/dist/themes/themes.module.js +21 -0
- package/dist/themes/themes.schemas.d.ts +3 -0
- package/dist/themes/themes.schemas.js +2 -0
- package/dist/themes/themes.service.d.ts +50 -0
- package/dist/themes/themes.service.js +99 -0
- package/dist/time-zone.d.ts +5 -0
- package/dist/time-zone.js +19 -0
- package/dist/tools/admin-connectors.d.ts +69 -0
- package/dist/tools/admin-connectors.js +135 -0
- package/dist/tools/approvals.controller.js +2 -3
- package/dist/tools/approvals.schemas.d.ts +21 -0
- package/dist/tools/approvals.schemas.js +15 -0
- package/dist/tools/approvals.service.d.ts +26 -2
- package/dist/tools/approvals.service.js +44 -5
- package/dist/tools/builtin-names.d.ts +104 -0
- package/dist/tools/builtin-names.js +164 -0
- package/dist/tools/builtins/agent.d.ts +27 -25
- package/dist/tools/builtins/agent.js +66 -63
- package/dist/tools/builtins/ask-user.d.ts +1 -1
- package/dist/tools/builtins/ask-user.js +5 -4
- package/dist/tools/builtins/builtin-tools.d.ts +23 -4
- package/dist/tools/builtins/builtin-tools.js +78 -12
- package/dist/tools/builtins/current-time.d.ts +26 -0
- package/dist/tools/builtins/current-time.js +99 -0
- package/dist/tools/builtins/handback.d.ts +28 -0
- package/dist/tools/builtins/handback.js +53 -0
- package/dist/tools/builtins/platform.d.ts +51 -0
- package/dist/tools/builtins/platform.js +451 -0
- package/dist/tools/builtins/read-tool-output.d.ts +1 -1
- package/dist/tools/builtins/read-tool-output.js +2 -2
- package/dist/tools/builtins/sandbox/bash.d.ts +5 -5
- package/dist/tools/builtins/sandbox/bash.js +291 -39
- package/dist/tools/builtins/sandbox/common.d.ts +135 -36
- package/dist/tools/builtins/sandbox/common.js +222 -62
- package/dist/tools/builtins/sandbox/deliver.d.ts +1 -1
- package/dist/tools/builtins/sandbox/deliver.js +19 -16
- package/dist/tools/builtins/sandbox/edit.d.ts +1 -1
- package/dist/tools/builtins/sandbox/edit.js +64 -50
- package/dist/tools/builtins/sandbox/file-state.d.ts +34 -0
- package/dist/tools/builtins/sandbox/file-state.js +34 -0
- package/dist/tools/builtins/sandbox/glob-match.d.ts +1 -1
- package/dist/tools/builtins/sandbox/glob-match.js +1 -1
- package/dist/tools/builtins/sandbox/glob.d.ts +1 -1
- package/dist/tools/builtins/sandbox/glob.js +17 -12
- package/dist/tools/builtins/sandbox/grep.d.ts +7 -4
- package/dist/tools/builtins/sandbox/grep.js +153 -34
- package/dist/tools/builtins/sandbox/index.d.ts +9 -5
- package/dist/tools/builtins/sandbox/index.js +13 -5
- package/dist/tools/builtins/sandbox/read.d.ts +2 -2
- package/dist/tools/builtins/sandbox/read.js +29 -19
- package/dist/tools/builtins/sandbox/task-output.d.ts +79 -0
- package/dist/tools/builtins/sandbox/task-output.js +334 -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.d.ts +1 -1
- package/dist/tools/builtins/sandbox/write.js +51 -44
- 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 +29 -18
- package/dist/tools/builtins/skill-load.js +125 -73
- package/dist/tools/builtins/tool-search.d.ts +13 -9
- package/dist/tools/builtins/tool-search.js +25 -14
- 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/connector-account-policies.d.ts +51 -0
- package/dist/tools/connector-account-policies.js +165 -0
- package/dist/tools/connectors.controller.d.ts +74 -9
- package/dist/tools/connectors.controller.js +133 -16
- package/dist/tools/connectors.schemas.d.ts +27 -0
- package/dist/tools/connectors.schemas.js +34 -0
- package/dist/tools/connectors.service.d.ts +101 -8
- package/dist/tools/connectors.service.js +266 -28
- package/dist/tools/credentials.d.ts +23 -0
- package/dist/tools/credentials.js +90 -1
- package/dist/tools/display-names.d.ts +9 -0
- package/dist/tools/display-names.js +24 -0
- package/dist/tools/drift.js +5 -5
- package/dist/tools/elicitation.js +1 -1
- 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 +61 -4
- package/dist/tools/info.js +119 -33
- package/dist/tools/legacy-data.d.ts +34 -0
- package/dist/tools/legacy-data.js +76 -0
- package/dist/tools/legacy-keys.d.ts +51 -0
- package/dist/tools/legacy-keys.js +114 -0
- package/dist/tools/naming.d.ts +1 -5
- package/dist/tools/naming.js +1 -7
- package/dist/tools/oauth/flow-paths.d.ts +1 -1
- package/dist/tools/oauth/flow-paths.js +1 -1
- package/dist/tools/oauth/flow.js +1 -1
- package/dist/tools/oauth/tokens.d.ts +54 -7
- package/dist/tools/oauth/tokens.js +87 -17
- package/dist/tools/org-tool-switches.d.ts +89 -0
- package/dist/tools/org-tool-switches.js +201 -0
- package/dist/tools/outputs.js +1 -1
- package/dist/tools/pipeline.d.ts +67 -47
- package/dist/tools/pipeline.js +319 -380
- package/dist/tools/policy.d.ts +30 -23
- package/dist/tools/policy.js +142 -64
- package/dist/tools/questions.controller.d.ts +1 -1
- package/dist/tools/questions.controller.js +1 -1
- package/dist/tools/questions.service.d.ts +23 -2
- package/dist/tools/questions.service.js +104 -2
- package/dist/tools/registry.d.ts +189 -68
- package/dist/tools/registry.js +318 -236
- package/dist/tools/resources.d.ts +1 -1
- package/dist/tools/resources.js +1 -1
- package/dist/tools/tools.module.js +31 -3
- package/dist/tools/validate.js +1 -1
- package/dist/ui/admin-ui.controller.d.ts +56 -0
- package/dist/ui/admin-ui.controller.js +192 -0
- package/dist/ui/arrangement.d.ts +65 -0
- package/dist/ui/arrangement.js +171 -0
- package/dist/ui/embed-token.d.ts +2 -2
- package/dist/ui/embed-token.js +30 -5
- package/dist/ui/registry.d.ts +42 -17
- package/dist/ui/registry.js +46 -14
- package/dist/ui/slots.controller.d.ts +11 -0
- package/dist/ui/slots.controller.js +25 -0
- package/dist/ui/ui-stream.d.ts +20 -3
- package/dist/ui/ui-stream.js +25 -7
- package/dist/ui/ui.schemas.d.ts +70 -0
- package/dist/ui/ui.schemas.js +65 -0
- package/dist/ui/views.controller.d.ts +35 -49
- package/dist/ui/views.controller.js +48 -70
- package/dist/ui/views.d.ts +112 -18
- package/dist/ui/views.js +254 -47
- package/package.json +6 -3
- package/src/migrations/0063_tool_keys_claude_code.sql +220 -0
- 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/src/migrations/0089_model_kinds_usage.sql +38 -0
- package/src/migrations/0090_initial_passwords.sql +27 -0
- package/src/migrations/0091_account_time_zone.sql +4 -0
- package/src/migrations/0092_tools_default_on.sql +27 -0
- package/src/migrations/0093_connected_environments.sql +37 -0
- package/src/migrations/0094_environment_paths_idx.sql +7 -0
- package/src/migrations/0095_environment_files_resets.sql +5 -0
- package/src/migrations/0096_environment_demoted_default.sql +18 -0
- package/src/migrations/0097_extension_installs_enabled_at.sql +16 -0
- package/src/migrations/0098_single_provider_running_first.sql +41 -0
- package/src/migrations/0099_channel_connection_guide_ack.sql +6 -0
- package/src/migrations/0100_catalog_files.sql +13 -0
- package/src/migrations/0101_marketplace_icons.sql +32 -0
- package/src/migrations/0102_themes.sql +64 -0
- package/src/migrations/0103_ui_theme_setting.sql +7 -0
- package/src/migrations/0104_connector_tool_account_policies.sql +16 -0
- package/src/migrations/0105_devices_rename.sql +136 -0
- package/src/migrations/0106_setup_guides_v2.sql +10 -0
- package/src/migrations/0107_extension_client_builds.sql +50 -0
- package/src/migrations/0108_question_skipped.sql +6 -0
- package/src/migrations/0109_audit_platform_idx.sql +5 -0
- package/src/migrations/0110_usage_time_idx.sql +8 -0
- package/src/migrations/0111_agent_skill_sharing.sql +22 -0
- package/src/migrations/0112_skill_share_requests.sql +4 -0
- package/dist/catalog/upgrade-targets.d.ts +0 -56
- package/dist/catalog/upgrade-targets.js +0 -90
- package/dist/conversations/sandbox-status.d.ts +0 -24
- package/dist/conversations/sandbox-status.js +0 -52
- package/dist/extensions/org-config.controller.d.ts +0 -24
- package/dist/extensions/org-config.controller.js +0 -62
- package/dist/tools/builtins/sandbox/names.d.ts +0 -7
- package/dist/tools/builtins/sandbox/names.js +0 -20
- package/dist/tools/builtins/skill-write.d.ts +0 -59
- package/dist/tools/builtins/skill-write.js +0 -244
|
@@ -0,0 +1,996 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
+
};
|
|
10
|
+
import { randomUUID } from "node:crypto";
|
|
11
|
+
import { parseSkillMd, SKILL_ENTRY_FILE } from "@capybara-hq/plugin-sdk";
|
|
12
|
+
import { Inject, Injectable } from "@nestjs/common";
|
|
13
|
+
import { sql } from "kysely";
|
|
14
|
+
import { visibleTo } from "../agents/agent-lookup.js";
|
|
15
|
+
import { offeredNamed } from "../catalog/component-state.js";
|
|
16
|
+
import { AttachmentsService, SKILL_PACKAGE_CONTENT_TYPE, skillFilesPrefix, } from "../conversations/attachments.service.js";
|
|
17
|
+
import { EventLog } from "../conversations/event-log.js";
|
|
18
|
+
import { ApiError } from "../errors.js";
|
|
19
|
+
import { audit } from "../identity/audit.js";
|
|
20
|
+
import { assertCustomAllowed } from "../identity/settings.js";
|
|
21
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
22
|
+
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
23
|
+
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
24
|
+
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
25
|
+
import { OrgLock } from "../orgs/org-lock.js";
|
|
26
|
+
import { roleAtLeast } from "../orgs/roles.js";
|
|
27
|
+
import { StorageService } from "../storage/storage.service.js";
|
|
28
|
+
import { invocationOf } from "./catalog.js";
|
|
29
|
+
import { appendConversationCatalog, cancelRequestIn, } from "./conversation-catalog.js";
|
|
30
|
+
import { readSkillPackage, skillManifest, } from "./package.js";
|
|
31
|
+
import { SkillsService } from "./skills.service.js";
|
|
32
|
+
/**
|
|
33
|
+
* The cap on an agent's own skills (`scope = agent`). Far below the catalog snapshot's cap
|
|
34
|
+
* (`SKILLS_CATALOG_MAX`), so normal use never truncates the catalog. Requests never add agent
|
|
35
|
+
* skills (a share moves an existing one out, a version proposal targets an org skill), so they
|
|
36
|
+
* do not count.
|
|
37
|
+
*/
|
|
38
|
+
export const AGENT_SKILLS_MAX = 50;
|
|
39
|
+
/** How many skill files are written at once. */
|
|
40
|
+
const PUT_CONCURRENCY = 4;
|
|
41
|
+
const agentNotFound = () => new ApiError("agent.not_found", "Agent not found");
|
|
42
|
+
const notOwner = () => new ApiError("forbidden", "Only the agent's owner can change its skills.");
|
|
43
|
+
const skillNotFound = () => new ApiError("skill.not_found", "Skill not found");
|
|
44
|
+
/** Whether the account is an admin (or owner) of the org, read live. */
|
|
45
|
+
export async function isOrgAdmin(db, orgId, accountId) {
|
|
46
|
+
const m = await db
|
|
47
|
+
.selectFrom("memberships")
|
|
48
|
+
.select("role")
|
|
49
|
+
.where("org_id", "=", orgId)
|
|
50
|
+
.where("account_id", "=", accountId)
|
|
51
|
+
.executeTakeFirst();
|
|
52
|
+
return m !== undefined && roleAtLeast(m.role, "admin");
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* In the caller's transaction, refuses sharing a skill named `name` when the org already has a
|
|
56
|
+
* live org skill of that name or a platform skill of that name is offered to the org (409
|
|
57
|
+
* `skill.name_exists`): skill names are unique in an org.
|
|
58
|
+
*/
|
|
59
|
+
export async function assertShareableName(db, orgId, name) {
|
|
60
|
+
const taken = await db
|
|
61
|
+
.selectFrom("skills")
|
|
62
|
+
.select("id")
|
|
63
|
+
.where("org_id", "=", orgId)
|
|
64
|
+
.where("scope", "=", "org")
|
|
65
|
+
.where("name", "=", name)
|
|
66
|
+
.where("deleted_at", "is", null)
|
|
67
|
+
.executeTakeFirst();
|
|
68
|
+
const offered = taken ? [] : await offeredNamed(db.db, orgId, "skill", name);
|
|
69
|
+
if (taken || offered.length > 0) {
|
|
70
|
+
throw new ApiError("skill.name_exists", `The organization already has a skill named "${name}"; rename this skill (register it again under another name) before sharing it.`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* In the caller's transaction (the skill row locked), turns an agent skill into an org skill: the
|
|
75
|
+
* org owns it, `agent_id` is cleared, the agent it came from and its maintainer are recorded.
|
|
76
|
+
* Its versions stay.
|
|
77
|
+
*/
|
|
78
|
+
export async function shareSkillIn(db, v) {
|
|
79
|
+
await db
|
|
80
|
+
.updateTable("skills")
|
|
81
|
+
.set({
|
|
82
|
+
scope: "org",
|
|
83
|
+
agent_id: null,
|
|
84
|
+
origin_agent_id: v.agentId,
|
|
85
|
+
maintainer_account_id: v.maintainerAccountId,
|
|
86
|
+
updated_at: sql `now()`,
|
|
87
|
+
})
|
|
88
|
+
.where("id", "=", v.skillId)
|
|
89
|
+
.execute();
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The catalog snapshot `base` with skill `name` replaced by the version just written or proposed
|
|
93
|
+
* (`source` = its prefix), or removed when that version is manual-only. A pinned entry of the
|
|
94
|
+
* skill gets the new version, source and body; a manual-only version drops it (no longer live).
|
|
95
|
+
*/
|
|
96
|
+
function withVersion(base, v) {
|
|
97
|
+
return {
|
|
98
|
+
...base,
|
|
99
|
+
skills: [
|
|
100
|
+
...base.skills.filter((s) => s.name !== v.name),
|
|
101
|
+
...(v.forModel
|
|
102
|
+
? [
|
|
103
|
+
{
|
|
104
|
+
id: v.skillId,
|
|
105
|
+
name: v.name,
|
|
106
|
+
description: v.description,
|
|
107
|
+
version: v.version,
|
|
108
|
+
source: v.source,
|
|
109
|
+
},
|
|
110
|
+
]
|
|
111
|
+
: []),
|
|
112
|
+
],
|
|
113
|
+
...(base.pinned && {
|
|
114
|
+
pinned: base.pinned.map((p) => p.id === v.skillId && v.pinnedBody !== null
|
|
115
|
+
? {
|
|
116
|
+
id: v.skillId,
|
|
117
|
+
version: v.version,
|
|
118
|
+
name: v.name,
|
|
119
|
+
source: v.source,
|
|
120
|
+
body: v.pinnedBody,
|
|
121
|
+
}
|
|
122
|
+
: p),
|
|
123
|
+
}),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/** The body of a skill's SKILL.md (as run start would read it); null if unparsable. */
|
|
127
|
+
export function skillMdBody(files) {
|
|
128
|
+
const md = files.find((f) => f.path === SKILL_ENTRY_FILE);
|
|
129
|
+
if (!md)
|
|
130
|
+
return null;
|
|
131
|
+
try {
|
|
132
|
+
const parsed = parseSkillMd(new TextDecoder("utf-8", { fatal: true }).decode(md.data));
|
|
133
|
+
return "errors" in parsed ? null : parsed.body;
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Takes a KEY SHARE lock on the org row before the agent row is locked: the order `AgentsService`
|
|
141
|
+
* uses (org row FOR UPDATE -> agent row). Without it, a transaction holding the agent row that
|
|
142
|
+
* inserts a row referencing the org (the foreign key takes KEY SHARE) can deadlock with it (40P01).
|
|
143
|
+
*/
|
|
144
|
+
export async function keyShareOrg(db, orgId) {
|
|
145
|
+
await db.selectFrom("orgs").select("id").where("id", "=", orgId).forKeyShare().executeTakeFirst();
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The cap on new agent skills: at {@link AGENT_SKILLS_MAX} live own skills -> 409
|
|
149
|
+
* `skill.agent_cap`. Runs in the caller's transaction.
|
|
150
|
+
*/
|
|
151
|
+
export async function assertBelowAgentSkillCap(db, agentId) {
|
|
152
|
+
const skills = await db
|
|
153
|
+
.selectFrom("skills")
|
|
154
|
+
.select((eb) => eb.fn.countAll().as("n"))
|
|
155
|
+
.where("scope", "=", "agent")
|
|
156
|
+
.where("agent_id", "=", agentId)
|
|
157
|
+
.where("deleted_at", "is", null)
|
|
158
|
+
.executeTakeFirstOrThrow();
|
|
159
|
+
if (Number(skills.n) >= AGENT_SKILLS_MAX) {
|
|
160
|
+
throw new ApiError("skill.agent_cap", `This agent already has ${AGENT_SKILLS_MAX} skills, the maximum; register a new version of an existing skill (same name) instead, or ask the agent's owner to delete one of its skills.`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/** Writes a version of an agent skill and points `current_version` at it (creating the skill). */
|
|
164
|
+
export async function createAgentSkillVersion(db, v) {
|
|
165
|
+
if (v.exists) {
|
|
166
|
+
await db
|
|
167
|
+
.updateTable("skills")
|
|
168
|
+
.set({
|
|
169
|
+
current_version: v.version,
|
|
170
|
+
description: v.manifest.description,
|
|
171
|
+
updated_at: sql `now()`,
|
|
172
|
+
})
|
|
173
|
+
.where("id", "=", v.skillId)
|
|
174
|
+
.execute();
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
await db
|
|
178
|
+
.insertInto("skills")
|
|
179
|
+
.values({
|
|
180
|
+
id: v.skillId,
|
|
181
|
+
org_id: v.orgId,
|
|
182
|
+
scope: "agent",
|
|
183
|
+
agent_id: v.agentId,
|
|
184
|
+
name: v.manifest.name,
|
|
185
|
+
description: v.manifest.description,
|
|
186
|
+
current_version: v.version,
|
|
187
|
+
created_by: v.createdBy,
|
|
188
|
+
})
|
|
189
|
+
.execute();
|
|
190
|
+
}
|
|
191
|
+
await db
|
|
192
|
+
.insertInto("skill_versions")
|
|
193
|
+
.values({
|
|
194
|
+
skill_id: v.skillId,
|
|
195
|
+
version: v.version,
|
|
196
|
+
manifest: JSON.stringify(v.manifest),
|
|
197
|
+
object_prefix: v.prefix,
|
|
198
|
+
created_by: v.createdBy,
|
|
199
|
+
})
|
|
200
|
+
.execute();
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* An agent's own skills (`scope = agent`): only the agent's current owner (read live) registers
|
|
204
|
+
* a zip package as one of them, deletes one or shares one with the org; anyone else gets 403
|
|
205
|
+
* `forbidden` (404 `agent.not_found` when the agent is not visible to them).
|
|
206
|
+
*
|
|
207
|
+
* `register` reads the zip with the one package reader (`readSkillPackage`), writes the files under
|
|
208
|
+
* a fresh `skills/<id>/` prefix before the transaction, then in one transaction (lock order org ->
|
|
209
|
+
* agent -> conversation -> skill rows -> request rows) creates the skill or its next version,
|
|
210
|
+
* audits, and appends a `skills_catalog` snapshot to `conversationId` when given so the same run
|
|
211
|
+
* can `Skill` it at its next step. On failure the prefix is deleted. A package named like a shared
|
|
212
|
+
* org skill the actor maintains (and the agent has no own skill of that name) is a new version of
|
|
213
|
+
* that org skill instead (spec §5.5): an org admin's applies at once, anyone else's becomes a
|
|
214
|
+
* version proposal an org admin decides, tried only in the proposing conversation.
|
|
215
|
+
*
|
|
216
|
+
* `share` (spec §5.4) turns an agent skill into an org skill at once when the owner is an org
|
|
217
|
+
* admin, else records a share request for the org admins. All state is in PG and object storage.
|
|
218
|
+
*/
|
|
219
|
+
let AgentSkillsService = class AgentSkillsService {
|
|
220
|
+
db;
|
|
221
|
+
storage;
|
|
222
|
+
eventLog;
|
|
223
|
+
log;
|
|
224
|
+
txHost;
|
|
225
|
+
skills;
|
|
226
|
+
attachments;
|
|
227
|
+
orgLock;
|
|
228
|
+
catalogDeps;
|
|
229
|
+
constructor(db, storage, eventLog, log, txHost,
|
|
230
|
+
/** An org admin maintainer's version of a shared skill is an org skill version. */
|
|
231
|
+
skills, attachments, orgLock) {
|
|
232
|
+
this.db = db;
|
|
233
|
+
this.storage = storage;
|
|
234
|
+
this.eventLog = eventLog;
|
|
235
|
+
this.log = log;
|
|
236
|
+
this.txHost = txHost;
|
|
237
|
+
this.skills = skills;
|
|
238
|
+
this.attachments = attachments;
|
|
239
|
+
this.orgLock = orgLock;
|
|
240
|
+
this.catalogDeps = { db, log, eventLog };
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Registers a skill package upload onto an agent (presigned, `application/zip`, <= 50 MB): only
|
|
244
|
+
* the agent's current owner (403 `forbidden`, 404 `agent.not_found` when not visible). Agent
|
|
245
|
+
* skills are not governed by the deployment's `customSkills` setting, so it is not checked.
|
|
246
|
+
*/
|
|
247
|
+
async createAgentUpload(orgId, accountId, agentId, input) {
|
|
248
|
+
await this.assertOwner(orgId, agentId, accountId);
|
|
249
|
+
return this.attachments.create(orgId, accountId, { name: input.name, contentType: SKILL_PACKAGE_CONTENT_TYPE, size: input.size }, "skill-package");
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Registers an uploaded package as one of the agent's own skills ({@link register}): the owner
|
|
253
|
+
* is checked before the upload is read (a non-owner learns nothing about it), the zip is read
|
|
254
|
+
* from the uploader's own upload (`attachment.not_found` otherwise) and the upload is consumed
|
|
255
|
+
* in the register transaction (of concurrent requests for it only one registers).
|
|
256
|
+
*/
|
|
257
|
+
async registerAgentUpload(orgId, accountId, agentId, uploadId, actorTokenId) {
|
|
258
|
+
await this.assertOwner(orgId, agentId, accountId);
|
|
259
|
+
const zip = await this.attachments.readSkillPackage(orgId, accountId, uploadId);
|
|
260
|
+
return this.register({ orgId, agentId, accountId, ...(actorTokenId !== undefined && { actorTokenId }) }, zip, { inTransaction: () => this.attachments.consumeSkillPackage(orgId, accountId, uploadId) });
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Registers a zip package as one of the agent's own skills, or as a new version of a shared org
|
|
264
|
+
* skill the actor maintains (see the class comment). `opts.inTransaction` runs in the register
|
|
265
|
+
* transaction after the agent row lock, before the skill rows (e.g. consuming the upload the zip
|
|
266
|
+
* came from, so a concurrent retry of the same upload registers nothing).
|
|
267
|
+
*
|
|
268
|
+
* A version proposal refuses with 409 `skill.proposal_pending_elsewhere` while another
|
|
269
|
+
* conversation (or another agent of the maintainer) has a pending proposal of that skill; one
|
|
270
|
+
* pending from the same conversation is superseded (cancelled, its draft deleted). Versions of a
|
|
271
|
+
* shared skill (proposed or applied) are refused while `customSkills` is denied. A new own skill
|
|
272
|
+
* named like an org skill the agent uses (not maintained by the actor) -> 409
|
|
273
|
+
* `skill.name_exists`. A new version of an own skill cancels its pending share request.
|
|
274
|
+
*/
|
|
275
|
+
async register(actor, zip, opts = {}) {
|
|
276
|
+
const pkg = await readSkillPackage(zip);
|
|
277
|
+
// Refuse early (re-checked under the lock) so a non-owner writes nothing to storage
|
|
278
|
+
await this.assertOwner(actor.orgId, actor.agentId, actor.accountId);
|
|
279
|
+
this.storage.assertAvailable();
|
|
280
|
+
if (await this.appliesToOrgSkill(actor, pkg.name)) {
|
|
281
|
+
// A shared skill is an org skill: refused while custom org skills are denied
|
|
282
|
+
await assertCustomAllowed(this.db.db, "customSkills");
|
|
283
|
+
const claimed = await this.claimIn(actor, pkg.name, opts.inTransaction);
|
|
284
|
+
if (claimed !== null) {
|
|
285
|
+
for (const [conv, seq] of claimed.seqs)
|
|
286
|
+
await this.eventLog.notify(conv, seq);
|
|
287
|
+
for (const p of claimed.prefixes)
|
|
288
|
+
await this.deletePrefix(actor.orgId, p);
|
|
289
|
+
return this.applyOrgVersion(actor, pkg);
|
|
290
|
+
}
|
|
291
|
+
// no longer the maintainer's (or the agent got an own skill of the name): register below
|
|
292
|
+
}
|
|
293
|
+
const prefix = skillFilesPrefix(randomUUID());
|
|
294
|
+
let committed;
|
|
295
|
+
try {
|
|
296
|
+
await this.putFiles(actor.orgId, prefix, pkg.files);
|
|
297
|
+
committed = await this.registerIn(actor, pkg, skillManifest(pkg), prefix, opts.inTransaction);
|
|
298
|
+
}
|
|
299
|
+
catch (e) {
|
|
300
|
+
await this.deletePrefix(actor.orgId, prefix);
|
|
301
|
+
throw e;
|
|
302
|
+
}
|
|
303
|
+
if (committed.toSeq !== null && actor.conversationId !== undefined) {
|
|
304
|
+
await this.eventLog.notify(actor.conversationId, committed.toSeq);
|
|
305
|
+
}
|
|
306
|
+
for (const p of committed.superseded)
|
|
307
|
+
await this.deletePrefix(actor.orgId, p);
|
|
308
|
+
return committed.outcome;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Shares one of the agent's own skills with the org (only the agent's current owner; the
|
|
312
|
+
* deployment's `customSkills` must allow it, else 403 `catalog.custom_disabled`). The org may
|
|
313
|
+
* not already have a skill of that name (409 `skill.name_exists`).
|
|
314
|
+
* - An org admin owner: in one transaction the skill becomes an org skill (`scope = org`,
|
|
315
|
+
* `agent_id` cleared, `origin_agent_id` = the agent, `maintainer_account_id` = the actor);
|
|
316
|
+
* audit `skill.shared`. Its id, versions and files stay, and the agent keeps resolving it.
|
|
317
|
+
* - Anyone else: a share request for the org admins (`kind = 'share'`, the current version, no
|
|
318
|
+
* new files: its prefix is the version's and never deleted); a pending one -> 409
|
|
319
|
+
* `skill.share_pending`. Audit `skill.share_requested`.
|
|
320
|
+
*/
|
|
321
|
+
async share(actor, skillId) {
|
|
322
|
+
await this.assertOwner(actor.orgId, actor.agentId, actor.accountId);
|
|
323
|
+
await assertCustomAllowed(this.db.db, "customSkills");
|
|
324
|
+
const admin = await isOrgAdmin(this.db.db, actor.orgId, actor.accountId);
|
|
325
|
+
return this.shareIn(actor, skillId, admin);
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Soft-deletes one of the agent's own skills (only the agent's current owner; others 403
|
|
329
|
+
* `forbidden`): missing / already deleted / not this agent's -> `skill.not_found`. A pending
|
|
330
|
+
* request of the same name is cancelled with it (a version draft: a reverting snapshot in the
|
|
331
|
+
* requesting conversation, its draft deleted after the commit; a share request keeps its
|
|
332
|
+
* files). Audits `skill.deleted`. Every conversation drops it at its next run start; the name
|
|
333
|
+
* can then be registered again as a new skill.
|
|
334
|
+
*/
|
|
335
|
+
async deleteAgentSkill(orgId, agentId, skillId, accountId, actorTokenId, auditDetail) {
|
|
336
|
+
const cancelled = await this.deleteAgentSkillIn(orgId, agentId, skillId, accountId, actorTokenId, auditDetail);
|
|
337
|
+
for (const [conv, seq] of cancelled.seqs)
|
|
338
|
+
await this.eventLog.notify(conv, seq);
|
|
339
|
+
for (const p of cancelled.prefixes)
|
|
340
|
+
await this.deletePrefix(orgId, p);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* The owner check without a lock (operation prechecks, and before storage writes): a live agent
|
|
344
|
+
* of the org whose current owner is `accountId`; visible but not owned -> 403 `forbidden`, not
|
|
345
|
+
* visible -> 404 `agent.not_found`.
|
|
346
|
+
*/
|
|
347
|
+
async assertOwner(orgId, agentId, accountId) {
|
|
348
|
+
await this.checkOwner(orgId, agentId, accountId, false);
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Whether the account maintains a live shared org skill and is an org admin, read live: then a
|
|
352
|
+
* registration may apply a version to an org skill at once (the Platform operation's
|
|
353
|
+
* confirmation class is `org` for it, before the package name is known).
|
|
354
|
+
*/
|
|
355
|
+
async mayApplyOrgVersions(orgId, accountId) {
|
|
356
|
+
const maintained = await this.db
|
|
357
|
+
.selectFrom("skills")
|
|
358
|
+
.select("id")
|
|
359
|
+
.where("org_id", "=", orgId)
|
|
360
|
+
.where("scope", "=", "org")
|
|
361
|
+
.where("maintainer_account_id", "=", accountId)
|
|
362
|
+
.where("deleted_at", "is", null)
|
|
363
|
+
.executeTakeFirst();
|
|
364
|
+
return maintained !== undefined && (await isOrgAdmin(this.db.db, orgId, accountId));
|
|
365
|
+
}
|
|
366
|
+
/** Reads the agent row (locked FOR NO KEY UPDATE when `lock`) and applies the owner check. */
|
|
367
|
+
async checkOwner(orgId, agentId, accountId, lock) {
|
|
368
|
+
// NO KEY UPDATE, not UPDATE: it serializes the skill writes of one agent but not the foreign
|
|
369
|
+
// key check (FOR KEY SHARE) of a transaction already holding the conversation row locked later
|
|
370
|
+
let q = this.db
|
|
371
|
+
.selectFrom("agents")
|
|
372
|
+
.select(["owner_account_id", "deleted_at"])
|
|
373
|
+
.where("id", "=", agentId)
|
|
374
|
+
.where("org_id", "=", orgId);
|
|
375
|
+
if (lock)
|
|
376
|
+
q = q.forNoKeyUpdate();
|
|
377
|
+
const agent = await q.executeTakeFirst();
|
|
378
|
+
if (!agent || agent.deleted_at !== null)
|
|
379
|
+
throw agentNotFound();
|
|
380
|
+
if (agent.owner_account_id === accountId)
|
|
381
|
+
return;
|
|
382
|
+
// As AgentsService: an agent the actor cannot see -> 404, visible but not owned -> 403
|
|
383
|
+
const visible = await this.db
|
|
384
|
+
.selectFrom("agents")
|
|
385
|
+
.select("id")
|
|
386
|
+
.where("id", "=", agentId)
|
|
387
|
+
.where(visibleTo(accountId))
|
|
388
|
+
.executeTakeFirst();
|
|
389
|
+
if (!visible)
|
|
390
|
+
throw agentNotFound();
|
|
391
|
+
throw notOwner();
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* The live shared org skill named `name` that `accountId` maintains, when the agent has no own
|
|
395
|
+
* skill of that name (locked FOR UPDATE when `lock`, after the own skill row was looked at).
|
|
396
|
+
*/
|
|
397
|
+
async maintainedSkill(actor, name, lock) {
|
|
398
|
+
let q = this.db
|
|
399
|
+
.selectFrom("skills")
|
|
400
|
+
.select(["id", "current_version"])
|
|
401
|
+
.where("org_id", "=", actor.orgId)
|
|
402
|
+
.where("scope", "=", "org")
|
|
403
|
+
.where("name", "=", name)
|
|
404
|
+
.where("maintainer_account_id", "=", actor.accountId)
|
|
405
|
+
.where("deleted_at", "is", null);
|
|
406
|
+
if (lock)
|
|
407
|
+
q = q.forUpdate();
|
|
408
|
+
return q.executeTakeFirst();
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Whether registering `name` applies a version to a shared org skill at once: the actor, an org
|
|
412
|
+
* admin, maintains a live org skill of that name and the agent has no own skill of it.
|
|
413
|
+
*/
|
|
414
|
+
async appliesToOrgSkill(actor, name) {
|
|
415
|
+
const own = await this.db
|
|
416
|
+
.selectFrom("skills")
|
|
417
|
+
.select("id")
|
|
418
|
+
.where("org_id", "=", actor.orgId)
|
|
419
|
+
.where("scope", "=", "agent")
|
|
420
|
+
.where("agent_id", "=", actor.agentId)
|
|
421
|
+
.where("name", "=", name)
|
|
422
|
+
.where("deleted_at", "is", null)
|
|
423
|
+
.executeTakeFirst();
|
|
424
|
+
if (own)
|
|
425
|
+
return false;
|
|
426
|
+
if ((await this.maintainedSkill(actor, name, false)) === undefined)
|
|
427
|
+
return false;
|
|
428
|
+
return isOrgAdmin(this.db.db, actor.orgId, actor.accountId);
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* An org admin maintainer's new version of a shared skill: written as an org skill version
|
|
432
|
+
* (`SkillsService.createVersionFromFiles`, which re-checks `skills.manage` under the org row
|
|
433
|
+
* lock and handles a skill the org promoted), then the registering conversation's catalog gets
|
|
434
|
+
* it at once. {@link claimIn} ran first.
|
|
435
|
+
*/
|
|
436
|
+
async applyOrgVersion(actor, pkg) {
|
|
437
|
+
const out = await this.skills.createVersionFromFiles(actor.orgId, actor.accountId, pkg, {
|
|
438
|
+
...(actor.actorTokenId !== undefined && { actorTokenId: actor.actorTokenId }),
|
|
439
|
+
auditDetail: {
|
|
440
|
+
agentId: actor.agentId,
|
|
441
|
+
...(actor.conversationId !== undefined && { conversationId: actor.conversationId }),
|
|
442
|
+
...actor.auditDetail,
|
|
443
|
+
},
|
|
444
|
+
});
|
|
445
|
+
const forModel = invocationOf(skillManifest(pkg)).model;
|
|
446
|
+
if (actor.conversationId !== undefined) {
|
|
447
|
+
const toSeq = await this.appendAppliedIn(actor, actor.conversationId, out, pkg, forModel);
|
|
448
|
+
if (toSeq !== null)
|
|
449
|
+
await this.eventLog.notify(actor.conversationId, toSeq);
|
|
450
|
+
}
|
|
451
|
+
return {
|
|
452
|
+
kind: "version",
|
|
453
|
+
skillId: out.skill.id,
|
|
454
|
+
name: pkg.name,
|
|
455
|
+
version: out.version,
|
|
456
|
+
created: out.created,
|
|
457
|
+
manualOnly: !forModel,
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Before {@link applyOrgVersion} writes the version, in a transaction of its own: re-checks the
|
|
462
|
+
* owner (agent row lock) and that the actor still maintains the org skill of that name with no
|
|
463
|
+
* own skill of it (skill row lock); cancels the skill's pending version proposals (an older one
|
|
464
|
+
* must not overwrite this version later: reverting snapshots, drafts deleted after the commit)
|
|
465
|
+
* and runs `inTransaction` (consuming the upload). Returns null, cancelling and consuming
|
|
466
|
+
* nothing, when the skill no longer qualifies or a proposal appeared in a conversation that was
|
|
467
|
+
* not locked first (the caller registers it the ordinary way).
|
|
468
|
+
* Lock order org -> agent -> the proposals' conversations -> skill row -> request rows.
|
|
469
|
+
*/
|
|
470
|
+
async claimIn(actor, name, inTransaction) {
|
|
471
|
+
await keyShareOrg(this.db, actor.orgId);
|
|
472
|
+
await this.checkOwner(actor.orgId, actor.agentId, actor.accountId, true);
|
|
473
|
+
const seen = await this.maintainedSkill(actor, name, false);
|
|
474
|
+
if (seen === undefined)
|
|
475
|
+
return null;
|
|
476
|
+
const proposals = (skillId) => this.db
|
|
477
|
+
.selectFrom("skill_change_requests")
|
|
478
|
+
.selectAll()
|
|
479
|
+
.where("skill_id", "=", skillId)
|
|
480
|
+
.where("kind", "=", "version")
|
|
481
|
+
.where("status", "=", "pending");
|
|
482
|
+
const convs = [
|
|
483
|
+
...new Set((await proposals(seen.id).execute()).flatMap((r) => r.requested_in_conversation === null ? [] : [r.requested_in_conversation])),
|
|
484
|
+
].sort();
|
|
485
|
+
if (convs.length > 0) {
|
|
486
|
+
await this.db
|
|
487
|
+
.selectFrom("conversations")
|
|
488
|
+
.select("id")
|
|
489
|
+
.where("id", "in", convs)
|
|
490
|
+
.orderBy("id")
|
|
491
|
+
.forUpdate()
|
|
492
|
+
.execute();
|
|
493
|
+
}
|
|
494
|
+
const own = await this.db
|
|
495
|
+
.selectFrom("skills")
|
|
496
|
+
.select("id")
|
|
497
|
+
.where("org_id", "=", actor.orgId)
|
|
498
|
+
.where("scope", "=", "agent")
|
|
499
|
+
.where("agent_id", "=", actor.agentId)
|
|
500
|
+
.where("name", "=", name)
|
|
501
|
+
.where("deleted_at", "is", null)
|
|
502
|
+
.forUpdate()
|
|
503
|
+
.executeTakeFirst();
|
|
504
|
+
const shared = own ? undefined : await this.maintainedSkill(actor, name, true);
|
|
505
|
+
if (shared === undefined)
|
|
506
|
+
return null;
|
|
507
|
+
const pending = await proposals(shared.id).orderBy("created_at").forUpdate().execute();
|
|
508
|
+
// A proposal committed after the conversations were locked: its revert would lock a
|
|
509
|
+
// conversation after the skill row (reverse order). Back off to the ordinary register path
|
|
510
|
+
const locked = new Set(convs);
|
|
511
|
+
if (pending.some((r) => r.requested_in_conversation !== null && !locked.has(r.requested_in_conversation))) {
|
|
512
|
+
return null;
|
|
513
|
+
}
|
|
514
|
+
const out = { prefixes: [], seqs: [] };
|
|
515
|
+
for (const r of pending) {
|
|
516
|
+
await cancelRequestIn(this.catalogDeps, r, out, {
|
|
517
|
+
actorAccountId: actor.accountId,
|
|
518
|
+
...(actor.actorTokenId !== undefined && { actorTokenId: actor.actorTokenId }),
|
|
519
|
+
reason: "superseded",
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
if (inTransaction !== undefined)
|
|
523
|
+
await inTransaction();
|
|
524
|
+
return out;
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* After {@link applyOrgVersion}: appends a snapshot to the conversation (of this org and agent)
|
|
528
|
+
* with the org skill's new version. A version served from the platform row (a skill the org
|
|
529
|
+
* promoted) has no version row of the org: nothing is appended, the next run start resolves it.
|
|
530
|
+
*/
|
|
531
|
+
async appendAppliedIn(actor, conversationId, out, pkg, forModel) {
|
|
532
|
+
await keyShareOrg(this.db, actor.orgId);
|
|
533
|
+
await this.lockConversation(actor, conversationId);
|
|
534
|
+
const v = await this.db
|
|
535
|
+
.selectFrom("skill_versions")
|
|
536
|
+
.select("object_prefix")
|
|
537
|
+
.where("skill_id", "=", out.skill.id)
|
|
538
|
+
.where("version", "=", out.version)
|
|
539
|
+
.executeTakeFirst();
|
|
540
|
+
if (!v)
|
|
541
|
+
return null;
|
|
542
|
+
const pinnedBody = skillMdBody(pkg.files);
|
|
543
|
+
return appendConversationCatalog(this.catalogDeps, conversationId, (base) => withVersion(base, {
|
|
544
|
+
skillId: out.skill.id,
|
|
545
|
+
name: pkg.name,
|
|
546
|
+
description: pkg.description,
|
|
547
|
+
version: out.version,
|
|
548
|
+
source: v.object_prefix,
|
|
549
|
+
forModel,
|
|
550
|
+
pinnedBody,
|
|
551
|
+
}), `skills_catalog:register:${v.object_prefix}`, actor.runId);
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Locks the conversation row (the snapshot append's lock): a conversation of this org with this
|
|
555
|
+
* agent only (defense in depth: callers pass the run's own), else `conversation.not_found`.
|
|
556
|
+
*/
|
|
557
|
+
async lockConversation(actor, conversationId) {
|
|
558
|
+
const conv = await this.db
|
|
559
|
+
.selectFrom("conversations")
|
|
560
|
+
.select("agent_id")
|
|
561
|
+
.where("id", "=", conversationId)
|
|
562
|
+
.where("org_id", "=", actor.orgId)
|
|
563
|
+
.forUpdate()
|
|
564
|
+
.executeTakeFirst();
|
|
565
|
+
if (conv?.agent_id !== actor.agentId) {
|
|
566
|
+
throw new ApiError("conversation.not_found", "Conversation not found");
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
/** The transaction of {@link register}. */
|
|
570
|
+
async registerIn(actor, pkg, manifest, prefix, inTransaction) {
|
|
571
|
+
await keyShareOrg(this.db, actor.orgId);
|
|
572
|
+
await this.checkOwner(actor.orgId, actor.agentId, actor.accountId, true);
|
|
573
|
+
// Then the conversation row, still after the agent row
|
|
574
|
+
if (actor.conversationId !== undefined)
|
|
575
|
+
await this.lockConversation(actor, actor.conversationId);
|
|
576
|
+
if (inTransaction !== undefined)
|
|
577
|
+
await inTransaction();
|
|
578
|
+
const existing = await this.db
|
|
579
|
+
.selectFrom("skills")
|
|
580
|
+
.select(["id", "current_version"])
|
|
581
|
+
.where("org_id", "=", actor.orgId)
|
|
582
|
+
.where("scope", "=", "agent")
|
|
583
|
+
.where("agent_id", "=", actor.agentId)
|
|
584
|
+
.where("name", "=", pkg.name)
|
|
585
|
+
.where("deleted_at", "is", null)
|
|
586
|
+
.forUpdate()
|
|
587
|
+
.executeTakeFirst();
|
|
588
|
+
const superseded = { prefixes: [], seqs: [] };
|
|
589
|
+
if (!existing) {
|
|
590
|
+
const shared = await this.maintainedSkill(actor, pkg.name, true);
|
|
591
|
+
if (shared)
|
|
592
|
+
return this.proposeIn(actor, pkg, manifest, prefix, shared);
|
|
593
|
+
await this.assertNoUsedOrgSkillNamed(actor, pkg.name);
|
|
594
|
+
await assertBelowAgentSkillCap(this.db, actor.agentId);
|
|
595
|
+
}
|
|
596
|
+
else {
|
|
597
|
+
// A pending share was for the version the admins review: a new version supersedes it (the
|
|
598
|
+
// share's files are that version's own and stay)
|
|
599
|
+
const shares = await this.db
|
|
600
|
+
.selectFrom("skill_change_requests")
|
|
601
|
+
.selectAll()
|
|
602
|
+
.where("skill_id", "=", existing.id)
|
|
603
|
+
.where("kind", "=", "share")
|
|
604
|
+
.where("status", "=", "pending")
|
|
605
|
+
.forUpdate()
|
|
606
|
+
.execute();
|
|
607
|
+
for (const r of shares) {
|
|
608
|
+
await cancelRequestIn(this.catalogDeps, r, superseded, {
|
|
609
|
+
actorAccountId: actor.accountId,
|
|
610
|
+
...(actor.actorTokenId !== undefined && { actorTokenId: actor.actorTokenId }),
|
|
611
|
+
reason: "superseded_by_new_version",
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
const version = (existing?.current_version ?? 0) + 1;
|
|
616
|
+
const skillId = existing?.id ?? randomUUID();
|
|
617
|
+
await createAgentSkillVersion(this.db, {
|
|
618
|
+
orgId: actor.orgId,
|
|
619
|
+
agentId: actor.agentId,
|
|
620
|
+
skillId,
|
|
621
|
+
exists: existing !== undefined,
|
|
622
|
+
version,
|
|
623
|
+
manifest,
|
|
624
|
+
prefix,
|
|
625
|
+
createdBy: actor.accountId,
|
|
626
|
+
});
|
|
627
|
+
await audit(this.db.db, {
|
|
628
|
+
actorAccountId: actor.accountId,
|
|
629
|
+
...(actor.actorTokenId !== undefined && { actorTokenId: actor.actorTokenId }),
|
|
630
|
+
orgId: actor.orgId,
|
|
631
|
+
action: existing ? "skill.version_created" : "skill.created",
|
|
632
|
+
target: skillId,
|
|
633
|
+
detail: {
|
|
634
|
+
name: pkg.name,
|
|
635
|
+
version,
|
|
636
|
+
files: manifest.files.length,
|
|
637
|
+
agentId: actor.agentId,
|
|
638
|
+
...(actor.conversationId !== undefined && { conversationId: actor.conversationId }),
|
|
639
|
+
...actor.auditDetail,
|
|
640
|
+
},
|
|
641
|
+
});
|
|
642
|
+
const forModel = invocationOf(manifest).model;
|
|
643
|
+
let toSeq = null;
|
|
644
|
+
if (actor.conversationId !== undefined) {
|
|
645
|
+
// The conversation sees the new version at once: this skill replaced / added in its latest
|
|
646
|
+
// snapshot (source = this version's prefix)
|
|
647
|
+
const pinnedBody = skillMdBody(pkg.files);
|
|
648
|
+
toSeq = await appendConversationCatalog(this.catalogDeps, actor.conversationId, (base) => withVersion(base, {
|
|
649
|
+
skillId,
|
|
650
|
+
name: pkg.name,
|
|
651
|
+
description: pkg.description,
|
|
652
|
+
version,
|
|
653
|
+
source: prefix,
|
|
654
|
+
forModel,
|
|
655
|
+
pinnedBody,
|
|
656
|
+
}), `skills_catalog:register:${prefix}`, actor.runId);
|
|
657
|
+
}
|
|
658
|
+
return {
|
|
659
|
+
outcome: {
|
|
660
|
+
kind: "version",
|
|
661
|
+
skillId,
|
|
662
|
+
name: pkg.name,
|
|
663
|
+
version,
|
|
664
|
+
created: !existing,
|
|
665
|
+
manualOnly: !forModel,
|
|
666
|
+
},
|
|
667
|
+
toSeq,
|
|
668
|
+
superseded: superseded.prefixes,
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Spec §5.2: an agent's own skill may not take the name of an org skill the agent uses (selected
|
|
673
|
+
* in its current definition, or one it shared) unless the actor maintains it (then the
|
|
674
|
+
* registration is a version of it): 409 `skill.name_exists`.
|
|
675
|
+
*/
|
|
676
|
+
async assertNoUsedOrgSkillNamed(actor, name) {
|
|
677
|
+
const def = await this.db
|
|
678
|
+
.selectFrom("agents")
|
|
679
|
+
.innerJoin("agent_versions", (j) => j
|
|
680
|
+
.onRef("agent_versions.agent_id", "=", "agents.id")
|
|
681
|
+
.onRef("agent_versions.version", "=", "agents.current_version"))
|
|
682
|
+
.select("agent_versions.definition")
|
|
683
|
+
.where("agents.id", "=", actor.agentId)
|
|
684
|
+
.executeTakeFirst();
|
|
685
|
+
const selected = def?.definition?.skills
|
|
686
|
+
?.orgSkills;
|
|
687
|
+
const ids = Array.isArray(selected)
|
|
688
|
+
? selected.filter((x) => typeof x === "string")
|
|
689
|
+
: [];
|
|
690
|
+
const used = await this.db
|
|
691
|
+
.selectFrom("skills")
|
|
692
|
+
.select("id")
|
|
693
|
+
.where("org_id", "=", actor.orgId)
|
|
694
|
+
.where("scope", "=", "org")
|
|
695
|
+
.where("name", "=", name)
|
|
696
|
+
.where("deleted_at", "is", null)
|
|
697
|
+
.where((eb) => eb.or([
|
|
698
|
+
eb("origin_agent_id", "=", actor.agentId),
|
|
699
|
+
...(ids.length > 0 ? [eb("id", "in", ids)] : []),
|
|
700
|
+
]))
|
|
701
|
+
.executeTakeFirst();
|
|
702
|
+
if (used) {
|
|
703
|
+
throw new ApiError("skill.name_exists", `This agent uses the org skill "${name}", which only its maintainer can update; register the package under another name, or ask the skill's maintainer.`);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* In {@link registerIn} (the org skill row locked): a version proposal on the shared skill. The
|
|
708
|
+
* pending proposals of that skill (and any pending request of this agent with the name) are
|
|
709
|
+
* locked: one from another conversation refuses, ones from this conversation are superseded.
|
|
710
|
+
* The trial applies only in the proposing conversation (the catalog overlay reads pending
|
|
711
|
+
* `version` requests by conversation).
|
|
712
|
+
*/
|
|
713
|
+
async proposeIn(actor, pkg, manifest, prefix, shared) {
|
|
714
|
+
// A shared skill is an org skill: refused while custom org skills are denied
|
|
715
|
+
await assertCustomAllowed(this.db.db, "customSkills");
|
|
716
|
+
const here = actor.conversationId ?? null;
|
|
717
|
+
const pending = await this.db
|
|
718
|
+
.selectFrom("skill_change_requests")
|
|
719
|
+
.selectAll()
|
|
720
|
+
.where("org_id", "=", actor.orgId)
|
|
721
|
+
.where("status", "=", "pending")
|
|
722
|
+
.where((eb) => eb.or([
|
|
723
|
+
eb.and([eb("skill_id", "=", shared.id), eb("kind", "=", "version")]),
|
|
724
|
+
eb.and([
|
|
725
|
+
eb("agent_id", "=", actor.agentId),
|
|
726
|
+
eb(sql `proposed_version -> 'manifest' ->> 'name'`, "=", pkg.name),
|
|
727
|
+
]),
|
|
728
|
+
]))
|
|
729
|
+
.orderBy("created_at")
|
|
730
|
+
.forUpdate()
|
|
731
|
+
.execute();
|
|
732
|
+
if (pending.some((p) => p.kind !== "version" ||
|
|
733
|
+
p.agent_id !== actor.agentId ||
|
|
734
|
+
p.requested_in_conversation !== here)) {
|
|
735
|
+
throw new ApiError("skill.proposal_pending_elsewhere", `A proposed version of the skill "${pkg.name}" from another conversation is waiting for an org admin; wait for that decision, or continue in that conversation.`);
|
|
736
|
+
}
|
|
737
|
+
const superseded = { prefixes: [], seqs: [] };
|
|
738
|
+
for (const p of pending) {
|
|
739
|
+
await cancelRequestIn(this.catalogDeps, p, superseded, {
|
|
740
|
+
actorAccountId: actor.accountId,
|
|
741
|
+
...(actor.actorTokenId !== undefined && { actorTokenId: actor.actorTokenId }),
|
|
742
|
+
reason: "superseded",
|
|
743
|
+
// the new snapshot below replaces the draft: no reverting snapshot in between
|
|
744
|
+
revert: false,
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
const version = shared.current_version + 1;
|
|
748
|
+
const requestId = randomUUID();
|
|
749
|
+
await this.db
|
|
750
|
+
.insertInto("skill_change_requests")
|
|
751
|
+
.values({
|
|
752
|
+
id: requestId,
|
|
753
|
+
org_id: actor.orgId,
|
|
754
|
+
agent_id: actor.agentId,
|
|
755
|
+
skill_id: shared.id,
|
|
756
|
+
kind: "version",
|
|
757
|
+
proposed_version: JSON.stringify({ skillId: shared.id, version, manifest }),
|
|
758
|
+
object_prefix: prefix,
|
|
759
|
+
requested_by_account: actor.accountId,
|
|
760
|
+
requested_in_conversation: here,
|
|
761
|
+
})
|
|
762
|
+
.execute();
|
|
763
|
+
await audit(this.db.db, {
|
|
764
|
+
actorAccountId: actor.accountId,
|
|
765
|
+
...(actor.actorTokenId !== undefined && { actorTokenId: actor.actorTokenId }),
|
|
766
|
+
orgId: actor.orgId,
|
|
767
|
+
action: "skill.change_requested",
|
|
768
|
+
target: requestId,
|
|
769
|
+
detail: {
|
|
770
|
+
kind: "version",
|
|
771
|
+
skillId: shared.id,
|
|
772
|
+
name: pkg.name,
|
|
773
|
+
version,
|
|
774
|
+
files: manifest.files.length,
|
|
775
|
+
agentId: actor.agentId,
|
|
776
|
+
...(here !== null && { conversationId: here }),
|
|
777
|
+
...actor.auditDetail,
|
|
778
|
+
},
|
|
779
|
+
});
|
|
780
|
+
const forModel = invocationOf(manifest).model;
|
|
781
|
+
let toSeq = null;
|
|
782
|
+
if (actor.conversationId !== undefined) {
|
|
783
|
+
const pinnedBody = skillMdBody(pkg.files);
|
|
784
|
+
toSeq = await appendConversationCatalog(this.catalogDeps, actor.conversationId, (base) => withVersion(base, {
|
|
785
|
+
skillId: shared.id,
|
|
786
|
+
name: pkg.name,
|
|
787
|
+
description: pkg.description,
|
|
788
|
+
version,
|
|
789
|
+
source: prefix,
|
|
790
|
+
forModel,
|
|
791
|
+
pinnedBody,
|
|
792
|
+
}), `skills_catalog:propose:${prefix}`, actor.runId);
|
|
793
|
+
}
|
|
794
|
+
return {
|
|
795
|
+
outcome: {
|
|
796
|
+
kind: "proposed",
|
|
797
|
+
requestId,
|
|
798
|
+
skillId: shared.id,
|
|
799
|
+
name: pkg.name,
|
|
800
|
+
version,
|
|
801
|
+
manualOnly: !forModel,
|
|
802
|
+
},
|
|
803
|
+
toSeq,
|
|
804
|
+
superseded: superseded.prefixes,
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
/** The transaction of {@link share} (lock order org -> agent -> skill row -> request rows). */
|
|
808
|
+
async shareIn(actor, skillId, admin) {
|
|
809
|
+
// An org admin changes the org's skill library: the org row lock re-checks the role live and
|
|
810
|
+
// serializes it with every other org skill write (names stay unique)
|
|
811
|
+
if (admin)
|
|
812
|
+
await this.orgLock.lockAndAuthorize(actor.orgId, actor.accountId, "skills.manage");
|
|
813
|
+
else
|
|
814
|
+
await keyShareOrg(this.db, actor.orgId);
|
|
815
|
+
await this.checkOwner(actor.orgId, actor.agentId, actor.accountId, true);
|
|
816
|
+
await assertCustomAllowed(this.db.db, "customSkills");
|
|
817
|
+
const skill = await this.db
|
|
818
|
+
.selectFrom("skills")
|
|
819
|
+
.select(["id", "name", "current_version"])
|
|
820
|
+
.where("id", "=", skillId)
|
|
821
|
+
.where("org_id", "=", actor.orgId)
|
|
822
|
+
.where("scope", "=", "agent")
|
|
823
|
+
.where("agent_id", "=", actor.agentId)
|
|
824
|
+
.where("deleted_at", "is", null)
|
|
825
|
+
.forUpdate()
|
|
826
|
+
.executeTakeFirst();
|
|
827
|
+
if (!skill)
|
|
828
|
+
throw skillNotFound();
|
|
829
|
+
await assertShareableName(this.db, actor.orgId, skill.name);
|
|
830
|
+
const who = {
|
|
831
|
+
actorAccountId: actor.accountId,
|
|
832
|
+
...(actor.actorTokenId !== undefined && { actorTokenId: actor.actorTokenId }),
|
|
833
|
+
orgId: actor.orgId,
|
|
834
|
+
};
|
|
835
|
+
if (admin) {
|
|
836
|
+
await shareSkillIn(this.db, {
|
|
837
|
+
skillId,
|
|
838
|
+
agentId: actor.agentId,
|
|
839
|
+
maintainerAccountId: actor.accountId,
|
|
840
|
+
});
|
|
841
|
+
await audit(this.db.db, {
|
|
842
|
+
...who,
|
|
843
|
+
action: "skill.shared",
|
|
844
|
+
target: skillId,
|
|
845
|
+
detail: {
|
|
846
|
+
name: skill.name,
|
|
847
|
+
agentId: actor.agentId,
|
|
848
|
+
maintainer: actor.accountId,
|
|
849
|
+
...actor.auditDetail,
|
|
850
|
+
},
|
|
851
|
+
});
|
|
852
|
+
return { kind: "shared", skillId };
|
|
853
|
+
}
|
|
854
|
+
const pending = await this.db
|
|
855
|
+
.selectFrom("skill_change_requests")
|
|
856
|
+
.select("id")
|
|
857
|
+
.where("skill_id", "=", skillId)
|
|
858
|
+
.where("kind", "=", "share")
|
|
859
|
+
.where("status", "=", "pending")
|
|
860
|
+
.forUpdate()
|
|
861
|
+
.executeTakeFirst();
|
|
862
|
+
if (pending) {
|
|
863
|
+
throw new ApiError("skill.share_pending", `Sharing the skill "${skill.name}" is already waiting for an org admin.`);
|
|
864
|
+
}
|
|
865
|
+
const v = await this.db
|
|
866
|
+
.selectFrom("skill_versions")
|
|
867
|
+
.select(["manifest", "object_prefix"])
|
|
868
|
+
.where("skill_id", "=", skillId)
|
|
869
|
+
.where("version", "=", skill.current_version)
|
|
870
|
+
.executeTakeFirstOrThrow();
|
|
871
|
+
const requestId = randomUUID();
|
|
872
|
+
await this.db
|
|
873
|
+
.insertInto("skill_change_requests")
|
|
874
|
+
.values({
|
|
875
|
+
id: requestId,
|
|
876
|
+
org_id: actor.orgId,
|
|
877
|
+
agent_id: actor.agentId,
|
|
878
|
+
skill_id: skillId,
|
|
879
|
+
kind: "share",
|
|
880
|
+
proposed_version: JSON.stringify({
|
|
881
|
+
skillId,
|
|
882
|
+
version: skill.current_version,
|
|
883
|
+
manifest: v.manifest,
|
|
884
|
+
}),
|
|
885
|
+
// the version's own files: never deleted with the request
|
|
886
|
+
object_prefix: v.object_prefix,
|
|
887
|
+
requested_by_account: actor.accountId,
|
|
888
|
+
requested_in_conversation: null,
|
|
889
|
+
})
|
|
890
|
+
.execute();
|
|
891
|
+
await audit(this.db.db, {
|
|
892
|
+
...who,
|
|
893
|
+
action: "skill.share_requested",
|
|
894
|
+
target: skillId,
|
|
895
|
+
detail: {
|
|
896
|
+
requestId,
|
|
897
|
+
name: skill.name,
|
|
898
|
+
version: skill.current_version,
|
|
899
|
+
agentId: actor.agentId,
|
|
900
|
+
...actor.auditDetail,
|
|
901
|
+
},
|
|
902
|
+
});
|
|
903
|
+
return { kind: "requested", requestId };
|
|
904
|
+
}
|
|
905
|
+
/** The transaction of {@link deleteAgentSkill}. */
|
|
906
|
+
async deleteAgentSkillIn(orgId, agentId, skillId, accountId, actorTokenId, auditDetail) {
|
|
907
|
+
await keyShareOrg(this.db, orgId);
|
|
908
|
+
await this.checkOwner(orgId, agentId, accountId, true);
|
|
909
|
+
const r = await this.db
|
|
910
|
+
.updateTable("skills")
|
|
911
|
+
.set({ deleted_at: sql `now()`, updated_at: sql `now()` })
|
|
912
|
+
.where("id", "=", skillId)
|
|
913
|
+
.where("org_id", "=", orgId)
|
|
914
|
+
.where("scope", "=", "agent")
|
|
915
|
+
.where("agent_id", "=", agentId)
|
|
916
|
+
.where("deleted_at", "is", null)
|
|
917
|
+
.returning(["name"])
|
|
918
|
+
.executeTakeFirst();
|
|
919
|
+
if (!r)
|
|
920
|
+
throw skillNotFound();
|
|
921
|
+
const out = { prefixes: [], seqs: [] };
|
|
922
|
+
const pend = await this.db
|
|
923
|
+
.selectFrom("skill_change_requests")
|
|
924
|
+
.selectAll()
|
|
925
|
+
.where("agent_id", "=", agentId)
|
|
926
|
+
.where("status", "=", "pending")
|
|
927
|
+
.where(sql `proposed_version -> 'manifest' ->> 'name'`, "=", r.name)
|
|
928
|
+
.forUpdate()
|
|
929
|
+
.execute();
|
|
930
|
+
for (const p of pend) {
|
|
931
|
+
await cancelRequestIn(this.catalogDeps, p, out, {
|
|
932
|
+
actorAccountId: accountId,
|
|
933
|
+
...(actorTokenId !== undefined && { actorTokenId }),
|
|
934
|
+
reason: "skill_deleted",
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
await audit(this.db.db, {
|
|
938
|
+
actorAccountId: accountId,
|
|
939
|
+
...(actorTokenId !== undefined && { actorTokenId }),
|
|
940
|
+
orgId,
|
|
941
|
+
action: "skill.deleted",
|
|
942
|
+
target: skillId,
|
|
943
|
+
detail: { name: r.name, agentId, ...auditDetail },
|
|
944
|
+
});
|
|
945
|
+
return out;
|
|
946
|
+
}
|
|
947
|
+
/** Writes the files under `prefix` in the org's kernel space, a few at a time. */
|
|
948
|
+
async putFiles(orgId, prefix, files) {
|
|
949
|
+
const store = this.storage.kernel(orgId);
|
|
950
|
+
const queue = [...files];
|
|
951
|
+
await Promise.all(Array.from({ length: Math.min(PUT_CONCURRENCY, queue.length) }, async () => {
|
|
952
|
+
for (let f = queue.shift(); f; f = queue.shift()) {
|
|
953
|
+
await store.put(`${prefix}${f.path}`, f.data, {
|
|
954
|
+
contentType: "application/octet-stream",
|
|
955
|
+
size: f.size,
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
}));
|
|
959
|
+
}
|
|
960
|
+
/** Deletes objects best effort (a failure is only logged: org data cleanup removes orphans). */
|
|
961
|
+
async deletePrefix(orgId, prefix) {
|
|
962
|
+
try {
|
|
963
|
+
await this.storage.kernel(orgId).deletePrefix(prefix);
|
|
964
|
+
}
|
|
965
|
+
catch (err) {
|
|
966
|
+
this.log.warn("skill files cleanup failed", { orgId, prefix, err });
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
};
|
|
970
|
+
__decorate([
|
|
971
|
+
Transactional()
|
|
972
|
+
], AgentSkillsService.prototype, "claimIn", null);
|
|
973
|
+
__decorate([
|
|
974
|
+
Transactional()
|
|
975
|
+
], AgentSkillsService.prototype, "appendAppliedIn", null);
|
|
976
|
+
__decorate([
|
|
977
|
+
Transactional()
|
|
978
|
+
], AgentSkillsService.prototype, "registerIn", null);
|
|
979
|
+
__decorate([
|
|
980
|
+
Transactional()
|
|
981
|
+
], AgentSkillsService.prototype, "shareIn", null);
|
|
982
|
+
__decorate([
|
|
983
|
+
Transactional()
|
|
984
|
+
], AgentSkillsService.prototype, "deleteAgentSkillIn", null);
|
|
985
|
+
AgentSkillsService = __decorate([
|
|
986
|
+
Injectable(),
|
|
987
|
+
__param(0, Inject(KernelDb)),
|
|
988
|
+
__param(1, Inject(StorageService)),
|
|
989
|
+
__param(2, Inject(EventLog)),
|
|
990
|
+
__param(3, Inject(KERNEL_LOGGER)),
|
|
991
|
+
__param(4, Inject(TransactionHost)),
|
|
992
|
+
__param(5, Inject(SkillsService)),
|
|
993
|
+
__param(6, Inject(AttachmentsService)),
|
|
994
|
+
__param(7, Inject(OrgLock))
|
|
995
|
+
], AgentSkillsService);
|
|
996
|
+
export { AgentSkillsService };
|