Describe the issue
Bundlers fail to build apps importing @hatchet-dev/typescript-sdk/v1 because v1/agent/openai.js contains a static require('@openai/agents') call that is statically traced by bundlers at build time. @openai/agents is not declared in the SDK's dependencies, peerDependencies, or optionalDependencies, so it is never installed, and the build fails with an unresolvable module error.
The runtime guard before the require (a try { require.resolve('@openai/agents') } catch {} check) protects Node at runtime, but does not help bundlers — they tokenize and resolve every literal require(...) call they can statically reach.
v1/agent/claude.js follows the same pattern with @anthropic-ai/claude-agent-sdk.
This was introduced between v1.22.0 and v1.22.1. v1.22.0 does not contain v1/agent/openai.js and builds cleanly. v1.22.1 and v1.22.2 both reproduce the failure.
Environment
- SDK:
@hatchet-dev/typescript-sdk v1.22.1, v1.22.2 (v1.22.0 unaffected)
- Bundler: Bun
bun build --target node (Bun versions v1.3.0 and v1.3.13 both reproduce). webpack/esbuild with static tracing will exhibit the same behavior.
Expected behavior
A library that ships optional integrations should let consumers build without installing every supported third-party SDK. Either:
- Declare
@openai/agents and @anthropic-ai/claude-agent-sdk as optionalDependencies or peerDependenciesMeta.*.optional, OR
- Use a bundler-opaque dynamic import (
(0, eval)('require')('@openai/agents'), new Function('return import(\"@openai/agents\")'), or await import('@openai/agents')) so static analysis does not try to resolve the module.
Code to Reproduce, Logs, or Screenshots
Reproducer (any consumer that imports HatchetClient from /v1):
// src/index.ts
import { HatchetClient } from '@hatchet-dev/typescript-sdk/v1'
console.log(HatchetClient.name)
Build:
$ bun build src/index.ts --target node --outdir dist
65 | const { tool } = require('@openai/agents');
^
error: Could not resolve: "@openai/agents". Maybe you need to "bun install"?
at node_modules/@hatchet-dev/typescript-sdk/v1/agent/openai.js:65:30
Offending lines in v1/agent/openai.js (1.22.1, 1.22.2):
// line 53 (inside OpenAIToolFunc)
try { require.resolve('@openai/agents'); } catch (_a) { hasOpenAIAgents = false; }
// ...
// line 65
const { tool } = require('@openai/agents');
v1/declaration.js makes agent/openai.js statically reachable from any /v1 import:
if (sdk === 'openai') {
const { OpenAIToolFunc } = require('./agent/openai');
return OpenAIToolFunc(this, ...args);
}
const { ClaudeToolFunc } = require('./agent/claude');
return ClaudeToolFunc(this, ...args);
Additional context
Workaround we are using until this is fixed: pinning the SDK to 1.22.0 via npm overrides. This avoids both the unresolvable require('@openai/agents') and the require('@anthropic-ai/claude-agent-sdk') site in agent/claude.js, and still picks up the protobufjs and OpenTelemetry transitive updates from the 1.22.x line.
Describe the issue
Bundlers fail to build apps importing
@hatchet-dev/typescript-sdk/v1becausev1/agent/openai.jscontains a staticrequire('@openai/agents')call that is statically traced by bundlers at build time.@openai/agentsis not declared in the SDK'sdependencies,peerDependencies, oroptionalDependencies, so it is never installed, and the build fails with an unresolvable module error.The runtime guard before the require (a
try { require.resolve('@openai/agents') } catch {}check) protects Node at runtime, but does not help bundlers — they tokenize and resolve every literalrequire(...)call they can statically reach.v1/agent/claude.jsfollows the same pattern with@anthropic-ai/claude-agent-sdk.This was introduced between
v1.22.0andv1.22.1.v1.22.0does not containv1/agent/openai.jsand builds cleanly.v1.22.1andv1.22.2both reproduce the failure.Environment
@hatchet-dev/typescript-sdkv1.22.1, v1.22.2 (v1.22.0 unaffected)bun build --target node(Bun versions v1.3.0 and v1.3.13 both reproduce). webpack/esbuild with static tracing will exhibit the same behavior.Expected behavior
A library that ships optional integrations should let consumers build without installing every supported third-party SDK. Either:
@openai/agentsand@anthropic-ai/claude-agent-sdkasoptionalDependenciesorpeerDependenciesMeta.*.optional, OR(0, eval)('require')('@openai/agents'),new Function('return import(\"@openai/agents\")'), orawait import('@openai/agents')) so static analysis does not try to resolve the module.Code to Reproduce, Logs, or Screenshots
Reproducer (any consumer that imports
HatchetClientfrom/v1):Build:
Offending lines in
v1/agent/openai.js(1.22.1, 1.22.2):v1/declaration.jsmakesagent/openai.jsstatically reachable from any/v1import:Additional context
Workaround we are using until this is fixed: pinning the SDK to
1.22.0via npm overrides. This avoids both the unresolvablerequire('@openai/agents')and therequire('@anthropic-ai/claude-agent-sdk')site inagent/claude.js, and still picks up theprotobufjsand OpenTelemetry transitive updates from the 1.22.x line.