@skydiveai/pi-server 0.1.0-beta.3048 → 0.1.0-beta.3102
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 +38 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2418,11 +2418,43 @@ const steerContentPartSchema = z.union([z.object({
|
|
|
2418
2418
|
type: z.literal("image_url"),
|
|
2419
2419
|
image_url: z.object({ url: z.string() })
|
|
2420
2420
|
})]);
|
|
2421
|
+
const steerSenderSchema = z.object({
|
|
2422
|
+
kind: z.enum([
|
|
2423
|
+
"user",
|
|
2424
|
+
"system",
|
|
2425
|
+
"agent",
|
|
2426
|
+
"external"
|
|
2427
|
+
]),
|
|
2428
|
+
displayName: z.string().nullable(),
|
|
2429
|
+
participantId: z.string().nullable(),
|
|
2430
|
+
attribute: z.boolean()
|
|
2431
|
+
});
|
|
2421
2432
|
const steerRequestSchema = z.object({
|
|
2422
2433
|
content: z.union([z.string().min(1), z.array(steerContentPartSchema).min(1)]).optional(),
|
|
2423
2434
|
mode: z.enum(["steer", "follow-up"]).default("steer"),
|
|
2435
|
+
sender: steerSenderSchema.optional(),
|
|
2424
2436
|
text: z.string().optional()
|
|
2425
2437
|
}).refine((v) => v.content !== void 0 || v.text !== void 0, { message: "content or text is required" });
|
|
2438
|
+
/**
|
|
2439
|
+
* Render a steer as the user-role text the model reads.
|
|
2440
|
+
*
|
|
2441
|
+
* Typed senders let the harness own this frame instead of callers embedding a
|
|
2442
|
+
* prefix in the text itself — nothing downstream string-matches a marker.
|
|
2443
|
+
* Forms mirror the worker's history projection of the same rows
|
|
2444
|
+
* (messageToOai / to-oai-history) so the live steer and its re-read next turn
|
|
2445
|
+
* agree: system-authored rows project as `[platform] <text>`; attributed
|
|
2446
|
+
* humans as `Name: <text>`. Agent steers keep the explicit not-the-user agent
|
|
2447
|
+
* form rather than the human `Name:` attribution, per the impersonation fix
|
|
2448
|
+
* this carries forward. An attributed steer with no text (attachment-only)
|
|
2449
|
+
* still carries its attribution over `(attachments only)`.
|
|
2450
|
+
*/
|
|
2451
|
+
function frameSteerText({ text, sender }) {
|
|
2452
|
+
if (!sender?.attribute) return text;
|
|
2453
|
+
const body = text.length > 0 ? text : "(attachments only)";
|
|
2454
|
+
if (sender.kind === "system") return `[platform] ${body}`;
|
|
2455
|
+
if (sender.kind === "agent") return sender.displayName ? `[platform] steer from agent ${sender.displayName}: ${body}` : `[platform] steer from agent: ${body}`;
|
|
2456
|
+
return `${sender.displayName ?? "unnamed participant"}: ${body}`;
|
|
2457
|
+
}
|
|
2426
2458
|
async function handleSteer(request, sessionId, registry, pendingSteerIds) {
|
|
2427
2459
|
const { log } = requestLogger(request);
|
|
2428
2460
|
const session = registry.get(sessionId);
|
|
@@ -2441,6 +2473,10 @@ async function handleSteer(request, sessionId, registry, pendingSteerIds) {
|
|
|
2441
2473
|
log
|
|
2442
2474
|
});
|
|
2443
2475
|
if (!text && images.length === 0) return jsonError(400, "steer has no content");
|
|
2476
|
+
const framedText = frameSteerText({
|
|
2477
|
+
text,
|
|
2478
|
+
sender: parsed.data.sender ?? null
|
|
2479
|
+
});
|
|
2444
2480
|
const steerId = randomUUID();
|
|
2445
2481
|
let queues = pendingSteerIds.get(sessionId);
|
|
2446
2482
|
if (!queues) {
|
|
@@ -2452,10 +2488,10 @@ async function handleSteer(request, sessionId, registry, pendingSteerIds) {
|
|
|
2452
2488
|
}
|
|
2453
2489
|
if (mode === "follow-up") {
|
|
2454
2490
|
queues.followUp.push(steerId);
|
|
2455
|
-
await session.followUp(
|
|
2491
|
+
await session.followUp(framedText, images.length > 0 ? images : void 0);
|
|
2456
2492
|
} else {
|
|
2457
2493
|
queues.steer.push(steerId);
|
|
2458
|
-
await session.steer(
|
|
2494
|
+
await session.steer(framedText, images.length > 0 ? images : void 0);
|
|
2459
2495
|
}
|
|
2460
2496
|
log.info({
|
|
2461
2497
|
event: "steer_accepted",
|