@agi-cli/sdk 0.1.143 → 0.1.145
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 +3 -3
- package/src/index.ts +4 -1
- package/src/prompts/src/providers.ts +30 -24
- package/src/providers/src/catalog.ts +27 -1
- package/src/providers/src/utils.ts +13 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agi-cli/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.145",
|
|
4
4
|
"description": "AI agent SDK for building intelligent assistants - tree-shakable and comprehensive",
|
|
5
5
|
"author": "nitishxyz",
|
|
6
6
|
"license": "MIT",
|
|
@@ -102,10 +102,10 @@
|
|
|
102
102
|
"bun-pty": "^0.3.2",
|
|
103
103
|
"diff": "^8.0.2",
|
|
104
104
|
"fast-glob": "^3.3.2",
|
|
105
|
-
"hono": "^4.9.
|
|
105
|
+
"hono": "^4.9.9",
|
|
106
106
|
"opencode-anthropic-auth": "^0.0.2",
|
|
107
107
|
"tweetnacl": "^1.0.3",
|
|
108
|
-
"x402": "^
|
|
108
|
+
"x402": "^1.1.0",
|
|
109
109
|
"zod": "^4.1.8"
|
|
110
110
|
},
|
|
111
111
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -158,7 +158,10 @@ export type { Scope } from './config/src/manager.ts';
|
|
|
158
158
|
// =======================
|
|
159
159
|
// Prompts (from internal prompts module)
|
|
160
160
|
// =======================
|
|
161
|
-
export {
|
|
161
|
+
export {
|
|
162
|
+
providerBasePrompt,
|
|
163
|
+
type ProviderPromptResult,
|
|
164
|
+
} from './prompts/src/providers.ts';
|
|
162
165
|
|
|
163
166
|
// =======================
|
|
164
167
|
// Core AI Functions (from internal core module)
|
|
@@ -43,12 +43,19 @@ async function readIfExists(path: string): Promise<string | undefined> {
|
|
|
43
43
|
return undefined;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
export type ProviderPromptResult = {
|
|
47
|
+
prompt: string;
|
|
48
|
+
resolvedType: string;
|
|
49
|
+
};
|
|
50
|
+
|
|
46
51
|
export async function providerBasePrompt(
|
|
47
52
|
provider: string,
|
|
48
53
|
modelId: string | undefined,
|
|
49
54
|
_projectRoot: string,
|
|
50
|
-
): Promise<
|
|
55
|
+
): Promise<ProviderPromptResult> {
|
|
51
56
|
const id = String(provider || '').toLowerCase();
|
|
57
|
+
let promptType: string;
|
|
58
|
+
let result: string;
|
|
52
59
|
|
|
53
60
|
// 1) Model-specific override: src/prompts/models/<sanitizedModel>.txt
|
|
54
61
|
if (modelId) {
|
|
@@ -56,9 +63,9 @@ export async function providerBasePrompt(
|
|
|
56
63
|
const modelPath = `src/prompts/models/${sanitized}.txt`;
|
|
57
64
|
const modelText = await readIfExists(modelPath);
|
|
58
65
|
if (modelText) {
|
|
59
|
-
|
|
60
|
-
debugLog(`[provider]
|
|
61
|
-
return modelText;
|
|
66
|
+
promptType = `model:${sanitized}`;
|
|
67
|
+
debugLog(`[provider] prompt: ${promptType} (${modelText.length} chars)`);
|
|
68
|
+
return { prompt: modelText, resolvedType: promptType };
|
|
62
69
|
}
|
|
63
70
|
}
|
|
64
71
|
|
|
@@ -74,7 +81,7 @@ export async function providerBasePrompt(
|
|
|
74
81
|
) {
|
|
75
82
|
const family = inferFamilyFromModel(id, modelId);
|
|
76
83
|
if (family) {
|
|
77
|
-
|
|
84
|
+
result = (
|
|
78
85
|
family === 'openai'
|
|
79
86
|
? PROVIDER_OPENAI
|
|
80
87
|
: family === 'anthropic'
|
|
@@ -83,40 +90,39 @@ export async function providerBasePrompt(
|
|
|
83
90
|
? PROVIDER_GOOGLE
|
|
84
91
|
: PROVIDER_DEFAULT
|
|
85
92
|
).trim();
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
debugLog(`[provider] base prompt for family ${family}:\n${embedded}`);
|
|
90
|
-
return embedded;
|
|
93
|
+
promptType = `family:${family} (via ${id}/${modelId})`;
|
|
94
|
+
debugLog(`[provider] prompt: ${promptType} (${result.length} chars)`);
|
|
95
|
+
return { prompt: result, resolvedType: family };
|
|
91
96
|
}
|
|
92
97
|
}
|
|
93
98
|
|
|
94
99
|
// 3) Provider-specific embedded defaults for known providers
|
|
95
100
|
if (id === 'openai') {
|
|
96
|
-
|
|
97
|
-
debugLog(
|
|
98
|
-
return
|
|
101
|
+
result = PROVIDER_OPENAI.trim();
|
|
102
|
+
debugLog(`[provider] prompt: openai (${result.length} chars)`);
|
|
103
|
+
return { prompt: result, resolvedType: 'openai' };
|
|
99
104
|
}
|
|
100
105
|
if (id === 'anthropic') {
|
|
101
|
-
|
|
102
|
-
debugLog(
|
|
103
|
-
return
|
|
106
|
+
result = PROVIDER_ANTHROPIC.trim();
|
|
107
|
+
debugLog(`[provider] prompt: anthropic (${result.length} chars)`);
|
|
108
|
+
return { prompt: result, resolvedType: 'anthropic' };
|
|
104
109
|
}
|
|
105
110
|
if (id === 'google') {
|
|
106
|
-
|
|
107
|
-
debugLog(
|
|
108
|
-
return
|
|
111
|
+
result = PROVIDER_GOOGLE.trim();
|
|
112
|
+
debugLog(`[provider] prompt: google (${result.length} chars)`);
|
|
113
|
+
return { prompt: result, resolvedType: 'google' };
|
|
109
114
|
}
|
|
115
|
+
|
|
110
116
|
// If a project adds a custom provider file, allow reading it from disk (user-defined)
|
|
111
117
|
const providerPath = `src/prompts/providers/${id}.txt`;
|
|
112
118
|
const providerText = await readIfExists(providerPath);
|
|
113
119
|
if (providerText) {
|
|
114
|
-
debugLog(`[provider]
|
|
115
|
-
|
|
116
|
-
return providerText;
|
|
120
|
+
debugLog(`[provider] prompt: custom:${id} (${providerText.length} chars)`);
|
|
121
|
+
return { prompt: providerText, resolvedType: `custom:${id}` };
|
|
117
122
|
}
|
|
118
123
|
|
|
119
124
|
// 4) Generic default
|
|
120
|
-
|
|
121
|
-
|
|
125
|
+
result = PROVIDER_DEFAULT.trim();
|
|
126
|
+
debugLog(`[provider] prompt: default (${result.length} chars)`);
|
|
127
|
+
return { prompt: result, resolvedType: 'default' };
|
|
122
128
|
}
|
|
@@ -6350,7 +6350,7 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
6350
6350
|
id: 'kimi-k2.5',
|
|
6351
6351
|
label: 'Kimi K2.5',
|
|
6352
6352
|
modalities: {
|
|
6353
|
-
input: ['text'],
|
|
6353
|
+
input: ['text', 'image', 'video'],
|
|
6354
6354
|
output: ['text'],
|
|
6355
6355
|
},
|
|
6356
6356
|
toolCall: true,
|
|
@@ -6985,6 +6985,32 @@ export const catalog: Partial<Record<ProviderId, ProviderCatalogEntry>> = {
|
|
|
6985
6985
|
output: 262144,
|
|
6986
6986
|
},
|
|
6987
6987
|
},
|
|
6988
|
+
{
|
|
6989
|
+
id: 'kimi-k2.5',
|
|
6990
|
+
label: 'Kimi K2.5',
|
|
6991
|
+
modalities: {
|
|
6992
|
+
input: ['text', 'image', 'video'],
|
|
6993
|
+
output: ['text'],
|
|
6994
|
+
},
|
|
6995
|
+
toolCall: true,
|
|
6996
|
+
reasoningText: true,
|
|
6997
|
+
attachment: false,
|
|
6998
|
+
temperature: true,
|
|
6999
|
+
knowledge: '2025-01',
|
|
7000
|
+
releaseDate: '2026-01',
|
|
7001
|
+
lastUpdated: '2026-01',
|
|
7002
|
+
openWeights: true,
|
|
7003
|
+
cost: {
|
|
7004
|
+
input: 0,
|
|
7005
|
+
output: 0,
|
|
7006
|
+
cacheRead: 0,
|
|
7007
|
+
cacheWrite: 0,
|
|
7008
|
+
},
|
|
7009
|
+
limit: {
|
|
7010
|
+
context: 262144,
|
|
7011
|
+
output: 262144,
|
|
7012
|
+
},
|
|
7013
|
+
},
|
|
6988
7014
|
],
|
|
6989
7015
|
label: 'Moonshot AI',
|
|
6990
7016
|
env: ['MOONSHOT_API_KEY'],
|
|
@@ -108,10 +108,20 @@ export function getModelNpmBinding(
|
|
|
108
108
|
provider: ProviderId,
|
|
109
109
|
model: string,
|
|
110
110
|
): string | undefined {
|
|
111
|
+
// 1) Check provider's own catalog entry
|
|
111
112
|
const entry = catalog[provider];
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
const modelInfo = entry?.models?.find((m) => m.id === model);
|
|
114
|
+
if (modelInfo?.provider?.npm) return modelInfo.provider.npm;
|
|
115
|
+
if (entry?.npm) return entry.npm;
|
|
116
|
+
|
|
117
|
+
// 2) Search entire catalog for the model
|
|
118
|
+
for (const key of Object.keys(catalog) as ProviderId[]) {
|
|
119
|
+
const e = catalog[key];
|
|
120
|
+
const m = e?.models?.find((x) => x.id === model);
|
|
121
|
+
if (m?.provider?.npm) return m.provider.npm;
|
|
122
|
+
if (m && e?.npm) return e.npm;
|
|
123
|
+
}
|
|
124
|
+
return undefined;
|
|
115
125
|
}
|
|
116
126
|
|
|
117
127
|
export function isAnthropicBasedModel(
|