Skip to content

Commit 64be6af

Browse files
committed
feat(bridge): use streamingBehavior hint to select deliverAs in pi bridge
Map hint to pi's native deliverAs: steer -> steer, followUp -> followUp, info -> informational buffer. Falls back to isActionableEvent heuristic when hint is absent. Expose streamingBehavior in the TypeBox tool schema.
1 parent 58dbc5b commit 64be6af

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

src/bridges/pi/index.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
buildAction,
2525
ensureProjectRoom,
2626
ensureRegistered,
27+
extractStreamingBehavior,
2728
formatDeliveryEvent,
2829
isActionableEvent,
2930
} from "../../core/index.js";
@@ -86,19 +87,27 @@ export default function (pi: ExtensionAPI) {
8687
}
8788

8889
const line = formatDeliveryEvent(event);
90+
const hint = extractStreamingBehavior(event);
8991

90-
if (isActionableEvent(event)) {
91-
// Actionable events wake the model via sendMessage (not sendUserMessage)
92+
// Pick deliverAs from sender hint; fall back to event-type heuristic
93+
const deliverAs: "steer" | "followUp" | undefined =
94+
hint === "followUp"
95+
? "followUp"
96+
: hint === "steer" || (!hint && isActionableEvent(event))
97+
? "steer"
98+
: undefined;
99+
100+
if (deliverAs !== undefined) {
92101
pi.sendMessage(
93102
{
94103
content: `📬 ${line}`,
95104
customType: "comms-delivery",
96105
display: false,
97106
},
98-
{ triggerTurn: true, deliverAs: "steer" },
107+
{ triggerTurn: true, deliverAs },
99108
);
100109
} else {
101-
// Informational events buffer for next tool call
110+
// info or non-actionable with no hint — buffer for next tool call
102111
informationalBuffer.push(line);
103112
}
104113

@@ -279,6 +288,12 @@ export default function (pi: ExtensionAPI) {
279288
description: "Reason for declining an invite (for decline_invite)",
280289
}),
281290
),
291+
streamingBehavior: Type.Optional(
292+
StringEnum(["steer", "followUp", "info"], {
293+
description:
294+
"Delivery timing hint: steer (act now), followUp (act when idle), info (whenever convenient)",
295+
}),
296+
),
282297
}),
283298

284299
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {

0 commit comments

Comments
 (0)