devez-vibe 0.1.43 → 0.1.44
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/bin/dvz.exe +0 -0
- package/bridge/claude-agent-sdk-bridge.mjs +34 -8
- package/package.json +1 -1
package/bin/dvz.exe
CHANGED
|
Binary file
|
|
@@ -644,8 +644,34 @@ async function consume(session) {
|
|
|
644
644
|
}
|
|
645
645
|
}
|
|
646
646
|
|
|
647
|
-
|
|
648
|
-
|
|
647
|
+
const HANDOFF_HEADER = '<devez_provider_handoff chars="';
|
|
648
|
+
const HANDOFF_SEPARATOR = '">\n';
|
|
649
|
+
const HANDOFF_FOOTER = "\n</devez_provider_handoff>\n\n";
|
|
650
|
+
|
|
651
|
+
function prependHandoff(content, handoffContext) {
|
|
652
|
+
if (!handoffContext) return content;
|
|
653
|
+
const handoff = String(handoffContext);
|
|
654
|
+
const prefix = `${HANDOFF_HEADER}${handoff.length}${HANDOFF_SEPARATOR}${handoff}${HANDOFF_FOOTER}`;
|
|
655
|
+
const firstText = content.find((item) => item.type === "text");
|
|
656
|
+
if (firstText) firstText.text = `${prefix}${firstText.text || ""}`;
|
|
657
|
+
else content.unshift({ type: "text", text: prefix });
|
|
658
|
+
return content;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
function stripHandoff(text) {
|
|
662
|
+
if (!text.startsWith(HANDOFF_HEADER)) return text;
|
|
663
|
+
const separator = text.indexOf(HANDOFF_SEPARATOR, HANDOFF_HEADER.length);
|
|
664
|
+
if (separator < 0) return text;
|
|
665
|
+
const length = Number(text.slice(HANDOFF_HEADER.length, separator));
|
|
666
|
+
if (!Number.isSafeInteger(length) || length < 0) return text;
|
|
667
|
+
const contextStart = separator + HANDOFF_SEPARATOR.length;
|
|
668
|
+
const contextEnd = contextStart + length;
|
|
669
|
+
if (text.slice(contextEnd, contextEnd + HANDOFF_FOOTER.length) !== HANDOFF_FOOTER) return text;
|
|
670
|
+
return text.slice(contextEnd + HANDOFF_FOOTER.length);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
async function inputContent(input, handoffContext) {
|
|
674
|
+
const content = [];
|
|
649
675
|
for (const item of Array.isArray(input) ? input : []) {
|
|
650
676
|
if (item.type === "text") content.push({ type: "text", text: item.text || "" });
|
|
651
677
|
else if (item.type === "localImage" && item.path) {
|
|
@@ -658,7 +684,7 @@ async function inputContent(input) {
|
|
|
658
684
|
content.push({ type: "image", source: { type: "base64", media_type: mediaType, data: bytes.toString("base64") } });
|
|
659
685
|
}
|
|
660
686
|
}
|
|
661
|
-
return content.length ? content : [{ type: "text", text: "" }];
|
|
687
|
+
return prependHandoff(content.length ? content : [{ type: "text", text: "" }], handoffContext);
|
|
662
688
|
}
|
|
663
689
|
|
|
664
690
|
async function startPrompt(params) {
|
|
@@ -679,9 +705,9 @@ async function startPrompt(params) {
|
|
|
679
705
|
const turnId = `claude-turn-${session.turnSequence++}-${randomUUID()}`;
|
|
680
706
|
session.turn = { id: turnId, sawStreamText: false };
|
|
681
707
|
notify("turn/started", { threadId: id, turn: { id: turnId } });
|
|
682
|
-
session.queue.push({
|
|
683
|
-
type: "user",
|
|
684
|
-
message: { role: "user", content: await inputContent(params.input) },
|
|
708
|
+
session.queue.push({
|
|
709
|
+
type: "user",
|
|
710
|
+
message: { role: "user", content: await inputContent(params.input, params.handoffContext) },
|
|
685
711
|
parent_tool_use_id: null,
|
|
686
712
|
session_id: id,
|
|
687
713
|
origin: { kind: "human" },
|
|
@@ -702,8 +728,8 @@ function historyTurns(messages) {
|
|
|
702
728
|
const tasks = new Map();
|
|
703
729
|
for (const message of messages) {
|
|
704
730
|
const blocks = contentBlocks(message.message);
|
|
705
|
-
const userText = message.type === "user"
|
|
706
|
-
? blocks.filter((block) => block.type === "text").map((block) => block.text || "").join("\n")
|
|
731
|
+
const userText = message.type === "user"
|
|
732
|
+
? stripHandoff(blocks.filter((block) => block.type === "text").map((block) => block.text || "").join("\n"))
|
|
707
733
|
: "";
|
|
708
734
|
if (userText && !blocks.some((block) => block.type === "tool_result")) {
|
|
709
735
|
turn = {
|