import { Observable, PathKey, GetAtPath } from '@noya-app/observable'; import { Emitter } from '@noya-app/emitter'; import { EncodedSchema, Asset, Input, OutputTransform, Resource, CreateResourceParametersWithoutAccessibleByFileId, UploadableAsset, DeleteResourceParameters, AssetMode, MediaMap } from '@noya-app/noya-schemas'; import { Cache, hash } from '@noya-app/noya-utils'; import { TaskSnapshot } from '@noya-app/task-runner'; import * as _sinclair_typebox from '@sinclair/typebox'; import { TObject, Static, TSchema } from '@sinclair/typebox'; import { Patch, Draft } from 'mutative'; import * as _noya_app_noya_multiplayer_react from '@noya-app/noya-multiplayer-react'; import { ExtendedPatch as ExtendedPatch$1, AssetUploadProgress as AssetUploadProgress$1, ClientToServerMessage as ClientToServerMessage$1, ExtractRequestBody as ExtractRequestBody$1, ExtractResponseBody as ExtractResponseBody$1 } from '@noya-app/noya-multiplayer-react'; import * as _noya_app_noya_pipeline from '@noya-app/noya-pipeline'; import { PipelineState, RemoteEvaluateParameters, ParsedError, PipelineGraphAPI } from '@noya-app/noya-pipeline'; import { Operation } from 'mutative/dist/interface.js'; import { MenuItem } from '@noya-app/noya-designsystem'; type Secret = { id: string; stableId: string; name: string; }; type SecretManagerOptions = { initialSecrets?: Secret[]; }; declare class SecretManager { rpcManager: RPCManager; constructor(rpcManager: RPCManager, options: SecretManagerOptions); secrets$: Observable; isInitialized$: Observable; fetchSecrets(): Promise; createSecret(id: string | null, name: string, value: string): Promise; deleteSecret(id: string): Promise<{ status: 200; statusText: "OK"; headers: {}; body: _noya_app_noya_multiplayer_react.TypedBody<{ success: true; }>; }>; } type SerializableRequest = { id?: string; url: string; streaming?: boolean; options: { method?: string; headers?: Record; body?: string; }; }; type SerializableResponse = { id?: string; status: number; statusText: string; headers: Record; body: string; }; type TypedBody = string & { __type?: T; }; type RPCRequestPayload = { type: "fetch" | "streamingFetch"; request: SerializableRequest; }; type RPCResponsePayload = { type: "fetch"; response: SerializableResponse; }; type RPCSuccessResponse = { id: string; type: "rpcResponse"; payload: RPCResponsePayload; }; type RPCStreamChunkResponse = { id: string; type: "rpcStreamChunk"; chunk: string; }; type RPCStreamEndResponse = { id: string; type: "rpcStreamEnd"; payload?: RPCResponsePayload; }; type RPCErrorResponse = { id: string; type: "rpcResponse"; error: any; }; type UploadProgress = { loaded: number; total?: number; percent?: number; }; type WorkspaceMemberUser = { id: string; name: string | null; email: string | null; image: string | null; }; type BaseTranscriptionRequest = { fileName?: string; contentType?: string; endpoint?: string; apiKey?: string; }; type TranscriptionRequest = BaseTranscriptionRequest & ({ type: "data"; data: string; } | { type: "assetId"; assetId: string; }); type TranscriptionSegment = { id: number; seek: number; start: number; end: number; text: string; tokens: number[]; temperature: number; avg_logprob: number; compression_ratio: number; no_speech_prob: number; }; type TranscriptionMetadata = { filename?: string; originalSize?: number; originalSizeMB?: string; duration?: number; language?: string; processingTimeSeconds?: number; segmentCount?: number; [key: string]: unknown; }; type TranscriptionResponse = { success: boolean; transcription: string; segments: TranscriptionSegment[]; metadata: TranscriptionMetadata; }; type AIGenerateImage = { type: "data"; data: string; mediaType: string; } | { type: "url"; url: string; }; type AIGenerateRequest = { prompt: string; system?: string; model?: string; schema: Record; encodedSchema?: EncodedSchema; images?: AIGenerateImage[]; }; type AIGenerateResponse = { object: unknown; }; type AIGenerateTextRequest = { prompt: string; system?: string; model?: string; images?: AIGenerateImage[]; }; type AIGenerateTextResponse = { text: string; }; type AIGenerateImageRequest = { prompt: string; model?: string; }; type AIGenerateImageResponse = { base64: string; mediaType: string; }; type ScriptEvaluatorFile = string | { content: string; }; type ScriptEvaluatorRequestBase = { args?: unknown[]; env?: Record; secrets?: Record; includeFileEnv?: boolean; }; type ScriptEvaluatorRequest = ScriptEvaluatorRequestBase & ({ type: "code"; code: string; } | { type: "url"; url: string; cid?: string; } | { type: "files"; files: Record; entryPoint?: string; }); type ScriptEvaluatorResponse = { status: "success"; result: unknown; logs: unknown[][]; } | { status: "error"; error: ParsedError; logs: unknown[][]; }; type ResourcePatchUpdateParameters = { id: string; path?: string; type?: Resource["type"]; assetId?: string; asset?: UploadableAsset; fileId?: string; fileVersionId?: string; resourceId?: string; }; type ResourcePatchRequestBody = { create?: CreateResourceParametersWithoutAccessibleByFileId[]; update?: ResourcePatchUpdateParameters[]; delete?: DeleteResourceParameters[]; }; type GitFileCreateOperation = { path: string; content: string; }; type GitFileRenameOperation = { oldPath: string; newPath: string; }; type GitFileDeleteOperation = { path: string; }; type GitFilePatchRequestBody = { create?: GitFileCreateOperation[]; rename?: GitFileRenameOperation[]; delete?: GitFileDeleteOperation[]; }; type GitInitRepoRequestBody = { initialFiles?: GitFileCreateOperation[]; }; type GitFilePatchResponseBody = { oid: string; files: string[]; ref: string; /** Present when includeContent query param is true */ fileContents?: GitFileInfo[]; }; type GitFileInfo = { path: string; /** Base64-encoded file content */ content: string; }; type GitListFilesResponseBody = { files: string[]; ref: string; oid: string; /** Present when includeContent query param is true */ fileContents?: GitFileInfo[]; }; type RouteDefinition = Record> = { request: TRequest; response: TResponse; searchParams: TSearchParams; }; type Routes = { "GET /api/assets": RouteDefinition<{ url: "/api/assets"; options: { method: "GET"; }; }, { status: 200; statusText: "OK"; headers: {}; body: TypedBody; }>; "POST /api/assets": RouteDefinition<{ url: "/api/assets"; options: { method: "POST"; headers?: { "Content-Type"?: string; }; body: TypedBody; }; }, { status: 200; statusText: "OK"; headers: {}; body: TypedBody; }, { mode?: "immutable" | "mutable"; }>; "PUT /api/assets/:id": RouteDefinition<{ url: `/api/assets/${string}`; options: { method: "PUT"; headers?: { "Content-Type"?: string; }; body: TypedBody; }; }, { status: 200; statusText: "OK"; headers: {}; body: TypedBody; }>; "DELETE /api/assets/:id": RouteDefinition<{ url: `/api/assets/${string}`; options: { method: "DELETE"; }; }, { status: 200; statusText: "OK"; headers: {}; body: TypedBody<{ success: true; }>; }>; "GET /api/secrets": RouteDefinition<{ url: "/api/secrets"; options: { method: "GET"; }; }, { status: 200; statusText: "OK"; headers: {}; body: TypedBody; }>; "POST /api/secrets": RouteDefinition<{ url: "/api/secrets"; options: { method: "POST"; headers: { "Content-Type": "application/json"; }; body: TypedBody<{ name: string; value: string; }>; }; }, { status: 200; statusText: "OK"; headers: {}; body: TypedBody; }>; "DELETE /api/secrets": RouteDefinition<{ url: "/api/secrets"; options: { method: "DELETE"; headers: { "Content-Type": "application/json"; }; body: TypedBody<{ name: string; }>; }; }, { status: 200; statusText: "OK"; headers: {}; body: TypedBody<{ success: true; }>; }>; "PUT /api/file": RouteDefinition<{ url: "/api/file"; options: { method: "PUT"; headers: { "Content-Type": "application/json"; }; body: TypedBody<{ name: string; changeId?: string; }>; }; }, { status: 200; statusText: "OK"; headers: { "Content-Type": "application/json"; }; body: TypedBody<{ name: string; changeId?: string; }>; }>; "GET /api/file/members": RouteDefinition<{ url: "/api/file/members"; options: { method: "GET"; }; }, { status: 200; statusText: "OK"; headers: {}; body: TypedBody; }>; "POST /api/runWorkflow": RouteDefinition<{ url: "/api/runWorkflow"; options: { method: "POST"; }; body: TypedBody<{ pipelineState?: PipelineState; }>; }, { status: 200; statusText: "OK"; headers: {}; body: TypedBody<{ result: any; snapshot: any; }>; }>; "POST /api/transcriptions": RouteDefinition<{ url: "/api/transcriptions"; options: { method: "POST"; headers: { "Content-Type": "application/json"; }; body: TypedBody; }; }, { status: 200; statusText: "OK"; headers: { "Content-Type": "application/json"; }; body: TypedBody; }>; "POST /api/evaluate": RouteDefinition<{ url: "/api/evaluate"; options: { method: "POST"; body: TypedBody; }; }, { status: 200; statusText: "OK"; headers: { "Content-Type": "application/json"; }; body: TypedBody<{ result: any; }>; }>; "POST /api/scripts/evaluate": RouteDefinition<{ url: "/api/scripts/evaluate"; options: { method: "POST"; headers: { "Content-Type": "application/json"; }; body: TypedBody; }; }, { status: 200; statusText: "OK"; headers: { "Content-Type": "application/json"; }; body: TypedBody; }>; "POST /api/ai": RouteDefinition<{ url: "/api/ai"; streaming: true; options: { method: "POST"; headers?: Record; body?: string; }; }, { status: 200; statusText: "OK"; headers: {}; body: string; }>; "POST /api/ai/generate": RouteDefinition<{ url: "/api/ai/generate"; options: { method: "POST"; headers: { "Content-Type": "application/json"; }; body: TypedBody; }; }, { status: 200; statusText: "OK"; headers: { "Content-Type": "application/json"; }; body: TypedBody; }>; "POST /api/ai/generate/text": RouteDefinition<{ url: "/api/ai/generate/text"; options: { method: "POST"; headers: { "Content-Type": "application/json"; }; body: TypedBody; }; }, { status: 200; statusText: "OK"; headers: { "Content-Type": "application/json"; }; body: TypedBody; }>; "POST /api/ai/generate/image": RouteDefinition<{ url: "/api/ai/generate/image"; options: { method: "POST"; headers: { "Content-Type": "application/json"; }; body: TypedBody; }; }, { status: 200; statusText: "OK"; headers: { "Content-Type": "application/json"; }; body: TypedBody; }>; "GET /api/inputs": RouteDefinition<{ url: "/api/inputs"; options: { method: "GET"; }; }, { status: 200; statusText: "OK"; headers: {}; body: TypedBody; }>; "GET /api/outputTransforms": RouteDefinition<{ url: "/api/outputTransforms"; options: { method: "GET"; }; }, { status: 200; statusText: "OK"; headers: {}; body: TypedBody; }>; "POST /api/inputs": RouteDefinition<{ url: "/api/inputs"; options: { method: "POST"; headers: { "Content-Type": "application/json"; }; body: TypedBody & { id?: string; }>; }; }, { status: 200; statusText: "OK"; headers: {}; body: TypedBody; }>; "PATCH /api/inputs": RouteDefinition<{ url: "/api/inputs"; options: { method: "PATCH"; headers: { "Content-Type": "application/json"; }; body: TypedBody; }; }, { status: 200; statusText: "OK"; headers: {}; body: TypedBody; }>; "POST /api/outputTransforms": RouteDefinition<{ url: "/api/outputTransforms"; options: { method: "POST"; headers: { "Content-Type": "application/json"; }; body: TypedBody & { id?: string; }>; }; }, { status: 200; statusText: "OK"; headers: {}; body: TypedBody; }>; "DELETE /api/inputs": RouteDefinition<{ url: `/api/inputs`; options: { method: "DELETE"; headers: { "Content-Type": "application/json"; }; body: TypedBody<{ id: string; }>; }; }, { status: 200; statusText: "OK"; headers: {}; body: TypedBody<{ success: true; }>; }>; "DELETE /api/outputTransforms": RouteDefinition<{ url: `/api/outputTransforms`; options: { method: "DELETE"; headers: { "Content-Type": "application/json"; }; body: TypedBody<{ id: string; }>; }; }, { status: 200; statusText: "OK"; headers: {}; body: TypedBody<{ success: true; }>; }>; "PATCH /api/outputTransforms": RouteDefinition<{ url: "/api/outputTransforms"; options: { method: "PATCH"; headers: { "Content-Type": "application/json"; }; body: TypedBody; }; }, { status: 200; statusText: "OK"; headers: {}; body: TypedBody; }>; "GET /api/resources": RouteDefinition<{ url: "/api/resources"; options: { method: "GET"; }; }, { status: 200; statusText: "OK"; headers: {}; body: TypedBody; }>; "PATCH /api/resources": RouteDefinition<{ url: "/api/resources"; options: { method: "PATCH"; headers: { "Content-Type": "application/json"; }; body: TypedBody; }; }, { status: 200; statusText: "OK"; headers: {}; body: TypedBody<{ created: Resource[]; updated: Resource[]; deleted: Resource[]; }>; }>; "POST /api/snapshots/restore": RouteDefinition<{ url: "/api/snapshots/restore"; options: { method: "POST"; headers: { "Content-Type": "application/json"; }; body: TypedBody<{ fileId: string; fileVersionId: string; }>; }; }, { status: 200; statusText: "OK"; headers: {}; body: TypedBody; }>; "POST /api/git/repos": RouteDefinition<{ url: "/api/git/repos"; options: { method: "POST"; headers: { "Content-Type": "application/json"; }; body?: TypedBody; }; }, { status: 200; statusText: "OK"; headers: { "Content-Type": "application/json"; }; body: TypedBody<{ id: string; }>; }>; "GET /api/git/repos/:id/files": RouteDefinition<{ url: `/api/git/repos/${string}/files`; options: { method: "GET"; }; }, { status: 200; statusText: "OK"; headers: { "Content-Type": "application/json"; }; body: TypedBody; }, { ref?: string; includeContent?: string; }>; "GET /api/git/repos/:id/branches": RouteDefinition<{ url: `/api/git/repos/${string}/branches`; options: { method: "GET"; }; }, { status: 200; statusText: "OK"; headers: { "Content-Type": "application/json"; }; body: TypedBody<{ branches: Array<{ name: string; oid: string; }>; }>; }>; "PATCH /api/git/repos/:id/files": RouteDefinition<{ url: `/api/git/repos/${string}/files`; options: { method: "PATCH"; headers: { "Content-Type": "application/json"; }; body: TypedBody; }; }, { status: 200; statusText: "OK"; headers: { "Content-Type": "application/json"; }; body: TypedBody; }, { ref?: string; includeContent?: string; }>; "GET /api/sandbox/files": RouteDefinition<{ url: "/api/sandbox/files"; options: { method: "GET"; }; }, { status: 200; statusText: "OK"; headers: { "Content-Type": "application/json"; }; body: TypedBody<{ files: Array<{ name: string; path: string; type: "file" | "directory"; }>; error?: string; }>; }>; "POST /api/sandbox/preview": RouteDefinition<{ url: "/api/sandbox/preview"; options: { method: "POST"; headers: { "Content-Type": "application/json"; }; }; }, { status: 200; statusText: "OK"; headers: { "Content-Type": "application/json"; }; body: TypedBody<{ previewUrl?: string; error?: string; }>; }>; "POST /api/sandbox/exec": RouteDefinition<{ url: "/api/sandbox/exec"; options: { method: "POST"; headers: { "Content-Type": "application/json"; }; body: TypedBody<{ command: string; cwd?: string; }>; }; }, { status: 200; statusText: "OK"; headers: { "Content-Type": "application/json"; }; body: TypedBody<{ success: boolean; stdout: string; stderr: string; exitCode: number; }>; }>; "GET /api/sandbox/build-files": RouteDefinition<{ url: "/api/sandbox/build-files"; options: { method: "GET"; }; }, { status: 200; statusText: "OK"; headers: { "Content-Type": "application/json"; }; body: TypedBody<{ success: boolean; zip?: string; error?: string; }>; }>; "POST /api/sandbox/checkpoint": RouteDefinition<{ url: "/api/sandbox/checkpoint"; options: { method: "POST"; headers: { "Content-Type": "application/json"; }; body?: TypedBody<{ message?: string; }>; }; }, { status: 200; statusText: "OK"; headers: { "Content-Type": "application/json"; }; body: TypedBody<{ success: boolean; error?: string; }>; }>; }; type RouteKey$1 = keyof Routes; type ExtractRequestBody = Routes[K]["request"]["options"] extends { body: TypedBody; } ? T : Routes[K]["request"]["options"] extends { body?: TypedBody; } ? T | undefined : string; type ExtractResponseBody = Routes[K]["response"]["body"] extends TypedBody ? T : never; type ExtractSearchParams = Routes[K]["searchParams"]; type RPCStatus = "pending" | "resolved" | "rejected" | "streaming"; type RPCResponseMessage = { id: string; } & ({ type: "end"; response: SerializableResponse; } | { type: "chunk"; chunk: string; } | { type: "error"; error: any; }); type RequestOptions = Record> = { headers?: Record; body?: string; searchParams?: Partial; onUploadProgress?: (progress: UploadProgress) => void; }; type StreamingHandlers = { onStreamChunk?: (chunk: string) => void; onStreamEnd?: () => Promise; }; type RouteKey = keyof Routes; declare class RPCManager extends Emitter<[SerializableRequest]> { debug: boolean; constructor(options?: { isConnected?: boolean; debug?: boolean; }); isConnected$: Observable; setIsConnected(connected: boolean): void; requests: Record void; reject: (reason: any) => void; onStreamChunk?: (chunk: string) => void; onStreamEnd?: () => Promise; onUploadProgress?: (progress: UploadProgress) => void; }>; request: (request: Routes[K]["request"], options?: RequestOptions & StreamingHandlers & { streaming?: boolean; }) => Promise; requestRoute: (route: K, { body, headers, searchParams, onUploadProgress }?: RequestOptions>) => Promise; requestStreamingRoute: (route: K, { body, headers, onStreamChunk, onStreamEnd, }: RequestOptions & StreamingHandlers) => Promise; handleMessage: (message: RPCResponseMessage) => void; getResponseBody: ; headers: Record; }>(response: R) => NonNullable; } /** Helper type that preserves all properties and their requirements except for id */ type CreateParams = Omit | (Partial & { id?: string; stableId?: string; }); declare class IOManager { rpcManager: RPCManager; constructor(rpcManager: RPCManager); inputs$: Observable<({ id: string; name: string; stableId: string; kind: "file"; required: boolean; toolId: string | null; description: string | null; } | { id: string; name: string; stableId: string; schema: { default?: string | undefined; type: "string"; _kind: "String"; } | { default?: number | undefined; minimum?: number | undefined; maximum?: number | undefined; type: "number"; _kind: "Number"; } | { default?: boolean | undefined; type: "boolean"; _kind: "Boolean"; } | { type: "null"; _kind: "Null"; } | { type: "array"; _kind: "Array"; items: { default?: string | undefined; type: "string"; _kind: "String"; } | { default?: number | undefined; minimum?: number | undefined; maximum?: number | undefined; type: "number"; _kind: "Number"; } | { default?: boolean | undefined; type: "boolean"; _kind: "Boolean"; } | { type: "null"; _kind: "Null"; } | any | { required?: string[] | undefined; type: "object"; properties: { [x: string]: { default?: string | undefined; type: "string"; _kind: "String"; } | { default?: number | undefined; minimum?: number | undefined; maximum?: number | undefined; type: "number"; _kind: "Number"; } | { default?: boolean | undefined; type: "boolean"; _kind: "Boolean"; } | { type: "null"; _kind: "Null"; } | any | any; }; _kind: "Object"; }; } | { required?: string[] | undefined; type: "object"; properties: { [x: string]: { default?: string | undefined; type: "string"; _kind: "String"; } | { default?: number | undefined; minimum?: number | undefined; maximum?: number | undefined; type: "number"; _kind: "Number"; } | { default?: boolean | undefined; type: "boolean"; _kind: "Boolean"; } | { type: "null"; _kind: "Null"; } | any | any; }; _kind: "Object"; } | null; kind: "data"; required: boolean; description: string | null; } | { authProvider?: "github" | "figma" | null | undefined; authScope?: string | null | undefined; id: string; name: string; stableId: string; kind: "secret"; required: boolean; description: string | null; })[]>; outputTransforms$: Observable<({ value: string; id: string; stableId: string; kind: "script"; location: "url" | "state"; order: number; } | { value: string; id: string; stableId: string; kind: "jsonPointer"; order: number; })[]>; inputsInitialized$: Observable; outputTransformsInitialized$: Observable; isInitialized$: Observable; fetchInputs(): Promise; fetchOutputTransforms(): Promise; createInput(input: CreateParams): Promise; createOutputTransform(outputTransform: CreateParams): Promise; deleteInput(id: string): Promise<{ success: true; }>; deleteOutputTransform(id: string): Promise<{ success: true; }>; applyInputPatches(patches: ExtendedPatch$1[]): Promise; applyOutputTransformPatches(patches: ExtendedPatch$1[]): Promise; } type ServerScriptLogLevel = "log" | "warn" | "error"; type ServerScriptLogEntry = { id: string; scriptId: string; level: ServerScriptLogLevel; values: unknown[]; timestamp: number; origin?: string; target?: string; mode?: string; }; type LogManagerOptions = { maxEntries?: number; }; /** * Stores server script log entries emitted over the multiplayer channel. */ declare class LogManager { private options; logs$: Observable; constructor(options?: LogManagerOptions); append(entry: ServerScriptLogEntry): void; appendMany(entries: ServerScriptLogEntry[]): void; clear(): void; private truncate; } declare function applyPatchToString(str: string, patch: SimplePatch): string; declare function apply(obj: S, patches: SimplePatch[]): any; type SimplePatch = Patch & { length?: number; }; type SimplePatchWithStringPath = Patch<{ pathAsArray: false; }>; type ExtendedPatch = { op: (typeof Operation)[keyof typeof Operation]; value?: any; path: ExtendedPathKey[]; from?: ExtendedPathKey[]; length?: number; }; type ExtendedPathKey = string | number | { id: string | number; }; declare function extractItemId(item: unknown): string | number | undefined; declare function toExtendedPathKey(obj: any, path: (string | number)[], type?: "insert"): ExtendedPathKey[]; declare function toSimplePath(obj: any, extendedPath: ExtendedPathKey[]): (string | number)[]; declare function toExtendedPatch(obj: any, patch: SimplePatch): ExtendedPatch; declare function toSimplePatch(obj: any, patch: ExtendedPatch): SimplePatch; declare function applyExtendedPatch(obj: S, patches: ExtendedPatch[]): S; declare function toExtendedPatches(obj: S, patches: SimplePatch[]): ExtendedPatch[]; declare function createExtended(obj: S, mutator: (state: Draft) => void): readonly [S, ExtendedPatch[], ExtendedPatch[]]; type SandboxPhase = "idle" | "preparing" | "uploading" | "installing" | "starting" | "running" | "error"; type SandboxState = { status: SandboxPhase; sandboxId?: string; previewUrl?: string; devProcessId?: string; port?: number; installLogs: string; devLogs: string; lastUpdated: string; error?: string; }; declare const createInitialSandboxState: () => SandboxState; type ExecResult = { success: boolean; stdout: string; stderr: string; exitCode: number; }; declare class SandboxManager { private rpcManager; state$: Observable; constructor(rpcManager: RPCManager); private setState; setFromServer: (next: SandboxState) => void; exec(command: string, cwd?: string): Promise; listFiles(): Promise<{ files: Array<{ name: string; path: string; type: "file" | "directory"; }>; }>; exposePreview(): Promise<{ previewUrl?: string; error?: string; }>; getBuildFilesZip(): Promise<{ success: boolean; zip?: string; error?: string; }>; } type AssetManagerOptions = { assetStore?: IAssetStore; initialAssets?: Asset[]; }; type AssetUploadProgress = UploadProgress & { id: string; name?: string; contentType?: string; }; /** * AssetManager is an abstraction for managing assets. * It can be backed by IndexedDB, or a remote asset server. */ declare class AssetManager { isInitialized$: Observable; assets$: Observable<{ contentType?: string | undefined; mode?: "immutable" | "mutable" | undefined; version?: number | undefined; id: string; createdAt: string; stableId: string; url: string; size: number; width: number | null; height: number | null; userId: string | null; }[]>; uploads$: Observable>; _assetStore: IAssetStore; get assetStore(): IAssetStore; set assetStore(value: IAssetStore); constructor(options?: AssetManagerOptions); _toNoyaAsset: (asset: Asset) => NoyaAsset; /** * Handles external updates to the asset list * * Preserves signed urls for unchanged assets to improve browser caching. */ set: (assets: Asset[]) => void; fetch: () => Promise; _withUploadProgress: (name: string | undefined, fn: (onUploadProgress: CreateAssetOptions["onUploadProgress"]) => Promise) => Promise; create: (options: CreateAssetOptions | Uint8Array | File | Blob) => Promise; delete: (id: string) => Promise; update: (id: string, options: UpdateAssetOptions | Uint8Array | File | Blob) => Promise; read: (idOrStableId: string) => NoyaAsset | undefined; getAsset: (idOrStableId: string) => NoyaAsset | undefined; /** * Internal: get the server id for an asset when given a stableId or id. */ _getServerAssetId: (idOrStableId: string) => string | undefined; getRealAssetId: (idOrStableId: string) => string | undefined; } type StoreAsset = { id: string; stableId: string; data: Uint8Array; createdAt: string; size: number; contentType?: string; width: number | null; height: number | null; userId: string | null; mode?: AssetMode; version?: number; }; type CreateAssetOptions = { data: Uint8Array; contentType?: string; stableId?: string; mode?: AssetMode; onUploadProgress?: (progress: { loaded: number; total?: number; percent?: number; }) => void; }; type UpdateAssetOptions = { data: Uint8Array; contentType?: string; onUploadProgress?: (progress: { loaded: number; total?: number; percent?: number; }) => void; }; interface IAssetStore { read: (id: string) => Promise; list: () => Promise; create: (options: CreateAssetOptions) => Promise; update?: (id: string, options: UpdateAssetOptions) => Promise; delete: (id: string) => Promise; _listWithBytes?: () => Promise; } type NoyaAsset = Omit; type AssetManagerLocalOptions = { randomId?: () => string; databaseName?: string; indexedDB?: typeof globalThis.indexedDB; }; /** * AssetManagerLocal is a local asset manager that uses IndexedDB to store assets. */ declare class AssetStoreIndexedDB implements IAssetStore { databaseName: string; randomId: () => string; db: Promise; constructor(options?: AssetManagerLocalOptions); _initialize({ indexedDB, }?: { indexedDB?: typeof globalThis.indexedDB; } & Omit): Promise; read: (id: string) => Promise; _readWithBytes: (id: string) => Promise; list: () => Promise; _listWithBytes: () => Promise; create: (asset: CreateAssetOptions) => Promise; update: (id: string, options: UpdateAssetOptions) => Promise; delete: (id: string) => Promise; _list: (db: IDBDatabase) => Promise; _urlCache: Map; _getUrl: (id: string) => string; _createAssetUrl(asset: StoreAsset): void; _populateUrlCache(db: IDBDatabase): Promise; } type AssetStoreMemoryOptions = { randomId?: () => string; initialAssets?: StoreAsset[]; }; declare class AssetStoreMemory implements IAssetStore { assets: StoreAsset[]; randomId: () => string; constructor(options?: AssetStoreMemoryOptions); read: (id: string) => Promise; list: () => Promise; _listWithBytes: () => Promise; create: (asset: CreateAssetOptions) => Promise; update: (id: string, options: UpdateAssetOptions) => Promise; delete: (id: string) => Promise; _urlCache: Map; _getUrl: (id: string) => string; _createAssetUrl(asset: StoreAsset): void; } declare class AssetStoreRemote implements IAssetStore { private rpcManager; constructor(rpcManager: RPCManager); read: (id: string) => Promise<{ contentType?: string | undefined; mode?: "immutable" | "mutable" | undefined; version?: number | undefined; id: string; createdAt: string; stableId: string; url: string; size: number; width: number | null; height: number | null; userId: string | null; } | null>; list: () => Promise<{ contentType?: string | undefined; mode?: "immutable" | "mutable" | undefined; version?: number | undefined; id: string; createdAt: string; stableId: string; url: string; size: number; width: number | null; height: number | null; userId: string | null; }[]>; create: (options: CreateAssetOptions) => Promise<{ contentType?: string | undefined; mode?: "immutable" | "mutable" | undefined; version?: number | undefined; id: string; createdAt: string; stableId: string; url: string; size: number; width: number | null; height: number | null; userId: string | null; }>; update: (id: string, options: UpdateAssetOptions) => Promise<{ contentType?: string | undefined; mode?: "immutable" | "mutable" | undefined; version?: number | undefined; id: string; createdAt: string; stableId: string; url: string; size: number; width: number | null; height: number | null; userId: string | null; }>; delete: (id: string) => Promise; } type AIToolDefinition = { functionName: string; description: string; parameters: Record; onCall: (parameters: Record) => Promise; }; type CallableAIToolsMap = Record; }>; type AIToolInvocation = { id: string; name: string; parameters: Record; }; type AIImageInput = Blob | { data: Uint8Array; mediaType: string; } | { url: string | URL; }; type AIGenerateObjectOptions = { prompt: string; schema: Schema; system?: string; images?: AIImageInput[]; model?: string; }; type AIGenerateTextOptions = { prompt: string; system?: string; images?: AIImageInput[]; model?: string; }; type AIGenerateImageOptions = { prompt: string; model?: string; }; type AIGeneratedImage = { data: Uint8Array; mediaType: string; }; declare class AIManager { rpcManager: RPCManager; invocationEmitter: Emitter<[AIToolInvocation]>; responseEmitter: Emitter<[AIToolInvocation, string | undefined]>; tools$: Observable; systemMessage$: Observable; callableTools$: Observable; configuration$: Observable<{ tools: CallableAIToolsMap; systemMessage: string | undefined; }>; get callableTools(): CallableAIToolsMap; constructor(rpcManager: RPCManager); private createFetch; fetch: typeof globalThis.fetch; registerTool(tool: AIToolDefinition): () => void; unregisterTool(name: string): void; callTool(toolInvocation: AIToolInvocation): Promise | undefined; generateObject({ prompt, schema, system, images, model, }: AIGenerateObjectOptions): Promise>; generateText({ prompt, system, images, model, }: AIGenerateTextOptions): Promise; generateImage({ prompt, model, }: AIGenerateImageOptions): Promise; } declare class UserActivityDetector { onActivity?: (() => void) | undefined; constructor(onActivity?: (() => void) | undefined); private _activityHandler; addListeners(): void; removeListeners(): void; setOnActivity(callback?: () => void): void; } type ReconnectingWebSocketState = "CONNECTING" | "OPEN" | "CLOSING" | "CLOSED" | "RECONNECTING" | "MAX_ATTEMPTS_EXCEEDED" | "SHUTDOWN"; type ConnectionOptions = { reconnectInterval?: number; maxReconnectInterval?: number; reconnectDecay?: number; timeoutInterval?: number; maxReconnectAttempts?: number; }; type ReconnectingWebSocketOptions = ConnectionOptions & { onopen?: (event: Event) => void; onmessage?: (event: MessageEvent) => void; onclose?: (event: CloseEvent) => void; onerror?: (event: Event) => void; activityDetector?: UserActivityDetector; debug?: boolean; }; declare class ReconnectingWebSocket extends Emitter<[ ReconnectingWebSocketState ]> { private websocket; private timeoutHandle; private reconnectTimeoutHandle; state: ReconnectingWebSocketState; private attempt; private options; private url; private protocols?; constructor(options?: ReconnectingWebSocketOptions); private transitionTo; connect(url?: string, protocols?: string | string[] | undefined): void; private onOpen; private onClosing; private onClosed; private onReconnecting; private onMaxAttemptsExceeded; private onShutdown; private reconnect; private resetAndReconnect; send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void; close(): void; shutdown(): void; } type ConnectionEvent = { type: "stateChange"; state: ReconnectingWebSocketState; } | { type: "send"; message: ClientToServerMessage; } | { type: "receive"; message: ServerToClientMessage; } | { type: "error"; error: MultiplayerStateManagerError; }; declare class ConnectionEventManager { options: { maxEvents?: number; }; constructor(options?: { maxEvents?: number; }); events$: Observable[]>; addEvent(event: ConnectionEvent): void; getEvents(): ConnectionEvent[]; } type EvalRequest = { id: string; code: string; }; type EvalResponse = { id: string; type: "error"; error: string; } | { id: string; type: "result"; result: string; }; type SafeEval = (code: string) => unknown; declare class EvalManager { constructor(options: { safeEval?: SafeEval; }); safeEval?: SafeEval; requestEmitter: Emitter<[EvalRequest]>; responseEmitter: Emitter<[EvalResponse]>; _evalRequests: Map>; evaluate(code: string): Promise; } type FilePropertyManagerOptions = { initialName?: string; }; /** * Manages synchronization of the file name between the local client and * the multiplayer durable object. */ declare class FilePropertyManager { private rpcManager; name$: Observable; private pendingChanges$; optimisticValue$: Observable; isInitialized$: Observable; isUpdating$: Observable; constructor(rpcManager: RPCManager, options?: FilePropertyManagerOptions); setName(name: string): void; applyServerUpdate({ name, changeId }: { name: string; changeId?: string; }): void; /** * Optimistically update the file name and persist the change through the * durable object. */ updateName: (name: string) => Promise; acknowledgeNameChange(changeId: string): void; private removePendingChange; } declare class MenuManager extends Emitter<[T]> { leftMenuItems$: Observable[]>; rightMenuItems$: Observable[]>; allMenuItems$: Observable[]>; getLeftMenuItems(): MenuItem[]; getRightMenuItems(): MenuItem[]; getAllMenuItems(): MenuItem[]; setLeftMenuItems(items: MenuItem[]): void; setRightMenuItems(items: MenuItem[]): void; showCommandPaletteEmitter: Emitter<[boolean]>; } type TaskArtifact = { name: string; size: number; url: string; }; type TaskMetadata = { artifacts: TaskArtifact[]; }; declare class PipelineManager { rpcManager: RPCManager; constructor(rpcManager: RPCManager); status$: Observable; tasks$: Observable[]>; result$: Observable; run(parameters: RemoteEvaluateParameters): Promise; runScript(scriptUrl: string, parameters: Pick): Promise; runScriptOnFileState(scriptUrl: string, state: unknown): Promise; runPipeline(pipelineState?: PipelineState): Promise<{ result: any; snapshot: any; }>; getPipelineGraphAPI(options: { getFileVersionData: PipelineGraphAPI["getFileVersionData"]; getFileVersionInputs: PipelineGraphAPI["getFileVersionInputs"]; getFileVersionTransforms: PipelineGraphAPI["getFileVersionTransforms"]; getFileVersionIds: PipelineGraphAPI["getFileVersionIds"]; getFileSecret: PipelineGraphAPI["getFileSecret"]; getFileVersionAssets: PipelineGraphAPI["getFileVersionAssets"]; getFileAssets: PipelineGraphAPI["getFileAssets"]; createFileVersion: PipelineGraphAPI["createFileVersion"]; } & ({ executionEnvironment: "local"; } | { executionEnvironment: "remote"; baseUrl: string; })): PipelineGraphAPI; runPipelineLocally(pipelineState: PipelineState, options: Parameters[0]): Promise<{ result: _noya_app_noya_pipeline.TaskResult; snapshot: TaskSnapshot<_noya_app_noya_pipeline.TaskMetadata>[]; error?: undefined; } | { error: unknown; snapshot: TaskSnapshot<_noya_app_noya_pipeline.TaskMetadata>[]; result?: undefined; }>; } type PublishCallback = () => Promise; declare class PublishingManager { enablePublishing$: Observable; setPublishingEnabled(enabled: boolean): void; getFilesToPublish?: PublishCallback; } type GitFileEditServerMessage = Extract, { type: "gitFileEdit.object"; }> | Extract, { type: "gitFileEdit.acceptPatch"; }> | Extract, { type: "gitFileEdit.rejectPatch"; }>; type GitFileEditHandle = { repoId: string; filePath: string; ref: string; content$: Observable; isInitialized$: Observable; sendPatches: (patches: ExtendedPatch[], metadata?: { name?: string; }) => void; /** Set the content, automatically computing and sending patches from the current state */ setState: (newContent: string, metadata?: { name?: string; }) => void; close: () => void; }; declare class GitFileEditSession { options: { repoId: string; filePath: string; ref: string; sendMessage?: (message: ClientToServerMessage) => void; onClose?: () => void; }; private multiplayer; private unsubscribeMultiplayerMessages; private isOpen; constructor(options: { repoId: string; filePath: string; ref: string; sendMessage?: (message: ClientToServerMessage) => void; onClose?: () => void; }); getHandle(): GitFileEditHandle; open(): void; close(): void; private sendPatches; private setState; handleServerMessage(message: GitFileEditServerMessage): void; private flushOutgoingMessages; private translateOutgoingMessage; private translateIncomingMessage; private ensureMessageSubscription; } type GitFileCommittedMessage = Extract, { type: "gitFileEdit.committed"; }>; type GitRepo = NoyaAsset; type BranchInfo = { name: string; oid: string; }; type RepoFilesFetchState = "idle" | "loading" | "refreshing"; type RepoFilesState = { fetchState: RepoFilesFetchState; files: string[]; ref: string; oid: string; branches: BranchInfo[]; error?: string; /** Present when files were fetched with includeContent=true */ fileContents?: GitFileInfo[]; /** Whether content was included in the last fetch (used for background refresh) */ includeContent?: boolean; }; type GitManagerOptions = { sendMessage?: (message: ClientToServerMessage) => void; subscribeConnectionEvents?: (handler: (event: ConnectionEvent) => void) => () => void; includeContent?: boolean; }; declare class GitManager { rpcManager: RPCManager; assetManager: AssetManager; repos$: Observable; isInitialized$: Observable; repoFiles$: Observable>; includeContent: boolean; constructor(rpcManager: RPCManager, assetManager: AssetManager, options?: GitManagerOptions); getRepoState$(repoId: string): Observable; /** * Fetch files and branches for a specific repo at an optional ref. * Uses the instance's includeContent setting to determine whether to fetch file contents. */ fetchRepoFiles(repoId: string, ref?: string): Promise; /** * Refresh files for a repo in the background. * Sets fetchState to "refreshing" so the UI can show a subtle indicator * without replacing the file list with a loading spinner. */ refreshRepoFiles(repoId: string, ref?: string): Promise; /** * Initialize a new git repo by creating a mutable asset with git bundle content type. * Optionally accepts initial files to populate the repo. */ initRepo(options?: GitInitRepoRequestBody): Promise; /** * List all files in a git repo at an optional ref. * The repoId can be either the asset id or stableId. * Uses the instance's includeContent setting to determine whether to fetch file contents. */ listFiles(repoId: string, ref?: string): Promise; /** * List all branches in a git repo. * The repoId can be either the asset id or stableId. */ listBranches(repoId: string): Promise; /** * Patch files in a git repo (create, rename, delete). * Creates a single commit with all the requested operations. * Uses the instance's includeContent setting to determine whether to include file contents in response. */ patchFiles(repoId: string, patch: GitFilePatchRequestBody, ref?: string): Promise; _sendMessage?: (message: ClientToServerMessage) => void; _unsubscribeConnectionEvents?: () => void; _editSessions: Map; _sessionSubscriptions: Map void>; _autoFetchedRepos: Set; _repoStateCache: Map>; private _makeSessionKey; _handleConnectionEvent: (event: ConnectionEvent) => void; openEditingHandle(repoId: string, filePath: string, ref: string): GitFileEditHandle; /** * Optimistically update a file's content in the repoFiles state. * This is called when a file edit session receives content updates. */ private _updateFileContent; } type ResourceEditServerMessage = Extract, { type: "resourceEdit.object"; }> | Extract, { type: "resourceEdit.acceptPatch"; }> | Extract, { type: "resourceEdit.rejectPatch"; }>; type ResourceEditHandle = { resourceId: string; content$: Observable; isInitialized$: Observable; sendPatches: (patches: ExtendedPatch[], metadata?: { name?: string; }) => void; close: () => void; }; declare class ResourceEditSession { options: { resourceId: string; sendMessage?: (message: ClientToServerMessage) => void; onClose?: () => void; }; private multiplayer; private unsubscribeMultiplayerMessages; private isOpen; constructor(options: { resourceId: string; sendMessage?: (message: ClientToServerMessage) => void; onClose?: () => void; }); getHandle(): ResourceEditHandle; open(): void; close(): void; private sendPatches; handleServerMessage(message: ResourceEditServerMessage): void; private flushOutgoingMessages; private translateOutgoingMessage; private translateIncomingMessage; private ensureMessageSubscription; } type ResourceManagerOptions = { initialResources?: Resource[]; sendMessage?: (message: ClientToServerMessage$1) => void; subscribeConnectionEvents?: (handler: (event: ConnectionEvent) => void) => () => void; resolveAssetId?: (idOrStableId: string) => string; }; declare class ResourceManager { rpcManager: RPCManager; isInitialized$: Observable; resources$: Observable<({ url?: string | undefined; accessibleByFile?: { id: string; name: string; toolId: string; } | undefined; path: string; id: string; type: "asset"; createdAt: string; stableId: string; assetId: string; updatedAt: string; accessibleByFileId: string | null; accessibleByFileVersionId: string | null; } | { url?: string | undefined; accessibleByFile?: { id: string; name: string; toolId: string; } | undefined; path: string; id: string; type: "file"; createdAt: string; fileId: string; stableId: string; updatedAt: string; accessibleByFileId: string | null; accessibleByFileVersionId: string | null; } | { url?: string | undefined; accessibleByFile?: { id: string; name: string; toolId: string; } | undefined; path: string; id: string; type: "directory"; createdAt: string; stableId: string; updatedAt: string; accessibleByFileId: string | null; accessibleByFileVersionId: string | null; } | { url?: string | undefined; accessibleByFile?: { id: string; name: string; toolId: string; } | undefined; path: string; id: string; type: "resource"; createdAt: string; fileId: string; resourceId: string; stableId: string; updatedAt: string; accessibleByFileId: string | null; accessibleByFileVersionId: string | null; })[]>; patches$: Observable<{ id: string; patches: ExtendedPatch$1[]; }[]>; optimisticResources$: Observable<({ url?: string | undefined; accessibleByFile?: { id: string; name: string; toolId: string; } | undefined; path: string; id: string; type: "asset"; createdAt: string; stableId: string; assetId: string; updatedAt: string; accessibleByFileId: string | null; accessibleByFileVersionId: string | null; } | { url?: string | undefined; accessibleByFile?: { id: string; name: string; toolId: string; } | undefined; path: string; id: string; type: "file"; createdAt: string; fileId: string; stableId: string; updatedAt: string; accessibleByFileId: string | null; accessibleByFileVersionId: string | null; } | { url?: string | undefined; accessibleByFile?: { id: string; name: string; toolId: string; } | undefined; path: string; id: string; type: "directory"; createdAt: string; stableId: string; updatedAt: string; accessibleByFileId: string | null; accessibleByFileVersionId: string | null; } | { url?: string | undefined; accessibleByFile?: { id: string; name: string; toolId: string; } | undefined; path: string; id: string; type: "resource"; createdAt: string; fileId: string; resourceId: string; stableId: string; updatedAt: string; accessibleByFileId: string | null; accessibleByFileVersionId: string | null; })[]>; uploads$: Observable>; constructor(rpcManager: RPCManager, options?: ResourceManagerOptions); setResources(resources: Resource[]): void; createResource(parameters: Result): Promise; _withPatch(patches: ExtendedPatch$1[], callback: () => Promise): Promise; deleteResource(parameters: Result): Promise; patchResources({ create, update, delete: deleteParameters, }: ExtractRequestBody$1<"PATCH /api/resources">): Promise>; updateResource({ id, path, assetId, asset, type, fileId, fileVersionId, resourceId, }: { id: string; path?: string; assetId?: string; asset?: UploadableAsset; type?: Resource["type"]; fileId?: string; fileVersionId?: string; resourceId?: string; }): Promise<{ url?: string | undefined; accessibleByFile?: { id: string; name: string; toolId: string; } | undefined; path: string; id: string; type: "asset"; createdAt: string; stableId: string; assetId: string; updatedAt: string; accessibleByFileId: string | null; accessibleByFileVersionId: string | null; } | { url?: string | undefined; accessibleByFile?: { id: string; name: string; toolId: string; } | undefined; path: string; id: string; type: "file"; createdAt: string; fileId: string; stableId: string; updatedAt: string; accessibleByFileId: string | null; accessibleByFileVersionId: string | null; } | { url?: string | undefined; accessibleByFile?: { id: string; name: string; toolId: string; } | undefined; path: string; id: string; type: "directory"; createdAt: string; stableId: string; updatedAt: string; accessibleByFileId: string | null; accessibleByFileVersionId: string | null; } | { url?: string | undefined; accessibleByFile?: { id: string; name: string; toolId: string; } | undefined; path: string; id: string; type: "resource"; createdAt: string; fileId: string; resourceId: string; stableId: string; updatedAt: string; accessibleByFileId: string | null; accessibleByFileVersionId: string | null; }>; listResources(): Promise<({ url?: string | undefined; accessibleByFile?: { id: string; name: string; toolId: string; } | undefined; path: string; id: string; type: "asset"; createdAt: string; stableId: string; assetId: string; updatedAt: string; accessibleByFileId: string | null; accessibleByFileVersionId: string | null; } | { url?: string | undefined; accessibleByFile?: { id: string; name: string; toolId: string; } | undefined; path: string; id: string; type: "file"; createdAt: string; fileId: string; stableId: string; updatedAt: string; accessibleByFileId: string | null; accessibleByFileVersionId: string | null; } | { url?: string | undefined; accessibleByFile?: { id: string; name: string; toolId: string; } | undefined; path: string; id: string; type: "directory"; createdAt: string; stableId: string; updatedAt: string; accessibleByFileId: string | null; accessibleByFileVersionId: string | null; } | { url?: string | undefined; accessibleByFile?: { id: string; name: string; toolId: string; } | undefined; path: string; id: string; type: "resource"; createdAt: string; fileId: string; resourceId: string; stableId: string; updatedAt: string; accessibleByFileId: string | null; accessibleByFileVersionId: string | null; })[]>; _sendMessage?: (message: ClientToServerMessage$1) => void; _unsubscribeConnectionEvents?: () => void; _resolveAssetId?: (idOrStableId: string) => string; _editSessions: Map; _handleConnectionEvent: (event: ConnectionEvent) => void; openEditingHandle(resourceId: string): _noya_app_noya_multiplayer_react.ResourceEditHandle; } type RequestOfType = Omit, "type">; type EvaluateScriptOptions = RequestOfType<"code">; type EvaluateScriptUrlOptions = RequestOfType<"url">; type EvaluateScriptFilesOptions = RequestOfType<"files">; type ScriptEvaluationResult = { result: Result; logs: unknown[][]; }; declare class ScriptEvaluationError extends Error { evaluationError: ParsedError; logs: unknown[][]; constructor(evaluationError: ParsedError, logs: unknown[][]); } declare class ScriptEvaluatorManager { private rpcManager; constructor(rpcManager: RPCManager); evaluateScript(options: EvaluateScriptOptions): Promise>; evaluateUrl(options: EvaluateScriptUrlOptions): Promise>; evaluateFiles(options: EvaluateScriptFilesOptions): Promise>; private evaluate; } type HistoryEntry = { undo: (state: S) => S; redo: (state: S) => S; undoPatches?: ExtendedPatch[]; redoPatches?: ExtendedPatch[]; metadata: M; }; type ActionHandler = { run: (state: S) => S; undo: (state: S) => S; }; type HistorySnapshot = { version: number; history: HistoryEntry[]; historyIndex: number; canUndo: boolean; canRedo: boolean; }; type StateManagerOptions = { /** * By default, the state manager will ignore edits that don't change the state. * Set this to true to allow empty edits. */ allowEmptyEdits?: boolean; /** * Merge two history entries into a single history entry. * Usually this means providing a name, timestamp, or other metadata, and * combining the undo/redo operations based on this metadata. */ mergeHistoryEntries?: (parameters: { previous: HistoryEntry; next: HistoryEntry; }, stateManager: StateManager) => HistoryEntry | void; /** * Maximum number of history entries to retain. * When the limit is reached, older entries are discarded. */ maxHistoryEntries?: number; /** * Schema to validate the state against. */ schema?: TSchema; }; declare function createEditHistoryEntry(state: S, options: StateManagerOptions, metadata: M, mutator: (draft: Draft) => void): { state: S; historyEntry: Required>; } | undefined; declare function createPatchHistoryEntry(state: S, options: StateManagerOptions, metadata: M, patches: ExtendedPatch[], inversePatches: ExtendedPatch[]): { state: S; historyEntry: Required>; } | undefined; /** * A wrapper class that allows easily creating JSON patches. * * Supports methods for the following operations: * - 'add' * - 'remove' * - 'replace' * - 'move' */ declare class OperationManager { state: S; constructor(state: S); patches: ExtendedPatch[]; inversePatches: ExtendedPatch[]; getState: () => S; get:

(path: P) => GetAtPath; _replaceLastDashWithIndex: (exInv: ExtendedPatch, state: S, value: unknown) => void; set:

(path: P | PathKey[], value: GetAtPath) => void; /** * Alias for `set` */ replace:

(path: P | PathKey[], value: GetAtPath) => void; /** * For objects, behaves like `set`. * For arrays, inserts the value instead of replacing an existing value. */ add:

(path: P, value: GetAtPath) => void; remove:

(path: P) => void; /** * Alias for `remove` */ delete:

(path: P) => void; static getInverseMoveIndexes({ state, opFrom, opTo, }: { state?: any; opFrom: PathKey[]; opTo: PathKey[]; }): { invFrom: PathKey[]; invTo: PathKey[]; }; move:

(from: F, to: P) => void; editDraft: (mutator: (draft: Draft) => void) => void; } declare class StateManager extends Emitter { options: StateManagerOptions; state: S; schema?: TSchema; version: number; history: HistoryEntry[]; historyIndex$: Observable; get historyIndex(): number; set historyIndex(value: number); historyEmittor: Emitter<[]>; constructor(initialState: S, options?: StateManagerOptions); _setState(newState: S): void; _setStateWithHistoryEntry(newState: S, historyEntry: HistoryEntry, { shouldTypeCheck, }?: { shouldTypeCheck?: boolean; }): void; edit: (...args: M extends {} ? [metadata: M, mutator: (draft: Draft) => void] : [mutator: (draft: Draft) => void]) => void; operate: (...args: M extends {} ? [metadata: M, operator: (operationManager: OperationManager) => void] : [operator: (operationManager: OperationManager) => void]) => ExtendedPatch[] | undefined; performAction: (...args: M extends {} ? [metadata: M, handler: ActionHandler] : [handler: ActionHandler]) => void; canUndo: () => boolean; canUndo$: Observable; canRedo: () => boolean; canRedo$: Observable; undo: () => void; redo: () => void; getState(): S; getState

(path: P): GetAtPath; clearHistory: () => void; replaceState: (newState: S) => void; /** * Replace the initial state of the state manager, effectively rebasing the history. * * Replaces the initial state with the new state then applies each redo up to the * current history index. */ rebase: (newInitialState: S) => void; getStateAtHistoryIndex: (index: number) => S; _rewindToIndex: (index: number, f: (state: S) => S) => void; /** * Accept a patch to the base state, effectively rebasing the history. */ acceptPatchesAtIndex: (index: number, patches: ExtendedPatch[], filterHistoryEntry?: (entry: HistoryEntry, index: number) => boolean) => void; goToHistoryIndex: (index: number) => void; getHistorySnapshot: () => HistorySnapshot; _createVersionMemoizer any>(f: F): (...args: Parameters) => ReturnType; } type AvoidRect = { id: string; rect: { x: number; y: number; width: number; height: number; }; }; /** * Messages sent from the embedded editor to the parent frame */ type EmbeddedToParentMessage = { type: "multiplayer.ready"; } | { type: "multiplayer.message"; payload: ClientToServerMessage; } | { type: "application.setMenuItems"; payload: { menuItems: MenuItem[]; position: "left" | "right"; }; } | { type: "application.showCommandPalette"; payload: boolean; } | { type: "application.evaluate"; payload: EvalRequest; } | { type: "application.enablePublishing"; payload: boolean; } | { type: "application.publish"; payload: { id: string; files: MediaMap; }; } | { type: "ai.setConfig"; payload: { tools: CallableAIToolsMap; systemMessage?: string; }; } | { type: "ai.tool.response"; payload: { invocation: AIToolInvocation; response?: string; }; } | { type: "rpc.request"; payload: SerializableRequest; }; /** * Messages sent from the parent frame to the embedded editor */ type ParentToEmbeddedMessage = ConnectionMessage | RPCResponseMessage | ServerToClientMessage | { type: "application.selectMenuItem"; payload: { value: string; }; } | { type: "application.evaluate.result"; payload: EvalResponse; } | { type: "application.requestPublish"; payload: { id: string; }; } | { type: "ai.tool.call"; payload: AIToolInvocation; } | { type: "application.setAvoidRects"; payload: { rects: AvoidRect[]; }; }; /** * Interface for handling communication between parent frame and embedded editor */ interface ParentFrameMessageHandler { /** * Send a message to the parent frame * @param message The message to send * @param origin The target origin */ postMessage: (message: EmbeddedToParentMessage | ParentToEmbeddedMessage, origin: string) => void; /** * Add a listener for messages from the parent frame * @param handler The message handler function * @returns A cleanup function to remove the listener */ addMessageListener: (handler: (event: MessageEvent>) => void) => () => void; } /** * Default implementation of ParentFrameMessageHandler using window.parent */ declare function createDefaultMessageHandler(): ParentFrameMessageHandler; /** * Type guard to check if a message is a valid ParentToEmbeddedMessage */ declare function isParentToEmbeddedMessage(message: any): message is ParentToEmbeddedMessage; /** * Type guard to check if a message is a valid EmbeddedToParentMessage */ declare function isEmbeddedToParentMessage(message: any): message is EmbeddedToParentMessage; type Task = { id: string; name: string; payload: any; status: "pending" | "done" | "error"; }; declare class TaskManager { options: { maxTasks?: number; }; constructor(options?: { maxTasks?: number; }); tasks$: Observable; setTasks(tasks: Task[]): void; getTasks(): Task[]; } type BaseTranscribeOptions = { fileName?: string; contentType?: string; endpoint?: string; apiKey?: string; }; type TranscribeOptions = BaseTranscribeOptions & ({ data: Uint8Array; } | { assetId: string; }); type TranscriptionResult = ExtractResponseBody$1<"POST /api/transcriptions">; type AssetTranscriptionResult = ({ type: "success"; } & Omit) | { type: "error"; error: Error; } | { type: "processing"; }; declare class TranscriptionManager { private rpcManager; private assetManager; constructor(rpcManager: RPCManager, assetManager: AssetManager); assetTranscriptions$: Observable>; getAssetTranscription$(assetId: string, options: BaseTranscribeOptions): Observable; transcribe(options: TranscribeOptions): Promise; } type AssetResolverResult = { data: ArrayBufferLike; contentType?: string; }; declare function requestTranscription(options: TranscriptionRequest & { endpoint: string; }, { resolveAsset, }: { resolveAsset: (assetId: string) => Promise; }): Promise; declare function findNoyaUser(users: MultiplayerUser[], id: string): MultiplayerUser; declare function findNoyaUser(users: MultiplayerUser[], id?: string): MultiplayerUser | undefined; declare class UserManager { #private; private rpcManager?; constructor(rpcManager?: RPCManager | undefined); currentUserId$: Observable; currentClientId$: Observable; currentConnectionId$: Observable; /** * Get the best id we have for the current user. * The user id (signed in) > client id (browser storage) > connection id (websocket connection) */ currentId$: Observable; allUsers$: Observable; connectedUsers$: Observable; connectedUsersCount$: Observable; currentUser$: Observable; workspaceUsers$: Observable; initializeWorkspaceUsers(): void; setCurrentUserId(userId: string | undefined): void; setCurrentConnectionId(connectionId: string | undefined): void; setAllUsers(users: MultiplayerUser[]): void; private fetchWorkspaceMembers; } type NoyaManagerOptions = MultiplayerStateManagerOptions & { initialAssets?: Asset[]; initialSecrets?: Secret[]; initialResources?: Resource[]; initialFileName?: string; registerDefaultAITools?: boolean; safeEval?: SafeEval; /** Whether git operations should include base64-encoded file contents in responses */ gitIncludeContent?: boolean; }; declare function defaultMergeHistoryEntries({ previous, next, }: { previous: HistoryEntry; next: HistoryEntry; }): HistoryEntry | undefined; declare class NoyaManager = Record> { id: string; multiplayerStateManager: MultiplayerStateManager; rpcManager: RPCManager; pipelineManager: PipelineManager; scriptEvaluatorManager: ScriptEvaluatorManager; secretManager: SecretManager; aiManager: AIManager; ioManager: IOManager; sharedConnectionDataManager: SharedConnectionDataManager; assetManager: AssetManager; userManager: UserManager; taskManager: TaskManager; connectionEventManager: ConnectionEventManager; menuManager: MenuManager; evalManager: EvalManager; publishingManager: PublishingManager; resourceManager: ResourceManager; activityEventsManager: ActivityEventsManager; filePropertyManager: FilePropertyManager; logManager: LogManager; transcriptionManager: TranscriptionManager; sandboxManager: SandboxManager; gitManager: GitManager; isProcessing$: Observable; avoidRects$: Observable; initialState: S | (() => S); options: NoyaManagerOptions; unrecoverableError: Observable; constructor(initialState: S | (() => S), options?: NoyaManagerOptions); enqueueInput: >(queue: K, payload: I[K]) => void; forceInit: () => void; undo: () => HistoryEntry & MultiplayerPatchMetadata> | undefined; redo: () => HistoryEntry & MultiplayerPatchMetadata> | undefined; canUndo: () => boolean; canRedo: () => boolean; restoreSnapshot: (options: { fileId: string; fileVersionId: string; }) => Promise; } declare const createMutatorParametersSchema: _sinclair_typebox.TObject<{ sourceCode: _sinclair_typebox.TString; message: _sinclair_typebox.TString; }>; type CreateMutatorParameters = Static; type MultiplayerUser = { id: string; connectionId: string; clientId: string; authId?: string; name?: string; image?: string; inactive?: boolean; }; type AccessType = "read" | "write" | "none"; type TokenPayload = Omit & { fileId: string; access: AccessType; writeTo?: string; baseUrl: string; }; type Destructor = () => void; type SyncAdapterOptions = Record> = { noyaManager: NoyaManager; }; type SyncAdapter = Record> = (options: SyncAdapterOptions) => Destructor; type SyncURLOption = string | URL | (() => Promise); type SyncOptionsBase = { url: SyncURLOption; debug?: boolean; }; type WebSocketSyncOptions = SyncURLOption | SyncOptionsBase; type ParentFrameSyncOptions = { origin?: string; messageHandler?: ParentFrameMessageHandler; debug?: boolean; policyAuthContext?: PolicyAuthContext; }; type SyncConfig = { url: URL; tokenString: string; tokenPayload: TokenPayload; }; type AdapterHandlers = { assetManager?: AssetManager; sharedConnectionDataManager?: SharedConnectionDataManager; pipelineManager?: PipelineManager; secretManager?: SecretManager; userManager?: UserManager; onChangeTasks?: (tasks: Task[]) => void; }; type ConnectionMessage = { type: "connection"; state: "connected" | "disconnected"; }; declare const MULTIPLAYER_POLICY_METADATA_KEY = "noyaPolicy"; declare const SERVER_COMPUTED_METADATA_KEY = "noyaServerComputed"; declare const SERVER_SCRIPTS_METADATA_KEY = "noyaServerScripts"; type MultiplayerPolicyAction = "read" | "create" | "update" | "delete"; type MultiplayerPolicyLet = [string, string]; type MultiplayerPolicyDefinition = { allow?: Partial>; let?: MultiplayerPolicyLet[] | Record; }; type PolicyAuthContext = { id?: string | null; access?: AccessType; [key: string]: unknown; }; type ServerComputedEvent = "create" | "update"; type ServerComputedTarget = "value" | "object"; type ServerComputedValueFactory = { kind: "timestamp"; format?: "iso" | "number"; } | { kind: "authId"; } | { kind: "uuid"; } | { kind: "literal"; value: unknown; } | { kind: "expression"; expression: string; }; type ServerComputedDefinition = { events?: ServerComputedEvent[]; targets?: ServerComputedTarget[]; compute: ServerComputedValueFactory; }; type ServerScriptDefinition = { id: string; code: string; label?: string; on?: { interval?: string; stateChange?: true | { paths: string[]; }; inputQueue?: true | { queues: string[]; }; user?: true | { events: ("join" | "leave")[]; }; schemaMigration?: true | { fromVersions?: number[]; }; }; }; type ServerComputedDefinitionInput = Omit & { compute: ServerComputedValueFactory | string; }; declare function ServerComputed(schema: T, definition: ServerComputedDefinitionInput): T; declare function AccessPolicy(schema: T, definition: MultiplayerPolicyDefinition): T; declare function ServerScripts(schema: T, scripts: ServerScriptDefinition[]): T; declare function getServerScriptDefinitions(schema?: TSchema | null): ServerScriptDefinition[]; type PolicyViolation = { action: MultiplayerPolicyAction; patch: ExtendedPatch; expression?: string; message?: string; }; declare function enforceMultiplayerPolicies(options: { schema?: TSchema; patches: ExtendedPatch[]; previousState: S; nextState: S; auth?: PolicyAuthContext; now: number; }): PolicyViolation | undefined; declare function applyServerComputedMetadata(options: { schema?: TSchema; patches: ExtendedPatch[]; auth?: PolicyAuthContext; now: number; }): ExtendedPatch[]; declare function filterStateForReadAccess(options: { schema?: TSchema; state: S; auth?: PolicyAuthContext; now: number; }): S; type InputQueueItem = { id: string; connectionId: string; queue: string; enqueuedAt: number; payload: unknown; }; type DrainInputQueueOptions = { connectionId?: string; queue?: string; maxEntries?: number; }; type QuickJSHandleLike = { consume(fn: (handle: QuickJSHandleLike) => T): T; dispose(): void; }; type QuickJSContextLike = { global: QuickJSHandleLike; undefined: QuickJSHandleLike; evalCode(code: string, filename?: string, options?: { type?: "global" | "module"; }): QuickJSHandleLike; unwrapResult(handle: QuickJSHandleLike): QuickJSHandleLike; newFunction(name: string, fn: (...args: QuickJSHandleLike[]) => QuickJSHandleLike): QuickJSHandleLike; newObject(): QuickJSHandleLike; newString(value: string): QuickJSHandleLike; setProp(object: QuickJSHandleLike, prop: string, value: QuickJSHandleLike): void; dump(handle: QuickJSHandleLike): T; dispose(): void; }; type QuickJSRuntimeLike = { newContext(): QuickJSContextLike; setModuleLoader(loader: (moduleName: string) => string | { error: Error; } | Promise): void; dispose(): void; }; type QuickJSModuleLike = { newRuntime(): QuickJSRuntimeLike; }; type QuickJSModuleFactory = () => Promise | TModule; type ServerScriptTarget = "durable-object" | "local-storage" | "client-simulator" | "test"; type ServerScriptUserTriggerEvent = "join" | "leave"; type ServerScriptMode = "live" | "simulation"; type ServerScriptEnvironment = { target: ServerScriptTarget; mode?: ServerScriptMode; label?: string; clock?: () => number; }; type ServerScriptLogEvent = { level: "log" | "error" | "warn"; scriptId: string; target: ServerScriptTarget; mode: ServerScriptMode; origin: string; values: unknown[]; }; type ServerScriptRuntimeBindings = { getState: () => any; getSharedConnectionData: () => Record; setSharedConnectionData: (data: Record) => void; drainInputQueue: (options?: DrainInputQueueOptions) => InputQueueItem[]; applyState: (options: { scriptId: string; nextState: any; invocation?: number; timestamp?: number; }) => Promise | void; getInitialInvocation?: (scriptId: string) => number | undefined; }; type ServerScriptManagerOptions = ServerScriptRuntimeBindings & { getQuickJSModule: QuickJSModuleFactory; randomUUID?: () => string; environment: ServerScriptEnvironment; log: (entry: ServerScriptLogEvent) => void; }; declare function serializeServerScriptLogValue(value: unknown, seen?: WeakSet): unknown; declare class ServerScriptManager { private options; private isHot; private runners; private quickJSPromise; private randomUUID; private environment; private log; constructor(options: ServerScriptManagerOptions); private getQuickJSPromise; setIsHot(isHot: boolean): void; syncInvocation(scriptId: string | undefined, invocation: number, timestamp?: number): void; updateSchema(schema?: any | null): Promise; handleStateChange(patches: ExtendedPatch[]): void; handleInputQueueActivity(queueName?: string): void; handleUserEvent(event: ServerScriptUserTriggerEvent, user: MultiplayerUser): void; /** * Runs migration scripts in definition order. * If multiple scripts match, they chain: each receives the output of the previous. * Returns the final migrated state, or undefined if no scripts ran/returned state. * * Note: Unlike other handlers, this does NOT require isHot to be true since * migrations run during schema initialization before normal script execution. */ handleSchemaMigration(fromVersion: number, toVersion: number, state: any): Promise; dispose(): void; } declare const createHash: typeof hash; type SetStateAction = S | ((prevState: S) => S); /** * TODO: * * Pending commits may need to be updated when a patch is accepted or rejected? * Since right now we're using optimisticState based on pending commits - but * instead we could use a memoization approach * * Server may want to say whether a commit is from self or not, so that we can * more easily ignore patches that we sent (e.g. in case we change a pending patch * after sending? but it already has an id so maybe not needed) * * Prune old patches from the server * * MSM can just have a sm StateManager, mostly separate from any multiplayer logic, * that does its usual patch merging etc, but can be used to send undo/redo patches */ type ServerInvocation = { scriptId?: string; invocation: number; timestamp: number; }; type MultiplayerPatchMetadata = { id: string; name?: string; timestamp: number; serverInvocation?: ServerInvocation & { source: "server" | "client-sim"; }; }; type ClientCommit = { state: S; baseHash: string; historyEntry: Required>; }; type ClientConnectionStatus = "connected" | "disconnected"; type ClientToServerMessage = { type: "init"; object: S; force?: boolean; schema?: EncodedSchema; inputs?: CreateParams[]; outputTransforms?: CreateParams[]; } | { type: "patch"; id: string; name?: string; patches: ExtendedPatch[]; baseHash: string; serverInvocation?: ServerInvocation; } | { type: "resourceEdit.open"; resourceId: string; } | { type: "resourceEdit.patch"; resourceId: string; id: string; patches: ExtendedPatch[]; baseHash: string; } | { type: "resourceEdit.close"; resourceId: string; } | { type: "gitFileEdit.open"; repoId: string; filePath: string; ref: string; } | { type: "gitFileEdit.patch"; repoId: string; filePath: string; ref: string; id: string; patches: ExtendedPatch[]; baseHash: string; } | { type: "gitFileEdit.close"; repoId: string; filePath: string; ref: string; } | { type: "setSharedConnectionData"; connectionId: string; data?: unknown; } | { type: "enqueueInput"; connectionId?: string; queue: string; payload: unknown; } | { type: "ping"; id: string; } | { type: "activityEvents.subscribe"; streamId: string; cursor?: string; } | { type: "activityEvents.unsubscribe"; streamId: string; }; type RejectInitReason = "invalidDataType" | "schemaMismatch" | "outdatedSchema" | "dataMigrationFailure"; type RejectPatchReason = "serverStateNotInitialized" | "errorApplyingPatch" | "clientOutOfSync" | "invalidDataType" | "outdatedSchema" | "policyViolation"; type PipelineStatus = "idle" | "running" | "success" | "error"; type ServerToClientMessage = { type: "object"; object: S; schema?: EncodedSchema; } | { type: "rejectInit"; reason: RejectInitReason; error?: string; } | { type: "acceptPatch"; id: string; patches: ExtendedPatch[]; hash?: string; serverInvocation?: ServerInvocation; } | { type: "rejectPatch"; id: string; reason: RejectPatchReason; error?: string; } | { type: "resourceEdit.object"; resourceId: string; content: string; hash?: string; } | { type: "resourceEdit.acceptPatch"; resourceId: string; id: string; patches: ExtendedPatch[]; hash?: string; } | { type: "resourceEdit.rejectPatch"; resourceId: string; id: string; reason: RejectPatchReason; error?: string; } | { type: "gitFileEdit.object"; repoId: string; filePath: string; ref: string; content: string; hash?: string; } | { type: "gitFileEdit.acceptPatch"; repoId: string; filePath: string; ref: string; id: string; patches: ExtendedPatch[]; hash?: string; } | { type: "gitFileEdit.rejectPatch"; repoId: string; filePath: string; ref: string; id: string; reason: RejectPatchReason; error?: string; } | { type: "gitFileEdit.committed"; repoId: string; ref: string; oid: string; } | { type: "connectedUsers"; users: MultiplayerUser[]; } | { type: "schemaMigration"; schema: EncodedSchema; } | { type: "sharedConnectionData"; data: Record; } | { type: "workflow"; workflow: { status: PipelineStatus; tasks: TaskSnapshot[]; result: any; }; } | { type: "tasks"; tasks: Task[]; } | { type: "assets"; assets: Asset[]; } | { type: "resources"; resources: Resource[]; } | { type: "inputs"; inputs: Input[]; } | { type: "outputTransforms"; outputTransforms: OutputTransform[]; } | { type: "pong"; id: string; } | { type: "secrets"; secrets: Secret[]; } | { type: "fileName"; name: string; changeId?: string; } | { type: "activityEvents"; activityEvents: unknown[]; } | { type: "activityEvents.update"; streamId: string; activityEvents: unknown[]; } | { type: "serverScript.log"; log: ServerScriptLogEntry; } | { type: "sandbox"; state: SandboxState; }; type MultiplayerStateManagerErrorType = RejectInitReason | "schemaMigration" | RejectPatchReason; declare class MultiplayerStateManagerError extends Error { readonly reason: MultiplayerStateManagerErrorType; constructor(reason: MultiplayerStateManagerErrorType, message?: string); } type MultiplayerStateManagerMode = "standalone" | "synchronized"; type MultiplayerStateManagerOptions = StateManagerOptions & MultiplayerPatchMetadata> & { randomId?: () => string; getNow?: () => number; serverScripts?: { simulateLocally?: boolean; getQuickJSModule: ServerScriptManagerOptions["getQuickJSModule"]; randomUUID?: ServerScriptManagerOptions["randomUUID"]; getNow?: () => number; }; getSharedConnectionData?: () => Record; drainInputQueue?: (options?: DrainInputQueueOptions) => InputQueueItem[]; overrideExistingState?: boolean; outputTransforms?: CreateParams[]; inputs?: CreateParams[]; debug?: boolean; mode?: MultiplayerStateManagerMode; }; declare class MultiplayerStateManager extends Emitter { options: MultiplayerStateManagerOptions; get _metadataType(): Partial & MultiplayerPatchMetadata; state: TState; schema?: TSchema; errorEmitter: Emitter<[MultiplayerStateManagerError]>; sm: StateManager; pendingCommits: ClientCommit[]; connectionStatus$: Observable; isInitialized$: Observable; outgoingMessages: ClientToServerMessage[]; incomingMessages: ServerToClientMessage[]; optimisticState$: Observable; partialHashCache: Cache; createHashCached: (input: unknown) => string; applyCommitCache: Cache; private policyAuthContext; private enforcePoliciesLocally; enhanceMetadata(metadata: Partial & Partial): typeof this._metadataType; getRandomId(): string; private initializeServerSimulator; setPolicyAuthContext(context: PolicyAuthContext | undefined): void; setLocalPolicyEnforcement(enabled: boolean): void; constructor(state: TState | (() => TState), options?: MultiplayerStateManagerOptions); autoConnect: () => void; getHash(): string; _setState(state: TState, schema: TSchema | undefined): void; _lastEmittedHash: string | undefined; emitIfChanged: () => void; get isConnected(): boolean; _pushCommit(state: TState, historyEntry: Required>, { addToHistory, shouldTypeCheck, sendMessage, }: { addToHistory: boolean; shouldTypeCheck?: boolean; sendMessage?: boolean; }): void; private getLocalPolicyViolation; canUndo: () => boolean; canRedo: () => boolean; undo: () => HistoryEntry & MultiplayerPatchMetadata> | undefined; redo: () => HistoryEntry & MultiplayerPatchMetadata> | undefined; /** * Mutate the state in-place. * * This will create a patch based on the changes made to the state and create * a history entry with the patch. */ editDraft: (...args: [metadata: Partial, callback: (draft: Draft) => void] | [callback: (draft: Draft) => void]) => void; /** * Apply a patch optimistically. * * Creates a history entry with the patch. If inversePatches are not provided, * this will perform a diff between the current state and the new state. */ applyPatch: (...args: [metadata: Partial, { patches: ExtendedPatch[]; inversePatches?: ExtendedPatch[]; }] | [{ patches: ExtendedPatch[]; inversePatches?: ExtendedPatch[]; }]) => void; /** * Set the current state optimistically. * * This will perform a diff between the current state and the new state, and * create a history entry with the patch. */ setState: (...args: [metadata: Partial, action: SetStateAction] | [action: SetStateAction]) => void; setStateAtPath:

(...args: [metadata: Partial, path: P, value: SetStateAction>] | [path: P, value: SetStateAction>]) => void; operate: (...args: [metadata: Partial, operator: (operationManager: OperationManager) => void] | [operator: (operationManager: OperationManager) => void]) => void; getConfirmedState: () => TState; getOptimisticState: () => TState; getOptimisticHash(): string; reinitialize(state: TState): void; _handledMessages: Record; processIncomingMessages(): void; connect(): void; sendInit({ force, state, schema, outputTransforms, inputs, }?: { force?: boolean; state?: TState; schema?: TSchema; outputTransforms?: CreateParams[]; inputs?: CreateParams[]; }): void; sendMessage(message: ClientToServerMessage): void; disconnect(): void; hasPendingMessages(): boolean; messageEmitter: Emitter<[ClientToServerMessage]>; /** SERVER PREDICTIONS */ serverSimulationLogManager: LogManager; serverSimulationLogs$: Observable; private serverPredictionCommits; private serverInvocationTracker; private serverClockSkewMs; private serverScriptSimulator?; private getNow; private getServerNowEstimate; getServerSimulationDiagnostics(): { simulateLocally: boolean; simulatorActive: boolean; clockSkewMs: number; invocations: { scriptId: string | undefined; invocation: number; timestamp: number; }[]; pendingPredictions: { scriptId: string | undefined; invocation: number | undefined; commitId: string; }[]; }; getLatestServerInvocation(scriptId?: string): { invocation: number; timestamp: number; } | undefined; getLatestPrediction(): { state: TState; serverInvocation: (ServerInvocation & { source: "server" | "client-sim"; }) | undefined; } | undefined; private clearServerPredictions; applyServerPrediction(options: { scriptId?: string; nextState: TState; invocation?: number; timestamp?: number; }): void; private handleServerInvocation; } type SharedConnectionMetadata = { updatedAt: number; }; type SelectionRange = { anchor: PathKey[]; head?: PathKey[]; }; type Point = { x: number; y: number; }; type DefaultSharedConnectionData = { pointer?: Point; selection?: SelectionRange[]; }; declare class SharedConnectionDataManager extends Emitter<[ Record, Record ]> { data$: Observable>; metadata$: Observable>; currentConnectionId$: Observable; currentConnectionDataEmitter: Emitter<[(E & DefaultSharedConnectionData) | undefined]>; setCurrentConnectionId: (currentConnectionId: string | undefined) => void; setForCurrentConnection: (value: E & DefaultSharedConnectionData) => void; set: (connectionId: string, value: E & DefaultSharedConnectionData) => void; merge: (partial: Record) => void; delete: (connectionId: string) => void; _snapshot: { data: Record; metadata: Record; currentConnectionId: string | undefined; } | undefined; getSnapshot: () => { data: Record; metadata: Record; currentConnectionId: string | undefined; }; } type ActivityEventStream = { activityEvents: Observable; isInitialized: Observable; }; type StreamFilter = "all" | { resourceId: string; }; declare class ActivityEventsManager { private sendMessage?; activityEventStreams: Record; constructor(sendMessage?: ((message: ClientToServerMessage) => void) | undefined); subscribe(filter: StreamFilter): string; getStream(streamId: string): Observable; unsubscribe(streamId: string): void; setStreamEvents(streamId: string, activityEvents: unknown[]): void; } export { type AvoidRect as $, AssetStoreIndexedDB as A, type RouteDefinition as B, type ClientToServerMessage as C, type DrainInputQueueOptions as D, type ExtractRequestBody as E, type RouteKey$1 as F, type GitFileCreateOperation as G, type HistoryEntry as H, type InputQueueItem as I, type ScriptEvaluatorFile as J, type ScriptEvaluatorRequest as K, type ScriptEvaluatorResponse as L, type WorkspaceMemberUser as M, NoyaManager as N, type AdapterHandlers as O, type ParentToEmbeddedMessage as P, type ConnectionMessage as Q, type Routes as R, type SerializableRequest as S, ReconnectingWebSocket as T, type UploadProgress as U, UserActivityDetector as V, type WebSocketSyncOptions as W, type ReconnectingWebSocketState as X, createDefaultMessageHandler as Y, isEmbeddedToParentMessage as Z, isParentToEmbeddedMessage as _, type SerializableResponse as a, type MultiplayerStateManagerErrorType as a$, type EmbeddedToParentMessage as a0, type ParentFrameMessageHandler as a1, type StreamFilter as a2, ActivityEventsManager as a3, type AIToolDefinition as a4, type CallableAIToolsMap as a5, type AIToolInvocation as a6, type AIImageInput as a7, type AIGenerateObjectOptions as a8, type AIGenerateTextOptions as a9, createExtended as aA, type FilePropertyManagerOptions as aB, FilePropertyManager as aC, type GitFileEditServerMessage as aD, type GitFileEditHandle as aE, GitFileEditSession as aF, type GitFileCommittedMessage as aG, type GitRepo as aH, type BranchInfo as aI, type RepoFilesFetchState as aJ, type RepoFilesState as aK, type GitManagerOptions as aL, GitManager as aM, type CreateParams as aN, IOManager as aO, type ServerScriptLogLevel as aP, type ServerScriptLogEntry as aQ, type LogManagerOptions as aR, LogManager as aS, MenuManager as aT, createHash as aU, type MultiplayerPatchMetadata as aV, type ClientCommit as aW, type ClientConnectionStatus as aX, type RejectInitReason as aY, type RejectPatchReason as aZ, type PipelineStatus as a_, type AIGenerateImageOptions as aa, type AIGeneratedImage as ab, AIManager as ac, type AssetUploadProgress as ad, type CreateAssetOptions as ae, type UpdateAssetOptions as af, type IAssetStore as ag, type NoyaAsset as ah, AssetStoreMemory as ai, AssetStoreRemote as aj, type ConnectionEvent as ak, ConnectionEventManager as al, type EvalRequest as am, type EvalResponse as an, type SafeEval as ao, EvalManager as ap, applyPatchToString as aq, apply as ar, type SimplePatchWithStringPath as as, extractItemId as at, toExtendedPathKey as au, toSimplePath as av, toExtendedPatch as aw, toSimplePatch as ax, applyExtendedPatch as ay, toExtendedPatches as az, type ExtractResponseBody as b, type Secret as b$, MultiplayerStateManagerError as b0, type MultiplayerStateManagerMode as b1, type MultiplayerStateManagerOptions as b2, MultiplayerStateManager as b3, type SharedConnectionMetadata as b4, type SelectionRange as b5, type DefaultSharedConnectionData as b6, SharedConnectionDataManager as b7, MULTIPLAYER_POLICY_METADATA_KEY as b8, SERVER_COMPUTED_METADATA_KEY as b9, PublishingManager as bA, type ResourceEditServerMessage as bB, type ResourceEditHandle as bC, ResourceEditSession as bD, type ResourceManagerOptions as bE, ResourceManager as bF, type TypedBody as bG, type RPCRequestPayload as bH, type RPCResponsePayload as bI, type RPCSuccessResponse as bJ, type RPCStreamChunkResponse as bK, type RPCStreamEndResponse as bL, type RPCErrorResponse as bM, type RPCStatus as bN, type RPCResponseMessage as bO, RPCManager as bP, type SandboxPhase as bQ, type SandboxState as bR, createInitialSandboxState as bS, type ExecResult as bT, SandboxManager as bU, type EvaluateScriptOptions as bV, type EvaluateScriptUrlOptions as bW, type EvaluateScriptFilesOptions as bX, type ScriptEvaluationResult as bY, ScriptEvaluationError as bZ, ScriptEvaluatorManager as b_, SERVER_SCRIPTS_METADATA_KEY as ba, type MultiplayerPolicyAction as bb, type MultiplayerPolicyLet as bc, type MultiplayerPolicyDefinition as bd, type PolicyAuthContext as be, type ServerComputedEvent as bf, type ServerComputedTarget as bg, type ServerComputedValueFactory as bh, type ServerComputedDefinition as bi, type ServerScriptDefinition as bj, ServerComputed as bk, AccessPolicy as bl, ServerScripts as bm, getServerScriptDefinitions as bn, type PolicyViolation as bo, enforceMultiplayerPolicies as bp, applyServerComputedMetadata as bq, filterStateForReadAccess as br, type NoyaManagerOptions as bs, defaultMergeHistoryEntries as bt, createMutatorParametersSchema as bu, type CreateMutatorParameters as bv, type TaskArtifact as bw, type TaskMetadata as bx, PipelineManager as by, type PublishCallback as bz, type ServerToClientMessage as c, type SecretManagerOptions as c0, SecretManager as c1, type QuickJSHandleLike as c2, type QuickJSContextLike as c3, type QuickJSRuntimeLike as c4, type QuickJSModuleLike as c5, type QuickJSModuleFactory as c6, type ServerScriptTarget as c7, type ServerScriptMode as c8, type ServerScriptEnvironment as c9, type ServerScriptLogEvent as ca, type ServerScriptRuntimeBindings as cb, serializeServerScriptLogValue as cc, ServerScriptManager as cd, type ActionHandler as ce, type HistorySnapshot as cf, type StateManagerOptions as cg, createEditHistoryEntry as ch, createPatchHistoryEntry as ci, OperationManager as cj, StateManager as ck, type MultiplayerUser as cl, type AccessType as cm, type TokenPayload as cn, type Destructor as co, type SyncAdapterOptions as cp, TaskManager as cq, type Task as cr, type TranscribeOptions as cs, type TranscriptionResult as ct, type AssetTranscriptionResult as cu, TranscriptionManager as cv, requestTranscription as cw, findNoyaUser as cx, UserManager as cy, type SyncOptionsBase as d, type SyncURLOption as e, type SyncConfig as f, type ServerScriptManagerOptions as g, type SyncAdapter as h, type ParentFrameSyncOptions as i, type StoreAsset as j, type ExtendedPatch as k, type SimplePatch as l, type ExtendedPathKey as m, AssetManager as n, type AIGenerateImage as o, type AIGenerateImageRequest as p, type AIGenerateImageResponse as q, type AIGenerateRequest as r, type AIGenerateResponse as s, type AIGenerateTextRequest as t, type AIGenerateTextResponse as u, type GitFileDeleteOperation as v, type GitFileInfo as w, type GitFilePatchRequestBody as x, type GitFilePatchResponseBody as y, type GitFileRenameOperation as z };