@blockrun/franklin 3.31.0 → 3.32.0
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/dist/agent/commands.js +72 -2
- package/dist/agent/llm.d.ts +1 -1
- package/dist/agent/llm.js +55 -14
- package/dist/agent/loop.js +19 -3
- package/dist/agent/permissions.js +17 -0
- package/dist/agent/types.d.ts +24 -0
- package/dist/commands/predict.d.ts +10 -0
- package/dist/commands/predict.js +143 -0
- package/dist/commands/start.js +24 -7
- package/dist/config.d.ts +1 -0
- package/dist/config.js +6 -0
- package/dist/index.js +12 -0
- package/dist/market/client.d.ts +69 -0
- package/dist/market/client.js +230 -0
- package/dist/tools/agent-talent.d.ts +15 -0
- package/dist/tools/agent-talent.js +116 -0
- package/dist/tools/defillama.js +6 -5
- package/dist/tools/index.d.ts +15 -0
- package/dist/tools/index.js +28 -0
- package/dist/tools/prediction.js +11 -10
- package/dist/tools/trading.js +3 -2
- package/dist/ui/model-picker.d.ts +26 -1
- package/dist/ui/model-picker.js +49 -3
- package/package.json +2 -2
package/dist/tools/trading.js
CHANGED
|
@@ -4,6 +4,7 @@ const SUPPORTED_STOCK_MARKETS = [
|
|
|
4
4
|
];
|
|
5
5
|
import { rsi, macd, bollingerBands, volatility } from '../trading/metrics.js';
|
|
6
6
|
import { bus } from '../events/bus.js';
|
|
7
|
+
import { frameUntrusted } from './untrusted.js';
|
|
7
8
|
import { makeEvent } from '../events/types.js';
|
|
8
9
|
function formatUsd(n) {
|
|
9
10
|
if (n >= 1e12)
|
|
@@ -292,7 +293,7 @@ async function executeMarket(input, _ctx) {
|
|
|
292
293
|
return { output: `Error: ${result}`, isError: true };
|
|
293
294
|
}
|
|
294
295
|
const lines = result.map((c, i) => `${i + 1}. ${c.name} (${c.symbol.toUpperCase()})${c.marketCapRank ? ` — #${c.marketCapRank}` : ''}`);
|
|
295
|
-
return { output:
|
|
296
|
+
return { output: frameUntrusted('Trending coins (untrusted)', lines.join('\n')) };
|
|
296
297
|
}
|
|
297
298
|
case 'overview': {
|
|
298
299
|
const result = await getMarketOverview();
|
|
@@ -302,7 +303,7 @@ async function executeMarket(input, _ctx) {
|
|
|
302
303
|
const header = 'Rank | Coin | Price | 24h Change | Market Cap';
|
|
303
304
|
const sep = '-----|------|-------|------------|----------';
|
|
304
305
|
const rows = result.map((c, i) => `${i + 1} | ${c.name} (${c.symbol.toUpperCase()}) | $${c.price.toLocaleString()} | ${c.change24h > 0 ? '+' : ''}${c.change24h.toFixed(2)}% | ${formatUsd(c.marketCap)}`);
|
|
305
|
-
return { output:
|
|
306
|
+
return { output: frameUntrusted('Top coins by market cap (untrusted)', `${header}\n${sep}\n${rows.join('\n')}`) };
|
|
306
307
|
}
|
|
307
308
|
default:
|
|
308
309
|
return {
|
|
@@ -4,9 +4,34 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export declare const MODEL_SHORTCUTS: Record<string, string>;
|
|
6
6
|
/**
|
|
7
|
-
* Resolve a model name — supports shortcuts.
|
|
7
|
+
* Resolve a model name — supports shortcuts. Returns the canonical model id.
|
|
8
|
+
*
|
|
9
|
+
* If the input matches a shortcut, the shortcut's target is returned. If the
|
|
10
|
+
* input is already a fully-qualified `provider/model` id (contains a `/`), it
|
|
11
|
+
* is returned verbatim so the gateway can validate it. Bare, unknown aliases
|
|
12
|
+
* (e.g. `llama3`, `foo`) resolve to themselves too, but the gateway will
|
|
13
|
+
* reject them — callers that care about a clean error should branch on
|
|
14
|
+
* {@link resolveModelStrict} instead.
|
|
8
15
|
*/
|
|
9
16
|
export declare function resolveModel(input: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Strict variant of {@link resolveModel} — used by the `/model` handler so
|
|
19
|
+
* an unknown bare alias surfaces a clean error in the UI instead of
|
|
20
|
+
* forwarding `llama` to the gateway and getting back `HTTP 400: Unknown
|
|
21
|
+
* model: llama` two turns later.
|
|
22
|
+
*
|
|
23
|
+
* Recognised:
|
|
24
|
+
* - Any entry in {@link MODEL_SHORTCUTS} (case-insensitive).
|
|
25
|
+
* - Any id of the form `provider/model` (e.g. `anthropic/claude-sonnet-4.6`).
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveModelStrict(input: string): {
|
|
28
|
+
ok: true;
|
|
29
|
+
id: string;
|
|
30
|
+
viaShortcut: boolean;
|
|
31
|
+
} | {
|
|
32
|
+
ok: false;
|
|
33
|
+
suggestion: string;
|
|
34
|
+
};
|
|
10
35
|
export interface ModelEntry {
|
|
11
36
|
id: string;
|
|
12
37
|
shortcut: string;
|
package/dist/ui/model-picker.js
CHANGED
|
@@ -107,6 +107,12 @@ export const MODEL_SHORTCUTS = {
|
|
|
107
107
|
'gpt-oss-small': 'nvidia/qwen3-next-80b-a3b-instruct',
|
|
108
108
|
'mistral-small': 'nvidia/qwen3-next-80b-a3b-instruct',
|
|
109
109
|
'mistral-nemotron': 'nvidia/mistral-nemotron',
|
|
110
|
+
// llama shortcuts point at the still-live free maverick model (not the free
|
|
111
|
+
// default — that's qwen3-next above). Kept as explicit aliases so the name
|
|
112
|
+
// resolves for users who type it.
|
|
113
|
+
llama: 'nvidia/llama-4-maverick',
|
|
114
|
+
'llama-4': 'nvidia/llama-4-maverick',
|
|
115
|
+
'llama-4-maverick': 'nvidia/llama-4-maverick',
|
|
110
116
|
// Backward-compatibility aliases for models the gateway retired or exposes
|
|
111
117
|
// unreliably on /v1/messages. Map to agent-tested free models so shortcuts
|
|
112
118
|
// keep working without silent paid fallback or empty tool-use turns.
|
|
@@ -137,11 +143,51 @@ export const MODEL_SHORTCUTS = {
|
|
|
137
143
|
'k2.5': 'moonshot/kimi-k2.7',
|
|
138
144
|
};
|
|
139
145
|
/**
|
|
140
|
-
* Resolve a model name — supports shortcuts.
|
|
146
|
+
* Resolve a model name — supports shortcuts. Returns the canonical model id.
|
|
147
|
+
*
|
|
148
|
+
* If the input matches a shortcut, the shortcut's target is returned. If the
|
|
149
|
+
* input is already a fully-qualified `provider/model` id (contains a `/`), it
|
|
150
|
+
* is returned verbatim so the gateway can validate it. Bare, unknown aliases
|
|
151
|
+
* (e.g. `llama3`, `foo`) resolve to themselves too, but the gateway will
|
|
152
|
+
* reject them — callers that care about a clean error should branch on
|
|
153
|
+
* {@link resolveModelStrict} instead.
|
|
141
154
|
*/
|
|
142
155
|
export function resolveModel(input) {
|
|
143
|
-
const
|
|
144
|
-
|
|
156
|
+
const trimmed = input.trim();
|
|
157
|
+
if (!trimmed)
|
|
158
|
+
return trimmed;
|
|
159
|
+
const lower = trimmed.toLowerCase();
|
|
160
|
+
return MODEL_SHORTCUTS[lower] || trimmed;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Strict variant of {@link resolveModel} — used by the `/model` handler so
|
|
164
|
+
* an unknown bare alias surfaces a clean error in the UI instead of
|
|
165
|
+
* forwarding `llama` to the gateway and getting back `HTTP 400: Unknown
|
|
166
|
+
* model: llama` two turns later.
|
|
167
|
+
*
|
|
168
|
+
* Recognised:
|
|
169
|
+
* - Any entry in {@link MODEL_SHORTCUTS} (case-insensitive).
|
|
170
|
+
* - Any id of the form `provider/model` (e.g. `anthropic/claude-sonnet-4.6`).
|
|
171
|
+
*/
|
|
172
|
+
export function resolveModelStrict(input) {
|
|
173
|
+
const trimmed = input.trim();
|
|
174
|
+
if (!trimmed) {
|
|
175
|
+
return { ok: false, suggestion: 'Empty model name. Try /model sonnet or /model free.' };
|
|
176
|
+
}
|
|
177
|
+
const lower = trimmed.toLowerCase();
|
|
178
|
+
if (Object.prototype.hasOwnProperty.call(MODEL_SHORTCUTS, lower)) {
|
|
179
|
+
return { ok: true, id: MODEL_SHORTCUTS[lower], viaShortcut: true };
|
|
180
|
+
}
|
|
181
|
+
if (trimmed.includes('/')) {
|
|
182
|
+
return { ok: true, id: trimmed, viaShortcut: false };
|
|
183
|
+
}
|
|
184
|
+
const known = Object.keys(MODEL_SHORTCUTS).sort();
|
|
185
|
+
const head = known.slice(0, 6).join(', ');
|
|
186
|
+
return {
|
|
187
|
+
ok: false,
|
|
188
|
+
suggestion: `Unknown model alias: "${trimmed}". Use a shortcut like ${head}, ` +
|
|
189
|
+
`or a full id like anthropic/claude-sonnet-4.6.`,
|
|
190
|
+
};
|
|
145
191
|
}
|
|
146
192
|
/**
|
|
147
193
|
* Single source of truth for the /model picker.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blockrun/franklin",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.32.0",
|
|
4
4
|
"description": "Franklin Agent — The AI agent with a wallet. Spends USDC autonomously to get real work done. Pay per action, no subscriptions.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"build": "tsc && node scripts/copy-plugin-assets.mjs",
|
|
32
32
|
"dev": "tsc --watch",
|
|
33
33
|
"start": "node dist/index.js",
|
|
34
|
-
"test": "npm run build && node --test --test-reporter=spec test/local.mjs test/skills.local.mjs test/repair.mjs test/exa.local.mjs test/audit-batch.local.mjs test/polymarket.local.mjs",
|
|
34
|
+
"test": "npm run build && node --test --test-reporter=spec test/local.mjs test/skills.local.mjs test/repair.mjs test/model-resolver.mjs test/exa.local.mjs test/audit-batch.local.mjs test/polymarket.local.mjs test/market.local.mjs",
|
|
35
35
|
"test:e2e": "npm run build && node --test --test-reporter=spec test/e2e.mjs",
|
|
36
36
|
"test:free-models": "npm run build && node --test --test-reporter=spec test/free-model-matrix.mjs",
|
|
37
37
|
"test:all": "npm run test && npm run test:e2e",
|