@vite-hub/comments 0.0.0 → 0.1.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 (59) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +243 -0
  3. package/dist/anchor.d.ts +40 -0
  4. package/dist/anchor.js +128 -0
  5. package/dist/client.d.ts +101 -0
  6. package/dist/client.js +553 -0
  7. package/dist/console-BIz9t2cO.d.ts +243 -0
  8. package/dist/database/postgres.d.ts +1011 -0
  9. package/dist/database/postgres.js +60 -0
  10. package/dist/database-BSnVrwHn.js +60 -0
  11. package/dist/database-C-ktS9Do.js +95 -0
  12. package/dist/database-Cb2xjC1V.d.ts +1096 -0
  13. package/dist/database.d.ts +104 -0
  14. package/dist/database.js +3 -0
  15. package/dist/define-BzW2Ychn.d.ts +46 -0
  16. package/dist/define-Cbhl6QVJ.js +32 -0
  17. package/dist/errors-BAQYcy3_.d.ts +89 -0
  18. package/dist/errors-DeD6wTCl.js +77 -0
  19. package/dist/h3-v1-request-DDGXJ9E7.js +166 -0
  20. package/dist/identity-3qtVC4rF.js +34 -0
  21. package/dist/index-DklG2Etf.d.ts +111 -0
  22. package/dist/index.d.ts +7 -0
  23. package/dist/index.js +5 -0
  24. package/dist/operations-0B0QTVWX.d.ts +138 -0
  25. package/dist/operations-NZG5dB8y.js +732 -0
  26. package/dist/operations.d.ts +7 -0
  27. package/dist/operations.js +2 -0
  28. package/dist/overlay/overlay.js +195 -0
  29. package/dist/page/loader.js +22 -0
  30. package/dist/page-BtXADR6d.d.ts +21 -0
  31. package/dist/page-BuroSMXO.js +38 -0
  32. package/dist/page-tools-shared-D-amu6sx.js +53 -0
  33. package/dist/plugin-QElKQYkA.js +725 -0
  34. package/dist/realtime.d.ts +18 -0
  35. package/dist/realtime.js +48 -0
  36. package/dist/request-DVc3M_AG.js +14 -0
  37. package/dist/rpc.d.ts +29 -0
  38. package/dist/rpc.js +75 -0
  39. package/dist/runtime/auth.d.ts +6 -0
  40. package/dist/runtime/auth.js +15 -0
  41. package/dist/runtime/connect/node.d.ts +1 -0
  42. package/dist/runtime/connect/node.js +2 -0
  43. package/dist/runtime/connect.d.ts +1 -0
  44. package/dist/runtime/connect.js +2 -0
  45. package/dist/runtime/console.d.ts +5 -0
  46. package/dist/runtime/console.js +59 -0
  47. package/dist/runtime/index.d.ts +222 -0
  48. package/dist/runtime/index.js +665 -0
  49. package/dist/server-BomGg3Gb.js +63 -0
  50. package/dist/server.d.ts +94 -0
  51. package/dist/server.js +326 -0
  52. package/dist/src-CRTwnaEG.js +1362 -0
  53. package/dist/testing.d.ts +30 -0
  54. package/dist/testing.js +175 -0
  55. package/dist/types-Cj8K7Vx7.d.ts +176 -0
  56. package/dist/types-Un2dcJWD.d.ts +288 -0
  57. package/dist/vite.d.ts +304 -0
  58. package/dist/vite.js +1921 -0
  59. package/package.json +156 -4
@@ -0,0 +1,18 @@
1
+ import { x as CommentsUser } from "./types-Un2dcJWD.js";
2
+ import { t as Comments } from "./index-DklG2Etf.js";
3
+ import { H3Event } from "h3";
4
+ import { RealtimeDefinition } from "@vite-hub/realtime";
5
+ //#region src/realtime.d.ts
6
+ /**
7
+ * The Realtime Definition of the page presence rooms: who is on a page and where their cursor is. Rooms hold no
8
+ * document; threads stay in the Database. Connections are read-only, and the server binds account presence to the user
9
+ * that Comments resolves. Guests name themselves in the browser. ViteHub adds it as the `comments` definition when the
10
+ * host has a room authority.
11
+ */
12
+ export declare function commentsRealtime(comments: Comments, options?: {
13
+ /** Auth fallback, skipped when custom `identify` is configured. */
14
+ session?: (event: H3Event) => Promise<CommentsUser | null | undefined>;
15
+ /** Console section access, checked before custom `identify` or Comments policies. */
16
+ consoleSession?: (event: H3Event) => Promise<CommentsUser | null | undefined | false>;
17
+ }): RealtimeDefinition;
18
+ //#endregion
@@ -0,0 +1,48 @@
1
+ import { r as text } from "./identity-3qtVC4rF.js";
2
+ //#region src/realtime.ts
3
+ function toRealtimeUser(user) {
4
+ const result = { id: user.id };
5
+ const name = text(user.name) ?? text(user.email);
6
+ const email = text(user.email);
7
+ const image = text(user.image);
8
+ if (name) result.name = name;
9
+ if (email) result.email = email;
10
+ if (image) result.image = image;
11
+ return result;
12
+ }
13
+ /**
14
+ * The Realtime Definition of the page presence rooms: who is on a page and where their cursor is. Rooms hold no
15
+ * document; threads stay in the Database. Connections are read-only, and the server binds account presence to the user
16
+ * that Comments resolves. Guests name themselves in the browser. ViteHub adds it as the `comments` definition when the
17
+ * host has a room authority.
18
+ */
19
+ function commentsRealtime(comments, options = {}) {
20
+ const readers = /* @__PURE__ */ new WeakMap();
21
+ return {
22
+ async identify({ event }) {
23
+ const consoleUser = await options.consoleSession?.(event).catch(() => false);
24
+ if (consoleUser === false) {
25
+ readers.set(event, false);
26
+ return null;
27
+ }
28
+ const user = comments.options.identify ? await comments.options.identify({ event }) : options.consoleSession ? consoleUser : await options.session?.(event).catch(() => null);
29
+ readers.set(event, await comments.can({
30
+ user: user ?? null,
31
+ action: "read"
32
+ }));
33
+ return user && (comments.options.identify || user.guest !== true) ? toRealtimeUser(user) : null;
34
+ },
35
+ authorize: ({ event, mode }) => mode === "read" && readers.get(event) === true,
36
+ document: {
37
+ kind: "comments",
38
+ load: async () => ({
39
+ body: "",
40
+ digest: null
41
+ }),
42
+ save: async () => ({ digest: "comments" })
43
+ },
44
+ persistence: false
45
+ };
46
+ }
47
+ //#endregion
48
+ export { commentsRealtime };
@@ -0,0 +1,14 @@
1
+ import { r as toH3V1Request, t as isH3V1Event } from "./h3-v1-request-DDGXJ9E7.js";
2
+ //#region src/runtime/request.ts
3
+ /**
4
+ * The Web Request of an event. Nitro 3 events carry it as `req`; the H3 1 events of Nuxt 4's Nitro 2 carry Node's
5
+ * request instead, so this reads one from it.
6
+ */
7
+ function requestOf(event) {
8
+ const req = Reflect.get(event, "req");
9
+ if (req instanceof Request) return req;
10
+ if (isH3V1Event(event)) return toH3V1Request(event);
11
+ return event.req;
12
+ }
13
+ //#endregion
14
+ export { requestOf as t };
package/dist/rpc.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ import { y as CommentsTransport } from "./types-Cj8K7Vx7.js";
2
+ //#region src/operations-core/rpc.d.ts
3
+ export interface RpcTransportOptions {
4
+ /** The app origin and mount, such as `https://app.example.com` or `/portal`. Defaults to the page origin. */
5
+ base?: string;
6
+ /** Replaces `fetch`, for tests. */
7
+ fetch?: typeof fetch;
8
+ }
9
+ /** A failed operation, with the fields that every ViteHub surface reports. */
10
+ export declare class CommentsRpcError extends Error {
11
+ readonly code: string;
12
+ readonly fix?: string;
13
+ readonly status: number;
14
+ readonly details?: Record<string, unknown>;
15
+ constructor(failure: {
16
+ code: string;
17
+ details?: Record<string, unknown>;
18
+ fix?: string;
19
+ message: string;
20
+ status: number;
21
+ });
22
+ }
23
+ /**
24
+ * A transport over the operations RPC at `/_vitehub/rpc/__call`. The browser sends its session cookie, and the server
25
+ * runs `console.authorize` and the `authorize` of `server/comments.ts`. It has no `subscribe`: the client refreshes
26
+ * when the window gets focus.
27
+ */
28
+ export declare function createRpcTransport(options?: RpcTransportOptions): CommentsTransport;
29
+ //#endregion
package/dist/rpc.js ADDED
@@ -0,0 +1,75 @@
1
+ //#region src/operations-core/rpc.ts
2
+ /** A failed operation, with the fields that every ViteHub surface reports. */
3
+ var CommentsRpcError = class extends Error {
4
+ code;
5
+ fix;
6
+ status;
7
+ details;
8
+ constructor(failure) {
9
+ super(failure.message);
10
+ this.name = "CommentsRpcError";
11
+ this.code = failure.code;
12
+ this.status = failure.status;
13
+ if (failure.fix) this.fix = failure.fix;
14
+ if (failure.details) this.details = failure.details;
15
+ }
16
+ };
17
+ function isRecord(value) {
18
+ return value !== null && Object(value) === value && !Array.isArray(value);
19
+ }
20
+ /**
21
+ * A transport over the operations RPC at `/_vitehub/rpc/__call`. The browser sends its session cookie, and the server
22
+ * runs `console.authorize` and the `authorize` of `server/comments.ts`. It has no `subscribe`: the client refreshes
23
+ * when the window gets focus.
24
+ */
25
+ function createRpcTransport(options = {}) {
26
+ const base = (options.base ?? "").replace(/\/+$/, "");
27
+ async function call(operation, input) {
28
+ const send = options.fetch ?? globalThis.fetch;
29
+ let response;
30
+ try {
31
+ response = await send(`${base}/_vitehub/rpc/__call`, {
32
+ body: JSON.stringify({
33
+ operation,
34
+ input
35
+ }),
36
+ cache: "no-store",
37
+ credentials: "same-origin",
38
+ headers: {
39
+ "content-type": "application/json",
40
+ "x-vitehub-console": "1"
41
+ },
42
+ method: "POST"
43
+ });
44
+ } catch (cause) {
45
+ throw new CommentsRpcError({
46
+ code: "COMMENTS_R0013",
47
+ fix: "Check the connection and try again.",
48
+ message: `The request failed: ${cause instanceof Error ? cause.message : String(cause)}`,
49
+ status: 0
50
+ });
51
+ }
52
+ const body = await response.json().catch(() => void 0);
53
+ if (isRecord(body) && body.ok === true) return body.value;
54
+ throw new CommentsRpcError({
55
+ code: isRecord(body) && typeof body.code === "string" ? body.code : "COMMENTS_R0013",
56
+ message: isRecord(body) && typeof body.message === "string" ? body.message : `The server answered with HTTP ${response.status}.`,
57
+ status: isRecord(body) && typeof body.status === "number" ? body.status : response.status,
58
+ ...isRecord(body) && typeof body.fix === "string" ? { fix: body.fix } : {},
59
+ ...isRecord(body) && isRecord(body.details) ? { details: body.details } : {}
60
+ });
61
+ }
62
+ return {
63
+ create: (input) => call("comments.create", input),
64
+ delete: (input) => call("comments.delete", input),
65
+ edit: (input) => call("comments.edit", input),
66
+ get: (input) => call("comments.get", input),
67
+ list: (query) => call("comments.list", query),
68
+ reopen: (input) => call("comments.reopen", input),
69
+ reply: (input) => call("comments.reply", input),
70
+ resolve: (input) => call("comments.resolve", input),
71
+ users: (input) => call("comments.users", input)
72
+ };
73
+ }
74
+ //#endregion
75
+ export { CommentsRpcError, createRpcTransport };
@@ -0,0 +1,6 @@
1
+ import { x as CommentsUser } from "../types-Un2dcJWD.js";
2
+ import { H3Event } from "h3";
3
+ //#region src/runtime/auth.d.ts
4
+ /** The ViteHub Auth user of a request, or null. Generated Comments files pass it as `session` when the app has Auth. */
5
+ export declare function commentsAuthSession(event: H3Event): Promise<CommentsUser | null>;
6
+ //#endregion
@@ -0,0 +1,15 @@
1
+ import { t as requestOf } from "../request-DVc3M_AG.js";
2
+ import { getAuthForRequest } from "@vite-hub/auth/server";
3
+ //#region src/runtime/auth.ts
4
+ /** The ViteHub Auth user of a request, or null. Generated Comments files pass it as `session` when the app has Auth. */
5
+ async function commentsAuthSession(event) {
6
+ const request = requestOf(event);
7
+ const user = (await getAuthForRequest(request, void 0, event).api.getSession({ headers: request.headers }))?.user;
8
+ if (!user || typeof user !== "object" || !("id" in user) || typeof user.id !== "string") return null;
9
+ return {
10
+ ...user,
11
+ id: user.id
12
+ };
13
+ }
14
+ //#endregion
15
+ export { commentsAuthSession };
@@ -0,0 +1 @@
1
+ export * from "@vite-hub/database/connect/node";
@@ -0,0 +1,2 @@
1
+ export * from "@vite-hub/database/connect/node";
2
+ export {};
@@ -0,0 +1 @@
1
+ export * from "@vite-hub/database/connect";
@@ -0,0 +1,2 @@
1
+ export * from "@vite-hub/database/connect";
2
+ export {};
@@ -0,0 +1,5 @@
1
+ import { n as ViteHubConsoleRecord } from "../console-BIz9t2cO.js";
2
+ //#region src/runtime/console.d.ts
3
+ /** The threads of the app as Console records: open threads first, each group newest activity first. It runs on each Console request. */
4
+ export declare function readCommentsConsoleRecords(): Promise<ViteHubConsoleRecord[]>;
5
+ //#endregion
@@ -0,0 +1,59 @@
1
+ import { o as describeCommentContext } from "../src-CRTwnaEG.js";
2
+ import { n as commentsPageScope } from "../page-BuroSMXO.js";
3
+ import { n as installedComments } from "../plugin-QElKQYkA.js";
4
+ //#region src/runtime/console.ts
5
+ function excerpt(text) {
6
+ const line = text.replace(/\s+/g, " ").trim();
7
+ return line.length > 80 ? `${line.slice(0, 79)}…` : line;
8
+ }
9
+ /** The threads of the app as Console records: open threads first, each group newest activity first. It runs on each Console request. */
10
+ async function readCommentsConsoleRecords() {
11
+ const comments = installedComments();
12
+ if (!comments) return [];
13
+ const [error, threads] = await comments.list({
14
+ scope: commentsPageScope,
15
+ limit: 500
16
+ });
17
+ if (error) return [];
18
+ return [...threads.filter((thread) => thread.status === "open"), ...threads.filter((thread) => thread.status !== "open")].map((thread) => {
19
+ const first = thread.comments[0];
20
+ const author = (name, guest) => guest ? `${name} (guest)` : name;
21
+ return {
22
+ id: thread.id,
23
+ cells: {
24
+ comment: first ? excerpt(first.body) : "",
25
+ page: `\`${thread.page}\``,
26
+ author: author(thread.createdBy.name, thread.createdBy.guest),
27
+ replies: String(Math.max(0, thread.comments.length - 1)),
28
+ status: thread.status === "open" ? "Open" : "Resolved",
29
+ updated: thread.updatedAt
30
+ },
31
+ link: {
32
+ href: `${thread.page}?vitehub=comments#comment-${thread.id}`,
33
+ label: "Open on page"
34
+ },
35
+ activity: thread.comments.map((comment) => ({
36
+ author: author(comment.author.name, comment.author.guest),
37
+ at: comment.createdAt,
38
+ text: comment.body
39
+ })),
40
+ fields: [
41
+ {
42
+ label: "Page",
43
+ value: thread.page
44
+ },
45
+ ...thread.anchor ? [{
46
+ label: "Anchor",
47
+ value: thread.anchor.field ? `Content field ${thread.anchor.field}` : thread.anchor.label
48
+ }] : [],
49
+ ...describeCommentContext(thread.context),
50
+ ...thread.resolvedBy ? [{
51
+ label: "Resolved by",
52
+ value: thread.resolvedBy.name
53
+ }] : []
54
+ ]
55
+ };
56
+ });
57
+ }
58
+ //#endregion
59
+ export { readCommentsConsoleRecords };
@@ -0,0 +1,222 @@
1
+ import { o as CommentContext, p as CommentsAction, x as CommentsUser } from "../types-Un2dcJWD.js";
2
+ import { o as CommentsDatabase, t as Comments } from "../index-DklG2Etf.js";
3
+ import { H3Event, defineEventHandler } from "h3";
4
+ //#region src/runtime/github-login.d.ts
5
+ /** The Server Env names of the OAuth client that people sign in to Comments with: a GitHub App's, or an OAuth App's. */
6
+ export declare const githubLoginEnv: {
7
+ readonly clientId: "VITEHUB_GITHUB_CLIENT_ID";
8
+ readonly clientSecret: "VITEHUB_GITHUB_CLIENT_SECRET";
9
+ };
10
+ interface CommentsGitHubLogin {
11
+ /** Whether the server has the OAuth client, so the overlay offers **Sign in with GitHub**. */
12
+ configured(): boolean;
13
+ /** The person signed in with GitHub, with what they may do in the repository. Null without a session. */
14
+ user(event: H3Event): Promise<CommentsUser | null>;
15
+ /** The sign-in, callback, and sign-out routes under `/api/_vitehub/comments/auth/`. */
16
+ handle(event: H3Event, path: string): Promise<Response>;
17
+ }
18
+ /**
19
+ * Sign in with GitHub for Comments, with no database: ViteHub Auth's `stateless()` preset keeps the session, and the
20
+ * GitHub token, in encrypted cookies. A person may comment when GitHub says they can push to the repository of the
21
+ * build.
22
+ */
23
+ export declare function createCommentsGitHubLogin(options?: {
24
+ repository?: string;
25
+ apiUrl?: string;
26
+ fetch?: typeof fetch;
27
+ basePath?: string;
28
+ }): CommentsGitHubLogin;
29
+ //#endregion
30
+ //#region src/runtime/session.d.ts
31
+ interface CommentsSessionOptions {
32
+ /** Reads the ViteHub Auth user only when no custom `identify` is configured. */
33
+ session?: (event: H3Event) => Promise<CommentsUser | null | undefined>;
34
+ /**
35
+ * Checks Console section access for the action before custom `identify` or Comments policies. `false` or a failed
36
+ * check denies access; otherwise this is the user when no custom `identify` is configured.
37
+ */
38
+ consoleSession?: (event: H3Event, action?: CommentsAction) => Promise<CommentsUser | null | undefined | false>;
39
+ }
40
+ //#endregion
41
+ //#region src/runtime/handler.d.ts
42
+ /** One field address, as `parseContentField()` from `@vite-hub/content/client` reads it. */
43
+ interface CommentsContentField {
44
+ collection: string;
45
+ id?: string;
46
+ field: string;
47
+ }
48
+ interface ContentDocumentLike {
49
+ id: string;
50
+ data: Record<string, unknown>;
51
+ body?: string;
52
+ digest: string;
53
+ }
54
+ interface ContentCollectionLike {
55
+ readonly name: string;
56
+ readonly kind: "documents" | "singleton";
57
+ readonly id?: string;
58
+ readonly format: string;
59
+ get(id: string, options: {
60
+ ref: "draft";
61
+ }): Promise<ContentDocumentLike | null>;
62
+ save(id: string, input: {
63
+ data: Record<string, unknown>;
64
+ body?: string;
65
+ }, options: {
66
+ ifDigest: string;
67
+ message: string;
68
+ metadata: Record<string, string>;
69
+ }): Promise<ContentDocumentLike>;
70
+ }
71
+ /** The parts of a Content runtime that inline edits use: `content` from `server/content.ts`. */
72
+ interface CommentsContent {
73
+ can(context: {
74
+ user?: Record<string, unknown>;
75
+ collection: string;
76
+ action: "write";
77
+ id?: string;
78
+ }): Promise<boolean>;
79
+ collections(): readonly ContentCollectionLike[];
80
+ }
81
+ interface CommentsHandlerOptions extends CommentsSessionOptions {
82
+ comments: Comments;
83
+ /**
84
+ * Sign in with GitHub, for apps without their own sign-in: people who are not signed in another way see **Sign in
85
+ * with GitHub** in the overlay. It works once the server has a GitHub OAuth client.
86
+ */
87
+ githubLogin?: CommentsGitHubLogin;
88
+ /** Inline edits of Content fields. Omitted when the app has no Content collections. */
89
+ content?: {
90
+ runtime: CommentsContent;
91
+ parseField: (value: string) => CommentsContentField | undefined;
92
+ };
93
+ /** Whether the page presence rooms run, because the host has a Realtime authority. */
94
+ realtime: boolean;
95
+ /** The commit and branch of this build. New threads keep them in `context.build`. */
96
+ build?: NonNullable<CommentContext["build"]>;
97
+ /**
98
+ * The Vue files of the project by component name, relative to the project root. New threads get the files of each
99
+ * component that the overlay names, because production builds keep only the name.
100
+ */
101
+ components?: Readonly<Record<string, readonly string[]>>;
102
+ }
103
+ /**
104
+ * The Comments API at `/api/_vitehub/comments/**`. The overlay calls it; every route checks the `authorize` policy of
105
+ * `defineComments()` for the user of the request, and inline edits also check `content.can()`.
106
+ */
107
+ export declare function createCommentsHandler(options: CommentsHandlerOptions): ReturnType<typeof defineEventHandler>;
108
+ //#endregion
109
+ //#region src/runtime/plugin.d.ts
110
+ interface CommentsPluginOptions extends CommentsSessionOptions {
111
+ comments: Comments;
112
+ /** Offers GitHub sign-in or account switching through the overlay, even before read access is granted. */
113
+ githubLogin?: CommentsGitHubLogin;
114
+ /** The Database of `defineComments({ database })`, or undefined when the app has none. */
115
+ database: () => CommentsDatabase | undefined;
116
+ /**
117
+ * Path of the overlay script below the app base, such as `/api/_vitehub/comments/assets/overlay.js`. The page tools
118
+ * loader imports it for people that may read comments.
119
+ */
120
+ overlay: string;
121
+ /** The app base, such as `/portal/`. The page tools use it for the loader tag of Nitro 3 pages. Default: the root. */
122
+ base?: string;
123
+ /** Vite's serve/build identity, recorded by the generated plugin. Defaults to false. */
124
+ development?: boolean;
125
+ /** What the server log says when `database()` returns nothing. */
126
+ missingDatabase?: string;
127
+ }
128
+ /** The Comments definition that the Nitro plugin installed, for the Console reader. */
129
+ export declare function installedComments(): Comments | undefined;
130
+ /**
131
+ * The Nitro plugin of Comments. It connects the definition to its Database, and registers the overlay as the
132
+ * `comments` page tool: a visitor may load it when `authorize` allows `read` or GitHub sign-in is available.
133
+ */
134
+ export declare function defineCommentsPlugin(options: CommentsPluginOptions): (nitroApp: unknown) => void;
135
+ //#endregion
136
+ //#region src/runtime/console-session.d.ts
137
+ /** The parts of `consoleRealtimeAccess()` from `vite-hub/console/sections` that Comments reads. */
138
+ interface CommentsConsoleAccess {
139
+ identify(context: {
140
+ event: unknown;
141
+ }): Promise<{
142
+ id: string;
143
+ name?: string;
144
+ email?: string;
145
+ image?: string;
146
+ } | null>;
147
+ authorize(context: {
148
+ event: unknown;
149
+ kind?: "read" | "write";
150
+ }): Promise<boolean>;
151
+ user(context: {
152
+ event: unknown;
153
+ }): Promise<Record<string, unknown> | null>;
154
+ }
155
+ /**
156
+ * The user of a request from the Console access rules: the person must be allowed to use the Console `comments`
157
+ * section. People that the Console does not allow get `false`, which denies access before Comments guest policies.
158
+ * A Console without accounts, such as `console: { auth: false }` or the dev server, stays anonymous to policies.
159
+ * Guest authors name themselves in the overlay; their browser display data never becomes a policy user.
160
+ */
161
+ export declare function commentsConsoleSession(access: CommentsConsoleAccess): (event: H3Event, action?: CommentsAction) => Promise<CommentsUser | null | false>;
162
+ //#endregion
163
+ //#region ../internal/src/runtime/mcp-tools.d.ts
164
+ /** A JSON Schema object for the arguments of a tool. */
165
+ interface ViteHubMcpInputSchema {
166
+ type: "object";
167
+ properties: Record<string, Record<string, unknown>>;
168
+ required?: string[];
169
+ additionalProperties?: boolean;
170
+ }
171
+ /** What a tool call returns: text for the Agent, and the same data as JSON. */
172
+ interface ViteHubMcpToolResult {
173
+ text: string;
174
+ structured?: Record<string, unknown>;
175
+ isError?: boolean;
176
+ }
177
+ /** The checked caller of a tool. */
178
+ interface ViteHubMcpToolContext {
179
+ /** The checked user, with every field, or null for a caller without accounts. */
180
+ user: Record<string, unknown> | null;
181
+ /** The request event, when available, for owners that resolve request identity. */
182
+ event?: unknown;
183
+ }
184
+ /**
185
+ * One tool of the ViteHub MCP server at `/_vitehub/mcp`. An owner package registers its tools when the server starts.
186
+ * The server lists and runs a tool only for a person whose Console access includes the tool's `section`.
187
+ */
188
+ interface ViteHubMcpTool {
189
+ /** Snake case and prefixed with the owner, such as `comments_list_threads`. */
190
+ name: string;
191
+ title?: string;
192
+ description: string;
193
+ inputSchema: ViteHubMcpInputSchema;
194
+ /** Only `readOnlyHint: true` permits a read-only Console grant; other tools require full section access. */
195
+ annotations?: {
196
+ readOnlyHint?: boolean;
197
+ destructiveHint?: boolean;
198
+ idempotentHint?: boolean;
199
+ openWorldHint?: boolean;
200
+ };
201
+ /** The Console section whose access the tool needs, such as `comments`. */
202
+ section: string;
203
+ call(input: Record<string, unknown>, context: ViteHubMcpToolContext): Promise<ViteHubMcpToolResult>;
204
+ }
205
+ //#endregion
206
+ //#region src/runtime/mcp.d.ts
207
+ /**
208
+ * The Comments tools of the ViteHub MCP server. Each call resolves the Comments identity and checks `authorize`,
209
+ * as the overlay does. Pass the overlay's session reader; an app's own MCP server can instead supply `context.user`.
210
+ * With a request event, Console denial is final; otherwise `identify` takes precedence over the session user.
211
+ * Without an event, the tools use the checked `context.user` directly. Replies and resolves show that user as the author.
212
+ */
213
+ export declare function commentsMcpTools(comments: Comments, options?: CommentsSessionOptions): ViteHubMcpTool[];
214
+ //#endregion
215
+ //#region ../internal/src/runtime/page-tools.d.ts
216
+ /**
217
+ * The Nitro handler of `GET /_vitehub/page/session`. H3 2 and H3 1 both call a plain function with their event, so it
218
+ * serves Nitro 3 and Nitro 2.
219
+ */
220
+ export declare function viteHubPageSessionHandler(event: unknown): Promise<Response>;
221
+ //#endregion
222
+ export type { CommentsConsoleAccess, CommentsContent, CommentsContentField, CommentsGitHubLogin, CommentsHandlerOptions, CommentsPluginOptions };