@capybara-hq/kernel 0.1.0-rc.49 → 0.1.0-rc.50

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 (128) hide show
  1. package/dist/admin/admin.schemas.d.ts +0 -6
  2. package/dist/background/launch.d.ts +7 -61
  3. package/dist/background/launch.js +8 -133
  4. package/dist/background/poll.job.d.ts +19 -23
  5. package/dist/background/poll.job.js +30 -66
  6. package/dist/background/render.d.ts +9 -0
  7. package/dist/background/render.js +19 -0
  8. package/dist/background/session.d.ts +3 -66
  9. package/dist/background/session.js +3 -114
  10. package/dist/background/stop.d.ts +26 -33
  11. package/dist/background/stop.js +59 -90
  12. package/dist/background/store.d.ts +26 -60
  13. package/dist/background/store.js +23 -108
  14. package/dist/background/tasks.service.d.ts +9 -29
  15. package/dist/background/tasks.service.js +18 -115
  16. package/dist/catalog/marketplaces.service.d.ts +1 -1
  17. package/dist/channels/cards.d.ts +3 -0
  18. package/dist/channels/cards.js +29 -2
  19. package/dist/channels/phrases.d.ts +35 -0
  20. package/dist/channels/phrases.js +32 -0
  21. package/dist/config/load.d.ts +3 -10
  22. package/dist/config/load.js +26 -21
  23. package/dist/config/schema.js +3 -3
  24. package/dist/conversations/events.d.ts +45 -2
  25. package/dist/conversations/events.js +44 -4
  26. package/dist/db/kernel-schema.d.ts +9 -4
  27. package/dist/devices/devices.service.js +1 -1
  28. package/dist/devices/errors.d.ts +5 -0
  29. package/dist/devices/errors.js +5 -0
  30. package/dist/devices/project-rules.d.ts +2 -2
  31. package/dist/errors.d.ts +9 -11
  32. package/dist/errors.js +9 -11
  33. package/dist/identity/settings.d.ts +4 -17
  34. package/dist/identity/settings.js +9 -32
  35. package/dist/infra/config/kernel-config.service.js +2 -9
  36. package/dist/infra/outbox/registry.d.ts +13 -0
  37. package/dist/infra/outbox/registry.js +8 -0
  38. package/dist/local-devices/device-auth.controller.d.ts +1 -1
  39. package/dist/local-devices/device-auth.controller.js +1 -1
  40. package/dist/local-devices/device-auth.d.ts +4 -3
  41. package/dist/local-devices/device-auth.js +1 -1
  42. package/dist/local-devices/device-policy.service.d.ts +6 -6
  43. package/dist/local-devices/device-routes.d.ts +4 -2
  44. package/dist/local-devices/device-routes.js +7 -6
  45. package/dist/local-devices/instance-bindings.d.ts +4 -4
  46. package/dist/local-devices/instance-bindings.js +2 -2
  47. package/dist/local-devices/local-device-gateway.d.ts +12 -12
  48. package/dist/local-devices/local-device-gateway.js +94 -129
  49. package/dist/local-devices/local-device-provider.d.ts +19 -87
  50. package/dist/local-devices/local-device-provider.js +43 -158
  51. package/dist/local-devices/local-devices.module.d.ts +4 -5
  52. package/dist/local-devices/local-devices.module.js +6 -9
  53. package/dist/local-devices/machines.d.ts +6 -6
  54. package/dist/local-devices/machines.js +4 -4
  55. package/dist/local-devices/owner-report.d.ts +3 -3
  56. package/dist/local-devices/owner-report.js +4 -4
  57. package/dist/local-devices/owner-reports.js +2 -2
  58. package/dist/local-devices/policy-summary.js +2 -2
  59. package/dist/local-devices/relay.d.ts +12 -25
  60. package/dist/local-devices/relay.js +17 -31
  61. package/dist/orgs/settings.controller.d.ts +1 -4
  62. package/dist/orgs/settings.controller.js +3 -3
  63. package/dist/orgs/settings.service.d.ts +7 -21
  64. package/dist/orgs/settings.service.js +16 -40
  65. package/dist/overrides.d.ts +3 -3
  66. package/dist/platform/ops/admin.ops.js +6 -8
  67. package/dist/platform/ops/org-settings.ops.js +4 -4
  68. package/dist/platform/ops/orgs.ops.js +0 -1
  69. package/dist/runtime/maintenance.d.ts +1 -1
  70. package/dist/runtime/maintenance.js +7 -1
  71. package/dist/runtime/run-steps.js +2 -2
  72. package/dist/sandbox/held-operations.d.ts +7 -0
  73. package/dist/sandbox/held-operations.js +25 -1
  74. package/dist/sandbox/leases.d.ts +6 -3
  75. package/dist/sandbox/leases.js +16 -10
  76. package/dist/sandbox/legacy-retirement.d.ts +0 -19
  77. package/dist/sandbox/legacy-retirement.js +6 -37
  78. package/dist/sandbox/managed-device-context.d.ts +12 -0
  79. package/dist/sandbox/managed-device-context.js +49 -1
  80. package/dist/sandbox/modes.d.ts +9 -8
  81. package/dist/sandbox/modes.js +4 -15
  82. package/dist/sandbox/operation-authority-types.d.ts +18 -1
  83. package/dist/sandbox/operation-authority-types.js +20 -1
  84. package/dist/sandbox/operation-authority.d.ts +14 -0
  85. package/dist/sandbox/operation-authority.js +120 -18
  86. package/dist/sandbox/operation-intents.d.ts +43 -0
  87. package/dist/sandbox/operation-intents.js +107 -4
  88. package/dist/sandbox/operation-reconcile.job.d.ts +12 -1
  89. package/dist/sandbox/operation-reconcile.job.js +53 -6
  90. package/dist/sandbox/permission-call-grants.d.ts +4 -0
  91. package/dist/sandbox/permission-call-grants.js +32 -3
  92. package/dist/sandbox/permission-call-types.d.ts +27 -2
  93. package/dist/sandbox/permission-ceiling-writes.js +2 -1
  94. package/dist/sandbox/permission-context-types.d.ts +2 -2
  95. package/dist/sandbox/permission-context-types.js +2 -2
  96. package/dist/sandbox/permission-facts.js +10 -2
  97. package/dist/sandbox/platform-full-access.d.ts +8 -26
  98. package/dist/sandbox/platform-full-access.js +8 -20
  99. package/dist/sandbox/review/classifier.d.ts +2 -2
  100. package/dist/sandbox/review/classifier.js +18 -5
  101. package/dist/sandbox/review/permission-candidate.d.ts +59 -3
  102. package/dist/sandbox/review/permission-candidate.js +192 -25
  103. package/dist/sandbox/review/review.service.d.ts +18 -0
  104. package/dist/sandbox/review/review.service.js +158 -12
  105. package/dist/sandbox/sandbox.service.d.ts +71 -47
  106. package/dist/sandbox/sandbox.service.js +234 -133
  107. package/dist/tools/approvals.service.d.ts +6 -1
  108. package/dist/tools/approvals.service.js +10 -0
  109. package/dist/tools/builtins/builtin-tools.d.ts +1 -4
  110. package/dist/tools/builtins/builtin-tools.js +13 -18
  111. package/dist/tools/builtins/sandbox/bash.d.ts +16 -3
  112. package/dist/tools/builtins/sandbox/bash.js +92 -270
  113. package/dist/tools/builtins/sandbox/common.d.ts +15 -9
  114. package/dist/tools/builtins/sandbox/common.js +55 -19
  115. package/dist/tools/builtins/sandbox/device-owner.d.ts +13 -0
  116. package/dist/tools/builtins/sandbox/device-owner.js +14 -0
  117. package/dist/tools/builtins/sandbox/task-list.js +2 -2
  118. package/dist/tools/builtins/sandbox/task-output.d.ts +14 -57
  119. package/dist/tools/builtins/sandbox/task-output.js +88 -210
  120. package/dist/tools/builtins/sandbox/task-stop.d.ts +2 -2
  121. package/dist/tools/builtins/sandbox/task-stop.js +15 -26
  122. package/dist/tools/pipeline.d.ts +31 -2
  123. package/dist/tools/pipeline.js +273 -43
  124. package/dist/tools/registry.d.ts +7 -0
  125. package/package.json +4 -4
  126. package/src/migrations/0162_permission_call_escalation.sql +9 -0
  127. package/dist/background/status.d.ts +0 -35
  128. package/dist/background/status.js +0 -57
@@ -16,7 +16,6 @@ import { PlatformOperations } from "../../platform/registry.js";
16
16
  import type { HookRunner } from "../../runtime/hook-calls.js";
17
17
  import { ProviderRegistry } from "../../runtime/providers.js";
18
18
  import { StepLog } from "../../runtime/step-log.js";
19
- import { LegacyRetirementStore } from "../../sandbox/legacy-retirement.js";
20
19
  import { type ManagedDeviceContextPort, ManagedDeviceContextRecorder } from "../../sandbox/managed-device-context.js";
21
20
  import { SandboxService } from "../../sandbox/sandbox.service.js";
22
21
  import { ScheduledTaskStore } from "../../schedules/store.js";
@@ -38,9 +37,7 @@ export declare class BuiltinTools {
38
37
  /** The WebFetch extraction call: the `web_fetch` purpose, its hooks, usage and denials. */
39
38
  purposes: ModelPurposesService, host: {
40
39
  readonly hooks?: HookRunner;
41
- } | undefined, stepLog: StepLog, log: Logger, background: BackgroundTaskStore, finisher: BackgroundTaskFinisher, stopper: BackgroundTaskStopper,
42
- /** The legacy-launch freeze every legacy background launch checks before dispatch (8.5). */
43
- legacyLaunch: LegacyRetirementStore, platformOps: PlatformOperations, platformActor: PlatformActor, agentDocs: AgentDocs,
40
+ } | undefined, stepLog: StepLog, log: Logger, background: BackgroundTaskStore, finisher: BackgroundTaskFinisher, stopper: BackgroundTaskStopper, platformOps: PlatformOperations, platformActor: PlatformActor, agentDocs: AgentDocs,
44
41
  /** The schedule tools read tasks and grants; their writes go through the task service. */
45
42
  scheduleStore: ScheduledTaskStore,
46
43
  /** `ScheduleUpdate`'s write: its field change and grant changes in one transaction. */
@@ -30,7 +30,6 @@ import { PlatformOperations } from "../../platform/registry.js";
30
30
  import { ProviderRegistry } from "../../runtime/providers.js";
31
31
  import { conversationTimeZone, RUN_CONTEXT_CLOCK } from "../../runtime/run-context.service.js";
32
32
  import { StepLog } from "../../runtime/step-log.js";
33
- import { LegacyRetirementStore } from "../../sandbox/legacy-retirement.js";
34
33
  import { ManagedDeviceContextRecorder, } from "../../sandbox/managed-device-context.js";
35
34
  import { PERMISSION_CONTEXT_ACTIVATION, permissionContextActive, } from "../../sandbox/permission-context-types.js";
36
35
  import { SandboxService } from "../../sandbox/sandbox.service.js";
