TypeScript client guide

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. The family starts with Oda SDK overview; 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 Run an Oda runtime server.

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 a stop signal.
Note

Because env replaces the environment rather than adding to it, list every variable the runtime needs when you use it.

Run a turn

Read errors and diagnostics

Close the client

Questions, answered

What are the default timeouts?

The start-up handshake gets 10 seconds; requests wait indefinitely unless you set requestTimeoutMs; the shutdown request gets 1 second; and the teardown stages get 6 seconds after the input closes and 3 seconds after the stop signal.

Can I bound how long the client waits for a turn?

Yes, set requestTimeoutMs. Leaving it out is the default, because a turn can legitimately run long. A timeout ends the wait on your side; the runtime is not stopped.

Why must the working folder be an absolute path?

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

Does run() start a new runtime each time?

No. The runtime starts on the first call and is kept for later calls. Each run works in a session of its own.

Is finalResponse the reply 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 happens if 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.

What happens to notifications after close() or a crash?

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.

Do the environment variables I pass reach the runtime?

Yes. Pass env and the runtime starts with exactly that environment: it replaces the parent environment completely, so include every variable the runtime needs. The client reads it when the runtime starts.

How do I stop 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.