@dreamlake/dreamlake-cli 0.97.2 → 0.98.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.
Files changed (40) hide show
  1. package/dist/api/client.d.ts +1 -1
  2. package/dist/api/client.js +4 -4
  3. package/dist/api/http.d.ts +48 -1
  4. package/dist/api/http.js +111 -4
  5. package/dist/api/index.d.ts +17 -513
  6. package/dist/api/index.js +6 -2
  7. package/dist/api/note-edits.d.ts +40 -2
  8. package/dist/api/note-edits.js +197 -2
  9. package/dist/api/note-events.d.ts +40 -4
  10. package/dist/api/note-events.js +55 -2
  11. package/dist/api/note-facade.d.ts +268 -0
  12. package/dist/api/note-facade.js +376 -0
  13. package/dist/api/note-reading.d.ts +27 -0
  14. package/dist/api/note-reading.js +27 -0
  15. package/dist/api/note-write.d.ts +110 -0
  16. package/dist/api/note-write.js +217 -0
  17. package/dist/api/notes.d.ts +33 -44
  18. package/dist/api/notes.js +44 -34
  19. package/dist/api/sessions.d.ts +5 -5
  20. package/dist/cli/client.d.ts +2 -41
  21. package/dist/cli/client.js +13 -90
  22. package/dist/cli/help-examples.generated.js +1 -1
  23. package/dist/cli/notes/api-transport.js +6 -6
  24. package/dist/cli/notes/document.d.ts +32 -26
  25. package/dist/cli/notes/document.js +150 -95
  26. package/dist/cli/notes/edit-commands.d.ts +26 -5
  27. package/dist/cli/notes/edit-commands.js +163 -36
  28. package/dist/cli/notes/events.d.ts +3 -33
  29. package/dist/cli/notes/events.js +4 -51
  30. package/dist/cli/notes/html-read.d.ts +6 -0
  31. package/dist/cli/notes/html-read.js +12 -0
  32. package/dist/cli/notes/index.d.ts +10 -1
  33. package/dist/cli/notes/index.js +98 -27
  34. package/dist/cli/notes/move-command.d.ts +4 -0
  35. package/dist/cli/notes/move-command.js +7 -0
  36. package/dist/cli/sessions/runner/serve.d.ts +1 -1
  37. package/dist/cli/vault/sshTransfer.d.ts +1 -1
  38. package/dist/cli/version.d.ts +1 -1
  39. package/dist/cli/version.js +1 -1
  40. package/package.json +9 -9
@@ -427,15 +427,15 @@ export declare function createApi(transport: Transport): {
427
427
  }) => Promise<{
428
428
  commands: import("./sessions.js").Command[];
429
429
  }>;
430
- get: (commandId: string, wait?: number) => Promise<import("./sessions.js").Command<"status" | "start" | "stop" | "resume" | "send" | "sync" | "subagents">>;
431
- wait: (commandId: string, seconds: number, signal?: AbortSignal) => Promise<import("./sessions.js").Command<"status" | "start" | "stop" | "resume" | "send" | "sync" | "subagents">>;
432
- cancel: (commandId: string) => Promise<import("./sessions.js").Command<"status" | "start" | "stop" | "resume" | "send" | "sync" | "subagents">>;
430
+ get: (commandId: string, wait?: number) => Promise<import("./sessions.js").Command<"start" | "stop" | "status" | "resume" | "send" | "sync" | "subagents">>;
431
+ wait: (commandId: string, seconds: number, signal?: AbortSignal) => Promise<import("./sessions.js").Command<"start" | "stop" | "status" | "resume" | "send" | "sync" | "subagents">>;
432
+ cancel: (commandId: string) => Promise<import("./sessions.js").Command<"start" | "stop" | "status" | "resume" | "send" | "sync" | "subagents">>;
433
433
  renew: (commandId: string, runnerId: string, leaseToken: string) => Promise<{
434
434
  leaseMs: number;
435
435
  cancelRequested?: boolean;
436
436
  }>;
437
- reconcile: (commandId: string, runnerId: string, observation: Record<string, unknown>) => Promise<import("./sessions.js").Command<"status" | "start" | "stop" | "resume" | "send" | "sync" | "subagents">>;
438
- finish: (commandId: string, runnerId: string, receipt: import("./sessions.js").CommandReceipt) => Promise<import("./sessions.js").Command<"status" | "start" | "stop" | "resume" | "send" | "sync" | "subagents">>;
437
+ reconcile: (commandId: string, runnerId: string, observation: Record<string, unknown>) => Promise<import("./sessions.js").Command<"start" | "stop" | "status" | "resume" | "send" | "sync" | "subagents">>;
438
+ finish: (commandId: string, runnerId: string, receipt: import("./sessions.js").CommandReceipt) => Promise<import("./sessions.js").Command<"start" | "stop" | "status" | "resume" | "send" | "sync" | "subagents">>;
439
439
  };
