@vite-hub/comments 0.7.0 → 0.8.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 (60) hide show
  1. package/README.md +4 -10
  2. package/dist/anchor.d.ts +1 -1
  3. package/dist/client-request-B1DCz3a9.js +29 -0
  4. package/dist/client.d.ts +20 -240
  5. package/dist/client.js +3 -421
  6. package/dist/database.d.ts +1 -2
  7. package/dist/database.js +1 -1
  8. package/dist/{define-BqPcuDhf.js → define-C-LUOouq.js} +1 -1
  9. package/dist/{errors-C0VwRHiy.js → errors-C5utwZ5H.js} +0 -24
  10. package/dist/{errors-CBvIpwbo.js → errors-DeSEHzRf.js} +0 -12
  11. package/dist/hosted/hosted-comments/frame.js +4 -1
  12. package/dist/hosted/hosted-comments/tools.js +65 -74
  13. package/dist/hosted/hosted-comments.js +1 -1
  14. package/dist/{index-D1T7RJ4R.d.ts → index-d6NsDxu9.d.ts} +4 -112
  15. package/dist/index.d.ts +4 -5
  16. package/dist/index.js +6 -20
  17. package/dist/{install-CqBWFmU7.js → install-BueV_fJY.js} +7 -771
  18. package/dist/{install-9L4ASzUC.d.ts → install-F-_O7zDr.d.ts} +5 -11
  19. package/dist/{installed-wUYjqk_k.js → installed-BqQKo6WC.js} +2 -7
  20. package/dist/{database-BuSNVwTx.js → migrate-oseJAYbm.js} +2 -46
  21. package/dist/{operations-kMPw-Cyb.js → operations-0llC5kKO.js} +46 -47
  22. package/dist/{operations-Qt8ASQqW.d.ts → operations-jaihyWw2.d.ts} +35 -3
  23. package/dist/operations.d.ts +3 -3
  24. package/dist/operations.js +2 -2
  25. package/dist/overlay/client-ZBsUybIe.js +4 -0
  26. package/dist/overlay/overlay.js +47 -43
  27. package/dist/page/loader.js +31 -27
  28. package/dist/page-BgvzzsJb.d.ts +32 -0
  29. package/dist/{page-2NzFladc.js → page-CDhmXO-y.js} +24 -1
  30. package/dist/{page-tools-shared-BNw-aWEH.js → page-tools-shared-BCdvqA4S.js} +40 -2
  31. package/dist/{plugin-ChOHe7vq.js → plugin-DGUqlc3C.js} +9 -9
  32. package/dist/realtime.d.ts +6 -8
  33. package/dist/realtime.js +2 -4
  34. package/dist/runtime/auth.d.ts +1 -2
  35. package/dist/runtime/auth.js +1 -1
  36. package/dist/runtime/client-request-plugin.d.ts +2 -0
  37. package/dist/runtime/client-request-plugin.js +21 -0
  38. package/dist/runtime/console.js +2 -2
  39. package/dist/runtime/index.d.ts +5 -8
  40. package/dist/runtime/index.js +23 -151
  41. package/dist/{server-8o9u8leM.js → server-CAMs6viR.js} +1 -1
  42. package/dist/server.d.ts +11 -7
  43. package/dist/server.js +7 -6
  44. package/dist/{store-DvNTDNgn.d.ts → service-CMVA_Ryv.d.ts} +67 -1
  45. package/dist/{service-XT2A8YEF.js → service-DaMq8TBw.js} +35 -33
  46. package/dist/{session-DGdFKWDB.js → session-B7GDrqsK.js} +204 -39
  47. package/dist/{session-CN4irEqf.d.ts → session-EzQqBeE8.d.ts} +2 -3
  48. package/dist/{table-names-BIHjuEFK.js → table-names-DUmWROM4.js} +1 -3
  49. package/dist/testing.js +1 -1
  50. package/dist/{define-B1jLSPe9.d.ts → types-qzJKgWYS.d.ts} +157 -4
  51. package/dist/vite.d.ts +2 -19
  52. package/dist/vite.js +15 -51
  53. package/package.json +8 -8
  54. package/dist/database-CPua6Q6_.d.ts +0 -573
  55. package/dist/overlay/client-CrnKCZXc.js +0 -4
  56. package/dist/overlay/dist-yIZmvSaU.js +0 -1
  57. package/dist/page-DE71P_gQ.d.ts +0 -11
  58. package/dist/request-origin-B-CPVAVk.js +0 -53
  59. package/dist/service-IvgrI4XM.d.ts +0 -71
  60. package/dist/types-l6GOb_yc.d.ts +0 -206
