osborn 0.9.267 → 0.9.269
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/bridge-llm.d.ts +22 -0
- package/dist/bridge-llm.js +39 -0
- package/dist/claude-auth.js +33 -4
- package/dist/claude-llm.js +22 -0
- package/dist/codex-handler.d.ts +38 -0
- package/dist/codex-handler.js +83 -0
- package/dist/codex-llm.d.ts +40 -0
- package/dist/codex-llm.js +144 -0
- package/dist/fast-brain.d.ts +176 -0
- package/dist/fast-brain.js +1887 -0
- package/dist/index-3-2-26-legacy.d.ts +1 -0
- package/dist/index-3-2-26-legacy.js +2233 -0
- package/dist/leagcyprompts2.d.ts +0 -0
- package/dist/leagcyprompts2.js +573 -0
- package/dist/pipeline-fastbrain.js +69 -6
- package/dist/prompts-2-25-26.d.ts +0 -0
- package/dist/prompts-2-25-26.js +518 -0
- package/dist/prompts-3-2-26.d.ts +78 -0
- package/dist/prompts-3-2-26.js +1319 -0
- package/dist/summary-index.d.ts +90 -0
- package/dist/summary-index.js +585 -0
- package/package.json +1 -1
|
@@ -32,6 +32,27 @@ const OPENROUTER_URL = FIREWORKS
|
|
|
32
32
|
: 'https://openrouter.ai/api/v1/chat/completions';
|
|
33
33
|
const TIMEOUT_MS = 20_000;
|
|
34
34
|
const MAX_TOOL_ROUNDS = 4;
|
|
35
|
+
/**
|
|
36
|
+
* Per-call provider resolution for the HOUSE DEMO PASS. When the user has no
|
|
37
|
+
* Claude auth, applyAuthFallback() sets OSBORN_DEMO_PASS='zai' - the whole
|
|
38
|
+
* model layer (main agent AND this fast brain) then rides the shared z.ai GLM
|
|
39
|
+
* subscription instead of pay-per-use Fireworks/OpenRouter. Checked per call
|
|
40
|
+
* (not module-load) because applyAuthFallback runs after this module loads, and
|
|
41
|
+
* because a mid-session real-Claude login clears the flag via clearAuthFallback.
|
|
42
|
+
* Returns null on the normal (user pays their own providers) path.
|
|
43
|
+
*/
|
|
44
|
+
function resolveFastBrainProvider() {
|
|
45
|
+
if (process.env.OSBORN_DEMO_PASS !== 'zai')
|
|
46
|
+
return null;
|
|
47
|
+
const zaiKey = process.env.Z_AI_PERSONAL_API_KEY || process.env.ZAI_API_KEY;
|
|
48
|
+
if (!zaiKey)
|
|
49
|
+
return null;
|
|
50
|
+
return {
|
|
51
|
+
url: 'https://api.z.ai/api/paas/v4/chat/completions',
|
|
52
|
+
model: process.env.OSBORN_DEMO_FAST_MODEL || 'glm-4.5-air', // fast/cheap tier of the pass
|
|
53
|
+
name: 'z.ai (demo pass)',
|
|
54
|
+
};
|
|
55
|
+
}
|
|
35
56
|
// ============================================================
|
|
36
57
|
// PERSISTENT STATE (OpenAI message format)
|
|
37
58
|
// ============================================================
|
|
@@ -272,6 +293,9 @@ function buildSystemPrompt(chatHistory, researchContext) {
|
|
|
272
293
|
``,
|
|
273
294
|
`== STYLE ==`,
|
|
274
295
|
`1-3 sentences. Grounded in results. Never fabricate.`,
|
|
296
|
+
`Answer in plain prose ONLY. NEVER include result header lines (the`,
|
|
297
|
+
`"[source L… · msgType · matchedBy] timestamp" brackets), line numbers, or raw`,
|
|
298
|
+
`timestamps in your reply — those are internal provenance the user must never see.`,
|
|
275
299
|
`If not found after thorough searching: "I didn't find that in the session history."`,
|
|
276
300
|
``,
|
|
277
301
|
`== AUDIENCE ==`,
|
|
@@ -311,7 +335,12 @@ function buildSystemPrompt(chatHistory, researchContext) {
|
|
|
311
335
|
// OPENROUTER CALL
|
|
312
336
|
// ============================================================
|
|
313
337
|
async function callOpenRouter(messages, tools, apiKey) {
|
|
314
|
-
|
|
338
|
+
// Demo pass first — same OpenAI-compatible tool-loop contract, house z.ai key.
|
|
339
|
+
const demo = resolveFastBrainProvider();
|
|
340
|
+
const url = demo?.url || OPENROUTER_URL;
|
|
341
|
+
const model = demo?.model || OPENROUTER_MODEL;
|
|
342
|
+
const providerName = demo?.name || PROVIDER_NAME;
|
|
343
|
+
const resp = await fetch(url, {
|
|
315
344
|
method: 'POST',
|
|
316
345
|
headers: {
|
|
317
346
|
'Authorization': `Bearer ${apiKey}`,
|
|
@@ -319,7 +348,7 @@ async function callOpenRouter(messages, tools, apiKey) {
|
|
|
319
348
|
'X-OpenRouter-Title': 'Osborn Fast Brain',
|
|
320
349
|
},
|
|
321
350
|
body: JSON.stringify({
|
|
322
|
-
model
|
|
351
|
+
model,
|
|
323
352
|
messages,
|
|
324
353
|
tools,
|
|
325
354
|
tool_choice: 'auto',
|
|
@@ -328,18 +357,49 @@ async function callOpenRouter(messages, tools, apiKey) {
|
|
|
328
357
|
});
|
|
329
358
|
if (!resp.ok) {
|
|
330
359
|
const body = await resp.text().catch(() => '');
|
|
331
|
-
throw new Error(`${
|
|
360
|
+
throw new Error(`${providerName} ${resp.status}: ${body.substring(0, 200)}`);
|
|
332
361
|
}
|
|
333
362
|
return resp.json();
|
|
334
363
|
}
|
|
335
364
|
// ============================================================
|
|
336
365
|
// MAIN FUNCTION
|
|
337
366
|
// ============================================================
|
|
367
|
+
/**
|
|
368
|
+
* Strip internal recall provenance the fast brain may echo into its answer so
|
|
369
|
+
* the user never sees it: citation headers like
|
|
370
|
+
* [main L550 · tool_result · both] 2026-08-09T19:29:01.229Z
|
|
371
|
+
* bare "L123: ..." line prefixes, and standalone ISO timestamps.
|
|
372
|
+
*/
|
|
373
|
+
function sanitizeFastBrainAnswer(text) {
|
|
374
|
+
if (!text)
|
|
375
|
+
return text;
|
|
376
|
+
return text
|
|
377
|
+
.split('\n')
|
|
378
|
+
.filter((line) => {
|
|
379
|
+
const t = line.trim();
|
|
380
|
+
if (!t)
|
|
381
|
+
return true;
|
|
382
|
+
if (/^\[[^\]]*\bL\d+\b[^\]]*·[^\]]*\]/.test(t))
|
|
383
|
+
return false; // citation header
|
|
384
|
+
if (/^L\d+\s*:/.test(t))
|
|
385
|
+
return false; // "L123: ..." prefix
|
|
386
|
+
if (/^\d{4}-\d{2}-\d{2}T[\d:.]+Z?$/.test(t))
|
|
387
|
+
return false; // bare timestamp
|
|
388
|
+
return true;
|
|
389
|
+
})
|
|
390
|
+
.join('\n')
|
|
391
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
392
|
+
.trim();
|
|
393
|
+
}
|
|
338
394
|
export async function askPipelineFastBrain(workingDir, sessionId, question, opts) {
|
|
339
395
|
if (!sessionId || sessionId === 'pending') {
|
|
340
396
|
return { script: 'Session is still initializing.', type: 'acknowledgment', toolsUsed: [] };
|
|
341
397
|
}
|
|
342
|
-
|
|
398
|
+
// Demo pass (house z.ai key) takes precedence when active; else the user's own
|
|
399
|
+
// pay-per-use providers (Fireworks preferred, OpenRouter fallback).
|
|
400
|
+
const apiKey = resolveFastBrainProvider()
|
|
401
|
+
? (process.env.Z_AI_PERSONAL_API_KEY || process.env.ZAI_API_KEY)
|
|
402
|
+
: (process.env.FIREWORKS_API_KEY || process.env.OPENROUTER_API_KEY);
|
|
343
403
|
if (!apiKey) {
|
|
344
404
|
return { script: 'Search system not available right now.', type: 'acknowledgment', toolsUsed: [] };
|
|
345
405
|
}
|
|
@@ -385,8 +445,11 @@ export async function askPipelineFastBrain(workingDir, sessionId, question, opts
|
|
|
385
445
|
messages.push(msg);
|
|
386
446
|
const calls = msg.tool_calls;
|
|
387
447
|
if (!calls || calls.length === 0) {
|
|
388
|
-
// Final text response
|
|
389
|
-
|
|
448
|
+
// Final text response. Strip any internal recall provenance the model
|
|
449
|
+
// may have echoed (citation headers / line numbers / bare timestamps) —
|
|
450
|
+
// those leak as ugly "[main L550 · tool_result · both] 2026-…" lines in
|
|
451
|
+
// the chat bubble. Defense-in-depth alongside the system-prompt rule.
|
|
452
|
+
const text = sanitizeFastBrainAnswer((msg.content || '').trim());
|
|
390
453
|
// Update persistent history with this exchange
|
|
391
454
|
persistentMessages.push({ role: 'user', content: question });
|
|
392
455
|
if (text)
|
|
File without changes
|