@theokit/presenter 0.5.0 → 0.5.1
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/dist/index.d.ts +1 -1
- package/dist/index.js +54 -181
- package/dist/index.js.map +1 -1
- package/dist/wire/index.js +46 -103
- package/dist/wire/index.js.map +1 -1
- package/package.json +8 -8
- package/LICENSE +0 -201
- package/dist/chunk-Z4QWC7IK.js +0 -7
- package/dist/chunk-Z4QWC7IK.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -156,7 +156,7 @@ declare function fromSdkMessage(msg: SdkMessage): AgentOutputEvent[];
|
|
|
156
156
|
declare function fromInteractionUpdate(update: InteractionUpdate): AgentOutputEvent[];
|
|
157
157
|
|
|
158
158
|
/**
|
|
159
|
-
* The frame type is TheoKit's own since the `
|
|
159
|
+
* The frame type is TheoKit's own since the `remove-ai-dependency` plan; it is structurally the
|
|
160
160
|
* ai-sdk `UIMessageChunk`, so the emitted wire is unchanged and an ai-sdk client still reads it.
|
|
161
161
|
*/
|
|
162
162
|
type UIMessageChunk = WireChunk;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__name
|
|
3
|
-
} from "./chunk-Z4QWC7IK.js";
|
|
4
|
-
|
|
5
1
|
// src/agent-output-event.ts
|
|
6
2
|
var AGENT_OUTPUT_EVENT_TYPES = [
|
|
7
3
|
"text",
|
|
@@ -13,29 +9,25 @@ var AGENT_OUTPUT_EVENT_TYPES = [
|
|
|
13
9
|
"finish",
|
|
14
10
|
"status"
|
|
15
11
|
];
|
|
16
|
-
var isTextEvent =
|
|
17
|
-
var isReasoningEvent =
|
|
18
|
-
var isToolCallEvent =
|
|
19
|
-
var isPartialToolCallEvent =
|
|
20
|
-
var isToolResultEvent =
|
|
21
|
-
var isErrorEvent =
|
|
22
|
-
var isFinishEvent =
|
|
23
|
-
var isStatusEvent =
|
|
12
|
+
var isTextEvent = (e) => e.type === "text";
|
|
13
|
+
var isReasoningEvent = (e) => e.type === "reasoning";
|
|
14
|
+
var isToolCallEvent = (e) => e.type === "tool-call";
|
|
15
|
+
var isPartialToolCallEvent = (e) => e.type === "partial-tool-call";
|
|
16
|
+
var isToolResultEvent = (e) => e.type === "tool-result";
|
|
17
|
+
var isErrorEvent = (e) => e.type === "error";
|
|
18
|
+
var isFinishEvent = (e) => e.type === "finish";
|
|
19
|
+
var isStatusEvent = (e) => e.type === "status";
|
|
24
20
|
|
|
25
21
|
// src/presenter.ts
|
|
26
22
|
var UnknownPresenterError = class extends Error {
|
|
27
|
-
static {
|
|
28
|
-
__name(this, "UnknownPresenterError");
|
|
29
|
-
}
|
|
30
23
|
name = "UnknownPresenterError";
|
|
31
24
|
constructor(surface, known) {
|
|
32
|
-
super(
|
|
25
|
+
super(
|
|
26
|
+
`No presenter registered for surface "${surface}". Known: ${known.join(", ") || "(none)"}.`
|
|
27
|
+
);
|
|
33
28
|
}
|
|
34
29
|
};
|
|
35
30
|
var PresenterRegistry = class {
|
|
36
|
-
static {
|
|
37
|
-
__name(this, "PresenterRegistry");
|
|
38
|
-
}
|
|
39
31
|
#presenters = /* @__PURE__ */ new Map();
|
|
40
32
|
/** Register (or replace) the presenter for its surface. Returns `this` for fluent wiring. */
|
|
41
33
|
register(presenter) {
|
|
@@ -48,9 +40,7 @@ var PresenterRegistry = class {
|
|
|
48
40
|
}
|
|
49
41
|
/** The registered surface keys. */
|
|
50
42
|
surfaces() {
|
|
51
|
-
return [
|
|
52
|
-
...this.#presenters.keys()
|
|
53
|
-
];
|
|
43
|
+
return [...this.#presenters.keys()];
|
|
54
44
|
}
|
|
55
45
|
/** Resolve the presenter for `surface`, or throw {@link UnknownPresenterError} (never returns undefined). */
|
|
56
46
|
resolve(surface) {
|
|
@@ -64,7 +54,6 @@ var PresenterRegistry = class {
|
|
|
64
54
|
function asString(value, fallback) {
|
|
65
55
|
return typeof value === "string" ? value : fallback;
|
|
66
56
|
}
|
|
67
|
-
__name(asString, "asString");
|
|
68
57
|
function serializeToolResult(value, fallback) {
|
|
69
58
|
if (typeof value === "string") return value;
|
|
70
59
|
if (value === void 0 || value === null) return fallback;
|
|
@@ -74,17 +63,13 @@ function serializeToolResult(value, fallback) {
|
|
|
74
63
|
return typeof value === "bigint" ? value.toString() : fallback;
|
|
75
64
|
}
|
|
76
65
|
}
|
|
77
|
-
__name(serializeToolResult, "serializeToolResult");
|
|
78
66
|
function fromAssistant(msg) {
|
|
79
67
|
const events = [];
|
|
80
68
|
const content = msg.message?.content;
|
|
81
69
|
if (!Array.isArray(content)) return events;
|
|
82
70
|
for (const block of content) {
|
|
83
71
|
const b = block;
|
|
84
|
-
if (b.type === "text" && b.text) events.push({
|
|
85
|
-
type: "text",
|
|
86
|
-
text: b.text
|
|
87
|
-
});
|
|
72
|
+
if (b.type === "text" && b.text) events.push({ type: "text", text: b.text });
|
|
88
73
|
if (b.type === "tool_use") {
|
|
89
74
|
events.push({
|
|
90
75
|
type: "tool-call",
|
|
@@ -96,7 +81,6 @@ function fromAssistant(msg) {
|
|
|
96
81
|
}
|
|
97
82
|
return events;
|
|
98
83
|
}
|
|
99
|
-
__name(fromAssistant, "fromAssistant");
|
|
100
84
|
function fromToolUse(msg) {
|
|
101
85
|
const status = msg.status;
|
|
102
86
|
const callId = asString(msg.call_id, `tc-${Date.now()}`);
|
|
@@ -125,37 +109,19 @@ function fromToolUse(msg) {
|
|
|
125
109
|
}
|
|
126
110
|
if (status === "running") {
|
|
127
111
|
return [
|
|
128
|
-
{
|
|
129
|
-
type: "tool-call",
|
|
130
|
-
callId,
|
|
131
|
-
name,
|
|
132
|
-
input: msg.args ?? msg.input ?? msg.arguments ?? {}
|
|
133
|
-
}
|
|
112
|
+
{ type: "tool-call", callId, name, input: msg.args ?? msg.input ?? msg.arguments ?? {} }
|
|
134
113
|
];
|
|
135
114
|
}
|
|
136
115
|
return [];
|
|
137
116
|
}
|
|
138
|
-
__name(fromToolUse, "fromToolUse");
|
|
139
117
|
function fromStatus(msg) {
|
|
140
118
|
const s = msg.status;
|
|
141
|
-
if (s === "FINISHED" || s === "CANCELLED") return [
|
|
142
|
-
{
|
|
143
|
-
type: "finish",
|
|
144
|
-
reason: s.toLowerCase()
|
|
145
|
-
}
|
|
146
|
-
];
|
|
119
|
+
if (s === "FINISHED" || s === "CANCELLED") return [{ type: "finish", reason: s.toLowerCase() }];
|
|
147
120
|
if (s === "ERROR" || s === "EXPIRED") {
|
|
148
|
-
return [
|
|
149
|
-
{
|
|
150
|
-
type: "error",
|
|
151
|
-
message: asString(msg.message, "Agent error"),
|
|
152
|
-
code: "AGENT_ERROR"
|
|
153
|
-
}
|
|
154
|
-
];
|
|
121
|
+
return [{ type: "error", message: asString(msg.message, "Agent error"), code: "AGENT_ERROR" }];
|
|
155
122
|
}
|
|
156
123
|
return [];
|
|
157
124
|
}
|
|
158
|
-
__name(fromStatus, "fromStatus");
|
|
159
125
|
function fromSdkMessage(msg) {
|
|
160
126
|
switch (msg.type) {
|
|
161
127
|
case "assistant":
|
|
@@ -163,12 +129,7 @@ function fromSdkMessage(msg) {
|
|
|
163
129
|
case "tool_call":
|
|
164
130
|
return fromToolUse(msg);
|
|
165
131
|
case "thinking":
|
|
166
|
-
return [
|
|
167
|
-
{
|
|
168
|
-
type: "reasoning",
|
|
169
|
-
text: asString(msg.text, "")
|
|
170
|
-
}
|
|
171
|
-
];
|
|
132
|
+
return [{ type: "reasoning", text: asString(msg.text, "") }];
|
|
172
133
|
case "status":
|
|
173
134
|
return fromStatus(msg);
|
|
174
135
|
// `system` / run-lifecycle is framework framing, not pure output — intentionally skipped (ADR-4).
|
|
@@ -176,23 +137,12 @@ function fromSdkMessage(msg) {
|
|
|
176
137
|
return [];
|
|
177
138
|
}
|
|
178
139
|
}
|
|
179
|
-
__name(fromSdkMessage, "fromSdkMessage");
|
|
180
140
|
function fromInteractionUpdate(update) {
|
|
181
141
|
switch (update.type) {
|
|
182
142
|
case "text-delta":
|
|
183
|
-
return update.text ? [
|
|
184
|
-
{
|
|
185
|
-
type: "text",
|
|
186
|
-
text: update.text
|
|
187
|
-
}
|
|
188
|
-
] : [];
|
|
143
|
+
return update.text ? [{ type: "text", text: update.text }] : [];
|
|
189
144
|
case "thinking-delta":
|
|
190
|
-
return update.text ? [
|
|
191
|
-
{
|
|
192
|
-
type: "reasoning",
|
|
193
|
-
text: update.text
|
|
194
|
-
}
|
|
195
|
-
] : [];
|
|
145
|
+
return update.text ? [{ type: "reasoning", text: update.text }] : [];
|
|
196
146
|
case "tool-call-started":
|
|
197
147
|
return [
|
|
198
148
|
{
|
|
@@ -225,13 +175,9 @@ function fromInteractionUpdate(update) {
|
|
|
225
175
|
return [];
|
|
226
176
|
}
|
|
227
177
|
}
|
|
228
|
-
__name(fromInteractionUpdate, "fromInteractionUpdate");
|
|
229
178
|
|
|
230
179
|
// src/presenters/ui-message-stream.ts
|
|
231
180
|
var UIMessageStreamPresenter = class {
|
|
232
|
-
static {
|
|
233
|
-
__name(this, "UIMessageStreamPresenter");
|
|
234
|
-
}
|
|
235
181
|
surface = "ui-message-stream";
|
|
236
182
|
#textId;
|
|
237
183
|
#openBlock = null;
|
|
@@ -242,11 +188,7 @@ var UIMessageStreamPresenter = class {
|
|
|
242
188
|
}
|
|
243
189
|
/** Emit the opening `start` chunk (exactly once, before any event). */
|
|
244
190
|
start() {
|
|
245
|
-
return [
|
|
246
|
-
{
|
|
247
|
-
type: "start"
|
|
248
|
-
}
|
|
249
|
-
];
|
|
191
|
+
return [{ type: "start" }];
|
|
250
192
|
}
|
|
251
193
|
present(event) {
|
|
252
194
|
switch (event.type) {
|
|
@@ -265,12 +207,7 @@ var UIMessageStreamPresenter = class {
|
|
|
265
207
|
...this.#emitToolResult(event.callId, event.name, event.result, event.isError ?? false)
|
|
266
208
|
];
|
|
267
209
|
case "error":
|
|
268
|
-
return [
|
|
269
|
-
{
|
|
270
|
-
type: "error",
|
|
271
|
-
errorText: event.message
|
|
272
|
-
}
|
|
273
|
-
];
|
|
210
|
+
return [{ type: "error", errorText: event.message }];
|
|
274
211
|
// `partial-tool-call` streams incremental args — the current web path emits no chunk for it
|
|
275
212
|
// (args are shown on the committed `tool-call`); `finish` / `status` are handled by finish()/host.
|
|
276
213
|
default:
|
|
@@ -278,32 +215,27 @@ var UIMessageStreamPresenter = class {
|
|
|
278
215
|
}
|
|
279
216
|
}
|
|
280
217
|
/**
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
218
|
+
* Close any open text/reasoning block and emit the terminal `finish` chunk. When `metadata` is given
|
|
219
|
+
* (a clean run's turn totals from the framework `done`), it rides `messageMetadata`; otherwise the
|
|
220
|
+
* finish is bare (error/abort turns), byte-identical to the original translator.
|
|
221
|
+
*/
|
|
285
222
|
finish(metadata) {
|
|
286
223
|
const out = this.#closeOpenBlock();
|
|
287
|
-
out.push(metadata ? {
|
|
288
|
-
type: "finish",
|
|
289
|
-
messageMetadata: metadata
|
|
290
|
-
} : {
|
|
291
|
-
type: "finish"
|
|
292
|
-
});
|
|
224
|
+
out.push(metadata ? { type: "finish", messageMetadata: metadata } : { type: "finish" });
|
|
293
225
|
return out;
|
|
294
226
|
}
|
|
295
227
|
/**
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
228
|
+
* Close any open text/reasoning block WITHOUT finishing the stream. The host calls this before
|
|
229
|
+
* interleaving a framework chunk (HITL approval / checkpoint) that must not appear inside an open text
|
|
230
|
+
* block — mirroring the original translator's `closeOpenBlock` before those chunks. Idempotent.
|
|
231
|
+
*/
|
|
300
232
|
closeBlock() {
|
|
301
233
|
return this.#closeOpenBlock();
|
|
302
234
|
}
|
|
303
235
|
/**
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
236
|
+
* Whether a `callId` has already been introduced (a `tool-call` or a synthesized `tool-input`). The host
|
|
237
|
+
* uses this so a framework `approval_required` reuses the EC-1 synthesize-input-first rule exactly once.
|
|
238
|
+
*/
|
|
307
239
|
hasSeen(callId) {
|
|
308
240
|
return this.#seen.has(callId);
|
|
309
241
|
}
|
|
@@ -315,15 +247,9 @@ var UIMessageStreamPresenter = class {
|
|
|
315
247
|
#closeOpenBlock() {
|
|
316
248
|
const out = [];
|
|
317
249
|
if (this.#openBlock === "text") {
|
|
318
|
-
out.push({
|
|
319
|
-
type: "text-end",
|
|
320
|
-
id: this.#textId
|
|
321
|
-
});
|
|
250
|
+
out.push({ type: "text-end", id: this.#textId });
|
|
322
251
|
} else if (this.#openBlock === "reasoning" && this.#reasoningId) {
|
|
323
|
-
out.push({
|
|
324
|
-
type: "reasoning-end",
|
|
325
|
-
id: this.#reasoningId
|
|
326
|
-
});
|
|
252
|
+
out.push({ type: "reasoning-end", id: this.#reasoningId });
|
|
327
253
|
}
|
|
328
254
|
this.#openBlock = null;
|
|
329
255
|
this.#reasoningId = null;
|
|
@@ -332,17 +258,10 @@ var UIMessageStreamPresenter = class {
|
|
|
332
258
|
#emitTextDelta(content) {
|
|
333
259
|
const out = [];
|
|
334
260
|
if (this.#openBlock !== "text") {
|
|
335
|
-
out.push(...this.#closeOpenBlock(), {
|
|
336
|
-
type: "text-start",
|
|
337
|
-
id: this.#textId
|
|
338
|
-
});
|
|
261
|
+
out.push(...this.#closeOpenBlock(), { type: "text-start", id: this.#textId });
|
|
339
262
|
this.#openBlock = "text";
|
|
340
263
|
}
|
|
341
|
-
out.push({
|
|
342
|
-
type: "text-delta",
|
|
343
|
-
id: this.#textId,
|
|
344
|
-
delta: content
|
|
345
|
-
});
|
|
264
|
+
out.push({ type: "text-delta", id: this.#textId, delta: content });
|
|
346
265
|
return out;
|
|
347
266
|
}
|
|
348
267
|
#emitReasoningDelta(content) {
|
|
@@ -352,29 +271,16 @@ var UIMessageStreamPresenter = class {
|
|
|
352
271
|
out.push(...this.#closeOpenBlock());
|
|
353
272
|
reasoningId = crypto.randomUUID();
|
|
354
273
|
this.#reasoningId = reasoningId;
|
|
355
|
-
out.push({
|
|
356
|
-
type: "reasoning-start",
|
|
357
|
-
id: reasoningId
|
|
358
|
-
});
|
|
274
|
+
out.push({ type: "reasoning-start", id: reasoningId });
|
|
359
275
|
this.#openBlock = "reasoning";
|
|
360
276
|
}
|
|
361
|
-
out.push({
|
|
362
|
-
type: "reasoning-delta",
|
|
363
|
-
id: reasoningId,
|
|
364
|
-
delta: content
|
|
365
|
-
});
|
|
277
|
+
out.push({ type: "reasoning-delta", id: reasoningId, delta: content });
|
|
366
278
|
return out;
|
|
367
279
|
}
|
|
368
280
|
#emitToolCall(callId, name, input) {
|
|
369
281
|
this.#seen.add(callId);
|
|
370
282
|
return [
|
|
371
|
-
{
|
|
372
|
-
type: "tool-input-available",
|
|
373
|
-
toolCallId: callId,
|
|
374
|
-
toolName: name,
|
|
375
|
-
input,
|
|
376
|
-
dynamic: true
|
|
377
|
-
}
|
|
283
|
+
{ type: "tool-input-available", toolCallId: callId, toolName: name, input, dynamic: true }
|
|
378
284
|
];
|
|
379
285
|
}
|
|
380
286
|
#emitToolResult(callId, name, result, isError) {
|
|
@@ -391,17 +297,9 @@ var UIMessageStreamPresenter = class {
|
|
|
391
297
|
}
|
|
392
298
|
const output = typeof result === "string" ? result : "";
|
|
393
299
|
if (isError) {
|
|
394
|
-
out.push({
|
|
395
|
-
type: "tool-output-error",
|
|
396
|
-
toolCallId: callId,
|
|
397
|
-
errorText: output
|
|
398
|
-
});
|
|
300
|
+
out.push({ type: "tool-output-error", toolCallId: callId, errorText: output });
|
|
399
301
|
} else {
|
|
400
|
-
out.push({
|
|
401
|
-
type: "tool-output-available",
|
|
402
|
-
toolCallId: callId,
|
|
403
|
-
output
|
|
404
|
-
});
|
|
302
|
+
out.push({ type: "tool-output-available", toolCallId: callId, output });
|
|
405
303
|
}
|
|
406
304
|
return out;
|
|
407
305
|
}
|
|
@@ -411,11 +309,15 @@ var UIMessageStreamPresenter = class {
|
|
|
411
309
|
var ANSI = {
|
|
412
310
|
text: "",
|
|
413
311
|
reasoning: "\x1B[2m",
|
|
312
|
+
// dim
|
|
414
313
|
tool: "\x1B[36m",
|
|
314
|
+
// cyan
|
|
415
315
|
"tool-result": "\x1B[2m",
|
|
416
316
|
"tool-error": "\x1B[31m",
|
|
317
|
+
// red
|
|
417
318
|
error: "\x1B[31m",
|
|
418
319
|
status: "\x1B[35m",
|
|
320
|
+
// magenta
|
|
419
321
|
finish: "\x1B[2m"
|
|
420
322
|
};
|
|
421
323
|
var RESET = "\x1B[0m";
|
|
@@ -424,7 +326,6 @@ function preview(value, max) {
|
|
|
424
326
|
const flat = raw.replace(/\s+/g, " ").trim();
|
|
425
327
|
return flat.length > max ? `${flat.slice(0, max - 1)}\u2026` : flat;
|
|
426
328
|
}
|
|
427
|
-
__name(preview, "preview");
|
|
428
329
|
function safeJson(value) {
|
|
429
330
|
if (value === void 0 || value === null) return "";
|
|
430
331
|
try {
|
|
@@ -433,15 +334,10 @@ function safeJson(value) {
|
|
|
433
334
|
return typeof value === "bigint" ? value.toString() : "";
|
|
434
335
|
}
|
|
435
336
|
}
|
|
436
|
-
__name(safeJson, "safeJson");
|
|
437
337
|
function suffix(open, value, close) {
|
|
438
338
|
return value === void 0 ? "" : open + value + close;
|
|
439
339
|
}
|
|
440
|
-
__name(suffix, "suffix");
|
|
441
340
|
var TerminalPresenter = class {
|
|
442
|
-
static {
|
|
443
|
-
__name(this, "TerminalPresenter");
|
|
444
|
-
}
|
|
445
341
|
surface = "terminal";
|
|
446
342
|
#ansi;
|
|
447
343
|
#max;
|
|
@@ -452,33 +348,21 @@ var TerminalPresenter = class {
|
|
|
452
348
|
present(event) {
|
|
453
349
|
switch (event.type) {
|
|
454
350
|
case "text":
|
|
455
|
-
return event.text.length > 0 ? [
|
|
456
|
-
this.#row("text", event.text)
|
|
457
|
-
] : [];
|
|
351
|
+
return event.text.length > 0 ? [this.#row("text", event.text)] : [];
|
|
458
352
|
case "reasoning":
|
|
459
|
-
return event.text.length > 0 ? [
|
|
460
|
-
this.#row("reasoning", `\xB7 ${event.text}`)
|
|
461
|
-
] : [];
|
|
353
|
+
return event.text.length > 0 ? [this.#row("reasoning", `\xB7 ${event.text}`)] : [];
|
|
462
354
|
case "tool-call":
|
|
463
|
-
return [
|
|
464
|
-
this.#row("tool", `\u23FA ${event.name}(${preview(event.input, this.#max)})`)
|
|
465
|
-
];
|
|
355
|
+
return [this.#row("tool", `\u23FA ${event.name}(${preview(event.input, this.#max)})`)];
|
|
466
356
|
case "tool-result":
|
|
467
|
-
return [
|
|
468
|
-
this.#toolResult(event.isError === true, preview(event.result, this.#max))
|
|
469
|
-
];
|
|
357
|
+
return [this.#toolResult(event.isError === true, preview(event.result, this.#max))];
|
|
470
358
|
case "error":
|
|
471
|
-
return [
|
|
472
|
-
this.#row("error", `\u2716 ${event.message}${suffix(" (", event.code, ")")}`)
|
|
473
|
-
];
|
|
359
|
+
return [this.#row("error", `\u2716 ${event.message}${suffix(" (", event.code, ")")}`)];
|
|
474
360
|
case "status":
|
|
475
361
|
return [
|
|
476
362
|
this.#row("status", `\u25CF ${event.status}${suffix(" \u2014 ", event.detail, "")}`)
|
|
477
363
|
];
|
|
478
364
|
case "finish":
|
|
479
|
-
return [
|
|
480
|
-
this.#row("finish", this.#finishText(event.reason, event.usage?.totalTokens))
|
|
481
|
-
];
|
|
365
|
+
return [this.#row("finish", this.#finishText(event.reason, event.usage?.totalTokens))];
|
|
482
366
|
// `partial-tool-call` streams incremental args — the committed `tool-call` renders them.
|
|
483
367
|
default:
|
|
484
368
|
return [];
|
|
@@ -493,18 +377,12 @@ var TerminalPresenter = class {
|
|
|
493
377
|
return `<<${r}${t} >>`;
|
|
494
378
|
}
|
|
495
379
|
#row(kind, text) {
|
|
496
|
-
return {
|
|
497
|
-
kind,
|
|
498
|
-
text: this.#ansi && ANSI[kind] !== "" ? `${ANSI[kind]}${text}${RESET}` : text
|
|
499
|
-
};
|
|
380
|
+
return { kind, text: this.#ansi && ANSI[kind] !== "" ? `${ANSI[kind]}${text}${RESET}` : text };
|
|
500
381
|
}
|
|
501
382
|
};
|
|
502
383
|
|
|
503
384
|
// src/presenters/json.ts
|
|
504
385
|
var JsonPresenter = class {
|
|
505
|
-
static {
|
|
506
|
-
__name(this, "JsonPresenter");
|
|
507
|
-
}
|
|
508
386
|
surface = "json";
|
|
509
387
|
#ns;
|
|
510
388
|
constructor(options = {}) {
|
|
@@ -512,12 +390,7 @@ var JsonPresenter = class {
|
|
|
512
390
|
}
|
|
513
391
|
present(event) {
|
|
514
392
|
const { type, ...payload } = event;
|
|
515
|
-
return [
|
|
516
|
-
{
|
|
517
|
-
type: `${this.#ns}${type}`,
|
|
518
|
-
...payload
|
|
519
|
-
}
|
|
520
|
-
];
|
|
393
|
+
return [{ type: `${this.#ns}${type}`, ...payload }];
|
|
521
394
|
}
|
|
522
395
|
};
|
|
523
396
|
export {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/agent-output-event.ts","../src/presenter.ts","../src/source/from-sdk.ts","../src/presenters/ui-message-stream.ts","../src/presenters/terminal.ts","../src/presenters/json.ts"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/agent-output-event.ts","../src/presenter.ts","../src/source/from-sdk.ts","../src/presenters/ui-message-stream.ts","../src/presenters/terminal.ts","../src/presenters/json.ts"],"mappings":";AAqFO,IAAM,2BAA2B;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAMO,IAAM,cAAc,CAAC,MAA6C,EAAE,SAAS;AAC7E,IAAM,mBAAmB,CAAC,MAC/B,EAAE,SAAS;AACN,IAAM,kBAAkB,CAAC,MAC9B,EAAE,SAAS;AACN,IAAM,yBAAyB,CAAC,MACrC,EAAE,SAAS;AACN,IAAM,oBAAoB,CAAC,MAChC,EAAE,SAAS;AACN,IAAM,eAAe,CAAC,MAA8C,EAAE,SAAS;AAC/E,IAAM,gBAAgB,CAAC,MAA+C,EAAE,SAAS;AACjF,IAAM,gB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eAAO,CAAC;AAAA,IACZ;AAAA,EACF;AAAA,EAEA,YAAY,SAAkB,MAA2B;AACvD,WAAO,KAAK,KAAK,UAAU,eAAe,eAAe,YAAY,IAAI,EAAE;AAAA,EAC7E;AAAA,EAEA,YAAY,QAA4B,QAAoC;AAC1E,UAAM,IAAI,OAAO,KAAK,QAAQ,EAAE;AAChC,UAAM,IAAI,WAAW,SAAY,KAAK,SAAW,MAAM;AACvD,WAAO,KAAK,CAAC,GAAG,CAAC;AAAA,EACnB;AAAA,EAEA,KAAK,MAA2B,MAA2B;AACzD,WAAO,EAAE,MAAM,MAAM,KAAK,SAAS,KAAK,IAAI,MAAM,KAAK,GAAG,KAAK,IAAI,CAAC,GAAG,IAAI,GAAG,KAAK,KAAK,KAAK;AAAA,EAC/F;AACF;;;AC3FO,IAAM,gBAAN,MAAqD;AAAA,EACjD,UAAU;AAAA,EACV;AAAA,EAET,YAAY,UAAgC,CAAC,GAAG;AAC9C,SAAK,MAAM,QAAQ,aAAa;AAAA,EAClC;AAAA,EAEA,QAAQ,OAAuC;AAG7C,UAAM,EAAE,MAAM,GAAG,QAAQ,IAAI;AAC7B,WAAO,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,GAAG,IAAI,IAAI,GAAG,QAAQ,CAAC;AAAA,EACpD;AACF;","names":[]}
|
package/dist/wire/index.js
CHANGED
|
@@ -1,45 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__name
|
|
3
|
-
} from "../chunk-Z4QWC7IK.js";
|
|
4
|
-
|
|
5
1
|
// src/wire/chunk-schema.ts
|
|
6
2
|
import { z } from "zod";
|
|
7
3
|
var dataPartSchema = z.object({
|
|
8
|
-
type: z.custom(
|
|
4
|
+
type: z.custom(
|
|
5
|
+
(v) => typeof v === "string" && /^data-[a-z][a-z0-9-]*$/.test(v)
|
|
6
|
+
),
|
|
9
7
|
data: z.record(z.string(), z.unknown()),
|
|
10
8
|
transient: z.boolean().optional()
|
|
11
9
|
});
|
|
12
10
|
var fixedChunkSchema = z.discriminatedUnion("type", [
|
|
13
|
-
z.object({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}),
|
|
17
|
-
z.object({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}),
|
|
21
|
-
z.object({
|
|
22
|
-
type: z.literal("text-delta"),
|
|
23
|
-
id: z.string(),
|
|
24
|
-
delta: z.string()
|
|
25
|
-
}),
|
|
26
|
-
z.object({
|
|
27
|
-
type: z.literal("text-end"),
|
|
28
|
-
id: z.string()
|
|
29
|
-
}),
|
|
30
|
-
z.object({
|
|
31
|
-
type: z.literal("reasoning-start"),
|
|
32
|
-
id: z.string()
|
|
33
|
-
}),
|
|
34
|
-
z.object({
|
|
35
|
-
type: z.literal("reasoning-delta"),
|
|
36
|
-
id: z.string(),
|
|
37
|
-
delta: z.string()
|
|
38
|
-
}),
|
|
39
|
-
z.object({
|
|
40
|
-
type: z.literal("reasoning-end"),
|
|
41
|
-
id: z.string()
|
|
42
|
-
}),
|
|
11
|
+
z.object({ type: z.literal("start"), messageId: z.string().optional() }),
|
|
12
|
+
z.object({ type: z.literal("text-start"), id: z.string() }),
|
|
13
|
+
z.object({ type: z.literal("text-delta"), id: z.string(), delta: z.string() }),
|
|
14
|
+
z.object({ type: z.literal("text-end"), id: z.string() }),
|
|
15
|
+
z.object({ type: z.literal("reasoning-start"), id: z.string() }),
|
|
16
|
+
z.object({ type: z.literal("reasoning-delta"), id: z.string(), delta: z.string() }),
|
|
17
|
+
z.object({ type: z.literal("reasoning-end"), id: z.string() }),
|
|
43
18
|
z.object({
|
|
44
19
|
type: z.literal("tool-input-available"),
|
|
45
20
|
toolCallId: z.string(),
|
|
@@ -66,19 +41,10 @@ var fixedChunkSchema = z.discriminatedUnion("type", [
|
|
|
66
41
|
// `errorText` is optional: a malformed error frame must still be RECOGNISED as an error so the
|
|
67
42
|
// reader can reject. Requiring the field would push it into the discard path and turn a real
|
|
68
43
|
// provider failure into silence — theokit#136 through a side door.
|
|
69
|
-
z.object({
|
|
70
|
-
|
|
71
|
-
errorText: z.string().optional()
|
|
72
|
-
}),
|
|
73
|
-
z.object({
|
|
74
|
-
type: z.literal("finish"),
|
|
75
|
-
messageMetadata: z.unknown().optional()
|
|
76
|
-
})
|
|
77
|
-
]);
|
|
78
|
-
var wireChunkSchema = z.union([
|
|
79
|
-
fixedChunkSchema,
|
|
80
|
-
dataPartSchema
|
|
44
|
+
z.object({ type: z.literal("error"), errorText: z.string().optional() }),
|
|
45
|
+
z.object({ type: z.literal("finish"), messageMetadata: z.unknown().optional() })
|
|
81
46
|
]);
|
|
47
|
+
var wireChunkSchema = z.union([fixedChunkSchema, dataPartSchema]);
|
|
82
48
|
var WIRE_CHUNK_TYPES = [
|
|
83
49
|
"start",
|
|
84
50
|
"text-start",
|
|
@@ -100,21 +66,14 @@ var WIRE_DATA_PART_PREFIX = "data-";
|
|
|
100
66
|
var DONE_SENTINEL = "[DONE]";
|
|
101
67
|
var DEFAULT_MAX_FRAME_BYTES = 1e6;
|
|
102
68
|
var WireStreamError = class extends Error {
|
|
103
|
-
static {
|
|
104
|
-
__name(this, "WireStreamError");
|
|
105
|
-
}
|
|
106
69
|
name = "WireStreamError";
|
|
107
70
|
};
|
|
108
71
|
var WireFrameTooLargeError = class extends Error {
|
|
109
|
-
static {
|
|
110
|
-
__name(this, "WireFrameTooLargeError");
|
|
111
|
-
}
|
|
112
72
|
name = "WireFrameTooLargeError";
|
|
113
73
|
};
|
|
114
74
|
function normalizeEol(text) {
|
|
115
75
|
return text.replace(/\r\n|\r/g, "\n");
|
|
116
76
|
}
|
|
117
|
-
__name(normalizeEol, "normalizeEol");
|
|
118
77
|
function joinDataLines(event) {
|
|
119
78
|
const out = [];
|
|
120
79
|
for (const line of event.split("\n")) {
|
|
@@ -124,14 +83,13 @@ function joinDataLines(event) {
|
|
|
124
83
|
}
|
|
125
84
|
return out.join("\n");
|
|
126
85
|
}
|
|
127
|
-
__name(joinDataLines, "joinDataLines");
|
|
128
86
|
function parseWireStream(bytes, options = {}) {
|
|
129
87
|
const maxFrameBytes = options.maxFrameBytes ?? DEFAULT_MAX_FRAME_BYTES;
|
|
130
88
|
const warn = options.onWarn ?? (() => void 0);
|
|
131
89
|
const decoder = new TextDecoderStream();
|
|
132
90
|
const reader = bytes.pipeThrough(decoder).getReader();
|
|
133
91
|
let buffer = "";
|
|
134
|
-
const drain =
|
|
92
|
+
const drain = (controller) => {
|
|
135
93
|
let emitted = 0;
|
|
136
94
|
let cut = buffer.indexOf("\n\n");
|
|
137
95
|
while (cut !== -1) {
|
|
@@ -144,16 +102,14 @@ function parseWireStream(bytes, options = {}) {
|
|
|
144
102
|
try {
|
|
145
103
|
raw = JSON.parse(payload);
|
|
146
104
|
} catch {
|
|
147
|
-
warn(`wire: frame
|
|
105
|
+
warn(`wire: frame with invalid JSON discarded (${payload.slice(0, 60)})`);
|
|
148
106
|
continue;
|
|
149
107
|
}
|
|
150
108
|
if (typeof raw === "object" && raw !== null && raw.type === "error") {
|
|
151
109
|
const text = raw.errorText;
|
|
152
110
|
controller.enqueue({
|
|
153
111
|
type: "error",
|
|
154
|
-
...typeof text === "string" && text.length > 0 ? {
|
|
155
|
-
errorText: text
|
|
156
|
-
} : {}
|
|
112
|
+
...typeof text === "string" && text.length > 0 ? { errorText: text } : {}
|
|
157
113
|
});
|
|
158
114
|
emitted += 1;
|
|
159
115
|
continue;
|
|
@@ -163,20 +119,22 @@ function parseWireStream(bytes, options = {}) {
|
|
|
163
119
|
controller.enqueue(parsed.data);
|
|
164
120
|
emitted += 1;
|
|
165
121
|
} else {
|
|
166
|
-
warn(
|
|
122
|
+
warn(
|
|
123
|
+
`wire: unknown or invalid variant discarded (${String(raw.type)})`
|
|
124
|
+
);
|
|
167
125
|
}
|
|
168
126
|
}
|
|
169
127
|
return emitted;
|
|
170
|
-
}
|
|
128
|
+
};
|
|
171
129
|
return new ReadableStream({
|
|
172
130
|
/**
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
131
|
+
* Loop until this pull produces at least one chunk or the source ends.
|
|
132
|
+
*
|
|
133
|
+
* A `pull` that returns having enqueued nothing is NOT reliably re-invoked by the controller,
|
|
134
|
+
* so a frame that yields no chunk (the `[DONE]` sentinel, a comment, a discarded variant) would
|
|
135
|
+
* hang the consumer on its next `read()`. Measured: the `[DONE]` test timed out at exactly this
|
|
136
|
+
* point. Looping here makes progress a property of the parser, not of the scheduler.
|
|
137
|
+
*/
|
|
180
138
|
async pull(controller) {
|
|
181
139
|
for (; ; ) {
|
|
182
140
|
const { done, value } = await reader.read();
|
|
@@ -186,7 +144,9 @@ function parseWireStream(bytes, options = {}) {
|
|
|
186
144
|
}
|
|
187
145
|
buffer += normalizeEol(value);
|
|
188
146
|
if (buffer.length > maxFrameBytes) {
|
|
189
|
-
throw new WireFrameTooLargeError(
|
|
147
|
+
throw new WireFrameTooLargeError(
|
|
148
|
+
`wire: frame exceeded ${maxFrameBytes} bytes with no terminator; aborting instead of accumulating`
|
|
149
|
+
);
|
|
190
150
|
}
|
|
191
151
|
if (drain(controller) > 0) return;
|
|
192
152
|
}
|
|
@@ -196,30 +156,24 @@ function parseWireStream(bytes, options = {}) {
|
|
|
196
156
|
}
|
|
197
157
|
});
|
|
198
158
|
}
|
|
199
|
-
__name(parseWireStream, "parseWireStream");
|
|
200
159
|
|
|
201
160
|
// src/wire/read-message-stream.ts
|
|
202
161
|
function snapshot(message) {
|
|
203
162
|
return structuredClone(message);
|
|
204
163
|
}
|
|
205
|
-
__name(snapshot, "snapshot");
|
|
206
164
|
function open(messageId) {
|
|
207
165
|
return {
|
|
208
|
-
message: {
|
|
209
|
-
id: messageId ?? "",
|
|
210
|
-
role: "assistant",
|
|
211
|
-
parts: []
|
|
212
|
-
},
|
|
166
|
+
message: { id: messageId ?? "", role: "assistant", parts: [] },
|
|
213
167
|
blocks: /* @__PURE__ */ new Map(),
|
|
214
168
|
tools: /* @__PURE__ */ new Map()
|
|
215
169
|
};
|
|
216
170
|
}
|
|
217
|
-
__name(open, "open");
|
|
218
171
|
function raiseStreamError(chunk) {
|
|
219
172
|
const text = chunk.errorText;
|
|
220
|
-
throw new WireStreamError(
|
|
173
|
+
throw new WireStreamError(
|
|
174
|
+
typeof text === "string" && text.length > 0 ? text : "agent stream failed without a message"
|
|
175
|
+
);
|
|
221
176
|
}
|
|
222
|
-
__name(raiseStreamError, "raiseStreamError");
|
|
223
177
|
async function* readMessageStream(chunks) {
|
|
224
178
|
let state = null;
|
|
225
179
|
for await (const chunk of chunks) {
|
|
@@ -231,12 +185,18 @@ async function* readMessageStream(chunks) {
|
|
|
231
185
|
if (messageId !== void 0) yield snapshot(state.message);
|
|
232
186
|
continue;
|
|
233
187
|
}
|
|
234
|
-
if (chunk.type === "finish")
|
|
188
|
+
if (chunk.type === "finish") {
|
|
189
|
+
const metadata = chunk.messageMetadata;
|
|
190
|
+
if (metadata === void 0) continue;
|
|
191
|
+
state ??= open(void 0);
|
|
192
|
+
state.message.metadata = metadata;
|
|
193
|
+
yield snapshot(state.message);
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
235
196
|
state ??= open(void 0);
|
|
236
197
|
if (applyChunk(state, chunk)) yield snapshot(state.message);
|
|
237
198
|
}
|
|
238
199
|
}
|
|
239
|
-
__name(readMessageStream, "readMessageStream");
|
|
240
200
|
function applyChunk(state, chunk) {
|
|
241
201
|
const parts = state.message.parts;
|
|
242
202
|
switch (chunk.type) {
|
|
@@ -255,17 +215,12 @@ function applyChunk(state, chunk) {
|
|
|
255
215
|
return applyDataPart(parts, chunk);
|
|
256
216
|
}
|
|
257
217
|
}
|
|
258
|
-
__name(applyChunk, "applyChunk");
|
|
259
218
|
function applyBlock(state, parts, chunk) {
|
|
260
219
|
const id = chunk.id;
|
|
261
220
|
if (chunk.type === "text-start" || chunk.type === "reasoning-start") {
|
|
262
221
|
state.blocks.set(id, parts.length);
|
|
263
222
|
const kind = chunk.type === "text-start" ? "text" : "reasoning";
|
|
264
|
-
parts.push({
|
|
265
|
-
type: kind,
|
|
266
|
-
text: "",
|
|
267
|
-
state: "streaming"
|
|
268
|
-
});
|
|
223
|
+
parts.push({ type: kind, text: "", state: "streaming" });
|
|
269
224
|
return true;
|
|
270
225
|
}
|
|
271
226
|
const at = state.blocks.get(id);
|
|
@@ -278,7 +233,6 @@ function applyBlock(state, parts, chunk) {
|
|
|
278
233
|
part.text = (typeof part.text === "string" ? part.text : "") + chunk.delta;
|
|
279
234
|
return true;
|
|
280
235
|
}
|
|
281
|
-
__name(applyBlock, "applyBlock");
|
|
282
236
|
function applyTool(state, parts, chunk) {
|
|
283
237
|
const c = chunk;
|
|
284
238
|
if (chunk.type === "tool-input-available") {
|
|
@@ -295,30 +249,19 @@ function applyTool(state, parts, chunk) {
|
|
|
295
249
|
const at = state.tools.get(c.toolCallId);
|
|
296
250
|
if (at === void 0) return false;
|
|
297
251
|
if (chunk.type === "tool-output-error") {
|
|
298
|
-
Object.assign(parts[at], {
|
|
299
|
-
state: "output-error",
|
|
300
|
-
errorText: c.errorText
|
|
301
|
-
});
|
|
252
|
+
Object.assign(parts[at], { state: "output-error", errorText: c.errorText });
|
|
302
253
|
return true;
|
|
303
254
|
}
|
|
304
|
-
Object.assign(parts[at], {
|
|
305
|
-
state: "output-available",
|
|
306
|
-
output: c.output
|
|
307
|
-
});
|
|
255
|
+
Object.assign(parts[at], { state: "output-available", output: c.output });
|
|
308
256
|
return true;
|
|
309
257
|
}
|
|
310
|
-
__name(applyTool, "applyTool");
|
|
311
258
|
function applyDataPart(parts, chunk) {
|
|
312
259
|
if (!chunk.type.startsWith("data-")) return false;
|
|
313
260
|
const part = chunk;
|
|
314
261
|
if (part.transient === true) return false;
|
|
315
|
-
parts.push({
|
|
316
|
-
type: part.type,
|
|
317
|
-
data: part.data
|
|
318
|
-
});
|
|
262
|
+
parts.push({ type: part.type, data: part.data });
|
|
319
263
|
return true;
|
|
320
264
|
}
|
|
321
|
-
__name(applyDataPart, "applyDataPart");
|
|
322
265
|
export {
|
|
323
266
|
WIRE_CHUNK_TYPES,
|
|
324
267
|
WIRE_DATA_PART_PREFIX,
|
package/dist/wire/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/wire/chunk-schema.ts","../../src/wire/parse-wire-stream.ts","../../src/wire/read-message-stream.ts"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/wire/chunk-schema.ts","../../src/wire/parse-wire-stream.ts","../../src/wire/read-message-stream.ts"],"mappings":";AAAA,SAAS,SAAS;AA6ClB,IAAM,iBAAiB,EAAE,OAAO;AAAA,EAC9B,MAAM,EAAE;AAAA,IACN,CAAC,MAAM,OAAO,MAAM,YAAY,yBAAyB,KAAK,CAAC;AAAA,EACjE;AAAA,EACA,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC;AAAA,EACtC,WAAW,EAAE,QAAQ,EAAE,SAAS;AAClC,CAAC;AAED,IAAM,mBAAmB,EAAE,mBAAmB,QAAQ;AAAA,EACpD,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,OAAO,GAAG,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAAA,EAEvE,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,YAAY,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC;AAAA,EAC1D,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,YAAY,GAAG,IAAI,EAAE,OAAO,GAAG,OAAO,EAAE,OAAO,EAAE,CAAC;AAAA,EAC7E,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,UAAU,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC;AAAA,EAExD,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,iBAAiB,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC;AAAA,EAC/D,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,iBAAiB,GAAG,IAAI,EAAE,OAAO,GA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AM,QAAO;AACpC,QAAM,KAAK,EAAE,MAAM,KAAK,MAAM,MAAM,KAAK,KAAK,CAAC;AAC/C,SAAO;AACT;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theokit/presenter",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "TheoKit's presentation layer — the canonical AgentOutputEvent + Presenter Strategy that turns @theokit/sdk agent output into any surface (web UIMessageStream, terminal ANSI, JSON API) from ONE normalized event.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -21,6 +21,12 @@
|
|
|
21
21
|
"README.md",
|
|
22
22
|
"LICENSE"
|
|
23
23
|
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup",
|
|
26
|
+
"test": "vitest run",
|
|
27
|
+
"test:watch": "vitest",
|
|
28
|
+
"typecheck": "tsc --noEmit"
|
|
29
|
+
},
|
|
24
30
|
"peerDependencies": {
|
|
25
31
|
"@theokit/sdk": "^4.40.0",
|
|
26
32
|
"zod": "^4.0.0"
|
|
@@ -36,11 +42,5 @@
|
|
|
36
42
|
"license": "MIT",
|
|
37
43
|
"engines": {
|
|
38
44
|
"node": ">=22.12.0"
|
|
39
|
-
},
|
|
40
|
-
"scripts": {
|
|
41
|
-
"build": "tsup",
|
|
42
|
-
"test": "vitest run",
|
|
43
|
-
"test:watch": "vitest",
|
|
44
|
-
"typecheck": "tsc --noEmit"
|
|
45
45
|
}
|
|
46
|
-
}
|
|
46
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for describing the origin of the Work and
|
|
141
|
-
reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright 2026 usetheo.dev
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|
package/dist/chunk-Z4QWC7IK.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"mappings":"","names":[]}
|