@ottocode/server 0.1.263 → 0.1.265
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": "@ottocode/server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.265",
|
|
4
4
|
"description": "HTTP API server for ottocode",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"typecheck": "tsc --noEmit"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@ottocode/database": "0.1.
|
|
65
|
-
"@ottocode/sdk": "0.1.
|
|
64
|
+
"@ottocode/database": "0.1.265",
|
|
65
|
+
"@ottocode/sdk": "0.1.265",
|
|
66
66
|
"@hono/zod-openapi": "^1.1.5",
|
|
67
67
|
"ai-sdk-ollama": "^3.8.3",
|
|
68
68
|
"drizzle-orm": "^0.44.5",
|
|
@@ -26,7 +26,6 @@ import {
|
|
|
26
26
|
} from '../stream/handlers.ts';
|
|
27
27
|
import {
|
|
28
28
|
pruneSession,
|
|
29
|
-
getModelLimits,
|
|
30
29
|
shouldAutoCompactBeforeOverflow,
|
|
31
30
|
} from '../message/compaction.ts';
|
|
32
31
|
import { triggerDeferredTitleGeneration } from '../message/service.ts';
|
|
@@ -131,7 +130,6 @@ async function shouldPreemptivelyAutoCompact(
|
|
|
131
130
|
opts: RunOpts,
|
|
132
131
|
threshold: number | null | undefined,
|
|
133
132
|
): Promise<boolean> {
|
|
134
|
-
const limits = getModelLimits(opts.provider, opts.model);
|
|
135
133
|
const sessionRows = await db
|
|
136
134
|
.select({ currentContextTokens: sessions.currentContextTokens })
|
|
137
135
|
.from(sessions)
|
|
@@ -140,7 +138,6 @@ async function shouldPreemptivelyAutoCompact(
|
|
|
140
138
|
|
|
141
139
|
return shouldAutoCompactBeforeOverflow({
|
|
142
140
|
autoCompactThresholdTokens: threshold,
|
|
143
|
-
modelContextWindow: limits?.context ?? null,
|
|
144
141
|
currentContextTokens: sessionRows[0]?.currentContextTokens ?? 0,
|
|
145
142
|
estimatedInputTokens: opts.estimatedInputTokens ?? 0,
|
|
146
143
|
isCompactCommand: opts.isCompactCommand,
|
|
@@ -140,6 +140,7 @@ async function processAskRequest(
|
|
|
140
140
|
opencode: { enabled: true },
|
|
141
141
|
copilot: { enabled: true },
|
|
142
142
|
ottorouter: { enabled: true },
|
|
143
|
+
xai: { enabled: true },
|
|
143
144
|
zai: { enabled: true },
|
|
144
145
|
'zai-coding': { enabled: true },
|
|
145
146
|
moonshot: { enabled: true },
|
|
@@ -14,7 +14,6 @@ export interface ModelLimits {
|
|
|
14
14
|
|
|
15
15
|
export function shouldAutoCompactBeforeOverflow(args: {
|
|
16
16
|
autoCompactThresholdTokens?: number | null;
|
|
17
|
-
modelContextWindow?: number | null;
|
|
18
17
|
currentContextTokens?: number | null;
|
|
19
18
|
estimatedInputTokens?: number | null;
|
|
20
19
|
isCompactCommand?: boolean;
|
|
@@ -31,11 +30,6 @@ export function shouldAutoCompactBeforeOverflow(args: {
|
|
|
31
30
|
return false;
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
const modelContextWindow = Number(args.modelContextWindow ?? 0);
|
|
35
|
-
if (!Number.isFinite(modelContextWindow) || modelContextWindow <= threshold) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
33
|
const currentContextTokens = Math.max(
|
|
40
34
|
0,
|
|
41
35
|
Math.floor(Number(args.currentContextTokens ?? 0)),
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
resolveOttoRouterModel,
|
|
20
20
|
type ResolveOttoRouterModelOptions,
|
|
21
21
|
} from './ottorouter.ts';
|
|
22
|
+
import { getXaiInstance } from './xai.ts';
|
|
22
23
|
import { getZaiInstance, getZaiCodingInstance } from './zai.ts';
|
|
23
24
|
import { resolveOpencodeModel } from './opencode.ts';
|
|
24
25
|
import { getMoonshotInstance } from './moonshot.ts';
|
|
@@ -73,6 +74,9 @@ export async function resolveModel(
|
|
|
73
74
|
autoPayThresholdUsd: options?.autoPayThresholdUsd,
|
|
74
75
|
});
|
|
75
76
|
}
|
|
77
|
+
if (provider === 'xai') {
|
|
78
|
+
return getXaiInstance(cfg, model);
|
|
79
|
+
}
|
|
76
80
|
if (provider === 'zai') {
|
|
77
81
|
return getZaiInstance(cfg, model);
|
|
78
82
|
}
|
|
@@ -190,6 +190,7 @@ function getReasoningProviderTarget(
|
|
|
190
190
|
const npmBinding = getModelNpmBinding(provider, model);
|
|
191
191
|
if (npmBinding === '@ai-sdk/anthropic') return 'anthropic';
|
|
192
192
|
if (npmBinding === '@ai-sdk/openai') return 'openai';
|
|
193
|
+
if (npmBinding === '@ai-sdk/xai') return 'openai';
|
|
193
194
|
if (npmBinding === '@ai-sdk/google') return 'google';
|
|
194
195
|
if (npmBinding === 'ai-sdk-ollama') return 'ollama';
|
|
195
196
|
if (npmBinding === '@ai-sdk/openai-compatible') return 'openai-compatible';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { OttoConfig } from '@ottocode/sdk';
|
|
2
|
+
import { getAuth, createXaiModel } from '@ottocode/sdk';
|
|
3
|
+
|
|
4
|
+
export async function getXaiInstance(cfg: OttoConfig, model: string) {
|
|
5
|
+
const auth = await getAuth('xai', cfg.projectRoot);
|
|
6
|
+
const apiKey = auth?.type === 'api' ? auth.key : undefined;
|
|
7
|
+
return createXaiModel(model, { apiKey });
|
|
8
|
+
}
|