@typecaast/schema 0.2.1 → 0.4.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/dist/index.cjs +142 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +358 -47
- package/dist/index.d.ts +358 -47
- package/dist/index.js +127 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/typecaast.schema.json +820 -392
package/dist/index.cjs
CHANGED
|
@@ -68,6 +68,18 @@ var inlineCodeSchema = zod.z.object({
|
|
|
68
68
|
type: zod.z.literal("code"),
|
|
69
69
|
value: zod.z.string()
|
|
70
70
|
});
|
|
71
|
+
var inlineBoldSchema = zod.z.object({
|
|
72
|
+
type: zod.z.literal("bold"),
|
|
73
|
+
value: zod.z.string()
|
|
74
|
+
});
|
|
75
|
+
var inlineItalicSchema = zod.z.object({
|
|
76
|
+
type: zod.z.literal("italic"),
|
|
77
|
+
value: zod.z.string()
|
|
78
|
+
});
|
|
79
|
+
var inlineStrikeSchema = zod.z.object({
|
|
80
|
+
type: zod.z.literal("strike"),
|
|
81
|
+
value: zod.z.string()
|
|
82
|
+
});
|
|
71
83
|
var inlineLinkSchema = zod.z.object({
|
|
72
84
|
type: zod.z.literal("link"),
|
|
73
85
|
href: zod.z.string(),
|
|
@@ -90,6 +102,9 @@ var inlineEmojiSchema = zod.z.object({
|
|
|
90
102
|
var inlineNodeSchema = zod.z.discriminatedUnion("type", [
|
|
91
103
|
inlineTextSchema,
|
|
92
104
|
inlineCodeSchema,
|
|
105
|
+
inlineBoldSchema,
|
|
106
|
+
inlineItalicSchema,
|
|
107
|
+
inlineStrikeSchema,
|
|
93
108
|
inlineLinkSchema,
|
|
94
109
|
inlineMentionSchema,
|
|
95
110
|
inlineEmojiSchema
|
|
@@ -105,9 +120,74 @@ var imageNodeSchema = zod.z.object({
|
|
|
105
120
|
width: zod.z.number().positive().optional(),
|
|
106
121
|
height: zod.z.number().positive().optional()
|
|
107
122
|
});
|
|
123
|
+
var buttonElementSchema = zod.z.object({
|
|
124
|
+
type: zod.z.literal("button"),
|
|
125
|
+
label: zod.z.string(),
|
|
126
|
+
href: zod.z.string().optional(),
|
|
127
|
+
style: zod.z.enum(["primary", "danger"]).optional()
|
|
128
|
+
});
|
|
129
|
+
var imageElementSchema = zod.z.object({
|
|
130
|
+
type: zod.z.literal("image"),
|
|
131
|
+
src: zod.z.string(),
|
|
132
|
+
alt: zod.z.string().optional()
|
|
133
|
+
});
|
|
134
|
+
var headerNodeSchema = zod.z.object({
|
|
135
|
+
type: zod.z.literal("header"),
|
|
136
|
+
text: zod.z.string()
|
|
137
|
+
});
|
|
138
|
+
var sectionFieldSchema = zod.z.object({
|
|
139
|
+
spans: zod.z.array(inlineNodeSchema).optional(),
|
|
140
|
+
text: zod.z.string().optional()
|
|
141
|
+
});
|
|
142
|
+
var sectionNodeSchema = zod.z.object({
|
|
143
|
+
type: zod.z.literal("section"),
|
|
144
|
+
spans: zod.z.array(inlineNodeSchema).optional(),
|
|
145
|
+
text: zod.z.string().optional(),
|
|
146
|
+
accessory: zod.z.discriminatedUnion("type", [buttonElementSchema, imageElementSchema]).optional(),
|
|
147
|
+
fields: zod.z.array(sectionFieldSchema).optional()
|
|
148
|
+
});
|
|
149
|
+
var contextTextElementSchema = zod.z.object({
|
|
150
|
+
type: zod.z.literal("text"),
|
|
151
|
+
spans: zod.z.array(inlineNodeSchema).optional(),
|
|
152
|
+
text: zod.z.string().optional()
|
|
153
|
+
});
|
|
154
|
+
var contextElementSchema = zod.z.discriminatedUnion("type", [
|
|
155
|
+
contextTextElementSchema,
|
|
156
|
+
imageElementSchema
|
|
157
|
+
]);
|
|
158
|
+
var contextNodeSchema = zod.z.object({
|
|
159
|
+
type: zod.z.literal("context"),
|
|
160
|
+
elements: zod.z.array(contextElementSchema)
|
|
161
|
+
});
|
|
162
|
+
var dividerNodeSchema = zod.z.object({
|
|
163
|
+
type: zod.z.literal("divider")
|
|
164
|
+
});
|
|
165
|
+
var actionsNodeSchema = zod.z.object({
|
|
166
|
+
type: zod.z.literal("actions"),
|
|
167
|
+
elements: zod.z.array(buttonElementSchema)
|
|
168
|
+
});
|
|
169
|
+
var codeBlockNodeSchema = zod.z.object({
|
|
170
|
+
type: zod.z.literal("codeblock"),
|
|
171
|
+
text: zod.z.string(),
|
|
172
|
+
lang: zod.z.string().optional()
|
|
173
|
+
});
|
|
174
|
+
var attachmentNodeSchema = zod.z.lazy(
|
|
175
|
+
() => zod.z.object({
|
|
176
|
+
type: zod.z.literal("attachment"),
|
|
177
|
+
color: zod.z.string().optional(),
|
|
178
|
+
content: contentSchema
|
|
179
|
+
})
|
|
180
|
+
);
|
|
108
181
|
var registry = /* @__PURE__ */ new Map([
|
|
109
182
|
["text", textNodeSchema],
|
|
110
|
-
["image", imageNodeSchema]
|
|
183
|
+
["image", imageNodeSchema],
|
|
184
|
+
["header", headerNodeSchema],
|
|
185
|
+
["section", sectionNodeSchema],
|
|
186
|
+
["context", contextNodeSchema],
|
|
187
|
+
["divider", dividerNodeSchema],
|
|
188
|
+
["actions", actionsNodeSchema],
|
|
189
|
+
["codeblock", codeBlockNodeSchema],
|
|
190
|
+
["attachment", attachmentNodeSchema]
|
|
111
191
|
]);
|
|
112
192
|
function registerContentNodeType(type, schema) {
|
|
113
193
|
registry.set(type, schema);
|
|
@@ -131,7 +211,7 @@ var contentNodeSchema = buildContentNodeSchema();
|
|
|
131
211
|
var contentSchema = zod.z.array(contentNodeSchema);
|
|
132
212
|
|
|
133
213
|
// src/content-sugar.ts
|
|
134
|
-
var INLINE_TOKEN = /`([^`]+)
|
|
214
|
+
var INLINE_TOKEN = /`([^`]+)`|\*(?!\s)([^*\n]+?)(?<!\s)\*|(?<![A-Za-z0-9])_(?!\s)([^_\n]+?)(?<!\s)_(?![A-Za-z0-9])|~(?!\s)([^~\n]+?)(?<!\s)~|(https?:\/\/[^\s]+)|<@([A-Za-z0-9_.-]+)>|(@[A-Za-z0-9_][\w.-]*)/g;
|
|
135
215
|
function parseInline(text) {
|
|
136
216
|
if (text.length === 0) return [];
|
|
137
217
|
const spans = [];
|
|
@@ -146,9 +226,17 @@ function parseInline(text) {
|
|
|
146
226
|
if (match[1] !== void 0) {
|
|
147
227
|
spans.push({ type: "code", value: match[1] });
|
|
148
228
|
} else if (match[2] !== void 0) {
|
|
149
|
-
spans.push({ type: "
|
|
229
|
+
spans.push({ type: "bold", value: match[2] });
|
|
150
230
|
} else if (match[3] !== void 0) {
|
|
151
|
-
spans.push({ type: "
|
|
231
|
+
spans.push({ type: "italic", value: match[3] });
|
|
232
|
+
} else if (match[4] !== void 0) {
|
|
233
|
+
spans.push({ type: "strike", value: match[4] });
|
|
234
|
+
} else if (match[5] !== void 0) {
|
|
235
|
+
spans.push({ type: "link", href: match[5] });
|
|
236
|
+
} else if (match[6] !== void 0) {
|
|
237
|
+
spans.push({ type: "mention", id: match[6], label: `@${match[6]}` });
|
|
238
|
+
} else if (match[7] !== void 0) {
|
|
239
|
+
spans.push({ type: "mention", label: match[7] });
|
|
152
240
|
}
|
|
153
241
|
lastIndex = match.index + matchText.length;
|
|
154
242
|
}
|
|
@@ -167,8 +255,41 @@ function imageToContentNode(image) {
|
|
|
167
255
|
if (image.height !== void 0) node.height = image.height;
|
|
168
256
|
return node;
|
|
169
257
|
}
|
|
258
|
+
function normalizeContentNode(node) {
|
|
259
|
+
if (node.type === "section") {
|
|
260
|
+
const s = node;
|
|
261
|
+
return {
|
|
262
|
+
type: "section",
|
|
263
|
+
spans: s.spans ?? parseInline(s.text ?? ""),
|
|
264
|
+
...s.accessory ? { accessory: s.accessory } : {},
|
|
265
|
+
...s.fields ? {
|
|
266
|
+
fields: s.fields.map((f) => ({
|
|
267
|
+
spans: f.spans ?? parseInline(f.text ?? "")
|
|
268
|
+
}))
|
|
269
|
+
} : {}
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
if (node.type === "context") {
|
|
273
|
+
const c = node;
|
|
274
|
+
return {
|
|
275
|
+
type: "context",
|
|
276
|
+
elements: c.elements.map(
|
|
277
|
+
(el) => el.type === "text" ? { type: "text", spans: el.spans ?? parseInline(el.text ?? "") } : el
|
|
278
|
+
)
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
if (node.type === "attachment") {
|
|
282
|
+
const a = node;
|
|
283
|
+
return {
|
|
284
|
+
type: "attachment",
|
|
285
|
+
...a.color ? { color: a.color } : {},
|
|
286
|
+
content: a.content.map(normalizeContentNode)
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
return node;
|
|
290
|
+
}
|
|
170
291
|
function toContentNodes(body) {
|
|
171
|
-
if (body.content) return body.content;
|
|
292
|
+
if (body.content) return body.content.map(normalizeContentNode);
|
|
172
293
|
const nodes = [];
|
|
173
294
|
if (body.text !== void 0 && body.text.length > 0) {
|
|
174
295
|
nodes.push(textToContentNode(body.text));
|
|
@@ -259,22 +380,6 @@ var readReceiptStepSchema = zod.z.object({
|
|
|
259
380
|
var systemStepSchema = zod.z.object({
|
|
260
381
|
type: zod.z.literal("system"),
|
|
261
382
|
from: zod.z.string().optional(),
|
|
262
|
-
/** Named card variant the skin renders, e.g. `"pr-opened"`. */
|
|
263
|
-
card: zod.z.string().optional(),
|
|
264
|
-
/**
|
|
265
|
-
* Buttons rendered alongside the system message. When `href` is set the
|
|
266
|
-
* skin should render the button as a link that opens in a new tab; when
|
|
267
|
-
* absent it should be visibly inert (e.g. `cursor: not-allowed`). `variant`
|
|
268
|
-
* controls visual emphasis; if omitted the first action defaults to
|
|
269
|
-
* `"primary"` and the rest to `"secondary"`.
|
|
270
|
-
*/
|
|
271
|
-
actions: zod.z.array(
|
|
272
|
-
zod.z.object({
|
|
273
|
-
label: zod.z.string(),
|
|
274
|
-
href: zod.z.string().optional(),
|
|
275
|
-
variant: zod.z.enum(["primary", "secondary"]).optional()
|
|
276
|
-
})
|
|
277
|
-
).optional(),
|
|
278
383
|
...bodyShape,
|
|
279
384
|
...stepBaseShape
|
|
280
385
|
});
|
|
@@ -448,31 +553,45 @@ function validateConfig(raw) {
|
|
|
448
553
|
|
|
449
554
|
exports.CONFIG_VERSION = CONFIG_VERSION;
|
|
450
555
|
exports.STEP_TYPES = STEP_TYPES;
|
|
556
|
+
exports.actionsNodeSchema = actionsNodeSchema;
|
|
451
557
|
exports.assetModeSchema = assetModeSchema;
|
|
558
|
+
exports.attachmentNodeSchema = attachmentNodeSchema;
|
|
452
559
|
exports.buildContentNodeSchema = buildContentNodeSchema;
|
|
560
|
+
exports.buttonElementSchema = buttonElementSchema;
|
|
561
|
+
exports.codeBlockNodeSchema = codeBlockNodeSchema;
|
|
453
562
|
exports.composerModeSchema = composerModeSchema;
|
|
454
563
|
exports.composerTypeStepSchema = composerTypeStepSchema;
|
|
455
564
|
exports.configJsonSchema = configJsonSchema;
|
|
456
565
|
exports.configSchema = configSchema;
|
|
457
566
|
exports.contentNodeSchema = contentNodeSchema;
|
|
458
567
|
exports.contentSchema = contentSchema;
|
|
568
|
+
exports.contextElementSchema = contextElementSchema;
|
|
569
|
+
exports.contextNodeSchema = contextNodeSchema;
|
|
570
|
+
exports.contextTextElementSchema = contextTextElementSchema;
|
|
459
571
|
exports.delayStepSchema = delayStepSchema;
|
|
460
572
|
exports.deleteStepSchema = deleteStepSchema;
|
|
573
|
+
exports.dividerNodeSchema = dividerNodeSchema;
|
|
461
574
|
exports.editStepSchema = editStepSchema;
|
|
462
575
|
exports.fitModeSchema = fitModeSchema;
|
|
576
|
+
exports.headerNodeSchema = headerNodeSchema;
|
|
577
|
+
exports.imageElementSchema = imageElementSchema;
|
|
463
578
|
exports.imageNodeSchema = imageNodeSchema;
|
|
464
579
|
exports.imageSugarSchema = imageSugarSchema;
|
|
465
580
|
exports.imageToContentNode = imageToContentNode;
|
|
581
|
+
exports.inlineBoldSchema = inlineBoldSchema;
|
|
466
582
|
exports.inlineCodeSchema = inlineCodeSchema;
|
|
467
583
|
exports.inlineEmojiSchema = inlineEmojiSchema;
|
|
584
|
+
exports.inlineItalicSchema = inlineItalicSchema;
|
|
468
585
|
exports.inlineLinkSchema = inlineLinkSchema;
|
|
469
586
|
exports.inlineMentionSchema = inlineMentionSchema;
|
|
470
587
|
exports.inlineNodeSchema = inlineNodeSchema;
|
|
588
|
+
exports.inlineStrikeSchema = inlineStrikeSchema;
|
|
471
589
|
exports.inlineTextSchema = inlineTextSchema;
|
|
472
590
|
exports.isKnownContentNodeType = isKnownContentNodeType;
|
|
473
591
|
exports.knownContentNodeTypes = knownContentNodeTypes;
|
|
474
592
|
exports.messageStepSchema = messageStepSchema;
|
|
475
593
|
exports.metaSchema = metaSchema;
|
|
594
|
+
exports.normalizeContentNode = normalizeContentNode;
|
|
476
595
|
exports.pacingSchema = pacingSchema;
|
|
477
596
|
exports.parseInline = parseInline;
|
|
478
597
|
exports.participantKindSchema = participantKindSchema;
|
|
@@ -481,6 +600,8 @@ exports.participantsSchema = participantsSchema;
|
|
|
481
600
|
exports.reactionStepSchema = reactionStepSchema;
|
|
482
601
|
exports.readReceiptStepSchema = readReceiptStepSchema;
|
|
483
602
|
exports.registerContentNodeType = registerContentNodeType;
|
|
603
|
+
exports.sectionFieldSchema = sectionFieldSchema;
|
|
604
|
+
exports.sectionNodeSchema = sectionNodeSchema;
|
|
484
605
|
exports.sendStepSchema = sendStepSchema;
|
|
485
606
|
exports.sizeSchema = sizeSchema;
|
|
486
607
|
exports.skinRefSchema = skinRefSchema;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/meta.ts","../src/participants.ts","../src/pacing.ts","../src/content-nodes.ts","../src/content-registry.ts","../src/content-sugar.ts","../src/timeline.ts","../src/config.ts","../src/validate.ts"],"names":["z"],"mappings":";;;;;AAGO,IAAM,UAAA,GAAaA,MAAE,MAAA,CAAO;AAAA,EACjC,OAAOA,KAAA,CAAE,MAAA,EAAO,CAAE,GAAA,GAAM,QAAA,EAAS;AAAA,EACjC,QAAQA,KAAA,CAAE,MAAA,EAAO,CAAE,GA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AA,UACV,OAAA,EAAS,WAAW,MAAM,CAAA,kCAAA,CAAA;AAAA,UAC1B,QAAA,EAAU,GAAG,GAAG,CAAA,OAAA,CAAA;AAAA,UAChB,IAAA,EAAM;AAAA,SACP,CAAA;AAAA,MACH;AAAA,IACF;AAEA,IAAA,IAAI,IAAA,CAAK,IAAA,KAAS,SAAA,IAAa,IAAA,CAAK,SAAS,QAAA,EAAU,aAAA,EAAA;AAAA,EACzD,CAAC,CAAA;AAED,EAAA,OAAO,WAAA;AACT","file":"index.cjs","sourcesContent":["import { z } from \"zod\";\n\n/** A pixel dimension pair (authoring reference; the exact frame for video). */\nexport const sizeSchema = z.object({\n width: z.number().int().positive(),\n height: z.number().int().positive(),\n});\nexport type Size = z.infer<typeof sizeSchema>;\n\n/**\n * How the rendered conversation fills its container. The widget is\n * **container-driven** in the first two modes — its size never grows\n * with content; messages clip when they overflow the bottom-anchored\n * thread.\n * - `reflow`: fills the container in both axes; bubbles re-wrap to the\n * container width.\n * - `scale`: renders at the exact authored canvas size and CSS-scales\n * to fit (preserves the canonical layout — letterboxes if the\n * container's aspect doesn't match the canvas).\n * - `fixed`: pins the widget to the authored canvas px; clips. The only\n * non-container-driven mode.\n */\nexport const fitModeSchema = z.enum([\"reflow\", \"scale\", \"fixed\"]);\nexport type FitMode = z.infer<typeof fitModeSchema>;\n\n/**\n * Reply-box (composer) visibility:\n * - `auto`: shown only while someone is typing/sending (default).\n * - `always`: keep the message input visible the whole time.\n * - `never`: never show it.\n */\nexport const composerModeSchema = z.enum([\"auto\", \"always\", \"never\"]);\nexport type ComposerMode = z.infer<typeof composerModeSchema>;\n\n/**\n * Color theme. `auto` inherits the host page's `prefers-color-scheme` (live\n * preview) and falls back to `light`; video export resolves `auto` to a\n * concrete mode and defaults to `light` when unspecified.\n */\nexport const themeModeSchema = z.enum([\"light\", \"dark\", \"auto\"]);\nexport type ThemeMode = z.infer<typeof themeModeSchema>;\n\n/**\n * Asset resolution strategy.\n * - `inline`: embed images as data URLs (self-contained config; default).\n * - `url`: reference hosted images (smaller config; user hosts their own).\n */\nexport const assetModeSchema = z.enum([\"inline\", \"url\"]);\nexport type AssetMode = z.infer<typeof assetModeSchema>;\n\n/** Reference to a skin plus its skin-specific options (validated by the skin). */\nexport const skinRefSchema = z.object({\n id: z.string().min(1),\n options: z.record(z.string(), z.unknown()).optional(),\n});\nexport type SkinRef = z.infer<typeof skinRefSchema>;\n\n/** Top-level rendering/authoring metadata. */\nexport const metaSchema = z.object({\n /** Authoring reference size; fixed frame for video. */\n canvas: sizeSchema,\n fps: z.number().int().positive().default(30),\n fit: fitModeSchema.default(\"reflow\"),\n theme: themeModeSchema.default(\"auto\"),\n skin: skinRefSchema,\n /** Seed for all deterministic jitter (no `Math.random`). */\n seed: z.number().int().default(42),\n /** Canvas background: `\"transparent\"` or any CSS color. */\n background: z.string().default(\"transparent\"),\n assets: assetModeSchema.default(\"inline\"),\n /** Reply-box visibility (see `composerModeSchema`). */\n composer: composerModeSchema.default(\"auto\"),\n /**\n * Auto-replay when the timeline reaches the end. Honored by the builder\n * preview and by `<Typecaast>` when the consumer doesn't pass an explicit\n * `loop` prop.\n */\n loop: z.boolean().default(false),\n});\n\n/** `meta` as it appears after parsing (defaults applied). */\nexport type Meta = z.infer<typeof metaSchema>;\n/** `meta` as authored (fields with defaults are optional). */\nexport type MetaInput = z.input<typeof metaSchema>;\n","import { z } from \"zod\";\n\n/** Whether a participant is a human or an app/bot (changes how skins render it). */\nexport const participantKindSchema = z.enum([\"person\", \"app\"]);\nexport type ParticipantKind = z.infer<typeof participantKindSchema>;\n\n/** A speaker in the conversation. */\nexport const participantSchema = z.object({\n /** Stable id referenced by timeline steps (`from`, `target`, …). */\n id: z.string().min(1),\n name: z.string().min(1),\n /** Avatar asset (data URL or referenced URL per `meta.assets`). */\n avatar: z.string().optional(),\n /** Accent color (CSS color) some skins use for the author. */\n color: z.string().optional(),\n /** The viewer — rendered as the \"self\" side and the composer's author. */\n isSelf: z.boolean().optional(),\n kind: participantKindSchema.default(\"person\"),\n});\nexport type Participant = z.infer<typeof participantSchema>;\nexport type ParticipantInput = z.input<typeof participantSchema>;\n\nexport const participantsSchema = z.array(participantSchema);\n","import { z } from \"zod\";\n\n/**\n * Global auto-pacing defaults. Every value is overridable per step in the\n * timeline; the engine computes delays/durations from these and bakes in\n * seeded, deterministic jitter (`humanize`).\n */\nexport const pacingSchema = z.object({\n /** Gap before an incoming message ≈ reading time of the prior message. */\n readingWpm: z.number().positive().default(240),\n /** Chars/sec for composer typing + sender typing duration. */\n typingCps: z.number().positive().default(14),\n /** ±fraction of seeded jitter so pacing doesn't feel robotic (0–1). */\n humanize: z.number().min(0).max(1).default(0.15),\n /** Delay before the first event. */\n startDelayMs: z.number().nonnegative().default(400),\n});\nexport type Pacing = z.infer<typeof pacingSchema>;\nexport type PacingInput = z.input<typeof pacingSchema>;\n","import { z } from \"zod\";\n\n/**\n * Inline marks inside a text node. `text` runs carry plain content; the others\n * are the recognized marks (`code`, `link`, `mention`, `emoji`). The set is\n * intentionally small in v1 — new marks can be added without a schema-version\n * bump (unknown content node types are handled leniently; see the registry).\n */\nexport const inlineTextSchema = z.object({\n type: z.literal(\"text\"),\n value: z.string(),\n});\nexport const inlineCodeSchema = z.object({\n type: z.literal(\"code\"),\n value: z.string(),\n});\nexport const inlineLinkSchema = z.object({\n type: z.literal(\"link\"),\n href: z.string(),\n label: z.string().optional(),\n});\nexport const inlineMentionSchema = z.object({\n type: z.literal(\"mention\"),\n /** Display label as authored, e.g. `\"@PostHog\"`. */\n label: z.string(),\n /** Resolved participant id, filled when the mention binds to a participant. */\n id: z.string().optional(),\n});\nexport const inlineEmojiSchema = z.object({\n type: z.literal(\"emoji\"),\n /** The rendered glyph, e.g. `\"🦔\"`. */\n value: z.string(),\n /** Optional shortcode, e.g. `\"hedgehog\"`. */\n shortcode: z.string().optional(),\n});\n\nexport const inlineNodeSchema = z.discriminatedUnion(\"type\", [\n inlineTextSchema,\n inlineCodeSchema,\n inlineLinkSchema,\n inlineMentionSchema,\n inlineEmojiSchema,\n]);\nexport type InlineNode = z.infer<typeof inlineNodeSchema>;\n\n/** A block of inline content. */\nexport const textNodeSchema = z.object({\n type: z.literal(\"text\"),\n spans: z.array(inlineNodeSchema),\n});\nexport type TextNode = z.infer<typeof textNodeSchema>;\n\n/** An in-message image (same hosting model as avatars, per `meta.assets`). */\nexport const imageNodeSchema = z.object({\n type: z.literal(\"image\"),\n src: z.string(),\n alt: z.string().optional(),\n width: z.number().positive().optional(),\n height: z.number().positive().optional(),\n});\nexport type ImageNode = z.infer<typeof imageNodeSchema>;\n\n/**\n * A content node whose `type` the runtime doesn't recognize. It validates\n * leniently (only `type` is required) and is skipped by skins that don't handle\n * it — so future node types (`attachment`, `linkPreview`, …) slot in without\n * breaking older runtimes or bumping the schema version.\n */\nexport interface UnknownContentNode {\n type: string;\n [key: string]: unknown;\n}\n\n/** The body of a message: an ordered list of content nodes. */\nexport type ContentNode = TextNode | ImageNode | UnknownContentNode;\n","import { z } from \"zod\";\nimport {\n imageNodeSchema,\n textNodeSchema,\n type ContentNode,\n} from \"./content-nodes.js\";\n\n/**\n * The content-type registry. Each message body node has a `type` resolved\n * through here. v1 registers `text` and `image`; additional types can be\n * registered (with their own strict schema) without a schema-version bump.\n *\n * Nodes whose `type` is **not** registered validate leniently (only `type` is\n * required) and are skipped by skins that don't handle them. Nodes whose `type`\n * **is** registered must satisfy that type's schema — so a malformed `text`\n * node is an error rather than silently passing through the lenient path.\n */\nconst registry = new Map<string, z.ZodTypeAny>([\n [\"text\", textNodeSchema],\n [\"image\", imageNodeSchema],\n]);\n\n/** Register (or override) the strict schema for a content node type. */\nexport function registerContentNodeType(\n type: string,\n schema: z.ZodTypeAny,\n): void {\n registry.set(type, schema);\n}\n\n/** The content node types the runtime validates strictly. */\nexport function knownContentNodeTypes(): string[] {\n return [...registry.keys()];\n}\n\nexport function isKnownContentNodeType(type: string): boolean {\n return registry.has(type);\n}\n\n/** Accepts any object with a string `type` that isn't a registered type. */\nconst lenientUnknownNodeSchema = z\n .looseObject({ type: z.string() })\n .refine((node) => !registry.has(node.type), {\n message: \"malformed content node for a registered type\",\n });\n\n/**\n * Build a content-node schema from the current registry state. Call this after\n * registering a new type to pick it up; `contentNodeSchema` below is the\n * default built from the v1 registry (`text` + `image`).\n */\nexport function buildContentNodeSchema(): z.ZodType<ContentNode> {\n return z.union([\n ...registry.values(),\n lenientUnknownNodeSchema,\n ]) as unknown as z.ZodType<ContentNode>;\n}\n\n/** Default content-node schema (text + image + lenient unknown). */\nexport const contentNodeSchema = buildContentNodeSchema();\n\n/** A message body: an ordered array of content nodes. */\nexport const contentSchema = z.array(contentNodeSchema);\n","import type {\n ContentNode,\n ImageNode,\n InlineNode,\n TextNode,\n} from \"./content-nodes.js\";\n\n/**\n * Matches an inline mark: a backtick code span, an http(s) link, or an\n * `@mention`. Everything else becomes plain text runs.\n */\nconst INLINE_TOKEN = /`([^`]+)`|(https?:\\/\\/[^\\s]+)|(@[A-Za-z0-9_][\\w.-]*)/g;\n\n/**\n * Parse a plain authoring string into inline nodes, extracting inline `code`,\n * links, and `@mentions`. Emoji are left inside text runs in v1 (they render\n * fine and a dedicated emoji mark can be authored explicitly).\n */\nexport function parseInline(text: string): InlineNode[] {\n if (text.length === 0) return [];\n const spans: InlineNode[] = [];\n const re = new RegExp(INLINE_TOKEN.source, \"g\");\n let lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = re.exec(text)) !== null) {\n const matchText = match[0] ?? \"\";\n if (match.index > lastIndex) {\n spans.push({ type: \"text\", value: text.slice(lastIndex, match.index) });\n }\n if (match[1] !== undefined) {\n spans.push({ type: \"code\", value: match[1] });\n } else if (match[2] !== undefined) {\n spans.push({ type: \"link\", href: match[2] });\n } else if (match[3] !== undefined) {\n spans.push({ type: \"mention\", label: match[3] });\n }\n lastIndex = match.index + matchText.length;\n }\n if (lastIndex < text.length) {\n spans.push({ type: \"text\", value: text.slice(lastIndex) });\n }\n return spans;\n}\n\n/** Convenience shape for authoring an in-message image. */\nexport interface ImageSugar {\n src: string;\n alt?: string;\n width?: number;\n height?: number;\n}\n\n/** `text` string → a single text content node. */\nexport function textToContentNode(text: string): TextNode {\n return { type: \"text\", spans: parseInline(text) };\n}\n\n/** `image` sugar → an image content node (drops undefined optionals). */\nexport function imageToContentNode(image: ImageSugar): ImageNode {\n const node: ImageNode = { type: \"image\", src: image.src };\n if (image.alt !== undefined) node.alt = image.alt;\n if (image.width !== undefined) node.width = image.width;\n if (image.height !== undefined) node.height = image.height;\n return node;\n}\n\n/** The sugar fields a message may carry instead of explicit `content`. */\nexport interface MessageBodySugar {\n /** Authored text (parsed into inline marks). */\n text?: string;\n /** In-message images, rendered after the text. */\n images?: ImageSugar[];\n /** Explicit content nodes; when present, wins over `text`/`images`. */\n content?: ContentNode[];\n}\n\n/**\n * Resolve a message's body sugar to content nodes. Explicit `content` is\n * authoritative; otherwise the text node (if any) comes first, then images —\n * matching the \"here's the toast: [image]\" ordering in the spec example.\n */\nexport function toContentNodes(body: MessageBodySugar): ContentNode[] {\n if (body.content) return body.content;\n const nodes: ContentNode[] = [];\n if (body.text !== undefined && body.text.length > 0) {\n nodes.push(textToContentNode(body.text));\n }\n if (body.images) {\n for (const image of body.images) nodes.push(imageToContentNode(image));\n }\n return nodes;\n}\n","import { z } from \"zod\";\nimport { contentSchema } from \"./content-registry.js\";\n\n/**\n * Per-step overrides shared by every step. The engine computes timing from the\n * pacing model; these win over the computed values. Use a dedicated `delay`\n * step type to insert explicit pauses on the timeline.\n */\nconst stepBaseShape = {\n /** Optional id so reactions/edits/deletes can target this step's message. */\n id: z.string().optional(),\n /** Reveal with no animation and no computed delay. */\n instant: z.boolean().optional(),\n};\n\n/** Authoring sugar for an in-message image (compiled to an image node). */\nexport const imageSugarSchema = z.object({\n src: z.string(),\n alt: z.string().optional(),\n width: z.number().positive().optional(),\n height: z.number().positive().optional(),\n});\n\n/** Message-body sugar fields; `content` (explicit nodes) wins when present. */\nconst bodyShape = {\n text: z.string().optional(),\n images: z.array(imageSugarSchema).optional(),\n content: contentSchema.optional(),\n};\n\n/** Optional typing indicator preceding a message. */\nconst messageTypingSchema = z.union([\n z.boolean(),\n z.object({ showTypingFor: z.number().nonnegative().optional() }),\n]);\n\n/** An incoming message, optionally preceded by a typing indicator. */\nexport const messageStepSchema = z.object({\n type: z.literal(\"message\"),\n from: z.string(),\n typing: messageTypingSchema.optional(),\n ...bodyShape,\n ...stepBaseShape,\n});\n\n/** A reaction landing on a target message (`$prev` or a message id). */\nexport const reactionStepSchema = z.object({\n type: z.literal(\"reaction\"),\n /** Message id to react to. Defaults to `$prev` (the most-recent message). */\n target: z.string().optional(),\n emoji: z.string(),\n /** Emoji shortcode without colons, e.g. `\"eyes\"` — shown in skin tooltips. */\n shortcode: z.string().optional(),\n from: z.string().optional(),\n /** Gap from when the target appears, before the reaction lands (ms). */\n delay: z.number().nonnegative().optional(),\n ...stepBaseShape,\n});\n\n/** A standalone typing indicator (no message necessarily follows). */\nexport const typingStepSchema = z.object({\n type: z.literal(\"typing\"),\n from: z.string(),\n showTypingFor: z.number().nonnegative().optional(),\n ...stepBaseShape,\n});\n\n/** The self participant typing into the composer, char by char. */\nexport const composerTypeStepSchema = z.object({\n type: z.literal(\"composerType\"),\n from: z.string(),\n text: z.string(),\n /** Override the computed typing duration (ms). */\n typingDuration: z.number().nonnegative().optional(),\n ...stepBaseShape,\n});\n\n/** Commit the composer's current text to the thread. */\nexport const sendStepSchema = z.object({\n type: z.literal(\"send\"),\n from: z.string().optional(),\n ...stepBaseShape,\n});\n\n/** Edit a previously sent message's body. */\nexport const editStepSchema = z.object({\n type: z.literal(\"edit\"),\n /** Message id to edit. Defaults to `$prev` (the most-recent message). */\n target: z.string().optional(),\n ...bodyShape,\n ...stepBaseShape,\n});\n\n/** Delete a previously sent message. */\nexport const deleteStepSchema = z.object({\n type: z.literal(\"delete\"),\n /** Message id to delete. Defaults to `$prev` (the most-recent message). */\n target: z.string().optional(),\n ...stepBaseShape,\n});\n\n/** A read receipt (optionally by a participant, optionally up to a message). */\nexport const readReceiptStepSchema = z.object({\n type: z.literal(\"readReceipt\"),\n by: z.string().optional(),\n target: z.string().optional(),\n ...stepBaseShape,\n});\n\n/** An app/system card (e.g. \"Pull request opened\" with action buttons). */\nexport const systemStepSchema = z.object({\n type: z.literal(\"system\"),\n from: z.string().optional(),\n /** Named card variant the skin renders, e.g. `\"pr-opened\"`. */\n card: z.string().optional(),\n /**\n * Buttons rendered alongside the system message. When `href` is set the\n * skin should render the button as a link that opens in a new tab; when\n * absent it should be visibly inert (e.g. `cursor: not-allowed`). `variant`\n * controls visual emphasis; if omitted the first action defaults to\n * `\"primary\"` and the rest to `\"secondary\"`.\n */\n actions: z\n .array(\n z.object({\n label: z.string(),\n href: z.string().optional(),\n variant: z.enum([\"primary\", \"secondary\"]).optional(),\n }),\n )\n .optional(),\n ...bodyShape,\n ...stepBaseShape,\n});\n\n/** An explicit pause in the timeline (formerly `beat`). */\nexport const delayStepSchema = z.object({\n type: z.literal(\"delay\"),\n duration: z.number().nonnegative(),\n ...stepBaseShape,\n});\n\nexport const timelineStepSchema = z.discriminatedUnion(\"type\", [\n messageStepSchema,\n reactionStepSchema,\n typingStepSchema,\n composerTypeStepSchema,\n sendStepSchema,\n editStepSchema,\n deleteStepSchema,\n readReceiptStepSchema,\n systemStepSchema,\n delayStepSchema,\n]);\nexport type TimelineStep = z.infer<typeof timelineStepSchema>;\nexport type TimelineStepInput = z.input<typeof timelineStepSchema>;\n\nexport const timelineSchema = z.array(timelineStepSchema);\n\n/** The discriminant values of every timeline step. */\nexport const STEP_TYPES = [\n \"message\",\n \"reaction\",\n \"typing\",\n \"composerType\",\n \"send\",\n \"edit\",\n \"delete\",\n \"readReceipt\",\n \"system\",\n \"delay\",\n] as const;\nexport type StepType = (typeof STEP_TYPES)[number];\n","import { z } from \"zod\";\nimport { metaSchema } from \"./meta.js\";\nimport { participantsSchema } from \"./participants.js\";\nimport { pacingSchema } from \"./pacing.js\";\nimport { timelineSchema } from \"./timeline.js\";\n\n/**\n * The config schema version. Distinct from the `@typecaast/schema` package\n * version (related but versioned independently — see PLAN §22). A config newer\n * than the installed runtime fails parsing with a clear error.\n */\nexport const CONFIG_VERSION = 1;\n\n/** The complete Typecaast config: the single source of truth for a simulation. */\nexport const configSchema = z.object({\n version: z.literal(CONFIG_VERSION),\n meta: metaSchema,\n participants: participantsSchema,\n /** Optional; omitted pacing resolves to the full default model. */\n pacing: pacingSchema.default(() => pacingSchema.parse({})),\n timeline: timelineSchema,\n});\n\n/** A parsed config (defaults applied). */\nexport type Config = z.infer<typeof configSchema>;\n/** A config as authored (fields with defaults are optional). */\nexport type ConfigInput = z.input<typeof configSchema>;\n\n/**\n * Generate the JSON Schema for a Typecaast config (for editor autocomplete and\n * `$schema` references). Lazy so importing the package never eagerly runs the\n * conversion. Refinements (e.g. the lenient content-node guard) are not\n * representable in JSON Schema and are dropped.\n */\nexport function configJsonSchema(): Record<string, unknown> {\n return z.toJSONSchema(configSchema, {\n unrepresentable: \"any\",\n target: \"draft-7\",\n }) as Record<string, unknown>;\n}\n","import { CONFIG_VERSION, configSchema } from \"./config.js\";\n\n/** Diagnostic severity tiers (PLAN §23). */\nexport type Severity = \"error\" | \"warning\" | \"info\";\n\n/**\n * A single validation finding. Every diagnostic carries a stable `code`, the\n * offending `location` (step/message/path), and a `hint` for remediation.\n */\nexport interface Diagnostic {\n code: string;\n severity: Severity;\n message: string;\n /** Dotted/indexed path, e.g. `timeline[3].from` or `meta.canvas.width`. */\n location?: string;\n hint?: string;\n}\n\nfunction formatPath(path: ReadonlyArray<PropertyKey>): string {\n let out = \"\";\n for (const key of path) {\n if (typeof key === \"number\") out += `[${key}]`;\n else if (out === \"\") out += String(key);\n else out += `.${String(key)}`;\n }\n return out;\n}\n\n/** Read an optional `from`/`by`/`target` field off any step shape. */\nfunction field(step: unknown, key: string): string | undefined {\n const value = (step as Record<string, unknown>)[key];\n return typeof value === \"string\" ? value : undefined;\n}\n\n/**\n * Validate a parsed config value (already JSON-decoded). Returns all\n * diagnostics — schema errors, then semantic checks (reference integrity,\n * target resolution). Reusable by the CLI and the builder's lint panel.\n *\n * A version newer than the runtime short-circuits with a single hard error.\n */\nexport function validateConfig(raw: unknown): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n if (raw && typeof raw === \"object\" && \"version\" in raw) {\n const version = (raw as { version: unknown }).version;\n if (typeof version === \"number\" && version > CONFIG_VERSION) {\n return [\n {\n code: \"E_VERSION\",\n severity: \"error\",\n message: `Config version ${version} is newer than this runtime supports (max ${CONFIG_VERSION}).`,\n location: \"version\",\n hint: \"Upgrade Typecaast (e.g. `npm i @typecaast/cli@latest`).\",\n },\n ];\n }\n }\n\n const result = configSchema.safeParse(raw);\n if (!result.success) {\n for (const issue of result.error.issues) {\n diagnostics.push({\n code: \"E_SCHEMA\",\n severity: \"error\",\n message: issue.message,\n location: formatPath(issue.path) || undefined,\n });\n }\n return diagnostics;\n }\n\n const config = result.data;\n\n // Duplicate participant ids.\n const ids = config.participants.map((p) => p.id);\n const idSet = new Set(ids);\n for (const dup of new Set(ids.filter((id, i) => ids.indexOf(id) !== i))) {\n diagnostics.push({\n code: \"E_DUP_PARTICIPANT\",\n severity: \"error\",\n message: `Duplicate participant id \"${dup}\".`,\n location: \"participants\",\n hint: \"Participant ids must be unique.\",\n });\n }\n\n const hasSelf = config.participants.some((p) => p.isSelf);\n let warnedNoSelf = false;\n const messageIds = new Set<string>();\n let priorMessages = 0;\n\n config.timeline.forEach((step, i) => {\n const loc = `timeline[${i}]`;\n\n const from = field(step, \"from\");\n if (from !== undefined && !idSet.has(from)) {\n diagnostics.push({\n code: \"E_REF_PARTICIPANT\",\n severity: \"error\",\n message: `Step references unknown participant \"${from}\".`,\n location: `${loc}.from`,\n hint: `Add a participant with id \"${from}\" or fix the reference.`,\n });\n }\n\n if (step.type === \"readReceipt\") {\n const by = field(step, \"by\");\n if (by !== undefined && !idSet.has(by)) {\n diagnostics.push({\n code: \"E_REF_PARTICIPANT\",\n severity: \"error\",\n message: `Read receipt references unknown participant \"${by}\".`,\n location: `${loc}.by`,\n hint: `Add a participant with id \"${by}\" or fix the reference.`,\n });\n }\n }\n\n if (\n (step.type === \"composerType\" || step.type === \"send\") &&\n !hasSelf &&\n !warnedNoSelf\n ) {\n warnedNoSelf = true;\n diagnostics.push({\n code: \"W_NO_SELF\",\n severity: \"warning\",\n message: \"The composer is used but no participant is marked as self.\",\n location: loc,\n hint: 'Mark a participant with `\"isSelf\": true`.',\n });\n }\n\n if (\n (step.type === \"message\" || step.type === \"system\") &&\n typeof step.id === \"string\"\n ) {\n messageIds.add(step.id);\n }\n\n if (\n step.type === \"reaction\" ||\n step.type === \"edit\" ||\n step.type === \"delete\"\n ) {\n const target = step.target;\n // Blank/`$prev` both mean \"the most-recent message\".\n if (!target || target === \"$prev\") {\n if (priorMessages === 0) {\n diagnostics.push({\n code: \"W_NO_PREV\",\n severity: \"warning\",\n message: \"Default target has no preceding message.\",\n location: `${loc}.target`,\n hint: \"Place this after a message, or set a target message id.\",\n });\n }\n } else if (!messageIds.has(target)) {\n diagnostics.push({\n code: \"W_TARGET\",\n severity: \"warning\",\n message: `Target \"${target}\" matches no preceding message id.`,\n location: `${loc}.target`,\n hint: 'Give the target message an `\"id\"`, or check the reference.',\n });\n }\n }\n\n if (step.type === \"message\" || step.type === \"system\") priorMessages++;\n });\n\n return diagnostics;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/meta.ts","../src/participants.ts","../src/pacing.ts","../src/content-nodes.ts","../src/content-registry.ts","../src/content-sugar.ts","../src/timeline.ts","../src/config.ts","../src/validate.ts"],"names":["z"],"mappings":";;;;;AAGO,IAAM,UAAA,GAAaA,MAAE,MAAA,CAAO;AAAA,EACjC,OAAOA,KAAA,CAAE,MAAA,EAAO,CAAE,GAAA,GAAM,QAAA,EAAS;AAAA,EACjC,QAAQA,KAAA,CAAE,MAAA,EAAO,CAAE,GAAA,GAAM,QAAA;AAC3B,CAAC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AAA,WACP,CAAA;AAAA,QACH;AAAA,MACF,CAAA,MAAA,IAAW,CAAC,UAAA,CAAW,GAAA,CAAI,MAAM,CAAA,EAAG;AAClC,QAAA,WAAA,CAAY,IAAA,CAAK;AAAA,UACf,IAAA,EAAM,UAAA;AAAA,UACN,QAAA,EAAU,SAAA;AAAA,UACV,OAAA,EAAS,WAAW,MAAM,CAAA,kCAAA,CAAA;AAAA,UAC1B,QAAA,EAAU,GAAG,GAAG,CAAA,OAAA,CAAA;AAAA,UAChB,IAAA,EAAM;AAAA,SACP,CAAA;AAAA,MACH;AAAA,IACF;AAEA,IAAA,IAAI,IAAA,CAAK,IAAA,KAAS,SAAA,IAAa,IAAA,CAAK,SAAS,QAAA,EAAU,aAAA,EAAA;AAAA,EACzD,CAAC,CAAA;AAED,EAAA,OAAO,WAAA;AACT","file":"index.cjs","sourcesContent":["import { z } from \"zod\";\n\n/** A pixel dimension pair (authoring reference; the exact frame for video). */\nexport const sizeSchema = z.object({\n width: z.number().int().positive(),\n height: z.number().int().positive(),\n});\nexport type Size = z.infer<typeof sizeSchema>;\n\n/**\n * How the rendered conversation fills its container. The widget is\n * **container-driven** in the first two modes — its size never grows\n * with content; messages clip when they overflow the bottom-anchored\n * thread.\n * - `reflow`: fills the container in both axes; bubbles re-wrap to the\n * container width.\n * - `scale`: renders at the exact authored canvas size and CSS-scales\n * to fit (preserves the canonical layout — letterboxes if the\n * container's aspect doesn't match the canvas).\n * - `fixed`: pins the widget to the authored canvas px; clips. The only\n * non-container-driven mode.\n */\nexport const fitModeSchema = z.enum([\"reflow\", \"scale\", \"fixed\"]);\nexport type FitMode = z.infer<typeof fitModeSchema>;\n\n/**\n * Reply-box (composer) visibility:\n * - `auto`: shown only while someone is typing/sending (default).\n * - `always`: keep the message input visible the whole time.\n * - `never`: never show it.\n */\nexport const composerModeSchema = z.enum([\"auto\", \"always\", \"never\"]);\nexport type ComposerMode = z.infer<typeof composerModeSchema>;\n\n/**\n * Color theme. `auto` inherits the host page's `prefers-color-scheme` (live\n * preview) and falls back to `light`; video export resolves `auto` to a\n * concrete mode and defaults to `light` when unspecified.\n */\nexport const themeModeSchema = z.enum([\"light\", \"dark\", \"auto\"]);\nexport type ThemeMode = z.infer<typeof themeModeSchema>;\n\n/**\n * Asset resolution strategy.\n * - `inline`: embed images as data URLs (self-contained config; default).\n * - `url`: reference hosted images (smaller config; user hosts their own).\n */\nexport const assetModeSchema = z.enum([\"inline\", \"url\"]);\nexport type AssetMode = z.infer<typeof assetModeSchema>;\n\n/** Reference to a skin plus its skin-specific options (validated by the skin). */\nexport const skinRefSchema = z.object({\n id: z.string().min(1),\n options: z.record(z.string(), z.unknown()).optional(),\n});\nexport type SkinRef = z.infer<typeof skinRefSchema>;\n\n/** Top-level rendering/authoring metadata. */\nexport const metaSchema = z.object({\n /** Authoring reference size; fixed frame for video. */\n canvas: sizeSchema,\n fps: z.number().int().positive().default(30),\n fit: fitModeSchema.default(\"reflow\"),\n theme: themeModeSchema.default(\"auto\"),\n skin: skinRefSchema,\n /** Seed for all deterministic jitter (no `Math.random`). */\n seed: z.number().int().default(42),\n /** Canvas background: `\"transparent\"` or any CSS color. */\n background: z.string().default(\"transparent\"),\n assets: assetModeSchema.default(\"inline\"),\n /** Reply-box visibility (see `composerModeSchema`). */\n composer: composerModeSchema.default(\"auto\"),\n /**\n * Auto-replay when the timeline reaches the end. Honored by the builder\n * preview and by `<Typecaast>` when the consumer doesn't pass an explicit\n * `loop` prop.\n */\n loop: z.boolean().default(false),\n});\n\n/** `meta` as it appears after parsing (defaults applied). */\nexport type Meta = z.infer<typeof metaSchema>;\n/** `meta` as authored (fields with defaults are optional). */\nexport type MetaInput = z.input<typeof metaSchema>;\n","import { z } from \"zod\";\n\n/** Whether a participant is a human or an app/bot (changes how skins render it). */\nexport const participantKindSchema = z.enum([\"person\", \"app\"]);\nexport type ParticipantKind = z.infer<typeof participantKindSchema>;\n\n/** A speaker in the conversation. */\nexport const participantSchema = z.object({\n /** Stable id referenced by timeline steps (`from`, `target`, …). */\n id: z.string().min(1),\n name: z.string().min(1),\n /** Avatar asset (data URL or referenced URL per `meta.assets`). */\n avatar: z.string().optional(),\n /** Accent color (CSS color) some skins use for the author. */\n color: z.string().optional(),\n /** The viewer — rendered as the \"self\" side and the composer's author. */\n isSelf: z.boolean().optional(),\n kind: participantKindSchema.default(\"person\"),\n});\nexport type Participant = z.infer<typeof participantSchema>;\nexport type ParticipantInput = z.input<typeof participantSchema>;\n\nexport const participantsSchema = z.array(participantSchema);\n","import { z } from \"zod\";\n\n/**\n * Global auto-pacing defaults. Every value is overridable per step in the\n * timeline; the engine computes delays/durations from these and bakes in\n * seeded, deterministic jitter (`humanize`).\n */\nexport const pacingSchema = z.object({\n /** Gap before an incoming message ≈ reading time of the prior message. */\n readingWpm: z.number().positive().default(240),\n /** Chars/sec for composer typing + sender typing duration. */\n typingCps: z.number().positive().default(14),\n /** ±fraction of seeded jitter so pacing doesn't feel robotic (0–1). */\n humanize: z.number().min(0).max(1).default(0.15),\n /** Delay before the first event. */\n startDelayMs: z.number().nonnegative().default(400),\n});\nexport type Pacing = z.infer<typeof pacingSchema>;\nexport type PacingInput = z.input<typeof pacingSchema>;\n","import { z } from \"zod\";\n\n/**\n * Inline marks inside a text node. `text` runs carry plain content; the others\n * are the recognized marks (`code`, `link`, `mention`, `emoji`, and the\n * emphasis marks `bold`/`italic`/`strike`). New marks can be added without a\n * schema-version bump (unknown content node types are handled leniently; see\n * the registry). Emphasis marks are flat (no nesting, e.g. bold *and* italic on\n * the same run) — a deliberate v1 simplification matching Slack's common usage.\n */\nexport const inlineTextSchema = z.object({\n type: z.literal(\"text\"),\n value: z.string(),\n});\nexport const inlineCodeSchema = z.object({\n type: z.literal(\"code\"),\n value: z.string(),\n});\nexport const inlineBoldSchema = z.object({\n type: z.literal(\"bold\"),\n value: z.string(),\n});\nexport const inlineItalicSchema = z.object({\n type: z.literal(\"italic\"),\n value: z.string(),\n});\nexport const inlineStrikeSchema = z.object({\n type: z.literal(\"strike\"),\n value: z.string(),\n});\nexport const inlineLinkSchema = z.object({\n type: z.literal(\"link\"),\n href: z.string(),\n label: z.string().optional(),\n});\nexport const inlineMentionSchema = z.object({\n type: z.literal(\"mention\"),\n /** Display label as authored, e.g. `\"@PostHog\"`. */\n label: z.string(),\n /** Resolved participant id, filled when the mention binds to a participant. */\n id: z.string().optional(),\n});\nexport const inlineEmojiSchema = z.object({\n type: z.literal(\"emoji\"),\n /** The rendered glyph, e.g. `\"🦔\"`. */\n value: z.string(),\n /** Optional shortcode, e.g. `\"hedgehog\"`. */\n shortcode: z.string().optional(),\n});\n\nexport const inlineNodeSchema = z.discriminatedUnion(\"type\", [\n inlineTextSchema,\n inlineCodeSchema,\n inlineBoldSchema,\n inlineItalicSchema,\n inlineStrikeSchema,\n inlineLinkSchema,\n inlineMentionSchema,\n inlineEmojiSchema,\n]);\nexport type InlineNode = z.infer<typeof inlineNodeSchema>;\n\n/** A block of inline content. */\nexport const textNodeSchema = z.object({\n type: z.literal(\"text\"),\n spans: z.array(inlineNodeSchema),\n});\nexport type TextNode = z.infer<typeof textNodeSchema>;\n\n/** An in-message image (same hosting model as avatars, per `meta.assets`). */\nexport const imageNodeSchema = z.object({\n type: z.literal(\"image\"),\n src: z.string(),\n alt: z.string().optional(),\n width: z.number().positive().optional(),\n height: z.number().positive().optional(),\n});\nexport type ImageNode = z.infer<typeof imageNodeSchema>;\n\n// --- Block Kit content nodes -------------------------------------------------\n// Slack apps compose rich messages from \"blocks\". These model the common set\n// (header / section / context / divider / actions / image / attachment) so an\n// app message is a normal message from an `app` participant whose `content`\n// carries blocks — the same primitives a real Slack app would emit. Skins that\n// don't understand a block skip it (lenient registry), so they're Slack-leaning\n// but safe everywhere.\n\n/**\n * An interactive button (in an `actions` block or as a `section` accessory).\n * With `href` the skin renders a link opening in a new tab; without one it's\n * visibly inert. `style` controls emphasis — omitted = default (outlined),\n * matching Slack's `primary`/`danger`/default button styles.\n */\nexport const buttonElementSchema = z.object({\n type: z.literal(\"button\"),\n label: z.string(),\n href: z.string().optional(),\n style: z.enum([\"primary\", \"danger\"]).optional(),\n});\nexport type ButtonElement = z.infer<typeof buttonElementSchema>;\n\n/** A small image element (a `context` element or a `section` accessory). */\nexport const imageElementSchema = z.object({\n type: z.literal(\"image\"),\n src: z.string(),\n alt: z.string().optional(),\n});\nexport type ImageElement = z.infer<typeof imageElementSchema>;\n\n/** A large bold heading (Block Kit `header` — plain text, no inline marks). */\nexport const headerNodeSchema = z.object({\n type: z.literal(\"header\"),\n text: z.string(),\n});\nexport type HeaderNode = z.infer<typeof headerNodeSchema>;\n\n/**\n * A section block: a paragraph of inline content, with an optional `accessory`\n * (a button or image to its right) and optional `fields` (a two-column grid).\n * Text may be authored as `spans` (resolved) or `text` (sugar, parsed to spans\n * by `toContentNodes`).\n */\nexport const sectionFieldSchema = z.object({\n spans: z.array(inlineNodeSchema).optional(),\n text: z.string().optional(),\n});\nexport const sectionNodeSchema = z.object({\n type: z.literal(\"section\"),\n spans: z.array(inlineNodeSchema).optional(),\n text: z.string().optional(),\n accessory: z\n .discriminatedUnion(\"type\", [buttonElementSchema, imageElementSchema])\n .optional(),\n fields: z.array(sectionFieldSchema).optional(),\n});\nexport type SectionNode = z.infer<typeof sectionNodeSchema>;\n\n/** A context block: a row of small, muted text/image elements. */\nexport const contextTextElementSchema = z.object({\n type: z.literal(\"text\"),\n spans: z.array(inlineNodeSchema).optional(),\n text: z.string().optional(),\n});\nexport const contextElementSchema = z.discriminatedUnion(\"type\", [\n contextTextElementSchema,\n imageElementSchema,\n]);\nexport type ContextElement = z.infer<typeof contextElementSchema>;\nexport const contextNodeSchema = z.object({\n type: z.literal(\"context\"),\n elements: z.array(contextElementSchema),\n});\nexport type ContextNode = z.infer<typeof contextNodeSchema>;\n\n/** A horizontal rule between blocks. */\nexport const dividerNodeSchema = z.object({\n type: z.literal(\"divider\"),\n});\nexport type DividerNode = z.infer<typeof dividerNodeSchema>;\n\n/** A row of interactive buttons. */\nexport const actionsNodeSchema = z.object({\n type: z.literal(\"actions\"),\n elements: z.array(buttonElementSchema),\n});\nexport type ActionsNode = z.infer<typeof actionsNodeSchema>;\n\n/**\n * A multi-line preformatted code block (Slack's fenced ``` block) — a monospaced\n * box that preserves whitespace and newlines verbatim (used for tables, logs,\n * snippets). Distinct from the inline `code` mark; `text` is **literal** and is\n * never parsed for inline marks. `lang` is an optional language hint (unused by\n * the current skins, reserved for future syntax highlighting).\n */\nexport const codeBlockNodeSchema = z.object({\n type: z.literal(\"codeblock\"),\n text: z.string(),\n lang: z.string().optional(),\n});\nexport type CodeBlockNode = z.infer<typeof codeBlockNodeSchema>;\n\n/**\n * A legacy-style attachment: nested blocks rendered behind a colored left bar.\n * `color` is any CSS color (defaults to a neutral bar). Recursive — its Zod\n * schema lives in `content-registry.ts` (where the node union is built).\n */\nexport interface AttachmentNode {\n type: \"attachment\";\n color?: string;\n content: ContentNode[];\n}\n\n/**\n * A content node whose `type` the runtime doesn't recognize. It validates\n * leniently (only `type` is required) and is skipped by skins that don't handle\n * it — so future node types (`linkPreview`, `videoEmbed`, …) slot in without\n * breaking older runtimes or bumping the schema version.\n */\nexport interface UnknownContentNode {\n type: string;\n [key: string]: unknown;\n}\n\n/** The body of a message: an ordered list of content nodes. */\nexport type ContentNode =\n | TextNode\n | ImageNode\n | HeaderNode\n | SectionNode\n | ContextNode\n | DividerNode\n | ActionsNode\n | CodeBlockNode\n | AttachmentNode\n | UnknownContentNode;\n","import { z } from \"zod\";\nimport {\n actionsNodeSchema,\n codeBlockNodeSchema,\n contextNodeSchema,\n dividerNodeSchema,\n headerNodeSchema,\n imageNodeSchema,\n sectionNodeSchema,\n textNodeSchema,\n type AttachmentNode,\n type ContentNode,\n} from \"./content-nodes.js\";\n\n/**\n * A legacy-style attachment node — nested blocks behind a colored left bar.\n * Recursive (its `content` is the full node array), so it's defined here where\n * `contentSchema` is in scope and wrapped in `z.lazy` to defer the reference.\n */\nexport const attachmentNodeSchema: z.ZodType<AttachmentNode> = z.lazy(() =>\n z.object({\n type: z.literal(\"attachment\"),\n color: z.string().optional(),\n content: contentSchema,\n }),\n);\n\n/**\n * The content-type registry. Each message body node has a `type` resolved\n * through here. Built-ins cover text/image plus the Block Kit blocks\n * (header/section/context/divider/actions/attachment); additional types can be\n * registered (with their own strict schema) without a schema-version bump.\n *\n * Nodes whose `type` is **not** registered validate leniently (only `type` is\n * required) and are skipped by skins that don't handle them. Nodes whose `type`\n * **is** registered must satisfy that type's schema — so a malformed `text`\n * node is an error rather than silently passing through the lenient path.\n */\nconst registry = new Map<string, z.ZodTypeAny>([\n [\"text\", textNodeSchema],\n [\"image\", imageNodeSchema],\n [\"header\", headerNodeSchema],\n [\"section\", sectionNodeSchema],\n [\"context\", contextNodeSchema],\n [\"divider\", dividerNodeSchema],\n [\"actions\", actionsNodeSchema],\n [\"codeblock\", codeBlockNodeSchema],\n [\"attachment\", attachmentNodeSchema],\n]);\n\n/** Register (or override) the strict schema for a content node type. */\nexport function registerContentNodeType(\n type: string,\n schema: z.ZodTypeAny,\n): void {\n registry.set(type, schema);\n}\n\n/** The content node types the runtime validates strictly. */\nexport function knownContentNodeTypes(): string[] {\n return [...registry.keys()];\n}\n\nexport function isKnownContentNodeType(type: string): boolean {\n return registry.has(type);\n}\n\n/** Accepts any object with a string `type` that isn't a registered type. */\nconst lenientUnknownNodeSchema = z\n .looseObject({ type: z.string() })\n .refine((node) => !registry.has(node.type), {\n message: \"malformed content node for a registered type\",\n });\n\n/**\n * Build a content-node schema from the current registry state. Call this after\n * registering a new type to pick it up; `contentNodeSchema` below is the\n * default built from the v1 registry (`text` + `image`).\n */\nexport function buildContentNodeSchema(): z.ZodType<ContentNode> {\n return z.union([\n ...registry.values(),\n lenientUnknownNodeSchema,\n ]) as unknown as z.ZodType<ContentNode>;\n}\n\n/** Default content-node schema (text + image + lenient unknown). */\nexport const contentNodeSchema = buildContentNodeSchema();\n\n/** A message body: an ordered array of content nodes. */\nexport const contentSchema = z.array(contentNodeSchema);\n","import type {\n AttachmentNode,\n ContentNode,\n ContextNode,\n ImageNode,\n InlineNode,\n SectionNode,\n TextNode,\n} from \"./content-nodes.js\";\n\n/**\n * Matches an inline mark, in priority order: a backtick code span, Slack mrkdwn\n * emphasis (`*bold*`, `_italic_`, `~strike~`), an http(s) link, a `<@id>`\n * mention (Slack's encoded form — resolved to a display name at compile), or a\n * bare `@name` mention. Everything else becomes plain text runs.\n *\n * Emphasis delimiters must hug their content (no leading/trailing space), and\n * `_italic_` requires non-alphanumeric boundaries so `snake_case` and URLs with\n * underscores are left alone.\n */\nconst INLINE_TOKEN =\n /`([^`]+)`|\\*(?!\\s)([^*\\n]+?)(?<!\\s)\\*|(?<![A-Za-z0-9])_(?!\\s)([^_\\n]+?)(?<!\\s)_(?![A-Za-z0-9])|~(?!\\s)([^~\\n]+?)(?<!\\s)~|(https?:\\/\\/[^\\s]+)|<@([A-Za-z0-9_.-]+)>|(@[A-Za-z0-9_][\\w.-]*)/g;\n\n/**\n * Parse a plain authoring string into inline nodes, extracting inline `code`,\n * `bold`/`italic`/`strike`, links, and mentions. Emoji are left inside text\n * runs (they render fine; a dedicated emoji mark can be authored explicitly).\n * A `<@id>` mention carries its `id` and a placeholder label; the engine\n * resolves the label to the participant's display name at compile time.\n */\nexport function parseInline(text: string): InlineNode[] {\n if (text.length === 0) return [];\n const spans: InlineNode[] = [];\n const re = new RegExp(INLINE_TOKEN.source, \"g\");\n let lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = re.exec(text)) !== null) {\n const matchText = match[0] ?? \"\";\n if (match.index > lastIndex) {\n spans.push({ type: \"text\", value: text.slice(lastIndex, match.index) });\n }\n if (match[1] !== undefined) {\n spans.push({ type: \"code\", value: match[1] });\n } else if (match[2] !== undefined) {\n spans.push({ type: \"bold\", value: match[2] });\n } else if (match[3] !== undefined) {\n spans.push({ type: \"italic\", value: match[3] });\n } else if (match[4] !== undefined) {\n spans.push({ type: \"strike\", value: match[4] });\n } else if (match[5] !== undefined) {\n spans.push({ type: \"link\", href: match[5] });\n } else if (match[6] !== undefined) {\n spans.push({ type: \"mention\", id: match[6], label: `@${match[6]}` });\n } else if (match[7] !== undefined) {\n spans.push({ type: \"mention\", label: match[7] });\n }\n lastIndex = match.index + matchText.length;\n }\n if (lastIndex < text.length) {\n spans.push({ type: \"text\", value: text.slice(lastIndex) });\n }\n return spans;\n}\n\n/** Convenience shape for authoring an in-message image. */\nexport interface ImageSugar {\n src: string;\n alt?: string;\n width?: number;\n height?: number;\n}\n\n/** `text` string → a single text content node. */\nexport function textToContentNode(text: string): TextNode {\n return { type: \"text\", spans: parseInline(text) };\n}\n\n/** `image` sugar → an image content node (drops undefined optionals). */\nexport function imageToContentNode(image: ImageSugar): ImageNode {\n const node: ImageNode = { type: \"image\", src: image.src };\n if (image.alt !== undefined) node.alt = image.alt;\n if (image.width !== undefined) node.width = image.width;\n if (image.height !== undefined) node.height = image.height;\n return node;\n}\n\n/** The sugar fields a message may carry instead of explicit `content`. */\nexport interface MessageBodySugar {\n /** Authored text (parsed into inline marks). */\n text?: string;\n /** In-message images, rendered after the text. */\n images?: ImageSugar[];\n /** Explicit content nodes; when present, wins over `text`/`images`. */\n content?: ContentNode[];\n}\n\n/**\n * Resolve a block's `text` sugar to `spans` (and recurse into attachments), so\n * skins only ever read resolved inline content. Non-text blocks pass through.\n */\nexport function normalizeContentNode(node: ContentNode): ContentNode {\n // Explicit casts: `ContentNode` includes the lenient `UnknownContentNode`\n // (index signature), so a plain `switch` widens the narrowed fields to\n // `unknown`. The runtime `type` check is authoritative.\n if (node.type === \"section\") {\n const s = node as SectionNode;\n return {\n type: \"section\",\n spans: s.spans ?? parseInline(s.text ?? \"\"),\n ...(s.accessory ? { accessory: s.accessory } : {}),\n ...(s.fields\n ? {\n fields: s.fields.map((f) => ({\n spans: f.spans ?? parseInline(f.text ?? \"\"),\n })),\n }\n : {}),\n };\n }\n if (node.type === \"context\") {\n const c = node as ContextNode;\n return {\n type: \"context\",\n elements: c.elements.map((el) =>\n el.type === \"text\"\n ? { type: \"text\", spans: el.spans ?? parseInline(el.text ?? \"\") }\n : el,\n ),\n };\n }\n if (node.type === \"attachment\") {\n const a = node as AttachmentNode;\n return {\n type: \"attachment\",\n ...(a.color ? { color: a.color } : {}),\n content: a.content.map(normalizeContentNode),\n };\n }\n return node;\n}\n\n/**\n * Resolve a message's body sugar to content nodes. Explicit `content` is\n * authoritative (block `text` sugar is normalized to spans); otherwise the text\n * node (if any) comes first, then images — matching the \"here's the toast:\n * [image]\" ordering in the spec example.\n */\nexport function toContentNodes(body: MessageBodySugar): ContentNode[] {\n if (body.content) return body.content.map(normalizeContentNode);\n const nodes: ContentNode[] = [];\n if (body.text !== undefined && body.text.length > 0) {\n nodes.push(textToContentNode(body.text));\n }\n if (body.images) {\n for (const image of body.images) nodes.push(imageToContentNode(image));\n }\n return nodes;\n}\n","import { z } from \"zod\";\nimport { contentSchema } from \"./content-registry.js\";\n\n/**\n * Per-step overrides shared by every step. The engine computes timing from the\n * pacing model; these win over the computed values. Use a dedicated `delay`\n * step type to insert explicit pauses on the timeline.\n */\nconst stepBaseShape = {\n /** Optional id so reactions/edits/deletes can target this step's message. */\n id: z.string().optional(),\n /** Reveal with no animation and no computed delay. */\n instant: z.boolean().optional(),\n};\n\n/** Authoring sugar for an in-message image (compiled to an image node). */\nexport const imageSugarSchema = z.object({\n src: z.string(),\n alt: z.string().optional(),\n width: z.number().positive().optional(),\n height: z.number().positive().optional(),\n});\n\n/** Message-body sugar fields; `content` (explicit nodes) wins when present. */\nconst bodyShape = {\n text: z.string().optional(),\n images: z.array(imageSugarSchema).optional(),\n content: contentSchema.optional(),\n};\n\n/** Optional typing indicator preceding a message. */\nconst messageTypingSchema = z.union([\n z.boolean(),\n z.object({ showTypingFor: z.number().nonnegative().optional() }),\n]);\n\n/** An incoming message, optionally preceded by a typing indicator. */\nexport const messageStepSchema = z.object({\n type: z.literal(\"message\"),\n from: z.string(),\n typing: messageTypingSchema.optional(),\n ...bodyShape,\n ...stepBaseShape,\n});\n\n/** A reaction landing on a target message (`$prev` or a message id). */\nexport const reactionStepSchema = z.object({\n type: z.literal(\"reaction\"),\n /** Message id to react to. Defaults to `$prev` (the most-recent message). */\n target: z.string().optional(),\n emoji: z.string(),\n /** Emoji shortcode without colons, e.g. `\"eyes\"` — shown in skin tooltips. */\n shortcode: z.string().optional(),\n from: z.string().optional(),\n /** Gap from when the target appears, before the reaction lands (ms). */\n delay: z.number().nonnegative().optional(),\n ...stepBaseShape,\n});\n\n/** A standalone typing indicator (no message necessarily follows). */\nexport const typingStepSchema = z.object({\n type: z.literal(\"typing\"),\n from: z.string(),\n showTypingFor: z.number().nonnegative().optional(),\n ...stepBaseShape,\n});\n\n/** The self participant typing into the composer, char by char. */\nexport const composerTypeStepSchema = z.object({\n type: z.literal(\"composerType\"),\n from: z.string(),\n text: z.string(),\n /** Override the computed typing duration (ms). */\n typingDuration: z.number().nonnegative().optional(),\n ...stepBaseShape,\n});\n\n/** Commit the composer's current text to the thread. */\nexport const sendStepSchema = z.object({\n type: z.literal(\"send\"),\n from: z.string().optional(),\n ...stepBaseShape,\n});\n\n/** Edit a previously sent message's body. */\nexport const editStepSchema = z.object({\n type: z.literal(\"edit\"),\n /** Message id to edit. Defaults to `$prev` (the most-recent message). */\n target: z.string().optional(),\n ...bodyShape,\n ...stepBaseShape,\n});\n\n/** Delete a previously sent message. */\nexport const deleteStepSchema = z.object({\n type: z.literal(\"delete\"),\n /** Message id to delete. Defaults to `$prev` (the most-recent message). */\n target: z.string().optional(),\n ...stepBaseShape,\n});\n\n/** A read receipt (optionally by a participant, optionally up to a message). */\nexport const readReceiptStepSchema = z.object({\n type: z.literal(\"readReceipt\"),\n by: z.string().optional(),\n target: z.string().optional(),\n ...stepBaseShape,\n});\n\n/**\n * A system / notice line — not a chat message. Skins render it distinctly: a\n * centered muted notice (iMessage/WhatsApp/Slack \"X joined #channel\"), an agent\n * tool-output line (Cursor/Claude Code `⎿ …`), a CI notice (Discord), etc. App\n * \"cards\" are NOT system steps — model those as a `message` from an `app`\n * participant carrying Block Kit content (header/section/context/actions/…).\n */\nexport const systemStepSchema = z.object({\n type: z.literal(\"system\"),\n from: z.string().optional(),\n ...bodyShape,\n ...stepBaseShape,\n});\n\n/** An explicit pause in the timeline (formerly `beat`). */\nexport const delayStepSchema = z.object({\n type: z.literal(\"delay\"),\n duration: z.number().nonnegative(),\n ...stepBaseShape,\n});\n\nexport const timelineStepSchema = z.discriminatedUnion(\"type\", [\n messageStepSchema,\n reactionStepSchema,\n typingStepSchema,\n composerTypeStepSchema,\n sendStepSchema,\n editStepSchema,\n deleteStepSchema,\n readReceiptStepSchema,\n systemStepSchema,\n delayStepSchema,\n]);\nexport type TimelineStep = z.infer<typeof timelineStepSchema>;\nexport type TimelineStepInput = z.input<typeof timelineStepSchema>;\n\nexport const timelineSchema = z.array(timelineStepSchema);\n\n/** The discriminant values of every timeline step. */\nexport const STEP_TYPES = [\n \"message\",\n \"reaction\",\n \"typing\",\n \"composerType\",\n \"send\",\n \"edit\",\n \"delete\",\n \"readReceipt\",\n \"system\",\n \"delay\",\n] as const;\nexport type StepType = (typeof STEP_TYPES)[number];\n","import { z } from \"zod\";\nimport { metaSchema } from \"./meta.js\";\nimport { participantsSchema } from \"./participants.js\";\nimport { pacingSchema } from \"./pacing.js\";\nimport { timelineSchema } from \"./timeline.js\";\n\n/**\n * The config schema version. Distinct from the `@typecaast/schema` package\n * version (related but versioned independently — see PLAN §22). A config newer\n * than the installed runtime fails parsing with a clear error.\n */\nexport const CONFIG_VERSION = 1;\n\n/** The complete Typecaast config: the single source of truth for a simulation. */\nexport const configSchema = z.object({\n version: z.literal(CONFIG_VERSION),\n meta: metaSchema,\n participants: participantsSchema,\n /** Optional; omitted pacing resolves to the full default model. */\n pacing: pacingSchema.default(() => pacingSchema.parse({})),\n timeline: timelineSchema,\n});\n\n/** A parsed config (defaults applied). */\nexport type Config = z.infer<typeof configSchema>;\n/** A config as authored (fields with defaults are optional). */\nexport type ConfigInput = z.input<typeof configSchema>;\n\n/**\n * Generate the JSON Schema for a Typecaast config (for editor autocomplete and\n * `$schema` references). Lazy so importing the package never eagerly runs the\n * conversion. Refinements (e.g. the lenient content-node guard) are not\n * representable in JSON Schema and are dropped.\n */\nexport function configJsonSchema(): Record<string, unknown> {\n return z.toJSONSchema(configSchema, {\n unrepresentable: \"any\",\n target: \"draft-7\",\n }) as Record<string, unknown>;\n}\n","import { CONFIG_VERSION, configSchema } from \"./config.js\";\n\n/** Diagnostic severity tiers (PLAN §23). */\nexport type Severity = \"error\" | \"warning\" | \"info\";\n\n/**\n * A single validation finding. Every diagnostic carries a stable `code`, the\n * offending `location` (step/message/path), and a `hint` for remediation.\n */\nexport interface Diagnostic {\n code: string;\n severity: Severity;\n message: string;\n /** Dotted/indexed path, e.g. `timeline[3].from` or `meta.canvas.width`. */\n location?: string;\n hint?: string;\n}\n\nfunction formatPath(path: ReadonlyArray<PropertyKey>): string {\n let out = \"\";\n for (const key of path) {\n if (typeof key === \"number\") out += `[${key}]`;\n else if (out === \"\") out += String(key);\n else out += `.${String(key)}`;\n }\n return out;\n}\n\n/** Read an optional `from`/`by`/`target` field off any step shape. */\nfunction field(step: unknown, key: string): string | undefined {\n const value = (step as Record<string, unknown>)[key];\n return typeof value === \"string\" ? value : undefined;\n}\n\n/**\n * Validate a parsed config value (already JSON-decoded). Returns all\n * diagnostics — schema errors, then semantic checks (reference integrity,\n * target resolution). Reusable by the CLI and the builder's lint panel.\n *\n * A version newer than the runtime short-circuits with a single hard error.\n */\nexport function validateConfig(raw: unknown): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n if (raw && typeof raw === \"object\" && \"version\" in raw) {\n const version = (raw as { version: unknown }).version;\n if (typeof version === \"number\" && version > CONFIG_VERSION) {\n return [\n {\n code: \"E_VERSION\",\n severity: \"error\",\n message: `Config version ${version} is newer than this runtime supports (max ${CONFIG_VERSION}).`,\n location: \"version\",\n hint: \"Upgrade Typecaast (e.g. `npm i @typecaast/cli@latest`).\",\n },\n ];\n }\n }\n\n const result = configSchema.safeParse(raw);\n if (!result.success) {\n for (const issue of result.error.issues) {\n diagnostics.push({\n code: \"E_SCHEMA\",\n severity: \"error\",\n message: issue.message,\n location: formatPath(issue.path) || undefined,\n });\n }\n return diagnostics;\n }\n\n const config = result.data;\n\n // Duplicate participant ids.\n const ids = config.participants.map((p) => p.id);\n const idSet = new Set(ids);\n for (const dup of new Set(ids.filter((id, i) => ids.indexOf(id) !== i))) {\n diagnostics.push({\n code: \"E_DUP_PARTICIPANT\",\n severity: \"error\",\n message: `Duplicate participant id \"${dup}\".`,\n location: \"participants\",\n hint: \"Participant ids must be unique.\",\n });\n }\n\n const hasSelf = config.participants.some((p) => p.isSelf);\n let warnedNoSelf = false;\n const messageIds = new Set<string>();\n let priorMessages = 0;\n\n config.timeline.forEach((step, i) => {\n const loc = `timeline[${i}]`;\n\n const from = field(step, \"from\");\n if (from !== undefined && !idSet.has(from)) {\n diagnostics.push({\n code: \"E_REF_PARTICIPANT\",\n severity: \"error\",\n message: `Step references unknown participant \"${from}\".`,\n location: `${loc}.from`,\n hint: `Add a participant with id \"${from}\" or fix the reference.`,\n });\n }\n\n if (step.type === \"readReceipt\") {\n const by = field(step, \"by\");\n if (by !== undefined && !idSet.has(by)) {\n diagnostics.push({\n code: \"E_REF_PARTICIPANT\",\n severity: \"error\",\n message: `Read receipt references unknown participant \"${by}\".`,\n location: `${loc}.by`,\n hint: `Add a participant with id \"${by}\" or fix the reference.`,\n });\n }\n }\n\n if (\n (step.type === \"composerType\" || step.type === \"send\") &&\n !hasSelf &&\n !warnedNoSelf\n ) {\n warnedNoSelf = true;\n diagnostics.push({\n code: \"W_NO_SELF\",\n severity: \"warning\",\n message: \"The composer is used but no participant is marked as self.\",\n location: loc,\n hint: 'Mark a participant with `\"isSelf\": true`.',\n });\n }\n\n if (\n (step.type === \"message\" || step.type === \"system\") &&\n typeof step.id === \"string\"\n ) {\n messageIds.add(step.id);\n }\n\n if (\n step.type === \"reaction\" ||\n step.type === \"edit\" ||\n step.type === \"delete\"\n ) {\n const target = step.target;\n // Blank/`$prev` both mean \"the most-recent message\".\n if (!target || target === \"$prev\") {\n if (priorMessages === 0) {\n diagnostics.push({\n code: \"W_NO_PREV\",\n severity: \"warning\",\n message: \"Default target has no preceding message.\",\n location: `${loc}.target`,\n hint: \"Place this after a message, or set a target message id.\",\n });\n }\n } else if (!messageIds.has(target)) {\n diagnostics.push({\n code: \"W_TARGET\",\n severity: \"warning\",\n message: `Target \"${target}\" matches no preceding message id.`,\n location: `${loc}.target`,\n hint: 'Give the target message an `\"id\"`, or check the reference.',\n });\n }\n }\n\n if (step.type === \"message\" || step.type === \"system\") priorMessages++;\n });\n\n return diagnostics;\n}\n"]}
|