@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
package/dist/infra/tokens.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/** Injection tokens of the global infra modules. */
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* A class's logger (`KernelLogger`): the process logger with `context` set to the injecting class's
|
|
4
|
+
* name. Transient, so `app.get` cannot resolve it; use `KERNEL_ROOT_LOGGER` outside an injection.
|
|
5
|
+
*/
|
|
3
6
|
export const KERNEL_LOGGER = Symbol("KERNEL_LOGGER");
|
|
7
|
+
/** The process logger itself (`KernelLogger`), without a context. */
|
|
8
|
+
export const KERNEL_ROOT_LOGGER = Symbol("KERNEL_ROOT_LOGGER");
|
|
4
9
|
/** The startup input of `KernelConfigService`: `{ config, env }`. */
|
|
5
10
|
export const KERNEL_CONFIG_INPUT = Symbol("KERNEL_CONFIG_INPUT");
|
|
6
11
|
/** The Kysely pool, untyped (`Kysely<any>`); infra only, services inject `KernelDb`. */
|
package/dist/kernel.module.js
CHANGED
|
@@ -33,6 +33,8 @@ import { KernelLifecycle } from "./lifecycle/kernel-lifecycle.js";
|
|
|
33
33
|
import { KERNEL_APP_OPTIONS } from "./lifecycle/tokens.js";
|
|
34
34
|
import { createConfiguredLogger } from "./log-config.js";
|
|
35
35
|
import { KERNEL_OVERRIDE_TOKENS } from "./overrides.js";
|
|
36
|
+
import { PlatformModule } from "./platform/platform.module.js";
|
|
37
|
+
import { PlatformOpsModule } from "./platform/platform-ops.module.js";
|
|
36
38
|
import { GatewayModule } from "./roles/gateway.module.js";
|
|
37
39
|
import { WorkerModule } from "./roles/worker.module.js";
|
|
38
40
|
import { UsageReportModule } from "./runtime/usage-report.js";
|
|
@@ -108,6 +110,10 @@ let KernelModule = KernelModule_1 = class KernelModule {
|
|
|
108
110
|
TitlesModule,
|
|
109
111
|
UsageReportModule,
|
|
110
112
|
ChannelsModule,
|
|
113
|
+
// the Platform tool's operation registry and actor facts
|
|
114
|
+
PlatformModule,
|
|
115
|
+
// its operations (skills, agents, ...), registered at start on every role
|
|
116
|
+
PlatformOpsModule,
|
|
111
117
|
// the role modules, by `roles` (nest kernel spec §2)
|
|
112
118
|
...(config.roles.includes("api") ? [ApiModule] : []),
|
|
113
119
|
...(config.roles.includes("worker") ? [WorkerModule.forRoot(config)] : []),
|
|
@@ -123,7 +123,7 @@ export declare class KernelLifecycle implements OnApplicationBootstrap, BeforeAp
|
|
|
123
123
|
* and the next start tries again while it stays incomplete.
|
|
124
124
|
*/
|
|
125
125
|
private runBootstrap;
|
|
126
|
-
/**
|
|
126
|
+
/** 部署尚无活跃超级管理员时提示去初始化;查询失败只记日志,不影响启动。 */
|
|
127
127
|
private warnIfSetupPending;
|
|
128
128
|
beforeApplicationShutdown(): Promise<void>;
|
|
129
129
|
/** Logs the end of the stop phases (Redis and the pool close right after, in the infra modules). */
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
|
-
import { SANDBOX_EXTENSION_POINT
|
|
10
|
+
import { SANDBOX_EXTENSION_POINT } from "@capybara-hq/plugin-sdk";
|
|
11
11
|
import { Inject, Injectable, Optional, } from "@nestjs/common";
|
|
12
12
|
import { sql } from "kysely";
|
|
13
13
|
import { MarketplacesService } from "../catalog/marketplaces.service.js";
|
|
@@ -237,7 +237,7 @@ let KernelLifecycle = class KernelLifecycle {
|
|
|
237
237
|
.list("sandbox")
|
|
238
238
|
.find((x) => x.capability === SANDBOX_EXTENSION_POINT);
|
|
239
239
|
if (sandboxEntry !== undefined) {
|
|
240
|
-
for (const w of sandboxConfigWarnings(cfg(), sandboxEntry.plugin
|
|
240
|
+
for (const w of sandboxConfigWarnings(cfg(), sandboxEntry.plugin)) {
|
|
241
241
|
this.log[w.level](w.message);
|
|
242
242
|
}
|
|
243
243
|
}
|
|
@@ -318,10 +318,10 @@ let KernelLifecycle = class KernelLifecycle {
|
|
|
318
318
|
throw e;
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
|
-
/**
|
|
321
|
+
/** 部署尚无活跃超级管理员时提示去初始化;查询失败只记日志,不影响启动。 */
|
|
322
322
|
async warnIfSetupPending() {
|
|
323
323
|
try {
|
|
324
|
-
if ((await this.accounts.
|
|
324
|
+
if ((await this.accounts.countSuperAdmins()) === 0) {
|
|
325
325
|
this.log.warn("deployment is not set up; open the setup wizard or run `capybara admin create`");
|
|
326
326
|
}
|
|
327
327
|
}
|
package/dist/log.d.ts
CHANGED
|
@@ -30,6 +30,11 @@ export interface KernelLogger extends Logger {
|
|
|
30
30
|
redact(text: string): string;
|
|
31
31
|
/** Waits until buffered records reached every output (Loki); never rejects. Call before exit. */
|
|
32
32
|
flush(): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* A logger that adds `fields` to every record (e.g. `{ context: "RunWorker" }`); call fields cannot
|
|
35
|
+
* overwrite them. It shares everything else with this logger: level, secrets, outputs.
|
|
36
|
+
*/
|
|
37
|
+
child(fields: Record<string, string>): KernelLogger;
|
|
33
38
|
}
|
|
34
39
|
/**
|
|
35
40
|
* 用与 logger 相同的匹配器打码任意文本(工具结果等不经过日志的内容用):展开规则同 `addOrgSecrets`
|
|
@@ -37,13 +42,15 @@ export interface KernelLogger extends Logger {
|
|
|
37
42
|
* 不得小于匹配器的分桶前缀长度 4)。没有可用的值时原样返回。
|
|
38
43
|
*/
|
|
39
44
|
export declare function createRedactor(values: readonly unknown[], minLength?: number): (s: string) => string;
|
|
40
|
-
/** Console format: `pretty` (pino-pretty
|
|
45
|
+
/** Console format: `pretty` (pino-pretty), `json`, or `auto` (pretty on a TTY). */
|
|
41
46
|
export declare const LOG_FORMATS: readonly ["auto", "pretty", "json"];
|
|
42
47
|
/** Console format. */
|
|
43
48
|
export type LogFormat = (typeof LOG_FORMATS)[number];
|
|
44
49
|
/** A minimal writable the console output goes to (`process.stdout` by default). */
|
|
45
50
|
export interface LogOutput {
|
|
46
51
|
write(chunk: string): unknown;
|
|
52
|
+
/** A stream's `error` event (EPIPE when its reader is gone). */
|
|
53
|
+
on?(event: "error", listener: (err: unknown) => void): unknown;
|
|
47
54
|
}
|
|
48
55
|
/** Options of {@link createLogger}. */
|
|
49
56
|
export interface LoggerOptions {
|
|
@@ -58,6 +65,11 @@ export interface LoggerOptions {
|
|
|
58
65
|
out?: LogOutput;
|
|
59
66
|
/** Whether the console is a terminal (picks `auto` and colors); default `process.stdout.isTTY`. */
|
|
60
67
|
isTTY?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Pretty output in colors; default: `FORCE_COLOR` (set and not `0`) turns them on, `NO_COLOR` off,
|
|
70
|
+
* else a TTY. `pnpm dev:kernel` forces them, since its output goes through `tee`.
|
|
71
|
+
*/
|
|
72
|
+
colors?: boolean;
|
|
61
73
|
/** Also push every record to Loki. */
|
|
62
74
|
loki?: LokiOptions;
|
|
63
75
|
/** Fields on every record (e.g. `role`); log calls cannot overwrite them. */
|
package/dist/log.js
CHANGED
|
@@ -105,15 +105,16 @@ function expandSecret(value) {
|
|
|
105
105
|
}
|
|
106
106
|
return out;
|
|
107
107
|
}
|
|
108
|
-
/** Console format: `pretty` (pino-pretty
|
|
108
|
+
/** Console format: `pretty` (pino-pretty), `json`, or `auto` (pretty on a TTY). */
|
|
109
109
|
export const LOG_FORMATS = ["auto", "pretty", "json"];
|
|
110
|
-
/** Fields shown in the pretty prefix instead of the
|
|
111
|
-
const PREFIX_FIELDS = ["reqId", "
|
|
112
|
-
/**
|
|
110
|
+
/** Fields shown in the pretty prefix instead of the lines below, in this order. */
|
|
111
|
+
const PREFIX_FIELDS = ["traceId", "reqId", "queue", "jobId", "runId", "context", "plugin"];
|
|
112
|
+
/**
|
|
113
|
+
* pino-pretty's message format, the octok layout:
|
|
114
|
+
* `[pid=…] - [traceId=…] [reqId=…] [context=…] msg`, each bracket only when present.
|
|
115
|
+
*/
|
|
113
116
|
function prettyMessage(log, messageKey) {
|
|
114
|
-
const parts = [];
|
|
115
|
-
if (typeof log.role === "string")
|
|
116
|
-
parts.push(`[${log.role}]`);
|
|
117
|
+
const parts = [`[pid=${process.pid}] -`];
|
|
117
118
|
for (const k of PREFIX_FIELDS) {
|
|
118
119
|
const v = log[k];
|
|
119
120
|
if (typeof v === "string" || typeof v === "number")
|
|
@@ -122,6 +123,24 @@ function prettyMessage(log, messageKey) {
|
|
|
122
123
|
parts.push(String(log[messageKey] ?? ""));
|
|
123
124
|
return parts.join(" ");
|
|
124
125
|
}
|
|
126
|
+
/** The HTTP access record (`http/app.ts`) as one sentence: method, path, status and duration. */
|
|
127
|
+
function foldAccessLine(log) {
|
|
128
|
+
if (log.msg !== "request" || typeof log.method !== "string" || typeof log.url !== "string") {
|
|
129
|
+
return log;
|
|
130
|
+
}
|
|
131
|
+
const { method, url, status, ms, ...rest } = log;
|
|
132
|
+
return { ...rest, msg: `${method} ${url} ${status} ${ms}ms` };
|
|
133
|
+
}
|
|
134
|
+
function colorsOn(opts, isTTY) {
|
|
135
|
+
if (opts.colors !== undefined)
|
|
136
|
+
return opts.colors;
|
|
137
|
+
const force = process.env.FORCE_COLOR;
|
|
138
|
+
if (force !== undefined && force !== "0")
|
|
139
|
+
return true;
|
|
140
|
+
if (process.env.NO_COLOR)
|
|
141
|
+
return false;
|
|
142
|
+
return isTTY;
|
|
143
|
+
}
|
|
125
144
|
function consoleStream(opts) {
|
|
126
145
|
if (opts.write) {
|
|
127
146
|
const write = opts.write;
|
|
@@ -132,23 +151,50 @@ function consoleStream(opts) {
|
|
|
132
151
|
if (!LOG_FORMATS.includes(format)) {
|
|
133
152
|
throw new Error(`invalid log.format "${format}" (expected ${LOG_FORMATS.join(", ")})`);
|
|
134
153
|
}
|
|
135
|
-
const
|
|
154
|
+
const target = opts.out ?? process.stdout;
|
|
155
|
+
// A console whose reader is gone (the `tee` of `pnpm dev:kernel` stopped by Ctrl-C, a closed
|
|
156
|
+
// pipe) fails every write with EPIPE. Unhandled, each failure is an uncaught exception the
|
|
157
|
+
// process guard logs, which writes again: an endless chain that starves the event loop. So the
|
|
158
|
+
// first stream error ends console output for good (Loki, when configured, still gets records).
|
|
159
|
+
let broken = false;
|
|
160
|
+
target.on?.("error", () => {
|
|
161
|
+
broken = true;
|
|
162
|
+
});
|
|
163
|
+
const out = {
|
|
164
|
+
write: (s) => {
|
|
165
|
+
if (!broken)
|
|
166
|
+
target.write(s);
|
|
167
|
+
},
|
|
168
|
+
};
|
|
136
169
|
const isTTY = opts.isTTY ?? process.stdout.isTTY === true;
|
|
137
170
|
const pretty = format === "pretty" || (format === "auto" && isTTY);
|
|
138
171
|
if (!pretty)
|
|
139
172
|
return { write: (s) => out.write(s) };
|
|
140
|
-
|
|
173
|
+
const colors = colorsOn(opts, isTTY);
|
|
174
|
+
// In process (no worker thread): pino-pretty formats each record synchronously. The layout follows
|
|
175
|
+
// octok's buildPinoPrettyOptions: full local time, colored level, the bracket prefix, and
|
|
176
|
+
// the remaining fields as indented `key: value` lines below the message (errors with their stack).
|
|
141
177
|
const format_ = prettyFactory({
|
|
142
|
-
colorize:
|
|
143
|
-
colorizeObjects:
|
|
144
|
-
singleLine:
|
|
145
|
-
|
|
146
|
-
errorLikeObjectKeys: [],
|
|
147
|
-
translateTime: "SYS:HH:MM:ss.l",
|
|
178
|
+
colorize: colors,
|
|
179
|
+
colorizeObjects: colors,
|
|
180
|
+
singleLine: false,
|
|
181
|
+
translateTime: "SYS:standard",
|
|
148
182
|
ignore: ["pid", "hostname", "role", "spanId", ...PREFIX_FIELDS].join(","),
|
|
149
183
|
messageFormat: (log, messageKey) => prettyMessage(log, messageKey),
|
|
150
184
|
});
|
|
151
|
-
return {
|
|
185
|
+
return {
|
|
186
|
+
write: (s) => {
|
|
187
|
+
let record;
|
|
188
|
+
try {
|
|
189
|
+
record = JSON.parse(s);
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
out.write(s);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
out.write(format_(foldAccessLine(record)));
|
|
196
|
+
},
|
|
197
|
+
};
|
|
152
198
|
}
|
|
153
199
|
/**
|
|
154
200
|
* Creates the kernel logger on pino. Each record is `{ time, level, msg, ...base, ...fields }` with
|
|
@@ -254,7 +300,7 @@ export function createLogger(level = "info", opts = {}) {
|
|
|
254
300
|
}
|
|
255
301
|
sink[lvl](obj, redactMsg(msg));
|
|
256
302
|
};
|
|
257
|
-
|
|
303
|
+
const root = {
|
|
258
304
|
debug: (msg, fields) => emit("debug", msg, fields),
|
|
259
305
|
info: (msg, fields) => emit("info", msg, fields),
|
|
260
306
|
warn: (msg, fields) => emit("warn", msg, fields),
|
|
@@ -299,5 +345,35 @@ export function createLogger(level = "info", opts = {}) {
|
|
|
299
345
|
}
|
|
300
346
|
}
|
|
301
347
|
},
|
|
348
|
+
// a method, so a wrapper of this logger (a test proxy) is the parent its children forward to
|
|
349
|
+
child(fields) {
|
|
350
|
+
return childLogger(this, fields);
|
|
351
|
+
},
|
|
352
|
+
};
|
|
353
|
+
return root;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* A logger that adds `bound` to every record and forwards it to `parent`'s public methods (so a spy
|
|
357
|
+
* on the parent sees its children's records); call fields cannot overwrite the bound ones.
|
|
358
|
+
*/
|
|
359
|
+
function childLogger(parent, bound) {
|
|
360
|
+
const merged = (fields) => ({ ...fields, ...bound });
|
|
361
|
+
const child = {
|
|
362
|
+
debug: (msg, fields) => parent.debug(msg, merged(fields)),
|
|
363
|
+
info: (msg, fields) => parent.info(msg, merged(fields)),
|
|
364
|
+
warn: (msg, fields) => parent.warn(msg, merged(fields)),
|
|
365
|
+
error: (msg, fields) => parent.error(msg, merged(fields)),
|
|
366
|
+
get level() {
|
|
367
|
+
return parent.level;
|
|
368
|
+
},
|
|
369
|
+
setLevel: (level) => parent.setLevel(level),
|
|
370
|
+
addSecrets: (values) => parent.addSecrets(values),
|
|
371
|
+
addOrgSecrets: (values) => parent.addOrgSecrets(values),
|
|
372
|
+
redact: (text) => parent.redact(text),
|
|
373
|
+
flush: () => parent.flush(),
|
|
374
|
+
child(fields) {
|
|
375
|
+
return childLogger(this, fields);
|
|
376
|
+
},
|
|
302
377
|
};
|
|
378
|
+
return child;
|
|
303
379
|
}
|
package/dist/models/prices.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ModelUsage } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import {
|
|
3
|
+
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
4
4
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
5
5
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
6
6
|
/**
|
|
7
|
-
* 一个模型的价格(C2):每百万 token,币种为部署设置 `priceCurrency
|
|
7
|
+
* 一个模型的价格(C2):每百万 token,币种为部署设置 `priceCurrency`。由超级管理员录入,插件不声明价格。
|
|
8
8
|
* 缓存读 / 写价为 null 时按输入价计。
|
|
9
9
|
*/
|
|
10
10
|
export interface ModelPrice {
|
|
@@ -40,13 +40,13 @@ export declare class PricesService {
|
|
|
40
40
|
private readonly db;
|
|
41
41
|
readonly txHost: TransactionHost;
|
|
42
42
|
private readonly adminLock;
|
|
43
|
-
constructor(db: KernelDb, txHost: TransactionHost, adminLock:
|
|
43
|
+
constructor(db: KernelDb, txHost: TransactionHost, adminLock: SuperAdminLock);
|
|
44
44
|
/** 全部价格,按 provider、model 排序。 */
|
|
45
45
|
list(): Promise<ModelPrice[]>;
|
|
46
46
|
/** 价格表(按 {@link priceKey} 查)。 */
|
|
47
47
|
table(): Promise<PriceTable>;
|
|
48
48
|
/**
|
|
49
|
-
* 设置或删除(`price: null
|
|
49
|
+
* 设置或删除(`price: null`)一个模型的价格:事务内取超级管理员锁并复核发起人仍是活跃超级管理员
|
|
50
50
|
* (否则 `forbidden`),写审计 `model_price.updated` / `model_price.deleted`。
|
|
51
51
|
*/
|
|
52
52
|
put(input: ModelPrice | {
|
|
@@ -54,6 +54,6 @@ export declare class PricesService {
|
|
|
54
54
|
model: string;
|
|
55
55
|
price: null;
|
|
56
56
|
}, actorAccountId: string, actorTokenId?: string): Promise<void>;
|
|
57
|
-
/** The write of {@link put}, under the
|
|
57
|
+
/** The write of {@link put}, under the super admin lock. */
|
|
58
58
|
private write;
|
|
59
59
|
}
|
package/dist/models/prices.js
CHANGED
|
@@ -11,7 +11,7 @@ import { Inject, Injectable } from "@nestjs/common";
|
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
import { ApiError } from "../errors.js";
|
|
13
13
|
import { audit } from "../identity/audit.js";
|
|
14
|
-
import {
|
|
14
|
+
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
15
15
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
16
16
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
17
17
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
@@ -87,7 +87,7 @@ let PricesService = class PricesService {
|
|
|
87
87
|
return new Map((await this.list()).map((p) => [priceKey(p.provider, p.model), p]));
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
|
-
* 设置或删除(`price: null
|
|
90
|
+
* 设置或删除(`price: null`)一个模型的价格:事务内取超级管理员锁并复核发起人仍是活跃超级管理员
|
|
91
91
|
* (否则 `forbidden`),写审计 `model_price.updated` / `model_price.deleted`。
|
|
92
92
|
*/
|
|
93
93
|
async put(input, actorAccountId, actorTokenId) {
|
|
@@ -97,7 +97,7 @@ let PricesService = class PricesService {
|
|
|
97
97
|
}
|
|
98
98
|
await this.write(check.data, actorAccountId, actorTokenId);
|
|
99
99
|
}
|
|
100
|
-
/** The write of {@link put}, under the
|
|
100
|
+
/** The write of {@link put}, under the super admin lock. */
|
|
101
101
|
async write(v, actorAccountId, actorTokenId) {
|
|
102
102
|
await this.adminLock.lockAndAuthorize(actorAccountId);
|
|
103
103
|
const target = `${v.provider}/${v.model}`;
|
|
@@ -144,6 +144,6 @@ PricesService = __decorate([
|
|
|
144
144
|
Injectable(),
|
|
145
145
|
__param(0, Inject(KernelDb)),
|
|
146
146
|
__param(1, Inject(TransactionHost)),
|
|
147
|
-
__param(2, Inject(
|
|
147
|
+
__param(2, Inject(SuperAdminLock))
|
|
148
148
|
], PricesService);
|
|
149
149
|
export { PricesService };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { ExtensionDisplayNames } from "../extensions/display-name.js";
|
|
1
2
|
import { type Principal } from "../identity/principal.js";
|
|
2
3
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
3
|
-
import { ModelPurposesService, type
|
|
4
|
+
import { ModelPurposesService, type PurposeListing, type PurposePut, type PurposeTarget } from "./purposes.js";
|
|
4
5
|
/** body 的目标(参数缺省为 `{}`)。 */
|
|
5
6
|
export declare const purposeTargetOf: (b: PurposePut) => PurposeTarget | null;
|
|
6
7
|
/**
|
|
@@ -9,11 +10,12 @@ export declare const purposeTargetOf: (b: PurposePut) => PurposeTarget | null;
|
|
|
9
10
|
*/
|
|
10
11
|
export declare class ModelPurposesController {
|
|
11
12
|
private readonly purposes;
|
|
12
|
-
|
|
13
|
+
private readonly displayNames;
|
|
14
|
+
constructor(purposes: ModelPurposesService, displayNames: ExtensionDisplayNames);
|
|
13
15
|
list(principal: Principal, org: OrgContext): Promise<{
|
|
14
|
-
purposes:
|
|
16
|
+
purposes: PurposeListing[];
|
|
15
17
|
}>;
|
|
16
18
|
put(principal: Principal, org: OrgContext, purpose: string, body: PurposePut): Promise<{
|
|
17
|
-
purpose:
|
|
19
|
+
purpose: PurposeListing;
|
|
18
20
|
}>;
|
|
19
21
|
}
|
|
@@ -8,10 +8,11 @@ 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, Param, Put } from "@nestjs/common";
|
|
11
|
+
import { ExtensionDisplayNames } from "../extensions/display-name.js";
|
|
11
12
|
import { CurrentPrincipal, patTokenId, requireUser, } from "../identity/principal.js";
|
|
12
13
|
import { ZBody } from "../infra/validation/zod-params.js";
|
|
13
14
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
14
|
-
import { ModelPurposesService, PurposePutDto, } from "./purposes.js";
|
|
15
|
+
import { ModelPurposesService, PurposePutDto, withDeclaredByNames, } from "./purposes.js";
|
|
15
16
|
/** body 的目标(参数缺省为 `{}`)。 */
|
|
16
17
|
export const purposeTargetOf = (b) => b.target === null ? null : { model: b.target.model, params: b.target.params ?? {} };
|
|
17
18
|
/**
|
|
@@ -20,18 +21,22 @@ export const purposeTargetOf = (b) => b.target === null ? null : { model: b.targ
|
|
|
20
21
|
*/
|
|
21
22
|
let ModelPurposesController = class ModelPurposesController {
|
|
22
23
|
purposes;
|
|
23
|
-
|
|
24
|
+
displayNames;
|
|
25
|
+
constructor(purposes, displayNames) {
|
|
24
26
|
this.purposes = purposes;
|
|
27
|
+
this.displayNames = displayNames;
|
|
25
28
|
}
|
|
26
29
|
async list(principal, org) {
|
|
27
30
|
requireUser(principal);
|
|
28
|
-
return {
|
|
31
|
+
return {
|
|
32
|
+
purposes: await withDeclaredByNames(await this.purposes.list(org.orgId), this.displayNames),
|
|
33
|
+
};
|
|
29
34
|
}
|
|
30
35
|
async put(principal, org, purpose, body) {
|
|
31
36
|
const p = requireUser(principal);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
37
|
+
const view = await this.purposes.setOrg(org.orgId, purpose, purposeTargetOf(body), p.account.id, patTokenId(p));
|
|
38
|
+
const [listing] = await withDeclaredByNames([view], this.displayNames);
|
|
39
|
+
return { purpose: listing };
|
|
35
40
|
}
|
|
36
41
|
};
|
|
37
42
|
__decorate([
|
|
@@ -50,6 +55,7 @@ __decorate([
|
|
|
50
55
|
], ModelPurposesController.prototype, "put", null);
|
|
51
56
|
ModelPurposesController = __decorate([
|
|
52
57
|
Controller("api/v1/orgs/:orgId/model-purposes"),
|
|
53
|
-
__param(0, Inject(ModelPurposesService))
|
|
58
|
+
__param(0, Inject(ModelPurposesService)),
|
|
59
|
+
__param(1, Inject(ExtensionDisplayNames))
|
|
54
60
|
], ModelPurposesController);
|
|
55
61
|
export { ModelPurposesController };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type ContentBlock, type ModelRequest, type ModelUsage, type ParamValue, type StopReason } from "@capybara-hq/plugin-sdk";
|
|
1
|
+
import { type ContentBlock, type LocalizedName, type ModelRequest, type ModelUsage, type ParamValue, type StopReason } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { ModelRef } from "../agents/definition.js";
|
|
4
4
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
5
|
-
import {
|
|
5
|
+
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
6
6
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
7
7
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
8
8
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
@@ -11,7 +11,7 @@ import { ProviderRegistry } from "../runtime/providers.js";
|
|
|
11
11
|
/**
|
|
12
12
|
* 模型用途映射(C9):内核与插件按「用途」取模型,不在代码里写死模型。
|
|
13
13
|
* - 用途 = 内核用途 {@link KERNEL_PURPOSES}(目前只有评委 `eval`),或已加载插件 `permissions.models` 声明的;
|
|
14
|
-
* - 映射 = 部署默认(`org_id` 为 null
|
|
14
|
+
* - 映射 = 部署默认(`org_id` 为 null,超级管理员设)+ 组织覆盖(组织管理员设,`org.models.manage`);
|
|
15
15
|
* 生效的映射先取组织覆盖、再取部署默认,都没有 → `model.unconfigured`;
|
|
16
16
|
* - 目标模型按部署范围解析(与运行时一致),参数按目标模型自己的声明严格校验;不做模型白名单;
|
|
17
17
|
* - 每次都查 PG,不在进程内缓存(多副本下改映射立即生效)。`ctx.models` 仍预留,插件暂不能调用。
|
|
@@ -35,25 +35,32 @@ export declare const KERNEL_PURPOSES: readonly [{
|
|
|
35
35
|
readonly zh: "会话标题";
|
|
36
36
|
readonly en: "Conversation titles";
|
|
37
37
|
};
|
|
38
|
+
}, {
|
|
39
|
+
readonly purpose: "web_fetch";
|
|
40
|
+
readonly kind: "chat";
|
|
41
|
+
readonly label: {
|
|
42
|
+
readonly zh: "网页提取";
|
|
43
|
+
readonly en: "Web page extraction";
|
|
44
|
+
};
|
|
38
45
|
}, {
|
|
39
46
|
readonly purpose: "subagent_fast";
|
|
40
47
|
readonly kind: "chat";
|
|
41
48
|
readonly label: {
|
|
42
|
-
readonly zh: "
|
|
49
|
+
readonly zh: "子智能体:快速";
|
|
43
50
|
readonly en: "Sub-agent: fast";
|
|
44
51
|
};
|
|
45
52
|
}, {
|
|
46
53
|
readonly purpose: "subagent_standard";
|
|
47
54
|
readonly kind: "chat";
|
|
48
55
|
readonly label: {
|
|
49
|
-
readonly zh: "
|
|
56
|
+
readonly zh: "子智能体:标准";
|
|
50
57
|
readonly en: "Sub-agent: standard";
|
|
51
58
|
};
|
|
52
59
|
}, {
|
|
53
60
|
readonly purpose: "subagent_capable";
|
|
54
61
|
readonly kind: "chat";
|
|
55
62
|
readonly label: {
|
|
56
|
-
readonly zh: "
|
|
63
|
+
readonly zh: "子智能体:最强";
|
|
57
64
|
readonly en: "Sub-agent: capable";
|
|
58
65
|
};
|
|
59
66
|
}];
|
|
@@ -75,6 +82,17 @@ export interface PurposeView {
|
|
|
75
82
|
override: PurposeTarget | null;
|
|
76
83
|
effective: PurposeTarget | null;
|
|
77
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* A purpose as the purpose APIs return it: the view plus the declaring extension's display name
|
|
87
|
+
* (`null` for a kernel purpose, or an extension without one), so a page names the extension.
|
|
88
|
+
*/
|
|
89
|
+
export interface PurposeListing extends PurposeView {
|
|
90
|
+
declaredByName: LocalizedName | null;
|
|
91
|
+
}
|
|
92
|
+
/** {@link PurposeListing}s of `views`, the display names read in one call. */
|
|
93
|
+
export declare function withDeclaredByNames(views: PurposeView[], names: {
|
|
94
|
+
many(names: string[]): Promise<Map<string, LocalizedName | null>>;
|
|
95
|
+
}): Promise<PurposeListing[]>;
|
|
78
96
|
/** `PUT …/model-purposes/:purpose` 的 body:设映射,或 `target: null` 清除。 */
|
|
79
97
|
export declare const PURPOSE_PUT: z.ZodObject<{
|
|
80
98
|
target: z.ZodNullable<z.ZodObject<{
|
|
@@ -121,7 +139,7 @@ export declare class ModelPurposesService {
|
|
|
121
139
|
readonly txHost: TransactionHost;
|
|
122
140
|
private readonly adminLock;
|
|
123
141
|
private readonly orgLock;
|
|
124
|
-
constructor(db: KernelDb, extensions: ExtensionRegistry, config: KernelConfigService, providers: Pick<ProviderRegistry, "resolve">, txHost: TransactionHost, adminLock:
|
|
142
|
+
constructor(db: KernelDb, extensions: ExtensionRegistry, config: KernelConfigService, providers: Pick<ProviderRegistry, "resolve">, txHost: TransactionHost, adminLock: SuperAdminLock, orgLock: OrgLock);
|
|
125
143
|
/** 全部已声明的用途:内核的在前,其后按插件加载顺序。 */
|
|
126
144
|
private declared;
|
|
127
145
|
private find;
|
|
@@ -132,14 +150,27 @@ export declare class ModelPurposesService {
|
|
|
132
150
|
/** 校验目标:模型可解析(部署范围)、参数按它的声明严格通过。 */
|
|
133
151
|
private check;
|
|
134
152
|
private set;
|
|
135
|
-
/** The mapping write of {@link set}, under the
|
|
153
|
+
/** The mapping write of {@link set}, under the super admin or org lock. */
|
|
136
154
|
private write;
|
|
137
|
-
/** 设置(或 `null`
|
|
155
|
+
/** 设置(或 `null` 清除)部署默认;只有超级管理员(事务内复核)。 */
|
|
138
156
|
setDefault(purpose: string, target: PurposeTarget | null, actor: string, actorTokenId?: string): Promise<PurposeView>;
|
|
139
157
|
/** 设置(或 `null` 清除)组织覆盖;事务内锁组织并复核 `org.models.manage`。 */
|
|
140
158
|
setOrg(orgId: string, purpose: string, target: PurposeTarget | null, actor: string, actorTokenId?: string): Promise<PurposeView>;
|
|
141
159
|
/** 生效的映射:组织覆盖,否则部署默认;都没有 → `model.unconfigured`;用途未声明 → `model.purpose_unknown`。 */
|
|
142
160
|
resolve(orgId: string, purpose: string): Promise<PurposeTarget>;
|
|
161
|
+
/** The target a {@link chat} call on `purpose` uses: the mapping, else `fallback` when unmapped. */
|
|
162
|
+
private chatTarget;
|
|
163
|
+
/**
|
|
164
|
+
* The limits of the model a {@link chat} call on `purpose` would use now (the same mapping and
|
|
165
|
+
* `fallback` rule): its context window and output cap, so a caller can size its request (e.g.
|
|
166
|
+
* the `WebFetch` page) before the call. Fails as `chat` does before sending.
|
|
167
|
+
*/
|
|
168
|
+
chatLimits(orgId: string, purpose: string, opts?: {
|
|
169
|
+
fallback?: PurposeTarget;
|
|
170
|
+
}): Promise<{
|
|
171
|
+
contextWindow: number;
|
|
172
|
+
maxOutputTokens: number;
|
|
173
|
+
}>;
|
|
143
174
|
/**
|
|
144
175
|
* 按用途发一次对话请求:解析映射、按目标模型的声明宽松处理参数(补默认值,与运行时一致),用 `consumeModelStream`
|
|
145
176
|
* 收完(只有流空闲看门狗)。输出上限取 `min(req.maxOutputTokens, 目标模型的 maxOutputTokens)`。
|
|
@@ -147,10 +178,13 @@ export declare class ModelPurposesService {
|
|
|
147
178
|
* `opts.fallback`: the target used when the purpose is not mapped (`model.unconfigured`).
|
|
148
179
|
* `opts.beforeSend`: called with the resolved target and the final request just before sending;
|
|
149
180
|
* what it throws is thrown as is (a pre-send failure, e.g. a denied `model.request` hook).
|
|
181
|
+
* `opts.paramDefaults`: values for parameters the target does not set, kept only where the
|
|
182
|
+
* target model declares the key and the value fits it (e.g. `thinking: "off"` for a short call).
|
|
150
183
|
*/
|
|
151
184
|
chat(orgId: string, purpose: string, req: Omit<ModelRequest, "model" | "params">, signal: AbortSignal, opts?: {
|
|
152
185
|
fallback?: PurposeTarget;
|
|
153
186
|
beforeSend?: (target: ModelRef, request: ModelRequest) => Promise<void>;
|
|
187
|
+
paramDefaults?: Record<string, ParamValue>;
|
|
154
188
|
}): Promise<{
|
|
155
189
|
content: ContentBlock[];
|
|
156
190
|
stopReason: StopReason;
|