@templatical/ai-kit 0.0.0-stage → 0.50.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/LICENSE +21 -0
- package/README.md +61 -2
- package/dist/checks-Blbakkgc.js +649 -0
- package/dist/checks-Blbakkgc.js.map +1 -0
- package/dist/client/index.d.ts +24 -0
- package/dist/client/index.js +1 -0
- package/dist/http-provider-BoRkCd7H.js +327 -0
- package/dist/http-provider-BoRkCd7H.js.map +1 -0
- package/dist/http-provider-Cb41NXd5.d.ts +22 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/model-BuHDCTlM.d.ts +74 -0
- package/dist/server/index.d.ts +313 -0
- package/dist/server/index.js +355 -0
- package/dist/server/index.js.map +1 -0
- package/dist/testing/index.d.ts +277 -0
- package/dist/testing/index.js +2444 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/wire-B6AF_UGT.js +132 -0
- package/dist/wire-B6AF_UGT.js.map +1 -0
- package/dist/wire-Cv7Fk-7n.d.ts +136 -0
- package/eval/MANIFEST.sha256 +23 -0
- package/eval/cases.json +287 -0
- package/eval/designs/newsletter.png +0 -0
- package/eval/designs/one-page.pdf +0 -0
- package/eval/designs/promo.png +0 -0
- package/eval/domain-mismatch.json +25 -0
- package/eval/empty.json +11 -0
- package/eval/images/banner.png +0 -0
- package/eval/images/chart.png +0 -0
- package/eval/images/divider.png +0 -0
- package/eval/images/probe.png +0 -0
- package/eval/images/product.png +0 -0
- package/eval/injection.json +13 -0
- package/eval/low-text.json +41 -0
- package/eval/promo.json +12 -0
- package/eval/sources/banner.html +16 -0
- package/eval/sources/chart.html +16 -0
- package/eval/sources/divider.html +16 -0
- package/eval/sources/newsletter.html +16 -0
- package/eval/sources/one-page.html +16 -0
- package/eval/sources/probe.html +16 -0
- package/eval/sources/product.html +16 -0
- package/eval/sources/promo.html +16 -0
- package/eval/welcome.json +12 -0
- package/package.json +68 -3
- package/prompts/alt-text.md +7 -0
- package/prompts/chat-attachments.md +1 -0
- package/prompts/chat.md +2 -0
- package/prompts/editing.md +10 -0
- package/prompts/fix-rules.json +9 -0
- package/prompts/fix.md +8 -0
- package/prompts/operations.md +127 -0
- package/prompts/rewrite-presets.json +8 -0
- package/prompts/rewrite.md +4 -0
- package/schema/template-content.schema.json +1884 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026-present Templatical
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,62 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @templatical/ai-kit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Bring your own AI backend to the [Templatical](https://templatical.com) email editor.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@templatical/ai-kit)
|
|
6
|
+
[](https://github.com/templatical/sdk/blob/main/LICENSE-MIT)
|
|
7
|
+
|
|
8
|
+
The editor's AI (the AI assistant with Undo and attachments, Rewrite, Fix with AI, Write alt text and static localized chat starters) runs on an `AiProvider` you pass to `init({ ai })`. This package is everything around that contract, with no LLM SDK and no Node-only API: it runs in Node, Deno, Bun, Workers and the browser.
|
|
9
|
+
|
|
10
|
+
| Entry | What it is |
|
|
11
|
+
|---|---|
|
|
12
|
+
| `@templatical/ai-kit` | The wire: routes, headers, events, bodies, error statuses, limits; the contract types |
|
|
13
|
+
| `@templatical/ai-kit/client` | `createHttpAiProvider()`: an `AiProvider` over the wire, for the browser |
|
|
14
|
+
| `@templatical/ai-kit/server` | Prompts, the `apply_operations` tool, `createEditingSession`, `runEditingTurn`, `aiEventStream`, output checks |
|
|
15
|
+
| `@templatical/ai-kit/testing` | `runAiProviderConformance`, `runAiWireConformance`, `createMockAiProvider`, the test set and `runAiEvalSet` |
|
|
16
|
+
| `@templatical/ai-kit/prompts/*`, `/schema/*`, `/eval/*` | The prompt files, the JSON schemas and the test set, for backends in any language |
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @templatical/ai-kit
|
|
22
|
+
pnpm add @templatical/ai-kit
|
|
23
|
+
yarn add @templatical/ai-kit
|
|
24
|
+
bun add @templatical/ai-kit
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Choose the command for your package manager.
|
|
28
|
+
|
|
29
|
+
## In the editor
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { init } from "@templatical/editor";
|
|
33
|
+
import "@templatical/editor/style.css";
|
|
34
|
+
import { createHttpAiProvider } from "@templatical/ai-kit/client";
|
|
35
|
+
|
|
36
|
+
const editor = await init({
|
|
37
|
+
container: "#editor",
|
|
38
|
+
templates: {
|
|
39
|
+
load: async (id) => {
|
|
40
|
+
const response = await fetch(`/api/templates/${encodeURIComponent(id)}`);
|
|
41
|
+
if (!response.ok) throw new Error("Template load failed.");
|
|
42
|
+
return response.json();
|
|
43
|
+
},
|
|
44
|
+
create: false,
|
|
45
|
+
save: false,
|
|
46
|
+
},
|
|
47
|
+
ai: createHttpAiProvider({
|
|
48
|
+
baseUrl: "/api/ai",
|
|
49
|
+
}),
|
|
50
|
+
});
|
|
51
|
+
await editor.load("tpl_123");
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
AI needs a loaded template: the AI assistant and other entry points appear after `editor.load(id)` or `editor.create()` resolves. Omit `ai` to leave the feature out. Fix with AI and Write alt text also require `@templatical/quality` and lint on. The AI kit is MIT; the editor UI is source-available under FSL-1.1-MIT.
|
|
55
|
+
|
|
56
|
+
## On your server
|
|
57
|
+
|
|
58
|
+
See [Bring your own AI backend](https://docs.templatical.com/guide/bring-your-own-ai) for a complete Fetch-API server, model adapters for the Vercel AI SDK, OpenAI and Anthropic, and the wire for other languages.
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
MIT
|