@otto-code/protocol 0.8.10 → 0.8.13

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 (83) hide show
  1. package/dist/agent-labels.d.ts +3 -0
  2. package/dist/agent-labels.js +10 -0
  3. package/dist/agent-personalities.d.ts +4 -3
  4. package/dist/agent-personalities.js +13 -20
  5. package/dist/agent-queue.d.ts +87 -0
  6. package/dist/agent-queue.js +106 -0
  7. package/dist/agent-types.d.ts +24 -4
  8. package/dist/binary-frames/terminal.d.ts +4 -0
  9. package/dist/binary-frames/terminal.js +1 -0
  10. package/dist/brain.d.ts +2412 -0
  11. package/dist/brain.js +1100 -0
  12. package/dist/chat/rpc-schemas.js +1 -0
  13. package/dist/chat/types.js +1 -0
  14. package/dist/client-capabilities.d.ts +3 -0
  15. package/dist/client-capabilities.js +14 -0
  16. package/dist/code-intelligence.d.ts +917 -0
  17. package/dist/code-intelligence.js +699 -0
  18. package/dist/communications.d.ts +1106 -0
  19. package/dist/communications.js +384 -0
  20. package/dist/context.d.ts +787 -0
  21. package/dist/context.js +295 -0
  22. package/dist/daemon-config.d.ts +383 -0
  23. package/dist/daemon-config.js +401 -0
  24. package/dist/file-operations.d.ts +380 -0
  25. package/dist/file-operations.js +282 -0
  26. package/dist/generated/validation/ws-outbound.aot.js +67260 -57392
  27. package/dist/git-hosting.d.ts +117 -0
  28. package/dist/git-hosting.js +109 -0
  29. package/dist/git-operations.d.ts +255 -0
  30. package/dist/git-operations.js +221 -0
  31. package/dist/integration-authorization.d.ts +195 -0
  32. package/dist/integration-authorization.js +125 -0
  33. package/dist/kanban.d.ts +341 -0
  34. package/dist/kanban.js +273 -0
  35. package/dist/loop/rpc-schemas.d.ts +6 -6
  36. package/dist/loop/rpc-schemas.js +1 -0
  37. package/dist/meetings.d.ts +95 -0
  38. package/dist/meetings.js +57 -0
  39. package/dist/messages.d.ts +11175 -11039
  40. package/dist/messages.js +4756 -8700
  41. package/dist/orchestration.d.ts +726 -0
  42. package/dist/orchestration.js +232 -0
  43. package/dist/personality-schemas.d.ts +221 -0
  44. package/dist/personality-schemas.js +340 -0
  45. package/dist/preview.d.ts +140 -0
  46. package/dist/preview.js +98 -0
  47. package/dist/project-knowledge.d.ts +740 -0
  48. package/dist/project-knowledge.js +229 -0
  49. package/dist/project-links.d.ts +102 -0
  50. package/dist/project-links.js +62 -0
  51. package/dist/provider-config.d.ts +87 -2
  52. package/dist/provider-config.js +110 -0
  53. package/dist/provider-manifest.js +7 -0
  54. package/dist/provider-snapshot-codec.d.ts +18 -0
  55. package/dist/provider-snapshot-codec.js +71 -0
  56. package/dist/refine.d.ts +93 -0
  57. package/dist/refine.js +78 -0
  58. package/dist/schedule/rpc-schemas.d.ts +55 -111
  59. package/dist/schedule/types.d.ts +16 -37
  60. package/dist/schedule/types.js +1 -11
  61. package/dist/search/text-match.d.ts +55 -0
  62. package/dist/search/text-match.js +262 -0
  63. package/dist/speech.d.ts +180 -0
  64. package/dist/speech.js +177 -0
  65. package/dist/storage.d.ts +79 -0
  66. package/dist/storage.js +107 -0
  67. package/dist/suggested-tasks.d.ts +106 -0
  68. package/dist/suggested-tasks.js +81 -0
  69. package/dist/terminal-compatibility.d.ts +55 -0
  70. package/dist/terminal-compatibility.js +35 -0
  71. package/dist/terminal-input-mode.d.ts +4 -0
  72. package/dist/terminal-input-mode.js +35 -6
  73. package/dist/terminal-key-input.js +15 -6
  74. package/dist/terminal-profiles.d.ts +35 -0
  75. package/dist/terminal-profiles.js +246 -4
  76. package/dist/tool-call-display.d.ts +2 -2
  77. package/dist/tool-call-display.js +6 -6
  78. package/dist/usage-stats.d.ts +255 -0
  79. package/dist/usage-stats.js +162 -0
  80. package/dist/validation/ws-outbound-schema-metadata.d.ts +1906 -266
  81. package/dist/worktree-ops.d.ts +81 -0
  82. package/dist/worktree-ops.js +88 -0
  83. package/package.json +1 -1
