@yefengr/pi-reach 0.0.6 → 0.0.7

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 (45) hide show
  1. package/dist/files/content-type.d.ts +16 -0
  2. package/dist/files/content-type.js +98 -0
  3. package/dist/files/content-type.js.map +1 -0
  4. package/dist/files/image-structure.d.ts +21 -0
  5. package/dist/files/image-structure.js +269 -0
  6. package/dist/files/image-structure.js.map +1 -0
  7. package/dist/files/publications.d.ts +26 -0
  8. package/dist/files/publications.js +136 -0
  9. package/dist/files/publications.js.map +1 -0
  10. package/dist/files/publish-tool.d.ts +23 -0
  11. package/dist/files/publish-tool.js +70 -0
  12. package/dist/files/publish-tool.js.map +1 -0
  13. package/dist/files/reader.d.ts +66 -0
  14. package/dist/files/reader.js +416 -0
  15. package/dist/files/reader.js.map +1 -0
  16. package/dist/files/safe-open.d.ts +22 -0
  17. package/dist/files/safe-open.js +119 -0
  18. package/dist/files/safe-open.js.map +1 -0
  19. package/dist/index.js +12 -17
  20. package/dist/index.js.map +1 -1
  21. package/dist/runtime/file_binding.d.ts +25 -0
  22. package/dist/runtime/file_binding.js +49 -0
  23. package/dist/runtime/file_binding.js.map +1 -0
  24. package/dist/runtime/session_frame_router.d.ts +11 -0
  25. package/dist/runtime/session_frame_router.js +25 -0
  26. package/dist/runtime/session_frame_router.js.map +1 -0
  27. package/dist/timeline/runtime.d.ts +1 -1
  28. package/dist/timeline/runtime.js +26 -54
  29. package/dist/timeline/runtime.js.map +1 -1
  30. package/dist/timeline/system_event.d.ts +7 -0
  31. package/dist/timeline/system_event.js +58 -0
  32. package/dist/timeline/system_event.js.map +1 -0
  33. package/dist/timeline/tool_lifecycle.js +8 -2
  34. package/dist/timeline/tool_lifecycle.js.map +1 -1
  35. package/dist/timeline/v2_service.js +3 -0
  36. package/dist/timeline/v2_service.js.map +1 -1
  37. package/dist/vendor/protocol/session/files.d.ts +83 -0
  38. package/dist/vendor/protocol/session/files.js +162 -0
  39. package/dist/vendor/protocol/session/frames.d.ts +293 -18
  40. package/dist/vendor/protocol/session/frames.js +52 -2
  41. package/dist/vendor/protocol/session/index.d.ts +1 -0
  42. package/dist/vendor/protocol/session/index.js +1 -0
  43. package/dist/vendor/protocol/session/schema.d.ts +2 -2
  44. package/dist/vendor/protocol/session/schema.js +2 -0
  45. package/package.json +2 -2
@@ -243,6 +243,31 @@ export declare const attachmentDiscardFrameSchema: z.ZodObject<{
243
243
  type: z.ZodLiteral<"attachment_discard">;
244
244
  id: z.ZodString;
245
245
  }, z.core.$strict>;
