Skip to content

feat: simplify turn API#36

Open
varin-nair-factory wants to merge 1 commit intomainfrom
vn/turn-api-simplify
Open

feat: simplify turn API#36
varin-nair-factory wants to merge 1 commit intomainfrom
vn/turn-api-simplify

Conversation

@varin-nair-factory
Copy link
Copy Markdown
Contributor

@varin-nair-factory varin-nair-factory commented May 9, 2026

Summary

Simplifies the TypeScript SDK turn API around two paths:

  • run(prompt, options?) for one-shot aggregated results
  • session.send(prompt, options?) for starting a turn, then turn.stream() or turn.result()

This removes the overlapping query(...) API and DroidSession.stream(prompt, options?), and updates docs, examples, and tests to the new shape.

Closes FAC-20152: https://linear.app/factoryai/issue/FAC-20152/simplify-droid-sdk-public-session-apis

Examples

One-shot aggregate result:

import { run } from '@factory/droid-sdk';

const result = await run('Summarize this project');
console.log(result.text);

Streaming a session turn:

import { DroidMessageType, createSession } from '@factory/droid-sdk';

const session = await createSession();

try {
  const turn = await session.send('List the TypeScript files');

  for await (const msg of turn.stream()) {
    if (msg.type === DroidMessageType.AssistantTextDelta) {
      process.stdout.write(msg.text);
    }
  }
} finally {
  await session.close();
}

Aggregating a session turn:

const session = await createSession();

try {
  const turn = await session.send('Summarize this project');
  const result = await turn.result();

  console.log(result.text);
} finally {
  await session.close();
}

Notes

This is a breaking API cleanup:

  • Removed query(...)
  • Removed DroidSession.stream(prompt, options?)
  • Changed DroidSession.send(...) to return a DroidTurn

Validation

  • npm run typecheck
  • npm run typecheck:examples
  • npm run lint
  • npm run format:check
  • npm test
  • npm run build

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant