Vendor OpenClaw source as Adolf fork baseline
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
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
This commit is contained in:
430
extensions/lobster/src/lobster-tool.test.ts
Normal file
430
extensions/lobster/src/lobster-tool.test.ts
Normal file
@@ -0,0 +1,430 @@
|
||||
// Lobster tests cover lobster tool plugin behavior.
|
||||
import { createTestPluginApi } from "openclaw/plugin-sdk/plugin-test-api";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawPluginApi, OpenClawPluginToolContext } from "../runtime-api.js";
|
||||
import { createLobsterTool } from "./lobster-tool.js";
|
||||
import { createFakeTaskFlow } from "./taskflow-test-helpers.js";
|
||||
|
||||
function fakeApi(overrides: Partial<OpenClawPluginApi> = {}): OpenClawPluginApi {
|
||||
return createTestPluginApi({
|
||||
id: "lobster",
|
||||
name: "lobster",
|
||||
source: "test",
|
||||
runtime: { version: "test" } as any,
|
||||
resolvePath: (p) => p,
|
||||
...overrides,
|
||||
});
|
||||
}
|
||||
|
||||
function fakeCtx(overrides: Partial<OpenClawPluginToolContext> = {}): OpenClawPluginToolContext {
|
||||
return {
|
||||
config: {},
|
||||
workspaceDir: "/tmp",
|
||||
agentDir: "/tmp",
|
||||
agentId: "main",
|
||||
sessionKey: "main",
|
||||
messageChannel: undefined,
|
||||
agentAccountId: undefined,
|
||||
sandboxed: false,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
function requireRecord(value: unknown, label: string): Record<string, unknown> {
|
||||
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
||||
throw new Error(`expected ${label} to be a record`);
|
||||
}
|
||||
return value as Record<string, unknown>;
|
||||
}
|
||||
|
||||
describe("lobster plugin tool", () => {
|
||||
it("returns the Lobster envelope in details", async () => {
|
||||
const runner = {
|
||||
run: vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
status: "ok",
|
||||
output: [{ hello: "world" }],
|
||||
requiresApproval: null,
|
||||
}),
|
||||
};
|
||||
|
||||
const tool = createLobsterTool(fakeApi(), { runner });
|
||||
const res = await tool.execute("call1", {
|
||||
action: "run",
|
||||
pipeline: "noop",
|
||||
timeoutMs: 1000,
|
||||
});
|
||||
|
||||
expect(runner.run).toHaveBeenCalledWith({
|
||||
action: "run",
|
||||
pipeline: "noop",
|
||||
cwd: process.cwd(),
|
||||
timeoutMs: 1000,
|
||||
maxStdoutBytes: 512_000,
|
||||
});
|
||||
const details = requireRecord(res.details, "lobster tool details");
|
||||
expect(details.ok).toBe(true);
|
||||
expect(details.status).toBe("ok");
|
||||
expect(details.output).toEqual([{ hello: "world" }]);
|
||||
expect(details.requiresApproval).toBeNull();
|
||||
});
|
||||
|
||||
it("supports approval envelopes without changing the tool contract", async () => {
|
||||
const runner = {
|
||||
run: vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
status: "needs_approval",
|
||||
output: [],
|
||||
requiresApproval: {
|
||||
type: "approval_request",
|
||||
prompt: "Send these alerts?",
|
||||
items: [{ id: "alert-1" }],
|
||||
resumeToken: "resume-token-1",
|
||||
},
|
||||
}),
|
||||
};
|
||||
|
||||
const tool = createLobsterTool(fakeApi(), { runner });
|
||||
const res = await tool.execute("call-injected-runner", {
|
||||
action: "run",
|
||||
pipeline: "noop",
|
||||
argsJson: '{"since_hours":1}',
|
||||
timeoutMs: 1500,
|
||||
maxStdoutBytes: 4096,
|
||||
});
|
||||
|
||||
expect(runner.run).toHaveBeenCalledWith({
|
||||
action: "run",
|
||||
pipeline: "noop",
|
||||
argsJson: '{"since_hours":1}',
|
||||
cwd: process.cwd(),
|
||||
timeoutMs: 1500,
|
||||
maxStdoutBytes: 4096,
|
||||
});
|
||||
const details = requireRecord(res.details, "approval lobster tool details");
|
||||
expect(details.ok).toBe(true);
|
||||
expect(details.status).toBe("needs_approval");
|
||||
const approval = requireRecord(details.requiresApproval, "approval request");
|
||||
expect(approval.type).toBe("approval_request");
|
||||
expect(approval.prompt).toBe("Send these alerts?");
|
||||
expect(approval.resumeToken).toBe("resume-token-1");
|
||||
});
|
||||
|
||||
it("normalizes numeric string run limits before invoking the runner", async () => {
|
||||
const runner = {
|
||||
run: vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
status: "ok",
|
||||
output: [],
|
||||
requiresApproval: null,
|
||||
}),
|
||||
};
|
||||
|
||||
const tool = createLobsterTool(fakeApi(), { runner });
|
||||
await tool.execute("call-string-limits", {
|
||||
action: "run",
|
||||
pipeline: "noop",
|
||||
timeoutMs: "1500",
|
||||
maxStdoutBytes: "4096",
|
||||
});
|
||||
|
||||
expect(runner.run).toHaveBeenCalledWith({
|
||||
action: "run",
|
||||
pipeline: "noop",
|
||||
cwd: process.cwd(),
|
||||
timeoutMs: 1500,
|
||||
maxStdoutBytes: 4096,
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects malformed numeric run limits before invoking the runner", async () => {
|
||||
const runner = { run: vi.fn() };
|
||||
const tool = createLobsterTool(fakeApi(), { runner });
|
||||
|
||||
await expect(
|
||||
tool.execute("call-bad-timeout", {
|
||||
action: "run",
|
||||
pipeline: "noop",
|
||||
timeoutMs: "1500.5",
|
||||
}),
|
||||
).rejects.toThrow("timeoutMs must be a positive integer");
|
||||
await expect(
|
||||
tool.execute("call-bad-stdout", {
|
||||
action: "run",
|
||||
pipeline: "noop",
|
||||
maxStdoutBytes: 0,
|
||||
}),
|
||||
).rejects.toThrow("maxStdoutBytes must be a positive integer");
|
||||
expect(runner.run).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("throws when the runner returns an error envelope", async () => {
|
||||
const tool = createLobsterTool(fakeApi(), {
|
||||
runner: {
|
||||
run: vi.fn().mockResolvedValue({
|
||||
ok: false,
|
||||
error: {
|
||||
type: "runtime_error",
|
||||
message: "boom",
|
||||
},
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
await expect(
|
||||
tool.execute("call-runner-error", {
|
||||
action: "run",
|
||||
pipeline: "noop",
|
||||
}),
|
||||
).rejects.toThrow("boom");
|
||||
});
|
||||
|
||||
it("can run through managed TaskFlow mode", async () => {
|
||||
const runner = {
|
||||
run: vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
status: "needs_approval",
|
||||
output: [],
|
||||
requiresApproval: {
|
||||
type: "approval_request",
|
||||
prompt: "Approve this?",
|
||||
items: [{ id: "item-1" }],
|
||||
resumeToken: "resume-1",
|
||||
approvalId: "approval-1",
|
||||
},
|
||||
}),
|
||||
};
|
||||
const taskFlow = createFakeTaskFlow();
|
||||
|
||||
const tool = createLobsterTool(fakeApi(), { runner, taskFlow });
|
||||
const res = await tool.execute("call-managed-run", {
|
||||
action: "run",
|
||||
pipeline: "noop",
|
||||
flowControllerId: "tests/lobster",
|
||||
flowGoal: "Run Lobster workflow",
|
||||
flowStateJson: '{"lane":"email"}',
|
||||
flowCurrentStep: "run_lobster",
|
||||
flowWaitingStep: "await_review",
|
||||
});
|
||||
|
||||
expect(taskFlow.createManaged).toHaveBeenCalledWith({
|
||||
controllerId: "tests/lobster",
|
||||
goal: "Run Lobster workflow",
|
||||
currentStep: "run_lobster",
|
||||
stateJson: { lane: "email" },
|
||||
});
|
||||
expect(taskFlow.setWaiting).toHaveBeenCalledWith({
|
||||
flowId: "flow-1",
|
||||
expectedRevision: 1,
|
||||
currentStep: "await_review",
|
||||
waitJson: {
|
||||
kind: "lobster_approval",
|
||||
prompt: "Approve this?",
|
||||
items: [{ id: "item-1" }],
|
||||
resumeToken: "resume-1",
|
||||
approvalId: "approval-1",
|
||||
},
|
||||
});
|
||||
const details = requireRecord(res.details, "managed run lobster tool details");
|
||||
expect(details.ok).toBe(true);
|
||||
expect(details.status).toBe("needs_approval");
|
||||
const flow = requireRecord(details.flow, "managed run flow details");
|
||||
expect(flow.flowId).toBe("flow-1");
|
||||
const mutation = requireRecord(details.mutation, "managed run mutation details");
|
||||
expect(mutation.applied).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects managed TaskFlow params when no bound taskFlow runtime is available", async () => {
|
||||
const tool = createLobsterTool(fakeApi(), {
|
||||
runner: { run: vi.fn() },
|
||||
});
|
||||
|
||||
await expect(
|
||||
tool.execute("call-missing-taskflow", {
|
||||
action: "run",
|
||||
pipeline: "noop",
|
||||
flowControllerId: "tests/lobster",
|
||||
flowGoal: "Run Lobster workflow",
|
||||
}),
|
||||
).rejects.toThrow(/Managed TaskFlow run mode requires a bound taskFlow runtime/);
|
||||
});
|
||||
|
||||
it("rejects invalid flowStateJson in managed TaskFlow mode", async () => {
|
||||
const tool = createLobsterTool(fakeApi(), {
|
||||
runner: { run: vi.fn() },
|
||||
taskFlow: createFakeTaskFlow(),
|
||||
});
|
||||
|
||||
await expect(
|
||||
tool.execute("call-invalid-flow-json", {
|
||||
action: "run",
|
||||
pipeline: "noop",
|
||||
flowControllerId: "tests/lobster",
|
||||
flowGoal: "Run Lobster workflow",
|
||||
flowStateJson: "{bad",
|
||||
}),
|
||||
).rejects.toThrow(/flowStateJson must be valid JSON/);
|
||||
});
|
||||
|
||||
it("can resume managed TaskFlow mode with only approvalId", async () => {
|
||||
const runner = {
|
||||
run: vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
status: "ok",
|
||||
output: [],
|
||||
requiresApproval: null,
|
||||
}),
|
||||
};
|
||||
const taskFlow = createFakeTaskFlow();
|
||||
const tool = createLobsterTool(fakeApi(), { runner, taskFlow });
|
||||
|
||||
const res = await tool.execute("call-managed-resume-approval-id", {
|
||||
action: "resume",
|
||||
approvalId: "approval-1",
|
||||
approve: true,
|
||||
flowId: "flow-1",
|
||||
flowExpectedRevision: 1,
|
||||
flowCurrentStep: "resume_lobster",
|
||||
});
|
||||
|
||||
expect(taskFlow.resume).toHaveBeenCalledWith({
|
||||
flowId: "flow-1",
|
||||
expectedRevision: 1,
|
||||
status: "running",
|
||||
currentStep: "resume_lobster",
|
||||
});
|
||||
expect(runner.run).toHaveBeenCalledWith({
|
||||
action: "resume",
|
||||
approvalId: "approval-1",
|
||||
approve: true,
|
||||
cwd: process.cwd(),
|
||||
timeoutMs: 20_000,
|
||||
maxStdoutBytes: 512_000,
|
||||
});
|
||||
const details = requireRecord(res.details, "managed resume lobster tool details");
|
||||
expect(details.ok).toBe(true);
|
||||
expect(details.status).toBe("ok");
|
||||
const mutation = requireRecord(details.mutation, "managed resume mutation details");
|
||||
expect(mutation.applied).toBe(true);
|
||||
});
|
||||
|
||||
it("normalizes numeric string flowExpectedRevision before managed resume", async () => {
|
||||
const runner = {
|
||||
run: vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
status: "ok",
|
||||
output: [],
|
||||
requiresApproval: null,
|
||||
}),
|
||||
};
|
||||
const taskFlow = createFakeTaskFlow();
|
||||
const tool = createLobsterTool(fakeApi(), { runner, taskFlow });
|
||||
|
||||
await tool.execute("call-managed-resume-string-revision", {
|
||||
action: "resume",
|
||||
approvalId: "approval-1",
|
||||
approve: true,
|
||||
flowId: "flow-1",
|
||||
flowExpectedRevision: "1",
|
||||
flowCurrentStep: "resume_lobster",
|
||||
});
|
||||
|
||||
expect(taskFlow.resume).toHaveBeenCalledWith({
|
||||
flowId: "flow-1",
|
||||
expectedRevision: 1,
|
||||
status: "running",
|
||||
currentStep: "resume_lobster",
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects managed TaskFlow resume mode without a token or approvalId", async () => {
|
||||
const tool = createLobsterTool(fakeApi(), {
|
||||
runner: { run: vi.fn() },
|
||||
taskFlow: createFakeTaskFlow(),
|
||||
});
|
||||
|
||||
await expect(
|
||||
tool.execute("call-missing-resume-token", {
|
||||
action: "resume",
|
||||
flowId: "flow-1",
|
||||
flowExpectedRevision: 1,
|
||||
approve: true,
|
||||
}),
|
||||
).rejects.toThrow(/token or approvalId required when using managed TaskFlow resume mode/);
|
||||
});
|
||||
|
||||
it("rejects managed TaskFlow resume mode without approve", async () => {
|
||||
const tool = createLobsterTool(fakeApi(), {
|
||||
runner: { run: vi.fn() },
|
||||
taskFlow: createFakeTaskFlow(),
|
||||
});
|
||||
|
||||
await expect(
|
||||
tool.execute("call-missing-resume-approve", {
|
||||
action: "resume",
|
||||
token: "resume-token",
|
||||
flowId: "flow-1",
|
||||
flowExpectedRevision: 1,
|
||||
}),
|
||||
).rejects.toThrow(/approve required when using managed TaskFlow resume mode/);
|
||||
});
|
||||
|
||||
it("requires action", async () => {
|
||||
const tool = createLobsterTool(fakeApi(), {
|
||||
runner: { run: vi.fn() },
|
||||
});
|
||||
await expect(tool.execute("call-action-missing", {})).rejects.toThrow(/action required/);
|
||||
});
|
||||
|
||||
it("rejects unknown action", async () => {
|
||||
const tool = createLobsterTool(fakeApi(), {
|
||||
runner: { run: vi.fn() },
|
||||
});
|
||||
await expect(
|
||||
tool.execute("call-action-unknown", {
|
||||
action: "explode",
|
||||
}),
|
||||
).rejects.toThrow(/Unknown action/);
|
||||
});
|
||||
|
||||
it("rejects absolute cwd", async () => {
|
||||
const tool = createLobsterTool(fakeApi(), {
|
||||
runner: { run: vi.fn() },
|
||||
});
|
||||
await expect(
|
||||
tool.execute("call-absolute-cwd", {
|
||||
action: "run",
|
||||
pipeline: "noop",
|
||||
cwd: "/tmp",
|
||||
}),
|
||||
).rejects.toThrow(/cwd must be a relative path/);
|
||||
});
|
||||
|
||||
it("rejects cwd that escapes the gateway working directory", async () => {
|
||||
const tool = createLobsterTool(fakeApi(), {
|
||||
runner: { run: vi.fn() },
|
||||
});
|
||||
await expect(
|
||||
tool.execute("call-escape-cwd", {
|
||||
action: "run",
|
||||
pipeline: "noop",
|
||||
cwd: "../../etc",
|
||||
}),
|
||||
).rejects.toThrow(/must stay within/);
|
||||
});
|
||||
|
||||
it("can be gated off in sandboxed contexts", () => {
|
||||
const api = fakeApi();
|
||||
const factoryTool = (ctx: OpenClawPluginToolContext) => {
|
||||
if (ctx.sandboxed) {
|
||||
return null;
|
||||
}
|
||||
return createLobsterTool(api, {
|
||||
runner: { run: vi.fn() },
|
||||
});
|
||||
};
|
||||
|
||||
expect(factoryTool(fakeCtx({ sandboxed: true }))).toBeNull();
|
||||
expect(factoryTool(fakeCtx({ sandboxed: false }))?.name).toBe("lobster");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user