osborn 0.9.271 → 0.9.275
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/.claude/skills/browser-apply/SKILL.md +82 -30
- package/.claude/skills/browser-apply/candidate.example.env +16 -0
- package/.claude/skills/browser-apply/fill.mjs +294 -0
- package/Dockerfile +1 -1
- package/dist/claude-auth.d.ts +85 -6
- package/dist/claude-auth.js +202 -22
- package/dist/claude-llm.d.ts +13 -0
- package/dist/claude-llm.js +171 -25
- package/dist/compaction-log.d.ts +67 -0
- package/dist/compaction-log.js +195 -0
- package/dist/config.d.ts +18 -0
- package/dist/config.js +122 -65
- package/dist/content/transcript-sanitizer.d.ts +20 -6
- package/dist/content/transcript-sanitizer.js +66 -11
- package/dist/data-sender-auth.d.ts +90 -0
- package/dist/data-sender-auth.js +158 -0
- package/dist/duck.d.ts +8 -0
- package/dist/duck.js +59 -0
- package/dist/env-keys.js +11 -0
- package/dist/index.js +493 -97
- package/dist/lib/safe-artifact-path.d.ts +17 -0
- package/dist/lib/safe-artifact-path.js +129 -0
- package/dist/meeting-addressing.d.ts +176 -0
- package/dist/meeting-addressing.js +288 -0
- package/dist/pipeline-direct-llm.d.ts +52 -1
- package/dist/pipeline-direct-llm.js +206 -61
- package/dist/prompts/direct-mode-fallback.md +1 -1
- package/dist/prompts/direct-mode-research.md +2 -2
- package/dist/prompts.d.ts +1 -1
- package/dist/prompts.js +3 -3
- package/dist/pushover.d.ts +77 -0
- package/dist/pushover.js +276 -0
- package/dist/recall-client.js +21 -2
- package/dist/session-store.d.ts +15 -5
- package/dist/session-store.js +37 -10
- package/dist/transcript-wiring.d.ts +121 -0
- package/dist/transcript-wiring.js +252 -0
- package/dist/voice-io.d.ts +0 -9
- package/dist/voice-io.js +5 -19
- package/dist/watch-gateway.d.ts +38 -0
- package/dist/watch-gateway.js +205 -0
- package/package.json +1 -1
- package/scripts/review.ts +1 -1
- package/dist/bridge-llm.d.ts +0 -22
- package/dist/bridge-llm.js +0 -39
- package/dist/codex-handler.d.ts +0 -38
- package/dist/codex-handler.js +0 -83
- package/dist/codex-llm.d.ts +0 -40
- package/dist/codex-llm.js +0 -144
- package/dist/fast-brain.d.ts +0 -176
- package/dist/fast-brain.js +0 -1887
- package/dist/index-3-2-26-legacy.d.ts +0 -1
- package/dist/index-3-2-26-legacy.js +0 -2233
- package/dist/leagcyprompts2.d.ts +0 -0
- package/dist/leagcyprompts2.js +0 -573
- package/dist/prompts-2-25-26.d.ts +0 -0
- package/dist/prompts-2-25-26.js +0 -518
- package/dist/prompts-3-2-26.d.ts +0 -78
- package/dist/prompts-3-2-26.js +0 -1319
- package/dist/summary-index.d.ts +0 -90
- package/dist/summary-index.js +0 -585
package/dist/claude-auth.js
CHANGED
|
@@ -84,6 +84,13 @@ const CREDENTIALS_PATH = join(homedir(), '.claude', '.credentials.json');
|
|
|
84
84
|
* `\x1B\\`. Claude's Ink UI uses these extensively and they leak into error
|
|
85
85
|
* messages and URLs when we only strip the basic CSI form.
|
|
86
86
|
*/
|
|
87
|
+
/**
|
|
88
|
+
* Redact Claude tokens (sk-ant-oat01-…, sk-ant-api…) from CLI output before it
|
|
89
|
+
* is logged or forwarded — `claude setup-token` prints the token to the pty.
|
|
90
|
+
*/
|
|
91
|
+
export function redactClaudeTokens(text) {
|
|
92
|
+
return text.replace(/sk-ant-[A-Za-z0-9_-]+/g, 'sk-ant-[REDACTED]');
|
|
93
|
+
}
|
|
87
94
|
function stripAnsi(text) {
|
|
88
95
|
return text
|
|
89
96
|
// Full CSI: ESC [ <intermediates 0x20–0x3F> <final 0x40–0x7E>
|
|
@@ -151,17 +158,96 @@ export function isClaudeAuthenticated() {
|
|
|
151
158
|
*/
|
|
152
159
|
let fallbackTierActive = false;
|
|
153
160
|
/**
|
|
154
|
-
*
|
|
155
|
-
*
|
|
161
|
+
* Pre-fallback values of the model env vars applyAuthFallback() overwrites, so
|
|
162
|
+
* clearAuthFallbackIfActive() can RESTORE an operator-set value instead of
|
|
163
|
+
* deleting it. `undefined` means "was unset". Captured once, on the first
|
|
164
|
+
* activation (a second applyAuthFallback() must not snapshot its own values).
|
|
165
|
+
*/
|
|
166
|
+
const RESTORABLE_MODEL_VARS = ['ANTHROPIC_MODEL', 'ANTHROPIC_SMALL_FAST_MODEL', 'CLAUDE_CODE_MAX_CONTEXT_TOKENS'];
|
|
167
|
+
let preFallbackModelEnv = null;
|
|
168
|
+
function snapshotModelEnv() {
|
|
169
|
+
if (fallbackTierActive || preFallbackModelEnv)
|
|
170
|
+
return;
|
|
171
|
+
preFallbackModelEnv = {};
|
|
172
|
+
for (const k of RESTORABLE_MODEL_VARS)
|
|
173
|
+
preFallbackModelEnv[k] = process.env[k];
|
|
174
|
+
}
|
|
175
|
+
function restoreModelEnv() {
|
|
176
|
+
for (const k of RESTORABLE_MODEL_VARS) {
|
|
177
|
+
const v = preFallbackModelEnv ? preFallbackModelEnv[k] : undefined;
|
|
178
|
+
if (v === undefined)
|
|
179
|
+
delete process.env[k];
|
|
180
|
+
else
|
|
181
|
+
process.env[k] = v;
|
|
182
|
+
}
|
|
183
|
+
preFallbackModelEnv = null;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Set when the OAuth onComplete path cleared an active fallback, so a caller that
|
|
187
|
+
* awaited the flow (claude_auth_start) still learns a restart is needed even
|
|
188
|
+
* though its own clearAuthFallbackIfActive() then finds nothing to clear.
|
|
189
|
+
*/
|
|
190
|
+
let fallbackClearedByLogin = false;
|
|
191
|
+
export function consumeFallbackClearedByLogin() {
|
|
192
|
+
const v = fallbackClearedByLogin;
|
|
193
|
+
fallbackClearedByLogin = false;
|
|
194
|
+
return v;
|
|
195
|
+
}
|
|
196
|
+
/** Trim whitespace and strip one layer of surrounding quotes from an env value. */
|
|
197
|
+
export function cleanEnvKey(value) {
|
|
198
|
+
if (!value)
|
|
199
|
+
return '';
|
|
200
|
+
let v = value.trim();
|
|
201
|
+
if (v.length >= 2 && ((v.startsWith('"') && v.endsWith('"')) || (v.startsWith("'") && v.endsWith("'")))) {
|
|
202
|
+
v = v.slice(1, -1).trim();
|
|
203
|
+
}
|
|
204
|
+
return v;
|
|
205
|
+
}
|
|
206
|
+
/** Env vars that give the agent a working model backend without a Claude login. */
|
|
207
|
+
export const FALLBACK_MODEL_KEY_VARS = [
|
|
208
|
+
'ANTHROPIC_API_KEY',
|
|
209
|
+
'Z_AI_PERSONAL_API_KEY',
|
|
210
|
+
'ZAI_API_KEY',
|
|
211
|
+
'OPENROUTER_API_KEY',
|
|
212
|
+
];
|
|
213
|
+
/**
|
|
214
|
+
* True when any fallback model key (Anthropic API key, z.ai, OpenRouter) has a
|
|
215
|
+
* non-empty value after trimming and quote-stripping.
|
|
216
|
+
*/
|
|
217
|
+
export function hasFallbackModelKey(env = process.env) {
|
|
218
|
+
return FALLBACK_MODEL_KEY_VARS.some((name) => cleanEnvKey(env[name]) !== '');
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Pure decision for ensureClaudeAuth(): skip the blocking interactive OAuth when
|
|
222
|
+
* Claude is not authenticated but a fallback key exists — the session starts
|
|
223
|
+
* immediately on the fallback tier and Claude sign-in is offered as an optional
|
|
224
|
+
* upgrade. OSBORN_FORCE_CLAUDE_LOGIN=1 restores the old blocking behaviour.
|
|
225
|
+
*/
|
|
226
|
+
export function shouldSkipBlockingOAuth(env, authed) {
|
|
227
|
+
if (authed)
|
|
228
|
+
return false;
|
|
229
|
+
if (env.OSBORN_FORCE_CLAUDE_LOGIN === '1')
|
|
230
|
+
return false;
|
|
231
|
+
return hasFallbackModelKey(env);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Additive onboarding tier resolution. Runs AFTER ensureClaudeAuth() and BEFORE
|
|
235
|
+
* session creation. Resolves which auth backend the agent will use, in order
|
|
236
|
+
* (Claude → ANTHROPIC_API_KEY → z.ai → OpenRouter):
|
|
156
237
|
*
|
|
157
238
|
* Tier 1 — real Claude login active (expiry-aware): use it, no-op.
|
|
158
239
|
* Tier 2 — user's own ANTHROPIC_API_KEY is set: use it, no-op.
|
|
159
|
-
* Tier 3 —
|
|
240
|
+
* Tier 3 — house demo pass, Z_AI_PERSONAL_API_KEY (or ZAI_API_KEY): redirect
|
|
241
|
+
* the SDK to z.ai's Anthropic-compatible endpoint (GLM model).
|
|
242
|
+
* Tier 4 — central OPENROUTER_API_KEY present: redirect the SDK to
|
|
160
243
|
* OpenRouter's native Anthropic-Messages endpoint via env vars and
|
|
161
244
|
* point every model slot at FALLBACK_MODEL. Proven end-to-end
|
|
162
245
|
* env-var-only (no proxy) — the Claude Code tool loop completes.
|
|
163
|
-
* Tier
|
|
164
|
-
* may still find creds we didn't detect).
|
|
246
|
+
* Tier 4 fail — no fallback key at all: warn and no-op (do NOT throw; the
|
|
247
|
+
* SDK may still find creds we didn't detect).
|
|
248
|
+
*
|
|
249
|
+
* Key values are trimmed and quote-stripped (cleanEnvKey) — a stray trailing
|
|
250
|
+
* space in a secret would otherwise be sent verbatim as the bearer token.
|
|
165
251
|
*
|
|
166
252
|
* Env vars MUST be set here, before the first query() spawn — the SDK
|
|
167
253
|
* subprocess inherits process.env at spawn time and reads auth/model config
|
|
@@ -174,17 +260,20 @@ export function applyAuthFallback() {
|
|
|
174
260
|
return;
|
|
175
261
|
}
|
|
176
262
|
// Tier 2: user's own Anthropic key.
|
|
177
|
-
|
|
263
|
+
const anthropicKey = cleanEnvKey(process.env.ANTHROPIC_API_KEY);
|
|
264
|
+
if (anthropicKey !== '') {
|
|
265
|
+
process.env.ANTHROPIC_API_KEY = anthropicKey;
|
|
178
266
|
return;
|
|
179
267
|
}
|
|
180
268
|
// Tier 3: HOUSE DEMO PASS - z.ai GLM coding subscription (flat/shared, not
|
|
181
269
|
// pay-per-use). Cline/opencode-style: unauthenticated demo users ride the
|
|
182
270
|
// house pass instead of raw API billing. The z.ai Anthropic-compatible
|
|
183
271
|
// endpoint (api.z.ai/api/anthropic) speaks native Messages - verified live
|
|
184
|
-
// 2026-10-24 (glm-4.7 returned a real response). Precedence: Z_AI_PERSONAL_API_KEY
|
|
185
|
-
//
|
|
186
|
-
const zaiKey = process.env.Z_AI_PERSONAL_API_KEY || process.env.ZAI_API_KEY;
|
|
187
|
-
if (zaiKey
|
|
272
|
+
// 2026-10-24 (glm-4.7 returned a real response). Precedence: Z_AI_PERSONAL_API_KEY,
|
|
273
|
+
// then ZAI_API_KEY.
|
|
274
|
+
const zaiKey = cleanEnvKey(process.env.Z_AI_PERSONAL_API_KEY) || cleanEnvKey(process.env.ZAI_API_KEY);
|
|
275
|
+
if (zaiKey !== '') {
|
|
276
|
+
snapshotModelEnv();
|
|
188
277
|
// Native Anthropic-Messages endpoint - no local translation proxy needed.
|
|
189
278
|
process.env.ANTHROPIC_BASE_URL = process.env.OSBORN_DEMO_BASE_URL || 'https://api.z.ai/api/anthropic';
|
|
190
279
|
process.env.ANTHROPIC_AUTH_TOKEN = zaiKey;
|
|
@@ -204,8 +293,9 @@ export function applyAuthFallback() {
|
|
|
204
293
|
return;
|
|
205
294
|
}
|
|
206
295
|
// Tier 4: central OpenRouter key (pay-per-use fallback of the fallback).
|
|
207
|
-
const openRouterKey = process.env.OPENROUTER_API_KEY;
|
|
208
|
-
if (openRouterKey
|
|
296
|
+
const openRouterKey = cleanEnvKey(process.env.OPENROUTER_API_KEY);
|
|
297
|
+
if (openRouterKey !== '') {
|
|
298
|
+
snapshotModelEnv();
|
|
209
299
|
// Native Anthropic-Messages endpoint — no local translation proxy needed.
|
|
210
300
|
process.env.ANTHROPIC_BASE_URL = 'https://openrouter.ai/api';
|
|
211
301
|
// Injected as raw `Authorization: Bearer <token>` by the SDK.
|
|
@@ -237,16 +327,23 @@ export function applyAuthFallback() {
|
|
|
237
327
|
console.warn('[auth-fallback] no Claude login, no ANTHROPIC_API_KEY, no Z_AI key, and no OPENROUTER_API_KEY — agent may be unauthenticated');
|
|
238
328
|
}
|
|
239
329
|
/**
|
|
240
|
-
* Clear the
|
|
241
|
-
* it. Called from the auth onComplete path so a user who later finishes real
|
|
330
|
+
* Clear the fallback redirect (z.ai house pass or OpenRouter) — but ONLY if
|
|
331
|
+
* applyAuthFallback() set it. Called from the auth onComplete path so a user who later finishes real
|
|
242
332
|
* Claude login mid-session (or on the next cold start) is not stuck routing to
|
|
243
|
-
*
|
|
333
|
+
* the fallback. A user-supplied ANTHROPIC_BASE_URL is left untouched.
|
|
334
|
+
*
|
|
335
|
+
* Returns true iff a fallback was active and has now been cleared — callers use
|
|
336
|
+
* this to decide whether a running session needs a (deferred) restart.
|
|
244
337
|
*/
|
|
245
|
-
function clearAuthFallbackIfActive() {
|
|
338
|
+
export function clearAuthFallbackIfActive() {
|
|
246
339
|
if (!fallbackTierActive)
|
|
247
|
-
return;
|
|
340
|
+
return false;
|
|
248
341
|
delete process.env.ANTHROPIC_BASE_URL;
|
|
249
342
|
delete process.env.ANTHROPIC_AUTH_TOKEN;
|
|
343
|
+
// Model-slot overrides both tiers (z.ai + OpenRouter) set — restore the
|
|
344
|
+
// pre-fallback values (or unset) so the real Claude session isn't pinned onto
|
|
345
|
+
// glm-4.7 / FALLBACK_MODEL and the fallback's context cap.
|
|
346
|
+
restoreModelEnv();
|
|
250
347
|
// Was forced to '' for the OpenRouter redirect; unset so the real OAuth
|
|
251
348
|
// token path (CLAUDE_CODE_OAUTH_TOKEN) is used cleanly.
|
|
252
349
|
delete process.env.ANTHROPIC_API_KEY;
|
|
@@ -260,6 +357,7 @@ function clearAuthFallbackIfActive() {
|
|
|
260
357
|
delete process.env.OSBORN_DEMO_PASS;
|
|
261
358
|
fallbackTierActive = false;
|
|
262
359
|
console.log('[auth-fallback] real Claude login completed — cleared fallback redirect');
|
|
360
|
+
return true;
|
|
263
361
|
}
|
|
264
362
|
/**
|
|
265
363
|
* Check auth via `claude auth status` (most reliable).
|
|
@@ -439,8 +537,9 @@ export function runClaudeAuthFlow(callbacks) {
|
|
|
439
537
|
recentBuffer += clean;
|
|
440
538
|
// Debug log (truncated)
|
|
441
539
|
const logLine = clean.trim();
|
|
540
|
+
// Redact BEFORE truncating so a token can't survive as a cut-off prefix.
|
|
442
541
|
if (logLine)
|
|
443
|
-
console.log(`🔑 [claude-cli] ${logLine.substring(0, 200)}`);
|
|
542
|
+
console.log(`🔑 [claude-cli] ${redactClaudeTokens(logLine).substring(0, 200)}`);
|
|
444
543
|
callbacks.onOutput?.(data);
|
|
445
544
|
// Extract OAuth URL from accumulated output (claudebox whitespace-strip pattern)
|
|
446
545
|
if (!urlSent) {
|
|
@@ -466,7 +565,7 @@ export function runClaudeAuthFlow(callbacks) {
|
|
|
466
565
|
completed = true;
|
|
467
566
|
clearTimeout(timeout);
|
|
468
567
|
const token = tokenMatch[0];
|
|
469
|
-
console.log(`✅ OAuth token captured (${token.length} chars
|
|
568
|
+
console.log(`✅ OAuth token captured (${token.length} chars)`);
|
|
470
569
|
// Set as env var so Claude Agent SDK picks it up immediately
|
|
471
570
|
process.env.CLAUDE_CODE_OAUTH_TOKEN = token;
|
|
472
571
|
// Persist to volume for future restarts
|
|
@@ -491,7 +590,7 @@ export function runClaudeAuthFlow(callbacks) {
|
|
|
491
590
|
}
|
|
492
591
|
// Detect errors
|
|
493
592
|
if (/OAuth error|Invalid code|expired/i.test(recentBuffer)) {
|
|
494
|
-
const errMsg = stripAnsi(recentBuffer).trim().substring(0, 200);
|
|
593
|
+
const errMsg = redactClaudeTokens(stripAnsi(recentBuffer).trim()).substring(0, 200);
|
|
495
594
|
console.log('⚠️ Claude auth error:', errMsg);
|
|
496
595
|
callbacks.onError(errMsg);
|
|
497
596
|
recentBuffer = '';
|
|
@@ -551,6 +650,9 @@ export function replayInFlightAuth(send) {
|
|
|
551
650
|
* 1. CLAUDE_CODE_OAUTH_TOKEN env var
|
|
552
651
|
* 2. ~/.claude/.credentials.json file
|
|
553
652
|
* 3. `claude auth status --json`
|
|
653
|
+
* 3b. Fallback model key present (hasFallbackModelKey) → return immediately
|
|
654
|
+
* and emit `claude_auth_optional`; skipped when OSBORN_FORCE_CLAUDE_LOGIN=1
|
|
655
|
+
* or opts.force (user explicitly asked to sign in via `claude_auth_start`)
|
|
554
656
|
* 4. Interactive OAuth flow (setup-token)
|
|
555
657
|
*
|
|
556
658
|
* Concurrency: if a previous call is still running its OAuth flow, new
|
|
@@ -559,7 +661,7 @@ export function replayInFlightAuth(send) {
|
|
|
559
661
|
* microphone-permission error) retrigger ensureClaudeAuth and the user
|
|
560
662
|
* sees two different URLs / two different code_challenges racing.
|
|
561
663
|
*/
|
|
562
|
-
export async function ensureClaudeAuth(sendToFrontend) {
|
|
664
|
+
export async function ensureClaudeAuth(sendToFrontend, opts = {}) {
|
|
563
665
|
// If an auth flow is already running, attach to it and replay any
|
|
564
666
|
// state we've already captured (the URL, any waiting_code prompt).
|
|
565
667
|
if (inFlightAuth) {
|
|
@@ -609,6 +711,23 @@ export async function ensureClaudeAuth(sendToFrontend) {
|
|
|
609
711
|
console.log('✅ Claude authenticated (CLI status confirmed)');
|
|
610
712
|
return {};
|
|
611
713
|
}
|
|
714
|
+
// Check 3b: Fallback key present — don't block the session on interactive
|
|
715
|
+
// OAuth (which only ends on completion or a 5-minute timeout). Return the
|
|
716
|
+
// "no wait" shape so the caller proceeds straight to applyAuthFallback(),
|
|
717
|
+
// and tell the frontend Claude sign-in is an optional upgrade.
|
|
718
|
+
// opts.force (the on-demand `claude_auth_start` path) bypasses this check.
|
|
719
|
+
if (!opts.force && shouldSkipBlockingOAuth(process.env, false)) {
|
|
720
|
+
console.log('🔑 Claude not authenticated — fallback key present, skipping blocking OAuth');
|
|
721
|
+
try {
|
|
722
|
+
sendToFrontend('claude_auth_optional', {
|
|
723
|
+
message: 'Running on the fallback model. Sign in to Claude to upgrade.',
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
catch (err) {
|
|
727
|
+
console.warn('🔑 claude_auth_optional send failed:', err);
|
|
728
|
+
}
|
|
729
|
+
return {};
|
|
730
|
+
}
|
|
612
731
|
// Check 4: Need interactive OAuth flow
|
|
613
732
|
console.log('🔑 Claude not authenticated — starting OAuth flow');
|
|
614
733
|
// Create the in-flight record BEFORE spawning, and fan-out every
|
|
@@ -651,7 +770,8 @@ export async function ensureClaudeAuth(sendToFrontend) {
|
|
|
651
770
|
// the OpenRouter redirect env (only if the fallback set it) so this
|
|
652
771
|
// session — and the next cold start — use the real OAuth token instead
|
|
653
772
|
// of staying pinned to OpenRouter.
|
|
654
|
-
clearAuthFallbackIfActive()
|
|
773
|
+
if (clearAuthFallbackIfActive())
|
|
774
|
+
fallbackClearedByLogin = true;
|
|
655
775
|
// Include the captured token so the frontend can persist it to the
|
|
656
776
|
// host-persistent layer via the Sprites API. Without this, credentials
|
|
657
777
|
// written inside the service container's ephemeral overlay are lost on
|
|
@@ -681,3 +801,63 @@ export async function ensureClaudeAuth(sendToFrontend) {
|
|
|
681
801
|
});
|
|
682
802
|
return { submitCode: handle.submitCode, done };
|
|
683
803
|
}
|
|
804
|
+
// ─────────────────────────────────────────
|
|
805
|
+
// On-demand Claude sign-in (claude_auth_start)
|
|
806
|
+
// ─────────────────────────────────────────
|
|
807
|
+
let onDemandAuth = null;
|
|
808
|
+
/** True while a claude_auth_start-initiated flow is running. */
|
|
809
|
+
export function isOnDemandAuthInFlight() {
|
|
810
|
+
return onDemandAuth !== null;
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* Start Claude OAuth on demand — the upgrade path after ensureClaudeAuth()
|
|
814
|
+
* skipped the blocking flow because a fallback key exists. Guarded: a second
|
|
815
|
+
* call while one is running does NOT start another flow (started=false, same
|
|
816
|
+
* result promise).
|
|
817
|
+
*
|
|
818
|
+
* `submitCode` get/set bind the caller's pendingAuthSubmitCode slot; on settle
|
|
819
|
+
* the slot is cleared only if it still holds THIS flow's submitCode.
|
|
820
|
+
*
|
|
821
|
+
* Resolves `{ fallbackCleared }` — true only when a fallback redirect was
|
|
822
|
+
* active and is now gone (the caller should then request a deferred session
|
|
823
|
+
* restart). Already-authenticated → no flow, fallbackCleared reflects only
|
|
824
|
+
* whether a stale fallback was active.
|
|
825
|
+
*/
|
|
826
|
+
export function startClaudeAuthOnDemand(sendToFrontend, submitCode, deps = {}) {
|
|
827
|
+
if (onDemandAuth) {
|
|
828
|
+
console.log('🔑 claude_auth_start: on-demand flow already in flight — not starting another');
|
|
829
|
+
return { started: false, result: onDemandAuth };
|
|
830
|
+
}
|
|
831
|
+
const ensure = deps.ensure ?? ensureClaudeAuth;
|
|
832
|
+
const run = async () => {
|
|
833
|
+
try {
|
|
834
|
+
const authResult = await ensure(sendToFrontend, { force: true });
|
|
835
|
+
if (authResult.submitCode && authResult.done) {
|
|
836
|
+
const mine = authResult.submitCode;
|
|
837
|
+
submitCode.set(mine);
|
|
838
|
+
try {
|
|
839
|
+
await authResult.done;
|
|
840
|
+
}
|
|
841
|
+
finally {
|
|
842
|
+
if (submitCode.get() === mine)
|
|
843
|
+
submitCode.set(null);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
else {
|
|
847
|
+
sendToFrontend('claude_auth_complete', { message: 'Claude is already authenticated.' });
|
|
848
|
+
}
|
|
849
|
+
// onComplete may already have cleared it — consume that signal too.
|
|
850
|
+
const cleared = clearAuthFallbackIfActive();
|
|
851
|
+
const clearedByLogin = consumeFallbackClearedByLogin();
|
|
852
|
+
return { fallbackCleared: cleared || clearedByLogin };
|
|
853
|
+
}
|
|
854
|
+
catch (err) {
|
|
855
|
+
console.error('❌ On-demand Claude authentication failed:', err?.message);
|
|
856
|
+
sendToFrontend('claude_auth_error', { message: err?.message || 'Authentication failed' });
|
|
857
|
+
return { fallbackCleared: false };
|
|
858
|
+
}
|
|
859
|
+
};
|
|
860
|
+
const p = run().finally(() => { onDemandAuth = null; });
|
|
861
|
+
onDemandAuth = p;
|
|
862
|
+
return { started: true, result: p };
|
|
863
|
+
}
|
package/dist/claude-llm.d.ts
CHANGED
|
@@ -33,6 +33,9 @@ export interface ClaudeLLMOptions {
|
|
|
33
33
|
skillsWritten?: number;
|
|
34
34
|
skillNames?: string[];
|
|
35
35
|
trigger?: string;
|
|
36
|
+
at?: string;
|
|
37
|
+
transcriptRows?: number;
|
|
38
|
+
integrityWarning?: string;
|
|
36
39
|
}) => void;
|
|
37
40
|
agents?: Record<string, {
|
|
38
41
|
description: string;
|
|
@@ -85,6 +88,14 @@ export declare const NAMED_AGENTS: {
|
|
|
85
88
|
};
|
|
86
89
|
export declare const FAST_MODEL = "haiku";
|
|
87
90
|
export declare const FALLBACK_MODEL = "minimax/minimax-m3";
|
|
91
|
+
export declare function requestAuthRestart(): number;
|
|
92
|
+
export declare function getAuthEnvGeneration(): number;
|
|
93
|
+
/**
|
|
94
|
+
* Pure decision: restart a live persistent subprocess before pushing the next
|
|
95
|
+
* message? Only when it was spawned under an older auth generation AND it is
|
|
96
|
+
* idle (no turn streaming, no interrupt settling).
|
|
97
|
+
*/
|
|
98
|
+
export declare function shouldRestartForAuth(spawnGen: number, currentGen: number, turnsInFlight: number, interruptPending: boolean): boolean;
|
|
88
99
|
/**
|
|
89
100
|
* Apply turbo override to an agents roster.
|
|
90
101
|
* When turbo is true returns a DEEP COPY with every agent's model set to
|
|
@@ -127,6 +138,8 @@ export declare const VERIFIER_CHAIN: Record<string, {
|
|
|
127
138
|
}>;
|
|
128
139
|
export declare class ClaudeLLM extends llm.LLM {
|
|
129
140
|
#private;
|
|
141
|
+
/** True when the live subprocess predates the latest auth-backend change. */
|
|
142
|
+
get authRestartPending(): boolean;
|
|
130
143
|
constructor(opts?: ClaudeLLMOptions);
|
|
131
144
|
/**
|
|
132
145
|
* Respond to a pending permission request
|