open-swe/src/types.ts
Brace Sproul 0830c9c3e8
feat: Setup initialize node (#1)
* feat: Setup initialize node

* cr
2025-05-21 17:53:43 -07:00

76 lines
1.5 KiB
TypeScript

import "@langchain/langgraph/zod";
import { z } from "zod";
import {
Annotation,
LangGraphRunnableConfig,
MessagesAnnotation,
} from "@langchain/langgraph";
type PlanItem = {
id: string;
plan: string;
completed: boolean;
};
export type TargetRepository = {
owner: string;
repo: string;
branch?: string;
};
export const GraphAnnotation = Annotation.Root({
messages: MessagesAnnotation.spec.messages,
plan: Annotation<PlanItem[]>({
reducer: (_state, update) => update,
default: () => [],
}),
});
export type GraphState = typeof GraphAnnotation.State;
export type GraphUpdate = typeof GraphAnnotation.Update;
export const MCPConfig = z.object({
/**
* The MCP server URL.
*/
url: z.string(),
/**
* The list of tools to provide to the LLM.
*/
tools: z.array(z.string()),
});
export const GraphConfiguration = z.object({
/**
* The session ID of the Sandbox to use.
*/
sandbox_session_id: z
.string()
.optional()
.langgraph.metadata({
x_lg_ui_config: {
type: "hidden",
},
}),
/**
* The URL of the repository to clone.
*/
target_repository: z
.object({
owner: z.string(),
repo: z.string(),
branch: z.string().optional(),
})
.langgraph.metadata({}),
/**
* The language of the sandbox to use.
*/
sandbox_language: z.enum(["js", "python"]).optional().langgraph.metadata({}),
});
export type GraphConfig = LangGraphRunnableConfig<
z.infer<typeof GraphConfiguration> & {
thread_id: string;
assistant_id: string;
}
>;