Compare commits

...

3 Commits

Author SHA1 Message Date
Trevor Creech
2db8372df0 prettier 2025-05-16 13:03:40 -07:00
Trevor Creech
3fae0b0e69 fix deps 2025-05-16 13:01:38 -07:00
Trevor Creech
76d346461e chore: update openai sdk and types 2025-05-16 12:33:05 -07:00
4 changed files with 43 additions and 25 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.100.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,9 @@ 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);

42
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.100.0
version: 4.100.0(ws@8.18.1)(zod@3.24.3)
package-manager-detector:
specifier: ^1.2.0
version: 1.2.0
@@ -355,6 +355,12 @@ packages:
peerDependencies:
eslint: ^6.0.0 || ^7.0.0 || >=8.0.0
'@eslint-community/eslint-utils@4.7.0':
resolution: {integrity: sha512-dyybb3AcajC7uha6CvhdVRJqaKyn7w2YKqKyAN37NKYgZT36w+iRb0Dymmc5qEJ549c/S31cMMSFd75bteCpCw==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
eslint: ^6.0.0 || ^7.0.0 || >=8.0.0
'@eslint-community/regexpp@4.12.1':
resolution: {integrity: sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==}
engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0}
@@ -951,6 +957,15 @@ packages:
supports-color:
optional: true
debug@4.4.1:
resolution: {integrity: sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==}
engines: {node: '>=6.0'}
peerDependencies:
supports-color: '*'
peerDependenciesMeta:
supports-color:
optional: true
deep-eql@5.0.2:
resolution: {integrity: sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==}
engines: {node: '>=6'}
@@ -1836,8 +1851,8 @@ packages:
resolution: {integrity: sha512-zy1wx4+P3PfhXSEPJNtZmJXfhkkIaxU1VauWIrDZw1O7uJRDRJtKr9n3Ic4NgbA16KyOxOXO2ng9gYwCdXuSXA==}
engines: {node: '>=18'}
openai@4.95.1:
resolution: {integrity: sha512-IqJy+ymeW+k/Wq+2YVN3693OQMMcODRtHEYOlz263MdUwnN/Dwdl9c2EXSxLLtGEHkSHAfvzpDMHI5MaWJKXjQ==}
openai@4.100.0:
resolution: {integrity: sha512-9soq/wukv3utxcuD7TWFqKdKp0INWdeyhUCvxwrne5KwnxaCp4eHL4GdT/tMFhYolxgNhxFzg5GFwM331Z5CZg==}
hasBin: true
peerDependencies:
ws: ^8.18.0
@@ -2613,12 +2628,17 @@ snapshots:
eslint: 8.57.1
eslint-visitor-keys: 3.4.3
'@eslint-community/eslint-utils@4.7.0(eslint@8.57.1)':
dependencies:
eslint: 8.57.1
eslint-visitor-keys: 3.4.3
'@eslint-community/regexpp@4.12.1': {}
'@eslint/eslintrc@2.1.4':
dependencies:
ajv: 6.12.6
debug: 4.4.0
debug: 4.4.1
espree: 9.6.1
globals: 13.24.0
ignore: 5.3.2
@@ -2636,7 +2656,7 @@ snapshots:
'@humanwhocodes/config-array@0.13.0':
dependencies:
'@humanwhocodes/object-schema': 2.0.3
debug: 4.4.0
debug: 4.4.1
minimatch: 3.1.2
transitivePeerDependencies:
- supports-color
@@ -3220,6 +3240,10 @@ snapshots:
dependencies:
ms: 2.1.3
debug@4.4.1:
dependencies:
ms: 2.1.3
deep-eql@5.0.2: {}
deep-is@0.1.4: {}
@@ -3503,7 +3527,7 @@ snapshots:
eslint@8.57.1:
dependencies:
'@eslint-community/eslint-utils': 4.6.1(eslint@8.57.1)
'@eslint-community/eslint-utils': 4.7.0(eslint@8.57.1)
'@eslint-community/regexpp': 4.12.1
'@eslint/eslintrc': 2.1.4
'@eslint/js': 8.57.1
@@ -3514,7 +3538,7 @@ snapshots:
ajv: 6.12.6
chalk: 4.1.2
cross-spawn: 7.0.6
debug: 4.4.0
debug: 4.4.1
doctrine: 3.0.0
escape-string-regexp: 4.0.0
eslint-scope: 7.2.2
@@ -4254,7 +4278,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.100.0(ws@8.18.1)(zod@3.24.3):
dependencies:
'@types/node': 18.19.86
'@types/node-fetch': 2.6.12