orchestrating 0.1.38 → 0.1.39
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/orch +7 -4
- package/package.json +1 -1
package/bin/orch
CHANGED
|
@@ -830,6 +830,7 @@ const eventHistory = []; // all agent events for replay on reconnect
|
|
|
830
830
|
function sendToServer(msg) {
|
|
831
831
|
// Track agent events for reconnect replay
|
|
832
832
|
if (msg.type === "agent_event" && msg.event) {
|
|
833
|
+
if (!msg.event.ts) msg.event.ts = Date.now();
|
|
833
834
|
eventHistory.push(msg.event);
|
|
834
835
|
while (eventHistory.length > MAX_EVENT_HISTORY) {
|
|
835
836
|
eventHistory.shift();
|
|
@@ -1083,20 +1084,21 @@ if (adapter) {
|
|
|
1083
1084
|
for (const line of latest.split("\n").filter(Boolean)) {
|
|
1084
1085
|
try {
|
|
1085
1086
|
const record = JSON.parse(line);
|
|
1087
|
+
const ts = record.timestamp ? new Date(record.timestamp).getTime() : undefined;
|
|
1086
1088
|
if (record.type === "user" && record.message?.content) {
|
|
1087
1089
|
const text = typeof record.message.content === "string"
|
|
1088
1090
|
? record.message.content
|
|
1089
1091
|
: record.message.content.filter((b) => b.type === "text").map((b) => b.text).join("\n");
|
|
1090
1092
|
if (text) {
|
|
1091
|
-
historyEvents.push({ kind: "user_message", text });
|
|
1093
|
+
historyEvents.push({ kind: "user_message", text, ...(ts ? { ts } : {}) });
|
|
1092
1094
|
}
|
|
1093
1095
|
} else if (record.message?.role === "assistant" && record.message?.content) {
|
|
1094
1096
|
const msgId = `hist-${msgCounter++}`;
|
|
1095
|
-
historyEvents.push({ kind: "message_start", messageId: msgId });
|
|
1097
|
+
historyEvents.push({ kind: "message_start", messageId: msgId, ...(ts ? { ts } : {}) });
|
|
1096
1098
|
for (const block of record.message.content) {
|
|
1097
1099
|
if (block.type === "text" && block.text) {
|
|
1098
1100
|
const blockId = `hist-text-${msgCounter++}`;
|
|
1099
|
-
historyEvents.push({ kind: "text_delta", blockId, text: block.text });
|
|
1101
|
+
historyEvents.push({ kind: "text_delta", blockId, text: block.text, ...(ts ? { ts } : {}) });
|
|
1100
1102
|
} else if (block.type === "tool_use") {
|
|
1101
1103
|
const blockId = `hist-tool-${msgCounter++}`;
|
|
1102
1104
|
historyEvents.push({
|
|
@@ -1104,10 +1106,11 @@ if (adapter) {
|
|
|
1104
1106
|
toolName: block.name || "unknown",
|
|
1105
1107
|
toolId: block.id || blockId,
|
|
1106
1108
|
input: typeof block.input === "string" ? block.input : JSON.stringify(block.input || {}),
|
|
1109
|
+
...(ts ? { ts } : {}),
|
|
1107
1110
|
});
|
|
1108
1111
|
}
|
|
1109
1112
|
}
|
|
1110
|
-
historyEvents.push({ kind: "message_end", messageId: msgId });
|
|
1113
|
+
historyEvents.push({ kind: "message_end", messageId: msgId, ...(ts ? { ts } : {}) });
|
|
1111
1114
|
}
|
|
1112
1115
|
} catch {}
|
|
1113
1116
|
}
|