alvin-bot 5.7.0 → 5.8.1
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/CHANGELOG.md +25 -0
- package/README.md +25 -31
- package/dist/claude.js +1 -102
- package/dist/config.js +1 -96
- package/dist/engine.js +1 -90
- package/dist/find-claude-binary.js +1 -98
- package/dist/handlers/async-agent-chunk-handler.js +1 -50
- package/dist/handlers/background-bypass.js +1 -75
- package/dist/handlers/commands.js +1 -2336
- package/dist/handlers/cron-progress.js +1 -52
- package/dist/handlers/document.js +1 -194
- package/dist/handlers/message.js +1 -959
- package/dist/handlers/photo.js +1 -154
- package/dist/handlers/platform-message.js +1 -360
- package/dist/handlers/stuck-timer.js +1 -54
- package/dist/handlers/video.js +1 -237
- package/dist/handlers/voice.js +1 -148
- package/dist/i18n.js +1 -805
- package/dist/index.js +1 -697
- package/dist/init-data-dir.js +1 -98
- package/dist/middleware/auth.js +1 -233
- package/dist/migrate.js +1 -162
- package/dist/paths.js +1 -146
- package/dist/platforms/discord.js +1 -175
- package/dist/platforms/index.js +1 -130
- package/dist/platforms/signal.js +1 -205
- package/dist/platforms/slack-slash-parser.js +1 -32
- package/dist/platforms/slack.js +1 -501
- package/dist/platforms/telegram.js +1 -111
- package/dist/platforms/types.js +1 -8
- package/dist/platforms/whatsapp-auth-helpers.js +1 -53
- package/dist/platforms/whatsapp.js +1 -707
- package/dist/providers/claude-sdk-provider.js +1 -565
- package/dist/providers/codex-cli-provider.js +1 -134
- package/dist/providers/index.js +1 -7
- package/dist/providers/ollama-provider.js +1 -32
- package/dist/providers/openai-compatible.js +1 -406
- package/dist/providers/registry.js +1 -352
- package/dist/providers/runtime-header.js +1 -45
- package/dist/providers/tool-executor.js +1 -475
- package/dist/providers/types.js +1 -227
- package/dist/services/access.js +1 -144
- package/dist/services/allowed-users-gate.js +1 -56
- package/dist/services/alvin-dispatch.js +1 -174
- package/dist/services/alvin-mcp-tools.js +1 -104
- package/dist/services/asset-index.js +1 -224
- package/dist/services/async-agent-parser.js +1 -418
- package/dist/services/async-agent-watcher.js +1 -583
- package/dist/services/auto-diagnostic.js +1 -228
- package/dist/services/broadcast.js +1 -52
- package/dist/services/browser-manager.js +1 -562
- package/dist/services/browser-webfetch.js +1 -127
- package/dist/services/browser.js +1 -121
- package/dist/services/cdp-bootstrap.js +1 -357
- package/dist/services/compaction.js +1 -144
- package/dist/services/critical-notify.js +1 -203
- package/dist/services/cron-resolver.js +1 -58
- package/dist/services/cron-scheduling.js +1 -310
- package/dist/services/cron.js +1 -861
- package/dist/services/custom-tools.js +1 -317
- package/dist/services/delivery-queue.js +1 -173
- package/dist/services/delivery-registry.js +1 -21
- package/dist/services/disk-cleanup.js +1 -203
- package/dist/services/elevenlabs.js +1 -58
- package/dist/services/embeddings/auto-detect.js +1 -74
- package/dist/services/embeddings/fts5.js +1 -108
- package/dist/services/embeddings/gemini.js +1 -65
- package/dist/services/embeddings/index.js +1 -496
- package/dist/services/embeddings/ollama.js +1 -78
- package/dist/services/embeddings/openai.js +1 -49
- package/dist/services/embeddings/provider.js +1 -22
- package/dist/services/embeddings/vector-base.js +1 -113
- package/dist/services/embeddings-migration.js +1 -193
- package/dist/services/embeddings.js +1 -9
- package/dist/services/env-file.js +1 -50
- package/dist/services/exec-guard.js +1 -71
- package/dist/services/fallback-order.js +1 -154
- package/dist/services/file-permissions.js +1 -93
- package/dist/services/heartbeat-file.js +1 -65
- package/dist/services/heartbeat.js +1 -313
- package/dist/services/hooks.js +1 -44
- package/dist/services/imagegen.js +1 -72
- package/dist/services/language-detect.js +1 -154
- package/dist/services/markdown.js +1 -63
- package/dist/services/mcp.js +1 -263
- package/dist/services/memory-extractor.js +1 -178
- package/dist/services/memory-inject-mode.js +1 -43
- package/dist/services/memory-layers.js +1 -156
- package/dist/services/memory.js +1 -146
- package/dist/services/ollama-manager.js +1 -339
- package/dist/services/permissions-wizard.js +1 -291
- package/dist/services/personality.js +1 -376
- package/dist/services/plugins.js +1 -171
- package/dist/services/preflight.js +1 -292
- package/dist/services/process-manager.js +1 -291
- package/dist/services/release-highlights.js +1 -79
- package/dist/services/reminders.js +1 -97
- package/dist/services/restart.js +1 -48
- package/dist/services/security-audit.js +1 -74
- package/dist/services/self-diagnosis.js +1 -272
- package/dist/services/self-search.js +1 -129
- package/dist/services/session-persistence.js +1 -237
- package/dist/services/session.js +1 -282
- package/dist/services/skills.js +1 -290
- package/dist/services/ssrf-guard.js +1 -162
- package/dist/services/standing-orders.js +1 -29
- package/dist/services/steer-channel.js +1 -46
- package/dist/services/stop-controller.js +1 -52
- package/dist/services/subagent-dedup.js +1 -86
- package/dist/services/subagent-delivery.js +1 -452
- package/dist/services/subagent-stats.js +1 -123
- package/dist/services/subagents.js +1 -814
- package/dist/services/sudo.js +1 -329
- package/dist/services/telegram.js +1 -158
- package/dist/services/timing-safe-bearer.js +1 -51
- package/dist/services/tool-discovery.js +1 -214
- package/dist/services/trends.js +1 -580
- package/dist/services/updater.js +1 -291
- package/dist/services/usage-tracker.js +1 -144
- package/dist/services/users.js +1 -271
- package/dist/services/voice.js +1 -104
- package/dist/services/watchdog-brake.js +1 -154
- package/dist/services/watchdog.js +1 -311
- package/dist/services/workspaces.js +1 -276
- package/dist/tui/index.js +1 -667
- package/dist/util/console-formatter.js +1 -109
- package/dist/util/debounce.js +1 -24
- package/dist/util/telegram-error-filter.js +1 -62
- package/dist/version.js +1 -24
- package/dist/web/bind-strategy.js +1 -42
- package/dist/web/canvas.js +1 -30
- package/dist/web/doctor-api.js +1 -604
- package/dist/web/openai-compat.js +1 -252
- package/dist/web/server.js +1 -1902
- package/dist/web/setup-api.js +1 -1101
- package/package.json +5 -2
- package/dist/.metadata_never_index +0 -0
|
@@ -1,565 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Claude Agent SDK Provider
|
|
3
|
-
*
|
|
4
|
-
* Wraps the existing Claude Agent SDK integration as a provider.
|
|
5
|
-
* This is the "premium" provider with full tool use (Read, Write, Bash, etc.)
|
|
6
|
-
*
|
|
7
|
-
* Requires: Claude CLI installed & logged in (Max subscription)
|
|
8
|
-
*/
|
|
9
|
-
import { query } from "@anthropic-ai/claude-agent-sdk";
|
|
10
|
-
import { readFileSync } from "fs";
|
|
11
|
-
import { resolve, dirname } from "path";
|
|
12
|
-
import { fileURLToPath } from "url";
|
|
13
|
-
import { execFile } from "child_process";
|
|
14
|
-
import { promisify } from "util";
|
|
15
|
-
import { findClaudeBinary } from "../find-claude-binary.js";
|
|
16
|
-
import { buildAlvinMcpServer } from "../services/alvin-mcp-tools.js";
|
|
17
|
-
import { buildRuntimeHeader } from "./runtime-header.js";
|
|
18
|
-
const execFileAsync = promisify(execFile);
|
|
19
|
-
/**
|
|
20
|
-
* Detects the Claude CLI "Not logged in" error message. The CLI emits this
|
|
21
|
-
* as normal assistant text when no valid OAuth token is present, so we have
|
|
22
|
-
* to treat that output as an error in the SDK path too.
|
|
23
|
-
*/
|
|
24
|
-
export function isAuthErrorOutput(text) {
|
|
25
|
-
if (!text)
|
|
26
|
-
return false;
|
|
27
|
-
return /^\s*not logged in\b/i.test(text);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Detects Anthropic's rate-limit / quota-exhausted gateway responses.
|
|
31
|
-
* These are NOT model outputs — they come back as a single text chunk with
|
|
32
|
-
* output_tokens = 0 before the model even sees the prompt. Without this
|
|
33
|
-
* detection, the bot would forward the gateway message as if it were the
|
|
34
|
-
* assistant's reply ("(Keine Antwort)" or the raw quota text), masking the
|
|
35
|
-
* real cause and wasting more calls on retries.
|
|
36
|
-
*
|
|
37
|
-
* Covers the observed variants:
|
|
38
|
-
* - "You're out of extra usage · resets 9pm (Europe/Berlin)"
|
|
39
|
-
* - "You've reached your weekly usage limit. …"
|
|
40
|
-
* - "Rate limit exceeded"
|
|
41
|
-
* - Claude Max / Pro quota messages in both EN/DE
|
|
42
|
-
*/
|
|
43
|
-
export function isQuotaLimitOutput(text) {
|
|
44
|
-
if (!text)
|
|
45
|
-
return false;
|
|
46
|
-
const t = text.trim();
|
|
47
|
-
if (t.length === 0)
|
|
48
|
-
return false;
|
|
49
|
-
return (/you['’]re out of extra usage/i.test(t) ||
|
|
50
|
-
/reached (your |the )?(weekly |monthly |daily )?(usage|rate) limit/i.test(t) ||
|
|
51
|
-
/rate[- ]?limit(ed)? (exceeded|reached)/i.test(t) ||
|
|
52
|
-
/quota exceeded/i.test(t) ||
|
|
53
|
-
/usage limit reached/i.test(t) ||
|
|
54
|
-
/limit (reached|hit) for (this|your) (week|month|day)/i.test(t) ||
|
|
55
|
-
/resets? \d{1,2}(am|pm|:)/i.test(t) && /usage|limit/i.test(t));
|
|
56
|
-
}
|
|
57
|
-
const BOT_PROJECT_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "../..");
|
|
58
|
-
// Load CLAUDE.md once at startup
|
|
59
|
-
let botClaudeMd = "";
|
|
60
|
-
try {
|
|
61
|
-
botClaudeMd = readFileSync(resolve(BOT_PROJECT_ROOT, "CLAUDE.md"), "utf-8");
|
|
62
|
-
botClaudeMd = botClaudeMd.replaceAll("docs/", `${BOT_PROJECT_ROOT}/docs/`);
|
|
63
|
-
}
|
|
64
|
-
catch {
|
|
65
|
-
// CLAUDE.md not found — continue without
|
|
66
|
-
}
|
|
67
|
-
// Checkpoint thresholds
|
|
68
|
-
const CHECKPOINT_TOOL_THRESHOLD = 15;
|
|
69
|
-
const CHECKPOINT_MSG_THRESHOLD = 10;
|
|
70
|
-
export class ClaudeSDKProvider {
|
|
71
|
-
config;
|
|
72
|
-
// Cache the availability check: execFile on every user message would block
|
|
73
|
-
// the bot for ~0-5s each time. A 60s cache is safe — the CLI binary does
|
|
74
|
-
// not disappear mid-session.
|
|
75
|
-
availabilityCache = null;
|
|
76
|
-
static AVAILABILITY_CACHE_MS = 60_000;
|
|
77
|
-
constructor(config) {
|
|
78
|
-
this.config = {
|
|
79
|
-
type: "claude-sdk",
|
|
80
|
-
name: "Claude (Agent SDK)",
|
|
81
|
-
// "inherit" = don't pass model: to the SDK → Claude CLI default wins
|
|
82
|
-
// (currently Opus 4.7 on Max subscription). Override with an alias
|
|
83
|
-
// ("opus" | "sonnet" | "haiku") or a full ID ("claude-opus-4-7").
|
|
84
|
-
model: "inherit",
|
|
85
|
-
supportsTools: true,
|
|
86
|
-
supportsVision: true,
|
|
87
|
-
supportsStreaming: true,
|
|
88
|
-
...config,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
async *query(options) {
|
|
92
|
-
// Clean env to prevent nested session errors
|
|
93
|
-
const cleanEnv = { ...process.env };
|
|
94
|
-
delete cleanEnv.CLAUDECODE;
|
|
95
|
-
delete cleanEnv.CLAUDE_CODE_ENTRYPOINT;
|
|
96
|
-
// Build prompt with optional checkpoint reminder
|
|
97
|
-
let prompt = options.prompt;
|
|
98
|
-
const sessionState = options._sessionState;
|
|
99
|
-
if (sessionState) {
|
|
100
|
-
// Checkpoint reminder injection with COOLDOWN.
|
|
101
|
-
//
|
|
102
|
-
// Old behaviour: once either threshold was crossed, the hint got
|
|
103
|
-
// prepended to EVERY subsequent turn's prompt. That forced Claude
|
|
104
|
-
// to detour through memory-file reads/writes on every single turn,
|
|
105
|
-
// which bloated turn latency in long sessions and was a major
|
|
106
|
-
// contributor to the 5-minute hard timeout firing.
|
|
107
|
-
//
|
|
108
|
-
// New behaviour: inject only every CHECKPOINT_REMINDER_EVERY turns
|
|
109
|
-
// after the threshold is reached. At messageCount 10 → injected,
|
|
110
|
-
// 11/12/13/14 → skipped, 15 → injected again, etc. 80% reduction
|
|
111
|
-
// in per-turn overhead while still giving Claude periodic reminders.
|
|
112
|
-
const CHECKPOINT_REMINDER_EVERY = 5;
|
|
113
|
-
const overThreshold = sessionState.toolUseCount >= CHECKPOINT_TOOL_THRESHOLD ||
|
|
114
|
-
sessionState.messageCount >= CHECKPOINT_MSG_THRESHOLD;
|
|
115
|
-
const onCooldownBeat = sessionState.messageCount % CHECKPOINT_REMINDER_EVERY === 0;
|
|
116
|
-
if (overThreshold && onCooldownBeat) {
|
|
117
|
-
prompt = `[CHECKPOINT] Du hast bereits ${sessionState.toolUseCount} Tool-Aufrufe und ${sessionState.messageCount} Nachrichten in dieser Session. Schreibe jetzt einen Checkpoint in deine Memory-Datei (docs/memory/YYYY-MM-DD.md) bevor du diese Anfrage bearbeitest.\n\n${prompt}`;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
// Build system prompt. The runtime-header is injected ABOVE the CLAUDE.md
|
|
121
|
-
// contents so its values (BOT_VERSION, install path, runtime) outrank any
|
|
122
|
-
// stale "Version: x.y.z" line that may still live in CLAUDE.md.
|
|
123
|
-
const runtimeHeader = buildRuntimeHeader();
|
|
124
|
-
const systemPrompt = options.systemPrompt
|
|
125
|
-
? `${runtimeHeader}\n\n${options.systemPrompt}\n\n${botClaudeMd}`
|
|
126
|
-
: `${runtimeHeader}\n\n${botClaudeMd}`;
|
|
127
|
-
// Build a real AbortController the SDK can call .abort() on.
|
|
128
|
-
// The previous implementation cast a plain {signal} object to AbortController,
|
|
129
|
-
// which broke SDK-internal cancellation and left orphan subprocesses.
|
|
130
|
-
let internalAbortController;
|
|
131
|
-
if (options.abortSignal) {
|
|
132
|
-
internalAbortController = new AbortController();
|
|
133
|
-
if (options.abortSignal.aborted) {
|
|
134
|
-
internalAbortController.abort();
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
options.abortSignal.addEventListener("abort", () => internalAbortController?.abort(), { once: true });
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
try {
|
|
141
|
-
const claudePath = findClaudeBinary();
|
|
142
|
-
// v4.13 — Register Alvin's custom MCP server if the caller provided
|
|
143
|
-
// dispatch context. The server exposes `alvin_dispatch_agent` which
|
|
144
|
-
// spawns truly detached `claude -p` subprocesses (independent of the
|
|
145
|
-
// main SDK subprocess's lifecycle). When Claude calls it, the bot
|
|
146
|
-
// can abort this query without killing the dispatched sub-agent.
|
|
147
|
-
const mcpServers = {};
|
|
148
|
-
if (options.alvinDispatchContext) {
|
|
149
|
-
mcpServers.alvin = buildAlvinMcpServer(options.alvinDispatchContext);
|
|
150
|
-
}
|
|
151
|
-
// v4.13 — MCP tool names must be explicitly whitelisted via allowedTools
|
|
152
|
-
// in the form `mcp__<server>__<tool>`. Without this, Claude can see the
|
|
153
|
-
// tool in the catalog but cannot actually invoke it.
|
|
154
|
-
const defaultAllowed = [
|
|
155
|
-
"Read", "Write", "Edit", "Bash", "Glob", "Grep",
|
|
156
|
-
"WebSearch", "WebFetch", "Task",
|
|
157
|
-
];
|
|
158
|
-
if (options.alvinDispatchContext) {
|
|
159
|
-
defaultAllowed.push("mcp__alvin__dispatch_agent");
|
|
160
|
-
}
|
|
161
|
-
// v4.15 — Forward model selection to the Agent SDK. Resolution order:
|
|
162
|
-
// 1. options.model (per-query override — e.g. workspace `model:` field)
|
|
163
|
-
// 2. this.config.model (provider-level default — e.g. claude-sonnet)
|
|
164
|
-
// 3. "inherit" → don't pass model: → Claude CLI default (Opus 4.7 on Max)
|
|
165
|
-
// Aliases "opus" | "sonnet" | "haiku" auto-resolve to the latest tier.
|
|
166
|
-
const rawModel = options.model ?? this.config.model;
|
|
167
|
-
const modelOverride = rawModel && rawModel !== "inherit" ? rawModel : undefined;
|
|
168
|
-
// v4.15.1 — Suppress fallbackModel when the primary model is already
|
|
169
|
-
// Haiku. The Agent SDK rejects identical model/fallbackModel pairs with
|
|
170
|
-
// "Fallback model cannot be the same as the main model", which then
|
|
171
|
-
// cascades all the way down the provider fallback chain (→ Ollama
|
|
172
|
-
// on-demand boot → noticeable latency spike). For opus/sonnet/inherit,
|
|
173
|
-
// keep Haiku as the rate-limit fallback.
|
|
174
|
-
const primaryIsHaiku = (modelOverride ?? "").toLowerCase().includes("haiku");
|
|
175
|
-
const fallbackModel = primaryIsHaiku ? undefined : "haiku";
|
|
176
|
-
const q = query({
|
|
177
|
-
prompt: options.steerChannel
|
|
178
|
-
? options.steerChannel
|
|
179
|
-
: prompt,
|
|
180
|
-
options: {
|
|
181
|
-
cwd: options.workingDir || process.cwd(),
|
|
182
|
-
abortController: internalAbortController,
|
|
183
|
-
resume: options.sessionId ?? undefined,
|
|
184
|
-
pathToClaudeCodeExecutable: claudePath,
|
|
185
|
-
permissionMode: "bypassPermissions",
|
|
186
|
-
allowDangerouslySkipPermissions: true,
|
|
187
|
-
env: cleanEnv,
|
|
188
|
-
settingSources: ["user", "project"],
|
|
189
|
-
// v4.12.2 — options.allowedTools can override the default full set.
|
|
190
|
-
// Used by sub-agents with toolset="readonly"/"research" to restrict
|
|
191
|
-
// what Claude can do. Default = full access + alvin MCP tools.
|
|
192
|
-
allowedTools: options.allowedTools ?? defaultAllowed,
|
|
193
|
-
// v4.13 — Conditionally pass the MCP server config so the inline
|
|
194
|
-
// dispatch tool is visible. Empty object = no custom tools.
|
|
195
|
-
mcpServers: Object.keys(mcpServers).length > 0 ? mcpServers : undefined,
|
|
196
|
-
systemPrompt,
|
|
197
|
-
effort: (options.effort || "medium"),
|
|
198
|
-
maxTurns: 50,
|
|
199
|
-
betas: ["context-1m-2025-08-07"],
|
|
200
|
-
...(modelOverride ? { model: modelOverride } : {}),
|
|
201
|
-
// v4.19.0 — per-workspace temperature override. Passed through to
|
|
202
|
-
// the Agent SDK; providers that don't use it just drop it.
|
|
203
|
-
...(typeof options.temperature === "number" ? { temperature: options.temperature } : {}),
|
|
204
|
-
// Prefer Haiku as fallback on rate-limit/overload — cheap and
|
|
205
|
-
// fast, keeps the bot responsive when the primary tier is
|
|
206
|
-
// throttled. Omitted when the primary IS Haiku (SDK requires
|
|
207
|
-
// distinct model/fallbackModel values — see v4.15.1 fix above).
|
|
208
|
-
...(fallbackModel ? { fallbackModel } : {}),
|
|
209
|
-
},
|
|
210
|
-
});
|
|
211
|
-
// v5.1 — Expose the SDK query handle to the caller so requestStop()
|
|
212
|
-
// can interrupt it via q.interrupt() + transport.process.kill().
|
|
213
|
-
try {
|
|
214
|
-
options.onQueryHandle?.(q);
|
|
215
|
-
}
|
|
216
|
-
catch { /* non-fatal */ }
|
|
217
|
-
let accumulatedText = "";
|
|
218
|
-
let capturedSessionId = options.sessionId || "";
|
|
219
|
-
let localToolUseCount = 0;
|
|
220
|
-
for await (const message of q) {
|
|
221
|
-
// v5.1 — Bail immediately if the caller set abortSignal while iterating.
|
|
222
|
-
if (options.abortSignal?.aborted) {
|
|
223
|
-
try {
|
|
224
|
-
q.return?.();
|
|
225
|
-
}
|
|
226
|
-
catch { /* ignore */ }
|
|
227
|
-
break;
|
|
228
|
-
}
|
|
229
|
-
// System init — capture session ID
|
|
230
|
-
if (message.type === "system" && "subtype" in message && message.subtype === "init") {
|
|
231
|
-
const sysMsg = message;
|
|
232
|
-
capturedSessionId = sysMsg.session_id;
|
|
233
|
-
}
|
|
234
|
-
// Assistant message — text + tool use
|
|
235
|
-
if (message.type === "assistant") {
|
|
236
|
-
const assistantMsg = message;
|
|
237
|
-
capturedSessionId = assistantMsg.session_id;
|
|
238
|
-
if (assistantMsg.message?.content) {
|
|
239
|
-
for (const block of assistantMsg.message.content) {
|
|
240
|
-
if ("text" in block && block.text) {
|
|
241
|
-
// Guard against "Not logged in" leaking as assistant text.
|
|
242
|
-
// If the very first text chunk matches the CLI auth-error
|
|
243
|
-
// pattern, surface it as an error chunk instead of rendering
|
|
244
|
-
// it as a normal response.
|
|
245
|
-
if (!accumulatedText && isAuthErrorOutput(block.text)) {
|
|
246
|
-
yield {
|
|
247
|
-
type: "error",
|
|
248
|
-
error: "Claude CLI is not logged in. Run `claude login` on this machine.",
|
|
249
|
-
};
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
// v4.18.4 — Guard against Anthropic rate-limit / quota-exhausted
|
|
253
|
-
// gateway messages that also arrive as a single text chunk (with
|
|
254
|
-
// output_tokens = 0). Pass them through as a friendly text chunk
|
|
255
|
-
// (NOT an error — would trigger fallback cascade to Ollama) and
|
|
256
|
-
// mark the provider as degraded so the next heartbeat re-checks.
|
|
257
|
-
if (!accumulatedText && isQuotaLimitOutput(block.text)) {
|
|
258
|
-
const hint = "⚠️ " + block.text.trim() +
|
|
259
|
-
"\n\nTop up the plan or wait for the reset. No message was sent to Claude.";
|
|
260
|
-
this.invalidateAvailabilityCache();
|
|
261
|
-
yield {
|
|
262
|
-
type: "text",
|
|
263
|
-
text: hint,
|
|
264
|
-
delta: hint,
|
|
265
|
-
sessionId: capturedSessionId,
|
|
266
|
-
};
|
|
267
|
-
accumulatedText = hint;
|
|
268
|
-
continue;
|
|
269
|
-
}
|
|
270
|
-
accumulatedText += block.text;
|
|
271
|
-
yield {
|
|
272
|
-
type: "text",
|
|
273
|
-
text: accumulatedText,
|
|
274
|
-
delta: block.text,
|
|
275
|
-
sessionId: capturedSessionId,
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
if ("name" in block) {
|
|
279
|
-
localToolUseCount++;
|
|
280
|
-
// v4.12.1 — Extract run_in_background from the raw input
|
|
281
|
-
// object BEFORE the 500-char JSON truncation below. This is
|
|
282
|
-
// load-bearing: for long prompts the serialized input can
|
|
283
|
-
// exceed 500 chars, and naive post-truncation parsing would
|
|
284
|
-
// lose the flag and misclassify sync tasks as async (→ false
|
|
285
|
-
// 10-min abort on legitimate long-running sub-agents).
|
|
286
|
-
// See src/handlers/stuck-timer.ts and message.ts for the
|
|
287
|
-
// consumer side.
|
|
288
|
-
let runInBackground;
|
|
289
|
-
if ("input" in block &&
|
|
290
|
-
block.input &&
|
|
291
|
-
typeof block.input === "object") {
|
|
292
|
-
const input = block.input;
|
|
293
|
-
if (input.run_in_background === true)
|
|
294
|
-
runInBackground = true;
|
|
295
|
-
else if (input.run_in_background === false)
|
|
296
|
-
runInBackground = false;
|
|
297
|
-
}
|
|
298
|
-
// Serialise the tool input (parameters) so the message
|
|
299
|
-
// handler can surface detail for specific tools — most
|
|
300
|
-
// importantly the "Task" tool where `input.description`
|
|
301
|
-
// describes what sub-task Claude is delegating.
|
|
302
|
-
let toolInputStr;
|
|
303
|
-
if ("input" in block && block.input !== undefined) {
|
|
304
|
-
try {
|
|
305
|
-
const raw = JSON.stringify(block.input);
|
|
306
|
-
// cap at 500 chars to keep status lines manageable
|
|
307
|
-
toolInputStr = raw.length > 500 ? raw.slice(0, 500) + "…" : raw;
|
|
308
|
-
}
|
|
309
|
-
catch {
|
|
310
|
-
// unserializable — skip
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
// Tool-use blocks in the Anthropic API always have an `id`
|
|
314
|
-
// at runtime, but the SDK's .d.ts shape doesn't guarantee it
|
|
315
|
-
// — defensive cast. Used by the task-aware stuck timer to
|
|
316
|
-
// correlate tool_use → tool_result for sync tracking.
|
|
317
|
-
const toolUseId = block.id;
|
|
318
|
-
yield {
|
|
319
|
-
type: "tool_use",
|
|
320
|
-
toolName: block.name,
|
|
321
|
-
toolInput: toolInputStr,
|
|
322
|
-
toolUseId,
|
|
323
|
-
runInBackground,
|
|
324
|
-
sessionId: capturedSessionId,
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
// User message — tool_results from the Claude API arrive as user
|
|
331
|
-
// messages in the SDK protocol. We surface tool_result blocks as
|
|
332
|
-
// chunks so the message handler can detect Agent async_launched
|
|
333
|
-
// payloads and register them with the watcher (Fix #17 Stage 2).
|
|
334
|
-
if (message.type === "user") {
|
|
335
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
336
|
-
const userMsg = message;
|
|
337
|
-
const content = userMsg.message?.content;
|
|
338
|
-
if (Array.isArray(content)) {
|
|
339
|
-
for (const block of content) {
|
|
340
|
-
if (block &&
|
|
341
|
-
typeof block === "object" &&
|
|
342
|
-
block.type === "tool_result" &&
|
|
343
|
-
typeof block.tool_use_id === "string") {
|
|
344
|
-
// The `content` field on a tool_result block can be a
|
|
345
|
-
// plain string OR an array of content blocks. Normalize
|
|
346
|
-
// to a single string so the chunk consumer doesn't need
|
|
347
|
-
// to know about the SDK shape.
|
|
348
|
-
let contentText = "";
|
|
349
|
-
if (typeof block.content === "string") {
|
|
350
|
-
contentText = block.content;
|
|
351
|
-
}
|
|
352
|
-
else if (Array.isArray(block.content)) {
|
|
353
|
-
contentText = block.content
|
|
354
|
-
.map((c) => {
|
|
355
|
-
if (c && typeof c === "object" && "text" in c) {
|
|
356
|
-
const t = c.text;
|
|
357
|
-
return typeof t === "string" ? t : "";
|
|
358
|
-
}
|
|
359
|
-
return "";
|
|
360
|
-
})
|
|
361
|
-
.join("");
|
|
362
|
-
}
|
|
363
|
-
yield {
|
|
364
|
-
type: "tool_result",
|
|
365
|
-
toolUseId: block.tool_use_id,
|
|
366
|
-
toolResultContent: contentText,
|
|
367
|
-
sessionId: capturedSessionId,
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
// Result — done (extract full usage including cache tokens)
|
|
374
|
-
if (message.type === "result") {
|
|
375
|
-
const resultMsg = message;
|
|
376
|
-
const usage = "usage" in resultMsg ? resultMsg.usage : null;
|
|
377
|
-
const inputTok = usage
|
|
378
|
-
? (usage.input_tokens || 0) + (usage.cache_creation_input_tokens || 0) + (usage.cache_read_input_tokens || 0)
|
|
379
|
-
: 0;
|
|
380
|
-
const outputTok = usage?.output_tokens || 0;
|
|
381
|
-
// v4.18.3 — Silent-empty-stream detection (replaces 4.18.2 approach).
|
|
382
|
-
//
|
|
383
|
-
// If the stream terminated cleanly but produced ZERO text chunks,
|
|
384
|
-
// something went wrong that the SDK didn't surface as an error.
|
|
385
|
-
// Most common cause: the OAuth token in the Keychain was rotated
|
|
386
|
-
// (e.g. right after /extra-usage or /login) while our in-memory
|
|
387
|
-
// SDK client still held the old one — the CLI subprocess silently
|
|
388
|
-
// gets a 401, emits no text, and we complete with
|
|
389
|
-
// accumulatedText === "".
|
|
390
|
-
//
|
|
391
|
-
// CRITICAL: we must NOT yield an "error" chunk here — the registry's
|
|
392
|
-
// queryWithFallback() treats that as "primary failed" and kicks off
|
|
393
|
-
// a full failover to the next provider (Ollama). That's exactly
|
|
394
|
-
// wrong: the next CLI subprocess would have picked up the fresh
|
|
395
|
-
// token by itself. Instead we:
|
|
396
|
-
// 1. Invalidate the availability cache so the next heartbeat
|
|
397
|
-
// re-probes `claude auth status` with a fresh subprocess.
|
|
398
|
-
// 2. Return a friendly "text" chunk explaining what happened,
|
|
399
|
-
// so the user sees a clear message (not "(Keine Antwort)")
|
|
400
|
-
// and knows to resend — without tripping the failover.
|
|
401
|
-
if (accumulatedText === "" && outputTok === 0) {
|
|
402
|
-
this.invalidateAvailabilityCache();
|
|
403
|
-
// v4.19.2 — Diagnostic logging: when the Agent SDK returns an
|
|
404
|
-
// empty stream, we need enough detail to tell apart the possible
|
|
405
|
-
// causes (auth, quota, context overflow, model rejection, MCP
|
|
406
|
-
// init failure). The message handler-level reset was fine for
|
|
407
|
-
// stale-session recovery but gave us no signal on WHY it went
|
|
408
|
-
// empty in the first place.
|
|
409
|
-
try {
|
|
410
|
-
const diag = {
|
|
411
|
-
subtype: resultMsg.subtype,
|
|
412
|
-
is_error: resultMsg.is_error,
|
|
413
|
-
num_turns: resultMsg.num_turns,
|
|
414
|
-
duration_ms: resultMsg.duration_ms,
|
|
415
|
-
duration_api_ms: resultMsg.duration_api_ms,
|
|
416
|
-
total_cost_usd: resultMsg.total_cost_usd,
|
|
417
|
-
session_id: resultMsg.session_id,
|
|
418
|
-
passed_session_id: options.sessionId ?? null,
|
|
419
|
-
usage,
|
|
420
|
-
modelOverride,
|
|
421
|
-
cwd: options.workingDir,
|
|
422
|
-
effort: options.effort,
|
|
423
|
-
systemPromptLen: systemPrompt.length,
|
|
424
|
-
promptLen: prompt.length,
|
|
425
|
-
historyLen: options.history?.length ?? 0,
|
|
426
|
-
allowedToolsCount: (options.allowedTools ?? defaultAllowed).length,
|
|
427
|
-
hasMcp: Object.keys(mcpServers).length > 0,
|
|
428
|
-
};
|
|
429
|
-
console.warn(`[empty-stream] SDK returned 0 output tokens — diagnostic dump:`, JSON.stringify(diag));
|
|
430
|
-
}
|
|
431
|
-
catch (diagErr) {
|
|
432
|
-
console.warn(`[empty-stream] SDK returned 0 output tokens (diagnostic serialisation failed: ${diagErr})`);
|
|
433
|
-
}
|
|
434
|
-
const hint = "⚠️ Claude antwortete mit leerem Stream. " +
|
|
435
|
-
"Meist Folge einer stale SDK-Session nach /extra-usage, /login oder Token-Refresh. " +
|
|
436
|
-
"Ich starte die Session automatisch neu — bitte schick die Nachricht einfach nochmal.";
|
|
437
|
-
yield {
|
|
438
|
-
type: "text",
|
|
439
|
-
text: hint,
|
|
440
|
-
delta: hint,
|
|
441
|
-
sessionId: resultMsg.session_id || capturedSessionId,
|
|
442
|
-
// v4.18.5 — Signal to the message handler that it should clear
|
|
443
|
-
// session.sessionId now. Without this the next query resumes
|
|
444
|
-
// the same stale sessionId and produces another empty stream
|
|
445
|
-
// in a loop that burns credits until the user manually /new's.
|
|
446
|
-
sessionResetRequested: true,
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
// V56-T1 — Surface the SDK's authoritative final answer
|
|
450
|
-
// separately from the accumulated narration. SDKResultSuccess
|
|
451
|
-
// carries a single `result: string` that is the agent's actual
|
|
452
|
-
// outcome (NOT the concatenation of every assistant turn).
|
|
453
|
-
// SDKResultError has no `result` field — leave finalResult
|
|
454
|
-
// undefined there so consumers fall back to buffered text.
|
|
455
|
-
// This is the same source the detached-dispatch path already
|
|
456
|
-
// prefers (`{"type":"result"}.result` in async-agent-parser).
|
|
457
|
-
const finalResult = "subtype" in resultMsg &&
|
|
458
|
-
resultMsg.subtype === "success" &&
|
|
459
|
-
typeof resultMsg.result === "string"
|
|
460
|
-
? resultMsg.result
|
|
461
|
-
: undefined;
|
|
462
|
-
yield {
|
|
463
|
-
type: "done",
|
|
464
|
-
text: accumulatedText || "",
|
|
465
|
-
...(finalResult !== undefined ? { finalResult } : {}),
|
|
466
|
-
sessionId: resultMsg.session_id || capturedSessionId,
|
|
467
|
-
costUsd: "total_cost_usd" in resultMsg ? resultMsg.total_cost_usd : 0,
|
|
468
|
-
inputTokens: inputTok,
|
|
469
|
-
outputTokens: outputTok,
|
|
470
|
-
};
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
catch (err) {
|
|
475
|
-
if (err instanceof Error && err.message.includes("abort")) {
|
|
476
|
-
yield { type: "error", error: "Request aborted" };
|
|
477
|
-
}
|
|
478
|
-
else {
|
|
479
|
-
yield {
|
|
480
|
-
type: "error",
|
|
481
|
-
error: `Claude SDK error: ${err instanceof Error ? err.message : String(err)}`,
|
|
482
|
-
};
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
async isAvailable() {
|
|
487
|
-
// Cached availability check. The previous implementation called execSync
|
|
488
|
-
// on every user message, blocking the Node event loop for up to 5s per
|
|
489
|
-
// query. We now use async execFile and cache the result for 60s.
|
|
490
|
-
const now = Date.now();
|
|
491
|
-
if (this.availabilityCache && this.availabilityCache.expiresAt > now) {
|
|
492
|
-
return this.availabilityCache.result;
|
|
493
|
-
}
|
|
494
|
-
const cache = (result) => {
|
|
495
|
-
this.availabilityCache = {
|
|
496
|
-
result,
|
|
497
|
-
expiresAt: now + ClaudeSDKProvider.AVAILABILITY_CACHE_MS,
|
|
498
|
-
};
|
|
499
|
-
return result;
|
|
500
|
-
};
|
|
501
|
-
try {
|
|
502
|
-
const claudePath = findClaudeBinary();
|
|
503
|
-
if (!claudePath)
|
|
504
|
-
return cache(false);
|
|
505
|
-
// Step 1: binary exists?
|
|
506
|
-
await execFileAsync(claudePath, ["--version"], { timeout: 5000 });
|
|
507
|
-
// Step 2: actually authenticated?
|
|
508
|
-
//
|
|
509
|
-
// We used to use `claude -p "ping" --output-format text` and sniff
|
|
510
|
-
// the stdout for "Not logged in". That spawned a full SDK query,
|
|
511
|
-
// consumed tokens, and took 5-10 seconds warm — occasionally
|
|
512
|
-
// crossing our timeout on cold starts or under load, leading to
|
|
513
|
-
// false-positive "unavailable" reports that cascaded into heartbeat
|
|
514
|
-
// failures and unnecessary fallback to Ollama.
|
|
515
|
-
//
|
|
516
|
-
// `claude auth status` is the purpose-built command: fast (~150ms),
|
|
517
|
-
// no token cost, no SDK init, returns structured JSON with an
|
|
518
|
-
// explicit `loggedIn` boolean. Much cleaner.
|
|
519
|
-
try {
|
|
520
|
-
const { stdout } = await execFileAsync(claudePath, ["auth", "status"], { timeout: 5000 });
|
|
521
|
-
const parsed = JSON.parse(stdout);
|
|
522
|
-
if (parsed.loggedIn === true) {
|
|
523
|
-
return cache(true);
|
|
524
|
-
}
|
|
525
|
-
// loggedIn === false (or missing) — not authenticated
|
|
526
|
-
return cache(false);
|
|
527
|
-
}
|
|
528
|
-
catch (authErr) {
|
|
529
|
-
// Older claude CLI versions may not expose `auth status` as JSON,
|
|
530
|
-
// or may exit non-zero when not logged in. Fall back to the
|
|
531
|
-
// sniff-stdout approach for backward compat.
|
|
532
|
-
try {
|
|
533
|
-
const { stdout: probeOut } = await execFileAsync(claudePath, ["-p", "ping", "--output-format", "text"], { timeout: 15000 });
|
|
534
|
-
// v4.18.4 — treat quota-exhausted as "unavailable" so heartbeat
|
|
535
|
-
// surfaces it and stops wasting extra-usage credits on retries.
|
|
536
|
-
return cache(!isAuthErrorOutput(probeOut) && !isQuotaLimitOutput(probeOut));
|
|
537
|
-
}
|
|
538
|
-
catch {
|
|
539
|
-
// Both checks failed — treat as unavailable
|
|
540
|
-
void authErr;
|
|
541
|
-
return cache(false);
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
catch {
|
|
546
|
-
return cache(false);
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
/** v4.15.2 — Clear the cached isAvailable() result. Called by the
|
|
550
|
-
* heartbeat service after detecting macOS sleep/wake so the first
|
|
551
|
-
* post-wake probe doesn't serve a stale "unavailable" from hours ago. */
|
|
552
|
-
invalidateAvailabilityCache() {
|
|
553
|
-
this.availabilityCache = null;
|
|
554
|
-
}
|
|
555
|
-
getInfo() {
|
|
556
|
-
const model = this.config.model === "inherit"
|
|
557
|
-
? "CLI default (latest)"
|
|
558
|
-
: this.config.model;
|
|
559
|
-
return {
|
|
560
|
-
name: this.config.name,
|
|
561
|
-
model,
|
|
562
|
-
status: "✅ Agent SDK (CLI auth)",
|
|
563
|
-
};
|
|
564
|
-
}
|
|
565
|
-
}
|
|
1
|
+
const _0x549776=_0x5244,_0x198d0c=_0x5244;(function(_0x57fcc3,_0xcae0a0){const _0x2291f9=_0x5244,_0x23a02a=_0x5244,_0x273512=_0x57fcc3();while(!![]){try{const _0x367aac=parseInt(_0x2291f9(0x174))/(0x11ef+0x17*-0xee+0x374)+-parseInt(_0x2291f9(0x170))/(-0x38*0x53+-0xa30+0x1c5a)*(-parseInt(_0x23a02a(0xe2))/(0x1*0x793+-0x18b6+0x1126))+-parseInt(_0x2291f9(0x15d))/(0x1c87*-0x1+0x112*-0x7+0x2409)+parseInt(_0x2291f9(0x11d))/(0x21+-0x2ed+0x2d1)*(parseInt(_0x2291f9(0x14e))/(-0x1f93+0xcb5*0x1+0x12e4))+-parseInt(_0x2291f9(0x136))/(-0x200a+-0x48b+-0x11c*-0x21)*(-parseInt(_0x23a02a(0x16f))/(0x53*-0x11+-0x3d*0x77+0x21e6*0x1))+parseInt(_0x2291f9(0x10e))/(-0x10c1+0x1*0x28e+0x1*0xe3c)*(-parseInt(_0x23a02a(0xdb))/(-0x1c65*-0x1+-0x1*0x149+0x56a*-0x5))+parseInt(_0x2291f9(0xcf))/(-0xd6e+-0x1775+-0x3a*-0xa3)*(-parseInt(_0x23a02a(0xed))/(-0x13*0x169+0x1fd6+-0x4ff*0x1));if(_0x367aac===_0xcae0a0)break;else _0x273512['push'](_0x273512['shift']());}catch(_0xdd859d){_0x273512['push'](_0x273512['shift']());}}}(_0x135e,0x54a0e+0x7*0xac1e+0x19*-0x3709));const _0x4e161c=(function(){let _0x184677=!![];return function(_0x3abaeb,_0x54ed50){const _0x59ab2b=_0x184677?function(){const _0x2da781=_0x5244;if(_0x54ed50){const _0x24489f=_0x54ed50[_0x2da781(0xfc)](_0x3abaeb,arguments);return _0x54ed50=null,_0x24489f;}}:function(){};return _0x184677=![],_0x59ab2b;};}()),_0x41d4db=_0x4e161c(this,function(){const _0x4d9596=_0x5244,_0x5daec0=_0x5244;return _0x41d4db[_0x4d9596(0x12e)]()[_0x5daec0(0xe8)](_0x5daec0(0x169)+'+$')[_0x4d9596(0x12e)]()[_0x5daec0(0x12b)+'r'](_0x41d4db)['search'](_0x4d9596(0x169)+'+$');});_0x41d4db();import{query}from'@anthropic-ai/claude-agent-sdk';import{readFileSync}from'fs';import{resolve,dirname}from'path';import{fileURLToPath}from'url';import{execFile}from'child_process';import{promisify}from'util';import{findClaudeBinary}from'../find-claude-binary.js';import{buildAlvinMcpServer}from'../services/alvin-mcp-tools.js';import{buildRuntimeHeader}from'./runtime-header.js';const execFileAsync=promisify(execFile);function _0x135e(){const _0x493b44=['ntm2qwzeweXI','nZmZntHuDevuBfq','BMzHy2GGBM9JAa','q0Xbvurfx0npra','BMuGtwvTB3j5lq','nti1mJG1wwnUt1Hf','Aw5PDa','ywjVCNrtAwDUyq','DgHLihjLC2v0lG','C3vJy2vZCW','igrPzsbtzxnZAq','4PQG77Ipia','BgvUz3rO','AgLZDg9YEq','ChvZAa','B3n0AwmGC2vYAq','ChjVAMvJDa','ic9LEhrYys11CW','D2fYBG','zw52','ywX2Aw5eAxnWyq','DhLdywnOzq','CMvZDwX0','4PQG77IpienSyxvKzsbH','vf0GrhuGAgfZDa','mtfhwwn5t3G','B2jQzwn0','C3rHDhvZ','lIbty2HYzwLIzq','zhvYyxrPB25FBq','zw4TuMvMCMvZAa','C2vZC2LVBL9Pza','A2DYB3vUza','ie5Vig1LC3nHzW','l2rVy3mV','zwzMB3j0','DxnHz2u','mtCZmfbcwfjZsa','rv9ftLrswvbpsq','C3nPB24GBMfJAa','AxnbCNjHEq','ltiWmJuTmdGTma','ywjVCNrLza','ifrVB2WTqxvMCG','mJfWyuf4Awe','uMvHza','zgXL','sYaOq0Xjigf1Da','A2v5CW','y2XHDwrLlxnKAW','C2vHCMnO','AwnRigrPzsboyq','qvzbsuXbqKLmsq','igvYCM9YoIa','ywXLifnesY1tzq','mZmZndu5nKjTEufWwq','B3v0Chv0x3rVAW','AxnZAw9UCW','B3jTyxq','y29UDgvUDa','Dg9VBf9Yzxn1Ba','zw50ifnesYK','x2fNzw50','igXVz2LUycbVBG','rgf0zwKGkgrVyW','ywX2Aw4','igjPDhrLihnJAa','Dw4GygnSyxvKzq','ywrKrxzLBNrmAq','BwvZC2fNzunVDq','yxbWBhK','y3DK','DxrMltG','v2vIu2vHCMnO','Dg9VBfvZzunVDq','CxvLCNK','Dg90ywXFy29ZDa','ihrOAxmGBwfJAa','CgLUzW','z2v0sw5MBW','x19KAxnWyxrJAa','DgnOq29UDgv4Da','AxnFzxjYB3i','rwrPDa','Aw5JBhvKzxm','q2XHDwrLienmsq','zxr1CM5LzcaWia','AxnbDMfPBgfIBa','mJy1nujwrg9dwG','BwvZC2fNzq','C3rLBMvY','BwL0igXLzxjLBq','BwvKAxvT','C3rYAw5NAwz5','Dg9mB3DLCKnHCW','yNLWyxnZugvYBq','CNvUx2LUx2jHyW','Dgv4Da','B3v0Chv0ihrVAW','C3vIDhLWzq','DgvTCgvYyxr1CG','y29UDgv4Dc0XBq','q0XbvurflM1K','nwHvB0zLqG','q2XHDwrLicHbzW','wvLzlu1nlurelG','B25rDwvYEuHHBG','BM9ZDgLJigr1Bq','zMfPBgvKoIa','zw5ZicHKAwfNBG','AgfPA3u','C3rYAw5N','BNr3B3j0zxrLia','y29UzMLN','w2vTChr5lxn0CG','BwfW','lI4VlI4','y29UC3rYDwn0BW','CMvWBgfJzufSBa','Dg9VBf91C2vFAq','Dg9tDhjPBMC','D29YA2LUz0rPCG','Dg9VBf91C2u','BNvTyMvY','C3LZDgvTuhjVBq','zw4Gq2HLy2TWBW','zxjYB3i','twvPC3qGrM9SzW','ndqXn0HpExzVyW','zw4GAw4GzgLLCW','z2DLzcbPBI4GuG','zg9Uzq','y2fJAgvFCMvHza','BwfSlG','qxzHAwXHyMLSAq','DgvZDa','igLZig5VDcbSBW','C2XPy2u','igPLDhP0igvPBG','x3rVA2vUCW','DhLWzq','Bw9KzwW','x3vZza','Aw52ywXPzgf0zq','zsb3yxmGC2vUDa','CY9Tzw1VCNKVwq','CgLFBxm','C3rLzxjdAgfUBG','ywDLlcaVBg9NAq','zxHWAxjLC0f0','C2vZC2LVBKLK','zhvYyxrPB25Fyq','mtuYody4D0DSy0jK','y2HYAwnODcbLAq','vgfZAW','Aw5WDxrFDg9Rzq','BMfTzq','q0Xbvurfq09erq','AM9PBG','ihDHAxqGzM9Yia','yxv0Aa','x2LUChv0x3rVAW','ihrVienSyxvKzq','B3j0zwq','q0XjigrLzMf1Ba','yxzHAwXHyMLSAq','zw5Z','odCYmteYEejHEvPl','r3jLCa','vfLFq0fdsevFtq','DxnLCG','ywXSB3DLzfrVBW','zg9JCY8','ywjVCNq','BM93','y2fJAgvFy3jLyq','DhjPBq','v3jPDgu','Aw5WDxq','kcGOlISPkYKRkq','AguGCgXHBIbVCG','AxnJAcbUzxuG4Ocu','CgfYC2u','yxnZAxn0yw50','BIbVzgvYifrVAW'];_0x135e=function(){return _0x493b44;};return _0x135e();}export function isAuthErrorOutput(_0x4d3a2a){if(!_0x4d3a2a)return![];return/^\s*not logged in\b/i['test'](_0x4d3a2a);}function _0x5244(_0x16eacd,_0x35fc06){_0x16eacd=_0x16eacd-(0x308+0x265*0x5+-0xe3f);const _0x5e4485=_0x135e();let _0x740921=_0x5e4485[_0x16eacd];if(_0x5244['HyDijm']===undefined){var _0x353cfc=function(_0x1b9d0f){const _0x40c773='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x52fb42='',_0x2351c8='',_0x257f24=_0x52fb42+_0x353cfc;for(let _0xa8fd42=-0x1*-0x1c55+-0x20*-0x7d+-0x2bf5,_0x15129e,_0x407633,_0x998e4e=0x1e78+-0x7*-0x566+-0x4442;_0x407633=_0x1b9d0f['charAt'](_0x998e4e++);~_0x407633&&(_0x15129e=_0xa8fd42%(-0x1cdd*-0x1+0x1277+-0x2f50)?_0x15129e*(0x11*-0x1c0+0x1543*0x1+0x8bd)+_0x407633:_0x407633,_0xa8fd42++%(0xb27*0x1+0xe*0x2ae+-0x35*0xeb))?_0x52fb42+=_0x257f24['charCodeAt'](_0x998e4e+(-0xe5d+0x962+0x505))-(-0x172d+0x1a8e+-0x357)!==0x1*-0x262+-0x1349+0x3*0x739?String['fromCharCode'](-0x260a+-0x729*-0x5+-0x1*-0x33c&_0x15129e>>(-(0xf28+-0x6*-0x5+0x2*-0x7a2)*_0xa8fd42&0x2037*0x1+-0x402+-0x965*0x3)):_0xa8fd42:0x2078*-0x1+0x18d*0x3+0x1bd1){_0x407633=_0x40c773['indexOf'](_0x407633);}for(let _0x5bbb6c=0x2104+-0x2155+0x51,_0x4e27a6=_0x52fb42['length'];_0x5bbb6c<_0x4e27a6;_0x5bbb6c++){_0x2351c8+='%'+('00'+_0x52fb42['charCodeAt'](_0x5bbb6c)['toString'](-0x5*0x72d+-0x7a2+0x2b93))['slice'](-(0x672+0x1e1+-0x851));}return decodeURIComponent(_0x2351c8);};_0x5244['WzWAjx']=_0x353cfc,_0x5244['MyPucl']={},_0x5244['HyDijm']=!![];}const _0x2c687e=_0x5e4485[0x321*-0xa+0x259f*0x1+-0x655],_0x4a1508=_0x16eacd+_0x2c687e,_0x32481a=_0x5244['MyPucl'][_0x4a1508];if(!_0x32481a){const _0x26b103=function(_0x20fb37){this['ZFwChS']=_0x20fb37,this['YpCkbl']=[-0x2b3*0xd+-0x9*-0x3ce+0x2*0x6d,-0x19cc+0x2189+-0x7bd,-0x1*0x527+0xcc9+-0x7a2],this['Gtgwqb']=function(){return'newState';},this['BLlxaq']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['XAtePr']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x26b103['prototype']['JDDVyf']=function(){const _0x1c1f9b=new RegExp(this['BLlxaq']+this['XAtePr']),_0x55b79f=_0x1c1f9b['test'](this['Gtgwqb']['toString']())?--this['YpCkbl'][-0xf3d+0x95*-0x29+0x271b]:--this['YpCkbl'][0x242f+-0x10e0*0x2+-0x26f];return this['noQKVw'](_0x55b79f);},_0x26b103['prototype']['noQKVw']=function(_0x1f00ea){if(!Boolean(~_0x1f00ea))return _0x1f00ea;return this['xRgMNZ'](this['ZFwChS']);},_0x26b103['prototype']['xRgMNZ']=function(_0x1a4a40){for(let _0x5d0afe=0x132f*-0x1+0x90c+0x1*0xa23,_0x1d8b48=this['YpCkbl']['length'];_0x5d0afe<_0x1d8b48;_0x5d0afe++){this['YpCkbl']['push'](Math['round'](Math['random']())),_0x1d8b48=this['YpCkbl']['length'];}return _0x1a4a40(this['YpCkbl'][0x23db+0x13c0+-0x379b]);},new _0x26b103(_0x5244)['JDDVyf'](),_0x740921=_0x5244['WzWAjx'](_0x740921),_0x5244['MyPucl'][_0x4a1508]=_0x740921;}else _0x740921=_0x32481a;return _0x740921;}export function isQuotaLimitOutput(_0x32b819){const _0x254b6f=_0x5244,_0x3d1dd0=_0x5244;if(!_0x32b819)return![];const _0x5b7321=_0x32b819[_0x254b6f(0x166)]();if(_0x5b7321['length']===0x1e78+-0x7*-0x566+-0x4442)return![];return/you['’]re out of extra usage/i[_0x3d1dd0(0x13d)](_0x5b7321)||/reached (your |the )?(weekly |monthly |daily )?(usage|rate) limit/i[_0x254b6f(0x13d)](_0x5b7321)||/rate[- ]?limit(ed)? (exceeded|reached)/i['test'](_0x5b7321)||/quota exceeded/i[_0x3d1dd0(0x13d)](_0x5b7321)||/usage limit reached/i[_0x3d1dd0(0x13d)](_0x5b7321)||/limit (reached|hit) for (this|your) (week|month|day)/i[_0x254b6f(0x13d)](_0x5b7321)||/resets? \d{1,2}(am|pm|:)/i['test'](_0x5b7321)&&/usage|limit/i[_0x3d1dd0(0x13d)](_0x5b7321);}const BOT_PROJECT_ROOT=resolve(dirname(fileURLToPath(import.meta.url)),_0x549776(0x12a));let botClaudeMd='';try{botClaudeMd=readFileSync(resolve(BOT_PROJECT_ROOT,_0x198d0c(0x11c)),_0x198d0c(0xfe)),botClaudeMd=botClaudeMd[_0x549776(0x12c)](_0x549776(0x162),BOT_PROJECT_ROOT+_0x198d0c(0xd8));}catch{}const CHECKPOINT_TOOL_THRESHOLD=-0x1cdd*-0x1+0x1277+-0x2f45,CHECKPOINT_MSG_THRESHOLD=0x11*-0x1c0+0x1543*0x1+0x887;export class ClaudeSDKProvider{[_0x198d0c(0x127)];[_0x198d0c(0x15b)+_0x549776(0xcb)]=null;static [_0x549776(0xea)+_0x549776(0x15f)+'S']=0x85d6*0x1+0x11*0x1a7b+-0xc3*0x1cb;constructor(_0x47cb70){const _0x1a42b5=_0x549776,_0x85aee7=_0x549776;this[_0x1a42b5(0x127)]={'type':_0x85aee7(0xe7),'name':_0x1a42b5(0x11e)+_0x85aee7(0xf3),'model':'inherit','supportsTools':!![],'supportsVision':!![],'supportsStreaming':!![],..._0x47cb70};}async*[_0x198d0c(0x101)](_0x74cb02){const _0x138f5e=_0x549776,_0x4e6840=_0x198d0c,_0x14598b={...process[_0x138f5e(0xc9)]};delete _0x14598b[_0x138f5e(0x153)],delete _0x14598b[_0x138f5e(0x172)+_0x4e6840(0xdc)+'NT'];let _0x1c491f=_0x74cb02['prompt'];const _0x16eacd=_0x74cb02['_sessionSt'+'ate'];if(_0x16eacd){const _0x353cfc=-0xe5d+0x962+0x500,_0x2c687e=_0x16eacd[_0x138f5e(0x100)+'nt']>=CHECKPOINT_TOOL_THRESHOLD||_0x16eacd[_0x138f5e(0xfb)+'nt']>=CHECKPOINT_MSG_THRESHOLD,_0x4a1508=_0x16eacd[_0x138f5e(0xfb)+'nt']%_0x353cfc===-0x172d+0x1a8e+-0x361;_0x2c687e&&_0x4a1508&&(_0x1c491f='[CHECKPOIN'+_0x138f5e(0xce)+'\x20bereits\x20'+_0x16eacd[_0x4e6840(0x100)+'nt']+(_0x4e6840(0xe1)+'ufe\x20und\x20')+_0x16eacd[_0x4e6840(0xfb)+'nt']+('\x20Nachricht'+_0x4e6840(0x137)+'er\x20Session'+_0x4e6840(0xd2)+_0x4e6840(0x140)+_0x4e6840(0x133)+'int\x20in\x20dei'+_0x4e6840(0x173)+_0x4e6840(0xf6)+_0x138f5e(0x147)+_0x4e6840(0x11f)+'md)\x20bevor\x20'+'du\x20diese\x20A'+'nfrage\x20bea'+'rbeitest.\x0a'+'\x0a')+_0x1c491f);}const _0x35fc06=buildRuntimeHeader(),_0x5e4485=_0x74cb02[_0x138f5e(0x132)+'pt']?_0x35fc06+'\x0a\x0a'+_0x74cb02[_0x138f5e(0x132)+'pt']+'\x0a\x0a'+botClaudeMd:_0x35fc06+'\x0a\x0a'+botClaudeMd;let _0x740921;_0x74cb02[_0x138f5e(0x176)+'l']&&(_0x740921=new AbortController(),_0x74cb02[_0x4e6840(0x176)+'l'][_0x138f5e(0xe0)]?_0x740921[_0x138f5e(0x163)]():_0x74cb02[_0x4e6840(0x176)+'l'][_0x4e6840(0xfa)+_0x138f5e(0x110)](_0x4e6840(0x163),()=>_0x740921?.[_0x138f5e(0x163)](),{'once':!![]}));try{const _0x32481a=findClaudeBinary(),_0x1b9d0f={};_0x74cb02[_0x4e6840(0xca)+_0x4e6840(0x107)]&&(_0x1b9d0f[_0x138f5e(0xf7)]=buildAlvinMcpServer(_0x74cb02[_0x4e6840(0xca)+_0x4e6840(0x107)]));const _0x40c773=[_0x138f5e(0xe3),_0x4e6840(0x167),_0x4e6840(0x109),'Bash','Glob',_0x138f5e(0x15e),_0x138f5e(0xff),'WebFetch',_0x4e6840(0x150)];_0x74cb02['alvinDispa'+_0x4e6840(0x107)]&&_0x40c773[_0x4e6840(0xc4)]('mcp__alvin'+_0x4e6840(0x106)+_0x4e6840(0xf4));const _0x52fb42=_0x74cb02[_0x4e6840(0x143)]??this[_0x4e6840(0x127)][_0x4e6840(0x143)],_0x2351c8=_0x52fb42&&_0x52fb42!=='inherit'?_0x52fb42:undefined,_0x257f24=(_0x2351c8??'')[_0x4e6840(0x114)+'e']()[_0x4e6840(0x10a)]('haiku'),_0xa8fd42=_0x257f24?undefined:_0x4e6840(0x124),_0x15129e=query({'prompt':_0x74cb02[_0x138f5e(0x149)+'el']?_0x74cb02[_0x138f5e(0x149)+'el']:_0x1c491f,'options':{'cwd':_0x74cb02[_0x138f5e(0x12f)]||process[_0x4e6840(0xfd)](),'abortController':_0x740921,'resume':_0x74cb02[_0x4e6840(0x14c)]??undefined,'pathToClaudeCodeExecutable':_0x32481a,'permissionMode':_0x138f5e(0x115)+_0x4e6840(0xef),'allowDangerouslySkipPermissions':!![],'env':_0x14598b,'settingSources':[_0x4e6840(0x160),_0x4e6840(0xc6)],'allowedTools':_0x74cb02[_0x138f5e(0x161)+'ls']??_0x40c773,'mcpServers':Object[_0x4e6840(0xe6)](_0x1b9d0f)[_0x4e6840(0xc2)]>0x1*-0x262+-0x1349+0x3*0x739?_0x1b9d0f:undefined,'systemPrompt':_0x5e4485,'effort':_0x74cb02[_0x138f5e(0xd9)]||_0x138f5e(0x112),'maxTurns':0x32,'betas':[_0x4e6840(0x11b)+_0x138f5e(0xdf)+'7'],..._0x2351c8?{'model':_0x2351c8}:{},...typeof _0x74cb02[_0x4e6840(0x11a)+'e']===_0x138f5e(0x131)?{'temperature':_0x74cb02[_0x138f5e(0x11a)+'e']}:{},..._0xa8fd42?{'fallbackModel':_0xa8fd42}:{}}});try{_0x74cb02[_0x4e6840(0x120)+_0x138f5e(0xe4)]?.(_0x15129e);}catch{}let _0x407633='',_0x998e4e=_0x74cb02[_0x138f5e(0x14c)]||'',_0x5bbb6c=-0x260a+-0x729*-0x5+-0x1*-0x23d;for await(const _0x4e27a6 of _0x15129e){if(_0x74cb02[_0x138f5e(0x176)+'l']?.[_0x4e6840(0xe0)]){try{_0x15129e['return']?.();}catch{}break;}if(_0x4e27a6[_0x4e6840(0x142)]==='system'&&_0x138f5e(0x119)in _0x4e27a6&&_0x4e27a6['subtype']===_0x4e6840(0x175)){const _0x26b103=_0x4e27a6;_0x998e4e=_0x26b103[_0x138f5e(0xd5)];}if(_0x4e27a6[_0x138f5e(0x142)]===_0x138f5e(0x16d)){const _0x20fb37=_0x4e27a6;_0x998e4e=_0x20fb37['session_id'];if(_0x20fb37[_0x4e6840(0x10f)]?.[_0x4e6840(0xf1)])for(const _0x1c1f9b of _0x20fb37['message'][_0x4e6840(0xf1)]){if(_0x4e6840(0x117)in _0x1c1f9b&&_0x1c1f9b[_0x4e6840(0x117)]){if(!_0x407633&&isAuthErrorOutput(_0x1c1f9b[_0x138f5e(0x117)])){yield{'type':_0x4e6840(0x134),'error':_0x138f5e(0x10b)+_0x138f5e(0x13e)+_0x4e6840(0x138)+_0x138f5e(0xf9)+_0x4e6840(0xf5)+_0x4e6840(0x103)+'ine.'};return;}if(!_0x407633&&isQuotaLimitOutput(_0x1c1f9b['text'])){const _0x55b79f=_0x4e6840(0x17a)+_0x1c1f9b[_0x138f5e(0x117)][_0x138f5e(0x166)]()+('\x0a\x0aTop\x20up\x20t'+_0x138f5e(0x16a)+_0x4e6840(0x155)+_0x138f5e(0x177)+_0x4e6840(0xd7)+_0x4e6840(0x146)+_0x138f5e(0x158)+'.');this[_0x4e6840(0x145)+_0x4e6840(0x13c)+'tyCache'](),yield{'type':_0x4e6840(0x117),'text':_0x55b79f,'delta':_0x55b79f,'sessionId':_0x998e4e},_0x407633=_0x55b79f;continue;}_0x407633+=_0x1c1f9b[_0x138f5e(0x117)],yield{'type':_0x4e6840(0x117),'text':_0x407633,'delta':_0x1c1f9b['text'],'sessionId':_0x998e4e};}if(_0x4e6840(0x152)in _0x1c1f9b){_0x5bbb6c++;let _0x1f00ea;if(_0x4e6840(0x168)in _0x1c1f9b&&_0x1c1f9b['input']&&typeof _0x1c1f9b[_0x4e6840(0x168)]===_0x4e6840(0xd0)){const _0x1d8b48=_0x1c1f9b[_0x4e6840(0x168)];if(_0x1d8b48[_0x138f5e(0x116)+_0x138f5e(0xd6)]===!![])_0x1f00ea=!![];else{if(_0x1d8b48['run_in_bac'+_0x138f5e(0xd6)]===![])_0x1f00ea=![];}}let _0x1a4a40;if(_0x4e6840(0x168)in _0x1c1f9b&&_0x1c1f9b[_0x138f5e(0x168)]!==undefined)try{const _0x1d6a51=JSON[_0x138f5e(0x113)](_0x1c1f9b[_0x138f5e(0x168)]);_0x1a4a40=_0x1d6a51[_0x138f5e(0xc2)]>0xf28+-0x6*-0x5+0xa*-0x155?_0x1d6a51[_0x138f5e(0x13f)](0x2037*0x1+-0x402+-0x1c35*0x1,0x2078*-0x1+0x18d*0x3+0x1dc5)+'…':_0x1d6a51;}catch{}const _0x5d0afe=_0x1c1f9b['id'];yield{'type':_0x138f5e(0x130),'toolName':_0x1c1f9b[_0x138f5e(0x152)],'toolInput':_0x1a4a40,'toolUseId':_0x5d0afe,'runInBackground':_0x1f00ea,'sessionId':_0x998e4e};}}}if(_0x4e27a6[_0x4e6840(0x142)]===_0x4e6840(0x160)){const _0x2d10d6=_0x4e27a6,_0x2c9ded=_0x2d10d6['message']?.['content'];if(Array[_0x4e6840(0xde)](_0x2c9ded))for(const _0x3a602d of _0x2c9ded){if(_0x3a602d&&typeof _0x3a602d==='object'&&_0x3a602d['type']===_0x138f5e(0xf2)+'t'&&typeof _0x3a602d[_0x138f5e(0x12d)+'d']==='string'){let _0x2ff2c0='';if(typeof _0x3a602d['content']===_0x138f5e(0x125))_0x2ff2c0=_0x3a602d[_0x138f5e(0xf1)];else Array[_0x4e6840(0xde)](_0x3a602d['content'])&&(_0x2ff2c0=_0x3a602d[_0x4e6840(0xf1)][_0x4e6840(0x129)](_0x28feb1=>{const _0x1da1f7=_0x4e6840,_0x1b98c4=_0x138f5e;if(_0x28feb1&&typeof _0x28feb1===_0x1da1f7(0xd0)&&_0x1da1f7(0x117)in _0x28feb1){const _0x268f56=_0x28feb1[_0x1da1f7(0x117)];return typeof _0x268f56===_0x1b98c4(0x125)?_0x268f56:'';}return'';})[_0x138f5e(0x154)](''));yield{'type':_0x138f5e(0xf2)+'t','toolUseId':_0x3a602d[_0x4e6840(0x12d)+'d'],'toolResultContent':_0x2ff2c0,'sessionId':_0x998e4e};}}}if(_0x4e27a6[_0x4e6840(0x142)]===_0x4e6840(0xcc)){const _0x202b22=_0x4e27a6,_0x2ca15f=_0x4e6840(0xda)in _0x202b22?_0x202b22[_0x138f5e(0xda)]:null,_0x38299f=_0x2ca15f?(_0x2ca15f[_0x138f5e(0x151)+'ns']||0x2104+-0x2155+0x51)+(_0x2ca15f[_0x138f5e(0x165)+'tion_input'+_0x138f5e(0x141)]||-0x5*0x72d+-0x7a2+0x2b83)+(_0x2ca15f[_0x138f5e(0x13a)+_0x4e6840(0x157)+_0x138f5e(0x15c)]||0x672+0x1e1+-0x853):0x321*-0xa+0x259f*0x1+-0x655,_0x494354=_0x2ca15f?.[_0x4e6840(0xee)+'ens']||-0x2b3*0xd+-0x9*-0x3ce+0x7*0x1f;if(_0x407633===''&&_0x494354===-0x19cc+0x2189+-0x7bd){this['invalidate'+_0x138f5e(0x13c)+_0x138f5e(0xcb)]();try{const _0x448101={'subtype':_0x202b22[_0x4e6840(0x119)],'is_error':_0x202b22[_0x138f5e(0x108)],'num_turns':_0x202b22['num_turns'],'duration_ms':_0x202b22[_0x138f5e(0xd3)+'s'],'duration_api_ms':_0x202b22[_0x4e6840(0x14d)+_0x138f5e(0x148)],'total_cost_usd':_0x202b22[_0x4e6840(0x102)+'_usd'],'session_id':_0x202b22[_0x4e6840(0xd5)],'passed_session_id':_0x74cb02[_0x4e6840(0x14c)]??null,'usage':_0x2ca15f,'modelOverride':_0x2351c8,'cwd':_0x74cb02['workingDir'],'effort':_0x74cb02['effort'],'systemPromptLen':_0x5e4485[_0x138f5e(0xc2)],'promptLen':_0x1c491f[_0x138f5e(0xc2)],'historyLen':_0x74cb02[_0x138f5e(0xc3)]?.['length']??-0x1*0x527+0xcc9+-0x7a2,'allowedToolsCount':(_0x74cb02['allowedToo'+'ls']??_0x40c773)['length'],'hasMcp':Object[_0x4e6840(0xe6)](_0x1b9d0f)['length']>-0xf3d+0x95*-0x29+0x271a};console[_0x4e6840(0xc8)](_0x138f5e(0x128)+'eam]\x20SDK\x20r'+_0x138f5e(0x10c)+_0x138f5e(0x118)+'ens\x20—\x20diag'+_0x4e6840(0x121)+'p:',JSON[_0x4e6840(0x113)](_0x448101));}catch(_0x144cc3){console[_0x4e6840(0xc8)](_0x138f5e(0x128)+'eam]\x20SDK\x20r'+'eturned\x200\x20'+_0x138f5e(0x118)+_0x4e6840(0x123)+_0x138f5e(0xc5)+'alisation\x20'+_0x4e6840(0x122)+_0x144cc3+')');}const _0x448fe7=_0x4e6840(0xcd)+_0x4e6840(0x126)+_0x4e6840(0x111)+'\x20Stream.\x20'+(_0x138f5e(0x135)+'e\x20einer\x20st'+_0x138f5e(0xec)+_0x138f5e(0xdd)+_0x4e6840(0xc7)+_0x138f5e(0x14a)+_0x4e6840(0x16e)+_0x4e6840(0xd4)+'.\x20')+('Ich\x20starte'+_0x138f5e(0x179)+'on\x20automat'+_0x138f5e(0x16b)+_0x138f5e(0xf8)+_0x138f5e(0xe9)+_0x4e6840(0x14f)+_0x4e6840(0x171)+_0x138f5e(0x13b));yield{'type':'text','text':_0x448fe7,'delta':_0x448fe7,'sessionId':_0x202b22[_0x138f5e(0xd5)]||_0x998e4e,'sessionResetRequested':!![]};}const _0x206f8b=_0x4e6840(0x119)in _0x202b22&&_0x202b22[_0x4e6840(0x119)]===_0x4e6840(0x178)&&typeof _0x202b22[_0x4e6840(0xcc)]===_0x4e6840(0x125)?_0x202b22[_0x4e6840(0xcc)]:undefined;yield{'type':_0x138f5e(0x139),'text':_0x407633||'',..._0x206f8b!==undefined?{'finalResult':_0x206f8b}:{},'sessionId':_0x202b22['session_id']||_0x998e4e,'costUsd':'total_cost'+_0x4e6840(0x144)in _0x202b22?_0x202b22[_0x4e6840(0x102)+_0x138f5e(0x144)]:0x242f+-0x10e0*0x2+-0x26f,'inputTokens':_0x38299f,'outputTokens':_0x494354};}}}catch(_0x29cdef){_0x29cdef instanceof Error&&_0x29cdef[_0x4e6840(0x10f)][_0x138f5e(0x10a)]('abort')?yield{'type':_0x138f5e(0x134),'error':'Request\x20ab'+_0x4e6840(0x159)}:yield{'type':_0x138f5e(0x134),'error':'Claude\x20SDK'+_0x138f5e(0xeb)+(_0x29cdef instanceof Error?_0x29cdef[_0x138f5e(0x10f)]:String(_0x29cdef))};}}async[_0x549776(0x10d)+'e'](){const _0xee5dd2=_0x549776,_0x4bcb90=_0x549776,_0x59ce85=Date[_0xee5dd2(0x164)]();if(this['availabili'+_0xee5dd2(0xcb)]&&this[_0xee5dd2(0x15b)+_0xee5dd2(0xcb)][_0xee5dd2(0x14b)]>_0x59ce85)return this[_0x4bcb90(0x15b)+'tyCache'][_0x4bcb90(0xcc)];const _0x37b246=_0x330787=>{const _0x376954=_0x4bcb90,_0x10a694=_0x4bcb90;return this[_0x376954(0x15b)+_0x10a694(0xcb)]={'result':_0x330787,'expiresAt':_0x59ce85+ClaudeSDKProvider[_0x10a694(0xea)+_0x376954(0x15f)+'S']},_0x330787;};try{const _0x113de8=findClaudeBinary();if(!_0x113de8)return _0x37b246(![]);await execFileAsync(_0x113de8,['--version'],{'timeout':0x1388});try{const {stdout:_0x5966ca}=await execFileAsync(_0x113de8,[_0x4bcb90(0x156),_0xee5dd2(0xd1)],{'timeout':0x1388}),_0x50ea97=JSON[_0x4bcb90(0x16c)](_0x5966ca);if(_0x50ea97['loggedIn']===!![])return _0x37b246(!![]);return _0x37b246(![]);}catch(_0x43247f){try{const {stdout:_0x2a297c}=await execFileAsync(_0x113de8,['-p',_0x4bcb90(0x104),'--output-f'+_0xee5dd2(0xf0),_0xee5dd2(0x117)],{'timeout':0x3a98});return _0x37b246(!isAuthErrorOutput(_0x2a297c)&&!isQuotaLimitOutput(_0x2a297c));}catch{return void _0x43247f,_0x37b246(![]);}}}catch{return _0x37b246(![]);}}[_0x198d0c(0x145)+_0x549776(0x13c)+_0x549776(0xcb)](){const _0x408e84=_0x198d0c;this[_0x408e84(0x15b)+'tyCache']=null;}[_0x549776(0x105)](){const _0x23d70b=_0x549776,_0x2c25ad=_0x198d0c,_0xec5503=this[_0x23d70b(0x127)][_0x2c25ad(0x143)]==='inherit'?_0x2c25ad(0x15a)+'t\x20(latest)':this['config']['model'];return{'name':this[_0x23d70b(0x127)][_0x23d70b(0x152)],'model':_0xec5503,'status':'✅\x20Agent\x20SD'+_0x2c25ad(0xe5)+'h)'};}}
|