@capybara-hq/kernel 0.1.0-rc.53 → 0.1.0-rc.55

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.
Files changed (190) hide show
  1. package/dist/admin/admin.schemas.d.ts +11 -1
  2. package/dist/catalog/catalog.module.js +1 -1
  3. package/dist/catalog/marketplaces.service.d.ts +1 -1
  4. package/dist/catalog/requests.service.d.ts +5 -5
  5. package/dist/catalog/requests.service.js +9 -9
  6. package/dist/channels/cards.d.ts +4 -3
  7. package/dist/channels/cards.js +25 -16
  8. package/dist/channels/phrases.d.ts +15 -4
  9. package/dist/channels/phrases.js +15 -1
  10. package/dist/config/load.d.ts +26 -7
  11. package/dist/config/load.js +60 -9
  12. package/dist/config/permission-migration.d.ts +17 -9
  13. package/dist/config/permission-migration.js +60 -9
  14. package/dist/config/schema.d.ts +15 -1
  15. package/dist/config/schema.js +66 -11
  16. package/dist/conversations/events.d.ts +247 -5
  17. package/dist/conversations/events.js +127 -16
  18. package/dist/conversations/permission-profiles.controller.d.ts +12 -2
  19. package/dist/conversations/permission-profiles.service.d.ts +12 -2
  20. package/dist/conversations/permission-profiles.service.js +11 -4
  21. package/dist/db/kernel-schema.d.ts +18 -2
  22. package/dist/devices/device-projects.service.d.ts +1 -1
  23. package/dist/devices/device-projects.service.js +6 -6
  24. package/dist/devices/devices.controller.d.ts +10 -8
  25. package/dist/devices/devices.controller.js +14 -18
  26. package/dist/devices/devices.schemas.d.ts +5 -5
  27. package/dist/devices/devices.schemas.js +5 -5
  28. package/dist/devices/devices.service.d.ts +188 -175
  29. package/dist/devices/devices.service.js +284 -292
  30. package/dist/devices/dto.d.ts +43 -23
  31. package/dist/devices/dto.js +45 -49
  32. package/dist/devices/project-rules.d.ts +0 -10
  33. package/dist/devices/project-rules.js +0 -5
  34. package/dist/errors.d.ts +43 -19
  35. package/dist/errors.js +43 -19
  36. package/dist/evals/reconstruct.d.ts +12 -3
  37. package/dist/evals/reconstruct.js +10 -6
  38. package/dist/evals/recorded-permission-context.d.ts +6 -4
  39. package/dist/evals/recorded-permission-context.js +15 -9
  40. package/dist/evals/run-replay.d.ts +6 -1
  41. package/dist/evals/run-replay.js +7 -2
  42. package/dist/evals/worker.js +3 -1
  43. package/dist/http/api.module.js +8 -0
  44. package/dist/http/app.js +9 -0
  45. package/dist/http/meta.controller.d.ts +33 -0
  46. package/dist/http/meta.controller.js +72 -0
  47. package/dist/identity/app-auth.controller.d.ts +25 -0
  48. package/dist/identity/app-auth.controller.js +64 -0
  49. package/dist/identity/app-auth.d.ts +66 -0
  50. package/dist/identity/app-auth.js +203 -0
  51. package/dist/identity/app-auth.schemas.d.ts +47 -0
  52. package/dist/identity/app-auth.schemas.js +43 -0
  53. package/dist/identity/identity.module.d.ts +1 -1
  54. package/dist/identity/identity.module.js +4 -1
  55. package/dist/identity/settings.d.ts +45 -18
  56. package/dist/identity/settings.js +151 -51
  57. package/dist/infra/config/kernel-config.service.d.ts +1 -1
  58. package/dist/infra/config/kernel-config.service.js +19 -5
  59. package/dist/infra/outbox/registry.d.ts +14 -0
  60. package/dist/infra/outbox/registry.js +15 -0
  61. package/dist/infra/throttler/named-throttlers.d.ts +3 -2
  62. package/dist/infra/throttler/named-throttlers.js +14 -2
  63. package/dist/local-devices/device-auth.controller.d.ts +1 -1
  64. package/dist/local-devices/device-auth.controller.js +1 -1
  65. package/dist/local-devices/device-auth.d.ts +4 -4
  66. package/dist/local-devices/device-auth.js +1 -1
  67. package/dist/local-devices/device-policy.service.d.ts +18 -9
  68. package/dist/local-devices/device-policy.service.js +21 -61
  69. package/dist/local-devices/device-routes.d.ts +3 -1
  70. package/dist/local-devices/device-routes.js +15 -4
  71. package/dist/local-devices/instance-bindings.js +5 -2
  72. package/dist/local-devices/local-device-gateway.d.ts +2 -2
  73. package/dist/local-devices/local-device-gateway.js +3 -3
  74. package/dist/local-devices/local-device-provider.d.ts +4 -4
  75. package/dist/local-devices/local-device-provider.js +23 -9
  76. package/dist/local-devices/local-devices.module.d.ts +1 -1
  77. package/dist/local-devices/local-devices.module.js +1 -1
  78. package/dist/local-devices/machines.d.ts +40 -16
  79. package/dist/local-devices/machines.js +89 -61
  80. package/dist/local-devices/owner-report.d.ts +16 -14
  81. package/dist/local-devices/owner-report.js +24 -30
  82. package/dist/local-devices/owner-reports.js +26 -8
  83. package/dist/local-devices/policy-summary.d.ts +25 -44
  84. package/dist/local-devices/policy-summary.js +26 -71
  85. package/dist/local-devices/relay.d.ts +6 -6
  86. package/dist/local-devices/relay.js +10 -8
  87. package/dist/net/public-address.d.ts +1 -1
  88. package/dist/net/public-address.js +5 -2
  89. package/dist/orgs/device-network-setting.d.ts +82 -0
  90. package/dist/orgs/device-network-setting.js +142 -0
  91. package/dist/orgs/settings.service.d.ts +103 -66
  92. package/dist/orgs/settings.service.js +201 -137
  93. package/dist/overrides.d.ts +5 -1
  94. package/dist/overrides.js +2 -0
  95. package/dist/platform/exclusions.js +24 -1
  96. package/dist/platform/operation.js +2 -2
  97. package/dist/platform/ops/admin.ops.js +20 -11
  98. package/dist/platform/ops/devices.ops.js +70 -5
  99. package/dist/platform/ops/org-settings.ops.js +10 -6
  100. package/dist/platform/ops/orgs.ops.js +2 -1
  101. package/dist/platform/ops/platform-icons.ops.d.ts +14 -0
  102. package/dist/platform/ops/platform-icons.ops.js +117 -0
  103. package/dist/platform/platform-ops.module.d.ts +2 -1
  104. package/dist/platform/platform-ops.module.js +3 -0
  105. package/dist/platform/route-schemas.js +3 -0
  106. package/dist/runtime/context/permission-profile.d.ts +17 -8
  107. package/dist/runtime/context/permission-profile.js +126 -45
  108. package/dist/runtime/maintenance.d.ts +5 -2
  109. package/dist/runtime/maintenance.js +15 -4
  110. package/dist/runtime/permission-context.service.d.ts +1 -1
  111. package/dist/runtime/permission-context.service.js +5 -3
  112. package/dist/runtime/project/knowledge.d.ts +5 -4
  113. package/dist/runtime/project/knowledge.js +2 -1
  114. package/dist/runtime/project/knowledge.service.js +16 -13
  115. package/dist/sandbox/cloud-permission-snapshot.js +22 -3
  116. package/dist/sandbox/device-sandbox-settings.d.ts +230 -0
  117. package/dist/sandbox/device-sandbox-settings.js +470 -0
  118. package/dist/sandbox/device-sandbox.d.ts +187 -0
  119. package/dist/sandbox/device-sandbox.js +236 -0
  120. package/dist/sandbox/held-operations.js +15 -7
  121. package/dist/sandbox/modes.d.ts +49 -24
  122. package/dist/sandbox/modes.js +27 -19
  123. package/dist/sandbox/operation-authority-types.d.ts +6 -5
  124. package/dist/sandbox/operation-authority-types.js +7 -8
  125. package/dist/sandbox/operation-authority.d.ts +23 -9
  126. package/dist/sandbox/operation-authority.js +179 -97
  127. package/dist/sandbox/permission-auto-grants.d.ts +42 -0
  128. package/dist/sandbox/permission-auto-grants.js +145 -0
  129. package/dist/sandbox/permission-call-grants.d.ts +12 -4
  130. package/dist/sandbox/permission-call-grants.js +84 -35
  131. package/dist/sandbox/permission-call-grants.module.js +10 -3
  132. package/dist/sandbox/permission-call-types.d.ts +39 -5
  133. package/dist/sandbox/permission-ceiling-writes.d.ts +29 -3
  134. package/dist/sandbox/permission-ceiling-writes.js +38 -4
  135. package/dist/sandbox/permission-config-publication.d.ts +44 -2
  136. package/dist/sandbox/permission-config-publication.js +230 -59
  137. package/dist/sandbox/permission-context-types.d.ts +2 -2
  138. package/dist/sandbox/permission-facts.d.ts +144 -15
  139. package/dist/sandbox/permission-facts.js +258 -70
  140. package/dist/sandbox/permission-runtime-reports.d.ts +5 -4
  141. package/dist/sandbox/permission-runtime-reports.js +19 -29
  142. package/dist/sandbox/review/classifier.d.ts +8 -0
  143. package/dist/sandbox/review/classifier.js +10 -0
  144. package/dist/sandbox/review/permission-candidate.d.ts +69 -5
  145. package/dist/sandbox/review/permission-candidate.js +153 -30
  146. package/dist/sandbox/review/review.service.d.ts +19 -3
  147. package/dist/sandbox/review/review.service.js +59 -11
  148. package/dist/sandbox/review/rules.js +23 -3
  149. package/dist/sandbox/sandbox.service.d.ts +29 -11
  150. package/dist/sandbox/sandbox.service.js +51 -26
  151. package/dist/skills/invoke.js +3 -2
  152. package/dist/themes/platform-icon-objects.d.ts +51 -0
  153. package/dist/themes/platform-icon-objects.js +113 -0
  154. package/dist/themes/platform-icon-public.controller.d.ts +17 -0
  155. package/dist/themes/platform-icon-public.controller.js +58 -0
  156. package/dist/themes/platform-icon.controller.d.ts +22 -0
  157. package/dist/themes/platform-icon.controller.js +65 -0
  158. package/dist/themes/platform-icon.schemas.d.ts +48 -0
  159. package/dist/themes/platform-icon.schemas.js +53 -0
  160. package/dist/themes/platform-icon.service.d.ts +83 -0
  161. package/dist/themes/platform-icon.service.js +301 -0
  162. package/dist/themes/themes.module.d.ts +4 -1
  163. package/dist/themes/themes.module.js +9 -4
  164. package/dist/tools/approvals.service.d.ts +26 -116
  165. package/dist/tools/approvals.service.js +42 -346
  166. package/dist/tools/builtins/sandbox/bash.d.ts +16 -3
  167. package/dist/tools/builtins/sandbox/bash.js +80 -28
  168. package/dist/tools/builtins/sandbox/common.d.ts +39 -14
  169. package/dist/tools/builtins/sandbox/common.js +47 -24
  170. package/dist/tools/builtins/sandbox/deliver.js +7 -4
  171. package/dist/tools/builtins/skill-load.d.ts +2 -2
  172. package/dist/tools/builtins/skill-load.js +4 -3
  173. package/dist/tools/device-op-resolver.d.ts +4 -10
  174. package/dist/tools/device-op-resolver.js +8 -19
  175. package/dist/tools/network-asks.d.ts +52 -15
  176. package/dist/tools/network-asks.js +55 -25
  177. package/dist/tools/pipeline.d.ts +26 -14
  178. package/dist/tools/pipeline.js +144 -61
  179. package/dist/tools/registry.d.ts +6 -0
  180. package/dist/tools/tools.module.js +1 -1
  181. package/package.json +4 -4
  182. package/src/migrations/0164_platform_icons.sql +10 -0
  183. package/src/migrations/0165_device_network_columns.sql +50 -0
  184. package/src/migrations/0166_permission_grant_full_access.sql +17 -0
  185. package/src/migrations/0167_device_network_backfill.sql +32 -0
  186. package/src/migrations/0168_binding_installed_connection.sql +6 -0
  187. package/dist/orgs/cloud-network-setting.d.ts +0 -33
  188. package/dist/orgs/cloud-network-setting.js +0 -47
  189. package/dist/sandbox/platform-full-access.d.ts +0 -110
  190. package/dist/sandbox/platform-full-access.js +0 -198
