tiptap-apcore 0.2.1 → 0.3.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 CHANGED
@@ -1,9 +1,12 @@
1
1
  # tiptap-apcore
2
2
 
3
- Let AI safely control your TipTap editor via the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) and OpenAI Function Calling.
3
+ > Let AI safely control your TipTap editor via the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) and OpenAI Function Calling.
4
4
 
5
5
  **tiptap-apcore** wraps every TipTap editor command as a schema-driven [APCore](https://github.com/aipartnerup) module — complete with JSON Schema validation, safety annotations, and fine-grained access control. Any MCP-compatible AI agent can then discover and invoke these modules to read, format, insert, or restructure rich-text content.
6
6
 
7
+ [![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
8
+ [![TipTap](https://img.shields.io/badge/TipTap-v2-green.svg)](https://tiptap.dev)
9
+
7
10
  ## Features
8
11
 
9
12
  - **79 built-in commands** across 7 categories (query, format, content, destructive, selection, history, unknown)
@@ -13,8 +16,9 @@ Let AI safely control your TipTap editor via the [Model Context Protocol (MCP)](
13
16
  - **Role-based ACL** — `readonly`, `editor`, `admin` roles with tag-level and module-level overrides
14
17
  - **Safety annotations** — every command tagged `readonly`, `destructive`, `idempotent`, `requiresApproval`, `openWorld`, `streaming`
15
18
  - **Strict JSON Schemas** — `inputSchema` + `outputSchema` with `additionalProperties: false` for all known commands
16
- - **Dynamic re-discovery** — call `registry.discover()` to pick up extensions added at runtime
17
- - **925 tests**, 99.7% statement coverage
19
+ - **Dynamic re-discovery** — call `apcore.refresh()` or `registry.discover()` to pick up extensions added at runtime
20
+ - **Dynamic ACL** — call `apcore.setAcl()` to switch roles without recreating the instance
21
+ - **Framework agnostic** — works with React, Vue, Angular, or Vanilla JS
18
22
 
19
23
  ## Installation
20
24
 
@@ -26,10 +30,12 @@ npm install tiptap-apcore apcore-js apcore-mcp @tiptap/core
26
30
 
27
31
  ## Quick Start
28
32
 
33
+ ### Using `TiptapAPCore` class (recommended)
34
+
29
35
  ```typescript
30
36
  import { Editor } from "@tiptap/core";
31
37
  import StarterKit from "@tiptap/starter-kit";
32
- import { withApcore, serve, toOpenaiTools } from "tiptap-apcore";
38
+ import { TiptapAPCore } from "tiptap-apcore";
33
39
 
34
40
  // 1. Create a TipTap editor
35
41
  const editor = new Editor({
@@ -37,22 +43,41 @@ const editor = new Editor({
37
43
  content: "<p>Hello world</p>",
38
44
  });
39
45
 
40
- // 2. Create APCore registry + executor
41
- const { registry, executor } = withApcore(editor, {
46
+ // 2. Create the APCore instance
47
+ const apcore = new TiptapAPCore(editor, {
42
48
  acl: { role: "editor" }, // no destructive ops
43
49
  });
44
50
 
45
- // 3a. Launch an MCP Server (stdio)
46
- await serve(executor);
51
+ // 3. Call commands directly
52
+ await apcore.call("tiptap.format.toggleBold", {});
53
+ const { html } = await apcore.call("tiptap.query.getHTML", {});
47
54
 
48
- // 3b. Or export OpenAI tool definitions
49
- const tools = toOpenaiTools(executor);
55
+ // 4. Switch roles at runtime (e.g. when user toggles admin mode)
56
+ apcore.setAcl({ role: "admin" });
57
+
58
+ // 5. Launch an MCP Server (Node.js only — import from tiptap-apcore/server)
59
+ import { serve } from "tiptap-apcore/server";
60
+ await serve(apcore.executor);
61
+
62
+ // 6. Or export OpenAI tool definitions
63
+ import { toOpenaiTools } from "tiptap-apcore/server";
64
+ const tools = toOpenaiTools(apcore.executor);
65
+ ```
66
+
67
+ ### Using `withApcore` factory (shortcut)
68
+
69
+ ```typescript
70
+ import { withApcore } from "tiptap-apcore";
71
+
72
+ const { registry, executor } = withApcore(editor, {
73
+ acl: { role: "editor" },
74
+ });
50
75
 
51
- // 3c. Or call commands directly
52
76
  await executor.call("tiptap.format.toggleBold", {});
53
- const { html } = await executor.call("tiptap.query.getHTML", {});
54
77
  ```
55
78
 
79
+ `withApcore` returns a `{ registry, executor }` pair. Use it when you don't need dynamic ACL updates or the convenience methods on `TiptapAPCore`.
80
+
56
81
  ## Commands
57
82
 
58
83
  All commands follow the module ID pattern `{prefix}.{category}.{commandName}`.
@@ -100,24 +125,27 @@ Commands discovered from extensions but not in the built-in catalog. Excluded by
100
125
 
101
126
  ```typescript
102
127
  // Read-only: only query commands
103
- withApcore(editor, { acl: { role: "readonly" } });
128
+ new TiptapAPCore(editor, { acl: { role: "readonly" } });
104
129
 
105
130
  // Editor: query + format + content + history + selection
106
- withApcore(editor, { acl: { role: "editor" } });
131
+ new TiptapAPCore(editor, { acl: { role: "editor" } });
107
132
 
108
133
  // Admin: everything including destructive
109
- withApcore(editor, { acl: { role: "admin" } });
134
+ new TiptapAPCore(editor, { acl: { role: "admin" } });
110
135
 
111
136
  // Custom: readonly base + allow format tag
112
- withApcore(editor, { acl: { role: "readonly", allowTags: ["format"] } });
137
+ new TiptapAPCore(editor, { acl: { role: "readonly", allowTags: ["format"] } });
113
138
 
114
139
  // Custom: admin but deny destructive tag
115
- withApcore(editor, { acl: { role: "admin", denyTags: ["destructive"] } });
140
+ new TiptapAPCore(editor, { acl: { role: "admin", denyTags: ["destructive"] } });
116
141
 
117
142
  // Module-level: deny specific commands
118
- withApcore(editor, {
143
+ new TiptapAPCore(editor, {
119
144
  acl: { role: "admin", denyModules: ["tiptap.destructive.clearContent"] },
120
145
  });
146
+
147
+ // Dynamic: switch roles at runtime
148
+ apcore.setAcl({ role: "admin" });
121
149
  ```
122
150
 
123
151
  **Precedence:** `denyModules` > `allowModules` > `denyTags` > `allowTags` > role
@@ -126,32 +154,80 @@ withApcore(editor, {
126
154
 
127
155
  ## MCP Server
128
156
 
157
+ Server functions must be imported from the `tiptap-apcore/server` subpath (Node.js only).
158
+
129
159
  ```typescript
130
- import { withApcore, serve } from "tiptap-apcore";
160
+ import { TiptapAPCore } from "tiptap-apcore";
161
+ import { serve } from "tiptap-apcore/server";
131
162
 
132
- const { executor } = withApcore(editor);
163
+ const apcore = new TiptapAPCore(editor);
133
164
 
134
165
  // stdio (default)
135
- await serve(executor);
166
+ await serve(apcore.executor);
136
167
 
137
168
  // HTTP streaming
138
- await serve(executor, {
169
+ await serve(apcore.executor, {
139
170
  transport: "streamable-http",
140
171
  host: "127.0.0.1",
141
172
  port: 8000,
142
173
  });
143
174
 
144
175
  // Server-Sent Events
145
- await serve(executor, { transport: "sse", port: 3000 });
176
+ await serve(apcore.executor, { transport: "sse", port: 3000 });
177
+ ```
178
+
179
+ ### Embedding in Express / Koa / Fastify (`asyncServe`)
180
+
181
+ `asyncServe` returns a Node.js HTTP request handler that you can mount in any existing server — no separate process needed.
182
+
183
+ ```typescript
184
+ import express from "express";
185
+ import { TiptapAPCore } from "tiptap-apcore";
186
+ import { asyncServe } from "tiptap-apcore/server";
187
+
188
+ const app = express();
189
+ const apcore = new TiptapAPCore(editor, { acl: { role: "admin" } });
190
+
191
+ // Create the MCP handler with the built-in Tool Explorer UI
192
+ const { handler, close } = await asyncServe(apcore.executor, {
193
+ endpoint: "/mcp", // MCP protocol endpoint
194
+ explorer: true, // Enable /explorer UI for interactive testing
195
+ explorerPrefix: "/explorer",
196
+ allowExecute: true, // Allow tool execution from the explorer
197
+ name: "my-editor-mcp",
198
+ });
199
+
200
+ // Mount alongside your existing routes
201
+ app.all("/mcp", (req, res) => handler(req, res));
202
+ app.all("/explorer", (req, res) => handler(req, res));
203
+ app.all("/explorer/*", (req, res) => handler(req, res));
204
+
205
+ app.listen(8000);
206
+
207
+ // On shutdown:
208
+ await close();
209
+ ```
210
+
211
+ MCP clients (Claude Desktop, Cursor, etc.) can then connect to your server:
212
+
213
+ ```json
214
+ {
215
+ "mcpServers": {
216
+ "my-editor": {
217
+ "url": "http://localhost:8000/mcp"
218
+ }
219
+ }
220
+ }
146
221
  ```
147
222
 
148
223
  ## OpenAI Function Calling
149
224
 
150
225
  ```typescript
151
- import { withApcore, toOpenaiTools } from "tiptap-apcore";
226
+ import { TiptapAPCore } from "tiptap-apcore";
227
+ import { toOpenaiTools } from "tiptap-apcore/server";
152
228
 
153
- const { executor } = withApcore(editor);
154
- const tools = toOpenaiTools(executor);
229
+ const apcore = new TiptapAPCore(editor);
230
+ const tools = toOpenaiTools(apcore.executor);
155
231
 
156
232
  // Use with OpenAI API
157
233
  const response = await openai.chat.completions.create({
@@ -168,18 +244,18 @@ APCore's JSON schemas work directly with AI SDK's `jsonSchema()` — no Zod conv
168
244
  ```typescript
169
245
  import { generateText, tool, jsonSchema } from "ai";
170
246
  import { openai } from "@ai-sdk/openai";
171
- import { withApcore } from "tiptap-apcore";
247
+ import { TiptapAPCore } from "tiptap-apcore";
172
248
 
173
- const { registry, executor } = withApcore(editor, { acl: { role: "editor" } });
249
+ const apcore = new TiptapAPCore(editor, { acl: { role: "editor" } });
174
250
 
175
251
  // Convert APCore modules to AI SDK tools
176
252
  const tools: Record<string, CoreTool> = {};
177
- for (const id of registry.list()) {
178
- const def = registry.getDefinition(id)!;
179
- tools[id.replaceAll(".", "-")] = tool({
253
+ for (const id of apcore.list()) {
254
+ const def = apcore.getDefinition(id)!;
255
+ tools[id.replaceAll(".", "--")] = tool({
180
256
  description: def.description,
181
257
  parameters: jsonSchema(def.inputSchema),
182
- execute: (args) => executor.call(id, args),
258
+ execute: (args) => apcore.call(id, args),
183
259
  });
184
260
  }
185
261
 
@@ -194,15 +270,35 @@ const { text, steps } = await generateText({
194
270
 
195
271
  ## API Reference
196
272
 
197
- ### `withApcore(editor, options?)`
273
+ ### `TiptapAPCore` class
198
274
 
199
- Creates an APCore `{ registry, executor }` pair from a TipTap editor.
275
+ The primary entry point. Encapsulates registry, executor, ACL, and extension discovery.
276
+
277
+ ```typescript
278
+ const apcore = new TiptapAPCore(editor, options?);
279
+ ```
200
280
 
201
281
  | Option | Type | Default | Description |
202
282
  |--------|------|---------|-------------|
203
283
  | `prefix` | `string` | `"tiptap"` | Module ID prefix (lowercase alphanumeric) |
204
284
  | `acl` | `AclConfig` | `undefined` | Access control configuration (permissive if omitted) |
205
285
  | `includeUnsafe` | `boolean` | `false` | Include commands not in the built-in catalog |
286
+ | `logger` | `Logger` | `undefined` | Logger for diagnostic output |
287
+ | `sanitizeHtml` | `(html: string) => string` | `undefined` | HTML sanitizer for insertContent/setContent |
288
+
289
+ | Method / Property | Description |
290
+ |-------------------|-------------|
291
+ | `registry` | The APCore Registry (read-only) |
292
+ | `executor` | The APCore Executor (read-only) |
293
+ | `call(moduleId, inputs)` | Execute a command (async) |
294
+ | `list(options?)` | List module IDs, optionally filtered by `tags` and/or `prefix` |
295
+ | `getDefinition(moduleId)` | Get full `ModuleDescriptor` or `null` |
296
+ | `setAcl(acl)` | Update ACL configuration at runtime (validates role) |
297
+ | `refresh()` | Re-scan extensions and update registry; returns module count |
298
+
299
+ ### `withApcore(editor, options?)`
300
+
301
+ Factory function that creates a `TiptapAPCore` instance and returns `{ registry, executor }`. Accepts the same options as `TiptapAPCore`.
206
302
 
207
303
  ### Registry Methods
208
304
 
@@ -223,9 +319,24 @@ Creates an APCore `{ registry, executor }` pair from a TipTap editor.
223
319
  |--------|-------------|
224
320
  | `call(moduleId, inputs)` | Execute a module (async) |
225
321
  | `callAsync(moduleId, inputs)` | Alias for `call()` |
322
+ | `registry` | Access the underlying registry |
226
323
 
227
324
  ### Error Codes
228
325
 
326
+ All errors are instances of `TiptapModuleError` (extends `Error`).
327
+
328
+ ```typescript
329
+ import { TiptapModuleError, ErrorCodes } from "tiptap-apcore";
330
+
331
+ try {
332
+ await apcore.call("tiptap.format.toggleBold", {});
333
+ } catch (err) {
334
+ if (err instanceof TiptapModuleError) {
335
+ console.log(err.code, err.message, err.details);
336
+ }
337
+ }
338
+ ```
339
+
229
340
  | Code | Description |
230
341
  |------|-------------|
231
342
  | `MODULE_NOT_FOUND` | Module ID not registered |
@@ -236,96 +347,56 @@ Creates an APCore `{ registry, executor }` pair from a TipTap editor.
236
347
  | `SCHEMA_VALIDATION_ERROR` | Invalid options (bad prefix, bad role) |
237
348
  | `INTERNAL_ERROR` | Unexpected error |
238
349
 
239
- ## Comparison with TipTap AI Toolkit
240
-
241
- TipTap's official AI solution is the **[AI Toolkit](https://tiptap.dev/docs/ai-toolkit/getting-started/overview)** (`@tiptap-pro/ai-toolkit`), a paid extension for client-side AI-powered editing. The two projects serve different use cases and are complementary.
242
-
243
- ### Architecture
244
-
245
- | | TipTap AI Toolkit | tiptap-apcore |
246
- |---|---|---|
247
- | **Type** | Client-side TipTap extension | Server-side / headless adapter |
248
- | **License** | Proprietary (TipTap Pro subscription) | Apache-2.0 (open source) |
249
- | **Runtime** | Browser only | Browser + Node.js + headless |
250
- | **Protocol** | Provider-specific adapters | MCP standard + OpenAI Function Calling |
251
- | **Approach** | AI generates content, streams into editor | AI invokes structured commands on editor |
252
-
253
- ### Command Granularity
254
-
255
- | | TipTap AI Toolkit | tiptap-apcore |
256
- |---|---|---|
257
- | **Tools exposed** | 5 coarse tools | 79+ fine-grained commands |
258
- | **Read** | `tiptapRead`, `tiptapReadSelection` | `getHTML`, `getJSON`, `getText`, `isActive`, `getAttributes`, `isEmpty`, `isEditable`, `isFocused`, `getCharacterCount`, `getWordCount` |
259
- | **Write** | `tiptapEdit` (accepts operations array) | Individual commands: `toggleBold`, `insertContent`, `setNode`, `wrapIn`, ... |
260
- | **Comments** | `getThreads`, `editThreads` | Not supported |
261
- | **Schemas** | Tool parameters with descriptions | Strict JSON Schema per command (`additionalProperties: false`) |
262
-
263
- The AI Toolkit bundles all editing into a single `tiptapEdit` tool that accepts an array of operations. tiptap-apcore exposes each operation as a standalone tool with its own schema — this gives the LLM more precise tool selection and lower token usage per call.
264
-
265
- ### Security
350
+ ### Server Exports (`tiptap-apcore/server`)
266
351
 
267
- | | TipTap AI Toolkit | tiptap-apcore |
268
- |---|---|---|
269
- | **Access control** | None built-in | 3 roles + tag/module allow/deny lists |
270
- | **Safety annotations** | None | `readonly`, `destructive`, `idempotent`, `requiresApproval`, `openWorld`, `streaming` per command |
271
- | **Approval workflow** | Review mode (accept/reject UI) | `requiresApproval` annotation for MCP clients |
272
- | **Input validation** | Basic parameter types | Strict JSON Schema with `additionalProperties: false` |
352
+ | Function | Description |
353
+ |----------|-------------|
354
+ | `serve(executor, options?)` | Launch an MCP server (stdio / streamable-http / sse) |
355
+ | `asyncServe(executor, options?)` | Build an embeddable HTTP handler returns `{ handler, close }` |
356
+ | `toOpenaiTools(executor, options?)` | Export OpenAI Function Calling tool definitions |
357
+ | `resolveRegistry(executor)` | Access the registry from an executor |
358
+ | `resolveExecutor(registry)` | Create an executor from a registry |
273
359
 
274
- ### Protocol Support
360
+ #### `asyncServe` Options
275
361
 
276
- | | TipTap AI Toolkit | tiptap-apcore |
277
- |---|---|---|
278
- | **MCP** | Not supported | stdio, streamable-http, SSE |
279
- | **OpenAI** | Via adapter (`@tiptap-pro/ai-adapter-openai`) | `toOpenaiTools()` one-liner |
280
- | **Anthropic** | Via adapter (`@tiptap-pro/ai-adapter-anthropic`) | Via MCP (any MCP client) |
281
- | **Vercel AI SDK** | Via adapter | Direct (`generateText` + `tool` + `jsonSchema`) or via MCP |
282
- | **Custom agents** | Adapter required per provider | Any MCP-compatible agent works |
362
+ | Option | Type | Default | Description |
363
+ |--------|------|---------|-------------|
364
+ | `name` | `string` | `"apcore-mcp"` | MCP server name |
365
+ | `endpoint` | `string` | `"/mcp"` | MCP protocol endpoint path |
366
+ | `explorer` | `boolean` | `false` | Enable the browser-based Tool Explorer UI |
367
+ | `explorerPrefix` | `string` | `"/explorer"` | URL prefix for the explorer |
368
+ | `allowExecute` | `boolean` | `false` | Allow tool execution from the explorer UI |
369
+ | `validateInputs` | `boolean` | `false` | Validate inputs against JSON schemas |
370
+ | `tags` | `string[]` | `null` | Filter modules by tags |
371
+ | `prefix` | `string` | `null` | Filter modules by prefix |
283
372
 
284
- ### AI Content Generation
373
+ `asyncServe` returns `{ handler, close }` where `handler` is `(IncomingMessage, ServerResponse) => Promise<void>`.
285
374
 
286
- | | TipTap AI Toolkit | tiptap-apcore |
287
- |---|---|---|
288
- | **Streaming output** | `streamText()`, `streamHtml()` | Not yet supported |
289
- | **Review mode** | Accept / Reject UI | Not supported (planned) |
290
- | **Content generation** | Built-in (prompts → editor) | Delegated to LLM (tool use → commands) |
375
+ ## Architecture
291
376
 
292
- The AI Toolkit streams LLM-generated content directly into the editor with a review UI. tiptap-apcore takes a different approach: the LLM decides *which commands* to call, and the executor applies them. Content generation is the LLM's responsibility, not the editor's.
377
+ ```
378
+ ┌──────────────────┐ ┌──────────────────┐ ┌──────────────┐
379
+ │ TipTap Editor │────▶│ tiptap-apcore │────▶│ apcore-mcp │
380
+ │ (@tiptap/core) │ │ (this package) │ │ (protocol) │
381
+ └──────────────────┘ └──────────────────┘ └──────────────┘
382
+ Registry + Executor MCP / OpenAI
383
+ ```
293
384
 
294
- ### Server-Side & Headless
385
+ **tiptap-apcore provides:**
386
+ - Extension discovery (`ExtensionScanner`)
387
+ - Module building (`ModuleBuilder` + `AnnotationCatalog` + `SchemaCatalog`)
388
+ - Command execution (`TiptapExecutor`)
389
+ - Access control (`AclGuard`)
295
390
 
296
- | | TipTap AI Toolkit | tiptap-apcore |
297
- |---|---|---|
298
- | **Headless mode** | Not supported | Full support |
299
- | **Batch processing** | Not possible | Process multiple documents programmatically |
300
- | **CI/CD pipelines** | Not applicable | Can validate, transform, or test content |
301
- | **Multi-tenant** | One editor per user | One executor per editor, server-side isolation |
302
-
303
- ### When to Use Which
304
-
305
- **Use TipTap AI Toolkit when:**
306
- - You need real-time streaming of AI-generated content into the editor
307
- - You want a built-in accept/reject review UI
308
- - You're building a client-side-only application
309
- - You need comment thread management with AI
310
-
311
- **Use tiptap-apcore when:**
312
- - You want any MCP-compatible agent to control the editor
313
- - You need fine-grained access control (roles, tag/module blocking)
314
- - You're running headless / server-side (batch processing, CI/CD)
315
- - You want strict schema validation and safety annotations
316
- - You need to support multiple AI providers without per-provider adapters
317
- - You want open-source with no licensing fees
318
-
319
- **Use both when:**
320
- - You want streaming AI content generation (AI Toolkit) AND structured command control (tiptap-apcore) in the same application
321
- - You want client-side AI chat + server-side AI automation on the same editor
391
+ **apcore-mcp provides:**
392
+ - `serve(executor)` — Launch an MCP server (stdio / HTTP / SSE)
393
+ - `toOpenaiTools(executor)` Export OpenAI Function Calling tool definitions
394
+ - Types and constants for the APCore protocol
322
395
 
323
396
  ## AI Capabilities
324
397
 
325
398
  ### Supported (79 commands)
326
399
 
327
- tiptap-apcore exposes 79 built-in commands that an AI agent can invoke:
328
-
329
400
  | Category | Count | Commands |
330
401
  |----------|-------|----------|
331
402
  | **Query** | 10 | `getHTML`, `getJSON`, `getText`, `isActive`, `getAttributes`, `isEmpty`, `isEditable`, `isFocused`, `getCharacterCount`, `getWordCount` |
@@ -348,58 +419,66 @@ The `selectText` command enables semantic text selection — the AI can select t
348
419
  | Streaming content generation | Content generation is delegated to the LLM; the executor applies discrete commands |
349
420
  | Comment threads | Not part of core TipTap — requires `@tiptap-pro` extensions |
350
421
 
351
- ## Architecture
422
+ ## Comparison with TipTap AI Toolkit
352
423
 
353
- ### tiptap-apcore vs apcore-mcp
424
+ TipTap's official AI solution is the **[AI Toolkit](https://tiptap.dev/docs/ai-toolkit/getting-started/overview)** (`@tiptap-pro/ai-toolkit`), a paid extension for client-side AI-powered editing. The two projects serve different use cases and are complementary.
354
425
 
355
- **tiptap-apcore** is the TipTap adapter that wraps editor commands as APCore modules. **apcore-mcp** is the protocol layer that exposes those modules to AI agents via MCP or OpenAI Function Calling.
426
+ | | TipTap AI Toolkit | tiptap-apcore |
427
+ |---|---|---|
428
+ | **Type** | Client-side TipTap extension | Server-side / headless adapter |
429
+ | **License** | Proprietary (TipTap Pro subscription) | Apache-2.0 (open source) |
430
+ | **Runtime** | Browser only | Browser + Node.js + headless |
431
+ | **Protocol** | Provider-specific adapters | MCP standard + OpenAI Function Calling |
432
+ | **Tools exposed** | 5 coarse tools | 79+ fine-grained commands |
433
+ | **Access control** | None built-in | 3 roles + tag/module allow/deny lists |
434
+ | **Safety annotations** | None | `readonly`, `destructive`, `idempotent`, `requiresApproval` per command |
435
+ | **Streaming output** | `streamText()`, `streamHtml()` | Not yet supported |
436
+ | **Headless mode** | Not supported | Full support |
356
437
 
357
- ```
358
- ┌──────────────────┐ ┌──────────────────┐ ┌──────────────┐
359
- │ TipTap Editor │────▶│ tiptap-apcore │────▶│ apcore-mcp │
360
- │ (@tiptap/core) │ │ (this package) │ │ (protocol) │
361
- └──────────────────┘ └──────────────────┘ └──────────────┘
362
- Registry + Executor MCP / OpenAI
363
- ```
438
+ **Use TipTap AI Toolkit when** you need real-time streaming of AI-generated content with a built-in accept/reject review UI.
364
439
 
365
- **tiptap-apcore provides:**
366
- - Extension discovery (`ExtensionScanner`)
367
- - Module building (`ModuleBuilder` + `AnnotationCatalog` + `SchemaCatalog`)
368
- - Command execution (`TiptapExecutor`)
369
- - Access control (`AclGuard`)
440
+ **Use tiptap-apcore when** you want any MCP-compatible agent to control the editor with fine-grained access control, strict schema validation, and headless/server-side support.
370
441
 
371
- **apcore-mcp provides:**
372
- - `serve(executor)` — Launch an MCP server (stdio / HTTP / SSE)
373
- - `toOpenaiTools(executor)` — Export OpenAI Function Calling tool definitions
374
- - `resolveRegistry(executor)` — Access the registry from an executor
375
- - `resolveExecutor(registry)` — Create an executor from a registry
376
- - Types and constants for the APCore protocol
442
+ **Use both** when you want streaming AI content generation AND structured command control in the same application.
377
443
 
378
444
  ## Demo
379
445
 
380
- The `demo/` directory contains a full-stack example: a React + Vite frontend with a TipTap editor, and an Express backend that uses the [Vercel AI SDK](https://ai-sdk.dev/) to let any LLM edit the document via APCore tools.
446
+ The `demo/` directory contains a full-stack example with two modes:
381
447
 
382
448
  ```bash
383
449
  cd demo/server && npm install && npm run dev # Terminal 1
384
- cd demo && npm install && npm run dev # Terminal 2
450
+ cd demo/frontend && npm install && npm run dev # Terminal 2
451
+ # Open http://localhost:5173
385
452
  ```
386
453
 
387
454
  Set `LLM_MODEL` (e.g. `openai:gpt-4o`, `anthropic:claude-sonnet-4-5`) in `demo/.env`. See [`demo/README.md`](demo/README.md) for details.
388
455
 
389
- ## Development
456
+ ### AI Editor Demo tab
390
457
 
391
- ```bash
392
- # Install dependencies
393
- npm install
458
+ A React + Vite frontend with a TipTap editor and an Express backend that uses the [Vercel AI SDK](https://ai-sdk.dev/) to let any LLM edit the document via APCore tools. Includes role-based ACL switching, demo scenarios, and a tool call log.
459
+
460
+ ### MCP Server tab
461
+
462
+ A persistent headless TipTap editor exposed as an MCP `streamable-http` endpoint via `asyncServe()`. The tab shows:
463
+
464
+ - **Status** — live server status, tool count, and endpoint URL
465
+ - **Tool Explorer** — embedded `/explorer` UI for browsing and executing all 79+ tools interactively
466
+ - **Connect** — copy-paste config snippets for Claude Desktop, Cursor, and generic MCP clients
394
467
 
395
- # Run tests
396
- npm test
468
+ The MCP endpoint is available at `http://localhost:8000/mcp` — connect any MCP client to control the editor remotely.
397
469
 
398
- # Type check
399
- npm run typecheck
470
+ ## Documentation
400
471
 
401
- # Build
402
- npm run build
472
+ - [Getting Started Guide](docs/GETTING_STARTED.md) — React integration, ACL roles, MCP and AI SDK setup.
473
+ - [Technical Design](docs/tiptap-apcore/tech-design.md) — Architecture, security model, and design decisions.
474
+
475
+ ## Development
476
+
477
+ ```bash
478
+ npm install # Install dependencies
479
+ npm test # Run tests
480
+ npm run typecheck # Type check
481
+ npm run build # Build
403
482
  ```
404
483
 
405
484
  ## License
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@
9
9
  * - toOpenaiTools(registryOrExecutor, options?) - Export OpenAI tool definitions
10
10
  */
11
11
  export { withApcore } from "./withApcore.js";
12
+ export { TiptapAPCore } from "./runtime/TiptapAPCore.js";
12
13
  export type { ApcoreOptions, ApcoreResult, AclConfig, ExtensionCommandInfo, AnnotationEntry, SelectionEffect, SchemaEntry, Logger, EditorLike, ChainLike, Registry, Executor, ModuleDescriptor, ModuleAnnotations, JsonSchema, } from "./types.js";
13
14
  export { TiptapModuleError, ErrorCodes } from "./errors/index.js";
14
15
  export { TiptapRegistry } from "./runtime/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EACV,aAAa,EACb,YAAY,EACZ,SAAS,EACT,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,WAAW,EACX,MAAM,EACN,UAAU,EACV,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG/C,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,YAAY,EACV,aAAa,EACb,YAAY,EACZ,SAAS,EACT,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,WAAW,EACX,MAAM,EACN,UAAU,EACV,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG/C,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -9,6 +9,7 @@
9
9
  * - toOpenaiTools(registryOrExecutor, options?) - Export OpenAI tool definitions
10
10
  */
11
11
  export { withApcore } from "./withApcore.js";
12
+ export { TiptapAPCore } from "./runtime/TiptapAPCore.js";
12
13
  export { TiptapModuleError, ErrorCodes } from "./errors/index.js";
13
14
  export { TiptapRegistry } from "./runtime/index.js";
14
15
  export { TiptapExecutor } from "./runtime/index.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAkB7C,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAW/C,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAkBzD,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAW/C,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,61 @@
1
+ import type { ApcoreOptions, EditorLike, AclConfig, ModuleDescriptor } from "../types.js";
2
+ import { TiptapRegistry } from "./TiptapRegistry.js";
3
+ import { TiptapExecutor } from "./TiptapExecutor.js";
4
+ /**
5
+ * TiptapAPCore - Unified entry point for TipTap editor AI control.
6
+ *
7
+ * This class encapsulates the registry, executor, and discovery logic,
8
+ * providing a simplified API for developers.
9
+ */
10
+ export declare class TiptapAPCore {
11
+ private _editor;
12
+ private _options;
13
+ private _registry;
14
+ private _executor;
15
+ private _aclGuard;
16
+ private _scanner;
17
+ private _builder;
18
+ constructor(editor: EditorLike, options?: ApcoreOptions);
19
+ /** The APCore Registry containing all discovered module definitions */
20
+ get registry(): TiptapRegistry;
21
+ /** The APCore Executor for running commands against the editor */
22
+ get executor(): TiptapExecutor;
23
+ /**
24
+ * Execute an editor command via APCore.
25
+ *
26
+ * @param moduleId - The module ID (e.g., 'tiptap.format.toggleBold')
27
+ * @param inputs - Input arguments for the command
28
+ * @returns The execution result
29
+ */
30
+ call(moduleId: string, inputs: Record<string, unknown>): Promise<Record<string, unknown>>;
31
+ /**
32
+ * List available modules in the registry.
33
+ *
34
+ * @param options - Optional filters (tags, prefix)
35
+ * @returns Array of module IDs
36
+ */
37
+ list(options?: {
38
+ tags?: string[];
39
+ prefix?: string;
40
+ }): string[];
41
+ /**
42
+ * Get the full definition of a module.
43
+ *
44
+ * @param moduleId - The module ID to look up
45
+ * @returns The module descriptor or null if not found
46
+ */
47
+ getDefinition(moduleId: string): ModuleDescriptor | null;
48
+ /**
49
+ * Update the ACL configuration without recreating the instance.
50
+ *
51
+ * @param acl - The new ACL configuration
52
+ */
53
+ setAcl(acl: AclConfig): void;
54
+ /**
55
+ * Trigger a re-scan of TipTap extensions to update the registry.
56
+ *
57
+ * @returns The number of modules discovered
58
+ */
59
+ refresh(): number;
60
+ }
61
+ //# sourceMappingURL=TiptapAPCore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TiptapAPCore.d.ts","sourceRoot":"","sources":["../../src/runtime/TiptapAPCore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EACV,SAAS,EACT,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAMrD;;;;;GAKG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,CAAC,QAAQ,CAAmB;IACnC,OAAO,CAAC,QAAQ,CAAgB;gBAEpB,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,aAAa;IAyDvD,uEAAuE;IACvE,IAAI,QAAQ,IAAI,cAAc,CAE7B;IAED,kEAAkE;IAClE,IAAI,QAAQ,IAAI,cAAc,CAE7B;IAED;;;;;;OAMG;IACG,IAAI,CACR,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAInC;;;;;OAKG;IACH,IAAI,CAAC,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,EAAE;IAI9D;;;;;OAKG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI;IAIxD;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI;IAa5B;;;;OAIG;IACH,OAAO,IAAI,MAAM;CA6BlB"}
@@ -0,0 +1,131 @@
1
+ import { ExtensionScanner } from "../discovery/index.js";
2
+ import { ModuleBuilder } from "../builder/index.js";
3
+ import { TiptapRegistry } from "./TiptapRegistry.js";
4
+ import { TiptapExecutor } from "./TiptapExecutor.js";
5
+ import { AclGuard } from "../security/index.js";
6
+ import { TiptapModuleError, ErrorCodes } from "../errors/index.js";
7
+ const PREFIX_PATTERN = /^[a-z][a-z0-9]*$/;
8
+ /**
9
+ * TiptapAPCore - Unified entry point for TipTap editor AI control.
10
+ *
11
+ * This class encapsulates the registry, executor, and discovery logic,
12
+ * providing a simplified API for developers.
13
+ */
14
+ export class TiptapAPCore {
15
+ _editor;
16
+ _options;
17
+ _registry;
18
+ _executor;
19
+ _aclGuard;
20
+ _scanner;
21
+ _builder;
22
+ constructor(editor, options) {
23
+ if (editor == null) {
24
+ throw new TypeError("editor must be a valid TipTap Editor instance");
25
+ }
26
+ if (editor.isDestroyed) {
27
+ throw new TiptapModuleError(ErrorCodes.EDITOR_NOT_READY, "Editor is not ready", { editorDestroyed: true });
28
+ }
29
+ this._editor = editor;
30
+ this._options = { ...options };
31
+ // Validate options
32
+ const prefix = this._options.prefix ?? "tiptap";
33
+ if (!PREFIX_PATTERN.test(prefix)) {
34
+ throw new TiptapModuleError(ErrorCodes.SCHEMA_VALIDATION_ERROR, `Invalid prefix '${prefix}': must match /^[a-z][a-z0-9]*$/`, { field: "prefix", value: prefix });
35
+ }
36
+ const validRoles = ["readonly", "editor", "admin"];
37
+ if (this._options.acl?.role &&
38
+ !validRoles.includes(this._options.acl.role)) {
39
+ throw new TiptapModuleError(ErrorCodes.SCHEMA_VALIDATION_ERROR, `Invalid ACL role '${this._options.acl.role}': must be one of ${validRoles.join(", ")}`, { field: "acl.role", value: this._options.acl.role });
40
+ }
41
+ // 1. Initialize components
42
+ this._scanner = new ExtensionScanner(this._options.logger);
43
+ this._builder = new ModuleBuilder(prefix);
44
+ this._registry = new TiptapRegistry();
45
+ this._aclGuard = new AclGuard(this._options.acl, this._options.logger);
46
+ this._executor = new TiptapExecutor(editor, this._registry, this._aclGuard, this._options.sanitizeHtml);
47
+ // 2. Initial discovery
48
+ this.refresh();
49
+ // 3. Set up deferred discovery (for SDK compatibility)
50
+ this._registry.setScanFunction(() => this.refresh());
51
+ }
52
+ /** The APCore Registry containing all discovered module definitions */
53
+ get registry() {
54
+ return this._registry;
55
+ }
56
+ /** The APCore Executor for running commands against the editor */
57
+ get executor() {
58
+ return this._executor;
59
+ }
60
+ /**
61
+ * Execute an editor command via APCore.
62
+ *
63
+ * @param moduleId - The module ID (e.g., 'tiptap.format.toggleBold')
64
+ * @param inputs - Input arguments for the command
65
+ * @returns The execution result
66
+ */
67
+ async call(moduleId, inputs) {
68
+ return this._executor.call(moduleId, inputs);
69
+ }
70
+ /**
71
+ * List available modules in the registry.
72
+ *
73
+ * @param options - Optional filters (tags, prefix)
74
+ * @returns Array of module IDs
75
+ */
76
+ list(options) {
77
+ return this._registry.list(options);
78
+ }
79
+ /**
80
+ * Get the full definition of a module.
81
+ *
82
+ * @param moduleId - The module ID to look up
83
+ * @returns The module descriptor or null if not found
84
+ */
85
+ getDefinition(moduleId) {
86
+ return this._registry.getDefinition(moduleId);
87
+ }
88
+ /**
89
+ * Update the ACL configuration without recreating the instance.
90
+ *
91
+ * @param acl - The new ACL configuration
92
+ */
93
+ setAcl(acl) {
94
+ const validRoles = ["readonly", "editor", "admin"];
95
+ if (acl.role && !validRoles.includes(acl.role)) {
96
+ throw new TiptapModuleError(ErrorCodes.SCHEMA_VALIDATION_ERROR, `Invalid ACL role '${acl.role}': must be one of ${validRoles.join(", ")}`, { field: "acl.role", value: acl.role });
97
+ }
98
+ this._options.acl = acl;
99
+ this._aclGuard.updateConfig(acl);
100
+ }
101
+ /**
102
+ * Trigger a re-scan of TipTap extensions to update the registry.
103
+ *
104
+ * @returns The number of modules discovered
105
+ */
106
+ refresh() {
107
+ const includeUnsafe = this._options.includeUnsafe ?? false;
108
+ const extensionMap = this._scanner.scan(this._editor);
109
+ const newIds = new Set();
110
+ // Register new/updated
111
+ for (const [, extensionInfo] of extensionMap) {
112
+ for (const commandName of extensionInfo.commandNames) {
113
+ const descriptor = this._builder.build(commandName, extensionInfo);
114
+ // Skip unknown commands if includeUnsafe is false
115
+ if (!includeUnsafe && descriptor.tags?.includes("unknown")) {
116
+ continue;
117
+ }
118
+ newIds.add(descriptor.moduleId);
119
+ this._registry.register(descriptor);
120
+ }
121
+ }
122
+ // Unregister removed
123
+ for (const oldId of this._registry.list()) {
124
+ if (!newIds.has(oldId)) {
125
+ this._registry.unregister(oldId);
126
+ }
127
+ }
128
+ return newIds.size;
129
+ }
130
+ }
131
+ //# sourceMappingURL=TiptapAPCore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TiptapAPCore.js","sourceRoot":"","sources":["../../src/runtime/TiptapAPCore.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEnE,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IACf,OAAO,CAAa;IACpB,QAAQ,CAAgB;IACxB,SAAS,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AAQ,CAAC,SAAS,CAAC,EAAE,CAAC;oBAC3D,SAAS;gBACX,CAAC;gBAED,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;gBAChC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;QAED,qBAAqB;QACrB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC;YAC1C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBACvB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;CACF"}
@@ -1,3 +1,4 @@
1
+ export { TiptapAPCore } from "./TiptapAPCore.js";
1
2
  export { TiptapRegistry } from "./TiptapRegistry.js";
2
3
  export { TiptapExecutor } from "./TiptapExecutor.js";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
@@ -1,4 +1,5 @@
1
- // Runtime layer - TiptapRegistry, TiptapExecutor (Tasks 6, 9)
1
+ // Runtime layer - TiptapAPCore, TiptapRegistry, TiptapExecutor
2
+ export { TiptapAPCore } from "./TiptapAPCore.js";
2
3
  export { TiptapRegistry } from "./TiptapRegistry.js";
3
4
  export { TiptapExecutor } from "./TiptapExecutor.js";
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
@@ -3,6 +3,8 @@ export declare class AclGuard {
3
3
  private config;
4
4
  private logger;
5
5
  constructor(config?: AclConfig, logger?: Logger);
6
+ /** Update ACL configuration at runtime */
7
+ updateConfig(config: AclConfig | undefined): void;
6
8
  check(moduleId: string, descriptor: ModuleDescriptor): void;
7
9
  isAllowed(moduleId: string, descriptor: ModuleDescriptor): boolean;
8
10
  private getDenialReason;
@@ -1 +1 @@
1
- {"version":3,"file":"AclGuard.d.ts","sourceRoot":"","sources":["../../src/security/AclGuard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AASvE,qBAAa,QAAQ;IACnB,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,MAAM,CAAqB;gBAEvB,MAAM,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM;IAK/C,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,gBAAgB,GAAG,IAAI;IAY3D,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,gBAAgB,GAAG,OAAO;IAwClE,OAAO,CAAC,eAAe;CAgDxB"}
1
+ {"version":3,"file":"AclGuard.d.ts","sourceRoot":"","sources":["../../src/security/AclGuard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AASvE,qBAAa,QAAQ;IACnB,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,MAAM,CAAqB;gBAEvB,MAAM,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM;IAK/C,0CAA0C;IAC1C,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI;IAKjD,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,gBAAgB,GAAG,IAAI;IAY3D,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,gBAAgB,GAAG,OAAO;IAwClE,OAAO,CAAC,eAAe;CAgDxB"}
@@ -11,6 +11,11 @@ export class AclGuard {
11
11
  this.config = config;
12
12
  this.logger = logger;
13
13
  }
14
+ /** Update ACL configuration at runtime */
15
+ updateConfig(config) {
16
+ this.config = config;
17
+ this.logger?.info?.("ACL configuration updated", { role: config?.role });
18
+ }
14
19
  check(moduleId, descriptor) {
15
20
  if (!this.isAllowed(moduleId, descriptor)) {
16
21
  const reason = this.getDenialReason(moduleId, descriptor);
@@ -1 +1 @@
1
- {"version":3,"file":"AclGuard.js","sourceRoot":"","sources":["../../src/security/AclGuard.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEnE,MAAM,SAAS,GAA6B;IAC1C,QAAQ,EAAE,CAAC,OAAO,CAAC;IACnB,MAAM,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,CAAC;IAC9D,KAAK,EAAE,CAAC,OAAO,EAAE,QAAQ,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CAAC,IAAI,CAAC,4BAA4B,CAAC;YACvE,CAAC;QACH,CAAC;QAED,kCAAkC;QAClC,IAAI,SAAS,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACnD,OAAO,gBAAgB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,iCAAiC,CAAC;YAChF,CAAC;QACH,CAAC;QAED,uBAAuB;QACvB,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;YACjC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,OAAO,iBAAiB,IAAI,GAAG,CAAC;YAClC,CAAC;YACD,OAAO,SAAS,IAAI,2BAA2B,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;QAC1E,CAAC;QAED,OAAO,yBAAyB,CAAC;IACnC,CAAC;CACF"}
package/dist/types.d.ts CHANGED
@@ -8,6 +8,7 @@ export type { Registry, Executor, ModuleDescriptor, ModuleAnnotations, JsonSchem
8
8
  import type { ModuleAnnotations, JsonSchema } from "apcore-mcp";
9
9
  /** Minimal logger interface for diagnostic output */
10
10
  export interface Logger {
11
+ info?(msg: string, ctx?: Record<string, unknown>): void;
11
12
  warn(msg: string, ctx?: Record<string, unknown>): void;
12
13
  error(msg: string, ctx?: Record<string, unknown>): void;
13
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EACV,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,YAAY,CAA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EAAE,UAAU,CAAC;IACxB,YAAY,EAAE,UAAU,CAAC;CAC1B"}
@@ -1,6 +1,8 @@
1
1
  /**
2
- * withApcore - Factory function that creates an APCore Registry + Executor
3
- * from a TipTap editor instance.
2
+ * withApcore - Factory function that creates a TiptapAPCore instance.
3
+ *
4
+ * This function is kept for backward compatibility and as a shortcut
5
+ * for simple integrations.
4
6
  */
5
7
  import type { ApcoreOptions, ApcoreResult, EditorLike } from "./types.js";
6
8
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"withApcore.d.ts","sourceRoot":"","sources":["../src/withApcore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAU1E;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,UAAU,EAClB,OAAO,CAAC,EAAE,aAAa,GACtB,YAAY,CAsFd"}
1
+ {"version":3,"file":"withApcore.d.ts","sourceRoot":"","sources":["../src/withApcore.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG1E;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,UAAU,EAClB,OAAO,CAAC,EAAE,aAAa,GACtB,YAAY,CAMd"}
@@ -1,14 +1,10 @@
1
1
  /**
2
- * withApcore - Factory function that creates an APCore Registry + Executor
3
- * from a TipTap editor instance.
2
+ * withApcore - Factory function that creates a TiptapAPCore instance.
3
+ *
4
+ * This function is kept for backward compatibility and as a shortcut
5
+ * for simple integrations.
4
6
  */
5
- import { ExtensionScanner } from "./discovery/index.js";
6
- import { ModuleBuilder } from "./builder/index.js";
7
- import { TiptapRegistry } from "./runtime/TiptapRegistry.js";
8
- import { TiptapExecutor } from "./runtime/TiptapExecutor.js";
9
- import { AclGuard } from "./security/index.js";
10
- import { TiptapModuleError, ErrorCodes } from "./errors/index.js";
11
- const PREFIX_PATTERN = /^[a-z][a-z0-9]*$/;
7
+ import { TiptapAPCore } from "./runtime/TiptapAPCore.js";
12
8
  /**
13
9
  * Create an APCore Registry + Executor from a TipTap editor instance.
14
10
  *
@@ -17,65 +13,10 @@ const PREFIX_PATTERN = /^[a-z][a-z0-9]*$/;
17
13
  * @returns { registry, executor } pair compatible with apcore-mcp SDK
18
14
  */
19
15
  export function withApcore(editor, options) {
20
- // Validate editor
21
- if (editor == null) {
22
- throw new TypeError("editor must be a valid TipTap Editor instance");
23
- }
24
- if (editor.isDestroyed) {
25
- throw new TiptapModuleError(ErrorCodes.EDITOR_NOT_READY, "Editor is not ready", { editorDestroyed: true });
26
- }
27
- // Validate options
28
- const prefix = options?.prefix ?? "tiptap";
29
- if (!PREFIX_PATTERN.test(prefix)) {
30
- throw new TiptapModuleError(ErrorCodes.SCHEMA_VALIDATION_ERROR, `Invalid prefix '${prefix}': must match /^[a-z][a-z0-9]*$/`, { field: "prefix", value: prefix });
31
- }
32
- const validRoles = ["readonly", "editor", "admin"];
33
- if (options?.acl?.role && !validRoles.includes(options.acl.role)) {
34
- throw new TiptapModuleError(ErrorCodes.SCHEMA_VALIDATION_ERROR, `Invalid ACL role '${options.acl.role}': must be one of ${validRoles.join(", ")}`, { field: "acl.role", value: options.acl.role });
35
- }
36
- // C-2: Default includeUnsafe to false
37
- const includeUnsafe = options?.includeUnsafe ?? false;
38
- const logger = options?.logger;
39
- // 1. Scan extensions (H-11 + H-12: wire logger)
40
- const scanner = new ExtensionScanner(logger);
41
- const extensionMap = scanner.scan(editor);
42
- // 2. Build module descriptors
43
- const builder = new ModuleBuilder(prefix);
44
- const registry = new TiptapRegistry();
45
- for (const [, extensionInfo] of extensionMap) {
46
- for (const commandName of extensionInfo.commandNames) {
47
- const descriptor = builder.build(commandName, extensionInfo);
48
- // Skip unknown commands if includeUnsafe is false
49
- if (!includeUnsafe && descriptor.tags?.includes("unknown")) {
50
- continue;
51
- }
52
- registry.register(descriptor);
53
- }
54
- }
55
- // 3. Create executor with ACL (H-7 + H-11: wire logger to AclGuard; H-1: wire sanitizeHtml)
56
- const aclGuard = new AclGuard(options?.acl, logger);
57
- const executor = new TiptapExecutor(editor, registry, aclGuard, options?.sanitizeHtml);
58
- // 4. H-5: Diff-based discover — only emit register/unregister for changed modules
59
- registry.setScanFunction(() => {
60
- const newExtensionMap = scanner.scan(editor);
61
- const newIds = new Set();
62
- // Register new/updated
63
- for (const [, extInfo] of newExtensionMap) {
64
- for (const cmdName of extInfo.commandNames) {
65
- const desc = builder.build(cmdName, extInfo);
66
- if (!includeUnsafe && desc.tags?.includes("unknown"))
67
- continue;
68
- newIds.add(desc.moduleId);
69
- registry.register(desc);
70
- }
71
- }
72
- // Unregister removed
73
- for (const oldId of registry.list()) {
74
- if (!newIds.has(oldId))
75
- registry.unregister(oldId);
76
- }
77
- return newIds.size;
78
- });
79
- return { registry, executor };
16
+ const instance = new TiptapAPCore(editor, options);
17
+ return {
18
+ registry: instance.registry,
19
+ executor: instance.executor,
20
+ };
80
21
  }
81
22
  //# sourceMappingURL=withApcore.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"withApcore.js","sourceRoot":"","sources":["../src/withApcore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAElE,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACxB,MAAkB,EAClB,OAAuB;IAEvB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,CAAC;gBAC7C,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC;oBAAE,SAAS;gBAC/D,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAC1B,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QAED,qBAAqB;QACrB,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;YACpC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC;gBAAE,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACrD,CAAC;QAED,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAChC,CAAC"}
1
+ {"version":3,"file":"withApcore.js","sourceRoot":"","sources":["../src/withApcore.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACxB,MAAkB,EAClB,OAAuB;IAEvB,MAAM,QAAQ,GAAG,IAAI,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnD,OAAO;QACL,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,QAAQ,EAAE,QAAQ,CAAC,QAAQ;KAC5B,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiptap-apcore",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "TipTap editor APCore modules - let AI safely control your TipTap editor",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -39,7 +39,7 @@
39
39
  "@vitest/coverage-v8": "^3.0.0",
40
40
  "apcore-js": "^0.13.0",
41
41
  "apcore-mcp": "^0.10.0",
42
- "apdev-js": "^0.1.1",
42
+ "apdev-js": "^0.2.2",
43
43
  "jsdom": "^25.0.0",
44
44
  "typescript": "^5.5.0",
45
45
  "vitest": "^3.0.0"