@deathbeam/pi-delegate 0.0.17 → 0.0.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 +4 -2
- package/index.ts +21 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Optional `delegate` settings live in `~/.pi/agent/settings.json` or `.pi/setting
|
|
|
20
20
|
"delegate": {
|
|
21
21
|
"agentDirs": ["./.pi/agents"],
|
|
22
22
|
"models": {
|
|
23
|
-
"cheap": "anthropic/claude-haiku-latest",
|
|
23
|
+
"cheap": { "model": "anthropic/claude-haiku-latest", "thinking": "low" },
|
|
24
24
|
"balanced": "anthropic/claude-sonnet-latest",
|
|
25
25
|
"strong": "anthropic/claude-opus-latest"
|
|
26
26
|
}
|
|
@@ -29,7 +29,9 @@ Optional `delegate` settings live in `~/.pi/agent/settings.json` or `.pi/setting
|
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
Relative `agentDirs` resolve against the project cwd, later same-name definitions win. Project `models` override global
|
|
32
|
-
tiers (`cheap`, `balanced`, `strong`)
|
|
32
|
+
tiers (`cheap`, `balanced`, `strong`); a tier is a `provider/model` string or a `{ "model": "...", "thinking": "..." }`
|
|
33
|
+
object, otherwise the child uses the current session model and thinking level. Thinking resolves from the agent
|
|
34
|
+
frontmatter first, then the tier entry, then the session level.
|
|
33
35
|
|
|
34
36
|
Agents are Markdown files with frontmatter, the body becomes the child's system prompt:
|
|
35
37
|
|
package/index.ts
CHANGED
|
@@ -173,15 +173,21 @@ function discoverAgents(cwd: string, configuredDirs: unknown): AgentFile[] {
|
|
|
173
173
|
return [...agents.values()];
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
function resolveModel(
|
|
176
|
+
export function resolveModel(
|
|
177
177
|
value: string | undefined,
|
|
178
178
|
models: Record<string, unknown>,
|
|
179
179
|
current: ExtensionContext["model"],
|
|
180
|
-
): string
|
|
181
|
-
if (value && !MODEL_TIERS.has(value)) return value;
|
|
180
|
+
): { model?: string; thinking?: string } {
|
|
181
|
+
if (value && !MODEL_TIERS.has(value)) return { model: value };
|
|
182
182
|
const configured = value ? models[value] : undefined;
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
const entry =
|
|
184
|
+
configured && typeof configured === "object"
|
|
185
|
+
? (configured as { model?: unknown; thinking?: unknown })
|
|
186
|
+
: undefined;
|
|
187
|
+
const model = typeof configured === "string" ? configured : typeof entry?.model === "string" ? entry.model : "";
|
|
188
|
+
// Tier thinking only applies when the model itself came from the tier entry.
|
|
189
|
+
if (model) return { model, thinking: typeof entry?.thinking === "string" ? entry.thinking : undefined };
|
|
190
|
+
return { model: current ? `${current.provider}/${current.id}` : undefined };
|
|
185
191
|
}
|
|
186
192
|
|
|
187
193
|
function contextWindowFor(ctx: ExtensionContext, model: string | undefined): number | undefined {
|
|
@@ -547,7 +553,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
547
553
|
const footer = truncateToWidth(
|
|
548
554
|
theme.fg(
|
|
549
555
|
"dim",
|
|
550
|
-
`${keyHint("tui.select.up", "
|
|
556
|
+
`${keyHint("tui.select.up", "up")} · ${keyHint("tui.select.down", "down")} · ${rawKeyHint("←/→", "switch pane")} · ${keyHint("tui.select.cancel", "close")}`,
|
|
551
557
|
),
|
|
552
558
|
width,
|
|
553
559
|
);
|
|
@@ -595,7 +601,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
595
601
|
},
|
|
596
602
|
handleInput(data: string) {
|
|
597
603
|
if (keys.matches(data, "tui.select.cancel")) done(undefined);
|
|
598
|
-
else if (matchesKey(data, "tab")) focus = focus === "list" ? "history" : "list";
|
|
599
604
|
else if (matchesKey(data, "left")) focus = "list";
|
|
600
605
|
else if (
|
|
601
606
|
matchesKey(data, "right") ||
|
|
@@ -683,17 +688,23 @@ export default function (pi: ExtensionAPI) {
|
|
|
683
688
|
const names = agents.map((candidate) => candidate.name).join(", ") || "(none)";
|
|
684
689
|
throw new Error(`Unknown agent "${params.agent}". Available agents: ${names}.`);
|
|
685
690
|
}
|
|
686
|
-
const
|
|
691
|
+
const { model, thinking: tierThinking } = resolveModel(
|
|
692
|
+
params.model ?? agent.model,
|
|
693
|
+
config.models ?? {},
|
|
694
|
+
ctx.model,
|
|
695
|
+
);
|
|
687
696
|
if (!model) throw new Error(`No model found for "${params.agent}".`);
|
|
688
697
|
const tools = (agent.tools?.length ? agent.tools : pi.getActiveTools()).filter(
|
|
689
698
|
(tool) => !DELEGATION_TOOLS.has(tool),
|
|
690
699
|
);
|
|
700
|
+
const thinking = agent.thinking ?? tierThinking ?? ctx.thinkingLevel;
|
|
701
|
+
const displayModel = thinking ? `${model}:${thinking}` : model;
|
|
691
702
|
const job: DelegateJob = {
|
|
692
703
|
id: randomUUID().slice(0, 8),
|
|
693
704
|
agent: agent.name,
|
|
694
705
|
description: params.description.trim(),
|
|
695
706
|
task: params.task,
|
|
696
|
-
model,
|
|
707
|
+
model: displayModel,
|
|
697
708
|
status: "running",
|
|
698
709
|
activity: [],
|
|
699
710
|
tools,
|
|
@@ -707,13 +718,11 @@ export default function (pi: ExtensionAPI) {
|
|
|
707
718
|
agent: job.agent,
|
|
708
719
|
description: job.description,
|
|
709
720
|
task: job.task,
|
|
710
|
-
model,
|
|
721
|
+
model: displayModel,
|
|
711
722
|
tools,
|
|
712
|
-
// Only a UI can deliver a result that arrives after the tool returned; headless runs must block.
|
|
713
723
|
background: ctx.hasUI,
|
|
714
724
|
};
|
|
715
725
|
const args = ["--model", model, "--tools", tools.join(",")];
|
|
716
|
-
const thinking = agent.thinking ?? ctx.thinkingLevel;
|
|
717
726
|
if (thinking) args.push("--thinking", thinking);
|
|
718
727
|
if (agent.prompt) args.push("--append-system-prompt", agent.prompt);
|
|
719
728
|
const entrypoint = process.argv[1];
|
|
@@ -741,8 +750,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
741
750
|
running.set(job.id, job);
|
|
742
751
|
if (!ticker) ticker = setInterval(() => refreshWidget(ctx), SPINNER_INTERVAL_MS);
|
|
743
752
|
refreshWidget(ctx);
|
|
744
|
-
// The only failure left here is reporting into a session that is being torn down,
|
|
745
|
-
// and an unhandled rejection would crash pi.
|
|
746
753
|
void run.done
|
|
747
754
|
.then(
|
|
748
755
|
(output) => finishJob(ctx, job, output),
|