@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
|
@@ -11,6 +11,7 @@ import { CompactionProgressService } from "./compaction-progress.js";
|
|
|
11
11
|
import { CompactionSettingsService } from "./compaction-settings.service.js";
|
|
12
12
|
import { type LoopDeps } from "./langgraph-loop.js";
|
|
13
13
|
import type { AgentLoop } from "./loop.js";
|
|
14
|
+
import { PermissionContextRecorder } from "./permission-context.service.js";
|
|
14
15
|
import { ProviderRegistry } from "./providers.js";
|
|
15
16
|
import { StepLog } from "./step-log.js";
|
|
16
17
|
import { SubagentsService } from "./subagents/subagents.service.js";
|
|
@@ -31,10 +32,17 @@ export declare class AgentLoops {
|
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
34
|
* What a run's steps use (`LoopDeps`: one model step plus the tool pipeline), over the injected
|
|
34
|
-
* services. `deps` is a plain object (eval replays copy it without the hooks, the progress
|
|
35
|
-
* fork dispatch).
|
|
35
|
+
* services. `deps` is a plain object (eval replays copy it without the hooks, the progress, the
|
|
36
|
+
* fork dispatch and the live permission recorder). The live permission context recorder is wired
|
|
37
|
+
* only when the paired activation gate is on ({@link PERMISSION_CONTEXT_ACTIVATION}).
|
|
36
38
|
*/
|
|
37
39
|
export declare class RunSteps {
|
|
38
40
|
readonly deps: LoopDeps;
|
|
39
|
-
constructor(kdb: KernelDb, eventLog: EventLog, stepLog: StepLog, registry: ProviderRegistry, tools: ToolRegistry, config: KernelConfigService, log: KernelLogger, toolPipeline: ToolPipeline, host: ExtensionHost, subagents: SubagentsService, attachments: AttachmentsService, compactionSettings: CompactionSettingsService, compactionProgress: CompactionProgressService);
|
|
41
|
+
constructor(kdb: KernelDb, eventLog: EventLog, stepLog: StepLog, registry: ProviderRegistry, tools: ToolRegistry, config: KernelConfigService, log: KernelLogger, toolPipeline: ToolPipeline, host: ExtensionHost, subagents: SubagentsService, attachments: AttachmentsService, compactionSettings: CompactionSettingsService, compactionProgress: CompactionProgressService, permissionContext: PermissionContextRecorder, activation?: boolean);
|
|
40
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* The live request boundary of a run's steps (spec B2): every agent-history request construction
|
|
45
|
+
* records the root's current permission context first. Present only when the one activation gate
|
|
46
|
+
* is on ({@link PERMISSION_CONTEXT_ACTIVATION}); otherwise no key at all.
|
|
47
|
+
*/
|
|
48
|
+
export declare function livePermissionContext(recorder: Pick<PermissionContextRecorder, "record">, activation: boolean | undefined): Pick<LoopDeps, "permissionContext">;
|
|
@@ -14,12 +14,14 @@ import { ExtensionHost } from "../extensions/host.js";
|
|
|
14
14
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
15
15
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
16
16
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
17
|
+
import { PERMISSION_CONTEXT_ACTIVATION, permissionContextActive, } from "../sandbox/permission-context-types.js";
|
|
17
18
|
import { ToolPipeline } from "../tools/pipeline.js";
|
|
18
19
|
import { ToolRegistry } from "../tools/registry.js";
|
|
19
20
|
import { KyselyCheckpointSaver } from "./checkpointer.js";
|
|
20
21
|
import { CompactionProgressService } from "./compaction-progress.js";
|
|
21
22
|
import { CompactionSettingsService } from "./compaction-settings.service.js";
|
|
22
23
|
import { LangGraphLoop } from "./langgraph-loop.js";
|
|
24
|
+
import { PermissionContextRecorder } from "./permission-context.service.js";
|
|
23
25
|
import { ProviderRegistry } from "./providers.js";
|
|
24
26
|
import { StepLog } from "./step-log.js";
|
|
25
27
|
import { SubagentsService } from "./subagents/subagents.service.js";
|
|
@@ -48,12 +50,13 @@ AgentLoops = __decorate([
|
|
|
48
50
|
export { AgentLoops };
|
|
49
51
|
/**
|
|
50
52
|
* What a run's steps use (`LoopDeps`: one model step plus the tool pipeline), over the injected
|
|
51
|
-
* services. `deps` is a plain object (eval replays copy it without the hooks, the progress
|
|
52
|
-
* fork dispatch).
|
|
53
|
+
* services. `deps` is a plain object (eval replays copy it without the hooks, the progress, the
|
|
54
|
+
* fork dispatch and the live permission recorder). The live permission context recorder is wired
|
|
55
|
+
* only when the paired activation gate is on ({@link PERMISSION_CONTEXT_ACTIVATION}).
|
|
53
56
|
*/
|
|
54
57
|
let RunSteps = class RunSteps {
|
|
55
58
|
deps;
|
|
56
|
-
constructor(kdb, eventLog, stepLog, registry, tools, config, log, toolPipeline, host, subagents, attachments, compactionSettings, compactionProgress) {
|
|
59
|
+
constructor(kdb, eventLog, stepLog, registry, tools, config, log, toolPipeline, host, subagents, attachments, compactionSettings, compactionProgress, permissionContext, activation) {
|
|
57
60
|
this.deps = {
|
|
58
61
|
get db() {
|
|
59
62
|
return kdb.db;
|
|
@@ -78,6 +81,9 @@ let RunSteps = class RunSteps {
|
|
|
78
81
|
info: (orgId, conversationId, ids) => attachments.mediaInfo(orgId, conversationId, ids),
|
|
79
82
|
fetch: (orgId, conversationId, ids, caps) => attachments.fetchMedia(orgId, conversationId, ids, caps),
|
|
80
83
|
},
|
|
84
|
+
// the request boundary of the recorded permission context (spec B2); dormant until the
|
|
85
|
+
// paired activation (Task 8 phase 8.6) turns the gate on
|
|
86
|
+
...livePermissionContext(permissionContext, activation),
|
|
81
87
|
};
|
|
82
88
|
}
|
|
83
89
|
};
|
|
@@ -95,6 +101,23 @@ RunSteps = __decorate([
|
|
|
95
101
|
__param(9, Inject(SubagentsService)),
|
|
96
102
|
__param(10, Inject(AttachmentsService)),
|
|
97
103
|
__param(11, Inject(CompactionSettingsService)),
|
|
98
|
-
__param(12, Inject(CompactionProgressService))
|
|
104
|
+
__param(12, Inject(CompactionProgressService)),
|
|
105
|
+
__param(13, Inject(PermissionContextRecorder)),
|
|
106
|
+
__param(14, Optional()),
|
|
107
|
+
__param(14, Inject(PERMISSION_CONTEXT_ACTIVATION))
|
|
99
108
|
], RunSteps);
|
|
100
109
|
export { RunSteps };
|
|
110
|
+
/**
|
|
111
|
+
* The live request boundary of a run's steps (spec B2): every agent-history request construction
|
|
112
|
+
* records the root's current permission context first. Present only when the one activation gate
|
|
113
|
+
* is on ({@link PERMISSION_CONTEXT_ACTIVATION}); otherwise no key at all.
|
|
114
|
+
*/
|
|
115
|
+
export function livePermissionContext(recorder, activation) {
|
|
116
|
+
if (!permissionContextActive(activation))
|
|
117
|
+
return {};
|
|
118
|
+
return {
|
|
119
|
+
permissionContext: {
|
|
120
|
+
beforeRequest: ({ orgId, conversationId, runId, accountId, signal }) => recorder.record({ orgId, conversationId, runId, accountId }, signal),
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
@@ -10,6 +10,7 @@ import { BackgroundWake } from "../background/wake.js";
|
|
|
10
10
|
import { ConversationAccessModule } from "../conversations/access.js";
|
|
11
11
|
import { AttachmentsModule } from "../conversations/attachments.module.js";
|
|
12
12
|
import { EventLogModule } from "../conversations/event-log.js";
|
|
13
|
+
import { PermissionProfileStoreModule } from "../conversations/permission-profile-store.module.js";
|
|
13
14
|
import { TitlesModule } from "../conversations/titles.js";
|
|
14
15
|
import { DevicesModule } from "../devices/devices.module.js";
|
|
15
16
|
import { ExtensionsModule } from "../extensions/extensions.module.js";
|
|
@@ -18,6 +19,8 @@ import { IdentityModule } from "../identity/identity.module.js";
|
|
|
18
19
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
19
20
|
import { QueueModule } from "../infra/queue/queue.module.js";
|
|
20
21
|
import { REDIS } from "../infra/tokens.js";
|
|
22
|
+
import { OperationAuthorityModule } from "../sandbox/operation-authority.module.js";
|
|
23
|
+
import { PermissionAuthorityModule } from "../sandbox/permission-authority.module.js";
|
|
21
24
|
import { SandboxModule } from "../sandbox/sandbox.module.js";
|
|
22
25
|
import { ScheduledTaskTrackerModule } from "../schedules/run-tracker.js";
|
|
23
26
|
import { SkillsModule } from "../skills/skills.module.js";
|
|
@@ -29,6 +32,7 @@ import { CompactionProgressService } from "./compaction-progress.js";
|
|
|
29
32
|
import { CompactionSettingsService } from "./compaction-settings.service.js";
|
|
30
33
|
import { ConversationLock } from "./conversation-lock.js";
|
|
31
34
|
import { MAINTENANCE_QUEUE_NAME } from "./maintenance-queue.js";
|
|
35
|
+
import { PermissionContextRecorder } from "./permission-context.service.js";
|
|
32
36
|
import { PluginContextService } from "./plugin-context.service.js";
|
|
33
37
|
import { ProjectKnowledgeService } from "./project/knowledge.service.js";
|
|
34
38
|
import { ProvidersModule } from "./providers.js";
|
|
@@ -70,6 +74,11 @@ RuntimeModule = __decorate([
|
|
|
70
74
|
// a bound conversation's device and project scope (project root spec §4.4)
|
|
71
75
|
DevicesModule,
|
|
72
76
|
SandboxModule,
|
|
77
|
+
// the recorded permission context: the authority projection shared with admission, its locks
|
|
78
|
+
// and publication, and the stored root (dormant until the request boundary activates)
|
|
79
|
+
OperationAuthorityModule,
|
|
80
|
+
PermissionAuthorityModule,
|
|
81
|
+
PermissionProfileStoreModule,
|
|
73
82
|
GitModule,
|
|
74
83
|
ProvidersModule,
|
|
75
84
|
RunJobsModule,
|
|
@@ -99,6 +108,7 @@ RuntimeModule = __decorate([
|
|
|
99
108
|
AgentLoops,
|
|
100
109
|
RunSteps,
|
|
101
110
|
RunContextService,
|
|
111
|
+
PermissionContextRecorder,
|
|
102
112
|
PluginContextService,
|
|
103
113
|
ProjectKnowledgeService,
|
|
104
114
|
RunWorker,
|
|
@@ -138,6 +148,7 @@ RuntimeModule = __decorate([
|
|
|
138
148
|
AgentLoops,
|
|
139
149
|
RunSteps,
|
|
140
150
|
RunWorker,
|
|
151
|
+
PermissionContextRecorder,
|
|
141
152
|
CompactionSettingsService,
|
|
142
153
|
CompactionService,
|
|
143
154
|
RUN_QUOTA,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type SandboxRoots } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
/**
|
|
3
|
+
* Where attachments live in a device: FetchAttachment writes there, and the sandbox service's
|
|
4
|
+
* trusted preparation accepts exactly one conversation's directory (`tools/builtins/sandbox/
|
|
5
|
+
* common.ts` re-exports these).
|
|
6
|
+
*/
|
|
7
|
+
/** The directory of attachments in the device (each conversation has a subdirectory). */
|
|
8
|
+
export declare const attachmentsRoot: (roots: SandboxRoots) => string;
|
|
9
|
+
/** {@link attachmentsRoot} of an instance with the default roots. */
|
|
10
|
+
export declare const ATTACHMENTS_ROOT: string;
|
|
11
|
+
/**
|
|
12
|
+
* One conversation's attachment directory: the first 12 hex digits of the root conversation's
|
|
13
|
+
* UUID, so conversations sharing a device do not overwrite each other's files.
|
|
14
|
+
*/
|
|
15
|
+
export declare const attachmentsDir: (roots: SandboxRoots, rootConversationId: string) => string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DEFAULT_SANDBOX_ROOTS } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
/**
|
|
3
|
+
* Where attachments live in a device: FetchAttachment writes there, and the sandbox service's
|
|
4
|
+
* trusted preparation accepts exactly one conversation's directory (`tools/builtins/sandbox/
|
|
5
|
+
* common.ts` re-exports these).
|
|
6
|
+
*/
|
|
7
|
+
/** The directory of attachments in the device (each conversation has a subdirectory). */
|
|
8
|
+
export const attachmentsRoot = (roots) => `${roots.workspace}/attachments`;
|
|
9
|
+
/** {@link attachmentsRoot} of an instance with the default roots. */
|
|
10
|
+
export const ATTACHMENTS_ROOT = attachmentsRoot(DEFAULT_SANDBOX_ROOTS);
|
|
11
|
+
/**
|
|
12
|
+
* One conversation's attachment directory: the first 12 hex digits of the root conversation's
|
|
13
|
+
* UUID, so conversations sharing a device do not overwrite each other's files.
|
|
14
|
+
*/
|
|
15
|
+
export const attachmentsDir = (roots, rootConversationId) => `${attachmentsRoot(roots)}/${rootConversationId.replaceAll("-", "").slice(0, 12)}`;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
2
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
3
|
+
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
4
|
+
import { SandboxLeases } from "./leases.js";
|
|
5
|
+
import { LegacyRetirementStore } from "./legacy-retirement.js";
|
|
6
|
+
import { type AppliedLimits } from "./modes.js";
|
|
7
|
+
import { PermissionAuthorityLock } from "./permission-authority-lock.js";
|
|
8
|
+
import { PermissionCeilingWrites } from "./permission-ceiling-writes.js";
|
|
9
|
+
import { PermissionConfigPublication } from "./permission-config-publication.js";
|
|
10
|
+
import { PermissionFacts } from "./permission-facts.js";
|
|
11
|
+
import { SandboxProviders } from "./providers.js";
|
|
12
|
+
/**
|
|
13
|
+
* What a snapshot or reconciliation found: `unprobed` (no instance or file system yet: the next
|
|
14
|
+
* create applies the desired limits exactly), `bound` (the recorded applied limits are exactly
|
|
15
|
+
* the desired ones), `reconcile-required` (unknown, stale, wider or pending: no admission until a
|
|
16
|
+
* lifecycle action establishes them; `action` names it), `existing` (already snapshotted, kept),
|
|
17
|
+
* `skipped` (not a live cloud device).
|
|
18
|
+
*/
|
|
19
|
+
export type CloudSnapshotState = "unprobed" | "bound" | "reconcile-required" | "existing" | "skipped";
|
|
20
|
+
export interface CloudSnapshotOutcome {
|
|
21
|
+
state: CloudSnapshotState;
|
|
22
|
+
/** The lifecycle action that establishes the exact limits when they are required. */
|
|
23
|
+
action?: "reset-files";
|
|
24
|
+
/**
|
|
25
|
+
* `reconcile-required` on a live instance: the limits that would establish the device's
|
|
26
|
+
* authority, never wider than the instance is known to run in any dimension (B-12). A provider
|
|
27
|
+
* `update` that applies exactly these clears the marker (`SandboxService.reconcileLimits`).
|
|
28
|
+
*/
|
|
29
|
+
target?: AppliedLimits;
|
|
30
|
+
}
|
|
31
|
+
/** One device a {@link CloudPermissionSnapshots.snapshotAll} run snapshotted. */
|
|
32
|
+
export interface CloudSnapshotResult extends CloudSnapshotOutcome {
|
|
33
|
+
deviceId: string;
|
|
34
|
+
orgId: string;
|
|
35
|
+
}
|
|
36
|
+
/** What a {@link CloudPermissionSnapshots.snapshotAll} run did. */
|
|
37
|
+
export interface CloudSnapshotRun {
|
|
38
|
+
/** The devices this run snapshotted (empty on a rerun: nothing published). */
|
|
39
|
+
results: CloudSnapshotResult[];
|
|
40
|
+
/** Devices it could not snapshot (lease wait, a failed transaction); left for the next run. */
|
|
41
|
+
failed: {
|
|
42
|
+
deviceId: string;
|
|
43
|
+
orgId: string;
|
|
44
|
+
error: string;
|
|
45
|
+
}[];
|
|
46
|
+
/** Live cloud devices still without a snapshot after the run. */
|
|
47
|
+
pending: number;
|
|
48
|
+
/** Live cloud devices that keep the reconciliation marker (admission blocked until reset). */
|
|
49
|
+
reconcileRequired: string[];
|
|
50
|
+
}
|
|
51
|
+
/** Where the cloud snapshot stands (read by `capybara permissions cutover report`, too). */
|
|
52
|
+
export interface CloudSnapshotProgress {
|
|
53
|
+
/** Live cloud devices. */
|
|
54
|
+
cloudDevices: number;
|
|
55
|
+
/** Live cloud devices without a snapshot yet. */
|
|
56
|
+
pending: number;
|
|
57
|
+
/** Live cloud devices carrying `permission_reconcile_required`. */
|
|
58
|
+
reconcileRequired: string[];
|
|
59
|
+
}
|
|
60
|
+
/** The live (not deleted) cloud devices of orgs that still exist. */
|
|
61
|
+
type DeviceReader = Pick<KernelDb, "selectFrom">;
|
|
62
|
+
/** Reads the cloud snapshot's progress; no lock, no lease (a report). */
|
|
63
|
+
export declare function readCloudSnapshotProgress(db: DeviceReader): Promise<CloudSnapshotProgress>;
|
|
64
|
+
/**
|
|
65
|
+
* The B1 cloud per-device authority writer: replaces the old daily mode of a cloud device by an
|
|
66
|
+
* explicit owner Full ceiling and outer network, computed from the device's OLD effective
|
|
67
|
+
* authority (platform switch with its configured / stored precedence, the org's switch and cloud
|
|
68
|
+
* network, the device's narrowing switch, `egress: none`), narrowed by what its instance is known
|
|
69
|
+
* to run, never widened. Each device: the exclusive lifecycle lease outside the transaction, then
|
|
70
|
+
* the device authority write lock (platform -> org -> device order) before the row locks. Written
|
|
71
|
+
* once: a snapshot is never recomputed (a later false stays explicit after a widening). A device
|
|
72
|
+
* whose applied limits are not exactly the desired ones keeps a durable marker that blocks
|
|
73
|
+
* admission ({@link PermissionFacts.assertCloudReconciled}) until {@link reconcile} finds them
|
|
74
|
+
* established: after a file reset (the next create applies them exactly), or once a provider
|
|
75
|
+
* `update` under the lifecycle lease applied the reconcile target (B-12,
|
|
76
|
+
* `SandboxService.reconcileLimits`). Reconciling keeps any stricter boundary the instance is
|
|
77
|
+
* known to run by intersection: the owner ceiling and outer network are narrowed to it (a real
|
|
78
|
+
* narrowing, published like the snapshot's), never the instance widened to the authority.
|
|
79
|
+
*/
|
|
80
|
+
export declare class CloudPermissionSnapshots {
|
|
81
|
+
private readonly db;
|
|
82
|
+
readonly txHost: TransactionHost;
|
|
83
|
+
private readonly leases;
|
|
84
|
+
private readonly locks;
|
|
85
|
+
private readonly config;
|
|
86
|
+
private readonly facts;
|
|
87
|
+
private readonly publication;
|
|
88
|
+
private readonly ceilings;
|
|
89
|
+
private readonly retirement;
|
|
90
|
+
/** Whether a device's provider fixes limits at its file system (B-12 intersection). */
|
|
91
|
+
private readonly providers;
|
|
92
|
+
constructor(db: KernelDb, txHost: TransactionHost, leases: SandboxLeases, locks: PermissionAuthorityLock, config: Pick<KernelConfigService, "get" | "fieldSource">, facts: PermissionFacts, publication: Pick<PermissionConfigPublication, "assertCurrent">, ceilings: Pick<PermissionCeilingWrites, "publishLocked">, retirement: Pick<LegacyRetirementStore, "assertCutoverBarrier">,
|
|
93
|
+
/** Whether a device's provider fixes limits at its file system (B-12 intersection). */
|
|
94
|
+
providers: Pick<SandboxProviders, "cloud" | "forName">);
|
|
95
|
+
/**
|
|
96
|
+
* The production driver (B-10, `capybara permissions cutover snapshot`): snapshots every live
|
|
97
|
+
* cloud device that has none yet, one device at a time, each under its exclusive lifecycle
|
|
98
|
+
* lease and in its own transaction ({@link snapshot}).
|
|
99
|
+
*
|
|
100
|
+
* - **Barrier.** Refuses unless legacy admission is closed (the freeze published and enumerated,
|
|
101
|
+
* {@link LegacyRetirementStore.assertCutoverBarrier}) and this replica's permission
|
|
102
|
+
* configuration is the published one; each device re-checks the latter under the platform
|
|
103
|
+
* lock, and a failure there stops the run.
|
|
104
|
+
* - **Idempotent.** Only devices without a snapshot are visited, and {@link snapshot} keeps an
|
|
105
|
+
* existing one under the row lock, so a rerun takes no lease and publishes nothing.
|
|
106
|
+
* - **Resumable.** A device's snapshot, its narrowing publication (epoch, Full consent reset,
|
|
107
|
+
* exact revocation) and its marker commit together or not at all; a crash or a failed device
|
|
108
|
+
* leaves it without a snapshot for the next run, never half written or published twice.
|
|
109
|
+
* - Devices whose applied limits are not established keep `permission_reconcile_required`
|
|
110
|
+
* (listed in the answer) until a file reset reconciles them.
|
|
111
|
+
*/
|
|
112
|
+
snapshotAll(opts?: {
|
|
113
|
+
signal?: AbortSignal;
|
|
114
|
+
leaseWaitMs?: number;
|
|
115
|
+
}): Promise<CloudSnapshotRun>;
|
|
116
|
+
/** Snapshots one device under its exclusive lifecycle lease. */
|
|
117
|
+
snapshot(orgId: string, deviceId: string, signal?: AbortSignal): Promise<CloudSnapshotOutcome>;
|
|
118
|
+
/** Re-checks a device carrying the marker; clears it once its limits are established. */
|
|
119
|
+
reconcile(orgId: string, deviceId: string, signal?: AbortSignal): Promise<CloudSnapshotOutcome>;
|
|
120
|
+
/**
|
|
121
|
+
* {@link reconcile} for a caller that already holds the device's exclusive lifecycle lease
|
|
122
|
+
* (`SandboxService.reconcileLimits`): the same transaction, no lease taken here.
|
|
123
|
+
*/
|
|
124
|
+
reconcileHeld(orgId: string, deviceId: string): Promise<CloudSnapshotOutcome>;
|
|
125
|
+
/** {@link reconcile} by device id alone (after a file reset); nothing for an unknown device. */
|
|
126
|
+
reconcileDevice(deviceId: string): Promise<CloudSnapshotOutcome>;
|
|
127
|
+
private underLease;
|
|
128
|
+
private snapshotLocked;
|
|
129
|
+
/**
|
|
130
|
+
* A narrowed owner ceiling or outer network changes the device's authority: it goes through the
|
|
131
|
+
* device ceiling writer (epoch, Full consent, exact revocation) in the caller's transaction,
|
|
132
|
+
* under the device write lock already held.
|
|
133
|
+
*/
|
|
134
|
+
private publishNarrowing;
|
|
135
|
+
/**
|
|
136
|
+
* Re-checks a marked device under its write lock. With an instance whose applied limits are
|
|
137
|
+
* known (in force, even with a newer value pending a reset), the device's authority is first
|
|
138
|
+
* narrowed to them by intersection (B-12): Full only where the instance runs auto, the outer
|
|
139
|
+
* network cut to the applied network; a real narrowing is published. Then the marker clears
|
|
140
|
+
* when the applied limits are exactly the (narrowed) effective ones with nothing pending;
|
|
141
|
+
* otherwise it stays, with the target that would establish them: the effective limits, which
|
|
142
|
+
* are now never wider than the instance in any dimension, so applying them only narrows.
|
|
143
|
+
*/
|
|
144
|
+
private reconcileLocked;
|
|
145
|
+
private desired;
|
|
146
|
+
/**
|
|
147
|
+
* The device row under the device authority write lock, or undefined (not a live cloud one). The
|
|
148
|
+
* row is locked first (`FOR NO KEY UPDATE`: only non-key columns change), then the permission
|
|
149
|
+
* lock, the order the device writers take (`DevicesService.lockOwn`, the device project writes),
|
|
150
|
+
* then the row is read again under both.
|
|
151
|
+
*/
|
|
152
|
+
private lockedDevice;
|
|
153
|
+
/**
|
|
154
|
+
* The device's instance row when an instance or a file system exists (their limits are in
|
|
155
|
+
* force); null when neither does (the next create applies the desired limits exactly).
|
|
156
|
+
*/
|
|
157
|
+
private lockedInstance;
|
|
158
|
+
}
|
|
159
|
+
export {};
|