pi-landstrip 0.20.15 → 0.20.17
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 +12 -0
- package/dist/index.ts +244 -104
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -60,6 +60,18 @@ Global definitions load first.
|
|
|
60
60
|
`maxSubagents` accepts values from 0 to 16. Agent definitions can override
|
|
61
61
|
model, prompt, mode, options, and permissions.
|
|
62
62
|
|
|
63
|
+
The `task` tool accepts an optional `model` parameter, `provider/model[:level]`,
|
|
64
|
+
that overrides the agent's configured model (and variant) for that run, e.g.
|
|
65
|
+
`model="openrouter/openai/gpt-6-luna:low"`. The provider is required, and the
|
|
66
|
+
model must exist and have authentication configured. The tool description tells
|
|
67
|
+
the LLM to set it only when the user explicitly asks for a model or level. Valid
|
|
68
|
+
levels are `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`.
|
|
69
|
+
Without a level, the model's entry in `modelThinkingLevels` (keyed by
|
|
70
|
+
`provider/model`), then `defaultThinkingLevel`, both from
|
|
71
|
+
`~/.pi/agent/settings.json`, then `medium` is used. The override is stored on
|
|
72
|
+
the task, so resuming it with `task_id` keeps the same model, and its auth is
|
|
73
|
+
checked again on resume. Passing a new `model` with `task_id` is an error.
|
|
74
|
+
|
|
63
75
|
Use `/landstrip-sandbox` for sandbox overview/policy (`Overview`, `Policy`, `Help`)
|
|
64
76
|
and `/landstrip-subagents` for subagent/task management (`Tasks`, `Log`, `Subagent`,
|
|
65
77
|
`Primary`, `Settings`, `Help`). Task IDs accept unique prefixes; bare IDs open logs.
|
package/dist/index.ts
CHANGED
|
@@ -33,17 +33,16 @@ import {
|
|
|
33
33
|
deepMergeSandboxConfig as deepMerge,
|
|
34
34
|
domainMatchesAny,
|
|
35
35
|
evaluateDomainAccess,
|
|
36
|
-
formatLandstripTraps,
|
|
36
|
+
formatLandstripTraps as formatLandstripTraps2,
|
|
37
37
|
isDenialTrap,
|
|
38
38
|
isFilesystemTrap,
|
|
39
39
|
isPathReadAllowed,
|
|
40
|
-
isPathWriteAllowed,
|
|
41
40
|
isRecord as isRecord3,
|
|
42
41
|
isQueryTrap,
|
|
43
42
|
matchesPathPattern,
|
|
44
43
|
matchesWriteDenyPattern,
|
|
45
44
|
mergeArray,
|
|
46
|
-
parseLandstripTraps,
|
|
45
|
+
parseLandstripTraps as parseLandstripTraps2,
|
|
47
46
|
parseSandboxConfig,
|
|
48
47
|
canonicalizeGlobPattern,
|
|
49
48
|
canonicalizePath as canonicalizePath2,
|
|
@@ -55,6 +54,8 @@ import {
|
|
|
55
54
|
sessionScopeFor,
|
|
56
55
|
writeLandstripPolicyFile,
|
|
57
56
|
shouldPromptForWrite,
|
|
57
|
+
writeGrantScopesFor,
|
|
58
|
+
readGrantScopesFor,
|
|
58
59
|
normalizeBlockedPath,
|
|
59
60
|
extractNativeDeniedPath,
|
|
60
61
|
extractNativeWriteDeniedPath,
|
|
@@ -262,7 +263,12 @@ import {
|
|
|
262
263
|
visibleWidth,
|
|
263
264
|
wrapTextWithAnsi
|
|
264
265
|
} from "@earendil-works/pi-tui";
|
|
265
|
-
import {
|
|
266
|
+
import {
|
|
267
|
+
canonicalizeHost as canonicalizeHost2,
|
|
268
|
+
canonicalizePath,
|
|
269
|
+
formatLandstripTraps,
|
|
270
|
+
parseLandstripTraps
|
|
271
|
+
} from "@landstrip/landstrip-api/shared";
|
|
266
272
|
import { Type } from "typebox";
|
|
267
273
|
|
|
268
274
|
// agents.ts
|
|
@@ -2477,6 +2483,39 @@ function paneRow(_theme, width, content = "") {
|
|
|
2477
2483
|
return ` ${line}${" ".repeat(Math.max(0, width - visibleWidth(line) - 1))}`;
|
|
2478
2484
|
}
|
|
2479
2485
|
var PI_THINKING_LEVELS = new Set(["off", "minimal", "low", "medium", "high", "xhigh", "max"]);
|
|
2486
|
+
var FALLBACK_THINKING_LEVEL = "medium";
|
|
2487
|
+
function parseTaskModelOverride(value) {
|
|
2488
|
+
const trimmed = value.trim();
|
|
2489
|
+
if (!trimmed)
|
|
2490
|
+
throw new Error("Task model cannot be empty");
|
|
2491
|
+
let model = trimmed;
|
|
2492
|
+
let variant;
|
|
2493
|
+
const index = trimmed.lastIndexOf(":");
|
|
2494
|
+
if (index > 0 && PI_THINKING_LEVELS.has(trimmed.slice(index + 1))) {
|
|
2495
|
+
model = trimmed.slice(0, index);
|
|
2496
|
+
variant = trimmed.slice(index + 1);
|
|
2497
|
+
}
|
|
2498
|
+
const slash = model.indexOf("/");
|
|
2499
|
+
if (slash <= 0 || slash === model.length - 1) {
|
|
2500
|
+
throw new Error(`Task model must be "provider/model[:level]", got: ${value}`);
|
|
2501
|
+
}
|
|
2502
|
+
return variant ? { model, variant } : { model };
|
|
2503
|
+
}
|
|
2504
|
+
function resolveOverrideThinkingLevel(settings, qualifiedModel) {
|
|
2505
|
+
const perModel = settings?.modelThinkingLevels?.[qualifiedModel];
|
|
2506
|
+
if (perModel && PI_THINKING_LEVELS.has(perModel))
|
|
2507
|
+
return perModel;
|
|
2508
|
+
const fallback = settings?.defaultThinkingLevel;
|
|
2509
|
+
return fallback && PI_THINKING_LEVELS.has(fallback) ? fallback : FALLBACK_THINKING_LEVEL;
|
|
2510
|
+
}
|
|
2511
|
+
function assertOverrideModelUsable(ctx, model) {
|
|
2512
|
+
const found = ctx.modelRegistry?.getAll().find((candidate) => `${candidate.provider}/${candidate.id}` === model);
|
|
2513
|
+
if (!found)
|
|
2514
|
+
throw new Error(`Model not found for task: ${model}`);
|
|
2515
|
+
if (!ctx.modelRegistry.hasConfiguredAuth(found)) {
|
|
2516
|
+
throw new Error(`No authentication configured for task model: ${model}`);
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2480
2519
|
var SANDBOX_HELP_ROWS = [
|
|
2481
2520
|
["Tab", "Next tab"],
|
|
2482
2521
|
["↑ / ↓", "Scroll when content exceeds pane height"],
|
|
@@ -2590,6 +2629,9 @@ var taskParameters = Type.Object({
|
|
|
2590
2629
|
description: Type.String({ description: "Short task label (3-5 words)" }),
|
|
2591
2630
|
prompt: Type.String({ description: "Full instructions for the subagent" }),
|
|
2592
2631
|
subagent_type: Type.String({ description: "Subagent name" }),
|
|
2632
|
+
model: Type.Optional(Type.String({
|
|
2633
|
+
description: 'NEVER set this unless the user explicitly asks for a particular model or thinking level; by default the subagent uses the model configured for it. Format: "provider/model[:level]" (level: off, minimal, low, medium, high, xhigh, max). Without a level, the entry for the model in modelThinkingLevels, then defaultThinkingLevel (from Pi settings) is used. Cannot be combined with task_id.'
|
|
2634
|
+
})),
|
|
2593
2635
|
task_id: Type.Optional(Type.String({ description: "Task ID to resume" })),
|
|
2594
2636
|
command: Type.Optional(Type.String({ description: "Originating command, if any" })),
|
|
2595
2637
|
background: Type.Optional(Type.Boolean({
|
|
@@ -2880,7 +2922,8 @@ function taskProgress(task) {
|
|
|
2880
2922
|
return progress;
|
|
2881
2923
|
}
|
|
2882
2924
|
function workerDialogTitle(task, title) {
|
|
2883
|
-
const
|
|
2925
|
+
const actor = task.kind === "command" || task.agent === "bash" ? "$ bash" : `@${task.agent}`;
|
|
2926
|
+
const label = `${actor} · ${task.description} · ${task.id.slice(0, 8)}`;
|
|
2884
2927
|
return title === undefined ? label : `${label}
|
|
2885
2928
|
${title}`;
|
|
2886
2929
|
}
|
|
@@ -4868,10 +4911,15 @@ ${outputText}` }
|
|
|
4868
4911
|
this.controllers.set(taskId, controller);
|
|
4869
4912
|
const runPromise = (async () => {
|
|
4870
4913
|
try {
|
|
4914
|
+
let trapBuffer = "";
|
|
4871
4915
|
const result = await this.integration.runSandboxedCommand(params.command, ctx.cwd, {
|
|
4872
4916
|
timeout: params.timeout,
|
|
4873
4917
|
signal: controller.signal,
|
|
4874
|
-
promptOnBlock:
|
|
4918
|
+
promptOnBlock: ctx.hasUI,
|
|
4919
|
+
permissionPromptLabel: workerDialogTitle(task),
|
|
4920
|
+
onErrorFd: (chunk) => {
|
|
4921
|
+
trapBuffer += chunk.toString("utf8");
|
|
4922
|
+
},
|
|
4875
4923
|
onData: (chunk) => {
|
|
4876
4924
|
try {
|
|
4877
4925
|
writeSync(outputFd, chunk);
|
|
@@ -4879,6 +4927,17 @@ ${outputText}` }
|
|
|
4879
4927
|
this.notifyTaskUpdate();
|
|
4880
4928
|
}
|
|
4881
4929
|
}, ctx);
|
|
4930
|
+
const traps = parseLandstripTraps(trapBuffer);
|
|
4931
|
+
if (traps.length > 0) {
|
|
4932
|
+
const formatted = [...new Set(formatLandstripTraps(traps).split(`
|
|
4933
|
+
`))].join(`
|
|
4934
|
+
`);
|
|
4935
|
+
try {
|
|
4936
|
+
writeSync(outputFd, Buffer.from(`${formatted}
|
|
4937
|
+
`, "utf8"));
|
|
4938
|
+
} catch {}
|
|
4939
|
+
this.notifyTaskUpdate();
|
|
4940
|
+
}
|
|
4882
4941
|
task.exitCode = result.exitCode;
|
|
4883
4942
|
if (task.state !== "cancelled") {
|
|
4884
4943
|
task.state = result.exitCode === 0 ? "completed" : "error";
|
|
@@ -5058,15 +5117,21 @@ ${catalog.diagnostics.join(`
|
|
|
5058
5117
|
}
|
|
5059
5118
|
if (catalog.maxSubagents === 0)
|
|
5060
5119
|
throw new Error("Subagents are disabled by maxSubagents: 0");
|
|
5061
|
-
const
|
|
5062
|
-
if (!
|
|
5120
|
+
const baseAgent = catalog.agents.get(input.subagent_type);
|
|
5121
|
+
if (!baseAgent || baseAgent.disabled || baseAgent.mode === "primary")
|
|
5063
5122
|
throw new Error(`Unknown subagent: ${input.subagent_type}`);
|
|
5123
|
+
if (input.model !== undefined && input.task_id) {
|
|
5124
|
+
throw new Error("Cannot change the model when resuming a task (model with task_id)");
|
|
5125
|
+
}
|
|
5126
|
+
const requestedOverride = input.model !== undefined ? parseTaskModelOverride(input.model) : undefined;
|
|
5127
|
+
if (requestedOverride)
|
|
5128
|
+
assertOverrideModelUsable(ctx, requestedOverride.model);
|
|
5064
5129
|
const rules = callerRules ?? catalog.permissions;
|
|
5065
|
-
const taskPermission = permissionDecision(rules, "task",
|
|
5130
|
+
const taskPermission = permissionDecision(rules, "task", baseAgent.name);
|
|
5066
5131
|
if (taskPermission === "deny")
|
|
5067
|
-
throw new Error(`Task permission denied for ${
|
|
5132
|
+
throw new Error(`Task permission denied for ${baseAgent.name}`);
|
|
5068
5133
|
if (taskPermission === "ask") {
|
|
5069
|
-
await this.broker.ask(ctx, input.description, "task",
|
|
5134
|
+
await this.broker.ask(ctx, input.description, "task", baseAgent.name, signal, {
|
|
5070
5135
|
context: parentTask ? this.taskContext(parentTask, ctx) : this.permissionContext(ctx),
|
|
5071
5136
|
toolName: "task",
|
|
5072
5137
|
input: { ...input },
|
|
@@ -5088,15 +5153,19 @@ ${catalog.diagnostics.join(`
|
|
|
5088
5153
|
if (task.parentTaskId !== parentTask?.id) {
|
|
5089
5154
|
throw new Error(`Task ${task.id} does not belong to this parent task`);
|
|
5090
5155
|
}
|
|
5091
|
-
if (task.agent !==
|
|
5092
|
-
throw new Error(`Task ${task.id} belongs to agent ${task.agent}, not ${
|
|
5156
|
+
if (task.agent !== baseAgent.name) {
|
|
5157
|
+
throw new Error(`Task ${task.id} belongs to agent ${task.agent}, not ${baseAgent.name}`);
|
|
5093
5158
|
}
|
|
5094
5159
|
if (!this.running.has(task.id) && (!task.sessionDir || !existsSync5(task.sessionDir)) && (!task.sessionFile || !existsSync5(task.sessionFile))) {
|
|
5095
5160
|
throw new Error(`Task ${task.id} session is unavailable`);
|
|
5096
5161
|
}
|
|
5097
5162
|
} else {
|
|
5098
|
-
task = this.createRecord(input, ctx, parentTask,
|
|
5163
|
+
task = this.createRecord(input, ctx, parentTask, baseAgent, depth, requestedOverride);
|
|
5099
5164
|
}
|
|
5165
|
+
const override = task.kind === "command" ? undefined : task.modelOverride;
|
|
5166
|
+
if (input.task_id && override)
|
|
5167
|
+
assertOverrideModelUsable(ctx, override.model);
|
|
5168
|
+
const agent = override ? { ...baseAgent, model: override.model, variant: override.variant } : baseAgent;
|
|
5100
5169
|
const existingRun = this.runPromises.get(task.id);
|
|
5101
5170
|
if (input.task_id)
|
|
5102
5171
|
task.delivered = false;
|
|
@@ -5235,7 +5304,7 @@ ${bounded}
|
|
|
5235
5304
|
|
|
5236
5305
|
${prompt}`;
|
|
5237
5306
|
}
|
|
5238
|
-
createRecord(input, ctx, parentTask, agent, depth) {
|
|
5307
|
+
createRecord(input, ctx, parentTask, agent, depth, modelOverride) {
|
|
5239
5308
|
const parentSession = parentTask?.sessionFile ?? ctx.sessionManager.getSessionFile();
|
|
5240
5309
|
const id = randomUUID();
|
|
5241
5310
|
const sessionDir = join7(getAgentDir4(), "sessions", "pi-landstrip", ctx.sessionManager.getSessionId(), id);
|
|
@@ -5251,7 +5320,8 @@ ${prompt}`;
|
|
|
5251
5320
|
description: input.description,
|
|
5252
5321
|
depth,
|
|
5253
5322
|
state: "queued",
|
|
5254
|
-
background: input.background === true
|
|
5323
|
+
background: input.background === true,
|
|
5324
|
+
modelOverride
|
|
5255
5325
|
};
|
|
5256
5326
|
this.tasks.set(task.id, task);
|
|
5257
5327
|
this.persist(task);
|
|
@@ -5437,7 +5507,7 @@ ${prompt}`;
|
|
|
5437
5507
|
const endpoint = await workerEndpoint(ctx, model, agent.name, signal);
|
|
5438
5508
|
if (signal.aborted)
|
|
5439
5509
|
throw new Error("Task cancelled");
|
|
5440
|
-
const thinking = agent.variant && PI_THINKING_LEVELS.has(agent.variant) ? agent.variant : this.pi.getThinkingLevel();
|
|
5510
|
+
const thinking = agent.variant && PI_THINKING_LEVELS.has(agent.variant) ? agent.variant : task.kind !== "command" && task.modelOverride ? resolveOverrideThinkingLevel(this.pi.getSettings(), endpoint.model) : this.pi.getThinkingLevel();
|
|
5441
5511
|
if (agent.variant && !PI_THINKING_LEVELS.has(agent.variant)) {
|
|
5442
5512
|
ctx.ui.notify(`Agent ${agent.name} uses unsupported Pi model variant: ${agent.variant}`, "warning");
|
|
5443
5513
|
}
|
|
@@ -6179,23 +6249,27 @@ function resolveProcessReadPolicy(audience, shellReadAccess, denyRead, allowRead
|
|
|
6179
6249
|
var SUPPORTED_PLATFORMS = new Set(["linux", "darwin", "win32"]);
|
|
6180
6250
|
var EXIT_STDIO_GRACE_MS = 100;
|
|
6181
6251
|
var packageDir2 = dirname5(fileURLToPath2(import.meta.url));
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6252
|
+
function permissionOptionsFor(ctx) {
|
|
6253
|
+
const options = [
|
|
6254
|
+
{ label: "Allow once", action: "once" },
|
|
6255
|
+
{ label: "Allow for this session", action: "session" }
|
|
6256
|
+
];
|
|
6257
|
+
if (isProjectTrusted(ctx)) {
|
|
6258
|
+
options.push({
|
|
6259
|
+
label: "Allow for this project",
|
|
6260
|
+
action: "project",
|
|
6261
|
+
confirm: true,
|
|
6262
|
+
hint: "save to .pi/sandbox.json"
|
|
6263
|
+
});
|
|
6264
|
+
}
|
|
6265
|
+
options.push({
|
|
6192
6266
|
label: "Allow for all projects",
|
|
6193
6267
|
action: "global",
|
|
6194
6268
|
confirm: true,
|
|
6195
6269
|
hint: "save to ~/.pi/agent/sandbox.json"
|
|
6196
|
-
},
|
|
6197
|
-
|
|
6198
|
-
|
|
6270
|
+
}, { label: "Keep blocked", action: "abort" });
|
|
6271
|
+
return options;
|
|
6272
|
+
}
|
|
6199
6273
|
var NETWORK_PERMISSION_OPTIONS = [
|
|
6200
6274
|
{ label: "Allow once", action: "once" },
|
|
6201
6275
|
{ label: "Allow for this session", action: "session" },
|
|
@@ -6471,11 +6545,11 @@ ${option.hint ?? "This changes persisted sandbox policy."}`, { signal });
|
|
|
6471
6545
|
}
|
|
6472
6546
|
function promptReadBlock(ctx, filePath, reason, signal, label) {
|
|
6473
6547
|
const title = reason ? `Read blocked: "${filePath}" is in denyRead (${reason})` : `Read blocked: "${filePath}" is not in allowRead`;
|
|
6474
|
-
return showPermissionPrompt(ctx, title,
|
|
6548
|
+
return showPermissionPrompt(ctx, title, permissionOptionsFor(ctx), signal, label);
|
|
6475
6549
|
}
|
|
6476
6550
|
function promptWriteBlock(ctx, filePath, reason, signal, label) {
|
|
6477
6551
|
const title = reason ? `Write blocked: "${filePath}" is in denyWrite (${reason})` : `Write blocked: "${filePath}" is not in allowWrite`;
|
|
6478
|
-
return showPermissionPrompt(ctx, title,
|
|
6552
|
+
return showPermissionPrompt(ctx, title, permissionOptionsFor(ctx), signal, label);
|
|
6479
6553
|
}
|
|
6480
6554
|
function writeEnvFile(env, proxyPort, proxyToken) {
|
|
6481
6555
|
const lines = [];
|
|
@@ -6572,8 +6646,11 @@ function createLandstripIntegrationWithPrompts(options, permissionPrompts) {
|
|
|
6572
6646
|
const localCwd = options.cwd ?? process.cwd();
|
|
6573
6647
|
let subagentRuntime = options.subagentRuntime;
|
|
6574
6648
|
let projectConfigTrusted = false;
|
|
6575
|
-
function
|
|
6576
|
-
return
|
|
6649
|
+
function isProjectConfigTrusted(ctx = activeContext) {
|
|
6650
|
+
return ctx ? isProjectTrusted(ctx) : projectConfigTrusted;
|
|
6651
|
+
}
|
|
6652
|
+
function loadConfig(cwd, ctx = activeContext) {
|
|
6653
|
+
return loadSandboxConfig(cwd, isProjectConfigTrusted(ctx));
|
|
6577
6654
|
}
|
|
6578
6655
|
let sandboxEnabled = false;
|
|
6579
6656
|
let sandboxReady = false;
|
|
@@ -6589,6 +6666,7 @@ function createLandstripIntegrationWithPrompts(options, permissionPrompts) {
|
|
|
6589
6666
|
const sessionAllowedDomains = [];
|
|
6590
6667
|
const sessionAllowedReadPaths = [];
|
|
6591
6668
|
const sessionAllowedWritePaths = [];
|
|
6669
|
+
const sessionAllowedUnixSockets = [];
|
|
6592
6670
|
const sessionAllowedTargets = [];
|
|
6593
6671
|
function getContext(ctx = activeContext) {
|
|
6594
6672
|
return {
|
|
@@ -6750,9 +6828,17 @@ function createLandstripIntegrationWithPrompts(options, permissionPrompts) {
|
|
|
6750
6828
|
readPaths: [...new Set([...allowances.readPaths, ...executablePaths, ...additionalPaths])]
|
|
6751
6829
|
};
|
|
6752
6830
|
}
|
|
6753
|
-
|
|
6831
|
+
function resolvePersistedConfigPath(cwd, choice, ctx = activeContext) {
|
|
6754
6832
|
const { globalPath, projectPath } = getPiConfigPaths(cwd, "sandbox.json");
|
|
6755
|
-
|
|
6833
|
+
if (choice === "project") {
|
|
6834
|
+
return isProjectConfigTrusted(ctx) ? projectPath : undefined;
|
|
6835
|
+
}
|
|
6836
|
+
if (choice === "global")
|
|
6837
|
+
return globalPath;
|
|
6838
|
+
return;
|
|
6839
|
+
}
|
|
6840
|
+
async function applyDomainChoice(ctx, choice, domain, cwd, allowances) {
|
|
6841
|
+
const configPath = resolvePersistedConfigPath(cwd, choice, ctx);
|
|
6756
6842
|
if (configPath) {
|
|
6757
6843
|
await addConfigValue(configPath, domain, (config) => config.network?.allowedDomains ?? [], (config, allowedDomains) => {
|
|
6758
6844
|
config.network = {
|
|
@@ -6766,45 +6852,69 @@ function createLandstripIntegrationWithPrompts(options, permissionPrompts) {
|
|
|
6766
6852
|
if (target && !target.includes(domain))
|
|
6767
6853
|
target.push(domain);
|
|
6768
6854
|
}
|
|
6769
|
-
function
|
|
6770
|
-
|
|
6771
|
-
|
|
6855
|
+
async function applyUnixSocketChoice(ctx, choice, socketPath, key, cwd, allowances) {
|
|
6856
|
+
const configPath = resolvePersistedConfigPath(cwd, choice, ctx);
|
|
6857
|
+
if (configPath) {
|
|
6858
|
+
await addConfigValue(configPath, socketPath, (config) => config.network?.allowUnixSockets ?? [], (config, allowUnixSockets) => {
|
|
6859
|
+
config.network = { ...config.network, allowUnixSockets };
|
|
6860
|
+
});
|
|
6861
|
+
}
|
|
6862
|
+
if (choice === "once") {
|
|
6863
|
+
if (allowances && !allowances.targets.includes(key))
|
|
6864
|
+
allowances.targets.push(key);
|
|
6865
|
+
} else {
|
|
6866
|
+
if (!sessionAllowedUnixSockets.includes(socketPath)) {
|
|
6867
|
+
sessionAllowedUnixSockets.push(socketPath);
|
|
6868
|
+
}
|
|
6869
|
+
if (!sessionAllowedTargets.includes(key))
|
|
6870
|
+
sessionAllowedTargets.push(key);
|
|
6871
|
+
}
|
|
6872
|
+
}
|
|
6873
|
+
function noteScope(ctx, verb, choice, filePath, scopes) {
|
|
6874
|
+
if (scopes.length !== 1 || scopes[0] !== filePath) {
|
|
6875
|
+
notify(ctx, `${verb} allowed (${choice}): ${scopes.join(", ")}`, "info");
|
|
6876
|
+
}
|
|
6772
6877
|
}
|
|
6773
6878
|
async function applyReadChoice(ctx, choice, filePath, cwd, allowances, scope = sessionScopeFor(filePath, cwd)) {
|
|
6774
|
-
const
|
|
6775
|
-
|
|
6879
|
+
const config = loadConfig(cwd, ctx);
|
|
6880
|
+
const effectiveDenyRead = allowances?.explicitDenyRead ? mergeArray(config.filesystem.denyRead, [
|
|
6776
6881
|
...allowances.explicitDenyRead.patterns,
|
|
6777
6882
|
...[...allowances.explicitDenyRead.globRoots.values()].flat()
|
|
6778
|
-
])
|
|
6779
|
-
|
|
6780
|
-
const configPath =
|
|
6883
|
+
]) : config.filesystem.denyRead;
|
|
6884
|
+
const scopes = readGrantScopesFor(filePath, getEffectiveAllowRead(config, cwd, allowances), effectiveDenyRead, cwd, scope);
|
|
6885
|
+
const configPath = resolvePersistedConfigPath(cwd, choice, ctx);
|
|
6781
6886
|
if (configPath) {
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6887
|
+
for (const entry of scopes) {
|
|
6888
|
+
await addConfigValue(configPath, entry, (cfg) => cfg.filesystem?.allowRead ?? [], (cfg, allowRead) => {
|
|
6889
|
+
cfg.filesystem = { ...cfg.filesystem, allowRead };
|
|
6890
|
+
});
|
|
6891
|
+
}
|
|
6785
6892
|
}
|
|
6786
6893
|
const target = choice === "once" ? allowances?.readPaths : sessionAllowedReadPaths;
|
|
6787
|
-
|
|
6788
|
-
target.
|
|
6789
|
-
|
|
6790
|
-
|
|
6894
|
+
for (const entry of scopes) {
|
|
6895
|
+
if (target && !target.includes(entry))
|
|
6896
|
+
target.push(entry);
|
|
6897
|
+
allowances?.explicitDenyRead?.approvedPaths.push(entry);
|
|
6898
|
+
}
|
|
6899
|
+
noteScope(ctx, "Read", choice, filePath, scopes);
|
|
6791
6900
|
}
|
|
6792
6901
|
async function applyWriteChoice(ctx, choice, filePath, cwd, allowances) {
|
|
6793
|
-
const
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
scope = filePath;
|
|
6797
|
-
}
|
|
6798
|
-
const configPath = choice === "project" ? projectPath : choice === "global" ? globalPath : undefined;
|
|
6902
|
+
const config = loadConfig(cwd, ctx);
|
|
6903
|
+
const scopes = writeGrantScopesFor(filePath, getEffectiveAllowWrite(config, allowances), config.filesystem.denyWrite, cwd);
|
|
6904
|
+
const configPath = resolvePersistedConfigPath(cwd, choice, ctx);
|
|
6799
6905
|
if (configPath) {
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6906
|
+
for (const entry of scopes) {
|
|
6907
|
+
await addConfigValue(configPath, entry, (cfg) => cfg.filesystem?.allowWrite ?? [], (cfg, allowWrite) => {
|
|
6908
|
+
cfg.filesystem = { ...cfg.filesystem, allowWrite };
|
|
6909
|
+
});
|
|
6910
|
+
}
|
|
6803
6911
|
}
|
|
6804
6912
|
const target = choice === "once" ? allowances?.writePaths : sessionAllowedWritePaths;
|
|
6805
|
-
|
|
6806
|
-
target.
|
|
6807
|
-
|
|
6913
|
+
for (const entry of scopes) {
|
|
6914
|
+
if (target && !target.includes(entry))
|
|
6915
|
+
target.push(entry);
|
|
6916
|
+
}
|
|
6917
|
+
noteScope(ctx, "Write", choice, filePath, scopes);
|
|
6808
6918
|
}
|
|
6809
6919
|
async function authorizeFilesystemToolAccess(ctx, accesses, options = {}) {
|
|
6810
6920
|
const normalized = [
|
|
@@ -6820,7 +6930,7 @@ function createLandstripIntegrationWithPrompts(options, permissionPrompts) {
|
|
|
6820
6930
|
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));
|
|
6821
6931
|
};
|
|
6822
6932
|
const current = () => {
|
|
6823
|
-
const config = loadConfig(ctx.cwd);
|
|
6933
|
+
const config = loadConfig(ctx.cwd, ctx);
|
|
6824
6934
|
if (!config.enabled)
|
|
6825
6935
|
return { allowed: true, prompted: false };
|
|
6826
6936
|
for (const access of normalized) {
|
|
@@ -6842,14 +6952,14 @@ function createLandstripIntegrationWithPrompts(options, permissionPrompts) {
|
|
|
6842
6952
|
return { allowed: false, prompted: false, reason: "Filesystem access requires approval" };
|
|
6843
6953
|
}
|
|
6844
6954
|
return permissionPrompts.resolve(current, async (promptSignal) => {
|
|
6845
|
-
const blocked = blockedAccesses(loadConfig(ctx.cwd));
|
|
6955
|
+
const blocked = blockedAccesses(loadConfig(ctx.cwd, ctx));
|
|
6846
6956
|
const paths = blocked.map(({ operation, path }) => `${operation}: ${path}`).join(`
|
|
6847
6957
|
`);
|
|
6848
6958
|
const note = options.authorizationNote ? `
|
|
6849
6959
|
|
|
6850
6960
|
${options.authorizationNote}` : "";
|
|
6851
6961
|
const choice = await showPermissionPrompt(ctx, `Filesystem policy blocked this tool call:
|
|
6852
|
-
${paths}${note}`,
|
|
6962
|
+
${paths}${note}`, permissionOptionsFor(ctx), promptSignal);
|
|
6853
6963
|
if (choice === "abort" || promptSignal.aborted) {
|
|
6854
6964
|
return { allowed: false, prompted: true, reason: "Filesystem access denied" };
|
|
6855
6965
|
}
|
|
@@ -6865,7 +6975,7 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
6865
6975
|
}
|
|
6866
6976
|
async function ensureDomainAllowed(ctx, domain, cwd, allowances, signal) {
|
|
6867
6977
|
const current = () => {
|
|
6868
|
-
const config = loadConfig(cwd);
|
|
6978
|
+
const config = loadConfig(cwd, ctx);
|
|
6869
6979
|
const decision = evaluateDomainAccess(domain, config.network, {
|
|
6870
6980
|
allowedDomainsOverrides: [...sessionAllowedDomains, ...allowances?.domains ?? []]
|
|
6871
6981
|
});
|
|
@@ -6878,21 +6988,24 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
6878
6988
|
if (!ctx.hasUI)
|
|
6879
6989
|
return current() ?? false;
|
|
6880
6990
|
return permissionPrompts.resolve(current, async (promptSignal) => {
|
|
6881
|
-
const choice = await showPermissionPrompt(ctx, `Network blocked: "${domain}" is not in the allowed domains list`,
|
|
6991
|
+
const choice = await showPermissionPrompt(ctx, `Network blocked: "${domain}" is not in the allowed domains list`, permissionOptionsFor(ctx), promptSignal, allowances?.permissionPromptLabel);
|
|
6882
6992
|
if (choice === "abort" || promptSignal.aborted)
|
|
6883
6993
|
return false;
|
|
6884
|
-
await applyDomainChoice(choice, domain, cwd, allowances);
|
|
6994
|
+
await applyDomainChoice(ctx, choice, domain, cwd, allowances);
|
|
6885
6995
|
return true;
|
|
6886
6996
|
}, signal);
|
|
6887
6997
|
}
|
|
6888
|
-
function buildLandstripPolicy(cwd, proxyPort, audience, allowances) {
|
|
6889
|
-
const config = loadConfig(cwd);
|
|
6998
|
+
function buildLandstripPolicy(cwd, proxyPort, audience, allowances, ctx = activeContext) {
|
|
6999
|
+
const config = loadConfig(cwd, ctx);
|
|
6890
7000
|
const readPolicy = resolveProcessReadPolicy(audience, config.shell.readAccess, mergeArray(getEffectiveDenyRead(config, cwd), [
|
|
6891
7001
|
...allowances?.explicitDenyRead?.patterns ?? [],
|
|
6892
7002
|
...[...allowances?.explicitDenyRead?.globRoots.values() ?? []].flat()
|
|
6893
7003
|
]), getEffectiveAllowRead(config, cwd, allowances));
|
|
6894
7004
|
return assembleLandstripPolicy({
|
|
6895
|
-
network:
|
|
7005
|
+
network: {
|
|
7006
|
+
...config.network,
|
|
7007
|
+
allowUnixSockets: mergeAllowances(config.network.allowUnixSockets, sessionAllowedUnixSockets)
|
|
7008
|
+
},
|
|
6896
7009
|
filesystem: {
|
|
6897
7010
|
...readPolicy,
|
|
6898
7011
|
denyReadAlways: mergeArray(config.filesystem.denyReadAlways, allowances?.protectedPaths),
|
|
@@ -6905,13 +7018,13 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
6905
7018
|
httpProxyPort: proxyPort
|
|
6906
7019
|
});
|
|
6907
7020
|
}
|
|
6908
|
-
function writePolicyFile(cwd, proxyPort, audience, allowances) {
|
|
6909
|
-
return writeLandstripPolicyFile(buildLandstripPolicy(cwd, proxyPort, audience, allowances), "pi-landstrip-");
|
|
7021
|
+
function writePolicyFile(cwd, proxyPort, audience, allowances, ctx = activeContext) {
|
|
7022
|
+
return writeLandstripPolicyFile(buildLandstripPolicy(cwd, proxyPort, audience, allowances, ctx), "pi-landstrip-");
|
|
6910
7023
|
}
|
|
6911
7024
|
function startProxy(ctx, cwd, allowances, signal, authorization, portRange) {
|
|
6912
7025
|
return startFilterProxy({
|
|
6913
7026
|
isDomainAllowed: async (domain) => {
|
|
6914
|
-
const config = loadConfig(cwd);
|
|
7027
|
+
const config = loadConfig(cwd, ctx);
|
|
6915
7028
|
if (domainMatchesAny(domain, config.network.deniedDomains))
|
|
6916
7029
|
return false;
|
|
6917
7030
|
return ensureDomainAllowed(ctx, domain, cwd, allowances, signal);
|
|
@@ -6944,19 +7057,36 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
6944
7057
|
async function resolveTrapQuery(trap, ctx, cwd, allowances, promptOnBlock, signal, readScope) {
|
|
6945
7058
|
if (trap.kind !== "filesystem") {
|
|
6946
7059
|
const key = `${trap.operation}\x00${trap.target}`;
|
|
6947
|
-
const
|
|
7060
|
+
const isUnixSocket = isAbsolute4(trap.target);
|
|
7061
|
+
const socketPath = isUnixSocket ? normalizeBlockedPath(trap.target, cwd) : trap.target;
|
|
7062
|
+
const current = () => {
|
|
7063
|
+
if (sessionAllowedTargets.includes(key) || allowances.targets.includes(key)) {
|
|
7064
|
+
return { action: "allow" };
|
|
7065
|
+
}
|
|
7066
|
+
if (isUnixSocket) {
|
|
7067
|
+
const config = loadConfig(cwd, ctx);
|
|
7068
|
+
if (config.network.allowAllUnixSockets || matchesPattern(socketPath, mergeAllowances(config.network.allowUnixSockets, sessionAllowedUnixSockets), cwd)) {
|
|
7069
|
+
return { action: "allow" };
|
|
7070
|
+
}
|
|
7071
|
+
}
|
|
7072
|
+
return;
|
|
7073
|
+
};
|
|
6948
7074
|
const existing = current();
|
|
6949
7075
|
if (existing)
|
|
6950
7076
|
return existing;
|
|
6951
7077
|
if (!ctx.hasUI || !promptOnBlock)
|
|
6952
7078
|
return { action: "deny", reason: "unprompted" };
|
|
6953
7079
|
return permissionPrompts.resolve(current, async (promptSignal) => {
|
|
6954
|
-
const choice = await showPermissionPrompt(ctx, `Network blocked: ${trap.operation} "${trap.target}"`, NETWORK_PERMISSION_OPTIONS, promptSignal, allowances.permissionPromptLabel);
|
|
7080
|
+
const choice = await showPermissionPrompt(ctx, isUnixSocket ? `Unix socket blocked: ${trap.operation} "${socketPath}"` : `Network blocked: ${trap.operation} "${trap.target}"`, isUnixSocket ? permissionOptionsFor(ctx) : NETWORK_PERMISSION_OPTIONS, promptSignal, allowances.permissionPromptLabel);
|
|
6955
7081
|
if (choice === "abort" || promptSignal.aborted)
|
|
6956
7082
|
return { action: "deny", reason: "rejected" };
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
-
|
|
7083
|
+
if (isUnixSocket) {
|
|
7084
|
+
await applyUnixSocketChoice(ctx, choice, socketPath, key, cwd, allowances);
|
|
7085
|
+
} else {
|
|
7086
|
+
const targets = choice === "once" ? allowances.targets : sessionAllowedTargets;
|
|
7087
|
+
if (!targets.includes(key))
|
|
7088
|
+
targets.push(key);
|
|
7089
|
+
}
|
|
6960
7090
|
return { action: "allow" };
|
|
6961
7091
|
}, signal);
|
|
6962
7092
|
}
|
|
@@ -6965,7 +7095,7 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
6965
7095
|
if (matchesPattern(path, allowances.protectedPaths ?? [], cwd)) {
|
|
6966
7096
|
return { action: "deny", reason: "hard-deny" };
|
|
6967
7097
|
}
|
|
6968
|
-
const config = loadConfig(cwd);
|
|
7098
|
+
const config = loadConfig(cwd, ctx);
|
|
6969
7099
|
if (trap.operation === "read" && matchesPattern(path, config.filesystem.denyReadAlways, cwd)) {
|
|
6970
7100
|
return { action: "deny", reason: "hard-deny" };
|
|
6971
7101
|
}
|
|
@@ -6990,7 +7120,7 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
6990
7120
|
if (!ctx.hasUI || !promptOnBlock)
|
|
6991
7121
|
return { action: "deny", reason: "unprompted" };
|
|
6992
7122
|
return permissionPrompts.resolve(current, async (promptSignal) => {
|
|
6993
|
-
const config = loadConfig(cwd);
|
|
7123
|
+
const config = loadConfig(cwd, ctx);
|
|
6994
7124
|
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);
|
|
6995
7125
|
if (choice === "abort" || promptSignal.aborted)
|
|
6996
7126
|
return { action: "deny", reason: "rejected" };
|
|
@@ -7044,7 +7174,7 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
7044
7174
|
if (isFilesystemTrap(trap) && trap.operation === "read" && matchesPattern(normalizeBlockedPath(trap.path, cwd), allowances.protectedPaths ?? [], cwd)) {
|
|
7045
7175
|
continue;
|
|
7046
7176
|
}
|
|
7047
|
-
reportTrapError(
|
|
7177
|
+
reportTrapError(formatLandstripTraps2([trap]));
|
|
7048
7178
|
continue;
|
|
7049
7179
|
}
|
|
7050
7180
|
handleQuery(trap);
|
|
@@ -7116,7 +7246,7 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
7116
7246
|
]
|
|
7117
7247
|
};
|
|
7118
7248
|
const processAllowances = withWindowsProcessReadAccess(allowances, options.command, options.cwd);
|
|
7119
|
-
const config = loadConfig(options.cwd);
|
|
7249
|
+
const config = loadConfig(options.cwd, options.ctx);
|
|
7120
7250
|
const explicitDenyGlobRoots = new Map;
|
|
7121
7251
|
processAllowances.explicitDenyRead = {
|
|
7122
7252
|
patterns: config.explicitDenyRead,
|
|
@@ -7253,7 +7383,7 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
7253
7383
|
};
|
|
7254
7384
|
}
|
|
7255
7385
|
async function prepareProcess(options) {
|
|
7256
|
-
if (process.platform === "win32" && (getNoSandboxFlag() || !loadConfig(options.cwd).enabled)) {
|
|
7386
|
+
if (process.platform === "win32" && (getNoSandboxFlag() || !loadConfig(options.cwd, options.ctx).enabled)) {
|
|
7257
7387
|
throw new Error("Generic process preparation requires sandboxing on Windows");
|
|
7258
7388
|
}
|
|
7259
7389
|
return prepareManagedProcess({
|
|
@@ -7381,7 +7511,7 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
7381
7511
|
if (!existsSync6(cwd))
|
|
7382
7512
|
throw new Error(`Working directory does not exist: ${cwd}`);
|
|
7383
7513
|
const provider = activeShellProvider();
|
|
7384
|
-
const config = loadConfig(cwd);
|
|
7514
|
+
const config = loadConfig(cwd, ctx);
|
|
7385
7515
|
const { token: proxyToken, authorization: proxyAuthorization } = createProxyCredentials();
|
|
7386
7516
|
const proxy = shouldStartProxy(config) ? await startProxy(ctx, cwd, allowances, signal, proxyAuthorization, restrictedUserProxyPortRange()) : null;
|
|
7387
7517
|
let policy;
|
|
@@ -7419,7 +7549,7 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
7419
7549
|
readPaths: [...allowances.readPaths, ...invocation.readPaths ?? []]
|
|
7420
7550
|
};
|
|
7421
7551
|
processAllowances = withWindowsProcessReadAccess(processAllowances, invocation.executable, cwd);
|
|
7422
|
-
policy = writePolicyFile(cwd, proxy?.port ?? null, "shell", processAllowances);
|
|
7552
|
+
policy = writePolicyFile(cwd, proxy?.port ?? null, "shell", processAllowances, ctx);
|
|
7423
7553
|
landstripArgs = ["run", "-p", policy.path];
|
|
7424
7554
|
if (process.platform !== "win32")
|
|
7425
7555
|
landstripArgs.push("--trap", "3");
|
|
@@ -7505,15 +7635,15 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
7505
7635
|
}
|
|
7506
7636
|
const blockedPath = extractTrapBlockedPath(errorFdAcc, cwd) ?? extractNativeDeniedPath(stderrAcc, cwd);
|
|
7507
7637
|
if (!blockedPath && ctx.hasUI) {
|
|
7508
|
-
const traps =
|
|
7638
|
+
const traps = parseLandstripTraps2(errorFdAcc);
|
|
7509
7639
|
const denials = traps.filter(isDenialTrap);
|
|
7510
7640
|
if (denials.length > 0) {
|
|
7511
|
-
const formatted =
|
|
7641
|
+
const formatted = formatLandstripTraps2(denials);
|
|
7512
7642
|
notify(ctx, `Sandbox blocked an operation: ${formatted}`, "warning");
|
|
7513
7643
|
}
|
|
7514
7644
|
const failures = traps.filter((trap) => !isDenialTrap(trap));
|
|
7515
7645
|
if (failures.length > 0) {
|
|
7516
|
-
notify(ctx, `Sandbox failed: ${
|
|
7646
|
+
notify(ctx, `Sandbox failed: ${formatLandstripTraps2(failures)}`, "error");
|
|
7517
7647
|
}
|
|
7518
7648
|
}
|
|
7519
7649
|
resolvePromise({ exitCode: code });
|
|
@@ -7642,15 +7772,15 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
7642
7772
|
});
|
|
7643
7773
|
const run = () => sandboxedBash.execute(id, params, signal, onUpdate, ctx);
|
|
7644
7774
|
const formatTrapErrors = () => {
|
|
7645
|
-
const landstripErrors =
|
|
7775
|
+
const landstripErrors = parseLandstripTraps2(landstripErrorOutput);
|
|
7646
7776
|
if (landstripErrors.length === 0)
|
|
7647
7777
|
return null;
|
|
7648
|
-
return [...new Set(
|
|
7778
|
+
return [...new Set(formatLandstripTraps2(landstripErrors).split(`
|
|
7649
7779
|
`))].join(`
|
|
7650
7780
|
`);
|
|
7651
7781
|
};
|
|
7652
7782
|
const blockedReadPathForRetry = (nativeOutput) => {
|
|
7653
|
-
const config = loadConfig(ctx.cwd);
|
|
7783
|
+
const config = loadConfig(ctx.cwd, ctx);
|
|
7654
7784
|
if (!enforcesShellReadPolicy(config.shell.readAccess))
|
|
7655
7785
|
return null;
|
|
7656
7786
|
const trappedPath = extractTrapBlockedPath(landstripErrorOutput, ctx.cwd, "read");
|
|
@@ -7664,7 +7794,7 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
7664
7794
|
const { globalPath, projectPath } = getPiConfigPaths(ctx.cwd, "sandbox.json");
|
|
7665
7795
|
const isWriteDeniedAlways = (config) => matchesWriteDenyPattern(blockedPath, config.filesystem.denyWriteAlways, ctx.cwd, getEffectiveAllowWrite(config, allowances));
|
|
7666
7796
|
const current = () => {
|
|
7667
|
-
const config = loadConfig(ctx.cwd);
|
|
7797
|
+
const config = loadConfig(ctx.cwd, ctx);
|
|
7668
7798
|
if (operation === "read" ? matchesPattern(blockedPath, config.filesystem.denyReadAlways, ctx.cwd) : isWriteDeniedAlways(config)) {
|
|
7669
7799
|
return false;
|
|
7670
7800
|
}
|
|
@@ -7672,7 +7802,7 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
7672
7802
|
return needsPrompt ? undefined : true;
|
|
7673
7803
|
};
|
|
7674
7804
|
const access = await permissionPrompts.resolve(current, async (promptSignal) => {
|
|
7675
|
-
const config = loadConfig(ctx.cwd);
|
|
7805
|
+
const config = loadConfig(ctx.cwd, ctx);
|
|
7676
7806
|
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);
|
|
7677
7807
|
if (choice === "abort" || promptSignal.aborted)
|
|
7678
7808
|
return false;
|
|
@@ -7684,7 +7814,7 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
7684
7814
|
return true;
|
|
7685
7815
|
}, signal);
|
|
7686
7816
|
if (!access) {
|
|
7687
|
-
const config = loadConfig(ctx.cwd);
|
|
7817
|
+
const config = loadConfig(ctx.cwd, ctx);
|
|
7688
7818
|
if (operation === "write" && isWriteDeniedAlways(config)) {
|
|
7689
7819
|
notify(ctx, `"${blockedPath}" is blocked by denyWriteAlways. Check:
|
|
7690
7820
|
${projectPath}
|
|
@@ -7692,7 +7822,7 @@ ${paths}${note}`, PERMISSION_OPTIONS, promptSignal);
|
|
|
7692
7822
|
}
|
|
7693
7823
|
return null;
|
|
7694
7824
|
}
|
|
7695
|
-
const config = loadConfig(ctx.cwd);
|
|
7825
|
+
const config = loadConfig(ctx.cwd, ctx);
|
|
7696
7826
|
if (operation === "write" && isWriteDeniedAlways(config)) {
|
|
7697
7827
|
notify(ctx, `"${blockedPath}" was added to allowWrite, but denyWriteAlways still blocks it. Check:
|
|
7698
7828
|
${projectPath}
|
|
@@ -7829,7 +7959,7 @@ ${trapMessage}
|
|
|
7829
7959
|
}
|
|
7830
7960
|
}
|
|
7831
7961
|
function enableSandbox(ctx) {
|
|
7832
|
-
const config = loadConfig(ctx.cwd);
|
|
7962
|
+
const config = loadConfig(ctx.cwd, ctx);
|
|
7833
7963
|
if (!SUPPORTED_PLATFORMS.has(process.platform)) {
|
|
7834
7964
|
sandboxEnabled = false;
|
|
7835
7965
|
sandboxReady = false;
|
|
@@ -7858,7 +7988,7 @@ ${trapMessage}
|
|
|
7858
7988
|
disableSandbox(ctx);
|
|
7859
7989
|
return false;
|
|
7860
7990
|
}
|
|
7861
|
-
const config = loadConfig(ctx.cwd);
|
|
7991
|
+
const config = loadConfig(ctx.cwd, ctx);
|
|
7862
7992
|
if (!config.enabled) {
|
|
7863
7993
|
disableSandbox(ctx);
|
|
7864
7994
|
return false;
|
|
@@ -7961,10 +8091,10 @@ ${trapMessage}
|
|
|
7961
8091
|
sessionAllowedDomains.length = 0;
|
|
7962
8092
|
sessionAllowedReadPaths.length = 0;
|
|
7963
8093
|
sessionAllowedWritePaths.length = 0;
|
|
8094
|
+
sessionAllowedUnixSockets.length = 0;
|
|
7964
8095
|
sessionAllowedTargets.length = 0;
|
|
7965
8096
|
unsandboxedWorkerWarningShown = false;
|
|
7966
|
-
|
|
7967
|
-
projectConfigTrusted = trustContext.isProjectTrusted?.() ?? false;
|
|
8097
|
+
projectConfigTrusted = isProjectTrusted(ctx);
|
|
7968
8098
|
if (getNoSandboxFlag()) {
|
|
7969
8099
|
disableSandbox(ctx);
|
|
7970
8100
|
notify(ctx, "Sandbox disabled via --no-sandbox", "warning");
|
|
@@ -7972,7 +8102,7 @@ ${trapMessage}
|
|
|
7972
8102
|
unpublishRuntime = publishLandstripRuntime(pi, integration);
|
|
7973
8103
|
return;
|
|
7974
8104
|
}
|
|
7975
|
-
const config = loadConfig(ctx.cwd);
|
|
8105
|
+
const config = loadConfig(ctx.cwd, ctx);
|
|
7976
8106
|
if (!config.enabled) {
|
|
7977
8107
|
disableSandbox(ctx);
|
|
7978
8108
|
notify(ctx, "Sandbox disabled via config", "info");
|
|
@@ -7993,7 +8123,7 @@ ${trapMessage}
|
|
|
7993
8123
|
}
|
|
7994
8124
|
async function applySandboxSetting(ctx, enabled, scope) {
|
|
7995
8125
|
await writeSandboxConfigEnabled(ctx.cwd, enabled, scope);
|
|
7996
|
-
const effectiveEnabled = loadConfig(ctx.cwd).enabled;
|
|
8126
|
+
const effectiveEnabled = loadConfig(ctx.cwd, ctx).enabled;
|
|
7997
8127
|
if (!effectiveEnabled) {
|
|
7998
8128
|
disableSandbox(ctx);
|
|
7999
8129
|
} else if (!getNoSandboxFlag()) {
|
|
@@ -8042,7 +8172,17 @@ ${trapMessage}
|
|
|
8042
8172
|
register,
|
|
8043
8173
|
emit: emitEvent,
|
|
8044
8174
|
runSandboxedCommand(command, cwd, execOptions, ctx) {
|
|
8045
|
-
const
|
|
8175
|
+
const allowances = {
|
|
8176
|
+
permissionPromptLabel: execOptions.permissionPromptLabel,
|
|
8177
|
+
domains: [],
|
|
8178
|
+
readPaths: [],
|
|
8179
|
+
writePaths: [],
|
|
8180
|
+
targets: []
|
|
8181
|
+
};
|
|
8182
|
+
const ops = ensureSandboxState(ctx) ? createLandstripBashOps(ctx, {
|
|
8183
|
+
promptOnBlock: execOptions.promptOnBlock ?? false,
|
|
8184
|
+
onErrorFd: execOptions.onErrorFd
|
|
8185
|
+
}, allowances) : externalShellProvider !== undefined ? createProviderBashOps() : createLocalBashOperations();
|
|
8046
8186
|
return ops.exec(command, cwd, {
|
|
8047
8187
|
onData: execOptions.onData ?? (() => {}),
|
|
8048
8188
|
signal: execOptions.signal,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-landstrip",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.17",
|
|
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.17",
|
|
43
43
|
"jsonc-parser": "^3.3.1",
|
|
44
44
|
"minimatch": "^10.2.5",
|
|
45
45
|
"undici": "^8.9.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@earendil-works/pi-coding-agent": "^1.0.4",
|
|
51
51
|
"@earendil-works/pi-tui": "^1.0.4",
|
|
52
52
|
"@types/node": "^26.4.1",
|
|
53
|
-
"oxfmt": "^0.
|
|
53
|
+
"oxfmt": "^0.75.0",
|
|
54
54
|
"oxlint": "^1.68.0",
|
|
55
55
|
"typebox": "^1.3.6",
|
|
56
56
|
"typescript": "^5.0.0",
|