@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
package/dist/schedules/fire.d.ts
CHANGED
|
@@ -3,13 +3,14 @@ import { ChannelConnections } from "../channels/connections.service.js";
|
|
|
3
3
|
import { ConversationAccess } from "../conversations/access.js";
|
|
4
4
|
import { ConversationsService } from "../conversations/conversations.service.js";
|
|
5
5
|
import { ConversationQueue } from "../conversations/queue.service.js";
|
|
6
|
+
import { DialInRelay } from "../dial-in/relay.js";
|
|
6
7
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
7
8
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
8
9
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
9
|
-
import { LockService } from "../infra/lock/lock.service.js";
|
|
10
10
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
11
11
|
import type { KernelLogger } from "../log.js";
|
|
12
12
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
13
|
+
import { DeviceProviders } from "../sandbox/providers.js";
|
|
13
14
|
import { type SchedSettleJobData } from "./job-ids.js";
|
|
14
15
|
import { ScheduledTaskRunTracker } from "./run-tracker.js";
|
|
15
16
|
import { ScheduledTaskStore } from "./store.js";
|
|
@@ -52,14 +53,18 @@ export declare class ScheduledTaskFirer {
|
|
|
52
53
|
private readonly conversations;
|
|
53
54
|
private readonly queue;
|
|
54
55
|
private readonly connections;
|
|
55
|
-
/**
|
|
56
|
-
private readonly
|
|
56
|
+
/** Whether a dial-in device's machine is connected now. */
|
|
57
|
+
private readonly relay;
|
|
58
|
+
/** Each device's provider (whether it serves its devices over the dial-in channel). */
|
|
59
|
+
private readonly providers;
|
|
57
60
|
private readonly log;
|
|
58
61
|
/** The claim owes the run's settle check (ruling R26). */
|
|
59
62
|
private readonly outbox;
|
|
60
63
|
constructor(kdb: KernelDb, txHost: TransactionHost, config: Pick<KernelConfigService, "get">, store: ScheduledTaskStore, tracker: Pick<ScheduledTaskRunTracker, "inFlightIn" | "failStartIn">, orgLock: Pick<OrgLock, "tryLock">, agents: Pick<AgentLookup, "get">, access: Pick<ConversationAccess, "isAccessible">, conversations: Pick<ConversationsService, "createWithMessage" | "create">, queue: Pick<ConversationQueue, "add">, connections: Pick<ChannelConnections, "row" | "channel">,
|
|
61
|
-
/**
|
|
62
|
-
|
|
64
|
+
/** Whether a dial-in device's machine is connected now. */
|
|
65
|
+
relay: Pick<DialInRelay, "online">,
|
|
66
|
+
/** Each device's provider (whether it serves its devices over the dial-in channel). */
|
|
67
|
+
providers: Pick<DeviceProviders, "forDevice">, log: Pick<KernelLogger, "warn" | "info">,
|
|
63
68
|
/** The claim owes the run's settle check (ruling R26). */
|
|
64
69
|
outbox: Pick<OutboxService, "add">);
|
|
65
70
|
private get db();
|
|
@@ -126,7 +131,11 @@ export declare class ScheduledTaskFirer {
|
|
|
126
131
|
* archived ones included), so a run may post there on their behalf.
|
|
127
132
|
*/
|
|
128
133
|
private inGroup;
|
|
129
|
-
/**
|
|
134
|
+
/**
|
|
135
|
+
* The device is gone, or its provider serves it over the dial-in channel and its machine is not
|
|
136
|
+
* connected now ({@link DialInRelay.online}). A provider not loaded here is not asked: the run's
|
|
137
|
+
* own sandbox use refuses it (`device.unavailable`).
|
|
138
|
+
*/
|
|
130
139
|
private deviceOffline;
|
|
131
140
|
}
|
|
132
141
|
/**
|
package/dist/schedules/fire.js
CHANGED
|
@@ -17,18 +17,20 @@ import { ConversationsModule } from "../conversations/conversations.module.js";
|
|
|
17
17
|
import { ConversationsService } from "../conversations/conversations.service.js";
|
|
18
18
|
import { ConversationQueue } from "../conversations/queue.service.js";
|
|
19
19
|
import { channelSource } from "../conversations/source.js";
|
|
20
|
+
import { DialInRelay } from "../dial-in/relay.js";
|
|
21
|
+
import { DialInRelayModule } from "../dial-in/relay.module.js";
|
|
20
22
|
import { ApiError } from "../errors.js";
|
|
21
23
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
22
24
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
23
25
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
24
26
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
25
|
-
import { LockService } from "../infra/lock/lock.service.js";
|
|
26
27
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
27
28
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
28
|
-
import { deviceLeaseKey } from "../local-devices/keys.js";
|
|
29
29
|
import { OrgLock, OrgLockModule } from "../orgs/org-lock.js";
|
|
30
30
|
import { FORBIDDEN_TOOLS_UNREADABLE_ERROR } from "../orgs/settings.service.js";
|
|
31
31
|
import { RuntimeModule } from "../runtime/runtime.module.js";
|
|
32
|
+
import { DeviceProviders, servesDialIn } from "../sandbox/providers.js";
|
|
33
|
+
import { SandboxProviderRegistryModule } from "../sandbox/providers.module.js";
|
|
32
34
|
import { readScheduleSettings } from "./effective-settings.js";
|
|
33
35
|
import { oweSchedSettle, SCHED_LATE_FIRE_SLACK_MS, SCHED_SETTLE_AFTER_MS, SCHED_SETTLE_LONG_CHECKS, SCHED_SETTLE_RECHECK_MS, } from "./job-ids.js";
|
|
34
36
|
import { pauseTaskIn } from "./pause.js";
|
|
@@ -100,12 +102,15 @@ let ScheduledTaskFirer = class ScheduledTaskFirer {
|
|
|
100
102
|
conversations;
|
|
101
103
|
queue;
|
|
102
104
|
connections;
|
|
103
|
-
|
|
105
|
+
relay;
|
|
106
|
+
providers;
|
|
104
107
|
log;
|
|
105
108
|
outbox;
|
|
106
109
|
constructor(kdb, txHost, config, store, tracker, orgLock, agents, access, conversations, queue, connections,
|
|
107
|
-
/**
|
|
108
|
-
|
|
110
|
+
/** Whether a dial-in device's machine is connected now. */
|
|
111
|
+
relay,
|
|
112
|
+
/** Each device's provider (whether it serves its devices over the dial-in channel). */
|
|
113
|
+
providers, log,
|
|
109
114
|
/** The claim owes the run's settle check (ruling R26). */
|
|
110
115
|
outbox) {
|
|
111
116
|
this.kdb = kdb;
|
|
@@ -119,7 +124,8 @@ let ScheduledTaskFirer = class ScheduledTaskFirer {
|
|
|
119
124
|
this.conversations = conversations;
|
|
120
125
|
this.queue = queue;
|
|
121
126
|
this.connections = connections;
|
|
122
|
-
this.
|
|
127
|
+
this.relay = relay;
|
|
128
|
+
this.providers = providers;
|
|
123
129
|
this.log = log;
|
|
124
130
|
this.outbox = outbox;
|
|
125
131
|
}
|
|
@@ -630,18 +636,23 @@ let ScheduledTaskFirer = class ScheduledTaskFirer {
|
|
|
630
636
|
.executeTakeFirst();
|
|
631
637
|
return row !== undefined;
|
|
632
638
|
}
|
|
633
|
-
/**
|
|
639
|
+
/**
|
|
640
|
+
* The device is gone, or its provider serves it over the dial-in channel and its machine is not
|
|
641
|
+
* connected now ({@link DialInRelay.online}). A provider not loaded here is not asked: the run's
|
|
642
|
+
* own sandbox use refuses it (`device.unavailable`).
|
|
643
|
+
*/
|
|
634
644
|
async deviceOffline(deviceId) {
|
|
635
645
|
const row = await this.db
|
|
636
646
|
.selectFrom("devices")
|
|
637
|
-
.select(["
|
|
647
|
+
.select(["provider", "deleted_at"])
|
|
638
648
|
.where("id", "=", deviceId)
|
|
639
649
|
.executeTakeFirst();
|
|
640
650
|
if (!row || row.deleted_at !== null)
|
|
641
651
|
return true;
|
|
642
|
-
|
|
652
|
+
const p = this.providers.forDevice(row.provider);
|
|
653
|
+
if (p === undefined || !servesDialIn(p))
|
|
643
654
|
return false;
|
|
644
|
-
return (await this.
|
|
655
|
+
return !(await this.relay.online(deviceId));
|
|
645
656
|
}
|
|
646
657
|
};
|
|
647
658
|
__decorate([
|
|
@@ -678,9 +689,10 @@ ScheduledTaskFirer = __decorate([
|
|
|
678
689
|
__param(8, Inject(ConversationsService)),
|
|
679
690
|
__param(9, Inject(ConversationQueue)),
|
|
680
691
|
__param(10, Inject(ChannelConnections)),
|
|
681
|
-
__param(11, Inject(
|
|
682
|
-
__param(12, Inject(
|
|
683
|
-
__param(13, Inject(
|
|
692
|
+
__param(11, Inject(DialInRelay)),
|
|
693
|
+
__param(12, Inject(DeviceProviders)),
|
|
694
|
+
__param(13, Inject(KERNEL_LOGGER)),
|
|
695
|
+
__param(14, Inject(OutboxService))
|
|
684
696
|
], ScheduledTaskFirer);
|
|
685
697
|
export { ScheduledTaskFirer };
|
|
686
698
|
/**
|
|
@@ -700,6 +712,8 @@ ScheduledTaskFireModule = __decorate([
|
|
|
700
712
|
OrgLockModule,
|
|
701
713
|
ScheduledTaskStoreModule,
|
|
702
714
|
ScheduledTaskTrackerModule,
|
|
715
|
+
DialInRelayModule,
|
|
716
|
+
SandboxProviderRegistryModule,
|
|
703
717
|
],
|
|
704
718
|
providers: [ScheduledTaskFirer, ScheduledTaskScanJob],
|
|
705
719
|
exports: [ScheduledTaskFirer],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { validateAllowHost } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { GIT_REPO_MAX_CHARS } from "../conversations/events.js";
|
|
3
|
-
import { orgAllows } from "../local-devices/network-grants.js";
|
|
4
3
|
import { roleAtLeast } from "../orgs/roles.js";
|
|
4
|
+
import { orgAllows } from "../sandbox/network-grants.js";
|
|
5
5
|
import { isFixedAsk } from "../tools/fixed-ask.js";
|
|
6
6
|
import { changesAgentSkills } from "./unattended.js";
|
|
7
7
|
/**
|
|
@@ -50,13 +50,6 @@ export interface ScheduleAttention {
|
|
|
50
50
|
* can add the host (network ask-to-allow spec §8.3); the creator cannot pre-approve them.
|
|
51
51
|
*/
|
|
52
52
|
needsAdmin: string[];
|
|
53
|
-
/**
|
|
54
|
-
* `missing` holds `network:` keys and the task's device cannot take network grants from the
|
|
55
|
-
* deployment (Docker mode, or a program too old to take them): a task grant would not reach it;
|
|
56
|
-
* its owner allows the domains locally (`capybara-device policy add allowedDomains <host>`). No
|
|
57
|
-
* device reports this now, so the kernel always sends false; the wire field stays for the web.
|
|
58
|
-
*/
|
|
59
|
-
deviceRefuses: boolean;
|
|
60
53
|
/** `failed` only: the run's error; else null. */
|
|
61
54
|
error: string | null;
|
|
62
55
|
/** When the pause happened, or when the refused or failed run was due. */
|
|
@@ -24,12 +24,12 @@ import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
|
24
24
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
25
25
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
26
26
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
27
|
-
import { orgAllows } from "../local-devices/network-grants.js";
|
|
28
27
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
29
28
|
import { can, roleAtLeast } from "../orgs/roles.js";
|
|
30
29
|
import { FORBIDDEN_TOOLS_UNREADABLE_GRANT_ERROR } from "../orgs/settings.service.js";
|
|
31
30
|
import { ProviderRegistry } from "../runtime/providers.js";
|
|
32
31
|
import { orgHostOutsideCeiling } from "../sandbox/modes.js";
|
|
32
|
+
import { orgAllows } from "../sandbox/network-grants.js";
|
|
33
33
|
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
34
34
|
import { isTimeZone } from "../time-zone.js";
|
|
35
35
|
import { ToolRegistry } from "../tools/registry.js";
|
|
@@ -685,7 +685,6 @@ let ScheduledTasksService = class ScheduledTasksService {
|
|
|
685
685
|
missing: [],
|
|
686
686
|
needsRole: [],
|
|
687
687
|
needsAdmin: [],
|
|
688
|
-
deviceRefuses: false,
|
|
689
688
|
error: null,
|
|
690
689
|
at: task.updatedAt,
|
|
691
690
|
});
|
|
@@ -703,7 +702,6 @@ let ScheduledTasksService = class ScheduledTasksService {
|
|
|
703
702
|
missing: [],
|
|
704
703
|
needsRole: [],
|
|
705
704
|
needsAdmin: [],
|
|
706
|
-
deviceRefuses: false,
|
|
707
705
|
error: run.error,
|
|
708
706
|
at: run.fired_at ?? new Date(run.scheduled_for),
|
|
709
707
|
});
|
|
@@ -755,7 +753,6 @@ let ScheduledTasksService = class ScheduledTasksService {
|
|
|
755
753
|
needsRole,
|
|
756
754
|
needsAdmin,
|
|
757
755
|
// the wire field stays for the web; no network grant is refused by a device now
|
|
758
|
-
deviceRefuses: false,
|
|
759
756
|
error: null,
|
|
760
757
|
at: run.fired_at ?? new Date(run.scheduled_for),
|
|
761
758
|
});
|
|
@@ -10,10 +10,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { Inject, Module } from "@nestjs/common";
|
|
11
11
|
import { AgentLookupModule } from "../agents/agent-lookup.js";
|
|
12
12
|
import { ConversationAccessModule } from "../conversations/access.js";
|
|
13
|
+
import { DialInModule } from "../dial-in/dial-in.module.js";
|
|
13
14
|
import { ExtensionRegistryModule } from "../extensions/registry.js";
|
|
14
|
-
import { LocalDevicesModule } from "../local-devices/local-devices.module.js";
|
|
15
15
|
import { OrgLockModule } from "../orgs/org-lock.js";
|
|
16
16
|
import { ProvidersModule } from "../runtime/providers.js";
|
|
17
|
+
import { NetworkGrantsModule } from "../sandbox/network-grants.module.js";
|
|
17
18
|
import { SandboxModule } from "../sandbox/sandbox.module.js";
|
|
18
19
|
import { ScheduleToolsPort } from "../tools/builtins/schedules.js";
|
|
19
20
|
import { ToolsModule } from "../tools/tools.module.js";
|
|
@@ -48,9 +49,10 @@ SchedulesModule = __decorate([
|
|
|
48
49
|
ToolsModule,
|
|
49
50
|
// a new-conversation task's model must resolve for the org
|
|
50
51
|
ProvidersModule,
|
|
51
|
-
// network grants: the org's effective egress
|
|
52
|
+
// network grants: the org's effective egress
|
|
52
53
|
SandboxModule,
|
|
53
|
-
|
|
54
|
+
NetworkGrantsModule,
|
|
55
|
+
DialInModule,
|
|
54
56
|
],
|
|
55
57
|
providers: [ScheduledTasksService],
|
|
56
58
|
exports: [ScheduledTasksService, ScheduledTaskStoreModule],
|
package/dist/skills/invoke.d.ts
CHANGED
|
@@ -137,7 +137,7 @@ export declare class SkillInvoker {
|
|
|
137
137
|
/** A bound conversation's latest `project_root` (its project skills). */
|
|
138
138
|
eventLog: Pick<EventLog, "latestOfType">,
|
|
139
139
|
/** A project skill's SKILL.md is read through the conversation's device. */
|
|
140
|
-
sandbox: Pick<SandboxService, "withSandbox">, devices: Pick<ConversationDevices, "forTool" | "modeLevel" | "workingFacts"
|
|
140
|
+
sandbox: Pick<SandboxService, "withSandbox">, devices: Pick<ConversationDevices, "forTool" | "modeLevel" | "workingFacts">,
|
|
141
141
|
/** The paired activation gate: once on, no raw device use reads a project skill. */
|
|
142
142
|
activation?: boolean | undefined);
|
|
143
143
|
/**
|
package/dist/skills/invoke.js
CHANGED
|
@@ -413,9 +413,8 @@ let SkillInvoker = class SkillInvoker {
|
|
|
413
413
|
try {
|
|
414
414
|
const deviceId = await this.devices.forTool(a.orgId, a.conversationId);
|
|
415
415
|
// a person invokes in a root conversation: it is its own sandbox conversation
|
|
416
|
-
const [level,
|
|
416
|
+
const [level, working] = await Promise.all([
|
|
417
417
|
this.devices.modeLevel(a.orgId, deviceId),
|
|
418
|
-
this.devices.projectReach(a.orgId, deviceId),
|
|
419
418
|
this.devices.workingFacts(a.orgId, a.conversationId, a.conversationId, deviceId),
|
|
420
419
|
]);
|
|
421
420
|
// unknown mode: the strict (sandbox) path checks stay (fail closed), as in a tool call
|
|
@@ -434,7 +433,7 @@ let SkillInvoker = class SkillInvoker {
|
|
|
434
433
|
h,
|
|
435
434
|
roots: info.roots,
|
|
436
435
|
// the working root a tool call of this conversation would get (one rule)
|
|
437
|
-
workingRoot: sessionWorkingRoot(working,
|
|
436
|
+
workingRoot: sessionWorkingRoot(working, info.roots.workspace),
|
|
438
437
|
p,
|
|
439
438
|
signal,
|
|
440
439
|
}, root, bare), AbortSignal.timeout(PROJECT_SKILL_READ_TIMEOUT_MS));
|
|
@@ -71,7 +71,10 @@ export interface NetworkAskDetail {
|
|
|
71
71
|
result: KeptToolResult;
|
|
72
72
|
/** The hosts the decision allowed (every approved decision writes them; none: nothing). */
|
|
73
73
|
grantedHosts?: string[];
|
|
74
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* What took effect: a run grant (`once`, the only decision: an ask never adds a host to the
|
|
76
|
+
* device's own network list, only its owner's network setting does).
|
|
77
|
+
*/
|
|
75
78
|
outcome?: "once";
|
|
76
79
|
}
|
|
77
80
|
/** A network ask's detail as the API shows it: without the kept command result. */
|
|
@@ -376,8 +379,8 @@ export interface NetworkAskInput {
|
|
|
376
379
|
requestedFor: string;
|
|
377
380
|
detail: Omit<NetworkAskDetail, "grantedHosts" | "outcome">;
|
|
378
381
|
/**
|
|
379
|
-
* Always `["once"]`: a run grant (approval-only profiles design).
|
|
380
|
-
*
|
|
382
|
+
* Always `["once"]`: a run grant (approval-only profiles design). An ask never adds a host to the
|
|
383
|
+
* device's own network list (only its owner's network setting does), so "always" is never offered.
|
|
381
384
|
*/
|
|
382
385
|
scopes: "once"[];
|
|
383
386
|
}
|
|
@@ -521,8 +524,8 @@ export declare class ApprovalsService {
|
|
|
521
524
|
* A network ask's decision (network ask-to-allow spec §5.2), one at a time per ask across
|
|
522
525
|
* replicas: only the device owner (`requested_for`) decides, in a signed-in session (a personal
|
|
523
526
|
* access token is refused; the route already refuses service and embed tokens); the allowed
|
|
524
|
-
* hosts are a subset of those asked. The decision is a run grant only (`once`):
|
|
525
|
-
*
|
|
527
|
+
* hosts are a subset of those asked. The decision is a run grant only (`once`): an ask never adds
|
|
528
|
+
* a host to the device's own network list, so `always` is refused. Every
|
|
526
529
|
* decision resumes the run in its transaction and is announced after the commit.
|
|
527
530
|
*/
|
|
528
531
|
private decideNetwork;
|
|
@@ -850,8 +850,8 @@ let ApprovalsService = class ApprovalsService {
|
|
|
850
850
|
* A network ask's decision (network ask-to-allow spec §5.2), one at a time per ask across
|
|
851
851
|
* replicas: only the device owner (`requested_for`) decides, in a signed-in session (a personal
|
|
852
852
|
* access token is refused; the route already refuses service and embed tokens); the allowed
|
|
853
|
-
* hosts are a subset of those asked. The decision is a run grant only (`once`):
|
|
854
|
-
*
|
|
853
|
+
* hosts are a subset of those asked. The decision is a run grant only (`once`): an ask never adds
|
|
854
|
+
* a host to the device's own network list, so `always` is refused. Every
|
|
855
855
|
* decision resumes the run in its transaction and is announced after the commit.
|
|
856
856
|
*/
|
|
857
857
|
async decideNetwork(orgId, id, accountId, body, actorTokenId, via) {
|
|
@@ -896,9 +896,9 @@ let ApprovalsService = class ApprovalsService {
|
|
|
896
896
|
let network;
|
|
897
897
|
if (body.decision === "approve") {
|
|
898
898
|
const scope = body.scope ?? "once";
|
|
899
|
-
// a run grant only (approval-only profiles
|
|
900
|
-
//
|
|
901
|
-
//
|
|
899
|
+
// a run grant only (approval-only profiles): an ask never widens the device's own network
|
|
900
|
+
// list (its owner's setting does), so `always` is refused, also for an ask made before that
|
|
901
|
+
// still listing it
|
|
902
902
|
if (scope !== "once" || !ask.scopes.includes(scope)) {
|
|
903
903
|
throw new ApiError("approval.scope_not_allowed", `Scope "${scope}" is not allowed for this approval; allowed: once`);
|
|
904
904
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { classifyAddress, DEFAULT_SANDBOX_ROOTS, isSandboxOperationOutcomeUnknownError, isSandboxPermissionUnsupportedError, isSandboxScopeDeniedError, isSandboxWorkUnsettledError, ToolError, } from "@capybara-hq/plugin-sdk";
|
|
1
|
+
import { classifyAddress, DEFAULT_SANDBOX_ROOTS, isDeviceRequestNotSent, isSandboxOperationOutcomeUnknownError, isSandboxPermissionUnsupportedError, isSandboxScopeDeniedError, isSandboxWorkUnsettledError, ToolError, } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { backgroundMaxSeconds, LAUNCH_EXEC_TIMEOUT_MS, managedStartedText, managedTaskArtifactPath, newTaskId, } from "../../../background/launch.js";
|
|
3
3
|
import { taskReasonText } from "../../../background/render.js";
|
|
4
|
-
import { isDeviceRequestNotSent } from "../../../local-devices/relay.js";
|
|
5
4
|
import { isEscalationGrantMissing } from "../../../sandbox/operation-authority-types.js";
|
|
6
5
|
import { launchRefusedText, operationIdFor } from "../../../sandbox/operation-intents.js";
|
|
7
6
|
import { ESCALATION_JUSTIFICATION_MAX_CHARS, ESCALATION_RETRY_HINT, SANDBOX_ESCALATED, } from "../../../sandbox/review/permission-candidate.js";
|
|
@@ -32,7 +32,7 @@ export interface SandboxToolDeps {
|
|
|
32
32
|
* (absent in test stubs: free mode) gives what decides the working root, read as the review
|
|
33
33
|
* reads it.
|
|
34
34
|
*/
|
|
35
|
-
devices: Pick<ConversationDevices, "forTool"> & Partial<Pick<ConversationDevices, "usableNow" | "unusableReason" | "modeLevel" | "workingFacts"
|
|
35
|
+
devices: Pick<ConversationDevices, "forTool"> & Partial<Pick<ConversationDevices, "usableNow" | "unusableReason" | "modeLevel" | "workingFacts">>;
|
|
36
36
|
/** Background `Bash` tasks; absent in test stubs, where `run_in_background` is refused. */
|
|
37
37
|
background?: Pick<BackgroundTaskStore, "releaseStop" | "get" | "advanceOffset" | "runningOwnedBy" | "finishedOwnedBy"> & Partial<Pick<BackgroundTaskStore, "reserveManaged" | "failManagedPreEffect">>;
|
|
38
38
|
/**
|
|
@@ -137,6 +137,12 @@ export declare const SANDBOX_UNAVAILABLE_REASON: string;
|
|
|
137
137
|
export declare function noSandboxError(): ToolError;
|
|
138
138
|
/** A device whose provider does not serve its org now (`device.unavailable`): files kept. */
|
|
139
139
|
export declare 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.";
|
|
140
|
+
/**
|
|
141
|
+
* The device's files are gone at its provider (`device.files_lost`): the devices page resets them
|
|
142
|
+
* where the provider offers that; otherwise the device is set up again where its provider keeps
|
|
143
|
+
* its files (a dial-in device: its machine signs in to it again).
|
|
144
|
+
*/
|
|
145
|
+
export declare 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.";
|
|
140
146
|
/**
|
|
141
147
|
* A provider call that never connected (refused, unknown host, unreachable network): the request
|
|
142
148
|
* did not reach the provider, so the call did nothing in the sandbox.
|
|
@@ -144,6 +150,8 @@ export declare const ENV_UNAVAILABLE_TEXT = "This conversation's device runs on
|
|
|
144
150
|
export declare 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 \u2192 Extensions). Continue without the sandbox, or ask the person to have a super admin check it.";
|
|
145
151
|
/** A provider connection that broke during the call: the provider may have acted before it broke. */
|
|
146
152
|
export declare 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 \u2192 Extensions).";
|
|
153
|
+
/** A dial-in device whose machine is not connected (`device.offline`, the SDK's offline error). */
|
|
154
|
+
export declare 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.";
|
|
147
155
|
/**
|
|
148
156
|
* A cloud provider refused the device's open public network (`sandbox.open_network_refused`): the
|
|
149
157
|
* fixed text, never the provider's own message (it may name its settings).
|
|
@@ -258,16 +266,14 @@ export declare const PLATFORM_OUTSIDE_SANDBOX_OFF_TOOL_TEXT = "Running commands
|
|
|
258
266
|
/**
|
|
259
267
|
* The device does not allow running outside the sandbox (`device.outside_sandbox_not_allowed`).
|
|
260
268
|
*/
|
|
261
|
-
export declare 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
|
|
269
|
+
export declare 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.";
|
|
262
270
|
/**
|
|
263
271
|
* The legacy retirement gate's refusals (`RetirementPendingError`, permission runtime cutover
|
|
264
272
|
* 8.5): the device's earlier instance may still run background work an earlier version started.
|
|
265
273
|
* Each says what clears it; the generic `device.unavailable` text would name an inactive provider.
|
|
266
274
|
*/
|
|
267
275
|
export declare const RETIREMENT_PENDING_TOOL_TEXT = "This device is unavailable: background work started by an earlier version may still run on its previous instance, which has not been confirmed destroyed yet, so nothing ran. Retry later (a cloud device becomes usable once its provider confirms the old instance destroyed), continue without the device, or ask the user to start a new conversation on another device.";
|
|
268
|
-
export declare const RETIREMENT_RESTART_TOOL_TEXT = "Background work started by an earlier version may still be running on this device's computer, so nothing ran. Ask the user to restart that computer to finish the upgrade, then retry; or continue without the device.";
|
|
269
276
|
export declare const RETIREMENT_RECREATE_TOOL_TEXT = "Background work started by an earlier version may still be running on an earlier instance of this device, which can no longer be verified as destroyed, so nothing ran. Ask the device's owner to delete the device and create it again, or ask the user to start a new conversation on another device.";
|
|
270
|
-
export declare const RETIREMENT_REPLACE_TOOL_TEXT = "Background work started by an earlier version may still be running on this device's computer, which cannot prove a restart, so nothing ran. Ask the device's owner to delete the device and connect the computer again as a new device, or ask the user to start a new conversation on another device.";
|
|
271
277
|
/**
|
|
272
278
|
* A managed operation outside the admitted scope (`SandboxScopeDeniedError`): fixed text, never
|
|
273
279
|
* the refusal's own message (a provider may write it).
|
|
@@ -280,9 +286,9 @@ export declare const ESCALATION_GRANT_MISSING_LAUNCH_WHY = "its approval to run
|
|
|
280
286
|
/** A staged request the machine never got: it reconnected before the request was sent. */
|
|
281
287
|
export declare const DEVICE_REQUEST_NOT_SENT_TOOL_TEXT = "The device's machine reconnected before this operation was sent, so nothing ran. Retry the tool call.";
|
|
282
288
|
/** The device itself refused: it cannot enforce its sandbox (`SandboxPermissionUnsupportedError`). */
|
|
283
|
-
export declare 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
|
|
289
|
+
export declare 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.";
|
|
284
290
|
/** Earlier work on the device blocks a new operation (`SandboxWorkUnsettledError`). */
|
|
285
|
-
export declare 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
|
|
291
|
+
export declare 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.";
|
|
286
292
|
export { PermissionAdmissionUnavailable };
|
|
287
293
|
/**
|
|
288
294
|
* Admission's refusal on a device without permission-scoped operations
|
|
@@ -296,10 +302,10 @@ export declare function admissionUnavailableText(cause: PermissionAvailabilityCa
|
|
|
296
302
|
*/
|
|
297
303
|
export declare 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.";
|
|
298
304
|
/**
|
|
299
|
-
* A device request whose machine came back as a new run of
|
|
305
|
+
* A device request whose machine came back as a new run of its device program before answering
|
|
300
306
|
* (`DeviceProgramRestartedError`, also as the cause of an unknown outcome): its result is lost.
|
|
301
307
|
*/
|
|
302
|
-
export declare const DEVICE_PROGRAM_RESTARTED_TOOL_TEXT = "The
|
|
308
|
+
export declare 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.";
|
|
303
309
|
/** A managed operation whose outcome could not be confirmed (`SandboxOperationOutcomeUnknownError`). */
|
|
304
310
|
export declare const OUTCOME_UNKNOWN_TOOL_TEXT = "The device may or may not have run this operation: its outcome could not be confirmed. Check the device's state (for example with Read, Glob or TaskList) before retrying, and do not repeat an operation that must not run twice.";
|
|
305
311
|
export { DEVICE_OF_ANOTHER_ACCOUNT_TEXT } from "./device-owner.js";
|
|
@@ -365,7 +371,7 @@ export declare function recordManagedDevicePaths(deps: {
|
|
|
365
371
|
* workspace (`workspace`), where the call really runs. Every session built outside `inSandbox` (a
|
|
366
372
|
* person's project skill invocation) takes its working root from here too.
|
|
367
373
|
*/
|
|
368
|
-
export declare function sessionWorkingRoot(working: WorkingFacts | null,
|
|
374
|
+
export declare function sessionWorkingRoot(working: WorkingFacts | null, workspace: string): string;
|
|
369
375
|
/**
|
|
370
376
|
* What bounds a session's file-tool paths ({@link SandboxSession.pathBound}): the admitted scope
|
|
371
377
|
* on the managed operation route, under every tier; on the legacy route, the fixed roots unless
|