osagent 0.1.98 → 0.1.100
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/cli.js +496 -20
- package/package.json +2 -2
package/cli.js
CHANGED
|
@@ -141747,6 +141747,14 @@ var init_openai = __esm({
|
|
|
141747
141747
|
});
|
|
141748
141748
|
|
|
141749
141749
|
// packages/core/dist/src/core/credentialValidator.js
|
|
141750
|
+
var credentialValidator_exports = {};
|
|
141751
|
+
__export(credentialValidator_exports, {
|
|
141752
|
+
getProviderHelpText: () => getProviderHelpText,
|
|
141753
|
+
validateGroqCredentials: () => validateGroqCredentials,
|
|
141754
|
+
validateOllamaCloudCredentials: () => validateOllamaCloudCredentials,
|
|
141755
|
+
validateOllamaLocalCredentials: () => validateOllamaLocalCredentials,
|
|
141756
|
+
validateOpenAICredentials: () => validateOpenAICredentials
|
|
141757
|
+
});
|
|
141750
141758
|
function getProviderHelpText(authType) {
|
|
141751
141759
|
return PROVIDER_HELP_TEXT[authType] || "Please check your API key and try again";
|
|
141752
141760
|
}
|
|
@@ -141760,9 +141768,9 @@ async function validateOpenAICredentials(client, authType, timeout2 = DEFAULT_VA
|
|
|
141760
141768
|
}
|
|
141761
141769
|
}
|
|
141762
141770
|
async function validateOllamaCloudCredentials(apiKey, timeout2 = DEFAULT_VALIDATION_TIMEOUT) {
|
|
141763
|
-
const baseUrl = "https://
|
|
141771
|
+
const baseUrl = "https://ollama.com";
|
|
141764
141772
|
try {
|
|
141765
|
-
const response = await fetch(`${baseUrl}/
|
|
141773
|
+
const response = await fetch(`${baseUrl}/api/tags`, {
|
|
141766
141774
|
method: "GET",
|
|
141767
141775
|
headers: {
|
|
141768
141776
|
Authorization: `Bearer ${apiKey}`,
|
|
@@ -145280,6 +145288,23 @@ ${this.getTimeoutTroubleshootingTips(context2)}`);
|
|
|
145280
145288
|
return `${errorMessage}
|
|
145281
145289
|
|
|
145282
145290
|
\u{1F4A1} Model not found. Pull it with: ollama pull <model-name>`;
|
|
145291
|
+
}
|
|
145292
|
+
if (lowerMessage.includes("401") || lowerMessage.includes("unauthorized") || lowerMessage.includes("invalid api key") || lowerMessage.includes("invalid_api_key")) {
|
|
145293
|
+
if (lowerMessage.includes("groq") || lowerMessage.includes("api.groq.com")) {
|
|
145294
|
+
return `${errorMessage}
|
|
145295
|
+
|
|
145296
|
+
\u{1F4A1} Invalid GROQ API key. Get one at: https://console.groq.com/keys
|
|
145297
|
+
Set it with: export GROQ_API_KEY=your_key`;
|
|
145298
|
+
}
|
|
145299
|
+
if (lowerMessage.includes("ollama")) {
|
|
145300
|
+
return `${errorMessage}
|
|
145301
|
+
|
|
145302
|
+
\u{1F4A1} Invalid Ollama Cloud API key. Get one at: https://ollama.com/settings/keys
|
|
145303
|
+
Set it with: export OLLAMA_API_KEY=your_key`;
|
|
145304
|
+
}
|
|
145305
|
+
return `${errorMessage}
|
|
145306
|
+
|
|
145307
|
+
\u{1F4A1} Invalid API key. Please check your API key is correct and not expired.`;
|
|
145283
145308
|
}
|
|
145284
145309
|
if (lowerMessage.includes("groq") && lowerMessage.includes("rate limit")) {
|
|
145285
145310
|
return `${errorMessage}
|
|
@@ -148117,6 +148142,459 @@ var init_openaiContentGenerator2 = __esm({
|
|
|
148117
148142
|
}
|
|
148118
148143
|
});
|
|
148119
148144
|
|
|
148145
|
+
// packages/core/dist/src/core/ollamaContentGenerator/index.js
|
|
148146
|
+
var ollamaContentGenerator_exports = {};
|
|
148147
|
+
__export(ollamaContentGenerator_exports, {
|
|
148148
|
+
OllamaContentGenerator: () => OllamaContentGenerator,
|
|
148149
|
+
createOllamaContentGenerator: () => createOllamaContentGenerator
|
|
148150
|
+
});
|
|
148151
|
+
function getEffectiveOllamaUrl2() {
|
|
148152
|
+
const ollamaHost = process.env["OLLAMA_HOST"];
|
|
148153
|
+
if (ollamaHost) {
|
|
148154
|
+
const url3 = ollamaHost.startsWith("http") ? ollamaHost : `http://${ollamaHost}`;
|
|
148155
|
+
return url3.replace(/\/$/, "");
|
|
148156
|
+
}
|
|
148157
|
+
const ollamaBaseUrl = process.env["OLLAMA_BASE_URL"];
|
|
148158
|
+
if (ollamaBaseUrl) {
|
|
148159
|
+
return ollamaBaseUrl.replace(/\/v1\/?$/, "").replace(/\/$/, "");
|
|
148160
|
+
}
|
|
148161
|
+
return "http://localhost:11434";
|
|
148162
|
+
}
|
|
148163
|
+
function isContentObject(content) {
|
|
148164
|
+
return typeof content === "object" && content !== null && "role" in content;
|
|
148165
|
+
}
|
|
148166
|
+
function createOllamaContentGenerator(config2, cliConfig) {
|
|
148167
|
+
return new OllamaContentGenerator(config2, cliConfig);
|
|
148168
|
+
}
|
|
148169
|
+
var OllamaContentGenerator;
|
|
148170
|
+
var init_ollamaContentGenerator = __esm({
|
|
148171
|
+
"packages/core/dist/src/core/ollamaContentGenerator/index.js"() {
|
|
148172
|
+
"use strict";
|
|
148173
|
+
init_esbuild_shims();
|
|
148174
|
+
__name(getEffectiveOllamaUrl2, "getEffectiveOllamaUrl");
|
|
148175
|
+
__name(isContentObject, "isContentObject");
|
|
148176
|
+
OllamaContentGenerator = class {
|
|
148177
|
+
static {
|
|
148178
|
+
__name(this, "OllamaContentGenerator");
|
|
148179
|
+
}
|
|
148180
|
+
config;
|
|
148181
|
+
baseUrl;
|
|
148182
|
+
constructor(config2, _cliConfig) {
|
|
148183
|
+
this.config = config2;
|
|
148184
|
+
this.baseUrl = config2.baseUrl?.replace(/\/v1\/?$/, "").replace(/\/$/, "") || getEffectiveOllamaUrl2();
|
|
148185
|
+
}
|
|
148186
|
+
/**
|
|
148187
|
+
* Check if this is Ollama Cloud (requires auth)
|
|
148188
|
+
*/
|
|
148189
|
+
isCloud() {
|
|
148190
|
+
return this.baseUrl.includes("ollama.com");
|
|
148191
|
+
}
|
|
148192
|
+
/**
|
|
148193
|
+
* Build headers for Ollama API requests
|
|
148194
|
+
*/
|
|
148195
|
+
buildHeaders() {
|
|
148196
|
+
const headers = {
|
|
148197
|
+
"Content-Type": "application/json"
|
|
148198
|
+
};
|
|
148199
|
+
if (this.isCloud() && this.config.apiKey) {
|
|
148200
|
+
headers["Authorization"] = `Bearer ${this.config.apiKey}`;
|
|
148201
|
+
}
|
|
148202
|
+
return headers;
|
|
148203
|
+
}
|
|
148204
|
+
/**
|
|
148205
|
+
* Extract text content from a ContentUnion
|
|
148206
|
+
*/
|
|
148207
|
+
extractTextFromContentUnion(content) {
|
|
148208
|
+
if (typeof content === "string") {
|
|
148209
|
+
return content;
|
|
148210
|
+
}
|
|
148211
|
+
if (isContentObject(content) && content.parts) {
|
|
148212
|
+
return this.extractTextFromParts(content.parts);
|
|
148213
|
+
}
|
|
148214
|
+
return "";
|
|
148215
|
+
}
|
|
148216
|
+
/**
|
|
148217
|
+
* Extract text content from parts
|
|
148218
|
+
*/
|
|
148219
|
+
extractTextFromParts(parts) {
|
|
148220
|
+
return parts.map((part) => {
|
|
148221
|
+
if (typeof part === "string")
|
|
148222
|
+
return part;
|
|
148223
|
+
if (part && typeof part === "object" && "text" in part)
|
|
148224
|
+
return part.text;
|
|
148225
|
+
return "";
|
|
148226
|
+
}).join("");
|
|
148227
|
+
}
|
|
148228
|
+
/**
|
|
148229
|
+
* Check if a part is a function call
|
|
148230
|
+
*/
|
|
148231
|
+
isFunctionCall(part) {
|
|
148232
|
+
return part !== null && typeof part === "object" && "functionCall" in part;
|
|
148233
|
+
}
|
|
148234
|
+
/**
|
|
148235
|
+
* Check if a part is a function response
|
|
148236
|
+
*/
|
|
148237
|
+
isFunctionResponse(part) {
|
|
148238
|
+
return part !== null && typeof part === "object" && "functionResponse" in part;
|
|
148239
|
+
}
|
|
148240
|
+
/**
|
|
148241
|
+
* Convert GenerateContentParameters to Ollama format
|
|
148242
|
+
*/
|
|
148243
|
+
convertToOllamaRequest(params) {
|
|
148244
|
+
const messages = [];
|
|
148245
|
+
if (params.config?.systemInstruction) {
|
|
148246
|
+
const systemContent = this.extractTextFromContentUnion(params.config.systemInstruction);
|
|
148247
|
+
if (systemContent) {
|
|
148248
|
+
messages.push({
|
|
148249
|
+
role: "system",
|
|
148250
|
+
content: systemContent
|
|
148251
|
+
});
|
|
148252
|
+
}
|
|
148253
|
+
}
|
|
148254
|
+
const contents = params.contents;
|
|
148255
|
+
if (Array.isArray(contents)) {
|
|
148256
|
+
for (const content of contents) {
|
|
148257
|
+
if (!content)
|
|
148258
|
+
continue;
|
|
148259
|
+
if (typeof content === "string") {
|
|
148260
|
+
messages.push({
|
|
148261
|
+
role: "user",
|
|
148262
|
+
content
|
|
148263
|
+
});
|
|
148264
|
+
} else if (isContentObject(content)) {
|
|
148265
|
+
const parts = content.parts || [];
|
|
148266
|
+
const functionCalls = parts.filter((p) => this.isFunctionCall(p));
|
|
148267
|
+
const functionResponses = parts.filter((p) => this.isFunctionResponse(p));
|
|
148268
|
+
if (functionCalls.length > 0 && content.role === "model") {
|
|
148269
|
+
const textParts = parts.filter((p) => !this.isFunctionCall(p) && !this.isFunctionResponse(p));
|
|
148270
|
+
const textContent2 = this.extractTextFromParts(textParts);
|
|
148271
|
+
const toolCalls = functionCalls.map((fc, index) => {
|
|
148272
|
+
const funcCall = fc;
|
|
148273
|
+
return {
|
|
148274
|
+
type: "function",
|
|
148275
|
+
function: {
|
|
148276
|
+
index,
|
|
148277
|
+
name: funcCall.functionCall.name,
|
|
148278
|
+
arguments: funcCall.functionCall.args || {}
|
|
148279
|
+
}
|
|
148280
|
+
};
|
|
148281
|
+
});
|
|
148282
|
+
messages.push({
|
|
148283
|
+
role: "assistant",
|
|
148284
|
+
content: textContent2 || "",
|
|
148285
|
+
tool_calls: toolCalls
|
|
148286
|
+
});
|
|
148287
|
+
} else if (functionResponses.length > 0) {
|
|
148288
|
+
for (const fr of functionResponses) {
|
|
148289
|
+
const funcResp = fr;
|
|
148290
|
+
const responseContent = typeof funcResp.functionResponse.response === "string" ? funcResp.functionResponse.response : JSON.stringify(funcResp.functionResponse.response);
|
|
148291
|
+
messages.push({
|
|
148292
|
+
role: "tool",
|
|
148293
|
+
tool_name: funcResp.functionResponse.name,
|
|
148294
|
+
content: responseContent
|
|
148295
|
+
});
|
|
148296
|
+
}
|
|
148297
|
+
} else {
|
|
148298
|
+
const role = content.role === "model" ? "assistant" : content.role;
|
|
148299
|
+
const text = this.extractTextFromParts(parts);
|
|
148300
|
+
if (text) {
|
|
148301
|
+
messages.push({
|
|
148302
|
+
role,
|
|
148303
|
+
content: text
|
|
148304
|
+
});
|
|
148305
|
+
}
|
|
148306
|
+
}
|
|
148307
|
+
}
|
|
148308
|
+
}
|
|
148309
|
+
} else if (contents) {
|
|
148310
|
+
if (typeof contents === "string") {
|
|
148311
|
+
messages.push({
|
|
148312
|
+
role: "user",
|
|
148313
|
+
content: contents
|
|
148314
|
+
});
|
|
148315
|
+
} else if (isContentObject(contents)) {
|
|
148316
|
+
const role = contents.role === "model" ? "assistant" : contents.role;
|
|
148317
|
+
const text = this.extractTextFromParts(contents.parts || []);
|
|
148318
|
+
if (text) {
|
|
148319
|
+
messages.push({
|
|
148320
|
+
role,
|
|
148321
|
+
content: text
|
|
148322
|
+
});
|
|
148323
|
+
}
|
|
148324
|
+
}
|
|
148325
|
+
}
|
|
148326
|
+
const model = params.model || this.config.model;
|
|
148327
|
+
const request4 = {
|
|
148328
|
+
model,
|
|
148329
|
+
messages,
|
|
148330
|
+
stream: false
|
|
148331
|
+
};
|
|
148332
|
+
if (params.config?.tools && Array.isArray(params.config.tools)) {
|
|
148333
|
+
const ollamaTools = [];
|
|
148334
|
+
for (const tool of params.config.tools) {
|
|
148335
|
+
if (tool && typeof tool === "object" && "functionDeclarations" in tool) {
|
|
148336
|
+
const funcDecls = tool.functionDeclarations;
|
|
148337
|
+
for (const func of funcDecls) {
|
|
148338
|
+
ollamaTools.push({
|
|
148339
|
+
type: "function",
|
|
148340
|
+
function: {
|
|
148341
|
+
name: func.name,
|
|
148342
|
+
description: func.description || "",
|
|
148343
|
+
parameters: func.parameters || { type: "object", properties: {} }
|
|
148344
|
+
}
|
|
148345
|
+
});
|
|
148346
|
+
}
|
|
148347
|
+
}
|
|
148348
|
+
}
|
|
148349
|
+
if (ollamaTools.length > 0) {
|
|
148350
|
+
request4.tools = ollamaTools;
|
|
148351
|
+
}
|
|
148352
|
+
}
|
|
148353
|
+
if (this.config.samplingParams) {
|
|
148354
|
+
request4.options = {};
|
|
148355
|
+
if (this.config.samplingParams.temperature !== void 0) {
|
|
148356
|
+
request4.options.temperature = this.config.samplingParams.temperature;
|
|
148357
|
+
}
|
|
148358
|
+
if (this.config.samplingParams.top_p !== void 0) {
|
|
148359
|
+
request4.options.top_p = this.config.samplingParams.top_p;
|
|
148360
|
+
}
|
|
148361
|
+
if (this.config.samplingParams.top_k !== void 0) {
|
|
148362
|
+
request4.options.top_k = this.config.samplingParams.top_k;
|
|
148363
|
+
}
|
|
148364
|
+
if (this.config.samplingParams.max_tokens !== void 0) {
|
|
148365
|
+
request4.options.num_predict = this.config.samplingParams.max_tokens;
|
|
148366
|
+
}
|
|
148367
|
+
if (this.config.samplingParams.repetition_penalty !== void 0) {
|
|
148368
|
+
request4.options.repeat_penalty = this.config.samplingParams.repetition_penalty;
|
|
148369
|
+
}
|
|
148370
|
+
if (this.config.samplingParams.presence_penalty !== void 0) {
|
|
148371
|
+
request4.options.presence_penalty = this.config.samplingParams.presence_penalty;
|
|
148372
|
+
}
|
|
148373
|
+
if (this.config.samplingParams.frequency_penalty !== void 0) {
|
|
148374
|
+
request4.options.frequency_penalty = this.config.samplingParams.frequency_penalty;
|
|
148375
|
+
}
|
|
148376
|
+
}
|
|
148377
|
+
return request4;
|
|
148378
|
+
}
|
|
148379
|
+
/**
|
|
148380
|
+
* Convert Ollama response to GenerateContentResponse format
|
|
148381
|
+
*/
|
|
148382
|
+
convertFromOllamaResponse(response) {
|
|
148383
|
+
const parts = [];
|
|
148384
|
+
if (response.message.content) {
|
|
148385
|
+
parts.push({ text: response.message.content });
|
|
148386
|
+
}
|
|
148387
|
+
if (response.message.tool_calls && response.message.tool_calls.length > 0) {
|
|
148388
|
+
for (const toolCall of response.message.tool_calls) {
|
|
148389
|
+
parts.push({
|
|
148390
|
+
functionCall: {
|
|
148391
|
+
name: toolCall.function.name,
|
|
148392
|
+
args: toolCall.function.arguments
|
|
148393
|
+
}
|
|
148394
|
+
});
|
|
148395
|
+
}
|
|
148396
|
+
}
|
|
148397
|
+
if (parts.length === 0) {
|
|
148398
|
+
parts.push({ text: "" });
|
|
148399
|
+
}
|
|
148400
|
+
return {
|
|
148401
|
+
candidates: [
|
|
148402
|
+
{
|
|
148403
|
+
content: {
|
|
148404
|
+
role: "model",
|
|
148405
|
+
parts
|
|
148406
|
+
},
|
|
148407
|
+
finishReason: response.message.tool_calls?.length ? "TOOL_USE" : response.done_reason === "stop" ? "STOP" : "OTHER",
|
|
148408
|
+
index: 0
|
|
148409
|
+
}
|
|
148410
|
+
],
|
|
148411
|
+
usageMetadata: {
|
|
148412
|
+
promptTokenCount: response.prompt_eval_count || 0,
|
|
148413
|
+
candidatesTokenCount: response.eval_count || 0,
|
|
148414
|
+
totalTokenCount: (response.prompt_eval_count || 0) + (response.eval_count || 0)
|
|
148415
|
+
},
|
|
148416
|
+
modelVersion: response.model
|
|
148417
|
+
};
|
|
148418
|
+
}
|
|
148419
|
+
/**
|
|
148420
|
+
* Generate content using Ollama API
|
|
148421
|
+
*/
|
|
148422
|
+
async generateContent(request4, _userPromptId) {
|
|
148423
|
+
const ollamaRequest = this.convertToOllamaRequest(request4);
|
|
148424
|
+
ollamaRequest.stream = false;
|
|
148425
|
+
const url3 = `${this.baseUrl}/api/chat`;
|
|
148426
|
+
const headers = this.buildHeaders();
|
|
148427
|
+
const response = await fetch(url3, {
|
|
148428
|
+
method: "POST",
|
|
148429
|
+
headers,
|
|
148430
|
+
body: JSON.stringify(ollamaRequest)
|
|
148431
|
+
});
|
|
148432
|
+
if (!response.ok) {
|
|
148433
|
+
const errorText = await response.text();
|
|
148434
|
+
if (response.status === 401) {
|
|
148435
|
+
throw new Error(`Ollama API error: 401 Unauthorized - ${errorText}
|
|
148436
|
+
|
|
148437
|
+
\u{1F4A1} Invalid or missing Ollama Cloud API key.
|
|
148438
|
+
Get one at: https://ollama.com/settings/keys
|
|
148439
|
+
Set it with: export OLLAMA_API_KEY=your_key`);
|
|
148440
|
+
}
|
|
148441
|
+
if (response.status === 404) {
|
|
148442
|
+
throw new Error(`Ollama API error: 404 Not Found - ${errorText}
|
|
148443
|
+
|
|
148444
|
+
\u{1F4A1} Model not found. Make sure you're using a valid cloud model like: qwen3-coder:480b-cloud`);
|
|
148445
|
+
}
|
|
148446
|
+
throw new Error(`Ollama API error: ${response.status} ${response.statusText} - ${errorText}`);
|
|
148447
|
+
}
|
|
148448
|
+
const ollamaResponse = await response.json();
|
|
148449
|
+
return this.convertFromOllamaResponse(ollamaResponse);
|
|
148450
|
+
}
|
|
148451
|
+
/**
|
|
148452
|
+
* Generate content stream using Ollama API
|
|
148453
|
+
*/
|
|
148454
|
+
async generateContentStream(request4, _userPromptId) {
|
|
148455
|
+
const ollamaRequest = this.convertToOllamaRequest(request4);
|
|
148456
|
+
ollamaRequest.stream = true;
|
|
148457
|
+
const url3 = `${this.baseUrl}/api/chat`;
|
|
148458
|
+
const headers = this.buildHeaders();
|
|
148459
|
+
const response = await fetch(url3, {
|
|
148460
|
+
method: "POST",
|
|
148461
|
+
headers,
|
|
148462
|
+
body: JSON.stringify(ollamaRequest)
|
|
148463
|
+
});
|
|
148464
|
+
if (!response.ok) {
|
|
148465
|
+
const errorText = await response.text();
|
|
148466
|
+
if (response.status === 401) {
|
|
148467
|
+
throw new Error(`Ollama API error: 401 Unauthorized - ${errorText}
|
|
148468
|
+
|
|
148469
|
+
\u{1F4A1} Invalid or missing Ollama Cloud API key.
|
|
148470
|
+
Get one at: https://ollama.com/settings/keys
|
|
148471
|
+
Set it with: export OLLAMA_API_KEY=your_key`);
|
|
148472
|
+
}
|
|
148473
|
+
if (response.status === 404) {
|
|
148474
|
+
throw new Error(`Ollama API error: 404 Not Found - ${errorText}
|
|
148475
|
+
|
|
148476
|
+
\u{1F4A1} Model not found. Make sure you're using a valid cloud model like: qwen3-coder:480b-cloud`);
|
|
148477
|
+
}
|
|
148478
|
+
throw new Error(`Ollama API error: ${response.status} ${response.statusText} - ${errorText}`);
|
|
148479
|
+
}
|
|
148480
|
+
const reader = response.body?.getReader();
|
|
148481
|
+
if (!reader) {
|
|
148482
|
+
throw new Error("No response body");
|
|
148483
|
+
}
|
|
148484
|
+
const decoder2 = new TextDecoder();
|
|
148485
|
+
async function* streamGenerator() {
|
|
148486
|
+
let buffer = "";
|
|
148487
|
+
const accumulatedToolCalls = [];
|
|
148488
|
+
while (true) {
|
|
148489
|
+
const { done, value } = await reader.read();
|
|
148490
|
+
if (done)
|
|
148491
|
+
break;
|
|
148492
|
+
buffer += decoder2.decode(value, { stream: true });
|
|
148493
|
+
const lines = buffer.split("\n");
|
|
148494
|
+
buffer = lines.pop() || "";
|
|
148495
|
+
for (const line of lines) {
|
|
148496
|
+
if (!line.trim())
|
|
148497
|
+
continue;
|
|
148498
|
+
try {
|
|
148499
|
+
const chunk = JSON.parse(line);
|
|
148500
|
+
if (chunk.message.tool_calls?.length) {
|
|
148501
|
+
accumulatedToolCalls.push(...chunk.message.tool_calls);
|
|
148502
|
+
}
|
|
148503
|
+
const parts = [];
|
|
148504
|
+
if (chunk.message.content) {
|
|
148505
|
+
parts.push({ text: chunk.message.content });
|
|
148506
|
+
}
|
|
148507
|
+
if (chunk.done && accumulatedToolCalls.length > 0) {
|
|
148508
|
+
for (const toolCall of accumulatedToolCalls) {
|
|
148509
|
+
parts.push({
|
|
148510
|
+
functionCall: {
|
|
148511
|
+
name: toolCall.function.name,
|
|
148512
|
+
args: toolCall.function.arguments
|
|
148513
|
+
}
|
|
148514
|
+
});
|
|
148515
|
+
}
|
|
148516
|
+
}
|
|
148517
|
+
if (parts.length === 0) {
|
|
148518
|
+
parts.push({ text: "" });
|
|
148519
|
+
}
|
|
148520
|
+
yield {
|
|
148521
|
+
candidates: [
|
|
148522
|
+
{
|
|
148523
|
+
content: {
|
|
148524
|
+
role: "model",
|
|
148525
|
+
parts
|
|
148526
|
+
},
|
|
148527
|
+
finishReason: chunk.done ? accumulatedToolCalls.length > 0 ? "TOOL_USE" : "STOP" : void 0,
|
|
148528
|
+
index: 0
|
|
148529
|
+
}
|
|
148530
|
+
]
|
|
148531
|
+
};
|
|
148532
|
+
} catch {
|
|
148533
|
+
}
|
|
148534
|
+
}
|
|
148535
|
+
}
|
|
148536
|
+
if (buffer.trim()) {
|
|
148537
|
+
try {
|
|
148538
|
+
const chunk = JSON.parse(buffer);
|
|
148539
|
+
if (chunk.message.tool_calls?.length) {
|
|
148540
|
+
accumulatedToolCalls.push(...chunk.message.tool_calls);
|
|
148541
|
+
}
|
|
148542
|
+
const parts = [];
|
|
148543
|
+
if (chunk.message.content) {
|
|
148544
|
+
parts.push({ text: chunk.message.content });
|
|
148545
|
+
}
|
|
148546
|
+
if (accumulatedToolCalls.length > 0) {
|
|
148547
|
+
for (const toolCall of accumulatedToolCalls) {
|
|
148548
|
+
parts.push({
|
|
148549
|
+
functionCall: {
|
|
148550
|
+
name: toolCall.function.name,
|
|
148551
|
+
args: toolCall.function.arguments
|
|
148552
|
+
}
|
|
148553
|
+
});
|
|
148554
|
+
}
|
|
148555
|
+
}
|
|
148556
|
+
if (parts.length === 0) {
|
|
148557
|
+
parts.push({ text: "" });
|
|
148558
|
+
}
|
|
148559
|
+
yield {
|
|
148560
|
+
candidates: [
|
|
148561
|
+
{
|
|
148562
|
+
content: {
|
|
148563
|
+
role: "model",
|
|
148564
|
+
parts
|
|
148565
|
+
},
|
|
148566
|
+
finishReason: chunk.done ? accumulatedToolCalls.length > 0 ? "TOOL_USE" : "STOP" : void 0,
|
|
148567
|
+
index: 0
|
|
148568
|
+
}
|
|
148569
|
+
]
|
|
148570
|
+
};
|
|
148571
|
+
} catch {
|
|
148572
|
+
}
|
|
148573
|
+
}
|
|
148574
|
+
}
|
|
148575
|
+
__name(streamGenerator, "streamGenerator");
|
|
148576
|
+
return streamGenerator();
|
|
148577
|
+
}
|
|
148578
|
+
/**
|
|
148579
|
+
* Count tokens - Ollama doesn't have a direct token counting API,
|
|
148580
|
+
* so we estimate based on character count
|
|
148581
|
+
*/
|
|
148582
|
+
async countTokens(_request) {
|
|
148583
|
+
return {
|
|
148584
|
+
totalTokens: 0
|
|
148585
|
+
};
|
|
148586
|
+
}
|
|
148587
|
+
/**
|
|
148588
|
+
* Embed content - Use Ollama's embedding API if available
|
|
148589
|
+
*/
|
|
148590
|
+
async embedContent(_request) {
|
|
148591
|
+
throw new Error("Embedding not supported by Ollama content generator");
|
|
148592
|
+
}
|
|
148593
|
+
};
|
|
148594
|
+
__name(createOllamaContentGenerator, "createOllamaContentGenerator");
|
|
148595
|
+
}
|
|
148596
|
+
});
|
|
148597
|
+
|
|
148120
148598
|
// packages/core/dist/src/qwen/qwenContentGenerator.js
|
|
148121
148599
|
var qwenContentGenerator_exports = {};
|
|
148122
148600
|
__export(qwenContentGenerator_exports, {
|
|
@@ -148269,7 +148747,7 @@ var init_qwenContentGenerator = __esm({
|
|
|
148269
148747
|
});
|
|
148270
148748
|
|
|
148271
148749
|
// packages/core/dist/src/core/contentGenerator.js
|
|
148272
|
-
function
|
|
148750
|
+
function getEffectiveOllamaUrl3(includeV1 = true) {
|
|
148273
148751
|
const ollamaHost = process.env["OLLAMA_HOST"];
|
|
148274
148752
|
if (ollamaHost) {
|
|
148275
148753
|
const url3 = ollamaHost.startsWith("http") ? ollamaHost : `http://${ollamaHost}`;
|
|
@@ -148343,7 +148821,8 @@ function createContentGeneratorConfig(config2, authType, generationConfig) {
|
|
|
148343
148821
|
return {
|
|
148344
148822
|
...baseConfig,
|
|
148345
148823
|
model: ollamaModel,
|
|
148346
|
-
|
|
148824
|
+
// Ollama Cloud uses native API at https://ollama.com/api/chat (NOT OpenAI-compatible)
|
|
148825
|
+
baseUrl: "https://ollama.com",
|
|
148347
148826
|
apiKey: ollamaApiKey,
|
|
148348
148827
|
authType: AuthType2.OLLAMA_CLOUD,
|
|
148349
148828
|
// Ollama doesn't need special cache control handling
|
|
@@ -148358,7 +148837,7 @@ function createContentGeneratorConfig(config2, authType, generationConfig) {
|
|
|
148358
148837
|
return {
|
|
148359
148838
|
...baseConfig,
|
|
148360
148839
|
model: ollamaModel,
|
|
148361
|
-
baseUrl:
|
|
148840
|
+
baseUrl: getEffectiveOllamaUrl3(true),
|
|
148362
148841
|
// Gets OLLAMA_HOST or defaults to localhost:11434/v1
|
|
148363
148842
|
apiKey: "ollama",
|
|
148364
148843
|
authType: AuthType2.OLLAMA_LOCAL,
|
|
@@ -148394,7 +148873,7 @@ function createContentGeneratorConfig(config2, authType, generationConfig) {
|
|
|
148394
148873
|
};
|
|
148395
148874
|
}
|
|
148396
148875
|
async function createContentGenerator(config2, gcConfig, sessionId2, isInitialAuth) {
|
|
148397
|
-
const version3 = "0.1.
|
|
148876
|
+
const version3 = "0.1.100";
|
|
148398
148877
|
const userAgent2 = `OSAgent/${version3} (${process.platform}; ${process.arch})`;
|
|
148399
148878
|
const baseHeaders = {
|
|
148400
148879
|
"User-Agent": userAgent2
|
|
@@ -148432,15 +148911,12 @@ async function createContentGenerator(config2, gcConfig, sessionId2, isInitialAu
|
|
|
148432
148911
|
return result instanceof Promise ? await result : result;
|
|
148433
148912
|
}
|
|
148434
148913
|
if (config2.authType === AuthType2.OLLAMA_CLOUD) {
|
|
148435
|
-
const {
|
|
148436
|
-
|
|
148437
|
-
|
|
148438
|
-
|
|
148439
|
-
}
|
|
148440
|
-
|
|
148441
|
-
validateCredentials: isInitialAuth
|
|
148442
|
-
});
|
|
148443
|
-
return result instanceof Promise ? await result : result;
|
|
148914
|
+
const { createOllamaContentGenerator: createOllamaContentGenerator2 } = await Promise.resolve().then(() => (init_ollamaContentGenerator(), ollamaContentGenerator_exports));
|
|
148915
|
+
if (isInitialAuth && config2.apiKey) {
|
|
148916
|
+
const { validateOllamaCloudCredentials: validateOllamaCloudCredentials2 } = await Promise.resolve().then(() => (init_credentialValidator(), credentialValidator_exports));
|
|
148917
|
+
await validateOllamaCloudCredentials2(config2.apiKey);
|
|
148918
|
+
}
|
|
148919
|
+
return createOllamaContentGenerator2(config2, gcConfig);
|
|
148444
148920
|
}
|
|
148445
148921
|
if (config2.authType === AuthType2.OLLAMA_LOCAL) {
|
|
148446
148922
|
const { createOpenAIContentGenerator: createOpenAIContentGenerator2 } = await Promise.resolve().then(() => (init_openaiContentGenerator2(), openaiContentGenerator_exports));
|
|
@@ -148481,7 +148957,7 @@ var init_contentGenerator = __esm({
|
|
|
148481
148957
|
init_models();
|
|
148482
148958
|
init_installationManager();
|
|
148483
148959
|
init_loggingContentGenerator();
|
|
148484
|
-
__name(
|
|
148960
|
+
__name(getEffectiveOllamaUrl3, "getEffectiveOllamaUrl");
|
|
148485
148961
|
(function(AuthType4) {
|
|
148486
148962
|
AuthType4["LOGIN_WITH_OSAGENT"] = "oauth-personal";
|
|
148487
148963
|
AuthType4["USE_OSA"] = "OSA-api-key";
|
|
@@ -337381,7 +337857,7 @@ __name(getPackageJson, "getPackageJson");
|
|
|
337381
337857
|
// packages/cli/src/utils/version.ts
|
|
337382
337858
|
async function getCliVersion() {
|
|
337383
337859
|
const pkgJson = await getPackageJson();
|
|
337384
|
-
return "0.1.
|
|
337860
|
+
return "0.1.100";
|
|
337385
337861
|
}
|
|
337386
337862
|
__name(getCliVersion, "getCliVersion");
|
|
337387
337863
|
|
|
@@ -341589,8 +342065,8 @@ var formatDuration = /* @__PURE__ */ __name((milliseconds) => {
|
|
|
341589
342065
|
|
|
341590
342066
|
// packages/cli/src/generated/git-commit.ts
|
|
341591
342067
|
init_esbuild_shims();
|
|
341592
|
-
var GIT_COMMIT_INFO2 = "
|
|
341593
|
-
var CLI_VERSION2 = "0.1.
|
|
342068
|
+
var GIT_COMMIT_INFO2 = "97ab282";
|
|
342069
|
+
var CLI_VERSION2 = "0.1.100";
|
|
341594
342070
|
|
|
341595
342071
|
// packages/cli/src/utils/systemInfo.ts
|
|
341596
342072
|
async function getNpmVersion() {
|
|
@@ -385477,7 +385953,7 @@ var useAuthCommand = /* @__PURE__ */ __name((settings, config2, addItem) => {
|
|
|
385477
385953
|
}
|
|
385478
385954
|
if (authType === AuthType2.OLLAMA_CLOUD) {
|
|
385479
385955
|
if (credentials) {
|
|
385480
|
-
const effectiveBaseUrl = credentials.baseUrl || "https://ollama.com
|
|
385956
|
+
const effectiveBaseUrl = credentials.baseUrl || "https://ollama.com";
|
|
385481
385957
|
const effectiveModel = credentials.model || "qwen3-coder:480b-cloud";
|
|
385482
385958
|
config2.updateCredentials({
|
|
385483
385959
|
apiKey: credentials.apiKey,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "osagent",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.100",
|
|
4
4
|
"description": "OS Agent - AI-powered CLI for autonomous coding with Ollama Cloud and Qwen models",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"locales"
|
|
21
21
|
],
|
|
22
22
|
"config": {
|
|
23
|
-
"sandboxImageUri": "ghcr.io/osagent/osagent:0.1.
|
|
23
|
+
"sandboxImageUri": "ghcr.io/osagent/osagent:0.1.100"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"punycode": "^2.3.1"
|