@mastra/json-render 0.2.0-alpha.0 → 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.cjs +0 -2
- package/dist/index.js +0 -2
- package/dist/state-BJ97_AE8.cjs +0 -2
- package/dist/state-Bl6NZlzO.js +0 -2
- package/dist/studio/index.cjs +0 -2
- package/dist/studio/index.js +0 -2
- package/package.json +9 -8
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/processor.d.ts.map +0 -1
- package/dist/state-BJ97_AE8.cjs.map +0 -1
- package/dist/state-Bl6NZlzO.js.map +0 -1
- package/dist/state.d.ts.map +0 -1
- package/dist/studio/catalog.d.ts.map +0 -1
- package/dist/studio/index.cjs.map +0 -1
- package/dist/studio/index.d.ts.map +0 -1
- package/dist/studio/index.js.map +0 -1
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
package/dist/state-BJ97_AE8.cjs
CHANGED
package/dist/state-Bl6NZlzO.js
CHANGED
package/dist/studio/index.cjs
CHANGED
package/dist/studio/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/json-render",
|
|
3
|
-
"version": "0.2.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Let Mastra agents compose json-render interfaces that stream to the client and stay in memory",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
|
-
"dist"
|
|
9
|
+
"dist",
|
|
10
|
+
"!dist/**/*.d.*ts.map"
|
|
10
11
|
],
|
|
11
12
|
"exports": {
|
|
12
13
|
".": {
|
|
@@ -75,12 +76,12 @@
|
|
|
75
76
|
"typescript": "^7.0.2",
|
|
76
77
|
"vitest": "5.1.0",
|
|
77
78
|
"zod": "^4.6.7",
|
|
78
|
-
"@internal/ai-sdk-v5": "0.0.
|
|
79
|
-
"@internal/
|
|
80
|
-
"@internal/
|
|
81
|
-
"@mastra/core": "1.86.0
|
|
82
|
-
"@mastra/memory": "1.41.3
|
|
83
|
-
"@mastra/react": "1.16.0
|
|
79
|
+
"@internal/ai-sdk-v5": "0.0.99",
|
|
80
|
+
"@internal/types-builder": "0.0.127",
|
|
81
|
+
"@internal/lint": "0.0.152",
|
|
82
|
+
"@mastra/core": "1.86.0",
|
|
83
|
+
"@mastra/memory": "1.41.3",
|
|
84
|
+
"@mastra/react": "1.16.0"
|
|
84
85
|
},
|
|
85
86
|
"scripts": {
|
|
86
87
|
"build:lib": "tsdown --silent --config tsdown.config.ts",
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["JSON_RENDER_STATE","parseSpecStreamLine","SPEC_DATA_PART_TYPE","REPROCESS_PART_KEY","diffToPatches","validateSpec","formatSpecIssues","resolveElementProps","resolveRepeatStatePath","getByPath","resolveRepeatItemStatePath"],"sources":["../src/processor.ts"],"sourcesContent":["import {\n SPEC_DATA_PART_TYPE,\n applySpecPatch,\n diffToPatches,\n formatSpecIssues,\n getByPath,\n parseSpecStreamLine,\n resolveElementProps,\n resolveRepeatItemStatePath,\n resolveRepeatStatePath,\n validateSpec,\n} from '@json-render/core';\nimport type { Catalog, PropResolutionContext, Spec, SpecDataPart } from '@json-render/core';\nimport type { MastraDBMessage } from '@mastra/core/agent';\nimport { REPROCESS_PART_KEY } from '@mastra/core/processors';\nimport type {\n ProcessLLMRequestArgs,\n ProcessLLMRequestResult,\n ProcessOutputStepArgs,\n ProcessOutputStreamArgs,\n Processor,\n ProcessorContext,\n} from '@mastra/core/processors';\nimport type { ChunkType } from '@mastra/core/stream';\nimport type { z } from 'zod';\nimport { JSON_RENDER_STATE } from './state';\n\nconst FENCE_OPEN = '```spec';\nconst FENCE_CLOSE = '```';\n/** Where a patch can write in a spec. Outside a ```spec block, only patches here are taken as interface edits. */\nconst SPEC_PATH = /^\\/(root|elements|state)(\\/|$)/;\n\nexport interface JsonRenderProcessorOptions {\n /** The catalog the model composes interfaces from. */\n catalog: Catalog;\n}\n\n/** An open code block: its fence (three or more backticks or tildes), and whether it is a ```spec block. */\ninterface Fence {\n marker: string;\n spec: boolean;\n}\n\n/** Where the text stream is: lines that may be a patch or a fence are held until they end. */\ninterface Split {\n line: string;\n holding: boolean;\n /** Whether the line has prose before this point, so a fence or patch can no longer start it. */\n midLine: boolean;\n /** Columns of whitespace the line starts with: from four, Markdown reads it as indented code, not a fence or patch. */\n indent: number;\n /** The code block the stream is in: a ```spec block, or any other, whose lines stay prose. */\n fence?: Fence;\n /** Whether the open fence has had its first patch, which decides if it starts a new spec or edits the last one. */\n started: boolean;\n}\n\n/** The interface the current message has streamed so far, and the patches held back from it. */\ninterface Live {\n spec?: Spec;\n rejected: string[];\n}\n\n/** A part that empties an interface the client has already rendered. */\nconst CLEARED: SpecDataPart = { type: 'flat', spec: { root: '', elements: {} } };\n\n/** The code block a line opens, as CommonMark reads it. */\nfunction fenceOpenedBy(line: string): Fence | undefined {\n const [, marker, info] = /^(`{3,}|~{3,})(.*)$/.exec(line) ?? [];\n if (!marker || (marker.startsWith('`') && info!.includes('`'))) return;\n return { marker, spec: info!.trim().split(/\\s/)[0] === 'spec' };\n}\n\n/** Whether a line closes a code block: the fence's character, at least as many times, and nothing else. */\nfunction closes(fence: Fence, line: string) {\n const [, marker] = /^(`+|~+)$/.exec(line) ?? [];\n return !!marker && marker[0] === fence.marker[0] && marker.length >= fence.marker.length;\n}\n\n/**\n * Whether a line held back may still turn out to be a code fence or a patch\n * (`{\"op\": …}`). Lines that cannot are released as prose right away, so\n * only a reply cut off inside a patch line ends with text held back.\n */\nfunction couldOpenSpecLine(line: string) {\n if (line.startsWith('`') || line.startsWith('~')) {\n const fence = line[0]!.repeat(3);\n return fence.startsWith(line) || line.startsWith(fence);\n }\n return /^\\{\\s*(\"|$)/.test(line);\n}\n\nfunction uiStateIn(requestContext: ProcessorContext['requestContext']) {\n return requestContext?.get(JSON_RENDER_STATE) as Spec['state'];\n}\n\n/** The spec the latest message with one builds, which a block not starting at `/root` edits. */\nfunction latestSpec(messages: ReadonlyArray<MastraDBMessage>): Spec | undefined {\n for (let i = messages.length - 1; i >= 0; i--) {\n const spec = specOf(messages[i]!.content.parts ?? []);\n if (spec) return spec;\n }\n}\n\n/**\n * Turns the ```spec blocks a model writes (json-render's text format) into\n * `data-spec` parts, so the interface streams to the client and is saved with\n * the message while the text keeps only the prose.\n *\n * A block that does not start by setting `/root` edits the latest interface in\n * the thread: the reply saves that spec first, then the patches, so every\n * message rebuilds its own interface and earlier ones stay as they were.\n */\nexport class JsonRenderProcessor implements Processor<'json-render'> {\n readonly id = 'json-render';\n readonly name = 'json-render';\n\n constructor(readonly options: JsonRenderProcessorOptions) {}\n\n /**\n * Shows the model the latest interface it wrote, which Mastra leaves out of the\n * prompt with every `data-*` part: the ```spec block goes back into the reply\n * that wrote it, as the spec is now, holding the state the user set in it.\n * Only this call's prompt changes, not the thread.\n */\n async processLLMRequest({\n prompt,\n messageList,\n requestContext,\n }: ProcessLLMRequestArgs): Promise<ProcessLLMRequestResult> {\n const messages = messageList?.get.all.db() ?? [];\n const reply = messages.findLast(message => specOf(message.content.parts ?? []));\n if (!reply) return;\n const spec = specOf(reply.content.parts)!;\n const uiState = uiStateIn(requestContext);\n const text = specBlock(uiState ? { ...spec, state: uiState } : spec);\n\n // The prompt does not say which message each one comes from, but its parts keep the time they were written.\n // Parts can share a millisecond with the next user message, so only the model's own messages are matched.\n const written = new Set(reply.content.parts.map(part => (part as { createdAt?: number }).createdAt));\n const wrote = (message: (typeof prompt)[number] | undefined) =>\n !!message && message.role !== 'user' && writtenAt(message).some(createdAt => written.has(createdAt));\n let at = prompt.findIndex(wrote);\n if (at < 0) {\n // A reply with no text or tool calls has no message in the prompt. Memory keeps messages in the order they were\n // saved, so the block goes before the user message that followed it, counted from the end.\n const later = messages.slice(messages.indexOf(reply) + 1).filter(message => message.role === 'user').length;\n const users = prompt.flatMap((message, index) => (message.role === 'user' ? [index] : []));\n const after = later > 0 ? users.at(-later) : undefined;\n if (after === undefined) return;\n return { prompt: prompt.toSpliced(after, 0, { role: 'assistant', content: [{ type: 'text', text }] }) };\n }\n // A reply that calls tools spans several prompt messages; the block goes after its last one.\n while (wrote(prompt[at + 1])) at++;\n const message = prompt[at]!;\n if (message.role === 'assistant' && !message.content.some(part => part.type === 'tool-call')) {\n const prose = message.content.findLast(part => part.type === 'text')?.text ?? '';\n const block = { type: 'text' as const, text: prose && !prose.endsWith('\\n') ? `\\n${text}` : text };\n return { prompt: prompt.with(at, { ...message, content: [...message.content, block] }) };\n }\n return { prompt: prompt.toSpliced(at + 1, 0, { role: 'assistant', content: [{ type: 'text', text }] }) };\n }\n\n async processOutputStream({\n part,\n state,\n writer,\n messageList,\n requestContext,\n }: ProcessOutputStreamArgs): Promise<ChunkType | null> {\n if (part.type !== 'text-delta' && part.type !== 'text-end') return part;\n const split = ((state.split as Split | undefined) ??= {\n line: '',\n holding: false,\n midLine: false,\n indent: 0,\n started: false,\n });\n const live = ((state.live as Live | undefined) ??= { rejected: [] });\n const parts: SpecDataPart[] = [];\n let text = '';\n\n /** `last`: the text block ended on this line, so no newline follows it. */\n const endLine = (last = false) => {\n const line = split.line;\n const trimmed = line.trim();\n split.line = '';\n split.holding = false;\n const keep = () => void (text += last ? line : `${line}\\n`);\n const fence = split.fence;\n if (fence && closes(fence, trimmed)) {\n split.fence = undefined;\n return fence.spec ? undefined : keep();\n }\n if (fence && !fence.spec) return keep();\n const opened = !fence && fenceOpenedBy(trimmed);\n if (opened) {\n split.fence = opened;\n split.started = false;\n return opened.spec ? undefined : keep();\n }\n const parsed = parseSpecStreamLine(trimmed);\n // The edit prompt asks for the patch lines alone, so they count outside a block too, when they write to a spec.\n const patch = parsed && (fence || SPEC_PATH.test(parsed.path)) ? parsed : null;\n if (!patch) return void (!fence && keep());\n if (!split.started) {\n split.started = true;\n const latest = patch.path !== '/root' && messageList && latestSpec(messageList.get.all.db());\n const uiState = uiStateIn(requestContext);\n const edited = latest && (uiState ? { ...latest, state: uiState } : latest);\n if (edited) {\n live.spec = structuredClone(edited);\n parts.push({ type: 'flat', spec: edited });\n }\n }\n // The client applies each patch as it arrives, so one that cannot apply is held back and sent to the model instead.\n try {\n applyPatch((live.spec ??= { root: '', elements: {} }), patch);\n parts.push({ type: 'patch', patch });\n } catch (error) {\n live.rejected.push((error as Error).message);\n }\n };\n\n if (part.type === 'text-end') {\n if (split.holding) endLine(true);\n state.split = undefined;\n } else {\n for (const char of part.payload.text) {\n const inSpec = !!split.fence?.spec;\n if (char === '\\n') {\n if (split.holding) endLine();\n else if (!inSpec) text += char;\n split.midLine = false;\n split.indent = 0;\n } else if (split.holding) {\n split.line += char;\n if (!inSpec && !couldOpenSpecLine(split.line)) {\n text += split.line;\n split.line = '';\n split.holding = false;\n split.midLine = true;\n }\n } else if (inSpec || (!split.midLine && split.indent < 4 && (char === '{' || char === '`' || char === '~'))) {\n split.holding = true;\n split.line = char;\n } else {\n text += char;\n if (!/\\s/.test(char)) split.midLine = true;\n else if (!split.midLine) split.indent += char === '\\t' ? 4 : 1;\n }\n }\n }\n\n for (const data of parts) await writer?.custom({ type: SPEC_DATA_PART_TYPE, data });\n if (part.type !== 'text-end') return text ? { ...part, payload: { ...part.payload, text } } : null;\n if (!text) return part;\n // Text held to the end of the block goes out before the block closes. Only one\n // part can be returned, so the runner sends the text-end after it.\n state[REPROCESS_PART_KEY] = part;\n return { type: 'text-delta', runId: part.runId, from: part.from, payload: { id: part.payload.id, text } };\n }\n\n /** Sends a reply whose interface cannot render back to the model, with what is wrong. */\n async processOutputStep({\n messages,\n abort,\n state,\n writer,\n }: ProcessOutputStepArgs): Promise<ProcessOutputStepArgs['messages']> {\n const live = state.live as Live | undefined;\n const rejected = live?.rejected.splice(0) ?? [];\n const reply = messages.at(-1);\n if (reply?.role !== 'assistant') return messages;\n let problems = rejected.join('\\n') || undefined;\n try {\n const spec = buildSpec(reply.content.parts);\n problems ??= spec && problemsIn(spec, this.options.catalog);\n } catch (error) {\n problems ??= (error as Error).message;\n }\n if (problems) {\n // The retry writes a new message; this one stays on the client until it reloads, so its interface is cleared.\n // Transient: the rejected message is not saved, and nothing else should be.\n if (live?.spec) {\n live.spec = undefined;\n await writer?.custom({ type: SPEC_DATA_PART_TYPE, data: CLEARED, transient: true });\n }\n abort(\n `The interface in your \\`\\`\\`spec block cannot be shown. Write it again without these problems:\\n${problems}`,\n {\n retry: true,\n },\n );\n }\n return messages;\n }\n}\n\n/** The ```spec block json-render's prompt asks for, writing `spec` from nothing. */\nfunction specBlock({ root, state, elements }: Spec) {\n const patches = diffToPatches({ elements: {} }, { root, ...(state && { state }), elements });\n return [FENCE_OPEN, ...patches.map(patch => JSON.stringify(patch)), FENCE_CLOSE].join('\\n');\n}\n\n/** When the parts of a prompt message were written, as Mastra records it on each part. */\nfunction writtenAt(message: ProcessLLMRequestArgs['prompt'][number]): number[] {\n if (typeof message.content === 'string') return [];\n return message.content.flatMap(part => {\n const at = part.providerOptions?.mastra?.createdAt;\n return typeof at === 'number' ? [at] : [];\n });\n}\n\n/**\n * The spec a message's `data-spec` parts build, the way the client renders it,\n * leaving the parts as they are. Throws when a patch cannot be applied, naming it.\n */\nfunction buildSpec(parts: ReadonlyArray<{ type: string }>): Spec | undefined {\n let spec: Spec | undefined;\n for (const part of parts) {\n if (part.type !== SPEC_DATA_PART_TYPE) continue;\n const data = (part as unknown as { data: SpecDataPart }).data;\n if (data.type === 'flat') spec = structuredClone(data.spec);\n else if (data.type === 'patch') applyPatch((spec ??= { root: '', elements: {} }), data.patch);\n }\n return spec;\n}\n\n/**\n * Applies a copy of `patch` to `spec`: `applySpecPatch` inserts the values a\n * patch holds, so applying the patch itself would let later patches change it.\n * Throws when it cannot be applied, naming it.\n */\nfunction applyPatch(spec: Spec, patch: Extract<SpecDataPart, { type: 'patch' }>['patch']) {\n try {\n if (typeof patch.path !== 'string') throw new Error('its path is not a string');\n applySpecPatch(spec, structuredClone(patch));\n } catch (error) {\n throw new Error(`- ${JSON.stringify(patch)} cannot be applied: ${(error as Error).message}`);\n }\n}\n\n/** The spec a message's `data-spec` parts build, or none when they cannot build one. */\nfunction specOf(parts: ReadonlyArray<{ type: string }>): Spec | undefined {\n try {\n return buildSpec(parts);\n } catch {\n return undefined;\n }\n}\n\n/** What keeps a spec from rendering: broken structure, unknown components, or props a component does not take. */\nfunction problemsIn(spec: Spec, catalog: Catalog): string | undefined {\n const problems = validateSpec(spec).issues.filter(issue => issue.severity === 'error');\n const lines = problems.length ? [formatSpecIssues(problems)] : [];\n const components = (catalog.data as { components?: Record<string, { props: z.ZodType }> }).components ?? {};\n const stateModel = spec.state ?? {};\n const seen = new Set<string>();\n const report = (line: string) => {\n if (seen.has(line)) return;\n seen.add(line);\n lines.push(line);\n };\n\n // Walks the tree the way the renderer does, so props bound to `$item` are checked against each item they render for.\n const visit = (key: string, scope: Omit<PropResolutionContext, 'stateModel'>, path: ReadonlySet<string>) => {\n const element = spec.elements[key];\n if (!element || path.has(key)) return;\n const component = components[element.type];\n if (!component) report(`- \"${key}\" uses \"${element.type}\", which is not in the catalog`);\n else {\n const result = component.props.safeParse(resolveElementProps(element.props ?? {}, { stateModel, ...scope }));\n for (const issue of result.success ? [] : result.error.issues) {\n report(`- \"${key}\" (${element.type}) prop \"${issue.path.join('.')}\": ${issue.message}`);\n }\n }\n const inner = new Set(path).add(key);\n const children = [...(element.children ?? []), ...Object.values(element.slots ?? {}).flat()];\n if (!element.repeat) return children.forEach(child => visit(child, scope, inner));\n const statePath = resolveRepeatStatePath(element.repeat.statePath, scope.repeatBasePath);\n const items = statePath === undefined ? [] : getByPath(stateModel, statePath);\n if (!Array.isArray(items)) return;\n const keyField = element.repeat.key;\n if (keyField) {\n const keys = items.map((item, index) => String((item as Record<string, unknown> | null)?.[keyField] ?? index));\n const repeated = keys.find((itemKey, index) => keys.indexOf(itemKey) !== index);\n if (repeated !== undefined) {\n report(\n `- \"${key}\" repeats ${statePath} keyed by \"${keyField}\", but \"${repeated}\" appears more than once; each item needs its own key`,\n );\n }\n }\n items.forEach((repeatItem, repeatIndex) => {\n const itemScope = {\n repeatItem,\n repeatIndex,\n repeatBasePath: resolveRepeatItemStatePath(statePath!, repeatIndex),\n };\n children.forEach(child => visit(child, itemScope, inner));\n });\n };\n visit(spec.root, {}, new Set());\n return lines.length ? lines.join('\\n') : undefined;\n}\n"],"mappings":";;;;;AA2BA,MAAM,aAAa;AACnB,MAAM,cAAc;;AAEpB,MAAM,YAAY;;AAkClB,MAAM,UAAwB;CAAE,MAAM;CAAQ,MAAM;EAAE,MAAM;EAAI,UAAU,CAAC;CAAE;AAAE;;AAG/E,SAAS,cAAc,MAAiC;CACtD,MAAM,GAAG,QAAQ,QAAQ,sBAAsB,KAAK,IAAI,KAAK,CAAC;CAC9D,IAAI,CAAC,UAAW,OAAO,WAAW,GAAG,KAAK,KAAM,SAAS,GAAG,GAAI;CAChE,OAAO;EAAE;EAAQ,MAAM,KAAM,KAAK,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO;CAAO;AAChE;;AAGA,SAAS,OAAO,OAAc,MAAc;CAC1C,MAAM,GAAG,UAAU,YAAY,KAAK,IAAI,KAAK,CAAC;CAC9C,OAAO,CAAC,CAAC,UAAU,OAAO,OAAO,MAAM,OAAO,MAAM,OAAO,UAAU,MAAM,OAAO;AACpF;;;;;;AAOA,SAAS,kBAAkB,MAAc;CACvC,IAAI,KAAK,WAAW,GAAG,KAAK,KAAK,WAAW,GAAG,GAAG;EAChD,MAAM,QAAQ,KAAK,EAAE,CAAE,OAAO,CAAC;EAC/B,OAAO,MAAM,WAAW,IAAI,KAAK,KAAK,WAAW,KAAK;CACxD;CACA,OAAO,cAAc,KAAK,IAAI;AAChC;AAEA,SAAS,UAAU,gBAAoD;CACrE,OAAO,gBAAgB,IAAIA,cAAAA,iBAAiB;AA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@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,YAAY,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/processor.ts"],"sourcesContent":["import {\n SPEC_DATA_PART_TYPE,\n applySpecPatch,\n diffToPatches,\n formatSpecIssues,\n getByPath,\n parseSpecStreamLine,\n resolveElementProps,\n resolveRepeatItemStatePath,\n resolveRepeatStatePath,\n validateSpec,\n} from '@json-render/core';\nimport type { Catalog, PropResolutionContext, Spec, SpecDataPart } from '@json-render/core';\nimport type { MastraDBMessage } from '@mastra/core/agent';\nimport { REPROCESS_PART_KEY } from '@mastra/core/processors';\nimport type {\n ProcessLLMRequestArgs,\n ProcessLLMRequestResult,\n ProcessOutputStepArgs,\n ProcessOutputStreamArgs,\n Processor,\n ProcessorContext,\n} from '@mastra/core/processors';\nimport type { ChunkType } from '@mastra/core/stream';\nimport type { z } from 'zod';\nimport { JSON_RENDER_STATE } from './state';\n\nconst FENCE_OPEN = '```spec';\nconst FENCE_CLOSE = '```';\n/** Where a patch can write in a spec. Outside a ```spec block, only patches here are taken as interface edits. */\nconst SPEC_PATH = /^\\/(root|elements|state)(\\/|$)/;\n\nexport interface JsonRenderProcessorOptions {\n /** The catalog the model composes interfaces from. */\n catalog: Catalog;\n}\n\n/** An open code block: its fence (three or more backticks or tildes), and whether it is a ```spec block. */\ninterface Fence {\n marker: string;\n spec: boolean;\n}\n\n/** Where the text stream is: lines that may be a patch or a fence are held until they end. */\ninterface Split {\n line: string;\n holding: boolean;\n /** Whether the line has prose before this point, so a fence or patch can no longer start it. */\n midLine: boolean;\n /** Columns of whitespace the line starts with: from four, Markdown reads it as indented code, not a fence or patch. */\n indent: number;\n /** The code block the stream is in: a ```spec block, or any other, whose lines stay prose. */\n fence?: Fence;\n /** Whether the open fence has had its first patch, which decides if it starts a new spec or edits the last one. */\n started: boolean;\n}\n\n/** The interface the current message has streamed so far, and the patches held back from it. */\ninterface Live {\n spec?: Spec;\n rejected: string[];\n}\n\n/** A part that empties an interface the client has already rendered. */\nconst CLEARED: SpecDataPart = { type: 'flat', spec: { root: '', elements: {} } };\n\n/** The code block a line opens, as CommonMark reads it. */\nfunction fenceOpenedBy(line: string): Fence | undefined {\n const [, marker, info] = /^(`{3,}|~{3,})(.*)$/.exec(line) ?? [];\n if (!marker || (marker.startsWith('`') && info!.includes('`'))) return;\n return { marker, spec: info!.trim().split(/\\s/)[0] === 'spec' };\n}\n\n/** Whether a line closes a code block: the fence's character, at least as many times, and nothing else. */\nfunction closes(fence: Fence, line: string) {\n const [, marker] = /^(`+|~+)$/.exec(line) ?? [];\n return !!marker && marker[0] === fence.marker[0] && marker.length >= fence.marker.length;\n}\n\n/**\n * Whether a line held back may still turn out to be a code fence or a patch\n * (`{\"op\": …}`). Lines that cannot are released as prose right away, so\n * only a reply cut off inside a patch line ends with text held back.\n */\nfunction couldOpenSpecLine(line: string) {\n if (line.startsWith('`') || line.startsWith('~')) {\n const fence = line[0]!.repeat(3);\n return fence.startsWith(line) || line.startsWith(fence);\n }\n return /^\\{\\s*(\"|$)/.test(line);\n}\n\nfunction uiStateIn(requestContext: ProcessorContext['requestContext']) {\n return requestContext?.get(JSON_RENDER_STATE) as Spec['state'];\n}\n\n/** The spec the latest message with one builds, which a block not starting at `/root` edits. */\nfunction latestSpec(messages: ReadonlyArray<MastraDBMessage>): Spec | undefined {\n for (let i = messages.length - 1; i >= 0; i--) {\n const spec = specOf(messages[i]!.content.parts ?? []);\n if (spec) return spec;\n }\n}\n\n/**\n * Turns the ```spec blocks a model writes (json-render's text format) into\n * `data-spec` parts, so the interface streams to the client and is saved with\n * the message while the text keeps only the prose.\n *\n * A block that does not start by setting `/root` edits the latest interface in\n * the thread: the reply saves that spec first, then the patches, so every\n * message rebuilds its own interface and earlier ones stay as they were.\n */\nexport class JsonRenderProcessor implements Processor<'json-render'> {\n readonly id = 'json-render';\n readonly name = 'json-render';\n\n constructor(readonly options: JsonRenderProcessorOptions) {}\n\n /**\n * Shows the model the latest interface it wrote, which Mastra leaves out of the\n * prompt with every `data-*` part: the ```spec block goes back into the reply\n * that wrote it, as the spec is now, holding the state the user set in it.\n * Only this call's prompt changes, not the thread.\n */\n async processLLMRequest({\n prompt,\n messageList,\n requestContext,\n }: ProcessLLMRequestArgs): Promise<ProcessLLMRequestResult> {\n const messages = messageList?.get.all.db() ?? [];\n const reply = messages.findLast(message => specOf(message.content.parts ?? []));\n if (!reply) return;\n const spec = specOf(reply.content.parts)!;\n const uiState = uiStateIn(requestContext);\n const text = specBlock(uiState ? { ...spec, state: uiState } : spec);\n\n // The prompt does not say which message each one comes from, but its parts keep the time they were written.\n // Parts can share a millisecond with the next user message, so only the model's own messages are matched.\n const written = new Set(reply.content.parts.map(part => (part as { createdAt?: number }).createdAt));\n const wrote = (message: (typeof prompt)[number] | undefined) =>\n !!message && message.role !== 'user' && writtenAt(message).some(createdAt => written.has(createdAt));\n let at = prompt.findIndex(wrote);\n if (at < 0) {\n // A reply with no text or tool calls has no message in the prompt. Memory keeps messages in the order they were\n // saved, so the block goes before the user message that followed it, counted from the end.\n const later = messages.slice(messages.indexOf(reply) + 1).filter(message => message.role === 'user').length;\n const users = prompt.flatMap((message, index) => (message.role === 'user' ? [index] : []));\n const after = later > 0 ? users.at(-later) : undefined;\n if (after === undefined) return;\n return { prompt: prompt.toSpliced(after, 0, { role: 'assistant', content: [{ type: 'text', text }] }) };\n }\n // A reply that calls tools spans several prompt messages; the block goes after its last one.\n while (wrote(prompt[at + 1])) at++;\n const message = prompt[at]!;\n if (message.role === 'assistant' && !message.content.some(part => part.type === 'tool-call')) {\n const prose = message.content.findLast(part => part.type === 'text')?.text ?? '';\n const block = { type: 'text' as const, text: prose && !prose.endsWith('\\n') ? `\\n${text}` : text };\n return { prompt: prompt.with(at, { ...message, content: [...message.content, block] }) };\n }\n return { prompt: prompt.toSpliced(at + 1, 0, { role: 'assistant', content: [{ type: 'text', text }] }) };\n }\n\n async processOutputStream({\n part,\n state,\n writer,\n messageList,\n requestContext,\n }: ProcessOutputStreamArgs): Promise<ChunkType | null> {\n if (part.type !== 'text-delta' && part.type !== 'text-end') return part;\n const split = ((state.split as Split | undefined) ??= {\n line: '',\n holding: false,\n midLine: false,\n indent: 0,\n started: false,\n });\n const live = ((state.live as Live | undefined) ??= { rejected: [] });\n const parts: SpecDataPart[] = [];\n let text = '';\n\n /** `last`: the text block ended on this line, so no newline follows it. */\n const endLine = (last = false) => {\n const line = split.line;\n const trimmed = line.trim();\n split.line = '';\n split.holding = false;\n const keep = () => void (text += last ? line : `${line}\\n`);\n const fence = split.fence;\n if (fence && closes(fence, trimmed)) {\n split.fence = undefined;\n return fence.spec ? undefined : keep();\n }\n if (fence && !fence.spec) return keep();\n const opened = !fence && fenceOpenedBy(trimmed);\n if (opened) {\n split.fence = opened;\n split.started = false;\n return opened.spec ? undefined : keep();\n }\n const parsed = parseSpecStreamLine(trimmed);\n // The edit prompt asks for the patch lines alone, so they count outside a block too, when they write to a spec.\n const patch = parsed && (fence || SPEC_PATH.test(parsed.path)) ? parsed : null;\n if (!patch) return void (!fence && keep());\n if (!split.started) {\n split.started = true;\n const latest = patch.path !== '/root' && messageList && latestSpec(messageList.get.all.db());\n const uiState = uiStateIn(requestContext);\n const edited = latest && (uiState ? { ...latest, state: uiState } : latest);\n if (edited) {\n live.spec = structuredClone(edited);\n parts.push({ type: 'flat', spec: edited });\n }\n }\n // The client applies each patch as it arrives, so one that cannot apply is held back and sent to the model instead.\n try {\n applyPatch((live.spec ??= { root: '', elements: {} }), patch);\n parts.push({ type: 'patch', patch });\n } catch (error) {\n live.rejected.push((error as Error).message);\n }\n };\n\n if (part.type === 'text-end') {\n if (split.holding) endLine(true);\n state.split = undefined;\n } else {\n for (const char of part.payload.text) {\n const inSpec = !!split.fence?.spec;\n if (char === '\\n') {\n if (split.holding) endLine();\n else if (!inSpec) text += char;\n split.midLine = false;\n split.indent = 0;\n } else if (split.holding) {\n split.line += char;\n if (!inSpec && !couldOpenSpecLine(split.line)) {\n text += split.line;\n split.line = '';\n split.holding = false;\n split.midLine = true;\n }\n } else if (inSpec || (!split.midLine && split.indent < 4 && (char === '{' || char === '`' || char === '~'))) {\n split.holding = true;\n split.line = char;\n } else {\n text += char;\n if (!/\\s/.test(char)) split.midLine = true;\n else if (!split.midLine) split.indent += char === '\\t' ? 4 : 1;\n }\n }\n }\n\n for (const data of parts) await writer?.custom({ type: SPEC_DATA_PART_TYPE, data });\n if (part.type !== 'text-end') return text ? { ...part, payload: { ...part.payload, text } } : null;\n if (!text) return part;\n // Text held to the end of the block goes out before the block closes. Only one\n // part can be returned, so the runner sends the text-end after it.\n state[REPROCESS_PART_KEY] = part;\n return { type: 'text-delta', runId: part.runId, from: part.from, payload: { id: part.payload.id, text } };\n }\n\n /** Sends a reply whose interface cannot render back to the model, with what is wrong. */\n async processOutputStep({\n messages,\n abort,\n state,\n writer,\n }: ProcessOutputStepArgs): Promise<ProcessOutputStepArgs['messages']> {\n const live = state.live as Live | undefined;\n const rejected = live?.rejected.splice(0) ?? [];\n const reply = messages.at(-1);\n if (reply?.role !== 'assistant') return messages;\n let problems = rejected.join('\\n') || undefined;\n try {\n const spec = buildSpec(reply.content.parts);\n problems ??= spec && problemsIn(spec, this.options.catalog);\n } catch (error) {\n problems ??= (error as Error).message;\n }\n if (problems) {\n // The retry writes a new message; this one stays on the client until it reloads, so its interface is cleared.\n // Transient: the rejected message is not saved, and nothing else should be.\n if (live?.spec) {\n live.spec = undefined;\n await writer?.custom({ type: SPEC_DATA_PART_TYPE, data: CLEARED, transient: true });\n }\n abort(\n `The interface in your \\`\\`\\`spec block cannot be shown. Write it again without these problems:\\n${problems}`,\n {\n retry: true,\n },\n );\n }\n return messages;\n }\n}\n\n/** The ```spec block json-render's prompt asks for, writing `spec` from nothing. */\nfunction specBlock({ root, state, elements }: Spec) {\n const patches = diffToPatches({ elements: {} }, { root, ...(state && { state }), elements });\n return [FENCE_OPEN, ...patches.map(patch => JSON.stringify(patch)), FENCE_CLOSE].join('\\n');\n}\n\n/** When the parts of a prompt message were written, as Mastra records it on each part. */\nfunction writtenAt(message: ProcessLLMRequestArgs['prompt'][number]): number[] {\n if (typeof message.content === 'string') return [];\n return message.content.flatMap(part => {\n const at = part.providerOptions?.mastra?.createdAt;\n return typeof at === 'number' ? [at] : [];\n });\n}\n\n/**\n * The spec a message's `data-spec` parts build, the way the client renders it,\n * leaving the parts as they are. Throws when a patch cannot be applied, naming it.\n */\nfunction buildSpec(parts: ReadonlyArray<{ type: string }>): Spec | undefined {\n let spec: Spec | undefined;\n for (const part of parts) {\n if (part.type !== SPEC_DATA_PART_TYPE) continue;\n const data = (part as unknown as { data: SpecDataPart }).data;\n if (data.type === 'flat') spec = structuredClone(data.spec);\n else if (data.type === 'patch') applyPatch((spec ??= { root: '', elements: {} }), data.patch);\n }\n return spec;\n}\n\n/**\n * Applies a copy of `patch` to `spec`: `applySpecPatch` inserts the values a\n * patch holds, so applying the patch itself would let later patches change it.\n * Throws when it cannot be applied, naming it.\n */\nfunction applyPatch(spec: Spec, patch: Extract<SpecDataPart, { type: 'patch' }>['patch']) {\n try {\n if (typeof patch.path !== 'string') throw new Error('its path is not a string');\n applySpecPatch(spec, structuredClone(patch));\n } catch (error) {\n throw new Error(`- ${JSON.stringify(patch)} cannot be applied: ${(error as Error).message}`);\n }\n}\n\n/** The spec a message's `data-spec` parts build, or none when they cannot build one. */\nfunction specOf(parts: ReadonlyArray<{ type: string }>): Spec | undefined {\n try {\n return buildSpec(parts);\n } catch {\n return undefined;\n }\n}\n\n/** What keeps a spec from rendering: broken structure, unknown components, or props a component does not take. */\nfunction problemsIn(spec: Spec, catalog: Catalog): string | undefined {\n const problems = validateSpec(spec).issues.filter(issue => issue.severity === 'error');\n const lines = problems.length ? [formatSpecIssues(problems)] : [];\n const components = (catalog.data as { components?: Record<string, { props: z.ZodType }> }).components ?? {};\n const stateModel = spec.state ?? {};\n const seen = new Set<string>();\n const report = (line: string) => {\n if (seen.has(line)) return;\n seen.add(line);\n lines.push(line);\n };\n\n // Walks the tree the way the renderer does, so props bound to `$item` are checked against each item they render for.\n const visit = (key: string, scope: Omit<PropResolutionContext, 'stateModel'>, path: ReadonlySet<string>) => {\n const element = spec.elements[key];\n if (!element || path.has(key)) return;\n const component = components[element.type];\n if (!component) report(`- \"${key}\" uses \"${element.type}\", which is not in the catalog`);\n else {\n const result = component.props.safeParse(resolveElementProps(element.props ?? {}, { stateModel, ...scope }));\n for (const issue of result.success ? [] : result.error.issues) {\n report(`- \"${key}\" (${element.type}) prop \"${issue.path.join('.')}\": ${issue.message}`);\n }\n }\n const inner = new Set(path).add(key);\n const children = [...(element.children ?? []), ...Object.values(element.slots ?? {}).flat()];\n if (!element.repeat) return children.forEach(child => visit(child, scope, inner));\n const statePath = resolveRepeatStatePath(element.repeat.statePath, scope.repeatBasePath);\n const items = statePath === undefined ? [] : getByPath(stateModel, statePath);\n if (!Array.isArray(items)) return;\n const keyField = element.repeat.key;\n if (keyField) {\n const keys = items.map((item, index) => String((item as Record<string, unknown> | null)?.[keyField] ?? index));\n const repeated = keys.find((itemKey, index) => keys.indexOf(itemKey) !== index);\n if (repeated !== undefined) {\n report(\n `- \"${key}\" repeats ${statePath} keyed by \"${keyField}\", but \"${repeated}\" appears more than once; each item needs its own key`,\n );\n }\n }\n items.forEach((repeatItem, repeatIndex) => {\n const itemScope = {\n repeatItem,\n repeatIndex,\n repeatBasePath: resolveRepeatItemStatePath(statePath!, repeatIndex),\n };\n children.forEach(child => visit(child, itemScope, inner));\n });\n };\n visit(spec.root, {}, new Set());\n return lines.length ? lines.join('\\n') : undefined;\n}\n"],"mappings":";;;;AA2BA,MA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OAAO,EAAE,0BAA0B,EAAI;IAE5D;;;;;OAKG;IACG,iBAAiB,CAAC,EACtB,MAAM,EACN,WAAW,EACX,cAAc,GACf,EAAE,qBAAqB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAgC1D;IAEK,mBAAmB,CAAC,EACxB,IAAI,EACJ,KAAK,EACL,MAAM,EACN,WAAW,EACX,cAAc,GACf,EAAE,uBAAuB,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CA4FrD;IAED,yFAAyF;IACnF,iBAAiB,CAAC,EACtB,QAAQ,EACR,KAAK,EACL,KAAK,EACL,MAAM,GACP,EAAE,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CA2BpE;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"state-BJ97_AE8.cjs","names":[],"sources":["../src/state.ts"],"sourcesContent":["/** The `requestContext` key a client sends the state its interface holds under, so the model can see it. */\nexport const JSON_RENDER_STATE = 'jsonRender.state';\n"],"mappings":";;AACA,MAAa,oBAAoB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"state-Bl6NZlzO.js","names":[],"sources":["../src/state.ts"],"sourcesContent":["/** The `requestContext` key a client sends the state its interface holds under, so the model can see it. */\nexport const JSON_RENDER_STATE = 'jsonRender.state';\n"],"mappings":";;AACA,MAAa,oBAAoB"}
|
package/dist/state.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,eAAO,MAAM,iBAAiB,qBAAqB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/studio/catalog.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAEtB,KAAK;YACH,KAAK;;;;;;;;;;;;;;;;;YAKL,KAAK;YACL,WAAW;;QAEb,IAAI;YACF,KAAK;;;YACL,KAAK;YACL,WAAW;;QAEb,IAAI;YACF,KAAK;;;;YACL,KAAK;YACL,WAAW;;QAEb,OAAO;YACL,KAAK;;;;;;;;YACL,KAAK;YACL,WAAW;;QAEb,IAAI;YACF,KAAK;;;;;;;YACL,KAAK;YACL,WAAW;;QAEb,KAAK;YACH,KAAK;;;;;;;;;;YAIL,KAAK;YACL,WAAW;;QAEb,IAAI;YACF,KAAK;;;;;;;;;;YAML,KAAK;YACL,WAAW;;QAGb,KAAK;YACH,KAAK;;;;YAIL,KAAK;YACL,WAAW;;QAEb,IAAI;YACF,KAAK;;;;YACL,KAAK;YACL,WAAW;;QAEb,QAAQ;YACN,KAAK;;;;;YACL,KAAK;YACL,WAAW;;QAEb,MAAM;YACJ,KAAK;;;;;;;;;;;YAKL,KAAK;YACL,WAAW;;QAEb,SAAS;YACP,KAAK;YACL,KAAK;YACL,WAAW;;QAEb,MAAM;YACJ,KAAK;;;;;;;;YACL,KAAK;YACL,MAAM;YACN,WAAW;;QAGb,KAAK;YACH,KAAK;;;;;;;;;;YAML,KAAK;YACL,WAAW;;QAEb,MAAM;YACJ,KAAK;;;;;;;;;YAML,KAAK;YACL,WAAW;;QAEb,QAAQ;YACN,KAAK;;;;YACL,KAAK;YACL,WAAW;;;;QAIb,WAAW;YACT,MAAM;;;YACN,WAAW;;;EAIf,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["defineCatalog","schema","z"],"sources":["../../src/studio/catalog.ts"],"sourcesContent":["import { defineCatalog } from '@json-render/core';\nimport { schema } from '@json-render/react/schema';\nimport { z } from 'zod';\n\n/**\n * The components Mastra Studio renders in agent replies, drawn with its design system.\n * Give it to an agent's `JsonRenderProcessor` to let the agent compose interfaces in Studio chat.\n * `@json-render/react/schema` only describes the spec format; it does not load React.\n */\nexport const studioCatalog = defineCatalog(schema, {\n components: {\n Stack: {\n props: z.object({\n direction: z.enum(['vertical', 'horizontal']).optional(),\n gap: z.enum(['sm', 'md', 'lg']).optional(),\n align: z.enum(['start', 'center', 'end', 'stretch']).optional(),\n }),\n slots: ['default'],\n description: 'Lays children out in a column (default) or a wrapping row.',\n },\n Grid: {\n props: z.object({ columns: z.number().int().min(1).max(4) }),\n slots: ['default'],\n description: 'Grid of equal columns; collapses to one column on narrow screens. Use for Stat or Card groups.',\n },\n Card: {\n props: z.object({ title: z.string().optional(), description: z.string().optional() }),\n slots: ['default'],\n description: 'Surface grouping related content, with an optional title and description.',\n },\n Heading: {\n props: z.object({ text: z.string(), size: z.enum(['lg', 'md', 'sm']).optional() }),\n slots: [],\n description: 'Section heading.',\n },\n Text: {\n props: z.object({ text: z.string(), tone: z.enum(['default', 'muted']).optional() }),\n slots: [],\n description: 'A paragraph of plain text.',\n },\n Badge: {\n props: z.object({\n text: z.string(),\n variant: z.enum(['neutral', 'success', 'warning', 'destructive', 'info']).optional(),\n }),\n slots: [],\n description: 'Short status or category label, e.g. \"On track\" or \"Blocked\".',\n },\n Stat: {\n props: z.object({\n label: z.string(),\n value: z.string(),\n detail: z.string().optional(),\n trend: z.enum(['up', 'down', 'flat']).optional(),\n }),\n slots: [],\n description:\n \"A key figure with its label, e.g. a metric, price or score. `detail` is a short note like '+12% vs last week'.\",\n },\n Table: {\n props: z.object({\n columns: z.array(z.string()).min(1),\n rows: z.array(z.array(z.union([z.string(), z.number()]))),\n }),\n slots: [],\n description: 'Tabular data. Each row lists one cell per column, in column order.',\n },\n List: {\n props: z.object({ items: z.array(z.string()), ordered: z.boolean().optional() }),\n slots: [],\n description: 'Bulleted (or numbered when `ordered`) list of short items.',\n },\n Progress: {\n props: z.object({ label: z.string(), value: z.number().min(0).max(100), detail: z.string().optional() }),\n slots: [],\n description: 'Labeled progress bar; `value` is a percentage from 0 to 100.',\n },\n Notice: {\n props: z.object({\n text: z.string(),\n title: z.string().optional(),\n variant: z.enum(['info', 'success', 'warning', 'destructive', 'note']).optional(),\n }),\n slots: [],\n description: 'Callout that draws attention to a note, tip, warning or error.',\n },\n Separator: {\n props: z.object({}),\n slots: [],\n description: 'Horizontal divider between sections.',\n },\n Button: {\n props: z.object({ label: z.string(), variant: z.enum(['primary', 'default', 'ghost']).optional() }),\n slots: [],\n events: ['press'],\n description:\n \"Button. Bind its `press` event with `on`, e.g. to `sendMessage` to answer on the user's behalf, or to `setState`.\",\n },\n Input: {\n props: z.object({\n label: z.string(),\n value: z.string().optional(),\n placeholder: z.string().optional(),\n type: z.enum(['text', 'number', 'email']).optional(),\n }),\n slots: [],\n description: 'Labeled text field. Bind `value` to state with { \"$bindState\": \"/path\" } so its value can be read.',\n },\n Select: {\n props: z.object({\n label: z.string(),\n options: z.array(z.object({ label: z.string(), value: z.string() })).min(1),\n value: z.string().optional(),\n placeholder: z.string().optional(),\n }),\n slots: [],\n description: 'Labeled dropdown. Bind `value` to state with { \"$bindState\": \"/path\" }.',\n },\n Checkbox: {\n props: z.object({ label: z.string(), checked: z.boolean().optional() }),\n slots: [],\n description: 'Labeled checkbox. Bind `checked` to state with { \"$bindState\": \"/path\" }.',\n },\n },\n actions: {\n sendMessage: {\n params: z.object({ message: z.string().min(1) }),\n description:\n 'Sends `message` to you as the user\\'s next turn, e.g. when they pick an option or submit a form. Pass a field\\'s value with { \"$state\": \"/path\" }.',\n },\n },\n});\n\nexport type StudioCatalog = typeof studioCatalog;\n"],"mappings":";;;;;;;;;;;AASA,MAAa,iBAAA,GAAgBA,kBAAAA,cAAAA,CAAcC,0BAAAA,QAAQ;CACjD,YAAY;EACV,OAAO;GACL,OAAOC,IAAAA,EAAE,OAAO;IACd,WAAWA,IAAAA,EAAE,KAAK,CAAC,YAAY,YAAY,CAAC,CAAC,CAAC,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aAAa;EACf;CACF;CACA,SAAS,EACP,aAAa;EACX,QAAQA,IAAAA,EAAE,OAAO,EAAE,SAASA,IAAAA,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;EAC/C,aACE;CACJ,EACF;AACF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/studio/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/studio/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/studio/catalog.ts"],"sourcesContent":["import { defineCatalog } from '@json-render/core';\nimport { schema } from '@json-render/react/schema';\nimport { z } from 'zod';\n\n/**\n * The components Mastra Studio renders in agent replies, drawn with its design system.\n * Give it to an agent's `JsonRenderProcessor` to let the agent compose interfaces in Studio chat.\n * `@json-render/react/schema` only describes the spec format; it does not load React.\n */\nexport const studioCatalog = defineCatalog(schema, {\n components: {\n Stack: {\n props: z.object({\n direction: z.enum(['vertical', 'horizontal']).optional(),\n gap: z.enum(['sm', 'md', 'lg']).optional(),\n align: z.enum(['start', 'center', 'end', 'stretch']).optional(),\n }),\n slots: ['default'],\n description: 'Lays children out in a column (default) or a wrapping row.',\n },\n Grid: {\n props: z.object({ columns: z.number().int().min(1).max(4) }),\n slots: ['default'],\n description: 'Grid of equal columns; collapses to one column on narrow screens. Use for Stat or Card groups.',\n },\n Card: {\n props: z.object({ title: z.string().optional(), description: z.string().optional() }),\n slots: ['default'],\n description: 'Surface grouping related content, with an optional title and description.',\n },\n Heading: {\n props: z.object({ text: z.string(), size: z.enum(['lg', 'md', 'sm']).optional() }),\n slots: [],\n description: 'Section heading.',\n },\n Text: {\n props: z.object({ text: z.string(), tone: z.enum(['default', 'muted']).optional() }),\n slots: [],\n description: 'A paragraph of plain text.',\n },\n Badge: {\n props: z.object({\n text: z.string(),\n variant: z.enum(['neutral', 'success', 'warning', 'destructive', 'info']).optional(),\n }),\n slots: [],\n description: 'Short status or category label, e.g. \"On track\" or \"Blocked\".',\n },\n Stat: {\n props: z.object({\n label: z.string(),\n value: z.string(),\n detail: z.string().optional(),\n trend: z.enum(['up', 'down', 'flat']).optional(),\n }),\n slots: [],\n description:\n \"A key figure with its label, e.g. a metric, price or score. `detail` is a short note like '+12% vs last week'.\",\n },\n Table: {\n props: z.object({\n columns: z.array(z.string()).min(1),\n rows: z.array(z.array(z.union([z.string(), z.number()]))),\n }),\n slots: [],\n description: 'Tabular data. Each row lists one cell per column, in column order.',\n },\n List: {\n props: z.object({ items: z.array(z.string()), ordered: z.boolean().optional() }),\n slots: [],\n description: 'Bulleted (or numbered when `ordered`) list of short items.',\n },\n Progress: {\n props: z.object({ label: z.string(), value: z.number().min(0).max(100), detail: z.string().optional() }),\n slots: [],\n description: 'Labeled progress bar; `value` is a percentage from 0 to 100.',\n },\n Notice: {\n props: z.object({\n text: z.string(),\n title: z.string().optional(),\n variant: z.enum(['info', 'success', 'warning', 'destructive', 'note']).optional(),\n }),\n slots: [],\n description: 'Callout that draws attention to a note, tip, warning or error.',\n },\n Separator: {\n props: z.object({}),\n slots: [],\n description: 'Horizontal divider between sections.',\n },\n Button: {\n props: z.object({ label: z.string(), variant: z.enum(['primary', 'default', 'ghost']).optional() }),\n slots: [],\n events: ['press'],\n description:\n \"Button. Bind its `press` event with `on`, e.g. to `sendMessage` to answer on the user's behalf, or to `setState`.\",\n },\n Input: {\n props: z.object({\n label: z.string(),\n value: z.string().optional(),\n placeholder: z.string().optional(),\n type: z.enum(['text', 'number', 'email']).optional(),\n }),\n slots: [],\n description: 'Labeled text field. Bind `value` to state with { \"$bindState\": \"/path\" } so its value can be read.',\n },\n Select: {\n props: z.object({\n label: z.string(),\n options: z.array(z.object({ label: z.string(), value: z.string() })).min(1),\n value: z.string().optional(),\n placeholder: z.string().optional(),\n }),\n slots: [],\n description: 'Labeled dropdown. Bind `value` to state with { \"$bindState\": \"/path\" }.',\n },\n Checkbox: {\n props: z.object({ label: z.string(), checked: z.boolean().optional() }),\n slots: [],\n description: 'Labeled checkbox. Bind `checked` to state with { \"$bindState\": \"/path\" }.',\n },\n },\n actions: {\n sendMessage: {\n params: z.object({ message: z.string().min(1) }),\n description:\n 'Sends `message` to you as the user\\'s next turn, e.g. when they pick an option or submit a form. Pass a field\\'s value with { \"$state\": \"/path\" }.',\n },\n },\n});\n\nexport type StudioCatalog = typeof studioCatalog;\n"],"mappings":";;;;;;;;;;AASA,MAAa,gBAAgB,cAAc,QAAQ;CACjD,YAAY;EACV,OAAO;GACL,OAAO,EAAE,OAAO;IACd,WAAW,EAAE,KAAK,CAAC,YAAY,YAAY,CAAC,CAAC,CAAC,SAAS;IACvD,KAAK,EAAE,KAAK;KAAC;KAAM;KAAM;IAAI,CAAC,CAAC,CAAC,SAAS;IACzC,OAAO,EAAE,KAAK;KAAC;KAAS;KAAU;KAAO;IAAS,CAAC,CAAC,CAAC,SAAS;GAChE,CAAC;GACD,OAAO,CAAC,SAAS;GACjB,aAAa;EACf;EACA,MAAM;GACJ,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;GAC3D,OAAO,CAAC,SAAS;GACjB,aAAa;EACf;EACA,MAAM;GACJ,OAAO,EAAE,OAAO;IAAE,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS;IAAG,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;GAAE,CAAC;GACpF,OAAO,CAAC,SAAS;GACjB,aAAa;EACf;EACA,SAAS;GACP,OAAO,EAAE,OAAO;IAAE,MAAM,EAAE,OAAO;IAAG,MAAM,EAAE,KAAK;KAAC;KAAM;KAA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