@capybara-hq/kernel 0.1.0-rc.53 → 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 +15 -1
- package/dist/config/schema.js +66 -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 +18 -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 +43 -19
- package/dist/errors.js +43 -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/http/api.module.js +8 -0
- package/dist/http/app.js +9 -0
- package/dist/http/meta.controller.d.ts +33 -0
- package/dist/http/meta.controller.js +72 -0
- package/dist/identity/app-auth.controller.d.ts +25 -0
- package/dist/identity/app-auth.controller.js +64 -0
- package/dist/identity/app-auth.d.ts +66 -0
- package/dist/identity/app-auth.js +203 -0
- package/dist/identity/app-auth.schemas.d.ts +47 -0
- package/dist/identity/app-auth.schemas.js +43 -0
- package/dist/identity/identity.module.d.ts +1 -1
- package/dist/identity/identity.module.js +4 -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 +19 -5
- package/dist/infra/outbox/registry.d.ts +14 -0
- package/dist/infra/outbox/registry.js +15 -0
- package/dist/infra/throttler/named-throttlers.d.ts +3 -2
- package/dist/infra/throttler/named-throttlers.js +14 -2
- 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 +24 -1
- package/dist/platform/operation.js +2 -2
- 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/platform/ops/platform-icons.ops.d.ts +14 -0
- package/dist/platform/ops/platform-icons.ops.js +117 -0
- package/dist/platform/platform-ops.module.d.ts +2 -1
- package/dist/platform/platform-ops.module.js +3 -0
- package/dist/platform/route-schemas.js +3 -0
- package/dist/runtime/context/permission-profile.d.ts +17 -8
- package/dist/runtime/context/permission-profile.js +126 -45
- package/dist/runtime/maintenance.d.ts +5 -2
- package/dist/runtime/maintenance.js +15 -4
- 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/themes/platform-icon-objects.d.ts +51 -0
- package/dist/themes/platform-icon-objects.js +113 -0
- package/dist/themes/platform-icon-public.controller.d.ts +17 -0
- package/dist/themes/platform-icon-public.controller.js +58 -0
- package/dist/themes/platform-icon.controller.d.ts +22 -0
- package/dist/themes/platform-icon.controller.js +65 -0
- package/dist/themes/platform-icon.schemas.d.ts +48 -0
- package/dist/themes/platform-icon.schemas.js +53 -0
- package/dist/themes/platform-icon.service.d.ts +83 -0
- package/dist/themes/platform-icon.service.js +301 -0
- package/dist/themes/themes.module.d.ts +4 -1
- package/dist/themes/themes.module.js +9 -4
- 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/0164_platform_icons.sql +10 -0
- 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
|
@@ -15,10 +15,8 @@ export declare const NETWORK_ASK_KEPT_MAX_BYTES: number;
|
|
|
15
15
|
export declare const NETWORK_ASK_CLIPPED_NOTE = "[Output clipped to its first 16 KB while waiting for network access.]";
|
|
16
16
|
/** The idempotency key of a call's `network_blocked` event. */
|
|
17
17
|
export declare const networkBlockedIdemKey: (runId: string, callId: string) => string;
|
|
18
|
-
/** Asked, allowed this time (a run grant
|
|
18
|
+
/** Asked, allowed this time (a run grant, the only offer under device protocol 4). */
|
|
19
19
|
export declare const allowedOnceNote: (hosts: readonly string[]) => string;
|
|
20
|
-
/** Asked, allowed on the device from now on. */
|
|
21
|
-
export declare const allowedAlwaysNote: (hosts: readonly string[]) => string;
|
|
22
20
|
/** Asked and declined (also the unchecked hosts of a partial decision, and a host refused earlier in the run). */
|
|
23
21
|
export declare const deniedNote: (hosts: readonly string[], reason?: string | null) => string;
|
|
24
22
|
/** Asked, no answer within the approval timeout. */
|
|
@@ -33,21 +31,39 @@ export declare const otherAskPendingNote: (hosts: readonly string[]) => string;
|
|
|
33
31
|
export declare const tooManyNote: (hosts: readonly string[]) => string;
|
|
34
32
|
/**
|
|
35
33
|
* Not asked: the device cannot take network changes from the deployment (Docker mode, or a program
|
|
36
|
-
* too old to take them), so
|
|
34
|
+
* too old to take them), so a run grant would not reach it; only its owner can
|
|
37
35
|
* allow the host locally.
|
|
38
36
|
*/
|
|
39
37
|
export declare const localOnlyNote: (hosts: readonly string[]) => string;
|
|
40
|
-
/**
|
|
41
|
-
* Asked and allowed 「一直允许」, but the device refused the policy op (outcome `refused`): nothing
|
|
42
|
-
* was granted.
|
|
43
|
-
*/
|
|
44
|
-
export declare const alwaysRefusedNote: (hosts: readonly string[]) => string;
|
|
45
38
|
/** The org layer (spec §6.6): only an org admin can lift it. */
|
|
46
39
|
export declare const orgLayerNote: (hosts: readonly string[]) => string;
|
|
47
40
|
/** An org-layer host beyond the platform's ceiling (org egress ceiling spec §D2): only a super admin. */
|
|
48
41
|
export declare const platformCeilingNote: (hosts: readonly string[]) => string;
|
|
49
|
-
/**
|
|
50
|
-
|
|
42
|
+
/**
|
|
43
|
+
* The address layer (spec §6.6): no host grant lifts it, only running outside the sandbox. `why`,
|
|
44
|
+
* when running outside the sandbox is not possible for this call, is the escalation refusal's
|
|
45
|
+
* per-layer text (who turns it on, or that an unattended run cannot ask).
|
|
46
|
+
*/
|
|
47
|
+
export declare const addressLayerNote: (hosts: readonly string[], why?: string) => string;
|
|
48
|
+
/**
|
|
49
|
+
* The address layer under the open sandbox network on a device that allows running outside the
|
|
50
|
+
* sandbox (approval-only profiles design, "Open network"): no host grant reaches a private or
|
|
51
|
+
* local address from the sandbox, only an escalated call does. No network ask is made.
|
|
52
|
+
*/
|
|
53
|
+
export declare const addressEscalationNote: (hosts: readonly string[]) => string;
|
|
54
|
+
/**
|
|
55
|
+
* Whether a private-address block gets {@link addressEscalationNote}: admission's verdict for the
|
|
56
|
+
* call allows escalation (`available`, the source of the Bash tool's own hint: no
|
|
57
|
+
* `escalationRefusal`), and the device runs the open sandbox network (under an allowlist, a host
|
|
58
|
+
* grant is the remedy, not escalation).
|
|
59
|
+
*/
|
|
60
|
+
export declare function addressEscalationHint(escalation: "available" | "escalated" | undefined, networkMode: "open" | "allowlist" | "none"): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Not asked: a per-call grant for the host is unavailable on this device (approval-only profiles
|
|
63
|
+
* design, "Per-call host grant"), so asking would change nothing; `why` names who can add it
|
|
64
|
+
* (`hostGrantRefusal`): the device owner on the machine, an organization admin or a super admin.
|
|
65
|
+
*/
|
|
66
|
+
export declare const unavailableHostNote: (host: string, why: string) => string;
|
|
51
67
|
/**
|
|
52
68
|
* An unattended run (spec §8.1): the task approves the host, yet the device refused it: the device
|
|
53
69
|
* takes no network grants from the deployment (Docker mode, or a program too old for them).
|
|
@@ -70,16 +86,32 @@ export interface NetworkPlanContext {
|
|
|
70
86
|
* ceiling spec §D2): only a super admin can add it, so its note names the super admin.
|
|
71
87
|
*/
|
|
72
88
|
outsideCeiling?: (host: string) => boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Why a per-call grant for a host is unavailable on the device (`hostGrantRefusal`), or null when
|
|
91
|
+
* one may be granted: an unavailable host is never asked about, its note names who adds it.
|
|
92
|
+
*/
|
|
93
|
+
refusal?: (host: string) => string | null;
|
|
94
|
+
/**
|
|
95
|
+
* {@link addressEscalationHint}: a private-address block of an attended run answers with the
|
|
96
|
+
* escalation hint.
|
|
97
|
+
*/
|
|
98
|
+
escalation?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Why this call could not run outside the sandbox (the escalation refusal's per-layer text):
|
|
101
|
+
* a private-address block names who could allow it.
|
|
102
|
+
*/
|
|
103
|
+
escalationRefusal?: string;
|
|
73
104
|
}
|
|
74
105
|
/** What to do with a command's refused hosts. */
|
|
75
106
|
export interface NetworkPlan {
|
|
76
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* The device-layer hosts to ask the device owner about (empty: no ask). The ask offers a run
|
|
109
|
+
* grant only: the deployment never adds a host to a local device.
|
|
110
|
+
*/
|
|
77
111
|
ask: {
|
|
78
112
|
host: string;
|
|
79
113
|
port: number;
|
|
80
114
|
}[];
|
|
81
|
-
/** The scopes the ask offers (a device without remote grants is never asked). */
|
|
82
|
-
scopes: ("once" | "always")[];
|
|
83
115
|
/** Notes written now, after the command output (one line per outcome). */
|
|
84
116
|
notes: string[];
|
|
85
117
|
/** `missing_grants` keys of an unattended run (`network:<host>`). */
|
|
@@ -92,7 +124,12 @@ export declare function blockedEventHosts(blocked: readonly NetworkBlockedHost[]
|
|
|
92
124
|
* tree's network asks (`run`). The caller asks only for foreground `Bash` on a device; this decides
|
|
93
125
|
* the rest:
|
|
94
126
|
* - `address` and `org` layers: a note each (in an unattended run an `org` host is a missing grant);
|
|
127
|
+
* an `address` host under the open network on a device that allows running outside the sandbox
|
|
128
|
+
* gets the escalation hint; an `org` host whose grant is unavailable names who adds it;
|
|
95
129
|
* `unknown`: nothing (the device's trailer explains);
|
|
130
|
+
* - a `device` host whose per-call grant is unavailable (`ctx.refusal`: beyond a local owner's
|
|
131
|
+
* allowlist, or the org's or platform's allowlist ceiling): a note naming who adds it, never an
|
|
132
|
+
* ask;
|
|
96
133
|
* - `device` layer on a program without `policyOpId`: nothing (no ask, the trailer explains);
|
|
97
134
|
* - approved by the scheduled task the run serves (`run.taskGranted`) yet refused: a note that
|
|
98
135
|
* the device ignores the task's grants (never asked, never a missing grant);
|
|
@@ -104,7 +141,7 @@ export declare function blockedEventHosts(blocked: readonly NetworkBlockedHost[]
|
|
|
104
141
|
export declare function planNetworkAsk(blocked: readonly NetworkBlockedHost[], run: NetworkRunState | null, ctx: NetworkPlanContext): NetworkPlan;
|
|
105
142
|
/**
|
|
106
143
|
* The note of a settled network ask (spec §6.6): one line per outcome. An approval allows
|
|
107
|
-
* `detail.grantedHosts`
|
|
144
|
+
* `detail.grantedHosts` for the run and declines the hosts
|
|
108
145
|
* left unchecked; `hours` is the ask's own wait (created to expiry). Null while it is pending.
|
|
109
146
|
*/
|
|
110
147
|
export declare function settledNetworkNotes(a: ApprovalRecord, hours: number): string[] | null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { validateAllowHost, } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { NETWORK_ASK_MAX_HOSTS, NETWORK_HOST_MAX_CHARS } from "../conversations/events.js";
|
|
3
|
+
import { ESCALATION_UNATTENDED_WHY } from "../sandbox/review/permission-candidate.js";
|
|
3
4
|
import { networkGrantKey, unattendedFails, unattendedRules, } from "../schedules/unattended.js";
|
|
4
5
|
import { NETWORK_ASK_CANCELLED_NOTE } from "./approvals.service.js";
|
|
5
6
|
/**
|
|
@@ -20,10 +21,8 @@ const one = (hosts) => hosts.length === 1;
|
|
|
20
21
|
const pron = (hosts) => (one(hosts) ? "it" : "them");
|
|
21
22
|
/** "x was blocked by this device's network policy." (the lead of every device-layer note). */
|
|
22
23
|
const blockedLead = (hosts) => `[network] ${list(hosts)} ${one(hosts) ? "was" : "were"} blocked by this device's network policy.`;
|
|
23
|
-
/** Asked, allowed this time (a run grant
|
|
24
|
+
/** Asked, allowed this time (a run grant, the only offer under device protocol 4). */
|
|
24
25
|
export const allowedOnceNote = (hosts) => `${blockedLead(hosts)} The user allowed ${pron(hosts)} for the rest of this task. Run the command again.`;
|
|
25
|
-
/** Asked, allowed on the device from now on. */
|
|
26
|
-
export const allowedAlwaysNote = (hosts) => `${blockedLead(hosts)} The user allowed ${pron(hosts)} on this device from now on. Run the command again.`;
|
|
27
26
|
/** Asked and declined (also the unchecked hosts of a partial decision, and a host refused earlier in the run). */
|
|
28
27
|
export const deniedNote = (hosts, reason) => `${blockedLead(hosts)} The user declined access to ${list(hosts)}. Do not try to reach ${pron(hosts)} another way; continue without ${pron(hosts)} or ask the user.` +
|
|
29
28
|
(reason != null && reason !== "" ? ` Reason: ${reason}` : "");
|
|
@@ -41,15 +40,10 @@ export const tooManyNote = (hosts) => `${blockedLead(hosts)} Too many network re
|
|
|
41
40
|
const localAdd = (hosts) => hosts.map((h) => `capybara-device policy add allowedDomains ${h}`).join(" and ");
|
|
42
41
|
/**
|
|
43
42
|
* Not asked: the device cannot take network changes from the deployment (Docker mode, or a program
|
|
44
|
-
* too old to take them), so
|
|
43
|
+
* too old to take them), so a run grant would not reach it; only its owner can
|
|
45
44
|
* allow the host locally.
|
|
46
45
|
*/
|
|
47
46
|
export const localOnlyNote = (hosts) => `${blockedLead(hosts).slice(0, -1)}, and this device does not accept network changes from the conversation. The device owner can allow ${pron(hosts)} locally: ${localAdd(hosts)}. Continue without ${pron(hosts)} or tell the user.`;
|
|
48
|
-
/**
|
|
49
|
-
* Asked and allowed 「一直允许」, but the device refused the policy op (outcome `refused`): nothing
|
|
50
|
-
* was granted.
|
|
51
|
-
*/
|
|
52
|
-
export const alwaysRefusedNote = (hosts) => `${blockedLead(hosts)} The user allowed ${pron(hosts)} on this device, but the device does not accept network changes from the deployment; access stays blocked. The device owner can allow ${pron(hosts)} locally: ${localAdd(hosts)}.`;
|
|
53
47
|
/** The org layer (spec §6.6): only an org admin can lift it. */
|
|
54
48
|
export const orgLayerNote = (hosts) => one(hosts)
|
|
55
49
|
? `[network] ${list(hosts)} is not in the organization's network allowlist. Only an organization admin can add it; the user can ask an admin from the conversation. Continue without it or tell the user.`
|
|
@@ -58,10 +52,37 @@ export const orgLayerNote = (hosts) => one(hosts)
|
|
|
58
52
|
export const platformCeilingNote = (hosts) => one(hosts)
|
|
59
53
|
? `[network] ${list(hosts)} is not in the platform's network allowlist, which limits this organization. Only a super admin can add it; organization admins cannot. Continue without it or tell the user.`
|
|
60
54
|
: `[network] ${list(hosts)} are not in the platform's network allowlist, which limits this organization. Only a super admin can add them; organization admins cannot. Continue without them or tell the user.`;
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
/**
|
|
56
|
+
* The address layer (spec §6.6): no host grant lifts it, only running outside the sandbox. `why`,
|
|
57
|
+
* when running outside the sandbox is not possible for this call, is the escalation refusal's
|
|
58
|
+
* per-layer text (who turns it on, or that an unattended run cannot ask).
|
|
59
|
+
*/
|
|
60
|
+
export const addressLayerNote = (hosts, why) => `${one(hosts)
|
|
61
|
+
? `[network] ${list(hosts)} is a private or local address.`
|
|
62
|
+
: `[network] ${list(hosts)} are private or local addresses.`} Private and local addresses are closed inside the sandbox; only a command run outside the sandbox reaches ${pron(hosts)}${why === undefined ? "." : `, but ${why}. Continue without ${pron(hosts)} or tell the user.`}`;
|
|
63
|
+
/**
|
|
64
|
+
* The address layer under the open sandbox network on a device that allows running outside the
|
|
65
|
+
* sandbox (approval-only profiles design, "Open network"): no host grant reaches a private or
|
|
66
|
+
* local address from the sandbox, only an escalated call does. No network ask is made.
|
|
67
|
+
*/
|
|
68
|
+
export const addressEscalationNote = (hosts) => `${one(hosts)
|
|
69
|
+
? `[network] ${list(hosts)} is a private or local address, which the sandbox never reaches.`
|
|
70
|
+
: `[network] ${list(hosts)} are private or local addresses, which the sandbox never reaches.`} If the command must reach ${pron(hosts)}, retry the same Bash call with sandbox: "escalated" and justification: one sentence saying why; this conversation's permission profile decides whether it may run outside the sandbox for this call only.`;
|
|
71
|
+
/**
|
|
72
|
+
* Whether a private-address block gets {@link addressEscalationNote}: admission's verdict for the
|
|
73
|
+
* call allows escalation (`available`, the source of the Bash tool's own hint: no
|
|
74
|
+
* `escalationRefusal`), and the device runs the open sandbox network (under an allowlist, a host
|
|
75
|
+
* grant is the remedy, not escalation).
|
|
76
|
+
*/
|
|
77
|
+
export function addressEscalationHint(escalation, networkMode) {
|
|
78
|
+
return escalation === "available" && networkMode === "open";
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Not asked: a per-call grant for the host is unavailable on this device (approval-only profiles
|
|
82
|
+
* design, "Per-call host grant"), so asking would change nothing; `why` names who can add it
|
|
83
|
+
* (`hostGrantRefusal`): the device owner on the machine, an organization admin or a super admin.
|
|
84
|
+
*/
|
|
85
|
+
export const unavailableHostNote = (host, why) => `[network] ${host} was blocked by this device's network policy and cannot be allowed from this conversation: ${why}. Continue without it or tell the user.`;
|
|
65
86
|
/**
|
|
66
87
|
* An unattended run (spec §8.1): the task approves the host, yet the device refused it: the device
|
|
67
88
|
* takes no network grants from the deployment (Docker mode, or a program too old for them).
|
|
@@ -94,7 +115,12 @@ export function blockedEventHosts(blocked) {
|
|
|
94
115
|
* tree's network asks (`run`). The caller asks only for foreground `Bash` on a device; this decides
|
|
95
116
|
* the rest:
|
|
96
117
|
* - `address` and `org` layers: a note each (in an unattended run an `org` host is a missing grant);
|
|
118
|
+
* an `address` host under the open network on a device that allows running outside the sandbox
|
|
119
|
+
* gets the escalation hint; an `org` host whose grant is unavailable names who adds it;
|
|
97
120
|
* `unknown`: nothing (the device's trailer explains);
|
|
121
|
+
* - a `device` host whose per-call grant is unavailable (`ctx.refusal`: beyond a local owner's
|
|
122
|
+
* allowlist, or the org's or platform's allowlist ceiling): a note naming who adds it, never an
|
|
123
|
+
* ask;
|
|
98
124
|
* - `device` layer on a program without `policyOpId`: nothing (no ask, the trailer explains);
|
|
99
125
|
* - approved by the scheduled task the run serves (`run.taskGranted`) yet refused: a note that
|
|
100
126
|
* the device ignores the task's grants (never asked, never a missing grant);
|
|
@@ -112,15 +138,18 @@ export function planNetworkAsk(blocked, run, ctx) {
|
|
|
112
138
|
const taskIgnored = [];
|
|
113
139
|
const candidates = [];
|
|
114
140
|
const missingGrants = [];
|
|
115
|
-
|
|
116
|
-
//
|
|
141
|
+
const unavailable = [];
|
|
142
|
+
// a machine that reports blocked hosts and logs its ops under ids (Docker mode has no report)
|
|
117
143
|
const canAsk = ctx.device?.features.includes("networkReport") === true &&
|
|
118
144
|
ctx.device.features.includes("policyOpId");
|
|
119
145
|
for (const b of hostsOf(blocked)) {
|
|
120
146
|
if (b.layer === "address")
|
|
121
147
|
address.push(b.host);
|
|
122
148
|
else if (b.layer === "org") {
|
|
123
|
-
|
|
149
|
+
const why = ctx.refusal?.(b.host) ?? null;
|
|
150
|
+
if (why !== null)
|
|
151
|
+
unavailable.push(unavailableHostNote(b.host, why));
|
|
152
|
+
else if (ctx.outsideCeiling?.(b.host) === true)
|
|
124
153
|
platform.push(b.host);
|
|
125
154
|
else
|
|
126
155
|
org.push(b.host);
|
|
@@ -130,10 +159,13 @@ export function planNetworkAsk(blocked, run, ctx) {
|
|
|
130
159
|
else if (b.layer === "device") {
|
|
131
160
|
if (!canAsk)
|
|
132
161
|
continue;
|
|
162
|
+
const why = ctx.refusal?.(b.host) ?? null;
|
|
133
163
|
// relayer already made an invalid name an address; a wildcard is never asked
|
|
134
164
|
if (b.host.startsWith("*.") || validateAllowHost(b.host).length > 0) {
|
|
135
165
|
address.push(b.host);
|
|
136
166
|
}
|
|
167
|
+
else if (why !== null)
|
|
168
|
+
unavailable.push(unavailableHostNote(b.host, why));
|
|
137
169
|
else if (run?.taskGranted?.has(b.host))
|
|
138
170
|
taskIgnored.push(b.host);
|
|
139
171
|
else if (run?.refused.has(b.host))
|
|
@@ -163,33 +195,31 @@ export function planNetworkAsk(blocked, run, ctx) {
|
|
|
163
195
|
else
|
|
164
196
|
ask = candidates.slice(0, NETWORK_ASK_MAX_HOSTS);
|
|
165
197
|
}
|
|
198
|
+
notes.push(...unavailable);
|
|
166
199
|
if (org.length > 0)
|
|
167
200
|
notes.push(orgLayerNote(org));
|
|
168
201
|
if (platform.length > 0)
|
|
169
202
|
notes.push(platformCeilingNote(platform));
|
|
170
203
|
if (address.length > 0)
|
|
171
|
-
notes.push(
|
|
172
|
-
|
|
204
|
+
notes.push(ctx.escalation === true && ctx.unattended == null
|
|
205
|
+
? addressEscalationNote(address)
|
|
206
|
+
: addressLayerNote(address, ctx.unattended != null ? ESCALATION_UNATTENDED_WHY : ctx.escalationRefusal));
|
|
207
|
+
return { ask, notes, missingGrants };
|
|
173
208
|
}
|
|
174
209
|
/**
|
|
175
210
|
* The note of a settled network ask (spec §6.6): one line per outcome. An approval allows
|
|
176
|
-
* `detail.grantedHosts`
|
|
211
|
+
* `detail.grantedHosts` for the run and declines the hosts
|
|
177
212
|
* left unchecked; `hours` is the ask's own wait (created to expiry). Null while it is pending.
|
|
178
213
|
*/
|
|
179
214
|
export function settledNetworkNotes(a, hours) {
|
|
180
215
|
const asked = (a.detail?.hosts ?? []).map((h) => h.host);
|
|
181
216
|
switch (a.status) {
|
|
182
217
|
case "approved": {
|
|
183
|
-
// 「一直允许」 the device refused: nothing took effect (compared as a string: the outcome
|
|
184
|
-
// may predate this build's type)
|
|
185
|
-
if (a.detail?.outcome === "refused") {
|
|
186
|
-
return [alwaysRefusedNote(asked)];
|
|
187
|
-
}
|
|
188
218
|
const granted = a.detail?.grantedHosts ?? asked;
|
|
189
219
|
const rest = asked.filter((h) => !granted.includes(h));
|
|
190
220
|
const notes = [];
|
|
191
221
|
if (granted.length > 0) {
|
|
192
|
-
notes.push(
|
|
222
|
+
notes.push(allowedOnceNote(granted));
|
|
193
223
|
}
|
|
194
224
|
if (rest.length > 0)
|
|
195
225
|
notes.push(deniedNote(rest));
|
package/dist/tools/pipeline.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ import { SubagentMessages } from "../runtime/subagents/messages.js";
|
|
|
19
19
|
import { SubagentsService } from "../runtime/subagents/subagents.service.js";
|
|
20
20
|
import { SandboxOperationAuthority } from "../sandbox/operation-authority.js";
|
|
21
21
|
import { PermissionAuthorityLock } from "../sandbox/permission-authority-lock.js";
|
|
22
|
+
import { PermissionAutoGrants } from "../sandbox/permission-auto-grants.js";
|
|
22
23
|
import { PermissionCallGrants } from "../sandbox/permission-call-grants.js";
|
|
23
24
|
import { type CommandReview } from "../sandbox/review/index.js";
|
|
24
25
|
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
@@ -43,16 +44,18 @@ export declare const approvalDeniedText: (reason: string | null) => string;
|
|
|
43
44
|
export declare const approvalExpiredText: (hours: number) => string;
|
|
44
45
|
/** 等待审批期间 run 被中止。 */
|
|
45
46
|
export declare const APPROVAL_CANCELLED_TEXT = "The run was stopped while waiting for approval.";
|
|
47
|
+
/** What the review held: a shell command, a file write, or a file read outside the scope. */
|
|
48
|
+
export type ReviewKind = "command" | "write" | "read";
|
|
46
49
|
/**
|
|
47
50
|
* The command review's deny text (auto mode spec §5.4, P-D12): the model-visible reason and what it
|
|
48
|
-
* can do instead. `kind` says whether a shell command or a file
|
|
51
|
+
* can do instead. `kind` says whether a shell command, a file write or a file read was held.
|
|
49
52
|
*/
|
|
50
|
-
export declare const commandDeniedText: (reason: string, kind:
|
|
53
|
+
export declare const commandDeniedText: (reason: string, kind: ReviewKind) => string;
|
|
51
54
|
/**
|
|
52
|
-
* A command (or write) the review held in an unattended run: no one can answer, so it is a
|
|
53
|
-
* once — no approval, no grant (P-D3).
|
|
55
|
+
* A command (or write, or read) the review held in an unattended run: no one can answer, so it is a
|
|
56
|
+
* deny at once — no approval, no grant (P-D3).
|
|
54
57
|
*/
|
|
55
|
-
export declare const commandUnattendedText: (reason: string, kind:
|
|
58
|
+
export declare const commandUnattendedText: (reason: string, kind: ReviewKind) => string;
|
|
56
59
|
/**
|
|
57
60
|
* A command longer than the ask ceiling (`COMMAND_ASK_MAX_CHARS`): it cannot be shown for approval,
|
|
58
61
|
* and an approval must bind the whole text, so the call is refused before any approval exists.
|
|
@@ -60,8 +63,8 @@ export declare const commandUnattendedText: (reason: string, kind: "command" | "
|
|
|
60
63
|
export declare const commandTooLongReason: (chars: number) => string;
|
|
61
64
|
/** The model-visible result of a command over the ask ceiling (actionable, English). */
|
|
62
65
|
export declare const commandTooLongText: (chars: number) => string;
|
|
63
|
-
/** The person declined a held command or
|
|
64
|
-
export declare const commandDeclinedText: (reason: string | null, kind:
|
|
66
|
+
/** The person declined a held command, write or read (P-D12); `reason` is what they said, if any. */
|
|
67
|
+
export declare const commandDeclinedText: (reason: string | null, kind: ReviewKind) => string;
|
|
65
68
|
/** 等待用户输入期间 run 被中止。 */
|
|
66
69
|
export declare const INPUT_CANCELLED_TEXT = "The run was stopped while waiting for user input.";
|
|
67
70
|
/**
|
|
@@ -244,6 +247,8 @@ interface PipelineDeps {
|
|
|
244
247
|
runState(runId: string, deviceId?: string): Promise<NetworkRunState>;
|
|
245
248
|
};
|
|
246
249
|
devices: Pick<DevicePolicyService, "summary">;
|
|
250
|
+
/** The device's per-call host ceiling (absent: every device-layer host is asked about). */
|
|
251
|
+
sandbox?: Pick<SandboxService, "hostRefusal">;
|
|
247
252
|
} | undefined;
|
|
248
253
|
}
|
|
249
254
|
/** The sub-agent dispatch the pipeline calls (`SubagentsService.dispatch`). */
|
|
@@ -343,6 +348,8 @@ export declare class ToolPipeline {
|
|
|
343
348
|
readonly txHost: TransactionHost;
|
|
344
349
|
private readonly permissionAuthority?;
|
|
345
350
|
private readonly permissionGrants?;
|
|
351
|
+
/** Full access auto-grants, recorded exactly once (absent in hand-built pipelines). */
|
|
352
|
+
private readonly autoGrants?;
|
|
346
353
|
private readonly permissionLocks?;
|
|
347
354
|
/** Starts a cloud device before its first managed call is reviewed (absent: never). */
|
|
348
355
|
private readonly sandboxes?;
|
|
@@ -360,11 +367,13 @@ export declare class ToolPipeline {
|
|
|
360
367
|
/** The command review (auto mode spec §5.4); absent in hand-built pipelines. */
|
|
361
368
|
review?: CommandReview,
|
|
362
369
|
/** The reviewed call's device facts; absent in hand-built pipelines. */
|
|
363
|
-
devices?: Pick<ConversationDevices, "reviewFacts">, permissionAuthority?: SandboxOperationAuthority | undefined, permissionGrants?: PermissionCallGrants | undefined,
|
|
370
|
+
devices?: Pick<ConversationDevices, "reviewFacts">, permissionAuthority?: SandboxOperationAuthority | undefined, permissionGrants?: PermissionCallGrants | undefined,
|
|
371
|
+
/** Full access auto-grants, recorded exactly once (absent in hand-built pipelines). */
|
|
372
|
+
autoGrants?: PermissionAutoGrants | undefined, permissionLocks?: PermissionAuthorityLock | undefined,
|
|
364
373
|
/** The paired activation gate: on, the managed builtins take the permission review. */
|
|
365
374
|
activation?: boolean,
|
|
366
375
|
/** Starts a cloud device before its first managed call is reviewed (absent: never). */
|
|
367
|
-
sandboxes?: Pick<SandboxService, "ensureRunning"> | undefined);
|
|
376
|
+
sandboxes?: Pick<SandboxService, "ensureRunning" | "hostRefusal"> | undefined);
|
|
368
377
|
/**
|
|
369
378
|
* tools 节点:按顺序处理本步 assistant 消息里的全部 `tool_call`,每个调用都以一条 `tool_result` 结束
|
|
370
379
|
* (之后才回到 prepare 构建下一次请求,保持「已记录调用、未记录结果之间不构建请求」的不变式)。
|
|
@@ -417,8 +426,9 @@ export declare class ToolPipeline {
|
|
|
417
426
|
private reviewPermissionCall;
|
|
418
427
|
private reviewPermissionCallWith;
|
|
419
428
|
/**
|
|
420
|
-
* Whether an execution of this call was admitted outside the sandbox
|
|
421
|
-
*
|
|
429
|
+
* Whether an execution of this call was admitted outside the sandbox (a per-call escalation's
|
|
430
|
+
* full reach, under any profile): an intent past admission, or one revoked after dispatch, whose
|
|
431
|
+
* device-wide scope came from the call's escalation grant.
|
|
422
432
|
*/
|
|
423
433
|
private admittedOutsideSandbox;
|
|
424
434
|
private findPermissionGrant;
|
|
@@ -448,11 +458,12 @@ export declare class ToolPipeline {
|
|
|
448
458
|
* 或找不到 model_call 时返回 null(不做加载检查)。已加载集合由此从日志得出,不放进程内存。
|
|
449
459
|
*/
|
|
450
460
|
private sentTools;
|
|
451
|
-
/**
|
|
461
|
+
/** A decided approval other than approved → the model's text; still pending → null (wait). */
|
|
452
462
|
private refusalText;
|
|
453
463
|
/**
|
|
454
|
-
*
|
|
455
|
-
*
|
|
464
|
+
* A handler returned `input_required`: past the round limit, an invalid form
|
|
465
|
+
* (`validateInputForm`) or an oversized state is an error text for the model; otherwise an
|
|
466
|
+
* input request is made (writing `question_asked`) and its wait returned.
|
|
456
467
|
*/
|
|
457
468
|
private askInput;
|
|
458
469
|
/**
|
|
@@ -464,6 +475,7 @@ export declare class ToolPipeline {
|
|
|
464
475
|
workingRoot?: string | undefined;
|
|
465
476
|
against?: string | undefined;
|
|
466
477
|
escalation?: "available" | "escalated" | undefined;
|
|
478
|
+
escalationRefusal?: string | undefined;
|
|
467
479
|
}): Promise<ExecOutcome>;
|
|
468
480
|
private executeConnector;
|
|
469
481
|
/** 抛出的错误 → 给模型的结果:ToolError 的消息原样(插件约定为英文、可操作),其他只给错误类名。 */
|