@skydiveai/pi-extensions 0.1.0-beta.428 → 0.1.0-beta.434
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/dist/index.mjs +21 -6
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1769,7 +1769,11 @@ async function postSubagentSpawn({ messageId, tasks }) {
|
|
|
1769
1769
|
tasks
|
|
1770
1770
|
} });
|
|
1771
1771
|
if (!res.ok) throw new Error(`subagent-spawn POST failed: ${res.status}`);
|
|
1772
|
-
|
|
1772
|
+
const body = await res.json();
|
|
1773
|
+
return {
|
|
1774
|
+
taskIds: body.taskIds,
|
|
1775
|
+
tasks: body.tasks ?? []
|
|
1776
|
+
};
|
|
1773
1777
|
}
|
|
1774
1778
|
function createHeartbeatThrottle({ messageId }) {
|
|
1775
1779
|
let lastAt = 0;
|
|
@@ -2786,7 +2790,8 @@ function buildTool(messageId) {
|
|
|
2786
2790
|
"Delegate one or more tasks to subagent runs — fresh isolated copies of yourself, each with its own context window, linked to this conversation.",
|
|
2787
2791
|
"Use it to parallelize independent work, to keep a large or noisy subtask out of your own context, or to run a task under a specialized persona.",
|
|
2788
2792
|
"Fire-and-forget: this returns immediately after queueing. It does NOT wait for results. Each subagent runs on its own and, when it finishes, sends you its result on this thread — so queue the work, then keep going or end your turn. To chain, re-delegate after a result lands.",
|
|
2789
|
-
"Pass tasks: [{ task, title, persona?, model? }]. title is a short 3-6 word name for the task — it is shown to the person in the chat as that subagent's row, so name the work rather than restating the prompt. persona is an optional extra system prompt layered ON TOP of your default persona for that task (it adds to, it does not replace, your identity); omit it to run with just your default persona. model is an optional model id for that task — prefer a lower-cost, faster model for well-scoped subtasks that don't need deep reasoning, and reserve a top-tier model for the ones that do; omit it to inherit your own model."
|
|
2793
|
+
"Pass tasks: [{ task, title, persona?, model? }]. title is a short 3-6 word name for the task — it is shown to the person in the chat as that subagent's row, so name the work rather than restating the prompt. persona is an optional extra system prompt layered ON TOP of your default persona for that task (it adds to, it does not replace, your identity); omit it to run with just your default persona. model is an optional model id for that task — prefer a lower-cost, faster model for well-scoped subtasks that don't need deep reasoning, and reserve a top-tier model for the ones that do; omit it to inherit your own model.",
|
|
2794
|
+
"Peering: each queued task comes back with its own conversation id. A subagent is a real linked conversation, so to see what one is doing RIGHT NOW while it runs — its reasoning, the tools it has called and their results, its progress — read that conversation with `platform conversations show <conversationId>` (you are already authorized; it is your own delegated run). Check in that way instead of waiting blind for the final result. The read reflects the child's persisted state, which lags a few seconds behind live (tool results land as they complete; in-progress reasoning can be up to ~5s stale), so peek between checkpoints rather than polling in a tight loop."
|
|
2790
2795
|
].join(" "),
|
|
2791
2796
|
promptSnippet: "subagent — delegate tasks to isolated subagent runs; each rewakes you with its result when done",
|
|
2792
2797
|
parameters: SubagentParams,
|
|
@@ -2808,21 +2813,31 @@ function buildTool(messageId) {
|
|
|
2808
2813
|
timeoutMs: t.timeoutMinutes != null ? t.timeoutMinutes * 6e4 : DEFAULT_SUBAGENT_TIMEOUT_MS
|
|
2809
2814
|
}));
|
|
2810
2815
|
try {
|
|
2811
|
-
const
|
|
2816
|
+
const spawned = await postSubagentSpawn({
|
|
2812
2817
|
messageId,
|
|
2813
2818
|
tasks: spawnTasks
|
|
2814
2819
|
});
|
|
2820
|
+
const { taskIds } = spawned;
|
|
2815
2821
|
log$2.info({
|
|
2816
2822
|
event: "subagent_spawned",
|
|
2817
2823
|
count: taskIds.length
|
|
2818
2824
|
}, "subagent tasks queued");
|
|
2819
|
-
const
|
|
2825
|
+
const convByTask = new Map(spawned.tasks.map((t) => [t.taskId, t.conversationId]));
|
|
2826
|
+
const lines = taskIds.map((id, i) => {
|
|
2827
|
+
const label = spawnTasks[i]?.title ?? spawnTasks[i]?.task ?? "";
|
|
2828
|
+
const conv = convByTask.get(id);
|
|
2829
|
+
return `- ${id}: ${label}${conv ? ` — peek: conversations show ${conv}` : ""}`;
|
|
2830
|
+
}).join("\n");
|
|
2831
|
+
const peerHint = spawned.tasks.length ? "\nTo see what a subagent is doing while it runs, read its conversation with `platform conversations show <conversationId>` (shown per task above)." : "";
|
|
2820
2832
|
return {
|
|
2821
2833
|
content: [{
|
|
2822
2834
|
type: "text",
|
|
2823
|
-
text: `Queued ${taskIds.length} subagent ${taskIds.length === 1 ? "run" : "runs"}. Each runs on its own and will send you its result on this thread when it finishes — keep working or end your turn meanwhile.\n${lines}`
|
|
2835
|
+
text: `Queued ${taskIds.length} subagent ${taskIds.length === 1 ? "run" : "runs"}. Each runs on its own and will send you its result on this thread when it finishes — keep working or end your turn meanwhile.\n${lines}${peerHint}`
|
|
2824
2836
|
}],
|
|
2825
|
-
details: {
|
|
2837
|
+
details: {
|
|
2838
|
+
taskIds,
|
|
2839
|
+
tasks: spawned.tasks
|
|
2840
|
+
}
|
|
2826
2841
|
};
|
|
2827
2842
|
} catch (err) {
|
|
2828
2843
|
const message = err instanceof Error ? err.message : String(err);
|