@blockrun/franklin 3.49.11 → 3.49.13
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 +20 -2
- package/dist/agent/context.d.ts +5 -0
- package/dist/agent/context.js +26 -47
- package/dist/agent/injection-scan.d.ts +14 -0
- package/dist/agent/injection-scan.js +52 -0
- package/dist/agent/loop.js +8 -0
- package/dist/agent/optimize.js +1 -0
- package/dist/agent/tokens.js +1 -0
- package/dist/free-models.constants.js +3 -1
- package/dist/free-models.d.ts +17 -7
- package/dist/free-models.js +21 -8
- package/dist/goal/runtime.d.ts +4 -1
- package/dist/goal/runtime.js +42 -0
- package/dist/goal/types.d.ts +4 -0
- package/dist/learnings/experience.d.ts +80 -0
- package/dist/learnings/experience.js +422 -0
- package/dist/learnings/extractor.d.ts +8 -0
- package/dist/learnings/extractor.js +36 -29
- package/dist/learnings/store.d.ts +2 -0
- package/dist/learnings/store.js +2 -2
- package/dist/learnings/types.d.ts +39 -0
- package/dist/pricing.js +37 -18
- package/dist/router/vision.js +7 -0
- package/dist/ui/model-picker.js +85 -32
- package/package.json +4 -4
package/dist/agent/commands.js
CHANGED
|
@@ -944,12 +944,30 @@ export async function handleSlashCommand(input, ctx) {
|
|
|
944
944
|
// /learnings — view or clear per-user learnings
|
|
945
945
|
if (input === '/learnings' || input.startsWith('/learnings ')) {
|
|
946
946
|
const { loadLearnings, decayLearnings, saveLearnings } = await import('../learnings/store.js');
|
|
947
|
+
const { loadExperiences, saveExperiences } = await import('../learnings/experience.js');
|
|
947
948
|
const arg = input.slice('/learnings'.length).trim();
|
|
948
|
-
if (arg === 'clear') {
|
|
949
|
+
if (arg === 'clear lessons') {
|
|
950
|
+
saveExperiences([]);
|
|
951
|
+
ctx.onEvent({ kind: 'text_delta', text: 'All verified lessons cleared.\n' });
|
|
952
|
+
}
|
|
953
|
+
else if (arg === 'clear') {
|
|
949
954
|
saveLearnings([]);
|
|
950
|
-
ctx.onEvent({ kind: 'text_delta', text: 'All learnings cleared.\n' });
|
|
955
|
+
ctx.onEvent({ kind: 'text_delta', text: 'All learnings cleared (verified lessons kept — `/learnings clear lessons` removes those).\n' });
|
|
951
956
|
}
|
|
952
957
|
else {
|
|
958
|
+
const lessons = loadExperiences();
|
|
959
|
+
if (lessons.length > 0) {
|
|
960
|
+
const live = lessons.filter(l => l.verdict !== 'confounded');
|
|
961
|
+
const confounded = lessons.length - live.length;
|
|
962
|
+
let text = `**Lessons verified by goal outcomes** (${live.length}${confounded ? `, ${confounded} confounded` : ''})\n\n`;
|
|
963
|
+
for (const l of live.sort((a, b) => b.times_confirmed - a.times_confirmed)) {
|
|
964
|
+
const where = l.scope.wallet ? `wallet ${l.scope.wallet}` : `workspace ${l.scope.workspace}`;
|
|
965
|
+
text += ` [${l.verdict}/${l.confidence}] ${l.lesson}\n`;
|
|
966
|
+
text += ` when: ${l.cue}\n`;
|
|
967
|
+
text += ` evidence: goal ${l.evidence.goalId}, ${l.evidence.roundsRefuted} refuted round(s), closed: ${l.evidence.closedGaps.join('; ') || '—'} · ${where} · ×${l.times_confirmed}\n`;
|
|
968
|
+
}
|
|
969
|
+
ctx.onEvent({ kind: 'text_delta', text: text + '\n' });
|
|
970
|
+
}
|
|
953
971
|
let learnings = loadLearnings();
|
|
954
972
|
if (learnings.length === 0) {
|
|
955
973
|
ctx.onEvent({ kind: 'text_delta', text: 'No learnings yet. Franklin learns your preferences over time.\n' });
|
package/dist/agent/context.d.ts
CHANGED
|
@@ -14,3 +14,8 @@ export declare function assembleInstructions(workingDir: string, model?: string)
|
|
|
14
14
|
export declare function getModelGuidance(model: string): string;
|
|
15
15
|
/** Invalidate cache for a workingDir (call after /clear or session reset). */
|
|
16
16
|
export declare function invalidateInstructionCache(workingDir?: string): void;
|
|
17
|
+
export declare function readRuntimeWallet(): {
|
|
18
|
+
chain?: string;
|
|
19
|
+
base?: string;
|
|
20
|
+
solana?: string;
|
|
21
|
+
};
|
package/dist/agent/context.js
CHANGED
|
@@ -10,6 +10,8 @@ import { getWalletAddress as getBaseWalletAddress } from '@blockrun/llm';
|
|
|
10
10
|
import { Keypair } from '@solana/web3.js';
|
|
11
11
|
import bs58 from 'bs58';
|
|
12
12
|
import { loadLearnings, decayLearnings, saveLearnings, formatForPrompt } from '../learnings/store.js';
|
|
13
|
+
import { renderExperienceSection, experienceScope } from '../learnings/experience.js';
|
|
14
|
+
import { scanForInjection } from './injection-scan.js';
|
|
13
15
|
import { isKeyMode, resolvePayMode } from '../payments/auth-mode.js';
|
|
14
16
|
import { sanitizeSubprocessEnv } from '../tools/subprocess-env.js';
|
|
15
17
|
// ─── System Instructions Assembly ──────────────────────────────────────────
|
|
@@ -562,6 +564,29 @@ export function assembleInstructions(workingDir, model) {
|
|
|
562
564
|
}
|
|
563
565
|
}
|
|
564
566
|
catch { /* learnings are optional — never block startup */ }
|
|
567
|
+
// Outcome-verified lessons (src/learnings/experience.ts): written only when
|
|
568
|
+
// a /goal was refuted and then verified, scoped to this wallet or workspace.
|
|
569
|
+
// Rendered after the learnings block and inside the same personal-context
|
|
570
|
+
// budget until the always-on cap lands. FRANKLIN_NO_EXPERIENCE=1 removes
|
|
571
|
+
// the section (ADR-0003).
|
|
572
|
+
try {
|
|
573
|
+
const walletInfo = readRuntimeWallet();
|
|
574
|
+
const scopes = [
|
|
575
|
+
experienceScope(workingDir, walletInfo, 'general'),
|
|
576
|
+
experienceScope(workingDir, walletInfo, 'trading'),
|
|
577
|
+
];
|
|
578
|
+
const seen = new Set();
|
|
579
|
+
for (const scope of scopes) {
|
|
580
|
+
const key = scope.wallet ? `w:${scope.wallet}` : `d:${scope.workspace}`;
|
|
581
|
+
if (seen.has(key))
|
|
582
|
+
continue;
|
|
583
|
+
seen.add(key);
|
|
584
|
+
const section = renderExperienceSection(scope);
|
|
585
|
+
if (section)
|
|
586
|
+
parts.push(section);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
catch { /* experience is optional — never block startup */ }
|
|
565
590
|
// Procedural skills (bundled + learned + user + project) used to be
|
|
566
591
|
// injected here at session boot. They now flow through the unified
|
|
567
592
|
// src/skills/ Registry and are matched per-turn against the user's
|
|
@@ -647,52 +672,6 @@ export function invalidateInstructionCache(workingDir) {
|
|
|
647
672
|
_instructionCache.clear();
|
|
648
673
|
}
|
|
649
674
|
}
|
|
650
|
-
// ─── Prompt Injection Detection ────────────────────────────────────────────
|
|
651
|
-
/** Patterns that indicate potential prompt injection in context files. */
|
|
652
|
-
const INJECTION_PATTERNS = [
|
|
653
|
-
// Direct instruction override attempts
|
|
654
|
-
{ pattern: /ignore\s+(all\s+)?previous\s+instructions/i, description: 'instruction override' },
|
|
655
|
-
{ pattern: /disregard\s+(all\s+)?(previous\s+|above\s+)?rules/i, description: 'rule disregard' },
|
|
656
|
-
{ pattern: /forget\s+(everything|all|your)\s+(you|instructions|rules)/i, description: 'memory wipe' },
|
|
657
|
-
{ pattern: /you\s+are\s+now\s+(?:a\s+)?(?:different|new|unrestricted)/i, description: 'identity hijack' },
|
|
658
|
-
{ pattern: /system\s*:\s*you\s+are/i, description: 'fake system message' },
|
|
659
|
-
// Dangerous command injection
|
|
660
|
-
{ pattern: /execute\s+(curl|wget|bash|sh|python|node)\b/i, description: 'command execution' },
|
|
661
|
-
{ pattern: /\bcat\s+\/etc\/(passwd|shadow|sudoers)/i, description: 'credential access' },
|
|
662
|
-
{ pattern: /\brm\s+-rf\s+[\/~]/i, description: 'destructive command' },
|
|
663
|
-
{ pattern: /\beval\s*\(/i, description: 'eval injection' },
|
|
664
|
-
// Data exfiltration
|
|
665
|
-
{ pattern: /\bcurl\s+.*\|\s*(bash|sh)/i, description: 'pipe to shell' },
|
|
666
|
-
{ pattern: /send\s+(to|via)\s+(http|webhook|url)/i, description: 'data exfiltration' },
|
|
667
|
-
// HTML/comment injection
|
|
668
|
-
{ pattern: /<!--[\s\S]*?-->/g, description: 'HTML comment injection' },
|
|
669
|
-
];
|
|
670
|
-
/** Invisible unicode characters that can hide malicious content. */
|
|
671
|
-
const INVISIBLE_UNICODE = /[\u200B-\u200F\u202A-\u202E\u2060-\u2064\uFEFF\u00AD]/g;
|
|
672
|
-
/**
|
|
673
|
-
* Scan text for prompt injection patterns and invisible unicode.
|
|
674
|
-
* Returns sanitized text with threats neutralized and a list of detections.
|
|
675
|
-
*/
|
|
676
|
-
function scanForInjection(text) {
|
|
677
|
-
const threats = [];
|
|
678
|
-
let sanitized = text;
|
|
679
|
-
// Check for invisible unicode
|
|
680
|
-
if (INVISIBLE_UNICODE.test(sanitized)) {
|
|
681
|
-
const count = (sanitized.match(INVISIBLE_UNICODE) || []).length;
|
|
682
|
-
threats.push(`${count} invisible unicode character(s) removed`);
|
|
683
|
-
sanitized = sanitized.replace(INVISIBLE_UNICODE, '');
|
|
684
|
-
}
|
|
685
|
-
// Check for injection patterns
|
|
686
|
-
for (const { pattern, description } of INJECTION_PATTERNS) {
|
|
687
|
-
const matches = sanitized.match(pattern);
|
|
688
|
-
if (matches) {
|
|
689
|
-
threats.push(`${description}: "${matches[0].slice(0, 50)}"`);
|
|
690
|
-
// Neutralize by wrapping in brackets (visible but defanged)
|
|
691
|
-
sanitized = sanitized.replace(pattern, (match) => `[BLOCKED: ${match}]`);
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
return { sanitized, threats };
|
|
695
|
-
}
|
|
696
675
|
// ─── Project Config ────────────────────────────────────────────────────────
|
|
697
676
|
/**
|
|
698
677
|
* Look for RUNCODE.md, then CLAUDE.md in the working directory and parents.
|
|
@@ -760,7 +739,7 @@ function buildEnvironmentSection(workingDir) {
|
|
|
760
739
|
}
|
|
761
740
|
return lines.join('\n');
|
|
762
741
|
}
|
|
763
|
-
function readRuntimeWallet() {
|
|
742
|
+
export function readRuntimeWallet() {
|
|
764
743
|
const home = process.env.HOME || '';
|
|
765
744
|
if (!home)
|
|
766
745
|
return {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt-injection scanning for text that enters the system prompt from
|
|
3
|
+
* outside Franklin's own code: project config files, and lessons written
|
|
4
|
+
* back by the goal-outcome reflector. Shared so every such path applies the
|
|
5
|
+
* same patterns.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Scan text for prompt injection patterns and invisible unicode.
|
|
9
|
+
* Returns sanitized text with threats neutralized and a list of detections.
|
|
10
|
+
*/
|
|
11
|
+
export declare function scanForInjection(text: string): {
|
|
12
|
+
sanitized: string;
|
|
13
|
+
threats: string[];
|
|
14
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt-injection scanning for text that enters the system prompt from
|
|
3
|
+
* outside Franklin's own code: project config files, and lessons written
|
|
4
|
+
* back by the goal-outcome reflector. Shared so every such path applies the
|
|
5
|
+
* same patterns.
|
|
6
|
+
*/
|
|
7
|
+
// ─── Prompt Injection Detection ────────────────────────────────────────────
|
|
8
|
+
/** Patterns that indicate potential prompt injection in context files. */
|
|
9
|
+
const INJECTION_PATTERNS = [
|
|
10
|
+
// Direct instruction override attempts
|
|
11
|
+
{ pattern: /ignore\s+(all\s+)?previous\s+instructions/i, description: 'instruction override' },
|
|
12
|
+
{ pattern: /disregard\s+(all\s+)?(previous\s+|above\s+)?rules/i, description: 'rule disregard' },
|
|
13
|
+
{ pattern: /forget\s+(everything|all|your)\s+(you|instructions|rules)/i, description: 'memory wipe' },
|
|
14
|
+
{ pattern: /you\s+are\s+now\s+(?:a\s+)?(?:different|new|unrestricted)/i, description: 'identity hijack' },
|
|
15
|
+
{ pattern: /system\s*:\s*you\s+are/i, description: 'fake system message' },
|
|
16
|
+
// Dangerous command injection
|
|
17
|
+
{ pattern: /execute\s+(curl|wget|bash|sh|python|node)\b/i, description: 'command execution' },
|
|
18
|
+
{ pattern: /\bcat\s+\/etc\/(passwd|shadow|sudoers)/i, description: 'credential access' },
|
|
19
|
+
{ pattern: /\brm\s+-rf\s+[\/~]/i, description: 'destructive command' },
|
|
20
|
+
{ pattern: /\beval\s*\(/i, description: 'eval injection' },
|
|
21
|
+
// Data exfiltration
|
|
22
|
+
{ pattern: /\bcurl\s+.*\|\s*(bash|sh)/i, description: 'pipe to shell' },
|
|
23
|
+
{ pattern: /send\s+(to|via)\s+(http|webhook|url)/i, description: 'data exfiltration' },
|
|
24
|
+
// HTML/comment injection
|
|
25
|
+
{ pattern: /<!--[\s\S]*?-->/g, description: 'HTML comment injection' },
|
|
26
|
+
];
|
|
27
|
+
/** Invisible unicode characters that can hide malicious content. */
|
|
28
|
+
const INVISIBLE_UNICODE = /[\u200B-\u200F\u202A-\u202E\u2060-\u2064\uFEFF\u00AD]/g;
|
|
29
|
+
/**
|
|
30
|
+
* Scan text for prompt injection patterns and invisible unicode.
|
|
31
|
+
* Returns sanitized text with threats neutralized and a list of detections.
|
|
32
|
+
*/
|
|
33
|
+
export function scanForInjection(text) {
|
|
34
|
+
const threats = [];
|
|
35
|
+
let sanitized = text;
|
|
36
|
+
// Check for invisible unicode
|
|
37
|
+
if (INVISIBLE_UNICODE.test(sanitized)) {
|
|
38
|
+
const count = (sanitized.match(INVISIBLE_UNICODE) || []).length;
|
|
39
|
+
threats.push(`${count} invisible unicode character(s) removed`);
|
|
40
|
+
sanitized = sanitized.replace(INVISIBLE_UNICODE, '');
|
|
41
|
+
}
|
|
42
|
+
// Check for injection patterns
|
|
43
|
+
for (const { pattern, description } of INJECTION_PATTERNS) {
|
|
44
|
+
const matches = sanitized.match(pattern);
|
|
45
|
+
if (matches) {
|
|
46
|
+
threats.push(`${description}: "${matches[0].slice(0, 50)}"`);
|
|
47
|
+
// Neutralize by wrapping in brackets (visible but defanged)
|
|
48
|
+
sanitized = sanitized.replace(pattern, (match) => `[BLOCKED: ${match}]`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return { sanitized, threats };
|
|
52
|
+
}
|
package/dist/agent/loop.js
CHANGED
|
@@ -636,6 +636,7 @@ async function runInteractiveSession(config, getUserInput, onEvent, onAbortReady
|
|
|
636
636
|
client,
|
|
637
637
|
getModel: () => config.model,
|
|
638
638
|
capabilities: config.capabilities,
|
|
639
|
+
getHistory: () => history,
|
|
639
640
|
});
|
|
640
641
|
if (config.resumeSessionId) {
|
|
641
642
|
const resumedMeta = loadSessionMeta(config.resumeSessionId);
|
|
@@ -860,6 +861,13 @@ async function runInteractiveSession(config, getUserInput, onEvent, onAbortReady
|
|
|
860
861
|
const matches = matchSkillTriggers(input, skillRegistry.list());
|
|
861
862
|
if (matches.length > 0) {
|
|
862
863
|
turnSkillHints = formatSkillHints(matches);
|
|
864
|
+
// Remember which skills were in play for the active goal, so the
|
|
865
|
+
// goal-outcome reflector can tie a lesson to them later.
|
|
866
|
+
const hintedGoal = getActiveGoal();
|
|
867
|
+
if (hintedGoal && hintedGoal.status === 'active') {
|
|
868
|
+
const names = matches.map(m => m.skill.skill.name);
|
|
869
|
+
updateActiveGoal({ skillsHinted: [...new Set([...(hintedGoal.skillsHinted ?? []), ...names])].slice(0, 20) });
|
|
870
|
+
}
|
|
863
871
|
if (config.debug && matches.length > 0) {
|
|
864
872
|
const summary = matches.map(m => `${m.skill.skill.name}(${m.score.toFixed(1)})`).join(', ');
|
|
865
873
|
onEvent({ kind: 'text_delta', text: `*[skill triggers] ${summary}*\n` });
|
package/dist/agent/optimize.js
CHANGED
|
@@ -71,6 +71,7 @@ const MODEL_MAX_OUTPUT = {
|
|
|
71
71
|
'deepseek/deepseek-chat': 65_536,
|
|
72
72
|
'deepseek/deepseek-reasoner': 65_536,
|
|
73
73
|
'deepseek/deepseek-v4-pro': 65_536,
|
|
74
|
+
'deepseek/deepseek-v4.1-flash': 65_536,
|
|
74
75
|
// Kimi K3 (flagship, 2026-07) supports 65K output per the BlockRun gateway
|
|
75
76
|
// model entry (max_output: 65536). Without this entry the default 16K cap
|
|
76
77
|
// left users with 4× headroom on the table for long-form coding outputs
|
package/dist/agent/tokens.js
CHANGED
|
@@ -264,6 +264,7 @@ const MODEL_CONTEXT_WINDOWS = {
|
|
|
264
264
|
'deepseek/deepseek-chat': 1_000_000,
|
|
265
265
|
'deepseek/deepseek-reasoner': 1_000_000,
|
|
266
266
|
'deepseek/deepseek-v4-pro': 1_000_000,
|
|
267
|
+
'deepseek/deepseek-v4.1-flash': 1_000_000,
|
|
267
268
|
// xAI. grok-4.5 / 4.3 / build were missing until 2026-08-20: neither matches
|
|
268
269
|
// any inference pattern below, so a cold catalog cache fell through to the
|
|
269
270
|
// blind 128k default and compacted a 500K–1M window ~4-8x too early.
|
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
export const FREE_DEFAULT_MODEL = 'nvidia/nemotron-3-nano-omni-30b-a3b-reasoning';
|
|
25
25
|
/** Free models in preference order, best first. See free-models.ts. */
|
|
26
26
|
export const FREE_PREFERENCE_ORDER = [
|
|
27
|
-
|
|
27
|
+
// nvidia/nemotron-3-nano-30b led this list until the gateway delisted it on
|
|
28
|
+
// 2026-09-08 (NVIDIA deprovisioned it). It is gone from /api/v1/models, so
|
|
29
|
+
// the chain-safe default leads again.
|
|
28
30
|
FREE_DEFAULT_MODEL, // the floor this never drops below
|
|
29
31
|
'poolside/laguna-xs-2.1', // different provider
|
|
30
32
|
'cohere/north-mini-code', // different provider; needs max_tokens >= 1200
|
package/dist/free-models.d.ts
CHANGED
|
@@ -103,7 +103,15 @@ export { FREE_DEFAULT_MODEL, FREE_POOL_CONTEXT_FLOOR, FREE_PREFERENCE_ORDER };
|
|
|
103
103
|
* chain alive through an NVIDIA-wide outage instead of it being four names
|
|
104
104
|
* for one upstream.
|
|
105
105
|
*
|
|
106
|
+
* 2026-10-20: nemotron-3-nano-30b, the Base leader in the table above, was
|
|
107
|
+
* delisted on 2026-09-08 and has left this list (see LEGACY_FREE_MODEL_IDS).
|
|
108
|
+
* The measurements stay as the record of why it led.
|
|
109
|
+
*
|
|
106
110
|
* Not listed, and why:
|
|
111
|
+
* - nvidia/muse-glimmer-30b — joined the free pool 2026-10-02 and has not
|
|
112
|
+
* been measured on /v1/messages, the bar every rung above had to clear.
|
|
113
|
+
* A reasoning model that spends a small max_tokens budget entirely on
|
|
114
|
+
* reasoning (gateway probe). Reachable by explicit pin until measured.
|
|
107
115
|
* - nvidia/nemotron-3.5-lightning — LATENCY, and only latency. Measured
|
|
108
116
|
* 10.9s / 12.2s / 22.5s for a one-sentence answer at max_tokens 800,
|
|
109
117
|
* against ~0.8-3s for the rest of the pool. Its name is a lie. (An
|
|
@@ -178,16 +186,18 @@ export { FREE_DEFAULT_MODEL, FREE_POOL_CONTEXT_FLOOR, FREE_PREFERENCE_ORDER };
|
|
|
178
186
|
*/
|
|
179
187
|
export declare const QUARANTINED_FREE_MODELS: readonly string[];
|
|
180
188
|
/**
|
|
181
|
-
* Free ids Franklin used to name.
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
189
|
+
* Free ids Franklin used to name. All are gone from /api/v1/models; the
|
|
190
|
+
* gateway answers for most of them by substitution. Kept DELIBERATELY: this
|
|
191
|
+
* list is what lets isFreeModelId() report an old session's model as $0 and
|
|
192
|
+
* keep a stale pin on the free side of every paid-approval gate. It is never
|
|
193
|
+
* routed to — FREE_PREFERENCE_ORDER is the routing list.
|
|
185
194
|
*/
|
|
186
195
|
export declare const LEGACY_FREE_MODEL_IDS: readonly string[];
|
|
187
196
|
/**
|
|
188
|
-
* Every free id in the live
|
|
189
|
-
*
|
|
190
|
-
*
|
|
197
|
+
* Every free id (billing_mode "free") in the live catalog as of 2026-10-20 —
|
|
198
|
+
* identical on Base and Solana — mapped to its catalogued context window.
|
|
199
|
+
* Used for metadata display and as the cold-cache answer to isFreeModelId();
|
|
200
|
+
* NOT for sizing a request — use FREE_POOL_CONTEXT_FLOOR for that.
|
|
191
201
|
*/
|
|
192
202
|
export declare const FREE_MODEL_CONTEXT_WINDOWS: Readonly<Record<string, number>>;
|
|
193
203
|
/**
|
package/dist/free-models.js
CHANGED
|
@@ -109,7 +109,15 @@ export { FREE_DEFAULT_MODEL, FREE_POOL_CONTEXT_FLOOR, FREE_PREFERENCE_ORDER };
|
|
|
109
109
|
* chain alive through an NVIDIA-wide outage instead of it being four names
|
|
110
110
|
* for one upstream.
|
|
111
111
|
*
|
|
112
|
+
* 2026-10-20: nemotron-3-nano-30b, the Base leader in the table above, was
|
|
113
|
+
* delisted on 2026-09-08 and has left this list (see LEGACY_FREE_MODEL_IDS).
|
|
114
|
+
* The measurements stay as the record of why it led.
|
|
115
|
+
*
|
|
112
116
|
* Not listed, and why:
|
|
117
|
+
* - nvidia/muse-glimmer-30b — joined the free pool 2026-10-02 and has not
|
|
118
|
+
* been measured on /v1/messages, the bar every rung above had to clear.
|
|
119
|
+
* A reasoning model that spends a small max_tokens budget entirely on
|
|
120
|
+
* reasoning (gateway probe). Reachable by explicit pin until measured.
|
|
113
121
|
* - nvidia/nemotron-3.5-lightning — LATENCY, and only latency. Measured
|
|
114
122
|
* 10.9s / 12.2s / 22.5s for a one-sentence answer at max_tokens 800,
|
|
115
123
|
* against ~0.8-3s for the rest of the pool. Its name is a lie. (An
|
|
@@ -202,12 +210,16 @@ export const QUARANTINED_FREE_MODELS = [
|
|
|
202
210
|
// it is a cascade rung other BlockRun components depend on.
|
|
203
211
|
];
|
|
204
212
|
/**
|
|
205
|
-
* Free ids Franklin used to name.
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
213
|
+
* Free ids Franklin used to name. All are gone from /api/v1/models; the
|
|
214
|
+
* gateway answers for most of them by substitution. Kept DELIBERATELY: this
|
|
215
|
+
* list is what lets isFreeModelId() report an old session's model as $0 and
|
|
216
|
+
* keep a stale pin on the free side of every paid-approval gate. It is never
|
|
217
|
+
* routed to — FREE_PREFERENCE_ORDER is the routing list.
|
|
209
218
|
*/
|
|
210
219
|
export const LEGACY_FREE_MODEL_IDS = [
|
|
220
|
+
// Delisted 2026-09-08 (NVIDIA deprovisioned it; gateway marks it
|
|
221
|
+
// unavailable and redirects to nano-omni). Led the free chain until then.
|
|
222
|
+
'nvidia/nemotron-3-nano-30b',
|
|
211
223
|
'nvidia/nemotron-nano-9b-v2',
|
|
212
224
|
'nvidia/mistral-nemotron',
|
|
213
225
|
'nvidia/nemotron-nano-12b-v2-vl',
|
|
@@ -216,17 +228,18 @@ export const LEGACY_FREE_MODEL_IDS = [
|
|
|
216
228
|
'nvidia/nemotron-3-super-120b-a12b-free',
|
|
217
229
|
];
|
|
218
230
|
/**
|
|
219
|
-
* Every free id in the live
|
|
220
|
-
*
|
|
221
|
-
*
|
|
231
|
+
* Every free id (billing_mode "free") in the live catalog as of 2026-10-20 —
|
|
232
|
+
* identical on Base and Solana — mapped to its catalogued context window.
|
|
233
|
+
* Used for metadata display and as the cold-cache answer to isFreeModelId();
|
|
234
|
+
* NOT for sizing a request — use FREE_POOL_CONTEXT_FLOOR for that.
|
|
222
235
|
*/
|
|
223
236
|
export const FREE_MODEL_CONTEXT_WINDOWS = {
|
|
224
237
|
'nvidia/nemotron-3-ultra-550b': 1_000_000,
|
|
225
238
|
'nvidia/nemotron-3.5-lightning': 1_000_000,
|
|
226
239
|
'nvidia/nemotron-3-nano-omni-30b-a3b-reasoning': 256_000,
|
|
227
240
|
'cohere/north-mini-code': 256_000,
|
|
228
|
-
'nvidia/nemotron-3-nano-30b': 131_072,
|
|
229
241
|
'poolside/laguna-xs-2.1': 131_072,
|
|
242
|
+
'nvidia/muse-glimmer-30b': 131_072,
|
|
230
243
|
'nvidia/llama-3.2-11b-vision': 128_000,
|
|
231
244
|
};
|
|
232
245
|
/**
|
package/dist/goal/runtime.d.ts
CHANGED
|
@@ -5,12 +5,15 @@
|
|
|
5
5
|
* panel. The loop installs the dependencies at session start.
|
|
6
6
|
*/
|
|
7
7
|
import type { ModelClient } from '../agent/llm.js';
|
|
8
|
-
import type { CapabilityHandler, CapabilityResult, ExecutionScope } from '../agent/types.js';
|
|
8
|
+
import type { CapabilityHandler, CapabilityResult, Dialogue, ExecutionScope } from '../agent/types.js';
|
|
9
9
|
export interface GoalEngineDeps {
|
|
10
10
|
client: ModelClient;
|
|
11
11
|
getModel: () => string;
|
|
12
12
|
capabilities: CapabilityHandler[];
|
|
13
|
+
/** The session transcript, read by the goal-outcome reflector as evidence. */
|
|
14
|
+
getHistory?: () => Dialogue[];
|
|
13
15
|
}
|
|
16
|
+
export declare function awaitGoalReflection(): Promise<void>;
|
|
14
17
|
export declare function setGoalEngineDeps(d: GoalEngineDeps | null): void;
|
|
15
18
|
export interface GoalClaimInput {
|
|
16
19
|
completed?: boolean;
|
package/dist/goal/runtime.js
CHANGED
|
@@ -4,9 +4,28 @@
|
|
|
4
4
|
* capability set, and processes completion claims through the verifier
|
|
5
5
|
* panel. The loop installs the dependencies at session start.
|
|
6
6
|
*/
|
|
7
|
+
import { readRuntimeWallet } from '../agent/context.js';
|
|
8
|
+
import { experienceEnabled, experienceScope, markRenderedLessonsRefuted, recordConfoundedGoal, reflectGoalExperience, } from '../learnings/experience.js';
|
|
7
9
|
import { getActiveGoal, loadPlan, saveVerdicts, updateActiveGoal, } from './store.js';
|
|
8
10
|
import { needsStrategist, runStrategist, runSummarizer, runVerifierPanel, } from './engine.js';
|
|
9
11
|
import { goalMaxRounds } from './types.js';
|
|
12
|
+
// The reflector runs after a verified claim without blocking the reply.
|
|
13
|
+
// Tests (and shutdown) await it here.
|
|
14
|
+
let pendingReflection = Promise.resolve();
|
|
15
|
+
export function awaitGoalReflection() {
|
|
16
|
+
return pendingReflection.then(() => undefined, () => undefined);
|
|
17
|
+
}
|
|
18
|
+
function scopeFor(goal, scope) {
|
|
19
|
+
return experienceScope(scope.workingDir, safeWallet(), goal.kind);
|
|
20
|
+
}
|
|
21
|
+
function safeWallet() {
|
|
22
|
+
try {
|
|
23
|
+
return readRuntimeWallet();
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
10
29
|
let deps = null;
|
|
11
30
|
export function setGoalEngineDeps(d) {
|
|
12
31
|
deps = d;
|
|
@@ -51,6 +70,10 @@ export async function processGoalClaim(input, scope) {
|
|
|
51
70
|
status: 'blocked',
|
|
52
71
|
blockedReason: `verification round cap (${goalMaxRounds()}) reached`,
|
|
53
72
|
});
|
|
73
|
+
try {
|
|
74
|
+
recordConfoundedGoal(goal, scopeFor(goal, scope));
|
|
75
|
+
}
|
|
76
|
+
catch { /* best-effort */ }
|
|
54
77
|
return {
|
|
55
78
|
output: `Verification round cap reached (${goalMaxRounds()} rounds). The goal is now blocked — ` +
|
|
56
79
|
'summarize for the user what passed, what kept failing, and ask how they want to proceed.',
|
|
@@ -69,6 +92,19 @@ export async function processGoalClaim(input, scope) {
|
|
|
69
92
|
}
|
|
70
93
|
catch { /* summary is best-effort */ }
|
|
71
94
|
updateActiveGoal({ status: 'completed', rounds, verifierGaps: [], summary });
|
|
95
|
+
// Harnessing-level recursion: a refuted→verified contrast is evidence; a
|
|
96
|
+
// round-1 pass is adoption alone and teaches nothing durable.
|
|
97
|
+
if (experienceEnabled() && (rounds.length >= 2 || goal.strategistNote)) {
|
|
98
|
+
const verified = { ...goal, rounds, status: 'completed', summary };
|
|
99
|
+
pendingReflection = reflectGoalExperience({
|
|
100
|
+
goal: verified,
|
|
101
|
+
planMd,
|
|
102
|
+
history: deps?.getHistory?.() ?? [],
|
|
103
|
+
scope: scopeFor(goal, scope),
|
|
104
|
+
sessionId: scope.sessionId ?? '',
|
|
105
|
+
client: ctx.client,
|
|
106
|
+
}).catch(() => null);
|
|
107
|
+
}
|
|
72
108
|
return {
|
|
73
109
|
output: `GOAL VERIFIED COMPLETE (round ${round}, ${outcome.verdicts.length}-reviewer panel).\n\n` +
|
|
74
110
|
`${summary || 'Deliverable verified against every acceptance criterion.'}\n\n` +
|
|
@@ -90,6 +126,12 @@ export async function processGoalClaim(input, scope) {
|
|
|
90
126
|
};
|
|
91
127
|
}
|
|
92
128
|
const updated = updateActiveGoal({ status: 'active', rounds, verifierGaps: outcome.gaps });
|
|
129
|
+
if (round === 1) {
|
|
130
|
+
try {
|
|
131
|
+
markRenderedLessonsRefuted(scopeFor(goal, scope), goal.id);
|
|
132
|
+
}
|
|
133
|
+
catch { /* best-effort */ }
|
|
134
|
+
}
|
|
93
135
|
let strategistLine = '';
|
|
94
136
|
if (updated && needsStrategist(updated)) {
|
|
95
137
|
try {
|
package/dist/goal/types.d.ts
CHANGED
|
@@ -42,6 +42,10 @@ export interface GoalState {
|
|
|
42
42
|
blockedReason?: string;
|
|
43
43
|
/** Closing user-facing summary, once completed. */
|
|
44
44
|
summary?: string;
|
|
45
|
+
/** Skills whose trigger hints fired on turns while this goal was active.
|
|
46
|
+
* Carried into the experience record so a lesson can later be scored
|
|
47
|
+
* against the skills that were in play. */
|
|
48
|
+
skillsHinted?: string[];
|
|
45
49
|
}
|
|
46
50
|
export interface VerifierVerdict {
|
|
47
51
|
refuted: boolean;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Goal-outcome experience library — the harnessing-level recursion from
|
|
3
|
+
* Harness² (google-research/harness2), scaled to one agent with a wallet.
|
|
4
|
+
*
|
|
5
|
+
* Model gap this component patches (ADR-0003): a single verified run is not
|
|
6
|
+
* evidence that anything in the harness worked. The verifier panel refuting a
|
|
7
|
+
* goal and then verifying it on a later round IS evidence — a behavioral
|
|
8
|
+
* contrast between two attempts at the same objective, same model, same
|
|
9
|
+
* tools. This module turns that contrast into at most one lesson per goal,
|
|
10
|
+
* keyed to the wallet (trading) or workspace (everything else), rendered
|
|
11
|
+
* into the system prompt, and retired when later goals in the same scope
|
|
12
|
+
* refute while it was in play.
|
|
13
|
+
*
|
|
14
|
+
* Safety: the reflector reads transcripts as DATA. Lessons are prose only —
|
|
15
|
+
* never hooks, skills or scripts. FRANKLIN_NO_EXPERIENCE=1 disables writes
|
|
16
|
+
* and rendering.
|
|
17
|
+
*/
|
|
18
|
+
import type { ModelClient } from '../agent/llm.js';
|
|
19
|
+
import type { Dialogue } from '../agent/types.js';
|
|
20
|
+
import type { GoalKind, GoalState } from '../goal/types.js';
|
|
21
|
+
import type { Experience, ExperienceConfidence, ExperienceScope } from './types.js';
|
|
22
|
+
export declare function experienceEnabled(): boolean;
|
|
23
|
+
export declare function loadExperiences(): Experience[];
|
|
24
|
+
export declare function saveExperiences(list: Experience[]): void;
|
|
25
|
+
export declare function sameScope(a: ExperienceScope, b: ExperienceScope): boolean;
|
|
26
|
+
/** Confirm a similar lesson (same scope + component) or insert; cap per scope. */
|
|
27
|
+
export declare function mergeExperience(existing: Experience[], entry: Experience): Experience[];
|
|
28
|
+
/** Idle lessons lose one confirmation per decay pass; three confirmations are immune. */
|
|
29
|
+
export declare function decayExperiences(list: Experience[]): Experience[];
|
|
30
|
+
export interface RuntimeWalletInfo {
|
|
31
|
+
chain?: string;
|
|
32
|
+
base?: string;
|
|
33
|
+
solana?: string;
|
|
34
|
+
}
|
|
35
|
+
/** Trading goals key on the wallet; anything else on the workspace. Never global. */
|
|
36
|
+
export declare function experienceScope(workingDir: string, wallet: RuntimeWalletInfo, kind: GoalKind): ExperienceScope;
|
|
37
|
+
/** Pure: render this scope's lessons under a character budget. */
|
|
38
|
+
export declare function formatExperienceForPrompt(list: Experience[], scope: ExperienceScope, maxChars?: number): string;
|
|
39
|
+
/** Load, decay, render and stamp this scope's lessons for a system prompt. */
|
|
40
|
+
export declare function renderExperienceSection(scope: ExperienceScope, maxChars?: number): string;
|
|
41
|
+
/**
|
|
42
|
+
* A goal in this scope was refuted on its first round while lessons were in
|
|
43
|
+
* the prompt: each rendered `helped` lesson loses a confirmation; two such
|
|
44
|
+
* events flip it to `hurt` (rendered as a ⛔ rule, so the next run avoids it).
|
|
45
|
+
*/
|
|
46
|
+
export declare function markRenderedLessonsRefuted(scope: ExperienceScope, goalId: string): void;
|
|
47
|
+
export interface ParsedExperience {
|
|
48
|
+
cue: string;
|
|
49
|
+
lesson: string;
|
|
50
|
+
component: string;
|
|
51
|
+
evidence: string;
|
|
52
|
+
confidence: ExperienceConfidence;
|
|
53
|
+
}
|
|
54
|
+
export interface ParsedReply {
|
|
55
|
+
edits: string;
|
|
56
|
+
experience: ParsedExperience | null;
|
|
57
|
+
noEntry: boolean;
|
|
58
|
+
}
|
|
59
|
+
export declare function experiencePrompt(goal: GoalState, planMd: string, history: Dialogue[]): string;
|
|
60
|
+
export declare function parseExperienceReply(text: string): ParsedReply;
|
|
61
|
+
/** Why this parsed entry must not enter the library, or null when it may. */
|
|
62
|
+
export declare function rejectExperience(exp: ParsedExperience, objective: string): string | null;
|
|
63
|
+
export interface ReflectArgs {
|
|
64
|
+
goal: GoalState;
|
|
65
|
+
planMd: string;
|
|
66
|
+
history: Dialogue[];
|
|
67
|
+
scope: ExperienceScope;
|
|
68
|
+
sessionId: string;
|
|
69
|
+
client: ModelClient;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Run the reflector on a verified goal that was refuted at least once. Writes
|
|
73
|
+
* at most one lesson and returns it, or null when the record supports none.
|
|
74
|
+
*/
|
|
75
|
+
export declare function reflectGoalExperience(args: ReflectArgs): Promise<Experience | null>;
|
|
76
|
+
/**
|
|
77
|
+
* A goal that hit the verification round cap: record what kept failing as a
|
|
78
|
+
* confounded row (never rendered; read by /learnings and later scoring).
|
|
79
|
+
*/
|
|
80
|
+
export declare function recordConfoundedGoal(goal: GoalState, scope: ExperienceScope): Experience | null;
|