Skip to content
SegmentStream/ Docs

Loading documentation…

↑ ↓ to navigate  ↵ to open  Esc to close
Website Console
Section menu

@segmentstream/ontology/workspace-channel

16 public exports from @segmentstream/ontology/workspace-channel.

Public exports

WORKSPACE_CHANNEL_FILES_BYTES

The most bytes of files one message through a workspace channel carries unless the channel's code takes more (`limits.fileBytes`).

const WORKSPACE_CHANNEL_FILES_BYTES: number
WORKSPACE_CHANNEL_ID

A chat, person or message id on a workspace channel: letters, digits and `:_.@+-`, at most 256 characters, as the platform keys chats and their provenance. A provider's id of other characters is encoded by the channel's code, such as in base64url.

const WORKSPACE_CHANNEL_ID: RegExp
WORKSPACE_CHANNEL_MAXIMUM_FILES_BYTES

The most a channel's `limits.fileBytes` may be: what SegmentStream's connection proxy sends from the workspace's file storage in one request, so the channel's code can always send a file it takes through its connection.

const WORKSPACE_CHANNEL_MAXIMUM_FILES_BYTES: number
WORKSPACE_CHANNEL_REFUSALS

Why a workspace channel's provider refused a message, as its `send` names it: `422 { error }` with one of these sent nothing, and the ontology records the refusal as a first-party channel's.

const WORKSPACE_CHANNEL_REFUSALS: readonly [
    "outside_reply_window",
    "recipient_unreachable",
    "recipient_opted_out"
]
WORKSPACE_CHANNEL_ROUTE

Where the agent serves its workspace channels, each under its name.

const WORKSPACE_CHANNEL_ROUTE = "/eve/segmentstream/v1/custom"
WORKSPACE_CHANNEL_TEXT_LIMIT

The most characters one message through a workspace channel may have, whatever its provider.

const WORKSPACE_CHANNEL_TEXT_LIMIT = 20000
WorkspaceChannelFile

One file of {@link WorkspaceChannelSend}, by a short-lived signed read of it in the workspace's file storage: the bytes never travel in the request, so a file may be larger than a request.

interface WorkspaceChannelFile {
    readonly filename: string;
    readonly content_type: string;
    readonly size: number;
    readonly url?: string;
    readonly data?: string;
}
WorkspaceChannelRefusal
type WorkspaceChannelRefusal = (typeof WORKSPACE_CHANNEL_REFUSALS)[number];
WorkspaceChannelSend

`POST` {@link workspaceChannelSendRoute}: one message to one person's chat.

interface WorkspaceChannelSend {
    readonly operation_id: string;
    readonly chat_id: string | null;
    readonly recipient: string;
    readonly thread_id: string | null;
    readonly reply_to: string | null;
    readonly text: string;
    readonly files?: ReadonlyArray<WorkspaceChannelFile>;
}
WorkspaceChannelSent

The agent's answer: `200 { message_id }` once the channel's `send` returned, with the provider's id when it gave one. A `4xx` with `{ error }` sent nothing, and an `error` among {@link WORKSPACE_CHANNEL_REFUSALS} says why the provider refused it; anything else may have sent it.

interface WorkspaceChannelSent {
    readonly message_id: string | null;
}
isWorkspaceChannelRefusal

Whether `value` is one of {@link WORKSPACE_CHANNEL_REFUSALS}.

function isWorkspaceChannelRefusal(value: unknown): value is WorkspaceChannelRefusal;
renderWorkspaceChannelText

The text a workspace channel sends: the text as written, then the separator and attribution.

function renderWorkspaceChannelText(text: string, attribution: string, separator: string): string;
splitReply

A reply in parts of at most `maxLength` characters, as a workspace channel whose code sets `limits.maxLength` sends a longer one: at a paragraph, else a line, else a space, else where the length ends. The agent splits its own replies so, and the ontology the turn replies it sends.

function splitReply(text: string, maxLength: number | undefined): ReadonlyArray<string>;
workspaceChannelFiles

The files of a {@link WorkspaceChannelSend}, as the send route takes them: each by its link, and its bytes too while the message's files are within {@link WORKSPACE_CHANNEL_FILES_BYTES}.

function workspaceChannelFiles(files: ReadonlyArray<{
    readonly filename: string;
    readonly contentType: string;
    readonly size: number;
    readonly url: string;
    readonly bytes?: Uint8Array;
}>): ReadonlyArray<WorkspaceChannelFile>;
workspaceChannelRoute

The route of the workspace channel `name`: where its webhook receives, or where the platform wakes it when it reads its source on a schedule.

function workspaceChannelRoute(name: string): string;
workspaceChannelSendRoute

The route the ontology sends an approved reply or a chat post through, as the deployment.

function workspaceChannelSendRoute(name: string): string;