@capybara-hq/kernel 0.1.0-rc.40 → 0.1.0-rc.42
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 +10 -1
- 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 +1 -1
- package/dist/config/schema.js +11 -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 +304 -4
- package/dist/conversations/events.js +279 -29
- 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/db/kernel-schema.d.ts +238 -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/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 +31 -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/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/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/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/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/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 +129 -0
- package/dist/sandbox/review/review.service.d.ts +4 -1
- package/dist/sandbox/review/review.service.js +19 -5
- 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/builtins/builtin-tools.d.ts +16 -2
- package/dist/tools/builtins/builtin-tools.js +38 -10
- 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 +2 -2
- 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 +300 -19
- package/dist/tools/registry.d.ts +9 -0
- package/dist/tools/tools.module.js +12 -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/dist/sandbox/platform-auto-mode.d.ts +0 -63
- package/dist/sandbox/platform-auto-mode.js +0 -63
|
@@ -9,7 +9,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
9
9
|
};
|
|
10
10
|
import { Inject, Injectable } from "@nestjs/common";
|
|
11
11
|
import { z } from "zod";
|
|
12
|
-
import { OrgSettingsPatchSchema, OrgSettingsService } from "../../orgs/settings.service.js";
|
|
12
|
+
import { OrgSettingsPatchSchema, OrgSettingsService, orgSettingsView, } from "../../orgs/settings.service.js";
|
|
13
13
|
import { ThemesService } from "../../themes/themes.service.js";
|
|
14
14
|
import { defineOperation } from "../operation.js";
|
|
15
15
|
import { PlatformOperations } from "../registry.js";
|
|
@@ -39,7 +39,7 @@ let OrgSettingsOperations = class OrgSettingsOperations {
|
|
|
39
39
|
this.registry.register([
|
|
40
40
|
defineOperation({
|
|
41
41
|
id: "org-settings.get",
|
|
42
|
-
description: "Read this org's settings: toolSearch, locale, sandboxToolPolicy, platformTool (on, read-only or off),
|
|
42
|
+
description: "Read this org's settings: toolSearch, locale, sandboxToolPolicy, platformTool (on, read-only or off), fullAccess (allowed or off: whether the org's devices may run with Full permission; absent follows the deployment's switch, and the org may never exceed it; autoMode is its old name, shown with the same value), cloudNetwork (the org's sandbox-mode network stored as a delta over the platform's allowlist: mode open or allowlist for a cloud device in sandbox mode, absent following the platform; base platform or none; extraHosts the org adds; excludedHosts platform hosts it drops; open means any public host, while loopback, private and cloud metadata addresses stay blocked), wakeOnBackgroundTask (absent means it follows the deployment), theme (the org's default theme id, null or absent following the platform, and personal: allowed or locked), uiArrangement (per list slot, the extension contributions the org hides and their order; per single slot, the contribution that replaces the built-in as use, null for the built-in; a slot not listed follows the platform), the deployment's Full switch (fullAccess; autoMode is its old name) and network (its allowlist, orgHosts: extend lets the org go beyond it, within makes it the ceiling, and off for the platform kill switch), effectiveNetwork (the mode and hosts the org's sandbox mode really gets), and the sandbox cpu / memory limits in effect.",
|
|
43
43
|
input: z.object({}).strict(),
|
|
44
44
|
example: {},
|
|
45
45
|
authz: { orgAction: "org.read" },
|
|
@@ -48,7 +48,7 @@ let OrgSettingsOperations = class OrgSettingsOperations {
|
|
|
48
48
|
run: async (_input, ctx) => {
|
|
49
49
|
const settings = await this.settings.get(ctx.orgId);
|
|
50
50
|
return {
|
|
51
|
-
settings,
|
|
51
|
+
settings: orgSettingsView(settings),
|
|
52
52
|
deployment: await this.settings.deployment(),
|
|
53
53
|
effectiveNetwork: this.settings.effectiveNetwork(settings),
|
|
54
54
|
sandboxLimits: await this.settings.sandboxLimits(ctx.orgId),
|
|
@@ -57,7 +57,7 @@ let OrgSettingsOperations = class OrgSettingsOperations {
|
|
|
57
57
|
}),
|
|
58
58
|
defineOperation({
|
|
59
59
|
id: "org-settings.update",
|
|
60
|
-
description: "Change this org's settings (org admins). Give only the settings to change; null clears
|
|
60
|
+
description: "Change this org's settings (org admins). Give only the settings to change; null clears fullAccess, cloudNetwork or wakeOnBackgroundTask so they follow the deployment again (refused when the deployment value is wider than what this tool may set). fullAccess (allowed or off; the platform must allow it; autoMode is its old name, never both) and cloudNetwork ({ mode?, base?: platform | none, extraHosts?, excludedHosts? }, replaced whole, so send the stored fields you keep) may only narrow the org's devices here: allowing Full where the org has it off, switching the cloud network from allowlist to open, adding an extra host, dropping an exclusion or moving base from none to platform is refused and needs a person in the organization settings on the web. theme: { id, personal } sets the org's default theme (a theme id from themes.list, or null to follow the platform) and whether members may pick their own (allowed) or not (locked); null clears it. uiArrangement: { <slot>: { hidden, order } } (a list slot) or { <slot>: { use } } (a single slot: shell.brand, conversation.empty, conversation.composer.frame) replaces that slot's entry, where hidden, order and use name contribution keys <extension>/<contribution> (hidden ones are not listed in the web UI but their pages still open by URL; use null is the built-in); null for a slot makes it follow the platform again; platform.page is refused. Setting platformTool to off or read-only takes effect from the next call and cuts this Platform tool off in the org, so say so before asking; an org admin switches it back on in the web settings.",
|
|
61
61
|
input: OrgSettingsPatchSchema.refine((i) => Object.values(i).some((v) => v !== undefined), {
|
|
62
62
|
message: "give at least one setting",
|
|
63
63
|
}),
|
|
@@ -72,7 +72,7 @@ let OrgSettingsOperations = class OrgSettingsOperations {
|
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
74
|
code: "org.auto_mode_not_allowed",
|
|
75
|
-
next: "Through this tool the org's
|
|
75
|
+
next: "Through this tool the org's Full permission (fullAccess) may only be turned off, never allowed (the platform may turn it off too; org-settings.get shows both); to allow it, ask an org admin to change it in the organization settings on the web.",
|
|
76
76
|
},
|
|
77
77
|
{
|
|
78
78
|
code: "theme.not_available",
|
|
@@ -126,7 +126,7 @@ let OrgSettingsOperations = class OrgSettingsOperations {
|
|
|
126
126
|
? undefined
|
|
127
127
|
: PLATFORM_TOOL_NOTE[settings.platformTool];
|
|
128
128
|
return {
|
|
129
|
-
settings,
|
|
129
|
+
settings: orgSettingsView(settings),
|
|
130
130
|
effectiveNetwork: this.settings.effectiveNetwork(settings),
|
|
131
131
|
...(note !== undefined && { note }),
|
|
132
132
|
};
|
|
@@ -8,6 +8,7 @@ var WorkerModule_1;
|
|
|
8
8
|
import { Module } from "@nestjs/common";
|
|
9
9
|
import { BackgroundModule } from "../background/background.module.js";
|
|
10
10
|
import { BackgroundTaskPollJob } from "../background/poll.job.js";
|
|
11
|
+
import { RetireLegacyTasksJob } from "../background/retire-legacy-tasks.job.js";
|
|
11
12
|
import { CatalogModule } from "../catalog/catalog.module.js";
|
|
12
13
|
import { CatalogJobs } from "../catalog/jobs.js";
|
|
13
14
|
import { PluginScopeWorkersModule } from "../catalog/scope-sync-workers.js";
|
|
@@ -96,6 +97,9 @@ let WorkerModule = WorkerModule_1 = class WorkerModule {
|
|
|
96
97
|
SandboxSweepJobs,
|
|
97
98
|
LegacySandboxCleanupJob,
|
|
98
99
|
BackgroundTaskPollJob,
|
|
100
|
+
// legacy retirement (permission runtime cutover 8.5): bounded, retryable; the sandbox
|
|
101
|
+
// service's inline gate holds without it
|
|
102
|
+
RetireLegacyTasksJob,
|
|
99
103
|
ToolJobs,
|
|
100
104
|
InitialPasswordCleanupJob,
|
|
101
105
|
ClientReportsCron,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ContentBlock, type ModelInfo, type ModelRequest, type ParamValue } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import type { AgentDefinition } from "../../agents/definition.js";
|
|
3
|
-
import { type ConversationEvent, type EventPayload } from "../../conversations/events.js";
|
|
3
|
+
import { type ConversationEvent, type EventPayload, type PermissionContextMetaV1 } from "../../conversations/events.js";
|
|
4
4
|
import type { ResolvedTool } from "../../tools/registry.js";
|
|
5
5
|
/**
|
|
6
6
|
* 平台行为规范(模型可见,英文)。短而通用(spec 6 原则 5);不放时间戳、会话 ID 等会变化的内容,
|
|
@@ -17,6 +17,8 @@ export interface ModelCallMeta {
|
|
|
17
17
|
summarySeq: number | null;
|
|
18
18
|
/** system 文本的 sha256(hex)。 */
|
|
19
19
|
systemHash: string;
|
|
20
|
+
/** Recorded v1 history contributions only; absent for historical logs. */
|
|
21
|
+
permissionContext?: PermissionContextMetaV1;
|
|
20
22
|
/** 被放进请求的 `reminder` 事件 seq。 */
|
|
21
23
|
reminderSeqs: number[];
|
|
22
24
|
/** 构建时的 `absorbedUpToSeq`(见 {@link BuildModelRequestInput});未提供则没有该字段。 */
|
|
@@ -5,6 +5,7 @@ import { isAbsorbable, } from "../../conversations/events.js";
|
|
|
5
5
|
import { catalogText, isAlwaysLoaded } from "../../tools/builtins/tool-search.js";
|
|
6
6
|
import { renderSubagentDelivery } from "../subagents/render.js";
|
|
7
7
|
import { devicePathsAt, devicePathsText } from "./device-paths.js";
|
|
8
|
+
import { permissionContextHistory } from "./permission-profile.js";
|
|
8
9
|
import { pluginContextsAfterSummary, pluginContextText } from "./plugin-context.js";
|
|
9
10
|
import { latestProjectRoot, projectRootText } from "./project-root.js";
|
|
10
11
|
import { currentRunContext, runContextEvents, runContextFullText, runContextText, scheduleHeader, senderLines, } from "./run-context.js";
|
|
@@ -477,6 +478,7 @@ export function buildModelRequest(input) {
|
|
|
477
478
|
};
|
|
478
479
|
const summary = latestSummary(events);
|
|
479
480
|
const after = summary ? summary.payload.coversUpToSeq : Number.NEGATIVE_INFINITY;
|
|
481
|
+
const permissionHistory = permissionContextHistory(events, summary?.payload.coversUpToSeq);
|
|
480
482
|
const messages = [];
|
|
481
483
|
const reminderSeqs = [];
|
|
482
484
|
const absorbed = input.absorbedUpToSeq;
|
|
@@ -671,9 +673,12 @@ export function buildModelRequest(input) {
|
|
|
671
673
|
// environments spec §13.1: the instance's directories told before the boundary follow the
|
|
672
674
|
// summary again (the model keeps using the real paths)
|
|
673
675
|
const paths = devicePathsAt(events, after);
|
|
674
|
-
if (paths) {
|
|
676
|
+
if (paths && paths.payload.permissionContextVersion !== 1) {
|
|
675
677
|
messages.push({ role: "system", content: devicePathsText(paths.payload) });
|
|
676
678
|
}
|
|
679
|
+
for (const contribution of permissionHistory.restored) {
|
|
680
|
+
messages.push({ role: "system", content: contribution.text });
|
|
681
|
+
}
|
|
677
682
|
// memory spec §6.1: each plugin's context in effect at the boundary follows the summary again
|
|
678
683
|
for (const text of pluginContextsAfterSummary(events, after)) {
|
|
679
684
|
messages.push({ role: "system", content: text });
|
|
@@ -760,9 +765,15 @@ export function buildModelRequest(input) {
|
|
|
760
765
|
break;
|
|
761
766
|
// the instance's directories (environments spec §13.1): logged during a step's tool call,
|
|
762
767
|
// so rendered after that step's tool results
|
|
763
|
-
case "
|
|
764
|
-
|
|
768
|
+
case "permission_context":
|
|
769
|
+
case "device_paths": {
|
|
770
|
+
const contribution = permissionHistory.ordered.get(e.seq);
|
|
771
|
+
if (contribution)
|
|
772
|
+
messages.push({ role: "system", content: contribution.text });
|
|
773
|
+
else if (e.type === "device_paths")
|
|
774
|
+
messages.push({ role: "system", content: devicePathsText(e.payload) });
|
|
765
775
|
break;
|
|
776
|
+
}
|
|
766
777
|
// a context@1 provider's text (memory spec §6.1); empty text (nothing any more) renders nothing
|
|
767
778
|
case "plugin_context": {
|
|
768
779
|
const text = pluginContextText(e.payload);
|
|
@@ -834,6 +845,10 @@ export function buildModelRequest(input) {
|
|
|
834
845
|
case "run_finished":
|
|
835
846
|
case "run_aborted":
|
|
836
847
|
case "run_failed":
|
|
848
|
+
// the permission records are not model-visible: the profile reaches the model only through
|
|
849
|
+
// its recorded permission_context, the review only through the tool result
|
|
850
|
+
case "permission_profile_changed":
|
|
851
|
+
case "permission_reviewed":
|
|
837
852
|
break;
|
|
838
853
|
default: {
|
|
839
854
|
const unrendered = e;
|
|
@@ -893,6 +908,7 @@ export function buildModelRequest(input) {
|
|
|
893
908
|
toSeq: last?.seq ?? 0,
|
|
894
909
|
summarySeq: summary?.seq ?? null,
|
|
895
910
|
systemHash: hashSystem(system),
|
|
911
|
+
...(permissionHistory.meta !== undefined && { permissionContext: permissionHistory.meta }),
|
|
896
912
|
reminderSeqs,
|
|
897
913
|
...(absorbed !== undefined && { absorbedUpToSeq: absorbed }),
|
|
898
914
|
params: { ...request.params },
|
|
@@ -358,6 +358,11 @@ function transcriptLine(e) {
|
|
|
358
358
|
case "run_finished":
|
|
359
359
|
case "run_aborted":
|
|
360
360
|
case "run_failed":
|
|
361
|
+
// permission_context, like device_paths, follows the summary (the latest covered ones again,
|
|
362
|
+
// build.ts); the profile change and the review record are not model-visible
|
|
363
|
+
case "permission_context":
|
|
364
|
+
case "permission_profile_changed":
|
|
365
|
+
case "permission_reviewed":
|
|
361
366
|
return null;
|
|
362
367
|
default: {
|
|
363
368
|
const unrendered = e;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SandboxRoots } from "@capybara-hq/plugin-sdk";
|
|
2
|
-
import type { ConversationEvent } from "../../conversations/events.js";
|
|
2
|
+
import type { ConversationEvent, ManagedDevicePathsV1 } from "../../conversations/events.js";
|
|
3
3
|
import type { DeviceNetwork, SandboxMode } from "../../sandbox/modes.js";
|
|
4
4
|
/**
|
|
5
5
|
* The `device_paths` event (environments spec §13.1, ruling R22; auto mode spec §4.2): the first
|
|
@@ -19,7 +19,9 @@ export interface DeviceModeLevel {
|
|
|
19
19
|
local: boolean;
|
|
20
20
|
}
|
|
21
21
|
/** The payload of a `device_paths` event; the mode fields are absent on events before auto mode. */
|
|
22
|
-
export
|
|
22
|
+
export type DevicePathsPayload = LegacyDevicePathsPayload | ManagedDevicePathsV1;
|
|
23
|
+
export interface LegacyDevicePathsPayload {
|
|
24
|
+
permissionContextVersion?: undefined;
|
|
23
25
|
roots: SandboxRoots;
|
|
24
26
|
mode?: SandboxMode | undefined;
|
|
25
27
|
allowedMode?: SandboxMode | undefined;
|
|
@@ -79,4 +81,9 @@ export declare function devicePathsChange(latest: {
|
|
|
79
81
|
export declare function devicePathsAt(events: readonly ConversationEvent[], seq: number): Extract<ConversationEvent, {
|
|
80
82
|
type: "device_paths";
|
|
81
83
|
}> | undefined;
|
|
84
|
+
/** Full managed payload equality; historical payloads retain their existing comparisons and keys. */
|
|
85
|
+
export declare function devicePathsChangeFromPayload(latest: {
|
|
86
|
+
seq: number;
|
|
87
|
+
payload: DevicePathsPayload;
|
|
88
|
+
} | undefined, payload: DevicePathsPayload, runId?: string): ReturnType<typeof devicePathsChange>;
|
|
82
89
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
+
import { managedDevicePathsHash, managedDevicePathsIdemKey, managedDevicePathsText, } from "./permission-profile.js";
|
|
2
3
|
/** The roots line of a `device_paths` event (model-visible, English). */
|
|
3
4
|
const rootsText = (r) => `This device's directories: workspace ${r.workspace}, skills ${r.skills} (read only), temporary files ${r.tmp}. Use these paths in commands and tool calls.`;
|
|
4
5
|
const TIER_NAMES = {
|
|
@@ -75,6 +76,8 @@ function legacyLevel(p) {
|
|
|
75
76
|
}
|
|
76
77
|
/** The level a payload records, in either shape; undefined without one. */
|
|
77
78
|
export function devicePathsLevel(p) {
|
|
79
|
+
if (p.permissionContextVersion === 1)
|
|
80
|
+
return undefined;
|
|
78
81
|
if (p.mode !== undefined &&
|
|
79
82
|
p.allowedMode !== undefined &&
|
|
80
83
|
typeof p.network === "object" &&
|
|
@@ -90,6 +93,8 @@ export function devicePathsLevel(p) {
|
|
|
90
93
|
}
|
|
91
94
|
/** The system message of a `device_paths` event (model-visible, English). */
|
|
92
95
|
export function devicePathsText(p) {
|
|
96
|
+
if (p.permissionContextVersion === 1)
|
|
97
|
+
return managedDevicePathsText(p);
|
|
93
98
|
const roots = rootsText(p.roots);
|
|
94
99
|
const level = devicePathsLevel(p);
|
|
95
100
|
if (level === undefined)
|
|
@@ -163,3 +168,18 @@ export function devicePathsAt(events, seq) {
|
|
|
163
168
|
}
|
|
164
169
|
return found;
|
|
165
170
|
}
|
|
171
|
+
/** Full managed payload equality; historical payloads retain their existing comparisons and keys. */
|
|
172
|
+
export function devicePathsChangeFromPayload(latest, payload, runId) {
|
|
173
|
+
if (payload.permissionContextVersion !== 1)
|
|
174
|
+
return devicePathsChange(latest, payload.roots, runId, devicePathsLevel(payload));
|
|
175
|
+
const currentHash = managedDevicePathsHash(payload);
|
|
176
|
+
if (latest?.payload.permissionContextVersion === 1 &&
|
|
177
|
+
managedDevicePathsHash(latest.payload) === currentHash)
|
|
178
|
+
return null;
|
|
179
|
+
return {
|
|
180
|
+
type: "device_paths",
|
|
181
|
+
...(runId !== undefined && { runId }),
|
|
182
|
+
idemKey: managedDevicePathsIdemKey(payload, latest?.seq ?? 0),
|
|
183
|
+
payload: structuredClone(payload),
|
|
184
|
+
};
|
|
185
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type ConversationEvent, type ManagedDevicePathsV1, type PermissionContextMetaV1, type PermissionContextV1 } from "../../conversations/events.js";
|
|
2
|
+
/** A recorded log carries a present v1 marker or version that its strict schema rejects. */
|
|
3
|
+
export declare class RecordedPermissionContextError extends Error {
|
|
4
|
+
readonly seq: number;
|
|
5
|
+
readonly eventType: "permission_context" | "device_paths";
|
|
6
|
+
readonly name = "RecordedPermissionContextError";
|
|
7
|
+
constructor(seq: number, eventType: "permission_context" | "device_paths");
|
|
8
|
+
}
|
|
9
|
+
/** Canonical v1 bytes: explicit nulls, code-point object keys, validated array order. */
|
|
10
|
+
export declare function canonicalPermissionJson(value: unknown): string;
|
|
11
|
+
/** JSON quoting makes recorded values inert, including markup and Unicode line separators. */
|
|
12
|
+
export declare const permissionQuote: (value: string) => string;
|
|
13
|
+
export declare function permissionContextText(payload: PermissionContextV1): string;
|
|
14
|
+
export declare function managedDevicePathsText(payload: ManagedDevicePathsV1): string;
|
|
15
|
+
export declare const permissionContextHash: (payload: PermissionContextV1) => string;
|
|
16
|
+
export declare const managedDevicePathsHash: (payload: ManagedDevicePathsV1) => string;
|
|
17
|
+
export declare const permissionContextIdemKey: (payload: PermissionContextV1, previousSeq: number) => string;
|
|
18
|
+
export declare const managedDevicePathsIdemKey: (payload: ManagedDevicePathsV1, previousSeq: number) => string;
|
|
19
|
+
export declare function permissionContextAt(events: readonly ConversationEvent[], seq: number): Extract<ConversationEvent, {
|
|
20
|
+
type: "permission_context";
|
|
21
|
+
}> | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Snapshot validation for raw (cast) events: every `permission_context` and every `device_paths`
|
|
24
|
+
* carrying a marker must satisfy its strict v1 schema, covered or not, before any rendering; an
|
|
25
|
+
* unsupported version must never fall back to historical text. Unmarked paths keep their parser.
|
|
26
|
+
*/
|
|
27
|
+
export declare function assertRecordedPermissionEvents(events: readonly ConversationEvent[]): void;
|
|
28
|
+
export interface PermissionContribution {
|
|
29
|
+
type: "permission_context" | "device_paths";
|
|
30
|
+
text: string;
|
|
31
|
+
}
|
|
32
|
+
export declare function permissionContextMeta(events: readonly ConversationEvent[], contributions: readonly PermissionContribution[]): PermissionContextMetaV1 | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* One traversal for request rendering and original-coordinate replay diagnostics. Both callers get
|
|
35
|
+
* the same marker rule: a present marker or version that fails its strict v1 schema (covered by a
|
|
36
|
+
* summary or not) throws {@link RecordedPermissionContextError} before anything renders, so it is
|
|
37
|
+
* never shown as historical device-mode text nor surfaces as a raw schema error. Unmarked events
|
|
38
|
+
* are left to their historical rendering.
|
|
39
|
+
*/
|
|
40
|
+
export declare function permissionContextHistory(events: readonly ConversationEvent[], coversUpToSeq?: number): {
|
|
41
|
+
restored: (PermissionContribution & {
|
|
42
|
+
seq: number;
|
|
43
|
+
})[];
|
|
44
|
+
ordered: Map<number, PermissionContribution>;
|
|
45
|
+
meta: PermissionContextMetaV1 | undefined;
|
|
46
|
+
};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { ManagedDevicePathsV1Schema, PermissionContextV1Schema, permissionCodePointCompare, } from "../../conversations/events.js";
|
|
3
|
+
/** A recorded log carries a present v1 marker or version that its strict schema rejects. */
|
|
4
|
+
export class RecordedPermissionContextError extends Error {
|
|
5
|
+
seq;
|
|
6
|
+
eventType;
|
|
7
|
+
name = "RecordedPermissionContextError";
|
|
8
|
+
constructor(seq, eventType) {
|
|
9
|
+
super(`Recorded ${eventType} event at seq ${seq} has an unsupported version or an invalid v1 payload`);
|
|
10
|
+
this.seq = seq;
|
|
11
|
+
this.eventType = eventType;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** Canonical v1 bytes: explicit nulls, code-point object keys, validated array order. */
|
|
15
|
+
export function canonicalPermissionJson(value) {
|
|
16
|
+
if (value === null || typeof value === "string" || typeof value === "boolean")
|
|
17
|
+
return JSON.stringify(value);
|
|
18
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
19
|
+
return JSON.stringify(value);
|
|
20
|
+
if (Array.isArray(value)) {
|
|
21
|
+
if (Object.keys(value).length !== value.length)
|
|
22
|
+
throw new TypeError("Permission JSON requires dense arrays without extra fields");
|
|
23
|
+
return `[${value.map(canonicalPermissionJson).join(",")}]`;
|
|
24
|
+
}
|
|
25
|
+
if (typeof value === "object" &&
|
|
26
|
+
(Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null)) {
|
|
27
|
+
return `{${Object.keys(value)
|
|
28
|
+
.sort(permissionCodePointCompare)
|
|
29
|
+
.map((key) => `${JSON.stringify(key)}:${canonicalPermissionJson(value[key])}`)
|
|
30
|
+
.join(",")}}`;
|
|
31
|
+
}
|
|
32
|
+
throw new TypeError("Permission JSON requires finite JSON values and explicit nulls");
|
|
33
|
+
}
|
|
34
|
+
const hash = (value) => createHash("sha256").update(canonicalPermissionJson(value), "utf8").digest("hex");
|
|
35
|
+
/** JSON quoting makes recorded values inert, including markup and Unicode line separators. */
|
|
36
|
+
export const permissionQuote = (value) => JSON.stringify(value).replace(/[<>&\u2028\u2029]/g, (c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, "0")}`);
|
|
37
|
+
const arrayText = (values) => `[${values.map(permissionQuote).join(",")}]`;
|
|
38
|
+
const labels = {
|
|
39
|
+
"request-approval": "Request approval",
|
|
40
|
+
"approve-for-me": "Approve for me",
|
|
41
|
+
"full-access": "Full access",
|
|
42
|
+
};
|
|
43
|
+
export function permissionContextText(payload) {
|
|
44
|
+
const p = PermissionContextV1Schema.parse(payload);
|
|
45
|
+
const s = p.scope;
|
|
46
|
+
const lines = [
|
|
47
|
+
`Permission context for new operations: ${p.availability.state === "supported" && p.effectiveProfile !== null ? labels[p.effectiveProfile] : "unavailable"}.`,
|
|
48
|
+
"This context supersedes earlier device-mode descriptions for new operations.",
|
|
49
|
+
];
|
|
50
|
+
if (s !== null) {
|
|
51
|
+
lines.push(`Working directory: ${permissionQuote(s.workingRoot)}.`);
|
|
52
|
+
if (s.filesystem.kind === "scoped") {
|
|
53
|
+
lines.push(`Readable directories: ${arrayText(s.filesystem.readDirectories)}.`, `Writable directories: ${arrayText(s.filesystem.writeDirectories)}.`);
|
|
54
|
+
}
|
|
55
|
+
else
|
|
56
|
+
lines.push(s.location === "local"
|
|
57
|
+
? "Filesystem: this device as the existing OS user; no additional OS privileges."
|
|
58
|
+
: "Filesystem: the provisioned device environment as its existing OS user; no additional OS privileges.");
|
|
59
|
+
switch (s.network.kind) {
|
|
60
|
+
case "none":
|
|
61
|
+
lines.push("Network: no destinations are authorized for new commands.");
|
|
62
|
+
break;
|
|
63
|
+
case "allowlist":
|
|
64
|
+
lines.push(`Network: new commands may reach only these authorized hosts: ${arrayText(s.network.hosts)}.`);
|
|
65
|
+
break;
|
|
66
|
+
case "environment":
|
|
67
|
+
lines.push(s.location === "local"
|
|
68
|
+
? "Network: the host environment; restricted-profile host lists do not restrict Full access."
|
|
69
|
+
: "Network: the provisioned environment, subject to its outer network boundary.");
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
switch (s.outerNetwork.kind) {
|
|
73
|
+
case "host-environment":
|
|
74
|
+
lines.push("Outer network boundary: the host environment.");
|
|
75
|
+
break;
|
|
76
|
+
case "none":
|
|
77
|
+
lines.push("Outer network boundary: network access is disabled.");
|
|
78
|
+
break;
|
|
79
|
+
case "allowlist":
|
|
80
|
+
lines.push(`Outer network boundary: allowed hosts ${arrayText(s.outerNetwork.hosts)}.`);
|
|
81
|
+
break;
|
|
82
|
+
case "open-public":
|
|
83
|
+
lines.push("Outer network boundary: public addresses only.");
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
lines.push(p.execution === "scheduled"
|
|
87
|
+
? "Scheduled run: only the unattended policy and explicit task grants apply; interactive approvals and chat Full access do not apply."
|
|
88
|
+
: p.effectiveProfile === "request-approval"
|
|
89
|
+
? "Extra filesystem or network scope requires the person's approval."
|
|
90
|
+
: p.effectiveProfile === "approve-for-me"
|
|
91
|
+
? "A separate reviewer may approve eligible extra scope; uncertainty asks the person."
|
|
92
|
+
: "No discretionary command approval; explicit policy, device-owner limits and OS permissions still apply.");
|
|
93
|
+
}
|
|
94
|
+
else if (p.availability.state !== "supported") {
|
|
95
|
+
lines.push(`Device operations are ${p.availability.state === "unprobed" ? "unverified" : "unavailable"}: ${permissionQuote(p.availability.reason)}.`);
|
|
96
|
+
}
|
|
97
|
+
lines.push("Changes apply to new operations. Work already started keeps its starting permissions. Actual owner or organization revocation may still stop affected work.");
|
|
98
|
+
return lines.join("\n");
|
|
99
|
+
}
|
|
100
|
+
export function managedDevicePathsText(payload) {
|
|
101
|
+
const p = ManagedDevicePathsV1Schema.parse(payload);
|
|
102
|
+
return `Device directories: workspace ${permissionQuote(p.roots.workspace)}, skills ${permissionQuote(p.roots.skills)}, temporary files ${permissionQuote(p.roots.tmp)}.\nSelected working directory: ${permissionQuote(p.workingRoot)}. These paths do not grant access; the current permission context governs new operations.`;
|
|
103
|
+
}
|
|
104
|
+
export const permissionContextHash = (payload) => hash(["permission_context", 1, PermissionContextV1Schema.parse(payload)]);
|
|
105
|
+
export const managedDevicePathsHash = (payload) => hash(["device_paths", 1, ManagedDevicePathsV1Schema.parse(payload)]);
|
|
106
|
+
function predecessor(seq) {
|
|
107
|
+
if (!Number.isSafeInteger(seq) || seq < 0)
|
|
108
|
+
throw new TypeError("Permission predecessor must be a nonnegative safe integer");
|
|
109
|
+
return seq;
|
|
110
|
+
}
|
|
111
|
+
export const permissionContextIdemKey = (payload, previousSeq) => `permission_context:v1:${permissionContextHash(payload)}:${predecessor(previousSeq)}`;
|
|
112
|
+
export const managedDevicePathsIdemKey = (payload, previousSeq) => `device_paths:permission-v1:${managedDevicePathsHash(payload)}:${predecessor(previousSeq)}`;
|
|
113
|
+
export function permissionContextAt(events, seq) {
|
|
114
|
+
let latest;
|
|
115
|
+
for (const e of events)
|
|
116
|
+
if (e.type === "permission_context" &&
|
|
117
|
+
e.seq <= seq &&
|
|
118
|
+
(latest === undefined || e.seq > latest.seq))
|
|
119
|
+
latest = e;
|
|
120
|
+
return latest;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Snapshot validation for raw (cast) events: every `permission_context` and every `device_paths`
|
|
124
|
+
* carrying a marker must satisfy its strict v1 schema, covered or not, before any rendering; an
|
|
125
|
+
* unsupported version must never fall back to historical text. Unmarked paths keep their parser.
|
|
126
|
+
*/
|
|
127
|
+
export function assertRecordedPermissionEvents(events) {
|
|
128
|
+
for (const e of events) {
|
|
129
|
+
if (e.type === "permission_context") {
|
|
130
|
+
if (!PermissionContextV1Schema.safeParse(e.payload).success)
|
|
131
|
+
throw new RecordedPermissionContextError(e.seq, e.type);
|
|
132
|
+
}
|
|
133
|
+
else if (e.type === "device_paths" &&
|
|
134
|
+
typeof e.payload === "object" &&
|
|
135
|
+
e.payload !== null &&
|
|
136
|
+
e.payload.permissionContextVersion !==
|
|
137
|
+
undefined &&
|
|
138
|
+
!ManagedDevicePathsV1Schema.safeParse(e.payload).success)
|
|
139
|
+
throw new RecordedPermissionContextError(e.seq, e.type);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
export function permissionContextMeta(events, contributions) {
|
|
143
|
+
if (contributions.length === 0)
|
|
144
|
+
return undefined;
|
|
145
|
+
return {
|
|
146
|
+
version: 1,
|
|
147
|
+
contextSeq: permissionContextAt(events, Number.POSITIVE_INFINITY)?.seq ?? null,
|
|
148
|
+
hash: hash([1, contributions.map(({ type, text }) => [type, text])]),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* One traversal for request rendering and original-coordinate replay diagnostics. Both callers get
|
|
153
|
+
* the same marker rule: a present marker or version that fails its strict v1 schema (covered by a
|
|
154
|
+
* summary or not) throws {@link RecordedPermissionContextError} before anything renders, so it is
|
|
155
|
+
* never shown as historical device-mode text nor surfaces as a raw schema error. Unmarked events
|
|
156
|
+
* are left to their historical rendering.
|
|
157
|
+
*/
|
|
158
|
+
export function permissionContextHistory(events, coversUpToSeq) {
|
|
159
|
+
assertRecordedPermissionEvents(events);
|
|
160
|
+
const sorted = [...events].sort((a, b) => a.seq - b.seq);
|
|
161
|
+
const floor = coversUpToSeq ?? Number.NEGATIVE_INFINITY;
|
|
162
|
+
const restored = [];
|
|
163
|
+
const contribution = (e) => {
|
|
164
|
+
if (e.type === "permission_context")
|
|
165
|
+
return { type: e.type, text: permissionContextText(e.payload) };
|
|
166
|
+
if (e.type === "device_paths" && e.payload.permissionContextVersion === 1)
|
|
167
|
+
return { type: e.type, text: managedDevicePathsText(e.payload) };
|
|
168
|
+
return undefined;
|
|
169
|
+
};
|
|
170
|
+
if (coversUpToSeq !== undefined) {
|
|
171
|
+
const paths = sorted.filter((e) => e.type === "device_paths" && e.seq <= floor).at(-1);
|
|
172
|
+
const permission = permissionContextAt(sorted, floor);
|
|
173
|
+
for (const e of [paths, permission]) {
|
|
174
|
+
if (!e)
|
|
175
|
+
continue;
|
|
176
|
+
const item = contribution(e);
|
|
177
|
+
if (item)
|
|
178
|
+
restored.push({ ...item, seq: e.seq });
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const ordered = new Map();
|
|
182
|
+
for (const e of sorted) {
|
|
183
|
+
if (e.seq <= floor)
|
|
184
|
+
continue;
|
|
185
|
+
const item = contribution(e);
|
|
186
|
+
if (item)
|
|
187
|
+
ordered.set(e.seq, item);
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
restored,
|
|
191
|
+
ordered,
|
|
192
|
+
meta: permissionContextMeta(sorted, [...restored, ...ordered.values()]),
|
|
193
|
+
};
|
|
194
|
+
}
|
|
@@ -5,10 +5,13 @@ import { ScheduledRuns } from "../infra/schedule/scheduled-runs.js";
|
|
|
5
5
|
import type { KernelLogger } from "../log.js";
|
|
6
6
|
import { DirectorySync } from "../orgs/directory-sync.js";
|
|
7
7
|
import { Offboarding } from "../orgs/offboarding.js";
|
|
8
|
+
import { CloudPermissionSnapshots } from "../sandbox/cloud-permission-snapshot.js";
|
|
9
|
+
import { SandboxOperationReconcileJob } from "../sandbox/operation-reconcile.job.js";
|
|
8
10
|
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
9
11
|
import { ScheduledTaskFirer } from "../schedules/fire.js";
|
|
10
12
|
import { DeviceOpResolver } from "../tools/device-op-resolver.js";
|
|
11
13
|
import { ToolDrift } from "../tools/drift.js";
|
|
14
|
+
import { PermissionApprovalJobs } from "../tools/permission-approval-jobs.js";
|
|
12
15
|
import { RunDeletion } from "./run-deletion.js";
|
|
13
16
|
import { RunQueue } from "./run-queue.js";
|
|
14
17
|
import { Waits } from "./waits.js";
|
|
@@ -30,6 +33,7 @@ export declare const MAINTENANCE_CONCURRENCY = 5;
|
|
|
30
33
|
* name fails the job (BullMQ retries it; in a rolling deploy a newer replica knows it). The producers are the domains' own (same names, ids and options).
|
|
31
34
|
*/
|
|
32
35
|
export declare class MaintenanceProcessor extends WorkerHost<Worker> {
|
|
36
|
+
private readonly permissionApprovals;
|
|
33
37
|
private readonly waits;
|
|
34
38
|
private readonly sandbox;
|
|
35
39
|
private readonly drift;
|
|
@@ -42,7 +46,9 @@ export declare class MaintenanceProcessor extends WorkerHost<Worker> {
|
|
|
42
46
|
private readonly deviceOps;
|
|
43
47
|
private readonly scheduled;
|
|
44
48
|
private readonly log;
|
|
45
|
-
|
|
49
|
+
private readonly operations;
|
|
50
|
+
private readonly snapshots?;
|
|
51
|
+
constructor(permissionApprovals: Pick<PermissionApprovalJobs, "recheck">, waits: Pick<Waits, "processTimeout" | "childFinished" | "stopChildren" | "stopDescendantsOfStopped" | "stopTree">, sandbox: Pick<SandboxService, "destroyDevice" | "resetFileSystem">, drift: Pick<ToolDrift, "check">, directory: Pick<DirectorySync, "runSyncJob">, deletion: Pick<RunDeletion, "stopOrg" | "stopTree">, offboarding: Pick<Offboarding, "stopRun">, runs: Pick<RunQueue, "ensureRun">, ownedCleanup: Pick<OwnedPluginCleanup, "run">, scheduledTasks: Pick<ScheduledTaskFirer, "fire" | "settle">, deviceOps: Pick<DeviceOpResolver, "resolve">, scheduled: Pick<ScheduledRuns, "runNow">, log: Pick<KernelLogger, "error" | "warn">, operations: Pick<SandboxOperationReconcileJob, "reconcile" | "revoke">, snapshots?: Pick<CloudPermissionSnapshots, "reconcileDevice"> | undefined);
|
|
46
52
|
process(job: Job, token?: string): Promise<void>;
|
|
47
53
|
/** Starts consuming (worker role, after the extensions loaded; built with `autorun: false`). */
|
|
48
54
|
start(): void;
|