Sessions
Open a Runtime session and send the first command.
Create a session and send a message from a trusted backend:
import { createClient } from "@nylorun/agents";
const client = createClient({
url: process.env.NYLORUN_RUNTIME_URL,
key: process.env.NYLORUN_SERVER_KEY,
});
const session = await client.createSession({
agentId: "assistant",
ownerUserId: authenticatedUser.id,
});
await session.input("Look up order demo-123", { idempotencyKey: requestId });The generated project exports agents from agents/index.ts. nylorun dev
attaches to Runtime and connects your tools. Studio can send the same command
without this snippet.
The snippet assumes an authenticated user and a request id. Those values come from your application; they are not created by the SDK.
Trusted servers supply ownerUserId. Message input is content (the input()
helper takes a string). Retry the same semantic command with the same
idempotencyKey. Application credentials are not browser credentials.
createClient reads NYLORUN_RUNTIME_URL and NYLORUN_SERVER_KEY when you
omit url / key. There is no implicit default URL in the SDK; local CLI
scope uses http://127.0.0.1:8787.
createSession can take optional id, info, vaultIds, and
credentialSelections. info is host identity for hooks and tools
(context.info). It is not model-visible unless a hook copies it into
instructions.
Continue the same session by calling session.input again, or
client.session(sessionId) to reattach. session.history({ agent }) filters
delegated-agent events by delegationId or path. Start a new session after
definition or implementation edits; live upgrades are not supported.
Default local storage is SQLite under .nylorun/runtime.sqlite. Old
SessionRecord / events.jsonl files are not converted.
Need an in-process engine? See Harness.
Session commands
| Helper | Command type | Use |
|---|---|---|
session.input(content, options) | message | User text. |
session.approve(interactionId, approved, options) | approve | Correlated approval. |
session.respond(interactionId, value, options) | respond | Correlated response. |
session.cancel(options) | cancel | Cooperative cancel. Optional reason. |
Every helper requires idempotencyKey. Exact semantic duplicates return the
stored response; changed content conflicts (409).
Studio exposes text input, history, events, and cancel. It does not ship an approvals UI.