PASH Protocol

Protocol for Agentic Semantic Hypermedia — LLM-agnostic UI protocol

v1.1.0 MIT License 224 tests

npm: pash-sdk · npm: @akynzhe/pash-js · GitHub

−79%
vs HTML tokens
−87%
PASH+ID mode
14
UI components
3
Output modes

What is PASH?

The AI doesn't write markup. It sends intent. The client renders.

PASH is a token-efficient text format for transmitting UI components from LLMs to clients.

Instead of HTML (52 tokens):

<div class="product-card"><h3>Смартфон X1</h3><p>AMOLED 120Hz</p>
<span class="price">69 990 ₽</span><button>Купить</button></div>

The AI outputs PASH (11 tokens — 79% fewer):

1|Смартфон X1|AMOLED 120Hz|69990|Купить

Your client knows 1 = ProductCard, renders it with your CSS, your locale, your design system.


Quick Start

Step 1 — Install

npm install pash-sdk @pash/prompt

Step 2 — Generate system prompt

const { PromptEngine } = require('@pash/prompt');
const { SCHEMAS }      = require('pash-sdk');

const engine = new PromptEngine({ schemas: SCHEMAS });
const system = engine.generate({ lang: 'ru', mode: 'pash' });
// Auto-generated from your component registry. Always in sync.

Step 3 — Decode AI response

const { decodeStream, renderStream } = require('pash-sdk');

const aiResponse = `
1|Смартфон X1|AMOLED 120Hz, 256GB|69990|Купить
2|warn|Последний в наличии
`;

const decoded = decodeStream(aiResponse);
// { version: null, components: [ ProductCard, Notification ] }

document.getElementById('output').innerHTML = renderStream(decoded);

Step 4 — Streaming (optional)

const { StreamingDecoder, renderComponent } = require('pash-sdk');

const decoder = new StreamingDecoder((component) => {
  document.getElementById('output').innerHTML += renderComponent(component);
});

const response = await fetch('/api/ai');
const reader   = response.body.getReader();
const utf8     = new TextDecoder();

while (true) {
  const { done, value } = await reader.read();
  if (done) { decoder.flush(); break; }
  decoder.push(utf8.decode(value));
}

Format

COMP_ID|field1|field2|field3|...

Token efficiency

FormatTokensvs HTML
HTML~52
JSON~34−35%
Markdown~26−50%
PASH~11−79%
PASH+ID~7−87%

Component Registry

UI Components (ID 1–6)

IDComponentFields
1ProductCardtitle* | desc | price[currency] | cta
2Notificationlevel*(info|warn|error) | message*
3Listtitle | items*
4Heroheadline* | sub | cta
5Articletitle* | author | date | summary
6RichBlockcontent*[richtext]

PASH-Doc Blocks (ID 20–32)

IDBlockFields
20Headinglevel*(1-6) | text*
21Paragraphtext*[richtext]
22Codelang | body*
23Blockquoteauthor | text*[richtext]
24Imageurl* | alt | caption
25Divider
26Tableheaders* | rows*
27OrderedListtitle | items*
28BulletListtitle | items*
29Notelevel*(info|tip|warn|danger) | text*
30Spoilertitle* | body*[richtext]
31Mathdisplay*(block|inline) | formula*
32Embedtype*(youtube|...) | url* | title

* = required. ID 40+ available for custom components.


Modes

ModeExampleTokens
pash1|Смартфон X1|AMOLED|69990|Купить~11
pash+id1|102|45|69990|12~7
eventsCOMP_START(1)\nTEXT(Смартфон X1)...similar

Custom component

const { registerComponent } = require('pash-sdk');

registerComponent(40, {
  name: 'UserCard',
  fields: [
    { id: 0, type: 'string', label: 'name',  required: true },
    { id: 1, type: 'string', label: 'email'                 },
  ],
  render: (f) => `<div class="user-card"><b>${f.name}</b><span>${f.email}</span></div>`,
});

// AI can now generate: 40|Иван Петров|ivan@example.com

Locale

const { setLocale } = require('pash-sdk');

setLocale('en-US');  // price: 69990 → $69,990
setLocale('de-DE');  // price: 69990 → 69.990 €
setLocale('ru-RU');  // price: 69990 → 69 990 ₽  (default)

SDK Modules

decodeStream parseLine encode encodeStream renderComponent renderStream StreamingDecoder EventStreamDecoder Dictionary setLocale addLocale validateStream registerComponent SCHEMAS VERSION


Links


PASH v1.1.0 · MIT License · Copyright (c) 2026 Sergei