Skip to content
SegmentStream/ Docs

Loading documentation…

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

@segmentstream/ontology/nitro

9 public exports from @segmentstream/ontology/nitro.

Public exports

ONTOLOGY_QUEUE_NAMESPACE

The queue namespace of the ontology's runs, fixed at build time. The app and the agent of the same deployment run their own workflows on the SDK's default topics and on `eve<hex>`; this one keeps the ontology's messages on `__ontology_wkf_workflow_*`.

const ONTOLOGY_QUEUE_NAMESPACE = "ontology"
ONTOLOGY_SERVICE_PATHS
const ONTOLOGY_SERVICE_PATHS: readonly [
    "/api/ontology",
    "/api/ontology/**",
    "/mcp",
    "/.well-known/oauth-protected-resource",
    "/.well-known/oauth-protected-resource/mcp",
    "/.well-known/oauth-authorization-server",
    "/api/webhooks/**"
]
OntologyRoute

A Nitro route to the service's handler, loaded on its first request.

interface OntologyRoute {
    readonly handler: string;
    readonly lazy: true;
}
OntologyWorkflowsModule

A Nitro module: `modules: [ontologyWorkflows()]` in `ontology/nitro.config.ts`.

type OntologyWorkflowsModule = NitroModule & {
    readonly name: string;
};
OntologyWorkflowsOptions
interface OntologyWorkflowsOptions {
    readonly dirs?: ReadonlyArray<string>;
}
WORKFLOW_FLOW_ROUTE

The route of the Workflow SDK's queue callback, below the ontology service's path. Since Workflow SDK 5 a run's steps execute inside the flow callback and background steps come back on the workflow topic: there is no step route.

const WORKFLOW_FLOW_ROUTE = "/api/ontology/.well-known/workflow/v1/flow"
WORKFLOW_QUEUE_TRIGGER

The queue trigger of the flow function: the ontology's namespaced workflow topic.

const WORKFLOW_QUEUE_TRIGGER: {
    readonly type: "queue/v2beta";
    readonly topic: "__ontology_wkf_workflow_*";
    readonly consumer: "default";
    readonly retryAfterSeconds: 5;
    readonly initialDelaySeconds: 0;
}
ontologyRoutes

The Nitro routes that send every path of the ontology service to one handler.

function ontologyRoutes(handler: string): Record<string, OntologyRoute>;
ontologyWorkflows

The Workflow SDK, compiled and served by the ontology service: list it in `modules` of `ontology/nitro.config.ts`, in place of `workflow/nitro`. It - adds the SDK's transform to the server build, so `start` finds the compiled workflows; - before every build, bundles the workflows (`"use workflow"`) and their steps (`"use step"`) of `dirs` into Nitro's build directory, with the callback's base path `/api/ontology` and the queue namespace `ontology` written into the generated entrypoint; - mounts the flow handler, which runs the steps, in the ontology service's own server bundle at `/api/ontology/.well-known/workflow/v1/flow`, refusing anything but a queue delivery; - on Vercel, gives that route its own function with `maxDuration: "max"` and the queue trigger `__ontology_wkf_workflow_*`. It never uses `workflow/nitro`, and it mounts no webhook route.

function ontologyWorkflows(options?: OntologyWorkflowsOptions): OntologyWorkflowsModule;