@czap/astro 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 (159) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -0
  3. package/dist/Satellite.d.ts +42 -0
  4. package/dist/Satellite.d.ts.map +1 -0
  5. package/dist/Satellite.js +55 -0
  6. package/dist/Satellite.js.map +1 -0
  7. package/dist/client-directives/gpu.d.ts +3 -0
  8. package/dist/client-directives/gpu.d.ts.map +1 -0
  9. package/dist/client-directives/gpu.js +5 -0
  10. package/dist/client-directives/gpu.js.map +1 -0
  11. package/dist/client-directives/llm.d.ts +3 -0
  12. package/dist/client-directives/llm.d.ts.map +1 -0
  13. package/dist/client-directives/llm.js +5 -0
  14. package/dist/client-directives/llm.js.map +1 -0
  15. package/dist/client-directives/satellite.d.ts +3 -0
  16. package/dist/client-directives/satellite.d.ts.map +1 -0
  17. package/dist/client-directives/satellite.js +5 -0
  18. package/dist/client-directives/satellite.js.map +1 -0
  19. package/dist/client-directives/stream.d.ts +3 -0
  20. package/dist/client-directives/stream.d.ts.map +1 -0
  21. package/dist/client-directives/stream.js +5 -0
  22. package/dist/client-directives/stream.js.map +1 -0
  23. package/dist/client-directives/wasm.d.ts +3 -0
  24. package/dist/client-directives/wasm.d.ts.map +1 -0
  25. package/dist/client-directives/wasm.js +6 -0
  26. package/dist/client-directives/wasm.js.map +1 -0
  27. package/dist/client-directives/worker.d.ts +3 -0
  28. package/dist/client-directives/worker.d.ts.map +1 -0
  29. package/dist/client-directives/worker.js +5 -0
  30. package/dist/client-directives/worker.js.map +1 -0
  31. package/dist/detect-upgrade.d.ts +16 -0
  32. package/dist/detect-upgrade.d.ts.map +1 -0
  33. package/dist/detect-upgrade.js +105 -0
  34. package/dist/detect-upgrade.js.map +1 -0
  35. package/dist/headers.d.ts +45 -0
  36. package/dist/headers.d.ts.map +1 -0
  37. package/dist/headers.js +64 -0
  38. package/dist/headers.js.map +1 -0
  39. package/dist/index.d.ts +30 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +26 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/integration.d.ts +76 -0
  44. package/dist/integration.d.ts.map +1 -0
  45. package/dist/integration.js +240 -0
  46. package/dist/integration.js.map +1 -0
  47. package/dist/middleware.d.ts +69 -0
  48. package/dist/middleware.d.ts.map +1 -0
  49. package/dist/middleware.js +75 -0
  50. package/dist/middleware.js.map +1 -0
  51. package/dist/quantize.d.ts +50 -0
  52. package/dist/quantize.d.ts.map +1 -0
  53. package/dist/quantize.js +122 -0
  54. package/dist/quantize.js.map +1 -0
  55. package/dist/runtime/boundary.d.ts +123 -0
  56. package/dist/runtime/boundary.d.ts.map +1 -0
  57. package/dist/runtime/boundary.js +164 -0
  58. package/dist/runtime/boundary.js.map +1 -0
  59. package/dist/runtime/globals.d.ts +32 -0
  60. package/dist/runtime/globals.d.ts.map +1 -0
  61. package/dist/runtime/globals.js +45 -0
  62. package/dist/runtime/globals.js.map +1 -0
  63. package/dist/runtime/gpu.d.ts +15 -0
  64. package/dist/runtime/gpu.d.ts.map +1 -0
  65. package/dist/runtime/gpu.js +266 -0
  66. package/dist/runtime/gpu.js.map +1 -0
  67. package/dist/runtime/index.d.ts +7 -0
  68. package/dist/runtime/index.d.ts.map +1 -0
  69. package/dist/runtime/index.js +5 -0
  70. package/dist/runtime/index.js.map +1 -0
  71. package/dist/runtime/llm-receipt-tracker.d.ts +21 -0
  72. package/dist/runtime/llm-receipt-tracker.d.ts.map +1 -0
  73. package/dist/runtime/llm-receipt-tracker.js +60 -0
  74. package/dist/runtime/llm-receipt-tracker.js.map +1 -0
  75. package/dist/runtime/llm-render-pipeline.d.ts +89 -0
  76. package/dist/runtime/llm-render-pipeline.d.ts.map +1 -0
  77. package/dist/runtime/llm-render-pipeline.js +241 -0
  78. package/dist/runtime/llm-render-pipeline.js.map +1 -0
  79. package/dist/runtime/llm-session.d.ts +126 -0
  80. package/dist/runtime/llm-session.d.ts.map +1 -0
  81. package/dist/runtime/llm-session.js +385 -0
  82. package/dist/runtime/llm-session.js.map +1 -0
  83. package/dist/runtime/llm.d.ts +16 -0
  84. package/dist/runtime/llm.d.ts.map +1 -0
  85. package/dist/runtime/llm.js +273 -0
  86. package/dist/runtime/llm.js.map +1 -0
  87. package/dist/runtime/policy.d.ts +100 -0
  88. package/dist/runtime/policy.d.ts.map +1 -0
  89. package/dist/runtime/policy.js +147 -0
  90. package/dist/runtime/policy.js.map +1 -0
  91. package/dist/runtime/receipt-chain.d.ts +22 -0
  92. package/dist/runtime/receipt-chain.d.ts.map +1 -0
  93. package/dist/runtime/receipt-chain.js +80 -0
  94. package/dist/runtime/receipt-chain.js.map +1 -0
  95. package/dist/runtime/runtime-session.d.ts +34 -0
  96. package/dist/runtime/runtime-session.d.ts.map +1 -0
  97. package/dist/runtime/runtime-session.js +102 -0
  98. package/dist/runtime/runtime-session.js.map +1 -0
  99. package/dist/runtime/satellite.d.ts +13 -0
  100. package/dist/runtime/satellite.d.ts.map +1 -0
  101. package/dist/runtime/satellite.js +59 -0
  102. package/dist/runtime/satellite.js.map +1 -0
  103. package/dist/runtime/slots.d.ts +34 -0
  104. package/dist/runtime/slots.d.ts.map +1 -0
  105. package/dist/runtime/slots.js +108 -0
  106. package/dist/runtime/slots.js.map +1 -0
  107. package/dist/runtime/stream-session.d.ts +47 -0
  108. package/dist/runtime/stream-session.d.ts.map +1 -0
  109. package/dist/runtime/stream-session.js +82 -0
  110. package/dist/runtime/stream-session.js.map +1 -0
  111. package/dist/runtime/stream.d.ts +9 -0
  112. package/dist/runtime/stream.d.ts.map +1 -0
  113. package/dist/runtime/stream.js +308 -0
  114. package/dist/runtime/stream.js.map +1 -0
  115. package/dist/runtime/url-policy.d.ts +28 -0
  116. package/dist/runtime/url-policy.d.ts.map +1 -0
  117. package/dist/runtime/url-policy.js +87 -0
  118. package/dist/runtime/url-policy.js.map +1 -0
  119. package/dist/runtime/wasm.d.ts +20 -0
  120. package/dist/runtime/wasm.d.ts.map +1 -0
  121. package/dist/runtime/wasm.js +70 -0
  122. package/dist/runtime/wasm.js.map +1 -0
  123. package/dist/runtime/worker.d.ts +11 -0
  124. package/dist/runtime/worker.d.ts.map +1 -0
  125. package/dist/runtime/worker.js +249 -0
  126. package/dist/runtime/worker.js.map +1 -0
  127. package/package.json +106 -0
  128. package/src/Satellite.astro +39 -0
  129. package/src/Satellite.ts +84 -0
  130. package/src/client-directives/gpu.ts +5 -0
  131. package/src/client-directives/llm.ts +5 -0
  132. package/src/client-directives/satellite.ts +5 -0
  133. package/src/client-directives/stream.ts +5 -0
  134. package/src/client-directives/wasm.ts +6 -0
  135. package/src/client-directives/worker.ts +5 -0
  136. package/src/detect-upgrade.ts +105 -0
  137. package/src/headers.ts +84 -0
  138. package/src/index.ts +30 -0
  139. package/src/integration.ts +309 -0
  140. package/src/middleware.ts +133 -0
  141. package/src/quantize.ts +173 -0
  142. package/src/runtime/boundary.ts +263 -0
  143. package/src/runtime/globals.ts +57 -0
  144. package/src/runtime/gpu.ts +291 -0
  145. package/src/runtime/index.ts +12 -0
  146. package/src/runtime/llm-receipt-tracker.ts +88 -0
  147. package/src/runtime/llm-render-pipeline.ts +366 -0
  148. package/src/runtime/llm-session.ts +548 -0
  149. package/src/runtime/llm.ts +344 -0
  150. package/src/runtime/policy.ts +229 -0
  151. package/src/runtime/receipt-chain.ts +106 -0
  152. package/src/runtime/runtime-session.ts +139 -0
  153. package/src/runtime/satellite.ts +80 -0
  154. package/src/runtime/slots.ts +136 -0
  155. package/src/runtime/stream-session.ts +125 -0
  156. package/src/runtime/stream.ts +407 -0
  157. package/src/runtime/url-policy.ts +107 -0
  158. package/src/runtime/wasm.ts +85 -0
  159. package/src/runtime/worker.ts +307 -0
