orchestrating 0.1.37 → 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 +11 -4
- package/package.json +1 -1
package/bin/orch
CHANGED
|
@@ -328,6 +328,8 @@ if (firstArg === "daemon") {
|
|
|
328
328
|
</dict>
|
|
329
329
|
</dict>
|
|
330
330
|
</plist>`;
|
|
331
|
+
// Unload old plist first if it exists (avoids "Load failed" error on re-enable)
|
|
332
|
+
try { execSync(`launchctl unload "${plistPath}" 2>/dev/null`); } catch {}
|
|
331
333
|
writeFileSync(plistPath, plist);
|
|
332
334
|
execSync(`launchctl load -w "${plistPath}"`);
|
|
333
335
|
console.log("Daemon enabled — will start on login and auto-restart.");
|
|
@@ -353,6 +355,8 @@ WantedBy=default.target
|
|
|
353
355
|
`;
|
|
354
356
|
writeFileSync(servicePath, service);
|
|
355
357
|
execSync("systemctl --user daemon-reload");
|
|
358
|
+
// Stop old instance if running, then enable + start
|
|
359
|
+
try { execSync("systemctl --user stop orch-daemon.service 2>/dev/null"); } catch {}
|
|
356
360
|
execSync("systemctl --user enable --now orch-daemon.service");
|
|
357
361
|
// Enable lingering so user services run without active login session
|
|
358
362
|
try { execSync(`loginctl enable-linger ${os.userInfo().username}`); } catch {}
|
|
@@ -826,6 +830,7 @@ const eventHistory = []; // all agent events for replay on reconnect
|
|
|
826
830
|
function sendToServer(msg) {
|
|
827
831
|
// Track agent events for reconnect replay
|
|
828
832
|
if (msg.type === "agent_event" && msg.event) {
|
|
833
|
+
if (!msg.event.ts) msg.event.ts = Date.now();
|
|
829
834
|
eventHistory.push(msg.event);
|
|
830
835
|
while (eventHistory.length > MAX_EVENT_HISTORY) {
|
|
831
836
|
eventHistory.shift();
|
|
@@ -1079,20 +1084,21 @@ if (adapter) {
|
|
|
1079
1084
|
for (const line of latest.split("\n").filter(Boolean)) {
|
|
1080
1085
|
try {
|
|
1081
1086
|
const record = JSON.parse(line);
|
|
1087
|
+
const ts = record.timestamp ? new Date(record.timestamp).getTime() : undefined;
|
|
1082
1088
|
if (record.type === "user" && record.message?.content) {
|
|
1083
1089
|
const text = typeof record.message.content === "string"
|
|
1084
1090
|
? record.message.content
|
|
1085
1091
|
: record.message.content.filter((b) => b.type === "text").map((b) => b.text).join("\n");
|
|
1086
1092
|
if (text) {
|
|
1087
|
-
historyEvents.push({ kind: "user_message", text });
|
|
1093
|
+
historyEvents.push({ kind: "user_message", text, ...(ts ? { ts } : {}) });
|
|
1088
1094
|
}
|
|
1089
1095
|
} else if (record.message?.role === "assistant" && record.message?.content) {
|
|
1090
1096
|
const msgId = `hist-${msgCounter++}`;
|
|
1091
|
-
historyEvents.push({ kind: "message_start", messageId: msgId });
|
|
1097
|
+
historyEvents.push({ kind: "message_start", messageId: msgId, ...(ts ? { ts } : {}) });
|
|
1092
1098
|
for (const block of record.message.content) {
|
|
1093
1099
|
if (block.type === "text" && block.text) {
|
|
1094
1100
|
const blockId = `hist-text-${msgCounter++}`;
|
|
1095
|
-
historyEvents.push({ kind: "text_delta", blockId, text: block.text });
|
|
1101
|
+
historyEvents.push({ kind: "text_delta", blockId, text: block.text, ...(ts ? { ts } : {}) });
|
|
1096
1102
|
} else if (block.type === "tool_use") {
|
|
1097
1103
|
const blockId = `hist-tool-${msgCounter++}`;
|
|
1098
1104
|
historyEvents.push({
|
|
@@ -1100,10 +1106,11 @@ if (adapter) {
|
|
|
1100
1106
|
toolName: block.name || "unknown",
|
|
1101
1107
|
toolId: block.id || blockId,
|
|
1102
1108
|
input: typeof block.input === "string" ? block.input : JSON.stringify(block.input || {}),
|
|
1109
|
+
...(ts ? { ts } : {}),
|
|
1103
1110
|
});
|
|
1104
1111
|
}
|
|
1105
1112
|
}
|
|
1106
|
-
historyEvents.push({ kind: "message_end", messageId: msgId });
|
|
1113
|
+
historyEvents.push({ kind: "message_end", messageId: msgId, ...(ts ? { ts } : {}) });
|
|
1107
1114
|
}
|
|
1108
1115
|
} catch {}
|
|
1109
1116
|
}
|