@otto-code/client 0.6.6 → 0.6.7

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.
@@ -1,10 +1,10 @@
1
1
  import type { z } from "zod";
2
2
  import { type ClientCapability } from "@otto-code/protocol/client-capabilities";
3
3
  import { AgentRefreshedStatusPayloadSchema, CheckoutRenameBranchResponseSchema, RenameTerminalResponseSchema, RestartRequestedStatusPayloadSchema, ShutdownRequestedStatusPayloadSchema, DaemonUpdateResponseSchema, type ServerInfoStatusPayload } from "@otto-code/protocol/messages";
4
- import type { AgentStreamEventPayload, AgentSnapshotPayload, ProjectPlacementPayload, AgentPermissionResolvedMessage, CreateAgentRequestMessage, CreateOttoWorktreeRequest, CodeListFilesResponse, CodeSymbolLocation, FileDownloadTokenResponse, FileEol, FileReplaceFileResult, FileReplaceRequest, FileReplaceResponse, FileSearchResultPayload, FileSearchSummary, FileUploadResponse, FileExplorerResponse, FileWatchEventPayload, FileWriteResult, FetchAgentTimelineResponseMessage, AgentForkContextResponseMessage, GitSetupOptions, CheckoutStatusResponse, CheckoutCommitResponse, CheckoutGitCommitResponse, CheckoutGitCommitAgentResponse, CheckoutGitRollbackResponse, CheckoutGitFileHistoryResponse, CheckoutGitFileCommitDiffResponse, CheckoutGitFileBlameResponse, CheckoutGitFileOriginResponse, CheckoutGitGetOperationLogResponse, CheckoutMergeResponse, CheckoutMergeFromBaseResponse, CheckoutPullResponse, CheckoutPushResponse, CheckoutRefreshResponse, CheckoutPrCreateResponse, CheckoutPrMergeResponse, CheckoutPrMergeMethod, CheckoutGithubSetAutoMergeResponse, CheckoutGithubGetCheckDetailsResponse, PreviewListConfigResponse, PreviewStartResponse, PreviewBindTabResponse, PreviewStopResponse, CheckoutPrStatusResponse, PullRequestTimelineResponse, CheckoutSwitchBranchResponse, StashSaveResponse, StashPopResponse, StashListResponse, ValidateBranchResponse, BranchSuggestionsResponse, GitHubSearchResponse, GitHubSearchRequest, GitHostingProviderId, HostingSearchRequest, HostingSearchResponse, HostingAuthStatusResponse, DirectorySuggestionsResponse, OttoWorktreeListResponse, OttoWorktreeArchiveResponse, ProjectIconResponse, ContextReportGetResponseMessage, ContextEdgeConvertResponseMessage, ProjectAddResponse, OpenProjectResponseMessage, ArchiveWorkspaceResponseMessage, WorkspaceSetupStatusResponseMessage, ListCommandsResponse, ListProviderFeaturesResponseMessage, ListProviderModelsResponseMessage, ListProviderModesResponseMessage, ListAvailableProvidersResponse, GetProvidersSnapshotResponseMessage, RefreshProvidersSnapshotResponseMessage, ProviderDiagnosticResponseMessage, ProviderUsageListResponseMessage, StatsActivityGetResponseMessage, StatsActivityResetResponseMessage, UsageLogGetResponseMessage, AgentContextGetUsageResponseMessage, DaemonGetStatusResponse, DaemonGetPairingOfferResponse, DiagnosticsResponse, AgentRewindResponseMessage, ListTerminalsResponse, CreateTerminalResponse, SubscribeTerminalResponse, SubscribeTerminalRequest, CloseItemsResponse, KillTerminalResponse, CaptureTerminalResponse, TerminalInput, SessionInboundMessage, SessionOutboundMessage, SendAgentMessageRequest, TasksSuggestedStartMode, OttoConfigRaw, OttoConfigRevision, WorkspaceCreateRequest } from "@otto-code/protocol/messages";
4
+ import type { AgentStreamEventPayload, AgentSnapshotPayload, ProjectPlacementPayload, AgentPermissionResolvedMessage, CreateAgentRequestMessage, CreateOttoWorktreeRequest, CodeListFilesResponse, CodeSymbolLocation, FileDownloadTokenResponse, FileEol, FileReplaceFileResult, FileReplaceRequest, FileReplaceResponse, FileSearchResultPayload, FileSearchSummary, FileUploadResponse, FileExplorerResponse, FileWatchEventPayload, FileWriteResult, FetchAgentTimelineResponseMessage, AgentForkContextResponseMessage, GitSetupOptions, CheckoutStatusResponse, CheckoutCommitResponse, CheckoutGitCommitResponse, CheckoutGitCommitAgentResponse, CheckoutGitRollbackResponse, CheckoutGitFileHistoryResponse, CheckoutGitFileCommitDiffResponse, CheckoutGitFileBlameResponse, CheckoutGitFileOriginResponse, CheckoutGitGetOperationLogResponse, CheckoutMergeResponse, CheckoutMergeFromBaseResponse, CheckoutPullResponse, CheckoutPushResponse, CheckoutRefreshResponse, CheckoutPrCreateResponse, CheckoutPrMergeResponse, CheckoutPrMergeMethod, CheckoutGithubSetAutoMergeResponse, CheckoutGithubGetCheckDetailsResponse, PreviewListConfigResponse, PreviewStartResponse, PreviewBindTabResponse, PreviewStopResponse, CheckoutPrStatusResponse, PullRequestTimelineResponse, CheckoutSwitchBranchResponse, StashSaveResponse, StashPopResponse, StashListResponse, ValidateBranchResponse, BranchSuggestionsResponse, GitHubSearchResponse, GitHubSearchRequest, GitHostingProviderId, HostingSearchRequest, HostingSearchResponse, HostingAuthStatusResponse, DirectorySuggestionsResponse, OttoWorktreeListResponse, OttoWorktreeArchiveResponse, ProjectIconResponse, ContextReportGetResponseMessage, ContextEdgeConvertResponseMessage, ProjectAddResponse, OpenProjectResponseMessage, ArchiveWorkspaceResponseMessage, WorkspaceArchivePreflightResponse, WorktreeReattachListResponse, WorktreeReattachResponse, WorktreeReattachTarget, WorkspaceSetupStatusResponseMessage, ListCommandsResponse, ListProviderFeaturesResponseMessage, ListProviderModelsResponseMessage, ListProviderModesResponseMessage, ListAvailableProvidersResponse, GetProvidersSnapshotResponseMessage, RefreshProvidersSnapshotResponseMessage, ProviderDiagnosticResponseMessage, ProviderUsageListResponseMessage, StatsActivityGetResponseMessage, StatsActivityResetResponseMessage, UsageLogGetResponseMessage, AgentContextGetUsageResponseMessage, DaemonGetStatusResponse, DaemonGetPairingOfferResponse, DiagnosticsResponse, AgentRewindResponseMessage, ListTerminalsResponse, CreateTerminalResponse, SubscribeTerminalResponse, SubscribeTerminalRequest, CloseItemsResponse, KillTerminalResponse, CaptureTerminalResponse, TerminalInput, SessionInboundMessage, SessionOutboundMessage, SendAgentMessageRequest, TasksSuggestedStartMode, OttoConfigRaw, OttoConfigRevision, WorkspaceCreateRequest } from "@otto-code/protocol/messages";
5
5
  import type { AgentPermissionRequest, AgentPermissionResponse, AgentPersistenceHandle, AgentProviderNotice, AgentProvider, AgentSessionConfig } from "@otto-code/protocol/agent-types";