package/README.md CHANGED
@@ -114,13 +114,11 @@ On a preview, `forge: { provider: "github" }` posts each thread to the pull requ
114
114
 
115
115
  ## Failures in logs
116
116
 
117
- A failure in `onComment`, `onMention`, or the pull request sync never fails the comment. With the evlog Nitro module registered, Comments logs it with `comments: { hook, step?, thread, code }`: a failed `onComment` on the wide event of the request, the others as their own evlog events. Without evlog, they go to the console. See [Limits and errors](https://vitehub.dev/docs/comments/limits-and-errors#see-hook-and-sync-failures-in-logs).
117
+ A failure in `onComment`, `onMention`, or the pull request sync never fails the comment. With the evlog Nitro module registered, Comments logs it with `comments: { hook, step?, thread, code }`: a failed `onComment` on the wide event of the request, the others as their own evlog events. `onComment` runs before the answer; give slow work to its `waitUntil(promise)`, which keeps the promise running after the answer, and a rejection is logged as its own event with `hook: "onComment"`. Without evlog, they go to the console. See [Limits and errors](https://vitehub.dev/docs/comments/limits-and-errors#see-hook-and-sync-failures-in-logs).
118
118
 
119
- ## Send to an agent
119
+ ## Hand comments to an agent
120
120
 
121
- Each open thread has **Open in T3 Code** and **Copy**, and the list of open threads has **Copy prompt** and **Open in T3 Code** in one row under the title. **Copy** and **Open in T3 Code** give a prompt with the page URL, the text and replies of each thread, the element, and the URLs of its files, for every person who may read the comments. For a Console team member whose MCP access may read the threads, the prompt also names the linked app, its team, and the steps of the ViteHub MCP. It includes resolution steps only with Console MCP write access. `/session` supplies `agent: { mcp, project, resolve }`, and `repository`, the GitHub `owner/name` that the T3 Code link opens: `forge.repository`, else the repository of the build. A Hosted Comments script tag gives it with `data-vitehub-repo`. The pill shows **Copy prompt** too, in both modes, when the page has open threads. In the pill and in the list, **Copy prompt** copies the same text. For a Console team member, it is a short prompt that names the page, the app (its Console name, else its domain), and the ViteHub MCP calls that read and resolve the page's threads. Other people get the full text. <kbd>Shift</kbd> <kbd>C</kbd> hides or shows the pins, as the eye does. Build it with `commentsPagePrompt({ url, threads, agent })`. For one click without a paste, use `send`:
122
-
123
- `defineComments({ send: true })` adds **Send N** to the comment pill: one click hands the open threads of the page that wait for an answer to the person's own agent, such as a T3 Code thread. The first press copies a setup prompt; the agent creates a T3 webhook task and pairs it with the one-use code, and the pill asks once to allow it. Each send is a signed `POST` with the thread ids and a read token for 24 hours, through the member endpoints of `@vite-hub/webhooks`. `send: { grant: false }` leaves the token out, for an app that reads through its own MCP server, and `payload` adds fields, and `prompt` changes the setup prompt. Each member has their own count, and Allow sends only the threads the member saw. The `comments_get_send` MCP tool reads a send, and `comments.listSends(user)` and `comments.readSend(user, id)` read sends on the server. Reopening a thread can restore a done inbox send or let the member send it to a webhook agent again. Send needs a ViteHub app with a SQLite Database. See [Send comments to your agent](https://vitehub.dev/docs/comments/send).
121
+ Each open thread has **Open in T3 Code** and **Copy**, and the list of open threads has **Copy prompt** and **Open in T3 Code** in one row under the title. **Copy** and **Open in T3 Code** give a prompt with the page URL, the text and replies of each thread, the element, and the URLs of its files, for every person who may read the comments. For a Console team member whose MCP access may read the threads, the prompt also names the linked app, its team, and the steps of the ViteHub MCP. It includes resolution steps only with Console MCP write access. `/session` supplies `agent: { mcp, project, resolve }`, and `repository`, the GitHub `owner/name` that the T3 Code link opens: `forge.repository`, else the repository of the build. A Hosted Comments script tag gives it with `data-vitehub-repo`. The pill shows **Copy prompt** too, in both modes, when the page has open threads. In the pill and in the list, **Copy prompt** copies the same text. For a Console team member, it is a short prompt that names the page, the app (its Console name, else its domain), and the ViteHub MCP calls that read and resolve the page's threads. Other people get the full text. <kbd>Shift</kbd> <kbd>C</kbd> hides or shows the pins, as the eye does. Build it with `commentsPagePrompt({ url, threads, agent })`.
124
122
 
125
123
  ## Deployment and security boundaries
126
124
 
@@ -138,7 +136,7 @@ Each open thread has **Open in T3 Code** and **Copy**, and the list of open thre
138
136
  | Import | Purpose |
139
137
  | --- | --- |
140
138
  | `@vite-hub/comments` | `defineComments()` and types. `installComments()` is in `@vite-hub/comments/server`. |
141
- | `@vite-hub/comments/client` | Framework-free client, transport types, `createAnchor()`, `resolveAnchor()`, `commentsAgentPrompt()`, the text of **Copy**, `commentsPagePrompt()`, the text of **Copy prompt** in the pill, `commentsT3CodeLink()`, the link of **Open in T3 Code**, and `createCommentSend()`, the state of the Send segment that hands a member's waiting comments to their agent. |
139
+ | `@vite-hub/comments/client` | Framework-free client, transport types, `createAnchor()`, `resolveAnchor()`, `commentsAgentPrompt()`, the text of **Copy**, `commentsPagePrompt()`, the text of **Copy prompt** in the pill, and `commentsT3CodeLink()`, the link of **Open in T3 Code**. |
142
140
  | `@vite-hub/comments/testing` | In-memory client transport for tests and examples. |
143
141
  | `@vite-hub/comments/anchor` | DOM anchoring: `createAnchor()`, `placeAnchor()`, `selectorOf()`, `labelOf()`. |
144
142
  | `@vite-hub/comments/database` | `commentsSchema`, the Drizzle tables, and `commentsTables`, the statements that create them. |
@@ -319,10 +317,6 @@ const client = createCommentsClient({ transport, user: ana });
319
317
 
320
318
  `transport.as(user)` gives another person on the same store, and `transport.reconnect()` sends `reconnected` to the listeners.
321
319
 
322
- ### Send
323
-
324
- `createCommentSend(transport)` is the state of the **Send** segment of a comment pill, without a framework. Its states are `idle`, `pairing`, `confirm`, `sending`, `sent`, `working`, `failed`, and `limited`. `send.state` holds the state and its data, and `send.onChange()` reports each change. The transport has `status()`, `startPairing()`, `pollPairing(code)`, `allow(code, selection)`, `cancel(code)`, `send()`, and an optional `subscribe()`. `CommentSend` of `@vite-hub/ui` renders it. `createCommentSendTransport({ page })` is the transport over the Send routes of `send: true`. See [Send to an agent](https://vitehub.dev/docs/ui/comments#send-to-an-agent).
325
-
326
320
  ## Errors
327
321
 
328
322
  Errors have a stable code, a `why`, and a `fix`.
package/dist/anchor.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { A as ElementAnchor } from "./types-BX3vH18p.js";
2
- import "./types-l6GOb_yc.js";
2
+ import "./types-qzJKgWYS.js";
3
3
  /** The anchor of a pin that the overlay drops: an element anchor with every hint that `placeAnchor()` uses. */
4
4
  export type PinAnchor = ElementAnchor & Required<Pick<ElementAnchor, "label" | "page" | "viewport">>;
5
5
  /** The attribute that Content's `contentField()` writes on an element that renders a field. */
@@ -0,0 +1,29 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ // ../internal/src/runtime/client-request.ts
3
+ const storageKey = Symbol.for("vitehub.client-request");
4
+ const runtimeGlobal = globalThis;
5
+ const clientRequests = runtimeGlobal[storageKey] ||= new AsyncLocalStorage();
6
+ function isRelativeInProcessRequest(request, client) {
7
+ const url = new URL(request.url);
8
+ if (url.protocol !== "http:") return false;
9
+ if (url.host === "localhost") return true;
10
+ const clientUrl = new URL(client.url);
11
+ url.protocol = clientUrl.protocol;
12
+ return url.host === clientUrl.host || url.host === client.headers.get("host");
13
+ }
14
+ /** Runs `next` with `request` as the client request, unless `request` is a relative request inside a client request. */
15
+ function runWithClientRequest(request, next) {
16
+ const client = clientRequests.getStore();
17
+ return client && isRelativeInProcessRequest(request, client) ? next() : clientRequests.run(request, next);
18
+ }
19
+ /**
20
+ * The request that the client sent. Nitro builds a relative request that the server sends to itself, such as a Nuxt
21
+ * `useFetch()` during server rendering or `serverFetch("/api/...")`, at `http://localhost` or `http://<forwarded Host>`,
22
+ * so the URL of that request does not show the origin of the page. Read origins from this request instead. It needs
23
+ * the Nitro plugin that `clientRequestPlugin()` of `@vite-hub/internal/nitro-kit` gives.
24
+ */
25
+ function clientRequest(request) {
26
+ const client = clientRequests.getStore();
27
+ return client && isRelativeInProcessRequest(request, client) ? client : request;
28
+ }
29
+ export { runWithClientRequest as n, clientRequest as t };
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { A as ElementAnchor, C as CommentStatusInput, D as CommentUser, E as CommentUploadInput, M as PageAnchor, N as TextAnchor, O as CommentUsersInput, S as CommentStatus, T as CommentThread, _ as CommentListCursor, a as CommentBuild, b as CommentMetadata, c as CommentCreateInput, d as CommentDeliveryError, f as CommentEditInput, g as CommentGetInput, h as CommentForgeLink, i as CommentAttachment, j as ImageAnchor, k as CommentsTransport, l as CommentDeleteInput, m as CommentFiles, n as CommentActor, o as CommentComponent, p as CommentEvent, r as CommentAnchor, s as CommentContext, t as AreaAnchor, u as CommentDelivery, v as CommentListQuery, w as CommentSubject, x as CommentReplyInput, y as CommentMessage } from "./types-BX3vH18p.js";
2
- import "./types-l6GOb_yc.js";
2
+ import "./types-qzJKgWYS.js";
3
3
  /** A page event that a client store reacts to. */
4
4
  type BrowserEvent = "online" | "offline" | "visible" | "hidden";
5
5
  /** What a client store needs from the browser: page events, one sender across tabs, and messages between tabs. Tests pass a fake one. */
@@ -418,22 +418,6 @@ export declare const commentsErrorDiagnostics: import("nostics").Diagnostics<{
418
418
  }) => string;
419
419
  readonly fix: "Set `VITEHUB_SECRET` to the output of `openssl rand -base64 32`, which has 44 characters.";
420
420
  };
421
- readonly COMMENTS_SEND_POSTGRES: {
422
- readonly why: "`defineComments({ send })` keeps its sends in SQLite tables, and this app keeps comments in Postgres.";
423
- readonly fix: "Keep comments in a SQLite, libSQL, or D1 Database, or remove `send` from `defineComments()`.";
424
- };
425
- readonly COMMENTS_SEND_TABLES_MISSING: {
426
- readonly why: ({ missing }: {
427
- missing: string;
428
- }) => string;
429
- readonly fix: "Run `vitehub database generate` and `vitehub database migrate`. `vite dev` applies the migration for you.";
430
- };
431
- readonly COMMENTS_SEND_WEBHOOKS_OFF: {
432
- readonly why: ({ file }: {
433
- file: string;
434
- }) => string;
435
- readonly fix: "Use Comments through `vitehub()`, which adds Webhooks, and install `@vite-hub/webhooks` when you use the packages one by one. `comments()` without `vite-hub` has no Send.";
436
- };
437
421
  readonly COMMENTS_TENANT_DELETE_USER: {
438
422
  readonly why: "Deleting a user from shared Comments tables requires access to all projects.";
439
423
  readonly fix: "Delete the user's messages through the project that owns them.";
@@ -482,191 +466,27 @@ export declare const commentsErrorDiagnostics: import("nostics").Diagnostics<{
482
466
  fix: string;
483
467
  };
484
468
  }, readonly import("nostics").AnyDiagnosticReporter[], import("nostics").InferCodesData>;
485
- /** The logo that a Send segment shows for an agent. `@vite-hub/ui` draws each one. */
486
- type CommentSendLogo = "t3" | "claude" | "codex";
487
- /** The agent that gets a member's comments. */
488
- interface CommentSendAgent {
489
- /** Its name, such as `T3 Code`. */
490
- name: string;
491
- logo: CommentSendLogo;
492
- /** The host that deliveries go to, such as `relay.t3.codes`. An inbox has none: the agent picks the comments up itself. */
493
- host?: string;
494
- }
495
- /** What the server knows about the member's Send now. */
496
- interface CommentSendStatus {
497
- /** The open threads that wait for an answer and that no send has carried yet. */
498
- count: number;
499
- /** The member's agent. Without one, Send pairs an agent first. */
500
- agent?: CommentSendAgent;
501
- /** The member's last send, after the agent read it and while it works on it. `thread` is the URL of the agent's thread. */
502
- working?: {
503
- id: string;
504
- thread?: string;
505
- };
506
- /**
507
- * The member's last send, delivered and not read by the agent yet. An inbox send stays here until the agent reads it.
508
- * `inbox` tells where this send went. If omitted, the client uses `agent` to tell whether it went to an inbox.
509
- */
510
- sent?: {
511
- id: string;
512
- thread?: string;
513
- inbox?: boolean;
514
- };
515
- /** The last delivery is still being attempted. */
516
- pending?: boolean;
517
- /** While the member may not send, the time in ms when the next send may go. */
518
- retryAt?: number;
519
- /** Names the `count` waiting threads and their last messages. Allow sends only the threads that it names. */
520
- selection?: string;
521
- }
522
- /** A new setup code. The member pastes `prompt` in the agent's thread, and the agent pairs with `code`. */
523
- interface CommentSendPairing {
524
- code: string;
525
- /** The setup prompt, with the code in it. */
526
- prompt: string;
527
- /** The time in ms when the code stops working. */
528
- expiresAt: number;
529
- /** The agent that the prompt is for. `host` is the only host its URL may have. */
530
- agent: CommentSendAgent;
531
- /** The threads that wait now, which Allow sends, and the selection that names them. */
532
- count: number;
533
- selection: string;
534
- }
535
- /** Where a setup code is: not used yet, used by an agent that waits for Allow, too old, or used with a URL on another host. */
536
- type CommentSendPairingCheck = {
537
- status: "waiting";
538
- } | {
539
- status: "paired";
540
- agent: CommentSendAgent;
541
- } | {
542
- status: "expired";
543
- } | {
544
- status: "refused";
545
- };
546
- /**
547
- * The answer to a send: delivered, not delivered, or refused until `retryAt`. Allow answers `changed` when the waiting
548
- * threads are not the ones that the member confirmed, and keeps the code for the new `count`.
549
- */
550
- type CommentSendResult = {
551
- status: "sent" | "pending";
552
- id: string;
553
- thread?: string;
554
- inbox?: boolean;
555
- } | {
556
- status: "failed";
557
- reason: string;
558
- } | {
559
- status: "limited";
560
- retryAt: number;
561
- } | {
562
- status: "changed";
563
- count: number;
564
- selection: string;
565
- };
566
- /** What the server pushes: the agent started on a send, finished it, or the number of waiting threads changed. */
567
- type CommentSendEvent = {
568
- type: "working";
569
- id: string;
570
- thread?: string;
571
- } | {
572
- type: "done";
573
- id: string;
574
- } | {
575
- type: "count";
576
- count: number;
577
- };
578
- /** How a Send segment talks to the server. Comments `send: true` gives one over HTTP. */
579
- interface CommentSendTransport {
580
- status: () => Promise<CommentSendStatus>;
581
- startPairing: () => Promise<CommentSendPairing>;
582
- pollPairing: (code: string) => Promise<CommentSendPairingCheck>;
583
- /** Pairs the agent that used `code` and sends the waiting threads that `selection` names to it. */
584
- allow: (code: string, selection: string) => Promise<CommentSendResult>;
585
- /** Drops `code`, so no agent can use it. */
586
- cancel: (code: string) => Promise<void>;
587
- send: () => Promise<CommentSendResult>;
588
- /** Pushes events, and returns a function that stops them. Without it, the client asks `status()` while the agent works. */
589
- subscribe?: (listener: (event: CommentSendEvent) => void) => () => void;
590
- }
591
- /**
592
- * What the Send segment shows. Every state has the number of waiting threads, `count`. In `sent`, `inbox` tells where
593
- * the last send went, and `agent` is where the next Send goes.
594
- */
595
- type CommentSendState = {
596
- status: "idle";
597
- count: number;
598
- inbox: boolean;
599
- canPairAnother?: true;
600
- } | {
601
- status: "pairing";
602
- count: number;
603
- prompt: string;
604
- expiresAt: number;
605
- agent: CommentSendAgent;
606
- reason?: "expired" | "refused";
607
- } | {
608
- status: "confirm";
609
- count: number;
610
- agent: CommentSendAgent;
611
- } | {
612
- status: "sending";
613
- count: number;
614
- } | {
615
- status: "sent";
616
- count: number;
617
- inbox: boolean;
618
- agent?: CommentSendAgent;
619
- } | {
620
- status: "working";
621
- count: number;
622
- agent?: CommentSendAgent;
623
- thread?: string;
624
- } | {
625
- status: "failed";
626
- count: number;
627
- reason: string;
628
- } | {
629
- status: "limited";
630
- count: number;
631
- retryAt: number;
632
- };
633
- /** Writes the setup prompt to the clipboard once it loads. Resolves to `false` when the browser refuses. */
634
- type CommentSendCopy = (prompt: Promise<string>) => Promise<boolean>;
635
- interface CommentSendOptions {
636
- /** How often, in ms, the client asks whether an agent used the setup code. Default 1500. */
637
- pairingInterval?: number;
638
- /** How often, in ms, the client asks `status()` while the agent works and the transport cannot push. Default 5000. */
639
- statusInterval?: number;
640
- /** How long, in ms, Sent shows before Working. Default 2000. */
641
- sentFor?: number;
642
- }
643
- interface CommentSendClient {
644
- readonly state: CommentSendState;
645
- /** Calls `listener` after every change of `state`. Returns a function that stops it. */
646
- onChange: (listener: () => void) => () => void;
647
- /** Loads the status, then follows the agent: pushed events, or `status()` while it works. Returns a function that stops it. */
648
- start: () => () => void;
649
- /** Loads the status again, such as after the member wrote a comment. */
650
- refresh: () => Promise<void>;
651
- /**
652
- * Send N, and Retry after Not delivered. Without an agent, it gets a setup code, gives its prompt to `copy`, and waits
653
- * for an agent to use the code.
654
- */
655
- send: (copy?: CommentSendCopy) => Promise<void>;
656
- /** Starts a new pairing without changing where the regular Send button sends. */
657
- pairAnother: (copy?: CommentSendCopy) => Promise<void>;
658
- /** Allow and send N: pairs the agent that used the code and sends to it. */
659
- allow: () => Promise<void>;
660
- /** Copy again, after the code expired or the agent used a URL on another host. */
661
- copyAgain: (copy?: CommentSendCopy) => Promise<void>;
662
- /** × or Escape while pairing: drops the code and goes back to Send N. */
663
- cancel: () => void;
469
+ /** Lower case without accents, so `jose` finds `José`. Mention suggestions match names this way, in the browser and on the server. */
470
+ export declare function foldName(text: string): string;
471
+ /** What the Comments API session lets the person do on the page. */
472
+ interface CommentsPageCan {
473
+ comment: boolean;
474
+ resolve: boolean;
475
+ delete?: boolean;
476
+ /** `false` keeps every message as it was sent. */
477
+ change?: false;
664
478
  }
665
479
  /**
666
- * The Send segment of a comment pill, without a framework: it hands the member's waiting threads to their agent, and
667
- * pairs one in place first when there is none. `CommentSend` of `@vite-hub/ui` renders it.
480
+ * Whether the Comments API lets `user` do `action`, from the permissions of the page session and the ones that the API
481
+ * sent with the thread. A guest never edits or deletes, because the server does not take a guest id as proof. The
482
+ * server still decides.
668
483
  */
669
- export declare function createCommentSend(transport: CommentSendTransport, options?: CommentSendOptions): CommentSendClient;
484
+ export declare function commentsApiCan(user: CommentUser | undefined, page: CommentsPageCan | undefined, action: "reply" | "resolve" | "edit" | "delete", { thread, message }: {
485
+ thread: CommentThread;
486
+ message?: CommentMessage;
487
+ }): boolean;
488
+ /** The app base, such as `/portal`, that Vite `base` or Nuxt `app.baseURL` sets. The Comments API of the app runs below it. */
489
+ export declare function appCommentsBase(): string;
670
490
  /** A guest that named itself in the browser. The server keeps the name as display data only. */
671
491
  interface CommentsGuest {
672
492
  id: string;
@@ -733,46 +553,6 @@ interface RestTransport extends CommentsTransport {
733
553
  export declare function createRestTransport(options?: RestTransportOptions & {
734
554
  route?: string;
735
555
  }): RestTransport;
736
- interface CommentSendTransportOptions extends Pick<RestTransportOptions, "base" | "headers" | "credentials" | "fetch"> {
737
- /**
738
- * The path of the page that Send is on, such as `/notes/azores`. The server turns it into the subject, as `page` of
739
- * `defineComments()` decides. A function runs before each request, so it follows client-side navigation. Default:
740
- * `location.pathname`.
741
- */
742
- page?: string | (() => string);
743
- }
744
- /**
745
- * The transport of `createCommentSend()` over the Send routes of Comments, `<base>/_vitehub/comments/send/**`. The
746
- * ViteHub pill uses it, and an app renders `CommentSend` of `@vite-hub/ui` with it in its own pill:
747
- *
748
- * ```ts
749
- * import { createCommentSend, createCommentSendTransport } from "@vite-hub/comments/client"
750
- *
751
- * const send = createCommentSend(createCommentSendTransport({ page: () => location.pathname }))
752
- * ```
753
- */
754
- export declare function createCommentSendTransport(options?: CommentSendTransportOptions): CommentSendTransport;
755
- /** Lower case without accents, so `jose` finds `José`. Mention suggestions match names this way, in the browser and on the server. */
756
- export declare function foldName(text: string): string;
757
- /** What the Comments API session lets the person do on the page. */
758
- interface CommentsPageCan {
759
- comment: boolean;
760
- resolve: boolean;
761
- delete?: boolean;
762
- /** `false` keeps every message as it was sent. */
763
- change?: false;
764
- }
765
- /**
766
- * Whether the Comments API lets `user` do `action`, from the permissions of the page session and the ones that the API
767
- * sent with the thread. A guest never edits or deletes, because the server does not take a guest id as proof. The
768
- * server still decides.
769
- */
770
- export declare function commentsApiCan(user: CommentUser | undefined, page: CommentsPageCan | undefined, action: "reply" | "resolve" | "edit" | "delete", { thread, message }: {
771
- thread: CommentThread;
772
- message?: CommentMessage;
773
- }): boolean;
774
- /** The app base, such as `/portal`, that Vite `base` or Nuxt `app.baseURL` sets. The Comments API of the app runs below it. */
775
- export declare function appCommentsBase(): string;
776
556
  /** The guest name and id that this browser saved, the same one that the overlay uses. */
777
557
  export declare function readCommentsGuest(): CommentsGuest | undefined;
778
558
  /** Saves the name that a guest typed. The id stays when the guest saved a name before. */
@@ -842,4 +622,4 @@ export declare function createCommentsClient(options: CommentsClientOptions & {
842
622
  readonly outbox: CommentsOutbox;
843
623
  };
844
624
  export declare function createCommentsClient(options?: CommentsClientOptions): CommentsClient;
845
- export type { AnchorPoint, AnchorPosition, AnchorRect, AnchorTarget, AreaAnchor, CommentActor, CommentAnchor, CommentAttachment, CommentBuild, CommentComponent, CommentContext, CommentCreateInput, CommentDeleteInput, CommentDelivery, CommentDeliveryError, CommentEditInput, CommentEvent, CommentFiles, CommentForgeLink, CommentGetInput, CommentListCursor, CommentListQuery, CommentMessage, CommentMetadata, CommentReplyInput, CommentSendAgent, CommentSendClient, CommentSendCopy, CommentSendEvent, CommentSendLogo, CommentSendOptions, CommentSendPairing, CommentSendPairingCheck, CommentSendResult, CommentSendState, CommentSendStatus, CommentSendTransport, CommentSendTransportOptions, CommentStatus, CommentStatusInput, CommentSubject, CommentThread, CommentUploadInput, CommentUser, CommentUsersInput, CommentsAgentAccess, CommentsAgentPromptInput, CommentsAgentPromptThread, CommentsClientFiles, CommentsGuest, CommentsOutbox, CommentsOutboxEntry, CommentsOutboxEnvironment, CommentsOutboxMessage, CommentsOutboxOptions, CommentsOutboxStore, CommentsPageCan, CommentsRestAnswer, CommentsRestRequest, CommentsTransport, CreateAnchorOptions, DetachedAnchor, ElementAnchor, ImageAnchor, PageAnchor, ResolvedAnchor, RestCommentThread, RestTransport, RestTransportOptions, TextAnchor };
625
+ export type { AnchorPoint, AnchorPosition, AnchorRect, AnchorTarget, AreaAnchor, CommentActor, CommentAnchor, CommentAttachment, CommentBuild, CommentComponent, CommentContext, CommentCreateInput, CommentDeleteInput, CommentDelivery, CommentDeliveryError, CommentEditInput, CommentEvent, CommentFiles, CommentForgeLink, CommentGetInput, CommentListCursor, CommentListQuery, CommentMessage, CommentMetadata, CommentReplyInput, CommentStatus, CommentStatusInput, CommentSubject, CommentThread, CommentUploadInput, CommentUser, CommentUsersInput, CommentsAgentAccess, CommentsAgentPromptInput, CommentsAgentPromptThread, CommentsClientFiles, CommentsGuest, CommentsOutbox, CommentsOutboxEntry, CommentsOutboxEnvironment, CommentsOutboxMessage, CommentsOutboxOptions, CommentsOutboxStore, CommentsPageCan, CommentsRestAnswer, CommentsRestRequest, CommentsTransport, CreateAnchorOptions, DetachedAnchor, ElementAnchor, ImageAnchor, PageAnchor, ResolvedAnchor, RestCommentThread, RestTransport, RestTransportOptions, TextAnchor };