Anvia
Studio

Studio Runtime

Studio class, server lifecycle, config, and run request contracts.

Import from @anvia/studio.

Studio

class Studio implements AnviaStudio {
  constructor(agents?: Agent[], options?: StudioOptions);
  get app(): Hono;
  fetch(request: Request): Response | Promise<Response>;
  config(): StudioConfig;
  traceObserver(): StudioTraceObserver;
  start(serveOptions?: StudioServeOptions): this;
  close(): void;
}

Purpose: local Studio HTTP runtime and UI/API host.

Return behavior: start(...) starts an HTTP server and returns this; fetch(...) delegates to the Hono app.

Notable errors: server startup can fail when the port is unavailable; route handlers return structured StudioErrorResponse values for request errors.

AnviaStudio

type AnviaStudio = {
  readonly app: Hono;
  fetch(request: Request): Response | Promise<Response>;
  config(): StudioConfig;
  close(): void;
};

Purpose: minimal Studio runtime interface.

Return behavior: implemented by Studio.

Notable errors: none directly.

Options

type StudioOptions = {
  quickPrompts?: Record<string, string[]>;
};

type StudioServeOptions = {
  port?: number;
  hostname?: string;
  log?: boolean;
};

type StudioUiOptions = {
  path?: string;
  rootRoutes?: boolean;
  title?: string;
  redirectRoot?: boolean;
  clientScript?: string;
  protectShell?: boolean;
};

Purpose: configure Studio agents, server binding, and UI mounting.

Return behavior: options are constructor or start inputs.

Notable errors: invalid server options can fail at the Hono server layer.

Run Contracts

type AgentRunRequest = {
  message: string | Message;
  history?: Message[];
  sessionId?: string;
  stream?: boolean;
  maxTurns?: number;
  toolConcurrency?: number;
  metadata?: JsonObject;
  trace?: AgentTraceOptions;
};

type AgentRunResponse = PromptResponse;
type AgentRunStreamEvent = AgentStreamEvent | StudioToolApprovalRequestEvent | StudioToolApprovalResultEvent;

Purpose: request, response, and stream event contracts for Studio agent run routes.

Return behavior: non-streaming runs return PromptResponse; streaming runs emit agent and approval events.

Notable errors: invalid request bodies return StudioErrorResponse with bad_request.