@@ -1,5 +1,8 @@
1
1
  import { type PermissionProfile } from "@capybara-hq/plugin-sdk";
2
- import type { PermissionCandidate, PermissionCandidateResult, PermissionEscalation, PermissionExpansion, PermissionReviewSnapshot } from "../permission-call-types.js";
2
+ import { type DeviceSandboxLayer } from "../device-sandbox.js";
3
+ import type { PermissionCandidate, PermissionCandidateResult, PermissionCrossingKind, PermissionEscalation, PermissionExpansion, PermissionReviewSnapshot } from "../permission-call-types.js";
4
+ export type { PermissionCrossingKind };
5
+ import type { ReviewFacts } from "./types.js";
3
6
  export declare const withinDirectory: (target: string, root: string) => boolean;
4
7
  /** Validate the exact presentation and its union with base authority; never truncate or widen. */
5
8
  export declare function normalizePermissionExpansion(value: PermissionExpansion, base: Pick<PermissionReviewSnapshot, "baseReadDirectories" | "baseWriteDirectories" | "baseHosts">): PermissionExpansion;
@@ -32,9 +35,25 @@ export declare const isEscalatedCall: (toolKey: string, input: unknown) => boole
32
35
  export declare const ESCALATION_JUSTIFICATION_MISSING_TEXT = "This Bash call asked to run outside the sandbox (sandbox: \"escalated\") without a justification, so it did not run. Retry with justification: one sentence saying why this command must run outside the sandbox, or call Bash without sandbox to run it in the sandbox.";
