@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/evals/run-replay.js
CHANGED
|
@@ -27,6 +27,7 @@ import { runContextIdemKey } from "../runtime/run-context.service.js";
|
|
|
27
27
|
import { recordedSkillForks } from "../runtime/subagents/skill-fork.js";
|
|
28
28
|
import { skillsCatalogIdemKey } from "../skills/catalog.js";
|
|
29
29
|
import { ACTIVE_EVAL_STATUSES, addUsage, consumeTokens, TOO_MANY_ERRORS, usageTokens, } from "./budget.js";
|
|
30
|
+
import { recordedPermissionContext, recordedRunPermissionDrift, } from "./recorded-permission-context.js";
|
|
30
31
|
import { RecordedToolPipeline, recordedCalls } from "./recorded-tools.js";
|
|
31
32
|
import { toEvents } from "./snapshot.js";
|
|
32
33
|
/** 写种子时发现已失去认领或运行已不在执行:本次执行停下,不留评测对话。 */
|
|
@@ -371,6 +372,14 @@ export async function replayRun(d, s, candidate, evalRunId, signal) {
|
|
|
371
372
|
const source = s.source ?? (subagent === undefined ? "web" : "subagent");
|
|
372
373
|
const conversationId = randomUUID();
|
|
373
374
|
const runId = randomUUID();
|
|
375
|
+
// recorded permission context (spec B4), both before anything is seeded so an invalid recording
|
|
376
|
+
// fails as `eval.snapshot_invalid` without an eval conversation: the original-coordinate
|
|
377
|
+
// diagnostics, and the recorded-only feeder (undefined for a recording without markers)
|
|
378
|
+
const permissionContextDrift = recordedRunPermissionDrift(s);
|
|
379
|
+
const permissionContext = recordedPermissionContext(s, eventLog, { conversationId, runId });
|
|
380
|
+
// the recorded tool results (reviews validated here) are read before the seed too, so an
|
|
381
|
+
// invalid recording leaves no eval conversation either
|
|
382
|
+
const recordings = recordedCalls(s);
|
|
374
383
|
await d.seeder.seed({
|
|
375
384
|
evalRunId,
|
|
376
385
|
orgId: s.orgId,
|
|
@@ -486,7 +495,7 @@ export async function replayRun(d, s, candidate, evalRunId, signal) {
|
|
|
486
495
|
};
|
|
487
496
|
const pipeline = new RecordedToolPipeline({
|
|
488
497
|
eventLog,
|
|
489
|
-
recordings
|
|
498
|
+
recordings,
|
|
490
499
|
// 出错直接抛出:tools 节点的异常让 loop 抛出,按崩溃处理
|
|
491
500
|
beforeStep: async () => {
|
|
492
501
|
if (await allowed())
|
|
@@ -565,7 +574,13 @@ export async function replayRun(d, s, candidate, evalRunId, signal) {
|
|
|
565
574
|
timer?.unref();
|
|
566
575
|
// a fork invocation's report is the recorded one: a replay never dispatches a sub-agent (A5)
|
|
567
576
|
const skillForks = recordedSkillForks(eventLog, s.events.filter((e) => e.runId === s.runId));
|
|
568
|
-
const loop = d.loop({
|
|
577
|
+
const loop = d.loop({
|
|
578
|
+
toolPipeline: pipeline,
|
|
579
|
+
registry,
|
|
580
|
+
skillForks,
|
|
581
|
+
...(media && { media }),
|
|
582
|
+
...(permissionContext !== undefined && { permissionContext }),
|
|
583
|
+
});
|
|
569
584
|
// a replay never executes a tool, so the role only completes the context
|
|
570
585
|
const membership = await db
|
|
571
586
|
.selectFrom("memberships")
|
|
@@ -662,5 +677,6 @@ export async function replayRun(d, s, candidate, evalRunId, signal) {
|
|
|
662
677
|
outcome: outcome.kind,
|
|
663
678
|
...summary,
|
|
664
679
|
unmatched: pipeline.unmatched(),
|
|
680
|
+
...(permissionContextDrift && { permissionContextDrift: true }),
|
|
665
681
|
};
|
|
666
682
|
}
|
|
@@ -54,7 +54,7 @@ export interface TrajectoryToolCall {
|
|
|
54
54
|
approval: {
|
|
55
55
|
approvalId: string;
|
|
56
56
|
requestedAt: string;
|
|
57
|
-
decision: "approved" | "denied" | "expired" | "cancelled" | "skipped" | null;
|
|
57
|
+
decision: "approved" | "denied" | "expired" | "cancelled" | "skipped" | "superseded" | null;
|
|
58
58
|
scope?: "once" | "session" | "always";
|
|
59
59
|
byAccountId: string | null;
|
|
60
60
|
decidedAt: string | null;
|
package/dist/evals/worker.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
|
7
7
|
import type { KernelLogger } from "../log.js";
|
|
8
8
|
import { ModelPurposesService } from "../models/purposes.js";
|
|
9
9
|
import { KyselyCheckpointSaver } from "../runtime/checkpointer.js";
|
|
10
|
+
import type { LoopDeps } from "../runtime/langgraph-loop.js";
|
|
10
11
|
import { ProviderRegistry } from "../runtime/providers.js";
|
|
11
12
|
import { type OrgQuota } from "../runtime/quota.js";
|
|
12
13
|
import { RunFinish } from "../runtime/run-finish.js";
|
|
@@ -14,7 +15,7 @@ import { AgentLoops, RunSteps } from "../runtime/run-steps.js";
|
|
|
14
15
|
import { EvalBudget } from "./budget.js";
|
|
15
16
|
import { type EvalJobData } from "./jobs.js";
|
|
16
17
|
import { type SubagentTemplateRef } from "./reconstruct.js";
|
|
17
|
-
import { type EvalReplayHooks, EvalReplaySeeder } from "./run-replay.js";
|
|
18
|
+
import { type EvalReplayHooks, EvalReplaySeeder, type RunReplayDeps } from "./run-replay.js";
|
|
18
19
|
import { type CaseSnapshot } from "./snapshot.js";
|
|
19
20
|
/**
|
|
20
21
|
* 评测 worker(C7,只在含 `worker` 角色的进程启动):领取 `cap-kernel-evals` 的任务,每个任务回放一个用例。
|
|
@@ -41,6 +42,14 @@ export declare const EVAL_MAX_STALLED_COUNT = 3;
|
|
|
41
42
|
* (`overrides: [{ provide: EVAL_REPLAY_HOOKS, useValue }]`), absent in production.
|
|
42
43
|
*/
|
|
43
44
|
export declare const EVAL_REPLAY_HOOKS: unique symbol;
|
|
45
|
+
/**
|
|
46
|
+
* The loop deps of a full-run replay: the run's own step deps without anything live that a replay
|
|
47
|
+
* must never trigger, then the replay's overrides. Removed: plugin hooks (P-18), sub-agent and
|
|
48
|
+
* compaction progress on a live stream, fork dispatch (run-replay passes the recorded reports) and
|
|
49
|
+
* the live permission context recorder (permission context replay spec B4): a replay gets only the
|
|
50
|
+
* recorded feeder `overrides.permissionContext`, and none at all for a recording without markers.
|
|
51
|
+
*/
|
|
52
|
+
export declare function replayLoopDeps(stepDeps: LoopDeps, overrides: Parameters<RunReplayDeps["loop"]>[0]): LoopDeps;
|
|
44
53
|
export declare class EvalWorker {
|
|
45
54
|
readonly txHost: TransactionHost;
|
|
46
55
|
private worker;
|
package/dist/evals/worker.js
CHANGED
|
@@ -70,6 +70,25 @@ export const EVAL_REPLAY_HOOKS = Symbol("EVAL_REPLAY_HOOKS");
|
|
|
70
70
|
/** 供应商插件在调用途中被撤销(错误本身或其 cause)。 */
|
|
71
71
|
const isPluginUnloaded = (err) => err instanceof ExtensionUnloadedError ||
|
|
72
72
|
(err instanceof Error && err.cause instanceof ExtensionUnloadedError);
|
|
73
|
+
/**
|
|
74
|
+
* The loop deps of a full-run replay: the run's own step deps without anything live that a replay
|
|
75
|
+
* must never trigger, then the replay's overrides. Removed: plugin hooks (P-18), sub-agent and
|
|
76
|
+
* compaction progress on a live stream, fork dispatch (run-replay passes the recorded reports) and
|
|
77
|
+
* the live permission context recorder (permission context replay spec B4): a replay gets only the
|
|
78
|
+
* recorded feeder `overrides.permissionContext`, and none at all for a recording without markers.
|
|
79
|
+
*/
|
|
80
|
+
export function replayLoopDeps(stepDeps, overrides) {
|
|
81
|
+
const { db: _snapshot, hooks: _noHooks, subagentProgress: _noProgress, compactionProgress: _noCompactionProgress, skillForks: _noForks, permissionContext: _noLivePermissionContext, ...replayDeps } = stepDeps;
|
|
82
|
+
// the object rest above copied `db` as a value: read it through the step deps' getter
|
|
83
|
+
// instead, so the loop always resolves the context-aware handle
|
|
84
|
+
return {
|
|
85
|
+
...replayDeps,
|
|
86
|
+
get db() {
|
|
87
|
+
return stepDeps.db;
|
|
88
|
+
},
|
|
89
|
+
...overrides,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
73
92
|
/** 回放出错的分类(与运行时的降级梯子同一套码)。 */
|
|
74
93
|
function classify(err) {
|
|
75
94
|
if (isModelError(err)) {
|
|
@@ -201,19 +220,7 @@ let EvalWorker = class EvalWorker {
|
|
|
201
220
|
checkpoints,
|
|
202
221
|
// explicitly without plugin hooks: eval replays never fire them (P-18); nor do they
|
|
203
222
|
// publish sub-agent progress on a live conversation's stream
|
|
204
|
-
loop: (d) =>
|
|
205
|
-
// nor dispatch fork invocations: run-replay passes the recorded reports instead
|
|
206
|
-
const { db: _snapshot, hooks: _noHooks, subagentProgress: _noProgress, compactionProgress: _noCompactionProgress, skillForks: _noForks, ...replayDeps } = stepDeps;
|
|
207
|
-
// the object rest above copied `db` as a value: read it through the step deps' getter
|
|
208
|
-
// instead, so the loop always resolves the context-aware handle
|
|
209
|
-
return loops.create({
|
|
210
|
-
...replayDeps,
|
|
211
|
-
get db() {
|
|
212
|
-
return stepDeps.db;
|
|
213
|
-
},
|
|
214
|
-
...d,
|
|
215
|
-
});
|
|
216
|
-
},
|
|
223
|
+
loop: (d) => loops.create(replayLoopDeps(stepDeps, d)),
|
|
217
224
|
...(hooks !== undefined && { hooks }),
|
|
218
225
|
},
|
|
219
226
|
};
|
|
@@ -684,10 +691,12 @@ let EvalWorker = class EvalWorker {
|
|
|
684
691
|
if (!(await held()))
|
|
685
692
|
return;
|
|
686
693
|
const baseline = runBaseline(s);
|
|
687
|
-
// in DRIFT_ORDER: subagent_changed,
|
|
694
|
+
// in DRIFT_ORDER: subagent_changed, permission_profile_changed (a recorded permission
|
|
695
|
+
// context the snapshot cannot reproduce), model_switched (the candidate replaced the person's
|
|
688
696
|
// switch), then tool_unmatched
|
|
689
697
|
const drift = [
|
|
690
698
|
...(subagentCaseChanged(s, resolved) ? ["subagent_changed"] : []),
|
|
699
|
+
...(out.permissionContextDrift ? ["permission_profile_changed"] : []),
|
|
691
700
|
...(resolved.overridesSwitch ? ["model_switched"] : []),
|
|
692
701
|
...(out.unmatched > 0 ? ["tool_unmatched"] : []),
|
|
693
702
|
];
|
|
@@ -12,6 +12,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
|
|
|
12
12
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
13
13
|
import type { KernelLogger } from "../log.js";
|
|
14
14
|
import { ModelEmbeddings } from "../models/embeddings.js";
|
|
15
|
+
import { ModelImages } from "../models/images.js";
|
|
15
16
|
import { OrgNetworkAllowances } from "../orgs/network-allowances.service.js";
|
|
16
17
|
import { EmbedTokens } from "../ui/embed-token.js";
|
|
17
18
|
import type { UiActionHandler, UiRender } from "../ui/registry.js";
|
|
@@ -266,7 +267,9 @@ export declare class ExtensionHost {
|
|
|
266
267
|
*/
|
|
267
268
|
effective: Pick<EffectiveConfigs, "get">,
|
|
268
269
|
/** `ctx.models`: the embeddings broker (spec B §5.4). */
|
|
269
|
-
|
|
270
|
+
embeddings: Pick<ModelEmbeddings, "embed" | "describe">,
|
|
271
|
+
/** `ctx.models.generateImage`: the image generation calls (image generation spec §5.5). */
|
|
272
|
+
images: Pick<ModelImages, "generateForExtension" | "describeForExtension">,
|
|
270
273
|
/** `ctx.net`: the internal endpoints each org's extension requests may reach (read per call). */
|
|
271
274
|
allowances: OrgNetworkAllowances,
|
|
272
275
|
/** Tests only: `ctx.net`'s DNS and dispatcher seams (`EXTENSION_NET_SEAMS`). */
|
package/dist/extensions/host.js
CHANGED
|
@@ -26,6 +26,7 @@ import { LockService } from "../infra/lock/lock.service.js";
|
|
|
26
26
|
import { KERNEL_LOGGER, KEYRING, REDIS, REDIS_SUBSCRIBER } from "../infra/tokens.js";
|
|
27
27
|
import { KERNEL_APP_OPTIONS } from "../lifecycle/tokens.js";
|
|
28
28
|
import { ModelEmbeddings } from "../models/embeddings.js";
|
|
29
|
+
import { ModelImages } from "../models/images.js";
|
|
29
30
|
import { OrgNetworkAllowances } from "../orgs/network-allowances.service.js";
|
|
30
31
|
import { packagePath } from "../packages/tgz.js";
|
|
31
32
|
import { EmbedTokens } from "../ui/embed-token.js";
|
|
@@ -413,7 +414,9 @@ let ExtensionHost = class ExtensionHost {
|
|
|
413
414
|
*/
|
|
414
415
|
effective,
|
|
415
416
|
/** `ctx.models`: the embeddings broker (spec B §5.4). */
|
|
416
|
-
|
|
417
|
+
embeddings,
|
|
418
|
+
/** `ctx.models.generateImage`: the image generation calls (image generation spec §5.5). */
|
|
419
|
+
images,
|
|
417
420
|
/** `ctx.net`: the internal endpoints each org's extension requests may reach (read per call). */
|
|
418
421
|
allowances,
|
|
419
422
|
/** Tests only: `ctx.net`'s DNS and dispatcher seams (`EXTENSION_NET_SEAMS`). */
|
|
@@ -445,8 +448,8 @@ let ExtensionHost = class ExtensionHost {
|
|
|
445
448
|
redisUrl: c.redis.url,
|
|
446
449
|
keyring,
|
|
447
450
|
embedTokens,
|
|
448
|
-
models,
|
|
449
|
-
// ctx.models.embed
|
|
451
|
+
models: { embeddings, images },
|
|
452
|
+
// ctx.models.embed and generateImage fire model.request through the same registry
|
|
450
453
|
hooks: this.hooks,
|
|
451
454
|
net: { config, allowances, ...(netSeams !== undefined && { seams: netSeams }) },
|
|
452
455
|
locks,
|
|
@@ -2394,8 +2397,9 @@ ExtensionHost = __decorate([
|
|
|
2394
2397
|
__param(12, Inject(KERNEL_APP_OPTIONS)),
|
|
2395
2398
|
__param(13, Inject(EffectiveConfigs)),
|
|
2396
2399
|
__param(14, Inject(ModelEmbeddings)),
|
|
2397
|
-
__param(15, Inject(
|
|
2398
|
-
__param(16,
|
|
2399
|
-
__param(
|
|
2400
|
+
__param(15, Inject(ModelImages)),
|
|
2401
|
+
__param(16, Inject(OrgNetworkAllowances)),
|
|
2402
|
+
__param(17, Optional()),
|
|
2403
|
+
__param(17, Inject(EXTENSION_NET_SEAMS))
|
|
2400
2404
|
], ExtensionHost);
|
|
2401
2405
|
export { ExtensionHost };
|
package/dist/http/api.module.js
CHANGED
|
@@ -40,6 +40,7 @@ import { ClientDeliveryController } from "../client/client-delivery.controller.j
|
|
|
40
40
|
import { AttachmentsController } from "../conversations/attachments.controller.js";
|
|
41
41
|
import { ConversationsController } from "../conversations/conversations.controller.js";
|
|
42
42
|
import { ConversationsModule } from "../conversations/conversations.module.js";
|
|
43
|
+
import { PermissionProfilesController } from "../conversations/permission-profiles.controller.js";
|
|
43
44
|
import { DevicesController } from "../devices/devices.controller.js";
|
|
44
45
|
import { DevicesModule } from "../devices/devices.module.js";
|
|
45
46
|
import { EvalsModule } from "../evals/evals.module.js";
|
|
@@ -129,6 +130,7 @@ const CONTROLLERS = [
|
|
|
129
130
|
ModelEnablementController,
|
|
130
131
|
ReadinessController,
|
|
131
132
|
ConversationsController,
|
|
133
|
+
PermissionProfilesController,
|
|
132
134
|
BackgroundController,
|
|
133
135
|
DevicesController,
|
|
134
136
|
SchedulesController,
|
|
@@ -3,6 +3,7 @@ import { SetupLock } from "../admin/setup-lock.js";
|
|
|
3
3
|
import type { AccountsTable } from "../db/kernel-schema.js";
|
|
4
4
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
5
5
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
6
|
+
import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
|
|
6
7
|
import { SuperAdminLock } from "./super-admin.js";
|
|
7
8
|
export interface Account {
|
|
8
9
|
id: string;
|
|
@@ -56,7 +57,8 @@ export declare class AccountsService {
|
|
|
56
57
|
readonly txHost: TransactionHost;
|
|
57
58
|
private readonly adminLock;
|
|
58
59
|
private readonly setupLock;
|
|
59
|
-
|
|
60
|
+
private readonly ceilings;
|
|
61
|
+
constructor(db: KernelDb, txHost: TransactionHost, adminLock: SuperAdminLock, setupLock: SetupLock, ceilings: PermissionCeilingWrites);
|
|
60
62
|
/** Checks the password length and hashes it (scrypt, slow): for callers that hash before their transaction opens. */
|
|
61
63
|
hashNewPassword(password: string): Promise<string>;
|
|
62
64
|
/**
|
|
@@ -140,6 +142,11 @@ export declare class AccountsService {
|
|
|
140
142
|
* account's sessions (`sessions.revoked_at`) and personal tokens in **the same PG transaction**,
|
|
141
143
|
* all or nothing; returns the revoked session ids, whose Redis markers the caller writes after
|
|
142
144
|
* the commit (the fast path; a failure is only a warning: auth reads PG).
|
|
145
|
+
*
|
|
146
|
+
* The super admin lock and, for a status change, the platform permission authority lock are the
|
|
147
|
+
* transaction's ordered prelude (`withOrderedLocks`): inside a run's fence (the Platform tool's
|
|
148
|
+
* `accounts.disable` / `accounts.enable`) they follow the org row and precede the conversation
|
|
149
|
+
* rows.
|
|
143
150
|
*/
|
|
144
151
|
updateAccount(id: string, patch: AccountPatch, actorAccountId: string, actorTokenId?: string, opts?: {
|
|
145
152
|
auditDetail?: Record<string, unknown>;
|
|
@@ -147,6 +154,12 @@ export declare class AccountsService {
|
|
|
147
154
|
account: Account;
|
|
148
155
|
revokedSessionIds: string[];
|
|
149
156
|
}>;
|
|
157
|
+
/**
|
|
158
|
+
* The prelude of {@link updateAccount}: the super admin lock (re-checking the actor), then the
|
|
159
|
+
* platform permission authority lock when the status changes; whether it locked it.
|
|
160
|
+
*/
|
|
161
|
+
private lockForUpdate;
|
|
162
|
+
private updateAccountIn;
|
|
150
163
|
/**
|
|
151
164
|
* The CLI's `capybara admin grant|revoke <login>` (no actor account): changes the super
|
|
152
165
|
* admin flag by local login under the super admin lock; revoking keeps the
|
|
@@ -13,8 +13,10 @@ import { sql } from "kysely";
|
|
|
13
13
|
import { SetupLock, SetupLockModule } from "../admin/setup-lock.js";
|
|
14
14
|
import { ApiError } from "../errors.js";
|
|
15
15
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
16
|
-
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
16
|
+
import { TransactionHost, withOrderedLocks } from "../infra/database/transaction-host.js";
|
|
17
17
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
18
|
+
import { PermissionCeilingWritesModule } from "../sandbox/permission-authority.module.js";
|
|
19
|
+
import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
|
|
18
20
|
import { assertThemeOnForAccount } from "../themes/theme-state.js";
|
|
19
21
|
import { audit } from "./audit.js";
|
|
20
22
|
import { MAX_PASSWORD_LENGTH, normalizeLogin, validatePassword } from "./login.js";
|
|
@@ -65,11 +67,13 @@ let AccountsService = class AccountsService {
|
|
|
65
67
|
txHost;
|
|
66
68
|
adminLock;
|
|
67
69
|
setupLock;
|
|
68
|
-
|
|
70
|
+
ceilings;
|
|
71
|
+
constructor(db, txHost, adminLock, setupLock, ceilings) {
|
|
69
72
|
this.db = db;
|
|
70
73
|
this.txHost = txHost;
|
|
71
74
|
this.adminLock = adminLock;
|
|
72
75
|
this.setupLock = setupLock;
|
|
76
|
+
this.ceilings = ceilings;
|
|
73
77
|
}
|
|
74
78
|
/** Checks the password length and hashes it (scrypt, slow): for callers that hash before their transaction opens. */
|
|
75
79
|
async hashNewPassword(password) {
|
|
@@ -329,12 +333,43 @@ let AccountsService = class AccountsService {
|
|
|
329
333
|
* account's sessions (`sessions.revoked_at`) and personal tokens in **the same PG transaction**,
|
|
330
334
|
* all or nothing; returns the revoked session ids, whose Redis markers the caller writes after
|
|
331
335
|
* the commit (the fast path; a failure is only a warning: auth reads PG).
|
|
336
|
+
*
|
|
337
|
+
* The super admin lock and, for a status change, the platform permission authority lock are the
|
|
338
|
+
* transaction's ordered prelude (`withOrderedLocks`): inside a run's fence (the Platform tool's
|
|
339
|
+
* `accounts.disable` / `accounts.enable`) they follow the org row and precede the conversation
|
|
340
|
+
* rows.
|
|
332
341
|
*/
|
|
333
342
|
async updateAccount(id, patch, actorAccountId, actorTokenId, opts = {}) {
|
|
343
|
+
// filled by the prelude, which runs once the body's transaction opens (after the call)
|
|
344
|
+
const locked = { platform: false };
|
|
345
|
+
return withOrderedLocks(async () => {
|
|
346
|
+
locked.platform = await this.lockForUpdate(id, patch, actorAccountId);
|
|
347
|
+
}, () => this.updateAccountIn(id, patch, actorAccountId, actorTokenId, opts, locked));
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* The prelude of {@link updateAccount}: the super admin lock (re-checking the actor), then the
|
|
351
|
+
* platform permission authority lock when the status changes; whether it locked it.
|
|
352
|
+
*/
|
|
353
|
+
async lockForUpdate(id, patch, actorAccountId) {
|
|
334
354
|
// Every super admin write is serialized by one lock and re-checks the actor under it: two
|
|
335
355
|
// admins revoking each other concurrently cannot leave none, and a just-revoked admin's
|
|
336
356
|
// request in flight fails
|
|
337
357
|
await this.adminLock.lockAndAuthorize(actorAccountId);
|
|
358
|
+
if (patch.status === undefined)
|
|
359
|
+
return false;
|
|
360
|
+
const row = await this.db
|
|
361
|
+
.selectFrom("accounts")
|
|
362
|
+
.select("status")
|
|
363
|
+
.where("id", "=", id)
|
|
364
|
+
.executeTakeFirst();
|
|
365
|
+
if (row === undefined || row.status === patch.status)
|
|
366
|
+
return false;
|
|
367
|
+
await this.ceilings.lock({}, "platform");
|
|
368
|
+
return true;
|
|
369
|
+
}
|
|
370
|
+
async updateAccountIn(id, patch, actorAccountId, actorTokenId, opts, locked) {
|
|
371
|
+
// held since the prelude; taking it again re-checks the actor
|
|
372
|
+
await this.adminLock.lockAndAuthorize(actorAccountId);
|
|
338
373
|
const before = await this.db
|
|
339
374
|
.selectFrom("accounts")
|
|
340
375
|
.selectAll()
|
|
@@ -342,6 +377,9 @@ let AccountsService = class AccountsService {
|
|
|
342
377
|
.executeTakeFirst();
|
|
343
378
|
if (!before)
|
|
344
379
|
throw new ApiError("account.not_found", "Account not found");
|
|
380
|
+
// a status that changed since the prelude read it would need the platform lock it did not take
|
|
381
|
+
if (patch.status !== undefined && patch.status !== before.status && !locked.platform)
|
|
382
|
+
throw new ApiError("conflict", "The account's status changed; retry the change");
|
|
345
383
|
return this.applyUpdate(before, patch, {
|
|
346
384
|
actorAccountId,
|
|
347
385
|
...(actorTokenId !== undefined && { actorTokenId }),
|
|
@@ -470,6 +508,20 @@ let AccountsService = class AccountsService {
|
|
|
470
508
|
const values = { updated_at: new Date() };
|
|
471
509
|
if (patch.displayName !== undefined)
|
|
472
510
|
values.display_name = patch.displayName;
|
|
511
|
+
if (patch.status !== undefined && patch.status !== before.status) {
|
|
512
|
+
await this.ceilings.lock({}, "platform");
|
|
513
|
+
await this.ceilings.publishLocked({}, "platform", patch.status === "disabled" ? (_scope, row) => row.account_id === id : false);
|
|
514
|
+
await this.db
|
|
515
|
+
.updateTable("conversations")
|
|
516
|
+
.set((eb) => ({
|
|
517
|
+
permission_profile: "approve-for-me",
|
|
518
|
+
permission_consent: null,
|
|
519
|
+
permission_revision: eb("permission_revision", "+", 1),
|
|
520
|
+
}))
|
|
521
|
+
.where("account_id", "=", id)
|
|
522
|
+
.where("permission_profile", "=", "full-access")
|
|
523
|
+
.execute();
|
|
524
|
+
}
|
|
473
525
|
if (patch.status !== undefined)
|
|
474
526
|
values.status = patch.status;
|
|
475
527
|
if (patch.isSuperAdmin !== undefined)
|
|
@@ -527,9 +579,12 @@ __decorate([
|
|
|
527
579
|
__decorate([
|
|
528
580
|
Transactional()
|
|
529
581
|
], AccountsService.prototype, "changePasswordIn", null);
|
|
582
|
+
__decorate([
|
|
583
|
+
Transactional({ propagation: "mandatory" })
|
|
584
|
+
], AccountsService.prototype, "lockForUpdate", null);
|
|
530
585
|
__decorate([
|
|
531
586
|
Transactional()
|
|
532
|
-
], AccountsService.prototype, "
|
|
587
|
+
], AccountsService.prototype, "updateAccountIn", null);
|
|
533
588
|
__decorate([
|
|
534
589
|
Transactional()
|
|
535
590
|
], AccountsService.prototype, "setSuperAdminIn", null);
|
|
@@ -547,7 +602,8 @@ AccountsService = __decorate([
|
|
|
547
602
|
__param(0, Inject(KernelDb)),
|
|
548
603
|
__param(1, Inject(TransactionHost)),
|
|
549
604
|
__param(2, Inject(SuperAdminLock)),
|
|
550
|
-
__param(3, Inject(SetupLock))
|
|
605
|
+
__param(3, Inject(SetupLock)),
|
|
606
|
+
__param(4, Inject(PermissionCeilingWrites))
|
|
551
607
|
], AccountsService);
|
|
552
608
|
export { AccountsService };
|
|
553
609
|
/**
|
|
@@ -559,7 +615,7 @@ let AccountsModule = class AccountsModule {
|
|
|
559
615
|
};
|
|
560
616
|
AccountsModule = __decorate([
|
|
561
617
|
Module({
|
|
562
|
-
imports: [SetupLockModule, SuperAdminLockModule],
|
|
618
|
+
imports: [SetupLockModule, SuperAdminLockModule, PermissionCeilingWritesModule],
|
|
563
619
|
providers: [AccountsService],
|
|
564
620
|
exports: [AccountsService],
|
|
565
621
|
})
|
|
@@ -8,6 +8,7 @@ import { Module } from "@nestjs/common";
|
|
|
8
8
|
import { SetupLockModule } from "../admin/setup-lock.js";
|
|
9
9
|
import { ExtensionRegistryModule } from "../extensions/registry.js";
|
|
10
10
|
import { OrgLockModule } from "../orgs/org-lock.js";
|
|
11
|
+
import { PermissionAuthorityModule } from "../sandbox/permission-authority.module.js";
|
|
11
12
|
import { AccountsModule } from "./accounts.js";
|
|
12
13
|
import { ApiTokenService } from "./api-tokens.js";
|
|
13
14
|
import { IdentityBinding } from "./binding.js";
|
|
@@ -27,6 +28,7 @@ let IdentityModule = class IdentityModule {
|
|
|
27
28
|
IdentityModule = __decorate([
|
|
28
29
|
Module({
|
|
29
30
|
imports: [
|
|
31
|
+
PermissionAuthorityModule,
|
|
30
32
|
AccountsModule,
|
|
31
33
|
OrgLockModule,
|
|
32
34
|
SetupLockModule,
|
|
@@ -5,7 +5,8 @@ import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
|
5
5
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
6
6
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
7
7
|
import type { KernelLogger } from "../log.js";
|
|
8
|
-
import {
|
|
8
|
+
import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
|
|
9
|
+
import { type DevicesAutoModeView, type DevicesFullAccessPatch, type DevicesFullAccessStored, type DevicesFullAccessView } from "../sandbox/platform-full-access.js";
|
|
9
10
|
import { type UiArrangement } from "../ui/arrangement.js";
|
|
10
11
|
import { SuperAdminLock } from "./super-admin.js";
|
|
11
12
|
/** 沙箱 cpu(核)与内存(MB)覆盖的范围(C19)。 */
|
|
@@ -166,6 +167,8 @@ export type DeploymentSettings = z.infer<typeof DEPLOYMENT_SETTINGS>;
|
|
|
166
167
|
* attribution defaults with their sources the same way.
|
|
167
168
|
*/
|
|
168
169
|
export type DeploymentSettingsView = DeploymentSettings & {
|
|
170
|
+
devicesFullAccess: DevicesFullAccessView;
|
|
171
|
+
/** The same switch under its old public name, until the old public readers are removed. */
|
|
169
172
|
devicesAutoMode: DevicesAutoModeView;
|
|
170
173
|
attribution: PlatformAttributionView;
|
|
171
174
|
};
|
|
@@ -211,6 +214,12 @@ export declare const DEPLOYMENT_SETTINGS_PATCH: z.ZodObject<{
|
|
|
211
214
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
212
215
|
disabled: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
213
216
|
}, z.core.$strict>>;
|
|
217
|
+
devicesFullAccess: z.ZodOptional<z.ZodObject<{
|
|
218
|
+
permission: z.ZodNullable<z.ZodEnum<{
|
|
219
|
+
allowed: "allowed";
|
|
220
|
+
off: "off";
|
|
221
|
+
}>>;
|
|
222
|
+
}, z.core.$strict>>;
|
|
214
223
|
devicesAutoMode: z.ZodOptional<z.ZodObject<{
|
|
215
224
|
mode: z.ZodNullable<z.ZodEnum<{
|
|
216
225
|
allowed: "allowed";
|
|
@@ -280,31 +289,37 @@ export declare function readUiArrangement(db: KernelSchemaDb): Promise<UiArrange
|
|
|
280
289
|
* {@link parseClientExtensions} (missing or invalid -> everything on; invalid also warns on `log`).
|
|
281
290
|
*/
|
|
282
291
|
export declare function readClientExtensions(db: KernelSchemaDb, log?: Pick<KernelLogger, "warn">): Promise<ClientExtensionsKillSwitch>;
|
|
292
|
+
/**
|
|
293
|
+
* A patch with the old `devicesAutoMode` moved to `devicesFullAccess`; both together is a
|
|
294
|
+
* validation error (never pick one silently).
|
|
295
|
+
*/
|
|
296
|
+
export declare function normalizeDeploymentSettingsPatch(patch: DeploymentSettingsPatch): DeploymentSettingsPatch;
|
|
283
297
|
/** Deployment settings: one row per key, defaults for missing keys. */
|
|
284
298
|
export declare class SettingsService {
|
|
285
299
|
private readonly db;
|
|
286
300
|
readonly txHost: TransactionHost;
|
|
287
301
|
private readonly adminLock;
|
|
288
302
|
private readonly log;
|
|
289
|
-
/** The startup config's `devices.
|
|
303
|
+
/** The startup config's `devices.fullAccess`, which wins over the stored choice. */
|
|
290
304
|
private readonly config;
|
|
305
|
+
private readonly ceilings;
|
|
291
306
|
constructor(db: KernelDb, txHost: TransactionHost, adminLock: SuperAdminLock, log: Pick<KernelLogger, "warn">,
|
|
292
|
-
/** The startup config's `devices.
|
|
293
|
-
config: Pick<KernelConfigService, "get" | "fieldSource"
|
|
294
|
-
/** The settings with the platform's
|
|
307
|
+
/** The startup config's `devices.fullAccess`, which wins over the stored choice. */
|
|
308
|
+
config: Pick<KernelConfigService, "get" | "fieldSource">, ceilings: PermissionCeilingWrites);
|
|
309
|
+
/** The settings with the platform's Full switch and attribution defaults in effect. */
|
|
295
310
|
view(): Promise<DeploymentSettingsView>;
|
|
296
311
|
private attributionView;
|
|
297
312
|
/**
|
|
298
|
-
* The refusals of a `
|
|
313
|
+
* The refusals of a `devicesFullAccess` change: a value set in the startup config
|
|
299
314
|
* (`deployment.setting_readonly`) and, with `onlyNarrows` (an API token, the Platform tool),
|
|
300
|
-
*
|
|
301
|
-
*
|
|
315
|
+
* allowing Full where it is off (`deployment.auto_mode_not_allowed`). Returns the next stored
|
|
316
|
+
* choice and the effective switch before it.
|
|
302
317
|
*/
|
|
303
|
-
|
|
318
|
+
checkDevicesFullAccess(patch: DevicesFullAccessPatch, opts?: {
|
|
304
319
|
onlyNarrows?: boolean;
|
|
305
320
|
}): Promise<{
|
|
306
|
-
next:
|
|
307
|
-
before:
|
|
321
|
+
next: DevicesFullAccessStored;
|
|
322
|
+
before: DevicesFullAccessView;
|
|
308
323
|
}>;
|
|
309
324
|
/**
|
|
310
325
|
* The refusals of an `attribution` change against the stored choice: a field set in the startup
|
|
@@ -320,12 +335,13 @@ export declare class SettingsService {
|
|
|
320
335
|
get(): Promise<DeploymentSettings>;
|
|
321
336
|
/**
|
|
322
337
|
* Updates settings under the super admin lock, re-checking the actor (else `forbidden`).
|
|
323
|
-
* `onlyNarrows` (an API token, the Platform tool): `
|
|
338
|
+
* `onlyNarrows` (an API token, the Platform tool): `devicesFullAccess` may only turn Full off.
|
|
324
339
|
*/
|
|
325
340
|
update(patch: DeploymentSettingsPatch, actorAccountId: string, actorTokenId?: string,
|
|
326
341
|
/** Merged into the audit detail (the Platform tool's `via: "agent"`). */
|
|
327
342
|
auditDetail?: Record<string, unknown>, opts?: {
|
|
328
343
|
onlyNarrows?: boolean;
|
|
329
344
|
}): Promise<DeploymentSettingsView>;
|
|
345
|
+
private lockFor;
|
|
330
346
|
private write;
|
|
331
347
|
}
|