refactor: make v0.3 runtime node-scoped

This commit is contained in:
Codex Agent
2026-06-08 22:19:30 +08:00
parent e8ab452b10
commit 187fb80a5d
38 changed files with 549 additions and 450 deletions
+10 -2
View File
@@ -1,7 +1,8 @@
export const DEFAULT_AGENTRUN_NAMESPACE = "agentrun-v01";
export const DEFAULT_AGENTRUN_MANAGER_URL = "http://agentrun-mgr.agentrun-v01.svc.cluster.local:8080";
export const DEFAULT_HWLAB_AGENTRUN_PROJECT_ID = "pikasTech/HWLAB";
export const DEFAULT_HWLAB_AGENTRUN_PROVIDER_ID = "G14";
export const HWLAB_AGENTRUN_PROVIDER_ID_ENV = "HWLAB_CODE_AGENT_AGENTRUN_PROVIDER_ID";
export const LEGACY_AGENTRUN_PROVIDER_ID_ENV = "AGENTRUN_PROVIDER_ID";
export const DEFAULT_HWLAB_AGENTRUN_REPO_URL = "http://git-mirror-http.devops-infra.svc.cluster.local/pikasTech/HWLAB.git";
export const DEFAULT_HWLAB_AGENTRUN_BRANCH = "v0.2";
export const DEFAULT_HWLAB_AGENTRUN_BACKEND_PROFILE = "deepseek";
@@ -148,7 +149,7 @@ export function createHwlabAgentRunDispatchAssembly(options = {}) {
const namespace = nonEmptyString(options.namespace ?? DEFAULT_AGENTRUN_NAMESPACE, "namespace");
const managerUrl = trimTrailingSlash(nonEmptyString(options.managerUrl ?? DEFAULT_AGENTRUN_MANAGER_URL, "managerUrl"));
const projectId = DEFAULT_HWLAB_AGENTRUN_PROJECT_ID;
const providerId = DEFAULT_HWLAB_AGENTRUN_PROVIDER_ID;
const providerId = resolveHwlabAgentRunProviderId(env);
const repoUrl = nonEmptyString(options.repoUrl ?? DEFAULT_HWLAB_AGENTRUN_REPO_URL, "repoUrl");
const branch = nonEmptyString(options.branch ?? DEFAULT_HWLAB_AGENTRUN_BRANCH, "branch");
const timeoutMs = positiveInteger(options.timeoutMs ?? 600000, "timeoutMs");
@@ -397,6 +398,13 @@ function positiveInteger(value, fieldName) {
return parsed;
}
function resolveHwlabAgentRunProviderId(env = process.env) {
const providerId = optionalString(env[HWLAB_AGENTRUN_PROVIDER_ID_ENV] ?? env[LEGACY_AGENTRUN_PROVIDER_ID_ENV]);
if (!providerId) throw new Error(`${HWLAB_AGENTRUN_PROVIDER_ID_ENV} is required and must be injected from the runtime lane node id`);
if (!/^[A-Za-z0-9._-]+$/u.test(providerId)) throw new Error(`${HWLAB_AGENTRUN_PROVIDER_ID_ENV} must be a simple node id`);
return providerId;
}
function nonEmptyString(value, fieldName) {
const text = optionalString(value);
if (!text) throw new Error(`${fieldName} is required`);
+12 -1
View File
@@ -1,5 +1,5 @@
import assert from "node:assert/strict";
import test from "node:test";
import test, { after, before } from "node:test";
import {
DEFAULT_UNIDESK_MAIN_SERVER_ENV,
@@ -8,6 +8,17 @@ import {
} from "./agentrun-dispatch.mjs";
const commitId = "8da27c83fa56d87e78e488a819afe898cf97c62b";
let previousProviderId;
before(() => {
previousProviderId = process.env.HWLAB_CODE_AGENT_AGENTRUN_PROVIDER_ID;
process.env.HWLAB_CODE_AGENT_AGENTRUN_PROVIDER_ID = "G14";
});
after(() => {
if (previousProviderId === undefined) delete process.env.HWLAB_CODE_AGENT_AGENTRUN_PROVIDER_ID;
else process.env.HWLAB_CODE_AGENT_AGENTRUN_PROVIDER_ID = previousProviderId;
});
test("HWLAB AgentRun assembly grants GitHub and UniDesk SSH through toolCredentials", () => {
const assembly = createHwlabAgentRunDispatchAssembly({