@molecule/api-ai-summarization-llm 1.0.0 → 1.0.2

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 (2) hide show
  1. package/README.md +140 -0
  2. package/package.json +12 -11
package/README.md ADDED
@@ -0,0 +1,140 @@
1
+ <!--
2
+ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
+ Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
+ Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
+ To change this document, edit the module-level JSDoc in src/index.ts.
6
+ Generated: 2026-08-04T01:47:38.403Z
7
+ -->
8
+
9
+ # @molecule/api-ai-summarization-llm
10
+
11
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
12
+ > It is written to be read by coding agents as much as by people, and is generated from this
13
+ > package's source — edit `src/index.ts` JSDoc, not this file.
14
+
15
+ Default (`llm`) AI summarization provider for molecule.dev.
16
+
17
+ Turns a block of text into a concise summary over whatever LLM the app has
18
+ bonded. It has no vendor of its own — it composes the swappable `ai` chat
19
+ bond (`@molecule/api-ai`) with a summarizer system prompt built from the
20
+ requested format / length / focus, so swapping the LLM swaps the summarizer.
21
+
22
+ ## Quick Start
23
+
24
+ ```typescript
25
+ import { provider as anthropic } from '@molecule/api-ai-anthropic'
26
+ import { requireProvider } from '@molecule/api-ai-summarization'
27
+ import { provider as summarization } from '@molecule/api-ai-summarization-llm'
28
+ import { bond } from '@molecule/api-bond'
29
+
30
+ // Wire the AI chat provider this composes, then bond the summarizer.
31
+ bond('ai', anthropic)
32
+ bond('ai-summarization', summarization)
33
+
34
+ // Use anywhere after startup.
35
+ const { summary, usage } = await requireProvider().summarize({
36
+ text: longArticle,
37
+ format: 'bullets',
38
+ maxLength: 60,
39
+ focus: 'the financial impact',
40
+ })
41
+ ```
42
+
43
+ ## Type
44
+
45
+ `provider`
46
+
47
+ ## Installation
48
+
49
+ ```bash
50
+ npm install @molecule/api-ai-summarization-llm @molecule/api-ai @molecule/api-ai-summarization @molecule/api-i18n
51
+ ```
52
+
53
+ ## API
54
+
55
+ ### Constants
56
+
57
+ #### `provider`
58
+
59
+ Default AI summarization provider.
60
+
61
+ Composes the bonded `ai` chat provider (`@molecule/api-ai`) — an AI provider
62
+ MUST be bonded first (`bond('ai', <provider>)`), or `summarize()` throws. Bond
63
+ it with `bond('ai-summarization', provider)`; swap in a custom
64
+ `AISummarizationProvider` to replace it without touching call sites.
65
+
66
+ ```typescript
67
+ const provider: AISummarizationProvider
68
+ ```
69
+
70
+ ## Core Interface
71
+
72
+ Implements `@molecule/api-ai-summarization` interface.
73
+
74
+ ## Bond Wiring
75
+
76
+ Setup function to register this provider with the core interface:
77
+
78
+ ```typescript
79
+ import { setProvider } from '@molecule/api-ai-summarization'
80
+ import { provider } from '@molecule/api-ai-summarization-llm'
81
+
82
+ export function setupAiSummarizationLlm(): void {
83
+ setProvider(provider)
84
+ }
85
+ ```
86
+
87
+ ## Injection Notes
88
+
89
+ ### Requirements
90
+
91
+ Peer dependencies:
92
+
93
+ - `@molecule/api-ai` ^1.0.1
94
+ - `@molecule/api-ai-summarization` ^1.0.1
95
+ - `@molecule/api-i18n` ^1.0.1
96
+
97
+ ### Runtime Dependencies
98
+
99
+ - `@molecule/api-ai`
100
+ - `@molecule/api-ai-summarization`
101
+ - `@molecule/api-i18n`
102
+
103
+ Composes the swappable `ai` bond: an `ai` provider MUST be bonded first
104
+ (`bond('ai', <provider>)`) or `summarize()` throws (a missing AI provider
105
+ throws at `summarize()` time, not at import). Pass `provider` on the input to
106
+ target a specific named `ai` provider. Because it is just prompt orchestration
107
+ over the bonded LLM, swapping the `ai` provider swaps the model behind every
108
+ summary without touching call sites.
109
+
110
+ ## E2E Tests
111
+
112
+ Integration checklist — drive the real UI (live preview, no mocks), adapt
113
+ each item to this app's actual screens/flows, and check every box off one
114
+ by one. A box you can't check is an integration bug to fix — not a skip:
115
+
116
+ - [ ] Summarizing a real long document through the app's UI returns a summary
117
+ that is clearly SHORTER than the input and captures its key points — not a
118
+ truncation of the first N characters, not an echo of the input, not empty.
119
+ The sandbox has a live AI provider, so this runs for real; the output is
120
+ non-deterministic, so assert on behavior (it is shorter, the main ideas are
121
+ present), never on an exact string.
122
+ - [ ] A second, different document yields a genuinely different summary — not
123
+ the same cached/boilerplate text — confirming each summary reflects the
124
+ actual input rather than a canned response.
125
+ - [ ] The shape/length controls actually change the output: a smaller
126
+ `maxLength` (approx target words) produces a shorter summary than a larger
127
+ one, and switching `format` between 'paragraph', 'bullets', and 'tldr'
128
+ visibly changes the structure (bullets render as a list, tldr is terser).
129
+ If the app exposes only some of these, verify the ones it exposes.
130
+ - [ ] Edge inputs are handled, not silently mangled: empty or whitespace-only
131
+ input does not crash and gives a clear "nothing to summarize" response; very
132
+ long input (beyond the model's limit) either summarizes or fails with a
133
+ visible, clear message — never a silent truncation that drops half the
134
+ meaning.
135
+ - [ ] A provider failure (the AI request errors, is rate-limited, or times
136
+ out) surfaces gracefully in the UI — a readable error, no blank screen, no
137
+ crash, no uncaught 500.
138
+ - [ ] The summarize call runs server-side only: no AI key or provider secret
139
+ is ever exposed to the browser. Confirm the request goes to this app's own
140
+ API and the key never appears in network traffic or the client bundle.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/api-ai-summarization-llm",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Default LLM-composed AI summarization provider for molecule.dev — summarizes over any bonded @molecule/api-ai chat provider",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -17,7 +17,8 @@
17
17
  }
18
18
  },
19
19
  "files": [
20
- "dist"
20
+ "dist",
21
+ "README.md"
21
22
  ],
22
23
  "keywords": [
23
24
  "molecule",
@@ -27,25 +28,25 @@
27
28
  ],
28
29
  "license": "Apache-2.0",
29
30
  "peerDependencies": {
30
- "@molecule/api-ai": "^1.0.0",
31
- "@molecule/api-ai-summarization": "^1.0.0",
32
- "@molecule/api-i18n": "^1.0.0"
31
+ "@molecule/api-ai": "^1.0.1",
32
+ "@molecule/api-ai-summarization": "^1.0.1",
33
+ "@molecule/api-i18n": "^1.0.1"
33
34
  },
34
35
  "devDependencies": {
35
- "@molecule/api-ai": "1.0.0",
36
- "@molecule/api-ai-summarization": "1.0.0",
37
- "@molecule/api-bond": "1.0.0",
38
- "@molecule/api-i18n": "1.0.0",
36
+ "@molecule/api-ai": "1.2.1",
37
+ "@molecule/api-ai-summarization": "1.0.2",
38
+ "@molecule/api-bond": "1.0.2",
39
+ "@molecule/api-i18n": "1.0.3",
39
40
  "@types/node": "26.1.2",
40
41
  "typescript": "6.0.3",
41
- "vitest": "4.1.10"
42
+ "vitest": "4.1.11"
42
43
  },
43
44
  "repository": {
44
45
  "type": "git",
45
46
  "url": "https://github.com/molecule-dev/molecule.git",
46
47
  "directory": "packages/api/bonds/ai-summarization/llm"
47
48
  },
48
- "homepage": "https://github.com/molecule-dev/molecule/tree/main/packages/api/bonds/ai-summarization/llm",
49
+ "homepage": "https://www.molecule.dev/packages/api-ai-summarization-llm",
49
50
  "bugs": "https://github.com/molecule-dev/molecule/issues",
50
51
  "publishConfig": {
51
52
  "access": "public"