33
36
  /** Why an escalation cannot be reviewed: an unattended run (no one can approve it). */
34
37
  export declare const ESCALATION_UNATTENDED_WHY = "this is an unattended run (a scheduled task) where no one can approve running outside the sandbox";
35
- /** Why an escalation cannot be reviewed: the device, org or platform forbids Full access. */
36
- export declare const ESCALATION_CEILING_WHY = "running commands outside the sandbox is not allowed on this device (its owner, the organization or the platform has not allowed Full access)";
37
- /** Why an escalation cannot be reviewed: the runtime cannot run Full access now. */
38
+ /**
39
+ * Why an escalation cannot be reviewed because a layer's outside-sandbox setting is off: one text
40
+ * per layer that blocks it (`DeviceSandbox.layer.outsideSandbox`), each naming who lifts it and how.
41
+ */
42
+ export declare const ESCALATION_DEVICE_OFF_WHY = "running commands outside the sandbox is off on this device; its owner turns it on by running `capybara-device ceiling set --outside-sandbox on` on that machine";
43
+ export declare const ESCALATION_ORG_OFF_WHY = "running commands outside the sandbox is off in this organization; an organization admin can allow running outside the sandbox";
44
+ export declare const ESCALATION_PLATFORM_OFF_WHY = "running commands outside the sandbox is off on this platform; a super admin can allow running outside the sandbox";
45
+ export declare const ESCALATION_NO_OUTSIDE_WHY = "this device is a cloud instance that is itself the sandbox, so this device has no outside of its sandbox to run a command in";
46
+ /**
47
+ * The refusal text of an escalation that a layer's outside-sandbox setting blocks. A cloud device
48
+ * or an instance-boundary runtime has no outside at all, whichever layer is off; a local runtime
49
+ * that cannot run outside its sandbox is a runtime limit.
50
+ */
51
+ export declare const escalationCeilingWhy: (input: {
52
+ layer: DeviceSandboxLayer | null;
53
+ location: "local" | "cloud";
54
+ boundary: "operation" | "instance";
55
+ }) => string;
56
+ /** Why an escalation cannot be reviewed: the runtime cannot run a command outside its sandbox now. */
38
57
  export declare const escalationRuntimeWhy: (reason: string) => string;
39
58
  /** What the model gets when its escalated call cannot be reviewed, with what works instead. */
40
59
  export declare const escalationRefusedText: (why: string, workingRoot: string) => string;
@@ -43,7 +62,7 @@ export declare const escalationRefusedText: (why: string, workingRoot: string) =
43
62
  * it) when this device and org allow running outside the sandbox: the model may retry the same
44
63
  * call escalated, and the profile's approver decides.
45
64
  */
46
- export declare const ESCALATION_RETRY_HINT = " If this command must reach outside the sandbox, retry the same Bash call with sandbox: \"escalated\" and justification: one sentence saying why; the user or the review model decides whether it may run outside the sandbox for this call only.";
65
+ export declare const ESCALATION_RETRY_HINT = " If this command must reach outside the sandbox, retry the same Bash call with sandbox: \"escalated\" and justification: one sentence saying why; this conversation's permission profile decides whether it may run outside the sandbox for this call only (the user, the review model, or Full access within this device's limits).";
47
66
  /**
48
67
  * Who decides a boundary crossing (a per-call escalation, a directory or host proposal) under a
49
68
  * profile (2026-11-19 maintainer decision: the profiles are approval policy only): Request approval
@@ -52,6 +71,51 @@ export declare const ESCALATION_RETRY_HINT = " If this command must reach outsid
52
71
  */
53
72
  export type PermissionApprover = "person" | "review-model" | "none";
54
73
  export declare const approverForProfile: (profile: PermissionProfile) => PermissionApprover;
74
+ /**
75
+ * The sensitive-command consents that touch credentials (`ask.credential-*`, `ask.ssh`,
76
+ * `ask.secret-file`): an escalation carrying one is reviewed even under Full access.
77
+ */
78
+ export declare const isCredentialConsentRule: (rule: string) => boolean;
79
+ /**
80
+ * Whether a command carries a credential consent ({@link isCredentialConsentRule}) under the
81
+ * review rules, derived from the command itself: grant issuance re-derives it from the recorded
82
+ * call so a Full access auto-grant never covers a credential escalation, whatever the pipeline
83
+ * decided.
84
+ */
85
+ export declare const commandCarriesCredentialConsent: (command: string, facts: ReviewFacts) => boolean;
86
+ /**
87
+ * Who decides one crossing (approval-only profiles design, "Profiles"): {@link approverForProfile},
88
+ * except that an `outside-sandbox` escalation is never auto-granted when a sub-agent asks for it or
89
+ * when it carries a credential consent ({@link isCredentialConsentRule}): `none` becomes
90
+ * `review-model` (maintainer ruling 2026-11-19). Other sensitive consents (sudo, persistent
91
+ * changes) stay automatic under Full access and are recorded.
92
+ */
93
+ export declare function approverForCrossing(input: {
94
+ profile: PermissionProfile;
95
+ crossing: PermissionCrossingKind;
96
+ subAgent: boolean;
97
+ /** The call carries a credential consent (its rule hits; absent: none). */
98
+ credentialConsent?: boolean;
99
+ }): PermissionApprover;
100
+ /**
101
+ * The crossing a candidate asks for: running one call outside the sandbox, a directory outside the
102
+ * scope (also when hosts come with it), or a new host while the network is an allowlist.
103
+ */
104
+ export declare function crossingOfCandidate(candidate: Pick<PermissionCandidate, "scopeKind" | "permissionScope">): PermissionCrossingKind;
105
+ /**
106
+ * Why a write root is refused because it is, lies in or contains a system runtime or socket
107
+ * directory (`sandboxRuntimeDirectoryOf`: `/run`, `/var/run`, `/tmp` itself, `/dev`, ...), or null.
108
+ * The candidate builder never proposes such a root and admission refuses one in a grant: a socket
109
+ * another process made there would let a sandboxed command act outside the sandbox.
110
+ */
111
+ export declare function runtimeWriteRootRefusal(root: string, escalationRefusal?: string | null): string | null;
112
+ /**
113
+ * Why a per-call grant for `host` is unavailable under `facts`, naming who can add it, or null when
114
+ * it is grantable: the device sandbox's host ceiling (`device-sandbox.ts` `hostGrantRefusal`), the
115
+ * one rule the candidate builder, grant issuance and admission read. Facts without the ceiling
116
+ * (built outside admission) fall back to `policy.network`.
117
+ */
118
+ export declare function perCallHostRefusal(facts: PermissionReviewSnapshot, host: string): string | null;
55
119
  /**
56
120
  * Extract proposals from the actual validated call. Parsing proposes reach; it never grants it.
57
121
  * `homes` are the owner's home candidates (the machine's home, the workspace's home prefix): a
@@ -1,12 +1,13 @@
1
1
  import { isIP } from "node:net";
2
2
  import path from "node:path";
3
- import { DEVICE_DEFAULT_STATE_PATH, DEVICE_DENIED_SECRET_PATHS, validateAllowHost, } from "@capybara-hq/plugin-sdk";
3
+ import { DEVICE_DEFAULT_STATE_PATH, DEVICE_DENIED_SECRET_PATHS, isSandboxHomeWriteDenied, isSandboxWriteDenied, sandboxRuntimeDirectoryOf, validateAllowHost, } from "@capybara-hq/plugin-sdk";
4
4
  import { ApiError } from "../../errors.js";
5
5
  import { HIDDEN_FORMAT_RE } from "../../text.js";
6
6
  import { generateImagePaths } from "../../tools/builtins/image/paths.js";
7
+ import { hostGrantable } from "../device-sandbox.js";
7
8
  import { coversHost } from "../modes.js";
8
9
  import { hostsWithinOuter, permissionScopeHash } from "../permission-facts.js";
9
- import { parseCommand } from "./rules.js";
10
+ import { parseCommand, reviewRules } from "./rules.js";
10
11
  export const withinDirectory = (target, root) => target === root || target.startsWith(root === "/" ? "/" : `${root}/`);
11
12
  const sorted = (items) => [...new Set(items)].sort();
12
13
  function directory(value) {
@@ -84,23 +85,88 @@ export const isEscalatedCall = (toolKey, input) => toolKey === "Bash" &&
84
85
  export const ESCALATION_JUSTIFICATION_MISSING_TEXT = 'This Bash call asked to run outside the sandbox (sandbox: "escalated") without a justification, so it did not run. Retry with justification: one sentence saying why this command must run outside the sandbox, or call Bash without sandbox to run it in the sandbox.';
85
86
  /** Why an escalation cannot be reviewed: an unattended run (no one can approve it). */
86
87
  export const ESCALATION_UNATTENDED_WHY = "this is an unattended run (a scheduled task) where no one can approve running outside the sandbox";
87
- /** Why an escalation cannot be reviewed: the device, org or platform forbids Full access. */
88
- export const ESCALATION_CEILING_WHY = "running commands outside the sandbox is not allowed on this device (its owner, the organization or the platform has not allowed Full access)";
89
- /** Why an escalation cannot be reviewed: the runtime cannot run Full access now. */
88
+ /**
89
+ * Why an escalation cannot be reviewed because a layer's outside-sandbox setting is off: one text
90
+ * per layer that blocks it (`DeviceSandbox.layer.outsideSandbox`), each naming who lifts it and how.
91
+ */
92
+ export const ESCALATION_DEVICE_OFF_WHY = "running commands outside the sandbox is off on this device; its owner turns it on by running `capybara-device ceiling set --outside-sandbox on` on that machine";
93
+ export const ESCALATION_ORG_OFF_WHY = "running commands outside the sandbox is off in this organization; an organization admin can allow running outside the sandbox";
94
+ export const ESCALATION_PLATFORM_OFF_WHY = "running commands outside the sandbox is off on this platform; a super admin can allow running outside the sandbox";
95
+ export const ESCALATION_NO_OUTSIDE_WHY = "this device is a cloud instance that is itself the sandbox, so this device has no outside of its sandbox to run a command in";
96
+ /**
97
+ * The refusal text of an escalation that a layer's outside-sandbox setting blocks. A cloud device
98
+ * or an instance-boundary runtime has no outside at all, whichever layer is off; a local runtime
99
+ * that cannot run outside its sandbox is a runtime limit.
100
+ */
101
+ export const escalationCeilingWhy = (input) => {
102
+ if (input.location === "cloud" || input.boundary === "instance")
103
+ return ESCALATION_NO_OUTSIDE_WHY;
104
+ switch (input.layer) {
105
+ case "platform":
106
+ return ESCALATION_PLATFORM_OFF_WHY;
107
+ case "org":
108
+ return ESCALATION_ORG_OFF_WHY;
109
+ case "provider":
110
+ return escalationRuntimeWhy("This device's runtime cannot run a command outside its sandbox");
111
+ default:
112
+ return ESCALATION_DEVICE_OFF_WHY;
113
+ }
114
+ };
115
+ /** Why an escalation cannot be reviewed: the runtime cannot run a command outside its sandbox now. */
90
116
  export const escalationRuntimeWhy = (reason) => `this device cannot run commands outside its sandbox now (${reason.replace(/\.$/, "")})`;
91
117
  /** What the model gets when its escalated call cannot be reviewed, with what works instead. */
92
- export const escalationRefusedText = (why, workingRoot) => `This Bash call asked to run outside the sandbox, but ${why}, so it did not run. Call Bash without sandbox: "escalated" to run the command inside the sandbox (inside ${workingRoot} and the directories already granted), or ask the user to run it themselves or to allow Full access on this device.`;
118
+ export const escalationRefusedText = (why, workingRoot) => `This Bash call asked to run outside the sandbox, but ${why}, so it did not run. Call Bash without sandbox: "escalated" to run the command inside the sandbox (inside ${workingRoot} and the directories already granted), or ask the user to run it themselves.`;
93
119
  /**
94
120
  * Appended to a refusal of a restricted `Bash` call (the sandbox or the restricted scope stopped
95
121
  * it) when this device and org allow running outside the sandbox: the model may retry the same
96
122
  * call escalated, and the profile's approver decides.
97
123
  */
98
- export const ESCALATION_RETRY_HINT = ' If this command must reach outside the sandbox, retry the same Bash call with sandbox: "escalated" and justification: one sentence saying why; the user or the review model decides whether it may run outside the sandbox for this call only.';
124
+ export const ESCALATION_RETRY_HINT = ` If this command must reach outside the sandbox, retry the same Bash call with sandbox: "escalated" and justification: one sentence saying why; this conversation's permission profile decides whether it may run outside the sandbox for this call only (the user, the review model, or Full access within this device's limits).`;
99
125
  export const approverForProfile = (profile) => profile === "request-approval"
100
126
  ? "person"
101
127
  : profile === "approve-for-me"
