@opencode-ai/sdk 0.7.9 → 0.9.0

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 { Options as ClientOptions, TDataShape, Client } from "./client/index.js";
2
- import type { ProjectListData, ProjectListResponses, ProjectCurrentData, ProjectCurrentResponses, EventSubscribeData, EventSubscribeResponses, ConfigGetData, ConfigGetResponses, ToolRegisterData, ToolRegisterResponses, ToolRegisterErrors, ToolIdsData, ToolIdsResponses, ToolIdsErrors, ToolListData, ToolListResponses, ToolListErrors, PathGetData, PathGetResponses, SessionListData, SessionListResponses, SessionCreateData, SessionCreateResponses, SessionCreateErrors, SessionDeleteData, SessionDeleteResponses, SessionGetData, SessionGetResponses, SessionUpdateData, SessionUpdateResponses, SessionChildrenData, SessionChildrenResponses, SessionInitData, SessionInitResponses, SessionAbortData, SessionAbortResponses, SessionUnshareData, SessionUnshareResponses, SessionShareData, SessionShareResponses, SessionSummarizeData, SessionSummarizeResponses, SessionMessagesData, SessionMessagesResponses, SessionPromptData, SessionPromptResponses, SessionMessageData, SessionMessageResponses, SessionCommandData, SessionCommandResponses, SessionShellData, SessionShellResponses, SessionRevertData, SessionRevertResponses, SessionUnrevertData, SessionUnrevertResponses, PostSessionByIdPermissionsByPermissionIdData, PostSessionByIdPermissionsByPermissionIdResponses, CommandListData, CommandListResponses, ConfigProvidersData, ConfigProvidersResponses, FindTextData, FindTextResponses, FindFilesData, FindFilesResponses, FindSymbolsData, FindSymbolsResponses, FileListData, FileListResponses, FileReadData, FileReadResponses, FileStatusData, FileStatusResponses, AppLogData, AppLogResponses, AppAgentsData, AppAgentsResponses, TuiAppendPromptData, TuiAppendPromptResponses, TuiOpenHelpData, TuiOpenHelpResponses, TuiOpenSessionsData, TuiOpenSessionsResponses, TuiOpenThemesData, TuiOpenThemesResponses, TuiOpenModelsData, TuiOpenModelsResponses, TuiSubmitPromptData, TuiSubmitPromptResponses, TuiClearPromptData, TuiClearPromptResponses, TuiExecuteCommandData, TuiExecuteCommandResponses, TuiShowToastData, TuiShowToastResponses, AuthSetData, AuthSetResponses, AuthSetErrors } from "./types.gen.js";
2
+ import type { ProjectListData, ProjectListResponses, ProjectCurrentData, ProjectCurrentResponses, EventSubscribeData, EventSubscribeResponses, ConfigGetData, ConfigGetResponses, ToolRegisterData, ToolRegisterResponses, ToolRegisterErrors, ToolIdsData, ToolIdsResponses, ToolIdsErrors, ToolListData, ToolListResponses, ToolListErrors, PathGetData, PathGetResponses, SessionListData, SessionListResponses, SessionCreateData, SessionCreateResponses, SessionCreateErrors, SessionDeleteData, SessionDeleteResponses, SessionGetData, SessionGetResponses, SessionUpdateData, SessionUpdateResponses, SessionChildrenData, SessionChildrenResponses, SessionInitData, SessionInitResponses, SessionAbortData, SessionAbortResponses, SessionUnshareData, SessionUnshareResponses, SessionShareData, SessionShareResponses, SessionSummarizeData, SessionSummarizeResponses, SessionMessagesData, SessionMessagesResponses, SessionPromptData, SessionPromptResponses, SessionMessageData, SessionMessageResponses, SessionCommandData, SessionCommandResponses, SessionShellData, SessionShellResponses, SessionRevertData, SessionRevertResponses, SessionUnrevertData, SessionUnrevertResponses, PostSessionIdPermissionsPermissionIdData, PostSessionIdPermissionsPermissionIdResponses, CommandListData, CommandListResponses, ConfigProvidersData, ConfigProvidersResponses, FindTextData, FindTextResponses, FindFilesData, FindFilesResponses, FindSymbolsData, FindSymbolsResponses, FileListData, FileListResponses, FileReadData, FileReadResponses, FileStatusData, FileStatusResponses, AppLogData, AppLogResponses, AppAgentsData, AppAgentsResponses, TuiAppendPromptData, TuiAppendPromptResponses, TuiOpenHelpData, TuiOpenHelpResponses, TuiOpenSessionsData, TuiOpenSessionsResponses, TuiOpenThemesData, TuiOpenThemesResponses, TuiOpenModelsData, TuiOpenModelsResponses, TuiSubmitPromptData, TuiSubmitPromptResponses, TuiClearPromptData, TuiClearPromptResponses, TuiExecuteCommandData, TuiExecuteCommandResponses, TuiShowToastData, TuiShowToastResponses, AuthSetData, AuthSetResponses, AuthSetErrors } from "./types.gen.js";
3
3
  export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
4
4
  /**
5
5
  * You can provide a client instance returned by `createClient()` instead of
@@ -231,7 +231,7 @@ export declare class OpencodeClient extends _HeyApiClient {
231
231
  /**
232
232
  * Respond to a permission request
233
233
  */
