@nelsonlongxiang/dsh-prompt-templates 0.2.8

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":"client.js","names":["css","IconSendOutline16","IconGlobeOutline14","IconEditOutline16","IconTrashOutline16","IconPlusOutline16","css","#actions","#pendingAutoOpen","#sessions","#conversation","#require","#inputOf"],"sources":["client/api.js","client/Panel.js","client/PanelButton.js","client/store.js","client/service.js","client/locales.js","client/index.js"],"sourcesContent":["/**\n * Browser-side API over the host's `/plugins/dsh-prompt-templates` routes.\n * One fetch helper per verb; every response settles into the same\n * `{ ok: true; value } | { ok: false; error }` envelope the panel face\n * consumes, so callers never see transport details.\n */\nconst BASE = '/plugins/dsh-prompt-templates';\n/** Load the full template set (global + every session's). */\nexport async function listTemplates() {\n const response = await fetch(`${BASE}/templates`, { cache: 'no-store' });\n if (!response.ok)\n return [];\n const body = await response.json();\n return [...body.items ?? []];\n}\n/** Create one template. */\nexport async function createTemplate(request) {\n return mutate('POST', '/templates', request);\n}\n/** Patch one template by id. */\nexport async function updateTemplate(id, request) {\n return mutate('PATCH', `/templates/${encodeURIComponent(id)}`, request);\n}\n/** Promote one session template to the global partition. */\nexport async function makeTemplateGlobal(id) {\n return mutate('POST', `/templates/${encodeURIComponent(id)}/make-global`, {});\n}\n/** Delete one template by id. */\nexport async function deleteTemplate(id) {\n return mutate('DELETE', `/templates/${encodeURIComponent(id)}`);\n}\n/** Run one mutating request and settle it into the action envelope. */\nasync function mutate(method, path, body) {\n try {\n const response = await fetch(`${BASE}${path}`, {\n method,\n headers: body === undefined ? undefined : { 'content-type': 'application/json' },\n body: body === undefined ? undefined : JSON.stringify(body),\n cache: 'no-store',\n });\n if (!response.ok) {\n const payload = await response.json().catch(() => null);\n return {\n ok: false,\n error: payload?.error ?? { code: `http:${response.status}`, message: response.statusText },\n };\n }\n return { ok: true, value: await response.json().catch(() => undefined) };\n }\n catch (error) {\n return { ok: false, error: { code: 'network-error', message: String(error) } };\n }\n}\n","import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\n/**\n * Quick prompt panel: the right-anchored floating surface registered into\n * shell.overlay. Lists global templates plus the current session's private\n * ones; clicking a row inserts its content into the composer draft. The\n * injected face carries the CRUD verbs and insert; the panel store holds\n * visibility; the current session arrives through the standard kit.\n */\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { IconEditOutline16, IconGlobeOutline14, IconPlusOutline16, IconSendOutline16, IconTrashOutline16 } from '@deepseek-ai/dsh-client-ui-primitives';\nimport css from './Panel.module.css';\nfunction TemplateRow({ template, onInsert, onSend, onEdit, onDelete, onMakeGlobal, t }) {\n return (_jsxs(\"div\", { className: css.row, \"data-prompt-template\": true, children: [_jsxs(\"button\", { type: \"button\", className: css.insert, onClick: () => { onInsert(template.content); }, title: t('panel.insert'), children: [_jsx(\"span\", { className: css.name, children: template.name }), _jsx(\"span\", { className: css.preview, children: template.content })] }), _jsx(\"button\", { type: \"button\", className: css.sendBtn, onClick: () => { onSend(template.content); }, \"aria-label\": t('panel.sendNow'), title: t('panel.sendNow'), children: _jsx(IconSendOutline16, { size: 12 }) }), onMakeGlobal !== undefined && (_jsx(\"button\", { type: \"button\", className: css.globalBtn, onClick: () => { onMakeGlobal(template.id); }, \"aria-label\": t('panel.makeGlobal'), title: t('panel.makeGlobal'), children: _jsx(IconGlobeOutline14, { size: 12 }) })), _jsx(\"button\", { type: \"button\", className: css.editBtn, onClick: () => { onEdit(template.id); }, \"aria-label\": t('panel.edit'), title: t('panel.edit'), children: _jsx(IconEditOutline16, { size: 12 }) }), _jsx(\"button\", { type: \"button\", className: css.deleteBtn, onClick: () => { onDelete(template.id); }, \"aria-label\": t('panel.delete'), children: _jsx(IconTrashOutline16, { size: 12 }) })] }));\n}\n/** The template inline form: creation (with scope picker) and in-place edit. */\nfunction TemplateForm({ initial, allowScope, sessionId, t, submitLabel, onSubmit, onDone }) {\n const [name, setName] = useState(initial?.name ?? '');\n const [content, setContent] = useState(initial?.content ?? '');\n const [scope, setScope] = useState('global');\n const [busy, setBusy] = useState(false);\n const [error, setError] = useState(null);\n const submit = useCallback(async () => {\n const trimmedName = name.trim();\n const trimmedContent = content.trim();\n if (trimmedName === '' || trimmedContent === '')\n return;\n if (allowScope && scope === 'session' && sessionId === null) {\n setError(t('panel.error'));\n return;\n }\n setBusy(true);\n setError(null);\n const ok = await onSubmit(trimmedName, trimmedContent, scope);\n setBusy(false);\n if (!ok) {\n setError(t('panel.error'));\n return;\n }\n onDone();\n }, [name, content, scope, allowScope, sessionId, onSubmit, t, onDone]);\n return (_jsxs(\"div\", { className: css.addForm, \"data-prompt-add\": true, children: [_jsx(\"input\", { className: css.nameInput, type: \"text\", placeholder: t('panel.addName'), value: name, onChange: (e) => { setName(e.target.value); }, \"aria-label\": t('panel.addName') }), _jsx(\"textarea\", { className: css.contentInput, placeholder: t('panel.addContent'), value: content, onChange: (e) => { setContent(e.target.value); }, rows: 3, \"aria-label\": t('panel.addContent') }), _jsxs(\"div\", { className: css.addRow, children: [allowScope && (_jsx(\"label\", { className: css.scopeLabel, children: _jsxs(\"select\", { value: scope, onChange: (e) => { setScope(e.target.value); }, \"aria-label\": \"scope\", children: [_jsx(\"option\", { value: \"global\", children: t('panel.global') }), _jsx(\"option\", { value: \"session\", disabled: sessionId === null, children: t('panel.session') })] }) })), _jsxs(\"div\", { className: css.addActions, children: [error !== null && _jsx(\"span\", { className: css.error, role: \"alert\", children: error }), _jsx(\"button\", { type: \"button\", className: css.saveBtn, onClick: () => void submit(), disabled: busy || name.trim() === '' || content.trim() === '', children: submitLabel })] })] })] }));\n}\n/**\n * The prompt-templates panel body.\n * @param props - runtime kit, injected face members, store handle, and locale.\n */\nexport function PromptPanel(props) {\n const { useStore, useSessions, refresh, create, update, remove, makeGlobal, insert, send, panelPosition, savePanelPosition, resetPanelPosition, actions, t, } = props;\n const open = useStore(s => s.open);\n const currentSession = useSessions(s => s.current);\n const [templates, setTemplates] = useState([]);\n const [showAdd, setShowAdd] = useState(false);\n // Live search filter over name + content, case-insensitive.\n const [query, setQuery] = useState('');\n // In-place editing: the id whose row swaps to the edit form, null = none.\n const [editingId, setEditingId] = useState(null);\n // Drag placement: seeded from the persisted position, live-updated while\n // dragging, committed to the settings document on release. A null with no\n // drag in flight keeps the CSS right-anchored default.\n const persisted = panelPosition();\n const [dragPos, setDragPos] = useState(null);\n const dragRef = useRef(null);\n const panelRef = useRef(null);\n const sessionId = currentSession ?? null;\n const load = useCallback(async () => {\n const items = await refresh();\n setTemplates(items);\n }, [refresh]);\n useEffect(() => {\n if (open)\n void load();\n }, [open, load]);\n const handleInsert = useCallback((content) => {\n if (sessionId === null)\n return;\n insert(sessionId, content);\n }, [insert, sessionId]);\n const handleSend = useCallback((content) => {\n if (sessionId === null)\n return;\n send(sessionId, content);\n }, [send, sessionId]);\n const handleRemove = useCallback(async (id) => {\n const result = await remove(id);\n if (result.ok)\n void load();\n }, [remove, load]);\n const handleMakeGlobal = useCallback(async (id) => {\n const result = await makeGlobal(id);\n if (result.ok)\n void load();\n }, [makeGlobal, load]);\n // Drag-by-header: capture the pointer, track the offset, clamp so the\n // header always stays reachable inside the viewport, commit on release.\n const onHeaderPointerDown = (event) => {\n if (event.button !== 0)\n return;\n const target = event.target;\n if (target.closest('button'))\n return;\n const panel = panelRef.current;\n if (panel === null)\n return;\n const rect = panel.getBoundingClientRect();\n dragRef.current = { pointerId: event.pointerId, offX: event.clientX - rect.left, offY: event.clientY - rect.top };\n // jsdom lacks the pointer-capture API; feature-detect before using it.\n if (Reflect.has(event.currentTarget, 'setPointerCapture')) {\n event.currentTarget.setPointerCapture(event.pointerId);\n }\n };\n const onHeaderPointerMove = (event) => {\n const drag = dragRef.current;\n if (drag === null || event.pointerId !== drag.pointerId)\n return;\n const width = panelRef.current?.getBoundingClientRect().width ?? 320;\n const maxX = Math.max(0, window.innerWidth - width);\n const maxY = Math.max(0, window.innerHeight - 40);\n const x = Math.min(Math.max(event.clientX - drag.offX, 0), maxX);\n const y = Math.min(Math.max(event.clientY - drag.offY, 0), maxY);\n setDragPos({ x, y });\n };\n const onHeaderPointerUp = (event) => {\n const drag = dragRef.current;\n if (drag === null || event.pointerId !== drag.pointerId)\n return;\n dragRef.current = null;\n if (Reflect.has(event.currentTarget, 'releasePointerCapture')) {\n event.currentTarget.releasePointerCapture(event.pointerId);\n }\n if (dragPos !== null)\n savePanelPosition(dragPos);\n };\n // Double-click the header to forget the placement and re-anchor right.\n const onHeaderDoubleClick = () => {\n setDragPos(null);\n resetPanelPosition();\n };\n if (!open)\n return null;\n // The full set is loaded; group here — a server-side session filter would\n // hide global rows (their session_id is NULL and never matches). The search\n // query narrows both groups by name + content, case-insensitive.\n const needle = query.trim().toLowerCase();\n const matches = (row) => needle === ''\n || row.name.toLowerCase().includes(needle)\n || row.content.toLowerCase().includes(needle);\n const globalRows = templates.filter(row => row.scope === 'global' && matches(row));\n /** One list row: the edit form while being edited, the rendered row otherwise. */\n const renderTemplateRow = (row) => (editingId === row.id\n ? (_jsx(TemplateForm, { initial: { name: row.name, content: row.content }, allowScope: false, sessionId: sessionId, t: t, submitLabel: t('panel.addSave'), onSubmit: async (name, content) => (await update(row.id, { name, content })).ok, onDone: () => { setEditingId(null); void load(); } }, row.id))\n : (_jsx(TemplateRow, { template: row, onInsert: (c) => { handleInsert(c); }, onSend: (c) => { handleSend(c); }, onEdit: (id) => { setEditingId(id); }, onDelete: (id) => { void handleRemove(id); }, onMakeGlobal: row.scope === 'session' ? (id) => { void handleMakeGlobal(id); } : undefined, t: t }, row.id)));\n const sessionRows = templates.filter(row => row.scope === 'session' && row.session_id === sessionId && matches(row));\n const placement = dragPos ?? persisted;\n const placementStyle = placement === null\n ? undefined\n : { left: placement.x, top: placement.y, right: 'auto', bottom: 'auto' };\n return (_jsxs(\"div\", { className: css.panel, \"data-prompt-panel\": true, ref: panelRef, style: placementStyle, children: [_jsxs(\"div\", { className: css.header, title: t('panel.dragHint'), onPointerDown: onHeaderPointerDown, onPointerMove: onHeaderPointerMove, onPointerUp: onHeaderPointerUp, onDoubleClick: onHeaderDoubleClick, children: [_jsx(\"span\", { className: css.title, children: t('panel.title') }), _jsx(\"button\", { type: \"button\", className: css.closeBtn, onClick: () => { actions.close(); }, \"aria-label\": t('panel.close'), children: \"\\u00D7\" })] }), _jsx(\"div\", { className: css.searchBar, children: _jsx(\"input\", { type: \"search\", className: css.searchInput, value: query, onChange: (e) => { setQuery(e.target.value); }, placeholder: t('panel.search'), \"aria-label\": t('panel.search') }) }), _jsxs(\"div\", { className: css.body, children: [templates.length === 0 && !showAdd && (_jsx(\"div\", { className: css.empty, children: t('panel.empty') })), templates.length > 0 && needle !== '' && globalRows.length === 0 && sessionRows.length === 0 && (_jsx(\"div\", { className: css.empty, children: t('panel.noMatch') })), globalRows.length > 0 && (_jsxs(\"div\", { className: css.group, children: [_jsx(\"div\", { className: css.groupTitle, children: t('panel.global') }), globalRows.map(row => renderTemplateRow(row))] })), sessionRows.length > 0 && sessionId !== null && (_jsxs(\"div\", { className: css.group, children: [_jsx(\"div\", { className: css.groupTitle, children: t('panel.session') }), sessionRows.map(row => renderTemplateRow(row))] })), showAdd && (_jsx(TemplateForm, { sessionId: sessionId, t: t, allowScope: true, submitLabel: t('panel.addSave'), onSubmit: async (name, content, scope) => {\n const result = await create({\n name,\n content,\n scope,\n session_id: scope === 'session' ? sessionId : null,\n });\n return result.ok;\n }, onDone: () => { setShowAdd(false); void load(); } }))] }), _jsx(\"div\", { className: css.footer, children: _jsxs(\"button\", { type: \"button\", className: css.addBtn, onClick: () => { setShowAdd(v => !v); }, children: [_jsx(IconPlusOutline16, { size: 12 }), \" \", t('panel.add')] }) })] }));\n}\n","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport css from './PanelButton.module.css';\n/**\n * The composer tool-row button.\n * @param props - runtime kit (includes the InputZone owner share), the toggle verb, and the locale seat.\n */\nexport function PanelButton({ toggle, t }) {\n return (_jsx(\"button\", { type: \"button\", className: css.button, onClick: toggle, \"aria-label\": t('panel.open'), \"aria-pressed\": \"false\", title: t('panel.title'), children: _jsx(\"span\", { className: css.glyph, children: \"\\u25A4\" }) }));\n}\n","/**\n * Panel store owned by the shell.overlay entry: the open flag plus the\n * ever-opened marker. The composer button reaches the same state through\n * ctx.promptPanel (the controller holds the entry's bound actions); inserts\n * go through the controller's session-input path, never this store. The\n * ever-opened marker lets the settings-driven default-open apply exactly\n * once: any manual toggle or open marks the panel user-owned, so a late\n * settings load can never reopen what the user closed.\n *\n * Module level exports the factory only (de-facto singleton prohibition —\n * see ui-layout's store).\n */\nimport { defineStore } from '@deepseek-ai/dsh-client-runtime/client';\n/**\n * Complete write set for the panel.\n * @returns the store handle (spec + type + identity + factory in one).\n */\nexport function createPromptPanelStore() {\n const handle = defineStore({\n init: () => ({ open: false, everOpened: false }),\n actions: {\n toggle: (d) => {\n d.everOpened = true;\n d.open = !d.open;\n },\n open: (d) => {\n d.everOpened = true;\n d.open = true;\n },\n close: (d) => {\n d.everOpened = true;\n d.open = false;\n },\n // One-shot settings-driven default open: a no-op once the user has\n // ever touched the panel (either direction).\n openOnce: (d) => {\n if (d.everOpened)\n return;\n d.everOpened = true;\n d.open = true;\n },\n },\n });\n return handle;\n}\n","/**\n * Cross-entry panel face (ctx.promptPanel).\n */\nexport class PromptPanelController {\n #actions;\n #sessions;\n #conversation;\n #pendingAutoOpen = false;\n /**\n * Adopt the shell.overlay entry's bound store actions. Called from that\n * registration's inject hook; a re-register overwrites the stale set. A\n * default-open that arrived before the entry's first render is applied\n * here, once wiring exists.\n * @param actions - bound actions of the panel store instance.\n */\n attach(actions) {\n this.#actions = actions;\n if (this.#pendingAutoOpen) {\n this.#pendingAutoOpen = false;\n actions.openOnce();\n }\n }\n /**\n * Bind the session-scope resolution services needed for inserts.\n * @param deps - sessions and conversation services from the plugin closure.\n */\n bind(deps) {\n this.#sessions = deps.sessions;\n this.#conversation = deps.conversation;\n }\n /** Flip the panel open/closed. */\n toggle() {\n this.#require().toggle();\n }\n /**\n * Apply the settings-driven default open, at most once per store lifetime\n * and never after any user interaction with the panel. Before the entry's\n * first render the request parks as pending and attach() replays it.\n */\n openOnce() {\n if (this.#actions === undefined) {\n this.#pendingAutoOpen = true;\n return;\n }\n this.#actions.openOnce();\n }\n /**\n * Append one template's content to a session's composer draft. An empty\n * draft takes the content verbatim; a non-empty draft joins with a newline.\n * @param sessionId - target session.\n * @param content - template content.\n */\n insert(sessionId, content) {\n const input = this.#inputOf(sessionId);\n if (input === undefined)\n return;\n const draft = input.state.getSnapshot().draft;\n input.setDraft(draft === '' ? content : `${draft}\\n${content}`);\n }\n /**\n * Fill the draft with one template's content and submit it immediately —\n * the same transaction as typing the text and pressing send.\n * @param sessionId - target session.\n * @param content - template content.\n */\n send(sessionId, content) {\n const input = this.#inputOf(sessionId);\n if (input === undefined)\n return;\n input.setDraft(content);\n input.submit();\n }\n /** Resolve a session's input facade, or undefined when out of reach. */\n #inputOf(sessionId) {\n const sessions = this.#sessions;\n const conversation = this.#conversation;\n if (sessions === undefined || conversation === undefined)\n return undefined;\n const actx = sessions.scope(sessionId);\n if (actx === undefined)\n return undefined;\n return conversation.input.for(actx);\n }\n #require() {\n if (this.#actions === undefined) {\n throw new Error('prompt-panel: panel actions not wired (shell.overlay entry not mounted)');\n }\n return this.#actions;\n }\n}\n","/** Locale keys for the prompt-templates surface. */\n/** Chinese dictionary. */\nexport const zh = {\n 'panel.title': '快捷提示词',\n 'panel.dragHint': '拖动移动,双击复位',\n 'panel.sendNow': '直接发送',\n 'panel.open': '打开提示词面板',\n 'panel.close': '关闭提示词面板',\n 'panel.empty': '暂无模板',\n 'panel.search': '搜索模板…',\n 'panel.noMatch': '没有匹配的模板',\n 'panel.global': '全局模板',\n 'panel.session': '会话模板',\n 'panel.add': '新增',\n 'panel.addName': '模板名称',\n 'panel.addContent': '模板内容',\n 'panel.addSave': '保存',\n 'panel.addCancel': '取消',\n 'panel.insert': '插入',\n 'panel.delete': '删除',\n 'panel.edit': '编辑',\n 'panel.makeGlobal': '设为全局',\n 'panel.error': '操作失败',\n 'panel.inserted': '已插入',\n 'panel.none': '无',\n};\n/** English dictionary. */\nexport const en = {\n 'panel.title': 'Quick prompts',\n 'panel.dragHint': 'Drag to move, double-click to reset',\n 'panel.sendNow': 'Send now',\n 'panel.open': 'Open prompt panel',\n 'panel.close': 'Close prompt panel',\n 'panel.empty': 'No templates yet',\n 'panel.search': 'Search templates…',\n 'panel.noMatch': 'No matching templates',\n 'panel.global': 'Global templates',\n 'panel.session': 'Session templates',\n 'panel.add': 'Add',\n 'panel.addName': 'Template name',\n 'panel.addContent': 'Template content',\n 'panel.addSave': 'Save',\n 'panel.addCancel': 'Cancel',\n 'panel.insert': 'Insert',\n 'panel.delete': 'Delete',\n 'panel.edit': 'Edit',\n 'panel.makeGlobal': 'Make global',\n 'panel.error': 'Operation failed',\n 'panel.inserted': 'Inserted',\n 'panel.none': 'None',\n};\n","import { listTemplates, createTemplate, updateTemplate, deleteTemplate, makeTemplateGlobal, } from \"./api.js\";\nimport { PromptPanel } from \"./Panel.js\";\nimport { PanelButton } from \"./PanelButton.js\";\nimport { createPromptPanelStore } from \"./store.js\";\nimport { PromptPanelController } from \"./service.js\";\nimport { en, zh } from \"./locales.js\";\nexport { PromptPanel } from \"./Panel.js\";\nexport { PanelButton } from \"./PanelButton.js\";\nexport { PromptPanelController } from \"./service.js\";\n/** Dictionary namespace owned by this plugin. */\nconst NS = 'promptTemplates';\n/** Required services: slots, sessions, locale, conversation, and settings scope. */\nexport const inject = ['slots', 'sessions', 'locale', 'conversation', 'settingsScope'];\n/**\n * Client plugin body: the shell.overlay panel owns the store; the controller\n * bridges its actions to the composer entry and performs inserts.\n * @param ctx - client root context.\n */\nexport function apply(ctx) {\n ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'ui-prompt-templates: dictionaries');\n const controller = new PromptPanelController();\n controller.bind({ sessions: ctx.sessions, conversation: ctx.conversation });\n ctx.effect(() => ctx.reflect.provide('promptPanel', controller), 'ui-prompt-templates: panel service');\n const uiSettings = ctx.settingsScope.bind({ namespace: 'prompt-templates' });\n // The panel's business face, created exactly once: the `refresh` identity\n // feeds the panel's load-effect dependency array, so a fresh object per\n // inject evaluation would loop the effect. refresh pulls EVERYTHING and\n // the component groups rows — a server-side session_id filter would hide\n // the global rows (their session_id is NULL and never matches).\n const panelFace = {\n refresh: listTemplates,\n create: (request) => {\n return createTemplate(request);\n },\n update: (id, request) => {\n return updateTemplate(id, request);\n },\n remove: (id) => {\n return deleteTemplate(id);\n },\n makeGlobal: (id) => {\n return makeTemplateGlobal(id);\n },\n insert: (sessionId, content) => {\n controller.insert(sessionId, content);\n },\n send: (sessionId, content) => {\n controller.send(sessionId, content);\n },\n panelPosition: () => {\n const snapshot = uiSettings.getSnapshot();\n if (snapshot.status !== 'ready')\n return null;\n const panel = snapshot.value?.panel;\n if (panel === undefined)\n return null;\n return typeof panel.x === 'number' && typeof panel.y === 'number' ? panel : null;\n },\n savePanelPosition: (position) => {\n void uiSettings.set('panel', { x: Math.round(position.x), y: Math.round(position.y) });\n },\n resetPanelPosition: () => {\n void uiSettings.unset('panel');\n },\n };\n // Settings-driven default open: applied once per store lifetime, only\n // while the user has never touched the panel. The scope is a snapshot\n // source, so the subscription re-checks when the host document lands (the\n // initial read usually races the settings transport). Before the entry\n // renders, openOnce parks the request and attach() replays it.\n const applyDefaultOpen = () => {\n const snapshot = uiSettings.getSnapshot();\n if (snapshot.status === 'ready' && snapshot.value?.defaultOpen === true) {\n controller.openOnce();\n }\n };\n ctx.effect(() => {\n const unsubscribe = uiSettings.subscribe(applyDefaultOpen);\n return () => { unsubscribe(); };\n }, 'ui-prompt-templates: default-open watch');\n applyDefaultOpen();\n // The shell.overlay entry: root scope, owns the panel store; the inject\n // hook hands the bound actions to the controller and the shared face.\n ctx.slots.inject('shell.overlay', () => ctx.slots.register({\n name: 'shell.overlay',\n id: 'prompt-templates',\n order: 10,\n locale: NS,\n store: createPromptPanelStore,\n inject: (actions) => {\n // attach is a side effect on the controller; the face is the data verbs.\n controller.attach(actions);\n return panelFace;\n },\n }, PromptPanel));\n // The composer entry: session scope, toggles the panel via the controller.\n ctx.slots.inject('conversation.input.right', () => ctx.slots.register({\n name: 'conversation.input.right',\n id: 'prompt-templates',\n order: 10,\n locale: NS,\n inject: () => ({\n toggle: () => { controller.toggle(); },\n }),\n }, PanelButton));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;EAMA,MAAM,OAAO;;EAEb,eAAsB,gBAAgB;GAClC,MAAM,WAAW,MAAM,MAAM,GAAG,KAAK,aAAa,EAAE,OAAO,WAAW,CAAC;GACvE,IAAI,CAAC,SAAS,IACV,OAAO,CAAC;GAEZ,OAAO,CAAC,IAAG,MADQ,SAAS,KAAK,EAAA,CACjB,SAAS,CAAC,CAAC;EAC/B;;EAEA,eAAsB,eAAe,SAAS;GAC1C,OAAO,OAAO,QAAQ,cAAc,OAAO;EAC/C;;EAEA,eAAsB,eAAe,IAAI,SAAS;GAC9C,OAAO,OAAO,SAAS,cAAc,mBAAmB,EAAE,KAAK,OAAO;EAC1E;;EAEA,eAAsB,mBAAmB,IAAI;GACzC,OAAO,OAAO,QAAQ,cAAc,mBAAmB,EAAE,EAAE,eAAe,CAAC,CAAC;EAChF;;EAEA,eAAsB,eAAe,IAAI;GACrC,OAAO,OAAO,UAAU,cAAc,mBAAmB,EAAE,GAAG;EAClE;;EAEA,eAAe,OAAO,QAAQ,MAAM,MAAM;GACtC,IAAI;IACA,MAAM,WAAW,MAAM,MAAM,GAAG,OAAO,QAAQ;KAC3C;KACA,SAAS,SAAS,KAAA,IAAY,KAAA,IAAY,EAAE,gBAAgB,mBAAmB;KAC/E,MAAM,SAAS,KAAA,IAAY,KAAA,IAAY,KAAK,UAAU,IAAI;KAC1D,OAAO;IACX,CAAC;IACD,IAAI,CAAC,SAAS,IAEV,OAAO;KACH,IAAI;KACJ,QAAO,MAHW,SAAS,KAAK,CAAC,CAAC,YAAY,IAAI,EAA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YAAY,OAAO,MAAM,MAAM,WAAW,QAAQ;IAChF;IACA,oBAAoB,aAAa;KAC7B,WAAgB,IAAI,SAAS;MAAE,GAAG,KAAK,MAAM,SAAS,CAAC;MAAG,GAAG,KAAK,MAAM,SAAS,CAAC;KAAE,CAAC;IACzF;IACA,0BAA0B;KACtB,WAAgB,MAAM,OAAO;IACjC;GACJ;GAMA,MAAM,yBAAyB;IAC3B,MAAM,WAAW,WAAW,YAAY;IACxC,IAAI,SAAS,WAAW,WAAW,SAAS,OAAO,gBAAgB,MAC/D,WAAW,SAAS;GAE5B;GACA,IAAI,aAAa;IACb,MAAM,cAAc,WAAW,UAAU,gBAAgB;IACzD,aAAa;KAAE,YAAY;IAAG;GAClC,GAAG,yCAAyC;GAC5C,iBAAiB;GAGjB,IAAI,MAAM,OAAO,uBAAuB,IAAI,MAAM,SAAS;IACvD,MAAM;IACN,IAAI;IACJ,OAAO;IACP,QAAQ;IACR,OAAO;IACP,SAAS,YAAY;KAEjB,WAAW,OAAO,OAAO;KACzB,OAAO;IACX;GACJ,GAAG,WAAW,CAAC;GAEf,IAAI,MAAM,OAAO,kCAAkC,IAAI,MAAM,SAAS;IAClE,MAAM;IACN,IAAI;IACJ,OAAO;IACP,QAAQ;IACR,eAAe,EACX,cAAc;KAAE,WAAW,OAAO;IAAG,EACzC;GACJ,GAAG,WAAW,CAAC;EACnB"}
package/lib/index.js ADDED
@@ -0,0 +1,180 @@
1
+ /**
2
+ * dsh-prompt-templates host half: spawns the Python backend child through
3
+ * the subprocess seam and exposes template CRUD over web-server routes the
4
+ * browser panel fetches (`/plugins/dsh-prompt-templates/*`). The Python
5
+ * child owns all durable state; this plugin owns the child process, the
6
+ * routes, and the settings namespace (panel default-open + placement).
7
+ *
8
+ * Route map (JSON bodies, `Cache-Control: no-store`):
9
+ * GET /plugins/dsh-prompt-templates/templates → { items }
10
+ * POST /plugins/dsh-prompt-templates/templates → { template }
11
+ * GET /plugins/dsh-prompt-templates/templates/:id → { template } | 404
12
+ * PATCH /plugins/dsh-prompt-templates/templates/:id → { template } | 404
13
+ * POST /plugins/dsh-prompt-templates/templates/:id/make-global → { template } | 404
14
+ * DELETE /plugins/dsh-prompt-templates/templates/:id → { deleted }
15
+ *
16
+ * @module dsh-prompt-templates
17
+ */
18
+ import s from '@deepseek-ai/schemastery';
19
+ import { settingsNamespace } from '@deepseek-ai/dsh-settings';
20
+ import { DEFAULT_EOF_GRACE_MS, PythonBridgeError, resolveEofGrace } from '@nelsonlongxiang/dsh-python-bridge';
21
+ export const name = 'prompt-templates';
22
+ /** Spawns the Python child through the pythonBridge service; the web-server route registration waits for it lazily. */
23
+ export const inject = ['pythonBridge'];
24
+ export const Config = s.object({
25
+ command: s.array(s.string()).required(),
26
+ cwd: s.string(),
27
+ eofGraceMs: s.number(),
28
+ dbPath: s.string(),
29
+ });
30
+ /** Web-server service key candidates, newest first. */
31
+ const WEB_SERVER_KEYS = ['webServer', 'httpServer'];
32
+ /**
33
+ * Host plugin body: lazily register the web routes once the web server and
34
+ * this plugin's pythonBridge service are both live; headless profiles without a
35
+ * web server never block boot.
36
+ * @param ctx - Host context carrying the pythonBridge service.
37
+ * @param config - validated spawn facts for the Python backend.
38
+ */
39
+ export function apply(ctx, config) {
40
+ const resolved = {
41
+ command: [...config.command],
42
+ cwd: config.cwd ?? process.cwd(),
43
+ eofGraceMs: resolveEofGrace(config.eofGraceMs ?? DEFAULT_EOF_GRACE_MS, 'prompt-templates'),
44
+ dbPath: config.dbPath ?? undefined,
45
+ };
46
+ let bridge;
47
+ const client = () => {
48
+ if (bridge === undefined) {
49
+ bridge = ctx.pythonBridge.create({
50
+ argv: resolved.dbPath === undefined
51
+ ? [...resolved.command]
52
+ : [...resolved.command, '--db', resolved.dbPath],
53
+ cwd: resolved.cwd,
54
+ eofGraceMs: resolved.eofGraceMs,
55
+ });
56
+ }
57
+ return bridge;
58
+ };
59
+ ctx.effect(() => () => { void bridge?.dispose(); }, 'prompt-templates: python bridge teardown');
60
+ // Browser preference namespace (panel default-open and remembered
61
+ // position), optional: without a mounted settings provider the client
62
+ // scope simply reports unavailable.
63
+ ctx.inject(['settings'], (settingsCtx) => {
64
+ settingsCtx.settings.register(settingsNamespace('prompt-templates'), s.object({
65
+ defaultOpen: s.boolean().default(false),
66
+ panel: s.object({ x: s.number(), y: s.number() }),
67
+ }));
68
+ });
69
+ let routesRegistered = false;
70
+ const registerRoutes = () => {
71
+ if (routesRegistered)
72
+ return;
73
+ const webServer = (ctx.get(WEB_SERVER_KEYS[0]) ?? ctx.get(WEB_SERVER_KEYS[1]));
74
+ if (webServer === undefined)
75
+ return;
76
+ routesRegistered = true;
77
+ ctx.effect(() => webServer.register({
78
+ kind: 'prefix',
79
+ path: '/plugins/dsh-prompt-templates',
80
+ handler: (req, res) => { void handle(req, res, client); },
81
+ }), 'prompt-templates: api routes');
82
+ };
83
+ registerRoutes();
84
+ ctx.on('internal/service', (serviceName) => {
85
+ if (WEB_SERVER_KEYS.includes(serviceName)) {
86
+ registerRoutes();
87
+ }
88
+ });
89
+ }
90
+ /** Dispatch one API request against the Python child. */
91
+ async function handle(req, res, client) {
92
+ const url = new URL(req.url ?? '/', 'http://x');
93
+ const segments = url.pathname.split('/').filter(part => part !== '');
94
+ // Expect ['plugins', 'dsh-prompt-templates', 'templates', ...rest].
95
+ const rest = segments.slice(3);
96
+ const method = req.method ?? 'GET';
97
+ try {
98
+ if (rest.length === 0 && method === 'GET') {
99
+ const items = await client().call('templates/list', {});
100
+ return json(res, 200, { items });
101
+ }
102
+ if (rest.length === 0 && method === 'POST') {
103
+ const body = await readJson(req);
104
+ const template = await client().call('templates/create', body);
105
+ return json(res, 200, { template });
106
+ }
107
+ const id = rest[0];
108
+ if (id === undefined)
109
+ return json(res, 400, errorBody('bad-request', 'missing template id'));
110
+ if (rest.length === 1 && method === 'GET') {
111
+ const template = await client().call('templates/get', { id });
112
+ if (template === null)
113
+ return json(res, 404, notFound(id));
114
+ return json(res, 200, { template });
115
+ }
116
+ if (rest.length === 1 && method === 'PATCH') {
117
+ const body = await readJson(req);
118
+ const template = await client().call('templates/update', { id, ...body });
119
+ if (template === null)
120
+ return json(res, 404, notFound(id));
121
+ return json(res, 200, { template });
122
+ }
123
+ if (rest.length === 2 && rest[1] === 'make-global' && method === 'POST') {
124
+ const template = await client().call('templates/make_global', { id });
125
+ if (template === null)
126
+ return json(res, 404, notFound(id));
127
+ return json(res, 200, { template });
128
+ }
129
+ if (rest.length === 1 && method === 'DELETE') {
130
+ const deleted = await client().call('templates/delete', { id });
131
+ return json(res, 200, { deleted });
132
+ }
133
+ return json(res, 405, errorBody('method-not-allowed', `${method} ${url.pathname}`));
134
+ }
135
+ catch (error) {
136
+ if (error instanceof PythonBridgeError) {
137
+ return json(res, 502, errorBody(`python:${String(error.code)}`, error.message));
138
+ }
139
+ const message = error instanceof Error ? error.message : String(error);
140
+ return json(res, 500, errorBody('bridge-error', message));
141
+ }
142
+ }
143
+ /** Read and parse one JSON request body. */
144
+ function readJson(req) {
145
+ return new Promise((resolve, reject) => {
146
+ const chunks = [];
147
+ req.on('data', (chunk) => { chunks.push(chunk); });
148
+ req.on('end', () => {
149
+ if (chunks.length === 0) {
150
+ resolve({});
151
+ return;
152
+ }
153
+ try {
154
+ const parsed = JSON.parse(Buffer.concat(chunks).toString('utf8'));
155
+ resolve(typeof parsed === 'object' && parsed !== null ? parsed : {});
156
+ }
157
+ catch (error) {
158
+ reject(error);
159
+ }
160
+ });
161
+ req.on('error', reject);
162
+ });
163
+ }
164
+ /** Write one JSON response with no-store caching. */
165
+ function json(res, status, body) {
166
+ const payload = JSON.stringify(body);
167
+ res.writeHead(status, {
168
+ 'content-type': 'application/json; charset=utf-8',
169
+ 'cache-control': 'no-store',
170
+ });
171
+ res.end(payload);
172
+ }
173
+ /** The not-found envelope for one template id. */
174
+ function notFound(id) {
175
+ return errorBody('not-found', `template ${id} not found`);
176
+ }
177
+ /** The business error envelope. */
178
+ function errorBody(code, message) {
179
+ return { error: { code, message } };
180
+ }
@@ -0,0 +1,11 @@
1
+ /** Package-owned invariant companion. @module dsh-prompt-templates/invariant */
2
+ const PACKAGE_NAME = 'dsh-prompt-templates';
3
+ /** Cordis companion plugin name. */
4
+ export const name = 'prompt-templates-invariant';
5
+ /** Service required before the companion can reserve package ownership. */
6
+ export const inject = ['invariants'];
7
+ /** No runtime invariant: the durable truth lives in the Python SQLite backend. */
8
+ const install = () => { };
9
+ /** Register this package's invariant companion. */
10
+ export const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
11
+ /* jscpd:ignore-end */
@@ -0,0 +1,10 @@
1
+ import { PropsLocale, PropsRuntime, PropsStore } from '@deepseek-ai/dsh-client-ui-slots';
2
+ import type { PromptPanelFace } from './slots.ts';
3
+ import { createPromptPanelStore } from './store.ts';
4
+ /** Full props of the shell.overlay panel entry. */
5
+ export type PromptPanelProps = PropsRuntime<'shell.overlay'> & PromptPanelFace & PropsStore<ReturnType<typeof createPromptPanelStore>> & PropsLocale<'promptTemplates'>;
6
+ /**
7
+ * The prompt-templates panel body.
8
+ * @param props - runtime kit, injected face members, store handle, and locale.
9
+ */
10
+ export declare function PromptPanel(props: PromptPanelProps): import("react").JSX.Element | null;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Composer entry button: toggles the quick prompt panel. Registered into
3
+ * conversation.input.right (the tool row, before the send button). The
4
+ * session-scoped inject face carries the toggle verb, which routes through
5
+ * ctx.promptPanel to the panel's store.
6
+ */
7
+ import { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
8
+ import type { PromptPanelToggleFace } from './slots.ts';
9
+ /** Full props of the composer entry. */
10
+ export type PanelButtonProps = PropsRuntime<'conversation.input.right'> & PromptPanelToggleFace & PropsLocale<'promptTemplates'>;
11
+ /**
12
+ * The composer tool-row button.
13
+ * @param props - runtime kit (includes the InputZone owner share), the toggle verb, and the locale seat.
14
+ */
15
+ export declare function PanelButton({ toggle, t }: PanelButtonProps): import("react").JSX.Element;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Browser-side API over the host's `/plugins/dsh-prompt-templates` routes.
3
+ * One fetch helper per verb; every response settles into the same
4
+ * `{ ok: true; value } | { ok: false; error }` envelope the panel face
5
+ * consumes, so callers never see transport details.
6
+ */
7
+ import type { TemplateView } from '../types.ts';
8
+ /** Business error carried by a failed call. */
9
+ export interface TemplateError {
10
+ readonly code: string;
11
+ readonly message: string;
12
+ }
13
+ /** Settled outcome of one template mutation. */
14
+ export type TemplateActionResult = {
15
+ readonly ok: true;
16
+ readonly value: unknown;
17
+ } | {
18
+ readonly ok: false;
19
+ readonly error: TemplateError;
20
+ };
21
+ /** Load the full template set (global + every session's). */
22
+ export declare function listTemplates(): Promise<TemplateView[]>;
23
+ /** Create one template. */
24
+ export declare function createTemplate(request: {
25
+ name: string;
26
+ content: string;
27
+ scope: 'global' | 'session';
28
+ session_id: string | null;
29
+ }): Promise<TemplateActionResult>;
30
+ /** Patch one template by id. */
31
+ export declare function updateTemplate(id: string, request: {
32
+ name?: string;
33
+ content?: string;
34
+ description?: string | null;
35
+ }): Promise<TemplateActionResult>;
36
+ /** Promote one session template to the global partition. */
37
+ export declare function makeTemplateGlobal(id: string): Promise<TemplateActionResult>;
38
+ /** Delete one template by id. */
39
+ export declare function deleteTemplate(id: string): Promise<TemplateActionResult>;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Quick prompt templates plugin, browser half: the shell.overlay panel and
3
+ * the composer entry that toggles it and inserts template content into the
4
+ * draft. Data flows through the host's `/plugins/dsh-prompt-templates`
5
+ * HTTP routes; panel transitions and inserts route through ctx.promptPanel
6
+ * (the controller holds the panel entry's bound store actions). The panel
7
+ * face is created ONCE per apply — a per-render face object would mint
8
+ * fresh `refresh` identities on every inject evaluation, invalidating the
9
+ * panel's load callback and re-running its effect in a loop. The
10
+ * settings-driven default-open rides the promptTemplates settings
11
+ * namespace (absent when the host exposes no settings document — the panel
12
+ * then just starts closed).
13
+ */
14
+ import type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client';
15
+ import { type IPromptPanel } from './service.ts';
16
+ import { type PromptTemplateKey } from './locales.ts';
17
+ export { PromptPanel } from './Panel.tsx';
18
+ export { PanelButton } from './PanelButton.tsx';
19
+ export { PromptPanelController } from './service.ts';
20
+ export type { PromptPanelProps } from './Panel.tsx';
21
+ export type { PanelButtonProps } from './PanelButton.tsx';
22
+ export type { PromptPanelFace, PromptPanelToggleFace } from './slots.ts';
23
+ export type { IPromptPanel } from './service.ts';
24
+ declare module '@deepseek-ai/cordis' {
25
+ interface Context {
26
+ /** Cross-entry panel face: toggle + insert + settings-driven default open. */
27
+ promptPanel: IPromptPanel;
28
+ }
29
+ }
30
+ declare module '@deepseek-ai/dsh-client-ui-slots' {
31
+ interface LocaleNamespaceMap {
32
+ /** The quick-prompt panel and composer entry copy. */
33
+ promptTemplates: PromptTemplateKey;
34
+ }
35
+ }
36
+ /** Required services: slots, sessions, locale, conversation, and settings scope. */
37
+ export declare const inject: string[];
38
+ /**
39
+ * Client plugin body: the shell.overlay panel owns the store; the controller
40
+ * bridges its actions to the composer entry and performs inserts.
41
+ * @param ctx - client root context.
42
+ */
43
+ export declare function apply(ctx: ClientContext): void;
@@ -0,0 +1,53 @@
1
+ /** Locale keys for the prompt-templates surface. */
2
+ /** Chinese dictionary. */
3
+ export declare const zh: {
4
+ readonly 'panel.title': "快捷提示词";
5
+ readonly 'panel.dragHint': "拖动移动,双击复位";
6
+ readonly 'panel.sendNow': "直接发送";
7
+ readonly 'panel.open': "打开提示词面板";
8
+ readonly 'panel.close': "关闭提示词面板";
9
+ readonly 'panel.empty': "暂无模板";
10
+ readonly 'panel.search': "搜索模板…";
11
+ readonly 'panel.noMatch': "没有匹配的模板";
12
+ readonly 'panel.global': "全局模板";
13
+ readonly 'panel.session': "会话模板";
14
+ readonly 'panel.add': "新增";
15
+ readonly 'panel.addName': "模板名称";
16
+ readonly 'panel.addContent': "模板内容";
17
+ readonly 'panel.addSave': "保存";
18
+ readonly 'panel.addCancel': "取消";
19
+ readonly 'panel.insert': "插入";
20
+ readonly 'panel.delete': "删除";
21
+ readonly 'panel.edit': "编辑";
22
+ readonly 'panel.makeGlobal': "设为全局";
23
+ readonly 'panel.error': "操作失败";
24
+ readonly 'panel.inserted': "已插入";
25
+ readonly 'panel.none': "无";
26
+ };
27
+ /** English dictionary. */
28
+ export declare const en: {
29
+ readonly 'panel.title': "Quick prompts";
30
+ readonly 'panel.dragHint': "Drag to move, double-click to reset";
31
+ readonly 'panel.sendNow': "Send now";
32
+ readonly 'panel.open': "Open prompt panel";
33
+ readonly 'panel.close': "Close prompt panel";
34
+ readonly 'panel.empty': "No templates yet";
35
+ readonly 'panel.search': "Search templates…";
36
+ readonly 'panel.noMatch': "No matching templates";
37
+ readonly 'panel.global': "Global templates";
38
+ readonly 'panel.session': "Session templates";
39
+ readonly 'panel.add': "Add";
40
+ readonly 'panel.addName': "Template name";
41
+ readonly 'panel.addContent': "Template content";
42
+ readonly 'panel.addSave': "Save";
43
+ readonly 'panel.addCancel': "Cancel";
44
+ readonly 'panel.insert': "Insert";
45
+ readonly 'panel.delete': "Delete";
46
+ readonly 'panel.edit': "Edit";
47
+ readonly 'panel.makeGlobal': "Make global";
48
+ readonly 'panel.error': "Operation failed";
49
+ readonly 'panel.inserted': "Inserted";
50
+ readonly 'panel.none': "None";
51
+ };
52
+ /** Key union of the prompt-templates dictionary. */
53
+ export type PromptTemplateKey = keyof typeof zh;
@@ -0,0 +1,72 @@
1
+ /**
2
+ * PromptPanelController: the cross-entry panel face behind ctx.promptPanel.
3
+ * The open state lives in the shell.overlay entry's panel store; this
4
+ * service exposes the transitions other entries trigger (the composer
5
+ * button's toggle) and the insert handoff (the panel requests an insert,
6
+ * this controller writes the session draft through the conversation input
7
+ * resolver). Writes stay inside the store's declared action set, delivered
8
+ * as the registration's bound actions.
9
+ */
10
+ import type { BoundActions } from '@deepseek-ai/dsh-client-ui-slots';
11
+ import type { ClientContext, SessionId, ISessions } from '@deepseek-ai/dsh-client-runtime/client';
12
+ import type { createPromptPanelStore } from './store.ts';
13
+ /** The panel store's bound action set (framework-baked, draft params peeled). */
14
+ export type PromptPanelActions = BoundActions<ReturnType<typeof createPromptPanelStore>>;
15
+ /** The outward prompt-panel face (`ctx.promptPanel`). */
16
+ export interface IPromptPanel {
17
+ /** Flip the panel open/closed. */
18
+ toggle(): void;
19
+ /** Insert one template's content into a session's composer draft. */
20
+ insert(sessionId: SessionId, content: string): void;
21
+ /** Fill the draft with one template's content and submit it immediately. */
22
+ send(sessionId: SessionId, content: string): void;
23
+ /**
24
+ * Apply the settings-driven default open, at most once per store lifetime
25
+ * and never after any user interaction with the panel.
26
+ */
27
+ openOnce(): void;
28
+ }
29
+ /**
30
+ * Cross-entry panel face (ctx.promptPanel).
31
+ */
32
+ export declare class PromptPanelController implements IPromptPanel {
33
+ #private;
34
+ /**
35
+ * Adopt the shell.overlay entry's bound store actions. Called from that
36
+ * registration's inject hook; a re-register overwrites the stale set. A
37
+ * default-open that arrived before the entry's first render is applied
38
+ * here, once wiring exists.
39
+ * @param actions - bound actions of the panel store instance.
40
+ */
41
+ attach(actions: PromptPanelActions): void;
42
+ /**
43
+ * Bind the session-scope resolution services needed for inserts.
44
+ * @param deps - sessions and conversation services from the plugin closure.
45
+ */
46
+ bind(deps: {
47
+ sessions: ISessions;
48
+ conversation: ClientContext['conversation'];
49
+ }): void;
50
+ /** Flip the panel open/closed. */
51
+ toggle(): void;
52
+ /**
53
+ * Apply the settings-driven default open, at most once per store lifetime
54
+ * and never after any user interaction with the panel. Before the entry's
55
+ * first render the request parks as pending and attach() replays it.
56
+ */
57
+ openOnce(): void;
58
+ /**
59
+ * Append one template's content to a session's composer draft. An empty
60
+ * draft takes the content verbatim; a non-empty draft joins with a newline.
61
+ * @param sessionId - target session.
62
+ * @param content - template content.
63
+ */
64
+ insert(sessionId: SessionId, content: string): void;
65
+ /**
66
+ * Fill the draft with one template's content and submit it immediately —
67
+ * the same transaction as typing the text and pressing send.
68
+ * @param sessionId - target session.
69
+ * @param content - template content.
70
+ */
71
+ send(sessionId: SessionId, content: string): void;
72
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Injected faces of the prompt-templates entries. The panel slot
3
+ * ('shell.overlay') is root-scoped, so its inject factory receives no
4
+ * session id — the component reads the current session through the standard
5
+ * kit. The composer entry ('conversation.input.right') is session-scoped and
6
+ * carries the panel toggle.
7
+ */
8
+ import type { TemplateActionResult } from './api.ts';
9
+ import type { TemplateView } from '../types.ts';
10
+ /** One template row the panel renders (the backend record). */
11
+ export type { TemplateView };
12
+ export type { TemplateActionResult };
13
+ /** Persisted panel placement in viewport pixels. */
14
+ export interface PanelPosition {
15
+ readonly x: number;
16
+ readonly y: number;
17
+ }
18
+ /** The panel's injected business face: CRUD verbs + refresh + insert + placement. */
19
+ export interface PromptPanelFace {
20
+ /** Load the full template set (global + every session's); the component groups rows. */
21
+ refresh: () => Promise<TemplateView[]>;
22
+ /** Create one template. */
23
+ create: (request: {
24
+ name: string;
25
+ content: string;
26
+ scope: 'global' | 'session';
27
+ session_id: string | null;
28
+ }) => Promise<TemplateActionResult>;
29
+ /** Patch one template by id (name/content/description). */
30
+ update: (id: string, request: {
31
+ name?: string;
32
+ content?: string;
33
+ description?: string | null;
34
+ }) => Promise<TemplateActionResult>;
35
+ /** Delete one template by id. */
36
+ remove: (id: string) => Promise<TemplateActionResult>;
37
+ /** Promote one session template to the global partition. */
38
+ makeGlobal: (id: string) => Promise<TemplateActionResult>;
39
+ /** The persisted panel placement; null = the right-anchored default. */
40
+ panelPosition: () => PanelPosition | null;
41
+ /** Persist the dragged placement (write-through to the settings document). */
42
+ savePanelPosition: (position: PanelPosition) => void;
43
+ /** Forget the placement and return to the right-anchored default. */
44
+ resetPanelPosition: () => void;
45
+ /** Append the content to the session's composer draft. */
46
+ insert: (sessionId: string, content: string) => void;
47
+ /** Fill the draft and submit it immediately (same as pressing send). */
48
+ send: (sessionId: string, content: string) => void;
49
+ }
50
+ /** The composer entry's injected face: toggle the panel. */
51
+ export interface PromptPanelToggleFace {
52
+ /** Flip the panel open/closed. */
53
+ toggle: () => void;
54
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Panel store owned by the shell.overlay entry: the open flag plus the
3
+ * ever-opened marker. The composer button reaches the same state through
4
+ * ctx.promptPanel (the controller holds the entry's bound actions); inserts
5
+ * go through the controller's session-input path, never this store. The
6
+ * ever-opened marker lets the settings-driven default-open apply exactly
7
+ * once: any manual toggle or open marks the panel user-owned, so a late
8
+ * settings load can never reopen what the user closed.
9
+ *
10
+ * Module level exports the factory only (de-facto singleton prohibition —
11
+ * see ui-layout's store).
12
+ */
13
+ import { type EngineStoreHandle } from '@deepseek-ai/dsh-client-runtime/client';
14
+ /** Panel state: open flag plus the one-shot default-open marker. */
15
+ type PromptPanelState = {
16
+ open: boolean;
17
+ everOpened: boolean;
18
+ };
19
+ /**
20
+ * Complete write set for the panel.
21
+ * @returns the store handle (spec + type + identity + factory in one).
22
+ */
23
+ export declare function createPromptPanelStore(): EngineStoreHandle<PromptPanelState, PromptPanelActions>;
24
+ /** Action type of the panel store (the exported annotation twin). */
25
+ export type PromptPanelActions = {
26
+ toggle: (draft: PromptPanelState) => void;
27
+ open: (draft: PromptPanelState) => void;
28
+ close: (draft: PromptPanelState) => void;
29
+ openOnce: (draft: PromptPanelState) => void;
30
+ };
31
+ export {};