mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-09-30 09:13:14 +00:00
fix: command.join() is not a function (#270)
* fix: command.join() is not a function * fix: better typing
This commit is contained in:
parent
530c62da40
commit
a71f17f1d6
2 changed files with 35 additions and 29 deletions
|
|
@ -12,6 +12,18 @@ import {
|
|||
MessageSquare,
|
||||
FileText,
|
||||
} from "lucide-react";
|
||||
import {
|
||||
createApplyPatchToolFields,
|
||||
createShellToolFields,
|
||||
} from "@open-swe/shared/open-swe/tools";
|
||||
import { z } from "zod";
|
||||
|
||||
// Used only for Zod type inference.
|
||||
const dummyRepo = { owner: "dummy", repo: "dummy" };
|
||||
const shellTool = createShellToolFields(dummyRepo);
|
||||
type ShellToolArgs = z.infer<typeof shellTool.schema>;
|
||||
const applyPatchTool = createApplyPatchToolFields(dummyRepo);
|
||||
type ApplyPatchToolArgs = z.infer<typeof applyPatchTool.schema>;
|
||||
|
||||
// Common props for all action types
|
||||
type BaseActionProps = {
|
||||
|
|
@ -21,23 +33,23 @@ type BaseActionProps = {
|
|||
summaryText?: string;
|
||||
};
|
||||
|
||||
// Shell command specific props
|
||||
type ShellActionProps = BaseActionProps & {
|
||||
actionType: "shell";
|
||||
command: string[];
|
||||
workdir?: string;
|
||||
output?: string;
|
||||
errorCode?: number;
|
||||
};
|
||||
// Shell command specific props. We need to wrap the args in Partial<...>
|
||||
// because even though they're required, they may be undefined at a point in time
|
||||
// due to streaming.
|
||||
type ShellActionProps = BaseActionProps &
|
||||
Partial<ShellToolArgs> & {
|
||||
actionType: "shell";
|
||||
output?: string;
|
||||
errorCode?: number;
|
||||
};
|
||||
|
||||
// Apply patch specific props
|
||||
type PatchActionProps = BaseActionProps & {
|
||||
actionType: "apply-patch";
|
||||
file: string;
|
||||
diff?: string;
|
||||
errorMessage?: string;
|
||||
fixedDiff?: string;
|
||||
};
|
||||
type PatchActionProps = BaseActionProps &
|
||||
Partial<ApplyPatchToolArgs> & {
|
||||
actionType: "apply-patch";
|
||||
errorMessage?: string;
|
||||
fixedDiff?: string;
|
||||
};
|
||||
|
||||
// Union type for all possible action props
|
||||
export type ActionStepProps =
|
||||
|
|
@ -137,14 +149,14 @@ export function ActionStep(props: ActionStepProps) {
|
|||
</div>
|
||||
)}
|
||||
<code className="text-foreground/80 text-xs font-normal">
|
||||
{props.command.join(" ")}
|
||||
{props.command?.join(" ")}
|
||||
</code>
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<code className="text-foreground/80 flex-1 text-xs font-normal">
|
||||
{props.file}
|
||||
{props.file_path}
|
||||
</code>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ export function mapToolMessageToActionStepProps(
|
|||
actionType: "apply-patch",
|
||||
status,
|
||||
success,
|
||||
file: args.file_path || "",
|
||||
file_path: args.file_path || "",
|
||||
diff: args.diff,
|
||||
reasoningText,
|
||||
errorMessage: !success ? getContentString(message.content) : undefined,
|
||||
|
|
@ -222,24 +222,18 @@ export function AssistantMessage({
|
|||
actionType={aiToolCallName === shellTool.name ? "shell" : "apply-patch"}
|
||||
status="generating"
|
||||
command={
|
||||
aiToolCallName === shellTool.name
|
||||
? aiToolCallArgs?.command || []
|
||||
: undefined
|
||||
aiToolCallName === shellTool.name ? aiToolCallArgs?.command || [] : []
|
||||
}
|
||||
workdir={
|
||||
aiToolCallName === shellTool.name
|
||||
? aiToolCallArgs?.workdir
|
||||
: undefined
|
||||
aiToolCallName === shellTool.name ? aiToolCallArgs?.workdir : ""
|
||||
}
|
||||
file={
|
||||
file_path={
|
||||
aiToolCallName === applyPatchTool.name
|
||||
? aiToolCallArgs?.file_path || ""
|
||||
: undefined
|
||||
: ""
|
||||
}
|
||||
diff={
|
||||
aiToolCallName === applyPatchTool.name
|
||||
? aiToolCallArgs?.diff
|
||||
: undefined
|
||||
aiToolCallName === applyPatchTool.name ? aiToolCallArgs?.diff : ""
|
||||
}
|
||||
reasoningText={contentString}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue