fly-to-moon 0.1.20 → 0.1.22
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/README.md +0 -6
- package/dist/cli.mjs +50 -2
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/cli.mjs
CHANGED
|
@@ -1041,6 +1041,25 @@ var ClaudeAgent = class {
|
|
|
1041
1041
|
};
|
|
1042
1042
|
//#endregion
|
|
1043
1043
|
//#region src/core/agents/codex.ts
|
|
1044
|
+
function truncateStatus(text, maxLength = 60) {
|
|
1045
|
+
return text.length <= maxLength ? text : `${text.slice(0, maxLength - 3)}...`;
|
|
1046
|
+
}
|
|
1047
|
+
function extractEventErrorMessage(event) {
|
|
1048
|
+
return event.error?.message ?? ("message" in event ? event.message : void 0) ?? "unknown error";
|
|
1049
|
+
}
|
|
1050
|
+
function formatStartedItemMessage(item) {
|
|
1051
|
+
if (item.type === "command_execution") return item.command?.length ? `Running: ${item.command.join(" ")}` : "Running command...";
|
|
1052
|
+
if (item.type === "web_search") return item.query ? `Searching: ${item.query}` : "Searching...";
|
|
1053
|
+
if (item.type === "mcp_tool_call") {
|
|
1054
|
+
const toolName = item.tool_name ?? item.name ?? item.title;
|
|
1055
|
+
return toolName ? `Using tool: ${toolName}` : "Using tool...";
|
|
1056
|
+
}
|
|
1057
|
+
return null;
|
|
1058
|
+
}
|
|
1059
|
+
function formatCompletedItemMessage(item) {
|
|
1060
|
+
if (item.type === "reasoning" && item.text?.trim()) return `Reasoning: ${truncateStatus(item.text.trim())}`;
|
|
1061
|
+
return null;
|
|
1062
|
+
}
|
|
1044
1063
|
function shouldUseWindowsShell$1(bin, platform) {
|
|
1045
1064
|
if (platform !== "win32") return false;
|
|
1046
1065
|
if (/\.(cmd|bat)$/i.test(bin)) return true;
|
|
@@ -1109,6 +1128,7 @@ var CodexAgent = class {
|
|
|
1109
1128
|
});
|
|
1110
1129
|
if (setupAbortHandler(signal, child, reject, () => terminateCodexProcess(child, this.platform))) return;
|
|
1111
1130
|
let lastAgentMessage = null;
|
|
1131
|
+
let terminalError = null;
|
|
1112
1132
|
const cumulative = {
|
|
1113
1133
|
inputTokens: 0,
|
|
1114
1134
|
outputTokens: 0,
|
|
@@ -1116,9 +1136,24 @@ var CodexAgent = class {
|
|
|
1116
1136
|
cacheCreationTokens: 0
|
|
1117
1137
|
};
|
|
1118
1138
|
parseJSONLStream(child.stdout, logStream, (event) => {
|
|
1139
|
+
if (event.type === "turn.started") {
|
|
1140
|
+
onMessage?.("Starting turn...");
|
|
1141
|
+
return;
|
|
1142
|
+
}
|
|
1143
|
+
if (event.type === "item.started" && "item" in event) {
|
|
1144
|
+
const message = formatStartedItemMessage(event.item);
|
|
1145
|
+
if (message) onMessage?.(message);
|
|
1146
|
+
return;
|
|
1147
|
+
}
|
|
1119
1148
|
if (event.type === "item.completed" && "item" in event && event.item.type === "agent_message") {
|
|
1120
1149
|
lastAgentMessage = event.item.text;
|
|
1121
1150
|
onMessage?.(lastAgentMessage);
|
|
1151
|
+
return;
|
|
1152
|
+
}
|
|
1153
|
+
if (event.type === "item.completed" && "item" in event) {
|
|
1154
|
+
const message = formatCompletedItemMessage(event.item);
|
|
1155
|
+
if (message) onMessage?.(message);
|
|
1156
|
+
return;
|
|
1122
1157
|
}
|
|
1123
1158
|
if (event.type === "turn.completed" && "usage" in event) {
|
|
1124
1159
|
const u = event.usage;
|
|
@@ -1126,11 +1161,21 @@ var CodexAgent = class {
|
|
|
1126
1161
|
cumulative.outputTokens += u.output_tokens ?? 0;
|
|
1127
1162
|
cumulative.cacheReadTokens += u.cached_input_tokens ?? 0;
|
|
1128
1163
|
onUsage?.({ ...cumulative });
|
|
1164
|
+
return;
|
|
1129
1165
|
}
|
|
1166
|
+
if (event.type === "turn.failed") {
|
|
1167
|
+
terminalError = /* @__PURE__ */ new Error(`codex turn failed: ${extractEventErrorMessage(event)}`);
|
|
1168
|
+
return;
|
|
1169
|
+
}
|
|
1170
|
+
if (event.type === "error") terminalError = /* @__PURE__ */ new Error(`codex error: ${extractEventErrorMessage(event)}`);
|
|
1130
1171
|
});
|
|
1131
1172
|
setupChildProcessHandlers(child, "codex", logStream, reject, () => {
|
|
1173
|
+
if (terminalError) {
|
|
1174
|
+
reject(terminalError);
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1132
1177
|
if (!lastAgentMessage) {
|
|
1133
|
-
reject(/* @__PURE__ */ new Error("codex
|
|
1178
|
+
reject(/* @__PURE__ */ new Error("codex completed without a final agent_message"));
|
|
1134
1179
|
return;
|
|
1135
1180
|
}
|
|
1136
1181
|
try {
|
|
@@ -2286,6 +2331,7 @@ var Orchestrator = class extends EventEmitter {
|
|
|
2286
2331
|
failCount: 0,
|
|
2287
2332
|
consecutiveFailures: 0,
|
|
2288
2333
|
startTime: /* @__PURE__ */ new Date(),
|
|
2334
|
+
endTime: null,
|
|
2289
2335
|
waitingUntil: null,
|
|
2290
2336
|
lastMessage: null
|
|
2291
2337
|
};
|
|
@@ -2337,6 +2383,7 @@ var Orchestrator = class extends EventEmitter {
|
|
|
2337
2383
|
} else await this.closeAgent();
|
|
2338
2384
|
resetHard(this.cwd);
|
|
2339
2385
|
this.state.status = "stopped";
|
|
2386
|
+
this.state.endTime = /* @__PURE__ */ new Date();
|
|
2340
2387
|
this.emit("state", this.getState());
|
|
2341
2388
|
this.emit("stopped");
|
|
2342
2389
|
})();
|
|
@@ -2568,6 +2615,7 @@ var Orchestrator = class extends EventEmitter {
|
|
|
2568
2615
|
}
|
|
2569
2616
|
abort(reason) {
|
|
2570
2617
|
this.state.status = "aborted";
|
|
2618
|
+
this.state.endTime = /* @__PURE__ */ new Date();
|
|
2571
2619
|
this.state.lastMessage = reason;
|
|
2572
2620
|
this.state.waitingUntil = null;
|
|
2573
2621
|
appendDebugLog("orchestrator:abort", {
|
|
@@ -3196,7 +3244,7 @@ function buildContentCells(prompt, agentName, modelName, state, elapsed, now, av
|
|
|
3196
3244
|
return rows;
|
|
3197
3245
|
}
|
|
3198
3246
|
function buildFrameCells(prompt, agentName, modelName, state, topStars, bottomStars, sideStars, now, terminalWidth, terminalHeight) {
|
|
3199
|
-
const elapsed = formatElapsed(now - state.startTime.getTime());
|
|
3247
|
+
const elapsed = formatElapsed((state.endTime?.getTime() ?? now) - state.startTime.getTime());
|
|
3200
3248
|
const availableHeight = Math.max(0, terminalHeight - 2);
|
|
3201
3249
|
const contentRows = buildContentCells(prompt, agentName, modelName, state, elapsed, now, availableHeight);
|
|
3202
3250
|
while (contentRows.length < Math.min(BASE_CONTENT_ROWS, availableHeight)) contentRows.push([]);
|