npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@robota-sdk/agent-interface-session

v3.0.0-beta.97

Published

Session contract interfaces for the Robota SDK — interactive sessions, interaction channels, session events, turns and persistence

Readme

@robota-sdk/agent-interface-session

The session contracts of the Robota SDK: what an interactive session is and what it exposes, the events it emits, the handle a caller gets for one submitted turn, the record that persists a session and the store port that loads it, and the in-process interaction channel a surface can talk to a session through.

The package is mostly type declarations. Its few runtime exports are pure helpers over those types (listed below); it contains no classes and no I/O. It builds on the other contract packages: @robota-sdk/agent-interface-execution (background work), @robota-sdk/agent-interface-command (commands) and @robota-sdk/agent-interface-analytics (usage).

Installation

npm install @robota-sdk/agent-interface-session

Usage

Code that drives a session depends on IInteractiveSession, not on the class that implements it:

import type { IInteractiveSession } from '@robota-sdk/agent-interface-session';
import { isTurnNotRunError } from '@robota-sdk/agent-interface-session';

async function ask(session: IInteractiveSession, prompt: string): Promise<string | undefined> {
  const turn = await session.submit(prompt);
  try {
    const result = await turn.completed;
    return result.response;
  } catch (error) {
    // The turn never ran: it was coalesced, dropped at queue capacity, or cancelled.
    if (isTurnNotRunError(error)) return undefined;
    throw error; // a real failure inside the turn
  }
}

A session runs one turn at a time and queues the rest. submit() returns an ITurnHandle whose completed promise always settles: with this turn's result, or with a "turn did not run" error that isTurnNotRunError recognizes.

What it defines

| Area | Main types | | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | The session | IInteractiveSession, and the capability slices it is made of (ISessionTurnSubmission, ISessionConversationRead, ISessionCommands, ISessionBackgroundTasks, …) collected in ISessionCapabilityMap | | Turns | ITurnHandle, IExecutionResult, ITurnNotRunError, TTurnNotRunReason, TTurnSource, ISubmitOptions | | Events | IInteractiveSessionEvents, TInteractiveEventName, IPermissionRequestEvent, IAskRequestEvent, IPromptResolvedEvent, IBranchEvent, ISkillActivationEvent, IMemoryEvent | | Persistence | IInteractiveSessionRecord, IInteractiveSessionStore, TSessionLoadOutcome (valid, missing, corrupt or unsupported) | | Interaction channel | IInteractionChannel, InteractionEvent, IAgentDriver, ICommandInfo | | Drivers and co-driving | TDriverId, IPeerTurnContext, IUiIntentEvent | | Session listing, binding, loops, prompt history, compaction | ISessionListing, ISessionBinder, ISessionLoopState, IPromptHistorySource, ICompactEvent |

Runtime exports:

| Export | What it is | | ------------------------------------------------------------------------------ | ------------------------------------------------------------ | | readAssistantReplies, readLastAssistantText, readToolCalls, readErrors | Pure readers over an InteractionEvent[] stream | | isTurnNotRunError | Tells a "turn did not run" rejection from a real failure | | isSessionChangeRefusal, SESSION_CHANGE_REFUSAL_CODES | Recognize a refused session switch and list its reason codes | | SESSION_CAPABILITY_MEMBER_KEYS | The members each capability slice contributes to a session | | OWNER_DRIVER_ID, AGENT_DRIVER_ID | Driver ids for the local operator and for autonomous turns |

A driver id is for display and attribution only; it is never an authorization input.

Test doubles: @robota-sdk/agent-interface-session/testing

The ./testing subpath ships conformant doubles for code that consumes these contracts. It is separate from the main entry so the doubles never land in a production bundle.

| Export | What it does | | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | | createTestInteractiveSession(overrides?) | Returns a complete IInteractiveSession with inert defaults; each double has its own session id and every submit() handle settles | | createSessionCapabilityHost(capabilities) (alias createTestSessionCapabilityHost) | Builds a host object from a partial set of capability slices, rejecting unknown slice names | | readSessionCapability(host, key) | Reads one slice as { provided: true, value } or { provided: false } |

import { createTestInteractiveSession } from '@robota-sdk/agent-interface-session/testing';

const session = createTestInteractiveSession({ getCwd: () => '/tmp/project' });

Because the double is typed as IInteractiveSession without a cast, a test that uses it stops compiling when the contract gains a member, instead of silently testing against an old shape.

Where it sits

  • Depends on @robota-sdk/agent-core, @robota-sdk/agent-interface-analytics, @robota-sdk/agent-interface-command and @robota-sdk/agent-interface-execution.
  • @robota-sdk/agent-framework implements the session (InteractiveSession) and an in-process interaction channel (ProgrammaticInteractionChannel).
  • @robota-sdk/agent-session persists session records (NodeSessionStore implements IInteractiveSessionStore).
  • Transports (@robota-sdk/agent-transport and its -http, -mcp, -ws carriers), the UIs (@robota-sdk/agent-ui-terminal, @robota-sdk/agent-ui-web), @robota-sdk/agent-command, @robota-sdk/agent-session-analytics and @robota-sdk/agent-interface-session-mobility consume these types.

Documentation

  • docs/SPEC.md — the contract: interaction channel, persistence, capability presence, turn identity, and the runtime-tool capability.

License

This package is dual-licensed under the GNU AGPL-3.0 or a commercial license. See LICENSING.md.