opencode-rewind 0.1.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.
- package/README.md +244 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/opencode.d.ts +178 -0
- package/dist/providers/opencode.d.ts.map +1 -0
- package/dist/providers/opencode.js +687 -0
- package/dist/providers/opencode.js.map +1 -0
- package/dist/types.d.ts +164 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +75 -0
package/README.md
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
# rewind
|
|
2
|
+
|
|
3
|
+
Local viewer, analytics dashboard, and TypeScript library for inspecting OpenCode sessions.
|
|
4
|
+
|
|
5
|
+
Published on npm as `opencode-rewind`.
|
|
6
|
+
|
|
7
|
+
This project is not built by the OpenCode team and is not affiliated with OpenCode or Anomaly.
|
|
8
|
+
|
|
9
|
+
## Why
|
|
10
|
+
|
|
11
|
+
OpenCode stores rich local session state, but the raw SQLite data is awkward to inspect directly.
|
|
12
|
+
Rewind turns it into something easier to use for:
|
|
13
|
+
|
|
14
|
+
- browsing sessions
|
|
15
|
+
- drilling into tool calls and subagents
|
|
16
|
+
- inspecting compactions, diffs, and todos
|
|
17
|
+
- understanding token usage, timing, and cost over time
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm add opencode-rewind
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Library
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { createRewind } from "opencode-rewind";
|
|
29
|
+
|
|
30
|
+
const rewind = createRewind();
|
|
31
|
+
|
|
32
|
+
const sessions = await rewind.listSessions({ limit: 20 });
|
|
33
|
+
const session = await rewind.getSession(sessions[0].id);
|
|
34
|
+
const messages = await rewind.getMessages(sessions[0].id);
|
|
35
|
+
|
|
36
|
+
rewind.close();
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Config
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { createRewind } from "opencode-rewind";
|
|
43
|
+
|
|
44
|
+
const rewind = createRewind({
|
|
45
|
+
basePath: "/custom/path/to/opencode-data-dir",
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
`basePath` should point at the OpenCode data directory.
|
|
50
|
+
|
|
51
|
+
By default Rewind reads:
|
|
52
|
+
|
|
53
|
+
- `~/.local/share/opencode/opencode.db`
|
|
54
|
+
- `~/.local/share/opencode/storage/session_diff/*.json`
|
|
55
|
+
|
|
56
|
+
If `XDG_DATA_HOME` is set, Rewind uses that base directory instead of `~/.local/share`.
|
|
57
|
+
|
|
58
|
+
### Direct Provider
|
|
59
|
+
|
|
60
|
+
If you want the OpenCode-specific provider directly:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { createOpenCodeProvider } from "opencode-rewind/providers/opencode";
|
|
64
|
+
|
|
65
|
+
const provider = createOpenCodeProvider();
|
|
66
|
+
const sessions = await provider.listSessions();
|
|
67
|
+
provider.close();
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## API
|
|
71
|
+
|
|
72
|
+
### `createRewind(config?)`
|
|
73
|
+
|
|
74
|
+
Returns an object with:
|
|
75
|
+
|
|
76
|
+
- `listSessions(options?)`
|
|
77
|
+
- `getSession(sessionId)`
|
|
78
|
+
- `getMessages(sessionId)`
|
|
79
|
+
- `close()`
|
|
80
|
+
|
|
81
|
+
### `listSessions(options?)`
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
await rewind.listSessions({
|
|
85
|
+
projectPath: "/Users/me/myproject",
|
|
86
|
+
after: "2025-01-01T00:00:00Z",
|
|
87
|
+
before: "2025-02-01T00:00:00Z",
|
|
88
|
+
includeSubagents: true,
|
|
89
|
+
limit: 50,
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Subagent sessions are excluded by default. Pass `includeSubagents: true` to include them.
|
|
94
|
+
|
|
95
|
+
### `getSession(sessionId)`
|
|
96
|
+
|
|
97
|
+
Returns a normalized `Session` with:
|
|
98
|
+
|
|
99
|
+
- session summary fields
|
|
100
|
+
- `messages`
|
|
101
|
+
- `diffs` from `storage/session_diff/<sessionId>.json` when present
|
|
102
|
+
- `todos` from the SQLite `todo` table when present
|
|
103
|
+
|
|
104
|
+
### `getMessages(sessionId)`
|
|
105
|
+
|
|
106
|
+
Returns normalized messages only.
|
|
107
|
+
|
|
108
|
+
## Data Model
|
|
109
|
+
|
|
110
|
+
The source of truth is `src/types.ts`. The most important shapes are:
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
interface SessionSummary {
|
|
114
|
+
id: string;
|
|
115
|
+
provider: "opencode";
|
|
116
|
+
title?: string;
|
|
117
|
+
slug?: string;
|
|
118
|
+
createdAt: string;
|
|
119
|
+
updatedAt: string;
|
|
120
|
+
messageCount?: number;
|
|
121
|
+
projectPath?: string;
|
|
122
|
+
usage?: TokenUsage;
|
|
123
|
+
cost?: number;
|
|
124
|
+
totalDurationMs?: number;
|
|
125
|
+
parentSessionId?: string;
|
|
126
|
+
cliVersion?: string;
|
|
127
|
+
codeChanges?: { additions: number; deletions: number; files: number };
|
|
128
|
+
permissions?: Array<{ type: string; glob?: string; description?: string }>;
|
|
129
|
+
primaryModel?: string;
|
|
130
|
+
models?: string[];
|
|
131
|
+
toolCallCount?: number;
|
|
132
|
+
subagentCount?: number;
|
|
133
|
+
compactionCount?: number;
|
|
134
|
+
topTools?: Array<{ name: string; count: number }>;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
interface Session<TRaw = unknown> extends SessionSummary {
|
|
138
|
+
messages: Message<TRaw>[];
|
|
139
|
+
diffs?: OpenCodeSessionDiff[];
|
|
140
|
+
todos?: OpenCodeTodo[];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
interface Message<TRaw = unknown> {
|
|
144
|
+
id: string;
|
|
145
|
+
role: "user" | "assistant" | "system" | "tool";
|
|
146
|
+
content: MessageContent[];
|
|
147
|
+
timestamp: string;
|
|
148
|
+
completedAt?: string;
|
|
149
|
+
durationMs?: number;
|
|
150
|
+
model?: string;
|
|
151
|
+
usage?: TokenUsage;
|
|
152
|
+
cost?: number;
|
|
153
|
+
parentId?: string;
|
|
154
|
+
isCompactSummary?: boolean;
|
|
155
|
+
error?: MessageError;
|
|
156
|
+
stopReason?: string;
|
|
157
|
+
cwd?: string;
|
|
158
|
+
apiProvider?: string;
|
|
159
|
+
mode?: string;
|
|
160
|
+
summary?: { title?: string; diffs?: unknown[] };
|
|
161
|
+
raw: TRaw;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
type MessageContent =
|
|
165
|
+
| { type: "text"; text: string; textType?: string }
|
|
166
|
+
| { type: "tool_use"; toolName: string; toolCallId?: string; input: unknown; subagentSessionId?: string; durationMs?: number; title?: string }
|
|
167
|
+
| { type: "tool_result"; toolCallId?: string; toolName?: string; output: string; isError?: boolean; durationMs?: number; interrupted?: boolean; status?: string }
|
|
168
|
+
| { type: "thinking"; text: string; durationMs?: number; signature?: string }
|
|
169
|
+
| { type: "compaction"; auto: boolean; preTokens?: number }
|
|
170
|
+
| { type: "patch"; hash: string; files: string[] }
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Token Usage
|
|
174
|
+
|
|
175
|
+
```ts
|
|
176
|
+
interface TokenUsage {
|
|
177
|
+
inputTokens?: number;
|
|
178
|
+
outputTokens?: number;
|
|
179
|
+
reasoningTokens?: number;
|
|
180
|
+
cacheReadTokens?: number;
|
|
181
|
+
cacheCreationTokens?: number;
|
|
182
|
+
totalTokens?: number;
|
|
183
|
+
peakInputTokens?: number;
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Every normalized message also carries a `.raw` field with the original OpenCode payload.
|
|
188
|
+
|
|
189
|
+
## OpenCode-Specific Behavior
|
|
190
|
+
|
|
191
|
+
### Subagents
|
|
192
|
+
|
|
193
|
+
OpenCode spawns subagent sessions for parallel work like exploration and research.
|
|
194
|
+
These sessions have `parentSessionId` set to the parent session ID.
|
|
195
|
+
|
|
196
|
+
### Compaction
|
|
197
|
+
|
|
198
|
+
Rewind surfaces compaction as:
|
|
199
|
+
|
|
200
|
+
- a message containing `{ type: "compaction", auto: boolean }`
|
|
201
|
+
- the next assistant message marked with `isCompactSummary: true`
|
|
202
|
+
- possible API errors on messages that failed during context pressure
|
|
203
|
+
|
|
204
|
+
## Web App
|
|
205
|
+
|
|
206
|
+
Rewind also includes a Next.js web app for browsing and analyzing OpenCode sessions.
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
pnpm dev # http://localhost:3838
|
|
210
|
+
pnpm build:app
|
|
211
|
+
pnpm serve # http://localhost:3838
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### REST API
|
|
215
|
+
|
|
216
|
+
The web app exposes these routes:
|
|
217
|
+
|
|
218
|
+
```text
|
|
219
|
+
GET /api/sessions
|
|
220
|
+
GET /api/sessions?project=/path/to/project
|
|
221
|
+
GET /api/sessions?after=2025-01-01T00:00:00Z&before=2025-02-01T23:59:59.999Z
|
|
222
|
+
GET /api/sessions?includeSubagents=true
|
|
223
|
+
GET /api/sessions?limit=100
|
|
224
|
+
|
|
225
|
+
GET /api/session/:sessionId
|
|
226
|
+
GET /api/session/:sessionId?startMessage=10&endMessage=40
|
|
227
|
+
|
|
228
|
+
GET /api/dashboard
|
|
229
|
+
GET /api/dashboard?after=2025-01-01T00:00:00Z&before=2025-02-01T23:59:59.999Z
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Development
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
pnpm install
|
|
236
|
+
pnpm typecheck
|
|
237
|
+
pnpm test
|
|
238
|
+
pnpm build
|
|
239
|
+
pnpm build:app
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## License
|
|
243
|
+
|
|
244
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* rewind – OpenCode session viewer and analytics library.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { createRewind } from "opencode-rewind";
|
|
7
|
+
*
|
|
8
|
+
* const rewind = createRewind();
|
|
9
|
+
* const sessions = await rewind.listSessions({ limit: 20 });
|
|
10
|
+
* const session = await rewind.getSession(sessions[0].id);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export type { MessageRole, TextContent, ToolUseContent, ToolResultContent, ThinkingContent, CompactionContent, PatchContent, MessageContent, TokenUsage, MessageError, Message, CodeChangeSummary, PermissionRule, SessionSummary, Session, OpenCodeSessionDiff, OpenCodeTodo, OpenCodeConfig, ListSessionsOptions, } from "./types";
|
|
14
|
+
export { createOpenCodeProvider } from "./providers/opencode";
|
|
15
|
+
export type { OpenCodeRawSession, OpenCodeRawMessage, OpenCodePart, OpenCodeTextPart, OpenCodeReasoningPart, OpenCodeToolPart, OpenCodeCompactionPart, OpenCodeStepStartPart, OpenCodeStepFinishPart, OpenCodePatchPart, OpenCodeProject, } from "./providers/opencode";
|
|
16
|
+
import type { ListSessionsOptions, Message, OpenCodeConfig, Session, SessionSummary } from "./types";
|
|
17
|
+
export interface Rewind {
|
|
18
|
+
listSessions(options?: ListSessionsOptions): Promise<SessionSummary[]>;
|
|
19
|
+
getSession(sessionId: string): Promise<Session | null>;
|
|
20
|
+
getMessages(sessionId: string): Promise<Message[]>;
|
|
21
|
+
close(): void;
|
|
22
|
+
}
|
|
23
|
+
export declare function createRewind(config?: OpenCodeConfig): Rewind;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,YAAY,EACV,WAAW,EACX,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,UAAU,EACV,YAAY,EACZ,OAAO,EACP,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,OAAO,EACP,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,mBAAmB,GACpB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAGrG,MAAM,WAAW,MAAM;IACrB,YAAY,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IACvE,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IACvD,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IACnD,KAAK,IAAI,IAAI,CAAC;CACf;AAED,wBAAgB,YAAY,CAAC,MAAM,GAAE,cAAmB,GAAG,MAAM,CAoBhE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* rewind – OpenCode session viewer and analytics library.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { createRewind } from "opencode-rewind";
|
|
7
|
+
*
|
|
8
|
+
* const rewind = createRewind();
|
|
9
|
+
* const sessions = await rewind.listSessions({ limit: 20 });
|
|
10
|
+
* const session = await rewind.getSession(sessions[0].id);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export { createOpenCodeProvider } from "./providers/opencode";
|
|
14
|
+
import { createOpenCodeProvider } from "./providers/opencode";
|
|
15
|
+
export function createRewind(config = {}) {
|
|
16
|
+
const provider = createOpenCodeProvider(config);
|
|
17
|
+
return {
|
|
18
|
+
listSessions(options) {
|
|
19
|
+
return provider.listSessions(options);
|
|
20
|
+
},
|
|
21
|
+
getSession(sessionId) {
|
|
22
|
+
return provider.getSession(sessionId);
|
|
23
|
+
},
|
|
24
|
+
getMessages(sessionId) {
|
|
25
|
+
return provider.getMessages(sessionId);
|
|
26
|
+
},
|
|
27
|
+
close() {
|
|
28
|
+
provider.close();
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAwBH,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAiB9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAS9D,MAAM,UAAU,YAAY,CAAC,SAAyB,EAAE;IACtD,MAAM,QAAQ,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAEhD,OAAO;QACL,YAAY,CAAC,OAAO;YAClB,OAAO,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACxC,CAAC;QAED,UAAU,CAAC,SAAS;YAClB,OAAO,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QACxC,CAAC;QAED,WAAW,CAAC,SAAS;YACnB,OAAO,QAAQ,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QACzC,CAAC;QAED,KAAK;YACH,QAAQ,CAAC,KAAK,EAAE,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type { ListSessionsOptions, Message, OpenCodeConfig, Session, SessionSummary } from "../types";
|
|
2
|
+
export interface OpenCodeRawSession {
|
|
3
|
+
id: string;
|
|
4
|
+
slug?: string;
|
|
5
|
+
version?: string;
|
|
6
|
+
projectID: string;
|
|
7
|
+
directory?: string;
|
|
8
|
+
parentID?: string;
|
|
9
|
+
title?: string;
|
|
10
|
+
time: {
|
|
11
|
+
created: number;
|
|
12
|
+
updated: number;
|
|
13
|
+
};
|
|
14
|
+
summary?: {
|
|
15
|
+
additions: number;
|
|
16
|
+
deletions: number;
|
|
17
|
+
files: number;
|
|
18
|
+
};
|
|
19
|
+
permission?: Array<{
|
|
20
|
+
type: string;
|
|
21
|
+
glob?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
export interface OpenCodeRawMessage {
|
|
26
|
+
id: string;
|
|
27
|
+
sessionID: string;
|
|
28
|
+
role: string;
|
|
29
|
+
time: {
|
|
30
|
+
created: number;
|
|
31
|
+
completed?: number;
|
|
32
|
+
};
|
|
33
|
+
parentID?: string;
|
|
34
|
+
modelID?: string;
|
|
35
|
+
providerID?: string;
|
|
36
|
+
mode?: string;
|
|
37
|
+
agent?: string;
|
|
38
|
+
cost?: number;
|
|
39
|
+
tokens?: {
|
|
40
|
+
input: number;
|
|
41
|
+
output: number;
|
|
42
|
+
reasoning: number;
|
|
43
|
+
total?: number;
|
|
44
|
+
cache?: {
|
|
45
|
+
read: number;
|
|
46
|
+
write: number;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
finish?: string;
|
|
50
|
+
model?: {
|
|
51
|
+
providerID: string;
|
|
52
|
+
modelID: string;
|
|
53
|
+
};
|
|
54
|
+
summary?: {
|
|
55
|
+
title?: string;
|
|
56
|
+
diffs?: unknown[];
|
|
57
|
+
};
|
|
58
|
+
path?: {
|
|
59
|
+
cwd?: string;
|
|
60
|
+
root?: string;
|
|
61
|
+
};
|
|
62
|
+
tools?: Record<string, unknown>;
|
|
63
|
+
/** API error, present when the model call failed (e.g. context overflow). */
|
|
64
|
+
error?: {
|
|
65
|
+
name: string;
|
|
66
|
+
data?: {
|
|
67
|
+
message?: string;
|
|
68
|
+
statusCode?: number;
|
|
69
|
+
isRetryable?: boolean;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
/** Parts loaded from disk/db and attached during reading */
|
|
73
|
+
_parts?: OpenCodePart[];
|
|
74
|
+
}
|
|
75
|
+
export type OpenCodePart = OpenCodeTextPart | OpenCodeReasoningPart | OpenCodeToolPart | OpenCodeCompactionPart | OpenCodePatchPart | OpenCodeStepStartPart | OpenCodeStepFinishPart;
|
|
76
|
+
export interface OpenCodeTextPart {
|
|
77
|
+
id: string;
|
|
78
|
+
sessionID: string;
|
|
79
|
+
messageID: string;
|
|
80
|
+
type: "text";
|
|
81
|
+
text: string;
|
|
82
|
+
time?: {
|
|
83
|
+
start: number;
|
|
84
|
+
end: number;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export interface OpenCodeReasoningPart {
|
|
88
|
+
id: string;
|
|
89
|
+
sessionID: string;
|
|
90
|
+
messageID: string;
|
|
91
|
+
type: "reasoning";
|
|
92
|
+
text: string;
|
|
93
|
+
time?: {
|
|
94
|
+
start: number;
|
|
95
|
+
end: number;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export interface OpenCodeToolPart {
|
|
99
|
+
id: string;
|
|
100
|
+
sessionID: string;
|
|
101
|
+
messageID: string;
|
|
102
|
+
type: "tool";
|
|
103
|
+
callID: string;
|
|
104
|
+
tool: string;
|
|
105
|
+
state: {
|
|
106
|
+
status: string;
|
|
107
|
+
input: unknown;
|
|
108
|
+
output?: string;
|
|
109
|
+
title?: string;
|
|
110
|
+
metadata?: Record<string, unknown>;
|
|
111
|
+
time?: {
|
|
112
|
+
start: number;
|
|
113
|
+
end: number;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
export interface OpenCodeCompactionPart {
|
|
118
|
+
id: string;
|
|
119
|
+
sessionID: string;
|
|
120
|
+
messageID: string;
|
|
121
|
+
type: "compaction";
|
|
122
|
+
/** Whether compaction was triggered automatically. */
|
|
123
|
+
auto: boolean;
|
|
124
|
+
}
|
|
125
|
+
export interface OpenCodePatchPart {
|
|
126
|
+
id: string;
|
|
127
|
+
sessionID: string;
|
|
128
|
+
messageID: string;
|
|
129
|
+
type: "patch";
|
|
130
|
+
hash: string;
|
|
131
|
+
files: string[];
|
|
132
|
+
}
|
|
133
|
+
export interface OpenCodeStepStartPart {
|
|
134
|
+
id: string;
|
|
135
|
+
sessionID: string;
|
|
136
|
+
messageID: string;
|
|
137
|
+
type: "step-start";
|
|
138
|
+
snapshot?: string;
|
|
139
|
+
}
|
|
140
|
+
export interface OpenCodeStepFinishPart {
|
|
141
|
+
id: string;
|
|
142
|
+
sessionID: string;
|
|
143
|
+
messageID: string;
|
|
144
|
+
type: "step-finish";
|
|
145
|
+
reason?: string;
|
|
146
|
+
snapshot?: string;
|
|
147
|
+
cost?: number;
|
|
148
|
+
tokens?: {
|
|
149
|
+
input: number;
|
|
150
|
+
output: number;
|
|
151
|
+
reasoning: number;
|
|
152
|
+
cache?: {
|
|
153
|
+
read: number;
|
|
154
|
+
write: number;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
export interface OpenCodeProject {
|
|
159
|
+
id: string;
|
|
160
|
+
worktree: string;
|
|
161
|
+
vcs?: string;
|
|
162
|
+
time?: {
|
|
163
|
+
created: number;
|
|
164
|
+
updated: number;
|
|
165
|
+
};
|
|
166
|
+
sandboxes?: unknown;
|
|
167
|
+
}
|
|
168
|
+
export interface OpenCodeProvider {
|
|
169
|
+
id: "opencode";
|
|
170
|
+
name: string;
|
|
171
|
+
basePath: string;
|
|
172
|
+
listSessions(options?: ListSessionsOptions): Promise<SessionSummary[]>;
|
|
173
|
+
getSession(sessionId: string): Promise<Session<OpenCodeRawMessage> | null>;
|
|
174
|
+
getMessages(sessionId: string): Promise<Message<OpenCodeRawMessage>[]>;
|
|
175
|
+
close(): void;
|
|
176
|
+
}
|
|
177
|
+
export declare function createOpenCodeProvider(config?: OpenCodeConfig): OpenCodeProvider;
|
|
178
|
+
//# sourceMappingURL=opencode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencode.d.ts","sourceRoot":"","sources":["../../src/providers/opencode.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,mBAAmB,EACnB,OAAO,EAGP,cAAc,EAId,OAAO,EACP,cAAc,EAEf,MAAM,UAAU,CAAC;AAQlB,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,OAAO,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAClE,UAAU,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC3E;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI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