fix: bound AgentRun AipodSpec describe output
This commit is contained in:
@@ -374,6 +374,187 @@ describe("AgentRun default transport contract", () => {
|
||||
}
|
||||
});
|
||||
|
||||
test("aipodspec describe is bounded and homologous while full and raw stay complete", async () => {
|
||||
const aipodName = "Artificer";
|
||||
const hiddenCredential = "HIDDEN_AIPOD_CREDENTIAL_VALUE_MUST_NOT_BE_PRINTED";
|
||||
const providerCredential = {
|
||||
profile: "sub2api",
|
||||
name: "agentrun-provider",
|
||||
namespace: null,
|
||||
keys: ["auth.json", "config.toml"],
|
||||
value: hiddenCredential,
|
||||
valuesPrinted: false,
|
||||
};
|
||||
const toolCredentials = [
|
||||
{
|
||||
tool: "github",
|
||||
purpose: "github-pr",
|
||||
name: "agentrun-github",
|
||||
namespace: null,
|
||||
keys: ["GH_TOKEN"],
|
||||
projection: { kind: "env", envName: "GH_TOKEN", secretKey: "GH_TOKEN", value: hiddenCredential },
|
||||
token: hiddenCredential,
|
||||
valuesPrinted: false,
|
||||
},
|
||||
{
|
||||
tool: "ssh",
|
||||
purpose: "remote-workspace",
|
||||
name: "agentrun-ssh",
|
||||
namespace: null,
|
||||
keys: ["config", "key"],
|
||||
projection: { kind: "mount", mountPath: "/run/secrets/ssh", value: hiddenCredential },
|
||||
valuesPrinted: false,
|
||||
},
|
||||
{
|
||||
tool: "provider",
|
||||
purpose: "model-auth",
|
||||
name: "agentrun-provider",
|
||||
namespace: null,
|
||||
keys: ["auth.json"],
|
||||
projection: { kind: "mount", mountPath: "/run/secrets/provider", value: hiddenCredential },
|
||||
valuesPrinted: false,
|
||||
},
|
||||
];
|
||||
const data = {
|
||||
action: "show",
|
||||
item: {
|
||||
name: aipodName,
|
||||
displayName: "Artificer",
|
||||
description: "x".repeat(20_000),
|
||||
specHash: "sha256:aipod-fixture",
|
||||
source: "config/aipods/artificer.yaml",
|
||||
backendProfile: "sub2api",
|
||||
model: { model: "gpt-5.5", reasoningEffort: "high" },
|
||||
imageRef: {
|
||||
kind: "env-image-dockerfile",
|
||||
repoUrl: "https://github.com/pikasTech/agentrun.git",
|
||||
commitId: "a".repeat(40),
|
||||
dockerfilePath: "deploy/container/Containerfile",
|
||||
sourceIdentity: "agentrun@aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
valuesPrinted: false,
|
||||
},
|
||||
queue: "commander",
|
||||
lane: "v0.1",
|
||||
providerId: "NC01",
|
||||
providerCredentials: { count: 1, profiles: ["sub2api"], items: [providerCredential], valuesPrinted: false },
|
||||
toolCredentials: { count: 3, tools: ["github", "ssh", "provider"], items: toolCredentials, valuesPrinted: false },
|
||||
resourceBundleRef: {
|
||||
kind: "gitbundle",
|
||||
repoUrl: `https://fixture:${hiddenCredential}@github.com/pikasTech/unidesk.git`,
|
||||
ref: "master",
|
||||
commitId: null,
|
||||
bundles: { count: 6, items: [{ name: "unidesk-skills", targetPath: ".agents/skills" }], valuesPrinted: false },
|
||||
requiredSkills: { count: 11, names: ["unidesk-gh"], valuesPrinted: false },
|
||||
promptRefs: { count: 0, names: [], valuesPrinted: false },
|
||||
valuesPrinted: false,
|
||||
},
|
||||
createdAt: "2026-07-12T00:00:00.000Z",
|
||||
updatedAt: "2026-07-12T01:00:00.000Z",
|
||||
valuesPrinted: false,
|
||||
},
|
||||
spec: {
|
||||
apiVersion: "agentrun.pikastech.local/v1alpha1",
|
||||
kind: "AipodSpec",
|
||||
metadata: { name: aipodName, displayName: "Artificer", description: "x".repeat(20_000) },
|
||||
spec: {
|
||||
queue: "commander",
|
||||
lane: "v0.1",
|
||||
providerId: "NC01",
|
||||
backendProfile: "sub2api",
|
||||
model: { model: "gpt-5.5", reasoningEffort: "high" },
|
||||
workspaceRef: { kind: "opaque", path: "." },
|
||||
executionPolicy: {
|
||||
secretScope: {
|
||||
allowCredentialEcho: false,
|
||||
providerCredentials: [{ profile: "sub2api", secretRef: { name: "agentrun-provider", keys: ["auth.json"], value: hiddenCredential } }],
|
||||
toolCredentials: [{ tool: "github", secretRef: { name: "agentrun-github", keys: ["GH_TOKEN"], token: hiddenCredential } }],
|
||||
},
|
||||
},
|
||||
resourceBundleRef: {
|
||||
kind: "gitbundle",
|
||||
repoUrl: `https://fixture:${hiddenCredential}@github.com/pikasTech/unidesk.git`,
|
||||
ref: "master",
|
||||
bundles: [{ name: "unidesk-skills", subpath: ".agents/skills", targetPath: ".agents/skills" }],
|
||||
requiredSkills: [{ name: "unidesk-gh" }],
|
||||
},
|
||||
metadata: { aipod: aipodName, source: "config/aipods/artificer.yaml" },
|
||||
},
|
||||
},
|
||||
valuesPrinted: false,
|
||||
};
|
||||
let requests = 0;
|
||||
const server = Bun.serve({
|
||||
port: 0,
|
||||
fetch(request) {
|
||||
const url = new URL(request.url);
|
||||
expect(request.headers.get("authorization")).toBe("Bearer secret-value");
|
||||
expect(url.pathname).toBe(`/api/v1/aipod-specs/${aipodName}`);
|
||||
requests += 1;
|
||||
return Response.json({ ok: true, data });
|
||||
},
|
||||
});
|
||||
const previousConfig = process.env.AGENTRUN_CLIENT_CONFIG;
|
||||
const previousKey = process.env.HWLAB_API_KEY;
|
||||
process.env.HWLAB_API_KEY = "secret-value";
|
||||
const tempConfigPath = `/tmp/unidesk-agentrun-aipodspec-test-${process.pid}-${Date.now()}.yaml`;
|
||||
try {
|
||||
process.env.AGENTRUN_CLIENT_CONFIG = tempConfigPath;
|
||||
await Bun.write(tempConfigPath, agentRunMinimalClientYaml.replace("http://agentrun.example.local:8080", server.url.href.replace(/\/$/u, "")));
|
||||
|
||||
const text = renderedTextOf(await runAgentRunCommand(null, ["describe", `aipodspec/${aipodName}`]));
|
||||
expect(text).toContain(`Name: aipodspec/${aipodName}`);
|
||||
expect(text).toContain("Hash: sha256:aipod-fixture");
|
||||
expect(text).toContain("Kind: opaque path=. branch=-");
|
||||
expect(text).toContain("References: bundles=6 requiredSkills=11 promptRefs=0");
|
||||
expect(text).toContain("Credentials: provider=1 tool=3 total=4");
|
||||
expect(text).toContain("secret=agentrun-provider keys=auth.json,config.toml");
|
||||
expect(text).toContain(`agentrun describe aipodspec/${aipodName} --full -o json`);
|
||||
expect(Buffer.byteLength(text, "utf8")).toBeLessThan(10_240);
|
||||
expect(text).not.toContain(hiddenCredential);
|
||||
|
||||
const jsonText = renderedTextOf(await runAgentRunCommand(null, ["describe", `aipodspec/${aipodName}`, "-o", "json"]));
|
||||
const json = JSON.parse(jsonText) as Record<string, any>;
|
||||
const yamlText = renderedTextOf(await runAgentRunCommand(null, ["describe", `aipodspec/${aipodName}`, "-o", "yaml"]));
|
||||
const yaml = Bun.YAML.parse(yamlText) as Record<string, any>;
|
||||
expect(yaml).toEqual(json);
|
||||
expect(json.kind).toBe("AipodSpec");
|
||||
expect(json.identity.specHash).toBe("sha256:aipod-fixture");
|
||||
expect(json.runtime).toMatchObject({ lane: "v0.1", backendProfile: "sub2api", providerId: "NC01" });
|
||||
expect(json.workspaceRef).toMatchObject({ kind: "opaque", path: ".", valuesPrinted: false });
|
||||
expect(json.resourceBundleRef.sourceIdentity.repoUrl).toBe("https://github.com/pikasTech/unidesk.git");
|
||||
expect(json.resourceBundleRef).toMatchObject({ bundleCount: 6, requiredSkillCount: 11, promptRefCount: 0 });
|
||||
expect(json.credentialRefs).toMatchObject({ totalCount: 4, valuesPrinted: false });
|
||||
expect(json.credentialRefs.provider.items[0].secretRef).toEqual({
|
||||
namespace: null,
|
||||
name: "agentrun-provider",
|
||||
keys: ["auth.json", "config.toml"],
|
||||
valuesPrinted: false,
|
||||
});
|
||||
expect(json.redaction).toEqual({ credentialValues: "omitted", secretRefsOnly: true, valuesPrinted: false });
|
||||
expect(json.valuesPrinted).toBe(false);
|
||||
for (const bounded of [jsonText, yamlText]) {
|
||||
expect(Buffer.byteLength(bounded, "utf8")).toBeLessThan(10_240);
|
||||
expect(bounded).not.toContain(hiddenCredential);
|
||||
expect(bounded).not.toContain("x".repeat(200));
|
||||
}
|
||||
|
||||
const full = JSON.parse(renderedTextOf(await runAgentRunCommand(null, ["describe", `aipodspec/${aipodName}`, "--full", "-o", "json"]))) as { resource?: typeof data };
|
||||
expect(full.resource?.item.description).toBe("x".repeat(20_000));
|
||||
expect(full.resource?.spec.kind).toBe("AipodSpec");
|
||||
const raw = JSON.parse(renderedTextOf(await runAgentRunCommand(null, ["describe", `aipodspec/${aipodName}`, "--raw"]))) as { data?: typeof data };
|
||||
expect(raw.data?.item.description).toBe("x".repeat(20_000));
|
||||
expect(raw.data?.spec.kind).toBe("AipodSpec");
|
||||
expect(requests).toBe(5);
|
||||
} finally {
|
||||
server.stop(true);
|
||||
if (previousConfig === undefined) delete process.env.AGENTRUN_CLIENT_CONFIG;
|
||||
else process.env.AGENTRUN_CLIENT_CONFIG = previousConfig;
|
||||
if (previousKey === undefined) delete process.env.HWLAB_API_KEY;
|
||||
else process.env.HWLAB_API_KEY = previousKey;
|
||||
rmSync(tempConfigPath, { force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("retry dry-run is server-validated and attempts use the formal resource API", async () => {
|
||||
const taskId = "qt_failed_1";
|
||||
const attempt = {
|
||||
|
||||
Reference in New Issue
Block a user