@opencode-ai/sdk 1.3.1 → 1.3.3

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,5 +1,5 @@
1
1
  import { type Client, type Options as Options2, type TDataShape } from "./client/index.js";
2
- import type { AgentPartInput, AppAgentsResponses, AppLogErrors, AppLogResponses, AppSkillsResponses, Auth as Auth3, AuthRemoveErrors, AuthRemoveResponses, AuthSetErrors, AuthSetResponses, CommandListResponses, Config as Config3, ConfigGetResponses, ConfigProvidersResponses, ConfigUpdateErrors, ConfigUpdateResponses, EventSubscribeResponses, EventTuiCommandExecute, EventTuiPromptAppend, EventTuiSessionSelect, EventTuiToastShow, ExperimentalResourceListResponses, ExperimentalSessionListResponses, ExperimentalWorkspaceCreateErrors, ExperimentalWorkspaceCreateResponses, ExperimentalWorkspaceListResponses, ExperimentalWorkspaceRemoveErrors, ExperimentalWorkspaceRemoveResponses, FileListResponses, FilePartInput, FilePartSource, FileReadResponses, FileStatusResponses, FindFilesResponses, FindSymbolsResponses, FindTextResponses, FormatterStatusResponses, GlobalConfigGetResponses, GlobalConfigUpdateErrors, GlobalConfigUpdateResponses, GlobalDisposeResponses, GlobalEventResponses, GlobalHealthResponses, GlobalUpgradeErrors, GlobalUpgradeResponses, InstanceDisposeResponses, LspStatusResponses, McpAddErrors, McpAddResponses, McpAuthAuthenticateErrors, McpAuthAuthenticateResponses, McpAuthCallbackErrors, McpAuthCallbackResponses, McpAuthRemoveErrors, McpAuthRemoveResponses, McpAuthStartErrors, McpAuthStartResponses, McpConnectResponses, McpDisconnectResponses, McpLocalConfig, McpRemoteConfig, McpStatusResponses, OutputFormat, Part as Part2, PartDeleteErrors, PartDeleteResponses, PartUpdateErrors, PartUpdateResponses, PathGetResponses, PermissionListResponses, PermissionReplyErrors, PermissionReplyResponses, PermissionRespondErrors, PermissionRespondResponses, PermissionRuleset, ProjectCurrentResponses, ProjectInitGitResponses, ProjectListResponses, ProjectUpdateErrors, ProjectUpdateResponses, ProviderAuthResponses, ProviderListResponses, ProviderOauthAuthorizeErrors, ProviderOauthAuthorizeResponses, ProviderOauthCallbackErrors, ProviderOauthCallbackResponses, PtyConnectErrors, PtyConnectResponses, PtyCreateErrors, PtyCreateResponses, PtyGetErrors, PtyGetResponses, PtyListResponses, PtyRemoveErrors, PtyRemoveResponses, PtyUpdateErrors, PtyUpdateResponses, QuestionAnswer, QuestionListResponses, QuestionRejectErrors, QuestionRejectResponses, QuestionReplyErrors, QuestionReplyResponses, SessionAbortErrors, SessionAbortResponses, SessionChildrenErrors, SessionChildrenResponses, SessionCommandErrors, SessionCommandResponses, SessionCreateErrors, SessionCreateResponses, SessionDeleteErrors, SessionDeleteMessageErrors, SessionDeleteMessageResponses, SessionDeleteResponses, SessionDiffResponses, SessionForkResponses, SessionGetErrors, SessionGetResponses, SessionInitErrors, SessionInitResponses, SessionListResponses, SessionMessageErrors, SessionMessageResponses, SessionMessagesErrors, SessionMessagesResponses, SessionPromptAsyncErrors, SessionPromptAsyncResponses, SessionPromptErrors, SessionPromptResponses, SessionRevertErrors, SessionRevertResponses, SessionShareErrors, SessionShareResponses, SessionShellErrors, SessionShellResponses, SessionStatusErrors, SessionStatusResponses, SessionSummarizeErrors, SessionSummarizeResponses, SessionTodoErrors, SessionTodoResponses, SessionUnrevertErrors, SessionUnrevertResponses, SessionUnshareErrors, SessionUnshareResponses, SessionUpdateErrors, SessionUpdateResponses, SubtaskPartInput, TextPartInput, ToolIdsErrors, ToolIdsResponses, ToolListErrors, ToolListResponses, TuiAppendPromptErrors, TuiAppendPromptResponses, TuiClearPromptResponses, TuiControlNextResponses, TuiControlResponseResponses, TuiExecuteCommandErrors, TuiExecuteCommandResponses, TuiOpenHelpResponses, TuiOpenModelsResponses, TuiOpenSessionsResponses, TuiOpenThemesResponses, TuiPublishErrors, TuiPublishResponses, TuiSelectSessionErrors, TuiSelectSessionResponses, TuiShowToastResponses, TuiSubmitPromptResponses, VcsGetResponses, WorktreeCreateErrors, WorktreeCreateInput, WorktreeCreateResponses, WorktreeListResponses, WorktreeRemoveErrors, WorktreeRemoveInput, WorktreeRemoveResponses, WorktreeResetErrors, WorktreeResetInput, WorktreeResetResponses } from "./types.gen.js";
2
+ import type { AgentPartInput, AppAgentsResponses, AppLogErrors, AppLogResponses, AppSkillsResponses, Auth as Auth3, AuthRemoveErrors, AuthRemoveResponses, AuthSetErrors, AuthSetResponses, CommandListResponses, Config as Config3, ConfigGetResponses, ConfigProvidersResponses, ConfigUpdateErrors, ConfigUpdateResponses, EventSubscribeResponses, EventTuiCommandExecute, EventTuiPromptAppend, EventTuiSessionSelect, EventTuiToastShow, ExperimentalResourceListResponses, ExperimentalSessionListResponses, ExperimentalWorkspaceCreateErrors, ExperimentalWorkspaceCreateResponses, ExperimentalWorkspaceListResponses, ExperimentalWorkspaceRemoveErrors, ExperimentalWorkspaceRemoveResponses, FileListResponses, FilePartInput, FilePartSource, FileReadResponses, FileStatusResponses, FindFilesResponses, FindSymbolsResponses, FindTextResponses, FormatterStatusResponses, GlobalConfigGetResponses, GlobalConfigUpdateErrors, GlobalConfigUpdateResponses, GlobalDisposeResponses, GlobalEventResponses, GlobalHealthResponses, GlobalSyncEventSubscribeResponses, GlobalUpgradeErrors, GlobalUpgradeResponses, InstanceDisposeResponses, LspStatusResponses, McpAddErrors, McpAddResponses, McpAuthAuthenticateErrors, McpAuthAuthenticateResponses, McpAuthCallbackErrors, McpAuthCallbackResponses, McpAuthRemoveErrors, McpAuthRemoveResponses, McpAuthStartErrors, McpAuthStartResponses, McpConnectResponses, McpDisconnectResponses, McpLocalConfig, McpRemoteConfig, McpStatusResponses, OutputFormat, Part as Part2, PartDeleteErrors, PartDeleteResponses, PartUpdateErrors, PartUpdateResponses, PathGetResponses, PermissionListResponses, PermissionReplyErrors, PermissionReplyResponses, PermissionRespondErrors, PermissionRespondResponses, PermissionRuleset, ProjectCurrentResponses, ProjectInitGitResponses, ProjectListResponses, ProjectUpdateErrors, ProjectUpdateResponses, ProviderAuthResponses, ProviderListResponses, ProviderOauthAuthorizeErrors, ProviderOauthAuthorizeResponses, ProviderOauthCallbackErrors, ProviderOauthCallbackResponses, PtyConnectErrors, PtyConnectResponses, PtyCreateErrors, PtyCreateResponses, PtyGetErrors, PtyGetResponses, PtyListResponses, PtyRemoveErrors, PtyRemoveResponses, PtyUpdateErrors, PtyUpdateResponses, QuestionAnswer, QuestionListResponses, QuestionRejectErrors, QuestionRejectResponses, QuestionReplyErrors, QuestionReplyResponses, SessionAbortErrors, SessionAbortResponses, SessionChildrenErrors, SessionChildrenResponses, SessionCommandErrors, SessionCommandResponses, SessionCreateErrors, SessionCreateResponses, SessionDeleteErrors, SessionDeleteMessageErrors, SessionDeleteMessageResponses, SessionDeleteResponses, SessionDiffResponses, SessionForkResponses, SessionGetErrors, SessionGetResponses, SessionInitErrors, SessionInitResponses, SessionListResponses, SessionMessageErrors, SessionMessageResponses, SessionMessagesErrors, SessionMessagesResponses, SessionPromptAsyncErrors, SessionPromptAsyncResponses, SessionPromptErrors, SessionPromptResponses, SessionRevertErrors, SessionRevertResponses, SessionShareErrors, SessionShareResponses, SessionShellErrors, SessionShellResponses, SessionStatusErrors, SessionStatusResponses, SessionSummarizeErrors, SessionSummarizeResponses, SessionTodoErrors, SessionTodoResponses, SessionUnrevertErrors, SessionUnrevertResponses, SessionUnshareErrors, SessionUnshareResponses, SessionUpdateErrors, SessionUpdateResponses, SubtaskPartInput, TextPartInput, ToolIdsErrors, ToolIdsResponses, ToolListErrors, ToolListResponses, TuiAppendPromptErrors, TuiAppendPromptResponses, TuiClearPromptResponses, TuiControlNextResponses, TuiControlResponseResponses, TuiExecuteCommandErrors, TuiExecuteCommandResponses, TuiOpenHelpResponses, TuiOpenModelsResponses, TuiOpenSessionsResponses, TuiOpenThemesResponses, TuiPublishErrors, TuiPublishResponses, TuiSelectSessionErrors, TuiSelectSessionResponses, TuiShowToastResponses, TuiSubmitPromptResponses, VcsGetResponses, WorktreeCreateErrors, WorktreeCreateInput, WorktreeCreateResponses, WorktreeListResponses, WorktreeRemoveErrors, WorktreeRemoveInput, WorktreeRemoveResponses, WorktreeResetErrors, WorktreeResetInput, WorktreeResetResponses } from "./types.gen.js";
3
3
  export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & {
4
4
  /**
5
5
  * You can provide a client instance returned by `createClient()` instead of
@@ -25,6 +25,14 @@ declare class HeyApiRegistry<T> {
25
25
  get(key?: string): T;
26
26
  set(value: T, key?: string): void;
27
27
  }
28
+ export declare class SyncEvent extends HeyApiClient {
29
+ /**
30
+ * Subscribe to global sync events
31
+ *
32
+ * Get global sync events
33
+ */
34
+ subscribe<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>): Promise<import("./core/serverSentEvents.gen.js").ServerSentEventsResult<GlobalSyncEventSubscribeResponses, unknown>>;
35
+ }
28
36
  export declare class Config extends HeyApiClient {
29
37
  /**
30
38
  * Get global configuration
@@ -68,6 +76,8 @@ export declare class Global extends HeyApiClient {
68
76
  upgrade<ThrowOnError extends boolean = false>(parameters?: {
69
77
  target?: string;
70
78
  }, options?: Options<never, ThrowOnError>): import("./client/types.gen.js").RequestResult<GlobalUpgradeResponses, GlobalUpgradeErrors, ThrowOnError, "fields">;
79
+ private _syncEvent?;
80
+ get syncEvent(): SyncEvent;
71
81
  private _config?;
72
82
  get config(): Config;
73
83
  }
@@ -21,6 +21,19 @@ class HeyApiRegistry {
21
21
  this.instances.set(key ?? this.defaultKey, value);
22
22
  }
23
23
  }
24
+ export class SyncEvent extends HeyApiClient {
25
+ /**
26
+ * Subscribe to global sync events
27
+ *
28
+ * Get global sync events
29
+ */
30
+ subscribe(options) {
31
+ return (options?.client ?? this.client).sse.get({
32
+ url: "/global/sync-event",
33
+ ...options,
34
+ });
35
+ }
36
+ }
24
37
  export class Config extends HeyApiClient {
25
38
  /**
26
39
  * Get global configuration
@@ -104,6 +117,10 @@ export class Global extends HeyApiClient {
104
117
  },
105
118
  });
106
119
  }
120
+ _syncEvent;
121
+ get syncEvent() {
122
+ return (this._syncEvent ??= new SyncEvent({ client: this.client }));
123
+ }
107
124
  _config;
108
125
  get config() {
109
126
  return (this._config ??= new Config({ client: this.client }));
@@ -71,24 +71,224 @@ export type EventLspUpdated = {
71
71
  [key: string]: unknown;
72
72
  };
73
73
  };
74
+ export type EventMessagePartDelta = {
75
+ type: "message.part.delta";
76
+ properties: {
77
+ sessionID: string;
78
+ messageID: string;
79
+ partID: string;
80
+ field: string;
81
+ delta: string;
82
+ };
83
+ };
84
+ export type PermissionRequest = {
85
+ id: string;
86
+ sessionID: string;
87
+ permission: string;
88
+ patterns: Array<string>;
89
+ metadata: {
90
+ [key: string]: unknown;
91
+ };
92
+ always: Array<string>;
93
+ tool?: {
94
+ messageID: string;
95
+ callID: string;
96
+ };
97
+ };
98
+ export type EventPermissionAsked = {
99
+ type: "permission.asked";
100
+ properties: PermissionRequest;
101
+ };
102
+ export type EventPermissionReplied = {
103
+ type: "permission.replied";
104
+ properties: {
105
+ sessionID: string;
106
+ requestID: string;
107
+ reply: "once" | "always" | "reject";
108
+ };
109
+ };
110
+ export type SessionStatus = {
111
+ type: "idle";
112
+ } | {
113
+ type: "retry";
114
+ attempt: number;
115
+ message: string;
116
+ next: number;
117
+ } | {
118
+ type: "busy";
119
+ };
120
+ export type EventSessionStatus = {
121
+ type: "session.status";
122
+ properties: {
123
+ sessionID: string;
124
+ status: SessionStatus;
125
+ };
126
+ };
127
+ export type EventSessionIdle = {
128
+ type: "session.idle";
129
+ properties: {
130
+ sessionID: string;
131
+ };
132
+ };
133
+ export type QuestionOption = {
134
+ /**
135
+ * Display text (1-5 words, concise)
136
+ */
137
+ label: string;
138
+ /**
139
+ * Explanation of choice
140
+ */
141
+ description: string;
142
+ };
143
+ export type QuestionInfo = {
144
+ /**
145
+ * Complete question
146
+ */
147
+ question: string;
148
+ /**
149
+ * Very short label (max 30 chars)
150
+ */
151
+ header: string;
152
+ /**
153
+ * Available choices
154
+ */
155
+ options: Array<QuestionOption>;
156
+ /**
157
+ * Allow selecting multiple choices
158
+ */
159
+ multiple?: boolean;
160
+ /**
161
+ * Allow typing a custom answer (default: true)
162
+ */
163
+ custom?: boolean;
164
+ };
165
+ export type QuestionRequest = {
166
+ id: string;
167
+ sessionID: string;
168
+ /**
169
+ * Questions to ask
170
+ */
171
+ questions: Array<QuestionInfo>;
172
+ tool?: {
173
+ messageID: string;
174
+ callID: string;
175
+ };
176
+ };
177
+ export type EventQuestionAsked = {
178
+ type: "question.asked";
179
+ properties: QuestionRequest;
180
+ };
181
+ export type QuestionAnswer = Array<string>;
182
+ export type EventQuestionReplied = {
183
+ type: "question.replied";
184
+ properties: {
185
+ sessionID: string;
186
+ requestID: string;
187
+ answers: Array<QuestionAnswer>;
188
+ };
189
+ };
190
+ export type EventQuestionRejected = {
191
+ type: "question.rejected";
192
+ properties: {
193
+ sessionID: string;
194
+ requestID: string;
195
+ };
196
+ };
197
+ export type EventSessionCompacted = {
198
+ type: "session.compacted";
199
+ properties: {
200
+ sessionID: string;
201
+ };
202
+ };
74
203
  export type EventFileEdited = {
75
204
  type: "file.edited";
76
205
  properties: {
77
206
  file: string;
78
207
  };
79
208
  };
