fix(ipc): steer desktop messages into live runs

This commit is contained in:
ZacharyZhang-NY committed 2026-04-23 19:12:32 -04:00
1 parent a1dd361f51
commit b520de9a51
4 files changed
+132 -1

No files matched your search

@@ -15,6 +15,7 @@ export function registerAgentCoordinationHandlers({
emitEvent,
notify,
wakeAgentIfPossible,
injectRuntimeMessage,
onHumanMessage,
}: Pick<
RegisterDomainHandlersDependencies,
@@ -25,6 +26,7 @@ export function registerAgentCoordinationHandlers({
| "emitEvent"
| "notify"
| "wakeAgentIfPossible"
| "injectRuntimeMessage"
| "onHumanMessage"
>) {
registerHandle(IPC_CHANNELS.sendAgentMessage, async (_event, payload) => {
@@ -38,6 +40,7 @@ export function registerAgentCoordinationHandlers({
notify,
publishDomainChanged,
wakeAgentIfPossible,
injectRuntimeMessage,
onHumanMessage,
},
parsed,
+2 -1
View File
@@ -2,7 +2,7 @@ import type { IpcMainInvokeEvent } from "electron";
import { z } from "zod";
import type { DesktopResult } from "@shared/contracts";
import type { bootstrapOnboardingSchema } from "@shared/contracts";
import type { DesktopEvent, SectionId } from "@shared/types";
import type { AgentMessageRecord, DesktopEvent, SectionId } from "@shared/types";
import type { AppDatabase } from "./database";
import type { createSkillService } from "./skill-service";
import type { createBudgetEnforcementService } from "./budget-enforcement-service";
@@ -45,6 +45,7 @@ export interface RegisterDomainHandlersDependencies {
emitEvent: (event: DesktopEvent) => void;
notify: (options: { title: string; body: string; urgency: "critical" | "informational"; navigation?: { section: SectionId; entityId?: string }; batchKey?: string }) => void;
wakeAgentIfPossible: (agentId: string | null | undefined, companyId: string, trigger: string) => string | null;
injectRuntimeMessage: (recipientAgentId: string, companyId: string, message: AgentMessageRecord) => boolean;
dispatchAutomation: (trigger: string, ctx: { companyId: string; [key: string]: unknown }) => void;
runWorkflowPipeline: (workflowId: string, companyId: string) => Promise<void>;
bootstrapOnboarding: (input: z.infer<typeof bootstrapOnboardingSchema>) => unknown;
+12
View File
@@ -202,6 +202,18 @@ export function createMainRuntimeSupport(state: MainRuntimeState) {
notify: (options) => requireIpcSupport().notify(options),
wakeAgentIfPossible: (agentId, companyId, trigger) =>
requireOrchestrationService().wakeAgentIfPossible(agentId, companyId, trigger),
injectRuntimeMessage: (recipientAgentId, companyId, message) => {
const injector = requireServiceGraph().getRuntimeMessageInjector();
if (!injector) return false;
try {
return injector.tryInject(recipientAgentId, companyId, message);
} catch (error) {
log.warn(
`[ipc-domain] runtime message injection failed for agent ${recipientAgentId}: ${error instanceof Error ? error.message : String(error)}`,
);
return false;
}
},
dispatchAutomation: (trigger, ctx) => requireAutomationService().dispatchAutomation(trigger, ctx),
runWorkflowPipeline: (workflowId, companyId) =>
requireAutomationService().runWorkflowPipeline(workflowId, companyId),