@klarkxy/dsh-deep-view 0.0.0-stage → 0.1.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["fail","isRecord","isRecord"],"sources":["../../dsh-plugin-kit/src/host-rpc.ts","../src/core/formula.js","../src/core/views.js","../src/answer-text.ts","../src/index.ts"],"sourcesContent":["import type { IncomingMessage, ServerResponse } from 'node:http'\nimport type { RpcResult } from './contracts.ts'\n\nexport interface HostRpcContext {\n webServer: { register(route: { kind: 'prefix'; path: string; handler(req: IncomingMessage, res: ServerResponse): void | Promise<void> }): () => void }\n connection: { requestRejection?: (request: IncomingMessage) => number | undefined }\n}\n\ntype Rejection = { status: number; body?: string }\n\nexport interface HostRpcTransportOptions {\n maxBodyBytes?: number\n isEndpoint?: (endpoint: string) => boolean\n caseInsensitiveContentType?: boolean\n emptyBodyAsNull?: boolean\n beforeBody?: (request: IncomingMessage, endpoint: string) => Rejection | undefined\n errorBody?: (status: number, error?: unknown) => string | undefined\n}\n\nexport interface HostRpcOptions extends HostRpcTransportOptions {\n requirePayload?: boolean\n}\n\n/** The shared authenticated HTTP boundary. Each plugin still owns its RPC envelope semantics. */\nexport function registerHostRpcTransport(\n ctx: HostRpcContext,\n channel: string,\n dispatch: (endpoint: string, body: unknown, signal: AbortSignal, response: ServerResponse) => void | Promise<void>,\n options: HostRpcTransportOptions = {},\n): () => void {\n const bodyLimit = options.maxBodyBytes ?? 64 * 1024\n if (!Number.isSafeInteger(bodyLimit) || bodyLimit <= 0) throw new Error('Invalid RPC body limit')\n const isEndpoint = options.isEndpoint ?? ((endpoint: string) => /^[a-z.]+$/.test(endpoint))\n return ctx.webServer.register({ kind: 'prefix', path: channel, handler: async (req, res) => {\n const reject = (status: number, error?: unknown, override?: string) => {\n if (res.destroyed) return\n if (status === 413) res.writeHead(status, { connection: 'close' })\n else res.writeHead(status)\n res.end(override ?? options.errorBody?.(status, error) ?? (status === 500 ? 'rpc request failed' : ''))\n }\n try {\n // Host admission always runs before plugin-specific checks or body reads.\n if (typeof ctx.connection.requestRejection !== 'function') { reject(503); return }\n const rejection = ctx.connection.requestRejection(req)\n if (rejection !== undefined) { reject(rejection); return }\n const pathname = new URL(req.url ?? '/', 'http://dsh.internal').pathname\n const endpoint = pathname.startsWith(`${channel}/`) ? pathname.slice(channel.length + 1) : ''\n if (req.method !== 'POST' || !isEndpoint(endpoint)) { reject(404); return }\n const contentType = String(req.headers['content-type'] ?? '').split(';', 1)[0]?.trim()\n if ((options.caseInsensitiveContentType ? contentType.toLowerCase() : contentType) !== 'application/json') {\n reject(415); return\n }\n const guarded = options.beforeBody?.(req, endpoint)\n if (guarded) { reject(guarded.status, undefined, guarded.body); return }\n\n const controller = new AbortController()\n res.on('close', () => { if (!res.writableEnded) controller.abort() })\n const chunks: Buffer[] = []\n let size = 0\n for await (const chunk of req) {\n const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)\n size += buffer.length\n if (size > bodyLimit) { reject(413); req.destroy(); return }\n chunks.push(buffer)\n }\n let body: unknown\n try { body = JSON.parse(Buffer.concat(chunks).toString('utf8') || (options.emptyBodyAsNull ? 'null' : '')) }\n catch { reject(400); return }\n await dispatch(endpoint, body, controller.signal, res)\n } catch (error) {\n reject(500, error)\n }\n } })\n}\n\n/** Write the native Connection response envelope after a plugin has handled a request. */\nexport function sendHostRpcResponse(response: ServerResponse, rpcId: string, result: unknown, noStore = true): void {\n if (response.destroyed) return\n response.writeHead(200, { 'content-type': 'application/json', ...(noStore ? { 'cache-control': 'no-store' } : {}) })\n response.end(JSON.stringify({ type: 'server-response', rpcId, result }))\n}\n\n/** Safe host RPC registration. Missing requestRejection fails closed. */\nexport function registerHostRpc<R extends RpcResult = RpcResult>(\n ctx: HostRpcContext,\n channel: string,\n call: (endpoint: string, payload: unknown, signal: AbortSignal) => Promise<R>,\n options: HostRpcOptions = {},\n): () => void {\n return registerHostRpcTransport(ctx, channel, async (endpoint, body, signal, res) => {\n if (!body || typeof body !== 'object' || Array.isArray(body)) { res.writeHead(400); res.end(); return }\n const request = body as Record<string, unknown>\n if (request.type !== 'client-request' || request.method !== endpoint || typeof request.rpcId !== 'string'\n || (options.requirePayload && !Object.hasOwn(request, 'payload'))) {\n res.writeHead(400); res.end(); return\n }\n const raw = await call(endpoint, request.payload, signal)\n const result = raw.ok ? raw : { ...raw, error: { details: {}, ...raw.error } }\n sendHostRpcResponse(res, request.rpcId, result)\n }, options)\n}\n","// Adapted from deep-view/src/core/formula.js (deep-view 0.1.0, Apache-2.0).\n// Kept as the same bounded expression interpreter: no eval, property access,\n// assignment or loops. The DSH migration preserves its grammar and error model.\n// It reads names and calls a fixed set of functions without reaching the page.\n\nconst FUNCTIONS = {\n min: { args: [1, Infinity], run: (...values) => Math.min(...values.map(num)) },\n max: { args: [1, Infinity], run: (...values) => Math.max(...values.map(num)) },\n abs: { args: [1, 1], run: value => Math.abs(num(value)) },\n floor: { args: [1, 1], run: value => Math.floor(num(value)) },\n ceil: { args: [1, 1], run: value => Math.ceil(num(value)) },\n sqrt: { args: [1, 1], run: value => Math.sqrt(num(value)) },\n pow: { args: [2, 2], run: (base, power) => num(base) ** num(power) },\n round: { args: [1, 2], run: (value, digits = 0) => roundTo(num(value), digitsOf(digits)) },\n clamp: { args: [3, 3], run: (value, low, high) => Math.min(Math.max(num(value), num(low)), num(high)) },\n fixed: { args: [1, 2], run: (value, digits = 0) => roundTo(num(value), digitsOf(digits)).toFixed(digitsOf(digits)) },\n format: { args: [1, 2], run: (value, digits = 0) => grouped(num(value), digitsOf(digits)) },\n percent: { args: [1, 2], run: (value, digits = 0) => `${grouped(num(value) * 100, digitsOf(digits))}%` },\n}\nexport const FORMULA_FUNCTIONS = Object.keys(FUNCTIONS)\nconst CONSTANTS = new Map([['true', true], ['false', false]])\n// Nesting deeper than this is no calculation a view needs; the parser recurses per level.\nconst MAX_NESTING = 64\n\nclass FormulaError extends Error {}\nconst fail = (message) => { throw new FormulaError(message) }\n\nfunction num(value) {\n if (typeof value === 'number') return value\n if (typeof value === 'boolean') return value ? 1 : 0\n const parsed = Number(value)\n if (typeof value === 'string' && value.trim() !== '' && !Number.isNaN(parsed)) return parsed\n return fail(`${JSON.stringify(value)} is not a number`)\n}\nconst digitsOf = (digits) => {\n const value = num(digits)\n if (!Number.isInteger(value) || value < 0 || value > 10) fail('digits must be a whole number from 0 to 10')\n return value\n}\nconst roundTo = (value, digits) => {\n const scale = 10 ** digits\n return Math.round(value * scale) / scale\n}\nfunction grouped(value, digits) {\n if (!Number.isFinite(value)) return String(value)\n const [whole, part] = Math.abs(roundTo(value, digits)).toFixed(digits).split('.')\n const sign = value < 0 && Number(whole + (part ?? '')) !== 0 ? '-' : ''\n return `${sign}${whole.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',')}${part ? `.${part}` : ''}`\n}\n\n// -------------------------------------------------------------------------\n// Tokens and parsing\n\nconst IDENT = /^[A-Za-z_][A-Za-z0-9_]*$/\nexport const isName = value => typeof value === 'string' && IDENT.test(value)\nconst OPERATORS = ['==', '!=', '<=', '>=', '&&', '||', '+', '-', '*', '/', '%', '<', '>', '!', '?', ':', '(', ')', ',']\n\nfunction tokenize(source) {\n const tokens = []\n let at = 0\n while (at < source.length) {\n const char = source[at]\n if (/\\s/.test(char)) { at += 1; continue }\n const number = /^(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?/.exec(source.slice(at))\n if (number) { tokens.push({ kind: 'number', value: Number(number[0]), at }); at += number[0].length; continue }\n const name = /^[A-Za-z_][A-Za-z0-9_]*/.exec(source.slice(at))\n if (name) { tokens.push({ kind: 'name', value: name[0], at }); at += name[0].length; continue }\n if (char === '\"' || char === '\\'') {\n let end = at + 1\n let text = ''\n while (end < source.length && source[end] !== char) {\n if (source[end] === '\\\\' && end + 1 < source.length) { text += source[end + 1]; end += 2; continue }\n text += source[end]\n end += 1\n }\n if (end >= source.length) fail(`unclosed string at ${at + 1}`)\n tokens.push({ kind: 'string', value: text, at })\n at = end + 1\n continue\n }\n const operator = OPERATORS.find(op => source.startsWith(op, at))\n if (operator === undefined) fail(`unexpected ${JSON.stringify(char)} at ${at + 1}`)\n tokens.push({ kind: 'op', value: operator, at })\n at += operator.length\n }\n return tokens\n}\n\nconst BINARY = [['||'], ['&&'], ['==', '!='], ['<', '<=', '>', '>='], ['+', '-'], ['*', '/', '%']]\n\nfunction parse(source) {\n const tokens = tokenize(source)\n let index = 0\n let depth = 0\n const peek = () => tokens[index]\n const isOp = value => peek()?.kind === 'op' && peek().value === value\n const expect = (value) => {\n if (!isOp(value)) fail(peek() ? `expected \"${value}\" at ${peek().at + 1}` : `expected \"${value}\" at the end`)\n index += 1\n }\n const nest = (read) => {\n depth += 1\n if (depth > MAX_NESTING) fail(`nested more than ${MAX_NESTING} levels`)\n const node = read()\n depth -= 1\n return node\n }\n const ternary = () => nest(() => {\n const test = binary(0)\n if (!isOp('?')) return test\n index += 1\n const yes = ternary()\n expect(':')\n return { type: 'if', test, yes, no: ternary() }\n })\n const binary = (level) => {\n if (level === BINARY.length) return unary()\n let left = binary(level + 1)\n while (peek()?.kind === 'op' && BINARY[level].includes(peek().value)) {\n const op = peek().value\n index += 1\n left = { type: 'binary', op, left, right: binary(level + 1) }\n }\n return left\n }\n const unary = () => {\n if (isOp('-') || isOp('!') || isOp('+')) {\n const op = peek().value\n index += 1\n return nest(() => ({ type: 'unary', op, value: unary() }))\n }\n return primary()\n }\n const primary = () => {\n const token = peek()\n if (token === undefined) fail('the formula ends too early')\n index += 1\n if (token.kind === 'number' || token.kind === 'string') return { type: 'value', value: token.value }\n if (token.kind === 'op' && token.value === '(') {\n const inner = ternary()\n expect(')')\n return inner\n }\n if (token.kind !== 'name') fail(`unexpected \"${token.value}\" at ${token.at + 1}`)\n if (!isOp('(')) return CONSTANTS.has(token.value) ? { type: 'value', value: CONSTANTS.get(token.value) } : { type: 'name', name: token.value }\n const fn = Object.hasOwn(FUNCTIONS, token.value) ? FUNCTIONS[token.value] : undefined\n if (fn === undefined) fail(`unknown function \"${token.value}\"; allowed: ${FORMULA_FUNCTIONS.join(', ')}`)\n index += 1\n const args = []\n if (!isOp(')')) {\n args.push(ternary())\n while (isOp(',')) { index += 1; args.push(ternary()) }\n }\n expect(')')\n if (args.length < fn.args[0] || args.length > fn.args[1]) {\n fail(`${token.value}() takes ${fn.args[0] === fn.args[1] ? fn.args[0] : fn.args[1] === Infinity ? `at least ${fn.args[0]}` : `${fn.args[0]} or ${fn.args[1]}`} argument${fn.args[1] === 1 ? '' : 's'}; got ${args.length}`)\n }\n return { type: 'call', name: token.value, args }\n }\n if (tokens.length === 0) fail('the formula is empty')\n const tree = ternary()\n if (index < tokens.length) fail(`unexpected \"${peek().value}\" at ${peek().at + 1}`)\n return tree\n}\n\nfunction namesIn(node, found = new Set()) {\n if (node.type === 'name') found.add(node.name)\n else if (node.type === 'unary') namesIn(node.value, found)\n else if (node.type === 'binary') { namesIn(node.left, found); namesIn(node.right, found) }\n else if (node.type === 'if') { namesIn(node.test, found); namesIn(node.yes, found); namesIn(node.no, found) }\n else if (node.type === 'call') for (const arg of node.args) namesIn(arg, found)\n return found\n}\n\n// { tree, names } or { error }. `names` are the names the formula reads.\nexport function compileFormula(source) {\n if (typeof source !== 'string') return { error: 'expected a formula string' }\n try {\n const tree = parse(source)\n return { tree, names: [...namesIn(tree)] }\n } catch (error) {\n if (error instanceof FormulaError) return { error: error.message }\n throw error\n }\n}\n\n// -------------------------------------------------------------------------\n// Evaluation. `lookup(name)` returns a name's value or throws.\n\nfunction run(node, lookup) {\n switch (node.type) {\n case 'value': return node.value\n case 'name': return lookup(node.name)\n case 'unary': {\n const value = run(node.value, lookup)\n if (node.op === '!') return !truthy(value)\n return node.op === '-' ? -num(value) : num(value)\n }\n case 'if': return truthy(run(node.test, lookup)) ? run(node.yes, lookup) : run(node.no, lookup)\n case 'call': return FUNCTIONS[node.name].run(...node.args.map(arg => run(arg, lookup)))\n default: return binary(node, lookup)\n }\n}\nconst truthy = value => (typeof value === 'string' ? value !== '' : Boolean(value))\n\nfunction binary(node, lookup) {\n if (node.op === '&&') return truthy(run(node.left, lookup)) ? run(node.right, lookup) : false\n if (node.op === '||') { const left = run(node.left, lookup); return truthy(left) ? left : run(node.right, lookup) }\n const left = run(node.left, lookup)\n const right = run(node.right, lookup)\n switch (node.op) {\n case '+': return typeof left === 'string' || typeof right === 'string' ? `${show(left)}${show(right)}` : num(left) + num(right)\n case '-': return num(left) - num(right)\n case '*': return num(left) * num(right)\n case '/': return num(left) / num(right)\n case '%': return num(left) % num(right)\n case '==': return left === right\n case '!=': return left !== right\n case '<': return num(left) < num(right)\n case '<=': return num(left) <= num(right)\n case '>': return num(left) > num(right)\n default: return num(left) >= num(right)\n }\n}\n\n// A value as text: numbers lose float noise (0.1 + 0.2 shows 0.3).\nexport function show(value) {\n if (typeof value === 'number') return Number.isFinite(value) ? String(Number(value.toPrecision(12))) : String(value)\n return String(value)\n}\n\n// A scope for one view: input values, plus `let` names worked out on demand. A cycle\n// or a missing name fails the formula that reads it.\nexport function createScope(inputs, lets) {\n const done = new Map()\n const busy = new Set()\n const lookup = (name) => {\n if (inputs.has(name)) return inputs.get(name)\n if (done.has(name)) return done.get(name)\n const tree = lets.get(name)\n if (tree === undefined) fail(`unknown name \"${name}\"`)\n if (busy.has(name)) fail(`\"${name}\" refers to itself`)\n busy.add(name)\n try {\n const value = run(tree, lookup)\n done.set(name, value)\n return value\n } finally { busy.delete(name) }\n }\n return lookup\n}\n\n// { value } or { error }.\nexport function evaluate(tree, lookup) {\n try {\n return { value: run(tree, lookup) }\n } catch (error) {\n if (error instanceof FormulaError) return { error: error.message }\n if (error instanceof RangeError) return { error: 'the formula is too deep to work out' }\n throw error\n }\n}\n","// Adapted from deep-view/src/core/views.js (deep-view 0.1.0, Apache-2.0).\n// DSH migration: html is deliberately rejected rather than migrating its frame;\n// validation, formulas and answers retain the original bounded JSON semantics.\n// Pure validation and evaluation of a declarative card, on Host and Client.\n// Formulas use formula.js; model-authored code never enters the DOM.\n\nimport { compileFormula, createScope, evaluate, isName, show } from './formula.js'\n\nconst LAYOUT = ['stack', 'row']\nconst DISPLAY = ['text', 'metric', 'table', 'chart', 'progress', 'callout', 'sources']\nconst INPUT_TYPES = ['slider', 'choice', 'toggle', 'number']\nconst ANSWERS = ['options', 'confirm', 'form', 'submit']\nconst COMPONENTS = [...LAYOUT, ...DISPLAY, ...INPUT_TYPES, ...ANSWERS]\nconst TONES = ['good', 'warn', 'bad']\nconst TEXT_TONES = ['muted']\nconst CALLOUT_TONES = ['info', 'good', 'warn', 'bad']\nexport const CHART_KINDS = ['bar', 'hbar', 'line', 'area', 'donut']\nconst INTERACTIVE = new Set(ANSWERS)\nconst INPUTS = new Set(INPUT_TYPES)\nconst PROPS = {\n stack: ['children', 'let'],\n row: ['children', 'let'],\n text: ['text', 'tone'],\n metric: ['label', 'value', 'tone', 'caption'],\n table: ['columns', 'rows'],\n chart: ['kind', 'categories', 'series', 'unit', 'caption'],\n progress: ['label', 'percent', 'value', 'max', 'valueLabel', 'tone'],\n callout: ['text', 'tone'],\n sources: ['items'],\n slider: ['id', 'label', 'min', 'max', 'step', 'value', 'unit'],\n choice: ['id', 'label', 'options', 'value'],\n toggle: ['id', 'label', 'value'],\n number: ['id', 'label', 'min', 'max', 'step', 'value', 'unit'],\n options: ['id', 'options', 'multi'],\n confirm: ['id', 'confirmLabel', 'cancelLabel'],\n form: ['id', 'fields', 'submitLabel'],\n submit: ['id', 'label'],\n}\nconst MAX_DEPTH = 8\nconst MAX_NODES = 64\nconst MAX_CHILDREN = 16\nconst MAX_TEXT = 2000\nconst MAX_CELL = 200\nconst MAX_COLUMNS = 8\nconst MAX_ROWS = 50\nconst MAX_OPTIONS = 8\nconst MAX_FIELDS = 6\nconst SUMMARY_PART = 40\nconst SUMMARY_COUNT = 8\nconst RESERVED = new Set(['true', 'false'])\n// UTF-8 bytes of the blueprint JSON plus the title. Not a wrapped document:\n// the tool rejects a show_view whose viewBytes() is over this before it\n// normalizes or validates, so the number has to be the bytes the model sent.\nexport const VIEW_BYTE_LIMIT = 8192\n\nconst isRecord = value => value !== null && typeof value === 'object' && !Array.isArray(value)\nconst quoted = value => JSON.stringify(value)\nconst allowed = list => list.join(', ')\nconst isNumber = value => typeof value === 'number' && Number.isFinite(value)\nconst isScalar = value => typeof value === 'string' || typeof value === 'boolean' || isNumber(value)\n\n// `{ \"=\": \"a * b\" }`: a value worked out from the view's inputs.\nexport const isFormula = value => isRecord(value) && Object.keys(value).length === 1 && Object.hasOwn(value, '=')\n\nexport function viewBytes(title, view) {\n return new TextEncoder().encode(`${JSON.stringify(view) ?? ''}${title ?? ''}`).length\n}\n\nconst NUMERIC = ['value', 'percent', 'min', 'max', 'step', 'height']\nconst numeric = value => (typeof value === 'string' && value.trim() !== '' && !Number.isNaN(Number(value)) ? Number(value) : value)\n\n// Some providers serialize nested arrays as `{ item: [...] }` (XML-style) and\n// numbers as strings. Normalize the blueprint before validation so a model is\n// not asked to retry a call whose only fault is the provider's encoding.\n// Arrays are unwrapped; numeric fields and chart values accept a numeric string.\n// Returns a new object; the input is not mutated.\nexport function normalizeView(value) {\n if (Array.isArray(value)) return value.map(normalizeView)\n if (!isRecord(value)) return value\n const keys = Object.keys(value)\n // Unwrap recursively: a provider may nest the wrapper, as { item: { item: [...] } }.\n if (keys.length === 1 && keys[0] === 'item') {\n const inner = normalizeView(value.item)\n if (Array.isArray(inner)) return inner\n }\n // Define own properties: an incoming \"__proto__\" key must become data the\n // validator can reject, not hit the prototype setter and vanish from the JSON.\n const out = {}\n for (const key of keys) Object.defineProperty(out, key, { value: normalizeView(value[key]), writable: true, enumerable: true, configurable: true })\n for (const field of NUMERIC) if (Object.hasOwn(out, field)) out[field] = numeric(out[field])\n if (Array.isArray(out.values)) out.values = out.values.map(numeric)\n return out\n}\n\nexport function validateView(view) {\n const ctx = { ids: new Set(), nodes: 0, interactive: false, inputs: new Map(), lets: new Map(), formulas: [] }\n const error = checkNode(view, 'view', 1, ctx) ?? checkFormulas(ctx)\n return error === undefined ? { ok: true, interactive: ctx.interactive } : { ok: false, error }\n}\n\n// What show_view checks before it shows a view: the same answer on the host and\n// in the client. The bytes are measured as sent, before normalizeView unwraps the\n// provider's encoding, or a wrapped view could shrink under the byte limit. The\n// normalized view and the trimmed title come back; the title may be empty.\nexport function checkShownView(title, sent) {\n let bytes\n try { bytes = viewBytes(title, sent) } catch { return { error: 'The view is not JSON data.' } }\n if (bytes > VIEW_BYTE_LIMIT) return { error: `The view is ${bytes} bytes; the limit is ${VIEW_BYTE_LIMIT}.` }\n if (title !== undefined && title !== null && typeof title !== 'string') return { error: 'title: expected a string' }\n const named = String(title ?? '').trim()\n const view = normalizeView(sent)\n const checked = validateView(view)\n if (!checked.ok) return { error: checked.error }\n return { title: named, view, interactive: checked.interactive }\n}\n\nfunction checkNode(node, path, depth, ctx) {\n if (!isRecord(node)) return `${path}: expected a component object`\n if (depth > MAX_DEPTH) return `${path}: ${depth} levels exceeds the limit of ${MAX_DEPTH}`\n ctx.nodes += 1\n if (ctx.nodes > MAX_NODES) return `${path}: ${ctx.nodes} components exceeds the limit of ${MAX_NODES}`\n const type = node.type\n if (!COMPONENTS.includes(type)) return `${path}.type: unknown component ${quoted(type)}; allowed: ${allowed(COMPONENTS)}`\n const props = PROPS[type]\n for (const key of Object.keys(node)) {\n if (key === 'type' || props.includes(key)) continue\n return `${path}.${key}: unknown property ${quoted(key)}; allowed: ${allowed(props)}`\n }\n if (INTERACTIVE.has(type)) ctx.interactive = true\n switch (type) {\n case 'stack': case 'row': return checkLayout(node, path, depth, ctx)\n case 'text': return checkText(node, path, ctx)\n case 'metric': return checkMetric(node, path, ctx)\n case 'table': return checkTable(node, path, ctx)\n case 'chart': return checkChart(node, path, ctx)\n case 'progress': return checkProgress(node, path, ctx)\n case 'callout': return checkCallout(node, path, ctx)\n case 'sources': return checkSources(node, path)\n case 'slider': case 'number': return checkNumberInput(node, path, ctx)\n case 'choice': return checkChoice(node, path, ctx)\n case 'toggle': return checkToggle(node, path, ctx)\n case 'options': return checkOptions(node, path, ctx)\n case 'confirm': return checkConfirm(node, path, ctx)\n case 'form': return checkForm(node, path, ctx)\n default: return checkSubmit(node, path, ctx)\n }\n}\n\nfunction checkLayout(node, path, depth, ctx) {\n if (node.let !== undefined) {\n if (depth !== 1) return `${path}.let: only the outermost component can define names`\n if (!isRecord(node.let)) return `${path}.let: expected an object of names to formulas`\n for (const [name, source] of Object.entries(node.let)) {\n if (!isName(name) || RESERVED.has(name)) return `${path}.let.${name}: a name is letters, digits and _, and starts with a letter or _`\n if (typeof source !== 'string') return `${path}.let.${name}: expected a formula string`\n ctx.lets.set(name, { source, path: `${path}.let.${name}` })\n }\n }\n if (!Array.isArray(node.children)) return `${path}.children: expected an array of 1 to ${MAX_CHILDREN} components`\n if (node.children.length < 1 || node.children.length > MAX_CHILDREN) return `${path}.children: expected 1 to ${MAX_CHILDREN} children; got ${node.children.length}`\n for (let index = 0; index < node.children.length; index += 1) {\n const error = checkNode(node.children[index], `${path}.children[${index}]`, depth + 1, ctx)\n if (error !== undefined) return error\n }\n return undefined\n}\n\n// A property that may be a literal of `kind` or a formula giving one. Formulas are\n// checked once the whole tree, with every input and name, is known.\nfunction checkValue(node, key, path, ctx, kind, { required = false, max = MAX_TEXT } = {}) {\n const value = node[key]\n const at = `${path}.${key}`\n if (value === undefined) return required ? `${at}: ${expected(kind)}` : undefined\n if (isFormula(value)) {\n ctx.formulas.push({ source: value['='], path: at, kind })\n return undefined\n }\n if (kind === 'number') return isNumber(value) ? undefined : `${at}: ${expected(kind)}`\n if (Array.isArray(kind)) return kind.includes(value) ? undefined : `${at}: unknown tone ${quoted(value)}; allowed: ${allowed(kind)}`\n if (kind === 'string') {\n if (typeof value !== 'string') return `${at}: ${expected(kind)}`\n return value.length > max ? `${at}: ${value.length} characters exceeds the limit of ${max}` : undefined\n }\n if (!isScalar(value)) return `${at}: ${expected(kind)}`\n return undefined\n}\nconst expected = kind => (kind === 'number' ? 'expected a number' : kind === 'string' ? 'expected a string' : Array.isArray(kind) ? `expected one of ${allowed(kind)}` : 'expected a string or a number')\n\nfunction checkText(node, path, ctx) {\n return checkValue(node, 'text', path, ctx, 'string', { required: true })\n ?? checkValue(node, 'tone', path, ctx, TEXT_TONES)\n}\n\nfunction checkMetric(node, path, ctx) {\n if (typeof node.label !== 'string') return `${path}.label: expected a string`\n if (node.value === undefined) return `${path}.value: expected a string or a number`\n if (typeof node.value === 'number' && !Number.isFinite(node.value)) return `${path}.value: expected a finite number`\n return checkValue(node, 'value', path, ctx, 'scalar')\n ?? checkValue(node, 'tone', path, ctx, TONES)\n ?? checkValue(node, 'caption', path, ctx, 'string')\n}\n\nfunction checkTable(node, path, ctx) {\n if (!Array.isArray(node.columns)) return `${path}.columns: expected an array of at most ${MAX_COLUMNS} columns`\n if (node.columns.length > MAX_COLUMNS) return `${path}.columns: ${node.columns.length} columns exceeds the limit of ${MAX_COLUMNS}`\n for (let index = 0; index < node.columns.length; index += 1) {\n const column = node.columns[index]\n const at = `${path}.columns[${index}]`\n if (!isRecord(column)) return `${at}: expected a column object`\n for (const key of Object.keys(column)) {\n if (key !== 'key' && key !== 'label') return `${at}.${key}: unknown property ${quoted(key)}; allowed: key, label`\n }\n if (typeof column.key !== 'string' || column.key === '') return `${at}.key: expected a non-empty string`\n if (typeof column.label !== 'string') return `${at}.label: expected a string`\n }\n if (!Array.isArray(node.rows)) return `${path}.rows: expected an array of at most ${MAX_ROWS} rows`\n if (node.rows.length > MAX_ROWS) return `${path}.rows: ${node.rows.length} rows exceeds the limit of ${MAX_ROWS}`\n for (let row = 0; row < node.rows.length; row += 1) {\n const cells = node.rows[row]\n if (!Array.isArray(cells)) return `${path}.rows[${row}]: expected an array of cells`\n for (let column = 0; column < cells.length; column += 1) {\n const at = `${path}.rows[${row}][${column}]`\n if (isFormula(cells[column])) { ctx.formulas.push({ source: cells[column]['='], path: at, kind: 'scalar' }); continue }\n const text = cellText(cells[column])\n if (text.length > MAX_CELL) return `${at}: ${text.length} characters exceeds the limit of ${MAX_CELL}`\n }\n }\n return undefined\n}\n\nfunction checkChart(node, path, ctx) {\n if (node.kind !== undefined && !CHART_KINDS.includes(node.kind)) return `${path}.kind: unknown chart ${quoted(node.kind)}; allowed: ${allowed(CHART_KINDS)}`\n if (!Array.isArray(node.categories) || node.categories.length === 0) return `${path}.categories: expected a non-empty array of labels`\n for (let index = 0; index < node.categories.length; index += 1) {\n const label = node.categories[index]\n if (typeof label !== 'string' && !isNumber(label)) return `${path}.categories[${index}]: expected a string`\n }\n if (!Array.isArray(node.series) || node.series.length === 0) return `${path}.series: expected a non-empty array of { name?, values }`\n if (node.kind === 'donut' && node.series.length > 1) return `${path}.series: a donut takes one series; got ${node.series.length}`\n for (let index = 0; index < node.series.length; index += 1) {\n const series = node.series[index]\n const at = `${path}.series[${index}]`\n if (!isRecord(series)) return `${at}: expected a series object`\n for (const key of Object.keys(series)) {\n if (key !== 'name' && key !== 'values') return `${at}.${key}: unknown property ${quoted(key)}; allowed: name, values`\n }\n if (series.name !== undefined && typeof series.name !== 'string') return `${at}.name: expected a string`\n if (!Array.isArray(series.values)) return `${at}.values: expected an array of numbers`\n if (series.values.length !== node.categories.length) return `${at}.values: ${series.values.length} values for ${node.categories.length} categories`\n for (let item = 0; item < series.values.length; item += 1) {\n const value = series.values[item]\n if (isFormula(value)) ctx.formulas.push({ source: value['='], path: `${at}.values[${item}]`, kind: 'number' })\n else if (!isNumber(value)) return `${at}.values[${item}]: expected a number`\n }\n }\n if (node.unit !== undefined && typeof node.unit !== 'string') return `${path}.unit: expected a string`\n if (node.caption !== undefined && typeof node.caption !== 'string') return `${path}.caption: expected a string`\n return undefined\n}\n\nfunction checkProgress(node, path, ctx) {\n if (node.label !== undefined && typeof node.label !== 'string') return `${path}.label: expected a string`\n if ((node.percent === undefined) === (node.value === undefined)) return `${path}: give percent (0 to 100), or value with max`\n if (node.percent !== undefined && !isFormula(node.percent)) {\n if (typeof node.percent !== 'number' || !Number.isFinite(node.percent) || node.percent < 0 || node.percent > 100) return `${path}.percent: expected a number from 0 to 100`\n }\n if (node.value !== undefined && node.max === undefined) return `${path}.max: expected a number with value`\n if (node.value === undefined && node.max !== undefined) return `${path}.value: expected a number with max`\n return checkValue(node, 'percent', path, ctx, 'number')\n ?? checkValue(node, 'value', path, ctx, 'number')\n ?? checkValue(node, 'max', path, ctx, 'number')\n ?? checkValue(node, 'valueLabel', path, ctx, 'scalar')\n ?? checkValue(node, 'tone', path, ctx, TONES)\n}\n\nfunction checkCallout(node, path, ctx) {\n return checkValue(node, 'text', path, ctx, 'string', { required: true })\n ?? checkValue(node, 'tone', path, ctx, CALLOUT_TONES)\n}\n\nfunction checkSources(node, path) {\n if (!Array.isArray(node.items) || node.items.length === 0) return `${path}.items: expected a non-empty array of { label, url }`\n for (let index = 0; index < node.items.length; index += 1) {\n const item = node.items[index]\n const at = `${path}.items[${index}]`\n if (!isRecord(item)) return `${at}: expected a { label, url } object`\n for (const key of Object.keys(item)) {\n if (key !== 'label' && key !== 'url') return `${at}.${key}: unknown property ${quoted(key)}; allowed: label, url`\n }\n if (typeof item.label !== 'string' || item.label.trim() === '') return `${at}.label: expected a non-empty string`\n if (typeof item.url !== 'string' || !/^https?:\\/\\/[^\\s]+$/i.test(item.url)) return `${at}.url: expected an http(s) address`\n }\n return undefined\n}\n\nfunction checkInputId(node, path, ctx) {\n if (!isName(node.id) || RESERVED.has(node.id)) return `${path}.id: an input id is letters, digits and _, and starts with a letter or _, so formulas can use it`\n if (ctx.ids.has(node.id)) return `${path}.id: duplicate id ${quoted(node.id)}`\n ctx.ids.add(node.id)\n if (typeof node.label !== 'string') return `${path}.label: expected a string`\n return undefined\n}\n\nfunction checkNumberInput(node, path, ctx) {\n const idError = checkInputId(node, path, ctx)\n if (idError !== undefined) return idError\n for (const key of ['min', 'max', 'step']) {\n if (node[key] !== undefined && !isNumber(node[key])) return `${path}.${key}: expected a number`\n }\n if (node.type === 'slider' && (node.min === undefined || node.max === undefined)) return `${path}: a slider needs min and max`\n if (node.min !== undefined && node.max !== undefined && node.max <= node.min) return `${path}.max: expected more than min (${node.min})`\n if (node.step !== undefined && node.step <= 0) return `${path}.step: expected more than 0`\n if (!isNumber(node.value)) return `${path}.value: expected a number`\n if ((node.min !== undefined && node.value < node.min) || (node.max !== undefined && node.value > node.max)) return `${path}.value: expected a number from ${node.min ?? '-∞'} to ${node.max ?? '∞'}`\n if (node.unit !== undefined && typeof node.unit !== 'string') return `${path}.unit: expected a string`\n ctx.inputs.set(node.id, node.value)\n return undefined\n}\n\nfunction checkChoice(node, path, ctx) {\n const idError = checkInputId(node, path, ctx)\n if (idError !== undefined) return idError\n if (!Array.isArray(node.options) || node.options.length === 0) return `${path}.options: expected a non-empty array of { label, value }`\n const labels = new Set()\n const values = new Set()\n for (let index = 0; index < node.options.length; index += 1) {\n const option = node.options[index]\n const at = `${path}.options[${index}]`\n if (!isRecord(option)) return `${at}: expected a { label, value } object`\n for (const key of Object.keys(option)) {\n if (key !== 'label' && key !== 'value') return `${at}.${key}: unknown property ${quoted(key)}; allowed: label, value`\n }\n if (typeof option.label !== 'string' || option.label.trim() === '') return `${at}.label: expected a non-empty string`\n if (labels.has(option.label)) return `${at}.label: duplicate label ${quoted(option.label)}`\n labels.add(option.label)\n const value = option.value ?? option.label\n if (!isScalar(value)) return `${at}.value: expected a string, a number or true/false`\n if (values.has(value)) return `${at}.value: duplicate value ${quoted(value)}`\n values.add(value)\n }\n const chosen = node.value ?? choiceValue(node.options[0])\n if (!values.has(chosen)) return `${path}.value: expected one of the options' values`\n ctx.inputs.set(node.id, chosen)\n return undefined\n}\n\nfunction checkToggle(node, path, ctx) {\n const idError = checkInputId(node, path, ctx)\n if (idError !== undefined) return idError\n if (node.value !== undefined && typeof node.value !== 'boolean') return `${path}.value: expected true or false`\n ctx.inputs.set(node.id, node.value === true)\n return undefined\n}\n\nfunction checkOptions(node, path, ctx) {\n const idError = checkId(node, path, ctx)\n if (idError !== undefined) return idError\n if (node.multi !== undefined && typeof node.multi !== 'boolean') return `${path}.multi: expected a boolean`\n if (!Array.isArray(node.options)) return `${path}.options: expected an array of 1 to ${MAX_OPTIONS} options`\n if (node.options.length < 1 || node.options.length > MAX_OPTIONS) return `${path}.options: expected 1 to ${MAX_OPTIONS} options; got ${node.options.length}`\n const labels = new Set()\n for (let index = 0; index < node.options.length; index += 1) {\n const option = node.options[index]\n const at = `${path}.options[${index}]`\n if (!isRecord(option)) return `${at}: expected an option object`\n for (const key of Object.keys(option)) {\n if (key !== 'label' && key !== 'description') return `${at}.${key}: unknown property ${quoted(key)}; allowed: label, description`\n }\n if (typeof option.label !== 'string' || option.label.trim() === '') return `${at}.label: expected a non-empty string`\n if (labels.has(option.label)) return `${at}.label: duplicate label ${quoted(option.label)}`\n labels.add(option.label)\n if (option.description !== undefined && typeof option.description !== 'string') return `${at}.description: expected a string`\n }\n return undefined\n}\n\nfunction checkConfirm(node, path, ctx) {\n const idError = checkId(node, path, ctx)\n if (idError !== undefined) return idError\n if (node.confirmLabel !== undefined && typeof node.confirmLabel !== 'string') return `${path}.confirmLabel: expected a string`\n if (node.cancelLabel !== undefined && typeof node.cancelLabel !== 'string') return `${path}.cancelLabel: expected a string`\n return undefined\n}\n\nfunction checkForm(node, path, ctx) {\n const idError = checkId(node, path, ctx)\n if (idError !== undefined) return idError\n if (node.submitLabel !== undefined && typeof node.submitLabel !== 'string') return `${path}.submitLabel: expected a string`\n if (!Array.isArray(node.fields)) return `${path}.fields: expected an array of at most ${MAX_FIELDS} fields`\n if (node.fields.length > MAX_FIELDS) return `${path}.fields: ${node.fields.length} fields exceeds the limit of ${MAX_FIELDS}`\n const seen = new Set()\n for (let index = 0; index < node.fields.length; index += 1) {\n const field = node.fields[index]\n const at = `${path}.fields[${index}]`\n if (!isRecord(field)) return `${at}: expected a field object`\n for (const key of Object.keys(field)) {\n if (key !== 'id' && key !== 'label' && key !== 'placeholder') return `${at}.${key}: unknown property ${quoted(key)}; allowed: id, label, placeholder`\n }\n if (typeof field.id !== 'string' || field.id === '') return `${at}.id: expected a non-empty string`\n if (field.id === '__proto__') return `${at}.id: \"__proto__\" cannot be an id`\n if (seen.has(field.id)) return `${at}.id: duplicate field id ${quoted(field.id)}`\n seen.add(field.id)\n if (typeof field.label !== 'string') return `${at}.label: expected a string`\n if (field.placeholder !== undefined && typeof field.placeholder !== 'string') return `${at}.placeholder: expected a string`\n }\n return undefined\n}\n\nfunction checkSubmit(node, path, ctx) {\n const idError = checkId(node, path, ctx)\n if (idError !== undefined) return idError\n if (node.label !== undefined && typeof node.label !== 'string') return `${path}.label: expected a string`\n return undefined\n}\n\nfunction checkId(node, path, ctx) {\n if (typeof node.id !== 'string' || node.id === '') return `${path}.id: expected a non-empty string`\n // A `__proto__` id would write through to a plain object's prototype where the\n // answer is kept, losing it silently.\n if (node.id === '__proto__') return `${path}.id: \"__proto__\" cannot be an id`\n if (ctx.ids.has(node.id)) return `${path}.id: duplicate id ${quoted(node.id)}`\n ctx.ids.add(node.id)\n return undefined\n}\n\n// Every formula parses, reads only inputs and names the view defines, and gives the\n// right kind of value with the inputs as the Bot set them.\nfunction checkFormulas(ctx) {\n const known = new Set([...ctx.inputs.keys(), ...ctx.lets.keys()])\n const lets = new Map()\n for (const [name, entry] of ctx.lets) {\n if (ctx.inputs.has(name)) return `${entry.path}: ${quoted(name)} is already an input id`\n const compiled = compileFormula(entry.source)\n if (compiled.error !== undefined) return `${entry.path}: ${compiled.error}`\n const unknown = compiled.names.find(item => !known.has(item))\n if (unknown !== undefined) return `${entry.path}: unknown name ${quoted(unknown)}; known: ${allowed([...known]) || '(none)'}`\n lets.set(name, compiled.tree)\n }\n const lookup = createScope(ctx.inputs, lets)\n for (const [name, entry] of ctx.lets) {\n const result = evaluate(lets.get(name), lookup)\n if (result.error !== undefined) return `${entry.path}: ${result.error}`\n }\n for (const formula of ctx.formulas) {\n const compiled = compileFormula(formula.source)\n if (compiled.error !== undefined) return `${formula.path}: ${compiled.error}`\n const unknown = compiled.names.find(item => !known.has(item))\n if (unknown !== undefined) return `${formula.path}: unknown name ${quoted(unknown)}; known: ${allowed([...known]) || '(none)'}`\n const result = evaluate(compiled.tree, lookup)\n if (result.error !== undefined) return `${formula.path}: ${result.error}`\n const problem = kindProblem(result.value, formula.kind)\n if (problem !== undefined) return `${formula.path}: the formula gives ${quoted(result.value)}; ${problem}`\n }\n return undefined\n}\n\nfunction kindProblem(value, kind) {\n if (kind === 'number') return isNumber(value) ? undefined : 'expected a number'\n if (Array.isArray(kind)) return kind.includes(value) ? undefined : `expected one of ${allowed(kind)}`\n if (kind === 'string') return isScalar(value) ? undefined : 'expected text'\n return isScalar(value) ? undefined : 'expected a string or a number'\n}\n\nfunction cellText(value) {\n if (typeof value === 'string') return value\n const text = JSON.stringify(value)\n return typeof text === 'string' ? text : ''\n}\n\n// -------------------------------------------------------------------------\n// Working a blueprint out: the client draws with these, the summary reads them.\n\nconst compiled = new WeakMap()\nconst treeOf = (formula) => {\n let entry = compiled.get(formula)\n if (entry === undefined) {\n entry = compileFormula(formula['='])\n compiled.set(formula, entry)\n }\n return entry\n}\n\nexport const choiceValue = option => option?.value ?? option?.label\n\nfunction walk(node, visit) {\n if (!isRecord(node)) return\n visit(node)\n if (LAYOUT.includes(node.type) && Array.isArray(node.children)) for (const child of node.children) walk(child, visit)\n}\n\nexport function viewInputs(view) {\n const found = []\n walk(view, (node) => { if (INPUTS.has(node.type)) found.push(node) })\n return found\n}\n\nexport function inputDefault(node) {\n if (node.type === 'toggle') return node.value === true\n if (node.type === 'choice') return node.value ?? choiceValue(Array.isArray(node.options) ? node.options[0] : undefined)\n return node.value\n}\n\nexport const hasInputs = view => viewInputs(view).length > 0\n\n// The values a view's formulas read: each input's default unless `values` sets it.\nexport function viewScope(view, values = {}) {\n const inputs = new Map()\n for (const node of viewInputs(view)) inputs.set(node.id, Object.hasOwn(values, node.id) ? values[node.id] : inputDefault(node))\n const lets = new Map()\n for (const [name, source] of Object.entries(isRecord(view?.let) ? view.let : {})) {\n const entry = compileFormula(source)\n if (entry.tree !== undefined) lets.set(name, entry.tree)\n }\n return createScope(inputs, lets)\n}\n\n// A property's value: the literal, or the formula worked out. A formula that fails\n// with these inputs gives `fallback`.\nexport function resolve(value, lookup, fallback = undefined) {\n if (!isFormula(value)) return value\n const entry = treeOf(value)\n if (entry.tree === undefined) return fallback\n const result = evaluate(entry.tree, lookup)\n return result.error === undefined ? result.value : fallback\n}\n\nexport const asText = value => (value === undefined || value === null ? '' : show(value))\n\n// -------------------------------------------------------------------------\n// Summaries\n\nfunction clip(text) {\n const flat = String(text).replace(/\\s+/g, ' ').trim()\n return flat.length <= SUMMARY_PART ? flat : flat.slice(0, SUMMARY_PART)\n}\n\nconst choiceLabel = (node, value) => (Array.isArray(node.options) ? node.options : []).find(option => choiceValue(option) === value)?.label ?? asText(value)\n\nfunction inputText(node, value) {\n if (node.type === 'toggle') return value === true ? 'on' : 'off'\n if (node.type === 'choice') return choiceLabel(node, value)\n return `${asText(value)}${node.unit ? ` ${node.unit}` : ''}`\n}\n\nfunction progressPercent(node, lookup) {\n if (node.percent !== undefined) return Number(resolve(node.percent, lookup, 0))\n const max = Number(resolve(node.max, lookup, 0))\n return max > 0 ? (Number(resolve(node.value, lookup, 0)) / max) * 100 : 0\n}\n\nfunction componentSummary(node, lookup) {\n const value = item => asText(resolve(item, lookup, ''))\n switch (node.type) {\n case 'text': return `text: ${value(node.text)}`\n case 'metric': return `metric: ${node.label}=${value(node.value)}`\n case 'table': return `table: ${(Array.isArray(node.columns) ? node.columns : []).map(column => column?.label ?? column?.key ?? '').filter(Boolean).join('/')}`\n case 'chart': {\n const series = Array.isArray(node.series) ? node.series[0] : undefined\n const values = Array.isArray(series?.values) ? series.values : []\n const unit = node.unit ? ` ${node.unit}` : ''\n return `chart: ${(Array.isArray(node.categories) ? node.categories : []).map((label, index) => `${label}=${value(values[index])}${unit}`).join(', ')}`\n }\n case 'progress': return `progress: ${node.label ? `${node.label} ` : ''}${Math.round(progressPercent(node, lookup))}%`\n case 'callout': return `callout: ${value(node.text)}`\n case 'sources': return `sources: ${(Array.isArray(node.items) ? node.items : []).map(item => item?.label).filter(Boolean).join('/')}`\n case 'slider': case 'number': case 'choice': case 'toggle': return `${node.type}: ${node.label}=${inputText(node, inputDefault(node))}`\n case 'options': return `options: ${(Array.isArray(node.options) ? node.options : []).map(option => option?.label).filter(Boolean).join('/')}`\n case 'confirm': return 'confirm'\n case 'form': return `form: ${(Array.isArray(node.fields) ? node.fields : []).map(field => field?.label ?? field?.id).filter(Boolean).join('/')}`\n case 'submit': return `submit: ${node.label ?? 'Send'}`\n default: return undefined\n }\n}\n\n// One line for a handoff or a checkpoint. Containers add nothing of their own;\n// each component keeps one short phrase, and the line stops after a few. Formulas\n// show what they give with the inputs as the Bot set them.\nexport function viewSummary(view) {\n const parts = []\n const lookup = viewScope(view)\n const visit = (node) => {\n if (parts.length >= SUMMARY_COUNT || !isRecord(node)) return\n const line = componentSummary(node, lookup)\n if (line !== undefined) parts.push(clip(line))\n if (parts.length >= SUMMARY_COUNT || !LAYOUT.includes(node.type) || !Array.isArray(node.children)) return\n for (const child of node.children) visit(child)\n }\n visit(view)\n return parts.join('; ')\n}\n\n// The inputs of an answer as `Label=value` pairs, for the Bot's history.\nexport function inputsSummary(view, inputs) {\n if (!isRecord(inputs)) return ''\n return viewInputs(view)\n .filter(node => Object.hasOwn(inputs, node.id))\n .map(node => `${node.label || node.id}=${inputText(node, inputs[node.id])}`)\n .join('; ')\n}\n\n// -------------------------------------------------------------------------\n// Answers\n\nfunction interactiveNodes(node, found = []) {\n walk(node, (item) => { if (INTERACTIVE.has(item.type)) found.push(item) })\n return found\n}\n\n// `action` is the id of the component the user submitted. One submit settles\n// the whole card, so only that component's values are kept, plus the inputs'\n// values when the view has inputs.\nexport function validateViewAnswer(view, action, values) {\n const nodes = interactiveNodes(view)\n if (typeof action !== 'string' || action === '') return { error: `action: expected an interactive component id; allowed: ${allowed(nodes.map(node => node.id))}` }\n const node = nodes.find(item => item.id === action)\n if (node === undefined) return { error: `action: no interactive component with id ${quoted(action)}; allowed: ${allowed(nodes.map(item => item.id))}` }\n if (!isRecord(values)) return { error: 'values: expected an object' }\n const inputs = validateInputs(view, values.inputs)\n if (inputs.error !== undefined) return inputs\n const extra = inputs.inputs === undefined ? {} : { inputs: inputs.inputs }\n if (node.type === 'submit') return { ...extra }\n const own = node.type === 'options' ? validateOptions(node, values) : node.type === 'confirm' ? validateConfirm(values) : validateForm(node, values)\n return own.error === undefined ? { ...own, ...extra } : own\n}\n\n// Every input of the view, as sent or else as the Bot set it.\nfunction validateInputs(view, sent) {\n const nodes = viewInputs(view)\n if (nodes.length === 0) return sent === undefined ? {} : { error: 'values.inputs: this view has no inputs' }\n if (sent !== undefined && !isRecord(sent)) return { error: 'values.inputs: expected an object of input ids to values' }\n const given = sent ?? {}\n const ids = nodes.map(node => node.id)\n const unknown = Object.keys(given).find(key => !ids.includes(key))\n if (unknown !== undefined) return { error: `values.inputs.${unknown}: unknown input; allowed: ${allowed(ids)}` }\n const inputs = {}\n for (const node of nodes) {\n const value = Object.hasOwn(given, node.id) ? given[node.id] : inputDefault(node)\n const at = `values.inputs.${node.id}`\n if (node.type === 'toggle' && typeof value !== 'boolean') return { error: `${at}: expected true or false` }\n if (node.type === 'choice' && !(Array.isArray(node.options) ? node.options : []).some(option => choiceValue(option) === value)) return { error: `${at}: expected one of the options' values` }\n if (node.type === 'slider' || node.type === 'number') {\n if (!isNumber(value)) return { error: `${at}: expected a number` }\n if ((node.min !== undefined && value < node.min) || (node.max !== undefined && value > node.max)) return { error: `${at}: expected a number from ${node.min ?? '-∞'} to ${node.max ?? '∞'}` }\n }\n inputs[node.id] = value\n }\n return { inputs }\n}\n\nfunction validateOptions(node, values) {\n if (!Array.isArray(values.selected)) return { error: 'values.selected: expected an array of option labels' }\n const labels = new Set((node.options ?? []).map(option => option?.label))\n const picked = values.selected.filter(label => typeof label === 'string' && labels.has(label))\n const selected = node.multi === true ? [...new Set(picked)] : picked.slice(0, 1)\n if (selected.length === 0) return { error: 'values.selected: select at least one option' }\n return { selected }\n}\n\nfunction validateConfirm(values) {\n if (typeof values.confirmed !== 'boolean') return { error: 'values.confirmed: expected a boolean' }\n return { confirmed: values.confirmed }\n}\n\nfunction validateForm(node, values) {\n if (!isRecord(values.fields)) return { error: 'values.fields: expected an object of field ids to strings' }\n const declared = (node.fields ?? []).map(field => field?.id).filter(id => typeof id === 'string')\n const allowedIds = new Set(declared)\n const fields = {}\n for (const [key, value] of Object.entries(values.fields)) {\n if (!allowedIds.has(key)) return { error: `values.fields.${key}: unknown field; allowed: ${allowed(declared)}` }\n if (typeof value !== 'string') return { error: `values.fields.${key}: expected a string` }\n if (value.length > MAX_TEXT) return { error: `values.fields.${key}: ${value.length} characters exceeds the limit of ${MAX_TEXT}` }\n fields[key] = value\n }\n return { fields }\n}\n","import { choiceValue, inputsSummary, validateViewAnswer, viewInputs } from './core/index.js'\nimport { isRecord, type ViewAnswer, type ViewNode } from './contracts.ts'\n\ntype Card = { id: string; title: string; view: ViewNode }\nfunction controls(view: ViewNode): ViewNode[] {\n return ['options', 'confirm', 'form', 'submit'].includes(view.type)\n ? [view] : (view.children ?? []).flatMap(controls)\n}\n\nexport function answerText(card: Pick<Card, 'title' | 'view'>, action: string, values: Record<string, unknown>): string {\n const node = controls(card.view).find(node => node.id === action)\n const lines = [card.title || 'Deep View']\n if (Array.isArray(values.selected)) lines.push(values.selected.map(String).join(', '))\n if (typeof values.confirmed === 'boolean') lines.push(values.confirmed\n ? node?.confirmLabel ?? 'Confirm' : node?.cancelLabel ?? 'Cancel')\n if (isRecord(values.fields)) {\n for (const field of node?.fields ?? []) lines.push(`${field.label}: ${String(values.fields[field.id] ?? '')}`)\n }\n const inputs = inputsSummary(card.view, values.inputs)\n if (inputs) lines.push(inputs)\n if (node?.type === 'submit') lines.push(node.label ?? 'Submit')\n return lines.join('\\n')\n}\n\n/** Legacy messages have no metadata. Restore only unambiguous, fully validated\n * answers that reproduce the exact text written by this plugin. Never guess\n * from ordinary prose, and never modify the stored message. */\nexport function legacyAnswer(card: Card, text: string): ViewAnswer | null {\n if (text.startsWith('{')) {\n try {\n const data: unknown = JSON.parse(text)\n if (!isRecord(data) || data.kind !== 'answer_to_pending_view' || data.tool !== 'show_view' || !Array.isArray(data.answers)) return null\n const answer = data.answers.find(value => isRecord(value) && value.id === card.id)\n if (!isRecord(answer) || typeof answer.action !== 'string') return null\n const values = validateViewAnswer(card.view, answer.action, answer.values)\n return values.error === undefined ? { id: card.id, action: answer.action, values } : null\n } catch { return null }\n }\n const lines = text.split('\\n')\n if (lines.shift() !== (card.title || 'Deep View')) return null\n const candidates: ViewAnswer[] = []\n for (const node of controls(card.view)) {\n const rest = [...lines]\n const values: Record<string, unknown> = {}\n if (node.type === 'options') {\n const line = rest.shift()\n if (line === undefined) continue\n const labels = node.options?.map(option => option.label) ?? []\n if (node.multi && labels.some(label => label.includes(', '))) continue\n values.selected = node.multi ? line.split(', ') : [line]\n } else if (node.type === 'confirm') {\n const line = rest.shift(), yes = node.confirmLabel ?? 'Confirm', no = node.cancelLabel ?? 'Cancel'\n if (yes === no || line !== yes && line !== no) continue\n values.confirmed = line === yes\n } else if (node.type === 'form') {\n const fields: Record<string, string> = {}\n let valid = true\n for (const field of node.fields ?? []) {\n const line = rest.shift(), prefix = `${field.label}: `\n if (line === undefined || !line.startsWith(prefix)) { valid = false; break }\n fields[field.id] = line.slice(prefix.length)\n }\n if (!valid) continue\n values.fields = fields\n }\n const inputs = viewInputs(card.view) as ViewNode[]\n if (inputs.length) {\n const pairs = rest.shift()?.split('; ')\n if (!pairs || pairs.length !== inputs.length) continue\n const sent: Record<string, unknown> = {}\n let valid = true\n for (let i = 0; i < inputs.length; i++) {\n const input = inputs[i], prefix = `${input.label || input.id}=`\n if (!pairs[i].startsWith(prefix)) { valid = false; break }\n const value = pairs[i].slice(prefix.length)\n if (input.type === 'toggle') sent[input.id!] = value === 'on' ? true : value === 'off' ? false : undefined\n else if (input.type === 'choice') {\n const choices = input.options?.filter(option => option.label === value) ?? []\n sent[input.id!] = choices.length === 1 ? choiceValue(choices[0]) : undefined\n } else {\n const unit = input.unit ? ` ${input.unit}` : ''\n sent[input.id!] = !unit || value.endsWith(unit) ? Number(unit ? value.slice(0, -unit.length) : value) : undefined\n }\n }\n if (!valid) continue\n values.inputs = sent\n }\n if (node.type === 'submit' && rest.shift() !== (node.label ?? 'Submit')) continue\n if (rest.length || !node.id) continue\n const checked = validateViewAnswer(card.view, node.id, values)\n if (checked.error === undefined && answerText(card, node.id, checked) === text) {\n candidates.push({ id: card.id, action: node.id, values: checked })\n }\n }\n return candidates.length === 1 ? candidates[0] : null\n}\n","import { randomUUID } from 'node:crypto'\nimport type { Context } from '@deepseek-ai/cordis'\nimport type { ObjectJsonSchema } from '@deepseek-ai/dsh-tools'\nimport { createUserMessage } from '@deepseek-ai/dsh-llm'\nimport { registerHostRpc, type HostRpcContext } from '@klarkxy/dsh-plugin-kit/host-rpc'\nimport { checkShownView, validateViewAnswer, viewSummary } from './core/index.js'\nimport { answerText } from './answer-text.ts'\nimport { RPC_CHANNEL, VIEW_OWNER, isRecord, type PendingView, type RpcResult, type ShownView, type ViewNode, type ViewPresentation, type ViewAnswerMetadata } from './contracts.ts'\n\nexport const name = 'deep-view'\nexport const inject = ['tools', 'sessionController', 'sessions', 'agents', 'connection', 'webServer'] as const\n\ntype AgentLike = {\n id: string\n session: unknown\n followup(message: ReturnType<typeof createUserMessage>): void\n}\n// The real `agents` service returns the runtime Agent type; our local narrow\n// shape cannot feed includes() against it, so compare by id.\nconst isLiveRoot = (host: Host, agent: AgentLike | undefined) => agent !== undefined && host.agents.roots().some(root => (root as unknown as AgentLike).id === agent.id)\ntype Host = Context & HostRpcContext & {\n tools: {\n get(name: string, scope?: object): unknown\n register(definition: Record<string, unknown>): () => void\n }\n agents: { get(id: string): AgentLike | undefined; roots(): AgentLike[] }\n sessionController: { resolveAgent(id: string): Promise<{ agent?: AgentLike; error?: { message?: string } }> }\n sessions: { flush(session: unknown): Promise<boolean> }\n logger?: { warn(message: string, ...args: unknown[]): void }\n}\nconst ok = <T,>(value: T): RpcResult<T> => ({ ok: true, value })\nconst fail = (code: string, message: string): RpcResult<never> => ({ ok: false, error: { code, message } })\nconst short = (value: unknown, max = 160): value is string => typeof value === 'string' && value.length > 0 && value.length <= max\nconst checkedShown = (title: unknown, view: unknown) => checkShownView(title, view) as ShownView | { error: string }\nconst isShown = (value: ShownView | { error: string }): value is ShownView => !('error' in value)\n\nfunction presentation(args: unknown, value: unknown): ViewPresentation | undefined {\n if (!isRecord(value) || value.owner !== VIEW_OWNER || !['shown', 'pending'].includes(String(value.status))) return undefined\n const shown = checkedShown(isRecord(args) ? args.title : undefined, isRecord(args) ? args.view : undefined)\n if (!isShown(shown)) return undefined\n return {\n owner: VIEW_OWNER, ...(short(value.viewId, 80) ? { viewId: value.viewId } : {}),\n ...shown, awaitReply: value.awaitReply === true,\n }\n}\n\nexport function createShowViewTool(host: Host, pending: Map<string, PendingView>, makeId: () => string = randomUUID): Record<string, unknown> {\n return {\n name: 'show_view',\n description: [\n 'Attach one card below your final reply when a visual or interactive form beats prose: compared numbers, a trend, a share, progress; an estimate with user-adjustable inputs; or a choice the user answers afterwards (use ask_user_question when you cannot continue without it).',\n 'Prefer plain Markdown otherwise. Call once, then finish the reply; the card is not yet visible when this tool returns.',\n 'Never end on the call, wait or poll, repeat the card JSON, or claim the user saw it. Answers accept one reply, sent as the next user message. Never collect keys, tokens or passwords.',\n ].join(' '),\n // tools.register() takes raw JSON Schema; the per-field DSL is only for defineTool().\n parameters: {\n type: 'object',\n properties: {\n title: { type: 'string', description: 'Short heading above the card.' },\n view: { type: 'object', additionalProperties: true, description: [\n 'One ViewNode, nodes nest under stack|row(children,let?).',\n 'Display: text,metric{label,value},table{columns:[{key,label}],rows:[[cell]]},chart{kind:bar|hbar|line|area|donut,categories,series:[{name?,values}]},progress{percent|value+max},callout{text},sources{items:[{label,url}]}.',\n 'Inputs: slider,number,choice,toggle{id,label,value}. A {\"=\":\"expr\"} formula replaces a value or cell, reading input ids and let names.',\n 'Answers(need await_reply true): options{id,options,multi?},confirm{id},form{id,fields},submit{id,label}. No html.',\n ].join(' ') },\n await_reply: { type: 'boolean', description: 'Whether this card asks the user for a response.' },\n },\n required: ['view'],\n } satisfies ObjectJsonSchema,\n output: {\n schema: { type: 'object', properties: { owner: { type: 'string', const: VIEW_OWNER }, status: { type: 'string' }, viewId: { type: 'string' }, awaitReply: { type: 'boolean' }, summary: { type: 'string' } }, required: ['owner', 'status', 'awaitReply', 'summary'], additionalProperties: false },\n render: (_args: unknown, value: { summary?: string }) => [{ type: 'text', text: String(value.summary ?? '') }],\n presentationMeta: presentation,\n },\n async execute(args: unknown, exec: { agent?: AgentLike; callId?: string; concludeTurn(): void }) {\n const input = isRecord(args) ? args : {}\n const shown = checkedShown(input.title, input.view)\n if (!isShown(shown)) return { owner: VIEW_OWNER, status: 'invalid', awaitReply: false, summary: shown.error }\n if (typeof input.await_reply !== 'undefined' && typeof input.await_reply !== 'boolean') {\n return { owner: VIEW_OWNER, status: 'invalid', awaitReply: false, summary: 'await_reply: expected true or false' }\n }\n const awaitReply = input.await_reply ?? shown.interactive\n if (awaitReply !== shown.interactive) {\n return { owner: VIEW_OWNER, status: 'invalid', awaitReply: false, summary: shown.interactive ? 'This card has answer controls; omit await_reply or set it true.' : 'A display-only card cannot wait for an answer; omit await_reply or set it false.' }\n }\n const id = exec.agent?.id\n const agent = id === undefined ? undefined : host.agents.get(id)\n if (awaitReply && !isLiveRoot(host, agent)) {\n return { owner: VIEW_OWNER, status: 'invalid', awaitReply: false, summary: 'An interactive view only works in a live root session. Put the question or decision in your response instead.' }\n }\n let viewId: string | undefined\n if (awaitReply && agent) {\n viewId = makeId()\n // set() alone replaces an earlier unanswered card: the old card becomes\n // stale and its pending record points at the newest view only.\n pending.set(agent.id, { id: viewId, sessionId: agent.id, ...(exec.callId ? { callId: exec.callId } : {}), ...shown })\n }\n return {\n owner: VIEW_OWNER, status: awaitReply ? 'pending' : 'shown', ...(viewId ? { viewId } : {}), awaitReply,\n // A tool result is process data. The completed-turn reply surface owns\n // the card, so the model must still produce its final answer.\n summary: `Card prepared for the final reply. Finish with a concise final answer; do not call this tool again for the same card.${awaitReply ? ' The user can answer the card after your reply finishes; do not wait or poll.' : ''} ${viewSummary(shown.view)}`,\n }\n },\n isConcurrencySafe: () => false,\n }\n}\n\nexport function createRpc(host: Host, pending: Map<string, PendingView>) {\n const claims = new Set<string>()\n return async (endpoint: string, payload: unknown, signal: AbortSignal): Promise<RpcResult> => {\n if (!isRecord(payload) || !short(payload.sessionId, 200)) return fail('bad-request', 'A bounded sessionId is required')\n const sessionId = payload.sessionId\n const record = pending.get(sessionId)\n if (endpoint === 'pending') return ok(record?.callId === payload.callId || payload.callId === undefined ? record ?? null : null)\n if (endpoint === 'dismiss') {\n if (record?.id === payload.viewId) pending.delete(sessionId)\n return ok(true)\n }\n if (endpoint !== 'reply') return fail('not-found', 'Unknown Deep View endpoint')\n if (!record || !short(payload.viewId, 80) || payload.viewId !== record.id || !short(payload.action, 160) || !isRecord(payload.values)) {\n return fail('stale', 'This view is no longer open')\n }\n if (claims.has(record.id)) return fail('busy', 'This view is already being answered')\n const checked = validateViewAnswer(record.view as ViewNode, payload.action, payload.values) as { error?: string } & Record<string, unknown>\n if (checked.error !== undefined) return fail('invalid', checked.error)\n claims.add(record.id)\n pending.delete(sessionId)\n // Exact-once: the record is restored only when followup never appended a\n // user message. Once appended, a failed checkpoint may lose the card from\n // disk, but re-adding the record would let a retry send the same user\n // answer a second time. Restoration lives in the finally so cancellation\n // returns, resolve failures and append failures share one path.\n let appended = false\n try {\n if (signal.aborted) return fail('cancelled', 'The request was cancelled')\n const resolved = await host.sessionController.resolveAgent(sessionId)\n const agent = resolved.agent\n if (!agent || host.agents.get(agent.id) !== agent || !host.agents.roots().some(root => (root as unknown as AgentLike).id === agent.id)) throw new Error(resolved.error?.message ?? 'The session is not a live root session')\n if (signal.aborted) return fail('cancelled', 'The request was cancelled')\n // Text and answer facts share one durable message: neither can survive\n // without the other, and fork/history boundaries preserve their pairing.\n const deepView: ViewAnswerMetadata = {\n owner: VIEW_OWNER, version: 1,\n answer: { id: record.id, action: payload.action, values: checked },\n }\n agent.followup(createUserMessage({\n content: [{ type: 'text', text: answerText(record, payload.action, checked) }],\n source: { kind: 'user', deepView },\n }))\n appended = true\n await host.sessions.flush(agent.session)\n return ok({ answered: true })\n } catch (error) {\n return fail('internal', error instanceof Error ? error.message : String(error))\n } finally {\n if (!appended && !pending.has(sessionId)) pending.set(sessionId, record)\n claims.delete(record.id)\n }\n }\n}\n\nexport async function apply(ctx: Context): Promise<void> {\n const host = ctx as unknown as Host\n const pending = new Map<string, PendingView>()\n ctx.effect(() => {\n if (host.tools.get('show_view')) {\n host.logger?.warn('deep-view: show_view is already registered by another plugin; this bundle stays disabled for its own tool')\n return () => {}\n }\n try {\n return host.tools.register(createShowViewTool(host, pending))\n }\n catch (error) {\n host.logger?.warn('deep-view: show_view registration skipped: %s', error instanceof Error ? error.message : String(error))\n return () => {}\n }\n }, 'deep-view.tool')\n // Only admission events are observed, never scanned. A new human message closes a stale card.\n ctx.effect(() => ctx.on('session/event', (session: { id: string }, event: { type: string; data?: unknown }) => {\n if (event.type !== 'user/message' || !isRecord(event.data) || !isRecord(event.data.source) || event.data.source.kind !== 'user') return\n pending.delete(session.id)\n }), 'deep-view.close-pending')\n ctx.effect(() => registerHostRpc(host, RPC_CHANNEL, createRpc(host, pending), { maxBodyBytes: 24 * 1024 }), 'deep-view.rpc')\n}\n"],"mappings":";;;;;AAwBA,SAAgB,yBACd,KACA,SACA,UACA,UAAmC,CAAC,GACxB;CACZ,MAAM,YAAY,QAAQ,gBAAgB;CAC1C,IAAI,CAAC,OAAO,cAAc,SAAS,KAAK,aAAa,GAAG,MAAM,IAAI,MAAM,wBAAwB;CAChG,MAAM,aAAa,QAAQ,gBAAgB,aAAqB,YAAY,KAAK,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AAS,kBAAkB,CAACA,WAAS,MAAM,IAAI,KAAK,CAACA,WAAS,MAAM,KAAK,MAAM,KAAK,MAAM,KAAK,OAAO,SAAS,QAAQ;EACjI,QAAQ,OAAO,QAAQ,EAAE;CAC3B,CAAC,GAAG,yBAAyB;CAC7B,IAAI,aAAa,gBAAgB,MAAM,aAAa,UAAU,MAAM,OAAO,GAAG,EAAE,cAAc,MAAU,CAAC,GAAG,eAAe;AAC7H"}
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Deep View reply cards",
4
+ "description": "Charts, metrics, tables and safe local inputs in replies, with validated answers to show_view cards."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Deep View 回复卡片",
4
+ "description": "在回复中展示图表、指标、表格和安全联动的本地输入;show_view 可接收已校验的用户回答。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,129 @@
1
1
  {
2
2
  "name": "@klarkxy/dsh-deep-view",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Declarative reply cards with charts, safe formulas, local inputs and validated show_view answers.",
5
+ "icon": "./icon.svg",
6
+ "license": "Apache-2.0",
7
+ "type": "module",
8
+ "engines": {
9
+ "node": ">=22",
10
+ "dsh": ">=0.2.1-rc.1"
11
+ },
12
+ "main": "./lib/index.js",
13
+ "types": "./lib/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./lib/index.d.ts",
17
+ "import": "./lib/index.js",
18
+ "default": "./lib/index.js"
19
+ },
20
+ "./client": {
21
+ "default": "./lib/client.js"
22
+ },
23
+ "./contracts": {
24
+ "types": "./lib/contracts.d.ts",
25
+ "import": "./lib/contracts.js",
26
+ "default": "./lib/contracts.js"
27
+ },
28
+ "./icon": "./icon.svg",
29
+ "./package.json": "./package.json",
30
+ "./locale/*.json": "./locale/*.json"
31
+ },
32
+ "files": [
33
+ "lib",
34
+ "icon.svg",
35
+ "locale/*.json",
36
+ "cordis.patch.yml",
37
+ "README.md",
38
+ "docs/README.zh-CN.md",
39
+ "LICENSE",
40
+ "NOTICE"
41
+ ],
42
+ "dsh": {
43
+ "bundle": {
44
+ "patch": "./cordis.patch.yml"
45
+ },
46
+ "client": {
47
+ "platform": "web",
48
+ "inject": [
49
+ "@deepseek-ai/dsh-client-connection",
50
+ "@deepseek-ai/dsh-client-locale",
51
+ "@deepseek-ai/dsh-client-ui-slots",
52
+ "@deepseek-ai/dsh-client-ui-session",
53
+ "@deepseek-ai/dsh-client-ui-conversation",
54
+ "@deepseek-ai/dsh-client-ui-chat",
55
+ "@deepseek-ai/dsh-client-ui-primitives"
56
+ ]
57
+ }
58
+ },
59
+ "scripts": {
60
+ "build": "tsdown && node ../../scripts/editor-plugins/wrap-client.mjs @klarkxy/dsh-deep-view",
61
+ "typecheck": "tsc --noEmit -p tsconfig.json",
62
+ "test": "vitest run --root ../.. --config vitest.editor-plugins.config.ts --maxWorkers=2 plugins/dsh-deep-view/src"
63
+ },
64
+ "dependencies": {
65
+ "@klarkxy/dsh-plugin-kit": "0.7.0"
66
+ },
67
+ "peerDependencies": {
68
+ "@deepseek-ai/cordis": ">=4.0.4",
69
+ "@deepseek-ai/dsh-agent": ">=0.2.1-rc.1",
70
+ "@deepseek-ai/dsh-llm": ">=0.2.1-rc.1",
71
+ "@deepseek-ai/dsh-session": ">=0.2.1-rc.1",
72
+ "@deepseek-ai/dsh-tools": ">=0.2.1-rc.1"
73
+ },
74
+ "peerDependenciesMeta": {
75
+ "@deepseek-ai/cordis": {
76
+ "optional": true
77
+ },
78
+ "@deepseek-ai/dsh-agent": {
79
+ "optional": true
80
+ },
81
+ "@deepseek-ai/dsh-llm": {
82
+ "optional": true
83
+ },
84
+ "@deepseek-ai/dsh-session": {
85
+ "optional": true
86
+ },
87
+ "@deepseek-ai/dsh-tools": {
88
+ "optional": true
89
+ }
90
+ },
91
+ "devDependencies": {
92
+ "@deepseek-ai/cordis": "4.1.0",
93
+ "@deepseek-ai/dsh-agent": "0.2.2-rc.1",
94
+ "@deepseek-ai/dsh-llm": "0.2.2-rc.1",
95
+ "@deepseek-ai/dsh-session": "0.2.2-rc.1",
96
+ "@deepseek-ai/dsh-tools": "0.2.2-rc.1",
97
+ "@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.1",
98
+ "react": "^18.2.0",
99
+ "react-dom": "^18.2.0",
100
+ "@types/react": "18.3.31",
101
+ "@types/react-dom": "^18.3.0",
102
+ "jsdom": "29.1.1",
103
+ "@types/jsdom": "28.0.3"
104
+ },
105
+ "keywords": [
106
+ "dsh",
107
+ "dsh-plugin",
108
+ "deepseek-harness-plugin",
109
+ "charts",
110
+ "widgets",
111
+ "markdown"
112
+ ],
113
+ "repository": {
114
+ "type": "git",
115
+ "url": "git+https://github.com/klarkxy/dsh-plugins.git",
116
+ "directory": "plugins/dsh-deep-view"
117
+ },
118
+ "homepage": "https://klarkxy.github.io/dsh-plugins/plugins/deep-view/",
119
+ "bugs": {
120
+ "url": "https://github.com/klarkxy/dsh-plugins/issues"
121
+ },
122
+ "publishConfig": {
123
+ "access": "public",
124
+ "registry": "https://registry.npmjs.org/"
125
+ },
126
+ "dshRelease": {
127
+ "contentHash": "aa0c363195c43ebf5463bb71ea25419006a692bc84da768af76b6f2e826b2f20"
128
+ }
129
+ }