histoire
Version:
A fast story book powered by Vite
530 lines • 26.6 kB
TypeScript
import type { DevMcpCliOptions } from '@histoire/cli';
import type { ProjectRuntimeOptions } from './types.js';
import { createProjectRuntimeController } from './controller.js';
/** Reuses canonical controller/MCP assembly without command signal or process mutation. */
export declare function createDevSession(options: ProjectRuntimeOptions & DevMcpCliOptions & {
projectId?: string;
}, token?: string, createController?: typeof createProjectRuntimeController): {
controller: {
readonly status: import("@histoire/dev-proxy/protocol").RuntimeStatus;
readonly current: import("@histoire/dev-proxy/lifecycle").LifecycleHandle<import("./types.js").RuntimeGeneration>;
start: () => Promise<import("@histoire/dev-proxy/lifecycle").LifecycleHandle<import("./types.js").RuntimeGeneration>>;
restart: (_source?: string) => Promise<import("@histoire/dev-proxy/lifecycle").LifecycleHandle<import("./types.js").RuntimeGeneration>>;
waitForReady: () => Promise<import("@histoire/dev-proxy/lifecycle").LifecycleHandle<import("./types.js").RuntimeGeneration>>;
subscribe(listener: (status: import("@histoire/dev-proxy/protocol").RuntimeStatus, handle?: import("@histoire/dev-proxy/lifecycle").LifecycleHandle<import("./types.js").RuntimeGeneration>) => void): () => void;
close(): Promise<void>;
};
execution: {
readonly available: boolean;
readonly pendingCount: number;
enqueue<T>(task: import("./execution-types.js").ExecutionTask<T>): import("./execution-types.js").ExecutionHandle<T>;
cancelAll: () => Promise<void>;
quarantine(): void;
close(): Promise<void>;
};
/** Active optional dev HTTP adapter, owned independently of book listener. */
readonly mcp: {
readonly url: string;
project: {
projectId: string;
getProject: (signal?: AbortSignal) => import("../mcp/project/facade.js").McpRead<import("../mcp/protocol/project-schema.js").McpProject>;
listStories: (input: import("../mcp/protocol/tool-schema.js").McpToolInput<'histoire_list_stories'>, signal?: AbortSignal) => import("../mcp/project/facade.js").McpRead<import("../mcp/project/facade.js").McpStoriesResult>;
getStory: (input: import("../mcp/protocol/tool-schema.js").McpToolInput<'histoire_get_story'>, signal?: AbortSignal) => import("../mcp/project/facade.js").McpRead<import("../mcp/project/facade.js").McpStoryResult>;
getDocs: (input: import("../mcp/protocol/tool-schema.js").McpToolInput<'histoire_get_docs'>, signal?: AbortSignal) => import("../mcp/project/facade.js").McpRead<import("../mcp/protocol/content-schema.js").McpDocsResult>;
getSource: (input: import("../mcp/protocol/tool-schema.js").McpToolInput<'histoire_get_source'>, signal?: AbortSignal) => import("../mcp/project/facade.js").McpRead<import("../mcp/protocol/content-schema.js").McpSourceResult>;
getPreview: (input: import("../mcp/protocol/tool-schema.js").McpToolInput<'histoire_get_preview'>, signal?: AbortSignal) => import("../mcp/project/facade.js").McpRead<import("../mcp/project/facade.js").McpPreviewResult>;
capture(): {
handle: import("./types.js").ProjectRuntimeHandle;
catalog: {
readonly current: import("./catalog/types.js").CatalogSnapshot;
readonly updating: boolean;
markUpdating(): void;
publish(ctx: import("../context.js").Context, outcomes?: ReadonlyMap<string, import("../collect/outcome.js").StoryCollectionOutcome>): Promise<import("./catalog/types.js").CatalogSnapshot>;
getStory(storyId: string, expectedRevision?: string): {
revision: string;
story: import("./catalog/types.js").CatalogStory;
projectId: string;
};
getTarget(storyId: string, variantId: string, expectedRevision?: string): {
revision: string;
story: import("./catalog/types.js").CatalogStory;
variant: {
id: string;
title: string;
};
projectId: string;
};
list: (input: import("../mcp/project/catalog-pages.js").CatalogListInput) => {
projectId: string;
revision: string;
updating: boolean;
items: {
id: string;
title: string;
treePath: string[];
filePath: string;
fileOrigin?: "external" | "generated" | "project";
supportPluginId: string;
group?: string;
docsOnly: boolean;
variants: {
id: string;
title: string;
}[];
docsAvailable: boolean;
sourceAvailable: boolean;
sourceKind: "file" | "unavailable" | "virtual";
}[];
total: number;
diagnostics: {
filePath?: string;
storyId?: string;
code: string;
message: string;
}[];
diagnosticsTruncated: boolean;
nextCursor: string;
};
};
content: {
getDocs(input: import("../mcp/project/content.js").DocsContentInput): Promise<import("../mcp/protocol/content-schema.js").McpDocsResult>;
getSource(input: import("../mcp/project/content.js").SourceContentInput): Promise<import("../mcp/protocol/content-schema.js").McpSourceResult>;
};
};
close(): void;
};
operations: {
execution: {
readonly available: boolean;
readonly pendingCount: number;
enqueue<T>(task: import("./execution-types.js").ExecutionTask<T>): import("./execution-types.js").ExecutionHandle<T>;
cancelAll: () => Promise<void>;
quarantine(): void;
close(): Promise<void>;
};
snapshot: () => import("@histoire/shared").UiMcpOperationInfo[];
onOperationChange: (listener: (operation: import("@histoire/shared").UiMcpOperationInfo) => void) => () => void;
readonly available: boolean;
hasExecutor(kind: import("../mcp/operations/types.js").McpOperationKind): boolean;
registerExecutor(kind: import("../mcp/operations/types.js").McpOperationKind, executor: import("../mcp/operations/types.js").McpOperationExecutor<{
handle: import("./types.js").ProjectRuntimeHandle;
catalog: {
readonly current: import("./catalog/types.js").CatalogSnapshot;
readonly updating: boolean;
markUpdating(): void;
publish(ctx: import("../context.js").Context, outcomes?: ReadonlyMap<string, import("../collect/outcome.js").StoryCollectionOutcome>): Promise<import("./catalog/types.js").CatalogSnapshot>;
getStory(storyId: string, expectedRevision?: string): {
revision: string;
story: import("./catalog/types.js").CatalogStory;
projectId: string;
};
getTarget(storyId: string, variantId: string, expectedRevision?: string): {
revision: string;
story: import("./catalog/types.js").CatalogStory;
variant: {
id: string;
title: string;
};
projectId: string;
};
list: (input: import("../mcp/project/catalog-pages.js").CatalogListInput) => {
projectId: string;
revision: string;
updating: boolean;
items: {
id: string;
title: string;
treePath: string[];
filePath: string;
fileOrigin?: "external" | "generated" | "project";
supportPluginId: string;
group?: string;
docsOnly: boolean;
variants: {
id: string;
title: string;
}[];
docsAvailable: boolean;
sourceAvailable: boolean;
sourceKind: "file" | "unavailable" | "virtual";
}[];
total: number;
diagnostics: {
filePath?: string;
storyId?: string;
code: string;
message: string;
}[];
diagnosticsTruncated: boolean;
nextCursor: string;
};
};
content: {
getDocs(input: import("../mcp/project/content.js").DocsContentInput): Promise<import("../mcp/protocol/content-schema.js").McpDocsResult>;
getSource(input: import("../mcp/project/content.js").SourceContentInput): Promise<import("../mcp/protocol/content-schema.js").McpSourceResult>;
};
}>): void;
admit(principal: string, kind: import("../mcp/operations/types.js").McpOperationKind, input: import("../mcp/operations/types.js").McpOperationInput): {
operationId: string;
projectId: string;
epoch: string;
revision: string;
kind: "inspect-accessibility" | "inspect-dom" | "inspect-variant" | "runtime-diagnostics" | "screenshot" | "tests";
state: "cancelled" | "cancelling" | "completed" | "failed" | "queued" | "running";
createdAt: string;
startedAt?: string;
finishedAt?: string;
result?: {
storyId: string;
variantId: string;
viewport: {
width: number;
height: number;
};
truncated: boolean;
inspection: "variant";
state: Record<string, import("zod").JSONType>;
propsAvailable: boolean;
components: {
name: string;
index: number;
props: {
name: string;
types?: string[];
required?: boolean;
default?: import("zod").JSONType;
value?: import("zod").JSONType;
values?: import("zod").JSONType[];
}[];
}[];
omittedValues: number;
} | {
storyId: string;
variantId: string;
viewport: {
width: number;
height: number;
};
truncated: boolean;
inspection: "dom";
matched: boolean;
nodes: {
index: number;
parentIndex?: number;
tag: string;
attributes: Record<string, string>;
text: string;
rect: {
x: number;
y: number;
width: number;
height: number;
};
styles: Record<string, string>;
}[];
} | {
storyId: string;
variantId: string;
viewport: {
width: number;
height: number;
};
truncated: boolean;
inspection: "accessibility";
matched: boolean;
snapshot: string;
totalCharacters: number;
} | {
storyId: string;
variantId: string;
viewport: {
width: number;
height: number;
};
truncated: boolean;
inspection: "diagnostics";
previewReady: boolean;
readinessError?: string;
entries: {
kind: "console" | "http-error" | "page-error" | "request-failed";
level?: string;
message: string;
url?: string;
status?: number;
}[];
droppedCount: number;
} | {
storyId: string;
variantId: string;
width: number;
height: number;
mimeType: "image/png";
bytes: number;
sha256: string;
artifactUri: string;
} | {
storyId: string;
variantId?: string;
engine: "built-preview" | "project-vitest";
summary: import("@histoire/protocol").HistoireTestRunSummary;
truncated: boolean;
};
error?: {
code: "ARTIFACT_NOT_FOUND" | "BROWSER_UNAVAILABLE" | "CANCELLED" | "CAPABILITY_UNAVAILABLE" | "COLLECTION_FAILED" | "CURSOR_EXPIRED" | "DEPENDENCY_MISSING" | "DOCS_NOT_FOUND" | "INTERNAL_ERROR" | "INVALID_CURSOR" | "INVALID_SELECTOR" | "OPERATION_NOT_FOUND" | "PATH_OUTSIDE_ROOT" | "PREVIEW_NOT_READY" | "PROJECT_CLOSED" | "PROJECT_RESTARTING" | "PROJECT_STARTING" | "QUEUE_FULL" | "REQUEST_KEY_CONFLICT" | "RESULT_TOO_LARGE" | "SOURCE_UNAVAILABLE" | "STALE_REVISION" | "STORY_AMBIGUOUS" | "STORY_NOT_FOUND" | "TIMEOUT" | "VARIANT_NOT_FOUND";
message: string;
retryable: boolean;
details?: Record<string, import("zod").JSONType>;
};
};
get(principal: string, operationId: string): {
operationId: string;
projectId: string;
epoch: string;
revision: string;
kind: "inspect-accessibility" | "inspect-dom" | "inspect-variant" | "runtime-diagnostics" | "screenshot" | "tests";
state: "cancelled" | "cancelling" | "completed" | "failed" | "queued" | "running";
createdAt: string;
startedAt?: string;
finishedAt?: string;
result?: {
storyId: string;
variantId: string;
viewport: {
width: number;
height: number;
};
truncated: boolean;
inspection: "variant";
state: Record<string, import("zod").JSONType>;
propsAvailable: boolean;
components: {
name: string;
index: number;
props: {
name: string;
types?: string[];
required?: boolean;
default?: import("zod").JSONType;
value?: import("zod").JSONType;
values?: import("zod").JSONType[];
}[];
}[];
omittedValues: number;
} | {
storyId: string;
variantId: string;
viewport: {
width: number;
height: number;
};
truncated: boolean;
inspection: "dom";
matched: boolean;
nodes: {
index: number;
parentIndex?: number;
tag: string;
attributes: Record<string, string>;
text: string;
rect: {
x: number;
y: number;
width: number;
height: number;
};
styles: Record<string, string>;
}[];
} | {
storyId: string;
variantId: string;
viewport: {
width: number;
height: number;
};
truncated: boolean;
inspection: "accessibility";
matched: boolean;
snapshot: string;
totalCharacters: number;
} | {
storyId: string;
variantId: string;
viewport: {
width: number;
height: number;
};
truncated: boolean;
inspection: "diagnostics";
previewReady: boolean;
readinessError?: string;
entries: {
kind: "console" | "http-error" | "page-error" | "request-failed";
level?: string;
message: string;
url?: string;
status?: number;
}[];
droppedCount: number;
} | {
storyId: string;
variantId: string;
width: number;
height: number;
mimeType: "image/png";
bytes: number;
sha256: string;
artifactUri: string;
} | {
storyId: string;
variantId?: string;
engine: "built-preview" | "project-vitest";
summary: import("@histoire/protocol").HistoireTestRunSummary;
truncated: boolean;
};
error?: {
code: "ARTIFACT_NOT_FOUND" | "BROWSER_UNAVAILABLE" | "CANCELLED" | "CAPABILITY_UNAVAILABLE" | "COLLECTION_FAILED" | "CURSOR_EXPIRED" | "DEPENDENCY_MISSING" | "DOCS_NOT_FOUND" | "INTERNAL_ERROR" | "INVALID_CURSOR" | "INVALID_SELECTOR" | "OPERATION_NOT_FOUND" | "PATH_OUTSIDE_ROOT" | "PREVIEW_NOT_READY" | "PROJECT_CLOSED" | "PROJECT_RESTARTING" | "PROJECT_STARTING" | "QUEUE_FULL" | "REQUEST_KEY_CONFLICT" | "RESULT_TOO_LARGE" | "SOURCE_UNAVAILABLE" | "STALE_REVISION" | "STORY_AMBIGUOUS" | "STORY_NOT_FOUND" | "TIMEOUT" | "VARIANT_NOT_FOUND";
message: string;
retryable: boolean;
details?: Record<string, import("zod").JSONType>;
};
};
cancel: (principal: string, operationId: string) => {
operationId: string;
projectId: string;
epoch: string;
revision: string;
kind: "inspect-accessibility" | "inspect-dom" | "inspect-variant" | "runtime-diagnostics" | "screenshot" | "tests";
state: "cancelled" | "cancelling" | "completed" | "failed" | "queued" | "running";
createdAt: string;
startedAt?: string;
finishedAt?: string;
result?: {
storyId: string;
variantId: string;
viewport: {
width: number;
height: number;
};
truncated: boolean;
inspection: "variant";
state: Record<string, import("zod").JSONType>;
propsAvailable: boolean;
components: {
name: string;
index: number;
props: {
name: string;
types?: string[];
required?: boolean;
default?: import("zod").JSONType;
value?: import("zod").JSONType;
values?: import("zod").JSONType[];
}[];
}[];
omittedValues: number;
} | {
storyId: string;
variantId: string;
viewport: {
width: number;
height: number;
};
truncated: boolean;
inspection: "dom";
matched: boolean;
nodes: {
index: number;
parentIndex?: number;
tag: string;
attributes: Record<string, string>;
text: string;
rect: {
x: number;
y: number;
width: number;
height: number;
};
styles: Record<string, string>;
}[];
} | {
storyId: string;
variantId: string;
viewport: {
width: number;
height: number;
};
truncated: boolean;
inspection: "accessibility";
matched: boolean;
snapshot: string;
totalCharacters: number;
} | {
storyId: string;
variantId: string;
viewport: {
width: number;
height: number;
};
truncated: boolean;
inspection: "diagnostics";
previewReady: boolean;
readinessError?: string;
entries: {
kind: "console" | "http-error" | "page-error" | "request-failed";
level?: string;
message: string;
url?: string;
status?: number;
}[];
droppedCount: number;
} | {
storyId: string;
variantId: string;
width: number;
height: number;
mimeType: "image/png";
bytes: number;
sha256: string;
artifactUri: string;
} | {
storyId: string;
variantId?: string;
engine: "built-preview" | "project-vitest";
summary: import("@histoire/protocol").HistoireTestRunSummary;
truncated: boolean;
};
error?: {
code: "ARTIFACT_NOT_FOUND" | "BROWSER_UNAVAILABLE" | "CANCELLED" | "CAPABILITY_UNAVAILABLE" | "COLLECTION_FAILED" | "CURSOR_EXPIRED" | "DEPENDENCY_MISSING" | "DOCS_NOT_FOUND" | "INTERNAL_ERROR" | "INVALID_CURSOR" | "INVALID_SELECTOR" | "OPERATION_NOT_FOUND" | "PATH_OUTSIDE_ROOT" | "PREVIEW_NOT_READY" | "PROJECT_CLOSED" | "PROJECT_RESTARTING" | "PROJECT_STARTING" | "QUEUE_FULL" | "REQUEST_KEY_CONFLICT" | "RESULT_TOO_LARGE" | "SOURCE_UNAVAILABLE" | "STALE_REVISION" | "STORY_AMBIGUOUS" | "STORY_NOT_FOUND" | "TIMEOUT" | "VARIANT_NOT_FOUND";
message: string;
retryable: boolean;
details?: Record<string, import("zod").JSONType>;
};
};
cancelFromUi(operationId: string): void;
readResource(address: import("../mcp/protocol/uris.js").McpResourceAddress, uri: string, principal: string): {
contents: {
uri: string;
mimeType: string;
text: string;
}[];
} | {
contents: {
uri: string;
mimeType: string;
blob: string;
}[];
};
invalidate(epoch?: string): Promise<void>;
close(): Promise<void>;
};
snapshot: () => import("@histoire/shared").UiMcpSnapshot;
onClientChange: (listener: (value: import("@histoire/shared").UiMcpSnapshot) => void) => () => void;
onOperationChange: (listener: (operation: import("@histoire/shared").UiMcpOperationInfo) => void) => () => void;
cancelFromUi: (operationId: string) => void;
reconcile(next: import("../mcp/transport/http-options.js").DevMcpOptions): Promise<void>;
close(): Promise<void>;
};
/** Releases every session-owned adapter, preserving an injected parent lane. */
close(): Promise<void>;
};
//# sourceMappingURL=dev-session.d.ts.map