@agi-cli/server 0.1.111 → 0.1.112
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agi-cli/server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.112",
|
|
4
4
|
"description": "HTTP API server for AGI CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"typecheck": "tsc --noEmit"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@agi-cli/sdk": "0.1.
|
|
33
|
-
"@agi-cli/database": "0.1.
|
|
32
|
+
"@agi-cli/sdk": "0.1.112",
|
|
33
|
+
"@agi-cli/database": "0.1.112",
|
|
34
34
|
"drizzle-orm": "^0.44.5",
|
|
35
35
|
"hono": "^4.9.9",
|
|
36
36
|
"zod": "^4.1.8"
|
|
@@ -173,10 +173,9 @@ export async function updateMessageTokensIncremental(
|
|
|
173
173
|
? Number(providerMetadata.openai.cachedPromptTokens)
|
|
174
174
|
: priorCached;
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
: cumPrompt + cumCompletion + cumReasoning;
|
|
176
|
+
// Note: AI SDK's totalTokens excludes cachedInputTokens for Anthropic,
|
|
177
|
+
// so we always compute total ourselves to include all token types.
|
|
178
|
+
const cumTotal = cumPrompt + cumCompletion + cumCached + cumReasoning;
|
|
180
179
|
|
|
181
180
|
await db
|
|
182
181
|
.update(messages)
|
|
@@ -7,7 +7,7 @@ import { publish } from '../events/bus.ts';
|
|
|
7
7
|
import { enqueueAssistantRun } from './session-queue.ts';
|
|
8
8
|
import { runSessionLoop } from './runner.ts';
|
|
9
9
|
import { resolveModel } from './provider.ts';
|
|
10
|
-
import type
|
|
10
|
+
import { getFastModel, type ProviderId } from '@agi-cli/sdk';
|
|
11
11
|
import { debugLog } from './debug.ts';
|
|
12
12
|
|
|
13
13
|
type SessionRow = typeof sessions.$inferSelect;
|
|
@@ -230,8 +230,6 @@ async function generateSessionTitle(args: {
|
|
|
230
230
|
debugLog('[TITLE_GEN] Generating title for session');
|
|
231
231
|
debugLog(`[TITLE_GEN] Provider: ${provider}, Model: ${modelName}`);
|
|
232
232
|
|
|
233
|
-
const model = await resolveModel(provider, modelName, cfg);
|
|
234
|
-
|
|
235
233
|
const { getAuth } = await import('@agi-cli/sdk');
|
|
236
234
|
const { getProviderSpoofPrompt } = await import('./prompt.ts');
|
|
237
235
|
const auth = await getAuth(provider, cfg.projectRoot);
|
|
@@ -240,6 +238,12 @@ async function generateSessionTitle(args: {
|
|
|
240
238
|
? getProviderSpoofPrompt(provider)
|
|
241
239
|
: undefined;
|
|
242
240
|
|
|
241
|
+
// Use a smaller, faster model for title generation
|
|
242
|
+
// Look up the cheapest/fastest model from the catalog for this provider
|
|
243
|
+
const titleModel = getFastModel(provider) ?? modelName;
|
|
244
|
+
debugLog(`[TITLE_GEN] Using title model: ${titleModel}`);
|
|
245
|
+
const model = await resolveModel(provider, titleModel, cfg);
|
|
246
|
+
|
|
243
247
|
debugLog(
|
|
244
248
|
`[TITLE_GEN] needsSpoof: ${needsSpoof}, spoofPrompt: ${spoofPrompt || 'NONE'}`,
|
|
245
249
|
);
|
package/src/runtime/provider.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { AGIConfig, ProviderId } from '@agi-cli/sdk';
|
|
|
2
2
|
import {
|
|
3
3
|
catalog,
|
|
4
4
|
createSolforgeModel,
|
|
5
|
+
createOpenAIOAuthModel,
|
|
5
6
|
getAuth,
|
|
6
7
|
refreshToken,
|
|
7
8
|
setAuth,
|
|
@@ -437,7 +438,23 @@ export async function resolveModel(
|
|
|
437
438
|
model: string,
|
|
438
439
|
cfg: AGIConfig,
|
|
439
440
|
) {
|
|
440
|
-
if (provider === 'openai')
|
|
441
|
+
if (provider === 'openai') {
|
|
442
|
+
const auth = await getAuth('openai', cfg.projectRoot);
|
|
443
|
+
if (auth?.type === 'oauth') {
|
|
444
|
+
const isCodexModel = model.toLowerCase().includes('codex');
|
|
445
|
+
return createOpenAIOAuthModel(model, {
|
|
446
|
+
oauth: auth,
|
|
447
|
+
projectRoot: cfg.projectRoot,
|
|
448
|
+
reasoningEffort: isCodexModel ? 'high' : 'medium',
|
|
449
|
+
reasoningSummary: 'auto',
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
if (auth?.type === 'api' && auth.key) {
|
|
453
|
+
const instance = createOpenAI({ apiKey: auth.key });
|
|
454
|
+
return instance(model);
|
|
455
|
+
}
|
|
456
|
+
return openai(model);
|
|
457
|
+
}
|
|
441
458
|
if (provider === 'anthropic') {
|
|
442
459
|
const instance = await getAnthropicInstance(cfg);
|
|
443
460
|
return instance(model);
|
package/src/runtime/runner.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { hasToolCall, streamText } from 'ai';
|
|
2
|
-
import { loadConfig
|
|
2
|
+
import { loadConfig } from '@agi-cli/sdk';
|
|
3
3
|
import { getDb } from '@agi-cli/database';
|
|
4
4
|
import { messageParts } from '@agi-cli/database/schema';
|
|
5
5
|
import { eq } from 'drizzle-orm';
|
|
@@ -178,7 +178,10 @@ async function runAssistant(opts: RunOpts) {
|
|
|
178
178
|
|
|
179
179
|
// FIX: For OAuth, ALWAYS prepend the system message because it's never in history
|
|
180
180
|
// For API key mode, only add on first message (when additionalSystemMessages is empty)
|
|
181
|
-
const messagesWithSystemInstructions:
|
|
181
|
+
const messagesWithSystemInstructions: Array<{
|
|
182
|
+
role: string;
|
|
183
|
+
content: string | Array<unknown>;
|
|
184
|
+
}> = [
|
|
182
185
|
...additionalSystemMessages, // Always add for OAuth, empty for API key mode
|
|
183
186
|
...history,
|
|
184
187
|
];
|