@@ -0,0 +1,380 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Otto file-operation wire schemas: the file.search, file.replace, file.create/delete/rename and file.watch RPCs and pushes used by the file explorer and editor. Fork-only capability, so it owns its schemas; messages.ts re-exports them.
4
+ */
5
+ export declare const FileEolSchema: z.ZodEnum<{
6
+ lf: "lf";
7
+ crlf: "crlf";
8
+ }>;
9
+ /** What a directory entry is. Shared by the file-mutation RPCs below. */
10
+ export declare const FileEntryKindSchema: z.ZodEnum<{
11
+ file: "file";
12
+ directory: "directory";
13
+ }>;
14
+ /**
15
+ * The general file-mutation surface: create, delete, rename/move.
16
+ *
17
+ * Deliberately separate from `file.write.request`, which is the text editor's
18
+ * conditional *content* save. These three change what exists in the directory
19
+ * rather than what is inside a file, and unlike `file.write` they are
20
+ * **workspace-bounded**: the daemon refuses a `cwd` outside every known Otto
21
+ * workspace, the way directory listing already does. Editing a stray file the
22
+ * user opened by path is one thing; unlinking one is another.
23
+ *
24
+ * `path` is workspace-relative throughout, matching every other file RPC.
25
+ */
26
+ export declare const FileCreateRequestSchema: z.ZodObject<{
27
+ type: z.ZodLiteral<"file.create.request">;
28
+ cwd: z.ZodString;
29
+ path: z.ZodString;
30
+ kind: z.ZodEnum<{
31
+ file: "file";
32
+ directory: "directory";
33
+ }>;
34
+ requestId: z.ZodString;
35
+ }, z.core.$strip>;
36
+ /**
37
+ * Permanent delete - an unlink, not a move to the OS trash. The daemon may be
38
+ * headless, remote, or inside WSL, where there is no reliable trash to move to;
39
+ * a "deleted" file that silently stayed on disk in one environment and vanished
40
+ * in another would be worse than either. The client's confirmation says so.
41
+ */
42
+ export declare const FileDeleteRequestSchema: z.ZodObject<{
43
+ type: z.ZodLiteral<"file.delete.request">;
44
+ cwd: z.ZodString;
45
+ path: z.ZodString;
46
+ recursive: z.ZodOptional<z.ZodBoolean>;
47
+ requestId: z.ZodString;
48
+ }, z.core.$strip>;
49
+ /**
50
+ * Rename and move are the same operation - a move is a rename whose new path
51
+ * has a different parent. Never clobbers: an occupied destination comes back as
52
+ * `exists` and nothing moves. There is no overwrite flag on purpose, so this
53
+ * RPC cannot destroy a file the user did not name.
54
+ */
55
+ export declare const FileRenameRequestSchema: z.ZodObject<{
56
+ type: z.ZodLiteral<"file.rename.request">;
57
+ cwd: z.ZodString;
58
+ path: z.ZodString;
59
+ newPath: z.ZodString;
60
+ requestId: z.ZodString;
61
+ }, z.core.$strip>;
62
+ export declare const FileWatchSubscribeRequestSchema: z.ZodObject<{
63
+ type: z.ZodLiteral<"file.watch.subscribe.request">;
64
+ cwd: z.ZodString;
65
+ path: z.ZodString;
66
+ requestId: z.ZodString;
67
+ }, z.core.$strip>;
68
+ export declare const FileWatchUnsubscribeRequestSchema: z.ZodObject<{
69
+ type: z.ZodLiteral<"file.watch.unsubscribe.request">;
70
+ cwd: z.ZodString;
71
+ path: z.ZodString;
72
+ requestId: z.ZodString;
73
+ }, z.core.$strip>;
74
+ /**
75
+ * Project-wide search ("Find in Files" semantics: explicit search, not
76
+ * per-keystroke). Results stream as file.search.result events correlated by
77
+ * searchId (= this requestId); a new search from the same session supersedes
78
+ * any in-flight one.
79
+ */
80
+ export declare const FileSearchRequestSchema: z.ZodObject<{
81
+ type: z.ZodLiteral<"file.search.request">;
82
+ cwd: z.ZodString;
83
+ query: z.ZodString;
84
+ caseSensitive: z.ZodOptional<z.ZodBoolean>;
85
+ wholeWord: z.ZodOptional<z.ZodBoolean>;
86
+ regexp: z.ZodOptional<z.ZodBoolean>;
87
+ include: z.ZodOptional<z.ZodString>;
88
+ exclude: z.ZodOptional<z.ZodString>;
89
+ requestId: z.ZodString;
90
+ }, z.core.$strip>;
91
+ export declare const FileReplaceMatchSchema: z.ZodObject<{
92
+ line: z.ZodNumber;
93
+ column: z.ZodNumber;
94
+ length: z.ZodNumber;
95
+ }, z.core.$strip>;
96
+ /**
97
+ * Preview-first project replace. Each file carries the hash the preview was
98
+ * built against - files changed since are skipped and reported, never
99
+ * corrupted. The replacement string is literal (no capture references in v1).
100
+ */
101
+ export declare const FileReplaceRequestSchema: z.ZodObject<{
102
+ type: z.ZodLiteral<"file.replace.request">;
103
+ cwd: z.ZodString;
104
+ replacement: z.ZodString;
105
+ files: z.ZodArray<z.ZodObject<{
106
+ path: z.ZodString;
107
+ expectedHash: z.ZodString;
108
+ matches: z.ZodArray<z.ZodObject<{
109
+ line: z.ZodNumber;
110
+ column: z.ZodNumber;
111
+ length: z.ZodNumber;
112
+ }, z.core.$strip>>;
113
+ }, z.core.$strip>>;
114
+ requestId: z.ZodString;
115
+ }, z.core.$strip>;
116
+ /**
117
+ * Create outcome. `exists` is its own status rather than an error string: it is
118
+ * the one failure the client can act on (offer a different name) instead of
119
+ * merely reporting.
120
+ */
121
+ export declare const FileCreateResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
122
+ status: z.ZodLiteral<"ok">;
123
+ path: z.ZodString;
124
+ kind: z.ZodEnum<{
125
+ file: "file";
126
+ directory: "directory";
127
+ }>;
128
+ modifiedAt: z.ZodString;
129
+ size: z.ZodNumber;
130
+ }, z.core.$strip>, z.ZodObject<{
131
+ status: z.ZodLiteral<"exists">;
132
+ }, z.core.$strip>, z.ZodObject<{
133
+ status: z.ZodLiteral<"error">;
134
+ message: z.ZodString;
135
+ }, z.core.$strip>], "status">;
136
+ export declare const FileCreateResponseSchema: z.ZodObject<{
137
+ type: z.ZodLiteral<"file.create.response">;
138
+ payload: z.ZodObject<{
139
+ cwd: z.ZodString;
140
+ path: z.ZodString;
141
+ result: z.ZodDiscriminatedUnion<[z.ZodObject<{
142
+ status: z.ZodLiteral<"ok">;
143
+ path: z.ZodString;
144
+ kind: z.ZodEnum<{
145
+ file: "file";
146
+ directory: "directory";
147
+ }>;
148
+ modifiedAt: z.ZodString;
149
+ size: z.ZodNumber;
150
+ }, z.core.$strip>, z.ZodObject<{
151
+ status: z.ZodLiteral<"exists">;
152
+ }, z.core.$strip>, z.ZodObject<{
153
+ status: z.ZodLiteral<"error">;
154
+ message: z.ZodString;
155
+ }, z.core.$strip>], "status">;
156
+ requestId: z.ZodString;
157
+ }, z.core.$strip>;
158
+ }, z.core.$strip>;
159
+ /**
160
+ * Delete outcome. `not_empty` means the target is a directory with children and
161
+ * the request did not set `recursive` - nothing was removed, and the client can
162
+ * re-ask with the stronger confirmation.
163
+ */
164
+ export declare const FileDeleteResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
165
+ status: z.ZodLiteral<"ok">;
166
+ path: z.ZodString;
167
+ kind: z.ZodEnum<{
168
+ file: "file";
169
+ directory: "directory";
170
+ }>;
171
+ }, z.core.$strip>, z.ZodObject<{
172
+ status: z.ZodLiteral<"not_found">;
173
+ }, z.core.$strip>, z.ZodObject<{
174
+ status: z.ZodLiteral<"not_empty">;
175
+ }, z.core.$strip>, z.ZodObject<{
176
+ status: z.ZodLiteral<"error">;
177
+ message: z.ZodString;
178
+ }, z.core.$strip>], "status">;
179
+ export declare const FileDeleteResponseSchema: z.ZodObject<{
180
+ type: z.ZodLiteral<"file.delete.response">;
181
+ payload: z.ZodObject<{
182
+ cwd: z.ZodString;
183
+ path: z.ZodString;
184
+ result: z.ZodDiscriminatedUnion<[z.ZodObject<{
185
+ status: z.ZodLiteral<"ok">;
186
+ path: z.ZodString;
187
+ kind: z.ZodEnum<{
188
+ file: "file";
189
+ directory: "directory";
190
+ }>;
191
+ }, z.core.$strip>, z.ZodObject<{
192
+ status: z.ZodLiteral<"not_found">;
193
+ }, z.core.$strip>, z.ZodObject<{
194
+ status: z.ZodLiteral<"not_empty">;
195
+ }, z.core.$strip>, z.ZodObject<{
196
+ status: z.ZodLiteral<"error">;
197
+ message: z.ZodString;
198
+ }, z.core.$strip>], "status">;
199
+ requestId: z.ZodString;
200
+ }, z.core.$strip>;
201
+ }, z.core.$strip>;
202
+ /** Rename/move outcome. `exists` means the destination was occupied; nothing moved. */
203
+ export declare const FileRenameResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
204
+ status: z.ZodLiteral<"ok">;
205
+ from: z.ZodString;
206
+ to: z.ZodString;
207
+ kind: z.ZodEnum<{
208
+ file: "file";
209
+ directory: "directory";
210
+ }>;
211
+ }, z.core.$strip>, z.ZodObject<{
212
+ status: z.ZodLiteral<"not_found">;
213
+ }, z.core.$strip>, z.ZodObject<{
214
+ status: z.ZodLiteral<"exists">;
215
+ }, z.core.$strip>, z.ZodObject<{
216
+ status: z.ZodLiteral<"error">;
217
+ message: z.ZodString;
218
+ }, z.core.$strip>], "status">;
219
+ export declare const FileRenameResponseSchema: z.ZodObject<{
220
+ type: z.ZodLiteral<"file.rename.response">;
221
+ payload: z.ZodObject<{
222
+ cwd: z.ZodString;
223
+ path: z.ZodString;
224
+ newPath: z.ZodString;
225
+ result: z.ZodDiscriminatedUnion<[z.ZodObject<{
226
+ status: z.ZodLiteral<"ok">;
227
+ from: z.ZodString;
228
+ to: z.ZodString;
229
+ kind: z.ZodEnum<{
230
+ file: "file";
231
+ directory: "directory";
232
+ }>;
233
+ }, z.core.$strip>, z.ZodObject<{
234
+ status: z.ZodLiteral<"not_found">;
235
+ }, z.core.$strip>, z.ZodObject<{
236
+ status: z.ZodLiteral<"exists">;
237
+ }, z.core.$strip>, z.ZodObject<{
238
+ status: z.ZodLiteral<"error">;
239
+ message: z.ZodString;
240
+ }, z.core.$strip>], "status">;
241
+ requestId: z.ZodString;
242
+ }, z.core.$strip>;
243
+ }, z.core.$strip>;
244
+ export declare const FileWatchSubscribeResponseSchema: z.ZodObject<{
245
+ type: z.ZodLiteral<"file.watch.subscribe.response">;
246
+ payload: z.ZodObject<{
247
+ cwd: z.ZodString;
248
+ path: z.ZodString;
249
+ ok: z.ZodBoolean;
250
+ error: z.ZodNullable<z.ZodString>;
251
+ requestId: z.ZodString;
252
+ }, z.core.$strip>;
253
+ }, z.core.$strip>;
254
+ export declare const FileWatchUnsubscribeResponseSchema: z.ZodObject<{
255
+ type: z.ZodLiteral<"file.watch.unsubscribe.response">;
256
+ payload: z.ZodObject<{
257
+ cwd: z.ZodString;
258
+ path: z.ZodString;
259
+ ok: z.ZodBoolean;
260
+ error: z.ZodNullable<z.ZodString>;
261
+ requestId: z.ZodString;
262
+ }, z.core.$strip>;
263
+ }, z.core.$strip>;
264
+ export declare const FileSearchMatchSchema: z.ZodObject<{
265
+ line: z.ZodNumber;
266
+ column: z.ZodNumber;
267
+ length: z.ZodNumber;
268
+ lineText: z.ZodString;
269
+ previewStart: z.ZodNumber;
270
+ }, z.core.$strip>;
271
+ export declare const FileSearchResultEventSchema: z.ZodObject<{
272
+ type: z.ZodLiteral<"file.search.result">;
273
+ payload: z.ZodObject<{
274
+ cwd: z.ZodString;
275
+ searchId: z.ZodString;
276
+ path: z.ZodString;
277
+ hash: z.ZodString;
278
+ matches: z.ZodArray<z.ZodObject<{
279
+ line: z.ZodNumber;
280
+ column: z.ZodNumber;
281
+ length: z.ZodNumber;
282
+ lineText: z.ZodString;
283
+ previewStart: z.ZodNumber;
284
+ }, z.core.$strip>>;
285
+ }, z.core.$strip>;
286
+ }, z.core.$strip>;
287
+ export declare const FileSearchResponseSchema: z.ZodObject<{
288
+ type: z.ZodLiteral<"file.search.response">;
289
+ payload: z.ZodObject<{
290
+ cwd: z.ZodString;
291
+ status: z.ZodEnum<{
292
+ error: "error";
293
+ completed: "completed";
294
+ truncated: "truncated";
295
+ superseded: "superseded";
296
+ }>;
297
+ error: z.ZodNullable<z.ZodString>;
298
+ fileCount: z.ZodNumber;
299
+ matchCount: z.ZodNumber;
300
+ requestId: z.ZodString;
301
+ }, z.core.$strip>;
302
+ }, z.core.$strip>;
303
+ export declare const FileReplaceFileResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
304
+ status: z.ZodLiteral<"ok">;
305
+ path: z.ZodString;
306
+ replacedCount: z.ZodNumber;
307
+ modifiedAt: z.ZodString;
308
+ hash: z.ZodString;
309
+ }, z.core.$strip>, z.ZodObject<{
310
+ status: z.ZodLiteral<"skipped">;
311
+ path: z.ZodString;
312
+ reason: z.ZodString;
313
+ }, z.core.$strip>, z.ZodObject<{
314
+ status: z.ZodLiteral<"error">;
315
+ path: z.ZodString;
316
+ message: z.ZodString;
317
+ }, z.core.$strip>], "status">;
318
+ export declare const FileReplaceResponseSchema: z.ZodObject<{
319
+ type: z.ZodLiteral<"file.replace.response">;
320
+ payload: z.ZodObject<{
321
+ cwd: z.ZodString;
322
+ results: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
323
+ status: z.ZodLiteral<"ok">;
324
+ path: z.ZodString;
325
+ replacedCount: z.ZodNumber;
326
+ modifiedAt: z.ZodString;
327
+ hash: z.ZodString;
328
+ }, z.core.$strip>, z.ZodObject<{
329
+ status: z.ZodLiteral<"skipped">;
330
+ path: z.ZodString;
331
+ reason: z.ZodString;
332
+ }, z.core.$strip>, z.ZodObject<{
333
+ status: z.ZodLiteral<"error">;
334
+ path: z.ZodString;
335
+ message: z.ZodString;
336
+ }, z.core.$strip>], "status">>;
337
+ error: z.ZodNullable<z.ZodString>;
338
+ requestId: z.ZodString;
339
+ }, z.core.$strip>;
340
+ }, z.core.$strip>;
341
+ export declare const FileWatchEventSchema: z.ZodObject<{
342
+ type: z.ZodLiteral<"file.watch.event">;
343
+ payload: z.ZodObject<{
344
+ cwd: z.ZodString;
345
+ path: z.ZodString;
346
+ change: z.ZodEnum<{
347
+ deleted: "deleted";
348
+ changed: "changed";
349
+ recreated: "recreated";
350
+ }>;
351
+ modifiedAt: z.ZodNullable<z.ZodString>;
352
+ hash: z.ZodNullable<z.ZodString>;
353
+ size: z.ZodNullable<z.ZodNumber>;
354
+ }, z.core.$strip>;
355
+ }, z.core.$strip>;
356
+ export type FileEol = z.infer<typeof FileEolSchema>;
357
+ export type FileEntryKind = z.infer<typeof FileEntryKindSchema>;
358
+ export type FileCreateRequest = z.infer<typeof FileCreateRequestSchema>;
359
+ export type FileCreateResponse = z.infer<typeof FileCreateResponseSchema>;
360
+ export type FileCreateResult = z.infer<typeof FileCreateResultSchema>;
361
+ export type FileDeleteRequest = z.infer<typeof FileDeleteRequestSchema>;
362
+ export type FileDeleteResponse = z.infer<typeof FileDeleteResponseSchema>;
363
+ export type FileDeleteResult = z.infer<typeof FileDeleteResultSchema>;
364
+ export type FileRenameRequest = z.infer<typeof FileRenameRequestSchema>;
365
+ export type FileRenameResponse = z.infer<typeof FileRenameResponseSchema>;
366
+ export type FileRenameResult = z.infer<typeof FileRenameResultSchema>;
367
+ export type FileWatchSubscribeRequest = z.infer<typeof FileWatchSubscribeRequestSchema>;
368
+ export type FileWatchUnsubscribeRequest = z.infer<typeof FileWatchUnsubscribeRequestSchema>;
369
+ export type FileWatchEvent = z.infer<typeof FileWatchEventSchema>;
370
+ export type FileWatchEventPayload = FileWatchEvent["payload"];
371
+ export type FileSearchRequest = z.infer<typeof FileSearchRequestSchema>;
372
+ export type FileSearchMatch = z.infer<typeof FileSearchMatchSchema>;
373
+ export type FileSearchResultEvent = z.infer<typeof FileSearchResultEventSchema>;
374
+ export type FileSearchResultPayload = FileSearchResultEvent["payload"];
375
+ export type FileSearchResponse = z.infer<typeof FileSearchResponseSchema>;
376
+ export type FileSearchSummary = FileSearchResponse["payload"];
377
+ export type FileReplaceRequest = z.infer<typeof FileReplaceRequestSchema>;
378
+ export type FileReplaceResponse = z.infer<typeof FileReplaceResponseSchema>;
379
+ export type FileReplaceFileResult = z.infer<typeof FileReplaceFileResultSchema>;
380
+ //# sourceMappingURL=file-operations.d.ts.map
@@ -0,0 +1,282 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Otto file-operation wire schemas: the file.search, file.replace, file.create/delete/rename and file.watch RPCs and pushes used by the file explorer and editor. Fork-only capability, so it owns its schemas; messages.ts re-exports them.
4
+ */
5
+ export const FileEolSchema = z.enum(["lf", "crlf"]);
6
+ /** What a directory entry is. Shared by the file-mutation RPCs below. */
7
+ export const FileEntryKindSchema = z.enum(["file", "directory"]);
8
+ /**
9
+ * The general file-mutation surface: create, delete, rename/move.
10
+ *
11
+ * Deliberately separate from `file.write.request`, which is the text editor's
12
+ * conditional *content* save. These three change what exists in the directory
13
+ * rather than what is inside a file, and unlike `file.write` they are
14
+ * **workspace-bounded**: the daemon refuses a `cwd` outside every known Otto
15
+ * workspace, the way directory listing already does. Editing a stray file the
16
+ * user opened by path is one thing; unlinking one is another.
17
+ *
18
+ * `path` is workspace-relative throughout, matching every other file RPC.
19
+ */
20
+ export const FileCreateRequestSchema = z.object({
21
+ type: z.literal("file.create.request"),
22
+ cwd: z.string(),
23
+ path: z.string(),
24
+ kind: FileEntryKindSchema,
25
+ requestId: z.string(),
26
+ });
27
+ /**
28
+ * Permanent delete - an unlink, not a move to the OS trash. The daemon may be
29
+ * headless, remote, or inside WSL, where there is no reliable trash to move to;
30
+ * a "deleted" file that silently stayed on disk in one environment and vanished
31
+ * in another would be worse than either. The client's confirmation says so.
32
+ */
33
+ export const FileDeleteRequestSchema = z.object({
34
+ type: z.literal("file.delete.request"),
35
+ cwd: z.string(),
36
+ path: z.string(),
37
+ // Required to delete a directory that has children. Absent (the default) a
38
+ // non-empty directory comes back as `not_empty` and nothing is removed, so a
39
+ // client that never asks can never recursively wipe a tree by accident.
40
+ recursive: z.boolean().optional(),
41
+ requestId: z.string(),
42
+ });
43
+ /**
44
+ * Rename and move are the same operation - a move is a rename whose new path
45
+ * has a different parent. Never clobbers: an occupied destination comes back as
46
+ * `exists` and nothing moves. There is no overwrite flag on purpose, so this
47
+ * RPC cannot destroy a file the user did not name.
48
+ */
49
+ export const FileRenameRequestSchema = z.object({
50
+ type: z.literal("file.rename.request"),
51
+ cwd: z.string(),
52
+ path: z.string(),
53
+ newPath: z.string(),
54
+ requestId: z.string(),
55
+ });
56
+ // Subscriptions exist only for paths open in tabs; the daemon cleans them up
57
+ // when the session ends.
58
+ export const FileWatchSubscribeRequestSchema = z.object({
59
+ type: z.literal("file.watch.subscribe.request"),
60
+ cwd: z.string(),
61
+ path: z.string(),
62
+ requestId: z.string(),
63
+ });
64
+ export const FileWatchUnsubscribeRequestSchema = z.object({
65
+ type: z.literal("file.watch.unsubscribe.request"),
66
+ cwd: z.string(),
67
+ path: z.string(),
68
+ requestId: z.string(),
69
+ });
70
+ /**
71
+ * Project-wide search ("Find in Files" semantics: explicit search, not
72
+ * per-keystroke). Results stream as file.search.result events correlated by
73
+ * searchId (= this requestId); a new search from the same session supersedes
74
+ * any in-flight one.
75
+ */
76
+ export const FileSearchRequestSchema = z.object({
77
+ type: z.literal("file.search.request"),
78
+ cwd: z.string(),
79
+ query: z.string(),
80
+ caseSensitive: z.boolean().optional(),
81
+ wholeWord: z.boolean().optional(),
82
+ regexp: z.boolean().optional(),
83
+ include: z.string().optional(),
84
+ exclude: z.string().optional(),
85
+ requestId: z.string(),
86
+ });
87
+ export const FileReplaceMatchSchema = z.object({
88
+ /** 1-based line number. */
89
+ line: z.number().int().positive(),
90
+ /** 1-based character column of the match start. */
91
+ column: z.number().int().positive(),
92
+ /** Match length in characters. */
93
+ length: z.number().int().nonnegative(),
94
+ });
95
+ /**
96
+ * Preview-first project replace. Each file carries the hash the preview was
97
+ * built against - files changed since are skipped and reported, never
98
+ * corrupted. The replacement string is literal (no capture references in v1).
99
+ */
100
+ export const FileReplaceRequestSchema = z.object({
101
+ type: z.literal("file.replace.request"),
102
+ cwd: z.string(),
103
+ replacement: z.string(),
104
+ files: z.array(z.object({
105
+ path: z.string(),
106
+ expectedHash: z.string(),
107
+ matches: z.array(FileReplaceMatchSchema),
108
+ })),
109
+ requestId: z.string(),
110
+ });
111
+ /**
112
+ * Create outcome. `exists` is its own status rather than an error string: it is
113
+ * the one failure the client can act on (offer a different name) instead of
114
+ * merely reporting.
115
+ */
116
+ export const FileCreateResultSchema = z.discriminatedUnion("status", [
117
+ z.object({
118
+ status: z.literal("ok"),
119
+ // Echoed back normalized (forward slashes, workspace-relative) so the client
120
+ // selects the entry it will actually see in the next listing.
121
+ path: z.string(),
122
+ kind: FileEntryKindSchema,
123
+ modifiedAt: z.string(),
124
+ size: z.number(),
125
+ }),
126
+ z.object({ status: z.literal("exists") }),
127
+ z.object({ status: z.literal("error"), message: z.string() }),
128
+ ]);
129
+ export const FileCreateResponseSchema = z.object({
130
+ type: z.literal("file.create.response"),
131
+ payload: z.object({
132
+ cwd: z.string(),
133
+ path: z.string(),
134
+ result: FileCreateResultSchema,
135
+ requestId: z.string(),
136
+ }),
137
+ });
138
+ /**
139
+ * Delete outcome. `not_empty` means the target is a directory with children and
140
+ * the request did not set `recursive` - nothing was removed, and the client can
141
+ * re-ask with the stronger confirmation.
142
+ */
143
+ export const FileDeleteResultSchema = z.discriminatedUnion("status", [
144
+ z.object({
145
+ status: z.literal("ok"),
146
+ path: z.string(),
147
+ kind: FileEntryKindSchema,
148
+ }),
149
+ z.object({ status: z.literal("not_found") }),
150
+ z.object({ status: z.literal("not_empty") }),
151
+ z.object({ status: z.literal("error"), message: z.string() }),
152
+ ]);
153
+ export const FileDeleteResponseSchema = z.object({
154
+ type: z.literal("file.delete.response"),
155
+ payload: z.object({
156
+ cwd: z.string(),
157
+ path: z.string(),
158
+ result: FileDeleteResultSchema,
159
+ requestId: z.string(),
160
+ }),
161
+ });
162
+ /** Rename/move outcome. `exists` means the destination was occupied; nothing moved. */
163
+ export const FileRenameResultSchema = z.discriminatedUnion("status", [
164
+ z.object({
165
+ status: z.literal("ok"),
166
+ from: z.string(),
167
+ to: z.string(),
168
+ kind: FileEntryKindSchema,
169
+ }),
170
+ z.object({ status: z.literal("not_found") }),
171
+ z.object({ status: z.literal("exists") }),
172
+ z.object({ status: z.literal("error"), message: z.string() }),
173
+ ]);
174
+ export const FileRenameResponseSchema = z.object({
175
+ type: z.literal("file.rename.response"),
176
+ payload: z.object({
177
+ cwd: z.string(),
178
+ path: z.string(),
179
+ newPath: z.string(),
180
+ result: FileRenameResultSchema,
181
+ requestId: z.string(),
182
+ }),
183
+ });
184
+ export const FileWatchSubscribeResponseSchema = z.object({
185
+ type: z.literal("file.watch.subscribe.response"),
186
+ payload: z.object({
187
+ cwd: z.string(),
188
+ path: z.string(),
189
+ ok: z.boolean(),
190
+ error: z.string().nullable(),
191
+ requestId: z.string(),
192
+ }),
193
+ });
194
+ export const FileWatchUnsubscribeResponseSchema = z.object({
195
+ type: z.literal("file.watch.unsubscribe.response"),
196
+ payload: z.object({
197
+ cwd: z.string(),
198
+ path: z.string(),
199
+ ok: z.boolean(),
200
+ error: z.string().nullable(),
201
+ requestId: z.string(),
202
+ }),
203
+ });
204
+ export const FileSearchMatchSchema = z.object({
205
+ /** 1-based line number. */
206
+ line: z.number().int().positive(),
207
+ /** 1-based character column of the match start within the full line. */
208
+ column: z.number().int().positive(),
209
+ /** Match length in characters. */
210
+ length: z.number().int().nonnegative(),
211
+ /** Display line (possibly truncated around the match). */
212
+ lineText: z.string(),
213
+ /** 0-based offset of the match within lineText. */
214
+ previewStart: z.number().int().nonnegative(),
215
+ });
216
+ // One event per file with matches, streamed while the scan runs.
217
+ export const FileSearchResultEventSchema = z.object({
218
+ type: z.literal("file.search.result"),
219
+ payload: z.object({
220
+ cwd: z.string(),
221
+ searchId: z.string(),
222
+ path: z.string(),
223
+ /** File content hash at match time - the replace precondition. */
224
+ hash: z.string(),
225
+ matches: z.array(FileSearchMatchSchema),
226
+ }),
227
+ });
228
+ export const FileSearchResponseSchema = z.object({
229
+ type: z.literal("file.search.response"),
230
+ payload: z.object({
231
+ cwd: z.string(),
232
+ status: z.enum(["completed", "truncated", "superseded", "error"]),
233
+ error: z.string().nullable(),
234
+ fileCount: z.number(),
235
+ matchCount: z.number(),
236
+ requestId: z.string(),
237
+ }),
238
+ });
239
+ export const FileReplaceFileResultSchema = z.discriminatedUnion("status", [
240
+ z.object({
241
+ status: z.literal("ok"),
242
+ path: z.string(),
243
+ replacedCount: z.number(),
244
+ modifiedAt: z.string(),
245
+ hash: z.string(),
246
+ }),
247
+ // The file changed since the preview; nothing was written to it.
248
+ z.object({
249
+ status: z.literal("skipped"),
250
+ path: z.string(),
251
+ reason: z.string(),
252
+ }),
253
+ z.object({
254
+ status: z.literal("error"),
255
+ path: z.string(),
256
+ message: z.string(),
257
+ }),
258
+ ]);
259
+ export const FileReplaceResponseSchema = z.object({
260
+ type: z.literal("file.replace.response"),
261
+ payload: z.object({
262
+ cwd: z.string(),
263
+ results: z.array(FileReplaceFileResultSchema),
264
+ error: z.string().nullable(),
265
+ requestId: z.string(),
266
+ }),
267
+ });
268
+ // Pushed to subscribers when a watched file changes under the editor. Carries
269
+ // the fresh disk identity (null when the file is gone) so clients can ignore
270
+ // echoes of their own saves; content is re-read on demand.
271
+ export const FileWatchEventSchema = z.object({
272
+ type: z.literal("file.watch.event"),
273
+ payload: z.object({
274
+ cwd: z.string(),
275
+ path: z.string(),
276
+ change: z.enum(["changed", "deleted", "recreated"]),
277
+ modifiedAt: z.string().nullable(),
278
+ hash: z.string().nullable(),
279
+ size: z.number().nullable(),
280
+ }),
281
+ });
282
+ //# sourceMappingURL=file-operations.js.map