@capybara-hq/kernel 0.1.0-rc.41 → 0.1.0-rc.43
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 +3 -3
- package/dist/admin/admin.schemas.d.ts +6 -0
- package/dist/admin/org-network.service.d.ts +3 -1
- package/dist/admin/org-network.service.js +10 -2
- package/dist/app.d.ts +4 -0
- package/dist/app.js +2 -0
- package/dist/background/finish.d.ts +9 -1
- package/dist/background/finish.js +57 -4
- package/dist/background/launch.d.ts +23 -0
- package/dist/background/launch.js +55 -1
- package/dist/background/managed-output.d.ts +110 -0
- package/dist/background/managed-output.js +219 -0
- package/dist/background/managed.d.ts +52 -0
- package/dist/background/managed.js +128 -0
- package/dist/background/poll.job.d.ts +35 -1
- package/dist/background/poll.job.js +174 -9
- package/dist/background/render.js +1 -0
- package/dist/background/retire-legacy-tasks.job.d.ts +57 -0
- package/dist/background/retire-legacy-tasks.job.js +149 -0
- package/dist/background/session.d.ts +15 -5
- package/dist/background/session.js +22 -6
- package/dist/background/stop.d.ts +35 -5
- package/dist/background/stop.js +94 -8
- package/dist/background/store.d.ts +110 -3
- package/dist/background/store.js +205 -3
- package/dist/background/tasks.service.d.ts +18 -1
- package/dist/background/tasks.service.js +99 -9
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/channels/cards.js +1 -1
- package/dist/channels/inbound.js +2 -0
- package/dist/channels/phrases.d.ts +4 -0
- package/dist/channels/phrases.js +4 -0
- package/dist/config/load.d.ts +18 -0
- package/dist/config/load.js +39 -1
- package/dist/config/permission-migration.d.ts +26 -0
- package/dist/config/permission-migration.js +64 -0
- package/dist/config/schema.d.ts +4 -1
- package/dist/config/schema.js +41 -10
- package/dist/conversations/conversations.controller.d.ts +1 -1
- package/dist/conversations/conversations.controller.js +1 -1
- package/dist/conversations/conversations.module.js +12 -0
- package/dist/conversations/conversations.service.d.ts +11 -2
- package/dist/conversations/conversations.service.js +97 -27
- package/dist/conversations/event-log.d.ts +1 -1
- package/dist/conversations/event-log.js +10 -2
- package/dist/conversations/events.d.ts +307 -4
- package/dist/conversations/events.js +286 -32
- package/dist/conversations/permission-profile-store.d.ts +50 -0
- package/dist/conversations/permission-profile-store.js +67 -0
- package/dist/conversations/permission-profile-store.module.d.ts +2 -0
- package/dist/conversations/permission-profile-store.module.js +19 -0
- package/dist/conversations/permission-profiles.controller.d.ts +84 -0
- package/dist/conversations/permission-profiles.controller.js +105 -0
- package/dist/conversations/permission-profiles.schemas.d.ts +31 -0
- package/dist/conversations/permission-profiles.schemas.js +23 -0
- package/dist/conversations/permission-profiles.service.d.ts +56 -0
- package/dist/conversations/permission-profiles.service.js +179 -0
- package/dist/ctx/create-ctx.d.ts +12 -5
- package/dist/ctx/create-ctx.js +21 -5
- package/dist/db/kernel-schema.d.ts +248 -3
- package/dist/devices/access.js +1 -1
- package/dist/devices/access.module.d.ts +2 -0
- package/dist/devices/access.module.js +19 -0
- package/dist/devices/conversation-devices.d.ts +8 -29
- package/dist/devices/conversation-devices.js +37 -73
- package/dist/devices/device-projects.service.d.ts +26 -28
- package/dist/devices/device-projects.service.js +123 -127
- package/dist/devices/devices.controller.js +3 -1
- package/dist/devices/devices.module.js +11 -9
- package/dist/devices/devices.service.d.ts +116 -8
- package/dist/devices/devices.service.js +252 -20
- package/dist/devices/dto.d.ts +16 -0
- package/dist/devices/dto.js +34 -6
- package/dist/devices/errors.d.ts +8 -0
- package/dist/devices/errors.js +10 -0
- package/dist/devices/project-rules.d.ts +44 -0
- package/dist/devices/project-rules.js +27 -0
- package/dist/devices/working-root.d.ts +6 -0
- package/dist/devices/working-root.js +12 -1
- package/dist/errors.d.ts +31 -0
- package/dist/errors.js +31 -0
- package/dist/evals/reconstruct.d.ts +19 -2
- package/dist/evals/reconstruct.js +40 -2
- package/dist/evals/recorded-permission-context.d.ts +77 -0
- package/dist/evals/recorded-permission-context.js +151 -0
- package/dist/evals/recorded-tools.d.ts +10 -1
- package/dist/evals/recorded-tools.js +27 -3
- package/dist/evals/run-replay.d.ts +8 -2
- package/dist/evals/run-replay.js +18 -2
- package/dist/evals/trajectory.d.ts +1 -1
- package/dist/evals/worker.d.ts +10 -1
- package/dist/evals/worker.js +23 -14
- package/dist/extensions/host.d.ts +4 -1
- package/dist/extensions/host.js +10 -6
- package/dist/http/api.module.js +2 -0
- package/dist/identity/accounts.d.ts +14 -1
- package/dist/identity/accounts.js +61 -5
- package/dist/identity/identity.module.js +2 -0
- package/dist/identity/settings.d.ts +28 -12
- package/dist/identity/settings.js +89 -33
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/dist/infra/cli/kernel-cli.module.d.ts +2 -2
- package/dist/infra/cli/kernel-cli.module.js +5 -2
- package/dist/infra/cli/permission-cutover.d.ts +59 -0
- package/dist/infra/cli/permission-cutover.js +107 -0
- package/dist/infra/config/kernel-config.service.d.ts +2 -2
- package/dist/infra/config/kernel-config.service.js +35 -11
- package/dist/infra/database/startup-activation-transaction.d.ts +36 -0
- package/dist/infra/database/startup-activation-transaction.js +242 -0
- package/dist/infra/database/transaction-host.d.ts +47 -0
- package/dist/infra/database/transaction-host.js +119 -0
- package/dist/infra/database/xact-lock.d.ts +1 -0
- package/dist/infra/database/xact-lock.js +6 -0
- package/dist/infra/outbox/registry.d.ts +39 -0
- package/dist/infra/outbox/registry.js +18 -0
- package/dist/kernel.module.js +2 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +3 -1
- package/dist/lifecycle/kernel-lifecycle.js +55 -28
- package/dist/local-devices/device-auth.js +1 -1
- package/dist/local-devices/device-policy.service.d.ts +35 -5
- package/dist/local-devices/device-policy.service.js +188 -13
- package/dist/local-devices/instance-bindings.d.ts +82 -0
- package/dist/local-devices/instance-bindings.js +304 -0
- package/dist/local-devices/keys.d.ts +5 -0
- package/dist/local-devices/keys.js +5 -0
- package/dist/local-devices/local-device-gateway.d.ts +19 -4
- package/dist/local-devices/local-device-gateway.js +185 -17
- package/dist/local-devices/local-device-provider.d.ts +42 -7
- package/dist/local-devices/local-device-provider.js +185 -10
- package/dist/local-devices/local-devices.module.d.ts +17 -2
- package/dist/local-devices/local-devices.module.js +49 -8
- package/dist/local-devices/machines.d.ts +35 -12
- package/dist/local-devices/machines.js +203 -8
- package/dist/local-devices/network-grants.js +3 -3
- package/dist/local-devices/network-grants.module.d.ts +2 -0
- package/dist/local-devices/network-grants.module.js +14 -0
- package/dist/local-devices/owner-report.d.ts +79 -0
- package/dist/local-devices/owner-report.js +155 -0
- package/dist/local-devices/owner-reports.d.ts +48 -0
- package/dist/local-devices/owner-reports.js +190 -0
- package/dist/local-devices/policy-summary.d.ts +24 -1
- package/dist/local-devices/policy-summary.js +48 -0
- package/dist/local-devices/relay.d.ts +82 -6
- package/dist/local-devices/relay.js +187 -16
- package/dist/local-devices/targets.d.ts +16 -1
- package/dist/local-devices/targets.js +35 -2
- package/dist/models/image-usable.d.ts +22 -0
- package/dist/models/image-usable.js +29 -0
- package/dist/models/images.d.ts +125 -0
- package/dist/models/images.js +440 -0
- package/dist/models/models.module.d.ts +3 -2
- package/dist/models/models.module.js +16 -5
- package/dist/models/org-models.schemas.js +1 -0
- package/dist/models/purposes.controller.d.ts +7 -0
- package/dist/models/purposes.controller.js +9 -0
- package/dist/models/purposes.d.ts +28 -3
- package/dist/models/purposes.js +40 -13
- package/dist/orgs/cloud-network-setting.d.ts +33 -0
- package/dist/orgs/cloud-network-setting.js +47 -0
- package/dist/orgs/offboarding.d.ts +3 -1
- package/dist/orgs/offboarding.js +8 -2
- package/dist/orgs/org-lock.d.ts +10 -4
- package/dist/orgs/org-lock.js +10 -4
- package/dist/orgs/orgs.service.d.ts +3 -1
- package/dist/orgs/orgs.service.js +8 -2
- package/dist/orgs/settings.controller.d.ts +4 -1
- package/dist/orgs/settings.controller.js +3 -3
- package/dist/orgs/settings.service.d.ts +48 -56
- package/dist/orgs/settings.service.js +144 -101
- package/dist/overrides.d.ts +6 -1
- package/dist/overrides.js +2 -0
- package/dist/platform/exclusions.js +20 -0
- package/dist/platform/ops/admin.ops.js +14 -11
- package/dist/platform/ops/agent-skills.ops.js +2 -0
- package/dist/platform/ops/devices.ops.js +10 -2
- package/dist/platform/ops/models.ops.js +10 -0
- package/dist/platform/ops/org-settings.ops.js +6 -6
- package/dist/platform/ops/orgs.ops.js +1 -0
- package/dist/roles/worker.module.js +4 -0
- package/dist/runtime/context/build.d.ts +3 -1
- package/dist/runtime/context/build.js +19 -3
- package/dist/runtime/context/compaction.js +5 -0
- package/dist/runtime/context/device-paths.d.ts +9 -2
- package/dist/runtime/context/device-paths.js +20 -0
- package/dist/runtime/context/permission-profile.d.ts +46 -0
- package/dist/runtime/context/permission-profile.js +194 -0
- package/dist/runtime/hook-calls.d.ts +11 -1
- package/dist/runtime/hook-calls.js +24 -1
- package/dist/runtime/maintenance.d.ts +7 -1
- package/dist/runtime/maintenance.js +43 -15
- package/dist/runtime/model-call.d.ts +32 -0
- package/dist/runtime/model-call.js +67 -0
- package/dist/runtime/permission-context-errors.d.ts +39 -0
- package/dist/runtime/permission-context-errors.js +67 -0
- package/dist/runtime/permission-context.service.d.ts +60 -0
- package/dist/runtime/permission-context.service.js +286 -0
- package/dist/runtime/project/knowledge.d.ts +7 -2
- package/dist/runtime/project/knowledge.js +5 -2
- package/dist/runtime/project/knowledge.service.d.ts +17 -2
- package/dist/runtime/project/knowledge.service.js +76 -12
- package/dist/runtime/providers.d.ts +9 -5
- package/dist/runtime/providers.js +22 -3
- package/dist/runtime/run-execution.d.ts +4 -1
- package/dist/runtime/run-execution.js +14 -5
- package/dist/runtime/run-steps.d.ts +11 -3
- package/dist/runtime/run-steps.js +27 -4
- package/dist/runtime/runtime.module.js +11 -0
- package/dist/runtime/usage-report.d.ts +10 -6
- package/dist/runtime/usage-report.js +31 -11
- package/dist/sandbox/attachments-path.d.ts +15 -0
- package/dist/sandbox/attachments-path.js +15 -0
- package/dist/sandbox/cloud-permission-snapshot.d.ts +159 -0
- package/dist/sandbox/cloud-permission-snapshot.js +407 -0
- package/dist/sandbox/cloud-permission-snapshot.module.d.ts +8 -0
- package/dist/sandbox/cloud-permission-snapshot.module.js +34 -0
- package/dist/sandbox/held-operations.d.ts +39 -0
- package/dist/sandbox/held-operations.js +119 -0
- package/dist/sandbox/jobs.d.ts +14 -3
- package/dist/sandbox/jobs.js +20 -2
- package/dist/sandbox/kernel-read.d.ts +55 -0
- package/dist/sandbox/kernel-read.js +57 -0
- package/dist/sandbox/legacy-retirement.d.ts +336 -0
- package/dist/sandbox/legacy-retirement.js +1063 -0
- package/dist/sandbox/legacy-retirement.module.d.ts +8 -0
- package/dist/sandbox/legacy-retirement.module.js +25 -0
- package/dist/sandbox/managed-device-context.d.ts +94 -0
- package/dist/sandbox/managed-device-context.js +308 -0
- package/dist/sandbox/managed-device-context.module.d.ts +6 -0
- package/dist/sandbox/managed-device-context.module.js +33 -0
- package/dist/sandbox/modes.d.ts +56 -8
- package/dist/sandbox/modes.js +92 -8
- package/dist/sandbox/operation-authority-types.d.ts +8 -0
- package/dist/sandbox/operation-authority-types.js +32 -0
- package/dist/sandbox/operation-authority.d.ts +145 -0
- package/dist/sandbox/operation-authority.js +783 -0
- package/dist/sandbox/operation-authority.module.d.ts +2 -0
- package/dist/sandbox/operation-authority.module.js +29 -0
- package/dist/sandbox/operation-intents.d.ts +206 -0
- package/dist/sandbox/operation-intents.js +1252 -0
- package/dist/sandbox/operation-intents.module.d.ts +2 -0
- package/dist/sandbox/operation-intents.module.js +21 -0
- package/dist/sandbox/operation-payloads.d.ts +33 -0
- package/dist/sandbox/operation-payloads.js +332 -0
- package/dist/sandbox/operation-reconcile.job.d.ts +49 -0
- package/dist/sandbox/operation-reconcile.job.js +247 -0
- package/dist/sandbox/permission-authority-epochs.d.ts +18 -0
- package/dist/sandbox/permission-authority-epochs.js +83 -0
- package/dist/sandbox/permission-authority-lock.d.ts +38 -0
- package/dist/sandbox/permission-authority-lock.js +147 -0
- package/dist/sandbox/permission-authority.module.d.ts +9 -0
- package/dist/sandbox/permission-authority.module.js +55 -0
- package/dist/sandbox/permission-availability.d.ts +18 -0
- package/dist/sandbox/permission-availability.js +19 -0
- package/dist/sandbox/permission-call-grants.d.ts +34 -0
- package/dist/sandbox/permission-call-grants.js +349 -0
- package/dist/sandbox/permission-call-grants.module.d.ts +2 -0
- package/dist/sandbox/permission-call-grants.module.js +21 -0
- package/dist/sandbox/permission-call-types.d.ts +82 -0
- package/dist/sandbox/permission-call-types.js +1 -0
- package/dist/sandbox/permission-ceiling-writes.d.ts +47 -0
- package/dist/sandbox/permission-ceiling-writes.js +223 -0
- package/dist/sandbox/permission-config-publication.d.ts +76 -0
- package/dist/sandbox/permission-config-publication.js +339 -0
- package/dist/sandbox/permission-context-types.d.ts +64 -0
- package/dist/sandbox/permission-context-types.js +24 -0
- package/dist/sandbox/permission-facts.d.ts +206 -0
- package/dist/sandbox/permission-facts.js +627 -0
- package/dist/sandbox/permission-facts.module.d.ts +2 -0
- package/dist/sandbox/permission-facts.module.js +20 -0
- package/dist/sandbox/permission-instance-writes.d.ts +90 -0
- package/dist/sandbox/permission-instance-writes.js +305 -0
- package/dist/sandbox/permission-runtime-reports.d.ts +83 -0
- package/dist/sandbox/permission-runtime-reports.js +354 -0
- package/dist/sandbox/permission-transitions.d.ts +31 -0
- package/dist/sandbox/permission-transitions.js +155 -0
- package/dist/sandbox/platform-full-access.d.ts +128 -0
- package/dist/sandbox/platform-full-access.js +210 -0
- package/dist/sandbox/providers.d.ts +22 -0
- package/dist/sandbox/providers.js +10 -2
- package/dist/sandbox/providers.module.d.ts +2 -0
- package/dist/sandbox/providers.module.js +19 -0
- package/dist/sandbox/request-not-sent.d.ts +13 -0
- package/dist/sandbox/request-not-sent.js +13 -0
- package/dist/sandbox/review/classifier.d.ts +2 -0
- package/dist/sandbox/review/classifier.js +8 -0
- package/dist/sandbox/review/permission-candidate.d.ts +12 -0
- package/dist/sandbox/review/permission-candidate.js +145 -0
- package/dist/sandbox/review/review.service.d.ts +5 -2
- package/dist/sandbox/review/review.service.js +60 -15
- package/dist/sandbox/sandbox-file-reader.d.ts +18 -1
- package/dist/sandbox/sandbox-file-reader.js +51 -7
- package/dist/sandbox/sandbox.module.js +26 -6
- package/dist/sandbox/sandbox.service.d.ts +230 -34
- package/dist/sandbox/sandbox.service.js +1368 -199
- package/dist/sandbox/unreachable.js +17 -3
- package/dist/sandbox/use-context.d.ts +17 -0
- package/dist/sandbox/use-context.js +1 -0
- package/dist/skills/invoke.d.ts +27 -4
- package/dist/skills/invoke.js +72 -7
- package/dist/tools/approvals.controller.d.ts +1 -0
- package/dist/tools/approvals.schemas.d.ts +1 -0
- package/dist/tools/approvals.schemas.js +3 -1
- package/dist/tools/approvals.service.d.ts +23 -10
- package/dist/tools/approvals.service.js +104 -26
- package/dist/tools/builtin-names.d.ts +3 -1
- package/dist/tools/builtin-names.js +5 -1
- package/dist/tools/builtins/artifacts.d.ts +43 -0
- package/dist/tools/builtins/artifacts.js +67 -0
- package/dist/tools/builtins/builtin-tools.d.ts +20 -2
- package/dist/tools/builtins/builtin-tools.js +61 -10
- package/dist/tools/builtins/image/generate.d.ts +59 -0
- package/dist/tools/builtins/image/generate.js +535 -0
- package/dist/tools/builtins/image/index.d.ts +2 -0
- package/dist/tools/builtins/image/index.js +2 -0
- package/dist/tools/builtins/image/paths.d.ts +12 -0
- package/dist/tools/builtins/image/paths.js +26 -0
- package/dist/tools/builtins/sandbox/bash.d.ts +25 -1
- package/dist/tools/builtins/sandbox/bash.js +201 -5
- package/dist/tools/builtins/sandbox/common.d.ts +92 -20
- package/dist/tools/builtins/sandbox/common.js +201 -17
- package/dist/tools/builtins/sandbox/deliver.js +9 -51
- package/dist/tools/builtins/sandbox/edit.js +2 -2
- package/dist/tools/builtins/sandbox/fetch-attachment.js +11 -4
- 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 +2 -2
- package/dist/tools/builtins/sandbox/task-list.js +7 -1
- package/dist/tools/builtins/sandbox/task-output.d.ts +1 -1
- package/dist/tools/builtins/sandbox/task-output.js +172 -0
- package/dist/tools/builtins/sandbox/task-stop.js +25 -3
- package/dist/tools/builtins/sandbox/write.js +2 -2
- package/dist/tools/builtins/skill-load.js +9 -6
- package/dist/tools/device-op-resolver.d.ts +1 -1
- package/dist/tools/device-op-resolver.js +13 -3
- package/dist/tools/permission-approval-jobs.d.ts +18 -0
- package/dist/tools/permission-approval-jobs.js +92 -0
- package/dist/tools/pipeline.d.ts +17 -2
- package/dist/tools/pipeline.js +315 -26
- package/dist/tools/registry.d.ts +9 -0
- package/dist/tools/tools.module.js +15 -0
- package/package.json +4 -3
- package/src/migrations/0146_permission_authority_epochs.sql +6 -0
- package/src/migrations/0147_conversation_permission_profiles.sql +4 -0
- package/src/migrations/0148_first_message_request_hash.sql +2 -0
- package/src/migrations/0149_sandbox_operation_intents.sql +66 -0
- package/src/migrations/0150_permission_call_grants_and_approvals.sql +36 -0
- package/src/migrations/0151_starting_execution_grants.sql +8 -0
- package/src/migrations/0152_background_launch_identity.sql +66 -0
- package/src/migrations/0153_background_cancel_requester.sql +13 -0
- package/src/migrations/0154_cloud_owner_ceiling.sql +14 -0
- package/src/migrations/0155_device_instance_generations.sql +30 -0
- package/src/migrations/0156_device_owner_report.sql +7 -0
- package/src/migrations/0157_legacy_retirement.sql +116 -0
- package/src/migrations/0158_legacy_freeze_enumerated.sql +5 -0
- package/src/migrations/0159_retirement_exact_cancel.sql +9 -0
- package/src/migrations/0160_model_usage_image_kind.sql +10 -0
- package/dist/sandbox/platform-auto-mode.d.ts +0 -63
- package/dist/sandbox/platform-auto-mode.js +0 -63
package/dist/models/purposes.js
CHANGED
|
@@ -19,21 +19,14 @@ import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
|
19
19
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
20
20
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
21
21
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
22
|
+
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
22
23
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
23
24
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
24
25
|
import { estimateTokens } from "../runtime/context/tokens.js";
|
|
25
26
|
import { consumeModelStream } from "../runtime/model-call.js";
|
|
26
27
|
import { ProviderListError, ProviderRegistry } from "../runtime/providers.js";
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
* - 用途 = 内核用途 {@link KERNEL_PURPOSES}(目前只有评委 `eval`),或已加载插件 `permissions.models` 声明的;
|
|
30
|
-
* - 映射 = 部署默认(`org_id` 为 null,超级管理员设)+ 组织覆盖(组织管理员设,`org.models.manage`);
|
|
31
|
-
* 生效的映射先取组织覆盖、再取部署默认,都没有 → `model.unconfigured`;
|
|
32
|
-
* - a target's kind must equal the purpose's kind; an org's override must be enabled in the org on
|
|
33
|
-
* save (a deployment default: not disabled on the platform), and an effective target disabled in
|
|
34
|
-
* the org (by either layer) counts as unconfigured there (spec B §5.3);参数按目标模型自己的声明严格校验;
|
|
35
|
-
* - 每次都查 PG,不在进程内缓存(多副本下改映射立即生效)。`ctx.models` 仍预留,插件暂不能调用。
|
|
36
|
-
*/
|
|
28
|
+
import { StorageService } from "../storage/storage.service.js";
|
|
29
|
+
import { IMAGE_PURPOSE, imagePurposeUsable } from "./image-usable.js";
|
|
37
30
|
/**
|
|
38
31
|
* Purposes the kernel declares: the eval judge, and the three sub-agent model tiers (phase C,
|
|
39
32
|
* spec §5.4: `fast` / `standard` / `capable` → `subagent_<tier>`; an unmapped tier runs on the
|
|
@@ -68,6 +61,8 @@ export const KERNEL_PURPOSES = [
|
|
|
68
61
|
kind: "chat",
|
|
69
62
|
label: { zh: "子智能体:最强", en: "Sub-agent: capable" },
|
|
70
63
|
},
|
|
64
|
+
/** The `GenerateImage` tool's model; no fallback: unmapped → `model.unconfigured`. */
|
|
65
|
+
{ purpose: "image", kind: "image_generation", label: { zh: "图片生成", en: "Image generation" } },
|
|
71
66
|
];
|
|
72
67
|
/** {@link PurposeListing}s of `views`, the display names read in one call. */
|
|
73
68
|
export async function withDeclaredByNames(views, names) {
|
|
@@ -131,7 +126,11 @@ let ModelPurposesService = class ModelPurposesService {
|
|
|
131
126
|
txHost;
|
|
132
127
|
adminLock;
|
|
133
128
|
orgLock;
|
|
134
|
-
|
|
129
|
+
storage;
|
|
130
|
+
log;
|
|
131
|
+
constructor(db, extensions, config, providers, txHost, adminLock, orgLock,
|
|
132
|
+
/** The `image` purpose's availability needs an object store (`GenerateImage` delivers there). */
|
|
133
|
+
storage, log) {
|
|
135
134
|
this.db = db;
|
|
136
135
|
this.extensions = extensions;
|
|
137
136
|
this.config = config;
|
|
@@ -139,6 +138,8 @@ let ModelPurposesService = class ModelPurposesService {
|
|
|
139
138
|
this.txHost = txHost;
|
|
140
139
|
this.adminLock = adminLock;
|
|
141
140
|
this.orgLock = orgLock;
|
|
141
|
+
this.storage = storage;
|
|
142
|
+
this.log = log;
|
|
142
143
|
}
|
|
143
144
|
/** 全部已声明的用途:内核的在前,其后按插件加载顺序。 */
|
|
144
145
|
declared() {
|
|
@@ -196,6 +197,30 @@ let ModelPurposesService = class ModelPurposesService {
|
|
|
196
197
|
async list(orgId) {
|
|
197
198
|
return this.views(this.declared(), orgId);
|
|
198
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Whether each purpose (kernel and extension-declared) resolves to a usable model for the org
|
|
202
|
+
* now, as {@link resolve} decides, without naming the model (the agent form's gate for
|
|
203
|
+
* `GenerateImage`, readable by every member). The `image` purpose reads `GenerateImage`'s own
|
|
204
|
+
* predicate ({@link imagePurposeUsable}: an image model callable now and an object store).
|
|
205
|
+
*/
|
|
206
|
+
async availability(orgId) {
|
|
207
|
+
const out = [];
|
|
208
|
+
for (const d of this.declared()) {
|
|
209
|
+
if (d.purpose === IMAGE_PURPOSE) {
|
|
210
|
+
// `GenerateImage`'s own predicate: the form offers the tool exactly when it is listed
|
|
211
|
+
const usable = await imagePurposeUsable({ purposes: this, providers: this.providers, storage: this.storage, log: this.log }, orgId);
|
|
212
|
+
out.push({ purpose: d.purpose, available: usable === "usable" });
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
const available = await this.resolve(orgId, d.purpose).then(() => true, (e) => {
|
|
216
|
+
if (e instanceof ApiError && e.code === "model.unconfigured")
|
|
217
|
+
return false;
|
|
218
|
+
throw e;
|
|
219
|
+
});
|
|
220
|
+
out.push({ purpose: d.purpose, available });
|
|
221
|
+
}
|
|
222
|
+
return out;
|
|
223
|
+
}
|
|
199
224
|
/**
|
|
200
225
|
* 校验目标:模型可解析且启用(an org's override for the org, a deployment default in the
|
|
201
226
|
* platform view)、its kind is the purpose's `kind`、参数按它的声明严格通过。
|
|
@@ -220,7 +245,7 @@ let ModelPurposesService = class ModelPurposesService {
|
|
|
220
245
|
throw invalid([
|
|
221
246
|
{
|
|
222
247
|
path: "target.model",
|
|
223
|
-
message: `this purpose needs ${kind
|
|
248
|
+
message: `this purpose needs ${/^[aeiou]/.test(kind) ? "an" : "a"} ${kind} model, not ${info.kind}`,
|
|
224
249
|
},
|
|
225
250
|
]);
|
|
226
251
|
}
|
|
@@ -398,6 +423,8 @@ ModelPurposesService = __decorate([
|
|
|
398
423
|
__param(3, Inject(ProviderRegistry)),
|
|
399
424
|
__param(4, Inject(TransactionHost)),
|
|
400
425
|
__param(5, Inject(SuperAdminLock)),
|
|
401
|
-
__param(6, Inject(OrgLock))
|
|
426
|
+
__param(6, Inject(OrgLock)),
|
|
427
|
+
__param(7, Inject(StorageService)),
|
|
428
|
+
__param(8, Inject(KERNEL_LOGGER))
|
|
402
429
|
], ModelPurposesService);
|
|
403
430
|
export { ModelPurposesService };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** The org cloud-network allowlist's host limit. */
|
|
3
|
+
export declare const ORG_SANDBOX_ALLOW_HOSTS_MAX = 200;
|
|
4
|
+
/**
|
|
5
|
+
* The org's sandbox-mode network (org egress ceiling spec §D1), stored as a delta over the
|
|
6
|
+
* platform's `sandbox.limits.allowHosts`, never a copy of it, so platform changes keep reaching the
|
|
7
|
+
* org:
|
|
8
|
+
* - `mode`: the cloud network of a cloud device in sandbox mode, `open` (any public host; loopback,
|
|
9
|
+
* private and cloud metadata addresses are blocked outside the container) or `allowlist`; absent
|
|
10
|
+
* follows the platform's default (open). `sandbox.limits.orgHosts: within` makes it the allowlist.
|
|
11
|
+
* - `base`: `platform` (the default: start from the platform's list) or `none` (only the org's own
|
|
12
|
+
* hosts).
|
|
13
|
+
* - `extraHosts`: hosts the org adds (ignored outside the platform list under `within`).
|
|
14
|
+
* - `excludedHosts`: platform entries the org drops (exact entries; any host is accepted, since the
|
|
15
|
+
* platform may drop an entry later).
|
|
16
|
+
* The effective hosts ({@link orgEffectiveHosts} in `sandbox/modes.ts`) are also the ceiling a local
|
|
17
|
+
* device in sandbox mode reaches (the device intersects them with its own list).
|
|
18
|
+
*/
|
|
19
|
+
export declare const CloudNetworkSettingSchema: z.ZodObject<{
|
|
20
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
21
|
+
allowlist: "allowlist";
|
|
22
|
+
open: "open";
|
|
23
|
+
}>>;
|
|
24
|
+
base: z.ZodOptional<z.ZodEnum<{
|
|
25
|
+
none: "none";
|
|
26
|
+
platform: "platform";
|
|
27
|
+
}>>;
|
|
28
|
+
extraHosts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
29
|
+
excludedHosts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
30
|
+
}, z.core.$strict>;
|
|
31
|
+
export type CloudNetworkSetting = z.infer<typeof CloudNetworkSettingSchema>;
|
|
32
|
+
/** What an invalid stored `cloudNetwork` reads as: the allowlist with no host (never wider). */
|
|
33
|
+
export declare const invalidCloudNetwork: () => CloudNetworkSetting;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { validateAllowHost } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/** The org cloud-network allowlist's host limit. */
|
|
4
|
+
export const ORG_SANDBOX_ALLOW_HOSTS_MAX = 200;
|
|
5
|
+
/** One host list of the org's cloud network: at most {@link ORG_SANDBOX_ALLOW_HOSTS_MAX} valid, unique hosts. */
|
|
6
|
+
const orgHostList = (name) => z
|
|
7
|
+
.array(z.string())
|
|
8
|
+
.max(ORG_SANDBOX_ALLOW_HOSTS_MAX)
|
|
9
|
+
.superRefine((hosts, ctx) => {
|
|
10
|
+
hosts.forEach((h, i) => {
|
|
11
|
+
for (const message of validateAllowHost(h)) {
|
|
12
|
+
ctx.addIssue({ code: "custom", path: [i], message: `${h}: ${message}` });
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
if (new Set(hosts).size !== hosts.length) {
|
|
16
|
+
ctx.addIssue({ code: "custom", message: `${name} must not contain duplicates` });
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
.optional();
|
|
20
|
+
/**
|
|
21
|
+
* The org's sandbox-mode network (org egress ceiling spec §D1), stored as a delta over the
|
|
22
|
+
* platform's `sandbox.limits.allowHosts`, never a copy of it, so platform changes keep reaching the
|
|
23
|
+
* org:
|
|
24
|
+
* - `mode`: the cloud network of a cloud device in sandbox mode, `open` (any public host; loopback,
|
|
25
|
+
* private and cloud metadata addresses are blocked outside the container) or `allowlist`; absent
|
|
26
|
+
* follows the platform's default (open). `sandbox.limits.orgHosts: within` makes it the allowlist.
|
|
27
|
+
* - `base`: `platform` (the default: start from the platform's list) or `none` (only the org's own
|
|
28
|
+
* hosts).
|
|
29
|
+
* - `extraHosts`: hosts the org adds (ignored outside the platform list under `within`).
|
|
30
|
+
* - `excludedHosts`: platform entries the org drops (exact entries; any host is accepted, since the
|
|
31
|
+
* platform may drop an entry later).
|
|
32
|
+
* The effective hosts ({@link orgEffectiveHosts} in `sandbox/modes.ts`) are also the ceiling a local
|
|
33
|
+
* device in sandbox mode reaches (the device intersects them with its own list).
|
|
34
|
+
*/
|
|
35
|
+
export const CloudNetworkSettingSchema = z
|
|
36
|
+
.object({
|
|
37
|
+
mode: z.enum(["open", "allowlist"]).optional(),
|
|
38
|
+
base: z.enum(["platform", "none"]).optional(),
|
|
39
|
+
extraHosts: orgHostList("extraHosts"),
|
|
40
|
+
excludedHosts: orgHostList("excludedHosts"),
|
|
41
|
+
})
|
|
42
|
+
.strict();
|
|
43
|
+
/** What an invalid stored `cloudNetwork` reads as: the allowlist with no host (never wider). */
|
|
44
|
+
export const invalidCloudNetwork = () => ({
|
|
45
|
+
mode: "allowlist",
|
|
46
|
+
base: "none",
|
|
47
|
+
});
|
|
@@ -6,6 +6,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
|
|
|
6
6
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
7
7
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
8
8
|
import type { KernelLogger } from "../log.js";
|
|
9
|
+
import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
|
|
9
10
|
import { ApprovalsService } from "../tools/approvals.service.js";
|
|
10
11
|
import { Credentials } from "../tools/credentials.js";
|
|
11
12
|
import { QuestionsService } from "../tools/questions.service.js";
|
|
@@ -84,6 +85,7 @@ export declare class Offboarding {
|
|
|
84
85
|
/** Owes `org.member_removed` to the subscribing plugins, in the offboard transaction. */
|
|
85
86
|
private readonly lifecycle;
|
|
86
87
|
readonly log: KernelLogger;
|
|
88
|
+
private readonly ceilings;
|
|
87
89
|
private readonly orgLock;
|
|
88
90
|
constructor(db: KernelDb, txHost: TransactionHost, sessions: Pick<SessionService, "markRevoked">, registry: Pick<ExtensionRegistry, "list">, eventLog: Pick<EventLog, "notify" | "publishChanged">,
|
|
89
91
|
/** Owes the run stops and device destroys in the offboard transaction. */
|
|
@@ -91,7 +93,7 @@ export declare class Offboarding {
|
|
|
91
93
|
/** Stops the departed member's runs (`by: null`, a system action) in the `run-stop` job. */
|
|
92
94
|
runs: OffboardingRunControl, credentials: Pick<Credentials, "clearAccount">, approvals: Pick<ApprovalsService, "pendingConversationsFor" | "cancelPendingFor">, questions: Pick<QuestionsService, "pendingConversationsFor" | "cancelPendingFor">,
|
|
93
95
|
/** Owes `org.member_removed` to the subscribing plugins, in the offboard transaction. */
|
|
94
|
-
lifecycle: Pick<LifecycleHooks, "recordIn">, log: KernelLogger, orgLock: Pick<OrgLock, "lockForRemoval">);
|
|
96
|
+
lifecycle: Pick<LifecycleHooks, "recordIn">, log: KernelLogger, ceilings: PermissionCeilingWrites, orgLock: Pick<OrgLock, "lockForRemoval">);
|
|
95
97
|
/**
|
|
96
98
|
* In the caller's transaction (`mandatory`: the caller holds the org row lock, order org row →
|
|
97
99
|
* membership, and did the "last owner" checks):
|
package/dist/orgs/offboarding.js
CHANGED
|
@@ -27,6 +27,7 @@ import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
|
27
27
|
import { MAINTENANCE_QUEUE_NAME } from "../runtime/maintenance-queue.js";
|
|
28
28
|
import { RunControl } from "../runtime/run-control.js";
|
|
29
29
|
import { oweDeviceDestroy } from "../sandbox/jobs.js";
|
|
30
|
+
import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
|
|
30
31
|
import { ApprovalsService } from "../tools/approvals.service.js";
|
|
31
32
|
import { Credentials } from "../tools/credentials.js";
|
|
32
33
|
import { QuestionsService } from "../tools/questions.service.js";
|
|
@@ -66,6 +67,7 @@ let Offboarding = class Offboarding {
|
|
|
66
67
|
questions;
|
|
67
68
|
lifecycle;
|
|
68
69
|
log;
|
|
70
|
+
ceilings;
|
|
69
71
|
orgLock;
|
|
70
72
|
constructor(db, txHost, sessions, registry, eventLog,
|
|
71
73
|
/** Owes the run stops and device destroys in the offboard transaction. */
|
|
@@ -73,7 +75,7 @@ let Offboarding = class Offboarding {
|
|
|
73
75
|
/** Stops the departed member's runs (`by: null`, a system action) in the `run-stop` job. */
|
|
74
76
|
runs, credentials, approvals, questions,
|
|
75
77
|
/** Owes `org.member_removed` to the subscribing plugins, in the offboard transaction. */
|
|
76
|
-
lifecycle, log, orgLock) {
|
|
78
|
+
lifecycle, log, ceilings, orgLock) {
|
|
77
79
|
this.db = db;
|
|
78
80
|
this.txHost = txHost;
|
|
79
81
|
this.sessions = sessions;
|
|
@@ -86,6 +88,7 @@ let Offboarding = class Offboarding {
|
|
|
86
88
|
this.questions = questions;
|
|
87
89
|
this.lifecycle = lifecycle;
|
|
88
90
|
this.log = log;
|
|
91
|
+
this.ceilings = ceilings;
|
|
89
92
|
this.orgLock = orgLock;
|
|
90
93
|
}
|
|
91
94
|
/**
|
|
@@ -114,6 +117,8 @@ let Offboarding = class Offboarding {
|
|
|
114
117
|
// the org admission lock exclusively (the callers take it first, before the org row; a no-op
|
|
115
118
|
// then): it waits for the run writes the fence admitted shared and keeps new ones out
|
|
116
119
|
await this.orgLock.lockForRemoval(orgId);
|
|
120
|
+
await this.ceilings.lock({ orgId }, "org");
|
|
121
|
+
await this.ceilings.publishLocked({ orgId }, "org", (_scope, row) => row.account_id === accountId);
|
|
117
122
|
const deleted = await this.db
|
|
118
123
|
.deleteFrom("memberships")
|
|
119
124
|
.where("org_id", "=", orgId)
|
|
@@ -470,6 +475,7 @@ Offboarding = __decorate([
|
|
|
470
475
|
__param(9, Inject(QuestionsService)),
|
|
471
476
|
__param(10, Inject(LifecycleHooks)),
|
|
472
477
|
__param(11, Inject(KERNEL_LOGGER)),
|
|
473
|
-
__param(12, Inject(
|
|
478
|
+
__param(12, Inject(PermissionCeilingWrites)),
|
|
479
|
+
__param(13, Inject(OrgLock))
|
|
474
480
|
], Offboarding);
|
|
475
481
|
export { Offboarding };
|
package/dist/orgs/org-lock.d.ts
CHANGED
|
@@ -20,10 +20,16 @@ export interface LockedOrg {
|
|
|
20
20
|
* `FOR UPDATE`: org deletion's `deleted_at` update is a no-key update too.
|
|
21
21
|
*
|
|
22
22
|
* The global lock order: the org admission lock ({@link lockForRemoval}; the run fence's shared
|
|
23
|
-
* admission, `RunExecution`) → this org row lock (also the run fence's exclusive admission) →
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
23
|
+
* admission, `RunExecution`) → this org row lock (also the run fence's exclusive admission) → a
|
|
24
|
+
* membership row → a device row (`DevicesService.lockOwn`, the device project writes, the cloud
|
|
25
|
+
* permission snapshot) → the super admin advisory lock (`SuperAdminLock`) → the permission
|
|
26
|
+
* authority locks (`PermissionAuthorityLock`: platform, org, device, root; inside a run's fence
|
|
27
|
+
* an ordered prelude takes them and the locks before them, `withOrderedLocks` /
|
|
28
|
+
* `withTransactionFencePrelude`) → the root conversation → the conversation (then what a writer
|
|
29
|
+
* locks under its conversation: an approval, a run, a machine row). A writer that locks several
|
|
30
|
+
* conversation or run rows of one tree locks the tree's root conversation first. A transaction
|
|
31
|
+
* the run fence admitted shared takes none of these org-level locks (each method throws in one,
|
|
32
|
+
* `assertNotSharedAdmission`).
|
|
27
33
|
*/
|
|
28
34
|
export declare class OrgLock {
|
|
29
35
|
private readonly db;
|
package/dist/orgs/org-lock.js
CHANGED
|
@@ -27,10 +27,16 @@ import { can } from "./roles.js";
|
|
|
27
27
|
* `FOR UPDATE`: org deletion's `deleted_at` update is a no-key update too.
|
|
28
28
|
*
|
|
29
29
|
* The global lock order: the org admission lock ({@link lockForRemoval}; the run fence's shared
|
|
30
|
-
* admission, `RunExecution`) → this org row lock (also the run fence's exclusive admission) →
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
30
|
+
* admission, `RunExecution`) → this org row lock (also the run fence's exclusive admission) → a
|
|
31
|
+
* membership row → a device row (`DevicesService.lockOwn`, the device project writes, the cloud
|
|
32
|
+
* permission snapshot) → the super admin advisory lock (`SuperAdminLock`) → the permission
|
|
33
|
+
* authority locks (`PermissionAuthorityLock`: platform, org, device, root; inside a run's fence
|
|
34
|
+
* an ordered prelude takes them and the locks before them, `withOrderedLocks` /
|
|
35
|
+
* `withTransactionFencePrelude`) → the root conversation → the conversation (then what a writer
|
|
36
|
+
* locks under its conversation: an approval, a run, a machine row). A writer that locks several
|
|
37
|
+
* conversation or run rows of one tree locks the tree's root conversation first. A transaction
|
|
38
|
+
* the run fence admitted shared takes none of these org-level locks (each method throws in one,
|
|
39
|
+
* `assertNotSharedAdmission`).
|
|
34
40
|
*/
|
|
35
41
|
let OrgLock = class OrgLock {
|
|
36
42
|
db;
|
|
@@ -9,6 +9,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
|
|
|
9
9
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
10
10
|
import { KernelEvents } from "../infra/events/kernel-events.js";
|
|
11
11
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
12
|
+
import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
|
|
12
13
|
import { OrgLock } from "./org-lock.js";
|
|
13
14
|
import type { OrgRole } from "./roles.js";
|
|
14
15
|
export type Org = {
|
|
@@ -41,6 +42,7 @@ export declare class OrgsService {
|
|
|
41
42
|
private readonly ownedItems;
|
|
42
43
|
/** Records `org.deleted` for the subscribing plugins in the delete's transaction. */
|
|
43
44
|
private readonly lifecycle;
|
|
45
|
+
private readonly ceilings;
|
|
44
46
|
constructor(db: KernelDb, outbox: Pick<OutboxService, "add">, txHost: TransactionHost, settings: SettingsService, apiTokens: ApiTokenService, orgLock: OrgLock, events: KernelEvents,
|
|
45
47
|
/** Cancels the deleted org's running eval runs (in the delete's transaction). */
|
|
46
48
|
evalBudget: Pick<EvalBudget, "cancelRuns">,
|
|
@@ -49,7 +51,7 @@ export declare class OrgsService {
|
|
|
49
51
|
/** What the deleted org owns is transferred or removed in the delete's transaction (P3-20). */
|
|
50
52
|
ownedItems: Pick<OwnedItems, "onOrgDeleted">,
|
|
51
53
|
/** Records `org.deleted` for the subscribing plugins in the delete's transaction. */
|
|
52
|
-
lifecycle: Pick<LifecycleHooks, "recordIn"
|
|
54
|
+
lifecycle: Pick<LifecycleHooks, "recordIn">, ceilings: PermissionCeilingWrites);
|
|
53
55
|
/**
|
|
54
56
|
* Creates an org with the actor as owner, in the caller's transaction when there is one (the
|
|
55
57
|
* setup wizard creates it with the account); a slug conflict is `org.slug_taken` either way, but
|
|
@@ -28,6 +28,7 @@ import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
|
28
28
|
import { MAINTENANCE_QUEUE_NAME } from "../runtime/maintenance-queue.js";
|
|
29
29
|
import { STOP_DELETED_ORG_JOB } from "../runtime/run-deletion.js";
|
|
30
30
|
import { USAGE_REPORT_QUEUE } from "../runtime/usage-report-jobs.js";
|
|
31
|
+
import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
|
|
31
32
|
import { OrgLock } from "./org-lock.js";
|
|
32
33
|
/** 组织 slug:小写字母数字与 `-`,首尾不能是 `-`,1–40 个字符。 */
|
|
33
34
|
export const SLUG_RE = /^[a-z0-9](?:[a-z0-9-]{0,38}[a-z0-9])?$/;
|
|
@@ -92,6 +93,7 @@ let OrgsService = class OrgsService {
|
|
|
92
93
|
scopeSync;
|
|
93
94
|
ownedItems;
|
|
94
95
|
lifecycle;
|
|
96
|
+
ceilings;
|
|
95
97
|
constructor(db, outbox, txHost, settings, apiTokens, orgLock, events,
|
|
96
98
|
/** Cancels the deleted org's running eval runs (in the delete's transaction). */
|
|
97
99
|
evalBudget,
|
|
@@ -100,7 +102,7 @@ let OrgsService = class OrgsService {
|
|
|
100
102
|
/** What the deleted org owns is transferred or removed in the delete's transaction (P3-20). */
|
|
101
103
|
ownedItems,
|
|
102
104
|
/** Records `org.deleted` for the subscribing plugins in the delete's transaction. */
|
|
103
|
-
lifecycle) {
|
|
105
|
+
lifecycle, ceilings) {
|
|
104
106
|
this.db = db;
|
|
105
107
|
this.outbox = outbox;
|
|
106
108
|
this.txHost = txHost;
|
|
@@ -112,6 +114,7 @@ let OrgsService = class OrgsService {
|
|
|
112
114
|
this.scopeSync = scopeSync;
|
|
113
115
|
this.ownedItems = ownedItems;
|
|
114
116
|
this.lifecycle = lifecycle;
|
|
117
|
+
this.ceilings = ceilings;
|
|
115
118
|
}
|
|
116
119
|
/**
|
|
117
120
|
* Creates an org with the actor as owner, in the caller's transaction when there is one (the
|
|
@@ -248,6 +251,8 @@ let OrgsService = class OrgsService {
|
|
|
248
251
|
await this.orgLock.precheck(orgId, actor.id, "org.delete");
|
|
249
252
|
await this.orgLock.lockForRemoval(orgId);
|
|
250
253
|
await this.orgLock.lockAndAuthorize(orgId, actor.id, "org.delete");
|
|
254
|
+
await this.ceilings.lock({ orgId }, "org");
|
|
255
|
+
await this.ceilings.publishLocked({ orgId }, "org");
|
|
251
256
|
await this.db
|
|
252
257
|
.updateTable("orgs")
|
|
253
258
|
.set({ deleted_at: sql `now()` })
|
|
@@ -316,6 +321,7 @@ OrgsService = __decorate([
|
|
|
316
321
|
__param(7, Inject(EvalBudget)),
|
|
317
322
|
__param(8, Inject(PluginScopeSync)),
|
|
318
323
|
__param(9, Inject(OwnedItems)),
|
|
319
|
-
__param(10, Inject(LifecycleHooks))
|
|
324
|
+
__param(10, Inject(LifecycleHooks)),
|
|
325
|
+
__param(11, Inject(PermissionCeilingWrites))
|
|
320
326
|
], OrgsService);
|
|
321
327
|
export { OrgsService };
|
|
@@ -7,7 +7,10 @@ import { type OrgEffectiveNetwork, type OrgSandboxLimits, type OrgSettingsDeploy
|
|
|
7
7
|
* 以及只读的 `sandboxLimits`(组织实际生效的沙箱 cpu / 内存与来源,超级管理员在部署设置里覆盖,C19)。
|
|
8
8
|
*/
|
|
9
9
|
type SettingsResponse = {
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* `scheduledTasks.forbiddenToolsUnreadable: true` when the stored list cannot be read; `autoMode`
|
|
12
|
+
* mirrors `fullAccess`.
|
|
13
|
+
*/
|
|
11
14
|
settings: OrgSettingsView;
|
|
12
15
|
deployment: OrgSettingsDeployment;
|
|
13
16
|
/** The org's effective sandbox-mode network (org egress ceiling spec §D4). */
|
|
@@ -12,7 +12,7 @@ import { CurrentPrincipal, patTokenId, requireUser, } from "../identity/principa
|
|
|
12
12
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
13
13
|
import { ZBody } from "../infra/validation/zod-params.js";
|
|
14
14
|
import { CurrentOrg, OrgAction } from "./org.guard.js";
|
|
15
|
-
import { OrgSettingsPatchSchema, OrgSettingsService, } from "./settings.service.js";
|
|
15
|
+
import { OrgSettingsPatchSchema, OrgSettingsService, orgSettingsView, } from "./settings.service.js";
|
|
16
16
|
class OrgSettingsPatchBody extends createZodDto(OrgSettingsPatchSchema, "OrgSettingsPatch") {
|
|
17
17
|
}
|
|
18
18
|
let OrgSettingsController = class OrgSettingsController {
|
|
@@ -23,7 +23,7 @@ let OrgSettingsController = class OrgSettingsController {
|
|
|
23
23
|
async get(org) {
|
|
24
24
|
const settings = await this.settings.get(org.orgId);
|
|
25
25
|
return {
|
|
26
|
-
settings,
|
|
26
|
+
settings: orgSettingsView(settings),
|
|
27
27
|
deployment: await this.settings.deployment(),
|
|
28
28
|
effectiveNetwork: this.settings.effectiveNetwork(settings),
|
|
29
29
|
sandboxLimits: await this.settings.sandboxLimits(org.orgId),
|
|
@@ -34,7 +34,7 @@ let OrgSettingsController = class OrgSettingsController {
|
|
|
34
34
|
// an API token may narrow auto mode and the cloud network, never widen them (auto mode spec §4.3)
|
|
35
35
|
const settings = await this.settings.update(org.orgId, body, p.account.id, patTokenId(p), undefined, { onlyNarrows: patTokenId(p) !== undefined });
|
|
36
36
|
return {
|
|
37
|
-
settings,
|
|
37
|
+
settings: orgSettingsView(settings),
|
|
38
38
|
deployment: await this.settings.deployment(),
|
|
39
39
|
effectiveNetwork: this.settings.effectiveNetwork(settings),
|
|
40
40
|
sandboxLimits: await this.settings.sandboxLimits(org.orgId),
|