Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@langchain/protocol

Package Overview
Dependencies
Maintainers
13
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@langchain/protocol - npm Package Compare versions

Comparing version
0.0.13
to
0.0.14-alpha.1
+2
-2
package.json
{
"name": "@langchain/protocol",
"version": "0.0.13",
"version": "0.0.14-alpha.1",
"description": "TypeScript bindings for the LangChain agent streaming protocol",

@@ -30,2 +30,2 @@ "license": "MIT",

}
}
}

@@ -14,3 +14,4 @@ // ==========================================================================

// The result is a single protocol where:
// - Content blocks are the universal delta carrier for LLM streaming
// - Content blocks are the universal carrier for LLM output
// - Content block deltas have explicit append/merge semantics
// - Events have full lifecycle semantics (no inferred boundaries)

@@ -20,3 +21,3 @@ // - Namespace-based filtering provides server-side routing

// Status: DRAFT
// Version: 0.5.0
// Version: 0.0.13
// ==========================================================================

@@ -53,6 +54,6 @@ // ==========================================================================

// 2. Content Block Types
// LangChain content blocks are the universal carrier for streaming
// deltas. The block's `type` field is the discriminant. New content
// block types automatically work with the streaming protocol without
// protocol changes.
// LangChain content blocks are the universal carrier for model output.
// The block's `type` field is the discriminant. New content block
// types automatically work with the streaming protocol without protocol
// changes by using BlockDelta for incremental field updates.
// "Chunk" variants (ToolCallChunk, ServerToolCallChunk) carry

@@ -227,2 +228,51 @@ // partial/incremental data during streaming. "Standard" variants carry

// Explicit incremental updates for content blocks.
// TextDelta, ReasoningDelta, and DataDelta append to their named fields.
// BlockDelta shallow-merges `fields` onto the accumulated content block.
// Producers should use DataDelta for streamed base64 chunks in image,
// audio, video, or file blocks. Use BlockDelta for tool-call argument
// streaming, provider signatures, citations, compaction markers, and
// future block fields without dedicated append semantics.
export type NonStandardContentBlock = Extensible & {
type: "non_standard";
value: Record<string, any>;
id?: string;
index?: BlockIndex;
};
export type TextDelta = Extensible & {
type: "text-delta";
text: string;
};
export type ReasoningDelta = Extensible & {
type: "reasoning-delta";
reasoning: string;
};
// One-layer patch for the currently active content block.
// `type` identifies the content block type whose fields are being
// updated; all other keys are shallow-merged onto the accumulated block.
export type DataDelta = Extensible & {
type: "data-delta";
/**
* Encoded data chunk to append
*/
data: string;
/**
* Defaults to base64 when absent
*/
encoding?: "base64";
};
export interface BlockDeltaFields {
type: string;
[key: string]: any | undefined;
}
export type BlockDelta = Extensible & {
type: "block-delta";
fields: BlockDeltaFields;
};
// ==========================================================================

@@ -237,8 +287,3 @@ // 3. Top-Level Message Framing

// --- Client -> Server ---
export type NonStandardContentBlock = Extensible & {
type: "non_standard";
value: Record<string, any>;
id?: string;
index?: BlockIndex;
};
export type ContentBlockDelta = TextDelta | ReasoningDelta | DataDelta | BlockDelta;