234
- postSessionByIdPermissionsByPermissionId<ThrowOnError extends boolean = false>(options: Options<PostSessionByIdPermissionsByPermissionIdData, ThrowOnError>): import("./client/types.gen.js").RequestResult<PostSessionByIdPermissionsByPermissionIdResponses, unknown, ThrowOnError, "fields">;
234
+ postSessionIdPermissionsPermissionId<ThrowOnError extends boolean = false>(options: Options<PostSessionIdPermissionsPermissionIdData, ThrowOnError>): import("./client/types.gen.js").RequestResult<PostSessionIdPermissionsPermissionIdResponses, unknown, ThrowOnError, "fields">;
235
235
  project: Project;
236
236
  event: Event;
237
237
  config: Config;
@@ -506,7 +506,7 @@ export class OpencodeClient extends _HeyApiClient {
506
506
  /**
507
507
  * Respond to a permission request
508
508
  */
509
- postSessionByIdPermissionsByPermissionId(options) {
509
+ postSessionIdPermissionsPermissionId(options) {
510
510
  return (options.client ?? this._client).post({
511
511
  url: "/session/{id}/permissions/{permissionID}",
512
512
  ...options,
@@ -7,37 +7,6 @@ export type Project = {
7
7
  initialized?: number;
8
8
  };
9
9
  };
10
- export type Event = ({
11
- type: "installation.updated";
12
- } & EventInstallationUpdated) | ({
13
- type: "lsp.client.diagnostics";
14
- } & EventLspClientDiagnostics) | ({
15
- type: "message.updated";
16
- } & EventMessageUpdated) | ({
17
- type: "message.removed";
18
- } & EventMessageRemoved) | ({
19
- type: "message.part.updated";
20
- } & EventMessagePartUpdated) | ({
21
- type: "message.part.removed";
22
- } & EventMessagePartRemoved) | ({
23
- type: "permission.updated";
24
- } & EventPermissionUpdated) | ({
25
- type: "permission.replied";
26
- } & EventPermissionReplied) | ({
27
- type: "file.edited";
28
- } & EventFileEdited) | ({
29
- type: "session.updated";
30
- } & EventSessionUpdated) | ({
31
- type: "session.deleted";
32
- } & EventSessionDeleted) | ({
33
- type: "session.idle";
34
- } & EventSessionIdle) | ({
35
- type: "session.error";
36
- } & EventSessionError) | ({
37
- type: "session.compacted";
38
- } & EventSessionCompacted) | ({
39
- type: "server.connected";
40
- } & EventServerConnected);
41
10
  export type EventInstallationUpdated = {
42
11
  type: "installation.updated";
43
12
  properties: {
@@ -51,17 +20,6 @@ export type EventLspClientDiagnostics = {
51
20
  path: string;
52
21
  };
53
22
  };
54
- export type EventMessageUpdated = {
55
- type: "message.updated";
56
- properties: {
57
- info: Message;
58
- };
59
- };
60
- export type Message = ({
61
- role: "user";
62
- } & UserMessage) | ({
63
- role: "assistant";
64
- } & AssistantMessage);
65
23
  export type UserMessage = {
66
24
  id: string;
67
25
  sessionID: string;
@@ -70,6 +28,31 @@ export type UserMessage = {
70
28
  created: number;
71
29
  };
72
30
  };
31
+ export type ProviderAuthError = {
32
+ name: "ProviderAuthError";
33
+ data: {
34
+ providerID: string;
35
+ message: string;
36
+ };
37
+ };
38
+ export type UnknownError = {
39
+ name: "UnknownError";
40
+ data: {
41
+ message: string;
42
+ };
43
+ };
44
+ export type MessageOutputLengthError = {
45
+ name: "MessageOutputLengthError";
46
+ data: {
47
+ [key: string]: unknown;
48
+ };
49
+ };
50
+ export type MessageAbortedError = {
51
+ name: "MessageAbortedError";
52
+ data: {
53
+ message: string;
54
+ };
55
+ };
73
56
  export type AssistantMessage = {
74
57
  id: string;
75
58
  sessionID: string;
@@ -78,15 +61,7 @@ export type AssistantMessage = {
78
61
  created: number;
79
62
  completed?: number;
80
63
  };
81
- error?: ({
82
- name: "ProviderAuthError";
83
- } & ProviderAuthError) | ({
84
- name: "UnknownError";
85
- } & UnknownError) | ({
86
- name: "MessageOutputLengthError";
87
- } & MessageOutputLengthError) | ({
88
- name: "MessageAbortedError";
89
- } & MessageAbortedError);
64
+ error?: ProviderAuthError | UnknownError | MessageOutputLengthError | MessageAbortedError;
90
65
  system: Array<string>;
91
66
  modelID: string;
92
67
  providerID: string;
@@ -107,29 +82,11 @@ export type AssistantMessage = {
107
82
  };
108
83
  };
109
84
  };
110
- export type ProviderAuthError = {
111
- name: "ProviderAuthError";
112
- data: {
113
- providerID: string;
114
- message: string;
115
- };
116
- };
117
- export type UnknownError = {
118
- name: "UnknownError";
119
- data: {
120
- message: string;
121
- };
122
- };
123
- export type MessageOutputLengthError = {
124
- name: "MessageOutputLengthError";
125
- data: {
126
- [key: string]: unknown;
127
- };
128
- };
129
- export type MessageAbortedError = {
130
- name: "MessageAbortedError";
131
- data: {
132
- [key: string]: unknown;
85
+ export type Message = UserMessage | AssistantMessage;
86
+ export type EventMessageUpdated = {
87
+ type: "message.updated";
88
+ properties: {
89
+ info: Message;
133
90
  };
134
91
  };
135
92
  export type EventMessageRemoved = {
@@ -139,31 +96,6 @@ export type EventMessageRemoved = {
139
96
  messageID: string;
140
97
  };
141
98
  };
142
- export type EventMessagePartUpdated = {
143
- type: "message.part.updated";
144
- properties: {
145
- part: Part;
146
- };
147
- };
148
- export type Part = ({
149
- type: "text";
150
- } & TextPart) | ({
151
- type: "reasoning";
152
- } & ReasoningPart) | ({
153
- type: "file";
154
- } & FilePart) | ({
155
- type: "tool";
156
- } & ToolPart) | ({
157
- type: "step-start";
158
- } & StepStartPart) | ({
159
- type: "step-finish";
160
- } & StepFinishPart) | ({
161
- type: "snapshot";
162
- } & SnapshotPart) | ({
163
- type: "patch";
164
- } & PatchPart) | ({
165
- type: "agent";
166
- } & AgentPart);
167
99
  export type TextPart = {
168
100
  id: string;
169
101
  sessionID: string;
@@ -190,38 +122,15 @@ export type ReasoningPart = {
190
122
  end?: number;
191
123
  };
192
124
  };
193
- export type FilePart = {
194
- id: string;
195
- sessionID: string;
196
- messageID: string;
197
- type: "file";
198
- mime: string;
199
- filename?: string;
200
- url: string;
201
- source?: FilePartSource;
202
- };
203
- export type FilePartSource = ({
204
- type: "file";
205
- } & FileSource) | ({
206
- type: "symbol";
207
- } & SymbolSource);
208
- export type FileSource = {
209
- text: FilePartSourceText;
210
- type: "file";
211
- path: string;
212
- };
213
125
  export type FilePartSourceText = {
214
126
  value: string;
215
127
  start: number;
216
128
  end: number;
217
129
  };
218
- export type SymbolSource = {
130
+ export type FileSource = {
219
131
  text: FilePartSourceText;
220
- type: "symbol";
132
+ type: "file";
221
133
  path: string;
222
- range: Range;
223
- name: string;
224
- kind: number;
225
134
  };
226
135
  export type Range = {
227
136
  start: {
@@ -233,30 +142,31 @@ export type Range = {
233
142
  character: number;
234
143
  };
235
144
  };
236
- export type ToolPart = {
145
+ export type SymbolSource = {
146
+ text: FilePartSourceText;
147
+ type: "symbol";
148
+ path: string;
149
+ range: Range;
150
+ name: string;
151
+ kind: number;
152
+ };
153
+ export type FilePartSource = FileSource | SymbolSource;
154
+ export type FilePart = {
237
155
  id: string;
238
156
  sessionID: string;
239
157
  messageID: string;
240
- type: "tool";
241
- callID: string;
242
- tool: string;
243
- state: ToolState;
158
+ type: "file";
159
+ mime: string;
160
+ filename?: string;
161
+ url: string;
162
+ source?: FilePartSource;
244
163
  };
245
- export type ToolState = ({
246
- status: "pending";
247
- } & ToolStatePending) | ({
248
- status: "running";
249
- } & ToolStateRunning) | ({
250
- status: "completed";
251
- } & ToolStateCompleted) | ({
252
- status: "error";
253
- } & ToolStateError);
254
164
  export type ToolStatePending = {
255
165
  status: "pending";
256
166
  };
257
167
  export type ToolStateRunning = {
258
168
  status: "running";
259
- input?: unknown;
169
+ input: unknown;
260
170
  title?: string;
261
171
  metadata?: {
262
172
  [key: string]: unknown;
@@ -295,6 +205,16 @@ export type ToolStateError = {
295
205
  end: number;
296
206
  };
297
207
  };
208
+ export type ToolState = ToolStatePending | ToolStateRunning | ToolStateCompleted | ToolStateError;
209
+ export type ToolPart = {
210
+ id: string;
211
+ sessionID: string;
212
+ messageID: string;
213
+ type: "tool";
214
+ callID: string;
215
+ tool: string;
216
+ state: ToolState;
217
+ };
298
218
  export type StepStartPart = {
299
219
  id: string;
300
220
  sessionID: string;
@@ -344,6 +264,13 @@ export type AgentPart = {
344
264
  end: number;
345
265
  };
346
266
  };
267
+ export type Part = TextPart | ReasoningPart | FilePart | ToolPart | StepStartPart | StepFinishPart | SnapshotPart | PatchPart | AgentPart;
268
+ export type EventMessagePartUpdated = {
269
+ type: "message.part.updated";
270
+ properties: {
271
+ part: Part;
272
+ };
273
+ };
347
274
  export type EventMessagePartRemoved = {
348
275
  type: "message.part.removed";
349
276
  properties: {
@@ -352,14 +279,16 @@ export type EventMessagePartRemoved = {
352
279
  partID: string;
353
280
  };
354
281
  };
355
- export type EventPermissionUpdated = {
356
- type: "permission.updated";
357
- properties: Permission;
282
+ export type EventSessionCompacted = {
283
+ type: "session.compacted";
284
+ properties: {
285
+ sessionID: string;
286
+ };
358
287
  };
359
288
  export type Permission = {
360
289
  id: string;
361
290
  type: string;
362
- pattern?: string;
291
+ pattern?: string | Array<string>;
363
292
  sessionID: string;
364
293
  messageID: string;
365
294
  callID?: string;
@@ -371,6 +300,10 @@ export type Permission = {
371
300
  created: number;
372
301
  };
373
302
  };
303
+ export type EventPermissionUpdated = {
304
+ type: "permission.updated";
305
+ properties: Permission;
306
+ };
374
307
  export type EventPermissionReplied = {
375
308
  type: "permission.replied";
376
309
  properties: {
@@ -385,10 +318,10 @@ export type EventFileEdited = {
385
318
  file: string;
386
319
  };
387
320
  };
388
- export type EventSessionUpdated = {
389
- type: "session.updated";
321
+ export type EventSessionIdle = {
322
+ type: "session.idle";
390
323
  properties: {
391
- info: Session;
324
+ sessionID: string;
392
325
  };
393
326
  };
394
327
  export type Session = {
@@ -413,37 +346,23 @@ export type Session = {
413
346
  diff?: string;
414
347
  };
415
348
  };
416
- export type EventSessionDeleted = {
417
- type: "session.deleted";
349
+ export type EventSessionUpdated = {
350
+ type: "session.updated";
418
351
  properties: {
419
352
  info: Session;
420
353
  };
421
354
  };
422
- export type EventSessionIdle = {
423
- type: "session.idle";
355
+ export type EventSessionDeleted = {
356
+ type: "session.deleted";
424
357
  properties: {
425
- sessionID: string;
358
+ info: Session;
426
359
  };
427
360
  };
428
361
  export type EventSessionError = {
429
362
  type: "session.error";
430
363
  properties: {
431
364
  sessionID?: string;
432
- error?: ({
433
- name: "ProviderAuthError";
434
- } & ProviderAuthError) | ({
435
- name: "UnknownError";
436
- } & UnknownError) | ({
437
- name: "MessageOutputLengthError";
438
- } & MessageOutputLengthError) | ({
439
- name: "MessageAbortedError";
440
- } & MessageAbortedError);
441
- };
442
- };
443
- export type EventSessionCompacted = {
444
- type: "session.compacted";
445
- properties: {
446
- sessionID: string;
365
+ error?: ProviderAuthError | UnknownError | MessageOutputLengthError | MessageAbortedError;
447
366
  };
448
367
  };
449
368
  export type EventServerConnected = {
@@ -452,405 +371,207 @@ export type EventServerConnected = {
452
371
  [key: string]: unknown;
453
372
  };
454
373
  };
455
- export type Config = {
374
+ export type Event = EventInstallationUpdated | EventLspClientDiagnostics | EventMessageUpdated | EventMessageRemoved | EventMessagePartUpdated | EventMessagePartRemoved | EventSessionCompacted | EventPermissionUpdated | EventPermissionReplied | EventFileEdited | EventSessionIdle | EventSessionUpdated | EventSessionDeleted | EventSessionError | EventServerConnected;
375
+ /**
376
+ * Custom keybind configurations
377
+ */
378
+ export type KeybindsConfig = {
456
379
  /**
457
- * JSON schema reference for configuration validation
380
+ * Leader key for keybind combinations
458
381
  */
459
- $schema?: string;
382
+ leader?: string;
460
383
  /**
461
- * Theme name to use for the interface
384
+ * Show help dialog
462
385
  */
463
- theme?: string;
386
+ app_help?: string;
464
387
  /**
465
- * Custom keybind configurations
388
+ * Exit the application
466
389
  */
467
- keybinds?: KeybindsConfig;
390
+ app_exit?: string;
468
391
  /**
469
- * TUI specific settings
392
+ * Open external editor
470
393
  */
471
- tui?: {
472
- /**
473
- * TUI scroll speed
474
- */
475
- scroll_speed: number;
476
- };
394
+ editor_open?: string;
477
395
  /**
478
- * Command configuration, see https://opencode.ai/docs/commands
396
+ * List available themes
479
397
  */
480
- command?: {
481
- [key: string]: {
482
- template: string;
483
- description?: string;
484
- agent?: string;
485
- model?: string;
486
- };
487
- };
488
- plugin?: Array<string>;
489
- snapshot?: boolean;
398
+ theme_list?: string;
490
399
  /**
491
- * Control sharing behavior:'manual' allows manual sharing via commands, 'auto' enables automatic sharing, 'disabled' disables all sharing
400
+ * Create/update AGENTS.md
492
401
  */
493
- share?: "manual" | "auto" | "disabled";
402
+ project_init?: string;
494
403
  /**
495
- * @deprecated Use 'share' field instead. Share newly created sessions automatically
404
+ * Toggle tool details
496
405
  */
497
- autoshare?: boolean;
406
+ tool_details?: string;
498
407
  /**
499
- * Automatically update to the latest version
408
+ * Toggle thinking blocks
500
409
  */
501
- autoupdate?: boolean;
410
+ thinking_blocks?: string;
502
411
  /**
503
- * Disable providers that are loaded automatically
412
+ * Export session to editor
504
413
  */
505
- disabled_providers?: Array<string>;
414
+ session_export?: string;
506
415
  /**
507
- * Model to use in the format of provider/model, eg anthropic/claude-2
416
+ * Create a new session
508
417
  */
509
- model?: string;
418
+ session_new?: string;
510
419
  /**
511
- * Small model to use for tasks like title generation in the format of provider/model
420
+ * List all sessions
512
421
  */
513
- small_model?: string;
422
+ session_list?: string;
514
423
  /**
515
- * Custom username to display in conversations instead of system username
424
+ * Show session timeline
516
425
  */
517
- username?: string;
426
+ session_timeline?: string;
518
427
  /**
519
- * @deprecated Use `agent` field instead.
428
+ * Share current session
520
429
  */
521
- mode?: {
522
- build?: AgentConfig;
523
- plan?: AgentConfig;
524
- [key: string]: AgentConfig | undefined;
525
- };
430
+ session_share?: string;
526
431
  /**
527
- * Agent configuration, see https://opencode.ai/docs/agent
432
+ * Unshare current session
528
433
  */
529
- agent?: {
530
- plan?: AgentConfig;
531
- build?: AgentConfig;
532
- general?: AgentConfig;
533
- [key: string]: AgentConfig | undefined;
534
- };
434
+ session_unshare?: string;
535
435
  /**
536
- * Custom provider configurations and model overrides
436
+ * Interrupt current session
537
437
  */
538
- provider?: {
539
- [key: string]: {
540
- api?: string;
541
- name?: string;
542
- env?: Array<string>;
543
- id?: string;
544
- npm?: string;
545
- models?: {
546
- [key: string]: {
547
- id?: string;
548
- name?: string;
549
- release_date?: string;
550
- attachment?: boolean;
551
- reasoning?: boolean;
552
- temperature?: boolean;
553
- tool_call?: boolean;
554
- cost?: {
555
- input: number;
556
- output: number;
557
- cache_read?: number;
558
- cache_write?: number;
559
- };
560
- limit?: {
561
- context: number;
562
- output: number;
563
- };
564
- experimental?: boolean;
565
- options?: {
566
- [key: string]: unknown;
567
- };
568
- provider?: {
569
- npm: string;
570
- };
571
- };
572
- };
573
- options?: {
574
- apiKey?: string;
575
- baseURL?: string;
576
- /**
577
- * Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout.
578
- */
579
- timeout?: number | false;
580
- [key: string]: unknown | string | (number | false) | undefined;
581
- };
582
- };
583
- };
584
- /**
585
- * MCP (Model Context Protocol) server configurations
586
- */
587
- mcp?: {
588
- [key: string]: ({
589
- type: "local";
590
- } & McpLocalConfig) | ({
591
- type: "remote";
592
- } & McpRemoteConfig);
593
- };
594
- formatter?: {
595
- [key: string]: {
596
- disabled?: boolean;
597
- command?: Array<string>;
598
- environment?: {
599
- [key: string]: string;
600
- };
601
- extensions?: Array<string>;
602
- };
603
- };
604
- lsp?: {
605
- [key: string]: {
606
- disabled: true;
607
- } | {
608
- command: Array<string>;
609
- extensions?: Array<string>;
610
- disabled?: boolean;
611
- env?: {
612
- [key: string]: string;
613
- };
614
- initialization?: {
615
- [key: string]: unknown;
616
- };
617
- };
618
- };
619
- /**
620
- * Additional instruction files or patterns to include
621
- */
622
- instructions?: Array<string>;
623
- /**
624
- * @deprecated Always uses stretch layout.
625
- */
626
- layout?: LayoutConfig;
627
- permission?: {
628
- edit?: "ask" | "allow" | "deny";
629
- bash?: ("ask" | "allow" | "deny") | {
630
- [key: string]: "ask" | "allow" | "deny";
631
- };
632
- webfetch?: "ask" | "allow" | "deny";
633
- };
634
- tools?: {
635
- [key: string]: boolean;
636
- };
637
- experimental?: {
638
- hook?: {
639
- file_edited?: {
640
- [key: string]: Array<{
641
- command: Array<string>;
642
- environment?: {
643
- [key: string]: string;
644
- };
645
- }>;
646
- };
647
- session_completed?: Array<{
648
- command: Array<string>;
649
- environment?: {
650
- [key: string]: string;
651
- };
652
- }>;
653
- };
654
- disable_paste_summary?: boolean;
655
- };
656
- };
657
- export type KeybindsConfig = {
658
- /**
659
- * Leader key for keybind combinations
660
- */
661
- leader: string;
662
- /**
663
- * Show help dialog
664
- */
665
- app_help: string;
666
- /**
667
- * Exit the application
668
- */
669
- app_exit: string;
670
- /**
671
- * Open external editor
672
- */
673
- editor_open: string;
674
- /**
675
- * List available themes
676
- */
677
- theme_list: string;
678
- /**
679
- * Create/update AGENTS.md
680
- */
681
- project_init: string;
682
- /**
683
- * Toggle tool details
684
- */
685
- tool_details: string;
686
- /**
687
- * Toggle thinking blocks
688
- */
689
- thinking_blocks: string;
690
- /**
691
- * Export session to editor
692
- */
693
- session_export: string;
694
- /**
695
- * Create a new session
696
- */
697
- session_new: string;
698
- /**
699
- * List all sessions
700
- */
701
- session_list: string;
702
- /**
703
- * Show session timeline
704
- */
705
- session_timeline: string;
706
- /**
707
- * Share current session
708
- */
709
- session_share: string;
710
- /**
711
- * Unshare current session
712
- */
713
- session_unshare: string;
714
- /**
715
- * Interrupt current session
716
- */
717
- session_interrupt: string;
438
+ session_interrupt?: string;
718
439
  /**
719
440
  * Compact the session
720
441
  */
721
- session_compact: string;
442
+ session_compact?: string;
722
443
  /**
723
444
  * Cycle to next child session
724
445
  */
725
- session_child_cycle: string;
446
+ session_child_cycle?: string;
726
447
  /**
727
448
  * Cycle to previous child session
728
449
  */
729
- session_child_cycle_reverse: string;
450
+ session_child_cycle_reverse?: string;
730
451
  /**
731
452
  * Scroll messages up by one page
732
453
  */
733
- messages_page_up: string;
454
+ messages_page_up?: string;
734
455
  /**
735
456
  * Scroll messages down by one page
736
457
  */
737
- messages_page_down: string;
458
+ messages_page_down?: string;
738
459
  /**
739
460
  * Scroll messages up by half page
740
461
  */
741
- messages_half_page_up: string;
462
+ messages_half_page_up?: string;
742
463
  /**
743
464
  * Scroll messages down by half page
744
465
  */
745
- messages_half_page_down: string;
466
+ messages_half_page_down?: string;
746
467
  /**
747
468
  * Navigate to first message
748
469
  */
749
- messages_first: string;
470
+ messages_first?: string;
750
471
  /**
751
472
  * Navigate to last message
752
473
  */
753
- messages_last: string;
474
+ messages_last?: string;
754
475
  /**
755
476
  * Copy message
756
477
  */
757
- messages_copy: string;
478
+ messages_copy?: string;
758
479
  /**
759
480
  * Undo message
760
481
  */
761
- messages_undo: string;
482
+ messages_undo?: string;
762
483
  /**
763
484
  * Redo message
764
485
  */
765
- messages_redo: string;
486
+ messages_redo?: string;
766
487
  /**
767
488
  * List available models
768
489
  */
769
- model_list: string;
490
+ model_list?: string;
770
491
  /**
771
492
  * Next recent model
772
493
  */
773
- model_cycle_recent: string;
494
+ model_cycle_recent?: string;
774
495
  /**
775
496
  * Previous recent model
776
497
  */
777
- model_cycle_recent_reverse: string;
498
+ model_cycle_recent_reverse?: string;
778
499
  /**
779
500
  * List agents
780
501
  */
781
- agent_list: string;
502
+ agent_list?: string;
782
503
  /**
783
504
  * Next agent
784
505
  */
785
- agent_cycle: string;
506
+ agent_cycle?: string;
786
507
  /**
787
508
  * Previous agent
788
509
  */
789
- agent_cycle_reverse: string;
510
+ agent_cycle_reverse?: string;
790
511
  /**
791
512
  * Clear input field
792
513
  */
793
- input_clear: string;
514
+ input_clear?: string;
794
515
  /**
795
516
  * Paste from clipboard
796
517
  */
797
- input_paste: string;
518
+ input_paste?: string;
798
519
  /**
799
520
  * Submit input
800
521
  */
801
- input_submit: string;
522
+ input_submit?: string;
802
523
  /**
803
524
  * Insert newline in input
804
525
  */
805
- input_newline: string;
526
+ input_newline?: string;
806
527
  /**
807
528
  * @deprecated use agent_cycle. Next mode
808
529
  */
809
- switch_mode: string;
530
+ switch_mode?: string;
810
531
  /**
811
532
  * @deprecated use agent_cycle_reverse. Previous mode
812
533
  */
813
- switch_mode_reverse: string;
534
+ switch_mode_reverse?: string;
814
535
  /**
815
536
  * @deprecated use agent_cycle. Next agent
816
537
  */
817
- switch_agent: string;
538
+ switch_agent?: string;
818
539
  /**
819
540
  * @deprecated use agent_cycle_reverse. Previous agent
820
541
  */
821
- switch_agent_reverse: string;
542
+ switch_agent_reverse?: string;
822
543
  /**
823
544
  * @deprecated Currently not available. List files
824
545
  */
825
- file_list: string;
546
+ file_list?: string;
826
547
  /**
827
548
  * @deprecated Close file
828
549
  */
829
- file_close: string;
550
+ file_close?: string;
830
551
  /**
831
552
  * @deprecated Search file
832
553
  */
833
- file_search: string;
554
+ file_search?: string;
834
555
  /**
835
556
  * @deprecated Split/unified diff
836
557
  */
837
- file_diff_toggle: string;
558
+ file_diff_toggle?: string;
838
559
  /**
839
560
  * @deprecated Navigate to previous message
840
561
  */
841
- messages_previous: string;
562
+ messages_previous?: string;
842
563
  /**
843
564
  * @deprecated Navigate to next message
844
565
  */
845
- messages_next: string;
566
+ messages_next?: string;
846
567
  /**
847
568
  * @deprecated Toggle layout
848
569
  */
849
- messages_layout_toggle: string;
570
+ messages_layout_toggle?: string;
850
571
  /**
851
572
  * @deprecated use messages_undo. Revert message
852
573
  */
853
- messages_revert: string;
574
+ messages_revert?: string;
854
575
  };
855
576
  export type AgentConfig = {
856
577
  model?: string;
@@ -883,42 +604,6 @@ export type AgentConfig = {
883
604
  webfetch?: "ask" | "allow" | "deny";
884
605
  } | undefined;
885
606
  };
886
- export type Provider = {
887
- api?: string;
888
- name: string;
889
- env: Array<string>;
890
- id: string;
891
- npm?: string;
892
- models: {
893
- [key: string]: Model;
894
- };
895
- };
896
- export type Model = {
897
- id: string;
898
- name: string;
899
- release_date: string;
900
- attachment: boolean;
901
- reasoning: boolean;
902
- temperature: boolean;
903
- tool_call: boolean;
904
- cost: {
905
- input: number;
906
- output: number;
907
- cache_read?: number;
908
- cache_write?: number;
909
- };
910
- limit: {
911
- context: number;
912
- output: number;
913
- };
914
- experimental?: boolean;
915
- options: {
916
- [key: string]: unknown;
917
- };
918
- provider?: {
919
- npm: string;
920
- };
921
- };
922
607
  export type McpLocalConfig = {
923
608
  /**
924
609
  * Type of MCP server connection
@@ -959,12 +644,214 @@ export type McpRemoteConfig = {
959
644
  [key: string]: string;
960
645
  };
961
646
  };
647
+ /**
648
+ * @deprecated Always uses stretch layout.
649
+ */
962
650
  export type LayoutConfig = "auto" | "stretch";
651
+ export type Config = {
652
+ /**
653
+ * JSON schema reference for configuration validation
654
+ */
655
+ $schema?: string;
656
+ /**
657
+ * Theme name to use for the interface
658
+ */
659
+ theme?: string;
660
+ keybinds?: KeybindsConfig;
661
+ /**
662
+ * TUI specific settings
663
+ */
664
+ tui?: {
665
+ /**
666
+ * TUI scroll speed
667
+ */
668
+ scroll_speed?: number;
669
+ };
670
+ /**
671
+ * Command configuration, see https://opencode.ai/docs/commands
672
+ */
673
+ command?: {
674
+ [key: string]: {
675
+ template: string;
676
+ description?: string;
677
+ agent?: string;
678
+ model?: string;
679
+ subtask?: boolean;
680
+ };
681
+ };
682
+ plugin?: Array<string>;
683
+ snapshot?: boolean;
684
+ /**
685
+ * Control sharing behavior:'manual' allows manual sharing via commands, 'auto' enables automatic sharing, 'disabled' disables all sharing
686
+ */
687
+ share?: "manual" | "auto" | "disabled";
688
+ /**
689
+ * @deprecated Use 'share' field instead. Share newly created sessions automatically
690
+ */
691
+ autoshare?: boolean;
692
+ /**
693
+ * Automatically update to the latest version
694
+ */
695
+ autoupdate?: boolean;
696
+ /**
697
+ * Disable providers that are loaded automatically
698
+ */
699
+ disabled_providers?: Array<string>;
700
+ /**
701
+ * Model to use in the format of provider/model, eg anthropic/claude-2
702
+ */
703
+ model?: string;
704
+ /**
705
+ * Small model to use for tasks like title generation in the format of provider/model
706
+ */
707
+ small_model?: string;
708
+ /**
709
+ * Custom username to display in conversations instead of system username
710
+ */
711
+ username?: string;
712
+ /**
713
+ * @deprecated Use `agent` field instead.
714
+ */
715
+ mode?: {
716
+ build?: AgentConfig;
717
+ plan?: AgentConfig;
718
+ [key: string]: AgentConfig | undefined;
719
+ };
720
+ /**
721
+ * Agent configuration, see https://opencode.ai/docs/agent
722
+ */
723
+ agent?: {
724
+ plan?: AgentConfig;
725
+ build?: AgentConfig;
726
+ general?: AgentConfig;
727
+ [key: string]: AgentConfig | undefined;
728
+ };
729
+ /**
730
+ * Custom provider configurations and model overrides
731
+ */
732
+ provider?: {
733
+ [key: string]: {
734
+ api?: string;
735
+ name?: string;
736
+ env?: Array<string>;
737
+ id?: string;
738
+ npm?: string;
739
+ models?: {
740
+ [key: string]: {
741
+ id?: string;
742
+ name?: string;
743
+ release_date?: string;
744
+ attachment?: boolean;
745
+ reasoning?: boolean;
746
+ temperature?: boolean;
747
+ tool_call?: boolean;
748
+ cost?: {
749
+ input: number;
750
+ output: number;
751
+ cache_read?: number;
752
+ cache_write?: number;
753
+ };
754
+ limit?: {
755
+ context: number;
756
+ output: number;
757
+ };
758
+ experimental?: boolean;
759
+ options?: {
760
+ [key: string]: unknown;
761
+ };
762
+ provider?: {
763
+ npm: string;
764
+ };
765
+ };
766
+ };
767
+ options?: {
768
+ apiKey?: string;
769
+ baseURL?: string;
770
+ /**
771
+ * Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout.
772
+ */
773
+ timeout?: number | false;
774
+ [key: string]: unknown | string | (number | false) | undefined;
775
+ };
776
+ };
777
+ };
778
+ /**
779
+ * MCP (Model Context Protocol) server configurations
780
+ */
781
+ mcp?: {
782
+ [key: string]: McpLocalConfig | McpRemoteConfig;
783
+ };
784
+ formatter?: {
785
+ [key: string]: {
786
+ disabled?: boolean;
787
+ command?: Array<string>;
788
+ environment?: {
789
+ [key: string]: string;
790
+ };
791
+ extensions?: Array<string>;
792
+ };
793
+ };
794
+ lsp?: {
795
+ [key: string]: {
796
+ disabled: true;
797
+ } | {
798
+ command: Array<string>;
799
+ extensions?: Array<string>;
800
+ disabled?: boolean;
801
+ env?: {
802
+ [key: string]: string;
803
+ };
804
+ initialization?: {
805
+ [key: string]: unknown;
806
+ };
807
+ };
808
+ };
809
+ /**
810
+ * Additional instruction files or patterns to include
811
+ */
812
+ instructions?: Array<string>;
813
+ layout?: LayoutConfig;
814
+ permission?: {
815
+ edit?: "ask" | "allow" | "deny";
816
+ bash?: ("ask" | "allow" | "deny") | {
817
+ [key: string]: "ask" | "allow" | "deny";
818
+ };
819
+ webfetch?: "ask" | "allow" | "deny";
820
+ };
821
+ tools?: {
822
+ [key: string]: boolean;
823
+ };
824
+ experimental?: {
825
+ hook?: {
826
+ file_edited?: {
827
+ [key: string]: Array<{
828
+ command: Array<string>;
829
+ environment?: {
830
+ [key: string]: string;
831
+ };
832
+ }>;
833
+ };
834
+ session_completed?: Array<{
835
+ command: Array<string>;
836
+ environment?: {
837
+ [key: string]: string;
838
+ };
839
+ }>;
840
+ };
841
+ disable_paste_summary?: boolean;
842
+ };
843
+ };
963
844
  export type _Error = {
964
845
  data: {
965
846
  [key: string]: unknown;
966
847
  };
967
848
  };
849
+ export type HttpParamSpec = {
850
+ type: "string" | "number" | "boolean" | "array";
851
+ description?: string;
852
+ optional?: boolean;
853
+ items?: "string" | "number" | "boolean";
854
+ };
968
855
  export type HttpToolRegistration = {
969
856
  id: string;
970
857
  description: string;
@@ -979,19 +866,13 @@ export type HttpToolRegistration = {
979
866
  [key: string]: string;
980
867
  };
981
868
  };
982
- export type HttpParamSpec = {
983
- type: "string" | "number" | "boolean" | "array";
984
- description?: string;
985
- optional?: boolean;
986
- items?: "string" | "number" | "boolean";
987
- };
988
869
  export type ToolIds = Array<string>;
989
- export type ToolList = Array<ToolListItem>;
990
870
  export type ToolListItem = {
991
871
  id: string;
992
872
  description: string;
993
- parameters?: unknown;
873
+ parameters: unknown;
994
874
  };
875
+ export type ToolList = Array<ToolListItem>;
995
876
  export type Path = {
996
877
  state: string;
997
878
  config: string;
@@ -1032,6 +913,43 @@ export type Command = {
1032
913
  agent?: string;
1033
914
  model?: string;
1034
915
  template: string;
916
+ subtask?: boolean;
917
+ };
918
+ export type Model = {
919
+ id: string;
920
+ name: string;
921
+ release_date: string;
922
+ attachment: boolean;
923
+ reasoning: boolean;
924
+ temperature: boolean;
925
+ tool_call: boolean;
926
+ cost: {
927
+ input: number;
928
+ output: number;
929
+ cache_read?: number;
930
+ cache_write?: number;
931
+ };
932
+ limit: {
933
+ context: number;
934
+ output: number;
935
+ };
936
+ experimental?: boolean;
937
+ options: {
938
+ [key: string]: unknown;
939
+ };
940
+ provider?: {
941
+ npm: string;
942
+ };
943
+ };
944
+ export type Provider = {
945
+ api?: string;
946
+ name: string;
947
+ env: Array<string>;
948
+ id: string;
949
+ npm?: string;
950
+ models: {
951
+ [key: string]: Model;
952
+ };
1035
953
  };
1036
954
  export type Symbol = {
1037
955
  name: string;
@@ -1098,13 +1016,6 @@ export type Agent = {
1098
1016
  [key: string]: unknown;
1099
1017
  };
1100
1018
  };
1101
- export type Auth = ({
1102
- type: "oauth";
1103
- } & OAuth) | ({
1104
- type: "api";
1105
- } & ApiAuth) | ({
1106
- type: "wellknown";
1107
- } & WellKnownAuth);
1108
1019
  export type OAuth = {
1109
1020
  type: "oauth";
1110
1021
  refresh: string;
@@ -1120,6 +1031,7 @@ export type WellKnownAuth = {
1120
1031
  key: string;
1121
1032
  token: string;
1122
1033
  };
1034
+ export type Auth = OAuth | ApiAuth | WellKnownAuth;
1123
1035
  export type ProjectListData = {
1124
1036
  body?: never;
1125
1037
  path?: never;
@@ -1506,13 +1418,7 @@ export type SessionPromptData = {
1506
1418
  tools?: {
1507
1419
  [key: string]: boolean;
1508
1420
  };
1509
- parts: Array<({
1510
- type: "text";
1511
- } & TextPartInput) | ({
1512
- type: "file";
1513
- } & FilePartInput) | ({
1514
- type: "agent";
1515
- } & AgentPartInput)>;
1421
+ parts: Array<TextPartInput | FilePartInput | AgentPartInput>;
1516
1422
  };
1517
1423
  path: {
1518
1424
  /**
@@ -1651,7 +1557,7 @@ export type SessionUnrevertResponses = {
1651
1557
  200: Session;
1652
1558
  };
1653
1559
  export type SessionUnrevertResponse = SessionUnrevertResponses[keyof SessionUnrevertResponses];
1654
- export type PostSessionByIdPermissionsByPermissionIdData = {
1560
+ export type PostSessionIdPermissionsPermissionIdData = {
1655
1561
  body?: {
1656
1562
  response: "once" | "always" | "reject";
1657
1563
  };
@@ -1664,13 +1570,13 @@ export type PostSessionByIdPermissionsByPermissionIdData = {
1664
1570
  };
1665
1571
  url: "/session/{id}/permissions/{permissionID}";
1666
1572
  };
1667
- export type PostSessionByIdPermissionsByPermissionIdResponses = {
1573
+ export type PostSessionIdPermissionsPermissionIdResponses = {
1668
1574
  /**
1669
1575
  * Permission processed successfully
1670
1576
  */
1671
1577
  200: boolean;
1672
1578
  };
1673
- export type PostSessionByIdPermissionsByPermissionIdResponse = PostSessionByIdPermissionsByPermissionIdResponses[keyof PostSessionByIdPermissionsByPermissionIdResponses];
1579
+ export type PostSessionIdPermissionsPermissionIdResponse = PostSessionIdPermissionsPermissionIdResponses[keyof PostSessionIdPermissionsPermissionIdResponses];
1674
1580
  export type CommandListData = {
1675
1581
  body?: never;
1676
1582
  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": "0.7.9",
4
+ "version": "0.9.0",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "typecheck": "tsc --noEmit"