SDK
Markdown

TypeScript SDK 0.1.10

Services and observability

Services keep named processes running in the sandbox. The SDK can inspect their state and output alongside ports, metrics, and captured mail.

Run a service

Redis is available as a built-in service. You can also run a named command as a service:

TypeScript
await sandbox.services.run('redis');
await sandbox.services.run('queue', 'php artisan queue:work');

const services = await sandbox.services.list();
console.log(services);

Stop a service by name:

TypeScript
await sandbox.services.stop('queue');

Read service logs

TypeScript
const recent = await sandbox.services.logs('redis', { tail: 50 });
console.log(recent);

const stream = sandbox.services.logs('queue', {
  follow: true,
  tail: 25,
});

for await (const line of stream) {
  console.log(line);
}

Inspect the runtime

TypeScript
const ports = await sandbox.runtime.ports.list();
const metrics = await sandbox.runtime.metrics.current();

console.log(ports, metrics);

Realtime clients can also watch ports and metrics and follow combined runtime logs.

Capture application mail

TypeScript
const state = await sandbox.mail.status();

if (!state.enabled) {
  await sandbox.mail.enable();
}

const messages = await sandbox.mail.list();

Use the returned SMTP state to configure the application. Captured mail remains inside the sandbox workflow and is not delivered to real recipients.

Loading templates

You can also reach out on Twitter or Discord if you need help.