@bobannomi/client 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -74,7 +74,7 @@ await modelProviders.defaults.updateModel({
74
74
 
75
75
  全局推理强度使用 `modelProviders.defaults.updateEffort({ effort, expectedRevision })`,可选值来自当前模型的 `reasoningEfforts`。断开或删除默认供应商时传入 `replacement: { provider, model }`,或显式传入 `disableDefault: true`。连接测试查询模型列表并记录验证结果。没有独立验证接口的订阅会返回 `unsupported`。 [可运行示例](../../apps/client-docs/examples/README.md)
76
76
 
77
- ## 宿主配置模型目录
77
+ ## 自建后台的共享目录(可选)
78
78
 
79
79
  自行启动后台的 Node 宿主,可将 `modelCatalog: { url }` 或 `modelCatalog: { load }` 传给 `startBobanNomiDaemon()`。用启动结果的 `listen.url` 作为 SDK 的 `baseUrl`,并传入该后台的 token。连接成功后,`client.models.list()` 返回已连接供应商的模型。 [bobannomi 网关动态目录示例](../server/src/application/README.md#bobannomi-网关示例)
80
80
 
@@ -108,7 +108,7 @@ await modelProviders.defaults.updateModel({
108
108
 
109
109
  会话快照、reducer(合并快照和事件的函数)、选择函数及同步控制器从根入口导出,供不同界面共用一套恢复流程。请求 metadata 与工具输入/输出保留扩展数据。
110
110
 
111
- 工作台模型设置由 app-host 提供管理接口。公开 Client SDK 可读取已连接的模型,并通过会话配置选项读取新会话默认值。供应商连接与凭据、目录刷新、全局默认模型和推理强度写入,以及已保存连接的验证需要宿主授权。
111
+ 内置工作台经 AppHost 授权管理模型供应商。独立应用用目标 daemon 的管理员连接调用 `client.modelProviders`。页面用 `client.models.list()` 读取模型目录,用会话配置选项核对当前后台支持执行的模型。
112
112
 
113
113
  `session.management` 先按动作读取版本,再用原 `requestId` 和 `expectedRevision` 或 `expectedTreeRevision` 改名、置顶、归档或删除。`getMutation` 按原请求 ID 查询结果。`session.goal.getRequest` 和 `attachments.getUpload` 也通过原请求定位回执。`session.getContextUsage()` 读取会话当前上下文的用量,`session.getUsage()` 读取历史统计。 [会话管理与配置示例](../../apps/client-docs/examples/README.md)
114
114
 
package/dist/index.d.ts CHANGED
@@ -179,6 +179,8 @@ interface CreateClientSessionInput$1 {
179
179
  requestId?: string;
180
180
  cwd: string;
181
181
  projectId?: string;
182
+ workspaceId?: never;
183
+ outsideProject?: never;
182
184
  title?: string;
183
185
  storage?: "sqlite" | "memory";
184
186
  configuration?: SessionConfigurationInput;
@@ -196,7 +198,18 @@ type CreateSessionByProjectInput = Omit<CreateClientSessionInput$1, "cwd" | "pro
196
198
  projectId: string;
197
199
  cwd?: never;
198
200
  };
199
- type SessionCreationInput = CreateClientSessionInput$1 | CreateSessionByProjectInput;
201
+ /** Use a desktop workspace selection or let the daemon allocate a new directory. */
202
+ type CreateSessionWithDirectoryInput = Omit<CreateClientSessionInput$1, "cwd" | "projectId" | "workspaceId" | "outsideProject"> & {
203
+ cwd?: never;
204
+ projectId?: never;
205
+ } & ({
206
+ workspaceId: string;
207
+ outsideProject?: never;
208
+ } | {
209
+ outsideProject: true;
210
+ workspaceId?: never;
211
+ });
212
+ type SessionCreationInput = CreateClientSessionInput$1 | CreateSessionByProjectInput | CreateSessionWithDirectoryInput;
200
213
  type DispatchedSessionCreationRequest = SessionCreationInput & {
201
214
  id: string;
202
215
  requestId: string;
@@ -2633,6 +2646,17 @@ interface PluginGitInstallInput extends PluginGitPreviewInput {
2633
2646
 
2634
2647
  /** Public Agent lifecycle request, response and synchronization types. */
2635
2648
 
2649
+ /** Gateway credentials supplied by the application for its Agent sessions. */
2650
+ interface ClientModelConnection {
2651
+ baseUrl: string;
2652
+ apiKey: string;
2653
+ apiFormat: "openai";
2654
+ }
2655
+ type ClientModelProvider = ModelProviderInfo & {
2656
+ connection?: ClientModelConnection | ((options: {
2657
+ signal?: AbortSignal;
2658
+ }) => Promise<ClientModelConnection>);
2659
+ };
2636
2660
  /** `BobanNomiClient` 构造参数。 */
2637
2661
  interface BobanNomiClientOptions {
2638
2662
  /** daemon HTTP 根地址,例如 `http://127.0.0.1:8787`。 */
@@ -2641,10 +2665,10 @@ interface BobanNomiClientOptions {
2641
2665
  token?: string;
2642
2666
  /** 可注入的 fetch,便于测试或自定义传输。 */
2643
2667
  fetch?: typeof fetch;
2644
- /** Optional display catalog. It supplies models.list() without configuring the daemon. */
2645
- providers?: readonly ModelProviderInfo[] | ((options: {
2668
+ /** App-provided catalog and optional connections. Reading the catalog is side-effect-free. */
2669
+ providers?: readonly ClientModelProvider[] | ((options: {
2646
2670
  signal?: AbortSignal;
2647
- }) => Promise<readonly ModelProviderInfo[]>);
2671
+ }) => Promise<readonly ClientModelProvider[]>);
2648
2672
  }
2649
2673
  interface BobanNomiServerHealth {
2650
2674
  ok: true;
@@ -2861,6 +2885,8 @@ declare class ProtocolClient {
2861
2885
  capabilities(options?: CapabilitiesOptions): Promise<ServerCapabilities>;
2862
2886
  }
2863
2887
 
2888
+ type PrepareModelConnection = (sessionId: string, selection: SessionConfigurationInput["model"], signal?: AbortSignal) => Promise<string | undefined>;
2889
+
2864
2890
  declare class EventResource {
2865
2891
  private readonly transport;
2866
2892
  private readonly sse;
@@ -2909,7 +2935,7 @@ declare function selectSessionMessagesWithParts(bucket: SessionBucket | undefine
2909
2935
  * Default display view: hides superseded parts and drops assistant messages that
2910
2936
  * have no visible parts left. The raw state keeps the diagnostic records.
2911
2937
  */
2912
- declare function selectVisibleSessionMessagesWithParts(bucket: SessionBucket | undefined): SessionMessageWithParts[];
2938
+ declare function getVisibleSessionMessages(bucket: SessionBucket | undefined): SessionMessageWithParts[];
2913
2939
  declare function selectSessionInputs(bucket: SessionBucket | undefined): SessionInputRecord[];
2914
2940
  declare function selectSessionOrderedMessages(bucket: SessionBucket | undefined): SessionMessageRecord[];
2915
2941
  declare function selectSessionParts(bucket: SessionBucket | undefined): SessionMessagePartRecord[];
@@ -3076,7 +3102,8 @@ interface SessionHandle {
3076
3102
  /** Find, prepare, and create sessions on one daemon connection. */
3077
3103
  declare class SessionResource {
3078
3104
  #private;
3079
- constructor(transport: HttpTransport, events?: EventResource);
3105
+ private readonly prepareModel?;
3106
+ constructor(transport: HttpTransport, events?: EventResource, prepareModel?: PrepareModelConnection | undefined);
3080
3107
  /** Bind a session ID locally. Operations use this resource's daemon connection when called. */
3081
3108
  byId(sessionId: string): SessionHandle;
3082
3109
  /** `GET /sessions/search` - search saved conversation text without opening it. */
@@ -3120,8 +3147,8 @@ declare class SessionResource {
3120
3147
  }): Promise<SessionCreationReceipt | null>;
3121
3148
  }
3122
3149
 
3123
- /** Generate a caller-stable id for one prompt admission attempt. */
3124
- declare function createPromptRequestId(): string;
3150
+ /** Generate an ID to save before sending a session request that may need recovery. */
3151
+ declare function createSessionRequestId(): string;
3125
3152
 
3126
3153
  declare class AttachmentResource {
3127
3154
  private readonly transport;
@@ -4082,11 +4109,11 @@ declare class UnsupportedSessionEventSchemaVersionError extends Error {
4082
4109
  constructor(event: SessionEventRecord);
4083
4110
  }
4084
4111
  /** 空客户端状态,作为 replay/hydrate 起点。 */
4085
- declare function createInitialClientState(): BobanNomiClientState;
4112
+ declare function createClientState(): BobanNomiClientState;
4086
4113
  /** 按序批量应用事件。 */
4087
4114
  declare function applyEvents(state: BobanNomiClientState, events: Iterable<SessionEventRecord>): BobanNomiClientState;
4088
4115
  /** Replace one session bucket with an atomic server snapshot. */
4089
- declare function applySessionSnapshot(state: BobanNomiClientState, snapshot: AgentSessionStateSnapshot): BobanNomiClientState;
4116
+ declare function replaceSessionState(state: BobanNomiClientState, snapshot: AgentSessionStateSnapshot): BobanNomiClientState;
4090
4117
  /**
4091
4118
  * 应用单条事件。已见过的 `seq` 直接返回原 state(引用相等,便于 live 去重)。
4092
4119
  */
@@ -4133,5 +4160,5 @@ declare function isWorkMode(value: unknown): value is WorkMode;
4133
4160
  declare function readSessionRuntimeConfig(session: SessionRecord, defaults?: Partial<SessionRuntimeConfig>): SessionRuntimeConfig;
4134
4161
  declare function patchSessionRuntimeMetadata(metadata: Record<string, unknown>, patch: SessionRuntimeConfigPatch): Record<string, unknown>;
4135
4162
 
4136
- export { AttachmentResource, BobanNomiApiError, BobanNomiClient, CURRENT_PROTOCOL_VERSION, ChannelResource, CommandResource, ContextResource, DiagnosticResource, EventResource, GitResource, HookResource, HttpTransport, IncompatibleProtocolError, MaintenanceResource, McpResource, McpServersResource, MemoryResource, PermissionResource, PluginMarketplaceResource, PluginResource, ProjectResource, ProtocolClient, ProtocolValidationError, ScheduleResource, SessionResource, SessionSyncController, SettingsResource, SseTransport, TerminalResource, UnsupportedSessionEventSchemaVersionError, WorktreeResource, applyEvent, applyEvents, applySessionSnapshot, attachmentRangeHeader, checkProtocolCompatibility, createInitialClientState, createPromptRequestId, hydrateState, isSupersededModelPart, isWorkMode, normalizeApprovalMode, normalizeDaemonBaseUrl, parseCreateSessionGoalInput, parseGoalActionInput, parseMcpCallResultData, parseUpdateSessionGoalInput, patchSessionRuntimeMetadata, readPluginUiInstance, readRuntimeMetadata, readSessionModelRetryState, readSessionModelUsage, readSessionRuntimeConfig, readWorkspaceChangesMetadata, responseArray, responseField, selectFirstPendingPermission, selectSessionInputs, selectSessionMessagesWithParts, selectSessionModelRetry, selectSessionModelUsage, selectSessionOrderedMessages, selectSessionParts, selectSessionPermissions, selectSessionRuns, selectSessionTasks, selectVisibleSessionMessagesWithParts, streamServerSentEvents, supportsFeature, syncEvents };
4137
- export type { AdmitClientPromptInput, AdmitPromptAttachmentInput, AgentEnvironmentCapabilities, AgentPersonaInfo, ApprovalMode, ApprovalReviewRecord, AttachmentAssetRecord, AttachmentStorageGcResult, AttachmentStorageIssue, AttachmentStorageRepairResult, AttachmentStorageReport, AuthStatus, BobanNomiClientOptions, BobanNomiClientState, BobanNomiServerHealth, CancelQueuedClientPromptInput, CancelQueuedPromptResponse, CancelResponseMode, ChannelConnectorRuntimeStatus, ChannelDeliveryRecord, ChannelDeliveryStatus, ChannelDenialNotice, ChannelDomain, ChannelQuery, ChannelRuntimeControlInput, ChannelRuntimeState, ChannelRuntimeStatus, ChannelStatusSnapshot, CleanupCandidate, CleanupPreview, CleanupResult, ClearMemoryInput, ClientProtocolSupport, CommandCatalogEntry, CommandKind, CommandSelection, CommandSource, ConfigureClientSessionInput, ContextBucketId, ContextUsageBucket, ContextUsageSnapshot, ContextUsageTip, ContextUsageTipCode, CreateBackgroundShellInput, CreateBackgroundShellResult, CreateClientSessionInput, CreateScheduledTaskInput, CreateSessionByProjectInput, CreateSessionGoalInput, CustomModelProviderInput, DaemonRestartPreview, DiagnosticExecutionQuery, DispatchedSessionCreation, DispatchedSessionCreationRequest, DownloadAttachmentOptions, DraftComposerOptions, DraftComposerTarget, DurableChannelMessageInput, DurableChannelMessageResult, EditLatestClientPromptInput, EventSyncOptions, ExecutionInstructions, ExpectedModelConnection, ExternalConversationRecord, FactReplacementResult, FeishuAllowInput, FeishuChannelSnapshot, FeishuComposedSnapshot, FeishuConnectInput, FeishuPatchInput, FeishuRegistrationSnapshot, FeishuRegistrationStartInput, FeishuRegistrationState, ForkClientSessionInput, GlobalSettingsPatch, GoalActionInput, GoalExternalWait, GoalStopReason, HookInfo, HostDiagnosticSnapshots, HttpRequestOptions, HttpTransportOptions, InputDelivery, InterruptSessionResponse, JobCancelReceipt, JobCapabilities, JobInputReceipt, JobKind, JobListResult, JobReadResult, JobSnapshot, JobStatus, JobTarget, JobWaitResult, JsonValue, ListClientMessagePartsOptions, ListCommandsOptions, ListEventsOptions, ListMessagePartsOptions, ListMessagesOptions, ListPermissionsOptions, ListProjectsOptions, ListSessionJobsOptions, ListSessionsOptions, MaintenanceBackupManifest, MaintenanceBackupResult, MarketplaceAddSourceRequest, MarketplaceCancelRequest, MarketplaceCancelResponse, MarketplaceCatalog, MarketplaceCatalogRequest, MarketplaceEntry, MarketplaceInstallInput, MarketplaceInstallRequest, MarketplaceOperation, MarketplacePreview, MarketplacePreviewRequest, MarketplaceProvenance, MarketplaceSelection, MarketplaceSource, MarketplaceSourceEnabledRequest, MarketplaceSourceView, MarketplaceSourcesResponse, McpConfigOperationResult, McpManagedServerConfig, McpManagedServerSummary, McpOAuthLoginInput, McpOAuthLoginResponse, McpOAuthStatusSnapshot, McpRuntimeStatus, McpRuntimeSyncResult, McpServerRuntimeRef, McpServerStatus, MemoryEntryRecord, MemoryListResponse, MemoryRevision, ModelInfo, ModelProviderConnection, ModelProviderInfo, ModelProviderRequest, OAuthOperationEvent, OAuthOperationView, OutputStyleInfo, PermissionRequestRecord, PermissionStatus, PluginArchiveError, PluginArchiveInstallInput, PluginArchivePreview, PluginArchivePreviewInput, PluginGitInstallInput, PluginGitPreview, PluginGitPreviewInput, PluginInfo, PluginListResult, PluginLocalInstallInput, PluginLocalPreview, PluginLocalPreviewInput, PluginRuntimeStatus, PluginUiInstanceRecord, PluginUiInventory, ProjectFactRecord, ProjectRecord, PromoteQueuedClientPromptInput, PromoteQueuedPromptResponse, PromptResponse, ProtocolCompatibility, ProviderConnectionTestResult, ProviderDefaultsRequest, ProviderDefaultsSnapshot, ProviderInfo, QueuedPromptCancelReceipt, RawRequestOptions, RecordChannelDeliveryInput, ReloadPluginsResponse, RememberSessionResponse, ReplyPermissionInput, ResolvedSessionConfiguration, ResumeInterruptedRunInput, ResumeInterruptedRunResponse, RewindSessionResponse, RunResult, ScheduledRunRecord, ScheduledTaskRecord, ScheduledTaskStatusSummary, SearchSessionsOptions, ServerCapabilities, SessionActivityPage, SessionAttachmentMessagePartRecord, SessionBucket, SessionComposerContext, SessionConfigurationInput, SessionConfigurationOptions, SessionConfigurationResultInput, SessionConfigurationSnapshot, SessionControlOriginal, SessionControlReceipt, SessionControls, SessionCreationInput, SessionCreationReceipt, SessionDirectoryEntry, SessionDirectoryPage, SessionDirectoryResult, SessionEventRecord, SessionExecutionRecord, SessionExportResponse, SessionFileErrorCode, SessionFileFindInput, SessionFileFindOptions, SessionFileInfo, SessionFileListInput, SessionFileListOptions, SessionFileReadInput, SessionFileReadOptions, SessionFileRequestOptions, SessionFileSearchInput, SessionFileSearchMatch, SessionFileSearchOptions, SessionFileStatInput, SessionFindFilesResult, SessionGoal, SessionGoalRequestReceipt, SessionHandle, SessionInputAttachmentRecord, SessionInputRecord, SessionManagementAction, SessionMessagePartRecord, SessionMessageRecord, SessionMessageWithParts, SessionModelRetryState, SessionModelUsageSummary, SessionMutationPublicReceipt, SessionRecord, SessionResourceRevision, SessionRunAttemptRecord, SessionRunRecord, SessionRuntimeConfig, SessionRuntimeConfigPatch, SessionSearchFilesResult, SessionSearchResult, AgentSessionStateSnapshot as SessionStateSnapshot, SessionSyncControllerOptions, SessionTextFileResult, SessionTransformationMessagePartRecord, SessionUsageResponse, SessionUserInputItem, SkillInfo, SkillMarketplaceEntry, SkillMarketplaceInstallInput, SkillProject, SkillSnapshot, SkillSource, StartDreamResponse, StorageCategory, StorageReport, StorageRetentionPolicy, SyncConnectionStatus, SyncEventUpdate, SyncEventsClient, TaskWorktreeRecord, TerminalCreateRequest, TerminalEvent, TerminalReadRequest, TerminalReadResult, TerminalResizeRequest, TerminalRuntime, TerminalSessionInfo, TerminalSessionStatus, TerminalSignal, TerminalSource, TerminalWriteRequest, UpdateMemoryEntryInput, UpdateScheduledTaskInput, UpdateSessionGoalInput, UploadAttachmentInput, UsageFilter, UsagePrice, UsageReport, UsageRequest, UsageSettings, WorkMode, WorkspaceChangeFile, WorkspaceChangesMetadata };
4163
+ export { AttachmentResource, BobanNomiApiError, BobanNomiClient, CURRENT_PROTOCOL_VERSION, ChannelResource, CommandResource, ContextResource, DiagnosticResource, EventResource, GitResource, HookResource, HttpTransport, IncompatibleProtocolError, MaintenanceResource, McpResource, McpServersResource, MemoryResource, PermissionResource, PluginMarketplaceResource, PluginResource, ProjectResource, ProtocolClient, ProtocolValidationError, ScheduleResource, SessionResource, SessionSyncController, SettingsResource, SseTransport, TerminalResource, UnsupportedSessionEventSchemaVersionError, WorktreeResource, applyEvent, applyEvents, attachmentRangeHeader, checkProtocolCompatibility, createClientState, createSessionRequestId, getVisibleSessionMessages, hydrateState, isSupersededModelPart, isWorkMode, normalizeApprovalMode, normalizeDaemonBaseUrl, parseCreateSessionGoalInput, parseGoalActionInput, parseMcpCallResultData, parseUpdateSessionGoalInput, patchSessionRuntimeMetadata, readPluginUiInstance, readRuntimeMetadata, readSessionModelRetryState, readSessionModelUsage, readSessionRuntimeConfig, readWorkspaceChangesMetadata, replaceSessionState, responseArray, responseField, selectFirstPendingPermission, selectSessionInputs, selectSessionMessagesWithParts, selectSessionModelRetry, selectSessionModelUsage, selectSessionOrderedMessages, selectSessionParts, selectSessionPermissions, selectSessionRuns, selectSessionTasks, streamServerSentEvents, supportsFeature, syncEvents };
4164
+ export type { AdmitClientPromptInput, AdmitPromptAttachmentInput, AgentEnvironmentCapabilities, AgentPersonaInfo, ApprovalMode, ApprovalReviewRecord, AttachmentAssetRecord, AttachmentStorageGcResult, AttachmentStorageIssue, AttachmentStorageRepairResult, AttachmentStorageReport, AuthStatus, BobanNomiClientOptions, BobanNomiClientState, BobanNomiServerHealth, CancelQueuedClientPromptInput, CancelQueuedPromptResponse, CancelResponseMode, ChannelConnectorRuntimeStatus, ChannelDeliveryRecord, ChannelDeliveryStatus, ChannelDenialNotice, ChannelDomain, ChannelQuery, ChannelRuntimeControlInput, ChannelRuntimeState, ChannelRuntimeStatus, ChannelStatusSnapshot, CleanupCandidate, CleanupPreview, CleanupResult, ClearMemoryInput, ClientModelConnection, ClientModelProvider, ClientProtocolSupport, CommandCatalogEntry, CommandKind, CommandSelection, CommandSource, ConfigureClientSessionInput, ContextBucketId, ContextUsageBucket, ContextUsageSnapshot, ContextUsageTip, ContextUsageTipCode, CreateBackgroundShellInput, CreateBackgroundShellResult, CreateClientSessionInput, CreateScheduledTaskInput, CreateSessionByProjectInput, CreateSessionGoalInput, CreateSessionWithDirectoryInput, CustomModelProviderInput, DaemonRestartPreview, DiagnosticExecutionQuery, DispatchedSessionCreation, DispatchedSessionCreationRequest, DownloadAttachmentOptions, DraftComposerOptions, DraftComposerTarget, DurableChannelMessageInput, DurableChannelMessageResult, EditLatestClientPromptInput, EventSyncOptions, ExecutionInstructions, ExpectedModelConnection, ExternalConversationRecord, FactReplacementResult, FeishuAllowInput, FeishuChannelSnapshot, FeishuComposedSnapshot, FeishuConnectInput, FeishuPatchInput, FeishuRegistrationSnapshot, FeishuRegistrationStartInput, FeishuRegistrationState, ForkClientSessionInput, GlobalSettingsPatch, GoalActionInput, GoalExternalWait, GoalStopReason, HookInfo, HostDiagnosticSnapshots, HttpRequestOptions, HttpTransportOptions, InputDelivery, InterruptSessionResponse, JobCancelReceipt, JobCapabilities, JobInputReceipt, JobKind, JobListResult, JobReadResult, JobSnapshot, JobStatus, JobTarget, JobWaitResult, JsonValue, ListClientMessagePartsOptions, ListCommandsOptions, ListEventsOptions, ListMessagePartsOptions, ListMessagesOptions, ListPermissionsOptions, ListProjectsOptions, ListSessionJobsOptions, ListSessionsOptions, MaintenanceBackupManifest, MaintenanceBackupResult, MarketplaceAddSourceRequest, MarketplaceCancelRequest, MarketplaceCancelResponse, MarketplaceCatalog, MarketplaceCatalogRequest, MarketplaceEntry, MarketplaceInstallInput, MarketplaceInstallRequest, MarketplaceOperation, MarketplacePreview, MarketplacePreviewRequest, MarketplaceProvenance, MarketplaceSelection, MarketplaceSource, MarketplaceSourceEnabledRequest, MarketplaceSourceView, MarketplaceSourcesResponse, McpConfigOperationResult, McpManagedServerConfig, McpManagedServerSummary, McpOAuthLoginInput, McpOAuthLoginResponse, McpOAuthStatusSnapshot, McpRuntimeStatus, McpRuntimeSyncResult, McpServerRuntimeRef, McpServerStatus, MemoryEntryRecord, MemoryListResponse, MemoryRevision, ModelInfo, ModelProviderConnection, ModelProviderInfo, ModelProviderRequest, OAuthOperationEvent, OAuthOperationView, OutputStyleInfo, PermissionRequestRecord, PermissionStatus, PluginArchiveError, PluginArchiveInstallInput, PluginArchivePreview, PluginArchivePreviewInput, PluginGitInstallInput, PluginGitPreview, PluginGitPreviewInput, PluginInfo, PluginListResult, PluginLocalInstallInput, PluginLocalPreview, PluginLocalPreviewInput, PluginRuntimeStatus, PluginUiInstanceRecord, PluginUiInventory, ProjectFactRecord, ProjectRecord, PromoteQueuedClientPromptInput, PromoteQueuedPromptResponse, PromptResponse, ProtocolCompatibility, ProviderConnectionTestResult, ProviderDefaultsRequest, ProviderDefaultsSnapshot, ProviderInfo, QueuedPromptCancelReceipt, RawRequestOptions, RecordChannelDeliveryInput, ReloadPluginsResponse, RememberSessionResponse, ReplyPermissionInput, ResolvedSessionConfiguration, ResumeInterruptedRunInput, ResumeInterruptedRunResponse, RewindSessionResponse, RunResult, ScheduledRunRecord, ScheduledTaskRecord, ScheduledTaskStatusSummary, SearchSessionsOptions, ServerCapabilities, SessionActivityPage, SessionAttachmentMessagePartRecord, SessionBucket, SessionComposerContext, SessionConfigurationInput, SessionConfigurationOptions, SessionConfigurationResultInput, SessionConfigurationSnapshot, SessionControlOriginal, SessionControlReceipt, SessionControls, SessionCreationInput, SessionCreationReceipt, SessionDirectoryEntry, SessionDirectoryPage, SessionDirectoryResult, SessionEventRecord, SessionExecutionRecord, SessionExportResponse, SessionFileErrorCode, SessionFileFindInput, SessionFileFindOptions, SessionFileInfo, SessionFileListInput, SessionFileListOptions, SessionFileReadInput, SessionFileReadOptions, SessionFileRequestOptions, SessionFileSearchInput, SessionFileSearchMatch, SessionFileSearchOptions, SessionFileStatInput, SessionFindFilesResult, SessionGoal, SessionGoalRequestReceipt, SessionHandle, SessionInputAttachmentRecord, SessionInputRecord, SessionManagementAction, SessionMessagePartRecord, SessionMessageRecord, SessionMessageWithParts, SessionModelRetryState, SessionModelUsageSummary, SessionMutationPublicReceipt, SessionRecord, SessionResourceRevision, SessionRunAttemptRecord, SessionRunRecord, SessionRuntimeConfig, SessionRuntimeConfigPatch, SessionSearchFilesResult, SessionSearchResult, AgentSessionStateSnapshot as SessionStateSnapshot, SessionSyncControllerOptions, SessionTextFileResult, SessionTransformationMessagePartRecord, SessionUsageResponse, SessionUserInputItem, SkillInfo, SkillMarketplaceEntry, SkillMarketplaceInstallInput, SkillProject, SkillSnapshot, SkillSource, StartDreamResponse, StorageCategory, StorageReport, StorageRetentionPolicy, SyncConnectionStatus, SyncEventUpdate, SyncEventsClient, TaskWorktreeRecord, TerminalCreateRequest, TerminalEvent, TerminalReadRequest, TerminalReadResult, TerminalResizeRequest, TerminalRuntime, TerminalSessionInfo, TerminalSessionStatus, TerminalSignal, TerminalSource, TerminalWriteRequest, UpdateMemoryEntryInput, UpdateScheduledTaskInput, UpdateSessionGoalInput, UploadAttachmentInput, UsageFilter, UsagePrice, UsageReport, UsageRequest, UsageSettings, WorkMode, WorkspaceChangeFile, WorkspaceChangesMetadata };
package/dist/index.js CHANGED
@@ -909,16 +909,25 @@ function validateSessionId(id2) {
909
909
  }
910
910
  function parseCreateSessionRequest(value) {
911
911
  const body = record3(value);
912
- fields2(body, ["id", "requestId", "cwd", "projectId", "title", "storage", "configuration", "optionsRevision", "metadata"]);
912
+ fields2(body, ["id", "requestId", "cwd", "projectId", "workspaceId", "outsideProject", "title", "storage", "configuration", "optionsRevision", "metadata"]);
913
913
  const cwd = optionalString2(body, "cwd");
914
+ const workspaceId = optionalString2(body, "workspaceId");
915
+ const outsideProject = optionalBoolean2(body, "outsideProject");
914
916
  const id2 = validateSessionId(requiredString2(body, "id"));
915
917
  const requestId = requiredString2(body, "requestId");
916
918
  if (cwd !== void 0 && !cwd.trim()) throw new ProtocolValidationError("cwd cannot be empty", "cwd");
917
919
  if (!requestId.trim()) throw new ProtocolValidationError("requestId cannot be empty", "requestId");
918
- const target = cwd === void 0 ? { projectId: requiredString2(body, "projectId") } : { cwd };
919
- if (cwd === void 0 && !target.projectId?.trim()) throw new ProtocolValidationError("projectId cannot be empty", "projectId");
920
+ if (workspaceId !== void 0 && !workspaceId.trim()) throw new ProtocolValidationError("workspaceId cannot be empty", "workspaceId");
921
+ if (outsideProject === false || outsideProject === true && workspaceId !== void 0)
922
+ throw new ProtocolValidationError("outsideProject must be true and used without workspaceId", "outsideProject");
923
+ if ((outsideProject === true || workspaceId !== void 0) && (cwd !== void 0 || body.projectId !== void 0))
924
+ throw new ProtocolValidationError("Supply one session directory choice", outsideProject === true ? "outsideProject" : "workspaceId");
925
+ const projectId = optionalString2(body, "projectId");
926
+ if (cwd === void 0 && outsideProject === void 0 && workspaceId === void 0 && !projectId?.trim())
927
+ throw new ProtocolValidationError("projectId cannot be empty", "projectId");
928
+ const target = workspaceId !== void 0 ? { workspaceId } : outsideProject === true ? { outsideProject } : cwd !== void 0 ? { cwd, ...projectId === void 0 ? {} : { projectId } } : { projectId };
920
929
  const result = { id: id2, requestId, ...target };
921
- for (const key of ["projectId", "title", "optionsRevision"]) if (body[key] !== void 0) result[key] = optionalString2(body, key);
930
+ for (const key of ["title", "optionsRevision"]) if (body[key] !== void 0) result[key] = optionalString2(body, key);
922
931
  if (body.storage !== void 0) result.storage = optionalEnum2(body, "storage", ["sqlite", "memory"]);
923
932
  if (body.configuration !== void 0) result.configuration = parseSessionConfiguration2(body.configuration);
924
933
  if (body.metadata !== void 0) result.metadata = appMetadata(optionalRecord(body, "metadata"));
@@ -2958,13 +2967,13 @@ var ScheduleResource = class {
2958
2967
  };
2959
2968
 
2960
2969
  // src/resources/session/session-request-id.ts
2961
- var promptRequestCounter = 0;
2962
- function createPromptRequestId() {
2970
+ var sessionRequestCounter = 0;
2971
+ function createSessionRequestId() {
2963
2972
  if (typeof globalThis.crypto?.randomUUID === "function") {
2964
2973
  return globalThis.crypto.randomUUID();
2965
2974
  }
2966
- promptRequestCounter += 1;
2967
- return `prompt-${Date.now().toString(36)}-${promptRequestCounter.toString(36)}`;
2975
+ sessionRequestCounter += 1;
2976
+ return `prompt-${Date.now().toString(36)}-${sessionRequestCounter.toString(36)}`;
2968
2977
  }
2969
2978
 
2970
2979
  // src/resources/session/session-configuration-requests.ts
@@ -2986,18 +2995,25 @@ async function getDraftComposerOptions(transport, input, options = {}) {
2986
2995
  }
2987
2996
  return result;
2988
2997
  }
2989
- async function create(transport, input, options = {}) {
2998
+ async function create(transport, input, options = {}, prepareModel) {
2990
2999
  const body = parseCreateSessionRequest({
2991
3000
  ...input,
2992
- id: input.id ?? createPromptRequestId(),
2993
- requestId: input.requestId ?? createPromptRequestId()
3001
+ id: input.id ?? createSessionRequestId(),
3002
+ requestId: input.requestId ?? createSessionRequestId()
2994
3003
  });
2995
- if (body.cwd === void 0) await requireDaemonFeature(transport, "projectSessionCreation", options.signal);
3004
+ if (body.workspaceId !== void 0 || body.outsideProject)
3005
+ await requireDaemonFeature(transport, "sessionDirectoryCreation", options.signal);
3006
+ else if (body.cwd === void 0) await requireDaemonFeature(transport, "projectSessionCreation", options.signal);
3007
+ const modelConnection = await prepareModel?.(body.id, body.configuration?.model, options.signal);
2996
3008
  const response = await transport.request(
2997
3009
  "/sessions",
2998
3010
  {
2999
3011
  method: "POST",
3000
3012
  body,
3013
+ headers: {
3014
+ ...body.workspaceId === void 0 ? {} : { "x-bobannomi-workspace-id": body.workspaceId },
3015
+ ...modelConnection === void 0 ? {} : { "x-bobannomi-model-connection": modelConnection }
3016
+ },
3001
3017
  signal: options.signal
3002
3018
  }
3003
3019
  );
@@ -3011,7 +3027,9 @@ async function getConfigurationOptions(transport, input, options = {}) {
3011
3027
  );
3012
3028
  }
3013
3029
  async function getCreationResult(transport, input, options = {}) {
3014
- if (input.original.cwd === void 0) await requireDaemonFeature(transport, "projectSessionCreation", options.signal);
3030
+ if (input.original.workspaceId !== void 0 || input.original.outsideProject)
3031
+ await requireDaemonFeature(transport, "sessionDirectoryCreation", options.signal);
3032
+ else if (input.original.cwd === void 0) await requireDaemonFeature(transport, "projectSessionCreation", options.signal);
3015
3033
  return transport.request("/sessions/creation-result", {
3016
3034
  method: "POST",
3017
3035
  body: input,
@@ -3025,11 +3043,17 @@ async function getConfiguration(transport, sessionId, options = {}) {
3025
3043
  );
3026
3044
  return decodeSessionConfigurationSnapshot(value);
3027
3045
  }
3028
- async function configure(transport, sessionId, input, options = {}) {
3046
+ async function configure(transport, sessionId, input, options = {}, prepareModel) {
3029
3047
  const body = parseConfigureSessionRequest(input);
3048
+ const modelConnection = await prepareModel?.(sessionId, body.configuration.model, options.signal);
3030
3049
  const response = await transport.requestUnknown(
3031
3050
  `/sessions/${encodeURIComponent(sessionId)}/configure`,
3032
- { method: "POST", body, signal: options.signal }
3051
+ {
3052
+ method: "POST",
3053
+ body,
3054
+ signal: options.signal,
3055
+ ...modelConnection === void 0 ? {} : { headers: { "x-bobannomi-model-connection": modelConnection } }
3056
+ }
3033
3057
  );
3034
3058
  return decodeSessionConfigurationReceipt(response, {
3035
3059
  sessionId,
@@ -3142,7 +3166,7 @@ function selectSessionMessagesWithParts(bucket) {
3142
3166
  parts: [...bucket.partsByMessageId[message.id] ?? []].sort((a, b) => a.seq - b.seq)
3143
3167
  }));
3144
3168
  }
3145
- function selectVisibleSessionMessagesWithParts(bucket) {
3169
+ function getVisibleSessionMessages(bucket) {
3146
3170
  return selectSessionMessagesWithParts(bucket).map(({ message, parts }) => ({
3147
3171
  message,
3148
3172
  parts: parts.filter((part) => !isSupersededModelPart(part))
@@ -3215,7 +3239,7 @@ var UnsupportedSessionEventSchemaVersionError = class extends Error {
3215
3239
  };
3216
3240
  }
3217
3241
  };
3218
- function createInitialClientState() {
3242
+ function createClientState() {
3219
3243
  return {
3220
3244
  sessions: {},
3221
3245
  sessionOrder: [],
@@ -3231,7 +3255,7 @@ function applyEvents(state, events) {
3231
3255
  for (const event of events) next = applyEvent(next, event);
3232
3256
  return next;
3233
3257
  }
3234
- function applySessionSnapshot(state, snapshot) {
3258
+ function replaceSessionState(state, snapshot) {
3235
3259
  const knownCursor = state.snapshotCursorBySession[snapshot.session.id] ?? 0;
3236
3260
  if (snapshot.cursor < knownCursor) return state;
3237
3261
  if (Object.values(state.eventsBySeq).some((event) => event.sessionId === snapshot.session.id && event.seq > snapshot.cursor)) return state;
@@ -3589,7 +3613,7 @@ function applySessionStreamEvent(state, event) {
3589
3613
  }
3590
3614
  function applySessionStreamSnapshot(state, snapshot) {
3591
3615
  if (snapshot.cursor < state.lastSeq) return state;
3592
- return { ...applySessionSnapshot(state, snapshot), eventsBySeq: {} };
3616
+ return { ...replaceSessionState(state, snapshot), eventsBySeq: {} };
3593
3617
  }
3594
3618
 
3595
3619
  // src/state/sync.ts
@@ -3597,7 +3621,7 @@ var DEFAULT_RECONNECT_DELAY_MS = (attempt) => Math.min(3e4, 250 * 2 ** Math.max(
3597
3621
  var DEFAULT_SESSION_IDLE_TIMEOUT_MS = 6e4;
3598
3622
  var EVENT_REPLAY_PAGE_SIZE = 128;
3599
3623
  function hydrateState(events) {
3600
- return applyEvents(createInitialClientState(), events);
3624
+ return applyEvents(createClientState(), events);
3601
3625
  }
3602
3626
  async function* syncEvents(client, options = {}) {
3603
3627
  yield* runEventSync(client, {
@@ -3607,7 +3631,7 @@ async function* syncEvents(client, options = {}) {
3607
3631
  idleTimeoutMs: options.idleTimeoutMs ?? DEFAULT_SESSION_IDLE_TIMEOUT_MS
3608
3632
  });
3609
3633
  }
3610
- async function* runEventSync(client, options, initialState = createInitialClientState(), onLiveEvent) {
3634
+ async function* runEventSync(client, options, initialState = createClientState(), onLiveEvent) {
3611
3635
  let state = initialState;
3612
3636
  let cursor = Math.max(0, options.cursor ?? 0, state.lastSeq);
3613
3637
  let attempt = 0;
@@ -3622,7 +3646,7 @@ async function* runEventSync(client, options, initialState = createInitialClient
3622
3646
  partView: options.partView
3623
3647
  });
3624
3648
  if (signal?.aborted) return;
3625
- const next = initial ? applySessionSnapshot(state, snapshot) : applySessionStreamSnapshot(state, snapshot);
3649
+ const next = initial ? replaceSessionState(state, snapshot) : applySessionStreamSnapshot(state, snapshot);
3626
3650
  state = Object.keys(next.eventsBySeq).length ? { ...next, eventsBySeq: {} } : next;
3627
3651
  cursor = Math.max(cursor, snapshot.cursor, state.lastSeq);
3628
3652
  };
@@ -3732,7 +3756,7 @@ async function waitForRun(client, options) {
3732
3756
  if (!run || run.status === "pending" || run.status === "running") continue;
3733
3757
  return {
3734
3758
  run,
3735
- messages: selectVisibleSessionMessagesWithParts(bucket).filter((item) => item.message.runId === options.runId)
3759
+ messages: getVisibleSessionMessages(bucket).filter((item) => item.message.runId === options.runId)
3736
3760
  };
3737
3761
  }
3738
3762
  options.signal?.throwIfAborted();
@@ -3926,7 +3950,7 @@ async function admitPrompt(transport, sessionId, input, options = {}) {
3926
3950
  `/sessions/${encodeURIComponent(sessionId)}/prompts`,
3927
3951
  {
3928
3952
  method: "POST",
3929
- body: { ...input, expectedModelConnection, id: input.id ?? createPromptRequestId() },
3953
+ body: { ...input, expectedModelConnection, id: input.id ?? createSessionRequestId() },
3930
3954
  signal: options.signal
3931
3955
  }
3932
3956
  );
@@ -3978,7 +4002,7 @@ async function resumeInterruptedRun(transport, sessionId, runId, input = {}, opt
3978
4002
  `/sessions/${encodeURIComponent(sessionId)}/runs/${encodeURIComponent(runId)}/resume`,
3979
4003
  {
3980
4004
  method: "POST",
3981
- body: { ...input, id: input.id ?? createPromptRequestId() },
4005
+ body: { ...input, id: input.id ?? createSessionRequestId() },
3982
4006
  signal: options.signal
3983
4007
  }
3984
4008
  );
@@ -3995,7 +4019,7 @@ async function interrupt(transport, sessionId, options = {}) {
3995
4019
  }
3996
4020
 
3997
4021
  // src/resources/session/session-handle.ts
3998
- function createSessionHandle(transport, syncClient, management, sessionId) {
4022
+ function createSessionHandle(transport, syncClient, management, sessionId, prepareModel) {
3999
4023
  function cancelQueuedPrompt2(inputId, input, options) {
4000
4024
  return cancelQueuedPrompt(transport, sessionId, inputId, input, options);
4001
4025
  }
@@ -4110,8 +4134,8 @@ function createSessionHandle(transport, syncClient, management, sessionId) {
4110
4134
  method: "POST",
4111
4135
  body: parseForkSessionRequest({
4112
4136
  ...input,
4113
- id: input.id ?? createPromptRequestId(),
4114
- requestId: input.requestId ?? createPromptRequestId()
4137
+ id: input.id ?? createSessionRequestId(),
4138
+ requestId: input.requestId ?? createSessionRequestId()
4115
4139
  }),
4116
4140
  signal: options.signal
4117
4141
  }
@@ -4156,7 +4180,7 @@ function createSessionHandle(transport, syncClient, management, sessionId) {
4156
4180
  return getConfiguration(transport, sessionId, options);
4157
4181
  },
4158
4182
  update(input, options = {}) {
4159
- return configure(transport, sessionId, input, options);
4183
+ return configure(transport, sessionId, input, options, prepareModel);
4160
4184
  },
4161
4185
  getResult(input, options = {}) {
4162
4186
  return getConfigurationResult(transport, sessionId, input, options);
@@ -4263,17 +4287,19 @@ function createSessionHandle(transport, syncClient, management, sessionId) {
4263
4287
 
4264
4288
  // src/resources/session/session-resource.ts
4265
4289
  var SessionResource = class {
4266
- #management;
4267
- #events;
4268
- #transport;
4269
- constructor(transport, events) {
4290
+ constructor(transport, events, prepareModel) {
4291
+ this.prepareModel = prepareModel;
4270
4292
  this.#transport = transport;
4271
4293
  this.#management = new SessionManagementResource(transport);
4272
4294
  this.#events = events ?? new EventResource(transport, new SseTransport(transport));
4273
4295
  }
4296
+ prepareModel;
4297
+ #management;
4298
+ #events;
4299
+ #transport;
4274
4300
  /** Bind a session ID locally. Operations use this resource's daemon connection when called. */
4275
4301
  byId(sessionId) {
4276
- return createSessionHandle(this.#transport, { sessions: this, events: this.#events }, this.#management, sessionId);
4302
+ return createSessionHandle(this.#transport, { sessions: this, events: this.#events }, this.#management, sessionId, this.prepareModel);
4277
4303
  }
4278
4304
  /** `GET /sessions/search` - search saved conversation text without opening it. */
4279
4305
  async search(options) {
@@ -4304,7 +4330,7 @@ var SessionResource = class {
4304
4330
  }
4305
4331
  /** `POST /sessions` */
4306
4332
  create(input, options = {}) {
4307
- return create(this.#transport, input, options);
4333
+ return create(this.#transport, input, options, this.prepareModel);
4308
4334
  }
4309
4335
  getConfigurationOptions(input, options = {}) {
4310
4336
  return getConfigurationOptions(this.#transport, input, options);
@@ -4427,7 +4453,54 @@ var PermissionResource = class {
4427
4453
 
4428
4454
  // src/resources/runtime/runtime-resource.ts
4429
4455
  function createRuntimeResources(transport, providers) {
4430
- const catalog = typeof providers === "function" || providers === void 0 ? providers : structuredClone([...providers]);
4456
+ const catalog = typeof providers === "function" || providers === void 0 ? providers : providers.map(({ connection, ...provider2 }) => ({
4457
+ ...structuredClone(provider2),
4458
+ connection: typeof connection === "function" ? connection : structuredClone(connection)
4459
+ }));
4460
+ async function load(source, signal) {
4461
+ signal?.throwIfAborted();
4462
+ const value = await waitForRequest(Promise.resolve().then(() => {
4463
+ signal?.throwIfAborted();
4464
+ return source({ signal });
4465
+ }), signal);
4466
+ signal?.throwIfAborted();
4467
+ return value;
4468
+ }
4469
+ function readCatalog(signal) {
4470
+ signal?.throwIfAborted();
4471
+ return typeof catalog === "function" ? load(catalog, signal) : Promise.resolve(catalog ?? []);
4472
+ }
4473
+ const prepareModel = catalog === void 0 ? void 0 : async (sessionId, selection, signal) => {
4474
+ if (!selection) return;
4475
+ const provider2 = (await readCatalog(signal)).find(({ name }) => name === selection.provider);
4476
+ if (!provider2?.connection) return;
4477
+ if (!provider2.models.some(({ id: id2 }) => id2 === selection.model)) throw new Error("The selected model is not in the supplied provider catalog");
4478
+ await requireDaemonFeature(transport, "sessionModelConnections", signal);
4479
+ const connection = typeof provider2.connection === "function" ? await load(provider2.connection, signal) : provider2.connection;
4480
+ const { ref } = await transport.request("/model-connections", {
4481
+ method: "POST",
4482
+ signal,
4483
+ body: {
4484
+ sessionId,
4485
+ provider: {
4486
+ id: provider2.name,
4487
+ displayName: provider2.displayName,
4488
+ baseUrl: connection.baseUrl,
4489
+ apiKey: connection.apiKey,
4490
+ apiFormat: connection.apiFormat,
4491
+ models: provider2.models.map(({ id: id2, label, contextWindow, outputLimit, inputCapabilities }) => ({
4492
+ id: id2,
4493
+ displayName: label,
4494
+ contextWindow,
4495
+ maxOutputTokens: outputLimit,
4496
+ imageInputSupport: inputCapabilities?.image
4497
+ }))
4498
+ }
4499
+ }
4500
+ });
4501
+ if (typeof ref !== "string" || !ref) throw new Error("Invalid prepared model connection");
4502
+ return ref;
4503
+ };
4431
4504
  async function modelProviders(input, options = {}) {
4432
4505
  const response = await transport.request("/providers/manage", { ...options, method: "POST", body: input });
4433
4506
  if (!validModelProviderConnections(response?.providers)) throw new Error("Invalid model provider response");
@@ -4440,19 +4513,14 @@ function createRuntimeResources(transport, providers) {
4440
4513
  return result;
4441
4514
  }
4442
4515
  return {
4516
+ prepareModel,
4443
4517
  models: {
4444
4518
  async list({ signal } = {}) {
4445
4519
  if (catalog === void 0) {
4446
4520
  const response = await transport.request("/models", { signal });
4447
4521
  return response.providers;
4448
4522
  }
4449
- signal?.throwIfAborted();
4450
- const providers2 = typeof catalog === "function" ? await waitForRequest(Promise.resolve().then(() => {
4451
- signal?.throwIfAborted();
4452
- return catalog({ signal });
4453
- }), signal) : catalog;
4454
- signal?.throwIfAborted();
4455
- return structuredClone([...providers2]);
4523
+ return (await readCatalog(signal)).map(({ name, displayName, models }) => structuredClone({ name, displayName, models }));
4456
4524
  }
4457
4525
  },
4458
4526
  agents: {
@@ -5355,7 +5423,7 @@ var BobanNomiClient = class {
5355
5423
  const sse = new SseTransport(transport);
5356
5424
  this.protocol = new ProtocolClient(transport);
5357
5425
  const providers = options instanceof HttpTransport ? void 0 : options.providers;
5358
- const { models, modelProviders, agents, skills } = createRuntimeResources(transport, providers);
5426
+ const { models, modelProviders, agents, skills, prepareModel } = createRuntimeResources(transport, providers);
5359
5427
  this.models = models;
5360
5428
  this.modelProviders = modelProviders;
5361
5429
  this.agents = agents;
@@ -5364,7 +5432,7 @@ var BobanNomiClient = class {
5364
5432
  this.attachments = new AttachmentResource(transport);
5365
5433
  this.permissions = new PermissionResource(transport);
5366
5434
  this.events = new EventResource(transport, sse);
5367
- this.sessions = new SessionResource(transport, this.events);
5435
+ this.sessions = new SessionResource(transport, this.events, prepareModel);
5368
5436
  this.plugins = new PluginResource(transport);
5369
5437
  this.channels = new ChannelResource(transport);
5370
5438
  this.projects = new ProjectResource(transport);
@@ -5393,7 +5461,7 @@ var SessionSyncController = class {
5393
5461
  running = false;
5394
5462
  constructor(options) {
5395
5463
  this.options = { ...options };
5396
- this.state = options.initialState ?? createInitialClientState();
5464
+ this.state = options.initialState ?? createClientState();
5397
5465
  if ((options.cursor ?? 0) > 0 && !options.initialState) {
5398
5466
  throw new Error("A non-zero cursor requires initialState so durable state is not skipped");
5399
5467
  }
@@ -5566,11 +5634,11 @@ export {
5566
5634
  UnsupportedSessionEventSchemaVersionError,
5567
5635
  applyEvent,
5568
5636
  applyEvents,
5569
- applySessionSnapshot,
5570
5637
  attachmentRangeHeader,
5571
5638
  checkProtocolCompatibility,
5572
- createInitialClientState,
5573
- createPromptRequestId,
5639
+ createClientState,
5640
+ createSessionRequestId,
5641
+ getVisibleSessionMessages,
5574
5642
  hydrateState,
5575
5643
  isSupersededModelPart,
5576
5644
  isWorkMode,
@@ -5587,6 +5655,7 @@ export {
5587
5655
  readSessionModelUsage,
5588
5656
  readSessionRuntimeConfig,
5589
5657
  readWorkspaceChangesMetadata,
5658
+ replaceSessionState,
5590
5659
  responseArray2 as responseArray,
5591
5660
  responseField,
5592
5661
  selectFirstPendingPermission,
@@ -5599,7 +5668,6 @@ export {
5599
5668
  selectSessionPermissions,
5600
5669
  selectSessionRuns,
5601
5670
  selectSessionTasks,
5602
- selectVisibleSessionMessagesWithParts,
5603
5671
  streamServerSentEvents,
5604
5672
  supportsFeature,
5605
5673
  syncEvents