@maheidem/pi-delegate 0.6.2 → 0.6.3
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/background.ts +7 -14
- package/index.ts +2 -2
- package/package.json +1 -1
package/background.ts
CHANGED
|
@@ -150,11 +150,9 @@ export function formatBackgroundResultEnvelope(
|
|
|
150
150
|
runText: string,
|
|
151
151
|
): string {
|
|
152
152
|
return (
|
|
153
|
-
|
|
153
|
+
`### [delegate background ${runId} · ${role} · ${description}: ${backgroundStateWord(state)}]\n` +
|
|
154
154
|
"\n" +
|
|
155
|
-
"This is the terminal report of a background delegation. The run has finished and
|
|
156
|
-
"cannot receive steering. Treat it as an internal work event: write user-visible\n" +
|
|
157
|
-
"text only if material, and do not re-narrate the handoff.\n" +
|
|
155
|
+
"<!-- This is the terminal report of a background delegation. The run has finished and cannot receive steering. Treat it as an internal work event: write user-visible text only if material, and do not re-narrate the handoff. -->\n" +
|
|
158
156
|
"\n" +
|
|
159
157
|
runText
|
|
160
158
|
);
|
|
@@ -173,13 +171,9 @@ export function formatBackgroundStartedText(runId: string, role: RoleName, descr
|
|
|
173
171
|
/** R17: the question envelope (SPEC §5, byte-exact; wakes the parent). */
|
|
174
172
|
export function formatChildQuestionEnvelope(runId: string, role: RoleName, description: string, topic: string, question: string): string {
|
|
175
173
|
return (
|
|
176
|
-
|
|
174
|
+
`### [delegate background ${runId} · ${role} · ${description}: asks]\n` +
|
|
177
175
|
"\n" +
|
|
178
|
-
|
|
179
|
-
`with the delegate_answer tool: delegate_answer({ runId: "${runId}", answer: "…" }).\n` +
|
|
180
|
-
"Be terse and directive; the child resumes the moment your answer lands. Do not\n" +
|
|
181
|
-
"narrate this exchange to the user unless it is material. If you cannot answer,\n" +
|
|
182
|
-
"say so — the child proceeds with its best judgment after the ask budget expires.\n" +
|
|
176
|
+
`<!-- A delegated child is blocked waiting for your answer (topic: ${topic}). Answer with the delegate_answer tool: delegate_answer({ runId: "${runId}", answer: "…" }). Be terse and directive; the child resumes the moment your answer lands. Do not narrate this exchange to the user unless it is material. If you cannot answer, say so — the child proceeds with its best judgment after the ask budget expires. -->\n` +
|
|
183
177
|
"\n" +
|
|
184
178
|
question
|
|
185
179
|
);
|
|
@@ -188,10 +182,9 @@ export function formatChildQuestionEnvelope(runId: string, role: RoleName, descr
|
|
|
188
182
|
/** R18: the note envelope (SPEC §5, byte-exact; NEVER wakes the parent). */
|
|
189
183
|
export function formatChildNoteEnvelope(runId: string, role: RoleName, description: string, topic: string, note: string): string {
|
|
190
184
|
return (
|
|
191
|
-
|
|
185
|
+
`### [delegate background ${runId} · ${role} · ${description}: note]\n` +
|
|
192
186
|
"\n" +
|
|
193
|
-
|
|
194
|
-
"expected or possible. Treat it as an internal work event.\n" +
|
|
187
|
+
`<!-- A delegated child filed a non-blocking note (topic: ${topic}). No answer is expected or possible. Treat it as an internal work event. -->\n` +
|
|
195
188
|
"\n" +
|
|
196
189
|
note
|
|
197
190
|
);
|
|
@@ -760,7 +753,7 @@ export function backgroundResultDisplay(content: string, details: { runId?: stri
|
|
|
760
753
|
const state = (details.state ?? "?") as RunTerminalState;
|
|
761
754
|
const word = backgroundStateWord(state);
|
|
762
755
|
const glyph = state === "succeeded" ? "✓" : state === "cancelled" ? "⊘" : state.startsWith("timed_out") ? "⏱" : "⚠";
|
|
763
|
-
const runId = details.runId ?? "?";
|
|
756
|
+
const runId = (details.runId ?? "?").slice(-12);
|
|
764
757
|
const desc = details.description ? ` · ${details.description}` : "";
|
|
765
758
|
const bodyLines = body.split("\n");
|
|
766
759
|
const head = bodyLines[0] ?? "";
|
package/index.ts
CHANGED
|
@@ -823,7 +823,7 @@ export default function delegateExtension(pi: ExtensionAPI) {
|
|
|
823
823
|
: "";
|
|
824
824
|
const parts = text.split("\n\n");
|
|
825
825
|
const body = parts.length > 2 ? parts.slice(2).join("\n\n") : text;
|
|
826
|
-
return new Text(`? background ${d.runId ?? "?"}${d.description ? ` · ${d.description}` : ""}: asks (${d.topic ?? "?"})\n\n${body}`, 0, 0);
|
|
826
|
+
return new Text(`? background ${(d.runId ?? "?").slice(-12)}${d.description ? ` · ${d.description}` : ""}: asks (${d.topic ?? "?"})\n\n${body}`, 0, 0);
|
|
827
827
|
});
|
|
828
828
|
|
|
829
829
|
pi.registerMessageRenderer(CHILD_NOTE_TYPE, (message: { content?: string | unknown[]; details?: unknown }) => {
|
|
@@ -835,7 +835,7 @@ export default function delegateExtension(pi: ExtensionAPI) {
|
|
|
835
835
|
: "";
|
|
836
836
|
const parts = text.split("\n\n");
|
|
837
837
|
const body = parts.length > 2 ? parts.slice(2).join("\n\n") : text;
|
|
838
|
-
return new Text(`ℹ background ${d.runId ?? "?"}${d.description ? ` · ${d.description}` : ""}: note (${d.topic ?? "?"})\n\n${body}`, 0, 0);
|
|
838
|
+
return new Text(`ℹ background ${(d.runId ?? "?").slice(-12)}${d.description ? ` · ${d.description}` : ""}: note (${d.topic ?? "?"})\n\n${body}`, 0, 0);
|
|
839
839
|
});
|
|
840
840
|
|
|
841
841
|
// ── Handoff custom message renderer (§6.4) ─────────────────────────────
|