102
128
  ? "review-model"
103
129
  : "none";
130
+ /**
131
+ * The sensitive-command consents that touch credentials (`ask.credential-*`, `ask.ssh`,
132
+ * `ask.secret-file`): an escalation carrying one is reviewed even under Full access.
133
+ */
134
+ export const isCredentialConsentRule = (rule) => rule.startsWith("ask.credential-") || rule === "ask.ssh" || rule === "ask.secret-file";
135
+ /**
136
+ * Whether a command carries a credential consent ({@link isCredentialConsentRule}) under the
137
+ * review rules, derived from the command itself: grant issuance re-derives it from the recorded
138
+ * call so a Full access auto-grant never covers a credential escalation, whatever the pipeline
139
+ * decided.
140
+ */
141
+ export const commandCarriesCredentialConsent = (command, facts) => reviewRules(command, facts).hits.some((hit) => hit.outcome === "ask" && isCredentialConsentRule(hit.id));
142
+ /**
143
+ * Who decides one crossing (approval-only profiles design, "Profiles"): {@link approverForProfile},
144
+ * except that an `outside-sandbox` escalation is never auto-granted when a sub-agent asks for it or
145
+ * when it carries a credential consent ({@link isCredentialConsentRule}): `none` becomes
146
+ * `review-model` (maintainer ruling 2026-11-19). Other sensitive consents (sudo, persistent
147
+ * changes) stay automatic under Full access and are recorded.
148
+ */
149
+ export function approverForCrossing(input) {
150
+ const approver = approverForProfile(input.profile);
151
+ // only the person or the review model approves these escalations, never the agent tree itself
152
+ return approver === "none" &&
153
+ input.crossing === "outside-sandbox" &&
154
+ (input.subAgent || input.credentialConsent === true)
155
+ ? "review-model"
156
+ : approver;
157
+ }
158
+ /**
159
+ * The crossing a candidate asks for: running one call outside the sandbox, a directory outside the
160
+ * scope (also when hosts come with it), or a new host while the network is an allowlist.
161
+ */
162
+ export function crossingOfCandidate(candidate) {
163
+ if (candidate.scopeKind === "sandbox-escalation")
164
+ return "outside-sandbox";
165
+ return candidate.permissionScope.readDirectories.length > 0 ||
166
+ candidate.permissionScope.writeDirectories.length > 0
167
+ ? "directory"
168
+ : "host";
169
+ }
104
170
  /** The paths a local device never opens to restricted work, relative to `~`. */
105
171
  const OWNER_DENIED_PATHS = [...DEVICE_DENIED_SECRET_PATHS, DEVICE_DEFAULT_STATE_PATH];
106
172
  /**
@@ -114,7 +180,26 @@ function ownerDeniedPath(target, homes) {
114
180
  return denied;
115
181
  return undefined;
116
182
  }
117
- const ownerDeniedText = (denied, target) => `${target} is under ${denied}, which the device never opens to this conversation's permission profile (a credential location or the device's own state), so this call cannot be approved and did not run. Ask the user to provide what is needed from it, or to choose Full access for this conversation if it must be used there.`;
183
+ /** How a protected location is still reached: only a Bash call run outside the sandbox, if allowed. */
184
+ const protectedReach = (escalationRefusal) => escalationRefusal
185
+ ? ` Running a command outside the sandbox is not possible here (${escalationRefusal}).`
186
+ : ' If it must be used, only a Bash call run outside the sandbox (sandbox: "escalated" with a justification) can reach it, for that call only and as this conversation\'s permission profile decides.';
187
+ const ownerDeniedText = (denied, target, escalationRefusal) => `${target} is under ${denied}, which the device never opens to sandboxed work (a credential location or the device's own state), so this call cannot be approved and did not run. Ask the user to provide what is needed from it.${protectedReach(escalationRefusal)}`;
188
+ const protectedWriteText = (target, escalationRefusal) => `${target} is a protected location the sandbox never writes (shell startup files, git hooks and configuration, and the places the system runs programs from later), so no directory approval covers it and this call did not run. Keep the change inside the project, or ask the user to make it.${protectedReach(escalationRefusal)}`;
189
+ const runtimeDirectoryText = (target, hit, escalationRefusal) => `${target} is a system runtime or socket directory (${hit}), where other programs keep their sockets, so no directory approval covers it and this call did not run. Use a path inside the project, or a directory of its own such as /tmp/<name>/ (never /tmp itself).${protectedReach(escalationRefusal)}`;
190
+ /**
191
+ * Why a write root is refused because it is, lies in or contains a system runtime or socket
192
+ * directory (`sandboxRuntimeDirectoryOf`: `/run`, `/var/run`, `/tmp` itself, `/dev`, ...), or null.
193
+ * The candidate builder never proposes such a root and admission refuses one in a grant: a socket
194
+ * another process made there would let a sandboxed command act outside the sandbox.
195
+ */
196
+ export function runtimeWriteRootRefusal(root, escalationRefusal) {
197
+ const hit = sandboxRuntimeDirectoryOf(root);
198
+ return hit === null ? null : runtimeDirectoryText(root, hit, escalationRefusal);
199
+ }
200
+ /** A refusal of a protected location: never proposed, and its text already names the escalation. */
201
+ class ProtectedPathError extends Error {
202
+ }
118
203
  /**
119
204
  * A background escalation's disclosure: it starts a process that keeps running outside the
120
205
  * sandbox until it exits or is stopped, at most the task's deadline (the requested timeout
@@ -133,6 +218,23 @@ function backgroundOf(input, maxSeconds) {
133
218
  maxSeconds: Math.max(1, Math.ceil(Math.min(requested, maxMs) / 1000)),
134
219
  };
135
220
  }
221
+ /**
222
+ * Why a per-call grant for `host` is unavailable under `facts`, naming who can add it, or null when
223
+ * it is grantable: the device sandbox's host ceiling (`device-sandbox.ts` `hostGrantRefusal`), the
224
+ * one rule the candidate builder, grant issuance and admission read. Facts without the ceiling
225
+ * (built outside admission) fall back to `policy.network`.
226
+ */
227
+ export function perCallHostRefusal(facts, host) {
228
+ if (facts.hostRefusal)
229
+ return facts.hostRefusal(host);
230
+ if ((facts.network ?? "none") === "none")
231
+ return "network access is turned off for this device's sandbox";
232
+ const grantable = facts.hostCeiling
233
+ ? hostGrantable(facts.hostCeiling, host)
234
+ : facts.policy.network.kind === "open-public" ||
235
+ facts.policy.network.hosts.some((pattern) => coversHost(pattern, host));
236
+ return grantable ? null : "it is beyond the device's network limits";
237
+ }
136
238
  /** The exact call binding of a candidate: server identity from the facts, the call's own digests. */
