pi-landstrip 0.20.13 → 0.20.15
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/README.md +3 -3
- package/dist/index.ts +124 -253
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -47,8 +47,8 @@ Worker boundaries:
|
|
|
47
47
|
|
|
48
48
|
## Agents and tasks
|
|
49
49
|
|
|
50
|
-
Configure `~/.pi/agent/landstrip.json
|
|
51
|
-
|
|
50
|
+
Configure `~/.pi/agent/landstrip.json` or trusted-project `.pi/landstrip.json`.
|
|
51
|
+
Global definitions load first.
|
|
52
52
|
|
|
53
53
|
```json
|
|
54
54
|
{
|
|
@@ -63,7 +63,7 @@ model, prompt, mode, options, and permissions.
|
|
|
63
63
|
Use `/landstrip-sandbox` for sandbox overview/policy (`Overview`, `Policy`, `Help`)
|
|
64
64
|
and `/landstrip-subagents` for subagent/task management (`Tasks`, `Log`, `Subagent`,
|
|
65
65
|
`Primary`, `Settings`, `Help`). Task IDs accept unique prefixes; bare IDs open logs.
|
|
66
|
-
`/landstrip-subagents tasks
|
|
66
|
+
`/landstrip-subagents tasks cancel <id>` terminates a task. `Ctrl+Shift+A` cycles
|
|
67
67
|
primary agents while idle. The `task` tool accepts `background: true`, `include_context: true`,
|
|
68
68
|
and `task_id` to continue a saved task; the `tasks` tool supports `list`, `inspect`,
|
|
69
69
|
`steer`, and `cancel`. Press `S` in `Tasks` or `Enter` in running/queued logs to steer workers.
|
package/dist/index.ts
CHANGED
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
isDenialTrap,
|
|
38
38
|
isFilesystemTrap,
|
|
39
39
|
isPathReadAllowed,
|
|
40
|
+
isPathWriteAllowed,
|
|
40
41
|
isRecord as isRecord3,
|
|
41
42
|
isQueryTrap,
|
|
42
43
|
matchesPathPattern,
|
|
@@ -53,11 +54,10 @@ import {
|
|
|
53
54
|
pathUnderDirectory,
|
|
54
55
|
sessionScopeFor,
|
|
55
56
|
writeLandstripPolicyFile,
|
|
56
|
-
shouldPromptForWrite
|
|
57
|
+
shouldPromptForWrite,
|
|
57
58
|
normalizeBlockedPath,
|
|
58
59
|
extractNativeDeniedPath,
|
|
59
60
|
extractNativeWriteDeniedPath,
|
|
60
|
-
extractDeniedPath,
|
|
61
61
|
extractTrapBlockedPath
|
|
62
62
|
} from "@landstrip/landstrip-api/shared";
|
|
63
63
|
import {
|
|
@@ -245,7 +245,7 @@ import {
|
|
|
245
245
|
writeSync
|
|
246
246
|
} from "node:fs";
|
|
247
247
|
import { homedir as homedir3, tmpdir } from "node:os";
|
|
248
|
-
import { basename as
|
|
248
|
+
import { basename as basename2, dirname as dirname4, isAbsolute as isAbsolute3, join as join7, relative as relative3, resolve as resolve3, sep as sep4 } from "node:path";
|
|
249
249
|
import { fileURLToPath } from "node:url";
|
|
250
250
|
import {
|
|
251
251
|
getAgentDir as getAgentDir4,
|
|
@@ -600,62 +600,42 @@ function expandAgentPromptReferences(config, path) {
|
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
602
|
}
|
|
603
|
-
function parseLandstripConfig(value, path
|
|
604
|
-
const label = kind === "settings" ? "landstrip" : "configuration";
|
|
603
|
+
function parseLandstripConfig(value, path) {
|
|
605
604
|
if (!isRecord2(value))
|
|
606
|
-
throw new Error(`${path}:
|
|
605
|
+
throw new Error(`${path}: configuration must be a JSON object`);
|
|
607
606
|
for (const key of Object.keys(value)) {
|
|
608
607
|
if (!LANDSTRIP_KEYS.includes(key)) {
|
|
609
|
-
throw new Error(`${path}:
|
|
608
|
+
throw new Error(`${path}: configuration has an unknown field ${key}`);
|
|
610
609
|
}
|
|
611
610
|
}
|
|
612
|
-
const field = (name) => kind === "settings" ? `landstrip.${name}` : name;
|
|
613
611
|
const config = {};
|
|
614
612
|
if ("maxSubagents" in value) {
|
|
615
613
|
if (typeof value.maxSubagents !== "number") {
|
|
616
|
-
throw new Error(`${path}:
|
|
614
|
+
throw new Error(`${path}: maxSubagents must be a number`);
|
|
617
615
|
}
|
|
618
616
|
config.maxSubagents = value.maxSubagents;
|
|
619
617
|
}
|
|
620
618
|
if ("agent" in value) {
|
|
621
619
|
if (!isRecord2(value.agent))
|
|
622
|
-
throw new Error(`${path}:
|
|
620
|
+
throw new Error(`${path}: agent must be an object`);
|
|
623
621
|
config.agent = value.agent;
|
|
624
622
|
}
|
|
625
623
|
if ("permission" in value)
|
|
626
624
|
config.permission = value.permission;
|
|
627
625
|
return config;
|
|
628
626
|
}
|
|
629
|
-
function readLandstripConfigSource(cwd, scope, agentDir) {
|
|
630
|
-
const settingsPaths = getPiConfigPaths(cwd, "settings.json", agentDir);
|
|
631
|
-
const dedicatedPaths = getPiConfigPaths(cwd, "landstrip.json", agentDir);
|
|
632
|
-
const settingsPath = scope === "global" ? settingsPaths.globalPath : settingsPaths.projectPath;
|
|
633
|
-
const dedicatedPath = scope === "global" ? dedicatedPaths.globalPath : dedicatedPaths.projectPath;
|
|
634
|
-
const settings = existsSync(settingsPath) ? readJsonObject(settingsPath) : undefined;
|
|
635
|
-
const hasSettingsConfig = settings?.landstrip !== undefined;
|
|
636
|
-
const hasDedicatedConfig = existsSync(dedicatedPath);
|
|
637
|
-
if (hasSettingsConfig && hasDedicatedConfig) {
|
|
638
|
-
throw new Error(`Landstrip configuration is defined in both ${settingsPath} and ${dedicatedPath}`);
|
|
639
|
-
}
|
|
640
|
-
if (hasDedicatedConfig) {
|
|
641
|
-
return {
|
|
642
|
-
path: dedicatedPath,
|
|
643
|
-
kind: "dedicated",
|
|
644
|
-
config: parseLandstripConfig(readJsonObject(dedicatedPath), dedicatedPath, "dedicated")
|
|
645
|
-
};
|
|
646
|
-
}
|
|
647
|
-
if (hasSettingsConfig) {
|
|
648
|
-
return {
|
|
649
|
-
path: settingsPath,
|
|
650
|
-
kind: "settings",
|
|
651
|
-
config: parseLandstripConfig(settings.landstrip, settingsPath, "settings")
|
|
652
|
-
};
|
|
653
|
-
}
|
|
654
|
-
return { path: dedicatedPath, kind: "dedicated", config: {} };
|
|
655
|
-
}
|
|
656
627
|
function getLandstripConfigTarget(cwd, scope, agentDir = getAgentDir()) {
|
|
657
|
-
const
|
|
658
|
-
return { path
|
|
628
|
+
const paths = getPiConfigPaths(cwd, "landstrip.json", agentDir);
|
|
629
|
+
return { path: scope === "global" ? paths.globalPath : paths.projectPath };
|
|
630
|
+
}
|
|
631
|
+
function readLandstripConfigSource(cwd, scope, agentDir) {
|
|
632
|
+
const { path } = getLandstripConfigTarget(cwd, scope, agentDir);
|
|
633
|
+
if (!existsSync(path))
|
|
634
|
+
return { path, config: {} };
|
|
635
|
+
return {
|
|
636
|
+
path,
|
|
637
|
+
config: parseLandstripConfig(readJsonObject(path), path)
|
|
638
|
+
};
|
|
659
639
|
}
|
|
660
640
|
function mergeValue(base, override) {
|
|
661
641
|
if (override === undefined)
|
|
@@ -694,28 +674,19 @@ async function updateLandstripConfigForScope(cwd, scope, agentDir, update) {
|
|
|
694
674
|
const target = getLandstripConfigTarget(cwd, scope, agentDir);
|
|
695
675
|
await withFileMutationQueue(target.path, async () => {
|
|
696
676
|
const source = readLandstripConfigSource(cwd, scope, agentDir);
|
|
697
|
-
if (source.path !== target.path || source.kind !== target.kind) {
|
|
698
|
-
throw new Error(`Landstrip ${scope} configuration source changed while updating it`);
|
|
699
|
-
}
|
|
700
677
|
const landstrip = { ...source.config };
|
|
701
678
|
update(landstrip);
|
|
702
|
-
|
|
703
|
-
if (source.kind === "dedicated" && empty) {
|
|
679
|
+
if (Object.keys(landstrip).length === 0) {
|
|
704
680
|
if (existsSync(source.path))
|
|
705
681
|
unlinkSync(source.path);
|
|
706
682
|
return;
|
|
707
683
|
}
|
|
708
684
|
let content = existsSync(source.path) ? readFileSync2(source.path, "utf8") : `{}
|
|
709
685
|
`;
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
for (const key of LANDSTRIP_KEYS) {
|
|
715
|
-
if (source.config[key] === landstrip[key])
|
|
716
|
-
continue;
|
|
717
|
-
content = applyEdits(content, modify(content, [...root, key], landstrip[key], JSON_FORMAT));
|
|
718
|
-
}
|
|
686
|
+
for (const key of LANDSTRIP_KEYS) {
|
|
687
|
+
if (source.config[key] === landstrip[key])
|
|
688
|
+
continue;
|
|
689
|
+
content = applyEdits(content, modify(content, [key], landstrip[key], JSON_FORMAT));
|
|
719
690
|
}
|
|
720
691
|
mkdirSync(dirname(source.path), { recursive: true });
|
|
721
692
|
writeFileSync(source.path, ensureFinalNewline(content), { mode: 384 });
|
|
@@ -877,23 +848,6 @@ function parseFrontmatter(content) {
|
|
|
877
848
|
throw new Error("frontmatter must be a YAML mapping");
|
|
878
849
|
return { data: { ...parsed }, body: match[2] ?? "" };
|
|
879
850
|
}
|
|
880
|
-
function convertToolsToPermission(tools) {
|
|
881
|
-
if (!isRecord2(tools))
|
|
882
|
-
throw new Error("tools must be a map of booleans");
|
|
883
|
-
const permission = {};
|
|
884
|
-
for (const [tool, enabled] of Object.entries(tools)) {
|
|
885
|
-
if (typeof enabled !== "boolean") {
|
|
886
|
-
throw new Error(`tools.${tool} must be a boolean`);
|
|
887
|
-
}
|
|
888
|
-
const action = enabled ? "allow" : "deny";
|
|
889
|
-
if (tool === "write" || tool === "edit" || tool === "patch") {
|
|
890
|
-
permission.edit = action;
|
|
891
|
-
continue;
|
|
892
|
-
}
|
|
893
|
-
permission[tool] = action;
|
|
894
|
-
}
|
|
895
|
-
return permission;
|
|
896
|
-
}
|
|
897
851
|
function normalizeMarkdownAgentRaw(data, prompt) {
|
|
898
852
|
const known = new Set([
|
|
899
853
|
"name",
|
|
@@ -907,27 +861,18 @@ function normalizeMarkdownAgentRaw(data, prompt) {
|
|
|
907
861
|
"hidden",
|
|
908
862
|
"color",
|
|
909
863
|
"steps",
|
|
910
|
-
"maxSteps",
|
|
911
864
|
"options",
|
|
912
865
|
"permission",
|
|
913
|
-
"disable"
|
|
914
|
-
"tools"
|
|
866
|
+
"disable"
|
|
915
867
|
]);
|
|
916
868
|
const options = isRecord2(data.options) ? { ...data.options } : {};
|
|
917
869
|
for (const [key, value] of Object.entries(data)) {
|
|
918
870
|
if (!known.has(key))
|
|
919
871
|
options[key] = value;
|
|
920
872
|
}
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
permission = convertToolsToPermission(data.tools);
|
|
924
|
-
}
|
|
925
|
-
if (data.permission !== undefined) {
|
|
926
|
-
if (!isRecord2(data.permission))
|
|
927
|
-
throw new Error("permission must be an object");
|
|
928
|
-
permission = { ...permission, ...data.permission };
|
|
873
|
+
if (data.permission !== undefined && !isRecord2(data.permission)) {
|
|
874
|
+
throw new Error("permission must be an object");
|
|
929
875
|
}
|
|
930
|
-
const steps = data.steps ?? data.maxSteps;
|
|
931
876
|
const raw = {
|
|
932
877
|
description: data.description,
|
|
933
878
|
prompt,
|
|
@@ -937,13 +882,13 @@ function normalizeMarkdownAgentRaw(data, prompt) {
|
|
|
937
882
|
hidden: data.hidden,
|
|
938
883
|
disable: data.disable,
|
|
939
884
|
color: data.color,
|
|
885
|
+
steps: data.steps,
|
|
940
886
|
temperature: data.temperature,
|
|
941
887
|
top_p: data.top_p
|
|
942
888
|
};
|
|
943
|
-
if (
|
|
944
|
-
raw.
|
|
945
|
-
|
|
946
|
-
raw.permission = permission;
|
|
889
|
+
if (isRecord2(data.permission) && Object.keys(data.permission).length > 0) {
|
|
890
|
+
raw.permission = { ...data.permission };
|
|
891
|
+
}
|
|
947
892
|
if (Object.keys(options).length > 0)
|
|
948
893
|
raw.options = options;
|
|
949
894
|
for (const key of Object.keys(raw)) {
|
|
@@ -1200,7 +1145,7 @@ function agentSupportsMode(agent, mode) {
|
|
|
1200
1145
|
|
|
1201
1146
|
// agent-files.ts
|
|
1202
1147
|
import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync4, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
1203
|
-
import {
|
|
1148
|
+
import { dirname as dirname2, join as join5, relative as relative2, sep as sep2 } from "node:path";
|
|
1204
1149
|
import { getAgentDir as getAgentDir3, withFileMutationQueue as withFileMutationQueue2 } from "@earendil-works/pi-coding-agent";
|
|
1205
1150
|
import {
|
|
1206
1151
|
applyEdits as applyEdits2,
|
|
@@ -1232,16 +1177,13 @@ function valueAtPath(root, path) {
|
|
|
1232
1177
|
}
|
|
1233
1178
|
return value;
|
|
1234
1179
|
}
|
|
1235
|
-
function agentJsonPath(
|
|
1236
|
-
return
|
|
1180
|
+
function agentJsonPath(name) {
|
|
1181
|
+
return ["agent", name];
|
|
1237
1182
|
}
|
|
1238
|
-
function parseEditorSnippet(content, name
|
|
1183
|
+
function parseEditorSnippet(content, name) {
|
|
1239
1184
|
const root = parseJsonDocument(content, "Edited agent");
|
|
1240
|
-
const
|
|
1241
|
-
|
|
1242
|
-
const container = valueAtPath(root, [...parentPath, "agent"]);
|
|
1243
|
-
const expectedRootKey = kind === "settings" ? "landstrip" : "agent";
|
|
1244
|
-
if (Object.keys(root).length !== 1 || root[expectedRootKey] === undefined || !isRecord2(parent) || Object.keys(parent).length !== 1 || parent.agent === undefined || !isRecord2(container) || Object.keys(container).length !== 1 || !isRecord2(container[name])) {
|
|
1185
|
+
const container = root.agent;
|
|
1186
|
+
if (Object.keys(root).length !== 1 || !isRecord2(container) || Object.keys(container).length !== 1 || !isRecord2(container[name])) {
|
|
1245
1187
|
throw new Error(`Edited JSON must contain only agent ${name}`);
|
|
1246
1188
|
}
|
|
1247
1189
|
return container[name];
|
|
@@ -1251,9 +1193,8 @@ function ensureFinalNewline2(content) {
|
|
|
1251
1193
|
`) ? content : `${content}
|
|
1252
1194
|
`;
|
|
1253
1195
|
}
|
|
1254
|
-
async function writeJsonNode(path, nodePath, value
|
|
1196
|
+
async function writeJsonNode(path, nodePath, value) {
|
|
1255
1197
|
await withFileMutationQueue2(path, async () => {
|
|
1256
|
-
validate?.();
|
|
1257
1198
|
const content = existsSync3(path) ? readFileSync4(path, "utf8") : `{}
|
|
1258
1199
|
`;
|
|
1259
1200
|
parseJsonDocument(content, path);
|
|
@@ -1262,12 +1203,11 @@ async function writeJsonNode(path, nodePath, value, validate) {
|
|
|
1262
1203
|
writeFileSync2(path, ensureFinalNewline2(edited), { mode: 384 });
|
|
1263
1204
|
});
|
|
1264
1205
|
}
|
|
1265
|
-
async function deleteJsonNode(path, nodePath, containerPaths,
|
|
1206
|
+
async function deleteJsonNode(path, nodePath, containerPaths, removeEmptyFile = false) {
|
|
1266
1207
|
if (!existsSync3(path))
|
|
1267
1208
|
return false;
|
|
1268
1209
|
let deleted = false;
|
|
1269
1210
|
await withFileMutationQueue2(path, async () => {
|
|
1270
|
-
validate?.();
|
|
1271
1211
|
let content = readFileSync4(path, "utf8");
|
|
1272
1212
|
const root = parseJsonDocument(content, path);
|
|
1273
1213
|
if (valueAtPath(root, nodePath) === undefined)
|
|
@@ -1290,11 +1230,11 @@ async function deleteJsonNode(path, nodePath, containerPaths, validate, removeEm
|
|
|
1290
1230
|
});
|
|
1291
1231
|
return deleted;
|
|
1292
1232
|
}
|
|
1293
|
-
function readAgentNode(path,
|
|
1233
|
+
function readAgentNode(path, name) {
|
|
1294
1234
|
if (!existsSync3(path))
|
|
1295
1235
|
return;
|
|
1296
1236
|
const root = parseJsonDocument(readFileSync4(path, "utf8"), path);
|
|
1297
|
-
const value = valueAtPath(root, agentJsonPath(
|
|
1237
|
+
const value = valueAtPath(root, agentJsonPath(name));
|
|
1298
1238
|
return isRecord2(value) ? { ...value } : undefined;
|
|
1299
1239
|
}
|
|
1300
1240
|
function permissionConfig(agent) {
|
|
@@ -1346,16 +1286,10 @@ function projectMarkdownPath(cwd, agentDir, agent) {
|
|
|
1346
1286
|
}
|
|
1347
1287
|
throw new Error(`Agent ${agent.name} has no Markdown source`);
|
|
1348
1288
|
}
|
|
1349
|
-
function assertProjectConfigTarget(cwd, agentDir, target) {
|
|
1350
|
-
const current = getLandstripConfigTarget(cwd, "project", agentDir);
|
|
1351
|
-
if (current.path !== target.path || current.kind !== target.kind) {
|
|
1352
|
-
throw new Error("Landstrip project configuration source changed while updating it");
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
1289
|
function canDeleteProjectAgent(cwd, agent, agentDir = getAgentDir3()) {
|
|
1356
1290
|
try {
|
|
1357
1291
|
const target = getLandstripConfigTarget(cwd, "project", agentDir);
|
|
1358
|
-
if (readAgentNode(target.path,
|
|
1292
|
+
if (readAgentNode(target.path, agent.name) !== undefined)
|
|
1359
1293
|
return true;
|
|
1360
1294
|
} catch {
|
|
1361
1295
|
return false;
|
|
@@ -1365,8 +1299,7 @@ function canDeleteProjectAgent(cwd, agent, agentDir = getAgentDir3()) {
|
|
|
1365
1299
|
}
|
|
1366
1300
|
async function deleteProjectAgent(cwd, agent, agentDir = getAgentDir3()) {
|
|
1367
1301
|
const target = getLandstripConfigTarget(cwd, "project", agentDir);
|
|
1368
|
-
const
|
|
1369
|
-
const deletedOverride = await deleteJsonNode(target.path, agentJsonPath(target.kind, agent.name), containers, () => assertProjectConfigTarget(cwd, agentDir, target), target.kind === "dedicated");
|
|
1302
|
+
const deletedOverride = await deleteJsonNode(target.path, agentJsonPath(agent.name), [["agent"]], true);
|
|
1370
1303
|
const origin = agent.origin;
|
|
1371
1304
|
if (origin?.source !== "local" || !origin.path || origin.kind !== "pi-markdown") {
|
|
1372
1305
|
return deletedOverride;
|
|
@@ -1393,24 +1326,23 @@ function prepareProjectAgentEditor(cwd, agent, agentDir = getAgentDir3()) {
|
|
|
1393
1326
|
};
|
|
1394
1327
|
}
|
|
1395
1328
|
const sourcePath = origin?.path;
|
|
1396
|
-
const sourceRaw = origin?.kind === "config" && sourcePath ? readAgentNode(sourcePath,
|
|
1329
|
+
const sourceRaw = origin?.kind === "config" && sourcePath ? readAgentNode(sourcePath, agent.name) : undefined;
|
|
1397
1330
|
const raw = relocateGlobalPrompt(sourceRaw ?? (agent.raw ? { ...agent.raw } : normalizedAgentRaw(agent)), agent);
|
|
1398
1331
|
const target = getLandstripConfigTarget(cwd, "project", agentDir);
|
|
1399
1332
|
return {
|
|
1400
1333
|
title: `Edit @${agent.name}`,
|
|
1401
|
-
content: `${JSON.stringify(
|
|
1334
|
+
content: `${JSON.stringify({ agent: { [agent.name]: raw } }, null, 2)}
|
|
1402
1335
|
`,
|
|
1403
1336
|
async save(content) {
|
|
1404
|
-
const edited = parseEditorSnippet(content, agent.name
|
|
1337
|
+
const edited = parseEditorSnippet(content, agent.name);
|
|
1405
1338
|
validateAgentRaw(agent.name, edited);
|
|
1406
|
-
await writeJsonNode(target.path, agentJsonPath(
|
|
1339
|
+
await writeJsonNode(target.path, agentJsonPath(agent.name), edited);
|
|
1407
1340
|
}
|
|
1408
1341
|
};
|
|
1409
1342
|
}
|
|
1410
1343
|
|
|
1411
1344
|
// commands.ts
|
|
1412
1345
|
import { fuzzyFilter } from "@earendil-works/pi-tui";
|
|
1413
|
-
var DEFAULT_SUBCOMMAND = "status";
|
|
1414
1346
|
function parseArgv(args) {
|
|
1415
1347
|
const raw = args.trim();
|
|
1416
1348
|
const [name = "", ...words] = raw ? raw.split(/\s+/) : [];
|
|
@@ -1508,16 +1440,6 @@ var policySubcommand = {
|
|
|
1508
1440
|
].join(" · "), "info");
|
|
1509
1441
|
}
|
|
1510
1442
|
};
|
|
1511
|
-
var sandboxSubcommand = {
|
|
1512
|
-
name: "sandbox",
|
|
1513
|
-
summary: "Inspect or toggle sandbox OS isolation",
|
|
1514
|
-
pane: (argv, { ctx, integration }) => !argv.rest && integration.sandboxCallbacks?.overview?.(ctx.cwd, isProjectTrusted(ctx)) ? "overview" : undefined,
|
|
1515
|
-
complete: () => [
|
|
1516
|
-
{ value: "sandbox on", label: "on", description: "Enable OS sandbox isolation" },
|
|
1517
|
-
{ value: "sandbox off", label: "off", description: "Disable OS sandbox isolation" }
|
|
1518
|
-
],
|
|
1519
|
-
run: async (argv, deps) => runSandboxToggle(argv.rest, deps)
|
|
1520
|
-
};
|
|
1521
1443
|
var settingsSubcommand = {
|
|
1522
1444
|
name: "settings",
|
|
1523
1445
|
summary: "Manage subagent concurrency settings",
|
|
@@ -1571,7 +1493,7 @@ var tasksSubcommand = {
|
|
|
1571
1493
|
summary: "Inspect and manage running task sessions",
|
|
1572
1494
|
pane: (argv) => {
|
|
1573
1495
|
const first = argv.words[0]?.toLowerCase() ?? "";
|
|
1574
|
-
if (["cancel", "delete"
|
|
1496
|
+
if (["cancel", "delete"].includes(first))
|
|
1575
1497
|
return;
|
|
1576
1498
|
if (first === "inspect" && argv.words[1])
|
|
1577
1499
|
return argv.words[1];
|
|
@@ -1582,8 +1504,8 @@ var tasksSubcommand = {
|
|
|
1582
1504
|
complete: (argv, { runtime }) => {
|
|
1583
1505
|
const tasks = runtime?.getTasks() ?? [];
|
|
1584
1506
|
const action = argv.words[0]?.toLowerCase();
|
|
1585
|
-
if (action === "cancel"
|
|
1586
|
-
return taskItems(tasks,
|
|
1507
|
+
if (action === "cancel")
|
|
1508
|
+
return taskItems(tasks, "tasks cancel ");
|
|
1587
1509
|
if (action === "delete")
|
|
1588
1510
|
return taskItems(tasks, "tasks delete ");
|
|
1589
1511
|
if (action === "inspect")
|
|
@@ -1599,14 +1521,14 @@ var tasksSubcommand = {
|
|
|
1599
1521
|
const [rawAction = "", rawTaskId = ""] = argv.words;
|
|
1600
1522
|
let action = rawAction.toLowerCase();
|
|
1601
1523
|
let taskId = rawTaskId;
|
|
1602
|
-
if (!["cancel", "delete", "
|
|
1524
|
+
if (!["cancel", "delete", "inspect", "list"].includes(action) && action) {
|
|
1603
1525
|
const matched = matchingTasksById(runtime.getTasks(), action);
|
|
1604
1526
|
if (matched.length > 0) {
|
|
1605
1527
|
action = "inspect";
|
|
1606
1528
|
taskId = matched[0].id;
|
|
1607
1529
|
}
|
|
1608
1530
|
}
|
|
1609
|
-
if (action === "cancel"
|
|
1531
|
+
if (action === "cancel") {
|
|
1610
1532
|
if (!taskId) {
|
|
1611
1533
|
ctx.ui.notify("Task ID required to cancel a task", "error");
|
|
1612
1534
|
return;
|
|
@@ -1661,24 +1583,6 @@ var logsSubcommand = {
|
|
|
1661
1583
|
ctx.ui.notify("Task logs are available in interactive TUI mode", "info");
|
|
1662
1584
|
}
|
|
1663
1585
|
};
|
|
1664
|
-
var SUBCOMMANDS = [
|
|
1665
|
-
statusSubcommand,
|
|
1666
|
-
sandboxSubcommand,
|
|
1667
|
-
policySubcommand,
|
|
1668
|
-
settingsSubcommand,
|
|
1669
|
-
agentsSubcommand,
|
|
1670
|
-
subagentsSubcommand,
|
|
1671
|
-
tasksSubcommand,
|
|
1672
|
-
logsSubcommand,
|
|
1673
|
-
{
|
|
1674
|
-
name: "help",
|
|
1675
|
-
summary: "Show Landstrip commands and shortcuts help",
|
|
1676
|
-
pane: () => "help",
|
|
1677
|
-
run: (_argv, { ctx }) => {
|
|
1678
|
-
ctx.ui.notify(`Commands: /landstrip [${SUBCOMMANDS.map((command) => command.name).join("|")}]`, "info");
|
|
1679
|
-
}
|
|
1680
|
-
}
|
|
1681
|
-
];
|
|
1682
1586
|
var SANDBOX_SUBCOMMANDS = [
|
|
1683
1587
|
statusSubcommand,
|
|
1684
1588
|
policySubcommand,
|
|
@@ -1695,7 +1599,7 @@ var SANDBOX_SUBCOMMANDS = [
|
|
|
1695
1599
|
{
|
|
1696
1600
|
name: "help",
|
|
1697
1601
|
summary: "Show Landstrip sandbox commands and shortcuts",
|
|
1698
|
-
pane: () => "
|
|
1602
|
+
pane: () => "help",
|
|
1699
1603
|
run: (_argv, { ctx }) => {
|
|
1700
1604
|
ctx.ui.notify(`Commands: /landstrip-sandbox [${SANDBOX_SUBCOMMANDS.map((command) => command.name).join("|")}]`, "info");
|
|
1701
1605
|
}
|
|
@@ -1710,7 +1614,7 @@ var SUBAGENTS_SUBCOMMANDS = [
|
|
|
1710
1614
|
{
|
|
1711
1615
|
name: "help",
|
|
1712
1616
|
summary: "Show Landstrip subagents commands and shortcuts",
|
|
1713
|
-
pane: () => "
|
|
1617
|
+
pane: () => "help",
|
|
1714
1618
|
run: (_argv, { ctx }) => {
|
|
1715
1619
|
ctx.ui.notify(`Commands: /landstrip-subagents [${SUBAGENTS_SUBCOMMANDS.map((command) => command.name).join("|")}]`, "info");
|
|
1716
1620
|
}
|
|
@@ -1737,9 +1641,6 @@ function getCompletionsForTable(commands, includeRootTasks, argumentPrefix, runt
|
|
|
1737
1641
|
const items = command?.complete?.(argv, deps) ?? [];
|
|
1738
1642
|
return fuzzyFilter(items, argv.trailing ? "" : argv.words.at(-1) ?? "", itemText);
|
|
1739
1643
|
}
|
|
1740
|
-
function getLandstripArgumentCompletions(argumentPrefix, runtime, contextProvider) {
|
|
1741
|
-
return getCompletionsForTable(SUBCOMMANDS, true, argumentPrefix, runtime, contextProvider);
|
|
1742
|
-
}
|
|
1743
1644
|
function getLandstripSandboxArgumentCompletions(argumentPrefix, runtime, contextProvider) {
|
|
1744
1645
|
return getCompletionsForTable(SANDBOX_SUBCOMMANDS, false, argumentPrefix, runtime, contextProvider);
|
|
1745
1646
|
}
|
|
@@ -1767,9 +1668,6 @@ async function dispatchCommandTable(commands, defaultName, commandLabel, scope,
|
|
|
1767
1668
|
}
|
|
1768
1669
|
await command.run(argv, deps);
|
|
1769
1670
|
}
|
|
1770
|
-
async function handleLandstripCommand(args, ctx, runtime, integration) {
|
|
1771
|
-
await dispatchCommandTable(SUBCOMMANDS, DEFAULT_SUBCOMMAND, "landstrip", undefined, args, ctx, runtime, integration);
|
|
1772
|
-
}
|
|
1773
1671
|
async function handleLandstripSandboxCommand(args, ctx, runtime, integration) {
|
|
1774
1672
|
await dispatchCommandTable(SANDBOX_SUBCOMMANDS, "status", "landstrip-sandbox", "sandbox", args, ctx, runtime, integration);
|
|
1775
1673
|
}
|
|
@@ -1777,11 +1675,6 @@ async function handleLandstripSubagentsCommand(args, ctx, runtime, integration)
|
|
|
1777
1675
|
await dispatchCommandTable(SUBAGENTS_SUBCOMMANDS, "tasks", "landstrip-subagents", "subagents", args, ctx, runtime, integration);
|
|
1778
1676
|
}
|
|
1779
1677
|
function registerLandstripCommands(pi, runtime, integration) {
|
|
1780
|
-
pi.registerCommand("landstrip", {
|
|
1781
|
-
description: "Manage Landstrip sandbox, agents, tasks, and runtime settings",
|
|
1782
|
-
getArgumentCompletions: (prefix) => getLandstripArgumentCompletions(prefix, runtime, () => integration.getExtensionContext()),
|
|
1783
|
-
handler: async (args, ctx) => handleLandstripCommand(args, ctx, runtime, integration)
|
|
1784
|
-
});
|
|
1785
1678
|
pi.registerCommand("landstrip-sandbox", {
|
|
1786
1679
|
description: "Inspect and configure Landstrip OS sandbox status and policy",
|
|
1787
1680
|
getArgumentCompletions: (prefix) => getLandstripSandboxArgumentCompletions(prefix, runtime, () => integration.getExtensionContext()),
|
|
@@ -2447,7 +2340,7 @@ function workerEnvironment(env) {
|
|
|
2447
2340
|
import { existsSync as existsSync4, readFileSync as readFileSync5, realpathSync, statSync as statSync2 } from "node:fs";
|
|
2448
2341
|
import { createRequire } from "node:module";
|
|
2449
2342
|
import { homedir as homedir2 } from "node:os";
|
|
2450
|
-
import { basename
|
|
2343
|
+
import { basename, dirname as dirname3, isAbsolute as isAbsolute2, join as join6, resolve as resolve2, sep as sep3 } from "node:path";
|
|
2451
2344
|
import {
|
|
2452
2345
|
DefaultPackageManager,
|
|
2453
2346
|
loadProjectContextFiles,
|
|
@@ -2470,7 +2363,7 @@ async function collectWorkerResourceReadPaths({
|
|
|
2470
2363
|
const resources = await new DefaultPackageManager({ cwd, agentDir, settingsManager }).resolve(async () => "skip");
|
|
2471
2364
|
const paths = new Set;
|
|
2472
2365
|
const broadRoots = [agentDir, resolve2(homedir2())].flatMap((path) => existsSync4(path) ? [path, realpathSync(path)] : [path]);
|
|
2473
|
-
const isBroadRoot = (path) => dirname3(path) === path ||
|
|
2366
|
+
const isBroadRoot = (path) => dirname3(path) === path || basename(path) === "node_modules" || broadRoots.some((root) => root === path || root.startsWith(`${path}${sep3}`));
|
|
2474
2367
|
const addPath = (path) => {
|
|
2475
2368
|
if (!existsSync4(path))
|
|
2476
2369
|
return;
|
|
@@ -2658,22 +2551,9 @@ function resolvePiPackage() {
|
|
|
2658
2551
|
} catch {}
|
|
2659
2552
|
}
|
|
2660
2553
|
try {
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
} catch {}
|
|
2665
|
-
let dir = packageDir;
|
|
2666
|
-
for (;; ) {
|
|
2667
|
-
const pkgPath = join7(dir, "node_modules", "@earendil-works", "pi-coding-agent", "package.json");
|
|
2668
|
-
if (existsSync5(pkgPath)) {
|
|
2669
|
-
const pkg = readPiPackage(pkgPath);
|
|
2670
|
-
if (pkg)
|
|
2671
|
-
return pkg;
|
|
2672
|
-
}
|
|
2673
|
-
const parent = dirname4(dir);
|
|
2674
|
-
if (parent === dir)
|
|
2675
|
-
return;
|
|
2676
|
-
dir = parent;
|
|
2554
|
+
return findPiPackage(fileURLToPath(import.meta.resolve("@earendil-works/pi-coding-agent")));
|
|
2555
|
+
} catch {
|
|
2556
|
+
return;
|
|
2677
2557
|
}
|
|
2678
2558
|
}
|
|
2679
2559
|
function readPiPackage(pkgPath) {
|
|
@@ -3414,7 +3294,7 @@ function canonicalPermissionPath(path, seen = new Set) {
|
|
|
3414
3294
|
const parent = dirname4(existing);
|
|
3415
3295
|
if (parent === existing)
|
|
3416
3296
|
return path;
|
|
3417
|
-
missing.unshift(
|
|
3297
|
+
missing.unshift(basename2(existing));
|
|
3418
3298
|
existing = parent;
|
|
3419
3299
|
}
|
|
3420
3300
|
}
|
|
@@ -3632,7 +3512,7 @@ class SubagentRuntime {
|
|
|
3632
3512
|
});
|
|
3633
3513
|
this.pi.registerShortcut("ctrl+shift+t", {
|
|
3634
3514
|
description: "Open Landstrip task sessions dashboard",
|
|
3635
|
-
handler: async (ctx) => this.openLandstrip("tasks", ctx)
|
|
3515
|
+
handler: async (ctx) => this.openLandstrip("tasks", ctx, "subagents")
|
|
3636
3516
|
});
|
|
3637
3517
|
this.pi.on("session_start", async (_event, ctx) => {
|
|
3638
3518
|
this.recentCompletions.clear();
|
|
@@ -3749,22 +3629,14 @@ ${this.primaryAgent.prompt}` };
|
|
|
3749
3629
|
if (nextTools.join("\x00") !== activeTools.join("\x00"))
|
|
3750
3630
|
this.pi.setActiveTools(nextTools);
|
|
3751
3631
|
}
|
|
3752
|
-
async openLandstrip(args, ctx,
|
|
3632
|
+
async openLandstrip(args, ctx, viewScope) {
|
|
3753
3633
|
if (ctx.mode !== "tui") {
|
|
3754
3634
|
ctx.ui.notify("Agent management is available in TUI mode", "warning");
|
|
3755
3635
|
return;
|
|
3756
3636
|
}
|
|
3757
3637
|
const projectTrusted = isProjectTrusted(ctx);
|
|
3758
3638
|
let tasks = [...this.tasks.values()];
|
|
3759
|
-
|
|
3760
|
-
if (requested === "sandbox:help") {
|
|
3761
|
-
scope = "sandbox";
|
|
3762
|
-
requested = "help";
|
|
3763
|
-
} else if (requested === "subagents:help") {
|
|
3764
|
-
scope = "subagents";
|
|
3765
|
-
requested = "help";
|
|
3766
|
-
}
|
|
3767
|
-
const viewScope = scope ?? (!requested || requested === "overview" || requested === "sandbox" || requested === "status" || requested === "policy" ? "sandbox" : "subagents");
|
|
3639
|
+
const requested = args.trim();
|
|
3768
3640
|
let catalog = this.getAgentCatalog(ctx);
|
|
3769
3641
|
for (const diagnostic of catalog.diagnostics)
|
|
3770
3642
|
ctx.ui.notify(diagnostic, "warning");
|
|
@@ -3804,7 +3676,7 @@ ${this.primaryAgent.prompt}` };
|
|
|
3804
3676
|
tab = "primary";
|
|
3805
3677
|
} else if (requested === "settings") {
|
|
3806
3678
|
tab = "settings";
|
|
3807
|
-
} else if (requested === "overview" || requested === "
|
|
3679
|
+
} else if (requested === "overview" || requested === "status") {
|
|
3808
3680
|
tab = "overview";
|
|
3809
3681
|
} else if (requested === "policy") {
|
|
3810
3682
|
tab = "policy";
|
|
@@ -6431,9 +6303,6 @@ async function addConfigValue(configPath, value, readValues, writeValues) {
|
|
|
6431
6303
|
function mergeAllowances(base, session, execution) {
|
|
6432
6304
|
return [...base, ...session, ...execution ?? []];
|
|
6433
6305
|
}
|
|
6434
|
-
function shouldPromptForWrite(path, allowWrite, cwd) {
|
|
6435
|
-
return sharedShouldPromptForWrite(path, allowWrite, cwd);
|
|
6436
|
-
}
|
|
6437
6306
|
function matchesPattern(filePath, patterns, cwd, explicitDenyGlobRoots) {
|
|
6438
6307
|
if (!explicitDenyGlobRoots) {
|
|
6439
6308
|
return matchesPathPattern(filePath, patterns, cwd);
|
|
@@ -6604,6 +6473,10 @@ function promptReadBlock(ctx, filePath, reason, signal, label) {
|
|
|
6604
6473
|
const title = reason ? `Read blocked: "${filePath}" is in denyRead (${reason})` : `Read blocked: "${filePath}" is not in allowRead`;
|
|
6605
6474
|
return showPermissionPrompt(ctx, title, PERMISSION_OPTIONS, signal, label);
|
|
6606
6475
|
}
|
|
6476
|
+
function promptWriteBlock(ctx, filePath, reason, signal, label) {
|
|
6477
|
+
const title = reason ? `Write blocked: "${filePath}" is in denyWrite (${reason})` : `Write blocked: "${filePath}" is not in allowWrite`;
|
|
6478
|
+
return showPermissionPrompt(ctx, title, PERMISSION_OPTIONS, signal, label);
|
|
6479
|
+
}
|
|
6607
6480
|
function writeEnvFile(env, proxyPort, proxyToken) {
|
|
6608
6481
|
const lines = [];
|
|
6609
6482
|
for (const [key, value] of Object.entries(env)) {
|
|
@@ -6615,7 +6488,7 @@ function writeEnvFile(env, proxyPort, proxyToken) {
|
|
|
6615
6488
|
lines.push(`export ${key}='${escaped}'`);
|
|
6616
6489
|
}
|
|
6617
6490
|
if (proxyPort !== null) {
|
|
6618
|
-
const proxyVars = createProxyEnvironment(proxyPort, proxyToken);
|
|
6491
|
+
const proxyVars = createProxyEnvironment(proxyPort, { token: proxyToken });
|
|
6619
6492
|
for (const [name, value] of Object.entries(proxyVars)) {
|
|
6620
6493
|
lines.push(`export ${name}='${value}'`);
|
|
6621
6494
|
}
|
|
@@ -6653,7 +6526,7 @@ function createPosixShellProvider() {
|
|
|
6653
6526
|
}
|
|
6654
6527
|
function shellEnvironment(env, cwd, proxyPort, proxyToken) {
|
|
6655
6528
|
const result = { ...process.env, ...env, PWD: resolve4(cwd) };
|
|
6656
|
-
return createProxyEnvironment(proxyPort, proxyToken, result);
|
|
6529
|
+
return createProxyEnvironment(proxyPort, { token: proxyToken, baseEnv: result });
|
|
6657
6530
|
}
|
|
6658
6531
|
var WINDOWS_LAUNCHER_ENVIRONMENT = [
|
|
6659
6532
|
"ProgramData",
|
|
@@ -6918,7 +6791,10 @@ function createLandstripIntegrationWithPrompts(options, permissionPrompts) {
|
|
|
6918
6791
|
}
|
|
6919
6792
|
async function applyWriteChoice(ctx, choice, filePath, cwd, allowances) {
|
|
6920
6793
|
const { globalPath, projectPath } = getPiConfigPaths(cwd, "sandbox.json");
|
|
6921
|
-
|
|
6794
|
+
let scope = sessionScopeFor(filePath, cwd);
|
|
6795
|
+
if (!isPathWriteAllowed(filePath, [scope], loadConfig(cwd).filesystem.denyWrite, cwd)) {
|
|
6796
|
+
scope = filePath;
|
|
6797
|
+
}
|
|
6922
6798
|
const configPath = choice === "project" ? projectPath : choice === "global" ? globalPath : undefined;
|
|
6923
6799
|
if (configPath) {
|
|
6924
6800
|
await addConfigValue(configPath, scope, (config) => config.filesystem?.allowWrite ?? [], (config, allowWrite) => {
|
|
@@ -6941,14 +6817,14 @@ function createLandstripIntegrationWithPrompts(options, permissionPrompts) {
|
|
|
6941
6817
|
return { allowed: true, prompted: false };
|
|
6942
6818
|
const blockedAccesses = (config) => {
|
|
6943
6819
|
const enforceReads = enforcesShellReadPolicy(config.shell.readAccess);
|
|
6944
|
-
return normalized.filter((access) => access.operation === "read" ? enforceReads && !readAllowed(access.path, getEffectiveAllowRead(config, ctx.cwd), getEffectiveDenyRead(config, ctx.cwd), ctx.cwd) : shouldPromptForWrite(access.path, getEffectiveAllowWrite(config), ctx.cwd));
|
|
6820
|
+
return normalized.filter((access) => access.operation === "read" ? enforceReads && !readAllowed(access.path, getEffectiveAllowRead(config, ctx.cwd), getEffectiveDenyRead(config, ctx.cwd), ctx.cwd) : shouldPromptForWrite(access.path, getEffectiveAllowWrite(config), config.filesystem.denyWrite, ctx.cwd));
|
|
6945
6821
|
};
|
|
6946
6822
|
const current = () => {
|
|
6947
6823
|
const config = loadConfig(ctx.cwd);
|
|
6948
6824
|
if (!config.enabled)
|
|
6949
6825
|
return { allowed: true, prompted: false };
|
|
6950
6826
|
for (const access of normalized) {
|
|
6951
|
-
const denied = access.operation === "read" ? matchesPattern(access.path, config.filesystem.denyReadAlways, ctx.cwd) : matchesWriteDenyPattern(access.path,
|
|
6827
|
+
const denied = access.operation === "read" ? matchesPattern(access.path, config.filesystem.denyReadAlways, ctx.cwd) : matchesWriteDenyPattern(access.path, config.filesystem.denyWriteAlways, ctx.cwd, getEffectiveAllowWrite(config));
|
|
6952
6828
|
if (denied) {
|
|
6953
6829
|
return {
|
|
6954
6830
|
allowed: false,
|
|
@@ -6990,10 +6866,9 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
6990
6866
|
async function ensureDomainAllowed(ctx, domain, cwd, allowances, signal) {
|
|
6991
6867
|
const current = () => {
|
|
6992
6868
|
const config = loadConfig(cwd);
|
|
6993
|
-
const decision = evaluateDomainAccess(domain, config.network,
|
|
6994
|
-
...sessionAllowedDomains,
|
|
6995
|
-
|
|
6996
|
-
]);
|
|
6869
|
+
const decision = evaluateDomainAccess(domain, config.network, {
|
|
6870
|
+
allowedDomainsOverrides: [...sessionAllowedDomains, ...allowances?.domains ?? []]
|
|
6871
|
+
});
|
|
6997
6872
|
if (decision === "deny")
|
|
6998
6873
|
return false;
|
|
6999
6874
|
if (decision === "allow")
|
|
@@ -7103,10 +6978,10 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
7103
6978
|
...[...allowances.explicitDenyRead.globRoots.values()].flat()
|
|
7104
6979
|
]), cwd, { requireAllowMatch: true }) ? { action: "allow" } : undefined;
|
|
7105
6980
|
}
|
|
7106
|
-
if (trap.operation === "write" &&
|
|
6981
|
+
if (trap.operation === "write" && matchesWriteDenyPattern(path, config.filesystem.denyWriteAlways, cwd, getEffectiveAllowWrite(config, allowances))) {
|
|
7107
6982
|
return { action: "deny", reason: "hard-deny" };
|
|
7108
6983
|
}
|
|
7109
|
-
const allowed = trap.operation === "read" ? readAllowed(path, getEffectiveAllowRead(config, cwd, allowances), getEffectiveDenyRead(config, cwd), cwd) : !shouldPromptForWrite(path, getEffectiveAllowWrite(config, allowances), cwd);
|
|
6984
|
+
const allowed = trap.operation === "read" ? readAllowed(path, getEffectiveAllowRead(config, cwd, allowances), getEffectiveDenyRead(config, cwd), cwd) : !shouldPromptForWrite(path, getEffectiveAllowWrite(config, allowances), config.filesystem.denyWrite, cwd);
|
|
7110
6985
|
return allowed ? { action: "allow" } : undefined;
|
|
7111
6986
|
};
|
|
7112
6987
|
const existing = current();
|
|
@@ -7116,7 +6991,7 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
7116
6991
|
return { action: "deny", reason: "unprompted" };
|
|
7117
6992
|
return permissionPrompts.resolve(current, async (promptSignal) => {
|
|
7118
6993
|
const config = loadConfig(cwd);
|
|
7119
|
-
const choice = trap.operation === "read" ? await promptReadBlock(ctx, path, matchesPattern(path, config.filesystem.denyRead, cwd) ? "granting allowRead will override it" : undefined, promptSignal, allowances.permissionPromptLabel) : await
|
|
6994
|
+
const choice = trap.operation === "read" ? await promptReadBlock(ctx, path, matchesPattern(path, config.filesystem.denyRead, cwd) ? "granting allowRead will override it" : undefined, promptSignal, allowances.permissionPromptLabel) : await promptWriteBlock(ctx, path, matchesWriteDenyPattern(path, config.filesystem.denyWrite, cwd, getEffectiveAllowWrite(config, allowances)) ? "granting allowWrite will override it" : undefined, promptSignal, allowances.permissionPromptLabel);
|
|
7120
6995
|
if (choice === "abort" || promptSignal.aborted)
|
|
7121
6996
|
return { action: "deny", reason: "rejected" };
|
|
7122
6997
|
if (trap.operation === "read") {
|
|
@@ -7311,7 +7186,10 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
7311
7186
|
}
|
|
7312
7187
|
const workerPolicy = policy;
|
|
7313
7188
|
const workerChildEnd = childEnd;
|
|
7314
|
-
const workerEnv = createProxyEnvironment(proxy?.port ?? null,
|
|
7189
|
+
const workerEnv = createProxyEnvironment(proxy?.port ?? null, {
|
|
7190
|
+
token: proxyToken,
|
|
7191
|
+
baseEnv: options.env ?? {}
|
|
7192
|
+
});
|
|
7315
7193
|
let spawned = false;
|
|
7316
7194
|
let disposePromise;
|
|
7317
7195
|
const spawnWorker = (_command, _args, spawnOptions) => {
|
|
@@ -7689,7 +7567,10 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
7689
7567
|
if (trap && isQueryTrap(trap)) {
|
|
7690
7568
|
queryChain = queryChain.then(async () => {
|
|
7691
7569
|
const result = await resolveTrapQuery(trap, ctx, cwd, processAllowances, callbacks.promptOnBlock === true, signal);
|
|
7692
|
-
if (result.
|
|
7570
|
+
if (result.action === "deny") {
|
|
7571
|
+
if (result.reason === "rejected" && isFilesystemTrap(trap)) {
|
|
7572
|
+
callbacks.onRejectedPath?.(trap.operation, normalizeBlockedPath(trap.path, cwd));
|
|
7573
|
+
}
|
|
7693
7574
|
appendErrorLine(line);
|
|
7694
7575
|
}
|
|
7695
7576
|
respondQuery(trap.query_id, result.action);
|
|
@@ -7734,6 +7615,10 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
7734
7615
|
async function runBashWithOptionalRetry(id, params, signal, onUpdate, ctx) {
|
|
7735
7616
|
let landstripErrorOutput = "";
|
|
7736
7617
|
let stderrOutput = "";
|
|
7618
|
+
const rejectedPaths = {
|
|
7619
|
+
read: new Set,
|
|
7620
|
+
write: new Set
|
|
7621
|
+
};
|
|
7737
7622
|
const allowances = {
|
|
7738
7623
|
domains: [],
|
|
7739
7624
|
readPaths: [],
|
|
@@ -7748,11 +7633,22 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
7748
7633
|
onStderr: (data) => {
|
|
7749
7634
|
stderrOutput += data.toString("utf8");
|
|
7750
7635
|
},
|
|
7636
|
+
onRejectedPath: (operation, path) => {
|
|
7637
|
+
rejectedPaths[operation].add(path);
|
|
7638
|
+
},
|
|
7751
7639
|
promptOnBlock: true
|
|
7752
7640
|
}, allowances),
|
|
7753
7641
|
shellPath: SettingsManager2.create(ctx.cwd).getShellPath()
|
|
7754
7642
|
});
|
|
7755
7643
|
const run = () => sandboxedBash.execute(id, params, signal, onUpdate, ctx);
|
|
7644
|
+
const formatTrapErrors = () => {
|
|
7645
|
+
const landstripErrors = parseLandstripTraps(landstripErrorOutput);
|
|
7646
|
+
if (landstripErrors.length === 0)
|
|
7647
|
+
return null;
|
|
7648
|
+
return [...new Set(formatLandstripTraps(landstripErrors).split(`
|
|
7649
|
+
`))].join(`
|
|
7650
|
+
`);
|
|
7651
|
+
};
|
|
7756
7652
|
const blockedReadPathForRetry = (nativeOutput) => {
|
|
7757
7653
|
const config = loadConfig(ctx.cwd);
|
|
7758
7654
|
if (!enforcesShellReadPolicy(config.shell.readAccess))
|
|
@@ -7763,30 +7659,21 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
7763
7659
|
return extractRetryableNativeReadDeniedPath(nativeOutput, ctx.cwd, getEffectiveAllowRead(config, ctx.cwd, allowances), getEffectiveDenyRead(config, ctx.cwd));
|
|
7764
7660
|
};
|
|
7765
7661
|
const retryWithAccess = async (operation, blockedPath) => {
|
|
7766
|
-
if (!ctx.hasUI)
|
|
7662
|
+
if (!ctx.hasUI || rejectedPaths[operation].has(blockedPath))
|
|
7767
7663
|
return null;
|
|
7768
7664
|
const { globalPath, projectPath } = getPiConfigPaths(ctx.cwd, "sandbox.json");
|
|
7769
|
-
const
|
|
7770
|
-
const writeRoots = getEffectiveAllowWrite(config, allowances);
|
|
7771
|
-
if (matchesWriteDenyPattern(blockedPath, config.filesystem.denyWriteAlways, ctx.cwd, writeRoots)) {
|
|
7772
|
-
return "denyWriteAlways";
|
|
7773
|
-
}
|
|
7774
|
-
if (matchesWriteDenyPattern(blockedPath, config.filesystem.denyWrite, ctx.cwd, writeRoots)) {
|
|
7775
|
-
return "denyWrite";
|
|
7776
|
-
}
|
|
7777
|
-
return null;
|
|
7778
|
-
};
|
|
7665
|
+
const isWriteDeniedAlways = (config) => matchesWriteDenyPattern(blockedPath, config.filesystem.denyWriteAlways, ctx.cwd, getEffectiveAllowWrite(config, allowances));
|
|
7779
7666
|
const current = () => {
|
|
7780
7667
|
const config = loadConfig(ctx.cwd);
|
|
7781
|
-
if (operation === "read" ? matchesPattern(blockedPath, config.filesystem.denyReadAlways, ctx.cwd) :
|
|
7668
|
+
if (operation === "read" ? matchesPattern(blockedPath, config.filesystem.denyReadAlways, ctx.cwd) : isWriteDeniedAlways(config)) {
|
|
7782
7669
|
return false;
|
|
7783
7670
|
}
|
|
7784
|
-
const needsPrompt = operation === "read" ? !readAllowed(blockedPath, getEffectiveAllowRead(config, ctx.cwd, allowances), getEffectiveDenyRead(config, ctx.cwd), ctx.cwd) : shouldPromptForWrite(blockedPath, getEffectiveAllowWrite(config, allowances), ctx.cwd);
|
|
7671
|
+
const needsPrompt = operation === "read" ? !readAllowed(blockedPath, getEffectiveAllowRead(config, ctx.cwd, allowances), getEffectiveDenyRead(config, ctx.cwd), ctx.cwd) : shouldPromptForWrite(blockedPath, getEffectiveAllowWrite(config, allowances), config.filesystem.denyWrite, ctx.cwd);
|
|
7785
7672
|
return needsPrompt ? undefined : true;
|
|
7786
7673
|
};
|
|
7787
7674
|
const access = await permissionPrompts.resolve(current, async (promptSignal) => {
|
|
7788
7675
|
const config = loadConfig(ctx.cwd);
|
|
7789
|
-
const choice = operation === "read" ? await promptReadBlock(ctx, blockedPath, matchesPattern(blockedPath, config.filesystem.denyRead, ctx.cwd) ? "granting allowRead will override it" : undefined, promptSignal) : await
|
|
7676
|
+
const choice = operation === "read" ? await promptReadBlock(ctx, blockedPath, matchesPattern(blockedPath, config.filesystem.denyRead, ctx.cwd) ? "granting allowRead will override it" : undefined, promptSignal) : await promptWriteBlock(ctx, blockedPath, matchesWriteDenyPattern(blockedPath, config.filesystem.denyWrite, ctx.cwd, getEffectiveAllowWrite(config, allowances)) ? "granting allowWrite will override it" : undefined, promptSignal);
|
|
7790
7677
|
if (choice === "abort" || promptSignal.aborted)
|
|
7791
7678
|
return false;
|
|
7792
7679
|
if (operation === "read") {
|
|
@@ -7798,25 +7685,19 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
7798
7685
|
}, signal);
|
|
7799
7686
|
if (!access) {
|
|
7800
7687
|
const config = loadConfig(ctx.cwd);
|
|
7801
|
-
if (operation === "write") {
|
|
7802
|
-
|
|
7803
|
-
if (tier) {
|
|
7804
|
-
notify(ctx, `"${blockedPath}" is blocked by ${tier}. Check:
|
|
7688
|
+
if (operation === "write" && isWriteDeniedAlways(config)) {
|
|
7689
|
+
notify(ctx, `"${blockedPath}" is blocked by denyWriteAlways. Check:
|
|
7805
7690
|
${projectPath}
|
|
7806
7691
|
${globalPath}`, "warning");
|
|
7807
|
-
}
|
|
7808
7692
|
}
|
|
7809
7693
|
return null;
|
|
7810
7694
|
}
|
|
7811
|
-
|
|
7812
|
-
if (operation === "write") {
|
|
7813
|
-
|
|
7814
|
-
if (tier) {
|
|
7815
|
-
notify(ctx, `"${blockedPath}" was added to allowWrite, but ${tier} still blocks it. Check:
|
|
7695
|
+
const config = loadConfig(ctx.cwd);
|
|
7696
|
+
if (operation === "write" && isWriteDeniedAlways(config)) {
|
|
7697
|
+
notify(ctx, `"${blockedPath}" was added to allowWrite, but denyWriteAlways still blocks it. Check:
|
|
7816
7698
|
${projectPath}
|
|
7817
7699
|
${globalPath}`, "warning");
|
|
7818
|
-
|
|
7819
|
-
}
|
|
7700
|
+
return null;
|
|
7820
7701
|
}
|
|
7821
7702
|
onUpdate?.({
|
|
7822
7703
|
content: [
|
|
@@ -7852,17 +7733,18 @@ ${errorText}`;
|
|
|
7852
7733
|
if (retryResult)
|
|
7853
7734
|
return retryResult;
|
|
7854
7735
|
}
|
|
7855
|
-
const
|
|
7856
|
-
if (
|
|
7857
|
-
throw new Error(
|
|
7736
|
+
const trapMessage = formatTrapErrors();
|
|
7737
|
+
if (trapMessage) {
|
|
7738
|
+
throw new Error(errorText ? `${trapMessage}
|
|
7739
|
+
|
|
7740
|
+
${errorText}` : trapMessage);
|
|
7858
7741
|
}
|
|
7859
7742
|
throw error;
|
|
7860
7743
|
}
|
|
7861
|
-
const
|
|
7862
|
-
if (
|
|
7863
|
-
const message = formatLandstripTraps(landstripErrors);
|
|
7744
|
+
const trapMessage = formatTrapErrors();
|
|
7745
|
+
if (trapMessage) {
|
|
7864
7746
|
result.content.unshift({ type: "text", text: `
|
|
7865
|
-
${
|
|
7747
|
+
${trapMessage}
|
|
7866
7748
|
` });
|
|
7867
7749
|
}
|
|
7868
7750
|
const blockedWritePath = extractTrapBlockedPath(landstripErrorOutput, ctx.cwd, "write") ?? extractNativeWriteDeniedPath(stderrOutput, ctx.cwd, params.command);
|
|
@@ -8178,25 +8060,14 @@ ${message}
|
|
|
8178
8060
|
export {
|
|
8179
8061
|
LandstripBashSchema,
|
|
8180
8062
|
POSIX_SHELL_PROVIDER_ID,
|
|
8181
|
-
controlResponseLine,
|
|
8182
8063
|
createLandstripIntegration,
|
|
8183
8064
|
createLandstripLauncherEnvironment,
|
|
8184
8065
|
createPosixShellProvider,
|
|
8185
8066
|
createWindowsDenyRead,
|
|
8186
8067
|
pi_landstrip_default as default,
|
|
8187
|
-
domainMatchesAny,
|
|
8188
8068
|
enforcesShellReadPolicy,
|
|
8189
|
-
extractDeniedPath,
|
|
8190
|
-
extractNativeDeniedPath,
|
|
8191
|
-
extractNativeWriteDeniedPath,
|
|
8192
8069
|
extractRetryableNativeReadDeniedPath,
|
|
8193
|
-
formatLandstripTraps,
|
|
8194
|
-
isQueryTrap,
|
|
8195
8070
|
matchesPattern,
|
|
8196
|
-
parseTrapLine,
|
|
8197
|
-
readAllowed,
|
|
8198
8071
|
resolveProcessReadPolicy,
|
|
8199
|
-
sessionScopeFor,
|
|
8200
|
-
shouldPromptForWrite,
|
|
8201
8072
|
writeEnvFile
|
|
8202
8073
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-landstrip",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.15",
|
|
4
4
|
"description": "Sandboxed Bash and process-backed agents for Pi",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"landstrip",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"ci:test": "npm run test"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@landstrip/landstrip-api": "^0.20.
|
|
42
|
+
"@landstrip/landstrip-api": "^0.20.15",
|
|
43
43
|
"jsonc-parser": "^3.3.1",
|
|
44
44
|
"minimatch": "^10.2.5",
|
|
45
45
|
"undici": "^8.9.0",
|