import { CapabilityCall, CapabilityClient, CapabilityHandlerContext, CapabilityImplementation } from "@dsh-std/connection"; import { PresentationClients, PresentationDescriptor } from "@dsh-std/presentation"; import { ProtocolCatalog, ProtocolDefinition, ProtocolSupport } from "@dsh-std/core"; import { ManifestDefinitionCatalog, ManifestExtension } from "@dsh-std/manifest"; //#region src/index.d.ts declare const API_VERSION = "commands.dsh/v1alpha1"; declare const KIND = "Command"; declare const RUNTIME_KIND = "CommandRuntime"; /** Stable reference to one declared command path. */ interface CommandReference { readonly name: string; readonly path?: readonly string[]; } interface CommandValueSpec { readonly value: string; readonly title?: string; readonly titles?: Readonly>; } interface CommandArgumentSpec { readonly name: string; readonly title?: string; readonly titles?: Readonly>; readonly required?: boolean; readonly variadic?: boolean; readonly values?: readonly CommandValueSpec[]; } interface CommandOptionSpec { /** Literal spellings such as `--verbose` and `-v`. */ readonly names: readonly string[]; readonly title: string; readonly titles?: Readonly>; readonly value?: CommandArgumentSpec; } interface CommandNodeSpec { readonly title: string; readonly titles?: Readonly>; readonly description?: string; readonly aliases?: readonly string[]; readonly arguments?: readonly CommandArgumentSpec[]; readonly options?: readonly CommandOptionSpec[]; readonly children?: readonly CommandNode[]; } interface CommandNode { readonly name: string; readonly spec: CommandNodeSpec; } type CommandSpec = CommandNodeSpec; type CommandResource = ManifestExtension; interface CommandOwnerReference { readonly component: string; readonly facet: string; readonly participantId?: string; } interface CommandDescriptor { readonly name: string; readonly description: string; readonly input?: { readonly hint: string; }; readonly owner: CommandOwnerReference; readonly resource: CommandResource; readonly available: boolean; readonly missingPresentation: readonly ProtocolSupport[]; readonly issues: readonly { readonly code: string; readonly message: string; }[]; } interface CommandCatalog { readonly apiVersion: typeof API_VERSION; readonly commands: readonly CommandDescriptor[]; } interface CommandCatalogInput { /** Opaque execution context selected by the consuming product. */ readonly contextId: string; readonly presentation?: PresentationDescriptor; } interface CommandExecutionInput extends CommandCatalogInput { readonly line: string; } interface CommandExecution { readonly apiVersion: typeof API_VERSION; readonly commandId: string; readonly result: { readonly kind: 'success' | 'error'; readonly text?: string; readonly sourceEventSeq?: number; }; } type CommandRuntimeCall = { readonly operation: 'catalog'; readonly input: CommandCatalogInput; readonly output: CommandCatalog; } | { readonly operation: 'execute'; readonly input: CommandExecutionInput; readonly output: CommandExecution | undefined; }; interface CommandRuntimeClient { catalog(input: CommandCatalogInput, options?: { readonly signal?: AbortSignal; }): CapabilityCall; execute(input: CommandExecutionInput, options?: { readonly signal?: AbortSignal; }): CapabilityCall; } interface CommandRuntimeHandler { catalog(input: CommandCatalogInput, context: CapabilityHandlerContext): CommandCatalog | Promise; execute(input: CommandExecutionInput, context: CapabilityHandlerContext): CommandExecution | undefined | Promise; } interface CommandHandlerInput { readonly rawInput: string; } interface CommandHandlerContext { readonly signal: AbortSignal; /** Host-bound clients for Presentation agreements active in this invocation. */ readonly presentation?: PresentationClients; } interface CommandHandler { execute(input: CommandHandlerInput, context: CommandHandlerContext): CommandExecution['result'] | Promise; } declare function assertCommandHandler(value: unknown): asserts value is CommandHandler; declare const extensionDefinition: Readonly<{ apiVersion: "commands.dsh/v1alpha1"; kind: "Command"; validateMetadata(metadata: { readonly name: string; }): void; validateSpec(value: unknown): void; }>; /** Host support for accepting and owning Command resource publications. */ declare const resourceProtocol: ProtocolDefinition; declare const resourceSupport: ProtocolSupport; /** Callable, resource-keyed command dispatcher implemented once by a Runtime adapter. */ declare const runtimeProtocol: ProtocolDefinition; declare const runtimeSupport: ProtocolSupport; /** Bind the typed CommandRuntime operations to a consumer-scoped connection client. */ declare function commandRuntime(client: CapabilityClient): CommandRuntimeClient; /** Create the sole Runtime-side dispatcher implementation for every Command resource. */ declare function commandRuntimeImplementation(participantId: string, handler: CommandRuntimeHandler): CapabilityImplementation; declare function register(protocols: ProtocolCatalog, manifest?: ManifestDefinitionCatalog): () => void; //#endregion export { API_VERSION, CommandArgumentSpec, CommandCatalog, CommandCatalogInput, CommandDescriptor, CommandExecution, CommandExecutionInput, CommandHandler, CommandHandlerContext, CommandHandlerInput, CommandNode, CommandNodeSpec, CommandOptionSpec, CommandOwnerReference, CommandReference, CommandResource, CommandRuntimeCall, CommandRuntimeClient, CommandRuntimeHandler, CommandSpec, CommandValueSpec, KIND, RUNTIME_KIND, assertCommandHandler, commandRuntime, commandRuntimeImplementation, extensionDefinition, register, resourceProtocol, resourceSupport, runtimeProtocol, runtimeSupport }; //# sourceMappingURL=index.d.ts.map