Skip to content

Commit 69671bd

Browse files
committed
fix: chat loop and change model
1 parent 28a87d1 commit 69671bd

3 files changed

Lines changed: 18 additions & 14 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "spec2tools",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "Dynamically convert OpenAPI specs into AI agent tools at runtime",
55
"type": "module",
66
"main": "dist/main.js",

src/agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class Agent {
2121

2222
constructor(config: AgentConfig) {
2323
this.tools = config.tools;
24-
this.model = config.model || 'gpt-4o';
24+
this.model = config.model || 'gpt-5.1-chat-latest';
2525
this.maxSteps = config.maxSteps || 10;
2626
this.conversationHistory = [];
2727
}

src/cli.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,25 +155,29 @@ async function startChatLoop(session: Session): Promise<void> {
155155
});
156156

157157
const prompt = (): void => {
158-
rl.question(chalk.cyan('> '), (input) => {
158+
rl.question(chalk.cyan('> '), async (input) => {
159159
const trimmedInput = input.trim();
160160

161161
if (!trimmedInput) {
162162
prompt();
163163
return;
164164
}
165165

166-
handleInput(trimmedInput, session, agent)
167-
.catch((error) => {
168-
console.error(
169-
chalk.red(
170-
`Error: ${error instanceof Error ? error.message : String(error)}`
171-
)
172-
);
173-
})
174-
.finally(() => {
175-
prompt();
176-
});
166+
// Pause readline during async operations to prevent corruption
167+
rl.pause();
168+
169+
try {
170+
await handleInput(trimmedInput, session, agent);
171+
} catch (error) {
172+
console.error(
173+
chalk.red(
174+
`Error: ${error instanceof Error ? error.message : String(error)}`
175+
)
176+
);
177+
} finally {
178+
rl.resume();
179+
prompt();
180+
}
177181
});
178182
};
179183

0 commit comments

Comments
 (0)