@frumu/tandem-panel 0.5.3 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/setup.js +21 -4
- package/dist/assets/AutomationsPage-6mRHsh9V.js +946 -0
- package/dist/assets/BugMonitorPage-B9mcxV8k.js +4 -0
- package/dist/assets/ChannelsPage-oJ5a717t.js +1 -0
- package/dist/assets/ChatInterfacePanel-3nvwn0cJ.js +1 -0
- package/dist/assets/ChatPage-CGKFC9ev.js +1 -0
- package/dist/assets/CodingWorkflowsPage-DosUtoeO.js +8 -0
- package/dist/assets/ControlPanelDialogs-BBIPHXnw.js +1 -0
- package/dist/assets/DashboardPage-Cv9_TUZQ.js +1 -0
- package/dist/assets/ExperimentsPage-DuYHzo7d.js +84 -0
- package/dist/assets/FilesPage-NAInb3WU.js +1 -0
- package/dist/assets/IntentPlannerPage-BwlF9wfW.js +5 -0
- package/dist/assets/LazyJson-DYncL_RR.js +1 -0
- package/dist/assets/MarketplacePage-Wo7biaBa.js +1 -0
- package/dist/assets/McpToolAllowlistEditor-B3qCkiFT.js +1 -0
- package/dist/assets/MemoryImportDialog-BWT93PW1.js +1 -0
- package/dist/assets/MemoryPage-gSBH1OKG.js +1 -0
- package/dist/assets/OrchestratorPage-HDyjjwF-.js +3 -0
- package/dist/assets/PacksPage-BWnL4dRB.js +3 -0
- package/dist/assets/PlannerDiagnosticsPanel-VyacxaCM.js +1 -0
- package/dist/assets/ProviderModelSelector-B_IE0-e7.js +1 -0
- package/dist/assets/RunsPage-B6ttNeUJ.js +1 -0
- package/dist/assets/SettingsPage-DhAKDQHw.js +5 -0
- package/dist/assets/TaskBoard-DSRrmiyQ.js +1 -0
- package/dist/assets/TeamsPage-CwMnVES9.js +4472 -0
- package/dist/assets/TimezoneField-DKINpKxU.js +1 -0
- package/dist/assets/WorkflowStudioPage-CyWDhEEE.js +1854 -0
- package/dist/assets/WorkflowsPage-BWGWH8uD.js +2 -0
- package/dist/assets/api-CpR5ozpc.js +1 -0
- package/dist/assets/chatPageHelpers-D-NhHk4M.js +1 -0
- package/dist/assets/explorerHandoff-KpFRPNQc.js +1 -0
- package/dist/assets/format-CimuGHiH.js +1 -0
- package/dist/assets/fullcalendar-Bn75j0xM.js +1 -0
- package/dist/assets/index-DAWzCKcg.css +1 -0
- package/dist/assets/index-picB46b5.js +3 -0
- package/dist/assets/messages-AWZpX-Rw.js +3 -0
- package/dist/assets/motion-B3ZE8SGR.js +9 -0
- package/dist/assets/plannerShared-1kHFyAp-.js +1 -0
- package/dist/assets/preact-vendor-DaCG_P2o.js +1 -0
- package/dist/assets/react-query-BIbNygEJ.js +1 -0
- package/dist/assets/sse-B1wvyjPI.js +2 -0
- package/dist/assets/ui-CV-Z6sqF.js +1 -0
- package/dist/assets/useEngineStream-ChEkuUVV.js +1 -0
- package/dist/assets/vendor-DSaYtO9f.js +156 -0
- package/dist/assets/workflowStability-Dsk2DR6F.js +2 -0
- package/dist/index.html +10 -7
- package/lib/automations/workflow-list.js +147 -0
- package/lib/setup/control-panel-preferences.js +4 -0
- package/package.json +3 -3
- package/server/routes/capabilities.js +1 -0
- package/server/routes/knowledgebase.js +7 -1
- package/dist/assets/index-D6sUkBw6.css +0 -1
- package/dist/assets/index-gUgdIB3_.js +0 -7379
- package/dist/assets/motion-CBnf8hfk.js +0 -9
- package/dist/assets/preact-vendor-B239Onrg.js +0 -1
- package/dist/assets/react-query-_hsOQSt5.js +0 -1
- package/dist/assets/vendor-DeUDWccs.js +0 -156
- /package/dist/assets/{markdown-Dd89TVib.js → markdown-DJurGVIJ.js} +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import{C as e,E as t,g as n,v as r}from"./fullcalendar-Bn75j0xM.js";import{a as i,n as a,t as o}from"./react-query-BIbNygEJ.js";import{t as s}from"./vendor-DSaYtO9f.js";import{i as c}from"./motion-B3ZE8SGR.js";import{l,n as u,t as d,u as f}from"./ui-CV-Z6sqF.js";import{s as p}from"./index-picB46b5.js";import{r as m}from"./plannerShared-1kHFyAp-.js";var h=`kind: extract_format
|
|
2
|
+
description: Two-node validator-backed workflow for cheap optimization smoke tests.
|
|
3
|
+
status: draft
|
|
4
|
+
schedule:
|
|
5
|
+
type: manual
|
|
6
|
+
timezone: UTC
|
|
7
|
+
misfire_policy: skip
|
|
8
|
+
agents:
|
|
9
|
+
- agent_id: agent-1
|
|
10
|
+
display_name: Extractor
|
|
11
|
+
skills: []
|
|
12
|
+
tool_policy:
|
|
13
|
+
allowlist: []
|
|
14
|
+
denylist: []
|
|
15
|
+
mcp_policy:
|
|
16
|
+
allowed_servers: []
|
|
17
|
+
execution: {}
|
|
18
|
+
output_targets: []
|
|
19
|
+
creator_id: optimization-smoke-pack
|
|
20
|
+
workspace_root: ""
|
|
21
|
+
automation_id: wf-smoke-extract-format
|
|
22
|
+
name: Smoke Extract Format Workflow
|
|
23
|
+
flow:
|
|
24
|
+
nodes:
|
|
25
|
+
- node_id: node-1
|
|
26
|
+
agent_id: agent-1
|
|
27
|
+
objective: Extract the key facts only.
|
|
28
|
+
depends_on: []
|
|
29
|
+
input_refs: []
|
|
30
|
+
retry_policy:
|
|
31
|
+
max_attempts: 1
|
|
32
|
+
timeout_ms: 45000
|
|
33
|
+
- node_id: node-2
|
|
34
|
+
agent_id: agent-1
|
|
35
|
+
objective: Format the extracted facts into a short structured answer.
|
|
36
|
+
depends_on:
|
|
37
|
+
- node-1
|
|
38
|
+
input_refs:
|
|
39
|
+
- from_step_id: node-1
|
|
40
|
+
alias: facts
|
|
41
|
+
output_contract:
|
|
42
|
+
kind: formatted_answer
|
|
43
|
+
validator: structured_json
|
|
44
|
+
summary_guidance: Return a small structured artifact with stable fields.
|
|
45
|
+
retry_policy:
|
|
46
|
+
max_attempts: 1
|
|
47
|
+
timeout_ms: 60000
|
|
48
|
+
`,g=`kind: summary
|
|
49
|
+
description: Single-node validator-backed workflow for cheap optimization smoke tests.
|
|
50
|
+
status: draft
|
|
51
|
+
schedule:
|
|
52
|
+
type: manual
|
|
53
|
+
timezone: UTC
|
|
54
|
+
misfire_policy: skip
|
|
55
|
+
agents:
|
|
56
|
+
- agent_id: agent-1
|
|
57
|
+
display_name: Summarizer
|
|
58
|
+
skills: []
|
|
59
|
+
tool_policy:
|
|
60
|
+
allowlist: []
|
|
61
|
+
denylist: []
|
|
62
|
+
mcp_policy:
|
|
63
|
+
allowed_servers: []
|
|
64
|
+
execution: {}
|
|
65
|
+
output_targets: []
|
|
66
|
+
creator_id: optimization-smoke-pack
|
|
67
|
+
workspace_root: ""
|
|
68
|
+
automation_id: wf-smoke-summary
|
|
69
|
+
name: Smoke Summary Workflow
|
|
70
|
+
flow:
|
|
71
|
+
nodes:
|
|
72
|
+
- node_id: node-1
|
|
73
|
+
agent_id: agent-1
|
|
74
|
+
objective: Write a clear report for the team
|
|
75
|
+
depends_on: []
|
|
76
|
+
input_refs: []
|
|
77
|
+
output_contract:
|
|
78
|
+
kind: summary
|
|
79
|
+
validator: generic_artifact
|
|
80
|
+
summary_guidance: Return a short, clean artifact that a validator can check.
|
|
81
|
+
retry_policy:
|
|
82
|
+
max_attempts: 1
|
|
83
|
+
timeout_ms: 60000
|
|
84
|
+
`;function _(e,t){return Array.isArray(e)?e:Array.isArray(e?.[t])?e[t]:[]}function v(e){let t=String(e||``).trim().toLowerCase();return t===`running`?`tcp-badge-warn`:t.includes(`paused`)?`tcp-badge-info`:t===`completed`?`tcp-badge-ok`:t===`failed`?`tcp-badge-err`:t.includes(`approval`)?`tcp-badge-warn`:`tcp-badge-info`}function y(e){let t=Number(e);return Number.isFinite(t)?t.toFixed(3):`n/a`}var b=Object.entries(Object.assign({"./smoke-workflows/extract-format.yaml":h,"./smoke-workflows/summary.yaml":g})).map(([e,t])=>{let n=s.parse(t);if(!n||typeof n!=`object`)throw Error(`Invalid smoke workflow template at `+e+`: expected a YAML object.`);let r=n,i=String(r.kind||``).trim();if(i!==`summary`&&i!==`extract_format`)throw Error(`Invalid smoke workflow template at `+e+`: missing kind.`);return{kind:i,payload:r}}).sort((e,t)=>e.kind.localeCompare(t.kind));function x(e,t){let n=b.find(t=>t.kind===e);if(!n)throw Error(`Unknown smoke workflow kind: `+e);let{kind:r,...i}=structuredClone(n.payload);return i.workspace_root=String(t||``).trim(),i}function S({client:s,toast:l}){let u=i(),[d,f]=r(``),[h,g]=r({name:``,sourceWorkflowId:``,smokeWorkspaceRoot:``,objectiveRef:`objective.md`,evalRef:`eval.yaml`,mutationPolicyRef:`mutation_policy.yaml`,scopeRef:`scope.yaml`,budgetRef:`budget.yaml`,modelProvider:``,modelId:``,startImmediately:!0}),b=a({queryKey:[`optimizations`,`workflows`,`automations-v2`],queryFn:()=>s?.automationsV2?.list?.().catch(()=>({automations:[]}))??Promise.resolve({automations:[]})}),S=a({queryKey:[`optimizations`,`list`],queryFn:()=>s?.optimizations?.list?.().catch(()=>({optimizations:[]}))??Promise.resolve({optimizations:[]})}),C=a({queryKey:[`optimizations`,`health`],queryFn:()=>s.health().catch(()=>({})),refetchInterval:3e4}),w=a({queryKey:[`optimizations`,`providers`,`catalog`],queryFn:()=>s.providers.catalog().catch(()=>({all:[]})),refetchInterval:3e4}),T=a({queryKey:[`optimizations`,`providers`,`config`],queryFn:()=>s.providers.config().catch(()=>({})),refetchInterval:3e4}),E=n(()=>_(S.data,`optimizations`),[S.data]),D=n(()=>m({providerCatalog:w.data,providerConfig:T.data,defaultProvider:String(T.data?.default||``).trim(),defaultModel:String(T.data?.providers?.[String(T.data?.default||``).trim()]?.default_model||T.data?.providers?.[String(T.data?.default||``).trim()]?.defaultModel||``).trim()}),[w.data,T.data]),O=n(()=>{let e=D.find(e=>e.id===String(h.modelProvider||``).trim());return Array.isArray(e?.models)?e.models:[]},[h.modelProvider,D]);e(()=>{let e=String(C.data?.workspaceRoot||C.data?.workspace_root||``).trim();e&&g(t=>String(t.smokeWorkspaceRoot||``).trim()?t:{...t,smokeWorkspaceRoot:`${e}/docs/internal/optimization-smoke-pack`})},[C.data]);let k=d||String(E[0]?.optimization_id||``).trim(),A=a({queryKey:[`optimizations`,`detail`,k],enabled:!!k,queryFn:()=>s.optimizations.get(k)}),j=a({queryKey:[`optimizations`,`experiments`,k],enabled:!!k,queryFn:()=>s.optimizations.listExperiments(k)}),M=o({mutationFn:async()=>{let e=String(h.sourceWorkflowId||``).trim();if(!e)throw Error(`Source workflow is required.`);let t={name:String(h.name||``).trim()||void 0,source_workflow_id:e,artifacts:{objective_ref:String(h.objectiveRef||``).trim(),eval_ref:String(h.evalRef||``).trim(),mutation_policy_ref:String(h.mutationPolicyRef||``).trim(),scope_ref:String(h.scopeRef||``).trim(),budget_ref:String(h.budgetRef||``).trim()},execution_override:String(h.modelProvider||``).trim()&&String(h.modelId||``).trim()?{provider_id:String(h.modelProvider||``).trim(),model_id:String(h.modelId||``).trim()}:void 0},n=await s.optimizations.create(t);if(h.startImmediately){let e=String(n?.optimization?.optimization_id||``).trim();e&&await s.optimizations.action(e,{action:`start`})}return n},onSuccess:async e=>{let t=String(e?.optimization?.optimization_id||``).trim();l(`ok`,`Optimization campaign created.`),t&&f(t),await u.invalidateQueries({queryKey:[`optimizations`]})},onError:e=>l(`err`,e instanceof Error?e.message:String(e))}),N=o({mutationFn:async e=>{let t=String(h.smokeWorkspaceRoot||``).trim();if(!t)throw Error(`Smoke workflow workspace root is required.`);if(!s?.automationsV2?.create)throw Error(`Workflow creation client is unavailable.`);let n=x(e,t);return s.automationsV2.create(n)},onSuccess:async(e,t)=>{let n=String(e?.automation?.automation_id||e?.automation?.automationId||``).trim();g(t=>({...t,sourceWorkflowId:n||t.sourceWorkflowId,name:n&&!String(t.name||``).trim()?`Optimize ${String(e?.automation?.name||n).trim()}`:t.name})),l(`ok`,t===`summary`?`Smoke summary workflow created and selected.`:`Smoke extract-format workflow created and selected.`),await u.invalidateQueries({queryKey:[`optimizations`,`workflows`,`automations-v2`]})},onError:e=>l(`err`,e instanceof Error?e.message:String(e))}),P=o({mutationFn:async({optimizationId:e,action:t,experimentId:n})=>s.optimizations.action(e,{action:t,experiment_id:n}),onSuccess:async()=>{l(`ok`,`Optimization action applied.`),await u.invalidateQueries({queryKey:[`optimizations`]})},onError:e=>l(`err`,e instanceof Error?e.message:String(e))}),F=o({mutationFn:async({optimizationId:e,experimentId:t})=>s.optimizations.applyWinner(e,t),onSuccess:async()=>{l(`ok`,`Approved winner applied to the live workflow.`),await u.invalidateQueries({queryKey:[`optimizations`]}),await u.invalidateQueries({queryKey:[`optimizations`,`detail`,k]}),await u.invalidateQueries({queryKey:[`optimizations`,`experiments`,k]}),await u.invalidateQueries({queryKey:[`optimizations`,`workflows`,`automations-v2`]})},onError:e=>l(`err`,e instanceof Error?e.message:String(e))}),I=_(b.data,`automations`).map(e=>({id:String(e?.automation_id||e?.automationId||e?.id||``).trim(),name:String(e?.name||e?.automation_id||`Workflow`).trim()})),L=A.data?.optimization||null,R=_(j.data,`experiments`),z=L?.baseline_metrics||null;return c(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(320px,380px),minmax(0,1fr)]`,children:[c(`div`,{className:`grid gap-4`,children:[c(`div`,{className:`rounded-xl border border-slate-700/50 bg-slate-950/40 p-4`,children:[c(`div`,{className:`mb-1 text-sm font-semibold text-slate-100`,children:`New Optimization Campaign`}),c(`div`,{className:`tcp-subtle text-xs`,children:`Create a shadow-eval workflow optimization campaign from an existing automation.`}),c(`div`,{className:`mt-1 text-xs text-slate-500`,children:[`Inspired by`,` `,c(`a`,{className:`text-amber-300 hover:text-amber-200`,href:`https://github.com/karpathy/autoresearch`,target:`_blank`,rel:`noreferrer`,children:`karpathy/autoresearch`}),`.`]}),c(`div`,{className:`mt-3 grid gap-3`,children:[c(`label`,{className:`grid gap-1 text-xs text-slate-300`,children:[c(`span`,{children:`Name`}),c(`input`,{className:`rounded-lg border border-slate-700 bg-slate-950 px-3 py-2 text-sm`,value:h.name,onChange:e=>g(t=>({...t,name:e.target.value})),placeholder:`Optimize research brief workflow`})]}),c(`label`,{className:`grid gap-1 text-xs text-slate-300`,children:[c(`span`,{children:`Source workflow`}),c(`select`,{className:`rounded-lg border border-slate-700 bg-slate-950 px-3 py-2 text-sm`,value:h.sourceWorkflowId,onChange:e=>g(t=>({...t,sourceWorkflowId:e.target.value})),children:[c(`option`,{value:``,children:`Select a workflow`}),I.map(e=>c(`option`,{value:e.id,children:e.name},e.id))]})]}),c(`div`,{className:`rounded-lg border border-slate-800 bg-slate-950/50 p-3`,children:[c(`div`,{className:`text-xs font-medium text-slate-200`,children:`Need a cheap target first?`}),c(`div`,{className:`mt-1 text-[11px] text-slate-500`,children:`Create a tiny validator-backed workflow in the smoke-pack workspace, then use it as the optimization source.`}),c(`label`,{className:`mt-3 grid gap-1 text-xs text-slate-300`,children:[c(`span`,{children:`Smoke workspace root`}),c(`input`,{className:`rounded-lg border border-slate-700 bg-slate-950 px-3 py-2 text-sm`,value:h.smokeWorkspaceRoot,onChange:e=>g(t=>({...t,smokeWorkspaceRoot:e.target.value})),placeholder:`/abs/path/to/docs/internal/optimization-smoke-pack`})]}),c(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[c(`button`,{className:`tcp-btn h-9 px-3 text-xs`,onClick:()=>N.mutate(`summary`),disabled:N.isPending,children:`Create Smoke Summary`}),c(`button`,{className:`tcp-btn h-9 px-3 text-xs`,onClick:()=>N.mutate(`extract_format`),disabled:N.isPending,children:`Create Extract + Format`})]})]}),c(`label`,{className:`grid gap-1 text-xs text-slate-300`,children:[c(`span`,{children:`Model provider`}),c(`select`,{className:`rounded-lg border border-slate-700 bg-slate-950 px-3 py-2 text-sm`,value:h.modelProvider,onChange:e=>g(t=>({...t,modelProvider:e.target.value,modelId:e.target.value&&t.modelProvider!==e.target.value?``:t.modelId})),children:[c(`option`,{value:``,children:`Use workflow/default model`}),D.map(e=>c(`option`,{value:e.id,children:e.id},e.id))]})]}),c(`label`,{className:`grid gap-1 text-xs text-slate-300`,children:[c(`span`,{children:`Model id`}),c(`input`,{className:`rounded-lg border border-slate-700 bg-slate-950 px-3 py-2 text-sm`,value:h.modelId,onChange:e=>g(t=>({...t,modelId:e.target.value})),placeholder:h.modelProvider?`Pick a cheaper model for this campaign`:`Optional`,list:`optimization-model-ids`}),c(`datalist`,{id:`optimization-model-ids`,children:O.map(e=>c(`option`,{value:e},e))}),c(`span`,{className:`tcp-subtle text-[11px]`,children:`Fixed for the whole campaign. Leave blank to use the workflow's existing model settings.`})]}),[[`Objective ref`,`objectiveRef`],[`Eval ref`,`evalRef`],[`Mutation policy ref`,`mutationPolicyRef`],[`Scope ref`,`scopeRef`],[`Budget ref`,`budgetRef`]].map(([e,t])=>c(`label`,{className:`grid gap-1 text-xs text-slate-300`,children:[c(`span`,{children:e}),c(`input`,{className:`rounded-lg border border-slate-700 bg-slate-950 px-3 py-2 text-sm`,value:h[t],onChange:e=>g(n=>({...n,[t]:e.target.value}))})]},t)),c(`label`,{className:`flex items-center gap-2 text-xs text-slate-300`,children:[c(`input`,{type:`checkbox`,checked:h.startImmediately,onChange:e=>g(t=>({...t,startImmediately:e.target.checked}))}),`Start immediately after create`]}),c(`button`,{className:`tcp-btn h-10 px-3 text-sm`,onClick:()=>M.mutate(),disabled:M.isPending,children:M.isPending?`Creating...`:`Create Campaign`})]})]}),c(`div`,{className:`rounded-xl border border-slate-700/50 bg-slate-950/40 p-4`,children:[c(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[c(`div`,{className:`text-sm font-semibold text-slate-100`,children:`Campaigns`}),c(`span`,{className:`tcp-badge-info`,children:E.length})]}),c(`div`,{className:`grid gap-2`,children:E.length?E.map(e=>{let t=String(e?.optimization_id||``).trim();return c(`button`,{type:`button`,className:`rounded-xl border px-3 py-3 text-left transition ${k===t?`border-amber-400/60 bg-amber-400/10`:`border-slate-700/50 bg-slate-950/40 hover:border-slate-600`}`,onClick:()=>f(t),children:[c(`div`,{className:`flex items-center justify-between gap-2`,children:[c(`div`,{className:`font-medium text-slate-100`,children:String(e?.name||t||`Optimization`)}),c(`span`,{className:v(e?.status),children:String(e?.status||`draft`)})]}),c(`div`,{className:`mt-1 text-xs text-slate-400`,children:[`workflow:`,` `,String(e?.source_workflow_name||e?.source_workflow_id||`unknown`)]})]},t)}):c(p,{text:`No optimization campaigns yet.`})})]})]}),c(`div`,{className:`grid gap-4`,children:L?c(t,{children:[c(`div`,{className:`rounded-xl border border-slate-700/50 bg-slate-950/40 p-4`,children:[c(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[c(`div`,{children:[c(`div`,{className:`text-lg font-semibold text-slate-100`,children:String(L?.name||L?.optimization_id||`Optimization`)}),c(`div`,{className:`mt-1 text-sm text-slate-400`,children:[`Source workflow:`,` `,String(L?.source_workflow_name||L?.source_workflow_id||`unknown`)]}),c(`div`,{className:`mt-1 text-xs text-slate-500`,children:[`baseline: `,String(L?.baseline_snapshot_hash||``).slice(0,12)]}),L?.execution_override?c(`div`,{className:`mt-1 text-xs text-slate-500`,children:[`model: `,String(L.execution_override.provider_id||``).trim(),`/`,String(L.execution_override.model_id||``).trim()]}):null]}),c(`div`,{className:`flex flex-wrap gap-2`,children:[c(`button`,{className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>P.mutate({optimizationId:k,action:`start`}),disabled:P.isPending,children:`Start`}),c(`button`,{className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>P.mutate({optimizationId:k,action:`pause`}),disabled:P.isPending,children:`Pause`}),c(`button`,{className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>P.mutate({optimizationId:k,action:`resume`}),disabled:P.isPending,children:`Resume`})]})]}),c(`div`,{className:`mt-4 grid gap-3 md:grid-cols-4`,children:[c(`div`,{className:`rounded-lg border border-slate-800 bg-slate-950/60 p-3`,children:[c(`div`,{className:`text-[11px] uppercase tracking-[0.22em] text-slate-500`,children:`Status`}),c(`div`,{className:`mt-1 text-sm text-slate-100`,children:String(L?.status||`draft`)})]}),c(`div`,{className:`rounded-lg border border-slate-800 bg-slate-950/60 p-3`,children:[c(`div`,{className:`text-[11px] uppercase tracking-[0.22em] text-slate-500`,children:`Pass Rate`}),c(`div`,{className:`mt-1 text-sm text-slate-100`,children:z?y(z.artifact_validator_pass_rate):`n/a`})]}),c(`div`,{className:`rounded-lg border border-slate-800 bg-slate-950/60 p-3`,children:[c(`div`,{className:`text-[11px] uppercase tracking-[0.22em] text-slate-500`,children:`Unmet Reqs`}),c(`div`,{className:`mt-1 text-sm text-slate-100`,children:z?y(z.unmet_requirement_count):`n/a`})]}),c(`div`,{className:`rounded-lg border border-slate-800 bg-slate-950/60 p-3`,children:[c(`div`,{className:`text-[11px] uppercase tracking-[0.22em] text-slate-500`,children:`Blocked Rate`}),c(`div`,{className:`mt-1 text-sm text-slate-100`,children:z?y(z.blocked_node_rate):`n/a`})]})]}),L?.last_pause_reason?c(`div`,{className:`mt-3 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-sm text-amber-200`,children:String(L.last_pause_reason)}):null]}),c(`div`,{className:`rounded-xl border border-slate-700/50 bg-slate-950/40 p-4`,children:[c(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[c(`div`,{className:`text-sm font-semibold text-slate-100`,children:`Experiments`}),c(`span`,{className:`tcp-badge-info`,children:R.length})]}),R.length?c(`div`,{className:`overflow-x-auto`,children:c(`table`,{className:`min-w-full text-left text-sm`,children:[c(`thead`,{className:`text-xs uppercase tracking-[0.22em] text-slate-500`,children:c(`tr`,{children:[c(`th`,{className:`px-2 py-2`,children:`Experiment`}),c(`th`,{className:`px-2 py-2`,children:`Status`}),c(`th`,{className:`px-2 py-2`,children:`Mutation`}),c(`th`,{className:`px-2 py-2`,children:`Pass`}),c(`th`,{className:`px-2 py-2`,children:`Recommendation`}),c(`th`,{className:`px-2 py-2`,children:`Action`})]})}),c(`tbody`,{children:R.map(e=>{let t=String(e?.experiment_id||``).trim(),n=e?.phase1_metrics||{};return c(`tr`,{className:`border-t border-slate-800`,children:[c(`td`,{className:`px-2 py-3 text-slate-200`,children:t||`unknown`}),c(`td`,{className:`px-2 py-3`,children:c(`span`,{className:v(e?.status),children:String(e?.status||`draft`)})}),c(`td`,{className:`px-2 py-3 text-slate-300`,children:String(e?.mutation_summary||`pending`)}),c(`td`,{className:`px-2 py-3 text-slate-300`,children:n?y(n.artifact_validator_pass_rate):`n/a`}),c(`td`,{className:`px-2 py-3 text-slate-300`,children:String(e?.promotion_recommendation||`n/a`)}),c(`td`,{className:`px-2 py-3`,children:c(`div`,{className:`flex flex-wrap gap-2`,children:[c(`button`,{className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>P.mutate({optimizationId:k,action:`approve_winner`,experimentId:t}),disabled:!t||P.isPending,children:`Approve`}),c(`button`,{className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>P.mutate({optimizationId:k,action:`reject_winner`,experimentId:t}),disabled:!t||P.isPending,children:`Reject`}),c(`button`,{className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>F.mutate({optimizationId:k,experimentId:t}),disabled:!t||F.isPending||String(e?.status||``).trim().toLowerCase()!==`promotion_approved`,children:`Apply`})]})})]},t)})})]})}):c(p,{text:`No experiments recorded for this campaign yet.`})]})]}):c(`div`,{className:`rounded-xl border border-slate-700/50 bg-slate-950/40 p-6`,children:c(p,{text:`Select or create an optimization campaign to inspect it.`})})})]})}function C(e,t){return Array.isArray(e)?e:Array.isArray(e?.[t])?e[t]:[]}function w({client:e,toast:t}){let n=i(),r=a({queryKey:[`automations`,`approvals`],queryFn:()=>e?.agentTeams?.listApprovals?.().catch(()=>({spawnApprovals:[]}))??Promise.resolve({spawnApprovals:[]}),refetchInterval:6e3}),s=a({queryKey:[`automations`,`instances`],queryFn:()=>e?.agentTeams?.listInstances?.().catch(()=>({instances:[]}))??Promise.resolve({instances:[]}),refetchInterval:8e3}),l=o({mutationFn:({requestId:t,decision:n})=>e?.agentTeams?.replyApproval?.(t,n),onSuccess:async()=>{t(`ok`,`Approval updated.`),await n.invalidateQueries({queryKey:[`automations`]})},onError:e=>t(`err`,e instanceof Error?e.message:String(e))}),u=C(r.data,`spawnApprovals`),d=C(s.data,`instances`);return c(`div`,{className:`grid gap-4`,children:[u.length>0?c(`div`,{className:`grid gap-2`,children:[c(`p`,{className:`text-xs font-medium uppercase tracking-wide text-slate-500`,children:`Pending Approvals`}),u.map((e,t)=>{let n=String(e?.request_id||e?.id||`request-${t}`);return c(`div`,{className:`tcp-list-item border-amber-500/40`,children:[c(`div`,{className:`mb-1 font-medium text-amber-300`,children:[`⚠️ `,String(e?.reason||e?.title||`Spawn request`)]}),c(`div`,{className:`tcp-subtle text-xs`,children:n}),c(`div`,{className:`mt-2 flex gap-2`,children:[c(`button`,{className:`tcp-btn-primary h-7 px-2 text-xs`,onClick:()=>l.mutate({requestId:n,decision:`approve`}),children:[c(`i`,{"data-lucide":`badge-check`}),`Approve`]}),c(`button`,{className:`tcp-btn-danger h-7 px-2 text-xs`,onClick:()=>l.mutate({requestId:n,decision:`deny`}),children:[c(`i`,{"data-lucide":`x`}),`Deny`]})]})]},n)})]}):null,d.length>0?c(`div`,{className:`grid gap-2`,children:[c(`p`,{className:`text-xs font-medium uppercase tracking-wide text-slate-500`,children:`Active Teams`}),d.map((e,t)=>c(`div`,{className:`tcp-list-item`,children:[c(`div`,{className:`flex items-center justify-between gap-2`,children:[c(`div`,{className:`flex items-center gap-2`,children:[c(`span`,{children:`👥`}),c(`strong`,{children:String(e?.name||e?.template_id||e?.instance_id||`Instance`)})]}),c(`span`,{className:`tcp-badge-info`,children:String(e?.status||`active`)})]}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:[`Mission: `,String(e?.mission_id||`—`)]})]},String(e?.instance_id||e?.id||t)))]}):null,!u.length&&!d.length?c(p,{text:`No active teams or pending approvals right now.`}):null]})}function T({client:e,toast:n,navigate:r}){return c(d,{className:`grid gap-4`,children:[c(l,{eyebrow:`Opt-in surface`,title:`Experiments`,subtitle:`This page stays hidden by default. Turn it on from Settings > Navigation when you want access to the experimental automation surfaces.`,badges:c(t,{children:[c(u,{tone:`warn`,children:`Hidden by default`}),c(u,{tone:`ghost`,children:`Settings required`})]}),actions:c(`button`,{type:`button`,className:`tcp-btn-primary`,onClick:()=>r(`settings`),children:`Open Settings`})}),c(f,{title:`Why this is separate`,subtitle:`These tools are useful, but they are not the main entry point for new users.`,children:c(`div`,{className:`grid gap-3 text-sm text-slate-200`,children:[c(`p`,{children:`Keep the Automations page focused on the core loop: create, schedule, review, and run.`}),c(`p`,{className:`tcp-subtle`,children:`Experiments is where we park the exploratory surfaces until they have a clearer home.`})]})}),c(f,{title:`Optimization campaigns`,subtitle:`Shadow evals, optimization runs, and the related workflow tooling.`,children:c(S,{client:e,toast:n})}),c(f,{title:`Teams and approvals`,subtitle:`Pending spawn approvals and active team instances.`,children:c(w,{client:e,toast:n})})]})}export{T as ExperimentsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,E as t,g as n,h as r,v as i}from"./fullcalendar-Bn75j0xM.js";import{a,n as o,t as s}from"./react-query-BIbNygEJ.js";import{i as c,n as ee,r as l}from"./motion-B3ZE8SGR.js";import{i as u,m as d,n as f,t as p,u as te}from"./ui-CV-Z6sqF.js";import{a as ne,s as m,t as h,u as re}from"./index-picB46b5.js";import{i as g,n as ie,t as ae}from"./explorerHandoff-KpFRPNQc.js";import{n as _,t as oe}from"./ControlPanelDialogs-BBIPHXnw.js";import{t as se}from"./MemoryImportDialog-BWT93PW1.js";var v=3,y=`.md,.markdown,.txt,text/plain,text/markdown`,b=[10,25,50,100],ce=25;function le(){return`${Date.now()}-${Math.random().toString(16).slice(2)}`}function ue(e){let t=String(e||``).trim();if(!t)return``;let n=t.split(`/`);return(n[n.length-1]||t).replace(/\.[^.]+$/,``)}function x(e){return Array.isArray(e)?e:Array.isArray(e?.documents)?e.documents:Array.isArray(e?.items)?e.items:e?.document&&typeof e.document==`object`?[e.document]:[]}function S(e){let t=String(e.collection_id||``).trim();if(t)return t;let n=String(e.doc_id||e.id||``).trim(),r=n.indexOf(`/`);return r>0?n.slice(0,r):``}function de(e){let t=S(e),n=String(e.doc_id||e.id||``).trim();return!t||!n?``:`${t}|${n}`}function fe(e){let t=Number(e||0);return t?new Date(t).toLocaleString():`n/a`}function pe(e){let t=Number(e||0);if(!t)return`n/a`;if(t<1024)return`${t} B`;let n=[`KB`,`MB`,`GB`,`TB`],r=t/1024,i=0;for(;r>=1024&&i<n.length-1;)r/=1024,i+=1;return`${r.toFixed(r>=10?0:1)} ${n[i]}`}function me(e){let t=String(e?.content_type||``).toLowerCase(),n=String(e?.title||e?.filename||e?.file_name||``).toLowerCase();return t.includes(`markdown`)||n.endsWith(`.md`)||n.endsWith(`.markdown`)?`markdown`:t.includes(`json`)||n.endsWith(`.json`)?`json`:`text`}function C(e){let t=S(e||{}),n=String(e?.doc_id||e?.id||``).trim();return!t||!n?``:n.startsWith(`${t}/`)?n.slice(t.length+1):n}function w(e,t){return!Number.isFinite(e)||e<1||!Number.isFinite(t)||t<1?1:Math.min(e,t)}function T(e,t,n){if(!n)return`0 of 0`;let r=w(e,Math.max(1,Math.ceil(n/Math.max(1,t)))),i=Math.max(1,t);return`${(r-1)*i+1}-${Math.min(n,r*i)} of ${n}`}function he({api:t,toast:p,defaultCollectionId:m}){let h=a(),g=r(null),ie=r(null),ae=r(null),_=r(new Map),se=r(new Map),he=r(0),[E,D]=i(``),[O,ge]=i(!1),[_e,ve]=i(!1),[ye,be]=i(!1),[xe,Se]=i(``),[k,Ce]=i(``),[we,A]=i(!1),[Te,j]=i(!1),[Ee,M]=i(``),[De,N]=i(``),[P,Oe]=i(1),[F,ke]=i(ce),[I,Ae]=i(null),[je,Me]=i([]),[Ne,Pe]=i(null),[L,Fe]=i(null),[R,z]=i([]),[Ie,B]=i(!1),V=o({queryKey:[`knowledgebase`,`config`],queryFn:async()=>t(`/api/knowledgebase/config`).catch(()=>({configured:!1})),staleTime:6e4}).data?.configured===!0,Le=o({queryKey:[`knowledgebase`,`collections`],enabled:V,queryFn:async()=>t(`/api/knowledgebase/collections`).catch(()=>({collections:[]})),staleTime:3e4,refetchInterval:6e4}),Re=Array.isArray(Le.data?.collections)?Le.data.collections:[];e(()=>{if(O)return;let e=String(m||``).trim();!E.trim()&&e&&D(e)},[E,O,m]),e(()=>{if(O||E.trim())return;let e=String(Re[0]?.collection_id||``).trim();e&&D(e)},[E,O,Re]),e(()=>{let e=ae.current;e&&(e.setAttribute(`webkitdirectory`,``),e.setAttribute(`directory`,``))},[]);let H=E.trim();e(()=>{Oe(1),Me([]),Ae(null),Ce(``),A(!0),j(!1),N(``)},[H]),e(()=>{Oe(1)},[xe]);let ze=(Math.max(1,P)-1)*Math.max(1,F),U=xe.trim(),W=o({queryKey:[`knowledgebase`,`documents`,H||`__all__`,U,P,F],enabled:V,queryFn:async()=>{let e=new URLSearchParams;return H&&e.set(`collection_id`,H),e.set(`limit`,String(Math.max(1,F))),e.set(`offset`,String(Math.max(0,ze))),U&&e.set(`query`,U),t(`/api/knowledgebase/documents?${e.toString()}`).catch(()=>({collection_id:H||null,documents:[],total:0,offset:ze,limit:F,has_more:!1}))},staleTime:15e3,refetchInterval:H?3e4:!1}),Be=W.data||{},G=n(()=>x(Be),[Be]),Ve=Math.max(0,Number(Be.total??G.length??0)),K=Math.max(1,Number(Be.limit??F)||F),q=Math.max(0,Number(Be.offset??ze)||ze),He=Math.max(1,Math.ceil(Math.max(Ve,G.length)/Math.max(1,F))),J=w(P,He),Ue=q,We=G,Ge=T(J,K,Ve);e(()=>{P!==J&&Oe(J)},[P,J]),e(()=>{k&&A(!0)},[k]);let Ke=Re,qe=n(()=>[...Ke].sort((e,t)=>String(e.collection_id).localeCompare(String(t.collection_id))),[Ke]),Je=n(()=>{let e=new Map,t=t=>{let n=typeof t==`string`?t.trim():String(t?.collection_id||``).trim();!n||e.has(n)||e.set(n,typeof t==`string`?{collection_id:n}:{...t,collection_id:n})};t(m);for(let e of qe)t(e);return t(H),Array.from(e.values()).sort((e,t)=>String(e.collection_id).localeCompare(String(t.collection_id)))},[qe,H,m]),Ye=Je.some(e=>String(e.collection_id||``).trim()===H)?H:`__custom__`,Xe=Ye===`__custom__`,Ze=n(()=>new Set(je.map(e=>e.key)),[je]),Qe=je,$e=Qe.length,Y=n(()=>I||null,[I]),et=String(Y?.slug||``).trim(),X=String(Y?.collection||``).trim(),Z=o({queryKey:[`knowledgebase`,`document`,X,et],enabled:V&&!!X&&!!et,queryFn:async()=>t(`/api/knowledgebase/documents/${encodeURIComponent(X)}/${encodeURIComponent(et)}`),staleTime:3e4}),Q=Z.data?.document||Z.data||null,tt=me(Q||Y),nt=String(Q?.title||Q?.filename||Q?.file_name||Y?.title||Y?.slug||`Document`).trim(),rt=String(Q?.path||Q?.doc_id||(Y?`${Y.collection}/${Y.slug}`:``)||``).trim(),$=String(Q?.content||Q?.excerpt||``),it=Z.error?Z.error instanceof Error?Z.error.message:String(Z.error):``,at=Number(Q?.updated_at||Q?.created_at||0),ot=Number(Q?.size_bytes||0),st=!!(X&&et),ct=Y?c(`div`,{className:`flex min-h-0 flex-col rounded-xl border border-white/10 bg-black/20 p-3`,children:[c(`div`,{className:`flex items-start justify-between gap-3`,children:[c(`div`,{className:`min-w-0`,children:[c(`div`,{className:`truncate text-sm font-semibold text-slate-100`,children:nt}),c(`div`,{className:`tcp-subtle mt-1 truncate text-xs`,children:rt||et||H})]}),c(`div`,{className:`flex flex-col items-end gap-2`,children:[c(f,{tone:`info`,children:X||H}),c(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[c(`button`,{type:`button`,className:`tcp-btn h-7 w-7 justify-center px-0`,title:`Refresh preview`,"aria-label":`Refresh preview`,onClick:()=>void Z.refetch(),disabled:!k,children:[c(`i`,{"data-lucide":`refresh-cw`}),c(`span`,{className:`sr-only`,children:`Refresh preview`})]}),c(`button`,{type:`button`,className:`tcp-btn h-7 w-7 justify-center px-0`,title:`Copy document content`,"aria-label":`Copy document content`,onClick:()=>void vt(),disabled:!$.trim(),children:[c(`i`,{"data-lucide":`copy`}),c(`span`,{className:`sr-only`,children:`Copy document content`})]}),c(`button`,{type:`button`,className:`tcp-btn h-7 w-7 justify-center border-rose-500/30 px-0 text-rose-200 hover:bg-rose-950/20`,title:`Delete document`,"aria-label":`Delete document`,onClick:()=>Pe({collection:X,slug:et,title:nt}),disabled:!st,children:[c(`i`,{"data-lucide":`trash-2`}),c(`span`,{className:`sr-only`,children:`Delete document`})]})]})]})]}),c(`div`,{className:`mt-3 grid grid-cols-3 gap-2 text-xs`,children:[c(`div`,{className:`rounded-lg border border-white/10 bg-black/10 p-2`,children:[c(`div`,{className:`tcp-subtle`,children:`Type`}),c(`div`,{className:`mt-1 font-medium`,children:String(Q?.content_type||tt||`text`)})]}),c(`div`,{className:`rounded-lg border border-white/10 bg-black/10 p-2`,children:[c(`div`,{className:`tcp-subtle`,children:`Updated`}),c(`div`,{className:`mt-1 font-medium`,children:fe(at)})]}),c(`div`,{className:`rounded-lg border border-white/10 bg-black/10 p-2`,children:[c(`div`,{className:`tcp-subtle`,children:`Size`}),c(`div`,{className:`mt-1 font-medium`,children:pe(ot)})]})]}),c(`div`,{className:`mt-3 rounded-xl border border-white/10 bg-black/10 p-3 text-xs`,children:[c(`div`,{className:`tcp-subtle uppercase tracking-wide`,children:`Excerpt`}),c(`div`,{className:`mt-1 whitespace-pre-wrap break-words text-slate-200`,children:String(Q?.excerpt||$.slice(0,600)||`No excerpt returned.`)})]}),Z.isLoading&&!Q?c(`div`,{className:`mt-3 rounded-xl border border-white/10 bg-black/20 p-3 text-sm tcp-subtle`,children:`Loading preview...`}):it?c(`div`,{className:`mt-3`,children:c(u,{title:`Preview unavailable`,text:it})}):Te?c(`div`,{className:`mt-3 flex min-h-0 flex-1 flex-col gap-3 rounded-xl border border-sky-500/30 bg-sky-950/10 p-3`,children:[c(`div`,{className:`flex items-center justify-between gap-3`,children:[c(`div`,{className:`tcp-subtle text-xs uppercase tracking-wide`,children:`Edit document in place`}),c(`div`,{className:`flex flex-wrap gap-2`,children:[c(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>{j(!1),N(``),M(String($||``))},children:`Cancel`}),c(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>void yt(),children:[c(`i`,{"data-lucide":`save`}),`Save`]})]})]}),De?c(`div`,{className:`rounded-lg border border-rose-500/30 bg-rose-950/20 p-2 text-xs text-rose-200`,children:De}):null,c(`textarea`,{className:`tcp-input min-h-[340px] flex-1 resize-none font-mono text-xs leading-6`,value:Ee,onChange:e=>M(e.target.value),spellCheck:!1})]}):we?c(`div`,{className:`mt-3 flex min-h-0 flex-1 flex-col gap-3 rounded-xl border border-white/10 bg-black/20 p-3`,children:[c(`div`,{className:`flex items-center justify-between gap-3`,children:[c(`div`,{className:`tcp-subtle text-xs uppercase tracking-wide`,children:`Document content`}),c(`div`,{className:`flex flex-wrap gap-2`,children:[c(`button`,{type:`button`,className:`tcp-btn h-7 w-7 justify-center px-0`,title:`Edit document`,"aria-label":`Edit document`,onClick:()=>{N(``),j(!0),M(String($||``))},disabled:!$.trim(),children:[c(`i`,{"data-lucide":`square-pen`}),c(`span`,{className:`sr-only`,children:`Edit document`})]}),c(`button`,{type:`button`,className:`tcp-btn h-7 w-7 justify-center px-0`,title:`Collapse preview`,"aria-label":`Collapse preview`,onClick:()=>A(!1),children:[c(`i`,{"data-lucide":`chevron-up`}),c(`span`,{className:`sr-only`,children:`Collapse preview`})]})]})]}),c(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-xl border border-white/10 bg-black/20 p-3`,children:$?tt===`markdown`?c(`div`,{className:`tcp-markdown tcp-markdown-ai`,dangerouslySetInnerHTML:{__html:re($)}}):c(`pre`,{className:`tcp-code whitespace-pre-wrap break-words`,children:$}):c(u,{title:`No preview content`,text:`This document did not return preview text from the KB service.`})})]}):c(u,{title:`Preview collapsed`,text:`Open the document content when you want to inspect or edit it. The list stays compact until you expand a file.`,action:c(`div`,{className:`flex flex-wrap gap-2`,children:[c(`button`,{type:`button`,className:`tcp-btn h-8 w-8 justify-center px-0`,title:`Open content`,"aria-label":`Open content`,onClick:()=>A(!0),children:[c(`i`,{"data-lucide":`chevron-down`}),c(`span`,{className:`sr-only`,children:`Open content`})]}),c(`button`,{type:`button`,className:`tcp-btn h-8 w-8 justify-center px-0`,title:`Edit in place`,"aria-label":`Edit in place`,onClick:()=>{A(!0),N(``),j(!0),M(String($||``))},disabled:!$.trim(),children:[c(`i`,{"data-lucide":`square-pen`}),c(`span`,{className:`sr-only`,children:`Edit in place`})]})]})})]}):null;e(()=>{Te||M(String($||``))},[Te,$,k]);let lt=R.filter(e=>e.status===`done`||e.status===`error`);e(()=>{for(let e of R){if(e.status!==`done`&&e.status!==`error`||_.current.has(e.id))continue;let t=se.current.get(e.id)??he.current++%6;se.current.set(e.id,t);let n=3e3+t*350,r=window.setTimeout(()=>{z(t=>t.filter(t=>t.id!==e.id)),_.current.delete(e.id),se.current.delete(e.id)},n);_.current.set(e.id,r)}let e=new Set(R.map(e=>e.id));for(let[t,n]of _.current.entries())e.has(t)||(window.clearTimeout(n),_.current.delete(t),se.current.delete(t))},[R]),e(()=>()=>{for(let e of _.current.values())window.clearTimeout(e);_.current.clear(),se.current.clear()},[]),e(()=>{g.current&&ne(g.current)},[qe.length,Je.length,R.length,P,F,Ve,q,K,H,Ie,V,G.length,We.length,k,I,$e,xe,Z.data,Z.isFetching,we,Te,_e,ye]);let ut=()=>{for(let e of R){if(e.status!==`done`&&e.status!==`error`)continue;let t=_.current.get(e.id);typeof t==`number`&&window.clearTimeout(t),_.current.delete(e.id),se.current.delete(e.id)}z(e=>e.filter(e=>e.status===`queued`||e.status===`uploading`))},dt=s({mutationFn:({file:e,targetCollection:t})=>new Promise((n,r)=>{let i=le();z(t=>[...t,{id:i,name:e.name,progress:0,status:`queued`,error:``}]);let a=new XMLHttpRequest;a.open(`POST`,`/api/knowledgebase/documents`),a.withCredentials=!0,a.responseType=`json`;let o=new FormData;o.set(`collection_id`,t),o.set(`title`,ue(e.name)),o.set(`file`,e,e.name),a.upload.onprogress=e=>{if(!e.lengthComputable)return;let t=e.loaded/e.total*100;z(e=>e.map(e=>e.id===i?{...e,status:`uploading`,progress:t}:e))},a.onerror=()=>{z(e=>e.map(e=>e.id===i?{...e,status:`error`,error:`Network error`,progress:Math.max(e.progress,4)}:e)),r(Error(`KB upload failed: ${e.name}`))},a.onload=()=>{let o=a.response||{};if(a.status<200||a.status>=300||o?.ok===!1){let e=String(o?.error||`Upload failed (${a.status})`);z(t=>t.map(t=>t.id===i?{...t,status:`error`,error:e,progress:Math.max(t.progress,4)}:t)),r(Error(e));return}let s=o?.document&&typeof o.document==`object`?o.document:o?.doc||o?.item||{},c=String(s?.doc_id||s?.id||o?.doc_id||``).trim(),ee=String(s?.collection_id||t).trim(),l=String(s?.title||s?.filename||s?.file_name||ue(e.name)||e.name).trim();z(e=>e.map(e=>e.id===i?{...e,status:`done`,progress:100,error:``,result:{docId:c,collectionId:ee,title:l}}:e)),n(o)},z(e=>e.map(e=>e.id===i?{...e,status:`uploading`}:e)),a.send(o)})}),ft=async e=>{let t=[...e||[]],n=E.trim();if(!V||!t.length)return;if(!n){p(`warn`,`Choose a knowledgebase collection first.`);return}B(!0);let r=0,i=0,a=0;try{let e=Array.from({length:Math.min(v,t.length)},async()=>{for(;;){let e=a;if(a+=1,e>=t.length)return;let o=t[e];try{await dt.mutateAsync({file:o,targetCollection:n}),r+=1}catch{i+=1}}});await Promise.all(e),await h.invalidateQueries({queryKey:[`knowledgebase`,`collections`]}),await h.invalidateQueries({queryKey:[`knowledgebase`,`documents`]}),r&&i?p(`warn`,`Uploaded ${r} file(s) to ${n}; ${i} failed.`):r?p(`ok`,`Uploaded ${r} file(s) to ${n}.`):i&&p(`err`,`All ${i} KB upload(s) failed.`)}finally{B(!1)}},pt=async()=>{try{await t(`/api/knowledgebase/reindex`,{method:`POST`}),p(`ok`,`Knowledgebase reindex requested.`)}catch(e){p(`err`,e instanceof Error?e.message:String(e))}},mt=e=>{let t=String(S(e)||H).trim(),n=C(e),r=de(e);return!t||!n||!r?null:{collection:t,slug:n,title:String(e.title||e.filename||e.file_name||e.doc_id||n).trim(),key:r}},ht=e=>{let t=mt(e);t&&Me(e=>e.some(e=>e.key===t.key)?e.filter(e=>e.key!==t.key):[...e,t])},gt=()=>{let e=G.map(e=>mt(e)).filter(e=>!!e);Me(t=>{let n=new Map(t.map(e=>[e.key,e]));for(let t of e)n.set(t.key,t);return[...n.values()]})},_t=()=>{Me([])},vt=async()=>{let e=String($||``).trim();if(!e){p(`warn`,`No document content is available to copy.`);return}try{await navigator.clipboard.writeText(e),p(`ok`,`Document content copied to clipboard.`)}catch{p(`warn`,`Could not copy the document content.`)}},yt=async()=>{let e=String(X||``).trim(),t=String(et||``).trim();if(!e||!t){p(`warn`,`Pick a document before saving edits.`);return}N(``);try{let n=new FormData;n.set(`title`,String(nt||``).trim()||t),n.set(`content`,Ee);let r=await fetch(`/api/knowledgebase/documents/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PUT`,credentials:`include`,body:n}),i=await r.text(),a={};if(i)try{a=JSON.parse(i)}catch{a={}}if(!r.ok||a?.ok===!1){let e=String(a?.error||i||`Update failed (${r.status})`);throw Error(e)}j(!1),A(!0),p(`ok`,`Document updated.`),await h.invalidateQueries({queryKey:[`knowledgebase`,`documents`]}),await h.invalidateQueries({queryKey:[`knowledgebase`,`document`]}),await W.refetch(),await Z.refetch()}catch(e){let t=e instanceof Error?e.message:String(e);N(t),p(`err`,t)}},bt=()=>{if(!Qe.length){p(`warn`,`Select one or more documents first.`);return}Fe({documents:Qe.map(({collection:e,slug:t,title:n,key:r})=>({collection:e,slug:t,title:n,key:r}))})},xt=async()=>{let e=String(Ne?.collection||``).trim(),t=String(Ne?.slug||``).trim();if(!e||!t){p(`warn`,`Pick a document before deleting it.`);return}try{let n=await fetch(`/api/knowledgebase/documents/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`DELETE`,credentials:`include`}),r=await n.text(),i={};if(r)try{i=JSON.parse(r)}catch{i={}}if(!n.ok||i?.ok===!1){let e=String(i?.error||r||`Delete failed (${n.status})`);throw Error(e)}let a=I?.key||``;Ce(``),Ae(null),Me(e=>e.filter(e=>e.key!==a)),A(!1),j(!1),M(``),N(``),Pe(null),p(`ok`,`Document deleted.`),await h.invalidateQueries({queryKey:[`knowledgebase`,`collections`]}),await h.invalidateQueries({queryKey:[`knowledgebase`,`documents`]}),await W.refetch()}catch(e){p(`err`,e instanceof Error?e.message:String(e))}},St=async()=>{let e=L?.documents||[];if(!e.length){p(`warn`,`Select one or more documents first.`);return}let t=new Map(je.map(e=>[e.key,e])),n=0,r=0;try{for(let i of e)try{let e=await fetch(`/api/knowledgebase/documents/${encodeURIComponent(i.collection)}/${encodeURIComponent(i.slug)}`,{method:`DELETE`,credentials:`include`}),r=await e.text(),a={};if(r)try{a=JSON.parse(r)}catch{a={}}if(!e.ok||a?.ok===!1){let t=String(a?.error||r||`Delete failed (${e.status})`);throw Error(t)}n+=1,t.delete(i.key)}catch{r+=1}Me([...t.values()]),I?.key&&!t.has(I.key)&&(Ce(``),Ae(null),A(!1),j(!1),M(``),N(``)),Fe(null),n&&r?p(`warn`,`Deleted ${n} document(s); ${r} failed.`):n?p(`ok`,`Deleted ${n} document(s).`):p(`err`,`All ${r} selected document deletions failed.`),await h.invalidateQueries({queryKey:[`knowledgebase`,`collections`]}),await h.invalidateQueries({queryKey:[`knowledgebase`,`documents`]}),await W.refetch()}catch(e){p(`err`,e instanceof Error?e.message:String(e))}};return V?c(te,{className:`overflow-hidden`,title:`Knowledgebase`,subtitle:`Provisioned-server docs live in KB collections searched through MCP, not in the file buckets below.`,actions:c(d,{className:`justify-start`,children:[c(`button`,{type:`button`,className:`tcp-icon-btn`,title:`Upload documents`,"aria-label":`Upload documents`,onClick:()=>ie.current?.click(),disabled:Ie,children:c(`i`,{"data-lucide":`upload`})}),c(`button`,{type:`button`,className:`tcp-icon-btn`,title:`Upload folder`,"aria-label":`Upload folder`,onClick:()=>ae.current?.click(),disabled:Ie,children:c(`i`,{"data-lucide":`folder-up`})}),c(`button`,{type:`button`,className:`tcp-icon-btn`,title:`Refresh collections`,"aria-label":`Refresh collections`,onClick:()=>void Le.refetch(),children:c(`i`,{"data-lucide":`refresh-cw`})}),c(`button`,{type:`button`,className:`tcp-icon-btn`,title:`Reindex knowledgebase`,"aria-label":`Reindex knowledgebase`,onClick:pt,children:c(`i`,{"data-lucide":`sparkles`})}),c(`button`,{type:`button`,className:`tcp-icon-btn`,title:_e?`Expand knowledgebase`:`Collapse knowledgebase`,"aria-label":_e?`Expand knowledgebase`:`Collapse knowledgebase`,onClick:()=>ve(e=>!e),children:c(`i`,{"data-lucide":_e?`chevron-down`:`chevron-up`})})]}),children:c(`div`,{ref:g,className:_e?`hidden`:`grid gap-4 p-4`,children:[c(`div`,{className:`grid gap-2`,children:[c(`label`,{className:`tcp-subtle text-xs uppercase tracking-wide`,htmlFor:`kb-collection-select`,children:`Collection`}),c(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center`,children:[c(`div`,{className:`relative min-w-[min(100%,18rem)] flex-1`,children:[c(`select`,{id:`kb-collection-select`,className:`tcp-select h-10 w-full appearance-none pr-10 font-semibold text-slate-100`,value:Ye,onChange:e=>{let t=e.target.value;if(ge(!0),t===`__custom__`){D(``);return}D(t)},children:[Je.length?Je.map(e=>{let t=String(e.collection_id||``).trim();return c(`option`,{value:t,children:[t,typeof e.document_count==`number`?` (${e.document_count})`:``]},t)}):c(`option`,{value:``,children:`No collections yet`}),c(`option`,{value:`__custom__`,children:`Create new collection...`})]}),c(`i`,{"data-lucide":`chevron-down`,className:`pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-slate-400`})]}),Xe?c(`input`,{id:`kb-collection-id`,className:`tcp-input h-10 min-w-[min(100%,18rem)] flex-1`,value:E,onChange:e=>{ge(!0),D(e.target.value)},placeholder:`new-customer-collection`,spellCheck:!1}):c(`button`,{type:`button`,className:`tcp-icon-btn h-10 w-10 shrink-0`,title:`Create a new collection`,"aria-label":`Create a new collection`,onClick:()=>{ge(!0),D(``)},children:c(`i`,{"data-lucide":`plus`})}),c(`div`,{className:`flex shrink-0 gap-2`,children:[c(`input`,{ref:ie,type:`file`,multiple:!0,accept:y,className:`hidden`,onChange:e=>{ft(e.target.files),e.currentTarget.value=``}}),c(`input`,{ref:ae,type:`file`,multiple:!0,accept:y,className:`hidden`,onChange:e=>{ft(e.target.files),e.currentTarget.value=``}}),c(`button`,{type:`button`,className:`tcp-icon-btn h-10 w-10`,title:`Select files`,"aria-label":`Select files`,onClick:()=>ie.current?.click(),disabled:!H||Ie,children:c(`i`,{"data-lucide":`files`})}),c(`button`,{type:`button`,className:`tcp-icon-btn h-10 w-10`,onClick:()=>ae.current?.click(),disabled:!H||Ie,title:`Select a local folder and upload all matching docs inside it`,"aria-label":`Select a local folder`,children:c(`i`,{"data-lucide":`folder-open`})})]})]}),c(`div`,{className:`tcp-subtle text-xs`,children:`Pick an existing KB MCP collection, or type a new collection ID before uploading.`})]}),c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3 text-sm`,children:[c(`div`,{className:`font-medium text-slate-100`,children:`How this works`}),c(`div`,{className:`tcp-subtle mt-1`,children:"The KB MCP reads from collections in the hosted knowledgebase service. It does not browse a raw server folder directly, so uploads here will not appear in the managed `Files` buckets below unless you upload them there separately."})]}),R.length?c(`div`,{className:`grid gap-2`,children:[c(`div`,{className:`flex items-center justify-between gap-3`,children:[c(`div`,{className:`tcp-subtle text-xs uppercase tracking-wide`,children:`Upload history`}),lt.length?c(`button`,{type:`button`,className:`tcp-icon-btn h-7 w-7`,title:`Clear finished uploads`,"aria-label":`Clear finished uploads`,onClick:ut,children:c(`i`,{"data-lucide":`x`})}):null]}),c(`div`,{className:`grid gap-2`,children:R.map(e=>c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3 text-xs`,children:[c(`div`,{className:`flex items-center justify-between gap-3`,children:[c(`div`,{className:`min-w-0`,children:[c(`div`,{className:`truncate font-medium`,children:e.name}),c(`div`,{className:`tcp-subtle mt-1 truncate`,children:[e.result?.collectionId||H||`collection`,` •`,` `,e.status]}),e.result?.docId?c(`div`,{className:`tcp-subtle mt-1 truncate text-[11px]`,children:e.result.docId}):null]}),c(f,{tone:e.status===`done`?`ok`:e.status===`error`?`err`:`info`,children:[Math.round(e.progress),`%`]})]}),c(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-white/10`,children:c(`div`,{className:`h-full rounded-full ${e.status===`error`?`bg-rose-400`:e.status===`done`?`bg-emerald-400`:`bg-sky-400`}`,style:{width:`${Math.max(4,Math.min(100,e.progress||0))}%`}})}),e.error?c(`div`,{className:`mt-2 text-rose-200`,children:e.error}):null]},e.id))})]}):null,c(`div`,{className:`grid gap-2`,children:[c(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[c(`div`,{children:[c(`div`,{className:`tcp-subtle text-xs uppercase tracking-wide`,children:`Collection documents`}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:`Showing what the selected KB collection currently contains.`})]}),c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(f,{tone:`ghost`,children:Ve}),c(f,{tone:$e?`info`:`ghost`,children:[$e,` selected`]}),c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:`Refresh documents`,"aria-label":`Refresh documents`,onClick:()=>void W.refetch(),disabled:!H,children:c(`i`,{"data-lucide":`refresh-cw`})}),c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:ye?`Expand collection documents`:`Collapse collection documents`,"aria-label":ye?`Expand collection documents`:`Collapse collection documents`,onClick:()=>be(e=>!e),children:c(`i`,{"data-lucide":ye?`chevron-down`:`chevron-up`})})]})]}),ye?c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3 text-sm tcp-subtle`,children:`Collection documents are collapsed.`}):H?W.isFetching&&!G.length?c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3 text-sm tcp-subtle`,children:[`Loading documents from`,` `,c(`span`,{className:`font-medium text-slate-200`,children:H}),`.`]}):G.length?c(`div`,{className:`grid gap-4`,children:c(`div`,{className:`grid min-h-0 gap-3`,children:[c(`div`,{className:`grid gap-2 rounded-xl border border-white/10 bg-black/20 p-3`,children:[c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(`input`,{className:`tcp-input h-9 min-w-[220px] flex-1`,value:xe,onChange:e=>Se(e.target.value),placeholder:`Filter documents`,spellCheck:!1}),c(f,{tone:`ghost`,children:Ge})]}),c(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:`Select all visible documents`,"aria-label":`Select all visible documents`,onClick:gt,disabled:!G.length,children:c(`i`,{"data-lucide":`square-check-big`})}),c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:`Clear selected documents`,"aria-label":`Clear selected documents`,onClick:_t,disabled:!$e,children:c(`i`,{"data-lucide":`x`})}),c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8 border-rose-500/30 text-rose-100 hover:bg-rose-950/20 disabled:opacity-50`,title:`Delete selected documents`,"aria-label":`Delete selected documents`,onClick:bt,disabled:!$e,children:c(`i`,{"data-lucide":`trash-2`})})]}),c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(`label`,{className:`flex items-center gap-2 text-[11px] uppercase tracking-wide text-slate-500`,children:[c(`span`,{children:`Per page`}),c(`select`,{className:`tcp-select h-8 min-w-[5.5rem] px-3 text-center text-sm font-semibold tabular-nums text-slate-100 [text-align-last:center]`,value:F,onChange:e=>{ke(Number(e.target.value)||ce),Oe(1)},children:b.map(e=>c(`option`,{value:e,children:e},e))})]}),c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:`Previous page`,"aria-label":`Previous page`,onClick:()=>Oe(e=>w(e-1,He)),disabled:J<=1,children:c(`i`,{"data-lucide":`chevron-left`})}),c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:`Next page`,"aria-label":`Next page`,onClick:()=>Oe(e=>w(e+1,He)),disabled:J>=He,children:c(`i`,{"data-lucide":`chevron-right`})})]})]})]}),We.length?c(`div`,{className:`grid gap-2`,children:We.map((e,t)=>{let n=String(e.doc_id||e.id||``).trim(),r=String(e.title||e.filename||e.file_name||n||`Document ${Ue+t+1}`).trim(),i=String(e.collection_id||H).trim(),a=Number(e.updated_at||e.created_at||0),o=de(e),s=!!o,u=s&&Ze.has(o),d=o===k;return c(ee.div,{layout:!0,children:c(`div`,{className:`flex items-start gap-3`,children:[c(`label`,{className:`mt-3 flex h-6 w-6 items-center justify-center rounded border ${s?`border-white/15 bg-black/20 text-slate-200 cursor-pointer hover:border-sky-500/40`:`border-white/10 bg-black/10 text-slate-500`}`,children:c(`input`,{type:`checkbox`,className:`h-4 w-4 accent-sky-400`,checked:u,disabled:!s,onChange:()=>ht(e),"aria-label":`Select ${r}`})}),c(`div`,{className:`min-w-0 flex-1`,children:[c(`button`,{type:`button`,className:`w-full rounded-xl border p-3 text-left text-sm transition ${d?`border-sky-500/50 bg-sky-950/20`:u?`border-emerald-500/40 bg-emerald-950/20 hover:border-emerald-400/50 hover:bg-emerald-950/30`:`border-white/10 bg-black/20 hover:border-white/20 hover:bg-black/30`}`.trim(),onClick:()=>{let t=mt(e);if(d){Ce(``),Ae(null),A(!1),j(!1),N(``);return}Ce(o),t&&Ae(t),A(!0),j(!1),N(``)},"aria-expanded":d,children:[c(`div`,{className:`flex items-start justify-between gap-3`,children:[c(`div`,{className:`min-w-0`,children:[c(`div`,{className:`truncate font-medium text-slate-100`,children:r}),c(`div`,{className:`tcp-subtle mt-1 truncate text-xs`,children:n||`${i}/${r}`})]}),c(f,{tone:d?`ok`:u?`info`:`ghost`,children:i})]}),c(`div`,{className:`mt-2 flex flex-wrap gap-2 text-xs tcp-subtle`,children:[c(`span`,{children:[`Updated: `,fe(a)]}),e.content_type?c(`span`,{children:e.content_type}):null]})]}),c(l,{initial:!1,children:d?c(ee.div,{initial:{opacity:0,height:0,y:-8},animate:{opacity:1,height:`auto`,y:0},exit:{opacity:0,height:0,y:-8},transition:{duration:.22,ease:`easeOut`},className:`overflow-hidden`,children:c(`div`,{className:`mt-2`,children:ct})},`${k}-expanded`):null})]})]})},n||`${i}-${r}-${t}`)})}):c(u,{title:U?`No documents match your filter`:`No documents found`,text:U?`Try another search term or clear the filter to show the full collection.`:`This collection does not contain any documents yet.`,action:U?c(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>Se(``),children:`Clear filter`}):null})]})}):c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3 text-sm tcp-subtle`,children:[`No visible documents returned for`,` `,c(`span`,{className:`font-medium text-slate-200`,children:H}),`. If you just uploaded a file, refresh docs or reindex and confirm the KB admin service exposes document listing for that collection.`]}):c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3 text-sm tcp-subtle`,children:`Pick or type a collection ID to inspect its documents.`})]}),c(oe,{open:!!Ne,title:`Delete document`,message:c(`span`,{children:[`This will permanently remove`,` `,c(`strong`,{children:Ne?.title||`this document`}),` from`,` `,c(`strong`,{children:Ne?.collection||H||`the selected collection`}),`.`]}),confirmLabel:`Delete document`,confirmIcon:`trash-2`,confirmTone:`danger`,onCancel:()=>Pe(null),onConfirm:()=>void xt()}),c(oe,{open:!!L,title:`Delete selected documents`,message:c(`span`,{children:[`This will permanently remove`,` `,c(`strong`,{children:[L?.documents.length||0,` selected document(s)`]}),` from`,` `,c(`strong`,{children:H||`the selected collection`}),`.`]}),confirmLabel:`Delete selected`,confirmIcon:`trash-2`,confirmTone:`danger`,widthClassName:`w-[min(42rem,96vw)]`,onCancel:()=>Fe(null),onConfirm:()=>void St(),children:L?.documents.length?c(`div`,{className:`mt-3 grid gap-2 rounded-xl border border-white/10 bg-black/20 p-3 text-left text-xs`,children:[c(`div`,{className:`tcp-subtle uppercase tracking-wide`,children:`Selected documents`}),c(`div`,{className:`max-h-40 overflow-auto`,children:[L.documents.slice(0,12).map(e=>c(`div`,{className:`truncate py-1`,children:[c(`span`,{className:`font-medium text-slate-100`,children:e.title||e.slug}),c(`span`,{className:`tcp-subtle`,children:[` `,`· `,e.collection,`/`,e.slug]})]},`${e.collection}|${e.slug}`)),L.documents.length>12?c(`div`,{className:`pt-1 text-slate-400`,children:[`+`,L.documents.length-12,` more`]}):null]})]}):null})]})}):null}var E=`__global__`;function D(e){return e===`collection`?`Collection override`:e===`global`?`Global override`:`Default`}function O(e){return e===`collection`?`ok`:e===`global`?`info`:`warn`}function ge({api:r,toast:ee}){let l=a(),[u,p]=i(!0),[m,h]=i(E),[re,g]=i({}),[ie,ae]=i({}),[_,se]=i({}),[v,y]=i(null),b=o({queryKey:[`knowledgebase`,`config`],queryFn:async()=>r(`/api/knowledgebase/config`).catch(()=>({configured:!1})),staleTime:6e4}).data?.configured===!0,ce=o({queryKey:[`knowledgebase`,`collections`],enabled:b,queryFn:async()=>r(`/api/knowledgebase/collections`).catch(()=>({collections:[]})),staleTime:3e4}),le=Array.isArray(ce.data?.collections)?ce.data.collections:[],ue=m===E?``:m,x=o({queryKey:[`knowledgebase`,`prompts`,ue||`__global__`],enabled:b&&!u,queryFn:async()=>await r(`/api/knowledgebase/prompts${ue?`?collection_id=${encodeURIComponent(ue)}`:``}`)}),S=x.data?.prompts||[];e(()=>{let e=x.data?.prompts||[];e.length&&g(t=>{let n={...t};for(let t of e)t.key in n||(n[t.key]=m===E?t.global_override??t.default:t.collection_override??t.global_override??t.default);return n})},[x.dataUpdatedAt,m]),e(()=>{g({})},[m]);let de=s({mutationFn:async({key:e,value:t,collection_id:n})=>{let i={value:t};return n&&(i.collection_id=n),r(`/api/knowledgebase/prompts/${encodeURIComponent(e)}`,{method:`PUT`,body:JSON.stringify(i)})},onSuccess:async(e,t)=>{ee(`ok`,`Saved prompt "${t.key}".`),await l.invalidateQueries({queryKey:[`knowledgebase`,`prompts`]}),g(e=>{let n={...e};return delete n[t.key],n})},onError:e=>{ee(`err`,`Save failed: ${e?.message||`Save failed.`}`)}}),fe=s({mutationFn:async({key:e,collection_id:t})=>{let n=t?`?collection_id=${encodeURIComponent(t)}`:``;return r(`/api/knowledgebase/prompts/${encodeURIComponent(e)}${n}`,{method:`DELETE`})},onSuccess:async(e,t)=>{ee(`ok`,t.collection_id?`Reverted "${t.key}" for collection "${t.collection_id}".`:`Reverted global "${t.key}" to default.`),await l.invalidateQueries({queryKey:[`knowledgebase`,`prompts`]}),g(e=>{let n={...e};return delete n[t.key],n})},onError:e=>{ee(`err`,`Reset failed: ${e?.message||`Reset failed.`}`)}}),pe=n(()=>le.map(e=>String(e.collection_id||``).trim()).filter(Boolean).sort(),[le]);return b?c(te,{title:`Agent prompts`,subtitle:`Edit how the AI agent answers questions from this knowledgebase. Defaults are shipped in code; overrides take effect on the next agent session or answer_question call.`,actions:c(d,{className:`justify-end`,children:c(`button`,{type:`button`,className:`tcp-btn h-8 w-8 justify-center px-0`,title:u?`Expand prompts`:`Collapse prompts`,"aria-label":u?`Expand prompts`:`Collapse prompts`,onClick:()=>p(e=>!e),ref:e=>{e&&ne(e)},children:c(`i`,{"data-lucide":u?`chevron-down`:`chevron-up`,"aria-hidden":`true`})})}),children:[u?null:c(`div`,{className:`flex flex-col gap-4`,children:[c(`div`,{className:`flex flex-wrap items-center gap-3 rounded-lg border border-white/10 bg-black/20 p-3 text-sm`,children:[c(`label`,{className:`flex items-center gap-2`,children:[c(`span`,{className:`tcp-subtle`,children:`Scope:`}),c(`select`,{className:`tcp-input h-8 px-2`,value:m,onChange:e=>h(e.target.value),children:[c(`option`,{value:E,children:`Global (all collections)`}),pe.map(e=>c(`option`,{value:e,children:[`Collection: `,e]},e))]})]}),c(`span`,{className:`tcp-subtle text-xs`,children:m===E?`Global overrides apply to every collection unless a collection-specific override exists.`:`Editing overrides for collection "${m}". Collection overrides take precedence over global ones.`})]}),x.isLoading?c(`div`,{className:`tcp-subtle p-4 text-sm`,children:`Loading prompts…`}):x.isError?c(`div`,{className:`rounded-lg border border-rose-500/30 bg-rose-950/20 p-3 text-sm text-rose-200`,children:[`Failed to load prompts: `,x.error?.message||`Unknown error.`]}):S.length===0?c(`div`,{className:`tcp-subtle p-4 text-sm`,children:`No prompts available.`}):c(`div`,{className:`flex flex-col gap-3`,children:S.map(e=>{let t=!!ie[e.key],n=re[e.key]??e.current,r=m!==E&&!e.supports_collection_override,i=m===E?e.global_override!==null:e.collection_override!==null,a=!!_[e.key],o=n!==(m===E?e.global_override??e.default:e.collection_override??e.global_override??e.default);return c(`div`,{className:`rounded-lg border border-white/10 bg-black/20 p-3`,children:[c(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[c(`div`,{className:`flex flex-col`,children:[c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(`span`,{className:`font-mono text-sm`,children:e.key}),c(f,{tone:O(e.scope),children:D(e.scope)}),e.supports_collection_override?null:c(f,{tone:`warn`,children:`Global only`}),e.collection_overrides.length>0?c(`span`,{className:`tcp-subtle text-xs`,children:[e.collection_overrides.length,` collection override`,e.collection_overrides.length===1?``:`s`]}):null]}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:e.description})]}),c(d,{className:`justify-end`,children:c(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>ae(t=>({...t,[e.key]:!t[e.key]})),children:t?`Collapse`:`Edit`})})]}),t?c(`div`,{className:`mt-3 flex flex-col gap-2`,children:[r?c(`div`,{className:`rounded border border-amber-500/30 bg-amber-950/20 p-2 text-xs text-amber-200`,children:`This prompt is global only — it is sent before any collection is selected, so per-collection overrides are not supported. Switch scope back to Global to edit it.`}):null,c(`div`,{className:`flex items-center gap-2`,children:[c(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>se(t=>({...t,[e.key]:!t[e.key]})),children:a?`Hide default`:`Show default`}),e.global_override!==null&&m!==E?c(`span`,{className:`tcp-subtle text-xs`,children:`Inherits a global override when no collection override is set.`}):null]}),a?c(`div`,{className:`rounded border border-white/10 bg-black/30 p-2`,children:[c(`div`,{className:`tcp-subtle text-[10px] uppercase tracking-wide`,children:`Built-in default`}),c(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-5`,children:e.default})]}):null,c(`textarea`,{className:`tcp-input min-h-[200px] resize-y font-mono text-xs leading-6`,value:n,disabled:r,onChange:t=>g(n=>({...n,[e.key]:t.target.value}))}),c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,disabled:r||!o||!n.trim()||de.isPending,onClick:()=>de.mutate({key:e.key,value:n,collection_id:m===E?void 0:m}),children:[`Save `,m===E?`global`:`collection`,` override`]}),c(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,disabled:r||!i||fe.isPending,onClick:()=>y({key:e.key,collectionId:m===E?null:m}),children:[`Reset `,m===E?`global`:`collection`,` to default`]}),o?c(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>g(t=>{let n={...t};return delete n[e.key],n}),children:`Discard changes`}):null]}),e.collection_overrides.length>0?c(`div`,{className:`mt-1 rounded border border-white/10 bg-black/30 p-2 text-xs`,children:[c(`div`,{className:`tcp-subtle uppercase tracking-wide`,children:`Collections with overrides`}),c(`ul`,{className:`mt-1 flex flex-wrap gap-2`,children:e.collection_overrides.map(e=>c(`li`,{children:c(`button`,{type:`button`,className:`tcp-btn h-6 px-2 text-[11px]`,onClick:()=>h(e.collection_id),children:e.collection_id})},e.collection_id))})]}):null]}):null]},e.key)})})]}),c(oe,{open:v!==null,title:`Reset prompt to default?`,message:v?c(`span`,{children:v.collectionId?c(t,{children:[`This removes the override for `,c(`code`,{children:v.key}),` on collection`,` `,c(`code`,{children:v.collectionId}),`. The agent will fall back to the global override (if any) or the built-in default for this collection. Other collections are unaffected.`]}):c(t,{children:[`This removes the global override for `,c(`code`,{children:v.key}),`. The agent will fall back to the built-in default. Per-collection overrides for this prompt remain in place.`]})}):``,confirmLabel:`Reset`,confirmIcon:`rotate-ccw`,confirmTone:`danger`,confirmDisabled:fe.isPending,onCancel:()=>y(null),onConfirm:()=>{v&&(fe.mutate({key:v.key,collection_id:v.collectionId??void 0}),y(null))}})]}):null}var _e=[`uploads`,`artifacts`,`exports`],ve=new Set([`text`,`markdown`,`json`,`yaml`]),ye=[10,25,50,100],be=25;function xe(e){let t=Number(e||0);return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function Se(e){let t=Number(e||0);return t?new Date(t).toLocaleString():`n/a`}function k(e,t){return Array.isArray(e)?e:Array.isArray(e?.[t])?e[t]:[]}function Ce(e){let t=String(e||``).trim();return t?t.split(`/`).filter(Boolean).length:0}function we(e,t=!0){let n=String(e||``).trim().replace(/\\/g,`/`).replace(/^\/+/,``).replace(/\/+$/,``);if(!n)return t?``:null;if(n.includes(`\0`))return null;let r=n.split(`/`).filter(Boolean);return r.length?r.some(e=>e===`.`||e===`..`)?null:r.join(`/`):t?``:null}function A(e){let t=String(e||``).trim().replace(/\\/g,`/`).replace(/\/+$/g,``);return!t||!t.includes(`/`)?``:t.split(`/`).slice(0,-1).join(`/`)}function Te(e,t){return!Number.isFinite(e)||e<1||!Number.isFinite(t)||t<1?1:Math.min(e,t)}function j(e,t,n){if(!n)return`0 of 0`;let r=Te(e,Math.max(1,Math.ceil(n/Math.max(1,t)))),i=Math.max(1,t);return`${(r-1)*i+1}-${Math.min(n,r*i)} of ${n}`}function Ee({api:l,client:u,toast:v}){let y=a(),b=h(),ce=r(null),le=r(null),ue=r(null),[x,S]=i(`managed`),[de,fe]=i(!1),[pe,me]=i(!1),[C,w]=i(``),[T,E]=i(``),[D,O]=i(null),[Ee,M]=i([]),[De,N]=i(1),[P,Oe]=i(be),[F,ke]=i([]),[I,Ae]=i(null),[je,Me]=i(null);e(()=>{let e=ae();e&&(S(`managed`),e.dir?w(e.dir):e.path&&w(g(e.path)),E(e.path||e.dir||``))},[]);let Ne=b.data?.workspace_files_api_available===!0,Pe=Ne&&b.data?.workspace_files_available===!0&&!de;e(()=>{Pe&&(x!==`managed`||C||T||S(`workspace`))},[Pe,x,C,T]);let L=x===`workspace`,Fe=L?`/api/workspace/files`:`/api/files`,R=o({queryKey:[`files`,x,C],queryFn:async()=>l(`${Fe}/list?dir=${encodeURIComponent(C)}`).catch(e=>(L&&Number(e?.status||0)===404&&(fe(!0),S(`managed`),w(``)),{dir:C,parent:null,directories:[],files:[]})),refetchInterval:15e3}),z=String(R.data?.dir||``).trim(),Ie=String(R.data?.parent||``).trim(),B=k(R.data,`directories`),V=k(R.data,`files`);e(()=>{let e=new Set(V.map(e=>String(e.path||``).trim()).filter(Boolean));ke(t=>t.filter(t=>e.has(t)))},[V]),e(()=>{N(1)},[C]);let Le=n(()=>new Set(F),[F]),Re=n(()=>V.filter(e=>Le.has(String(e.path||``).trim())),[V,Le]),H=Re.length,ze=Math.max(1,Math.ceil(V.length/Math.max(1,P))),U=Te(De,ze),W=(U-1)*Math.max(1,P),Be=V.slice(W,W+Math.max(1,P)),G=j(U,P,V.length);e(()=>{De!==U&&N(U)},[De,U]);let Ve=n(()=>V.find(e=>String(e?.path||``)===T)||B.find(e=>String(e?.path||``)===T)||null,[R.data,T]),K=!!Ve&&String(Ve?.previewKind||``)===`directory`||!!z&&T===z,q=Ve&&!K?Ve:null,He=String(q?.mime||``).trim(),J=String(q?.previewKind||``).trim(),Ue=q?.downloadUrl||`${Fe}/download?path=${encodeURIComponent(T)}`,We=o({queryKey:[`files`,x,`read`,T],enabled:!!q&&ve.has(J),queryFn:async()=>l(`${Fe}/read?path=${encodeURIComponent(T)}`).catch(e=>({ok:!1,previewable:!1,reason:`unavailable`,error:e instanceof Error?e.message:String(e)}))}),Ge=B.length+V.length,Ke=Ce(z),qe=!!q&&ve.has(J)&&We.data?.previewable!==!1,Je=We.isFetching&&qe;e(()=>{ce.current&&ne(ce.current)},[Ge,B.length,V.length,De,P,Be.length,H,T,J,K,Ee.length,z,x,pe,We.data?.previewable]);let Ye=s({mutationFn:({file:e,targetDir:t,surface:n,relativePath:r})=>new Promise((i,a)=>{let o=`${Date.now()}-${Math.random().toString(16).slice(2)}`;M(t=>[...t,{id:o,name:e.name,progress:0,error:``}]);let s=new XMLHttpRequest,c=n===`workspace`?`/api/workspace/files/upload`:`/api/files/upload`;s.open(`POST`,`${c}?dir=${encodeURIComponent(t)}`),s.withCredentials=!0,s.responseType=`json`,s.setRequestHeader(`x-file-name`,encodeURIComponent(e.name)),n===`workspace`&&r&&s.setRequestHeader(`x-relative-path`,encodeURIComponent(r)),s.upload.onprogress=e=>{if(!e.lengthComputable)return;let t=e.loaded/e.total*100;M(e=>e.map(e=>e.id===o?{...e,progress:t}:e))},s.onerror=()=>{M(e=>e.map(e=>e.id===o?{...e,error:`Network error`}:e)),window.setTimeout(()=>{M(e=>e.filter(e=>e.id!==o))},1200),a(Error(`Upload failed: ${e.name}`))},s.onload=()=>{let e=s.response||{};if(s.status<200||s.status>=300||e?.ok===!1){let t=String(e?.error||`Upload failed (${s.status})`);M(e=>e.map(e=>e.id===o?{...e,error:t}:e)),window.setTimeout(()=>{M(e=>e.filter(e=>e.id!==o))},1600),a(Error(t));return}M(e=>e.filter(e=>e.id!==o)),i(e)},s.send(e)}),onSuccess:async(e,t)=>{let n=String(e?.path||``).trim();if(n){let e=String(t.targetDir||``).trim()||g(n);t.surface===`managed`&&!C&&e===`uploads`&&w(`uploads`),E(n)}await y.invalidateQueries({queryKey:[`files`]}),v(`ok`,`Uploaded ${String(t.file?.name||`file`)} into ${t.targetDir||(t.surface===`workspace`?`Workspace`:`uploads`)}.`)},onError:e=>v(`err`,e instanceof Error?e.message:String(e))}),Xe=s({mutationFn:async e=>l(`${Fe}/mkdir`,{method:`POST`,body:JSON.stringify({path:e})}),onSuccess:async e=>{let t=String(e?.path||``).trim();t&&(w(t),E(t)),await y.invalidateQueries({queryKey:[`files`]}),v(`ok`,`Created folder ${t||`folder`}.`)},onError:e=>v(`err`,e instanceof Error?e.message:String(e))}),Ze=async e=>{let t=[...e||[]];if(!t.length)return;let n=L?C:C||`uploads`;for(let e of t){let t=L?String(e.webkitRelativePath||e.name):void 0;await Ye.mutateAsync({file:e,targetDir:n,surface:x,relativePath:t}).catch(()=>void 0)}!L&&!C&&w(`uploads`)},Qe=()=>{let e=String(C||``).trim();if(!L&&!e){v(`warn`,`Choose a bucket before creating folders.`);return}O({baseDir:e,value:L?`new-folder`:`knowledgebooks/new-collection`})},$e=async()=>{let e=D;if(!e)return;let t=String(e.value||``).trim().replace(/^\/+|\/+$/g,``).replace(/\/{2,}/g,`/`);if(!t){v(`warn`,`Enter a folder name.`);return}O(null),await Xe.mutateAsync(e.baseDir?`${e.baseDir}/${t}`:t)},Y=e=>{let t=L?we(e,!0):ie(e);t&&(w(t),E(t))},et=()=>{if(!Ie){w(``),E(``);return}w(Ie),E(Ie)},X=()=>{w(``),E(``)},Z=e=>{let t=String(e||``).trim();t&&ke(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},Q=()=>{let e=V.map(e=>String(e.path||``).trim()).filter(Boolean);ke(Array.from(new Set(e)))},tt=()=>{ke([])},nt=()=>{if(!Re.length){v(`warn`,`Select one or more files first.`);return}Ae({files:Re.map(e=>({path:String(e.path||``).trim(),name:String(e.name||e.path||``).trim()}))})},rt=()=>{let e=``,t=``;K&&T?e=T:H?(e=A(Re[0]?.path||``),t=`Import the containing folder for now.`):q?(e=A(q.path||T),t=`Import the containing folder for now.`):z?e=z:L&&(e=`.`),Me({path:e,note:t})},$=async()=>{let e=I?.files||[];if(!e.length){v(`warn`,`Select one or more files first.`);return}let t=new Set(F),n=0,r=0;for(let i of e)try{await l(`${Fe}/delete`,{method:`POST`,body:JSON.stringify({path:i.path})}),n+=1,t.delete(i.path)}catch{r+=1}ke(Array.from(t)),E(t=>e.some(e=>e.path===t)?``:t),Ae(null),await y.invalidateQueries({queryKey:[`files`]}),n&&r?v(`warn`,`Deleted ${n} file(s); ${r} failed.`):n?v(`ok`,`Deleted ${n} file(s).`):v(`err`,`All ${r} selected file deletions failed.`)},it=e=>{e!==x&&(S(e),w(``),E(``),ke([]),N(1))},at=L?z||`Workspace`:z||`Root`,ot=String(We.data?.reason||``).trim(),st=String(We.data?.text||``).trim(),ct=_e.length,lt=String(b.data?.hosted_deployment_slug||b.data?.hosted_hostname||``).trim(),ut=lt,dt=ut?`project`:`global`;return c(p,{className:`grid h-full min-h-0 gap-4`,children:[c(he,{api:l,toast:v,defaultCollectionId:lt}),c(ge,{api:l,toast:v}),c(te,{fullHeight:!0,title:`Files`,subtitle:L?`Browse and edit the hosted workspace.`:`Browse managed uploads, published artifacts, and exports.`,actions:c(d,{className:`justify-start`,children:[c(`button`,{type:`button`,className:`tcp-icon-btn`,title:`Upload files`,"aria-label":`Upload files`,onClick:()=>le.current?.click(),disabled:Ye.isPending,children:c(`i`,{"data-lucide":`upload`})}),L?c(`button`,{type:`button`,className:`tcp-icon-btn`,title:`Upload folder`,"aria-label":`Upload folder`,onClick:()=>ue.current?.click(),disabled:Ye.isPending,children:c(`i`,{"data-lucide":`folder-up`})}):null,c(`button`,{type:`button`,className:`tcp-icon-btn`,onClick:Qe,disabled:Xe.isPending||!L&&!C,title:!L&&!C?`Choose a bucket first`:`Create a folder inside the current path`,"aria-label":`Create folder`,children:c(`i`,{"data-lucide":`folder-plus`})}),c(`button`,{type:`button`,className:`tcp-icon-btn`,title:`Import to Memory`,"aria-label":`Import to Memory`,onClick:rt,children:c(`i`,{"data-lucide":`database-zap`})}),c(`button`,{type:`button`,className:`tcp-icon-btn`,title:`Refresh files`,"aria-label":`Refresh files`,onClick:()=>void R.refetch(),children:c(`i`,{"data-lucide":`refresh-cw`})}),c(`button`,{type:`button`,className:`tcp-icon-btn`,title:`Go up one folder`,"aria-label":`Go up one folder`,onClick:et,disabled:!z,children:c(`i`,{"data-lucide":`corner-up-left`})}),c(`button`,{type:`button`,className:`tcp-icon-btn`,title:pe?`Expand files`:`Collapse files`,"aria-label":pe?`Expand files`:`Collapse files`,onClick:()=>me(e=>!e),children:c(`i`,{"data-lucide":pe?`chevron-down`:`chevron-up`})})]}),children:c(`div`,{ref:ce,className:pe?`hidden`:`grid min-h-0 gap-4 xl:grid-cols-[280px_minmax(0,1fr)_360px]`,children:[c(te,{fullHeight:!0,className:`overflow-hidden`,title:`Locations`,subtitle:L?`Hosted workspace root.`:`Managed file buckets.`,actions:c(f,{tone:`ghost`,children:L?`workspace`:ct}),children:c(`div`,{className:`grid min-h-0 gap-3 p-4`,children:[c(`div`,{className:`grid grid-cols-2 gap-2`,children:[c(`button`,{type:`button`,className:`tcp-btn h-9 justify-center px-2 text-xs ${L?`border-sky-500/40 bg-sky-950/20`:``}`.trim(),onClick:()=>it(`workspace`),disabled:!Pe,title:Pe?`Browse the workspace`:Ne?`Workspace root is not configured`:`Workspace file browsing is not available on this deployment`,children:[c(`i`,{"data-lucide":`folder-code`}),`Workspace`]}),c(`button`,{type:`button`,className:`tcp-btn h-9 justify-center px-2 text-xs ${L?``:`border-sky-500/40 bg-sky-950/20`}`.trim(),onClick:()=>it(`managed`),children:[c(`i`,{"data-lucide":`archive`}),`Managed`]})]}),c(`div`,{className:`grid gap-1`,children:[c(`button`,{type:`button`,className:`tcp-list-item w-full text-left ${z?``:`border-sky-500/40 bg-sky-950/20`}`,onClick:X,children:[c(`i`,{"data-lucide":`hard-drive`}),L?`Workspace root`:`Root`]}),L?null:_e.map(e=>c(`button`,{type:`button`,className:`tcp-list-item w-full text-left ${z===e?`border-sky-500/40 bg-sky-950/20`:``}`,onClick:()=>Y(e),children:[c(`i`,{"data-lucide":`folder-open`}),c(`span`,{className:`flex min-w-0 flex-1 items-center justify-between gap-2`,children:[c(`span`,{className:`truncate`,children:e}),c(`span`,{className:`tcp-subtle text-[11px]`,children:e===`uploads`?`managed`:e})]})]},e))]}),c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3`,children:[c(`div`,{className:`tcp-subtle text-xs uppercase tracking-wide`,children:`Path`}),c(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[c(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-xs`,onClick:X,children:L?`Workspace`:`Root`}),z.split(`/`).filter(Boolean).reduce((e,t)=>{let n=e.length?`${e[e.length-1]}/${t}`:t;return e.push(n),e},[]).map(e=>c(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-xs ${e===z?`border-sky-500/40 bg-sky-950/20`:``}`.trim(),onClick:()=>Y(e),children:e.split(`/`).pop()||e},e))]})]}),Ee.length?c(`div`,{className:`grid gap-2`,children:[c(`div`,{className:`tcp-subtle text-xs uppercase tracking-wide`,children:`Uploads`}),c(`div`,{className:`grid gap-2`,children:Ee.map(e=>c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-2 text-xs`,children:[c(`div`,{className:`flex items-center justify-between gap-2`,children:[c(`span`,{className:`truncate`,children:e.name}),c(`span`,{className:`tcp-subtle`,children:[Math.round(e.progress),`%`]})]}),c(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-white/10`,children:c(`div`,{className:`h-full rounded-full ${e.error?`bg-rose-400`:`bg-sky-400`}`,style:{width:`${Math.max(4,Math.min(100,e.progress||0))}%`}})}),e.error?c(`div`,{className:`mt-1 text-rose-200`,children:e.error}):null]},e.id))})]}):null]})}),c(te,{fullHeight:!0,className:`overflow-hidden`,title:at,subtitle:!L&&Ke===0?`Select a bucket to browse its files.`:`${B.length} folder${B.length===1?``:`s`} and ${V.length} file${V.length===1?``:`s`}`,actions:c(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[c(`span`,{className:`tcp-badge tcp-badge-ghost`,children:at}),J?c(f,{tone:`info`,children:J}):null,K?c(f,{tone:`ghost`,children:`folder`}):null]}),children:c(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-4`,children:[c(`div`,{className:`tcp-toolbar`,children:[c(`span`,{className:`tcp-badge-info`,children:[B.length,` folder`,B.length===1?``:`s`]}),c(`span`,{className:`tcp-badge-info`,children:[V.length,` file`,V.length===1?``:`s`]}),c(`span`,{className:C?`tcp-badge-ok`:`tcp-badge tcp-badge-ghost`,children:C?`browsing`:`root`})]}),c(`div`,{className:`grid min-h-0 gap-2 overflow-auto pr-1`,children:!L&&Ke===0?c(m,{text:`Pick a bucket on the left, or upload a file to start browsing.`,title:`No folder selected`}):B.length||V.length?c(t,{children:[B.map(e=>{let t=String(e?.path||``);return c(`button`,{type:`button`,className:`tcp-list-item w-full text-left ${t===T?`border-sky-500/40 bg-sky-950/20`:``}`,onClick:()=>Y(t),children:[c(`i`,{"data-lucide":`folder-open`}),c(`div`,{className:`min-w-0 flex-1`,children:[c(`div`,{className:`flex items-center justify-between gap-2`,children:[c(`strong`,{className:`truncate`,children:String(e?.name||t)}),c(`span`,{className:`tcp-subtle text-xs`,children:`folder`})]}),c(`div`,{className:`mt-1 flex items-center justify-between gap-2 text-xs tcp-subtle`,children:[c(`span`,{className:`truncate`,children:t}),c(`span`,{children:Se(Number(e?.updatedAt||0))})]})]})]},`dir-${t}`)}),c(`div`,{className:`grid gap-2 rounded-xl border border-white/10 bg-black/20 p-3`,children:[c(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(f,{tone:`ghost`,children:G}),c(f,{tone:H?`info`:`ghost`,children:[H,` selected`]})]}),c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:`Import selected file folder to memory`,"aria-label":`Import selected file folder to memory`,onClick:rt,disabled:!H,children:c(`i`,{"data-lucide":`database-zap`})}),c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:`Select all visible files`,"aria-label":`Select all visible files`,onClick:Q,disabled:!V.length,children:c(`i`,{"data-lucide":`square-check-big`})}),c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:`Clear selected files`,"aria-label":`Clear selected files`,onClick:tt,disabled:!H,children:c(`i`,{"data-lucide":`x`})}),c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8 border-rose-500/30 text-rose-100 hover:bg-rose-950/20 disabled:opacity-50`,title:`Delete selected files`,"aria-label":`Delete selected files`,onClick:nt,disabled:!H,children:c(`i`,{"data-lucide":`trash-2`})}),c(`label`,{className:`flex items-center gap-2 text-[11px] uppercase tracking-wide text-slate-500`,children:[c(`span`,{children:`Per page`}),c(`select`,{className:`tcp-select h-8 min-w-[5.5rem] px-3 text-center text-sm font-semibold tabular-nums text-slate-100 [text-align-last:center]`,value:P,onChange:e=>{Oe(Number(e.target.value)||be),N(1)},children:ye.map(e=>c(`option`,{value:e,children:e},e))})]}),c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:`Previous page`,"aria-label":`Previous page`,onClick:()=>N(e=>Te(e-1,ze)),disabled:U<=1,children:c(`i`,{"data-lucide":`chevron-left`})}),c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:`Next page`,"aria-label":`Next page`,onClick:()=>N(e=>Te(e+1,ze)),disabled:U>=ze,children:c(`i`,{"data-lucide":`chevron-right`})})]})]}),c(`div`,{className:`grid gap-2`,children:Be.map(e=>{let t=String(e?.path||``),n=t===T,r=Le.has(t),i=String(e?.previewKind||`file`);return c(ee.div,{layout:!0,children:c(`div`,{className:`flex items-start gap-3`,children:[c(`label`,{className:`mt-3 flex h-6 w-6 items-center justify-center rounded border ${t?`border-white/15 bg-black/20 text-slate-200 cursor-pointer hover:border-sky-500/40`:`border-white/10 bg-black/10 text-slate-500`}`,children:c(`input`,{type:`checkbox`,className:`h-4 w-4 accent-sky-400`,checked:r,onChange:()=>Z(t),"aria-label":`Select ${e.name||t}`})}),c(`button`,{type:`button`,className:`tcp-list-item min-w-0 flex-1 text-left ${n?`border-sky-500/40 bg-sky-950/20`:``}`,onClick:()=>E(e=>e===t?``:t),children:[c(`i`,{"data-lucide":`file-text`}),c(`div`,{className:`min-w-0 flex-1`,children:[c(`div`,{className:`flex items-center justify-between gap-2`,children:[c(`strong`,{className:`truncate`,children:e.name||t}),c(`span`,{className:`tcp-subtle text-xs`,children:i})]}),c(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs tcp-subtle`,children:[c(`span`,{className:`truncate`,children:t}),c(`span`,{children:xe(Number(e?.size||0))}),c(`span`,{children:Se(Number(e?.updatedAt||0))})]})]})]})]})},`file-${t}`)})})]})]}):c(m,{text:`This folder does not contain any files yet.`})})]})}),c(te,{fullHeight:!0,className:`overflow-hidden`,title:`Preview`,subtitle:q?q.path:K?T:`Select a file`,actions:q?c(`a`,{className:`tcp-icon-btn h-8 w-8`,href:Ue,target:`_blank`,rel:`noreferrer`,title:`Download file`,"aria-label":`Download file`,children:c(`i`,{"data-lucide":`download`})}):K?c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:`Open folder`,"aria-label":`Open folder`,onClick:()=>Y(T),children:c(`i`,{"data-lucide":`folder-open`})}):null,children:c(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-4`,children:q?c(t,{children:[c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3`,children:[c(`div`,{className:`flex items-start justify-between gap-3`,children:[c(`div`,{className:`min-w-0`,children:[c(`div`,{className:`truncate text-sm font-semibold`,children:q.name}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:q.path})]}),c(`div`,{className:`flex flex-col items-end gap-1`,children:[c(f,{tone:`info`,children:J||`file`}),c(`span`,{className:`tcp-subtle text-xs`,children:He||`application/octet-stream`})]})]}),c(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs`,children:[c(`div`,{className:`rounded-lg border border-white/10 bg-black/10 p-2`,children:[c(`div`,{className:`tcp-subtle`,children:`Size`}),c(`div`,{className:`mt-1 font-medium`,children:xe(Number(q.size||0))})]}),c(`div`,{className:`rounded-lg border border-white/10 bg-black/10 p-2`,children:[c(`div`,{className:`tcp-subtle`,children:`Updated`}),c(`div`,{className:`mt-1 font-medium`,children:Se(Number(q.updatedAt||0))})]})]})]}),J===`image`?c(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-xl border border-white/10 bg-black/20 p-3`,children:c(`img`,{src:Ue,alt:q.name,className:`max-h-full max-w-full rounded-lg object-contain`})}):J===`pdf`?c(`div`,{className:`min-h-0 flex-1 overflow-hidden rounded-xl border border-white/10 bg-black/20`,children:c(`iframe`,{title:q.name,src:Ue,className:`h-full w-full`})}):qe?c(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-xl border border-white/10 bg-black/20 p-3`,children:Je?c(`div`,{className:`tcp-subtle text-sm`,children:`Loading preview...`}):J===`markdown`?c(`div`,{className:`tcp-markdown tcp-markdown-ai`,dangerouslySetInnerHTML:{__html:re(st||` `)}}):c(`pre`,{className:`tcp-code whitespace-pre-wrap break-words`,children:st||` `})}):c(`div`,{className:`grid min-h-0 flex-1 gap-3`,children:[c(m,{title:`Preview unavailable`,text:ot===`too_large`?`This file is larger than ${xe(2*1024*1024)} for inline preview.`:ot===`unavailable`?`The preview request failed or the file is no longer available.`:`This file type is not previewed inline.`}),c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3 text-xs`,children:[c(`div`,{className:`tcp-subtle`,children:`Download URL`}),c(`a`,{className:`mt-1 block truncate text-sky-200`,href:Ue,children:Ue})]})]})]}):K?c(`div`,{className:`grid gap-3`,children:[c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3`,children:[c(`div`,{className:`flex items-start justify-between gap-3`,children:[c(`div`,{children:[c(`div`,{className:`text-sm font-semibold`,children:T||`Folder`}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:`Folder preview`})]}),c(f,{tone:`ghost`,children:`folder`})]}),c(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs`,children:[c(`div`,{className:`rounded-lg border border-white/10 bg-black/10 p-2`,children:[c(`div`,{className:`tcp-subtle`,children:`Folders`}),c(`div`,{className:`mt-1 font-medium`,children:B.length})]}),c(`div`,{className:`rounded-lg border border-white/10 bg-black/10 p-2`,children:[c(`div`,{className:`tcp-subtle`,children:`Files`}),c(`div`,{className:`mt-1 font-medium`,children:V.length})]})]})]}),c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3 text-xs`,children:[c(`div`,{className:`tcp-subtle`,children:`Folder path`}),c(`div`,{className:`mt-1 break-all`,children:T})]}),c(`button`,{type:`button`,className:`tcp-btn-primary justify-center`,onClick:rt,children:[c(`i`,{"data-lucide":`database-zap`}),`Import to Memory`]})]}):c(m,{title:`No selection`,text:`Pick a file to preview it here, or select a folder to see its details.`})})})]})}),c(`input`,{ref:le,type:`file`,className:`hidden`,multiple:!0,onChange:e=>{Ze(e.target.files),e.target.value=``}}),c(`input`,{ref:ue,type:`file`,className:`hidden`,multiple:!0,webkitdirectory:``,directory:``,onChange:e=>{Ze(e.target.files),e.target.value=``}}),c(_,{open:!!D,title:`Create folder`,message:c(`span`,{children:[`Create a new folder inside`,` `,c(`strong`,{children:D?.baseDir||(L?`Workspace`:`current path`)}),`.`]}),label:`Folder path`,value:D?.value||``,placeholder:L?`new-folder`:`knowledgebooks/new-collection`,confirmLabel:`Create folder`,confirmIcon:`folder-plus`,confirmDisabled:!String(D?.value||``).trim(),onCancel:()=>O(null),onChange:e=>O(t=>t&&{...t,value:e}),onConfirm:()=>void $e()}),c(oe,{open:!!I,title:`Delete selected files`,message:c(`span`,{children:[`This will permanently remove`,` `,c(`strong`,{children:[I?.files.length||0,` selected file(s)`]}),` from`,` `,c(`strong`,{children:at||`the current folder`}),`.`]}),confirmLabel:`Delete selected`,confirmIcon:`trash-2`,confirmTone:`danger`,widthClassName:`w-[min(42rem,96vw)]`,onCancel:()=>Ae(null),onConfirm:()=>void $(),children:I?.files.length?c(`div`,{className:`mt-3 grid gap-2 rounded-xl border border-white/10 bg-black/20 p-3 text-left text-xs`,children:[c(`div`,{className:`tcp-subtle uppercase tracking-wide`,children:`Selected files`}),c(`div`,{className:`max-h-40 overflow-auto`,children:[I.files.slice(0,12).map(e=>c(`div`,{className:`truncate py-1`,children:[c(`span`,{className:`font-medium text-slate-100`,children:e.name||e.path}),c(`span`,{className:`tcp-subtle`,children:[` · `,e.path]})]},e.path)),I.files.length>12?c(`div`,{className:`pt-1 text-slate-400`,children:[`+`,I.files.length-12,` more`]}):null]})]}):null}),c(se,{open:!!je,client:u,initialPath:je?.path||``,initialTier:dt,initialProjectId:ut,note:je?.note||``,toast:v,onCancel:()=>Me(null),onSuccess:async()=>{await y.invalidateQueries({queryKey:[`memory`]})}})]})}export{Ee as FilesPage};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{C as e,E as t,g as n,v as r}from"./fullcalendar-Bn75j0xM.js";import{n as i}from"./react-query-BIbNygEJ.js";import{i as a,n as o}from"./motion-B3ZE8SGR.js";import{h as s,i as c,n as l,t as u,u as d}from"./ui-CV-Z6sqF.js";import{a as f}from"./index-picB46b5.js";import{t as p}from"./ProviderModelSelector-B_IE0-e7.js";import{i as ee,n as m,r as te,t as ne}from"./plannerShared-1kHFyAp-.js";import{t as re}from"./ChatInterfacePanel-3nvwn0cJ.js";import{n as h,r as g,t as ie}from"./PlannerDiagnosticsPanel-VyacxaCM.js";function _({value:e,error:n=``,open:r,browseDir:i,search:o,parentDir:s,currentDir:l,directories:u,label:d=`Workspace root`,helperText:f=`Select the local workspace folder the planner should inspect.`,onOpen:p,onClose:ee,onClear:m,onSearchChange:te,onBrowseParent:ne,onBrowseDirectory:re,onSelectDirectory:h}){let g=String(o||``).trim().toLowerCase();return a(t,{children:[a(`label`,{className:`grid gap-2`,children:[a(`span`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:d}),a(`div`,{className:`grid gap-2 md:grid-cols-[auto_1fr_auto]`,children:[a(`button`,{className:`tcp-btn h-10 px-3`,type:`button`,onClick:p,children:`Browse`}),a(`input`,{className:`tcp-input text-sm ${n?`border-red-500/70 text-red-100`:``}`,value:e,readOnly:!0,placeholder:`Select a local directory with Browse`}),a(`button`,{className:`tcp-btn h-10 px-3`,type:`button`,onClick:m,disabled:!e,children:`Clear`})]}),a(`span`,{className:`text-xs ${n?`text-red-300`:`tcp-subtle`}`,children:n||f})]}),r?a(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4`,children:[a(`button`,{type:`button`,className:`tcp-confirm-backdrop`,"aria-label":`Close workspace directory dialog`,onClick:ee}),a(`div`,{className:`tcp-confirm-dialog max-w-2xl`,children:[a(`h3`,{className:`tcp-confirm-title`,children:`Select Workspace Folder`}),a(`p`,{className:`tcp-confirm-message`,children:[`Current: `,l||i||`n/a`]}),a(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:[a(`button`,{className:`tcp-btn`,type:`button`,onClick:ne,disabled:!s,children:`Up`}),a(`button`,{className:`tcp-btn-primary`,type:`button`,onClick:h,disabled:!l,children:`Select This Folder`}),a(`button`,{className:`tcp-btn`,type:`button`,onClick:ee,children:`Close`})]}),a(`div`,{className:`mb-2`,children:a(`input`,{className:`tcp-input`,placeholder:`Type to filter folders...`,value:o,onInput:e=>te(e.target.value)})}),a(`div`,{className:`max-h-[360px] overflow-auto rounded-lg border border-slate-700/60 bg-slate-900/20 p-2`,children:u.length?u.map(e=>a(`button`,{className:`tcp-list-item mb-1 w-full text-left`,type:`button`,onClick:()=>re(String(e?.path||``)),children:a(`span`,{children:String(e?.name||e?.path||``)})},String(e?.path||e?.name))):a(c,{text:g?`No folders match your search.`:`No subdirectories in this folder.`})})]})]}):null]})}var v=[{id:`automation`,label:`Workflow automation`,detail:`Package the result into a governed automation draft.`},{id:`mission`,label:`Mission execution`,detail:`Shape a mission-style plan with multi-agent handoff and runtime review.`},{id:`coding`,label:`Coder`,detail:`Turn intent into repo-aware work that can publish into coding flows.`},{id:`orchestrator`,label:`Orchestrator`,detail:`Prepare an execution-ready plan for orchestration and approvals.`}],y=[{id:`same_day`,label:`Same day`,detail:`Split work into waves that should complete in a single day.`},{id:`multi_day`,label:`Multi-day`,detail:`Break the mission into a plan that spans several days.`},{id:`weekly`,label:`Weekly recurring`,detail:`Plan recurring work that should execute on a weekly cadence.`},{id:`monthly`,label:`Monthly recurring`,detail:`Plan recurring synthesis or review across a monthly cycle.`},{id:`mixed`,label:`Mixed cadence`,detail:`Blend one-time setup work with recurring follow-on work.`}],b=[`Plan a week-long multi-agent launch workflow`,`Turn this outcome into a phased mission with approvals`,`Break this into daily work waves and recurring follow-up`];function x(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t].sort((e,t)=>e.localeCompare(t))}function S(e){return String(e||``).trim()}function ae({draft:t,onChange:n,providerOptions:i,plannerCanUseLlm:o,basePlannerLabel:s,availableMcpServers:c,workspaceRootError:u=``,workspaceBrowserOpen:d,workspaceBrowserDir:ee,workspaceBrowserSearch:te,workspaceBrowserParentDir:re,workspaceBrowserCurrentDir:h,workspaceBrowserDirectories:g,onOpenWorkspaceBrowser:ie,onCloseWorkspaceBrowser:ae,onClearWorkspaceRoot:C,onWorkspaceBrowserSearchChange:w,onWorkspaceBrowserParent:T,onWorkspaceBrowserDirectory:E,onSelectWorkspaceDirectory:oe,onReset:D,disabled:O=!1}){let[se,k]=r(!1);e(()=>{try{f()}catch{}});let ce=v.find(e=>e.id===t.targetSurface),A=y.find(e=>e.id===t.planningHorizon),le=ne(t.goal).knowledge,j=m(t.goal).rollout,ue=S(le.subject||t.goal);return a(`div`,{className:`grid gap-4 min-h-0`,children:[a(`div`,{className:`rounded-2xl border border-emerald-500/10 bg-emerald-500/5 p-3`,children:[a(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a(l,{tone:`ok`,children:`planner workbench`}),a(l,{tone:o?`ok`:`warn`,children:o?`model ready`:`model missing`}),a(`div`,{className:`flex-1`}),a(`button`,{type:`button`,className:`tcp-btn h-6 px-2 text-[10px]`,onClick:D,title:`Start a new mission and clear the current planner state`,disabled:O,children:[a(`i`,{"data-lucide":`plus`,className:`mr-1 h-3 w-3`}),`New mission`]})]}),a(`p`,{className:`tcp-subtle mt-2 text-xs`,children:`The planner turns your intent into a structured workflow. Describe the full system — connected agents, schedules, and handoffs — and the planner will decompose it.`})]}),a(`div`,{className:`rounded-2xl border border-cyan-500/10 bg-cyan-500/5 p-3`,children:[a(`div`,{className:`text-xs uppercase tracking-wide text-cyan-200/80`,children:`Knowledge defaults`}),a(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[a(l,{tone:`info`,children:`project scope`}),a(l,{tone:`info`,children:`preflight reuse`}),a(l,{tone:`info`,children:`promoted trust floor`}),ue?null:a(l,{tone:`warn`,children:`subject inferred later`})]}),ue?a(`div`,{className:`mt-3 rounded border border-white/5 bg-black/20 p-2 text-xs tcp-subtle break-words`,children:[a(`strong`,{className:`text-emerald-500/80 uppercase tracking-wide mr-1`,children:`Subject:`}),a(`span`,{className:`line-clamp-3`,children:ue})]}):null,a(`p`,{className:`tcp-subtle mt-2 text-xs`,children:`The planner will start from project-scoped promoted knowledge and reuse prior work before it recomputes. Raw working notes stay local unless they are promoted later.`})]}),a(`div`,{className:`rounded-2xl border border-amber-500/15 bg-amber-500/5 p-3`,children:[a(`div`,{className:`text-xs uppercase tracking-wide text-amber-200/80`,children:`Rollout guardrails`}),a(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[a(l,{tone:`warn`,children:`project-first pilot`}),a(l,{tone:`warn`,children:`promoted only`}),a(l,{tone:`warn`,children:`approved_default rare`})]}),a(`ul`,{className:`tcp-subtle mt-2 space-y-1 text-xs`,children:j.guardrails.map(e=>a(`li`,{children:[`• `,e]},e))})]}),a(_,{value:t.workspaceRoot,error:u,open:d,browseDir:ee,search:te,parentDir:re,currentDir:h,directories:g,helperText:`This folder is required. The planner uses it to inspect the repo and generate the plan.`,onOpen:ie,onClose:ae,onClear:C,onSearchChange:w,onBrowseParent:T,onBrowseDirectory:E,onSelectDirectory:oe}),a(`label`,{className:`grid gap-2`,children:[a(`span`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Intent`}),a(`textarea`,{className:`tcp-input min-h-32 text-sm`,value:t.goal,onInput:e=>n({...t,goal:e.target.value}),placeholder:`Describe the long-horizon outcome you want, including what success looks like.`,disabled:O}),a(`div`,{className:`flex flex-wrap gap-2`,children:b.map(e=>a(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>n({...t,goal:e}),disabled:O,children:e},e))}),a(`span`,{className:`tcp-subtle text-xs`,children:`Keep this high-level. The planner should turn the goal into structure after the first draft.`})]}),a(`div`,{className:`rounded-2xl border border-white/10 bg-black/20 p-4`,children:[a(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[a(`div`,{children:[a(`div`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Optional guidance`}),a(`div`,{className:`tcp-subtle mt-1 text-xs`,children:`Leave this collapsed if you want the planner to infer the setup from your intent.`})]}),a(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>k(e=>!e),disabled:O,children:se?`Hide guidance`:`Add guidance`})]}),a(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[a(`span`,{className:`tcp-badge-info`,children:ce?.label||`Mission execution`}),a(`span`,{className:`tcp-badge-info`,children:A?.label||`Mixed cadence`}),a(`span`,{className:`tcp-badge-info`,children:t.selectedMcpServers.length?`${t.selectedMcpServers.length} MCP source${t.selectedMcpServers.length===1?``:`s`}`:`all connected MCP sources`})]}),se?a(`div`,{className:`mt-4 grid gap-4`,children:[a(`div`,{className:`grid gap-2`,children:[a(`div`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Target surface`}),a(`select`,{className:`tcp-input text-sm`,value:t.targetSurface,onChange:e=>n({...t,targetSurface:e.target.value}),disabled:O,children:v.map(e=>a(`option`,{value:e.id,children:e.label},e.id))}),a(`div`,{className:`tcp-subtle text-xs`,children:ce?.detail})]}),a(`div`,{className:`grid gap-2`,children:[a(`div`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Planning horizon`}),a(`select`,{className:`tcp-input text-sm`,value:t.planningHorizon,onChange:e=>n({...t,planningHorizon:e.target.value}),disabled:O,children:y.map(e=>a(`option`,{value:e.id,children:e.label},e.id))}),a(`div`,{className:`tcp-subtle text-xs`,children:A?.detail})]}),a(`label`,{className:`grid gap-2`,children:[a(`span`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Outputs or constraints`}),a(`textarea`,{className:`tcp-input min-h-28 text-sm`,value:[t.outputExpectations,t.constraints].filter(Boolean).join(`
|
|
2
|
+
|
|
3
|
+
`),onInput:e=>n({...t,outputExpectations:e.target.value,constraints:``}),placeholder:`Optional: add anything the planner must produce or respect.`,disabled:O})]}),a(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3`,children:[a(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:a(`div`,{children:[a(`div`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Planner model`}),a(`div`,{className:`tcp-subtle text-xs`,children:[`Base model: `,s||`not configured`]})]})}),a(p,{providerLabel:`Planner provider`,modelLabel:`Planner model`,draft:{provider:t.plannerProvider,model:t.plannerModel},providers:i,onChange:({provider:e,model:r})=>n({...t,plannerProvider:e,plannerModel:r}),inheritLabel:`Workspace default`,disabled:O})]}),a(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3`,children:[a(`div`,{className:`mb-3`,children:[a(`div`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`MCP sources`}),a(`div`,{className:`tcp-subtle mt-1 text-xs`,children:`Optional: limit which connected systems the planner should reference.`})]}),a(`div`,{className:`flex flex-wrap gap-2`,children:c.length?c.map(e=>a(`button`,{type:`button`,className:t.selectedMcpServers.includes(e.name)?`tcp-btn-primary h-8 px-3 text-xs`:`tcp-btn h-8 px-3 text-xs`,onClick:()=>n({...t,selectedMcpServers:x(t.selectedMcpServers,e.name)}),disabled:O||!e.connected,title:e.lastError||e.transport||``,children:e.name},e.name)):a(`div`,{className:`tcp-subtle text-xs`,children:`No MCP servers are currently connected.`})})]})]}):null]})]})}function C(e){return String(e||``).trim()}function w(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function T(e){let t=w(e?.knowledge);if(Object.keys(t).length)return t;let n=w(w(w(e?.metadata).builder).knowledge);return Object.keys(n).length?n:null}function E(e,t=`n/a`){let n=Array.isArray(e)?e.map(e=>{if(e&&typeof e==`object`){let t=C(e.scope),n=C(e.namespace);if(t&&n)return`${t}:${n}`;if(t)return t}return C(e)}).filter(Boolean):[];return n.length?n.join(`, `):t}function oe({planPreview:e,brief:t,planPackage:n,planPackageBundle:r}){let i=Array.isArray(e?.steps)?e.steps:[],o=Array.isArray(n?.routine_graph)?n.routine_graph:[],s=w(r?.scope_snapshot||r?.scopeSnapshot),c=w(s.output_roots||s.outputRoots),u=i.map(T).find(Boolean)||null,f=m(t.goal).rollout;return a(d,{title:`Plan summary`,subtitle:`Review the compiler draft and bundle snapshot before handing it off downstream.`,children:e?a(`div`,{className:`grid gap-3 text-sm`,children:[a(`div`,{className:`flex flex-wrap gap-2`,children:[a(l,{tone:n?`ok`:`warn`,children:n?`plan package ready`:`plan package pending`}),a(l,{tone:r?`ok`:`warn`,children:r?`bundle ready`:`bundle pending`}),a(l,{tone:`info`,children:t.targetSurface.replace(`_`,` `)}),a(l,{tone:`info`,children:t.planningHorizon.replace(`_`,` `)})]}),a(h,{metrics:[{label:`Plan title`,value:C(e?.title)||C(e?.plan_id)||`Draft`},{label:`Plan id`,value:C(e?.plan_id||e?.planId)||`pending`},{label:`Routines`,value:o.length||`pending`},{label:`Steps`,value:i.length||`pending`}]}),a(g,{title:`Description`,children:a(`div`,{className:`text-slate-200`,children:C(e?.description)||`No description returned yet.`})}),a(g,{title:`Knowledge defaults`,description:`The compiler now carries reusable knowledge defaults alongside each step.`,children:u?a(`div`,{className:`grid gap-2 text-xs text-slate-200`,children:[a(`div`,{className:`flex flex-wrap gap-2`,children:[a(l,{tone:u.enabled===!1?`warn`:`ok`,children:u.enabled===!1?`knowledge off`:`knowledge on`}),a(l,{tone:`info`,children:[`reuse: `,C(u.reuse_mode||`preflight`)]}),a(l,{tone:`info`,children:[`trust: `,C(u.trust_floor||`promoted`)]})]}),a(`div`,{className:`tcp-subtle text-xs`,children:[`subject:`,` `,C(u.subject||e?.original_prompt||`n/a`)]}),a(`div`,{className:`tcp-subtle text-xs`,children:[`reads: `,E(u.read_spaces,`project`)]}),a(`div`,{className:`tcp-subtle text-xs`,children:[`promotes: `,E(u.promote_spaces,`project`)]})]}):a(`div`,{className:`tcp-subtle text-xs`,children:`No knowledge defaults surfaced yet; the plan compiler may not have normalized the step metadata.`})}),a(g,{title:`Rollout guardrails`,description:`Use these checks when expanding reusable knowledge across workflows.`,children:a(`div`,{className:`grid gap-2 text-xs text-slate-200`,children:[a(`div`,{className:`flex flex-wrap gap-2`,children:[a(l,{tone:`warn`,children:`project-first pilot`}),a(l,{tone:`warn`,children:`promoted only`}),a(l,{tone:`warn`,children:`approved_default rare`})]}),a(`div`,{className:`tcp-subtle`,children:f.rollout_mode===`project_first_pilot`?`Run a project-scoped pilot first, then widen only after the reuse path is stable.`:`Rollout guidance is missing or incomplete.`}),a(`ul`,{className:`space-y-1`,children:f.guardrails.map(e=>a(`li`,{children:[`• `,e]},e))})]})}),a(g,{title:`Bundle snapshot`,children:a(h,{metrics:[{label:`Bundle version`,value:C(r?.bundle_version||r?.bundleVersion)||`pending`},{label:`Snapshot plan`,value:C(s.plan_id||s.planId)||`pending`},{label:`Snapshot revision`,value:C(s.plan_revision||s.planRevision)||`pending`},{label:`Output roots`,value:a(`div`,{className:`text-xs text-slate-200`,children:[c.plan?a(`div`,{children:[`plan: `,C(c.plan)]}):null,c.history?a(`div`,{children:[`history: `,C(c.history)]}):null,c.proof?a(`div`,{children:[`proof: `,C(c.proof)]}):null,c.drafts?a(`div`,{children:[`drafts: `,C(c.drafts)]}):null,!c.plan&&!c.history&&!c.proof&&!c.drafts?a(`div`,{className:`tcp-subtle`,children:`No bundle roots available yet.`}):null]})}]})}),a(g,{title:`Step graph`,children:a(`div`,{className:`grid gap-2`,children:i.length?i.map((e,t)=>a(`div`,{className:`rounded-lg border border-white/10 bg-black/20 p-3`,children:[a(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a(l,{tone:`info`,children:[`Step `,t+1]}),a(`span`,{className:`text-sm font-medium text-slate-100`,children:C(e?.objective)||C(e?.title)||`Untitled step`})]}),a(`div`,{className:`tcp-subtle mt-2 text-xs`,children:[`role: `,C(e?.agent_role||e?.agentRole)||`n/a`]}),a(`div`,{className:`tcp-subtle mt-1 text-xs`,children:[`depends on:`,` `,Array.isArray(e?.depends_on)&&e.depends_on.length?e.depends_on.join(`, `):`none`]}),T(e)?a(`div`,{className:`mt-2 flex flex-wrap gap-2 text-[11px]`,children:[a(l,{tone:T(e)?.enabled===!1?`warn`:`ok`,children:T(e)?.enabled===!1?`knowledge off`:`knowledge on`}),a(l,{tone:`info`,children:[`reuse: `,C(T(e)?.reuse_mode||`preflight`)]}),a(l,{tone:`info`,children:[`trust: `,C(T(e)?.trust_floor||`promoted`)]}),a(`span`,{className:`tcp-subtle text-[11px]`,children:[`subject: `,C(T(e)?.subject||`inferred`)]})]}):null]},C(e?.step_id||e?.stepId||t))):a(`div`,{className:`tcp-subtle text-xs`,children:`No step graph has been returned yet.`})})})]}):a(`div`,{className:`tcp-subtle text-sm`,children:`No plan yet. Start with the intent brief and planner chat to generate a draft.`})})}function D(e){return String(e||``).trim()}function O(e){switch(e){case`same_day`:return 2;case`multi_day`:return 3;case`weekly`:return 2;case`monthly`:return 3;default:return 3}}function se(e,t,n){return t===1?`One-time delivery`:e===0?`Setup and framing`:e===t-1?n===`weekly`||n===`monthly`||n===`mixed`?`Recurring follow-up`:`Review and handoff`:`Core delivery`}function k(e,t){let n=Math.max(1,Math.min(O(t),e.length||1)),r=Math.max(1,Math.ceil((e.length||1)/n)),i=[];for(let a=0;a<n;a+=1){let o=e.slice(a*r,(a+1)*r);!o.length&&e.length||i.push({index:a,title:se(a,n,t),steps:o})}return i.length||i.push({index:0,title:se(0,1,t),steps:[]}),i}function ce({brief:e,planPreview:t}){let n=Array.isArray(t?.steps)?t.steps:[],r=k(n,e.planningHorizon),i=e.planningHorizon===`weekly`||e.planningHorizon===`monthly`||e.planningHorizon===`mixed`;return a(d,{title:`Timeline`,subtitle:`Preview the mission as time waves and milestones instead of one flattened schedule.`,children:a(`div`,{className:`grid gap-3 text-sm`,children:[a(`div`,{className:`flex flex-wrap gap-2`,children:[a(l,{tone:`info`,children:e.planningHorizon.replace(`_`,` `)}),a(l,{tone:i?`ok`:`info`,children:i?`one-time + recurring`:`one-time only`}),a(l,{tone:n.length?`ok`:`warn`,children:n.length?`${n.length} step${n.length===1?``:`s`}`:`no steps yet`})]}),a(g,{title:`Timeline model`,children:a(`div`,{className:`text-slate-200`,children:i?`This horizon is treated as a mix of one-time setup work plus recurring follow-up waves.`:`This horizon is treated as one-time work split into sequential execution waves.`})}),a(`div`,{className:`grid gap-2`,children:r.map(e=>a(g,{title:`Milestone ${e.index+1}`,description:e.title,children:[a(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a(l,{tone:e.index===r.length-1&&i?`ok`:`info`,children:e.title}),a(`span`,{className:`tcp-subtle text-xs`,children:e.steps.length?`${e.steps.length} step${e.steps.length===1?``:`s`}`:`no assigned steps`})]}),e.steps.length?a(`div`,{className:`mt-3 grid gap-2`,children:e.steps.map((t,n)=>a(`div`,{className:`rounded-lg border border-white/10 bg-black/20 p-2`,children:[a(`div`,{className:`text-sm font-medium text-slate-100`,children:D(t?.objective)||D(t?.title)||`Untitled step`}),a(`div`,{className:`tcp-subtle mt-1 text-xs`,children:[`role: `,D(t?.agent_role||t?.agentRole)||`n/a`]})]},D(t?.step_id||t?.stepId||`${e.index}-${n}`)))}):null]},`${e.index}-${e.title}`))})]})})}function A(e){return String(e||``).trim()}function le({validationReport:e}){let t=Array.isArray(e?.issues)?e.issues:[],n=t.filter(e=>e?.blocking),r=t.filter(e=>!e?.blocking);return a(d,{title:`Validation`,subtitle:`Compiler checks that gate preview, apply, and activation.`,children:a(`div`,{className:`grid gap-3 text-sm`,children:[a(`div`,{className:`flex flex-wrap gap-2`,children:[a(l,{tone:e?`ok`:`warn`,children:e?`report ready`:`report pending`}),a(l,{tone:Number(e?.ready_for_apply||e?.readyForApply)?`ok`:`warn`,children:Number(e?.ready_for_apply||e?.readyForApply)?`ready for apply`:`apply blocked`}),a(l,{tone:Number(e?.ready_for_activation||e?.readyForActivation)?`ok`:`warn`,children:Number(e?.ready_for_activation||e?.readyForActivation)?`ready for activation`:`activation blocked`})]}),a(h,{metrics:[{label:`Blockers`,value:Number(n.length||e?.blocker_count||0)},{label:`Warnings`,value:Number(r.length||e?.warning_count||0)}]}),t.length?a(`div`,{className:`grid gap-2`,children:t.slice(0,4).map((e,t)=>a(`div`,{className:`rounded-lg border border-white/10 bg-black/20 p-3`,children:[a(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a(l,{tone:e?.blocking?`err`:`warn`,children:e?.blocking?`blocking`:`warning`}),a(`span`,{className:`text-sm font-medium text-slate-100`,children:A(e?.code)||`validation issue`})]}),a(`div`,{className:`tcp-subtle mt-2 text-xs`,children:A(e?.path)||`unknown path`}),a(`div`,{className:`mt-1 text-slate-200`,children:A(e?.message)})]},`${A(e?.code)}-${t}`))}):a(`div`,{className:`tcp-subtle text-xs`,children:e?`No validation issues were reported for the current draft.`:`Validation results will appear after the planner generates a draft.`}),e?.validation_state?a(g,{title:`Validation state`,children:a(`div`,{className:`text-slate-100`,children:A(e.validation_state.state||e.validationState?.state)||`pending`})}):null]})})}function j(e){return String(e||``).trim()}function ue({overlapAnalysis:e}){let t=j(e?.matched_plan_id||e?.matchedPlanId),n=j(e?.matched_plan_revision||e?.matchedPlanRevision),r=j(e?.decision||``).replace(/_/g,` `),i=j(e?.match_layer||e?.matchLayer).replace(/_/g,` `),o=e?.similarity_score??e?.similarityScore,s=!!(e?.requires_user_confirmation||e?.requiresUserConfirmation);return a(d,{title:`Overlap`,subtitle:`Match the current draft against prior plans and decide how it should evolve.`,children:a(`div`,{className:`grid gap-3 text-sm`,children:[a(`div`,{className:`flex flex-wrap gap-2`,children:[a(l,{tone:t?`ok`:`warn`,children:t?`prior match found`:`no prior match`}),r?a(l,{tone:`info`,children:r}):null,i?a(l,{tone:`info`,children:i}):null,a(l,{tone:s?`warn`:`ok`,children:s?`confirmation needed`:`no confirmation needed`})]}),a(h,{metrics:[{label:`Matched plan`,value:t||`none`},{label:`Matched revision`,value:n||`none`},{label:`Similarity`,value:typeof o==`number`?o.toFixed(2):`n/a`},{label:`Reason`,value:j(e?.reason)||`No overlap reason provided.`}]})]})})}function M(e){return String(e||``).trim()}function N(e){return Array.isArray(e)?e:[]}function de({planPackageReplay:e}){let t=!!e?.compatible,n=N(e?.issues),r=N(e?.diff_summary||e?.diffSummary),i=!!e?.scope_metadata_preserved,o=!!e?.handoff_rules_preserved,s=!!e?.credential_isolation_preserved;return a(d,{title:`Replay`,subtitle:`Compare the current draft against the baseline revision and review what changed.`,children:a(`div`,{className:`grid gap-3 text-sm`,children:[a(`div`,{className:`flex flex-wrap gap-2`,children:[a(l,{tone:e&&t?`ok`:`warn`,children:e?t?`replay compatible`:`replay drift`:`replay pending`}),a(l,{tone:i?`ok`:`warn`,children:i?`scope preserved`:`scope changed`}),a(l,{tone:o?`ok`:`warn`,children:o?`handoff preserved`:`handoff changed`}),a(l,{tone:s?`ok`:`warn`,children:s?`credentials preserved`:`credentials changed`})]}),a(h,{metrics:[{label:`Previous plan`,value:M(e?.previous_plan_id)||`baseline`,detail:M(e?.previous_plan_revision)?`revision ${M(e?.previous_plan_revision)}`:`revision 1`},{label:`Current plan`,value:M(e?.next_plan_id)||`current draft`,detail:M(e?.next_plan_revision)?`revision ${M(e?.next_plan_revision)}`:`latest revision`},{label:`Issues`,value:n.length||0},{label:`Diffs`,value:r.length||0}]}),r.length?a(g,{title:`Replay deltas`,children:a(`div`,{className:`grid gap-2`,children:r.slice(0,6).map((e,t)=>a(`div`,{className:`rounded-lg border border-white/10 bg-black/20 p-3`,children:[a(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a(l,{tone:e?.preserved?`ok`:`warn`,children:e?.preserved?`preserved`:`changed`}),a(`span`,{className:`text-sm font-medium text-slate-100`,children:M(e?.path)||`unknown path`})]}),e?.previous_value===void 0?null:a(`div`,{className:`mt-2 text-xs text-slate-400`,children:[`previous: `,JSON.stringify(e.previous_value)]}),e?.next_value===void 0?null:a(`div`,{className:`mt-1 text-xs text-slate-300`,children:[`next: `,JSON.stringify(e.next_value)]})]},`${M(e?.path)}-${t}`))})}):null,n.length?a(g,{title:`Replay issues`,children:a(`div`,{className:`grid gap-2`,children:n.slice(0,6).map((e,t)=>a(`div`,{className:`rounded-lg border border-white/10 bg-black/20 p-3`,children:[a(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a(l,{tone:e?.blocking?`err`:`warn`,children:e?.blocking?`blocking`:`warning`}),a(`span`,{className:`text-sm font-medium text-slate-100`,children:M(e?.code)||`replay issue`})]}),a(`div`,{className:`tcp-subtle mt-2 text-xs`,children:M(e?.path)||`unknown path`}),a(`div`,{className:`mt-1 text-slate-200`,children:M(e?.message)})]},`${M(e?.code)}-${t}`))})}):a(`div`,{className:`tcp-subtle text-xs`,children:e?`No replay issues were reported for the current draft.`:`Replay results will appear after the planner generates or revises a draft.`})]})})}var P=`tandem.automations.plannerSeed`,F=`tandem.intent-planner.codingTaskHandoff.v1`;function I(e){return String(e||``).trim()}function L({brief:e,planPreview:t,planPackageBundle:n,planPackage:r,validationReport:i,overlapAnalysis:a,teachingLibrary:o}){return{goal:I(e.goal||t?.description||t?.title),workspaceRoot:I(e.workspaceRoot),notes:[`Target surface: ${e.targetSurface.replace(`_`,` `)}`,`Planning horizon: ${e.planningHorizon.replace(`_`,` `)}`,e.outputExpectations?`Expected outputs: ${I(e.outputExpectations)}`:``,e.constraints?`Constraints: ${I(e.constraints)}`:``].filter(Boolean).join(`
|
|
4
|
+
`),plannerProvider:I(e.plannerProvider),plannerModel:I(e.plannerModel),plan:r||t||null,conversation:null,changeSummary:[],plannerError:``,plannerDiagnostics:{validation_report:i||null,overlap_analysis:a||null,teaching_library:o||null,handoff_source:`intent_planner_page`},publishedAtMs:null,publishedTasks:[],planPackageBundle:n||null}}function fe({brief:e,planPreview:t,planPackage:i,planPackageBundle:o,validationReport:s,overlapAnalysis:c,teachingLibrary:u,navigate:f,toast:p}){let[ee,m]=r(``),te=!!o,ne=!!t||!!i,re=n(()=>L({brief:e,planPreview:t,planPackageBundle:o,planPackage:i,validationReport:s,overlapAnalysis:c,teachingLibrary:u}),[e,c,i,o,t,u,s]),h=()=>{let n=I(e.goal||t?.description||t?.title);if(!n){p(`warn`,`Add an intent first so we have something to hand off.`);return}try{sessionStorage.setItem(P,JSON.stringify({prompt:n,plan_source:`intent_planner_page`})),f(`automations`)}catch{p(`err`,`Unable to seed the automation draft handoff.`)}},g=()=>{if(!ne){p(`warn`,`Generate a plan before publishing a coding task bundle.`);return}try{sessionStorage.setItem(F,JSON.stringify(re)),f(`coding`)}catch{p(`err`,`Unable to seed the coding handoff.`)}},ie=async()=>{if(!te){p(`warn`,`Generate a bundle before exporting it.`);return}try{let e=JSON.stringify(o,null,2);typeof navigator<`u`&&navigator.clipboard?.writeText?(await navigator.clipboard.writeText(e),m(`Bundle copied to clipboard.`),p(`ok`,`Plan bundle copied to clipboard.`)):(m(`Clipboard unavailable.`),p(`warn`,`Clipboard unavailable in this environment.`))}catch{m(`Copy failed.`),p(`err`,`Unable to copy the plan bundle.`)}};return a(d,{title:`Handoff`,subtitle:`Send the plan downstream without rebuilding it in another page.`,children:a(`div`,{className:`grid gap-3 text-sm`,children:[a(`div`,{className:`flex flex-wrap gap-2`,children:[a(l,{tone:ne?`ok`:`warn`,children:ne?`handoff ready`:`handoff pending`}),a(l,{tone:te?`ok`:`warn`,children:te?`bundle ready`:`bundle pending`}),a(l,{tone:`info`,children:e.targetSurface.replace(`_`,` `)})]}),a(`div`,{className:`flex flex-wrap gap-2`,children:[a(`button`,{type:`button`,className:`tcp-btn`,onClick:h,children:[a(`i`,{"data-lucide":`bot`,className:`mr-1 h-3 w-3`}),`Create automation draft`]}),a(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>f(`studio`),children:[a(`i`,{"data-lucide":`network`,className:`mr-1 h-3 w-3`}),`Open in mission builder`]}),a(`button`,{type:`button`,className:`tcp-btn`,onClick:g,children:[a(`i`,{"data-lucide":`code`,className:`mr-1 h-3 w-3`}),`Publish Coder task bundle`]}),a(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>f(`orchestrator`),children:[a(`i`,{"data-lucide":`sparkles`,className:`mr-1 h-3 w-3`}),`Open task board`]}),a(`button`,{type:`button`,className:`tcp-btn-primary`,onClick:()=>void ie(),children:[a(`i`,{"data-lucide":`download`,className:`mr-1 h-3 w-3`}),`Export plan bundle`]})]}),ee?a(`div`,{className:`tcp-subtle text-xs`,children:ee}):null]})})}function R(e){return String(e||``).trim()}function z(e){return e?`ok`:`warn`}function pe({brief:e,planPreview:t,validationReport:n,overlapAnalysis:r}){let i=Array.isArray(t?.steps)?t.steps:[],o=!!R(e.goal),s=i.length>0,c=!!(r?.matched_plan_id||r?.matchedPlanId||r);return a(d,{title:`Plan formation`,subtitle:`See the compiler move from intent to decomposition, checks, and review-ready structure.`,children:a(`div`,{className:`grid gap-3 text-sm`,children:[a(`div`,{className:`flex flex-wrap gap-2`,children:[{id:`intent-parsed`,label:`intent parsed`,active:o},{id:`decomposition`,label:`decomposition formed`,active:s},{id:`overlap`,label:`overlap checked`,active:c},{id:`validation`,label:`validation complete`,active:!!n}].map(e=>a(l,{tone:z(e.active),children:e.label},e.id))}),a(g,{title:`Formation summary`,children:a(`div`,{className:`text-slate-200`,children:s?`The current draft has ${i.length} planned step${i.length===1?``:`s`} and is ready for downstream review.`:`The planner has not yet produced a step decomposition for this intent.`})}),a(`div`,{className:`grid gap-2`,children:i.slice(0,4).map((e,t)=>{let n=R(e?.step_id||e?.stepId||`step-${t+1}`),r=R(e?.objective||e?.title||`Untitled step`),o=R(e?.agent_role||e?.agentRole||`n/a`);return a(g,{title:`Node ${t+1}`,children:[a(`div`,{className:`flex flex-wrap items-center gap-2`,children:a(`span`,{className:`text-slate-100`,children:r})}),a(`div`,{className:`tcp-subtle mt-1 text-xs`,children:[`agent: `,o]}),t<Math.min(i.length,4)-1?a(`div`,{className:`mt-3 flex items-center gap-2 text-xs text-slate-500`,children:[a(`span`,{className:`h-px flex-1 bg-white/10`}),a(`span`,{children:`→`}),a(`span`,{className:`h-px flex-1 bg-white/10`})]}):null]},n)})})]})})}function me(){return a(`div`,{className:`relative flex aspect-square w-full items-center justify-center overflow-hidden rounded-none border border-white/5 bg-black/40`,children:[a(`div`,{className:`absolute inset-0 opacity-20`,children:[a(`div`,{className:`tcp-shell-glow tcp-shell-glow-a opacity-50`}),a(`div`,{className:`tcp-shell-glow tcp-shell-glow-b opacity-30`})]}),a(`div`,{className:`relative z-10 grid w-full gap-5 px-6 py-6`,children:[a(s,{className:`mx-auto aspect-square w-full max-w-[17rem]`,mode:`panel`}),a(`div`,{className:`grid gap-2`,children:[`Mapping objective into shared workflow lanes`,`Scoring schedule and workspace constraints`,`Composing a mission draft with recovery steps`].map((e,t)=>a(`div`,{className:`grid gap-1 border border-white/5 bg-black/35 px-3 py-2`,children:[a(`div`,{className:`flex items-center justify-between gap-3`,children:[a(`span`,{className:`text-[11px] font-medium uppercase tracking-[0.22em] text-slate-300`,children:e}),a(`span`,{className:`text-[10px] uppercase tracking-[0.22em] text-amber-200/75`,children:`Live`})]}),a(o.div,{className:`h-1.5 origin-left bg-[linear-gradient(90deg,rgba(245,158,11,0.18),rgba(255,233,171,0.94),rgba(245,158,11,0.18))]`,animate:{scaleX:[.22,.94,.38]},transition:{duration:1.8,ease:`easeInOut`,repeat:1/0,delay:t*.22}})]},e))})]}),a(`div`,{className:`absolute inset-x-0 bottom-6 text-center`,children:a(`div`,{className:`inline-flex items-center gap-2 rounded-none border border-primary/20 bg-black/60 px-4 py-2 backdrop-blur-md`,children:[a(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-primary`}),a(`span`,{className:`font-display text-xs font-semibold uppercase tracking-widest text-primary`,children:`Synthesizing Plan Flow`})]})})]})}var he=`tcp.intent-planner.v1`,B=`tcp.intent-planner.saved.v1`,V=`tcp.intent-planner.history.v1`;function H(e){return String(e||``).trim()}function ge(e){return`${he}:${H(e)||`default`}`}function _e(e){return`${B}:${H(e)||`default`}`}function ve(e){return`${V}:${H(e)||`default`}`}function ye(e){if(typeof localStorage>`u`)return null;try{let t=localStorage.getItem(e);if(!t)return null;let n=JSON.parse(t);return!n||typeof n!=`object`?null:n}catch{return null}}function be(e,t){if(typeof localStorage>`u`)return null;let n=Date.now();try{return localStorage.setItem(e,JSON.stringify({...t,updatedAtMs:n})),n}catch{return null}}function xe(e,t){let n=t.validationReport||{},r=t.overlapAnalysis||{},i=Array.isArray(t.planningConversation?.messages)?t.planningConversation.messages:Array.isArray(t.conversation?.messages)?t.conversation.messages:[];return{storageKey:e,name:H(t.name||t.title||t.brief?.goal||t.goal)||`Untitled planner draft`,updatedAtMs:Number(t.updatedAtMs||0)||0,planId:H(t.planPackage?.plan_id||t.planPreview?.plan_id||t.plan?.plan_id),planRevision:H(t.planPackage?.plan_revision||t.planPackageBundle?.scope_snapshot?.plan_revision||t.planPackageBundle?.scopeSnapshot?.planRevision),briefGoal:H(t.brief?.goal||t.goal),targetSurface:H(t.brief?.targetSurface||t.targetSurface),planningHorizon:H(t.brief?.planningHorizon||t.planningHorizon),messageCount:i.length,blockerCount:Number(n.blocker_count||n.blockerCount||0)||0,warningCount:Number(n.warning_count||n.warningCount||0)||0,hasOverlapMatch:!!H(r.matched_plan_id||r.matchedPlanId||r.match_layer)}}function U(e){return H(e).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,48)}function Se(e,t,n){if(typeof localStorage>`u`)return null;let r=Date.now(),i=`${e}:${U(t)||`draft`}:${r}`;try{return localStorage.setItem(i,JSON.stringify({...n,name:H(t)||`Untitled planner draft`,updatedAtMs:r})),{storageKey:i,updatedAtMs:r}}catch{return null}}function Ce(e){if(typeof localStorage>`u`)return[];let t=[];try{for(let n=0;n<localStorage.length;n+=1){let r=localStorage.key(n);if(!r||!r.startsWith(`${e}:`))continue;let i=localStorage.getItem(r);if(!i)continue;let a=JSON.parse(i);!a||typeof a!=`object`||t.push(xe(r,a))}}catch{return[]}return t.sort((e,t)=>t.updatedAtMs-e.updatedAtMs)}function we(e){Ae(e)}function Te(e){return JSON.stringify({goal:H(e.brief?.goal||e.goal),planId:H(e.planPreview?.plan_id||e.plan?.plan_id),planRevision:H(e.planPackage?.plan_revision||e.planPackageBundle?.scope_snapshot?.plan_revision),changeSummary:Array.isArray(e.planningChangeSummary)?e.planningChangeSummary:Array.isArray(e.changeSummary)?e.changeSummary:[],conversationLength:Array.isArray(e.planningConversation?.messages)?e.planningConversation.messages.length:Array.isArray(e.conversation?.messages)?e.conversation.messages.length:0,plannerError:H(e.plannerError)})}function Ee(e,t,n=24){if(typeof localStorage>`u`)return null;let r=Date.now(),i={...t,entryId:`${r}`,updatedAtMs:r,fingerprint:Te(t)};try{let t=ye(e)||[],r=Array.isArray(t)?t[0]:null;if(r?.fingerprint&&r.fingerprint===i.fingerprint)return r.entryId||null;let a=[i,...Array.isArray(t)?t:[]].slice(0,n);return localStorage.setItem(e,JSON.stringify(a)),i.entryId}catch{return null}}function De(e){let t=ye(e);return Array.isArray(t)?t.filter(e=>e&&typeof e==`object`).map(t=>({entryId:H(t.entryId)||`${Number(t.updatedAtMs||0)||0}`,...xe(e,t)})).sort((e,t)=>t.updatedAtMs-e.updatedAtMs):[]}function Oe(e,t){let n=ye(e);if(!Array.isArray(n))return null;let r=n.find(e=>H(e?.entryId)===H(t));return r&&typeof r==`object`?r:null}function ke(e,t){if(!(typeof localStorage>`u`))try{let n=ye(e);if(!Array.isArray(n))return;let r=n.filter(e=>H(e?.entryId)!==H(t));localStorage.setItem(e,JSON.stringify(r))}catch{}}function Ae(e){if(!(typeof localStorage>`u`))try{localStorage.removeItem(e)}catch{}}function je(e){return String(e||``).trim()}function Me(e){if(!e)return`unknown`;let t=Date.now()-e,n=Math.max(1,Math.round(t/6e4));if(n<60)return`${n}m ago`;let r=Math.round(n/60);return r<24?`${r}h ago`:`${Math.round(r/24)}d ago`}function Ne({storagePrefix:t,historyKey:i,draftName:o,onDraftNameChange:s,onSaveCurrentDraft:c,onOpenDraft:u,onDeleteDraft:p,onOpenHistory:ee,onDeleteHistory:m}){let[te,ne]=r(``),[re,ie]=r(!1),[_,v]=r(null);e(()=>{try{f()}catch{}});let y=Ce(t),b=De(i),x=je(te).toLowerCase(),S=n(()=>x?y.filter(e=>[e.name,e.planId,e.planRevision,e.briefGoal,e.targetSurface,e.planningHorizon].join(` `).toLowerCase().includes(x)):y,[y,x]),ae=n(()=>x?b.filter(e=>[e.name,e.planId,e.planRevision,e.briefGoal,e.targetSurface,e.planningHorizon].join(` `).toLowerCase().includes(x)):b,[b,x]);return a(d,{title:`Saved intents`,subtitle:`Open, inspect, and reopen saved planning work from local storage.`,children:a(`div`,{className:`grid gap-3 text-sm`,children:[a(`div`,{className:`flex flex-wrap gap-2`,children:[a(l,{tone:y.length?`ok`:`warn`,children:y.length?`${y.length} saved draft${y.length===1?``:`s`}`:`no saved drafts`}),a(l,{tone:b.length?`info`:`warn`,children:b.length?`${b.length} autosave snapshots`:`no autosave snapshots`})]}),a(`input`,{className:`tcp-input`,value:te,onChange:e=>ne(e.target.value),placeholder:`Filter saved drafts and autosaves`}),a(g,{title:`Save current draft`,children:a(`div`,{className:`grid gap-2`,children:[a(`input`,{className:`tcp-input`,value:o,onChange:e=>s(e.target.value),placeholder:`Name this intent`}),a(`button`,{type:`button`,className:`tcp-btn-primary`,onClick:c,children:`Save named intent`})]})}),S.length?a(`div`,{className:`grid gap-2`,children:S.slice(0,8).map(e=>a(g,{title:e.name,children:[a(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:[a(l,{tone:`ok`,children:e.targetSurface||`planner`}),a(l,{tone:`info`,children:e.planningHorizon||`unspecified horizon`}),a(l,{tone:e.hasOverlapMatch?`warn`:`ok`,children:e.hasOverlapMatch?`overlap match`:`no overlap`})]}),a(h,{metrics:[{label:`Updated`,value:e.updatedAtMs?new Date(e.updatedAtMs).toLocaleString():`unknown`,detail:Me(e.updatedAtMs)},{label:`Plan`,value:e.planId||`pending`},{label:`Revision`,value:e.planRevision||`pending`},{label:`Brief`,value:a(`span`,{className:`block text-xs line-clamp-3`,title:e.briefGoal||`no saved goal`,children:e.briefGoal||`no saved goal`})},{label:`Conversation`,value:`${e.messageCount} turn${e.messageCount===1?``:`s`}`},{label:`Validation`,value:`${e.blockerCount} blocker${e.blockerCount===1?``:`s`}`,detail:`${e.warningCount} warning${e.warningCount===1?``:`s`}`}],columns:`grid-cols-1 sm:grid-cols-2`}),a(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[a(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>u(e.storageKey),children:[a(`i`,{"data-lucide":`folder-open`,className:`mr-1 h-3 w-3`}),`Reopen draft`]}),_===e.storageKey?a(`div`,{className:`flex items-center gap-2 rounded border border-red-500/20 bg-red-500/10 px-2 py-1`,children:[a(`span`,{className:`text-xs text-red-400`,children:`Confirm delete?`}),a(`button`,{type:`button`,className:`tcp-btn bg-red-500/20 text-red-300 border-red-500/50 hover:bg-red-500/30`,onClick:()=>{p(e.storageKey),v(null)},children:[a(`i`,{"data-lucide":`trash-2`,className:`mr-1 h-3 w-3`}),`Confirm`]}),a(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>v(null),children:`Cancel`})]}):a(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>v(e.storageKey),children:[a(`i`,{"data-lucide":`trash-2`,className:`mr-1 h-3 w-3`}),`Delete`]})]})]},e.storageKey))}):a(`div`,{className:`tcp-subtle text-xs`,children:`Save a planner draft and it will appear here for quick reopening.`}),a(g,{title:`Recent autosaves`,children:re?ae.length?a(`div`,{className:`grid gap-2`,children:ae.slice(0,8).map(e=>a(`div`,{className:`rounded-lg border border-white/10 bg-black/20 p-3`,children:[a(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:[a(l,{tone:`info`,children:e.targetSurface||`planner`}),a(l,{tone:`info`,children:e.planningHorizon||`unspecified horizon`}),a(l,{tone:e.hasOverlapMatch?`warn`:`ok`,children:e.hasOverlapMatch?`overlap match`:`no overlap`})]}),a(h,{metrics:[{label:`Updated`,value:e.updatedAtMs?new Date(e.updatedAtMs).toLocaleString():`unknown`,detail:Me(e.updatedAtMs)},{label:`Plan`,value:e.planId||`pending`},{label:`Revision`,value:e.planRevision||`pending`},{label:`Brief`,value:a(`span`,{className:`block text-xs line-clamp-3`,title:e.briefGoal||`no saved goal`,children:e.briefGoal||`no saved goal`})},{label:`Conversation`,value:`${e.messageCount} turn${e.messageCount===1?``:`s`}`},{label:`Validation`,value:`${e.blockerCount} blocker${e.blockerCount===1?``:`s`}`,detail:`${e.warningCount} warning${e.warningCount===1?``:`s`}`}],columns:`grid-cols-1 sm:grid-cols-2`}),a(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[a(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>ee(e.entryId),children:[a(`i`,{"data-lucide":`folder-open`,className:`mr-1 h-3 w-3`}),`Reopen autosave`]}),_===e.entryId?a(`div`,{className:`flex items-center gap-2 rounded border border-red-500/20 bg-red-500/10 px-2 py-1`,children:[a(`span`,{className:`text-xs text-red-400`,children:`Confirm delete?`}),a(`button`,{type:`button`,className:`tcp-btn bg-red-500/20 text-red-300 border-red-500/50 hover:bg-red-500/30`,onClick:()=>{m(e.entryId),v(null)},children:[a(`i`,{"data-lucide":`trash-2`,className:`mr-1 h-3 w-3`}),`Confirm`]}),a(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>v(null),children:`Cancel`})]}):a(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>v(e.entryId),children:[a(`i`,{"data-lucide":`trash-2`,className:`mr-1 h-3 w-3`}),`Delete`]})]})]},e.entryId))}):a(`div`,{className:`tcp-subtle text-xs`,children:x?`No autosaves match the current filter.`:`Recent autosaved planner states will appear here as the plan evolves.`}):a(`button`,{type:`button`,className:`tcp-btn w-full justify-start text-xs`,onClick:()=>ie(!0),children:[a(`i`,{"data-lucide":`chevron-down`,className:`mr-1 h-3 w-3`}),`Show `,b.length,` autosaved snapshots`]})})]})})}var W={goal:``,workspaceRoot:``,targetSurface:`mission`,planningHorizon:`mixed`,outputExpectations:``,constraints:``,plannerProvider:``,plannerModel:``,selectedMcpServers:[]};function G(e){return String(e||``).trim()}function Pe(e){let t=Array.isArray(e)?e.map(e=>G(e)).filter(Boolean):[];return t.length?t.join(`, `):`—`}function Fe(e){let t=G(e?.source_platform),n=G(e?.created_by_agent||e?.requesting_actor);return t===`control_panel`&&(!n||n===`human`)?`human`:n||`—`}function Ie(e){let t=e?.preview_payload?.plan||{},n=G(t?.title||t?.original_prompt),r=Array.isArray(t?.steps)?t.steps.length:0,i=G(t?.schedule?.cron_expression||t?.schedule?.type||t?.schedule?.label),a=[n||`Workflow preview`];return r&&a.push(`${r} step${r===1?``:`s`}`),i&&a.push(i),a.join(` • `)}function Le(e){return(Array.isArray(e)?e:Array.isArray(e?.servers)?e.servers:e&&typeof e==`object`?Object.entries(e).map(([e,t])=>({name:e,...t})):[]).map(e=>({name:String(e?.name||``).trim(),connected:!!e?.connected,enabled:e?.enabled!==!1,transport:String(e?.transport||``).trim(),lastError:String(e?.last_error||e?.lastError||``).trim()})).filter(e=>e.name)}function Re(e){let t=G(e);return t?t.startsWith(`/`)?``:`Workspace root must be an absolute path.`:`Workspace root is required.`}function ze(e){switch(e){case`same_day`:return`same-day split work`;case`multi_day`:return`multi-day plan`;case`weekly`:return`weekly recurring work`;case`monthly`:return`monthly recurring work`;default:return`mixed one-time and recurring work`}}function Be(e){switch(e){case`automation`:return`workflow automation`;case`mission`:return`mission execution`;case`coding`:return`coding workflow`;default:return`orchestrator handoff`}}function Ve(e){return[G(e.goal),`Planning horizon: ${ze(e.planningHorizon)}.`,`Target surface: ${Be(e.targetSurface)}.`,G(e.workspaceRoot)?`Workspace root: ${G(e.workspaceRoot)}`:``,G(e.outputExpectations)?`Expected outputs:\n${G(e.outputExpectations)}`:``,G(e.constraints)?`Constraints:\n${G(e.constraints)}`:``,`Default knowledge behavior: project-scoped preflight reuse with promoted trust floor.`,`Use clarifying questions instead of guessing when important details are missing.`,`Prefer multi-agent decomposition, milestones, and timeline-aware work waves when appropriate.`,`Return a workflow plan that can later be handed off to Automations, Coder, or Orchestrator.`].filter(Boolean).join(`
|
|
5
|
+
`)}var He=`tandem.workflow.importHandoff.v1`,K=`tandem.workflow.plannerSeed`;function Ue(){try{let e=localStorage.getItem(He);if(!e)return null;let t=JSON.parse(e);return!t||typeof t!=`object`?null:t}catch{return null}}function We(){try{let e=sessionStorage.getItem(K);if(!e)return null;let t=JSON.parse(e);return!t||typeof t!=`object`?null:t}catch{return null}}function Ge(){try{let e=window.location.hash||``,t=e.includes(`?`)?e.slice(e.indexOf(`?`)+1):``,n=new URLSearchParams(t);return String(n.get(`session_id`)||``).trim()||``}catch{return``}}function Ke({api:o,client:s,toast:c,providerStatus:p,identity:h,navigate:g}){let[_,v]=r(W),[y,b]=r(``),[x,S]=r(`idle`),[C,w]=r(null),[T,E]=r(null),[D,O]=r([]),[se,k]=r(``),[A,j]=r(null),[M,N]=r({status:`none`}),[P,F]=r(null),[I,L]=r(null),[R,z]=r(null),[he,B]=r(null),[V,H]=r(null),[xe,U]=r(null),[Ce,Te]=r(``),[De,je]=r(!1),[Me,ze]=r(null),[Be,K]=r(!1),[Ke,qe]=r(``),[q,Je]=r(null),[J,Ye]=r(null),[Xe,Ze]=r(!1),[Qe,$e]=r(``),[et,tt]=r(``),nt=n(()=>Ge(),[]),rt=n(()=>ge(h.botName),[h.botName]),it=n(()=>_e(h.botName),[h.botName]),at=n(()=>ve(h.botName),[h.botName]),ot=i({queryKey:[`intent-planner`,`providers`,`catalog`],queryFn:()=>s.providers.catalog().catch(()=>({all:[]})),refetchInterval:3e4}),st=i({queryKey:[`intent-planner`,`providers`,`config`],queryFn:()=>s.providers.config().catch(()=>({})),refetchInterval:3e4}),ct=i({queryKey:[`intent-planner`,`mcp-servers`],queryFn:()=>s.mcp.list().catch(()=>({})),refetchInterval:1e4}),lt=i({queryKey:[`global`,`health`],queryFn:()=>s.health().catch(()=>({})),refetchInterval:3e4}),ut=i({queryKey:[`intent-planner`,`workspace-browser`,Qe],enabled:Xe&&!!Qe,queryFn:()=>o(`/api/orchestrator/workspaces/list?dir=${encodeURIComponent(Qe)}`,{method:`GET`}).catch(()=>({}))}),Y=G(J?.session_id||q?.session_id||nt),dt=i({queryKey:[`intent-planner`,`workflow-handoff`,Y],enabled:!!Y,queryFn:()=>s.workflowPlannerSessions.get(Y).catch(()=>({session:null}))}),ft=n(()=>te({providerCatalog:ot.data,providerConfig:st.data,defaultProvider:p.defaultProvider,defaultModel:p.defaultModel}),[p.defaultModel,p.defaultProvider,ot.data,st.data]),pt=n(()=>Le(ct.data),[ct.data]),mt=n(()=>pt.filter(e=>e.connected).map(e=>e.name),[pt]),ht=!!(G(_.plannerProvider)&&G(_.plannerModel)||G(p.defaultProvider)&&G(p.defaultModel)),gt=n(()=>ee(T),[T]),_t=x===`generating`||x===`revising`,X=!!G(C?.plan_id||C?.planId),vt=!!(X||I||P||V||he||D.length),yt=x===`generating`?`Drafting plan`:x===`revising`?`Revising plan`:x===`clarifying`?`Waiting for clarification`:``,bt=x===`clarifying`?`Reply to the planner's question so it can continue shaping the mission.`:`The planner is composing a governed workflow plan from your intent.`,xt=Array.isArray(ut.data?.directories)?ut.data.directories:[],Z=dt.data?.session||null,St=G(Z?.source_kind||q?.source_kind||``),Q=Z?.draft?.review||null,$=Z?.planning||null,Ct=(Q?.preview_payload||null)?.plan||null,wt=G(Ct?.original_prompt||Z?.goal||G(J?.prompt||``)||Z?.title||`—`),Tt=G($?.draft_id||$?.linked_draft_plan_id||Z?.current_plan_id||Ct?.plan_id||`—`),Et=Q?`review ready`:`draft in progress`,Dt=G(Q?.validation_state||$?.validation_state||`incomplete`),Ot=G(Q?.approval_status||$?.approval_status||`not_required`),kt=G(J?.prompt||``),At=String(ut.data?.parent||``).trim(),jt=String(ut.data?.dir||Qe||``).trim(),Mt=n(()=>{let e=String(et||``).trim().toLowerCase();return e?xt.filter(t=>String(t?.name||t?.path||``).trim().toLowerCase().includes(e)):xt},[et,xt]),Nt=Re(_.workspaceRoot);e(()=>{let e=String(lt.data?.workspaceRoot||lt.data?.workspace_root||``).trim();e&&v(t=>G(t.workspaceRoot)?t:{...t,workspaceRoot:e})},[lt.data]),e(()=>{Je(Ue()),Ye(We())},[]),e(()=>{if(!Y||!Z||Z.session_id!==Y||Ke===Z.session_id)return;let e=Z.draft?.current_plan||Z.draft?.initial_plan;if(!e)return;v({...W,goal:G(Z.goal||Z.title||e.original_prompt||e.title),workspaceRoot:G(Z.workspace_root||e.workspace_root),targetSurface:W.targetSurface,planningHorizon:W.planningHorizon,outputExpectations:G(e.description),constraints:``,plannerProvider:G(Z.planner_provider),plannerModel:G(Z.planner_model),selectedMcpServers:Array.isArray(e.allowed_mcp_servers)?e.allowed_mcp_servers.map(e=>G(e)).filter(Boolean):[]}),b(G(Z.goal||Z.title||e.normalized_prompt||e.original_prompt)),w(e),E(Z.draft?.conversation||null),O([]),k(``),j(Z.import_scope_snapshot||Z.draft?.planner_diagnostics||null),F(null),L(null),z(null),B(null),H(null),U(null);let t=Z.draft?.review||null,n=t?.preview_payload||null;t&&n&&(j(n.planner_diagnostics||Z.draft?.planner_diagnostics||null),F(n.plan_package_validation||null),L(n.plan_package||null),z(n.plan_package_bundle||null),B(n.plan_package_replay||null),H(n.overlap_analysis||null),U(n.teaching_library||null),ze(Number.isFinite(Number(t.updated_at_ms))?Number(t.updated_at_ms):Number.isFinite(Number(Z.updated_at_ms))?Number(Z.updated_at_ms):null)),S(`idle`),K(!0),je(!0),Te(G(Z.title||e.title)),qe(Z.session_id),q?.session_id===Y&&Wt(!1)},[Z,Ke,Y,q?.session_id]),e(()=>{if(!J?.prompt||Y||De&&G(y||_.goal))return;let e=G(J.prompt);e&&(v(t=>({...t,goal:e,workspaceRoot:G(J.workspace_root||t.workspaceRoot)})),b(e),S(`idle`),K(!1),je(!0))},[_.goal,De,Y,y,J]);let Pt=()=>{Ae(rt),v(W),b(``),S(`idle`),w(null),E(null),O([]),k(``),j(null),N({status:`none`}),F(null),L(null),z(null),B(null),H(null),U(null),ze(null),K(!1),Te(``)},Ft=e=>e?(v({...W,goal:G(e.brief?.goal||e.goal),workspaceRoot:G(e.brief?.workspaceRoot||e.workspaceRoot),targetSurface:e.brief?.targetSurface||e.targetSurface||W.targetSurface,planningHorizon:e.brief?.planningHorizon||e.planningHorizon||W.planningHorizon,outputExpectations:G(e.brief?.outputExpectations||e.outputExpectations),constraints:G(e.brief?.constraints||e.constraints),plannerProvider:G(e.brief?.plannerProvider||e.plannerProvider),plannerModel:G(e.brief?.plannerModel||e.plannerModel),selectedMcpServers:Array.isArray(e.brief?.selectedMcpServers)?e.brief.selectedMcpServers.map(e=>G(e)).filter(Boolean):Array.isArray(e.selectedMcpServers)?e.selectedMcpServers.map(e=>G(e)).filter(Boolean):[]}),b(G(e.plannerInput)),S(`idle`),w(e.planPreview||e.planPreviewJson||e.plan||null),E(e.planningConversation||e.conversation||null),O(Array.isArray(e.planningChangeSummary||e.changeSummary)?(e.planningChangeSummary||e.changeSummary).map(e=>G(e)).filter(Boolean):[]),k(G(e.plannerError)),j(e.plannerDiagnostics||null),F(e.validationReport||null),L(e.planPackage||null),z(e.planPackageBundle||null),B(e.planPackageReplay||null),H(e.overlapAnalysis||null),U(e.teachingLibrary||null),ze(Number.isFinite(Number(e.updatedAtMs))?Number(e.updatedAtMs):null),K(!0),je(!0),Te(G(e.name||e.title||e.brief?.goal||e.goal)),!0):!1;e(()=>{je(!1);let e=ye(rt);if(!e){je(!0),K(!1);return}Ft(e)},[rt]),e(()=>{try{f()}catch{}}),e(()=>{if(!De)return;let e={name:Ce,brief:_,plannerInput:y,planPreview:C,planningConversation:T,planningChangeSummary:D,plannerError:se,plannerDiagnostics:A,validationReport:P,planPackage:I,planPackageBundle:R,planPackageReplay:he,overlapAnalysis:V,teachingLibrary:xe},t=be(rt,e);typeof t==`number`&&ze(t),Ee(at,e)},[_,V,rt,I,R,he,C,A,se,y,D,T,De,at,Ce,xe,P]);let It=async e=>{let t=G(e||y||_.goal),n=G(_.workspaceRoot);if(!t){c(`warn`,`Describe the intent you want the planner to turn into a long-horizon plan.`);return}if(!n){c(`warn`,`Workspace root is required so the planner can inspect the target workspace.`);return}if(!n.startsWith(`/`)){c(`warn`,`Workspace root must be an absolute path.`);return}S(`generating`),k(``),j(null),v(e=>({...e,goal:t}));try{let e=await s.workflowPlans.chatStart({prompt:Ve({..._,goal:t}),plan_source:`intent_planner_page`,workspace_root:n,allowed_mcp_servers:_.selectedMcpServers.length?_.selectedMcpServers:mt,operator_preferences:{planner_target_surface:_.targetSurface,planning_horizon:_.planningHorizon,expected_outputs:G(_.outputExpectations),constraints:G(_.constraints),planner_provider:G(_.plannerProvider),planner_model:G(_.plannerModel),...ne(t),...m(t)}});w(e?.plan||null),E(e?.conversation||null),O([]),j(e?.planner_diagnostics||null),F(e?.plan_package_validation||null),L(e?.plan_package||null),z(e?.plan_package_bundle||null),B(e?.plan_package_replay||null),H(e?.overlap_analysis||null),U(e?.teaching_library||null),K(!1);let r=typeof e?.clarifier?.question==`string`?String(e.clarifier.question):``,i=Array.isArray(e?.clarifier?.options)?e.clarifier.options.map(e=>({id:G(e?.id),label:G(e?.label)})).filter(e=>e.id&&e.label):[];r&&k(r),r&&i.length>0?(N({status:`waiting`,question:r,options:i}),S(`clarifying`)):(N({status:`none`}),S(`idle`)),b(``),c(`ok`,r?`Planner needs clarification before it can refine the mission.`:`Planner generated a draft mission plan.`)}catch(e){let t=e instanceof Error?e.message:String(e);k(t),N({status:`none`}),S(`idle`),c(`err`,t)}},Lt=async e=>{let t=G(C?.plan_id||C?.planId);if(!t){c(`warn`,`Start a planning session before revising the plan.`);return}let n=G(e??y);if(!n){c(`warn`,`Add a message for the planner first.`);return}S(`revising`),k(``),j(null);try{let e=await s.workflowPlans.chatMessage({plan_id:t,message:n});w(e?.plan||null),E(e?.conversation||null),O(Array.isArray(e?.change_summary)?e.change_summary.map(e=>G(e)).filter(Boolean):[]),j(e?.planner_diagnostics||null),F(e?.plan_package_validation||null),L(e?.plan_package||null),z(e?.plan_package_bundle||null),B(e?.plan_package_replay||null),H(e?.overlap_analysis||null),U(e?.teaching_library||null),K(!1);let r=typeof e?.clarifier?.question==`string`?String(e.clarifier.question):``,i=Array.isArray(e?.clarifier?.options)?e.clarifier.options.map(e=>({id:G(e?.id),label:G(e?.label)})).filter(e=>e.id&&e.label):[];r&&k(r),r&&i.length>0?(N({status:`waiting`,question:r,options:i}),S(`clarifying`)):(N({status:`none`}),S(`idle`)),b(``),c(`ok`,`Planner revised the draft plan.`)}catch(e){let t=e instanceof Error?e.message:String(e);k(t),N({status:`none`}),S(`idle`),c(`err`,t)}},Rt=async()=>{let e=G(C?.plan_id||C?.planId);if(!e||!s.workflowPlans.chatReset){Pt(),c(`ok`,`Planner draft reset.`);return}try{let t=await s.workflowPlans.chatReset({plan_id:e});w(t?.plan||null),E(t?.conversation||null),O([]),k(``),j(t?.planner_diagnostics||null),F(t?.plan_package_validation||null),L(t?.plan_package||null),z(t?.plan_package_bundle||null),B(t?.plan_package_replay||null),H(t?.overlap_analysis||null),U(t?.teaching_library||null),N({status:`none`}),S(`idle`),b(``),K(!1),c(`ok`,`Planner session reset.`)}catch(e){let t=e instanceof Error?e.message:String(e);k(t),c(`err`,t)}},zt=()=>{let e=G(Ce||_.goal||C?.title||C?.plan_id);if(!e){c(`warn`,`Name the planner draft before saving it as a saved intent.`);return}if(!Se(it,e,{name:e,brief:_,plannerInput:y,planPreview:C,planningConversation:T,planningChangeSummary:D,plannerError:se,plannerDiagnostics:A,validationReport:P,planPackage:I,planPackageBundle:R,planPackageReplay:he,overlapAnalysis:V,teachingLibrary:xe})){c(`err`,`Unable to save the named planner draft.`);return}Te(e),K(!1),c(`ok`,`Saved planner draft “${e}”.`)},Bt=e=>{let t=ye(e);if(!t){c(`warn`,`That saved planner draft could not be loaded.`);return}if(!Ft(t)){c(`warn`,`That saved planner draft was empty.`);return}c(`ok`,`Reopened planner draft “${G(t.name||t.title)}”.`)},Vt=e=>{we(e),K(!1),c(`ok`,`Deleted the saved planner draft.`)},Ht=e=>{let t=Oe(at,e);if(!t){c(`warn`,`That autosaved planner state could not be loaded.`);return}if(!Ft(t)){c(`warn`,`That autosaved planner state was empty.`);return}c(`ok`,`Reopened a recent autosaved planner state.`)},Ut=e=>{ke(at,e),K(!1),c(`ok`,`Deleted the autosaved planner state.`)},Wt=(e=!0)=>{try{localStorage.removeItem(He)}catch{}Je(null),e&&c(`ok`,`Cleared the imported workflow handoff.`)};return a(u,{className:`flex flex-col min-h-0 h-full overflow-hidden`,children:[q?a(d,{title:`Imported workflow handoff`,subtitle:`This durable session was created from an imported bundle. Open the workflow center to inspect, revise, or continue it.`,className:`mb-4`,actions:a(`div`,{className:`flex flex-wrap gap-2`,children:[a(`button`,{type:`button`,className:`tcp-btn-secondary`,onClick:()=>g(`workflows`),children:`Open workflow center`}),a(`button`,{type:`button`,className:`tcp-btn-secondary`,onClick:()=>Wt(),children:`Dismiss`})]}),children:a(`div`,{className:`grid gap-3 text-sm`,children:[a(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a(l,{tone:St===`imported_bundle`?`warn`:`info`,children:St||`imported_bundle`}),a(l,{tone:`ghost`,children:G(q.session_id)})]}),a(`div`,{className:`grid gap-1 md:grid-cols-2`,children:[a(`div`,{children:[a(`div`,{className:`tcp-subtle text-xs`,children:`Title`}),a(`div`,{children:G(Z?.title||q.title||`Imported workflow`)})]}),a(`div`,{children:[a(`div`,{className:`tcp-subtle text-xs`,children:`Project`}),a(`div`,{children:G(Z?.project_slug||q.project_slug||`workflow-imports`)})]}),a(`div`,{children:[a(`div`,{className:`tcp-subtle text-xs`,children:`Bundle digest`}),a(`div`,{children:G(Z?.source_bundle_digest||q.source_bundle_digest||`—`)})]}),a(`div`,{children:[a(`div`,{className:`tcp-subtle text-xs`,children:`Current plan id`}),a(`div`,{children:G(Z?.current_plan_id||q.current_plan_id||`—`)})]})]})]})}):null,(Y||kt)&&!q?a(d,{title:`Workflow planner handoff`,subtitle:`This planner session was seeded from chat or a channel and will resume the governed draft here.`,className:`mb-4`,children:a(`div`,{className:`grid gap-3 text-sm`,children:[a(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a(l,{tone:Y?`info`:`warn`,children:Y?`session`:`seed`}),Y?a(l,{tone:`ghost`,children:Y}):null]}),a(`div`,{className:`grid gap-1 md:grid-cols-2 xl:grid-cols-3`,children:[a(`div`,{children:[a(`div`,{className:`tcp-subtle text-xs`,children:`Original request`}),a(`div`,{children:G(wt||kt||`Workflow planner`)})]}),a(`div`,{children:[a(`div`,{className:`tcp-subtle text-xs`,children:`Source platform`}),a(`div`,{children:G($?.source_platform||J?.source_platform||`chat`)})]}),a(`div`,{children:[a(`div`,{className:`tcp-subtle text-xs`,children:`Source channel`}),a(`div`,{children:G($?.source_channel||J?.source_channel||`—`)})]}),a(`div`,{children:[a(`div`,{className:`tcp-subtle text-xs`,children:`Planning mode`}),a(`div`,{children:G($?.mode||`workflow_planning`)})]}),a(`div`,{children:[a(`div`,{className:`tcp-subtle text-xs`,children:`Created by / actor`}),a(`div`,{children:G(Fe($))})]}),a(`div`,{children:[a(`div`,{className:`tcp-subtle text-xs`,children:`Draft id`}),a(`div`,{children:Tt})]}),a(`div`,{children:[a(`div`,{className:`tcp-subtle text-xs`,children:`Draft status`}),a(`div`,{children:Et})]}),a(`div`,{children:[a(`div`,{className:`tcp-subtle text-xs`,children:`Validation state`}),a(`div`,{children:Dt})]}),a(`div`,{children:[a(`div`,{className:`tcp-subtle text-xs`,children:`Validation status`}),a(`div`,{children:G(Q?.validation_status||$?.validation_status||`pending`)})]}),a(`div`,{children:[a(`div`,{className:`tcp-subtle text-xs`,children:`Approval requirements`}),a(`div`,{children:Ot})]}),a(`div`,{children:[a(`div`,{className:`tcp-subtle text-xs`,children:`Docs MCP`}),a(`div`,{children:Q?.docs_mcp_used?`used in the draft`:`not used yet`})]}),a(`div`,{children:[a(`div`,{className:`tcp-subtle text-xs`,children:`Required capabilities`}),a(`div`,{children:Pe(Q?.required_capabilities)})]}),a(`div`,{children:[a(`div`,{className:`tcp-subtle text-xs`,children:`Blocked capabilities`}),a(`div`,{children:Pe(Q?.blocked_capabilities)})]}),a(`div`,{children:[a(`div`,{className:`tcp-subtle text-xs`,children:`Missing requirements`}),a(`div`,{children:Pe($?.missing_requirements)})]}),a(`div`,{children:[a(`div`,{className:`tcp-subtle text-xs`,children:`Workflow preview`}),a(`div`,{children:Ie(Q)})]})]})]})}):null,a(`div`,{className:`grid flex-1 gap-4 min-h-0 xl:grid-cols-[minmax(400px,0.8fr)_minmax(0,1.2fr)]`,children:[a(`div`,{className:`flex flex-col gap-4 min-h-0 h-full overflow-y-auto pr-1`,children:[a(d,{title:`Intent brief`,subtitle:`Describe the mission goal.`,className:`flex flex-col shrink-0`,actions:a(`div`,{className:`flex flex-wrap gap-2 text-[10px]`,children:[a(l,{tone:`ok`,children:`intent → plan`}),Be?a(l,{tone:`info`,children:`restored`}):null]}),children:a(ae,{draft:_,onChange:v,providerOptions:ft,plannerCanUseLlm:ht,basePlannerLabel:G(p.defaultProvider)&&G(p.defaultModel)?`${G(p.defaultProvider)} / ${G(p.defaultModel)}`:`not configured`,availableMcpServers:pt,workspaceRootError:Nt,workspaceBrowserOpen:Xe,workspaceBrowserDir:Qe,workspaceBrowserSearch:et,workspaceBrowserParentDir:At,workspaceBrowserCurrentDir:jt,workspaceBrowserDirectories:Mt,onOpenWorkspaceBrowser:()=>{$e(String(_.workspaceRoot||lt.data?.workspaceRoot||lt.data?.workspace_root||`/`).trim()||`/`),tt(``),Ze(!0)},onCloseWorkspaceBrowser:()=>{Ze(!1),tt(``)},onClearWorkspaceRoot:()=>v(e=>({...e,workspaceRoot:``})),onWorkspaceBrowserSearchChange:tt,onWorkspaceBrowserParent:()=>{At&&$e(At)},onWorkspaceBrowserDirectory:e=>$e(e),onSelectWorkspaceDirectory:()=>{jt&&(v(e=>({...e,workspaceRoot:jt})),Ze(!1),tt(``),c(`ok`,`Workspace selected: ${jt}`))},onReset:()=>{Pt(),c(`ok`,`Started a new empty mission draft.`)},disabled:_t})}),a(Ne,{storagePrefix:it,historyKey:at,draftName:Ce,onDraftNameChange:Te,onSaveCurrentDraft:zt,onOpenDraft:Bt,onDeleteDraft:Vt,onOpenHistory:Ht,onDeleteHistory:Ut})]}),a(`div`,{className:`flex flex-col gap-4 min-h-0 h-full overflow-y-auto pr-1 pb-10`,children:[a(d,{title:`Planner conversation`,subtitle:`Shape the full workflow plan.`,className:`flex flex-col shrink-0 h-[500px]`,actions:a(`div`,{className:`flex flex-wrap gap-2`,children:[a(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>void It(),disabled:_t,children:[a(`i`,{"data-lucide":X?`refresh-cw`:`play`,className:`mr-1 h-3 w-3`}),X?`Regenerate`:`Start planning`]}),a(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>void Rt(),title:`Reset session`,children:a(`i`,{"data-lucide":`rotate-ccw`})})]}),children:a(`div`,{className:`tcp-chat-container flex-1`,children:[Me?a(`div`,{className:`mb-3 rounded-xl border border-white/5 bg-black/20 px-3 py-2 text-[10px] text-slate-500`,children:[`Last autosave: `,new Date(Me).toLocaleTimeString()]}):null,a(`div`,{className:`tcp-chat-fill flex flex-col`,children:a(re,{messages:gt,emptyText:`Describe your mission intent to start.`,inputValue:y,inputPlaceholder:X?`Refine the plan...`:`Describe the mission and outcome...`,sendLabel:X?`Send to planner`:`Start plan`,onInputChange:b,onSend:()=>void(X?Lt(y):It(y)),sendDisabled:_t||!G(y),inputDisabled:_t,statusTitle:yt,statusDetail:_t?bt:``,questionTitle:`Planner question`,questionText:M.status===`waiting`?M.question:``,quickReplies:M.status===`waiting`&&M.options||[],onQuickReply:e=>void Lt(e.label),questionHint:`Reply with more detail.`,botIdentity:{botName:`Tandem Planner`,botAvatarUrl:h.botAvatarUrl},showThinking:x===`generating`||x===`revising`,thinkingText:x===`revising`?`Revising plan`:`Drafting plan`})}),a(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[a(`button`,{type:`button`,className:`tcp-btn-primary`,onClick:()=>void(X?Lt(y||_.goal):It()),disabled:_t||!X&&!G(_.goal)||!G(_.workspaceRoot),children:X?`Revise draft`:`Generate draft`}),a(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>b(_.goal),disabled:_t||!G(_.goal),children:`Seed from brief`})]})]})}),_t?a(d,{title:`Generating plan flow`,subtitle:`The planner is synthesizing structure.`,className:`shrink-0`,children:a(me,{})}):null,vt?a(t,{children:[a(fe,{brief:_,planPreview:C,planPackage:I,planPackageBundle:R,validationReport:P,overlapAnalysis:V,teachingLibrary:xe,navigate:g,toast:c}),a(pe,{brief:_,planPreview:C,validationReport:P,overlapAnalysis:V}),a(ce,{brief:_,planPreview:C}),a(oe,{planPreview:C,brief:_,planPackage:I,planPackageBundle:R}),a(le,{validationReport:P}),a(ue,{overlapAnalysis:V}),a(de,{planPackageReplay:he}),a(ie,{plannerDiagnostics:A,teachingLibrary:xe,planningChangeSummary:D})]}):null]})]})]})}export{Ke as IntentPlannerPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as e,v as t}from"./fullcalendar-Bn75j0xM.js";import{i as n}from"./motion-B3ZE8SGR.js";function r(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function i({value:i,label:a=`Show raw JSON`,className:o=``,preClassName:s=`tcp-code mt-2 max-h-64 overflow-auto text-[11px]`,hint:c}){let[l,u]=t(!1),d=e(()=>l?r(i):``,[l,i]);return n(`details`,{className:o,onToggle:e=>u(e.currentTarget.open),children:[n(`summary`,{className:`cursor-pointer select-none text-xs text-slate-400 hover:text-slate-200`,children:[a,c?n(`span`,{className:`ml-2 text-[10px] text-slate-500`,children:c}):null]}),l?n(`pre`,{className:s,children:d}):null]})}function a({value:t,open:i,className:a=`tcp-code mt-2 max-h-32 overflow-auto text-[11px]`}){let o=e(()=>i?r(t):``,[i,t]);return i?n(`pre`,{className:a,children:o}):null}export{i as n,a as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{E as e,g as t,v as n}from"./fullcalendar-Bn75j0xM.js";import{i as r}from"./motion-B3ZE8SGR.js";import{d as i,l as a,n as o,t as s,u as c}from"./ui-CV-Z6sqF.js";import{s as l}from"./index-picB46b5.js";var u=[{packId:`planning-pack`,title:`Planning Pack`,summary:`Kickoff, weekly status, meeting notes, and action tracking for teams that need clarity fast.`,audience:`Project leads, operators, and team managers`,categories:[`planning`,`project management`,`operations`],tags:[`kickoff`,`weekly status`,`action tracking`],highlight:`Best starting point for general-purpose planning workflows.`},{packId:`writing-pack`,title:`Writing Pack`,summary:`Draft, polish, and repurpose articles with an SEO-aware workflow that keeps the story readable.`,audience:`Writers, editors, and marketers`,categories:[`writing`,`seo`,`content marketing`],tags:[`blog drafts`,`copy editing`,`content refresh`],highlight:`Useful when the output needs to read well and rank well.`},{packId:`research-pack`,title:`Research Pack`,summary:`Turn rough questions into structured briefs, source checks, and comparative analysis.`,audience:`Researchers, analysts, and product teams`,categories:[`research`,`analysis`,`fact finding`],tags:[`briefs`,`source verification`,`competitive scan`],highlight:`Good for turning uncertainty into a clear evidence trail.`},{packId:`build-pack`,title:`Build Pack`,summary:`Break features into implementation tasks, review changes, and keep engineering work moving.`,audience:`Developers, reviewers, and release teams`,categories:[`engineering`,`delivery`,`release`],tags:[`feature breakdown`,`bug triage`,`pr review`],highlight:`Best when you want a workflow that maps directly to coding work.`}];function d(d){let[f,p]=n(u[0]?.packId||``),m=t(()=>u.find(e=>e.packId===f)||u[0],[f]);return r(s,{className:`grid gap-4`,children:[r(a,{eyebrow:`Marketplace`,title:`Marketplace coming soon`,subtitle:`This route is intentionally hidden by default. If someone enables it manually, it stays a placeholder until the tandem.ac marketplace is live.`,badges:r(e,{children:[r(o,{tone:`info`,children:`coming soon`}),r(o,{tone:`ghost`,children:[u.length,` seed concepts`]}),r(o,{tone:`ghost`,children:`disabled by default`})]})}),r(c,{title:`Marketplace not live yet`,subtitle:`The public store will live on tandem.ac. This page is a placeholder until search, login, and purchase are ready.`,children:r(`div`,{className:`grid gap-3`,children:[r(`div`,{className:`tcp-list-item`,children:[r(`div`,{className:`tcp-subtle text-xs uppercase tracking-[0.24em]`,children:`Status`}),r(`div`,{className:`mt-2 text-sm`,children:`The marketplace page is intentionally a placeholder until the tandem.ac catalog API and listing pages go live.`})]}),r(`div`,{className:`flex flex-wrap gap-2`,children:[r(`button`,{className:`tcp-btn-primary`,type:`button`,disabled:!0,children:[r(`i`,{"data-lucide":`search`}),`Search marketplace`]}),r(`button`,{className:`tcp-btn`,type:`button`,disabled:!0,children:[r(`i`,{"data-lucide":`external-link`}),`Open tandem.ac`]})]})]})}),r(i,{main:r(`div`,{className:`grid gap-4`,children:[r(c,{title:`Seed concepts`,subtitle:`These are planning concepts, not published marketplace listings.`,children:r(`div`,{className:`grid gap-3`,children:u.map(e=>r(`button`,{type:`button`,className:`tcp-list-item text-left ${m?.packId===e.packId?`border-amber-400/70`:``}`,onClick:()=>p(e.packId),children:r(`div`,{className:`flex items-start justify-between gap-3`,children:[r(`div`,{className:`min-w-0 flex-1`,children:[r(`div`,{className:`mb-1 flex items-center gap-2`,children:[r(`strong`,{children:e.title}),r(o,{tone:`info`,children:e.packId}),r(o,{tone:`ghost`,children:`planned seed`})]}),r(`div`,{className:`tcp-subtle text-sm`,children:e.summary}),r(`div`,{className:`mt-2 flex flex-wrap gap-2 text-xs`,children:[r(o,{tone:`ghost`,children:e.audience}),e.categories.map(t=>r(o,{tone:`ghost`,children:t},`${e.packId}-${t}`))]})]}),r(o,{tone:`ghost`,children:e.highlight})]})},e.packId))})}),r(c,{title:`What tandem.ac will own later`,subtitle:`The store belongs on the web, not inside the control panel.`,children:r(`div`,{className:`grid gap-2 text-sm tcp-subtle`,children:[r(`div`,{children:`• login and account state`}),r(`div`,{children:`• pricing and purchase`}),r(`div`,{children:`• pack detail pages and publisher pages`}),r(`div`,{children:`• public search and browse results`}),r(`div`,{children:`• future entitlement and redemption flows`})]})})]}),aside:r(c,{title:`Selected concept`,subtitle:`This is a seed idea that will become a real listing later.`,children:m?r(`div`,{className:`grid gap-3`,children:[r(`div`,{className:`tcp-list-item`,children:[r(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[r(`strong`,{children:m.title}),r(o,{tone:`info`,children:m.packId}),r(o,{tone:`ghost`,children:`concept only`})]}),r(`div`,{className:`tcp-subtle text-sm`,children:m.summary}),r(`div`,{className:`mt-2 flex flex-wrap gap-2 text-xs`,children:[m.categories.map(e=>r(o,{tone:`ghost`,children:e},`${m.packId}-${e}-aside`)),m.tags.map(e=>r(o,{tone:`ghost`,children:e},`${m.packId}-${e}`))]})]}),r(`div`,{className:`tcp-list-item`,children:[r(`div`,{className:`tcp-subtle text-xs uppercase tracking-[0.24em]`,children:`Why it exists`}),r(`div`,{className:`mt-2 text-sm`,children:m.highlight})]})]}):r(l,{text:`Select a featured concept.`})})})]})}export{d as MarketplacePage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,E as t,g as n,h as r,v as i}from"./fullcalendar-Bn75j0xM.js";import{i as a}from"./motion-B3ZE8SGR.js";import{a as o}from"./index-picB46b5.js";function s(e){let t=``,n=!1;for(let r of String(e||``).trim())/^[a-z0-9]$/i.test(r)?(t+=r.toLowerCase(),n=!1):n||=(t+=`_`,!0);return t.replace(/^_+|_+$/g,``)||`mcp`}function c(e){return String(e||``).trim()}function l(e){return c(e).toLowerCase().startsWith(`mcp.`)}function u(e){let t=Array.isArray(e)?e:Array.isArray(e?.toolCache)?e.toolCache:Array.isArray(e?.tool_cache)?e.tool_cache:[],n=new Set,r=[];for(let e of t){let t=typeof e==`string`?c(e):e&&typeof e==`object`?c(e.namespaced_name||e.namespacedName||e.tool_name||e.toolName||e.name):``;!t||n.has(t)||(n.add(t),r.push(t))}return r}function d(e){let t=Array.isArray(e)?e:[],n=[],r=[],i=new Set,a=new Set;for(let e of t){let t=c(e);if(t){if(l(t)){if(i.has(t))continue;i.add(t),n.push(t);continue}a.has(t)||(a.add(t),r.push(t))}}return{mcpTools:n,otherTools:r}}function f(e,t){let n=u(e),r=u(t);return n.length&&n.length===r.length&&n.every(e=>r.includes(e))?null:r}function p({title:s,subtitle:c,discoveredTools:l,value:d,onChange:p,disabled:m=!1,emptyText:h=`No MCP tools have been discovered for this server yet.`,collapsible:g=!1,defaultCollapsed:_=!1}){let v=r(null),[y,b]=i(_),x=n(()=>u(l),[l]),S=n(()=>d===null?[...x]:u(d),[d,x]),C=n(()=>new Set(S),[S]),w=n(()=>new Set(x),[x]),T=x.filter(e=>C.has(e)).length,E=S.filter(e=>!w.has(e)),D=x.length>0&&T===x.length&&E.length===0;e(()=>{v.current&&o(v.current)},[y,x.length,E.length,T]);let O=e=>{m||p(e)},k=e=>{if(m)return;let t=new Set(d===null?x:S);t.has(e)?t.delete(e):t.add(e);let n=Array.from(t);p(f(x,n)===null?null:n)};return a(`div`,{ref:v,className:`grid gap-3 rounded-xl border border-slate-700/70 bg-slate-950/30 p-3`,children:[a(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[a(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[g?a(`button`,{type:`button`,className:`mt-0.5 rounded-full border border-slate-700/80 p-1 text-slate-300 transition hover:border-slate-500 hover:text-slate-100`,"aria-label":y?`Expand ${s}`:`Collapse ${s}`,"aria-expanded":!y,onClick:()=>b(e=>!e),children:a(`i`,{"data-lucide":`chevron-down`,className:`block h-4 w-4 transition-transform ${y?``:`rotate-180`}`})}):null,a(`div`,{className:`grid gap-1`,children:[a(`div`,{className:`text-sm font-medium text-slate-100`,children:s}),c?a(`div`,{className:`text-xs text-slate-400`,children:c}):null]})]}),a(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] text-slate-400`,children:[a(`span`,{className:`rounded-full border border-slate-700 px-2 py-1`,children:d===null||D?`all discovered`:`${T}/${x.length||0} selected`}),y?null:a(t,{children:[a(`button`,{type:`button`,className:`rounded-full border border-slate-700 px-2 py-1 text-slate-200 transition hover:border-slate-500 disabled:cursor-not-allowed disabled:opacity-50`,disabled:m||!x.length,onClick:()=>O(null),children:`Select all`}),a(`button`,{type:`button`,className:`rounded-full border border-slate-700 px-2 py-1 text-slate-200 transition hover:border-slate-500 disabled:cursor-not-allowed disabled:opacity-50`,disabled:m||!S.length&&!E.length,onClick:()=>O([]),children:`Clear all`})]})]})]}),y?null:!x.length&&!E.length?a(`div`,{className:`text-xs text-slate-500`,children:h}):a(t,{children:[x.length?a(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-3`,children:x.map(e=>{let t=d===null||C.has(e);return a(`label`,{className:`flex items-start gap-2 rounded-lg border px-3 py-2 text-sm transition ${t?`border-amber-400/40 bg-amber-400/10 text-amber-100`:`border-slate-700/70 bg-slate-950/20 text-slate-300`} ${m?`opacity-60`:`cursor-pointer`}`,children:[a(`input`,{type:`checkbox`,className:`mt-1`,checked:t,disabled:m,onChange:()=>k(e)}),a(`span`,{className:`break-all font-mono text-[11px] leading-5`,children:e})]},e)})}):null,E.length?a(`div`,{className:`grid gap-2`,children:[a(`div`,{className:`text-[11px] uppercase tracking-wide text-amber-200`,children:`Saved but not currently discovered`}),a(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-3`,children:E.map(e=>a(`label`,{className:`flex items-start gap-2 rounded-lg border border-amber-400/30 bg-amber-400/10 px-3 py-2 text-sm text-amber-100 ${m?`opacity-60`:`cursor-pointer`}`,children:[a(`input`,{type:`checkbox`,className:`mt-1`,checked:!0,disabled:m,onChange:()=>k(e)}),a(`span`,{className:`break-all font-mono text-[11px] leading-5`,children:e})]},e))})]}):null]})]})}export{s as n,d as r,p as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,h as t,v as n}from"./fullcalendar-Bn75j0xM.js";import{t as r}from"./react-query-BIbNygEJ.js";import{i,n as a,r as o}from"./motion-B3ZE8SGR.js";import{a as s}from"./index-picB46b5.js";var c=[[`discovered_files`,`Discovered files`],[`indexed_files`,`Indexed files`],[`skipped_files`,`Skipped files`],[`deleted_files`,`Deleted files`],[`chunks_created`,`Chunks created`],[`errors`,`Errors`]];function l({open:l,client:u,initialPath:d=``,initialTier:f=`global`,initialProjectId:p=``,note:m=``,toast:h,onCancel:g,onSuccess:_}){let v=t(null),[y,b]=n({path:d,format:`directory`,tier:f,projectId:p,sessionId:``,syncDeletes:!1}),[x,S]=n(null);e(()=>{l&&(b({path:d,format:`directory`,tier:f,projectId:p,sessionId:``,syncDeletes:!1}),S(null))},[d,p,f,l]),e(()=>{!l||!v.current||s(v.current)},[y.format,y.syncDeletes,y.tier,l,x]),e(()=>{if(!l||typeof window>`u`)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),g())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g,l]);let C=r({mutationFn:()=>u.memory.importPath({path:y.path.trim(),format:y.format,tier:y.tier,projectId:y.projectId.trim()||void 0,sessionId:y.sessionId.trim()||void 0,syncDeletes:y.syncDeletes}),onSuccess:async e=>{S(e),h(`ok`,`Indexed ${e.indexed_files} file(s) and created ${e.chunks_created} chunk(s).`),await _?.(e)},onError:e=>{h(`err`,e instanceof Error?e.message:String(e))}}),w=y.tier===`project`,T=y.tier===`session`,E=!y.path.trim(),D=w&&!y.projectId.trim()||T&&!y.sessionId.trim();return i(o,{children:l?i(a.div,{className:`tcp-confirm-overlay`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:g,children:i(a.div,{ref:v,className:`tcp-confirm-dialog w-[min(42rem,96vw)]`,initial:{opacity:0,y:8,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:6,scale:.98},onClick:e=>e.stopPropagation(),children:[i(`h3`,{className:`tcp-confirm-title`,children:`Import Knowledge`}),i(`div`,{className:`tcp-confirm-message`,children:`Index this file or folder so Tandem agents can retrieve it as governed memory.`}),m?i(`div`,{className:`mb-3 rounded-lg border border-amber-500/20 bg-amber-950/20 p-2 text-xs text-amber-100`,children:m}):null,i(`div`,{className:`grid gap-3 text-left`,children:[i(`label`,{className:`grid gap-1`,children:[i(`span`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Path`}),i(`input`,{className:`tcp-input`,value:y.path,placeholder:`/srv/tandem/imports/company-docs`,onChange:e=>b({...y,path:e.target.value})})]}),i(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[i(`label`,{className:`grid gap-1`,children:[i(`span`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Format`}),i(`select`,{className:`tcp-select`,value:y.format,onChange:e=>b({...y,format:e.target.value}),children:[i(`option`,{value:`directory`,children:`directory`}),i(`option`,{value:`openclaw`,children:`openclaw`})]})]}),i(`label`,{className:`grid gap-1`,children:[i(`span`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Tier`}),i(`select`,{className:`tcp-select`,value:y.tier,onChange:e=>b({...y,tier:e.target.value}),children:[i(`option`,{value:`global`,children:`global`}),i(`option`,{value:`project`,children:`project`}),i(`option`,{value:`session`,children:`session`})]})]}),i(`label`,{className:`flex items-center gap-2 rounded-lg border border-white/10 bg-black/20 px-3 py-2 text-sm`,children:[i(`input`,{type:`checkbox`,className:`h-4 w-4 accent-sky-400`,checked:y.syncDeletes,onChange:e=>b({...y,syncDeletes:e.target.checked})}),`Sync deletes`]})]}),i(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[i(`label`,{className:`grid gap-1`,children:[i(`span`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`project_id`}),i(`input`,{className:`tcp-input`,value:y.projectId,placeholder:w?`company-brain-demo`:`optional`,onChange:e=>b({...y,projectId:e.target.value})})]}),i(`label`,{className:`grid gap-1`,children:[i(`span`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`session_id`}),i(`input`,{className:`tcp-input`,value:y.sessionId,placeholder:T?`session id`:`optional`,onChange:e=>b({...y,sessionId:e.target.value})})]})]})]}),x?i(`div`,{className:`mt-3 grid gap-2 rounded-xl border border-white/10 bg-black/20 p-3 text-left`,children:[i(`div`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Import stats`}),i(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:c.map(([e,t])=>i(`div`,{className:`rounded-lg border border-white/10 bg-black/10 p-2`,children:[i(`div`,{className:`tcp-subtle text-[11px]`,children:t}),i(`div`,{className:`mt-1 font-semibold tabular-nums`,children:Number(x[e]||0)})]},e))})]}):null,i(`div`,{className:`tcp-confirm-actions mt-3`,children:[i(`button`,{type:`button`,className:`tcp-btn`,onClick:g,children:[i(`i`,{"data-lucide":`x`}),`Close`]}),i(`button`,{type:`button`,className:`tcp-btn-primary`,disabled:E||D||C.isPending,onClick:()=>C.mutate(),children:[i(`i`,{"data-lucide":`database-zap`}),C.isPending?`Importing...`:`Import to Memory`]})]})]})}):null})}export{l as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{E as e,g as t,v as n}from"./fullcalendar-Bn75j0xM.js";import{a as r,n as i,t as a}from"./react-query-BIbNygEJ.js";import{i as o,n as s,r as c}from"./motion-B3ZE8SGR.js";import{m as l,n as u,t as d,u as f}from"./ui-CV-Z6sqF.js";import{s as p,u as m}from"./index-picB46b5.js";import{t as h}from"./MemoryImportDialog-BWT93PW1.js";var g=new Set([`user_message`,`assistant_message`,`assistant_response`,`assistant_final`,`channel_message`,`session_message`]);function _(e,t){return Array.isArray(e)?e:Array.isArray(e?.[t])?e[t]:[]}function v(e,t){let n=t.trim().toLowerCase();if(g.has(n)||n.endsWith(`_message`)||n.includes(`message`))return!0;let r=e?.metadata||{},i=e?.provenance||{},a=String(r?.origin||i?.origin_event_type||``).toLowerCase();return a.includes(`message`)||a.includes(`channel`)}function y({api:g,client:y,toast:b}){let x=r(),[S,C]=n(``),[w,T]=n(`knowledge`),[E,D]=n(null),[O,k]=n(!1),[A,j]=n(!1),[M,N]=n(``),[P,F]=n(`note`),[I,L]=n(``),[R,z]=n(`private`),B=i({queryKey:[`memory`,S],queryFn:()=>(S.trim()?y.memory.search({query:S,limit:40}):y.memory.list({q:``,limit:40})).catch(()=>({items:[]})),refetchInterval:15e3}),V=a({mutationFn:e=>y.memory.delete(e),onSuccess:async()=>{b(`ok`,`Memory record deleted.`),await x.invalidateQueries({queryKey:[`memory`]})},onError:e=>b(`err`,e instanceof Error?e.message:String(e))}),H=a({mutationFn:async()=>{let e=I.trim()||`default`,t=R===`shared`?`project`:`session`,n=`manual-memory-${Date.now()}`;return g(`/api/engine/memory/put`,{method:`POST`,body:JSON.stringify({run_id:n,partition:{org_id:`local`,workspace_id:`control-panel`,project_id:e,tier:t},kind:P,content:M.trim(),classification:`internal`,metadata:{origin:`control_panel_manual_add`,visibility:R},capability:{run_id:n,subject:`control-panel`,org_id:`local`,workspace_id:`control-panel`,project_id:e,memory:{read_tiers:[`session`,`project`],write_tiers:[t],promote_targets:[`project`],require_review_for_promote:!1,allow_auto_use_tiers:[`curated`]},expires_at:9007199254740991}})})},onSuccess:async()=>{b(`ok`,`Memory saved.`),N(``),j(!1),await x.invalidateQueries({queryKey:[`memory`]})},onError:e=>b(`err`,e instanceof Error?e.message:String(e))}),U=_(B.data,`items`),W=_(B.data,`results`),G=U.length?U:W,K=t(()=>G.map((e,t)=>{let n=String(e?.id||`mem-${t}`),r=String(e?.text||e?.content||e?.value||``),i=r.length>340?`${r.slice(0,340)}...`:r,a=e?.metadata||{},o=e?.linkage||{},s=String(e?.source_path||e?.sourcePath||a?.path||a?.source_path||a?.import_root||``),c=String(e?.source_type||e?.sourceType||e?.kind||e?.source||``),l=String(e?.project_tag||e?.projectTag||e?.project_id||e?.projectId||o?.project_id||a?.project_id||``),u=String(e?.visibility||a?.visibility||``),d=String(e?.run_id||e?.runId||o?.run_id||``);return{id:n,text:r,compact:i,html:m(r),sourcePath:s,sourceType:c,project:l,visibility:u,runId:d,runtime:v(e,c)}}),[G]),q=K.filter(e=>!e.runtime).length,J=K.filter(e=>e.runtime).length,Y=K.filter(e=>w===`knowledge`?!e.runtime:w===`runtime`?e.runtime:!0),X=w===`knowledge`?`No governed knowledge records found. Import docs or add memory to seed this view.`:w===`runtime`?`No runtime message records found.`:`No memory records found.`;return o(d,{className:`grid gap-4`,children:[o(f,{title:`Memory`,subtitle:`Search recent records and open full entry details inline.`,actions:o(e,{children:[o(u,{tone:`info`,children:[Y.length,` results`]}),S.trim()?o(u,{tone:`ghost`,children:[`Filter: `,S]}):o(u,{tone:`ghost`,children:w===`knowledge`?`Governed knowledge`:w===`runtime`?`Runtime messages`:`All memory`}),o(`button`,{type:`button`,className:`tcp-btn-primary`,onClick:()=>k(!0),children:[o(`i`,{"data-lucide":`database-zap`}),`Import Knowledge`]}),o(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>j(e=>!e),children:[o(`i`,{"data-lucide":`plus`}),`Add Memory`]})]}),children:[A?o(`div`,{className:`mb-3 grid gap-3 rounded-xl border border-white/10 bg-black/20 p-3`,children:[o(`textarea`,{className:`tcp-input min-h-28 resize-y`,value:M,onChange:e=>N(e.target.value),placeholder:`Store a durable note, fact, or solution capsule.`}),o(`div`,{className:`grid gap-3 md:grid-cols-[1fr_1fr_1fr_auto]`,children:[o(`select`,{className:`tcp-select`,value:P,onChange:e=>F(e.target.value),children:[o(`option`,{value:`note`,children:`note`}),o(`option`,{value:`fact`,children:`fact`}),o(`option`,{value:`solution_capsule`,children:`solution_capsule`})]}),o(`input`,{className:`tcp-input`,value:I,onChange:e=>L(e.target.value),placeholder:`project id`}),o(`select`,{className:`tcp-select`,value:R,onChange:e=>z(e.target.value),children:[o(`option`,{value:`private`,children:`private`}),o(`option`,{value:`shared`,children:`shared`})]}),o(`button`,{type:`button`,className:`tcp-btn-primary`,disabled:!M.trim()||H.isPending,onClick:()=>H.mutate(),children:[o(`i`,{"data-lucide":`save`}),`Save`]})]})]}):null,o(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[[`knowledge`,`Knowledge`,q],[`runtime`,`Runtime`,J],[`all`,`All`,K.length]].map(([e,t,n])=>o(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs ${w===e?`border-sky-500/40 bg-sky-950/20 text-sky-100`:``}`.trim(),onClick:()=>T(e),children:[t,o(`span`,{className:`tcp-badge tcp-badge-ghost ml-1`,children:n})]},String(e)))}),o(l,{className:`mb-3`,children:[o(`input`,{className:`tcp-input flex-1`,value:S,onInput:e=>C(e.target.value),placeholder:`Search memory`}),o(`button`,{className:`tcp-btn`,onClick:()=>B.refetch(),children:[o(`i`,{"data-lucide":`search`}),`Search`]})]}),o(`div`,{className:`grid gap-2`,children:Y.length?Y.map(e=>{let t=E===e.id;return o(s.article,{layout:!0,className:`tcp-list-item cursor-pointer ${t?`border-amber-500/60`:``}`,onClick:()=>D(t?null:e.id),children:[o(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[o(`strong`,{className:`truncate`,children:e.id}),o(`div`,{className:`flex items-center gap-2`,children:[o(u,{tone:t?`info`:`ghost`,children:t?`expanded`:`compact`}),o(`button`,{className:`tcp-btn-danger h-7 px-2 text-xs`,onClick:t=>{t.stopPropagation(),V.mutate(e.id)},children:[o(`i`,{"data-lucide":`trash-2`}),`Delete`]})]})]}),o(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[e.sourceType?o(u,{tone:`ghost`,children:e.sourceType}):null,e.project?o(u,{tone:`info`,children:e.project}):null,e.visibility?o(u,{tone:`ghost`,children:e.visibility}):null,e.runId?o(u,{tone:`ghost`,children:e.runId}):null]}),e.sourcePath?o(`div`,{className:`tcp-subtle mb-2 truncate text-[11px]`,children:e.sourcePath}):null,o(c,{initial:!1,mode:`wait`,children:t?o(s.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:`auto`},exit:{opacity:0,height:0},transition:{duration:.18,ease:`easeOut`},className:`overflow-hidden`,children:o(`div`,{className:`tcp-markdown tcp-markdown-ai rounded-lg border border-slate-700/60 bg-black/20 p-3 text-sm`,dangerouslySetInnerHTML:{__html:e.html}})},`expanded`):o(s.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.14,ease:`easeOut`},className:`tcp-subtle whitespace-pre-wrap text-xs`,children:e.compact||`(empty)`},`compact`)})]},e.id)}):o(p,{text:X})})]}),o(h,{open:O,client:y,initialTier:`global`,toast:b,onCancel:()=>k(!1),onSuccess:async()=>{await x.invalidateQueries({queryKey:[`memory`]})}})]})}export{y as MemoryPage};
|