80
- export type OutputFormatText = {
81
- type: "text";
209
+ export type EventFileWatcherUpdated = {
210
+ type: "file.watcher.updated";
211
+ properties: {
212
+ file: string;
213
+ event: "add" | "change" | "unlink";
214
+ };
82
215
  };
83
- export type JsonSchema = {
84
- [key: string]: unknown;
216
+ export type Todo = {
217
+ /**
218
+ * Brief description of the task
219
+ */
220
+ content: string;
221
+ /**
222
+ * Current status of the task: pending, in_progress, completed, cancelled
223
+ */
224
+ status: string;
225
+ /**
226
+ * Priority level of the task: high, medium, low
227
+ */
228
+ priority: string;
85
229
  };
86
- export type OutputFormatJsonSchema = {
87
- type: "json_schema";
88
- schema: JsonSchema;
89
- retryCount?: number;
230
+ export type EventTodoUpdated = {
231
+ type: "todo.updated";
232
+ properties: {
233
+ sessionID: string;
234
+ todos: Array<Todo>;
235
+ };
236
+ };
237
+ export type EventTuiPromptAppend = {
238
+ type: "tui.prompt.append";
239
+ properties: {
240
+ text: string;
241
+ };
242
+ };
243
+ export type EventTuiCommandExecute = {
244
+ type: "tui.command.execute";
245
+ properties: {
246
+ command: "session.list" | "session.new" | "session.share" | "session.interrupt" | "session.compact" | "session.page.up" | "session.page.down" | "session.line.up" | "session.line.down" | "session.half.page.up" | "session.half.page.down" | "session.first" | "session.last" | "prompt.clear" | "prompt.submit" | "agent.cycle" | string;
247
+ };
248
+ };
249
+ export type EventTuiToastShow = {
250
+ type: "tui.toast.show";
251
+ properties: {
252
+ title?: string;
253
+ message: string;
254
+ variant: "info" | "success" | "warning" | "error";
255
+ /**
256
+ * Duration in milliseconds
257
+ */
258
+ duration?: number;
259
+ };
260
+ };
261
+ export type EventTuiSessionSelect = {
262
+ type: "tui.session.select";
263
+ properties: {
264
+ /**
265
+ * Session ID to navigate to
266
+ */
267
+ sessionID: string;
268
+ };
269
+ };
270
+ export type EventMcpToolsChanged = {
271
+ type: "mcp.tools.changed";
272
+ properties: {
273
+ server: string;
274
+ };
275
+ };
276
+ export type EventMcpBrowserOpenFailed = {
277
+ type: "mcp.browser.open.failed";
278
+ properties: {
279
+ mcpName: string;
280
+ url: string;
281
+ };
282
+ };
283
+ export type EventCommandExecuted = {
284
+ type: "command.executed";
285
+ properties: {
286
+ name: string;
287
+ sessionID: string;
288
+ arguments: string;
289
+ messageID: string;
290
+ };
90
291
  };
91
- export type OutputFormat = OutputFormatText | OutputFormatJsonSchema;
92
292
  export type FileDiff = {
93
293
  file: string;
94
294
  before: string;
@@ -97,29 +297,12 @@ export type FileDiff = {
97
297
  deletions: number;
98
298
  status?: "added" | "deleted" | "modified";
99
299
  };
100
- export type UserMessage = {
101
- id: string;
102
- sessionID: string;
103
- role: "user";
104
- time: {
105
- created: number;
106
- };
107
- format?: OutputFormat;
108
- summary?: {
109
- title?: string;
110
- body?: string;
111
- diffs: Array<FileDiff>;
112
- };
113
- agent: string;
114
- model: {
115
- providerID: string;
116
- modelID: string;
117
- };
118
- system?: string;
119
- tools?: {
120
- [key: string]: boolean;
300
+ export type EventSessionDiff = {
301
+ type: "session.diff";
302
+ properties: {
303
+ sessionID: string;
304
+ diff: Array<FileDiff>;
121
305
  };
122
- variant?: string;
123
306
  };
124
307
  export type ProviderAuthError = {
125
308
  name: "ProviderAuthError";
@@ -159,21 +342,129 @@ export type ContextOverflowError = {
159
342
  message: string;
160
343
  responseBody?: string;
161
344
  };
162
- };
163
- export type ApiError = {
164
- name: "APIError";
165
- data: {
166
- message: string;
167
- statusCode?: number;
168
- isRetryable: boolean;
169
- responseHeaders?: {
170
- [key: string]: string;
171
- };
172
- responseBody?: string;
173
- metadata?: {
174
- [key: string]: string;
175
- };
345
+ };
346
+ export type ApiError = {
347
+ name: "APIError";
348
+ data: {
349
+ message: string;
350
+ statusCode?: number;
351
+ isRetryable: boolean;
352
+ responseHeaders?: {
353
+ [key: string]: string;
354
+ };
355
+ responseBody?: string;
356
+ metadata?: {
357
+ [key: string]: string;
358
+ };
359
+ };
360
+ };
361
+ export type EventSessionError = {
362
+ type: "session.error";
363
+ properties: {
364
+ sessionID?: string;
365
+ error?: ProviderAuthError | UnknownError | MessageOutputLengthError | MessageAbortedError | StructuredOutputError | ContextOverflowError | ApiError;
366
+ };
367
+ };
368
+ export type EventVcsBranchUpdated = {
369
+ type: "vcs.branch.updated";
370
+ properties: {
371
+ branch?: string;
372
+ };
373
+ };
374
+ export type EventWorkspaceReady = {
375
+ type: "workspace.ready";
376
+ properties: {
377
+ name: string;
378
+ };
379
+ };
380
+ export type EventWorkspaceFailed = {
381
+ type: "workspace.failed";
382
+ properties: {
383
+ message: string;
384
+ };
385
+ };
386
+ export type Pty = {
387
+ id: string;
388
+ title: string;
389
+ command: string;
390
+ args: Array<string>;
391
+ cwd: string;
392
+ status: "running" | "exited";
393
+ pid: number;
394
+ };
395
+ export type EventPtyCreated = {
396
+ type: "pty.created";
397
+ properties: {
398
+ info: Pty;
399
+ };
400
+ };
401
+ export type EventPtyUpdated = {
402
+ type: "pty.updated";
403
+ properties: {
404
+ info: Pty;
405
+ };
406
+ };
407
+ export type EventPtyExited = {
408
+ type: "pty.exited";
409
+ properties: {
410
+ id: string;
411
+ exitCode: number;
412
+ };
413
+ };
414
+ export type EventPtyDeleted = {
415
+ type: "pty.deleted";
416
+ properties: {
417
+ id: string;
418
+ };
419
+ };
420
+ export type EventWorktreeReady = {
421
+ type: "worktree.ready";
422
+ properties: {
423
+ name: string;
424
+ branch: string;
425
+ };
426
+ };
427
+ export type EventWorktreeFailed = {
428
+ type: "worktree.failed";
429
+ properties: {
430
+ message: string;
431
+ };
432
+ };
433
+ export type OutputFormatText = {
434
+ type: "text";
435
+ };
436
+ export type JsonSchema = {
437
+ [key: string]: unknown;
438
+ };
439
+ export type OutputFormatJsonSchema = {
440
+ type: "json_schema";
441
+ schema: JsonSchema;
442
+ retryCount?: number;
443
+ };
444
+ export type OutputFormat = OutputFormatText | OutputFormatJsonSchema;
445
+ export type UserMessage = {
446
+ id: string;
447
+ sessionID: string;
448
+ role: "user";
449
+ time: {
450
+ created: number;
451
+ };
452
+ format?: OutputFormat;
453
+ summary?: {
454
+ title?: string;
455
+ body?: string;
456
+ diffs: Array<FileDiff>;
457
+ };
458
+ agent: string;
459
+ model: {
460
+ providerID: string;
461
+ modelID: string;
462
+ };
463
+ system?: string;
464
+ tools?: {
465
+ [key: string]: boolean;
176
466
  };
467
+ variant?: string;
177
468
  };
178
469
  export type AssistantMessage = {
179
470
  id: string;
@@ -213,6 +504,7 @@ export type Message = UserMessage | AssistantMessage;
213
504
  export type EventMessageUpdated = {
214
505
  type: "message.updated";
215
506
  properties: {
507
+ sessionID: string;
216
508
  info: Message;
217
509
  };
218
510
  };
@@ -355,324 +647,114 @@ export type ToolStateError = {
355
647
  [key: string]: unknown;
356
648
  };
357
649
  error: string;
358
- metadata?: {
359
- [key: string]: unknown;
360
- };
361
- time: {
362
- start: number;
363
- end: number;
364
- };
365
- };
366
- export type ToolState = ToolStatePending | ToolStateRunning | ToolStateCompleted | ToolStateError;
367
- export type ToolPart = {
368
- id: string;
369
- sessionID: string;
370
- messageID: string;
371
- type: "tool";
372
- callID: string;
373
- tool: string;
374
- state: ToolState;
375
- metadata?: {
376
- [key: string]: unknown;
377
- };
378
- };
379
- export type StepStartPart = {
380
- id: string;
381
- sessionID: string;
382
- messageID: string;
383
- type: "step-start";
384
- snapshot?: string;
385
- };
386
- export type StepFinishPart = {
387
- id: string;
388
- sessionID: string;
389
- messageID: string;
390
- type: "step-finish";
391
- reason: string;
392
- snapshot?: string;
393
- cost: number;
394
- tokens: {
395
- total?: number;
396
- input: number;
397
- output: number;
398
- reasoning: number;
399
- cache: {
400
- read: number;
401
- write: number;
402
- };
403
- };
404
- };
405
- export type SnapshotPart = {
406
- id: string;
407
- sessionID: string;
408
- messageID: string;
409
- type: "snapshot";
410
- snapshot: string;
411
- };
412
- export type PatchPart = {
413
- id: string;
414
- sessionID: string;
415
- messageID: string;
416
- type: "patch";
417
- hash: string;
418
- files: Array<string>;
419
- };
420
- export type AgentPart = {
421
- id: string;
422
- sessionID: string;
423
- messageID: string;
424
- type: "agent";
425
- name: string;
426
- source?: {
427
- value: string;
428
- start: number;
429
- end: number;
430
- };
431
- };
432
- export type RetryPart = {
433
- id: string;
434
- sessionID: string;
435
- messageID: string;
436
- type: "retry";
437
- attempt: number;
438
- error: ApiError;
439
- time: {
440
- created: number;
441
- };
442
- };
443
- export type CompactionPart = {
444
- id: string;
445
- sessionID: string;
446
- messageID: string;
447
- type: "compaction";
448
- auto: boolean;
449
- overflow?: boolean;
450
- };
451
- export type Part = TextPart | SubtaskPart | ReasoningPart | FilePart | ToolPart | StepStartPart | StepFinishPart | SnapshotPart | PatchPart | AgentPart | RetryPart | CompactionPart;
452
- export type EventMessagePartUpdated = {
453
- type: "message.part.updated";
454
- properties: {
455
- part: Part;
456
- };
457
- };
458
- export type EventMessagePartDelta = {
459
- type: "message.part.delta";
460
- properties: {
461
- sessionID: string;
462
- messageID: string;
463
- partID: string;
464
- field: string;
465
- delta: string;
466
- };
467
- };
468
- export type EventMessagePartRemoved = {
469
- type: "message.part.removed";
470
- properties: {
471
- sessionID: string;
472
- messageID: string;
473
- partID: string;
474
- };
475
- };
476
- export type PermissionRequest = {
477
- id: string;
478
- sessionID: string;
479
- permission: string;
480
- patterns: Array<string>;
481
- metadata: {
482
- [key: string]: unknown;
483
- };
484
- always: Array<string>;
485
- tool?: {
486
- messageID: string;
487
- callID: string;
488
- };
489
- };
490
- export type EventPermissionAsked = {
491
- type: "permission.asked";
492
- properties: PermissionRequest;
493
- };
494
- export type EventPermissionReplied = {
495
- type: "permission.replied";
496
- properties: {
497
- sessionID: string;
498
- requestID: string;
499
- reply: "once" | "always" | "reject";
500
- };
501
- };
502
- export type SessionStatus = {
503
- type: "idle";
504
- } | {
505
- type: "retry";
506
- attempt: number;
507
- message: string;
508
- next: number;
509
- } | {
510
- type: "busy";
511
- };
512
- export type EventSessionStatus = {
513
- type: "session.status";
514
- properties: {
515
- sessionID: string;
516
- status: SessionStatus;
517
- };
518
- };
519
- export type EventSessionIdle = {
520
- type: "session.idle";
521
- properties: {
522
- sessionID: string;
523
- };
524
- };
525
- export type QuestionOption = {
526
- /**
527
- * Display text (1-5 words, concise)
528
- */
529
- label: string;
530
- /**
531
- * Explanation of choice
532
- */
533
- description: string;
534
- };
535
- export type QuestionInfo = {
536
- /**
537
- * Complete question
538
- */
539
- question: string;
540
- /**
541
- * Very short label (max 30 chars)
542
- */
543
- header: string;
544
- /**
545
- * Available choices
546
- */
547
- options: Array<QuestionOption>;
548
- /**
549
- * Allow selecting multiple choices
550
- */
551
- multiple?: boolean;
552
- /**
553
- * Allow typing a custom answer (default: true)
554
- */
555
- custom?: boolean;
556
- };
557
- export type QuestionRequest = {
558
- id: string;
559
- sessionID: string;
560
- /**
561
- * Questions to ask
562
- */
563
- questions: Array<QuestionInfo>;
564
- tool?: {
565
- messageID: string;
566
- callID: string;
567
- };
568
- };
569
- export type EventQuestionAsked = {
570
- type: "question.asked";
571
- properties: QuestionRequest;
572
- };
573
- export type QuestionAnswer = Array<string>;
574
- export type EventQuestionReplied = {
575
- type: "question.replied";
576
- properties: {
577
- sessionID: string;
578
- requestID: string;
579
- answers: Array<QuestionAnswer>;
580
- };
581
- };
582
- export type EventQuestionRejected = {
583
- type: "question.rejected";
584
- properties: {
585
- sessionID: string;
586
- requestID: string;
587
- };
588
- };
589
- export type EventSessionCompacted = {
590
- type: "session.compacted";
591
- properties: {
592
- sessionID: string;
650
+ metadata?: {
651
+ [key: string]: unknown;
652
+ };
653
+ time: {
654
+ start: number;
655
+ end: number;
593
656
  };
594
657
  };
595
- export type EventFileWatcherUpdated = {
596
- type: "file.watcher.updated";
597
- properties: {
598
- file: string;
599
- event: "add" | "change" | "unlink";
658
+ export type ToolState = ToolStatePending | ToolStateRunning | ToolStateCompleted | ToolStateError;
659
+ export type ToolPart = {
660
+ id: string;
661
+ sessionID: string;
662
+ messageID: string;
663
+ type: "tool";
664
+ callID: string;
665
+ tool: string;
666
+ state: ToolState;
667
+ metadata?: {
668
+ [key: string]: unknown;
600
669
  };
601
670
  };
602
- export type Todo = {
603
- /**
604
- * Brief description of the task
605
- */
606
- content: string;
607
- /**
608
- * Current status of the task: pending, in_progress, completed, cancelled
609
- */
610
- status: string;
611
- /**
612
- * Priority level of the task: high, medium, low
613
- */
614
- priority: string;
671
+ export type StepStartPart = {
672
+ id: string;
673
+ sessionID: string;
674
+ messageID: string;
675
+ type: "step-start";
676
+ snapshot?: string;
615
677
  };
616
- export type EventTodoUpdated = {
617
- type: "todo.updated";
618
- properties: {
619
- sessionID: string;
620
- todos: Array<Todo>;
678
+ export type StepFinishPart = {
679
+ id: string;
680
+ sessionID: string;
681
+ messageID: string;
682
+ type: "step-finish";
683
+ reason: string;
684
+ snapshot?: string;
685
+ cost: number;
686
+ tokens: {
687
+ total?: number;
688
+ input: number;
689
+ output: number;
690
+ reasoning: number;
691
+ cache: {
692
+ read: number;
693
+ write: number;
694
+ };
621
695
  };
622
696
  };
623
- export type EventTuiPromptAppend = {
624
- type: "tui.prompt.append";
625
- properties: {
626
- text: string;
627
- };
697
+ export type SnapshotPart = {
698
+ id: string;
699
+ sessionID: string;
700
+ messageID: string;
701
+ type: "snapshot";
702
+ snapshot: string;
628
703
  };
629
- export type EventTuiCommandExecute = {
630
- type: "tui.command.execute";
631
- properties: {
632
- command: "session.list" | "session.new" | "session.share" | "session.interrupt" | "session.compact" | "session.page.up" | "session.page.down" | "session.line.up" | "session.line.down" | "session.half.page.up" | "session.half.page.down" | "session.first" | "session.last" | "prompt.clear" | "prompt.submit" | "agent.cycle" | string;
633
- };
704
+ export type PatchPart = {
705
+ id: string;
706
+ sessionID: string;
707
+ messageID: string;
708
+ type: "patch";
709
+ hash: string;
710
+ files: Array<string>;
634
711
  };
635
- export type EventTuiToastShow = {
636
- type: "tui.toast.show";
637
- properties: {
638
- title?: string;
639
- message: string;
640
- variant: "info" | "success" | "warning" | "error";
641
- /**
642
- * Duration in milliseconds
643
- */
644
- duration?: number;
712
+ export type AgentPart = {
713
+ id: string;
714
+ sessionID: string;
715
+ messageID: string;
716
+ type: "agent";
717
+ name: string;
718
+ source?: {
719
+ value: string;
720
+ start: number;
721
+ end: number;
645
722
  };
646
723
  };
647
- export type EventTuiSessionSelect = {
648
- type: "tui.session.select";
649
- properties: {
650
- /**
651
- * Session ID to navigate to
652
- */
653
- sessionID: string;
724
+ export type RetryPart = {
725
+ id: string;
726
+ sessionID: string;
727
+ messageID: string;
728
+ type: "retry";
729
+ attempt: number;
730
+ error: ApiError;
731
+ time: {
732
+ created: number;
654
733
  };
655
734
  };
656
- export type EventMcpToolsChanged = {
657
- type: "mcp.tools.changed";
658
- properties: {
659
- server: string;
660
- };
735
+ export type CompactionPart = {
736
+ id: string;
737
+ sessionID: string;
738
+ messageID: string;
739
+ type: "compaction";
740
+ auto: boolean;
741
+ overflow?: boolean;
661
742
  };
662
- export type EventMcpBrowserOpenFailed = {
663
- type: "mcp.browser.open.failed";
743
+ export type Part = TextPart | SubtaskPart | ReasoningPart | FilePart | ToolPart | StepStartPart | StepFinishPart | SnapshotPart | PatchPart | AgentPart | RetryPart | CompactionPart;
744
+ export type EventMessagePartUpdated = {
745
+ type: "message.part.updated";
664
746
  properties: {
665
- mcpName: string;
666
- url: string;
747
+ sessionID: string;
748
+ part: Part;
749
+ time: number;
667
750
  };
668
751
  };
669
- export type EventCommandExecuted = {
670
- type: "command.executed";
752
+ export type EventMessagePartRemoved = {
753
+ type: "message.part.removed";
671
754
  properties: {
672
- name: string;
673
755
  sessionID: string;
674
- arguments: string;
675
756
  messageID: string;
757
+ partID: string;
676
758
  };
677
759
  };
678
760
  export type PermissionAction = "allow" | "deny" | "ask";
@@ -717,104 +799,120 @@ export type Session = {
717
799
  export type EventSessionCreated = {
718
800
  type: "session.created";
719
801
  properties: {
802
+ sessionID: string;
720
803
  info: Session;
721
804
  };
722
805
  };
723
806
  export type EventSessionUpdated = {
724
807
  type: "session.updated";
725
808
  properties: {
809
+ sessionID: string;
726
810
  info: Session;
727
811
  };
728
812
  };
729
813
  export type EventSessionDeleted = {
730
814
  type: "session.deleted";
731
- properties: {
732
- info: Session;
733
- };
734
- };
735
- export type EventSessionDiff = {
736
- type: "session.diff";
737
815
  properties: {
738
816
  sessionID: string;
739
- diff: Array<FileDiff>;
740
- };
741
- };
742
- export type EventSessionError = {
743
- type: "session.error";
744
- properties: {
745
- sessionID?: string;
746
- error?: ProviderAuthError | UnknownError | MessageOutputLengthError | MessageAbortedError | StructuredOutputError | ContextOverflowError | ApiError;
747
- };
748
- };
749
- export type EventVcsBranchUpdated = {
750
- type: "vcs.branch.updated";
751
- properties: {
752
- branch?: string;
817
+ info: Session;
753
818
  };
754
819
  };
755
- export type EventWorkspaceReady = {
756
- type: "workspace.ready";
757
- properties: {
758
- name: string;
759
- };
820
+ export type Event = EventInstallationUpdated | EventInstallationUpdateAvailable | EventProjectUpdated | EventServerInstanceDisposed | EventServerConnected | EventGlobalDisposed | EventLspClientDiagnostics | EventLspUpdated | EventMessagePartDelta | EventPermissionAsked | EventPermissionReplied | EventSessionStatus | EventSessionIdle | EventQuestionAsked | EventQuestionReplied | EventQuestionRejected | EventSessionCompacted | EventFileEdited | EventFileWatcherUpdated | EventTodoUpdated | EventTuiPromptAppend | EventTuiCommandExecute | EventTuiToastShow | EventTuiSessionSelect | EventMcpToolsChanged | EventMcpBrowserOpenFailed | EventCommandExecuted | EventSessionDiff | EventSessionError | EventVcsBranchUpdated | EventWorkspaceReady | EventWorkspaceFailed | EventPtyCreated | EventPtyUpdated | EventPtyExited | EventPtyDeleted | EventWorktreeReady | EventWorktreeFailed | EventMessageUpdated | EventMessageRemoved | EventMessagePartUpdated | EventMessagePartRemoved | EventSessionCreated | EventSessionUpdated | EventSessionDeleted;
821
+ export type GlobalEvent = {
822
+ directory: string;
823
+ payload: Event;
760
824
  };
761
- export type EventWorkspaceFailed = {
762
- type: "workspace.failed";
763
- properties: {
764
- message: string;
825
+ export type SyncEventMessageUpdated = {
826
+ type: "message.updated.1";
827
+ aggregate: "sessionID";
828
+ data: {
829
+ sessionID: string;
830
+ info: Message;
765
831
  };
766
832
  };
767
- export type Pty = {
768
- id: string;
769
- title: string;
770
- command: string;
771
- args: Array<string>;
772
- cwd: string;
773
- status: "running" | "exited";
774
- pid: number;
775
- };
776
- export type EventPtyCreated = {
777
- type: "pty.created";
778
- properties: {
779
- info: Pty;
833
+ export type SyncEventMessageRemoved = {
834
+ type: "message.removed.1";
835
+ aggregate: "sessionID";
836
+ data: {
837
+ sessionID: string;
838
+ messageID: string;
780
839
  };
781
840
  };
782
- export type EventPtyUpdated = {
783
- type: "pty.updated";
784
- properties: {
785
- info: Pty;
841
+ export type SyncEventMessagePartUpdated = {
842
+ type: "message.part.updated.1";
843
+ aggregate: "sessionID";
844
+ data: {
845
+ sessionID: string;
846
+ part: Part;
847
+ time: number;
786
848
  };
787
849
  };
788
- export type EventPtyExited = {
789
- type: "pty.exited";
790
- properties: {
791
- id: string;
792
- exitCode: number;
850
+ export type SyncEventMessagePartRemoved = {
851
+ type: "message.part.removed.1";
852
+ aggregate: "sessionID";
853
+ data: {
854
+ sessionID: string;
855
+ messageID: string;
856
+ partID: string;
793
857
  };
794
858
  };
795
- export type EventPtyDeleted = {
796
- type: "pty.deleted";
797
- properties: {
798
- id: string;
859
+ export type SyncEventSessionCreated = {
860
+ type: "session.created.1";
861
+ aggregate: "sessionID";
862
+ data: {
863
+ sessionID: string;
864
+ info: Session;
799
865
  };
800
866
  };
801
- export type EventWorktreeReady = {
802
- type: "worktree.ready";
803
- properties: {
804
- name: string;
805
- branch: string;
867
+ export type SyncEventSessionUpdated = {
868
+ type: "session.updated.1";
869
+ aggregate: "sessionID";
870
+ data: {
871
+ sessionID: string;
872
+ info: {
873
+ id: string | null;
874
+ slug: string | null;
875
+ projectID: string | null;
876
+ workspaceID: string | null;
877
+ directory: string | null;
878
+ parentID: string | null;
879
+ summary: {
880
+ additions: number;
881
+ deletions: number;
882
+ files: number;
883
+ diffs?: Array<FileDiff>;
884
+ } | null;
885
+ share?: {
886
+ url: string | null;
887
+ };
888
+ title: string | null;
889
+ version: string | null;
890
+ time?: {
891
+ created: number | null;
892
+ updated: number | null;
893
+ compacting: number | null;
894
+ archived: number | null;
895
+ };
896
+ permission: PermissionRuleset | null;
897
+ revert: {
898
+ messageID: string;
899
+ partID?: string;
900
+ snapshot?: string;
901
+ diff?: string;
902
+ } | null;
903
+ };
806
904
  };
807
905
  };
808
- export type EventWorktreeFailed = {
809
- type: "worktree.failed";
810
- properties: {
811
- message: string;
906
+ export type SyncEventSessionDeleted = {
907
+ type: "session.deleted.1";
908
+ aggregate: "sessionID";
909
+ data: {
910
+ sessionID: string;
911
+ info: Session;
812
912
  };
813
913
  };
814
- export type Event = EventInstallationUpdated | EventInstallationUpdateAvailable | EventProjectUpdated | EventServerInstanceDisposed | EventServerConnected | EventGlobalDisposed | EventLspClientDiagnostics | EventLspUpdated | EventFileEdited | EventMessageUpdated | EventMessageRemoved | EventMessagePartUpdated | EventMessagePartDelta | EventMessagePartRemoved | EventPermissionAsked | EventPermissionReplied | EventSessionStatus | EventSessionIdle | EventQuestionAsked | EventQuestionReplied | EventQuestionRejected | EventSessionCompacted | EventFileWatcherUpdated | EventTodoUpdated | EventTuiPromptAppend | EventTuiCommandExecute | EventTuiToastShow | EventTuiSessionSelect | EventMcpToolsChanged | EventMcpBrowserOpenFailed | EventCommandExecuted | EventSessionCreated | EventSessionUpdated | EventSessionDeleted | EventSessionDiff | EventSessionError | EventVcsBranchUpdated | EventWorkspaceReady | EventWorkspaceFailed | EventPtyCreated | EventPtyUpdated | EventPtyExited | EventPtyDeleted | EventWorktreeReady | EventWorktreeFailed;
815
- export type GlobalEvent = {
816
- directory: string;
817
- payload: Event;
914
+ export type SyncEvent = {
915
+ payload: SyncEvent;
818
916
  };
819
917
  /**
820
918
  * Log level
@@ -861,7 +959,6 @@ export type PermissionConfig = {
861
959
  task?: PermissionRuleConfig;
862
960
  external_directory?: PermissionRuleConfig;
863
961
  todowrite?: PermissionActionConfig;
864
- todoread?: PermissionActionConfig;
865
962
  question?: PermissionActionConfig;
866
963
  webfetch?: PermissionActionConfig;
867
964
  websearch?: PermissionActionConfig;
@@ -1604,7 +1701,7 @@ export type Path = {
1604
1701
  directory: string;
1605
1702
  };
1606
1703
  export type VcsInfo = {
1607
- branch: string;
1704
+ branch?: string;
1608
1705
  };
1609
1706
  export type Command = {
1610
1707
  name: string;
@@ -1677,6 +1774,19 @@ export type GlobalEventResponses = {
1677
1774
  200: GlobalEvent;
1678
1775
  };
1679
1776
  export type GlobalEventResponse = GlobalEventResponses[keyof GlobalEventResponses];
1777
+ export type GlobalSyncEventSubscribeData = {
1778
+ body?: never;
1779
+ path?: never;
1780
+ query?: never;
1781
+ url: "/global/sync-event";
1782
+ };
1783
+ export type GlobalSyncEventSubscribeResponses = {
1784
+ /**
1785
+ * Event stream
1786
+ */
1787
+ 200: SyncEvent;
1788
+ };
1789
+ export type GlobalSyncEventSubscribeResponse = GlobalSyncEventSubscribeResponses[keyof GlobalSyncEventSubscribeResponses];
1680
1790
  export type GlobalConfigGetData = {
1681
1791
  body?: never;
1682
1792
  path?: never;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@opencode-ai/sdk",
4
- "version": "1.3.1",
4
+ "version": "1.3.3",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "scripts": {