opencara 0.105.3 → 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.
Files changed (2) hide show
  1. package/dist/bin.js +52 -26
  2. 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
- client.onSessionUpdate((p) => translateUpdate(p.update, handlers.onLog));
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 translateUpdate(update, onLog) {
1156
- if (isMessageChunk(update)) {
1157
- if (update.sessionUpdate === "user_message_chunk") {
1158
- return;
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
- const text = textOfContent(update.content);
1161
- if (!text) return;
1162
- if (update.sessionUpdate === "agent_thought_chunk") {
1163
- onLog("stdout", `[think] ${text}`);
1164
- return;
1164
+ };
1165
+ const leaveThought = () => {
1166
+ if (inThought) {
1167
+ onLog("stdout", "\n[/think]\n");
1168
+ inThought = false;
1165
1169
  }
1166
- onLog("stdout", text);
1167
- return;
1168
- }
1169
- if (isToolCallStart(update)) {
1170
- const status2 = update.status ?? "?";
1171
- onLog("stdout", `
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
- return;
1175
- }
1176
- if (isToolCallProgress(update)) {
1177
- const status2 = update.status ?? "?";
1178
- const title = update.title ?? "(tool)";
1179
- onLog("stdout", `
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
- return;
1183
- }
1184
- onLog("stderr", `[acp] unmodeled update: ${update.sessionUpdate}
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.3";
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 = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencara",
3
- "version": "0.105.3",
3
+ "version": "0.105.4",
4
4
  "description": "OpenCara agent-host CLI: register a machine as an agent host and run dispatched agents.",
5
5
  "license": "MIT",
6
6
  "repository": {