Skip to content
SegmentStream/ Docs

Loading documentation…

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

@segmentstream/agent/web

7 public exports from @segmentstream/agent/web.

Public exports

WEB_CORS

Browsers on any origin may call the agent's routes: every request a browser makes carries an agent token as its bearer, never a cookie, and a website's visitors get theirs only from the ontology, on the websites its `guest` or `signUp` names. {@link WEB_EXPOSED_HEADERS} stay readable.

const WEB_CORS: {
    origin: string;
    exposeHeaders: ("retry-after" | "x-eve-session-id" | "x-eve-stream-format" | "x-eve-stream-tail-index" | "x-eve-stream-version")[];
}
WEB_EXPOSED_HEADERS

The response headers a browser on another origin must read: a refusal's `Retry-After`, and the session and stream headers the chat client reads from every stream response, without which it stops at the first reply. The runtime fixes their names; it exports no constants for them.

const WEB_EXPOSED_HEADERS: readonly [
    "retry-after",
    "x-eve-session-id",
    "x-eve-stream-format",
    "x-eve-stream-tail-index",
    "x-eve-stream-version"
]
WEB_PROVIDER

The identity provider of a member who wrote on the web, as the ontology names it.

const WEB_PROVIDER = "web"
WebAuthOptions
interface WebAuthOptions {
    readonly introspect?: WebIntrospection;
    readonly config?: SegmentStreamAgentConfigInput;
    readonly environment?: Environment;
}
WebIntrospection

Asks whom a token stands for, for the origin the member reached the agent on: the member or guest, or `undefined` when it stands for nobody. With `turn`, the caller is starting a turn, which the ontology counts against the agent's limits, the `limits` given kept first. Throws when the ontology cannot answer.

type WebIntrospection = (token: string, origin: string, turn?: boolean) => Promise<WebCaller | undefined>;
webAuth

The route authenticator for the agent's own HTTP channel: a request with an agent token runs as the member it stands for, and any other request goes on to the next authenticator. An answer to one of the agent's confirmations through its own buttons is stamped with its decision, as a click on a Telegram card is, so that only a click, never a typed message, decides a confirmation. A message starts a turn, which counts against the agent's limits for people who signed up, as their turns on a messenger do; one beyond them is refused with {@link TurnLimitedError}. In an app preview, a test member's eval session may also read `GET /eve/v1/info`, so that `eve eval --url` runs against the preview as that member.

function webAuth(options?: WebAuthOptions): EveAuthFn;
webChannel

The agent's own HTTP channel, which browsers talk to: a member, or a guest of a declared website, who shows an agent token from the ontology talks to the agent as themselves, in their own chat; every other request keeps the runtime's defaults (this deployment's own functions, local development). The runtime reads this channel only from the agent's `agent/channels/eve.ts`, whose name it fixes. It passes `agent/segmentstream.json`, whose `limits` the ontology counts the web's turns against: ```ts import { webChannel } from "@segmentstream/agent/web"; import config from "../../segmentstream.json"; export default webChannel({ config }); ```

function webChannel(options?: WebAuthOptions): import("eve/channels/eve").EveChannel;