Merge origin/main with local UI refactor integration
This commit is contained in:
@@ -1,6 +1,17 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { parseActorExecutionResultFromModelOutput } from "../src/agents/provider-executor.js";
|
||||
import { mkdtemp } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { resolve } from "node:path";
|
||||
import { loadConfig } from "../src/config.js";
|
||||
import type { ActorExecutionInput } from "../src/agents/pipeline.js";
|
||||
import {
|
||||
buildProviderRuntimeEnv,
|
||||
createProviderRunRuntime,
|
||||
parseActorExecutionResultFromModelOutput,
|
||||
resolveProviderWorkingDirectory,
|
||||
type ProviderRunRuntime,
|
||||
} from "../src/agents/provider-executor.js";
|
||||
|
||||
test("parseActorExecutionResultFromModelOutput parses strict JSON payload", () => {
|
||||
const parsed = parseActorExecutionResultFromModelOutput({
|
||||
@@ -103,3 +114,71 @@ test("parseActorExecutionResultFromModelOutput preserves status when optional fi
|
||||
assert.equal(parsed.failureKind, undefined);
|
||||
assert.equal(parsed.failureCode, undefined);
|
||||
});
|
||||
|
||||
test("resolveProviderWorkingDirectory reads cwd from actor execution context", () => {
|
||||
const actorInput = {
|
||||
executionContext: {
|
||||
security: {
|
||||
worktreePath: "/tmp/session/tasks/product-intake",
|
||||
},
|
||||
},
|
||||
} as unknown as ActorExecutionInput;
|
||||
|
||||
assert.equal(
|
||||
resolveProviderWorkingDirectory(actorInput),
|
||||
"/tmp/session/tasks/product-intake",
|
||||
);
|
||||
});
|
||||
|
||||
test("buildProviderRuntimeEnv scopes AGENT_WORKTREE_PATH to actor worktree and filters undefined auth", () => {
|
||||
const config = loadConfig({
|
||||
CLAUDE_CODE_OAUTH_TOKEN: "oauth-token",
|
||||
});
|
||||
const runtime = {
|
||||
provider: "claude",
|
||||
config,
|
||||
sharedEnv: {
|
||||
PATH: "/usr/bin",
|
||||
KEEP_ME: "1",
|
||||
},
|
||||
claudeObservability: {} as ProviderRunRuntime["claudeObservability"],
|
||||
close: async () => {},
|
||||
} satisfies ProviderRunRuntime;
|
||||
const actorInput = {
|
||||
executionContext: {
|
||||
security: {
|
||||
worktreePath: "/tmp/session/tasks/product-intake",
|
||||
},
|
||||
},
|
||||
} as unknown as ActorExecutionInput;
|
||||
|
||||
const env = buildProviderRuntimeEnv({
|
||||
runtime,
|
||||
actorInput,
|
||||
includeClaudeAuth: true,
|
||||
});
|
||||
|
||||
assert.equal(env.AGENT_WORKTREE_PATH, "/tmp/session/tasks/product-intake");
|
||||
assert.equal(env.CLAUDE_CODE_OAUTH_TOKEN, "oauth-token");
|
||||
assert.equal("ANTHROPIC_API_KEY" in env, false);
|
||||
assert.equal(env.KEEP_ME, "1");
|
||||
});
|
||||
|
||||
test("createProviderRunRuntime does not require session context provisioning", async () => {
|
||||
const observabilityRoot = await mkdtemp(resolve(tmpdir(), "ai-ops-provider-runtime-"));
|
||||
const runtime = await createProviderRunRuntime({
|
||||
provider: "claude",
|
||||
config: loadConfig({}),
|
||||
observabilityRootPath: observabilityRoot,
|
||||
baseEnv: {
|
||||
PATH: "/usr/bin",
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
assert.equal(runtime.provider, "claude");
|
||||
assert.equal(runtime.sharedEnv.PATH, "/usr/bin");
|
||||
} finally {
|
||||
await runtime.close();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user