@@ -297,6 +342,6 @@ export type Command = CommandData & Extensible & {

// **SSE/HTTP:**
// POST /v2/threads/:thread_id/events — filtered SSE event stream
// POST /v2/threads/:thread_id/commands — JSON command request/response
// POST /threads/:thread_id/stream — filtered SSE event stream
// POST /threads/:thread_id/commands — JSON command request/response
// **WebSocket:**
// ws://.../v2/threads/:thread_id — full-duplex connection
// ws://.../threads/:thread_id/stream — full-duplex connection
// Subscription model varies by transport:

@@ -381,3 +426,3 @@ // **SSE/HTTP:** Subscriptions are connection-scoped. Each

// **SSE/HTTP transport (connection-scoped subscriptions):**
// Clients open one or more `POST /v2/threads/:thread_id/events` requests,
// Clients open one or more `POST /threads/:thread_id/stream` requests,
// each carrying an `EventStreamRequest` body with the desired channel

@@ -406,3 +451,3 @@ // and namespace filters. The server responds with an SSE stream

// --- Event stream request (SSE/HTTP transport only) ---
// Sent as the JSON body of `POST /v2/threads/:thread_id/events`.
// Sent as the JSON body of `POST /threads/:thread_id/stream`.
// The server responds with `Content-Type: text/event-stream`.

@@ -628,6 +673,6 @@ export type Channel = "values" | "updates" | "messages" | "tools" | "lifecycle" | "input" | "checkpoints" | "tasks" | "custom" | `custom:${string}`;

// -> content-block-start(index=0, contentBlock)
// -> content-block-delta(index=0, contentBlock) ...
// -> content-block-delta(index=0, delta) ...
// -> content-block-finish(index=0, contentBlock)
// -> content-block-start(index=1, contentBlock)
// -> content-block-delta(index=1, contentBlock) ...
// -> content-block-delta(index=1, delta) ...
// -> content-block-finish(index=1, contentBlock)

@@ -639,5 +684,7 @@ // -> message-finish(reason)

// all major LLM providers.
// Delta events carry LangChain ContentBlock instances directly —
// the block's `type` field is the discriminant. This means adding
// a new content block type to LangChain requires zero protocol changes.
// Delta events carry explicit delta variants:
// - text-delta appends to the active block's `text` field
// - reasoning-delta appends to the active block's `reasoning` field
// - data-delta appends to the active block's `base64` field
// - block-delta shallow-merges `fields` onto the active block
// ==========================================================================

@@ -693,7 +740,8 @@ export interface LifecycleData {

// Emitted for each incremental update within a content block. The
// contentBlock carries only the delta for this update:
// { type: "text", text: "Hello " } — text delta
// { type: "reasoning", reasoning: "Let me" } — reasoning delta
// { type: "tool_call_chunk", args: '{"q":' } — tool call args delta
// Emitted for each incremental update within a content block:
// { type: "text-delta", text: "Hello " } — append text
// { type: "reasoning-delta", reasoning: "Let me" } — append reasoning
// { type: "data-delta", data: "UklGR..." } — append base64 data
// { type: "block-delta", fields: { type: "tool_call_chunk", args: '{"q":' } }
// — shallow merge fields
export type ContentBlockStartData = Extensible & {

@@ -714,3 +762,3 @@ event: "content-block-start";

index: number;
content: ContentBlock;
delta: ContentBlockDelta;
};

@@ -717,0 +765,0 @@

+11
-19

@@ -13,10 +13,9 @@ # `@langchain/protocol`

- Types for top-level messages such as `Command`, `Message`, and protocol events
- Types for protocol modules including session, subscription, resource,
sandbox, input, state, and usage
- Types for protocol modules including run, subscription, agent, input, state,
and usage
## What this package does not include
This package does not currently ship a runtime client, transport, or helper APIs
such as `createSession()`. It is intended for typing protocol payloads and
generated bindings only.
This package does not currently ship a runtime client, transport, or helper APIs.
It is intended for typing protocol payloads and generated bindings only.

@@ -37,3 +36,2 @@ ## Installation

Message,
SessionOpenParams,
SubscribeParams,

@@ -48,11 +46,11 @@ MessagesEvent,

```ts
import type { Command, SessionOpenParams } from "@langchain/protocol";
import type { Command, SubscribeParams } from "@langchain/protocol";
const params: SessionOpenParams = {
protocolVersion: "0.3.0",
const params: SubscribeParams = {
channels: ["messages", "lifecycle"],
};
const openCommand: Command = {
const subscribeCommand: Command = {
id: 1,
method: "session.open",
method: "subscription.subscribe",
params,

@@ -62,11 +60,5 @@ };

## Versioning
The package version is aligned with the draft protocol schema version published
from this repository. The current generated bindings target protocol `0.3.0`.
## Source of truth
The canonical protocol definition lives in the repository root at
`protocol.cddl`. The TypeScript bindings in this package are generated from that
schema.
The canonical protocol definition lives at [`protocol.cddl`]([https://](https://github.com/langchain-ai/agent-protocol/blob/main/streaming/protocol.cddl)). The TypeScript
bindings in this package are generated from that schema.