pi-landstrip 0.20.16 → 0.20.18
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 +65 -18
- package/package.json +2 -2
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
|
@@ -2483,6 +2483,39 @@ function paneRow(_theme, width, content = "") {
|
|
|
2483
2483
|
return ` ${line}${" ".repeat(Math.max(0, width - visibleWidth(line) - 1))}`;
|
|
2484
2484
|
}
|
|
2485
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
|
+
}
|
|
2486
2519
|
var SANDBOX_HELP_ROWS = [
|
|
2487
2520
|
["Tab", "Next tab"],
|
|
2488
2521
|
["↑ / ↓", "Scroll when content exceeds pane height"],
|
|
@@ -2596,6 +2629,9 @@ var taskParameters = Type.Object({
|
|
|
2596
2629
|
description: Type.String({ description: "Short task label (3-5 words)" }),
|
|
2597
2630
|
prompt: Type.String({ description: "Full instructions for the subagent" }),
|
|
2598
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
|
+
})),
|
|
2599
2635
|
task_id: Type.Optional(Type.String({ description: "Task ID to resume" })),
|
|
2600
2636
|
command: Type.Optional(Type.String({ description: "Originating command, if any" })),
|
|
2601
2637
|
background: Type.Optional(Type.Boolean({
|
|
@@ -4893,9 +4929,7 @@ ${outputText}` }
|
|
|
4893
4929
|
}, ctx);
|
|
4894
4930
|
const traps = parseLandstripTraps(trapBuffer);
|
|
4895
4931
|
if (traps.length > 0) {
|
|
4896
|
-
const formatted =
|
|
4897
|
-
`))].join(`
|
|
4898
|
-
`);
|
|
4932
|
+
const formatted = formatLandstripTraps(traps);
|
|
4899
4933
|
try {
|
|
4900
4934
|
writeSync(outputFd, Buffer.from(`${formatted}
|
|
4901
4935
|
`, "utf8"));
|
|
@@ -5081,15 +5115,21 @@ ${catalog.diagnostics.join(`
|
|
|
5081
5115
|
}
|
|
5082
5116
|
if (catalog.maxSubagents === 0)
|
|
5083
5117
|
throw new Error("Subagents are disabled by maxSubagents: 0");
|
|
5084
|
-
const
|
|
5085
|
-
if (!
|
|
5118
|
+
const baseAgent = catalog.agents.get(input.subagent_type);
|
|
5119
|
+
if (!baseAgent || baseAgent.disabled || baseAgent.mode === "primary")
|
|
5086
5120
|
throw new Error(`Unknown subagent: ${input.subagent_type}`);
|
|
5121
|
+
if (input.model !== undefined && input.task_id) {
|
|
5122
|
+
throw new Error("Cannot change the model when resuming a task (model with task_id)");
|
|
5123
|
+
}
|
|
5124
|
+
const requestedOverride = input.model !== undefined ? parseTaskModelOverride(input.model) : undefined;
|
|
5125
|
+
if (requestedOverride)
|
|
5126
|
+
assertOverrideModelUsable(ctx, requestedOverride.model);
|
|
5087
5127
|
const rules = callerRules ?? catalog.permissions;
|
|
5088
|
-
const taskPermission = permissionDecision(rules, "task",
|
|
5128
|
+
const taskPermission = permissionDecision(rules, "task", baseAgent.name);
|
|
5089
5129
|
if (taskPermission === "deny")
|
|
5090
|
-
throw new Error(`Task permission denied for ${
|
|
5130
|
+
throw new Error(`Task permission denied for ${baseAgent.name}`);
|
|
5091
5131
|
if (taskPermission === "ask") {
|
|
5092
|
-
await this.broker.ask(ctx, input.description, "task",
|
|
5132
|
+
await this.broker.ask(ctx, input.description, "task", baseAgent.name, signal, {
|
|
5093
5133
|
context: parentTask ? this.taskContext(parentTask, ctx) : this.permissionContext(ctx),
|
|
5094
5134
|
toolName: "task",
|
|
5095
5135
|
input: { ...input },
|
|
@@ -5111,15 +5151,19 @@ ${catalog.diagnostics.join(`
|
|
|
5111
5151
|
if (task.parentTaskId !== parentTask?.id) {
|
|
5112
5152
|
throw new Error(`Task ${task.id} does not belong to this parent task`);
|
|
5113
5153
|
}
|
|
5114
|
-
if (task.agent !==
|
|
5115
|
-
throw new Error(`Task ${task.id} belongs to agent ${task.agent}, not ${
|
|
5154
|
+
if (task.agent !== baseAgent.name) {
|
|
5155
|
+
throw new Error(`Task ${task.id} belongs to agent ${task.agent}, not ${baseAgent.name}`);
|
|
5116
5156
|
}
|
|
5117
5157
|
if (!this.running.has(task.id) && (!task.sessionDir || !existsSync5(task.sessionDir)) && (!task.sessionFile || !existsSync5(task.sessionFile))) {
|
|
5118
5158
|
throw new Error(`Task ${task.id} session is unavailable`);
|
|
5119
5159
|
}
|
|
5120
5160
|
} else {
|
|
5121
|
-
task = this.createRecord(input, ctx, parentTask,
|
|
5161
|
+
task = this.createRecord(input, ctx, parentTask, baseAgent, depth, requestedOverride);
|
|
5122
5162
|
}
|
|
5163
|
+
const override = task.kind === "command" ? undefined : task.modelOverride;
|
|
5164
|
+
if (input.task_id && override)
|
|
5165
|
+
assertOverrideModelUsable(ctx, override.model);
|
|
5166
|
+
const agent = override ? { ...baseAgent, model: override.model, variant: override.variant } : baseAgent;
|
|
5123
5167
|
const existingRun = this.runPromises.get(task.id);
|
|
5124
5168
|
if (input.task_id)
|
|
5125
5169
|
task.delivered = false;
|
|
@@ -5258,7 +5302,7 @@ ${bounded}
|
|
|
5258
5302
|
|
|
5259
5303
|
${prompt}`;
|
|
5260
5304
|
}
|
|
5261
|
-
createRecord(input, ctx, parentTask, agent, depth) {
|
|
5305
|
+
createRecord(input, ctx, parentTask, agent, depth, modelOverride) {
|
|
5262
5306
|
const parentSession = parentTask?.sessionFile ?? ctx.sessionManager.getSessionFile();
|
|
5263
5307
|
const id = randomUUID();
|
|
5264
5308
|
const sessionDir = join7(getAgentDir4(), "sessions", "pi-landstrip", ctx.sessionManager.getSessionId(), id);
|
|
@@ -5274,7 +5318,8 @@ ${prompt}`;
|
|
|
5274
5318
|
description: input.description,
|
|
5275
5319
|
depth,
|
|
5276
5320
|
state: "queued",
|
|
5277
|
-
background: input.background === true
|
|
5321
|
+
background: input.background === true,
|
|
5322
|
+
modelOverride
|
|
5278
5323
|
};
|
|
5279
5324
|
this.tasks.set(task.id, task);
|
|
5280
5325
|
this.persist(task);
|
|
@@ -5460,7 +5505,7 @@ ${prompt}`;
|
|
|
5460
5505
|
const endpoint = await workerEndpoint(ctx, model, agent.name, signal);
|
|
5461
5506
|
if (signal.aborted)
|
|
5462
5507
|
throw new Error("Task cancelled");
|
|
5463
|
-
const thinking = agent.variant && PI_THINKING_LEVELS.has(agent.variant) ? agent.variant : this.pi.getThinkingLevel();
|
|
5508
|
+
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();
|
|
5464
5509
|
if (agent.variant && !PI_THINKING_LEVELS.has(agent.variant)) {
|
|
5465
5510
|
ctx.ui.notify(`Agent ${agent.name} uses unsupported Pi model variant: ${agent.variant}`, "warning");
|
|
5466
5511
|
}
|
|
@@ -7089,7 +7134,11 @@ ${paths}${note}`, permissionOptionsFor(ctx), promptSignal);
|
|
|
7089
7134
|
const decoder = new StringDecoder3("utf8");
|
|
7090
7135
|
let buffer = "";
|
|
7091
7136
|
let prompts = Promise.resolve();
|
|
7137
|
+
const reportedErrors = new Set;
|
|
7092
7138
|
const reportTrapError = (message) => {
|
|
7139
|
+
if (reportedErrors.has(message))
|
|
7140
|
+
return;
|
|
7141
|
+
reportedErrors.add(message);
|
|
7093
7142
|
notify(ctx, message, "error");
|
|
7094
7143
|
if (!ctx.hasUI)
|
|
7095
7144
|
console.error(`pi-landstrip: ${message}`);
|
|
@@ -7124,7 +7173,7 @@ ${paths}${note}`, permissionOptionsFor(ctx), promptSignal);
|
|
|
7124
7173
|
if (!trap)
|
|
7125
7174
|
continue;
|
|
7126
7175
|
if (!isQueryTrap(trap)) {
|
|
7127
|
-
if (isFilesystemTrap(trap) &&
|
|
7176
|
+
if (isFilesystemTrap(trap) && matchesPattern(normalizeBlockedPath(trap.path, cwd), allowances.protectedPaths ?? [], cwd)) {
|
|
7128
7177
|
continue;
|
|
7129
7178
|
}
|
|
7130
7179
|
reportTrapError(formatLandstripTraps2([trap]));
|
|
@@ -7728,9 +7777,7 @@ ${paths}${note}`, permissionOptionsFor(ctx), promptSignal);
|
|
|
7728
7777
|
const landstripErrors = parseLandstripTraps2(landstripErrorOutput);
|
|
7729
7778
|
if (landstripErrors.length === 0)
|
|
7730
7779
|
return null;
|
|
7731
|
-
return
|
|
7732
|
-
`))].join(`
|
|
7733
|
-
`);
|
|
7780
|
+
return formatLandstripTraps2(landstripErrors);
|
|
7734
7781
|
};
|
|
7735
7782
|
const blockedReadPathForRetry = (nativeOutput) => {
|
|
7736
7783
|
const config = loadConfig(ctx.cwd, ctx);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-landstrip",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.18",
|
|
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.18",
|
|
43
43
|
"jsonc-parser": "^3.3.1",
|
|
44
44
|
"minimatch": "^10.2.5",
|
|
45
45
|
"undici": "^8.9.0",
|