@capybara-hq/kernel 0.1.0-rc.67 → 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/bootstrap.json +9 -1
- 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/credential-key.d.ts +10 -0
- package/dist/catalog/credential-key.js +28 -0
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/plugin-upgrade.js +1 -19
- 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/connectors.controller.d.ts +2 -0
- package/dist/tools/connectors.schemas.d.ts +2 -0
- package/dist/tools/credentials.d.ts +2 -0
- package/dist/tools/network-asks.d.ts +19 -22
- package/dist/tools/network-asks.js +15 -21
- package/dist/tools/oauth/authorization-params.d.ts +7 -0
- package/dist/tools/oauth/authorization-params.js +19 -0
- package/dist/tools/oauth/flow.js +7 -0
- package/dist/tools/oauth/tokens.js +2 -1
- 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
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"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
-- Device provider phase 2 (dial-in contract): local device semantics leave the kernel for the
|
|
2
|
+
-- device-local plugin. The kernel keeps only a dial-in device's signed-in machine (its
|
|
3
|
+
-- credential and program facts); what the former local provider kept per machine, its instance
|
|
4
|
+
-- bindings and boot history, and the device's location column go.
|
|
5
|
+
-- capybara:allow-destructive local device semantics moved to device-local; project not released, no compatibility layer
|
|
6
|
+
ALTER TABLE device_machines DROP COLUMN IF EXISTS features;
|
|
7
|
+
-- capybara:allow-destructive local device semantics moved to device-local; project not released, no compatibility layer
|
|
8
|
+
ALTER TABLE device_machines DROP COLUMN IF EXISTS local_policy;
|
|
9
|
+
-- capybara:allow-destructive local device semantics moved to device-local; project not released, no compatibility layer
|
|
10
|
+
ALTER TABLE device_machines DROP COLUMN IF EXISTS owner_report;
|
|
11
|
+
-- capybara:allow-destructive local device semantics moved to device-local; project not released, no compatibility layer
|
|
12
|
+
ALTER TABLE device_machines DROP COLUMN IF EXISTS pending_policy_ops;
|
|
13
|
+
-- capybara:allow-destructive local device semantics moved to device-local; project not released, no compatibility layer
|
|
14
|
+
ALTER TABLE device_machines DROP COLUMN IF EXISTS home;
|
|
15
|
+
-- capybara:allow-destructive local device semantics moved to device-local; project not released, no compatibility layer
|
|
16
|
+
ALTER TABLE device_machines DROP COLUMN IF EXISTS roots;
|
|
17
|
+
-- capybara:allow-destructive local device semantics moved to device-local; project not released, no compatibility layer
|
|
18
|
+
ALTER TABLE device_machines DROP COLUMN IF EXISTS mode;
|
|
19
|
+
-- capybara:allow-destructive local device semantics moved to device-local; project not released, no compatibility layer
|
|
20
|
+
ALTER TABLE device_machines DROP COLUMN IF EXISTS session_isolation;
|
|
21
|
+
-- The former @local provider kept nothing of its own (a local device's files live on its machine)
|
|
22
|
+
-- and no provider can destroy its instance rows any more: they go, so deleting such a device
|
|
23
|
+
-- settles at once. The device itself stays bound to @local (unavailable until its owner deletes it).
|
|
24
|
+
-- capybara:allow-destructive the @local provider is gone and held no resources; no loaded provider can ever destroy these rows
|
|
25
|
+
DELETE FROM device_instances WHERE provider = '@local';
|
|
26
|
+
-- capybara:allow-destructive local device semantics moved to device-local; project not released, no compatibility layer
|
|
27
|
+
DROP TABLE IF EXISTS device_machine_boots;
|
|
28
|
+
-- capybara:allow-destructive local device semantics moved to device-local; project not released, no compatibility layer
|
|
29
|
+
DROP TABLE IF EXISTS device_instance_bindings;
|
|
30
|
+
ALTER TABLE devices DROP CONSTRAINT IF EXISTS devices_source_check;
|
|
31
|
+
-- capybara:allow-destructive local device semantics moved to device-local; project not released, no compatibility layer
|
|
32
|
+
ALTER TABLE devices DROP COLUMN IF EXISTS source;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Device sign-in (environments spec §13.3): {@link DeviceAuthService} behind
|
|
3
|
-
* `DeviceAuthController`. Kept apart from {@link LocalDevicesModule}, which `DevicesModule`
|
|
4
|
-
* imports (deleting a device revokes its machine), while sign-in needs both.
|
|
5
|
-
*/
|
|
6
|
-
export declare class DeviceAuthModule {
|
|
7
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { Module } from "@nestjs/common";
|
|
8
|
-
import { DevicesModule } from "../devices/devices.module.js";
|
|
9
|
-
import { DeviceAuthService } from "./device-auth.js";
|
|
10
|
-
import { LocalDevicesModule } from "./local-devices.module.js";
|
|
11
|
-
/**
|
|
12
|
-
* Device sign-in (environments spec §13.3): {@link DeviceAuthService} behind
|
|
13
|
-
* `DeviceAuthController`. Kept apart from {@link LocalDevicesModule}, which `DevicesModule`
|
|
14
|
-
* imports (deleting a device revokes its machine), while sign-in needs both.
|
|
15
|
-
*/
|
|
16
|
-
let DeviceAuthModule = class DeviceAuthModule {
|
|
17
|
-
};
|
|
18
|
-
DeviceAuthModule = __decorate([
|
|
19
|
-
Module({
|
|
20
|
-
imports: [LocalDevicesModule, DevicesModule],
|
|
21
|
-
providers: [DeviceAuthService],
|
|
22
|
-
exports: [DeviceAuthService],
|
|
23
|
-
})
|
|
24
|
-
], DeviceAuthModule);
|
|
25
|
-
export { DeviceAuthModule };
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import { type DeviceFeature, type DeviceLocalPolicySummary, type DeviceOwnerCeilingNarrowing, type DevicePolicyArgs, type LegacyDevicePolicyArgs, type LegacyDevicePolicyStatus } from "@capybara-hq/plugin-sdk";
|
|
2
|
-
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
3
|
-
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
4
|
-
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
5
|
-
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
6
|
-
import type { KernelLogger } from "../log.js";
|
|
7
|
-
import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
|
|
8
|
-
import { MachinesService } from "./machines.js";
|
|
9
|
-
import { OwnerReports } from "./owner-reports.js";
|
|
10
|
-
import { LocalDeviceRelay } from "./relay.js";
|
|
11
|
-
/** How long the machine may take to apply a policy change. */
|
|
12
|
-
export declare const POLICY_DEADLINE_MS = 30000;
|
|
13
|
-
/** How long an op left `unknown` waits for the machine's hello to report it (from its intent). */
|
|
14
|
-
export declare const UNKNOWN_OP_MS: number;
|
|
15
|
-
/**
|
|
16
|
-
* A policy change as callers ask for it (the op id and the source are added here): narrowings
|
|
17
|
-
* only. Under device protocol 4 the deployment never widens a local device: its owner adds hosts,
|
|
18
|
-
* opens the network or allows running outside the sandbox on the machine.
|
|
19
|
-
*/
|
|
20
|
-
export interface PolicyChange {
|
|
21
|
-
remove?: string[];
|
|
22
|
-
ownerCeiling?: DeviceOwnerCeilingNarrowing;
|
|
23
|
-
}
|
|
24
|
-
/** Who asked for a change, for the device's local audit line (never a network ask). */
|
|
25
|
-
export type PolicyChangeSource = Omit<LegacyDevicePolicyArgs["source"], "approvalId">;
|
|
26
|
-
/**
|
|
27
|
-
* Test seam (`KernelOverride`): called by {@link DevicePolicyService.send} right after the `policy`
|
|
28
|
-
* op's call returned, before its outcome is recorded (by `apply` or a network ask's decision);
|
|
29
|
-
* throwing stands for a crash between the call and the resolve transaction.
|
|
30
|
-
* The kernel never provides it.
|
|
31
|
-
*/
|
|
32
|
-
export declare const DEVICE_POLICY_AFTER_CALL: unique symbol;
|
|
33
|
-
/** What became of a policy change. */
|
|
34
|
-
export type PolicyChangeOutcome = {
|
|
35
|
-
applied: true;
|
|
36
|
-
policy: DeviceLocalPolicySummary;
|
|
37
|
-
} | {
|
|
38
|
-
applied: false;
|
|
39
|
-
reason: "offline" | "refused" | "unsupported";
|
|
40
|
-
message: string;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* An op whose intent is recorded ({@link DevicePolicyService.begin}): the call sends `args` to
|
|
44
|
-
* the device's machine.
|
|
45
|
-
*/
|
|
46
|
-
export interface PolicyIntent {
|
|
47
|
-
orgId: string;
|
|
48
|
-
deviceId: string;
|
|
49
|
-
machineId: string;
|
|
50
|
-
opId: string;
|
|
51
|
-
args: DevicePolicyArgs;
|
|
52
|
-
/**
|
|
53
|
-
* The staged (protocol 4) connection the op goes to, when the device's machine is connected
|
|
54
|
-
* over one: the op is sent as a v3 `policy` request fenced to it (not sent at all once it
|
|
55
|
-
* changed), and its answer's owner report is recorded with its id. Absent: protocol 2.
|
|
56
|
-
*/
|
|
57
|
-
connection?: {
|
|
58
|
-
connectionId: string;
|
|
59
|
-
maxFrameBytes: number;
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* What became of a sent op, as recorded by {@link DevicePolicyService.settleIn}: `applied` (with
|
|
64
|
-
* the policy the machine wrote, when it said), `refused` (the machine's message), `not_received`
|
|
65
|
-
* (the machine never got it and never will), `unknown` (no answer).
|
|
66
|
-
*/
|
|
67
|
-
export type PolicyOpResult = {
|
|
68
|
-
outcome: "applied";
|
|
69
|
-
policy?: DeviceLocalPolicySummary;
|
|
70
|
-
/** A staged (v3) answer's owner report: recorded before the outcome is accepted (B2). */
|
|
71
|
-
ownerCeiling?: unknown;
|
|
72
|
-
/** The authenticated connection the answer arrived on (recorded with the report). */
|
|
73
|
-
connectionId?: string | null;
|
|
74
|
-
} | {
|
|
75
|
-
outcome: "refused";
|
|
76
|
-
message: string;
|
|
77
|
-
} | {
|
|
78
|
-
outcome: "not_received";
|
|
79
|
-
} | {
|
|
80
|
-
outcome: "interrupted";
|
|
81
|
-
} | {
|
|
82
|
-
outcome: "unknown";
|
|
83
|
-
};
|
|
84
|
-
/** What a machine says of an op id ({@link DevicePolicyService.outcomeOf}). */
|
|
85
|
-
export type PolicyOpStatus = (LegacyDevicePolicyStatus & {
|
|
86
|
-
ownerCeiling?: unknown;
|
|
87
|
-
connectionId?: string | null;
|
|
88
|
-
}) | {
|
|
89
|
-
outcome: "offline";
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* Narrows a local device's policy on its machine (approval-only profiles design, "Settings model":
|
|
93
|
-
* hosts removed, the network to the allowlist, no running outside the sandbox, the workspace
|
|
94
|
-
* reach): the kernel→device `policy`
|
|
95
|
-
* op over the {@link LocalDeviceRelay}. The machine is the authority: it refuses what its owner
|
|
96
|
-
* forbids, validates every host and answers with the policy as written, which the kernel then
|
|
97
|
-
* keeps on the active machine's row (§5.4).
|
|
98
|
-
*
|
|
99
|
-
* Intent first (transactional outbox spec §7): {@link begin} writes the intent in a transaction
|
|
100
|
-
* before anything is sent (the entry on the machine row's `pending_policy_ops`, the audit
|
|
101
|
-
* `device.policy_requested` and the `device-op-resolve` job owed for when the op can no longer
|
|
102
|
-
* reach the machine); the call sends the op with its id (no transaction open); {@link settleIn}
|
|
103
|
-
* records the outcome: `device.policy_changed` (applied), `device.policy_failed` (refused, never
|
|
104
|
-
* received) or `device.policy_unknown` (no answer: the entry stays, `unknown`, for the machine's
|
|
105
|
-
* next hello or the resolver). A crash between the call and the resolve transaction leaves the
|
|
106
|
-
* intent and its owed job, whose resolver asks the machine what became of the op (never sends it
|
|
107
|
-
* again). Callers decide who may change a device's policy (the device owner, in a signed-in
|
|
108
|
-
* session); this service checks only that the device is a live device of the org.
|
|
109
|
-
*/
|
|
110
|
-
export declare class DevicePolicyService {
|
|
111
|
-
private readonly db;
|
|
112
|
-
readonly txHost: TransactionHost;
|
|
113
|
-
private readonly relay;
|
|
114
|
-
private readonly machines;
|
|
115
|
-
private readonly outbox;
|
|
116
|
-
private readonly config;
|
|
117
|
-
private readonly log;
|
|
118
|
-
private readonly ceilings;
|
|
119
|
-
private readonly owners;
|
|
120
|
-
private readonly afterCall;
|
|
121
|
-
constructor(db: KernelDb, txHost: TransactionHost, relay: Pick<LocalDeviceRelay, "call" | "callV3" | "holderLive" | "connection" | "stagedTransport">, machines: Pick<MachinesService, "activeFor">, outbox: Pick<OutboxService, "add">, config: Pick<KernelConfigService, "get">, log: Pick<KernelLogger, "warn">, ceilings: PermissionCeilingWrites, owners: Pick<OwnerReports, "recordLocked">, afterCall?: (opId: string) => void);
|
|
122
|
-
/**
|
|
123
|
-
* Changes the policy: {@link begin}, the call, then the outcome recorded in its own transaction
|
|
124
|
-
* (no transaction may be open). Never throws for an offline machine, a refusal or a program
|
|
125
|
-
* without the `policyOpId` feature (nothing is sent to it); a device that is not a live device
|
|
126
|
-
* of `orgId` is `device.not_found`.
|
|
127
|
-
*/
|
|
128
|
-
apply(input: {
|
|
129
|
-
orgId: string;
|
|
130
|
-
deviceId: string;
|
|
131
|
-
change: PolicyChange;
|
|
132
|
-
source: PolicyChangeSource;
|
|
133
|
-
actorTokenId?: string;
|
|
134
|
-
}): Promise<PolicyChangeOutcome>;
|
|
135
|
-
/**
|
|
136
|
-
* Checks the device and its machine, then records the intent in its own transaction: the entry
|
|
137
|
-
* (`sent`) on the machine's row, the audit `device.policy_requested` and the `device-op-resolve`
|
|
138
|
-
* job owed for when the op can no longer reach the machine. No transaction may be open (the
|
|
139
|
-
* call follows). Returns the intent, or why nothing will be sent (offline, unsupported).
|
|
140
|
-
*/
|
|
141
|
-
begin(input: {
|
|
142
|
-
orgId: string;
|
|
143
|
-
deviceId: string;
|
|
144
|
-
change: PolicyChange;
|
|
145
|
-
source: PolicyChangeSource;
|
|
146
|
-
actorTokenId?: string;
|
|
147
|
-
}): Promise<{
|
|
148
|
-
intent: PolicyIntent;
|
|
149
|
-
} | {
|
|
150
|
-
outcome: PolicyChangeOutcome;
|
|
151
|
-
}>;
|
|
152
|
-
/**
|
|
153
|
-
* Sends the intent's `policy` op (no transaction may be open) and classifies the answer:
|
|
154
|
-
* applied; refused (the machine's local policy refused it: its message); anything else is
|
|
155
|
-
* `unknown`, left to the resolver's `policyStatus`: no answer, and an answer the kernel cannot
|
|
156
|
-
* trust to mean "not applied" (a result it cannot read, the machine's own error). `notFound`:
|
|
157
|
-
* the device was deleted meanwhile (recorded as unknown; the caller throws `device.not_found`).
|
|
158
|
-
*/
|
|
159
|
-
send(intent: PolicyIntent): Promise<{
|
|
160
|
-
result: PolicyOpResult;
|
|
161
|
-
outcome: PolicyChangeOutcome;
|
|
162
|
-
notFound?: true;
|
|
163
|
-
}>;
|
|
164
|
-
/** The `policy` op's call and its classification ({@link send}). */
|
|
165
|
-
private call;
|
|
166
|
-
/** The authenticated connection a call goes to now, or null when unknown (M4). */
|
|
167
|
-
private connectionIdOf;
|
|
168
|
-
/**
|
|
169
|
-
* What the machine says became of the op `opId` (a read-only `policyStatus`), or `offline` when
|
|
170
|
-
* no replica holds its connection or it does not answer. Never sends the change.
|
|
171
|
-
*/
|
|
172
|
-
outcomeOf(deviceId: string, opId: string): Promise<PolicyOpStatus>;
|
|
173
|
-
/**
|
|
174
|
-
* Records what became of the op `opId` of machine `machineId`, in the caller's transaction (the
|
|
175
|
-
* machine's row locked): `applied` → the policy the machine wrote (when given) kept on the row,
|
|
176
|
-
* the entry removed, `device.policy_changed` (`late` when the op was left `unknown`); `refused`,
|
|
177
|
-
* `not_received` or `interrupted` → the entry removed, `device.policy_failed` (`reason` the
|
|
178
|
-
* outcome); `unknown` → the entry kept, `unknown` until a day after its intent,
|
|
179
|
-
* `device.policy_unknown` (once; ignored once a hello reported the op). Returns the outcome for
|
|
180
|
-
* the caller, or null when the op has no live entry (resolved already, or expired: a no-op).
|
|
181
|
-
*/
|
|
182
|
-
settleIn(ref: {
|
|
183
|
-
machineId: string;
|
|
184
|
-
opId: string;
|
|
185
|
-
}, result: PolicyOpResult): Promise<PolicyChangeOutcome | null>;
|
|
186
|
-
/** The active machine's features and policy summary (null when no machine is connected). */
|
|
187
|
-
summary(deviceId: string): Promise<{
|
|
188
|
-
features: DeviceFeature[];
|
|
189
|
-
policy: DeviceLocalPolicySummary | null;
|
|
190
|
-
} | null>;
|
|
191
|
-
/**
|
|
192
|
-
* How long after its intent an op can no longer reach the machine: the call's deadline, the
|
|
193
|
-
* reconnect grace and the request list's margin (the relay's list TTL), plus 5 s. A machine
|
|
194
|
-
* that does not know the op id by then never will.
|
|
195
|
-
*/
|
|
196
|
-
resolveDelayMs(): number;
|
|
197
|
-
/**
|
|
198
|
-
* The ordered prelude of a transaction that records an op's outcome ({@link settleIn}) after it
|
|
199
|
-
* locked other rows (a network ask's conversation, its approval, its run): the permission
|
|
200
|
-
* authority lock of the machine's device, read without a lock first. The global order puts it
|
|
201
|
-
* before every conversation row (`withOrderedLocks`); {@link settleIn} re-reads the machine
|
|
202
|
-
* under it. A machine that is gone locks nothing (its settle is a no-op).
|
|
203
|
-
*/
|
|
204
|
-
lockMachineDevice(machineId: string): Promise<void>;
|
|
205
|
-
/** {@link settleIn} in its own transaction (the {@link apply} path). */
|
|
206
|
-
private settle;
|
|
207
|
-
/**
|
|
208
|
-
* The intent transaction: locks the machine's row (still the device's active machine), appends
|
|
209
|
-
* the entry (dropping the expired ones), audits `device.policy_requested` and owes the
|
|
210
|
-
* `device-op-resolve` job. False when the machine was revoked meanwhile (nothing written).
|
|
211
|
-
*/
|
|
212
|
-
private recordIntent;
|
|
213
|
-
}
|