Breaking change: assemblyApi() is now async

The factory function returns Promise<AssemblyAPI> instead of AssemblyAPI.

- import { copilotApi } from 'copilot-node-sdk'
+ import { assemblyApi } from '@assembly-js/node-sdk'

- const client = copilotApi({ apiKey, token })
+ const client = await assemblyApi({ apiKey, token })

Why?

Vercel Edge Runtime and other edge environments (Cloudflare Workers, etc.) do not provide the Node.js crypto module. We replaced it with the Web Crypto API (crypto.subtle), which is async by designimportKey(), sign(), and decrypt() all return promises. Since the SDK decrypts the token during initialization (AES-128-CBC via HMAC-derived key), the factory function is now async.

See MDN's SubtleCrypto reference for details on why these operations are promise-based.


If you can't await in your context

For example, in a class constructor, use the lazy init pattern — store the promise and await it before use:

import type { AssemblyAPI as SDK } from '@assembly-js/node-sdk'
import { assemblyApi } from '@assembly-js/node-sdk'

class MyService {
  private assemblyPromise: Promise<SDK>

  constructor(token: string) {
    // Kick off initialization immediately, but don't block
    this.assemblyPromise = assemblyApi({ apiKey: API_KEY, token })
  }

  async getClients() {
    const assembly = await this.assemblyPromise // resolves once, cached after that
    return assembly.listClients({})
  }
}

All call sites (new MyService(token)) remain unchanged.


Other renames

Old New
copilot-node-sdk @assembly-js/node-sdk
copilotApi() assemblyApi()
CopilotAPI (type) AssemblyAPI
COPILOT_ENV ASSEMBLY_ENV (old name still works)
COPILOT_DEBUG ASSEMBLY_DEBUG (old name still works)

The old copilotApi export still exists as a deprecated alias and will be removed in v5.0.0.