Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | import { Effect } from 'effect'; |
| 2 | import { isPerfDebugEnabled, isToolDebugEnabled } from 'src/services/runtime-flags'; |
| 3 | import { TerminalUI } from 'src/services/terminal-ui'; |
| 4 | |
| 5 | const writeJsonDebugLine = (channel: string, payload: Record<string, unknown>) => |
| 6 | Effect.gen(function* () { |
| 7 | const ui = yield* TerminalUI; |
| 8 | yield* ui.error(`[${channel}] ${JSON.stringify(payload)}`); |
| 9 | }); |
| 10 | |
| 11 | export const logToolDebug = (label: string, details: Record<string, unknown> = {}) => |
| 12 | Effect.flatMap(isToolDebugEnabled, enabled => |
| 13 | enabled ? writeJsonDebugLine('tool-debug', { label, ...details }) : Effect.void |
| 14 | ); |
| 15 | |
| 16 | export const makePerfDebugLogger = |
| 17 | (startedAt: number = Date.now()) => |
| 18 | (label: string, details: Record<string, unknown> = {}) => |
| 19 | Effect.flatMap(isPerfDebugEnabled, enabled => |
| 20 | enabled |
| 21 | ? writeJsonDebugLine('perf', { |
| 22 | phase: 'event', |
| 23 | label, |
| 24 | elapsedMs: Date.now() - startedAt, |
| 25 | ...details, |
| 26 | }) |
| 27 | : Effect.void |
| 28 | ); |