@vite-hub/comments 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -6
- package/dist/{client-diagnostics-CvfTW5d4.js → client-diagnostics-DoXqdnBd.js} +12 -0
- package/dist/client.d.ts +119 -23
- package/dist/client.js +708 -209
- package/dist/{database-BkPoOdZr.js → database-BuSNVwTx.js} +1 -1
- package/dist/database.js +1 -1
- package/dist/{define-BCxNaSZv.js → define-BqPcuDhf.js} +1 -1
- package/dist/{errors-DFNiJg67.js → errors-CBvIpwbo.js} +1 -1
- package/dist/hosted/hosted-comments/frame.js +1 -1
- package/dist/hosted/hosted-comments/tools.js +371 -0
- package/dist/hosted/hosted-comments.js +1 -9
- package/dist/index.js +11 -10
- package/dist/{install-NehuMNhG.d.ts → install-9L4ASzUC.d.ts} +10 -1
- package/dist/{install-w6CCgGFV.js → install-CqBWFmU7.js} +23 -15
- package/dist/{installed-C9SkldMi.js → installed-wUYjqk_k.js} +1 -1
- package/dist/{operations-8hqTi0DH.d.ts → operations-DFLer1fR.d.ts} +1 -0
- package/dist/{operations-Cic9A9e_.d.ts → operations-Qt8ASQqW.d.ts} +2 -2
- package/dist/{operations-B8IMhRmY.js → operations-kMPw-Cyb.js} +10 -11
- package/dist/operations.d.ts +2 -2
- package/dist/operations.js +2 -2
- package/dist/overlay/client-CrnKCZXc.js +4 -0
- package/dist/overlay/overlay.js +70 -29
- package/dist/page/loader.js +25 -23
- package/dist/{page-xzgZ6DGm.js → page-2NzFladc.js} +5 -1
- package/dist/{page-tools-shared-fvmJQCrP.js → page-tools-shared-BNw-aWEH.js} +2 -5
- package/dist/{plugin-DbCYT7Ac.js → plugin-ChOHe7vq.js} +9 -8
- package/dist/realtime.d.ts +12 -1
- package/dist/realtime.js +14 -6
- package/dist/{request-origin-YPzfE2eh.js → request-origin-B-CPVAVk.js} +6 -1
- package/dist/{rpc-BKY7XRlR.js → rpc-kkxzQ3Qy.js} +1 -1
- package/dist/rpc.js +1 -1
- package/dist/runtime/auth.js +1 -1
- package/dist/runtime/console.js +2 -2
- package/dist/runtime/index.d.ts +4 -1
- package/dist/runtime/index.js +16 -14
- package/dist/{server-BGbD7H5s.js → server-8o9u8leM.js} +1 -1
- package/dist/server.d.ts +3 -3
- package/dist/server.js +6 -6
- package/dist/{service-CPiWPoiY.d.ts → service-IvgrI4XM.d.ts} +2 -0
- package/dist/{service-DUh2uGd2.js → service-XT2A8YEF.js} +11 -6
- package/dist/{session-_1GY5gaG.js → session-DGdFKWDB.js} +8 -7
- package/dist/testing.js +1 -1
- package/dist/vite.d.ts +2 -1
- package/dist/vite.js +31 -11
- package/package.json +9 -8
- package/dist/hosted/hosted-comments/client-B3dlmmQd.js +0 -4
- package/dist/hosted/hosted-comments/dist-DyVmH21U.js +0 -14
- package/dist/hosted/hosted-comments/overlay-CFuq5QAH.js +0 -182
- package/dist/hosted/hosted-comments/protocol-BHvtQKte.js +0 -1
- package/dist/hosted/hosted-comments/rest-transport-D-9_pNqZ.js +0 -1
- package/dist/hosted/hosted-comments/tools-Bz--joZw.js +0 -126
- package/dist/overlay/client-CerbVjTz.js +0 -4
package/README.md
CHANGED
|
@@ -76,7 +76,7 @@ export const comments = defineComments({
|
|
|
76
76
|
|
|
77
77
|
Console `comments:read` access allows reading threads and joining presence. Writes also require full `comments` access and the Comments policy.
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
With the pill open, press `C` and click the page to start a thread, or press `B` to draw on the page with a marker, a pen, arrows, or text labels and comment with a picture of it. Press `E` to edit text that `contentField()` marks:
|
|
80
80
|
|
|
81
81
|
```vue
|
|
82
82
|
<script setup lang="ts">
|
|
@@ -93,7 +93,7 @@ An edit reads the draft, changes one string field, and saves the document with `
|
|
|
93
93
|
|
|
94
94
|
### Add Hosted Comments
|
|
95
95
|
|
|
96
|
-
Register your site in the Console with **Hosted Comments only**, then copy the script into your page HTML. For a connected app, copy it from **Settings** > **Connection** > **Hosted Comments
|
|
96
|
+
Register your site in the Console with **Hosted Comments only**, then copy the script into your page HTML. For a connected app, copy it from **Settings** > **Connection** > **Hosted Comments**, and set `comments: { overlay: false }`. This turns off the app's overlay but keeps its Comments API. When the app's Comments start, Hosted Comments stay off or stop after you send or discard any draft. The browser console shows `COMMENTS_HOSTED_CONFLICT`. The hosted overlay draws in `<vitehub-hosted-comments>`, so it never takes the element of the app's overlay. The Console signs reviewers in and stores their page threads. Send shows a comment at once and sends it in the background, with one outbox for each project. Confirming an unlink permanently deletes that project's hosted threads and replies.
|
|
97
97
|
|
|
98
98
|
## Server API
|
|
99
99
|
|
|
@@ -118,7 +118,7 @@ A failure in `onComment`, `onMention`, or the pull request sync never fails the
|
|
|
118
118
|
|
|
119
119
|
## Send to an agent
|
|
120
120
|
|
|
121
|
-
|
|
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
122
|
|
|
123
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).
|
|
124
124
|
|
|
@@ -126,7 +126,7 @@ A Console team member who opens the app through Site access gets **Copy prompt**
|
|
|
126
126
|
|
|
127
127
|
- Threads live only in the Database. Presence rooms hold no document, and connections are read-only. The server binds each person's presence to the user that `identify` or the Auth session resolves.
|
|
128
128
|
- Pins anchor to the Content field first, then a CSS path checked against the element text, then the text alone, then the page point. A pin whose element is gone shows dashed.
|
|
129
|
-
-
|
|
129
|
+
- After a thread changes, the server sends a Realtime notice to tabs displaying its subject, including different pages that show the same subject. Each tab reads the threads again through the Comments API. Cursors and presence stay on the current page. Pages without Realtime read the threads again on focus and every 30 seconds.
|
|
130
130
|
- Without a Realtime driver, such as on Vercel, comments work without presence or cursors.
|
|
131
131
|
- Write routes compare `Origin` with the request origin, and honour `X-Forwarded-Proto` and `X-Forwarded-Host` from a proxy that ends TLS.
|
|
132
132
|
- Page context stores only the URL origin and pathname, validated against the request origin and thread page. Query parameters, URL credentials, and fragments are discarded. Nuxt component files come from its resolved component registry.
|
|
@@ -138,7 +138,7 @@ A Console team member who opens the app through Site access gets **Copy prompt**
|
|
|
138
138
|
| Import | Purpose |
|
|
139
139
|
| --- | --- |
|
|
140
140
|
| `@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 prompt**, and `createCommentSend()`, the state of the Send segment that hands a member's waiting comments to their agent. |
|
|
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. |
|
|
142
142
|
| `@vite-hub/comments/testing` | In-memory client transport for tests and examples. |
|
|
143
143
|
| `@vite-hub/comments/anchor` | DOM anchoring: `createAnchor()`, `placeAnchor()`, `selectorOf()`, `labelOf()`. |
|
|
144
144
|
| `@vite-hub/comments/database` | `commentsSchema`, the Drizzle tables, and `commentsTables`, the statements that create them. |
|
|
@@ -247,6 +247,8 @@ client.threads; // The cached threads, ordered by number.
|
|
|
247
247
|
client.onChange(() => console.log(`${client.threads.length} threads`));
|
|
248
248
|
```
|
|
249
249
|
|
|
250
|
+
Without `transport`, the client uses the Comments API of the app, with the guest that `saveCommentsGuest(name)` saved in this browser. In Vue, `useComments({ subject })` from `@vite-hub/ui/headless` and `<CommentLayer :subject>` use that client and learn the user from `GET /session`.
|
|
251
|
+
|
|
250
252
|
To retry a create safely, give it a `requestId`, such as `crypto.randomUUID()`, and keep it for that draft. A second create with the same `requestId` in the same scope returns the first thread and creates no new thread. Only the author of the first thread gets it back, for the same subject, and only when that author may still read it. Anything else fails: the Operations and `POST /threads` answer `409` with `COMMENTS_R0022`, and the server API `comments.create()` returns `COMMENTS_INVALID_INPUT` with the reason. Make a new `requestId` for each new comment.
|
|
251
253
|
|
|
252
254
|
A reply takes a `requestId` too. A second reply with the same `requestId` in the same thread returns the thread with the first message, adds nothing, and runs no hooks. Another author with that key gets the same `409`.
|
|
@@ -255,7 +257,22 @@ A reply takes a `requestId` too. A second reply with the same `requestId` in the
|
|
|
255
257
|
|
|
256
258
|
### Outbox
|
|
257
259
|
|
|
258
|
-
`createCommentsClient({ ..., outbox: { account } })` saves each new comment and reply in IndexedDB before it sends.
|
|
260
|
+
`createCommentsClient({ ..., outbox: { account } })` saves each new comment and reply in IndexedDB before it sends. `create` and `reply` show the draft with `delivery: { status: "pending" }` in `threads` and `outbox.entries` the moment you call them, and `onChange` fires before the save ends. The draft goes out, and other tabs see it, once it is saved. Drafts go out in the order you wrote them and survive a reload. If the save fails, as when the disk is full, the draft stays on the page as `failed` with its body and files, and `outbox.retry(id)` saves and sends it. The outbox checks the author on each write and stores progress so another tab can resume. When one origin serves more than one Comments API, give each its own `namespace`: entries saved under one never go out under another. See [Write comments offline](https://vitehub.dev/docs/comments/offline).
|
|
261
|
+
|
|
262
|
+
With an outbox, `files` may be a promise, such as of a screenshot that renders after Send:
|
|
263
|
+
|
|
264
|
+
```ts fragment
|
|
265
|
+
const files = renderScreenshot().then(blob => [blob]);
|
|
266
|
+
await client.create({ subject, anchor, body, files }); // Shows and saves now; sends once `files` settles.
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
To keep files the reader already picked when the page reloads before the screenshot arrives, pass them as `files` and the screenshot as `deferredFiles`:
|
|
270
|
+
|
|
271
|
+
```ts fragment
|
|
272
|
+
await client.create({ subject, anchor, body, files: picked, deferredFiles: renderScreenshot().then(blob => [blob]) });
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
The draft holds the queue until the files arrive, then goes out with them. If saving the files fails, Retry saves them again. If the promise rejects, the draft goes out without them. If the page reloads first, the next page sends a saved draft without them. Without Web Locks, the default outbox stays in memory. With a custom store and no locks, drafts wait in memory until their files arrive and can be saved in send order.
|
|
259
276
|
|
|
260
277
|
If a comment write gets no answer, retry it to recover the server copy. A later refusal does not make the draft safe to edit or dismiss. A lost upload or thread lookup answer does not lock the draft on its own.
|
|
261
278
|
|
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
import { Diagnostic, defineDiagnostics } from "nostics";
|
|
2
2
|
// src/client-diagnostics.ts
|
|
3
3
|
const commentsClientCodes = {
|
|
4
|
+
COMMENTS_HOSTED_CONFLICT: {
|
|
5
|
+
why: "This page runs the app's own Comments, so the Hosted Comments script does not start its overlay.",
|
|
6
|
+
fix: "Remove the Hosted Comments script, or keep it and set `comments: { overlay: false }` to turn off the app's overlay. See https://vitehub.dev/docs/comments/configure#add-hosted-comments"
|
|
7
|
+
},
|
|
4
8
|
COMMENTS_OUTBOX_ACCOUNT_CHANGED: {
|
|
5
9
|
why: "The current author is not the author of this queued comment.",
|
|
6
10
|
fix: "Sign in as the original author and retry the outbox."
|
|
7
11
|
},
|
|
12
|
+
COMMENTS_OUTBOX_RESOLVE_BLOCKED: {
|
|
13
|
+
why: "Queued delivery must resume before the thread can close.",
|
|
14
|
+
fix: "Go online, then retry or dismiss any blocked comments and resolve the thread again."
|
|
15
|
+
},
|
|
8
16
|
COMMENTS_OUTBOX_SENDING: {
|
|
9
17
|
why: "The server may already have this comment, so the draft cannot change.",
|
|
10
18
|
fix: "Wait for delivery to finish, then edit or delete the server copy."
|
|
11
19
|
},
|
|
20
|
+
COMMENTS_OVERLAY_ELEMENT_TAKEN: {
|
|
21
|
+
why: ({ name }) => `Another script defined the <${name}> element, so this Comments overlay cannot start.`,
|
|
22
|
+
fix: "Load one Comments overlay script on the page. Remove the other script that defines the element."
|
|
23
|
+
},
|
|
12
24
|
COMMENTS_R0001: {
|
|
13
25
|
why: ({ target }) => `createAnchor() found nothing to anchor to for ${target}.`,
|
|
14
26
|
fix: "Pass an element, a non-empty selection, or a point that is over an element of the page."
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +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
3
|
/** A page event that a client store reacts to. */
|
|
3
4
|
type BrowserEvent = "online" | "offline" | "visible" | "hidden";
|
|
4
5
|
/** What a client store needs from the browser: page events, one sender across tabs, and messages between tabs. Tests pass a fake one. */
|
|
@@ -34,19 +35,13 @@ type CommentsOutboxMessage = {
|
|
|
34
35
|
/** What the outbox needs from the browser: online and visible events, Web Locks, and a BroadcastChannel. Tests pass a fake one. */
|
|
35
36
|
type CommentsOutboxEnvironment = BrowserEnvironment<CommentsOutboxMessage>;
|
|
36
37
|
interface CommentsOutboxEntryBase {
|
|
37
|
-
/** The local thread or message id. Use it for outbox actions. */
|
|
38
38
|
id: string;
|
|
39
|
-
/** The retry key that the server gets. */
|
|
40
39
|
requestId: string;
|
|
41
40
|
account: string;
|
|
42
41
|
files: Blob[];
|
|
43
|
-
/** Milliseconds since the epoch. */
|
|
44
42
|
createdAt: number;
|
|
45
|
-
/** The place in the queue. */
|
|
46
43
|
order: number;
|
|
47
|
-
/** `sending` while one tab sends it. `failed` when the server refused it: it waits for `retry` or a safe `edit` or `dismiss`. */
|
|
48
44
|
status: "pending" | "sending" | "failed";
|
|
49
|
-
/** Why the last try did not go out. */
|
|
50
45
|
error?: CommentDeliveryError;
|
|
51
46
|
uncertain?: boolean;
|
|
52
47
|
claim?: string;
|
|
@@ -54,6 +49,7 @@ interface CommentsOutboxEntryBase {
|
|
|
54
49
|
retryAt?: number;
|
|
55
50
|
held?: boolean;
|
|
56
51
|
uploaded?: string[];
|
|
52
|
+
awaitingFiles?: boolean;
|
|
57
53
|
}
|
|
58
54
|
/** A comment or reply that the outbox holds. */
|
|
59
55
|
type CommentsOutboxEntry = CommentsOutboxEntryBase & ({
|
|
@@ -68,10 +64,10 @@ type CommentsOutboxEntry = CommentsOutboxEntryBase & ({
|
|
|
68
64
|
interface CommentsOutboxStore {
|
|
69
65
|
/** `false` when the entries live only in this page, and a reload loses them. */
|
|
70
66
|
readonly persisted: boolean;
|
|
71
|
-
/** The entries of
|
|
72
|
-
list: (
|
|
73
|
-
/** Read and change one
|
|
74
|
-
update: <T>(
|
|
67
|
+
/** The entries of one queue, in queue order. The key is the account, or the namespace and account of the outbox. */
|
|
68
|
+
list: (queue: string) => Promise<CommentsOutboxEntry[]>;
|
|
69
|
+
/** Read and change one queue's entries in one transaction. Replace entries rather than mutating them. */
|
|
70
|
+
update: <T>(queue: string, change: (entries: Map<string, CommentsOutboxEntry>) => T) => Promise<T>;
|
|
75
71
|
}
|
|
76
72
|
interface CommentsOutboxOptions {
|
|
77
73
|
/**
|
|
@@ -79,6 +75,8 @@ interface CommentsOutboxOptions {
|
|
|
79
75
|
* comment never goes out as somebody else.
|
|
80
76
|
*/
|
|
81
77
|
account: string;
|
|
78
|
+
/** Separates destinations on the same origin, such as two Comments APIs. Entries of another namespace never send. */
|
|
79
|
+
namespace?: string;
|
|
82
80
|
/** Default: the `vitehub-comments` IndexedDB database, else memory with `persisted: false`. */
|
|
83
81
|
store?: CommentsOutboxStore;
|
|
84
82
|
/** Default: the browser. */
|
|
@@ -103,6 +101,18 @@ interface CommentsOutbox {
|
|
|
103
101
|
/** Removes every entry of the account, such as at sign-out. */
|
|
104
102
|
clear: () => Promise<void>;
|
|
105
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* The files of a new comment or reply. With an outbox, `files` may be a promise, such as of a screenshot that renders
|
|
106
|
+
* after Send: the entry shows and saves at once and sends when the promise settles, without files if it rejects. To
|
|
107
|
+
* keep files the reader already picked through a reload, pass them as `files` and the late ones as `deferredFiles`.
|
|
108
|
+
*/
|
|
109
|
+
type CommentsClientFiles = Omit<CommentFiles, "files"> & ({
|
|
110
|
+
files?: Blob[] | Promise<Blob[]>;
|
|
111
|
+
deferredFiles?: undefined;
|
|
112
|
+
} | {
|
|
113
|
+
files?: Blob[];
|
|
114
|
+
deferredFiles: Promise<Blob[]>;
|
|
115
|
+
});
|
|
106
116
|
/** An outbox store in memory. Entries live as long as the store object. Pass one store to two clients to test a reload. */
|
|
107
117
|
export declare function createMemoryOutboxStore(): CommentsOutboxStore;
|
|
108
118
|
/**
|
|
@@ -110,18 +120,60 @@ export declare function createMemoryOutboxStore(): CommentsOutboxStore;
|
|
|
110
120
|
* does not open, as in some private windows, it keeps the entries in memory and `persisted` is `false`.
|
|
111
121
|
*/
|
|
112
122
|
export declare function createIndexedDBOutboxStore(): CommentsOutboxStore;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
123
|
+
/** One thread in a prompt: its messages, where it is on the page, and the URLs of its files. */
|
|
124
|
+
interface CommentsAgentPromptThread {
|
|
125
|
+
id: string;
|
|
126
|
+
anchor: CommentAnchor;
|
|
127
|
+
/** Oldest first. The first message is the comment. */
|
|
128
|
+
messages: readonly {
|
|
129
|
+
author: string;
|
|
130
|
+
body: string;
|
|
131
|
+
}[];
|
|
132
|
+
/** The version of the subject that the thread was started on. */
|
|
133
|
+
revision?: number;
|
|
134
|
+
/** The URLs of the files of the comment, such as its screenshot. */
|
|
135
|
+
files?: readonly string[];
|
|
136
|
+
}
|
|
137
|
+
/** The ViteHub MCP of a Console member, and the linked app that the agent checks before it reads the threads. */
|
|
138
|
+
interface CommentsAgentAccess {
|
|
116
139
|
mcp: string;
|
|
140
|
+
/** `name` is the app's name in the Console, such as `Acme Docs`. */
|
|
117
141
|
project: {
|
|
118
142
|
id: string;
|
|
119
143
|
teamId: string;
|
|
120
144
|
url: string;
|
|
145
|
+
name?: string;
|
|
121
146
|
};
|
|
147
|
+
/** `true` when the member's MCP access may resolve the threads. */
|
|
122
148
|
resolve: boolean;
|
|
123
149
|
}
|
|
124
|
-
|
|
150
|
+
interface CommentsAgentPromptInput {
|
|
151
|
+
/** The page of the threads. */
|
|
152
|
+
url: string;
|
|
153
|
+
threads: readonly CommentsAgentPromptThread[];
|
|
154
|
+
/** Without it, the prompt has no ViteHub MCP steps and asks the agent to report the fixes. */
|
|
155
|
+
agent?: CommentsAgentAccess;
|
|
156
|
+
}
|
|
157
|
+
/** The longest link that `commentsT3CodeLink()` makes. */
|
|
158
|
+
export declare const t3CodeLinkLimit = 8000;
|
|
159
|
+
/**
|
|
160
|
+
* The prompt that sends an agent to fix comments: the text of each thread, where it is, and its files. With `agent`, it
|
|
161
|
+
* also tells the agent to read the threads, and to resolve them when the member may, through the ViteHub MCP.
|
|
162
|
+
*/
|
|
163
|
+
export declare function commentsAgentPrompt(input: CommentsAgentPromptInput): string;
|
|
164
|
+
/**
|
|
165
|
+
* A link that opens a new T3 Code thread with the prompt of `commentsAgentPrompt()`, in `repository` (`owner/name`)
|
|
166
|
+
* when it is a GitHub repository. The link is at most `t3CodeLinkLimit` characters. A long prompt always keeps its steps:
|
|
167
|
+
* first its messages and anchors get shorter, then each thread keeps only its ID and a short title. For an MCP prompt,
|
|
168
|
+
* the last option is the thread IDs and instructions. Returns `undefined` if none of these fit.
|
|
169
|
+
*/
|
|
170
|
+
export declare function commentsT3CodeLink(input: CommentsAgentPromptInput, repository?: string): string | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* The prompt of **Copy prompt** in the pill, for the open threads of one page. With `agent`, it is three lines: the page,
|
|
173
|
+
* the app in the Console to read the threads from, and what to do with them. Without it, the agent cannot read the
|
|
174
|
+
* threads, so the prompt is `commentsAgentPrompt()` with their text.
|
|
175
|
+
*/
|
|
176
|
+
export declare function commentsPagePrompt(input: CommentsAgentPromptInput): string;
|
|
125
177
|
/** A point in client (viewport) coordinates, such as `event.clientX` and `event.clientY`. */
|
|
126
178
|
interface AnchorPoint {
|
|
127
179
|
x: number;
|
|
@@ -393,14 +445,28 @@ export declare const commentsErrorDiagnostics: import("nostics").Diagnostics<{
|
|
|
393
445
|
}) => string;
|
|
394
446
|
readonly fix: "Start a thread on a page in this project.";
|
|
395
447
|
};
|
|
448
|
+
readonly COMMENTS_HOSTED_CONFLICT: {
|
|
449
|
+
why: string;
|
|
450
|
+
fix: string;
|
|
451
|
+
};
|
|
396
452
|
readonly COMMENTS_OUTBOX_ACCOUNT_CHANGED: {
|
|
397
453
|
why: string;
|
|
398
454
|
fix: string;
|
|
399
455
|
};
|
|
456
|
+
readonly COMMENTS_OUTBOX_RESOLVE_BLOCKED: {
|
|
457
|
+
why: string;
|
|
458
|
+
fix: string;
|
|
459
|
+
};
|
|
400
460
|
readonly COMMENTS_OUTBOX_SENDING: {
|
|
401
461
|
why: string;
|
|
402
462
|
fix: string;
|
|
403
463
|
};
|
|
464
|
+
readonly COMMENTS_OVERLAY_ELEMENT_TAKEN: {
|
|
465
|
+
why: ({ name }: {
|
|
466
|
+
name: string;
|
|
467
|
+
}) => string;
|
|
468
|
+
fix: string;
|
|
469
|
+
};
|
|
404
470
|
readonly COMMENTS_R0001: {
|
|
405
471
|
why: ({ target }: {
|
|
406
472
|
target: string;
|
|
@@ -688,6 +754,32 @@ interface CommentSendTransportOptions extends Pick<RestTransportOptions, "base"
|
|
|
688
754
|
export declare function createCommentSendTransport(options?: CommentSendTransportOptions): CommentSendTransport;
|
|
689
755
|
/** Lower case without accents, so `jose` finds `José`. Mention suggestions match names this way, in the browser and on the server. */
|
|
690
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
|
+
/** The guest name and id that this browser saved, the same one that the overlay uses. */
|
|
777
|
+
export declare function readCommentsGuest(): CommentsGuest | undefined;
|
|
778
|
+
/** Saves the name that a guest typed. The id stays when the guest saved a name before. */
|
|
779
|
+
export declare function saveCommentsGuest(name: string): CommentsGuest;
|
|
780
|
+
/** Calls `listener` each time `saveCommentsGuest()` saves a guest on this page. Returns a function that stops it. */
|
|
781
|
+
export declare function onCommentsGuestSaved(listener: (guest: CommentsGuest) => void): () => void;
|
|
782
|
+
export declare function commentsGuestUser(guest: CommentsGuest): CommentUser;
|
|
691
783
|
/**
|
|
692
784
|
* The id of the message that a reply with `requestId` stores in a thread. Every retry gets the same id, so the primary
|
|
693
785
|
* key of the messages refuses a second message, and the client's outbox finds the server copy of its waiting reply.
|
|
@@ -696,7 +788,8 @@ export declare function foldName(text: string): string;
|
|
|
696
788
|
export declare function replyMessageId(threadId: string, requestId: string): Promise<string>;
|
|
697
789
|
export type CommentsClientStatus = "idle" | "loading" | "ready" | "error";
|
|
698
790
|
export interface CommentsClientOptions {
|
|
699
|
-
|
|
791
|
+
/** Default: the Comments API of this app, as the signed-in user, or as the guest that `saveCommentsGuest()` saved. */
|
|
792
|
+
transport?: CommentsTransport;
|
|
700
793
|
/** The signed-in user. The UI uses it for the "mine" filter and to know which messages the user may edit. */
|
|
701
794
|
user?: CommentUser;
|
|
702
795
|
/** What `refresh()` lists. For example `{ page: "/pricing" }`. Without an explicit limit, loads all pages. */
|
|
@@ -704,8 +797,8 @@ export interface CommentsClientOptions {
|
|
|
704
797
|
/** Refresh when the window gets focus and the transport cannot push updates. Default `true`. */
|
|
705
798
|
refreshOnFocus?: boolean;
|
|
706
799
|
/**
|
|
707
|
-
*
|
|
708
|
-
* the network is back. Off by default: `create` and `reply` wait for the server.
|
|
800
|
+
* Shows each new comment and reply at once and saves it before it sends, so it survives a reload and goes out once
|
|
801
|
+
* when the network is back. Off by default: `create` and `reply` wait for the server.
|
|
709
802
|
*/
|
|
710
803
|
outbox?: CommentsOutboxOptions;
|
|
711
804
|
}
|
|
@@ -719,10 +812,13 @@ export interface CommentsClient {
|
|
|
719
812
|
query: CommentListQuery;
|
|
720
813
|
refresh: () => Promise<readonly CommentThread[]>;
|
|
721
814
|
get: (input: CommentGetInput) => Promise<CommentThread | null>;
|
|
722
|
-
/**
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
815
|
+
/**
|
|
816
|
+
* With an outbox, shows the comment at once. With no supplied `requestId`, returns the waiting thread before the save.
|
|
817
|
+
* With a supplied `requestId`, waits for the save to check for a replay. `files` may be a promise.
|
|
818
|
+
*/
|
|
819
|
+
create: (input: CommentCreateInput & CommentsClientFiles) => Promise<CommentThread>;
|
|
820
|
+
/** With an outbox, shows the reply at once. `requestId` and `files` work as they do for `create`. */
|
|
821
|
+
reply: (input: CommentReplyInput & CommentsClientFiles) => Promise<CommentThread>;
|
|
726
822
|
edit: (input: CommentEditInput) => Promise<CommentThread>;
|
|
727
823
|
delete: (input: CommentDeleteInput) => Promise<CommentThread | null>;
|
|
728
824
|
resolve: (input: CommentStatusInput) => Promise<CommentThread>;
|
|
@@ -745,5 +841,5 @@ export declare function createCommentsClient(options: CommentsClientOptions & {
|
|
|
745
841
|
}): CommentsClient & {
|
|
746
842
|
readonly outbox: CommentsOutbox;
|
|
747
843
|
};
|
|
748
|
-
export declare function createCommentsClient(options
|
|
749
|
-
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, CommentsAgentPromptInput, CommentsGuest, CommentsOutbox, CommentsOutboxEntry, CommentsOutboxEnvironment, CommentsOutboxMessage, CommentsOutboxOptions, CommentsOutboxStore, CommentsRestAnswer, CommentsRestRequest, CommentsTransport, CreateAnchorOptions, DetachedAnchor, ElementAnchor, ImageAnchor, PageAnchor, ResolvedAnchor, RestCommentThread, RestTransport, RestTransportOptions, TextAnchor };
|
|
844
|
+
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 };
|