137
239
  function bindingOf(call, facts) {
138
240
  return {
@@ -165,23 +267,20 @@ export function buildPermissionCandidate(call, facts, homes = [], opts = {}) {
165
267
  const refuseDenied = (target) => {
166
268
  const denied = ownerDeniedPath(target, homeRoots);
167
269
  if (denied)
168
- throw new Error(ownerDeniedText(denied, target));
270
+ throw new ProtectedPathError(ownerDeniedText(denied, target, facts.escalationRefusal));
271
+ };
272
+ // a write proposal never covers a location the sandbox refuses to write (the persistence
273
+ // vectors, git internals): no approval could make it run inside the sandbox
274
+ const refuseWriteDenied = (target) => {
275
+ if (isSandboxWriteDenied(target) ||
276
+ homeRoots.some((home) => isSandboxHomeWriteDenied(target, home)))
277
+ throw new ProtectedPathError(protectedWriteText(target, facts.escalationRefusal));
169
278
  };
170
279
  const input = call.validatedInput;
171
280
  // a per-call sandbox escalation: one Bash call with full execution, never a directory or host
172
- // expansion; Full access already runs every call that way, so there it asks for nothing more
281
+ // expansion. Every profile proposes it: the profile only chooses who approves it (Full access
282
+ // grants it within the device's outside-sandbox ceiling, recorded and audited)
173
283
  if (isEscalatedCall(call.toolKey, input)) {
174
- // no approver (Full access): granted for this call within the ceiling, never past it. Full
175
- // access runs every call outside the sandbox today, so there is no grant to issue (until the
176
- // profile-semantics refactor keeps the sandbox under every profile)
177
- if (approverForProfile(facts.profile) === "none")
178
- return facts.escalationRefusal
179
- ? {
180
- kind: "unsupported",
181
- code: "escalation-unavailable",
182
- message: escalationRefusedText(facts.escalationRefusal, facts.workingRoot),
183
- }
184
- : { kind: "in-scope" };
185
284
  const justification = input.justification;
186
285
  if (typeof justification !== "string" || justification.trim() === "")
187
286
  return {
@@ -218,8 +317,15 @@ export function buildPermissionCandidate(call, facts, homes = [], opts = {}) {
218
317
  const normalized = directory(path.posix.resolve(facts.workingRoot, value));
219
318
  refuseDenied(normalized);
220
319
  const base = write ? facts.baseWriteDirectories : facts.baseReadDirectories;
221
- if (!base.some((root) => withinDirectory(normalized, root)))
320
+ if (!base.some((root) => withinDirectory(normalized, root))) {
321
+ if (write) {
322
+ refuseWriteDenied(normalized);
323
+ const runtime = runtimeWriteRootRefusal(normalized, facts.escalationRefusal);
324
+ if (runtime)
325
+ throw new ProtectedPathError(runtime);
326
+ }
222
327
  (write ? writes : reads).push(normalized);
328
+ }
223
329
  };
224
330
  // the paths a file call names: `file_path`, or every path a `GenerateImage` call writes into the
225
331
  // device (none without `file_path`; the suffixed paths of several images), each judged
@@ -244,6 +350,8 @@ export function buildPermissionCandidate(call, facts, homes = [], opts = {}) {
244
350
  refuseDenied(target);
245
351
  for (const target of resolved) {
246
352
  if (!base.some((root) => withinDirectory(target, root))) {
353
+ if (write)
354
+ refuseWriteDenied(target);
247
355
  proposeDirectory(path.posix.dirname(target), write);
248
356
  }
249
357
  }
@@ -253,16 +361,24 @@ export function buildPermissionCandidate(call, facts, homes = [], opts = {}) {
253
361
  throw new Error("Invalid target path");
254
362
  }
255
363
  else if (call.toolKey === "Bash" && typeof input?.command === "string") {
364
+ // a host is a crossing only while the sandbox network is not the open one: the open network
365
+ // already reaches every public host, and private ones only outside the sandbox
366
+ const allowlist = facts.network !== "open-public";
256
367
  const parsed = parseCommand(input.command);
257
368
  for (const command of parsed?.commands ?? []) {
258
369
  if (command.argv[0] === "cd" && command.argv.length === 2 && command.argv[1])
259
370
  proposeDirectory(command.argv[1], true);
260
371
  for (const word of command.argv) {
261
- if (!/^https?:\/\//i.test(word))
372
+ if (!allowlist || !/^https?:\/\//i.test(word))
262
373
  continue;
263
374
  const url = new URL(word);
264
- // an IP literal is no grantable host: nothing is proposed, the enforced network decides
265
- if (isIP(url.hostname.replace(/^\[|\]$/g, "")) !== 0)
375
+ // an IP literal or a loopback name is no grantable host (no per-call private endpoint
376
+ // grants): nothing is proposed, the enforced network decides and only running outside
377
+ // the sandbox reaches a private address
378
+ const hostname = url.hostname.toLowerCase().replace(/\.$/, "");
379
+ if (isIP(hostname.replace(/^\[|\]$/g, "")) !== 0 ||
380
+ hostname === "localhost" ||
381
+ hostname.endsWith(".localhost"))
266
382
  continue;
267
383
  if (url.username ||
268
384
  url.password ||
@@ -281,14 +397,19 @@ export function buildPermissionCandidate(call, facts, homes = [], opts = {}) {
281
397
  if (!reads.length && !writes.length && !hosts.length)
282
398
  return { kind: "in-scope" };
283
399
  const permissionScope = normalizePermissionExpansion({ readDirectories: reads, writeDirectories: writes, hosts }, facts);
284
- if ((!facts.broadProjectReach && (reads.length || writes.length)) ||
285
- hosts.some((host) => facts.policy.network.kind !== "open-public" &&
286
- !facts.policy.network.hosts.some((pattern) => coversHost(pattern, host))))
400
+ if (!facts.broadProjectReach && (reads.length || writes.length))
287
401
  throw new Error(`This call needs access outside the working directory ${facts.workingRoot} (${[
288
402
  ...writes,
289
403
  ...reads,
290
- ...hosts,
291
- ].join(", ")}), which the device owner's or the organization's limits do not allow, so it did not run. Keep the call inside ${facts.workingRoot}, or ask the user to have the device's limits widened.`);
404
+ ].join(", ")}), which the device owner's limits do not allow, so it did not run. Keep the call inside ${facts.workingRoot}, or ask the user to have the device's limits widened.`);
405
+ // a host beyond the per-call host ceiling is never proposed (so never auto-granted): the reply
406
+ // names who can add it
407
+ const refused = hosts.flatMap((host) => {
408
+ const why = perCallHostRefusal(facts, host);
409
+ return why ? [`${host}: ${why}`] : [];
410
+ });
411
+ if (refused.length)
412
+ throw new Error(`This call needs network access this device's sandbox cannot be granted per call, so it did not run (${refused.join("; ")}). Run it without those hosts, or ask the user to have the host added.`);
292
413
  const candidate = {
293
414
  binding: bindingOf(call, facts),
294
415
  permissionScope,
@@ -301,6 +422,8 @@ export function buildPermissionCandidate(call, facts, homes = [], opts = {}) {
301
422
  };
302
423
  }
303
424
  catch (error) {
425
+ if (error instanceof ProtectedPathError)
426
+ return { kind: "unsupported", code: "protected-path", message: error.message };
304
427
  return {
305
428
  kind: "unsupported",
306
429
  code: "unbounded-scope",
@@ -7,7 +7,8 @@ import { KernelDb } from "../../infra/database/kernel-db.js";
7
7
  import { ModelPurposesService } from "../../models/purposes.js";
8
8
  import type { ConversationKindForHooks } from "../../runtime/hook-calls.js";
9
9
  import { StepLog } from "../../runtime/step-log.js";
10
- import type { PermissionCandidate } from "../permission-call-types.js";
10
+ import type { PermissionCandidate, PermissionCrossingKind } from "../permission-call-types.js";
11
+ import { type PermissionApprover } from "./permission-candidate.js";
11
12
  export { escalationAskReason, quotedJustification } from "./permission-candidate.js";
12
13
  /**
13
14
  * The command review the tool pipeline calls (auto mode spec §5): stage 1 the pure rule table, stage
@@ -26,6 +27,19 @@ export interface ReviewVerdict {
26
27
  reason: string;
27
28
  /** The rule the decision came from, or null for a classifier decision. */
28
29
  rule: string | null;
30
+ /**
31
+ * The crossing a Full access allow granted by itself (approval-only profiles design): the
32
+ * candidate's kind, or `sensitive` when it skipped a sensitive-command consent; also `sensitive`
33
+ * when the review model allowed a sensitive command. Absent otherwise.
34
+ */
35
+ crossing?: PermissionCrossingKind;
36
+ /**
37
+ * Who decided the permission review of a call with a candidate: the person, the review model
38
+ * or nobody (Full access). Absent outside the permission review.
39
+ */
40
+ approver?: PermissionApprover;
41
+ /** The sensitive-command consents (rule ids) a Full access allow skipped. */
42
+ sensitive?: string[];
29
43
  }
30
44
  /** What the pipeline knows about one tool call it reviews. */
31
45
  export interface ReviewInput {
@@ -123,8 +137,10 @@ export declare class CommandReviewService implements CommandReview {
123
137
  review(input: ReviewInput & ReviewCall): Promise<ReviewVerdict>;
124
138
  /**
125
139
  * The permission review of a managed call (permission operation contract, policy order), after
126
- * the fixed denies: Full access has no discretionary review; Request approval and Approve for me
127
- * keep the sensitive-command consent (the fixed asks: sudo, credentials, persistent changes,
140
+ * the fixed denies. The profile only chooses who approves ({@link approverForCrossing}): under
141
+ * Full access nobody does (the candidate's crossing is granted within the device's ceilings, a
142
+ * sensitive-command consent is skipped, both recorded), except a sub-agent's escalation, which
143
+ * goes to the review model. Request approval and Approve for me keep the sensitive-command consent (the fixed asks: sudo, credentials, persistent changes,
128
144
  * force push, ...), which comes before any reach. A call with neither a consent ask nor a
129
145
  * proposed expansion runs under the enforced base scope with no review. Otherwise Request
130
146
  * approval asks the person and Approve for me asks the review model (an ask when it is not
@@ -17,7 +17,7 @@ import { ModelPurposesService } from "../../models/purposes.js";
17
17
  import { StepLog } from "../../runtime/step-log.js";
18
18
  import { generateImagePaths } from "../../tools/builtins/image/paths.js";
19
19
  import { boundMessages, newReviewTag, REVIEW_ASK_REASON, REVIEW_PURPOSE, runClassifier, } from "./classifier.js";
20
- import { approverForProfile, ESCALATION_RETRY_HINT, escalationAskReason, } from "./permission-candidate.js";
20
+ import { approverForCrossing, crossingOfCandidate, ESCALATION_RETRY_HINT, escalationAskReason, isCredentialConsentRule, } from "./permission-candidate.js";
21
21
  export { escalationAskReason, quotedJustification } from "./permission-candidate.js";
22
22
  import { reviewRules, reviewWrite, writtenPaths } from "./rules.js";
23
23
  import { applySessionGrants, isSessionGrantableRule, } from "./types.js";
@@ -126,8 +126,10 @@ let CommandReviewService = class CommandReviewService {
126
126
  }
127
127
  /**
128
128
  * The permission review of a managed call (permission operation contract, policy order), after
129
- * the fixed denies: Full access has no discretionary review; Request approval and Approve for me
130
- * keep the sensitive-command consent (the fixed asks: sudo, credentials, persistent changes,
129
+ * the fixed denies. The profile only chooses who approves ({@link approverForCrossing}): under
130
+ * Full access nobody does (the candidate's crossing is granted within the device's ceilings, a
131
+ * sensitive-command consent is skipped, both recorded), except a sub-agent's escalation, which
132
+ * goes to the review model. Request approval and Approve for me keep the sensitive-command consent (the fixed asks: sudo, credentials, persistent changes,
131
133
  * force push, ...), which comes before any reach. A call with neither a consent ask nor a
132
134
  * proposed expansion runs under the enforced base scope with no review. Otherwise Request
133
135
  * approval asks the person and Approve for me asks the review model (an ask when it is not
@@ -136,11 +138,6 @@ let CommandReviewService = class CommandReviewService {
136
138
  * and without one the enforced scope decides. An ask keeps its rule id.
137
139
  */
138
140
  async decidePermission(input, result, facts) {
139
- // no approver (Full access): nothing discretionary is asked; a crossing the candidate names is
140
- // granted for this call within the ceiling the candidate builder already checked
141
- const approver = approverForProfile(input.permissionProfile ?? "approve-for-me");
142
- if (approver === "none")
143
- return allow("Current Full access covers discretionary review.", null);
144
141
  const escalation = input.permissionCandidate?.scopeKind === "sandbox-escalation"
145
142
  ? input.permissionCandidate.escalation
146
143
  : undefined;
@@ -163,6 +160,46 @@ let CommandReviewService = class CommandReviewService {
163
160
  const consentHits = result.hits.filter((h) => facts.kind === "read"
164
161
  ? h.outcome === "ask" && CREDENTIAL_READ_RULES.has(h.id)
165
162
  : (h.outcome === "ask" && !SCOPE_ASK_RULES.has(h.id)) || h.outcome === "unsure");
163
+ const candidate = input.permissionCandidate;
164
+ const subAgent = input.parentRunId !== undefined;
165
+ const credentialConsent = consentHits.some((h) => isCredentialConsentRule(h.id));
166
+ // who decides (approval-only profiles design, "Profiles"): under Full access an escalation a
167
+ // sub-agent asks for, or one carrying a credential consent, goes to the review model; the fixed
168
+ // denies were evaluated before this
169
+ const approver = approverForCrossing({
170
+ profile: input.permissionProfile ?? "approve-for-me",
171
+ crossing: candidate ? crossingOfCandidate(candidate) : "sensitive",
172
+ subAgent,
173
+ credentialConsent,
174
+ });
175
+ // why the review model sees a Full access call at all (its input says so, neutrally)
176
+ const fullAccessReview = input.permissionProfile === "full-access" && approver === "review-model"
177
+ ? {
178
+ ...(subAgent ? { subAgent: true } : {}),
179
+ ...(credentialConsent ? { credential: true } : {}),
180
+ }
181
+ : undefined;
182
+ if (approver === "none") {
183
+ // Full access: the candidate's crossing is granted for this call within the ceilings the
184
+ // candidate builder checked (issuance checks them again), and a sensitive-command consent
185
+ // is skipped but recorded (with the crossing when there is one): the sandbox still holds
186
+ // the protected paths
187
+ const skipped = [...new Set(consentHits.map((h) => h.id))].sort();
188
+ if (candidate)
189
+ return {
190
+ ...allow("Full access grants this crossing within the device's limits.", consentHits[0]?.id ?? null),
191
+ crossing: crossingOfCandidate(candidate),
192
+ approver,
193
+ ...(skipped.length > 0 ? { sensitive: skipped } : {}),
194
+ };
195
+ const consentHit = consentHits[0];
196
+ if (consentHit)
197
+ return {
198
+ ...allow("Full access runs this sensitive command without asking; the sandbox still applies.", consentHit.id),
199
+ crossing: "sensitive",
200
+ };
201
+ return allow("The enforced operation scope covers this call without expansion.", null);
202
+ }
166
203
  let consent;
167
204
  let granted;
168
205
  if (consentHits.length > 0) {
@@ -177,7 +214,6 @@ let CommandReviewService = class CommandReviewService {
177
214
  else
178
215
  granted = after.hit;
179
216
  }
180
- const candidate = input.permissionCandidate;
181
217
  if (!consent && !candidate) {
182
218
  if (granted)
183
219
  return allow(REVIEW_REASONS.sessionGrant, granted.id);
@@ -196,7 +232,7 @@ let CommandReviewService = class CommandReviewService {
196
232
  ? escalationAskReason(escalation, consent?.reason)
197
233
  : (consent?.reason ??
198
234
  (scopeHit?.reason ? `${scopeHit.reason} ${EXPANSION_ASK_REASON}` : EXPANSION_ASK_REASON));
199
- const ask = { decision: "ask", by: "rule", rule, reason };
235
+ const ask = { decision: "ask", by: "rule", rule, reason, approver };
200
236
  if (approver === "person")
201
237
  return ask;
202
238
  if (!(await this.classifierMapped(input.orgId)))
@@ -235,6 +271,7 @@ let CommandReviewService = class CommandReviewService {
235
271
  personMessages: await this.personMessages(await facts.rootOf()),
236
272
  tag: newReviewTag(),
237
273
  ...(candidate ? { permissionCandidate: candidate } : {}),
274
+ ...(fullAccessReview ? { fullAccessReview } : {}),
238
275
  },
239
276
  beforeSend: input.beforeSend,
240
277
  });
@@ -245,7 +282,18 @@ let CommandReviewService = class CommandReviewService {
245
282
  by: "classifier",
246
283
  reason: escalation ? withEscalation(reason, answer.reason) : answer.reason,
247
284
  };
248
- return { decision: answer.decision, by: "classifier", reason: answer.reason, rule: null };
285
+ return {
286
+ decision: answer.decision,
287
+ by: "classifier",
288
+ reason: answer.reason,
289
+ rule: null,
290
+ approver,
291
+ // a sensitive command the review model allowed is recorded as that crossing, as a Full
292
+ // access skip is
293
+ ...(answer.decision === "allow" && !candidate && consent
294
+ ? { crossing: "sensitive" }
295
+ : {}),
296
+ };
249
297
  }
250
298
  async decide(input) {
251
299
  // not a reviewed tool, a sandbox-mode write (the tools stay root-confined), or no device: the
@@ -1238,11 +1238,16 @@ function isPersistenceForm(t, facts) {
1238
1238
  "/etc/profile",
1239
1239
  "/etc/bashrc",
1240
1240
  "/etc/bash.bashrc",
1241
+ "/etc/bash.bash_logout",
1241
1242
  "/etc/zshrc",
1242
1243
  "/etc/zshenv",
1244
+ "/etc/zprofile",
1245
+ "/etc/zlogin",
1246
+ "/etc/zlogout",
1243
1247
  "/etc/paths",
1244
1248
  ].includes(t) ||
1245
- t.startsWith("/etc/profile.d/")) {
1249
+ t.startsWith("/etc/profile.d/") ||
1250
+ t.startsWith("/etc/zsh/")) {
1246
1251
  return true;
1247
1252
  }
1248
1253
  if (t === "/etc/crontab" || t.startsWith("/var/spool/cron") || t.startsWith("/etc/cron."))
@@ -4114,8 +4119,23 @@ function isRunLaterHomePath(t, facts) {
4114
4119
  return (under("~/capybara-device") &&
4115
4120
  !foldedForms(facts.workspace, facts).some((w) => w.startsWith("~/capybara-device/")));
4116
4121
  }
4117
- /** PATH shims and desktop autostart entries in the home (case-folded). */
4118
- const RUN_LATER_HOME_DIRS = ["~/.local/bin", "~/bin", "~/.cargo/bin", "~/.config/autostart"];
4122
+ /**
4123
+ * PATH shims, desktop autostart entries (XDG and KDE), the X session files, the session environment
4124
+ * (`environment.d`, KDE's `plasma-workspace/env`) and user systemd data in the home (case-folded):
4125
+ * the persistence vectors the sandbox write denies name (`SANDBOX_MANDATORY_WRITE_DENIES`).
4126
+ */
4127
+ const RUN_LATER_HOME_DIRS = [
4128
+ "~/.local/bin",
4129
+ "~/bin",
4130
+ "~/.cargo/bin",
4131
+ "~/.config/autostart",
4132
+ "~/.config/autostart-scripts",
4133
+ "~/.config/plasma-workspace/env",
4134
+ "~/.config/environment.d",
4135
+ "~/.local/share/systemd",
4136
+ "~/.xprofile",
4137
+ "~/.xsessionrc",
4138
+ ];
4119
4139
  /** The grant class of a secret or persistence path (judged on every case-folded home spelling). */
4120
4140
  function configClassOf(path, facts) {
4121
4141
  const forms = foldedForms(path, facts);