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);

8
pnpm-lock.yaml generated
View File

@@ -79,8 +79,8 @@ importers:
specifier: ^10.1.0
version: 10.1.1
openai:
specifier: ^4.95.1
version: 4.95.1(ws@8.18.1)(zod@3.24.3)
specifier: ^4.99.0
version: 4.99.0(ws@8.18.1)(zod@3.24.3)
package-manager-detector:
specifier: ^1.2.0
version: 1.2.0
@@ -1836,7 +1836,7 @@ packages:
resolution: {integrity: sha512-zy1wx4+P3PfhXSEPJNtZmJXfhkkIaxU1VauWIrDZw1O7uJRDRJtKr9n3Ic4NgbA16KyOxOXO2ng9gYwCdXuSXA==}
engines: {node: '>=18'}
openai@4.95.1:
openai@4.99.0:
resolution: {integrity: sha512-IqJy+ymeW+k/Wq+2YVN3693OQMMcODRtHEYOlz263MdUwnN/Dwdl9c2EXSxLLtGEHkSHAfvzpDMHI5MaWJKXjQ==}
hasBin: true
peerDependencies:
@@ -4254,7 +4254,7 @@ snapshots:
is-inside-container: 1.0.0
is-wsl: 3.1.0
openai@4.95.1(ws@8.18.1)(zod@3.24.3):
openai@4.99.0(ws@8.18.1)(zod@3.24.3):
dependencies:
'@types/node': 18.19.86
'@types/node-fetch': 2.6.12