




















11import { spawnSync } from "node:child_process";
2-import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
2+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
33import { tmpdir } from "node:os";
44import path from "node:path";
55import { describe, expect, it } from "vitest";
@@ -12,22 +12,61 @@ function writeJson(filePath: string, value: unknown) {
1212}
13131414function runAssertion(root: string, env: Record<string, string> = {}) {
15-return spawnSync(process.execPath, [ASSERTIONS_SCRIPT, "assert-agent-turn"], {
15+return runAssertionCommand("assert-agent-turn", root, env);
16+}
17+18+function runAssertionCommand(command: string, root: string, env: Record<string, string> = {}) {
19+return spawnSync(process.execPath, [ASSERTIONS_SCRIPT, command], {
1620encoding: "utf8",
1721env: {
1822 ...process.env,
1923EXPECTED_SLUG: "live-plugin-slug",
2024HOME: root,
25+MODEL_REF: "openai/gpt-5.5",
2126OPENCLAW_LIVE_PLUGIN_TOOL_AGENT_ERROR_PATH: path.join(root, "agent.err"),
2227OPENCLAW_LIVE_PLUGIN_TOOL_AGENT_OUTPUT_PATH: path.join(root, "agent.json"),
2328OPENCLAW_STATE_DIR: path.join(root, "state"),
29+PLUGIN_ID: "e2e-live-plugin-tool",
30+PLUGIN_NAME: "@openclaw/e2e-live-plugin-tool",
31+PLUGIN_VERSION: "1.0.0",
32+SEED: "live plugin slug",
2433TOOL_NAME: "e2e_slug_probe",
2534 ...env,
2635},
2736});
2837}
29383039describe("live plugin tool assertions", () => {
40+it("rejects loose timeout env values instead of parsing numeric prefixes", () => {
41+const root = mkdtempSync(path.join(tmpdir(), "openclaw-live-plugin-tool-"));
42+try {
43+const result = runAssertionCommand("configure", root, {
44+OPENCLAW_LIVE_PLUGIN_TOOL_TIMEOUT_SECONDS: "1e3",
45+});
46+47+expect(result.status).not.toBe(0);
48+expect(result.stderr).toContain("invalid OPENCLAW_LIVE_PLUGIN_TOOL_TIMEOUT_SECONDS: 1e3");
49+} finally {
50+rmSync(root, { force: true, recursive: true });
51+}
52+});
53+54+it("writes strict positive timeout values into generated config", () => {
55+const root = mkdtempSync(path.join(tmpdir(), "openclaw-live-plugin-tool-"));
56+try {
57+const result = runAssertionCommand("configure", root, {
58+OPENCLAW_LIVE_PLUGIN_TOOL_TIMEOUT_SECONDS: "240",
59+});
60+61+expect(result.status).toBe(0);
62+const config = JSON.parse(readFileSync(path.join(root, "state", "openclaw.json"), "utf8"));
63+expect(config.models.providers.openai.timeoutSeconds).toBe(240);
64+expect(config.agents.defaults.timeoutSeconds).toBe(240);
65+} finally {
66+rmSync(root, { force: true, recursive: true });
67+}
68+});
69+3170it("streams session transcripts across chunk boundaries", () => {
3271const root = mkdtempSync(path.join(tmpdir(), "openclaw-live-plugin-tool-"));
3372const sessionsDir = path.join(root, "state", "agents", "main", "sessions");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。