feat(02-03): wire SkillService into ServiceGraph and preload bridge
- Add lazy SkillService creation in ServiceGraph with getOrCreateSkillService getter - Pass skillService to registerDomainHandlers in main-runtime-support - Add 7 skill operations to preload bridge (importSkill, listSkills, getSkillDetail, deleteSkill, assignSkillToAgent, removeSkillFromAgent, checkSkillUpdate) - Add skillService cleanup in app lifecycle shutdown
This commit is contained in:
1 parent
b5ad164338
commit
bbdabbe675
3 files changed
+31
-1
No files matched your search
@@ -168,6 +168,7 @@ export function createMainRuntimeSupport(state: MainRuntimeState) {
|
|||||||
bootstrapOnboarding: (input) => requireOnboardingService().bootstrapOnboarding(input),
|
bootstrapOnboarding: (input) => requireOnboardingService().bootstrapOnboarding(input),
|
||||||
getBrowserActions: () => requireServiceGraph().getBrowserActionService(),
|
getBrowserActions: () => requireServiceGraph().getBrowserActionService(),
|
||||||
randomFallbackCompanyId: () => requireConnectorHealthService().randomFallbackCompanyId(),
|
randomFallbackCompanyId: () => requireConnectorHealthService().randomFallbackCompanyId(),
|
||||||
|
skillService: requireServiceGraph().getOrCreateSkillService(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { createOrchestrationService } from "./orchestration-service";
|
|||||||
import { createUpdaterService } from "./updater-service";
|
import { createUpdaterService } from "./updater-service";
|
||||||
import { createWorkerService } from "./worker-service";
|
import { createWorkerService } from "./worker-service";
|
||||||
import { createAppLifecycleService } from "./app-lifecycle-service";
|
import { createAppLifecycleService } from "./app-lifecycle-service";
|
||||||
|
import { createSkillService } from "./skill-service";
|
||||||
import type { DesktopEvent, RunRecord } from "@shared/types";
|
import type { DesktopEvent, RunRecord } from "@shared/types";
|
||||||
import type { AutomationEventContext } from "./automation-service";
|
import type { AutomationEventContext } from "./automation-service";
|
||||||
import type { NotificationOptions } from "./notification-service";
|
import type { NotificationOptions } from "./notification-service";
|
||||||
@@ -67,8 +68,20 @@ export function createServiceGraph({
|
|||||||
let workerService: ReturnType<typeof createWorkerService> | null = null;
|
let workerService: ReturnType<typeof createWorkerService> | null = null;
|
||||||
let updaterService: ReturnType<typeof createUpdaterService> | null = null;
|
let updaterService: ReturnType<typeof createUpdaterService> | null = null;
|
||||||
let appLifecycleService: ReturnType<typeof createAppLifecycleService> | null = null;
|
let appLifecycleService: ReturnType<typeof createAppLifecycleService> | null = null;
|
||||||
|
let skillService: ReturnType<typeof createSkillService> | null = null;
|
||||||
|
|
||||||
const wakeAgentIfPossible = (agentId: string | null | undefined, companyId: string, trigger: string) => {
|
function getOrCreateSkillService() {
|
||||||
|
if (!skillService) {
|
||||||
|
skillService = createSkillService({
|
||||||
|
db,
|
||||||
|
profileDir: db.profileDir,
|
||||||
|
logger,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return skillService;
|
||||||
|
}
|
||||||
|
|
||||||
|
const wakeAgentIfPossible =(agentId: string | null | undefined, companyId: string, trigger: string) => {
|
||||||
if (!orchestrationService) {
|
if (!orchestrationService) {
|
||||||
throw new Error("Orchestration service is not initialized.");
|
throw new Error("Orchestration service is not initialized.");
|
||||||
}
|
}
|
||||||
@@ -236,6 +249,7 @@ export function createServiceGraph({
|
|||||||
orchestrationService = null;
|
orchestrationService = null;
|
||||||
updaterService = null;
|
updaterService = null;
|
||||||
appLifecycleService = null;
|
appLifecycleService = null;
|
||||||
|
skillService = null;
|
||||||
db.close();
|
db.close();
|
||||||
// Force exit after grace period — covers all platforms (macOS Dock, Windows tray, Linux)
|
// Force exit after grace period — covers all platforms (macOS Dock, Windows tray, Linux)
|
||||||
// Worker child processes (claude/codex CLI) may keep the event loop alive indefinitely
|
// Worker child processes (claude/codex CLI) may keep the event loop alive indefinitely
|
||||||
@@ -255,5 +269,6 @@ export function createServiceGraph({
|
|||||||
getOnboardingService: () => onboardingService,
|
getOnboardingService: () => onboardingService,
|
||||||
getUpdaterService: () => updaterService,
|
getUpdaterService: () => updaterService,
|
||||||
getAppLifecycleService: () => appLifecycleService,
|
getAppLifecycleService: () => appLifecycleService,
|
||||||
|
getOrCreateSkillService,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -76,6 +76,20 @@ const api: DesktopApi = {
|
|||||||
deleteWorkflow: (input) => ipcRenderer.invoke(IPC_CHANNELS.deleteWorkflow, input),
|
deleteWorkflow: (input) => ipcRenderer.invoke(IPC_CHANNELS.deleteWorkflow, input),
|
||||||
runWorkflow: (input) => ipcRenderer.invoke(IPC_CHANNELS.runWorkflow, input),
|
runWorkflow: (input) => ipcRenderer.invoke(IPC_CHANNELS.runWorkflow, input),
|
||||||
autoAssignTask: (input) => ipcRenderer.invoke(IPC_CHANNELS.autoAssignTask, input),
|
autoAssignTask: (input) => ipcRenderer.invoke(IPC_CHANNELS.autoAssignTask, input),
|
||||||
|
importSkill: (companyId, source) =>
|
||||||
|
ipcRenderer.invoke(IPC_CHANNELS.importSkill, { companyId, source }),
|
||||||
|
listSkills: (companyId) =>
|
||||||
|
ipcRenderer.invoke(IPC_CHANNELS.listSkills, { companyId }),
|
||||||
|
getSkillDetail: (companyId, skillId) =>
|
||||||
|
ipcRenderer.invoke(IPC_CHANNELS.getSkillDetail, { companyId, skillId }),
|
||||||
|
deleteSkill: (companyId, skillId) =>
|
||||||
|
ipcRenderer.invoke(IPC_CHANNELS.deleteSkill, { companyId, skillId }),
|
||||||
|
assignSkillToAgent: (companyId, agentId, skillId) =>
|
||||||
|
ipcRenderer.invoke(IPC_CHANNELS.assignSkillToAgent, { companyId, agentId, skillId }),
|
||||||
|
removeSkillFromAgent: (companyId, agentId, skillId) =>
|
||||||
|
ipcRenderer.invoke(IPC_CHANNELS.removeSkillFromAgent, { companyId, agentId, skillId }),
|
||||||
|
checkSkillUpdate: (companyId, skillId) =>
|
||||||
|
ipcRenderer.invoke(IPC_CHANNELS.checkSkillUpdate, { companyId, skillId }),
|
||||||
recoveryRetry: (taskId: string, agentId: string, companyId: string) =>
|
recoveryRetry: (taskId: string, agentId: string, companyId: string) =>
|
||||||
ipcRenderer.invoke("recovery:retry", { taskId, agentId, companyId }),
|
ipcRenderer.invoke("recovery:retry", { taskId, agentId, companyId }),
|
||||||
recoveryDismiss: (taskId: string) =>
|
recoveryDismiss: (taskId: string) =>
|
||||||
|
|||||||
Reference in new issue
Block a user