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

Function stampSyncedWithHealth

packages/core/sdk/src/executor.ts:3325–3351  ·  view source on GitHub ↗
(reason: string, health?: HealthCheckResult)

Source from the content-addressed store, hash-verified

3323 // reconnect re-syncs tools anyway); at worst the skipped
3324 // `tools_synced_at` stamp makes the next read re-attempt the sync.
3325 const stampSyncedWithHealth = (reason: string, health?: HealthCheckResult) =>
3326 findConnectionRow(ref).pipe(
3327 Effect.flatMap((fresh) =>
3328 fresh === null
3329 ? Effect.void
3330 : core
3331 .updateMany("connection", {
3332 where: (b: AnyCb) =>
3333 b.and(
3334 connectionWhere(b),
3335 b("updated_at", "=", fresh.updated_at),
3336 fresh.tools_synced_at == null
3337 ? b.isNull("tools_synced_at")
3338 : b("tools_synced_at", "=", fresh.tools_synced_at),
3339 ),
3340 set:
3341 oauthReauthRequiredFromProviderState(fresh.provider_state) !== null
3342 ? { tools_synced_at: Date.now() }
3343 : {
3344 tools_synced_at: Date.now(),
3345 last_health: health ?? toolSyncHealth(reason),
3346 updated_at: new Date(),
3347 },
3348 })
3349 .pipe(Effect.asVoid),
3350 ),
3351 );
3352
3353 // Defense in depth (and cleanup for rows created before the create-time
3354 // guard, or emptied by an external edit): a credentialed non-OAuth

Callers 1

Calls 4

findConnectionRowFunction · 0.85
connectionWhereFunction · 0.85
toolSyncHealthFunction · 0.85

Tested by

no test coverage detected