Oda SDK: TypeScript client

The Oda SDK client is the TypeScript package that starts an Oda runtime and drives its turns from your own program, so a script or an internal tool of yours can call DataMind Oda. Start with the Oda SDK overview if you are new to the family; the raw JSON-RPC messages are in SDK wire protocol.

Start the runtime

The opposite role, a process that serves SDK clients instead of driving one, is described in Oda SDK: the runtime server.

Launch options and defaults

Timeouts are in milliseconds.

OptionDefaultWhat it does
initializeTimeoutMs10000How long the client waits for the start-up handshake.
requestTimeoutMsnoneWith no value, requests wait indefinitely, because a turn can legitimately run long.
shutdownTimeoutMs1000How long the shutdown request may take before the client moves on.
disposeEofGraceMs6000How long the runtime may take to finish after its input closes.
disposeGraceMs3000How long it may take to exit after the client sends the stop signal.
Note

env replaces the environment of the runtime instead of adding to it, so list every variable the runtime needs when you use it.

Run a turn

Errors and diagnostics

Tip

Keep the stderr tail and the exit code in your logs: they are what a problem report needs.

Close the client

Questions, answered

What are the default timeouts?

The handshake has 10 seconds, a request waits indefinitely unless you set requestTimeoutMs, the shutdown request has 1 second, and the teardown stages have 6 seconds after the input closes and 3 seconds after the stop signal.

Should I set a request timeout?

Only if your own program needs a bound. Requests wait indefinitely by default, because a turn can legitimately run long. A timeout ends your wait; it does not stop the runtime.

What working folder should I give the client?

An absolute one. The client resolves the folder before the start-up handshake, and an absolute path keeps that resolution final, so the folder cannot be resolved twice.

Can I cap how much a request may produce?

Yes, pass maxTokens. It caps each request the root agent makes, and subagents that run in the same process inherit the cap.

Can I control the environment of the runtime?

Yes. Pass env and the runtime starts with exactly that environment instead of an inherited one, so include every variable the runtime needs.

Is finalResponse the answer to my prompt?

Not exactly. It is the last committed assistant text of the session, and it is not assigned to a specific prompt. If the session has not produced an assistant message yet, it is empty.

What is the difference between events and notifications?

events are the events of your own session. notifications follow the wider session tree, subagents included, in wire order.

What happens when the start-up handshake fails?

The client cleans up that attempt and prepares a fresh one, so your next call may succeed. If the cleanup fails too, the client reports both failures as one combined error.

Why does an error include an exit code or a stderr tail?

So you can see why the runtime stalled or died. The tail holds the newest 400 lines of the runtime's error output, and the exit code shows how the process ended.

How do I close the client without leaving a stray process?

Use close(). It asks the runtime to shut down and escalates in bounded steps until the process has exited, and calling it again is safe. Only a process that will not exit after the force step makes it fail, with a message that names the wait.

What happens to notifications after the runtime dies or the client closes?

A reader that is open when the runtime dies can still drain what was already delivered, then it fails. After close(), notifications that were not delivered yet are dropped.