@capybara-hq/kernel 0.1.0-rc.40 → 0.1.0-rc.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bootstrap.json +10 -1
- package/dist/admin/admin.schemas.d.ts +6 -0
- package/dist/admin/org-network.service.d.ts +3 -1
- package/dist/admin/org-network.service.js +10 -2
- package/dist/app.d.ts +4 -0
- package/dist/app.js +2 -0
- package/dist/background/finish.d.ts +9 -1
- package/dist/background/finish.js +57 -4
- package/dist/background/launch.d.ts +23 -0
- package/dist/background/launch.js +55 -1
- package/dist/background/managed-output.d.ts +110 -0
- package/dist/background/managed-output.js +219 -0
- package/dist/background/managed.d.ts +52 -0
- package/dist/background/managed.js +128 -0
- package/dist/background/poll.job.d.ts +35 -1
- package/dist/background/poll.job.js +174 -9
- package/dist/background/render.js +1 -0
- package/dist/background/retire-legacy-tasks.job.d.ts +57 -0
- package/dist/background/retire-legacy-tasks.job.js +149 -0
- package/dist/background/session.d.ts +15 -5
- package/dist/background/session.js +22 -6
- package/dist/background/stop.d.ts +35 -5
- package/dist/background/stop.js +94 -8
- package/dist/background/store.d.ts +110 -3
- package/dist/background/store.js +205 -3
- package/dist/background/tasks.service.d.ts +18 -1
- package/dist/background/tasks.service.js +99 -9
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/channels/cards.js +1 -1
- package/dist/channels/inbound.js +2 -0
- package/dist/channels/phrases.d.ts +4 -0
- package/dist/channels/phrases.js +4 -0
- package/dist/config/load.d.ts +18 -0
- package/dist/config/load.js +39 -1
- package/dist/config/permission-migration.d.ts +26 -0
- package/dist/config/permission-migration.js +64 -0
- package/dist/config/schema.d.ts +1 -1
- package/dist/config/schema.js +11 -10
- package/dist/conversations/conversations.controller.d.ts +1 -1
- package/dist/conversations/conversations.controller.js +1 -1
- package/dist/conversations/conversations.module.js +12 -0
- package/dist/conversations/conversations.service.d.ts +11 -2
- package/dist/conversations/conversations.service.js +97 -27
- package/dist/conversations/event-log.d.ts +1 -1
- package/dist/conversations/event-log.js +10 -2
- package/dist/conversations/events.d.ts +304 -4
- package/dist/conversations/events.js +279 -29
- package/dist/conversations/permission-profile-store.d.ts +50 -0
- package/dist/conversations/permission-profile-store.js +67 -0
- package/dist/conversations/permission-profile-store.module.d.ts +2 -0
- package/dist/conversations/permission-profile-store.module.js +19 -0
- package/dist/conversations/permission-profiles.controller.d.ts +84 -0
- package/dist/conversations/permission-profiles.controller.js +105 -0
- package/dist/conversations/permission-profiles.schemas.d.ts +31 -0
- package/dist/conversations/permission-profiles.schemas.js +23 -0
- package/dist/conversations/permission-profiles.service.d.ts +56 -0
- package/dist/conversations/permission-profiles.service.js +179 -0
- package/dist/db/kernel-schema.d.ts +238 -3
- package/dist/devices/access.js +1 -1
- package/dist/devices/access.module.d.ts +2 -0
- package/dist/devices/access.module.js +19 -0
- package/dist/devices/conversation-devices.d.ts +8 -29
- package/dist/devices/conversation-devices.js +37 -73
- package/dist/devices/device-projects.service.d.ts +26 -28
- package/dist/devices/device-projects.service.js +123 -127
- package/dist/devices/devices.controller.js +3 -1
- package/dist/devices/devices.module.js +11 -9
- package/dist/devices/devices.service.d.ts +116 -8
- package/dist/devices/devices.service.js +252 -20
- package/dist/devices/dto.d.ts +16 -0
- package/dist/devices/dto.js +34 -6
- package/dist/devices/errors.d.ts +8 -0
- package/dist/devices/errors.js +10 -0
- package/dist/devices/project-rules.d.ts +44 -0
- package/dist/devices/project-rules.js +27 -0
- package/dist/devices/working-root.d.ts +6 -0
- package/dist/devices/working-root.js +12 -1
- package/dist/errors.d.ts +31 -0
- package/dist/errors.js +31 -0
- package/dist/evals/reconstruct.d.ts +19 -2
- package/dist/evals/reconstruct.js +40 -2
- package/dist/evals/recorded-permission-context.d.ts +77 -0
- package/dist/evals/recorded-permission-context.js +151 -0
- package/dist/evals/recorded-tools.d.ts +10 -1
- package/dist/evals/recorded-tools.js +27 -3
- package/dist/evals/run-replay.d.ts +8 -2
- package/dist/evals/run-replay.js +18 -2
- package/dist/evals/trajectory.d.ts +1 -1
- package/dist/evals/worker.d.ts +10 -1
- package/dist/evals/worker.js +23 -14
- package/dist/http/api.module.js +2 -0
- package/dist/identity/accounts.d.ts +14 -1
- package/dist/identity/accounts.js +61 -5
- package/dist/identity/identity.module.js +2 -0
- package/dist/identity/settings.d.ts +28 -12
- package/dist/identity/settings.js +89 -33
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/dist/infra/cli/kernel-cli.module.d.ts +2 -2
- package/dist/infra/cli/kernel-cli.module.js +5 -2
- package/dist/infra/cli/permission-cutover.d.ts +59 -0
- package/dist/infra/cli/permission-cutover.js +107 -0
- package/dist/infra/config/kernel-config.service.d.ts +2 -2
- package/dist/infra/config/kernel-config.service.js +31 -11
- package/dist/infra/database/startup-activation-transaction.d.ts +36 -0
- package/dist/infra/database/startup-activation-transaction.js +242 -0
- package/dist/infra/database/transaction-host.d.ts +47 -0
- package/dist/infra/database/transaction-host.js +119 -0
- package/dist/infra/database/xact-lock.d.ts +1 -0
- package/dist/infra/database/xact-lock.js +6 -0
- package/dist/infra/outbox/registry.d.ts +39 -0
- package/dist/infra/outbox/registry.js +18 -0
- package/dist/kernel.module.js +2 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +3 -1
- package/dist/lifecycle/kernel-lifecycle.js +55 -28
- package/dist/local-devices/device-auth.js +1 -1
- package/dist/local-devices/device-policy.service.d.ts +35 -5
- package/dist/local-devices/device-policy.service.js +188 -13
- package/dist/local-devices/instance-bindings.d.ts +82 -0
- package/dist/local-devices/instance-bindings.js +304 -0
- package/dist/local-devices/keys.d.ts +5 -0
- package/dist/local-devices/keys.js +5 -0
- package/dist/local-devices/local-device-gateway.d.ts +19 -4
- package/dist/local-devices/local-device-gateway.js +185 -17
- package/dist/local-devices/local-device-provider.d.ts +42 -7
- package/dist/local-devices/local-device-provider.js +185 -10
- package/dist/local-devices/local-devices.module.d.ts +17 -2
- package/dist/local-devices/local-devices.module.js +49 -8
- package/dist/local-devices/machines.d.ts +35 -12
- package/dist/local-devices/machines.js +203 -8
- package/dist/local-devices/network-grants.js +3 -3
- package/dist/local-devices/network-grants.module.d.ts +2 -0
- package/dist/local-devices/network-grants.module.js +14 -0
- package/dist/local-devices/owner-report.d.ts +79 -0
- package/dist/local-devices/owner-report.js +155 -0
- package/dist/local-devices/owner-reports.d.ts +48 -0
- package/dist/local-devices/owner-reports.js +190 -0
- package/dist/local-devices/policy-summary.d.ts +24 -1
- package/dist/local-devices/policy-summary.js +48 -0
- package/dist/local-devices/relay.d.ts +82 -6
- package/dist/local-devices/relay.js +187 -16
- package/dist/local-devices/targets.d.ts +16 -1
- package/dist/local-devices/targets.js +35 -2
- package/dist/orgs/cloud-network-setting.d.ts +33 -0
- package/dist/orgs/cloud-network-setting.js +47 -0
- package/dist/orgs/offboarding.d.ts +3 -1
- package/dist/orgs/offboarding.js +8 -2
- package/dist/orgs/org-lock.d.ts +10 -4
- package/dist/orgs/org-lock.js +10 -4
- package/dist/orgs/orgs.service.d.ts +3 -1
- package/dist/orgs/orgs.service.js +8 -2
- package/dist/orgs/settings.controller.d.ts +4 -1
- package/dist/orgs/settings.controller.js +3 -3
- package/dist/orgs/settings.service.d.ts +48 -56
- package/dist/orgs/settings.service.js +144 -101
- package/dist/overrides.d.ts +6 -1
- package/dist/overrides.js +2 -0
- package/dist/platform/exclusions.js +20 -0
- package/dist/platform/ops/admin.ops.js +14 -11
- package/dist/platform/ops/agent-skills.ops.js +2 -0
- package/dist/platform/ops/devices.ops.js +10 -2
- package/dist/platform/ops/org-settings.ops.js +6 -6
- package/dist/platform/ops/orgs.ops.js +1 -0
- package/dist/roles/worker.module.js +4 -0
- package/dist/runtime/context/build.d.ts +3 -1
- package/dist/runtime/context/build.js +19 -3
- package/dist/runtime/context/compaction.js +5 -0
- package/dist/runtime/context/device-paths.d.ts +9 -2
- package/dist/runtime/context/device-paths.js +20 -0
- package/dist/runtime/context/permission-profile.d.ts +46 -0
- package/dist/runtime/context/permission-profile.js +194 -0
- package/dist/runtime/maintenance.d.ts +7 -1
- package/dist/runtime/maintenance.js +43 -15
- package/dist/runtime/model-call.d.ts +32 -0
- package/dist/runtime/model-call.js +67 -0
- package/dist/runtime/permission-context-errors.d.ts +39 -0
- package/dist/runtime/permission-context-errors.js +67 -0
- package/dist/runtime/permission-context.service.d.ts +60 -0
- package/dist/runtime/permission-context.service.js +286 -0
- package/dist/runtime/project/knowledge.d.ts +7 -2
- package/dist/runtime/project/knowledge.js +5 -2
- package/dist/runtime/project/knowledge.service.d.ts +17 -2
- package/dist/runtime/project/knowledge.service.js +76 -12
- package/dist/runtime/run-execution.d.ts +4 -1
- package/dist/runtime/run-execution.js +14 -5
- package/dist/runtime/run-steps.d.ts +11 -3
- package/dist/runtime/run-steps.js +27 -4
- package/dist/runtime/runtime.module.js +11 -0
- package/dist/sandbox/attachments-path.d.ts +15 -0
- package/dist/sandbox/attachments-path.js +15 -0
- package/dist/sandbox/cloud-permission-snapshot.d.ts +159 -0
- package/dist/sandbox/cloud-permission-snapshot.js +407 -0
- package/dist/sandbox/cloud-permission-snapshot.module.d.ts +8 -0
- package/dist/sandbox/cloud-permission-snapshot.module.js +34 -0
- package/dist/sandbox/held-operations.d.ts +39 -0
- package/dist/sandbox/held-operations.js +119 -0
- package/dist/sandbox/jobs.d.ts +14 -3
- package/dist/sandbox/jobs.js +20 -2
- package/dist/sandbox/kernel-read.d.ts +55 -0
- package/dist/sandbox/kernel-read.js +57 -0
- package/dist/sandbox/legacy-retirement.d.ts +336 -0
- package/dist/sandbox/legacy-retirement.js +1063 -0
- package/dist/sandbox/legacy-retirement.module.d.ts +8 -0
- package/dist/sandbox/legacy-retirement.module.js +25 -0
- package/dist/sandbox/managed-device-context.d.ts +94 -0
- package/dist/sandbox/managed-device-context.js +308 -0
- package/dist/sandbox/managed-device-context.module.d.ts +6 -0
- package/dist/sandbox/managed-device-context.module.js +33 -0
- package/dist/sandbox/modes.d.ts +56 -8
- package/dist/sandbox/modes.js +92 -8
- package/dist/sandbox/operation-authority-types.d.ts +8 -0
- package/dist/sandbox/operation-authority-types.js +32 -0
- package/dist/sandbox/operation-authority.d.ts +145 -0
- package/dist/sandbox/operation-authority.js +783 -0
- package/dist/sandbox/operation-authority.module.d.ts +2 -0
- package/dist/sandbox/operation-authority.module.js +29 -0
- package/dist/sandbox/operation-intents.d.ts +206 -0
- package/dist/sandbox/operation-intents.js +1252 -0
- package/dist/sandbox/operation-intents.module.d.ts +2 -0
- package/dist/sandbox/operation-intents.module.js +21 -0
- package/dist/sandbox/operation-payloads.d.ts +33 -0
- package/dist/sandbox/operation-payloads.js +332 -0
- package/dist/sandbox/operation-reconcile.job.d.ts +49 -0
- package/dist/sandbox/operation-reconcile.job.js +247 -0
- package/dist/sandbox/permission-authority-epochs.d.ts +18 -0
- package/dist/sandbox/permission-authority-epochs.js +83 -0
- package/dist/sandbox/permission-authority-lock.d.ts +38 -0
- package/dist/sandbox/permission-authority-lock.js +147 -0
- package/dist/sandbox/permission-authority.module.d.ts +9 -0
- package/dist/sandbox/permission-authority.module.js +55 -0
- package/dist/sandbox/permission-availability.d.ts +18 -0
- package/dist/sandbox/permission-availability.js +19 -0
- package/dist/sandbox/permission-call-grants.d.ts +34 -0
- package/dist/sandbox/permission-call-grants.js +349 -0
- package/dist/sandbox/permission-call-grants.module.d.ts +2 -0
- package/dist/sandbox/permission-call-grants.module.js +21 -0
- package/dist/sandbox/permission-call-types.d.ts +82 -0
- package/dist/sandbox/permission-call-types.js +1 -0
- package/dist/sandbox/permission-ceiling-writes.d.ts +47 -0
- package/dist/sandbox/permission-ceiling-writes.js +223 -0
- package/dist/sandbox/permission-config-publication.d.ts +76 -0
- package/dist/sandbox/permission-config-publication.js +339 -0
- package/dist/sandbox/permission-context-types.d.ts +64 -0
- package/dist/sandbox/permission-context-types.js +24 -0
- package/dist/sandbox/permission-facts.d.ts +206 -0
- package/dist/sandbox/permission-facts.js +627 -0
- package/dist/sandbox/permission-facts.module.d.ts +2 -0
- package/dist/sandbox/permission-facts.module.js +20 -0
- package/dist/sandbox/permission-instance-writes.d.ts +90 -0
- package/dist/sandbox/permission-instance-writes.js +305 -0
- package/dist/sandbox/permission-runtime-reports.d.ts +83 -0
- package/dist/sandbox/permission-runtime-reports.js +354 -0
- package/dist/sandbox/permission-transitions.d.ts +31 -0
- package/dist/sandbox/permission-transitions.js +155 -0
- package/dist/sandbox/platform-full-access.d.ts +128 -0
- package/dist/sandbox/platform-full-access.js +210 -0
- package/dist/sandbox/providers.d.ts +22 -0
- package/dist/sandbox/providers.js +10 -2
- package/dist/sandbox/providers.module.d.ts +2 -0
- package/dist/sandbox/providers.module.js +19 -0
- package/dist/sandbox/request-not-sent.d.ts +13 -0
- package/dist/sandbox/request-not-sent.js +13 -0
- package/dist/sandbox/review/classifier.d.ts +2 -0
- package/dist/sandbox/review/classifier.js +8 -0
- package/dist/sandbox/review/permission-candidate.d.ts +12 -0
- package/dist/sandbox/review/permission-candidate.js +129 -0
- package/dist/sandbox/review/review.service.d.ts +4 -1
- package/dist/sandbox/review/review.service.js +19 -5
- package/dist/sandbox/sandbox-file-reader.d.ts +18 -1
- package/dist/sandbox/sandbox-file-reader.js +51 -7
- package/dist/sandbox/sandbox.module.js +26 -6
- package/dist/sandbox/sandbox.service.d.ts +230 -34
- package/dist/sandbox/sandbox.service.js +1368 -199
- package/dist/sandbox/unreachable.js +17 -3
- package/dist/sandbox/use-context.d.ts +17 -0
- package/dist/sandbox/use-context.js +1 -0
- package/dist/skills/invoke.d.ts +27 -4
- package/dist/skills/invoke.js +72 -7
- package/dist/tools/approvals.controller.d.ts +1 -0
- package/dist/tools/approvals.schemas.d.ts +1 -0
- package/dist/tools/approvals.schemas.js +3 -1
- package/dist/tools/approvals.service.d.ts +23 -10
- package/dist/tools/approvals.service.js +104 -26
- package/dist/tools/builtins/builtin-tools.d.ts +16 -2
- package/dist/tools/builtins/builtin-tools.js +38 -10
- package/dist/tools/builtins/sandbox/bash.d.ts +25 -1
- package/dist/tools/builtins/sandbox/bash.js +201 -5
- package/dist/tools/builtins/sandbox/common.d.ts +92 -20
- package/dist/tools/builtins/sandbox/common.js +201 -17
- package/dist/tools/builtins/sandbox/deliver.js +2 -2
- package/dist/tools/builtins/sandbox/edit.js +2 -2
- package/dist/tools/builtins/sandbox/fetch-attachment.js +11 -4
- package/dist/tools/builtins/sandbox/glob.js +2 -2
- package/dist/tools/builtins/sandbox/grep.js +2 -2
- package/dist/tools/builtins/sandbox/read.js +2 -2
- package/dist/tools/builtins/sandbox/task-list.js +7 -1
- package/dist/tools/builtins/sandbox/task-output.d.ts +1 -1
- package/dist/tools/builtins/sandbox/task-output.js +172 -0
- package/dist/tools/builtins/sandbox/task-stop.js +25 -3
- package/dist/tools/builtins/sandbox/write.js +2 -2
- package/dist/tools/builtins/skill-load.js +9 -6
- package/dist/tools/device-op-resolver.d.ts +1 -1
- package/dist/tools/device-op-resolver.js +13 -3
- package/dist/tools/permission-approval-jobs.d.ts +18 -0
- package/dist/tools/permission-approval-jobs.js +92 -0
- package/dist/tools/pipeline.d.ts +17 -2
- package/dist/tools/pipeline.js +300 -19
- package/dist/tools/registry.d.ts +9 -0
- package/dist/tools/tools.module.js +12 -0
- package/package.json +4 -3
- package/src/migrations/0146_permission_authority_epochs.sql +6 -0
- package/src/migrations/0147_conversation_permission_profiles.sql +4 -0
- package/src/migrations/0148_first_message_request_hash.sql +2 -0
- package/src/migrations/0149_sandbox_operation_intents.sql +66 -0
- package/src/migrations/0150_permission_call_grants_and_approvals.sql +36 -0
- package/src/migrations/0151_starting_execution_grants.sql +8 -0
- package/src/migrations/0152_background_launch_identity.sql +66 -0
- package/src/migrations/0153_background_cancel_requester.sql +13 -0
- package/src/migrations/0154_cloud_owner_ceiling.sql +14 -0
- package/src/migrations/0155_device_instance_generations.sql +30 -0
- package/src/migrations/0156_device_owner_report.sql +7 -0
- package/src/migrations/0157_legacy_retirement.sql +116 -0
- package/src/migrations/0158_legacy_freeze_enumerated.sql +5 -0
- package/src/migrations/0159_retirement_exact_cancel.sql +9 -0
- package/dist/sandbox/platform-auto-mode.d.ts +0 -63
- package/dist/sandbox/platform-auto-mode.js +0 -63
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { DEFAULT_SANDBOX_ROOTS, ToolError, } from "@capybara-hq/plugin-sdk";
|
|
2
|
-
import { backgroundMaxSeconds, LAUNCH_EXEC_TIMEOUT_MS, launchScript, newTaskId, startedText, taskOutputPath, taskSidPath, } from "../../../background/launch.js";
|
|
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
3
|
import { KILL_SESSION_TIMEOUT_MS, killSession, SID_RE } from "../../../background/session.js";
|
|
4
|
-
import {
|
|
4
|
+
import { runOutsideTransaction } from "../../../infra/database/transaction-host.js";
|
|
5
|
+
import { isDeviceRequestNotSent } from "../../../local-devices/relay.js";
|
|
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";
|
|
5
8
|
import { parseDeviceCode } from "./device-code.js";
|
|
6
9
|
/** The command timeout in seconds when `timeout` is not given, at most `sandbox.limits.maxCommandSeconds`. */
|
|
7
10
|
export const BASH_DEFAULT_TIMEOUT_SECONDS = 120;
|
|
@@ -225,6 +228,27 @@ async function runInBackground(deps, ctx, input) {
|
|
|
225
228
|
const v = f ? new TextDecoder().decode(f.data).trim() : "";
|
|
226
229
|
return SID_RE.test(v) ? v : null;
|
|
227
230
|
};
|
|
231
|
+
// immediately before the dispatch (0157): refused once the legacy-launch freeze is
|
|
232
|
+
// published, else the reservation is marked as possibly dispatched in the same step
|
|
233
|
+
const legacyLaunch = deps.legacyLaunch;
|
|
234
|
+
if (legacyLaunch) {
|
|
235
|
+
// under the shared lease: the incarnation the launch dispatches into, exactly (I2)
|
|
236
|
+
const at = await currentInstance(deviceId);
|
|
237
|
+
const admission = await runOutsideTransaction(() => legacyLaunch.admitLegacyDispatch(ctx.orgId, id, {
|
|
238
|
+
provider: at?.provider ?? "unknown",
|
|
239
|
+
generation: at ? String(at.createdAt.getTime()) : "unknown",
|
|
240
|
+
}));
|
|
241
|
+
if (admission === "frozen")
|
|
242
|
+
return {
|
|
243
|
+
kind: "not_started",
|
|
244
|
+
why: "background tasks are being upgraded on this deployment and cannot be started with the old launcher",
|
|
245
|
+
};
|
|
246
|
+
if (admission === "gone")
|
|
247
|
+
return {
|
|
248
|
+
kind: "not_started",
|
|
249
|
+
why: "its task record was finished meanwhile",
|
|
250
|
+
};
|
|
251
|
+
}
|
|
228
252
|
let r;
|
|
229
253
|
try {
|
|
230
254
|
r = await p.exec(h, {
|
|
@@ -334,6 +358,174 @@ async function runInBackground(deps, ctx, input) {
|
|
|
334
358
|
display: display(`后台运行命令:${shown}`, `Started in the background: ${shown}`),
|
|
335
359
|
};
|
|
336
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* Managed `Bash` background launch (permission runtime cutover phase 8.2): the tool's background
|
|
363
|
+
* path once the one activation gate is on (B-17); while it is off the protocol-2 launch above
|
|
364
|
+
* stays the active path.
|
|
365
|
+
*
|
|
366
|
+
* Inside the held operation session it reserves the task (or, for a retry of the same run call,
|
|
367
|
+
* reuses the reservation it persisted before: the same task id, artifact, deadline and
|
|
368
|
+
* retention, so the start input and its hash are unchanged), with its artifact at
|
|
369
|
+
* `${workingRoot}/.capybara/tasks/${taskId}.out` under the trusted working root. The start then
|
|
370
|
+
* goes through the operation facade: admitted, bound to the reservation and dispatched under the
|
|
371
|
+
* stable operation id, and acknowledged with its exact typed ref. The output path is told to the
|
|
372
|
+
* model only after the acknowledgement. A refusal before dispatch settles the reservation; an
|
|
373
|
+
* unknown outcome leaves it dispatched for reconciliation under the same identity.
|
|
374
|
+
*/
|
|
375
|
+
export async function runInBackgroundManaged(deps, ctx, input) {
|
|
376
|
+
const { background } = deps;
|
|
377
|
+
const claim = ctx.executionClaim;
|
|
378
|
+
if (!background?.reserveManaged || !background.failManagedPreEffect || !claim || !ctx.runId) {
|
|
379
|
+
throw new ToolError("Background tasks are not available here; call Bash without run_in_background.");
|
|
380
|
+
}
|
|
381
|
+
const reserveManaged = background.reserveManaged.bind(background);
|
|
382
|
+
const failManagedPreEffect = background.failManagedPreEffect.bind(background);
|
|
383
|
+
const cfg = deps.config.get();
|
|
384
|
+
const maxMs = backgroundMaxSeconds(cfg) * 1000;
|
|
385
|
+
const requested = input.timeout;
|
|
386
|
+
const seconds = Math.max(1, Math.ceil(Math.min(requested ?? maxMs, maxMs) / 1000));
|
|
387
|
+
const root = sandboxConversationOf(ctx);
|
|
388
|
+
const maxTasks = cfg.sandbox.background.maxTasks;
|
|
389
|
+
const description = input.description ?? clip(input.command, 120);
|
|
390
|
+
// The facade derives the same id from this call's first dispatched method.
|
|
391
|
+
const operationId = operationIdFor({ claim, callId: ctx.callId, ordinal: 0 });
|
|
392
|
+
const announce = async () => {
|
|
393
|
+
if (!deps.eventLog.publishChanged)
|
|
394
|
+
return;
|
|
395
|
+
for (const c of new Set([ctx.conversationId, root])) {
|
|
396
|
+
await deps.eventLog.publishChanged(c, "background");
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
const { value: launch, notices } = await inSandboxOperations(deps, ctx, async (s) => {
|
|
400
|
+
const start = s.p.backgroundStart?.bind(s.p);
|
|
401
|
+
if (!start) {
|
|
402
|
+
throw new ToolError("Background tasks are not available on this device; call Bash without run_in_background.");
|
|
403
|
+
}
|
|
404
|
+
const id = newTaskId();
|
|
405
|
+
const startedAt = new Date();
|
|
406
|
+
const deadlineAt = new Date(startedAt.getTime() + seconds * 1000);
|
|
407
|
+
const reserved = await reserveManaged({
|
|
408
|
+
id,
|
|
409
|
+
orgId: ctx.orgId,
|
|
410
|
+
conversationId: ctx.conversationId,
|
|
411
|
+
sandboxConversationId: root,
|
|
412
|
+
deviceId: s.deviceId,
|
|
413
|
+
runId: ctx.runId,
|
|
414
|
+
callId: ctx.callId,
|
|
415
|
+
triggerAccountId: ctx.accountId,
|
|
416
|
+
description,
|
|
417
|
+
command: input.command,
|
|
418
|
+
operationId,
|
|
419
|
+
workingRoot: s.workingRoot,
|
|
420
|
+
outputPath: managedTaskArtifactPath(s.workingRoot, id),
|
|
421
|
+
startedAt,
|
|
422
|
+
deadlineAt,
|
|
423
|
+
retainUntil: new Date(deadlineAt.getTime() + cfg.tools.outputRetentionDays * 86_400_000),
|
|
424
|
+
}, maxTasks);
|
|
425
|
+
if (reserved.kind === "full")
|
|
426
|
+
return { kind: "full" };
|
|
427
|
+
const task = reserved.row;
|
|
428
|
+
if (task.command !== input.command ||
|
|
429
|
+
task.workingRoot !== s.workingRoot ||
|
|
430
|
+
task.operationId !== operationId)
|
|
431
|
+
return { kind: "changed" };
|
|
432
|
+
if (task.launchState === "terminal" || task.retainUntil === null || task.workingRoot === null)
|
|
433
|
+
return { kind: "launched", task };
|
|
434
|
+
try {
|
|
435
|
+
await start(s.h, {
|
|
436
|
+
command: input.command,
|
|
437
|
+
cwd: task.workingRoot,
|
|
438
|
+
timeoutMs: task.deadlineAt.getTime() - task.startedAt.getTime(),
|
|
439
|
+
maxOutputBytes: LAUNCH_MAX_OUTPUT_BYTES,
|
|
440
|
+
taskId: task.id,
|
|
441
|
+
outputPath: task.outputPath,
|
|
442
|
+
retainUntilMs: task.retainUntil.getTime(),
|
|
443
|
+
signal: s.signal,
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
catch (e) {
|
|
447
|
+
// kernel-written text only: the provider's message is logged, never shown to the model
|
|
448
|
+
const why = launchRefusedWhy(e);
|
|
449
|
+
deps.log?.warn("managed background start failed", { taskId: task.id, err: e });
|
|
450
|
+
// a reservation that never dispatched is settled; a dispatched one never is here
|
|
451
|
+
if (await failManagedPreEffect(task.id, `launch refused: ${why}`, claim.executionId)) {
|
|
452
|
+
return {
|
|
453
|
+
kind: "refused",
|
|
454
|
+
task: (await background.get(task.id)) ?? task,
|
|
455
|
+
why,
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
const now = (await background.get(task.id)) ?? task;
|
|
459
|
+
if (now.launchState === "dispatched" && !isRefusal(e))
|
|
460
|
+
return { kind: "unknown", task: now };
|
|
461
|
+
// a dispatched start the provider refused was settled with it: the kernel's reason
|
|
462
|
+
if (now.launchState === "terminal" && isRefusal(e))
|
|
463
|
+
return { kind: "refused", task: now, why };
|
|
464
|
+
return { kind: "launched", task: now };
|
|
465
|
+
}
|
|
466
|
+
return {
|
|
467
|
+
kind: "launched",
|
|
468
|
+
task: (await background.get(task.id)) ?? task,
|
|
469
|
+
};
|
|
470
|
+
});
|
|
471
|
+
if (launch.kind === "full") {
|
|
472
|
+
throw new ToolError(`${maxTasks} background tasks are already running; stop one with TaskStop or wait for one to finish, then retry`);
|
|
473
|
+
}
|
|
474
|
+
if (launch.kind === "changed") {
|
|
475
|
+
throw new ToolError("This call already reserved a background task with a different command or working directory; it cannot be reused with changed input. Call Bash again as a new call.");
|
|
476
|
+
}
|
|
477
|
+
await announce();
|
|
478
|
+
const { task } = launch;
|
|
479
|
+
if (launch.kind === "unknown") {
|
|
480
|
+
throw new ToolError(`Background task ${task.id} ("${description}") may have started, but its start was not confirmed; it is being reconciled under its original identity and will not be started again. Check TaskList before starting it again.`, { kind: "unavailable" });
|
|
481
|
+
}
|
|
482
|
+
// a retry of a call whose acknowledged task has since ended reports the start it made
|
|
483
|
+
const started = task.executionRef !== null &&
|
|
484
|
+
(task.launchState === "acknowledged" || task.status !== "running");
|
|
485
|
+
if (!started && (launch.kind === "refused" || task.launchState === "terminal")) {
|
|
486
|
+
// the recorded reason may hold a provider's words: the model gets kernel text only
|
|
487
|
+
const why = launch.kind === "refused" ? launch.why : "it was stopped or refused before it started";
|
|
488
|
+
throw new ToolError(`The background task was not started: ${why}. Nothing runs; fix the cause, or call Bash without run_in_background.`);
|
|
489
|
+
}
|
|
490
|
+
if (!started && task.launchState === "cancel-pending" && task.executionRef !== null) {
|
|
491
|
+
// the device acknowledged the start; a stop, while or after it started, is being applied
|
|
492
|
+
throw new ToolError(`Background task ${task.id} ("${description}") is being stopped: a stop was asked for while or after it started, and its cancellation is in progress. Call TaskOutput to see when it has ended, or call Bash again as a new call if it is still needed.`);
|
|
493
|
+
}
|
|
494
|
+
if (!started && task.launchState === "cancel-pending") {
|
|
495
|
+
throw new ToolError(`Background task ${task.id} ("${description}") was stopped while it was starting; its cancellation is in progress. Call Bash again if it is still needed.`);
|
|
496
|
+
}
|
|
497
|
+
if (!started) {
|
|
498
|
+
throw new ToolError(`Background task ${task.id} ("${description}") may have started, but its start was not confirmed; it will not be started again. Check TaskList before starting it again.`, { kind: "unavailable" });
|
|
499
|
+
}
|
|
500
|
+
const lowered = requested !== undefined && requested > maxMs
|
|
501
|
+
? `\n[timeout ${requested} ms is over the background task maximum; it was lowered to ${maxMs} ms.]`
|
|
502
|
+
: "";
|
|
503
|
+
const shown = clip(input.command, 120);
|
|
504
|
+
return {
|
|
505
|
+
content: [
|
|
506
|
+
{
|
|
507
|
+
type: "text",
|
|
508
|
+
text: withNotices(notices, managedStartedText(task.id, description, task.outputPath) + lowered),
|
|
509
|
+
},
|
|
510
|
+
],
|
|
511
|
+
isError: false,
|
|
512
|
+
view: { kind: "command", description, exitCode: null, timedOut: false },
|
|
513
|
+
display: display(`后台运行命令:${shown}`, `Started in the background: ${shown}`),
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
/** Why a managed start was refused, in the kernel's own words (never the provider's message). */
|
|
517
|
+
function launchRefusedWhy(e) {
|
|
518
|
+
return launchRefusedText(isDeviceRequestNotSent(e)
|
|
519
|
+
? "not_sent"
|
|
520
|
+
: isSandboxScopeDeniedError(e)
|
|
521
|
+
? "denied"
|
|
522
|
+
: isSandboxPermissionUnsupportedError(e)
|
|
523
|
+
? "unsupported"
|
|
524
|
+
: undefined);
|
|
525
|
+
}
|
|
526
|
+
/** A typed refusal: the provider or admission proved the start had no effect. */
|
|
527
|
+
const isRefusal = (e) => !isSandboxOperationOutcomeUnknownError(e) &&
|
|
528
|
+
(isSandboxScopeDeniedError(e) || isSandboxPermissionUnsupportedError(e));
|
|
337
529
|
/**
|
|
338
530
|
* A background command's script, started in the conversation's working root: the launch itself
|
|
339
531
|
* runs in the workspace (its task files live under `.capybara/tasks` there), so for a bound
|
|
@@ -364,7 +556,11 @@ export function sandboxBashTool(deps) {
|
|
|
364
556
|
},
|
|
365
557
|
async run(input, ctx) {
|
|
366
558
|
if (input.run_in_background === true) {
|
|
367
|
-
|
|
559
|
+
// once the activation gate is on, only the managed launch (B-17): the legacy launch
|
|
560
|
+
// would refuse before entering
|
|
561
|
+
return deps.managedDeviceContextRequired
|
|
562
|
+
? runInBackgroundManaged(deps, ctx, input)
|
|
563
|
+
: runInBackground(deps, ctx, input);
|
|
368
564
|
}
|
|
369
565
|
const { command, description } = input;
|
|
370
566
|
const max = deps.config.get().sandbox.limits.maxCommandSeconds;
|
|
@@ -377,7 +573,7 @@ export function sandboxBashTool(deps) {
|
|
|
377
573
|
let workspace = DEFAULT_SANDBOX_ROOTS.workspace;
|
|
378
574
|
// the device the command ran on (a refused network host is asked about there)
|
|
379
575
|
let deviceId = "";
|
|
380
|
-
const { value: r, notices } = await
|
|
576
|
+
const { value: r, notices } = await inToolSandbox(deps, ctx, (s) => {
|
|
381
577
|
const left = Math.floor(runTimeLeftMs(ctx.runDeadline) / 1000) * 1000;
|
|
382
578
|
ms = Math.max(1000, Math.min(askedMs, left));
|
|
383
579
|
workspace = s.roots.workspace;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Logger, type SandboxHandle, type SandboxRoots, ToolError } from "@capybara-hq/plugin-sdk";
|
|
1
|
+
import { type Logger, type SandboxHandle, type SandboxPreparation, type SandboxPreparationScope, type SandboxRoots, ToolError } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import type { BackgroundTaskFinisher } from "../../../background/finish.js";
|
|
3
3
|
import type { BackgroundTaskStopper } from "../../../background/stop.js";
|
|
4
4
|
import type { BackgroundTaskStore } from "../../../background/store.js";
|
|
@@ -8,7 +8,11 @@ import type { AttachmentsService } from "../../../conversations/attachments.serv
|
|
|
8
8
|
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
|
+
import { ATTACHMENTS_ROOT, attachmentsDir, attachmentsRoot } from "../../../sandbox/attachments-path.js";
|
|
12
|
+
import type { LegacyRetirementStore } from "../../../sandbox/legacy-retirement.js";
|
|
13
|
+
import { type ManagedDeviceContextPort } from "../../../sandbox/managed-device-context.js";
|
|
11
14
|
import type { SandboxMode } from "../../../sandbox/modes.js";
|
|
15
|
+
import type { HeldDeviceContextEvidence } from "../../../sandbox/permission-context-types.js";
|
|
12
16
|
import { type HeldProvider, type SandboxService } from "../../../sandbox/sandbox.service.js";
|
|
13
17
|
import type { StorageService } from "../../../storage/storage.service.js";
|
|
14
18
|
import type { BuiltinCallContext, ToolListingScope } from "../../registry.js";
|
|
@@ -19,16 +23,21 @@ export interface SandboxToolDeps {
|
|
|
19
23
|
* `currentInstance` too: a background `Bash` launch records the instance it started in; and
|
|
20
24
|
* `ifRunning`, which `TaskOutput` reads a task through.
|
|
21
25
|
*/
|
|
22
|
-
sandbox: Pick<SandboxService, "cloudAvailable" | "availableFor" | "withSandbox"> & Partial<Pick<SandboxService, "pathLease" | "currentInstance" | "ifRunning">>;
|
|
26
|
+
sandbox: Pick<SandboxService, "cloudAvailable" | "availableFor" | "withSandbox"> & Partial<Pick<SandboxService, "pathLease" | "currentInstance" | "ifRunning" | "withOperations">>;
|
|
23
27
|
/**
|
|
24
28
|
* The device a call enters: the root conversation's, checked for its owner every call.
|
|
25
29
|
* `usableNow` (absent in test stubs: only the cloud provider counts) tells a listing whether a
|
|
26
30
|
* conversation's device can run without a cloud provider (ruling R8). `workingFacts` (absent
|
|
27
31
|
* in test stubs: free mode) gives what decides the working root, read as the review reads it.
|
|
28
32
|
*/
|
|
29
|
-
devices: Pick<ConversationDevices, "forTool"> & Partial<Pick<ConversationDevices, "usableNow" | "modeLevel" | "workingFacts">>;
|
|
33
|
+
devices: Pick<ConversationDevices, "forTool"> & Partial<Pick<ConversationDevices, "usableNow" | "modeLevel" | "workingFacts" | "projectReach">>;
|
|
30
34
|
/** Background `Bash` tasks; absent in test stubs, where `run_in_background` is refused. */
|
|
31
|
-
background?: Pick<BackgroundTaskStore, "reserve" | "markStarted" | "failLaunch" | "finishStoppedLaunch" | "releaseStop" | "get" | "advanceOffset" | "runningOwnedBy" | "finishedOwnedBy"
|
|
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">;
|
|
32
41
|
/**
|
|
33
42
|
* Whether `id` is a sub-agent conversation in the tree under `rootConversationId` (TaskOutput /
|
|
34
43
|
* TaskStop tell a sub-agent's agentId apart from an unknown task id), and the sub-agents a
|
|
@@ -52,10 +61,21 @@ export interface SandboxToolDeps {
|
|
|
52
61
|
* `publishChanged`: `Deliver` announces `changed: files` (UI refresh B). `latestOfType` reads the
|
|
53
62
|
* conversation's latest `device_paths` (absent in test stubs, which record none).
|
|
54
63
|
*/
|
|
55
|
-
eventLog: Pick<EventLog, "append" | "latestFileState"> & Partial<Pick<EventLog, "publishChanged" | "latestOfType">>;
|
|
64
|
+
eventLog: Pick<EventLog, "append" | "latestFileState"> & Partial<Pick<EventLog, "publishChanged" | "latestOfType" | "findByIdem">>;
|
|
56
65
|
config: Pick<KernelConfigService, "get">;
|
|
57
66
|
/** Where a mapped provider failure keeps its raw error (warn); absent in test stubs. */
|
|
58
67
|
log?: Pick<Logger, "warn">;
|
|
68
|
+
/**
|
|
69
|
+
* The managed device context writer (permission context replay spec B3): on the managed route it
|
|
70
|
+
* records the marked device paths before any preparation or user callback, instead of the legacy
|
|
71
|
+
* `device_paths` writer. Absent while dormant (the legacy writer stays on unactivated routes).
|
|
72
|
+
*/
|
|
73
|
+
managedDeviceContext?: ManagedDeviceContextPort;
|
|
74
|
+
/**
|
|
75
|
+
* The paired activation (`PERMISSION_CONTEXT_ACTIVATION`): the managed route then requires
|
|
76
|
+
* {@link managedDeviceContext} and refuses before entering without it.
|
|
77
|
+
*/
|
|
78
|
+
managedDeviceContextRequired?: boolean;
|
|
59
79
|
}
|
|
60
80
|
/**
|
|
61
81
|
* The sandbox a callback gets: the instance handle, the provider (every `exec` carries the
|
|
@@ -113,15 +133,7 @@ export declare const SANDBOX_CONNECTION_DROPPED_TEXT = "The connection to the sa
|
|
|
113
133
|
export declare const SANDBOX_OPEN_NETWORK_REFUSED_TEXT = "The cloud sandbox provider refused to give this device the open public network, so nothing ran in the sandbox and retrying won't help. Ask the person to switch this device to sandbox mode and have an org admin switch the organization's cloud network to an allowlist, or have a super admin use a sandbox provider that offers the open network. Continue without the sandbox meanwhile.";
|
|
114
134
|
/** A cloud provider failed to create the device's sandbox otherwise (`sandbox.create_failed`). */
|
|
115
135
|
export declare const SANDBOX_CREATE_FAILED_TEXT = "The cloud sandbox provider could not create this device's sandbox, so nothing ran in it. Retry once; if it fails again, continue without the sandbox and ask the person to have a super admin check the sandbox extension's settings (Admin console \u2192 Extensions).";
|
|
116
|
-
|
|
117
|
-
export declare const attachmentsRoot: (roots: SandboxRoots) => string;
|
|
118
|
-
/** {@link attachmentsRoot} of an instance with the default roots. */
|
|
119
|
-
export declare const ATTACHMENTS_ROOT: string;
|
|
120
|
-
/**
|
|
121
|
-
* One conversation's attachment directory: the first 12 hex digits of the root conversation's
|
|
122
|
-
* UUID, so conversations sharing a device do not overwrite each other's files.
|
|
123
|
-
*/
|
|
124
|
-
export declare const attachmentsDir: (roots: SandboxRoots, rootConversationId: string) => string;
|
|
136
|
+
export { ATTACHMENTS_ROOT, attachmentsDir, attachmentsRoot };
|
|
125
137
|
/** 附件文件名的上限(UTF-8 字节,常见文件系统单个文件名上限 255 字节,留出 `-N` 后缀的余量)。 */
|
|
126
138
|
export declare const ATTACHMENT_NAME_MAX_BYTES = 200;
|
|
127
139
|
/**
|
|
@@ -209,13 +221,33 @@ export declare function assignAttachmentNames(items: readonly {
|
|
|
209
221
|
id: string;
|
|
210
222
|
name: string;
|
|
211
223
|
}[], used: ReadonlySet<string>): Map<string, string>;
|
|
224
|
+
/** A trusted copy's session: the three preparation methods, scoped to the declared roots. */
|
|
225
|
+
export interface PreparationSession {
|
|
226
|
+
deviceId: string;
|
|
227
|
+
roots: SandboxRoots;
|
|
228
|
+
signal: AbortSignal;
|
|
229
|
+
p: SandboxPreparation;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Full access refused by policy (B-13: `org.*` / `deployment.*`, old and renamed codes): the
|
|
233
|
+
* organization or the platform has it off. The kernel's own message is never shown.
|
|
234
|
+
*/
|
|
235
|
+
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.";
|
|
236
|
+
/**
|
|
237
|
+
* The device's owner ceiling does not allow Full access (`device.full_access_not_allowed`).
|
|
238
|
+
*/
|
|
239
|
+
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.";
|
|
212
240
|
/**
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
* fixed text (providers never write model-visible text) with `kind: "unavailable"`, and its raw
|
|
216
|
-
* error is logged to `log` as a warning (the pipeline logs only errors it did not get as a
|
|
217
|
-
* `ToolError`).
|
|
241
|
+
* A managed operation outside the admitted scope (`SandboxScopeDeniedError`): fixed text, never
|
|
242
|
+
* the refusal's own message (a provider may write it).
|
|
218
243
|
*/
|
|
244
|
+
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.";
|
|
245
|
+
/** A staged request the machine never got: it reconnected before the request was sent. */
|
|
246
|
+
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.";
|
|
247
|
+
/** The device cannot enforce the conversation's profile (`SandboxPermissionUnsupportedError`). */
|
|
248
|
+
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.";
|
|
249
|
+
/** A managed operation whose outcome could not be confirmed (`SandboxOperationOutcomeUnknownError`). */
|
|
250
|
+
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.";
|
|
219
251
|
export declare function mapSandboxError(e: unknown, log: Pick<Logger, "warn"> | undefined): unknown;
|
|
220
252
|
/**
|
|
221
253
|
* Runs `fn` in the device of the call's conversation (a sub-agent: its root's): resolves and
|
|
@@ -232,13 +264,53 @@ export declare function inSandbox<T>(deps: SandboxToolDeps, ctx: BuiltinCallCont
|
|
|
232
264
|
value: T;
|
|
233
265
|
notices: string[];
|
|
234
266
|
}>;
|
|
267
|
+
/**
|
|
268
|
+
* The device entry of every builtin tool (B-17): once the one activation gate is on (the managed
|
|
269
|
+
* writer required, {@link SandboxToolDeps.managedDeviceContextRequired}) the managed operation
|
|
270
|
+
* route ({@link inSandboxOperations}: the marked device paths recorded before the callback, every
|
|
271
|
+
* provider call a managed operation); otherwise the legacy route ({@link inSandbox}), unchanged.
|
|
272
|
+
*/
|
|
273
|
+
export declare function inToolSandbox<T>(deps: SandboxToolDeps, ctx: BuiltinCallContext, fn: (s: SandboxSession) => Promise<T>): Promise<{
|
|
274
|
+
value: T;
|
|
275
|
+
notices: string[];
|
|
276
|
+
}>;
|
|
277
|
+
export declare function inSandboxOperations<T>(deps: SandboxToolDeps, ctx: BuiltinCallContext, fn: (s: SandboxSession) => Promise<T>, stage?: {
|
|
278
|
+
purpose: SandboxPreparationScope["purpose"];
|
|
279
|
+
roots: (roots: SandboxRoots) => readonly string[];
|
|
280
|
+
run: (s: PreparationSession) => Promise<void>;
|
|
281
|
+
}): Promise<{
|
|
282
|
+
value: T;
|
|
283
|
+
notices: string[];
|
|
284
|
+
}>;
|
|
285
|
+
/**
|
|
286
|
+
* Trusted copy callbacks only receive preparation's three methods. Once the activation gate is on
|
|
287
|
+
* the copy is a trusted preparation on the managed route ({@link inSandboxOperationPreparation},
|
|
288
|
+
* scoped to `roots`, after the marked device paths); otherwise the protocol-2 binding.
|
|
289
|
+
*/
|
|
290
|
+
export declare function inSandboxPreparation<T>(deps: SandboxToolDeps, ctx: BuiltinCallContext, purpose: SandboxPreparationScope["purpose"], roots: (roots: SandboxRoots) => readonly string[], fn: (s: PreparationSession) => Promise<T>): Promise<{
|
|
291
|
+
value: T;
|
|
292
|
+
notices: string[];
|
|
293
|
+
}>;
|
|
294
|
+
/** The trusted-copy entry on the managed route ({@link inSandboxPreparation} once activated). */
|
|
295
|
+
export declare function inSandboxOperationPreparation<T>(deps: SandboxToolDeps, ctx: BuiltinCallContext, purpose: SandboxPreparationScope["purpose"], roots: (roots: SandboxRoots) => readonly string[], fn: (s: PreparationSession) => Promise<T>): Promise<{
|
|
296
|
+
value: T;
|
|
297
|
+
notices: string[];
|
|
298
|
+
}>;
|
|
299
|
+
/**
|
|
300
|
+
* Records the managed device paths of the held instance `held` into the calling conversation (a
|
|
301
|
+
* sub-agent: its own log) for this call's run and actor: a thin delegator to the managed writer,
|
|
302
|
+
* which owns the transaction and all validation (permission context replay spec B3).
|
|
303
|
+
*/
|
|
304
|
+
export declare function recordManagedDevicePaths(deps: {
|
|
305
|
+
managedDeviceContext: ManagedDeviceContextPort;
|
|
306
|
+
}, ctx: BuiltinCallContext, held: Readonly<HeldDeviceContextEvidence>, signal: AbortSignal): Promise<void>;
|
|
235
307
|
/**
|
|
236
308
|
* The working root of a call: the project root exactly as the review decides it (from the same
|
|
237
309
|
* {@link WorkingFacts}); when that falls back to the device's workspace, the held instance's own
|
|
238
310
|
* workspace (`workspace`), where the call really runs. Every session built outside `inSandbox` (a
|
|
239
311
|
* person's project skill invocation) takes its working root from here too.
|
|
240
312
|
*/
|
|
241
|
-
export declare function sessionWorkingRoot(working: WorkingFacts | null, mode: SandboxMode, workspace: string): string;
|
|
313
|
+
export declare function sessionWorkingRoot(working: WorkingFacts | null, mode: SandboxMode, workspace: string, reach?: "workspace" | "os-user"): string;
|
|
242
314
|
/** The conversation whose device a call uses (the root conversation's for a sub-agent). */
|
|
243
315
|
export declare const sandboxConversationOf: (ctx: BuiltinCallContext) => string;
|
|
244
316
|
/**
|