opencara 0.105.2 → 0.105.4
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/bin.js +74 -27
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -1070,7 +1070,8 @@ function runAcpJob(opts) {
|
|
|
1070
1070
|
env: spec.env,
|
|
1071
1071
|
cwd: spec.cwd
|
|
1072
1072
|
});
|
|
1073
|
-
|
|
1073
|
+
const translator = createUpdateTranslator(handlers.onLog);
|
|
1074
|
+
client.onSessionUpdate((p) => translator.handle(p.update));
|
|
1074
1075
|
client.onStderr((chunk) => handlers.onLog("stderr", chunk));
|
|
1075
1076
|
const controller = {
|
|
1076
1077
|
onAgentCallResult(msg) {
|
|
@@ -1110,6 +1111,7 @@ function runAcpJob(opts) {
|
|
|
1110
1111
|
};
|
|
1111
1112
|
return result;
|
|
1112
1113
|
} finally {
|
|
1114
|
+
translator.flush();
|
|
1113
1115
|
bridge.shutdown("acp run ended");
|
|
1114
1116
|
await Promise.race([
|
|
1115
1117
|
host.stop().catch(() => void 0),
|
|
@@ -1152,37 +1154,61 @@ ${turns}`);
|
|
|
1152
1154
|
${acp.userPromptMd}`);
|
|
1153
1155
|
return [{ type: "text", text: parts.join("\n\n---\n\n") }];
|
|
1154
1156
|
}
|
|
1155
|
-
function
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1157
|
+
function createUpdateTranslator(onLog) {
|
|
1158
|
+
let inThought = false;
|
|
1159
|
+
const enterThought = () => {
|
|
1160
|
+
if (!inThought) {
|
|
1161
|
+
onLog("stdout", "\n[think]\n");
|
|
1162
|
+
inThought = true;
|
|
1159
1163
|
}
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
if (
|
|
1163
|
-
onLog("stdout",
|
|
1164
|
-
|
|
1164
|
+
};
|
|
1165
|
+
const leaveThought = () => {
|
|
1166
|
+
if (inThought) {
|
|
1167
|
+
onLog("stdout", "\n[/think]\n");
|
|
1168
|
+
inThought = false;
|
|
1165
1169
|
}
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1170
|
+
};
|
|
1171
|
+
return {
|
|
1172
|
+
handle(update) {
|
|
1173
|
+
if (isMessageChunk(update)) {
|
|
1174
|
+
if (update.sessionUpdate === "user_message_chunk") {
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1177
|
+
const text = textOfContent(update.content);
|
|
1178
|
+
if (!text) return;
|
|
1179
|
+
if (update.sessionUpdate === "agent_thought_chunk") {
|
|
1180
|
+
enterThought();
|
|
1181
|
+
onLog("stdout", text);
|
|
1182
|
+
return;
|
|
1183
|
+
}
|
|
1184
|
+
leaveThought();
|
|
1185
|
+
onLog("stdout", text);
|
|
1186
|
+
return;
|
|
1187
|
+
}
|
|
1188
|
+
if (isToolCallStart(update)) {
|
|
1189
|
+
leaveThought();
|
|
1190
|
+
const status2 = update.status ?? "?";
|
|
1191
|
+
onLog("stdout", `
|
|
1172
1192
|
[tool] ${update.title} (${status2})
|
|
1173
1193
|
`);
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
if (isToolCallProgress(update)) {
|
|
1197
|
+
leaveThought();
|
|
1198
|
+
const status2 = update.status ?? "?";
|
|
1199
|
+
const title = update.title ?? "(tool)";
|
|
1200
|
+
onLog("stdout", `
|
|
1180
1201
|
[tool] ${title} \u2192 ${status2}
|
|
1181
1202
|
`);
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1203
|
+
return;
|
|
1204
|
+
}
|
|
1205
|
+
onLog("stderr", `[acp] unmodeled update: ${update.sessionUpdate}
|
|
1185
1206
|
`);
|
|
1207
|
+
},
|
|
1208
|
+
flush() {
|
|
1209
|
+
leaveThought();
|
|
1210
|
+
}
|
|
1211
|
+
};
|
|
1186
1212
|
}
|
|
1187
1213
|
function textOfContent(content) {
|
|
1188
1214
|
if (content.type !== "text") return "";
|
|
@@ -1206,7 +1232,7 @@ function resolveLocalAcpAdapter(command, args) {
|
|
|
1206
1232
|
}
|
|
1207
1233
|
|
|
1208
1234
|
// src/commands/run.ts
|
|
1209
|
-
var PKG_VERSION = "0.105.
|
|
1235
|
+
var PKG_VERSION = "0.105.4";
|
|
1210
1236
|
var LOG_FLUSH_MS = 800;
|
|
1211
1237
|
var MAX_CHUNK_SIZE = 4 * 1024;
|
|
1212
1238
|
async function run(opts = {}) {
|
|
@@ -1533,7 +1559,17 @@ function worktreeCreate(args) {
|
|
|
1533
1559
|
mkdirSync2(sessionDir, { recursive: true });
|
|
1534
1560
|
if (existsSync4(join2(checkoutDir, ".git"))) {
|
|
1535
1561
|
git(checkoutDir, ["fetch", "origin"]);
|
|
1536
|
-
|
|
1562
|
+
if (refExists(checkoutDir, `refs/remotes/origin/${branch}`)) {
|
|
1563
|
+
git(checkoutDir, ["checkout", "-B", branch, `origin/${branch}`]);
|
|
1564
|
+
} else if (refExists(checkoutDir, `refs/heads/${branch}`)) {
|
|
1565
|
+
git(checkoutDir, ["checkout", branch]);
|
|
1566
|
+
} else if (fromBranch) {
|
|
1567
|
+
git(checkoutDir, ["checkout", "-B", branch, `origin/${fromBranch}`]);
|
|
1568
|
+
} else {
|
|
1569
|
+
fail(
|
|
1570
|
+
`worktree create: '${branch}' missing locally and on origin/, no --from-branch to fall back to`
|
|
1571
|
+
);
|
|
1572
|
+
}
|
|
1537
1573
|
} else {
|
|
1538
1574
|
mkdirSync2(checkoutDir, { recursive: true });
|
|
1539
1575
|
const cloneArgs = ["-c", `credential.helper=${HELPER_SNIPPET}`, "clone"];
|
|
@@ -1635,6 +1671,17 @@ function worktreeRemove(args) {
|
|
|
1635
1671
|
function git(cwd, args) {
|
|
1636
1672
|
execFileSync("git", args, { cwd, stdio: ["ignore", "ignore", "inherit"] });
|
|
1637
1673
|
}
|
|
1674
|
+
function refExists(cwd, ref) {
|
|
1675
|
+
try {
|
|
1676
|
+
execFileSync("git", ["rev-parse", "--verify", "--quiet", ref], {
|
|
1677
|
+
cwd,
|
|
1678
|
+
stdio: ["ignore", "ignore", "ignore"]
|
|
1679
|
+
});
|
|
1680
|
+
return true;
|
|
1681
|
+
} catch {
|
|
1682
|
+
return false;
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1638
1685
|
function pickFlag(argv, name) {
|
|
1639
1686
|
const i = argv.indexOf(name);
|
|
1640
1687
|
if (i === -1) return void 0;
|