Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
229 lines
6.4 KiB
TypeScript
229 lines
6.4 KiB
TypeScript
// Lobster tests cover lobster taskflow plugin behavior.
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import type { LobsterRunner } from "./lobster-runner.js";
|
|
import { resumeManagedLobsterFlow, runManagedLobsterFlow } from "./lobster-taskflow.js";
|
|
import { createFakeTaskFlow } from "./taskflow-test-helpers.js";
|
|
|
|
function expectManagedFlowFailure(
|
|
result: Awaited<ReturnType<typeof runManagedLobsterFlow | typeof resumeManagedLobsterFlow>>,
|
|
) {
|
|
expect(result.ok).toBe(false);
|
|
if (result.ok) {
|
|
throw new Error("Expected managed Lobster flow to fail");
|
|
}
|
|
return result;
|
|
}
|
|
function createRunner(result: Awaited<ReturnType<LobsterRunner["run"]>>): LobsterRunner {
|
|
return {
|
|
run: vi.fn().mockResolvedValue(result),
|
|
};
|
|
}
|
|
|
|
function createRunFlowParams(
|
|
taskFlow: ReturnType<typeof createFakeTaskFlow>,
|
|
runner: LobsterRunner,
|
|
): Parameters<typeof runManagedLobsterFlow>[0] {
|
|
return {
|
|
taskFlow,
|
|
runner,
|
|
runnerParams: {
|
|
action: "run",
|
|
pipeline: "noop",
|
|
cwd: process.cwd(),
|
|
timeoutMs: 1000,
|
|
maxStdoutBytes: 4096,
|
|
},
|
|
controllerId: "tests/lobster",
|
|
goal: "Run Lobster workflow",
|
|
};
|
|
}
|
|
|
|
function createResumeFlowParams(
|
|
taskFlow: ReturnType<typeof createFakeTaskFlow>,
|
|
runner: LobsterRunner,
|
|
): Parameters<typeof resumeManagedLobsterFlow>[0] {
|
|
return {
|
|
taskFlow,
|
|
runner,
|
|
flowId: "flow-1",
|
|
expectedRevision: 4,
|
|
runnerParams: {
|
|
action: "resume",
|
|
token: "resume-1",
|
|
approve: true,
|
|
cwd: process.cwd(),
|
|
timeoutMs: 1000,
|
|
maxStdoutBytes: 4096,
|
|
},
|
|
};
|
|
}
|
|
|
|
describe("runManagedLobsterFlow", () => {
|
|
it("creates a flow and finishes it when Lobster succeeds", async () => {
|
|
const taskFlow = createFakeTaskFlow();
|
|
const runner = createRunner({
|
|
ok: true,
|
|
status: "ok",
|
|
output: [{ id: "result-1" }],
|
|
requiresApproval: null,
|
|
});
|
|
|
|
const result = await runManagedLobsterFlow(createRunFlowParams(taskFlow, runner));
|
|
|
|
expect(result.ok).toBe(true);
|
|
expect(taskFlow.createManaged).toHaveBeenCalledWith({
|
|
controllerId: "tests/lobster",
|
|
goal: "Run Lobster workflow",
|
|
currentStep: "run_lobster",
|
|
});
|
|
expect(taskFlow.finish).toHaveBeenCalledWith({
|
|
flowId: "flow-1",
|
|
expectedRevision: 1,
|
|
});
|
|
});
|
|
|
|
it("moves the flow to waiting when Lobster requests approval", async () => {
|
|
const taskFlow = createFakeTaskFlow();
|
|
const createdAt = new Date("2026-04-05T21:00:00.000Z");
|
|
const runner = createRunner({
|
|
ok: true,
|
|
status: "needs_approval",
|
|
output: [],
|
|
requiresApproval: {
|
|
type: "approval_request",
|
|
prompt: "Approve this?",
|
|
items: [{ id: "item-1", createdAt, count: 2n, skip: undefined }],
|
|
resumeToken: "resume-1",
|
|
},
|
|
});
|
|
|
|
const result = await runManagedLobsterFlow(createRunFlowParams(taskFlow, runner));
|
|
|
|
expect(result.ok).toBe(true);
|
|
expect(taskFlow.setWaiting).toHaveBeenCalledWith({
|
|
flowId: "flow-1",
|
|
expectedRevision: 1,
|
|
currentStep: "await_lobster_approval",
|
|
waitJson: {
|
|
kind: "lobster_approval",
|
|
prompt: "Approve this?",
|
|
items: [{ id: "item-1", createdAt: createdAt.toISOString(), count: "2" }],
|
|
resumeToken: "resume-1",
|
|
},
|
|
});
|
|
});
|
|
|
|
it("fails the flow when Lobster returns an error envelope", async () => {
|
|
const taskFlow = createFakeTaskFlow();
|
|
const runner = createRunner({
|
|
ok: false,
|
|
error: {
|
|
type: "runtime_error",
|
|
message: "boom",
|
|
},
|
|
});
|
|
|
|
const result = expectManagedFlowFailure(
|
|
await runManagedLobsterFlow(createRunFlowParams(taskFlow, runner)),
|
|
);
|
|
expect(result.error.message).toBe("boom");
|
|
expect(taskFlow.fail).toHaveBeenCalledWith({
|
|
flowId: "flow-1",
|
|
expectedRevision: 1,
|
|
});
|
|
});
|
|
|
|
it("fails the flow when the runner throws", async () => {
|
|
const taskFlow = createFakeTaskFlow();
|
|
const runner: LobsterRunner = {
|
|
run: vi.fn().mockRejectedValue(new Error("crashed")),
|
|
};
|
|
|
|
const result = expectManagedFlowFailure(
|
|
await runManagedLobsterFlow(createRunFlowParams(taskFlow, runner)),
|
|
);
|
|
expect(result.error.message).toBe("crashed");
|
|
expect(taskFlow.fail).toHaveBeenCalledWith({
|
|
flowId: "flow-1",
|
|
expectedRevision: 1,
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("resumeManagedLobsterFlow", () => {
|
|
it("resumes the flow and finishes it on success", async () => {
|
|
const taskFlow = createFakeTaskFlow();
|
|
const runner = createRunner({
|
|
ok: true,
|
|
status: "ok",
|
|
output: [],
|
|
requiresApproval: null,
|
|
});
|
|
|
|
const result = await resumeManagedLobsterFlow(createResumeFlowParams(taskFlow, runner));
|
|
|
|
expect(result.ok).toBe(true);
|
|
expect(taskFlow.resume).toHaveBeenCalledWith({
|
|
flowId: "flow-1",
|
|
expectedRevision: 4,
|
|
status: "running",
|
|
currentStep: "resume_lobster",
|
|
});
|
|
expect(taskFlow.finish).toHaveBeenCalledWith({
|
|
flowId: "flow-1",
|
|
expectedRevision: 5,
|
|
});
|
|
});
|
|
|
|
it("returns a mutation error when taskFlow resume is rejected", async () => {
|
|
const taskFlow = createFakeTaskFlow({
|
|
resume: vi.fn().mockReturnValue({
|
|
applied: false,
|
|
code: "revision_conflict",
|
|
}),
|
|
});
|
|
const runner = createRunner({
|
|
ok: true,
|
|
status: "ok",
|
|
output: [],
|
|
requiresApproval: null,
|
|
});
|
|
|
|
const result = expectManagedFlowFailure(
|
|
await resumeManagedLobsterFlow(createResumeFlowParams(taskFlow, runner)),
|
|
);
|
|
expect(result.error.message).toMatch(/revision_conflict/);
|
|
expect(runner.run).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("returns to waiting when the resumed Lobster run needs approval again", async () => {
|
|
const taskFlow = createFakeTaskFlow();
|
|
const runner = createRunner({
|
|
ok: true,
|
|
status: "needs_approval",
|
|
output: [],
|
|
requiresApproval: {
|
|
type: "approval_request",
|
|
prompt: "Approve this too?",
|
|
items: [{ id: "item-2" }],
|
|
resumeToken: "resume-2",
|
|
},
|
|
});
|
|
|
|
const result = await resumeManagedLobsterFlow(createResumeFlowParams(taskFlow, runner));
|
|
|
|
expect(result.ok).toBe(true);
|
|
expect(taskFlow.setWaiting).toHaveBeenCalledWith({
|
|
flowId: "flow-1",
|
|
expectedRevision: 5,
|
|
currentStep: "await_lobster_approval",
|
|
waitJson: {
|
|
kind: "lobster_approval",
|
|
prompt: "Approve this too?",
|
|
items: [{ id: "item-2" }],
|
|
resumeToken: "resume-2",
|
|
},
|
|
});
|
|
});
|
|
});
|