@ai-matrx/desktop-protocol 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0
4
+
5
+ fs.patch reports every edit, as the cloud sandbox daemon does (recorded from a live sandbox:
6
+ matrx-desktop `test/fixtures/sandbox-daemon/observed.json`, `patch_cases`).
7
+
8
+ - `FsPatchResult` gains `edits_applied` (`{ edit_index, mode: "create" | "replace" |
9
+ "replace_all", matches_replaced? }`, `matches_replaced` only for replace_all) and `edits_failed`
10
+ (`{ edit_index, reason }`, the daemon's reason text verbatim). `applied` stays (= the count).
11
+ - When every edit fails (CONFLICT, reason `patch_no_match` / `patch_ambiguous`), the error's
12
+ `data.edits_failed` lists them — the daemon's 422 `failures`.
13
+
14
+ Consumer action: none required (additive). Read `edits_failed` instead of reconstructing it from
15
+ `applied`.
16
+
17
+ ## 0.3.0
18
+
19
+ SPEC 6.1 sandbox parity: every search and list op now answers exactly what the cloud sandbox
20
+ daemon answers (fd 8.3.1 / ripgrep 13 run in `cwd`), verified against answers recorded from a live
21
+ sandbox (matrx-desktop `test/fixtures/sandbox-daemon/observed.json`).
22
+
23
+ - `fs.search_content`: `results[].path` is RELATIVE to `cwd` (no `./`), `submatches[].match` is
24
+ ripgrep's `{ text }`, and there is no `truncated` (`max_results` caps matching lines per file,
25
+ as `rg -m`).
26
+ - `fs.search_paths`: `paths` are RELATIVE to `cwd` and prefixed `./` (fd), sorted, cut to
27
+ `max_results`; no `truncated`.
28
+ - `FsEntry` (`fs.stat`, `fs.list` entries) is the daemon's `get_stat_dict` field for field:
29
+ `mtime_ms` and `hidden` are gone (take a write guard from `fs.read`'s `mtime_ms`).
30
+ - `fs.list` defaults are the daemon's behaviour: `limit` 1000, dotfiles listed (`show_hidden`
31
+ true), siblings in byte order of name (`sort` "name"). Page tokens are single-use.
32
+
33
+ Consumer action: join a search path to `cwd` yourself when you need an absolute one; read
34
+ `match.text` instead of `match`; drop any use of `truncated` on search results and of `mtime_ms` /
35
+ `hidden` on entries.
36
+
3
37
  ## 0.2.0
4
38
 
5
39
  The phone console (lane E) needs a client that comes back the instant the person does.
package/dist/client.cjs CHANGED
@@ -125,6 +125,7 @@ var import_zod2 = require("zod");
125
125
  var import_zod = require("zod");
126
126
  var PROTOCOL_MAJOR = 1;
127
127
  var PROTOCOL_MINOR = 0;
128
+ var PROTOCOL_VERSION = `${PROTOCOL_MAJOR}.${PROTOCOL_MINOR}`;
128
129
  var ProtocolVersion = import_zod.z.string().regex(/^[1-9][0-9]{0,2}\.[0-9]{1,3}$/);
129
130
  var RequestId = import_zod.z.string().min(1).max(64).regex(/^[A-Za-z0-9_-]+$/);
130
131
  var ResourceId = import_zod.z.string().regex(/^(pty|watch)_[A-Za-z0-9]{16,40}$/);
@@ -183,6 +184,7 @@ var ErrorReason = import_zod2.z.enum([
183
184
  // another client of the same user took control
184
185
  "window_exhausted"
185
186
  ]);
