Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

@theokit/presenter

Latest version: v0.18.2

Overview

Last scanned
23 Nov 2026
Published
23 Nov 2026
npm package Publisher: usetheodev
5 Stars
1 Forks
16 Versions
14.7K Downloads
TypeScript Repo language

Scan summary

@theokit/presenter was last scanned on 23 Nov 2026 at version 0.18.2. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 16 versions; the latest 5 were published within 5 days (19–23 Nov 2026).
  • Findings: No rules fired in version 0.18.2.
  • Downloads: 14,697 downloads.

Versions

16 versions published
Versions and the rules that fired in each
VersionPublishedStatus
0.18.2 LATEST 23 Nov 2026 No rules fired
0.18.1 23 Nov 2026 No rules fired
0.18.0 22 Nov 2026 No rules fired
0.17.0 20 Nov 2026 Not shown
0.16.0 19 Nov 2026 Not shown

No rules fired in 0.18.2

Findings

Findings for v0.18.2. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 0.18.2; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

@theokit/presenter

The presentation layer: one normalized agent-output event, N surfaces.

Agent output has to reach a web stream, a terminal, and a JSON API. Translating the runtime's messages separately for each of them gives you N×M translators that drift — the terminal grows a tool-call rendering the web never gets, and a new SDK event lands in one path only.

This package is the narrow waist that removes the multiplication. Every source translates into AgentOutputEvent; every presenter translates out of it.

SDK message ─┐                        ┌─→ UIMessageStreamPresenter → web
             ├─→ AgentOutputEvent ────┼─→ TerminalPresenter        → ANSI rows
wire chunk ──┘                        └─→ JsonPresenter            → records

The variants are derived from the runtime's own discriminants, never from one surface's wire format — so no surface leaks into the contract.

Install

pnpm add @theokit/presenter

Peers (@theokit/sdk and zod) are optional. What each entry needs:

  • @theokit/presenter (root): neither at runtime.
  • @theokit/presenter/wire: zod.
  • The .d.ts files reference types from both packages, so a TypeScript consumer without them needs skipLibCheck (or installs them as devDependencies).

New root exports must stay free of runtime imports of either peer; tests/root-entry-has-no-runtime-peers.test.ts pins it.

The canonical event

Eight variants, discriminated on type:

Variant Carries
text assistant text output, streamed or whole
reasoning thinking content, distinct from user-visible text
tool-call a tool invocation with its committed input
partial-tool-call incremental tool input while the model streams the args
tool-result the result for a callId, with isError for failures
status run-level status
error a failed turn
finish the end of the turn plus its metadata

Sources and presenters

import { fromSdkMessage, TerminalPresenter } from '@theokit/presenter'

const presenter = new TerminalPresenter()
for (const message of sdkMessages) {
  for (const event of fromSdkMessage(message)) {
    for (const row of presenter.present(event)) render(row)
  }
}

fromSdkMessage reads a failed, vetoed or timed-out tool call from the result's exitCode (non-zero), not from status, because the SDK reports every finished call as completed. An absent or non-numeric exit code is not a failure.

fromRunTimelineEvent is the door for run.events(), the SDK's one ordered timeline of messages and token deltas. It drops text a message repeats (textAlreadyStreamed), repeated reasoning and repeated tool lifecycle points, and holds a tool result until the other report can mark it failed. Keep one state per run and flush it when the timeline ends:

import { createRunTimelineState, flushRunTimeline, fromRunTimelineEvent } from '@theokit/presenter'

const state = createRunTimelineState()
for await (const item of run.events()) {
  for (const event of fromRunTimelineEvent(item, state)) render(event)
}
for (const event of flushRunTimeline(state)) render(event)

fromWireChunk is the other door — from the transport wire into the canonical event, which is what a client-side surface receives. createWireReader() wraps it with the state a stream needs: it keeps the call-name map and attaches the data-error-code code (WIRE_ERROR_CODE_PART) to the next error event. fromInteractionUpdate covers interactive runs.

A Presenter<TOut> is surface + present(event), with optional start() / finish() framing for stateful surfaces. UIMessageStreamPresenter holds open-block state and is therefore instantiated per stream; TerminalPresenter and JsonPresenter are stateless and may be singletons. PresenterRegistry resolves one by surface key and throws a typed UnknownPresenterError when the key is unknown — never a silent fallback.

foldTurnLifecycle collapses a turn's events into a TurnLifecycle when a surface wants the outcome rather than the stream.

