TypeScript SDK
Capture application turns with the source TypeScript SDK and inspect their recorded evidence.
Watch the workflow: Read a recorded session and tool trace · Authored dummy data
Read authored agent inputs and outputs, open the recorded trace and inspect one tool run. Role, completion and customer outcome remain unknown. No evidence or feedback is saved.
This video shows the matching app inspection workflow with authored dummy data. It does not execute an SDK example or prove successful delivery from your application. Read the matching command examples separately.
Read the walkthrough transcript
- 00:00 — Read recorded agent inputs and outputs in Tensile. This is an authored demo session.
- 00:05 — Open Trace to see the recorded runs. The session outcome remains unknown.
- 00:11 — Read one tool run's input and output. Saving evidence is a separate action.
The SDK registry release is pending. These instructions require a trusted source checkout supplied by your team. They do not install a package from the public registry. Without SDK source access, use the capture API instead.
Source setup
pnpm install --frozen-lockfile
pnpm --filter @withtensile/sdk buildRun these commands from the source checkout with Node.js 22 or later. In the consuming application, install the built SDK folder:
npm install /absolute/path/to/source/sdks/typescriptReplace the path with the trusted checkout on your machine. The import name is @withtensile/sdk.
Configure capture
Create a scoped API key in Settings. Set TENSILE_API_KEY in the application environment. The default endpoint is https://api.withtensile.com. Set TENSILE_ENDPOINT to change it, including for an isolated local test. Never put a real key in source code or a recording.
Set TENSILE_ENV=staging, or pass the environment explicitly. The explicit setting wins. Without a stage tag, the app cannot treat the record as production traffic.
Capture a turn
import { init, begin, identify } from "@withtensile/sdk";
init(process.env.TENSILE_API_KEY, { environment: "staging" });
identify("demo-user", { plan: "demo" });
const turn = begin({
userId: "demo-user",
agentName: "demo-support",
input: "What is the status of demo order 1042?",
});
turn.setProperty("channel", "help-demo");
await turn.end("Demo order 1042 is shipped.", { success: true });begin creates a session ID and records the start time. end sends the session once, then sends an event with the output, success flag and latency. The success flag describes this recorded turn; it is not an assessment of task correctness.
For a completed turn, use await track({ userId: "demo-user", input: "Hi", output: "Hello", agentName: "demo-support" }) after importing track. Pass a shared conversationId to group turns in one session.
Use identify("demo-user", { plan: "demo" }) before capture, after importing identify. Traits apply to the next session. Use turn.setProperties({ channel: "help-demo", model: "demo-model" }) for custom properties. These values do not run a model.
Check errors and delivery
Capture failures are logged and swallowed by default. Set throwOnError: true in the init options when an isolated test must fail on capture errors. Await end or track before the process exits. A returned application result does not prove delivery.
Open User Stories to inspect a captured conversation. Use its trace view to read recorded events. Or open Raw Logs, select the matching stage and inspect the input and output of one event. Missing records are not successful delivery. A tool success flag does not prove a customer outcome.
For tool calls, see MCP capture.