@opencode-ai/schema 0.0.0-next-14659
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/dist/agent.d.ts +175 -0
- package/dist/agent.js +43 -0
- package/dist/catalog.d.ts +89 -0
- package/dist/catalog.js +4 -0
- package/dist/command.d.ts +44 -0
- package/dist/command.js +12 -0
- package/dist/connection.d.ts +28 -0
- package/dist/connection.js +15 -0
- package/dist/credential.d.ts +36 -0
- package/dist/credential.js +23 -0
- package/dist/durable-event-manifest.d.ts +10626 -0
- package/dist/durable-event-manifest.js +12 -0
- package/dist/event-manifest.d.ts +15309 -0
- package/dist/event-manifest.js +43 -0
- package/dist/event.d.ts +82 -0
- package/dist/event.js +73 -0
- package/dist/file-diff.d.ts +11 -0
- package/dist/file-diff.js +10 -0
- package/dist/filesystem-watcher.d.ts +102 -0
- package/dist/filesystem-watcher.js +11 -0
- package/dist/filesystem.d.ts +134 -0
- package/dist/filesystem.js +32 -0
- package/dist/ide-event.d.ts +96 -0
- package/dist/ide-event.js +10 -0
- package/dist/identifier.d.ts +3 -0
- package/dist/identifier.js +24 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +29 -0
- package/dist/installation-event.d.ts +189 -0
- package/dist/installation-event.js +16 -0
- package/dist/integration-id.d.ts +5 -0
- package/dist/integration-id.js +3 -0
- package/dist/integration.d.ts +572 -0
- package/dist/integration.js +93 -0
- package/dist/legacy-event.d.ts +1 -0
- package/dist/legacy-event.js +1 -0
- package/dist/llm.d.ts +28 -0
- package/dist/llm.js +19 -0
- package/dist/location.d.ts +36 -0
- package/dist/location.js +21 -0
- package/dist/lsp-event.d.ts +87 -0
- package/dist/lsp-event.js +4 -0
- package/dist/mcp-event.d.ts +286 -0
- package/dist/mcp-event.js +25 -0
- package/dist/mcp.d.ts +39 -0
- package/dist/mcp.js +38 -0
- package/dist/model.d.ts +205 -0
- package/dist/model.js +86 -0
- package/dist/models-dev.d.ts +89 -0
- package/dist/models-dev.js +7 -0
- package/dist/permission-saved.d.ts +18 -0
- package/dist/permission-saved.js +12 -0
- package/dist/permission-v1.d.ts +1 -0
- package/dist/permission-v1.js +1 -0
- package/dist/permission.d.ts +346 -0
- package/dist/permission.js +45 -0
- package/dist/plugin.d.ts +105 -0
- package/dist/plugin.js +12 -0
- package/dist/project-copy.d.ts +29 -0
- package/dist/project-copy.js +21 -0
- package/dist/project-directories.d.ts +105 -0
- package/dist/project-directories.js +8 -0
- package/dist/project-id.d.ts +5 -0
- package/dist/project-id.js +3 -0
- package/dist/project.d.ts +278 -0
- package/dist/project.js +44 -0
- package/dist/prompt-input.d.ts +106 -0
- package/dist/prompt-input.js +19 -0
- package/dist/prompt.d.ts +177 -0
- package/dist/prompt.js +43 -0
- package/dist/provider.d.ts +111 -0
- package/dist/provider.js +53 -0
- package/dist/pty-ticket.d.ts +8 -0
- package/dist/pty-ticket.js +7 -0
- package/dist/pty.d.ts +542 -0
- package/dist/pty.js +43 -0
- package/dist/question-v1.d.ts +1 -0
- package/dist/question-v1.js +1 -0
- package/dist/question.d.ts +516 -0
- package/dist/question.js +64 -0
- package/dist/reference.d.ts +140 -0
- package/dist/reference.js +31 -0
- package/dist/revert.d.ts +34 -0
- package/dist/revert.js +19 -0
- package/dist/schema.d.ts +10 -0
- package/dist/schema.js +14 -0
- package/dist/server-event.d.ts +172 -0
- package/dist/server-event.js +5 -0
- package/dist/session-compaction-event.d.ts +107 -0
- package/dist/session-compaction-event.js +10 -0
- package/dist/session-delivery.d.ts +4 -0
- package/dist/session-delivery.js +3 -0
- package/dist/session-event.d.ts +14225 -0
- package/dist/session-event.js +421 -0
- package/dist/session-id.d.ts +6 -0
- package/dist/session-id.js +10 -0
- package/dist/session-input.d.ts +145 -0
- package/dist/session-input.js +18 -0
- package/dist/session-message.d.ts +1318 -0
- package/dist/session-message.js +171 -0
- package/dist/session-status-event.d.ts +339 -0
- package/dist/session-status-event.js +43 -0
- package/dist/session-todo.d.ts +137 -0
- package/dist/session-todo.js +21 -0
- package/dist/session-v1.d.ts +1 -0
- package/dist/session-v1.js +1 -0
- package/dist/session.d.ts +140 -0
- package/dist/session.js +43 -0
- package/dist/shell.d.ts +441 -0
- package/dist/shell.js +58 -0
- package/dist/skill.d.ts +146 -0
- package/dist/skill.js +45 -0
- package/dist/tui-event.d.ts +387 -0
- package/dist/tui-event.js +53 -0
- package/dist/v1/legacy-event.d.ts +128 -0
- package/dist/v1/legacy-event.js +15 -0
- package/dist/v1/permission.d.ts +356 -0
- package/dist/v1/permission.js +41 -0
- package/dist/v1/question.d.ts +504 -0
- package/dist/v1/question.js +57 -0
- package/dist/v1/session.d.ts +7775 -0
- package/dist/v1/session.js +535 -0
- package/dist/vcs-event.d.ts +96 -0
- package/dist/vcs-event.js +11 -0
- package/dist/workspace-event.d.ts +307 -0
- package/dist/workspace-event.js +25 -0
- package/dist/workspace-id.d.ts +6 -0
- package/dist/workspace-id.js +16 -0
- package/dist/workspace.d.ts +9 -0
- package/dist/workspace.js +5 -0
- package/dist/worktree-event.d.ts +193 -0
- package/dist/worktree-event.js +18 -0
- package/package.json +41 -0
|
@@ -0,0 +1,535 @@
|
|
|
1
|
+
export * as SessionV1 from "./session.js";
|
|
2
|
+
import { Effect, Schema, Types } from "effect";
|
|
3
|
+
import { define, inventory } from "../event.js";
|
|
4
|
+
import { FileDiff } from "../file-diff.js";
|
|
5
|
+
import { Project } from "../project.js";
|
|
6
|
+
import { Provider } from "../provider.js";
|
|
7
|
+
import { Model } from "../model.js";
|
|
8
|
+
import { NonNegativeInt, optional, statics } from "../schema.js";
|
|
9
|
+
import { ascending } from "../identifier.js";
|
|
10
|
+
import { SessionID } from "../session-id.js";
|
|
11
|
+
import { WorkspaceID } from "../workspace-id.js";
|
|
12
|
+
import { PermissionV1 } from "./permission.js";
|
|
13
|
+
const Timestamp = Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0));
|
|
14
|
+
export const MessageID = Schema.String.check(Schema.isStartsWith("msg")).pipe(Schema.brand("MessageID"), statics((schema) => ({ ascending: (id) => schema.make(id ?? "msg_" + ascending()) })));
|
|
15
|
+
export const PartID = Schema.String.check(Schema.isStartsWith("prt")).pipe(Schema.brand("PartID"), statics((schema) => ({ ascending: (id) => schema.make(id ?? "prt_" + ascending()) })));
|
|
16
|
+
const namedError = (name, fields) => {
|
|
17
|
+
const schema = Schema.Struct({ name: Schema.Literal(name), data: Schema.Struct(fields) }).annotate({
|
|
18
|
+
identifier: name,
|
|
19
|
+
});
|
|
20
|
+
return { Schema: schema, EffectSchema: schema };
|
|
21
|
+
};
|
|
22
|
+
export const OutputLengthError = namedError("MessageOutputLengthError", {});
|
|
23
|
+
export const AuthError = namedError("ProviderAuthError", {
|
|
24
|
+
providerID: Schema.String,
|
|
25
|
+
message: Schema.String,
|
|
26
|
+
});
|
|
27
|
+
export const AbortedError = namedError("MessageAbortedError", { message: Schema.String });
|
|
28
|
+
export const StructuredOutputError = namedError("StructuredOutputError", {
|
|
29
|
+
message: Schema.String,
|
|
30
|
+
retries: NonNegativeInt,
|
|
31
|
+
});
|
|
32
|
+
export const APIError = namedError("APIError", {
|
|
33
|
+
message: Schema.String,
|
|
34
|
+
statusCode: Schema.optional(NonNegativeInt),
|
|
35
|
+
isRetryable: Schema.Boolean,
|
|
36
|
+
responseHeaders: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
|
37
|
+
responseBody: Schema.optional(Schema.String),
|
|
38
|
+
metadata: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
|
39
|
+
});
|
|
40
|
+
export const ContextOverflowError = namedError("ContextOverflowError", {
|
|
41
|
+
message: Schema.String,
|
|
42
|
+
responseBody: Schema.optional(Schema.String),
|
|
43
|
+
});
|
|
44
|
+
export const ContentFilterError = namedError("ContentFilterError", {
|
|
45
|
+
message: Schema.String,
|
|
46
|
+
});
|
|
47
|
+
export class OutputFormatText extends Schema.Class("OutputFormatText")({
|
|
48
|
+
type: Schema.Literal("text"),
|
|
49
|
+
}) {
|
|
50
|
+
}
|
|
51
|
+
export class OutputFormatJsonSchema extends Schema.Class("OutputFormatJsonSchema")({
|
|
52
|
+
type: Schema.Literal("json_schema"),
|
|
53
|
+
schema: Schema.Record(Schema.String, Schema.Any).annotate({ identifier: "JSONSchema" }),
|
|
54
|
+
retryCount: NonNegativeInt.pipe(Schema.optional, Schema.withDecodingDefault(Effect.succeed(2))),
|
|
55
|
+
}) {
|
|
56
|
+
}
|
|
57
|
+
export const Format = Schema.Union([OutputFormatText, OutputFormatJsonSchema]).annotate({
|
|
58
|
+
discriminator: "type",
|
|
59
|
+
identifier: "OutputFormat",
|
|
60
|
+
});
|
|
61
|
+
const partBase = {
|
|
62
|
+
id: PartID,
|
|
63
|
+
sessionID: SessionID,
|
|
64
|
+
messageID: MessageID,
|
|
65
|
+
};
|
|
66
|
+
export const SnapshotPart = Schema.Struct({
|
|
67
|
+
...partBase,
|
|
68
|
+
type: Schema.Literal("snapshot"),
|
|
69
|
+
snapshot: Schema.String,
|
|
70
|
+
}).annotate({ identifier: "SnapshotPart" });
|
|
71
|
+
export const PatchPart = Schema.Struct({
|
|
72
|
+
...partBase,
|
|
73
|
+
type: Schema.Literal("patch"),
|
|
74
|
+
hash: Schema.String,
|
|
75
|
+
files: Schema.Array(Schema.String),
|
|
76
|
+
}).annotate({ identifier: "PatchPart" });
|
|
77
|
+
export const TextPart = Schema.Struct({
|
|
78
|
+
...partBase,
|
|
79
|
+
type: Schema.Literal("text"),
|
|
80
|
+
text: Schema.String,
|
|
81
|
+
synthetic: Schema.optional(Schema.Boolean),
|
|
82
|
+
ignored: Schema.optional(Schema.Boolean),
|
|
83
|
+
time: Schema.optional(Schema.Struct({
|
|
84
|
+
start: NonNegativeInt,
|
|
85
|
+
end: Schema.optional(NonNegativeInt),
|
|
86
|
+
})),
|
|
87
|
+
metadata: Schema.optional(Schema.Record(Schema.String, Schema.Any)),
|
|
88
|
+
}).annotate({ identifier: "TextPart" });
|
|
89
|
+
export const ReasoningPart = Schema.Struct({
|
|
90
|
+
...partBase,
|
|
91
|
+
type: Schema.Literal("reasoning"),
|
|
92
|
+
text: Schema.String,
|
|
93
|
+
metadata: Schema.optional(Schema.Record(Schema.String, Schema.Any)),
|
|
94
|
+
time: Schema.Struct({
|
|
95
|
+
start: NonNegativeInt,
|
|
96
|
+
end: Schema.optional(NonNegativeInt),
|
|
97
|
+
}),
|
|
98
|
+
}).annotate({ identifier: "ReasoningPart" });
|
|
99
|
+
const filePartSourceBase = {
|
|
100
|
+
text: Schema.Struct({
|
|
101
|
+
value: Schema.String,
|
|
102
|
+
start: Schema.Finite,
|
|
103
|
+
end: Schema.Finite,
|
|
104
|
+
}).annotate({ identifier: "FilePartSourceText" }),
|
|
105
|
+
};
|
|
106
|
+
export const Range = Schema.Struct({
|
|
107
|
+
start: Schema.Struct({ line: NonNegativeInt, character: NonNegativeInt }),
|
|
108
|
+
end: Schema.Struct({ line: NonNegativeInt, character: NonNegativeInt }),
|
|
109
|
+
}).annotate({ identifier: "Range" });
|
|
110
|
+
export const FileSource = Schema.Struct({
|
|
111
|
+
...filePartSourceBase,
|
|
112
|
+
type: Schema.Literal("file"),
|
|
113
|
+
path: Schema.String,
|
|
114
|
+
}).annotate({ identifier: "FileSource" });
|
|
115
|
+
export const SymbolSource = Schema.Struct({
|
|
116
|
+
...filePartSourceBase,
|
|
117
|
+
type: Schema.Literal("symbol"),
|
|
118
|
+
path: Schema.String,
|
|
119
|
+
range: Range,
|
|
120
|
+
name: Schema.String,
|
|
121
|
+
kind: NonNegativeInt,
|
|
122
|
+
}).annotate({ identifier: "SymbolSource" });
|
|
123
|
+
export const ResourceSource = Schema.Struct({
|
|
124
|
+
...filePartSourceBase,
|
|
125
|
+
type: Schema.Literal("resource"),
|
|
126
|
+
clientName: Schema.String,
|
|
127
|
+
uri: Schema.String,
|
|
128
|
+
}).annotate({ identifier: "ResourceSource" });
|
|
129
|
+
export const FilePartSource = Schema.Union([FileSource, SymbolSource, ResourceSource]).annotate({
|
|
130
|
+
discriminator: "type",
|
|
131
|
+
identifier: "FilePartSource",
|
|
132
|
+
});
|
|
133
|
+
export const FilePart = Schema.Struct({
|
|
134
|
+
...partBase,
|
|
135
|
+
type: Schema.Literal("file"),
|
|
136
|
+
mime: Schema.String,
|
|
137
|
+
filename: Schema.optional(Schema.String),
|
|
138
|
+
url: Schema.String,
|
|
139
|
+
source: Schema.optional(FilePartSource),
|
|
140
|
+
}).annotate({ identifier: "FilePart" });
|
|
141
|
+
export const AgentPart = Schema.Struct({
|
|
142
|
+
...partBase,
|
|
143
|
+
type: Schema.Literal("agent"),
|
|
144
|
+
name: Schema.String,
|
|
145
|
+
source: Schema.optional(Schema.Struct({
|
|
146
|
+
value: Schema.String,
|
|
147
|
+
start: NonNegativeInt,
|
|
148
|
+
end: NonNegativeInt,
|
|
149
|
+
})),
|
|
150
|
+
}).annotate({ identifier: "AgentPart" });
|
|
151
|
+
export const CompactionPart = Schema.Struct({
|
|
152
|
+
...partBase,
|
|
153
|
+
type: Schema.Literal("compaction"),
|
|
154
|
+
auto: Schema.Boolean,
|
|
155
|
+
overflow: Schema.optional(Schema.Boolean),
|
|
156
|
+
tail_start_id: Schema.optional(MessageID),
|
|
157
|
+
}).annotate({ identifier: "CompactionPart" });
|
|
158
|
+
export const SubtaskPart = Schema.Struct({
|
|
159
|
+
...partBase,
|
|
160
|
+
type: Schema.Literal("subtask"),
|
|
161
|
+
prompt: Schema.String,
|
|
162
|
+
description: Schema.String,
|
|
163
|
+
agent: Schema.String,
|
|
164
|
+
model: Schema.optional(Schema.Struct({
|
|
165
|
+
providerID: Provider.ID,
|
|
166
|
+
modelID: Model.ID,
|
|
167
|
+
})),
|
|
168
|
+
command: Schema.optional(Schema.String),
|
|
169
|
+
}).annotate({ identifier: "SubtaskPart" });
|
|
170
|
+
export const RetryPart = Schema.Struct({
|
|
171
|
+
...partBase,
|
|
172
|
+
type: Schema.Literal("retry"),
|
|
173
|
+
attempt: NonNegativeInt,
|
|
174
|
+
error: APIError.EffectSchema,
|
|
175
|
+
time: Schema.Struct({
|
|
176
|
+
created: NonNegativeInt,
|
|
177
|
+
}),
|
|
178
|
+
}).annotate({ identifier: "RetryPart" });
|
|
179
|
+
export const StepStartPart = Schema.Struct({
|
|
180
|
+
...partBase,
|
|
181
|
+
type: Schema.Literal("step-start"),
|
|
182
|
+
snapshot: Schema.optional(Schema.String),
|
|
183
|
+
}).annotate({ identifier: "StepStartPart" });
|
|
184
|
+
export const StepFinishPart = Schema.Struct({
|
|
185
|
+
...partBase,
|
|
186
|
+
type: Schema.Literal("step-finish"),
|
|
187
|
+
reason: Schema.String,
|
|
188
|
+
snapshot: Schema.optional(Schema.String),
|
|
189
|
+
cost: Schema.Finite,
|
|
190
|
+
tokens: Schema.Struct({
|
|
191
|
+
total: Schema.optional(Schema.Finite),
|
|
192
|
+
input: Schema.Finite,
|
|
193
|
+
output: Schema.Finite,
|
|
194
|
+
reasoning: Schema.Finite,
|
|
195
|
+
cache: Schema.Struct({
|
|
196
|
+
read: Schema.Finite,
|
|
197
|
+
write: Schema.Finite,
|
|
198
|
+
}),
|
|
199
|
+
}),
|
|
200
|
+
}).annotate({ identifier: "StepFinishPart" });
|
|
201
|
+
export const ToolStatePending = Schema.Struct({
|
|
202
|
+
status: Schema.Literal("pending"),
|
|
203
|
+
input: Schema.Record(Schema.String, Schema.Any),
|
|
204
|
+
raw: Schema.String,
|
|
205
|
+
}).annotate({ identifier: "ToolStatePending" });
|
|
206
|
+
export const ToolStateRunning = Schema.Struct({
|
|
207
|
+
status: Schema.Literal("running"),
|
|
208
|
+
input: Schema.Record(Schema.String, Schema.Any),
|
|
209
|
+
title: Schema.optional(Schema.String),
|
|
210
|
+
metadata: Schema.optional(Schema.Record(Schema.String, Schema.Any)),
|
|
211
|
+
time: Schema.Struct({
|
|
212
|
+
start: NonNegativeInt,
|
|
213
|
+
}),
|
|
214
|
+
}).annotate({ identifier: "ToolStateRunning" });
|
|
215
|
+
export const ToolStateCompleted = Schema.Struct({
|
|
216
|
+
status: Schema.Literal("completed"),
|
|
217
|
+
input: Schema.Record(Schema.String, Schema.Any),
|
|
218
|
+
output: Schema.String,
|
|
219
|
+
title: Schema.String,
|
|
220
|
+
metadata: Schema.Record(Schema.String, Schema.Any),
|
|
221
|
+
time: Schema.Struct({
|
|
222
|
+
start: NonNegativeInt,
|
|
223
|
+
end: NonNegativeInt,
|
|
224
|
+
compacted: Schema.optional(NonNegativeInt),
|
|
225
|
+
}),
|
|
226
|
+
attachments: Schema.optional(Schema.Array(FilePart)),
|
|
227
|
+
}).annotate({ identifier: "ToolStateCompleted" });
|
|
228
|
+
export const ToolStateError = Schema.Struct({
|
|
229
|
+
status: Schema.Literal("error"),
|
|
230
|
+
input: Schema.Record(Schema.String, Schema.Any),
|
|
231
|
+
error: Schema.String,
|
|
232
|
+
metadata: Schema.optional(Schema.Record(Schema.String, Schema.Any)),
|
|
233
|
+
time: Schema.Struct({
|
|
234
|
+
start: NonNegativeInt,
|
|
235
|
+
end: NonNegativeInt,
|
|
236
|
+
}),
|
|
237
|
+
}).annotate({ identifier: "ToolStateError" });
|
|
238
|
+
export const ToolState = Schema.Union([
|
|
239
|
+
ToolStatePending,
|
|
240
|
+
ToolStateRunning,
|
|
241
|
+
ToolStateCompleted,
|
|
242
|
+
ToolStateError,
|
|
243
|
+
]).annotate({
|
|
244
|
+
discriminator: "status",
|
|
245
|
+
identifier: "ToolState",
|
|
246
|
+
});
|
|
247
|
+
export const ToolPart = Schema.Struct({
|
|
248
|
+
...partBase,
|
|
249
|
+
type: Schema.Literal("tool"),
|
|
250
|
+
callID: Schema.String,
|
|
251
|
+
tool: Schema.String,
|
|
252
|
+
state: ToolState,
|
|
253
|
+
metadata: Schema.optional(Schema.Record(Schema.String, Schema.Any)),
|
|
254
|
+
}).annotate({ identifier: "ToolPart" });
|
|
255
|
+
const messageBase = {
|
|
256
|
+
id: MessageID,
|
|
257
|
+
sessionID: partBase.sessionID,
|
|
258
|
+
};
|
|
259
|
+
export const User = Schema.Struct({
|
|
260
|
+
...messageBase,
|
|
261
|
+
role: Schema.Literal("user"),
|
|
262
|
+
time: Schema.Struct({
|
|
263
|
+
created: Timestamp,
|
|
264
|
+
}),
|
|
265
|
+
format: Schema.optional(Format),
|
|
266
|
+
summary: Schema.optional(Schema.Struct({
|
|
267
|
+
title: Schema.optional(Schema.String),
|
|
268
|
+
body: Schema.optional(Schema.String),
|
|
269
|
+
diffs: Schema.Array(FileDiff.Info),
|
|
270
|
+
})),
|
|
271
|
+
agent: Schema.String,
|
|
272
|
+
model: Schema.Struct({
|
|
273
|
+
providerID: Provider.ID,
|
|
274
|
+
modelID: Model.ID,
|
|
275
|
+
variant: Schema.optional(Schema.String),
|
|
276
|
+
}),
|
|
277
|
+
system: Schema.optional(Schema.String),
|
|
278
|
+
tools: Schema.optional(Schema.Record(Schema.String, Schema.Boolean)),
|
|
279
|
+
}).annotate({ identifier: "UserMessage" });
|
|
280
|
+
export const Part = Schema.Union([
|
|
281
|
+
TextPart,
|
|
282
|
+
SubtaskPart,
|
|
283
|
+
ReasoningPart,
|
|
284
|
+
FilePart,
|
|
285
|
+
ToolPart,
|
|
286
|
+
StepStartPart,
|
|
287
|
+
StepFinishPart,
|
|
288
|
+
SnapshotPart,
|
|
289
|
+
PatchPart,
|
|
290
|
+
AgentPart,
|
|
291
|
+
RetryPart,
|
|
292
|
+
CompactionPart,
|
|
293
|
+
]).annotate({ discriminator: "type", identifier: "Part" });
|
|
294
|
+
const AssistantErrorSchema = Schema.Union([
|
|
295
|
+
AuthError.EffectSchema,
|
|
296
|
+
namedError("UnknownError", { message: Schema.String, ref: Schema.optional(Schema.String) }).EffectSchema,
|
|
297
|
+
OutputLengthError.EffectSchema,
|
|
298
|
+
AbortedError.EffectSchema,
|
|
299
|
+
StructuredOutputError.EffectSchema,
|
|
300
|
+
ContextOverflowError.EffectSchema,
|
|
301
|
+
ContentFilterError.EffectSchema,
|
|
302
|
+
APIError.EffectSchema,
|
|
303
|
+
]).annotate({ discriminator: "name" });
|
|
304
|
+
export const TextPartInput = Schema.Struct({
|
|
305
|
+
id: Schema.optional(PartID),
|
|
306
|
+
type: Schema.Literal("text"),
|
|
307
|
+
text: Schema.String,
|
|
308
|
+
synthetic: Schema.optional(Schema.Boolean),
|
|
309
|
+
ignored: Schema.optional(Schema.Boolean),
|
|
310
|
+
time: Schema.optional(Schema.Struct({
|
|
311
|
+
start: NonNegativeInt,
|
|
312
|
+
end: Schema.optional(NonNegativeInt),
|
|
313
|
+
})),
|
|
314
|
+
metadata: Schema.optional(Schema.Record(Schema.String, Schema.Any)),
|
|
315
|
+
}).annotate({ identifier: "TextPartInput" });
|
|
316
|
+
export const FilePartInput = Schema.Struct({
|
|
317
|
+
id: Schema.optional(PartID),
|
|
318
|
+
type: Schema.Literal("file"),
|
|
319
|
+
mime: Schema.String,
|
|
320
|
+
filename: Schema.optional(Schema.String),
|
|
321
|
+
url: Schema.String,
|
|
322
|
+
source: Schema.optional(FilePartSource),
|
|
323
|
+
}).annotate({ identifier: "FilePartInput" });
|
|
324
|
+
export const AgentPartInput = Schema.Struct({
|
|
325
|
+
id: Schema.optional(PartID),
|
|
326
|
+
type: Schema.Literal("agent"),
|
|
327
|
+
name: Schema.String,
|
|
328
|
+
source: Schema.optional(Schema.Struct({
|
|
329
|
+
value: Schema.String,
|
|
330
|
+
start: NonNegativeInt,
|
|
331
|
+
end: NonNegativeInt,
|
|
332
|
+
})),
|
|
333
|
+
}).annotate({ identifier: "AgentPartInput" });
|
|
334
|
+
export const SubtaskPartInput = Schema.Struct({
|
|
335
|
+
id: Schema.optional(PartID),
|
|
336
|
+
type: Schema.Literal("subtask"),
|
|
337
|
+
prompt: Schema.String,
|
|
338
|
+
description: Schema.String,
|
|
339
|
+
agent: Schema.String,
|
|
340
|
+
model: Schema.optional(Schema.Struct({
|
|
341
|
+
providerID: Provider.ID,
|
|
342
|
+
modelID: Model.ID,
|
|
343
|
+
})),
|
|
344
|
+
command: Schema.optional(Schema.String),
|
|
345
|
+
}).annotate({ identifier: "SubtaskPartInput" });
|
|
346
|
+
export const Assistant = Schema.Struct({
|
|
347
|
+
...messageBase,
|
|
348
|
+
role: Schema.Literal("assistant"),
|
|
349
|
+
time: Schema.Struct({
|
|
350
|
+
created: NonNegativeInt,
|
|
351
|
+
completed: Schema.optional(NonNegativeInt),
|
|
352
|
+
}),
|
|
353
|
+
error: Schema.optional(AssistantErrorSchema),
|
|
354
|
+
parentID: MessageID,
|
|
355
|
+
modelID: Model.ID,
|
|
356
|
+
providerID: Provider.ID,
|
|
357
|
+
mode: Schema.String,
|
|
358
|
+
agent: Schema.String,
|
|
359
|
+
path: Schema.Struct({
|
|
360
|
+
cwd: Schema.String,
|
|
361
|
+
root: Schema.String,
|
|
362
|
+
}),
|
|
363
|
+
summary: Schema.optional(Schema.Boolean),
|
|
364
|
+
cost: Schema.Finite,
|
|
365
|
+
tokens: Schema.Struct({
|
|
366
|
+
total: Schema.optional(Schema.Finite),
|
|
367
|
+
input: Schema.Finite,
|
|
368
|
+
output: Schema.Finite,
|
|
369
|
+
reasoning: Schema.Finite,
|
|
370
|
+
cache: Schema.Struct({
|
|
371
|
+
read: Schema.Finite,
|
|
372
|
+
write: Schema.Finite,
|
|
373
|
+
}),
|
|
374
|
+
}),
|
|
375
|
+
structured: Schema.optional(Schema.Any),
|
|
376
|
+
variant: Schema.optional(Schema.String),
|
|
377
|
+
finish: Schema.optional(Schema.String),
|
|
378
|
+
}).annotate({ identifier: "AssistantMessage" });
|
|
379
|
+
export const Info = Schema.Union([User, Assistant]).annotate({ discriminator: "role", identifier: "Message" });
|
|
380
|
+
export const WithParts = Schema.Struct({
|
|
381
|
+
info: Info,
|
|
382
|
+
parts: Schema.Array(Part),
|
|
383
|
+
});
|
|
384
|
+
const options = {
|
|
385
|
+
durable: {
|
|
386
|
+
aggregate: "sessionID",
|
|
387
|
+
version: 1,
|
|
388
|
+
},
|
|
389
|
+
};
|
|
390
|
+
const SessionSummary = Schema.Struct({
|
|
391
|
+
additions: Schema.Finite,
|
|
392
|
+
deletions: Schema.Finite,
|
|
393
|
+
files: Schema.Finite,
|
|
394
|
+
diffs: optional(Schema.Array(FileDiff.Info)),
|
|
395
|
+
});
|
|
396
|
+
const SessionTokens = Schema.Struct({
|
|
397
|
+
input: Schema.Finite,
|
|
398
|
+
output: Schema.Finite,
|
|
399
|
+
reasoning: Schema.Finite,
|
|
400
|
+
cache: Schema.Struct({
|
|
401
|
+
read: Schema.Finite,
|
|
402
|
+
write: Schema.Finite,
|
|
403
|
+
}),
|
|
404
|
+
});
|
|
405
|
+
const SessionShare = Schema.Struct({
|
|
406
|
+
url: Schema.String,
|
|
407
|
+
});
|
|
408
|
+
const SessionRevert = Schema.Struct({
|
|
409
|
+
messageID: MessageID,
|
|
410
|
+
partID: optional(PartID),
|
|
411
|
+
snapshot: optional(Schema.String),
|
|
412
|
+
diff: optional(Schema.String),
|
|
413
|
+
});
|
|
414
|
+
const SessionModel = Schema.Struct({
|
|
415
|
+
id: Model.ID,
|
|
416
|
+
providerID: Provider.ID,
|
|
417
|
+
variant: optional(Schema.String),
|
|
418
|
+
});
|
|
419
|
+
export const SessionInfo = Schema.Struct({
|
|
420
|
+
id: SessionID,
|
|
421
|
+
slug: Schema.String,
|
|
422
|
+
projectID: Project.ID,
|
|
423
|
+
workspaceID: optional(WorkspaceID),
|
|
424
|
+
directory: Schema.String,
|
|
425
|
+
path: optional(Schema.String),
|
|
426
|
+
parentID: optional(SessionID),
|
|
427
|
+
summary: optional(SessionSummary),
|
|
428
|
+
cost: optional(Schema.Finite),
|
|
429
|
+
tokens: optional(SessionTokens),
|
|
430
|
+
share: optional(SessionShare),
|
|
431
|
+
title: Schema.String,
|
|
432
|
+
agent: optional(Schema.String),
|
|
433
|
+
model: optional(SessionModel),
|
|
434
|
+
version: Schema.String,
|
|
435
|
+
metadata: optional(Schema.Record(Schema.String, Schema.Any)),
|
|
436
|
+
time: Schema.Struct({
|
|
437
|
+
created: NonNegativeInt,
|
|
438
|
+
updated: NonNegativeInt,
|
|
439
|
+
compacting: optional(NonNegativeInt),
|
|
440
|
+
archived: optional(Schema.Finite),
|
|
441
|
+
}),
|
|
442
|
+
permission: optional(PermissionV1.Ruleset),
|
|
443
|
+
revert: optional(SessionRevert),
|
|
444
|
+
}).annotate({ identifier: "Session" });
|
|
445
|
+
const events = {
|
|
446
|
+
Created: define({
|
|
447
|
+
type: "session.created",
|
|
448
|
+
...options,
|
|
449
|
+
schema: {
|
|
450
|
+
sessionID: SessionID,
|
|
451
|
+
info: SessionInfo,
|
|
452
|
+
},
|
|
453
|
+
}),
|
|
454
|
+
Updated: define({
|
|
455
|
+
type: "session.updated",
|
|
456
|
+
...options,
|
|
457
|
+
schema: {
|
|
458
|
+
sessionID: SessionID,
|
|
459
|
+
info: SessionInfo,
|
|
460
|
+
},
|
|
461
|
+
}),
|
|
462
|
+
Deleted: define({
|
|
463
|
+
type: "session.deleted",
|
|
464
|
+
...options,
|
|
465
|
+
schema: {
|
|
466
|
+
sessionID: SessionID,
|
|
467
|
+
info: SessionInfo,
|
|
468
|
+
},
|
|
469
|
+
}),
|
|
470
|
+
MessageUpdated: define({
|
|
471
|
+
type: "message.updated",
|
|
472
|
+
...options,
|
|
473
|
+
schema: {
|
|
474
|
+
sessionID: SessionID,
|
|
475
|
+
info: Info,
|
|
476
|
+
},
|
|
477
|
+
}),
|
|
478
|
+
MessageRemoved: define({
|
|
479
|
+
type: "message.removed",
|
|
480
|
+
...options,
|
|
481
|
+
schema: {
|
|
482
|
+
sessionID: SessionID,
|
|
483
|
+
messageID: MessageID,
|
|
484
|
+
},
|
|
485
|
+
}),
|
|
486
|
+
PartUpdated: define({
|
|
487
|
+
type: "message.part.updated",
|
|
488
|
+
...options,
|
|
489
|
+
schema: {
|
|
490
|
+
sessionID: SessionID,
|
|
491
|
+
part: Part,
|
|
492
|
+
time: Schema.Finite,
|
|
493
|
+
},
|
|
494
|
+
}),
|
|
495
|
+
PartRemoved: define({
|
|
496
|
+
type: "message.part.removed",
|
|
497
|
+
...options,
|
|
498
|
+
schema: {
|
|
499
|
+
sessionID: SessionID,
|
|
500
|
+
messageID: MessageID,
|
|
501
|
+
partID: PartID,
|
|
502
|
+
},
|
|
503
|
+
}),
|
|
504
|
+
};
|
|
505
|
+
export const PartDelta = define({
|
|
506
|
+
type: "message.part.delta",
|
|
507
|
+
schema: {
|
|
508
|
+
sessionID: SessionID,
|
|
509
|
+
messageID: MessageID,
|
|
510
|
+
partID: PartID,
|
|
511
|
+
field: Schema.String,
|
|
512
|
+
delta: Schema.String,
|
|
513
|
+
},
|
|
514
|
+
});
|
|
515
|
+
export const Diff = define({
|
|
516
|
+
type: "session.diff",
|
|
517
|
+
schema: {
|
|
518
|
+
sessionID: SessionID,
|
|
519
|
+
diff: Schema.Array(FileDiff.Info),
|
|
520
|
+
},
|
|
521
|
+
});
|
|
522
|
+
export const Error = define({
|
|
523
|
+
type: "session.error",
|
|
524
|
+
schema: {
|
|
525
|
+
sessionID: Schema.optional(SessionID),
|
|
526
|
+
error: Assistant.fields.error,
|
|
527
|
+
},
|
|
528
|
+
});
|
|
529
|
+
export const Event = {
|
|
530
|
+
...events,
|
|
531
|
+
PartDelta,
|
|
532
|
+
Diff,
|
|
533
|
+
Error,
|
|
534
|
+
Definitions: inventory(events.Created, events.Updated, events.Deleted, events.MessageUpdated, events.MessageRemoved, events.PartUpdated, events.PartRemoved, PartDelta, Diff, Error),
|
|
535
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export * as VcsEvent from "./vcs-event.js";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
export declare const BranchUpdated: Schema.Struct<{
|
|
4
|
+
readonly id: Schema.brand<Schema.String, "Event.ID"> & {
|
|
5
|
+
create: () => string & import("effect/Brand").Brand<"Event.ID">;
|
|
6
|
+
};
|
|
7
|
+
readonly metadata: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
|
|
8
|
+
readonly type: Schema.Literal<"vcs.branch.updated">;
|
|
9
|
+
readonly durable: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
|
|
10
|
+
readonly aggregateID: Schema.String;
|
|
11
|
+
readonly seq: Schema.Int;
|
|
12
|
+
readonly version: Schema.Int;
|
|
13
|
+
}>>>, Schema.optionalKey<Schema.Struct<{
|
|
14
|
+
readonly aggregateID: Schema.String;
|
|
15
|
+
readonly seq: Schema.Int;
|
|
16
|
+
readonly version: Schema.Int;
|
|
17
|
+
}>>, never, never>;
|
|
18
|
+
readonly location: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
|
|
19
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
20
|
+
readonly workspaceID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "WorkspaceV2.ID"> & {
|
|
21
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"WorkspaceV2.ID">;
|
|
22
|
+
create: () => string & import("effect/Brand").Brand<"WorkspaceV2.ID">;
|
|
23
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.String, "WorkspaceV2.ID"> & {
|
|
24
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"WorkspaceV2.ID">;
|
|
25
|
+
create: () => string & import("effect/Brand").Brand<"WorkspaceV2.ID">;
|
|
26
|
+
}>, never, never>;
|
|
27
|
+
}>>>, Schema.optionalKey<Schema.Struct<{
|
|
28
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
29
|
+
readonly workspaceID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "WorkspaceV2.ID"> & {
|
|
30
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"WorkspaceV2.ID">;
|
|
31
|
+
create: () => string & import("effect/Brand").Brand<"WorkspaceV2.ID">;
|
|
32
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.String, "WorkspaceV2.ID"> & {
|
|
33
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"WorkspaceV2.ID">;
|
|
34
|
+
create: () => string & import("effect/Brand").Brand<"WorkspaceV2.ID">;
|
|
35
|
+
}>, never, never>;
|
|
36
|
+
}>>, never, never>;
|
|
37
|
+
readonly data: Schema.Struct<{
|
|
38
|
+
readonly branch: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
39
|
+
}>;
|
|
40
|
+
}> & {
|
|
41
|
+
data: Schema.Struct<{
|
|
42
|
+
readonly branch: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
43
|
+
}>;
|
|
44
|
+
durable?: {
|
|
45
|
+
readonly version: number;
|
|
46
|
+
readonly aggregate: string;
|
|
47
|
+
} | undefined;
|
|
48
|
+
type: "vcs.branch.updated";
|
|
49
|
+
};
|
|
50
|
+
export declare const Definitions: readonly [Schema.Struct<{
|
|
51
|
+
readonly id: Schema.brand<Schema.String, "Event.ID"> & {
|
|
52
|
+
create: () => string & import("effect/Brand").Brand<"Event.ID">;
|
|
53
|
+
};
|
|
54
|
+
readonly metadata: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
|
|
55
|
+
readonly type: Schema.Literal<"vcs.branch.updated">;
|
|
56
|
+
readonly durable: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
|
|
57
|
+
readonly aggregateID: Schema.String;
|
|
58
|
+
readonly seq: Schema.Int;
|
|
59
|
+
readonly version: Schema.Int;
|
|
60
|
+
}>>>, Schema.optionalKey<Schema.Struct<{
|
|
61
|
+
readonly aggregateID: Schema.String;
|
|
62
|
+
readonly seq: Schema.Int;
|
|
63
|
+
readonly version: Schema.Int;
|
|
64
|
+
}>>, never, never>;
|
|
65
|
+
readonly location: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
|
|
66
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
67
|
+
readonly workspaceID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "WorkspaceV2.ID"> & {
|
|
68
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"WorkspaceV2.ID">;
|
|
69
|
+
create: () => string & import("effect/Brand").Brand<"WorkspaceV2.ID">;
|
|
70
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.String, "WorkspaceV2.ID"> & {
|
|
71
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"WorkspaceV2.ID">;
|
|
72
|
+
create: () => string & import("effect/Brand").Brand<"WorkspaceV2.ID">;
|
|
73
|
+
}>, never, never>;
|
|
74
|
+
}>>>, Schema.optionalKey<Schema.Struct<{
|
|
75
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
76
|
+
readonly workspaceID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "WorkspaceV2.ID"> & {
|
|
77
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"WorkspaceV2.ID">;
|
|
78
|
+
create: () => string & import("effect/Brand").Brand<"WorkspaceV2.ID">;
|
|
79
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.String, "WorkspaceV2.ID"> & {
|
|
80
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"WorkspaceV2.ID">;
|
|
81
|
+
create: () => string & import("effect/Brand").Brand<"WorkspaceV2.ID">;
|
|
82
|
+
}>, never, never>;
|
|
83
|
+
}>>, never, never>;
|
|
84
|
+
readonly data: Schema.Struct<{
|
|
85
|
+
readonly branch: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
86
|
+
}>;
|
|
87
|
+
}> & {
|
|
88
|
+
data: Schema.Struct<{
|
|
89
|
+
readonly branch: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
90
|
+
}>;
|
|
91
|
+
durable?: {
|
|
92
|
+
readonly version: number;
|
|
93
|
+
readonly aggregate: string;
|
|
94
|
+
} | undefined;
|
|
95
|
+
type: "vcs.branch.updated";
|
|
96
|
+
}];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * as VcsEvent from "./vcs-event.js";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
import { optional } from "./schema.js";
|
|
4
|
+
import { Event } from "./event.js";
|
|
5
|
+
export const BranchUpdated = Event.define({
|
|
6
|
+
type: "vcs.branch.updated",
|
|
7
|
+
schema: {
|
|
8
|
+
branch: optional(Schema.String),
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
export const Definitions = Event.inventory(BranchUpdated);
|