@capybara-hq/kernel 0.1.0-rc.3 → 0.1.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bootstrap.json +61 -5
- package/dist/admin/admin.controller.d.ts +47 -16
- package/dist/admin/admin.controller.js +44 -19
- package/dist/admin/extensions.controller.d.ts +24 -3
- package/dist/admin/extensions.controller.js +48 -8
- package/dist/admin/setup-lock.d.ts +1 -1
- package/dist/admin/setup-lock.js +1 -1
- package/dist/admin/setup.controller.d.ts +1 -1
- package/dist/admin/setup.controller.js +1 -1
- package/dist/admin/setup.service.d.ts +4 -4
- package/dist/admin/setup.service.js +8 -8
- package/dist/agents/agent-lookup.d.ts +19 -0
- package/dist/agents/agent-lookup.js +21 -0
- package/dist/agents/agent-profile.service.d.ts +29 -0
- package/dist/agents/agent-profile.service.js +117 -0
- package/dist/agents/agents.controller.d.ts +168 -3
- package/dist/agents/agents.controller.js +201 -12
- package/dist/agents/agents.module.d.ts +4 -1
- package/dist/agents/agents.module.js +36 -6
- package/dist/agents/agents.service.d.ts +64 -27
- package/dist/agents/agents.service.js +199 -74
- package/dist/agents/definition.d.ts +53 -0
- package/dist/agents/definition.js +55 -0
- package/dist/agents/from-template.d.ts +106 -0
- package/dist/agents/from-template.js +649 -0
- package/dist/agents/from-template.service.d.ts +60 -0
- package/dist/agents/from-template.service.js +161 -0
- package/dist/agents/instruction-files.d.ts +60 -0
- package/dist/agents/instruction-files.js +111 -0
- package/dist/agents/models.controller.d.ts +9 -3
- package/dist/agents/models.controller.js +19 -4
- package/dist/agents/org-templates.d.ts +176 -0
- package/dist/agents/org-templates.js +827 -0
- package/dist/agents/pending-connector-requests.d.ts +77 -0
- package/dist/agents/pending-connector-requests.js +215 -0
- package/dist/agents/pending-connectors.controller.d.ts +39 -0
- package/dist/agents/pending-connectors.controller.js +91 -0
- package/dist/agents/pending-connectors.service.d.ts +62 -0
- package/dist/agents/pending-connectors.service.js +282 -0
- package/dist/agents/profile.d.ts +96 -0
- package/dist/agents/profile.js +51 -0
- package/dist/agents/readiness.controller.d.ts +26 -0
- package/dist/agents/readiness.controller.js +56 -0
- package/dist/agents/templates.controller.d.ts +86 -5
- package/dist/agents/templates.controller.js +171 -7
- package/dist/agents/templates.d.ts +127 -23
- package/dist/agents/templates.js +476 -53
- package/dist/background/background.controller.d.ts +38 -0
- package/dist/background/background.controller.js +87 -0
- package/dist/background/background.module.d.ts +10 -0
- package/dist/background/background.module.js +39 -0
- package/dist/background/finish.d.ts +44 -0
- package/dist/background/finish.js +94 -0
- package/dist/background/launch-lock.d.ts +15 -0
- package/dist/background/launch-lock.js +40 -0
- package/dist/background/launch.d.ts +36 -0
- package/dist/background/launch.js +70 -0
- package/dist/background/poll.job.d.ts +56 -0
- package/dist/background/poll.job.js +190 -0
- package/dist/background/render.d.ts +23 -0
- package/dist/background/render.js +48 -0
- package/dist/background/session.d.ts +48 -0
- package/dist/background/session.js +79 -0
- package/dist/background/status.d.ts +35 -0
- package/dist/background/status.js +57 -0
- package/dist/background/stop.d.ts +68 -0
- package/dist/background/stop.js +243 -0
- package/dist/background/store.d.ts +162 -0
- package/dist/background/store.js +357 -0
- package/dist/background/store.module.d.ts +6 -0
- package/dist/background/store.module.js +22 -0
- package/dist/background/tasks.service.d.ts +77 -0
- package/dist/background/tasks.service.js +211 -0
- package/dist/background/wake-rules.d.ts +66 -0
- package/dist/background/wake-rules.js +113 -0
- package/dist/background/wake.d.ts +30 -0
- package/dist/background/wake.js +63 -0
- package/dist/catalog/admin-catalog.controller.d.ts +129 -30
- package/dist/catalog/admin-catalog.controller.js +213 -42
- package/dist/catalog/catalog-content.d.ts +58 -32
- package/dist/catalog/catalog-content.js +34 -8
- package/dist/catalog/catalog-import.module.d.ts +7 -0
- package/dist/catalog/catalog-import.module.js +60 -0
- package/dist/catalog/catalog-items.d.ts +111 -7
- package/dist/catalog/catalog-items.js +279 -13
- package/dist/catalog/catalog-scope.service.d.ts +260 -0
- package/dist/catalog/catalog-scope.service.js +1116 -0
- package/dist/catalog/catalog.module.d.ts +7 -9
- package/dist/catalog/catalog.module.js +41 -31
- package/dist/catalog/catalog.service.d.ts +101 -29
- package/dist/catalog/catalog.service.js +104 -106
- package/dist/catalog/claude/agents.js +2 -0
- package/dist/catalog/cli.d.ts +11 -1
- package/dist/catalog/cli.js +26 -1
- package/dist/catalog/component-promotion.d.ts +96 -0
- package/dist/catalog/component-promotion.js +395 -0
- package/dist/catalog/component-scope.controller.d.ts +152 -0
- package/dist/catalog/component-scope.controller.js +287 -0
- package/dist/catalog/component-scope.service.d.ts +303 -0
- package/dist/catalog/component-scope.service.js +936 -0
- package/dist/catalog/component-state.d.ts +174 -0
- package/dist/catalog/component-state.js +437 -0
- package/dist/catalog/job-ids.d.ts +30 -0
- package/dist/catalog/job-ids.js +25 -0
- package/dist/catalog/marketplace-fetch.d.ts +1 -1
- package/dist/catalog/marketplaces.controller.d.ts +22 -5
- package/dist/catalog/marketplaces.controller.js +56 -7
- package/dist/catalog/marketplaces.service.d.ts +54 -14
- package/dist/catalog/marketplaces.service.js +71 -22
- package/dist/catalog/org-catalog.controller.d.ts +125 -34
- package/dist/catalog/org-catalog.controller.js +181 -65
- package/dist/catalog/org-catalog.service.d.ts +65 -33
- package/dist/catalog/org-catalog.service.js +324 -157
- package/dist/catalog/org-extension-switch.d.ts +41 -0
- package/dist/catalog/org-extension-switch.js +115 -0
- package/dist/catalog/org-extension.controller.d.ts +119 -0
- package/dist/catalog/org-extension.controller.js +266 -0
- package/dist/catalog/org-plugin-uploads.controller.d.ts +98 -0
- package/dist/catalog/org-plugin-uploads.controller.js +213 -0
- package/dist/catalog/org-plugin-uploads.d.ts +63 -0
- package/dist/catalog/org-plugin-uploads.js +116 -0
- package/dist/catalog/owned-items.d.ts +184 -0
- package/dist/catalog/owned-items.js +789 -0
- package/dist/catalog/owned-plugin-cleanup.d.ts +56 -0
- package/dist/catalog/owned-plugin-cleanup.js +194 -0
- package/dist/catalog/ownership.d.ts +172 -0
- package/dist/catalog/ownership.js +326 -0
- package/dist/catalog/platform-components.d.ts +221 -0
- package/dist/catalog/platform-components.js +761 -0
- package/dist/catalog/platform-migration.d.ts +115 -0
- package/dist/catalog/platform-migration.js +582 -0
- package/dist/catalog/plugin-import.d.ts +178 -34
- package/dist/catalog/plugin-import.js +623 -83
- package/dist/catalog/plugin-install.d.ts +185 -41
- package/dist/catalog/plugin-install.js +758 -126
- package/dist/catalog/plugin-upgrade.d.ts +260 -225
- package/dist/catalog/plugin-upgrade.js +1148 -1137
- package/dist/catalog/request-rules.d.ts +65 -0
- package/dist/catalog/request-rules.js +217 -0
- package/dist/catalog/requests.service.d.ts +193 -118
- package/dist/catalog/requests.service.js +526 -343
- package/dist/catalog/reserved-names.d.ts +8 -0
- package/dist/catalog/reserved-names.js +42 -0
- package/dist/catalog/scope-orgs.d.ts +21 -0
- package/dist/catalog/scope-orgs.js +67 -0
- package/dist/catalog/scope-state.d.ts +35 -0
- package/dist/catalog/scope-state.js +87 -0
- package/dist/catalog/scope-sync-workers.d.ts +7 -0
- package/dist/catalog/scope-sync-workers.js +29 -0
- package/dist/catalog/scope-sync.d.ts +176 -0
- package/dist/catalog/scope-sync.js +576 -0
- package/dist/catalog/scope.d.ts +42 -0
- package/dist/catalog/scope.js +42 -0
- package/dist/catalog/unshare.d.ts +22 -0
- package/dist/catalog/unshare.js +118 -0
- package/dist/channels/actions.js +1 -0
- package/dist/channels/cards.js +21 -3
- package/dist/channels/channels.module.js +2 -0
- package/dist/channels/connections.service.d.ts +16 -1
- package/dist/channels/connections.service.js +38 -4
- package/dist/channels/inbound.d.ts +9 -1
- package/dist/channels/inbound.js +67 -5
- package/dist/channels/phrases.d.ts +35 -0
- package/dist/channels/phrases.js +29 -0
- package/dist/channels/threads.d.ts +5 -0
- package/dist/channels/threads.js +8 -0
- package/dist/config/docs.js +3 -1
- package/dist/config/schema.d.ts +24 -2
- package/dist/config/schema.js +145 -19
- package/dist/conversations/access.d.ts +6 -4
- package/dist/conversations/access.js +29 -5
- package/dist/conversations/agent-tree.d.ts +46 -0
- package/dist/conversations/agent-tree.js +92 -0
- package/dist/conversations/attachments.service.d.ts +30 -0
- package/dist/conversations/attachments.service.js +130 -5
- package/dist/conversations/conversations.controller.d.ts +79 -23
- package/dist/conversations/conversations.controller.js +141 -50
- package/dist/conversations/conversations.module.d.ts +1 -1
- package/dist/conversations/conversations.module.js +10 -7
- package/dist/conversations/conversations.service.d.ts +108 -9
- package/dist/conversations/conversations.service.js +237 -30
- package/dist/conversations/environment-status.d.ts +24 -0
- package/dist/conversations/environment-status.js +71 -0
- package/dist/conversations/event-log.d.ts +21 -6
- package/dist/conversations/event-log.js +70 -1
- package/dist/conversations/events.d.ts +140 -0
- package/dist/conversations/events.js +142 -13
- package/dist/conversations/queue.d.ts +3 -1
- package/dist/conversations/queue.js +13 -2
- package/dist/conversations/queue.service.d.ts +1 -1
- package/dist/conversations/queue.service.js +8 -1
- package/dist/conversations/titles.d.ts +12 -3
- package/dist/conversations/titles.js +36 -8
- package/dist/conversations/tree.d.ts +17 -0
- package/dist/conversations/tree.js +42 -0
- package/dist/ctx/create-ctx.d.ts +5 -0
- package/dist/ctx/create-ctx.js +15 -5
- package/dist/db/kernel-schema.d.ts +420 -20
- package/dist/db/pool.d.ts +5 -0
- package/dist/db/pool.js +3 -0
- package/dist/environments/access.d.ts +41 -0
- package/dist/environments/access.js +77 -0
- package/dist/environments/conversation-environments.d.ts +61 -0
- package/dist/environments/conversation-environments.js +170 -0
- package/dist/environments/dto.d.ts +25 -0
- package/dist/environments/dto.js +12 -0
- package/dist/environments/environments.controller.d.ts +33 -0
- package/dist/environments/environments.controller.js +110 -0
- package/dist/environments/environments.module.d.ts +8 -0
- package/dist/environments/environments.module.js +27 -0
- package/dist/environments/environments.service.d.ts +153 -0
- package/dist/environments/environments.service.js +541 -0
- package/dist/environments/legacy-cleanup.job.d.ts +34 -0
- package/dist/environments/legacy-cleanup.job.js +141 -0
- package/dist/errors.d.ts +90 -2
- package/dist/errors.js +90 -2
- package/dist/evals/reconstruct.d.ts +18 -9
- package/dist/evals/reconstruct.js +26 -7
- package/dist/evals/run-replay.d.ts +7 -2
- package/dist/evals/run-replay.js +42 -7
- package/dist/evals/step-replay.d.ts +2 -5
- package/dist/evals/step-replay.js +13 -7
- package/dist/evals/trajectory.js +1 -1
- package/dist/evals/trajectory.service.d.ts +8 -3
- package/dist/evals/trajectory.service.js +26 -14
- package/dist/evals/worker.d.ts +5 -5
- package/dist/evals/worker.js +9 -3
- package/dist/extensions/admin-ops.d.ts +36 -10
- package/dist/extensions/admin-ops.js +67 -42
- package/dist/extensions/admin-view.d.ts +39 -10
- package/dist/extensions/admin-view.js +111 -20
- package/dist/extensions/blobs.js +1 -0
- package/dist/extensions/bootstrap.d.ts +17 -4
- package/dist/extensions/bootstrap.js +70 -9
- package/dist/extensions/cli.d.ts +12 -0
- package/dist/extensions/cli.js +11 -2
- package/dist/extensions/config-issues.d.ts +13 -1
- package/dist/extensions/config-issues.js +22 -5
- package/dist/extensions/config-json-schema.d.ts +43 -7
- package/dist/extensions/config-json-schema.js +124 -58
- package/dist/extensions/deployment-config-store.d.ts +6 -0
- package/dist/extensions/deployment-config.d.ts +78 -8
- package/dist/extensions/deployment-config.js +172 -34
- package/dist/extensions/display-name.d.ts +22 -0
- package/dist/extensions/display-name.js +77 -0
- package/dist/extensions/effective-config.d.ts +127 -0
- package/dist/extensions/effective-config.js +368 -0
- package/dist/extensions/extensions.module.js +14 -2
- package/dist/extensions/hooks.d.ts +37 -4
- package/dist/extensions/hooks.js +82 -16
- package/dist/extensions/host.d.ts +45 -2
- package/dist/extensions/host.js +112 -16
- package/dist/extensions/installs.d.ts +20 -8
- package/dist/extensions/installs.js +37 -15
- package/dist/extensions/org-config.d.ts +81 -6
- package/dist/extensions/org-config.js +195 -44
- package/dist/extensions/org-levels.d.ts +37 -0
- package/dist/extensions/org-levels.js +71 -0
- package/dist/extensions/org-overrides.d.ts +151 -0
- package/dist/extensions/org-overrides.js +524 -0
- package/dist/extensions/package.d.ts +14 -1
- package/dist/extensions/package.js +51 -2
- package/dist/extensions/permission-view.d.ts +19 -4
- package/dist/extensions/permission-view.js +4 -4
- package/dist/extensions/plugin-items.d.ts +21 -0
- package/dist/extensions/plugin-items.js +42 -0
- package/dist/extensions/point-defaults.controller.d.ts +34 -0
- package/dist/extensions/point-defaults.controller.js +71 -0
- package/dist/extensions/point-defaults.d.ts +71 -0
- package/dist/extensions/point-defaults.js +234 -0
- package/dist/extensions/registry.d.ts +1 -1
- package/dist/extensions/registry.js +2 -0
- package/dist/extensions/resolve.d.ts +5 -1
- package/dist/extensions/resolve.js +15 -2
- package/dist/files/previewers.d.ts +8 -1
- package/dist/files/previewers.js +35 -6
- package/dist/http/api.module.js +31 -3
- package/dist/http/app.d.ts +11 -2
- package/dist/http/app.js +31 -5
- package/dist/http/nest-logger.d.ts +6 -5
- package/dist/http/nest-logger.js +24 -10
- package/dist/identity/accounts.d.ts +29 -29
- package/dist/identity/accounts.js +47 -47
- package/dist/identity/audit.d.ts +2 -1
- package/dist/identity/auth.controller.js +9 -5
- package/dist/identity/auth.guard.d.ts +13 -5
- package/dist/identity/auth.guard.js +26 -9
- package/dist/identity/cookies.d.ts +20 -5
- package/dist/identity/cookies.js +44 -6
- package/dist/identity/identity.module.d.ts +1 -1
- package/dist/identity/identity.module.js +4 -4
- package/dist/identity/me.controller.d.ts +5 -1
- package/dist/identity/me.controller.js +12 -3
- package/dist/identity/principal.d.ts +3 -3
- package/dist/identity/principal.js +3 -3
- package/dist/identity/sessions.d.ts +12 -0
- package/dist/identity/sessions.js +45 -0
- package/dist/identity/settings.d.ts +22 -11
- package/dist/identity/settings.js +53 -18
- package/dist/identity/{enterprise-admin.d.ts → super-admin.d.ts} +5 -5
- package/dist/identity/{enterprise-admin.js → super-admin.js} +24 -24
- package/dist/inbox/inbox.module.d.ts +4 -1
- package/dist/inbox/inbox.module.js +7 -3
- package/dist/inbox/inbox.service.d.ts +62 -3
- package/dist/inbox/inbox.service.js +74 -4
- package/dist/inbox/org-notices.d.ts +63 -0
- package/dist/inbox/org-notices.js +91 -0
- package/dist/inbox/platform-inbox.controller.d.ts +23 -0
- package/dist/inbox/platform-inbox.controller.js +58 -0
- package/dist/inbox/platform-inbox.service.d.ts +151 -0
- package/dist/inbox/platform-inbox.service.js +263 -0
- package/dist/inbox/platform-notices.d.ts +19 -0
- package/dist/inbox/platform-notices.js +9 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/infra/cli/kernel-cli.module.js +9 -1
- package/dist/infra/config/kernel-config.service.js +27 -1
- package/dist/infra/database/database.module.js +1 -0
- package/dist/infra/database/xact-lock.d.ts +1 -1
- package/dist/infra/database/xact-lock.js +1 -1
- package/dist/infra/events/kernel-events.d.ts +19 -2
- package/dist/infra/lifecycle/process-guards.js +4 -0
- package/dist/infra/logging/logging.module.d.ts +4 -2
- package/dist/infra/logging/logging.module.js +24 -6
- package/dist/infra/queue/add-job-once.d.ts +14 -0
- package/dist/infra/queue/add-job-once.js +16 -0
- package/dist/infra/queue/redis-connection.d.ts +6 -0
- package/dist/infra/queue/redis-connection.js +7 -0
- package/dist/infra/redis/redis.module.js +6 -2
- package/dist/infra/tokens.d.ts +6 -1
- package/dist/infra/tokens.js +6 -1
- package/dist/kernel.module.js +6 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +1 -1
- package/dist/lifecycle/kernel-lifecycle.js +4 -4
- package/dist/log.d.ts +13 -1
- package/dist/log.js +93 -17
- package/dist/models/prices.d.ts +5 -5
- package/dist/models/prices.js +4 -4
- package/dist/models/purposes.controller.d.ts +6 -4
- package/dist/models/purposes.controller.js +13 -7
- package/dist/models/purposes.d.ts +43 -9
- package/dist/models/purposes.js +48 -18
- package/dist/orgs/directory-sync.d.ts +14 -5
- package/dist/orgs/directory-sync.js +41 -17
- package/dist/orgs/offboarding.d.ts +12 -8
- package/dist/orgs/offboarding.js +54 -33
- package/dist/orgs/org-lock.d.ts +5 -0
- package/dist/orgs/org-lock.js +13 -0
- package/dist/orgs/org.guard.d.ts +10 -0
- package/dist/orgs/org.guard.js +43 -32
- package/dist/orgs/orgs.module.js +3 -0
- package/dist/orgs/orgs.service.d.ts +20 -7
- package/dist/orgs/orgs.service.js +32 -12
- package/dist/orgs/roles.d.ts +1 -1
- package/dist/orgs/roles.js +5 -1
- package/dist/orgs/settings.controller.d.ts +1 -1
- package/dist/orgs/settings.service.d.ts +20 -3
- package/dist/orgs/settings.service.js +19 -4
- package/dist/overrides.d.ts +3 -0
- package/dist/overrides.js +2 -0
- package/dist/platform/actor.d.ts +48 -0
- package/dist/platform/actor.js +100 -0
- package/dist/platform/agent-docs.d.ts +18 -0
- package/dist/platform/agent-docs.js +59 -0
- package/dist/platform/availability.d.ts +14 -0
- package/dist/platform/availability.js +43 -0
- package/dist/platform/errors.d.ts +11 -0
- package/dist/platform/errors.js +26 -0
- package/dist/platform/exclusions.d.ts +12 -0
- package/dist/platform/exclusions.js +1387 -0
- package/dist/platform/method.d.ts +6 -0
- package/dist/platform/method.js +15 -0
- package/dist/platform/operation.d.ts +92 -0
- package/dist/platform/operation.js +35 -0
- package/dist/platform/ops/agent-templates.ops.d.ts +14 -0
- package/dist/platform/ops/agent-templates.ops.js +92 -0
- package/dist/platform/ops/agents.ops.d.ts +19 -0
- package/dist/platform/ops/agents.ops.js +294 -0
- package/dist/platform/ops/connectors.ops.d.ts +15 -0
- package/dist/platform/ops/connectors.ops.js +126 -0
- package/dist/platform/ops/errors.d.ts +11 -0
- package/dist/platform/ops/errors.js +22 -0
- package/dist/platform/ops/extensions.ops.d.ts +19 -0
- package/dist/platform/ops/extensions.ops.js +116 -0
- package/dist/platform/ops/marketplaces.ops.d.ts +16 -0
- package/dist/platform/ops/marketplaces.ops.js +157 -0
- package/dist/platform/ops/paging.d.ts +14 -0
- package/dist/platform/ops/paging.js +20 -0
- package/dist/platform/ops/platform.ops.d.ts +23 -0
- package/dist/platform/ops/platform.ops.js +158 -0
- package/dist/platform/ops/plugins.ops.d.ts +33 -0
- package/dist/platform/ops/plugins.ops.js +377 -0
- package/dist/platform/ops/requests.ops.d.ts +14 -0
- package/dist/platform/ops/requests.ops.js +153 -0
- package/dist/platform/ops/role.d.ts +4 -0
- package/dist/platform/ops/role.js +10 -0
- package/dist/platform/ops/skills.ops.d.ts +13 -0
- package/dist/platform/ops/skills.ops.js +98 -0
- package/dist/platform/ops/summary.d.ts +10 -0
- package/dist/platform/ops/summary.js +18 -0
- package/dist/platform/platform-ops.module.d.ts +7 -0
- package/dist/platform/platform-ops.module.js +55 -0
- package/dist/platform/platform.module.d.ts +8 -0
- package/dist/platform/platform.module.js +25 -0
- package/dist/platform/redact-orgs.d.ts +7 -0
- package/dist/platform/redact-orgs.js +52 -0
- package/dist/platform/registry.d.ts +30 -0
- package/dist/platform/registry.js +111 -0
- package/dist/roles/worker-role.d.ts +6 -4
- package/dist/roles/worker-role.js +14 -7
- package/dist/roles/worker.module.d.ts +1 -1
- package/dist/roles/worker.module.js +15 -1
- package/dist/runtime/context/build.d.ts +11 -7
- package/dist/runtime/context/build.js +46 -19
- package/dist/runtime/context/claude-tools.d.ts +3 -1
- package/dist/runtime/context/claude-tools.js +8 -6
- package/dist/runtime/context/compaction.js +13 -0
- package/dist/runtime/context/reminders.d.ts +2 -0
- package/dist/runtime/context/reminders.js +2 -0
- package/dist/runtime/context/skills.js +9 -2
- package/dist/runtime/context/tool-changes.d.ts +27 -0
- package/dist/runtime/context/tool-changes.js +60 -0
- package/dist/runtime/hook-calls.js +2 -0
- package/dist/runtime/langgraph-loop.d.ts +3 -1
- package/dist/runtime/langgraph-loop.js +36 -17
- package/dist/runtime/loop.d.ts +34 -5
- package/dist/runtime/maintenance.d.ts +9 -4
- package/dist/runtime/maintenance.js +35 -8
- package/dist/runtime/model-call.d.ts +46 -8
- package/dist/runtime/model-call.js +72 -21
- package/dist/runtime/providers.d.ts +6 -0
- package/dist/runtime/providers.js +8 -0
- package/dist/runtime/run-control.d.ts +11 -1
- package/dist/runtime/run-control.js +12 -0
- package/dist/runtime/run-drafts.d.ts +85 -0
- package/dist/runtime/run-drafts.js +230 -0
- package/dist/runtime/run-jobs.d.ts +3 -5
- package/dist/runtime/run-jobs.js +3 -7
- package/dist/runtime/run-queue.d.ts +59 -2
- package/dist/runtime/run-queue.js +311 -38
- package/dist/runtime/run-worker.d.ts +11 -5
- package/dist/runtime/run-worker.js +69 -33
- package/dist/runtime/runtime.module.js +11 -3
- package/dist/runtime/step-log.d.ts +15 -4
- package/dist/runtime/step-log.js +24 -7
- package/dist/runtime/stream.controller.d.ts +23 -1
- package/dist/runtime/stream.controller.js +60 -3
- package/dist/runtime/stream.d.ts +4 -1
- package/dist/runtime/stream.js +27 -3
- package/dist/runtime/subagents/child.d.ts +55 -7
- package/dist/runtime/subagents/child.js +105 -7
- package/dist/runtime/subagents/definition.d.ts +12 -3
- package/dist/runtime/subagents/definition.js +44 -28
- package/dist/runtime/subagents/deliveries.d.ts +71 -0
- package/dist/runtime/subagents/deliveries.js +228 -0
- package/dist/runtime/subagents/dispatch.d.ts +115 -26
- package/dist/runtime/subagents/dispatch.js +212 -141
- package/dist/runtime/subagents/limits.d.ts +24 -5
- package/dist/runtime/subagents/limits.js +40 -6
- package/dist/runtime/subagents/messages.d.ts +95 -0
- package/dist/runtime/subagents/messages.js +328 -0
- package/dist/runtime/subagents/preamble.d.ts +4 -4
- package/dist/runtime/subagents/preamble.js +9 -7
- package/dist/runtime/subagents/progress.d.ts +8 -6
- package/dist/runtime/subagents/progress.js +11 -6
- package/dist/runtime/subagents/render.d.ts +30 -0
- package/dist/runtime/subagents/render.js +53 -0
- package/dist/runtime/subagents/roster.d.ts +24 -7
- package/dist/runtime/subagents/roster.js +47 -11
- package/dist/runtime/subagents/skill-fork.d.ts +3 -2
- package/dist/runtime/subagents/skill-fork.js +8 -4
- package/dist/runtime/subagents/status.d.ts +14 -0
- package/dist/runtime/subagents/status.js +23 -0
- package/dist/runtime/subagents/subagents.service.d.ts +7 -4
- package/dist/runtime/subagents/subagents.service.js +11 -6
- package/dist/runtime/usage-report.d.ts +2 -1
- package/dist/runtime/usage-report.js +19 -13
- package/dist/runtime/waits.d.ts +145 -36
- package/dist/runtime/waits.js +423 -109
- package/dist/sandbox/jobs.d.ts +40 -13
- package/dist/sandbox/jobs.js +57 -20
- package/dist/sandbox/leases.d.ts +37 -54
- package/dist/sandbox/leases.js +71 -115
- package/dist/sandbox/providers.d.ts +2 -2
- package/dist/sandbox/providers.js +1 -1
- package/dist/sandbox/sandbox.module.d.ts +3 -2
- package/dist/sandbox/sandbox.module.js +10 -4
- package/dist/sandbox/sandbox.service.d.ts +282 -129
- package/dist/sandbox/sandbox.service.js +736 -381
- package/dist/skills/catalog.d.ts +3 -2
- package/dist/skills/catalog.js +21 -43
- package/dist/skills/changes.controller.d.ts +7 -0
- package/dist/skills/changes.controller.js +19 -1
- package/dist/skills/invoke.js +8 -3
- package/dist/skills/package.d.ts +20 -1
- package/dist/skills/package.js +28 -1
- package/dist/skills/skills.controller.d.ts +39 -4
- package/dist/skills/skills.controller.js +88 -10
- package/dist/skills/skills.module.js +10 -1
- package/dist/skills/skills.service.d.ts +106 -26
- package/dist/skills/skills.service.js +421 -75
- package/dist/skills/usable.d.ts +81 -0
- package/dist/skills/usable.js +379 -0
- package/dist/tools/approvals.service.d.ts +20 -2
- package/dist/tools/approvals.service.js +25 -4
- package/dist/tools/builtin-names.d.ts +41 -7
- package/dist/tools/builtin-names.js +59 -7
- package/dist/tools/builtins/agent.d.ts +23 -21
- package/dist/tools/builtins/agent.js +62 -55
- package/dist/tools/builtins/builtin-tools.d.ts +19 -1
- package/dist/tools/builtins/builtin-tools.js +59 -2
- package/dist/tools/builtins/handback.d.ts +28 -0
- package/dist/tools/builtins/handback.js +53 -0
- package/dist/tools/builtins/platform.d.ts +34 -0
- package/dist/tools/builtins/platform.js +362 -0
- package/dist/tools/builtins/sandbox/bash.d.ts +1 -1
- package/dist/tools/builtins/sandbox/bash.js +241 -4
- package/dist/tools/builtins/sandbox/common.d.ts +69 -27
- package/dist/tools/builtins/sandbox/common.js +87 -48
- package/dist/tools/builtins/sandbox/deliver.js +1 -1
- package/dist/tools/builtins/sandbox/edit.js +2 -2
- package/dist/tools/builtins/sandbox/glob.js +2 -2
- package/dist/tools/builtins/sandbox/grep.js +2 -4
- package/dist/tools/builtins/sandbox/index.d.ts +3 -1
- package/dist/tools/builtins/sandbox/index.js +7 -1
- package/dist/tools/builtins/sandbox/read.js +1 -1
- package/dist/tools/builtins/sandbox/task-output.d.ts +74 -0
- package/dist/tools/builtins/sandbox/task-output.js +329 -0
- package/dist/tools/builtins/sandbox/task-stop.d.ts +10 -0
- package/dist/tools/builtins/sandbox/task-stop.js +113 -0
- package/dist/tools/builtins/sandbox/write.js +2 -2
- package/dist/tools/builtins/send-message.d.ts +56 -0
- package/dist/tools/builtins/send-message.js +100 -0
- package/dist/tools/builtins/skill-load.d.ts +22 -14
- package/dist/tools/builtins/skill-load.js +86 -57
- package/dist/tools/builtins/skill-write.js +1 -1
- package/dist/tools/builtins/web/errors.d.ts +8 -0
- package/dist/tools/builtins/web/errors.js +53 -0
- package/dist/tools/builtins/web/extract.d.ts +62 -0
- package/dist/tools/builtins/web/extract.js +271 -0
- package/dist/tools/builtins/web/fetch.d.ts +55 -0
- package/dist/tools/builtins/web/fetch.js +175 -0
- package/dist/tools/builtins/web/index.d.ts +13 -0
- package/dist/tools/builtins/web/index.js +12 -0
- package/dist/tools/builtins/web/page-cache.d.ts +25 -0
- package/dist/tools/builtins/web/page-cache.js +77 -0
- package/dist/tools/builtins/web/search.d.ts +25 -0
- package/dist/tools/builtins/web/search.js +210 -0
- package/dist/tools/builtins/web/url.d.ts +17 -0
- package/dist/tools/builtins/web/url.js +43 -0
- package/dist/tools/connectors.controller.d.ts +10 -0
- package/dist/tools/connectors.controller.js +12 -0
- package/dist/tools/connectors.service.d.ts +46 -5
- package/dist/tools/connectors.service.js +94 -15
- package/dist/tools/extension-tools.controller.d.ts +14 -0
- package/dist/tools/extension-tools.controller.js +37 -0
- package/dist/tools/info.d.ts +42 -1
- package/dist/tools/info.js +64 -1
- package/dist/tools/oauth/flow-paths.d.ts +1 -1
- package/dist/tools/oauth/flow-paths.js +1 -1
- package/dist/tools/org-tool-switches.d.ts +74 -0
- package/dist/tools/org-tool-switches.js +184 -0
- package/dist/tools/pipeline.d.ts +46 -40
- package/dist/tools/pipeline.js +202 -364
- package/dist/tools/policy.d.ts +1 -1
- package/dist/tools/policy.js +36 -16
- package/dist/tools/registry.d.ts +120 -8
- package/dist/tools/registry.js +112 -19
- package/dist/tools/tools.module.js +24 -2
- package/dist/tools/validate.js +1 -1
- package/dist/ui/views.d.ts +2 -1
- package/dist/ui/views.js +17 -3
- package/package.json +3 -3
- package/src/migrations/0064_account_last_org.sql +7 -0
- package/src/migrations/0065_conversation_archive.sql +8 -0
- package/src/migrations/0066_extension_display_name.sql +4 -0
- package/src/migrations/0067_agent_profiles.sql +20 -0
- package/src/migrations/0068_agent_avatar_uploads.sql +7 -0
- package/src/migrations/0069_attachments_agent_idx.sql +3 -0
- package/src/migrations/0070_background_tasks.sql +37 -0
- package/src/migrations/0071_background_tasks_reserve.sql +6 -0
- package/src/migrations/0072_background_tasks_stopping.sql +5 -0
- package/src/migrations/0073_org_extension_point_defaults.sql +11 -0
- package/src/migrations/0074_subagent_tree.sql +50 -0
- package/src/migrations/0075_plugin_scope.sql +61 -0
- package/src/migrations/0076_skills_created_by_nullable.sql +6 -0
- package/src/migrations/0077_scope_requests.sql +52 -0
- package/src/migrations/0078_scope_grant_switches.sql +18 -0
- package/src/migrations/0079_scope_live_install_switches.sql +19 -0
- package/src/migrations/0080_rename_enterprise_admin.sql +18 -0
- package/src/migrations/0081_platform_components.sql +129 -0
- package/src/migrations/0082_platform_migration.sql +33 -0
- package/src/migrations/0083_plugin_scope_sync_failures.sql +15 -0
- package/src/migrations/0084_org_owned_items.sql +85 -0
- package/src/migrations/0085_agent_templates_phase4.sql +45 -0
- package/src/migrations/0086_org_layering.sql +30 -0
- package/src/migrations/0087_approval_summary.sql +6 -0
- package/src/migrations/0088_environments.sql +80 -0
- package/dist/catalog/upgrade-targets.d.ts +0 -56
- package/dist/catalog/upgrade-targets.js +0 -90
- package/dist/conversations/sandbox-status.d.ts +0 -24
- package/dist/conversations/sandbox-status.js +0 -52
- package/dist/extensions/org-config.controller.d.ts +0 -24
- package/dist/extensions/org-config.controller.js +0 -62
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ExtensionHost } from "../extensions/host.js";
|
|
2
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
3
|
+
import type { KernelLogger } from "../log.js";
|
|
4
|
+
import { ModelPurposesService } from "../models/purposes.js";
|
|
5
|
+
import { ProviderRegistry } from "../runtime/providers.js";
|
|
6
|
+
import { AgentsService, type AgentView, type AgentVisibility } from "./agents.service.js";
|
|
7
|
+
import type { ModelRef } from "./definition.js";
|
|
8
|
+
import { type ModelSource, type PlanItem } from "./from-template.js";
|
|
9
|
+
import { PendingConnectorRequests } from "./pending-connector-requests.js";
|
|
10
|
+
import type { ProfileInput } from "./profile.js";
|
|
11
|
+
/** The preview of creating an agent from a template (`POST …/agents/from-template/preview`). */
|
|
12
|
+
export interface TemplatePreview {
|
|
13
|
+
items: PlanItem[];
|
|
14
|
+
/** The automatic choice the dialog preselects (P4-4); null when the org has no usable model. */
|
|
15
|
+
model: (ModelRef & {
|
|
16
|
+
source: ModelSource;
|
|
17
|
+
}) | null;
|
|
18
|
+
dropped: string[];
|
|
19
|
+
previewHash: string;
|
|
20
|
+
}
|
|
21
|
+
export interface CreateFromTemplateRequest {
|
|
22
|
+
templateId: string;
|
|
23
|
+
name: string;
|
|
24
|
+
visibility?: AgentVisibility;
|
|
25
|
+
members?: string[];
|
|
26
|
+
model?: ModelRef;
|
|
27
|
+
avatar?: ProfileInput["avatar"];
|
|
28
|
+
previewHash: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Creating agents from templates (rulings P4-3…P4-8): the preview and the create both resolve the
|
|
32
|
+
* template with {@link planFromTemplate}; the create refuses a plan whose hash differs from the
|
|
33
|
+
* preview's (409 `agent.template_preview_stale`: the base part, and the automatic model's part when
|
|
34
|
+
* no model is chosen), writes the agent through
|
|
35
|
+
* {@link AgentsService.createFromTemplate}, and after the commit opens the pending connector request
|
|
36
|
+
* when the creator cannot configure connectors.
|
|
37
|
+
*/
|
|
38
|
+
export declare class AgentsFromTemplate {
|
|
39
|
+
private readonly db;
|
|
40
|
+
private readonly agents;
|
|
41
|
+
/** Extension tools loaded here and the org's enabled extensions. */
|
|
42
|
+
private readonly host;
|
|
43
|
+
private readonly providers;
|
|
44
|
+
/** The tier's purpose mapping (`subagent_<tier>`, P4-4). */
|
|
45
|
+
private readonly purposes;
|
|
46
|
+
private readonly requests;
|
|
47
|
+
private readonly log;
|
|
48
|
+
constructor(db: KernelDb, agents: AgentsService,
|
|
49
|
+
/** Extension tools loaded here and the org's enabled extensions. */
|
|
50
|
+
host: Pick<ExtensionHost, "tools" | "enabledPlugins">, providers: Pick<ProviderRegistry, "resolve" | "list">,
|
|
51
|
+
/** The tier's purpose mapping (`subagent_<tier>`, P4-4). */
|
|
52
|
+
purposes: Pick<ModelPurposesService, "resolve">, requests: PendingConnectorRequests, log: Pick<KernelLogger, "warn">);
|
|
53
|
+
/** The template, when usable in the org (P4-3); otherwise 404 `component.not_found`. */
|
|
54
|
+
private template;
|
|
55
|
+
private plan;
|
|
56
|
+
preview(orgId: string, templateId: string): Promise<TemplatePreview>;
|
|
57
|
+
create(orgId: string, actorAccountId: string, req: CreateFromTemplateRequest, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<{
|
|
58
|
+
agent: AgentView;
|
|
59
|
+
}>;
|
|
60
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
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 { Inject, Injectable } from "@nestjs/common";
|
|
11
|
+
import { ApiError } from "../errors.js";
|
|
12
|
+
import { ExtensionHost } from "../extensions/host.js";
|
|
13
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
14
|
+
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
15
|
+
import { ModelPurposesService } from "../models/purposes.js";
|
|
16
|
+
import { can } from "../orgs/roles.js";
|
|
17
|
+
import { ProviderRegistry } from "../runtime/providers.js";
|
|
18
|
+
import { AgentsService } from "./agents.service.js";
|
|
19
|
+
import { planFromTemplate, } from "./from-template.js";
|
|
20
|
+
import { PendingConnectorRequests } from "./pending-connector-requests.js";
|
|
21
|
+
import { loadTemplates } from "./templates.js";
|
|
22
|
+
/**
|
|
23
|
+
* Creating agents from templates (rulings P4-3…P4-8): the preview and the create both resolve the
|
|
24
|
+
* template with {@link planFromTemplate}; the create refuses a plan whose hash differs from the
|
|
25
|
+
* preview's (409 `agent.template_preview_stale`: the base part, and the automatic model's part when
|
|
26
|
+
* no model is chosen), writes the agent through
|
|
27
|
+
* {@link AgentsService.createFromTemplate}, and after the commit opens the pending connector request
|
|
28
|
+
* when the creator cannot configure connectors.
|
|
29
|
+
*/
|
|
30
|
+
let AgentsFromTemplate = class AgentsFromTemplate {
|
|
31
|
+
db;
|
|
32
|
+
agents;
|
|
33
|
+
host;
|
|
34
|
+
providers;
|
|
35
|
+
purposes;
|
|
36
|
+
requests;
|
|
37
|
+
log;
|
|
38
|
+
constructor(db, agents,
|
|
39
|
+
/** Extension tools loaded here and the org's enabled extensions. */
|
|
40
|
+
host, providers,
|
|
41
|
+
/** The tier's purpose mapping (`subagent_<tier>`, P4-4). */
|
|
42
|
+
purposes, requests, log) {
|
|
43
|
+
this.db = db;
|
|
44
|
+
this.agents = agents;
|
|
45
|
+
this.host = host;
|
|
46
|
+
this.providers = providers;
|
|
47
|
+
this.purposes = purposes;
|
|
48
|
+
this.requests = requests;
|
|
49
|
+
this.log = log;
|
|
50
|
+
}
|
|
51
|
+
/** The template, when usable in the org (P4-3); otherwise 404 `component.not_found`. */
|
|
52
|
+
async template(orgId, templateId) {
|
|
53
|
+
const row = (await loadTemplates(this.db.db, orgId, [templateId])).get(templateId);
|
|
54
|
+
if (!row) {
|
|
55
|
+
throw new ApiError("component.not_found", "The agent template does not exist or is not available in this organization");
|
|
56
|
+
}
|
|
57
|
+
return row;
|
|
58
|
+
}
|
|
59
|
+
async plan(orgId, row, model) {
|
|
60
|
+
const opts = {
|
|
61
|
+
pluginTools: this.host.tools().map((t) => ({ plugin: t.plugin, name: t.spec.name })),
|
|
62
|
+
enabledPlugins: await this.host.enabledPlugins(orgId),
|
|
63
|
+
resolveModel: async (ref) => {
|
|
64
|
+
try {
|
|
65
|
+
return (await this.providers.resolve(ref)).info.parameters;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
purpose: async (purpose) => {
|
|
72
|
+
try {
|
|
73
|
+
return await this.purposes.resolve(orgId, purpose);
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
if (e instanceof ApiError)
|
|
77
|
+
return null;
|
|
78
|
+
throw e;
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
defaultModel: async () => {
|
|
82
|
+
for (const p of await this.providers.list()) {
|
|
83
|
+
const m = p.models[0];
|
|
84
|
+
if (m)
|
|
85
|
+
return { provider: p.provider, model: m.id };
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
},
|
|
89
|
+
...(model !== undefined && { model }),
|
|
90
|
+
};
|
|
91
|
+
return planFromTemplate(this.db.db, orgId, row, opts);
|
|
92
|
+
}
|
|
93
|
+
async preview(orgId, templateId) {
|
|
94
|
+
const plan = await this.plan(orgId, await this.template(orgId, templateId));
|
|
95
|
+
return {
|
|
96
|
+
items: plan.items,
|
|
97
|
+
model: plan.auto === null ? null : { ...plan.auto.ref, source: plan.auto.source },
|
|
98
|
+
dropped: plan.dropped,
|
|
99
|
+
previewHash: plan.hash,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
async create(orgId, actorAccountId, req, actorTokenId, auditDetail) {
|
|
103
|
+
const row = await this.template(orgId, req.templateId);
|
|
104
|
+
const plan = await this.plan(orgId, row, req.model);
|
|
105
|
+
// the base part always; the automatic model's part only when the person chose none, so a
|
|
106
|
+
// silently changed choice is stale while an explicit one never is
|
|
107
|
+
const [base, auto] = req.previewHash.split(".");
|
|
108
|
+
if (base !== plan.baseHash || (req.model === undefined && auto !== plan.modelHash)) {
|
|
109
|
+
throw new ApiError("agent.template_preview_stale", "The template or the organization changed since the preview; preview it again");
|
|
110
|
+
}
|
|
111
|
+
if (plan.model === null) {
|
|
112
|
+
throw new ApiError("agent.model_unavailable", "No model is available for the new agent");
|
|
113
|
+
}
|
|
114
|
+
const { agent, role } = await this.agents.createFromTemplate(orgId, actorAccountId, {
|
|
115
|
+
definition: {
|
|
116
|
+
...plan.definition,
|
|
117
|
+
name: req.name,
|
|
118
|
+
model: plan.model.ref,
|
|
119
|
+
modelParams: plan.model.params,
|
|
120
|
+
},
|
|
121
|
+
visibility: req.visibility ?? "private",
|
|
122
|
+
...(req.members !== undefined && { memberIds: req.members }),
|
|
123
|
+
profile: {
|
|
124
|
+
description: plan.profile.description,
|
|
125
|
+
quickActions: plan.profile.quickActions,
|
|
126
|
+
...(req.avatar != null && { avatar: req.avatar }),
|
|
127
|
+
},
|
|
128
|
+
}, { id: req.templateId, version: row.version, name: row.name }, actorTokenId, auditDetail);
|
|
129
|
+
const keys = (agent.definition.pendingConnectors ?? []).map((c) => c.key);
|
|
130
|
+
if (keys.length > 0 && !can(role, "connectors.manage")) {
|
|
131
|
+
try {
|
|
132
|
+
await this.requests.openFor({
|
|
133
|
+
orgId,
|
|
134
|
+
agentId: agent.id,
|
|
135
|
+
ownerAccountId: agent.ownerAccountId,
|
|
136
|
+
keys,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
catch (err) {
|
|
140
|
+
// the agent stands; its 待配置 notice offers the request again (ruling P4-7)
|
|
141
|
+
this.log.warn("cannot open the pending connector request of a new agent", {
|
|
142
|
+
orgId,
|
|
143
|
+
agentId: agent.id,
|
|
144
|
+
err,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return { agent };
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
AgentsFromTemplate = __decorate([
|
|
152
|
+
Injectable(),
|
|
153
|
+
__param(0, Inject(KernelDb)),
|
|
154
|
+
__param(1, Inject(AgentsService)),
|
|
155
|
+
__param(2, Inject(ExtensionHost)),
|
|
156
|
+
__param(3, Inject(ProviderRegistry)),
|
|
157
|
+
__param(4, Inject(ModelPurposesService)),
|
|
158
|
+
__param(5, Inject(PendingConnectorRequests)),
|
|
159
|
+
__param(6, Inject(KERNEL_LOGGER))
|
|
160
|
+
], AgentsFromTemplate);
|
|
161
|
+
export { AgentsFromTemplate };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { AgentDefinition } from "./definition.js";
|
|
3
|
+
/**
|
|
4
|
+
* Prompt files (spec 2026-11-04 §3.3): the authoring form of an agent's system prompt. The kernel
|
|
5
|
+
* joins them into `instructions` on save, and `instructions` stays the one model-visible field
|
|
6
|
+
* (build.ts, the sub-agent copy, eval candidates and replay keep reading it), so no log event
|
|
7
|
+
* changes shape and replay needs no new `DriftReason`.
|
|
8
|
+
*/
|
|
9
|
+
export type InstructionFile = {
|
|
10
|
+
name: string;
|
|
11
|
+
content: string;
|
|
12
|
+
};
|
|
13
|
+
/** The default and first file. */
|
|
14
|
+
export declare const AGENTS_MD = "AGENTS.md";
|
|
15
|
+
export declare const INSTRUCTION_FILE_LIMITS: {
|
|
16
|
+
/** At most this many files, at least one. */
|
|
17
|
+
readonly count: 20;
|
|
18
|
+
/** The joined text, the same bound as `instructions`. */
|
|
19
|
+
readonly joinedChars: 100000;
|
|
20
|
+
};
|
|
21
|
+
/** A file name: 1–64 characters without `/` or `\`, then `.md`. */
|
|
22
|
+
export declare const INSTRUCTION_FILE_NAME_RE: RegExp;
|
|
23
|
+
/**
|
|
24
|
+
* The starter prompt of a new agent created without one (model-visible once saved; English like
|
|
25
|
+
* every model-facing text).
|
|
26
|
+
*/
|
|
27
|
+
export declare const AGENTS_MD_STARTER: string;
|
|
28
|
+
/**
|
|
29
|
+
* The model-visible join: one file gives exactly its content (so an old agent edited without
|
|
30
|
+
* adding files sends the same text as before); several files give `# <name>\n\n<content>` each,
|
|
31
|
+
* in order, joined by `\n\n`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function joinInstructionFiles(files: readonly InstructionFile[]): string;
|
|
34
|
+
/** The files of a definition; a definition without them (every old version) is one `AGENTS.md`. */
|
|
35
|
+
export declare function readInstructionFiles(def: Pick<AgentDefinition, "instructions" | "instructionFiles">): InstructionFile[];
|
|
36
|
+
export declare const InstructionFileSchema: z.ZodObject<{
|
|
37
|
+
name: z.ZodString;
|
|
38
|
+
content: z.ZodString;
|
|
39
|
+
}, z.core.$strict>;
|
|
40
|
+
/**
|
|
41
|
+
* 1–20 files, names unique ignoring case (`AGENTS.md` and `agents.md` would collide on a
|
|
42
|
+
* case-insensitive file system), a joined total of at most 100 000 characters.
|
|
43
|
+
*/
|
|
44
|
+
export declare const InstructionFilesSchema: z.ZodArray<z.ZodObject<{
|
|
45
|
+
name: z.ZodString;
|
|
46
|
+
content: z.ZodString;
|
|
47
|
+
}, z.core.$strict>>;
|
|
48
|
+
/** A definition as a save request gives it: `instructions` may be left out. */
|
|
49
|
+
export type AgentDefinitionInput = Omit<AgentDefinition, "instructions"> & {
|
|
50
|
+
instructions?: string | undefined;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Derives the stored definition of a save. With `instructionFiles`, `instructions` is their join
|
|
54
|
+
* (a differing `instructions` given with them → 400 `agent.instructions_mismatch`). With only
|
|
55
|
+
* `instructions` (old clients) the current files are kept while it equals their join, else the
|
|
56
|
+
* definition is stored as given, without files. Given neither,
|
|
57
|
+
* an update keeps the `current` version's prompt, and a new agent (`current` null) gets the
|
|
58
|
+
* `AGENTS.md` starter.
|
|
59
|
+
*/
|
|
60
|
+
export declare function deriveInstructions(def: AgentDefinitionInput, current: Pick<AgentDefinition, "instructions" | "instructionFiles"> | null): AgentDefinition;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ApiError } from "../errors.js";
|
|
3
|
+
import { CONTROL_OR_HIDDEN_RE } from "../text.js";
|
|
4
|
+
/** The default and first file. */
|
|
5
|
+
export const AGENTS_MD = "AGENTS.md";
|
|
6
|
+
export const INSTRUCTION_FILE_LIMITS = {
|
|
7
|
+
/** At most this many files, at least one. */
|
|
8
|
+
count: 20,
|
|
9
|
+
/** The joined text, the same bound as `instructions`. */
|
|
10
|
+
joinedChars: 100_000,
|
|
11
|
+
};
|
|
12
|
+
/** A file name: 1–64 characters without `/` or `\`, then `.md`. */
|
|
13
|
+
export const INSTRUCTION_FILE_NAME_RE = /^[^/\\]{1,64}\.md$/;
|
|
14
|
+
/**
|
|
15
|
+
* The starter prompt of a new agent created without one (model-visible once saved; English like
|
|
16
|
+
* every model-facing text).
|
|
17
|
+
*/
|
|
18
|
+
export const AGENTS_MD_STARTER = [
|
|
19
|
+
"You are an assistant for this team. Help people get their work done accurately and efficiently.",
|
|
20
|
+
"",
|
|
21
|
+
"- Tone: clear, friendly and concise. Use plain language, keep answers short, and add detail when asked.",
|
|
22
|
+
"- When a request is unclear or missing key details, ask one short clarifying question before acting.",
|
|
23
|
+
" If you go ahead anyway, say what you assumed.",
|
|
24
|
+
"- If you don't know something or can't do it, say so instead of guessing.",
|
|
25
|
+
].join("\n");
|
|
26
|
+
/**
|
|
27
|
+
* The model-visible join: one file gives exactly its content (so an old agent edited without
|
|
28
|
+
* adding files sends the same text as before); several files give `# <name>\n\n<content>` each,
|
|
29
|
+
* in order, joined by `\n\n`.
|
|
30
|
+
*/
|
|
31
|
+
export function joinInstructionFiles(files) {
|
|
32
|
+
if (files.length === 1)
|
|
33
|
+
return files[0]?.content ?? "";
|
|
34
|
+
return files.map((f) => `# ${f.name}\n\n${f.content}`).join("\n\n");
|
|
35
|
+
}
|
|
36
|
+
/** The files of a definition; a definition without them (every old version) is one `AGENTS.md`. */
|
|
37
|
+
export function readInstructionFiles(def) {
|
|
38
|
+
return def.instructionFiles ?? [{ name: AGENTS_MD, content: def.instructions }];
|
|
39
|
+
}
|
|
40
|
+
export const InstructionFileSchema = z
|
|
41
|
+
.object({
|
|
42
|
+
name: z
|
|
43
|
+
.string()
|
|
44
|
+
.regex(INSTRUCTION_FILE_NAME_RE, "a file name is 1–64 characters without / or \\, then .md")
|
|
45
|
+
.refine((n) => !CONTROL_OR_HIDDEN_RE.test(n), "a file name must not contain control or format characters"),
|
|
46
|
+
content: z.string().max(INSTRUCTION_FILE_LIMITS.joinedChars),
|
|
47
|
+
})
|
|
48
|
+
.strict();
|
|
49
|
+
/**
|
|
50
|
+
* 1–20 files, names unique ignoring case (`AGENTS.md` and `agents.md` would collide on a
|
|
51
|
+
* case-insensitive file system), a joined total of at most 100 000 characters.
|
|
52
|
+
*/
|
|
53
|
+
export const InstructionFilesSchema = z
|
|
54
|
+
.array(InstructionFileSchema)
|
|
55
|
+
.min(1)
|
|
56
|
+
.max(INSTRUCTION_FILE_LIMITS.count)
|
|
57
|
+
.superRefine((files, ctx) => {
|
|
58
|
+
const seen = new Set();
|
|
59
|
+
files.forEach((f, i) => {
|
|
60
|
+
const key = f.name.toLowerCase();
|
|
61
|
+
if (seen.has(key)) {
|
|
62
|
+
ctx.addIssue({ code: "custom", path: [i, "name"], message: `duplicate file ${f.name}` });
|
|
63
|
+
}
|
|
64
|
+
seen.add(key);
|
|
65
|
+
});
|
|
66
|
+
const joined = joinInstructionFiles(files).length;
|
|
67
|
+
if (joined > INSTRUCTION_FILE_LIMITS.joinedChars) {
|
|
68
|
+
ctx.addIssue({
|
|
69
|
+
code: "custom",
|
|
70
|
+
message: `the joined files are ${joined} characters, more than ${INSTRUCTION_FILE_LIMITS.joinedChars}`,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
/**
|
|
75
|
+
* Derives the stored definition of a save. With `instructionFiles`, `instructions` is their join
|
|
76
|
+
* (a differing `instructions` given with them → 400 `agent.instructions_mismatch`). With only
|
|
77
|
+
* `instructions` (old clients) the current files are kept while it equals their join, else the
|
|
78
|
+
* definition is stored as given, without files. Given neither,
|
|
79
|
+
* an update keeps the `current` version's prompt, and a new agent (`current` null) gets the
|
|
80
|
+
* `AGENTS.md` starter.
|
|
81
|
+
*/
|
|
82
|
+
export function deriveInstructions(def, current) {
|
|
83
|
+
const { instructions, instructionFiles, ...rest } = def;
|
|
84
|
+
if (instructionFiles !== undefined) {
|
|
85
|
+
const joined = joinInstructionFiles(instructionFiles);
|
|
86
|
+
if (instructions !== undefined && instructions !== joined) {
|
|
87
|
+
throw new ApiError("agent.instructions_mismatch", "instructions differs from the join of instructionFiles; send only instructionFiles");
|
|
88
|
+
}
|
|
89
|
+
return { ...rest, instructions: joined, instructionFiles };
|
|
90
|
+
}
|
|
91
|
+
if (instructions !== undefined) {
|
|
92
|
+
// an old client re-sending the same joined text (an unrelated edit) keeps the files
|
|
93
|
+
const files = current?.instructionFiles;
|
|
94
|
+
if (files !== undefined && instructions === joinInstructionFiles(files)) {
|
|
95
|
+
return { ...rest, instructions, instructionFiles: files };
|
|
96
|
+
}
|
|
97
|
+
return { ...rest, instructions };
|
|
98
|
+
}
|
|
99
|
+
if (current !== null) {
|
|
100
|
+
return {
|
|
101
|
+
...rest,
|
|
102
|
+
instructions: current.instructions,
|
|
103
|
+
...(current.instructionFiles !== undefined && { instructionFiles: current.instructionFiles }),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
...rest,
|
|
108
|
+
instructions: AGENTS_MD_STARTER,
|
|
109
|
+
instructionFiles: [{ name: AGENTS_MD, content: AGENTS_MD_STARTER }],
|
|
110
|
+
};
|
|
111
|
+
}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import type { ModelInfo } from "@capybara-hq/plugin-sdk";
|
|
1
|
+
import type { LocalizedName, ModelInfo } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { ExtensionDisplayNames } from "../extensions/display-name.js";
|
|
2
3
|
import { ProviderRegistry } from "../runtime/providers.js";
|
|
3
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* 可选模型(`/api/v1/orgs/:orgId/models`):已安装的模型供应商及其模型,列表缓存在 Redis。Each provider
|
|
6
|
+
* carries its extension's display name (null when it has none).
|
|
7
|
+
*/
|
|
4
8
|
export declare class ModelsController {
|
|
5
9
|
private readonly registry;
|
|
6
|
-
|
|
10
|
+
private readonly displayNames;
|
|
11
|
+
constructor(registry: ProviderRegistry, displayNames: ExtensionDisplayNames);
|
|
7
12
|
list(): Promise<{
|
|
8
13
|
providers: {
|
|
9
14
|
provider: string;
|
|
15
|
+
displayName: LocalizedName | null;
|
|
10
16
|
models: ModelInfo[];
|
|
11
17
|
}[];
|
|
12
18
|
}>;
|
|
@@ -8,16 +8,30 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
10
|
import { Controller, Get, Inject } from "@nestjs/common";
|
|
11
|
+
import { ExtensionDisplayNames } from "../extensions/display-name.js";
|
|
11
12
|
import { OrgAction } from "../orgs/org.guard.js";
|
|
12
13
|
import { ProviderRegistry } from "../runtime/providers.js";
|
|
13
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* 可选模型(`/api/v1/orgs/:orgId/models`):已安装的模型供应商及其模型,列表缓存在 Redis。Each provider
|
|
16
|
+
* carries its extension's display name (null when it has none).
|
|
17
|
+
*/
|
|
14
18
|
let ModelsController = class ModelsController {
|
|
15
19
|
registry;
|
|
16
|
-
|
|
20
|
+
displayNames;
|
|
21
|
+
constructor(registry, displayNames) {
|
|
17
22
|
this.registry = registry;
|
|
23
|
+
this.displayNames = displayNames;
|
|
18
24
|
}
|
|
19
25
|
async list() {
|
|
20
|
-
|
|
26
|
+
const providers = await this.registry.list();
|
|
27
|
+
const names = await this.displayNames.many(providers.map((p) => p.provider));
|
|
28
|
+
return {
|
|
29
|
+
providers: providers.map((p) => ({
|
|
30
|
+
provider: p.provider,
|
|
31
|
+
displayName: names.get(p.provider) ?? null,
|
|
32
|
+
models: p.models,
|
|
33
|
+
})),
|
|
34
|
+
};
|
|
21
35
|
}
|
|
22
36
|
};
|
|
23
37
|
__decorate([
|
|
@@ -26,6 +40,7 @@ __decorate([
|
|
|
26
40
|
], ModelsController.prototype, "list", null);
|
|
27
41
|
ModelsController = __decorate([
|
|
28
42
|
Controller("api/v1/orgs/:orgId/models"),
|
|
29
|
-
__param(0, Inject(ProviderRegistry))
|
|
43
|
+
__param(0, Inject(ProviderRegistry)),
|
|
44
|
+
__param(1, Inject(ExtensionDisplayNames))
|
|
30
45
|
], ModelsController);
|
|
31
46
|
export { ModelsController };
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { type AgentTemplate } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { type Owner } from "../catalog/ownership.js";
|
|
3
|
+
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
4
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
5
|
+
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
6
|
+
import { OrgLock } from "../orgs/org-lock.js";
|
|
7
|
+
import { AgentLookup, type AgentView } from "./agent-lookup.js";
|
|
8
|
+
import { type AgentTemplateView } from "./templates.js";
|
|
9
|
+
/** A template with its definition, as `GET orgs/:orgId/agent-templates/:id` answers. */
|
|
10
|
+
export interface AgentTemplateDetail extends AgentTemplateView {
|
|
11
|
+
/** The current definition (the served version). */
|
|
12
|
+
definition: AgentTemplate;
|
|
13
|
+
/** Who owns it: the platform, or the org that created it (P3-14's shape). */
|
|
14
|
+
owner: Owner;
|
|
15
|
+
/**
|
|
16
|
+
* The org's own template (an org template, promoted or not; rulings P3-6, P4-12): its admins
|
|
17
|
+
* edit, delete and set 可共享 on it. Always false for a plugin's template.
|
|
18
|
+
*/
|
|
19
|
+
owned: boolean;
|
|
20
|
+
/** 可共享 (only meaningful when `owned`). */
|
|
21
|
+
shareable: boolean;
|
|
22
|
+
/** Shared already: the platform row it was promoted to on share (ruling P3-3). */
|
|
23
|
+
promoted: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* In the org's usable set (agents can be created from it here). False only when the owner reads
|
|
26
|
+
* its own template while it is not usable in its org (a promoted one switched off there).
|
|
27
|
+
*/
|
|
28
|
+
usable: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* What 另存为模板 left out (ruling P4-10), listed to the person: `kind` names the part of the
|
|
32
|
+
* agent, `name` the item (roster name, skill or connector name), `id` its id when it has one, and
|
|
33
|
+
* `reason`:
|
|
34
|
+
* - `org_agent`: an allowlisted org agent in the roster (an agent, not a template);
|
|
35
|
+
* - `unavailable`: a skill, sub-agent template or connector the org can no longer use;
|
|
36
|
+
* - `agent_skill`: one of the agent's own skills (not in the org library, so no other agent could
|
|
37
|
+
* resolve it);
|
|
38
|
+
* - `no_endpoint`: a hand-configured connector without a URL to record (an inline OpenAPI document);
|
|
39
|
+
* - `unsupported_protocol`: a hand-configured connector of a kind other than MCP or OpenAPI;
|
|
40
|
+
* - `limit`: past a template limit (connectors 16, sub-agent types and inline 16, tools 200, a
|
|
41
|
+
* connector entry's tools and policy keys 200 together: kind `tool_policy`, `name` the tool,
|
|
42
|
+
* `id` the connector);
|
|
43
|
+
* - `connector_tool`: a policy on a tool of a connector the template does not carry (kind
|
|
44
|
+
* `tool_policy`, `name` its key; carried connectors take their policies in `policies`), or a
|
|
45
|
+
* connector tool key in an inline sub-agent's allowlist (kind `subagent_inline`,
|
|
46
|
+
* `field: "tools"`, `name` the sub-agent): connector keys embed this org's connector slug;
|
|
47
|
+
* - `unsupported_field`: a field of an inline sub-agent a template's inline entry cannot hold
|
|
48
|
+
* (kind `subagent_inline`, `field`: `disallowedTools`, `toolPolicies`, `effort` or `maxSteps`);
|
|
49
|
+
* - `model_param`: a model parameter other than a valid `effort` (kind `model_param`, `name` its
|
|
50
|
+
* key): a template records only the effort (P4-10);
|
|
51
|
+
* - `fallback`: the fallback model and its parameters (kind `fallback_model`, `name`
|
|
52
|
+
* `provider/model`): a template has no fallback;
|
|
53
|
+
* - `empty_text`: whitespace-only text a template requires (kind `subagent_inline` with `field`
|
|
54
|
+
* `description` or `instructions`: the sub-agent is left out; kind `quick_action`, `name` its
|
|
55
|
+
* title: the quick action is left out).
|
|
56
|
+
* An inline sub-agent's skills that are the agent's own (`agent_skill`), gone (`unavailable`) or
|
|
57
|
+
* past the 3 a template holds (`limit`) are listed as kind `skill`.
|
|
58
|
+
*/
|
|
59
|
+
export interface SaveAsOmission {
|
|
60
|
+
kind: "subagent_agent" | "subagent_template" | "subagent_inline" | "skill" | "connector" | "tool" | "tool_policy" | "model_param" | "fallback_model" | "quick_action";
|
|
61
|
+
name: string;
|
|
62
|
+
id?: string;
|
|
63
|
+
/** The field of an inline sub-agent left out (`connector_tool`, `unsupported_field`). */
|
|
64
|
+
field?: string;
|
|
65
|
+
reason: "org_agent" | "unavailable" | "agent_skill" | "no_endpoint" | "unsupported_protocol" | "limit" | "connector_tool" | "unsupported_field" | "model_param" | "fallback" | "empty_text";
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Roster names no template may take (ruling T4-R15): `general-purpose`, always the roster's first
|
|
69
|
+
* entry. Claude Code's other built-in types (`Explore`, `Plan`) are capitalized, which the
|
|
70
|
+
* template name rule already refuses.
|
|
71
|
+
*/
|
|
72
|
+
export declare const RESERVED_TEMPLATE_NAMES: ReadonlySet<string>;
|
|
73
|
+
/**
|
|
74
|
+
* A connector's URL as a template may record it (ruling P4-11): userinfo, query and fragment
|
|
75
|
+
* removed (they may carry credentials). Null when it is no absolute http(s) URL.
|
|
76
|
+
*/
|
|
77
|
+
export declare function sanitizeEndpoint(raw: string): string | null;
|
|
78
|
+
/**
|
|
79
|
+
* Validates a template definition the way an `agents/<name>.md` file is (the SDK parser, so the
|
|
80
|
+
* two never drift): the definition minus `instructions` as the frontmatter (JSON is YAML), then
|
|
81
|
+
* the instructions as the body. Problems -> 400 `validation_failed` naming each.
|
|
82
|
+
*/
|
|
83
|
+
export declare function parseTemplateDefinition(definition: Record<string, unknown>): AgentTemplate;
|
|
84
|
+
/**
|
|
85
|
+
* Ruling P4-11 on an edit: a `connectors[].needs.endpoint` that carries userinfo, a query or a
|
|
86
|
+
* fragment, or is no http(s) URL of at most 2048 characters, is refused with 400
|
|
87
|
+
* `validation_failed` naming the field and what it carries (an edit is never stripped silently).
|
|
88
|
+
* One that differs only by normalization (a trailing slash, the host's case) is accepted:
|
|
89
|
+
* returns the template with each such endpoint in its canonical {@link sanitizeEndpoint} form.
|
|
90
|
+
*/
|
|
91
|
+
export declare function canonicalEndpoints(template: AgentTemplate): AgentTemplate;
|
|
92
|
+
/**
|
|
93
|
+
* The template an agent is saved as (rulings P4-10, P4-11), with what was left out. Pure reads of
|
|
94
|
+
* the org's state through `db`.
|
|
95
|
+
*/
|
|
96
|
+
export declare function templateFromAgent(db: KernelSchemaDb, orgId: string, agent: AgentView, meta: {
|
|
97
|
+
name: string;
|
|
98
|
+
description: string;
|
|
99
|
+
}): Promise<{
|
|
100
|
+
template: AgentTemplate;
|
|
101
|
+
omitted: SaveAsOmission[];
|
|
102
|
+
}>;
|
|
103
|
+
/**
|
|
104
|
+
* The org's agent templates beyond the plugin ones (rulings P4-9 to P4-12): 另存为模板, the detail
|
|
105
|
+
* of a usable template and the owner's new versions. Writes run under the org row lock, with
|
|
106
|
+
* `agents.manage` re-checked there.
|
|
107
|
+
*/
|
|
108
|
+
export declare class OrgAgentTemplates {
|
|
109
|
+
private readonly kdb;
|
|
110
|
+
private readonly orgLock;
|
|
111
|
+
private readonly agents;
|
|
112
|
+
readonly txHost: TransactionHost;
|
|
113
|
+
constructor(kdb: KernelDb, orgLock: Pick<OrgLock, "lockAndAuthorize">, agents: Pick<AgentLookup, "view">, txHost: TransactionHost);
|
|
114
|
+
private get db();
|
|
115
|
+
/**
|
|
116
|
+
* 另存为模板 (ruling P4-9): the org's live agent `agentId` (any one: an org admin may edit every
|
|
117
|
+
* agent of the org) saved as the org template `name` (version 1, `plugin_name` null), mapped
|
|
118
|
+
* by {@link templateFromAgent}. The bare name must be free in the org (rule 10): a usable
|
|
119
|
+
* template of that type, one of the org's own rows of that name, or a live platform template
|
|
120
|
+
* the org created under that name -> 409 `agent_template.name_taken` naming its owner (details
|
|
121
|
+
* `[{ owner, templateId }]`). Audits `agent_template.created`.
|
|
122
|
+
*/
|
|
123
|
+
saveAs(orgId: string, actor: string, agentId: string, meta: {
|
|
124
|
+
name: string;
|
|
125
|
+
description: string;
|
|
126
|
+
}, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<{
|
|
127
|
+
template: AgentTemplateDetail;
|
|
128
|
+
omitted: SaveAsOmission[];
|
|
129
|
+
}>;
|
|
130
|
+
/**
|
|
131
|
+
* Rule 10 for a new org template named `name` (a bare type): refused for a reserved roster name
|
|
132
|
+
* (details `[{ reserved: true }]`), and while the org's usable set has that type, the org has a
|
|
133
|
+
* live row of that name without a plugin (an unusable copy too: the live-name index), a
|
|
134
|
+
* plugin-less platform template of that name is offered to the org (ruling P2-3's alignment),
|
|
135
|
+
* or the platform has a live template the org created under that name (promotion would clash).
|
|
136
|
+
*/
|
|
137
|
+
private assertNameFree;
|
|
138
|
+
/**
|
|
139
|
+
* A template usable in the org by id ({@link loadTemplates}: an org row, a linked copy, a
|
|
140
|
+
* platform template on in the org), or the org's own template whatever its switch, with its
|
|
141
|
+
* definition, owner and the org's flags. Otherwise -> 404 `component.not_found`.
|
|
142
|
+
*/
|
|
143
|
+
detail(orgId: string, id: string): Promise<AgentTemplateDetail>;
|
|
144
|
+
/**
|
|
145
|
+
* A new version of the org's own template `id` (ruling P4-12; `agents.manage` re-checked under
|
|
146
|
+
* the org row lock): `definition` is validated like a template file and keeps its name;
|
|
147
|
+
* `expectedVersion` must be the version the editor read (else 409
|
|
148
|
+
* `agent_template.version_conflict`). An unshared template gets a new version of its org row; a
|
|
149
|
+
* promoted one a new version of its platform row (ruling P3-4), which the org row then serves
|
|
150
|
+
* (ruling P3-43), and the orgs using it are told (`shared_item_updated`). An unchanged
|
|
151
|
+
* definition writes nothing. Not the org's own -> 409 `catalog.not_owned`; missing -> 404.
|
|
152
|
+
* Agents created earlier are never touched. Audits `agent_template.updated`.
|
|
153
|
+
*/
|
|
154
|
+
update(orgId: string, actor: string, id: string, body: {
|
|
155
|
+
definition: Record<string, unknown>;
|
|
156
|
+
expectedVersion: number;
|
|
157
|
+
}, actorTokenId?: string): Promise<AgentTemplateDetail>;
|
|
158
|
+
/**
|
|
159
|
+
* The org's own template `id` ({@link readOwnTemplate}, the predicate `OwnedItems` shares), or
|
|
160
|
+
* undefined: another org's, a plugin's, or a copy of a platform template it does not own.
|
|
161
|
+
*/
|
|
162
|
+
private ownRow;
|
|
163
|
+
/**
|
|
164
|
+
* What the org's own template serves, read directly (its usable-set entry is missing while the
|
|
165
|
+
* org switched its promoted template off): the platform row's current version when it is newer
|
|
166
|
+
* than the org row's (ruling P3-43), else the org row's.
|
|
167
|
+
*/
|
|
168
|
+
private ownServed;
|
|
169
|
+
/** 409 `catalog.not_owned` for a template the org has but does not own, else 404. */
|
|
170
|
+
private notOwnedOrMissing;
|
|
171
|
+
/**
|
|
172
|
+
* The owner of a usable template the org does not own itself: a platform template's (or a
|
|
173
|
+
* linked copy's) `owner_org_id`, a plugin template's catalog item owner, else the platform.
|
|
174
|
+
*/
|
|
175
|
+
private ownerOfRow;
|
|
176
|
+
}
|