Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Vendor strip-ansi npm module to avoid ESM-related issues (#895)
Mish Ushakov44365999e182
diff --git a/.changeset/hungry-cups-warn.md b/.changeset/hungry-cups-warn.mdnew file mode 100644index 000000000..a35d72079--- /dev/null+++ b/.changeset/hungry-cups-warn.md@@ -0,0 +1,5 @@+---+'e2b': patch+---++inline strip-ansi to avoid esm-related errorsdiff --git a/packages/js-sdk/package.json b/packages/js-sdk/package.jsonindex 72fb3cf4b..6ea60ee1b 100644--- a/packages/js-sdk/package.json+++ b/packages/js-sdk/package.json@@ -94,7 +94,6 @@"glob": "^11.0.3","openapi-fetch": "^0.9.7","platform": "^1.3.6",- "strip-ansi": "^7.1.0","tar": "^7.4.3"},"engines": {diff --git a/packages/js-sdk/src/template/buildApi.ts b/packages/js-sdk/src/template/buildApi.tsindex 5acb70ee2..ef1a2a57f 100644--- a/packages/js-sdk/src/template/buildApi.ts+++ b/packages/js-sdk/src/template/buildApi.ts@@ -2,7 +2,7 @@ import { ApiClient, paths, handleApiError } from '../api'import { BuildError, FileUploadError } from './errors'import { LogEntry } from './types'import { tarFileStreamUpload } from './utils'-import stripAnsi from 'strip-ansi'+import { stripAnsi } from '../utils'type RequestBuildInput = {alias: stringdiff --git a/packages/js-sdk/src/template/types.ts b/packages/js-sdk/src/template/types.tsindex 28b5c13e2..f8971bf9b 100644--- a/packages/js-sdk/src/template/types.ts+++ b/packages/js-sdk/src/template/types.ts@@ -1,4 +1,4 @@-import stripAnsi from 'strip-ansi'+import { stripAnsi } from '../utils'import { ReadyCmd } from './readycmd'export type Instruction = {diff --git a/packages/js-sdk/src/utils.ts b/packages/js-sdk/src/utils.tsindex fc56db125..85ce5f3f5 100644--- a/packages/js-sdk/src/utils.ts+++ b/packages/js-sdk/src/utils.ts@@ -84,3 +84,22 @@ export async function dynamicTar(): Promise<typeof import('tar')> {// @ts-ignorereturn await import('tar')}++// Source: https://github.com/chalk/ansi-regex/blob/main/index.js+function ansiRegex({ onlyFirst = false } = {}) {+ // Valid string terminator sequences are BEL, ESC\, and 0x9c+ const ST = '(?:\\u0007|\\u001B\\u005C|\\u009C)'+ // OSC sequences only: ESC ] ... ST (non-greedy until the first ST)+ const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`+ // CSI and related: ESC/C1, optional intermediates, optional params (supports ; and :) then final byte+ const csi =+ '[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]'++ const pattern = `${osc}|${csi}`++ return new RegExp(pattern, onlyFirst ? undefined : 'g')+}++export function stripAnsi(text: string): string {+ return text.replace(ansiRegex(), '')+}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 70a247016..c4512492a 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -347,9 +347,6 @@ importers:platform:specifier: ^1.3.6version: 1.3.6- strip-ansi:- specifier: ^7.1.0- version: 7.1.0tar:specifier: ^7.4.3version: 7.4.3@@ -11171,7 +11168,7 @@ snapshots:dependencies:- node-gyp-build: 4.6.1+ node-gyp-build: 4.8.4dependencies:@@ -14136,8 +14133,7 @@ snapshots:- optional: true+ [email protected]: {}dependencies: