@edugate/ai-agent 0.1.1 → 0.2.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.d.mts CHANGED
@@ -35,6 +35,599 @@ declare function applyItemPatch(items: unknown, op: "insertItem" | "updateItem"
35
35
  at?: number;
36
36
  }): any[];
37
37
 
38
+ declare const CanvasOpSchema: z.ZodDiscriminatedUnion<"action", [z.ZodObject<{
39
+ action: z.ZodLiteral<"createScene">;
40
+ data: z.ZodObject<{
41
+ scene: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
42
+ newIndex: z.ZodOptional<z.ZodNumber>;
43
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
44
+ scene: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
45
+ newIndex: z.ZodOptional<z.ZodNumber>;
46
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
47
+ scene: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
48
+ newIndex: z.ZodOptional<z.ZodNumber>;
49
+ }, z.ZodTypeAny, "passthrough">>;
50
+ }, "strip", z.ZodTypeAny, {
51
+ action: "createScene";
52
+ data: {
53
+ newIndex?: number | undefined;
54
+ scene?: Record<string, unknown> | undefined;
55
+ } & {
56
+ [k: string]: unknown;
57
+ };
58
+ }, {
59
+ action: "createScene";
60
+ data: {
61
+ newIndex?: number | undefined;
62
+ scene?: Record<string, unknown> | undefined;
63
+ } & {
64
+ [k: string]: unknown;
65
+ };
66
+ }>, z.ZodObject<{
67
+ action: z.ZodLiteral<"deleteScene">;
68
+ data: z.ZodObject<{
69
+ sceneId: z.ZodString;
70
+ }, "strip", z.ZodTypeAny, {
71
+ sceneId: string;
72
+ }, {
73
+ sceneId: string;
74
+ }>;
75
+ }, "strip", z.ZodTypeAny, {
76
+ action: "deleteScene";
77
+ data: {
78
+ sceneId: string;
79
+ };
80
+ }, {
81
+ action: "deleteScene";
82
+ data: {
83
+ sceneId: string;
84
+ };
85
+ }>, z.ZodObject<{
86
+ action: z.ZodLiteral<"addBlock">;
87
+ data: z.ZodObject<{
88
+ sceneId: z.ZodString;
89
+ block: z.ZodRecord<z.ZodString, z.ZodUnknown>;
90
+ }, "strip", z.ZodTypeAny, {
91
+ sceneId: string;
92
+ block: Record<string, unknown>;
93
+ }, {
94
+ sceneId: string;
95
+ block: Record<string, unknown>;
96
+ }>;
97
+ }, "strip", z.ZodTypeAny, {
98
+ action: "addBlock";
99
+ data: {
100
+ sceneId: string;
101
+ block: Record<string, unknown>;
102
+ };
103
+ }, {
104
+ action: "addBlock";
105
+ data: {
106
+ sceneId: string;
107
+ block: Record<string, unknown>;
108
+ };
109
+ }>, z.ZodObject<{
110
+ action: z.ZodLiteral<"updateScene">;
111
+ data: z.ZodObject<{
112
+ sceneId: z.ZodString;
113
+ updates: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
114
+ newIndex: z.ZodOptional<z.ZodNumber>;
115
+ }, "strip", z.ZodTypeAny, {
116
+ sceneId: string;
117
+ updates?: Record<string, unknown> | undefined;
118
+ newIndex?: number | undefined;
119
+ }, {
120
+ sceneId: string;
121
+ updates?: Record<string, unknown> | undefined;
122
+ newIndex?: number | undefined;
123
+ }>;
124
+ }, "strip", z.ZodTypeAny, {
125
+ action: "updateScene";
126
+ data: {
127
+ sceneId: string;
128
+ updates?: Record<string, unknown> | undefined;
129
+ newIndex?: number | undefined;
130
+ };
131
+ }, {
132
+ action: "updateScene";
133
+ data: {
134
+ sceneId: string;
135
+ updates?: Record<string, unknown> | undefined;
136
+ newIndex?: number | undefined;
137
+ };
138
+ }>, z.ZodObject<{
139
+ action: z.ZodLiteral<"deleteBlock">;
140
+ data: z.ZodObject<{
141
+ sceneId: z.ZodString;
142
+ blockId: z.ZodString;
143
+ }, "strip", z.ZodTypeAny, {
144
+ sceneId: string;
145
+ blockId: string;
146
+ }, {
147
+ sceneId: string;
148
+ blockId: string;
149
+ }>;
150
+ }, "strip", z.ZodTypeAny, {
151
+ action: "deleteBlock";
152
+ data: {
153
+ sceneId: string;
154
+ blockId: string;
155
+ };
156
+ }, {
157
+ action: "deleteBlock";
158
+ data: {
159
+ sceneId: string;
160
+ blockId: string;
161
+ };
162
+ }>, z.ZodObject<{
163
+ action: z.ZodLiteral<"updateBlock">;
164
+ data: z.ZodObject<{
165
+ sceneId: z.ZodString;
166
+ blockId: z.ZodString;
167
+ updates: z.ZodRecord<z.ZodString, z.ZodUnknown>;
168
+ }, "strip", z.ZodTypeAny, {
169
+ sceneId: string;
170
+ blockId: string;
171
+ updates: Record<string, unknown>;
172
+ }, {
173
+ sceneId: string;
174
+ blockId: string;
175
+ updates: Record<string, unknown>;
176
+ }>;
177
+ }, "strip", z.ZodTypeAny, {
178
+ action: "updateBlock";
179
+ data: {
180
+ sceneId: string;
181
+ blockId: string;
182
+ updates: Record<string, unknown>;
183
+ };
184
+ }, {
185
+ action: "updateBlock";
186
+ data: {
187
+ sceneId: string;
188
+ blockId: string;
189
+ updates: Record<string, unknown>;
190
+ };
191
+ }>, z.ZodObject<{
192
+ action: z.ZodLiteral<"duplicateBlock">;
193
+ data: z.ZodObject<{
194
+ sceneId: z.ZodString;
195
+ blockId: z.ZodString;
196
+ }, "strip", z.ZodTypeAny, {
197
+ sceneId: string;
198
+ blockId: string;
199
+ }, {
200
+ sceneId: string;
201
+ blockId: string;
202
+ }>;
203
+ }, "strip", z.ZodTypeAny, {
204
+ action: "duplicateBlock";
205
+ data: {
206
+ sceneId: string;
207
+ blockId: string;
208
+ };
209
+ }, {
210
+ action: "duplicateBlock";
211
+ data: {
212
+ sceneId: string;
213
+ blockId: string;
214
+ };
215
+ }>, z.ZodObject<{
216
+ action: z.ZodLiteral<"groupBlocks">;
217
+ data: z.ZodObject<{
218
+ blockIds: z.ZodArray<z.ZodString, "many">;
219
+ }, "strip", z.ZodTypeAny, {
220
+ blockIds: string[];
221
+ }, {
222
+ blockIds: string[];
223
+ }>;
224
+ }, "strip", z.ZodTypeAny, {
225
+ action: "groupBlocks";
226
+ data: {
227
+ blockIds: string[];
228
+ };
229
+ }, {
230
+ action: "groupBlocks";
231
+ data: {
232
+ blockIds: string[];
233
+ };
234
+ }>, z.ZodObject<{
235
+ action: z.ZodLiteral<"updateBlockTheme">;
236
+ data: z.ZodObject<{
237
+ sceneId: z.ZodString;
238
+ blockId: z.ZodString;
239
+ theme: z.ZodRecord<z.ZodString, z.ZodUnknown>;
240
+ }, "strip", z.ZodTypeAny, {
241
+ sceneId: string;
242
+ blockId: string;
243
+ theme: Record<string, unknown>;
244
+ }, {
245
+ sceneId: string;
246
+ blockId: string;
247
+ theme: Record<string, unknown>;
248
+ }>;
249
+ }, "strip", z.ZodTypeAny, {
250
+ action: "updateBlockTheme";
251
+ data: {
252
+ sceneId: string;
253
+ blockId: string;
254
+ theme: Record<string, unknown>;
255
+ };
256
+ }, {
257
+ action: "updateBlockTheme";
258
+ data: {
259
+ sceneId: string;
260
+ blockId: string;
261
+ theme: Record<string, unknown>;
262
+ };
263
+ }>, z.ZodObject<{
264
+ action: z.ZodLiteral<"updateBlockElementStyle">;
265
+ data: z.ZodObject<{
266
+ sceneId: z.ZodString;
267
+ blockId: z.ZodString;
268
+ elementId: z.ZodString;
269
+ customStyle: z.ZodRecord<z.ZodString, z.ZodUnknown>;
270
+ }, "strip", z.ZodTypeAny, {
271
+ sceneId: string;
272
+ blockId: string;
273
+ elementId: string;
274
+ customStyle: Record<string, unknown>;
275
+ }, {
276
+ sceneId: string;
277
+ blockId: string;
278
+ elementId: string;
279
+ customStyle: Record<string, unknown>;
280
+ }>;
281
+ }, "strip", z.ZodTypeAny, {
282
+ action: "updateBlockElementStyle";
283
+ data: {
284
+ sceneId: string;
285
+ blockId: string;
286
+ elementId: string;
287
+ customStyle: Record<string, unknown>;
288
+ };
289
+ }, {
290
+ action: "updateBlockElementStyle";
291
+ data: {
292
+ sceneId: string;
293
+ blockId: string;
294
+ elementId: string;
295
+ customStyle: Record<string, unknown>;
296
+ };
297
+ }>, z.ZodObject<{
298
+ action: z.ZodLiteral<"addAction">;
299
+ data: z.ZodObject<{
300
+ sceneId: z.ZodString;
301
+ blockId: z.ZodString;
302
+ action: z.ZodRecord<z.ZodString, z.ZodUnknown>;
303
+ }, "strip", z.ZodTypeAny, {
304
+ sceneId: string;
305
+ blockId: string;
306
+ action: Record<string, unknown>;
307
+ }, {
308
+ sceneId: string;
309
+ blockId: string;
310
+ action: Record<string, unknown>;
311
+ }>;
312
+ }, "strip", z.ZodTypeAny, {
313
+ action: "addAction";
314
+ data: {
315
+ sceneId: string;
316
+ blockId: string;
317
+ action: Record<string, unknown>;
318
+ };
319
+ }, {
320
+ action: "addAction";
321
+ data: {
322
+ sceneId: string;
323
+ blockId: string;
324
+ action: Record<string, unknown>;
325
+ };
326
+ }>, z.ZodObject<{
327
+ action: z.ZodLiteral<"removeAction">;
328
+ data: z.ZodObject<{
329
+ sceneId: z.ZodString;
330
+ blockId: z.ZodString;
331
+ actionId: z.ZodString;
332
+ }, "strip", z.ZodTypeAny, {
333
+ sceneId: string;
334
+ blockId: string;
335
+ actionId: string;
336
+ }, {
337
+ sceneId: string;
338
+ blockId: string;
339
+ actionId: string;
340
+ }>;
341
+ }, "strip", z.ZodTypeAny, {
342
+ action: "removeAction";
343
+ data: {
344
+ sceneId: string;
345
+ blockId: string;
346
+ actionId: string;
347
+ };
348
+ }, {
349
+ action: "removeAction";
350
+ data: {
351
+ sceneId: string;
352
+ blockId: string;
353
+ actionId: string;
354
+ };
355
+ }>, z.ZodObject<{
356
+ action: z.ZodLiteral<"manageVariables">;
357
+ data: z.ZodObject<{
358
+ operation: z.ZodString;
359
+ name: z.ZodString;
360
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
361
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
362
+ operation: z.ZodString;
363
+ name: z.ZodString;
364
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
365
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
366
+ operation: z.ZodString;
367
+ name: z.ZodString;
368
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
369
+ }, z.ZodTypeAny, "passthrough">>;
370
+ }, "strip", z.ZodTypeAny, {
371
+ action: "manageVariables";
372
+ data: {
373
+ operation: string;
374
+ name: string;
375
+ defaultValue?: unknown;
376
+ } & {
377
+ [k: string]: unknown;
378
+ };
379
+ }, {
380
+ action: "manageVariables";
381
+ data: {
382
+ operation: string;
383
+ name: string;
384
+ defaultValue?: unknown;
385
+ } & {
386
+ [k: string]: unknown;
387
+ };
388
+ }>, z.ZodObject<{
389
+ action: z.ZodLiteral<"configureTimer">;
390
+ data: z.ZodObject<{
391
+ scope: z.ZodOptional<z.ZodString>;
392
+ sceneId: z.ZodOptional<z.ZodString>;
393
+ blockId: z.ZodOptional<z.ZodString>;
394
+ hasTimer: z.ZodOptional<z.ZodBoolean>;
395
+ timer: z.ZodOptional<z.ZodUnknown>;
396
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
397
+ scope: z.ZodOptional<z.ZodString>;
398
+ sceneId: z.ZodOptional<z.ZodString>;
399
+ blockId: z.ZodOptional<z.ZodString>;
400
+ hasTimer: z.ZodOptional<z.ZodBoolean>;
401
+ timer: z.ZodOptional<z.ZodUnknown>;
402
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
403
+ scope: z.ZodOptional<z.ZodString>;
404
+ sceneId: z.ZodOptional<z.ZodString>;
405
+ blockId: z.ZodOptional<z.ZodString>;
406
+ hasTimer: z.ZodOptional<z.ZodBoolean>;
407
+ timer: z.ZodOptional<z.ZodUnknown>;
408
+ }, z.ZodTypeAny, "passthrough">>;
409
+ }, "strip", z.ZodTypeAny, {
410
+ action: "configureTimer";
411
+ data: {
412
+ sceneId?: string | undefined;
413
+ blockId?: string | undefined;
414
+ scope?: string | undefined;
415
+ hasTimer?: boolean | undefined;
416
+ timer?: unknown;
417
+ } & {
418
+ [k: string]: unknown;
419
+ };
420
+ }, {
421
+ action: "configureTimer";
422
+ data: {
423
+ sceneId?: string | undefined;
424
+ blockId?: string | undefined;
425
+ scope?: string | undefined;
426
+ hasTimer?: boolean | undefined;
427
+ timer?: unknown;
428
+ } & {
429
+ [k: string]: unknown;
430
+ };
431
+ }>, z.ZodObject<{
432
+ action: z.ZodLiteral<"reorderScenes">;
433
+ data: z.ZodObject<{
434
+ sceneId: z.ZodString;
435
+ newIndex: z.ZodNumber;
436
+ }, "strip", z.ZodTypeAny, {
437
+ sceneId: string;
438
+ newIndex: number;
439
+ }, {
440
+ sceneId: string;
441
+ newIndex: number;
442
+ }>;
443
+ }, "strip", z.ZodTypeAny, {
444
+ action: "reorderScenes";
445
+ data: {
446
+ sceneId: string;
447
+ newIndex: number;
448
+ };
449
+ }, {
450
+ action: "reorderScenes";
451
+ data: {
452
+ sceneId: string;
453
+ newIndex: number;
454
+ };
455
+ }>, z.ZodObject<{
456
+ action: z.ZodLiteral<"insertItem">;
457
+ data: z.ZodObject<{
458
+ sceneId: z.ZodOptional<z.ZodString>;
459
+ blockId: z.ZodString;
460
+ collection: z.ZodString;
461
+ item: z.ZodUnknown;
462
+ at: z.ZodOptional<z.ZodNumber>;
463
+ }, "strip", z.ZodTypeAny, {
464
+ blockId: string;
465
+ collection: string;
466
+ sceneId?: string | undefined;
467
+ item?: unknown;
468
+ at?: number | undefined;
469
+ }, {
470
+ blockId: string;
471
+ collection: string;
472
+ sceneId?: string | undefined;
473
+ item?: unknown;
474
+ at?: number | undefined;
475
+ }>;
476
+ }, "strip", z.ZodTypeAny, {
477
+ action: "insertItem";
478
+ data: {
479
+ blockId: string;
480
+ collection: string;
481
+ sceneId?: string | undefined;
482
+ item?: unknown;
483
+ at?: number | undefined;
484
+ };
485
+ }, {
486
+ action: "insertItem";
487
+ data: {
488
+ blockId: string;
489
+ collection: string;
490
+ sceneId?: string | undefined;
491
+ item?: unknown;
492
+ at?: number | undefined;
493
+ };
494
+ }>, z.ZodObject<{
495
+ action: z.ZodLiteral<"updateItem">;
496
+ data: z.ZodObject<{
497
+ sceneId: z.ZodOptional<z.ZodString>;
498
+ blockId: z.ZodString;
499
+ collection: z.ZodString;
500
+ itemId: z.ZodString;
501
+ item: z.ZodUnknown;
502
+ }, "strip", z.ZodTypeAny, {
503
+ blockId: string;
504
+ collection: string;
505
+ itemId: string;
506
+ sceneId?: string | undefined;
507
+ item?: unknown;
508
+ }, {
509
+ blockId: string;
510
+ collection: string;
511
+ itemId: string;
512
+ sceneId?: string | undefined;
513
+ item?: unknown;
514
+ }>;
515
+ }, "strip", z.ZodTypeAny, {
516
+ action: "updateItem";
517
+ data: {
518
+ blockId: string;
519
+ collection: string;
520
+ itemId: string;
521
+ sceneId?: string | undefined;
522
+ item?: unknown;
523
+ };
524
+ }, {
525
+ action: "updateItem";
526
+ data: {
527
+ blockId: string;
528
+ collection: string;
529
+ itemId: string;
530
+ sceneId?: string | undefined;
531
+ item?: unknown;
532
+ };
533
+ }>, z.ZodObject<{
534
+ action: z.ZodLiteral<"deleteItem">;
535
+ data: z.ZodObject<{
536
+ sceneId: z.ZodOptional<z.ZodString>;
537
+ blockId: z.ZodString;
538
+ collection: z.ZodString;
539
+ itemId: z.ZodString;
540
+ }, "strip", z.ZodTypeAny, {
541
+ blockId: string;
542
+ collection: string;
543
+ itemId: string;
544
+ sceneId?: string | undefined;
545
+ }, {
546
+ blockId: string;
547
+ collection: string;
548
+ itemId: string;
549
+ sceneId?: string | undefined;
550
+ }>;
551
+ }, "strip", z.ZodTypeAny, {
552
+ action: "deleteItem";
553
+ data: {
554
+ blockId: string;
555
+ collection: string;
556
+ itemId: string;
557
+ sceneId?: string | undefined;
558
+ };
559
+ }, {
560
+ action: "deleteItem";
561
+ data: {
562
+ blockId: string;
563
+ collection: string;
564
+ itemId: string;
565
+ sceneId?: string | undefined;
566
+ };
567
+ }>, z.ZodObject<{
568
+ action: z.ZodLiteral<"replaceActivity">;
569
+ data: z.ZodObject<{
570
+ activity: z.ZodUnknown;
571
+ }, "strip", z.ZodTypeAny, {
572
+ activity?: unknown;
573
+ }, {
574
+ activity?: unknown;
575
+ }>;
576
+ }, "strip", z.ZodTypeAny, {
577
+ action: "replaceActivity";
578
+ data: {
579
+ activity?: unknown;
580
+ };
581
+ }, {
582
+ action: "replaceActivity";
583
+ data: {
584
+ activity?: unknown;
585
+ };
586
+ }>]>;
587
+ type CanvasOp = z.infer<typeof CanvasOpSchema>;
588
+
589
+ /**
590
+ * Semantic (content-aware) canvas-op validation, layered on top of
591
+ * `CanvasOpSchema`'s structural check. Deliberately does NOT import
592
+ * `@edugate/types` or any concrete block registry — it receives a narrow
593
+ * VIEW of the registry instead (dependency inversion), so this package stays
594
+ * decoupled from the builder's block catalog and callers (the Dify proxy
595
+ * route, the client) can wire in whatever registry instance they hold without
596
+ * this package needing to know it exists. Only `zod` is a hard dependency.
597
+ *
598
+ * Two-tier validation:
599
+ * 1. Structural (`CanvasOpSchema.safeParse`) — is this a well-formed op for
600
+ * its action? Runs unconditionally.
601
+ * 2. Semantic — does `block.type` / `collection` / item payload actually
602
+ * match what the registry knows? Only runs when the caller supplies
603
+ * enough context (a registry view, and for item ops a
604
+ * `resolveBlockType`). Missing context means "skip", never "fail" — this
605
+ * validator must never produce a false positive by rejecting an op it
606
+ * lacks the information to judge.
607
+ */
608
+ interface BlockRegistryView {
609
+ /** Content schema for a block type, or undefined if the type is unknown. */
610
+ getContentSchema(type: string): z.ZodTypeAny | undefined;
611
+ /** Item schema for one collection (e.g. quiz "questions"), or undefined if
612
+ * the block type or the collection name is unknown. */
613
+ getCollectionSchema(type: string, collection: string): z.ZodTypeAny | undefined;
614
+ }
615
+ type CanvasOpValidationCode = "SHAPE_INVALID" | "UNKNOWN_BLOCK_TYPE" | "CONTENT_INVALID" | "UNKNOWN_COLLECTION" | "ITEM_INVALID";
616
+ interface CanvasOpValidationResult {
617
+ ok: boolean;
618
+ code?: CanvasOpValidationCode;
619
+ errors?: string[];
620
+ }
621
+ /**
622
+ * Builds a validator function bound to a registry view and (optionally) a
623
+ * blockId -> block-type resolver. The resolver is optional because callers
624
+ * validating an op BEFORE the block exists on the canvas (or without access
625
+ * to canvas state) have no way to resolve `blockId` to a type — in that case
626
+ * item-op and updateBlock semantic checks are skipped (best-effort), and only
627
+ * the structural check + addBlock's self-contained type/content check apply.
628
+ */
629
+ declare function createCanvasOpValidator(registry: BlockRegistryView, resolveBlockType?: (blockId: string) => string | undefined): (op: unknown) => CanvasOpValidationResult;
630
+
38
631
  /**
39
632
  * Optimistic-concurrency conflict detection for canvas ops (Phase 7).
40
633
  *
@@ -92,59 +685,6 @@ declare function opConflictStamp(action: string, data: any, baseScenes: any[]):
92
685
  baseSignature: string | null;
93
686
  };
94
687
 
95
- /**
96
- * @-mention ("tag") resolution — turn the builder's `@[Name|UUID]` tags into an
97
- * AUTHORITATIVE target the agents can actually consume.
98
- *
99
- * Root cause (see docs/ai-tag-context-and-quiz-styling-rootcause.md): the builder
100
- * inserts a literal `@[Name|UUID]` into the message text, but NOTHING resolved it —
101
- * the only structured target the agents received was `selectedBlockId` (the CLICKED
102
- * block). Tagging ≠ selecting, so a tagged-but-not-selected block (e.g. a Quiz the
103
- * user wants to style) was effectively ignored and mis-targeted.
104
- *
105
- * This module is PURE (no I/O): given the message text and the activity, it strips
106
- * the tag noise to readable names and returns the entities that actually exist, so
107
- * the route can promote them to the request target and surface them in [CONTEXT].
108
- */
109
- /** A `@[Name|UUID]` reference resolved against the activity. */
110
- interface ResolvedEntity {
111
- id: string;
112
- name: string;
113
- kind: "scene" | "block";
114
- /** Present for blocks. */
115
- blockType?: string;
116
- /** The scene that contains the block (present for blocks). */
117
- sceneId?: string;
118
- }
119
- interface MentionResolution {
120
- /** The text with every `@[Name|UUID]` replaced by the bare `Name`. For display
121
- * or any place where the literal name is wanted. */
122
- cleanedText: string;
123
- /**
124
- * The text to send to the AGENT PIPELINE (router + specialists). Each mention is
125
- * replaced by a NEUTRAL DEICTIC ("il blocco selezionato" / "la scena selezionata")
126
- * instead of the entity name. Rationale: the small routing model keyword-matches
127
- * intent, and a tagged block whose name happens to read as a command — e.g. the
128
- * default "Nuovo blocco quiz vuoto" ("new empty quiz block") — was mis-parsed as
129
- * an `add_block` intent, creating a phantom block. The authoritative name + ID
130
- * still travel in [CONTEXT] (referencedEntities), so nothing is lost.
131
- */
132
- agentText: string;
133
- /** De-duplicated entities that exist in the activity (unknown UUIDs dropped). */
134
- entities: ResolvedEntity[];
135
- }
136
- /** Raw `{name,id}` pairs as written in the text (no validation). */
137
- declare function parseMentions(text: string): {
138
- name: string;
139
- id: string;
140
- }[];
141
- /**
142
- * Resolve mentions against an `activity` ({ scenes: [{ id, blocks: [{ id, type }] }] }).
143
- * Strips every tag to its readable name; collects the ones whose UUID matches a real
144
- * scene/block. Pure and deterministic.
145
- */
146
- declare function resolveMentions(text: string, activity: any): MentionResolution;
147
-
148
688
  declare const BLOCK_TYPES: readonly ["Quiz", "Editor", "Hotpoint", "Embed", "Media", "DragAndDrop", "Anagram", "Dice", "Crossword", "WordSearch", "Puzzle", "Memory", "Flashcard", "SpinningWheel", "Chart", "MatchPairs", "Shape", "Arrow", "Cloze", "CardDeck"];
149
689
  declare const BlockTypeSchema: z.ZodEnum<["Quiz", "Editor", "Hotpoint", "Embed", "Media", "DragAndDrop", "Anagram", "Dice", "Crossword", "WordSearch", "Puzzle", "Memory", "Flashcard", "SpinningWheel", "Chart", "MatchPairs", "Shape", "Arrow", "Cloze", "CardDeck"]>;
150
690
  type BlockType = z.infer<typeof BlockTypeSchema>;
@@ -25969,6 +26509,111 @@ interface AIState {
25969
26509
  }
25970
26510
  declare const SceneTypeSchema: z.ZodEnum<["2D", "360°"]>;
25971
26511
  type SceneType = z.infer<typeof SceneTypeSchema>;
26512
+ declare const baseBlockShape: {
26513
+ id: z.ZodString;
26514
+ type: z.ZodEnum<["Quiz", "Editor", "Hotpoint", "Embed", "Media", "DragAndDrop", "Anagram", "Dice", "Crossword", "WordSearch", "Puzzle", "Memory", "Flashcard", "SpinningWheel", "Chart", "MatchPairs", "Shape", "Arrow", "Cloze", "CardDeck"]>;
26515
+ title: z.ZodString;
26516
+ showTitle: z.ZodOptional<z.ZodBoolean>;
26517
+ locked: z.ZodOptional<z.ZodBoolean>;
26518
+ groupId: z.ZodOptional<z.ZodString>;
26519
+ position: z.ZodOptional<z.ZodObject<{
26520
+ x: z.ZodNumber;
26521
+ y: z.ZodNumber;
26522
+ z: z.ZodOptional<z.ZodNumber>;
26523
+ }, "strip", z.ZodTypeAny, {
26524
+ x: number;
26525
+ y: number;
26526
+ z?: number | undefined;
26527
+ }, {
26528
+ x: number;
26529
+ y: number;
26530
+ z?: number | undefined;
26531
+ }>>;
26532
+ rotation: z.ZodNumber;
26533
+ hidden: z.ZodOptional<z.ZodBoolean>;
26534
+ draggable: z.ZodOptional<z.ZodBoolean>;
26535
+ size: z.ZodOptional<z.ZodObject<{
26536
+ width: z.ZodOptional<z.ZodNumber>;
26537
+ height: z.ZodOptional<z.ZodNumber>;
26538
+ }, "strip", z.ZodTypeAny, {
26539
+ width?: number | undefined;
26540
+ height?: number | undefined;
26541
+ }, {
26542
+ width?: number | undefined;
26543
+ height?: number | undefined;
26544
+ }>>;
26545
+ minSize: z.ZodOptional<z.ZodObject<{
26546
+ width: z.ZodOptional<z.ZodNumber>;
26547
+ height: z.ZodOptional<z.ZodNumber>;
26548
+ }, "strip", z.ZodTypeAny, {
26549
+ width?: number | undefined;
26550
+ height?: number | undefined;
26551
+ }, {
26552
+ width?: number | undefined;
26553
+ height?: number | undefined;
26554
+ }>>;
26555
+ maxSize: z.ZodOptional<z.ZodObject<{
26556
+ width: z.ZodOptional<z.ZodNumber>;
26557
+ height: z.ZodOptional<z.ZodNumber>;
26558
+ }, "strip", z.ZodTypeAny, {
26559
+ width?: number | undefined;
26560
+ height?: number | undefined;
26561
+ }, {
26562
+ width?: number | undefined;
26563
+ height?: number | undefined;
26564
+ }>>;
26565
+ theme: z.ZodOptional<z.ZodObject<{
26566
+ spacing: z.ZodOptional<z.ZodEnum<["no-spacing", "small", "medium", "large"]>>;
26567
+ animation: z.ZodOptional<z.ZodObject<{
26568
+ type: z.ZodUnion<[z.ZodEnum<["none", "fade", "direction", "bounce", "scale", "rotate"]>, z.ZodString]>;
26569
+ duration: z.ZodOptional<z.ZodNumber>;
26570
+ delay: z.ZodOptional<z.ZodNumber>;
26571
+ phase: z.ZodOptional<z.ZodEnum<["in", "both", "out"]>>;
26572
+ direction: z.ZodOptional<z.ZodEnum<["up", "right", "down", "left"]>>;
26573
+ }, "strip", z.ZodTypeAny, {
26574
+ type: string;
26575
+ duration?: number | undefined;
26576
+ direction?: "up" | "right" | "down" | "left" | undefined;
26577
+ delay?: number | undefined;
26578
+ phase?: "in" | "both" | "out" | undefined;
26579
+ }, {
26580
+ type: string;
26581
+ duration?: number | undefined;
26582
+ direction?: "up" | "right" | "down" | "left" | undefined;
26583
+ delay?: number | undefined;
26584
+ phase?: "in" | "both" | "out" | undefined;
26585
+ }>>;
26586
+ styles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>>>;
26587
+ }, "strip", z.ZodTypeAny, {
26588
+ spacing?: "small" | "no-spacing" | "medium" | "large" | undefined;
26589
+ animation?: {
26590
+ type: string;
26591
+ duration?: number | undefined;
26592
+ direction?: "up" | "right" | "down" | "left" | undefined;
26593
+ delay?: number | undefined;
26594
+ phase?: "in" | "both" | "out" | undefined;
26595
+ } | undefined;
26596
+ styles?: Record<string, Record<string, any>> | undefined;
26597
+ }, {
26598
+ spacing?: "small" | "no-spacing" | "medium" | "large" | undefined;
26599
+ animation?: {
26600
+ type: string;
26601
+ duration?: number | undefined;
26602
+ direction?: "up" | "right" | "down" | "left" | undefined;
26603
+ delay?: number | undefined;
26604
+ phase?: "in" | "both" | "out" | undefined;
26605
+ } | undefined;
26606
+ styles?: Record<string, Record<string, any>> | undefined;
26607
+ }>>;
26608
+ };
26609
+ /**
26610
+ * The base-block plumbing keys every block carries (identity, geometry,
26611
+ * theme...) — editor concerns, not authorable content. Single source for
26612
+ * consumers that need a content-only projection of a canonical block schema
26613
+ * (e.g. `QuizBlockSchema.omit(...)` for an AI tool input): derived from
26614
+ * baseBlockShape itself so it can never drift from the real schemas.
26615
+ */
26616
+ declare const BASE_BLOCK_FIELDS: readonly (keyof typeof baseBlockShape)[];
25972
26617
  declare const ActionBlockSchema: z.ZodObject<{
25973
26618
  actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
25974
26619
  id: z.ZodString;
@@ -68793,6 +69438,7 @@ type Scene = z.infer<typeof SceneSchema>;
68793
69438
  declare const ActivityContentSchema: z.ZodObject<{
68794
69439
  id: z.ZodString;
68795
69440
  title: z.ZodString;
69441
+ schemaVersion: z.ZodOptional<z.ZodNumber>;
68796
69442
  hasTimer: z.ZodBoolean;
68797
69443
  timer: z.ZodOptional<z.ZodString>;
68798
69444
  allowNavigation: z.ZodBoolean;
@@ -69348,6 +69994,7 @@ declare const ActivityContentSchema: z.ZodObject<{
69348
69994
  scenes?: string | undefined;
69349
69995
  }[] | undefined;
69350
69996
  timer?: string | undefined;
69997
+ schemaVersion?: number | undefined;
69351
69998
  variables?: {
69352
69999
  name: string;
69353
70000
  defaultValue: string | number | boolean;
@@ -69445,6 +70092,7 @@ declare const ActivityContentSchema: z.ZodObject<{
69445
70092
  scenes?: string | undefined;
69446
70093
  }[] | undefined;
69447
70094
  timer?: string | undefined;
70095
+ schemaVersion?: number | undefined;
69448
70096
  variables?: {
69449
70097
  name: string;
69450
70098
  defaultValue: string | number | boolean;
@@ -77834,16 +78482,304 @@ declare const BasicContentSchema: z.ZodObject<{
77834
78482
  type BasicContent = z.infer<typeof BasicContentSchema>;
77835
78483
 
77836
78484
  /**
77837
- * Map of block type → content schema used for prompt reference generation.
77838
- * Adding a new block type means: add Zod schema + register here + (optionally)
77839
- * add MCP tool wiring. Agent prompts stay in sync automatically.
78485
+ * Map of block type → content schema used for prompt reference generation and
78486
+ * the published AI JSON-schema factory (@edugate/ai-agent).
78487
+ *
78488
+ * Now derived from BLOCK_REGISTRY: every entry IS the canonical block schema
78489
+ * from ./blocks.ts — the same one the editor, player and store validate
78490
+ * against. This replaces the second, hand-written AI-facing schema system
78491
+ * (content/*.ts), which had structurally drifted from the editor's real
78492
+ * schemas (incompatible Question shapes, 18/20 coverage). The content/*.ts
78493
+ * schemas stay exported for backward compatibility but are deprecated and no
78494
+ * longer feed any AI surface.
77840
78495
  */
77841
- declare const BLOCK_CONTENT_SCHEMAS: Record<string, z.ZodTypeAny>;
78496
+ declare const BLOCK_CONTENT_SCHEMAS: Record<BlockType, z.ZodTypeAny>;
78497
+ interface BlockReferenceOptions {
78498
+ /**
78499
+ * Omit the shared base-block plumbing (id, geometry, theme...; the
78500
+ * BASE_BLOCK_FIELDS) so the reference covers only each block's authorable
78501
+ * content. The full canonical reference weighs ~95KB — far too heavy to
78502
+ * inject into a system prompt every turn; the content-only view is what
78503
+ * agent prompts should use.
78504
+ */
78505
+ contentOnly?: boolean;
78506
+ }
77842
78507
  /**
77843
78508
  * Generates a human-readable Markdown reference of all block content
77844
78509
  * schemas, suitable for injection into agent system prompts.
77845
78510
  */
77846
- declare function generateBlockReference(): string;
78511
+ declare function generateBlockReference(options?: BlockReferenceOptions): string;
78512
+
78513
+ /**
78514
+ * The per-block-type contract every entry of BLOCK_REGISTRY must satisfy.
78515
+ *
78516
+ * A definition WRAPS the existing canonical Zod schema from ../blocks.ts — it
78517
+ * never redefines it. Everything the rest of the system needs to know about a
78518
+ * block type (schema, defaults, capabilities, versioning) is declared here
78519
+ * once; the hand-maintained parallel registries (BLOCK_CONTENT_SCHEMAS, the
78520
+ * named Block union, STYLE_TARGET_MAP, …) become derivations of this registry.
78521
+ */
78522
+ interface BlockCapabilities {
78523
+ /** actionBlockShape vs baseBlockShape: does the block carry actions[] + score? */
78524
+ hasActions: boolean;
78525
+ hasScore: boolean;
78526
+ /**
78527
+ * Nested collections the AI canvas ops insertItem/updateItem/deleteItem may
78528
+ * manipulate (e.g. { questions: QuestionSchema } for Quiz). A collection name
78529
+ * not declared here is unknown to the semantic canvas-op validator, so a typo
78530
+ * becomes a structured error instead of a silent no-op.
78531
+ */
78532
+ collections?: Record<string, z.ZodTypeAny>;
78533
+ /**
78534
+ * Logical style target → REAL style keys the block's renderer reads (same
78535
+ * nested shape as STYLE_TARGET_MAP in ../style-targets.ts). The nested shape
78536
+ * is load-bearing: styleTargetsHelpFor / mapLogicalThemeStyles depend on the
78537
+ * logical→real mapping, not on a flat key list. Undefined = block is not
78538
+ * styleable via logical targets (see UNSTYLEABLE_BLOCKS).
78539
+ */
78540
+ styleTargets?: Partial<Record<LogicalTarget, string[]>>;
78541
+ /** How the 360° scene renders this block; replaces the silent raster fallback switch. */
78542
+ vrMode: "interactive" | "raster" | "custom";
78543
+ analytics?: {
78544
+ scorable: boolean;
78545
+ };
78546
+ }
78547
+ interface BlockCoreDefinition<TType extends BlockType, TContent extends z.ZodTypeAny, TTheme extends z.ZodTypeAny = never> {
78548
+ type: TType;
78549
+ /** The canonical schema from ../blocks.ts — reused, never rewritten. */
78550
+ contentSchema: TContent;
78551
+ themeSchema?: TTheme;
78552
+ /**
78553
+ * Checked by a generated test: contentSchema.parse(defaultContent) must not
78554
+ * throw. `id` is a placeholder ("") replaced with a nanoid at instantiation
78555
+ * time — the schema enforces shape, not uniqueness, so "" is valid there.
78556
+ */
78557
+ defaultContent: z.infer<TContent>;
78558
+ capabilities: BlockCapabilities;
78559
+ /** Content-schema version of THIS block type (migration pipeline, D4). */
78560
+ version: number;
78561
+ /** Migrations vN → vN+1, keyed by the STARTING version. */
78562
+ migrations?: Record<number, (old: unknown) => unknown>;
78563
+ /**
78564
+ * Optional AI-facing projection: fields to omit from the JSON schema shown
78565
+ * to agents (e.g. editor-only fields). Default: expose the full canonical
78566
+ * schema. This is a projection of the ONE schema — never a second schema.
78567
+ */
78568
+ aiProjection?: {
78569
+ omit: readonly string[];
78570
+ };
78571
+ }
78572
+
78573
+ /**
78574
+ * Typed identity function over the registry contract: it builds no runtime
78575
+ * block instances — it forces the caller to provide every required field of
78576
+ * BlockCoreDefinition while preserving the literal types (the `satisfies`
78577
+ * pattern, for a value that is also exported with a reusable explicit type).
78578
+ * A definition missing e.g. capabilities.vrMode does not compile.
78579
+ */
78580
+ declare function defineBlock<TType extends BlockType, TContent extends z.ZodTypeAny, TTheme extends z.ZodTypeAny = never>(def: BlockCoreDefinition<TType, TContent, TTheme>): BlockCoreDefinition<TType, TContent, TTheme>;
78581
+
78582
+ /**
78583
+ * The single point of declaration for everything the system knows about a
78584
+ * block type. Mapped type over BlockType, NOT Record<string, …>: omitting an
78585
+ * entry here is a COMPILE error (TS2741), not a silent hole like the old
78586
+ * hand-maintained maps (BLOCK_CONTENT_SCHEMAS covered 18/20 types for months
78587
+ * before anyone noticed).
78588
+ *
78589
+ * Every hand-maintained parallel view (the AI content-schema map, the style
78590
+ * target map, …) must be derived from this registry — see ./derived.ts.
78591
+ */
78592
+ declare const BLOCK_REGISTRY: {
78593
+ [K in BlockType]: BlockCoreDefinition<K, z.ZodTypeAny, z.ZodTypeAny>;
78594
+ };
78595
+ declare function getBlockDefinition<T extends BlockType>(type: T): BlockCoreDefinition<T, z.ZodTypeAny, z.ZodTypeAny>;
78596
+
78597
+ /**
78598
+ * Views DERIVED from BLOCK_REGISTRY — successors of the hand-maintained
78599
+ * parallel maps. They cannot drift: the registry is exhaustive by mapped type,
78600
+ * so a new BlockType that lacks a definition breaks the build before any of
78601
+ * these can silently miss it.
78602
+ *
78603
+ * NOTE: the BlockSchema discriminated union itself intentionally stays
78604
+ * declared in ../blocks.ts — SceneSchema composes it in the same module, so
78605
+ * deriving it here would create a blocks.ts ⇄ registry import cycle (TDZ at
78606
+ * module init). Drift between the union and the registry is instead made
78607
+ * impossible by the referential-identity test in
78608
+ * __tests__/registry.consistency.spec.ts (union options === registry schemas).
78609
+ */
78610
+ /**
78611
+ * Block type → canonical content schema, straight from the registry.
78612
+ * Successor of the AI-facing BLOCK_CONTENT_SCHEMAS in ../docs.ts (which was a
78613
+ * second, hand-written schema system that drifted from the editor's real
78614
+ * schemas — incompatible Question shapes, 18/20 coverage).
78615
+ */
78616
+ declare const REGISTRY_CONTENT_SCHEMAS: {
78617
+ [K in BlockType]: z.ZodTypeAny;
78618
+ };
78619
+ /**
78620
+ * Block type → logical style-target map, from capabilities.styleTargets.
78621
+ * Successor of the hand-written STYLE_TARGET_MAP rows in ../style-targets.ts
78622
+ * (kept API-compatible there for the published npm surface; a consistency test
78623
+ * pins the two together until the legacy map is physically replaced).
78624
+ *
78625
+ * Known PRE-EXISTING gaps carried over as-is, not regressions of this
78626
+ * refactor: Embed and Arrow have no logical style targets (absent from the
78627
+ * legacy map without being listed in UNSTYLEABLE_BLOCKS either).
78628
+ */
78629
+ declare const REGISTRY_STYLE_TARGETS: {
78630
+ [K in BlockType]: Partial<Record<LogicalTarget, string[]>>;
78631
+ };
78632
+
78633
+ declare const CURRENT_SCHEMA_VERSION = 1;
78634
+ declare class ActivityContentMigrationError extends Error {
78635
+ constructor(message: string);
78636
+ }
78637
+ /**
78638
+ * The subset of BlockCoreDefinition the pipeline needs, keyed by block type.
78639
+ * Matches BLOCK_REGISTRY's shape but is intentionally loose (not the mapped
78640
+ * BlockType-exhaustive type BLOCK_REGISTRY itself has) so tests can pass a
78641
+ * partial/mock registry — e.g. to exercise a multi-step migration chain
78642
+ * without depending on a real block type ever reaching version 3.
78643
+ */
78644
+ type MigrationRegistry = Record<string, {
78645
+ version: number;
78646
+ migrations?: Record<number, (old: unknown) => unknown>;
78647
+ }>;
78648
+ interface MigrateActivityContentResult {
78649
+ content: ActivityContent;
78650
+ changed: boolean;
78651
+ issues: string[];
78652
+ }
78653
+ /**
78654
+ * Migrates a raw (untyped, possibly historical) activity content blob to the
78655
+ * current schema shape. Pure function — never mutates `raw`; every level it
78656
+ * touches is cloned.
78657
+ *
78658
+ * Deliberately does NOT zod-parse the result before returning it: validating
78659
+ * the migrated shape against ActivityContentSchema is the responsibility of
78660
+ * whatever boundary calls this pipeline (Fase 3 wiring, not this library) —
78661
+ * keeping that decision out of here means this stays usable for offline
78662
+ * inspection/dry-run tooling that wants to see `issues` even when the result
78663
+ * wouldn't (yet) pass strict validation.
78664
+ *
78665
+ * @param raw content as read from storage (e.g. an activities.content jsonb
78666
+ * column) — v0 (schemaVersion missing/undefined) is the implicit starting
78667
+ * point for content that predates versioning entirely.
78668
+ * @param registry block-type → definition lookup; defaults to the real
78669
+ * BLOCK_REGISTRY. Overridable for testing.
78670
+ */
78671
+ declare function migrateActivityContent(raw: unknown, registry?: MigrationRegistry): MigrateActivityContentResult;
78672
+
78673
+ /**
78674
+ * v1 → v2 migration for block content built on actionBlockShape (every block
78675
+ * that carries `actions[]` — Quiz, Hotpoint, Editor, DragAndDrop, Anagram,
78676
+ * Dice, Puzzle, Crossword, WordSearch, Memory, Flashcard, SpinningWheel,
78677
+ * Chart, MatchPairs, Cloze, CardDeck).
78678
+ *
78679
+ * Collapses the legacy single `condition` field on an Action into the
78680
+ * `conditions[]` array that now coexists with it on ActionSchema (see
78681
+ * packages/types/src/builder/actions.ts). Today the UI normalizes this ad hoc
78682
+ * in forms/panels/action.tsx and strips `condition` on submit — that
78683
+ * normalization is untouched by this migration and keeps doing its job for
78684
+ * content written through the editor.
78685
+ *
78686
+ * NOT registered on any BlockCoreDefinition yet, and no definition's
78687
+ * `version` is bumped to 2 here — that adoption step is deliberately
78688
+ * deferred until a real prod content sample has validated this transform.
78689
+ * To adopt it once validated, on the relevant block definition(s):
78690
+ *
78691
+ * migrations: { 1: actionsV1toV2 },
78692
+ * version: 2,
78693
+ *
78694
+ * Pure function: never mutates `old`. Malformed input (not an object, no
78695
+ * actions[], actions entries that aren't objects) is returned unchanged
78696
+ * rather than throwing — the migration pipeline calls this per-block on
78697
+ * historical data that may not conform to any current schema.
78698
+ */
78699
+ declare const actionsV1toV2: (old: unknown) => unknown;
78700
+
78701
+ /**
78702
+ * Machine-readable capabilities manifest for external agents (Dify tools,
78703
+ * edugate-agents). Closes the "external agents guess collections and style
78704
+ * targets" gap: STYLE_TARGET_MAP used to be copied by hand across repos and
78705
+ * silently went stale — this is generated from BLOCK_REGISTRY instead.
78706
+ *
78707
+ * PLAIN DATA ONLY, by design rule: the published npm surface exchanges JSON
78708
+ * Schema objects, op payloads and verdicts — never live Zod schema instances
78709
+ * (a consumer resolving its own zod copy would get schemas whose identity
78710
+ * doesn't match the bundled one). Collections are therefore exposed as key
78711
+ * NAMES; the per-item schemas stay internal to the validation functions.
78712
+ */
78713
+ interface BlockCapabilitiesManifestEntry {
78714
+ type: BlockType;
78715
+ /** Content-schema version of this block type (migration pipeline, D4). */
78716
+ version: number;
78717
+ hasActions: boolean;
78718
+ hasScore: boolean;
78719
+ /** Names of the collections insertItem/updateItem/deleteItem may target. */
78720
+ collections: string[];
78721
+ /**
78722
+ * Logical style target → REAL style keys the block's renderer reads (same
78723
+ * nested shape as capabilities.styleTargets). Empty object = the block is
78724
+ * not styleable via logical targets.
78725
+ */
78726
+ styleTargets: Partial<Record<LogicalTarget, string[]>>;
78727
+ vrMode: "interactive" | "raster" | "custom";
78728
+ }
78729
+ declare function getCapabilitiesManifest(): BlockCapabilitiesManifestEntry[];
78730
+
78731
+ /**
78732
+ * @-mention ("tag") resolution — turn the builder's `@[Name|UUID]` tags into an
78733
+ * AUTHORITATIVE target the agents can actually consume.
78734
+ *
78735
+ * Root cause (see docs/ai-tag-context-and-quiz-styling-rootcause.md): the builder
78736
+ * inserts a literal `@[Name|UUID]` into the message text, but NOTHING resolved it —
78737
+ * the only structured target the agents received was `selectedBlockId` (the CLICKED
78738
+ * block). Tagging ≠ selecting, so a tagged-but-not-selected block (e.g. a Quiz the
78739
+ * user wants to style) was effectively ignored and mis-targeted.
78740
+ *
78741
+ * This module is PURE (no I/O): given the message text and the activity, it strips
78742
+ * the tag noise to readable names and returns the entities that actually exist, so
78743
+ * the route can promote them to the request target and surface them in [CONTEXT].
78744
+ */
78745
+ /** A `@[Name|UUID]` reference resolved against the activity. */
78746
+ interface ResolvedEntity {
78747
+ id: string;
78748
+ name: string;
78749
+ kind: "scene" | "block";
78750
+ /** Present for blocks. */
78751
+ blockType?: string;
78752
+ /** The scene that contains the block (present for blocks). */
78753
+ sceneId?: string;
78754
+ }
78755
+ interface MentionResolution {
78756
+ /** The text with every `@[Name|UUID]` replaced by the bare `Name`. For display
78757
+ * or any place where the literal name is wanted. */
78758
+ cleanedText: string;
78759
+ /**
78760
+ * The text to send to the AGENT PIPELINE (router + specialists). Each mention is
78761
+ * replaced by a NEUTRAL DEICTIC ("il blocco selezionato" / "la scena selezionata")
78762
+ * instead of the entity name. Rationale: the small routing model keyword-matches
78763
+ * intent, and a tagged block whose name happens to read as a command — e.g. the
78764
+ * default "Nuovo blocco quiz vuoto" ("new empty quiz block") — was mis-parsed as
78765
+ * an `add_block` intent, creating a phantom block. The authoritative name + ID
78766
+ * still travel in [CONTEXT] (referencedEntities), so nothing is lost.
78767
+ */
78768
+ agentText: string;
78769
+ /** De-duplicated entities that exist in the activity (unknown UUIDs dropped). */
78770
+ entities: ResolvedEntity[];
78771
+ }
78772
+ /** Raw `{name,id}` pairs as written in the text (no validation). */
78773
+ declare function parseMentions(text: string): {
78774
+ name: string;
78775
+ id: string;
78776
+ }[];
78777
+ /**
78778
+ * Resolve mentions against an `activity` ({ scenes: [{ id, blocks: [{ id, type }] }] }).
78779
+ * Strips every tag to its readable name; collects the ones whose UUID matches a real
78780
+ * scene/block. Pure and deterministic.
78781
+ */
78782
+ declare function resolveMentions(text: string, activity: any): MentionResolution;
77847
78783
 
77848
78784
  declare function listBlockTypes(): string[];
77849
78785
  /**
@@ -77863,4 +78799,4 @@ declare function getBlockJsonSchema(blockType: string): Record<string, unknown>
77863
78799
  */
77864
78800
  declare function getAllBlockJsonSchemas(): Record<string, Record<string, unknown>>;
77865
78801
 
77866
- export { type AIState, type Action, type ActionBlock, ActionBlockSchema, type ActionCondition, ActionConditionSchema, ActionSchema, type ActionType, ActionTypeSchema, type ActionVariable, ActionVariableSchema, type ActivityContent, ActivityContentSchema, type ActivityContext, ActivityContextSchema, type ActivityVariable, ActivityVariableSchema, type AnagramBlock, AnagramBlockSchema, type AnagramBlockTheme, AnagramBlockThemeSchema, type AnagramContent, AnagramContentSchema, type Animation, AnimationSchema, type ArrowBlock, ArrowBlockSchema, type ArrowHeadType, ArrowHeadTypeSchema, type ArrowLabel, ArrowLabelSchema, BLOCK_CONTENT_SCHEMAS, BLOCK_STYLE_KEYS, BLOCK_TYPES, type BasicContent, BasicContentSchema, type Block, type BlockEvent, BlockEventSchema, type BlockEventType, BlockEventTypeSchema, type BlockGroup, BlockGroupSchema, BlockSchema, type BlockTheme, BlockThemeSchema, type BlockType, BlockTypeSchema, type BoxSide, BoxSideSchema, type BoxStyles, BoxStylesSchema, CANVAS_OP_NAMES, CANVAS_OP_REQUIRED, type CanvasDragItem, CanvasDragItemSchema, type CanvasOpErrorCode, type CanvasOpValidation, type Card, type CardDeckBlock, CardDeckBlockSchema, type CardDeckBlockTheme, CardDeckBlockThemeSchema, type CardFace, CardFaceSchema, type CardItem, CardItemSchema, CardSchema, type ChartBlock, ChartBlockSchema, type ChartConfig, ChartConfigSchema, type ChartContent, ChartContentSchema, type ChartType, ChartTypeSchema, type ChoiceQuestion, ChoiceQuestionSchema, type ClickCondition, ClickConditionSchema, type ClozeBlock, ClozeBlockSchema, type ClozeBlockTheme, ClozeBlockThemeSchema, type ClozeContent, ClozeContentSchema, type ClozeMode, ClozeModeSchema, type ConditionOperator, ConditionOperatorSchema, type ConflictVerdict, type CropData, CropDataSchema, type CrosswordBlock, CrosswordBlockSchema, type CrosswordBlockTheme, CrosswordBlockThemeSchema, type CrosswordCell, CrosswordCellSchema, type CrosswordContent, CrosswordContentSchema, type CrosswordLayoutOutput, CrosswordLayoutOutputSchema, type CrosswordLayoutWord, CrosswordLayoutWordSchema, type CrosswordWord, CrosswordWordSchema, type DeckBlockType, DeckBlockTypeSchema, type DeckContent, DeckContentSchema, type DiceBlock, DiceBlockSchema, type DiceBlockTheme, DiceBlockThemeSchema, type DiceContent, DiceContentSchema, type DiceType, DiceTypeSchema, type DieType, DieTypeSchema, type DragAndDropBlock, DragAndDropBlockSchema, type DragAndDropBlockTheme, DragAndDropBlockThemeSchema, type DragAndDropContent, DragAndDropContentSchema, type DragAndDropGroup, DragAndDropGroupSchema, DragAndDropItemSchema, type DragGroup, DragGroupSchema, type DragItem, DragItemSchema, type EditorBlock, EditorBlockSchema, type EditorBlockTheme, EditorBlockThemeSchema, type EmbedBlock, EmbedBlockSchema, type FlashcardBlock, FlashcardBlockSchema, type FlashcardBlockTheme, FlashcardBlockThemeSchema, FlashcardContentSchema, type FlashcardItem, FlashcardItemSchema, type GridSize, GridSizeSchema, type HotpointBlock, HotpointBlockSchema, type HotpointBlockTheme, HotpointBlockThemeSchema, ImageAlignSchema, ImageSizeSchema, type KeyPressCondition, KeyPressConditionSchema, type LogicalTarget, type MatchPairsBlock, MatchPairsBlockSchema, type MatchPairsBlockTheme, MatchPairsBlockThemeSchema, type MatchPairsPair, MatchPairsPairSchema, type MathOperation, MathOperationSchema, type MediaBlock, MediaBlockSchema, type MediaItem, MediaItemSchema, type MediaRef, MediaRefSchema, type MediaSource, MediaSourceSchema, type MediaType, MediaTypeSchema, type MemoryBlock, MemoryBlockSchema, type MemoryBlockTheme, MemoryBlockThemeSchema, type MemoryPair, MemoryPairSchema, type MemoryPairType, MemoryPairTypeSchema, type MentionResolution, type OpTarget, type OpTargetKind, type Pair, type PairGameBlockType, PairGameBlockTypeSchema, type PairGameContent, PairGameContentSchema, PairSchema, type Position, PositionSchema, type PuzzleBlock, PuzzleBlockSchema, type PuzzleContent, PuzzleContentSchema, type PuzzleGameMode, PuzzleGameModeSchema, type PuzzleType, PuzzleTypeSchema, type Question, type QuestionOption, QuestionOptionSchema, QuestionSchema, type QuestionType, QuestionTypeSchema, type QuizBlock, QuizBlockSchema, type QuizBlockTheme, QuizBlockThemeSchema, type QuizCondition, QuizConditionSchema, type QuizContent, QuizContentSchema, type QuizOption, QuizOptionSchema, type QuizQuestion, QuizQuestionSchema, type QuizQuestionType, QuizQuestionTypeSchema, type Radius, RadiusSchema, type ResolvedEntity, STYLE_TARGET_MAP, type Scene, type SceneBlockRef, SceneBlockRefSchema, SceneSchema, type SceneSummary, SceneSummarySchema, type SceneType, SceneTypeSchema, type ShapeBlock, ShapeBlockSchema, type ShapeBlockTheme, ShapeBlockThemeSchema, type ShapeType, ShapeTypeSchema, type Size, SizeSchema, type SpinnerContent, SpinnerContentSchema, type SpinnerSlice, SpinnerSliceSchema, type SpinningWheelBlock, SpinningWheelBlockSchema, type SpinningWheelBlockTheme, SpinningWheelBlockThemeSchema, type TextQuestion, TextQuestionSchema, type TextStyles, TextStylesSchema, type TimerCondition, TimerConditionSchema, type TrueFalseQuestion, TrueFalseQuestionSchema, UNSTYLEABLE_BLOCKS, type VideoSettings, VideoSettingsSchema, type WheelSlice, WheelSliceSchema, type WordGameBlockType, WordGameBlockTypeSchema, type WordSearchBlock, WordSearchBlockSchema, type WordSearchBlockTheme, WordSearchBlockThemeSchema, type WordSearchContent, WordSearchContentSchema, WordSearchDataSchema, type WordSearchDifficulty, WordSearchDifficultySchema, applyItemPatch, detectConflict, entitySignature, generateBlockReference, getAllBlockJsonSchemas, getBlockJsonSchema, isKnownCanvasOp, listBlockTypes, mapLogicalThemeStyles, mergeTheme, opConflictStamp, opTarget, parseMentions, realStyleKeysFor, resolveMentions, stableStringify, styleTargetsHelpFor, validateCanvasOp };
78802
+ export { type AIState, type Action, type ActionBlock, ActionBlockSchema, type ActionCondition, ActionConditionSchema, ActionSchema, type ActionType, ActionTypeSchema, type ActionVariable, ActionVariableSchema, type ActivityContent, ActivityContentMigrationError, ActivityContentSchema, type ActivityContext, ActivityContextSchema, type ActivityVariable, ActivityVariableSchema, type AnagramBlock, AnagramBlockSchema, type AnagramBlockTheme, AnagramBlockThemeSchema, type AnagramContent, AnagramContentSchema, type Animation, AnimationSchema, type ArrowBlock, ArrowBlockSchema, type ArrowHeadType, ArrowHeadTypeSchema, type ArrowLabel, ArrowLabelSchema, BASE_BLOCK_FIELDS, BLOCK_CONTENT_SCHEMAS, BLOCK_REGISTRY, BLOCK_STYLE_KEYS, BLOCK_TYPES, type BasicContent, BasicContentSchema, type Block, type BlockCapabilities, type BlockCapabilitiesManifestEntry, type BlockCoreDefinition, type BlockEvent, BlockEventSchema, type BlockEventType, BlockEventTypeSchema, type BlockGroup, BlockGroupSchema, type BlockReferenceOptions, type BlockRegistryView, BlockSchema, type BlockTheme, BlockThemeSchema, type BlockType, BlockTypeSchema, type BoxSide, BoxSideSchema, type BoxStyles, BoxStylesSchema, CANVAS_OP_NAMES, CANVAS_OP_REQUIRED, CURRENT_SCHEMA_VERSION, type CanvasDragItem, CanvasDragItemSchema, type CanvasOp, type CanvasOpErrorCode, CanvasOpSchema, type CanvasOpValidation, type CanvasOpValidationCode, type CanvasOpValidationResult, type Card, type CardDeckBlock, CardDeckBlockSchema, type CardDeckBlockTheme, CardDeckBlockThemeSchema, type CardFace, CardFaceSchema, type CardItem, CardItemSchema, CardSchema, type ChartBlock, ChartBlockSchema, type ChartConfig, ChartConfigSchema, type ChartContent, ChartContentSchema, type ChartType, ChartTypeSchema, type ChoiceQuestion, ChoiceQuestionSchema, type ClickCondition, ClickConditionSchema, type ClozeBlock, ClozeBlockSchema, type ClozeBlockTheme, ClozeBlockThemeSchema, type ClozeContent, ClozeContentSchema, type ClozeMode, ClozeModeSchema, type ConditionOperator, ConditionOperatorSchema, type ConflictVerdict, type CropData, CropDataSchema, type CrosswordBlock, CrosswordBlockSchema, type CrosswordBlockTheme, CrosswordBlockThemeSchema, type CrosswordCell, CrosswordCellSchema, type CrosswordContent, CrosswordContentSchema, type CrosswordLayoutOutput, CrosswordLayoutOutputSchema, type CrosswordLayoutWord, CrosswordLayoutWordSchema, type CrosswordWord, CrosswordWordSchema, type DeckBlockType, DeckBlockTypeSchema, type DeckContent, DeckContentSchema, type DiceBlock, DiceBlockSchema, type DiceBlockTheme, DiceBlockThemeSchema, type DiceContent, DiceContentSchema, type DiceType, DiceTypeSchema, type DieType, DieTypeSchema, type DragAndDropBlock, DragAndDropBlockSchema, type DragAndDropBlockTheme, DragAndDropBlockThemeSchema, type DragAndDropContent, DragAndDropContentSchema, type DragAndDropGroup, DragAndDropGroupSchema, DragAndDropItemSchema, type DragGroup, DragGroupSchema, type DragItem, DragItemSchema, type EditorBlock, EditorBlockSchema, type EditorBlockTheme, EditorBlockThemeSchema, type EmbedBlock, EmbedBlockSchema, type FlashcardBlock, FlashcardBlockSchema, type FlashcardBlockTheme, FlashcardBlockThemeSchema, FlashcardContentSchema, type FlashcardItem, FlashcardItemSchema, type GridSize, GridSizeSchema, type HotpointBlock, HotpointBlockSchema, type HotpointBlockTheme, HotpointBlockThemeSchema, ImageAlignSchema, ImageSizeSchema, type KeyPressCondition, KeyPressConditionSchema, type LogicalTarget, type MatchPairsBlock, MatchPairsBlockSchema, type MatchPairsBlockTheme, MatchPairsBlockThemeSchema, type MatchPairsPair, MatchPairsPairSchema, type MathOperation, MathOperationSchema, type MediaBlock, MediaBlockSchema, type MediaItem, MediaItemSchema, type MediaRef, MediaRefSchema, type MediaSource, MediaSourceSchema, type MediaType, MediaTypeSchema, type MemoryBlock, MemoryBlockSchema, type MemoryBlockTheme, MemoryBlockThemeSchema, type MemoryPair, MemoryPairSchema, type MemoryPairType, MemoryPairTypeSchema, type MentionResolution, type MigrateActivityContentResult, type MigrationRegistry, type OpTarget, type OpTargetKind, type Pair, type PairGameBlockType, PairGameBlockTypeSchema, type PairGameContent, PairGameContentSchema, PairSchema, type Position, PositionSchema, type PuzzleBlock, PuzzleBlockSchema, type PuzzleContent, PuzzleContentSchema, type PuzzleGameMode, PuzzleGameModeSchema, type PuzzleType, PuzzleTypeSchema, type Question, type QuestionOption, QuestionOptionSchema, QuestionSchema, type QuestionType, QuestionTypeSchema, type QuizBlock, QuizBlockSchema, type QuizBlockTheme, QuizBlockThemeSchema, type QuizCondition, QuizConditionSchema, type QuizContent, QuizContentSchema, type QuizOption, QuizOptionSchema, type QuizQuestion, QuizQuestionSchema, type QuizQuestionType, QuizQuestionTypeSchema, REGISTRY_CONTENT_SCHEMAS, REGISTRY_STYLE_TARGETS, type Radius, RadiusSchema, type ResolvedEntity, STYLE_TARGET_MAP, type Scene, type SceneBlockRef, SceneBlockRefSchema, SceneSchema, type SceneSummary, SceneSummarySchema, type SceneType, SceneTypeSchema, type ShapeBlock, ShapeBlockSchema, type ShapeBlockTheme, ShapeBlockThemeSchema, type ShapeType, ShapeTypeSchema, type Size, SizeSchema, type SpinnerContent, SpinnerContentSchema, type SpinnerSlice, SpinnerSliceSchema, type SpinningWheelBlock, SpinningWheelBlockSchema, type SpinningWheelBlockTheme, SpinningWheelBlockThemeSchema, type TextQuestion, TextQuestionSchema, type TextStyles, TextStylesSchema, type TimerCondition, TimerConditionSchema, type TrueFalseQuestion, TrueFalseQuestionSchema, UNSTYLEABLE_BLOCKS, type VideoSettings, VideoSettingsSchema, type WheelSlice, WheelSliceSchema, type WordGameBlockType, WordGameBlockTypeSchema, type WordSearchBlock, WordSearchBlockSchema, type WordSearchBlockTheme, WordSearchBlockThemeSchema, type WordSearchContent, WordSearchContentSchema, WordSearchDataSchema, type WordSearchDifficulty, WordSearchDifficultySchema, actionsV1toV2, applyItemPatch, createCanvasOpValidator, defineBlock, detectConflict, entitySignature, generateBlockReference, getAllBlockJsonSchemas, getBlockDefinition, getBlockJsonSchema, getCapabilitiesManifest, isKnownCanvasOp, listBlockTypes, mapLogicalThemeStyles, mergeTheme, migrateActivityContent, opConflictStamp, opTarget, parseMentions, realStyleKeysFor, resolveMentions, stableStringify, styleTargetsHelpFor, validateCanvasOp };