@teammy/server 0.1.26 → 0.1.27
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/main.js +468 -470
- package/dist/project-pi-entry.js +48 -13
- package/dist/web/downloads/teammy-skill.zip +0 -0
- package/package.json +1 -1
package/dist/project-pi-entry.js
CHANGED
|
@@ -307,6 +307,28 @@ function contentTools(content, tools) {
|
|
|
307
307
|
];
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
+
// apps/server/agents/answer-text.ts
|
|
311
|
+
var AnswerText = class {
|
|
312
|
+
completed = "";
|
|
313
|
+
current = "";
|
|
314
|
+
start() {
|
|
315
|
+
this.current = "";
|
|
316
|
+
}
|
|
317
|
+
delta(text) {
|
|
318
|
+
this.current += text;
|
|
319
|
+
}
|
|
320
|
+
end(message) {
|
|
321
|
+
this.current = ["error", "aborted", "pending", "length"].includes(message.stopReason) ? "" : message.content.filter((part) => part.type === "text").map((part) => part.text).join("");
|
|
322
|
+
this.completed = this.text;
|
|
323
|
+
this.current = "";
|
|
324
|
+
}
|
|
325
|
+
get text() {
|
|
326
|
+
return this.completed && this.current ? `${this.completed}
|
|
327
|
+
|
|
328
|
+
${this.current}` : this.completed || this.current;
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
|
|
310
332
|
// apps/server/agents/pi-entry.ts
|
|
311
333
|
async function piChild() {
|
|
312
334
|
const channel = new AgentChannel(process.stdin, process.stdout);
|
|
@@ -487,7 +509,21 @@ async function piChild() {
|
|
|
487
509
|
attempt: input.attempt,
|
|
488
510
|
done: false
|
|
489
511
|
});
|
|
490
|
-
|
|
512
|
+
const answer = new AnswerText();
|
|
513
|
+
let emitted = "";
|
|
514
|
+
const emitAnswer = () => {
|
|
515
|
+
const text = answer.text;
|
|
516
|
+
if (text === emitted) return;
|
|
517
|
+
if (!text.startsWith(emitted)) {
|
|
518
|
+
void channel.send({ type: "answer_reset" }).catch(() => {
|
|
519
|
+
});
|
|
520
|
+
emitted = "";
|
|
521
|
+
}
|
|
522
|
+
const delta = text.slice(emitted.length);
|
|
523
|
+
if (delta) void channel.send({ type: "delta", text: delta }).catch(() => {
|
|
524
|
+
});
|
|
525
|
+
emitted = text;
|
|
526
|
+
};
|
|
491
527
|
const unsubscribe = native.subscribe((event) => {
|
|
492
528
|
if (event.type === "tool_execution_start")
|
|
493
529
|
void channel.send({ type: "activity", tool: event.toolName }).catch(() => {
|
|
@@ -495,18 +531,17 @@ async function piChild() {
|
|
|
495
531
|
if (event.type === "tool_execution_end")
|
|
496
532
|
void channel.send({ type: "activity" }).catch(() => {
|
|
497
533
|
});
|
|
498
|
-
if (event.type === "message_start" && event.message.role === "assistant"
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
void channel.send({ type: "answer_reset" }).catch(() => {
|
|
502
|
-
});
|
|
534
|
+
if (event.type === "message_start" && event.message.role === "assistant") {
|
|
535
|
+
answer.start();
|
|
536
|
+
emitAnswer();
|
|
503
537
|
}
|
|
504
538
|
if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
539
|
+
answer.delta(event.assistantMessageEvent.delta);
|
|
540
|
+
emitAnswer();
|
|
541
|
+
}
|
|
542
|
+
if (event.type === "message_end" && event.message.role === "assistant") {
|
|
543
|
+
answer.end(event.message);
|
|
544
|
+
emitAnswer();
|
|
510
545
|
}
|
|
511
546
|
});
|
|
512
547
|
try {
|
|
@@ -524,9 +559,9 @@ ${input.text}` : input.text
|
|
|
524
559
|
runId: input.runId,
|
|
525
560
|
attempt: input.attempt,
|
|
526
561
|
done: true,
|
|
527
|
-
text
|
|
562
|
+
text: answer.text
|
|
528
563
|
});
|
|
529
|
-
await channel.send({ type: "result", text });
|
|
564
|
+
await channel.send({ type: "result", text: answer.text });
|
|
530
565
|
} finally {
|
|
531
566
|
unsubscribe();
|
|
532
567
|
}
|
|
Binary file
|