@tangle-network/agent-app 0.33.1 → 0.35.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.
@@ -111,6 +111,16 @@ interface VaultDockRenderProps {
111
111
  open: boolean;
112
112
  onClose: () => void;
113
113
  }
114
+ /** Configures the dock toggle VaultPane renders above the artifact pane. */
115
+ interface VaultDockToggle {
116
+ /** Button + aria label (e.g. 'Discuss', 'Review'). */
117
+ label: string;
118
+ /** Tooltip when enabled. Defaults to `label`. */
119
+ title?: string;
120
+ /** Disable the toggle while the open file has unsaved edits — a chat dock wants
121
+ * this (save before discussing); a review panel does not. Default true. */
122
+ disabledWhenDirty?: boolean;
123
+ }
114
124
  /** The two editor surfaces the pane switches between for editable text files. */
115
125
  type VaultEditorMode = 'rich' | 'source';
116
126
  interface VaultPaneProps {
@@ -122,6 +132,15 @@ interface VaultPaneProps {
122
132
  renderArtifact: (props: VaultArtifactRenderProps) => ReactNode;
123
133
  /** Renders an optional right dock (agent chat, metadata, …). Omit to hide. */
124
134
  renderDock?: (props: VaultDockRenderProps) => ReactNode;
135
+ /** Dock toggle config, or `false` for a PERSISTENT dock (no toggle, always open
136
+ * with the selected file) — e.g. a domain review panel. Default: a collapsible
137
+ * 'Discuss' chat toggle disabled while the file is dirty. */
138
+ dockToggle?: VaultDockToggle | false;
139
+ /** Bump (counter or string) to force the pane to re-list the tree + re-read the
140
+ * open file after an out-of-band change (an upload, an accepted edit). */
141
+ refreshKey?: number | string;
142
+ /** Extra controls rendered in the tree-pane header (e.g. an upload button). */
143
+ headerActions?: ReactNode;
125
144
  /**
126
145
  * When false, all write affordances (create / delete / save / source editor)
127
146
  * are hidden and the pane is read-only. Defaults to true.
@@ -138,4 +157,4 @@ interface VaultPaneProps {
138
157
 
139
158
  declare function VaultPane(props: VaultPaneProps): react.JSX.Element;
140
159
 
141
- export { type VaultArtifactRenderProps as V, type VaultDataPort as a, type VaultDockRenderProps as b, type VaultEditorMode as c, type VaultFile as d, type VaultMarkdownCodec as e, VaultPane as f, type VaultPaneProps as g, type VaultRichParts as h, type VaultTreeNode as i, type VaultTreeRenderProps as j };
160
+ export { type VaultArtifactRenderProps as V, type VaultDataPort as a, type VaultDockRenderProps as b, type VaultDockToggle as c, type VaultEditorMode as d, type VaultFile as e, type VaultMarkdownCodec as f, VaultPane as g, type VaultPaneProps as h, type VaultRichParts as i, type VaultTreeNode as j, type VaultTreeRenderProps as k };
@@ -0,0 +1,7 @@
1
+ import {
2
+ VaultPane
3
+ } from "./chunk-IITUMDKF.js";
4
+ export {
5
+ VaultPane
6
+ };
7
+ //# sourceMappingURL=VaultPane-YCMQBRIB.js.map
@@ -183,11 +183,16 @@ function VaultPane(props) {
183
183
  selectedPath: controlledPath,
184
184
  onSelectedPathChange,
185
185
  codec,
186
- className
186
+ className,
187
+ dockToggle,
188
+ refreshKey,
189
+ headerActions
187
190
  } = props;
188
191
  const activeCodec = codec ?? IDENTITY_CODEC;
189
192
  const controlled = controlledPath !== void 0;
190
193
  const isMarkdownCapable = codec !== void 0;
194
+ const persistentDock = dockToggle === false;
195
+ const dockToggleCfg = dockToggle ? dockToggle : { label: "Discuss", disabledWhenDirty: true };
191
196
  const [tree, setTree] = useState([]);
192
197
  const [treeLoading, setTreeLoading] = useState(true);
193
198
  const [internalPath, setInternalPath] = useState(null);
@@ -231,7 +236,7 @@ function VaultPane(props) {
231
236
  }, [port]);
232
237
  useEffect2(() => {
233
238
  void refresh();
234
- }, [refresh]);
239
+ }, [refresh, refreshKey]);
235
240
  useEffect2(() => {
236
241
  if (!selectedPath) {
237
242
  setSelectedFile(null);
@@ -255,7 +260,7 @@ function VaultPane(props) {
255
260
  return () => {
256
261
  cancelled = true;
257
262
  };
258
- }, [port, selectedPath]);
263
+ }, [port, selectedPath, refreshKey]);
259
264
  useEffect2(() => {
260
265
  if (!selectedFile) {
261
266
  loadedPathRef.current = null;
@@ -389,6 +394,7 @@ function VaultPane(props) {
389
394
  ] })
390
395
  ] }),
391
396
  /* @__PURE__ */ jsxs2("div", { className: "flex shrink-0 items-center gap-1", children: [
397
+ headerActions,
392
398
  /* @__PURE__ */ jsx2(
393
399
  "button",
394
400
  {
@@ -447,17 +453,17 @@ function VaultPane(props) {
447
453
  }
448
454
  )
449
455
  ] }),
450
- renderDock && /* @__PURE__ */ jsx2(
456
+ renderDock && !persistentDock && /* @__PURE__ */ jsx2(
451
457
  "button",
452
458
  {
453
459
  type: "button",
454
- "aria-label": "Discuss with agent",
460
+ "aria-label": dockToggleCfg.label,
455
461
  "aria-pressed": dockOpen,
456
- disabled: isDirty,
457
- title: isDirty ? "Save before discussing with agent" : "Discuss with agent",
462
+ disabled: (dockToggleCfg.disabledWhenDirty ?? true) && isDirty,
463
+ title: (dockToggleCfg.disabledWhenDirty ?? true) && isDirty ? "Save your changes first" : dockToggleCfg.title ?? dockToggleCfg.label,
458
464
  onClick: () => setDockOpen((v) => !v),
459
465
  className: `inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs transition-colors disabled:pointer-events-none disabled:opacity-40 ${dockOpen ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:bg-muted hover:text-foreground"}`,
460
- children: "Discuss"
466
+ children: dockToggleCfg.label
461
467
  }
462
468
  ),
463
469
  canWrite && /* @__PURE__ */ jsx2(
@@ -496,8 +502,9 @@ function VaultPane(props) {
496
502
  ] }),
497
503
  renderDock && selectedFile && renderDock({
498
504
  file: selectedFile,
499
- open: dockOpen,
500
- onClose: () => setDockOpen(false)
505
+ open: persistentDock ? true : dockOpen,
506
+ onClose: persistentDock ? () => {
507
+ } : () => setDockOpen(false)
501
508
  }),
502
509
  /* @__PURE__ */ jsx2(
503
510
  ConfirmDialog,
@@ -594,4 +601,4 @@ export {
594
601
  ConfirmDialog,
595
602
  VaultPane
596
603
  };
597
- //# sourceMappingURL=chunk-FNUEUOOZ.js.map
604
+ //# sourceMappingURL=chunk-IITUMDKF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/vault/VaultPane.tsx","../src/vault/ConfirmDialog.tsx"],"sourcesContent":["/**\n * The shared 3-pane vault: tree | artifact viewer | optional agent dock. This is\n * pure shell MECHANISM — selection, the dirty-guard + pending-nav state machine,\n * rich/source editor modes, create/delete/refresh, skeletons, an error boundary,\n * and an empty state. It renders NO file tree and NO artifact viewer of its own:\n * those arrive through the `renderTree` / `renderArtifact` / `renderDock` seams,\n * so a product wires sandbox-ui's RichFileTree + FileArtifactPane in ~10 lines.\n *\n * Data flows exclusively through `port` (a `VaultDataPort`). The pane never\n * imports a fetch client, a router, a toast system, or a markdown library — the\n * optional `codec` seam supplies rich/source parsing (identity passthrough by\n * default). Chrome uses the shared theme tokens (bg-card, border-border, …).\n */\n\nimport {\n Component,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ErrorInfo,\n type ReactNode,\n} from 'react'\nimport { ConfirmDialog } from './ConfirmDialog'\nimport type {\n VaultEditorMode,\n VaultFile,\n VaultMarkdownCodec,\n VaultPaneProps,\n VaultRichParts,\n VaultTreeNode,\n} from './contracts'\n\nconst IDENTITY_CODEC: VaultMarkdownCodec = {\n parse: (raw) => raw,\n serialize: (parts) => (typeof parts === 'string' ? parts : String(parts ?? '')),\n}\n\ntype PendingNav = { type: 'open'; path: string } | { type: 'close' } | null\n\nfunction collectFilePaths(nodes: VaultTreeNode[], into: Set<string>): Set<string> {\n for (const node of nodes) {\n if (node.type === 'file') into.add(node.path)\n if (node.children) collectFilePaths(node.children, into)\n }\n return into\n}\n\nfunction countFiles(nodes: VaultTreeNode[]): number {\n return nodes.reduce(\n (sum, node) => (node.type === 'file' ? sum + 1 : sum + countFiles(node.children ?? [])),\n 0,\n )\n}\n\nclass EditorErrorBoundary extends Component<{ children: ReactNode; onReset?: () => void }, { error: unknown }> {\n state: { error: unknown } = { error: null }\n static getDerivedStateFromError(error: unknown) {\n return { error }\n }\n componentDidCatch(error: unknown, info: ErrorInfo) {\n console.error('Vault crashed:', error, info)\n }\n render() {\n if (this.state.error) {\n const msg = this.state.error instanceof Error\n ? this.state.error.message\n : typeof this.state.error === 'string'\n ? this.state.error\n : 'Something went wrong loading the vault'\n return (\n <div className=\"flex h-full flex-1 flex-col items-center justify-center p-8 text-center\">\n <h3 className=\"mb-1 text-sm font-medium text-foreground\">Vault failed to load</h3>\n <p className=\"mb-4 max-w-xs text-xs text-muted-foreground\">{String(msg)}</p>\n <button\n type=\"button\"\n onClick={() => { this.setState({ error: null }); this.props.onReset?.() }}\n className=\"inline-flex h-8 items-center rounded-md border border-border px-3 text-xs font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/60\"\n >\n Try again\n </button>\n </div>\n )\n }\n return this.props.children\n }\n}\n\nfunction TreeSkeleton() {\n return (\n <div className=\"space-y-2 p-4\" aria-hidden=\"true\">\n {[32, 48, 40, 52].map((w, i) => (\n <div key={i} className=\"h-4 animate-pulse rounded bg-muted\" style={{ width: `${w * 4}px` }} />\n ))}\n </div>\n )\n}\n\nfunction EditorSkeleton() {\n return (\n <div className=\"space-y-3 p-8\" aria-hidden=\"true\">\n <div className=\"h-5 w-1/2 animate-pulse rounded bg-muted\" />\n <div className=\"h-4 w-full animate-pulse rounded bg-muted\" />\n <div className=\"h-4 w-3/4 animate-pulse rounded bg-muted\" />\n <div className=\"h-4 w-2/3 animate-pulse rounded bg-muted\" />\n </div>\n )\n}\n\nfunction EmptyState() {\n return (\n <div className=\"flex h-full flex-col items-center justify-center p-8 text-center\">\n <h3 className=\"text-sm font-medium text-foreground\">Open a vault document</h3>\n <p className=\"mt-1 max-w-xs text-xs text-muted-foreground\">\n Select a file from the directory, or create a new one.\n </p>\n </div>\n )\n}\n\nexport function VaultPane(props: VaultPaneProps) {\n const {\n port,\n renderTree,\n renderArtifact,\n renderDock,\n canWrite = true,\n selectedPath: controlledPath,\n onSelectedPathChange,\n codec,\n className,\n dockToggle,\n refreshKey,\n headerActions,\n } = props\n\n const activeCodec = codec ?? IDENTITY_CODEC\n const controlled = controlledPath !== undefined\n const isMarkdownCapable = codec !== undefined\n // `false` → a persistent dock (no toggle, always open with the selected file).\n const persistentDock = dockToggle === false\n const dockToggleCfg = dockToggle ? dockToggle : { label: 'Discuss', disabledWhenDirty: true }\n\n const [tree, setTree] = useState<VaultTreeNode[]>([])\n const [treeLoading, setTreeLoading] = useState(true)\n const [internalPath, setInternalPath] = useState<string | null>(null)\n const selectedPath = controlled ? (controlledPath ?? null) : internalPath\n\n const [selectedFile, setSelectedFile] = useState<VaultFile | null>(null)\n const [fileLoading, setFileLoading] = useState(false)\n const [saving, setSaving] = useState(false)\n\n const [editorMode, setEditorMode] = useState<VaultEditorMode>('rich')\n const [richDraft, setRichDraft] = useState<VaultRichParts>('')\n const [sourceDraft, setSourceDraft] = useState('')\n const [isDirty, setIsDirty] = useState(false)\n\n const [createOpen, setCreateOpen] = useState(false)\n const [newPath, setNewPath] = useState('')\n const [creating, setCreating] = useState(false)\n const [deleteOpen, setDeleteOpen] = useState(false)\n const [deleting, setDeleting] = useState(false)\n const [dockOpen, setDockOpen] = useState(false)\n const [pendingNav, setPendingNav] = useState<PendingNav>(null)\n\n const savedContentRef = useRef('')\n const loadedPathRef = useRef<string | null>(null)\n\n const filePaths = useMemo(() => collectFilePaths(tree, new Set<string>()), [tree])\n const treeRoot = useMemo<VaultTreeNode>(\n () => ({ name: 'Vault', path: '', type: 'directory', children: tree }),\n [tree],\n )\n const fileCount = useMemo(() => countFiles(tree), [tree])\n\n const commitPath = useCallback(\n (next: string | null) => {\n if (!controlled) setInternalPath(next)\n onSelectedPathChange?.(next)\n },\n [controlled, onSelectedPathChange],\n )\n\n const refresh = useCallback(async () => {\n setTreeLoading(true)\n try {\n setTree(await port.listTree())\n } finally {\n setTreeLoading(false)\n }\n }, [port])\n\n useEffect(() => {\n void refresh()\n }, [refresh, refreshKey])\n\n useEffect(() => {\n if (!selectedPath) {\n setSelectedFile(null)\n setFileLoading(false)\n loadedPathRef.current = null\n return\n }\n let cancelled = false\n const path = selectedPath\n setFileLoading(true)\n void (async () => {\n try {\n const file = await port.readFile(path)\n if (!cancelled) setSelectedFile(file)\n } catch {\n if (!cancelled) setSelectedFile(null)\n } finally {\n if (!cancelled) setFileLoading(false)\n }\n })()\n return () => {\n cancelled = true\n }\n }, [port, selectedPath, refreshKey])\n\n useEffect(() => {\n if (!selectedFile) {\n loadedPathRef.current = null\n savedContentRef.current = ''\n setRichDraft('')\n setSourceDraft('')\n setEditorMode('rich')\n setIsDirty(false)\n return\n }\n const pathChanged = loadedPathRef.current !== selectedFile.path\n loadedPathRef.current = selectedFile.path\n savedContentRef.current = selectedFile.content\n setRichDraft(activeCodec.parse(selectedFile.content))\n setSourceDraft(selectedFile.content)\n if (pathChanged) setEditorMode('rich')\n setIsDirty(false)\n setDockOpen(false)\n }, [selectedFile, activeCodec])\n\n const guardedOpen = useCallback(\n (path: string) => {\n if (path === selectedPath) return\n if (isDirty) {\n setPendingNav({ type: 'open', path })\n return\n }\n commitPath(path)\n },\n [isDirty, selectedPath, commitPath],\n )\n\n const guardedClose = useCallback(() => {\n if (isDirty) {\n setPendingNav({ type: 'close' })\n return\n }\n commitPath(null)\n setSelectedFile(null)\n }, [isDirty, commitPath])\n\n const confirmDiscard = useCallback(() => {\n const nav = pendingNav\n setPendingNav(null)\n setIsDirty(false)\n if (!nav) return\n if (nav.type === 'open') {\n commitPath(nav.path)\n } else {\n commitPath(null)\n setSelectedFile(null)\n }\n }, [pendingNav, commitPath])\n\n const showRichMode = useCallback(() => {\n setEditorMode((mode) => {\n if (mode === 'rich') return mode\n setRichDraft(activeCodec.parse(sourceDraft))\n setIsDirty(sourceDraft !== savedContentRef.current)\n return 'rich'\n })\n }, [activeCodec, sourceDraft])\n\n const showSourceMode = useCallback(() => {\n setEditorMode((mode) => {\n if (mode === 'source') return mode\n const content = isDirty ? activeCodec.serialize(richDraft) : savedContentRef.current\n setSourceDraft(content)\n setIsDirty(content !== savedContentRef.current)\n return 'source'\n })\n }, [activeCodec, isDirty, richDraft])\n\n const onSourceChange = useCallback((next: string) => {\n setSourceDraft(next)\n setIsDirty(next !== savedContentRef.current)\n }, [])\n\n const onRichChange = useCallback((next: VaultRichParts) => {\n setRichDraft(next)\n setIsDirty(activeCodec.serialize(next) !== savedContentRef.current)\n }, [activeCodec])\n\n const saveCurrent = useCallback(async () => {\n if (!selectedFile) return\n const content = editorMode === 'source' ? sourceDraft : activeCodec.serialize(richDraft)\n setSaving(true)\n try {\n await port.writeFile(selectedFile.path, content)\n savedContentRef.current = content\n setSelectedFile({ ...selectedFile, content })\n setSourceDraft(content)\n setRichDraft(activeCodec.parse(content))\n setIsDirty(false)\n } finally {\n setSaving(false)\n }\n }, [selectedFile, editorMode, sourceDraft, richDraft, activeCodec, port])\n\n const handleCreate = useCallback(async () => {\n const trimmed = newPath.trim()\n if (!trimmed) return\n setCreating(true)\n try {\n const created = await port.createFile(trimmed)\n setCreateOpen(false)\n setNewPath('')\n await refresh()\n commitPath(created)\n } finally {\n setCreating(false)\n }\n }, [newPath, port, refresh, commitPath])\n\n const handleDelete = useCallback(async () => {\n if (!selectedFile) return\n setDeleting(true)\n try {\n await port.deleteFile(selectedFile.path)\n setDeleteOpen(false)\n setIsDirty(false)\n commitPath(null)\n setSelectedFile(null)\n await refresh()\n } finally {\n setDeleting(false)\n }\n }, [selectedFile, port, refresh, commitPath])\n\n return (\n <EditorErrorBoundary onReset={() => { commitPath(null); setSelectedFile(null) }}>\n <div className={`flex min-h-0 flex-1 overflow-hidden ${className ?? ''}`}>\n <div className=\"flex w-[23rem] min-w-[23rem] flex-col border-r border-border bg-background\">\n <div className=\"flex items-center justify-between gap-3 border-b border-border px-4 py-3\">\n <div className=\"flex min-w-0 items-center gap-2\">\n <span className=\"text-sm font-semibold text-foreground\">Vault</span>\n <span className=\"text-xs text-muted-foreground\">\n {fileCount} file{fileCount === 1 ? '' : 's'}\n </span>\n </div>\n <div className=\"flex shrink-0 items-center gap-1\">\n {headerActions}\n <button\n type=\"button\"\n aria-label=\"Refresh vault\"\n onClick={() => void refresh()}\n className=\"inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/60\"\n >\n ↻\n </button>\n {canWrite && (\n <button\n type=\"button\"\n aria-label=\"New vault file\"\n onClick={() => setCreateOpen(true)}\n className=\"inline-flex h-8 w-8 items-center justify-center rounded-md bg-primary text-primary-foreground transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/60\"\n >\n +\n </button>\n )}\n </div>\n </div>\n <div className=\"flex-1 overflow-y-auto\">\n {treeLoading ? (\n <TreeSkeleton />\n ) : (\n renderTree({\n root: treeRoot,\n selectedPath: selectedPath ?? undefined,\n onSelect: (path) => { if (filePaths.has(path)) guardedOpen(path) },\n })\n )}\n </div>\n </div>\n\n <div className=\"flex min-w-0 flex-1 flex-col overflow-hidden\">\n {selectedFile && (\n <div className=\"flex shrink-0 items-center justify-between border-b border-border bg-card px-4 py-1.5\">\n <span data-vault-path className=\"truncate text-xs text-muted-foreground\">{selectedFile.path}</span>\n <div className=\"flex items-center gap-1\">\n {canWrite && isMarkdownCapable && (\n <div className=\"mr-1 flex items-center gap-1\">\n <button\n type=\"button\"\n aria-label=\"Edit as rich text\"\n aria-pressed={editorMode === 'rich'}\n onClick={showRichMode}\n className={`inline-flex h-7 items-center rounded px-2 text-xs transition-colors ${\n editorMode === 'rich'\n ? 'bg-primary text-primary-foreground'\n : 'text-muted-foreground hover:bg-muted hover:text-foreground'\n }`}\n >\n Rich\n </button>\n <button\n type=\"button\"\n aria-label=\"Edit as source\"\n aria-pressed={editorMode === 'source'}\n onClick={showSourceMode}\n className={`inline-flex h-7 items-center rounded px-2 text-xs transition-colors ${\n editorMode === 'source'\n ? 'bg-primary text-primary-foreground'\n : 'text-muted-foreground hover:bg-muted hover:text-foreground'\n }`}\n >\n Source\n </button>\n </div>\n )}\n {renderDock && !persistentDock && (\n <button\n type=\"button\"\n aria-label={dockToggleCfg.label}\n aria-pressed={dockOpen}\n disabled={(dockToggleCfg.disabledWhenDirty ?? true) && isDirty}\n title={(dockToggleCfg.disabledWhenDirty ?? true) && isDirty ? 'Save your changes first' : (dockToggleCfg.title ?? dockToggleCfg.label)}\n onClick={() => setDockOpen((v) => !v)}\n className={`inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs transition-colors disabled:pointer-events-none disabled:opacity-40 ${\n dockOpen\n ? 'bg-primary text-primary-foreground'\n : 'text-muted-foreground hover:bg-muted hover:text-foreground'\n }`}\n >\n {dockToggleCfg.label}\n </button>\n )}\n {canWrite && (\n <button\n type=\"button\"\n aria-label=\"Delete this file\"\n title=\"Delete file\"\n onClick={() => setDeleteOpen(true)}\n className=\"p-1 text-muted-foreground transition-colors hover:text-destructive\"\n >\n ✕\n </button>\n )}\n </div>\n </div>\n )}\n <div className=\"flex-1 overflow-hidden\">\n {fileLoading ? (\n <EditorSkeleton />\n ) : selectedFile && canWrite && isMarkdownCapable && editorMode === 'source' ? (\n <SourceEditor\n path={selectedFile.path}\n content={sourceDraft}\n saving={saving}\n dirty={isDirty}\n onChange={onSourceChange}\n onSave={() => void saveCurrent()}\n />\n ) : selectedFile ? (\n renderArtifact({\n file: selectedFile,\n loading: false,\n mode: editorMode,\n canWrite,\n richDraft,\n dirty: isDirty,\n onRichChange,\n onSave: () => void saveCurrent(),\n })\n ) : (\n <EmptyState />\n )}\n </div>\n </div>\n\n {renderDock && selectedFile && renderDock({\n file: selectedFile,\n open: persistentDock ? true : dockOpen,\n onClose: persistentDock ? () => {} : () => setDockOpen(false),\n })}\n\n <ConfirmDialog\n open={createOpen}\n title=\"Create vault file\"\n description=\"Add a new document to this vault.\"\n confirmLabel={creating ? 'Creating…' : 'Create'}\n confirmDisabled={creating || !newPath.trim()}\n onConfirm={() => void handleCreate()}\n onCancel={() => { setCreateOpen(false); setNewPath('') }}\n >\n <input\n value={newPath}\n autoFocus\n onChange={(e) => setNewPath(e.target.value)}\n placeholder=\"e.g. playbooks/new-strategy.md\"\n aria-label=\"New file path\"\n className=\"h-9 w-full rounded-md border border-border bg-background px-3 text-sm text-foreground outline-none placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-primary/60\"\n />\n </ConfirmDialog>\n\n <ConfirmDialog\n open={deleteOpen}\n title=\"Delete file?\"\n description={`This permanently removes ${selectedFile?.path ?? 'this file'} from the vault.`}\n confirmLabel={deleting ? 'Deleting…' : 'Delete file'}\n confirmDisabled={deleting}\n destructive\n onConfirm={() => void handleDelete()}\n onCancel={() => setDeleteOpen(false)}\n />\n\n <ConfirmDialog\n open={pendingNav !== null}\n title=\"Discard unsaved changes?\"\n description=\"Your edits to this document haven't been saved. Continue and lose them?\"\n confirmLabel=\"Discard changes\"\n destructive\n onConfirm={confirmDiscard}\n onCancel={() => setPendingNav(null)}\n />\n </div>\n </EditorErrorBoundary>\n )\n}\n\nfunction SourceEditor({\n path,\n content,\n saving,\n dirty,\n onChange,\n onSave,\n}: {\n path: string\n content: string\n saving: boolean\n dirty: boolean\n onChange: (content: string) => void\n onSave: () => void\n}) {\n return (\n <div className=\"flex h-full min-h-0 flex-col bg-background\">\n <div className=\"flex items-center justify-between gap-2 border-b border-border px-4 py-2\">\n <p className=\"truncate font-mono text-[11px] text-muted-foreground\">{path}</p>\n <div className=\"flex shrink-0 items-center gap-2\">\n <span className=\"rounded-full border border-border bg-background px-2.5 py-1 text-xs text-muted-foreground\">\n {dirty ? 'Unsaved changes' : 'Saved'}\n </span>\n <button\n type=\"button\"\n onClick={onSave}\n disabled={saving || !dirty}\n className=\"inline-flex h-7 items-center rounded-md bg-primary px-2 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-50\"\n >\n {saving ? 'Saving…' : 'Save'}\n </button>\n </div>\n </div>\n <textarea\n value={content}\n onChange={(event) => onChange(event.target.value)}\n spellCheck={false}\n aria-label=\"Source editor\"\n className=\"min-h-0 flex-1 resize-none border-0 bg-background p-4 font-mono text-sm leading-6 text-foreground outline-none\"\n />\n </div>\n )\n}\n","/**\n * Self-contained confirm dialog — no dialog library. A focus-trapped modal with\n * Esc-to-cancel and Enter-to-confirm, used for create / delete / discard-unsaved\n * flows so the pane carries zero UI-kit dependency.\n */\n\nimport { useEffect, useRef, type ReactNode } from 'react'\n\nexport interface ConfirmDialogProps {\n open: boolean\n title: string\n description?: ReactNode\n confirmLabel?: string\n cancelLabel?: string\n /** Styles the confirm button as a destructive action. */\n destructive?: boolean\n /** Disables the confirm button (e.g. while the action is in flight). */\n confirmDisabled?: boolean\n onConfirm: () => void\n onCancel: () => void\n /** Optional body (e.g. an input field for the create flow). */\n children?: ReactNode\n}\n\nexport function ConfirmDialog({\n open,\n title,\n description,\n confirmLabel = 'Confirm',\n cancelLabel = 'Cancel',\n destructive = false,\n confirmDisabled = false,\n onConfirm,\n onCancel,\n children,\n}: ConfirmDialogProps) {\n const panelRef = useRef<HTMLDivElement>(null)\n const confirmRef = useRef<HTMLButtonElement>(null)\n\n useEffect(() => {\n if (!open) return\n confirmRef.current?.focus()\n }, [open])\n\n if (!open) return null\n\n function onKeyDown(event: React.KeyboardEvent) {\n if (event.key === 'Escape') {\n event.preventDefault()\n onCancel()\n return\n }\n if (event.key === 'Enter' && !confirmDisabled) {\n event.preventDefault()\n onConfirm()\n return\n }\n if (event.key !== 'Tab') return\n const focusable = panelRef.current?.querySelectorAll<HTMLElement>(\n 'button:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])',\n )\n if (!focusable || focusable.length === 0) return\n const first = focusable[0]\n const last = focusable[focusable.length - 1]\n const active = document.activeElement as HTMLElement | null\n if (event.shiftKey && active === first) {\n event.preventDefault()\n last?.focus()\n } else if (!event.shiftKey && active === last) {\n event.preventDefault()\n first?.focus()\n }\n }\n\n return (\n <div\n className=\"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4\"\n onMouseDown={(e) => { if (e.target === e.currentTarget) onCancel() }}\n >\n <div\n ref={panelRef}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={title}\n onKeyDown={onKeyDown}\n className=\"w-full max-w-md rounded-lg border border-border bg-card p-5 shadow-lg\"\n >\n <h2 className=\"text-sm font-semibold text-foreground\">{title}</h2>\n {description && <p className=\"mt-1.5 text-xs text-muted-foreground\">{description}</p>}\n {children && <div className=\"mt-3\">{children}</div>}\n <div className=\"mt-5 flex justify-end gap-2\">\n <button\n type=\"button\"\n onClick={onCancel}\n className=\"inline-flex h-8 items-center rounded-md px-3 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/60\"\n >\n {cancelLabel}\n </button>\n <button\n ref={confirmRef}\n type=\"button\"\n onClick={onConfirm}\n disabled={confirmDisabled}\n className={`inline-flex h-8 items-center rounded-md px-3 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/60 disabled:pointer-events-none disabled:opacity-50 ${\n destructive\n ? 'bg-destructive text-destructive-foreground hover:bg-destructive/90'\n : 'bg-primary text-primary-foreground hover:bg-primary/90'\n }`}\n >\n {confirmLabel}\n </button>\n </div>\n </div>\n </div>\n )\n}\n"],"mappings":";AAcA;AAAA,EACE;AAAA,EACA;AAAA,EACA,aAAAA;AAAA,EACA;AAAA,EACA,UAAAC;AAAA,EACA;AAAA,OAGK;;;ACjBP,SAAS,WAAW,cAA8B;AAiF1C,cAGA,YAHA;AA/DD,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf,cAAc;AAAA,EACd,cAAc;AAAA,EACd,kBAAkB;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AACF,GAAuB;AACrB,QAAM,WAAW,OAAuB,IAAI;AAC5C,QAAM,aAAa,OAA0B,IAAI;AAEjD,YAAU,MAAM;AACd,QAAI,CAAC,KAAM;AACX,eAAW,SAAS,MAAM;AAAA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AAA;AAAA,QACC,OAAO;AAAA,QACP,UAAU,CAAC,UAAU,SAAS,MAAM,OAAO,KAAK;AAAA,QAChD,YAAY;AAAA,QACZ,cAAW;AAAA,QACX,WAAU;AAAA;AAAA,IACZ;AAAA,KACF;AAEJ;","names":["useEffect","useRef","jsx","jsxs","useRef","useEffect"]}
@@ -0,0 +1,41 @@
1
+ import { e as IntakeAnswers, b as IntakeGraph, I as IntakeAnswerValue } from './model-Bzi5i63l.js';
2
+
3
+ /**
4
+ * Pure completion-state helpers for an intake payload — the small algebra over
5
+ * the JSON blob the store persists. No I/O: the store reads/writes the row;
6
+ * these functions only build and judge the payload shape, so the same logic
7
+ * runs in the UI, the handlers, and the DB layer without divergence.
8
+ *
9
+ * A payload is `{ graphId, answers, completedAt? }`. It carries the answers
10
+ * and the id of the graph they were collected against, so a later graph
11
+ * revision can detect a stale payload (`graphId` mismatch) rather than
12
+ * silently mixing answers from two question sets.
13
+ */
14
+
15
+ /** The persisted JSON for one intake (the `payload` column). */
16
+ interface IntakePayload {
17
+ /** The graph id the answers were collected against — guards stale schemas. */
18
+ graphId: string;
19
+ answers: IntakeAnswers;
20
+ /** ISO-8601 instant the intake was completed, or undefined while in progress. */
21
+ completedAt?: string;
22
+ }
23
+ /** An empty payload for a fresh intake against `graph`. */
24
+ declare function emptyPayload(graph: IntakeGraph): IntakePayload;
25
+ /** A copy of `payload` with one answer set (does not mutate the input). */
26
+ declare function withAnswer(payload: IntakePayload, questionId: string, value: IntakeAnswerValue): IntakePayload;
27
+ /**
28
+ * True when the payload's answers complete the graph AND the payload was
29
+ * collected against THIS graph. A `graphId` mismatch is never "complete" —
30
+ * the answers belong to a different question set and must be re-collected.
31
+ */
32
+ declare function payloadComplete(graph: IntakeGraph, payload: IntakePayload): boolean;
33
+ /** True when the payload was collected against a DIFFERENT graph revision. */
34
+ declare function payloadIsStale(graph: IntakeGraph, payload: IntakePayload): boolean;
35
+ /**
36
+ * Stamp the payload complete at `at` (default now). Returns a copy; pure. The
37
+ * caller has already checked `payloadComplete` — this only records the instant.
38
+ */
39
+ declare function markComplete(payload: IntakePayload, at?: Date): IntakePayload;
40
+
41
+ export { type IntakePayload as I, payloadIsStale as a, emptyPayload as e, markComplete as m, payloadComplete as p, withAnswer as w };
@@ -1,7 +1,7 @@
1
- import { I as IntakeAnswerValue, a as IntakeQuestion, b as IntakeGraph } from '../model-Cuj7d-xT.js';
1
+ import { I as IntakeAnswerValue, a as IntakeQuestion, b as IntakeGraph } from '../model-Bzi5i63l.js';
2
2
  import { IntakeStore } from './drizzle.js';
3
3
  import 'drizzle-orm/sqlite-core';
4
- import './index.js';
4
+ import '../completion-Kaqp_tWk.js';
5
5
 
6
6
  /**
7
7
  * Framework-neutral intake API: the get-current / save-answer / complete logic,
@@ -1,7 +1,7 @@
1
1
  import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
2
2
  import { AnySQLiteTable, AnySQLiteColumn, BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core';
3
- import { I as IntakeAnswerValue, b as IntakeGraph } from '../model-Cuj7d-xT.js';
4
- import { IntakePayload } from './index.js';
3
+ import { I as IntakeAnswerValue, b as IntakeGraph } from '../model-Bzi5i63l.js';
4
+ import { I as IntakePayload } from '../completion-Kaqp_tWk.js';
5
5
 
6
6
  /** A product table referenced by FK — only the `id` column is touched. */
7
7
  type IntakeParentTable = AnySQLiteTable & {
@@ -1,42 +1,118 @@
1
- import { c as IntakeAnswers, b as IntakeGraph, I as IntakeAnswerValue } from '../model-Cuj7d-xT.js';
2
- export { A as AnswerRejectionReason, d as AnswerValidationResult, e as IntakeAnswerType, f as IntakeOption, a as IntakeQuestion, g as getQuestion, h as hasAnswer, i as intakeProgress, j as isComplete, n as nextQuestion, r as reachableQuestions, v as validateAnswer } from '../model-Cuj7d-xT.js';
1
+ export { A as AnswerRejectionReason, c as AnswerValidationResult, d as IntakeAnswerType, I as IntakeAnswerValue, e as IntakeAnswers, b as IntakeGraph, f as IntakeOption, a as IntakeQuestion, g as getQuestion, h as hasAnswer, i as intakeProgress, j as isComplete, n as nextQuestion, r as reachableQuestions, v as validateAnswer } from '../model-Bzi5i63l.js';
2
+ export { I as IntakePayload, e as emptyPayload, m as markComplete, p as payloadComplete, a as payloadIsStale, w as withAnswer } from '../completion-Kaqp_tWk.js';
3
3
 
4
4
  /**
5
- * Pure completion-state helpers for an intake payload — the small algebra over
6
- * the JSON blob the store persists. No I/O: the store reads/writes the row;
7
- * these functions only build and judge the payload shape, so the same logic
8
- * runs in the UI, the handlers, and the DB layer without divergence.
5
+ * Pure context-sufficiency floor + conversational-gather scaffold — the
6
+ * product-agnostic core of a CONVERSATIONAL intake. Where the question-graph
7
+ * model (`./model`) runs a one-question-at-a-time interview, this leaf judges
8
+ * whether an agent has gathered ENOUGH context to act, and renders the prompt
9
+ * directive that tells the agent to fold the remaining gaps into its work
10
+ * instead of running a form.
9
11
  *
10
- * A payload is `{ graphId, answers, completedAt? }`. It carries the answers
11
- * and the id of the graph they were collected against, so a later graph
12
- * revision can detect a stale payload (`graphId` mismatch) rather than
13
- * silently mixing answers from two question sets.
12
+ * Zero dependencies: no drizzle, no env, no react, no I/O, no product reads.
13
+ * A product declares WHICH facts matter (`ContextFactSpec`), and its own
14
+ * adapter resolves those facts + named substrate flags from whatever substrate
15
+ * it owns (`ResolvedContextSignals`); this leaf only does the deterministic
16
+ * combine and the wording. That separation is what makes the framework opt-in
17
+ * and tree-shakeable, and what lets gtm/tax/legal/insurance share one core.
18
+ *
19
+ * Readiness is a two-part floor: SCOPE (every required fact has a value) AND
20
+ * SUBSTRATE (at least one named substrate flag is true). Scope alone is not
21
+ * enough — knowing the goal without any durable thing to act on is still
22
+ * not-ready; substrate alone is not enough either. The product's adapter
23
+ * decides what counts as a fact and what counts as substrate.
14
24
  */
15
-
16
- /** The persisted JSON for one intake (the `payload` column). */
17
- interface IntakePayload {
18
- /** The graph id the answers were collected against — guards stale schemas. */
19
- graphId: string;
20
- answers: IntakeAnswers;
21
- /** ISO-8601 instant the intake was completed, or undefined while in progress. */
22
- completedAt?: string;
25
+ /** One fact the product treats as known context once it has a value. */
26
+ interface ContextFact {
27
+ /** Stable key the resolved-signals map is keyed on. */
28
+ key: string;
29
+ /** Human label shown in the prompt's known/missing lists. */
30
+ label: string;
31
+ /** When true, this fact must have a value for SCOPE to be met. */
32
+ required?: boolean;
33
+ /** How the agent should gather this fact conversationally, if missing. */
34
+ gatherHint?: string;
35
+ }
36
+ /**
37
+ * The product's declaration of what context matters: the facts that make up
38
+ * scope, plus optional tool hints appended verbatim to the gather prompt (e.g.
39
+ * a product passes the command that extracts a brand from a URL). Pure data —
40
+ * the product supplies labels, hints, and tool lines; the framework never
41
+ * names a product-specific concept itself.
42
+ */
43
+ interface ContextFactSpec {
44
+ facts: ContextFact[];
45
+ /** Lines appended after the gather directive — e.g. product tool pointers. */
46
+ toolHints?: string[];
47
+ }
48
+ /**
49
+ * What a product's adapter resolves from its own substrate, ready to combine.
50
+ * `facts` carries the resolved VALUE per fact key (undefined/empty = not
51
+ * known); `substrate` carries named boolean flags (e.g.
52
+ * `{ brandConfirmed, configHasContext, coreKnowledgePresent }`) — any one true
53
+ * satisfies the substrate half of the floor.
54
+ */
55
+ interface ResolvedContextSignals {
56
+ facts: Record<string, string | undefined>;
57
+ substrate: Record<string, boolean>;
58
+ }
59
+ /** A resolved fact that has a value — surfaced to the prompt as known context. */
60
+ interface KnownFact {
61
+ key: string;
62
+ label: string;
63
+ value: string;
64
+ }
65
+ /** A required fact with no value — surfaced to the prompt as a gap to close. */
66
+ interface MissingFact {
67
+ key: string;
68
+ label: string;
69
+ gatherHint?: string;
70
+ }
71
+ /** The deterministic verdict over the resolved signals. */
72
+ interface ContextSufficiency {
73
+ /** True when the floor is met: `hasScope && hasSubstrate`. */
74
+ ready: boolean;
75
+ /** Every REQUIRED fact has a non-empty value. */
76
+ hasScope: boolean;
77
+ /** At least one named substrate flag is true. */
78
+ hasSubstrate: boolean;
79
+ /** Facts (required or not) that have a value. */
80
+ knownFacts: KnownFact[];
81
+ /** Required facts that have no value yet. */
82
+ missingFacts: MissingFact[];
83
+ /** The substrate flags as resolved, passed through for the prompt/caller. */
84
+ substrate: Record<string, boolean>;
23
85
  }
24
- /** An empty payload for a fresh intake against `graph`. */
25
- declare function emptyPayload(graph: IntakeGraph): IntakePayload;
26
- /** A copy of `payload` with one answer set (does not mutate the input). */
27
- declare function withAnswer(payload: IntakePayload, questionId: string, value: IntakeAnswerValue): IntakePayload;
28
86
  /**
29
- * True when the payload's answers complete the graph AND the payload was
30
- * collected against THIS graph. A `graphId` mismatch is never "complete"
31
- * the answers belong to a different question set and must be re-collected.
87
+ * Combine a fact spec with resolved signals into the readiness verdict. Pure,
88
+ * deterministic, never throws a missing fact key or an empty substrate map
89
+ * reads as not-ready, not an error, so a fresh scope is honestly not-ready
90
+ * rather than crashing the caller.
91
+ *
92
+ * SCOPE = every `required` fact resolves to a non-empty value.
93
+ * SUBSTRATE = any value in `signals.substrate` is true.
94
+ * READY = SCOPE && SUBSTRATE.
95
+ *
96
+ * `knownFacts` lists every fact (required or optional) that resolved to a
97
+ * value, in spec declaration order; `missingFacts` lists every REQUIRED fact
98
+ * that did not — optional facts never appear as missing because they never gate
99
+ * scope.
32
100
  */
33
- declare function payloadComplete(graph: IntakeGraph, payload: IntakePayload): boolean;
34
- /** True when the payload was collected against a DIFFERENT graph revision. */
35
- declare function payloadIsStale(graph: IntakeGraph, payload: IntakePayload): boolean;
101
+ declare function computeContextSufficiency(spec: ContextFactSpec, signals: ResolvedContextSignals): ContextSufficiency;
36
102
  /**
37
- * Stamp the payload complete at `at` (default now). Returns a copy; pure. The
38
- * caller has already checked `payloadComplete` this only records the instant.
103
+ * Render the prompt section that mirrors a conversational-gather flow:
104
+ * - "### Context you already have"the known facts, as `label: value`.
105
+ * - "### Context still missing — gather it while you work, not as a form" —
106
+ * the missing facts (with their gather hints), the act-first directive, and
107
+ * any product tool hints appended verbatim.
108
+ *
109
+ * When scope is met but the floor still is not (no substrate flag), it emits
110
+ * the substrate directive instead of a missing-facts list. Returns '' when
111
+ * there is nothing to say (no known facts, no gaps, and ready) so a caller can
112
+ * concatenate it unconditionally. Pure: wording is product-neutral; every
113
+ * product-specific phrase comes from the spec's labels, gather hints, and tool
114
+ * hints.
39
115
  */
40
- declare function markComplete(payload: IntakePayload, at?: Date): IntakePayload;
116
+ declare function buildContextGatherPrompt(spec: ContextFactSpec, sufficiency: ContextSufficiency): string;
41
117
 
42
- export { IntakeAnswerValue, IntakeAnswers, IntakeGraph, type IntakePayload, emptyPayload, markComplete, payloadComplete, payloadIsStale, withAnswer };
118
+ export { type ContextFact, type ContextFactSpec, type ContextSufficiency, type KnownFact, type MissingFact, type ResolvedContextSignals, buildContextGatherPrompt, computeContextSufficiency };
@@ -14,7 +14,73 @@ import {
14
14
  reachableQuestions,
15
15
  validateAnswer
16
16
  } from "../chunk-ND3XEGBE.js";
17
+
18
+ // src/intakes/context-sufficiency.ts
19
+ function presentValue(value) {
20
+ if (typeof value !== "string") return void 0;
21
+ const trimmed = value.trim();
22
+ return trimmed.length > 0 ? trimmed : void 0;
23
+ }
24
+ function computeContextSufficiency(spec, signals) {
25
+ const facts = spec.facts ?? [];
26
+ const resolvedFacts = signals.facts ?? {};
27
+ const substrate = signals.substrate ?? {};
28
+ const knownFacts = [];
29
+ const missingFacts = [];
30
+ let hasScope = true;
31
+ for (const fact of facts) {
32
+ const value = presentValue(resolvedFacts[fact.key]);
33
+ if (value !== void 0) {
34
+ knownFacts.push({ key: fact.key, label: fact.label, value });
35
+ } else if (fact.required) {
36
+ hasScope = false;
37
+ missingFacts.push({ key: fact.key, label: fact.label, gatherHint: fact.gatherHint });
38
+ }
39
+ }
40
+ const hasSubstrate = Object.values(substrate).some(Boolean);
41
+ return {
42
+ ready: hasScope && hasSubstrate,
43
+ hasScope,
44
+ hasSubstrate,
45
+ knownFacts,
46
+ missingFacts,
47
+ substrate
48
+ };
49
+ }
50
+ var GATHER_DIRECTIVE = "Do not run an interview. Act on the message first, then fold AT MOST one or two pointed questions into the same turn to close the highest-leverage gap. Never present a form.";
51
+ var SUBSTRATE_DIRECTIVE = "You have the scope but no durable substrate to act on yet. As you work, persist what you learn \u2014 that is what makes this context-ready.";
52
+ function buildContextGatherPrompt(spec, sufficiency) {
53
+ const lines = [];
54
+ if (sufficiency.knownFacts.length > 0) {
55
+ lines.push("### Context you already have");
56
+ lines.push(sufficiency.knownFacts.map((f) => `- ${f.label}: ${f.value}`).join("\n"));
57
+ }
58
+ if (sufficiency.missingFacts.length > 0) {
59
+ if (lines.length > 0) lines.push("");
60
+ lines.push("### Context still missing \u2014 gather it while you work, not as a form");
61
+ const gaps = sufficiency.missingFacts.map((f) => f.gatherHint ? `- ${f.label} \u2014 ${f.gatherHint}` : `- ${f.label}`).join("\n");
62
+ lines.push(`You do NOT have:
63
+ ${gaps}`);
64
+ lines.push(GATHER_DIRECTIVE);
65
+ for (const hint of spec.toolHints ?? []) {
66
+ const trimmed = hint.trim();
67
+ if (trimmed) lines.push(trimmed);
68
+ }
69
+ } else if (!sufficiency.ready) {
70
+ if (lines.length > 0) lines.push("");
71
+ lines.push(SUBSTRATE_DIRECTIVE);
72
+ for (const hint of spec.toolHints ?? []) {
73
+ const trimmed = hint.trim();
74
+ if (trimmed) lines.push(trimmed);
75
+ }
76
+ }
77
+ if (lines.length === 0) return "";
78
+ return `## Project Context & Sufficiency
79
+ ${lines.join("\n")}`;
80
+ }
17
81
  export {
82
+ buildContextGatherPrompt,
83
+ computeContextSufficiency,
18
84
  emptyPayload,
19
85
  getQuestion,
20
86
  hasAnswer,
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../src/intakes/context-sufficiency.ts"],"sourcesContent":["/**\n * Pure context-sufficiency floor + conversational-gather scaffold — the\n * product-agnostic core of a CONVERSATIONAL intake. Where the question-graph\n * model (`./model`) runs a one-question-at-a-time interview, this leaf judges\n * whether an agent has gathered ENOUGH context to act, and renders the prompt\n * directive that tells the agent to fold the remaining gaps into its work\n * instead of running a form.\n *\n * Zero dependencies: no drizzle, no env, no react, no I/O, no product reads.\n * A product declares WHICH facts matter (`ContextFactSpec`), and its own\n * adapter resolves those facts + named substrate flags from whatever substrate\n * it owns (`ResolvedContextSignals`); this leaf only does the deterministic\n * combine and the wording. That separation is what makes the framework opt-in\n * and tree-shakeable, and what lets gtm/tax/legal/insurance share one core.\n *\n * Readiness is a two-part floor: SCOPE (every required fact has a value) AND\n * SUBSTRATE (at least one named substrate flag is true). Scope alone is not\n * enough — knowing the goal without any durable thing to act on is still\n * not-ready; substrate alone is not enough either. The product's adapter\n * decides what counts as a fact and what counts as substrate.\n */\n\n/** One fact the product treats as known context once it has a value. */\nexport interface ContextFact {\n /** Stable key the resolved-signals map is keyed on. */\n key: string\n /** Human label shown in the prompt's known/missing lists. */\n label: string\n /** When true, this fact must have a value for SCOPE to be met. */\n required?: boolean\n /** How the agent should gather this fact conversationally, if missing. */\n gatherHint?: string\n}\n\n/**\n * The product's declaration of what context matters: the facts that make up\n * scope, plus optional tool hints appended verbatim to the gather prompt (e.g.\n * a product passes the command that extracts a brand from a URL). Pure data —\n * the product supplies labels, hints, and tool lines; the framework never\n * names a product-specific concept itself.\n */\nexport interface ContextFactSpec {\n facts: ContextFact[]\n /** Lines appended after the gather directive — e.g. product tool pointers. */\n toolHints?: string[]\n}\n\n/**\n * What a product's adapter resolves from its own substrate, ready to combine.\n * `facts` carries the resolved VALUE per fact key (undefined/empty = not\n * known); `substrate` carries named boolean flags (e.g.\n * `{ brandConfirmed, configHasContext, coreKnowledgePresent }`) — any one true\n * satisfies the substrate half of the floor.\n */\nexport interface ResolvedContextSignals {\n facts: Record<string, string | undefined>\n substrate: Record<string, boolean>\n}\n\n/** A resolved fact that has a value — surfaced to the prompt as known context. */\nexport interface KnownFact {\n key: string\n label: string\n value: string\n}\n\n/** A required fact with no value — surfaced to the prompt as a gap to close. */\nexport interface MissingFact {\n key: string\n label: string\n gatherHint?: string\n}\n\n/** The deterministic verdict over the resolved signals. */\nexport interface ContextSufficiency {\n /** True when the floor is met: `hasScope && hasSubstrate`. */\n ready: boolean\n /** Every REQUIRED fact has a non-empty value. */\n hasScope: boolean\n /** At least one named substrate flag is true. */\n hasSubstrate: boolean\n /** Facts (required or not) that have a value. */\n knownFacts: KnownFact[]\n /** Required facts that have no value yet. */\n missingFacts: MissingFact[]\n /** The substrate flags as resolved, passed through for the prompt/caller. */\n substrate: Record<string, boolean>\n}\n\n/** Trim a fact value to a present string, or undefined when blank/absent. */\nfunction presentValue(value: string | undefined): string | undefined {\n if (typeof value !== 'string') return undefined\n const trimmed = value.trim()\n return trimmed.length > 0 ? trimmed : undefined\n}\n\n/**\n * Combine a fact spec with resolved signals into the readiness verdict. Pure,\n * deterministic, never throws — a missing fact key or an empty substrate map\n * reads as not-ready, not an error, so a fresh scope is honestly not-ready\n * rather than crashing the caller.\n *\n * SCOPE = every `required` fact resolves to a non-empty value.\n * SUBSTRATE = any value in `signals.substrate` is true.\n * READY = SCOPE && SUBSTRATE.\n *\n * `knownFacts` lists every fact (required or optional) that resolved to a\n * value, in spec declaration order; `missingFacts` lists every REQUIRED fact\n * that did not — optional facts never appear as missing because they never gate\n * scope.\n */\nexport function computeContextSufficiency(\n spec: ContextFactSpec,\n signals: ResolvedContextSignals,\n): ContextSufficiency {\n const facts = spec.facts ?? []\n const resolvedFacts = signals.facts ?? {}\n const substrate = signals.substrate ?? {}\n\n const knownFacts: KnownFact[] = []\n const missingFacts: MissingFact[] = []\n let hasScope = true\n\n for (const fact of facts) {\n const value = presentValue(resolvedFacts[fact.key])\n if (value !== undefined) {\n knownFacts.push({ key: fact.key, label: fact.label, value })\n } else if (fact.required) {\n hasScope = false\n missingFacts.push({ key: fact.key, label: fact.label, gatherHint: fact.gatherHint })\n }\n }\n\n const hasSubstrate = Object.values(substrate).some(Boolean)\n\n return {\n ready: hasScope && hasSubstrate,\n hasScope,\n hasSubstrate,\n knownFacts,\n missingFacts,\n substrate,\n }\n}\n\n/** The directive that turns gaps into conversational gathering, not a form. */\nconst GATHER_DIRECTIVE =\n 'Do not run an interview. Act on the message first, then fold AT MOST one or two pointed questions into the same turn to close the highest-leverage gap. Never present a form.'\n\n/** What to say when scope is met but no durable substrate exists yet. */\nconst SUBSTRATE_DIRECTIVE =\n 'You have the scope but no durable substrate to act on yet. As you work, persist what you learn — that is what makes this context-ready.'\n\n/**\n * Render the prompt section that mirrors a conversational-gather flow:\n * - \"### Context you already have\" — the known facts, as `label: value`.\n * - \"### Context still missing — gather it while you work, not as a form\" —\n * the missing facts (with their gather hints), the act-first directive, and\n * any product tool hints appended verbatim.\n *\n * When scope is met but the floor still is not (no substrate flag), it emits\n * the substrate directive instead of a missing-facts list. Returns '' when\n * there is nothing to say (no known facts, no gaps, and ready) so a caller can\n * concatenate it unconditionally. Pure: wording is product-neutral; every\n * product-specific phrase comes from the spec's labels, gather hints, and tool\n * hints.\n */\nexport function buildContextGatherPrompt(\n spec: ContextFactSpec,\n sufficiency: ContextSufficiency,\n): string {\n const lines: string[] = []\n\n if (sufficiency.knownFacts.length > 0) {\n lines.push('### Context you already have')\n lines.push(sufficiency.knownFacts.map((f) => `- ${f.label}: ${f.value}`).join('\\n'))\n }\n\n if (sufficiency.missingFacts.length > 0) {\n if (lines.length > 0) lines.push('')\n lines.push('### Context still missing — gather it while you work, not as a form')\n const gaps = sufficiency.missingFacts\n .map((f) => (f.gatherHint ? `- ${f.label} — ${f.gatherHint}` : `- ${f.label}`))\n .join('\\n')\n lines.push(`You do NOT have:\\n${gaps}`)\n lines.push(GATHER_DIRECTIVE)\n for (const hint of spec.toolHints ?? []) {\n const trimmed = hint.trim()\n if (trimmed) lines.push(trimmed)\n }\n } else if (!sufficiency.ready) {\n if (lines.length > 0) lines.push('')\n lines.push(SUBSTRATE_DIRECTIVE)\n for (const hint of spec.toolHints ?? []) {\n const trimmed = hint.trim()\n if (trimmed) lines.push(trimmed)\n }\n }\n\n if (lines.length === 0)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AACvC,QAAI,MAAM,SAAS,EAAG,OAAM,KAAK,EAAE;AACnC,UAAM,KAAK,0EAAqE;AAChF,UAAM,OAAO,YAAY,aACtB,IAAI,CAAC,MAAO,EAAE,aAAa,KAAK,EAAE,KAAK,WAAM,EAAE,UAAU,KAAK,KAAK,EAAE,KAAK,EAAG,EAC7E,KAAK,IAAI;AACZ,UAAM,KAAK;AAAA,EAAqB,IAAI,EAAE;AACtC,UAAM,KAAK,gBAAgB;AAC3B,eAAW,QAAQ,KAAK,aAAa,CAAC,GAAG;AACvC,YAAM,UAAU,KAAK,KAAK;AAC1B,UAAI,QAAS,OAAM,KAAK,OAAO;AAAA,IACjC;AAAA,EACF,WAAW,CAAC,YAAY,OAAO;AAC7B,QAAI,MAAM,SAAS,EAAG,OAAM,KAAK,EAAE;AACnC,UAAM,KAAK,mBAAmB;AAC9B,eAAW,QAAQ,KAAK,aAAa,CAAC,GAAG;AACvC,YAAM,UAAU,KAAK,KAAK;AAC1B,UAAI,QAAS,OAAM,KAAK,OAAO;AAAA,IACjC;AAAA,EACF;AAEA,MAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,SAAO;AAAA,EAAqC,MAAM,KAAK,IAAI,CAAC;AAC9D;","names":[]}
@@ -1,4 +1,4 @@
1
- import { I as IntakeAnswerValue, a as IntakeQuestion } from '../model-Cuj7d-xT.js';
1
+ import { I as IntakeAnswerValue, a as IntakeQuestion } from '../model-Bzi5i63l.js';
2
2
  import * as react from 'react';
3
3
 
4
4
  /**
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { IntakeInterview } from './index.js';
3
3
  export { IntakeInterviewProps } from './index.js';
4
- import '../model-Cuj7d-xT.js';
4
+ import '../model-Bzi5i63l.js';
5
5
 
6
6
  declare const IntakeInterviewLazy: react.LazyExoticComponent<typeof IntakeInterview>;
7
7
 
@@ -113,4 +113,4 @@ declare function intakeProgress(graph: IntakeGraph, answers: IntakeAnswers): {
113
113
  /** The questions reachable under the current answers, in traversal order. */
114
114
  declare function reachableQuestions(graph: IntakeGraph, answers: IntakeAnswers): IntakeQuestion[];
115
115
 
116
- export { type AnswerRejectionReason as A, type IntakeAnswerValue as I, type IntakeQuestion as a, type IntakeGraph as b, type IntakeAnswers as c, type AnswerValidationResult as d, type IntakeAnswerType as e, type IntakeOption as f, getQuestion as g, hasAnswer as h, intakeProgress as i, isComplete as j, nextQuestion as n, reachableQuestions as r, validateAnswer as v };
116
+ export { type AnswerRejectionReason as A, type IntakeAnswerValue as I, type IntakeQuestion as a, type IntakeGraph as b, type AnswerValidationResult as c, type IntakeAnswerType as d, type IntakeAnswers as e, type IntakeOption as f, getQuestion as g, hasAnswer as h, intakeProgress as i, isComplete as j, nextQuestion as n, reachableQuestions as r, validateAnswer as v };
@@ -1,4 +1,4 @@
1
- export { V as VaultArtifactRenderProps, a as VaultDataPort, b as VaultDockRenderProps, c as VaultEditorMode, d as VaultFile, e as VaultMarkdownCodec, f as VaultPane, g as VaultPaneProps, h as VaultRichParts, i as VaultTreeNode, j as VaultTreeRenderProps } from '../VaultPane-By2l5lol.js';
1
+ export { V as VaultArtifactRenderProps, a as VaultDataPort, b as VaultDockRenderProps, c as VaultDockToggle, d as VaultEditorMode, e as VaultFile, f as VaultMarkdownCodec, g as VaultPane, h as VaultPaneProps, i as VaultRichParts, j as VaultTreeNode, k as VaultTreeRenderProps } from '../VaultPane-B5b1_G7r.js';
2
2
  import * as react from 'react';
3
3
  import { ReactNode } from 'react';
4
4
 
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ConfirmDialog,
3
3
  VaultPane
4
- } from "../chunk-FNUEUOOZ.js";
4
+ } from "../chunk-IITUMDKF.js";
5
5
  export {
6
6
  ConfirmDialog,
7
7
  VaultPane
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
- import { f as VaultPane } from '../VaultPane-By2l5lol.js';
3
- export { g as VaultPaneProps } from '../VaultPane-By2l5lol.js';
2
+ import { g as VaultPane } from '../VaultPane-B5b1_G7r.js';
3
+ export { h as VaultPaneProps } from '../VaultPane-B5b1_G7r.js';
4
4
 
5
5
  declare const VaultPaneLazy: react.LazyExoticComponent<typeof VaultPane>;
6
6
 
@@ -1,7 +1,7 @@
1
1
  // src/vault/lazy.tsx
2
2
  import { lazy } from "react";
3
3
  var VaultPaneLazy = lazy(
4
- () => import("../VaultPane-BQ2MZIMM.js").then((m) => ({ default: m.VaultPane }))
4
+ () => import("../VaultPane-YCMQBRIB.js").then((m) => ({ default: m.VaultPane }))
5
5
  );
6
6
  export {
7
7
  VaultPaneLazy
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-app",
3
- "version": "0.33.1",
3
+ "version": "0.35.0",
4
4
  "packageManager": "pnpm@10.33.4",
5
5
  "description": "Application-shell framework for Tangle agent products: a bounded tool loop, the structured agent→app tool side channel, integration-hub client, per-workspace billing, and crypto — composed over the Tangle agent substrate through typed seams.",
6
6
  "keywords": [
@@ -1,7 +0,0 @@
1
- import {
2
- VaultPane
3
- } from "./chunk-FNUEUOOZ.js";
4
- export {
5
- VaultPane
6
- };
7
- //# sourceMappingURL=VaultPane-BQ2MZIMM.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/vault/VaultPane.tsx","../src/vault/ConfirmDialog.tsx"],"sourcesContent":["/**\n * The shared 3-pane vault: tree | artifact viewer | optional agent dock. This is\n * pure shell MECHANISM — selection, the dirty-guard + pending-nav state machine,\n * rich/source editor modes, create/delete/refresh, skeletons, an error boundary,\n * and an empty state. It renders NO file tree and NO artifact viewer of its own:\n * those arrive through the `renderTree` / `renderArtifact` / `renderDock` seams,\n * so a product wires sandbox-ui's RichFileTree + FileArtifactPane in ~10 lines.\n *\n * Data flows exclusively through `port` (a `VaultDataPort`). The pane never\n * imports a fetch client, a router, a toast system, or a markdown library — the\n * optional `codec` seam supplies rich/source parsing (identity passthrough by\n * default). Chrome uses the shared theme tokens (bg-card, border-border, …).\n */\n\nimport {\n Component,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ErrorInfo,\n type ReactNode,\n} from 'react'\nimport { ConfirmDialog } from './ConfirmDialog'\nimport type {\n VaultEditorMode,\n VaultFile,\n VaultMarkdownCodec,\n VaultPaneProps,\n VaultRichParts,\n VaultTreeNode,\n} from './contracts'\n\nconst IDENTITY_CODEC: VaultMarkdownCodec = {\n parse: (raw) => raw,\n serialize: (parts) => (typeof parts === 'string' ? parts : String(parts ?? '')),\n}\n\ntype PendingNav = { type: 'open'; path: string } | { type: 'close' } | null\n\nfunction collectFilePaths(nodes: VaultTreeNode[], into: Set<string>): Set<string> {\n for (const node of nodes) {\n if (node.type === 'file') into.add(node.path)\n if (node.children) collectFilePaths(node.children, into)\n }\n return into\n}\n\nfunction countFiles(nodes: VaultTreeNode[]): number {\n return nodes.reduce(\n (sum, node) => (node.type === 'file' ? sum + 1 : sum + countFiles(node.children ?? [])),\n 0,\n )\n}\n\nclass EditorErrorBoundary extends Component<{ children: ReactNode; onReset?: () => void }, { error: unknown }> {\n state: { error: unknown } = { error: null }\n static getDerivedStateFromError(error: unknown) {\n return { error }\n }\n componentDidCatch(error: unknown, info: ErrorInfo) {\n console.error('Vault crashed:', error, info)\n }\n render() {\n if (this.state.error) {\n const msg = this.state.error instanceof Error\n ? this.state.error.message\n : typeof this.state.error === 'string'\n ? this.state.error\n : 'Something went wrong loading the vault'\n return (\n <div className=\"flex h-full flex-1 flex-col items-center justify-center p-8 text-center\">\n <h3 className=\"mb-1 text-sm font-medium text-foreground\">Vault failed to load</h3>\n <p className=\"mb-4 max-w-xs text-xs text-muted-foreground\">{String(msg)}</p>\n <button\n type=\"button\"\n onClick={() => { this.setState({ error: null }); this.props.onReset?.() }}\n className=\"inline-flex h-8 items-center rounded-md border border-border px-3 text-xs font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/60\"\n >\n Try again\n </button>\n </div>\n )\n }\n return this.props.children\n }\n}\n\nfunction TreeSkeleton() {\n return (\n <div className=\"space-y-2 p-4\" aria-hidden=\"true\">\n {[32, 48, 40, 52].map((w, i) => (\n <div key={i} className=\"h-4 animate-pulse rounded bg-muted\" style={{ width: `${w * 4}px` }} />\n ))}\n </div>\n )\n}\n\nfunction EditorSkeleton() {\n return (\n <div className=\"space-y-3 p-8\" aria-hidden=\"true\">\n <div className=\"h-5 w-1/2 animate-pulse rounded bg-muted\" />\n <div className=\"h-4 w-full animate-pulse rounded bg-muted\" />\n <div className=\"h-4 w-3/4 animate-pulse rounded bg-muted\" />\n <div className=\"h-4 w-2/3 animate-pulse rounded bg-muted\" />\n </div>\n )\n}\n\nfunction EmptyState() {\n return (\n <div className=\"flex h-full flex-col items-center justify-center p-8 text-center\">\n <h3 className=\"text-sm font-medium text-foreground\">Open a vault document</h3>\n <p className=\"mt-1 max-w-xs text-xs text-muted-foreground\">\n Select a file from the directory, or create a new one.\n </p>\n </div>\n )\n}\n\nexport function VaultPane(props: VaultPaneProps) {\n const {\n port,\n renderTree,\n renderArtifact,\n renderDock,\n canWrite = true,\n selectedPath: controlledPath,\n onSelectedPathChange,\n codec,\n className,\n } = props\n\n const activeCodec = codec ?? IDENTITY_CODEC\n const controlled = controlledPath !== undefined\n const isMarkdownCapable = codec !== undefined\n\n const [tree, setTree] = useState<VaultTreeNode[]>([])\n const [treeLoading, setTreeLoading] = useState(true)\n const [internalPath, setInternalPath] = useState<string | null>(null)\n const selectedPath = controlled ? (controlledPath ?? null) : internalPath\n\n const [selectedFile, setSelectedFile] = useState<VaultFile | null>(null)\n const [fileLoading, setFileLoading] = useState(false)\n const [saving, setSaving] = useState(false)\n\n const [editorMode, setEditorMode] = useState<VaultEditorMode>('rich')\n const [richDraft, setRichDraft] = useState<VaultRichParts>('')\n const [sourceDraft, setSourceDraft] = useState('')\n const [isDirty, setIsDirty] = useState(false)\n\n const [createOpen, setCreateOpen] = useState(false)\n const [newPath, setNewPath] = useState('')\n const [creating, setCreating] = useState(false)\n const [deleteOpen, setDeleteOpen] = useState(false)\n const [deleting, setDeleting] = useState(false)\n const [dockOpen, setDockOpen] = useState(false)\n const [pendingNav, setPendingNav] = useState<PendingNav>(null)\n\n const savedContentRef = useRef('')\n const loadedPathRef = useRef<string | null>(null)\n\n const filePaths = useMemo(() => collectFilePaths(tree, new Set<string>()), [tree])\n const treeRoot = useMemo<VaultTreeNode>(\n () => ({ name: 'Vault', path: '', type: 'directory', children: tree }),\n [tree],\n )\n const fileCount = useMemo(() => countFiles(tree), [tree])\n\n const commitPath = useCallback(\n (next: string | null) => {\n if (!controlled) setInternalPath(next)\n onSelectedPathChange?.(next)\n },\n [controlled, onSelectedPathChange],\n )\n\n const refresh = useCallback(async () => {\n setTreeLoading(true)\n try {\n setTree(await port.listTree())\n } finally {\n setTreeLoading(false)\n }\n }, [port])\n\n useEffect(() => {\n void refresh()\n }, [refresh])\n\n useEffect(() => {\n if (!selectedPath) {\n setSelectedFile(null)\n setFileLoading(false)\n loadedPathRef.current = null\n return\n }\n let cancelled = false\n const path = selectedPath\n setFileLoading(true)\n void (async () => {\n try {\n const file = await port.readFile(path)\n if (!cancelled) setSelectedFile(file)\n } catch {\n if (!cancelled) setSelectedFile(null)\n } finally {\n if (!cancelled) setFileLoading(false)\n }\n })()\n return () => {\n cancelled = true\n }\n }, [port, selectedPath])\n\n useEffect(() => {\n if (!selectedFile) {\n loadedPathRef.current = null\n savedContentRef.current = ''\n setRichDraft('')\n setSourceDraft('')\n setEditorMode('rich')\n setIsDirty(false)\n return\n }\n const pathChanged = loadedPathRef.current !== selectedFile.path\n loadedPathRef.current = selectedFile.path\n savedContentRef.current = selectedFile.content\n setRichDraft(activeCodec.parse(selectedFile.content))\n setSourceDraft(selectedFile.content)\n if (pathChanged) setEditorMode('rich')\n setIsDirty(false)\n setDockOpen(false)\n }, [selectedFile, activeCodec])\n\n const guardedOpen = useCallback(\n (path: string) => {\n if (path === selectedPath) return\n if (isDirty) {\n setPendingNav({ type: 'open', path })\n return\n }\n commitPath(path)\n },\n [isDirty, selectedPath, commitPath],\n )\n\n const guardedClose = useCallback(() => {\n if (isDirty) {\n setPendingNav({ type: 'close' })\n return\n }\n commitPath(null)\n setSelectedFile(null)\n }, [isDirty, commitPath])\n\n const confirmDiscard = useCallback(() => {\n const nav = pendingNav\n setPendingNav(null)\n setIsDirty(false)\n if (!nav) return\n if (nav.type === 'open') {\n commitPath(nav.path)\n } else {\n commitPath(null)\n setSelectedFile(null)\n }\n }, [pendingNav, commitPath])\n\n const showRichMode = useCallback(() => {\n setEditorMode((mode) => {\n if (mode === 'rich') return mode\n setRichDraft(activeCodec.parse(sourceDraft))\n setIsDirty(sourceDraft !== savedContentRef.current)\n return 'rich'\n })\n }, [activeCodec, sourceDraft])\n\n const showSourceMode = useCallback(() => {\n setEditorMode((mode) => {\n if (mode === 'source') return mode\n const content = isDirty ? activeCodec.serialize(richDraft) : savedContentRef.current\n setSourceDraft(content)\n setIsDirty(content !== savedContentRef.current)\n return 'source'\n })\n }, [activeCodec, isDirty, richDraft])\n\n const onSourceChange = useCallback((next: string) => {\n setSourceDraft(next)\n setIsDirty(next !== savedContentRef.current)\n }, [])\n\n const onRichChange = useCallback((next: VaultRichParts) => {\n setRichDraft(next)\n setIsDirty(activeCodec.serialize(next) !== savedContentRef.current)\n }, [activeCodec])\n\n const saveCurrent = useCallback(async () => {\n if (!selectedFile) return\n const content = editorMode === 'source' ? sourceDraft : activeCodec.serialize(richDraft)\n setSaving(true)\n try {\n await port.writeFile(selectedFile.path, content)\n savedContentRef.current = content\n setSelectedFile({ ...selectedFile, content })\n setSourceDraft(content)\n setRichDraft(activeCodec.parse(content))\n setIsDirty(false)\n } finally {\n setSaving(false)\n }\n }, [selectedFile, editorMode, sourceDraft, richDraft, activeCodec, port])\n\n const handleCreate = useCallback(async () => {\n const trimmed = newPath.trim()\n if (!trimmed) return\n setCreating(true)\n try {\n const created = await port.createFile(trimmed)\n setCreateOpen(false)\n setNewPath('')\n await refresh()\n commitPath(created)\n } finally {\n setCreating(false)\n }\n }, [newPath, port, refresh, commitPath])\n\n const handleDelete = useCallback(async () => {\n if (!selectedFile) return\n setDeleting(true)\n try {\n await port.deleteFile(selectedFile.path)\n setDeleteOpen(false)\n setIsDirty(false)\n commitPath(null)\n setSelectedFile(null)\n await refresh()\n } finally {\n setDeleting(false)\n }\n }, [selectedFile, port, refresh, commitPath])\n\n return (\n <EditorErrorBoundary onReset={() => { commitPath(null); setSelectedFile(null) }}>\n <div className={`flex min-h-0 flex-1 overflow-hidden ${className ?? ''}`}>\n <div className=\"flex w-[23rem] min-w-[23rem] flex-col border-r border-border bg-background\">\n <div className=\"flex items-center justify-between gap-3 border-b border-border px-4 py-3\">\n <div className=\"flex min-w-0 items-center gap-2\">\n <span className=\"text-sm font-semibold text-foreground\">Vault</span>\n <span className=\"text-xs text-muted-foreground\">\n {fileCount} file{fileCount === 1 ? '' : 's'}\n </span>\n </div>\n <div className=\"flex shrink-0 items-center gap-1\">\n <button\n type=\"button\"\n aria-label=\"Refresh vault\"\n onClick={() => void refresh()}\n className=\"inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/60\"\n >\n ↻\n </button>\n {canWrite && (\n <button\n type=\"button\"\n aria-label=\"New vault file\"\n onClick={() => setCreateOpen(true)}\n className=\"inline-flex h-8 w-8 items-center justify-center rounded-md bg-primary text-primary-foreground transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/60\"\n >\n +\n </button>\n )}\n </div>\n </div>\n <div className=\"flex-1 overflow-y-auto\">\n {treeLoading ? (\n <TreeSkeleton />\n ) : (\n renderTree({\n root: treeRoot,\n selectedPath: selectedPath ?? undefined,\n onSelect: (path) => { if (filePaths.has(path)) guardedOpen(path) },\n })\n )}\n </div>\n </div>\n\n <div className=\"flex min-w-0 flex-1 flex-col overflow-hidden\">\n {selectedFile && (\n <div className=\"flex shrink-0 items-center justify-between border-b border-border bg-card px-4 py-1.5\">\n <span data-vault-path className=\"truncate text-xs text-muted-foreground\">{selectedFile.path}</span>\n <div className=\"flex items-center gap-1\">\n {canWrite && isMarkdownCapable && (\n <div className=\"mr-1 flex items-center gap-1\">\n <button\n type=\"button\"\n aria-label=\"Edit as rich text\"\n aria-pressed={editorMode === 'rich'}\n onClick={showRichMode}\n className={`inline-flex h-7 items-center rounded px-2 text-xs transition-colors ${\n editorMode === 'rich'\n ? 'bg-primary text-primary-foreground'\n : 'text-muted-foreground hover:bg-muted hover:text-foreground'\n }`}\n >\n Rich\n </button>\n <button\n type=\"button\"\n aria-label=\"Edit as source\"\n aria-pressed={editorMode === 'source'}\n onClick={showSourceMode}\n className={`inline-flex h-7 items-center rounded px-2 text-xs transition-colors ${\n editorMode === 'source'\n ? 'bg-primary text-primary-foreground'\n : 'text-muted-foreground hover:bg-muted hover:text-foreground'\n }`}\n >\n Source\n </button>\n </div>\n )}\n {renderDock && (\n <button\n type=\"button\"\n aria-label=\"Discuss with agent\"\n aria-pressed={dockOpen}\n disabled={isDirty}\n title={isDirty ? 'Save before discussing with agent' : 'Discuss with agent'}\n onClick={() => setDockOpen((v) => !v)}\n className={`inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs transition-colors disabled:pointer-events-none disabled:opacity-40 ${\n dockOpen\n ? 'bg-primary text-primary-foreground'\n : 'text-muted-foreground hover:bg-muted hover:text-foreground'\n }`}\n >\n Discuss\n </button>\n )}\n {canWrite && (\n <button\n type=\"button\"\n aria-label=\"Delete this file\"\n title=\"Delete file\"\n onClick={() => setDeleteOpen(true)}\n className=\"p-1 text-muted-foreground transition-colors hover:text-destructive\"\n >\n ✕\n </button>\n )}\n </div>\n </div>\n )}\n <div className=\"flex-1 overflow-hidden\">\n {fileLoading ? (\n <EditorSkeleton />\n ) : selectedFile && canWrite && isMarkdownCapable && editorMode === 'source' ? (\n <SourceEditor\n path={selectedFile.path}\n content={sourceDraft}\n saving={saving}\n dirty={isDirty}\n onChange={onSourceChange}\n onSave={() => void saveCurrent()}\n />\n ) : selectedFile ? (\n renderArtifact({\n file: selectedFile,\n loading: false,\n mode: editorMode,\n canWrite,\n richDraft,\n dirty: isDirty,\n onRichChange,\n onSave: () => void saveCurrent(),\n })\n ) : (\n <EmptyState />\n )}\n </div>\n </div>\n\n {renderDock && selectedFile && renderDock({\n file: selectedFile,\n open: dockOpen,\n onClose: () => setDockOpen(false),\n })}\n\n <ConfirmDialog\n open={createOpen}\n title=\"Create vault file\"\n description=\"Add a new document to this vault.\"\n confirmLabel={creating ? 'Creating…' : 'Create'}\n confirmDisabled={creating || !newPath.trim()}\n onConfirm={() => void handleCreate()}\n onCancel={() => { setCreateOpen(false); setNewPath('') }}\n >\n <input\n value={newPath}\n autoFocus\n onChange={(e) => setNewPath(e.target.value)}\n placeholder=\"e.g. playbooks/new-strategy.md\"\n aria-label=\"New file path\"\n className=\"h-9 w-full rounded-md border border-border bg-background px-3 text-sm text-foreground outline-none placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-primary/60\"\n />\n </ConfirmDialog>\n\n <ConfirmDialog\n open={deleteOpen}\n title=\"Delete file?\"\n description={`This permanently removes ${selectedFile?.path ?? 'this file'} from the vault.`}\n confirmLabel={deleting ? 'Deleting…' : 'Delete file'}\n confirmDisabled={deleting}\n destructive\n onConfirm={() => void handleDelete()}\n onCancel={() => setDeleteOpen(false)}\n />\n\n <ConfirmDialog\n open={pendingNav !== null}\n title=\"Discard unsaved changes?\"\n description=\"Your edits to this document haven't been saved. Continue and lose them?\"\n confirmLabel=\"Discard changes\"\n destructive\n onConfirm={confirmDiscard}\n onCancel={() => setPendingNav(null)}\n />\n </div>\n </EditorErrorBoundary>\n )\n}\n\nfunction SourceEditor({\n path,\n content,\n saving,\n dirty,\n onChange,\n onSave,\n}: {\n path: string\n content: string\n saving: boolean\n dirty: boolean\n onChange: (content: string) => void\n onSave: () => void\n}) {\n return (\n <div className=\"flex h-full min-h-0 flex-col bg-background\">\n <div className=\"flex items-center justify-between gap-2 border-b border-border px-4 py-2\">\n <p className=\"truncate font-mono text-[11px] text-muted-foreground\">{path}</p>\n <div className=\"flex shrink-0 items-center gap-2\">\n <span className=\"rounded-full border border-border bg-background px-2.5 py-1 text-xs text-muted-foreground\">\n {dirty ? 'Unsaved changes' : 'Saved'}\n </span>\n <button\n type=\"button\"\n onClick={onSave}\n disabled={saving || !dirty}\n className=\"inline-flex h-7 items-center rounded-md bg-primary px-2 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-50\"\n >\n {saving ? 'Saving…' : 'Save'}\n </button>\n </div>\n </div>\n <textarea\n value={content}\n onChange={(event) => onChange(event.target.value)}\n spellCheck={false}\n aria-label=\"Source editor\"\n className=\"min-h-0 flex-1 resize-none border-0 bg-background p-4 font-mono text-sm leading-6 text-foreground outline-none\"\n />\n </div>\n )\n}\n","/**\n * Self-contained confirm dialog — no dialog library. A focus-trapped modal with\n * Esc-to-cancel and Enter-to-confirm, used for create / delete / discard-unsaved\n * flows so the pane carries zero UI-kit dependency.\n */\n\nimport { useEffect, useRef, type ReactNode } from 'react'\n\nexport interface ConfirmDialogProps {\n open: boolean\n title: string\n description?: ReactNode\n confirmLabel?: string\n cancelLabel?: string\n /** Styles the confirm button as a destructive action. */\n destructive?: boolean\n /** Disables the confirm button (e.g. while the action is in flight). */\n confirmDisabled?: boolean\n onConfirm: () => void\n onCancel: () => void\n /** Optional body (e.g. an input field for the create flow). */\n children?: ReactNode\n}\n\nexport function ConfirmDialog({\n open,\n title,\n description,\n confirmLabel = 'Confirm',\n cancelLabel = 'Cancel',\n destructive = false,\n confirmDisabled = false,\n onConfirm,\n onCancel,\n children,\n}: ConfirmDialogProps) {\n const panelRef = useRef<HTMLDivElement>(null)\n const confirmRef = useRef<HTMLButtonElement>(null)\n\n useEffect(() => {\n if (!open) return\n confirmRef.current?.focus()\n }, [open])\n\n if (!open) return null\n\n function onKeyDown(event: React.KeyboardEvent) {\n if (event.key === 'Escape') {\n event.preventDefault()\n onCancel()\n return\n }\n if (event.key === 'Enter' && !confirmDisabled) {\n event.preventDefault()\n onConfirm()\n return\n }\n if (event.key !== 'Tab') return\n const focusable = panelRef.current?.querySelectorAll<HTMLElement>(\n 'button:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])',\n )\n if (!focusable || focusable.length === 0) return\n const first = focusable[0]\n const last = focusable[focusable.length - 1]\n const active = document.activeElement as HTMLElement | null\n if (event.shiftKey && active === first) {\n event.preventDefault()\n last?.focus()\n } else if (!event.shiftKey && active === last) {\n event.preventDefault()\n first?.focus()\n }\n }\n\n return (\n <div\n className=\"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4\"\n onMouseDown={(e) => { if (e.target === e.currentTarget) onCancel() }}\n >\n <div\n ref={panelRef}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={title}\n onKeyDown={onKeyDown}\n className=\"w-full max-w-md rounded-lg border border-border bg-card p-5 shadow-lg\"\n >\n <h2 className=\"text-sm font-semibold text-foreground\">{title}</h2>\n {description && <p className=\"mt-1.5 text-xs text-muted-foreground\">{description}</p>}\n {children && <div className=\"mt-3\">{children}</div>}\n <div className=\"mt-5 flex justify-end gap-2\">\n <button\n type=\"button\"\n onClick={onCancel}\n className=\"inline-flex h-8 items-center rounded-md px-3 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/60\"\n >\n {cancelLabel}\n </button>\n <button\n ref={confirmRef}\n type=\"button\"\n onClick={onConfirm}\n disabled={confirmDisabled}\n className={`inline-flex h-8 items-center rounded-md px-3 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/60 disabled:pointer-events-none disabled:opacity-50 ${\n destructive\n ? 'bg-destructive text-destructive-foreground hover:bg-destructive/90'\n : 'bg-primary text-primary-foreground hover:bg-primary/90'\n }`}\n >\n {confirmLabel}\n </button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