@capybara-hq/kernel 0.1.0-rc.68 → 0.1.0-rc.69
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/dist/admin/admin.module.js +2 -0
- package/dist/admin/health.service.d.ts +11 -4
- package/dist/admin/health.service.js +33 -17
- package/dist/background/poll.job.js +2 -2
- package/dist/background/tasks.service.d.ts +5 -5
- package/dist/background/tasks.service.js +9 -8
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/requests.service.js +1 -1
- package/dist/config/schema.d.ts +1 -1
- package/dist/config/schema.js +9 -9
- package/dist/conversations/conversations.controller.d.ts +8 -3
- package/dist/conversations/conversations.controller.js +8 -3
- package/dist/conversations/conversations.service.d.ts +33 -15
- package/dist/conversations/conversations.service.js +60 -10
- package/dist/conversations/events.d.ts +21 -41
- package/dist/conversations/events.js +57 -31
- package/dist/conversations/permission-profiles.controller.d.ts +6 -4
- package/dist/conversations/permission-profiles.service.d.ts +6 -4
- package/dist/ctx/create-ctx.d.ts +20 -1
- package/dist/ctx/create-ctx.js +77 -6
- package/dist/ctx/device-provider-check.d.ts +6 -2
- package/dist/ctx/device-provider-check.js +17 -2
- package/dist/db/kernel-schema.d.ts +10 -48
- package/dist/devices/access.d.ts +3 -4
- package/dist/devices/access.js +3 -4
- package/dist/devices/conversation-devices.d.ts +1 -3
- package/dist/devices/conversation-devices.js +2 -7
- package/dist/devices/device-projects.service.js +24 -29
- package/dist/devices/device-provider-selection.d.ts +5 -6
- package/dist/devices/device-provider-selection.js +8 -9
- package/dist/devices/devices.controller.d.ts +8 -21
- package/dist/devices/devices.controller.js +9 -34
- package/dist/devices/devices.module.js +6 -4
- package/dist/devices/devices.schemas.d.ts +1 -5
- package/dist/devices/devices.schemas.js +1 -5
- package/dist/devices/devices.service.d.ts +84 -147
- package/dist/devices/devices.service.js +134 -229
- package/dist/devices/dto.d.ts +5 -32
- package/dist/devices/dto.js +5 -37
- package/dist/devices/errors.d.ts +6 -5
- package/dist/devices/errors.js +7 -8
- package/dist/devices/project-rules.d.ts +9 -11
- package/dist/devices/project-rules.js +7 -7
- package/dist/devices/working-root.d.ts +3 -6
- package/dist/devices/working-root.js +3 -8
- package/dist/dial-in/access.d.ts +23 -0
- package/dist/dial-in/access.js +64 -0
- package/dist/{local-devices/device-auth.controller.d.ts → dial-in/auth.controller.d.ts} +12 -6
- package/dist/{local-devices/device-auth.controller.js → dial-in/auth.controller.js} +30 -15
- package/dist/dial-in/auth.module.d.ts +7 -0
- package/dist/dial-in/auth.module.js +27 -0
- package/dist/{local-devices/device-auth.d.ts → dial-in/auth.service.d.ts} +42 -13
- package/dist/{local-devices/device-auth.js → dial-in/auth.service.js} +83 -32
- package/dist/dial-in/dial-in.module.d.ts +9 -0
- package/dist/dial-in/dial-in.module.js +37 -0
- package/dist/{local-devices → dial-in}/dto.d.ts +17 -2
- package/dist/{local-devices → dial-in}/dto.js +14 -2
- package/dist/dial-in/envelope.d.ts +95 -0
- package/dist/dial-in/envelope.js +89 -0
- package/dist/dial-in/gateway.d.ts +214 -0
- package/dist/{local-devices/local-device-gateway.js → dial-in/gateway.js} +337 -181
- package/dist/dial-in/handlers.d.ts +47 -0
- package/dist/dial-in/handlers.js +84 -0
- package/dist/dial-in/machines.d.ts +155 -0
- package/dist/dial-in/machines.js +383 -0
- package/dist/dial-in/relay.d.ts +135 -0
- package/dist/dial-in/relay.js +444 -0
- package/dist/dial-in/relay.module.d.ts +7 -0
- package/dist/dial-in/relay.module.js +24 -0
- package/dist/{local-devices/device-routes.d.ts → dial-in/routes.d.ts} +19 -11
- package/dist/{local-devices/device-routes.js → dial-in/routes.js} +45 -25
- package/dist/{local-devices → dial-in}/targets.d.ts +3 -18
- package/dist/{local-devices → dial-in}/targets.js +3 -48
- package/dist/errors.d.ts +8 -27
- package/dist/errors.js +8 -27
- package/dist/extensions/bootstrap.d.ts +5 -0
- package/dist/extensions/bootstrap.js +10 -1
- package/dist/extensions/extensions.module.js +6 -0
- package/dist/extensions/host.d.ts +6 -0
- package/dist/extensions/host.js +12 -2
- package/dist/extensions/permission-set.d.ts +15 -1
- package/dist/extensions/permission-set.js +11 -1
- package/dist/extensions/permission-view.d.ts +1 -1
- package/dist/extensions/permission-view.js +4 -1
- package/dist/http/api.module.js +4 -4
- package/dist/http/gateway-routes.d.ts +1 -1
- package/dist/http/gateway-routes.js +1 -1
- package/dist/http/meta.controller.js +1 -1
- package/dist/identity/settings.d.ts +1 -1
- package/dist/identity/settings.js +6 -8
- package/dist/infra/config/kernel-config.service.js +2 -2
- package/dist/infra/outbox/registry.d.ts +0 -14
- package/dist/infra/outbox/registry.js +0 -15
- package/dist/infra/throttler/named-throttlers.d.ts +1 -1
- package/dist/infra/throttler/named-throttlers.js +1 -1
- package/dist/kernel.module.js +0 -3
- package/dist/orgs/settings.service.js +5 -10
- package/dist/overrides.d.ts +0 -4
- package/dist/overrides.js +0 -2
- package/dist/platform/exclusions.js +5 -5
- package/dist/platform/ops/admin.ops.js +1 -1
- package/dist/platform/ops/conversations.ops.js +5 -2
- package/dist/platform/ops/devices.ops.js +11 -24
- package/dist/platform/ops/inbox.ops.js +1 -1
- package/dist/roles/gateway-role.d.ts +3 -3
- package/dist/roles/gateway-role.js +4 -4
- package/dist/roles/gateway.module.d.ts +1 -1
- package/dist/roles/gateway.module.js +5 -5
- package/dist/runtime/context/device-paths.d.ts +4 -1
- package/dist/runtime/context/permission-profile.js +5 -5
- package/dist/runtime/maintenance.d.ts +2 -5
- package/dist/runtime/maintenance.js +9 -19
- package/dist/runtime/project/knowledge.js +4 -5
- package/dist/runtime/project/knowledge.service.js +2 -1
- package/dist/sandbox/cloud-permission-snapshot.d.ts +1 -1
- package/dist/sandbox/cloud-permission-snapshot.js +1 -3
- package/dist/sandbox/device-reports.d.ts +74 -14
- package/dist/sandbox/device-reports.js +190 -33
- package/dist/sandbox/device-reports.module.d.ts +7 -0
- package/dist/sandbox/device-reports.module.js +25 -0
- package/dist/sandbox/device-sandbox.d.ts +39 -41
- package/dist/sandbox/device-sandbox.js +44 -83
- package/dist/sandbox/kernel-read.d.ts +2 -2
- package/dist/sandbox/legacy-retirement.d.ts +11 -59
- package/dist/sandbox/legacy-retirement.js +34 -186
- package/dist/sandbox/legacy-retirement.module.d.ts +2 -2
- package/dist/sandbox/legacy-retirement.module.js +2 -2
- package/dist/sandbox/managed-device-context.d.ts +16 -4
- package/dist/sandbox/managed-device-context.js +25 -8
- package/dist/sandbox/managed-device-context.module.js +4 -0
- package/dist/sandbox/modes.d.ts +3 -12
- package/dist/sandbox/modes.js +2 -14
- package/dist/{local-devices → sandbox}/network-grants.d.ts +2 -21
- package/dist/{local-devices → sandbox}/network-grants.js +4 -49
- package/dist/sandbox/operation-authority-types.d.ts +2 -1
- package/dist/sandbox/operation-authority.d.ts +6 -20
- package/dist/sandbox/operation-authority.js +43 -104
- package/dist/sandbox/operation-authority.module.js +1 -1
- package/dist/sandbox/operation-intents.d.ts +4 -1
- package/dist/sandbox/operation-intents.js +11 -2
- package/dist/sandbox/operation-reconcile.job.js +2 -4
- package/dist/sandbox/permission-availability.d.ts +6 -7
- package/dist/sandbox/permission-availability.js +7 -10
- package/dist/sandbox/permission-call-grants.d.ts +2 -1
- package/dist/sandbox/permission-call-grants.js +1 -7
- package/dist/sandbox/permission-call-types.d.ts +4 -4
- package/dist/sandbox/permission-ceiling-writes.d.ts +7 -23
- package/dist/sandbox/permission-ceiling-writes.js +8 -35
- package/dist/sandbox/permission-config-publication.d.ts +9 -1
- package/dist/sandbox/permission-config-publication.js +29 -21
- package/dist/sandbox/permission-context-types.d.ts +17 -10
- package/dist/sandbox/permission-facts.d.ts +98 -95
- package/dist/sandbox/permission-facts.js +160 -314
- package/dist/sandbox/permission-instance-writes.d.ts +23 -37
- package/dist/sandbox/permission-instance-writes.js +44 -121
- package/dist/sandbox/permission-runtime-reports.d.ts +38 -30
- package/dist/sandbox/permission-runtime-reports.js +105 -122
- package/dist/sandbox/providers.d.ts +26 -38
- package/dist/sandbox/providers.js +36 -18
- package/dist/sandbox/request-not-sent.d.ts +2 -13
- package/dist/sandbox/request-not-sent.js +2 -13
- package/dist/sandbox/review/permission-candidate.d.ts +13 -8
- package/dist/sandbox/review/permission-candidate.js +38 -48
- package/dist/sandbox/sandbox.module.js +7 -3
- package/dist/sandbox/sandbox.service.d.ts +49 -59
- package/dist/sandbox/sandbox.service.js +139 -259
- package/dist/schedules/fire.d.ts +15 -6
- package/dist/schedules/fire.js +27 -13
- package/dist/schedules/grant-rules.js +1 -1
- package/dist/schedules/scheduled-tasks.service.d.ts +0 -7
- package/dist/schedules/scheduled-tasks.service.js +1 -4
- package/dist/schedules/schedules.module.js +5 -3
- package/dist/skills/invoke.d.ts +1 -1
- package/dist/skills/invoke.js +2 -3
- package/dist/tools/approvals.service.d.ts +8 -5
- package/dist/tools/approvals.service.js +5 -5
- package/dist/tools/builtins/sandbox/bash.js +1 -2
- package/dist/tools/builtins/sandbox/common.d.ts +15 -9
- package/dist/tools/builtins/sandbox/common.js +37 -38
- package/dist/tools/network-asks.d.ts +19 -22
- package/dist/tools/network-asks.js +15 -21
- package/dist/tools/pipeline.d.ts +6 -7
- package/dist/tools/pipeline.js +17 -21
- package/dist/tools/tools.module.js +3 -7
- package/package.json +3 -4
- package/src/migrations/0177_dial_in_contract.sql +32 -0
- package/dist/local-devices/device-auth.module.d.ts +0 -7
- package/dist/local-devices/device-auth.module.js +0 -25
- package/dist/local-devices/device-policy.service.d.ts +0 -213
- package/dist/local-devices/device-policy.service.js +0 -605
- package/dist/local-devices/instance-bindings.d.ts +0 -82
- package/dist/local-devices/instance-bindings.js +0 -307
- package/dist/local-devices/local-device-gateway.d.ts +0 -153
- package/dist/local-devices/local-device-provider.d.ts +0 -122
- package/dist/local-devices/local-device-provider.js +0 -326
- package/dist/local-devices/local-devices.module.d.ts +0 -31
- package/dist/local-devices/local-devices.module.js +0 -100
- package/dist/local-devices/machines.d.ts +0 -211
- package/dist/local-devices/machines.js +0 -766
- package/dist/local-devices/owner-report.d.ts +0 -81
- package/dist/local-devices/owner-report.js +0 -150
- package/dist/local-devices/owner-reports.d.ts +0 -48
- package/dist/local-devices/owner-reports.js +0 -208
- package/dist/local-devices/policy-op-jobs.d.ts +0 -15
- package/dist/local-devices/policy-op-jobs.js +0 -12
- package/dist/local-devices/policy-summary.d.ts +0 -102
- package/dist/local-devices/policy-summary.js +0 -155
- package/dist/local-devices/relay.d.ts +0 -166
- package/dist/local-devices/relay.js +0 -559
- package/dist/tools/device-op-resolver.d.ts +0 -34
- package/dist/tools/device-op-resolver.js +0 -120
- /package/dist/{local-devices → dial-in}/keys.d.ts +0 -0
- /package/dist/{local-devices → dial-in}/keys.js +0 -0
- /package/dist/{local-devices → sandbox}/network-grants.module.d.ts +0 -0
- /package/dist/{local-devices → sandbox}/network-grants.module.js +0 -0
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { DEFAULT_SANDBOX_ROOTS,
|
|
1
|
+
import { DEFAULT_SANDBOX_ROOTS, isDeviceOfflineError, isDeviceRequestNotSent, isFileSystemGoneError, isSandboxOperationOutcomeUnknownError, isSandboxPermissionUnsupportedError, isSandboxScopeDeniedError, isSandboxScopeValidationError, isSandboxWorkUnsettledError, SandboxScopeDeniedError, ToolError, validateSandboxPath, validateSandboxPathShape, } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { DeviceProtocolError } from "@capybara-hq/plugin-sdk/device-protocol";
|
|
2
3
|
import { ANONYMOUS_NO_DEVICE, NO_DEVICE, } from "../../../devices/conversation-devices.js";
|
|
3
4
|
import { canonicalRoot, workingRootOf } from "../../../devices/working-root.js";
|
|
4
5
|
import { ApiError } from "../../../errors.js";
|
|
5
|
-
import { InstanceBindingError } from "../../../local-devices/instance-bindings.js";
|
|
6
|
-
import { isDeviceRequestNotSent } from "../../../local-devices/relay.js";
|
|
7
6
|
import { devicePathsChange } from "../../../runtime/context/device-paths.js";
|
|
8
7
|
import { ATTACHMENTS_ROOT, attachmentsDir, attachmentsRoot, } from "../../../sandbox/attachments-path.js";
|
|
9
8
|
import { SandboxPathBusyError } from "../../../sandbox/leases.js";
|
|
@@ -52,7 +51,12 @@ const ENV_NOT_FOUND_TEXT = "This conversation's device was deleted or its owner
|
|
|
52
51
|
const ENV_FORBIDDEN_TEXT = "This conversation's owner may no longer use its device; ask the user to start a new conversation on a device they can use.";
|
|
53
52
|
/** A device whose provider does not serve its org now (`device.unavailable`): files kept. */
|
|
54
53
|
export const ENV_UNAVAILABLE_TEXT = "This conversation's device runs on a device provider that is off in this organization or not installed; its files are kept. Ask an org admin to switch the provider back on, or start a new conversation on another device.";
|
|
55
|
-
|
|
54
|
+
/**
|
|
55
|
+
* The device's files are gone at its provider (`device.files_lost`): the devices page resets them
|
|
56
|
+
* where the provider offers that; otherwise the device is set up again where its provider keeps
|
|
57
|
+
* its files (a dial-in device: its machine signs in to it again).
|
|
58
|
+
*/
|
|
59
|
+
export const ENV_FILES_LOST_TEXT = "This device's files are gone. Ask the user to reset its files on the devices page, or, where its provider offers no reset, to set the device up again (for a device served by a machine: sign that machine in to it again), then retry.";
|
|
56
60
|
/**
|
|
57
61
|
* A provider call that never connected (refused, unknown host, unreachable network): the request
|
|
58
62
|
* did not reach the provider, so the call did nothing in the sandbox.
|
|
@@ -60,12 +64,11 @@ const ENV_FILES_LOST_TEXT = "This device's files are gone. Ask the user to reset
|
|
|
60
64
|
export const SANDBOX_UNREACHABLE_TEXT = "The sandbox provider can't be reached (the connection failed), so this call did nothing in the sandbox; retrying won't help until a super admin checks the sandbox extension's configuration (Admin console → Extensions). Continue without the sandbox, or ask the person to have a super admin check it.";
|
|
61
65
|
/** A provider connection that broke during the call: the provider may have acted before it broke. */
|
|
62
66
|
export const SANDBOX_CONNECTION_DROPPED_TEXT = "The connection to the sandbox provider broke during this call, so it may or may not have taken effect; check the sandbox state before retrying. If it fails again, continue without the sandbox and ask the person to have a super admin check the sandbox extension's configuration (Admin console → Extensions).";
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
const deviceProtocolText = (detail) => `The device's machine sent an answer the platform cannot read (${detail}). Ask the person to update capybara-device on that machine, then retry.`;
|
|
67
|
+
/** A dial-in device whose machine is not connected (`device.offline`, the SDK's offline error). */
|
|
68
|
+
export const DEVICE_OFFLINE_TEXT = "The machine serving this device is offline. Ask the person to connect it again, or to start a new conversation on another device.";
|
|
69
|
+
const DEVICE_OUTDATED_TEXT = "The machine serving this device runs an outdated device program. Ask the person to update it on that machine and connect it again.";
|
|
70
|
+
const DEVICE_REVOKED_TEXT = "The machine serving this device was disconnected. Ask the person to sign that machine in to this device again, or to start a new conversation on another device.";
|
|
71
|
+
const deviceProtocolText = (detail) => `The machine serving this device sent an answer the platform cannot read (${detail}). Ask the person to update the device program on that machine, then retry.`;
|
|
69
72
|
/**
|
|
70
73
|
* A cloud provider refused the device's open public network (`sandbox.open_network_refused`): the
|
|
71
74
|
* fixed text, never the provider's own message (it may name its settings).
|
|
@@ -288,24 +291,18 @@ export const PLATFORM_OUTSIDE_SANDBOX_OFF_TOOL_TEXT = "Running commands outside
|
|
|
288
291
|
/**
|
|
289
292
|
* The device does not allow running outside the sandbox (`device.outside_sandbox_not_allowed`).
|
|
290
293
|
*/
|
|
291
|
-
export const OUTSIDE_SANDBOX_CEILING_TOOL_TEXT = "This device does not allow running commands outside the sandbox, so nothing ran. Run the command inside the sandbox, or ask the device's owner
|
|
294
|
+
export const OUTSIDE_SANDBOX_CEILING_TOOL_TEXT = "This device does not allow running commands outside the sandbox, so nothing ran. Run the command inside the sandbox, or ask the device's owner whether its provider can allow it.";
|
|
292
295
|
/**
|
|
293
296
|
* The legacy retirement gate's refusals (`RetirementPendingError`, permission runtime cutover
|
|
294
297
|
* 8.5): the device's earlier instance may still run background work an earlier version started.
|
|
295
298
|
* Each says what clears it; the generic `device.unavailable` text would name an inactive provider.
|
|
296
299
|
*/
|
|
297
300
|
export 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.";
|
|
298
|
-
export 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.";
|
|
299
301
|
export 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.";
|
|
300
|
-
export 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.";
|
|
301
302
|
/** The model-facing text of a retirement refusal's code (`device.unavailable` for any other). */
|
|
302
303
|
function retirementToolText(code) {
|
|
303
|
-
if (code === "device.restart_required")
|
|
304
|
-
return RETIREMENT_RESTART_TOOL_TEXT;
|
|
305
304
|
if (code === "device.recreate_required")
|
|
306
305
|
return RETIREMENT_RECREATE_TOOL_TEXT;
|
|
307
|
-
if (code === "device.replace_required")
|
|
308
|
-
return RETIREMENT_REPLACE_TOOL_TEXT;
|
|
309
306
|
return RETIREMENT_PENDING_TOOL_TEXT;
|
|
310
307
|
}
|
|
311
308
|
/**
|
|
@@ -320,9 +317,9 @@ export const ESCALATION_GRANT_MISSING_LAUNCH_WHY = 'its approval to run outside
|
|
|
320
317
|
/** A staged request the machine never got: it reconnected before the request was sent. */
|
|
321
318
|
export const DEVICE_REQUEST_NOT_SENT_TOOL_TEXT = "The device's machine reconnected before this operation was sent, so nothing ran. Retry the tool call.";
|
|
322
319
|
/** The device itself refused: it cannot enforce its sandbox (`SandboxPermissionUnsupportedError`). */
|
|
323
|
-
export const PERMISSION_UNSUPPORTED_TOOL_TEXT = "This device refused to run the operation because it cannot enforce its sandbox limits, so nothing ran. Ask the device's owner to update
|
|
320
|
+
export const PERMISSION_UNSUPPORTED_TOOL_TEXT = "This device refused to run the operation because it cannot enforce its sandbox limits, so nothing ran. Ask the device's owner to update its device program (or a super admin to update its device plugin), or continue without the device.";
|
|
324
321
|
/** Earlier work on the device blocks a new operation (`SandboxWorkUnsettledError`). */
|
|
325
|
-
export const WORK_UNSETTLED_TOOL_TEXT = "Earlier work on this device has not settled yet, so nothing ran. Retry in a moment; if it keeps happening, ask the device's owner to stop the device's background tasks or restart
|
|
322
|
+
export const WORK_UNSETTLED_TOOL_TEXT = "Earlier work on this device has not settled yet, so nothing ran. Retry in a moment; if it keeps happening, ask the device's owner to stop the device's background tasks or restart its device program.";
|
|
326
323
|
export { PermissionAdmissionUnavailable };
|
|
327
324
|
/**
|
|
328
325
|
* Admission's refusal on a device without permission-scoped operations
|
|
@@ -331,7 +328,7 @@ export { PermissionAdmissionUnavailable };
|
|
|
331
328
|
export function admissionUnavailableText(cause) {
|
|
332
329
|
if (cause.kind === "provider-outdated")
|
|
333
330
|
return `This device's sandbox plugin (${cause.plugin} ${cause.version}) cannot run device tools under a permission profile, so nothing ran. A super admin updates the plugin on the Plugins page; until then, continue without the device, or ask the user to start a new conversation on another device.`;
|
|
334
|
-
return "This device's runtime cannot enforce its sandbox, so nothing ran. Ask the device's owner to update
|
|
331
|
+
return "This device's runtime cannot enforce its sandbox, so nothing ran. Ask the device's owner to update its device program (or a super admin to update its device plugin), or continue without the device.";
|
|
335
332
|
}
|
|
336
333
|
/**
|
|
337
334
|
* A device refused an operation scope as invalid (`SandboxScopeValidationError`): the kernel only
|
|
@@ -340,10 +337,10 @@ export function admissionUnavailableText(cause) {
|
|
|
340
337
|
*/
|
|
341
338
|
export const SCOPE_INVALID_TOOL_TEXT = "The device refused this operation as malformed, which points to a problem in the platform itself, not in the request. Tell the user the device rejected the operation and that it should be reported; do not retry it unchanged.";
|
|
342
339
|
/**
|
|
343
|
-
* A device request whose machine came back as a new run of
|
|
340
|
+
* A device request whose machine came back as a new run of its device program before answering
|
|
344
341
|
* (`DeviceProgramRestartedError`, also as the cause of an unknown outcome): its result is lost.
|
|
345
342
|
*/
|
|
346
|
-
export const DEVICE_PROGRAM_RESTARTED_TOOL_TEXT = "The
|
|
343
|
+
export const DEVICE_PROGRAM_RESTARTED_TOOL_TEXT = "The device program restarted on the machine serving this device while this operation was in progress, so its result is lost and whether it ran, or how far, is unknown. Check the device's state (for example with Read, Glob or TaskList), then run it again if it is still needed; do not repeat an operation that must not run twice.";
|
|
347
344
|
/** A managed operation whose outcome could not be confirmed (`SandboxOperationOutcomeUnknownError`). */
|
|
348
345
|
export 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.";
|
|
349
346
|
/**
|
|
@@ -354,7 +351,6 @@ export const OUTCOME_UNKNOWN_TOOL_TEXT = "The device may or may not have run thi
|
|
|
354
351
|
* `ToolError`).
|
|
355
352
|
*/
|
|
356
353
|
const RECONCILE_REQUIRED_TEXT = "This device's sandbox limits must be established again before it runs anything, so nothing ran. Ask the person to reset the device's files on the devices page, then retry, or to start a new conversation on another device.";
|
|
357
|
-
const INSTANCE_BINDING_TEXT = "The device's machine has not confirmed its current instance, so nothing ran. Ask the person to restart capybara-device on that machine (updating it if it is outdated), then retry, or to start a new conversation on another device.";
|
|
358
354
|
/** The provider connection failure behind an unknown outcome, with the raw error to log. */
|
|
359
355
|
function unreachableCause(cause) {
|
|
360
356
|
if (cause instanceof SandboxProviderUnreachableError)
|
|
@@ -390,6 +386,9 @@ export function mapSandboxError(e, log) {
|
|
|
390
386
|
log?.warn("sandbox operation outcome unknown", { err: e });
|
|
391
387
|
return new ToolError(OUTCOME_UNKNOWN_TOOL_TEXT, { kind: "unavailable" });
|
|
392
388
|
}
|
|
389
|
+
// a dial-in provider's machine is not connected (the SDK's error, from any provider)
|
|
390
|
+
if (isDeviceOfflineError(e))
|
|
391
|
+
return new ToolError(DEVICE_OFFLINE_TEXT);
|
|
393
392
|
// kernel-typed, before the scope refusal it extends: nothing was sent, a retry is safe
|
|
394
393
|
if (isDeviceRequestNotSent(e))
|
|
395
394
|
return new ToolError(DEVICE_REQUEST_NOT_SENT_TOOL_TEXT, { kind: "unavailable" });
|
|
@@ -453,9 +452,6 @@ export function mapSandboxError(e, log) {
|
|
|
453
452
|
return new ToolError(ENV_FORBIDDEN_TEXT);
|
|
454
453
|
if (e.code === "device.unavailable")
|
|
455
454
|
return new ToolError(ENV_UNAVAILABLE_TEXT);
|
|
456
|
-
if (e.code === "device.files_lost" && detail?.source === "local") {
|
|
457
|
-
return new ToolError(DEVICE_FILES_LOST_TEXT);
|
|
458
|
-
}
|
|
459
455
|
if (e.code === "device.files_lost")
|
|
460
456
|
return new ToolError(ENV_FILES_LOST_TEXT);
|
|
461
457
|
if (e.code === "device.offline")
|
|
@@ -479,13 +475,9 @@ export function mapSandboxError(e, log) {
|
|
|
479
475
|
}
|
|
480
476
|
// an operation outside withSandbox's own mapping (it records lost files itself)
|
|
481
477
|
if (isFileSystemGoneError(e))
|
|
482
|
-
return new ToolError(
|
|
478
|
+
return new ToolError(ENV_FILES_LOST_TEXT);
|
|
483
479
|
if (e instanceof DeviceProtocolError)
|
|
484
480
|
return new ToolError(deviceProtocolText(e.message));
|
|
485
|
-
if (e instanceof InstanceBindingError) {
|
|
486
|
-
log?.warn("device instance binding failed", { err: e });
|
|
487
|
-
return new ToolError(INSTANCE_BINDING_TEXT, { kind: "unavailable" });
|
|
488
|
-
}
|
|
489
481
|
if (e instanceof SandboxLockLostError)
|
|
490
482
|
return new ToolError(LOCK_LOST_TEXT);
|
|
491
483
|
if (e instanceof SandboxPathBusyError)
|
|
@@ -556,9 +548,8 @@ async function inSandboxWith(deps, ctx, fn, operations, stage) {
|
|
|
556
548
|
// the working facts (workspace, home, project snapshot) are read as the review reads them
|
|
557
549
|
// a call the review covered runs in the working root it was reviewed against: never read again
|
|
558
550
|
const reviewed = ctx.reviewedWorkingRoot;
|
|
559
|
-
const [level,
|
|
551
|
+
const [level, working] = await Promise.all([
|
|
560
552
|
deps.devices.modeLevel?.(ctx.orgId, deviceId) ?? null,
|
|
561
|
-
deps.devices.projectReach?.(ctx.orgId, deviceId),
|
|
562
553
|
reviewed !== undefined
|
|
563
554
|
? null
|
|
564
555
|
: (deps.devices.workingFacts?.(ctx.orgId, sandboxConversationOf(ctx), ctx.conversationId, deviceId) ?? null),
|
|
@@ -576,9 +567,17 @@ async function inSandboxWith(deps, ctx, fn, operations, stage) {
|
|
|
576
567
|
beforeUser: async (staging, info, sig) => {
|
|
577
568
|
// the held instance's device paths, recorded before any preparation or user callback
|
|
578
569
|
if (managed) {
|
|
579
|
-
// no installed
|
|
570
|
+
// no installed evidence to describe the held instance: unavailable, not stale
|
|
571
|
+
// (a device or machine that is gone for good says so instead)
|
|
580
572
|
if (!info.contextEvidence)
|
|
581
|
-
throw
|
|
573
|
+
throw ((ctx.runId !== undefined &&
|
|
574
|
+
(await managed.goneFor?.({
|
|
575
|
+
orgId: ctx.orgId,
|
|
576
|
+
conversationId: ctx.conversationId,
|
|
577
|
+
runId: ctx.runId,
|
|
578
|
+
accountId: ctx.accountId,
|
|
579
|
+
}, deviceId))) ||
|
|
580
|
+
new ManagedDeviceContextUnavailable());
|
|
582
581
|
// B-18: the review judged the call against a root (the workspace included);
|
|
583
582
|
// held evidence of another root is stale, refused before anything is recorded
|
|
584
583
|
// or run
|
|
@@ -620,7 +619,7 @@ async function inSandboxWith(deps, ctx, fn, operations, stage) {
|
|
|
620
619
|
// which a reviewed call's root equals (checked before the callback, B-18)
|
|
621
620
|
workingRoot: (managed ? info.contextEvidence?.workingRoot : undefined) ??
|
|
622
621
|
reviewed ??
|
|
623
|
-
sessionWorkingRoot(working,
|
|
622
|
+
sessionWorkingRoot(working, info.roots.workspace),
|
|
624
623
|
p,
|
|
625
624
|
signal,
|
|
626
625
|
};
|
|
@@ -689,10 +688,10 @@ async function recordDevicePaths(deps, ctx, roots, level) {
|
|
|
689
688
|
* workspace (`workspace`), where the call really runs. Every session built outside `inSandbox` (a
|
|
690
689
|
* person's project skill invocation) takes its working root from here too.
|
|
691
690
|
*/
|
|
692
|
-
export function sessionWorkingRoot(working,
|
|
691
|
+
export function sessionWorkingRoot(working, workspace) {
|
|
693
692
|
if (working === null)
|
|
694
693
|
return workspace;
|
|
695
|
-
const root = workingRootOf(working.project,
|
|
694
|
+
const root = workingRootOf(working.project, working);
|
|
696
695
|
return root === working.workspace ? workspace : root;
|
|
697
696
|
}
|
|
698
697
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type { NetworkRunState } from "../
|
|
1
|
+
import { type NetworkBlockedHost } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import type { NetworkRunState } from "../sandbox/network-grants.js";
|
|
3
3
|
import { type UnattendedRun } from "../schedules/unattended.js";
|
|
4
4
|
import { type ApprovalRecord } from "./approvals.service.js";
|
|
5
5
|
/**
|
|
@@ -15,7 +15,10 @@ export declare const NETWORK_ASK_KEPT_MAX_BYTES: number;
|
|
|
15
15
|
export declare const NETWORK_ASK_CLIPPED_NOTE = "[Output clipped to its first 16 KB while waiting for network access.]";
|
|
16
16
|
/** The idempotency key of a call's `network_blocked` event. */
|
|
17
17
|
export declare const networkBlockedIdemKey: (runId: string, callId: string) => string;
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Asked, allowed this time (a run grant, the only offer: an ask never adds a host to the device's
|
|
20
|
+
* own network list, only its owner's network setting does).
|
|
21
|
+
*/
|
|
19
22
|
export declare const allowedOnceNote: (hosts: readonly string[]) => string;
|
|
20
23
|
/** Asked and declined (also the unchecked hosts of a partial decision, and a host refused earlier in the run). */
|
|
21
24
|
export declare const deniedNote: (hosts: readonly string[], reason?: string | null) => string;
|
|
@@ -29,12 +32,6 @@ export declare const cancelledNote: () => string;
|
|
|
29
32
|
export declare const otherAskPendingNote: (hosts: readonly string[]) => string;
|
|
30
33
|
/** Not asked: the run made {@link MAX_NETWORK_ASKS_PER_RUN} asks already (spec §6.8). */
|
|
31
34
|
export declare const tooManyNote: (hosts: readonly string[]) => string;
|
|
32
|
-
/**
|
|
33
|
-
* Not asked: the device cannot take network changes from the deployment (Docker mode, or a program
|
|
34
|
-
* too old to take them), so a run grant would not reach it; only its owner can
|
|
35
|
-
* allow the host locally.
|
|
36
|
-
*/
|
|
37
|
-
export declare const localOnlyNote: (hosts: readonly string[]) => string;
|
|
38
35
|
/** The org layer (spec §6.6): only an org admin can lift it. */
|
|
39
36
|
export declare const orgLayerNote: (hosts: readonly string[]) => string;
|
|
40
37
|
/** An org-layer host beyond the platform's ceiling (org egress ceiling spec §D2): only a super admin. */
|
|
@@ -65,20 +62,20 @@ export declare function addressEscalationHint(escalation: "available" | "escalat
|
|
|
65
62
|
*/
|
|
66
63
|
export declare const unavailableHostNote: (host: string, why: string) => string;
|
|
67
64
|
/**
|
|
68
|
-
* An unattended run (spec §8.1): the task approves the host, yet the device refused it:
|
|
69
|
-
*
|
|
70
|
-
*
|
|
65
|
+
* An unattended run (spec §8.1): the task approves the host, yet the device refused it: its
|
|
66
|
+
* provider did not apply the task's network grant. Not asked, not a missing grant: the device's
|
|
67
|
+
* owner adds the host to the device's network list on its page.
|
|
71
68
|
*/
|
|
72
69
|
export declare const taskGrantIgnoredNote: (hosts: readonly string[]) => string;
|
|
73
70
|
/** An unattended run in `fail` mode (spec §8.3): no ask, the creator can add a task grant. */
|
|
74
71
|
export declare const unattendedNetworkNote: (hosts: readonly string[]) => string;
|
|
75
72
|
/** What the pipeline knows when a command reported refused hosts. */
|
|
76
73
|
export interface NetworkPlanContext {
|
|
77
|
-
/**
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
/**
|
|
75
|
+
* The device's provider enforces a sandbox allowlist (its permission support): only then is a
|
|
76
|
+
* device-layer host asked about (absent: never).
|
|
77
|
+
*/
|
|
78
|
+
allowlist?: boolean;
|
|
82
79
|
/** The scheduled task run the run serves (null / undefined: attended). */
|
|
83
80
|
unattended: UnattendedRun | null | undefined;
|
|
84
81
|
/**
|
|
@@ -106,7 +103,7 @@ export interface NetworkPlanContext {
|
|
|
106
103
|
export interface NetworkPlan {
|
|
107
104
|
/**
|
|
108
105
|
* The device-layer hosts to ask the device owner about (empty: no ask). The ask offers a run
|
|
109
|
-
* grant only
|
|
106
|
+
* grant only; the owner adds a host to the device's own list on its page.
|
|
110
107
|
*/
|
|
111
108
|
ask: {
|
|
112
109
|
host: string;
|
|
@@ -127,10 +124,10 @@ export declare function blockedEventHosts(blocked: readonly NetworkBlockedHost[]
|
|
|
127
124
|
* an `address` host under the open network on a device that allows running outside the sandbox
|
|
128
125
|
* gets the escalation hint; an `org` host whose grant is unavailable names who adds it;
|
|
129
126
|
* `unknown`: nothing (the device's trailer explains);
|
|
130
|
-
* - a `device` host whose per-call grant is unavailable (`ctx.refusal`:
|
|
131
|
-
*
|
|
132
|
-
* ask;
|
|
133
|
-
* - `device` layer on a
|
|
127
|
+
* - a `device` host whose per-call grant is unavailable (`ctx.refusal`: a provider without
|
|
128
|
+
* per-operation hosts, or beyond the org's or platform's allowlist ceiling): a note naming who
|
|
129
|
+
* adds it, never an ask;
|
|
130
|
+
* - `device` layer on a provider that enforces no allowlist: nothing (no ask);
|
|
134
131
|
* - approved by the scheduled task the run serves (`run.taskGranted`) yet refused: a note that
|
|
135
132
|
* the device ignores the task's grants (never asked, never a missing grant);
|
|
136
133
|
* - refused earlier in the run tree: the denied note; an unattended run in `fail` mode: its note
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { validateAllowHost
|
|
1
|
+
import { validateAllowHost } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { NETWORK_ASK_MAX_HOSTS, NETWORK_HOST_MAX_CHARS } from "../conversations/events.js";
|
|
3
3
|
import { ESCALATION_UNATTENDED_WHY } from "../sandbox/review/permission-candidate.js";
|
|
4
4
|
import { networkGrantKey, unattendedFails, unattendedRules, } from "../schedules/unattended.js";
|
|
@@ -21,7 +21,10 @@ const one = (hosts) => hosts.length === 1;
|
|
|
21
21
|
const pron = (hosts) => (one(hosts) ? "it" : "them");
|
|
22
22
|
/** "x was blocked by this device's network policy." (the lead of every device-layer note). */
|
|
23
23
|
const blockedLead = (hosts) => `[network] ${list(hosts)} ${one(hosts) ? "was" : "were"} blocked by this device's network policy.`;
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Asked, allowed this time (a run grant, the only offer: an ask never adds a host to the device's
|
|
26
|
+
* own network list, only its owner's network setting does).
|
|
27
|
+
*/
|
|
25
28
|
export const allowedOnceNote = (hosts) => `${blockedLead(hosts)} The user allowed ${pron(hosts)} for the rest of this task. Run the command again.`;
|
|
26
29
|
/** Asked and declined (also the unchecked hosts of a partial decision, and a host refused earlier in the run). */
|
|
27
30
|
export const deniedNote = (hosts, reason) => `${blockedLead(hosts)} The user declined access to ${list(hosts)}. Do not try to reach ${pron(hosts)} another way; continue without ${pron(hosts)} or ask the user.` +
|
|
@@ -36,14 +39,6 @@ export const cancelledNote = () => NETWORK_ASK_CANCELLED_NOTE;
|
|
|
36
39
|
export const otherAskPendingNote = (hosts) => `${blockedLead(hosts).slice(0, -1)}; another network request is waiting for the user.`;
|
|
37
40
|
/** Not asked: the run made {@link MAX_NETWORK_ASKS_PER_RUN} asks already (spec §6.8). */
|
|
38
41
|
export const tooManyNote = (hosts) => `${blockedLead(hosts)} Too many network requests in this task; ask the user to allow the domains on the device page.`;
|
|
39
|
-
/** The local command that allows each host (one `policy add` per host). */
|
|
40
|
-
const localAdd = (hosts) => hosts.map((h) => `capybara-device policy add allowedDomains ${h}`).join(" and ");
|
|
41
|
-
/**
|
|
42
|
-
* Not asked: the device cannot take network changes from the deployment (Docker mode, or a program
|
|
43
|
-
* too old to take them), so a run grant would not reach it; only its owner can
|
|
44
|
-
* allow the host locally.
|
|
45
|
-
*/
|
|
46
|
-
export const localOnlyNote = (hosts) => `${blockedLead(hosts).slice(0, -1)}, and this device does not accept network changes from the conversation. The device owner can allow ${pron(hosts)} locally: ${localAdd(hosts)}. Continue without ${pron(hosts)} or tell the user.`;
|
|
47
42
|
/** The org layer (spec §6.6): only an org admin can lift it. */
|
|
48
43
|
export const orgLayerNote = (hosts) => one(hosts)
|
|
49
44
|
? `[network] ${list(hosts)} is not in the organization's network allowlist. Only an organization admin can add it; the user can ask an admin from the conversation. Continue without it or tell the user.`
|
|
@@ -84,11 +79,11 @@ export function addressEscalationHint(escalation, networkMode) {
|
|
|
84
79
|
*/
|
|
85
80
|
export const unavailableHostNote = (host, why) => `[network] ${host} was blocked by this device's network policy and cannot be allowed from this conversation: ${why}. Continue without it or tell the user.`;
|
|
86
81
|
/**
|
|
87
|
-
* An unattended run (spec §8.1): the task approves the host, yet the device refused it:
|
|
88
|
-
*
|
|
89
|
-
*
|
|
82
|
+
* An unattended run (spec §8.1): the task approves the host, yet the device refused it: its
|
|
83
|
+
* provider did not apply the task's network grant. Not asked, not a missing grant: the device's
|
|
84
|
+
* owner adds the host to the device's network list on its page.
|
|
90
85
|
*/
|
|
91
|
-
export const taskGrantIgnoredNote = (hosts) => `${blockedLead(hosts)} The scheduled task approves ${pron(hosts)}, but this device
|
|
86
|
+
export const taskGrantIgnoredNote = (hosts) => `${blockedLead(hosts)} The scheduled task approves ${pron(hosts)}, but this device did not apply the task's network grant. The device owner can add ${pron(hosts)} to the device's network list on its page. Continue without ${pron(hosts)}.`;
|
|
92
87
|
/** An unattended run in `fail` mode (spec §8.3): no ask, the creator can add a task grant. */
|
|
93
88
|
export const unattendedNetworkNote = (hosts) => `[network] ${list(hosts)} ${one(hosts) ? "is" : "are"} blocked on this device and this scheduled run cannot ask for network access. The task's owner can add ${pron(hosts)} to the task's approved domains. Continue without ${pron(hosts)}.`;
|
|
94
89
|
/** Hosts in first-seen order, deduplicated, lower-cased, trailing dot dropped. */
|
|
@@ -118,10 +113,10 @@ export function blockedEventHosts(blocked) {
|
|
|
118
113
|
* an `address` host under the open network on a device that allows running outside the sandbox
|
|
119
114
|
* gets the escalation hint; an `org` host whose grant is unavailable names who adds it;
|
|
120
115
|
* `unknown`: nothing (the device's trailer explains);
|
|
121
|
-
* - a `device` host whose per-call grant is unavailable (`ctx.refusal`:
|
|
122
|
-
*
|
|
123
|
-
* ask;
|
|
124
|
-
* - `device` layer on a
|
|
116
|
+
* - a `device` host whose per-call grant is unavailable (`ctx.refusal`: a provider without
|
|
117
|
+
* per-operation hosts, or beyond the org's or platform's allowlist ceiling): a note naming who
|
|
118
|
+
* adds it, never an ask;
|
|
119
|
+
* - `device` layer on a provider that enforces no allowlist: nothing (no ask);
|
|
125
120
|
* - approved by the scheduled task the run serves (`run.taskGranted`) yet refused: a note that
|
|
126
121
|
* the device ignores the task's grants (never asked, never a missing grant);
|
|
127
122
|
* - refused earlier in the run tree: the denied note; an unattended run in `fail` mode: its note
|
|
@@ -139,9 +134,8 @@ export function planNetworkAsk(blocked, run, ctx) {
|
|
|
139
134
|
const candidates = [];
|
|
140
135
|
const missingGrants = [];
|
|
141
136
|
const unavailable = [];
|
|
142
|
-
// a
|
|
143
|
-
const canAsk = ctx.
|
|
144
|
-
ctx.device.features.includes("policyOpId");
|
|
137
|
+
// only a provider that enforces an allowlist blocks a host at the device layer
|
|
138
|
+
const canAsk = ctx.allowlist === true;
|
|
145
139
|
for (const b of hostsOf(blocked)) {
|
|
146
140
|
if (b.layer === "address")
|
|
147
141
|
address.push(b.host);
|
package/dist/tools/pipeline.d.ts
CHANGED
|
@@ -9,8 +9,6 @@ import { ExtensionHost } from "../extensions/host.js";
|
|
|
9
9
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
10
10
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
11
11
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
12
|
-
import { DevicePolicyService } from "../local-devices/device-policy.service.js";
|
|
13
|
-
import { type NetworkRunState } from "../local-devices/network-grants.js";
|
|
14
12
|
import type { KernelLogger } from "../log.js";
|
|
15
13
|
import type { OrgRole } from "../orgs/roles.js";
|
|
16
14
|
import { type ConversationKindForHooks, type HookRunner } from "../runtime/hook-calls.js";
|
|
@@ -18,6 +16,7 @@ import { type SubagentParent, type WaitingFor } from "../runtime/loop.js";
|
|
|
18
16
|
import type { DispatchArgs, DispatchOutcome } from "../runtime/subagents/dispatch.js";
|
|
19
17
|
import { SubagentMessages } from "../runtime/subagents/messages.js";
|
|
20
18
|
import { SubagentsService } from "../runtime/subagents/subagents.service.js";
|
|
19
|
+
import { type NetworkRunState } from "../sandbox/network-grants.js";
|
|
21
20
|
import { SandboxOperationAuthority } from "../sandbox/operation-authority.js";
|
|
22
21
|
import { PermissionAuthorityLock } from "../sandbox/permission-authority-lock.js";
|
|
23
22
|
import { PermissionAutoGrants } from "../sandbox/permission-auto-grants.js";
|
|
@@ -275,16 +274,16 @@ interface PipelineDeps {
|
|
|
275
274
|
readonly devices: Pick<ConversationDevices, "reviewFacts"> | undefined;
|
|
276
275
|
/**
|
|
277
276
|
* What a command's refused network hosts need (network ask-to-allow spec §6.2): the run tree's
|
|
278
|
-
* network asks and the device's
|
|
279
|
-
* pipelines) a report only writes
|
|
277
|
+
* network asks and the device's sandbox (its per-call host ceiling, and whether its provider
|
|
278
|
+
* enforces an allowlist). Without them (hand-built test pipelines) a report only writes
|
|
279
|
+
* `network_blocked`.
|
|
280
280
|
*/
|
|
281
281
|
readonly network: {
|
|
282
282
|
/** `deviceId` scopes the run tree's asks to the device (ignored by an older provider). */
|
|
283
283
|
grants: {
|
|
284
284
|
runState(runId: string, deviceId?: string): Promise<NetworkRunState>;
|
|
285
285
|
};
|
|
286
|
-
|
|
287
|
-
/** The device's per-call host ceiling (absent: every device-layer host is asked about). */
|
|
286
|
+
/** The device's sandbox (absent: no device-layer host is asked about). */
|
|
288
287
|
sandbox?: Pick<SandboxService, "hostRefusal">;
|
|
289
288
|
} | undefined;
|
|
290
289
|
}
|
|
@@ -407,7 +406,7 @@ export declare class ToolPipeline {
|
|
|
407
406
|
/** Plugin hooks and inline ui contributions; absent (tests): no hooks, cards dropped. */
|
|
408
407
|
host: Pick<ExtensionHost, "hooks" | "current"> | undefined, drift: Pick<ToolDrift, "onToolsChanged"> | undefined, effective: Pick<EffectiveConfigs, "get">, switches: Pick<OrgToolSwitches, "isToolOff">, txHost: TransactionHost, hooks?: ToolPipelineHooks, networkGrants?: {
|
|
409
408
|
runState(runId: string, deviceId?: string): Promise<NetworkRunState>;
|
|
410
|
-
},
|
|
409
|
+
},
|
|
411
410
|
/** The command review (auto mode spec §5.4); absent in hand-built pipelines. */
|
|
412
411
|
review?: CommandReview,
|
|
413
412
|
/** The reviewed call's device facts; absent in hand-built pipelines. */
|
package/dist/tools/pipeline.js
CHANGED
|
@@ -28,8 +28,6 @@ import { KernelDb } from "../infra/database/kernel-db.js";
|
|
|
28
28
|
import { TransactionHost, withTransactionFencePrelude, } from "../infra/database/transaction-host.js";
|
|
29
29
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
30
30
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
31
|
-
import { DevicePolicyService } from "../local-devices/device-policy.service.js";
|
|
32
|
-
import { NetworkGrants } from "../local-devices/network-grants.js";
|
|
33
31
|
import { UNKNOWN_RESULT_TEXT } from "../runtime/context/pairing.js";
|
|
34
32
|
import { fireObserve, hookDeniedAudit, hookDeniedEvent, hookScope, } from "../runtime/hook-calls.js";
|
|
35
33
|
import { subagentWaitingIdemKey } from "../runtime/loop.js";
|
|
@@ -40,6 +38,7 @@ import { SubagentMessages } from "../runtime/subagents/messages.js";
|
|
|
40
38
|
import { pairStoppedForks } from "../runtime/subagents/skill-fork.js";
|
|
41
39
|
import { SubagentsService } from "../runtime/subagents/subagents.service.js";
|
|
42
40
|
import { orgHostOutsideCeiling } from "../sandbox/modes.js";
|
|
41
|
+
import { NetworkGrants } from "../sandbox/network-grants.js";
|
|
43
42
|
import { SandboxOperationAuthority } from "../sandbox/operation-authority.js";
|
|
44
43
|
import { PermissionAuthorityLock } from "../sandbox/permission-authority-lock.js";
|
|
45
44
|
import { PermissionAutoGrants } from "../sandbox/permission-auto-grants.js";
|
|
@@ -488,7 +487,7 @@ let ToolPipeline = class ToolPipeline {
|
|
|
488
487
|
/** The message tools between agents; absent (tests): their calls are refused. */
|
|
489
488
|
messages, registry, credentials, breaker, outputs, approvals, questions, config, log,
|
|
490
489
|
/** Plugin hooks and inline ui contributions; absent (tests): no hooks, cards dropped. */
|
|
491
|
-
host, drift, effective, switches, txHost, hooks, networkGrants,
|
|
490
|
+
host, drift, effective, switches, txHost, hooks, networkGrants,
|
|
492
491
|
/** The command review (auto mode spec §5.4); absent in hand-built pipelines. */
|
|
493
492
|
review,
|
|
494
493
|
/** The reviewed call's device facts; absent in hand-built pipelines. */
|
|
@@ -551,10 +550,9 @@ let ToolPipeline = class ToolPipeline {
|
|
|
551
550
|
messages,
|
|
552
551
|
review,
|
|
553
552
|
devices,
|
|
554
|
-
network: networkGrants
|
|
553
|
+
network: networkGrants
|
|
555
554
|
? {
|
|
556
555
|
grants: networkGrants,
|
|
557
|
-
devices: devicePolicy,
|
|
558
556
|
...(this.sandboxes !== undefined && { sandbox: this.sandboxes }),
|
|
559
557
|
}
|
|
560
558
|
: undefined,
|
|
@@ -2038,22 +2036,22 @@ let ToolPipeline = class ToolPipeline {
|
|
|
2038
2036
|
const network = this.deps.network;
|
|
2039
2037
|
if (network === undefined)
|
|
2040
2038
|
return { kind: "write", event, notes: [] };
|
|
2041
|
-
const device = await network.devices.summary(report.deviceId);
|
|
2042
2039
|
const run = hosts.some((h) => h.layer === "device")
|
|
2043
2040
|
? await network.grants.runState(ctx.runId, report.deviceId)
|
|
2044
2041
|
: null;
|
|
2045
2042
|
const limits = this.config.get().sandbox.limits;
|
|
2046
|
-
// the per-call host ceiling decides what is worth asking: a host
|
|
2047
|
-
//
|
|
2043
|
+
// the per-call host ceiling decides what is worth asking: a host a per-call grant cannot
|
|
2044
|
+
// reach on this device (its provider, the org's or the platform's allowlist ceiling) is
|
|
2045
|
+
// unavailable, never asked about
|
|
2048
2046
|
const sandbox = await network.sandbox?.hostRefusal({
|
|
2049
2047
|
orgId: ctx.orgId,
|
|
2050
2048
|
deviceId: report.deviceId,
|
|
2051
2049
|
});
|
|
2052
2050
|
const plan = planNetworkAsk(hosts, run, {
|
|
2053
|
-
device,
|
|
2054
2051
|
unattended: ctx.unattended,
|
|
2055
2052
|
outsideCeiling: (h) => orgHostOutsideCeiling(limits, h),
|
|
2056
2053
|
...(sandbox !== undefined && {
|
|
2054
|
+
allowlist: sandbox.allowlist,
|
|
2057
2055
|
refusal: sandbox.refusal,
|
|
2058
2056
|
// the hint follows admission's verdict for this call (never a recomputation), and only
|
|
2059
2057
|
// the open network makes a private address the one thing escalation adds
|
|
@@ -2779,26 +2777,24 @@ ToolPipeline = __decorate([
|
|
|
2779
2777
|
__param(18, Optional()),
|
|
2780
2778
|
__param(18, Inject(NetworkGrants)),
|
|
2781
2779
|
__param(19, Optional()),
|
|
2782
|
-
__param(19, Inject(
|
|
2780
|
+
__param(19, Inject(CommandReviewService)),
|
|
2783
2781
|
__param(20, Optional()),
|
|
2784
|
-
__param(20, Inject(
|
|
2782
|
+
__param(20, Inject(ConversationDevices)),
|
|
2785
2783
|
__param(21, Optional()),
|
|
2786
|
-
__param(21, Inject(
|
|
2784
|
+
__param(21, Inject(SandboxOperationAuthority)),
|
|
2787
2785
|
__param(22, Optional()),
|
|
2788
|
-
__param(22, Inject(
|
|
2786
|
+
__param(22, Inject(PermissionCallGrants)),
|
|
2789
2787
|
__param(23, Optional()),
|
|
2790
|
-
__param(23, Inject(
|
|
2788
|
+
__param(23, Inject(PermissionAutoGrants)),
|
|
2791
2789
|
__param(24, Optional()),
|
|
2792
|
-
__param(24, Inject(
|
|
2790
|
+
__param(24, Inject(PermissionAuthorityLock)),
|
|
2793
2791
|
__param(25, Optional()),
|
|
2794
|
-
__param(25, Inject(
|
|
2792
|
+
__param(25, Inject(PERMISSION_CONTEXT_ACTIVATION)),
|
|
2795
2793
|
__param(26, Optional()),
|
|
2796
|
-
__param(26, Inject(
|
|
2794
|
+
__param(26, Inject(SandboxService)),
|
|
2797
2795
|
__param(27, Optional()),
|
|
2798
|
-
__param(27, Inject(
|
|
2796
|
+
__param(27, Inject(ConversationApprovalProfile)),
|
|
2799
2797
|
__param(28, Optional()),
|
|
2800
|
-
__param(28, Inject(
|
|
2801
|
-
__param(29, Optional()),
|
|
2802
|
-
__param(29, Inject(ToolAskReview))
|
|
2798
|
+
__param(28, Inject(ToolAskReview))
|
|
2803
2799
|
], ToolPipeline);
|
|
2804
2800
|
export { ToolPipeline };
|
|
@@ -14,7 +14,6 @@ import { ConversationLeakCheckModule } from "../conversations/leak-check.js";
|
|
|
14
14
|
import { DevicesModule } from "../devices/devices.module.js";
|
|
15
15
|
import { ExtensionsModule } from "../extensions/extensions.module.js";
|
|
16
16
|
import { QueueModule } from "../infra/queue/queue.module.js";
|
|
17
|
-
import { LocalDevicesModule } from "../local-devices/local-devices.module.js";
|
|
18
17
|
import { ModelsModule } from "../models/models.module.js";
|
|
19
18
|
import { OrgLockModule } from "../orgs/org-lock.js";
|
|
20
19
|
import { FileRefs } from "../platform/file-ref.js";
|
|
@@ -25,6 +24,7 @@ import { RunJobsModule } from "../runtime/run-jobs.js";
|
|
|
25
24
|
import { StepLogModule } from "../runtime/step-log.js";
|
|
26
25
|
import { SubagentsModule } from "../runtime/subagents/subagents.service.js";
|
|
27
26
|
import { ManagedDeviceContextModule } from "../sandbox/managed-device-context.module.js";
|
|
27
|
+
import { NetworkGrantsModule } from "../sandbox/network-grants.module.js";
|
|
28
28
|
import { OperationAuthorityModule } from "../sandbox/operation-authority.module.js";
|
|
29
29
|
import { PermissionAuthorityModule } from "../sandbox/permission-authority.module.js";
|
|
30
30
|
import { PermissionCallGrantsModule } from "../sandbox/permission-call-grants.module.js";
|
|
@@ -42,7 +42,6 @@ import { ConnectorAccountPolicies } from "./connector-account-policies.js";
|
|
|
42
42
|
import { ConnectorContent } from "./connector-content.js";
|
|
43
43
|
import { ConnectorsService } from "./connectors.service.js";
|
|
44
44
|
import { CredentialsModule } from "./credentials.module.js";
|
|
45
|
-
import { DeviceOpResolver } from "./device-op-resolver.js";
|
|
46
45
|
import { ToolDrift } from "./drift.js";
|
|
47
46
|
import { ConversationToolInfo, OrgExtensionTools } from "./info.js";
|
|
48
47
|
import { OAuthFlow } from "./oauth/flow.js";
|
|
@@ -86,8 +85,8 @@ ToolsModule = __decorate([
|
|
|
86
85
|
// the managed sandbox route's device context writer (passed only once activated)
|
|
87
86
|
ManagedDeviceContextModule,
|
|
88
87
|
DevicesModule,
|
|
89
|
-
// network asks
|
|
90
|
-
|
|
88
|
+
// network asks read the run tree's network grants
|
|
89
|
+
NetworkGrantsModule,
|
|
91
90
|
// `Bash` with run_in_background records its task; TaskOutput / TaskStop finish and stop it
|
|
92
91
|
BackgroundModule,
|
|
93
92
|
// the conversation page's tool metadata reads only what the viewer may see
|
|
@@ -134,8 +133,6 @@ ToolsModule = __decorate([
|
|
|
134
133
|
ConversationToolInfo,
|
|
135
134
|
OrgExtensionTools,
|
|
136
135
|
OrgToolSwitches,
|
|
137
|
-
// the `device-op-resolve` job's body (it may decide the network ask the op answers)
|
|
138
|
-
DeviceOpResolver,
|
|
139
136
|
],
|
|
140
137
|
exports: [
|
|
141
138
|
PermissionApprovalJobs,
|
|
@@ -157,7 +154,6 @@ ToolsModule = __decorate([
|
|
|
157
154
|
ConversationToolInfo,
|
|
158
155
|
OrgExtensionTools,
|
|
159
156
|
OrgToolSwitches,
|
|
160
|
-
DeviceOpResolver,
|
|
161
157
|
],
|
|
162
158
|
})
|
|
163
159
|
], ToolsModule);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capybara-hq/kernel",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.69",
|
|
4
4
|
"description": "Capybara kernel: config, database, plugin host and HTTP API of the Capybara agent platform",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"yaml": "^2.9.1",
|
|
67
67
|
"yauzl": "3.4.0",
|
|
68
68
|
"zod": "^4.6.7",
|
|
69
|
-
"@capybara-hq/plugin-sdk": "^0.1.0-rc.
|
|
69
|
+
"@capybara-hq/plugin-sdk": "^0.1.0-rc.54"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@langchain/langgraph-checkpoint-validation": "^1.2.0",
|
|
@@ -75,8 +75,7 @@
|
|
|
75
75
|
"@types/ws": "^8.18.2",
|
|
76
76
|
"@types/yauzl": "3.4.0",
|
|
77
77
|
"ws": "^8.22.0",
|
|
78
|
-
"@capybara-hq/testing": "0.1.0-rc.
|
|
79
|
-
"@capybara-hq/device": "0.1.0-rc.27"
|
|
78
|
+
"@capybara-hq/testing": "0.1.0-rc.35"
|
|
80
79
|
},
|
|
81
80
|
"scripts": {
|
|
82
81
|
"build": "tsc -b"
|