6
- import type { Run } from "@otto-code/protocol/orchestration";
7
- import type { CueMoment, MutableDaemonConfig, MutableDaemonConfigPatch, ProjectLink, SpeechSettingsOptions, SpeechTtsPreviewResult, VisualizerVoiceCuesResult } from "@otto-code/protocol/messages";
6
+ import type { OrchestrationGraph, Run } from "@otto-code/protocol/orchestration";
7
+ import type { CueMoment, MutableDaemonConfig, MutableDaemonConfigPatch, ProjectLink, SpeechSettingsOptions, SpeechTtsPreviewResult, SpeechTtsSpeakResult, SpeechTtsSpeakCancelResult, VisualizerVoiceCuesResult } from "@otto-code/protocol/messages";
8
8
  import { type DaemonTransportFactory, type WebSocketFactory } from "./daemon-client-transport.js";
9
9
  import { type TerminalStreamEvent } from "./terminal-stream-router.js";
10
10
  import type { BrowserAutomationExecuteRequest, BrowserAutomationExecuteResponse } from "@otto-code/protocol/browser-automation/rpc-schemas";
@@ -631,6 +631,9 @@ export interface RenameTerminalInput {
631
631
  type OpenProjectPayload = OpenProjectResponseMessage["payload"];
632
632
  type ProjectAddPayload = ProjectAddResponse["payload"];
633
633
  type ArchiveWorkspacePayload = ArchiveWorkspaceResponseMessage["payload"];
634
+ type WorkspaceArchivePreflightPayload = WorkspaceArchivePreflightResponse["payload"];
635
+ type WorktreeReattachListPayload = WorktreeReattachListResponse["payload"];
636
+ type WorktreeReattachPayload = WorktreeReattachResponse["payload"];
634
637
  type WorkspaceSetupStatusPayload = WorkspaceSetupStatusResponseMessage["payload"];
635
638
  export interface FetchAgentResult {
636
639
  agent: AgentSnapshotPayload;
@@ -766,7 +769,16 @@ export declare class DaemonClient {
766
769
  startWorkspaceScript(workspaceId: string, scriptName: string, requestId?: string): Promise<Extract<SessionOutboundMessage, {
767
770
  type: "start_workspace_script_response";
768
771
  }>["payload"]>;
769
- archiveWorkspace(workspaceId: string, requestId?: string): Promise<ArchiveWorkspacePayload>;
772
+ archiveWorkspace(workspaceId: string, options?: {
773
+ branchDisposition?: "keep" | "delete";
774
+ requestId?: string;
775
+ }): Promise<ArchiveWorkspacePayload>;
776
+ workspaceArchivePreflight(workspaceId: string, requestId?: string): Promise<WorkspaceArchivePreflightPayload>;
777
+ listReattachableWorktrees(scope: {
778
+ projectId?: string;
779
+ cwd?: string;
780
+ }, requestId?: string): Promise<WorktreeReattachListPayload>;
781
+ reattachWorktree(target: WorktreeReattachTarget, requestId?: string): Promise<WorktreeReattachPayload>;
770
782
  fetchWorkspaceSetupStatus(workspaceId: string, requestId?: string): Promise<WorkspaceSetupStatusPayload>;
771
783
  fetchAgent(options: FetchAgentOptions): Promise<FetchAgentResult | null>;
772
784
  fetchAgent(agentId: string, requestId?: string): Promise<FetchAgentResult | null>;
@@ -823,6 +835,36 @@ export declare class DaemonClient {
823
835
  cancelRun(runId: string): Promise<boolean>;
824
836
  /** Orchestration: delete every finished (done/failed/canceled) run. */
825
837
  clearFinishedRuns(): Promise<string[]>;
838
+ /** Orchestration: list the host's reusable graph templates. */
839
+ listOrchestrationGraphs(): Promise<OrchestrationGraph[]>;
840
+ /** Orchestration: upsert a graph template. Returns the persisted graph. */
841
+ saveOrchestrationGraph(graph: OrchestrationGraph): Promise<OrchestrationGraph>;
842
+ /** Orchestration: delete a graph template (built-in starters refuse). */
843
+ deleteOrchestrationGraph(graphId: string): Promise<boolean>;
844
+ /**
845
+ * Orchestration: start (or draft) a user-initiated orchestration. Returns the
846
+ * run id (graph flavor) and the orchestrator chat's agent id to navigate to.
847
+ */
848
+ startOrchestration(input: {
849
+ flavor: "ai" | "graph";
850
+ cwd: string;
851
+ workspaceId?: string;
852
+ title?: string;
853
+ description?: string;
854
+ orchestratorPersonalityId?: string;
855
+ orchestratorProvider?: string;
856
+ orchestratorModel?: string;
857
+ orchestratorThinkingOptionId?: string;
858
+ prompt?: string;
859
+ graphId?: string;
860
+ graphInputs?: Record<string, string>;
861
+ draft?: boolean;
862
+ runId?: string;
863
+ }): Promise<{
864
+ runId?: string;
865
+ agentId?: string;
866
+ workspaceId?: string;
867
+ }>;
826
868
  updateAgent(agentId: string, updates: {
827
869
  name?: string;
828
870
  labels?: Record<string, string>;
@@ -1132,6 +1174,15 @@ export declare class DaemonClient {
1132
1174
  name: string;
1133
1175
  };
1134
1176
  }, requestId?: string): Promise<SpeechTtsPreviewResult>;
1177
+ speakMessage(params: {
1178
+ text: string;
1179
+ voice?: {
1180
+ provider?: string;
1181
+ model?: string;
1182
+ name: string;
1183
+ };
1184
+ }, requestId?: string): Promise<SpeechTtsSpeakResult>;
1185
+ cancelSpeakMessage(requestId?: string): Promise<SpeechTtsSpeakCancelResult>;
1135
1186
  generateVisualizerVoiceCues(params: {
1136
1187
  name: string;
1137
1188
  prompt?: string;
@@ -1033,16 +1033,55 @@ export class DaemonClient {
1033
1033
  responseType: "start_workspace_script_response",
1034
1034
  });
1035
1035
  }
1036
- async archiveWorkspace(workspaceId, requestId) {
1036
+ async archiveWorkspace(workspaceId, options) {
1037
1037
  return this.sendCorrelatedSessionRequest({
1038
- requestId,
1038
+ requestId: options?.requestId,
1039
1039
  message: {
1040
1040
  type: "archive_workspace_request",
1041
1041
  workspaceId,
1042
+ ...(options?.branchDisposition ? { branchDisposition: options.branchDisposition } : {}),
1042
1043
  },
1043
1044
  responseType: "archive_workspace_response",
1044
1045
  });
1045
1046
  }
1047
+ // Read-only pre-archive inspection of a worktree's leftover branch (merge
1048
+ // state, deletability). Gated by server_info.features.worktreeArchiveBranchCleanup.
1049
+ async workspaceArchivePreflight(workspaceId, requestId) {
1050
+ return this.sendCorrelatedSessionRequest({
1051
+ requestId,
1052
+ message: {
1053
+ type: "workspace.archive.preflight.request",
1054
+ workspaceId,
1055
+ },
1056
+ responseType: "workspace.archive.preflight.response",
1057
+ });
1058
+ }
1059
+ // List re-attachable Otto worktrees for a project (or the repo containing cwd):
1060
+ // archived worktree workspaces with a kept branch, plus orphaned on-disk
1061
+ // worktrees. Gated by server_info.features.worktreeReattach.
1062
+ async listReattachableWorktrees(scope, requestId) {
1063
+ return this.sendCorrelatedSessionRequest({
1064
+ requestId,
1065
+ message: {
1066
+ type: "worktree.reattach.list.request",
1067
+ ...(scope.projectId ? { projectId: scope.projectId } : {}),
1068
+ ...(scope.cwd ? { cwd: scope.cwd } : {}),
1069
+ },
1070
+ responseType: "worktree.reattach.list.response",
1071
+ });
1072
+ }
1073
+ // Re-attach a "left" worktree as a live workspace: revive an archived workspace
1074
+ // record in place, or bind a fresh workspace to an orphaned on-disk worktree.
1075
+ async reattachWorktree(target, requestId) {
1076
+ return this.sendCorrelatedSessionRequest({
1077
+ requestId,
1078
+ message: {
1079
+ type: "worktree.reattach.request",
1080
+ target,
1081
+ },
1082
+ responseType: "worktree.reattach.response",
1083
+ });
1084
+ }
1046
1085
  async fetchWorkspaceSetupStatus(workspaceId, requestId) {
1047
1086
  return this.sendCorrelatedSessionRequest({
1048
1087
  requestId,
@@ -1358,6 +1397,74 @@ export class DaemonClient {
1358
1397
  });
1359
1398
  return payload.runIds;
1360
1399
  }
1400
+ /** Orchestration: list the host's reusable graph templates. */
1401
+ async listOrchestrationGraphs() {
1402
+ const payload = await this.sendNamespacedCorrelatedSessionRequest({
1403
+ message: { type: "runs.graphs.list.request" },
1404
+ });
1405
+ return payload.graphs;
1406
+ }
1407
+ /** Orchestration: upsert a graph template. Returns the persisted graph. */
1408
+ async saveOrchestrationGraph(graph) {
1409
+ const payload = await this.sendNamespacedCorrelatedSessionRequest({
1410
+ message: { type: "runs.graphs.save.request", graph },
1411
+ });
1412
+ if (payload.error !== undefined || payload.graph === undefined) {
1413
+ throw new Error(payload.error ?? "saveOrchestrationGraph rejected");
1414
+ }
1415
+ return payload.graph;
1416
+ }
1417
+ /** Orchestration: delete a graph template (built-in starters refuse). */
1418
+ async deleteOrchestrationGraph(graphId) {
1419
+ const payload = await this.sendNamespacedCorrelatedSessionRequest({
1420
+ message: { type: "runs.graphs.delete.request", graphId },
1421
+ });
1422
+ if (payload.error !== undefined) {
1423
+ throw new Error(payload.error);
1424
+ }
1425
+ return payload.deleted;
1426
+ }
1427
+ /**
1428
+ * Orchestration: start (or draft) a user-initiated orchestration. Returns the
1429
+ * run id (graph flavor) and the orchestrator chat's agent id to navigate to.
1430
+ */
1431
+ async startOrchestration(input) {
1432
+ const payload = await this.sendNamespacedCorrelatedSessionRequest({
1433
+ message: {
1434
+ type: "runs.start.request",
1435
+ flavor: input.flavor,
1436
+ cwd: input.cwd,
1437
+ ...(input.workspaceId !== undefined ? { workspaceId: input.workspaceId } : {}),
1438
+ ...(input.title !== undefined ? { title: input.title } : {}),
1439
+ ...(input.description !== undefined ? { description: input.description } : {}),
1440
+ ...(input.orchestratorPersonalityId !== undefined
1441
+ ? { orchestratorPersonalityId: input.orchestratorPersonalityId }
1442
+ : {}),
1443
+ ...(input.orchestratorProvider !== undefined
1444
+ ? { orchestratorProvider: input.orchestratorProvider }
1445
+ : {}),
1446
+ ...(input.orchestratorModel !== undefined
1447
+ ? { orchestratorModel: input.orchestratorModel }
1448
+ : {}),
1449
+ ...(input.orchestratorThinkingOptionId !== undefined
1450
+ ? { orchestratorThinkingOptionId: input.orchestratorThinkingOptionId }
1451
+ : {}),
1452
+ ...(input.prompt !== undefined ? { prompt: input.prompt } : {}),
1453
+ ...(input.graphId !== undefined ? { graphId: input.graphId } : {}),
1454
+ ...(input.graphInputs !== undefined ? { graphInputs: input.graphInputs } : {}),
1455
+ ...(input.draft !== undefined ? { draft: input.draft } : {}),
1456
+ ...(input.runId !== undefined ? { runId: input.runId } : {}),
1457
+ },
1458
+ });
1459
+ if (payload.error !== undefined) {
1460
+ throw new Error(payload.error);
1461
+ }
1462
+ return {
1463
+ ...(payload.runId !== undefined ? { runId: payload.runId } : {}),
1464
+ ...(payload.agentId !== undefined ? { agentId: payload.agentId } : {}),
1465
+ ...(payload.workspaceId !== undefined ? { workspaceId: payload.workspaceId } : {}),
1466
+ };
1467
+ }
1361
1468
  async updateAgent(agentId, updates) {
1362
1469
  const requestId = this.createRequestId();
1363
1470
  const message = SessionInboundMessageSchema.parse({
@@ -3147,6 +3254,27 @@ export class DaemonClient {
3147
3254
  },
3148
3255
  });
3149
3256
  }
3257
+ // Stream a full message aloud on demand (per-message playback button). Audio
3258
+ // arrives as `audio_output` chunks the session already plays; this promise
3259
+ // resolves when playback finishes, is canceled, or errors. `voice` is the
3260
+ // speaking agent's personality voice (resolved on the client).
3261
+ async speakMessage(params, requestId) {
3262
+ return this.sendNamespacedCorrelatedSessionRequest({
3263
+ requestId,
3264
+ message: {
3265
+ type: "speech.tts.speak.request",
3266
+ text: params.text,
3267
+ ...(params.voice ? { voice: params.voice } : {}),
3268
+ },
3269
+ });
3270
+ }
3271
+ // Stop the in-flight message playback started by speakMessage.
3272
+ async cancelSpeakMessage(requestId) {
3273
+ return this.sendNamespacedCorrelatedSessionRequest({
3274
+ requestId,
3275
+ message: { type: "speech.tts.speak.cancel.request" },
3276
+ });
3277
+ }
3150
3278
  // Author short spoken cue lines (join / thinking / done) for a persona,
3151
3279
  // described inline (name + prompt) so it works for an unsaved editor draft.
3152
3280
  // Routed through the Writer chain; the caller stores the result on the
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ export function createOttoClient(config) {
14
14
  ref: (workspace) => createWorkspaceHandle(workspace),
15
15
  open: (input, requestId) => openWorkspace(daemonClient, createWorkspaceHandle, input, requestId),
16
16
  create: (input, requestId) => openWorkspace(daemonClient, createWorkspaceHandle, input, requestId),
17
- archive: (workspace, requestId) => daemonClient.archiveWorkspace(resolveWorkspaceId(workspace), requestId),
17
+ archive: (workspace, requestId) => daemonClient.archiveWorkspace(resolveWorkspaceId(workspace), { requestId }),
18
18
  subscribe: (handler) => daemonClient.on("workspace_update", (message) => {
19
19
  handler(message.payload);
20
20
  }),
@@ -75,7 +75,7 @@ function createWorkspaceHandleFactory(daemonClient) {
75
75
  return latest;
76
76
  },
77
77
  archive: async (requestId) => {
78
- const result = await daemonClient.archiveWorkspace(id, requestId);
78
+ const result = await daemonClient.archiveWorkspace(id, { requestId });
79
79
  if (latest) {
80
80
  latest = { ...latest, archivingAt: result.archivedAt };
81
81
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@otto-code/client",
3
- "version": "0.6.6",
3
+ "version": "0.6.7",
4
4
  "description": "Otto client SDK package",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "files": [
@@ -36,8 +36,8 @@
36
36
  "test": "vitest run"
37
37
  },
38
38
  "dependencies": {
39
- "@otto-code/protocol": "0.6.6",
40
- "@otto-code/relay": "0.6.6",
39
+ "@otto-code/protocol": "0.6.7",
40
+ "@otto-code/relay": "0.6.7",
41
41
  "zod": "^4.4.3"
42
42
  },
43
43
  "devDependencies": {