@capybara-hq/kernel 0.1.0-rc.4 → 0.1.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bootstrap.json +61 -5
- package/dist/admin/admin.controller.d.ts +51 -14
- package/dist/admin/admin.controller.js +60 -19
- package/dist/admin/extensions.controller.d.ts +16 -2
- package/dist/admin/extensions.controller.js +26 -6
- package/dist/admin/setup-lock.d.ts +1 -1
- package/dist/admin/setup-lock.js +1 -1
- package/dist/admin/setup.controller.d.ts +1 -1
- package/dist/admin/setup.controller.js +1 -1
- package/dist/admin/setup.service.d.ts +4 -4
- package/dist/admin/setup.service.js +8 -8
- package/dist/agents/agent-lookup.d.ts +16 -0
- package/dist/agents/agent-lookup.js +11 -0
- package/dist/agents/agents.controller.d.ts +76 -1
- package/dist/agents/agents.controller.js +90 -11
- package/dist/agents/agents.module.d.ts +4 -1
- package/dist/agents/agents.module.js +32 -6
- package/dist/agents/agents.service.d.ts +54 -23
- package/dist/agents/agents.service.js +180 -76
- package/dist/agents/definition.d.ts +49 -0
- package/dist/agents/definition.js +45 -0
- package/dist/agents/from-template.d.ts +106 -0
- package/dist/agents/from-template.js +649 -0
- package/dist/agents/from-template.service.d.ts +60 -0
- package/dist/agents/from-template.service.js +161 -0
- package/dist/agents/models.controller.d.ts +34 -5
- package/dist/agents/models.controller.js +50 -6
- package/dist/agents/org-templates.d.ts +176 -0
- package/dist/agents/org-templates.js +827 -0
- package/dist/agents/pending-connector-requests.d.ts +77 -0
- package/dist/agents/pending-connector-requests.js +215 -0
- package/dist/agents/pending-connectors.controller.d.ts +39 -0
- package/dist/agents/pending-connectors.controller.js +91 -0
- package/dist/agents/pending-connectors.service.d.ts +62 -0
- package/dist/agents/pending-connectors.service.js +282 -0
- package/dist/agents/readiness.controller.d.ts +5 -5
- package/dist/agents/readiness.controller.js +6 -6
- package/dist/agents/templates.controller.d.ts +86 -5
- package/dist/agents/templates.controller.js +171 -7
- package/dist/agents/templates.d.ts +127 -23
- package/dist/agents/templates.js +475 -52
- package/dist/background/background.module.js +8 -1
- package/dist/background/finish.d.ts +3 -2
- package/dist/background/launch-lock.d.ts +4 -3
- package/dist/background/launch-lock.js +4 -3
- package/dist/background/poll.job.d.ts +9 -6
- package/dist/background/poll.job.js +30 -22
- package/dist/background/session.d.ts +13 -2
- package/dist/background/session.js +13 -0
- package/dist/background/stop.d.ts +12 -6
- package/dist/background/stop.js +57 -39
- package/dist/background/store.d.ts +18 -6
- package/dist/background/store.js +12 -6
- package/dist/background/tasks.service.d.ts +15 -5
- package/dist/background/tasks.service.js +42 -17
- package/dist/background/wake-rules.d.ts +27 -18
- package/dist/background/wake-rules.js +52 -22
- package/dist/background/wake.d.ts +13 -11
- package/dist/background/wake.js +20 -14
- package/dist/catalog/admin-catalog.controller.d.ts +129 -30
- package/dist/catalog/admin-catalog.controller.js +213 -42
- package/dist/catalog/catalog-content.d.ts +58 -32
- package/dist/catalog/catalog-content.js +34 -8
- package/dist/catalog/catalog-import.module.d.ts +7 -0
- package/dist/catalog/catalog-import.module.js +60 -0
- package/dist/catalog/catalog-items.d.ts +111 -7
- package/dist/catalog/catalog-items.js +279 -13
- package/dist/catalog/catalog-scope.service.d.ts +260 -0
- package/dist/catalog/catalog-scope.service.js +1116 -0
- package/dist/catalog/catalog.module.d.ts +7 -9
- package/dist/catalog/catalog.module.js +41 -31
- package/dist/catalog/catalog.service.d.ts +101 -29
- package/dist/catalog/catalog.service.js +104 -106
- package/dist/catalog/cli.d.ts +11 -1
- package/dist/catalog/cli.js +26 -1
- package/dist/catalog/component-promotion.d.ts +96 -0
- package/dist/catalog/component-promotion.js +395 -0
- package/dist/catalog/component-scope.controller.d.ts +152 -0
- package/dist/catalog/component-scope.controller.js +287 -0
- package/dist/catalog/component-scope.service.d.ts +303 -0
- package/dist/catalog/component-scope.service.js +936 -0
- package/dist/catalog/component-state.d.ts +174 -0
- package/dist/catalog/component-state.js +437 -0
- package/dist/catalog/job-ids.d.ts +30 -0
- package/dist/catalog/job-ids.js +25 -0
- package/dist/catalog/marketplace-fetch.d.ts +1 -1
- package/dist/catalog/marketplaces.controller.d.ts +22 -5
- package/dist/catalog/marketplaces.controller.js +56 -7
- package/dist/catalog/marketplaces.service.d.ts +54 -14
- package/dist/catalog/marketplaces.service.js +71 -22
- package/dist/catalog/org-catalog.controller.d.ts +125 -34
- package/dist/catalog/org-catalog.controller.js +181 -65
- package/dist/catalog/org-catalog.service.d.ts +65 -33
- package/dist/catalog/org-catalog.service.js +324 -157
- package/dist/catalog/org-extension-switch.d.ts +41 -0
- package/dist/catalog/org-extension-switch.js +115 -0
- package/dist/catalog/org-extension.controller.d.ts +119 -0
- package/dist/catalog/org-extension.controller.js +266 -0
- package/dist/catalog/org-plugin-uploads.controller.d.ts +98 -0
- package/dist/catalog/org-plugin-uploads.controller.js +213 -0
- package/dist/catalog/org-plugin-uploads.d.ts +63 -0
- package/dist/catalog/org-plugin-uploads.js +116 -0
- package/dist/catalog/owned-items.d.ts +184 -0
- package/dist/catalog/owned-items.js +789 -0
- package/dist/catalog/owned-plugin-cleanup.d.ts +56 -0
- package/dist/catalog/owned-plugin-cleanup.js +194 -0
- package/dist/catalog/ownership.d.ts +172 -0
- package/dist/catalog/ownership.js +326 -0
- package/dist/catalog/platform-components.d.ts +221 -0
- package/dist/catalog/platform-components.js +761 -0
- package/dist/catalog/platform-migration.d.ts +115 -0
- package/dist/catalog/platform-migration.js +582 -0
- package/dist/catalog/plugin-import.d.ts +178 -34
- package/dist/catalog/plugin-import.js +622 -82
- package/dist/catalog/plugin-install.d.ts +185 -41
- package/dist/catalog/plugin-install.js +758 -126
- package/dist/catalog/plugin-upgrade.d.ts +260 -225
- package/dist/catalog/plugin-upgrade.js +1147 -1136
- package/dist/catalog/request-rules.d.ts +65 -0
- package/dist/catalog/request-rules.js +217 -0
- package/dist/catalog/requests.service.d.ts +193 -118
- package/dist/catalog/requests.service.js +526 -343
- package/dist/catalog/reserved-names.d.ts +8 -0
- package/dist/catalog/reserved-names.js +42 -0
- package/dist/catalog/scope-orgs.d.ts +21 -0
- package/dist/catalog/scope-orgs.js +67 -0
- package/dist/catalog/scope-state.d.ts +35 -0
- package/dist/catalog/scope-state.js +87 -0
- package/dist/catalog/scope-sync-workers.d.ts +7 -0
- package/dist/catalog/scope-sync-workers.js +29 -0
- package/dist/catalog/scope-sync.d.ts +176 -0
- package/dist/catalog/scope-sync.js +576 -0
- package/dist/catalog/scope.d.ts +42 -0
- package/dist/catalog/scope.js +42 -0
- package/dist/catalog/unshare.d.ts +22 -0
- package/dist/catalog/unshare.js +118 -0
- package/dist/channels/actions.js +1 -0
- package/dist/channels/cards.js +20 -2
- package/dist/channels/channels.module.js +2 -0
- package/dist/channels/inbound.d.ts +9 -1
- package/dist/channels/inbound.js +67 -5
- package/dist/channels/phrases.d.ts +35 -0
- package/dist/channels/phrases.js +29 -0
- package/dist/config/docs.js +3 -1
- package/dist/config/schema.d.ts +10 -2
- package/dist/config/schema.js +70 -22
- package/dist/conversations/access.d.ts +6 -4
- package/dist/conversations/access.js +27 -5
- package/dist/conversations/agent-tree.d.ts +46 -0
- package/dist/conversations/agent-tree.js +92 -0
- package/dist/conversations/conversations.controller.d.ts +43 -18
- package/dist/conversations/conversations.controller.js +79 -38
- package/dist/conversations/conversations.module.d.ts +1 -1
- package/dist/conversations/conversations.module.js +7 -7
- package/dist/conversations/conversations.service.d.ts +73 -15
- package/dist/conversations/conversations.service.js +115 -35
- package/dist/conversations/environment-status.d.ts +24 -0
- package/dist/conversations/environment-status.js +71 -0
- package/dist/conversations/event-log.d.ts +20 -5
- package/dist/conversations/event-log.js +60 -0
- package/dist/conversations/events.d.ts +84 -2
- package/dist/conversations/events.js +91 -17
- package/dist/conversations/queue.service.d.ts +1 -1
- package/dist/conversations/queue.service.js +5 -0
- package/dist/conversations/titles.d.ts +5 -3
- package/dist/conversations/titles.js +21 -8
- package/dist/conversations/tree.d.ts +17 -0
- package/dist/conversations/tree.js +42 -0
- package/dist/ctx/create-ctx.d.ts +20 -1
- package/dist/ctx/create-ctx.js +38 -7
- package/dist/db/kernel-schema.d.ts +386 -18
- package/dist/environments/access.d.ts +41 -0
- package/dist/environments/access.js +77 -0
- package/dist/environments/conversation-environments.d.ts +61 -0
- package/dist/environments/conversation-environments.js +170 -0
- package/dist/environments/dto.d.ts +25 -0
- package/dist/environments/dto.js +12 -0
- package/dist/environments/environments.controller.d.ts +33 -0
- package/dist/environments/environments.controller.js +110 -0
- package/dist/environments/environments.module.d.ts +8 -0
- package/dist/environments/environments.module.js +27 -0
- package/dist/environments/environments.service.d.ts +153 -0
- package/dist/environments/environments.service.js +541 -0
- package/dist/environments/legacy-cleanup.job.d.ts +34 -0
- package/dist/environments/legacy-cleanup.job.js +141 -0
- package/dist/errors.d.ts +85 -2
- package/dist/errors.js +85 -2
- package/dist/evals/reconstruct.d.ts +18 -9
- package/dist/evals/reconstruct.js +26 -7
- package/dist/evals/run-replay.d.ts +4 -2
- package/dist/evals/run-replay.js +20 -6
- package/dist/evals/runs.service.d.ts +2 -1
- package/dist/evals/runs.service.js +13 -12
- package/dist/evals/step-replay.d.ts +4 -6
- package/dist/evals/step-replay.js +4 -3
- package/dist/evals/trajectory.service.d.ts +8 -3
- package/dist/evals/trajectory.service.js +26 -14
- package/dist/evals/worker.d.ts +5 -5
- package/dist/evals/worker.js +9 -3
- package/dist/extensions/admin-ops.d.ts +36 -10
- package/dist/extensions/admin-ops.js +65 -42
- package/dist/extensions/admin-view.d.ts +37 -10
- package/dist/extensions/admin-view.js +103 -20
- package/dist/extensions/bootstrap.d.ts +17 -4
- package/dist/extensions/bootstrap.js +70 -9
- package/dist/extensions/cli.d.ts +12 -0
- package/dist/extensions/cli.js +11 -2
- package/dist/extensions/config-hash.d.ts +10 -0
- package/dist/extensions/config-hash.js +38 -0
- package/dist/extensions/deployment-config.d.ts +28 -5
- package/dist/extensions/deployment-config.js +48 -7
- package/dist/extensions/effective-config.d.ts +127 -0
- package/dist/extensions/effective-config.js +368 -0
- package/dist/extensions/extensions.module.js +11 -11
- package/dist/extensions/hooks.d.ts +37 -4
- package/dist/extensions/hooks.js +82 -16
- package/dist/extensions/host.d.ts +24 -10
- package/dist/extensions/host.js +49 -54
- package/dist/extensions/installs.d.ts +20 -8
- package/dist/extensions/installs.js +37 -15
- package/dist/extensions/org-config.d.ts +75 -6
- package/dist/extensions/org-config.js +184 -32
- package/dist/extensions/org-levels.d.ts +37 -0
- package/dist/extensions/org-levels.js +71 -0
- package/dist/extensions/org-overrides.d.ts +151 -0
- package/dist/extensions/org-overrides.js +524 -0
- package/dist/extensions/permission-view.d.ts +16 -4
- package/dist/extensions/permission-view.js +4 -4
- package/dist/extensions/plugin-items.d.ts +21 -0
- package/dist/extensions/plugin-items.js +42 -0
- package/dist/extensions/point-defaults.d.ts +12 -5
- package/dist/extensions/point-defaults.js +37 -9
- package/dist/extensions/resolve.d.ts +5 -1
- package/dist/extensions/resolve.js +15 -2
- package/dist/extensions/state.module.d.ts +9 -0
- package/dist/extensions/state.module.js +38 -0
- package/dist/files/previewers.d.ts +8 -1
- package/dist/files/previewers.js +35 -6
- package/dist/http/api.module.js +25 -3
- package/dist/http/app.d.ts +11 -2
- package/dist/http/app.js +31 -5
- package/dist/http/plugin-dispatch.d.ts +4 -1
- package/dist/http/plugin-dispatch.js +14 -2
- package/dist/identity/accounts.d.ts +29 -29
- package/dist/identity/accounts.js +47 -47
- package/dist/identity/audit.d.ts +2 -1
- package/dist/identity/auth.guard.d.ts +13 -5
- package/dist/identity/auth.guard.js +26 -9
- package/dist/identity/identity.module.d.ts +1 -1
- package/dist/identity/identity.module.js +4 -4
- package/dist/identity/me.controller.js +1 -1
- package/dist/identity/principal.d.ts +3 -3
- package/dist/identity/principal.js +3 -3
- package/dist/identity/settings.d.ts +22 -11
- package/dist/identity/settings.js +53 -18
- package/dist/identity/{enterprise-admin.d.ts → super-admin.d.ts} +5 -5
- package/dist/identity/{enterprise-admin.js → super-admin.js} +24 -24
- package/dist/inbox/inbox.module.d.ts +4 -1
- package/dist/inbox/inbox.module.js +7 -3
- package/dist/inbox/inbox.service.d.ts +62 -3
- package/dist/inbox/inbox.service.js +74 -4
- package/dist/inbox/org-notices.d.ts +63 -0
- package/dist/inbox/org-notices.js +91 -0
- package/dist/inbox/platform-inbox.controller.d.ts +23 -0
- package/dist/inbox/platform-inbox.controller.js +58 -0
- package/dist/inbox/platform-inbox.service.d.ts +151 -0
- package/dist/inbox/platform-inbox.service.js +263 -0
- package/dist/inbox/platform-notices.d.ts +19 -0
- package/dist/inbox/platform-notices.js +9 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/infra/cli/kernel-cli.module.js +9 -1
- package/dist/infra/config/kernel-config.service.js +24 -1
- package/dist/infra/database/xact-lock.d.ts +1 -1
- package/dist/infra/database/xact-lock.js +1 -1
- package/dist/infra/events/kernel-events.d.ts +19 -2
- package/dist/infra/queue/add-job-once.d.ts +14 -0
- package/dist/infra/queue/add-job-once.js +16 -0
- package/dist/kernel.module.js +6 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +1 -1
- package/dist/lifecycle/kernel-lifecycle.js +4 -4
- package/dist/models/embeddings.d.ts +82 -0
- package/dist/models/embeddings.js +326 -0
- package/dist/models/enablement.controller.d.ts +40 -0
- package/dist/models/enablement.controller.js +74 -0
- package/dist/models/enablement.d.ts +99 -0
- package/dist/models/enablement.js +263 -0
- package/dist/models/models.module.d.ts +5 -1
- package/dist/models/models.module.js +16 -4
- package/dist/models/prices.d.ts +5 -5
- package/dist/models/prices.js +4 -4
- package/dist/models/purposes.controller.d.ts +6 -4
- package/dist/models/purposes.controller.js +13 -7
- package/dist/models/purposes.d.ts +37 -12
- package/dist/models/purposes.js +63 -17
- package/dist/orgs/directory-sync.d.ts +14 -5
- package/dist/orgs/directory-sync.js +41 -17
- package/dist/orgs/offboarding.d.ts +9 -7
- package/dist/orgs/offboarding.js +28 -17
- package/dist/orgs/org-lock.d.ts +5 -0
- package/dist/orgs/org-lock.js +13 -0
- package/dist/orgs/org.guard.d.ts +10 -0
- package/dist/orgs/org.guard.js +43 -32
- package/dist/orgs/orgs.module.js +3 -0
- package/dist/orgs/orgs.service.d.ts +20 -7
- package/dist/orgs/orgs.service.js +32 -12
- package/dist/orgs/roles.d.ts +1 -1
- package/dist/orgs/roles.js +5 -1
- package/dist/orgs/settings.controller.d.ts +1 -1
- package/dist/orgs/settings.service.d.ts +15 -3
- package/dist/orgs/settings.service.js +6 -2
- package/dist/overrides.d.ts +3 -0
- package/dist/overrides.js +2 -0
- package/dist/platform/actor.d.ts +48 -0
- package/dist/platform/actor.js +100 -0
- package/dist/platform/agent-docs.d.ts +18 -0
- package/dist/platform/agent-docs.js +59 -0
- package/dist/platform/availability.d.ts +14 -0
- package/dist/platform/availability.js +43 -0
- package/dist/platform/errors.d.ts +11 -0
- package/dist/platform/errors.js +26 -0
- package/dist/platform/exclusions.d.ts +12 -0
- package/dist/platform/exclusions.js +1405 -0
- package/dist/platform/method.d.ts +6 -0
- package/dist/platform/method.js +15 -0
- package/dist/platform/operation.d.ts +92 -0
- package/dist/platform/operation.js +35 -0
- package/dist/platform/ops/agent-templates.ops.d.ts +14 -0
- package/dist/platform/ops/agent-templates.ops.js +92 -0
- package/dist/platform/ops/agents.ops.d.ts +19 -0
- package/dist/platform/ops/agents.ops.js +294 -0
- package/dist/platform/ops/connectors.ops.d.ts +15 -0
- package/dist/platform/ops/connectors.ops.js +126 -0
- package/dist/platform/ops/errors.d.ts +11 -0
- package/dist/platform/ops/errors.js +22 -0
- package/dist/platform/ops/extensions.ops.d.ts +19 -0
- package/dist/platform/ops/extensions.ops.js +116 -0
- package/dist/platform/ops/marketplaces.ops.d.ts +16 -0
- package/dist/platform/ops/marketplaces.ops.js +157 -0
- package/dist/platform/ops/paging.d.ts +14 -0
- package/dist/platform/ops/paging.js +20 -0
- package/dist/platform/ops/platform.ops.d.ts +23 -0
- package/dist/platform/ops/platform.ops.js +158 -0
- package/dist/platform/ops/plugins.ops.d.ts +33 -0
- package/dist/platform/ops/plugins.ops.js +377 -0
- package/dist/platform/ops/requests.ops.d.ts +14 -0
- package/dist/platform/ops/requests.ops.js +153 -0
- package/dist/platform/ops/role.d.ts +4 -0
- package/dist/platform/ops/role.js +10 -0
- package/dist/platform/ops/skills.ops.d.ts +13 -0
- package/dist/platform/ops/skills.ops.js +98 -0
- package/dist/platform/ops/summary.d.ts +10 -0
- package/dist/platform/ops/summary.js +18 -0
- package/dist/platform/platform-ops.module.d.ts +7 -0
- package/dist/platform/platform-ops.module.js +55 -0
- package/dist/platform/platform.module.d.ts +8 -0
- package/dist/platform/platform.module.js +25 -0
- package/dist/platform/redact-orgs.d.ts +7 -0
- package/dist/platform/redact-orgs.js +52 -0
- package/dist/platform/registry.d.ts +30 -0
- package/dist/platform/registry.js +111 -0
- package/dist/roles/worker-role.d.ts +6 -4
- package/dist/roles/worker-role.js +14 -7
- package/dist/roles/worker.module.d.ts +1 -1
- package/dist/roles/worker.module.js +9 -1
- package/dist/runtime/context/build.d.ts +6 -4
- package/dist/runtime/context/build.js +26 -7
- package/dist/runtime/context/claude-tools.d.ts +2 -1
- package/dist/runtime/context/claude-tools.js +5 -4
- package/dist/runtime/context/compaction.js +9 -0
- package/dist/runtime/context/reminders.d.ts +2 -0
- package/dist/runtime/context/reminders.js +2 -0
- package/dist/runtime/context/skills.js +9 -2
- package/dist/runtime/context/tool-changes.d.ts +27 -0
- package/dist/runtime/context/tool-changes.js +60 -0
- package/dist/runtime/hook-calls.d.ts +8 -1
- package/dist/runtime/hook-calls.js +40 -7
- package/dist/runtime/langgraph-loop.d.ts +3 -1
- package/dist/runtime/langgraph-loop.js +35 -17
- package/dist/runtime/loop.d.ts +32 -4
- package/dist/runtime/maintenance.d.ts +7 -4
- package/dist/runtime/maintenance.js +23 -8
- package/dist/runtime/model-call.d.ts +38 -11
- package/dist/runtime/model-call.js +97 -24
- package/dist/runtime/providers.d.ts +146 -32
- package/dist/runtime/providers.js +321 -67
- package/dist/runtime/run-control.d.ts +11 -1
- package/dist/runtime/run-control.js +12 -0
- package/dist/runtime/run-drafts.d.ts +85 -0
- package/dist/runtime/run-drafts.js +230 -0
- package/dist/runtime/run-jobs.d.ts +3 -5
- package/dist/runtime/run-jobs.js +3 -7
- package/dist/runtime/run-queue.d.ts +37 -3
- package/dist/runtime/run-queue.js +188 -11
- package/dist/runtime/run-worker.d.ts +12 -6
- package/dist/runtime/run-worker.js +58 -35
- package/dist/runtime/runtime.module.js +3 -0
- package/dist/runtime/step-log.d.ts +9 -4
- package/dist/runtime/step-log.js +8 -5
- package/dist/runtime/stream.controller.d.ts +23 -1
- package/dist/runtime/stream.controller.js +60 -3
- package/dist/runtime/stream.d.ts +4 -1
- package/dist/runtime/stream.js +27 -3
- package/dist/runtime/subagents/child.d.ts +55 -7
- package/dist/runtime/subagents/child.js +105 -7
- package/dist/runtime/subagents/definition.d.ts +12 -3
- package/dist/runtime/subagents/definition.js +46 -32
- package/dist/runtime/subagents/deliveries.d.ts +71 -0
- package/dist/runtime/subagents/deliveries.js +228 -0
- package/dist/runtime/subagents/dispatch.d.ts +115 -26
- package/dist/runtime/subagents/dispatch.js +212 -141
- package/dist/runtime/subagents/limits.d.ts +24 -5
- package/dist/runtime/subagents/limits.js +40 -6
- package/dist/runtime/subagents/messages.d.ts +95 -0
- package/dist/runtime/subagents/messages.js +328 -0
- package/dist/runtime/subagents/preamble.d.ts +4 -4
- package/dist/runtime/subagents/preamble.js +9 -7
- package/dist/runtime/subagents/progress.d.ts +8 -6
- package/dist/runtime/subagents/progress.js +11 -6
- package/dist/runtime/subagents/render.d.ts +30 -0
- package/dist/runtime/subagents/render.js +53 -0
- package/dist/runtime/subagents/roster.d.ts +24 -7
- package/dist/runtime/subagents/roster.js +47 -11
- package/dist/runtime/subagents/skill-fork.d.ts +3 -2
- package/dist/runtime/subagents/skill-fork.js +8 -4
- package/dist/runtime/subagents/status.d.ts +14 -0
- package/dist/runtime/subagents/status.js +23 -0
- package/dist/runtime/subagents/subagents.service.d.ts +7 -4
- package/dist/runtime/subagents/subagents.service.js +11 -6
- package/dist/runtime/usage-report-jobs.d.ts +88 -0
- package/dist/runtime/usage-report-jobs.js +158 -0
- package/dist/runtime/usage-report.d.ts +33 -38
- package/dist/runtime/usage-report.js +169 -96
- package/dist/runtime/waits.d.ts +140 -37
- package/dist/runtime/waits.js +394 -106
- package/dist/sandbox/jobs.d.ts +40 -13
- package/dist/sandbox/jobs.js +57 -20
- package/dist/sandbox/leases.d.ts +37 -54
- package/dist/sandbox/leases.js +71 -115
- package/dist/sandbox/providers.d.ts +2 -2
- package/dist/sandbox/providers.js +1 -1
- package/dist/sandbox/sandbox.module.d.ts +3 -2
- package/dist/sandbox/sandbox.module.js +4 -3
- package/dist/sandbox/sandbox.service.d.ts +229 -134
- package/dist/sandbox/sandbox.service.js +630 -409
- package/dist/skills/catalog.d.ts +3 -2
- package/dist/skills/catalog.js +21 -43
- package/dist/skills/changes.controller.d.ts +7 -0
- package/dist/skills/changes.controller.js +19 -1
- package/dist/skills/invoke.js +8 -3
- package/dist/skills/package.d.ts +20 -1
- package/dist/skills/package.js +28 -1
- package/dist/skills/skills.controller.d.ts +39 -4
- package/dist/skills/skills.controller.js +88 -10
- package/dist/skills/skills.module.js +10 -1
- package/dist/skills/skills.service.d.ts +106 -26
- package/dist/skills/skills.service.js +421 -75
- package/dist/skills/usable.d.ts +81 -0
- package/dist/skills/usable.js +379 -0
- package/dist/tools/approvals.service.d.ts +20 -2
- package/dist/tools/approvals.service.js +23 -4
- package/dist/tools/builtin-names.d.ts +21 -5
- package/dist/tools/builtin-names.js +30 -5
- package/dist/tools/builtins/agent.d.ts +23 -21
- package/dist/tools/builtins/agent.js +62 -55
- package/dist/tools/builtins/builtin-tools.d.ts +6 -2
- package/dist/tools/builtins/builtin-tools.js +37 -12
- package/dist/tools/builtins/handback.d.ts +28 -0
- package/dist/tools/builtins/handback.js +53 -0
- package/dist/tools/builtins/platform.d.ts +34 -0
- package/dist/tools/builtins/platform.js +362 -0
- package/dist/tools/builtins/sandbox/bash.js +13 -3
- package/dist/tools/builtins/sandbox/common.d.ts +43 -24
- package/dist/tools/builtins/sandbox/common.js +80 -45
- package/dist/tools/builtins/sandbox/edit.js +2 -2
- package/dist/tools/builtins/sandbox/glob.js +2 -2
- package/dist/tools/builtins/sandbox/grep.js +2 -4
- package/dist/tools/builtins/sandbox/index.d.ts +1 -1
- package/dist/tools/builtins/sandbox/index.js +1 -1
- package/dist/tools/builtins/sandbox/read.js +1 -1
- package/dist/tools/builtins/sandbox/task-output.d.ts +14 -3
- package/dist/tools/builtins/sandbox/task-output.js +30 -5
- package/dist/tools/builtins/sandbox/task-stop.js +2 -1
- package/dist/tools/builtins/sandbox/write.js +2 -2
- package/dist/tools/builtins/send-message.d.ts +56 -0
- package/dist/tools/builtins/send-message.js +100 -0
- package/dist/tools/builtins/skill-load.d.ts +22 -14
- package/dist/tools/builtins/skill-load.js +86 -57
- package/dist/tools/builtins/skill-write.js +1 -1
- package/dist/tools/builtins/web/extract.js +5 -1
- package/dist/tools/builtins/web/fetch.js +1 -0
- package/dist/tools/builtins/web/search.js +1 -0
- package/dist/tools/connectors.controller.d.ts +10 -0
- package/dist/tools/connectors.controller.js +12 -0
- package/dist/tools/connectors.service.d.ts +46 -5
- package/dist/tools/connectors.service.js +94 -15
- package/dist/tools/extension-tools.controller.d.ts +14 -0
- package/dist/tools/extension-tools.controller.js +37 -0
- package/dist/tools/info.d.ts +42 -1
- package/dist/tools/info.js +64 -1
- package/dist/tools/org-tool-switches.d.ts +74 -0
- package/dist/tools/org-tool-switches.js +184 -0
- package/dist/tools/pipeline.d.ts +46 -40
- package/dist/tools/pipeline.js +193 -364
- package/dist/tools/policy.d.ts +1 -1
- package/dist/tools/policy.js +36 -16
- package/dist/tools/registry.d.ts +98 -5
- package/dist/tools/registry.js +87 -9
- package/dist/tools/tools.module.js +12 -2
- package/dist/ui/views.d.ts +2 -1
- package/dist/ui/views.js +17 -3
- package/package.json +3 -3
- package/src/migrations/0074_subagent_tree.sql +50 -0
- package/src/migrations/0075_plugin_scope.sql +61 -0
- package/src/migrations/0076_skills_created_by_nullable.sql +6 -0
- package/src/migrations/0077_scope_requests.sql +52 -0
- package/src/migrations/0078_scope_grant_switches.sql +18 -0
- package/src/migrations/0079_scope_live_install_switches.sql +19 -0
- package/src/migrations/0080_rename_enterprise_admin.sql +18 -0
- package/src/migrations/0081_platform_components.sql +129 -0
- package/src/migrations/0082_platform_migration.sql +33 -0
- package/src/migrations/0083_plugin_scope_sync_failures.sql +15 -0
- package/src/migrations/0084_org_owned_items.sql +85 -0
- package/src/migrations/0085_agent_templates_phase4.sql +45 -0
- package/src/migrations/0086_org_layering.sql +30 -0
- package/src/migrations/0087_approval_summary.sql +6 -0
- package/src/migrations/0088_environments.sql +80 -0
- package/src/migrations/0089_model_kinds_usage.sql +38 -0
- package/dist/catalog/upgrade-targets.d.ts +0 -56
- package/dist/catalog/upgrade-targets.js +0 -90
- package/dist/conversations/sandbox-status.d.ts +0 -24
- package/dist/conversations/sandbox-status.js +0 -52
- package/dist/extensions/org-config.controller.d.ts +0 -32
- package/dist/extensions/org-config.controller.js +0 -70
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// Turning 可共享 off on an org-owned item (ruling P3-25): an `optional` / `all` scope is narrowed, in
|
|
2
|
+
// the caller's transaction, to `named` = the owner plus every live org where the item is on right
|
|
3
|
+
// now, so the orgs already associated keep it and no new org can see, switch on or request it
|
|
4
|
+
// (§14.1 item 3). A `named` scope is left as it is: the gate in `requestable` and the writers
|
|
5
|
+
// already holds back new orgs there.
|
|
6
|
+
import { sql } from "kysely";
|
|
7
|
+
import { audit } from "../identity/audit.js";
|
|
8
|
+
import { componentOn, listedIn, loadScopeState, pluginFactsOf, switchOf, } from "./component-state.js";
|
|
9
|
+
const LIVE_INSTALL = ["installing", "installed", "upgrading"];
|
|
10
|
+
async function liveOrgIds(db) {
|
|
11
|
+
const rows = await db.selectFrom("orgs").select("id").where("deleted_at", "is", null).execute();
|
|
12
|
+
return rows.map((r) => r.id);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Narrows an org-owned plugin (row locked by the caller) whose scope is `optional` / `all` to
|
|
16
|
+
* `named` = owner + the live orgs with a live install or a switch on. Bumps `scope_version` and
|
|
17
|
+
* audits `catalog.scope_changed`; returns whether the scope changed (the caller enqueues the item's
|
|
18
|
+
* scope sync after the commit).
|
|
19
|
+
*/
|
|
20
|
+
export async function narrowItemOnUnshare(db, actor, item) {
|
|
21
|
+
if (item.owner_org_id === null || item.scope === "named")
|
|
22
|
+
return false;
|
|
23
|
+
const live = new Set(await liveOrgIds(db));
|
|
24
|
+
const installs = await db
|
|
25
|
+
.selectFrom("plugin_installs")
|
|
26
|
+
.select("org_id")
|
|
27
|
+
.where("item_id", "=", item.id)
|
|
28
|
+
.where("status", "in", [...LIVE_INSTALL])
|
|
29
|
+
.execute();
|
|
30
|
+
const switches = await db
|
|
31
|
+
.selectFrom("catalog_item_org_switches")
|
|
32
|
+
.select("org_id")
|
|
33
|
+
.where("item_id", "=", item.id)
|
|
34
|
+
.where("enabled", "=", true)
|
|
35
|
+
.execute();
|
|
36
|
+
const orgs = [
|
|
37
|
+
...new Set([
|
|
38
|
+
item.owner_org_id,
|
|
39
|
+
...[...installs, ...switches].map((r) => r.org_id).filter((o) => live.has(o)),
|
|
40
|
+
]),
|
|
41
|
+
].sort();
|
|
42
|
+
await db
|
|
43
|
+
.updateTable("catalog_items")
|
|
44
|
+
.set({
|
|
45
|
+
scope: "named",
|
|
46
|
+
scope_version: sql `scope_version + 1`,
|
|
47
|
+
updated_at: sql `now()`,
|
|
48
|
+
})
|
|
49
|
+
.where("id", "=", item.id)
|
|
50
|
+
.execute();
|
|
51
|
+
await db.deleteFrom("catalog_item_scope_orgs").where("item_id", "=", item.id).execute();
|
|
52
|
+
await db
|
|
53
|
+
.insertInto("catalog_item_scope_orgs")
|
|
54
|
+
.values(orgs.map((org_id) => ({ item_id: item.id, org_id })))
|
|
55
|
+
.execute();
|
|
56
|
+
await audit(db, {
|
|
57
|
+
...(actor !== null && { actorAccountId: actor }),
|
|
58
|
+
action: "catalog.scope_changed",
|
|
59
|
+
target: item.id,
|
|
60
|
+
detail: {
|
|
61
|
+
name: item.name,
|
|
62
|
+
from: { scope: item.scope, orgs: [] },
|
|
63
|
+
to: { scope: "named", orgs },
|
|
64
|
+
reason: "unshared",
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Narrows an org-owned component with its own `optional` / `all` scope (row locked by the caller)
|
|
71
|
+
* to `named` = owner + the live orgs where it is on now ({@link componentOn}). A component that
|
|
72
|
+
* follows its plugin is narrowed with the plugin. Bumps `scope_version`, audits
|
|
73
|
+
* `component.scope_changed`.
|
|
74
|
+
*/
|
|
75
|
+
export async function narrowComponentOnUnshare(db, actor, c) {
|
|
76
|
+
if (c.ownerOrgId === null || c.scopeMode !== "own" || c.scope === "named")
|
|
77
|
+
return false;
|
|
78
|
+
const st = await loadScopeState(db, c.kind, [c]);
|
|
79
|
+
const on = (await liveOrgIds(db)).filter((o) => componentOn(c, pluginFactsOf(st, c.itemId, o), listedIn(st, c.id, o), switchOf(st, c.id, o)));
|
|
80
|
+
const orgs = [...new Set([c.ownerOrgId, ...on])].sort();
|
|
81
|
+
await db
|
|
82
|
+
.updateTable(TABLE[c.kind])
|
|
83
|
+
.set({
|
|
84
|
+
scope: "named",
|
|
85
|
+
scope_version: sql `scope_version + 1`,
|
|
86
|
+
updated_at: sql `now()`,
|
|
87
|
+
})
|
|
88
|
+
.where("id", "=", c.id)
|
|
89
|
+
.execute();
|
|
90
|
+
await db
|
|
91
|
+
.deleteFrom("component_scope_orgs")
|
|
92
|
+
.where("kind", "=", c.kind)
|
|
93
|
+
.where("component_id", "=", c.id)
|
|
94
|
+
.execute();
|
|
95
|
+
await db
|
|
96
|
+
.insertInto("component_scope_orgs")
|
|
97
|
+
.values(orgs.map((org_id) => ({ kind: c.kind, component_id: c.id, org_id })))
|
|
98
|
+
.execute();
|
|
99
|
+
await audit(db, {
|
|
100
|
+
...(actor !== null && { actorAccountId: actor }),
|
|
101
|
+
action: "component.scope_changed",
|
|
102
|
+
target: c.id,
|
|
103
|
+
detail: {
|
|
104
|
+
kind: c.kind,
|
|
105
|
+
name: c.name,
|
|
106
|
+
plugin: c.plugin,
|
|
107
|
+
from: { scopeMode: "own", scope: c.scope, orgs: [] },
|
|
108
|
+
to: { scopeMode: "own", scope: "named", orgs },
|
|
109
|
+
reason: "unshared",
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
const TABLE = {
|
|
115
|
+
skill: "platform_skills",
|
|
116
|
+
agent_template: "platform_agent_templates",
|
|
117
|
+
connector_template: "platform_connector_templates",
|
|
118
|
+
};
|
package/dist/channels/actions.js
CHANGED
|
@@ -11,6 +11,7 @@ const REPLY_FOR = {
|
|
|
11
11
|
"approval.already_decided": "alreadyHandled",
|
|
12
12
|
"question.already_answered": "alreadyHandled",
|
|
13
13
|
validation_failed: "invalidAction",
|
|
14
|
+
"approval.scope_not_allowed": "invalidAction",
|
|
14
15
|
};
|
|
15
16
|
/**
|
|
16
17
|
* IM 卡片上的按钮操作(Review Focus 2):点击者按入站同样的规则映射到账号(未绑定 → 私聊回绑定卡片、群里只提示去私聊),
|
package/dist/channels/cards.js
CHANGED
|
@@ -76,6 +76,18 @@ export function inputPreview(input, redact = (s) => s) {
|
|
|
76
76
|
}
|
|
77
77
|
return s.length <= INPUT_PREVIEW_MAX ? s : `${s.slice(0, INPUT_PREVIEW_MAX - 1)}…`;
|
|
78
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* The card's input line: the kernel-rendered summary of the call (Platform operations) in the
|
|
81
|
+
* card's language first, then the params; the card has no separate summary field.
|
|
82
|
+
*/
|
|
83
|
+
function previewWithSummary(v, locale, redact) {
|
|
84
|
+
const params = inputPreview(v.input, redact);
|
|
85
|
+
if (v.summary === null)
|
|
86
|
+
return params;
|
|
87
|
+
const text = redact ? redact(v.summary[locale]) : v.summary[locale];
|
|
88
|
+
const summary = text.length <= INPUT_PREVIEW_MAX ? text : `${text.slice(0, INPUT_PREVIEW_MAX - 1)}…`;
|
|
89
|
+
return `${summary}\n${params}`;
|
|
90
|
+
}
|
|
79
91
|
/** 去掉末尾斜杠的 `http.publicUrl`;未配置返回 undefined。 */
|
|
80
92
|
export function webBase(publicUrl) {
|
|
81
93
|
return publicUrl ? publicUrl.replace(/\/+$/, "") : undefined;
|
|
@@ -84,12 +96,17 @@ export function webBase(publicUrl) {
|
|
|
84
96
|
export const conversationUrl = (base, conversationId) => `${base}/chat/${conversationId}`;
|
|
85
97
|
/** 个人连接页里某个连接器的位置(与网页 ConnectCard 的链接一致)。 */
|
|
86
98
|
export const connectUrl = (base, connectorId) => `${base}/account/connections#connector-${encodeURIComponent(connectorId)}`;
|
|
99
|
+
const PLATFORM_KEY_PREFIX = "Platform:";
|
|
87
100
|
/**
|
|
88
101
|
* The tool as the card names it (tool naming spec §7): a builtin by its name; a connector or
|
|
89
102
|
* extension tool as `<display name> [<tool>]` (the connector's name, the plugin's display name in
|
|
90
103
|
* the card's language), the way the web labels it.
|
|
91
104
|
*/
|
|
92
105
|
export function approvalToolName(v, locale) {
|
|
106
|
+
// a Platform call is keyed `Platform:<operation>`: the label names the operation
|
|
107
|
+
if (v.toolKey.startsWith(PLATFORM_KEY_PREFIX)) {
|
|
108
|
+
return `Platform [${v.toolKey.slice(PLATFORM_KEY_PREFIX.length)}]`;
|
|
109
|
+
}
|
|
93
110
|
// `toolName` is already the connector's own name for its tool
|
|
94
111
|
if (v.connector)
|
|
95
112
|
return `${v.connector.name} [${v.toolName}]`;
|
|
@@ -126,8 +143,9 @@ export async function approvalCard(d, approvalId, base, locale, redact) {
|
|
|
126
143
|
// the label carries the source, so no separate appName (renderers would repeat it)
|
|
127
144
|
toolName: approvalToolName(v, locale),
|
|
128
145
|
agentName: v.agent.name || "Agent",
|
|
129
|
-
inputPreview:
|
|
130
|
-
scopes
|
|
146
|
+
inputPreview: previewWithSummary(v, locale, redact),
|
|
147
|
+
// the scopes the approval allows (the kernel stores them for per-call policies)
|
|
148
|
+
scopes: v.scopes,
|
|
131
149
|
expiresAt: v.expiresAt,
|
|
132
150
|
state: v.status,
|
|
133
151
|
...(decidedBy !== undefined && { decidedBy }),
|
|
@@ -12,6 +12,7 @@ import { OnWorkerEvent, WorkerHost } from "@nestjs/bullmq";
|
|
|
12
12
|
import { Inject, Injectable, Module } from "@nestjs/common";
|
|
13
13
|
import { ConversationsModule } from "../conversations/conversations.module.js";
|
|
14
14
|
import { EventLogModule } from "../conversations/event-log.js";
|
|
15
|
+
import { EnvironmentsModule } from "../environments/environments.module.js";
|
|
15
16
|
import { ExtensionsModule } from "../extensions/extensions.module.js";
|
|
16
17
|
import { IdentityModule } from "../identity/identity.module.js";
|
|
17
18
|
import { configuredProcessor, } from "../infra/queue/configured-processor.js";
|
|
@@ -38,6 +39,7 @@ let ChannelsModule = class ChannelsModule {
|
|
|
38
39
|
ChannelsModule = __decorate([
|
|
39
40
|
Module({
|
|
40
41
|
imports: [
|
|
42
|
+
EnvironmentsModule,
|
|
41
43
|
EventLogModule,
|
|
42
44
|
ExtensionsModule,
|
|
43
45
|
IdentityModule,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ChannelCard, InboundEvent, InboundSender, Logger } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import type { Redis } from "ioredis";
|
|
3
3
|
import { ConversationsService } from "../conversations/conversations.service.js";
|
|
4
|
+
import { EnvironmentsService } from "../environments/environments.service.js";
|
|
4
5
|
import { IdentityBinding } from "../identity/binding.js";
|
|
5
6
|
import { ExternalIdentities } from "../identity/external.js";
|
|
6
7
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
@@ -62,6 +63,7 @@ export declare class ChannelInbound {
|
|
|
62
63
|
/** The channel queue: inbound jobs (`onEvent` only dedupes and enqueues) and deliveries. */
|
|
63
64
|
private readonly jobs;
|
|
64
65
|
private readonly guests;
|
|
66
|
+
private readonly environments;
|
|
65
67
|
private readonly log;
|
|
66
68
|
private readonly actions;
|
|
67
69
|
constructor(kdb: KernelDb, redis: Pick<Redis, "set">,
|
|
@@ -72,7 +74,7 @@ export declare class ChannelInbound {
|
|
|
72
74
|
/** The channel queue: inbound jobs (`onEvent` only dedupes and enqueues) and deliveries. */
|
|
73
75
|
jobs: Pick<ChannelJobs, "enqueue" | "enqueueInbound">,
|
|
74
76
|
/** 卡片操作:审批决定与提问回答(授权由这两个服务按点击者映射到的账号判定)。 */
|
|
75
|
-
approvals: Pick<ApprovalsService, "decide">, questions: Pick<QuestionsService, "answer">, guests: Pick<AnonymousGuests, "ensure">, log: Pick<Logger, "warn" | "info">);
|
|
77
|
+
approvals: Pick<ApprovalsService, "decide">, questions: Pick<QuestionsService, "answer">, guests: Pick<AnonymousGuests, "ensure">, environments: Pick<EnvironmentsService, "list" | "imDefault" | "setImDefault">, log: Pick<Logger, "warn" | "info">);
|
|
76
78
|
/**
|
|
77
79
|
* 插件 `onEvent`:去重并入队后返回(见类注释)。返回后插件才向平台确认;抛错时插件不确认。
|
|
78
80
|
*/
|
|
@@ -92,6 +94,12 @@ export declare class ChannelInbound {
|
|
|
92
94
|
/** 入站任务的处理(worker 上执行;失败抛错由队列重试)。 */
|
|
93
95
|
handle(connectionId: string, e: InboundEvent): Promise<void>;
|
|
94
96
|
private message;
|
|
97
|
+
/**
|
|
98
|
+
* Direct-message `/env` (environments spec §4.2 item 8): lists the person's usable environments,
|
|
99
|
+
* or with a name sets the IM default their next new conversation is bound to. The name matches
|
|
100
|
+
* case-insensitively; the default environment (no name) answers to 个人环境 / Personal.
|
|
101
|
+
*/
|
|
102
|
+
private envCommand;
|
|
95
103
|
/**
|
|
96
104
|
* Posts the person's message: `/name args` as a skill invocation when the kernel accepts it, else
|
|
97
105
|
* as typed (phase D spec §9). A retry of the job finds the first write by `clientMessageId`
|
package/dist/channels/inbound.js
CHANGED
|
@@ -10,6 +10,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { randomUUID } from "node:crypto";
|
|
11
11
|
import { Inject, Injectable } from "@nestjs/common";
|
|
12
12
|
import { ConversationsService } from "../conversations/conversations.service.js";
|
|
13
|
+
import { EnvironmentsService } from "../environments/environments.service.js";
|
|
13
14
|
import { ApiError } from "../errors.js";
|
|
14
15
|
import { IdentityBinding } from "../identity/binding.js";
|
|
15
16
|
import { ExternalIdentities } from "../identity/external.js";
|
|
@@ -73,6 +74,7 @@ let ChannelInbound = class ChannelInbound {
|
|
|
73
74
|
directorySync;
|
|
74
75
|
jobs;
|
|
75
76
|
guests;
|
|
77
|
+
environments;
|
|
76
78
|
log;
|
|
77
79
|
actions;
|
|
78
80
|
constructor(kdb, redis,
|
|
@@ -83,7 +85,7 @@ let ChannelInbound = class ChannelInbound {
|
|
|
83
85
|
/** The channel queue: inbound jobs (`onEvent` only dedupes and enqueues) and deliveries. */
|
|
84
86
|
jobs,
|
|
85
87
|
/** 卡片操作:审批决定与提问回答(授权由这两个服务按点击者映射到的账号判定)。 */
|
|
86
|
-
approvals, questions, guests, log) {
|
|
88
|
+
approvals, questions, guests, environments, log) {
|
|
87
89
|
this.kdb = kdb;
|
|
88
90
|
this.redis = redis;
|
|
89
91
|
this.locks = locks;
|
|
@@ -94,6 +96,7 @@ let ChannelInbound = class ChannelInbound {
|
|
|
94
96
|
this.directorySync = directorySync;
|
|
95
97
|
this.jobs = jobs;
|
|
96
98
|
this.guests = guests;
|
|
99
|
+
this.environments = environments;
|
|
97
100
|
this.log = log;
|
|
98
101
|
this.actions = new ChannelCardActions({
|
|
99
102
|
get db() {
|
|
@@ -185,9 +188,10 @@ let ChannelInbound = class ChannelInbound {
|
|
|
185
188
|
const { locale } = await readOrgSettings(db, row.orgId);
|
|
186
189
|
// 回复带幂等键:任务重试时平台不会重复显示(一条消息至多一句回复)
|
|
187
190
|
const replyKey = idempotencyKey(`${connectionId}-${e.messageId}-reply`);
|
|
188
|
-
const
|
|
189
|
-
await connections.send(connectionId, replyTarget, { text
|
|
191
|
+
const replyText = async (text, cards) => {
|
|
192
|
+
await connections.send(connectionId, replyTarget, { text, ...(cards !== undefined && { cards }) }, replyKey);
|
|
190
193
|
};
|
|
194
|
+
const reply = (key, cards) => replyText(phrase(key, locale), cards);
|
|
191
195
|
const speaker = await this.resolveSpeaker(connectionId, row, e.sender, isGroup, locale, reply);
|
|
192
196
|
if (speaker === undefined)
|
|
193
197
|
return;
|
|
@@ -203,11 +207,19 @@ let ChannelInbound = class ChannelInbound {
|
|
|
203
207
|
await reply("newConversation");
|
|
204
208
|
return;
|
|
205
209
|
}
|
|
210
|
+
const envCommand = !isGroup && threadAccount !== null ? parseEnvCommand(e.text) : null;
|
|
211
|
+
if (envCommand !== null) {
|
|
212
|
+
await this.envCommand(row.orgId, accountId, envCommand.name, locale, replyText);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
206
215
|
let conversationId = await findThread(db, k);
|
|
207
216
|
if (conversationId === undefined) {
|
|
208
217
|
let created;
|
|
209
218
|
try {
|
|
210
|
-
|
|
219
|
+
// bound to the person's IM default environment, else their default (environments spec
|
|
220
|
+
// §4.2 item 8); an anonymous sender's stays unbound (no sandbox)
|
|
221
|
+
created = (await this.conversations.create(row.orgId, accountId, row.agentId, { im: true }))
|
|
222
|
+
.id;
|
|
211
223
|
}
|
|
212
224
|
catch (err) {
|
|
213
225
|
if (err instanceof ApiError && err.code === "agent.not_found") {
|
|
@@ -267,6 +279,47 @@ let ChannelInbound = class ChannelInbound {
|
|
|
267
279
|
.execute();
|
|
268
280
|
await this.jobs.enqueue(conversationId);
|
|
269
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* Direct-message `/env` (environments spec §4.2 item 8): lists the person's usable environments,
|
|
284
|
+
* or with a name sets the IM default their next new conversation is bound to. The name matches
|
|
285
|
+
* case-insensitively; the default environment (no name) answers to 个人环境 / Personal.
|
|
286
|
+
*/
|
|
287
|
+
async envCommand(orgId, accountId, name, locale, replyText) {
|
|
288
|
+
const { items, defaultId } = await this.environments.list(orgId, accountId);
|
|
289
|
+
const usable = items.filter((v) => v.available);
|
|
290
|
+
const labelOf = (v) => v.name ?? phrase("envPersonal", locale);
|
|
291
|
+
const current = (await this.environments.imDefault(orgId, accountId)) ?? defaultId;
|
|
292
|
+
const list = usable
|
|
293
|
+
.map((v) => `- ${labelOf(v)}${v.id === current ? phrase("envCurrent", locale) : ""}`)
|
|
294
|
+
.join("\n");
|
|
295
|
+
const fill = (key, vars) => phrase(key, locale).replace(/\{(\w+)\}/g, (m, k) => vars[k] ?? m);
|
|
296
|
+
if (usable.length === 0)
|
|
297
|
+
return replyText(phrase("envNone", locale));
|
|
298
|
+
if (name === null)
|
|
299
|
+
return replyText(fill("envList", { list }));
|
|
300
|
+
const wanted = name.toLowerCase();
|
|
301
|
+
// an environment the person named "Personal" wins over the default's alias
|
|
302
|
+
const hit = usable.find((v) => v.name !== null && v.name.toLowerCase() === wanted) ??
|
|
303
|
+
usable.find((v) => v.name === null && (wanted === "personal" || wanted === "个人环境"));
|
|
304
|
+
if (hit === undefined) {
|
|
305
|
+
const unavailable = items.find((v) => !v.available && v.name !== null && v.name.toLowerCase() === wanted);
|
|
306
|
+
if (unavailable !== undefined) {
|
|
307
|
+
return replyText(fill("envUnavailable", { name: unavailable.name, list }));
|
|
308
|
+
}
|
|
309
|
+
return replyText(fill("envUnknown", { name, list }));
|
|
310
|
+
}
|
|
311
|
+
try {
|
|
312
|
+
await this.environments.setImDefault(orgId, accountId, hit.id);
|
|
313
|
+
}
|
|
314
|
+
catch (err) {
|
|
315
|
+
// deleted or made unusable since the list was read
|
|
316
|
+
if (err instanceof ApiError && err.code.startsWith("environment.")) {
|
|
317
|
+
return replyText(fill("envUnknown", { name, list }));
|
|
318
|
+
}
|
|
319
|
+
throw err;
|
|
320
|
+
}
|
|
321
|
+
return replyText(fill("envSwitched", { name: labelOf(hit) }));
|
|
322
|
+
}
|
|
270
323
|
/**
|
|
271
324
|
* Posts the person's message: `/name args` as a skill invocation when the kernel accepts it, else
|
|
272
325
|
* as typed (phase D spec §9). A retry of the job finds the first write by `clientMessageId`
|
|
@@ -393,6 +446,15 @@ ChannelInbound = __decorate([
|
|
|
393
446
|
__param(9, Inject(ApprovalsService)),
|
|
394
447
|
__param(10, Inject(QuestionsService)),
|
|
395
448
|
__param(11, Inject(AnonymousGuests)),
|
|
396
|
-
__param(12, Inject(
|
|
449
|
+
__param(12, Inject(EnvironmentsService)),
|
|
450
|
+
__param(13, Inject(KERNEL_LOGGER))
|
|
397
451
|
], ChannelInbound);
|
|
398
452
|
export { ChannelInbound };
|
|
453
|
+
/** `/env` or `/env <name>` (the exact command word, case-insensitive); anything else is null. */
|
|
454
|
+
function parseEnvCommand(text) {
|
|
455
|
+
const m = /^\/env(?:\s+([\s\S]*))?$/i.exec(text.trim());
|
|
456
|
+
if (m === null)
|
|
457
|
+
return null;
|
|
458
|
+
const name = m[1]?.trim();
|
|
459
|
+
return { name: name ? name : null };
|
|
460
|
+
}
|
|
@@ -10,6 +10,41 @@ export declare const CHANNEL_PHRASES: {
|
|
|
10
10
|
readonly zh: "已开始新对话";
|
|
11
11
|
readonly en: "Started a new conversation.";
|
|
12
12
|
};
|
|
13
|
+
/** 私聊 `/env`:列出可用环境(`{list}` 每行一个,当前的带标记)。 */
|
|
14
|
+
readonly envList: {
|
|
15
|
+
readonly zh: "你的环境:\n{list}\n发送 /env <名称> 选择下一个新对话使用的环境。";
|
|
16
|
+
readonly en: "Your environments:\n{list}\nSend /env <name> to choose the one your next new conversation uses.";
|
|
17
|
+
};
|
|
18
|
+
/** 私聊 `/env <名称>` 之后(`{name}` 是环境名)。 */
|
|
19
|
+
readonly envSwitched: {
|
|
20
|
+
readonly zh: "下一个新对话将使用环境「{name}」,发送 /new 开始。";
|
|
21
|
+
readonly en: "Your next new conversation will use the environment “{name}”; send /new to start one.";
|
|
22
|
+
};
|
|
23
|
+
/** 私聊 `/env <名称>` 没有匹配的可用环境(`{list}` 同 envList)。 */
|
|
24
|
+
readonly envUnknown: {
|
|
25
|
+
readonly zh: "没有找到名为「{name}」的环境。你的环境:\n{list}";
|
|
26
|
+
readonly en: "No environment named “{name}”. Your environments:\n{list}";
|
|
27
|
+
};
|
|
28
|
+
/** `/env <name>` names an existing environment that is unavailable now (`{list}` as in envList). */
|
|
29
|
+
readonly envUnavailable: {
|
|
30
|
+
readonly zh: "环境「{name}」当前不可用(它的文件由未启用的沙箱提供方保存)。你的环境:\n{list}";
|
|
31
|
+
readonly en: "The environment “{name}” is unavailable: its files are kept by a sandbox provider that is not active. Your environments:\n{list}";
|
|
32
|
+
};
|
|
33
|
+
/** 私聊 `/env` 时此人没有可用环境(部署没有云沙箱)。 */
|
|
34
|
+
readonly envNone: {
|
|
35
|
+
readonly zh: "你目前没有可用的环境。";
|
|
36
|
+
readonly en: "You have no usable environments.";
|
|
37
|
+
};
|
|
38
|
+
/** 环境列表里默认环境的名字。 */
|
|
39
|
+
readonly envPersonal: {
|
|
40
|
+
readonly zh: "个人环境";
|
|
41
|
+
readonly en: "Personal";
|
|
42
|
+
};
|
|
43
|
+
/** 环境列表里当前 IM 默认环境的标记。 */
|
|
44
|
+
readonly envCurrent: {
|
|
45
|
+
readonly zh: "(当前)";
|
|
46
|
+
readonly en: " (current)";
|
|
47
|
+
};
|
|
13
48
|
/** 未绑定的人在私聊里发消息:附绑定卡片。 */
|
|
14
49
|
readonly bindPrompt: {
|
|
15
50
|
readonly zh: "请先绑定你的 Capybara 账号,再与我对话。";
|
package/dist/channels/phrases.js
CHANGED
|
@@ -5,6 +5,35 @@
|
|
|
5
5
|
export const CHANNEL_PHRASES = {
|
|
6
6
|
/** 私聊 `/new` 之后。 */
|
|
7
7
|
newConversation: { zh: "已开始新对话", en: "Started a new conversation." },
|
|
8
|
+
/** 私聊 `/env`:列出可用环境(`{list}` 每行一个,当前的带标记)。 */
|
|
9
|
+
envList: {
|
|
10
|
+
zh: "你的环境:\n{list}\n发送 /env <名称> 选择下一个新对话使用的环境。",
|
|
11
|
+
en: "Your environments:\n{list}\nSend /env <name> to choose the one your next new conversation uses.",
|
|
12
|
+
},
|
|
13
|
+
/** 私聊 `/env <名称>` 之后(`{name}` 是环境名)。 */
|
|
14
|
+
envSwitched: {
|
|
15
|
+
zh: "下一个新对话将使用环境「{name}」,发送 /new 开始。",
|
|
16
|
+
en: "Your next new conversation will use the environment \u201c{name}\u201d; send /new to start one.",
|
|
17
|
+
},
|
|
18
|
+
/** 私聊 `/env <名称>` 没有匹配的可用环境(`{list}` 同 envList)。 */
|
|
19
|
+
envUnknown: {
|
|
20
|
+
zh: "没有找到名为「{name}」的环境。你的环境:\n{list}",
|
|
21
|
+
en: "No environment named \u201c{name}\u201d. Your environments:\n{list}",
|
|
22
|
+
},
|
|
23
|
+
/** `/env <name>` names an existing environment that is unavailable now (`{list}` as in envList). */
|
|
24
|
+
envUnavailable: {
|
|
25
|
+
zh: "环境「{name}」当前不可用(它的文件由未启用的沙箱提供方保存)。你的环境:\n{list}",
|
|
26
|
+
en: "The environment \u201c{name}\u201d is unavailable: its files are kept by a sandbox provider that is not active. Your environments:\n{list}",
|
|
27
|
+
},
|
|
28
|
+
/** 私聊 `/env` 时此人没有可用环境(部署没有云沙箱)。 */
|
|
29
|
+
envNone: {
|
|
30
|
+
zh: "你目前没有可用的环境。",
|
|
31
|
+
en: "You have no usable environments.",
|
|
32
|
+
},
|
|
33
|
+
/** 环境列表里默认环境的名字。 */
|
|
34
|
+
envPersonal: { zh: "个人环境", en: "Personal" },
|
|
35
|
+
/** 环境列表里当前 IM 默认环境的标记。 */
|
|
36
|
+
envCurrent: { zh: "(当前)", en: " (current)" },
|
|
8
37
|
/** 未绑定的人在私聊里发消息:附绑定卡片。 */
|
|
9
38
|
bindPrompt: {
|
|
10
39
|
zh: "请先绑定你的 Capybara 账号,再与我对话。",
|
package/dist/config/docs.js
CHANGED
|
@@ -63,6 +63,7 @@ export function renderConfigDocs(schema) {
|
|
|
63
63
|
// body and package upload limits), apps/web/server.mjs (PORT / CAPYBARA_WEB_HOST) and
|
|
64
64
|
// apps/web/src/dev/catalog/routes.tsx (CAPYBARA_DEV_UI); change this text together with them.
|
|
65
65
|
// CAPYBARA_WEB_TRUST_PROXY: apps/web/src/lib/peer.ts; CAPYBARA_WEB_SHUTDOWN_GRACE_MS: apps/web/server.mjs.
|
|
66
|
+
// CAPYBARA_WEB_KEEP_ALIVE_TIMEOUT_MS: apps/web/src/lib/keep-alive.ts.
|
|
66
67
|
// CAPYBARA_WEB_OBJECT_STORE_*: apps/web/src/lib/object-store-proxy.ts.
|
|
67
68
|
"## Web tier (apps/web) environment variables",
|
|
68
69
|
"",
|
|
@@ -74,8 +75,9 @@ export function renderConfigDocs(schema) {
|
|
|
74
75
|
"| `PORT` / `CAPYBARA_WEB_HOST` | The web tier's listen port (default 3000) and address |",
|
|
75
76
|
"| `CAPYBARA_WEB_TRUST_PROXY` | Proxies in front of the web tier (TLS proxy, load balancer) trusted to report the client address in `X-Forwarded-For`: a hop count (`1` = the nearest proxy) or a list of IPs / CIDRs, comma-separated or a JSON array, in the grammar of `http.trustProxy` (dotted netmasks, `loopback` / `linklocal` / `uniquelocal`; a range that trusts every address such as `/0` is refused; no `true` / `false`). Unset (default) trusts nothing: the socket peer is the client, so behind a proxy every user shares the proxy's address for login rate limiting. A hop count is only safe when the web tier is reachable solely through exactly that many proxies. Either way the kernel receives one sanitized client address; a malformed value stops the web tier at startup |",
|
|
76
77
|
"| `CAPYBARA_WEB_SHUTDOWN_GRACE_MS` | Production only: after SIGTERM / SIGINT, how long in-flight requests (including SSE streams) may run before the process exits; default 5000 |",
|
|
78
|
+
"| `CAPYBARA_WEB_KEEP_ALIVE_TIMEOUT_MS` | How long an idle HTTP keep-alive connection to the web tier stays open, in milliseconds; default 65000. Keep it above the idle timeout of any load balancer or proxy in front of the web tier (often 60 s): otherwise the web tier may close a connection just as the proxy reuses it, and that request fails (a 502 at the proxy). A value that is not a positive integer stops the web tier at startup |",
|
|
77
79
|
"| `CAPYBARA_WEB_MAX_BODY_BYTES` | Request body limit of the `/api/*` proxy, default 1 MiB (matches the kernel's bodyLimit) |",
|
|
78
|
-
"| `CAPYBARA_WEB_MAX_PACKAGE_BYTES` | Request body limit for extension package and plugin uploads (`/api/v1/admin/extensions/packages/file`, `/api/v1/admin/catalog/import/file`), default 50 MiB, forwarded while being read. This is the web tier's limit; the kernel additionally rejects by `packages.maxBytes`. Raise both together, otherwise a large package uploaded through the web is first rejected by the web tier with a 413 |",
|
|
80
|
+
"| `CAPYBARA_WEB_MAX_PACKAGE_BYTES` | Request body limit for extension package and plugin uploads (`/api/v1/admin/extensions/packages/file`, `/api/v1/admin/catalog/import/file`, `/api/v1/orgs/:orgId/catalog/uploads/file`), default 50 MiB, forwarded while being read. This is the web tier's limit; the kernel additionally rejects by `packages.maxBytes`. Raise both together, otherwise a large package uploaded through the web is first rejected by the web tier with a 413 |",
|
|
79
81
|
"| `CAPYBARA_WEB_OBJECT_STORE_URL` | Object storage on the web origin: the object store's address as web reaches it (e.g. `http://seaweedfs-s3:8333`). When set, web proxies `/<bucket>/**` (and `/<bucket>` itself for POST only) there, so browsers upload attachments (presigned POST) and download attachments and artifacts (presigned GET) through web; set the object-store extension's `publicEndpoint` to the web origin with `forcePathStyle: true`. Only GET, HEAD and POST; the path is forwarded unchanged; cookies and authorization are not forwarded; responses carry `X-Content-Type-Options: nosniff` and `Content-Security-Policy: sandbox`; uploads are capped at `CAPYBARA_WEB_MAX_PACKAGE_BYTES`. Unset (default): off |",
|
|
80
82
|
"| `CAPYBARA_WEB_OBJECT_STORE_BUCKET` | With `CAPYBARA_WEB_OBJECT_STORE_URL`: the bucket, equal to the object-store extension's `bucket` (it is the first path segment web proxies) |",
|
|
81
83
|
"| `CAPYBARA_WEB_OBJECT_STORE_PUBLIC_HOST` | With `CAPYBARA_WEB_OBJECT_STORE_URL`: the host of the extension's `publicEndpoint` (a host such as `capybara.example.com`, or that URL). Sent upstream as `Host` instead of the incoming one, because presigned URLs sign the host they were issued for and front proxies rewrite it |",
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -177,7 +177,8 @@ export declare const KernelConfigSchema: z.ZodObject<{
|
|
|
177
177
|
requestMediaBytes: z.ZodDefault<z.ZodNumber>;
|
|
178
178
|
}, z.core.$strip>>;
|
|
179
179
|
subagents: z.ZodPrefault<z.ZodObject<{
|
|
180
|
-
|
|
180
|
+
maxDepth: z.ZodDefault<z.ZodNumber>;
|
|
181
|
+
maxConcurrentPerConversation: z.ZodDefault<z.ZodNumber>;
|
|
181
182
|
maxDispatchesPerRun: z.ZodDefault<z.ZodNumber>;
|
|
182
183
|
maxTokensPerRun: z.ZodDefault<z.ZodNumber>;
|
|
183
184
|
}, z.core.$strip>>;
|
|
@@ -193,7 +194,7 @@ export declare const KernelConfigSchema: z.ZodObject<{
|
|
|
193
194
|
}, z.core.$strip>>;
|
|
194
195
|
}, z.core.$strip>>;
|
|
195
196
|
sandbox: z.ZodPrefault<z.ZodObject<{
|
|
196
|
-
image: z.
|
|
197
|
+
image: z.ZodOptional<z.ZodString>;
|
|
197
198
|
lockWaitSeconds: z.ZodDefault<z.ZodNumber>;
|
|
198
199
|
maxConcurrentCommands: z.ZodDefault<z.ZodNumber>;
|
|
199
200
|
deliverMaxBytes: z.ZodDefault<z.ZodNumber>;
|
|
@@ -218,6 +219,9 @@ export declare const KernelConfigSchema: z.ZodObject<{
|
|
|
218
219
|
allowHosts: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
219
220
|
}, z.core.$strip>>;
|
|
220
221
|
}, z.core.$strip>>;
|
|
222
|
+
environments: z.ZodPrefault<z.ZodObject<{
|
|
223
|
+
maxPersonal: z.ZodDefault<z.ZodNumber>;
|
|
224
|
+
}, z.core.$strip>>;
|
|
221
225
|
evals: z.ZodPrefault<z.ZodObject<{
|
|
222
226
|
orgConcurrency: z.ZodDefault<z.ZodNumber>;
|
|
223
227
|
workerConcurrency: z.ZodDefault<z.ZodNumber>;
|
|
@@ -228,6 +232,10 @@ export declare const KernelConfigSchema: z.ZodObject<{
|
|
|
228
232
|
judgeMaxOutputTokens: z.ZodDefault<z.ZodNumber>;
|
|
229
233
|
maxConsecutiveErrors: z.ZodDefault<z.ZodNumber>;
|
|
230
234
|
}, z.core.$strip>>;
|
|
235
|
+
models: z.ZodPrefault<z.ZodObject<{
|
|
236
|
+
listTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
237
|
+
embedTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
238
|
+
}, z.core.$strip>>;
|
|
231
239
|
hooks: z.ZodPrefault<z.ZodObject<{
|
|
232
240
|
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
233
241
|
usageReportConcurrency: z.ZodDefault<z.ZodNumber>;
|