refactor: move tasks behind plugin-sdk seam

This commit is contained in:
Peter Steinberger
2026-03-31 15:21:24 +01:00
parent e1da91791a
commit da6e9bb76f
75 changed files with 157 additions and 137 deletions

1
extensions/tasks/api.ts Normal file
View File

@@ -0,0 +1 @@
export * from "./runtime-api.js";

View File

@@ -1,6 +1,8 @@
import { createDefaultOperationsMaintenanceService } from "openclaw/plugin-sdk/operations-default";
import { defaultOperationsRuntime } from "openclaw/plugin-sdk/operations-default";
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
import {
createDefaultOperationsMaintenanceService,
defaultOperationsRuntime,
} from "./runtime-api.js";
import { registerTasksCli } from "./src/cli.js";
export default definePluginEntry({

View File

@@ -0,0 +1,4 @@
export {
createDefaultOperationsMaintenanceService,
defaultOperationsRuntime,
} from "openclaw/plugin-sdk/tasks";

View File

@@ -185,9 +185,9 @@
"types": "./dist/plugin-sdk/plugin-runtime.d.ts",
"default": "./dist/plugin-sdk/plugin-runtime.js"
},
"./plugin-sdk/operations-default": {
"types": "./dist/plugin-sdk/operations-default.d.ts",
"default": "./dist/plugin-sdk/operations-default.js"
"./plugin-sdk/tasks": {
"types": "./dist/plugin-sdk/tasks.d.ts",
"default": "./dist/plugin-sdk/tasks.js"
},
"./plugin-sdk/security-runtime": {
"types": "./dist/plugin-sdk/security-runtime.d.ts",

View File

@@ -0,0 +1,9 @@
{
"name": "@openclaw/tasks-host-sdk",
"version": "0.0.0-private",
"private": true,
"type": "module",
"exports": {
"./runtime-core": "./src/runtime-core.ts"
}
}

View File

@@ -1,7 +1,7 @@
import { chmodSync, existsSync, mkdirSync } from "node:fs";
import type { DatabaseSync, StatementSync } from "node:sqlite";
import { requireNodeSqlite } from "../infra/node-sqlite.js";
import type { DeliveryContext } from "../utils/delivery-context.js";
import { requireNodeSqlite } from "../../../src/infra/node-sqlite.js";
import type { DeliveryContext } from "../../../src/utils/delivery-context.js";
import { resolveFlowRegistryDir, resolveFlowRegistrySqlitePath } from "./flow-registry.paths.js";
import type { FlowRegistryStoreSnapshot } from "./flow-registry.store.js";
import type { FlowOutputBag, FlowRecord, FlowShape } from "./flow-registry.types.js";

View File

@@ -1,6 +1,6 @@
import { statSync } from "node:fs";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { withTempDir } from "../test-helpers/temp-dir.js";
import { withTempDir } from "../../../src/test-helpers/temp-dir.js";
import { createFlowRecord, getFlowById, resetFlowRegistryForTests } from "./flow-registry.js";
import { resolveFlowRegistryDir, resolveFlowRegistrySqlitePath } from "./flow-registry.paths.js";
import { configureFlowRegistryRuntime } from "./flow-registry.store.js";

View File

@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { withTempDir } from "../test-helpers/temp-dir.js";
import { withTempDir } from "../../../src/test-helpers/temp-dir.js";
import {
createFlowRecord,
deleteFlowRecordById,

View File

@@ -1,4 +1,4 @@
import type { DeliveryContext } from "../utils/delivery-context.js";
import type { DeliveryContext } from "../../../src/utils/delivery-context.js";
import type { TaskNotifyPolicy } from "./task-registry.types.js";
export type FlowShape = "single_task" | "linear";

View File

@@ -1,5 +1,5 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { withTempDir } from "../test-helpers/temp-dir.js";
import { withTempDir } from "../../../src/test-helpers/temp-dir.js";
import { getFlowById, resetFlowRegistryForTests, updateFlowRecordById } from "./flow-registry.js";
import {
appendFlowOutput,

View File

@@ -1,7 +1,7 @@
import { requestHeartbeatNow } from "../infra/heartbeat-wake.js";
import { enqueueSystemEvent } from "../infra/system-events.js";
import { parseAgentSessionKey } from "../routing/session-key.js";
import { isDeliverableMessageChannel } from "../utils/message-channel.js";
import { requestHeartbeatNow } from "../../../src/infra/heartbeat-wake.js";
import { enqueueSystemEvent } from "../../../src/infra/system-events.js";
import { parseAgentSessionKey } from "../../../src/routing/session-key.js";
import { isDeliverableMessageChannel } from "../../../src/utils/message-channel.js";
import { createFlowRecord, getFlowById, updateFlowRecordById } from "./flow-registry.js";
import type { FlowOutputBag, FlowOutputValue, FlowRecord } from "./flow-registry.types.js";
import { createQueuedTaskRun, createRunningTaskRun } from "./task-executor.js";

View File

@@ -1,5 +1,5 @@
import { afterEach, describe, expect, it } from "vitest";
import { withTempDir } from "../test-helpers/temp-dir.js";
import { withTempDir } from "../../../src/test-helpers/temp-dir.js";
import { defaultTaskOperationsRuntime } from "./operations-runtime.js";
import { findTaskByRunId, resetTaskRegistryForTests } from "./task-registry.js";

View File

@@ -10,8 +10,8 @@ import type {
PluginOperationSummary,
PluginOperationsCancelResult,
PluginOperationsRuntime,
} from "../plugins/operations-state.js";
import { summarizeOperationRecords } from "../plugins/operations-state.js";
} from "../../../src/plugins/operations-state.js";
import { summarizeOperationRecords } from "../../../src/plugins/operations-state.js";
import {
listTaskAuditFindings,
type TaskAuditFinding,

View File

@@ -0,0 +1,13 @@
export * from "./flow-registry.js";
export * from "./flow-registry.store.js";
export * from "./flow-registry.types.js";
export * from "./flow-runtime.js";
export * from "./operations-runtime.js";
export * from "./task-executor.js";
export * from "./task-registry.audit.shared.js";
export * from "./task-registry.audit.js";
export * from "./task-registry.maintenance.js";
export * from "./task-registry.store.js";
export * from "./task-registry.summary.js";
export * from "./task-registry.js";
export * from "./task-registry.types.js";

View File

@@ -14,10 +14,10 @@ const RAW_TASK_MUTATORS = [
] as const;
const ALLOWED_CALLERS = new Set([
"tasks/operations-runtime.ts",
"tasks/task-executor.ts",
"tasks/task-registry.ts",
"tasks/task-registry.maintenance.ts",
"src/operations-runtime.ts",
"src/task-executor.ts",
"src/task-registry.ts",
"src/task-registry.maintenance.ts",
]);
async function listSourceFiles(root: string): Promise<string[]> {

View File

@@ -1,5 +1,5 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { withTempDir } from "../test-helpers/temp-dir.js";
import { withTempDir } from "../../../src/test-helpers/temp-dir.js";
import {
getFlowById,
listFlowRecords,

View File

@@ -1,5 +1,5 @@
import type { OpenClawConfig } from "../config/config.js";
import { createSubsystemLogger } from "../logging/subsystem.js";
import type { OpenClawConfig } from "../../../src/config/config.js";
import { createSubsystemLogger } from "../../../src/logging/subsystem.js";
import {
createFlowForTask,
createFlowRecord,

View File

@@ -0,0 +1 @@
export { sendMessage } from "../../../src/infra/outbound/message.js";

View File

@@ -6,15 +6,11 @@ const TASK_ROOT = path.resolve(import.meta.dirname);
const SRC_ROOT = path.resolve(TASK_ROOT, "..");
const ALLOWED_IMPORTERS = new Set([
"agents/tools/session-status-tool.ts",
"auto-reply/reply/commands-acp/runtime-options.ts",
"auto-reply/reply/commands-subagents/action-info.ts",
"commands/doctor-workspace-status.ts",
"commands/flows.ts",
"tasks/flow-runtime.ts",
"tasks/operations-runtime.ts",
"tasks/task-executor.ts",
"tasks/task-registry.maintenance.ts",
"src/flow-runtime.ts",
"src/operations-runtime.ts",
"src/runtime-core.ts",
"src/task-executor.ts",
"src/task-registry.maintenance.ts",
]);
async function listSourceFiles(root: string): Promise<string[]> {

View File

@@ -1,6 +1,6 @@
import { readAcpSessionEntry } from "../acp/runtime/session-meta.js";
import { loadSessionStore, resolveStorePath } from "../config/sessions.js";
import { parseAgentSessionKey } from "../routing/session-key.js";
import { readAcpSessionEntry } from "../../../src/acp/runtime/session-meta.js";
import { loadSessionStore, resolveStorePath } from "../../../src/config/sessions.js";
import { parseAgentSessionKey } from "../../../src/routing/session-key.js";
import { listTaskAuditFindings, summarizeTaskAuditFindings } from "./task-registry.audit.js";
import type { TaskAuditSummary } from "./task-registry.audit.js";
import {

View File

@@ -1,6 +1,6 @@
import os from "node:os";
import path from "node:path";
import { resolveStateDir } from "../config/paths.js";
import { resolveStateDir } from "../../../src/config/paths.js";
export function resolveTaskStateDir(env: NodeJS.ProcessEnv = process.env): string {
const explicit = env.OPENCLAW_STATE_DIR?.trim();

View File

@@ -1,7 +1,7 @@
import { chmodSync, existsSync, mkdirSync } from "node:fs";
import type { DatabaseSync, StatementSync } from "node:sqlite";
import { requireNodeSqlite } from "../infra/node-sqlite.js";
import type { DeliveryContext } from "../utils/delivery-context.js";
import { requireNodeSqlite } from "../../../src/infra/node-sqlite.js";
import type { DeliveryContext } from "../../../src/utils/delivery-context.js";
import { resolveTaskRegistryDir, resolveTaskRegistrySqlitePath } from "./task-registry.paths.js";
import type { TaskRegistryStoreSnapshot } from "./task-registry.store.js";
import type { TaskDeliveryState, TaskRecord } from "./task-registry.types.js";

View File

@@ -1,13 +1,13 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { startAcpSpawnParentStreamRelay } from "../agents/acp-spawn-parent-stream.js";
import { emitAgentEvent } from "../infra/agent-events.js";
import { startAcpSpawnParentStreamRelay } from "../../../src/agents/acp-spawn-parent-stream.js";
import { emitAgentEvent } from "../../../src/infra/agent-events.js";
import {
hasPendingHeartbeatWake,
resetHeartbeatWakeStateForTests,
} from "../infra/heartbeat-wake.js";
import { peekSystemEvents, resetSystemEventsForTest } from "../infra/system-events.js";
import { withTempDir } from "../test-helpers/temp-dir.js";
import { installInMemoryTaskAndFlowRegistryRuntime } from "../test-utils/task-flow-registry-runtime.js";
} from "../../../src/infra/heartbeat-wake.js";
import { peekSystemEvents, resetSystemEventsForTest } from "../../../src/infra/system-events.js";
import { withTempDir } from "../../../src/test-helpers/temp-dir.js";
import { installInMemoryTaskAndFlowRegistryRuntime } from "../../../src/test-utils/task-flow-registry-runtime.js";
import { createFlowRecord, getFlowById, resetFlowRegistryForTests } from "./flow-registry.js";
import {
createTaskRecord,

View File

@@ -1,14 +1,14 @@
import crypto from "node:crypto";
import { getAcpSessionManager } from "../acp/control-plane/manager.js";
import { killSubagentRunAdmin } from "../agents/subagent-control.js";
import type { OpenClawConfig } from "../config/config.js";
import { onAgentEvent } from "../infra/agent-events.js";
import { requestHeartbeatNow } from "../infra/heartbeat-wake.js";
import { enqueueSystemEvent } from "../infra/system-events.js";
import { createSubsystemLogger } from "../logging/subsystem.js";
import { parseAgentSessionKey } from "../routing/session-key.js";
import { normalizeDeliveryContext } from "../utils/delivery-context.js";
import { isDeliverableMessageChannel } from "../utils/message-channel.js";
import { getAcpSessionManager } from "../../../src/acp/control-plane/manager.js";
import { killSubagentRunAdmin } from "../../../src/agents/subagent-control.js";
import type { OpenClawConfig } from "../../../src/config/config.js";
import { onAgentEvent } from "../../../src/infra/agent-events.js";
import { requestHeartbeatNow } from "../../../src/infra/heartbeat-wake.js";
import { enqueueSystemEvent } from "../../../src/infra/system-events.js";
import { createSubsystemLogger } from "../../../src/logging/subsystem.js";
import { parseAgentSessionKey } from "../../../src/routing/session-key.js";
import { normalizeDeliveryContext } from "../../../src/utils/delivery-context.js";
import { isDeliverableMessageChannel } from "../../../src/utils/message-channel.js";
import { getFlowById, syncFlowFromTask } from "./flow-registry.js";
import {
formatTaskBlockedFollowupMessage,

View File

@@ -1,4 +1,4 @@
import type { DeliveryContext } from "../utils/delivery-context.js";
import type { DeliveryContext } from "../../../src/utils/delivery-context.js";
export type TaskRuntime = "subagent" | "acp" | "cli" | "cron";

View File

@@ -36,7 +36,7 @@
"speech-runtime",
"speech-core",
"plugin-runtime",
"operations-default",
"tasks",
"security-runtime",
"gateway-runtime",
"github-copilot-login",

View File

@@ -1,14 +1,14 @@
import { resolveAgentTimeoutMs } from "../../agents/timeout.js";
import type { OpenClawConfig } from "../../config/config.js";
import { logVerbose } from "../../globals.js";
import { normalizeAgentId } from "../../routing/session-key.js";
import { isAcpSessionKey } from "../../sessions/session-key-utils.js";
import {
createRunningTaskRun,
completeTaskRunByRunId,
failTaskRunByRunId,
startTaskRunByRunId,
} from "../../tasks/task-executor.js";
} from "openclaw/plugin-sdk/tasks";
import { resolveAgentTimeoutMs } from "../../agents/timeout.js";
import type { OpenClawConfig } from "../../config/config.js";
import { logVerbose } from "../../globals.js";
import { normalizeAgentId } from "../../routing/session-key.js";
import { isAcpSessionKey } from "../../sessions/session-key-utils.js";
import type { DeliveryContext } from "../../utils/delivery-context.js";
import {
AcpRuntimeError,

View File

@@ -37,9 +37,9 @@ vi.mock("../runtime/registry.js", async (importOriginal) => {
let AcpSessionManager: typeof import("./manager.js").AcpSessionManager;
let AcpRuntimeError: typeof import("../runtime/errors.js").AcpRuntimeError;
let resetAcpSessionManagerForTests: typeof import("./manager.js").__testing.resetAcpSessionManagerForTests;
let findTaskByRunId: typeof import("../../tasks/task-registry.js").findTaskByRunId;
let resetTaskRegistryForTests: typeof import("../../tasks/task-registry.js").resetTaskRegistryForTests;
let resetFlowRegistryForTests: typeof import("../../tasks/flow-registry.js").resetFlowRegistryForTests;
let findTaskByRunId: typeof import("openclaw/plugin-sdk/tasks").findTaskByRunId;
let resetTaskRegistryForTests: typeof import("openclaw/plugin-sdk/tasks").resetTaskRegistryForTests;
let resetFlowRegistryForTests: typeof import("openclaw/plugin-sdk/tasks").resetFlowRegistryForTests;
let installInMemoryTaskAndFlowRegistryRuntime: typeof import("../../test-utils/task-flow-registry-runtime.js").installInMemoryTaskAndFlowRegistryRuntime;
const baseCfg = {
@@ -184,8 +184,8 @@ describe("AcpSessionManager", () => {
__testing: { resetAcpSessionManagerForTests },
} = await import("./manager.js"));
({ AcpRuntimeError } = await import("../runtime/errors.js"));
({ findTaskByRunId, resetTaskRegistryForTests } = await import("../../tasks/task-registry.js"));
({ resetFlowRegistryForTests } = await import("../../tasks/flow-registry.js"));
({ findTaskByRunId, resetTaskRegistryForTests } = await import("openclaw/plugin-sdk/tasks"));
({ resetFlowRegistryForTests } = await import("openclaw/plugin-sdk/tasks"));
({ installInMemoryTaskAndFlowRegistryRuntime } =
await import("../../test-utils/task-flow-registry-runtime.js"));
});

View File

@@ -1,12 +1,12 @@
import { appendFile, mkdir } from "node:fs/promises";
import path from "node:path";
import { recordTaskRunProgressByRunId } from "openclaw/plugin-sdk/tasks";
import { readAcpSessionEntry } from "../acp/runtime/session-meta.js";
import { resolveSessionFilePath, resolveSessionFilePathOptions } from "../config/sessions/paths.js";
import { onAgentEvent } from "../infra/agent-events.js";
import { requestHeartbeatNow } from "../infra/heartbeat-wake.js";
import { enqueueSystemEvent } from "../infra/system-events.js";
import { scopedHeartbeatWakeOptions } from "../routing/session-key.js";
import { recordTaskRunProgressByRunId } from "../tasks/task-executor.js";
const DEFAULT_STREAM_FLUSH_MS = 2_500;
const DEFAULT_NO_OUTPUT_NOTICE_MS = 60_000;

View File

@@ -1,3 +1,4 @@
import { resetTaskRegistryForTests } from "openclaw/plugin-sdk/tasks";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import * as acpSessionManager from "../acp/control-plane/manager.js";
import type { AcpInitializeSessionInput } from "../acp/control-plane/manager.types.js";
@@ -18,7 +19,6 @@ import {
type SessionBindingPlacement,
type SessionBindingRecord,
} from "../infra/outbound/session-binding-service.js";
import { resetTaskRegistryForTests } from "../tasks/task-registry.js";
import * as acpSpawnParentStream from "./acp-spawn-parent-stream.js";
function createDefaultSpawnConfig(): OpenClawConfig {

View File

@@ -1,4 +1,5 @@
import crypto from "node:crypto";
import { createRunningTaskRun } from "openclaw/plugin-sdk/tasks";
import { getAcpSessionManager } from "../acp/control-plane/manager.js";
import {
cleanupFailedAcpSpawn,
@@ -44,7 +45,6 @@ import {
normalizeAgentId,
parseAgentSessionKey,
} from "../routing/session-key.js";
import { createRunningTaskRun } from "../tasks/task-executor.js";
import {
deliveryContextFromSession,
formatConversationTarget,

View File

@@ -192,7 +192,7 @@ async function loadFreshOpenClawToolsForSessionStatusTest() {
vi.doMock("../auto-reply/status.js", () => ({
buildStatusMessage: buildStatusMessageMock,
}));
vi.doMock("../tasks/task-registry.js", () => ({
vi.doMock("openclaw/plugin-sdk/tasks", () => ({
listTasksForSessionKey: (sessionKey: string) => listTasksForSessionKeyMock(sessionKey),
}));
({ createSessionStatusTool } = await import("./tools/session-status-tool.js"));

View File

@@ -1,11 +1,11 @@
import { isSilentReplyText, SILENT_REPLY_TOKEN } from "../auto-reply/tokens.js";
import { defaultRuntime } from "../runtime.js";
import { emitSessionLifecycleEvent } from "../sessions/session-lifecycle-events.js";
import {
completeTaskRunByRunId,
failTaskRunByRunId,
setDetachedTaskDeliveryStatusByRunId,
} from "../tasks/task-executor.js";
} from "openclaw/plugin-sdk/tasks";
import { isSilentReplyText, SILENT_REPLY_TOKEN } from "../auto-reply/tokens.js";
import { defaultRuntime } from "../runtime.js";
import { emitSessionLifecycleEvent } from "../sessions/session-lifecycle-events.js";
import { normalizeDeliveryContext } from "../utils/delivery-context.js";
import {
captureSubagentCompletionReply,

View File

@@ -1,7 +1,7 @@
import { createRunningTaskRun } from "openclaw/plugin-sdk/tasks";
import { loadConfig } from "../config/config.js";
import { callGateway } from "../gateway/call.js";
import { createSubsystemLogger } from "../logging/subsystem.js";
import { createRunningTaskRun } from "../tasks/task-executor.js";
import { type DeliveryContext, normalizeDeliveryContext } from "../utils/delivery-context.js";
import { ensureRuntimePluginsLoaded } from "./runtime-plugins.js";
import type { SubagentRunOutcome } from "./subagent-announce.js";

View File

@@ -1,4 +1,5 @@
import { Type } from "@sinclair/typebox";
import { listTasksForSessionKey } from "openclaw/plugin-sdk/tasks";
import { normalizeGroupActivation } from "../../auto-reply/group-activation.js";
import { getFollowupQueueDepth, resolveQueueSettings } from "../../auto-reply/reply/queue.js";
import { buildStatusMessage } from "../../auto-reply/status.js";
@@ -23,7 +24,6 @@ import {
resolveAgentIdFromSessionKey,
} from "../../routing/session-key.js";
import { applyModelOverrideToSessionEntry } from "../../sessions/model-overrides.js";
import { listTasksForSessionKey } from "../../tasks/task-registry.js";
import { resolveAgentConfig, resolveAgentDir } from "../agent-scope.js";
import { formatUserTime, resolveUserTimeFormat, resolveUserTimezone } from "../date-time.js";
import { resolveModelAuthLabel } from "../model-auth-label.js";

View File

@@ -114,8 +114,7 @@ const { handleAcpCommand } = await import("./commands-acp.js");
const { buildCommandTestParams } = await import("./commands-spawn.test-harness.js");
const { __testing: acpManagerTesting } = await import("../../acp/control-plane/manager.js");
const { __testing: acpResetTargetTesting } = await import("./acp-reset-target.js");
const { createTaskRecord, resetTaskRegistryForTests } =
await import("../../tasks/task-registry.js");
const { createTaskRecord, resetTaskRegistryForTests } = await import("openclaw/plugin-sdk/tasks");
function parseTelegramChatIdForTest(raw?: string | null): string | undefined {
const trimmed = raw?.trim().replace(/^telegram:/i, "");

View File

@@ -1,3 +1,4 @@
import { findLatestTaskForSessionKey } from "openclaw/plugin-sdk/tasks";
import { getAcpSessionManager } from "../../../acp/control-plane/manager.js";
import {
parseRuntimeTimeoutSecondsInput,
@@ -8,7 +9,6 @@ import {
validateRuntimePermissionProfileInput,
} from "../../../acp/control-plane/runtime-options.js";
import { resolveAcpSessionIdentifierLinesFromIdentity } from "../../../acp/runtime/session-identifiers.js";
import { findLatestTaskForSessionKey } from "../../../tasks/task-registry.js";
import type { CommandHandlerResult, HandleCommandsParams } from "../commands-types.js";
import {
ACP_CWD_USAGE,

View File

@@ -1,7 +1,7 @@
import { findTaskByRunId } from "openclaw/plugin-sdk/tasks";
import { countPendingDescendantRuns } from "../../../agents/subagent-registry.js";
import { loadSessionStore, resolveStorePath } from "../../../config/sessions.js";
import { formatDurationCompact } from "../../../shared/subagents-format.js";
import { findTaskByRunId } from "../../../tasks/task-registry.js";
import type { CommandHandlerResult } from "../commands-types.js";
import { formatRunLabel } from "../subagents-utils.js";
import {

View File

@@ -249,8 +249,7 @@ const { parseConfigCommand } = await import("./config-commands.js");
const { parseDebugCommand } = await import("./debug-commands.js");
const { parseInlineDirectives } = await import("./directive-handling.js");
const { buildCommandContext, handleCommands } = await import("./commands.js");
const { createTaskRecord, resetTaskRegistryForTests } =
await import("../../tasks/task-registry.js");
const { createTaskRecord, resetTaskRegistryForTests } = await import("openclaw/plugin-sdk/tasks");
let testWorkspaceDir = os.tmpdir();

View File

@@ -52,11 +52,11 @@ vi.mock("../plugins/memory-state.js", () => ({
hasMemoryRuntime: hasMemoryRuntimeMock,
}));
vi.mock("../tasks/task-registry.js", () => ({
vi.mock("openclaw/plugin-sdk/tasks", () => ({
ensureTaskRegistryReady: ensureTaskRegistryReadyMock,
}));
vi.mock("../tasks/task-registry.maintenance.js", () => ({
vi.mock("openclaw/plugin-sdk/tasks", () => ({
startTaskRegistryMaintenance: startTaskRegistryMaintenanceMock,
}));

View File

@@ -32,11 +32,11 @@ vi.mock("../plugins/status.js", () => ({
mocks.buildPluginCompatibilityWarnings(...args),
}));
vi.mock("../tasks/flow-registry.js", () => ({
vi.mock("openclaw/plugin-sdk/tasks", () => ({
listFlowRecords: (...args: unknown[]) => mocks.listFlowRecords(...args),
}));
vi.mock("../tasks/task-registry.js", () => ({
vi.mock("openclaw/plugin-sdk/tasks", () => ({
listTasksForFlowId: (...args: unknown[]) => mocks.listTasksForFlowId(...args),
}));

View File

@@ -1,10 +1,10 @@
import { listFlowRecords } from "openclaw/plugin-sdk/tasks";
import { listTasksForFlowId } from "openclaw/plugin-sdk/tasks";
import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js";
import { buildWorkspaceSkillStatus } from "../agents/skills-status.js";
import { formatCliCommand } from "../cli/command-format.js";
import type { OpenClawConfig } from "../config/config.js";
import { buildPluginCompatibilityWarnings, buildPluginStatusReport } from "../plugins/status.js";
import { listFlowRecords } from "../tasks/flow-registry.js";
import { listTasksForFlowId } from "../tasks/task-registry.js";
import { note } from "../terminal/note.js";
import { detectLegacyWorkspaceDirs, formatLegacyWorkspaceWarning } from "./doctor-workspace.js";

View File

@@ -12,17 +12,11 @@ const mocks = vi.hoisted(() => ({
loadConfigMock: vi.fn(() => ({ loaded: true })),
}));
vi.mock("../tasks/flow-registry.js", () => ({
vi.mock("openclaw/plugin-sdk/tasks", () => ({
listFlowRecords: (...args: unknown[]) => mocks.listFlowRecordsMock(...args),
resolveFlowForLookupToken: (...args: unknown[]) => mocks.resolveFlowForLookupTokenMock(...args),
getFlowById: (...args: unknown[]) => mocks.getFlowByIdMock(...args),
}));
vi.mock("../tasks/task-registry.js", () => ({
listTasksForFlowId: (...args: unknown[]) => mocks.listTasksForFlowIdMock(...args),
}));
vi.mock("../tasks/task-executor.js", () => ({
getFlowTaskSummary: (...args: unknown[]) => mocks.getFlowTaskSummaryMock(...args),
cancelFlowById: (...args: unknown[]) => mocks.cancelFlowByIdMock(...args),
}));

View File

@@ -1,10 +1,10 @@
import { getFlowById, listFlowRecords, resolveFlowForLookupToken } from "openclaw/plugin-sdk/tasks";
import type { FlowRecord, FlowStatus } from "openclaw/plugin-sdk/tasks";
import { cancelFlowById, getFlowTaskSummary } from "openclaw/plugin-sdk/tasks";
import { listTasksForFlowId } from "openclaw/plugin-sdk/tasks";
import { loadConfig } from "../config/config.js";
import { info } from "../globals.js";
import type { RuntimeEnv } from "../runtime.js";
import { getFlowById, listFlowRecords, resolveFlowForLookupToken } from "../tasks/flow-registry.js";
import type { FlowRecord, FlowStatus } from "../tasks/flow-registry.types.js";
import { cancelFlowById, getFlowTaskSummary } from "../tasks/task-executor.js";
import { listTasksForFlowId } from "../tasks/task-registry.js";
import { isRich, theme } from "../terminal/theme.js";
const ID_PAD = 10;

View File

@@ -1,10 +1,10 @@
import { createEmptyTaskAuditSummary } from "openclaw/plugin-sdk/tasks";
import { createEmptyTaskRegistrySummary } from "openclaw/plugin-sdk/tasks";
import type { OpenClawConfig } from "../config/types.js";
import type { UpdateCheckResult } from "../infra/update-check.js";
import { loggingState } from "../logging/state.js";
import { runExec } from "../process/exec.js";
import type { RuntimeEnv } from "../runtime.js";
import { createEmptyTaskAuditSummary } from "../tasks/task-registry.audit.shared.js";
import { createEmptyTaskRegistrySummary } from "../tasks/task-registry.summary.js";
import type { getAgentLocalStatuses as getAgentLocalStatusesFn } from "./status.agent-local.js";
import type { StatusScanResult } from "./status.scan.js";
import {

View File

@@ -1,4 +1,6 @@
import { existsSync } from "node:fs";
import { createEmptyTaskAuditSummary } from "openclaw/plugin-sdk/tasks";
import { createEmptyTaskRegistrySummary } from "openclaw/plugin-sdk/tasks";
import { resolveMemorySearchConfig } from "../agents/memory-search.js";
import { hasPotentialConfiguredChannels } from "../channels/config-presence.js";
import { resolveCommandSecretRefsViaGateway } from "../cli/command-secret-gateway.js";
@@ -17,8 +19,6 @@ import {
import { runExec } from "../process/exec.js";
import type { RuntimeEnv } from "../runtime.js";
import { createLazyRuntimeSurface } from "../shared/lazy-runtime.js";
import { createEmptyTaskAuditSummary } from "../tasks/task-registry.audit.shared.js";
import { createEmptyTaskRegistrySummary } from "../tasks/task-registry.summary.js";
import type { buildChannelsTable as buildChannelsTableFn } from "./status-all/channels.js";
import type { getAgentLocalStatuses as getAgentLocalStatusesFn } from "./status.agent-local.js";
import { buildColdStartUpdateResult, scanStatusJsonCore } from "./status.scan.json-core.js";

View File

@@ -59,7 +59,7 @@ vi.mock("../infra/system-events.js", () => ({
peekSystemEvents: vi.fn(() => []),
}));
vi.mock("../tasks/task-registry.maintenance.js", () => ({
vi.mock("openclaw/plugin-sdk/tasks", () => ({
getInspectableTaskRegistrySummary: vi.fn(() => ({
total: 0,
active: 0,

View File

@@ -17,7 +17,7 @@ let channelSummaryModulePromise: Promise<typeof import("../infra/channel-summary
let linkChannelModulePromise: Promise<typeof import("./status.link-channel.js")> | undefined;
let configIoModulePromise: Promise<typeof import("../config/io.js")> | undefined;
let taskRegistryMaintenanceModulePromise:
| Promise<typeof import("../tasks/task-registry.maintenance.js")>
| Promise<typeof import("openclaw/plugin-sdk/tasks")>
| undefined;
function loadChannelSummaryModule() {
@@ -41,7 +41,7 @@ function loadConfigIoModule() {
}
function loadTaskRegistryMaintenanceModule() {
taskRegistryMaintenanceModulePromise ??= import("../tasks/task-registry.maintenance.js");
taskRegistryMaintenanceModulePromise ??= import("openclaw/plugin-sdk/tasks");
return taskRegistryMaintenanceModulePromise;
}

View File

@@ -467,7 +467,7 @@ vi.mock("../daemon/node-service.js", () => ({
vi.mock("../node-host/config.js", () => ({
loadNodeHostConfig: mocks.loadNodeHostConfig,
}));
vi.mock("../tasks/task-registry.maintenance.js", () => ({
vi.mock("openclaw/plugin-sdk/tasks", () => ({
getInspectableTaskRegistrySummary: mocks.getInspectableTaskRegistrySummary,
getInspectableTaskAuditSummary: mocks.getInspectableTaskAuditSummary,
}));

View File

@@ -1,6 +1,6 @@
import type { TaskAuditSummary } from "openclaw/plugin-sdk/tasks";
import type { TaskRegistrySummary } from "openclaw/plugin-sdk/tasks";
import type { ChannelId } from "../channels/plugins/types.js";
import type { TaskAuditSummary } from "../tasks/task-registry.audit.js";
import type { TaskRegistrySummary } from "../tasks/task-registry.types.js";
export type SessionStatus = {
agentId?: string;

View File

@@ -1,8 +1,8 @@
import fs from "node:fs/promises";
import path from "node:path";
import * as taskExecutor from "openclaw/plugin-sdk/tasks";
import { findTaskByRunId, resetTaskRegistryForTests } from "openclaw/plugin-sdk/tasks";
import { describe, expect, it, vi } from "vitest";
import * as taskExecutor from "../../tasks/task-executor.js";
import { findTaskByRunId, resetTaskRegistryForTests } from "../../tasks/task-registry.js";
import { setupCronServiceSuite, writeCronStoreSnapshot } from "../service.test-harness.js";
import type { CronJob } from "../types.js";
import { run, start, stop } from "./ops.js";

View File

@@ -1,10 +1,10 @@
import { enqueueCommandInLane } from "../../process/command-queue.js";
import { CommandLane } from "../../process/lanes.js";
import {
completeTaskRunByRunId,
createRunningTaskRun,
failTaskRunByRunId,
} from "../../tasks/task-executor.js";
} from "openclaw/plugin-sdk/tasks";
import { enqueueCommandInLane } from "../../process/command-queue.js";
import { CommandLane } from "../../process/lanes.js";
import type { CronJob, CronJobCreate, CronJobPatch } from "../types.js";
import { normalizeCronCreateDeliveryInput } from "./initial-delivery.js";
import {

View File

@@ -1,11 +1,11 @@
import fs from "node:fs/promises";
import * as taskExecutor from "openclaw/plugin-sdk/tasks";
import { resetTaskRegistryForTests } from "openclaw/plugin-sdk/tasks";
import { afterEach, describe, expect, it, vi } from "vitest";
import { setupCronServiceSuite, writeCronStoreSnapshot } from "../../cron/service.test-harness.js";
import { createCronServiceState } from "../../cron/service/state.js";
import { onTimer } from "../../cron/service/timer.js";
import type { CronJob } from "../../cron/types.js";
import * as taskExecutor from "../../tasks/task-executor.js";
import { resetTaskRegistryForTests } from "../../tasks/task-registry.js";
const { logger, makeStorePath } = setupCronServiceSuite({
prefix: "cron-service-timer-seam",

View File

@@ -1,12 +1,12 @@
import { resolveFailoverReasonFromError } from "../../agents/failover-error.js";
import type { CronConfig, CronRetryOn } from "../../config/types.cron.js";
import type { HeartbeatRunResult } from "../../infra/heartbeat-wake.js";
import { DEFAULT_AGENT_ID } from "../../routing/session-key.js";
import {
completeTaskRunByRunId,
createRunningTaskRun,
failTaskRunByRunId,
} from "../../tasks/task-executor.js";
} from "openclaw/plugin-sdk/tasks";
import { resolveFailoverReasonFromError } from "../../agents/failover-error.js";
import type { CronConfig, CronRetryOn } from "../../config/types.cron.js";
import type { HeartbeatRunResult } from "../../infra/heartbeat-wake.js";
import { DEFAULT_AGENT_ID } from "../../routing/session-key.js";
import { resolveCronDeliveryPlan } from "../delivery.js";
import { sweepCronRunSessions } from "../session-reaper.js";
import type {

View File

@@ -1,6 +1,6 @@
import { findTaskByRunId, resetTaskRegistryForTests } from "openclaw/plugin-sdk/tasks";
import { afterEach, describe, expect, it, vi } from "vitest";
import { BARE_SESSION_RESET_PROMPT } from "../../auto-reply/reply/session-reset-prompt.js";
import { findTaskByRunId, resetTaskRegistryForTests } from "../../tasks/task-registry.js";
import { withTempDir } from "../../test-helpers/temp-dir.js";
import { agentHandlers } from "./agent.js";
import { expectSubagentFollowupReactivation } from "./subagent-followup.test-helpers.js";

View File

@@ -1,4 +1,5 @@
import { randomUUID } from "node:crypto";
import { createRunningTaskRun } from "openclaw/plugin-sdk/tasks";
import { listAgentIds } from "../../agents/agent-scope.js";
import type { AgentInternalEvent } from "../../agents/internal-events.js";
import {
@@ -28,7 +29,6 @@ import { classifySessionKeyShape, normalizeAgentId } from "../../routing/session
import { defaultRuntime } from "../../runtime.js";
import { normalizeInputProvenance, type InputProvenance } from "../../sessions/input-provenance.js";
import { resolveSendPolicy } from "../../sessions/send-policy.js";
import { createRunningTaskRun } from "../../tasks/task-executor.js";
import {
normalizeDeliveryContext,
normalizeSessionDeliveryFields,

View File

@@ -1,3 +1,4 @@
import { getInspectableTaskRegistrySummary } from "openclaw/plugin-sdk/tasks";
import { getActiveEmbeddedRunCount } from "../agents/pi-embedded-runner/runs.js";
import { getTotalPendingReplies } from "../auto-reply/reply/dispatcher-registry.js";
import type { CliDeps } from "../cli/deps.js";
@@ -16,7 +17,6 @@ import {
} from "../infra/restart.js";
import { setCommandLaneConcurrency, getTotalQueueSize } from "../process/command-queue.js";
import { CommandLane } from "../process/lanes.js";
import { getInspectableTaskRegistrySummary } from "../tasks/task-registry.maintenance.js";
import type { ChannelHealthMonitor } from "./channel-health-monitor.js";
import type { ChannelKind } from "./config-reload-plan.js";
import type { GatewayReloadPlan } from "./config-reload.js";

View File

@@ -1,4 +1,5 @@
import path from "node:path";
import { getInspectableTaskRegistrySummary } from "openclaw/plugin-sdk/tasks";
import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js";
import { getActiveEmbeddedRunCount } from "../agents/pi-embedded-runner/runs.js";
import { registerSkillsChangeListener } from "../agents/skills/refresh.js";
@@ -75,7 +76,6 @@ import {
} from "../secrets/runtime.js";
import { onSessionLifecycleEvent } from "../sessions/session-lifecycle-events.js";
import { onSessionTranscriptUpdate } from "../sessions/transcript-events.js";
import { getInspectableTaskRegistrySummary } from "../tasks/task-registry.maintenance.js";
import { runSetupWizard } from "../wizard/setup.js";
import { createAuthRateLimiter, type AuthRateLimiter } from "./auth-rate-limit.js";
import { startChannelHealthMonitor } from "./channel-health-monitor.js";

View File

@@ -1,6 +1,8 @@
import { defaultTaskOperationsRuntime } from "../../packages/tasks-host-sdk/src/runtime-core.js";
import { startTaskRegistryMaintenance } from "../../packages/tasks-host-sdk/src/runtime-core.js";
import type { OpenClawPluginService } from "../plugins/types.js";
import { defaultTaskOperationsRuntime } from "../tasks/operations-runtime.js";
import { startTaskRegistryMaintenance } from "../tasks/task-registry.maintenance.js";
export * from "../../packages/tasks-host-sdk/src/runtime-core.js";
export const defaultOperationsRuntime = defaultTaskOperationsRuntime;

View File

@@ -1,3 +1,4 @@
import { defaultTaskOperationsRuntime } from "openclaw/plugin-sdk/tasks";
import { resolveStateDir } from "../../config/paths.js";
import { loadBundledPluginPublicSurfaceModuleSync } from "../../plugin-sdk/facade-runtime.js";
import { resolveGlobalSingleton } from "../../shared/global-singleton.js";
@@ -6,7 +7,6 @@ import {
createLazyRuntimeMethodBinder,
createLazyRuntimeModule,
} from "../../shared/lazy-runtime.js";
import { defaultTaskOperationsRuntime } from "../../tasks/operations-runtime.js";
import { VERSION } from "../../version.js";
import { listWebSearchProviders, runWebSearch } from "../../web-search/runtime.js";
import { getRegisteredOperationsRuntime } from "../operations-state.js";

View File

@@ -1 +0,0 @@
export { sendMessage } from "../infra/outbound/message.js";

View File

@@ -2,14 +2,14 @@ import {
configureFlowRegistryRuntime,
type FlowRegistryStore,
type FlowRegistryStoreSnapshot,
} from "../tasks/flow-registry.store.js";
import type { FlowRecord } from "../tasks/flow-registry.types.js";
} from "openclaw/plugin-sdk/tasks";
import type { FlowRecord } from "openclaw/plugin-sdk/tasks";
import {
configureTaskRegistryRuntime,
type TaskRegistryStore,
type TaskRegistryStoreSnapshot,
} from "../tasks/task-registry.store.js";
import type { TaskDeliveryState, TaskRecord } from "../tasks/task-registry.types.js";
} from "openclaw/plugin-sdk/tasks";
import type { TaskDeliveryState, TaskRecord } from "openclaw/plugin-sdk/tasks";
function cloneTask(task: TaskRecord): TaskRecord {
return { ...task };

View File

@@ -13,7 +13,8 @@
"include": [
"src/plugin-sdk/**/*.ts",
"src/types/**/*.d.ts",
"packages/memory-host-sdk/src/**/*.ts"
"packages/memory-host-sdk/src/**/*.ts",
"packages/tasks-host-sdk/src/**/*.ts"
],
"exclude": ["node_modules", "dist", "src/**/*.test.ts"]
}