187
+ var FsPatchEditFailure = import_zod2.z.strictObject({ edit_index: nonNegInt, reason: import_zod2.z.string().max(300) });
186
188
  var ProtocolErrorBody = import_zod2.z.strictObject({
187
189
  code: ErrorCode,
188
190
  message: import_zod2.z.string().max(300),
@@ -197,6 +199,8 @@ var ProtocolErrorBody = import_zod2.z.strictObject({
197
199
  // PERMISSION_DENIED_OS deep link
198
200
  retry_after_ms: nonNegInt.optional(),
199
201
  limit_bytes: nonNegInt.optional(),
202
+ /** fs.patch when every edit failed (CONFLICT, patch_no_match / patch_ambiguous): the daemon's 422 `failures`. */
203
+ edits_failed: import_zod2.z.array(FsPatchEditFailure).max(256).optional(),
200
204
  upgrade: import_zod2.z.strictObject({
201
205
  min_version: ProtocolVersion,
202
206
  max_version: ProtocolVersion,
@@ -396,12 +400,9 @@ var FsEntry = import_zod6.z.strictObject({
396
400
  kind: FsKind,
397
401
  size: nonNegInt,
398
402
  mtime: import_zod6.z.number().min(0),
399
- // seconds, float — daemon parity
400
- mtime_ms: epochMs,
403
+ // seconds, float
401
404
  mode: import_zod6.z.int().min(0).max(4095),
402
- target: AbsPath.nullable(),
403
- // symlink target, never followed
404
- hidden: import_zod6.z.boolean()
405
+ target: AbsPath.nullable()
405
406
  });
406
407
  var FsListParams = import_zod6.z.strictObject({
407
408
  path: AbsPath,
@@ -409,10 +410,12 @@ var FsListParams = import_zod6.z.strictObject({
409
410
  depth: import_zod6.z.int().min(1).max(32).default(1),
410
411
  pattern: import_zod6.z.string().max(256).optional(),
411
412
  // glob on name
412
- limit: import_zod6.z.int().min(1).max(5e3).default(500),
413
+ limit: import_zod6.z.int().min(1).max(5e3).default(1e3),
413
414
  page_token: import_zod6.z.string().max(256).optional(),
414
- show_hidden: import_zod6.z.boolean().default(false),
415
- sort: import_zod6.z.enum(["name", "mtime", "size", "kind"]).default("kind")
415
+ // Desktop additions; their defaults ARE the daemon's behaviour: dotfiles listed, siblings in
416
+ // binary (byte) order of name, depth-first.
417
+ show_hidden: import_zod6.z.boolean().default(true),
418
+ sort: import_zod6.z.enum(["name", "mtime", "size", "kind"]).default("name")
416
419
  });
417
420
  var FsListResult = import_zod6.z.strictObject({
418
421
  entries: import_zod6.z.array(FsEntry),
@@ -489,14 +492,27 @@ var FsPatchParams = import_zod6.z.strictObject({
489
492
  ).min(1).max(256),
490
493
  create_if_missing: import_zod6.z.boolean().default(false)
491
494
  });
492
- var FsPatchResult = import_zod6.z.strictObject({ path: AbsPath, applied: nonNegInt, size: nonNegInt, mtime_ms: epochMs });
495
+ var FsPatchEditApplied = import_zod6.z.strictObject({
496
+ edit_index: nonNegInt,
497
+ mode: import_zod6.z.enum(["create", "replace", "replace_all"]),
498
+ /** Present for replace_all only, as the daemon sends it. */
499
+ matches_replaced: nonNegInt.optional()
500
+ });
501
+ var FsPatchResult = import_zod6.z.strictObject({
502
+ path: AbsPath,
503
+ applied: nonNegInt,
504
+ size: nonNegInt,
505
+ mtime_ms: epochMs,
506
+ edits_applied: import_zod6.z.array(FsPatchEditApplied).max(256),
507
+ edits_failed: import_zod6.z.array(FsPatchEditFailure).max(256)
508
+ });
493
509
  var FsSearchPathsParams = import_zod6.z.strictObject({
494
510
  pattern: import_zod6.z.string().min(1).max(512),
495
511
  cwd: AbsPath,
496
512
  hidden: import_zod6.z.boolean().default(false),
497
513
  max_results: import_zod6.z.int().min(1).max(5e3).default(100)
498
514
  });
499
- var FsSearchPathsResult = import_zod6.z.strictObject({ paths: import_zod6.z.array(AbsPath), truncated: import_zod6.z.boolean() });
515
+ var FsSearchPathsResult = import_zod6.z.strictObject({ paths: import_zod6.z.array(import_zod6.z.string().min(3).max(4096).regex(/^\.\/[^\\\u0000]+$/)) });
500
516
  var FsSearchContentParams = import_zod6.z.strictObject({
501
517
  query: import_zod6.z.string().min(1).max(1024),
502
518
  cwd: AbsPath,
@@ -509,13 +525,14 @@ var FsSearchContentParams = import_zod6.z.strictObject({
509
525
  var FsSearchContentResult = import_zod6.z.strictObject({
510
526
  results: import_zod6.z.array(
511
527
  import_zod6.z.strictObject({
512
- path: AbsPath,
528
+ path: import_zod6.z.string().min(1).max(4096).regex(/^[^/\\\u0000][^\\\u0000]*$/),
513
529
  lines: import_zod6.z.string(),
514
530
  line_number: import_zod6.z.int().min(1),
515
- submatches: import_zod6.z.array(import_zod6.z.strictObject({ match: import_zod6.z.string(), start: nonNegInt, end: nonNegInt }))
531
+ submatches: import_zod6.z.array(
532
+ import_zod6.z.strictObject({ match: import_zod6.z.strictObject({ text: import_zod6.z.string() }), start: nonNegInt, end: nonNegInt })
533
+ )
516
534
  })
517
- ),
518
- truncated: import_zod6.z.boolean()
535
+ )
519
536
  });
520
537
  var FsChange = import_zod6.z.strictObject({
521
538
  type: import_zod6.z.enum(["created", "modified", "deleted", "moved"]),