MCPcopy Create free account
hub / github.com/TanStack/ai / upsertHook

Function upsertHook

packages/ai-devtools/src/store/hook-registry.ts:545–578  ·  view source on GitHub ↗
(state: HookRegistryState, event: HookUpsertEvent)

Source from the content-addressed store, hash-verified

543}
544
545function upsertHook(state: HookRegistryState, event: HookUpsertEvent): void {
546 const existing = state.hooks[event.hookId]
547 if (!existing) {
548 state.hooks[event.hookId] = {
549 id: event.hookId,
550 hookName: event.hookName,
551 ...(event.displayName ? { displayName: event.displayName } : {}),
552 ...(event.framework ? { framework: event.framework } : {}),
553 ...(event.outputKind ? { outputKind: event.outputKind } : {}),
554 lifecycle: event.lifecycle,
555 ...(event.clientId ? { clientId: event.clientId } : {}),
556 ...(event.threadId ? { threadId: event.threadId } : {}),
557 ...(event.correlationId ? { correlationId: event.correlationId } : {}),
558 registeredAt: event.timestamp,
559 updatedAt: event.timestamp,
560 state: {},
561 tools: [],
562 runIds: [],
563 eventIds: [],
564 activityRunIds: [],
565 }
566 return
567 }
568
569 existing.hookName = event.hookName
570 if (event.displayName) existing.displayName = event.displayName
571 if (event.framework) existing.framework = event.framework
572 if (event.outputKind) existing.outputKind = event.outputKind
573 if (event.clientId) existing.clientId = event.clientId
574 if (event.threadId) existing.threadId = event.threadId
575 if (event.correlationId) existing.correlationId = event.correlationId
576 existing.lifecycle = event.lifecycle
577 existing.updatedAt = event.timestamp
578}
579
580function isStaleHookInstanceEvent(
581 state: HookRegistryState,

Callers 1

applyHookEventFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected