{"version":3,"file":"checkpoint.cjs","sources":["@gensx/core/../../../../src/checkpoint.ts"],"sourcesContent":["import { Buffer } from \"node:buffer\";\nimport { createHash } from \"node:crypto\";\nimport { join } from \"node:path\";\nimport { hrtime } from \"node:process\";\nimport { promisify } from \"node:util\";\nimport { gzip } from \"node:zlib\";\n\nimport {\n  CheckpointWriter,\n  ContentId,\n  ExecutionNode,\n  NodeId,\n  PathId,\n  STREAMING_PLACEHOLDER,\n} from \"./checkpoint-types.js\";\nimport { isAsyncIterable, isReadableStream } from \"./component.js\";\nimport { readConfig } from \"./utils/config.js\";\nimport { generateNodeId, stringifyProps } from \"./utils/nodeId.js\";\nimport { USER_AGENT } from \"./utils/user-agent.js\";\n\nexport type { CheckpointWriter, ExecutionNode, NodeId };\nexport { STREAMING_PLACEHOLDER };\n\nconst gzipAsync = promisify(gzip);\n\nclass NodeMap<T extends ExecutionNode> {\n  // Primary lookup by full ID\n  private idLookup = new Map<string, T>();\n\n  // Secondary lookups for fuzzy matching\n  private pathLookup = new Map<string, Set<string>>(); // pathId -> Set<primaryId>\n  private contentLookup = new Map<string, Set<string>>(); // contentId -> Set<primaryId>\n  private pathContentLookup = new Map<string, Set<string>>(); // pathId:contentId -> Set<primaryId>\n\n  set(node: T) {\n    this.idLookup.set(node.id, node);\n\n    // Update secondary lookups\n    const pathId = getPathId(node.id);\n    if (pathId) {\n      if (!this.pathLookup.has(pathId)) {\n        this.pathLookup.set(pathId, new Set());\n      }\n      this.pathLookup.get(pathId)!.add(node.id);\n    }\n\n    const contentId = getContentId(node.id);\n    if (contentId) {\n      if (!this.contentLookup.has(contentId)) {\n        this.contentLookup.set(contentId, new Set());\n      }\n      this.contentLookup.get(contentId)!.add(node.id);\n    }\n\n    const pathContentId = `${pathId}:${contentId}`;\n    if (!this.pathContentLookup.has(pathContentId)) {\n      this.pathContentLookup.set(pathContentId, new Set());\n    }\n    this.pathContentLookup.get(pathContentId)!.add(node.id);\n  }\n\n  get(primaryIdOrNode: string | T): T | undefined {\n    if (typeof primaryIdOrNode === \"string\") {\n      return this.idLookup.get(primaryIdOrNode);\n    }\n\n    const node = primaryIdOrNode;\n    return this.idLookup.get(node.id);\n  }\n\n  has(primaryIdOrNode: string | T): boolean {\n    if (typeof primaryIdOrNode === \"string\") {\n      return this.idLookup.has(primaryIdOrNode);\n    }\n    return this.get(primaryIdOrNode) !== undefined;\n  }\n\n  getByPathAndContent(pathId: string, contentId: string): T[] {\n    const primaryIds =\n      this.pathContentLookup.get(`${pathId}:${contentId}`) ?? new Set();\n    return Array.from(primaryIds)\n      .map((id) => this.idLookup.get(id))\n      .filter((node): node is T => node !== undefined);\n  }\n\n  getByPath(pathId: string): T[] {\n    const primaryIds = this.pathLookup.get(pathId) ?? new Set();\n    return Array.from(primaryIds)\n      .map((id) => this.idLookup.get(id))\n      .filter((node): node is T => node !== undefined);\n  }\n\n  getByContent(contentId: string): T[] {\n    const primaryIds = this.contentLookup.get(contentId) ?? new Set();\n    return Array.from(primaryIds)\n      .map((id) => this.idLookup.get(id))\n      .filter((node): node is T => node !== undefined);\n  }\n\n  entries() {\n    return Array.from(this.idLookup.entries());\n  }\n\n  clear() {\n    this.idLookup.clear();\n    this.pathLookup.clear();\n    this.contentLookup.clear();\n    this.pathContentLookup.clear();\n  }\n}\n\nexport class CheckpointManager implements CheckpointWriter {\n  private nodes = new NodeMap<ExecutionNode>();\n  private orphanedNodes = new Map<string, Set<ExecutionNode>>();\n  private _secretValues = new Map<string, Set<unknown>>(); // Internal per-node secrets\n  private currentNodeChain: ExecutionNode[] = []; // Track current execution context\n  private readonly MIN_SECRET_LENGTH = 8;\n  public root?: ExecutionNode;\n  public checkpointsEnabled: boolean;\n  public workflowName?: string;\n  private activeCheckpoint: Promise<void> | null = null;\n  private pendingUpdate = false;\n  private version = 1;\n  private org: string;\n  private apiKey: string;\n  private apiBaseUrl: string;\n  private consoleBaseUrl: string;\n  private printUrl = false;\n  private runtime?: \"cloud\" | \"sdk\";\n  private runtimeVersion?: string;\n  private checkpointListener?: (root: ExecutionNode) => Promise<void>;\n\n  private traceId?: string;\n  private executionRunId?: string;\n\n  // Replay functionality with enhanced fuzzy matching\n  private replayLookup: ExecutionNode[] = [];\n\n  // Provide unified view of all secrets\n  get secretValues(): Set<unknown> {\n    const allSecrets = new Set<unknown>();\n    for (const secrets of this._secretValues.values()) {\n      for (const secret of secrets) {\n        allSecrets.add(secret);\n      }\n    }\n    return allSecrets;\n  }\n\n  // Public getter for testing purposes\n  get nodesForTesting(): Map<string, ExecutionNode> {\n    const legacyMap = new Map<string, ExecutionNode>();\n    for (const [primaryId, node] of this.nodes.entries()) {\n      legacyMap.set(primaryId, node);\n    }\n    return legacyMap;\n  }\n\n  private callCounters = new Map<string, number>();\n\n  public getNextCallIndex(\n    parentPath: string,\n    componentName: string,\n    props: Record<string, unknown>,\n    idPropsKeys: string[] | undefined,\n  ): number {\n    const contentContext = {\n      name: componentName,\n      props: stringifyProps(props, idPropsKeys),\n      parent: parentPath,\n    };\n    const contentStr = JSON.stringify(contentContext);\n    const contentHash = createHash(\"sha256\")\n      .update(contentStr)\n      .digest(\"hex\")\n      .slice(0, 8);\n    const key = `${parentPath}-${componentName}:${contentHash}`;\n    const current = this.callCounters.get(key) ?? 0;\n    this.callCounters.set(key, current + 1);\n    return current;\n  }\n\n  constructor(opts?: {\n    apiKey?: string;\n    org?: string;\n    disabled?: boolean;\n    apiBaseUrl?: string;\n    consoleBaseUrl?: string;\n    executionRunId?: string;\n    runtime?: \"cloud\" | \"sdk\";\n    runtimeVersion?: string;\n    checkpoint?: ExecutionNode;\n  }) {\n    // Priority order: constructor opts > env vars > config file\n    const config = readConfig();\n    const apiKey =\n      opts?.apiKey ?? process.env.GENSX_API_KEY ?? config.api?.token;\n    const org = opts?.org ?? process.env.GENSX_ORG ?? config.api?.org;\n    const apiBaseUrl =\n      opts?.apiBaseUrl ?? process.env.GENSX_API_BASE_URL ?? config.api?.baseUrl;\n    const consoleBaseUrl =\n      opts?.consoleBaseUrl ??\n      process.env.GENSX_CONSOLE_URL ??\n      config.console?.baseUrl;\n\n    this.checkpointsEnabled = apiKey !== undefined;\n    this.org = org ?? \"\";\n    this.apiKey = apiKey ?? \"\";\n    this.apiBaseUrl = apiBaseUrl ?? \"https://api.gensx.com\";\n    this.consoleBaseUrl = consoleBaseUrl ?? \"https://app.gensx.com\";\n\n    const runtime = opts?.runtime ?? process.env.GENSX_RUNTIME;\n    if (runtime && runtime !== \"cloud\" && runtime !== \"sdk\") {\n      throw new Error('Invalid runtime. Must be either \"cloud\" or \"sdk\"');\n    }\n    this.runtime = runtime as \"cloud\" | \"sdk\" | undefined;\n    this.runtimeVersion =\n      opts?.runtimeVersion ?? process.env.GENSX_RUNTIME_VERSION;\n\n    this.executionRunId =\n      opts?.executionRunId ?? process.env.GENSX_EXECUTION_RUN_ID;\n\n    if (\n      opts?.disabled ||\n      process.env.GENSX_CHECKPOINTS === \"false\" ||\n      process.env.GENSX_CHECKPOINTS === \"0\" ||\n      process.env.GENSX_CHECKPOINTS === \"no\" ||\n      process.env.GENSX_CHECKPOINTS === \"off\"\n    ) {\n      this.checkpointsEnabled = false;\n    }\n\n    if (this.checkpointsEnabled && !this.org) {\n      throw new Error(\n        \"Organization not set. Set it via constructor options, GENSX_ORG environment variable, or in ~/.config/gensx/config. You can disable checkpoints by setting GENSX_CHECKPOINTS=false or unsetting GENSX_API_KEY.\",\n      );\n    }\n\n    if (opts?.checkpoint) {\n      this.buildReplayLookup(opts.checkpoint);\n    }\n  }\n\n  private attachToParent(\n    nodeToUpdate: ExecutionNode,\n    parentToUpdate: ExecutionNode,\n  ) {\n    const node = this.nodes.get(nodeToUpdate);\n    if (!node) {\n      throw new Error(\"Node not found\");\n    }\n    const parent = this.nodes.get(parentToUpdate);\n    if (!parent) {\n      throw new Error(\"Parent node not found\");\n    }\n    node.parentId = parent.id;\n    if (!parent.children.some((child) => child.id === node.id)) {\n      parent.children.push(node);\n    }\n  }\n\n  private handleOrphanedNode(node: ExecutionNode, parent: ExecutionNode) {\n    let orphans = this.orphanedNodes.get(parent.id);\n    if (!orphans) {\n      orphans = new Set();\n      this.orphanedNodes.set(parent.id, orphans);\n    }\n    orphans.add(node);\n\n    // Add diagnostic timeout to detect stuck orphans\n    this.checkOrphanTimeout(node, parent);\n  }\n\n  private isNativeFunction(value: unknown): boolean {\n    return (\n      typeof value === \"function\" &&\n      Function.prototype.toString.call(value).includes(\"[native code]\")\n    );\n  }\n\n  private checkOrphanTimeout(\n    expectedNode: ExecutionNode,\n    expectedParent: ExecutionNode,\n  ) {\n    setTimeout(() => {\n      const orphans = this.orphanedNodes.get(expectedParent.id);\n      const node = this.nodes.get(expectedNode);\n      if (!node) {\n        console.warn(\n          `[Checkpoint] Node ${expectedNode.id} (${expectedNode.componentName}) no longer exists`,\n        );\n        return;\n      }\n      if (orphans?.has(node)) {\n        console.warn(\n          `[Checkpoint] Node ${node.id} (${node.componentName}) still waiting for parent ${expectedParent.id} after 5s`,\n          {\n            node,\n            existingNodes: Array.from(this.nodes.entries()).map(\n              ([id, node]) => ({\n                id,\n                componentName: node.componentName,\n                parentId: node.parentId,\n              }),\n            ),\n          },\n        );\n      }\n    }, 5000);\n  }\n\n  /**\n   * Validates that the execution tree is in a complete state where:\n   * 1. Root node exists\n   * 2. No orphaned nodes are waiting for parents\n   * 3. All parent-child relationships are properly connected\n   */\n  private isTreeValid(): boolean {\n    // No root means tree isn't valid\n    if (!this.root) return false;\n\n    // If we have orphaned nodes, tree isn't complete\n    if (this.orphanedNodes.size > 0) return false;\n\n    // Verify all nodes in the tree have their parents\n    const verifyNode = (node: ExecutionNode): boolean => {\n      for (const child of node.children) {\n        if (child.parentId !== node.id) return false;\n        if (!verifyNode(child)) return false;\n      }\n      return true;\n    };\n\n    return verifyNode(this.root);\n  }\n\n  /**\n   * Updates the checkpoint in a non-blocking manner while ensuring consistency.\n   * Special care is taken to:\n   * 1. Queue updates instead of writing immediately to minimize API calls\n   * 2. Only write one checkpoint at a time to maintain order\n   * 3. Track pending updates to ensure no state is lost\n   * 4. Validate tree completeness before writing\n   *\n   * The flow is:\n   * 1. If a write is in progress, mark pendingUpdate = true\n   * 2. When write completes, check pendingUpdate and trigger another write if needed\n   * 3. Only write if tree is valid (has root and no orphans)\n   */\n  private updateCheckpoint() {\n    if (!this.checkpointsEnabled) {\n      return;\n    }\n\n    // Only write if we have a valid tree\n    if (!this.isTreeValid()) {\n      this.pendingUpdate = true;\n      return;\n    }\n\n    // If there's already a pending update, just mark that we need another update\n    if (this.activeCheckpoint) {\n      this.pendingUpdate = true;\n      return;\n    }\n\n    // Start a new checkpoint write\n    this.activeCheckpoint = this.writeCheckpoint().finally(() => {\n      this.activeCheckpoint = null;\n\n      // If there was a pending update requested while we were writing,\n      // trigger another write\n      if (this.pendingUpdate) {\n        this.pendingUpdate = false;\n        this.updateCheckpoint();\n      }\n    });\n  }\n\n  private havePrintedUrl = false;\n  private async writeCheckpoint() {\n    if (!this.root) return;\n\n    await this.checkpointListener?.(this.root);\n\n    try {\n      // Create a deep copy of the execution tree for masking\n      const cloneWithoutFunctions = (obj: unknown): unknown => {\n        if (this.isNativeFunction(obj) || typeof obj === \"function\") {\n          return \"[function]\";\n        }\n        if (Array.isArray(obj)) {\n          return obj.map(cloneWithoutFunctions);\n        }\n        if (obj && typeof obj === \"object\" && !ArrayBuffer.isView(obj)) {\n          return Object.fromEntries(\n            Object.entries(obj).map(([key, value]) => [\n              key,\n              cloneWithoutFunctions(value),\n            ]),\n          );\n        }\n        return obj;\n      };\n\n      const treeCopy = cloneWithoutFunctions(this.root);\n      const maskedRoot = this.maskExecutionTree(treeCopy as ExecutionNode);\n      const steps = this.countSteps(this.root);\n\n      function replacer(key: string, value: unknown): unknown {\n        if (typeof value === \"function\") {\n          console.warn(\"[GenSX] Unserializable function found in checkpoint\", {\n            key,\n          });\n          return \"[function]\";\n        }\n\n        if (typeof value === \"object\" && value !== null) {\n          if (isAsyncIterable(value)) {\n            console.warn(\n              \"[GenSX] Unserializable async iterable found in checkpoint\",\n              {\n                key,\n              },\n            );\n            return \"[async-iterator]\";\n          }\n          if (isReadableStream(value)) {\n            console.warn(\n              \"[GenSX] Unserializable readable stream found in checkpoint\",\n              {\n                key,\n              },\n            );\n            return \"[readable-stream]\";\n          }\n        }\n\n        if (typeof value === \"symbol\") {\n          return `[Symbol(${value.toString()})]`;\n        }\n\n        return value;\n      }\n\n      // Separately gzip the rawExecution data\n      const compressedExecution = await gzipAsync(\n        Buffer.from(\n          JSON.stringify(\n            {\n              ...maskedRoot,\n              updatedAt: Date.now(),\n            },\n            replacer,\n          ),\n          \"utf-8\",\n        ),\n      );\n      const base64CompressedExecution =\n        Buffer.from(compressedExecution).toString(\"base64\");\n\n      const workflowName = this.workflowName ?? this.root.componentName;\n      const payload = {\n        executionId: this.executionRunId,\n        version: this.version,\n        schemaVersion: 2,\n        workflowName,\n        startedAt: this.root.startTime,\n        completedAt: this.root.endTime,\n        rawExecution: base64CompressedExecution,\n        steps,\n        runtime: this.runtime,\n        runtimeVersion: this.runtimeVersion,\n        executionRunId: this.executionRunId,\n      };\n\n      const compressedData = await gzipAsync(JSON.stringify(payload));\n\n      let response: Response;\n      if (!this.traceId) {\n        // create the trace\n        const url = join(this.apiBaseUrl, `/org/${this.org}/traces`);\n        response = await fetch(url, {\n          method: \"POST\",\n          headers: {\n            \"Content-Type\": \"application/json\",\n            \"Content-Encoding\": \"gzip\",\n            Authorization: `Bearer ${this.apiKey}`,\n            \"accept-encoding\": \"gzip\",\n            \"User-Agent\": USER_AGENT,\n          },\n          body: compressedData,\n        });\n      } else {\n        const url = join(\n          this.apiBaseUrl,\n          `/org/${this.org}/traces/${this.traceId}`,\n        );\n        // otherwise update the trace\n        response = await fetch(url, {\n          method: \"PUT\",\n          headers: {\n            \"Content-Type\": \"application/json\",\n            \"Content-Encoding\": \"gzip\",\n            Authorization: `Bearer ${this.apiKey}`,\n            \"accept-encoding\": \"gzip\",\n            \"User-Agent\": USER_AGENT,\n          },\n          body: compressedData,\n        });\n      }\n\n      if (!response.ok) {\n        console.error(`[Checkpoint] Failed to save checkpoint, server error:`, {\n          status: response.status,\n          message: await response.text(),\n        });\n        return;\n      }\n\n      const responseBody = (await response.json()) as {\n        executionId: string;\n        traceId: string;\n        workflowName: string;\n      };\n\n      this.traceId = responseBody.traceId;\n\n      if (this.printUrl && !this.havePrintedUrl) {\n        const executionUrl = new URL(\n          `/${this.org}/default/executions/${responseBody.executionId}?workflowName=${responseBody.workflowName}`,\n          this.consoleBaseUrl,\n        );\n        this.havePrintedUrl = true;\n        console.info(\n          `\\n\\n\\x1b[33m[GenSX] View execution at:\\x1b[0m \\x1b[1;34m${executionUrl.toString()}\\x1b[0m\\n\\n`,\n        );\n      }\n    } catch (error) {\n      console.error(`[Checkpoint] Failed to save checkpoint:`, { error });\n    } finally {\n      // Always increment, just in case the write was received by the server. The version value does not need to be\n      // perfectly monotonic, just simply the next value needs to be greater than the previous value.\n      this.version++;\n    }\n  }\n\n  private countSteps(node: ExecutionNode): number {\n    return node.children.reduce(\n      (acc, child) => acc + this.countSteps(child),\n      1,\n    );\n  }\n\n  private maskExecutionTree(node: ExecutionNode): ExecutionNode {\n    // Mask props\n    node.props = this.scrubSecrets(node.props, node) as Record<string, unknown>;\n\n    // Mask output if present\n    if (node.output !== undefined) {\n      node.output = this.scrubSecrets(node.output, node, \"output\");\n    }\n\n    // Mask metadata if present\n    if (node.metadata) {\n      node.metadata = this.scrubSecrets(\n        node.metadata,\n        node,\n        \"metadata\",\n      ) as Record<string, unknown>;\n    }\n\n    // Recursively mask children\n    node.children = node.children.map((child) => this.maskExecutionTree(child));\n\n    return node;\n  }\n\n  private isEqual(a: unknown, b: unknown): boolean {\n    // Handle primitives\n    if (a === b) return true;\n\n    // If either isn't an object, they're not equal\n    if (!a || !b || typeof a !== \"object\" || typeof b !== \"object\") {\n      return false;\n    }\n\n    // Handle arrays\n    if (Array.isArray(a) && Array.isArray(b)) {\n      return (\n        a.length === b.length &&\n        a.every((item, index) => this.isEqual(item, b[index]))\n      );\n    }\n\n    // Handle objects\n    if (!Array.isArray(a) && !Array.isArray(b)) {\n      const aKeys = Object.keys(a);\n      const bKeys = Object.keys(b);\n      return (\n        aKeys.length === bKeys.length &&\n        aKeys.every((key) =>\n          this.isEqual(a[key as keyof typeof a], b[key as keyof typeof b]),\n        )\n      );\n    }\n\n    return false;\n  }\n\n  private withNode<T>(node: ExecutionNode, fn: () => T): T {\n    this.currentNodeChain.push(node);\n    try {\n      return fn();\n    } finally {\n      this.currentNodeChain.pop();\n    }\n  }\n\n  private getEffectiveSecrets(): Set<unknown> {\n    const allSecrets = new Set<unknown>();\n    for (const node of this.currentNodeChain) {\n      const nodeSecrets = this._secretValues.get(node.id);\n      if (nodeSecrets) {\n        for (const secret of nodeSecrets) {\n          allSecrets.add(secret);\n        }\n      }\n    }\n    return allSecrets;\n  }\n\n  private registerSecrets(\n    props: Record<string, unknown>,\n    paths: string[],\n    node: ExecutionNode,\n  ) {\n    this.withNode(node, () => {\n      // Initialize secrets set for this node\n      let nodeSecrets = this._secretValues.get(node.id);\n      if (!nodeSecrets) {\n        nodeSecrets = new Set();\n        this._secretValues.set(node.id, nodeSecrets);\n      }\n\n      // Use paths purely for collection\n      for (const path of paths) {\n        const value = this.getValueAtPath(props, path);\n        if (value !== undefined) {\n          this.collectSecretValues(value, nodeSecrets);\n        }\n      }\n    });\n  }\n\n  private collectSecretValues(\n    data: unknown,\n    nodeSecrets: Set<unknown>,\n    visited = new WeakSet(),\n  ): void {\n    // Skip if already visited to prevent cycles\n    if (data && typeof data === \"object\") {\n      if (visited.has(data)) {\n        return;\n      }\n      visited.add(data);\n    }\n\n    // Handle primitive values\n    if (typeof data === \"string\") {\n      if (data.length >= this.MIN_SECRET_LENGTH) {\n        nodeSecrets.add(data);\n      }\n      return;\n    }\n\n    // Skip other primitives\n    if (!data || typeof data !== \"object\") {\n      return;\n    }\n\n    // Handle arrays and objects (excluding ArrayBuffer views)\n    if (Array.isArray(data) || !ArrayBuffer.isView(data)) {\n      const values = Array.isArray(data) ? data : Object.values(data);\n      values.forEach((value) => {\n        this.collectSecretValues(value, nodeSecrets, visited);\n      });\n    }\n  }\n\n  private scrubSecrets(\n    data: unknown,\n    nodeToScrub: ExecutionNode,\n    path = \"\",\n  ): unknown {\n    const node = this.nodes.get(nodeToScrub);\n    if (!node) {\n      throw new Error(\"Node not found\");\n    }\n    return this.withNode(node, () => {\n      // Handle native functions\n      if (this.isNativeFunction(data)) {\n        return \"[native function]\";\n      }\n\n      // Handle functions\n      if (typeof data === \"function\") {\n        return \"[function]\";\n      }\n\n      // Handle primitive values\n      if (typeof data === \"string\") {\n        return this.scrubString(data);\n      }\n\n      // Skip other primitives\n      if (!data || typeof data !== \"object\") {\n        return data;\n      }\n\n      // Handle arrays\n      if (Array.isArray(data)) {\n        return data.map((item, index) =>\n          this.scrubSecrets(item, node, path ? `${path}.${index}` : `${index}`),\n        );\n      }\n\n      // Handle objects (excluding ArrayBuffer views)\n      if (!ArrayBuffer.isView(data)) {\n        return Object.fromEntries(\n          Object.entries(data).map(([key, value]) => [\n            key,\n            this.scrubSecrets(value, node, path ? `${path}.${key}` : key),\n          ]),\n        );\n      }\n\n      // Handle objects that shouldn't be cloned\n      if (ArrayBuffer.isView(data)) return data;\n\n      return data;\n    });\n  }\n\n  private scrubString(value: string): string {\n    const effectiveSecrets = this.getEffectiveSecrets();\n    let result = value;\n\n    // Sort secrets by length (longest first) to handle overlapping secrets correctly\n    const secrets = Array.from(effectiveSecrets)\n      .filter(\n        (s) => typeof s === \"string\" && s.length >= this.MIN_SECRET_LENGTH,\n      )\n      .sort((a, b) => String(b).length - String(a).length);\n\n    // Replace each secret with [secret]\n    for (const secret of secrets) {\n      if (typeof secret === \"string\") {\n        // Only replace if the secret is actually in the string\n        if (result.includes(secret)) {\n          const escapedSecret = secret.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n          const regex = new RegExp(escapedSecret, \"g\");\n          result = result.replace(regex, \"[secret]\");\n        }\n      }\n    }\n\n    return result;\n  }\n\n  private getValueAtPath(obj: Record<string, unknown>, path: string): unknown {\n    return path.split(\".\").reduce<unknown>((curr: unknown, key: string) => {\n      if (curr && typeof curr === \"object\") {\n        return (curr as Record<string, unknown>)[key];\n      }\n      return undefined;\n    }, obj);\n  }\n\n  private cloneValue(value: unknown): unknown {\n    // Handle null/undefined\n    if (value == null) return value;\n\n    // Don't clone functions\n    if (typeof value === \"function\") return value;\n\n    // Handle primitive values\n    if (typeof value !== \"object\") return value;\n\n    // Handle arrays\n    if (Array.isArray(value)) {\n      return value.map((item) => this.cloneValue(item));\n    }\n\n    // Handle objects that shouldn't be cloned\n    if (ArrayBuffer.isView(value)) return value;\n\n    // Check for toJSON method before doing regular object cloning\n    const objValue = value as { toJSON?: () => unknown };\n    if (typeof objValue.toJSON === \"function\") {\n      return this.cloneValue(objValue.toJSON());\n    }\n\n    // For regular objects, clone each property\n    return Object.fromEntries(\n      Object.entries(value).map(([key, val]) => [key, this.cloneValue(val)]),\n    );\n  }\n\n  /**\n   * Due to the async nature of component execution, nodes can arrive in any order.\n   * For example, in a tree like:\n   *    BlogWriter\n   *      └─ OpenAIProvider\n   *         └─ Research\n   *\n   * The Research component might execute before OpenAIProvider due to:\n   * - Parallel execution of components\n   * - Different resolution times for promises\n   * - Network delays in API calls\n   *\n   * To handle this, we:\n   * 1. Track orphaned nodes (children with parentIds where parents aren't yet in the graph) because:\n   *    - We need to maintain the true hierarchy regardless of arrival order\n   *    - We can't write incomplete checkpoints that would show incorrect relationships\n   *    - The tree structure is important for debugging and monitoring\n   *\n   * 2. Allow root replacement because:\n   *    - The first node to arrive might not be the true root\n   *    - We need to maintain correct component hierarchy for visualization\n   *    - Checkpoint consumers expect a complete, properly ordered tree\n   *\n   * This approach ensures that even if components resolve out of order,\n   * the final checkpoint will always show the correct logical structure\n   * of the execution.\n   */\n  addNode(\n    partialNode: Partial<ExecutionNode> & {\n      id: NodeId;\n    },\n    parentNode?: ExecutionNode,\n    { skipCheckpointUpdate }: { skipCheckpointUpdate?: boolean } = {},\n  ): ExecutionNode {\n    const clonedPartial = this.cloneValue(\n      partialNode,\n    ) as Partial<ExecutionNode> & { id: NodeId };\n    const node: ExecutionNode = {\n      completed: false,\n      componentName: \"Unknown\",\n      startTime: Date.now(),\n      // This gives us nanosecond precision for the start time, but without a stable epoch.\n      // This lets us relatively compare the start time between nodes, but not absolutely know when it started (use startTime for that)\n      startedAt: hrtime.bigint().toString(),\n      children: [],\n      props: {},\n      ...clonedPartial, // Clone mutable state while preserving functions\n    };\n\n    // Register any secrets from componentOpts\n    if (node.componentOpts?.secretProps) {\n      this.registerSecrets(node.props, node.componentOpts.secretProps, node);\n    }\n\n    // Store enhanced node\n    this.nodes.set(node);\n\n    const parent = parentNode ? this.nodes.get(parentNode) : undefined;\n    if (!parent && parentNode) {\n      console.warn(\"[Checkpoint] Parent node not stored\", {\n        parentNode: {\n          id: parentNode.id,\n        },\n      });\n      // Parent doesn't exist yet - track as orphaned\n      node.parentId = parentNode.id;\n      this.handleOrphanedNode(node, parentNode);\n    }\n\n    if (parent) {\n      // Normal case - parent exists\n      this.attachToParent(node, parent);\n    } else {\n      // Handle root node case\n      if (!this.root) {\n        this.root = node;\n      } else if (this.root.parentId === node.id) {\n        // Current root was waiting for this node as parent\n        this.attachToParent(this.root, node);\n        this.root = node;\n      } else {\n        console.warn(\n          `[Checkpoint] Multiple root nodes detected: existing=${this.root.componentName}, new=${node.componentName}`,\n        );\n      }\n    }\n\n    // Check if this node is a parent any orphans are waiting for\n    const waitingChildren = this.orphanedNodes.get(node.id);\n    if (waitingChildren) {\n      // Attach all waiting children\n      for (const orphan of waitingChildren) {\n        this.attachToParent(orphan, node);\n      }\n      // Clear the orphans list for this parent\n      this.orphanedNodes.delete(node.id);\n    }\n\n    if (!skipCheckpointUpdate) {\n      this.updateCheckpoint();\n    }\n    return node;\n  }\n\n  private addCachedNodeRecursively(\n    node: ExecutionNode,\n    parentNode?: ExecutionNode,\n  ) {\n    const parentPath = parentNode?.id ? getPathId(parentNode.id) : \"\";\n    const nodeId = generateNodeId(\n      node.componentName,\n      node.props,\n      node.componentOpts?.idPropsKeys,\n      parentPath,\n      this.getNextCallIndex(\n        parentPath,\n        node.componentName,\n        node.props,\n        node.componentOpts?.idPropsKeys,\n      ),\n    );\n    // Check if this node already exists in the current checkpoint\n    if (this.nodes.has(nodeId)) {\n      console.debug(`[Replay] Node ${nodeId} already exists, skipping subtree`);\n      return;\n    }\n\n    // Create a copy of the node to avoid modifying the original\n    const nodeCopy: ExecutionNode = {\n      ...node,\n      id: nodeId,\n      startedAt: hrtime.bigint().toString(),\n      children: [], // We'll add children recursively\n    };\n\n    // Add this node to the current checkpoint\n    this.nodes.set(nodeCopy);\n\n    const parent = parentNode ? this.nodes.get(parentNode) : undefined;\n    if (parentNode && !parent) {\n      console.warn(\"[Checkpoint] Parent node not stored\", {\n        parentNode: {\n          id: parentNode.id,\n        },\n      });\n\n      // Parent doesn't exist yet - track as orphaned\n      this.handleOrphanedNode(nodeCopy, parentNode);\n    }\n\n    // Handle parent-child relationships\n    if (parent) {\n      this.attachToParent(nodeCopy, parent);\n    } else {\n      // This is a root node\n      this.root ??= nodeCopy;\n    }\n\n    // Check if this node resolves any orphaned children\n    const waitingChildren = this.orphanedNodes.get(nodeCopy.id);\n    if (waitingChildren) {\n      for (const orphan of waitingChildren) {\n        this.attachToParent(orphan, nodeCopy);\n      }\n      this.orphanedNodes.delete(nodeCopy.id);\n    }\n\n    // Recursively add all children\n    node.children.forEach((child) => {\n      if (child.completed) {\n        this.addCachedNodeRecursively(child, nodeCopy);\n      }\n    });\n  }\n\n  completeNode(\n    nodeToUpdate: ExecutionNode,\n    output: unknown,\n    { wrapInPromise }: { wrapInPromise?: boolean } = {},\n  ) {\n    const node = this.nodes.get(nodeToUpdate);\n\n    if (node) {\n      node.completed = true;\n      node.endTime = Date.now();\n      node.output = this.cloneValue(output);\n\n      if (wrapInPromise) {\n        node.output = {\n          __gensxSerialized: true,\n          type: \"promise\",\n\n          value: node.output,\n        };\n      }\n\n      if (\n        node.componentOpts?.secretOutputs &&\n        output !== STREAMING_PLACEHOLDER\n      ) {\n        this.withNode(node, () => {\n          let nodeSecrets = this._secretValues.get(node.id);\n          if (!nodeSecrets) {\n            nodeSecrets = new Set();\n            this._secretValues.set(node.id, nodeSecrets);\n          }\n          this.collectSecretValues(output, nodeSecrets);\n        });\n      }\n\n      this.updateCheckpoint();\n    } else {\n      console.warn(`[Tracker] Attempted to complete unknown node:`, {\n        id: nodeToUpdate.id,\n      });\n    }\n  }\n\n  addMetadata(nodeToUpdate: ExecutionNode, metadata: Record<string, unknown>) {\n    const node = this.nodes.get(nodeToUpdate);\n    if (node) {\n      node.metadata = {\n        ...node.metadata,\n        ...metadata,\n      };\n      this.updateCheckpoint();\n    }\n  }\n\n  // TODO: What if we have already sent some checkpoints?\n  setWorkflowName(name: string) {\n    this.workflowName = name;\n  }\n\n  setPrintUrl(printUrl: boolean) {\n    this.printUrl = printUrl;\n  }\n\n  updateNode(nodeToUpdate: ExecutionNode, updates: Partial<ExecutionNode>) {\n    const node = this.nodes.get(nodeToUpdate);\n    if (node) {\n      if (\n        \"output\" in updates &&\n        node.componentOpts?.secretOutputs &&\n        updates.output !== STREAMING_PLACEHOLDER\n      ) {\n        this.withNode(node, () => {\n          let nodeSecrets = this._secretValues.get(node.id);\n          if (!nodeSecrets) {\n            nodeSecrets = new Set();\n            this._secretValues.set(node.id, nodeSecrets);\n          }\n          this.collectSecretValues(updates.output, nodeSecrets);\n        });\n      }\n\n      Object.assign(node, this.cloneValue(updates));\n      this.updateCheckpoint();\n    } else {\n      console.warn(`[Tracker] Attempted to update unknown node:`, {\n        id: nodeToUpdate.id,\n      });\n    }\n  }\n\n  write() {\n    this.updateCheckpoint();\n  }\n\n  async waitForPendingUpdates(): Promise<void> {\n    // If there's an active checkpoint, wait for it\n    if (this.activeCheckpoint) {\n      await this.activeCheckpoint;\n    }\n    // If that checkpoint triggered another update, wait again\n    if (this.pendingUpdate || this.activeCheckpoint) {\n      await this.waitForPendingUpdates();\n    }\n  }\n\n  private buildReplayLookup(node: ExecutionNode) {\n    this.addToReplayLookup(node);\n\n    // Ensure all the nodes are in order of when they started, so we can just pick the appropriate node off the front of the list\n    this.replayLookup.sort((a, b) =>\n      Number(BigInt(a.startedAt) - BigInt(b.startedAt)),\n    );\n  }\n\n  private addToReplayLookup(node: ExecutionNode) {\n    this.replayLookup.push(node);\n\n    node.children.forEach((child) => {\n      this.addToReplayLookup(child);\n    });\n  }\n\n  /**\n   * 1. Check the first node in the list. If it has the same path, content ID and call index use it.\n   * 2. If something does not match, look through the list to find a potential match (and warn about non-deterministic behavior if there is a match):\n   *   a. Look for the first node that has the same path, content ID and call index.\n   *   b. Look for the first node that has the same path and content ID.\n   *   c. Look for the first node that has the same content ID.\n   *   d. Look for the first node that has the same component name.\n   * 3. If no match is found, this component is probably not in the checkpoint. If there are nodes in the checkpoint, this indicates non-deterministic behavior.\n   * @param nodeId\n   * @returns\n   */\n  getNodeFromCheckpoint(\n    nodeId: NodeId,\n  ):\n    | { found: false; node?: ExecutionNode }\n    | { found: true; node: ExecutionNode } {\n    if (!this.replayLookup.length) {\n      return { found: false };\n    }\n\n    const [pathId, contentId] = nodeId.split(\":\");\n    const componentName = pathId.split(\"-\").pop();\n\n    // Strategy 1: Exact Node ID Match\n    const exactNode = this.replayLookup.find((node) => node.id === nodeId);\n    if (exactNode) {\n      if (this.replayLookup.indexOf(exactNode) !== 0) {\n        console.debug(\n          `[Replay] Non-deterministic behavior detected ${exactNode.id} is not the next node in the checkpoint (next: ${this.replayLookup[0].id})`,\n        );\n      }\n      this.replayLookup.splice(this.replayLookup.indexOf(exactNode), 1);\n      return { found: true, node: exactNode };\n    }\n\n    // Strategy 2: Path/Content matching (same path, same content, different call index)\n    const pathContentNode = this.replayLookup.find((node) => {\n      const [nodePathId, nodeContentId] = node.id.split(\":\");\n      return nodePathId === pathId && nodeContentId === contentId;\n    });\n    if (pathContentNode) {\n      console.debug(\n        `[Replay] Non-deterministic behavior detected: Found node with same path and content but different call index (target: ${nodeId}, found: ${pathContentNode.id})`,\n      );\n      this.replayLookup.splice(this.replayLookup.indexOf(pathContentNode), 1);\n      return { found: true, node: pathContentNode };\n    }\n\n    // Strategy 3: Content-based matching (same content/component name, different path)\n    const contentNode = this.replayLookup.find((node) => {\n      const nodeContentId = getContentId(node.id);\n      return (\n        node.componentName === componentName && nodeContentId === contentId\n      );\n    });\n    if (contentNode) {\n      console.debug(\n        `[Replay] Non-deterministic behavior detected: Found node with same content but different path (target: ${nodeId}, found: ${contentNode.id})`,\n      );\n      this.replayLookup.splice(this.replayLookup.indexOf(contentNode), 1);\n      return { found: true, node: contentNode };\n    }\n\n    console.debug(\n      `[Replay] No match found for node ${nodeId}, but there are unused nodes in the checkpoint. This may indicate non-deterministic behavior.`,\n      JSON.stringify(\n        // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n        this.replayLookup.map((node) => this.slimCheckpoint(node)),\n        null,\n        2,\n      ),\n    );\n    return { found: false };\n  }\n\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  public slimCheckpoint(checkpoint?: ExecutionNode): any {\n    if (!checkpoint) return undefined;\n    const slimmed = {\n      id: checkpoint.id,\n      completed: checkpoint.completed,\n      startedAt: checkpoint.startedAt,\n      // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n      children: checkpoint.children.map((child) => this.slimCheckpoint(child)),\n    };\n    return slimmed;\n  }\n\n  // Checkpoint reconstruction methods\n  addCachedSubtreeToCheckpoint(node: ExecutionNode, parent?: ExecutionNode) {\n    console.debug(\n      `[Replay] Adding cached subtree for ${node.componentName} (${node.id})`,\n    );\n\n    if (!node.completed) {\n      return;\n    }\n\n    this.addCachedNodeRecursively(node, parent);\n\n    // Validate tree structure after adding cached nodes\n    if (!this.isTreeValid()) {\n      console.warn(\n        `[Replay] Tree validation failed after adding cached subtree for ${node.componentName}`,\n      );\n    }\n  }\n}\n\nconst pathIdsMap = new Map<string, PathId>();\nconst contentIdsMap = new Map<string, ContentId>();\n\n// Helpers for working with node IDs\n// eg. \"Workflow/Component:456:789\" -> \"Workflow/Component\", \"456\", \"789\"\nfunction getPathId(id: NodeId): PathId {\n  const pathId = pathIdsMap.get(id) ?? id.split(\":\")[0];\n  pathIdsMap.set(id, pathId);\n  return pathId;\n}\n\nfunction getContentId(id: NodeId): ContentId {\n  const contentId = contentIdsMap.get(id) ?? id.split(\":\")[1];\n  contentIdsMap.set(id, contentId);\n  return contentId;\n}\n"],"names":["promisify","gzip","stringifyProps","createHash","config","readConfig","isAsyncIterable","isReadableStream","Buffer","join","USER_AGENT","hrtime","nodeId","generateNodeId","STREAMING_PLACEHOLDER"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,SAAS,GAAGA,mBAAS,CAACC,cAAI,CAAC;AAEjC,MAAM,OAAO,CAAA;;AAEH,IAAA,QAAQ,GAAG,IAAI,GAAG,EAAa;;AAG/B,IAAA,UAAU,GAAG,IAAI,GAAG,EAAuB,CAAC;AAC5C,IAAA,aAAa,GAAG,IAAI,GAAG,EAAuB,CAAC;AAC/C,IAAA,iBAAiB,GAAG,IAAI,GAAG,EAAuB,CAAC;AAE3D,IAAA,GAAG,CAAC,IAAO,EAAA;QACT,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC;;QAGhC,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QACjC,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;gBAChC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;;AAExC,YAAA,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;;QAG3C,MAAM,SAAS,GAAG,YAAY,CAAC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