mikasa-cli 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +39 -0
- package/prisma/migrations/20260122185342_trst_migration/migration.sql +7 -0
- package/prisma/migrations/20260122192114/migration.sql +78 -0
- package/prisma/migrations/20260123074430_device_flow/migration.sql +15 -0
- package/prisma/migrations/migration_lock.toml +3 -0
- package/prisma/schema.prisma +125 -0
- package/src/cli/ai/google-service.js +235 -0
- package/src/cli/chat/chat-with-ai-agent.js +219 -0
- package/src/cli/chat/chat-with-ai-tool.js +377 -0
- package/src/cli/chat/chat-with-ai.js +275 -0
- package/src/cli/commands/ai/wakeUp.js +81 -0
- package/src/cli/commands/auth/login.js +607 -0
- package/src/cli/main.js +56 -0
- package/src/config/agent.config.js +166 -0
- package/src/config/google.config.js +8 -0
- package/src/config/tool.config.js +112 -0
- package/src/index.js +119 -0
- package/src/lib/auth-client.js +9 -0
- package/src/lib/auth.js +52 -0
- package/src/lib/db.js +9 -0
- package/src/services/chat.services.js +152 -0
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mikasa-cli",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"mikasa": "./src/cli/main.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
|
+
"dev": "nodemon src/index.js",
|
|
12
|
+
"start": "node src/index.js",
|
|
13
|
+
"postinstall": "prisma generate"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [],
|
|
16
|
+
"author": "",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"type": "module",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@ai-sdk/google": "^3.0.13",
|
|
21
|
+
"@clack/prompts": "^0.11.0",
|
|
22
|
+
"@prisma/client": "^6.19.2",
|
|
23
|
+
"ai": "^6.0.49",
|
|
24
|
+
"better-auth": "^1.4.17",
|
|
25
|
+
"boxen": "^8.0.1",
|
|
26
|
+
"chalk": "^5.6.2",
|
|
27
|
+
"commander": "^14.0.2",
|
|
28
|
+
"cors": "^2.8.6",
|
|
29
|
+
"dotenv": "^17.2.3",
|
|
30
|
+
"express": "^5.2.1",
|
|
31
|
+
"figlet": "^1.9.4",
|
|
32
|
+
"marked": "^15.0.12",
|
|
33
|
+
"marked-terminal": "^7.3.0",
|
|
34
|
+
"open": "^11.0.0",
|
|
35
|
+
"prisma": "^6.19.2",
|
|
36
|
+
"yocto-spinner": "^1.0.0",
|
|
37
|
+
"zod": "^4.3.6"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
-- CreateTable
|
|
2
|
+
CREATE TABLE "user" (
|
|
3
|
+
"id" TEXT NOT NULL,
|
|
4
|
+
"name" TEXT NOT NULL,
|
|
5
|
+
"email" TEXT NOT NULL,
|
|
6
|
+
"emailVerified" BOOLEAN NOT NULL DEFAULT false,
|
|
7
|
+
"image" TEXT,
|
|
8
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
9
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
10
|
+
|
|
11
|
+
CONSTRAINT "user_pkey" PRIMARY KEY ("id")
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
-- CreateTable
|
|
15
|
+
CREATE TABLE "session" (
|
|
16
|
+
"id" TEXT NOT NULL,
|
|
17
|
+
"expiresAt" TIMESTAMP(3) NOT NULL,
|
|
18
|
+
"token" TEXT NOT NULL,
|
|
19
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
20
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
21
|
+
"ipAddress" TEXT,
|
|
22
|
+
"userAgent" TEXT,
|
|
23
|
+
"userId" TEXT NOT NULL,
|
|
24
|
+
|
|
25
|
+
CONSTRAINT "session_pkey" PRIMARY KEY ("id")
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
-- CreateTable
|
|
29
|
+
CREATE TABLE "account" (
|
|
30
|
+
"id" TEXT NOT NULL,
|
|
31
|
+
"accountId" TEXT NOT NULL,
|
|
32
|
+
"providerId" TEXT NOT NULL,
|
|
33
|
+
"userId" TEXT NOT NULL,
|
|
34
|
+
"accessToken" TEXT,
|
|
35
|
+
"refreshToken" TEXT,
|
|
36
|
+
"idToken" TEXT,
|
|
37
|
+
"accessTokenExpiresAt" TIMESTAMP(3),
|
|
38
|
+
"refreshTokenExpiresAt" TIMESTAMP(3),
|
|
39
|
+
"scope" TEXT,
|
|
40
|
+
"password" TEXT,
|
|
41
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
42
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
43
|
+
|
|
44
|
+
CONSTRAINT "account_pkey" PRIMARY KEY ("id")
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
-- CreateTable
|
|
48
|
+
CREATE TABLE "verification" (
|
|
49
|
+
"id" TEXT NOT NULL,
|
|
50
|
+
"identifier" TEXT NOT NULL,
|
|
51
|
+
"value" TEXT NOT NULL,
|
|
52
|
+
"expiresAt" TIMESTAMP(3) NOT NULL,
|
|
53
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
54
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
55
|
+
|
|
56
|
+
CONSTRAINT "verification_pkey" PRIMARY KEY ("id")
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
-- CreateIndex
|
|
60
|
+
CREATE UNIQUE INDEX "user_email_key" ON "user"("email");
|
|
61
|
+
|
|
62
|
+
-- CreateIndex
|
|
63
|
+
CREATE INDEX "session_userId_idx" ON "session"("userId");
|
|
64
|
+
|
|
65
|
+
-- CreateIndex
|
|
66
|
+
CREATE UNIQUE INDEX "session_token_key" ON "session"("token");
|
|
67
|
+
|
|
68
|
+
-- CreateIndex
|
|
69
|
+
CREATE INDEX "account_userId_idx" ON "account"("userId");
|
|
70
|
+
|
|
71
|
+
-- CreateIndex
|
|
72
|
+
CREATE INDEX "verification_identifier_idx" ON "verification"("identifier");
|
|
73
|
+
|
|
74
|
+
-- AddForeignKey
|
|
75
|
+
ALTER TABLE "session" ADD CONSTRAINT "session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
76
|
+
|
|
77
|
+
-- AddForeignKey
|
|
78
|
+
ALTER TABLE "account" ADD CONSTRAINT "account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
-- CreateTable
|
|
2
|
+
CREATE TABLE "deviceCode" (
|
|
3
|
+
"id" TEXT NOT NULL,
|
|
4
|
+
"deviceCode" TEXT NOT NULL,
|
|
5
|
+
"userCode" TEXT NOT NULL,
|
|
6
|
+
"userId" TEXT,
|
|
7
|
+
"expiresAt" TIMESTAMP(3) NOT NULL,
|
|
8
|
+
"status" TEXT NOT NULL,
|
|
9
|
+
"lastPolledAt" TIMESTAMP(3),
|
|
10
|
+
"pollingInterval" INTEGER,
|
|
11
|
+
"clientId" TEXT,
|
|
12
|
+
"scope" TEXT,
|
|
13
|
+
|
|
14
|
+
CONSTRAINT "deviceCode_pkey" PRIMARY KEY ("id")
|
|
15
|
+
);
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
|
|
2
|
+
generator client {
|
|
3
|
+
provider = "prisma-client-js"
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
datasource db {
|
|
7
|
+
provider = "postgresql"
|
|
8
|
+
url = env("DATABASE_URL")
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
model Test {
|
|
12
|
+
id String @id @default(cuid())
|
|
13
|
+
name String
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
model User {
|
|
17
|
+
id String @id
|
|
18
|
+
name String
|
|
19
|
+
email String
|
|
20
|
+
emailVerified Boolean @default(false)
|
|
21
|
+
image String?
|
|
22
|
+
createdAt DateTime @default(now())
|
|
23
|
+
updatedAt DateTime @updatedAt
|
|
24
|
+
sessions Session[]
|
|
25
|
+
accounts Account[]
|
|
26
|
+
conversations Conversation[]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@@unique([email])
|
|
30
|
+
@@map("user")
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
model Session {
|
|
34
|
+
id String @id
|
|
35
|
+
expiresAt DateTime
|
|
36
|
+
token String
|
|
37
|
+
createdAt DateTime @default(now())
|
|
38
|
+
updatedAt DateTime @updatedAt
|
|
39
|
+
ipAddress String?
|
|
40
|
+
userAgent String?
|
|
41
|
+
userId String
|
|
42
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
43
|
+
|
|
44
|
+
@@unique([token])
|
|
45
|
+
@@index([userId])
|
|
46
|
+
@@map("session")
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
model Account {
|
|
50
|
+
id String @id
|
|
51
|
+
accountId String
|
|
52
|
+
providerId String
|
|
53
|
+
userId String
|
|
54
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
55
|
+
accessToken String?
|
|
56
|
+
refreshToken String?
|
|
57
|
+
idToken String?
|
|
58
|
+
accessTokenExpiresAt DateTime?
|
|
59
|
+
refreshTokenExpiresAt DateTime?
|
|
60
|
+
scope String?
|
|
61
|
+
password String?
|
|
62
|
+
createdAt DateTime @default(now())
|
|
63
|
+
updatedAt DateTime @updatedAt
|
|
64
|
+
|
|
65
|
+
@@index([userId])
|
|
66
|
+
@@map("account")
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
model Verification {
|
|
70
|
+
id String @id
|
|
71
|
+
identifier String
|
|
72
|
+
value String
|
|
73
|
+
expiresAt DateTime
|
|
74
|
+
createdAt DateTime @default(now())
|
|
75
|
+
updatedAt DateTime @updatedAt
|
|
76
|
+
|
|
77
|
+
@@index([identifier])
|
|
78
|
+
@@map("verification")
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
model DeviceCode {
|
|
82
|
+
id String @id
|
|
83
|
+
deviceCode String
|
|
84
|
+
userCode String
|
|
85
|
+
userId String?
|
|
86
|
+
expiresAt DateTime
|
|
87
|
+
status String
|
|
88
|
+
lastPolledAt DateTime?
|
|
89
|
+
pollingInterval Int?
|
|
90
|
+
clientId String?
|
|
91
|
+
scope String?
|
|
92
|
+
|
|
93
|
+
@@map("deviceCode")
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
model Conversation {
|
|
98
|
+
id String @id @default(cuid())
|
|
99
|
+
title String
|
|
100
|
+
mode String
|
|
101
|
+
userId String
|
|
102
|
+
createdAt DateTime @default(now())
|
|
103
|
+
updatedAt DateTime @updatedAt
|
|
104
|
+
|
|
105
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
106
|
+
messages Message[]
|
|
107
|
+
|
|
108
|
+
@@index([userId])
|
|
109
|
+
@@map("conversation")
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
model Message {
|
|
114
|
+
id String @id @default(cuid())
|
|
115
|
+
conversationId String
|
|
116
|
+
role String
|
|
117
|
+
content String
|
|
118
|
+
createdAt DateTime @default(now())
|
|
119
|
+
|
|
120
|
+
conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
|
|
121
|
+
|
|
122
|
+
@@index([conversationId])
|
|
123
|
+
@@map("message")
|
|
124
|
+
}
|
|
125
|
+
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { google } from "@ai-sdk/google";
|
|
2
|
+
import { streamText, generateObject } from "ai";
|
|
3
|
+
import { config } from "../../config/google.config.js";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
|
|
6
|
+
export class AIService {
|
|
7
|
+
constructor() {
|
|
8
|
+
if (!config.googleApiKey) {
|
|
9
|
+
throw new Error("GOOGLE_API_KEY is not set in environment variables");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
this.model = google(config.model, {
|
|
13
|
+
apiKey: config.googleApiKey,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Send a message and get streaming response
|
|
19
|
+
* @param {Array} messages - Array of message objects {role, content}
|
|
20
|
+
* @param {Function} onChunk - Callback for each text chunk
|
|
21
|
+
* @param {Object} tools - Optional tools object
|
|
22
|
+
* @param {Function} onToolCall - Callback for tool calls
|
|
23
|
+
* @returns {Promise<Object>} Full response with content, tool calls, and usage
|
|
24
|
+
*/
|
|
25
|
+
async sendMessage(messages, onChunk, tools = undefined, onToolCall = null) {
|
|
26
|
+
try {
|
|
27
|
+
const streamConfig = {
|
|
28
|
+
model: this.model,
|
|
29
|
+
messages: messages,
|
|
30
|
+
temperature: config.temperature,
|
|
31
|
+
maxTokens: config.maxTokens,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Add tools if provided with maxSteps for multi-step tool calling
|
|
35
|
+
if (tools && Object.keys(tools).length > 0) {
|
|
36
|
+
streamConfig.tools = tools;
|
|
37
|
+
streamConfig.maxSteps = 5; // Allow up to 5 tool call steps
|
|
38
|
+
|
|
39
|
+
console.log(chalk.gray(`[DEBUG] Tools enabled: ${Object.keys(tools).join(', ')}`));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const result = streamText(streamConfig);
|
|
43
|
+
|
|
44
|
+
let fullResponse = "";
|
|
45
|
+
|
|
46
|
+
// Stream text chunks
|
|
47
|
+
for await (const chunk of result.textStream) {
|
|
48
|
+
fullResponse += chunk;
|
|
49
|
+
if (onChunk) {
|
|
50
|
+
onChunk(chunk);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// IMPORTANT: Await the result to get access to steps, toolCalls, etc.
|
|
55
|
+
const fullResult = await result;
|
|
56
|
+
|
|
57
|
+
const toolCalls = [];
|
|
58
|
+
const toolResults = [];
|
|
59
|
+
|
|
60
|
+
// Collect tool calls from all steps (if they exist)
|
|
61
|
+
if (fullResult.steps && Array.isArray(fullResult.steps)) {
|
|
62
|
+
for (const step of fullResult.steps) {
|
|
63
|
+
if (step.toolCalls && step.toolCalls.length > 0) {
|
|
64
|
+
for (const toolCall of step.toolCalls) {
|
|
65
|
+
toolCalls.push(toolCall);
|
|
66
|
+
if (onToolCall) {
|
|
67
|
+
onToolCall(toolCall);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Collect tool results
|
|
73
|
+
if (step.toolResults && step.toolResults.length > 0) {
|
|
74
|
+
toolResults.push(...step.toolResults);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
content: fullResponse,
|
|
81
|
+
finishReason: fullResult.finishReason,
|
|
82
|
+
usage: fullResult.usage,
|
|
83
|
+
toolCalls,
|
|
84
|
+
toolResults,
|
|
85
|
+
steps: fullResult.steps,
|
|
86
|
+
};
|
|
87
|
+
} catch (error) {
|
|
88
|
+
console.error(chalk.red("AI Service Error:"), error.message);
|
|
89
|
+
console.error(chalk.red("Full error:"), error);
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Get a non-streaming response
|
|
96
|
+
* @param {Array} messages - Array of message objects
|
|
97
|
+
* @param {Object} tools - Optional tools
|
|
98
|
+
* @returns {Promise<string>} Response text
|
|
99
|
+
*/
|
|
100
|
+
async getMessage(messages, tools = undefined) {
|
|
101
|
+
let fullResponse = "";
|
|
102
|
+
const result = await this.sendMessage(messages, (chunk) => {
|
|
103
|
+
fullResponse += chunk;
|
|
104
|
+
}, tools);
|
|
105
|
+
return result.content;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Generate structured output using a Zod schema
|
|
110
|
+
* @param {Object} schema - Zod schema
|
|
111
|
+
* @param {string} prompt - Prompt for generation
|
|
112
|
+
* @returns {Promise<Object>} Parsed object matching the schema
|
|
113
|
+
*/
|
|
114
|
+
async generateStructured(schema, prompt) {
|
|
115
|
+
try {
|
|
116
|
+
const result = await generateObject({
|
|
117
|
+
model: this.model,
|
|
118
|
+
schema: schema,
|
|
119
|
+
prompt: prompt,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
return result.object;
|
|
123
|
+
} catch (error) {
|
|
124
|
+
console.error(chalk.red("AI Structured Generation Error:"), error.message);
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
// this is the test class
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
// import { google } from '@ai-sdk/google';
|
|
136
|
+
// import { StreamText } from 'ai';
|
|
137
|
+
// import { config } from '../../config/google.config.js';
|
|
138
|
+
// import chalk from 'chalk';
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
// export class AIService {
|
|
142
|
+
// constructor() {
|
|
143
|
+
// if (!config.googleApiKey) {
|
|
144
|
+
// throw new Error("Google Generative AI API key is not configured.");
|
|
145
|
+
// }
|
|
146
|
+
// this.model = google(config.model, {
|
|
147
|
+
// apiKey: config.googleApiKey,
|
|
148
|
+
// });
|
|
149
|
+
// }
|
|
150
|
+
|
|
151
|
+
// /**
|
|
152
|
+
// * Send a message and get streaming response
|
|
153
|
+
// * @param {Array} messages - Array of message objects {role, content}
|
|
154
|
+
// * @param {Function} onChunk - Callback for each text chunk
|
|
155
|
+
// * @param {Object} tools - Optional tools object
|
|
156
|
+
// * @param {Function} onToolCall - Callback for tool calls
|
|
157
|
+
// * @returns {Promise<Object>} Full response with content, tool calls, and usage
|
|
158
|
+
// */
|
|
159
|
+
|
|
160
|
+
// async sendMessageStream({ messages, onChunk, tools = undefined, onToolCall = null }) {
|
|
161
|
+
// try {
|
|
162
|
+
// const streamConfig = {
|
|
163
|
+
// model: this.model,
|
|
164
|
+
// messages: messages,
|
|
165
|
+
// temperature: config.temperature,
|
|
166
|
+
// maxTokens: config.maxTokens,
|
|
167
|
+
// };
|
|
168
|
+
|
|
169
|
+
// // Add tools if provided with maxSteps for multi-step tool calling
|
|
170
|
+
// if (tools && Object.keys(tools).length > 0) {
|
|
171
|
+
// streamConfig.tools = tools;
|
|
172
|
+
// streamConfig.maxSteps = 5; // Allow up to 5 tool call steps
|
|
173
|
+
|
|
174
|
+
// console.log(chalk.gray(`[DEBUG] Tools enabled: ${Object.keys(tools).join(', ')}`));
|
|
175
|
+
// }
|
|
176
|
+
|
|
177
|
+
// const result = streamText(streamConfig);
|
|
178
|
+
|
|
179
|
+
// let fullResponse = "";
|
|
180
|
+
|
|
181
|
+
// // Stream text chunks
|
|
182
|
+
// for await (const chunk of result.textStream) {
|
|
183
|
+
// fullResponse += chunk;
|
|
184
|
+
// if (onChunk) {
|
|
185
|
+
// onChunk(chunk);
|
|
186
|
+
// }
|
|
187
|
+
// }
|
|
188
|
+
|
|
189
|
+
// // IMPORTANT: Await the result to get access to steps, toolCalls, etc.
|
|
190
|
+
// const fullResult = await result;
|
|
191
|
+
|
|
192
|
+
// const toolCalls = [];
|
|
193
|
+
// const toolResults = [];
|
|
194
|
+
|
|
195
|
+
// // Collect tool calls from all steps (if they exist)
|
|
196
|
+
// if (fullResult.steps && Array.isArray(fullResult.steps)) {
|
|
197
|
+
// for (const step of fullResult.steps) {
|
|
198
|
+
// if (step.toolCalls && step.toolCalls.length > 0) {
|
|
199
|
+
// for (const toolCall of step.toolCalls) {
|
|
200
|
+
// toolCalls.push(toolCall);
|
|
201
|
+
// if (onToolCall) {
|
|
202
|
+
// onToolCall(toolCall);
|
|
203
|
+
// }
|
|
204
|
+
// }
|
|
205
|
+
// }
|
|
206
|
+
|
|
207
|
+
// // Collect tool results
|
|
208
|
+
// if (step.toolResults && step.toolResults.length > 0) {
|
|
209
|
+
// toolResults.push(...step.toolResults);
|
|
210
|
+
// }
|
|
211
|
+
// }
|
|
212
|
+
// }
|
|
213
|
+
|
|
214
|
+
// return {
|
|
215
|
+
// content: fullResponse,
|
|
216
|
+
// finishReason: fullResult.finishReason,
|
|
217
|
+
// usage: fullResult.usage,
|
|
218
|
+
// toolCalls,
|
|
219
|
+
// toolResults,
|
|
220
|
+
// steps: fullResult.steps,
|
|
221
|
+
// };
|
|
222
|
+
// } catch (error) {
|
|
223
|
+
// console.error(chalk.red("AI Service Error:"), error.message);
|
|
224
|
+
// console.error(chalk.red("Full error:"), error);
|
|
225
|
+
// throw error;
|
|
226
|
+
// }
|
|
227
|
+
// }
|
|
228
|
+
|
|
229
|
+
// /**
|
|
230
|
+
// * Get a non-streaming response
|
|
231
|
+
// * @param {Array} messages - Array of message objects
|
|
232
|
+
// * @param {Object} tools - Optional tools
|
|
233
|
+
// * @returns {Promise<string>} Response text
|
|
234
|
+
// */
|
|
235
|
+
// }
|