chore: update openai sdk and types

This commit is contained in:
Trevor Creech
2025-05-16 12:33:05 -07:00
parent 1e39189393
commit 76d346461e
4 changed files with 12 additions and 20 deletions

View File

@@ -42,7 +42,7 @@
"marked-terminal": "^7.3.0",
"meow": "^13.2.0",
"open": "^10.1.0",
"openai": "^4.95.1",
"openai": "^4.99.0",
"package-manager-detector": "^1.2.0",
"react": "^18.2.0",
"shell-quote": "^1.8.2",

View File

@@ -3,6 +3,8 @@ import type { TerminalRendererOptions } from "marked-terminal";
import type {
ResponseFunctionToolCallItem,
ResponseFunctionToolCallOutputItem,
ResponseLocalShellCallItem,
ResponseLocalShellCallOutputItem,
ResponseInputMessageItem,
ResponseItem,
ResponseOutputMessage,
@@ -42,11 +44,9 @@ export default function TerminalChatResponseItem({
fileOpener={fileOpener}
/>
);
// @ts-expect-error new item types aren't in SDK yet
case "local_shell_call":
case "function_call":
return <TerminalChatResponseToolCall message={item} />;
// @ts-expect-error new item types aren't in SDK yet
case "local_shell_call_output":
case "function_call_output":
return (
@@ -171,8 +171,7 @@ function TerminalChatResponseMessage({
function TerminalChatResponseToolCall({
message,
}: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
message: ResponseFunctionToolCallItem | any;
message: ResponseFunctionToolCallItem | ResponseLocalShellCallItem;
}) {
let workdir: string | undefined;
let cmdReadableText: string | undefined;
@@ -202,8 +201,7 @@ function TerminalChatResponseToolCallOutput({
message,
fullStdout,
}: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
message: ResponseFunctionToolCallOutputItem | any;
message: ResponseFunctionToolCallOutputItem | ResponseLocalShellCallOutputItem;
fullStdout: boolean;
}) {
const { output, metadata } = parseToolCallOutput(message.output);

View File

@@ -4,6 +4,7 @@ import type { AppConfig } from "../config.js";
import type { ResponseEvent } from "../responses.js";
import type {
ResponseFunctionToolCall,
ResponseLocalShellCall,
ResponseInputItem,
ResponseItem,
ResponseCreateParams,
@@ -110,7 +111,6 @@ const shellFunctionTool: FunctionTool = {
};
const localShellTool: Tool = {
//@ts-expect-error - waiting on sdk
type: "local_shell",
};
@@ -468,8 +468,7 @@ export class AgentLoop {
}
private async handleLocalShellCall(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
item: any,
item: ResponseLocalShellCall,
): Promise<Array<ResponseInputItem>> {
// If the agent has been canceled in the meantime we should not perform any
// additional work. Returning an empty array ensures that we neither execute
@@ -480,8 +479,7 @@ export class AgentLoop {
return [];
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const outputItem: any = {
const outputItem: ResponseInputItem.LocalShellCallOutput = {
type: "local_shell_call_output",
// `call_id` is mandatory ensure we never send `undefined` which would
// trigger the "No tool output found…" 400 from the API.
@@ -726,7 +724,6 @@ export class AgentLoop {
if (
(item as ResponseInputItem).type === "function_call" ||
(item as ResponseInputItem).type === "reasoning" ||
//@ts-expect-error - waiting on sdk
(item as ResponseInputItem).type === "local_shell_call" ||
((item as ResponseInputItem).type === "message" &&
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1579,13 +1576,10 @@ export class AgentLoop {
// eslint-disable-next-line no-await-in-loop
const result = await this.handleFunctionCall(item);
turnInput.push(...result);
//@ts-expect-error - waiting on sdk
} else if (item.type === "local_shell_call") {
//@ts-expect-error - waiting on sdk
if (alreadyProcessedResponses.has(item.id)) {
continue;
}
//@ts-expect-error - waiting on sdk
alreadyProcessedResponses.add(item.id);
// eslint-disable-next-line no-await-in-loop
const result = await this.handleLocalShellCall(item);