@caelo-cms/shared 0.10.22 → 0.10.24
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/ai-tools.d.ts +289 -273
- package/dist/ai-tools.d.ts.map +1 -1
- package/dist/ai-tools.js +342 -323
- package/dist/ai-tools.js.map +1 -1
- package/dist/auth-forms.d.ts.map +1 -1
- package/dist/auth-forms.js +4 -1
- package/dist/auth-forms.js.map +1 -1
- package/dist/base-css.d.ts +35 -0
- package/dist/base-css.d.ts.map +1 -0
- package/dist/base-css.js +40 -0
- package/dist/base-css.js.map +1 -0
- package/dist/build-page.d.ts +330 -0
- package/dist/build-page.d.ts.map +1 -0
- package/dist/build-page.js +282 -0
- package/dist/build-page.js.map +1 -0
- package/dist/content.d.ts +322 -9
- package/dist/content.d.ts.map +1 -1
- package/dist/content.js +354 -11
- package/dist/content.js.map +1 -1
- package/dist/css-gradient-scan.d.ts +14 -0
- package/dist/css-gradient-scan.d.ts.map +1 -0
- package/dist/css-gradient-scan.js +81 -0
- package/dist/css-gradient-scan.js.map +1 -0
- package/dist/css-var-scan.d.ts +56 -0
- package/dist/css-var-scan.d.ts.map +1 -0
- package/dist/css-var-scan.js +97 -0
- package/dist/css-var-scan.js.map +1 -0
- package/dist/design-draft-shell.d.ts +21 -0
- package/dist/design-draft-shell.d.ts.map +1 -0
- package/dist/design-draft-shell.js +81 -0
- package/dist/design-draft-shell.js.map +1 -0
- package/dist/design-manifest.d.ts +36 -0
- package/dist/design-manifest.d.ts.map +1 -0
- package/dist/design-manifest.js +90 -0
- package/dist/design-manifest.js.map +1 -0
- package/dist/fonts.d.ts +89 -0
- package/dist/fonts.d.ts.map +1 -0
- package/dist/fonts.js +241 -0
- package/dist/fonts.js.map +1 -0
- package/dist/genesis-inventory.d.ts +32 -0
- package/dist/genesis-inventory.d.ts.map +1 -0
- package/dist/genesis-inventory.js +186 -0
- package/dist/genesis-inventory.js.map +1 -0
- package/dist/genesis.d.ts +102 -0
- package/dist/genesis.d.ts.map +1 -0
- package/dist/genesis.js +145 -0
- package/dist/genesis.js.map +1 -0
- package/dist/i18n.d.ts +29 -36
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +53 -128
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -1
- package/dist/index.js.map +1 -1
- package/dist/interactions.d.ts +23 -0
- package/dist/interactions.d.ts.map +1 -0
- package/dist/interactions.js +44 -0
- package/dist/interactions.js.map +1 -0
- package/dist/media.d.ts +101 -16
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +126 -15
- package/dist/media.js.map +1 -1
- package/dist/page-log.d.ts +94 -0
- package/dist/page-log.d.ts.map +1 -0
- package/dist/page-log.js +111 -0
- package/dist/page-log.js.map +1 -0
- package/dist/preview-compose.d.ts +85 -12
- package/dist/preview-compose.d.ts.map +1 -1
- package/dist/preview-compose.js +157 -67
- package/dist/preview-compose.js.map +1 -1
- package/dist/proposal-status.d.ts +40 -0
- package/dist/proposal-status.d.ts.map +1 -0
- package/dist/proposal-status.js +34 -0
- package/dist/proposal-status.js.map +1 -0
- package/dist/responsive-images.d.ts +64 -0
- package/dist/responsive-images.d.ts.map +1 -0
- package/dist/responsive-images.js +98 -0
- package/dist/responsive-images.js.map +1 -0
- package/dist/safe-keys.d.ts +9 -0
- package/dist/safe-keys.d.ts.map +1 -0
- package/dist/safe-keys.js +20 -0
- package/dist/safe-keys.js.map +1 -0
- package/dist/seo.d.ts +11 -16
- package/dist/seo.d.ts.map +1 -1
- package/dist/seo.js +7 -23
- package/dist/seo.js.map +1 -1
- package/dist/skills.d.ts +14 -68
- package/dist/skills.d.ts.map +1 -1
- package/dist/skills.js +19 -113
- package/dist/skills.js.map +1 -1
- package/dist/strip-cdata.d.ts +7 -0
- package/dist/strip-cdata.d.ts.map +1 -0
- package/dist/strip-cdata.js +48 -0
- package/dist/strip-cdata.js.map +1 -0
- package/dist/structured-sets.d.ts +6 -52
- package/dist/structured-sets.d.ts.map +1 -1
- package/dist/structured-sets.js +6 -68
- package/dist/structured-sets.js.map +1 -1
- package/dist/subagents.d.ts +105 -3
- package/dist/subagents.d.ts.map +1 -1
- package/dist/subagents.js +224 -41
- package/dist/subagents.js.map +1 -1
- package/dist/template-engine.d.ts +85 -0
- package/dist/template-engine.d.ts.map +1 -0
- package/dist/template-engine.js +403 -0
- package/dist/template-engine.js.map +1 -0
- package/dist/theme-importers/auto-detect.d.ts +26 -0
- package/dist/theme-importers/auto-detect.d.ts.map +1 -0
- package/dist/theme-importers/auto-detect.js +42 -0
- package/dist/theme-importers/auto-detect.js.map +1 -0
- package/dist/theme-importers/css-comments.d.ts +12 -0
- package/dist/theme-importers/css-comments.d.ts.map +1 -0
- package/dist/theme-importers/css-comments.js +15 -0
- package/dist/theme-importers/css-comments.js.map +1 -0
- package/dist/theme-importers/dtcg.d.ts +46 -0
- package/dist/theme-importers/dtcg.d.ts.map +1 -0
- package/dist/theme-importers/dtcg.js +111 -0
- package/dist/theme-importers/dtcg.js.map +1 -0
- package/dist/theme-importers/loose.d.ts +3 -0
- package/dist/theme-importers/loose.d.ts.map +1 -0
- package/dist/theme-importers/loose.js +76 -0
- package/dist/theme-importers/loose.js.map +1 -0
- package/dist/theme-importers/shadcn.d.ts +24 -0
- package/dist/theme-importers/shadcn.d.ts.map +1 -0
- package/dist/theme-importers/shadcn.js +135 -0
- package/dist/theme-importers/shadcn.js.map +1 -0
- package/dist/theme-importers/style-dictionary.d.ts +17 -0
- package/dist/theme-importers/style-dictionary.d.ts.map +1 -0
- package/dist/theme-importers/style-dictionary.js +125 -0
- package/dist/theme-importers/style-dictionary.js.map +1 -0
- package/dist/theme-importers/tailwind.d.ts +3 -0
- package/dist/theme-importers/tailwind.d.ts.map +1 -0
- package/dist/theme-importers/tailwind.js +218 -0
- package/dist/theme-importers/tailwind.js.map +1 -0
- package/dist/theme-literal-binding.d.ts +37 -0
- package/dist/theme-literal-binding.d.ts.map +1 -0
- package/dist/theme-literal-binding.js +138 -0
- package/dist/theme-literal-binding.js.map +1 -0
- package/dist/theme-normalize.d.ts +31 -0
- package/dist/theme-normalize.d.ts.map +1 -0
- package/dist/theme-normalize.js +587 -0
- package/dist/theme-normalize.js.map +1 -0
- package/dist/theme-ramp.d.ts +55 -0
- package/dist/theme-ramp.d.ts.map +1 -0
- package/dist/theme-ramp.js +149 -0
- package/dist/theme-ramp.js.map +1 -0
- package/dist/theme-render.d.ts +105 -0
- package/dist/theme-render.d.ts.map +1 -0
- package/dist/theme-render.js +441 -0
- package/dist/theme-render.js.map +1 -0
- package/dist/themes-errors.d.ts +109 -0
- package/dist/themes-errors.d.ts.map +1 -0
- package/dist/themes-errors.js +170 -0
- package/dist/themes-errors.js.map +1 -0
- package/dist/themes.d.ts +343 -0
- package/dist/themes.d.ts.map +1 -0
- package/dist/themes.js +697 -0
- package/dist/themes.js.map +1 -0
- package/dist/version.d.ts +7 -4
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +6 -3
- package/dist/version.js.map +1 -1
- package/package.json +10 -2
- package/src/__tests__/redos-hardening.test.ts +160 -0
- package/src/ai-tools-add-module-modes.test.ts +106 -0
- package/src/ai-tools-position.test.ts +134 -0
- package/src/ai-tools.test.ts +81 -0
- package/src/ai-tools.ts +1105 -0
- package/src/auth-forms.ts +36 -0
- package/src/base-css.ts +42 -0
- package/src/build-page.test.ts +228 -0
- package/src/build-page.ts +319 -0
- package/src/cap-failures.ts +67 -0
- package/src/content.test.ts +170 -0
- package/src/content.ts +620 -0
- package/src/context.ts +43 -0
- package/src/css-gradient-scan.ts +88 -0
- package/src/css-var-scan.test.ts +96 -0
- package/src/css-var-scan.ts +144 -0
- package/src/derive-module-type.test.ts +80 -0
- package/src/design-draft-shell.test.ts +85 -0
- package/src/design-draft-shell.ts +109 -0
- package/src/design-manifest.ts +93 -0
- package/src/fonts.test.ts +157 -0
- package/src/fonts.ts +296 -0
- package/src/genesis-inventory.test.ts +86 -0
- package/src/genesis-inventory.ts +215 -0
- package/src/genesis-sanitize.test.ts +35 -0
- package/src/genesis.ts +158 -0
- package/src/i18n.test.ts +58 -0
- package/src/i18n.ts +91 -0
- package/src/index.test.ts +10 -0
- package/src/index.ts +59 -0
- package/src/interactions.ts +48 -0
- package/src/logger.ts +147 -0
- package/src/media.test.ts +160 -0
- package/src/media.ts +355 -0
- package/src/page-log.test.ts +163 -0
- package/src/page-log.ts +124 -0
- package/src/preview-compose.test.ts +637 -0
- package/src/preview-compose.ts +656 -0
- package/src/preview-scanner.test.ts +96 -0
- package/src/preview-scanner.ts +214 -0
- package/src/proposal-status.test.ts +69 -0
- package/src/proposal-status.ts +40 -0
- package/src/responsive-images.test.ts +104 -0
- package/src/responsive-images.ts +151 -0
- package/src/result.ts +29 -0
- package/src/safe-keys.ts +21 -0
- package/src/seo.test.ts +194 -0
- package/src/seo.ts +233 -0
- package/src/skills.ts +48 -0
- package/src/snapshots.test.ts +80 -0
- package/src/snapshots.ts +81 -0
- package/src/strip-cdata.test.ts +41 -0
- package/src/strip-cdata.ts +50 -0
- package/src/structured-sets.ts +114 -0
- package/src/subagents.test.ts +262 -0
- package/src/subagents.ts +432 -0
- package/src/template-engine.test.ts +379 -0
- package/src/template-engine.ts +520 -0
- package/src/theme-gradient.test.ts +92 -0
- package/src/theme-importers/__tests__/proto-pollution.test.ts +54 -0
- package/src/theme-importers/auto-detect.ts +84 -0
- package/src/theme-importers/css-comments.ts +15 -0
- package/src/theme-importers/dtcg.ts +106 -0
- package/src/theme-importers/loose.ts +76 -0
- package/src/theme-importers/shadcn.ts +133 -0
- package/src/theme-importers/style-dictionary.ts +125 -0
- package/src/theme-importers/tailwind.ts +217 -0
- package/src/theme-literal-binding.test.ts +71 -0
- package/src/theme-literal-binding.ts +159 -0
- package/src/theme-motion.test.ts +115 -0
- package/src/theme-normalize-envelope.test.ts +43 -0
- package/src/theme-normalize-gradient.test.ts +135 -0
- package/src/theme-normalize.ts +661 -0
- package/src/theme-ramp.ts +187 -0
- package/src/theme-render-sanitize.test.ts +45 -0
- package/src/theme-render.test.ts +119 -0
- package/src/theme-render.ts +487 -0
- package/src/theme-shadow.test.ts +56 -0
- package/src/themes-errors.ts +199 -0
- package/src/themes.ts +842 -0
- package/src/version.ts +66 -0
- package/dist/translation.d.ts +0 -127
- package/dist/translation.d.ts.map +0 -1
- package/dist/translation.js +0 -208
- package/dist/translation.js.map +0 -1
package/dist/subagents.d.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* verdict ({pass, issues[], suggestions[]})
|
|
16
16
|
* tree ({tree: [...], rationale})
|
|
17
17
|
* freeform ({text})
|
|
18
|
+
* rebuild ({pages[], contentNotes[], skipped[], summary})
|
|
18
19
|
* - parseSubagentResult — pulls JSON out of the subagent's final
|
|
19
20
|
* assistant message (handles ```json fences) and validates against
|
|
20
21
|
* the requested shape.
|
|
@@ -24,8 +25,41 @@ declare const expectedReturnShape: z.ZodEnum<{
|
|
|
24
25
|
verdict: "verdict";
|
|
25
26
|
tree: "tree";
|
|
26
27
|
freeform: "freeform";
|
|
28
|
+
rebuild: "rebuild";
|
|
27
29
|
}>;
|
|
28
30
|
export type ExpectedReturnShape = z.infer<typeof expectedReturnShape>;
|
|
31
|
+
/**
|
|
32
|
+
* Run #8 R2a — the SINGLE source of truth for the return-shape enum.
|
|
33
|
+
*
|
|
34
|
+
* The spawn tools' hand-written provider `inputSchema` (JSON Schema) must
|
|
35
|
+
* carry the same enum values as this Zod schema; in run #8 the live
|
|
36
|
+
* validator rejected `"rebuild"` because the runtime resolved a stale
|
|
37
|
+
* pre-#266 build of this module while the provider schema advertised the
|
|
38
|
+
* new value (issue #251 drift class, resolution flavour). Tool files
|
|
39
|
+
* derive their JSON-Schema enums from this array instead of re-typing the
|
|
40
|
+
* literals, and a unit test asserts the tool schema accepts every shape
|
|
41
|
+
* this parser knows.
|
|
42
|
+
*/
|
|
43
|
+
export declare const EXPECTED_RETURN_SHAPES: readonly ExpectedReturnShape[];
|
|
44
|
+
/**
|
|
45
|
+
* issue #306 — model tier a subagent runs at. `inherit` (the default) is
|
|
46
|
+
* today's behaviour: the child reuses the parent chat's provider+model.
|
|
47
|
+
* `mid` / `small` route the child onto a cheaper model the Owner mapped
|
|
48
|
+
* in the active provider's config (`ai_providers.config.modelTiers`).
|
|
49
|
+
* The tier VOCABULARY is deliberately abstract — tool results and
|
|
50
|
+
* editor-facing text never name the underlying model (CLAUDE.md §2:
|
|
51
|
+
* provider brand never surfaces in the editor chat UI); concrete model
|
|
52
|
+
* ids appear only on Owner surfaces (security panel, cost dashboard).
|
|
53
|
+
*/
|
|
54
|
+
export declare const subagentModelTier: z.ZodEnum<{
|
|
55
|
+
small: "small";
|
|
56
|
+
inherit: "inherit";
|
|
57
|
+
mid: "mid";
|
|
58
|
+
}>;
|
|
59
|
+
export type SubagentModelTier = z.infer<typeof subagentModelTier>;
|
|
60
|
+
/** Single source of truth for the tier enum (same #251 drift-guard pattern
|
|
61
|
+
* as EXPECTED_RETURN_SHAPES — tool JSON schemas derive from this array). */
|
|
62
|
+
export declare const SUBAGENT_MODEL_TIERS: readonly SubagentModelTier[];
|
|
29
63
|
/**
|
|
30
64
|
* One subagent spec. The parent supplies role + task + optional
|
|
31
65
|
* narrowing. The handler creates the ephemeral chat session, appends
|
|
@@ -41,9 +75,15 @@ export declare const subagentSpec: z.ZodObject<{
|
|
|
41
75
|
verdict: "verdict";
|
|
42
76
|
tree: "tree";
|
|
43
77
|
freeform: "freeform";
|
|
78
|
+
rebuild: "rebuild";
|
|
44
79
|
}>>;
|
|
45
|
-
maxCostMicrocents: z.
|
|
80
|
+
maxCostMicrocents: z.ZodOptional<z.ZodNumber>;
|
|
46
81
|
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
82
|
+
tier: z.ZodDefault<z.ZodEnum<{
|
|
83
|
+
small: "small";
|
|
84
|
+
inherit: "inherit";
|
|
85
|
+
mid: "mid";
|
|
86
|
+
}>>;
|
|
47
87
|
activePageId: z.ZodOptional<z.ZodString>;
|
|
48
88
|
}, z.core.$strict>;
|
|
49
89
|
export type SubagentSpec = z.infer<typeof subagentSpec>;
|
|
@@ -55,9 +95,15 @@ export declare const spawnSubagentToolInput: z.ZodObject<{
|
|
|
55
95
|
verdict: "verdict";
|
|
56
96
|
tree: "tree";
|
|
57
97
|
freeform: "freeform";
|
|
98
|
+
rebuild: "rebuild";
|
|
58
99
|
}>>;
|
|
59
|
-
maxCostMicrocents: z.
|
|
100
|
+
maxCostMicrocents: z.ZodOptional<z.ZodNumber>;
|
|
60
101
|
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
102
|
+
tier: z.ZodDefault<z.ZodEnum<{
|
|
103
|
+
small: "small";
|
|
104
|
+
inherit: "inherit";
|
|
105
|
+
mid: "mid";
|
|
106
|
+
}>>;
|
|
61
107
|
activePageId: z.ZodOptional<z.ZodString>;
|
|
62
108
|
}, z.core.$strict>;
|
|
63
109
|
export type SpawnSubagentToolInput = SubagentSpec;
|
|
@@ -70,9 +116,15 @@ export declare const spawnSubagentsToolInput: z.ZodObject<{
|
|
|
70
116
|
verdict: "verdict";
|
|
71
117
|
tree: "tree";
|
|
72
118
|
freeform: "freeform";
|
|
119
|
+
rebuild: "rebuild";
|
|
73
120
|
}>>;
|
|
74
|
-
maxCostMicrocents: z.
|
|
121
|
+
maxCostMicrocents: z.ZodOptional<z.ZodNumber>;
|
|
75
122
|
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
123
|
+
tier: z.ZodDefault<z.ZodEnum<{
|
|
124
|
+
small: "small";
|
|
125
|
+
inherit: "inherit";
|
|
126
|
+
mid: "mid";
|
|
127
|
+
}>>;
|
|
76
128
|
activePageId: z.ZodOptional<z.ZodString>;
|
|
77
129
|
}, z.core.$strict>>;
|
|
78
130
|
}, z.core.$strict>;
|
|
@@ -92,6 +144,35 @@ export declare const freeformReturnShape: z.ZodObject<{
|
|
|
92
144
|
text: z.ZodString;
|
|
93
145
|
}, z.core.$strict>;
|
|
94
146
|
export type FreeformReturn = z.infer<typeof freeformReturnShape>;
|
|
147
|
+
/**
|
|
148
|
+
* issue #264 — compact per-page rebuild summary for migration fan-out
|
|
149
|
+
* subagents. The orchestrator chat's context grows by THIS shape only
|
|
150
|
+
* (never by the subagent's full transcript), so it is deliberately
|
|
151
|
+
* bounded: per-page status + short notes, deliberate omissions with a
|
|
152
|
+
* reason, and a one-paragraph summary. `pageId`/`slug` are both
|
|
153
|
+
* optional because a subagent that failed before resolving a page can
|
|
154
|
+
* still report the slug it was briefed with (or vice versa).
|
|
155
|
+
*/
|
|
156
|
+
export declare const rebuildReturnShape: z.ZodObject<{
|
|
157
|
+
pages: z.ZodArray<z.ZodObject<{
|
|
158
|
+
pageId: z.ZodOptional<z.ZodString>;
|
|
159
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
160
|
+
status: z.ZodEnum<{
|
|
161
|
+
rebuilt: "rebuilt";
|
|
162
|
+
skipped: "skipped";
|
|
163
|
+
failed: "failed";
|
|
164
|
+
needs_escalation: "needs_escalation";
|
|
165
|
+
}>;
|
|
166
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
167
|
+
}, z.core.$strict>>;
|
|
168
|
+
contentNotes: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
169
|
+
skipped: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
170
|
+
item: z.ZodString;
|
|
171
|
+
reason: z.ZodString;
|
|
172
|
+
}, z.core.$strict>>>;
|
|
173
|
+
summary: z.ZodDefault<z.ZodString>;
|
|
174
|
+
}, z.core.$strict>;
|
|
175
|
+
export type RebuildReturn = z.infer<typeof rebuildReturnShape>;
|
|
95
176
|
export type ParseSuccess = {
|
|
96
177
|
ok: true;
|
|
97
178
|
shape: "verdict";
|
|
@@ -104,11 +185,28 @@ export type ParseSuccess = {
|
|
|
104
185
|
ok: true;
|
|
105
186
|
shape: "freeform";
|
|
106
187
|
value: FreeformReturn;
|
|
188
|
+
} | {
|
|
189
|
+
ok: true;
|
|
190
|
+
shape: "rebuild";
|
|
191
|
+
value: RebuildReturn;
|
|
107
192
|
};
|
|
108
193
|
export type ParseResult = ParseSuccess | {
|
|
109
194
|
ok: false;
|
|
110
195
|
error: string;
|
|
111
196
|
};
|
|
197
|
+
/**
|
|
198
|
+
* Run #10 D2 — validate an ALREADY-PARSED value against the requested
|
|
199
|
+
* return shape. This is the structured half of the result channel: the
|
|
200
|
+
* `submit_result` tool hands the payload straight from the tool-call
|
|
201
|
+
* arguments (already JSON — no fence-stripping, no brace-balancing),
|
|
202
|
+
* so the "response is not valid JSON" failure class cannot occur.
|
|
203
|
+
* `parseSubagentResult` (final-text fallback) delegates here after its
|
|
204
|
+
* JSON extraction.
|
|
205
|
+
*
|
|
206
|
+
* For `freeform`, accepts `{text: "..."}` OR a bare string (wrapped as
|
|
207
|
+
* `{text}`) so the model can pass its prose directly.
|
|
208
|
+
*/
|
|
209
|
+
export declare function validateSubagentResultValue(value: unknown, shape: ExpectedReturnShape): ParseResult;
|
|
112
210
|
/**
|
|
113
211
|
* Pull JSON out of the subagent's final assistant text and validate
|
|
114
212
|
* against the requested shape. On schema mismatch, returns
|
|
@@ -117,6 +215,10 @@ export type ParseResult = ParseSuccess | {
|
|
|
117
215
|
* For `freeform`, accepts EITHER `{text: "..."}` JSON or raw text;
|
|
118
216
|
* raw text is wrapped as `{text: rawText}` so the caller always gets
|
|
119
217
|
* the same shape.
|
|
218
|
+
*
|
|
219
|
+
* Run #10 D2 — this is now the FALLBACK channel; the canonical path is
|
|
220
|
+
* the child calling `submit_result`, whose payload is validated by
|
|
221
|
+
* `validateSubagentResultValue` without any text extraction.
|
|
120
222
|
*/
|
|
121
223
|
export declare function parseSubagentResult(text: string, shape: ExpectedReturnShape): ParseResult;
|
|
122
224
|
export {};
|
package/dist/subagents.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subagents.d.ts","sourceRoot":"","sources":["../src/subagents.ts"],"names":[],"mappings":"AA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eform ({text})
|
|
19
|
+
* rebuild ({pages[], contentNotes[], skipped[], summary})
|
|
19
20
|
* - parseSubagentResult — pulls JSON out of the subagent's final
|
|
20
21
|
* assistant message (handles ```json fences) and validates against
|
|
21
22
|
* the requested shape.
|
|
22
23
|
*/
|
|
23
24
|
import { z } from "zod";
|
|
24
|
-
const expectedReturnShape = z.enum(["verdict", "tree", "freeform"]);
|
|
25
|
+
const expectedReturnShape = z.enum(["verdict", "tree", "freeform", "rebuild"]);
|
|
26
|
+
/**
|
|
27
|
+
* Run #8 R2a — the SINGLE source of truth for the return-shape enum.
|
|
28
|
+
*
|
|
29
|
+
* The spawn tools' hand-written provider `inputSchema` (JSON Schema) must
|
|
30
|
+
* carry the same enum values as this Zod schema; in run #8 the live
|
|
31
|
+
* validator rejected `"rebuild"` because the runtime resolved a stale
|
|
32
|
+
* pre-#266 build of this module while the provider schema advertised the
|
|
33
|
+
* new value (issue #251 drift class, resolution flavour). Tool files
|
|
34
|
+
* derive their JSON-Schema enums from this array instead of re-typing the
|
|
35
|
+
* literals, and a unit test asserts the tool schema accepts every shape
|
|
36
|
+
* this parser knows.
|
|
37
|
+
*/
|
|
38
|
+
export const EXPECTED_RETURN_SHAPES = expectedReturnShape.options;
|
|
39
|
+
/**
|
|
40
|
+
* issue #306 — model tier a subagent runs at. `inherit` (the default) is
|
|
41
|
+
* today's behaviour: the child reuses the parent chat's provider+model.
|
|
42
|
+
* `mid` / `small` route the child onto a cheaper model the Owner mapped
|
|
43
|
+
* in the active provider's config (`ai_providers.config.modelTiers`).
|
|
44
|
+
* The tier VOCABULARY is deliberately abstract — tool results and
|
|
45
|
+
* editor-facing text never name the underlying model (CLAUDE.md §2:
|
|
46
|
+
* provider brand never surfaces in the editor chat UI); concrete model
|
|
47
|
+
* ids appear only on Owner surfaces (security panel, cost dashboard).
|
|
48
|
+
*/
|
|
49
|
+
export const subagentModelTier = z.enum(["inherit", "mid", "small"]);
|
|
50
|
+
/** Single source of truth for the tier enum (same #251 drift-guard pattern
|
|
51
|
+
* as EXPECTED_RETURN_SHAPES — tool JSON schemas derive from this array). */
|
|
52
|
+
export const SUBAGENT_MODEL_TIERS = subagentModelTier.options;
|
|
25
53
|
/**
|
|
26
54
|
* One subagent spec. The parent supplies role + task + optional
|
|
27
55
|
* narrowing. The handler creates the ephemeral chat session, appends
|
|
@@ -44,10 +72,38 @@ export const subagentSpec = z
|
|
|
44
72
|
allowedToolNames: z.array(z.string().min(1).max(120)).optional(),
|
|
45
73
|
/** Zod-validated return shape. Defaults to `verdict`. */
|
|
46
74
|
expectedReturnShape: expectedReturnShape.default("verdict"),
|
|
47
|
-
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Per-spawn cost cap in microcents. OPTIONAL on purpose (issue #304):
|
|
77
|
+
* when omitted, the spawn orchestrator derives the cap from the armed
|
|
78
|
+
* run budget (#297) or falls back to SUBAGENT_CHILD_CAP_MICROCENTS.
|
|
79
|
+
* The old schema default (50M µ¢ = $0.50) sat BELOW the empirically
|
|
80
|
+
* observed 90–167M µ¢ per-child spend of migration page batches
|
|
81
|
+
* (runs #14/#15), so every child errored at the cap — a default here
|
|
82
|
+
* would make "AI omitted it" indistinguishable from "AI chose $0.50".
|
|
83
|
+
*/
|
|
84
|
+
maxCostMicrocents: z.number().int().nonnegative().optional(),
|
|
85
|
+
/**
|
|
86
|
+
* Per-spawn wall-clock timeout. Default 300s (5 min): the documented
|
|
87
|
+
* fan-out use cases are page BUILDS — a Genesis design draft (full page +
|
|
88
|
+
* image generation) and a migration per-type rebuild each legitimately run
|
|
89
|
+
* 2–4 min. The old 60s default aborted every build child mid-work (Genesis
|
|
90
|
+
* live-run 2026-07: all 3 draft children `timed_out` at ~60000ms, so the
|
|
91
|
+
* flow saved 0 drafts; the abort also skips the child's `ai_calls` write, so
|
|
92
|
+
* the roll-up read `$0.00` — the child WAS building, not idle). Quick
|
|
93
|
+
* reviewer children (qa/legal/menu/categorizer) finish well under this
|
|
94
|
+
* ceiling, so the higher default is harmless for them. The AI can still
|
|
95
|
+
* pass a smaller `timeoutMs` for a known-fast child.
|
|
96
|
+
*/
|
|
97
|
+
timeoutMs: z.number().int().min(1000).max(600_000).default(300_000),
|
|
98
|
+
/**
|
|
99
|
+
* issue #306 — model tier for this child. Default `inherit` keeps
|
|
100
|
+
* single-model behaviour byte-identical to pre-#306 (conservative
|
|
101
|
+
* default: nothing changes until a caller opts in per-spawn AND the
|
|
102
|
+
* Owner has mapped the tier). A requested-but-unmapped tier is a
|
|
103
|
+
* LOUD structured error at spawn time — never a silent downgrade to
|
|
104
|
+
* the parent's model (CLAUDE.md §2 no-fallbacks).
|
|
105
|
+
*/
|
|
106
|
+
tier: subagentModelTier.default("inherit"),
|
|
51
107
|
/**
|
|
52
108
|
* Optional active page id. When passed, the spawn handler routes
|
|
53
109
|
* it through to the runChatTurn invocation as `activePageId`,
|
|
@@ -61,7 +117,13 @@ export const subagentSpec = z
|
|
|
61
117
|
export const spawnSubagentToolInput = subagentSpec;
|
|
62
118
|
export const spawnSubagentsToolInput = z
|
|
63
119
|
.object({
|
|
64
|
-
|
|
120
|
+
// issue #304 — 32 matches the tool's advertised provider-schema
|
|
121
|
+
// maxItems (SUBAGENT_MAX_BATCH default). The previous max(8) silently
|
|
122
|
+
// rejected the very batches the provider schema invited (#251 drift
|
|
123
|
+
// class): a 14-page migration fan-out failed Zod validation at
|
|
124
|
+
// dispatch and fell back to serial building. SUBAGENT_MAX_BATCH must
|
|
125
|
+
// never be env-raised past this hard bound.
|
|
126
|
+
subagents: z.array(subagentSpec).min(1).max(32),
|
|
65
127
|
})
|
|
66
128
|
.strict();
|
|
67
129
|
// ---------------------------------------------------------------------
|
|
@@ -87,6 +149,66 @@ export const freeformReturnShape = z
|
|
|
87
149
|
text: z.string().min(1).max(40_000),
|
|
88
150
|
})
|
|
89
151
|
.strict();
|
|
152
|
+
/**
|
|
153
|
+
* issue #264 — compact per-page rebuild summary for migration fan-out
|
|
154
|
+
* subagents. The orchestrator chat's context grows by THIS shape only
|
|
155
|
+
* (never by the subagent's full transcript), so it is deliberately
|
|
156
|
+
* bounded: per-page status + short notes, deliberate omissions with a
|
|
157
|
+
* reason, and a one-paragraph summary. `pageId`/`slug` are both
|
|
158
|
+
* optional because a subagent that failed before resolving a page can
|
|
159
|
+
* still report the slug it was briefed with (or vice versa).
|
|
160
|
+
*/
|
|
161
|
+
export const rebuildReturnShape = z
|
|
162
|
+
.object({
|
|
163
|
+
pages: z
|
|
164
|
+
.array(z
|
|
165
|
+
.object({
|
|
166
|
+
pageId: z.string().uuid().optional(),
|
|
167
|
+
slug: z.string().min(1).max(500).optional(),
|
|
168
|
+
/**
|
|
169
|
+
* issue #306 — `needs_escalation`: the child detected the page
|
|
170
|
+
* needs something it is not equipped to BUILD (no matching
|
|
171
|
+
* module/pattern, a layout decision, unexpected source
|
|
172
|
+
* structure) and hands it back instead of improvising. The
|
|
173
|
+
* orchestrator re-dispatches exactly those pages one capability
|
|
174
|
+
* step up (see subagent-batch.ts escalation waves). The reason
|
|
175
|
+
* lives in `notes` and is REQUIRED for this status — a blind
|
|
176
|
+
* escalation would just re-run the same confusion at higher
|
|
177
|
+
* cost (enforced by the superRefine below).
|
|
178
|
+
*/
|
|
179
|
+
status: z.enum(["rebuilt", "skipped", "failed", "needs_escalation"]),
|
|
180
|
+
/** Content-completeness note: what was dropped/merged and why, or
|
|
181
|
+
* why skipped/failed — or, for `needs_escalation`, the REQUIRED
|
|
182
|
+
* reason the page needs a more capable pass. */
|
|
183
|
+
notes: z.string().max(2000).optional(),
|
|
184
|
+
})
|
|
185
|
+
.strict()
|
|
186
|
+
.superRefine((page, ctx) => {
|
|
187
|
+
if (page.status === "needs_escalation" && !page.notes?.trim()) {
|
|
188
|
+
ctx.addIssue({
|
|
189
|
+
code: "custom",
|
|
190
|
+
path: ["notes"],
|
|
191
|
+
message: 'status "needs_escalation" requires `notes` explaining WHAT new thing this page needs (missing pattern, layout decision, unexpected structure) — the escalated pass is briefed from it',
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}))
|
|
195
|
+
.min(1)
|
|
196
|
+
.max(100),
|
|
197
|
+
/** Cross-page content-completeness observations (e.g. "source pricing table had a footnote row I folded into the caption"). */
|
|
198
|
+
contentNotes: z.array(z.string().min(1).max(2000)).max(50).default([]),
|
|
199
|
+
/** Items deliberately left out — the orchestrator relays these verbatim. */
|
|
200
|
+
skipped: z
|
|
201
|
+
.array(z
|
|
202
|
+
.object({
|
|
203
|
+
item: z.string().min(1).max(500),
|
|
204
|
+
reason: z.string().min(1).max(1000),
|
|
205
|
+
})
|
|
206
|
+
.strict())
|
|
207
|
+
.max(100)
|
|
208
|
+
.default([]),
|
|
209
|
+
summary: z.string().max(4000).default(""),
|
|
210
|
+
})
|
|
211
|
+
.strict();
|
|
90
212
|
// ---------------------------------------------------------------------
|
|
91
213
|
// Result parser — handles `````json {…} ````` fences + raw JSON.
|
|
92
214
|
// ---------------------------------------------------------------------
|
|
@@ -136,6 +258,97 @@ function stripFences(text) {
|
|
|
136
258
|
}
|
|
137
259
|
return trimmed;
|
|
138
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* Run #10 D2 — validate an ALREADY-PARSED value against the requested
|
|
263
|
+
* return shape. This is the structured half of the result channel: the
|
|
264
|
+
* `submit_result` tool hands the payload straight from the tool-call
|
|
265
|
+
* arguments (already JSON — no fence-stripping, no brace-balancing),
|
|
266
|
+
* so the "response is not valid JSON" failure class cannot occur.
|
|
267
|
+
* `parseSubagentResult` (final-text fallback) delegates here after its
|
|
268
|
+
* JSON extraction.
|
|
269
|
+
*
|
|
270
|
+
* For `freeform`, accepts `{text: "..."}` OR a bare string (wrapped as
|
|
271
|
+
* `{text}`) so the model can pass its prose directly.
|
|
272
|
+
*/
|
|
273
|
+
export function validateSubagentResultValue(value, shape) {
|
|
274
|
+
// Defense-in-depth for the structured shapes: a provider can
|
|
275
|
+
// double-encode the payload so `value` arrives as a JSON string even
|
|
276
|
+
// after the `submit_result` inputSchema fix (and the final-text
|
|
277
|
+
// fallback path never passes through normalize-args at all). The
|
|
278
|
+
// structured shapes want an object/array, so decode a JSON-looking
|
|
279
|
+
// string before parsing. `freeform` legitimately wants a bare string,
|
|
280
|
+
// so it is left untouched.
|
|
281
|
+
let coerced = value;
|
|
282
|
+
if (shape !== "freeform" && typeof coerced === "string") {
|
|
283
|
+
const trimmed = coerced.trim();
|
|
284
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
285
|
+
try {
|
|
286
|
+
coerced = JSON.parse(trimmed);
|
|
287
|
+
}
|
|
288
|
+
catch {
|
|
289
|
+
// leave as-is; the shape parse below reports the real mismatch
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
// v0.2.67 — when the schema rejects, include the actual top-level
|
|
294
|
+
// keys the subagent returned so the parent AI can tell whether the
|
|
295
|
+
// subagent ignored the schema entirely (returned freeform text under
|
|
296
|
+
// a different shape) vs. got close but mistyped a single field.
|
|
297
|
+
const observedKeys = typeof coerced === "object" && coerced !== null && !Array.isArray(coerced)
|
|
298
|
+
? Object.keys(coerced)
|
|
299
|
+
: [];
|
|
300
|
+
const observedSummary = observedKeys.length > 0
|
|
301
|
+
? ` got keys: [${observedKeys.slice(0, 8).join(", ")}]`
|
|
302
|
+
: ` got: ${typeof coerced} (${Array.isArray(coerced) ? "array" : "scalar"})`;
|
|
303
|
+
const issueSummary = (issues) => issues
|
|
304
|
+
.slice(0, 3)
|
|
305
|
+
.map((i) => `${i.path.join(".") || "<root>"}: ${i.message}`)
|
|
306
|
+
.join("; ");
|
|
307
|
+
if (shape === "freeform") {
|
|
308
|
+
if (typeof value === "string") {
|
|
309
|
+
if (value.trim().length === 0)
|
|
310
|
+
return { ok: false, error: "subagent returned empty text" };
|
|
311
|
+
return { ok: true, shape: "freeform", value: { text: value.trim() } };
|
|
312
|
+
}
|
|
313
|
+
const validated = freeformReturnShape.safeParse(value);
|
|
314
|
+
if (!validated.success) {
|
|
315
|
+
return {
|
|
316
|
+
ok: false,
|
|
317
|
+
error: `freeform shape mismatch (expected {text: string} or a plain string):${observedSummary}; ${issueSummary(validated.error.issues)}`,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
return { ok: true, shape: "freeform", value: validated.data };
|
|
321
|
+
}
|
|
322
|
+
if (shape === "verdict") {
|
|
323
|
+
const validated = verdictReturnShape.safeParse(coerced);
|
|
324
|
+
if (!validated.success) {
|
|
325
|
+
return {
|
|
326
|
+
ok: false,
|
|
327
|
+
error: `verdict shape mismatch (expected {pass: boolean, issues: array, suggestions?: array}):${observedSummary}; ${issueSummary(validated.error.issues)}`,
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
return { ok: true, shape: "verdict", value: validated.data };
|
|
331
|
+
}
|
|
332
|
+
if (shape === "rebuild") {
|
|
333
|
+
const validated = rebuildReturnShape.safeParse(coerced);
|
|
334
|
+
if (!validated.success) {
|
|
335
|
+
return {
|
|
336
|
+
ok: false,
|
|
337
|
+
error: `rebuild shape mismatch (expected {pages: [{pageId?, slug?, status: "rebuilt"|"skipped"|"failed"|"needs_escalation", notes?}], contentNotes?: string[], skipped?: [{item, reason}], summary?: string}):${observedSummary}; ${issueSummary(validated.error.issues)}`,
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
return { ok: true, shape: "rebuild", value: validated.data };
|
|
341
|
+
}
|
|
342
|
+
// tree
|
|
343
|
+
const validated = treeReturnShape.safeParse(coerced);
|
|
344
|
+
if (!validated.success) {
|
|
345
|
+
return {
|
|
346
|
+
ok: false,
|
|
347
|
+
error: `tree shape mismatch (expected {tree: array, rationale?: string}):${observedSummary}; ${issueSummary(validated.error.issues)}`,
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
return { ok: true, shape: "tree", value: validated.data };
|
|
351
|
+
}
|
|
139
352
|
/**
|
|
140
353
|
* Pull JSON out of the subagent's final assistant text and validate
|
|
141
354
|
* against the requested shape. On schema mismatch, returns
|
|
@@ -144,6 +357,10 @@ function stripFences(text) {
|
|
|
144
357
|
* For `freeform`, accepts EITHER `{text: "..."}` JSON or raw text;
|
|
145
358
|
* raw text is wrapped as `{text: rawText}` so the caller always gets
|
|
146
359
|
* the same shape.
|
|
360
|
+
*
|
|
361
|
+
* Run #10 D2 — this is now the FALLBACK channel; the canonical path is
|
|
362
|
+
* the child calling `submit_result`, whose payload is validated by
|
|
363
|
+
* `validateSubagentResultValue` without any text extraction.
|
|
147
364
|
*/
|
|
148
365
|
export function parseSubagentResult(text, shape) {
|
|
149
366
|
if (shape === "freeform") {
|
|
@@ -173,40 +390,6 @@ export function parseSubagentResult(text, shape) {
|
|
|
173
390
|
error: `subagent response is not valid JSON: ${e.message}; first 200 chars: ${stripped.slice(0, 200)}`,
|
|
174
391
|
};
|
|
175
392
|
}
|
|
176
|
-
|
|
177
|
-
// keys the subagent returned so the parent AI can tell whether the
|
|
178
|
-
// subagent ignored the schema entirely (returned freeform text under
|
|
179
|
-
// a different shape) vs. got close but mistyped a single field.
|
|
180
|
-
const observedKeys = typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)
|
|
181
|
-
? Object.keys(parsed)
|
|
182
|
-
: [];
|
|
183
|
-
const observedSummary = observedKeys.length > 0
|
|
184
|
-
? ` got keys: [${observedKeys.slice(0, 8).join(", ")}]`
|
|
185
|
-
: ` got: ${typeof parsed} (${Array.isArray(parsed) ? "array" : "scalar"})`;
|
|
186
|
-
if (shape === "verdict") {
|
|
187
|
-
const validated = verdictReturnShape.safeParse(parsed);
|
|
188
|
-
if (!validated.success) {
|
|
189
|
-
return {
|
|
190
|
-
ok: false,
|
|
191
|
-
error: `verdict shape mismatch (expected {pass: boolean, issues: array, suggestions?: array}):${observedSummary}; ${validated.error.issues
|
|
192
|
-
.slice(0, 3)
|
|
193
|
-
.map((i) => `${i.path.join(".") || "<root>"}: ${i.message}`)
|
|
194
|
-
.join("; ")}`,
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
return { ok: true, shape: "verdict", value: validated.data };
|
|
198
|
-
}
|
|
199
|
-
// tree
|
|
200
|
-
const validated = treeReturnShape.safeParse(parsed);
|
|
201
|
-
if (!validated.success) {
|
|
202
|
-
return {
|
|
203
|
-
ok: false,
|
|
204
|
-
error: `tree shape mismatch (expected {tree: array, rationale?: string}):${observedSummary}; ${validated.error.issues
|
|
205
|
-
.slice(0, 3)
|
|
206
|
-
.map((i) => `${i.path.join(".") || "<root>"}: ${i.message}`)
|
|
207
|
-
.join("; ")}`,
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
return { ok: true, shape: "tree", value: validated.data };
|
|
393
|
+
return validateSubagentResultValue(parsed, shape);
|
|
211
394
|
}
|
|
212
395
|
//# sourceMappingURL=subagents.js.map
|
package/dist/subagents.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subagents.js","sourceRoot":"","sources":["../src/subagents.ts"],"names":[],"mappings":"AAAA,mCAAmC;AAEnC
|
|
1
|
+
{"version":3,"file":"subagents.js","sourceRoot":"","sources":["../src/subagents.ts"],"names":[],"mappings":"AAAA,mCAAmC;AAEnC;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,mBAAmB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC;AAG/E;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAmC,mBAAmB,CAAC,OAAO,CAAC;AAElG;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;AAErE;6EAC6E;AAC7E,MAAM,CAAC,MAAM,oBAAoB,GAAiC,iBAAiB,CAAC,OAAO,CAAC;AAE5F;;;;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,EAAE,CAAC;QACvF,CAAC;QAAC,MAAM,CAAC;YACP,kBAAkB;QACpB,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,8BAA8B,EAAE,CAAC;QAC1F,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC;IACvE,CAAC;IAED,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO;YACL,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,wCAAyC,CAAW,CAAC,OAAO,sBAAsB,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE;SAClH,CAAC;IACJ,CAAC;IACD,OAAO,2BAA2B,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { type ModuleFieldKind } from "./content.js";
|
|
2
|
+
/**
|
|
3
|
+
* Subset of `modules.fields[]` the engine cares about. The full
|
|
4
|
+
* schema lives in `content.ts`; the engine only needs `name`, `kind`,
|
|
5
|
+
* and the optional `default`. Importers pass the full row through.
|
|
6
|
+
*/
|
|
7
|
+
export interface TemplateField {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly kind: ModuleFieldKind;
|
|
10
|
+
readonly default?: unknown;
|
|
11
|
+
}
|
|
12
|
+
export interface RenderTemplateInput {
|
|
13
|
+
readonly html: string;
|
|
14
|
+
readonly fields: readonly TemplateField[];
|
|
15
|
+
/** Per-placement values from `content_instances.values`. */
|
|
16
|
+
readonly contentValues?: Readonly<Record<string, unknown>>;
|
|
17
|
+
/**
|
|
18
|
+
* Pre-rendered nested-module HTML keyed by:
|
|
19
|
+
* - `<name>` for single `{{>name}}` (module field kind)
|
|
20
|
+
* - `<name>__<index>` for each `{{#name}}` element (module-list)
|
|
21
|
+
* Compose path: empty map (no DB → loud HTML comments emit).
|
|
22
|
+
* Preview-render path: built from RenderResolver walks.
|
|
23
|
+
*/
|
|
24
|
+
readonly partials?: Readonly<Record<string, string>>;
|
|
25
|
+
/**
|
|
26
|
+
* v0.11.1 (issue #76) — active theme's resolved asset URLs. When
|
|
27
|
+
* present, `{{theme_logo_url}}` / `{{theme_logo_dark_url}}` /
|
|
28
|
+
* `{{theme_favicon_url}}` / `{{theme_social_share_url}}` substitute
|
|
29
|
+
* to the asset URL string. Unbound slots (null/absent) follow the
|
|
30
|
+
* existing loud-raw invariant (CLAUDE.md §2): the `{{…}}` stays in
|
|
31
|
+
* the output verbatim AND `theme-asset-unbound:<slot>` lands in
|
|
32
|
+
* `missingSlots`. Per-placement `contentValues` still take
|
|
33
|
+
* precedence so an operator can override on a single module.
|
|
34
|
+
*/
|
|
35
|
+
readonly themeAssets?: {
|
|
36
|
+
readonly logo: string | null;
|
|
37
|
+
readonly logoDark: string | null;
|
|
38
|
+
readonly favicon: string | null;
|
|
39
|
+
readonly socialShare: string | null;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export interface RenderTemplateOutput {
|
|
43
|
+
readonly html: string;
|
|
44
|
+
/** Structured failure channel — see file-level comment for the markers. */
|
|
45
|
+
readonly missingSlots: readonly string[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Render a `caelo:missing` HTML comment carrying a failure reason.
|
|
49
|
+
* The shape (`<!-- caelo:missing reason=<…> -->`) is part of the
|
|
50
|
+
* public failure-marker contract — the chat-runner diag pass reads
|
|
51
|
+
* the comment text out of rendered HTML, and the editor's missing-
|
|
52
|
+
* content surface highlights it for the operator. Exported so the
|
|
53
|
+
* DB-aware preview-render path (`packages/admin-core/src/ops/content/
|
|
54
|
+
* preview-render.ts`) emits the exact same shape without redeclaring.
|
|
55
|
+
*/
|
|
56
|
+
export declare function caeloMissingComment(reason: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* Render `html` against `contentValues` + `fields` + `partials`,
|
|
59
|
+
* returning the substituted HTML plus a structured `missingSlots`
|
|
60
|
+
* channel. Pure / sync / no IO.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* // AC #1 fixture (issue #71). Iterates a link-list field per element.
|
|
64
|
+
* renderTemplate({
|
|
65
|
+
* html: '<nav>{{#nav_items}}<a href="{{href}}">{{label}}</a>{{/nav_items}}</nav>',
|
|
66
|
+
* fields: [{ name: 'nav_items', kind: 'link-list' }],
|
|
67
|
+
* contentValues: {
|
|
68
|
+
* nav_items: [
|
|
69
|
+
* { label: 'Docs', href: '/docs' },
|
|
70
|
+
* { label: 'Blog', href: '/blog' },
|
|
71
|
+
* ],
|
|
72
|
+
* },
|
|
73
|
+
* });
|
|
74
|
+
* // → {
|
|
75
|
+
* // html: '<nav><a href="/docs">Docs</a><a href="/blog">Blog</a></nav>',
|
|
76
|
+
* // missingSlots: [],
|
|
77
|
+
* // }
|
|
78
|
+
*
|
|
79
|
+
* @see {@link TemplateField} for the field shape (name + kind + optional default).
|
|
80
|
+
* @see {@link ./content.js#MODULE_FIELD_KINDS} for the canonical kind union.
|
|
81
|
+
* @see {@link ./content.js#MODULE_FIELD_SECTION_KINDS} for the kinds the engine
|
|
82
|
+
* iterates via `{{#name}}` (text-list / link-list / module-list).
|
|
83
|
+
*/
|
|
84
|
+
export declare function renderTemplate(input: RenderTemplateInput): RenderTemplateOutput;
|
|
85
|
+
//# sourceMappingURL=template-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-engine.d.ts","sourceRoot":"","sources":["../src/template-engine.ts"],"names":[],"mappings":"AA8DA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