@capybara-hq/kernel 0.1.0-rc.54 → 0.1.0-rc.55
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.schemas.d.ts +11 -1
- package/dist/catalog/catalog.module.js +1 -1
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/requests.service.d.ts +5 -5
- package/dist/catalog/requests.service.js +9 -9
- package/dist/channels/cards.d.ts +4 -3
- package/dist/channels/cards.js +25 -16
- package/dist/channels/phrases.d.ts +15 -4
- package/dist/channels/phrases.js +15 -1
- package/dist/config/load.d.ts +26 -7
- package/dist/config/load.js +60 -9
- package/dist/config/permission-migration.d.ts +17 -9
- package/dist/config/permission-migration.js +60 -9
- package/dist/config/schema.d.ts +11 -1
- package/dist/config/schema.js +37 -11
- package/dist/conversations/events.d.ts +247 -5
- package/dist/conversations/events.js +127 -16
- package/dist/conversations/permission-profiles.controller.d.ts +12 -2
- package/dist/conversations/permission-profiles.service.d.ts +12 -2
- package/dist/conversations/permission-profiles.service.js +11 -4
- package/dist/db/kernel-schema.d.ts +8 -2
- package/dist/devices/device-projects.service.d.ts +1 -1
- package/dist/devices/device-projects.service.js +6 -6
- package/dist/devices/devices.controller.d.ts +10 -8
- package/dist/devices/devices.controller.js +14 -18
- package/dist/devices/devices.schemas.d.ts +5 -5
- package/dist/devices/devices.schemas.js +5 -5
- package/dist/devices/devices.service.d.ts +188 -175
- package/dist/devices/devices.service.js +284 -292
- package/dist/devices/dto.d.ts +43 -23
- package/dist/devices/dto.js +45 -49
- package/dist/devices/project-rules.d.ts +0 -10
- package/dist/devices/project-rules.js +0 -5
- package/dist/errors.d.ts +24 -19
- package/dist/errors.js +24 -19
- package/dist/evals/reconstruct.d.ts +12 -3
- package/dist/evals/reconstruct.js +10 -6
- package/dist/evals/recorded-permission-context.d.ts +6 -4
- package/dist/evals/recorded-permission-context.js +15 -9
- package/dist/evals/run-replay.d.ts +6 -1
- package/dist/evals/run-replay.js +7 -2
- package/dist/evals/worker.js +3 -1
- package/dist/identity/settings.d.ts +45 -18
- package/dist/identity/settings.js +151 -51
- package/dist/infra/config/kernel-config.service.d.ts +1 -1
- package/dist/infra/config/kernel-config.service.js +17 -5
- package/dist/local-devices/device-auth.controller.d.ts +1 -1
- package/dist/local-devices/device-auth.controller.js +1 -1
- package/dist/local-devices/device-auth.d.ts +4 -4
- package/dist/local-devices/device-auth.js +1 -1
- package/dist/local-devices/device-policy.service.d.ts +18 -9
- package/dist/local-devices/device-policy.service.js +21 -61
- package/dist/local-devices/device-routes.d.ts +3 -1
- package/dist/local-devices/device-routes.js +15 -4
- package/dist/local-devices/instance-bindings.js +5 -2
- package/dist/local-devices/local-device-gateway.d.ts +2 -2
- package/dist/local-devices/local-device-gateway.js +3 -3
- package/dist/local-devices/local-device-provider.d.ts +4 -4
- package/dist/local-devices/local-device-provider.js +23 -9
- package/dist/local-devices/local-devices.module.d.ts +1 -1
- package/dist/local-devices/local-devices.module.js +1 -1
- package/dist/local-devices/machines.d.ts +40 -16
- package/dist/local-devices/machines.js +89 -61
- package/dist/local-devices/owner-report.d.ts +16 -14
- package/dist/local-devices/owner-report.js +24 -30
- package/dist/local-devices/owner-reports.js +26 -8
- package/dist/local-devices/policy-summary.d.ts +25 -44
- package/dist/local-devices/policy-summary.js +26 -71
- package/dist/local-devices/relay.d.ts +6 -6
- package/dist/local-devices/relay.js +10 -8
- package/dist/net/public-address.d.ts +1 -1
- package/dist/net/public-address.js +5 -2
- package/dist/orgs/device-network-setting.d.ts +82 -0
- package/dist/orgs/device-network-setting.js +142 -0
- package/dist/orgs/settings.service.d.ts +103 -66
- package/dist/orgs/settings.service.js +201 -137
- package/dist/overrides.d.ts +5 -1
- package/dist/overrides.js +2 -0
- package/dist/platform/exclusions.js +1 -1
- package/dist/platform/operation.js +1 -1
- package/dist/platform/ops/admin.ops.js +20 -11
- package/dist/platform/ops/devices.ops.js +70 -5
- package/dist/platform/ops/org-settings.ops.js +10 -6
- package/dist/platform/ops/orgs.ops.js +2 -1
- package/dist/runtime/context/permission-profile.d.ts +17 -8
- package/dist/runtime/context/permission-profile.js +126 -45
- package/dist/runtime/permission-context.service.d.ts +1 -1
- package/dist/runtime/permission-context.service.js +5 -3
- package/dist/runtime/project/knowledge.d.ts +5 -4
- package/dist/runtime/project/knowledge.js +2 -1
- package/dist/runtime/project/knowledge.service.js +16 -13
- package/dist/sandbox/cloud-permission-snapshot.js +22 -3
- package/dist/sandbox/device-sandbox-settings.d.ts +230 -0
- package/dist/sandbox/device-sandbox-settings.js +470 -0
- package/dist/sandbox/device-sandbox.d.ts +187 -0
- package/dist/sandbox/device-sandbox.js +236 -0
- package/dist/sandbox/held-operations.js +15 -7
- package/dist/sandbox/modes.d.ts +49 -24
- package/dist/sandbox/modes.js +27 -19
- package/dist/sandbox/operation-authority-types.d.ts +6 -5
- package/dist/sandbox/operation-authority-types.js +7 -8
- package/dist/sandbox/operation-authority.d.ts +23 -9
- package/dist/sandbox/operation-authority.js +179 -97
- package/dist/sandbox/permission-auto-grants.d.ts +42 -0
- package/dist/sandbox/permission-auto-grants.js +145 -0
- package/dist/sandbox/permission-call-grants.d.ts +12 -4
- package/dist/sandbox/permission-call-grants.js +84 -35
- package/dist/sandbox/permission-call-grants.module.js +10 -3
- package/dist/sandbox/permission-call-types.d.ts +39 -5
- package/dist/sandbox/permission-ceiling-writes.d.ts +29 -3
- package/dist/sandbox/permission-ceiling-writes.js +38 -4
- package/dist/sandbox/permission-config-publication.d.ts +44 -2
- package/dist/sandbox/permission-config-publication.js +230 -59
- package/dist/sandbox/permission-context-types.d.ts +2 -2
- package/dist/sandbox/permission-facts.d.ts +144 -15
- package/dist/sandbox/permission-facts.js +258 -70
- package/dist/sandbox/permission-runtime-reports.d.ts +5 -4
- package/dist/sandbox/permission-runtime-reports.js +19 -29
- package/dist/sandbox/review/classifier.d.ts +8 -0
- package/dist/sandbox/review/classifier.js +10 -0
- package/dist/sandbox/review/permission-candidate.d.ts +69 -5
- package/dist/sandbox/review/permission-candidate.js +153 -30
- package/dist/sandbox/review/review.service.d.ts +19 -3
- package/dist/sandbox/review/review.service.js +59 -11
- package/dist/sandbox/review/rules.js +23 -3
- package/dist/sandbox/sandbox.service.d.ts +29 -11
- package/dist/sandbox/sandbox.service.js +51 -26
- package/dist/skills/invoke.js +3 -2
- package/dist/tools/approvals.service.d.ts +26 -116
- package/dist/tools/approvals.service.js +42 -346
- package/dist/tools/builtins/sandbox/bash.d.ts +16 -3
- package/dist/tools/builtins/sandbox/bash.js +80 -28
- package/dist/tools/builtins/sandbox/common.d.ts +39 -14
- package/dist/tools/builtins/sandbox/common.js +47 -24
- package/dist/tools/builtins/sandbox/deliver.js +7 -4
- package/dist/tools/builtins/skill-load.d.ts +2 -2
- package/dist/tools/builtins/skill-load.js +4 -3
- package/dist/tools/device-op-resolver.d.ts +4 -10
- package/dist/tools/device-op-resolver.js +8 -19
- package/dist/tools/network-asks.d.ts +52 -15
- package/dist/tools/network-asks.js +55 -25
- package/dist/tools/pipeline.d.ts +26 -14
- package/dist/tools/pipeline.js +144 -61
- package/dist/tools/registry.d.ts +6 -0
- package/dist/tools/tools.module.js +1 -1
- package/package.json +4 -4
- package/src/migrations/0165_device_network_columns.sql +50 -0
- package/src/migrations/0166_permission_grant_full_access.sql +17 -0
- package/src/migrations/0167_device_network_backfill.sql +32 -0
- package/src/migrations/0168_binding_installed_connection.sql +6 -0
- package/dist/orgs/cloud-network-setting.d.ts +0 -33
- package/dist/orgs/cloud-network-setting.js +0 -47
- package/dist/sandbox/platform-full-access.d.ts +0 -110
- package/dist/sandbox/platform-full-access.js +0 -198
package/dist/tools/pipeline.js
CHANGED
|
@@ -40,11 +40,12 @@ import { SubagentsService } from "../runtime/subagents/subagents.service.js";
|
|
|
40
40
|
import { orgHostOutsideCeiling } from "../sandbox/modes.js";
|
|
41
41
|
import { SandboxOperationAuthority } from "../sandbox/operation-authority.js";
|
|
42
42
|
import { PermissionAuthorityLock } from "../sandbox/permission-authority-lock.js";
|
|
43
|
+
import { PermissionAutoGrants } from "../sandbox/permission-auto-grants.js";
|
|
43
44
|
import { PermissionCallGrants } from "../sandbox/permission-call-grants.js";
|
|
44
45
|
import { PERMISSION_CONTEXT_ACTIVATION, permissionContextActive, } from "../sandbox/permission-context-types.js";
|
|
45
46
|
import { permissionScopeHash } from "../sandbox/permission-facts.js";
|
|
46
47
|
import { isSessionGrantableRule, } from "../sandbox/review/index.js";
|
|
47
|
-
import { buildPermissionCandidate, ESCALATION_RETRY_HINT, ESCALATION_UNATTENDED_WHY, escalationRefusedText, isEscalatedCall, } from "../sandbox/review/permission-candidate.js";
|
|
48
|
+
import { approverForCrossing, buildPermissionCandidate, crossingOfCandidate, ESCALATION_RETRY_HINT, ESCALATION_UNATTENDED_WHY, escalationRefusedText, isEscalatedCall, } from "../sandbox/review/permission-candidate.js";
|
|
48
49
|
import { CommandReviewService } from "../sandbox/review/review.service.js";
|
|
49
50
|
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
50
51
|
import { appendMissingGrant, connectionGrantKey, UNATTENDED_CONNECTION_ERROR, UNATTENDED_ELICITATION_NOTE, UNATTENDED_QUESTION_ERROR, unattendedFails, unattendedRunOf, } from "../schedules/unattended.js";
|
|
@@ -63,7 +64,7 @@ import { canonicalJson } from "./canonical-json.js";
|
|
|
63
64
|
import { CredentialMissing, Credentials } from "./credentials.js";
|
|
64
65
|
import { ToolDrift } from "./drift.js";
|
|
65
66
|
import { ElicitationSession } from "./elicitation.js";
|
|
66
|
-
import { blockedEventHosts, clipKept, NETWORK_ASK_KEPT_MAX_BYTES, networkBlockedIdemKey, planNetworkAsk, settledNetworkNotes, withNetworkNotes, } from "./network-asks.js";
|
|
67
|
+
import { addressEscalationHint, blockedEventHosts, clipKept, NETWORK_ASK_KEPT_MAX_BYTES, networkBlockedIdemKey, planNetworkAsk, settledNetworkNotes, withNetworkNotes, } from "./network-asks.js";
|
|
67
68
|
import { OrgToolSwitches, toolTurnedOffReason } from "./org-tool-switches.js";
|
|
68
69
|
import { renderResult, resolveOutputRefs, spillIfLarge, ToolOutputs } from "./outputs.js";
|
|
69
70
|
import { createDecidePolicy } from "./policy.js";
|
|
@@ -86,18 +87,20 @@ export const approvalExpiredText = (hours) => `Approval timed out after ${hours}
|
|
|
86
87
|
export const APPROVAL_CANCELLED_TEXT = "The run was stopped while waiting for approval.";
|
|
87
88
|
/**
|
|
88
89
|
* The command review's deny text (auto mode spec §5.4, P-D12): the model-visible reason and what it
|
|
89
|
-
* can do instead. `kind` says whether a shell command or a file
|
|
90
|
+
* can do instead. `kind` says whether a shell command, a file write or a file read was held.
|
|
90
91
|
*/
|
|
91
92
|
export const commandDeniedText = (reason, kind) => kind === "write"
|
|
92
93
|
? `This write is blocked by review: ${reason}. Write it another way or ask the user to allow it.`
|
|
93
|
-
:
|
|
94
|
+
: kind === "read"
|
|
95
|
+
? `This read is blocked by review: ${reason}. Read another file or ask the user to allow it.`
|
|
96
|
+
: `Command blocked by review: ${reason}. Do the work another way or ask the user to run it.`;
|
|
94
97
|
/**
|
|
95
|
-
* A command (or write) the review held in an unattended run: no one can answer, so it is a
|
|
96
|
-
* once — no approval, no grant (P-D3).
|
|
98
|
+
* A command (or write, or read) the review held in an unattended run: no one can answer, so it is a
|
|
99
|
+
* deny at once — no approval, no grant (P-D3).
|
|
97
100
|
*/
|
|
98
|
-
export const commandUnattendedText = (reason, kind) => kind === "
|
|
99
|
-
? `This
|
|
100
|
-
: `This
|
|
101
|
+
export const commandUnattendedText = (reason, kind) => kind === "command"
|
|
102
|
+
? `This command needs approval (${reason}), and no one can approve it now; do the work another way or leave it for the person.`
|
|
103
|
+
: `This ${kind} needs approval (${reason}), and no one can approve it now; do it another way or leave it for the person.`;
|
|
101
104
|
/**
|
|
102
105
|
* A command longer than the ask ceiling (`COMMAND_ASK_MAX_CHARS`): it cannot be shown for approval,
|
|
103
106
|
* and an approval must bind the whole text, so the call is refused before any approval exists.
|
|
@@ -105,9 +108,9 @@ export const commandUnattendedText = (reason, kind) => kind === "write"
|
|
|
105
108
|
export const commandTooLongReason = (chars) => `The command is ${chars} characters long; commands over ${COMMAND_ASK_MAX_CHARS} are too long to review and approve.`;
|
|
106
109
|
/** The model-visible result of a command over the ask ceiling (actionable, English). */
|
|
107
110
|
export const commandTooLongText = (chars) => `This command is too long to review (${chars} characters; the limit is ${COMMAND_ASK_MAX_CHARS}). Split it into shorter commands; long inline scripts are reviewed as code the review cannot read.`;
|
|
108
|
-
/** The person declined a held command or
|
|
111
|
+
/** The person declined a held command, write or read (P-D12); `reason` is what they said, if any. */
|
|
109
112
|
export const commandDeclinedText = (reason, kind) => {
|
|
110
|
-
const what = kind === "write" ? "this write" : "to run this command";
|
|
113
|
+
const what = kind === "write" ? "this write" : kind === "read" ? "this read" : "to run this command";
|
|
111
114
|
return reason === null
|
|
112
115
|
? `The user declined ${what}. Continue without it or ask the user.`
|
|
113
116
|
: `The user declined ${what}: ${reason}. Continue without it or ask the user.`;
|
|
@@ -245,8 +248,15 @@ const entersDevice = (toolKey, input) => {
|
|
|
245
248
|
}
|
|
246
249
|
return toolKey !== BUILTIN.GenerateImage || generateImagePaths(input).length > 0;
|
|
247
250
|
};
|
|
248
|
-
/**
|
|
249
|
-
|
|
251
|
+
/**
|
|
252
|
+
* What the review holds, for the texts and the ask's detail: a shell command, a file read (a read
|
|
253
|
+
* tool's crossing asks to read, never to write) or a file write.
|
|
254
|
+
*/
|
|
255
|
+
const reviewKindOf = (toolKey) => toolKey === BUILTIN.Bash
|
|
256
|
+
? "command"
|
|
257
|
+
: toolKey === BUILTIN.Read || toolKey === BUILTIN.Glob || toolKey === BUILTIN.Grep
|
|
258
|
+
? "read"
|
|
259
|
+
: "write";
|
|
250
260
|
/**
|
|
251
261
|
* The working root a reviewed call carries to its tool: a project root only. In free mode the
|
|
252
262
|
* reviewed root is the recorded workspace, which may be stale; the tool then maps it to the held
|
|
@@ -404,6 +414,7 @@ let ToolPipeline = class ToolPipeline {
|
|
|
404
414
|
txHost;
|
|
405
415
|
permissionAuthority;
|
|
406
416
|
permissionGrants;
|
|
417
|
+
autoGrants;
|
|
407
418
|
permissionLocks;
|
|
408
419
|
sandboxes;
|
|
409
420
|
decide;
|
|
@@ -418,7 +429,9 @@ let ToolPipeline = class ToolPipeline {
|
|
|
418
429
|
/** The command review (auto mode spec §5.4); absent in hand-built pipelines. */
|
|
419
430
|
review,
|
|
420
431
|
/** The reviewed call's device facts; absent in hand-built pipelines. */
|
|
421
|
-
devices, permissionAuthority, permissionGrants,
|
|
432
|
+
devices, permissionAuthority, permissionGrants,
|
|
433
|
+
/** Full access auto-grants, recorded exactly once (absent in hand-built pipelines). */
|
|
434
|
+
autoGrants, permissionLocks,
|
|
422
435
|
/** The paired activation gate: on, the managed builtins take the permission review. */
|
|
423
436
|
activation,
|
|
424
437
|
/** Starts a cloud device before its first managed call is reviewed (absent: never). */
|
|
@@ -427,6 +440,7 @@ let ToolPipeline = class ToolPipeline {
|
|
|
427
440
|
this.txHost = txHost;
|
|
428
441
|
this.permissionAuthority = permissionAuthority;
|
|
429
442
|
this.permissionGrants = permissionGrants;
|
|
443
|
+
this.autoGrants = autoGrants;
|
|
430
444
|
this.permissionLocks = permissionLocks;
|
|
431
445
|
this.sandboxes = sandboxes;
|
|
432
446
|
this.deps = {
|
|
@@ -466,7 +480,11 @@ let ToolPipeline = class ToolPipeline {
|
|
|
466
480
|
review,
|
|
467
481
|
devices,
|
|
468
482
|
network: networkGrants && devicePolicy
|
|
469
|
-
? {
|
|
483
|
+
? {
|
|
484
|
+
grants: networkGrants,
|
|
485
|
+
devices: devicePolicy,
|
|
486
|
+
...(this.sandboxes !== undefined && { sandbox: this.sandboxes }),
|
|
487
|
+
}
|
|
470
488
|
: undefined,
|
|
471
489
|
};
|
|
472
490
|
const decide = hooks?.decidePolicy;
|
|
@@ -777,6 +795,9 @@ let ToolPipeline = class ToolPipeline {
|
|
|
777
795
|
workingRoot: reviewed.workingRoot,
|
|
778
796
|
against: reviewed.reviewedAgainst,
|
|
779
797
|
...(reviewed.sandboxEscalation !== undefined && { escalation: reviewed.sandboxEscalation }),
|
|
798
|
+
...(reviewed.sandboxEscalationRefusal !== undefined && {
|
|
799
|
+
escalationRefusal: reviewed.sandboxEscalationRefusal,
|
|
800
|
+
}),
|
|
780
801
|
};
|
|
781
802
|
if (reviewed.commandAsk !== undefined)
|
|
782
803
|
authorization = approvalAuthorization(reviewed.commandAsk);
|
|
@@ -1043,7 +1064,7 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1043
1064
|
// carried into the kept result so a resumed run writes the event too (it was written
|
|
1044
1065
|
// with `network_blocked` below when the ask was created)
|
|
1045
1066
|
...(loginCode !== undefined && { loginCode }),
|
|
1046
|
-
});
|
|
1067
|
+
}, reviewedRoots.escalation, reviewedRoots.escalationRefusal);
|
|
1047
1068
|
if (handled.kind === "wait") {
|
|
1048
1069
|
if (hooks && hookBase) {
|
|
1049
1070
|
fireObserve(hooks, "tool.postExecute", { ...hookBase, isError: rendered.isError, content: handled.content, durationMs }, ctx.signal, this.deps.log);
|
|
@@ -1277,9 +1298,13 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1277
1298
|
async reviewPermissionCall(ctx, call, tool, input) {
|
|
1278
1299
|
const note = {};
|
|
1279
1300
|
const outcome = await this.reviewPermissionCallWith(ctx, call, tool, input, note);
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1301
|
+
if (outcome?.kind !== "continue")
|
|
1302
|
+
return outcome;
|
|
1303
|
+
return {
|
|
1304
|
+
...outcome,
|
|
1305
|
+
...(note.escalation !== undefined && { sandboxEscalation: note.escalation }),
|
|
1306
|
+
...(note.refusal !== undefined && { sandboxEscalationRefusal: note.refusal }),
|
|
1307
|
+
};
|
|
1283
1308
|
}
|
|
1284
1309
|
async reviewPermissionCallWith(ctx, call, tool, input, note) {
|
|
1285
1310
|
if (!this.permissionAuthority ||
|
|
@@ -1339,10 +1364,8 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1339
1364
|
return null;
|
|
1340
1365
|
}
|
|
1341
1366
|
if (facts.availability.state !== "supported") {
|
|
1342
|
-
// still unverified: the conservative command review decides (
|
|
1367
|
+
// still unverified: the conservative command review decides (every profile), but a call
|
|
1343
1368
|
// that needs more reach is refused now: admission could never run what an approval allowed
|
|
1344
|
-
if (facts.profile === "full-access")
|
|
1345
|
-
return null;
|
|
1346
1369
|
const unverified = buildPermissionCandidate({ toolKey: tool.key, specHash: tool.specHash, rawInput: call.input, validatedInput: input }, facts, [device.home, device.deviceHome], { backgroundMaxSeconds: backgroundMaxSeconds(this.config.get()) });
|
|
1347
1370
|
if (unverified.kind === "in-scope")
|
|
1348
1371
|
return null;
|
|
@@ -1356,26 +1379,37 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1356
1379
|
review: denyRecord("rule", null, "The command exceeds the review limit"),
|
|
1357
1380
|
};
|
|
1358
1381
|
const escalated = isEscalatedCall(tool.key, input);
|
|
1359
|
-
// the escalation state the tool's hints read:
|
|
1360
|
-
// org whose ceiling allows running outside the sandbox
|
|
1361
|
-
if (tool.key === "Bash" &&
|
|
1382
|
+
// the escalation state the tool's hints read: a Bash call (every profile runs it in the
|
|
1383
|
+
// sandbox) on a device and org whose ceiling allows running outside the sandbox
|
|
1384
|
+
if (tool.key === "Bash" && !facts.escalationRefusal)
|
|
1362
1385
|
note.escalation = escalated ? "escalated" : "available";
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1386
|
+
// where it cannot (a layer's outside-sandbox setting is off, the runtime cannot), the hints
|
|
1387
|
+
// say why and who changes it, in the escalation refusal's per-layer words
|
|
1388
|
+
else if (tool.key === "Bash" && facts.escalationRefusal && !escalated)
|
|
1389
|
+
note.refusal = facts.escalationRefusal;
|
|
1390
|
+
// candidate building runs for every profile: the profile only chooses who approves
|
|
1391
|
+
const built = buildPermissionCandidate({
|
|
1392
|
+
toolKey: tool.key,
|
|
1393
|
+
specHash: tool.specHash,
|
|
1394
|
+
rawInput: call.input,
|
|
1395
|
+
validatedInput: input,
|
|
1396
|
+
}, facts, [device.home, device.deviceHome], { backgroundMaxSeconds: backgroundMaxSeconds(this.config.get()) });
|
|
1371
1397
|
if (built.kind === "unsupported") {
|
|
1372
|
-
// a Bash reach the restricted scope cannot grant: retrying outside the sandbox may
|
|
1373
|
-
|
|
1398
|
+
// a Bash reach the restricted scope cannot grant: retrying outside the sandbox may (a
|
|
1399
|
+
// protected location's text names the escalation itself)
|
|
1400
|
+
const content = note.escalation === "available" && built.code === "unbounded-scope"
|
|
1374
1401
|
? `${built.message}${ESCALATION_RETRY_HINT}`
|
|
1375
1402
|
: built.message;
|
|
1376
1403
|
return { kind: "result", content, review: denyRecord("rule", null, content) };
|
|
1377
1404
|
}
|
|
1378
1405
|
const candidate = built.kind === "proposal" ? built.candidate : undefined;
|
|
1406
|
+
// who approves this call's crossing: the person, the review model, or nobody (Full access
|
|
1407
|
+
// grants it within the device's ceilings); a sub-agent's escalation never goes to nobody
|
|
1408
|
+
const approver = approverForCrossing({
|
|
1409
|
+
profile: facts.profile,
|
|
1410
|
+
crossing: candidate ? crossingOfCandidate(candidate) : "sensitive",
|
|
1411
|
+
subAgent: ctx.parent !== undefined,
|
|
1412
|
+
});
|
|
1379
1413
|
// a sensitive-command consent the person settled (no proposed reach): the call runs under
|
|
1380
1414
|
// the base scope it was asked under; the approval adds nothing
|
|
1381
1415
|
if (previous &&
|
|
@@ -1426,16 +1460,22 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1426
1460
|
kind: "continue",
|
|
1427
1461
|
workingRoot: carriedRoot(device),
|
|
1428
1462
|
reviewedAgainst: facts.workingRoot,
|
|
1429
|
-
// the evidence's real source: the person's approval
|
|
1463
|
+
// the evidence's real source: the person's approval, the review model's allow or the
|
|
1464
|
+
// Full access auto-grant
|
|
1430
1465
|
review: {
|
|
1431
1466
|
decision: "allow",
|
|
1432
|
-
by: existingGrant.source === "human"
|
|
1467
|
+
by: existingGrant.source === "human"
|
|
1468
|
+
? "person"
|
|
1469
|
+
: existingGrant.source === "review-model"
|
|
1470
|
+
? "classifier"
|
|
1471
|
+
: "rule",
|
|
1433
1472
|
rule: null,
|
|
1434
1473
|
reason: "The exact current call already has approved permission evidence.",
|
|
1435
1474
|
profile: facts.profile,
|
|
1436
1475
|
profileRevision: facts.profileRevision,
|
|
1437
1476
|
scopeRevision: facts.scopeRevision,
|
|
1438
|
-
decisionSource: existingGrant.source
|
|
1477
|
+
decisionSource: existingGrant.source,
|
|
1478
|
+
crossing: crossingOfCandidate(candidate),
|
|
1439
1479
|
...(candidate.escalation ? { sandbox: "escalated" } : {}),
|
|
1440
1480
|
},
|
|
1441
1481
|
};
|
|
@@ -1464,13 +1504,23 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1464
1504
|
...(candidate ? { permissionCandidate: candidate } : {}),
|
|
1465
1505
|
...(note.escalation === "available" ? { escalationAvailable: true } : {}),
|
|
1466
1506
|
});
|
|
1467
|
-
|
|
1507
|
+
// who decided: the review knows the call's consents (a credential consent sends a Full access
|
|
1508
|
+
// escalation to the review model); without its answer, the profile's approver
|
|
1509
|
+
const decidedBy = verdict.approver ?? approver;
|
|
1510
|
+
if (candidate && decidedBy === "review-model") {
|
|
1468
1511
|
await withTransactionFencePrelude(() => permissionLocks.acquire({
|
|
1469
1512
|
orgId: facts.orgId,
|
|
1470
1513
|
deviceId: facts.deviceId,
|
|
1471
1514
|
rootConversationId: facts.rootConversationId,
|
|
1472
1515
|
}, { kind: "admit" }), () => this.recordPermissionReview(candidate, verdict));
|
|
1473
1516
|
}
|
|
1517
|
+
// Full access: the crossing is granted for this call, recorded exactly once (its event, the
|
|
1518
|
+
// audit row and the grant in one fenced transaction); a fixed deny never reaches this
|
|
1519
|
+
if (candidate && decidedBy === "none" && verdict.decision === "allow") {
|
|
1520
|
+
if (!this.autoGrants)
|
|
1521
|
+
throw new Error("Permission auto-grants are unavailable");
|
|
1522
|
+
await this.autoGrants.record(candidate, verdict.sensitive ?? []);
|
|
1523
|
+
}
|
|
1474
1524
|
const provenance = {
|
|
1475
1525
|
profile: facts.profile,
|
|
1476
1526
|
profileRevision: facts.profileRevision,
|
|
@@ -1490,13 +1540,19 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1490
1540
|
review: {
|
|
1491
1541
|
...allowRecord(verdict),
|
|
1492
1542
|
...provenance,
|
|
1493
|
-
decisionSource:
|
|
1494
|
-
? "
|
|
1495
|
-
:
|
|
1496
|
-
? "
|
|
1543
|
+
decisionSource: verdict.by === "classifier"
|
|
1544
|
+
? "review-model"
|
|
1545
|
+
: facts.profile === "full-access"
|
|
1546
|
+
? "full-access"
|
|
1497
1547
|
: "scope",
|
|
1498
|
-
|
|
1499
|
-
|
|
1548
|
+
...(candidate
|
|
1549
|
+
? { crossing: crossingOfCandidate(candidate) }
|
|
1550
|
+
: verdict.crossing
|
|
1551
|
+
? { crossing: verdict.crossing }
|
|
1552
|
+
: {}),
|
|
1553
|
+
// the review model's allow or Full access issued this call's escalation grant: it runs
|
|
1554
|
+
// outside the sandbox
|
|
1555
|
+
...(candidate?.escalation && (verdict.by === "classifier" || decidedBy === "none")
|
|
1500
1556
|
? { sandbox: "escalated" }
|
|
1501
1557
|
: {}),
|
|
1502
1558
|
},
|
|
@@ -1544,21 +1600,24 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1544
1600
|
return { kind: "wait", wait: approvalWait(ask) };
|
|
1545
1601
|
}
|
|
1546
1602
|
/**
|
|
1547
|
-
* Whether an execution of this call was admitted outside the sandbox
|
|
1548
|
-
*
|
|
1603
|
+
* Whether an execution of this call was admitted outside the sandbox (a per-call escalation's
|
|
1604
|
+
* full reach, under any profile): an intent past admission, or one revoked after dispatch, whose
|
|
1605
|
+
* device-wide scope came from the call's escalation grant.
|
|
1549
1606
|
*/
|
|
1550
1607
|
async admittedOutsideSandbox(runId, callId) {
|
|
1551
1608
|
const rows = await this.deps.db
|
|
1552
|
-
.selectFrom("sandbox_operation_intents")
|
|
1553
|
-
.
|
|
1554
|
-
.
|
|
1555
|
-
.where("
|
|
1556
|
-
.where("
|
|
1609
|
+
.selectFrom("sandbox_operation_intents as i")
|
|
1610
|
+
.innerJoin("permission_call_grants as g", "g.id", "i.permission_grant_id")
|
|
1611
|
+
.select(["i.scope", "i.state", "i.outcome_unknown"])
|
|
1612
|
+
.where("i.run_id", "=", runId)
|
|
1613
|
+
.where("i.call_id", "=", callId)
|
|
1614
|
+
.where("i.method", "in", ["exec", "backgroundStart"])
|
|
1615
|
+
.where("g.scope_kind", "=", "sandbox-escalation")
|
|
1557
1616
|
.execute();
|
|
1558
1617
|
return rows.some((r) => {
|
|
1559
1618
|
const scope = r.scope;
|
|
1560
1619
|
const admitted = r.state === "revoked" ? r.outcome_unknown : r.state !== "pending";
|
|
1561
|
-
return admitted && scope.
|
|
1620
|
+
return admitted && scope.filesystem?.kind === "device";
|
|
1562
1621
|
});
|
|
1563
1622
|
}
|
|
1564
1623
|
findPermissionGrant(candidate) {
|
|
@@ -1657,7 +1716,11 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1657
1716
|
* followed by the notes written now; it is written with the decision's note when the ask
|
|
1658
1717
|
* settles (P-D2).
|
|
1659
1718
|
*/
|
|
1660
|
-
async networkBlocked(ctx, callId, toolKey, input, report, pre, callAudit, result
|
|
1719
|
+
async networkBlocked(ctx, callId, toolKey, input, report, pre, callAudit, result,
|
|
1720
|
+
/** Admission's verdict for this call: `available` when it may run outside the sandbox. */
|
|
1721
|
+
escalation,
|
|
1722
|
+
/** Why this call could not run outside the sandbox here (absent when it could). */
|
|
1723
|
+
escalationRefusal) {
|
|
1661
1724
|
const hosts = blockedEventHosts(report.blocked);
|
|
1662
1725
|
if (hosts.length === 0)
|
|
1663
1726
|
return { kind: "write", event: null, notes: [] };
|
|
@@ -1675,10 +1738,23 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1675
1738
|
? await network.grants.runState(ctx.runId, report.deviceId)
|
|
1676
1739
|
: null;
|
|
1677
1740
|
const limits = this.config.get().sandbox.limits;
|
|
1741
|
+
// the per-call host ceiling decides what is worth asking: a host beyond a local owner's
|
|
1742
|
+
// allowlist or the org's or platform's allowlist ceiling is unavailable, never asked about
|
|
1743
|
+
const sandbox = await network.sandbox?.hostRefusal({
|
|
1744
|
+
orgId: ctx.orgId,
|
|
1745
|
+
deviceId: report.deviceId,
|
|
1746
|
+
});
|
|
1678
1747
|
const plan = planNetworkAsk(hosts, run, {
|
|
1679
1748
|
device,
|
|
1680
1749
|
unattended: ctx.unattended,
|
|
1681
1750
|
outsideCeiling: (h) => orgHostOutsideCeiling(limits, h),
|
|
1751
|
+
...(sandbox !== undefined && {
|
|
1752
|
+
refusal: sandbox.refusal,
|
|
1753
|
+
// the hint follows admission's verdict for this call (never a recomputation), and only
|
|
1754
|
+
// the open network makes a private address the one thing escalation adds
|
|
1755
|
+
escalation: addressEscalationHint(escalation, sandbox.box.networkMode),
|
|
1756
|
+
}),
|
|
1757
|
+
...(escalationRefusal !== undefined && { escalationRefusal }),
|
|
1682
1758
|
});
|
|
1683
1759
|
if (ctx.unattended != null) {
|
|
1684
1760
|
for (const key of plan.missingGrants) {
|
|
@@ -1734,7 +1810,7 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1734
1810
|
description: typeof given.description === "string" ? given.description : null,
|
|
1735
1811
|
result: kept,
|
|
1736
1812
|
},
|
|
1737
|
-
scopes:
|
|
1813
|
+
scopes: ["once"],
|
|
1738
1814
|
});
|
|
1739
1815
|
return { kind: "wait", wait: approvalWait(ask), content: kept.content };
|
|
1740
1816
|
}
|
|
@@ -1775,7 +1851,7 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1775
1851
|
}
|
|
1776
1852
|
return null;
|
|
1777
1853
|
}
|
|
1778
|
-
/**
|
|
1854
|
+
/** A decided approval other than approved → the model's text; still pending → null (wait). */
|
|
1779
1855
|
refusalText(a) {
|
|
1780
1856
|
switch (a.status) {
|
|
1781
1857
|
case "denied":
|
|
@@ -1790,8 +1866,9 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1790
1866
|
}
|
|
1791
1867
|
}
|
|
1792
1868
|
/**
|
|
1793
|
-
*
|
|
1794
|
-
*
|
|
1869
|
+
* A handler returned `input_required`: past the round limit, an invalid form
|
|
1870
|
+
* (`validateInputForm`) or an oversized state is an error text for the model; otherwise an
|
|
1871
|
+
* input request is made (writing `question_asked`) and its wait returned.
|
|
1795
1872
|
*/
|
|
1796
1873
|
async askInput(ctx, callId, toolKey, attempt, req) {
|
|
1797
1874
|
if (attempt > MAX_INPUT_ROUNDS)
|
|
@@ -1865,6 +1942,10 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1865
1942
|
reviewedAgainstRoot !== undefined && { reviewedAgainstRoot }),
|
|
1866
1943
|
...(tool.source.kind === "builtin" &&
|
|
1867
1944
|
reviewed?.escalation !== undefined && { sandboxEscalation: reviewed.escalation }),
|
|
1945
|
+
...(tool.source.kind === "builtin" &&
|
|
1946
|
+
reviewed?.escalationRefusal !== undefined && {
|
|
1947
|
+
sandboxEscalationRefusal: reviewed.escalationRefusal,
|
|
1948
|
+
}),
|
|
1868
1949
|
// a sub-agent works in its root conversation's sandbox (spec §10.1, at every depth)
|
|
1869
1950
|
...(tool.source.kind === "builtin" &&
|
|
1870
1951
|
ctx.parent !== undefined && { sandboxConversationId: ctx.parent.rootConversationId }),
|
|
@@ -2323,10 +2404,12 @@ ToolPipeline = __decorate([
|
|
|
2323
2404
|
__param(23, Optional()),
|
|
2324
2405
|
__param(23, Inject(PermissionCallGrants)),
|
|
2325
2406
|
__param(24, Optional()),
|
|
2326
|
-
__param(24, Inject(
|
|
2407
|
+
__param(24, Inject(PermissionAutoGrants)),
|
|
2327
2408
|
__param(25, Optional()),
|
|
2328
|
-
__param(25, Inject(
|
|
2409
|
+
__param(25, Inject(PermissionAuthorityLock)),
|
|
2329
2410
|
__param(26, Optional()),
|
|
2330
|
-
__param(26, Inject(
|
|
2411
|
+
__param(26, Inject(PERMISSION_CONTEXT_ACTIVATION)),
|
|
2412
|
+
__param(27, Optional()),
|
|
2413
|
+
__param(27, Inject(SandboxService))
|
|
2331
2414
|
], ToolPipeline);
|
|
2332
2415
|
export { ToolPipeline };
|
package/dist/tools/registry.d.ts
CHANGED
|
@@ -72,6 +72,12 @@ export interface BuiltinCallContext extends ToolCallContext {
|
|
|
72
72
|
* an unattended run, a device or org that forbids it): no escalation hint is given.
|
|
73
73
|
*/
|
|
74
74
|
sandboxEscalation?: "available" | "escalated";
|
|
75
|
+
/**
|
|
76
|
+
* A reviewed, restricted `Bash` call on a device or org where running outside the sandbox is
|
|
77
|
+
* not possible: why, in the per-layer words of an escalation refusal (who turns it on). The
|
|
78
|
+
* tool's sandbox hint explains a denial with it instead of inviting an escalation.
|
|
79
|
+
*/
|
|
80
|
+
sandboxEscalationRefusal?: string;
|
|
75
81
|
/** The parent run of a sub-agent's run (absent for a top-level run). */
|
|
76
82
|
parentRunId?: string;
|
|
77
83
|
/**
|
|
@@ -78,7 +78,7 @@ ToolsModule = __decorate([
|
|
|
78
78
|
// the managed sandbox route's device context writer (passed only once activated)
|
|
79
79
|
ManagedDeviceContextModule,
|
|
80
80
|
DevicesModule,
|
|
81
|
-
//
|
|
81
|
+
// network asks and the sandbox tools read a local device's machine (owner report, policy)
|
|
82
82
|
LocalDevicesModule,
|
|
83
83
|
// `Bash` with run_in_background records its task; TaskOutput / TaskStop finish and stop it
|
|
84
84
|
BackgroundModule,
|
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.55",
|
|
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.39"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@langchain/langgraph-checkpoint-validation": "^1.2.0",
|
|
@@ -75,8 +75,8 @@
|
|
|
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.
|
|
78
|
+
"@capybara-hq/testing": "0.1.0-rc.29",
|
|
79
|
+
"@capybara-hq/device": "0.1.0-rc.19"
|
|
80
80
|
},
|
|
81
81
|
"scripts": {
|
|
82
82
|
"build": "tsc -b"
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
-- A cloud device's own sandbox network (approval-only profiles design, "Settings model" and
|
|
2
|
+
-- "Migration"; expand only). `network_mode` is the device's choice, `open` or `allowlist`; NULL
|
|
3
|
+
-- follows the org; `none` is a closed network. `network_hosts` is the device's allowlist (a JSON
|
|
4
|
+
-- array of host patterns),
|
|
5
|
+
-- used while the mode is `allowlist`. The device owner or an org admin changes both, within the
|
|
6
|
+
-- org and platform ceilings. A cloud device has no outside of its sandbox, so `owner_full_access`
|
|
7
|
+
-- no longer decides what a cloud device may do. It is still read by the one-time conversions (the
|
|
8
|
+
-- B1 snapshot and its reconciliation, the permission publication's version conversion) and for
|
|
9
|
+
-- the kernel-only mode recorded with an instance's limits, which never decides a provider update;
|
|
10
|
+
-- a later migration drops it (expand, then contract).
|
|
11
|
+
ALTER TABLE devices ADD COLUMN IF NOT EXISTS network_mode text;
|
|
12
|
+
ALTER TABLE devices ADD COLUMN IF NOT EXISTS network_hosts jsonb NOT NULL DEFAULT '[]'::jsonb;
|
|
13
|
+
-- each check is added NOT VALID (no scan under the add's lock), then validated
|
|
14
|
+
ALTER TABLE devices DROP CONSTRAINT IF EXISTS devices_network_mode_check;
|
|
15
|
+
ALTER TABLE devices ADD CONSTRAINT devices_network_mode_check
|
|
16
|
+
CHECK (network_mode IS NULL OR network_mode IN ('open', 'allowlist', 'none')) NOT VALID;
|
|
17
|
+
ALTER TABLE devices VALIDATE CONSTRAINT devices_network_mode_check;
|
|
18
|
+
ALTER TABLE devices DROP CONSTRAINT IF EXISTS devices_network_hosts_check;
|
|
19
|
+
ALTER TABLE devices ADD CONSTRAINT devices_network_hosts_check
|
|
20
|
+
CHECK (jsonb_typeof(network_hosts) = 'array') NOT VALID;
|
|
21
|
+
ALTER TABLE devices VALIDATE CONSTRAINT devices_network_hosts_check;
|
|
22
|
+
|
|
23
|
+
-- Never wider: a device's host list only narrows its org's effective hosts, never adds to them,
|
|
24
|
+
-- so a cloud device whose B1 snapshot ran on an allowlist keeps exactly that allowlist; an empty
|
|
25
|
+
-- allowlist, or hosts that are not an array of strings, ran with the network closed and become
|
|
26
|
+
-- `none`; an open or missing snapshot follows the org. Only rows still following the org are
|
|
27
|
+
-- written, so a rerun never overwrites a later choice.
|
|
28
|
+
UPDATE devices
|
|
29
|
+
SET network_mode = CASE
|
|
30
|
+
WHEN jsonb_typeof(outer_network -> 'hosts') = 'array'
|
|
31
|
+
AND jsonb_array_length(outer_network -> 'hosts') > 0
|
|
32
|
+
AND NOT EXISTS (
|
|
33
|
+
SELECT 1 FROM jsonb_array_elements(outer_network -> 'hosts') AS h(v)
|
|
34
|
+
WHERE jsonb_typeof(h.v) <> 'string'
|
|
35
|
+
)
|
|
36
|
+
THEN 'allowlist'
|
|
37
|
+
ELSE 'none'
|
|
38
|
+
END,
|
|
39
|
+
network_hosts = CASE
|
|
40
|
+
WHEN jsonb_typeof(outer_network -> 'hosts') = 'array'
|
|
41
|
+
AND NOT EXISTS (
|
|
42
|
+
SELECT 1 FROM jsonb_array_elements(outer_network -> 'hosts') AS h(v)
|
|
43
|
+
WHERE jsonb_typeof(h.v) <> 'string'
|
|
44
|
+
)
|
|
45
|
+
THEN outer_network -> 'hosts'
|
|
46
|
+
ELSE '[]'::jsonb
|
|
47
|
+
END
|
|
48
|
+
WHERE source = 'cloud'
|
|
49
|
+
AND network_mode IS NULL
|
|
50
|
+
AND outer_network ->> 'kind' = 'allowlist';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
-- Approval-only profiles (design 2026-11-19, "Kernel: decision, admission and records"): Full
|
|
2
|
+
-- access grants a crossing within the device's ceilings by itself, so a call grant's evidence may
|
|
3
|
+
-- also be a Full access auto-grant, recorded like the review model's by its `permission_reviewed`
|
|
4
|
+
-- event (`review_event_seq`), with no approval and no deciding account.
|
|
5
|
+
-- each check is added NOT VALID (no scan under the add's lock), then validated
|
|
6
|
+
ALTER TABLE permission_call_grants DROP CONSTRAINT IF EXISTS permission_call_grants_source_check;
|
|
7
|
+
ALTER TABLE permission_call_grants ADD CONSTRAINT permission_call_grants_source_check
|
|
8
|
+
CHECK (source IN ('human', 'review-model', 'full-access')) NOT VALID;
|
|
9
|
+
ALTER TABLE permission_call_grants VALIDATE CONSTRAINT permission_call_grants_source_check;
|
|
10
|
+
-- the evidence shape of each source (0150 created it unnamed: PostgreSQL named it `_check`)
|
|
11
|
+
ALTER TABLE permission_call_grants DROP CONSTRAINT IF EXISTS permission_call_grants_check;
|
|
12
|
+
ALTER TABLE permission_call_grants DROP CONSTRAINT IF EXISTS permission_call_grants_evidence_check;
|
|
13
|
+
ALTER TABLE permission_call_grants ADD CONSTRAINT permission_call_grants_evidence_check
|
|
14
|
+
CHECK ((source = 'human' AND approval_id IS NOT NULL AND decided_by IS NOT NULL AND review_event_seq IS NULL)
|
|
15
|
+
OR (source IN ('review-model', 'full-access') AND approval_id IS NULL AND decided_by IS NULL
|
|
16
|
+
AND review_event_seq IS NOT NULL)) NOT VALID;
|
|
17
|
+
ALTER TABLE permission_call_grants VALIDATE CONSTRAINT permission_call_grants_evidence_check;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
-- The device sandbox no longer reads a cloud device's B1 snapshot network (`outer_network`), so
|
|
2
|
+
-- the copy 0165 made runs once more for cloud devices snapshotted after it (approval-only profiles
|
|
3
|
+
-- design, "Migration"): a device still following its org whose snapshot ran on an allowlist gets
|
|
4
|
+
-- `network_mode = 'allowlist'` and the snapshot's hosts as `network_hosts` when they are a
|
|
5
|
+
-- non-empty array of strings; an empty or unreadable allowlist ran closed and becomes `none`.
|
|
6
|
+
-- Never wider: a device's host list only narrows its org's hosts. Only rows still following the
|
|
7
|
+
-- org are written, so a rerun never overwrites a later choice. The snapshot writer copies new
|
|
8
|
+
-- snapshots itself from now on, and every permission publication repeats the copy for a snapshot
|
|
9
|
+
-- an older replica writes later (`copyCloudSnapshotNetworks`).
|
|
10
|
+
UPDATE devices
|
|
11
|
+
SET network_mode = CASE
|
|
12
|
+
WHEN jsonb_typeof(outer_network -> 'hosts') = 'array'
|
|
13
|
+
AND jsonb_array_length(outer_network -> 'hosts') > 0
|
|
14
|
+
AND NOT EXISTS (
|
|
15
|
+
SELECT 1 FROM jsonb_array_elements(outer_network -> 'hosts') AS h(v)
|
|
16
|
+
WHERE jsonb_typeof(h.v) <> 'string'
|
|
17
|
+
)
|
|
18
|
+
THEN 'allowlist'
|
|
19
|
+
ELSE 'none'
|
|
20
|
+
END,
|
|
21
|
+
network_hosts = CASE
|
|
22
|
+
WHEN jsonb_typeof(outer_network -> 'hosts') = 'array'
|
|
23
|
+
AND NOT EXISTS (
|
|
24
|
+
SELECT 1 FROM jsonb_array_elements(outer_network -> 'hosts') AS h(v)
|
|
25
|
+
WHERE jsonb_typeof(h.v) <> 'string'
|
|
26
|
+
)
|
|
27
|
+
THEN outer_network -> 'hosts'
|
|
28
|
+
ELSE '[]'::jsonb
|
|
29
|
+
END
|
|
30
|
+
WHERE source = 'cloud'
|
|
31
|
+
AND network_mode IS NULL
|
|
32
|
+
AND outer_network ->> 'kind' = 'allowlist';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
-- The authenticated device connection whose bindInstance answer installed a binding. A connection
|
|
2
|
+
-- answers bind before its own hello is recorded (the hello is recorded after `ready`), so the
|
|
3
|
+
-- hello that would replace an unattested generation must not replace one installed on its own
|
|
4
|
+
-- connection: that hello predates the binding. Connection ids are unique per socket across
|
|
5
|
+
-- replicas, so the comparison needs no clock.
|
|
6
|
+
ALTER TABLE device_instance_bindings ADD COLUMN IF NOT EXISTS installed_connection_id text;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
/** The org cloud-network allowlist's host limit. */
|
|
3
|
-
export declare const ORG_SANDBOX_ALLOW_HOSTS_MAX = 200;
|
|
4
|
-
/**
|
|
5
|
-
* The org's sandbox-mode network (org egress ceiling spec §D1), stored as a delta over the
|
|
6
|
-
* platform's `sandbox.limits.allowHosts`, never a copy of it, so platform changes keep reaching the
|
|
7
|
-
* org:
|
|
8
|
-
* - `mode`: the cloud network of a cloud device in sandbox mode, `open` (any public host; loopback,
|
|
9
|
-
* private and cloud metadata addresses are blocked outside the container) or `allowlist`; absent
|
|
10
|
-
* follows the platform's default (open). `sandbox.limits.orgHosts: within` makes it the allowlist.
|
|
11
|
-
* - `base`: `platform` (the default: start from the platform's list) or `none` (only the org's own
|
|
12
|
-
* hosts).
|
|
13
|
-
* - `extraHosts`: hosts the org adds (ignored outside the platform list under `within`).
|
|
14
|
-
* - `excludedHosts`: platform entries the org drops (exact entries; any host is accepted, since the
|
|
15
|
-
* platform may drop an entry later).
|
|
16
|
-
* The effective hosts ({@link orgEffectiveHosts} in `sandbox/modes.ts`) are also the ceiling a local
|
|
17
|
-
* device in sandbox mode reaches (the device intersects them with its own list).
|
|
18
|
-
*/
|
|
19
|
-
export declare const CloudNetworkSettingSchema: z.ZodObject<{
|
|
20
|
-
mode: z.ZodOptional<z.ZodEnum<{
|
|
21
|
-
allowlist: "allowlist";
|
|
22
|
-
open: "open";
|
|
23
|
-
}>>;
|
|
24
|
-
base: z.ZodOptional<z.ZodEnum<{
|
|
25
|
-
none: "none";
|
|
26
|
-
platform: "platform";
|
|
27
|
-
}>>;
|
|
28
|
-
extraHosts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
29
|
-
excludedHosts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
30
|
-
}, z.core.$strict>;
|
|
31
|
-
export type CloudNetworkSetting = z.infer<typeof CloudNetworkSettingSchema>;
|
|
32
|
-
/** What an invalid stored `cloudNetwork` reads as: the allowlist with no host (never wider). */
|
|
33
|
-
export declare const invalidCloudNetwork: () => CloudNetworkSetting;
|