246
+ export declare const fileOpenFrameSchema: z.ZodObject<{
247
+ type: z.ZodLiteral<"file_open">;
248
+ id: z.ZodString;
249
+ publication_id: z.ZodString;
250
+ channel_id: z.ZodString;
251
+ session_id: z.ZodString;
252
+ protocol_version: z.ZodLiteral<2>;
253
+ }, z.core.$strict>;
254
+ export declare const fileReadFrameSchema: z.ZodObject<{
255
+ type: z.ZodLiteral<"file_read">;
256
+ id: z.ZodString;
257
+ transfer_id: z.ZodString;
258
+ offset: z.ZodNumber;
259
+ channel_id: z.ZodString;
260
+ session_id: z.ZodString;
261
+ protocol_version: z.ZodLiteral<2>;
262
+ }, z.core.$strict>;
263
+ export declare const fileCloseFrameSchema: z.ZodObject<{
264
+ type: z.ZodLiteral<"file_close">;
265
+ id: z.ZodString;
266
+ transfer_id: z.ZodString;
267
+ channel_id: z.ZodString;
268
+ session_id: z.ZodString;
269
+ protocol_version: z.ZodLiteral<2>;
270
+ }, z.core.$strict>;
246
271
  export declare const pairOkFrameSchema: z.ZodObject<{
247
272
  type: z.ZodLiteral<"pair_ok">;
248
273
  in_reply_to: z.ZodString;
@@ -1459,6 +1484,7 @@ export declare const protocolErrorFrameSchema: z.ZodUnion<readonly [z.ZodObject<
1459
1484
  type: z.ZodLiteral<"protocol_error">;
1460
1485
  in_reply_to: z.ZodOptional<z.ZodString>;
1461
1486
  code: z.ZodEnum<{
1487
+ too_large: "too_large";
1462
1488
  internal_error: "internal_error";
1463
1489
  protocol_upgrade_required: "protocol_upgrade_required";
1464
1490
  invalid_message: "invalid_message";
@@ -1467,7 +1493,6 @@ export declare const protocolErrorFrameSchema: z.ZodUnion<readonly [z.ZodObject<
1467
1493
  invalid_leaf: "invalid_leaf";
1468
1494
  invalid_cursor: "invalid_cursor";
1469
1495
  reset_required: "reset_required";
1470
- too_large: "too_large";
1471
1496
  }>;
1472
1497
  message: z.ZodString;
1473
1498
  protocol_version: z.ZodLiteral<2>;
@@ -1475,6 +1500,7 @@ export declare const protocolErrorFrameSchema: z.ZodUnion<readonly [z.ZodObject<
1475
1500
  type: z.ZodLiteral<"protocol_error">;
1476
1501
  in_reply_to: z.ZodOptional<z.ZodString>;
1477
1502
  code: z.ZodEnum<{
1503
+ too_large: "too_large";
1478
1504
  internal_error: "internal_error";
1479
1505
  protocol_upgrade_required: "protocol_upgrade_required";
1480
1506
  invalid_message: "invalid_message";
@@ -1483,7 +1509,6 @@ export declare const protocolErrorFrameSchema: z.ZodUnion<readonly [z.ZodObject<
1483
1509
  invalid_leaf: "invalid_leaf";
1484
1510
  invalid_cursor: "invalid_cursor";
1485
1511
  reset_required: "reset_required";
1486
- too_large: "too_large";
1487
1512
  }>;
1488
1513
  message: z.ZodString;
1489
1514
  protocol_version: z.ZodLiteral<2>;
@@ -1652,14 +1677,14 @@ export declare const attachmentStateFrameSchema: z.ZodUnion<readonly [z.ZodObjec
1652
1677
  export declare const attachmentErrorCodeSchema: z.ZodEnum<{
1653
1678
  cancelled: "cancelled";
1654
1679
  too_large: "too_large";
1680
+ offset_mismatch: "offset_mismatch";
1681
+ busy: "busy";
1682
+ io_error: "io_error";
1655
1683
  invalid_scope: "invalid_scope";
1656
1684
  not_found: "not_found";
1657
1685
  invalid_upload: "invalid_upload";
1658
- busy: "busy";
1659
1686
  no_space: "no_space";
1660
- io_error: "io_error";
1661
1687
  integrity_mismatch: "integrity_mismatch";
1662
- offset_mismatch: "offset_mismatch";
1663
1688
  }>;
1664
1689
  export declare const attachmentDiscardedFrameSchema: z.ZodObject<{
1665
1690
  type: z.ZodLiteral<"attachment_discarded">;
@@ -1681,14 +1706,14 @@ export declare const attachmentErrorFrameSchema: z.ZodObject<{
1681
1706
  code: z.ZodEnum<{
1682
1707
  cancelled: "cancelled";
1683
1708
  too_large: "too_large";
1709
+ offset_mismatch: "offset_mismatch";
1710
+ busy: "busy";
1711
+ io_error: "io_error";
1684
1712
  invalid_scope: "invalid_scope";
1685
1713
  not_found: "not_found";
1686
1714
  invalid_upload: "invalid_upload";
1687
- busy: "busy";
1688
1715
  no_space: "no_space";
1689
- io_error: "io_error";
1690
1716
  integrity_mismatch: "integrity_mismatch";
1691
- offset_mismatch: "offset_mismatch";
1692
1717
  }>;
1693
1718
  retryable: z.ZodBoolean;
1694
1719
  in_reply_to: z.ZodString;
@@ -1697,6 +1722,78 @@ export declare const attachmentErrorFrameSchema: z.ZodObject<{
1697
1722
  target_channel_id: z.ZodString;
1698
1723
  protocol_version: z.ZodLiteral<2>;
1699
1724
  }, z.core.$strict>;
1725
+ export declare const fileOpenedFrameSchema: z.ZodObject<{
1726
+ type: z.ZodLiteral<"file_opened">;
1727
+ publication_id: z.ZodString;
1728
+ transfer_id: z.ZodString;
1729
+ file_name: z.ZodString;
1730
+ mime_type: z.ZodString;
1731
+ byte_length: z.ZodNumber;
1732
+ preview: z.ZodUnion<readonly [z.ZodObject<{
1733
+ kind: z.ZodLiteral<"image">;
1734
+ width: z.ZodNumber;
1735
+ height: z.ZodNumber;
1736
+ }, z.core.$strict>, z.ZodObject<{
1737
+ kind: z.ZodLiteral<"text">;
1738
+ }, z.core.$strict>, z.ZodObject<{
1739
+ kind: z.ZodLiteral<"none">;
1740
+ }, z.core.$strict>]>;
1741
+ in_reply_to: z.ZodString;
1742
+ session_id: z.ZodString;
1743
+ target_channel_id: z.ZodString;
1744
+ protocol_version: z.ZodLiteral<2>;
1745
+ }, z.core.$strict>;
1746
+ /** Final chunks carry the transfer digest; only a zero-length file has an empty final chunk. */
1747
+ export declare const fileChunkFrameSchema: z.ZodUnion<readonly [z.ZodObject<{
1748
+ data_base64: z.ZodString;
1749
+ final: z.ZodLiteral<false>;
1750
+ type: z.ZodLiteral<"file_chunk">;
1751
+ transfer_id: z.ZodString;
1752
+ offset: z.ZodNumber;
1753
+ in_reply_to: z.ZodString;
1754
+ session_id: z.ZodString;
1755
+ target_channel_id: z.ZodString;
1756
+ protocol_version: z.ZodLiteral<2>;
1757
+ }, z.core.$strict>, z.ZodObject<{
1758
+ data_base64: z.ZodString;
1759
+ final: z.ZodLiteral<true>;
1760
+ total_bytes: z.ZodNumber;
1761
+ sha256: z.ZodString;
1762
+ type: z.ZodLiteral<"file_chunk">;
1763
+ transfer_id: z.ZodString;
1764
+ offset: z.ZodNumber;
1765
+ in_reply_to: z.ZodString;
1766
+ session_id: z.ZodString;
1767
+ target_channel_id: z.ZodString;
1768
+ protocol_version: z.ZodLiteral<2>;
1769
+ }, z.core.$strict>]>;
1770
+ export declare const fileClosedFrameSchema: z.ZodObject<{
1771
+ type: z.ZodLiteral<"file_closed">;
1772
+ transfer_id: z.ZodString;
1773
+ in_reply_to: z.ZodString;
1774
+ session_id: z.ZodString;
1775
+ target_channel_id: z.ZodString;
1776
+ protocol_version: z.ZodLiteral<2>;
1777
+ }, z.core.$strict>;
1778
+ export declare const fileErrorFrameSchema: z.ZodObject<{
1779
+ type: z.ZodLiteral<"file_error">;
1780
+ transfer_id: z.ZodOptional<z.ZodString>;
1781
+ code: z.ZodEnum<{
1782
+ not_available: "not_available";
1783
+ permission_denied: "permission_denied";
1784
+ not_regular_file: "not_regular_file";
1785
+ too_large: "too_large";
1786
+ file_changed: "file_changed";
1787
+ invalid_transfer: "invalid_transfer";
1788
+ offset_mismatch: "offset_mismatch";
1789
+ busy: "busy";
1790
+ io_error: "io_error";
1791
+ }>;
1792
+ in_reply_to: z.ZodString;
1793
+ session_id: z.ZodString;
1794
+ target_channel_id: z.ZodString;
1795
+ protocol_version: z.ZodLiteral<2>;
1796
+ }, z.core.$strict>;
1700
1797
  export declare const clientFrameSchema: z.ZodUnion<readonly [z.ZodObject<{
1701
1798
  type: z.ZodLiteral<"pair_request">;
1702
1799
  id: z.ZodString;
@@ -1916,6 +2013,28 @@ export declare const clientFrameSchema: z.ZodUnion<readonly [z.ZodObject<{
1916
2013
  protocol_version: z.ZodLiteral<2>;
1917
2014
  type: z.ZodLiteral<"attachment_discard">;
1918
2015
  id: z.ZodString;
2016
+ }, z.core.$strict>, z.ZodObject<{
2017
+ type: z.ZodLiteral<"file_open">;
2018
+ id: z.ZodString;
2019
+ publication_id: z.ZodString;
2020
+ channel_id: z.ZodString;
2021
+ session_id: z.ZodString;
2022
+ protocol_version: z.ZodLiteral<2>;
2023
+ }, z.core.$strict>, z.ZodObject<{
2024
+ type: z.ZodLiteral<"file_read">;
2025
+ id: z.ZodString;
2026
+ transfer_id: z.ZodString;
2027
+ offset: z.ZodNumber;
2028
+ channel_id: z.ZodString;
2029
+ session_id: z.ZodString;
2030
+ protocol_version: z.ZodLiteral<2>;
2031
+ }, z.core.$strict>, z.ZodObject<{
2032
+ type: z.ZodLiteral<"file_close">;
2033
+ id: z.ZodString;
2034
+ transfer_id: z.ZodString;
2035
+ channel_id: z.ZodString;
2036
+ session_id: z.ZodString;
2037
+ protocol_version: z.ZodLiteral<2>;
1919
2038
  }, z.core.$strict>]>;
1920
2039
  export declare const serverFrameSchema: z.ZodUnion<readonly [z.ZodObject<{
1921
2040
  type: z.ZodLiteral<"pair_ok">;
@@ -3123,6 +3242,7 @@ export declare const serverFrameSchema: z.ZodUnion<readonly [z.ZodObject<{
3123
3242
  type: z.ZodLiteral<"protocol_error">;
3124
3243
  in_reply_to: z.ZodOptional<z.ZodString>;
3125
3244
  code: z.ZodEnum<{
3245
+ too_large: "too_large";
3126
3246
  internal_error: "internal_error";
3127
3247
  protocol_upgrade_required: "protocol_upgrade_required";
3128
3248
  invalid_message: "invalid_message";
@@ -3131,7 +3251,6 @@ export declare const serverFrameSchema: z.ZodUnion<readonly [z.ZodObject<{
3131
3251
  invalid_leaf: "invalid_leaf";
3132
3252
  invalid_cursor: "invalid_cursor";
3133
3253
  reset_required: "reset_required";
3134
- too_large: "too_large";
3135
3254
  }>;
3136
3255
  message: z.ZodString;
3137
3256
  protocol_version: z.ZodLiteral<2>;
@@ -3139,6 +3258,7 @@ export declare const serverFrameSchema: z.ZodUnion<readonly [z.ZodObject<{
3139
3258
  type: z.ZodLiteral<"protocol_error">;
3140
3259
  in_reply_to: z.ZodOptional<z.ZodString>;
3141
3260
  code: z.ZodEnum<{
3261
+ too_large: "too_large";
3142
3262
  internal_error: "internal_error";
3143
3263
  protocol_upgrade_required: "protocol_upgrade_required";
3144
3264
  invalid_message: "invalid_message";
@@ -3147,7 +3267,6 @@ export declare const serverFrameSchema: z.ZodUnion<readonly [z.ZodObject<{
3147
3267
  invalid_leaf: "invalid_leaf";
3148
3268
  invalid_cursor: "invalid_cursor";
3149
3269
  reset_required: "reset_required";
3150
- too_large: "too_large";
3151
3270
  }>;
3152
3271
  message: z.ZodString;
3153
3272
  protocol_version: z.ZodLiteral<2>;
@@ -3309,14 +3428,14 @@ export declare const serverFrameSchema: z.ZodUnion<readonly [z.ZodObject<{
3309
3428
  code: z.ZodEnum<{
3310
3429
  cancelled: "cancelled";
3311
3430
  too_large: "too_large";
3431
+ offset_mismatch: "offset_mismatch";
3432
+ busy: "busy";
3433
+ io_error: "io_error";
3312
3434
  invalid_scope: "invalid_scope";
3313
3435
  not_found: "not_found";
3314
3436
  invalid_upload: "invalid_upload";
3315
- busy: "busy";
3316
3437
  no_space: "no_space";
3317
- io_error: "io_error";
3318
3438
  integrity_mismatch: "integrity_mismatch";
3319
- offset_mismatch: "offset_mismatch";
3320
3439
  }>;
3321
3440
  retryable: z.ZodBoolean;
3322
3441
  in_reply_to: z.ZodString;
@@ -3336,6 +3455,73 @@ export declare const serverFrameSchema: z.ZodUnion<readonly [z.ZodObject<{
3336
3455
  upload_scope: z.ZodString;
3337
3456
  target_channel_id: z.ZodString;
3338
3457
  protocol_version: z.ZodLiteral<2>;
3458
+ }, z.core.$strict>, z.ZodObject<{
3459
+ type: z.ZodLiteral<"file_opened">;
3460
+ publication_id: z.ZodString;
3461
+ transfer_id: z.ZodString;
3462
+ file_name: z.ZodString;
3463
+ mime_type: z.ZodString;
3464
+ byte_length: z.ZodNumber;
3465
+ preview: z.ZodUnion<readonly [z.ZodObject<{
3466
+ kind: z.ZodLiteral<"image">;
3467
+ width: z.ZodNumber;
3468
+ height: z.ZodNumber;
3469
+ }, z.core.$strict>, z.ZodObject<{
3470
+ kind: z.ZodLiteral<"text">;
3471
+ }, z.core.$strict>, z.ZodObject<{
3472
+ kind: z.ZodLiteral<"none">;
3473
+ }, z.core.$strict>]>;
3474
+ in_reply_to: z.ZodString;
3475
+ session_id: z.ZodString;
3476
+ target_channel_id: z.ZodString;
3477
+ protocol_version: z.ZodLiteral<2>;
3478
+ }, z.core.$strict>, z.ZodUnion<readonly [z.ZodObject<{
3479
+ data_base64: z.ZodString;
3480
+ final: z.ZodLiteral<false>;
3481
+ type: z.ZodLiteral<"file_chunk">;
3482
+ transfer_id: z.ZodString;
3483
+ offset: z.ZodNumber;
3484
+ in_reply_to: z.ZodString;
3485
+ session_id: z.ZodString;
3486
+ target_channel_id: z.ZodString;
3487
+ protocol_version: z.ZodLiteral<2>;
3488
+ }, z.core.$strict>, z.ZodObject<{
3489
+ data_base64: z.ZodString;
3490
+ final: z.ZodLiteral<true>;
3491
+ total_bytes: z.ZodNumber;
3492
+ sha256: z.ZodString;
3493
+ type: z.ZodLiteral<"file_chunk">;
3494
+ transfer_id: z.ZodString;
3495
+ offset: z.ZodNumber;
3496
+ in_reply_to: z.ZodString;
3497
+ session_id: z.ZodString;
3498
+ target_channel_id: z.ZodString;
3499
+ protocol_version: z.ZodLiteral<2>;
3500
+ }, z.core.$strict>]>, z.ZodObject<{
3501
+ type: z.ZodLiteral<"file_closed">;
3502
+ transfer_id: z.ZodString;
3503
+ in_reply_to: z.ZodString;
3504
+ session_id: z.ZodString;
3505
+ target_channel_id: z.ZodString;
3506
+ protocol_version: z.ZodLiteral<2>;
3507
+ }, z.core.$strict>, z.ZodObject<{
3508
+ type: z.ZodLiteral<"file_error">;
3509
+ transfer_id: z.ZodOptional<z.ZodString>;
3510
+ code: z.ZodEnum<{
3511
+ not_available: "not_available";
3512
+ permission_denied: "permission_denied";
3513
+ not_regular_file: "not_regular_file";
3514
+ too_large: "too_large";
3515
+ file_changed: "file_changed";
3516
+ invalid_transfer: "invalid_transfer";
3517
+ offset_mismatch: "offset_mismatch";
3518
+ busy: "busy";
3519
+ io_error: "io_error";
3520
+ }>;
3521
+ in_reply_to: z.ZodString;
3522
+ session_id: z.ZodString;
3523
+ target_channel_id: z.ZodString;
3524
+ protocol_version: z.ZodLiteral<2>;
3339
3525
  }, z.core.$strict>]>;
3340
3526
  export declare const ClientFrameSchema: z.ZodUnion<readonly [z.ZodObject<{
3341
3527
  type: z.ZodLiteral<"pair_request">;
@@ -3556,6 +3742,28 @@ export declare const ClientFrameSchema: z.ZodUnion<readonly [z.ZodObject<{
3556
3742
  protocol_version: z.ZodLiteral<2>;
3557
3743
  type: z.ZodLiteral<"attachment_discard">;
3558
3744
  id: z.ZodString;
3745
+ }, z.core.$strict>, z.ZodObject<{
3746
+ type: z.ZodLiteral<"file_open">;
3747
+ id: z.ZodString;
3748
+ publication_id: z.ZodString;
3749
+ channel_id: z.ZodString;
3750
+ session_id: z.ZodString;
3751
+ protocol_version: z.ZodLiteral<2>;
3752
+ }, z.core.$strict>, z.ZodObject<{
3753
+ type: z.ZodLiteral<"file_read">;
3754
+ id: z.ZodString;
3755
+ transfer_id: z.ZodString;
3756
+ offset: z.ZodNumber;
3757
+ channel_id: z.ZodString;
3758
+ session_id: z.ZodString;
3759
+ protocol_version: z.ZodLiteral<2>;
3760
+ }, z.core.$strict>, z.ZodObject<{
3761
+ type: z.ZodLiteral<"file_close">;
3762
+ id: z.ZodString;
3763
+ transfer_id: z.ZodString;
3764
+ channel_id: z.ZodString;
3765
+ session_id: z.ZodString;
3766
+ protocol_version: z.ZodLiteral<2>;
3559
3767
  }, z.core.$strict>]>;
3560
3768
  export declare const ServerFrameSchema: z.ZodUnion<readonly [z.ZodObject<{
3561
3769
  type: z.ZodLiteral<"pair_ok">;
@@ -4763,6 +4971,7 @@ export declare const ServerFrameSchema: z.ZodUnion<readonly [z.ZodObject<{
4763
4971
  type: z.ZodLiteral<"protocol_error">;
4764
4972
  in_reply_to: z.ZodOptional<z.ZodString>;
4765
4973
  code: z.ZodEnum<{
4974
+ too_large: "too_large";
4766
4975
  internal_error: "internal_error";
4767
4976
  protocol_upgrade_required: "protocol_upgrade_required";
4768
4977
  invalid_message: "invalid_message";
@@ -4771,7 +4980,6 @@ export declare const ServerFrameSchema: z.ZodUnion<readonly [z.ZodObject<{
4771
4980
  invalid_leaf: "invalid_leaf";
4772
4981
  invalid_cursor: "invalid_cursor";
4773
4982
  reset_required: "reset_required";
4774
- too_large: "too_large";
4775
4983
  }>;
4776
4984
  message: z.ZodString;
4777
4985
  protocol_version: z.ZodLiteral<2>;
@@ -4779,6 +4987,7 @@ export declare const ServerFrameSchema: z.ZodUnion<readonly [z.ZodObject<{
4779
4987
  type: z.ZodLiteral<"protocol_error">;
4780
4988
  in_reply_to: z.ZodOptional<z.ZodString>;
4781
4989
  code: z.ZodEnum<{
4990
+ too_large: "too_large";
4782
4991
  internal_error: "internal_error";
4783
4992
  protocol_upgrade_required: "protocol_upgrade_required";
4784
4993
  invalid_message: "invalid_message";
@@ -4787,7 +4996,6 @@ export declare const ServerFrameSchema: z.ZodUnion<readonly [z.ZodObject<{
4787
4996
  invalid_leaf: "invalid_leaf";
4788
4997
  invalid_cursor: "invalid_cursor";
4789
4998
  reset_required: "reset_required";
4790
- too_large: "too_large";
4791
4999
  }>;
4792
5000
  message: z.ZodString;
4793
5001
  protocol_version: z.ZodLiteral<2>;
@@ -4949,14 +5157,14 @@ export declare const ServerFrameSchema: z.ZodUnion<readonly [z.ZodObject<{
4949
5157
  code: z.ZodEnum<{
4950
5158
  cancelled: "cancelled";
4951
5159
  too_large: "too_large";
5160
+ offset_mismatch: "offset_mismatch";
5161
+ busy: "busy";
5162
+ io_error: "io_error";
4952
5163
  invalid_scope: "invalid_scope";
4953
5164
  not_found: "not_found";
4954
5165
  invalid_upload: "invalid_upload";
4955
- busy: "busy";
4956
5166
  no_space: "no_space";
4957
- io_error: "io_error";
4958
5167
  integrity_mismatch: "integrity_mismatch";
4959
- offset_mismatch: "offset_mismatch";
4960
5168
  }>;
4961
5169
  retryable: z.ZodBoolean;
4962
5170
  in_reply_to: z.ZodString;
@@ -4976,6 +5184,73 @@ export declare const ServerFrameSchema: z.ZodUnion<readonly [z.ZodObject<{
4976
5184
  upload_scope: z.ZodString;
4977
5185
  target_channel_id: z.ZodString;
4978
5186
  protocol_version: z.ZodLiteral<2>;
5187
+ }, z.core.$strict>, z.ZodObject<{
5188
+ type: z.ZodLiteral<"file_opened">;
5189
+ publication_id: z.ZodString;
5190
+ transfer_id: z.ZodString;
5191
+ file_name: z.ZodString;
5192
+ mime_type: z.ZodString;
5193
+ byte_length: z.ZodNumber;
5194
+ preview: z.ZodUnion<readonly [z.ZodObject<{
5195
+ kind: z.ZodLiteral<"image">;
5196
+ width: z.ZodNumber;
5197
+ height: z.ZodNumber;
5198
+ }, z.core.$strict>, z.ZodObject<{
5199
+ kind: z.ZodLiteral<"text">;
5200
+ }, z.core.$strict>, z.ZodObject<{
5201
+ kind: z.ZodLiteral<"none">;
5202
+ }, z.core.$strict>]>;
5203
+ in_reply_to: z.ZodString;
5204
+ session_id: z.ZodString;
5205
+ target_channel_id: z.ZodString;
5206
+ protocol_version: z.ZodLiteral<2>;
5207
+ }, z.core.$strict>, z.ZodUnion<readonly [z.ZodObject<{
5208
+ data_base64: z.ZodString;
5209
+ final: z.ZodLiteral<false>;
5210
+ type: z.ZodLiteral<"file_chunk">;
5211
+ transfer_id: z.ZodString;
5212
+ offset: z.ZodNumber;
5213
+ in_reply_to: z.ZodString;
5214
+ session_id: z.ZodString;
5215
+ target_channel_id: z.ZodString;
5216
+ protocol_version: z.ZodLiteral<2>;
5217
+ }, z.core.$strict>, z.ZodObject<{
5218
+ data_base64: z.ZodString;
5219
+ final: z.ZodLiteral<true>;
5220
+ total_bytes: z.ZodNumber;
5221
+ sha256: z.ZodString;
5222
+ type: z.ZodLiteral<"file_chunk">;
5223
+ transfer_id: z.ZodString;
5224
+ offset: z.ZodNumber;
5225
+ in_reply_to: z.ZodString;
5226
+ session_id: z.ZodString;
5227
+ target_channel_id: z.ZodString;
5228
+ protocol_version: z.ZodLiteral<2>;
5229
+ }, z.core.$strict>]>, z.ZodObject<{
5230
+ type: z.ZodLiteral<"file_closed">;
5231
+ transfer_id: z.ZodString;
5232
+ in_reply_to: z.ZodString;
5233
+ session_id: z.ZodString;
5234
+ target_channel_id: z.ZodString;
5235
+ protocol_version: z.ZodLiteral<2>;
5236
+ }, z.core.$strict>, z.ZodObject<{
5237
+ type: z.ZodLiteral<"file_error">;
5238
+ transfer_id: z.ZodOptional<z.ZodString>;
5239
+ code: z.ZodEnum<{
5240
+ not_available: "not_available";
5241
+ permission_denied: "permission_denied";
5242
+ not_regular_file: "not_regular_file";
5243
+ too_large: "too_large";
5244
+ file_changed: "file_changed";
5245
+ invalid_transfer: "invalid_transfer";
5246
+ offset_mismatch: "offset_mismatch";
5247
+ busy: "busy";
5248
+ io_error: "io_error";
5249
+ }>;
5250
+ in_reply_to: z.ZodString;
5251
+ session_id: z.ZodString;
5252
+ target_channel_id: z.ZodString;
5253
+ protocol_version: z.ZodLiteral<2>;
4979
5254
  }, z.core.$strict>]>;
4980
5255
  export declare const SessionHistoryChunkSchema: z.ZodUnion<readonly [z.ZodObject<{
4981
5256
  final_chunk: z.ZodLiteral<false>;
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { actionNameSchema, byeReasonSchema, channelIdSchema, harnessSchema, leafIdSchema, headSequenceSchema, idSchema, MAX_ARRAY_ITEMS, imageMimeSchema, pairingCodeSchema, protocolVersionSchema, eventSequenceSchema, sequencedTimelineEventSchema, timelineEventFragmentSchema, timelinePartialSchema, thinkingLevelSchema, queuedMessageItemSchema, timestampSchema, userBlockSchema, wireImageSchema, wireModelSchema, CLIENT_FRAME_TYPES, SERVER_FRAME_TYPES, strictObject, textSchema, } from "./schema.js";
3
3
  import { ATTACHMENT_CHUNK_BYTES, ATTACHMENT_MAX_COUNT, ATTACHMENT_MAX_FILE_BYTES, ATTACHMENT_MAX_IN_FLIGHT, ATTACHMENT_MAX_MESSAGE_BYTES, attachmentByteLengthSchema, attachmentChunkDataSchema, attachmentDescriptorSchema, attachmentFileNameSchema, attachmentIdsSchema, attachmentPreviewSchema, attachmentSha256Schema, } from "./attachments.js";
4
+ import { FILE_MAX_BYTES, canonicalBase64ByteLength, fileByteLengthSchema, fileChunkDataSchema, fileErrorCodeSchema, fileFileNameSchema, fileMimeSchema, fileOffsetSchema, filePreviewSchema, fileSha256Schema, } from "./files.js";
4
5
  const wireTimelineEventSchema = sequencedTimelineEventSchema;
5
6
  const protocol = { protocol_version: protocolVersionSchema };
6
7
  const channelRequest = { ...protocol, channel_id: channelIdSchema, session_id: idSchema, leaf_id: leafIdSchema };
@@ -8,6 +9,9 @@ const directResponse = { ...protocol, target_channel_id: channelIdSchema };
8
9
  const ownerBroadcast = { ...protocol, session_id: idSchema, leaf_id: leafIdSchema };
9
10
  const attachmentUploadRequest = { ...protocol, channel_id: channelIdSchema, session_id: idSchema, upload_scope: idSchema };
10
11
  const attachmentUploadResponse = { ...directResponse, in_reply_to: idSchema, session_id: idSchema, upload_scope: idSchema };
12
+ // Published-file reads are scoped to channel/session only: they never carry leaf or upload_scope.
13
+ const fileChannelRequest = { ...protocol, channel_id: channelIdSchema, session_id: idSchema };
14
+ const fileResponse = { ...directResponse, in_reply_to: idSchema, session_id: idSchema };
11
15
  const safeOffsetSchema = z.number().int().nonnegative().finite().max(Number.MAX_SAFE_INTEGER);
12
16
  export const pairRequestFrameSchema = strictObject({ ...protocol, type: z.literal("pair_request"), id: idSchema, code: pairingCodeSchema, device_name: textSchema });
13
17
  export const sessionHelloFrameSchema = strictObject({ ...protocol, type: z.literal("session_hello"), id: idSchema, channel_id: channelIdSchema });
@@ -37,6 +41,9 @@ export const attachmentFinishFrameSchema = strictObject({ ...protocol, type: z.l
37
41
  export const attachmentStatusRequestFrameSchema = strictObject({ ...protocol, type: z.literal("attachment_status_request"), id: idSchema, ...attachmentUploadRequest, upload_id: idSchema });
38
42
  export const attachmentCancelFrameSchema = strictObject({ ...protocol, type: z.literal("attachment_cancel"), id: idSchema, ...attachmentUploadRequest, upload_id: idSchema });
39
43
  export const attachmentDiscardFrameSchema = strictObject({ ...protocol, type: z.literal("attachment_discard"), id: idSchema, ...attachmentUploadRequest, attachment_id: idSchema });
44
+ export const fileOpenFrameSchema = strictObject({ ...fileChannelRequest, type: z.literal("file_open"), id: idSchema, publication_id: idSchema });
45
+ export const fileReadFrameSchema = strictObject({ ...fileChannelRequest, type: z.literal("file_read"), id: idSchema, transfer_id: idSchema, offset: fileOffsetSchema });
46
+ export const fileCloseFrameSchema = strictObject({ ...fileChannelRequest, type: z.literal("file_close"), id: idSchema, transfer_id: idSchema });
40
47
  export const pairOkFrameSchema = strictObject({ ...protocol, type: z.literal("pair_ok"), in_reply_to: idSchema, session_name: textSchema, session_started_at: timestampSchema, endpoint_id: idSchema, harness: harnessSchema.optional(), hostname: textSchema.optional() });
41
48
  export const pairErrorFrameSchema = strictObject({ ...protocol, type: z.literal("pair_error"), in_reply_to: idSchema, code: z.enum(["token_expired", "token_consumed", "token_unknown", "internal_error"]), message: textSchema.min(1) });
42
49
  export const sessionReadyFrameSchema = strictObject({ ...directResponse, type: z.literal("session_ready"), in_reply_to: idSchema, session_id: idSchema, leaf_id: leafIdSchema, head_seq: headSequenceSchema, self_sender_ref: idSchema });
@@ -107,8 +114,51 @@ export const attachmentErrorFrameSchema = strictObject({ ...attachmentUploadResp
107
114
  ctx.addIssue({ code: "custom", path: ["attachment_id"], message: "upload_id and attachment_id are mutually exclusive" });
108
115
  }
109
116
  });
110
- export const clientFrameSchema = z.union([pairRequestFrameSchema, sessionHelloFrameSchema, extensionInfoRequestFrameSchema, userMessageFrameSchema, userMessageObservedFrameSchema, sessionSyncFrameSchema, pingFrameSchema, cancelFrameSchema, sessionNewFrameSchema, sessionCompactFrameSchema, modelSetFrameSchema, thinkingSetFrameSchema, listModelsFrameSchema, queuedMessageSetFrameSchema, queuedMessageClearFrameSchema, queuedMessageSteerFrameSchema, approveToolFrameSchema, attachmentCapabilitiesRequestFrameSchema, attachmentBeginFrameSchema, attachmentChunkFrameSchema, attachmentFinishFrameSchema, attachmentStatusRequestFrameSchema, attachmentCancelFrameSchema, attachmentDiscardFrameSchema]);
111
- export const serverFrameSchema = z.union([pairOkFrameSchema, pairErrorFrameSchema, sessionReadyFrameSchema, extensionInfoFrameSchema, userMessageStartedFrameSchema, userMessageStatusFrameSchema, timelineEventFrameSchema, timelinePartialFrameSchema, timelineEventFragmentFrameSchema, sessionHistoryChunkFrameSchema, protocolErrorFrameSchema, resetFrameSchema, pongFrameSchema, cancelledFrameSchema, actionOkFrameSchema, actionErrorFrameSchema, modelsListFrameSchema, queuedMessageStateFrameSchema, byeFrameSchema, attachmentCapabilitiesFrameSchema, attachmentStateFrameSchema, attachmentErrorFrameSchema, attachmentDiscardedFrameSchema]);
117
+ export const fileOpenedFrameSchema = strictObject({
118
+ ...fileResponse,
119
+ type: z.literal("file_opened"),
120
+ publication_id: idSchema,
121
+ transfer_id: idSchema,
122
+ file_name: fileFileNameSchema,
123
+ mime_type: fileMimeSchema,
124
+ byte_length: fileByteLengthSchema,
125
+ preview: filePreviewSchema,
126
+ });
127
+ const fileChunkFields = {
128
+ ...fileResponse,
129
+ type: z.literal("file_chunk"),
130
+ transfer_id: idSchema,
131
+ offset: fileOffsetSchema,
132
+ };
133
+ /** Final chunks carry the transfer digest; only a zero-length file has an empty final chunk. */
134
+ export const fileChunkFrameSchema = z.union([
135
+ strictObject({ ...fileChunkFields, data_base64: fileChunkDataSchema, final: z.literal(false) }),
136
+ strictObject({ ...fileChunkFields, data_base64: fileChunkDataSchema, final: z.literal(true), total_bytes: fileByteLengthSchema, sha256: fileSha256Schema }),
137
+ ]).superRefine((frame, ctx) => {
138
+ const decoded = canonicalBase64ByteLength(frame.data_base64);
139
+ if (decoded === null) {
140
+ ctx.addIssue({ code: "custom", path: ["data_base64"], message: "data_base64 must be canonical Base64" });
141
+ return;
142
+ }
143
+ if (frame.final) {
144
+ if (decoded === 0 && (frame.offset !== 0 || frame.total_bytes !== 0)) {
145
+ ctx.addIssue({ code: "custom", path: ["data_base64"], message: "empty final chunk requires offset 0 and total_bytes 0" });
146
+ }
147
+ if (frame.offset + decoded !== frame.total_bytes) {
148
+ ctx.addIssue({ code: "custom", path: ["total_bytes"], message: "final chunk must end at total_bytes" });
149
+ }
150
+ }
151
+ else if (decoded < 1) {
152
+ ctx.addIssue({ code: "custom", path: ["data_base64"], message: "non-final chunk data must be at least 1 byte" });
153
+ }
154
+ if (frame.offset + decoded > FILE_MAX_BYTES) {
155
+ ctx.addIssue({ code: "custom", path: ["offset"], message: `chunk must not exceed ${FILE_MAX_BYTES} bytes` });
156
+ }
157
+ });
158
+ export const fileClosedFrameSchema = strictObject({ ...fileResponse, type: z.literal("file_closed"), transfer_id: idSchema });
159
+ export const fileErrorFrameSchema = strictObject({ ...fileResponse, type: z.literal("file_error"), transfer_id: idSchema.optional(), code: fileErrorCodeSchema });
160
+ export const clientFrameSchema = z.union([pairRequestFrameSchema, sessionHelloFrameSchema, extensionInfoRequestFrameSchema, userMessageFrameSchema, userMessageObservedFrameSchema, sessionSyncFrameSchema, pingFrameSchema, cancelFrameSchema, sessionNewFrameSchema, sessionCompactFrameSchema, modelSetFrameSchema, thinkingSetFrameSchema, listModelsFrameSchema, queuedMessageSetFrameSchema, queuedMessageClearFrameSchema, queuedMessageSteerFrameSchema, approveToolFrameSchema, attachmentCapabilitiesRequestFrameSchema, attachmentBeginFrameSchema, attachmentChunkFrameSchema, attachmentFinishFrameSchema, attachmentStatusRequestFrameSchema, attachmentCancelFrameSchema, attachmentDiscardFrameSchema, fileOpenFrameSchema, fileReadFrameSchema, fileCloseFrameSchema]);
161
+ export const serverFrameSchema = z.union([pairOkFrameSchema, pairErrorFrameSchema, sessionReadyFrameSchema, extensionInfoFrameSchema, userMessageStartedFrameSchema, userMessageStatusFrameSchema, timelineEventFrameSchema, timelinePartialFrameSchema, timelineEventFragmentFrameSchema, sessionHistoryChunkFrameSchema, protocolErrorFrameSchema, resetFrameSchema, pongFrameSchema, cancelledFrameSchema, actionOkFrameSchema, actionErrorFrameSchema, modelsListFrameSchema, queuedMessageStateFrameSchema, byeFrameSchema, attachmentCapabilitiesFrameSchema, attachmentStateFrameSchema, attachmentErrorFrameSchema, attachmentDiscardedFrameSchema, fileOpenedFrameSchema, fileChunkFrameSchema, fileClosedFrameSchema, fileErrorFrameSchema]);
112
162
  export const ClientFrameSchema = clientFrameSchema;
113
163
  export const ServerFrameSchema = serverFrameSchema;
114
164
  export const SessionHistoryChunkSchema = sessionHistoryChunkFrameSchema;
@@ -1,4 +1,5 @@
1
1
  export * from "./schema.js";
2
2
  export * from "./attachments.js";
3
+ export * from "./files.js";
3
4
  export * from "./frames.js";
4
5
  export * from "./codec.js";
@@ -1,4 +1,5 @@
1
1
  export * from "./schema.js";
2
2
  export * from "./attachments.js";
3
+ export * from "./files.js";
3
4
  export * from "./frames.js";
4
5
  export * from "./codec.js";
@@ -852,7 +852,7 @@ export declare const harnessSchema: z.ZodObject<{
852
852
  name: z.ZodString;
853
853
  version: z.ZodString;
854
854
  }, z.core.$strict>;
855
- export declare const CLIENT_FRAME_TYPES: readonly ["pair_request", "session_hello", "user_message", "user_message_observed", "session_sync", "ping", "cancel", "session_new", "session_compact", "model_set", "thinking_set", "list_models", "queued_message_set", "queued_message_clear", "queued_message_steer", "approve_tool", "extension_info_request", "attachment_capabilities_request", "attachment_begin", "attachment_chunk", "attachment_finish", "attachment_status_request", "attachment_cancel", "attachment_discard"];
856
- export declare const SERVER_FRAME_TYPES: readonly ["pair_ok", "pair_error", "session_ready", "user_message_started", "user_message_status", "timeline_event", "timeline_partial", "timeline_event_fragment", "session_history_chunk", "protocol_error", "reset", "pong", "cancelled", "action_ok", "action_error", "models_list", "queued_message_state", "bye", "extension_info", "attachment_capabilities", "attachment_state", "attachment_error", "attachment_discarded"];
855
+ export declare const CLIENT_FRAME_TYPES: readonly ["pair_request", "session_hello", "user_message", "user_message_observed", "session_sync", "ping", "cancel", "session_new", "session_compact", "model_set", "thinking_set", "list_models", "queued_message_set", "queued_message_clear", "queued_message_steer", "approve_tool", "extension_info_request", "attachment_capabilities_request", "attachment_begin", "attachment_chunk", "attachment_finish", "attachment_status_request", "attachment_cancel", "attachment_discard", "file_open", "file_read", "file_close"];
856
+ export declare const SERVER_FRAME_TYPES: readonly ["pair_ok", "pair_error", "session_ready", "user_message_started", "user_message_status", "timeline_event", "timeline_partial", "timeline_event_fragment", "session_history_chunk", "protocol_error", "reset", "pong", "cancelled", "action_ok", "action_error", "models_list", "queued_message_state", "bye", "extension_info", "attachment_capabilities", "attachment_state", "attachment_error", "attachment_discarded", "file_opened", "file_chunk", "file_closed", "file_error"];
857
857
  export type ClientFrameType = (typeof CLIENT_FRAME_TYPES)[number];
858
858
  export type ServerFrameType = (typeof SERVER_FRAME_TYPES)[number];
@@ -249,6 +249,7 @@ export const CLIENT_FRAME_TYPES = [
249
249
  "session_new", "session_compact", "model_set", "thinking_set", "list_models", "queued_message_set",
250
250
  "queued_message_clear", "queued_message_steer", "approve_tool", "extension_info_request",
251
251
  "attachment_capabilities_request", "attachment_begin", "attachment_chunk", "attachment_finish", "attachment_status_request", "attachment_cancel", "attachment_discard",
252
+ "file_open", "file_read", "file_close",
252
253
  ];
253
254
  export const SERVER_FRAME_TYPES = [
254
255
  "pair_ok", "pair_error", "session_ready", "user_message_started", "user_message_status", "timeline_event",
@@ -256,4 +257,5 @@ export const SERVER_FRAME_TYPES = [
256
257
  "cancelled", "action_ok", "action_error", "models_list", "queued_message_state", "bye",
257
258
  "extension_info",
258
259
  "attachment_capabilities", "attachment_state", "attachment_error", "attachment_discarded",
260
+ "file_opened", "file_chunk", "file_closed", "file_error",
259
261
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yefengr/pi-reach",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -52,7 +52,6 @@
52
52
  "tsx": "^4.22.0",
53
53
  "typescript": "6.0.3",
54
54
  "vite": "8.2.2",
55
- "typebox": "^1.1.38",
56
55
  "vitest": "4.1.11",
57
56
  "@pi-reach/protocol": "0.0.1"
58
57
  },
@@ -63,6 +62,7 @@
63
62
  "@napi-rs/keyring": "^1.3.0",
64
63
  "@noble/ed25519": "3.1.0",
65
64
  "qrcode-terminal": "^0.12.0",
65
+ "typebox": "^1.1.38",
66
66
  "ws": "^8.21.0",
67
67
  "zod": "4.4.3"
68
68
  },