pi-landstrip 0.20.16 → 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 +58 -11
- 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({
|
|
@@ -5081,15 +5117,21 @@ ${catalog.diagnostics.join(`
|
|
|
5081
5117
|
}
|
|
5082
5118
|
if (catalog.maxSubagents === 0)
|
|
5083
5119
|
throw new Error("Subagents are disabled by maxSubagents: 0");
|
|
5084
|
-
const
|
|
5085
|
-
if (!
|
|
5120
|
+
const baseAgent = catalog.agents.get(input.subagent_type);
|
|
5121
|
+
if (!baseAgent || baseAgent.disabled || baseAgent.mode === "primary")
|
|
5086
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);
|
|
5087
5129
|
const rules = callerRules ?? catalog.permissions;
|
|
5088
|
-
const taskPermission = permissionDecision(rules, "task",
|
|
5130
|
+
const taskPermission = permissionDecision(rules, "task", baseAgent.name);
|
|
5089
5131
|
if (taskPermission === "deny")
|
|
5090
|
-
throw new Error(`Task permission denied for ${
|
|
5132
|
+
throw new Error(`Task permission denied for ${baseAgent.name}`);
|
|
5091
5133
|
if (taskPermission === "ask") {
|
|
5092
|
-
await this.broker.ask(ctx, input.description, "task",
|
|
5134
|
+
await this.broker.ask(ctx, input.description, "task", baseAgent.name, signal, {
|
|
5093
5135
|
context: parentTask ? this.taskContext(parentTask, ctx) : this.permissionContext(ctx),
|
|
5094
5136
|
toolName: "task",
|
|
5095
5137
|
input: { ...input },
|
|
@@ -5111,15 +5153,19 @@ ${catalog.diagnostics.join(`
|
|
|
5111
5153
|
if (task.parentTaskId !== parentTask?.id) {
|
|
5112
5154
|
throw new Error(`Task ${task.id} does not belong to this parent task`);
|
|
5113
5155
|
}
|
|
5114
|
-
if (task.agent !==
|
|
5115
|
-
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}`);
|
|
5116
5158
|
}
|
|
5117
5159
|
if (!this.running.has(task.id) && (!task.sessionDir || !existsSync5(task.sessionDir)) && (!task.sessionFile || !existsSync5(task.sessionFile))) {
|
|
5118
5160
|
throw new Error(`Task ${task.id} session is unavailable`);
|
|
5119
5161
|
}
|
|
5120
5162
|
} else {
|
|
5121
|
-
task = this.createRecord(input, ctx, parentTask,
|
|
5163
|
+
task = this.createRecord(input, ctx, parentTask, baseAgent, depth, requestedOverride);
|
|
5122
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;
|
|
5123
5169
|
const existingRun = this.runPromises.get(task.id);
|
|
5124
5170
|
if (input.task_id)
|
|
5125
5171
|
task.delivered = false;
|
|
@@ -5258,7 +5304,7 @@ ${bounded}
|
|
|
5258
5304
|
|
|
5259
5305
|
${prompt}`;
|
|
5260
5306
|
}
|
|
5261
|
-
createRecord(input, ctx, parentTask, agent, depth) {
|
|
5307
|
+
createRecord(input, ctx, parentTask, agent, depth, modelOverride) {
|
|
5262
5308
|
const parentSession = parentTask?.sessionFile ?? ctx.sessionManager.getSessionFile();
|
|
5263
5309
|
const id = randomUUID();
|
|
5264
5310
|
const sessionDir = join7(getAgentDir4(), "sessions", "pi-landstrip", ctx.sessionManager.getSessionId(), id);
|
|
@@ -5274,7 +5320,8 @@ ${prompt}`;
|
|
|
5274
5320
|
description: input.description,
|
|
5275
5321
|
depth,
|
|
5276
5322
|
state: "queued",
|
|
5277
|
-
background: input.background === true
|
|
5323
|
+
background: input.background === true,
|
|
5324
|
+
modelOverride
|
|
5278
5325
|
};
|
|
5279
5326
|
this.tasks.set(task.id, task);
|
|
5280
5327
|
this.persist(task);
|
|
@@ -5460,7 +5507,7 @@ ${prompt}`;
|
|
|
5460
5507
|
const endpoint = await workerEndpoint(ctx, model, agent.name, signal);
|
|
5461
5508
|
if (signal.aborted)
|
|
5462
5509
|
throw new Error("Task cancelled");
|
|
5463
|
-
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();
|
|
5464
5511
|
if (agent.variant && !PI_THINKING_LEVELS.has(agent.variant)) {
|
|
5465
5512
|
ctx.ui.notify(`Agent ${agent.name} uses unsupported Pi model variant: ${agent.variant}`, "warning");
|
|
5466
5513
|
}
|
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",
|