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

Function healPersistedHealthOnUse

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

Source from the content-addressed store, hash-verified

4858 * stamp and the heal is a silent no-op. Any newer write is newer
4859 * evidence than this invocation. */
4860 const healPersistedHealthOnUse = (
4861 row: ConnectionRow,
4862 result: unknown,
4863 values: Record<string, string | null>,
4864 ): Effect.Effect<void> =>
4865 Effect.suspend(() => {
4866 if (isToolResult(result) && !result.ok) return Effect.void;
4867 if (Object.values(values).some((value) => value == null)) return Effect.void;
4868 const observed = Option.getOrNull(decodeLastHealth(row.last_health));
4869 if (observed === null || observed.status === "healthy" || observed.status === "unknown") {
4870 return Effect.void;
4871 }
4872 if (isToolSyncHealth(observed)) return Effect.void;
4873 if (oauthReauthRequiredFromProviderState(row.provider_state) !== null) return Effect.void;
4874 const ref: ConnectionRef = {
4875 owner: row.owner as Owner,
4876 integration: IntegrationSlug.make(row.integration),
4877 name: ConnectionName.make(row.name),
4878 };
4879 return findConnectionRow(ref).pipe(
4880 Effect.flatMap((fresh) => {
4881 if (fresh === null) return Effect.void;
4882 if (oauthReauthRequiredFromProviderState(fresh.provider_state) !== null) {
4883 return Effect.void;
4884 }
4885 const current = Option.getOrNull(decodeLastHealth(fresh.last_health));
4886 if (
4887 current === null ||
4888 current.status !== observed.status ||
4889 current.checkedAt !== observed.checkedAt
4890 ) {
4891 return Effect.void;
4892 }
4893 return persistHealthResult(ref, fresh, {
4894 status: "healthy",
4895 checkedAt: Date.now(),
4896 detail: "Tool invocation succeeded.",
4897 });
4898 }),
4899 Effect.ignore,
4900 );
4901 });
4902
4903 const healthFromCredentialResolutionFailure = (
4904 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