Pass { messageBoundary: 'tool-call' } as the third argument to split a preamble from the answer: text seen before a tool call is emitted as its own completed message item (message_0, message_1, ...) when the call arrives, and only the remainder is emitted at finish. The default, 'none', keeps one concatenated message item. A tool-result chunk with isError: true reaches itemCompleted with isError: true.

contentChunkFromEvent(event) turns an AgentOutputEvent into the ContentChunk the fold reads, or null for events it does not model (reasoning, partial tool calls, status, finish). finalMessageOf(events) returns the trimmed text after the last tool call, or all the text when the turn made no tool call.

Tool kinds

TOOL_KINDS is one table of known tool names. Each entry has a kind (shell, diff, read, write, list, search, fetch, plan, memory, other) and the input targetKeys that name the call's target, in preference order. toolKindOf(name) looks a name up.

import { toolKindOf } from '@theokit/presenter'

toolKindOf('shell') // { kind: 'shell', targetKeys: ['command', 'cmd'] }
toolKindOf('execute_sql') // undefined

Lookup is exact by design. A name that is not in the table gives undefined, never a substring guess, so thread_summary is not a read tool and execute_sql is not a shell tool. The table includes the SDK's builtin tools, pinned to the SDK type at compile time.

Reading a tool result

readToolResult(raw) turns any tool result into one ToolResultView (shell, diff, error or text) and never throws. It accepts both shell dialects:

  • @theokit/sdk-tools shell_exec: a JSON string {ok, stdout, stderr, exit_code}.
  • The SDK runtime: an object {stdout, stderr, exitCode}.

When both exit-code spellings are present and differ, exitCode wins. A missing exit code stays undefined, never 0. {ok: false, error} reads as error (tool_failed when absent, stderr as detail); {ok: true, diff} and a raw unified diff string read as diff; anything else is text.

Rendering a transcript

foldTranscript(state, event) folds AgentOutputEvents into a TranscriptState { items, status, error? }, starting from EMPTY_TRANSCRIPT. Items are messages, reasoning, tool cards (pending, running, success or failed, with a ToolResultView from readToolResult) and an error. Text before and after a tool call are two message items; tool cards are keyed by callId. It is pure, never mutates its input, and returns the same state object when an event changes nothing (status events).

It is terminal-final: finish sets done and error sets error (keeping code); both fail every tool still pending or running, and every later event returns the same state.

Use foldTranscript to draw a chat screen. Use foldTurnLifecycle when you need the turn's lifecycle (items started and completed, the outcome) rather than a render state.

Pending approvals

pendingApprovals(messages) returns every outstanding approval across wire messages, in order, as PendingApproval { approvalId, toolCallId, toolName, input, question?, timeoutMs? }. With nothing outstanding it returns one shared empty array. readPendingApproval(part) reads a single part. A part in approval-requested without a string approval.id is skipped, never settled by its toolCallId, because approve() could not settle it.

Turn metadata

readTurnMetadata(chunk) (from @theokit/presenter/wire) reads a finish chunk's messageMetadata as a WireTurnMetadata { usage?, cost?, durationMs?, stopReason?, model? }. Fields of the wrong type are dropped rather than thrown on, and an unknown stopReason is dropped. It returns undefined for any other chunk or a finish without object metadata. A stopReason of 'step_limit' or 'no_progress' means the turn was cut, not finished.

Refused tool calls

AgentToolResultEvent.refusal?: ToolRefusal ({ by: 'human' | 'timeout' | 'policy' | 'hook' | 'plugin', reason? }) marks a result as refused rather than run. UIMessageStreamPresenter sends it as a transient data-tool-refusal part (WIRE_TOOL_REFUSAL_PART, from ./wire) just before the tool-output-error, and readMessageStream sets refusal on that tool part. The text the model reads does not change.

Subpaths

Subpath What lives there
. The event, the Presenter contract, the registry, the sources, the three presenters
./wire The wire-format types shared with transports
./diff The one unified-diff model for UI kits: parseUnifiedDiff, foldDiffLines, segmentWords, pairIntraLines, DiffParseError. Data only; the only entry that loads parse-diff and diff

Licence

Apache-2.0 — see LICENSE.

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • npm @theokit/presenter

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Copy of Template Design OX Blog (3)
Research

Ruby2Shell: Ruby Memory Corruption Flaws Expose Applications to Remote Code Execution, But is it an Actual Risk?

Vulnerability Insights

Compromised Claude Code extensions (versions 2.1.312 & 2.1.313) in Cursor try to install a backdoor

The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Vulnerability Insights

The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?

Frame 2085668439 (1)
Group 1261154229