@shivaedev/agent-opencode 0.1.0 → 0.2.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/CHANGELOG.md +6 -0
- package/README.md +58 -1
- package/dist/Provider.d.ts +16 -0
- package/dist/Provider.d.ts.map +1 -0
- package/dist/Provider.js +4 -0
- package/dist/Provider.js.map +1 -0
- package/dist/adapters/MessageUpdatedProperties.d.ts +10 -0
- package/dist/adapters/MessageUpdatedProperties.d.ts.map +1 -0
- package/dist/adapters/MessageUpdatedProperties.js +10 -0
- package/dist/adapters/MessageUpdatedProperties.js.map +1 -0
- package/dist/adapters/OpencodeRequest.d.ts +6 -0
- package/dist/adapters/OpencodeRequest.d.ts.map +1 -0
- package/dist/adapters/OpencodeRequest.js +2 -0
- package/dist/adapters/OpencodeRequest.js.map +1 -0
- package/dist/adapters/answerToolRequest.d.ts +4 -0
- package/dist/adapters/answerToolRequest.d.ts.map +1 -0
- package/dist/adapters/answerToolRequest.js +106 -0
- package/dist/adapters/answerToolRequest.js.map +1 -0
- package/dist/adapters/listeningUrl.d.ts +2 -0
- package/dist/adapters/listeningUrl.d.ts.map +1 -0
- package/dist/adapters/listeningUrl.js +5 -0
- package/dist/adapters/listeningUrl.js.map +1 -0
- package/dist/adapters/makeOpencodeServer.d.ts +7 -0
- package/dist/adapters/makeOpencodeServer.d.ts.map +1 -0
- package/dist/adapters/makeOpencodeServer.js +49 -0
- package/dist/adapters/makeOpencodeServer.js.map +1 -0
- package/dist/adapters/mapping.d.ts +7 -0
- package/dist/adapters/mapping.d.ts.map +1 -0
- package/dist/adapters/mapping.js +11 -0
- package/dist/adapters/mapping.js.map +1 -0
- package/dist/adapters/messageAuthors.d.ts +11 -0
- package/dist/adapters/messageAuthors.d.ts.map +1 -0
- package/dist/adapters/messageAuthors.js +24 -0
- package/dist/adapters/messageAuthors.js.map +1 -0
- package/dist/adapters/openSseBuffer.d.ts +6 -0
- package/dist/adapters/openSseBuffer.d.ts.map +1 -0
- package/dist/adapters/openSseBuffer.js +34 -0
- package/dist/adapters/openSseBuffer.js.map +1 -0
- package/dist/adapters/openTurnBoundary.d.ts +11 -0
- package/dist/adapters/openTurnBoundary.d.ts.map +1 -0
- package/dist/adapters/openTurnBoundary.js +46 -0
- package/dist/adapters/openTurnBoundary.js.map +1 -0
- package/dist/adapters/opencodePlugin.config.d.ts +11 -0
- package/dist/adapters/opencodePlugin.config.d.ts.map +1 -0
- package/dist/adapters/opencodePlugin.config.js +9 -0
- package/dist/adapters/opencodePlugin.config.js.map +1 -0
- package/dist/adapters/partEvents.d.ts +7 -0
- package/dist/adapters/partEvents.d.ts.map +1 -0
- package/dist/adapters/partEvents.js +62 -0
- package/dist/adapters/partEvents.js.map +1 -0
- package/dist/adapters/projection.d.ts +7 -0
- package/dist/adapters/projection.d.ts.map +1 -0
- package/dist/adapters/projection.js +41 -0
- package/dist/adapters/projection.js.map +1 -0
- package/dist/adapters/protocol.d.ts +36 -0
- package/dist/adapters/protocol.d.ts.map +1 -0
- package/dist/adapters/protocol.js +32 -0
- package/dist/adapters/protocol.js.map +1 -0
- package/dist/adapters/protocolParts.d.ts +48 -0
- package/dist/adapters/protocolParts.d.ts.map +1 -0
- package/dist/adapters/protocolParts.js +47 -0
- package/dist/adapters/protocolParts.js.map +1 -0
- package/dist/adapters/providerAddress.d.ts +5 -0
- package/dist/adapters/providerAddress.d.ts.map +1 -0
- package/dist/adapters/providerAddress.js +21 -0
- package/dist/adapters/providerAddress.js.map +1 -0
- package/dist/adapters/serveOpencode.d.ts +13 -0
- package/dist/adapters/serveOpencode.d.ts.map +1 -0
- package/dist/adapters/serveOpencode.js +75 -0
- package/dist/adapters/serveOpencode.js.map +1 -0
- package/dist/adapters/serveToolRequests.d.ts +4 -0
- package/dist/adapters/serveToolRequests.d.ts.map +1 -0
- package/dist/adapters/serveToolRequests.js +23 -0
- package/dist/adapters/serveToolRequests.js.map +1 -0
- package/dist/adapters/servedTools.d.ts +4 -0
- package/dist/adapters/servedTools.d.ts.map +1 -0
- package/dist/adapters/servedTools.js +9 -0
- package/dist/adapters/servedTools.js.map +1 -0
- package/dist/adapters/sessionFrames.d.ts +7 -0
- package/dist/adapters/sessionFrames.d.ts.map +1 -0
- package/dist/adapters/sessionFrames.js +16 -0
- package/dist/adapters/sessionFrames.js.map +1 -0
- package/dist/adapters/toolEvents.d.ts +10 -0
- package/dist/adapters/toolEvents.d.ts.map +1 -0
- package/dist/adapters/toolEvents.js +30 -0
- package/dist/adapters/toolEvents.js.map +1 -0
- package/dist/adapters/toolNames.d.ts +6 -0
- package/dist/adapters/toolNames.d.ts.map +1 -0
- package/dist/adapters/toolNames.js +8 -0
- package/dist/adapters/toolNames.js.map +1 -0
- package/dist/adapters/toolSessions.d.ts +11 -0
- package/dist/adapters/toolSessions.d.ts.map +1 -0
- package/dist/adapters/toolSessions.js +15 -0
- package/dist/adapters/toolSessions.js.map +1 -0
- package/dist/callWhileOpen.d.ts +4 -0
- package/dist/callWhileOpen.d.ts.map +1 -0
- package/dist/callWhileOpen.js +9 -0
- package/dist/callWhileOpen.js.map +1 -0
- package/dist/failure.d.ts +4 -0
- package/dist/failure.d.ts.map +1 -0
- package/dist/failure.js +8 -0
- package/dist/failure.js.map +1 -0
- package/dist/listOpencodeModels.d.ts +11 -0
- package/dist/listOpencodeModels.d.ts.map +1 -0
- package/dist/listOpencodeModels.js +31 -0
- package/dist/listOpencodeModels.js.map +1 -0
- package/dist/openOpencodeSession.d.ts +5 -0
- package/dist/openOpencodeSession.d.ts.map +1 -0
- package/dist/openOpencodeSession.js +40 -0
- package/dist/openOpencodeSession.js.map +1 -0
- package/dist/opencode.d.ts +9 -1
- package/dist/opencode.d.ts.map +1 -1
- package/dist/opencode.js +49 -1
- package/dist/opencode.js.map +1 -1
- package/dist/operations.d.ts +367 -0
- package/dist/operations.d.ts.map +1 -0
- package/dist/operations.js +87 -0
- package/dist/operations.js.map +1 -0
- package/dist/options.d.ts +30 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +2 -0
- package/dist/options.js.map +1 -0
- package/dist/sessionOpen.d.ts +19 -0
- package/dist/sessionOpen.d.ts.map +1 -0
- package/dist/sessionOpen.js +60 -0
- package/dist/sessionOpen.js.map +1 -0
- package/dist/tools.d.ts +14 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +2 -0
- package/dist/tools.js.map +1 -0
- package/dist/turnRequests.d.ts +13 -0
- package/dist/turnRequests.d.ts.map +1 -0
- package/dist/turnRequests.js +19 -0
- package/dist/turnRequests.js.map +1 -0
- package/dist/turnState.d.ts +24 -0
- package/dist/turnState.d.ts.map +1 -0
- package/dist/turnState.js +27 -0
- package/dist/turnState.js.map +1 -0
- package/dist/turns.d.ts +19 -0
- package/dist/turns.d.ts.map +1 -0
- package/dist/turns.js +57 -0
- package/dist/turns.js.map +1 -0
- package/package.json +33 -4
- package/src/Provider.ts +14 -0
- package/src/adapters/MessageUpdatedProperties.ts +9 -0
- package/src/adapters/OpencodeRequest.ts +5 -0
- package/src/adapters/answerToolRequest.ts +121 -0
- package/src/adapters/listeningUrl.ts +4 -0
- package/src/adapters/makeOpencodeServer.ts +77 -0
- package/src/adapters/mapping.ts +14 -0
- package/src/adapters/messageAuthors.ts +31 -0
- package/src/adapters/openSseBuffer.ts +36 -0
- package/src/adapters/openTurnBoundary.ts +58 -0
- package/src/adapters/opencodePlugin.config.ts +17 -0
- package/src/adapters/partEvents.ts +85 -0
- package/src/adapters/projection.ts +46 -0
- package/src/adapters/protocol.ts +31 -0
- package/src/adapters/protocolParts.ts +48 -0
- package/src/adapters/providerAddress.ts +22 -0
- package/src/adapters/serveOpencode.ts +93 -0
- package/src/adapters/serveToolRequests.ts +24 -0
- package/src/adapters/servedTools.ts +11 -0
- package/src/adapters/sessionFrames.ts +25 -0
- package/src/adapters/toolEvents.ts +42 -0
- package/src/adapters/toolNames.ts +7 -0
- package/src/adapters/toolSessions.ts +22 -0
- package/src/callWhileOpen.ts +16 -0
- package/src/failure.ts +7 -0
- package/src/listOpencodeModels.ts +34 -0
- package/src/openOpencodeSession.ts +60 -0
- package/src/opencode.ts +61 -1
- package/src/operations.ts +111 -0
- package/src/options.ts +29 -0
- package/src/sessionOpen.ts +74 -0
- package/src/tools.ts +13 -0
- package/src/turnRequests.ts +25 -0
- package/src/turnState.ts +41 -0
- package/src/turns.ts +89 -0
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
import { Effect, Option, Stream } from "effect";
|
|
2
|
+
import type { RunEvent } from "@shivaedev/agent/events.ts";
|
|
3
|
+
import { ProtocolFailure, UnknownAcceptance } from "@shivaedev/agent/failures.ts";
|
|
4
|
+
import type { Receipt, StartRequest } from "@shivaedev/agent/run.ts";
|
|
5
|
+
import type { OpencodeOptions, SessionHandle } from "#options.ts";
|
|
6
|
+
import { Provider } from "#Provider.ts";
|
|
7
|
+
export interface OpenRun {
|
|
8
|
+
readonly events: Stream.Stream<RunEvent>;
|
|
9
|
+
readonly receipt: Receipt;
|
|
10
|
+
readonly session: SessionHandle;
|
|
11
|
+
}
|
|
12
|
+
export declare const makeOperations: (options: OpencodeOptions) => Effect.Effect<{
|
|
13
|
+
events: (receipt: Receipt) => Stream.Stream<{
|
|
14
|
+
readonly origin?: {
|
|
15
|
+
readonly node?: string | undefined;
|
|
16
|
+
readonly parentNode?: string | undefined;
|
|
17
|
+
readonly spawnedBy: string;
|
|
18
|
+
} | undefined;
|
|
19
|
+
readonly raw?: {
|
|
20
|
+
readonly kind: string;
|
|
21
|
+
readonly payload: string;
|
|
22
|
+
readonly source: string;
|
|
23
|
+
} | undefined;
|
|
24
|
+
readonly receipt: {
|
|
25
|
+
readonly backend: string;
|
|
26
|
+
readonly operationId: string;
|
|
27
|
+
readonly reference: {
|
|
28
|
+
readonly value: string;
|
|
29
|
+
readonly version: number;
|
|
30
|
+
};
|
|
31
|
+
readonly session?: {
|
|
32
|
+
readonly value: string;
|
|
33
|
+
readonly version: number;
|
|
34
|
+
} | undefined;
|
|
35
|
+
};
|
|
36
|
+
readonly type: "acknowledged";
|
|
37
|
+
} | {
|
|
38
|
+
readonly origin?: {
|
|
39
|
+
readonly node?: string | undefined;
|
|
40
|
+
readonly parentNode?: string | undefined;
|
|
41
|
+
readonly spawnedBy: string;
|
|
42
|
+
} | undefined;
|
|
43
|
+
readonly raw?: {
|
|
44
|
+
readonly kind: string;
|
|
45
|
+
readonly payload: string;
|
|
46
|
+
readonly source: string;
|
|
47
|
+
} | undefined;
|
|
48
|
+
readonly state: "accepted" | "awaiting-input" | "completed" | "failed" | "interrupted" | "running";
|
|
49
|
+
readonly type: "execution";
|
|
50
|
+
} | {
|
|
51
|
+
readonly origin?: {
|
|
52
|
+
readonly node?: string | undefined;
|
|
53
|
+
readonly parentNode?: string | undefined;
|
|
54
|
+
readonly spawnedBy: string;
|
|
55
|
+
} | undefined;
|
|
56
|
+
readonly raw?: {
|
|
57
|
+
readonly kind: string;
|
|
58
|
+
readonly payload: string;
|
|
59
|
+
readonly source: string;
|
|
60
|
+
} | undefined;
|
|
61
|
+
readonly reference: string;
|
|
62
|
+
readonly type: "session.opened";
|
|
63
|
+
} | {
|
|
64
|
+
readonly origin?: {
|
|
65
|
+
readonly node?: string | undefined;
|
|
66
|
+
readonly parentNode?: string | undefined;
|
|
67
|
+
readonly spawnedBy: string;
|
|
68
|
+
} | undefined;
|
|
69
|
+
readonly raw?: {
|
|
70
|
+
readonly kind: string;
|
|
71
|
+
readonly payload: string;
|
|
72
|
+
readonly source: string;
|
|
73
|
+
} | undefined;
|
|
74
|
+
readonly inputId?: string | undefined;
|
|
75
|
+
readonly parts: readonly ({
|
|
76
|
+
readonly text: string;
|
|
77
|
+
readonly type: "text";
|
|
78
|
+
} | {
|
|
79
|
+
readonly mediaType: string;
|
|
80
|
+
readonly path: string;
|
|
81
|
+
readonly type: "image";
|
|
82
|
+
} | {
|
|
83
|
+
readonly kind: string;
|
|
84
|
+
readonly payload: string;
|
|
85
|
+
readonly type: "native";
|
|
86
|
+
})[];
|
|
87
|
+
readonly role: "agent" | "user";
|
|
88
|
+
readonly type: "message";
|
|
89
|
+
} | {
|
|
90
|
+
readonly origin?: {
|
|
91
|
+
readonly node?: string | undefined;
|
|
92
|
+
readonly parentNode?: string | undefined;
|
|
93
|
+
readonly spawnedBy: string;
|
|
94
|
+
} | undefined;
|
|
95
|
+
readonly raw?: {
|
|
96
|
+
readonly kind: string;
|
|
97
|
+
readonly payload: string;
|
|
98
|
+
readonly source: string;
|
|
99
|
+
} | undefined;
|
|
100
|
+
readonly text: string;
|
|
101
|
+
readonly type: "thinking";
|
|
102
|
+
} | {
|
|
103
|
+
readonly origin?: {
|
|
104
|
+
readonly node?: string | undefined;
|
|
105
|
+
readonly parentNode?: string | undefined;
|
|
106
|
+
readonly spawnedBy: string;
|
|
107
|
+
} | undefined;
|
|
108
|
+
readonly raw?: {
|
|
109
|
+
readonly kind: string;
|
|
110
|
+
readonly payload: string;
|
|
111
|
+
readonly source: string;
|
|
112
|
+
} | undefined;
|
|
113
|
+
readonly input: string;
|
|
114
|
+
readonly name: string;
|
|
115
|
+
readonly providerName?: string | undefined;
|
|
116
|
+
readonly toolId: string;
|
|
117
|
+
readonly type: "tool.started";
|
|
118
|
+
} | {
|
|
119
|
+
readonly origin?: {
|
|
120
|
+
readonly node?: string | undefined;
|
|
121
|
+
readonly parentNode?: string | undefined;
|
|
122
|
+
readonly spawnedBy: string;
|
|
123
|
+
} | undefined;
|
|
124
|
+
readonly raw?: {
|
|
125
|
+
readonly kind: string;
|
|
126
|
+
readonly payload: string;
|
|
127
|
+
readonly source: string;
|
|
128
|
+
} | undefined;
|
|
129
|
+
readonly ok: boolean;
|
|
130
|
+
readonly output: string;
|
|
131
|
+
readonly toolId: string;
|
|
132
|
+
readonly type: "tool.completed";
|
|
133
|
+
} | {
|
|
134
|
+
readonly origin?: {
|
|
135
|
+
readonly node?: string | undefined;
|
|
136
|
+
readonly parentNode?: string | undefined;
|
|
137
|
+
readonly spawnedBy: string;
|
|
138
|
+
} | undefined;
|
|
139
|
+
readonly raw?: {
|
|
140
|
+
readonly kind: string;
|
|
141
|
+
readonly payload: string;
|
|
142
|
+
readonly source: string;
|
|
143
|
+
} | undefined;
|
|
144
|
+
readonly approvalId: string;
|
|
145
|
+
readonly description: string;
|
|
146
|
+
readonly toolId?: string | undefined;
|
|
147
|
+
readonly type: "approval.requested";
|
|
148
|
+
} | {
|
|
149
|
+
readonly origin?: {
|
|
150
|
+
readonly node?: string | undefined;
|
|
151
|
+
readonly parentNode?: string | undefined;
|
|
152
|
+
readonly spawnedBy: string;
|
|
153
|
+
} | undefined;
|
|
154
|
+
readonly raw?: {
|
|
155
|
+
readonly kind: string;
|
|
156
|
+
readonly payload: string;
|
|
157
|
+
readonly source: string;
|
|
158
|
+
} | undefined;
|
|
159
|
+
readonly type: "usage";
|
|
160
|
+
readonly cacheReadTokens?: number | undefined;
|
|
161
|
+
readonly cacheWriteTokens?: number | undefined;
|
|
162
|
+
readonly inputTokens?: number | undefined;
|
|
163
|
+
readonly model?: string | undefined;
|
|
164
|
+
readonly outputTokens?: number | undefined;
|
|
165
|
+
readonly scope: "cumulative" | "delta";
|
|
166
|
+
readonly unit: "run" | "session" | "turn";
|
|
167
|
+
} | {
|
|
168
|
+
readonly origin?: {
|
|
169
|
+
readonly node?: string | undefined;
|
|
170
|
+
readonly parentNode?: string | undefined;
|
|
171
|
+
readonly spawnedBy: string;
|
|
172
|
+
} | undefined;
|
|
173
|
+
readonly raw?: {
|
|
174
|
+
readonly kind: string;
|
|
175
|
+
readonly payload: string;
|
|
176
|
+
readonly source: string;
|
|
177
|
+
} | undefined;
|
|
178
|
+
readonly type: "cost";
|
|
179
|
+
readonly amount: number;
|
|
180
|
+
readonly currency: string;
|
|
181
|
+
readonly model?: string | undefined;
|
|
182
|
+
readonly scope: "cumulative" | "delta";
|
|
183
|
+
readonly source: "estimated" | "provider";
|
|
184
|
+
readonly unit: "run" | "session" | "turn";
|
|
185
|
+
} | {
|
|
186
|
+
readonly origin?: {
|
|
187
|
+
readonly node?: string | undefined;
|
|
188
|
+
readonly parentNode?: string | undefined;
|
|
189
|
+
readonly spawnedBy: string;
|
|
190
|
+
} | undefined;
|
|
191
|
+
readonly raw?: {
|
|
192
|
+
readonly kind: string;
|
|
193
|
+
readonly payload: string;
|
|
194
|
+
readonly source: string;
|
|
195
|
+
} | undefined;
|
|
196
|
+
readonly model: string;
|
|
197
|
+
readonly reason?: string | undefined;
|
|
198
|
+
readonly type: "model.changed";
|
|
199
|
+
} | {
|
|
200
|
+
readonly origin?: {
|
|
201
|
+
readonly node?: string | undefined;
|
|
202
|
+
readonly parentNode?: string | undefined;
|
|
203
|
+
readonly spawnedBy: string;
|
|
204
|
+
} | undefined;
|
|
205
|
+
readonly raw?: {
|
|
206
|
+
readonly kind: string;
|
|
207
|
+
readonly payload: string;
|
|
208
|
+
readonly source: string;
|
|
209
|
+
} | undefined;
|
|
210
|
+
readonly charter?: string | undefined;
|
|
211
|
+
readonly childRef: string;
|
|
212
|
+
readonly label?: string | undefined;
|
|
213
|
+
readonly parentRef?: string | undefined;
|
|
214
|
+
readonly spawnedBy: string;
|
|
215
|
+
readonly type: "child.opened";
|
|
216
|
+
} | {
|
|
217
|
+
readonly origin?: {
|
|
218
|
+
readonly node?: string | undefined;
|
|
219
|
+
readonly parentNode?: string | undefined;
|
|
220
|
+
readonly spawnedBy: string;
|
|
221
|
+
} | undefined;
|
|
222
|
+
readonly raw?: {
|
|
223
|
+
readonly kind: string;
|
|
224
|
+
readonly payload: string;
|
|
225
|
+
readonly source: string;
|
|
226
|
+
} | undefined;
|
|
227
|
+
readonly childRef: string;
|
|
228
|
+
readonly outcome: "completed" | "failed" | "interrupted" | "unknown";
|
|
229
|
+
readonly summary?: string | undefined;
|
|
230
|
+
readonly type: "child.ended";
|
|
231
|
+
} | {
|
|
232
|
+
readonly origin?: {
|
|
233
|
+
readonly node?: string | undefined;
|
|
234
|
+
readonly parentNode?: string | undefined;
|
|
235
|
+
readonly spawnedBy: string;
|
|
236
|
+
} | undefined;
|
|
237
|
+
readonly raw?: {
|
|
238
|
+
readonly kind: string;
|
|
239
|
+
readonly payload: string;
|
|
240
|
+
readonly source: string;
|
|
241
|
+
} | undefined;
|
|
242
|
+
readonly status: "allowed" | "rejected" | "unknown" | "warning";
|
|
243
|
+
readonly type: "rate.limit";
|
|
244
|
+
readonly windows: readonly {
|
|
245
|
+
readonly durationMinutes?: number | undefined;
|
|
246
|
+
readonly model?: string | undefined;
|
|
247
|
+
readonly resetsAt?: number | undefined;
|
|
248
|
+
readonly usedPercent: number;
|
|
249
|
+
}[];
|
|
250
|
+
} | {
|
|
251
|
+
readonly origin?: {
|
|
252
|
+
readonly node?: string | undefined;
|
|
253
|
+
readonly parentNode?: string | undefined;
|
|
254
|
+
readonly spawnedBy: string;
|
|
255
|
+
} | undefined;
|
|
256
|
+
readonly raw?: {
|
|
257
|
+
readonly kind: string;
|
|
258
|
+
readonly payload: string;
|
|
259
|
+
readonly source: string;
|
|
260
|
+
} | undefined;
|
|
261
|
+
readonly tasks: readonly {
|
|
262
|
+
readonly description: string;
|
|
263
|
+
readonly id: string;
|
|
264
|
+
readonly kind: string;
|
|
265
|
+
}[];
|
|
266
|
+
readonly type: "session.background";
|
|
267
|
+
} | {
|
|
268
|
+
readonly origin?: {
|
|
269
|
+
readonly node?: string | undefined;
|
|
270
|
+
readonly parentNode?: string | undefined;
|
|
271
|
+
readonly spawnedBy: string;
|
|
272
|
+
} | undefined;
|
|
273
|
+
readonly raw?: {
|
|
274
|
+
readonly kind: string;
|
|
275
|
+
readonly payload: string;
|
|
276
|
+
readonly source: string;
|
|
277
|
+
} | undefined;
|
|
278
|
+
readonly type: "gap";
|
|
279
|
+
readonly detail: string;
|
|
280
|
+
readonly kind: string;
|
|
281
|
+
} | {
|
|
282
|
+
readonly origin?: {
|
|
283
|
+
readonly node?: string | undefined;
|
|
284
|
+
readonly parentNode?: string | undefined;
|
|
285
|
+
readonly spawnedBy: string;
|
|
286
|
+
} | undefined;
|
|
287
|
+
readonly raw: {
|
|
288
|
+
readonly kind: string;
|
|
289
|
+
readonly payload: string;
|
|
290
|
+
readonly source: string;
|
|
291
|
+
};
|
|
292
|
+
readonly type: "raw";
|
|
293
|
+
}, ProtocolFailure, never>;
|
|
294
|
+
inspect: (receipt: Receipt) => Effect.Effect<{
|
|
295
|
+
readonly state: "accepted" | "awaiting-input" | "completed" | "failed" | "interrupted" | "running";
|
|
296
|
+
readonly type: "known";
|
|
297
|
+
} | {
|
|
298
|
+
readonly reason: string;
|
|
299
|
+
readonly type: "missing";
|
|
300
|
+
}, never, never>;
|
|
301
|
+
lookup: (receipt: Receipt) => Effect.Effect<OpenRun, ProtocolFailure, never>;
|
|
302
|
+
open: (request: {
|
|
303
|
+
readonly cwd: string;
|
|
304
|
+
readonly effort?: string | undefined;
|
|
305
|
+
readonly input: {
|
|
306
|
+
readonly id?: string | undefined;
|
|
307
|
+
readonly parts: readonly [{
|
|
308
|
+
readonly text: string;
|
|
309
|
+
readonly type: "text";
|
|
310
|
+
}, ...{
|
|
311
|
+
readonly text: string;
|
|
312
|
+
readonly type: "text";
|
|
313
|
+
}[]];
|
|
314
|
+
};
|
|
315
|
+
readonly model?: string | undefined;
|
|
316
|
+
readonly operationId: string;
|
|
317
|
+
}, resume: Option.Option<string>) => Effect.Effect<{
|
|
318
|
+
readonly backend: string;
|
|
319
|
+
readonly operationId: string;
|
|
320
|
+
readonly reference: {
|
|
321
|
+
readonly value: string;
|
|
322
|
+
readonly version: number;
|
|
323
|
+
};
|
|
324
|
+
readonly session?: {
|
|
325
|
+
readonly value: string;
|
|
326
|
+
readonly version: number;
|
|
327
|
+
} | undefined;
|
|
328
|
+
}, import("@shivaedev/agent/failures.ts").BackendUnavailable | ProtocolFailure | import("@shivaedev/agent/failures.ts").Rejected | UnknownAcceptance, import("effect/Scope").Scope>;
|
|
329
|
+
reconcile: (operationId: string) => Effect.Effect<{
|
|
330
|
+
operationId: string;
|
|
331
|
+
reason: string;
|
|
332
|
+
type: "uncertain";
|
|
333
|
+
receipt?: never;
|
|
334
|
+
} | {
|
|
335
|
+
operationId?: never;
|
|
336
|
+
reason?: never;
|
|
337
|
+
receipt: {
|
|
338
|
+
readonly backend: string;
|
|
339
|
+
readonly operationId: string;
|
|
340
|
+
readonly reference: {
|
|
341
|
+
readonly value: string;
|
|
342
|
+
readonly version: number;
|
|
343
|
+
};
|
|
344
|
+
readonly session?: {
|
|
345
|
+
readonly value: string;
|
|
346
|
+
readonly version: number;
|
|
347
|
+
} | undefined;
|
|
348
|
+
};
|
|
349
|
+
type: "accepted";
|
|
350
|
+
}, never, never>;
|
|
351
|
+
resume: (reference: {
|
|
352
|
+
readonly value: string;
|
|
353
|
+
readonly version: number;
|
|
354
|
+
}, request: StartRequest) => Effect.Effect<{
|
|
355
|
+
readonly backend: string;
|
|
356
|
+
readonly operationId: string;
|
|
357
|
+
readonly reference: {
|
|
358
|
+
readonly value: string;
|
|
359
|
+
readonly version: number;
|
|
360
|
+
};
|
|
361
|
+
readonly session?: {
|
|
362
|
+
readonly value: string;
|
|
363
|
+
readonly version: number;
|
|
364
|
+
} | undefined;
|
|
365
|
+
}, import("@shivaedev/agent/failures.ts").BackendUnavailable | ProtocolFailure | import("@shivaedev/agent/failures.ts").Rejected | UnknownAcceptance, import("effect/Scope").Scope>;
|
|
366
|
+
}, never, Provider>;
|
|
367
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,MAAM,EAAE,MAAM,EAAS,MAAM,EAAE,MAAM,QAAQ,CAAC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAClF,OAAO,KAAK,EAAe,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGlF,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,MAAM,WAAW,OAAO;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACzC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;CAChC;AACD,eAAO,MAAM,cAAc;sBAwEP,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBACN,OAAO;;;;;;;sBApEF,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BA0EN,MAAM;;;cAI2E,WAAW;;;;;;;;;;;;;;;;;cAC/F,UAAU;;wBAGpB;QACV,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;KACzB,WACQ,YAAY;;;;;;;;;;;;mBAMtB,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Effect, Option, Queue, Stream } from "effect";
|
|
2
|
+
import { ProtocolFailure, UnknownAcceptance } from "@shivaedev/agent/failures.ts";
|
|
3
|
+
import { opencodeFailure } from "#failure.ts";
|
|
4
|
+
import { openOpencodeSession } from "#openOpencodeSession.ts";
|
|
5
|
+
import { Provider } from "#Provider.ts";
|
|
6
|
+
export const makeOperations = Effect.fnUntraced(function* (options) {
|
|
7
|
+
const server = yield* Provider;
|
|
8
|
+
const runs = new Map();
|
|
9
|
+
const receipts = new Map();
|
|
10
|
+
const observation = new Map();
|
|
11
|
+
function lookup(receipt) {
|
|
12
|
+
return Effect.suspend(() => {
|
|
13
|
+
const run = runs.get(receipt.operationId);
|
|
14
|
+
return receipt.backend === "opencode" && receipt.reference.version === 1 && run?.receipt.reference.value === receipt.reference.value
|
|
15
|
+
? Effect.succeed(run)
|
|
16
|
+
: Effect.fail(opencodeFailure("run is not open in this backend scope"));
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
const open = Effect.fnUntraced(function* (request, resume) {
|
|
20
|
+
if (receipts.has(request.operationId)) {
|
|
21
|
+
return yield* Effect.fail(opencodeFailure("operation already acknowledged; reconcile instead"));
|
|
22
|
+
}
|
|
23
|
+
const session = yield* openOpencodeSession({
|
|
24
|
+
constrainedPrompt: options.constrainedPrompt,
|
|
25
|
+
cwd: request.cwd,
|
|
26
|
+
effort: Option.fromUndefinedOr(request.effort),
|
|
27
|
+
model: request.model,
|
|
28
|
+
resume,
|
|
29
|
+
tools: options.sessionTools?.(request) ?? options.tools ?? [],
|
|
30
|
+
}).pipe(Effect.provideService(Provider, server));
|
|
31
|
+
const reference = yield* session.nativeRef;
|
|
32
|
+
if (Option.isNone(reference)) {
|
|
33
|
+
return yield* Effect.fail(opencodeFailure("session returned no reference"));
|
|
34
|
+
}
|
|
35
|
+
const receipt = {
|
|
36
|
+
backend: "opencode",
|
|
37
|
+
operationId: request.operationId,
|
|
38
|
+
reference: { value: reference.value, version: 1 },
|
|
39
|
+
session: { value: reference.value, version: 1 },
|
|
40
|
+
};
|
|
41
|
+
yield* session
|
|
42
|
+
.steer(request.input)
|
|
43
|
+
.pipe(Effect.mapError((error) => error._tag === "Rejected"
|
|
44
|
+
? error
|
|
45
|
+
: new UnknownAcceptance({ backend: "opencode", message: error.message, operationId: request.operationId })));
|
|
46
|
+
const output = yield* Queue.unbounded();
|
|
47
|
+
observation.set(request.operationId, { state: "accepted", type: "known" });
|
|
48
|
+
function observe(event) {
|
|
49
|
+
return Effect.sync(() => {
|
|
50
|
+
if (event.type === "execution") {
|
|
51
|
+
observation.set(request.operationId, { state: event.state, type: "known" });
|
|
52
|
+
}
|
|
53
|
+
}).pipe(Effect.andThen(Queue.offer(output, event)));
|
|
54
|
+
}
|
|
55
|
+
const ended = Effect.sync(() => {
|
|
56
|
+
const latest = observation.get(request.operationId);
|
|
57
|
+
if (runs.has(request.operationId) && latest?.type === "known" && !["completed", "failed", "interrupted"].includes(latest.state)) {
|
|
58
|
+
observation.set(request.operationId, { reason: "provider event stream ended without terminal evidence", type: "missing" });
|
|
59
|
+
}
|
|
60
|
+
}).pipe(Effect.andThen(Queue.end(output)));
|
|
61
|
+
yield* Effect.forkScoped(session.events.pipe(Stream.runForEach(observe), Effect.ensuring(ended)));
|
|
62
|
+
const events = Stream.fromQueue(output);
|
|
63
|
+
runs.set(request.operationId, { events, receipt, session });
|
|
64
|
+
receipts.set(request.operationId, receipt);
|
|
65
|
+
yield* Effect.addFinalizer(() => Effect.sync(() => {
|
|
66
|
+
runs.delete(request.operationId);
|
|
67
|
+
observation.delete(request.operationId);
|
|
68
|
+
}));
|
|
69
|
+
return receipt;
|
|
70
|
+
});
|
|
71
|
+
return {
|
|
72
|
+
events: (receipt) => Stream.unwrap(lookup(receipt).pipe(Effect.map((run) => run.events))),
|
|
73
|
+
inspect: (receipt) => Effect.sync(() => observation.get(receipt.operationId) ?? { reason: "no live execution evidence in this backend scope", type: "missing" }),
|
|
74
|
+
lookup,
|
|
75
|
+
open,
|
|
76
|
+
reconcile: (operationId) => Effect.sync(() => {
|
|
77
|
+
const receipt = receipts.get(operationId);
|
|
78
|
+
return receipt === undefined
|
|
79
|
+
? { operationId, reason: "OpenCode has no operation-id lookup; absence is not proof of refusal", type: "uncertain" }
|
|
80
|
+
: { receipt, type: "accepted" };
|
|
81
|
+
}),
|
|
82
|
+
resume: (reference, request) => reference.version === 1
|
|
83
|
+
? open(request, Option.some(reference.value))
|
|
84
|
+
: Effect.fail(new ProtocolFailure({ backend: "opencode", message: "unsupported session reference version" })),
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAElF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAMxC,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,OAAwB;IAClF,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,QAAQ,CAAC;IAC/B,MAAM,IAAI,GAAG,IAAI,GAAG,EAAmB,CAAC;IACxC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAmB,CAAC;IAC5C,MAAM,WAAW,GAAG,IAAI,GAAG,EAAuB,CAAC;IACnD,SAAS,MAAM,CAAC,OAAgB;QAC/B,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE;YAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAC1C,OAAO,OAAO,CAAC,OAAO,KAAK,UAAU,IAAI,OAAO,CAAC,SAAS,CAAC,OAAO,KAAK,CAAC,IAAI,GAAG,EAAE,OAAO,CAAC,SAAS,CAAC,KAAK,KAAK,OAAO,CAAC,SAAS,CAAC,KAAK;gBACnI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,G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ailure } from "@shivaedev/agent/failures.ts";
|
|
4
|
+
import type { Input, StartRequest } from "@shivaedev/agent/run.ts";
|
|
5
|
+
import type { DirectTool } from "#tools.ts";
|
|
6
|
+
export interface OpencodeOptions {
|
|
7
|
+
readonly command?: string | undefined;
|
|
8
|
+
readonly constrainedPrompt?: string | undefined;
|
|
9
|
+
readonly cwd: string;
|
|
10
|
+
readonly sessionTools?: (request: StartRequest) => readonly DirectTool[];
|
|
11
|
+
readonly skills?: string | undefined;
|
|
12
|
+
readonly tools?: readonly DirectTool[];
|
|
13
|
+
readonly url?: string | undefined;
|
|
14
|
+
}
|
|
15
|
+
export interface OpenSessionOptions {
|
|
16
|
+
readonly constrainedPrompt?: string | undefined;
|
|
17
|
+
readonly cwd: string;
|
|
18
|
+
readonly effort: Option.Option<string>;
|
|
19
|
+
readonly model?: string | undefined;
|
|
20
|
+
readonly resume: Option.Option<string>;
|
|
21
|
+
readonly tools: readonly DirectTool[];
|
|
22
|
+
}
|
|
23
|
+
export interface SessionHandle {
|
|
24
|
+
readonly events: Stream.Stream<RunEvent>;
|
|
25
|
+
readonly interrupt: Effect.Effect<void, BackendFailure>;
|
|
26
|
+
readonly nativeRef: Effect.Effect<Option.Option<string>>;
|
|
27
|
+
readonly queue: (input: Input) => Effect.Effect<void, BackendFailure>;
|
|
28
|
+
readonly steer: (input: Input) => Effect.Effect<void, BackendFailure>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,KAAK,E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,MAAM,CAAC,CAAC,CAAC;IACzD,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IACtE,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;CACtE"}
|
package/dist/options.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import type { RunEvent as AgentEvent } from "@shivaedev/agent/events.ts";
|
|
3
|
+
import type { BackendFailure } from "@shivaedev/agent/failures.ts";
|
|
4
|
+
import type { OpenSessionOptions } from "#options.ts";
|
|
5
|
+
import { Provider } from "#Provider.ts";
|
|
6
|
+
export interface PromptSettings {
|
|
7
|
+
readonly agent?: string;
|
|
8
|
+
readonly model?: {
|
|
9
|
+
readonly "modelID": string;
|
|
10
|
+
readonly "providerID": string;
|
|
11
|
+
};
|
|
12
|
+
readonly system?: string;
|
|
13
|
+
readonly variant?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function promptSettings(options: OpenSessionOptions): Effect.Effect<PromptSettings, BackendFailure>;
|
|
16
|
+
export declare const openSession: (options: OpenSessionOptions) => Effect.Effect<readonly ["POST /session", unknown] | readonly [`GET /session/${string}`, unknown], import("@shivaedev/agent/failures.ts").Rejected | import("@shivaedev/agent/failures.ts").UnknownAcceptance | import("@shivaedev/agent/failures.ts").ReadFailure, Provider>;
|
|
17
|
+
export declare function sessionIdOf(route: string, response: unknown): Effect.Effect<string, BackendFailure>;
|
|
18
|
+
export declare function sessionOpened(route: string, response: unknown, sessionId: string): AgentEvent;
|
|
19
|
+
//# sourceMappingURL=sessionOpen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionOpen.d.ts","sourceRoot":"","sources":["../src/sessionOpen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAkB,MAAM,QAAQ,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAKnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAqB,MAAM,cAAc,CAAC;AAG3D,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE;QAChB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;KAC9B,CAAC;IACF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC1B;AAOD,wBAAgB,cAAc,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,cAAc,CAAC,CAOzG;AAcD,eAAO,MAAM,WAAW,+SAatB,CAAC;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAKnG;AACD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU,CAM7F"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Effect, Option, Schema } from "effect";
|
|
2
|
+
import { rawOf } from "#adapters/mapping.ts";
|
|
3
|
+
import { SessionResponse } from "#adapters/protocol.ts";
|
|
4
|
+
import { CONSTRAINED_AGENT, wireName } from "#adapters/toolNames.ts";
|
|
5
|
+
import { opencodeFailure } from "#failure.ts";
|
|
6
|
+
import { Provider } from "#Provider.ts";
|
|
7
|
+
const decodeSession = Schema.decodeUnknownOption(SessionResponse);
|
|
8
|
+
function namedModel(model) {
|
|
9
|
+
const separator = model.indexOf("/");
|
|
10
|
+
return separator === -1
|
|
11
|
+
? Effect.fail(opencodeFailure(`model ${JSON.stringify(model)} names no provider; OpenCode reads a model as provider/model`))
|
|
12
|
+
: Effect.succeed({ model: { "modelID": model.slice(separator + 1), "providerID": model.slice(0, separator) } });
|
|
13
|
+
}
|
|
14
|
+
export function promptSettings(options) {
|
|
15
|
+
const constrained = options.constrainedPrompt === undefined ? {} : { agent: CONSTRAINED_AGENT, system: options.constrainedPrompt };
|
|
16
|
+
const variant = Option.match(options.effort, {
|
|
17
|
+
onNone: () => constrained,
|
|
18
|
+
onSome: (effort) => ({ ...constrained, variant: effort }),
|
|
19
|
+
});
|
|
20
|
+
return Effect.map(options.model === undefined ? Effect.succeed({}) : namedModel(options.model), (named) => ({ ...named, ...variant }));
|
|
21
|
+
}
|
|
22
|
+
function onlyGivenTools(tools) {
|
|
23
|
+
return [
|
|
24
|
+
{ action: "deny", pattern: "*", permission: "*" },
|
|
25
|
+
...tools.map((tool) => ({ action: "allow", pattern: "*", permission: wireName(tool.name) })),
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
function withoutOtherTools(server, tools) {
|
|
29
|
+
const given = new Set(tools.map((tool) => tool.name));
|
|
30
|
+
return server.tools.names.filter((name) => !given.has(name)).map((name) => ({ action: "deny", pattern: "*", permission: wireName(name) }));
|
|
31
|
+
}
|
|
32
|
+
function permissions(server, options) {
|
|
33
|
+
return options.constrainedPrompt === undefined ? withoutOtherTools(server, options.tools) : onlyGivenTools(options.tools);
|
|
34
|
+
}
|
|
35
|
+
export const openSession = Effect.fnUntraced(function* (options) {
|
|
36
|
+
const server = yield* Provider;
|
|
37
|
+
const query = { directory: options.cwd };
|
|
38
|
+
return yield* Option.match(options.resume, {
|
|
39
|
+
onNone: () => server
|
|
40
|
+
.post({ body: { permission: permissions(server, options) }, path: "/session", query })
|
|
41
|
+
.pipe(Effect.map((response) => ["POST /session", response])),
|
|
42
|
+
onSome: (sessionId) => server
|
|
43
|
+
.get({ body: undefined, path: `/session/${sessionId}`, query })
|
|
44
|
+
.pipe(Effect.map((response) => [`GET /session/${sessionId}`, response])),
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
export function sessionIdOf(route, response) {
|
|
48
|
+
return Option.match(decodeSession(response), {
|
|
49
|
+
onNone: () => Effect.fail(opencodeFailure(`${route} returned no session`)),
|
|
50
|
+
onSome: ({ id }) => Effect.succeed(id),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
export function sessionOpened(route, response, sessionId) {
|
|
54
|
+
return {
|
|
55
|
+
raw: rawOf(route, response),
|
|
56
|
+
reference: sessionId,
|
|
57
|
+
type: "session.opened",
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=sessionOpen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionOpen.js","sourceRoot":"","sources":["../src/sessionOpen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAqB,MAAM,cAAc,CAAC;AAE3D,MAAM,aAAa,GAAG,MAAM,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC;AAUlE,SAAS,UAAU,CAAC,KA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AS;QACpB,IAAI,EAAE,gBAAgB;KACtB,CAAC;AACH,CAAC"}
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Effect } from "effect";
|
|
2
|
+
export interface ToolOutcome {
|
|
3
|
+
readonly ok: boolean;
|
|
4
|
+
readonly text: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ToolDefinition {
|
|
7
|
+
readonly description: string;
|
|
8
|
+
readonly inputSchema: Readonly<Record<string, unknown>>;
|
|
9
|
+
readonly name: string;
|
|
10
|
+
}
|
|
11
|
+
export interface DirectTool extends ToolDefinition {
|
|
12
|
+
readonly call: (callId: string, args: unknown) => Effect.Effect<ToolOutcome>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AACD,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACxD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AACD,MAAM,WAAW,UAAW,SAAQ,cAAc;IACjD,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;CAC7E"}
|
package/dist/tools.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import type { BackendFailure } from "@shivaedev/agent/failures.ts";
|
|
3
|
+
import { Provider } from "#Provider.ts";
|
|
4
|
+
import type { PromptSettings } from "#sessionOpen.ts";
|
|
5
|
+
export interface TurnRequests {
|
|
6
|
+
readonly abort: Effect.Effect<unknown, BackendFailure>;
|
|
7
|
+
readonly prompt: (text: string) => Effect.Effect<unknown, BackendFailure>;
|
|
8
|
+
}
|
|
9
|
+
export declare const turnRequests: (sessionId: string, cwd: string, settings: PromptSettings) => Effect.Effect<{
|
|
10
|
+
abort: Effect.Effect<unknown, import("@shivaedev/agent/failures.ts").BackendUnavailable | import("@shivaedev/agent/failures.ts").ProtocolFailure | import("@shivaedev/agent/failures.ts").Rejected | import("@shivaedev/agent/failures.ts").UnknownAcceptance, never>;
|
|
11
|
+
prompt: (text: string) => Effect.Effect<unknown, import("@shivaedev/agent/failures.ts").BackendUnavailable | import("@shivaedev/agent/failures.ts").ProtocolFailure | import("@shivaedev/agent/failures.ts").Rejected | import("@shivaedev/agent/failures.ts").UnknownAcceptance, never>;
|
|
12
|
+
}, never, Provider>;
|
|
13
|
+
//# sourceMappingURL=turnRequests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turnRequests.d.ts","sourceRoot":"","sources":["../src/turnRequests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IACvD,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;CAC1E;AACD,eAAO,MAAM,YAAY;;mBASR,MAAM;mBAOrB,CAAC"}
|