440
440
  runners: {
441
441
  list: () => Promise<import("./sessions.js").Runner[]>;
@@ -473,257 +473,7 @@ export declare function createApi(transport: Transport): {
473
473
  }) => Promise<unknown>;
474
474
  managed: (id: string, action: "status" | "start" | "reconnect" | "stop", input: Record<string, unknown>) => Promise<unknown>;
475
475
  };
476
- notes: (namespace: string) => {
477
- linger: (noteId: string, options: import("./note-linger.js").NoteLingerOptions, receive: (event: import("./note-linger.js").NoteLingerEvent) => void | Promise<void>) => Promise<void>;
478
- namespace: string;
479
- resolve: (ref: string) => Promise<string>;
480
- selectElement: (noteId: string, css: string) => Promise<{
481
- etag: string;
482
- tag: string;
483
- attrs: Record<string, string | null>;
484
- outer: [number, number];
485
- inner: [number, number];
486
- text: string;
487
- }>;
488
- source: (noteId: string, at?: string) => Promise<import("./note-edits.js").NoteSource>;
489
- patch: (noteId: string, input: import("./note-edits.js").NotePatch) => Promise<{
490
- note: string;
491
- hash: string;
492
- revision: string;
493
- baseRevision: string;
494
- mode: "exact" | "merge";
495
- }>;
496
- replaceContent: (noteId: string, baseRevision: string, content: string, mode?: "exact" | "merge") => Promise<{
497
- note: string;
498
- hash: string;
499
- revision: string;
500
- baseRevision: string;
501
- mode: "exact" | "merge";
502
- }>;
503
- replace: (noteId: string, baseRevision: string, text: string, where: import("./note-editing.js").Where, mode?: "exact" | "merge") => Promise<{
504
- note: string;
505
- hash: string;
506
- revision: string;
507
- baseRevision: string;
508
- mode: "exact" | "merge";
509
- }>;
510
- insert: (noteId: string, baseRevision: string, text: string, where: {
511
- line?: number;
512
- ind?: number;
513
- }, mode?: "exact" | "merge") => Promise<{
514
- note: string;
515
- hash: string;
516
- revision: string;
517
- baseRevision: string;
518
- mode: "exact" | "merge";
519
- }>;
520
- removeText: (noteId: string, baseRevision: string, where: import("./note-editing.js").Where, mode?: "exact" | "merge") => Promise<{
521
- note: string;
522
- hash: string;
523
- revision: string;
524
- baseRevision: string;
525
- mode: "exact" | "merge";
526
- }>;
527
- findInSource: (noteId: string, at: string, query?: string, options?: import("./note-editing.js").FindOpts) => Promise<{
528
- matches: import("./note-editing.js").Match[];
529
- note: string;
530
- content: string;
531
- hash: string;
532
- revision: string;
533
- }>;
534
- outline: (noteId: string, at?: string) => Promise<{
535
- note: string;
536
- revision: string;
537
- hash: string;
538
- entries: import("./note-toc.js").TocEntry[];
539
- }>;
540
- get: (noteId: string) => Promise<import("./notes.js").NoteRow & {
541
- namespaceSlug: string;
542
- permissions: Record<string, boolean>;
543
- }>;
544
- archive: (noteId: string) => Promise<import("./notes.js").NoteRow>;
545
- unarchive: (noteId: string) => Promise<import("./notes.js").NoteRow>;
546
- delete: (noteId: string) => Promise<unknown>;
547
- shared: (query?: {
548
- includeArchived?: boolean;
549
- }) => Promise<{
550
- notes: import("./notes.js").NoteRow[];
551
- }>;
552
- projects: (noteId: string, view?: "nodes") => Promise<unknown>;
553
- move: (noteId: string, input: {
554
- namespace: string;
555
- projects: string[];
556
- dryRun?: boolean;
557
- }) => Promise<unknown>;
558
- share: (noteId: string) => {
559
- get: () => Promise<Record<string, unknown>>;
560
- create: (role?: "read" | "write") => Promise<unknown>;
561
- revoke: (revokeAccepted?: boolean) => Promise<unknown>;
562
- visibility: (visibility: "private" | "public" | "team") => Promise<unknown>;
563
- access: () => Promise<unknown>;
564
- remove: (userId: string) => Promise<unknown>;
565
- };
566
- files: (noteId: string) => {
567
- list: (query?: import("./note-files.js").NoteFileListOptions) => Promise<import("./note-files.js").NoteFilePage>;
568
- get: (id: string) => Promise<import("./note-files.js").NoteFile>;
569
- resolve: (ref: string, includeTrashed?: boolean) => Promise<import("./note-files.js").NoteFile>;
570
- text: (ref: string) => Promise<{
571
- text: string;
572
- etag: string;
573
- }>;
574
- cat: (ref: string) => Promise<{
575
- text: string;
576
- etag: string;
577
- }>;
578
- download: (ref: string, signal?: AbortSignal) => Promise<Response>;
579
- upload: (path: string, body: NonNullable<import("./client.js").RequestOptions["body"]> | import("stream").Readable, options?: {
580
- contentType?: string;
581
- overwrite?: boolean;
582
- ifMatch?: string;
583
- contentLength?: number;
584
- signal?: AbortSignal;
585
- }) => Promise<import("./note-files.js").NoteFile>;
586
- write: (input: {
587
- path: string;
588
- text: string;
589
- overwrite?: boolean;
590
- contentType?: string;
591
- }, options?: {
592
- ifMatch?: string;
593
- idempotencyKey?: string;
594
- }) => Promise<import("./note-files.js").NoteFileWriteReceipt>;
595
- move: (ref: string, path: string, options?: {
596
- overwrite?: boolean;
597
- ifMatch?: string;
598
- }) => Promise<import("./note-files.js").NoteFile>;
599
- copy: (ref: string, path: string, options?: {
600
- overwrite?: boolean;
601
- idempotencyKey?: string;
602
- }) => Promise<import("./note-files.js").NoteFileWriteReceipt>;
603
- operation: (operationId: string, action?: "status" | "reconcile" | "cancel") => Promise<import("./note-files.js").NoteFileOperationReceipt>;
604
- status: (id: string) => Promise<import("./note-files.js").NoteFileOperationReceipt>;
605
- reconcile: (id: string) => Promise<import("./note-files.js").NoteFileOperationReceipt>;
606
- cancel: (id: string) => Promise<import("./note-files.js").NoteFileOperationReceipt>;
607
- delete: (ref: string, options?: {
608
- purge?: boolean;
609
- ifMatch?: string;
610
- }) => Promise<{
611
- id: string;
612
- purged: boolean;
613
- }>;
614
- restore: (ref: string, path?: string) => Promise<import("./note-files.js").NoteFile>;
615
- preview: (ref: string, share?: boolean) => Promise<import("./note-files.js").NoteFilePreview>;
616
- revokePreview: (ref: string) => Promise<{
617
- id: string;
618
- shared: boolean;
619
- }>;
620
- };
621
- media: (form: FormData) => Promise<import("./notes.js").NoteMediaReceipt>;
622
- read: (noteId: string, query?: import("./common.js").Query) => Promise<import("./notes.js").NoteReadResult>;
623
- readView: (noteId: string, options?: import("./note-reading.js").NoteReadingOptions) => Promise<import("./note-reading.js").NoteReadingPage>;
624
- html: (noteId: string, options?: {
625
- at?: string;
626
- section?: string;
627
- toc?: boolean;
628
- tag?: string;
629
- ifMatch?: string;
630
- }) => Promise<{
631
- note: string;
632
- revision: string;
633
- html: string;
634
- bytes: Uint8Array<ArrayBuffer>;
635
- }>;
636
- diff: (noteId: string, query: {
637
- from?: string;
638
- to?: string;
639
- since?: string;
640
- format?: "diff" | "inline-dff";
641
- }) => Promise<unknown>;
642
- saveVersion: (noteId: string, input: {
643
- hash: string;
644
- tag?: string;
645
- summary?: string;
646
- parentId?: string;
647
- }) => Promise<unknown>;
648
- find: (query: {
649
- q: string;
650
- note?: string;
651
- cursor?: string;
652
- limit?: number;
653
- includeArchived?: boolean;
654
- caseSensitive?: boolean;
655
- glob?: string;
656
- regex?: string;
657
- flags?: string;
658
- context?: string;
659
- }) => Promise<import("./notes.js").NoteSearchPage>;
660
- create: (input: {
661
- name: string;
662
- summary?: string;
663
- projects?: string[];
664
- visibility?: "private" | "public";
665
- }) => Promise<{
666
- note: import("./notes.js").NoteRow;
667
- rtc: {
668
- rtcDocId: string;
669
- };
670
- }>;
671
- edit: (noteId: string, baseRevision: string, edits: import("./note-edits.js").NoteEdit[], mode?: "merge" | "exact") => Promise<{
672
- note: string;
673
- hash: string;
674
- revision: string;
675
- baseRevision: string;
676
- mode: "exact" | "merge";
677
- }>;
678
- versions: (noteId: string, query?: {
679
- before?: string;
680
- }) => Promise<{
681
- versions: import("./notes.js").NoteVersion[];
682
- nextCursor?: string | null;
683
- }>;
684
- version: (noteId: string, versionId: string) => Promise<import("./notes.js").NoteVersion>;
685
- list: (query?: {
686
- q?: string;
687
- limit?: number;
688
- offset?: number;
689
- includeArchived?: boolean;
690
- }) => Promise<{
691
- notes: import("./notes.js").NoteRow[];
692
- }>;
693
- search: (q: string, limit?: number, offset?: number, options?: {
694
- includeArchived?: boolean;
695
- }) => Promise<{
696
- notes: import("./notes.js").NoteRow[];
697
- total: number;
698
- }>;
699
- body: (noteId: string) => Promise<import("./notes.js").NoteBody>;
700
- sections: (noteId: string) => Promise<{
701
- sections: import("./notes.js").Section[];
702
- etag: string;
703
- }>;
704
- section: (noteId: string, anchor: string) => Promise<import("./notes.js").NoteBody & Partial<import("./notes.js").Section>>;
705
- write: (noteId: string, text: string, ifMatch: string) => Promise<import("./notes.js").WriteReceipt>;
706
- append: (noteId: string, addition: string, ifMatch?: string) => Promise<import("./notes.js").WriteReceipt>;
707
- addSection: (noteId: string, text: string, placement?: {
708
- before?: string;
709
- after?: string;
710
- }, ifMatch?: string) => Promise<import("./notes.js").WriteReceipt>;
711
- removeSection: (noteId: string, anchor: string, ifMatch?: string) => Promise<import("./notes.js").WriteReceipt>;
712
- presence: {
713
- (id: string): Promise<import("./note-presence.js").NotePresenceRoster>;
714
- (id: string, input: Record<string, unknown>): Promise<import("./note-presence.js").NotePresenceReceipt>;
715
- };
716
- presenceText: (id: string) => Promise<string>;
717
- updatePresence: (id: string, input: Record<string, unknown>, options?: import("./client.js").RequestOptions) => Promise<import("./note-presence.js").NotePresenceReceipt>;
718
- visit: (id: string, options?: {
719
- intent?: string;
720
- }) => Promise<import("./note-presence.js").NotePresenceReceipt>;
721
- activity: (id: string, options?: import("./client.js").RequestOptions) => Promise<{
722
- activities: import("./note-presence.js").NoteActivity[];
723
- }>;
724
- events: (id: string, signal: AbortSignal, receive: (event: import("./note-events.js").NoteEvent) => void) => Promise<void>;
725
- selectText: (id: string, options: import("./note-presence.js").NoteSelectionOptions) => Promise<import("./note-presence.js").NoteSelectionReceipt>;
726
- };
476
+ notes: import("./note-facade.js").NotesFacade;
727
477
  projects: (namespace: string) => {
728
478
  grants: (project: string) => Promise<unknown>;
729
479
  grant: (project: string, input: ({
@@ -1645,15 +1395,15 @@ export declare function createClient(options: ClientOptions): {
1645
1395
  }) => Promise<{
1646
1396
  commands: import("./sessions.js").Command[];
1647
1397
  }>;
1648
- get: (commandId: string, wait?: number) => Promise<import("./sessions.js").Command<"status" | "start" | "stop" | "resume" | "send" | "sync" | "subagents">>;
1649
- wait: (commandId: string, seconds: number, signal?: AbortSignal) => Promise<import("./sessions.js").Command<"status" | "start" | "stop" | "resume" | "send" | "sync" | "subagents">>;
1650
- cancel: (commandId: string) => Promise<import("./sessions.js").Command<"status" | "start" | "stop" | "resume" | "send" | "sync" | "subagents">>;
1398
+ get: (commandId: string, wait?: number) => Promise<import("./sessions.js").Command<"start" | "stop" | "status" | "resume" | "send" | "sync" | "subagents">>;
1399
+ wait: (commandId: string, seconds: number, signal?: AbortSignal) => Promise<import("./sessions.js").Command<"start" | "stop" | "status" | "resume" | "send" | "sync" | "subagents">>;
1400
+ cancel: (commandId: string) => Promise<import("./sessions.js").Command<"start" | "stop" | "status" | "resume" | "send" | "sync" | "subagents">>;
1651
1401
  renew: (commandId: string, runnerId: string, leaseToken: string) => Promise<{
1652
1402
  leaseMs: number;
1653
1403
  cancelRequested?: boolean;
1654
1404
  }>;
1655
- reconcile: (commandId: string, runnerId: string, observation: Record<string, unknown>) => Promise<import("./sessions.js").Command<"status" | "start" | "stop" | "resume" | "send" | "sync" | "subagents">>;
1656
- finish: (commandId: string, runnerId: string, receipt: import("./sessions.js").CommandReceipt) => Promise<import("./sessions.js").Command<"status" | "start" | "stop" | "resume" | "send" | "sync" | "subagents">>;
1405
+ reconcile: (commandId: string, runnerId: string, observation: Record<string, unknown>) => Promise<import("./sessions.js").Command<"start" | "stop" | "status" | "resume" | "send" | "sync" | "subagents">>;
1406
+ finish: (commandId: string, runnerId: string, receipt: import("./sessions.js").CommandReceipt) => Promise<import("./sessions.js").Command<"start" | "stop" | "status" | "resume" | "send" | "sync" | "subagents">>;
1657
1407
  };
1658
1408
  runners: {
1659
1409
  list: () => Promise<import("./sessions.js").Runner[]>;
@@ -1691,257 +1441,7 @@ export declare function createClient(options: ClientOptions): {
1691
1441
  }) => Promise<unknown>;
1692
1442
  managed: (id: string, action: "status" | "start" | "reconnect" | "stop", input: Record<string, unknown>) => Promise<unknown>;
1693
1443
  };
1694
- notes: (namespace: string) => {
1695
- linger: (noteId: string, options: import("./note-linger.js").NoteLingerOptions, receive: (event: import("./note-linger.js").NoteLingerEvent) => void | Promise<void>) => Promise<void>;
1696
- namespace: string;
1697
- resolve: (ref: string) => Promise<string>;
1698
- selectElement: (noteId: string, css: string) => Promise<{
1699
- etag: string;
1700
- tag: string;
1701
- attrs: Record<string, string | null>;
1702
- outer: [number, number];
1703
- inner: [number, number];
1704
- text: string;
1705
- }>;
1706
- source: (noteId: string, at?: string) => Promise<import("./note-edits.js").NoteSource>;
1707
- patch: (noteId: string, input: import("./note-edits.js").NotePatch) => Promise<{
1708
- note: string;
1709
- hash: string;
1710
- revision: string;
1711
- baseRevision: string;
1712
- mode: "exact" | "merge";
1713
- }>;
1714
- replaceContent: (noteId: string, baseRevision: string, content: string, mode?: "exact" | "merge") => Promise<{
1715
- note: string;
1716
- hash: string;
1717
- revision: string;
1718
- baseRevision: string;
1719
- mode: "exact" | "merge";
1720
- }>;
1721
- replace: (noteId: string, baseRevision: string, text: string, where: import("./note-editing.js").Where, mode?: "exact" | "merge") => Promise<{
1722
- note: string;
1723
- hash: string;
1724
- revision: string;
1725
- baseRevision: string;
1726
- mode: "exact" | "merge";
1727
- }>;
1728
- insert: (noteId: string, baseRevision: string, text: string, where: {
1729
- line?: number;
1730
- ind?: number;
1731
- }, mode?: "exact" | "merge") => Promise<{
1732
- note: string;
1733
- hash: string;
1734
- revision: string;
1735
- baseRevision: string;
1736
- mode: "exact" | "merge";
1737
- }>;
1738
- removeText: (noteId: string, baseRevision: string, where: import("./note-editing.js").Where, mode?: "exact" | "merge") => Promise<{
1739
- note: string;
1740
- hash: string;
1741
- revision: string;
1742
- baseRevision: string;
1743
- mode: "exact" | "merge";
1744
- }>;
1745
- findInSource: (noteId: string, at: string, query?: string, options?: import("./note-editing.js").FindOpts) => Promise<{
1746
- matches: import("./note-editing.js").Match[];
1747
- note: string;
1748
- content: string;
1749
- hash: string;
1750
- revision: string;
1751
- }>;
1752
- outline: (noteId: string, at?: string) => Promise<{
1753
- note: string;
1754
- revision: string;
1755
- hash: string;
1756
- entries: import("./note-toc.js").TocEntry[];
1757
- }>;
1758
- get: (noteId: string) => Promise<import("./notes.js").NoteRow & {
1759
- namespaceSlug: string;
1760
- permissions: Record<string, boolean>;
1761
- }>;
1762
- archive: (noteId: string) => Promise<import("./notes.js").NoteRow>;
1763
- unarchive: (noteId: string) => Promise<import("./notes.js").NoteRow>;
1764
- delete: (noteId: string) => Promise<unknown>;
1765
- shared: (query?: {
1766
- includeArchived?: boolean;
1767
- }) => Promise<{
1768
- notes: import("./notes.js").NoteRow[];
1769
- }>;
1770
- projects: (noteId: string, view?: "nodes") => Promise<unknown>;
1771
- move: (noteId: string, input: {
1772
- namespace: string;
1773
- projects: string[];
1774
- dryRun?: boolean;
1775
- }) => Promise<unknown>;
1776
- share: (noteId: string) => {
1777
- get: () => Promise<Record<string, unknown>>;
1778
- create: (role?: "read" | "write") => Promise<unknown>;
1779
- revoke: (revokeAccepted?: boolean) => Promise<unknown>;
1780
- visibility: (visibility: "private" | "public" | "team") => Promise<unknown>;
1781
- access: () => Promise<unknown>;
1782
- remove: (userId: string) => Promise<unknown>;
1783
- };
1784
- files: (noteId: string) => {
1785
- list: (query?: import("./note-files.js").NoteFileListOptions) => Promise<import("./note-files.js").NoteFilePage>;
1786
- get: (id: string) => Promise<import("./note-files.js").NoteFile>;
1787
- resolve: (ref: string, includeTrashed?: boolean) => Promise<import("./note-files.js").NoteFile>;
1788
- text: (ref: string) => Promise<{
1789
- text: string;
1790
- etag: string;
1791
- }>;
1792
- cat: (ref: string) => Promise<{
1793
- text: string;
1794
- etag: string;
1795
- }>;
1796
- download: (ref: string, signal?: AbortSignal) => Promise<Response>;
1797
- upload: (path: string, body: NonNullable<import("./client.js").RequestOptions["body"]> | import("stream").Readable, options?: {
1798
- contentType?: string;
1799
- overwrite?: boolean;
1800
- ifMatch?: string;
1801
- contentLength?: number;
1802
- signal?: AbortSignal;
1803
- }) => Promise<import("./note-files.js").NoteFile>;
1804
- write: (input: {
1805
- path: string;
1806
- text: string;
1807
- overwrite?: boolean;
1808
- contentType?: string;
1809
- }, options?: {
1810
- ifMatch?: string;
1811
- idempotencyKey?: string;
1812
- }) => Promise<import("./note-files.js").NoteFileWriteReceipt>;
1813
- move: (ref: string, path: string, options?: {
1814
- overwrite?: boolean;
1815
- ifMatch?: string;
1816
- }) => Promise<import("./note-files.js").NoteFile>;
1817
- copy: (ref: string, path: string, options?: {
1818
- overwrite?: boolean;
1819
- idempotencyKey?: string;
1820
- }) => Promise<import("./note-files.js").NoteFileWriteReceipt>;
1821
- operation: (operationId: string, action?: "status" | "reconcile" | "cancel") => Promise<import("./note-files.js").NoteFileOperationReceipt>;
1822
- status: (id: string) => Promise<import("./note-files.js").NoteFileOperationReceipt>;
1823
- reconcile: (id: string) => Promise<import("./note-files.js").NoteFileOperationReceipt>;
1824
- cancel: (id: string) => Promise<import("./note-files.js").NoteFileOperationReceipt>;
1825
- delete: (ref: string, options?: {
1826
- purge?: boolean;
1827
- ifMatch?: string;
1828
- }) => Promise<{
1829
- id: string;
1830
- purged: boolean;
1831
- }>;
1832
- restore: (ref: string, path?: string) => Promise<import("./note-files.js").NoteFile>;
1833
- preview: (ref: string, share?: boolean) => Promise<import("./note-files.js").NoteFilePreview>;
1834
- revokePreview: (ref: string) => Promise<{
1835
- id: string;
1836
- shared: boolean;
1837
- }>;
1838
- };
1839
- media: (form: FormData) => Promise<import("./notes.js").NoteMediaReceipt>;
1840
- read: (noteId: string, query?: import("./common.js").Query) => Promise<import("./notes.js").NoteReadResult>;
1841
- readView: (noteId: string, options?: import("./note-reading.js").NoteReadingOptions) => Promise<import("./note-reading.js").NoteReadingPage>;
1842
- html: (noteId: string, options?: {
1843
- at?: string;
1844
- section?: string;
1845
- toc?: boolean;
1846
- tag?: string;
1847
- ifMatch?: string;
1848
- }) => Promise<{
1849
- note: string;
1850
- revision: string;
1851
- html: string;
1852
- bytes: Uint8Array<ArrayBuffer>;
1853
- }>;
1854
- diff: (noteId: string, query: {
1855
- from?: string;
1856
- to?: string;
1857
- since?: string;
1858
- format?: "diff" | "inline-dff";
1859
- }) => Promise<unknown>;
1860
- saveVersion: (noteId: string, input: {
1861
- hash: string;
1862
- tag?: string;
1863
- summary?: string;
1864
- parentId?: string;
1865
- }) => Promise<unknown>;
1866
- find: (query: {
1867
- q: string;
1868
- note?: string;
1869
- cursor?: string;
1870
- limit?: number;
1871
- includeArchived?: boolean;
1872
- caseSensitive?: boolean;
1873
- glob?: string;
1874
- regex?: string;
1875
- flags?: string;
1876
- context?: string;
1877
- }) => Promise<import("./notes.js").NoteSearchPage>;
1878
- create: (input: {
1879
- name: string;
1880
- summary?: string;
1881
- projects?: string[];
1882
- visibility?: "private" | "public";
1883
- }) => Promise<{
1884
- note: import("./notes.js").NoteRow;
1885
- rtc: {
1886
- rtcDocId: string;
1887
- };
1888
- }>;
1889
- edit: (noteId: string, baseRevision: string, edits: import("./note-edits.js").NoteEdit[], mode?: "merge" | "exact") => Promise<{
1890
- note: string;
1891
- hash: string;
1892
- revision: string;
1893
- baseRevision: string;
1894
- mode: "exact" | "merge";
1895
- }>;
1896
- versions: (noteId: string, query?: {
1897
- before?: string;
1898
- }) => Promise<{
1899
- versions: import("./notes.js").NoteVersion[];
1900
- nextCursor?: string | null;
1901
- }>;
1902
- version: (noteId: string, versionId: string) => Promise<import("./notes.js").NoteVersion>;
1903
- list: (query?: {
1904
- q?: string;
1905
- limit?: number;
1906
- offset?: number;
1907
- includeArchived?: boolean;
1908
- }) => Promise<{
1909
- notes: import("./notes.js").NoteRow[];
1910
- }>;
1911
- search: (q: string, limit?: number, offset?: number, options?: {
1912
- includeArchived?: boolean;
1913
- }) => Promise<{
1914
- notes: import("./notes.js").NoteRow[];
1915
- total: number;
1916
- }>;
1917
- body: (noteId: string) => Promise<import("./notes.js").NoteBody>;
1918
- sections: (noteId: string) => Promise<{
1919
- sections: import("./notes.js").Section[];
1920
- etag: string;
1921
- }>;
1922
- section: (noteId: string, anchor: string) => Promise<import("./notes.js").NoteBody & Partial<import("./notes.js").Section>>;
1923
- write: (noteId: string, text: string, ifMatch: string) => Promise<import("./notes.js").WriteReceipt>;
1924
- append: (noteId: string, addition: string, ifMatch?: string) => Promise<import("./notes.js").WriteReceipt>;
1925
- addSection: (noteId: string, text: string, placement?: {
1926
- before?: string;
1927
- after?: string;
1928
- }, ifMatch?: string) => Promise<import("./notes.js").WriteReceipt>;
1929
- removeSection: (noteId: string, anchor: string, ifMatch?: string) => Promise<import("./notes.js").WriteReceipt>;
1930
- presence: {
1931
- (id: string): Promise<import("./note-presence.js").NotePresenceRoster>;
1932
- (id: string, input: Record<string, unknown>): Promise<import("./note-presence.js").NotePresenceReceipt>;
1933
- };
1934
- presenceText: (id: string) => Promise<string>;
1935
- updatePresence: (id: string, input: Record<string, unknown>, options?: import("./client.js").RequestOptions) => Promise<import("./note-presence.js").NotePresenceReceipt>;
1936
- visit: (id: string, options?: {
1937
- intent?: string;
1938
- }) => Promise<import("./note-presence.js").NotePresenceReceipt>;
1939
- activity: (id: string, options?: import("./client.js").RequestOptions) => Promise<{
1940
- activities: import("./note-presence.js").NoteActivity[];
1941
- }>;
1942
- events: (id: string, signal: AbortSignal, receive: (event: import("./note-events.js").NoteEvent) => void) => Promise<void>;
1943
- selectText: (id: string, options: import("./note-presence.js").NoteSelectionOptions) => Promise<import("./note-presence.js").NoteSelectionReceipt>;
1944
- };
1444
+ notes: import("./note-facade.js").NotesFacade;
1945
1445
  projects: (namespace: string) => {
1946
1446
  grants: (project: string) => Promise<unknown>;
1947
1447
  grant: (project: string, input: ({
@@ -2404,4 +1904,8 @@ export * from "./note-html-read.js";
2404
1904
  export { characterDiff, NotePatchError, PATCH_LIMITS, } from "./note-character-plan.js";
2405
1905
  export * from "./presigned-transfer.js";
2406
1906
  export * from "./note-events.js";
2407
- export type { NoteReadingOptions, NoteReadingPage } from "./note-reading.js";
1907
+ export * from "./note-write.js";
1908
+ export { documentEdits, documentInsertion } from "./note-edits.js";
1909
+ export * from "./note-facade.js";
1910
+ export type { NoteReadingOptions, NoteReadingPage, NoteFocusedRead } from "./note-reading.js";
1911
+ export { lineRange, focusedRead, InvalidLineRange } from "./note-reading.js";
package/dist/api/index.js CHANGED
@@ -46,7 +46,7 @@ export * from "./infra.js";
46
46
  */
47
47
  import { agentApi, projectToolsApi } from "./agent.js";
48
48
  import { createTransport, } from "./client.js";
49
- import { notesApi } from "./notes.js";
49
+ import { notesFacade } from "./note-facade.js";
50
50
  import { sessionsApi } from "./sessions.js";
51
51
  export * from "./client.js";
52
52
  export * from "./sessions.js";
@@ -72,7 +72,7 @@ export function createApi(transport) {
72
72
  teams: teamsApi(transport),
73
73
  sessions: (namespace) => sessionsApi(transport, namespace),
74
74
  terminal: (namespace) => terminalApi(transport, namespace),
75
- notes: (namespace) => notesApi(transport, namespace),
75
+ notes: notesFacade(transport),
76
76
  projects: (namespace) => projectsApi(transport, namespace),
77
77
  nodes: nodesApi(transport),
78
78
  tasks: (namespace, project) => tasksApi(transport, namespace, project),
@@ -114,3 +114,7 @@ export * from "./note-html-read.js";
114
114
  export { characterDiff, NotePatchError, PATCH_LIMITS, } from "./note-character-plan.js";
115
115
  export * from "./presigned-transfer.js";
116
116
  export * from "./note-events.js";
117
+ export * from "./note-write.js";
118
+ export { documentEdits, documentInsertion } from "./note-edits.js";
119
+ export * from "./note-facade.js";
120
+ export { lineRange, focusedRead, InvalidLineRange } from "./note-reading.js";
@@ -5,10 +5,12 @@ export interface NoteSource {
5
5
  hash: string;
6
6
  revision: string;
7
7
  }
8
- export interface NoteEdit {
8
+ export interface SourceEdit {
9
9
  start: number;
10
10
  end: number;
11
11
  text: string;
12
+ }
13
+ export interface NoteEdit extends SourceEdit {
12
14
  expected?: string;
13
15
  }
14
16
  export interface NotePatch {
@@ -17,5 +19,41 @@ export interface NotePatch {
17
19
  baseRevision: string;
18
20
  mode: "merge" | "exact";
19
21
  }
20
- /** Validate optional expected text, then use the existing source-span compiler. */
22
+ /** The CLI's names for the same shapes; `src/cli/notes/document.ts` re-exports them. */
23
+ export type SourceSnapshot = NoteSource;
24
+ export type DocumentPatchPayload = NotePatch;
25
+ /** Generated reading-view annotations are never saved as source. What is
26
+ * forbidden is NEW text that carries the generated header line
27
+ * (`<!-- notes-reading-view revision=… hash=…`). Deleting such a line, keeping
28
+ * one the note already has, or mentioning the marker in prose or a code block
29
+ * is allowed. Checked on raw inserted text before compilation (escaping would
30
+ * hide it) and on the insertion payloads of a caller-supplied patch. */
31
+ export declare const READING_VIEW_MARKER = "<!-- notes-reading-view";
32
+ export declare const READING_VIEW_HEADER: RegExp;
33
+ export declare class ReadingViewMarkerRefused extends Error {
34
+ constructor(what: string);
35
+ }
36
+ /** Inserted or replacement text only, never deletions or unchanged context. */
37
+ export declare function refuseReadingView(text: string, what: string): void;
38
+ /** Whole-body replacement: only lines that are new relative to the baseline count, so a header the note already holds survives a write. */
39
+ export declare function refuseNewReadingViewLines(baseline: string, content: string, what: string): void;
40
+ /** Apply the inline-dff subset this client emits (`@@ chars s:e @@` + one `~` line of `[-old-]`/`{+new+}`
41
+ * segments) to a baseline. null when the patch is outside that subset or its old text does not match. */
42
+ export declare function applyInlineDff(baseline: string, patch: string): string | null;
43
+ /** Apply a unified diff to a baseline, verifying context and removed lines. null when it does not apply cleanly. */
44
+ export declare function applyUnifiedDiff(baseline: string, patch: string): string | null;
45
+ /** A caller-supplied patch. With the baseline it was written against, the target is reconstructed and
46
+ * checked like a whole-body write (so a header split across hunks is seen assembled, and one the note
47
+ * already has may be re-added). Without a baseline, or when the patch does not apply to it, the check is
48
+ * BEST-EFFORT on the insertion payloads: inline-dff `{+…+}` (escapes decoded), concatenated across hunks
49
+ * that are adjacent in the original (one's end offset is the next's start, so no baseline text lies
50
+ * between them), or unified-diff `+` lines. Authoritative enforcement belongs to the server. */
51
+ export declare function refuseReadingViewPatch(patch: string, format: "inline-dff" | "diff", baseline?: string): void;
52
+ /** Exact original-source spans, with untouched gaps omitted from the PATCH. The target the edits
53
+ * produce is reconstructed and checked against the baseline, so a generated header assembled from
54
+ * several spans is refused exactly as a whole-body write would be. */
55
+ export declare function documentEdits(source: SourceSnapshot, edits: SourceEdit[], exact?: boolean): DocumentPatchPayload;
56
+ /** One literal insertion at an original-source Unicode code-point boundary. */
57
+ export declare function documentInsertion(source: SourceSnapshot, at: number, text: string, exact?: boolean): DocumentPatchPayload;
58
+ /** Validate optional expected text, then use the same source-span compiler. */
21
59
  export declare function noteEdits(source: NoteSource, edits: NoteEdit[], mode?: "merge" | "exact"): NotePatch;