Skip to main content

TypeScript SDK

What this lets you do

Create durable local image turns from TypeScript or JavaScript.

What you need

  • Node.js and pnpm
  • A DreamLayer clone
  • A running local runtime

Steps

1. Install from the clone

2. Create a local conversation

Run this local capability-token example only in trusted server code on the same machine as the runtime. Browser applications use openSession with the one-time bootstrap token from the complete URL printed by ./dreamlayer; they must never embed the local token or a DreamLayer key in a browser bundle.

Confirm it worked

The callback prints durable job stages and ends with completed, failed, or cancelled. A completed turn contains one image asset.

Common errors

  • 401: read the current local token after starting ./dreamlayer; do not reuse a token from another machine or state directory.
  • Connection refused: start ./dreamlayer and use its loopback origin.
  • Invalid request: keep operation within the supported V1 operations.
  • Browser key exposure: move managed API calls to trusted server code.

Troubleshooting

Read canonical job state before retrying after a timeout or disconnect. Do not create a second logical request automatically.

Next steps