Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
feat: pretty default logs for build helper (#925)
Jakub Dobrya01c2374a977
diff --git a/.changeset/selfish-tools-add.md b/.changeset/selfish-tools-add.mdnew file mode 100644index 000000000..386704b05--- /dev/null+++ b/.changeset/selfish-tools-add.md@@ -0,0 +1,7 @@+---+'@e2b/python-sdk': patch+'e2b': patch+'@e2b/cli': patch+---++add template build logs pretty output helperdiff --git a/packages/cli/src/commands/template/build-v2.ts b/packages/cli/src/commands/template/build-v2.tsindex c43df7b06..e2d9b4f8a 100644--- a/packages/cli/src/commands/template/build-v2.ts+++ b/packages/cli/src/commands/template/build-v2.ts@@ -1,6 +1,6 @@import * as boxen from 'boxen'import * as commander from 'commander'-import { Template, TemplateClass } from 'e2b'+import { defaultBuildLogger, Template, TemplateClass } from 'e2b'import { connectionConfig, ensureAccessToken, ensureAPIKey } from 'src/api'import {defaultDockerfileName,@@ -144,7 +144,7 @@ export const buildV2Command = new commander.Command('build-v2')skipCache: opts.noCache,apiKey: apiKey,domain: domain,- onBuildLogs: (logEntry) => console.log(logEntry.toString()),+ onBuildLogs: defaultBuildLogger(),})} catch (error) {console.error('\n❌ Template build failed.')diff --git a/packages/cli/src/templates/python-build-async.hbs b/packages/cli/src/templates/python-build-async.hbsindex cc0a2a3a8..c067716bd 100644--- a/packages/cli/src/templates/python-build-async.hbs+++ b/packages/cli/src/templates/python-build-async.hbs@@ -1,5 +1,5 @@import asyncio-from e2b import AsyncTemplate+from e2b import AsyncTemplate, default_build_loggerfrom template import template@@ -13,6 +13,7 @@ async def main():{{#if memoryMB}}memory_mb={{memoryMB}},{{/if}}+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/src/templates/python-build-sync.hbs b/packages/cli/src/templates/python-build-sync.hbsindex 517dcd21b..233fb3294 100644--- a/packages/cli/src/templates/python-build-sync.hbs+++ b/packages/cli/src/templates/python-build-sync.hbs@@ -1,4 +1,4 @@-from e2b import Template+from e2b import Template, default_build_loggerfrom template import template@@ -12,4 +12,5 @@ if __name__ == "__main__":{{#if memoryMB}}memory_mb={{memoryMB}},{{/if}}+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/src/templates/typescript-build.hbs b/packages/cli/src/templates/typescript-build.hbsindex 05998e2fc..345e4a3a9 100644--- a/packages/cli/src/templates/typescript-build.hbs+++ b/packages/cli/src/templates/typescript-build.hbs@@ -1,4 +1,4 @@-import { Template } from 'e2b'+import { Template, defaultBuildLogger } from 'e2b'import { template } from './template'async function main() {@@ -10,6 +10,7 @@ async function main() {{{#if memoryMB}}memoryMB: {{memoryMB}},{{/if}}+ onBuildLogs: defaultBuildLogger(),});}diff --git a/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-async/build_dev.py b/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-async/build_dev.pyindex f69bf1901..64fd36d11 100644--- a/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-async/build_dev.py+++ b/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-async/build_dev.py@@ -1,5 +1,5 @@import asyncio-from e2b import AsyncTemplate+from e2b import AsyncTemplate, default_build_loggerfrom template import template@@ -7,6 +7,7 @@ async def main():await AsyncTemplate.build(template,alias="complex-python-app-dev",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-async/build_prod.py b/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-async/build_prod.pyindex c47bc588a..89c6fbe6d 100644--- a/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-async/build_prod.py+++ b/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-async/build_prod.py@@ -1,5 +1,5 @@import asyncio-from e2b import AsyncTemplate+from e2b import AsyncTemplate, default_build_loggerfrom template import template@@ -7,6 +7,7 @@ async def main():await AsyncTemplate.build(template,alias="complex-python-app",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-sync/build_dev.py b/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-sync/build_dev.pyindex 8eefb972c..690070721 100644--- a/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-sync/build_dev.py+++ b/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-sync/build_dev.py@@ -1,4 +1,4 @@-from e2b import Template+from e2b import Template, default_build_loggerfrom template import template@@ -6,4 +6,5 @@ if __name__ == "__main__":Template.build(template,alias="complex-python-app-dev",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-sync/build_prod.py b/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-sync/build_prod.pyindex 40faea9ec..c24b743f1 100644--- a/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-sync/build_prod.py+++ b/packages/cli/tests/commands/template/fixtures/complex-python/expected/python-sync/build_prod.py@@ -1,4 +1,4 @@-from e2b import Template+from e2b import Template, default_build_loggerfrom template import template@@ -6,4 +6,5 @@ if __name__ == "__main__":Template.build(template,alias="complex-python-app",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/complex-python/expected/typescript/build.dev.ts b/packages/cli/tests/commands/template/fixtures/complex-python/expected/typescript/build.dev.tsindex 70d937e2d..ab0970e38 100644--- a/packages/cli/tests/commands/template/fixtures/complex-python/expected/typescript/build.dev.ts+++ b/packages/cli/tests/commands/template/fixtures/complex-python/expected/typescript/build.dev.ts@@ -1,9 +1,10 @@-import { Template } from 'e2b'+import { Template, defaultBuildLogger } from 'e2b'import { template } from './template'async function main() {await Template.build(template, {alias: 'complex-python-app-dev',+ onBuildLogs: defaultBuildLogger(),});}diff --git a/packages/cli/tests/commands/template/fixtures/complex-python/expected/typescript/build.prod.ts b/packages/cli/tests/commands/template/fixtures/complex-python/expected/typescript/build.prod.tsindex 4a0c008cb..f5d7df411 100644--- a/packages/cli/tests/commands/template/fixtures/complex-python/expected/typescript/build.prod.ts+++ b/packages/cli/tests/commands/template/fixtures/complex-python/expected/typescript/build.prod.ts@@ -1,9 +1,10 @@-import { Template } from 'e2b'+import { Template, defaultBuildLogger } from 'e2b'import { template } from './template'async function main() {await Template.build(template, {alias: 'complex-python-app',+ onBuildLogs: defaultBuildLogger(),});}diff --git a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-async/build_dev.py b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-async/build_dev.pyindex 45b8806bc..4f84e88b3 100644--- a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-async/build_dev.py+++ b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-async/build_dev.py@@ -1,5 +1,5 @@import asyncio-from e2b import AsyncTemplate+from e2b import AsyncTemplate, default_build_loggerfrom template import template@@ -7,6 +7,7 @@ async def main():await AsyncTemplate.build(template,alias="copy-test-dev",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-async/build_prod.py b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-async/build_prod.pyindex bbb7cdce9..c9623f9f7 100644--- a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-async/build_prod.py+++ b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-async/build_prod.py@@ -1,5 +1,5 @@import asyncio-from e2b import AsyncTemplate+from e2b import AsyncTemplate, default_build_loggerfrom template import template@@ -7,6 +7,7 @@ async def main():await AsyncTemplate.build(template,alias="copy-test",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-sync/build_dev.py b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-sync/build_dev.pyindex 862806d80..bfa5130c4 100644--- a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-sync/build_dev.py+++ b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-sync/build_dev.py@@ -1,4 +1,4 @@-from e2b import Template+from e2b import Template, default_build_loggerfrom template import template@@ -6,4 +6,5 @@ if __name__ == "__main__":Template.build(template,alias="copy-test-dev",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-sync/build_prod.py b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-sync/build_prod.pyindex 93a6b4e91..d7e50a8e4 100644--- a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-sync/build_prod.py+++ b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-sync/build_prod.py@@ -1,4 +1,4 @@-from e2b import Template+from e2b import Template, default_build_loggerfrom template import template@@ -6,4 +6,5 @@ if __name__ == "__main__":Template.build(template,alias="copy-test",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/typescript/build.dev.ts b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/typescript/build.dev.tsindex 813b63eba..e1322523a 100644--- a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/typescript/build.dev.ts+++ b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/typescript/build.dev.ts@@ -1,9 +1,10 @@-import { Template } from 'e2b'+import { Template, defaultBuildLogger } from 'e2b'import { template } from './template'async function main() {await Template.build(template, {alias: 'copy-test-dev',+ onBuildLogs: defaultBuildLogger(),});}diff --git a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/typescript/build.prod.ts b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/typescript/build.prod.tsindex a6170c019..ea6273eef 100644--- a/packages/cli/tests/commands/template/fixtures/copy-variations/expected/typescript/build.prod.ts+++ b/packages/cli/tests/commands/template/fixtures/copy-variations/expected/typescript/build.prod.ts@@ -1,9 +1,10 @@-import { Template } from 'e2b'+import { Template, defaultBuildLogger } from 'e2b'import { template } from './template'async function main() {await Template.build(template, {alias: 'copy-test',+ onBuildLogs: defaultBuildLogger(),});}diff --git a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-async/build_dev.py b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-async/build_dev.pyindex 9dbb697fe..99799c049 100644--- a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-async/build_dev.py+++ b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-async/build_dev.py@@ -1,5 +1,5 @@import asyncio-from e2b import AsyncTemplate+from e2b import AsyncTemplate, default_build_loggerfrom template import template@@ -7,6 +7,7 @@ async def main():await AsyncTemplate.build(template,alias="custom-app-dev",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-async/build_prod.py b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-async/build_prod.pyindex 849bbd3a7..8172c99da 100644--- a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-async/build_prod.py+++ b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-async/build_prod.py@@ -1,5 +1,5 @@import asyncio-from e2b import AsyncTemplate+from e2b import AsyncTemplate, default_build_loggerfrom template import template@@ -7,6 +7,7 @@ async def main():await AsyncTemplate.build(template,alias="custom-app",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-sync/build_dev.py b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-sync/build_dev.pyindex 6c80575d0..eff404af6 100644--- a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-sync/build_dev.py+++ b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-sync/build_dev.py@@ -1,4 +1,4 @@-from e2b import Template+from e2b import Template, default_build_loggerfrom template import template@@ -6,4 +6,5 @@ if __name__ == "__main__":Template.build(template,alias="custom-app-dev",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-sync/build_prod.py b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-sync/build_prod.pyindex e1f9176e5..207bf3283 100644--- a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-sync/build_prod.py+++ b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/python-sync/build_prod.py@@ -1,4 +1,4 @@-from e2b import Template+from e2b import Template, default_build_loggerfrom template import template@@ -6,4 +6,5 @@ if __name__ == "__main__":Template.build(template,alias="custom-app",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/typescript/build.dev.ts b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/typescript/build.dev.tsindex 5600f1fdf..745ab073b 100644--- a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/typescript/build.dev.ts+++ b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/typescript/build.dev.ts@@ -1,9 +1,10 @@-import { Template } from 'e2b'+import { Template, defaultBuildLogger } from 'e2b'import { template } from './template'async function main() {await Template.build(template, {alias: 'custom-app-dev',+ onBuildLogs: defaultBuildLogger(),});}diff --git a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/typescript/build.prod.ts b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/typescript/build.prod.tsindex 66b3c4b92..e40611794 100644--- a/packages/cli/tests/commands/template/fixtures/custom-commands/expected/typescript/build.prod.ts+++ b/packages/cli/tests/commands/template/fixtures/custom-commands/expected/typescript/build.prod.ts@@ -1,9 +1,10 @@-import { Template } from 'e2b'+import { Template, defaultBuildLogger } from 'e2b'import { template } from './template'async function main() {await Template.build(template, {alias: 'custom-app',+ onBuildLogs: defaultBuildLogger(),});}diff --git a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-async/build_dev.py b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-async/build_dev.pyindex 38a2b004d..c08181d51 100644--- a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-async/build_dev.py+++ b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-async/build_dev.py@@ -1,5 +1,5 @@import asyncio-from e2b import AsyncTemplate+from e2b import AsyncTemplate, default_build_loggerfrom template import template@@ -7,6 +7,7 @@ async def main():await AsyncTemplate.build(template,alias="minimal-template-dev",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-async/build_prod.py b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-async/build_prod.pyindex 301686b78..e3b2c97e4 100644--- a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-async/build_prod.py+++ b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-async/build_prod.py@@ -1,5 +1,5 @@import asyncio-from e2b import AsyncTemplate+from e2b import AsyncTemplate, default_build_loggerfrom template import template@@ -7,6 +7,7 @@ async def main():await AsyncTemplate.build(template,alias="minimal-template",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-sync/build_dev.py b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-sync/build_dev.pyindex 2efce7de8..2d71c1c19 100644--- a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-sync/build_dev.py+++ b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-sync/build_dev.py@@ -1,4 +1,4 @@-from e2b import Template+from e2b import Template, default_build_loggerfrom template import template@@ -6,4 +6,5 @@ if __name__ == "__main__":Template.build(template,alias="minimal-template-dev",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-sync/build_prod.py b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-sync/build_prod.pyindex dc1652343..0e79d75d4 100644--- a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-sync/build_prod.py+++ b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/python-sync/build_prod.py@@ -1,4 +1,4 @@-from e2b import Template+from e2b import Template, default_build_loggerfrom template import template@@ -6,4 +6,5 @@ if __name__ == "__main__":Template.build(template,alias="minimal-template",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/typescript/build.dev.ts b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/typescript/build.dev.tsindex 35c519ef3..8c4f9cc33 100644--- a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/typescript/build.dev.ts+++ b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/typescript/build.dev.ts@@ -1,9 +1,10 @@-import { Template } from 'e2b'+import { Template, defaultBuildLogger } from 'e2b'import { template } from './template'async function main() {await Template.build(template, {alias: 'minimal-template-dev',+ onBuildLogs: defaultBuildLogger(),});}diff --git a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/typescript/build.prod.ts b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/typescript/build.prod.tsindex 10c082c34..758d9dce0 100644--- a/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/typescript/build.prod.ts+++ b/packages/cli/tests/commands/template/fixtures/minimal-dockerfile/expected/typescript/build.prod.ts@@ -1,9 +1,10 @@-import { Template } from 'e2b'+import { Template, defaultBuildLogger } from 'e2b'import { template } from './template'async function main() {await Template.build(template, {alias: 'minimal-template',+ onBuildLogs: defaultBuildLogger(),});}diff --git a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-async/build_dev.py b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-async/build_dev.pyindex 5c138f481..33af3d7d2 100644--- a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-async/build_dev.py+++ b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-async/build_dev.py@@ -1,5 +1,5 @@import asyncio-from e2b import AsyncTemplate+from e2b import AsyncTemplate, default_build_loggerfrom template import template@@ -7,6 +7,7 @@ async def main():await AsyncTemplate.build(template,alias="multi-stage-dev",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-async/build_prod.py b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-async/build_prod.pyindex ce0a21ee4..ebe798da7 100644--- a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-async/build_prod.py+++ b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-async/build_prod.py@@ -1,5 +1,5 @@import asyncio-from e2b import AsyncTemplate+from e2b import AsyncTemplate, default_build_loggerfrom template import template@@ -7,6 +7,7 @@ async def main():await AsyncTemplate.build(template,alias="multi-stage",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-sync/build_dev.py b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-sync/build_dev.pyindex f9bbb9570..59fffa7d9 100644--- a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-sync/build_dev.py+++ b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-sync/build_dev.py@@ -1,4 +1,4 @@-from e2b import Template+from e2b import Template, default_build_loggerfrom template import template@@ -6,4 +6,5 @@ if __name__ == "__main__":Template.build(template,alias="multi-stage-dev",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-sync/build_prod.py b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-sync/build_prod.pyindex 6eabffd16..fc53b3003 100644--- a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-sync/build_prod.py+++ b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/python-sync/build_prod.py@@ -1,4 +1,4 @@-from e2b import Template+from e2b import Template, default_build_loggerfrom template import template@@ -6,4 +6,5 @@ if __name__ == "__main__":Template.build(template,alias="multi-stage",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/typescript/build.dev.ts b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/typescript/build.dev.tsindex 7592e07b7..0fdecd176 100644--- a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/typescript/build.dev.ts+++ b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/typescript/build.dev.ts@@ -1,9 +1,10 @@-import { Template } from 'e2b'+import { Template, defaultBuildLogger } from 'e2b'import { template } from './template'async function main() {await Template.build(template, {alias: 'multi-stage-dev',+ onBuildLogs: defaultBuildLogger(),});}diff --git a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/typescript/build.prod.ts b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/typescript/build.prod.tsindex 63451d27e..8dd3e5781 100644--- a/packages/cli/tests/commands/template/fixtures/multi-stage/expected/typescript/build.prod.ts+++ b/packages/cli/tests/commands/template/fixtures/multi-stage/expected/typescript/build.prod.ts@@ -1,9 +1,10 @@-import { Template } from 'e2b'+import { Template, defaultBuildLogger } from 'e2b'import { template } from './template'async function main() {await Template.build(template, {alias: 'multi-stage',+ onBuildLogs: defaultBuildLogger(),});}diff --git a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-async/build_dev.py b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-async/build_dev.pyindex 28fd58fa1..3cb18ece4 100644--- a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-async/build_dev.py+++ b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-async/build_dev.py@@ -1,5 +1,5 @@import asyncio-from e2b import AsyncTemplate+from e2b import AsyncTemplate, default_build_loggerfrom template import template@@ -7,6 +7,7 @@ async def main():await AsyncTemplate.build(template,alias="env-test-dev",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-async/build_prod.py b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-async/build_prod.pyindex 7c02c0f8b..37cd47d06 100644--- a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-async/build_prod.py+++ b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-async/build_prod.py@@ -1,5 +1,5 @@import asyncio-from e2b import AsyncTemplate+from e2b import AsyncTemplate, default_build_loggerfrom template import template@@ -7,6 +7,7 @@ async def main():await AsyncTemplate.build(template,alias="env-test",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-sync/build_dev.py b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-sync/build_dev.pyindex 5e21966c2..63301bafd 100644--- a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-sync/build_dev.py+++ b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-sync/build_dev.py@@ -1,4 +1,4 @@-from e2b import Template+from e2b import Template, default_build_loggerfrom template import template@@ -6,4 +6,5 @@ if __name__ == "__main__":Template.build(template,alias="env-test-dev",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-sync/build_prod.py b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-sync/build_prod.pyindex 34147e0b5..621445029 100644--- a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-sync/build_prod.py+++ b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/python-sync/build_prod.py@@ -1,4 +1,4 @@-from e2b import Template+from e2b import Template, default_build_loggerfrom template import template@@ -6,4 +6,5 @@ if __name__ == "__main__":Template.build(template,alias="env-test",+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/typescript/build.dev.ts b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/typescript/build.dev.tsindex 47d283178..10c0e292e 100644--- a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/typescript/build.dev.ts+++ b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/typescript/build.dev.ts@@ -1,9 +1,10 @@-import { Template } from 'e2b'+import { Template, defaultBuildLogger } from 'e2b'import { template } from './template'async function main() {await Template.build(template, {alias: 'env-test-dev',+ onBuildLogs: defaultBuildLogger(),});}diff --git a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/typescript/build.prod.ts b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/typescript/build.prod.tsindex d8fc65ccf..df7f44057 100644--- a/packages/cli/tests/commands/template/fixtures/multiple-env/expected/typescript/build.prod.ts+++ b/packages/cli/tests/commands/template/fixtures/multiple-env/expected/typescript/build.prod.ts@@ -1,9 +1,10 @@-import { Template } from 'e2b'+import { Template, defaultBuildLogger } from 'e2b'import { template } from './template'async function main() {await Template.build(template, {alias: 'env-test',+ onBuildLogs: defaultBuildLogger(),});}diff --git a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-async/build_dev.py b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-async/build_dev.pyindex b0776da75..c0cd96d96 100644--- a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-async/build_dev.py+++ b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-async/build_dev.py@@ -1,5 +1,5 @@import asyncio-from e2b import AsyncTemplate+from e2b import AsyncTemplate, default_build_loggerfrom template import template@@ -9,6 +9,7 @@ async def main():alias="start-cmd-dev",cpu_count=2,memory_mb=1024,+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-async/build_prod.py b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-async/build_prod.pyindex 32534d8f4..8da80c6e4 100644--- a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-async/build_prod.py+++ b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-async/build_prod.py@@ -1,5 +1,5 @@import asyncio-from e2b import AsyncTemplate+from e2b import AsyncTemplate, default_build_loggerfrom template import template@@ -9,6 +9,7 @@ async def main():alias="start-cmd",cpu_count=2,memory_mb=1024,+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-sync/build_dev.py b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-sync/build_dev.pyindex 692e7bb81..2241a6c2d 100644--- a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-sync/build_dev.py+++ b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-sync/build_dev.py@@ -1,4 +1,4 @@-from e2b import Template+from e2b import Template, default_build_loggerfrom template import template@@ -8,4 +8,5 @@ if __name__ == "__main__":alias="start-cmd-dev",cpu_count=2,memory_mb=1024,+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-sync/build_prod.py b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-sync/build_prod.pyindex f6c1b5358..8fd2e2ad7 100644--- a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-sync/build_prod.py+++ b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/python-sync/build_prod.py@@ -1,4 +1,4 @@-from e2b import Template+from e2b import Template, default_build_loggerfrom template import template@@ -8,4 +8,5 @@ if __name__ == "__main__":alias="start-cmd",cpu_count=2,memory_mb=1024,+ on_build_logs=default_build_logger(),)diff --git a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/typescript/build.dev.ts b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/typescript/build.dev.tsindex ad6fa939f..5872ff5ff 100644--- a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/typescript/build.dev.ts+++ b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/typescript/build.dev.ts@@ -1,4 +1,4 @@-import { Template } from 'e2b'+import { Template, defaultBuildLogger } from 'e2b'import { template } from './template'async function main() {@@ -6,6 +6,7 @@ async function main() {alias: 'start-cmd-dev',cpuCount: 2,memoryMB: 1024,+ onBuildLogs: defaultBuildLogger(),});}diff --git a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/typescript/build.prod.ts b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/typescript/build.prod.tsindex 0d98fc8c1..ed353067a 100644--- a/packages/cli/tests/commands/template/fixtures/start-cmd/expected/typescript/build.prod.ts+++ b/packages/cli/tests/commands/template/fixtures/start-cmd/expected/typescript/build.prod.ts@@ -1,4 +1,4 @@-import { Template } from 'e2b'+import { Template, defaultBuildLogger } from 'e2b'import { template } from './template'async function main() {@@ -6,6 +6,7 @@ async function main() {alias: 'start-cmd',cpuCount: 2,memoryMB: 1024,+ onBuildLogs: defaultBuildLogger(),});}diff --git a/packages/js-sdk/package.json b/packages/js-sdk/package.jsonindex ad10a643f..b3ee56c01 100644--- a/packages/js-sdk/package.json+++ b/packages/js-sdk/package.json@@ -91,6 +91,7 @@"@bufbuild/protobuf": "^2.6.2","@connectrpc/connect": "2.0.0-rc.3","@connectrpc/connect-web": "2.0.0-rc.3",+ "chalk": "^5.3.0","compare-versions": "^6.1.0","dockerfile-ast": "^0.7.1","glob": "^11.0.3",diff --git a/packages/js-sdk/src/index.ts b/packages/js-sdk/src/index.tsindex 79af066aa..bb0612215 100644--- a/packages/js-sdk/src/index.ts+++ b/packages/js-sdk/src/index.ts@@ -74,6 +74,14 @@ export {waitForTimeout,} from './template/readycmd'+export {+ LogEntry,+ LogEntryStart,+ LogEntryEnd,+ type LogEntryLevel,+ defaultBuildLogger,+} from './template/logger'+export {Template,type TemplateClass,diff --git a/packages/js-sdk/src/template/buildApi.ts b/packages/js-sdk/src/template/buildApi.tsindex 86fc53464..9369a68b5 100644--- a/packages/js-sdk/src/template/buildApi.ts+++ b/packages/js-sdk/src/template/buildApi.ts@@ -1,7 +1,7 @@import { ApiClient, handleApiError, paths } from '../api'import { stripAnsi } from '../utils'import { BuildError, FileUploadError } from './errors'-import { LogEntry } from './types'+import { LogEntry } from './logger'import { getBuildStepIndex, tarFileStreamUpload } from './utils'type RequestBuildInput = {@@ -193,7 +193,7 @@ export async function waitForBuildFinish(}: {templateID: stringbuildID: string- onBuildLogs?: (logEntry: InstanceType<typeof LogEntry>) => void+ onBuildLogs?: (logEntry: LogEntry) => voidlogsRefreshFrequency: numberstackTraces: (string | undefined)[]}diff --git a/packages/js-sdk/src/template/index.ts b/packages/js-sdk/src/template/index.tsindex 1fc5f8a9b..4954079ea 100644--- a/packages/js-sdk/src/template/index.ts+++ b/packages/js-sdk/src/template/index.ts@@ -1,3 +1,4 @@+import type { PathLike } from 'node:fs'import { ApiClient } from '../api'import { ConnectionConfig } from '../connectionConfig'import { runtime } from '../utils'@@ -11,12 +12,12 @@ import {} from './buildApi'import { RESOLVE_SYMLINKS, STACK_TRACE_DEPTH } from './consts'import { parseDockerfile } from './dockerfileParser'+import { LogEntry, LogEntryEnd, LogEntryStart } from './logger'import { ReadyCmd } from './readycmd'import {CopyItem,Instruction,InstructionType,- LogEntry,RegistryConfig,TemplateBuilder,TemplateFinal,@@ -30,7 +31,6 @@ import {readDockerignore,readGCPServiceAccountJSON,} from './utils'-import type { PathLike } from 'node:fs'export { type TemplateBuilder } from './types'@@ -44,7 +44,7 @@ type BasicBuildOptions = {cpuCount?: numbermemoryMB?: numberskipCache?: boolean- onBuildLogs?: (logEntry: InstanceType<typeof LogEntry>) => void+ onBuildLogs?: (logEntry: LogEntry) => void}export type BuildOptions = BasicBuildOptions & {@@ -90,8 +90,16 @@ export class TemplateBasereturn (template as TemplateBase).toDockerfile()}- static build(template: TemplateClass, options: BuildOptions): Promise<void> {- return (template as TemplateBase).build(options)+ static async build(+ template: TemplateClass,+ options: BuildOptions+ ): Promise<void> {+ try {+ options.onBuildLogs?.(new LogEntryStart(new Date(), 'Build started'))+ return await (template as TemplateBase).build(options)+ } finally {+ options.onBuildLogs?.(new LogEntryEnd(new Date(), 'Build finished'))+ }}// Built-in image mixinsdiff --git a/packages/js-sdk/src/template/logger.ts b/packages/js-sdk/src/template/logger.tsnew file mode 100644index 000000000..f384adc3b--- /dev/null+++ b/packages/js-sdk/src/template/logger.ts@@ -0,0 +1,164 @@+import chalk from 'chalk'+import { stripAnsi } from '../utils'++export type LogEntryLevel = 'debug' | 'info' | 'warn' | 'error'++export class LogEntry {+ constructor(+ public readonly timestamp: Date,+ public readonly level: LogEntryLevel,+ public readonly message: string+ ) {}++ toString() {+ return `[${this.timestamp.toISOString()}] [${this.level}] ${stripAnsi(+ this.message+ )}`+ }+}++export class LogEntryStart extends LogEntry {+ constructor(timestamp: Date, message: string) {+ super(timestamp, 'debug', message)+ }+}++export class LogEntryEnd extends LogEntry {+ constructor(timestamp: Date, message: string) {+ super(timestamp, 'debug', message)+ }+}++const TIMER_UPDATE_INTERVAL_MS = 150++const DEFAULT_LEVEL: LogEntryLevel = 'info'++const levels: Record<LogEntryLevel, string> = {+ error: chalk.red('ERROR'),+ warn: chalk.hex('#FF4400')('WARN '),+ info: chalk.hex('#FF8800')('INFO '),+ debug: chalk.gray('DEBUG'),+}++// Level ordering for comparison (assuming lower = less severe)+const level_order: Record<LogEntryLevel, number> = {+ debug: 0,+ info: 1,+ warn: 2,+ error: 3,+}++interface BuildLoggerState {+ startTime: number+ animationFrame: number+ timerInterval: NodeJS.Timeout | undefined+}++class BuildLogger {+ private minLevel: LogEntryLevel+ private state: BuildLoggerState++ constructor(minLevel?: LogEntryLevel) {+ this.minLevel = minLevel ?? DEFAULT_LEVEL+ this.state = this.getInitialState()+ }++ logger(logEntry: LogEntry) {+ if (logEntry instanceof LogEntryStart) {+ this.startTimer()+ return+ }++ if (logEntry instanceof LogEntryEnd) {+ clearInterval(this.state.timerInterval)+ return+ }++ // Filter by minimum level+ if (level_order[logEntry.level] < level_order[this.minLevel]) {+ return+ }++ const formattedLine = this.formatLogLine(logEntry)+ process.stdout.write(`${formattedLine}\n`)++ // Redraw the timer line+ this.updateTimer()+ }++ private getInitialState(timerInterval?: NodeJS.Timeout): BuildLoggerState {+ return {+ startTime: Date.now(),+ animationFrame: 0,+ timerInterval: timerInterval,+ }+ }++ private formatTimerLine() {+ const elapsedSeconds = ((Date.now() - this.state.startTime) / 1000).toFixed(+ 1+ )+ return `${elapsedSeconds}s`+ }++ private animateStatus() {+ const frames = ['⣾', '⣽', '⣻', '⢿', '⡿', '⣟', '⣯', '⣷']+ const idx = this.state.animationFrame % frames.length+ return `${frames[idx]}`+ }++ private formatLogLine(line: LogEntry) {+ const timer = this.formatTimerLine().padEnd(5)++ const timestamp = chalk.dim(+ line.timestamp.toLocaleTimeString(undefined, {+ hour: '2-digit',+ minute: '2-digit',+ second: '2-digit',+ })+ )++ const level = levels[line.level] || levels[DEFAULT_LEVEL]++ const msg = line.message++ return `${timer} | ${timestamp} ${level} ${msg}`+ }++ private startTimer() {+ if (!process.stdout.isTTY) {+ return+ }++ // Start the timer interval+ const timerInterval = setInterval(+ this.updateTimer.bind(this),+ TIMER_UPDATE_INTERVAL_MS+ )++ this.state = this.getInitialState(timerInterval)++ // Initial timer display+ this.updateTimer()+ }++ private updateTimer() {+ if (!process.stdout.isTTY) {+ return+ }++ this.state.animationFrame+++ const jumpingSquares = this.animateStatus()+ process.stdout.write(+ `${jumpingSquares} Building ${this.formatTimerLine()}\r`+ )+ }+}++export function defaultBuildLogger(options?: {+ minLevel?: LogEntryLevel+}): (logEntry: LogEntry) => void {+ const buildLogger = new BuildLogger(options?.minLevel)++ return buildLogger.logger.bind(buildLogger)+}diff --git a/packages/js-sdk/src/template/types.ts b/packages/js-sdk/src/template/types.tsindex e68e15744..45652fe3f 100644--- a/packages/js-sdk/src/template/types.ts+++ b/packages/js-sdk/src/template/types.ts@@ -1,4 +1,3 @@-import { stripAnsi } from '../utils'import { ReadyCmd } from './readycmd'import type { PathLike } from 'node:fs'@@ -145,20 +144,6 @@ export interface TemplateBuilder {// eslint-disable-next-line @typescript-eslint/no-empty-object-typeexport interface TemplateFinal {}-export class LogEntry {- constructor(- public readonly timestamp: Date,- public readonly level: 'debug' | 'info' | 'warn' | 'error',- public readonly message: string- ) {}-- toString() {- return `[${this.timestamp.toISOString()}] [${this.level}] ${stripAnsi(- this.message- )}`- }-}-export type GenericDockerRegistry = {type: 'registry'username: stringdiff --git a/packages/js-sdk/tests/setup.ts b/packages/js-sdk/tests/setup.tsindex a5d119bec..81264e0a9 100644--- a/packages/js-sdk/tests/setup.ts+++ b/packages/js-sdk/tests/setup.ts@@ -1,7 +1,7 @@-import { Sandbox, Template, TemplateClass } from '../src'+import { randomUUID } from 'node:crypto'import { test as base } from 'vitest'+import { LogEntry, Sandbox, Template, TemplateClass } from '../src'import { template } from './template'-import { randomUUID } from 'node:crypto'interface SandboxFixture {sandbox: Sandbox@@ -10,15 +10,24 @@ interface SandboxFixture {}interface BuildTemplateFixture {- buildTemplate: (template: TemplateClass, skipCache?: boolean) => Promise<void>+ buildTemplate: (+ template: TemplateClass,+ skipCache?: boolean,+ onBuildLogs?: (logEntry: LogEntry) => void+ ) => Promise<void>}-function buildTemplate(template: TemplateClass, skipCache?: boolean) {+function buildTemplate(+ template: TemplateClass,+ skipCache?: boolean,+ onBuildLogs?: (logEntry: LogEntry) => void+) {return Template.build(template, {alias: randomUUID(),cpuCount: 1,memoryMB: 1024,skipCache: skipCache,+ onBuildLogs: onBuildLogs,})}diff --git a/packages/js-sdk/tests/template/build.test.ts b/packages/js-sdk/tests/template/build.test.tsindex 281eacb67..b7465ded6 100644--- a/packages/js-sdk/tests/template/build.test.ts+++ b/packages/js-sdk/tests/template/build.test.ts@@ -1,8 +1,8 @@+import fs from 'node:fs'+import path from 'node:path'import { afterAll, beforeAll } from 'vitest'+import { defaultBuildLogger, Template, waitForTimeout } from '../../src'import { buildTemplateTest } from '../setup'-import { Template, waitForTimeout } from '../../src'-import path from 'node:path'-import fs from 'node:fs'const folderPath = path.join(__dirname, 'folder')@@ -38,7 +38,7 @@ buildTemplateTest(.setWorkdir('/app').setStartCmd('echo "Hello, world!"', waitForTimeout(10_000))- await buildTemplate(template)+ await buildTemplate(template, undefined, defaultBuildLogger())})diff --git a/packages/python-sdk/e2b/__init__.py b/packages/python-sdk/e2b/__init__.pyindex 04ae84813..922643188 100644--- a/packages/python-sdk/e2b/__init__.py+++ b/packages/python-sdk/e2b/__init__.py@@ -42,8 +42,6 @@ from .exceptions import (NotEnoughSpaceException,TemplateException,)-from .sandbox.sandbox_api import SandboxInfo, SandboxQuery, SandboxState, SandboxMetrics-from .sandbox.commands.main import ProcessInfofrom .sandbox.commands.command_handle import (CommandResult,Stderr,@@ -52,32 +50,32 @@ from .sandbox.commands.command_handle import (PtyOutput,PtySize,)+from .sandbox.commands.main import ProcessInfo+from .sandbox.filesystem.filesystem import EntryInfo, WriteInfo, FileTypefrom .sandbox.filesystem.watch_handle import (FilesystemEvent,FilesystemEventType,)-from .sandbox.filesystem.filesystem import EntryInfo, WriteInfo, FileTypefrom .sandbox.mcp import McpServer--from .sandbox_sync.main import Sandbox-from .sandbox_sync.filesystem.watch_handle import WatchHandle-from .sandbox_sync.commands.command_handle import CommandHandle+from .sandbox.sandbox_api import SandboxInfo, SandboxQuery, SandboxState, SandboxMetrics+from .sandbox_async.commands.command_handle import AsyncCommandHandle+from .sandbox_async.filesystem.watch_handle import AsyncWatchHandle+from .sandbox_async.main import AsyncSandboxfrom .sandbox_async.paginator import AsyncSandboxPaginator-from .sandbox_async.utils import OutputHandler-from .sandbox_async.main import AsyncSandbox-from .sandbox_async.filesystem.watch_handle import AsyncWatchHandle-from .sandbox_async.commands.command_handle import AsyncCommandHandle+from .sandbox_sync.commands.command_handle import CommandHandle+from .sandbox_sync.filesystem.watch_handle import WatchHandle+from .sandbox_sync.main import Sandboxfrom .sandbox_sync.paginator import SandboxPaginator--from .template.main import TemplateBase, TemplateClass--from .template.types import CopyItem--from .template_sync.main import Template-from .template_async.main import AsyncTemplate-from .template.exceptions import BuildException, FileUploadException+from .template.logger import (+ LogEntry,+ LogEntryLevel,+ LogEntryStart,+ LogEntryEnd,+ default_build_logger,+)+from .template.main import TemplateBase, TemplateClassfrom .template.readycmd import (wait_for_file,wait_for_url,@@ -85,6 +83,9 @@ from .template.readycmd import (wait_for_process,wait_for_timeout,)+from .template.types import CopyItem+from .template_async.main import AsyncTemplate+from .template_sync.main import Template__all__ = [# API@@ -145,6 +146,11 @@ __all__ = ["wait_for_port","wait_for_process","wait_for_timeout",+ "LogEntry",+ "LogEntryStart",+ "LogEntryEnd",+ "LogEntryLevel",+ "default_build_logger",# MCP"McpServer",]diff --git a/packages/python-sdk/e2b/template/logger.py b/packages/python-sdk/e2b/template/logger.pynew file mode 100644index 000000000..d865015e8--- /dev/null+++ b/packages/python-sdk/e2b/template/logger.py@@ -0,0 +1,183 @@+import sys+import threading+import time+from dataclasses import dataclass, field+from datetime import datetime+from typing import Optional, TypedDict, Callable, Dict, Literal++from rich.console import Console+from rich.style import Style+from rich.text import Text++from e2b.template.utils import strip_ansi_escape_codes++LogEntryLevel = Literal["debug", "info", "warn", "error"]+++@dataclass+class LogEntry:+ timestamp: datetime+ level: LogEntryLevel+ message: str++ def __post_init__(self):+ self.message = strip_ansi_escape_codes(self.message)++ def __str__(self) -> str:+ return f"[{self.timestamp.isoformat()}] [{self.level}] {self.message}"+++@dataclass+class LogEntryStart(LogEntry):+ level: LogEntryLevel = field(default="debug", init=False)+++@dataclass+class LogEntryEnd(LogEntry):+ level: LogEntryLevel = field(default="debug", init=False)+++TIMER_UPDATE_INTERVAL_MS = 150++DEFAULT_LEVEL: LogEntryLevel = "info"++# Level labels with Rich styles+levels: Dict[LogEntryLevel, tuple[str, Style]] = {+ "error": ("ERROR", Style(color="red")),+ "warn": ("WARN ", Style(color="#FF4400")),+ "info": ("INFO ", Style(color="#FF8800")),+ "debug": ("DEBUG", Style(color="bright_black")),+}++# Level ordering for comparison+level_order = {+ "debug": 0,+ "info": 1,+ "warn": 2,+ "error": 3,+}+++def set_interval(func, interval):+ """+ Returns a stop function that can be called to cancel the interval.+ Similar to JavaScript's setInterval.+ """+ stopped = threading.Event()++ def loop():+ while not stopped.is_set():+ if stopped.wait(interval): # wait returns True if stopped+ break+ if not stopped.is_set(): # Double-check before executing+ func()++ threading.Thread(target=loop, daemon=True).start()+ return stopped.set # Return the stop function+++class InitialState(TypedDict):+ start_time: float+ animation_frame: int+ timer: Optional[Callable[[], None]]+++class BuildLogger:+ __console = Console()++ __min_level: LogEntryLevel+ __state: InitialState++ def __init__(self, min_level: Optional[LogEntryLevel] = None):+ self.__min_level = min_level if min_level is not None else DEFAULT_LEVEL+ self.__reset_initial_state()++ def logger(self, log):+ if isinstance(log, LogEntryStart):+ self.__start_timer()+ return++ if isinstance(log, LogEntryEnd):+ if self.__state["timer"] is not None:+ self.__state["timer"]()+ return++ # Filter by minimum level+ if level_order[log.level] < level_order[self.__min_level]:+ return++ formatted_line = self.__format_log_line(log)+ self.__console.print(formatted_line)++ # Redraw the timer line+ self.__update_timer()++ def __reset_initial_state(self, timer: Optional[Callable[[], None]] = None):+ self.__state = {+ "start_time": time.time(),+ "animation_frame": 0,+ "timer": timer,+ }++ def __format_timer_line(self) -> str:+ elapsed_seconds = time.time() - self.__state["start_time"]+ return f"{elapsed_seconds:.1f}s"++ def __animate_status(self) -> str:+ frames = ["⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"]+ idx = self.__state["animation_frame"] % len(frames)+ return frames[idx]++ def __format_log_line(self, line: LogEntry) -> Text:+ timer = self.__format_timer_line().ljust(5)+ timestamp = line.timestamp.strftime("%H:%M:%S")+ level_text, level_style = levels.get(line.level, levels[DEFAULT_LEVEL])++ # Build a rich Text object+ text = Text.assemble(+ timer,+ " | ",+ (timestamp, "dim"),+ " ",+ (level_text, level_style),+ " ",+ line.message,+ )++ return text++ def __start_timer(self):+ if not sys.stdout.isatty():+ return++ # Start the timer interval+ stop_timer = set_interval(+ self.__update_timer, TIMER_UPDATE_INTERVAL_MS / 1000.0+ )++ self.__reset_initial_state(stop_timer)++ # Initial timer display+ self.__update_timer()++ def __update_timer(self):+ if not sys.stdout.isatty():+ return++ self.__state["animation_frame"] += 1+ jumping_squares = self.__animate_status()++ timer_text = Text.assemble(+ jumping_squares, " Building ", self.__format_timer_line()+ )++ # Print with carriage return+ self.__console.print(timer_text, end="\r")+++def default_build_logger(+ min_level: Optional[LogEntryLevel] = None,+) -> Callable[[LogEntry], None]:+ build_logger = BuildLogger(min_level)++ return build_logger.loggerdiff --git a/packages/python-sdk/e2b/template/types.py b/packages/python-sdk/e2b/template/types.pyindex 80a046fa5..480b0a119 100644--- a/packages/python-sdk/e2b/template/types.py+++ b/packages/python-sdk/e2b/template/types.py@@ -1,11 +1,9 @@-from typing import List, Optional, TypedDict, Union-from typing_extensions import NotRequired-from dataclasses import dataclass-from datetime import datetime-from typing import Literalfrom enum import Enumfrom pathlib import Path-from e2b.template.utils import strip_ansi_escape_codes+from typing import List, Optional, TypedDict, Union+from typing import Literal++from typing_extensions import NotRequiredclass InstructionType(str, Enum):@@ -34,19 +32,6 @@ class Instruction(TypedDict):resolveSymlinks: NotRequired[Optional[bool]]-@dataclass-class LogEntry:- timestamp: datetime- level: Literal["debug", "info", "warn", "error"]- message: str-- def __post_init__(self):- self.message = strip_ansi_escape_codes(self.message)-- def __str__(self) -> str:- return f"[{self.timestamp.isoformat()}] [{self.level}] {self.message}"--class GenericDockerRegistry(TypedDict):type: Literal["registry"]username: strdiff --git a/packages/python-sdk/e2b/template_async/build_api.py b/packages/python-sdk/e2b/template_async/build_api.pyindex 21bd3163f..38eace670 100644--- a/packages/python-sdk/e2b/template_async/build_api.py+++ b/packages/python-sdk/e2b/template_async/build_api.py@@ -24,7 +24,8 @@ from e2b.api.client.models import (Error,)from e2b.template.exceptions import BuildException, FileUploadException-from e2b.template.types import TemplateType, LogEntry+from e2b.template.logger import LogEntry+from e2b.template.types import TemplateTypefrom e2b.template.utils import get_build_step_indexdiff --git a/packages/python-sdk/e2b/template_async/main.py b/packages/python-sdk/e2b/template_async/main.pyindex 187bcd059..0592987b9 100644--- a/packages/python-sdk/e2b/template_async/main.py+++ b/packages/python-sdk/e2b/template_async/main.py@@ -1,13 +1,13 @@-from typing import Callable, Optional--from e2b.template.main import TemplateBase, TemplateClass-import osfrom datetime import datetime+from typing import Callable, Optional-from e2b.connection_config import ConnectionConfigfrom e2b.api import AsyncApiClient-from e2b.template.types import LogEntry, InstructionType+from e2b.connection_config import ConnectionConfig+from e2b.template.consts import RESOLVE_SYMLINKS+from e2b.template.logger import LogEntry, LogEntryStart, LogEntryEnd+from e2b.template.main import TemplateBase, TemplateClass+from e2b.template.types import InstructionTypefrom .build_api import (get_file_upload_link,request_build,@@ -15,7 +15,6 @@ from .build_api import (upload_file,wait_for_build_finish,)-from e2b.template.consts import RESOLVE_SYMLINKSclass AsyncTemplate(TemplateBase):@@ -30,142 +29,163 @@ class AsyncTemplate(TemplateBase):api_key: Optional[str] = None,domain: Optional[str] = None,) -> None:- domain = domain or os.environ.get("E2B_DOMAIN", "e2b.dev")- config = ConnectionConfig(- domain=domain, api_key=api_key or os.environ.get("E2B_API_KEY")- )- client = AsyncApiClient(- config,- require_api_key=True,- require_access_token=False,- limits=TemplateBase._limits,- )-- if skip_cache:- template._template._force = True-- with client as api_client:- # Create template+ try:if on_build_logs:on_build_logs(- LogEntry(+ LogEntryStart(timestamp=datetime.now(),- level="info",- message=f"Requesting build for template: {alias}",+ message="Build started",))- response = await request_build(- api_client,- name=alias,- cpu_count=cpu_count,- memory_mb=memory_mb,+ domain = domain or os.environ.get("E2B_DOMAIN", "e2b.dev")+ config = ConnectionConfig(+ domain=domain, api_key=api_key or os.environ.get("E2B_API_KEY")+ )+ client = AsyncApiClient(+ config,+ require_api_key=True,+ require_access_token=False,+ limits=TemplateBase._limits,)- template_id = response.template_id- build_id = response.build_id-- if on_build_logs:- on_build_logs(- LogEntry(- timestamp=datetime.now(),- level="info",- message=f"Template created with ID: {template_id}, Build ID: {build_id}",+ if skip_cache:+ template._template._force = True++ with client as api_client:+ # Create template+ if on_build_logs:+ on_build_logs(+ LogEntry(+ timestamp=datetime.now(),+ level="info",+ message=f"Requesting build for template: {alias}",+ ))++ response = await request_build(+ api_client,+ name=alias,+ cpu_count=cpu_count,+ memory_mb=memory_mb,)- instructions_with_hashes = template._template._instructions_with_hashes()+ template_id = response.template_id+ build_id = response.build_id- # Upload files- for index, file_upload in enumerate(instructions_with_hashes):- if file_upload["type"] != InstructionType.COPY:- continue+ if on_build_logs:+ on_build_logs(+ LogEntry(+ timestamp=datetime.now(),+ level="info",+ message=f"Template created with ID: {template_id}, Build ID: {build_id}",+ )+ )- args = file_upload.get("args", [])- src = args[0] if len(args) > 0 else None- force_upload = file_upload.get("forceUpload")- files_hash = file_upload.get("filesHash", None)- resolve_symlinks = file_upload.get("resolveSymlinks", RESOLVE_SYMLINKS)+ instructions_with_hashes = (+ template._template._instructions_with_hashes()+ )- if src is None or files_hash is None:- raise ValueError("Source path and files hash are required")+ # Upload files+ for index, file_upload in enumerate(instructions_with_hashes):+ if file_upload["type"] != InstructionType.COPY:+ continue++ args = file_upload.get("args", [])+ src = args[0] if len(args) > 0 else None+ force_upload = file_upload.get("forceUpload")+ files_hash = file_upload.get("filesHash", None)+ resolve_symlinks = file_upload.get(+ "resolveSymlinks", RESOLVE_SYMLINKS+ )- stack_trace = None- if index + 1 < len(template._template._stack_traces):- stack_trace = template._template._stack_traces[index + 1]+ if src is None or files_hash is None:+ raise ValueError("Source path and files hash are required")- file_info = await get_file_upload_link(- api_client, template_id, files_hash, stack_trace- )+ stack_trace = None+ if index + 1 < len(template._template._stack_traces):+ stack_trace = template._template._stack_traces[index + 1]- if (force_upload and file_info.url) or (- file_info.present is False and file_info.url- ):- await upload_file(- src,- template._template._file_context_path,- file_info.url,- resolve_symlinks,- stack_trace,+ file_info = await get_file_upload_link(+ api_client, template_id, files_hash, stack_trace)- if on_build_logs:- on_build_logs(- LogEntry(- timestamp=datetime.now(),- level="info",- message=f"Uploaded '{src}'",- )++ if (force_upload and file_info.url) or (+ file_info.present is False and file_info.url+ ):+ await upload_file(+ src,+ template._template._file_context_path,+ file_info.url,+ resolve_symlinks,+ stack_trace,)- else:- if on_build_logs:- on_build_logs(- LogEntry(- timestamp=datetime.now(),- level="info",- message=f"Skipping upload of '{src}', already cached",+ if on_build_logs:+ on_build_logs(+ LogEntry(+ timestamp=datetime.now(),+ level="info",+ message=f"Uploaded '{src}'",+ )+ )+ else:+ if on_build_logs:+ on_build_logs(+ LogEntry(+ timestamp=datetime.now(),+ level="info",+ message=f"Skipping upload of '{src}', already cached",+ ))- )- if on_build_logs:- on_build_logs(- LogEntry(- timestamp=datetime.now(),- level="info",- message="All file uploads completed",+ if on_build_logs:+ on_build_logs(+ LogEntry(+ timestamp=datetime.now(),+ level="info",+ message="All file uploads completed",+ ))- )- # Start build- if on_build_logs:- on_build_logs(- LogEntry(- timestamp=datetime.now(),- level="info",- message="Starting building...",+ # Start build+ if on_build_logs:+ on_build_logs(+ LogEntry(+ timestamp=datetime.now(),+ level="info",+ message="Starting building...",+ ))++ await trigger_build(+ api_client,+ template_id,+ build_id,+ template._template._serialize(instructions_with_hashes),)- await trigger_build(- api_client,- template_id,- build_id,- template._template._serialize(instructions_with_hashes),- )+ if on_build_logs:+ on_build_logs(+ LogEntry(+ timestamp=datetime.now(),+ level="info",+ message="Waiting for logs...",+ )+ )+ await wait_for_build_finish(+ api_client,+ template_id,+ build_id,+ on_build_logs,+ logs_refresh_frequency=TemplateBase._logs_refresh_frequency,+ stack_traces=template._template._stack_traces,+ )+ finally:if on_build_logs:on_build_logs(- LogEntry(+ LogEntryEnd(timestamp=datetime.now(),- level="info",- message="Waiting for logs...",+ message="Build finished",))-- await wait_for_build_finish(- api_client,- template_id,- build_id,- on_build_logs,- logs_refresh_frequency=TemplateBase._logs_refresh_frequency,- stack_traces=template._template._stack_traces,- )diff --git a/packages/python-sdk/e2b/template_sync/build_api.py b/packages/python-sdk/e2b/template_sync/build_api.pyindex 37d165542..51fd4de28 100644--- a/packages/python-sdk/e2b/template_sync/build_api.py+++ b/packages/python-sdk/e2b/template_sync/build_api.py@@ -24,7 +24,8 @@ from e2b.api.client.models import (Error,)from e2b.template.exceptions import BuildException, FileUploadException-from e2b.template.types import TemplateType, LogEntry+from e2b.template.logger import LogEntry+from e2b.template.types import TemplateTypefrom e2b.template.utils import get_build_step_indexdiff --git a/packages/python-sdk/e2b/template_sync/main.py b/packages/python-sdk/e2b/template_sync/main.pyindex 671109c7d..20b121798 100644--- a/packages/python-sdk/e2b/template_sync/main.py+++ b/packages/python-sdk/e2b/template_sync/main.py@@ -1,14 +1,13 @@-from typing import Callable, Optional--from e2b.template.consts import RESOLVE_SYMLINKS-from e2b.template.main import TemplateBase, TemplateClass-from e2b.template.types import LogEntry, InstructionType-import osfrom datetime import datetime+from typing import Callable, Optionalfrom e2b.api import ApiClientfrom e2b.connection_config import ConnectionConfig+from e2b.template.consts import RESOLVE_SYMLINKS+from e2b.template.logger import LogEntry, LogEntryStart, LogEntryEnd+from e2b.template.main import TemplateBase, TemplateClass+from e2b.template.types import InstructionTypefrom e2b.template_sync.build_api import (get_file_upload_link,request_build,@@ -30,142 +29,163 @@ class Template(TemplateBase):api_key: Optional[str] = None,domain: Optional[str] = None,) -> None:- domain = domain or os.environ.get("E2B_DOMAIN", "e2b.dev")- config = ConnectionConfig(- domain=domain, api_key=api_key or os.environ.get("E2B_API_KEY")- )- client = ApiClient(- config,- require_api_key=True,- require_access_token=False,- limits=TemplateBase._limits,- )-- if skip_cache:- template._template._force = True-- with client as api_client:- # Create template+ try:if on_build_logs:on_build_logs(- LogEntry(+ LogEntryStart(timestamp=datetime.now(),- level="info",- message=f"Requesting build for template: {alias}",+ message="Build started",))- response = request_build(- api_client,- name=alias,- cpu_count=cpu_count,- memory_mb=memory_mb,+ domain = domain or os.environ.get("E2B_DOMAIN", "e2b.dev")+ config = ConnectionConfig(+ domain=domain, api_key=api_key or os.environ.get("E2B_API_KEY")+ )+ client = ApiClient(+ config,+ require_api_key=True,+ require_access_token=False,+ limits=TemplateBase._limits,)- template_id = response.template_id- build_id = response.build_id-- if on_build_logs:- on_build_logs(- LogEntry(- timestamp=datetime.now(),- level="info",- message=f"Template created with ID: {template_id}, Build ID: {build_id}",+ if skip_cache:+ template._template._force = True++ with client as api_client:+ # Create template+ if on_build_logs:+ on_build_logs(+ LogEntry(+ timestamp=datetime.now(),+ level="info",+ message=f"Requesting build for template: {alias}",+ ))++ response = request_build(+ api_client,+ name=alias,+ cpu_count=cpu_count,+ memory_mb=memory_mb,)- instructions_with_hashes = template._template._instructions_with_hashes()+ template_id = response.template_id+ build_id = response.build_id- # Upload files- for index, file_upload in enumerate(instructions_with_hashes):- if file_upload["type"] != InstructionType.COPY:- continue+ if on_build_logs:+ on_build_logs(+ LogEntry(+ timestamp=datetime.now(),+ level="info",+ message=f"Template created with ID: {template_id}, Build ID: {build_id}",+ )+ )- args = file_upload.get("args", [])- src = args[0] if len(args) > 0 else None- force_upload = file_upload.get("forceUpload")- files_hash = file_upload.get("filesHash", None)- resolve_symlinks = file_upload.get("resolveSymlinks", RESOLVE_SYMLINKS)+ instructions_with_hashes = (+ template._template._instructions_with_hashes()+ )- if src is None or files_hash is None:- raise ValueError("Source path and files hash are required")+ # Upload files+ for index, file_upload in enumerate(instructions_with_hashes):+ if file_upload["type"] != InstructionType.COPY:+ continue++ args = file_upload.get("args", [])+ src = args[0] if len(args) > 0 else None+ force_upload = file_upload.get("forceUpload")+ files_hash = file_upload.get("filesHash", None)+ resolve_symlinks = file_upload.get(+ "resolveSymlinks", RESOLVE_SYMLINKS+ )- stack_trace = None- if index + 1 < len(template._template._stack_traces):- stack_trace = template._template._stack_traces[index + 1]+ if src is None or files_hash is None:+ raise ValueError("Source path and files hash are required")- file_info = get_file_upload_link(- api_client, template_id, files_hash, stack_trace- )+ stack_trace = None+ if index + 1 < len(template._template._stack_traces):+ stack_trace = template._template._stack_traces[index + 1]- if (force_upload and file_info.url) or (- file_info.present is False and file_info.url- ):- upload_file(- src,- template._template._file_context_path,- file_info.url,- resolve_symlinks,- stack_trace,+ file_info = get_file_upload_link(+ api_client, template_id, files_hash, stack_trace)- if on_build_logs:- on_build_logs(- LogEntry(- timestamp=datetime.now(),- level="info",- message=f"Uploaded '{src}'",- )++ if (force_upload and file_info.url) or (+ file_info.present is False and file_info.url+ ):+ upload_file(+ src,+ template._template._file_context_path,+ file_info.url,+ resolve_symlinks,+ stack_trace,)- else:- if on_build_logs:- on_build_logs(- LogEntry(- timestamp=datetime.now(),- level="info",- message=f"Skipping upload of '{src}', already cached",+ if on_build_logs:+ on_build_logs(+ LogEntry(+ timestamp=datetime.now(),+ level="info",+ message=f"Uploaded '{src}'",+ )+ )+ else:+ if on_build_logs:+ on_build_logs(+ LogEntry(+ timestamp=datetime.now(),+ level="info",+ message=f"Skipping upload of '{src}', already cached",+ ))- )- if on_build_logs:- on_build_logs(- LogEntry(- timestamp=datetime.now(),- level="info",- message="All file uploads completed",+ if on_build_logs:+ on_build_logs(+ LogEntry(+ timestamp=datetime.now(),+ level="info",+ message="All file uploads completed",+ ))- )- # Start build- if on_build_logs:- on_build_logs(- LogEntry(- timestamp=datetime.now(),- level="info",- message="Starting building...",+ # Start build+ if on_build_logs:+ on_build_logs(+ LogEntry(+ timestamp=datetime.now(),+ level="info",+ message="Starting building...",+ ))++ trigger_build(+ api_client,+ template_id,+ build_id,+ template._template._serialize(instructions_with_hashes),)- trigger_build(- api_client,- template_id,- build_id,- template._template._serialize(instructions_with_hashes),- )+ if on_build_logs:+ on_build_logs(+ LogEntry(+ timestamp=datetime.now(),+ level="info",+ message="Waiting for logs...",+ )+ )+ wait_for_build_finish(+ api_client,+ template_id,+ build_id,+ on_build_logs,+ logs_refresh_frequency=TemplateBase._logs_refresh_frequency,+ stack_traces=template._template._stack_traces,+ )+ finally:if on_build_logs:on_build_logs(- LogEntry(+ LogEntryEnd(timestamp=datetime.now(),- level="info",- message="Waiting for logs...",+ message="Build finished",))-- wait_for_build_finish(- api_client,- template_id,- build_id,- on_build_logs,- logs_refresh_frequency=TemplateBase._logs_refresh_frequency,- stack_traces=template._template._stack_traces,- )diff --git a/packages/python-sdk/poetry.lock b/packages/python-sdk/poetry.lockindex c2d512749..c733d6d91 100644--- a/packages/python-sdk/poetry.lock+++ b/packages/python-sdk/poetry.lock@@ -1,4 +1,4 @@-# This file is automatically @generated by Poetry 2.1.1 and should not be changed by hand.+# This file is automatically @generated by Poetry 2.1.3 and should not be changed by hand.[[package]]name = "annotated-types"@@ -647,6 +647,31 @@ MarkupSafe = ">=2.0"[package.extras]i18n = ["Babel (>=2.7)"]+[[package]]+name = "markdown-it-py"+version = "3.0.0"+description = "Python port of markdown-it. Markdown parsing, done right!"+optional = false+python-versions = ">=3.8"+groups = ["main"]+files = [+ {file = "markdown-it-py-3.0.0.tar.gz", hash = "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb"},+ {file = "markdown_it_py-3.0.0-py3-none-any.whl", hash = "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1"},+]++[package.dependencies]+mdurl = ">=0.1,<1.0"++[package.extras]+benchmarking = ["psutil", "pytest", "pytest-benchmark"]+code-style = ["pre-commit (>=3.0,<4.0)"]+compare = ["commonmark (>=0.9,<1.0)", "markdown (>=3.4,<4.0)", "mistletoe (>=1.0,<2.0)", "mistune (>=2.0,<3.0)", "panflute (>=2.3,<3.0)"]+linkify = ["linkify-it-py (>=1,<3)"]+plugins = ["mdit-py-plugins"]+profiling = ["gprof2dot"]+rtd = ["jupyter_sphinx", "mdit-py-plugins", "myst-parser", "pyyaml", "sphinx", "sphinx-copybutton", "sphinx-design", "sphinx_book_theme"]+testing = ["coverage", "pytest", "pytest-cov", "pytest-regressions"]+[[package]]name = "markupsafe"version = "2.1.5"@@ -717,6 +742,18 @@ files = [{file = "MarkupSafe-2.1.5.tar.gz", hash = "sha256:d283d37a890ba4c1ae73ffadf8046435c76e7bc2247bbb63c00bd1a709c6544b"},]+[[package]]+name = "mdurl"+version = "0.1.2"+description = "Markdown URL utilities"+optional = false+python-versions = ">=3.7"+groups = ["main"]+files = [+ {file = "mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8"},+ {file = "mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"},+]+[[package]]name = "more-itertools"version = "10.8.0"@@ -1019,6 +1056,21 @@ tomli_w = ">=1.0.0,<2.0.0"watchdog = "*"yapf = ">=0.30.0"+[[package]]+name = "pygments"+version = "2.19.2"+description = "Pygments is a syntax highlighting package written in Python."+optional = false+python-versions = ">=3.8"+groups = ["main"]+files = [+ {file = "pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b"},+ {file = "pygments-2.19.2.tar.gz", hash = "sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887"},+]++[package.extras]+windows-terminal = ["colorama (>=0.4.6)"]+[[package]]name = "pytest"version = "7.4.4"@@ -1213,6 +1265,25 @@ urllib3 = ">=1.21.1,<3"socks = ["PySocks (>=1.5.6,!=1.5.7)"]use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"]+[[package]]+name = "rich"+version = "14.1.0"+description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal"+optional = false+python-versions = ">=3.8.0"+groups = ["main"]+files = [+ {file = "rich-14.1.0-py3-none-any.whl", hash = "sha256:536f5f1785986d6dbdea3c75205c473f970777b4a0d6c6dd1b696aa05a3fa04f"},+ {file = "rich-14.1.0.tar.gz", hash = "sha256:e497a48b844b0320d45007cdebfeaeed8db2a4f4bcf49f15e455cfc4af11eaa8"},+]++[package.dependencies]+markdown-it-py = ">=2.2.0"+pygments = ">=2.13.0,<3.0.0"++[package.extras]+jupyter = ["ipywidgets (>=7.5.1,<9)"]+[[package]]name = "ruff"version = "0.11.12"@@ -1248,7 +1319,7 @@ description = "Easily download, build, install, upgrade, and uninstall Python paoptional = falsepython-versions = ">=3.9"groups = ["dev"]-markers = "python_version < \"3.10\""+markers = "python_version == \"3.9\""files = [{file = "setuptools-80.9.0-py3-none-any.whl", hash = "sha256:062d34222ad13e0cc312a4c02d73f059e86a4acbfbdea8f8f76b28c99f306922"},{file = "setuptools-80.9.0.tar.gz", hash = "sha256:f36b47402ecde768dbfafc46e8e4207b4360c654f1f3bb84475f0a28628fb19c"},@@ -1599,4 +1670,4 @@ type = ["pytest-mypy"][metadata]lock-version = "2.1"python-versions = "^3.9"-content-hash = "ca49c7725d00f596779188ed2818fa4408c3757944dacf1427b8f05f3738e5e5"+content-hash = "04dab9a9328d4cd18faf57e661d272b78bee7ede93c10eb328fed49f0ddd3d0b"diff --git a/packages/python-sdk/pyproject.toml b/packages/python-sdk/pyproject.tomlindex da5480709..bf350b388 100644--- a/packages/python-sdk/pyproject.toml+++ b/packages/python-sdk/pyproject.toml@@ -20,6 +20,7 @@ attrs = ">=23.2.0"packaging = ">=24.1"typing-extensions = ">=4.1.0"dockerfile-parse = "^2.0.1"+rich = ">=14.0.0"[tool.poetry.group.dev.dependencies]pytest = "^7.4.0"@@ -41,4 +42,4 @@ build-backend = "poetry.core.masonry.api"[tool.ruff]exclude = ["e2b/envd/filesystem/filesystem_pb2.py"-]\ No newline at end of file+]diff --git a/packages/python-sdk/tests/async/template_async/test_build.py b/packages/python-sdk/tests/async/template_async/test_build.pyindex d0e87c495..1e334e32a 100644--- a/packages/python-sdk/tests/async/template_async/test_build.py+++ b/packages/python-sdk/tests/async/template_async/test_build.py@@ -4,7 +4,7 @@ import pytestimport osimport shutil-from e2b import AsyncTemplate, wait_for_timeout+from e2b import AsyncTemplate, wait_for_timeout, default_build_logger@pytest.fixture(scope="module")@@ -51,7 +51,7 @@ async def test_build_template(async_build, setup_test_folder):.set_start_cmd("echo 'Hello, world!'", wait_for_timeout(10_000)))- await async_build(template)+ await async_build(template, skip_cache=False, on_build_logs=default_build_logger())@pytest.mark.skip_debug()diff --git a/packages/python-sdk/tests/conftest.py b/packages/python-sdk/tests/conftest.pyindex 5e7289dd0..16552e9b6 100644--- a/packages/python-sdk/tests/conftest.py+++ b/packages/python-sdk/tests/conftest.py@@ -1,4 +1,5 @@import asyncio+from typing import Callable, Optionalimport uuidimport pytest@@ -17,6 +18,7 @@ from e2b import (AsyncTemplate,Template,TemplateClass,+ LogEntry,)@@ -66,12 +68,18 @@ async def async_sandbox(template, debug, sandbox_test_id):@pytest.fixturedef build():- def _build(template: TemplateClass):+ def _build(+ template: TemplateClass,+ skip_cache: bool = False,+ on_build_logs: Optional[Callable[[LogEntry], None]] = None,+ ):return Template.build(template,alias=str(uuid4()),cpu_count=1,memory_mb=1024,+ skip_cache=skip_cache,+ on_build_logs=on_build_logs,)return _build@@ -79,12 +87,18 @@ def build():@pytest_asyncio.fixturedef async_build():- async def _async_build(template: TemplateClass):+ async def _async_build(+ template: TemplateClass,+ skip_cache: bool = False,+ on_build_logs: Optional[Callable[[LogEntry], None]] = None,+ ):return await AsyncTemplate.build(template,alias=str(uuid4()),cpu_count=1,memory_mb=1024,+ skip_cache=skip_cache,+ on_build_logs=on_build_logs,)return _async_builddiff --git a/packages/python-sdk/tests/sync/template_sync/test_build.py b/packages/python-sdk/tests/sync/template_sync/test_build.pyindex a7904abea..cf854b121 100644--- a/packages/python-sdk/tests/sync/template_sync/test_build.py+++ b/packages/python-sdk/tests/sync/template_sync/test_build.py@@ -4,7 +4,7 @@ import pytestimport osimport shutil-from e2b import Template, wait_for_timeout+from e2b import Template, wait_for_timeout, default_build_logger@pytest.fixture(scope="module")@@ -51,7 +51,7 @@ def test_build_template(build, setup_test_folder):.set_start_cmd("echo 'Hello, world!'", wait_for_timeout(10_000)))- build(template)+ build(template, skip_cache=False, on_build_logs=default_build_logger())@pytest.mark.skip_debug()diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex d689ef8e5..3a7f8e803 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -356,6 +356,9 @@ importers:'@connectrpc/connect-web':specifier: 2.0.0-rc.3version: 2.0.0-rc.3(@bufbuild/[email protected])(@connectrpc/[email protected](@bufbuild/[email protected]))+ chalk:+ specifier: ^5.3.0+ version: 5.3.0compare-versions:specifier: ^6.1.0version: 6.1.1