fix merge; add control logging

This commit is contained in:
Peter Steinberger
2025-12-09 01:45:56 +00:00
parent 31750b5ee5
commit e15475449c
4 changed files with 1763 additions and 1762 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -35,6 +35,8 @@ swift build -c "$BUILD_CONFIG" --product "$PRODUCT" --product "${PRODUCT}CLI" --
BIN="$BUILD_PATH/$BUILD_CONFIG/$PRODUCT"
CLI_BIN="$BUILD_PATH/$BUILD_CONFIG/ClawdisCLI"
echo "pkg: binary $BIN" >&2
echo "pkg: cli $CLI_BIN" >&2
echo "🧹 Cleaning old app bundle"
rm -rf "$APP_ROOT"
mkdir -p "$APP_ROOT/Contents/MacOS"

View File

@@ -625,13 +625,10 @@ export async function runCommandReply(
toolCallId?: string;
tool_call_id?: string;
};
const role =
typeof msg.role === "string" ? msg.role.toLowerCase() : "";
const role = (msg.role ?? "") as string;
const isToolResult =
role === "toolresult" || role === "tool_result";
if (!isToolResult || !Array.isArray(msg.content)) {
// not a tool result message we care about
} else {
role === "toolResult" || role === "tool_result";
if (isToolResult && Array.isArray(msg.content)) {
const toolName = inferToolName(msg);
const toolCallId = msg.toolCallId ?? msg.tool_call_id;
const meta =
@@ -675,6 +672,11 @@ export async function runCommandReply(
flushPendingTool,
TOOL_RESULT_DEBOUNCE_MS,
);
return;
}
if (msg.role === "assistant") {
streamAssistantFinal(msg as AssistantMessage);
}
}

View File

@@ -2,6 +2,7 @@ import net from "node:net";
import { getHealthSnapshot, type HealthSummary } from "../commands/health.js";
import { getStatusSummary, type StatusSummary } from "../commands/status.js";
import { logDebug, logError } from "../logger.js";
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
import { type AgentEventPayload, onAgentEvent } from "./agent-events.js";
import {
@@ -76,6 +77,7 @@ export async function startControlChannel(
const lines = buffer.split(/\r?\n/);
buffer = lines.pop() ?? "";
for (const line of lines) {
logDebug(`control: line ${line.slice(0, 200)}`);
handleLine(socket, line.trim());
}
});
@@ -104,7 +106,7 @@ export async function startControlChannel(
try {
parsed = JSON.parse(line) as ControlRequest;
} catch (err) {
runtime.log?.(
logError(
`control: parse error (${String(err)}) on line: ${line.slice(0, 200)}`,
);
return write(socket, {
@@ -134,7 +136,7 @@ export async function startControlChannel(
});
try {
runtime.log?.(`control: recv ${parsed.method}`);
logDebug(`control: recv ${parsed.method}`);
switch (parsed.method) {
case "ping": {
respond({ pong: true, ts: Date.now() });
@@ -177,11 +179,9 @@ export async function startControlChannel(
respond(undefined, false, `unknown method: ${parsed.method}`);
break;
}
runtime.log?.(
`control: ${parsed.method} responded in ${Date.now() - started}ms`,
);
logDebug(`control: ${parsed.method} responded in ${Date.now() - started}ms`);
} catch (err) {
runtime.log?.(
logError(
`control: ${parsed.method} failed in ${Date.now() - started}ms: ${String(err)}`,
);
respond(undefined, false, String(err));