Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ClaudeProvider.ts

745 lines22.8 KB

1import type {
2 ClaudeSettings,
3 ModelCapabilities,
4 ServerProvider,
5 ServerProviderModel,
6 ServerProviderAuth,
7 ServerProviderSlashCommand,
8 ServerProviderState,
9} from "@t3tools/contracts";
10import { Cache, Duration, Effect, Equal, Layer, Option, Result, Schema, Stream } from "effect";
11import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
12import { decodeJsonResult } from "@t3tools/shared/schemaJson";
13import {
14 query as claudeQuery,
15 type SlashCommand as ClaudeSlashCommand,
16} from "@anthropic-ai/claude-agent-sdk";
17​
18import {
19 buildServerProvider,
20 DEFAULT_TIMEOUT_MS,
21 detailFromResult,
22 extractAuthBoolean,
23 isCommandMissingCause,
24 parseGenericCliVersion,
25 providerModelsFromSettings,
26 spawnAndCollect,
27 type CommandResult,
28} from "../providerSnapshot";
29import { makeManagedServerProvider } from "../makeManagedServerProvider";
30import { ClaudeProvider } from "../Services/ClaudeProvider";
31import { ServerSettingsService } from "../../serverSettings";
32import { ServerSettingsError } from "@t3tools/contracts";
33​
34const DEFAULT_CLAUDE_MODEL_CAPABILITIES: ModelCapabilities = {
35 reasoningEffortLevels: [],
36 supportsFastMode: false,
37 supportsThinkingToggle: false,
38 contextWindowOptions: [],
39 promptInjectedEffortLevels: [],
40};
41​
42const PROVIDER = "claudeAgent" as const;
43const BUILT_IN_MODELS: ReadonlyArray<ServerProviderModel> = [
44 {
45 slug: "claude-opus-4-6",
46 name: "Claude Opus 4.6",
47 isCustom: false,
48 capabilities: {
49 reasoningEffortLevels: [
50 { value: "low", label: "Low" },
51 { value: "medium", label: "Medium" },
52 { value: "high", label: "High", isDefault: true },
53 { value: "max", label: "Max" },
54 { value: "ultrathink", label: "Ultrathink" },
55 ],
56 supportsFastMode: true,
57 supportsThinkingToggle: false,
58 contextWindowOptions: [
59 { value: "200k", label: "200k", isDefault: true },
60 { value: "1m", label: "1M" },
61 ],
62 promptInjectedEffortLevels: ["ultrathink"],
63 } satisfies ModelCapabilities,
64 },
65 {
66 slug: "claude-sonnet-4-6",
67 name: "Claude Sonnet 4.6",
68 isCustom: false,
69 capabilities: {
70 reasoningEffortLevels: [
71 { value: "low", label: "Low" },
72 { value: "medium", label: "Medium" },
73 { value: "high", label: "High", isDefault: true },
74 { value: "ultrathink", label: "Ultrathink" },
75 ],
76 supportsFastMode: false,
77 supportsThinkingToggle: false,
78 contextWindowOptions: [
79 { value: "200k", label: "200k", isDefault: true },
80 { value: "1m", label: "1M" },
81 ],
82 promptInjectedEffortLevels: ["ultrathink"],
83 } satisfies ModelCapabilities,
84 },
85 {
86 slug: "claude-haiku-4-5",
87 name: "Claude Haiku 4.5",
88 isCustom: false,
89 capabilities: {
90 reasoningEffortLevels: [],
91 supportsFastMode: false,
92 supportsThinkingToggle: true,
93 contextWindowOptions: [],
94 promptInjectedEffortLevels: [],
95 } satisfies ModelCapabilities,
96 },
97];
98​
99export function getClaudeModelCapabilities(model: string | null | undefined): ModelCapabilities {
100 const slug = model?.trim();
101 return (
102 BUILT_IN_MODELS.find((candidate) => candidate.slug === slug)?.capabilities ??
103 DEFAULT_CLAUDE_MODEL_CAPABILITIES
104 );
106​
107export function parseClaudeAuthStatusFromOutput(result: CommandResult): {
108 readonly status: Exclude<ServerProviderState, "disabled">;
109 readonly auth: Pick<ServerProviderAuth, "status">;
110 readonly message?: string;
111} {
112 const lowerOutput = `${result.stdout}\n${result.stderr}`.toLowerCase();
113​
114 if (
115 lowerOutput.includes("unknown command") ||
116 lowerOutput.includes("unrecognized command") ||
117 lowerOutput.includes("unexpected argument")
118 ) {
119 return {
120 status: "warning",
121 auth: { status: "unknown" },
122 message:
123 "Claude Agent authentication status command is unavailable in this version of Claude.",
124 };
125 }
126​
127 if (
128 lowerOutput.includes("not logged in") ||
129 lowerOutput.includes("login required") ||
130 lowerOutput.includes("authentication required") ||
131 lowerOutput.includes("run `claude login`") ||
132 lowerOutput.includes("run claude login")
133 ) {
134 return {
135 status: "error",
136 auth: { status: "unauthenticated" },
137 message: "Claude is not authenticated. Run `claude auth login` and try again.",
138 };
139 }
140​
141 const parsedAuth = (() => {
142 const trimmed = result.stdout.trim();
143 if (!trimmed || (!trimmed.startsWith("{") && !trimmed.startsWith("["))) {
144 return { attemptedJsonParse: false as const, auth: undefined as boolean | undefined };
145 }
146 try {
147 return {
148 attemptedJsonParse: true as const,
149 auth: extractAuthBoolean(JSON.parse(trimmed)),
150 };
151 } catch {
152 return { attemptedJsonParse: false as const, auth: undefined as boolean | undefined };
153 }
154 })();
155​
156 if (parsedAuth.auth === true) {
157 return { status: "ready", auth: { status: "authenticated" } };
158 }
159 if (parsedAuth.auth === false) {
160 return {
161 status: "error",
162 auth: { status: "unauthenticated" },
163 message: "Claude is not authenticated. Run `claude auth login` and try again.",
164 };
165 }
166 if (parsedAuth.attemptedJsonParse) {
167 return {
168 status: "warning",
169 auth: { status: "unknown" },
170 message:
171 "Could not verify Claude authentication status from JSON output (missing auth marker).",
172 };
173 }
174 if (result.code === 0) {
175 return { status: "ready", auth: { status: "authenticated" } };
176 }
177​
178 const detail = detailFromResult(result);
179 return {
180 status: "warning",
181 auth: { status: "unknown" },
182 message: detail
183 ? `Could not verify Claude authentication status. ${detail}`
184 : "Could not verify Claude authentication status.",
185 };
187​
188// ── Subscription type detection ─────────────────────────────────────
189//
190// The SDK probe returns typed `AccountInfo.subscriptionType` directly.
191// This walker is a best-effort fallback for the `claude auth status`
192// JSON output whose shape is not guaranteed.
193​
194/** Keys that directly hold a subscription/plan identifier. */
195const SUBSCRIPTION_TYPE_KEYS = [
196 "subscriptionType",
197 "subscription_type",
198 "plan",
199 "tier",
200 "planType",
201 "plan_type",
202] as const;
203​
204/** Keys whose value may be a nested object containing subscription info. */
205const SUBSCRIPTION_CONTAINER_KEYS = ["account", "subscription", "user", "billing"] as const;
206const AUTH_METHOD_KEYS = ["authMethod", "auth_method"] as const;
207const AUTH_METHOD_CONTAINER_KEYS = ["auth", "account", "session"] as const;
208​
209/** Lift an unknown value into `Option<string>` if it is a non-empty string. */
210const asNonEmptyString = (v: unknown): Option.Option<string> =>
211 typeof v === "string" && v.length > 0 ? Option.some(v) : Option.none();
212​
213/** Lift an unknown value into `Option<Record>` if it is a plain object. */
214const asRecord = (v: unknown): Option.Option<Record<string, unknown>> =>
215 typeof v === "object" && v !== null && !globalThis.Array.isArray(v)
216 ? Option.some(v as Record<string, unknown>)
217 : Option.none();
218​
219/**
220 * Walk an unknown parsed JSON value looking for a subscription/plan
221 * identifier, returning the first match as an `Option`.
222 */
223function findSubscriptionType(value: unknown): Option.Option<string> {
224 if (globalThis.Array.isArray(value)) {
225 return Option.firstSomeOf(value.map(findSubscriptionType));
226 }
227​
228 return asRecord(value).pipe(
229 Option.flatMap((record) => {
230 const direct = Option.firstSomeOf(
231 SUBSCRIPTION_TYPE_KEYS.map((key) => asNonEmptyString(record[key])),
232 );
233 if (Option.isSome(direct)) return direct;
234​
235 return Option.firstSomeOf(
236 SUBSCRIPTION_CONTAINER_KEYS.map((key) =>
237 asRecord(record[key]).pipe(Option.flatMap(findSubscriptionType)),
238 ),
239 );
240 }),
241 );
243​
244function findAuthMethod(value: unknown): Option.Option<string> {
245 if (globalThis.Array.isArray(value)) {
246 return Option.firstSomeOf(value.map(findAuthMethod));
247 }
248​
249 return asRecord(value).pipe(
250 Option.flatMap((record) => {
251 const direct = Option.firstSomeOf(
252 AUTH_METHOD_KEYS.map((key) => asNonEmptyString(record[key])),
253 );
254 if (Option.isSome(direct)) return direct;
255​
256 return Option.firstSomeOf(
257 AUTH_METHOD_CONTAINER_KEYS.map((key) =>
258 asRecord(record[key]).pipe(Option.flatMap(findAuthMethod)),
259 ),
260 );
261 }),
262 );
264​
265/**
266 * Try to extract a subscription type from the `claude auth status` JSON
267 * output. This is a zero-cost operation on data we already have.
268 */
269const decodeUnknownJson = decodeJsonResult(Schema.Unknown);
270​
271function extractSubscriptionTypeFromOutput(result: CommandResult): string | undefined {
272 const parsed = decodeUnknownJson(result.stdout.trim());
273 if (Result.isFailure(parsed)) return undefined;
274 return Option.getOrUndefined(findSubscriptionType(parsed.success));
276​
277function extractClaudeAuthMethodFromOutput(result: CommandResult): string | undefined {
278 const parsed = decodeUnknownJson(result.stdout.trim());
279 if (Result.isFailure(parsed)) return undefined;
280 return Option.getOrUndefined(findAuthMethod(parsed.success));
282​
283function toTitleCaseWords(value: string): string {
284 return value
285 .split(/[\s_-]+/g)
286 .filter(Boolean)
287 .map((part) => part[0]!.toUpperCase() + part.slice(1).toLowerCase())
288 .join(" ");
290​
291function claudeSubscriptionLabel(subscriptionType: string | undefined): string | undefined {
292 const normalized = subscriptionType?.toLowerCase().replace(/[\s_-]+/g, "");
293 if (!normalized) return undefined;
294​
295 switch (normalized) {
296 case "max":
297 case "maxplan":
298 case "max5":
299 case "max20":
300 return "Max";
301 case "enterprise":
302 return "Enterprise";
303 case "team":
304 return "Team";
305 case "pro":
306 return "Pro";
307 case "free":
308 return "Free";
309 default:
310 return toTitleCaseWords(subscriptionType!);
311 }
313​
314function normalizeClaudeAuthMethod(authMethod: string | undefined): string | undefined {
315 const normalized = authMethod?.toLowerCase().replace(/[\s_-]+/g, "");
316 if (!normalized) return undefined;
317 if (normalized === "apikey") return "apiKey";
318 return undefined;
320​
321function claudeAuthMetadata(input: {
322 readonly subscriptionType: string | undefined;
323 readonly authMethod: string | undefined;
324}): { readonly type: string; readonly label: string } | undefined {
325 if (normalizeClaudeAuthMethod(input.authMethod) === "apiKey") {
326 return {
327 type: "apiKey",
328 label: "Claude API Key",
329 };
330 }
331​
332 if (input.subscriptionType) {
333 const subscriptionLabel = claudeSubscriptionLabel(input.subscriptionType);
334 return {
335 type: input.subscriptionType,
336 label: `Claude ${subscriptionLabel ?? toTitleCaseWords(input.subscriptionType)} Subscription`,
337 };
338 }
339​
340 return undefined;
342​
343// ── SDK capability probe ────────────────────────────────────────────
344​
345const CAPABILITIES_PROBE_TIMEOUT_MS = 8_000;
346​
347function nonEmptyProbeString(value: string): string | undefined {
348 const candidate = value.trim();
349 return candidate ? candidate : undefined;
351​
352function parseClaudeInitializationCommands(
353 commands: ReadonlyArray<ClaudeSlashCommand> | undefined,
354): ReadonlyArray<ServerProviderSlashCommand> {
355 return dedupeSlashCommands(
356 (commands ?? []).flatMap((command) => {
357 const name = nonEmptyProbeString(command.name);
358 if (!name) {
359 return [];
360 }
361​
362 const description = nonEmptyProbeString(command.description);
363 const argumentHint = nonEmptyProbeString(command.argumentHint);
364​
365 return [
366 {
367 name,
368 ...(description ? { description } : {}),
369 ...(argumentHint ? { input: { hint: argumentHint } } : {}),
370 } satisfies ServerProviderSlashCommand,
371 ];
372 }),
373 );
375​
376function dedupeSlashCommands(
377 commands: ReadonlyArray<ServerProviderSlashCommand>,
378): ReadonlyArray<ServerProviderSlashCommand> {
379 const commandsByName = new Map<string, ServerProviderSlashCommand>();
380​
381 for (const command of commands) {
382 const name = nonEmptyProbeString(command.name);
383 if (!name) {
384 continue;
385 }
386​
387 const key = name.toLowerCase();
388 const existing = commandsByName.get(key);
389 if (!existing) {
390 commandsByName.set(key, {
391 ...command,
392 name,
393 });
394 continue;
395 }
396​
397 commandsByName.set(key, {
398 ...existing,
399 ...(existing.description
400 ? {}
401 : command.description
402 ? { description: command.description }
403 : {}),
404 ...(existing.input?.hint
405 ? {}
406 : command.input?.hint
407 ? { input: { hint: command.input.hint } }
408 : {}),
409 });
410 }
411​
412 return [...commandsByName.values()];
414​
415/**
416 * Probe account information by spawning a lightweight Claude Agent SDK
417 * session and reading the initialization result.
418 *
419 * The prompt is never sent to the Anthropic API — we abort immediately
420 * after the local initialization phase completes. This gives us the
421 * user's subscription type without incurring any token cost.
422 *
423 * This is used as a fallback when `claude auth status` does not include
424 * subscription type information.
425 */
426const probeClaudeCapabilities = (binaryPath: string) => {
427 const abort = new AbortController();
428 return Effect.tryPromise(async () => {
429 const q = claudeQuery({
430 prompt: ".",
431 options: {
432 persistSession: false,
433 pathToClaudeCodeExecutable: binaryPath,
434 abortController: abort,
435 maxTurns: 0,
436 settingSources: ["user", "project", "local"],
437 allowedTools: [],
438 stderr: () => {},
439 },
440 });
441 const init = await q.initializationResult();
442 return {
443 subscriptionType: init.account?.subscriptionType,
444 slashCommands: parseClaudeInitializationCommands(init.commands),
445 };
446 }).pipe(
447 Effect.ensuring(
448 Effect.sync(() => {
449 if (!abort.signal.aborted) abort.abort();
450 }),
451 ),
452 Effect.timeoutOption(CAPABILITIES_PROBE_TIMEOUT_MS),
453 Effect.result,
454 Effect.map((result) => {
455 if (Result.isFailure(result)) return undefined;
456 return Option.isSome(result.success) ? result.success.value : undefined;
457 }),
458 );
459};
460​
461const runClaudeCommand = Effect.fn("runClaudeCommand")(function* (args: ReadonlyArray<string>) {
462 const claudeSettings = yield* Effect.service(ServerSettingsService).pipe(
463 Effect.flatMap((service) => service.getSettings),
464 Effect.map((settings) => settings.providers.claudeAgent),
465 );
466 const command = ChildProcess.make(claudeSettings.binaryPath, [...args], {
467 shell: process.platform === "win32",
468 });
469 return yield* spawnAndCollect(claudeSettings.binaryPath, command);
470});
471​
472export const checkClaudeProviderStatus = Effect.fn("checkClaudeProviderStatus")(function* (
473 resolveSubscriptionType?: (binaryPath: string) => Effect.Effect<string | undefined>,
474 resolveSlashCommands?: (
475 binaryPath: string,
476 ) => Effect.Effect<ReadonlyArray<ServerProviderSlashCommand> | undefined>,
477): Effect.fn.Return<
478 ServerProvider,
479 ServerSettingsError,
480 ChildProcessSpawner.ChildProcessSpawner | ServerSettingsService
481> {
482 const claudeSettings = yield* Effect.service(ServerSettingsService).pipe(
483 Effect.flatMap((service) => service.getSettings),
484 Effect.map((settings) => settings.providers.claudeAgent),
485 );
486 const checkedAt = new Date().toISOString();
487 const models = providerModelsFromSettings(
488 BUILT_IN_MODELS,
489 PROVIDER,
490 claudeSettings.customModels,
491 DEFAULT_CLAUDE_MODEL_CAPABILITIES,
492 );
493​
494 if (!claudeSettings.enabled) {
495 return buildServerProvider({
496 provider: PROVIDER,
497 enabled: false,
498 checkedAt,
499 models,
500 probe: {
501 installed: false,
502 version: null,
503 status: "warning",
504 auth: { status: "unknown" },
505 message: "Claude is disabled in T3 Code settings.",
506 },
507 });
508 }
509​
510 const versionProbe = yield* runClaudeCommand(["--version"]).pipe(
511 Effect.timeoutOption(DEFAULT_TIMEOUT_MS),
512 Effect.result,
513 );
514​
515 if (Result.isFailure(versionProbe)) {
516 const error = versionProbe.failure;
517 return buildServerProvider({
518 provider: PROVIDER,
519 enabled: claudeSettings.enabled,
520 checkedAt,
521 models,
522 probe: {
523 installed: !isCommandMissingCause(error),
524 version: null,
525 status: "error",
526 auth: { status: "unknown" },
527 message: isCommandMissingCause(error)
528 ? "Claude Agent CLI (`claude`) is not installed or not on PATH."
529 : `Failed to execute Claude Agent CLI health check: ${error instanceof Error ? error.message : String(error)}.`,
530 },
531 });
532 }
533​
534 if (Option.isNone(versionProbe.success)) {
535 return buildServerProvider({
536 provider: PROVIDER,
537 enabled: claudeSettings.enabled,
538 checkedAt,
539 models,
540 probe: {
541 installed: true,
542 version: null,
543 status: "error",
544 auth: { status: "unknown" },
545 message:
546 "Claude Agent CLI is installed but failed to run. Timed out while running command.",
547 },
548 });
549 }
550​
551 const version = versionProbe.success.value;
552 const parsedVersion = parseGenericCliVersion(`${version.stdout}\n${version.stderr}`);
553 if (version.code !== 0) {
554 const detail = detailFromResult(version);
555 return buildServerProvider({
556 provider: PROVIDER,
557 enabled: claudeSettings.enabled,
558 checkedAt,
559 models,
560 probe: {
561 installed: true,
562 version: parsedVersion,
563 status: "error",
564 auth: { status: "unknown" },
565 message: detail
566 ? `Claude Agent CLI is installed but failed to run. ${detail}`
567 : "Claude Agent CLI is installed but failed to run.",
568 },
569 });
570 }
571​
572 const slashCommands =
573 (resolveSlashCommands
574 ? yield* resolveSlashCommands(claudeSettings.binaryPath).pipe(
575 Effect.orElseSucceed(() => undefined),
576 )
577 : undefined) ?? [];
578 const dedupedSlashCommands = dedupeSlashCommands(slashCommands);
579​
580 // ── Auth check + subscription detection ────────────────────────────
581​
582 const authProbe = yield* runClaudeCommand(["auth", "status"]).pipe(
583 Effect.timeoutOption(DEFAULT_TIMEOUT_MS),
584 Effect.result,
585 );
586​
587 // Determine subscription type from multiple sources (cheapest first):
588 // 1. `claude auth status` JSON output (may or may not contain it)
589 // 2. Cached SDK probe (spawns a Claude process on miss, reads
590 // `initializationResult()` for account metadata, then aborts
591 // immediately — no API tokens are consumed)
592​
593 let subscriptionType: string | undefined;
594 let authMethod: string | undefined;
595​
596 if (Result.isSuccess(authProbe) && Option.isSome(authProbe.success)) {
597 subscriptionType = extractSubscriptionTypeFromOutput(authProbe.success.value);
598 authMethod = extractClaudeAuthMethodFromOutput(authProbe.success.value);
599 }
600​
601 if (!subscriptionType && resolveSubscriptionType) {
602 subscriptionType = yield* resolveSubscriptionType(claudeSettings.binaryPath);
603 }
604​
605 // ── Handle auth results (same logic as before, adjusted models) ──
606​
607 if (Result.isFailure(authProbe)) {
608 const error = authProbe.failure;
609 return buildServerProvider({
610 provider: PROVIDER,
611 enabled: claudeSettings.enabled,
612 checkedAt,
613 models,
614 slashCommands: dedupedSlashCommands,
615 probe: {
616 installed: true,
617 version: parsedVersion,
618 status: "warning",
619 auth: { status: "unknown" },
620 message:
621 error instanceof Error
622 ? `Could not verify Claude authentication status: ${error.message}.`
623 : "Could not verify Claude authentication status.",
624 },
625 });
626 }
627​
628 if (Option.isNone(authProbe.success)) {
629 return buildServerProvider({
630 provider: PROVIDER,
631 enabled: claudeSettings.enabled,
632 checkedAt,
633 models,
634 slashCommands: dedupedSlashCommands,
635 probe: {
636 installed: true,
637 version: parsedVersion,
638 status: "warning",
639 auth: { status: "unknown" },
640 message: "Could not verify Claude authentication status. Timed out while running command.",
641 },
642 });
643 }
644​
645 const parsed = parseClaudeAuthStatusFromOutput(authProbe.success.value);
646 const authMetadata = claudeAuthMetadata({ subscriptionType, authMethod });
647 return buildServerProvider({
648 provider: PROVIDER,
649 enabled: claudeSettings.enabled,
650 checkedAt,
651 models,
652 slashCommands: dedupedSlashCommands,
653 probe: {
654 installed: true,
655 version: parsedVersion,
656 status: parsed.status,
657 auth: {
658 ...parsed.auth,
659 ...(authMetadata ? authMetadata : {}),
660 },
661 ...(parsed.message ? { message: parsed.message } : {}),
662 },
663 });
664});
665​
666const makePendingClaudeProvider = (claudeSettings: ClaudeSettings): ServerProvider => {
667 const checkedAt = new Date().toISOString();
668 const models = providerModelsFromSettings(
669 BUILT_IN_MODELS,
670 PROVIDER,
671 claudeSettings.customModels,
672 DEFAULT_CLAUDE_MODEL_CAPABILITIES,
673 );
674​
675 if (!claudeSettings.enabled) {
676 return buildServerProvider({
677 provider: PROVIDER,
678 enabled: false,
679 checkedAt,
680 models,
681 probe: {
682 installed: false,
683 version: null,
684 status: "warning",
685 auth: { status: "unknown" },
686 message: "Claude is disabled in T3 Code settings.",
687 },
688 });
689 }
690​
691 return buildServerProvider({
692 provider: PROVIDER,
693 enabled: true,
694 checkedAt,
695 models,
696 probe: {
697 installed: false,
698 version: null,
699 status: "warning",
700 auth: { status: "unknown" },
701 message: "Claude provider status has not been checked in this session yet.",
702 },
703 });
704};
705​
706export const ClaudeProviderLive = Layer.effect(
707 ClaudeProvider,
708 Effect.gen(function* () {
709 const serverSettings = yield* ServerSettingsService;
710 const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
711​
712 const subscriptionProbeCache = yield* Cache.make({
713 capacity: 1,
714 timeToLive: Duration.minutes(5),
715 lookup: (binaryPath: string) => probeClaudeCapabilities(binaryPath),
716 });
717​
718 const checkProvider = checkClaudeProviderStatus(
719 (binaryPath) =>
720 Cache.get(subscriptionProbeCache, binaryPath).pipe(
721 Effect.map((probe) => probe?.subscriptionType),
722 ),
723 (binaryPath) =>
724 Cache.get(subscriptionProbeCache, binaryPath).pipe(
725 Effect.map((probe) => probe?.slashCommands),
726 ),
727 ).pipe(
728 Effect.provideService(ServerSettingsService, serverSettings),
729 Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
730 );
731​
732 return yield* makeManagedServerProvider<ClaudeSettings>({
733 getSettings: serverSettings.getSettings.pipe(
734 Effect.map((settings) => settings.providers.claudeAgent),
735 Effect.orDie,
736 ),
737 streamSettings: serverSettings.streamChanges.pipe(
738 Stream.map((settings) => settings.providers.claudeAgent),
739 ),
740 haveSettingsChanged: (previous, next) => !Equal.equals(previous, next),
741 initialSnapshot: makePendingClaudeProvider,
742 checkProvider,
743 });
744 }),
745);