@capybara-hq/kernel 0.1.0-rc.54 → 0.1.0-rc.56
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/dist/ui/views.d.ts +3 -1
- package/dist/ui/views.js +2 -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
|
@@ -73,6 +73,7 @@ const PermissionScopeSchema = z
|
|
|
73
73
|
z.object({ kind: z.literal("none") }).strict(),
|
|
74
74
|
z.object({ kind: z.literal("environment") }).strict(),
|
|
75
75
|
z.object({ kind: z.literal("allowlist"), hosts: PermissionHosts }).strict(),
|
|
76
|
+
z.object({ kind: z.literal("open-public") }).strict(),
|
|
76
77
|
]),
|
|
77
78
|
outerNetwork: z.discriminatedUnion("kind", [
|
|
78
79
|
z.object({ kind: z.literal("host-environment") }).strict(),
|
|
@@ -82,10 +83,47 @@ const PermissionScopeSchema = z
|
|
|
82
83
|
]),
|
|
83
84
|
})
|
|
84
85
|
.strict();
|
|
85
|
-
/**
|
|
86
|
-
|
|
86
|
+
/**
|
|
87
|
+
* The `sandbox` block of permission context version 2 (approval-only profiles design, "Replay and
|
|
88
|
+
* permission context"): the device sandbox, the same under every profile.
|
|
89
|
+
*/
|
|
90
|
+
export const PermissionContextSandboxSchema = z
|
|
87
91
|
.object({
|
|
88
|
-
|
|
92
|
+
boundary: z.enum(["operation", "instance"]),
|
|
93
|
+
location: z.enum(["local", "cloud"]),
|
|
94
|
+
workingRoot: z.string().min(1).max(4096),
|
|
95
|
+
network: z
|
|
96
|
+
.object({
|
|
97
|
+
kind: z.enum(["none", "allowlist", "open-public"]),
|
|
98
|
+
hostsCount: z.number().int().nonnegative().max(1000),
|
|
99
|
+
})
|
|
100
|
+
.strict(),
|
|
101
|
+
outsideSandbox: z.boolean(),
|
|
102
|
+
outerNetwork: z.discriminatedUnion("kind", [
|
|
103
|
+
z.object({ kind: z.literal("host-environment") }).strict(),
|
|
104
|
+
z.object({ kind: z.literal("none") }).strict(),
|
|
105
|
+
z.object({ kind: z.literal("open-public") }).strict(),
|
|
106
|
+
z.object({ kind: z.literal("allowlist"), hosts: PermissionHosts }).strict(),
|
|
107
|
+
]),
|
|
108
|
+
/**
|
|
109
|
+
* Whether a host may be granted per call on this device (false on an instance boundary, whose
|
|
110
|
+
* provider's network covers the whole instance). Absent in a block recorded before it existed:
|
|
111
|
+
* such a block renders the text it rendered, so replay never drifts.
|
|
112
|
+
*/
|
|
113
|
+
perCallHosts: z.boolean().optional(),
|
|
114
|
+
})
|
|
115
|
+
.strict()
|
|
116
|
+
.refine((b) => !(b.boundary === "instance" && b.perCallHosts === true), {
|
|
117
|
+
message: "An instance-boundary sandbox grants no host per call",
|
|
118
|
+
});
|
|
119
|
+
/**
|
|
120
|
+
* Complete recorded facts, never a grant or a requested-but-unverified scope. Version 2
|
|
121
|
+
* (approval-only profiles design) adds the device `sandbox` block, the same under every profile:
|
|
122
|
+
* a profile only chooses who approves a crossing, so Full access records a scoped sandbox too.
|
|
123
|
+
*/
|
|
124
|
+
export const PermissionContextV2Schema = z
|
|
125
|
+
.object({
|
|
126
|
+
version: z.literal(2),
|
|
89
127
|
rootConversationId: PermissionId,
|
|
90
128
|
profileRevision: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).nullable(),
|
|
91
129
|
selectedProfile: PermissionProfileSchema.nullable(),
|
|
@@ -107,6 +145,8 @@ export const PermissionContextV1Schema = z
|
|
|
107
145
|
.strict(),
|
|
108
146
|
]),
|
|
109
147
|
scope: PermissionScopeSchema.nullable(),
|
|
148
|
+
/** The device sandbox; only a supported context carries one. */
|
|
149
|
+
sandbox: PermissionContextSandboxSchema.nullable(),
|
|
110
150
|
})
|
|
111
151
|
.strict()
|
|
112
152
|
.superRefine((p, ctx) => {
|
|
@@ -148,15 +188,37 @@ export const PermissionContextV1Schema = z
|
|
|
148
188
|
: p.selectedProfile !== p.effectiveProfile))
|
|
149
189
|
reject("Invalid effective profile transition");
|
|
150
190
|
}
|
|
191
|
+
if (p.sandbox !== null && p.availability.state !== "supported")
|
|
192
|
+
reject("Only supported context carries a sandbox");
|
|
151
193
|
const s = p.scope;
|
|
152
194
|
if (!s)
|
|
153
195
|
return;
|
|
154
|
-
|
|
196
|
+
// every profile records a scoped sandbox under a block (the producer always writes one); a
|
|
197
|
+
// device filesystem or environment networking is never a sandboxed context's. Only a stored
|
|
198
|
+
// version 1 context, read as version 2 without a block, records Full access as exactly device
|
|
199
|
+
// + environment: that form stays readable because the log is never rewritten
|
|
200
|
+
if (p.effectiveProfile === "full-access" && p.sandbox === null) {
|
|
155
201
|
if (s.filesystem.kind !== "device" || s.network.kind !== "environment")
|
|
156
|
-
reject("Full access requires device filesystem and environment networking");
|
|
202
|
+
reject("Full access without a sandbox requires device filesystem and environment networking");
|
|
157
203
|
}
|
|
158
204
|
else if (s.filesystem.kind !== "scoped" || s.network.kind === "environment")
|
|
159
|
-
reject("
|
|
205
|
+
reject("A sandboxed context requires scoped filesystem and restricted networking");
|
|
206
|
+
if (p.sandbox !== null) {
|
|
207
|
+
const box = p.sandbox;
|
|
208
|
+
if (box.location !== s.location || box.workingRoot !== s.workingRoot)
|
|
209
|
+
reject("The sandbox must match the scope's location and working root");
|
|
210
|
+
if (canonicalOuter(box.outerNetwork) !== canonicalOuter(s.outerNetwork))
|
|
211
|
+
reject("The sandbox must match the scope's outer network");
|
|
212
|
+
// one canonical form: a scope without hosts is `none` in the block too
|
|
213
|
+
const hosts = s.network.kind === "allowlist" ? s.network.hosts.length : 0;
|
|
214
|
+
if (box.network.kind !== s.network.kind || box.network.hostsCount !== hosts)
|
|
215
|
+
reject("The sandbox network must match the scope's network");
|
|
216
|
+
if (box.boundary === "instance" && box.location !== "cloud")
|
|
217
|
+
reject("An instance boundary is a cloud device's");
|
|
218
|
+
// a cloud device has no outside: the provider's instance is the outermost boundary
|
|
219
|
+
if (box.location === "cloud" && box.outsideSandbox)
|
|
220
|
+
reject("A cloud device cannot run outside its sandbox");
|
|
221
|
+
}
|
|
160
222
|
if (s.filesystem.kind === "scoped") {
|
|
161
223
|
const { readDirectories, writeDirectories } = s.filesystem;
|
|
162
224
|
if (!readDirectories.includes(s.workingRoot) ||
|
|
@@ -168,6 +230,9 @@ export const PermissionContextV1Schema = z
|
|
|
168
230
|
}
|
|
169
231
|
if ((s.location === "local") !== (s.outerNetwork.kind === "host-environment"))
|
|
170
232
|
reject("Outer boundary must match the device location");
|
|
233
|
+
if (s.network.kind === "open-public" &&
|
|
234
|
+
(s.outerNetwork.kind === "none" || s.outerNetwork.kind === "allowlist"))
|
|
235
|
+
reject("An open network exceeds a disabled or allowlisted outer boundary");
|
|
171
236
|
if (s.location === "cloud" && s.network.kind === "allowlist") {
|
|
172
237
|
if (s.outerNetwork.kind === "none")
|
|
173
238
|
reject("Network hosts exceed the disabled outer boundary");
|
|
@@ -178,6 +243,26 @@ export const PermissionContextV1Schema = z
|
|
|
178
243
|
}
|
|
179
244
|
}
|
|
180
245
|
});
|
|
246
|
+
/**
|
|
247
|
+
* Reads a recorded payload as version 2. Stored v1 rows exist on deployments and the log is never
|
|
248
|
+
* rewritten: a v1 payload (`version: 1`, never a `sandbox` key) reads as v2 with `sandbox: null`,
|
|
249
|
+
* which v2 accepts under exactly v1's rules. Anything else is left for the v2 schema to judge.
|
|
250
|
+
*/
|
|
251
|
+
export function upconvertPermissionContext(payload) {
|
|
252
|
+
if (typeof payload === "object" &&
|
|
253
|
+
payload !== null &&
|
|
254
|
+
!Array.isArray(payload) &&
|
|
255
|
+
payload.version === 1 &&
|
|
256
|
+
!Object.hasOwn(payload, "sandbox"))
|
|
257
|
+
return { ...payload, version: 2, sandbox: null };
|
|
258
|
+
return payload;
|
|
259
|
+
}
|
|
260
|
+
/** A recorded `permission_context` payload as every reader parses it (v1 up-converted). */
|
|
261
|
+
export const RecordedPermissionContextSchema = z.preprocess(upconvertPermissionContext, PermissionContextV2Schema);
|
|
262
|
+
/** Order-independent identity of an outer network value (host lists are already sorted). */
|
|
263
|
+
function canonicalOuter(value) {
|
|
264
|
+
return JSON.stringify([value.kind, value.hosts ?? null]);
|
|
265
|
+
}
|
|
181
266
|
export const ManagedDevicePathsV1Schema = z
|
|
182
267
|
.object({
|
|
183
268
|
permissionContextVersion: z.literal(1),
|
|
@@ -193,6 +278,15 @@ export const PermissionContextMetaV1Schema = z
|
|
|
193
278
|
version: z.literal(1),
|
|
194
279
|
contextSeq: z.number().int().positive().max(Number.MAX_SAFE_INTEGER).nullable(),
|
|
195
280
|
hash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
281
|
+
/**
|
|
282
|
+
* The canonical hash of the located context's device `sandbox` block, present only when that
|
|
283
|
+
* context records one (permission context v2): a replay that rebuilds another block than the
|
|
284
|
+
* recording reports `device_sandbox_changed`.
|
|
285
|
+
*/
|
|
286
|
+
sandbox: z
|
|
287
|
+
.string()
|
|
288
|
+
.regex(/^[a-f0-9]{64}$/)
|
|
289
|
+
.optional(),
|
|
196
290
|
})
|
|
197
291
|
.strict();
|
|
198
292
|
/** 供应商私有数据(`ProviderOpaque`):原样保存、只回放给同一供应商。 */
|
|
@@ -308,6 +402,12 @@ export const ReviewRecordSchema = z
|
|
|
308
402
|
.optional(),
|
|
309
403
|
/** The call was allowed to run outside the OS sandbox (a per-call escalation). */
|
|
310
404
|
sandbox: z.literal("escalated").optional(),
|
|
405
|
+
/**
|
|
406
|
+
* The crossing this review decided (approval-only profiles design): a directory outside the
|
|
407
|
+
* scope, a host outside the allowlist, running outside the sandbox, or a sensitive command.
|
|
408
|
+
* Not model-visible, so it needs no DriftReason.
|
|
409
|
+
*/
|
|
410
|
+
crossing: z.enum(["directory", "host", "outside-sandbox", "sensitive"]).optional(),
|
|
311
411
|
})
|
|
312
412
|
.strict();
|
|
313
413
|
/** The display-only `approval_requested.command` facts of a `command` ask (auto mode spec §5.4). */
|
|
@@ -320,11 +420,13 @@ export const CommandAskSchema = z
|
|
|
320
420
|
escalation: PermissionEscalationSchema.optional(),
|
|
321
421
|
/** The directory the command runs in (an escalation shows it). */
|
|
322
422
|
workingRoot: z.string().max(4096).optional(),
|
|
323
|
-
/** A shell command or a file
|
|
324
|
-
kind: z.enum(["command", "write"]),
|
|
325
|
-
/** The
|
|
423
|
+
/** A shell command, a file write or a file read. */
|
|
424
|
+
kind: z.enum(["command", "write", "read"]),
|
|
425
|
+
/** The profile the call was reviewed under (a permission ask), for the card's wording. */
|
|
426
|
+
profile: z.enum(["request-approval", "approve-for-me", "full-access"]).optional(),
|
|
427
|
+
/** The command text, or the tool key of the write or read. */
|
|
326
428
|
command: z.string().max(COMMAND_ASK_TEXT_MAX_CHARS),
|
|
327
|
-
/** A file write's target path. */
|
|
429
|
+
/** A file write's or read's target path. */
|
|
328
430
|
path: z.string().max(4096).optional(),
|
|
329
431
|
rule: z.string().max(200).nullable(),
|
|
330
432
|
reason: z.string().max(COMMAND_ASK_TEXT_MAX_CHARS),
|
|
@@ -584,7 +686,7 @@ export const PluginContextSchema = z.object({
|
|
|
584
686
|
* 读出时按写入时的形状原样返回。
|
|
585
687
|
*/
|
|
586
688
|
export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
587
|
-
ev("permission_context",
|
|
689
|
+
ev("permission_context", PermissionContextV2Schema),
|
|
588
690
|
ev("permission_reviewed", z.object({
|
|
589
691
|
binding: PermissionCallBindingSchema,
|
|
590
692
|
permissionScope: PermissionExpansionSchema,
|
|
@@ -595,8 +697,15 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
|
595
697
|
candidateHash: z.string(),
|
|
596
698
|
outcome: z.enum(["allow", "ask", "deny"]),
|
|
597
699
|
reason: z.string(),
|
|
598
|
-
/**
|
|
599
|
-
|
|
700
|
+
/**
|
|
701
|
+
* Who decided: the review model, the fixed rules (a deny, an ask, the fail-closed ask), or
|
|
702
|
+
* Full access granting the crossing within the device's ceilings by itself.
|
|
703
|
+
*/
|
|
704
|
+
decisionSource: z.enum(["review-model", "rule", "full-access"]),
|
|
705
|
+
/** The crossing reviewed (approval-only profiles design); not model-visible. */
|
|
706
|
+
crossing: z.enum(["directory", "host", "outside-sandbox"]).optional(),
|
|
707
|
+
/** The sensitive-command consents (rule ids) a Full access auto-grant skipped; not model-visible. */
|
|
708
|
+
sensitive: z.array(z.string()).optional(),
|
|
600
709
|
})),
|
|
601
710
|
ev("permission_profile_changed", z.object({
|
|
602
711
|
oldProfile: z.enum(["request-approval", "approve-for-me", "full-access"]),
|
|
@@ -1171,9 +1280,11 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
|
1171
1280
|
reason: z.string().max(APPROVAL_DENY_REASON_MAX_CHARS).optional(),
|
|
1172
1281
|
})),
|
|
1173
1282
|
/**
|
|
1174
|
-
* A still-pending approval changed without a decision: a network ask's
|
|
1175
|
-
* device change was not applied or not confirmed (`detail.attempt`, transactional
|
|
1176
|
-
* §7).
|
|
1283
|
+
* A still-pending approval changed without a decision: a network ask's "always allow on this
|
|
1284
|
+
* device" whose device change was not applied or not confirmed (`detail.attempt`, transactional
|
|
1285
|
+
* outbox spec §7). No longer written (a network ask grants only the run since device protocol
|
|
1286
|
+
* 4); an older log may hold it. Display only, never model-visible: the page reads the approval
|
|
1287
|
+
* again.
|
|
1177
1288
|
*/
|
|
1178
1289
|
ev("approval_updated", z.object({ approvalId: z.string(), callId: z.string() })),
|
|
1179
1290
|
/**
|
|
@@ -61,8 +61,9 @@ export declare class PermissionProfilesController {
|
|
|
61
61
|
} | null;
|
|
62
62
|
scopeRevision: string | null;
|
|
63
63
|
availability: import("../sandbox/permission-availability.js").PermissionAvailability;
|
|
64
|
-
|
|
64
|
+
outsideSandboxCeiling: boolean;
|
|
65
65
|
broadProjectReach: boolean;
|
|
66
|
+
sandbox: import("../sandbox/device-sandbox.js").DeviceSandbox | null;
|
|
66
67
|
startingWorkNotice: string;
|
|
67
68
|
}>;
|
|
68
69
|
set(org: OrgContext, p: Principal, { id }: z.infer<typeof PermissionGetParams>, body: z.infer<typeof PermissionPatchBody>): Promise<{
|
|
@@ -72,8 +73,17 @@ export declare class PermissionProfilesController {
|
|
|
72
73
|
deviceId: string;
|
|
73
74
|
project: string | null;
|
|
74
75
|
scopeRevision: string;
|
|
76
|
+
consentIdentity: string;
|
|
77
|
+
consentReach: {
|
|
78
|
+
outsideSandbox: boolean;
|
|
79
|
+
networkCeiling: "none" | import("../sandbox/device-sandbox.js").DeviceNetworkMode;
|
|
80
|
+
networkMode: "none" | import("../sandbox/device-sandbox.js").DeviceNetworkMode;
|
|
81
|
+
restrictedProjectReach: "os-user" | "workspace";
|
|
82
|
+
hostCeiling: import("../sandbox/device-sandbox.js").HostGrantCeiling;
|
|
83
|
+
};
|
|
75
84
|
availability: import("../sandbox/permission-availability.js").PermissionAvailability;
|
|
76
|
-
|
|
85
|
+
sandbox: import("../sandbox/device-sandbox.js").DeviceSandbox;
|
|
86
|
+
outsideSandboxCeiling: boolean;
|
|
77
87
|
broadProjectReach: boolean;
|
|
78
88
|
}>;
|
|
79
89
|
first(org: OrgContext, p: Principal, body: z.infer<typeof FirstMessageBody>, reply: FastifyReply): Promise<{
|
|
@@ -24,8 +24,17 @@ export declare class PermissionProfilesService {
|
|
|
24
24
|
deviceId: string;
|
|
25
25
|
project: string | null;
|
|
26
26
|
scopeRevision: string;
|
|
27
|
+
consentIdentity: string;
|
|
28
|
+
consentReach: {
|
|
29
|
+
outsideSandbox: boolean;
|
|
30
|
+
networkCeiling: "none" | import("../sandbox/device-sandbox.js").DeviceNetworkMode;
|
|
31
|
+
networkMode: "none" | import("../sandbox/device-sandbox.js").DeviceNetworkMode;
|
|
32
|
+
restrictedProjectReach: "os-user" | "workspace";
|
|
33
|
+
hostCeiling: import("../sandbox/device-sandbox.js").HostGrantCeiling;
|
|
34
|
+
};
|
|
27
35
|
availability: import("../sandbox/permission-availability.js").PermissionAvailability;
|
|
28
|
-
|
|
36
|
+
sandbox: import("../sandbox/device-sandbox.js").DeviceSandbox;
|
|
37
|
+
outsideSandboxCeiling: boolean;
|
|
29
38
|
broadProjectReach: boolean;
|
|
30
39
|
}>;
|
|
31
40
|
get(orgId: string, id: string, accountId: string): Promise<{
|
|
@@ -39,8 +48,9 @@ export declare class PermissionProfilesService {
|
|
|
39
48
|
} | null;
|
|
40
49
|
scopeRevision: string | null;
|
|
41
50
|
availability: import("../sandbox/permission-availability.js").PermissionAvailability;
|
|
42
|
-
|
|
51
|
+
outsideSandboxCeiling: boolean;
|
|
43
52
|
broadProjectReach: boolean;
|
|
53
|
+
sandbox: import("../sandbox/device-sandbox.js").DeviceSandbox | null;
|
|
44
54
|
startingWorkNotice: string;
|
|
45
55
|
}>;
|
|
46
56
|
/** Reserve the root ID and authority before resolving its project or inserting first-send state. */
|
|
@@ -91,11 +91,18 @@ let PermissionProfilesService = class PermissionProfilesService {
|
|
|
91
91
|
if (!deviceId || !selection.consentScopeRevision)
|
|
92
92
|
throw new ApiError("conflict", "Full access requires an explicitly selected device and displayed scope consent");
|
|
93
93
|
const preview = await this.facts.scope(orgId, deviceId, projectPath, project);
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
// Full access is available wherever any profile is: the sandbox stays, and the consent binds
|
|
95
|
+
// the device and the crossing ceilings it auto-approves within (`scopeRevision`)
|
|
96
|
+
if (preview.availability.state === "unsupported" ||
|
|
96
97
|
preview.scopeRevision !== selection.consentScopeRevision)
|
|
97
|
-
throw new ApiError("conflict", "Device authority changed
|
|
98
|
-
|
|
98
|
+
throw new ApiError("conflict", "Device authority changed; refresh the permission preview and confirm Full access again");
|
|
99
|
+
// what the consent covers: a later narrowing keeps it, a widening needs a new one
|
|
100
|
+
return {
|
|
101
|
+
deviceId,
|
|
102
|
+
scopeRevision: preview.scopeRevision,
|
|
103
|
+
identity: preview.consentIdentity,
|
|
104
|
+
reach: preview.consentReach,
|
|
105
|
+
};
|
|
99
106
|
}
|
|
100
107
|
async set(orgId, id, accountId, body) {
|
|
101
108
|
const row = await this.store.own(orgId, id, accountId);
|
|
@@ -4,7 +4,7 @@ import type { ModelRef } from "../agents/definition.js";
|
|
|
4
4
|
import type { DeviceNetwork } from "../sandbox/modes.js";
|
|
5
5
|
import type { StartingExecutionGrants } from "../sandbox/operation-authority-types.js";
|
|
6
6
|
import type { AuthorityEpochVector } from "../sandbox/permission-authority-epochs.js";
|
|
7
|
-
import type { PermissionEscalation, PermissionExpansion, PermissionScopeKind } from "../sandbox/permission-call-types.js";
|
|
7
|
+
import type { PermissionEscalation, PermissionExpansion, PermissionGrantSource, PermissionScopeKind } from "../sandbox/permission-call-types.js";
|
|
8
8
|
import type { PermissionConfigProjection } from "../sandbox/permission-config-publication.js";
|
|
9
9
|
import type { PermissionRuntimeIdentity } from "../sandbox/permission-runtime-reports.js";
|
|
10
10
|
import type { ScheduleChat, ScheduleMarker, ScheduleMode, SchedulePauseReason, ScheduleStatus, ScheduleTrigger, TaskRunSkipReason, TaskRunStatus } from "../schedules/types.js";
|
|
@@ -39,7 +39,7 @@ export interface PermissionCallGrantsTable {
|
|
|
39
39
|
scope_kind: PermissionScopeKind;
|
|
40
40
|
/** A per-call sandbox escalation's justification (`scope_kind = 'sandbox-escalation'` only). */
|
|
41
41
|
escalation: ColumnType<PermissionEscalation | null, string | null | undefined, string | null>;
|
|
42
|
-
source:
|
|
42
|
+
source: PermissionGrantSource;
|
|
43
43
|
approval_id: string | null;
|
|
44
44
|
review_event_seq: number | null;
|
|
45
45
|
decided_by: string | null;
|
|
@@ -1057,6 +1057,10 @@ export interface DevicesTable {
|
|
|
1057
1057
|
permission_migration: ColumnType<unknown, string | null | undefined, string | null>;
|
|
1058
1058
|
/** 0154: the applied limits must be established before any operation is admitted. */
|
|
1059
1059
|
permission_reconcile_required: ColumnType<boolean, boolean | undefined, boolean>;
|
|
1060
|
+
/** 0165: a cloud device's sandbox network choice; null follows the org, `none` is closed. */
|
|
1061
|
+
network_mode: ColumnType<"open" | "allowlist" | "none" | null, "open" | "allowlist" | "none" | null | undefined, "open" | "allowlist" | "none" | null>;
|
|
1062
|
+
/** 0165: a cloud device's allowlist hosts (a JSON array), used while the mode is `allowlist`. */
|
|
1063
|
+
network_hosts: ColumnType<string[], string | undefined, string>;
|
|
1060
1064
|
created_at: Ts;
|
|
1061
1065
|
updated_at: Ts;
|
|
1062
1066
|
deleted_at: TsNullable;
|
|
@@ -1520,6 +1524,8 @@ export interface DeviceInstanceBindingsTable {
|
|
|
1520
1524
|
runtime_identity: ColumnType<PermissionRuntimeIdentity | null, string | null | undefined, string | null>;
|
|
1521
1525
|
created_at: Ts;
|
|
1522
1526
|
installed_at: TsNullable;
|
|
1527
|
+
/** Migration 0168: the device connection whose bind answer installed it. */
|
|
1528
|
+
installed_connection_id: string | null;
|
|
1523
1529
|
}
|
|
1524
1530
|
export interface LegacyLaunchFreezeTable {
|
|
1525
1531
|
id: "platform";
|
|
@@ -7,7 +7,7 @@ import { PermissionFacts } from "../sandbox/permission-facts.js";
|
|
|
7
7
|
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
8
8
|
import { DeviceAccess } from "./access.js";
|
|
9
9
|
import { type DeviceProjectScope } from "./project-rules.js";
|
|
10
|
-
export { type DeviceProjectScope,
|
|
10
|
+
export { type DeviceProjectScope, withinMode } from "./project-rules.js";
|
|
11
11
|
/** The most projects one device keeps (project root §4.1). */
|
|
12
12
|
export declare const MAX_DEVICE_PROJECTS = 100;
|
|
13
13
|
/** A project as the web and the Platform tool see it. */
|
|
@@ -24,11 +24,11 @@ import { PermissionFacts } from "../sandbox/permission-facts.js";
|
|
|
24
24
|
import { deviceNotFound, SandboxService } from "../sandbox/sandbox.service.js";
|
|
25
25
|
import { SandboxProviderUnreachableError } from "../sandbox/unreachable.js";
|
|
26
26
|
import { DeviceAccess } from "./access.js";
|
|
27
|
-
import { baseOf, clipped, homeUnknown, nameInvalid, nameTaken, outsideMode,
|
|
27
|
+
import { baseOf, clipped, homeUnknown, nameInvalid, nameTaken, outsideMode, tooBroad, withinMode, } from "./project-rules.js";
|
|
28
28
|
// a path above the owner's home is never stored as a project: the working root would fall back for
|
|
29
29
|
// it anyway (project root §4.3), so both use the one rule; the home itself may be one
|
|
30
30
|
import { aboveHome } from "./working-root.js";
|
|
31
|
-
export {
|
|
31
|
+
export { withinMode } from "./project-rules.js";
|
|
32
32
|
/** The most projects one device keeps (project root §4.1). */
|
|
33
33
|
export const MAX_DEVICE_PROJECTS = 100;
|
|
34
34
|
/**
|
|
@@ -38,17 +38,17 @@ export const MAX_DEVICE_PROJECTS = 100;
|
|
|
38
38
|
*/
|
|
39
39
|
const PROJECTS_HOLDER = "device-projects";
|
|
40
40
|
/** The raw route's reader over a held provider (gate off): the protocol 2 calls, unchanged. */
|
|
41
|
-
function heldReader(
|
|
41
|
+
function heldReader(h, p, workspace) {
|
|
42
42
|
const list = p.list;
|
|
43
43
|
const scan = p.scan;
|
|
44
44
|
return {
|
|
45
45
|
workspace,
|
|
46
46
|
browse: false,
|
|
47
47
|
...(list !== undefined && {
|
|
48
|
-
list: (path, limit, signal) => list.call(p, h, path, { limit,
|
|
48
|
+
list: (path, limit, signal) => list.call(p, h, path, { limit, signal }),
|
|
49
49
|
}),
|
|
50
50
|
...(scan !== undefined && {
|
|
51
|
-
scan: (base, signal) => scan.call(p, h, base, {
|
|
51
|
+
scan: (base, signal) => scan.call(p, h, base, { signal }),
|
|
52
52
|
}),
|
|
53
53
|
stat: (path, signal) => p.stat(h, path, signal),
|
|
54
54
|
};
|
|
@@ -366,7 +366,7 @@ let DeviceProjectsService = class DeviceProjectsService {
|
|
|
366
366
|
deviceId,
|
|
367
367
|
holderConversationId: PROJECTS_HOLDER,
|
|
368
368
|
actor: { accountId, conversationId: PROJECTS_HOLDER },
|
|
369
|
-
}, (h, p, info, sig) => fn(heldReader(
|
|
369
|
+
}, (h, p, info, sig) => fn(heldReader(h, p, info.roots.workspace), sig), signal);
|
|
370
370
|
}
|
|
371
371
|
catch (e) {
|
|
372
372
|
if (e instanceof ApiError)
|
|
@@ -13,19 +13,21 @@ import { type DeviceNameBody, type DeviceParams, type DevicePatchBody, type Devi
|
|
|
13
13
|
* - `GET /` → `{ items, defaultId, lastUsedId, cloudAvailable }` (`cloudAvailable`: there is a
|
|
14
14
|
* current sandbox provider; ruling R4);
|
|
15
15
|
* - `POST / { name }` → 201 `{ device }`; `GET /:id` → `{ device }`;
|
|
16
|
-
* - `PATCH /:id { name?,
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
16
|
+
* - `PATCH /:id { name?, network? }` → `{ device }`: renames it and sets a cloud device's sandbox
|
|
17
|
+
* network (`{ mode: open | allowlist | none | null, hosts? }`, approval-only profiles design,
|
|
18
|
+
* "Settings model") within its org's and the platform's ceilings (400
|
|
19
|
+
* `device.network_not_allowed` above them). A local device's network lives on its machine (409
|
|
20
|
+
* `device.ceiling_on_machine`; narrow it with `POST /:id/policy`). An API token may only narrow
|
|
21
|
+
* it (400 `device.network_not_allowed`);
|
|
21
22
|
* - `DELETE /:id` → 202 (destroyed by a job after the response);
|
|
22
23
|
* - `POST /:id/files/reset` → 202 (the reset is enqueued: a worker empties the files, the next use
|
|
23
24
|
* starts empty);
|
|
24
25
|
* - `DELETE /:id/machine` → 204: a local device's machine is disconnected (its credential
|
|
25
26
|
* revoked; it must sign in again);
|
|
26
|
-
* - `POST /:id/policy {
|
|
27
|
-
* device's
|
|
28
|
-
* `
|
|
27
|
+
* - `POST /:id/policy { remove?, ownerCeiling? }` → `{ policy }`: the owner narrows the local
|
|
28
|
+
* device's sandbox on its machine (hosts removed; `outsideSandbox: false`, `network:
|
|
29
|
+
* "allowlist"`, `restrictedProjectReach: "workspace"`); widening happens on the machine only.
|
|
30
|
+
* Web session only
|
|
29
31
|
* (`@SessionOnly`: a personal access token → 403 `auth.session_required`, a service token → 403):
|
|
30
32
|
* a person changes their own machine's network policy, nothing model-driven does. Offline → 503
|
|
31
33
|
* `device.offline`; cloud or an older program → 409 `device.policy_unsupported`; the machine's
|
|
@@ -8,7 +8,6 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
10
|
import { Controller, Delete, Get, HttpCode, Inject, Patch, Post } from "@nestjs/common";
|
|
11
|
-
import { ApiError } from "../errors.js";
|
|
12
11
|
import { CurrentPrincipal, patTokenId, requireUser, SessionOnly, } from "../identity/principal.js";
|
|
13
12
|
import { ZBody, ZParam } from "../infra/validation/zod-params.js";
|
|
14
13
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
@@ -23,19 +22,21 @@ import { DeviceCreateBodyDto, DeviceParamsDto, DevicePatchBodyDto, DevicePolicyB
|
|
|
23
22
|
* - `GET /` → `{ items, defaultId, lastUsedId, cloudAvailable }` (`cloudAvailable`: there is a
|
|
24
23
|
* current sandbox provider; ruling R4);
|
|
25
24
|
* - `POST / { name }` → 201 `{ device }`; `GET /:id` → `{ device }`;
|
|
26
|
-
* - `PATCH /:id { name?,
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
25
|
+
* - `PATCH /:id { name?, network? }` → `{ device }`: renames it and sets a cloud device's sandbox
|
|
26
|
+
* network (`{ mode: open | allowlist | none | null, hosts? }`, approval-only profiles design,
|
|
27
|
+
* "Settings model") within its org's and the platform's ceilings (400
|
|
28
|
+
* `device.network_not_allowed` above them). A local device's network lives on its machine (409
|
|
29
|
+
* `device.ceiling_on_machine`; narrow it with `POST /:id/policy`). An API token may only narrow
|
|
30
|
+
* it (400 `device.network_not_allowed`);
|
|
31
31
|
* - `DELETE /:id` → 202 (destroyed by a job after the response);
|
|
32
32
|
* - `POST /:id/files/reset` → 202 (the reset is enqueued: a worker empties the files, the next use
|
|
33
33
|
* starts empty);
|
|
34
34
|
* - `DELETE /:id/machine` → 204: a local device's machine is disconnected (its credential
|
|
35
35
|
* revoked; it must sign in again);
|
|
36
|
-
* - `POST /:id/policy {
|
|
37
|
-
* device's
|
|
38
|
-
* `
|
|
36
|
+
* - `POST /:id/policy { remove?, ownerCeiling? }` → `{ policy }`: the owner narrows the local
|
|
37
|
+
* device's sandbox on its machine (hosts removed; `outsideSandbox: false`, `network:
|
|
38
|
+
* "allowlist"`, `restrictedProjectReach: "workspace"`); widening happens on the machine only.
|
|
39
|
+
* Web session only
|
|
39
40
|
* (`@SessionOnly`: a personal access token → 403 `auth.session_required`, a service token → 403):
|
|
40
41
|
* a person changes their own machine's network policy, nothing model-driven does. Offline → 503
|
|
41
42
|
* `device.offline`; cloud or an older program → 409 `device.policy_unsupported`; the machine's
|
|
@@ -70,18 +71,13 @@ let DevicesController = class DevicesController {
|
|
|
70
71
|
async update(principal, org, params, body) {
|
|
71
72
|
const p = requireUser(principal);
|
|
72
73
|
const tokenId = patTokenId(p);
|
|
73
|
-
// a person changes their device's mode in a web session, narrowing or widening (auto mode
|
|
74
|
-
// spec §4.3, hardening D2): never an API token
|
|
75
|
-
if ((body.mode !== undefined || body.ownerCeiling !== undefined) && tokenId !== undefined) {
|
|
76
|
-
throw new ApiError("device.mode_requires_session", "A device's mode is changed by its owner on the device page, not with an API token");
|
|
77
|
-
}
|
|
78
74
|
return {
|
|
79
75
|
device: await this.devices.update(org.orgId, p.account.id, params.id, {
|
|
80
76
|
...(body.name !== undefined && { name: body.name }),
|
|
81
|
-
...(body.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
77
|
+
...(body.network !== undefined && { network: body.network }),
|
|
78
|
+
}, tokenId,
|
|
79
|
+
// an API token may narrow the network, never widen it (approval-only profiles design)
|
|
80
|
+
{ narrowOnly: tokenId !== undefined }),
|
|
85
81
|
};
|
|
86
82
|
}
|
|
87
83
|
async remove(principal, org, params) {
|
|
@@ -2,10 +2,10 @@ import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
|
2
2
|
/** The body of the excluded `POST /devices/:id/policy` route (human-only). */
|
|
3
3
|
export { DevicePolicyBody } from "./dto.js";
|
|
4
4
|
/**
|
|
5
|
-
* The devices routes the Platform operations mirror (`check:platform-ops` keys).
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* The devices routes the Platform operations mirror (`check:platform-ops` keys). Narrowing a local
|
|
6
|
+
* machine's sandbox (`POST /devices/:id/policy`, body {@link DevicePolicyBody}) is a person's act
|
|
7
|
+
* on their own machine and stays excluded, so it has no entry here. `PATCH /devices/:id`
|
|
8
|
+
* ({@link DevicePatchBody}) is mirrored by `devices.rename` (the name) and `devices.set-network`
|
|
9
|
+
* (a cloud device's network, narrow only).
|
|
10
10
|
*/
|
|
11
11
|
export declare const DEVICE_ROUTES: readonly RouteSchemas[];
|
|
@@ -2,11 +2,11 @@ import { DeviceNameBody, DeviceParams, DevicePatchBody, DeviceProjectAddBody, De
|
|
|
2
2
|
/** The body of the excluded `POST /devices/:id/policy` route (human-only). */
|
|
3
3
|
export { DevicePolicyBody } from "./dto.js";
|
|
4
4
|
/**
|
|
5
|
-
* The devices routes the Platform operations mirror (`check:platform-ops` keys).
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* The devices routes the Platform operations mirror (`check:platform-ops` keys). Narrowing a local
|
|
6
|
+
* machine's sandbox (`POST /devices/:id/policy`, body {@link DevicePolicyBody}) is a person's act
|
|
7
|
+
* on their own machine and stays excluded, so it has no entry here. `PATCH /devices/:id`
|
|
8
|
+
* ({@link DevicePatchBody}) is mirrored by `devices.rename` (the name) and `devices.set-network`
|
|
9
|
+
* (a cloud device's network, narrow only).
|
|
10
10
|
*/
|
|
11
11
|
export const DEVICE_ROUTES = [
|
|
12
12
|
{ route: "GET /api/v1/orgs/:orgId/devices" },
|