@@ -60,9 +59,7 @@ let BuiltinTools = class BuiltinTools {
60
59
  tools;
61
60
  constructor(db, config, outputs, storage, attachments, eventLog, sandbox, devices, points, webPages,
62
61
  /** The WebFetch extraction call: the `web_fetch` purpose, its hooks, usage and denials. */
63
- purposes, host, stepLog, log, background, finisher, stopper,
64
- /** The legacy-launch freeze every legacy background launch checks before dispatch (8.5). */
65
- legacyLaunch, platformOps, platformActor, agentDocs,
62
+ purposes, host, stepLog, log, background, finisher, stopper, platformOps, platformActor, agentDocs,
66
63
  /** The schedule tools read tasks and grants; their writes go through the task service. */
67
64
  scheduleStore,
68
65
  /** `ScheduleUpdate`'s write: its field change and grant changes in one transaction. */
@@ -83,7 +80,6 @@ let BuiltinTools = class BuiltinTools {
83
80
  sandbox,
84
81
  devices,
85
82
  background,
86
- legacyLaunch,
87
83
  tasks: { finisher, stopper },
88
84
  subagents: {
89
85
  inTree: async (root, id) => id !== root && (await conversationAncestors(db.db, id)).includes(root),
@@ -194,20 +190,19 @@ BuiltinTools = __decorate([
194
190
  __param(14, Inject(BackgroundTaskStore)),
195
191
  __param(15, Inject(BackgroundTaskFinisher)),
196
192
  __param(16, Inject(BackgroundTaskStopper)),
197
- __param(17, Inject(LegacyRetirementStore)),
198
- __param(18, Inject(PlatformOperations)),
199
- __param(19, Inject(PlatformActor)),
200
- __param(20, Inject(AgentDocs)),
201
- __param(21, Inject(ScheduledTaskStore)),
202
- __param(22, Inject(ScheduleUpdates)),
203
- __param(23, Inject(ScheduleToolsPort)),
204
- __param(24, Inject(ModelImages)),
205
- __param(25, Inject(ProviderRegistry)),
206
- __param(26, Inject(ManagedDeviceContextRecorder)),
193
+ __param(17, Inject(PlatformOperations)),
194
+ __param(18, Inject(PlatformActor)),
195
+ __param(19, Inject(AgentDocs)),
196
+ __param(20, Inject(ScheduledTaskStore)),
197
+ __param(21, Inject(ScheduleUpdates)),
198
+ __param(22, Inject(ScheduleToolsPort)),
199
+ __param(23, Inject(ModelImages)),
200
+ __param(24, Inject(ProviderRegistry)),
201
+ __param(25, Inject(ManagedDeviceContextRecorder)),
202
+ __param(26, Optional()),
203
+ __param(26, Inject(RUN_CONTEXT_CLOCK)),
207
204
  __param(27, Optional()),
208
- __param(27, Inject(RUN_CONTEXT_CLOCK)),
209
- __param(28, Optional()),
210
- __param(28, Inject(PERMISSION_CONTEXT_ACTIVATION))
205
+ __param(27, Inject(PERMISSION_CONTEXT_ACTIVATION))
211
206
  ], BuiltinTools);
212
207
  export { BuiltinTools };
213
208
  /**
@@ -1,4 +1,5 @@
1
1
  import { type ExecResult } from "@capybara-hq/plugin-sdk";
2
+ import { SANDBOX_ESCALATED } from "../../../sandbox/review/permission-candidate.js";
2
3
  import type { BuiltinCallContext, BuiltinResult, BuiltinTool } from "../../registry.js";
3
4
  import { type SandboxToolDeps } from "./common.js";
4
5
  /** The command timeout in seconds when `timeout` is not given, at most `sandbox.limits.maxCommandSeconds`. */
@@ -14,6 +15,9 @@ interface BashInput {
14
15
  /** Milliseconds. */
15
16
  timeout?: number;
16
17
  run_in_background?: boolean;
18
+ /** `escalated`: run this one call outside the OS sandbox once approved. */
19
+ sandbox?: typeof SANDBOX_ESCALATED;
20
+ justification?: string;
17
21
  }
18
22
  /**
19
23
  * 命令结果 → 给模型的文本。`budgetClamped`:运行的时限把超时收紧到了 `seconds`(Ruling M20),超时说明改为
@@ -21,9 +25,8 @@ interface BashInput {
21
25
  */
22
26
  export declare function formatExec(r: ExecResult, seconds: number, budgetClamped?: boolean, workspace?: string): string;
23
27
  /**
24
- * Managed `Bash` background launch (permission runtime cutover phase 8.2): the tool's background
25
- * path once the one activation gate is on (B-17); while it is off the protocol-2 launch above
26
- * stays the active path.
28
+ * Managed `Bash` background launch (permission runtime cutover phase 8.2): the tool's only
29
+ * background path (the SID launch is gone, permission activation W5-P2).
27
30
  *
28
31
  * Inside the held operation session it reserves the task (or, for a retry of the same run call,
29
32
  * reuses the reservation it persisted before: the same task id, artifact, deadline and
@@ -35,6 +38,16 @@ export declare function formatExec(r: ExecResult, seconds: number, budgetClamped
35
38
  * unknown outcome leaves it dispatched for reconciliation under the same identity.
36
39
  */
37
40
  export declare function runInBackgroundManaged(deps: SandboxToolDeps, ctx: BuiltinCallContext, input: BashInput): Promise<BuiltinResult>;
41
+ /**
42
+ * Whether a finished command failed in a way the OS sandbox may have caused: a host the device
43
+ * refused (`network.blocked`) or a sandbox-specific message, and no credential or auth failure.
44
+ */
45
+ export declare const sandboxDenied: (r: ExecResult) => boolean;
46
+ /**
47
+ * {@link SCOPE_DENIED_TOOL_TEXT} followed by {@link ESCALATION_RETRY_HINT}, written out as a literal
48
+ * for the tool design check (a unit test keeps the two copies equal).
49
+ */
50
+ export declare const SCOPE_DENIED_ESCALATION_TEXT = "This operation reaches outside what this conversation's permission profile allows on the device (a path outside the directories it may read or write, or a host it may not reach), so it did not run. Keep the call inside the working directory and the directories already granted, or ask the user to grant the directory or choose a broader permission profile, then retry. 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.";
38
51
  /** 内置工具 `Bash`:在本对话的沙箱里执行命令。 */
39
52
  export declare function sandboxBashTool(deps: SandboxToolDeps): BuiltinTool;
40
53
  export {};
@@ -1,10 +1,11 @@
1
1
  import { DEFAULT_SANDBOX_ROOTS, isSandboxOperationOutcomeUnknownError, isSandboxPermissionUnsupportedError, isSandboxScopeDeniedError, ToolError, } from "@capybara-hq/plugin-sdk";
2
- import { backgroundMaxSeconds, LAUNCH_EXEC_TIMEOUT_MS, launchScript, managedStartedText, managedTaskArtifactPath, newTaskId, startedText, taskOutputPath, taskSidPath, } from "../../../background/launch.js";
3
- import { KILL_SESSION_TIMEOUT_MS, killSession, SID_RE } from "../../../background/session.js";
4
- import { runOutsideTransaction } from "../../../infra/database/transaction-host.js";
2
+ import { backgroundMaxSeconds, LAUNCH_EXEC_TIMEOUT_MS, managedStartedText, managedTaskArtifactPath, newTaskId, } from "../../../background/launch.js";
3
+ import { taskReasonText } from "../../../background/render.js";
5
4
  import { isDeviceRequestNotSent } from "../../../local-devices/relay.js";
5
+ import { isEscalationGrantMissing } from "../../../sandbox/operation-authority-types.js";
6
6
  import { launchRefusedText, operationIdFor } from "../../../sandbox/operation-intents.js";
7
- import { clip, display, inSandbox, inSandboxOperations, inToolSandbox, mapSandboxError, noSandboxError, runBudgetNote, runTimeLeftMs, sandboxBaseTimeoutMs, sandboxConversationOf, shellQuote, unavailableWhenNoSandbox, withNotices, } from "./common.js";
7
+ import { ESCALATION_JUSTIFICATION_MAX_CHARS, ESCALATION_RETRY_HINT, SANDBOX_ESCALATED, } from "../../../sandbox/review/permission-candidate.js";
8
+ import { clip, display, inSandboxOperations, inToolSandbox, runBudgetNote, runTimeLeftMs, SCOPE_DENIED_TOOL_TEXT, sandboxBaseTimeoutMs, sandboxConversationOf, unavailableWhenNoSandbox, withNotices, } from "./common.js";
8
9
  import { parseDeviceCode } from "./device-code.js";
9
10
  /** The command timeout in seconds when `timeout` is not given, at most `sandbox.limits.maxCommandSeconds`. */
10
11
  export const BASH_DEFAULT_TIMEOUT_SECONDS = 120;
@@ -54,6 +55,12 @@ const SPEC = {
54
55
  "command exits, and processes it left running are stopped. A background task is lost if the " +
55
56
  "sandbox is suspended (it is suspended after it has been running for a while, " +
56
57
  "sandbox.limits.maxRunningMinutes).\n\n" +
58
+ "Commands run inside an OS sandbox that limits which directories they may write and which " +
59
+ "hosts they may reach. When the sandbox blocks a command you need (for example 'Operation not " +
60
+ "permitted' writing outside the project, or a dev tool that must reach the machine), retry " +
61
+ 'that one call with sandbox: "escalated" and a justification saying why; the user or a review ' +
62
+ "model decides, and only that call runs outside the sandbox. Do not escalate by default: try " +
63
+ "inside the sandbox first. Some devices and organizations do not allow it.\n\n" +
57
64
  "Network access goes through a proxy set in HTTP_PROXY / HTTPS_PROXY / ALL_PROXY; a tool " +
58
65
  "that ignores them fails with 'Operation not permitted' or cannot resolve names; such a tool " +
59
66
  "needs the proxy passed explicitly through its own proxy option. A blocked domain is " +
@@ -81,6 +88,17 @@ const SPEC = {
81
88
  type: "boolean",
82
89
  description: "Set to true to run this command in the background (see the description for when).",
83
90
  },
91
+ sandbox: {
92
+ type: "string",
93
+ enum: [SANDBOX_ESCALATED],
94
+ description: 'Set to "escalated" to ask to run this one call outside the OS sandbox (also in the background). Requires justification; the user or a review model approves it first.',
95
+ },
96
+ justification: {
97
+ type: "string",
98
+ minLength: 1,
99
+ maxLength: ESCALATION_JUSTIFICATION_MAX_CHARS,
100
+ description: 'With sandbox: "escalated": one sentence saying why this command must run outside the sandbox, e.g. "The dev server must bind port 3000 on the machine". Shown to the approver.',
101
+ },
84
102
  },
85
103
  required: ["command", "description"],
86
104
  additionalProperties: false,
@@ -116,256 +134,11 @@ export function formatExec(r, seconds, budgetClamped = false, workspace = DEFAUL
116
134
  }
117
135
  return parts.join("\n");
118
136
  }
119
- /** The most output the launch exec keeps (it prints only the session id, or an error). */
137
+ /** The most output a background start keeps (the device acknowledges it with a typed ref). */
120
138
  const LAUNCH_MAX_OUTPUT_BYTES = 64 * 1024;
121
- /** Above about this many bytes of base64, a provider may refuse the launch exec's command. */
122
- const LARGE_COMMAND_BASE64_BYTES = 96 * 1024;
123
- /** Why a launch exec did not start the command, for the model and the row's reason. */
124
- function launchFailure(r) {
125
- if (r.timedOut)
126
- return `the launch did not finish within ${LAUNCH_EXEC_TIMEOUT_MS / 1000}s`;
127
- if (r.exitCode === null)
128
- return "the launch was stopped before it finished";
129
- const said = clip(r.stderr || (r.exitCode === 0 ? "" : r.stdout), 500).replace(/\.$/, "");
130
- if (said !== "")
131
- return said;
132
- return r.exitCode === 0
133
- ? "the launch printed no session id"
134
- : `the launch exited with code ${r.exitCode}`;
135
- }
136
- /**
137
- * `Bash` with `run_in_background` (spec 2026-11-05-background-bash-design §2.1, §4.2):
138
- * 1. reserves the task's row (`BackgroundTaskStore.reserve`: `running`, no `sid`), refused once
139
- * the sandbox runs `sandbox.background.maxTasks` tasks; the count and the insert are one step
140
- * under the sandbox's launch lock;
141
- * 2. runs one short launch exec under the call's shared lease, and in the same lease records the
142
- * session id and the instance (`markStarted`); a command that started but could not be
143
- * recorded is killed there (`pkill -KILL -s <sid>`), so no process runs untracked;
144
- * 3. any failure finishes the row as `failed` with the reason (`failLaunch`);
145
- * 4. a stop that claimed the reservation meanwhile (`markStarted` answers `stopping`) has the
146
- * command killed at once and the row finished `stopped` (`finishStoppedLaunch`).
147
- * The command runs in a session of its own under its own `timeout` (default and maximum
148
- * {@link backgroundMaxSeconds}).
149
- */
150
- async function runInBackground(deps, ctx, input) {
151
- const { background, sandbox } = deps;
152
- if (!background || !sandbox.currentInstance) {
153
- throw new ToolError("Background tasks are not available here; call Bash without run_in_background.");
154
- }
155
- if (ctx.runId === undefined) {
156
- throw new ToolError("Background tasks can only be started from an agent run; call Bash without run_in_background.");
157
- }
158
- const currentInstance = sandbox.currentInstance.bind(sandbox);
159
- const cfg = deps.config.get();
160
- const maxMs = backgroundMaxSeconds(cfg) * 1000;
161
- const requested = input.timeout;
162
- const seconds = Math.max(1, Math.ceil(Math.min(requested ?? maxMs, maxMs) / 1000));
163
- const root = sandboxConversationOf(ctx);
164
- // the device the task will run in (the root conversation's, bound for good)
165
- let deviceId;
166
- try {
167
- deviceId = await deps.devices.forTool(ctx.orgId, root);
168
- }
169
- catch (e) {
170
- throw mapSandboxError(e, deps.log);
171
- }
172
- if (!(await sandbox.availableFor(deviceId)))
173
- throw noSandboxError();
174
- const maxTasks = cfg.sandbox.background.maxTasks;
175
- const id = newTaskId();
176
- const description = input.description ?? clip(input.command, 120);
177
- const startedAt = new Date();
178
- const reserved = await background.reserve({
179
- id,
180
- orgId: ctx.orgId,
181
- conversationId: ctx.conversationId,
182
- sandboxConversationId: root,
183
- deviceId,
184
- runId: ctx.runId,
185
- callId: ctx.callId,
186
- // the run's trigger account (the pipeline passes `runs.trigger_account_id` as `accountId`)
187
- triggerAccountId: ctx.accountId,
188
- description,
189
- command: input.command,
190
- outputPath: taskOutputPath(id),
191
- startedAt,
192
- deadlineAt: new Date(startedAt.getTime() + seconds * 1000),
193
- }, maxTasks);
194
- if (!reserved) {
195
- throw new ToolError(`${maxTasks} background tasks are already running; stop one with TaskStop or wait for one to finish, then retry`);
196
- }
197
- // the conversation's background panel lists the task live (a sub-agent's task shows in its
198
- // parent's panel too): announced when it starts and when its launch ends it (failed, stopped),
199
- // since a client may have listed the reservation as running meanwhile; a failed publish only logs
200
- const announce = async () => {
201
- if (!deps.eventLog.publishChanged)
202
- return;
203
- for (const c of new Set([ctx.conversationId, root])) {
204
- await deps.eventLog.publishChanged(c, "background");
205
- }
206
- };
207
- // the instance's workspace once the call entered it (the default until then)
208
- let workspace = DEFAULT_SANDBOX_ROOTS.workspace;
209
- const isLarge = Math.ceil(Buffer.byteLength(input.command, "utf8") / 3) * 4 > LARGE_COMMAND_BASE64_BYTES;
210
- const largeText = () => isLarge
211
- ? ` A very large command (over about 96 KB after base64) cannot be started in the background; write it to a script under ${workspace} and run that instead.`
212
- : "";
213
- // set once the row has its sid: from then on the task runs and is tracked, whatever follows
214
- let started = false;
215
- let launch;
216
- let notices;
217
- try {
218
- ({ value: launch, notices } = await inSandbox(deps, ctx, async (s) => {
219
- const { h, roots, p, signal } = s;
220
- workspace = roots.workspace;
221
- // right after the launch a process may fork while it is killed: killSession repeats
222
- const kill = (sid) => killSession(p, h, sid);
223
- // the session id the launch wrote before printing it: the launch may have ended (aborted,
224
- // timed out, thrown) after starting the command but before its output came back
225
- const sidFile = async () => {
226
- const f = await p
227
- .readFile(h, `${roots.workspace}/${taskSidPath(id)}`, {
228
- maxBytes: 64,
229
- signal: AbortSignal.timeout(KILL_SESSION_TIMEOUT_MS),
230
- })
231
- .catch(() => null);
232
- const v = f ? new TextDecoder().decode(f.data).trim() : "";
233
- return SID_RE.test(v) ? v : null;
234
- };
235
- // immediately before the dispatch (0157): refused once the legacy-launch freeze is
236
- // published, else the reservation is marked as possibly dispatched in the same step
237
- const legacyLaunch = deps.legacyLaunch;
238
- if (legacyLaunch) {
239
- // under the shared lease: the incarnation the launch dispatches into, exactly (I2)
240
- const at = await currentInstance(deviceId);
241
- const admission = await runOutsideTransaction(() => legacyLaunch.admitLegacyDispatch(ctx.orgId, id, {
242
- provider: at?.provider ?? "unknown",
243
- generation: at ? String(at.createdAt.getTime()) : "unknown",
244
- }));
245
- if (admission === "frozen")
246
- return {
247
- kind: "not_started",
248
- why: "background tasks are being upgraded on this deployment and cannot be started with the old launcher",
249
- };
250
- if (admission === "gone")
251
- return {
252
- kind: "not_started",
253
- why: "its task record was finished meanwhile",
254
- };
255
- }
256
- let r;
257
- try {
258
- r = await p.exec(h, {
259
- // the launch keeps its task files under the workspace (`.capybara/tasks`, where
260
- // TaskOutput and TaskStop find them); the command itself starts in the working root
261
- command: launchScript(id, inWorkingRoot(input.command, s), seconds),
262
- cwd: roots.workspace,
263
- timeoutMs: LAUNCH_EXEC_TIMEOUT_MS,
264
- maxOutputBytes: LAUNCH_MAX_OUTPUT_BYTES,
265
- signal,
266
- });
267
- }
268
- catch (e) {
269
- const sid = await sidFile();
270
- if (sid !== null)
271
- await kill(sid);
272
- throw e;
273
- }
274
- const out = r.stdout.trim();
275
- if (r.exitCode !== 0 || !SID_RE.test(out)) {
276
- const sid = SID_RE.test(out) ? out : await sidFile();
277
- if (sid !== null)
278
- await kill(sid);
279
- return { kind: "not_started", why: launchFailure(r) };
280
- }
281
- const sid = out;
282
- try {
283
- // under the shared lease: no rebuild can come between the launch and this read
284
- const instance = await currentInstance(deviceId);
285
- if (instance === null)
286
- throw new Error("the sandbox instance could not be read");
287
- const marked = await background.markStarted(id, {
288
- sid,
289
- sandboxCreatedAt: instance.createdAt,
290
- outputPath: `${roots.workspace}/${taskOutputPath(id)}`,
291
- });
292
- if (!marked)
293
- throw new Error("its task record was finished meanwhile");
294
- started = true;
295
- if (marked === "stopping") {
296
- // a stop claimed the reservation before the command started: kill it at once
297
- if (await kill(sid)) {
298
- await background.finishStoppedLaunch(id);
299
- return { kind: "stopped" };
300
- }
301
- // not confirmed: the task runs on and is tracked like any other (the poller checks it)
302
- await background.releaseStop(id);
303
- }
304
- return { kind: "started" };
305
- }
306
- catch (e) {
307
- const stopped = await kill(sid);
308
- const why = e instanceof Error ? e.message : String(e);
309
- return { kind: "unrecorded", why, stopped };
310
- }
311
- }));
312
- }
313
- catch (e) {
314
- if (started) {
315
- // the task runs and its row has its sid: an error after that (releasing the lease, say)
316
- // does not undo the launch
317
- launch = { kind: "started" };
318
- notices = [];
319
- }
320
- else {
321
- // no sandbox, a busy or lost lease, an abort, a provider error: nothing started (or what
322
- // did was killed above, when its session id could be read)
323
- const why = e instanceof Error ? e.message : String(e);
324
- await background.failLaunch(id, `launch failed: ${why}`).catch(() => undefined);
325
- await announce();
326
- if (!isLarge || e instanceof ToolError)
327
- throw e;
328
- throw new ToolError(`The background task was not started: ${clip(why, 500).replace(/\.$/, "")}. Check the environment, or call Bash without run_in_background.${largeText()}`);
329
- }
330
- }
331
- if (launch.kind === "not_started") {
332
- await background.failLaunch(id, launch.why);
333
- await announce();
334
- throw new ToolError(`The background task was not started: ${launch.why}. Check the environment, or call Bash without run_in_background.${largeText()}`);
335
- }
336
- if (launch.kind === "stopped") {
337
- await announce();
338
- throw new ToolError(`Background task ${id} ("${description}") was stopped while it was starting, so nothing runs. Call Bash again if it is still needed.`);
339
- }
340
- if (launch.kind === "unrecorded") {
341
- await background.failLaunch(id, `started but not recorded: ${launch.why}`);
342
- await announce();
343
- if (launch.stopped) {
344
- throw new ToolError(`The background command started but could not be recorded (${launch.why}), so it was stopped. Retry, or call Bash without run_in_background.`);
345
- }
346
- throw new ToolError(`The background command started but could not be recorded (${launch.why}); an attempt to stop it failed, so it ends at its timeout. Check the sandbox before you retry, or call Bash without run_in_background.`);
347
- }
348
- await announce();
349
- const lowered = requested !== undefined && requested > maxMs
350
- ? `\n[timeout ${requested} ms is over the background task maximum; it was lowered to ${maxMs} ms.]`
351
- : "";
352
- const shown = clip(input.command, 120);
353
- return {
354
- content: [
355
- {
356
- type: "text",
357
- text: withNotices(notices, startedText(id, description, workspace) + lowered),
358
- },
359
- ],
360
- isError: false,
361
- view: { kind: "command", description, exitCode: null, timedOut: false },
362
- display: display(`后台运行命令:${shown}`, `Started in the background: ${shown}`),
363
- };
364
- }
365
139
  /**
366
- * Managed `Bash` background launch (permission runtime cutover phase 8.2): the tool's background
367
- * path once the one activation gate is on (B-17); while it is off the protocol-2 launch above
368
- * stays the active path.
140
+ * Managed `Bash` background launch (permission runtime cutover phase 8.2): the tool's only
141
+ * background path (the SID launch is gone, permission activation W5-P2).
369
142
  *
370
143
  * Inside the held operation session it reserves the task (or, for a retry of the same run call,
371
144
  * reuses the reservation it persisted before: the same task id, artifact, deadline and
@@ -486,10 +259,22 @@ export async function runInBackgroundManaged(deps, ctx, input) {
486
259
  // a retry of a call whose acknowledged task has since ended reports the start it made
487
260
  const started = task.executionRef !== null &&
488
261
  (task.launchState === "acknowledged" || task.status !== "running");
262
+ if (!started && launch.kind !== "refused" && task.status === "lost") {
263
+ // revoked or given up before its start was confirmed: the process may have started, and its
264
+ // exact revoke (owed with the revocation) stops it; never claim that nothing ran
265
+ const how = task.lostReason === "launch_unknown" ? "given up" : "revoked";
266
+ throw new ToolError(`Background task ${task.id} ("${description}") may have started before its launch was ${how} (${taskReasonText(task)}); any process it started is being stopped and will not keep running, but it may already have had effects. Check them before calling Bash again as a new call.`);
267
+ }
489
268
  if (!started && (launch.kind === "refused" || task.launchState === "terminal")) {
490
269
  // the recorded reason may hold a provider's words: the model gets kernel text only
491
270
  const why = launch.kind === "refused" ? launch.why : "it was stopped or refused before it started";
492
- throw new ToolError(`The background task was not started: ${why}. Nothing runs; fix the cause, or call Bash without run_in_background.`);
271
+ // a scope refusal where running outside the sandbox is allowed: say the call may escalate
272
+ const hint = launch.kind === "refused" &&
273
+ ctx.sandboxEscalation === "available" &&
274
+ why === launchRefusedText("denied")
275
+ ? ESCALATION_RETRY_HINT
276
+ : "";
277
+ throw new ToolError(`The background task was not started: ${why}. Nothing runs; fix the cause, or call Bash without run_in_background.${hint}`);
493
278
  }
494
279
  if (!started && task.launchState === "cancel-pending" && task.executionRef !== null) {
495
280
  // the device acknowledged the start; a stop, while or after it started, is being applied
@@ -519,6 +304,8 @@ export async function runInBackgroundManaged(deps, ctx, input) {
519
304
  }
520
305
  /** Why a managed start was refused, in the kernel's own words (never the provider's message). */
521
306
  function launchRefusedWhy(e) {
307
+ if (isEscalationGrantMissing(e))
308
+ return 'its approval to run outside the sandbox no longer matches (the device, its Full access ceiling or the permission scope changed since it was approved); call Bash again with sandbox: "escalated" and a justification to ask again';
522
309
  return launchRefusedText(isDeviceRequestNotSent(e)
523
310
  ? "not_sent"
524
311
  : isSandboxScopeDeniedError(e)
@@ -531,15 +318,49 @@ function launchRefusedWhy(e) {
531
318
  const isRefusal = (e) => !isSandboxOperationOutcomeUnknownError(e) &&
532
319
  (isSandboxScopeDeniedError(e) || isSandboxPermissionUnsupportedError(e));
533
320
  /**
534
- * A background command's script, started in the conversation's working root: the launch itself
535
- * runs in the workspace (its task files live under `.capybara/tasks` there), so for a bound
536
- * project the script first changes into the project's root, and ends (exit 1) without running the
537
- * command when it cannot.
321
+ * Sandbox-specific signals in a command's output: the EPERM a Seatbelt or Landlock write denial
322
+ * gives, the read-only bind of the Linux sandbox, Seatbelt's own deny report, and the sandbox
323
+ * proxy refusing a host or a tunnel. A plain "Permission denied" (EACCES) is not one: ssh
324
+ * publickey failures, git 403s and file modes print it too.
325
+ */
326
+ const SANDBOX_DENIED_RE = /Operation not permitted|Read-only file system|Sandbox: \S+\(\d+\) deny\(\d+\)|Connection blocked by network allowlist|blocked-by-allowlist|HTTP code 403 from proxy after CONNECT/;
327
+ /**
328
+ * Credential and auth failures: never a reason to run outside the sandbox, so they never get the
329
+ * escalation hint, whatever else the output says.
330
+ */
331
+ const AUTH_FAILURE_RE = /Permission denied \(publickey|Host key verification failed|Authentication failed|authentication required|could not read (?:Username|Password)|Bad credentials|invalid credentials|remote: Permission to \S+ denied|The requested URL returned error: 40[13]|\b401 Unauthorized\b/i;
332
+ /**
333
+ * Whether a finished command failed in a way the OS sandbox may have caused: a host the device
334
+ * refused (`network.blocked`) or a sandbox-specific message, and no credential or auth failure.
538
335
  */
539
- function inWorkingRoot(command, s) {
540
- if (s.workingRoot === s.roots.workspace)
541
- return command;
542
- return `cd -- ${shellQuote(s.workingRoot)} || exit 1\n${command}`;
336
+ export const sandboxDenied = (r) => {
337
+ if (r.exitCode === null || r.exitCode === 0)
338
+ return false;
339
+ const out = `${r.stdout}\n${r.stderr}`;
340
+ if (AUTH_FAILURE_RE.test(out))
341
+ return false;
342
+ return (r.network?.blocked.length ?? 0) > 0 || SANDBOX_DENIED_RE.test(out);
343
+ };
344
+ /**
345
+ * {@link SCOPE_DENIED_TOOL_TEXT} followed by {@link ESCALATION_RETRY_HINT}, written out as a literal
346
+ * for the tool design check (a unit test keeps the two copies equal).
347
+ */
348
+ export const SCOPE_DENIED_ESCALATION_TEXT = 'This operation reaches outside what this conversation\'s permission profile allows on the device (a path outside the directories it may read or write, or a host it may not reach), so it did not run. Keep the call inside the working directory and the directories already granted, or ask the user to grant the directory or choose a broader permission profile, then retry. 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.';
349
+ /**
350
+ * A restricted call the scope refused ({@link SCOPE_DENIED_TOOL_TEXT}) where running outside the
351
+ * sandbox is allowed: the refusal also says the call may be retried escalated.
352
+ */
353
+ async function withEscalationHint(ctx, fn) {
354
+ try {
355
+ return await fn();
356
+ }
357
+ catch (e) {
358
+ if (ctx.sandboxEscalation === "available" &&
359
+ e instanceof ToolError &&
360
+ e.message === SCOPE_DENIED_TOOL_TEXT)
361
+ throw new ToolError(SCOPE_DENIED_ESCALATION_TEXT);
362
+ throw e;
363
+ }
543
364
  }
544
365
  /** 内置工具 `Bash`:在本对话的沙箱里执行命令。 */
545
366
  export function sandboxBashTool(deps) {
@@ -551,7 +372,7 @@ export function sandboxBashTool(deps) {
551
372
  // 命令自己的超时先到(提供方停掉命令、返回 timedOut),管线的时限再留出等锁与创建 / 恢复的余量
552
373
  timeoutMs: (input) => {
553
374
  const cfg = deps.config.get();
554
- // a background call is only the short launch; the task's own timeout runs in the sandbox
375
+ // a background call is only the short start; the task's own timeout runs on the device
555
376
  if (input.run_in_background === true) {
556
377
  return LAUNCH_EXEC_TIMEOUT_MS + sandboxBaseTimeoutMs(cfg);
557
378
  }
@@ -560,11 +381,8 @@ export function sandboxBashTool(deps) {
560
381
  },
561
382
  async run(input, ctx) {
562
383
  if (input.run_in_background === true) {
563
- // once the activation gate is on, only the managed launch (B-17): the legacy launch
564
- // would refuse before entering
565
- return deps.managedDeviceContextRequired
566
- ? runInBackgroundManaged(deps, ctx, input)
567
- : runInBackground(deps, ctx, input);
384
+ // the managed launch only: it refuses before any effect where it cannot run
385
+ return withEscalationHint(ctx, () => runInBackgroundManaged(deps, ctx, input));
568
386
  }
569
387
  const { command, description } = input;
570
388
  const max = deps.config.get().sandbox.limits.maxCommandSeconds;
@@ -577,7 +395,7 @@ export function sandboxBashTool(deps) {
577
395
  let workspace = DEFAULT_SANDBOX_ROOTS.workspace;
578
396
  // the device the command ran on (a refused network host is asked about there)
579
397
  let deviceId = "";
580
- const { value: r, notices } = await inToolSandbox(deps, ctx, (s) => {
398
+ const { value: r, notices } = await withEscalationHint(ctx, () => inToolSandbox(deps, ctx, (s) => {
581
399
  const left = Math.floor(runTimeLeftMs(ctx.runDeadline) / 1000) * 1000;
582
400
  ms = Math.max(1000, Math.min(askedMs, left));
583
401
  workspace = s.roots.workspace;
@@ -590,7 +408,7 @@ export function sandboxBashTool(deps) {
590
408
  maxOutputBytes: MAX_OUTPUT_BYTES,
591
409
  signal: s.signal,
592
410
  });
593
- });
411
+ }));
594
412
  const blocked = r.network?.blocked ?? [];
595
413
  // kernel-internal (auto mode spec §6, P-D13): `gh auth login --web`'s device code, which the
596
414
  // pipeline shows to the person. It never becomes part of the result the model sees.
@@ -601,7 +419,11 @@ export function sandboxBashTool(deps) {
601
419
  const lowered = requested !== undefined && requested > maxMs
602
420
  ? `\n[timeout ${requested} ms is over the deployment maximum; it was lowered to ${maxMs} ms.]`
603
421
  : "";
604
- const text = formatExec(r, seconds, clamped, workspace) + lowered;
422
+ const text = formatExec(r, seconds, clamped, workspace) +
423
+ lowered +
424
+ (ctx.sandboxEscalation === "available" && sandboxDenied(r)
425
+ ? `\n[sandbox] The OS sandbox may have blocked this command.${ESCALATION_RETRY_HINT}`
426
+ : "");
605
427
  return {
606
428
  content: [{ type: "text", text: withNotices(notices, text) }],
607
429
  isError: r.timedOut || r.exitCode === null,
@@ -9,7 +9,6 @@ import type { EventLog } from "../../../conversations/event-log.js";
9
9
  import { type ConversationDevices, type WorkingFacts } from "../../../devices/conversation-devices.js";
10
10
  import type { KernelConfigService } from "../../../infra/config/kernel-config.service.js";
11
11
  import { ATTACHMENTS_ROOT, attachmentsDir, attachmentsRoot } from "../../../sandbox/attachments-path.js";
12
- import type { LegacyRetirementStore } from "../../../sandbox/legacy-retirement.js";
13
12
  import { type ManagedDeviceContextPort } from "../../../sandbox/managed-device-context.js";
14
13
  import type { SandboxMode } from "../../../sandbox/modes.js";
15
14
  import type { HeldDeviceContextEvidence } from "../../../sandbox/permission-context-types.js";
@@ -32,12 +31,7 @@ export interface SandboxToolDeps {
32
31
  */
33
32
  devices: Pick<ConversationDevices, "forTool"> & Partial<Pick<ConversationDevices, "usableNow" | "modeLevel" | "workingFacts" | "projectReach">>;
34
33
  /** Background `Bash` tasks; absent in test stubs, where `run_in_background` is refused. */
35
- background?: Pick<BackgroundTaskStore, "reserve" | "markStarted" | "failLaunch" | "finishStoppedLaunch" | "releaseStop" | "get" | "advanceOffset" | "runningOwnedBy" | "finishedOwnedBy"> & Partial<Pick<BackgroundTaskStore, "reserveManaged" | "failManagedPreEffect">>;
36
- /**
37
- * The legacy-launch freeze check (permission runtime cutover 8.5) every legacy background launch
38
- * makes immediately before it dispatches; always wired in the kernel, absent in test stubs.
39
- */
40
- legacyLaunch?: Pick<LegacyRetirementStore, "admitLegacyDispatch">;
34
+ background?: Pick<BackgroundTaskStore, "releaseStop" | "get" | "advanceOffset" | "runningOwnedBy" | "finishedOwnedBy"> & Partial<Pick<BackgroundTaskStore, "reserveManaged" | "failManagedPreEffect">>;
41
35
  /**
42
36
  * Whether `id` is a sub-agent conversation in the tree under `rootConversationId` (TaskOutput /
43
37
  * TaskStop tell a sub-agent's agentId apart from an unknown task id), and the sub-agents a
@@ -230,25 +224,37 @@ export interface PreparationSession {
230
224
  p: SandboxPreparation;
231
225
  }
232
226
  /**
233
- * Full access refused by policy (B-13: `org.*` / `deployment.*`, old and renamed codes): the
234
- * organization or the platform has it off. The kernel's own message is never shown.
227
+ * Full access refused by policy (B-13: `org.*` / `deployment.*`): the organization or the
228
+ * platform has it off. The kernel's own message is never shown.
235
229
  */
236
230
  export declare const FULL_ACCESS_OFF_BY_POLICY_TOOL_TEXT = "Full access is turned off by your organization's or the platform's policy, so nothing ran. Continue with the Request approval or Approve for me permission profile, or ask an org admin (or a super admin) to allow Full access.";
237
231
  /**
238
232
  * The device's owner ceiling does not allow Full access (`device.full_access_not_allowed`).
239
233
  */
240
234
  export declare const FULL_ACCESS_CEILING_TOOL_TEXT = "This device's owner ceiling does not allow Full access, so nothing ran. Ask the device's owner to raise it with `capybara-device ceiling set` on that machine, or continue with the Request approval or Approve for me permission profile.";
235
+ /**
236
+ * The legacy retirement gate's refusals (`RetirementPendingError`, permission runtime cutover
237
+ * 8.5): the device's earlier instance may still run background work an earlier version started.
238
+ * Each says what clears it; the generic `device.unavailable` text would name an inactive provider.
239
+ */
240
+ export declare const RETIREMENT_PENDING_TOOL_TEXT = "This device is unavailable: background work started by an earlier version may still run on its previous instance, which has not been confirmed destroyed yet, so nothing ran. Retry later (a cloud device becomes usable once its provider confirms the old instance destroyed), continue without the device, or ask the user to start a new conversation on another device.";
241
+ export declare const RETIREMENT_RESTART_TOOL_TEXT = "Background work started by an earlier version may still be running on this device's computer, so nothing ran. Ask the user to restart that computer to finish the upgrade, then retry; or continue without the device.";
242
+ export declare const RETIREMENT_RECREATE_TOOL_TEXT = "Background work started by an earlier version may still be running on an earlier instance of this device, which can no longer be verified as destroyed, so nothing ran. Ask the device's owner to delete the device and create it again, or ask the user to start a new conversation on another device.";
243
+ export declare const RETIREMENT_REPLACE_TOOL_TEXT = "Background work started by an earlier version may still be running on this device's computer, which cannot prove a restart, so nothing ran. Ask the device's owner to delete the device and connect the computer again as a new device, or ask the user to start a new conversation on another device.";
241
244
  /**
242
245
  * A managed operation outside the admitted scope (`SandboxScopeDeniedError`): fixed text, never
243
246
  * the refusal's own message (a provider may write it).
244
247
  */
245
248
  export declare const SCOPE_DENIED_TOOL_TEXT = "This operation reaches outside what this conversation's permission profile allows on the device (a path outside the directories it may read or write, or a host it may not reach), so it did not run. Keep the call inside the working directory and the directories already granted, or ask the user to grant the directory or choose a broader permission profile, then retry.";
249
+ /** An approved sandbox escalation whose grant no longer matches at admission (nothing ran). */
250
+ export declare const ESCALATION_GRANT_MISSING_TEXT = "This Bash call was approved to run outside the sandbox, but the approval no longer matches: the device, its Full access ceiling or this conversation's permission scope changed since it was approved, so it did not run. Call Bash again with sandbox: \"escalated\" and a justification to ask again, or call it without sandbox to run it inside the sandbox.";
246
251
  /** A staged request the machine never got: it reconnected before the request was sent. */
247
252
  export declare const DEVICE_REQUEST_NOT_SENT_TOOL_TEXT = "The device's machine reconnected before this operation was sent, so nothing ran. Retry the tool call.";
248
253
  /** The device cannot enforce the conversation's profile (`SandboxPermissionUnsupportedError`). */
249
254
  export declare const PERMISSION_UNSUPPORTED_TOOL_TEXT = "This device cannot enforce this conversation's permission profile, so nothing ran. Ask the user to choose another permission profile for the conversation, or to start a new conversation on a device that supports it.";
250
255
  /** A managed operation whose outcome could not be confirmed (`SandboxOperationOutcomeUnknownError`). */
251
256
  export declare const OUTCOME_UNKNOWN_TOOL_TEXT = "The device may or may not have run this operation: its outcome could not be confirmed. Check the device's state (for example with Read, Glob or TaskList) before retrying, and do not repeat an operation that must not run twice.";
257
+ export { DEVICE_OF_ANOTHER_ACCOUNT_TEXT } from "./device-owner.js";
252
258
  export declare function mapSandboxError(e: unknown, log: Pick<Logger, "warn"> | undefined): unknown;
253
259
  /**
254
260
  * Runs `fn` in the device of the call's conversation (a sub-agent: its root's): resolves and