MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / healPersistedHealthOnUse

Function healPersistedHealthOnUse

packages/core/sdk/src/executor.ts:4406–4447  ·  view source on GitHub ↗
(
      row: ConnectionRow,
      result: unknown,
      values: Record<string, string | null>,
    )

Source from the content-addressed store, hash-verified

4404 * stamp and the heal is a silent no-op. Any newer write is newer
4405 * evidence than this invocation. */
4406 const healPersistedHealthOnUse = (
4407 row: ConnectionRow,
4408 result: unknown,
4409 values: Record<string, string | null>,
4410 ): Effect.Effect<void> =>
4411 Effect.suspend(() => {
4412 if (isToolResult(result) && !result.ok) return Effect.void;
4413 if (Object.values(values).some((value) => value == null)) return Effect.void;
4414 const observed = Option.getOrNull(decodeLastHealth(row.last_health));
4415 if (observed === null || observed.status === "healthy" || observed.status === "unknown") {
4416 return Effect.void;
4417 }
4418 if (isToolSyncHealth(observed)) return Effect.void;
4419 if (oauthReauthRequiredFromProviderState(row.provider_state) !== null) return Effect.void;
4420 const ref: ConnectionRef = {
4421 owner: row.owner as Owner,
4422 integration: IntegrationSlug.make(row.integration),
4423 name: ConnectionName.make(row.name),
4424 };
4425 return findConnectionRow(ref).pipe(
4426 Effect.flatMap((fresh) => {
4427 if (fresh === null) return Effect.void;
4428 if (oauthReauthRequiredFromProviderState(fresh.provider_state) !== null) {
4429 return Effect.void;
4430 }
4431 const current = Option.getOrNull(decodeLastHealth(fresh.last_health));
4432 if (
4433 current === null ||
4434 current.status !== observed.status ||
4435 current.checkedAt !== observed.checkedAt
4436 ) {
4437 return Effect.void;
4438 }
4439 return persistHealthResult(ref, fresh, {
4440 status: "healthy",
4441 checkedAt: Date.now(),
4442 detail: "Tool invocation succeeded.",
4443 });
4444 }),
4445 Effect.ignore,
4446 );
4447 });
4448
4449 const healthFromCredentialResolutionFailure = (
4450 failure: CredentialResolutionError,

Callers 1

executeFunction · 0.85

Calls 6

isToolResultFunction · 0.90
isToolSyncHealthFunction · 0.90
findConnectionRowFunction · 0.85
persistHealthResultFunction · 0.85
valuesMethod · 0.80

Tested by

no test coverage detected