Open History to see the last commit
1import { resolveProviderProbeTimeoutMs } from "@t3tools/provider-core/server/snapshotProbe";
2import {
3 type CustomModelSetting,
4 type ServerProvider,
5 type ServerProviderModel,
6} from "@t3tools/contracts";
7import type { PiSettings } from "../settings.ts";
8import { causeErrorTag } from "@t3tools/shared/observability";
9import { resolveSpawnCommand } from "@t3tools/shared/shell";
10import { compareSemverVersions } from "@t3tools/shared/semver";
11import * as Cause from "effect/Cause";
12import * as DateTime from "effect/DateTime";
13import * as Effect from "effect/Effect";
14import * as Stream from "effect/Stream";
15import * as Exit from "effect/Exit";
16import * as Fiber from "effect/Fiber";
17import * as Option from "effect/Option";
18import * as Result from "effect/Result";
19import * as Schema from "effect/Schema";
20import * as HttpClient from "effect/http/HttpClient";
21import * as ChildProcess from "effect/process/ChildProcess";
22import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
23
24import { buildPiRpcLaunch, resolvePiLaunchArgs } from "./mcpInjection.ts";
25import {
26 makePiRpcConnection,
27 PiRpcError,
28 PiRpcTimeoutError,
29 piRecordField as recordField,
30 piRecordString as recordString,
31} from "./rpc.ts";
32import * as ProviderLatestVersions from "@t3tools/provider-core/server/ProviderLatestVersions";
33import {
34 buildServerProvider,
35 DEFAULT_TIMEOUT_MS,
36 isCommandMissingCause,
37 parseCliVersionResult,
38 providerModelsFromSettings,
39 providerProbeEnvironment,
40 spawnAndCollect,
41 type ServerProviderDraft,
42} from "@t3tools/provider-core/server/snapshotProbe";
43import {
44 enrichProviderSnapshotWithVersionAdvisory,
45 type ProviderMaintenanceCapabilities,
46} from "@t3tools/provider-core/server/maintenanceResolver";
47import { EMPTY_PI_MODEL_CAPABILITIES, piModelCapabilities } from "./modelCapabilities.ts";
48import {
49 parsePiDiscoveredCommands,
50 withPiBuiltinSlashCommands,
51 type PiDiscoveredCommands,
52} from "./commands.ts";
53
54const PI_PRESENTATION = {
55 displayName: "Pi",
56 showInteractionModeToggle: false,
57 supportedRuntimeModes: ["approval-required", "auto-accept-edits", "full-access"],
58 reportsContextWindow: true,
59} as const;
60
61const VERSION_PROBE_TIMEOUT_MS = 10_000;
62const PI_RPC_DISCOVERY_TIMEOUT_MS = 30_000;
63const PI_TEXT_GENERATION_DISCOVERY_TIMEOUT_MS = 5_000;
64// Earlier releases persist background set_thinking_level requests as the user's global default.
65export const MINIMUM_PI_VERSION = "0.84.3";
66
67const decodePiAuthCheck = Schema.decodeUnknownOption(
68 Schema.fromJsonString(Schema.Struct({ reason: Schema.optional(Schema.String) })),
69);
70
71const PI_DEFAULT_MODEL: ServerProviderModel = {
72 slug: "default",
73 name: "Pi default",
74 isCustom: false,
75 capabilities: EMPTY_PI_MODEL_CAPABILITIES,
76};
77
78interface PiDiscovery extends PiDiscoveredCommands {
79 readonly models: ReadonlyArray<ServerProviderModel>;
80 readonly authenticated: boolean;
81 /** Pi's active model when Pi lists no model of its provider, so it cannot start a turn. */
82 readonly unavailableActiveModel: { readonly provider: string; readonly id: string } | undefined;
83 /** Pi without extensions can load no model, so text generation fails for every entry. */
84 readonly textGenerationUnavailable: boolean;
85}
86
87function piModelsFromSettings(
88 customModels: ReadonlyArray<CustomModelSetting> | undefined,
89 discovered: ReadonlyArray<ServerProviderModel> = [],
90): ReadonlyArray<ServerProviderModel> {
91 return providerModelsFromSettings(
92 [PI_DEFAULT_MODEL, ...discovered],
93 customModels ?? [],
94 EMPTY_PI_MODEL_CAPABILITIES,
95 );
96}
97
98function parseDiscoveredModels(
99 data: unknown,
100 state: unknown,
101): Result.Result<ReadonlyArray<ServerProviderModel>, PiRpcError> {
102 const models = recordField(data, "models");
103 if (!Array.isArray(models)) {
104 return Result.fail(
105 new PiRpcError({ operation: "get_available_models", detail: "Invalid model inventory" }),
106 );
107 }
108 const activeModel = recordField(state, "model");
109 const activeProvider = recordString(activeModel, "provider");
110 const activeModelId = recordString(activeModel, "id");
111 const seen = new Set<string>();
112 const parsed: Array<ServerProviderModel> = [];
113 for (const model of models) {
114 const provider = recordString(model, "provider");
115 const id = recordString(model, "id");
116 if (provider === undefined || id === undefined || provider.trim() === "" || id.trim() === "") {
117 return Result.fail(
118 new PiRpcError({ operation: "get_available_models", detail: "Invalid model identity" }),
119 );
120 }
121 const slug = `${provider}/${id}`;
122 if (seen.has(slug)) continue;
123 seen.add(slug);
124 parsed.push({
125 slug,
126 name: recordString(model, "name") ?? slug,
127 subProvider: provider,
128 isCustom: false,
129 capabilities: piModelCapabilities(
130 model,
131 provider === activeProvider && id === activeModelId
132 ? recordString(state, "thinkingLevel")
133 : undefined,
134 ),
135 });
136 }
137 return Result.succeed(parsed);
138}
139
140const makePiDiscoveryConnection = Effect.fnUntraced(function* (
141 piSettings: PiSettings,
142 environment: NodeJS.ProcessEnv,
143 launchArgs: ReadonlyArray<string>,
144 cwd?: string,
145 textGenerationLaunch = false,
146) {
147 const launch = buildPiRpcLaunch({
148 launchArgs,
149 environment,
150 mcpSession: undefined,
151 extensionPath: undefined,
152 ephemeral: true,
153 disableExtensions: textGenerationLaunch,
154 disableTools: textGenerationLaunch,
155 shortLived: true,
156 });
157 const connection = yield* makePiRpcConnection({
158 command: piSettings.binaryPath || "pi",
159 args: launch.args,
160 cwd,
161 env: launch.env,
162 });
163 yield* Stream.fromQueue(connection.events).pipe(
164 Stream.runDrain,
165 Effect.ignore,
166 Effect.forkScoped,
167 );
168 return connection;
169});
170
171// A failed response echoes Pi's own `command` field as the operation, so log only names we sent.
172const PI_LOGGED_RPC_OPERATIONS = new Set([
173 "spawn",
174 "read",
175 "write",
176 "exit",
177 "terminate",
178 "get_state",
179 "get_available_models",
180 "get_commands",
181]);
182
183const PI_PROJECT_TRUST_ARGUMENTS = new Set(["--approve", "-a", "--no-approve", "-na"]);
184
185const readPiInventory = Effect.fn("PiProviderStatus.readPiInventory")(function* (
186 piSettings: PiSettings,
187 environment: NodeJS.ProcessEnv,
188 launchArgs: ReadonlyArray<string>,
189 timeoutMs: number,
190 cwd?: string,
191) {
192 const connection = yield* makePiDiscoveryConnection(piSettings, environment, launchArgs, cwd);
193 const stateData = yield* connection.request({ type: "get_state" }, timeoutMs);
194 const modelsData = yield* connection.request({ type: "get_available_models" }, timeoutMs);
195 const commandsData = yield* connection
196 .request({ type: "get_commands" }, timeoutMs)
197 .pipe(Effect.orElseSucceed(() => undefined));
198 return { stateData, modelsData, commandsData };
199}, Effect.scoped);
200
201// Text generation runs Pi with --no-extensions, so it cannot load models that an
202// extension or package registers. Listing models with that launch tells them apart.
203const discoverPiTextGenerationModelSlugs = Effect.fn(
204 "PiProviderStatus.discoverPiTextGenerationModelSlugs",
205)(function* (
206 piSettings: PiSettings,
207 environment: NodeJS.ProcessEnv,
208 launchArgs: ReadonlyArray<string>,
209 cwd?: string,
210) {
211 const connection = yield* makePiDiscoveryConnection(
212 piSettings,
213 environment,
214 launchArgs,
215 cwd,
216 true,
217 );
218 const modelsData = yield* connection.request({ type: "get_available_models" });
219 const models = yield* Effect.fromResult(parseDiscoveredModels(modelsData, undefined));
220 return new Set(models.map((model) => model.slug));
221}, Effect.scoped);
222
223const discoverPiViaRpc = Effect.fn("PiProviderStatus.discoverPiViaRpc")(function* (
224 piSettings: PiSettings,
225 environment: NodeJS.ProcessEnv,
226 launchArgs: ReadonlyArray<string>,
227 cwd?: string,
228) {
229 const timeoutMs = resolveProviderProbeTimeoutMs("pi", PI_RPC_DISCOVERY_TIMEOUT_MS, environment);
230 // This optional probe must finish before the normal discovery deadline so
231 // it cannot discard an otherwise usable catalog and authentication state.
232 const textGenerationModelSlugsFiber = yield* discoverPiTextGenerationModelSlugs(
233 piSettings,
234 environment,
235 launchArgs,
236 cwd,
237 ).pipe(
238 // Pi exits before answering when launch args name a provider only an extension registers.
239 Effect.catchIf(
240 (error) =>
241 error._tag === "PiRpcError" && (error.operation === "read" || error.operation === "exit"),
242 () => Effect.succeed(new Set<string>()),
243 ),
244 Effect.orElseSucceed(() => undefined),
245 Effect.timeoutOrElse({
246 duration: PI_TEXT_GENERATION_DISCOVERY_TIMEOUT_MS,
247 orElse: () => Effect.void,
248 }),
249 Effect.forkScoped,
250 );
251 const { stateData, modelsData, commandsData } = yield* readPiInventory(
252 piSettings,
253 environment,
254 launchArgs,
255 timeoutMs,
256 cwd,
257 ).pipe(
258 // Pi's RPC mode reads stdin only after session_start, so a startup dialog (an MCP adapter asking
259 // to approve a project server) can never be answered and Pi exits. Retry declining project trust
260 // unless the user chose a trust mode, so trusted projects keep their project-local models.
261 Effect.catchIf(
262 (error) =>
263 error._tag === "PiRpcError" &&
264 (error.operation === "read" || error.operation === "exit") &&
265 !launchArgs.some((arg) => PI_PROJECT_TRUST_ARGUMENTS.has(arg)),
266 () =>
267 readPiInventory(piSettings, environment, [...launchArgs, "--no-approve"], timeoutMs, cwd),
268 ),
269 );
270 const discoveredModels = yield* Effect.fromResult(parseDiscoveredModels(modelsData, stateData));
271 const { slashCommands, skills } = parsePiDiscoveredCommands(commandsData);
272 const textGenerationModelSlugs = yield* Fiber.join(textGenerationModelSlugsFiber);
273 // Pi lists only models of providers it holds credentials for, including extension, virtual and
274 // --api-key ones. Turns need only the provider's credentials, so uncatalogued model ids still run.
275 const activeModel = recordField(stateData, "model");
276 const activeProvider = recordString(activeModel, "provider");
277 const activeModelId = recordString(activeModel, "id");
278 return {
279 models:
280 textGenerationModelSlugs === undefined
281 ? discoveredModels
282 : discoveredModels.map((model) =>
283 textGenerationModelSlugs.has(model.slug)
284 ? model
285 : { ...model, supportsTextGeneration: false },
286 ),
287 slashCommands: withPiBuiltinSlashCommands(slashCommands),
288 skills,
289 authenticated: discoveredModels.length > 0,
290 unavailableActiveModel:
291 activeProvider !== undefined &&
292 activeModelId !== undefined &&
293 !discoveredModels.some((model) => model.subProvider === activeProvider)
294 ? { provider: activeProvider, id: activeModelId }
295 : undefined,
296 textGenerationUnavailable: textGenerationModelSlugs?.size === 0,
297 } satisfies PiDiscovery;
298}, Effect.scoped);
299
300export const discoverPiCommandsForCwd = Effect.fn("discoverPiCommandsForCwd")(
301 function* (piSettings: PiSettings, environment: NodeJS.ProcessEnv, cwd: string) {
302 const launchArgs = resolvePiLaunchArgs(piSettings.launchArgs);
303 if (!launchArgs.ok) {
304 return yield* new PiRpcError({ operation: "launch", detail: launchArgs.message });
305 }
306 const connection = yield* makePiDiscoveryConnection(
307 piSettings,
308 providerProbeEnvironment(environment),
309 launchArgs.args,
310 cwd,
311 );
312 // A failed read must not replace a previously usable workspace catalog with an empty one.
313 const commandsData = yield* connection.request(
314 { type: "get_commands" },
315 resolveProviderProbeTimeoutMs("pi", PI_RPC_DISCOVERY_TIMEOUT_MS, environment),
316 );
317 const { slashCommands, skills } = parsePiDiscoveredCommands(commandsData);
318 return { slashCommands: withPiBuiltinSlashCommands(slashCommands), skills };
319 },
320 Effect.scoped,
321 (effect, _settings, environment) => {
322 const timeoutMs = resolveProviderProbeTimeoutMs("pi", PI_RPC_DISCOVERY_TIMEOUT_MS, environment);
323 return effect.pipe(
324 Effect.timeoutOrElse({
325 duration: timeoutMs,
326 orElse: () => Effect.fail(new PiRpcTimeoutError({ operation: "discovery", timeoutMs })),
327 }),
328 );
329 },
330);
331
332export const runPiVersionCommand = Effect.fn("PiProviderStatus.runPiVersionCommand")(function* (
333 piSettings: PiSettings,
334 environment: NodeJS.ProcessEnv,
335 cwd?: string,
336) {
337 const command = piSettings.binaryPath || "pi";
338 const spawnCommand = yield* resolveSpawnCommand(command, ["--version"], {
339 env: environment,
340 });
341 return yield* spawnAndCollect(
342 command,
343 ChildProcess.make(spawnCommand.command, spawnCommand.args, {
344 env: environment,
345 shell: spawnCommand.shell,
346 ...(cwd === undefined ? {} : { cwd }),
347 }),
348 );
349});
350
351/**
352 * Explains why Pi's active model cannot start a turn. Asks `pi auth check` whether credentials
353 * are missing, without refreshing or printing them. That command cannot see
354 * extension providers or a runtime --api-key, so it only refines Pi's own unavailable verdict,
355 * and is skipped when launch args supply the key.
356 */
357const describeUnavailablePiModel = Effect.fn("PiProviderStatus.describeUnavailablePiModel")(
358 function* (
359 piSettings: PiSettings,
360 environment: NodeJS.ProcessEnv,
361 launchArgs: ReadonlyArray<string>,
362 model: { readonly provider: string; readonly id: string },
363 ) {
364 const label = `Pi default (${model.provider}/${model.id})`;
365 const unavailable = `${label} uses ${model.provider}, which has no available models in Pi. Choose another model, or check that provider's setup and the Pi launch arguments.`;
366 if (launchArgs.includes("--api-key")) {
367 return unavailable;
368 }
369 const command = piSettings.binaryPath || "pi";
370 const output = yield* resolveSpawnCommand(
371 command,
372 ["auth", "check", "--provider", model.provider, "--json", "--no-refresh"],
373 { env: environment },
374 ).pipe(
375 Effect.flatMap((spawnCommand) =>
376 spawnAndCollect(
377 command,
378 ChildProcess.make(spawnCommand.command, spawnCommand.args, {
379 env: environment,
380 shell: spawnCommand.shell,
381 }),
382 ),
383 ),
384 Effect.timeout(resolveProviderProbeTimeoutMs("pi", DEFAULT_TIMEOUT_MS, environment)),
385 Effect.option,
386 );
387 const missingCredentials = Option.exists(
388 Option.flatMap(output, (result) => decodePiAuthCheck(result.stdout)),
389 (check) => check.reason === "credentials_not_configured",
390 );
391 return missingCredentials
392 ? `${label} has no credentials configured for ${model.provider}. Choose another model, or run \`pi\` in a terminal and use /login or configure its API key.`
393 : unavailable;
394 },
395);
396
397export const buildInitialPiProviderSnapshot = Effect.fn(
398 "PiProviderStatus.buildInitialPiProviderSnapshot",
399)(function* (piSettings: PiSettings): Effect.fn.Return<ServerProviderDraft> {
400 const checkedAt = yield* Effect.map(DateTime.now, DateTime.formatIso);
401 const models = piModelsFromSettings(piSettings.customModels);
402 if (!piSettings.enabled) {
403 return buildServerProvider({
404 presentation: PI_PRESENTATION,
405 enabled: false,
406 checkedAt,
407 models,
408 probe: {
409 installed: false,
410 version: null,
411 status: "warning",
412 auth: { status: "unknown" },
413 message: "Pi is disabled in T3 Code settings.",
414 },
415 });
416 }
417 return buildServerProvider({
418 presentation: PI_PRESENTATION,
419 enabled: true,
420 checkedAt,
421 models,
422 probe: {
423 installed: true,
424 version: null,
425 status: "warning",
426 auth: { status: "unknown" },
427 message: "Checking Pi CLI availability...",
428 },
429 });
430});
431
432export const checkPiProviderStatus = Effect.fn("checkPiProviderStatus")(function* (
433 piSettings: PiSettings,
434 environment: NodeJS.ProcessEnv = process.env,
435 cwd?: string,
436): Effect.fn.Return<ServerProviderDraft, never, ChildProcessSpawner.ChildProcessSpawner> {
437 const checkedAt = DateTime.formatIso(yield* DateTime.now);
438 const fallbackModels = piModelsFromSettings(piSettings.customModels);
439
440 if (!piSettings.enabled) {
441 return buildServerProvider({
442 presentation: PI_PRESENTATION,
443 enabled: false,
444 checkedAt,
445 models: fallbackModels,
446 probe: {
447 installed: false,
448 version: null,
449 status: "warning",
450 auth: { status: "unknown" },
451 message: "Pi is disabled in T3 Code settings.",
452 },
453 });
454 }
455
456 const probeEnvironment = providerProbeEnvironment(environment);
457 const versionResult = yield* runPiVersionCommand(piSettings, probeEnvironment).pipe(
458 Effect.timeoutOption(
459 resolveProviderProbeTimeoutMs("pi", VERSION_PROBE_TIMEOUT_MS, environment),
460 ),
461 Effect.result,
462 );
463
464 if (Result.isFailure(versionResult)) {
465 const error = versionResult.failure;
466 yield* Effect.logWarning("Pi CLI health check failed.", { errorTag: error._tag });
467 return buildServerProvider({
468 presentation: PI_PRESENTATION,
469 enabled: piSettings.enabled,
470 checkedAt,
471 models: fallbackModels,
472 probe: {
473 installed: !isCommandMissingCause(error),
474 version: null,
475 status: "error",
476 auth: { status: "unknown" },
477 message: isCommandMissingCause(error)
478 ? "Pi CLI (`pi`) is not installed or not on PATH. Install with `npm install -g --ignore-scripts @earendil-works/pi-coding-agent`."
479 : "Failed to execute Pi CLI health check.",
480 },
481 });
482 }
483
484 if (Option.isNone(versionResult.success)) {
485 return buildServerProvider({
486 presentation: PI_PRESENTATION,
487 enabled: piSettings.enabled,
488 checkedAt,
489 models: fallbackModels,
490 probe: {
491 installed: true,
492 version: null,
493 status: "error",
494 auth: { status: "unknown" },
495 message: "Pi CLI is installed but timed out while running `pi --version`.",
496 },
497 });
498 }
499
500 const versionOutput = versionResult.success.value;
501 const version = parseCliVersionResult(versionOutput);
502 if (versionOutput.code !== 0) {
503 return buildServerProvider({
504 presentation: PI_PRESENTATION,
505 enabled: piSettings.enabled,
506 checkedAt,
507 models: fallbackModels,
508 probe: {
509 installed: true,
510 version,
511 status: "error",
512 auth: { status: "unknown" },
513 message: "Pi CLI is installed but failed to run.",
514 },
515 });
516 }
517
518 if (version === null) {
519 return buildServerProvider({
520 presentation: PI_PRESENTATION,
521 enabled: piSettings.enabled,
522 checkedAt,
523 models: fallbackModels,
524 probe: {
525 installed: true,
526 version: null,
527 status: "error",
528 auth: { status: "unknown" },
529 message: `T3 Code could not determine the Pi version. Pi ${MINIMUM_PI_VERSION} or newer is required.`,
530 },
531 });
532 }
533
534 if (compareSemverVersions(version, MINIMUM_PI_VERSION) < 0) {
535 return buildServerProvider({
536 presentation: PI_PRESENTATION,
537 enabled: piSettings.enabled,
538 checkedAt,
539 models: fallbackModels,
540 probe: {
541 installed: true,
542 version,
543 status: "error",
544 auth: { status: "unknown" },
545 message: `Pi ${version} is unsupported. Update to Pi ${MINIMUM_PI_VERSION} or newer.`,
546 },
547 });
548 }
549
550 const resolvedLaunchArgs = resolvePiLaunchArgs(piSettings.launchArgs);
551 if (!resolvedLaunchArgs.ok) {
552 return buildServerProvider({
553 presentation: PI_PRESENTATION,
554 enabled: piSettings.enabled,
555 checkedAt,
556 models: fallbackModels,
557 probe: {
558 installed: true,
559 version,
560 status: "error",
561 auth: { status: "unknown" },
562 message: resolvedLaunchArgs.message,
563 },
564 });
565 }
566
567 const discoveryExit = yield* discoverPiViaRpc(
568 piSettings,
569 probeEnvironment,
570 resolvedLaunchArgs.args,
571 cwd,
572 ).pipe(
573 Effect.timeoutOption(
574 resolveProviderProbeTimeoutMs("pi", PI_RPC_DISCOVERY_TIMEOUT_MS, environment),
575 ),
576 Effect.exit,
577 );
578 if (Exit.isFailure(discoveryExit)) {
579 const failure = Cause.findErrorOption(discoveryExit.cause);
580 yield* Effect.logWarning("Pi RPC discovery failed.", {
581 errorTag: causeErrorTag(discoveryExit.cause),
582 ...(Option.isSome(failure) && PI_LOGGED_RPC_OPERATIONS.has(failure.value.operation)
583 ? { operation: failure.value.operation }
584 : {}),
585 });
586 return buildServerProvider({
587 presentation: PI_PRESENTATION,
588 enabled: piSettings.enabled,
589 checkedAt,
590 models: fallbackModels,
591 probe: {
592 installed: true,
593 version,
594 status: "ready",
595 auth: { status: "unknown" },
596 message:
597 "Pi is available, but T3 Code could not refresh its models and commands. The live session will retry startup.",
598 },
599 });
600 }
601 if (Option.isNone(discoveryExit.value)) {
602 return buildServerProvider({
603 presentation: PI_PRESENTATION,
604 enabled: piSettings.enabled,
605 checkedAt,
606 models: fallbackModels,
607 probe: {
608 installed: true,
609 version,
610 status: "ready",
611 auth: { status: "unknown" },
612 message:
613 "Pi is available, but model and command discovery needs interactive input. The live session will handle it.",
614 },
615 });
616 }
617
618 const discovery = discoveryExit.value.value;
619 const models = piModelsFromSettings(piSettings.customModels, discovery.models);
620 const message = !discovery.authenticated
621 ? "Pi has no usable models. Run `pi` in a terminal and use /login, or configure an API key in ~/.pi/agent."
622 : discovery.unavailableActiveModel === undefined
623 ? undefined
624 : yield* describeUnavailablePiModel(
625 piSettings,
626 probeEnvironment,
627 resolvedLaunchArgs.args,
628 discovery.unavailableActiveModel,
629 );
630 return {
631 ...buildServerProvider({
632 presentation: PI_PRESENTATION,
633 enabled: piSettings.enabled,
634 checkedAt,
635 models,
636 slashCommands: discovery.slashCommands,
637 skills: discovery.skills,
638 probe: {
639 installed: true,
640 version,
641 // Other Pi models still work when only the default is unavailable, so keep the picker usable.
642 status: discovery.authenticated ? "ready" : "warning",
643 auth: { status: discovery.authenticated ? "authenticated" : "unauthenticated", type: "pi" },
644 ...(message === undefined ? {} : { message }),
645 },
646 }),
647 ...(discovery.textGenerationUnavailable ? { supportsTextGeneration: false } : {}),
648 };
649});
650
651export const enrichPiSnapshot = (input: {
652 readonly snapshot: ServerProvider;
653 readonly maintenanceCapabilities: ProviderMaintenanceCapabilities;
654 readonly enableProviderUpdateChecks?: boolean;
655 readonly publishSnapshot: (snapshot: ServerProvider) => Effect.Effect<void>;
656}): Effect.Effect<
657 void,
658 never,
659 HttpClient.HttpClient | ProviderLatestVersions.ProviderLatestVersions
660> => {
661 const { snapshot, publishSnapshot } = input;
662 return enrichProviderSnapshotWithVersionAdvisory(snapshot, input.maintenanceCapabilities, {
663 enableProviderUpdateChecks: input.enableProviderUpdateChecks,
664 }).pipe(
665 Effect.flatMap((enrichedSnapshot) => publishSnapshot(enrichedSnapshot)),
666 Effect.catchCause((cause) =>
667 Effect.logWarning("Pi version advisory enrichment failed", {
668 errorTag: causeErrorTag(cause),
669 }),
670 ),
671 Effect.asVoid,
672 );
673};