@capybara-hq/kernel 0.1.0-rc.1 → 0.1.0-rc.2
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/dist/admin/admin.controller.d.ts +17 -17
- package/dist/admin/admin.controller.js +43 -26
- package/dist/admin/admin.module.d.ts +3 -0
- package/dist/admin/admin.module.js +22 -0
- package/dist/admin/extensions.controller.d.ts +14 -14
- package/dist/admin/extensions.controller.js +30 -17
- package/dist/admin/setup-lock.d.ts +16 -0
- package/dist/admin/setup-lock.js +47 -0
- package/dist/admin/setup.controller.d.ts +8 -8
- package/dist/admin/setup.controller.js +27 -25
- package/dist/admin/setup.service.d.ts +19 -27
- package/dist/admin/setup.service.js +61 -61
- package/dist/agents/agent-lookup.d.ts +53 -0
- package/dist/agents/agent-lookup.js +179 -0
- package/dist/agents/agents.controller.d.ts +1 -1
- package/dist/agents/agents.controller.js +14 -8
- package/dist/agents/agents.module.d.ts +7 -0
- package/dist/agents/agents.module.js +41 -0
- package/dist/agents/agents.service.d.ts +39 -58
- package/dist/agents/agents.service.js +261 -329
- package/dist/agents/definition.d.ts +8 -0
- package/dist/agents/definition.js +8 -0
- package/dist/agents/models.controller.d.ts +1 -1
- package/dist/agents/models.controller.js +2 -2
- package/dist/agents/templates.controller.d.ts +1 -1
- package/dist/agents/templates.controller.js +2 -2
- package/dist/agents/templates.d.ts +6 -8
- package/dist/agents/templates.js +20 -4
- package/dist/app.d.ts +93 -0
- package/dist/app.js +150 -0
- package/dist/catalog/admin-catalog.controller.d.ts +3 -3
- package/dist/catalog/admin-catalog.controller.js +27 -13
- package/dist/catalog/catalog-content.d.ts +185 -0
- package/dist/catalog/catalog-content.js +323 -0
- package/dist/catalog/catalog-items.d.ts +186 -0
- package/dist/catalog/catalog-items.js +410 -0
- package/dist/catalog/catalog.module.d.ts +14 -0
- package/dist/catalog/catalog.module.js +71 -0
- package/dist/catalog/catalog.service.d.ts +34 -188
- package/dist/catalog/catalog.service.js +155 -489
- package/dist/catalog/cli.d.ts +3 -2
- package/dist/catalog/cli.js +13 -31
- package/dist/catalog/job-ids.d.ts +15 -0
- package/dist/catalog/job-ids.js +15 -0
- package/dist/catalog/jobs.d.ts +27 -0
- package/dist/catalog/jobs.js +70 -0
- package/dist/catalog/locks.d.ts +24 -0
- package/dist/catalog/locks.js +63 -0
- package/dist/catalog/marketplaces.controller.d.ts +4 -4
- package/dist/catalog/marketplaces.controller.js +22 -11
- package/dist/catalog/marketplaces.service.d.ts +30 -13
- package/dist/catalog/marketplaces.service.js +330 -256
- package/dist/catalog/org-catalog.controller.d.ts +4 -3
- package/dist/catalog/org-catalog.controller.js +29 -14
- package/dist/catalog/org-catalog.service.d.ts +32 -198
- package/dist/catalog/org-catalog.service.js +159 -400
- package/dist/catalog/plugin-import.d.ts +73 -34
- package/dist/catalog/plugin-import.js +356 -217
- package/dist/catalog/plugin-install.d.ts +83 -41
- package/dist/catalog/plugin-install.js +421 -269
- package/dist/catalog/plugin-upgrade.d.ts +59 -4
- package/dist/catalog/plugin-upgrade.js +407 -282
- package/dist/catalog/requests.service.d.ts +27 -15
- package/dist/catalog/requests.service.js +201 -145
- package/dist/catalog/upgrade-targets.d.ts +4 -7
- package/dist/channels/actions.d.ts +6 -4
- package/dist/channels/actions.js +1 -1
- package/dist/channels/cards.d.ts +2 -2
- package/dist/channels/channels.module.d.ts +40 -0
- package/dist/channels/channels.module.js +128 -0
- package/dist/channels/connections.controller.d.ts +1 -1
- package/dist/channels/connections.controller.js +11 -6
- package/dist/channels/connections.service.d.ts +43 -21
- package/dist/channels/connections.service.js +236 -131
- package/dist/channels/inbound.d.ts +34 -38
- package/dist/channels/inbound.js +107 -41
- package/dist/channels/job-ids.d.ts +10 -0
- package/dist/channels/job-ids.js +10 -0
- package/dist/channels/jobs.d.ts +85 -0
- package/dist/channels/jobs.js +157 -0
- package/dist/channels/outbound.d.ts +60 -82
- package/dist/channels/outbound.js +165 -194
- package/dist/channels/supervisor.d.ts +88 -46
- package/dist/channels/supervisor.js +230 -132
- package/dist/channels/threads.d.ts +29 -8
- package/dist/channels/threads.js +71 -13
- package/dist/channels/webhook.d.ts +20 -14
- package/dist/channels/webhook.js +51 -20
- package/dist/config/load.d.ts +3 -2
- package/dist/config/load.js +3 -2
- package/dist/config/nacos-source.js +11 -2
- package/dist/config/schema.d.ts +1 -0
- package/dist/config/schema.js +10 -4
- package/dist/conversations/access.d.ts +29 -0
- package/dist/conversations/access.js +86 -0
- package/dist/conversations/artifacts.d.ts +10 -10
- package/dist/conversations/artifacts.js +35 -9
- package/dist/conversations/attachments.controller.d.ts +1 -1
- package/dist/conversations/attachments.controller.js +8 -6
- package/dist/conversations/attachments.module.d.ts +7 -0
- package/dist/conversations/attachments.module.js +25 -0
- package/dist/conversations/attachments.service.d.ts +30 -22
- package/dist/conversations/attachments.service.js +119 -46
- package/dist/conversations/conversations.controller.d.ts +8 -7
- package/dist/conversations/conversations.controller.js +59 -29
- package/dist/conversations/conversations.module.d.ts +8 -0
- package/dist/conversations/conversations.module.js +69 -0
- package/dist/conversations/conversations.service.d.ts +40 -38
- package/dist/conversations/conversations.service.js +130 -140
- package/dist/conversations/event-log.d.ts +28 -18
- package/dist/conversations/event-log.js +74 -27
- package/dist/conversations/files.d.ts +10 -10
- package/dist/conversations/files.js +37 -11
- package/dist/conversations/idem-keys.d.ts +5 -0
- package/dist/conversations/idem-keys.js +5 -0
- package/dist/conversations/job-ids.d.ts +6 -0
- package/dist/conversations/job-ids.js +6 -0
- package/dist/conversations/outputs-read.d.ts +11 -11
- package/dist/conversations/outputs-read.js +31 -7
- package/dist/conversations/queue.d.ts +48 -56
- package/dist/conversations/queue.js +13 -289
- package/dist/conversations/queue.service.d.ts +60 -0
- package/dist/conversations/queue.service.js +343 -0
- package/dist/conversations/sandbox-status.d.ts +13 -10
- package/dist/conversations/sandbox-status.js +36 -8
- package/dist/conversations/titles.d.ts +71 -24
- package/dist/conversations/titles.js +159 -63
- package/dist/ctx/bus.js +9 -3
- package/dist/ctx/create-ctx.d.ts +6 -0
- package/dist/ctx/create-ctx.js +7 -9
- package/dist/ctx/lock.d.ts +7 -3
- package/dist/ctx/lock.js +9 -20
- package/dist/ctx/secrets.d.ts +10 -2
- package/dist/ctx/secrets.js +7 -3
- package/dist/db/kernel-schema.d.ts +2 -2
- package/dist/db/pool.d.ts +5 -0
- package/dist/db/pool.js +1 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +1 -0
- package/dist/evals/budget.d.ts +42 -21
- package/dist/evals/budget.js +114 -62
- package/dist/evals/evals.module.d.ts +31 -0
- package/dist/evals/evals.module.js +114 -0
- package/dist/evals/jobs.d.ts +20 -0
- package/dist/evals/jobs.js +45 -0
- package/dist/evals/run-replay.d.ts +56 -8
- package/dist/evals/run-replay.js +140 -80
- package/dist/evals/runs.controller.d.ts +1 -1
- package/dist/evals/runs.controller.js +17 -8
- package/dist/evals/runs.service.d.ts +23 -45
- package/dist/evals/runs.service.js +245 -234
- package/dist/evals/sets.controller.d.ts +1 -1
- package/dist/evals/sets.controller.js +17 -8
- package/dist/evals/sets.service.d.ts +22 -6
- package/dist/evals/sets.service.js +248 -194
- package/dist/evals/snapshot.d.ts +2 -2
- package/dist/evals/step-replay.d.ts +2 -2
- package/dist/evals/step-replay.js +1 -1
- package/dist/evals/trajectory.controller.d.ts +1 -1
- package/dist/evals/trajectory.controller.js +11 -7
- package/dist/evals/trajectory.service.d.ts +5 -4
- package/dist/evals/trajectory.service.js +30 -7
- package/dist/evals/worker.d.ts +44 -27
- package/dist/evals/worker.js +220 -121
- package/dist/extensions/admin-ops.d.ts +61 -33
- package/dist/extensions/admin-ops.js +248 -154
- package/dist/extensions/admin-view.d.ts +38 -27
- package/dist/extensions/admin-view.js +126 -55
- package/dist/extensions/approvals.d.ts +12 -8
- package/dist/extensions/approvals.js +73 -46
- package/dist/extensions/blobs.d.ts +27 -10
- package/dist/extensions/blobs.js +111 -45
- package/dist/extensions/bootstrap.d.ts +58 -31
- package/dist/extensions/bootstrap.js +175 -121
- package/dist/extensions/cli.d.ts +20 -10
- package/dist/extensions/cli.js +41 -96
- package/dist/extensions/config-issues.d.ts +7 -0
- package/dist/extensions/config-issues.js +31 -0
- package/dist/extensions/deployment-config-store.d.ts +49 -0
- package/dist/extensions/deployment-config-store.js +133 -0
- package/dist/extensions/deployment-config.d.ts +58 -67
- package/dist/extensions/deployment-config.js +202 -230
- package/dist/extensions/enabled.d.ts +5 -5
- package/dist/extensions/extensions.module.d.ts +8 -0
- package/dist/extensions/extensions.module.js +77 -0
- package/dist/extensions/hooks.d.ts +3 -2
- package/dist/extensions/hooks.js +1 -1
- package/dist/extensions/host.d.ts +72 -68
- package/dist/extensions/host.js +191 -152
- package/dist/extensions/installs.d.ts +49 -16
- package/dist/extensions/installs.js +128 -32
- package/dist/extensions/job-ids.d.ts +6 -0
- package/dist/extensions/job-ids.js +6 -0
- package/dist/extensions/lifecycle-topics.d.ts +18 -0
- package/dist/extensions/lifecycle-topics.js +18 -0
- package/dist/extensions/lifecycle.d.ts +35 -47
- package/dist/extensions/lifecycle.js +103 -39
- package/dist/extensions/locks.d.ts +33 -0
- package/dist/extensions/locks.js +86 -0
- package/dist/extensions/migrate-lock.d.ts +3 -4
- package/dist/extensions/org-config.controller.d.ts +1 -1
- package/dist/extensions/org-config.controller.js +8 -5
- package/dist/extensions/org-config.d.ts +48 -46
- package/dist/extensions/org-config.js +284 -226
- package/dist/extensions/registry.d.ts +50 -2
- package/dist/extensions/registry.js +89 -4
- package/dist/extensions/sources.d.ts +12 -8
- package/dist/extensions/sources.js +34 -13
- package/dist/files/files.module.d.ts +3 -0
- package/dist/files/files.module.js +22 -0
- package/dist/files/previewers.controller.d.ts +7 -2
- package/dist/files/previewers.controller.js +17 -9
- package/dist/files/previewers.d.ts +13 -18
- package/dist/files/previewers.js +83 -36
- package/dist/http/adapter.d.ts +3 -0
- package/dist/http/adapter.js +25 -0
- package/dist/http/api.module.d.ts +3 -110
- package/dist/http/api.module.js +47 -355
- package/dist/http/app.d.ts +11 -15
- package/dist/http/app.js +17 -62
- package/dist/http/error-filter.module.d.ts +5 -0
- package/dist/http/error-filter.module.js +18 -0
- package/dist/http/error.filter.js +2 -2
- package/dist/identity/accounts.d.ts +82 -29
- package/dist/identity/accounts.js +294 -175
- package/dist/identity/api-tokens.d.ts +11 -7
- package/dist/identity/api-tokens.js +71 -44
- package/dist/identity/audit.d.ts +7 -4
- package/dist/identity/audit.js +5 -1
- package/dist/identity/auth.controller.d.ts +11 -10
- package/dist/identity/auth.controller.js +31 -25
- package/dist/identity/auth.guard.d.ts +3 -3
- package/dist/identity/auth.guard.js +6 -4
- package/dist/identity/binding.d.ts +9 -11
- package/dist/identity/binding.js +41 -13
- package/dist/identity/enterprise-admin.d.ts +18 -12
- package/dist/identity/enterprise-admin.js +67 -13
- package/dist/identity/external-identity-lock.d.ts +17 -0
- package/dist/identity/external-identity-lock.js +39 -0
- package/dist/identity/external.d.ts +19 -15
- package/dist/identity/external.js +163 -125
- package/dist/identity/identity.module.d.ts +6 -0
- package/dist/identity/identity.module.js +56 -0
- package/dist/identity/me.controller.d.ts +16 -15
- package/dist/identity/me.controller.js +37 -31
- package/dist/identity/sessions.d.ts +12 -10
- package/dist/identity/sessions.js +74 -42
- package/dist/identity/settings.d.ts +20 -14
- package/dist/identity/settings.js +85 -57
- package/dist/identity/sso.controller.d.ts +7 -7
- package/dist/identity/sso.controller.js +13 -9
- package/dist/identity/sso.d.ts +9 -12
- package/dist/identity/sso.js +54 -24
- package/dist/inbox/inbox.module.d.ts +3 -0
- package/dist/inbox/inbox.module.js +22 -0
- package/dist/inbox/inbox.service.d.ts +7 -9
- package/dist/inbox/inbox.service.js +32 -11
- package/dist/index.d.ts +16 -11
- package/dist/index.js +9 -6
- package/dist/infra/cache/cache.module.d.ts +3 -0
- package/dist/infra/cache/cache.module.js +16 -0
- package/dist/infra/cache/cache.service.d.ts +21 -0
- package/dist/infra/cache/cache.service.js +80 -0
- package/dist/infra/cache/cacheable.decorator.d.ts +32 -0
- package/dist/infra/cache/cacheable.decorator.js +83 -0
- package/dist/infra/cli/kernel-cli.module.d.ts +66 -0
- package/dist/infra/cli/kernel-cli.module.js +165 -0
- package/dist/infra/close-within.d.ts +15 -0
- package/dist/infra/close-within.js +36 -0
- package/dist/infra/config/config.module.d.ts +13 -0
- package/dist/infra/config/config.module.js +39 -0
- package/dist/infra/config/kernel-config.service.d.ts +25 -0
- package/dist/infra/config/kernel-config.service.js +126 -0
- package/dist/infra/database/after-commit.d.ts +6 -0
- package/dist/infra/database/after-commit.js +9 -0
- package/dist/infra/database/database.module.d.ts +25 -0
- package/dist/infra/database/database.module.js +90 -0
- package/dist/infra/database/kernel-db.d.ts +22 -0
- package/dist/infra/database/kernel-db.js +65 -0
- package/dist/infra/database/transaction-host.d.ts +50 -0
- package/dist/infra/database/transaction-host.js +125 -0
- package/dist/infra/database/transactional.decorator.d.ts +15 -0
- package/dist/infra/database/transactional.decorator.js +27 -0
- package/dist/infra/database/xact-lock.d.ts +17 -0
- package/dist/infra/database/xact-lock.js +43 -0
- package/dist/infra/events/kernel-events.d.ts +96 -0
- package/dist/infra/events/kernel-events.js +65 -0
- package/dist/infra/health/health.controller.d.ts +26 -0
- package/dist/infra/health/health.controller.js +104 -0
- package/dist/infra/health/health.module.d.ts +9 -0
- package/dist/infra/health/health.module.js +24 -0
- package/dist/infra/health/health.options.d.ts +10 -0
- package/dist/infra/health/health.options.js +15 -0
- package/dist/infra/health/shutdown-state.d.ts +6 -0
- package/dist/infra/health/shutdown-state.js +2 -0
- package/dist/infra/lifecycle/graceful-shutdown.module.d.ts +6 -0
- package/dist/infra/lifecycle/graceful-shutdown.module.js +23 -0
- package/dist/infra/lifecycle/graceful-shutdown.service.d.ts +70 -0
- package/dist/infra/lifecycle/graceful-shutdown.service.js +135 -0
- package/dist/infra/lifecycle/process-guards.d.ts +52 -0
- package/dist/infra/lifecycle/process-guards.js +86 -0
- package/dist/infra/lifecycle/shutdown-signals.d.ts +30 -0
- package/dist/infra/lifecycle/shutdown-signals.js +48 -0
- package/dist/infra/lock/key-template.d.ts +13 -0
- package/dist/infra/lock/key-template.js +46 -0
- package/dist/infra/lock/lock.module.d.ts +3 -0
- package/dist/infra/lock/lock.module.js +16 -0
- package/dist/infra/lock/lock.service.d.ts +120 -0
- package/dist/infra/lock/lock.service.js +343 -0
- package/dist/infra/lock/shared-lease.d.ts +44 -0
- package/dist/infra/lock/shared-lease.js +121 -0
- package/dist/infra/lock/with-lock.decorator.d.ts +28 -0
- package/dist/infra/lock/with-lock.decorator.js +49 -0
- package/dist/infra/logging/logging.module.d.ts +16 -0
- package/dist/infra/logging/logging.module.js +34 -0
- package/dist/infra/queue/configured-processor.d.ts +18 -0
- package/dist/infra/queue/configured-processor.js +23 -0
- package/dist/infra/queue/job-failure.d.ts +18 -0
- package/dist/infra/queue/job-failure.js +26 -0
- package/dist/infra/queue/queue-shutdown.d.ts +27 -0
- package/dist/infra/queue/queue-shutdown.js +81 -0
- package/dist/infra/queue/queue.module.d.ts +16 -0
- package/dist/infra/queue/queue.module.js +61 -0
- package/dist/infra/queue/redis-connection.d.ts +7 -0
- package/dist/infra/queue/redis-connection.js +18 -0
- package/dist/infra/queue/retired-schedulers.d.ts +7 -0
- package/dist/infra/queue/retired-schedulers.js +9 -0
- package/dist/infra/queue/run-job.d.ts +16 -0
- package/dist/infra/queue/run-job.js +19 -0
- package/dist/infra/redis/redis.module.d.ts +24 -0
- package/dist/infra/redis/redis.module.js +87 -0
- package/dist/infra/schedule/cron-tick.d.ts +12 -0
- package/dist/infra/schedule/cron-tick.js +25 -0
- package/dist/infra/schedule/locked-cron.decorator.d.ts +27 -0
- package/dist/infra/schedule/locked-cron.decorator.js +53 -0
- package/dist/infra/schedule/locked-interval.d.ts +69 -0
- package/dist/infra/schedule/locked-interval.js +190 -0
- package/dist/infra/schedule/locked-tick.d.ts +90 -0
- package/dist/infra/schedule/locked-tick.js +137 -0
- package/dist/infra/schedule/schedule.module.d.ts +8 -0
- package/dist/infra/schedule/schedule.module.js +27 -0
- package/dist/infra/schedule/scheduled-runs.d.ts +69 -0
- package/dist/infra/schedule/scheduled-runs.js +163 -0
- package/dist/infra/swagger/swagger.d.ts +16 -0
- package/dist/infra/swagger/swagger.js +31 -0
- package/dist/infra/throttler/credential-throttler.d.ts +35 -0
- package/dist/infra/throttler/credential-throttler.js +77 -0
- package/dist/infra/throttler/named-throttlers.d.ts +31 -0
- package/dist/infra/throttler/named-throttlers.js +119 -0
- package/dist/infra/throttler/redis-throttler-storage.d.ts +38 -0
- package/dist/infra/throttler/redis-throttler-storage.js +130 -0
- package/dist/infra/throttler/throttler.guard.d.ts +23 -0
- package/dist/infra/throttler/throttler.guard.js +68 -0
- package/dist/infra/throttler/throttler.module.d.ts +15 -0
- package/dist/infra/throttler/throttler.module.js +53 -0
- package/dist/infra/tokens.d.ts +15 -0
- package/dist/infra/tokens.js +15 -0
- package/dist/infra/validation/create-zod-dto.d.ts +23 -0
- package/dist/infra/validation/create-zod-dto.js +35 -0
- package/dist/infra/validation/parse-with-zod.d.ts +7 -0
- package/dist/infra/validation/parse-with-zod.js +12 -0
- package/dist/infra/validation/validation.module.d.ts +3 -0
- package/dist/infra/validation/validation.module.js +16 -0
- package/dist/infra/validation/zod-params.d.ts +7 -0
- package/dist/infra/validation/zod-params.js +42 -0
- package/dist/infra/validation/zod-validation.pipe.d.ts +11 -0
- package/dist/infra/validation/zod-validation.pipe.js +31 -0
- package/dist/kernel.d.ts +9 -244
- package/dist/kernel.js +8 -1305
- package/dist/kernel.module.d.ts +17 -0
- package/dist/kernel.module.js +136 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +140 -0
- package/dist/lifecycle/kernel-lifecycle.js +451 -0
- package/dist/lifecycle/tokens.d.ts +3 -0
- package/dist/lifecycle/tokens.js +3 -0
- package/dist/log-context.d.ts +2 -0
- package/dist/log-context.js +4 -0
- package/dist/models/models.module.d.ts +3 -0
- package/dist/models/models.module.js +24 -0
- package/dist/models/prices.d.ts +8 -2
- package/dist/models/prices.js +65 -37
- package/dist/models/purposes.controller.d.ts +1 -1
- package/dist/models/purposes.controller.js +5 -6
- package/dist/models/purposes.d.ts +35 -13
- package/dist/models/purposes.js +101 -51
- package/dist/orgs/directory-sync.controller.d.ts +1 -1
- package/dist/orgs/directory-sync.controller.js +2 -2
- package/dist/orgs/directory-sync.d.ts +61 -31
- package/dist/orgs/directory-sync.js +212 -125
- package/dist/orgs/invitations.controller.d.ts +8 -8
- package/dist/orgs/invitations.controller.js +27 -26
- package/dist/orgs/invitations.service.d.ts +12 -9
- package/dist/orgs/invitations.service.js +130 -92
- package/dist/orgs/job-ids.d.ts +8 -0
- package/dist/orgs/job-ids.js +8 -0
- package/dist/orgs/members.service.d.ts +19 -12
- package/dist/orgs/members.service.js +161 -117
- package/dist/orgs/offboarding.d.ts +54 -57
- package/dist/orgs/offboarding.js +161 -71
- package/dist/orgs/org-lock.d.ts +28 -19
- package/dist/orgs/org-lock.js +81 -35
- package/dist/orgs/org.guard.d.ts +1 -1
- package/dist/orgs/org.guard.js +2 -2
- package/dist/orgs/orgs.controller.d.ts +13 -13
- package/dist/orgs/orgs.controller.js +29 -17
- package/dist/orgs/orgs.module.d.ts +6 -0
- package/dist/orgs/orgs.module.js +68 -0
- package/dist/orgs/orgs.service.d.ts +30 -19
- package/dist/orgs/orgs.service.js +139 -86
- package/dist/orgs/settings.controller.d.ts +1 -1
- package/dist/orgs/settings.controller.js +8 -6
- package/dist/orgs/settings.service.d.ts +14 -8
- package/dist/orgs/settings.service.js +75 -46
- package/dist/overrides.d.ts +56 -0
- package/dist/overrides.js +30 -0
- package/dist/roles/gateway-role.d.ts +43 -0
- package/dist/roles/gateway-role.js +98 -0
- package/dist/roles/gateway.module.d.ts +8 -0
- package/dist/roles/gateway.module.js +28 -0
- package/dist/roles/worker-role.d.ts +63 -0
- package/dist/roles/worker-role.js +144 -0
- package/dist/roles/worker.module.d.ts +14 -0
- package/dist/roles/worker.module.js +90 -0
- package/dist/runtime/abort.js +19 -2
- package/dist/runtime/checkpointer.d.ts +8 -3
- package/dist/runtime/checkpointer.js +87 -55
- package/dist/runtime/conversation-lock.d.ts +20 -11
- package/dist/runtime/conversation-lock.js +62 -72
- package/dist/runtime/hook-calls.d.ts +3 -3
- package/dist/runtime/hook-calls.js +1 -6
- package/dist/runtime/job-ids.d.ts +10 -0
- package/dist/runtime/job-ids.js +10 -0
- package/dist/runtime/langgraph-loop.js +1 -1
- package/dist/runtime/loop.d.ts +7 -0
- package/dist/runtime/loop.js +14 -0
- package/dist/runtime/maintenance-queue.d.ts +10 -0
- package/dist/runtime/maintenance-queue.js +10 -0
- package/dist/runtime/maintenance.d.ts +45 -74
- package/dist/runtime/maintenance.js +139 -137
- package/dist/runtime/model-call.d.ts +7 -4
- package/dist/runtime/model-call.js +24 -57
- package/dist/runtime/providers.d.ts +17 -6
- package/dist/runtime/providers.js +66 -25
- package/dist/runtime/quota.d.ts +17 -3
- package/dist/runtime/quota.js +27 -2
- package/dist/runtime/retired-schedulers.d.ts +7 -0
- package/dist/runtime/retired-schedulers.js +31 -0
- package/dist/runtime/run-control.d.ts +33 -0
- package/dist/runtime/run-control.js +77 -0
- package/dist/runtime/run-finish.d.ts +26 -17
- package/dist/runtime/run-finish.js +98 -51
- package/dist/runtime/run-jobs.d.ts +48 -0
- package/dist/runtime/run-jobs.js +95 -0
- package/dist/runtime/run-processors.d.ts +60 -0
- package/dist/runtime/run-processors.js +185 -0
- package/dist/runtime/run-queue.d.ts +32 -57
- package/dist/runtime/run-queue.js +291 -295
- package/dist/runtime/run-steps.d.ts +39 -0
- package/dist/runtime/run-steps.js +96 -0
- package/dist/runtime/run-worker.d.ts +121 -75
- package/dist/runtime/run-worker.js +340 -226
- package/dist/runtime/runtime.module.d.ts +10 -0
- package/dist/runtime/runtime.module.js +112 -0
- package/dist/runtime/step-log.d.ts +40 -0
- package/dist/runtime/step-log.js +94 -0
- package/dist/runtime/stream.controller.d.ts +5 -8
- package/dist/runtime/stream.controller.js +14 -12
- package/dist/runtime/stream.d.ts +24 -6
- package/dist/runtime/stream.js +78 -7
- package/dist/runtime/subagents/child.d.ts +3 -44
- package/dist/runtime/subagents/child.js +0 -79
- package/dist/runtime/subagents/definition.d.ts +4 -4
- package/dist/runtime/subagents/definition.js +2 -2
- package/dist/runtime/subagents/dispatch.d.ts +87 -6
- package/dist/runtime/subagents/dispatch.js +135 -140
- package/dist/runtime/subagents/limits.d.ts +9 -4
- package/dist/runtime/subagents/limits.js +4 -2
- package/dist/runtime/subagents/org-agents.d.ts +4 -4
- package/dist/runtime/subagents/org-agents.js +1 -1
- package/dist/runtime/subagents/progress.d.ts +2 -2
- package/dist/runtime/subagents/roster.d.ts +3 -3
- package/dist/runtime/subagents/roster.js +1 -1
- package/dist/runtime/subagents/skill-fork.d.ts +6 -7
- package/dist/runtime/subagents/skill-fork.js +16 -5
- package/dist/runtime/subagents/subagents.service.d.ts +40 -0
- package/dist/runtime/subagents/subagents.service.js +101 -0
- package/dist/runtime/usage-report.d.ts +94 -52
- package/dist/runtime/usage-report.js +200 -100
- package/dist/runtime/waits.d.ts +125 -57
- package/dist/runtime/waits.js +431 -208
- package/dist/sandbox/job-ids.d.ts +10 -0
- package/dist/sandbox/job-ids.js +10 -0
- package/dist/sandbox/jobs.d.ts +41 -0
- package/dist/sandbox/jobs.js +113 -0
- package/dist/sandbox/leases.d.ts +39 -31
- package/dist/sandbox/leases.js +117 -257
- package/dist/sandbox/providers.d.ts +19 -0
- package/dist/sandbox/providers.js +38 -0
- package/dist/sandbox/sandbox.module.d.ts +8 -0
- package/dist/sandbox/sandbox.module.js +30 -0
- package/dist/sandbox/sandbox.service.d.ts +24 -29
- package/dist/sandbox/sandbox.service.js +106 -75
- package/dist/skills/catalog.d.ts +33 -20
- package/dist/skills/catalog.js +96 -53
- package/dist/skills/changes.controller.d.ts +4 -4
- package/dist/skills/changes.controller.js +15 -9
- package/dist/skills/changes.service.d.ts +28 -18
- package/dist/skills/changes.service.js +421 -364
- package/dist/skills/invocable.controller.d.ts +1 -1
- package/dist/skills/invocable.controller.js +8 -5
- package/dist/skills/invoke.d.ts +16 -15
- package/dist/skills/invoke.js +48 -17
- package/dist/skills/skills.controller.d.ts +1 -1
- package/dist/skills/skills.controller.js +11 -6
- package/dist/skills/skills.module.d.ts +6 -0
- package/dist/skills/skills.module.js +30 -0
- package/dist/skills/skills.service.d.ts +47 -30
- package/dist/skills/skills.service.js +221 -158
- package/dist/storage/job-ids.d.ts +6 -0
- package/dist/storage/job-ids.js +6 -0
- package/dist/storage/purge.d.ts +22 -7
- package/dist/storage/purge.js +55 -3
- package/dist/storage/storage.module.d.ts +6 -0
- package/dist/storage/storage.module.js +23 -0
- package/dist/storage/storage.service.d.ts +18 -4
- package/dist/storage/storage.service.js +44 -3
- package/dist/tools/approvals.controller.d.ts +1 -1
- package/dist/tools/approvals.controller.js +12 -8
- package/dist/tools/approvals.service.d.ts +27 -25
- package/dist/tools/approvals.service.js +324 -258
- package/dist/tools/breaker.d.ts +2 -2
- package/dist/tools/breaker.js +21 -3
- package/dist/tools/builtins/ask-user.d.ts +2 -2
- package/dist/tools/builtins/ask-user.js +1 -1
- package/dist/tools/builtins/builtin-tools.d.ts +21 -0
- package/dist/tools/builtins/builtin-tools.js +80 -0
- package/dist/tools/builtins/read-tool-output.d.ts +2 -2
- package/dist/tools/builtins/read-tool-output.js +1 -1
- package/dist/tools/builtins/sandbox/bash.js +2 -2
- package/dist/tools/builtins/sandbox/common.d.ts +2 -1
- package/dist/tools/builtins/sandbox/deliver.js +2 -2
- package/dist/tools/builtins/sandbox/edit.js +1 -1
- package/dist/tools/builtins/sandbox/glob.js +2 -2
- package/dist/tools/builtins/sandbox/grep.js +2 -2
- package/dist/tools/builtins/sandbox/read.js +1 -1
- package/dist/tools/builtins/sandbox/write.js +1 -1
- package/dist/tools/builtins/skill-load.d.ts +3 -3
- package/dist/tools/builtins/skill-load.js +1 -1
- package/dist/tools/canonical-json.d.ts +6 -0
- package/dist/tools/canonical-json.js +16 -0
- package/dist/tools/connector-content.controller.d.ts +1 -1
- package/dist/tools/connector-content.controller.js +11 -6
- package/dist/tools/connector-content.d.ts +12 -15
- package/dist/tools/connector-content.js +53 -18
- package/dist/tools/connectors.controller.d.ts +1 -1
- package/dist/tools/connectors.controller.js +21 -10
- package/dist/tools/connectors.service.d.ts +31 -13
- package/dist/tools/connectors.service.js +434 -344
- package/dist/tools/credentials.d.ts +17 -20
- package/dist/tools/credentials.js +55 -34
- package/dist/tools/drift.d.ts +29 -41
- package/dist/tools/drift.js +111 -79
- package/dist/tools/info.d.ts +12 -9
- package/dist/tools/info.js +33 -7
- package/dist/tools/job-ids.d.ts +13 -0
- package/dist/tools/job-ids.js +15 -0
- package/dist/tools/jobs.d.ts +24 -0
- package/dist/tools/jobs.js +69 -0
- package/dist/tools/oauth/flow-paths.d.ts +16 -0
- package/dist/tools/oauth/flow-paths.js +38 -0
- package/dist/tools/oauth/flow.d.ts +30 -30
- package/dist/tools/oauth/flow.js +109 -81
- package/dist/tools/oauth/oauth.controller.d.ts +3 -3
- package/dist/tools/oauth/oauth.controller.js +12 -9
- package/dist/tools/oauth/tokens.d.ts +11 -3
- package/dist/tools/oauth/tokens.js +15 -14
- package/dist/tools/outputs.d.ts +13 -4
- package/dist/tools/outputs.js +47 -3
- package/dist/tools/pipeline.d.ts +62 -46
- package/dist/tools/pipeline.js +145 -64
- package/dist/tools/policy.d.ts +2 -2
- package/dist/tools/questions.controller.d.ts +1 -1
- package/dist/tools/questions.controller.js +8 -5
- package/dist/tools/questions.service.d.ts +25 -24
- package/dist/tools/questions.service.js +201 -142
- package/dist/tools/registry.d.ts +30 -20
- package/dist/tools/registry.js +73 -37
- package/dist/tools/specs.d.ts +5 -4
- package/dist/tools/specs.js +3 -1
- package/dist/tools/tools.module.d.ts +10 -0
- package/dist/tools/tools.module.js +91 -0
- package/dist/ui/call-extension.d.ts +16 -0
- package/dist/ui/call-extension.js +38 -0
- package/dist/ui/embed-token.d.ts +9 -5
- package/dist/ui/embed-token.js +34 -6
- package/dist/ui/ui-stream.d.ts +22 -17
- package/dist/ui/ui-stream.js +72 -12
- package/dist/ui/ui.module.d.ts +7 -0
- package/dist/ui/ui.module.js +28 -0
- package/dist/ui/views.controller.d.ts +14 -12
- package/dist/ui/views.controller.js +32 -25
- package/dist/ui/views.d.ts +9 -57
- package/dist/ui/views.js +43 -45
- package/package.json +9 -2
- package/dist/http/health.controller.d.ts +0 -26
- package/dist/http/health.controller.js +0 -79
- package/dist/http/tokens.d.ts +0 -131
- package/dist/http/tokens.js +0 -131
- package/dist/http/zod.pipe.d.ts +0 -8
- package/dist/http/zod.pipe.js +0 -14
- package/dist/identity/rate-limit.d.ts +0 -55
- package/dist/identity/rate-limit.js +0 -121
- package/dist/sandbox/lifecycle.d.ts +0 -21
- package/dist/sandbox/lifecycle.js +0 -68
- /package/dist/http/{gateway.module.d.ts → gateway-routes.d.ts} +0 -0
- /package/dist/http/{gateway.module.js → gateway-routes.js} +0 -0
package/dist/orgs/org.guard.js
CHANGED
|
@@ -10,8 +10,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { applyDecorators, createParamDecorator, Inject, Injectable, SetMetadata, UseGuards, } from "@nestjs/common";
|
|
11
11
|
import { Reflector } from "@nestjs/core";
|
|
12
12
|
import { ApiError } from "../errors.js";
|
|
13
|
-
import { KERNEL_DB } from "../http/tokens.js";
|
|
14
13
|
import { AllowService } from "../identity/principal.js";
|
|
14
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
15
15
|
import { can, HUMAN_ONLY } from "./roles.js";
|
|
16
16
|
export const ORG_ACTION_KEY = "capybara:org:action";
|
|
17
17
|
/**
|
|
@@ -90,6 +90,6 @@ let OrgGuard = class OrgGuard {
|
|
|
90
90
|
OrgGuard = __decorate([
|
|
91
91
|
Injectable(),
|
|
92
92
|
__param(0, Inject(Reflector)),
|
|
93
|
-
__param(1, Inject(
|
|
93
|
+
__param(1, Inject(KernelDb))
|
|
94
94
|
], OrgGuard);
|
|
95
95
|
export { OrgGuard };
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { type ApiTokenRecord,
|
|
2
|
+
import { type ApiTokenRecord, ApiTokenService } from "../identity/api-tokens.js";
|
|
3
3
|
import { type Principal } from "../identity/principal.js";
|
|
4
|
-
import type
|
|
4
|
+
import { type Member, MembersService } from "./members.service.js";
|
|
5
5
|
import { type OrgContext } from "./org.guard.js";
|
|
6
|
-
import type
|
|
6
|
+
import { type Org, OrgsService } from "./orgs.service.js";
|
|
7
7
|
import { type OrgRole } from "./roles.js";
|
|
8
|
-
declare const
|
|
8
|
+
declare const CreateSchema: z.ZodObject<{
|
|
9
9
|
name: z.ZodString;
|
|
10
10
|
slug: z.ZodOptional<z.ZodString>;
|
|
11
11
|
}, z.core.$strip>;
|
|
12
|
-
declare const
|
|
12
|
+
declare const UpdateSchema: z.ZodObject<{
|
|
13
13
|
name: z.ZodOptional<z.ZodString>;
|
|
14
14
|
slug: z.ZodOptional<z.ZodString>;
|
|
15
15
|
}, z.core.$strip>;
|
|
16
|
-
declare const
|
|
16
|
+
declare const TransferSchema: z.ZodObject<{
|
|
17
17
|
toAccountId: z.ZodString;
|
|
18
18
|
}, z.core.$strip>;
|
|
19
|
-
declare const
|
|
19
|
+
declare const ServiceTokenSchema: z.ZodObject<{
|
|
20
20
|
name: z.ZodString;
|
|
21
21
|
role: z.ZodEnum<{
|
|
22
22
|
admin: "admin";
|
|
@@ -25,7 +25,7 @@ declare const ServiceTokenBody: z.ZodObject<{
|
|
|
25
25
|
}>;
|
|
26
26
|
expiresAt: z.ZodOptional<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>>;
|
|
27
27
|
}, z.core.$strip>;
|
|
28
|
-
declare const
|
|
28
|
+
declare const RoleSchema: z.ZodObject<{
|
|
29
29
|
role: z.ZodEnum<{
|
|
30
30
|
admin: "admin";
|
|
31
31
|
guest: "guest";
|
|
@@ -39,7 +39,7 @@ export declare class OrgsController {
|
|
|
39
39
|
private readonly members;
|
|
40
40
|
private readonly tokens;
|
|
41
41
|
constructor(orgs: OrgsService, members: MembersService, tokens: ApiTokenService);
|
|
42
|
-
create(principal: Principal, body: z.infer<typeof
|
|
42
|
+
create(principal: Principal, body: z.infer<typeof CreateSchema>): Promise<{
|
|
43
43
|
org: Org;
|
|
44
44
|
role: "owner";
|
|
45
45
|
}>;
|
|
@@ -52,21 +52,21 @@ export declare class OrgsController {
|
|
|
52
52
|
org: Org;
|
|
53
53
|
role: OrgRole;
|
|
54
54
|
}>;
|
|
55
|
-
update(principal: Principal, org: OrgContext, body: z.infer<typeof
|
|
55
|
+
update(principal: Principal, org: OrgContext, body: z.infer<typeof UpdateSchema>): Promise<{
|
|
56
56
|
org: Org;
|
|
57
57
|
}>;
|
|
58
58
|
remove(principal: Principal, org: OrgContext): Promise<void>;
|
|
59
|
-
transfer(principal: Principal, org: OrgContext, body: z.infer<typeof
|
|
59
|
+
transfer(principal: Principal, org: OrgContext, body: z.infer<typeof TransferSchema>): Promise<void>;
|
|
60
60
|
leave(principal: Principal, org: OrgContext): Promise<void>;
|
|
61
61
|
listMembers(org: OrgContext): Promise<{
|
|
62
62
|
members: Member[];
|
|
63
63
|
}>;
|
|
64
|
-
changeRole(principal: Principal, org: OrgContext, accountId: string, body: z.infer<typeof
|
|
64
|
+
changeRole(principal: Principal, org: OrgContext, accountId: string, body: z.infer<typeof RoleSchema>): Promise<{
|
|
65
65
|
accountId: string;
|
|
66
66
|
role: OrgRole;
|
|
67
67
|
}>;
|
|
68
68
|
removeMember(principal: Principal, org: OrgContext, accountId: string): Promise<void>;
|
|
69
|
-
createServiceToken(principal: Principal, org: OrgContext, body: z.infer<typeof
|
|
69
|
+
createServiceToken(principal: Principal, org: OrgContext, body: z.infer<typeof ServiceTokenSchema>): Promise<{
|
|
70
70
|
token: string;
|
|
71
71
|
record: ApiTokenRecord;
|
|
72
72
|
}>;
|
|
@@ -7,30 +7,42 @@ 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 {
|
|
10
|
+
import { Controller, Delete, Get, HttpCode, Inject, Param, Patch, Post } from "@nestjs/common";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
import { ApiError } from "../errors.js";
|
|
13
|
-
import {
|
|
14
|
-
import { ZodPipe } from "../http/zod.pipe.js";
|
|
15
|
-
import { FutureIsoDate, } from "../identity/api-tokens.js";
|
|
13
|
+
import { ApiTokenService, FutureIsoDate } from "../identity/api-tokens.js";
|
|
16
14
|
import { CurrentPrincipal, patTokenId, requireUser, SessionOnly, } from "../identity/principal.js";
|
|
15
|
+
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
16
|
+
import { ZBody } from "../infra/validation/zod-params.js";
|
|
17
|
+
import { MembersService } from "./members.service.js";
|
|
17
18
|
import { CurrentOrg, OrgAction } from "./org.guard.js";
|
|
19
|
+
import { OrgsService } from "./orgs.service.js";
|
|
18
20
|
import { ORG_ROLES } from "./roles.js";
|
|
19
|
-
const
|
|
21
|
+
const CreateSchema = z.object({
|
|
20
22
|
name: z.string().min(1).max(100),
|
|
21
23
|
slug: z.string().min(1).max(40).optional(),
|
|
22
24
|
});
|
|
23
|
-
|
|
25
|
+
class OrgCreateBody extends createZodDto(CreateSchema, "OrgCreateBody") {
|
|
26
|
+
}
|
|
27
|
+
const UpdateSchema = z.object({
|
|
24
28
|
name: z.string().min(1).max(100).optional(),
|
|
25
29
|
slug: z.string().min(1).max(40).optional(),
|
|
26
30
|
});
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
class OrgUpdateBody extends createZodDto(UpdateSchema, "OrgUpdateBody") {
|
|
32
|
+
}
|
|
33
|
+
const TransferSchema = z.object({ toAccountId: z.string().min(1) });
|
|
34
|
+
class OrgTransferBody extends createZodDto(TransferSchema, "OrgTransferBody") {
|
|
35
|
+
}
|
|
36
|
+
const ServiceTokenSchema = z.object({
|
|
29
37
|
name: z.string().min(1).max(100),
|
|
30
38
|
role: z.enum(["admin", "member", "guest"]),
|
|
31
39
|
expiresAt: FutureIsoDate.optional(),
|
|
32
40
|
});
|
|
33
|
-
|
|
41
|
+
class ServiceTokenBody extends createZodDto(ServiceTokenSchema, "ServiceTokenBody") {
|
|
42
|
+
}
|
|
43
|
+
const RoleSchema = z.object({ role: z.enum(ORG_ROLES) });
|
|
44
|
+
class MemberRoleBody extends createZodDto(RoleSchema, "MemberRoleBody") {
|
|
45
|
+
}
|
|
34
46
|
/** 组织与成员(`/api/v1/orgs`)。组织级路由由 `@OrgAction` + OrgGuard 每请求实时鉴权。 */
|
|
35
47
|
let OrgsController = class OrgsController {
|
|
36
48
|
orgs;
|
|
@@ -99,7 +111,7 @@ let OrgsController = class OrgsController {
|
|
|
99
111
|
__decorate([
|
|
100
112
|
Post(),
|
|
101
113
|
__param(0, CurrentPrincipal()),
|
|
102
|
-
__param(1,
|
|
114
|
+
__param(1, ZBody(OrgCreateBody))
|
|
103
115
|
], OrgsController.prototype, "create", null);
|
|
104
116
|
__decorate([
|
|
105
117
|
Get(),
|
|
@@ -115,7 +127,7 @@ __decorate([
|
|
|
115
127
|
OrgAction("org.update"),
|
|
116
128
|
__param(0, CurrentPrincipal()),
|
|
117
129
|
__param(1, CurrentOrg()),
|
|
118
|
-
__param(2,
|
|
130
|
+
__param(2, ZBody(OrgUpdateBody))
|
|
119
131
|
], OrgsController.prototype, "update", null);
|
|
120
132
|
__decorate([
|
|
121
133
|
Delete(":orgId"),
|
|
@@ -130,7 +142,7 @@ __decorate([
|
|
|
130
142
|
HttpCode(204),
|
|
131
143
|
__param(0, CurrentPrincipal()),
|
|
132
144
|
__param(1, CurrentOrg()),
|
|
133
|
-
__param(2,
|
|
145
|
+
__param(2, ZBody(OrgTransferBody))
|
|
134
146
|
], OrgsController.prototype, "transfer", null);
|
|
135
147
|
__decorate([
|
|
136
148
|
Post(":orgId/leave"),
|
|
@@ -150,7 +162,7 @@ __decorate([
|
|
|
150
162
|
__param(0, CurrentPrincipal()),
|
|
151
163
|
__param(1, CurrentOrg()),
|
|
152
164
|
__param(2, Param("accountId")),
|
|
153
|
-
__param(3,
|
|
165
|
+
__param(3, ZBody(MemberRoleBody))
|
|
154
166
|
], OrgsController.prototype, "changeRole", null);
|
|
155
167
|
__decorate([
|
|
156
168
|
Delete(":orgId/members/:accountId"),
|
|
@@ -166,7 +178,7 @@ __decorate([
|
|
|
166
178
|
SessionOnly(),
|
|
167
179
|
__param(0, CurrentPrincipal()),
|
|
168
180
|
__param(1, CurrentOrg()),
|
|
169
|
-
__param(2,
|
|
181
|
+
__param(2, ZBody(ServiceTokenBody))
|
|
170
182
|
], OrgsController.prototype, "createServiceToken", null);
|
|
171
183
|
__decorate([
|
|
172
184
|
Get(":orgId/service-tokens"),
|
|
@@ -185,8 +197,8 @@ __decorate([
|
|
|
185
197
|
], OrgsController.prototype, "revokeServiceToken", null);
|
|
186
198
|
OrgsController = __decorate([
|
|
187
199
|
Controller("api/v1/orgs"),
|
|
188
|
-
__param(0, Inject(
|
|
189
|
-
__param(1, Inject(
|
|
190
|
-
__param(2, Inject(
|
|
200
|
+
__param(0, Inject(OrgsService)),
|
|
201
|
+
__param(1, Inject(MembersService)),
|
|
202
|
+
__param(2, Inject(ApiTokenService))
|
|
191
203
|
], OrgsController);
|
|
192
204
|
export { OrgsController };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Module } from "@nestjs/common";
|
|
8
|
+
import { EventLogModule } from "../conversations/event-log.js";
|
|
9
|
+
import { EvalBudgetModule } from "../evals/budget.js";
|
|
10
|
+
import { ExtensionsModule } from "../extensions/extensions.module.js";
|
|
11
|
+
import { IdentityModule } from "../identity/identity.module.js";
|
|
12
|
+
import { QueueModule } from "../infra/queue/queue.module.js";
|
|
13
|
+
import { MAINTENANCE_QUEUE_NAME } from "../runtime/maintenance-queue.js";
|
|
14
|
+
import { RuntimeModule } from "../runtime/runtime.module.js";
|
|
15
|
+
import { SandboxModule } from "../sandbox/sandbox.module.js";
|
|
16
|
+
import { ToolsModule } from "../tools/tools.module.js";
|
|
17
|
+
import { DirectorySync } from "./directory-sync.js";
|
|
18
|
+
import { InvitationsService } from "./invitations.service.js";
|
|
19
|
+
import { MembersService } from "./members.service.js";
|
|
20
|
+
import { Offboarding } from "./offboarding.js";
|
|
21
|
+
import { OrgLockModule } from "./org-lock.js";
|
|
22
|
+
import { OrgsService } from "./orgs.service.js";
|
|
23
|
+
import { OrgSettingsService } from "./settings.service.js";
|
|
24
|
+
/**
|
|
25
|
+
* Organizations: orgs, org settings, members, invitations, offboarding (with its sweep cron) and
|
|
26
|
+
* directory sync (the hourly scan cron, one-off syncs on the maintenance queue).
|
|
27
|
+
*/
|
|
28
|
+
let OrgsModule = class OrgsModule {
|
|
29
|
+
};
|
|
30
|
+
OrgsModule = __decorate([
|
|
31
|
+
Module({
|
|
32
|
+
imports: [
|
|
33
|
+
IdentityModule,
|
|
34
|
+
// offboarding publishes the events it cancelled
|
|
35
|
+
EventLogModule,
|
|
36
|
+
OrgLockModule,
|
|
37
|
+
ExtensionsModule,
|
|
38
|
+
// offboarding clears credentials and cancels approvals and questions
|
|
39
|
+
ToolsModule,
|
|
40
|
+
// offboarding stops the member's runs
|
|
41
|
+
RuntimeModule,
|
|
42
|
+
// offboarding enqueues the destruction of the member's sandboxes
|
|
43
|
+
SandboxModule,
|
|
44
|
+
// cancels the deleted org's eval runs
|
|
45
|
+
EvalBudgetModule,
|
|
46
|
+
// the producer side of directory-sync jobs (the maintenance processor consumes them)
|
|
47
|
+
QueueModule.registerQueue(MAINTENANCE_QUEUE_NAME),
|
|
48
|
+
],
|
|
49
|
+
providers: [
|
|
50
|
+
OrgsService,
|
|
51
|
+
OrgSettingsService,
|
|
52
|
+
MembersService,
|
|
53
|
+
InvitationsService,
|
|
54
|
+
Offboarding,
|
|
55
|
+
DirectorySync,
|
|
56
|
+
],
|
|
57
|
+
exports: [
|
|
58
|
+
OrgLockModule,
|
|
59
|
+
OrgsService,
|
|
60
|
+
OrgSettingsService,
|
|
61
|
+
MembersService,
|
|
62
|
+
InvitationsService,
|
|
63
|
+
Offboarding,
|
|
64
|
+
DirectorySync,
|
|
65
|
+
],
|
|
66
|
+
})
|
|
67
|
+
], OrgsModule);
|
|
68
|
+
export { OrgsModule };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { KernelDatabase, KernelDb } from "../db/kernel-schema.js";
|
|
1
|
+
import { EvalBudget } from "../evals/budget.js";
|
|
3
2
|
import type { Account } from "../identity/accounts.js";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
3
|
+
import { ApiTokenService } from "../identity/api-tokens.js";
|
|
4
|
+
import { SettingsService } from "../identity/settings.js";
|
|
5
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
6
|
+
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
7
|
+
import { KernelEvents } from "../infra/events/kernel-events.js";
|
|
8
|
+
import { OrgLock } from "./org-lock.js";
|
|
6
9
|
import type { OrgRole } from "./roles.js";
|
|
7
|
-
type Trx = Transaction<KernelDatabase>;
|
|
8
10
|
export type Org = {
|
|
9
11
|
id: string;
|
|
10
12
|
slug: string;
|
|
@@ -15,27 +17,34 @@ export type Org = {
|
|
|
15
17
|
export declare const SLUG_RE: RegExp;
|
|
16
18
|
/** 由名字生成 slug:转小写、非字母数字换 `-`、去首尾 `-`;为空则 `org-<6 位随机>`。 */
|
|
17
19
|
export declare function slugFromName(name: string): string;
|
|
18
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Organizations: create, read, update and soft delete. A soft delete emits `org.deleted` on
|
|
22
|
+
* {@link KernelEvents} after the commit.
|
|
23
|
+
*/
|
|
19
24
|
export declare class OrgsService {
|
|
20
25
|
private readonly db;
|
|
26
|
+
readonly txHost: TransactionHost;
|
|
21
27
|
private readonly settings;
|
|
22
28
|
private readonly apiTokens;
|
|
23
|
-
private readonly
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
private readonly orgLock;
|
|
30
|
+
private readonly events;
|
|
31
|
+
/** Cancels the deleted org's running eval runs (in the delete's transaction). */
|
|
32
|
+
private readonly evalBudget;
|
|
33
|
+
constructor(db: KernelDb, txHost: TransactionHost, settings: SettingsService, apiTokens: ApiTokenService, orgLock: OrgLock, events: KernelEvents,
|
|
34
|
+
/** Cancels the deleted org's running eval runs (in the delete's transaction). */
|
|
35
|
+
evalBudget: Pick<EvalBudget, "cancelRuns">);
|
|
28
36
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
37
|
+
* Creates an org with the actor as owner, in the caller's transaction when there is one (the
|
|
38
|
+
* setup wizard creates it with the account); a slug conflict is `org.slug_taken` either way, but
|
|
39
|
+
* a caller's transaction is then aborted and can only roll back.
|
|
31
40
|
*/
|
|
32
41
|
create(input: {
|
|
33
42
|
name: string;
|
|
34
43
|
slug?: string | undefined;
|
|
35
44
|
}, actor: Account, opts?: {
|
|
36
|
-
trx?: Trx | undefined;
|
|
37
45
|
actorTokenId?: string | undefined;
|
|
38
46
|
}): Promise<Org>;
|
|
47
|
+
private createIn;
|
|
39
48
|
/** 账号所属的(未软删除的)组织及其角色,按创建时间升序。 */
|
|
40
49
|
listForAccount(accountId: string): Promise<(Org & {
|
|
41
50
|
role: OrgRole;
|
|
@@ -46,16 +55,18 @@ export declare class OrgsService {
|
|
|
46
55
|
})[]>;
|
|
47
56
|
/** 未软删除的组织;不存在或已软删除为 undefined。 */
|
|
48
57
|
get(orgId: string): Promise<Org | undefined>;
|
|
49
|
-
/**
|
|
58
|
+
/** Renames / re-slugs (needs admin, decided live under the org lock). */
|
|
50
59
|
update(orgId: string, patch: {
|
|
51
60
|
name?: string | undefined;
|
|
52
61
|
slug?: string | undefined;
|
|
53
62
|
}, actor: Account, actorTokenId?: string): Promise<Org>;
|
|
63
|
+
private updateIn;
|
|
54
64
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
65
|
+
* Soft delete (needs owner, decided live under the org lock): in the same transaction revokes
|
|
66
|
+
* the org's service tokens, cancels its running eval runs and pending catalog requests, and
|
|
67
|
+
* clears sessions' current org pointing at it; after the commit emits `org.deleted` (channel
|
|
68
|
+
* connections go with the org: the runtime's connection reads filter deleted orgs).
|
|
58
69
|
*/
|
|
59
70
|
softDelete(orgId: string, actor: Account, actorTokenId?: string): Promise<void>;
|
|
71
|
+
private softDeleteIn;
|
|
60
72
|
}
|
|
61
|
-
export {};
|
|
@@ -1,10 +1,27 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
+
};
|
|
1
10
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
11
|
+
import { Inject, Injectable } from "@nestjs/common";
|
|
2
12
|
import { sql } from "kysely";
|
|
3
13
|
import { cancelPendingRequests } from "../catalog/requests.service.js";
|
|
4
14
|
import { ApiError } from "../errors.js";
|
|
5
|
-
import {
|
|
15
|
+
import { EvalBudget } from "../evals/budget.js";
|
|
16
|
+
import { ApiTokenService } from "../identity/api-tokens.js";
|
|
6
17
|
import { audit } from "../identity/audit.js";
|
|
7
|
-
import {
|
|
18
|
+
import { SettingsService } from "../identity/settings.js";
|
|
19
|
+
import { afterCommit } from "../infra/database/after-commit.js";
|
|
20
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
21
|
+
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
22
|
+
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
23
|
+
import { KernelEvents } from "../infra/events/kernel-events.js";
|
|
24
|
+
import { OrgLock } from "./org-lock.js";
|
|
8
25
|
/** 组织 slug:小写字母数字与 `-`,首尾不能是 `-`,1–40 个字符。 */
|
|
9
26
|
export const SLUG_RE = /^[a-z0-9](?:[a-z0-9-]{0,38}[a-z0-9])?$/;
|
|
10
27
|
const MAX_SLUG = 40;
|
|
@@ -52,53 +69,65 @@ async function slugGuard(p) {
|
|
|
52
69
|
throw e;
|
|
53
70
|
}
|
|
54
71
|
}
|
|
55
|
-
/**
|
|
56
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Organizations: create, read, update and soft delete. A soft delete emits `org.deleted` on
|
|
74
|
+
* {@link KernelEvents} after the commit.
|
|
75
|
+
*/
|
|
76
|
+
let OrgsService = class OrgsService {
|
|
57
77
|
db;
|
|
78
|
+
txHost;
|
|
58
79
|
settings;
|
|
59
80
|
apiTokens;
|
|
60
|
-
|
|
61
|
-
|
|
81
|
+
orgLock;
|
|
82
|
+
events;
|
|
83
|
+
evalBudget;
|
|
84
|
+
constructor(db, txHost, settings, apiTokens, orgLock, events,
|
|
85
|
+
/** Cancels the deleted org's running eval runs (in the delete's transaction). */
|
|
86
|
+
evalBudget) {
|
|
62
87
|
this.db = db;
|
|
88
|
+
this.txHost = txHost;
|
|
63
89
|
this.settings = settings;
|
|
64
90
|
this.apiTokens = apiTokens;
|
|
65
|
-
this.
|
|
91
|
+
this.orgLock = orgLock;
|
|
92
|
+
this.events = events;
|
|
93
|
+
this.evalBudget = evalBudget;
|
|
66
94
|
}
|
|
67
95
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
96
|
+
* Creates an org with the actor as owner, in the caller's transaction when there is one (the
|
|
97
|
+
* setup wizard creates it with the account); a slug conflict is `org.slug_taken` either way, but
|
|
98
|
+
* a caller's transaction is then aborted and can only roll back.
|
|
70
99
|
*/
|
|
71
100
|
async create(input, actor, opts = {}) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
101
|
+
return slugGuard(this.createIn(input, actor, opts.actorTokenId));
|
|
102
|
+
}
|
|
103
|
+
async createIn(input, actor, actorTokenId) {
|
|
104
|
+
// read in the context's transaction: a caller holding a connection asking the pool for a
|
|
105
|
+
// second one could exhaust it under load
|
|
106
|
+
const { orgCreation } = await this.settings.get();
|
|
75
107
|
if (orgCreation === "enterprise_admin" && !actor.isEnterpriseAdmin) {
|
|
76
108
|
throw new ApiError("org.creation_disabled", "Only enterprise admins can create organizations");
|
|
77
109
|
}
|
|
78
110
|
const name = checkName(input.name);
|
|
79
111
|
const slug = input.slug ?? slugFromName(name);
|
|
80
112
|
checkSlug(slug);
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return toOrg(row);
|
|
100
|
-
};
|
|
101
|
-
return slugGuard(trx ? run(trx) : this.db.transaction().execute(run));
|
|
113
|
+
const row = await this.db
|
|
114
|
+
.insertInto("orgs")
|
|
115
|
+
.values({ id: randomUUID(), slug, name, created_by: actor.id })
|
|
116
|
+
.returning(["id", "slug", "name", "created_at"])
|
|
117
|
+
.executeTakeFirstOrThrow();
|
|
118
|
+
await this.db
|
|
119
|
+
.insertInto("memberships")
|
|
120
|
+
.values({ org_id: row.id, account_id: actor.id, role: "owner" })
|
|
121
|
+
.execute();
|
|
122
|
+
await audit(this.db.db, {
|
|
123
|
+
actorAccountId: actor.id,
|
|
124
|
+
...(actorTokenId !== undefined && { actorTokenId }),
|
|
125
|
+
orgId: row.id,
|
|
126
|
+
action: "org.created",
|
|
127
|
+
target: row.id,
|
|
128
|
+
detail: { slug, name },
|
|
129
|
+
});
|
|
130
|
+
return toOrg(row);
|
|
102
131
|
}
|
|
103
132
|
/** 账号所属的(未软删除的)组织及其角色,按创建时间升序。 */
|
|
104
133
|
async listForAccount(accountId) {
|
|
@@ -137,7 +166,7 @@ export class OrgsService {
|
|
|
137
166
|
.executeTakeFirst();
|
|
138
167
|
return row && toOrg(row);
|
|
139
168
|
}
|
|
140
|
-
/**
|
|
169
|
+
/** Renames / re-slugs (needs admin, decided live under the org lock). */
|
|
141
170
|
async update(orgId, patch, actor, actorTokenId) {
|
|
142
171
|
const values = {};
|
|
143
172
|
if (patch.name !== undefined)
|
|
@@ -146,64 +175,88 @@ export class OrgsService {
|
|
|
146
175
|
checkSlug(patch.slug);
|
|
147
176
|
values.slug = patch.slug;
|
|
148
177
|
}
|
|
149
|
-
return slugGuard(this.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return toOrg(row);
|
|
158
|
-
}
|
|
159
|
-
const row = await trx
|
|
160
|
-
.updateTable("orgs")
|
|
161
|
-
.set(values)
|
|
178
|
+
return slugGuard(this.updateIn(orgId, values, actor, actorTokenId));
|
|
179
|
+
}
|
|
180
|
+
async updateIn(orgId, values, actor, actorTokenId) {
|
|
181
|
+
const { org: before } = await this.orgLock.lockAndAuthorize(orgId, actor.id, "org.update");
|
|
182
|
+
if (Object.keys(values).length === 0) {
|
|
183
|
+
const row = await this.db
|
|
184
|
+
.selectFrom("orgs")
|
|
185
|
+
.select(["id", "slug", "name", "created_at"])
|
|
162
186
|
.where("id", "=", orgId)
|
|
163
|
-
.returning(["id", "slug", "name", "created_at"])
|
|
164
187
|
.executeTakeFirstOrThrow();
|
|
165
|
-
await audit(trx, {
|
|
166
|
-
actorAccountId: actor.id,
|
|
167
|
-
...(actorTokenId !== undefined && { actorTokenId }),
|
|
168
|
-
orgId,
|
|
169
|
-
action: "org.updated",
|
|
170
|
-
target: orgId,
|
|
171
|
-
detail: { before, after: values },
|
|
172
|
-
});
|
|
173
188
|
return toOrg(row);
|
|
174
|
-
}
|
|
189
|
+
}
|
|
190
|
+
const row = await this.db
|
|
191
|
+
.updateTable("orgs")
|
|
192
|
+
.set(values)
|
|
193
|
+
.where("id", "=", orgId)
|
|
194
|
+
.returning(["id", "slug", "name", "created_at"])
|
|
195
|
+
.executeTakeFirstOrThrow();
|
|
196
|
+
await audit(this.db.db, {
|
|
197
|
+
actorAccountId: actor.id,
|
|
198
|
+
...(actorTokenId !== undefined && { actorTokenId }),
|
|
199
|
+
orgId,
|
|
200
|
+
action: "org.updated",
|
|
201
|
+
target: orgId,
|
|
202
|
+
detail: { before, after: values },
|
|
203
|
+
});
|
|
204
|
+
return toOrg(row);
|
|
175
205
|
}
|
|
176
206
|
/**
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
207
|
+
* Soft delete (needs owner, decided live under the org lock): in the same transaction revokes
|
|
208
|
+
* the org's service tokens, cancels its running eval runs and pending catalog requests, and
|
|
209
|
+
* clears sessions' current org pointing at it; after the commit emits `org.deleted` (channel
|
|
210
|
+
* connections go with the org: the runtime's connection reads filter deleted orgs).
|
|
180
211
|
*/
|
|
181
212
|
async softDelete(orgId, actor, actorTokenId) {
|
|
182
|
-
await this.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
213
|
+
await this.softDeleteIn(orgId, actor, actorTokenId);
|
|
214
|
+
}
|
|
215
|
+
async softDeleteIn(orgId, actor, actorTokenId) {
|
|
216
|
+
await this.orgLock.lockAndAuthorize(orgId, actor.id, "org.delete");
|
|
217
|
+
await this.db
|
|
218
|
+
.updateTable("orgs")
|
|
219
|
+
.set({ deleted_at: sql `now()` })
|
|
220
|
+
.where("id", "=", orgId)
|
|
221
|
+
.execute();
|
|
222
|
+
await this.apiTokens.revokeAllForOrg(orgId);
|
|
223
|
+
// eval runs of a deleted org stop spending: cancelled explicitly (audited with the reason)
|
|
224
|
+
await this.evalBudget.cancelRuns({ orgId }, { accountId: actor.id, ...(actorTokenId !== undefined && { tokenId: actorTokenId }) }, "org_deleted");
|
|
225
|
+
// pending catalog requests (including those passed to enterprise admins) are cancelled too
|
|
226
|
+
await cancelPendingRequests(this.db.db, { orgId }, actor.id, "org_deleted", actorTokenId !== undefined ? { actorTokenId } : {});
|
|
227
|
+
await this.db
|
|
228
|
+
.updateTable("sessions")
|
|
229
|
+
.set({ current_org_id: null })
|
|
230
|
+
.where("current_org_id", "=", orgId)
|
|
231
|
+
.execute();
|
|
232
|
+
await audit(this.db.db, {
|
|
233
|
+
actorAccountId: actor.id,
|
|
234
|
+
...(actorTokenId !== undefined && { actorTokenId }),
|
|
235
|
+
orgId,
|
|
236
|
+
action: "org.deleted",
|
|
237
|
+
target: orgId,
|
|
206
238
|
});
|
|
207
|
-
|
|
239
|
+
// channel connections follow the org after the root commit (none after a rollback)
|
|
240
|
+
afterCommit(() => this.events.emit("org.deleted", { orgId }));
|
|
208
241
|
}
|
|
209
|
-
}
|
|
242
|
+
};
|
|
243
|
+
__decorate([
|
|
244
|
+
Transactional()
|
|
245
|
+
], OrgsService.prototype, "createIn", null);
|
|
246
|
+
__decorate([
|
|
247
|
+
Transactional()
|
|
248
|
+
], OrgsService.prototype, "updateIn", null);
|
|
249
|
+
__decorate([
|
|
250
|
+
Transactional()
|
|
251
|
+
], OrgsService.prototype, "softDeleteIn", null);
|
|
252
|
+
OrgsService = __decorate([
|
|
253
|
+
Injectable(),
|
|
254
|
+
__param(0, Inject(KernelDb)),
|
|
255
|
+
__param(1, Inject(TransactionHost)),
|
|
256
|
+
__param(2, Inject(SettingsService)),
|
|
257
|
+
__param(3, Inject(ApiTokenService)),
|
|
258
|
+
__param(4, Inject(OrgLock)),
|
|
259
|
+
__param(5, Inject(KernelEvents)),
|
|
260
|
+
__param(6, Inject(EvalBudget))
|
|
261
|
+
], OrgsService);
|
|
262
|
+
export { OrgsService };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Principal } from "../identity/principal.js";
|
|
2
2
|
import { type OrgContext } from "./org.guard.js";
|
|
3
|
-
import { type OrgSandboxLimits, type OrgSettings, type OrgSettingsDeployment, type OrgSettingsPatch,
|
|
3
|
+
import { type OrgSandboxLimits, type OrgSettings, type OrgSettingsDeployment, type OrgSettingsPatch, OrgSettingsService } from "./settings.service.js";
|
|
4
4
|
/**
|
|
5
5
|
* 组织设置(`/api/v1/orgs/:orgId/settings`):成员可读,修改需 `org.update`(admin)。
|
|
6
6
|
* 响应带 `deployment`(部署默认值,如沙箱出站),设置页据此展示「跟随部署」时的实际取值;
|