Files
agent-radar 2ed3415fb7
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:17:27 +08:00

66 lines
1.8 KiB
TypeScript

import type {
AgentGUIRuntime,
AgentActivityRuntimeDiagnosticInput
} from "../../../agentActivityRuntime";
export function reportAgentComposerDiagnostic(
runtime: AgentGUIRuntime | null,
input: AgentActivityRuntimeDiagnosticInput
): void {
const reportDiagnostic = runtime?.reportDiagnostic;
try {
if (reportDiagnostic && runtime) {
void Promise.resolve(reportDiagnostic.call(runtime, input)).catch(
(error: unknown) => {
reportAgentComposerDiagnosticFailure(input, error);
}
);
}
if (!runtime || !agentComposerDevConsoleDiagnosticSinkEnabled(runtime)) {
return;
}
const level = input.level ?? "info";
const consoleMethod =
level === "error"
? console.error
: level === "warn"
? console.warn
: level === "debug"
? console.debug
: console.info;
consoleMethod.call(console, "[agent-gui]", JSON.stringify(input));
} catch (error) {
reportAgentComposerDiagnosticFailure(input, error);
}
}
function reportAgentComposerDiagnosticFailure(
input: AgentActivityRuntimeDiagnosticInput,
error: unknown
): void {
console.warn(
"[agent-gui]",
JSON.stringify({
event: "agent.gui.composer.diagnostic_failed",
level: "warn",
source: "agent-gui",
workspaceId: input.workspaceId ?? null,
details: {
diagnosticEvent: input.event,
error: error instanceof Error ? error.message : String(error)
}
})
);
}
function agentComposerDevConsoleDiagnosticSinkEnabled(
runtime: AgentGUIRuntime
): boolean {
return (
runtime.devDiagnosticConsoleSink !== false &&
typeof process !== "undefined" &&
(process.env.NODE_ENV === "development" ||
process.env.AGENT_GUI_DEV_DIAGNOSTIC_CONSOLE === "1")
);
}