Skip to content

Conversation

@maksymilian-majer
Copy link
Contributor

This PR resolves two issues:

Issue 1: Running pnpm lint caused a Syntax Error

> [email protected] lint /Users/.../openai-agents-js
> eslint

(node:38158) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)

Oops! Something went wrong! :(

ESLint: 9.25.1

/Users/.../openai-agents-js/eslint.config.js:12
import eslint from '@eslint/js';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (node:internal/modules/cjs/loader:1378:20)
    at Module._compile (node:internal/modules/cjs/loader:1428:41)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Module._load (node:internal/modules/cjs/loader:1104:12)
    at cjsLoader (node:internal/modules/esm/translators:346:17)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:286:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:234:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:473:24)
    at async dynamicImportConfig (/Users/.../openai-agents-js/node_modules/eslint/lib/config/config-loader.js:181:17)

I fixed it by adding changing the extension to .mjs and now the running pnpm build && pnpm test && pnpm lint works as described in the contribution guidelines.

Issue 2: Some types that were marked as @internal where exported and caused build errors

I use the SDK in an Angular project with Webpack and when I used the @openai/agents-realtime package I got the following compilation errors:

✘ [ERROR] TS2305: Module '"./guardrail"' has no exported member 'OutputGuardrailMetadata'. [plugin angular-compiler]

    node_modules/@openai/agents-core/dist/errors.d.ts:2:31:
      2 │ ...nputGuardrailResult, OutputGuardrailMetadata, OutputGuardrailRes...
        ╵                         ~~~~~~~~~~~~~~~~~~~~~~~
✘ [ERROR] TS2552: Cannot find name 'InputGuardrailDefinition'. Did you mean 'GuardrailDefinition'? [plugin angular-compiler]

    node_modules/@openai/agents-core/dist/guardrail.d.ts:8:34:
      8 │ ...ardrailDefinition = InputGuardrailDefinition | OutputGuardrailDe...
        ╵                        ~~~~~~~~~~~~~~~~~~~~~~~~
✘ [ERROR] TS2552: Cannot find name 'OutputGuardrailDefinition'. Did you mean 'GuardrailDefinition'? [plugin angular-compiler]

    node_modules/@openai/agents-core/dist/guardrail.d.ts:8:61:
      8 │ ...lDefinition = InputGuardrailDefinition | OutputGuardrailDefinition;~~~~~~~~~~~~~~~~~~~~~~~~~
✘ [ERROR] TS2304: Cannot find name 'InputGuardrailMetadata'. [plugin angular-compiler]

    node_modules/@openai/agents-core/dist/guardrail.d.ts:60:15:
      60 │     guardrail: InputGuardrailMetadata;~~~~~~~~~~~~~~~~~~~~~~
✘ [ERROR] TS2552: Cannot find name 'InputGuardrailDefinition'. Did you mean 'GuardrailDefinition'? [plugin angular-compiler]

    node_modules/@openai/agents-core/dist/guardrail.d.ts:83:92:
      83 │ ..., execute, }: DefineInputGuardrailArgs): InputGuardrailDefinition;~~~~~~~~~~~~~~~~~~~~~~~~
✘ [ERROR] TS2304: Cannot find name 'OutputGuardrailMetadata'. [plugin angular-compiler]

    node_modules/@openai/agents-core/dist/guardrail.d.ts:95:47:
      95 │ ...drailResult<TMeta = OutputGuardrailMetadata, TOutput extends Ag...
         ╵                        ~~~~~~~~~~~~~~~~~~~~~~~
✘ [ERROR] TS2724: '"./guardrail"' has no exported member named 'defineOutputGuardrail'. Did you mean 'defineInputGuardrail'? [plugin angular-compiler]
    node_modules/@openai/agents-core/dist/index.d.ts:6:9:
      6 │ export { defineOutputGuardrail, GuardrailFunctionOutput, InputGuard...
        ╵          ~~~~~~~~~~~~~~~~~~~~~
  'defineInputGuardrail' is declared here.
    node_modules/@openai/agents-core/dist/guardrail.d.ts:83:24:
      83 │ export declare function defineInputGuardrail({ name, execute, }: D...
         ╵                         ~~~~~~~~~~~~~~~~~~~~
✘ [ERROR] TS2305: Module '"./guardrail"' has no exported member 'InputGuardrailMetadata'. [plugin angular-compiler]
    node_modules/@openai/agents-core/dist/index.d.ts:6:125:
      6 │ ...ardrailFunctionArgs, InputGuardrailMetadata, InputGuardrailResul...
        ╵                         ~~~~~~~~~~~~~~~~~~~~~~
✘ [ERROR] TS2724: '"./guardrail"' has no exported member named 'OutputGuardrailDefinition'. Did you mean 'GuardrailDefinition'? [plugin angular-compiler]
    node_modules/@openai/agents-core/dist/index.d.ts:6:188:
      6 │ ...t, OutputGuardrail, OutputGuardrailDefinition, OutputGuardrailFu...
        ╵                        ~~~~~~~~~~~~~~~~~~~~~~~~~
✘ [ERROR] TS2305: Module '"./guardrail"' has no exported member 'OutputGuardrailMetadata'. [plugin angular-compiler]
    node_modules/@openai/agents-core/dist/index.d.ts:6:269:
      6 │ ...ardrailFunctionArgs, OutputGuardrailMetadata, OutputGuardrailRes...

I fixed this by removing @internal and published an npm package to test and ensure it works in my Angular project.

- Remove @internal tags from InputGuardrailDefinition, OutputGuardrailDefinition,
  InputGuardrailMetadata, OutputGuardrailMetadata, DefineOutputGuardrailArgs, and defineOutputGuardrail
- Update JSDoc comments to be more appropriate for public APIs
@changeset-bot
Copy link

changeset-bot bot commented Jun 11, 2025

🦋 Changeset detected

Latest commit: a2330e9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@openai/agents-core Patch
@openai/agents-openai Patch
@openai/agents-realtime Patch
@openai/agents Patch
@openai/agents-extensions Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dkundel-openai dkundel-openai merged commit 1fccdca into openai:main Jun 11, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants