@opencode-ai/schema 0.0.0-dev-17471

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.
Files changed (193) hide show
  1. package/dist/agent.d.ts +164 -0
  2. package/dist/agent.js +46 -0
  3. package/dist/ai.d.ts +4 -0
  4. package/dist/ai.js +5 -0
  5. package/dist/catalog.d.ts +69 -0
  6. package/dist/catalog.js +4 -0
  7. package/dist/command.d.ts +124 -0
  8. package/dist/command.js +19 -0
  9. package/dist/config/agent.d.ts +42 -0
  10. package/dist/config/agent.js +20 -0
  11. package/dist/config/command.d.ts +27 -0
  12. package/dist/config/command.js +12 -0
  13. package/dist/config/compaction.d.ts +14 -0
  14. package/dist/config/compaction.js +13 -0
  15. package/dist/config/experimental.d.ts +17 -0
  16. package/dist/config/experimental.js +16 -0
  17. package/dist/config/formatter.d.ts +11 -0
  18. package/dist/config/formatter.js +11 -0
  19. package/dist/config/lsp.d.ts +20 -0
  20. package/dist/config/lsp.js +16 -0
  21. package/dist/config/mcp.d.ts +18 -0
  22. package/dist/config/mcp.js +14 -0
  23. package/dist/config/media.d.ts +15 -0
  24. package/dist/config/media.js +14 -0
  25. package/dist/config/model.d.ts +18 -0
  26. package/dist/config/model.js +28 -0
  27. package/dist/config/plugin.d.ts +11 -0
  28. package/dist/config/plugin.js +10 -0
  29. package/dist/config/policy.d.ts +10 -0
  30. package/dist/config/policy.js +8 -0
  31. package/dist/config/provider.d.ts +106 -0
  32. package/dist/config/provider.js +62 -0
  33. package/dist/config/reference.d.ts +21 -0
  34. package/dist/config/reference.js +18 -0
  35. package/dist/config/tool-output.d.ts +8 -0
  36. package/dist/config/tool-output.js +8 -0
  37. package/dist/config/warming.d.ts +10 -0
  38. package/dist/config/warming.js +16 -0
  39. package/dist/config/watcher.d.ts +7 -0
  40. package/dist/config/watcher.js +7 -0
  41. package/dist/config/websearch.d.ts +9 -0
  42. package/dist/config/websearch.js +8 -0
  43. package/dist/config.d.ts +175 -0
  44. package/dist/config.js +136 -0
  45. package/dist/connection.d.ts +28 -0
  46. package/dist/connection.js +15 -0
  47. package/dist/credential.d.ts +38 -0
  48. package/dist/credential.js +25 -0
  49. package/dist/durable-event-manifest.d.ts +3 -0
  50. package/dist/durable-event-manifest.js +5 -0
  51. package/dist/event-log.d.ts +14 -0
  52. package/dist/event-log.js +17 -0
  53. package/dist/event-manifest.d.ts +11372 -0
  54. package/dist/event-manifest.js +45 -0
  55. package/dist/event.d.ts +142 -0
  56. package/dist/event.js +110 -0
  57. package/dist/file-diff.d.ts +21 -0
  58. package/dist/file-diff.js +18 -0
  59. package/dist/filesystem-v1.d.ts +1 -0
  60. package/dist/filesystem-v1.js +1 -0
  61. package/dist/filesystem.d.ts +118 -0
  62. package/dist/filesystem.js +35 -0
  63. package/dist/form.d.ts +1259 -0
  64. package/dist/form.js +120 -0
  65. package/dist/ide-event.d.ts +76 -0
  66. package/dist/ide-event.js +10 -0
  67. package/dist/identifier.d.ts +3 -0
  68. package/dist/identifier.js +24 -0
  69. package/dist/index.d.ts +39 -0
  70. package/dist/index.js +39 -0
  71. package/dist/installation-event.d.ts +149 -0
  72. package/dist/installation-event.js +16 -0
  73. package/dist/instruction-entry.d.ts +23 -0
  74. package/dist/instruction-entry.js +22 -0
  75. package/dist/instruction.d.ts +13 -0
  76. package/dist/instruction.js +8 -0
  77. package/dist/integration-id.d.ts +5 -0
  78. package/dist/integration-id.js +3 -0
  79. package/dist/integration.d.ts +1675 -0
  80. package/dist/integration.js +87 -0
  81. package/dist/legacy-event.d.ts +1 -0
  82. package/dist/legacy-event.js +1 -0
  83. package/dist/llm.d.ts +4 -0
  84. package/dist/llm.js +3 -0
  85. package/dist/location.d.ts +37 -0
  86. package/dist/location.js +22 -0
  87. package/dist/lsp-event.d.ts +67 -0
  88. package/dist/lsp-event.js +4 -0
  89. package/dist/mcp-event.d.ts +222 -0
  90. package/dist/mcp-event.js +24 -0
  91. package/dist/mcp.d.ts +138 -0
  92. package/dist/mcp.js +111 -0
  93. package/dist/model.d.ts +186 -0
  94. package/dist/model.js +104 -0
  95. package/dist/models-dev.d.ts +69 -0
  96. package/dist/models-dev.js +7 -0
  97. package/dist/money.d.ts +10 -0
  98. package/dist/money.js +5 -0
  99. package/dist/permission-saved.d.ts +18 -0
  100. package/dist/permission-saved.js +12 -0
  101. package/dist/permission-v1.d.ts +1 -0
  102. package/dist/permission-v1.js +1 -0
  103. package/dist/permission.d.ts +306 -0
  104. package/dist/permission.js +45 -0
  105. package/dist/plugin.d.ts +150 -0
  106. package/dist/plugin.js +16 -0
  107. package/dist/project-id.d.ts +5 -0
  108. package/dist/project-id.js +3 -0
  109. package/dist/project.d.ts +241 -0
  110. package/dist/project.js +37 -0
  111. package/dist/prompt-input.d.ts +143 -0
  112. package/dist/prompt-input.js +25 -0
  113. package/dist/prompt.d.ts +297 -0
  114. package/dist/prompt.js +61 -0
  115. package/dist/provider.d.ts +60 -0
  116. package/dist/provider.js +42 -0
  117. package/dist/pty-ticket.d.ts +8 -0
  118. package/dist/pty-ticket.js +7 -0
  119. package/dist/pty.d.ts +462 -0
  120. package/dist/pty.js +43 -0
  121. package/dist/question-v1.d.ts +1 -0
  122. package/dist/question-v1.js +1 -0
  123. package/dist/question.d.ts +15 -0
  124. package/dist/question.js +15 -0
  125. package/dist/reference.d.ts +120 -0
  126. package/dist/reference.js +30 -0
  127. package/dist/schema.d.ts +10 -0
  128. package/dist/schema.js +14 -0
  129. package/dist/server-event.d.ts +132 -0
  130. package/dist/server-event.js +5 -0
  131. package/dist/session-compaction-event.d.ts +87 -0
  132. package/dist/session-compaction-event.js +10 -0
  133. package/dist/session-error.d.ts +9 -0
  134. package/dist/session-error.js +8 -0
  135. package/dist/session-event.d.ts +17994 -0
  136. package/dist/session-event.js +499 -0
  137. package/dist/session-fork.d.ts +26 -0
  138. package/dist/session-fork.js +11 -0
  139. package/dist/session-id.d.ts +6 -0
  140. package/dist/session-id.js +10 -0
  141. package/dist/session-inbox.d.ts +748 -0
  142. package/dist/session-inbox.js +47 -0
  143. package/dist/session-message.d.ts +1512 -0
  144. package/dist/session-message.js +209 -0
  145. package/dist/session-revert.d.ts +480 -0
  146. package/dist/session-revert.js +63 -0
  147. package/dist/session-status-event.d.ts +299 -0
  148. package/dist/session-status-event.js +43 -0
  149. package/dist/session-transfer.d.ts +744 -0
  150. package/dist/session-transfer.js +8 -0
  151. package/dist/session-v1.d.ts +1 -0
  152. package/dist/session-v1.js +1 -0
  153. package/dist/session.d.ts +218 -0
  154. package/dist/session.js +45 -0
  155. package/dist/shell.d.ts +381 -0
  156. package/dist/shell.js +58 -0
  157. package/dist/skill.d.ts +133 -0
  158. package/dist/skill.js +48 -0
  159. package/dist/snapshot.d.ts +4 -0
  160. package/dist/snapshot.js +3 -0
  161. package/dist/token-usage.d.ts +13 -0
  162. package/dist/token-usage.js +11 -0
  163. package/dist/tool.d.ts +74 -0
  164. package/dist/tool.js +22 -0
  165. package/dist/tui-event.d.ts +307 -0
  166. package/dist/tui-event.js +53 -0
  167. package/dist/v1/filesystem.d.ts +78 -0
  168. package/dist/v1/filesystem.js +8 -0
  169. package/dist/v1/legacy-event.d.ts +108 -0
  170. package/dist/v1/legacy-event.js +15 -0
  171. package/dist/v1/permission.d.ts +316 -0
  172. package/dist/v1/permission.js +41 -0
  173. package/dist/v1/question.d.ts +444 -0
  174. package/dist/v1/question.js +57 -0
  175. package/dist/v1/session.d.ts +7657 -0
  176. package/dist/v1/session.js +535 -0
  177. package/dist/vcs-event.d.ts +76 -0
  178. package/dist/vcs-event.js +11 -0
  179. package/dist/vcs.d.ts +26 -0
  180. package/dist/vcs.js +17 -0
  181. package/dist/websearch.d.ts +108 -0
  182. package/dist/websearch.js +31 -0
  183. package/dist/workspace-event.d.ts +247 -0
  184. package/dist/workspace-event.js +25 -0
  185. package/dist/workspace-id.d.ts +6 -0
  186. package/dist/workspace-id.js +16 -0
  187. package/dist/workspace.d.ts +9 -0
  188. package/dist/workspace.js +5 -0
  189. package/dist/worktree-event.d.ts +153 -0
  190. package/dist/worktree-event.js +18 -0
  191. package/dist/worktree.d.ts +255 -0
  192. package/dist/worktree.js +61 -0
  193. package/package.json +42 -0