@@ -0,0 +1,385 @@
1
+ import { LLMChunkNormalization, createHtmlFragment, } from '@czap/web';
2
+ import { createLLMRenderPipeline } from './llm-render-pipeline.js';
3
+ import { createLLMReceiptTracker } from './llm-receipt-tracker.js';
4
+ const noopSetTarget = () => { };
5
+ const noopEmitToken = () => { };
6
+ const noopEmitFrame = () => { };
7
+ const noopEmitToolStart = () => { };
8
+ const noopEmitToolEnd = () => { };
9
+ const noopEmitDone = () => { };
10
+ const alwaysRenderText = () => true;
11
+ const renderFrameTokensOnly = (frame) => frame.tokens.length > 0;
12
+ function appendText(target, text) {
13
+ if (typeof target.append === 'function') {
14
+ target.append(text);
15
+ return;
16
+ }
17
+ target.appendChild(document.createTextNode(text));
18
+ }
19
+ function replaceWithText(target, text) {
20
+ target.textContent = text;
21
+ }
22
+ function writeHtml(target, html, htmlPolicy, allowTrustedHtml) {
23
+ // Route through createHtmlFragment so the assignment goes via the
24
+ // shared trust pipeline's Trusted-Types-aware `assignInnerHTML` helper
25
+ // rather than a raw `target.innerHTML = ...` (which throws under
26
+ // `require-trusted-types-for 'script'` enforcement). See SECURITY.md
27
+ // "CSP and Trusted Types" for the recipe.
28
+ const fragment = createHtmlFragment(html, {
29
+ policy: htmlPolicy,
30
+ allowTrustedHtml,
31
+ });
32
+ target.replaceChildren(fragment);
33
+ }
34
+ /**
35
+ * Build an {@link LLMSessionHost} that writes text/frames directly to
36
+ * the DOM and dispatches `czap:llm-*` custom events on `element`.
37
+ * Default host used by {@link createLLMSession}.
38
+ */
39
+ export function createDOMLLMSessionHost(element, initialTarget, options) {
40
+ let currentTarget = initialTarget;
41
+ const htmlPolicy = options?.htmlPolicy ?? 'text';
42
+ const allowTrustedHtml = options?.allowTrustedHtml ?? false;
43
+ return {
44
+ setTarget(target) {
45
+ if (target) {
46
+ currentTarget = target;
47
+ }
48
+ },
49
+ renderText(text, accumulated, mode) {
50
+ if (htmlPolicy !== 'text') {
51
+ writeHtml(currentTarget, accumulated, htmlPolicy, allowTrustedHtml);
52
+ return true;
53
+ }
54
+ if (mode === 'append') {
55
+ appendText(currentTarget, text);
56
+ }
57
+ else {
58
+ replaceWithText(currentTarget, accumulated);
59
+ }
60
+ return true;
61
+ },
62
+ renderFrame(frame, accumulated, mode) {
63
+ const text = frame.tokens.join('');
64
+ if (!text) {
65
+ return false;
66
+ }
67
+ if (htmlPolicy !== 'text') {
68
+ writeHtml(currentTarget, accumulated, htmlPolicy, allowTrustedHtml);
69
+ return true;
70
+ }
71
+ if (mode === 'append') {
72
+ appendText(currentTarget, text);
73
+ }
74
+ else {
75
+ replaceWithText(currentTarget, accumulated);
76
+ }
77
+ return true;
78
+ },
79
+ emitToken(text, accumulated) {
80
+ element.dispatchEvent(new CustomEvent('czap:llm-token', {
81
+ detail: { text, accumulated },
82
+ bubbles: true,
83
+ }));
84
+ },
85
+ emitFrame(frame) {
86
+ element.dispatchEvent(new CustomEvent('czap:llm-frame', {
87
+ detail: frame,
88
+ bubbles: true,
89
+ }));
90
+ },
91
+ emitToolStart(name) {
92
+ element.dispatchEvent(new CustomEvent('czap:llm-tool-start', {
93
+ detail: { name },
94
+ bubbles: true,
95
+ }));
96
+ },
97
+ emitToolEnd(name, args) {
98
+ element.dispatchEvent(new CustomEvent('czap:llm-tool-end', {
99
+ detail: { name, args },
100
+ bubbles: true,
101
+ }));
102
+ },
103
+ emitDone(accumulated) {
104
+ element.dispatchEvent(new CustomEvent('czap:llm-done', {
105
+ detail: { accumulated },
106
+ bubbles: true,
107
+ }));
108
+ },
109
+ };
110
+ }
111
+ /**
112
+ * Build an {@link LLMSessionHost} that forwards events to the given
113
+ * handler callbacks instead of touching the DOM. Useful for tests,
114
+ * benchmarks, and any caller that wants to observe LLM output
115
+ * programmatically.
116
+ */
117
+ export function createSupportLLMSessionHost(handlers) {
118
+ const onToken = handlers?.onToken;
119
+ const onTokenValue = handlers?.onTokenValue;
120
+ const onFrame = handlers?.onFrame;
121
+ const onToolStart = handlers?.onToolStart;
122
+ const onToolStartValue = handlers?.onToolStartValue;
123
+ const onToolEnd = handlers?.onToolEnd;
124
+ const onToolEndValue = handlers?.onToolEndValue;
125
+ const onDone = handlers?.onDone;
126
+ const onDoneValue = handlers?.onDoneValue;
127
+ // The startup bench only needs the token boundary, so skip the generic
128
+ // support-host composition work when no other callbacks are present.
129
+ if (onTokenValue &&
130
+ !onToken &&
131
+ !onFrame &&
132
+ !onToolStart &&
133
+ !onToolStartValue &&
134
+ !onToolEnd &&
135
+ !onToolEndValue &&
136
+ !onDone &&
137
+ !onDoneValue) {
138
+ return {
139
+ setTarget: noopSetTarget,
140
+ renderText: alwaysRenderText,
141
+ renderFrame: renderFrameTokensOnly,
142
+ emitToken: onTokenValue,
143
+ emitFrame: noopEmitFrame,
144
+ emitToolStart: noopEmitToolStart,
145
+ emitToolEnd: noopEmitToolEnd,
146
+ emitDone: noopEmitDone,
147
+ };
148
+ }
149
+ const emitToken = onTokenValue && onToken
150
+ ? (text, accumulated) => {
151
+ onTokenValue(text, accumulated);
152
+ onToken({ text, accumulated });
153
+ }
154
+ : onTokenValue
155
+ ? onTokenValue
156
+ : onToken
157
+ ? (text, accumulated) => {
158
+ onToken({ text, accumulated });
159
+ }
160
+ : undefined;
161
+ const emitFrame = onFrame ?? noopEmitFrame;
162
+ const emitToolStart = onToolStartValue && onToolStart
163
+ ? (name) => {
164
+ onToolStartValue(name);
165
+ onToolStart({ name });
166
+ }
167
+ : onToolStartValue
168
+ ? onToolStartValue
169
+ : onToolStart
170
+ ? (name) => {
171
+ onToolStart({ name });
172
+ }
173
+ : noopEmitToolStart;
174
+ const emitToolEnd = onToolEndValue && onToolEnd
175
+ ? (name, args) => {
176
+ onToolEndValue(name, args);
177
+ onToolEnd({ name, args });
178
+ }
179
+ : onToolEndValue
180
+ ? onToolEndValue
181
+ : onToolEnd
182
+ ? (name, args) => {
183
+ onToolEnd({ name, args });
184
+ }
185
+ : noopEmitToolEnd;
186
+ const emitDone = onDoneValue && onDone
187
+ ? (accumulated) => {
188
+ onDoneValue(accumulated);
189
+ onDone({ accumulated });
190
+ }
191
+ : onDoneValue
192
+ ? onDoneValue
193
+ : onDone
194
+ ? (accumulated) => {
195
+ onDone({ accumulated });
196
+ }
197
+ : noopEmitDone;
198
+ return {
199
+ setTarget: noopSetTarget,
200
+ renderText: alwaysRenderText,
201
+ renderFrame: renderFrameTokensOnly,
202
+ emitToken: emitToken ?? noopEmitToken,
203
+ emitFrame,
204
+ emitToolStart,
205
+ emitToolEnd,
206
+ emitDone,
207
+ };
208
+ }
209
+ /**
210
+ * Minimal {@link LLMSessionHost} that only surfaces the token
211
+ * boundary, skipping the branching composition in
212
+ * {@link createSupportLLMSessionHost}. Exposed for startup benchmarks
213
+ * that need the cheapest possible host.
214
+ */
215
+ export function createSupportLLMTokenBoundaryHost(onTokenValue) {
216
+ return {
217
+ setTarget: noopSetTarget,
218
+ renderText: alwaysRenderText,
219
+ renderFrame: alwaysRenderText,
220
+ emitToken: onTokenValue,
221
+ emitFrame: noopEmitFrame,
222
+ emitToolStart: noopEmitToolStart,
223
+ emitToolEnd: noopEmitToolEnd,
224
+ emitDone: noopEmitDone,
225
+ };
226
+ }
227
+ class LLMSessionController {
228
+ config;
229
+ host;
230
+ runtimeState = 'idle';
231
+ currentTarget;
232
+ toolCallBuffer = null;
233
+ pipeline;
234
+ receiptTracker;
235
+ constructor(config, host) {
236
+ this.config = config;
237
+ this.host = host;
238
+ this.currentTarget = config.target;
239
+ this.pipeline = createLLMRenderPipeline({ mode: config.mode, getDeviceTier: config.getDeviceTier });
240
+ this.receiptTracker = createLLMReceiptTracker();
241
+ }
242
+ get state() {
243
+ return this.runtimeState;
244
+ }
245
+ activate() {
246
+ if (!this.isDisposed()) {
247
+ this.runtimeState = 'active';
248
+ }
249
+ }
250
+ beginReconnect() {
251
+ if (!this.isDisposed()) {
252
+ this.runtimeState = 'reconnecting';
253
+ }
254
+ }
255
+ ingest(chunk) {
256
+ if (this.isDisposed()) {
257
+ return 'done';
258
+ }
259
+ const recordFrame = (frame) => this.receiptTracker.recordFrame(frame);
260
+ switch (chunk.type) {
261
+ case 'text': {
262
+ if (!chunk.content) {
263
+ return 'continue';
264
+ }
265
+ if (this.pipeline.shouldUseFastLane(this.toolCallBuffer === null, this.receiptTracker.receiptChain === null, this.runtimeState) &&
266
+ this.pipeline.renderImmediateText(chunk.content, this.host)) {
267
+ this.pipeline.setFastLanePrimed(true);
268
+ this.host.emitToken(chunk.content, this.pipeline.accumulated);
269
+ return 'continue';
270
+ }
271
+ this.pipeline.pushText(chunk.content);
272
+ if (this.isDisposed()) {
273
+ this.pipeline.clearQueuedText();
274
+ return 'done';
275
+ }
276
+ if (!this.pipeline.canQueueRenderBurst()) {
277
+ this.pipeline.clearQueuedText();
278
+ return 'continue';
279
+ }
280
+ if (this.pipeline.fastLanePrimed && !this.pipeline.llmRuntime) {
281
+ this.pipeline.promoteFastLane();
282
+ }
283
+ this.pipeline.enqueueFlush(this.host, recordFrame);
284
+ return 'continue';
285
+ }
286
+ case 'tool-call-start': {
287
+ if (this.pipeline.flushQueued || this.pipeline.queuedTextFragments.length > 0) {
288
+ this.pipeline.flushPendingText(this.host, recordFrame);
289
+ }
290
+ const normalized = LLMChunkNormalization.normalize(chunk, this.toolCallBuffer);
291
+ this.toolCallBuffer = normalized.toolCallBuffer;
292
+ this.host.emitToolStart(normalized.chunk?.toolName ?? '');
293
+ return 'continue';
294
+ }
295
+ case 'tool-call-delta': {
296
+ if (this.pipeline.flushQueued || this.pipeline.queuedTextFragments.length > 0) {
297
+ this.pipeline.flushPendingText(this.host, recordFrame);
298
+ }
299
+ const normalized = LLMChunkNormalization.normalize(chunk, this.toolCallBuffer);
300
+ this.toolCallBuffer = normalized.toolCallBuffer;
301
+ return 'continue';
302
+ }
303
+ case 'tool-call-end': {
304
+ if (this.pipeline.flushQueued || this.pipeline.queuedTextFragments.length > 0) {
305
+ this.pipeline.flushPendingText(this.host, recordFrame);
306
+ }
307
+ if (!this.pipeline.llmRuntime) {
308
+ this.pipeline.promoteFastLane();
309
+ }
310
+ const normalized = LLMChunkNormalization.normalize(chunk, this.toolCallBuffer);
311
+ this.toolCallBuffer = normalized.toolCallBuffer;
312
+ const name = normalized.chunk?.toolName ?? '';
313
+ const args = normalized.chunk?.toolArgs;
314
+ this.host.emitToolEnd(name, args);
315
+ return 'continue';
316
+ }
317
+ case 'done':
318
+ this.pipeline.flushPendingText(this.host, recordFrame);
319
+ this.host.emitDone(this.pipeline.accumulated);
320
+ return 'done';
321
+ }
322
+ }
323
+ replayGap() {
324
+ return this.receiptTracker.replayGap(this.pipeline, this.host);
325
+ }
326
+ rememberEnvelope(envelope) {
327
+ if (this.isDisposed()) {
328
+ return;
329
+ }
330
+ this.receiptTracker.rememberEnvelope(envelope);
331
+ }
332
+ reset(target) {
333
+ if (this.isDisposed()) {
334
+ return;
335
+ }
336
+ // Preserve 'reconnecting' state so that chunks arriving between reset() and
337
+ // activate() cannot re-engage the fast lane prematurely. The caller must
338
+ // explicitly call activate() to advance past the reconnecting gate.
339
+ if (this.runtimeState !== 'reconnecting') {
340
+ this.runtimeState = 'idle';
341
+ }
342
+ this.resetSession(target);
343
+ }
344
+ dispose() {
345
+ this.resetSession(this.currentTarget);
346
+ this.pipeline.releaseRuntime();
347
+ this.runtimeState = 'disposed';
348
+ }
349
+ isDisposed() {
350
+ return this.runtimeState === 'disposed';
351
+ }
352
+ resetSession(target = this.currentTarget) {
353
+ this.currentTarget = target;
354
+ this.host.setTarget(target);
355
+ this.toolCallBuffer = null;
356
+ this.pipeline.resetPipelineState();
357
+ this.receiptTracker.reset();
358
+ }
359
+ }
360
+ /**
361
+ * Build an {@link LLMSessionShape} backed by a caller-supplied
362
+ * {@link LLMSessionHost}. Tests and bench harnesses prefer this
363
+ * variant over {@link createLLMSession} so they can observe output
364
+ * without a DOM.
365
+ */
366
+ export function createLLMSessionWithHost(config, host) {
367
+ return new LLMSessionController(config, host);
368
+ }
369
+ /**
370
+ * Default `client:llm` factory: builds a session wired to the DOM.
371
+ * Equivalent to composing {@link createDOMLLMSessionHost} with
372
+ * {@link createLLMSessionWithHost}.
373
+ */
374
+ export function createLLMSession(config) {
375
+ const domHost = createDOMLLMSessionHost(config.element, config.target, {
376
+ htmlPolicy: config.htmlPolicy,
377
+ allowTrustedHtml: config.allowTrustedHtml,
378
+ });
379
+ return createLLMSessionWithHost({
380
+ mode: config.mode,
381
+ getDeviceTier: config.getDeviceTier,
382
+ target: config.target,
383
+ }, domHost);
384
+ }
385
+ //# sourceMappingURL=llm-session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm-session.js","sourceRoot":"","sources":["../../src/runtime/llm-session.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,kBAAkB,GAInB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,uBAAuB,EAA0B,MAAM,0BAA0B,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAA0B,MAAM,0BAA0B,CAAC;AA+E3F,MAAM,aAAa,GAAG,GAAS,EAAE,GAAE,CAAC,CAAC;AACrC,MAAM,aAAa,GAAG,GAAS,EAAE,GAAE,CAAC,CAAC;AACrC,MAAM,aAAa,GAAG,GAAS,EAAE,GAAE,CAAC,CAAC;AACrC,MAAM,iBAAiB,GAAG,GAAS,EAAE,GAAE,CAAC,CAAC;AACzC,MAAM,eAAe,GAAG,GAAS,EAAE,GAAE,CAAC,CAAC;AACvC,MAAM,YAAY,GAAG,GAAS,EAAE,GAAE,CAAC,CAAC;AACpC,MAAM,gBAAgB,GAAG,GAAY,EAAE,CAAC,IAAI,CAAC;AAC7C,MAAM,qBAAqB,GAAG,CAAC,KAAc,EAAW,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;AAEnF,SAAS,UAAU,CAAC,MAAmB,EAAE,IAAY;IACnD,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QACxC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpB,OAAO;IACT,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;AACpD,CAAC;AAED,SAAS,eAAe,CAAC,MAAmB,EAAE,IAAY;IACxD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CAAC,MAAM,GAAG,IAAI,CAAC,aAAa;QAC9C,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC;QAC5B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC5B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC;QACnC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,MAA4F,EAC5F,IAAoB;IAEpB,OAAO,IAAI,oBAAoB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAChD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAwB;IACvD,MAAM,OAAO,GAAG,uBAAuB,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE;QACrE,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;KAC1C,CAAC,CAAC;IACH,OAAO,wBAAwB,CAC7B;QACE,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,EACD,OAAO,CACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { LLMChunk } from '@czap/web';
2
+ /**
3
+ * Parse a raw `MessageEvent` payload into an {@link LLMChunk}. Returns
4
+ * `null` when the payload is unrecognised so callers can drop
5
+ * non-chunk events (metrics, heartbeats, ...) silently.
6
+ */
7
+ export declare function parseLLMChunk(event: Pick<MessageEvent, 'data'>): LLMChunk | null;
8
+ /**
9
+ * Entry point used by the `client:llm` directive to start a streaming
10
+ * LLM session on `element`. Reads `data-czap-llm-url` (plus optional
11
+ * target / mode attributes), validates it against the runtime
12
+ * endpoint policy, opens an SSE stream, and drives an
13
+ * {@link LLMSessionShape} to completion.
14
+ */
15
+ export declare function initLLMDirective(load: () => Promise<unknown>, element: HTMLElement): void;
16
+ //# sourceMappingURL=llm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../src/runtime/llm.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AA4D1C;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,QAAQ,GAAG,IAAI,CAGhF;AAuID;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAmIzF"}