@best-agent/cli 0.0.2-beta.8 → 0.0.2-beta.9
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/LICENSE +21 -0
- package/README.md +44 -181
- package/dist/launcher.js +32 -0
- package/package.json +15 -27
- package/dist/best-agent-native-bridge.d.ts +0 -389
- package/dist/best-agent-native-bridge.js +0 -4645
- package/dist/cli-storage.d.ts +0 -5
- package/dist/cli-storage.js +0 -7
- package/dist/dimsdk/ask-user.d.ts +0 -21
- package/dist/dimsdk/ask-user.js +0 -131
- package/dist/dimsdk/cli/version.d.ts +0 -6
- package/dist/dimsdk/cli/version.js +0 -36
- package/dist/dimsdk/compat/archships/dim-agent/runtime-host.d.ts +0 -49
- package/dist/dimsdk/compat/archships/dim-agent/runtime-host.js +0 -215
- package/dist/dimsdk/compat/runtime-host.d.ts +0 -2
- package/dist/dimsdk/compat/runtime-host.js +0 -2
- package/dist/dimsdk/core/debug-log.d.ts +0 -8
- package/dist/dimsdk/core/debug-log.js +0 -100
- package/dist/dimsdk/core/env.d.ts +0 -26
- package/dist/dimsdk/core/env.js +0 -130
- package/dist/dimsdk/core/markdown/sanitize.d.ts +0 -2
- package/dist/dimsdk/core/markdown/sanitize.js +0 -43
- package/dist/dimsdk/core/markdown/wrap.d.ts +0 -9
- package/dist/dimsdk/core/markdown/wrap.js +0 -139
- package/dist/dimsdk/core/markdown.d.ts +0 -18
- package/dist/dimsdk/core/markdown.js +0 -62
- package/dist/dimsdk/core/model.d.ts +0 -273
- package/dist/dimsdk/core/model.js +0 -16
- package/dist/dimsdk/core/observability/perf-log.d.ts +0 -18
- package/dist/dimsdk/core/observability/perf-log.js +0 -236
- package/dist/dimsdk/core/store/agent-event-mappers.d.ts +0 -26
- package/dist/dimsdk/core/store/agent-event-mappers.js +0 -109
- package/dist/dimsdk/core/store/message-mutations.d.ts +0 -105
- package/dist/dimsdk/core/store/message-mutations.js +0 -1528
- package/dist/dimsdk/core/store/semantic-readers.d.ts +0 -2
- package/dist/dimsdk/core/store/semantic-readers.js +0 -4
- package/dist/dimsdk/core/store/transcript-projector.d.ts +0 -164
- package/dist/dimsdk/core/store/transcript-projector.js +0 -580
- package/dist/dimsdk/core/tool-metadata.d.ts +0 -12
- package/dist/dimsdk/core/tool-metadata.js +0 -70
- package/dist/dimsdk/core/transcript-part-id.d.ts +0 -6
- package/dist/dimsdk/core/transcript-part-id.js +0 -22
- package/dist/dimsdk/i18n/index.d.ts +0 -18
- package/dist/dimsdk/i18n/index.js +0 -141
- package/dist/dimsdk/i18n/locales/en.d.ts +0 -988
- package/dist/dimsdk/i18n/locales/en.js +0 -987
- package/dist/dimsdk/i18n/locales/index.d.ts +0 -1976
- package/dist/dimsdk/i18n/locales/index.js +0 -8
- package/dist/dimsdk/i18n/locales/zh-CN.d.ts +0 -988
- package/dist/dimsdk/i18n/locales/zh-CN.js +0 -987
- package/dist/dimsdk/i18n/types.d.ts +0 -13
- package/dist/dimsdk/i18n/types.js +0 -2
- package/dist/dimsdk/shared/value-normalizers.d.ts +0 -7
- package/dist/dimsdk/shared/value-normalizers.js +0 -48
- package/dist/dimsdk-tui.bundle-size.json +0 -169
- package/dist/dimsdk-tui.bundle.js +0 -330756
- package/dist/goatchain-adapter.d.ts +0 -41
- package/dist/goatchain-adapter.js +0 -499
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -1405
- package/dist/native-runtime-bridge.d.ts +0 -387
- package/dist/native-runtime-bridge.js +0 -4624
- package/dist/provider-config-env.d.ts +0 -7
- package/dist/provider-config-env.js +0 -286
- package/dist/provider-model-limit-index.generated.d.ts +0 -3
- package/dist/provider-model-limit-index.generated.js +0 -7818
- package/dist/provider-model-limits.d.ts +0 -8
- package/dist/provider-model-limits.js +0 -43
- package/dist/runtime.d.ts +0 -47
- package/dist/runtime.js +0 -516
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ProviderCompatibilityMode, ProviderConfig, ProviderDecisionTransportMode, ProviderKind } from "@best-agent/protocol";
|
|
2
|
-
export declare function getProviderConfigFromEnv(env?: NodeJS.ProcessEnv): ProviderConfig | undefined;
|
|
3
|
-
export declare function enrichProviderConfig(config: ProviderConfig): ProviderConfig;
|
|
4
|
-
export declare function parseProviderKind(raw: string | undefined): ProviderKind | undefined;
|
|
5
|
-
export declare function parseProviderCompatibilityMode(raw: string | undefined): ProviderCompatibilityMode | undefined;
|
|
6
|
-
export declare function parseProviderDecisionTransportMode(raw: string | undefined): ProviderDecisionTransportMode | undefined;
|
|
7
|
-
//# sourceMappingURL=provider-config-env.d.ts.map
|
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
import { inferProviderModelLimit } from "./provider-model-limits.js";
|
|
2
|
-
const COMPATIBLE_CHAT_COMPLETION_MAX_TOKENS = 32_000;
|
|
3
|
-
const PROVIDER_KIND_BY_VALUE = {
|
|
4
|
-
aihubmix: "aihubmix",
|
|
5
|
-
"aihubmix-responses": "aihubmix-responses",
|
|
6
|
-
anthropic: "anthropic",
|
|
7
|
-
customProvider: "customProvider",
|
|
8
|
-
deepseek: "deepseek",
|
|
9
|
-
google: "google",
|
|
10
|
-
moonshotai: "moonshotai",
|
|
11
|
-
openai: "openai",
|
|
12
|
-
"openai-responses": "openai-responses",
|
|
13
|
-
xai: "xai",
|
|
14
|
-
"xai-responses": "xai-responses",
|
|
15
|
-
zenmux: "zenmux",
|
|
16
|
-
};
|
|
17
|
-
const PROVIDER_COMPATIBILITY_BY_VALUE = {
|
|
18
|
-
auto: "auto",
|
|
19
|
-
compatible: "compatible",
|
|
20
|
-
native: "native",
|
|
21
|
-
};
|
|
22
|
-
const PROVIDER_DECISION_TRANSPORT_BY_VALUE = {
|
|
23
|
-
auto: "auto",
|
|
24
|
-
native_tools: "native_tools",
|
|
25
|
-
};
|
|
26
|
-
export function getProviderConfigFromEnv(env = process.env) {
|
|
27
|
-
const kind = parseProviderKindFromEnv(env.BEST_AGENT_PROVIDER_KIND);
|
|
28
|
-
const explicitCompatibilityMode = parseProviderCompatibilityModeFromEnv(env.BEST_AGENT_PROVIDER_COMPATIBILITY_MODE, "BEST_AGENT_PROVIDER_COMPATIBILITY_MODE");
|
|
29
|
-
const explicitDecisionTransport = parseProviderDecisionTransportMode(env.BEST_AGENT_PROVIDER_DECISION_TRANSPORT);
|
|
30
|
-
const timeoutMs = resolveProviderTimeoutMs(env);
|
|
31
|
-
const model = env.BEST_AGENT_PROVIDER_MODEL;
|
|
32
|
-
if (kind && model) {
|
|
33
|
-
return enrichProviderConfig({
|
|
34
|
-
kind,
|
|
35
|
-
model,
|
|
36
|
-
apiKey: resolveProviderApiKey(env, kind),
|
|
37
|
-
baseURL: resolveProviderBaseUrl(env, kind),
|
|
38
|
-
compatibilityMode: resolveProviderCompatibilityMode(env, kind, explicitCompatibilityMode),
|
|
39
|
-
decisionTransport: explicitDecisionTransport,
|
|
40
|
-
systemPrompt: env.BEST_AGENT_PROVIDER_SYSTEM_PROMPT,
|
|
41
|
-
timeoutMs,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
const inferredProviders = [
|
|
45
|
-
"openai",
|
|
46
|
-
"xai",
|
|
47
|
-
"deepseek",
|
|
48
|
-
"moonshotai",
|
|
49
|
-
"aihubmix",
|
|
50
|
-
"zenmux",
|
|
51
|
-
"customProvider",
|
|
52
|
-
];
|
|
53
|
-
for (const inferredKind of inferredProviders) {
|
|
54
|
-
const inferredModel = resolveDefaultProviderModel(env, inferredKind);
|
|
55
|
-
if (!inferredModel) {
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
return enrichProviderConfig({
|
|
59
|
-
kind: inferredKind,
|
|
60
|
-
model: inferredModel,
|
|
61
|
-
apiKey: resolveProviderApiKey(env, inferredKind),
|
|
62
|
-
baseURL: resolveProviderBaseUrl(env, inferredKind),
|
|
63
|
-
compatibilityMode: resolveProviderCompatibilityMode(env, inferredKind, explicitCompatibilityMode),
|
|
64
|
-
decisionTransport: explicitDecisionTransport,
|
|
65
|
-
systemPrompt: env.BEST_AGENT_PROVIDER_SYSTEM_PROMPT,
|
|
66
|
-
timeoutMs,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
return undefined;
|
|
70
|
-
}
|
|
71
|
-
export function enrichProviderConfig(config) {
|
|
72
|
-
const inferredContextWindow = resolveProviderContextWindow(config);
|
|
73
|
-
const inferredMaxOutputTokens = resolveProviderMaxOutputTokens(config);
|
|
74
|
-
return {
|
|
75
|
-
...config,
|
|
76
|
-
...(typeof inferredContextWindow === "number" ? { maxInputTokens: inferredContextWindow } : {}),
|
|
77
|
-
...(typeof inferredMaxOutputTokens === "number"
|
|
78
|
-
? { maxOutputTokens: inferredMaxOutputTokens }
|
|
79
|
-
: {}),
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
function resolveProviderApiKey(env, kind) {
|
|
83
|
-
const explicit = env.BEST_AGENT_PROVIDER_API_KEY;
|
|
84
|
-
if (explicit) {
|
|
85
|
-
return explicit;
|
|
86
|
-
}
|
|
87
|
-
switch (kind) {
|
|
88
|
-
case "openai":
|
|
89
|
-
case "openai-responses":
|
|
90
|
-
return env.OPENAI_API_KEY;
|
|
91
|
-
case "anthropic":
|
|
92
|
-
return env.ANTHROPIC_API_KEY;
|
|
93
|
-
case "google":
|
|
94
|
-
return env.GOOGLE_GENERATIVE_AI_API_KEY;
|
|
95
|
-
case "xai":
|
|
96
|
-
case "xai-responses":
|
|
97
|
-
return env.XAI_API_KEY;
|
|
98
|
-
case "deepseek":
|
|
99
|
-
return env.DEEPSEEK_API_KEY;
|
|
100
|
-
case "moonshotai":
|
|
101
|
-
return env.MOONSHOTAI_API_KEY;
|
|
102
|
-
case "aihubmix":
|
|
103
|
-
case "aihubmix-responses":
|
|
104
|
-
return env.AIHUBMIX_API_KEY;
|
|
105
|
-
case "zenmux":
|
|
106
|
-
return env.ZENMUX_API_KEY;
|
|
107
|
-
case "customProvider":
|
|
108
|
-
return env.CUSTOM_PROVIDER_API_KEY;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
function resolveProviderBaseUrl(env, kind) {
|
|
112
|
-
const explicit = env.BEST_AGENT_PROVIDER_BASE_URL;
|
|
113
|
-
if (explicit) {
|
|
114
|
-
return explicit;
|
|
115
|
-
}
|
|
116
|
-
switch (kind) {
|
|
117
|
-
case "openai":
|
|
118
|
-
case "openai-responses":
|
|
119
|
-
return env.OPENAI_BASE_URL;
|
|
120
|
-
case "xai":
|
|
121
|
-
case "xai-responses":
|
|
122
|
-
return env.XAI_BASE_URL;
|
|
123
|
-
case "deepseek":
|
|
124
|
-
return env.DEEPSEEK_BASE_URL;
|
|
125
|
-
case "moonshotai":
|
|
126
|
-
return env.MOONSHOTAI_BASE_URL;
|
|
127
|
-
case "aihubmix":
|
|
128
|
-
case "aihubmix-responses":
|
|
129
|
-
return env.AIHUBMIX_BASE_URL;
|
|
130
|
-
case "zenmux":
|
|
131
|
-
return env.ZENMUX_BASE_URL;
|
|
132
|
-
case "customProvider":
|
|
133
|
-
return env.CUSTOM_PROVIDER_BASE_URL;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
function resolveProviderCompatibilityMode(env, kind, explicit) {
|
|
137
|
-
if (explicit) {
|
|
138
|
-
return explicit;
|
|
139
|
-
}
|
|
140
|
-
switch (kind) {
|
|
141
|
-
case "openai":
|
|
142
|
-
case "openai-responses":
|
|
143
|
-
return parseProviderCompatibilityModeFromEnv(env.OPENAI_COMPATIBILITY_MODE, "OPENAI_COMPATIBILITY_MODE");
|
|
144
|
-
default:
|
|
145
|
-
return undefined;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
export function parseProviderKind(raw) {
|
|
149
|
-
return raw ? PROVIDER_KIND_BY_VALUE[raw] : undefined;
|
|
150
|
-
}
|
|
151
|
-
function parseProviderKindFromEnv(raw) {
|
|
152
|
-
if (!raw) {
|
|
153
|
-
return undefined;
|
|
154
|
-
}
|
|
155
|
-
const parsed = parseProviderKind(raw);
|
|
156
|
-
if (parsed) {
|
|
157
|
-
return parsed;
|
|
158
|
-
}
|
|
159
|
-
throw new Error(`Unsupported BEST_AGENT_PROVIDER_KIND=${raw}.`);
|
|
160
|
-
}
|
|
161
|
-
export function parseProviderCompatibilityMode(raw) {
|
|
162
|
-
return raw ? PROVIDER_COMPATIBILITY_BY_VALUE[raw] : undefined;
|
|
163
|
-
}
|
|
164
|
-
function parseProviderCompatibilityModeFromEnv(raw, envName) {
|
|
165
|
-
if (!raw) {
|
|
166
|
-
return undefined;
|
|
167
|
-
}
|
|
168
|
-
const parsed = parseProviderCompatibilityMode(raw);
|
|
169
|
-
if (parsed) {
|
|
170
|
-
return parsed;
|
|
171
|
-
}
|
|
172
|
-
throw new Error(`Unsupported ${envName}=${raw}. Use auto, compatible, or native.`);
|
|
173
|
-
}
|
|
174
|
-
export function parseProviderDecisionTransportMode(raw) {
|
|
175
|
-
if (!raw) {
|
|
176
|
-
return undefined;
|
|
177
|
-
}
|
|
178
|
-
const parsed = PROVIDER_DECISION_TRANSPORT_BY_VALUE[raw];
|
|
179
|
-
if (parsed) {
|
|
180
|
-
return parsed;
|
|
181
|
-
}
|
|
182
|
-
throw new Error(`Unsupported provider decision transport ${raw}. Use native_tools or auto.`);
|
|
183
|
-
}
|
|
184
|
-
function resolveProviderTimeoutMs(env) {
|
|
185
|
-
const value = env.BEST_AGENT_PROVIDER_TIMEOUT_MS;
|
|
186
|
-
if (!value) {
|
|
187
|
-
return undefined;
|
|
188
|
-
}
|
|
189
|
-
const parsed = Number(value);
|
|
190
|
-
if (Number.isFinite(parsed) && parsed > 0) {
|
|
191
|
-
return parsed;
|
|
192
|
-
}
|
|
193
|
-
throw new Error(`Unsupported BEST_AGENT_PROVIDER_TIMEOUT_MS=${value}. Use a positive number.`);
|
|
194
|
-
}
|
|
195
|
-
function resolveDefaultProviderModel(env, kind) {
|
|
196
|
-
switch (kind) {
|
|
197
|
-
case "openai":
|
|
198
|
-
return env.OPENAI_MODEL;
|
|
199
|
-
case "xai":
|
|
200
|
-
return env.XAI_MODEL;
|
|
201
|
-
case "deepseek":
|
|
202
|
-
return env.DEEPSEEK_MODEL;
|
|
203
|
-
case "moonshotai":
|
|
204
|
-
return env.MOONSHOTAI_MODEL;
|
|
205
|
-
case "aihubmix":
|
|
206
|
-
return env.AIHUBMIX_MODEL;
|
|
207
|
-
case "zenmux":
|
|
208
|
-
return env.ZENMUX_MODEL;
|
|
209
|
-
case "customProvider":
|
|
210
|
-
return env.CUSTOM_PROVIDER_MODEL;
|
|
211
|
-
default:
|
|
212
|
-
return undefined;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
function resolveProviderContextWindow(config) {
|
|
216
|
-
if (typeof config.maxInputTokens === "number" &&
|
|
217
|
-
Number.isFinite(config.maxInputTokens) &&
|
|
218
|
-
config.maxInputTokens > 0) {
|
|
219
|
-
return Math.floor(config.maxInputTokens);
|
|
220
|
-
}
|
|
221
|
-
if (!isOpenAiCompatibleProviderKind(config.kind)) {
|
|
222
|
-
return undefined;
|
|
223
|
-
}
|
|
224
|
-
const adapter = resolveProviderAdapter(config.kind);
|
|
225
|
-
return inferProviderModelLimit(config.model, adapter, "lowest")?.context;
|
|
226
|
-
}
|
|
227
|
-
function resolveProviderMaxOutputTokens(config) {
|
|
228
|
-
if (typeof config.maxOutputTokens === "number" &&
|
|
229
|
-
Number.isFinite(config.maxOutputTokens) &&
|
|
230
|
-
config.maxOutputTokens > 0) {
|
|
231
|
-
return Math.floor(config.maxOutputTokens);
|
|
232
|
-
}
|
|
233
|
-
return isCompatibleChatCompletionsProvider(config)
|
|
234
|
-
? COMPATIBLE_CHAT_COMPLETION_MAX_TOKENS
|
|
235
|
-
: undefined;
|
|
236
|
-
}
|
|
237
|
-
function resolveProviderAdapter(kind) {
|
|
238
|
-
switch (kind) {
|
|
239
|
-
case "google":
|
|
240
|
-
return "gemini";
|
|
241
|
-
case "anthropic":
|
|
242
|
-
return "anthropic";
|
|
243
|
-
case "openai-responses":
|
|
244
|
-
case "xai-responses":
|
|
245
|
-
case "aihubmix-responses":
|
|
246
|
-
return "openai-responses";
|
|
247
|
-
default:
|
|
248
|
-
return "openai";
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
function isCompatibleChatCompletionsProvider(config) {
|
|
252
|
-
if (!isOpenAiCompatibleProviderKind(config.kind)) {
|
|
253
|
-
return false;
|
|
254
|
-
}
|
|
255
|
-
return resolveProviderCompatibilityModeForConfig(config) === "compatible";
|
|
256
|
-
}
|
|
257
|
-
function isOpenAiCompatibleProviderKind(kind) {
|
|
258
|
-
return (kind === "openai" ||
|
|
259
|
-
kind === "openai-responses" ||
|
|
260
|
-
kind === "xai" ||
|
|
261
|
-
kind === "xai-responses" ||
|
|
262
|
-
kind === "deepseek" ||
|
|
263
|
-
kind === "moonshotai" ||
|
|
264
|
-
kind === "aihubmix" ||
|
|
265
|
-
kind === "aihubmix-responses" ||
|
|
266
|
-
kind === "zenmux" ||
|
|
267
|
-
kind === "customProvider");
|
|
268
|
-
}
|
|
269
|
-
function resolveProviderCompatibilityModeForConfig(config) {
|
|
270
|
-
if (config.compatibilityMode === "compatible") {
|
|
271
|
-
return "compatible";
|
|
272
|
-
}
|
|
273
|
-
if (config.compatibilityMode === "native") {
|
|
274
|
-
return "native";
|
|
275
|
-
}
|
|
276
|
-
if (!config.baseURL) {
|
|
277
|
-
return "native";
|
|
278
|
-
}
|
|
279
|
-
try {
|
|
280
|
-
return new URL(config.baseURL).hostname !== "api.openai.com" ? "compatible" : "native";
|
|
281
|
-
}
|
|
282
|
-
catch {
|
|
283
|
-
return "native";
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
//# sourceMappingURL=provider-config-env.js.map
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export type IndexedProviderAdapter = "openai" | "openai-responses" | "anthropic" | "gemini";
|
|
2
|
-
export declare const MODEL_LIMIT_INDEX: Readonly<Record<IndexedProviderAdapter, Readonly<Record<string, readonly [number, number, number, number]>>>>;
|
|
3
|
-
//# sourceMappingURL=provider-model-limit-index.generated.d.ts.map
|