@@ -0,0 +1,535 @@
1
+ export * as SessionV1 from "./session.js";
2
+ import { Effect, Schema, Types } from "effect";
3
+ import { durable, ephemeral, inventory } from "../event.js";
4
+ import { Project } from "../project.js";
5
+ import { Provider } from "../provider.js";
6
+ import { Model } from "../model.js";
7
+ import { NonNegativeInt, optional, statics } from "../schema.js";
8
+ import { ascending } from "../identifier.js";
9
+ import { SessionID } from "../session-id.js";
10
+ import { WorkspaceID } from "../workspace-id.js";
11
+ import { PermissionV1 } from "./permission.js";
12
+ import { FileDiff } from "../file-diff.js";
13
+ const Timestamp = Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0));
14
+ export const MessageID = Schema.String.check(Schema.isStartsWith("msg")).pipe(Schema.brand("SessionV1.MessageID"), statics((schema) => ({ ascending: (id) => schema.make(id ?? "msg_" + ascending()) })));
15
+ export const PartID = Schema.String.check(Schema.isStartsWith("prt")).pipe(Schema.brand("SessionV1.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: "SessionV1.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: "SessionV1.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: "SessionV1.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: "SessionV1.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: "SessionV1.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: "SessionV1.ReasoningPart" });
99
+ const filePartSourceBase = {
100
+ text: Schema.Struct({
101
+ value: Schema.String,
102
+ start: Schema.Finite,
103
+ end: Schema.Finite,
104
+ }).annotate({ identifier: "SessionV1.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: "SessionV1.Range" });
110
+ export const FileSource = Schema.Struct({
111
+ ...filePartSourceBase,
112
+ type: Schema.Literal("file"),
113
+ path: Schema.String,
114
+ }).annotate({ identifier: "SessionV1.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: "SessionV1.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: "SessionV1.ResourceSource" });
129
+ export const FilePartSource = Schema.Union([FileSource, SymbolSource, ResourceSource]).annotate({
130
+ discriminator: "type",
131
+ identifier: "SessionV1.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: "SessionV1.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: "SessionV1.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: "SessionV1.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: "SessionV1.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: "SessionV1.RetryPart" });
179
+ export const StepStartPart = Schema.Struct({
180
+ ...partBase,
181
+ type: Schema.Literal("step-start"),
182
+ snapshot: Schema.optional(Schema.String),
183
+ }).annotate({ identifier: "SessionV1.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: "SessionV1.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: "SessionV1.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: "SessionV1.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: "SessionV1.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: "SessionV1.ToolStateError" });
238
+ export const ToolState = Schema.Union([
239
+ ToolStatePending,
240
+ ToolStateRunning,
241
+ ToolStateCompleted,
242
+ ToolStateError,
243
+ ]).annotate({
244
+ discriminator: "status",
245
+ identifier: "SessionV1.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: "SessionV1.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.LegacyInfo),
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: "SessionV1.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: "SessionV1.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: "SessionV1.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: "SessionV1.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: "SessionV1.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: "SessionV1.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: "SessionV1.AssistantMessage" });
379
+ export const Info = Schema.Union([User, Assistant]).annotate({ discriminator: "role", identifier: "SessionV1.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.LegacyInfo)),
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: optional(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: "SessionV1.Info" });
445
+ const events = {
446
+ Created: durable({
447
+ type: "session.created",
448
+ ...options,
449
+ schema: {
450
+ sessionID: SessionID,
451
+ info: SessionInfo,
452
+ },
453
+ }),
454
+ Updated: durable({
455
+ type: "session.updated",
456
+ ...options,
457
+ schema: {
458
+ sessionID: SessionID,
459
+ info: SessionInfo,
460
+ },
461
+ }),
462
+ Deleted: durable({
463
+ type: "session.deleted",
464
+ ...options,
465
+ schema: {
466
+ sessionID: SessionID,
467
+ info: SessionInfo,
468
+ },
469
+ }),
470
+ MessageUpdated: durable({
471
+ type: "message.updated",
472
+ ...options,
473
+ schema: {
474
+ sessionID: SessionID,
475
+ info: Info,
476
+ },
477
+ }),
478
+ MessageRemoved: durable({
479
+ type: "message.removed",
480
+ ...options,
481
+ schema: {
482
+ sessionID: SessionID,
483
+ messageID: MessageID,
484
+ },
485
+ }),
486
+ PartUpdated: durable({
487
+ type: "message.part.updated",
488
+ ...options,
489
+ schema: {
490
+ sessionID: SessionID,
491
+ part: Part,
492
+ time: Schema.Finite,
493
+ },
494
+ }),
495
+ PartRemoved: durable({
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 = ephemeral({
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 = ephemeral({
516
+ type: "session.diff",
517
+ schema: {
518
+ sessionID: SessionID,
519
+ diff: Schema.Array(FileDiff.LegacyInfo),
520
+ },
521
+ });
522
+ export const Error = ephemeral({
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,76 @@
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 created: Schema.Finite;
8
+ readonly metadata: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
9
+ readonly type: Schema.Literal<"vcs.branch.updated">;
10
+ readonly location: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
11
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
12
+ readonly workspaceID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Workspace.ID"> & {
13
+ ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
14
+ create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
15
+ }>>, Schema.optionalKey<Schema.brand<Schema.String, "Workspace.ID"> & {
16
+ ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
17
+ create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
18
+ }>, never, never>;
19
+ }>>>, Schema.optionalKey<Schema.Struct<{
20
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
21
+ readonly workspaceID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Workspace.ID"> & {
22
+ ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
23
+ create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
24
+ }>>, Schema.optionalKey<Schema.brand<Schema.String, "Workspace.ID"> & {
25
+ ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
26
+ create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
27
+ }>, never, never>;
28
+ }>>, never, never>;
29
+ readonly data: Schema.Struct<{
30
+ readonly branch: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
31
+ }>;
32
+ }> & {
33
+ type: "vcs.branch.updated";
34
+ durability: "ephemeral";
35
+ durable: undefined;
36
+ data: Schema.Struct<{
37
+ readonly branch: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
38
+ }>;
39
+ };
40
+ export declare const Definitions: readonly [Schema.Struct<{
41
+ readonly id: Schema.brand<Schema.String, "Event.ID"> & {
42
+ create: () => string & import("effect/Brand").Brand<"Event.ID">;
43
+ };
44
+ readonly created: Schema.Finite;
45
+ readonly metadata: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
46
+ readonly type: Schema.Literal<"vcs.branch.updated">;
47
+ readonly location: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
48
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
49
+ readonly workspaceID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Workspace.ID"> & {
50
+ ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
51
+ create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
52
+ }>>, Schema.optionalKey<Schema.brand<Schema.String, "Workspace.ID"> & {
53
+ ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
54
+ create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
55
+ }>, never, never>;
56
+ }>>>, Schema.optionalKey<Schema.Struct<{
57
+ readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
58
+ readonly workspaceID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Workspace.ID"> & {
59
+ ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
60
+ create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
61
+ }>>, Schema.optionalKey<Schema.brand<Schema.String, "Workspace.ID"> & {
62
+ ascending: (id?: string) => string & import("effect/Brand").Brand<"Workspace.ID">;
63
+ create: () => string & import("effect/Brand").Brand<"Workspace.ID">;
64
+ }>, never, never>;
65
+ }>>, never, never>;
66
+ readonly data: Schema.Struct<{
67
+ readonly branch: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
68
+ }>;
69
+ }> & {
70
+ type: "vcs.branch.updated";
71
+ durability: "ephemeral";
72
+ durable: undefined;
73
+ data: Schema.Struct<{
74
+ readonly branch: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
75
+ }>;
76
+ }];
@@ -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.ephemeral({
6
+ type: "vcs.branch.updated",
7
+ schema: {
8
+ branch: optional(Schema.String),
9
+ },
10
+ });
11
+ export const Definitions = Event.inventory(BranchUpdated);
package/dist/vcs.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ export * as Vcs from "./vcs.js";
2
+ import { Schema } from "effect";
3
+ export declare const Branch: Schema.Struct<{
4
+ readonly current: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
5
+ readonly default: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
6
+ }>;
7
+ export interface Branch extends Schema.Schema.Type<typeof Branch> {
8
+ }
9
+ export declare const Info: Schema.Struct<{
10
+ readonly branch: Schema.Struct<{
11
+ readonly current: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
12
+ readonly default: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
13
+ }>;
14
+ }>;
15
+ export interface Info extends Schema.Schema.Type<typeof Info> {
16
+ }
17
+ export declare const Mode: Schema.Literals<readonly ["working", "branch"]>;
18
+ export type Mode = typeof Mode.Type;
19
+ export declare const FileStatus: Schema.Struct<{
20
+ readonly file: Schema.String;
21
+ readonly additions: Schema.Int;
22
+ readonly deletions: Schema.Int;
23
+ readonly status: Schema.Literals<readonly ["added", "deleted", "modified"]>;
24
+ }>;
25
+ export interface FileStatus extends Schema.Schema.Type<typeof FileStatus> {
26
+ }
package/dist/vcs.js ADDED
@@ -0,0 +1,17 @@
1
+ export * as Vcs from "./vcs.js";
2
+ import { Schema } from "effect";
3
+ import { NonNegativeInt, optional } from "./schema.js";
4
+ export const Branch = Schema.Struct({
5
+ current: optional(Schema.String),
6
+ default: optional(Schema.String),
7
+ }).annotate({ identifier: "Vcs.Branch" });
8
+ export const Info = Schema.Struct({
9
+ branch: Branch,
10
+ }).annotate({ identifier: "Vcs.Info" });
11
+ export const Mode = Schema.Literals(["working", "branch"]).annotate({ identifier: "Vcs.Mode" });
12
+ export const FileStatus = Schema.Struct({
13
+ file: Schema.String,
14
+ additions: NonNegativeInt,
15
+ deletions: NonNegativeInt,
16
+ status: Schema.Literals(["added", "deleted", "modified"]),
17
+ }).annotate({ identifier: "Vcs.FileStatus" });