@opencode-ai/sdk 0.6.4 → 0.6.6

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.
@@ -998,9 +998,28 @@ export type Symbol = {
998
998
  export type FileNode = {
999
999
  name: string;
1000
1000
  path: string;
1001
+ absolute: string;
1001
1002
  type: "file" | "directory";
1002
1003
  ignored: boolean;
1003
1004
  };
1005
+ export type FileContent = {
1006
+ content: string;
1007
+ diff?: string;
1008
+ patch?: {
1009
+ oldFileName: string;
1010
+ newFileName: string;
1011
+ oldHeader?: string;
1012
+ newHeader?: string;
1013
+ hunks: Array<{
1014
+ oldStart: number;
1015
+ oldLines: number;
1016
+ newStart: number;
1017
+ newLines: number;
1018
+ lines: Array<string>;
1019
+ }>;
1020
+ index?: string;
1021
+ };
1022
+ };
1004
1023
  export type File = {
1005
1024
  path: string;
1006
1025
  added: number;
@@ -1666,10 +1685,7 @@ export type FileReadResponses = {
1666
1685
  /**
1667
1686
  * File content
1668
1687
  */
1669
- 200: {
1670
- type: "raw" | "patch";
1671
- content: string;
1672
- };
1688
+ 200: FileContent;
1673
1689
  };
1674
1690
  export type FileReadResponse = FileReadResponses[keyof FileReadResponses];
1675
1691
  export type FileStatusData = {
package/dist/server.d.ts CHANGED
@@ -6,7 +6,18 @@ export type ServerOptions = {
6
6
  timeout?: number;
7
7
  config?: Config;
8
8
  };
9
+ export type TuiOptions = {
10
+ project?: string;
11
+ model?: string;
12
+ session?: string;
13
+ agent?: string;
14
+ signal?: AbortSignal;
15
+ config?: Config;
16
+ };
9
17
  export declare function createOpencodeServer(options?: ServerOptions): Promise<{
10
18
  url: string;
11
19
  close(): void;
12
20
  }>;
21
+ export declare function createOpencodeTui(options?: TuiOptions): {
22
+ close(): void;
23
+ };
package/dist/server.js CHANGED
@@ -61,3 +61,31 @@ export async function createOpencodeServer(options) {
61
61
  },
62
62
  };
63
63
  }
64
+ export function createOpencodeTui(options) {
65
+ const args = [];
66
+ if (options?.project) {
67
+ args.push(`--project=${options.project}`);
68
+ }
69
+ if (options?.model) {
70
+ args.push(`--model=${options.model}`);
71
+ }
72
+ if (options?.session) {
73
+ args.push(`--session=${options.session}`);
74
+ }
75
+ if (options?.agent) {
76
+ args.push(`--agent=${options.agent}`);
77
+ }
78
+ const proc = spawn(`opencode`, args, {
79
+ signal: options?.signal,
80
+ stdio: 'inherit',
81
+ env: {
82
+ ...process.env,
83
+ OPENCODE_CONFIG_CONTENT: JSON.stringify(options?.config ?? {}),
84
+ },
85
+ });
86
+ return {
87
+ close() {
88
+ proc.kill();
89
+ },
90
+ };
91
+ }
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.6.4",
4
+ "version": "0.6.6",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "typecheck": "tsc --noEmit"