fix: seed caserun hwpod workspace files
This commit is contained in:
@@ -796,6 +796,7 @@ function buildAgentRunCreateRunInput({ params, env, traceId, backendProfile, ses
|
||||
const threadId = safeOpaqueId(params.threadId);
|
||||
const hwlabProjectId = firstNonEmpty(params.projectId);
|
||||
const toolAliases = filteredResourceToolAliases(toolCapabilities);
|
||||
const workspaceFiles = normalizeResourceWorkspaceFiles(params.workspaceFiles ?? params.resourceWorkspaceFiles);
|
||||
const resourceBundleRef = {
|
||||
kind: "git",
|
||||
repoUrl: resolveAgentRunRepoUrl(env),
|
||||
@@ -804,7 +805,8 @@ function buildAgentRunCreateRunInput({ params, env, traceId, backendProfile, ses
|
||||
lfs: false,
|
||||
toolAliases,
|
||||
promptRefs: HWLAB_RESOURCE_PROMPT_REFS,
|
||||
skillRefs: HWLAB_RESOURCE_SKILL_REFS
|
||||
skillRefs: HWLAB_RESOURCE_SKILL_REFS,
|
||||
...(workspaceFiles.length > 0 ? { workspaceFiles } : {})
|
||||
};
|
||||
return {
|
||||
tenantId: firstNonEmpty(env.HWLAB_CODE_AGENT_AGENTRUN_TENANT_ID, DEFAULT_TENANT_ID),
|
||||
@@ -858,6 +860,21 @@ function buildAgentRunCreateRunInput({ params, env, traceId, backendProfile, ses
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeResourceWorkspaceFiles(value) {
|
||||
if (value == null || value === false || value === "") return [];
|
||||
if (!Array.isArray(value)) throw adapterError("invalid_workspace_files", "workspaceFiles must be an array when provided");
|
||||
return value.map((item, index) => {
|
||||
if (!item || typeof item !== "object" || Array.isArray(item)) throw adapterError("invalid_workspace_file", `workspaceFiles[${index}] must be an object`);
|
||||
const pathValue = text(item.path);
|
||||
const content = typeof item.content === "string" ? item.content : "";
|
||||
const encoding = text(item.encoding) || "utf8";
|
||||
if (!pathValue || pathValue === "." || pathValue.startsWith("/") || pathValue.includes("..") || pathValue.includes("\\")) throw adapterError("invalid_workspace_file_path", `workspaceFiles[${index}].path must be a safe relative POSIX path`);
|
||||
if (typeof item.content !== "string") throw adapterError("invalid_workspace_file_content", `workspaceFiles[${index}].content must be a utf8 string`);
|
||||
if (encoding !== "utf8") throw adapterError("invalid_workspace_file_encoding", `workspaceFiles[${index}].encoding must be utf8`);
|
||||
return { path: pathValue, content, encoding };
|
||||
});
|
||||
}
|
||||
|
||||
function buildAgentRunCommandInput({ params, traceId, backendProfile, sessionId }) {
|
||||
const prompt = String(params.message ?? params.prompt ?? "").trim();
|
||||
const threadId = safeOpaqueId(params.threadId);
|
||||
|
||||
Reference in New Issue
Block a user