mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 03:10:21 +00:00
Agents: reuse shared subagent hook runner type
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { vi, type Mock } from "vitest";
|
||||
import type { SubagentLifecycleHookRunner } from "../plugins/hooks.js";
|
||||
import {
|
||||
__testing as subagentAnnounceDeliveryTesting,
|
||||
resolveRequesterStoreKey,
|
||||
@@ -11,7 +12,6 @@ import {
|
||||
} from "./subagent-announce.js";
|
||||
import { __testing as subagentRegistryTesting } from "./subagent-registry.js";
|
||||
import { __testing as subagentSpawnTesting } from "./subagent-spawn.js";
|
||||
import type { SubagentLifecycleHookRunner } from "./subagent-spawn.js";
|
||||
|
||||
type SessionsSpawnTestConfig = ReturnType<(typeof import("../config/config.js"))["loadConfig"]>;
|
||||
type SessionsSpawnHookRunner = SubagentLifecycleHookRunner | null;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import os from "node:os";
|
||||
import { expect, vi } from "vitest";
|
||||
import type { SubagentLifecycleHookRunner } from "../plugins/hooks.js";
|
||||
|
||||
type MockFn = (...args: unknown[]) => unknown;
|
||||
type MockImplementationTarget = {
|
||||
@@ -7,10 +8,7 @@ type MockImplementationTarget = {
|
||||
};
|
||||
type SessionStore = Record<string, Record<string, unknown>>;
|
||||
type SessionStoreMutator = (store: SessionStore) => unknown;
|
||||
type HookRunner = {
|
||||
hasHooks: (name?: string) => boolean;
|
||||
runSubagentSpawning?: (...args: unknown[]) => Promise<unknown>;
|
||||
};
|
||||
type HookRunner = Pick<SubagentLifecycleHookRunner, "hasHooks" | "runSubagentSpawning">;
|
||||
|
||||
export function createSubagentSpawnTestConfig(
|
||||
workspaceDir = os.tmpdir(),
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
resolveGatewaySessionStoreTarget,
|
||||
} from "../gateway/session-utils.js";
|
||||
import { getGlobalHookRunner } from "../plugins/hook-runner-global.js";
|
||||
import type { SubagentLifecycleHookRunner } from "../plugins/hooks.js";
|
||||
import {
|
||||
isValidAgentId,
|
||||
isCronSessionKey,
|
||||
@@ -57,11 +58,6 @@ type SubagentSpawnDeps = {
|
||||
updateSessionStore: typeof updateSessionStore;
|
||||
};
|
||||
|
||||
export type SubagentLifecycleHookRunner = Pick<
|
||||
NonNullable<ReturnType<typeof getGlobalHookRunner>>,
|
||||
"hasHooks" | "runSubagentSpawning" | "runSubagentSpawned" | "runSubagentEnded"
|
||||
>;
|
||||
|
||||
const defaultSubagentSpawnDeps: SubagentSpawnDeps = {
|
||||
callGateway,
|
||||
getGlobalHookRunner,
|
||||
|
||||
Reference in New Issue
Block a user