@capybara-hq/kernel 0.1.0-rc.41 → 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 +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 +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
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { SandboxRoots } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import type { PermissionContextV1 } from "../conversations/events.js";
|
|
3
|
+
/**
|
|
4
|
+
* The complete identity a recorded permission context is read for: the calling conversation, its
|
|
5
|
+
* run and the run's actor. Kernel-private; shared by the authority projection below runtime and the
|
|
6
|
+
* runtime recorder above it, so neither imports the other's service.
|
|
7
|
+
*/
|
|
8
|
+
export interface PermissionContextSubject {
|
|
9
|
+
orgId: string;
|
|
10
|
+
conversationId: string;
|
|
11
|
+
runId: string;
|
|
12
|
+
accountId: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* What a managed operation entry already holds for the device it entered (Task 8 producer): the
|
|
16
|
+
* installed instance incarnation and binding, its roots and the working root of the shared base
|
|
17
|
+
* facts. Never read from model or tool input, never cached across operations.
|
|
18
|
+
*/
|
|
19
|
+
export interface HeldDeviceContextEvidence {
|
|
20
|
+
deviceId: string;
|
|
21
|
+
provider: string;
|
|
22
|
+
instanceId: string;
|
|
23
|
+
instanceGeneration: string;
|
|
24
|
+
bindingId: string;
|
|
25
|
+
roots: SandboxRoots;
|
|
26
|
+
workingRoot: string;
|
|
27
|
+
}
|
|
28
|
+
/** The outer boundary a recorded context reports, as the applied environment proves it. */
|
|
29
|
+
export type AppliedOuterNetwork = NonNullable<PermissionContextV1["scope"]>["outerNetwork"];
|
|
30
|
+
/**
|
|
31
|
+
* The installed environment of a device's current instance, proved by its installed binding and
|
|
32
|
+
* current runtime attestation (B1 adapter). Null from the reader means unproved: the context is
|
|
33
|
+
* unprobed and carries no scope.
|
|
34
|
+
*/
|
|
35
|
+
export interface AppliedEnvironment {
|
|
36
|
+
location: "local" | "cloud";
|
|
37
|
+
/** The provider of the installed instance (its row and its installed binding agree). */
|
|
38
|
+
provider: string;
|
|
39
|
+
instanceId: string;
|
|
40
|
+
instanceGeneration: string;
|
|
41
|
+
bindingId: string;
|
|
42
|
+
roots: SandboxRoots;
|
|
43
|
+
outerNetwork: AppliedOuterNetwork;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The root or device the caller discovered before taking the authority locks is no longer the
|
|
47
|
+
* conversation's: the held locks do not cover the current subject. The caller releases its
|
|
48
|
+
* transaction and rediscovers (once); it never adds a lock under the existing ones.
|
|
49
|
+
*/
|
|
50
|
+
export declare class PermissionContextSubjectChanged extends Error {
|
|
51
|
+
readonly name = "PermissionContextSubjectChanged";
|
|
52
|
+
constructor();
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The paired activation of the recorded permission context (Gate 9.4 with Task 8 phase 8.6): the
|
|
56
|
+
* one explicit gate for both live producers, the request boundary (`RunSteps`) and the managed
|
|
57
|
+
* device context writer (`BuiltinTools` into `common.ts`). Production provides nothing and reads
|
|
58
|
+
* {@link PERMISSION_CONTEXT_ACTIVE}; tests provide this token to exercise either state.
|
|
59
|
+
*/
|
|
60
|
+
export declare const PERMISSION_CONTEXT_ACTIVATION: unique symbol;
|
|
61
|
+
/** The production state of the gate: dormant until the paired cutover flips it. */
|
|
62
|
+
export declare const PERMISSION_CONTEXT_ACTIVE = false;
|
|
63
|
+
/** Whether the live producers are on: an injected test value, else {@link PERMISSION_CONTEXT_ACTIVE}. */
|
|
64
|
+
export declare function permissionContextActive(injected: boolean | undefined): boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The root or device the caller discovered before taking the authority locks is no longer the
|
|
3
|
+
* conversation's: the held locks do not cover the current subject. The caller releases its
|
|
4
|
+
* transaction and rediscovers (once); it never adds a lock under the existing ones.
|
|
5
|
+
*/
|
|
6
|
+
export class PermissionContextSubjectChanged extends Error {
|
|
7
|
+
name = "PermissionContextSubjectChanged";
|
|
8
|
+
constructor() {
|
|
9
|
+
super("The conversation's root or device changed before its permission context was read");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The paired activation of the recorded permission context (Gate 9.4 with Task 8 phase 8.6): the
|
|
14
|
+
* one explicit gate for both live producers, the request boundary (`RunSteps`) and the managed
|
|
15
|
+
* device context writer (`BuiltinTools` into `common.ts`). Production provides nothing and reads
|
|
16
|
+
* {@link PERMISSION_CONTEXT_ACTIVE}; tests provide this token to exercise either state.
|
|
17
|
+
*/
|
|
18
|
+
export const PERMISSION_CONTEXT_ACTIVATION = Symbol("PERMISSION_CONTEXT_ACTIVATION");
|
|
19
|
+
/** The production state of the gate: dormant until the paired cutover flips it. */
|
|
20
|
+
export const PERMISSION_CONTEXT_ACTIVE = false;
|
|
21
|
+
/** Whether the live producers are on: an injected test value, else {@link PERMISSION_CONTEXT_ACTIVE}. */
|
|
22
|
+
export function permissionContextActive(injected) {
|
|
23
|
+
return injected ?? PERMISSION_CONTEXT_ACTIVE;
|
|
24
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { type PermissionProfile } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import type { PermissionRoot } from "../conversations/permission-profile-store.js";
|
|
3
|
+
import { DeviceAccess } from "../devices/access.js";
|
|
4
|
+
import { type DeviceProjectScope } from "../devices/project-rules.js";
|
|
5
|
+
import { type WorkingProject } from "../devices/working-root.js";
|
|
6
|
+
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
7
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
8
|
+
import { type DeviceNetwork, type EffectiveDevicePolicy } from "./modes.js";
|
|
9
|
+
import type { AppliedEnvironment, AppliedOuterNetwork } from "./permission-context-types.js";
|
|
10
|
+
import { SandboxProviders } from "./providers.js";
|
|
11
|
+
type Scope = DeviceProjectScope;
|
|
12
|
+
/**
|
|
13
|
+
* What decides the working root of a call (project root spec §4.3), read the same way for a
|
|
14
|
+
* sandbox tool and for the command review, so both decide the same root.
|
|
15
|
+
*/
|
|
16
|
+
export interface WorkingFacts {
|
|
17
|
+
/**
|
|
18
|
+
* The device's workspace: the latest `device_paths` roots recorded in the calling conversation,
|
|
19
|
+
* else the root's, else the machine's reported roots, else the default.
|
|
20
|
+
*/
|
|
21
|
+
workspace: string;
|
|
22
|
+
/** The owner's home: the machine's reported home, else the workspace's home prefix; null: unknown. */
|
|
23
|
+
home: string | null;
|
|
24
|
+
/** The root conversation's latest project snapshot; null: free, or none recorded yet. */
|
|
25
|
+
project: WorkingProject | null;
|
|
26
|
+
}
|
|
27
|
+
export declare const permissionScopeHash: (value: unknown) => string;
|
|
28
|
+
/** Database and registered metadata reads only; never provisions or probes a device. */
|
|
29
|
+
export declare class PermissionFacts {
|
|
30
|
+
private readonly db;
|
|
31
|
+
private readonly config;
|
|
32
|
+
private readonly providers;
|
|
33
|
+
private readonly devices;
|
|
34
|
+
constructor(db: KernelDb, config: Pick<KernelConfigService, "get" | "fieldSource">, providers: Pick<SandboxProviders, "cloud" | "forName">, devices: Pick<DeviceAccess, "usable">);
|
|
35
|
+
/** Current policy and persisted owner roots; access is checked by the caller. */
|
|
36
|
+
readDevice(orgId: string, deviceId: string): Promise<{
|
|
37
|
+
policy: EffectiveDevicePolicy;
|
|
38
|
+
owner: {
|
|
39
|
+
state: "blocked" | "legacy" | "report";
|
|
40
|
+
fullAccess: boolean;
|
|
41
|
+
restrictedProjectReach: import("../local-devices/owner-report.js").RestrictedProjectReach;
|
|
42
|
+
allowedDomains: string[];
|
|
43
|
+
} | null;
|
|
44
|
+
roots: {} | null;
|
|
45
|
+
home: string | null;
|
|
46
|
+
}>;
|
|
47
|
+
/** Stored binding only; projectScope supplies the live owner and deletion checks. */
|
|
48
|
+
readProject(orgId: string, deviceId: string, name: string): Promise<{
|
|
49
|
+
name: string;
|
|
50
|
+
path: string;
|
|
51
|
+
} | null>;
|
|
52
|
+
devicePolicy(device: {
|
|
53
|
+
orgId: string;
|
|
54
|
+
deviceId?: string;
|
|
55
|
+
}): Promise<EffectiveDevicePolicy>;
|
|
56
|
+
/**
|
|
57
|
+
* Refuses admission on a cloud device whose B1 snapshot found applied limits it could not
|
|
58
|
+
* establish exactly (unknown, stale, wider or pending a reset): only a lifecycle action that
|
|
59
|
+
* establishes them clears the marker (`CloudPermissionSnapshots.reconcile`). Read under the
|
|
60
|
+
* caller's device authority lock, which the snapshot writer takes for writing.
|
|
61
|
+
*/
|
|
62
|
+
assertCloudReconciled(orgId: string, deviceId: string): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Refuses new authority on a local device whose machine regressed its owner report sequence on
|
|
65
|
+
* a new connection or sent conflicting reports (B2): only a valid current report or a new
|
|
66
|
+
* login clears it. Late deliveries of older reports are ignored, never blocking.
|
|
67
|
+
*/
|
|
68
|
+
assertOwnerReportUsable(orgId: string, deviceId: string): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* The mode a device chose: a local device's derived one (`localModeOf`, which never returns null
|
|
71
|
+
* — a machine with no summary or no mode feature is sandbox); a cloud device's narrowing switch
|
|
72
|
+
* (`devices.mode`, `sandbox` only), or null for a cloud device that follows the platform and the
|
|
73
|
+
* org.
|
|
74
|
+
*/
|
|
75
|
+
private deviceChosenMode;
|
|
76
|
+
readWorkingFacts({ orgId, rootConversationId, holderConversationId: conversationId, deviceId, }: {
|
|
77
|
+
orgId: string;
|
|
78
|
+
rootConversationId: string;
|
|
79
|
+
holderConversationId: string;
|
|
80
|
+
deviceId: string;
|
|
81
|
+
}): Promise<WorkingFacts>;
|
|
82
|
+
/**
|
|
83
|
+
* The project snapshot that decides the working root of the conversation tree rooted at
|
|
84
|
+
* `rootConversationId` (project root spec §4.3): its latest `project_root` event, read only when
|
|
85
|
+
* the conversation is bound to a project (a free conversation reads one row by its key). Null:
|
|
86
|
+
* free, or bound with no snapshot recorded yet.
|
|
87
|
+
*/
|
|
88
|
+
workingProject(orgId: string, rootConversationId: string): Promise<WorkingProject | null>;
|
|
89
|
+
/** The workspace root of a conversation's latest `device_paths` event, or null. */
|
|
90
|
+
private recordedWorkspace;
|
|
91
|
+
/**
|
|
92
|
+
* The workspace root and the owner's home the device's active machine last reported, or null
|
|
93
|
+
* (cloud: no machine).
|
|
94
|
+
*/
|
|
95
|
+
private machineRoots;
|
|
96
|
+
projectScope(orgId: string, accountId: string, deviceId: string): Promise<Scope>;
|
|
97
|
+
resolveProjectForBinding(orgId: string, deviceId: string, accountId: string, name: string): Promise<{
|
|
98
|
+
name: string;
|
|
99
|
+
path: string;
|
|
100
|
+
}>;
|
|
101
|
+
projectMatches(deviceId: string, name: string, path: string): Promise<boolean>;
|
|
102
|
+
scope(orgId: string, deviceId: string, projectPath: string | null, project: string | null): Promise<{
|
|
103
|
+
deviceId: string;
|
|
104
|
+
project: string | null;
|
|
105
|
+
scopeRevision: string;
|
|
106
|
+
availability: import("./permission-availability.js").PermissionAvailability;
|
|
107
|
+
fullAccessCeiling: boolean;
|
|
108
|
+
broadProjectReach: boolean;
|
|
109
|
+
}>;
|
|
110
|
+
preview(orgId: string, accountId: string, deviceId: string, project?: string): Promise<{
|
|
111
|
+
deviceId: string;
|
|
112
|
+
project: string | null;
|
|
113
|
+
scopeRevision: string;
|
|
114
|
+
availability: import("./permission-availability.js").PermissionAvailability;
|
|
115
|
+
fullAccessCeiling: boolean;
|
|
116
|
+
broadProjectReach: boolean;
|
|
117
|
+
}>;
|
|
118
|
+
view(orgId: string, accountId: string, row: PermissionRoot): Promise<{
|
|
119
|
+
profile: PermissionProfile;
|
|
120
|
+
revision: number;
|
|
121
|
+
rootConversationId: string;
|
|
122
|
+
deviceId: string | null;
|
|
123
|
+
consentScope: {
|
|
124
|
+
deviceId: string;
|
|
125
|
+
scopeRevision: string;
|
|
126
|
+
} | null;
|
|
127
|
+
scopeRevision: string | null;
|
|
128
|
+
availability: import("./permission-availability.js").PermissionAvailability;
|
|
129
|
+
fullAccessCeiling: boolean;
|
|
130
|
+
broadProjectReach: boolean;
|
|
131
|
+
startingWorkNotice: string;
|
|
132
|
+
}>;
|
|
133
|
+
/**
|
|
134
|
+
* {@link view} plus how the actor reached the root's device: none selected, usable, refused for
|
|
135
|
+
* this actor (`device.not_found`: not its device), or its provider is not the current one. The
|
|
136
|
+
* recorded permission context needs the distinction; the view itself stays unchanged.
|
|
137
|
+
*/
|
|
138
|
+
viewWithAccess(orgId: string, accountId: string, row: PermissionRoot): Promise<{
|
|
139
|
+
access: "actor-device-access" | "device" | "no-device" | "provider-unavailable";
|
|
140
|
+
view: {
|
|
141
|
+
profile: PermissionProfile;
|
|
142
|
+
revision: number;
|
|
143
|
+
rootConversationId: string;
|
|
144
|
+
deviceId: string | null;
|
|
145
|
+
consentScope: {
|
|
146
|
+
deviceId: string;
|
|
147
|
+
scopeRevision: string;
|
|
148
|
+
} | null;
|
|
149
|
+
scopeRevision: string | null;
|
|
150
|
+
availability: import("./permission-availability.js").PermissionAvailability;
|
|
151
|
+
fullAccessCeiling: boolean;
|
|
152
|
+
broadProjectReach: boolean;
|
|
153
|
+
startingWorkNotice: string;
|
|
154
|
+
};
|
|
155
|
+
}>;
|
|
156
|
+
/**
|
|
157
|
+
* The installed environment of the device's current instance (B1 adapter over the Task 8 B4
|
|
158
|
+
* installed binding and its current runtime attestation), read under the caller's device
|
|
159
|
+
* authority lock. Null whenever it cannot be proved: no live instance (none, creating,
|
|
160
|
+
* destroyed), no installed binding of exactly this generation, a binding of another provider or
|
|
161
|
+
* machine, a runtime identity differing from the bound one, roots differing from the committed
|
|
162
|
+
* ones. A cloud device proves it by its kernel-recorded cloud evidence instead (B-15,
|
|
163
|
+
* {@link cloudAppliedLocked}). Never desired policy, never a provider call, probe, resume or
|
|
164
|
+
* provisioning; a suspended instance is read as recorded.
|
|
165
|
+
*/
|
|
166
|
+
readAppliedEnvironmentLocked(input: {
|
|
167
|
+
orgId: string;
|
|
168
|
+
deviceId: string;
|
|
169
|
+
}): Promise<AppliedEnvironment | null>;
|
|
170
|
+
/**
|
|
171
|
+
* {@link readAppliedEnvironmentLocked} without the authority locks: a managed operation's held
|
|
172
|
+
* evidence only (read under its lifecycle lease), which the managed writer validates again
|
|
173
|
+
* under the locks. Never a basis for admission or a recorded context.
|
|
174
|
+
*/
|
|
175
|
+
readHeldEnvironment(input: {
|
|
176
|
+
orgId: string;
|
|
177
|
+
deviceId: string;
|
|
178
|
+
}): Promise<AppliedEnvironment | null>;
|
|
179
|
+
private readAppliedEnvironment;
|
|
180
|
+
/**
|
|
181
|
+
* A cloud instance's installed environment (B-15, Q1 option A): its current runtime report
|
|
182
|
+
* recorded with the kernel-built cloud identity (provider plugin and version, handle,
|
|
183
|
+
* generation, applied limits; `readCurrentReport`), named by that report's identity hash in
|
|
184
|
+
* place of a binding id. Null while the evidence is missing or stale, while desired limits wait
|
|
185
|
+
* for a file reset (`unapplied`) and while the applied limits are more permissive than the
|
|
186
|
+
* effective desired ones in any dimension (mode, network kind, a host the desired allowlist
|
|
187
|
+
* does not cover; spec §124): a pending desired change is never projected as installed. Applied
|
|
188
|
+
* limits narrower than desired stand (the outer boundary is the applied network, and restricted
|
|
189
|
+
* hosts are cut to it); the next use's lifecycle lease applies any change before admitting an
|
|
190
|
+
* operation, and its new limits change the identity, so that use records the evidence again.
|
|
191
|
+
*/
|
|
192
|
+
private cloudAppliedLocked;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* The outer boundary a cloud instance's applied network proves: public addresses, or its exact
|
|
196
|
+
* allowlist (empty: network disabled). Null when the allowlist cannot be stated as recorded
|
|
197
|
+
* context hosts (a host that is not a normalized authority host, or more than the cap).
|
|
198
|
+
*/
|
|
199
|
+
export declare function cloudOuterNetwork(network: DeviceNetwork): AppliedOuterNetwork | null;
|
|
200
|
+
/**
|
|
201
|
+
* Restricted hosts within a cloud instance's applied outer boundary (narrowing only): a host the
|
|
202
|
+
* outer allowlist does not cover cannot be reached, so neither admission nor the recorded context
|
|
203
|
+
* names it. A local device's host environment keeps every host.
|
|
204
|
+
*/
|
|
205
|
+
export declare function hostsWithinOuter(hosts: readonly string[], outer: AppliedOuterNetwork | undefined): string[];
|
|
206
|
+
export {};
|