modular-studio 1.0.4 → 1.0.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/README.md +101 -20
- package/dist/assets/Badge-22Ai0eyi.js +1 -0
- package/dist/assets/Input-Bgp734xs.js +1 -0
- package/dist/assets/KnowledgeTab-DABxirZh.js +4 -0
- package/dist/assets/MemoryTab-DZeYElIT.js +16 -0
- package/dist/assets/QualificationTab-Dfpy3J30.js +1 -0
- package/dist/assets/ReviewTab-SD8lQuCc.js +103 -0
- package/dist/assets/Section-DoJrmytO.js +1 -0
- package/dist/assets/TestTab-PDyMF8Fw.js +33 -0
- package/dist/assets/ToolsTab-B83qGCmG.js +1 -0
- package/dist/assets/conversationStore-CkfEU2eV.js +1 -0
- package/dist/assets/icons-C2EV-le6.js +1 -0
- package/dist/assets/index-DkpMAxX7.css +1 -0
- package/dist/assets/index-q24ug5Qs.js +143 -0
- package/dist/assets/{jszip.min-BK6ZQWkj.js → jszip.min-wf-D3Ix_.js} +1 -1
- package/dist/assets/markdown-DWF7F0i0.js +29 -0
- package/dist/assets/services-BaKotDf0.js +343 -0
- package/dist/assets/stores-CeKWz7ou.js +1 -0
- package/dist/assets/vendor-D1h_O76p.js +9 -0
- package/dist/index.html +8 -4
- package/dist-server/bin/modular-mcp.js +0 -1
- package/dist-server/bin/modular-studio.js +0 -1
- package/dist-server/server/config.js +0 -1
- package/dist-server/server/data/mcp-tokens.json +3 -3
- package/dist-server/server/index.d.ts.map +1 -1
- package/dist-server/server/index.js +2 -1
- package/dist-server/server/mcp/manager.js +0 -1
- package/dist-server/server/mcp/modular-server.js +0 -1
- package/dist-server/server/mcp/transport.js +0 -1
- package/dist-server/server/routes/agent-sdk.js +0 -1
- package/dist-server/server/routes/agents.d.ts +9 -5
- package/dist-server/server/routes/agents.d.ts.map +1 -1
- package/dist-server/server/routes/agents.js +81 -8
- package/dist-server/server/routes/auth-codex.js +0 -1
- package/dist-server/server/routes/capabilities.js +0 -1
- package/dist-server/server/routes/claude-config.js +0 -1
- package/dist-server/server/routes/connectors.d.ts.map +1 -1
- package/dist-server/server/routes/connectors.js +194 -1
- package/dist-server/server/routes/conversations.js +0 -1
- package/dist-server/server/routes/embeddings.js +0 -1
- package/dist-server/server/routes/health.js +0 -1
- package/dist-server/server/routes/knowledge.js +0 -1
- package/dist-server/server/routes/llm.js +0 -1
- package/dist-server/server/routes/mcp-oauth.js +0 -1
- package/dist-server/server/routes/mcp.js +0 -1
- package/dist-server/server/routes/memory.d.ts +3 -0
- package/dist-server/server/routes/memory.d.ts.map +1 -0
- package/dist-server/server/routes/memory.js +283 -0
- package/dist-server/server/routes/pipeline.js +0 -1
- package/dist-server/server/routes/providers.js +0 -1
- package/dist-server/server/routes/qualification.d.ts.map +1 -1
- package/dist-server/server/routes/qualification.js +382 -74
- package/dist-server/server/routes/repo-index.js +0 -1
- package/dist-server/server/routes/runtime.js +0 -1
- package/dist-server/server/routes/skills-search.d.ts.map +1 -1
- package/dist-server/server/routes/skills-search.js +39 -5
- package/dist-server/server/routes/worktrees.js +0 -1
- package/dist-server/server/services/__tests__/embeddingService.test.js +0 -1
- package/dist-server/server/services/adapters/postgresAdapter.d.ts +29 -0
- package/dist-server/server/services/adapters/postgresAdapter.d.ts.map +1 -0
- package/dist-server/server/services/adapters/postgresAdapter.js +224 -0
- package/dist-server/server/services/adapters/sqliteAdapter.d.ts +28 -0
- package/dist-server/server/services/adapters/sqliteAdapter.d.ts.map +1 -0
- package/dist-server/server/services/adapters/sqliteAdapter.js +219 -0
- package/dist-server/server/services/adapters/storageAdapter.d.ts +22 -0
- package/dist-server/server/services/adapters/storageAdapter.d.ts.map +1 -0
- package/dist-server/server/services/adapters/storageAdapter.js +1 -0
- package/dist-server/server/services/agentRunner.js +0 -1
- package/dist-server/server/services/agentStore.d.ts +18 -3
- package/dist-server/server/services/agentStore.d.ts.map +1 -1
- package/dist-server/server/services/agentStore.js +116 -23
- package/dist-server/server/services/contentStore.js +0 -1
- package/dist-server/server/services/embeddingService.d.ts +2 -0
- package/dist-server/server/services/embeddingService.d.ts.map +1 -1
- package/dist-server/server/services/embeddingService.js +30 -19
- package/dist-server/server/services/factExtractor.js +0 -1
- package/dist-server/server/services/githubIndexer.js +0 -1
- package/dist-server/server/services/mcpOAuth.js +0 -1
- package/dist-server/server/services/memoryScorer.js +0 -1
- package/dist-server/server/services/repoIndexer.js +0 -1
- package/dist-server/server/services/sqliteStore.js +0 -1
- package/dist-server/server/services/teamRunner.js +0 -1
- package/dist-server/server/services/worktreeManager.js +0 -1
- package/dist-server/server/types.d.ts +5 -0
- package/dist-server/server/types.d.ts.map +1 -1
- package/dist-server/server/types.js +0 -1
- package/dist-server/server/utils/pathSecurity.js +0 -1
- package/dist-server/src/services/budgetAllocator.js +0 -1
- package/dist-server/src/services/contradictionDetector.js +0 -1
- package/dist-server/src/services/treeIndexer.js +0 -1
- package/dist-server/src/store/knowledgeBase.d.ts +10 -0
- package/dist-server/src/store/knowledgeBase.d.ts.map +1 -1
- package/dist-server/src/store/knowledgeBase.js +13 -1
- package/dist-server/src/store/memoryStore.d.ts +107 -0
- package/dist-server/src/store/memoryStore.d.ts.map +1 -0
- package/dist-server/src/store/memoryStore.js +263 -0
- package/dist-server/tsconfig.server.tsbuildinfo +1 -1
- package/package.json +104 -97
- package/dist/assets/graphPopulator-B3rQxb5A.js +0 -1
- package/dist/assets/index-BA_J-aHx.js +0 -686
- package/dist/assets/index-C7vpqKVZ.css +0 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Modular Studio
|
|
2
2
|
|
|
3
|
-
**The context engineering IDE for AI agents
|
|
3
|
+
**The context engineering IDE for AI agents.**
|
|
4
4
|
|
|
5
|
-
Build
|
|
5
|
+
Build AI agents that truly understand your codebase, documentation, and tools — through intelligent knowledge pipelines, not just prompts.
|
|
6
6
|
|
|
7
7
|
## Quick Start
|
|
8
8
|
|
|
@@ -10,32 +10,113 @@ Build knowledge pipelines, not just prompts. Design AI systems that understand y
|
|
|
10
10
|
npx modular-studio
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Opens at [localhost:4800](http://localhost:4800).
|
|
14
14
|
|
|
15
|
-
##
|
|
15
|
+
## What It Does
|
|
16
|
+
|
|
17
|
+
Modular Studio is a visual IDE for designing AI agent systems. You describe what you want → it generates a complete agent configuration with persona, constraints, objectives, workflow, and tool selection — all grounded in your actual knowledge sources.
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
- **🔌 150+ MCP Connectors** — Integrate with any system or service
|
|
19
|
-
- **⚡ Built-in Tools** — GitHub indexing, file management, embeddings out of the box
|
|
20
|
-
- **📊 Pipeline Visibility** — See exactly how context flows through your system
|
|
21
|
-
- **🤖 Multi-Agent** — Coordinate multiple AI agents with shared knowledge
|
|
22
|
-
- **📤 Export Anywhere** — Generate prompts for Claude, ChatGPT, or any LLM
|
|
19
|
+
### The Workflow
|
|
23
20
|
|
|
24
|
-
|
|
21
|
+
1. **Describe** — Write what your agent should do (or pick a template)
|
|
22
|
+
2. **Generate** — AI creates a full agent config from your description via meta-prompt
|
|
23
|
+
3. **Knowledge** — Connect repos, files, connectors. See what's missing.
|
|
24
|
+
4. **Tools** — Pick MCP servers and skills from 150+ integrations
|
|
25
|
+
5. **Memory** — Configure conversation memory strategy
|
|
26
|
+
6. **Review** — Inspect and refine: persona, constraints, objectives, workflow
|
|
27
|
+
7. **Test** — Chat with your agent, see the full pipeline trace
|
|
28
|
+
8. **Qualify** — Run structured evaluations against test cases
|
|
29
|
+
9. **Export** — Output for Claude Code, OpenClaw, Codex, Amp, or generic JSON
|
|
25
30
|
|
|
26
|
-
|
|
31
|
+
### What Makes It Different
|
|
32
|
+
|
|
33
|
+
| | **Prompt Engineering** | **RAG Tools** | **Modular Studio** |
|
|
27
34
|
|---|---|---|---|
|
|
28
|
-
| **
|
|
29
|
-
| **Knowledge
|
|
30
|
-
| **
|
|
31
|
-
| **
|
|
32
|
-
| **
|
|
35
|
+
| **Starting point** | Manual writing | Upload docs | Describe in natural language |
|
|
36
|
+
| **Knowledge** | Copy-paste | Chunk embeddings | Tree-aware semantic retrieval |
|
|
37
|
+
| **Visibility** | None | Similarity scores | Full pipeline observability |
|
|
38
|
+
| **Output** | One prompt | API endpoint | Multi-target agent definitions |
|
|
39
|
+
| **Iteration** | Rewrite | Re-embed | Visual refinement + qualification |
|
|
40
|
+
|
|
41
|
+
## Key Features
|
|
42
|
+
|
|
43
|
+
- **🧠 Meta-Prompt Generation** — Describe your agent, get a complete configuration
|
|
44
|
+
- **🌳 Tree-Aware Retrieval** — Knowledge pipeline understands document and code structure
|
|
45
|
+
- **📊 Pipeline Observability** — See exactly how context flows: source assembly → retrieval → provenance
|
|
46
|
+
- **🔌 150+ MCP Connectors** — GitHub, Notion, Slack, HubSpot, and more
|
|
47
|
+
- **🏗️ Agent Library** — Save, version, and manage multiple agents
|
|
48
|
+
- **📋 Structured Review** — Identity, persona, constraints, objectives, workflow — all editable
|
|
49
|
+
- **🧪 Built-in Testing** — Chat with your agent, run teams, trace every step
|
|
50
|
+
- **📤 Multi-Target Export** — Claude Code (.md), OpenClaw (.yaml), Codex (.json), Amp, generic
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
### From npm
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# Run directly
|
|
58
|
+
npx modular-studio
|
|
59
|
+
|
|
60
|
+
# Or install globally
|
|
61
|
+
npm install -g modular-studio
|
|
62
|
+
modular-studio --open
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### From Source
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
git clone https://github.com/VictorGjn/modular-patchbay.git
|
|
69
|
+
cd modular-patchbay
|
|
70
|
+
npm install --legacy-peer-deps
|
|
71
|
+
npm run dev
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Frontend: `http://localhost:5173` · Backend: `http://localhost:4800`
|
|
75
|
+
|
|
76
|
+
## Configuration
|
|
77
|
+
|
|
78
|
+
### Providers
|
|
79
|
+
|
|
80
|
+
Connect at least one LLM provider in **Settings → Providers**:
|
|
81
|
+
|
|
82
|
+
- **Claude Agent SDK** — Zero-config if running inside Claude Code
|
|
83
|
+
- **Anthropic** — API key required
|
|
84
|
+
- **OpenAI** — API key required
|
|
85
|
+
- **OpenRouter** — API key for aggregated model access
|
|
86
|
+
- **Google** — API key for Gemini models
|
|
87
|
+
|
|
88
|
+
### Knowledge Sources
|
|
89
|
+
|
|
90
|
+
- **Local Files** — Drag and drop markdown, code, or documents
|
|
91
|
+
- **Git Repos** — Clone and index any GitHub repository
|
|
92
|
+
- **Connectors** — Notion, Slack, HubSpot via MCP
|
|
33
93
|
|
|
34
94
|
## Requirements
|
|
35
95
|
|
|
36
|
-
- **Node 18+**
|
|
37
|
-
- **API Key** (Anthropic, OpenAI, or compatible)
|
|
96
|
+
- **Node.js 18+**
|
|
97
|
+
- **LLM API Key** (Anthropic, OpenAI, or compatible provider)
|
|
98
|
+
|
|
99
|
+
## Architecture
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
src/
|
|
103
|
+
├── tabs/ # Wizard tab components (Describe, Knowledge, Tools, etc.)
|
|
104
|
+
├── panels/ # Sub-panels (AgentBuilder, review sections, pipeline)
|
|
105
|
+
├── components/ # Shared components (AgentLibrary, Topbar, InlineTraceView)
|
|
106
|
+
├── services/ # Pipeline services (treeIndexer, compress, contextAssembler)
|
|
107
|
+
├── store/ # Zustand stores (console, trace, conversation, memory)
|
|
108
|
+
├── utils/ # Agent generation, export, analysis utilities
|
|
109
|
+
└── layouts/ # WizardLayout, DashboardLayout
|
|
110
|
+
server/
|
|
111
|
+
├── routes/ # API routes (agents, providers, conversations)
|
|
112
|
+
└── services/ # Backend services (agentStore, embeddings)
|
|
113
|
+
```
|
|
38
114
|
|
|
39
115
|
## License
|
|
40
116
|
|
|
41
|
-
Apache 2.0 — Free for commercial and open source use.
|
|
117
|
+
Apache 2.0 — Free for commercial and open source use.
|
|
118
|
+
|
|
119
|
+
## Links
|
|
120
|
+
|
|
121
|
+
- **npm**: [modular-studio](https://www.npmjs.com/package/modular-studio)
|
|
122
|
+
- **GitHub**: [VictorGjn/modular-patchbay](https://github.com/VictorGjn/modular-patchbay)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as o}from"./vendor-D1h_O76p.js";import{u}from"./index-q24ug5Qs.js";function d({variant:r="neutral",children:e,dot:a,size:n="sm"}){const s=u(),t={success:{bg:s.statusSuccessBg,fg:s.statusSuccess},warning:{bg:s.statusWarningBg,fg:s.statusWarning},error:{bg:s.statusErrorBg,fg:s.statusError},info:{bg:"#3498db15",fg:"#3498db"},neutral:{bg:s.badgeBg,fg:s.textSecondary}}[r],g=n==="sm"?8:9,c=n==="sm"?"1px 6px":"2px 8px";return o.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full font-semibold uppercase tracking-wider",style:{background:t.bg,color:t.fg,fontSize:g,padding:c,fontFamily:"'Geist Mono', monospace"},children:[a&&o.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:t.fg}}),e]})}export{d as B};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as l,j as t}from"./vendor-D1h_O76p.js";import{u as c}from"./index-q24ug5Qs.js";const d=l.forwardRef(function({label:o,error:e,className:r="",style:n,...a},i){const s=c();return t.jsxs("div",{className:"flex flex-col gap-1",children:[o&&t.jsx("label",{className:"text-[13px] tracking-wider uppercase font-semibold",style:{color:s.textMuted,fontFamily:"'Geist Mono', monospace"},children:o}),t.jsx("input",{ref:i,className:`w-full px-3 py-2 rounded-md outline-none nodrag ${r}`,style:{background:s.inputBg,border:`1px solid ${e?s.statusError:s.border}`,color:s.textPrimary,fontFamily:"'Geist Sans', sans-serif",fontSize:16,lineHeight:1.5,...n},...a}),e&&t.jsx("span",{className:"text-[13px]",style:{color:s.statusError},children:e})]})});export{d as I};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{j as e,r as l}from"./vendor-D1h_O76p.js";import{u as K,b as L}from"./index-q24ug5Qs.js";import{u as M,x as A,K as H,G as V,H as Y,I as ee,A as z}from"./services-BaKotDf0.js";import{a as oe,C as ae,a0 as le,av as J,Q as E,X as te,i as ie,aC as X,aD as _,aE as se,ak as ne,Z as re,aF as Z,$ as ce,a6 as Q,_ as de,D as W,S as pe,a7 as xe,aG as ue}from"./icons-C2EV-le6.js";import"./stores-CeKWz7ou.js";function me({node:t}){const i=K();return e.jsx("div",{className:"pl-4 py-0.5 text-[11px] truncate",style:{color:i.textFaint,fontFamily:"'Geist Mono', monospace"},title:t.meta?.firstSentence??t.title,children:t.title})}function fe({node:t}){const i=K(),[k,w]=l.useState(!1);return e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>w(S=>!S),className:"flex items-center gap-1.5 w-full py-0.5 hover:opacity-80 transition-opacity",style:{color:i.textDim,fontFamily:"'Geist Mono', monospace",fontSize:"11px"},children:[k?e.jsx(oe,{size:9}):e.jsx(ae,{size:9}),e.jsx("span",{className:"flex-1 text-left",children:t.title}),e.jsxs("span",{style:{color:i.textFaint},children:["(",t.children.length,")"]})]}),k&&t.children.map(S=>e.jsx(me,{node:S},S.nodeId))]})}function ye({index:t}){const i=K(),k=t.root.children.filter(w=>w.children.length>0);return k.length===0?null:e.jsx("div",{className:"mt-2 pt-2 space-y-0.5",style:{borderTop:`1px solid ${i.borderSubtle}`},children:k.map(w=>e.jsx(fe,{node:w},w.nodeId))})}function q(t){return t>=100?"Full":t>=75?"Detail":t>=50?"Summary":t>=25?"Headlines":"Mention"}function he(t){return t>=100?"Full (100%) — Complete document, every line included. Best for specs, schemas, and ground-truth sources.":t>=75?"Detail (75%) — Main content with details; minor boilerplate trimmed. Good default for most sources.":t>=50?"Summary (50%) — Key points and structure; verbose sections condensed. Good for large reports.":t>=25?"Headlines (25%) — Section titles and key statements only. Good for broad awareness context.":"Mention (10%) — Brief reference only; title and top-level summary. Good for background context."}function be(){const t=K(),i=M(s=>s.channels),k=l.useMemo(()=>i.filter(s=>s.path&&!s.path.includes(".git")&&!s.contentSourceId),[i]),w=M(s=>s.setChannelDepth),S=M(s=>s.setChannelKnowledgeType),C=M(s=>s.removeChannel),y=M(s=>s.setShowFilePicker),m=A(s=>s.indexes),d=A(s=>s.loading),v=A(s=>s.errors),$=L(s=>s.scanDirectory),G=L(s=>s.lastDir),o=L(s=>s.scanning),[f,c]=l.useState(!1),[j,g]=l.useState(""),[u,R]=l.useState(!1),O=l.useCallback(s=>{const r=m[s.path],h=(s.depth||100)/100;return Math.round(r?r.index.totalTokens*h:(s.baseTokens??0)*h)},[m]),B=l.useCallback(async()=>{c(!0);const s=k.filter(r=>r.enabled&&r.path).map(r=>r.path);s.length>0&&await A.getState().indexFiles(s),c(!1)},[k]),P=l.useCallback(async()=>{j.trim()&&(await $(j.trim()),g(""),R(!1))},[j,$]);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>y(!0),className:"flex items-center justify-center gap-1.5 flex-1 px-2.5 py-2 rounded text-[12px] tracking-wide uppercase cursor-pointer transition-colors",style:{background:"transparent",border:"1px solid",borderColor:t.border,color:t.textDim,fontFamily:"'Geist Mono', monospace",minHeight:"44px"},onMouseEnter:s=>{s.currentTarget.style.borderColor=t.isDark?"#FF6B1A":"#FE5000",s.currentTarget.style.color=t.isDark?"#FF6B1A":"#FE5000"},onMouseLeave:s=>{s.currentTarget.style.borderColor=t.border,s.currentTarget.style.color=t.textDim},children:[e.jsx(le,{size:10})," Files"]}),e.jsxs("button",{type:"button",onClick:()=>R(!u),className:"flex items-center justify-center gap-1.5 flex-1 px-2.5 py-2 rounded text-[12px] tracking-wide uppercase cursor-pointer transition-colors",style:{background:u?"#24292F15":"transparent",border:"1px solid",borderColor:u?"#24292F":t.border,color:u?"#24292F":t.textDim,fontFamily:"'Geist Mono', monospace",minHeight:"44px"},children:[e.jsx(J,{size:10})," Directory"]})]}),u&&e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("input",{type:"text",value:j,onChange:s=>g(s.target.value),placeholder:G||"/path/to/directory",className:"flex-1 px-2.5 py-1.5 rounded text-[13px] outline-none",style:{background:t.inputBg,border:`1px solid ${t.border}`,color:t.textPrimary,fontFamily:"'Geist Sans', sans-serif"},onKeyDown:s=>s.key==="Enter"&&P()}),e.jsx("button",{type:"button",onClick:P,disabled:o||!j.trim(),className:"px-3 py-1.5 rounded text-[12px] font-semibold uppercase tracking-wide transition-opacity",style:{background:"#24292F",color:"#fff",opacity:o||!j.trim()?.5:1,fontFamily:"'Geist Mono', monospace"},children:o?e.jsx(E,{size:10,className:"animate-spin"}):"Scan"})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button",onClick:B,disabled:f||k.filter(s=>s.enabled).length===0,className:"flex items-center gap-2 px-4 py-2.5 rounded text-[13px] font-semibold transition-all duration-200",style:{background:f?"#f1c40f":"#2ecc71",color:"#fff",opacity:k.filter(s=>s.enabled).length===0?.5:1,fontFamily:"'Geist Sans', sans-serif",cursor:f||k.filter(s=>s.enabled).length===0?"not-allowed":"pointer",minWidth:"120px"},children:f?e.jsxs(e.Fragment,{children:[e.jsx(E,{size:14,className:"animate-spin"}),"Indexing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(J,{size:14}),"Index Files"]})})}),e.jsx("div",{className:"space-y-3",children:k.map(s=>{const r=s.depth||100,h=H[s.knowledgeType],I=!!m[s.path],F=!!d[s.path],n=!!v[s.path],a=O(s);return e.jsxs("div",{className:"p-3 rounded border",style:{borderColor:s.enabled?t.border:t.borderSubtle,background:s.enabled?t.isDark?"#ffffff05":"#00000005":t.isDark?"#ffffff02":"#00000002"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"flex-1 text-[13px] font-medium truncate",style:{color:s.enabled?t.textPrimary:t.textDim},title:s.path,children:s.name}),e.jsxs("button",{type:"button",onClick:()=>{const p=Object.keys(H),N=p.indexOf(s.knowledgeType);S(s.sourceId,(N+1)%p.length)},title:`${h.label}: ${h.instruction}
|
|
2
|
+
Click to change type`,className:"flex items-center gap-1.5 px-2 py-0.5 rounded transition-opacity hover:opacity-75",style:{background:`${h.color}15`,border:`1px solid ${h.color}40`,cursor:"pointer"},children:[e.jsx("span",{style:{fontSize:"11px",lineHeight:1},children:h.icon}),e.jsx("span",{className:"text-[11px] font-medium",style:{color:h.color,fontFamily:"'Geist Mono', monospace"},children:h.label})]}),F&&e.jsx(E,{size:12,className:"animate-spin",style:{color:t.textDim}}),e.jsxs("span",{className:"text-[12px] px-2 py-0.5 rounded font-medium",style:{fontFamily:"'Geist Mono', monospace",color:I?t.textPrimary:t.textDim,background:I?"#2ecc7115":t.isDark?"#ffffff10":"#00000010",border:`1px solid ${I?"#2ecc7130":t.borderSubtle}`},title:I?`Indexed: ${m[s.path].index.nodeCount} nodes`:"Estimated",children:[Math.round(a/1e3),"K"]}),e.jsx("button",{type:"button",onClick:()=>C(s.sourceId),className:"p-1.5 rounded transition-colors",style:{color:t.textFaint},title:"Remove source",children:e.jsx(te,{size:12})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-[12px]",children:[e.jsx("span",{style:{color:t.textDim,fontFamily:"'Geist Mono', monospace"},children:"Depth"}),e.jsxs("span",{style:{color:"#FE5000",fontFamily:"'Geist Mono', monospace",fontWeight:600},children:[q(r)," (",r,"%)"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px]",style:{color:t.textFaint},children:"10"}),e.jsxs("div",{className:"flex-1 relative h-2 rounded overflow-hidden",style:{background:t.isDark?"#ffffff12":"#00000012"},children:[e.jsx("div",{className:"absolute left-0 top-0 h-full rounded transition-all",style:{width:`${r}%`,background:"#FE5000"}}),e.jsx("input",{type:"range",min:ee,max:Y,step:V,value:r,onChange:p=>w(s.sourceId,Number(p.target.value)),className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer","aria-label":`Depth level for ${s.name}: ${q(r)} (${r}%)`,title:he(r)})]}),e.jsx("span",{className:"text-[10px]",style:{color:t.textFaint},children:"100"})]}),e.jsxs("div",{className:"text-[11px]",style:{color:t.textFaint,fontFamily:"'Geist Mono', monospace"},children:["~",a>=1e3?`${(a/1e3).toFixed(1)}k`:a," tokens at ",q(r)," level"]})]}),n&&e.jsxs("div",{className:"mt-2 text-[11px] px-2 py-1 rounded",style:{color:"#e74c3c",background:"#e74c3c15"},children:["Error: ",v[s.path]]}),I&&m[s.path].index.sourceType==="code"&&e.jsx(ye,{index:m[s.path].index})]},s.sourceId)})}),k.length===0&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-sm",style:{color:t.textDim},children:"No local files added yet."}),e.jsx("p",{className:"text-xs mt-2",style:{color:t.textFaint},children:'Click "Files" to upload documents or "Directory" to scan a folder.'})]})]})}function U(t){return t>=100?"Full":t>=75?"Detail":t>=50?"Summary":t>=25?"Headlines":"Mention"}function ge(t){return t>=100?"Full (100%) — Complete document, every line included. Best for specs, schemas, and ground-truth sources.":t>=75?"Detail (75%) — Main content with details; minor boilerplate trimmed. Good default for most sources.":t>=50?"Summary (50%) — Key points and structure; verbose sections condensed. Good for large reports.":t>=25?"Headlines (25%) — Section titles and key statements only. Good for broad awareness context.":"Mention (10%) — Brief reference only; title and top-level summary. Good for background context."}function je(){const t=K(),i=M(s=>s.channels),k=l.useMemo(()=>i.filter(s=>s.path?.includes(".git")||s.contentSourceId),[i]),w=M(s=>s.addChannel),S=M(s=>s.removeChannel),C=M(s=>s.setChannelDepth),y=M(s=>s.setChannelKnowledgeType),m=A(s=>s.indexes),[d,v]=l.useState(""),[$,G]=l.useState("main"),[o,f]=l.useState(""),[c,j]=l.useState(!1),[g,u]=l.useState(!1),R=l.useCallback(s=>{const r=m[s.path],h=(s.depth||100)/100;return Math.round(r?r.index.totalTokens*h:(s.baseTokens??0)*h)},[m]),O=l.useCallback(async()=>{if(!(!d.trim()||c)){j(!0);try{const s=d.trim(),r=/github\.com\//i.test(s)||s.endsWith(".git"),h=r?`${z}/repo/index-github`:`${z}/repo/index`,I=r?{url:s,persist:!0,...$!=="main"&&{branch:$},...o&&{token:o}}:{path:s},n=await(await fetch(h,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)})).json();if(n.status==="ok"&&n.data){const a=n.data.totalTokens??n.data.scan?.totalTokens??5e3,p=n.data.scan,N=Array.isArray(p?.stack)?p.stack:p?.stack&&typeof p.stack=="object"?Object.values(p.stack).filter(b=>typeof b=="string"&&b!=="unknown"&&b!=="none"):[];for(const b of n.data.files){const D=`${n.data.outputDir}/${b}`,x=b.includes("overview");w({sourceId:`repo-${b}-${Date.now()}`,name:b.replace(".compressed.md","").replace(".md","").replace(/^\d+-/,""),path:D,category:"knowledge",knowledgeType:"ground-truth",depth:r?50:70,baseTokens:Math.round(a/Math.max(n.data.files.length,1)),...x&&n.data.overviewMarkdown?{content:n.data.overviewMarkdown}:{},...x&&p?{repoMeta:{name:n.data.name??"",stack:N,totalFiles:p.totalFiles??0,baseUrl:p.baseUrl,features:(p.features??[]).map(T=>T.name)}}:{},...n.data.contentSourceId?{contentSourceId:n.data.contentSourceId}:{}})}await A.getState().indexFiles(n.data.files.map(b=>`${n.data.outputDir}/${b}`)),v(""),G("main"),f(""),u(!1)}}catch{}finally{j(!1)}}},[d,$,o,c,w]),B=l.useCallback(async(s,r)=>{await A.getState().indexFiles(r.map(h=>`${s}/${h}`))},[]),P=/github\.com\//i.test(d)||d.endsWith(".git");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:d,onChange:s=>v(s.target.value),placeholder:"https://github.com/user/repo or /path/to/local/repo",className:"flex-1 px-3 py-2 rounded text-[13px] outline-none",style:{background:t.inputBg,border:`1px solid ${t.border}`,color:t.textPrimary,fontFamily:"'Geist Sans', sans-serif"},onKeyDown:s=>s.key==="Enter"&&!c&&d.trim()&&O()}),e.jsx("button",{type:"button",onClick:()=>u(!g),className:"px-3 py-2 rounded text-[12px] tracking-wide uppercase transition-colors",style:{background:g?t.isDark?"#ffffff15":"#00000015":"transparent",border:`1px solid ${t.border}`,color:t.textDim,fontFamily:"'Geist Mono', monospace"},children:g?"Basic":"Advanced"})]}),g&&e.jsxs("div",{className:"space-y-2 p-3 rounded",style:{background:t.isDark?"#ffffff08":"#00000008"},children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(ie,{size:14,style:{color:t.textDim}}),e.jsx("input",{type:"text",value:$,onChange:s=>G(s.target.value),placeholder:"Branch name",className:"flex-1 px-2 py-1 rounded text-[12px] outline-none",style:{background:t.inputBg,border:`1px solid ${t.border}`,color:t.textPrimary,fontFamily:"'Geist Mono', monospace"}})]}),P&&e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(X,{size:14,style:{color:t.textDim}}),e.jsx("input",{type:"password",value:o,onChange:s=>f(s.target.value),placeholder:"GitHub token (optional, for private repos)",className:"flex-1 px-2 py-1 rounded text-[12px] outline-none",style:{background:t.inputBg,border:`1px solid ${t.border}`,color:t.textPrimary,fontFamily:"'Geist Mono', monospace"}})]})]}),e.jsx("button",{type:"button",onClick:O,disabled:c||!d.trim(),className:"w-full py-2.5 rounded text-[13px] font-semibold tracking-wide transition-opacity flex items-center justify-center gap-2",style:{background:"#24292F",color:"#fff",opacity:c||!d.trim()?.5:1,fontFamily:"'Geist Sans', sans-serif",cursor:c||!d.trim()?"not-allowed":"pointer"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(E,{size:14,className:"animate-spin"}),P?"Cloning & Indexing...":"Indexing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(_,{size:14}),P?"Clone & Index":"Index Repository"]})})]}),e.jsx("div",{className:"space-y-3",children:k.map(s=>{const r=s.depth||100,h=H[s.knowledgeType],I=R(s),F=s.repoMeta,n=!!m[s.path];return e.jsxs("div",{className:"p-3 rounded border",style:{borderColor:s.enabled?t.border:t.borderSubtle,background:s.enabled?t.isDark?"#ffffff05":"#00000005":t.isDark?"#ffffff02":"#00000002"},children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(X,{size:14,style:{color:t.textDim}}),e.jsx("span",{className:"font-medium text-[14px] truncate",style:{color:t.textPrimary},children:F?.name||s.name}),s.path?.includes(".compressed.md")&&e.jsx("span",{className:"text-[10px] px-1 py-0.5 rounded",style:{background:"#00A86B20",color:"#00A86B",fontFamily:"'Geist Mono', monospace"},children:"COMPRESSED"})]}),F?.stack&&F.stack.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 mb-2",children:[F.stack.slice(0,4).map((a,p)=>e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:t.isDark?"#ffffff15":"#00000015",color:t.textDim,fontFamily:"'Geist Mono', monospace"},children:a},p)),F.stack.length>4&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{color:t.textFaint},children:["+",F.stack.length-4]})]}),e.jsxs("button",{type:"button",onClick:()=>{const a=Object.keys(H),p=a.indexOf(s.knowledgeType);y(s.sourceId,(p+1)%a.length)},title:`${h.label}: ${h.instruction}
|
|
3
|
+
Click to change type`,className:"flex items-center gap-1.5 px-2 py-0.5 rounded transition-opacity hover:opacity-75 w-fit",style:{background:`${h.color}15`,border:`1px solid ${h.color}40`,cursor:"pointer"},children:[e.jsx("span",{style:{fontSize:"11px",lineHeight:1},children:h.icon}),e.jsx("span",{className:"text-[11px] font-medium",style:{color:h.color,fontFamily:"'Geist Mono', monospace"},children:h.label})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsxs("span",{className:"text-[12px] px-2 py-1 rounded font-medium",style:{fontFamily:"'Geist Mono', monospace",color:n?t.textPrimary:t.textDim,background:n?"#2ecc7115":t.isDark?"#ffffff10":"#00000010",border:`1px solid ${n?"#2ecc7130":t.borderSubtle}`},children:[Math.round(I/1e3),"K"]}),e.jsx("button",{type:"button",onClick:()=>B(s.path?.split("/").slice(0,-1).join("/")||"",[s.path?.split("/").pop()||""]),className:"p-1.5 rounded transition-colors",style:{color:t.textDim},title:"Re-index",children:e.jsx(se,{size:12})}),e.jsx("button",{type:"button",onClick:()=>S(s.sourceId),className:"p-1.5 rounded transition-colors",style:{color:t.textFaint},title:"Remove",children:e.jsx(te,{size:12})})]})]}),e.jsxs("div",{className:"space-y-1 mb-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-[12px]",children:[e.jsx("span",{style:{color:t.textDim,fontFamily:"'Geist Mono', monospace"},children:"Depth"}),e.jsxs("span",{style:{color:"#FE5000",fontFamily:"'Geist Mono', monospace",fontWeight:600},children:[U(r)," (",r,"%)"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px]",style:{color:t.textFaint},children:"10"}),e.jsxs("div",{className:"flex-1 relative h-2 rounded overflow-hidden",style:{background:t.isDark?"#ffffff12":"#00000012"},children:[e.jsx("div",{className:"absolute left-0 top-0 h-full rounded transition-all",style:{width:`${r}%`,background:"#FE5000"}}),e.jsx("input",{type:"range",min:ee,max:Y,step:V,value:r,onChange:a=>C(s.sourceId,Number(a.target.value)),className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer","aria-label":`Depth level for ${s.name}: ${U(r)} (${r}%)`,title:ge(r)})]}),e.jsx("span",{className:"text-[10px]",style:{color:t.textFaint},children:"100"})]}),e.jsxs("div",{className:"text-[11px]",style:{color:t.textFaint,fontFamily:"'Geist Mono', monospace"},children:["~",I>=1e3?`${(I/1e3).toFixed(1)}k`:I," tokens at ",U(r)," level"]})]}),F&&e.jsxs("div",{className:"flex items-center gap-4 text-[11px]",style:{color:t.textDim},children:[F.totalFiles>0&&e.jsx("div",{className:"flex items-center gap-1",children:e.jsxs("span",{children:[F.totalFiles," files"]})}),F.features&&F.features.length>0&&e.jsx("div",{className:"flex items-center gap-1",children:e.jsxs("span",{children:[F.features.length," features"]})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ne,{size:10}),e.jsx("span",{children:"Indexed recently"})]})]})]},s.sourceId)})}),k.length===0&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx(_,{size:32,style:{color:t.textFaint,margin:"0 auto 12px"}}),e.jsx("p",{className:"text-sm mb-2",style:{color:t.textDim},children:"No repositories indexed yet."}),e.jsx("p",{className:"text-xs",style:{color:t.textFaint},children:"Enter a GitHub URL or local repository path to get started."})]})]})}const ke=[{id:"notion",name:"Notion",icon:"📄",description:"Import databases, pages, and workspaces",authMethod:"api-key",fields:[{key:"apiKey",label:"API Key",type:"password",placeholder:"secret_...",required:!0},{key:"databaseIds",label:"Database IDs",type:"text",placeholder:"id1,id2,id3 (comma separated)",required:!1},{key:"pageUrls",label:"Page URLs",type:"text",placeholder:"https://notion.so/... (one per line)",required:!1}]},{id:"hubspot",name:"HubSpot",icon:"🧲",description:"Sync CRM objects: contacts, deals, tickets",authMethod:"oauth",fields:[{key:"objectTypes",label:"Object Types",type:"select",placeholder:"",required:!0,options:["contacts","deals","tickets","companies"]},{key:"filters",label:"Filters",type:"text",placeholder:"property filters (optional)",required:!1}]},{id:"slack",name:"Slack",icon:"💬",description:"Import messages and channels",authMethod:"oauth",fields:[{key:"channels",label:"Channels",type:"text",placeholder:"#general,#product (comma separated)",required:!1},{key:"keywords",label:"Keywords",type:"text",placeholder:"filter by keywords",required:!1},{key:"dateRange",label:"Date Range",type:"text",placeholder:"last 30 days",required:!1}]},{id:"google-drive",name:"Google Drive",icon:"📁",description:"Access documents and folders",authMethod:"oauth",fields:[{key:"folderIds",label:"Folder IDs",type:"text",placeholder:"folder1,folder2 (comma separated)",required:!1},{key:"fileTypes",label:"File Types",type:"select",placeholder:"",required:!1,options:["docs","sheets","slides","pdf","all"]}]},{id:"github",name:"GitHub",icon:"🐙",description:"Repository issues, PRs, and discussions",authMethod:"api-key",fields:[{key:"token",label:"Personal Access Token",type:"password",placeholder:"ghp_...",required:!0},{key:"repos",label:"Repositories",type:"text",placeholder:"owner/repo1,owner/repo2",required:!0},{key:"includeIssues",label:"Include Issues",type:"select",placeholder:"",required:!1,options:["yes","no"]},{key:"includePRs",label:"Include PRs",type:"select",placeholder:"",required:!1,options:["yes","no"]}]}];function Ne(){const t=K(),[i,k]=l.useState({}),[w]=l.useState(!1),[S,C]=l.useState(null),[y,m]=l.useState({}),[d,v]=l.useState({}),[$,G]=l.useState({}),[o,f]=l.useState({}),[c,j]=l.useState({}),g=M(n=>n.addChannel),u=l.useCallback(async()=>{try{const a=await(await fetch(`${z}/connectors/auth`)).json();a.status==="ok"&&k(a.data||{})}catch{}},[]);l.useEffect(()=>{u()},[u]);const R=l.useCallback(async(n,a)=>{v({...d,[n]:!0});try{(await(await fetch(`${z}/connectors/auth/api-key`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({service:n,apiKey:a})})).json()).status==="ok"&&(await u(),C(null))}catch{}finally{v({...d,[n]:!1})}},[d,u]),O=l.useCallback(async(n,a,p)=>{v({...d,[n]:!0});try{const N=new URLSearchParams({clientId:a});p&&N.set("clientSecret",p);const D=await(await fetch(`${z}/connectors/oauth/start/${n}?${N}`)).json();if(D.status==="ok"){window.open(D.data.redirectUrl,"_blank","width=600,height=700");const x=setInterval(async()=>{await u(),i[n]?.status==="connected"&&(clearInterval(x),C(null))},2e3)}}catch{}finally{v({...d,[n]:!1})}},[d,u,i]),B=l.useCallback(async n=>{v({...d,[n]:!0});try{(await(await fetch(`${z}/connectors/auth/test/${n}`,{method:"POST"})).json()).status==="ok"&&await u()}catch{}finally{v({...d,[n]:!1})}},[d,u]),P=l.useCallback(async n=>{try{(await fetch(`${z}/connectors/auth/${n}`,{method:"DELETE"})).ok&&await u()}catch{}},[u]),s=l.useCallback(async n=>{v(a=>({...a,notion:!0}));try{const p=await(await fetch(`${z}/connectors/notion/test`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:n})})).json();p.status==="ok"?(G(N=>({...N,notion:"ok"})),f(N=>({...N,notion:""}))):(G(N=>({...N,notion:"error"})),f(N=>({...N,notion:String(p.error??"Test failed")})))}catch{G(a=>({...a,notion:"error"})),f(a=>({...a,notion:"Connection error. Check your network."}))}finally{v(a=>({...a,notion:!1}))}},[]),r=l.useCallback(async n=>{const a=y[n]??{},p=a.apiKey??"",N=a.databaseIds?a.databaseIds.split(",").map(D=>D.trim()).filter(Boolean):void 0,b=a.pageUrls?a.pageUrls.split(`
|
|
4
|
+
`).map(D=>D.trim()).filter(Boolean):void 0;j(D=>({...D,[n]:!0}));try{const x=await(await fetch(`${z}/connectors/notion/fetch`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:p,databaseIds:N,pageUrls:b})})).json();if(x.status==="ok"&&Array.isArray(x.data))for(const T of x.data)g({sourceId:`notion-${String(T.id)}`,name:String(T.title),path:`notion://${String(T.id)}`,category:"knowledge",knowledgeType:"evidence",depth:100,baseTokens:Number(T.tokens)||0,content:String(T.content)})}catch{}finally{j(D=>({...D,[n]:!1}))}},[y,g]),h=l.useCallback(async n=>{v({...d,[n]:!0}),setTimeout(()=>{v({...d,[n]:!1})},2e3)},[d]),I=n=>{switch(n){case"connected":return e.jsx(Q,{size:16,style:{color:"#2ecc71"}});case"expired":return e.jsx(xe,{size:16,style:{color:"#e74c3c"}});case"configured":return e.jsx(ne,{size:16,style:{color:"#f1c40f"}});default:return e.jsx(pe,{size:16,style:{color:t.textDim}})}},F=n=>{switch(n){case"connected":return"Connected";case"expired":return"Expired";case"configured":return"Configured";default:return"Not configured"}};return e.jsxs("div",{className:"space-y-4",children:[w&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(E,{size:20,className:"animate-spin",style:{color:t.textDim}})}),e.jsx("div",{className:"space-y-3",children:ke.map(n=>{const a=i[n.id],p=S===n.id,N=a?.status==="connected",b=d[n.id],D=n.authMethod==="oauth";return e.jsxs("div",{className:"rounded-lg border overflow-hidden",style:{borderColor:N?"#2ecc71":t.border,background:t.isDark?"#ffffff05":"#00000005",opacity:D?.6:1},children:[e.jsx("div",{className:D?"p-4":"p-4 cursor-pointer",onClick:()=>!D&&C(p?null:n.id),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl",children:n.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-[14px]",style:{color:t.textPrimary},children:n.name}),e.jsx("p",{className:"text-[12px]",style:{color:t.textDim},children:n.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[D&&e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-medium",style:{background:t.isDark?"#ffffff15":"#00000015",color:t.textDim},children:"Coming soon"}),a&&e.jsxs(e.Fragment,{children:[I(a.status),e.jsx("span",{className:"text-[12px]",style:{color:t.textDim},children:F(a.status)})]}),N&&e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{type:"button",onClick:x=>{x.stopPropagation(),B(n.id)},disabled:b,className:"p-1.5 rounded transition-colors",style:{color:t.textDim},title:"Test connection",children:e.jsx(se,{size:12,className:b?"animate-spin":""})}),e.jsx("button",{type:"button",onClick:x=>{x.stopPropagation(),h(n.id)},disabled:b,className:"p-1.5 rounded transition-colors",style:{background:"#2ecc71",color:"#fff"},title:"Sync now",children:e.jsx(re,{size:12})})]})]})]})}),p&&e.jsx("div",{className:"border-t p-4",style:{borderColor:t.border,background:t.isDark?"#ffffff08":"#00000008"},children:e.jsx("div",{className:"space-y-3",children:n.authMethod==="api-key"?e.jsxs("div",{className:"space-y-3",children:[n.fields.map(x=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-[12px] font-medium",style:{color:t.textDim},children:[x.label," ",x.required&&e.jsx("span",{style:{color:"#e74c3c"},children:"*"})]}),x.type==="select"?e.jsxs("select",{value:y[n.id]?.[x.key]||"",onChange:T=>m({...y,[n.id]:{...y[n.id],[x.key]:T.target.value}}),className:"w-full px-3 py-2 rounded text-[13px] outline-none",style:{background:t.inputBg,border:`1px solid ${t.border}`,color:t.textPrimary},children:[e.jsx("option",{value:"",children:x.placeholder}),x.options?.map(T=>e.jsx("option",{value:T,children:T},T))]}):e.jsx("input",{type:x.type,value:y[n.id]?.[x.key]||"",onChange:T=>m({...y,[n.id]:{...y[n.id],[x.key]:T.target.value}}),placeholder:x.placeholder,className:"w-full px-3 py-2 rounded text-[13px] outline-none",style:{background:t.inputBg,border:`1px solid ${t.border}`,color:t.textPrimary}})]},x.key)),e.jsxs("div",{className:"flex gap-2 pt-2 flex-wrap",children:[n.id==="notion"?e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>{const x=y[n.id]?.apiKey;x&&s(x)},disabled:b||!y[n.id]?.apiKey,className:"flex items-center gap-2 px-4 py-2 rounded text-[12px] font-medium",style:{background:"#2ecc71",color:"#fff",opacity:b||!y[n.id]?.apiKey?.5:1},children:[b?e.jsx(E,{size:12,className:"animate-spin"}):e.jsx(Z,{size:12}),"Test"]}),$[n.id]==="ok"&&e.jsxs("button",{type:"button",onClick:()=>r(n.id),disabled:c[n.id],className:"flex items-center gap-2 px-4 py-2 rounded text-[12px] font-medium",style:{background:"#3498db",color:"#fff",opacity:c[n.id]?.5:1},children:[c[n.id]?e.jsx(E,{size:12,className:"animate-spin"}):e.jsx(ce,{size:12}),"Fetch"]})]}):e.jsxs("button",{type:"button",onClick:()=>{const x=y[n.id]?.apiKey;x&&R(n.id,x)},disabled:b||!y[n.id]?.apiKey,className:"flex items-center gap-2 px-4 py-2 rounded text-[12px] font-medium",style:{background:"#2ecc71",color:"#fff",opacity:b||!y[n.id]?.apiKey?.5:1},children:[b?e.jsx(E,{size:12,className:"animate-spin"}):e.jsx(Z,{size:12}),"Connect"]}),N&&e.jsx("button",{type:"button",onClick:()=>P(n.id),className:"px-4 py-2 rounded text-[12px] font-medium",style:{background:"transparent",border:`1px solid ${t.border}`,color:t.textDim},children:"Disconnect"})]}),$[n.id]==="ok"&&n.id==="notion"&&e.jsxs("div",{className:"flex items-center gap-1 mt-2 text-[12px]",style:{color:"#2ecc71"},children:[e.jsx(Q,{size:12}),"Connection verified"]}),$[n.id]==="error"&&o[n.id]&&e.jsx("p",{className:"mt-2 text-[12px]",style:{color:"#e74c3c"},children:o[n.id]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-[12px]",style:{color:t.textDim},children:['Click "Connect with OAuth" to authorize access to your ',n.name," account."]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>O(n.id,"your-client-id"),disabled:b,className:"flex items-center gap-2 px-4 py-2 rounded text-[12px] font-medium",style:{background:"#2ecc71",color:"#fff",opacity:b?.5:1},children:[b?e.jsx(E,{size:12,className:"animate-spin"}):e.jsx(de,{size:12}),"Connect with OAuth"]}),N&&e.jsx("button",{type:"button",onClick:()=>P(n.id),className:"px-4 py-2 rounded text-[12px] font-medium",style:{background:"transparent",border:`1px solid ${t.border}`,color:t.textDim},children:"Disconnect"})]})]})})})]},n.id)})}),Object.keys(i).length===0&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx(W,{size:32,style:{color:t.textFaint,margin:"0 auto 12px"}}),e.jsx("p",{className:"text-sm mb-2",style:{color:t.textDim},children:"Connect to external services"}),e.jsx("p",{className:"text-xs",style:{color:t.textFaint},children:"Import data from Notion, HubSpot, Slack and other platforms."})]})]})}function ve({gaps:t}){const i=K(),k=M(C=>C.setShowFilePicker),S=M(C=>C.agentMeta).name!=="";return t.length===0?S?e.jsx("div",{className:"mb-6",style:{borderBottom:`1px solid ${i.isDark?"#1e1e22":"#e8e8ec"}`,borderLeft:"3px solid #2ecc71"},children:e.jsx("div",{className:"px-5 py-3",style:{background:i.isDark?"#0f1a0f":"#f0fdf0"},children:e.jsx("span",{className:"text-[12px] font-bold tracking-[0.08em] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:"#2ecc71"},children:"✅ No missing sources detected"})})}):null:e.jsxs("div",{className:"mb-6",style:{borderBottom:`1px solid ${i.isDark?"#1e1e22":"#e8e8ec"}`,borderLeft:"3px solid #e74c3c"},children:[e.jsx("div",{className:"px-5 py-3",style:{background:i.isDark?"#1a1a1e":"#fff5f5"},children:e.jsxs("span",{className:"text-[12px] font-bold tracking-[0.08em] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:"#e74c3c"},children:["⚠ ",t.length," MISSING SOURCES"]})}),e.jsx("div",{className:"px-5 pb-4 flex flex-col gap-3",children:t.map((C,y)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{style:{color:"#e74c3c",fontSize:10,marginTop:3,flexShrink:0},children:"●"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-[13px]",children:[e.jsx("span",{style:{fontWeight:700,color:i.textPrimary},children:C.name}),e.jsxs("span",{style:{color:i.textDim},children:[" (",C.type,")"]})]}),C.description&&e.jsx("div",{className:"text-[12px] mt-0.5",style:{color:i.textDim},children:C.description}),e.jsx("button",{type:"button",onClick:()=>k(!0),title:"Add missing source",className:"mt-1.5 text-[12px] px-2 py-0.5 rounded cursor-pointer border-none",style:{background:"#e74c3c15",color:"#e74c3c",fontFamily:"'Geist Mono', monospace",border:"1px solid #e74c3c30"},children:"+ Add source"})]})]},y))})]})}function Te(){const t=K(),i=M(o=>o.channels),k=M(o=>o.knowledgeGaps),w=A(o=>o.indexes),[S,C]=l.useState("local-files"),y=l.useCallback(o=>{const f=w[o.path],c=(o.depth||100)/100;return Math.round(f?f.index.totalTokens*c:(o.baseTokens??0)*c)},[w]),m=l.useMemo(()=>{const o=i.filter(g=>g.enabled),f=o.length,c=o.filter(g=>w[g.path]).length,j=o.reduce((g,u)=>g+y(u),0);return{enabledCount:f,indexedCount:c,totalTokens:j}},[i,w,y]),d=l.useMemo(()=>{const o=i.filter(g=>g.enabled&&/\.compressed\.md$/i.test(g.path||"")),f=o.reduce((g,u)=>g+(u.baseTokens||0),0),c=o.reduce((g,u)=>g+y(u),0),j=f>0?Math.max(0,(f-c)/f*100):0;return{githubCompressedChannels:o,githubRawTokens:f,githubEffectiveTokens:c,githubSavingsPct:j}},[i,y]),v=o=>o>=1e3?`${(o/1e3).toFixed(0)}K`:`${o}`,$=l.useMemo(()=>[{id:"local-files",label:"Local Files",icon:ue,count:i.filter(o=>o.path&&!o.path.includes(".git")&&!o.contentSourceId).length},{id:"git-repos",label:"Git Repos",icon:_,count:i.filter(o=>o.path?.includes(".git")||o.contentSourceId).length},{id:"connectors",label:"Connectors",icon:W,count:0}],[i]),G=l.useMemo(()=>Object.entries(H).map(([o,f])=>{const j=i.filter(u=>u.enabled&&u.knowledgeType===o).reduce((u,R)=>u+y(R),0),g=m.totalTokens>0?j/m.totalTokens*100:0;return{key:o,kt:f,typeTokens:j,pct:g}}).filter(o=>o.typeTokens>0),[i,m.totalTokens,y]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-semibold mb-2 m-0",style:{color:t.textPrimary,fontFamily:"'Geist Sans', sans-serif"},children:"Knowledge Sources"}),e.jsx("p",{className:"text-sm",style:{color:t.textSecondary,lineHeight:1.5},children:"Configure the knowledge sources your agent will use. Different knowledge types serve different purposes in your agent's reasoning process."})]}),e.jsx(ve,{gaps:k}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[60%_40%] gap-6",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex gap-1 p-1 rounded",style:{background:t.isDark?"#ffffff08":"#00000008"},children:$.map(o=>{const f=o.icon,c=S===o.id;return e.jsxs("button",{type:"button",onClick:()=>C(o.id),title:o.id==="local-files"?"Add local files":o.id==="git-repos"?"Add git repositories":"Add API connectors",className:"flex items-center justify-center gap-2 flex-1 px-3 py-2.5 rounded text-[12px] font-medium tracking-wide uppercase transition-all duration-200",style:{background:c?t.isDark?"#ffffff15":"#ffffff":"transparent",border:c?`1px solid ${t.border}`:"1px solid transparent",color:c?t.textPrimary:t.textDim,fontFamily:"'Geist Mono', monospace",boxShadow:c?t.isDark?"0 1px 3px rgba(255,255,255,0.1)":"0 1px 3px rgba(0,0,0,0.1)":"none"},onMouseEnter:j=>{c||(j.currentTarget.style.background=t.isDark?"#ffffff08":"#00000008")},onMouseLeave:j=>{c||(j.currentTarget.style.background="transparent")},children:[e.jsx(f,{size:14}),e.jsx("span",{children:o.label}),o.count>0&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-semibold",style:{background:c?t.isDark?"#ffffff25":"#00000025":t.isDark?"#ffffff20":"#00000020",fontFamily:"'Geist Mono', monospace"},children:o.count})]},o.id)})}),e.jsxs("div",{style:{minHeight:"400px"},children:[S==="local-files"&&e.jsx(be,{}),S==="git-repos"&&e.jsx(je,{}),S==="connectors"&&e.jsx(Ne,{})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-2",style:{color:t.textPrimary,fontFamily:"'Geist Sans', sans-serif"},children:"Knowledge Map"}),e.jsxs("div",{className:"flex items-center gap-4 text-[13px]",style:{color:t.textDim},children:[e.jsxs("span",{children:[m.enabledCount," sources"]}),e.jsxs("span",{children:[v(m.totalTokens)," tokens"]}),m.indexedCount<m.enabledCount&&e.jsxs("span",{style:{color:"#f1c40f"},children:[m.enabledCount-m.indexedCount," pending index"]})]})]}),i.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"text-[13px] font-medium tracking-wide uppercase",style:{color:t.textSecondary,fontFamily:"'Geist Mono', monospace"},children:"Type Distribution"}),G.map(({key:o,kt:f,pct:c})=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-[12px]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{style:{width:8,height:8,borderRadius:1,background:f.color}}),e.jsx("span",{style:{color:t.textPrimary,fontFamily:"'Geist Sans', sans-serif"},children:f.label})]}),e.jsxs("span",{style:{color:t.textDim,fontFamily:"'Geist Mono', monospace"},children:[c.toFixed(0),"%"]})]}),e.jsx("div",{className:"h-2 rounded overflow-hidden",style:{background:t.isDark?"#ffffff12":"#00000012"},children:e.jsx("div",{className:"h-full transition-all duration-300",style:{width:`${c}%`,background:f.color,borderRadius:2}})})]},o))]}),m.totalTokens>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"text-[13px] font-medium tracking-wide uppercase",style:{color:t.textSecondary,fontFamily:"'Geist Mono', monospace"},children:"Token Budget"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-[12px]",children:[e.jsx("span",{style:{color:t.textDim},children:"Used"}),e.jsxs("span",{style:{color:t.textPrimary,fontFamily:"'Geist Mono', monospace"},children:[v(m.totalTokens)," / 200K"]})]}),e.jsx("div",{className:"h-3 rounded overflow-hidden",style:{background:t.isDark?"#ffffff12":"#00000012"},children:e.jsx("div",{className:"h-full transition-all duration-300",style:{width:`${Math.min(100,m.totalTokens/2e5*100)}%`,background:m.totalTokens>16e4?"#e74c3c":m.totalTokens>12e4?"#f1c40f":"#2ecc71",borderRadius:2}})}),e.jsxs("div",{className:"text-[11px]",style:{color:t.textFaint},children:[(m.totalTokens/2e5*100).toFixed(1),"% of budget used"]})]})]}),d.githubCompressedChannels.length>0&&e.jsxs("div",{className:"px-3 py-2.5 rounded",style:{border:`1px solid ${t.borderSubtle}`,background:t.isDark?"#ffffff08":"#00000008"},children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[12px] tracking-wide uppercase",style:{fontFamily:"'Geist Mono', monospace",color:t.textSecondary},children:"GitHub Compression"}),e.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"#00A86B"},children:["-",d.githubSavingsPct.toFixed(1),"%"]})]}),e.jsxs("div",{className:"mt-1 text-[11px]",style:{color:t.textDim},children:["Raw ",v(d.githubRawTokens)," → Effective ",v(d.githubEffectiveTokens)," tokens"]})]}),i.length===0&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx(W,{size:32,style:{color:t.textFaint,margin:"0 auto 12px"}}),e.jsx("p",{className:"text-sm mb-2",style:{color:t.textDim},children:"No knowledge sources yet"}),e.jsx("p",{className:"text-xs",style:{color:t.textFaint},children:"Add files, repositories, or connect to external services to start building your knowledge base."})]})]})]})]})}export{Te as KnowledgeTab};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{j as s,r as i}from"./vendor-D1h_O76p.js";import{u as Q,S as x}from"./index-q24ug5Qs.js";import{u as ce,e as de,j as me,k as ue,l as m}from"./services-BaKotDf0.js";import{I as q}from"./Input-Bgp734xs.js";import{S as C,T as E}from"./Section-DoJrmytO.js";import{Q as ge,s as pe,B as N,X as be,a0 as xe,aK as he,a6 as fe,a7 as ye,au as ve,D as je}from"./icons-C2EV-le6.js";import"./stores-CeKWz7ou.js";function Se(){const t=ce.getState(),o=[];t.agentMeta.name&&o.push(`Agent: ${t.agentMeta.name}`),t.agentMeta.description&&o.push(`Description: ${t.agentMeta.description}`),t.instructionState.persona&&o.push(`Persona: ${t.instructionState.persona}`),t.instructionState.objectives.primary&&o.push(`Primary objective: ${t.instructionState.objectives.primary}`),t.instructionState.constraints.scopeDefinition&&o.push(`Scope: ${t.instructionState.constraints.scopeDefinition}`);const a=t.skills.filter(r=>r.enabled).map(r=>r.name);a.length&&o.push(`Skills: ${a.join(", ")}`);const n=t.mcpServers.filter(r=>r.enabled).map(r=>r.name);return n.length&&o.push(`MCP servers: ${n.join(", ")}`),o.join(`
|
|
2
|
+
`)}const ke={memory:`You are an expert AI agent architect. Given the agent context below, generate memory configuration and initial facts.
|
|
3
|
+
|
|
4
|
+
Output ONLY a JSON object:
|
|
5
|
+
{
|
|
6
|
+
"maxMessages": <10-50>,
|
|
7
|
+
"summarizeAfter": <5-25>,
|
|
8
|
+
"summarizeEnabled": <true|false>,
|
|
9
|
+
"suggestedFacts": ["<pre-loaded fact relevant to the agent's domain>"]
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
Rules:
|
|
13
|
+
- Conversational agents need higher maxMessages and summarization
|
|
14
|
+
- One-shot tools can have lower limits and no summarization
|
|
15
|
+
- Facts should be domain-relevant knowledge the agent should always have
|
|
16
|
+
- Generate 2-5 facts that help the agent do its job better`};async function Ce(t,o){const a=de.getState(),n=a.providers.find(c=>c.id===a.selectedProviderId);if(!n)throw new Error("No provider configured — add one in Settings");const r=typeof n.models?.[0]=="object"?n.models[0].id:n.models?.[0]||"claude-sonnet-4-20250514";return n.authMethod==="claude-agent-sdk"?me({prompt:o,model:r,systemPrompt:t,maxTurns:1}):ue({providerId:n.id,model:r,messages:[{role:"system",content:t},{role:"user",content:o}],temperature:.4,maxTokens:2048})}function Ne(t){try{return JSON.parse(t)}catch{}const o=t.match(/```(?:json)?\s*([\s\S]*?)```/);if(o)try{return JSON.parse(o[1].trim())}catch{}const a=t.match(/[\[{][\s\S]*[\]}]/);if(a)try{return JSON.parse(a[0])}catch{}throw new Error("Could not parse LLM response as JSON")}async function we(){const t=Se();if(!t)throw new Error("Add agent identity/persona first — the generator needs context");const o=await Ce(ke.memory,t);return Ne(o)}function Te({loading:t,onClick:o,label:a="Generate",disabled:n=!1,"aria-describedby":r}){const c=n||t;return s.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),c||o()},disabled:c,"aria-label":t?`${a} in progress`:`${a} content`,"aria-describedby":r,className:"flex items-center gap-1 text-[13px] px-2 py-1 rounded cursor-pointer border-none transition-opacity",style:{background:"#FE500015",color:"#FE5000",fontFamily:"'Geist Mono', monospace",opacity:c?.6:1,cursor:c?"not-allowed":"pointer"},children:[t?s.jsx(ge,{size:9,className:"animate-spin motion-reduce:animate-none","aria-hidden":"true"}):s.jsx(pe,{size:9,"aria-hidden":"true"}),a]})}function b({label:t,value:o,min:a,max:n,step:r,onChange:c,suffix:d}){const h=Q(),w=d==="K"?`${(o/1e3).toFixed(0)}K`:`${o}`,j=`slider-${t.toLowerCase().replace(/\s+/g,"-")}`,S=`${j}-value`;return s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-3 mb-3",children:[s.jsx("label",{htmlFor:j,className:"text-sm font-medium shrink-0 sm:w-32",style:{color:h.textPrimary},children:t}),s.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[s.jsx("input",{id:j,type:"range",min:a,max:n,step:r,value:o,onChange:f=>c(Number(f.target.value)),title:`Adjust ${t.toLowerCase()}`,"aria-valuemin":a,"aria-valuemax":n,"aria-valuenow":o,"aria-valuetext":`${w}${d?" "+d.toLowerCase():""}`,"aria-describedby":S,className:"flex-1",style:{accentColor:"#FE5000"}}),s.jsx("span",{id:S,className:"text-sm w-12 text-right",style:{fontFamily:"'Geist Mono', monospace",color:h.textSecondary},"aria-live":"polite",children:w})]})]})}const R=[{value:"full",label:"Full History",description:"Keep all conversation messages in memory"},{value:"sliding_window",label:"Sliding Window",description:"Keep only the most recent messages"},{value:"summarize_and_recent",label:"Summarize + Recent",description:"Summarize old messages, keep recent ones"},{value:"rag",label:"RAG over History",description:"Retrieve relevant messages from searchable storage"}],$e=[{value:"local_sqlite",label:"SQLite (local)"},{value:"postgres",label:"PostgreSQL"},{value:"redis",label:"Redis"},{value:"chromadb",label:"ChromaDB"},{value:"pinecone",label:"Pinecone"},{value:"custom",label:"Custom"}],Ee=[{value:"text-embedding-3-small",label:"Ada 3 Small"},{value:"text-embedding-3-large",label:"Ada 3 Large"},{value:"voyage-3",label:"Voyage 3"},{value:"custom",label:"Custom"}],Me=[{value:"top_k",label:"Top-K"},{value:"threshold",label:"Threshold"},{value:"hybrid",label:"Hybrid"}],Fe=[{value:"auto_extract",label:"Auto Extract"},{value:"explicit",label:"Explicit Only"},{value:"both",label:"Both"}],Be=[{value:"per_user",label:"Per User"},{value:"per_agent",label:"Per Agent"},{value:"global",label:"Global"}],Oe=[{value:"user_preferences",label:"Preferences",color:"#3498db"},{value:"decisions",label:"Decisions",color:"#e67e22"},{value:"facts",label:"Facts",color:"#2ecc71"},{value:"feedback",label:"Feedback",color:"#9b59b6"},{value:"entities",label:"Entities",color:"#f1c40f"}],_e=[{value:"reset_each_run",label:"Reset Each Run"},{value:"persistent_sandbox",label:"Persistent Sandbox"},{value:"clone_from_shared",label:"Clone from Shared"}],M={shared:"#2ecc71",agent_private:"#3498db",run_scratchpad:"#e67e22"},A={preference:"#3498db",decision:"#e67e22",fact:"#2ecc71",entity:"#f1c40f",custom:"#999"},ze={display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",padding:"0.5rem 0.75rem",borderRadius:"0.25rem"},Pe={fontSize:"0.75rem",padding:"0.25rem 0.5rem",borderRadius:"9999px",fontFamily:"'Geist Mono', monospace"},Re={fontSize:"0.75rem",padding:"0.125rem 0.375rem",borderRadius:"0.25rem",fontFamily:"'Geist Mono', monospace"},Ae={border:"none",background:"transparent",cursor:"pointer",borderRadius:"0.25rem",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",minWidth:"44px",minHeight:"44px"};function Je(){const t=Q(),o=m(e=>e.session),a=m(e=>e.longTerm),n=m(e=>e.working),r=m(e=>e.facts),c=m(e=>e.setSessionConfig),d=m(e=>e.setLongTermConfig),h=m(e=>e.setRecallConfig),w=m(e=>e.setWriteConfig),j=m(e=>e.toggleExtractType),S=m(e=>e.setWorkingConfig),f=m(e=>e.addFact),U=m(e=>e.removeFact),T=m(e=>e.sandbox),D=m(e=>e.setSandboxConfig),V=m(e=>e.setSandboxDomain),[L,Z]=i.useState(!1),[I,ee]=i.useState(!1),[G,se]=i.useState(!1),[W,te]=i.useState(!1),[K,ae]=i.useState(!1),[k,F]=i.useState(""),[B,oe]=i.useState("shared"),[ne,H]=i.useState(!1),[O,le]=i.useState(""),[g,_]=i.useState(null),[J,Y]=i.useState(!1),[z,y]=i.useState("idle"),re=i.useCallback(async()=>{H(!0);try{const e=await we();c({maxMessages:e.maxMessages,summarizeAfter:e.summarizeAfter,summarizeEnabled:e.summarizeEnabled});for(const l of e.suggestedFacts||[])f(l,["generated"])}catch{}H(!1)},[c,f]),$=i.useCallback(async()=>{try{const e=await fetch("/api/memory/health");if(!e.ok)return _({status:"unavailable",factCount:0}),{status:"unavailable",factCount:0};const l=await e.json(),u=l.health??l.data??{status:"unknown",factCount:0};return _(u),u}catch{return _({status:"unavailable",factCount:0}),{status:"unavailable",factCount:0}}},[]),P=i.useCallback(async(e,l)=>{Y(!0),y("testing");try{const X=await(await fetch("/api/memory/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({backend:e,connectionString:l})})).json();X.status==="success"?(y("success"),d({store:e}),await $()):(y("error"),console.error("Connection test failed:",X.error))}catch(u){y("error"),console.error("Connection test error:",u)}Y(!1)},[d,$]),ie=i.useCallback(async e=>{const l=e;l==="postgres"?(d({store:l}),y("idle")):l==="local_sqlite"?await P(l):(d({store:l}),y("idle"))},[d,P]);i.useEffect(()=>{$()},[$]);const v=o.tokenBudget+a.tokenBudget+n.tokenBudget,p=e=>e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`;return a.enabled,n.enabled,s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-semibold mb-2 m-0",style:{color:t.textPrimary,fontFamily:"'Geist Sans', sans-serif"},children:"Memory Configuration"}),s.jsx("p",{className:"text-sm",style:{color:t.textSecondary,lineHeight:1.5},children:"Configure how your agent remembers and manages information across conversations. Set up session memory, long-term storage, working memory, and seed facts."})]}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-6",children:[s.jsxs(C,{icon:N,label:"Session Memory",color:"#3498db",badge:`${o.windowSize} messages · ${o.strategy}`,collapsed:L,onToggle:()=>Z(!L),children:[s.jsx("div",{className:"flex justify-end mb-4",children:s.jsx(Te,{loading:ne,onClick:re,label:"Configure"})}),s.jsx(b,{label:"Window Size",value:o.windowSize,min:5,max:100,step:5,onChange:e=>c({windowSize:e})}),s.jsxs("div",{className:"mb-4",children:[s.jsx(x,{options:R,value:o.strategy,onChange:e=>c({strategy:e}),label:"Strategy"}),R.find(e=>e.value===o.strategy)?.description&&s.jsx("p",{className:"text-xs mt-1",style:{color:t.textSecondary},children:R.find(e=>e.value===o.strategy)?.description})]}),o.strategy==="summarize_and_recent"&&s.jsx(b,{label:"Summarize After",value:o.summarizeAfter,min:5,max:o.windowSize,step:5,onChange:e=>c({summarizeAfter:e})}),s.jsx("div",{className:"mb-4",children:s.jsx(E,{checked:o.summarizeEnabled,onChange:e=>c({summarizeEnabled:e}),label:"Enable summarization of older messages"})}),s.jsx(b,{label:"Token Budget",value:o.tokenBudget,min:1e3,max:6e4,step:1e3,onChange:e=>c({tokenBudget:e}),suffix:"K"})]}),s.jsxs(C,{icon:N,label:"Seed Facts",color:"#e74c3c",badge:`${r.length} facts`,collapsed:W,onToggle:()=>te(!W),children:[s.jsxs("div",{className:"space-y-2 mb-4",children:[r.map(e=>{const l=M[e.domain]||"#999";return s.jsxs("div",{style:{...ze,background:t.surfaceElevated},children:[s.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:A[e.type]||"#999",flexShrink:0}}),s.jsx("span",{className:"flex-1 truncate",style:{color:t.textPrimary},children:e.content}),s.jsx("span",{style:{...Pe,background:`${l}15`,color:l},children:e.domain.replace("_"," ")}),e.tags.length>0&&e.tags.map(u=>s.jsx("span",{style:{...Re,background:`${A[e.type]||"#999"}15`,color:A[e.type]||"#999"},children:u},u)),s.jsx("button",{type:"button","aria-label":"Remove fact",title:"Remove fact",onClick:()=>U(e.id),style:{...Ae,color:t.textFaint},onMouseEnter:u=>{u.currentTarget.style.background="#ef444420",u.currentTarget.style.color="#ef4444"},onMouseLeave:u=>{u.currentTarget.style.background="transparent",u.currentTarget.style.color=t.textFaint},children:s.jsx(be,{size:12})})]},e.id)}),r.length===0&&s.jsx("div",{className:"text-center py-8 text-sm",style:{color:t.textDim},children:"No seed facts added yet. Add facts that your agent should always remember."})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(q,{value:k,onChange:e=>F(e.target.value),onKeyDown:e=>{e.key==="Enter"&&k.trim()&&(f(k.trim(),[],"fact",B),F(""))},placeholder:"Add a seed fact...",className:"flex-1"}),s.jsxs("select",{value:B,onChange:e=>oe(e.target.value),"aria-label":"Fact domain",title:"Select fact domain",className:"text-sm px-3 rounded border-none cursor-pointer",style:{background:t.surfaceElevated,color:t.textPrimary,fontFamily:"'Geist Mono', monospace"},children:[s.jsx("option",{value:"shared",children:"shared"}),s.jsx("option",{value:"agent_private",children:"private"}),s.jsx("option",{value:"run_scratchpad",children:"scratch"})]}),s.jsx("button",{type:"button","aria-label":"Add fact",title:"Add new fact",onClick:()=>{k.trim()&&(f(k.trim(),[],"fact",B),F(""))},className:"px-3 border-none rounded cursor-pointer shrink-0 min-w-[44px] min-h-[44px] flex items-center justify-center",style:{background:"#FE5000",color:"#fff"},children:s.jsx(xe,{size:12})})]})]}),s.jsx(C,{icon:N,label:"Sandbox Configuration",color:"#9b59b6",badge:T.isolation,collapsed:K,onToggle:()=>ae(!K),children:s.jsxs("div",{className:"space-y-4",children:[s.jsx(x,{options:_e,value:T.isolation,onChange:e=>D({isolation:e}),label:"Isolation"}),s.jsx("div",{children:s.jsx(E,{checked:T.allowPromoteToShared,onChange:e=>D({allowPromoteToShared:e}),label:"Allow promote to shared memory"})}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium mb-2",style:{color:t.textPrimary},children:"Memory Domains"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:[{key:"shared",label:"Shared",color:M.shared},{key:"agentPrivate",label:"Agent Private",color:M.agent_private},{key:"runScratchpad",label:"Run Scratchpad",color:M.run_scratchpad}].map(e=>{const l=T.domains[e.key].enabled;return s.jsx("button",{type:"button","aria-label":`Toggle ${e.label}`,title:`Toggle ${e.label}`,"aria-pressed":l,onClick:()=>V(e.key,!l),className:"text-sm px-3 py-2 rounded-full cursor-pointer border-none min-h-[44px]",style:{fontFamily:"'Geist Sans', sans-serif",background:l?`${e.color}20`:t.isDark?"#1c1c20":"#f0f0f5",color:l?e.color:t.textDim,border:`1px solid ${l?`${e.color}40`:"transparent"}`},children:e.label},e.key)})})]})]})})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(C,{icon:N,label:"Long-Term Memory",color:"#2ecc71",badge:a.enabled?`${a.store}${g?` · ${g.factCount} facts`:` · ${a.maxEntries} max`}`:"disabled",collapsed:I,onToggle:()=>ee(!I),children:[s.jsx("div",{className:"mb-4",children:s.jsx(E,{checked:a.enabled,onChange:e=>d({enabled:e}),label:"Enable long-term memory"})}),a.enabled&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(x,{options:$e,value:a.store,onChange:ie,label:"Store"}),s.jsx(x,{options:Be,value:a.scope,onChange:e=>d({scope:e}),label:"Scope"})]}),a.store==="postgres"&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx(q,{value:O,onChange:e=>le(e.target.value),placeholder:"postgresql://user:password@localhost:5432/database",className:"flex-1",type:"password"}),s.jsx("button",{type:"button",onClick:()=>P("postgres",O),disabled:!O||J,className:"px-4 py-2 rounded text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed min-w-[120px] flex items-center justify-center gap-2",style:{background:z==="success"?"#2ecc71":"#FE5000",color:"#fff"},children:J?s.jsxs(s.Fragment,{children:[s.jsx(he,{size:14,className:"animate-spin"}),"Testing..."]}):"Test Connection"})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[z==="success"&&s.jsxs(s.Fragment,{children:[s.jsx(fe,{size:14,style:{color:"#2ecc71"}}),s.jsx("span",{style:{color:"#2ecc71"},children:"Connected successfully"})]}),z==="error"&&s.jsxs(s.Fragment,{children:[s.jsx(ye,{size:14,style:{color:"#e74c3c"}}),s.jsx("span",{style:{color:"#e74c3c"},children:"Connection failed"})]})]})]}),["redis","chromadb","pinecone","custom"].includes(a.store)&&s.jsxs("div",{className:"flex items-center gap-2 p-3 rounded",style:{background:"#f39c1220",border:"1px solid #f39c1240"},children:[s.jsx(ve,{size:16,style:{color:"#f39c12"}}),s.jsx("span",{className:"text-sm",style:{color:"#f39c12"},children:"Coming soon"})]}),g&&s.jsxs("div",{className:"flex items-center gap-2 p-3 rounded",style:{background:g.status==="healthy"?"#2ecc7120":"#e74c3c20",border:`1px solid ${g.status==="healthy"?"#2ecc7140":"#e74c3c40"}`},children:[s.jsx(je,{size:16,style:{color:g.status==="healthy"?"#2ecc71":"#e74c3c"}}),s.jsx("span",{className:"text-sm",style:{color:g.status==="healthy"?"#2ecc71":"#e74c3c"},children:g.status==="healthy"?`${g.factCount} facts stored`:"Backend unavailable"})]}),s.jsx(x,{options:Ee,value:a.embeddingModel,onChange:e=>d({embeddingModel:e}),label:"Embedding Model"}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(x,{options:Me,value:a.recall.strategy,onChange:e=>h({strategy:e}),label:"Recall Strategy"}),s.jsx(b,{label:"K",value:a.recall.k,min:1,max:20,step:1,onChange:e=>h({k:e})})]}),s.jsx(b,{label:"Min Score",value:Math.round(a.recall.minScore*100),min:0,max:100,step:5,onChange:e=>h({minScore:e/100})}),s.jsx(x,{options:Fe,value:a.write.mode,onChange:e=>w({mode:e}),label:"Write Mode"}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium mb-2",style:{color:t.textPrimary},children:"Extract Types"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Oe.map(e=>{const l=a.write.extractTypes.includes(e.value);return s.jsx("button",{type:"button","aria-label":`Toggle ${e.label}`,"aria-pressed":l,onClick:()=>j(e.value),className:"text-sm px-3 py-2 rounded-full cursor-pointer border-none min-h-[44px]",style:{fontFamily:"'Geist Sans', sans-serif",background:l?`${e.color}20`:t.isDark?"#1c1c20":"#f0f0f5",color:l?e.color:t.textDim,border:`1px solid ${l?`${e.color}40`:"transparent"}`},children:e.label},e.value)})})]}),s.jsx(b,{label:"Max Entries",value:a.maxEntries,min:100,max:1e4,step:100,onChange:e=>d({maxEntries:e})}),s.jsx(b,{label:"Token Budget",value:a.tokenBudget,min:1e3,max:3e4,step:1e3,onChange:e=>d({tokenBudget:e}),suffix:"K"})]})]}),s.jsxs(C,{icon:N,label:"Working Memory",color:"#f1c40f",badge:n.enabled?`${p(n.maxTokens)} max`:"disabled",collapsed:G,onToggle:()=>se(!G),children:[s.jsx("div",{className:"mb-4",children:s.jsx(E,{checked:n.enabled,onChange:e=>S({enabled:e}),label:"Enable working memory scratchpad"})}),n.enabled&&s.jsx(b,{label:"Max Tokens",value:n.maxTokens,min:500,max:8e3,step:500,onChange:e=>S({maxTokens:e})})]}),v>0&&s.jsxs("div",{className:"mt-6 p-4 rounded-lg",style:{background:t.surfaceElevated,border:`1px solid ${t.border}`},children:[s.jsx("h3",{className:"text-sm font-semibold mb-3",style:{color:t.textPrimary,fontFamily:"'Geist Sans', sans-serif"},children:"Memory Budget Allocation"}),s.jsxs("div",{className:"flex gap-1 h-2 rounded overflow-hidden mb-3","aria-label":`Memory budget allocation: Session ${p(o.tokenBudget)}, ${a.enabled?`Long-term ${p(a.tokenBudget)}, `:""}${n.enabled?`Working ${p(n.tokenBudget)}, `:""}Total ${p(v)}`,role:"img",children:[s.jsx("div",{style:{width:`${o.tokenBudget/v*100}%`,background:"#3498db",borderRadius:2},title:`Session: ${p(o.tokenBudget)}`}),a.enabled&&s.jsx("div",{style:{width:`${a.tokenBudget/v*100}%`,background:"#2ecc71",borderRadius:2},title:`Long-term: ${p(a.tokenBudget)}`}),n.enabled&&s.jsx("div",{style:{width:`${n.tokenBudget/v*100}%`,background:"#f1c40f",borderRadius:2},title:`Working: ${p(n.tokenBudget)}`})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("div",{className:"flex gap-4",children:[{label:"Session",color:"#3498db",tokens:o.tokenBudget},...a.enabled?[{label:"Long-term",color:"#2ecc71",tokens:a.tokenBudget}]:[],...n.enabled?[{label:"Working",color:"#f1c40f",tokens:n.tokenBudget}]:[]].map(e=>s.jsxs("span",{className:"flex items-center gap-2 text-sm",style:{fontFamily:"'Geist Mono', monospace",color:t.textDim},children:[s.jsx("div",{style:{width:6,height:6,borderRadius:1,background:e.color}}),e.label]},e.label))}),s.jsxs("span",{className:"text-sm font-semibold",style:{fontFamily:"'Geist Mono', monospace",color:"#FE5000"},children:[p(v)," total"]})]})]})]})]})]})}export{Je as MemoryTab};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,r as x}from"./vendor-D1h_O76p.js";import{u as D,T as ce,a as E,B as L}from"./index-q24ug5Qs.js";import{u as O,C as de,E as pe,F as ue}from"./services-BaKotDf0.js";import{c as xe}from"./stores-CeKWz7ou.js";import{I as S}from"./Input-Bgp734xs.js";import{B as C}from"./Badge-22Ai0eyi.js";import{aA as H,Q as q,s as me,X as U,a0 as _,P as X,aB as K,a7 as V,W as he,C as ge,a as fe}from"./icons-C2EV-le6.js";let be=1;function Y(){return`q-${Date.now()}-${be++}`}const J={missionBrief:"",testCases:[],scoringDimensions:[],passThreshold:70},d=xe(n=>({status:"not-started",suite:{...J},runs:[],latestRunId:null,publishGated:!0,setSuiteField:(o,t)=>n(r=>({suite:{...r.suite,[o]:t}})),setMissionBrief:o=>n(t=>({suite:{...t.suite,missionBrief:o}})),addTestCase:o=>n(t=>({suite:{...t.suite,testCases:[...t.suite.testCases,{...o,id:Y(),score:null,feedback:"",passed:null}]}})),updateTestCase:(o,t)=>n(r=>({suite:{...r.suite,testCases:r.suite.testCases.map(i=>i.id===o?{...i,...t}:i)}})),removeTestCase:o=>n(t=>({suite:{...t.suite,testCases:t.suite.testCases.filter(r=>r.id!==o)}})),addScoringDimension:o=>n(t=>({suite:{...t.suite,scoringDimensions:[...t.suite.scoringDimensions,{...o,id:Y(),score:null}]}})),updateScoringDimension:(o,t)=>n(r=>({suite:{...r.suite,scoringDimensions:r.suite.scoringDimensions.map(i=>i.id===o?{...i,...t}:i)}})),removeScoringDimension:o=>n(t=>({suite:{...t.suite,scoringDimensions:t.suite.scoringDimensions.filter(r=>r.id!==o)}})),setPassThreshold:o=>n(t=>({suite:{...t.suite,passThreshold:o}})),setStatus:o=>n({status:o}),recordRun:o=>n(t=>({runs:[...t.runs,o],latestRunId:o.id,status:o.globalScore>=t.suite.passThreshold?"passed":"needs-work"})),applyPatch:(o,t)=>n(r=>({runs:r.runs.map(i=>i.id===o?{...i,patches:i.patches.map(l=>l.id===t?{...l,applied:!0}:l)}:i)})),setPublishGated:o=>n({publishGated:o}),reset:()=>n({status:"not-started",suite:{...J,testCases:[],scoringDimensions:[]},runs:[],latestRunId:null})}));function ye({value:n,showLabel:o=!1,className:t="",color:r}){const i=D(),l=Math.max(0,Math.min(100,n));return e.jsxs("div",{className:`flex flex-col gap-1 ${t}`,children:[o&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-[14px] font-semibold",style:{color:i.textSecondary,fontFamily:"'Geist Mono', monospace",fontSize:12},children:"Progress"}),e.jsxs("span",{className:"text-[14px]",style:{color:i.textMuted,fontFamily:"'Geist Mono', monospace",fontSize:12},children:[Math.round(l),"%"]})]}),e.jsx("div",{className:"h-2 rounded-full overflow-hidden",style:{background:i.surfaceElevated},children:e.jsx("div",{className:"h-full transition-all duration-300 ease-out",style:{width:`${l}%`,background:r||"#FE5000"}})})]})}const N={nominal:"#2ecc71",edge:"#f39c12",anti:"#e74c3c"};function k({label:n,color:o,collapsed:t,onToggle:r,right:i,t:l}){return e.jsxs("div",{className:"flex items-center gap-2.5 w-full px-5 py-3.5 select-none",style:{borderTop:`1px solid ${l.isDark?"#222226":"#e8e8ec"}`,background:`${o}08`},children:[e.jsxs("button",{type:"button",onClick:r,"aria-expanded":!t,className:"flex items-center gap-2.5 flex-1 cursor-pointer border-none bg-transparent p-0 text-left",children:[t?e.jsx(ge,{size:12,style:{color:l.textDim}}):e.jsx(fe,{size:12,style:{color:l.textDim}}),e.jsx("div",{style:{width:3,height:14,borderRadius:2,background:o,opacity:.8}}),e.jsx("span",{className:"text-[12px] font-bold tracking-[0.08em] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:l.textPrimary},children:n})]}),i]})}function T({score:n,threshold:o}){const t=n>=o;return e.jsxs("span",{className:"inline-flex items-center gap-1 text-[13px] font-bold px-2 py-0.5 rounded-full",style:{background:t?"#2ecc7120":"#e74c3c20",color:t?"#2ecc71":"#e74c3c",fontFamily:"'Geist Mono', monospace"},children:[t?e.jsx(K,{size:11}):e.jsx(V,{size:11}),n]})}function je(){const n=D(),o=d(s=>s.status),t=d(s=>s.suite),r=d(s=>s.runs),i=d(s=>s.latestRunId),l=d(s=>s.publishGated),w=d(s=>s.setMissionBrief),y=d(s=>s.addTestCase),b=d(s=>s.updateTestCase),R=d(s=>s.removeTestCase),u=d(s=>s.addScoringDimension),h=d(s=>s.updateScoringDimension),M=d(s=>s.removeScoringDimension),z=d(s=>s.setPassThreshold),m=d(s=>s.setStatus),A=d(s=>s.recordRun),Q=d(s=>s.applyPatch),g=O(s=>s.agentMeta),W=O(s=>s.selectedModel),f=O(s=>s.instructionState),[P,Z]=x.useState(!0),[B,ee]=x.useState(!0),[F,se]=x.useState(!1),[G,te]=x.useState(!0),[j,v]=x.useState(null),p=r.find(s=>s.id===i),ne=!l||p&&p.globalScore>=t.passThreshold,oe=x.useCallback(async()=>{if(t.missionBrief.trim()){v("generate"),m("generating");try{const s=await de({agentId:g.name||"current",missionBrief:t.missionBrief,persona:f.persona,constraints:f.constraints.customConstraints,objectives:f.objectives.primary});for(const a of s.testCases)y({type:a.type,label:a.label,input:a.input,expectedBehavior:a.expectedBehavior});for(const a of s.scoringDimensions)u({name:a.name,weight:a.weight});m("not-started")}catch{m("error")}v(null)}},[t.missionBrief,y,u,m,g.name,f.persona,f.constraints.customConstraints,f.objectives.primary]),ae=x.useCallback(async()=>{v("run"),m("running");try{const s=W?.split("::")||["default","claude-opus-4"],a=await pe({agentId:g.name||"current",providerId:s[0],model:s[1],suite:{missionBrief:t.missionBrief,testCases:t.testCases.map(({id:c,type:I,label:$,input:re,expectedBehavior:le})=>({id:c,type:I,label:$,input:re,expectedBehavior:le})),scoringDimensions:t.scoringDimensions.map(({id:c,name:I,weight:$})=>({id:c,name:I,weight:$})),passThreshold:t.passThreshold}});A({id:a.runId,timestamp:Date.now(),globalScore:a.globalScore,dimensionScores:a.dimensionScores,testResults:a.testResults,patches:a.patches})}catch{m("error")}v(null)},[t,A,m,W,g.name]),ie=x.useCallback(async(s,a)=>{try{await ue({agentId:g.name||"current",runId:s,patchIds:[a]}),Q(s,a)}catch{}},[Q,g.name]);return e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsxs("div",{className:"rounded-xl overflow-hidden",style:{background:n.surfaceOpaque,border:`1px solid ${n.border}`,boxShadow:`0 2px 12px ${n.isDark?"rgba(0,0,0,0.3)":"rgba(0,0,0,0.06)"}`},children:[e.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-3.5 select-none",style:{borderBottom:`1px solid ${n.border}`,background:n.surfaceElevated},children:[e.jsx(H,{size:14,style:{color:"#3498db"}}),e.jsx(ce,{content:"Qualify your agent before deployment",children:e.jsx("span",{className:"text-[13px] font-bold tracking-[0.08em] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:n.textPrimary},children:"Qualification"})}),e.jsx("div",{className:"flex-1"}),p&&e.jsx(T,{score:p.globalScore,threshold:t.passThreshold}),e.jsx(C,{variant:o==="passed"?"success":o==="needs-work"?"warning":o==="error"?"error":"neutral",children:o.replace("-"," ")})]}),e.jsx(k,{label:"Mission Brief",color:"#3498db",collapsed:!P,onToggle:()=>Z(!P),t:n,right:e.jsxs("button",{type:"button",onClick:oe,disabled:j==="generate"||!t.missionBrief.trim(),className:"flex items-center gap-1 text-[13px] px-2 py-1 rounded cursor-pointer border-none",style:{background:"#3498db15",color:"#3498db",fontFamily:"'Geist Mono', monospace",opacity:t.missionBrief.trim()?1:.4},children:[j==="generate"?e.jsx(q,{size:9,className:"animate-spin"}):e.jsx(me,{size:9}),"Generate Suite"]})}),P&&e.jsx("div",{className:"px-5 py-4",children:e.jsx(E,{label:"What should this agent do well? Describe its mission.",value:t.missionBrief,onChange:s=>w(s.target.value),placeholder:"e.g. This agent helps PMs write user stories from raw feedback. It should cite sources, stay concise, and refuse to fabricate data...",style:{minHeight:64}})}),e.jsx(k,{label:`Test Cases (${t.testCases.length})`,color:"#f39c12",collapsed:!B,onToggle:()=>ee(!B),t:n}),B&&e.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[t.testCases.map(s=>{const a=p?.testResults.find(c=>c.testCaseId===s.id);return e.jsxs("div",{className:"rounded-lg p-3",style:{background:n.surfaceElevated,border:`1px solid ${n.border}`},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-[13px] font-bold px-1.5 py-0.5 rounded",style:{background:`${N[s.type]}20`,color:N[s.type],fontFamily:"'Geist Mono', monospace"},children:s.type}),e.jsx(S,{value:s.label,onChange:c=>b(s.id,{label:c.target.value}),placeholder:"Test label...",style:{flex:1,fontSize:14}}),a&&e.jsx(T,{score:a.score,threshold:t.passThreshold}),e.jsx("button",{type:"button","aria-label":"Remove test case",onClick:()=>R(s.id),className:"border-none bg-transparent cursor-pointer p-1",style:{color:n.textFaint},children:e.jsx(U,{size:11})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(E,{label:"Input",value:s.input,onChange:c=>b(s.id,{input:c.target.value}),placeholder:"Agent input...",style:{minHeight:40,fontSize:13}}),e.jsx(E,{label:"Expected",value:s.expectedBehavior,onChange:c=>b(s.id,{expectedBehavior:c.target.value}),placeholder:"Expected behavior...",style:{minHeight:40,fontSize:13}})]}),a?.feedback&&e.jsx("div",{className:"mt-2 text-[12px] px-2 py-1 rounded",style:{background:a.passed?"#2ecc7110":"#e74c3c10",color:a.passed?"#2ecc71":"#e74c3c"},children:a.feedback})]},s.id)}),e.jsx("div",{className:"flex gap-2 justify-center",children:["nominal","edge","anti"].map(s=>e.jsxs("button",{type:"button",onClick:()=>y({type:s,label:"",input:"",expectedBehavior:""}),className:"flex items-center gap-1 text-[12px] px-3 py-1.5 rounded cursor-pointer border-none",style:{background:`${N[s]}15`,color:N[s],fontFamily:"'Geist Mono', monospace"},children:[e.jsx(_,{size:10})," ",s]},s))})]}),e.jsx(k,{label:"Scoring Rubric",color:"#9b59b6",collapsed:!F,onToggle:()=>se(!F),t:n}),F&&e.jsxs("div",{className:"px-5 py-4 flex flex-col gap-2",children:[t.scoringDimensions.map(s=>{const a=p?.dimensionScores[s.id];return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{value:s.name,onChange:c=>h(s.id,{name:c.target.value}),placeholder:"Dimension...",style:{flex:1,fontSize:14}}),e.jsx(S,{value:String(Math.round(s.weight*100)),type:"number",onChange:c=>h(s.id,{weight:Number(c.target.value)/100}),style:{width:56,fontSize:13,textAlign:"center"}}),e.jsx("span",{className:"text-[13px]",style:{color:n.textDim},children:"%"}),a!==void 0&&e.jsx(T,{score:a,threshold:t.passThreshold}),e.jsx("button",{type:"button","aria-label":"Remove dimension",onClick:()=>M(s.id),className:"border-none bg-transparent cursor-pointer p-1",style:{color:n.textFaint},children:e.jsx(U,{size:11})})]},s.id)}),e.jsxs("button",{type:"button",onClick:()=>u({name:"",weight:.25}),className:"flex items-center gap-1 text-[12px] cursor-pointer border-none bg-transparent self-start",style:{color:"#9b59b6",fontFamily:"'Geist Mono', monospace"},children:[e.jsx(_,{size:10})," Add Dimension"]}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx("span",{className:"text-[12px] font-semibold",style:{color:n.textDim,fontFamily:"'Geist Mono', monospace"},children:"Pass Threshold"}),e.jsx(S,{value:String(t.passThreshold),type:"number",onChange:s=>z(Number(s.target.value)),style:{width:56,fontSize:13,textAlign:"center"}}),e.jsx("span",{className:"text-[13px]",style:{color:n.textDim},children:"/ 100"})]})]})]}),e.jsxs("div",{className:"rounded-xl overflow-hidden",style:{background:n.surfaceOpaque,border:`1px solid ${n.border}`,boxShadow:`0 2px 12px ${n.isDark?"rgba(0,0,0,0.3)":"rgba(0,0,0,0.06)"}`},children:[e.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-3.5 select-none",style:{background:n.surfaceElevated,borderBottom:`1px solid ${n.border}`},children:[e.jsx(X,{size:12,style:{color:"#3498db"}}),e.jsx("span",{className:"text-[13px] font-bold tracking-[0.08em] uppercase flex-1",style:{fontFamily:"'Geist Mono', monospace",color:n.textPrimary},children:"Run & Results"}),e.jsx(L,{size:"sm",onClick:ae,disabled:j==="run"||t.testCases.length===0,children:j==="run"?e.jsxs(e.Fragment,{children:[e.jsx(q,{size:11,className:"animate-spin"})," Running..."]}):e.jsxs(e.Fragment,{children:[e.jsx(X,{size:11})," Run Qualification"]})})]}),p?e.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-[12px] font-bold tracking-wider uppercase",style:{color:n.textDim,fontFamily:"'Geist Mono', monospace"},children:"Global Score"}),e.jsx("div",{className:"flex-1",children:e.jsx(ye,{value:p.globalScore,color:p.globalScore>=t.passThreshold?"#2ecc71":"#e74c3c"})}),e.jsx(T,{score:p.globalScore,threshold:t.passThreshold})]}),e.jsx(k,{label:"Test Results",color:"#f39c12",collapsed:!G,onToggle:()=>te(!G),t:n}),G&&p.testResults.map(s=>{const a=t.testCases.find(c=>c.id===s.testCaseId);return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded",style:{background:s.passed?"#2ecc7108":"#e74c3c08",border:`1px solid ${s.passed?"#2ecc7120":"#e74c3c20"}`},children:[s.passed?e.jsx(K,{size:12,style:{color:"#2ecc71"}}):e.jsx(V,{size:12,style:{color:"#e74c3c"}}),e.jsx("span",{className:"text-[13px] flex-1",style:{color:n.textPrimary},children:a?.label||s.testCaseId}),e.jsx("span",{className:"text-[12px] font-bold",style:{fontFamily:"'Geist Mono', monospace",color:s.passed?"#2ecc71":"#e74c3c"},children:s.score})]},s.testCaseId)}),p.patches.length>0&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-bold tracking-wider uppercase",style:{color:n.textDim,fontFamily:"'Geist Mono', monospace"},children:"Suggested Patches"}),p.patches.map(s=>e.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 rounded",style:{background:"#f39c1208",border:"1px solid #f39c1220"},children:[e.jsx(he,{size:11,style:{color:"#f39c12",marginTop:2}}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-[13px]",style:{color:n.textPrimary},children:s.description}),e.jsx("code",{className:"text-[12px] block mt-1",style:{color:"#2ecc71",fontFamily:"'Geist Mono', monospace"},children:s.diff})]}),s.applied?e.jsx(C,{variant:"success",children:"Applied"}):e.jsx(L,{size:"sm",onClick:()=>ie(p.id,s.id),children:"Apply"})]},s.id))]}),e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 rounded",style:{background:n.surfaceElevated,border:`1px solid ${n.border}`},children:[e.jsx("span",{className:"text-[12px] font-bold tracking-wider uppercase",style:{color:n.textDim,fontFamily:"'Geist Mono', monospace"},children:"Publish Gate"}),ne?e.jsx(C,{variant:"success",children:"Ready to publish"}):e.jsxs(C,{variant:"error",children:["Score below ",t.passThreshold,"%"]})]})]}):e.jsxs("div",{className:"px-5 py-8 text-center",children:[e.jsx(H,{size:24,style:{color:n.textFaint,margin:"0 auto 8px"}}),e.jsx("div",{className:"text-[13px]",style:{color:n.textFaint},children:t.testCases.length===0?"Write a mission brief and generate a test suite to get started.":'Click "Run Qualification" to evaluate your agent.'})]})]})]})}function ve(){const n=D(),t=[...d(u=>u.runs)].sort((u,h)=>u.timestamp-h.timestamp).slice(-10);if(t.length<2)return null;const r=120,i=30,l=4,w=t.map((u,h)=>{const M=l+h/(t.length-1)*(r-2*l),z=l+(100-u.globalScore)/100*(i-2*l);return`${M},${z}`}).join(" "),b=t[t.length-1].globalScore>=t[0].globalScore?"#2ecc71":"#e74c3c",R=t[t.length-1].globalScore;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"8px 12px",backgroundColor:n.surface,borderRadius:"6px",border:`1px solid ${n.border}`},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:[e.jsxs("span",{style:{fontSize:"11px",color:n.textSecondary,fontWeight:500},children:["Score Trend (",t.length," runs)"]}),e.jsxs("span",{style:{fontSize:"14px",color:n.textPrimary,fontWeight:600},children:[R.toFixed(1),"%"]})]}),e.jsx("svg",{width:r,height:i,style:{flexShrink:0},children:e.jsx("polyline",{points:w,fill:"none",stroke:b,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})}function Re(){const n=D();return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4 mb-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-semibold mb-2 m-0",style:{color:n.textPrimary,fontFamily:"'Geist Sans', sans-serif"},children:"Qualification & Testing"}),e.jsx("p",{className:"text-sm",style:{color:n.textSecondary,lineHeight:1.5},children:"Run comprehensive test suites to validate your agent's performance, reliability, and adherence to requirements before production deployment."})]}),e.jsx(ve,{})]})}),e.jsx(je,{})]})}export{Re as QualificationTab};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import{r as f,j as e}from"./vendor-D1h_O76p.js";import{a as O,e as U,j as le,k as ce,O as we,u as j,l as X}from"./services-BaKotDf0.js";import{useConversationStore as Se}from"./conversationStore-CkfEU2eV.js";import{u as N,M as Ce,B as Y,a as W,S as Q,g as Ne,d as B,e as oe,h as Fe,i as Ee}from"./index-q24ug5Qs.js";import{I as z}from"./Input-Bgp734xs.js";import{B as Te}from"./Badge-22Ai0eyi.js";import{X as J,i as ne,aL as de,C as Ae,R as Me,ab as Pe,aM as Oe,ai as q,B as ze,Z as Re,g as $e,ae as Z,T as pe,aN as Ie,d as ue,aO as De,E as Be,y as Le,h as We,aP as Ge,aQ as Ue,aR as Ye,aS as Je,aT as Ke,aU as Ve,aV as He,aW as _e,aX as Xe,a0 as ae,u as Qe,S as Ze,aa as qe,$ as re,a as et,Q as tt,ah as st,U as ot}from"./icons-C2EV-le6.js";import{S as $,T as L}from"./Section-DoJrmytO.js";import"./stores-CeKWz7ou.js";const nt=f.forwardRef(function({icon:o,size:r="md",variant:n="ghost",tooltip:t,active:l,className:c="",style:i,...p},h){const a=N(),g=r==="sm"?24:32,w={ghost:{bg:l?"#FE500020":"transparent",color:l?"#FE5000":a.textDim,hoverBg:a.isDark?"#ffffff10":"#00000008"},secondary:{bg:a.surfaceElevated,color:a.textSecondary,hoverBg:a.isDark?"#2a2a30":"#eee"},danger:{bg:"transparent",color:a.statusError,hoverBg:a.statusErrorBg}}[n];return e.jsx("button",{ref:h,type:"button",title:t,"aria-label":t,className:`ds-icon-btn flex items-center justify-center rounded-md cursor-pointer border-none nodrag ${c}`,style:{width:g,height:g,background:w.bg,color:w.color,transition:"background 0.15s",...i},onMouseEnter:F=>F.currentTarget.style.background=w.hoverBg,onMouseLeave:F=>F.currentTarget.style.background=w.bg,...p,children:o})});function at({children:s,variant:o="default",onRemove:r,className:n=""}){const t=N(),c={default:{bg:`${t.textSecondary}15`,color:t.textSecondary},success:{bg:`${t.statusSuccess}15`,color:t.statusSuccess},error:{bg:`${t.statusError}15`,color:t.statusError},warning:{bg:`${t.statusWarning}15`,color:t.statusWarning},info:{bg:`${t.statusInfo}15`,color:t.statusInfo}}[o];return e.jsxs("div",{className:`inline-flex items-center gap-1 px-2 py-1 rounded-md text-[14px] nodrag ${n}`,style:{background:c.bg,color:c.color,fontFamily:"'Geist Mono', monospace",fontSize:12,fontWeight:500},children:[e.jsx("span",{children:s}),r&&e.jsx("button",{type:"button",onClick:r,className:"p-0 border-none bg-transparent cursor-pointer hover:opacity-70 nodrag",style:{color:c.color},"aria-label":"Remove",children:e.jsx(J,{size:10})})]})}function rt({type:s}){const o={major:"#FE5000",minor:"#3498db",patch:"#888"};return e.jsx(Oe,{size:6,fill:o[s],stroke:"none"})}function it({v:s,isCurrent:o,onRestore:r,onDelete:n}){const t=N(),[l,c]=f.useState(!1);return e.jsxs("div",{className:"rounded-lg overflow-hidden",style:{border:`1px solid ${o?"#FE500040":t.borderSubtle}`,background:o?"#FE500008":"transparent"},children:[e.jsxs("button",{type:"button",onClick:()=>c(!l),className:"w-full min-h-[36px] flex items-center gap-2 px-3 py-2 cursor-pointer border-none bg-transparent text-left",children:[e.jsx(Ae,{size:10,style:{color:t.textDim,transform:l?"rotate(90deg)":"none",transition:"transform 0.15s"}}),e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[e.jsxs("span",{className:"text-[14px] font-bold shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:o?"#FE5000":t.textPrimary},children:["v",s.version]}),e.jsx("span",{className:"text-[12px] truncate",style:{color:t.textMuted},children:s.label||"Checkpoint"})]}),o&&e.jsx(Te,{variant:"success",size:"sm",dot:!0,children:"CURRENT"}),e.jsx("span",{className:"text-[13px] shrink-0",style:{color:t.textFaint},children:new Date(s.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),l&&e.jsxs("div",{className:"px-3 pb-2 flex flex-col gap-1.5",children:[s.changes.length===0&&e.jsx("div",{className:"text-[12px]",style:{color:t.textMuted},children:"No changelog entries recorded for this version."}),s.changes.map((i,p)=>e.jsxs("div",{className:"flex items-center gap-2 text-[12px]",style:{color:t.textSecondary},children:[e.jsx(rt,{type:i.type}),e.jsx("span",{className:"uppercase text-[12px] font-semibold w-14 shrink-0",style:{color:t.textDim},children:i.category}),e.jsx("span",{children:i.description})]},p)),e.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[!o&&e.jsx(Y,{variant:"secondary",size:"sm",icon:e.jsx(Me,{size:10}),onClick:r,children:"Restore"}),e.jsx(nt,{icon:e.jsx(Pe,{size:11}),variant:"danger",size:"sm",tooltip:"Delete version",onClick:n})]})]})]})}function lt(){const s=N(),o=O(i=>i.versions),r=O(i=>i.currentVersion),n=O(i=>i.dirty),t=O(i=>i.checkpoint),[l,c]=f.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>c(!0),className:"flex items-center gap-1.5 px-2 h-8 rounded-lg cursor-pointer border-none",style:{background:n?"#FE500015":"transparent",color:n?"#FE5000":s.textDim,fontFamily:"'Geist Mono', monospace",fontSize:12,fontWeight:600,transition:"background 0.15s"},title:"Version history",children:[e.jsx(ne,{size:12}),"v",r,n&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#FE5000] animate-pulse"})]}),e.jsx(Ce,{open:l,onClose:()=>c(!1),title:"Version History",width:480,footer:e.jsx(Y,{variant:"primary",size:"sm",icon:e.jsx(de,{size:10}),onClick:()=>{t()},children:"Save Checkpoint"}),children:e.jsxs("div",{className:"flex flex-col gap-1.5 p-3 max-h-[60vh] overflow-y-auto overscroll-contain pr-1",children:[o.length===0&&e.jsxs("div",{className:"py-8 text-center",children:[e.jsx(ne,{size:20,style:{margin:"0 auto 8px",color:s.textFaint,opacity:.3}}),e.jsx("div",{className:"text-[12px]",style:{color:s.textFaint},children:"No versions yet"}),e.jsx("div",{className:"text-[12px] mt-1",style:{color:s.textMuted},children:"Make changes to your agent — versions are created automatically"})]}),[...o].reverse().map(i=>e.jsx(it,{v:i,isCurrent:i.version===r,onRestore:()=>{O.getState().restoreVersion(i.version),c(!1)},onDelete:()=>O.getState().deleteVersion(i.id)},i.id))]})})]})}const me=[{id:"bot",icon:q},{id:"brain",icon:ze},{id:"zap",icon:Re},{id:"flame",icon:$e},{id:"lightbulb",icon:Z},{id:"target",icon:pe},{id:"rocket",icon:Ie},{id:"shield",icon:ue},{id:"microscope",icon:De},{id:"chart",icon:Be},{id:"palette",icon:Le},{id:"file",icon:We},{id:"drama",icon:Ge},{id:"star",icon:Ue},{id:"gem",icon:Ye},{id:"bird",icon:Je},{id:"bug",icon:Ke},{id:"cat",icon:Ve},{id:"dog",icon:He},{id:"heart",icon:_e}];function ie({avatarId:s,size:o=20,color:r}){const n=N(),t=me.find(c=>c.id===s)?.icon??q,l=r||n.textPrimary;return e.jsx(t,{size:o,color:l})}function ct({agentMeta:s,setAgentMeta:o,collapsed:r,onToggle:n}){const t=N(),[l,c]=f.useState(!1),[i,p]=f.useState(""),h={display:"flex",alignItems:"center",justifyContent:"center",width:"80px",height:"80px",borderRadius:"8px",border:"2px dashed var(--border)",background:"var(--surface-elevated)",cursor:"pointer"},a={position:"absolute",top:"96px",left:0,background:t.surfaceElevated,border:`1px solid ${t.border}`,borderRadius:"8px",padding:"12px",display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"8px",zIndex:1e3,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"},g={display:"inline-flex",alignItems:"center",padding:"4px 8px",background:t.badgeBg,color:t.textSecondary,borderRadius:"12px",fontSize:"12px",fontFamily:"'Geist Sans', sans-serif"},y=u=>{u&&!s.tags.includes(u)&&o({tags:[...s.tags,u]})},w=u=>{o({tags:s.tags.filter(m=>m!==u)})},F=u=>{u.key==="Enter"&&i.trim()&&(y(i.trim()),p(""))};return e.jsxs($,{icon:Xe,label:"Identity",color:"#3498db",collapsed:r,onToggle:n,children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"md:col-span-2 space-y-4",children:[e.jsx(z,{label:"Agent Name",value:s.name,onChange:u=>o({name:u.target.value}),placeholder:"Enter agent name..."}),e.jsx(W,{label:"Description",value:s.description,onChange:u=>o({description:u.target.value}),placeholder:"Describe what this agent does...",rows:3}),e.jsx(z,{label:"Category",value:s.category,onChange:u=>o({category:u.target.value}),placeholder:"e.g., productivity, development, research..."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-medium",style:{color:t.textPrimary},children:"Avatar"}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",onClick:()=>c(!l),"aria-label":`Select agent avatar (currently ${s.avatar||"default"})`,title:"Choose avatar","aria-expanded":l,"aria-haspopup":"menu",style:h,children:e.jsx(ie,{avatarId:s.avatar,size:48})}),l&&e.jsx("div",{style:a,children:me.map(u=>e.jsx("button",{type:"button",onClick:()=>{o({avatar:u.id}),c(!1)},"aria-label":`Select avatar ${u.id} as agent avatar`,title:`Select ${u.id} avatar`,className:"flex items-center justify-center w-12 h-12 rounded-lg cursor-pointer border-none",style:{background:s.avatar===u.id?"#FE500020":"transparent",border:`1px solid ${s.avatar===u.id?"#FE5000":"transparent"}`},children:e.jsx(ie,{avatarId:u.id,size:24})},u.id))})]})]})]}),e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsx("label",{className:"block text-sm font-medium",style:{color:t.textPrimary},children:"Tags"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.tags.map(u=>e.jsxs("span",{style:g,children:[u,e.jsx("button",{type:"button",onClick:()=>w(u),title:`Remove ${u} tag`,className:"border-none bg-transparent cursor-pointer p-0 ml-1",style:{color:"#FE5000"},children:"×"})]},u)),e.jsx(z,{value:i,onChange:u=>p(u.target.value),onKeyDown:F,placeholder:"Add tag...",className:"w-24",style:{minWidth:"100px"}})]})]})]})}const dt="#27ae60",pt="#FE5000";function K({onRefine:s}){const o=N(),[r,n]=f.useState(!1),[t,l]=f.useState(null),[c,i]=f.useState(!1),p=async()=>{l(null),i(!1),n(!0);try{await s(),i(!0),setTimeout(()=>i(!1),2e3)}catch(y){const w=y instanceof Error?y.message:"Refinement failed";l(w),setTimeout(()=>l(null),4e3)}finally{n(!1)}},h=t?o.statusError:c?dt:pt,a={background:"transparent",border:`1px solid ${h}`,color:h,borderRadius:6,padding:"2px 8px",fontSize:11,fontFamily:"'Geist Mono', monospace",fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase",cursor:r?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:4,transition:"all 0.15s"},g=c?"Done":r?"Refining…":"Refine";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:p,disabled:r,title:"Refine with AI",style:a,children:[r?e.jsx("span",{className:"animate-spin",children:"⟳"}):e.jsx("span",{children:"✨"}),g]}),t&&e.jsx("span",{style:{color:o.statusError,fontSize:11,fontFamily:"'Geist Mono', monospace"},children:t})]})}const ut=`You are an expert prompt engineer. Your job is to take a user's rough brain dump about an AI agent they want to build, and transform it into structured, high-quality agent instructions following Anthropic's prompting best practices.
|
|
2
|
+
|
|
3
|
+
Given the user's rough input, produce a JSON response with this exact structure:
|
|
4
|
+
{
|
|
5
|
+
"persona": "<2-4 sentence persona description. Be specific about expertise, domain, and communication style. Use 'You are...' framing>",
|
|
6
|
+
"tone": "<one of: formal, neutral, casual>",
|
|
7
|
+
"expertise": <1-5 number, where 1=beginner-friendly and 5=expert-level>,
|
|
8
|
+
"constraints": [
|
|
9
|
+
"<clear, actionable constraint in imperative voice>"
|
|
10
|
+
],
|
|
11
|
+
"scopeDefinition": "<one sentence: what the agent handles and what it does NOT handle>",
|
|
12
|
+
"objectives": {
|
|
13
|
+
"primary": "<one clear sentence describing the agent's primary goal>",
|
|
14
|
+
"successCriteria": ["<measurable criterion>"],
|
|
15
|
+
"failureModes": ["<specific failure to avoid>"]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
Follow these rules:
|
|
20
|
+
1. Be specific — replace vague descriptions with concrete, actionable language
|
|
21
|
+
2. Use XML-tag-friendly language (the output will be assembled into a system prompt)
|
|
22
|
+
3. Infer reasonable constraints from the domain (e.g., a medical agent should cite sources)
|
|
23
|
+
4. Generate 2-4 success criteria and 2-3 failure modes based on the domain
|
|
24
|
+
5. Keep the persona concise but distinctive — give it a clear identity
|
|
25
|
+
6. If the input mentions tools, APIs, or specific capabilities, reference them in constraints
|
|
26
|
+
7. Think step by step about what makes an excellent agent for this use case before writing
|
|
27
|
+
|
|
28
|
+
Output ONLY the JSON object. No markdown fences, no explanation.`,mt={persona:'You are an expert prompt engineer. Transform this rough persona description into a clear, specific 2-4 sentence persona. Use "You are..." framing. Be concrete about expertise, domain knowledge, and communication style. Output ONLY the refined persona text.',constraints:"You are an expert prompt engineer. Transform these rough constraint notes into clear, actionable rules — one per line, imperative voice. Remove redundancy, sharpen vague rules, infer reasonable additions from the domain. Output ONLY the constraints, one per line.",scope:"You are an expert prompt engineer. Transform this rough scope description into a clear one-sentence definition of what the agent handles and what it does NOT handle. Output ONLY the scope sentence."};async function V(s,o){if(!o.trim())throw new Error("Nothing to refine");const r=U.getState(),n=r.providers.find(a=>a.id===r.selectedProviderId);if(!n)throw new Error("No provider configured — add one in Settings");const t=typeof n.models?.[0]=="object"?n.models[0].id:n.models?.[0]||"claude-sonnet-4-20250514",l=s==="full"?ut:mt[s];if(!l)throw new Error(`Unknown field: ${s}`);const i=n.authMethod==="claude-agent-sdk"?await le({prompt:o,model:t,systemPrompt:l,maxTurns:1}):await ce({providerId:n.id,model:t,messages:[{role:"system",content:l},{role:"user",content:o}],temperature:.3,maxTokens:1024});if(s!=="full")return i;try{return JSON.parse(i)}catch{}const p=i.match(/```(?:json)?\s*([\s\S]*?)```/);if(p)try{return JSON.parse(p[1].trim())}catch{}const h=i.match(/\{[\s\S]*\}/);if(h)try{return JSON.parse(h[0])}catch{}throw new Error("Could not parse agent structure from LLM response")}function ft({persona:s,tone:o,expertise:r,updateInstruction:n,collapsed:t,onToggle:l}){const c=N(),i=async()=>{const p=await V("persona",s);typeof p=="string"&&n({persona:p})};return e.jsx($,{icon:q,label:"Persona",color:"#9b59b6",collapsed:t,onToggle:l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(W,{label:"Persona Description",labelAction:e.jsx(K,{onRefine:i}),value:s,onChange:p=>n({persona:p.target.value}),placeholder:"Describe the agent's personality, communication style, and approach...",rows:4}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Q,{label:"Tone",options:[{value:"formal",label:"Formal"},{value:"neutral",label:"Neutral"},{value:"casual",label:"Casual"}],value:o,onChange:p=>n({tone:p})}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium mb-2",style:{color:c.textPrimary},children:["Expertise Level: ",r,"/5"]}),e.jsx("input",{type:"range",min:"1",max:"5",step:"1",value:r,onChange:p=>n({expertise:Number(p.target.value)}),className:"w-full",style:{accentColor:"#FE5000"}}),e.jsxs("div",{className:"flex justify-between text-xs mt-1",style:{color:c.textDim},children:[e.jsx("span",{children:"Beginner"}),e.jsx("span",{children:"Expert"})]})]})]})]})})}function xt({constraints:s,onAdd:o,onRemove:r}){const[n,t]=f.useState(""),l=c=>{c.key==="Enter"&&n.trim()&&(o(n.trim()),t(""))};return e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:s.map(c=>e.jsx(at,{onRemove:()=>r(c),children:c},c))}),e.jsx(z,{value:n,onChange:c=>t(c.target.value),onKeyDown:l,placeholder:"Type constraint and press Enter..."})]})}function gt({constraints:s,updateInstruction:o,customConstraints:r,addCustomConstraint:n,removeCustomConstraint:t,collapsed:l,onToggle:c}){const i=N(),p=async()=>{const a=await V("constraints",s.customConstraints);typeof a=="string"&&o({constraints:{...s,customConstraints:a}})},h=async()=>{const a=await V("scope",s.scopeDefinition);typeof a=="string"&&o({constraints:{...s,scopeDefinition:a}})};return e.jsx($,{icon:ue,label:"Constraints & Safety",color:"#e74c3c",collapsed:l,onToggle:c,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(L,{checked:s.neverMakeUp,onChange:a=>o({constraints:{...s,neverMakeUp:a}}),label:"Never fabricate information"}),e.jsx(L,{checked:s.askBeforeActions,onChange:a=>o({constraints:{...s,askBeforeActions:a}}),label:"Ask before taking actions"}),e.jsx(L,{checked:s.stayInScope,onChange:a=>o({constraints:{...s,stayInScope:a}}),label:"Stay within defined scope"}),e.jsx(L,{checked:s.useOnlyTools,onChange:a=>o({constraints:{...s,useOnlyTools:a}}),label:"Use only provided tools"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(L,{checked:s.limitWords,onChange:a=>o({constraints:{...s,limitWords:a}}),label:"Limit response length"}),s.limitWords&&e.jsx(z,{type:"number",value:s.wordLimit.toString(),onChange:a=>o({constraints:{...s,wordLimit:Number(a.target.value)||0}}),placeholder:"Word limit",className:"w-24"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",style:{color:i.textPrimary},children:"Custom Constraints"}),e.jsx(xt,{constraints:r,onAdd:n,onRemove:t})]}),e.jsx(W,{label:"Scope Definition",labelAction:e.jsx(K,{onRefine:h}),value:s.scopeDefinition,onChange:a=>o({constraints:{...s,scopeDefinition:a.target.value}}),placeholder:"Define the specific scope and boundaries for this agent...",rows:2}),e.jsx(W,{label:"Additional Notes",labelAction:e.jsx(K,{onRefine:p}),value:s.customConstraints,onChange:a=>o({constraints:{...s,customConstraints:a.target.value}}),placeholder:"Add any additional constraints or rules (one per line)...",rows:3})]})})}function ht({objectives:s,updateInstruction:o,collapsed:r,onToggle:n}){const t=N(),[l,c]=f.useState(""),[i,p]=f.useState(""),h=()=>{if(l.trim()){const m=[...s.successCriteria,l.trim()];o({objectives:{...s,successCriteria:m}}),c("")}},a=m=>{const S=s.successCriteria.filter((I,A)=>A!==m);o({objectives:{...s,successCriteria:S}})},g=()=>{if(i.trim()){const m=[...s.failureModes,i.trim()];o({objectives:{...s,failureModes:m}}),p("")}},y=m=>{const S=s.failureModes.filter((I,A)=>A!==m);o({objectives:{...s,failureModes:S}})},w=m=>{m.key==="Enter"&&(m.preventDefault(),h())},F=m=>{m.key==="Enter"&&(m.preventDefault(),g())},u=async()=>{const m=await V("scope",s.primary);typeof m=="string"&&o({objectives:{...s,primary:m}})};return e.jsx($,{icon:pe,label:"Objectives & Success Criteria",color:"#27ae60",collapsed:r,onToggle:n,children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(W,{label:"Primary Objective",labelAction:e.jsx(K,{onRefine:u}),value:s.primary,onChange:m=>o({objectives:{...s,primary:m.target.value}}),placeholder:"What is the main goal this agent should achieve?",rows:2}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",style:{color:t.textPrimary},children:"Success Criteria"}),e.jsxs("div",{className:"space-y-2",children:[s.successCriteria.map((m,S)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 px-3 py-2 rounded-md text-sm",style:{background:t.surfaceElevated,border:`1px solid ${t.border}`,color:t.textPrimary},children:m}),e.jsx("button",{type:"button",onClick:()=>a(S),className:"flex items-center justify-center w-8 h-8 rounded-md border-none cursor-pointer",style:{background:"transparent",color:t.textMuted},"aria-label":"Remove success criterion",title:"Remove criterion",children:e.jsx(J,{size:14})})]},S)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(z,{value:l,onChange:m=>c(m.target.value),onKeyDown:w,placeholder:"Add a success criterion...",className:"flex-1"}),e.jsxs(Y,{onClick:h,variant:"secondary",size:"sm",disabled:!l.trim(),title:"Add success criterion",className:"flex items-center gap-1",children:[e.jsx(ae,{size:14}),"Add"]})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",style:{color:t.textPrimary},children:"Failure Modes"}),e.jsxs("div",{className:"space-y-2",children:[s.failureModes.map((m,S)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 px-3 py-2 rounded-md text-sm",style:{background:t.surfaceElevated,border:`1px solid ${t.border}`,color:t.textPrimary},children:m}),e.jsx("button",{type:"button",onClick:()=>y(S),className:"flex items-center justify-center w-8 h-8 rounded-md border-none cursor-pointer",style:{background:"transparent",color:t.textMuted},"aria-label":"Remove failure mode",title:"Remove failure mode",children:e.jsx(J,{size:14})})]},S)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(z,{value:i,onChange:m=>p(m.target.value),onKeyDown:F,placeholder:"Add a potential failure mode...",className:"flex-1"}),e.jsxs(Y,{onClick:g,variant:"secondary",size:"sm",disabled:!i.trim(),title:"Add failure mode",className:"flex items-center gap-1",children:[e.jsx(ae,{size:14}),"Add"]})]})]})]})]})})}function yt({workflowSteps:s,collapsed:o,onToggle:r}){const n=N();return e.jsx($,{icon:Qe,label:"Workflow Steps",color:"#e67e22",collapsed:o,onToggle:r,children:s.length===0?e.jsx("div",{className:"text-center py-8 text-sm",style:{color:n.textDim},children:"No workflow steps defined. The agent will operate without a structured workflow."}):e.jsx("div",{className:"space-y-2",children:s.map((t,l)=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded",style:{background:n.surfaceElevated},children:[e.jsx("span",{className:"flex items-center justify-center w-6 h-6 rounded-full text-xs font-bold",style:{background:"#e67e22",color:"white"},children:l+1}),e.jsx("span",{className:"flex-1 text-sm",style:{color:n.textPrimary},children:t.label}),e.jsx("span",{className:"text-xs px-2 py-1 rounded",style:{background:n.badgeBg,color:n.textDim},children:t.action})]},l))})})}function bt({outputFormat:s,setOutputFormat:o,selectedModel:r,tokenBudget:n,collapsed:t,onToggle:l}){const c=N(),i=U(a=>a.getAllModels),p=U(a=>a.providers),h=f.useMemo(()=>i().map(a=>({value:`${a.providerId}::${a.id}`,label:`${a.providerName} / ${a.label}`})),[i,p]);return e.jsx($,{icon:Ze,label:"Output Configuration",color:"#f1c40f",collapsed:t,onToggle:l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(Q,{label:"Output Format",options:we.map(a=>({value:a.id,label:a.label})),value:s,onChange:a=>o(a)}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx("div",{children:e.jsx(Q,{label:"Model",options:h,value:r,onChange:a=>j.getState().setModel(a)})}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-sm font-medium mb-2",style:{color:c.textPrimary},children:"Token Budget"}),e.jsx("div",{className:"p-2 rounded",style:{background:c.surfaceElevated,color:c.textSecondary},children:n?.toLocaleString()||"Default"})]})]})]})})}function vt({onExport:s,onExportFormat:o,onPromptPreview:r,saveStatus:n}){const t=N(),[l,c]=f.useState(!1),i={display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",background:"#FE5000",color:"white",border:"none",borderRadius:"6px",fontSize:"14px",fontWeight:"500",fontFamily:"'Geist Sans', sans-serif",cursor:"pointer",transition:"all 0.15s ease"},p={display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",background:"transparent",color:t.textSecondary,border:`1px solid ${t.border}`,borderRadius:"6px",fontSize:"14px",fontWeight:"500",fontFamily:"'Geist Sans', sans-serif",cursor:"pointer",transition:"all 0.15s ease"},h={position:"absolute",top:"100%",left:0,right:0,background:t.surfaceElevated,border:`1px solid ${t.border}`,borderRadius:"6px",marginTop:"4px",zIndex:1e3,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"},a=f.useCallback(g=>{o(g),c(!1)},[o]);return e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("button",{type:"button",onClick:r,className:"flex items-center gap-2 px-4 py-2 text-sm rounded border",style:{background:"transparent",color:t.textSecondary,borderColor:t.border,fontFamily:"'Geist Sans', sans-serif"},children:[e.jsx(qe,{size:14}),"Prompt Preview"]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>c(!l),"aria-expanded":l,"aria-haspopup":"menu","aria-label":"Export agent configuration in different formats",style:i,children:[e.jsx(re,{size:14}),"Export",e.jsx(et,{size:12})]}),l&&e.jsx("div",{role:"menu",style:h,children:["JSON","YAML","Markdown","Claude format","OpenAI format"].map(g=>e.jsx("button",{type:"button",role:"menuitem",onClick:()=>a(g),"aria-label":`Export agent configuration as ${g}`,className:"w-full px-4 py-2 text-left text-sm hover:bg-gray-100",style:{background:"transparent",border:"none",color:t.textPrimary,cursor:"pointer"},children:g},g))})]}),e.jsxs("button",{type:"button",onClick:s,style:i,children:[e.jsx(re,{size:16}),"Export Agent"]}),e.jsxs("button",{type:"button",disabled:n==="saving",onClick:()=>{const g=O.getState();if(!g.agentId){const y=`agent-${Date.now()}`;g.setAgentId(y)}g.saveToServer("Manual save")},style:{...p,opacity:n==="saving"?.6:1,cursor:n==="saving"?"not-allowed":"pointer"},children:[e.jsx(de,{size:16}),n==="saving"?"Saving...":"Save Draft"]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{background:n==="saved"?"#22c55e":n==="saving"?"#f59e0b":n==="error"?"#ef4444":"#6b7280"}}),e.jsx("span",{style:{color:t.textSecondary,fontSize:"13px"},children:n==="saved"?"Saved":n==="saving"?"Saving...":n==="error"?"Save failed":"Unsaved changes"})]})]})}function jt(s){const o=j.getState(),r=[o.agentMeta.name&&`Agent: ${o.agentMeta.name}`,o.agentMeta.description&&`Description: ${o.agentMeta.description}`,o.instructionState.persona&&`Persona: ${o.instructionState.persona.slice(0,200)}`,o.instructionState.objectives.primary&&`Objective: ${o.instructionState.objectives.primary}`,o.instructionState.constraints.customConstraints&&`Constraints: ${o.instructionState.constraints.customConstraints.slice(0,200)}`,o.workflowSteps.length>0&&`Workflow: ${o.workflowSteps.map(t=>t.label).join(" → ")}`,o.channels.filter(t=>t.enabled).length>0&&`Knowledge: ${o.channels.filter(t=>t.enabled).map(t=>t.name).join(", ")}`,o.mcpServers.filter(t=>t.enabled!==!1).length>0&&`MCP: ${o.mcpServers.filter(t=>t.enabled!==!1).map(t=>t.name).join(", ")}`,o.skills.filter(t=>t.enabled!==!1).length>0&&`Skills: ${o.skills.filter(t=>t.enabled!==!1).map(t=>t.name).join(", ")}`].filter(Boolean).join(`
|
|
29
|
+
`),n=s.map((t,l)=>`${l+1}. [${t.id}] "${t.content}" (type: ${t.type}, tags: ${t.tags.join(",")})`).join(`
|
|
30
|
+
`);return`You are an expert agent architect analyzing runtime memory facts to improve an agent's design.
|
|
31
|
+
|
|
32
|
+
<agent_context>
|
|
33
|
+
${r}
|
|
34
|
+
</agent_context>
|
|
35
|
+
|
|
36
|
+
<facts>
|
|
37
|
+
${n}
|
|
38
|
+
</facts>
|
|
39
|
+
|
|
40
|
+
Analyze each fact and determine if it should be PROMOTED from runtime memory into a structured agent component. Facts that encode persistent patterns, preferences, or capabilities should graduate into the agent's design.
|
|
41
|
+
|
|
42
|
+
Promotion targets:
|
|
43
|
+
- "instruction": Fact describes HOW the agent should behave → append to persona or instructions
|
|
44
|
+
- "constraint": Fact is a rule or limitation → add as a constraint
|
|
45
|
+
- "workflow": Fact describes a recurring process → add as a workflow step
|
|
46
|
+
- "knowledge": Fact points to a data source the agent needs → add as knowledge source
|
|
47
|
+
- "mcp": Fact mentions a tool/API the agent should use → suggest MCP server
|
|
48
|
+
- "skill": Fact describes a capability the agent needs → suggest a skill
|
|
49
|
+
- "keep": Fact is volatile/contextual → keep in runtime memory
|
|
50
|
+
|
|
51
|
+
Output ONLY valid JSON:
|
|
52
|
+
{
|
|
53
|
+
"promotions": [
|
|
54
|
+
{
|
|
55
|
+
"factId": "<id from facts list>",
|
|
56
|
+
"factContent": "<the fact text>",
|
|
57
|
+
"target": "<promotion target>",
|
|
58
|
+
"confidence": <0.0-1.0>,
|
|
59
|
+
"suggestion": "<human-readable suggestion>",
|
|
60
|
+
"reason": "<why this promotion improves the agent>",
|
|
61
|
+
"payload": {
|
|
62
|
+
"constraintText": "<if target=constraint>",
|
|
63
|
+
"workflowStep": { "label": "<step name>", "action": "<what to do>" },
|
|
64
|
+
"knowledgeSource": { "name": "<source name>", "type": "<ground-truth|signal|evidence|framework>" },
|
|
65
|
+
"mcpServerId": "<id from MCP registry if target=mcp>",
|
|
66
|
+
"skillId": "<skill id if target=skill>",
|
|
67
|
+
"instructionAppend": "<text to append to persona if target=instruction>"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"summary": "<one sentence summary of recommended changes>",
|
|
72
|
+
"versionImpact": "<major|minor|patch|none>"
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
Rules:
|
|
76
|
+
- Only promote facts with confidence >= 0.6
|
|
77
|
+
- Facts that are temporary/contextual should stay as "keep"
|
|
78
|
+
- Prefer fewer high-confidence promotions over many low-confidence ones
|
|
79
|
+
- Include payload fields ONLY for the relevant target (omit others)
|
|
80
|
+
- versionImpact: major if persona/objective changes, minor if adding knowledge/tools/steps, patch if constraints only`}async function kt(s){const o=U.getState(),r=o.providers.find(t=>t.id===o.selectedProviderId);if(!r)throw new Error("No provider configured — add one in Settings");const n=typeof r.models?.[0]=="object"?r.models[0].id:r.models?.[0]||"claude-sonnet-4-20250514";return r.authMethod==="claude-agent-sdk"?le({prompt:s,model:n,maxTurns:1}):ce({providerId:r.id,model:n,messages:[{role:"user",content:s}],temperature:.3,maxTokens:4096})}function wt(s){try{return JSON.parse(s)}catch{}const o=s.match(/```(?:json)?\s*([\s\S]*?)```/);if(o)try{return JSON.parse(o[1].trim())}catch{}const r=s.match(/\{[\s\S]*\}/);if(r)try{return JSON.parse(r[0])}catch{}throw new Error("Could not parse analysis response")}async function St(s){if(s.length===0)return{promotions:[],summary:"No facts to analyze",versionImpact:"none"};const o=jt(s),r=await kt(o),n=wt(r);return n.promotions=n.promotions.filter(t=>t.confidence>=.6&&t.target!=="keep").sort((t,l)=>l.confidence-t.confidence),n}function Ct(){const s=N(),o=X(x=>x.facts),r=X(x=>x.removeFact),n=j(x=>x.updateInstruction),t=j(x=>x.instructionState),l=j(x=>x.addWorkflowStep),c=j(x=>x.addChannel),i=O(x=>x.checkpoint),[p,h]=f.useState(o.length===0),[a,g]=f.useState(!1),[y,w]=f.useState(null),[F,u]=f.useState(new Set),[m,S]=f.useState(""),I=f.useCallback(async()=>{if(o.length!==0){g(!0),S(""),u(new Set);try{const x=await St(o);w(x),p&&h(!1)}catch(x){S(x instanceof Error?x.message:"Analysis failed")}g(!1)}},[o,p]),A=f.useCallback(x=>{const C=x.payload;switch(x.target){case"instruction":if(C.instructionAppend){const P=t.persona;n({persona:P?`${P}
|
|
81
|
+
|
|
82
|
+
${C.instructionAppend}`:C.instructionAppend})}break;case"constraint":if(C.constraintText){const P=t.constraints.customConstraints;n({constraints:{...t.constraints,customConstraints:P?`${P}
|
|
83
|
+
${C.constraintText}`:C.constraintText}})}break;case"workflow":C.workflowStep&&l({label:C.workflowStep.label,action:C.workflowStep.action,tool:"",condition:"always"});break;case"knowledge":C.knowledgeSource&&c({sourceId:`promoted-${crypto.randomUUID().slice(0,8)}`,name:C.knowledgeSource.name,path:"",category:"knowledge",knowledgeType:C.knowledgeSource.type,depth:0,baseTokens:500});break}u(P=>new Set([...P,x.factId])),r(x.factId)},[t,n,l,c,r]),H=f.useCallback(()=>{if(y){for(const x of y.promotions)F.has(x.factId)||A(x);i("Facts promoted to agent design")}},[y,F,A,i]);if(o.length===0&&!y)return null;const M=y?y.promotions.filter(x=>!F.has(x.factId)).length:0;return e.jsxs("div",{className:"mt-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{size:16,style:{color:"#FE5000"}}),e.jsx("h4",{className:"text-sm font-semibold",style:{color:s.textPrimary,fontFamily:"'Geist Sans', sans-serif"},children:"Fact Insights"}),y&&M>0&&e.jsxs("span",{className:"text-xs px-2 py-1 rounded",style:{background:"#FE500015",color:"#FE5000"},children:[M," suggestion",M!==1?"s":""]}),!y&&o.length>0&&e.jsxs("span",{className:"text-xs px-2 py-1 rounded",style:{background:s.isDark?"#1c1c20":"#f3f4f6",color:s.textDim},children:[o.length," facts to analyze"]})]}),e.jsx("button",{type:"button",onClick:()=>h(!p),title:p?"Show insights":"Hide insights",className:"text-xs border-none bg-transparent cursor-pointer",style:{color:s.textDim},children:p?"Show":"Hide"})]}),!p&&e.jsxs("div",{className:"space-y-3",children:[!y&&o.length>0&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("div",{className:"text-[12px] leading-relaxed",style:{color:s.textDim},children:"Analyze accumulated facts to discover which should become permanent parts of your agent — instructions, constraints, workflow steps, or knowledge sources."}),e.jsxs("button",{type:"button",onClick:I,disabled:a||o.length===0,title:a?"Analyzing facts":"Analyze for promotions",className:"flex items-center justify-center gap-1.5 w-full px-3 py-2.5 rounded text-[13px] tracking-wide uppercase cursor-pointer border-none",style:{background:a?"#CC4000":"#FE5000",color:"#fff",fontFamily:"'Geist Mono', monospace",opacity:a||o.length===0?.6:1},children:[a?e.jsx(tt,{size:11,className:"animate-spin"}):e.jsx(Z,{size:11}),a?"Analyzing...":`Analyze ${o.length} fact${o.length!==1?"s":""}`]})]}),m&&e.jsx("div",{className:"text-xs text-red-500 p-2 rounded",style:{background:"#fee2e2"},children:m}),y&&M>0&&e.jsxs("button",{type:"button",onClick:H,title:"Apply all suggestions",className:"flex items-center justify-center gap-1.5 w-full px-3 py-2 rounded text-[12px] tracking-wide uppercase cursor-pointer border-none",style:{background:"#2ecc7120",color:"#2ecc71",fontFamily:"'Geist Mono', monospace"},children:["Apply all ",M," suggestions"]}),y&&M===0&&e.jsx("div",{className:"text-xs text-green-600 p-2 rounded",style:{background:"#f0fdf4"},children:"✅ All insights applied to your agent configuration."})]})]})}function Nt({isOpen:s,onClose:o,prompt:r}){const n=N(),[t,l]=f.useState("Copy"),c=async()=>{try{await navigator.clipboard.writeText(r),l("Copied!"),setTimeout(()=>l("Copy"),2e3)}catch(i){console.error("Failed to copy:",i)}};return s?e.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-50",style:{background:"rgba(0, 0, 0, 0.5)",backdropFilter:"blur(4px)"},onClick:o,children:e.jsxs("div",{className:"w-full h-[80vh] m-4 rounded-lg border shadow-lg flex flex-col",style:{background:n.surface,borderColor:n.border},onClick:i=>i.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",style:{borderColor:n.border},children:[e.jsx("h3",{className:"text-lg font-semibold m-0",style:{color:n.textPrimary,fontFamily:"'Geist Sans', sans-serif"},children:"System Prompt Preview"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:c,className:"flex items-center gap-2 px-3 py-2 text-sm rounded border",style:{background:"transparent",color:n.textSecondary,borderColor:n.border},children:[t==="Copy"?e.jsx(st,{size:14}):e.jsx(ot,{size:14}),t]}),e.jsx("button",{type:"button",onClick:o,className:"flex items-center justify-center w-8 h-8 rounded-md border-none cursor-pointer",style:{background:"transparent",color:n.textSecondary},"aria-label":"Close modal",children:e.jsx(J,{size:16})})]})]}),e.jsx("div",{className:"flex-1 p-4 overflow-y-auto",children:e.jsx("div",{className:"p-4 rounded-lg border h-full",style:{background:n.isDark?"#0a1929":"#f8fafc",borderColor:n.border},children:e.jsx("pre",{className:"h-full whitespace-pre-wrap",style:{fontSize:"14px",color:n.textSecondary,fontFamily:"'Geist Mono', monospace",lineHeight:1.5,margin:0},children:r||"No system prompt generated yet. Add persona, constraints, or workflow steps to see the preview."})})})]})}):null}function $t(){const s=j(d=>d.agentMeta),o=j(d=>d.setAgentMeta),r=j(d=>d.instructionState),n=j(d=>d.updateInstruction),t=j(d=>d.workflowSteps),l=j(d=>d.channels),c=j(d=>d.selectedModel),i=j(d=>d.outputFormat),p=j(d=>d.setOutputFormat),h=j(d=>d.outputFormats),a=j(d=>d.prompt),g=j(d=>d.tokenBudget),y=j(d=>d.mcpServers),w=j(d=>d.skills),F=O(d=>d.saveStatus),[u,m]=f.useState(!1),[S,I]=f.useState(!1),[A,H]=f.useState(!1),[M,x]=f.useState(!1),[C,P]=f.useState(!1),[ee,fe]=f.useState(!1),[xe,te]=f.useState(!1),G=f.useCallback(()=>{const d=j.getState(),b=Se.getState(),E=X.getState(),v=l.filter(k=>k.enabled).map(k=>({sourceId:k.sourceId,name:k.name,path:k.path,knowledgeType:k.knowledgeType,depth:k.depth,tokens:k.baseTokens,content:k.content})),T=b.lastPipelineStats?.pipeline,_=T?{context:T.context,tokens:T.tokens,utilization:T.utilization,sources:T.sources.map(k=>({name:k.name,type:k.type,totalTokens:k.totalTokens})),compression:{originalTokens:T.compression.originalTokens,compressedTokens:T.compression.compressedTokens,ratio:T.compression.ratio},timing:{totalMs:T.timing.totalMs}}:void 0,se=E.facts.map(k=>({id:k.id,text:k.content,domain:k.domain}));return{channels:l,selectedModel:c,outputFormat:i,outputFormats:h,prompt:a,tokenBudget:g,mcpServers:y,skills:w,agentMeta:s,agentConfig:d.agentConfig,connectors:d.connectors,instructionState:d.instructionState,workflowSteps:d.workflowSteps,knowledgeContent:v,pipelineSnapshot:_,facts:se.length>0?se:void 0}},[l,c,i,h,a,g,y,w,s,t]),ge=f.useCallback(()=>{const d=G(),b=Ne(d),E=b.match(/^name:\s*(.+)$/m)?.[1]?.trim()??"modular-agent";B(b,E)},[G]),he=f.useCallback(d=>{const b=G(),E=b.agentMeta.name||"modular-agent";switch(d){case"JSON":{const v=Ee(b);B(v,E,".json");break}case"YAML":{const v=Fe(b);B(v,E,".yaml");break}case"Markdown":case"Claude format":{const v=oe("claude",b);B(v,E,".md");break}case"OpenAI format":{const v=oe("codex",b);B(v,E,".json");break}}},[G]),{constraints:D}=r,R=D.customConstraints?D.customConstraints.split(`
|
|
84
|
+
`).filter(d=>d.trim()):[],ye=d=>{if(d&&!R.includes(d)){const b=[...R,d];n({constraints:{...D,customConstraints:b.join(`
|
|
85
|
+
`)}})}},be=d=>{const b=R.filter(E=>E!==d);n({constraints:{...D,customConstraints:b.join(`
|
|
86
|
+
`)}})},ve=()=>{const{persona:d,constraints:b,objectives:E}=r;let v="";return d&&(v+=`You are ${s.name||"an AI assistant"}.
|
|
87
|
+
|
|
88
|
+
${d}
|
|
89
|
+
|
|
90
|
+
`),(R.length>0||b.neverMakeUp||b.askBeforeActions)&&(v+=`CONSTRAINTS:
|
|
91
|
+
`,b.neverMakeUp&&(v+=`- Never fabricate information. If you don't know something, say so.
|
|
92
|
+
`),b.askBeforeActions&&(v+=`- Always ask for permission before taking actions that could affect the user's system.
|
|
93
|
+
`),b.stayInScope&&(v+=`- Stay within the defined scope of your role and responsibilities.
|
|
94
|
+
`),b.useOnlyTools&&(v+=`- Only use the tools and information sources provided to you.
|
|
95
|
+
`),b.limitWords&&b.wordLimit>0&&(v+=`- Keep responses concise, under ${b.wordLimit} words when possible.
|
|
96
|
+
`),R.forEach(T=>{v+=`- ${T}
|
|
97
|
+
`}),v+=`
|
|
98
|
+
`),E.primary&&(v+=`PRIMARY OBJECTIVE: ${E.primary}
|
|
99
|
+
|
|
100
|
+
`),t.length>0&&(v+=`WORKFLOW:
|
|
101
|
+
`,t.forEach((T,_)=>{v+=`${_+1}. ${T.label}
|
|
102
|
+
`}),v+=`
|
|
103
|
+
`),v.trim()},je={color:"var(--text-primary)",fontFamily:"'Geist Sans', sans-serif"},ke={color:"var(--text-secondary)",lineHeight:1.5};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-semibold mb-2 m-0",style:je,children:"Review & Configure"}),e.jsx("p",{className:"text-sm",style:ke,children:"Review and finalize your agent's configuration. Customize the identity, persona, constraints, and output settings before testing."})]}),e.jsx(vt,{onExport:ge,onExportFormat:he,onPromptPreview:()=>te(!0),saveStatus:F}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(ct,{agentMeta:s,setAgentMeta:o,collapsed:u,onToggle:()=>m(!u)}),e.jsx(ft,{persona:r.persona,tone:r.tone,expertise:r.expertise,updateInstruction:n,collapsed:S,onToggle:()=>I(!S)}),e.jsx(gt,{constraints:D,updateInstruction:n,customConstraints:R,addCustomConstraint:ye,removeCustomConstraint:be,collapsed:A,onToggle:()=>H(!A)}),e.jsx(ht,{objectives:r.objectives,updateInstruction:n,collapsed:M,onToggle:()=>x(!M)}),e.jsx(yt,{workflowSteps:t,collapsed:C,onToggle:()=>P(!C)}),e.jsx(bt,{selectedModel:c,outputFormat:i,setOutputFormat:d=>p(d),tokenBudget:g,collapsed:ee,onToggle:()=>fe(!ee)})]}),e.jsx(Ct,{}),e.jsx("div",{className:"mt-4",children:e.jsx(lt,{})}),e.jsx(Nt,{isOpen:xe,onClose:()=>te(!1),prompt:ve()})]})}export{$t as ReviewTab};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./vendor-D1h_O76p.js";import{u as p}from"./index-q24ug5Qs.js";import{C as u,a as h}from"./icons-C2EV-le6.js";function g({checked:n,onChange:r,label:i,size:o="md",disabled:s}){const a=p(),l=o==="sm"?28:36,d=o==="sm"?16:20,t=o==="sm"?12:16;return e.jsxs("button",{type:"button",role:"switch","aria-checked":n,onClick:()=>!s&&r(!n),className:"flex items-center gap-2 cursor-pointer border-none bg-transparent p-0 nodrag",style:{opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},children:[e.jsx("div",{className:"relative rounded-full transition-colors",style:{width:l,height:d,background:n?"#FE5000":a.border},children:e.jsx("div",{className:"absolute top-[2px] rounded-full bg-white transition-transform",style:{width:t,height:t,transform:`translateX(${n?l-t-2:2}px)`,transition:"transform 0.15s ease"}})}),i&&e.jsx("span",{className:"text-[13px]",style:{color:a.textSecondary},children:i})]})}function j({icon:n,label:r,color:i,badge:o,collapsed:s,onToggle:a,children:l,id:d}){const t=p(),c=d||`section-${r.toLowerCase().replace(/\s+/g,"-")}`,m=`${c}-content`;return e.jsxs("section",{role:"region","aria-labelledby":`${c}-heading`,className:"mb-6",style:{border:`1px solid ${t.border}`,borderRadius:"8px",overflow:"hidden"},children:[e.jsx("h3",{id:`${c}-heading`,className:"m-0",children:e.jsxs("button",{type:"button",onClick:a,"aria-expanded":!s,"aria-controls":m,className:"flex items-center gap-2 w-full px-5 py-3.5 border-none cursor-pointer select-none transition-colors",style:{background:t.surfaceElevated},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),a())},children:[e.jsx(n,{size:16,style:{color:i,flexShrink:0}}),s?e.jsx(u,{size:12,style:{color:t.textDim},"aria-hidden":"true"}):e.jsx(h,{size:12,style:{color:t.textDim},"aria-hidden":"true"}),e.jsx("span",{className:"text-sm font-semibold flex-1 text-left",style:{fontFamily:"'Geist Sans', sans-serif",color:t.textPrimary},children:r}),o&&e.jsx("span",{className:"text-[13px] px-2 py-1 rounded-full",style:{fontFamily:"'Geist Mono', monospace",color:t.textDim,background:t.badgeBg},"aria-label":`${r} status: ${o}`,children:o}),e.jsxs("span",{className:"sr-only",children:[s?"Expand":"Collapse"," ",r," section"]})]})}),!s&&e.jsx("div",{id:m,className:"px-5 pb-4",role:"region","aria-labelledby":`${c}-heading`,children:l})]})}export{j as S,g as T};
|