@capybara-hq/kernel 0.1.0-rc.32 → 0.1.0-rc.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bootstrap.json +3 -3
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/requests.service.d.ts +8 -6
- package/dist/catalog/requests.service.js +52 -29
- package/dist/channels/inbound.d.ts +0 -25
- package/dist/channels/inbound.js +26 -1
- package/dist/channels/phrases.d.ts +28 -0
- package/dist/channels/phrases.js +28 -0
- package/dist/config/schema.d.ts +4 -0
- package/dist/config/schema.js +7 -1
- package/dist/conversations/conversations.controller.d.ts +4 -1
- package/dist/conversations/conversations.controller.js +14 -2
- package/dist/conversations/conversations.service.d.ts +43 -3
- package/dist/conversations/conversations.service.js +93 -19
- package/dist/conversations/event-log.d.ts +3 -3
- package/dist/conversations/event-log.js +3 -3
- package/dist/conversations/events.d.ts +24 -0
- package/dist/conversations/events.js +69 -0
- package/dist/db/kernel-schema.d.ts +20 -0
- package/dist/devices/conversation-devices.d.ts +57 -3
- package/dist/devices/conversation-devices.js +63 -11
- package/dist/devices/device-projects.service.d.ts +162 -0
- package/dist/devices/device-projects.service.js +503 -0
- package/dist/devices/devices.controller.d.ts +15 -2
- package/dist/devices/devices.controller.js +60 -3
- package/dist/devices/devices.module.js +15 -2
- package/dist/devices/devices.schemas.js +9 -1
- package/dist/devices/devices.service.js +8 -4
- package/dist/devices/dto.d.ts +31 -0
- package/dist/devices/dto.js +38 -1
- package/dist/devices/working-root.d.ts +41 -0
- package/dist/devices/working-root.js +50 -0
- package/dist/errors.d.ts +39 -0
- package/dist/errors.js +39 -0
- package/dist/evals/run-replay.d.ts +9 -1
- package/dist/evals/run-replay.js +15 -1
- package/dist/local-devices/local-device-provider.d.ts +37 -1
- package/dist/local-devices/local-device-provider.js +33 -0
- package/dist/local-devices/machines.d.ts +2 -1
- package/dist/local-devices/machines.js +4 -1
- package/dist/local-devices/network-grants.d.ts +1 -1
- package/dist/local-devices/network-grants.js +2 -3
- package/dist/local-devices/policy-summary.js +1 -0
- package/dist/local-devices/relay.d.ts +2 -0
- package/dist/local-devices/relay.js +3 -1
- package/dist/local-devices/targets.d.ts +6 -1
- package/dist/local-devices/targets.js +14 -0
- package/dist/orgs/settings.controller.d.ts +3 -1
- package/dist/orgs/settings.controller.js +7 -3
- package/dist/orgs/settings.service.d.ts +78 -31
- package/dist/orgs/settings.service.js +109 -52
- package/dist/overrides.d.ts +4 -0
- package/dist/overrides.js +2 -0
- package/dist/platform/ops/agent-skills.ops.js +2 -1
- package/dist/platform/ops/devices.ops.d.ts +3 -1
- package/dist/platform/ops/devices.ops.js +136 -3
- package/dist/platform/ops/org-settings.ops.js +20 -10
- package/dist/runtime/context/build.d.ts +3 -0
- package/dist/runtime/context/build.js +14 -0
- package/dist/runtime/context/compaction.js +2 -0
- package/dist/runtime/context/project-root.d.ts +43 -0
- package/dist/runtime/context/project-root.js +85 -0
- package/dist/runtime/model-call.js +25 -1
- package/dist/runtime/project/knowledge.d.ts +129 -0
- package/dist/runtime/project/knowledge.js +248 -0
- package/dist/runtime/project/knowledge.service.d.ts +85 -0
- package/dist/runtime/project/knowledge.service.js +288 -0
- package/dist/runtime/run-worker.d.ts +5 -0
- package/dist/runtime/run-worker.js +27 -6
- package/dist/runtime/runtime.module.js +7 -0
- package/dist/sandbox/modes.d.ts +31 -19
- package/dist/sandbox/modes.js +43 -24
- package/dist/sandbox/review/review.service.d.ts +14 -2
- package/dist/sandbox/review/review.service.js +2 -0
- package/dist/sandbox/review/rules.d.ts +6 -4
- package/dist/sandbox/review/rules.js +185 -62
- package/dist/sandbox/review/types.d.ts +14 -0
- package/dist/sandbox/sandbox.service.d.ts +20 -2
- package/dist/sandbox/sandbox.service.js +86 -3
- package/dist/schedules/grant-rules.d.ts +2 -0
- package/dist/schedules/grant-rules.js +3 -1
- package/dist/schedules/schedule-math.js +21 -2
- package/dist/schedules/scheduled-tasks.service.js +3 -1
- package/dist/skills/catalog.d.ts +6 -1
- package/dist/skills/catalog.js +18 -4
- package/dist/skills/invoke.d.ts +64 -2
- package/dist/skills/invoke.js +214 -6
- package/dist/skills/skills.module.js +5 -0
- package/dist/tools/approvals.service.d.ts +6 -0
- package/dist/tools/builtins/sandbox/bash.js +19 -4
- package/dist/tools/builtins/sandbox/common.d.ts +36 -6
- package/dist/tools/builtins/sandbox/common.js +69 -8
- package/dist/tools/builtins/sandbox/edit.js +2 -2
- package/dist/tools/builtins/sandbox/glob.js +3 -2
- package/dist/tools/builtins/sandbox/grep.js +2 -1
- package/dist/tools/builtins/sandbox/read.js +3 -3
- package/dist/tools/builtins/sandbox/write.js +2 -2
- package/dist/tools/builtins/skill-load.d.ts +47 -2
- package/dist/tools/builtins/skill-load.js +160 -2
- package/dist/tools/network-asks.d.ts +7 -0
- package/dist/tools/network-asks.js +11 -1
- package/dist/tools/pipeline.d.ts +1 -1
- package/dist/tools/pipeline.js +60 -9
- package/dist/tools/registry.d.ts +6 -0
- package/package.json +2 -2
- package/src/migrations/0133_project_root.sql +30 -0
- package/src/migrations/0134_org_cloud_network_delta.sql +38 -0
|
@@ -22,6 +22,47 @@ const WORD_END = new Set([" ", "\t", "\n", "\r", "|", "&", ";", "<", ">", "(", "
|
|
|
22
22
|
const isDigit = (c) => c >= "0" && c <= "9";
|
|
23
23
|
const isAlphaNum = (c) => /[A-Za-z0-9]/.test(c);
|
|
24
24
|
/** The public parser: the parsed command, or null when the tokenizer is not confident. */
|
|
25
|
+
/** `git config` options that only read (the long-standing spelling). */
|
|
26
|
+
const GIT_CONFIG_READ_OPTIONS = new Set([
|
|
27
|
+
"--get",
|
|
28
|
+
"--get-all",
|
|
29
|
+
"--get-regexp",
|
|
30
|
+
"--get-urlmatch",
|
|
31
|
+
"--get-color",
|
|
32
|
+
"--get-colorbool",
|
|
33
|
+
"-l",
|
|
34
|
+
"--list",
|
|
35
|
+
]);
|
|
36
|
+
/** `git config` options that change the file whatever else the line says. */
|
|
37
|
+
const GIT_CONFIG_WRITE_OPTIONS = new Set([
|
|
38
|
+
"--add",
|
|
39
|
+
"--unset",
|
|
40
|
+
"--unset-all",
|
|
41
|
+
"--replace-all",
|
|
42
|
+
"--rename-section",
|
|
43
|
+
"--remove-section",
|
|
44
|
+
"-e",
|
|
45
|
+
"--edit",
|
|
46
|
+
]);
|
|
47
|
+
/**
|
|
48
|
+
* `git config --global` / `--system` that changes the user's or the system's config file: a value
|
|
49
|
+
* set, an `--unset`, an edit, a section rename (`git config [--global] name value`, the subcommands
|
|
50
|
+
* `set` / `unset` / `edit` / `rename-section` / `remove-section`). Reading it (`--get…`, `--list`,
|
|
51
|
+
* `get`, `list`) changes nothing; plain `git config --list` already prints the global values.
|
|
52
|
+
*/
|
|
53
|
+
function gitConfigChangesUserFile(args) {
|
|
54
|
+
if (args[0] !== "config")
|
|
55
|
+
return false;
|
|
56
|
+
const rest = args.slice(1);
|
|
57
|
+
if (!hasArg(rest, "--global", "--system"))
|
|
58
|
+
return false;
|
|
59
|
+
if (rest.some((a) => GIT_CONFIG_WRITE_OPTIONS.has(a)))
|
|
60
|
+
return true;
|
|
61
|
+
const sub = rest.find((a) => !a.startsWith("-"));
|
|
62
|
+
if (sub === "get" || sub === "list")
|
|
63
|
+
return false;
|
|
64
|
+
return !rest.some((a) => GIT_CONFIG_READ_OPTIONS.has(a));
|
|
65
|
+
}
|
|
25
66
|
export function parseCommand(command) {
|
|
26
67
|
const parsed = parseDetailed(command);
|
|
27
68
|
return parsed.ok ? { commands: parsed.value } : null;
|
|
@@ -763,7 +804,8 @@ function unwrapOneLevel(commands) {
|
|
|
763
804
|
function isDynamicScript(script) {
|
|
764
805
|
return script.includes("$(") || script.includes("`") || /\$\{?[A-Za-z_]/.test(script);
|
|
765
806
|
}
|
|
766
|
-
|
|
807
|
+
/** The home directory a path lies in by its `/home/<u>`, `/Users/<u>` or `/root` prefix, or null. */
|
|
808
|
+
export function homeOf(workspace) {
|
|
767
809
|
const parts = workspace.split("/").filter((p) => p.length > 0);
|
|
768
810
|
if ((parts[0] === "home" || parts[0] === "Users") && parts.length >= 2)
|
|
769
811
|
return `/${parts[0]}/${parts[1]}`;
|
|
@@ -773,11 +815,25 @@ function homeOf(workspace) {
|
|
|
773
815
|
}
|
|
774
816
|
function resolveFacts(facts) {
|
|
775
817
|
const workspace = normalizePath(facts.workspace);
|
|
818
|
+
const derived = homeOf(workspace);
|
|
819
|
+
// the home of the device's own workspace: a project outside every home keeps protecting it
|
|
820
|
+
const device = facts.deviceHome?.startsWith("/") ? normalizePath(facts.deviceHome) : null;
|
|
821
|
+
const deviceHome = device === null || device === "/" ? null : device;
|
|
822
|
+
// an implausible reported home (`/`, or an ancestor of a derived home such as `/Users`) would
|
|
823
|
+
// make every path a home path: it is ignored and only the derived homes are used
|
|
824
|
+
const given = facts.home?.startsWith("/") ? normalizePath(facts.home) : null;
|
|
825
|
+
const reported = given === null ||
|
|
826
|
+
given === "/" ||
|
|
827
|
+
[derived, deviceHome].some((d) => d !== null && isAncestor(given, d))
|
|
828
|
+
? null
|
|
829
|
+
: given;
|
|
776
830
|
const cwd = facts.cwd === undefined ? workspace : normalizePath(facts.cwd);
|
|
777
831
|
return {
|
|
778
832
|
workspace,
|
|
779
833
|
cwd,
|
|
780
|
-
home
|
|
834
|
+
// the owner's home as the pipeline knows it (the machine's), else the workspace's prefix
|
|
835
|
+
home: reported ?? derived ?? deviceHome,
|
|
836
|
+
homes: [...new Set([reported, derived, deviceHome].filter((h) => h !== null))],
|
|
781
837
|
written: new Set((facts.written ?? []).map((p) => p.endsWith("/**") ? `${normalizePath(p.slice(0, -3))}/**` : normalizePath(p))),
|
|
782
838
|
};
|
|
783
839
|
}
|
|
@@ -861,24 +917,34 @@ function tildeForm(path, facts) {
|
|
|
861
917
|
}
|
|
862
918
|
return path;
|
|
863
919
|
}
|
|
864
|
-
/** Case-folded spelling for the
|
|
920
|
+
/** Case-folded spelling for the home-level judgements. */
|
|
865
921
|
const foldCase = (value) => value.toLowerCase();
|
|
866
922
|
/**
|
|
867
|
-
* `
|
|
868
|
-
*
|
|
869
|
-
*
|
|
923
|
+
* Every spelling of `path` the home-level rules (secrets, shell and editor rc files, persistence,
|
|
924
|
+
* the device's files) judge: its `~` form against each of {@link ResolvedFacts.homes} it lies in,
|
|
925
|
+
* then the path itself. macOS's default file system is case-insensitive, so `/USERS/me/.SSH` names
|
|
926
|
+
* the same file as `/Users/me/.ssh`: the home is matched case-folded and the rules compare the
|
|
927
|
+
* case-folded forms ({@link foldedForms}), which only widens what they catch. Workspace containment
|
|
928
|
+
* keeps the exact spelling.
|
|
870
929
|
*/
|
|
871
|
-
function
|
|
872
|
-
if (facts.home === null)
|
|
873
|
-
return path;
|
|
874
|
-
const home = foldCase(facts.home);
|
|
930
|
+
function homeForms(path, facts) {
|
|
875
931
|
const folded = foldCase(path);
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
932
|
+
const out = [];
|
|
933
|
+
for (const h of facts.homes) {
|
|
934
|
+
const home = foldCase(h);
|
|
935
|
+
if (folded === home)
|
|
936
|
+
out.push("~");
|
|
937
|
+
// a root home keeps the path's own leading slash: `/.ssh/x` is `~/.ssh/x`, never `~.ssh/x`
|
|
938
|
+
else if (home === "/")
|
|
939
|
+
out.push(`~${path}`);
|
|
940
|
+
else if (folded.startsWith(`${home}/`))
|
|
941
|
+
out.push(`~${path.slice(h.length)}`);
|
|
942
|
+
}
|
|
943
|
+
out.push(path);
|
|
944
|
+
return out;
|
|
881
945
|
}
|
|
946
|
+
/** {@link homeForms}, case-folded: what the home-level rules compare against lowercase patterns. */
|
|
947
|
+
const foldedForms = (path, facts) => homeForms(path, facts).map(foldCase);
|
|
882
948
|
const TMP_ROOTS = ["/tmp", "/private/tmp", "/var/tmp", "/var/folders", "/private/var/folders"];
|
|
883
949
|
const tmpRootOf = (path) => TMP_ROOTS.some((root) => inside(path, root));
|
|
884
950
|
const SECRET_HOME_PATHS = [
|
|
@@ -896,6 +962,7 @@ const SECRET_HOME_PATHS = [
|
|
|
896
962
|
"~/.vault-token",
|
|
897
963
|
"~/.terraform.d/credentials.tfrc.json",
|
|
898
964
|
"~/.config/op",
|
|
965
|
+
"~/.gnupg",
|
|
899
966
|
"~/.bash_history",
|
|
900
967
|
"~/.zsh_history",
|
|
901
968
|
"~/.sh_history",
|
|
@@ -1082,9 +1149,11 @@ function isSecretPattern(path, facts) {
|
|
|
1082
1149
|
if (tail.length >= 2 && last !== undefined && segmentMatches(last, "environ"))
|
|
1083
1150
|
return true;
|
|
1084
1151
|
}
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1152
|
+
// every home the path lies in is tried; none matching falls through to the checks below
|
|
1153
|
+
for (const t of homeForms(path, facts)) {
|
|
1154
|
+
if (t.startsWith("~/") && isSecretHomePath(t.slice(2).split("/")))
|
|
1155
|
+
return true;
|
|
1156
|
+
}
|
|
1088
1157
|
// `/home/<pattern>/…` never becomes `~/…`: the user segment is the pattern, so judge only the
|
|
1089
1158
|
// literal suffix behind it.
|
|
1090
1159
|
const [root, user, ...suffix] = absolute;
|
|
@@ -1111,7 +1180,7 @@ function isSecretPattern(path, facts) {
|
|
|
1111
1180
|
// the workspace is under `/root`; from another home, `/root/…` is another user's and stays
|
|
1112
1181
|
// allowed (as the literal `/root/.netrc` does), so it must not turn a `/Users/me` workspace's
|
|
1113
1182
|
// `/*/.ssh/id_rsa` into a hit.
|
|
1114
|
-
const rootHit = (facts.
|
|
1183
|
+
const rootHit = (facts.homes.length === 0 || facts.homes.includes("/root")) &&
|
|
1115
1184
|
user !== undefined &&
|
|
1116
1185
|
segmentMatches(root, "root") &&
|
|
1117
1186
|
isSecretHomePath([user, ...suffix]);
|
|
@@ -1121,32 +1190,49 @@ function isSecretPattern(path, facts) {
|
|
|
1121
1190
|
return false;
|
|
1122
1191
|
}
|
|
1123
1192
|
function isSecretPath(path, facts) {
|
|
1193
|
+
if (isHomeSecretPath(path, facts))
|
|
1194
|
+
return true;
|
|
1195
|
+
const base = baseName(path).toLowerCase();
|
|
1196
|
+
return base.startsWith(".env") && !inside(path, facts.workspace);
|
|
1197
|
+
}
|
|
1198
|
+
/** {@link isSecretPath} without `.env*`: the secrets judged wherever they lie. */
|
|
1199
|
+
function isHomeSecretPath(path, facts) {
|
|
1124
1200
|
if (PROC_ENVIRON.test(path))
|
|
1125
1201
|
return true;
|
|
1126
1202
|
// A glob or brace is what the shell expands before the command runs: the path is a secret when
|
|
1127
1203
|
// it can expand to one, so `cat ~/.netr?` is the same read as `cat ~/.netrc`.
|
|
1128
1204
|
if (hasPattern(path) && isSecretPattern(path, facts))
|
|
1129
1205
|
return true;
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1206
|
+
return foldedForms(path, facts).some((t) => SECRET_HOME_PATHS.some((secret) => t === secret || t.startsWith(`${secret}/`)));
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* A home-level sensitive path (auto mode spec §5.2: shell rc files, `~/.ssh`, `~/.gitconfig`,
|
|
1210
|
+
* launch agents, crontab and the secret paths), judged by its absolute path against the owner's
|
|
1211
|
+
* home. These rules apply whether or not the path is inside the workspace fact: the workspace's
|
|
1212
|
+
* exemption covers ordinary files only, so a project at the owner's home (project root spec
|
|
1213
|
+
* §4.3) never makes `~/.bashrc` an ordinary write. (`.env*` stays a secret only outside the
|
|
1214
|
+
* workspace: {@link isSecretPath}.)
|
|
1215
|
+
*/
|
|
1216
|
+
function isHomeLevelSensitive(path, facts) {
|
|
1217
|
+
return isHomeSecretPath(path, facts) || isPersistencePath(path, facts);
|
|
1135
1218
|
}
|
|
1136
1219
|
function isPersistencePath(path, facts) {
|
|
1137
|
-
|
|
1138
|
-
|
|
1220
|
+
return foldedForms(path, facts).some((t) => isPersistenceForm(t, facts)) || isGitHook(path);
|
|
1221
|
+
}
|
|
1222
|
+
/** One case-folded {@link homeForms} spelling of a persistence path (patterns in lowercase). */
|
|
1223
|
+
function isPersistenceForm(t, facts) {
|
|
1224
|
+
if (isGitConfigForm(t))
|
|
1139
1225
|
return true;
|
|
1140
1226
|
if (/^~\/\.(bashrc|bash_profile|bash_login|profile|zshrc|zshenv|zprofile|zlogin|tcshrc|cshrc|kshrc)$/.test(t)) {
|
|
1141
1227
|
return true;
|
|
1142
1228
|
}
|
|
1143
1229
|
if (t === "~/.config/fish/config.fish" || t.startsWith("~/.config/fish/conf.d/"))
|
|
1144
1230
|
return true;
|
|
1145
|
-
if (t
|
|
1231
|
+
if (isEditorOrLogoutRc(t) || isRunLaterHomePath(t, facts))
|
|
1146
1232
|
return true;
|
|
1147
|
-
if (t
|
|
1233
|
+
if (t === "~/.ssh" || t.startsWith("~/.ssh/"))
|
|
1148
1234
|
return true;
|
|
1149
|
-
if (
|
|
1235
|
+
if (isLaunchForm(t))
|
|
1150
1236
|
return true;
|
|
1151
1237
|
if ([
|
|
1152
1238
|
"/etc/profile",
|
|
@@ -1161,10 +1247,12 @@ function isPersistencePath(path, facts) {
|
|
|
1161
1247
|
}
|
|
1162
1248
|
if (t === "/etc/crontab" || t.startsWith("/var/spool/cron") || t.startsWith("/etc/cron."))
|
|
1163
1249
|
return true;
|
|
1164
|
-
|
|
1165
|
-
return true;
|
|
1166
|
-
return isGitHook(path);
|
|
1250
|
+
return t.startsWith("~/.config/systemd");
|
|
1167
1251
|
}
|
|
1252
|
+
/** The global git configuration: `~/.gitconfig` (and its lock / backups) or `~/.config/git/config`. */
|
|
1253
|
+
const isGitConfigForm = (t) => t === "~/.gitconfig" || t.startsWith("~/.gitconfig.") || t === "~/.config/git/config";
|
|
1254
|
+
/** A launch agent or daemon, the owner's or the machine's. */
|
|
1255
|
+
const isLaunchForm = (t) => /^(~|)\/library\/launch(agents|daemons)/.test(t);
|
|
1168
1256
|
const DEVICE_DIRS = [
|
|
1169
1257
|
"~/.config/capybara-device",
|
|
1170
1258
|
"~/.capybara-device",
|
|
@@ -1174,13 +1262,18 @@ const DEVICE_DIRS = [
|
|
|
1174
1262
|
"/var/lib/capybara-device",
|
|
1175
1263
|
];
|
|
1176
1264
|
function isDevicePath(path, facts) {
|
|
1177
|
-
const
|
|
1178
|
-
if (
|
|
1265
|
+
const dirs = DEVICE_DIRS.map(foldCase);
|
|
1266
|
+
if (foldedForms(path, facts).some((t) => dirs.some((d) => t === d || t.startsWith(`${d}/`)))) {
|
|
1179
1267
|
return true;
|
|
1268
|
+
}
|
|
1180
1269
|
// The device binary, its unit file and its launch agent anywhere on disk.
|
|
1181
|
-
return isDeviceIdentifier(baseName(
|
|
1270
|
+
return isDeviceIdentifier(baseName(path));
|
|
1182
1271
|
}
|
|
1183
|
-
|
|
1272
|
+
/** A git hook, in any letter case (a case-insensitive file system names the same directory). */
|
|
1273
|
+
const isGitHook = (path) => {
|
|
1274
|
+
const p = foldCase(path);
|
|
1275
|
+
return p.includes("/.git/hooks/") || p.endsWith("/.git/hooks");
|
|
1276
|
+
};
|
|
1184
1277
|
function looksLikePath(token) {
|
|
1185
1278
|
if (token.length === 0 || token === "-" || token.startsWith("-"))
|
|
1186
1279
|
return false;
|
|
@@ -3956,8 +4049,7 @@ function destroyTargetsOf(inv) {
|
|
|
3956
4049
|
}
|
|
3957
4050
|
function isDangerousDelete(resolved, ctx) {
|
|
3958
4051
|
const base = globBase(resolved);
|
|
3959
|
-
|
|
3960
|
-
if (t === "/" || t === "~" || t === "~/")
|
|
4052
|
+
if (base === "/" || homeForms(base, ctx.facts).some((t) => t === "~" || t === "~/"))
|
|
3961
4053
|
return true;
|
|
3962
4054
|
// the workspace root itself and every directory above it (hardening spec R2)
|
|
3963
4055
|
return base === ctx.facts.workspace || isAncestor(base, ctx.facts.workspace);
|
|
@@ -4002,17 +4094,40 @@ const CONFIG_REASONS = {
|
|
|
4002
4094
|
"ask.ssh": "Changes or prints SSH keys or configuration; this needs approval.",
|
|
4003
4095
|
"ask.secret-file": "Prints, copies or changes a credential file; this needs approval each time.",
|
|
4004
4096
|
};
|
|
4005
|
-
/**
|
|
4097
|
+
/** Logout and editor rc files: read by a program the person starts later, like a shell rc file. */
|
|
4098
|
+
function isEditorOrLogoutRc(t) {
|
|
4099
|
+
if (/^~\/\.(bash_logout|zlogout|logout|vimrc|gvimrc|exrc|nanorc|emacs)$/.test(t))
|
|
4100
|
+
return true;
|
|
4101
|
+
return t.startsWith("~/.vim/") || t.startsWith("~/.config/nvim/") || t.startsWith("~/.emacs.d/");
|
|
4102
|
+
}
|
|
4103
|
+
/**
|
|
4104
|
+
* Home locations whose files run later without the person asking: PATH shims (`~/.local/bin`,
|
|
4105
|
+
* `~/bin`, `~/.cargo/bin`),
|
|
4106
|
+
* desktop autostart entries, and the device's own work directory `~/capybara-device` (other
|
|
4107
|
+
* conversations' background task scripts live there). The work directory counts only when the
|
|
4108
|
+
* workspace is not inside it: a free conversation's workspace is a directory of it.
|
|
4109
|
+
*/
|
|
4110
|
+
function isRunLaterHomePath(t, facts) {
|
|
4111
|
+
const under = (dir) => t === dir || t.startsWith(`${dir}/`);
|
|
4112
|
+
if (RUN_LATER_HOME_DIRS.some(under))
|
|
4113
|
+
return true;
|
|
4114
|
+
return (under("~/capybara-device") &&
|
|
4115
|
+
!foldedForms(facts.workspace, facts).some((w) => w.startsWith("~/capybara-device/")));
|
|
4116
|
+
}
|
|
4117
|
+
/** PATH shims and desktop autostart entries in the home (case-folded). */
|
|
4118
|
+
const RUN_LATER_HOME_DIRS = ["~/.local/bin", "~/bin", "~/.cargo/bin", "~/.config/autostart"];
|
|
4119
|
+
/** The grant class of a secret or persistence path (judged on every case-folded home spelling). */
|
|
4006
4120
|
function configClassOf(path, facts) {
|
|
4007
|
-
const
|
|
4008
|
-
if (t === "~/.ssh" || t.startsWith("~/.ssh/"))
|
|
4121
|
+
const forms = foldedForms(path, facts);
|
|
4122
|
+
if (forms.some((t) => t === "~/.ssh" || t.startsWith("~/.ssh/")))
|
|
4009
4123
|
return "ask.ssh";
|
|
4010
4124
|
if (isGitHook(path) ||
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4125
|
+
forms.some((t) => isLaunchForm(t) ||
|
|
4126
|
+
t === "/etc/crontab" ||
|
|
4127
|
+
t.startsWith("/var/spool/cron") ||
|
|
4128
|
+
t.startsWith("/etc/cron.") ||
|
|
4129
|
+
t.startsWith("~/.config/systemd") ||
|
|
4130
|
+
isRunLaterHomePath(t, facts))) {
|
|
4016
4131
|
return "ask.persistence";
|
|
4017
4132
|
}
|
|
4018
4133
|
return isPersistencePath(path, facts) ? "ask.shell-config" : "ask.secret-file";
|
|
@@ -4046,9 +4161,7 @@ function configMatches(ctx) {
|
|
|
4046
4161
|
}
|
|
4047
4162
|
if (inv.program === "ssh-keygen")
|
|
4048
4163
|
add("ask.ssh", command, "Changes ~/.ssh; this needs approval.");
|
|
4049
|
-
if (inv.program === "git" &&
|
|
4050
|
-
inv.args[0] === "config" &&
|
|
4051
|
-
hasArg(inv.args.slice(1), "--global", "--system")) {
|
|
4164
|
+
if (inv.program === "git" && gitConfigChangesUserFile(inv.args)) {
|
|
4052
4165
|
add("ask.shell-config", command, "Changes ~/.gitconfig; this needs approval.");
|
|
4053
4166
|
}
|
|
4054
4167
|
if (inv.program === "security" && inv.args.some((a) => KEYCHAIN_DUMP.test(a))) {
|
|
@@ -4104,19 +4217,23 @@ function linkSources(inv, command, ctx) {
|
|
|
4104
4217
|
return out;
|
|
4105
4218
|
}
|
|
4106
4219
|
/**
|
|
4107
|
-
* What a link would expose (hardening spec R3): a credential, SSH, persistence or device path,
|
|
4108
|
-
* the home directory or `/` itself (a link to them reaches every secret under them) is
|
|
4109
|
-
* `sensitive
|
|
4220
|
+
* What a link would expose (hardening spec R3): a credential, SSH, persistence or device path, and
|
|
4221
|
+
* the home directory or `/` itself (a link to them reaches every secret under them), is
|
|
4222
|
+
* `sensitive` wherever it lies, inside the workspace too (a project at the owner's home makes the
|
|
4223
|
+
* home the workspace: project root spec §4.3); a parent of the workspace is `sensitive` outside
|
|
4224
|
+
* it; anything else outside the workspace and temporary files is `outside`.
|
|
4110
4225
|
*/
|
|
4111
4226
|
function linkClass(path, ctx) {
|
|
4227
|
+
if (isHomeLevelSensitive(path, ctx.facts) || isDevicePath(path, ctx.facts))
|
|
4228
|
+
return "sensitive";
|
|
4229
|
+
// the home directory and `/` themselves reach every secret under them, whatever the workspace
|
|
4230
|
+
const base = globBase(path);
|
|
4231
|
+
if (base === "/" || homeForms(base, ctx.facts).some((t) => t === "~"))
|
|
4232
|
+
return "sensitive";
|
|
4112
4233
|
if (inside(path, ctx.facts.workspace) || tmpRootOf(path))
|
|
4113
4234
|
return null;
|
|
4114
|
-
if (
|
|
4115
|
-
isPersistencePath(path, ctx.facts) ||
|
|
4116
|
-
isDevicePath(path, ctx.facts) ||
|
|
4117
|
-
isDangerousDelete(path, ctx)) {
|
|
4235
|
+
if (isDangerousDelete(path, ctx))
|
|
4118
4236
|
return "sensitive";
|
|
4119
|
-
}
|
|
4120
4237
|
return "outside";
|
|
4121
4238
|
}
|
|
4122
4239
|
const RULES = [
|
|
@@ -4239,7 +4356,7 @@ const RULES = [
|
|
|
4239
4356
|
return false;
|
|
4240
4357
|
if (inv.args[0] === "push" && gitPushKind(inv.args.slice(1)) !== null)
|
|
4241
4358
|
return false;
|
|
4242
|
-
if (
|
|
4359
|
+
if (gitConfigChangesUserFile(inv.args))
|
|
4243
4360
|
return false;
|
|
4244
4361
|
return true;
|
|
4245
4362
|
});
|
|
@@ -5112,9 +5229,10 @@ export function reviewRules(command, facts) {
|
|
|
5112
5229
|
return { outcome: strictest(hits), hits };
|
|
5113
5230
|
}
|
|
5114
5231
|
/**
|
|
5115
|
-
* The same table for a file-tool write:
|
|
5116
|
-
*
|
|
5117
|
-
* outside
|
|
5232
|
+
* The same table for a file-tool write: the device's own files are denied; git hooks and
|
|
5233
|
+
* home-level sensitive paths (shell rc files, SSH, launch agents, credentials) ask wherever they
|
|
5234
|
+
* lie, inside the workspace too; other workspace and tmp writes pass; a `.env*` file outside the
|
|
5235
|
+
* workspace asks; anything else outside asks to write outside.
|
|
5118
5236
|
*/
|
|
5119
5237
|
export function reviewWrite(path, facts) {
|
|
5120
5238
|
const resolved = resolveFacts(facts);
|
|
@@ -5155,6 +5273,11 @@ export function reviewWrite(path, facts) {
|
|
|
5155
5273
|
],
|
|
5156
5274
|
};
|
|
5157
5275
|
}
|
|
5276
|
+
// home-level sensitive paths ask wherever they lie, inside the workspace fact too
|
|
5277
|
+
if (isHomeLevelSensitive(absolute, resolved)) {
|
|
5278
|
+
const id = configClassOf(absolute, resolved);
|
|
5279
|
+
return { outcome: "ask", hits: [{ id, outcome: "ask", reason: CONFIG_REASONS[id] }] };
|
|
5280
|
+
}
|
|
5158
5281
|
if (inside(absolute, resolved.workspace)) {
|
|
5159
5282
|
return {
|
|
5160
5283
|
outcome: "allow",
|
|
@@ -5179,7 +5302,7 @@ export function reviewWrite(path, facts) {
|
|
|
5179
5302
|
],
|
|
5180
5303
|
};
|
|
5181
5304
|
}
|
|
5182
|
-
if (
|
|
5305
|
+
if (isSecretPath(absolute, resolved)) {
|
|
5183
5306
|
const id = configClassOf(absolute, resolved);
|
|
5184
5307
|
return { outcome: "ask", hits: [{ id, outcome: "ask", reason: CONFIG_REASONS[id] }] };
|
|
5185
5308
|
}
|
|
@@ -44,6 +44,20 @@ export interface ReviewFacts {
|
|
|
44
44
|
attended: boolean;
|
|
45
45
|
/** The directory the command runs in; default: the workspace. */
|
|
46
46
|
cwd?: string;
|
|
47
|
+
/**
|
|
48
|
+
* The owner's home directory, which `~` and the home-level sensitive paths (shell rc files,
|
|
49
|
+
* SSH, credentials) are judged against. The pipeline passes it from the machine (or the device's
|
|
50
|
+
* workspace), never from a project root, so a project outside the home keeps every home rule
|
|
51
|
+
* (project root spec §4.3). Absent or null: derived from the workspace's `/home/<u>`,
|
|
52
|
+
* `/Users/<u>` or `/root` prefix.
|
|
53
|
+
*/
|
|
54
|
+
home?: string | null;
|
|
55
|
+
/**
|
|
56
|
+
* The home prefix of the device's own workspace (`homeOf` of it), judged beside `home` and the
|
|
57
|
+
* working root's prefix: a project outside every home (`/opt/app`) with an implausible reported
|
|
58
|
+
* home (`/`) still protects the real home. Absent or null: none.
|
|
59
|
+
*/
|
|
60
|
+
deviceHome?: string | null;
|
|
47
61
|
/**
|
|
48
62
|
* Absolute paths this conversation's own tool calls wrote (`Write` / `Edit`, and the write
|
|
49
63
|
* targets of its earlier `Bash` lines): running one of them with an interpreter is not a
|
|
@@ -41,6 +41,13 @@ export interface SandboxUseContext {
|
|
|
41
41
|
holderConversationId: string;
|
|
42
42
|
/** Passed with every `exec` (audit and attribution). */
|
|
43
43
|
actor: SandboxActor;
|
|
44
|
+
/**
|
|
45
|
+
* A use that tells the model nothing (the run-start read of a bound project): it does not mark
|
|
46
|
+
* the holder as having seen the instance, so the holder's next ordinary use still learns that
|
|
47
|
+
* the instance started, restarted or had its files reset ({@link SandboxUseInfo}); what this use
|
|
48
|
+
* itself caused (a creation, a rebuild) is kept for that next use.
|
|
49
|
+
*/
|
|
50
|
+
silent?: true;
|
|
44
51
|
}
|
|
45
52
|
export type { SandboxProviderEntry } from "./providers.js";
|
|
46
53
|
type Row = Selectable<DeviceInstancesTable>;
|
|
@@ -132,10 +139,13 @@ export declare const isInstance: (row: Pick<Row, "handle" | "created_at">, gone:
|
|
|
132
139
|
* startup config) while an org can be on it: auto mode always is, and a sandbox-mode cloud device
|
|
133
140
|
* keeps its org's cloud network, open by default, so turning auto mode off does not avoid it
|
|
134
141
|
* (auto mode hardening spec K3). Only the kill switch (`sandbox.limits.egress: none`) does.
|
|
142
|
+
* - `sandbox.limits.orgHosts: within` while the startup config does not turn auto mode off: the
|
|
143
|
+
* ceiling limits sandbox mode only, and auto mode (the default of every device) keeps the open
|
|
144
|
+
* network (org egress ceiling spec §D2). The admin console's runtime choice is not seen here.
|
|
135
145
|
* No run duration limit (`runtime.maxRunSeconds` 0, the default) cuts no command, so there is
|
|
136
146
|
* nothing to tell.
|
|
137
147
|
*/
|
|
138
|
-
export declare function sandboxConfigWarnings(cfg: Pick<KernelConfig, "runtime" | "sandbox" | "extensionConfig"
|
|
148
|
+
export declare function sandboxConfigWarnings(cfg: Pick<KernelConfig, "runtime" | "sandbox" | "extensionConfig"> & Partial<Pick<KernelConfig, "devices">>, providerPlugin?: string): {
|
|
139
149
|
level: "warn";
|
|
140
150
|
message: string;
|
|
141
151
|
}[];
|
|
@@ -213,7 +223,7 @@ export declare class SandboxService {
|
|
|
213
223
|
private readonly background;
|
|
214
224
|
constructor(db: KernelDb,
|
|
215
225
|
/** The record of the instance each holder last used (`capk:sandbox-seen:…`). */
|
|
216
|
-
redis: Pick<Redis, "set">, leases: SandboxLeases,
|
|
226
|
+
redis: Pick<Redis, "set" | "getdel">, leases: SandboxLeases,
|
|
217
227
|
/** The providers (read at every call: providers are ready after the extension load). */
|
|
218
228
|
providers: Pick<SandboxProviders, "cloud" | "forName">, config: Pick<KernelConfigService, "get" | "fieldSource">, log: Pick<KernelLogger, "info" | "warn">,
|
|
219
229
|
/** Background tasks lost while their process may live on (killed after a resume). */
|
|
@@ -375,6 +385,14 @@ export declare class SandboxService {
|
|
|
375
385
|
* machine: until a new login, which resets the row). A failed write only logs.
|
|
376
386
|
*/
|
|
377
387
|
private filesGone;
|
|
388
|
+
/**
|
|
389
|
+
* A silent use ({@link SandboxUseContext.silent}) of `holder`: the seen record is left alone, so
|
|
390
|
+
* the holder's next ordinary use compares against the instance it last saw itself (and learns
|
|
391
|
+
* of a restart or a files reset since); a creation or rebuild this use caused is kept
|
|
392
|
+
* (`capk:sandbox-notice:<env>:<holder>`, merged with an earlier one for the same instance, same
|
|
393
|
+
* TTL as the seen record) for {@link seenBy} to tell. Best effort: a Redis error only logs.
|
|
394
|
+
*/
|
|
395
|
+
private deferNotice;
|
|
378
396
|
/**
|
|
379
397
|
* Records that `holder` uses the instance of `e` (`capk:sandbox-seen:<env>:<holder>` =
|
|
380
398
|
* `<created_at>:<fs_resets>`, with a TTL of the inactivity destruction plus a day). When the
|
|
@@ -44,6 +44,26 @@ const EXCLUSIVE_WAIT_MS = 10 * 60_000;
|
|
|
44
44
|
const PENDING_KILL_TIMEOUT_MS = 30_000;
|
|
45
45
|
/** A background task's session id as `echo $!` printed it; anything else is never put in a command. */
|
|
46
46
|
const SID_RE = /^[1-9][0-9]{0,9}$/;
|
|
47
|
+
const noticeKey = (deviceId, holder) => `capk:sandbox-notice:${deviceId}:${holder}`;
|
|
48
|
+
/** A stored {@link DeferredNotice}, or null (none, or not one). */
|
|
49
|
+
function parseDeferred(raw) {
|
|
50
|
+
if (raw === null)
|
|
51
|
+
return null;
|
|
52
|
+
try {
|
|
53
|
+
const v = JSON.parse(raw);
|
|
54
|
+
if (typeof v.seen !== "string")
|
|
55
|
+
return null;
|
|
56
|
+
return {
|
|
57
|
+
seen: v.seen,
|
|
58
|
+
fresh: v.fresh === true,
|
|
59
|
+
restarted: v.restarted === true,
|
|
60
|
+
filesReset: v.filesReset === true,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
47
67
|
/** The signal of one provider call in maintenance: aborted on timeout or when the lease is lost. */
|
|
48
68
|
const opSignal = (lease) => AbortSignal.any([lease.signal, AbortSignal.timeout(SWEEP_OP_TIMEOUT_MS)]);
|
|
49
69
|
/** The provider-side name of a device's file system and instance. */
|
|
@@ -131,6 +151,9 @@ function tagged(impl, tag, actor, before) {
|
|
|
131
151
|
* startup config) while an org can be on it: auto mode always is, and a sandbox-mode cloud device
|
|
132
152
|
* keeps its org's cloud network, open by default, so turning auto mode off does not avoid it
|
|
133
153
|
* (auto mode hardening spec K3). Only the kill switch (`sandbox.limits.egress: none`) does.
|
|
154
|
+
* - `sandbox.limits.orgHosts: within` while the startup config does not turn auto mode off: the
|
|
155
|
+
* ceiling limits sandbox mode only, and auto mode (the default of every device) keeps the open
|
|
156
|
+
* network (org egress ceiling spec §D2). The admin console's runtime choice is not seen here.
|
|
134
157
|
* No run duration limit (`runtime.maxRunSeconds` 0, the default) cuts no command, so there is
|
|
135
158
|
* nothing to tell.
|
|
136
159
|
*/
|
|
@@ -145,6 +168,14 @@ export function sandboxConfigWarnings(cfg, providerPlugin) {
|
|
|
145
168
|
});
|
|
146
169
|
}
|
|
147
170
|
}
|
|
171
|
+
if (cfg.sandbox.limits.orgHosts === "within" &&
|
|
172
|
+
cfg.sandbox.limits.egress !== "none" &&
|
|
173
|
+
cfg.devices?.autoMode !== "off") {
|
|
174
|
+
out.push({
|
|
175
|
+
level: "warn",
|
|
176
|
+
message: "sandbox.limits.orgHosts is within but devices.autoMode is not off: the platform allowlist limits sandbox mode only; devices in auto mode (the default) still reach the open public network. Set devices.autoMode to off (or turn auto mode off in the admin console) for a hard ceiling",
|
|
177
|
+
});
|
|
178
|
+
}
|
|
148
179
|
const run = cfg.runtime.maxRunSeconds;
|
|
149
180
|
const cmd = cfg.sandbox.limits.maxCommandSeconds;
|
|
150
181
|
if (run > 0 && run < cmd) {
|
|
@@ -599,7 +630,8 @@ let SandboxService = class SandboxService {
|
|
|
599
630
|
// decides the shared fast path only (read again before each shared lease is used): the
|
|
600
631
|
// exclusive path reads it again under the lease
|
|
601
632
|
const want = () => this.wantedLimits(ctx, p);
|
|
602
|
-
|
|
633
|
+
const seen = (x) => ctx.silent ? this.deferNotice(env, holder, x) : this.seenBy(env, holder, x);
|
|
634
|
+
let e = await seen(await this.enter(ctx, p, signal, null, want));
|
|
603
635
|
try {
|
|
604
636
|
try {
|
|
605
637
|
return await this.runAs(e, ctx, p, fn, signal);
|
|
@@ -613,7 +645,7 @@ let SandboxService = class SandboxService {
|
|
|
613
645
|
const gone = { handle: e.handle, createdAt: e.createdAt };
|
|
614
646
|
const prev = e;
|
|
615
647
|
await this.leave(env, prev);
|
|
616
|
-
e = await
|
|
648
|
+
e = await seen(await this.enter(ctx, p, signal, gone, want));
|
|
617
649
|
// a reset seen on the first try still has to be told (it covers the restart)
|
|
618
650
|
const info = prev.info.filesReset
|
|
619
651
|
? { fresh: true, restarted: false, filesReset: true }
|
|
@@ -670,6 +702,43 @@ let SandboxService = class SandboxService {
|
|
|
670
702
|
}
|
|
671
703
|
return deviceFilesLost(p.plugin === LOCAL_PROVIDER);
|
|
672
704
|
}
|
|
705
|
+
/**
|
|
706
|
+
* A silent use ({@link SandboxUseContext.silent}) of `holder`: the seen record is left alone, so
|
|
707
|
+
* the holder's next ordinary use compares against the instance it last saw itself (and learns
|
|
708
|
+
* of a restart or a files reset since); a creation or rebuild this use caused is kept
|
|
709
|
+
* (`capk:sandbox-notice:<env>:<holder>`, merged with an earlier one for the same instance, same
|
|
710
|
+
* TTL as the seen record) for {@link seenBy} to tell. Best effort: a Redis error only logs.
|
|
711
|
+
*/
|
|
712
|
+
async deferNotice(deviceId, holder, e) {
|
|
713
|
+
if (!e.info.fresh && !e.info.restarted && e.info.filesReset !== true)
|
|
714
|
+
return e;
|
|
715
|
+
try {
|
|
716
|
+
const ttl = (this.config.get().sandbox.limits.destroyAfterInactiveDays + 1) * 86_400;
|
|
717
|
+
const seen = `${e.createdAt}:${e.fsResets}`;
|
|
718
|
+
const key = noticeKey(deviceId, holder);
|
|
719
|
+
const mine = {
|
|
720
|
+
seen,
|
|
721
|
+
fresh: e.info.fresh,
|
|
722
|
+
restarted: e.info.restarted,
|
|
723
|
+
filesReset: e.info.filesReset === true,
|
|
724
|
+
};
|
|
725
|
+
// swapped in, then merged with an earlier silent use's notice for the same instance
|
|
726
|
+
const prev = parseDeferred(await this.redis.set(key, JSON.stringify(mine), "EX", ttl, "GET"));
|
|
727
|
+
if (prev !== null && prev.seen === seen) {
|
|
728
|
+
const merged = {
|
|
729
|
+
seen,
|
|
730
|
+
fresh: mine.fresh || prev.fresh,
|
|
731
|
+
restarted: mine.restarted || prev.restarted,
|
|
732
|
+
filesReset: mine.filesReset || prev.filesReset,
|
|
733
|
+
};
|
|
734
|
+
await this.redis.set(key, JSON.stringify(merged), "EX", ttl);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
catch (err) {
|
|
738
|
+
this.log.warn("cannot keep the sandbox notice of a silent use", { deviceId, holder, err });
|
|
739
|
+
}
|
|
740
|
+
return e;
|
|
741
|
+
}
|
|
673
742
|
/**
|
|
674
743
|
* Records that `holder` uses the instance of `e` (`capk:sandbox-seen:<env>:<holder>` =
|
|
675
744
|
* `<created_at>:<fs_resets>`, with a TTL of the inactivity destruction plus a day). When the
|
|
@@ -679,10 +748,24 @@ let SandboxService = class SandboxService {
|
|
|
679
748
|
* (sandbox-docker's volumes are named after the device). Best effort: a Redis error only
|
|
680
749
|
* logs.
|
|
681
750
|
*/
|
|
682
|
-
async seenBy(deviceId, holder,
|
|
751
|
+
async seenBy(deviceId, holder, entered) {
|
|
752
|
+
let e = entered;
|
|
683
753
|
try {
|
|
684
754
|
const ttl = (this.config.get().sandbox.limits.destroyAfterInactiveDays + 1) * 86_400;
|
|
685
755
|
const seen = `${e.createdAt}:${e.fsResets}`;
|
|
756
|
+
// what a silent use of this holder caused on this same instance is told now
|
|
757
|
+
const deferred = parseDeferred(await this.redis.getdel(noticeKey(deviceId, holder)));
|
|
758
|
+
if (deferred !== null && deferred.seen === seen) {
|
|
759
|
+
e = {
|
|
760
|
+
...e,
|
|
761
|
+
info: e.info.filesReset === true || deferred.filesReset
|
|
762
|
+
? { fresh: e.info.fresh || deferred.fresh, restarted: false, filesReset: true }
|
|
763
|
+
: {
|
|
764
|
+
fresh: e.info.fresh || deferred.fresh,
|
|
765
|
+
restarted: e.info.restarted || deferred.restarted,
|
|
766
|
+
},
|
|
767
|
+
};
|
|
768
|
+
}
|
|
686
769
|
const prev = await this.redis.set(`capk:sandbox-seen:${deviceId}:${holder}`, seen, "EX", ttl, "GET");
|
|
687
770
|
if (prev !== null && prev !== seen) {
|
|
688
771
|
// `<createdAt>:<fsResets>`: another reset count means the files were reset since; another
|
|
@@ -51,6 +51,8 @@ export interface NetworkGrantContext {
|
|
|
51
51
|
* command may reach in sandbox mode.
|
|
52
52
|
*/
|
|
53
53
|
limits: Pick<SandboxLimits, "network">;
|
|
54
|
+
/** Whether a host is beyond the platform's ceiling (org egress ceiling spec §D2). */
|
|
55
|
+
outsideCeiling?: (host: string) => boolean;
|
|
54
56
|
}
|
|
55
57
|
/**
|
|
56
58
|
* Why `host` cannot be one of a task's network grants (network ask-to-allow spec §8.1), or null
|
|
@@ -80,7 +80,9 @@ export function networkGrantRefusal(host, ctx) {
|
|
|
80
80
|
if (!orgAllows(host, ctx.limits)) {
|
|
81
81
|
return {
|
|
82
82
|
code: "needs_admin",
|
|
83
|
-
message:
|
|
83
|
+
message: ctx.outsideCeiling?.(host) === true
|
|
84
|
+
? `${host} is not in the platform's network allowlist, which limits this organization; only a super admin can add it`
|
|
85
|
+
: `${host} is not in the organization's network allowlist; only an organization admin can add it`,
|
|
84
86
|
};
|
|
85
87
|
}
|
|
86
88
|
return null;
|