@agi-cli/server 0.1.131 → 0.1.132
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.132",
|
|
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.132",
|
|
33
|
+
"@agi-cli/database": "0.1.132",
|
|
34
34
|
"drizzle-orm": "^0.44.5",
|
|
35
35
|
"hono": "^4.9.9",
|
|
36
36
|
"zod": "^4.1.8"
|
package/src/index.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { registerTerminalsRoutes } from './routes/terminals.ts';
|
|
|
16
16
|
import { registerSessionFilesRoutes } from './routes/session-files.ts';
|
|
17
17
|
import { registerBranchRoutes } from './routes/branch.ts';
|
|
18
18
|
import { registerResearchRoutes } from './routes/research.ts';
|
|
19
|
+
import { registerSolforgeRoutes } from './routes/solforge.ts';
|
|
19
20
|
import type { AgentConfigEntry } from './runtime/agent/registry.ts';
|
|
20
21
|
|
|
21
22
|
const globalTerminalManager = new TerminalManager();
|
|
@@ -68,6 +69,7 @@ function initApp() {
|
|
|
68
69
|
registerSessionFilesRoutes(app);
|
|
69
70
|
registerBranchRoutes(app);
|
|
70
71
|
registerResearchRoutes(app);
|
|
72
|
+
registerSolforgeRoutes(app);
|
|
71
73
|
|
|
72
74
|
return app;
|
|
73
75
|
}
|
|
@@ -136,6 +138,7 @@ export function createStandaloneApp(_config?: StandaloneAppConfig) {
|
|
|
136
138
|
registerSessionFilesRoutes(honoApp);
|
|
137
139
|
registerBranchRoutes(honoApp);
|
|
138
140
|
registerResearchRoutes(honoApp);
|
|
141
|
+
registerSolforgeRoutes(honoApp);
|
|
139
142
|
|
|
140
143
|
return honoApp;
|
|
141
144
|
}
|
|
@@ -232,6 +235,7 @@ export function createEmbeddedApp(config: EmbeddedAppConfig = {}) {
|
|
|
232
235
|
registerSessionFilesRoutes(honoApp);
|
|
233
236
|
registerBranchRoutes(honoApp);
|
|
234
237
|
registerResearchRoutes(honoApp);
|
|
238
|
+
registerSolforgeRoutes(honoApp);
|
|
235
239
|
|
|
236
240
|
return honoApp;
|
|
237
241
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Hono } from 'hono';
|
|
2
|
+
import {
|
|
3
|
+
fetchSolforgeBalance,
|
|
4
|
+
getPublicKeyFromPrivate,
|
|
5
|
+
getAuth,
|
|
6
|
+
loadConfig,
|
|
7
|
+
} from '@agi-cli/sdk';
|
|
8
|
+
import { logger } from '@agi-cli/sdk';
|
|
9
|
+
import { serializeError } from '../runtime/errors/api-error.ts';
|
|
10
|
+
|
|
11
|
+
async function getSolforgePrivateKey(): Promise<string | null> {
|
|
12
|
+
if (process.env.SOLFORGE_PRIVATE_KEY) {
|
|
13
|
+
return process.env.SOLFORGE_PRIVATE_KEY;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const cfg = await loadConfig(process.cwd());
|
|
18
|
+
const auth = await getAuth('solforge', cfg.projectRoot);
|
|
19
|
+
if (auth?.type === 'wallet' && auth.secret) {
|
|
20
|
+
return auth.secret;
|
|
21
|
+
}
|
|
22
|
+
} catch {}
|
|
23
|
+
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function registerSolforgeRoutes(app: Hono) {
|
|
28
|
+
app.get('/v1/solforge/balance', async (c) => {
|
|
29
|
+
try {
|
|
30
|
+
const privateKey = await getSolforgePrivateKey();
|
|
31
|
+
if (!privateKey) {
|
|
32
|
+
return c.json({ error: 'Solforge wallet not configured' }, 401);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const balance = await fetchSolforgeBalance({ privateKey });
|
|
36
|
+
if (!balance) {
|
|
37
|
+
return c.json({ error: 'Failed to fetch balance from Solforge' }, 502);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return c.json(balance);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
logger.error('Failed to fetch Solforge balance', error);
|
|
43
|
+
const errorResponse = serializeError(error);
|
|
44
|
+
return c.json(errorResponse, errorResponse.error.status || 500);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
app.get('/v1/solforge/wallet', async (c) => {
|
|
49
|
+
try {
|
|
50
|
+
const privateKey = await getSolforgePrivateKey();
|
|
51
|
+
if (!privateKey) {
|
|
52
|
+
return c.json(
|
|
53
|
+
{ error: 'Solforge wallet not configured', configured: false },
|
|
54
|
+
200,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const publicKey = getPublicKeyFromPrivate(privateKey);
|
|
59
|
+
if (!publicKey) {
|
|
60
|
+
return c.json({ error: 'Invalid private key', configured: false }, 200);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return c.json({
|
|
64
|
+
configured: true,
|
|
65
|
+
publicKey,
|
|
66
|
+
});
|
|
67
|
+
} catch (error) {
|
|
68
|
+
logger.error('Failed to get Solforge wallet info', error);
|
|
69
|
+
const errorResponse = serializeError(error);
|
|
70
|
+
return c.json(errorResponse, errorResponse.error.status || 500);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
@@ -5,7 +5,11 @@ import { openai, createOpenAI } from '@ai-sdk/openai';
|
|
|
5
5
|
export async function resolveOpenAIModel(
|
|
6
6
|
model: string,
|
|
7
7
|
cfg: AGIConfig,
|
|
8
|
-
options?: {
|
|
8
|
+
options?: {
|
|
9
|
+
systemPrompt?: string;
|
|
10
|
+
promptCacheKey?: string;
|
|
11
|
+
promptCacheRetention?: 'in_memory' | '24h';
|
|
12
|
+
},
|
|
9
13
|
) {
|
|
10
14
|
const auth = await getAuth('openai', cfg.projectRoot);
|
|
11
15
|
if (auth?.type === 'oauth') {
|
|
@@ -16,6 +20,8 @@ export async function resolveOpenAIModel(
|
|
|
16
20
|
reasoningEffort: isCodexModel ? 'high' : 'medium',
|
|
17
21
|
reasoningSummary: 'auto',
|
|
18
22
|
instructions: options?.systemPrompt,
|
|
23
|
+
promptCacheKey: options?.promptCacheKey,
|
|
24
|
+
promptCacheRetention: options?.promptCacheRetention,
|
|
19
25
|
});
|
|
20
26
|
}
|
|
21
27
|
if (auth?.type === 'api' && auth.key) {
|
|
@@ -19,7 +19,6 @@ export function resolveSolforgeModel(model: string, sessionId?: string) {
|
|
|
19
19
|
}
|
|
20
20
|
const baseURL = process.env.SOLFORGE_BASE_URL;
|
|
21
21
|
const rpcURL = process.env.SOLFORGE_SOLANA_RPC_URL;
|
|
22
|
-
const topupAmount = process.env.SOLFORGE_TOPUP_MICRO_USDC;
|
|
23
22
|
|
|
24
23
|
const callbacks: SolforgePaymentCallbacks = sessionId
|
|
25
24
|
? {
|
|
@@ -62,7 +61,6 @@ export function resolveSolforgeModel(model: string, sessionId?: string) {
|
|
|
62
61
|
{
|
|
63
62
|
baseURL,
|
|
64
63
|
rpcURL,
|
|
65
|
-
topupAmountMicroUsdc: topupAmount,
|
|
66
64
|
callbacks,
|
|
67
65
|
providerNpm,
|
|
68
66
|
},
|