| 591 | } |
| 592 | |
| 593 | function upsertUnknownHook( |
| 594 | state: HookRegistryState, |
| 595 | hookId: string, |
| 596 | event: RunLifecycleEvent, |
| 597 | ): void { |
| 598 | if (state.hooks[hookId]) return |
| 599 | state.hooks[hookId] = { |
| 600 | id: hookId, |
| 601 | hookName: hookId, |
| 602 | lifecycle: 'active', |
| 603 | ...(event.clientId ? { clientId: event.clientId } : {}), |
| 604 | ...(event.threadId ? { threadId: event.threadId } : {}), |
| 605 | registeredAt: event.timestamp, |
| 606 | updatedAt: event.timestamp, |
| 607 | state: {}, |
| 608 | tools: [], |
| 609 | runIds: [], |
| 610 | eventIds: [], |
| 611 | activityRunIds: [], |
| 612 | } |
| 613 | } |
| 614 | |
| 615 | function removeHookRecord(state: HookRegistryState, hookId: string): void { |
| 616 | const hook = state.hooks[hookId] |