fix merge; add control logging
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -35,6 +35,8 @@ swift build -c "$BUILD_CONFIG" --product "$PRODUCT" --product "${PRODUCT}CLI" --
|
|||||||
|
|
||||||
BIN="$BUILD_PATH/$BUILD_CONFIG/$PRODUCT"
|
BIN="$BUILD_PATH/$BUILD_CONFIG/$PRODUCT"
|
||||||
CLI_BIN="$BUILD_PATH/$BUILD_CONFIG/ClawdisCLI"
|
CLI_BIN="$BUILD_PATH/$BUILD_CONFIG/ClawdisCLI"
|
||||||
|
echo "pkg: binary $BIN" >&2
|
||||||
|
echo "pkg: cli $CLI_BIN" >&2
|
||||||
echo "🧹 Cleaning old app bundle"
|
echo "🧹 Cleaning old app bundle"
|
||||||
rm -rf "$APP_ROOT"
|
rm -rf "$APP_ROOT"
|
||||||
mkdir -p "$APP_ROOT/Contents/MacOS"
|
mkdir -p "$APP_ROOT/Contents/MacOS"
|
||||||
|
|||||||
@@ -625,13 +625,10 @@ export async function runCommandReply(
|
|||||||
toolCallId?: string;
|
toolCallId?: string;
|
||||||
tool_call_id?: string;
|
tool_call_id?: string;
|
||||||
};
|
};
|
||||||
const role =
|
const role = (msg.role ?? "") as string;
|
||||||
typeof msg.role === "string" ? msg.role.toLowerCase() : "";
|
|
||||||
const isToolResult =
|
const isToolResult =
|
||||||
role === "toolresult" || role === "tool_result";
|
role === "toolResult" || role === "tool_result";
|
||||||
if (!isToolResult || !Array.isArray(msg.content)) {
|
if (isToolResult && Array.isArray(msg.content)) {
|
||||||
// not a tool result message we care about
|
|
||||||
} else {
|
|
||||||
const toolName = inferToolName(msg);
|
const toolName = inferToolName(msg);
|
||||||
const toolCallId = msg.toolCallId ?? msg.tool_call_id;
|
const toolCallId = msg.toolCallId ?? msg.tool_call_id;
|
||||||
const meta =
|
const meta =
|
||||||
@@ -675,6 +672,11 @@ export async function runCommandReply(
|
|||||||
flushPendingTool,
|
flushPendingTool,
|
||||||
TOOL_RESULT_DEBOUNCE_MS,
|
TOOL_RESULT_DEBOUNCE_MS,
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg.role === "assistant") {
|
||||||
|
streamAssistantFinal(msg as AssistantMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import net from "node:net";
|
|||||||
|
|
||||||
import { getHealthSnapshot, type HealthSummary } from "../commands/health.js";
|
import { getHealthSnapshot, type HealthSummary } from "../commands/health.js";
|
||||||
import { getStatusSummary, type StatusSummary } from "../commands/status.js";
|
import { getStatusSummary, type StatusSummary } from "../commands/status.js";
|
||||||
|
import { logDebug, logError } from "../logger.js";
|
||||||
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
|
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
|
||||||
import { type AgentEventPayload, onAgentEvent } from "./agent-events.js";
|
import { type AgentEventPayload, onAgentEvent } from "./agent-events.js";
|
||||||
import {
|
import {
|
||||||
@@ -76,6 +77,7 @@ export async function startControlChannel(
|
|||||||
const lines = buffer.split(/\r?\n/);
|
const lines = buffer.split(/\r?\n/);
|
||||||
buffer = lines.pop() ?? "";
|
buffer = lines.pop() ?? "";
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
|
logDebug(`control: line ${line.slice(0, 200)}`);
|
||||||
handleLine(socket, line.trim());
|
handleLine(socket, line.trim());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -104,7 +106,7 @@ export async function startControlChannel(
|
|||||||
try {
|
try {
|
||||||
parsed = JSON.parse(line) as ControlRequest;
|
parsed = JSON.parse(line) as ControlRequest;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
runtime.log?.(
|
logError(
|
||||||
`control: parse error (${String(err)}) on line: ${line.slice(0, 200)}`,
|
`control: parse error (${String(err)}) on line: ${line.slice(0, 200)}`,
|
||||||
);
|
);
|
||||||
return write(socket, {
|
return write(socket, {
|
||||||
@@ -134,7 +136,7 @@ export async function startControlChannel(
|
|||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
runtime.log?.(`control: recv ${parsed.method}`);
|
logDebug(`control: recv ${parsed.method}`);
|
||||||
switch (parsed.method) {
|
switch (parsed.method) {
|
||||||
case "ping": {
|
case "ping": {
|
||||||
respond({ pong: true, ts: Date.now() });
|
respond({ pong: true, ts: Date.now() });
|
||||||
@@ -177,11 +179,9 @@ export async function startControlChannel(
|
|||||||
respond(undefined, false, `unknown method: ${parsed.method}`);
|
respond(undefined, false, `unknown method: ${parsed.method}`);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
runtime.log?.(
|
logDebug(`control: ${parsed.method} responded in ${Date.now() - started}ms`);
|
||||||
`control: ${parsed.method} responded in ${Date.now() - started}ms`,
|
|
||||||
);
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
runtime.log?.(
|
logError(
|
||||||
`control: ${parsed.method} failed in ${Date.now() - started}ms: ${String(err)}`,
|
`control: ${parsed.method} failed in ${Date.now() - started}ms: ${String(err)}`,
|
||||||
);
|
);
|
||||||
respond(undefined, false, String(err));
|
respond(undefined, false, String(err));
|
||||||
|
|||||||
Reference in New Issue
Block a user