stagent 0.1.9 → 0.1.11
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 +144 -62
- package/package.json +1 -2
- package/public/readme/cost-usage-list.png +0 -0
- package/public/readme/dashboard-bulk-select.png +0 -0
- package/public/readme/dashboard-card-edit.png +0 -0
- package/public/readme/dashboard-create-form-ai-applied.png +0 -0
- package/public/readme/dashboard-create-form-ai-assist.png +0 -0
- package/public/readme/dashboard-create-form-empty.png +0 -0
- package/public/readme/dashboard-create-form-filled.png +0 -0
- package/public/readme/dashboard-filtered.png +0 -0
- package/public/readme/dashboard-list.png +0 -0
- package/public/readme/dashboard-sorted.png +0 -0
- package/public/readme/dashboard-workflow-confirm.png +0 -0
- package/public/readme/documents-grid.png +0 -0
- package/public/readme/documents-list.png +0 -0
- package/public/readme/home-below-fold.png +0 -0
- package/public/readme/home-list.png +0 -0
- package/public/readme/inbox-list.png +0 -0
- package/public/readme/monitor-list.png +0 -0
- package/public/readme/profiles-list.png +0 -0
- package/public/readme/projects-detail.png +0 -0
- package/public/readme/projects-list.png +0 -0
- package/public/readme/schedules-list.png +0 -0
- package/public/readme/settings-list.png +0 -0
- package/public/readme/workflows-list.png +0 -0
- package/src/app/api/profiles/route.ts +0 -1
- package/src/app/api/workflows/from-assist/route.ts +143 -0
- package/src/app/dashboard/page.tsx +24 -2
- package/src/app/globals.css +0 -5
- package/src/app/tasks/page.tsx +5 -0
- package/src/app/workflows/from-assist/page.tsx +35 -0
- package/src/components/profiles/profile-detail-view.tsx +1 -16
- package/src/components/profiles/profile-form-view.tsx +0 -22
- package/src/components/projects/project-card.tsx +47 -35
- package/src/components/tasks/ai-assist-panel.tsx +31 -10
- package/src/components/tasks/task-card.tsx +16 -1
- package/src/components/tasks/task-create-panel.tsx +39 -0
- package/src/components/workflows/workflow-confirmation-view.tsx +447 -0
- package/src/lib/agents/__tests__/claude-agent.test.ts +7 -2
- package/src/lib/agents/__tests__/learned-context.test.ts +500 -0
- package/src/lib/agents/__tests__/pattern-extractor.test.ts +243 -0
- package/src/lib/agents/__tests__/sweep.test.ts +202 -0
- package/src/lib/agents/claude-agent.ts +104 -78
- package/src/lib/agents/learned-context.ts +5 -13
- package/src/lib/agents/pattern-extractor.ts +15 -64
- package/src/lib/agents/profiles/__tests__/suggest.test.ts +67 -0
- package/src/lib/agents/profiles/builtins/code-reviewer/profile.yaml +0 -1
- package/src/lib/agents/profiles/builtins/data-analyst/profile.yaml +0 -1
- package/src/lib/agents/profiles/builtins/devops-engineer/profile.yaml +0 -1
- package/src/lib/agents/profiles/builtins/document-writer/profile.yaml +0 -1
- package/src/lib/agents/profiles/builtins/general/profile.yaml +0 -1
- package/src/lib/agents/profiles/builtins/health-fitness-coach/profile.yaml +0 -1
- package/src/lib/agents/profiles/builtins/learning-coach/profile.yaml +0 -1
- package/src/lib/agents/profiles/builtins/project-manager/profile.yaml +0 -1
- package/src/lib/agents/profiles/builtins/researcher/profile.yaml +0 -1
- package/src/lib/agents/profiles/builtins/shopping-assistant/profile.yaml +0 -1
- package/src/lib/agents/profiles/builtins/sweep/profile.yaml +0 -1
- package/src/lib/agents/profiles/builtins/technical-writer/profile.yaml +0 -1
- package/src/lib/agents/profiles/builtins/travel-planner/profile.yaml +0 -1
- package/src/lib/agents/profiles/builtins/wealth-manager/profile.yaml +0 -1
- package/src/lib/agents/profiles/registry.ts +0 -1
- package/src/lib/agents/profiles/suggest.ts +36 -0
- package/src/lib/agents/profiles/types.ts +0 -1
- package/src/lib/agents/runtime/catalog.ts +1 -1
- package/src/lib/agents/runtime/claude.ts +102 -6
- package/src/lib/agents/runtime/task-assist-types.ts +12 -2
- package/src/lib/constants/task-status.ts +6 -0
- package/src/lib/data/__tests__/clear.test.ts +42 -0
- package/src/lib/data/clear.ts +3 -0
- package/src/lib/data/seed-data/profiles.ts +0 -3
- package/src/lib/notifications/permissions.ts +6 -2
- package/src/lib/usage/__tests__/ledger.test.ts +29 -5
- package/src/lib/usage/ledger.ts +3 -1
- package/src/lib/usage/pricing.ts +61 -7
- package/src/lib/validators/__tests__/profile.test.ts +0 -15
- package/src/lib/validators/profile.ts +0 -1
- package/src/lib/workflows/__tests__/assist-builder.test.ts +255 -0
- package/src/lib/workflows/__tests__/engine.test.ts +2 -0
- package/src/lib/workflows/assist-builder.ts +248 -0
- package/src/lib/workflows/assist-session.ts +78 -0
- package/src/lib/workflows/engine.ts +47 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Open [localhost:3000](http://localhost:3000).
|
|
|
14
14
|
|
|
15
15
|
**Profiles & Policies** · **Blueprints & Schedules** · **Open Source**
|
|
16
16
|
|
|
17
|
-
<img src="https://raw.githubusercontent.com/navam-io/stagent/main/public/readme/home-
|
|
17
|
+
<img src="https://raw.githubusercontent.com/navam-io/stagent/main/public/readme/home-list.png" alt="Stagent home workspace" width="1200" />
|
|
18
18
|
|
|
19
19
|
| Home Workspace | Reusable Profiles | Workflow Blueprints | Governed Execution |
|
|
20
20
|
|:-:|:-:|:-:|:-:|
|
|
@@ -53,6 +53,9 @@ Stagent ships a shared runtime registry that routes tasks, schedules, and workfl
|
|
|
53
53
|
| 💸 | **[Cost & Usage](#cost--usage)** | Provider-aware metering, budgets, and spend visibility for governed runs |
|
|
54
54
|
| 🚨 | **[Ambient Approvals](#ambient-approvals)** | Shell-level approval prompts that keep Inbox as the durable supervision queue |
|
|
55
55
|
| 🔒 | **[Tool Permissions](#tool-permission-persistence)** | Trusted-tool policies with explicit "Always Allow" rules |
|
|
56
|
+
| 📋 | **[Kanban Board](#kanban-board-operations)** | Inline editing, bulk operations, and persistent board state |
|
|
57
|
+
| 🤖 | **[AI Assist → Workflows](#ai-assist--workflow-creation)** | Bridge task assist recommendations into governed workflow execution |
|
|
58
|
+
| 🧬 | **[Agent Self-Improvement](#agent-self-improvement)** | Agents learn patterns from execution history with human-approved context evolution |
|
|
56
59
|
|
|
57
60
|
---
|
|
58
61
|
|
|
@@ -69,6 +72,7 @@ Stagent ships a shared runtime registry that routes tasks, schedules, and workfl
|
|
|
69
72
|
- **Provider runtime abstraction** — Tasks, schedules, workflows, task assist, and health checks route through shared runtime adapters instead of provider-specific entry points
|
|
70
73
|
- **Reusable agent profiles** — Profiles define instructions, allowed tools, runtime tuning, and MCP configs for repeated use
|
|
71
74
|
- **Permission pre-check** — Saved "Always Allow" patterns bypass the notification loop for trusted tools
|
|
75
|
+
- **Learned context loop** — Pattern extraction → human approval → versioned context injection creates a supervised self-improvement cycle
|
|
72
76
|
|
|
73
77
|
---
|
|
74
78
|
|
|
@@ -82,9 +86,19 @@ Workspace-level briefing with active work, pending review, failed items, project
|
|
|
82
86
|
#### Task Execution
|
|
83
87
|
Status-driven execution board with five columns: Planned → Queued → Running → Completed → Failed. Filter across projects, create tasks inline, and open task detail to inspect status, description, and runtime state without leaving the board.
|
|
84
88
|
|
|
89
|
+
<img src="https://raw.githubusercontent.com/navam-io/stagent/main/public/readme/dashboard-list.png" alt="Stagent kanban board" width="1200" />
|
|
90
|
+
|
|
91
|
+
| Filtered by Project | Inline Card Editing | Bulk Select Mode |
|
|
92
|
+
|:-:|:-:|:-:|
|
|
93
|
+
| <img src="https://raw.githubusercontent.com/navam-io/stagent/main/public/readme/dashboard-filtered.png" alt="Dashboard filtered by project" width="380" /> | <img src="https://raw.githubusercontent.com/navam-io/stagent/main/public/readme/dashboard-card-edit.png" alt="Inline task editing dialog" width="380" /> | <img src="https://raw.githubusercontent.com/navam-io/stagent/main/public/readme/dashboard-bulk-select.png" alt="Bulk select mode with actions" width="380" /> |
|
|
94
|
+
|
|
85
95
|
#### Projects
|
|
86
96
|
Create and organize projects as containers for related tasks. Each project can specify a working directory — agent tasks resolve `cwd` from the project's path, enabling agents to operate on external codebases. Server-rendered project cards with task counts, status badges, and a detail view at `/projects/[id]`.
|
|
87
97
|
|
|
98
|
+
| Project Cards | Project Detail |
|
|
99
|
+
|:-:|:-:|
|
|
100
|
+
| <img src="https://raw.githubusercontent.com/navam-io/stagent/main/public/readme/projects-list.png" alt="Project cards overview" width="580" /> | <img src="https://raw.githubusercontent.com/navam-io/stagent/main/public/readme/projects-detail.png" alt="Project detail view" width="580" /> |
|
|
101
|
+
|
|
88
102
|
### Agent
|
|
89
103
|
|
|
90
104
|
#### Provider Runtimes
|
|
@@ -101,13 +115,18 @@ Claude Agent SDK integration with the `canUseTool` polling pattern remains the d
|
|
|
101
115
|
OpenAI Codex App Server is integrated as Stagent's second governed runtime. Codex-backed tasks preserve project working directories, document context, resumable thread IDs, inbox approval requests, user questions, and provider-labeled logs. The same runtime can also power task assist, scheduled firings, and workflow child tasks.
|
|
102
116
|
|
|
103
117
|
#### Agent Profiles
|
|
104
|
-
Profile-backed execution with specialist definitions for different job types. Each profile packages instructions, allowed tools,
|
|
118
|
+
Profile-backed execution with specialist definitions for different job types. Each profile packages instructions, allowed tools, max turns, and output format so teams can reuse behavior intentionally instead of relying on ad hoc prompts. Workflow steps and schedules can reference profiles directly, and runtimes can be selected independently when provider support differs.
|
|
119
|
+
|
|
120
|
+
<img src="https://raw.githubusercontent.com/navam-io/stagent/main/public/readme/profiles-list.png" alt="Stagent agent profiles" width="1200" />
|
|
105
121
|
|
|
106
122
|
#### Workflows
|
|
107
|
-
Multi-step task orchestration with
|
|
123
|
+
Multi-step task orchestration with six patterns:
|
|
108
124
|
- **Sequence** — Steps execute in order
|
|
109
125
|
- **Planner→Executor** — One agent plans, another executes each step
|
|
110
126
|
- **Human-in-the-Loop Checkpoint** — Pauses for human approval between steps
|
|
127
|
+
- **Parallel** — Concurrent branch execution with fork/join synthesis
|
|
128
|
+
- **Loop** — Iterative agent execution with configurable stop conditions
|
|
129
|
+
- **Swarm** — Mayor/workers/refinery multi-agent orchestration
|
|
111
130
|
|
|
112
131
|
State machine engine with step-level retry, project association, and real-time status visualization.
|
|
113
132
|
|
|
@@ -121,6 +140,18 @@ Both patterns preserve the same governed task model, runtime selection, monitori
|
|
|
121
140
|
#### AI Task Assist
|
|
122
141
|
AI-powered task creation: generate improved descriptions, break tasks into sub-tasks, recommend workflow patterns, and estimate complexity through the shared runtime task-assist layer. Claude and OpenAI task assist now both route through the provider runtime abstraction.
|
|
123
142
|
|
|
143
|
+
| Task Creation Form | AI Suggestions | AI Applied |
|
|
144
|
+
|:-:|:-:|:-:|
|
|
145
|
+
| <img src="https://raw.githubusercontent.com/navam-io/stagent/main/public/readme/dashboard-create-form-empty.png" alt="Empty task creation form" width="380" /> | <img src="https://raw.githubusercontent.com/navam-io/stagent/main/public/readme/dashboard-create-form-ai-assist.png" alt="AI Assist suggestions panel" width="380" /> | <img src="https://raw.githubusercontent.com/navam-io/stagent/main/public/readme/dashboard-create-form-ai-applied.png" alt="AI suggestions applied to form" width="380" /> |
|
|
146
|
+
|
|
147
|
+
#### AI Assist → Workflow Creation
|
|
148
|
+
Bridge from AI task assist to workflow engine: when task assist recommends a multi-step plan, a "Create as Workflow" button converts the recommendation into a validated workflow definition with per-step profile assignments, dependency ordering, and pattern selection across all six workflow types. The `WorkflowConfirmationSheet` lets operators review and edit steps, profiles, and configuration before creating the workflow. A keyword-based profile suggestion fallback ensures steps get reasonable profile assignments even without the AI classifier.
|
|
149
|
+
|
|
150
|
+
<img src="https://raw.githubusercontent.com/navam-io/stagent/main/public/readme/dashboard-workflow-confirm.png" alt="Workflow creation from AI Assist" width="1200" />
|
|
151
|
+
|
|
152
|
+
#### Agent Self-Improvement
|
|
153
|
+
Agents learn from execution history through a human-approved instruction evolution loop. After each task completion, the pattern extractor analyzes logs and proposes context updates — concise behavioral rules the agent should follow in future runs. Operators approve, reject, or edit proposals before they take effect. Learned context is versioned with rollback support and size-limited summarization to prevent unbounded growth. A sweep agent can audit the codebase for improvement opportunities and create prioritized tasks from its findings.
|
|
154
|
+
|
|
124
155
|
#### Session Management
|
|
125
156
|
Resume failed or cancelled agent tasks with one click. Tracks retry counts (limit: 3), detects expired sessions, and provides atomic claim to prevent duplicate runs.
|
|
126
157
|
|
|
@@ -133,13 +164,17 @@ Curated agent profiles across work and personal domains, built as portable Claud
|
|
|
133
164
|
#### Workflow Blueprints
|
|
134
165
|
Pre-configured workflow templates across work and personal domains. Browse blueprints in a gallery with filtering and search, preview steps and required variables, fill in a dynamic form, and create draft workflows with resolved prompts and profile assignments. Create custom blueprints via YAML or import from GitHub URLs. Lineage tracking connects workflows back to their source blueprint.
|
|
135
166
|
|
|
136
|
-
<img src="https://raw.githubusercontent.com/navam-io/stagent/main/public/readme/
|
|
167
|
+
<img src="https://raw.githubusercontent.com/navam-io/stagent/main/public/readme/workflows-list.png" alt="Stagent workflow management" width="1200" />
|
|
137
168
|
|
|
138
169
|
### Documents
|
|
139
170
|
|
|
140
171
|
#### Document Management
|
|
141
172
|
Full document browser at `/documents` with table and grid views. Upload files with drag-and-drop, preview images/PDFs/markdown/code inline, search by filename and extracted text, and filter by processing status or project. Bulk delete, link/unlink to projects and tasks.
|
|
142
173
|
|
|
174
|
+
| Table View | Grid View |
|
|
175
|
+
|:-:|:-:|
|
|
176
|
+
| <img src="https://raw.githubusercontent.com/navam-io/stagent/main/public/readme/documents-list.png" alt="Documents table view" width="580" /> | <img src="https://raw.githubusercontent.com/navam-io/stagent/main/public/readme/documents-grid.png" alt="Documents grid view" width="580" /> |
|
|
177
|
+
|
|
143
178
|
#### Document Preprocessing
|
|
144
179
|
Automatic text extraction on upload for five file types: text, PDF (pdf-parse), images (image-size), Office documents (mammoth/jszip), and spreadsheets (xlsx). Extracted text, processed paths, and processing errors are tracked per document.
|
|
145
180
|
|
|
@@ -157,22 +192,28 @@ Pending permission requests now surface through a shell-level approval presenter
|
|
|
157
192
|
#### Schedules
|
|
158
193
|
Time-based scheduling for agent tasks with human-friendly intervals (`5m`, `2h`, `1d`) and raw 5-field cron expressions. One-shot and recurring modes with pause/resume lifecycle, expiry limits, and max firings. Each firing creates a child task through the shared execution pipeline, and schedules can now target a runtime explicitly. Scheduler runs as a poll-based engine started via Next.js instrumentation hook.
|
|
159
194
|
|
|
195
|
+
<img src="https://raw.githubusercontent.com/navam-io/stagent/main/public/readme/schedules-list.png" alt="Stagent schedules" width="1200" />
|
|
196
|
+
|
|
160
197
|
#### Micro-Visualizations
|
|
161
198
|
Pure SVG chart primitives (Sparkline, MiniBar, DonutRing) with zero charting dependencies. Integrated into: homepage stats cards (7-day trends), activity feed (24h bar chart), project cards (completion donuts), monitor overview (success rate), and project detail (stacked status + 14-day sparkline). Full accessibility with `role="img"` and `aria-label`.
|
|
162
199
|
|
|
163
200
|
#### Cost & Usage
|
|
164
201
|
Provider-normalized metering tracks token and spend activity across tasks, resumes, workflow child tasks, schedules, task assist, and profile tests. The dedicated `Cost & Usage` surface adds summary cards, trend views, provider/model breakdowns, and budget-aware audit visibility on top of the usage ledger.
|
|
165
202
|
|
|
203
|
+
<img src="https://raw.githubusercontent.com/navam-io/stagent/main/public/readme/cost-usage-list.png" alt="Stagent cost and usage dashboard" width="1200" />
|
|
204
|
+
|
|
166
205
|
### UI & DevEx
|
|
167
206
|
|
|
168
207
|
#### Inbox & Human-in-the-Loop
|
|
169
208
|
When an agent needs approval or input, a notification appears in your inbox. Review tool permission requests with "Allow Once" / "Always Allow" / "Deny" buttons, answer agent questions, and see task completion summaries. Supports bulk dismiss and 10s polling.
|
|
170
209
|
|
|
171
|
-
<img src="https://raw.githubusercontent.com/navam-io/stagent/main/public/readme/inbox-
|
|
210
|
+
<img src="https://raw.githubusercontent.com/navam-io/stagent/main/public/readme/inbox-list.png" alt="Stagent inbox approval flow" width="1200" />
|
|
172
211
|
|
|
173
212
|
#### Monitoring
|
|
174
213
|
Real-time agent log streaming via Server-Sent Events. Filter by task or event type, click entries to jump to task details, and auto-pause polling when the tab is hidden (Page Visibility API).
|
|
175
214
|
|
|
215
|
+
<img src="https://raw.githubusercontent.com/navam-io/stagent/main/public/readme/monitor-list.png" alt="Stagent monitoring dashboard" width="1200" />
|
|
216
|
+
|
|
176
217
|
#### Content Handling
|
|
177
218
|
File upload with drag-and-drop in task creation. Type-aware content preview for text, markdown (via react-markdown), code, and JSON. Copy-to-clipboard and download-as-file for task outputs.
|
|
178
219
|
|
|
@@ -183,7 +224,7 @@ Configuration hub with provider-aware sections: Claude authentication (API key o
|
|
|
183
224
|
The `npx stagent` entry point boots a Next.js server from the published npm package. It is built from `bin/cli.ts` into `dist/cli.js` using tsup, and serves as the primary distribution channel — no clone required.
|
|
184
225
|
|
|
185
226
|
#### Database
|
|
186
|
-
SQLite with WAL mode via better-sqlite3 + Drizzle ORM.
|
|
227
|
+
SQLite with WAL mode via better-sqlite3 + Drizzle ORM. Ten tables: `projects`, `tasks`, `workflows`, `agent_logs`, `notifications`, `documents`, `schedules`, `settings`, `learned_context`, `usage_ledger`. Self-healing bootstrap — tables are created on startup if missing.
|
|
187
228
|
|
|
188
229
|
#### App Shell
|
|
189
230
|
Responsive sidebar with collapsible icon-only mode, custom Stagent logo, tooltip navigation, dark/light/system theme, and OKLCH hue 250 blue-indigo color palette. Built on shadcn/ui (New York style) with PWA manifest and app icons. Routes: Home, Dashboard, Projects, Documents, Workflows, Profiles, Schedules, Inbox, Monitor, Settings.
|
|
@@ -222,66 +263,96 @@ npm run test:coverage # Coverage report
|
|
|
222
263
|
```
|
|
223
264
|
src/
|
|
224
265
|
├── app/ # Next.js App Router pages
|
|
225
|
-
│ ├── dashboard/ #
|
|
266
|
+
│ ├── dashboard/ # Task kanban board
|
|
226
267
|
│ ├── projects/[id]/ # Project detail
|
|
268
|
+
│ ├── tasks/ # Task detail + creation (redirects to dashboard)
|
|
269
|
+
│ ├── profiles/ # Agent profile gallery + detail + creation
|
|
227
270
|
│ ├── documents/ # Document browser
|
|
228
|
-
│ ├── workflows/ # Workflow management
|
|
271
|
+
│ ├── workflows/ # Workflow management + blueprints
|
|
229
272
|
│ ├── schedules/ # Schedule management
|
|
273
|
+
│ ├── costs/ # Cost & usage dashboard
|
|
230
274
|
│ ├── inbox/ # Notifications
|
|
231
275
|
│ ├── monitor/ # Log streaming
|
|
232
276
|
│ └── settings/ # Configuration
|
|
233
277
|
├── components/
|
|
234
278
|
│ ├── dashboard/ # Homepage widgets + charts
|
|
235
279
|
│ ├── tasks/ # Board, cards, panels
|
|
236
|
-
│ ├──
|
|
280
|
+
│ ├── profiles/ # Profile gallery, detail, form, learned context
|
|
281
|
+
│ ├── workflows/ # Workflow UI + blueprints + swarm
|
|
237
282
|
│ ├── documents/ # Document browser + upload
|
|
283
|
+
│ ├── costs/ # Cost dashboard + filters
|
|
238
284
|
│ ├── schedules/ # Schedule management
|
|
239
285
|
│ ├── monitoring/ # Log viewer
|
|
240
286
|
│ ├── notifications/ # Inbox + permission actions
|
|
241
|
-
│ ├── settings/ # Auth, permissions, data mgmt
|
|
287
|
+
│ ├── settings/ # Auth, permissions, budgets, data mgmt
|
|
242
288
|
│ ├── shared/ # App shell, sidebar
|
|
243
289
|
│ └── ui/ # shadcn/ui primitives
|
|
244
290
|
└── lib/
|
|
245
|
-
├── agents/ # Runtime adapters,
|
|
291
|
+
├── agents/ # Runtime adapters, profiles, learned context, pattern extraction
|
|
246
292
|
├── db/ # Schema, migrations
|
|
247
293
|
├── documents/ # Preprocessing + context builder
|
|
248
294
|
├── workflows/ # Engine + types + blueprints
|
|
249
295
|
├── schedules/ # Scheduler engine + interval parser
|
|
250
296
|
├── settings/ # Auth, permissions, helpers
|
|
297
|
+
├── usage/ # Metering ledger + pricing registry
|
|
251
298
|
├── constants/ # Status transitions, colors
|
|
252
299
|
├── queries/ # Chart data aggregation
|
|
253
300
|
├── validators/ # Zod schemas
|
|
254
301
|
└── utils/ # Shared helpers
|
|
255
302
|
```
|
|
256
303
|
|
|
257
|
-
### API Endpoints
|
|
258
|
-
|
|
259
|
-
| Endpoint | Method | Purpose |
|
|
260
|
-
|
|
261
|
-
| `/api/projects
|
|
262
|
-
| `/api/
|
|
263
|
-
| `/api/tasks
|
|
264
|
-
| `/api/tasks/[id]
|
|
265
|
-
| `/api/tasks/[id]/
|
|
266
|
-
| `/api/
|
|
267
|
-
| `/api/
|
|
268
|
-
| `/api/
|
|
269
|
-
| `/api/
|
|
270
|
-
| `/api/
|
|
271
|
-
| `/api/
|
|
272
|
-
| `/api/
|
|
273
|
-
| `/api/
|
|
274
|
-
| `/api/
|
|
275
|
-
| `/api/
|
|
276
|
-
| `/api/
|
|
277
|
-
| `/api/
|
|
278
|
-
| `/api/
|
|
279
|
-
| `/api/
|
|
280
|
-
| `/api/
|
|
281
|
-
| `/api/blueprints` |
|
|
282
|
-
| `/api/
|
|
283
|
-
| `/api/
|
|
284
|
-
| `/api/
|
|
304
|
+
### API Endpoints (48 routes)
|
|
305
|
+
|
|
306
|
+
| Domain | Endpoint | Method | Purpose |
|
|
307
|
+
|--------|----------|--------|---------|
|
|
308
|
+
| **Projects** | `/api/projects` | GET/POST | List and create projects |
|
|
309
|
+
| | `/api/projects/[id]` | GET/PUT/DELETE | Project CRUD |
|
|
310
|
+
| **Tasks** | `/api/tasks` | GET/POST | List and create tasks |
|
|
311
|
+
| | `/api/tasks/[id]` | GET/PATCH/DELETE | Task detail, update, delete |
|
|
312
|
+
| | `/api/tasks/[id]/execute` | POST | Fire-and-forget task dispatch (202) |
|
|
313
|
+
| | `/api/tasks/[id]/resume` | POST | Resume failed/cancelled task |
|
|
314
|
+
| | `/api/tasks/[id]/cancel` | POST | Cancel running task |
|
|
315
|
+
| | `/api/tasks/[id]/respond` | POST | Human response to agent prompt |
|
|
316
|
+
| | `/api/tasks/[id]/output` | GET | Task execution output |
|
|
317
|
+
| | `/api/tasks/[id]/logs` | GET | Task log history |
|
|
318
|
+
| | `/api/tasks/assist` | POST | AI task assist (description, subtasks, workflow recommendation) |
|
|
319
|
+
| **Workflows** | `/api/workflows` | GET/POST | List and create workflows |
|
|
320
|
+
| | `/api/workflows/[id]` | GET/PATCH/DELETE | Workflow detail, update, delete |
|
|
321
|
+
| | `/api/workflows/[id]/execute` | POST | Execute workflow |
|
|
322
|
+
| | `/api/workflows/[id]/status` | GET | Workflow execution status |
|
|
323
|
+
| | `/api/workflows/[id]/steps/[stepId]/retry` | POST | Retry failed workflow step |
|
|
324
|
+
| | `/api/workflows/from-assist` | POST | Create workflow from AI assist recommendation |
|
|
325
|
+
| **Blueprints** | `/api/blueprints` | GET/POST | List and create blueprints |
|
|
326
|
+
| | `/api/blueprints/[id]` | GET/DELETE | Blueprint detail and deletion |
|
|
327
|
+
| | `/api/blueprints/[id]/instantiate` | POST | Create workflow from blueprint |
|
|
328
|
+
| | `/api/blueprints/import` | POST | Import blueprint from GitHub URL |
|
|
329
|
+
| **Documents** | `/api/documents` | GET | List documents with joins |
|
|
330
|
+
| | `/api/documents/[id]` | GET/PATCH/DELETE | Document detail, metadata, deletion |
|
|
331
|
+
| | `/api/documents/[id]/file` | GET | Download document file |
|
|
332
|
+
| **Uploads** | `/api/uploads` | POST | File upload |
|
|
333
|
+
| | `/api/uploads/[id]` | GET/DELETE | Upload detail and deletion |
|
|
334
|
+
| | `/api/uploads/cleanup` | POST | Clean up orphaned uploads |
|
|
335
|
+
| **Profiles** | `/api/profiles` | GET | List agent profiles |
|
|
336
|
+
| | `/api/profiles/[id]` | GET/PUT/DELETE | Profile CRUD |
|
|
337
|
+
| | `/api/profiles/[id]/test` | POST | Run behavioral tests on a profile |
|
|
338
|
+
| | `/api/profiles/[id]/context` | GET/POST/PATCH | Learned context: version history, manual add, approve/reject/rollback |
|
|
339
|
+
| | `/api/profiles/import` | POST | Import profile from GitHub URL |
|
|
340
|
+
| **Notifications** | `/api/notifications` | GET/POST | List and create notifications |
|
|
341
|
+
| | `/api/notifications/[id]` | PATCH/DELETE | Update and delete notification |
|
|
342
|
+
| | `/api/notifications/mark-all-read` | POST | Mark all notifications as read |
|
|
343
|
+
| | `/api/notifications/pending-approvals` | GET | Pending approval notifications |
|
|
344
|
+
| | `/api/notifications/pending-approvals/stream` | GET | SSE stream for pending approvals |
|
|
345
|
+
| **Schedules** | `/api/schedules` | GET/POST | Schedule CRUD |
|
|
346
|
+
| | `/api/schedules/[id]` | GET/PATCH/DELETE | Schedule detail + updates |
|
|
347
|
+
| **Settings** | `/api/settings` | GET/POST | General settings |
|
|
348
|
+
| | `/api/settings/openai` | GET/POST | OpenAI Codex runtime settings |
|
|
349
|
+
| | `/api/settings/test` | POST | Provider-aware runtime connectivity test |
|
|
350
|
+
| | `/api/settings/budgets` | GET/POST | Budget configuration |
|
|
351
|
+
| | `/api/permissions` | GET/POST/DELETE | Tool permission patterns |
|
|
352
|
+
| **Monitoring** | `/api/logs/stream` | GET | SSE agent log stream |
|
|
353
|
+
| **Platform** | `/api/command-palette/recent` | GET | Recent command palette items |
|
|
354
|
+
| | `/api/data/clear` | POST | Clear all data |
|
|
355
|
+
| | `/api/data/seed` | POST | Seed sample data |
|
|
285
356
|
|
|
286
357
|
---
|
|
287
358
|
|
|
@@ -297,29 +368,40 @@ All 14 features shipped across three layers:
|
|
|
297
368
|
| **Core** | Project management, task board, agent integration, inbox notifications, monitoring dashboard |
|
|
298
369
|
| **Polish** | Homepage dashboard, UX fixes, workflow engine, AI task assist, content handling, session management |
|
|
299
370
|
|
|
300
|
-
### Post-MVP — Complete
|
|
301
|
-
|
|
302
|
-
| Feature | What shipped |
|
|
303
|
-
|
|
304
|
-
| **
|
|
305
|
-
|
|
|
306
|
-
|
|
|
307
|
-
|
|
|
308
|
-
|
|
|
309
|
-
| **
|
|
310
|
-
|
|
|
311
|
-
|
|
|
312
|
-
|
|
|
313
|
-
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
|
318
|
-
|
|
319
|
-
|
|
|
320
|
-
|
|
|
321
|
-
|
|
|
322
|
-
|
|
|
371
|
+
### Post-MVP — Complete (27 features)
|
|
372
|
+
|
|
373
|
+
| Category | Feature | What shipped |
|
|
374
|
+
|----------|---------|-------------|
|
|
375
|
+
| **Documents** | File Attachments | Upload data layer with project/task linking |
|
|
376
|
+
| | Document Preprocessing | Text extraction for 5 formats (text, PDF, images, Office, spreadsheets) |
|
|
377
|
+
| | Agent Document Context | Automatic document injection into agent prompts |
|
|
378
|
+
| | Document Browser | Table/grid views, search, filters, bulk operations at `/documents` |
|
|
379
|
+
| | Document Output Generation | Agent-generated documents as deliverables |
|
|
380
|
+
| **Agent Intelligence** | Multi-Agent Routing | Profile registry (4 profiles), task classifier, per-step profile assignment |
|
|
381
|
+
| | Autonomous Loop Execution | 4 stop conditions, iteration context chaining, pause/resume, loop status view |
|
|
382
|
+
| | Multi-Agent Swarm | Mayor → worker pool → refinery orchestration with retryable stages |
|
|
383
|
+
| | AI Assist → Workflows | Bridge task assist into workflow engine with profile assignment and pattern selection |
|
|
384
|
+
| | Agent Self-Improvement | Pattern extraction from logs, human-approved context evolution, versioned rollback |
|
|
385
|
+
| **Agent Profiles** | Agent Profile Catalog | 13 domain-specific profiles, GitHub import, behavioral testing, MCP passthrough |
|
|
386
|
+
| | Workflow Blueprints | 8 templates, gallery, YAML editor, dynamic forms, GitHub import, lineage tracking |
|
|
387
|
+
| **UI Enhancement** | Ambient Approvals | Shell-level approval presenter on any route for fast supervision |
|
|
388
|
+
| | Micro-Visualizations | Sparklines, mini bars, donut rings — zero-dependency SVG charts |
|
|
389
|
+
| | Command Palette | ⌘K palette with navigation, create actions, recent items, theme toggle |
|
|
390
|
+
| | Operational Surface | Cross-route composition with consistent layout, density, and interaction patterns |
|
|
391
|
+
| | Profile Surface | Profile gallery stability, detail views, and behavioral testing UI |
|
|
392
|
+
| | Accessibility | ARIA labels, keyboard navigation, focus management, screen reader support |
|
|
393
|
+
| | UI Density Refinement | Tightened spacing, typography, and visual hierarchy across all routes |
|
|
394
|
+
| | Kanban Board Operations | Inline editing, bulk operations, card animations, edit dialog |
|
|
395
|
+
| | Board Context Persistence | Persisted filters, sort order, and project selection across sessions |
|
|
396
|
+
| **Platform** | Scheduled Prompt Loops | Cron + human-friendly intervals, one-shot/recurring, pause/resume lifecycle |
|
|
397
|
+
| | Tool Permission Persistence | "Always Allow" patterns, pre-check bypass, Settings management |
|
|
398
|
+
| | Provider Runtimes | Shared runtime registry with Claude Code and OpenAI Codex App Server adapters |
|
|
399
|
+
| | OpenAI Codex Runtime | Codex App Server integration with inbox approvals, logs, and thread resumption |
|
|
400
|
+
| | Cross-Provider Profiles | Profile compatibility layer ensuring profiles work across Claude and Codex runtimes |
|
|
401
|
+
| | Parallel Fork/Join | 2-5 concurrent research branches with synthesis step |
|
|
402
|
+
| **Governance** | Usage Metering Ledger | Provider-normalized token and spend tracking across all execution paths |
|
|
403
|
+
| | Spend Budget Guardrails | Per-project and global budgets with enforcement and alerts |
|
|
404
|
+
| | Cost & Usage Dashboard | Summary cards, trend views, provider/model breakdowns, budget audit visibility |
|
|
323
405
|
|
|
324
406
|
---
|
|
325
407
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stagent",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "Governed AI agent workspace for supervised local execution, workflows, documents, and provider runtimes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -51,7 +51,6 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@anthropic-ai/claude-agent-sdk": "^0.2.71",
|
|
54
|
-
"@anthropic-ai/sdk": "^0.78.0",
|
|
55
54
|
"@dnd-kit/core": "^6.3.1",
|
|
56
55
|
"@dnd-kit/sortable": "^10.0.0",
|
|
57
56
|
"@dnd-kit/utilities": "^3.2.2",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { NextRequest, NextResponse } from "next/server";
|
|
2
|
+
import { db } from "@/lib/db";
|
|
3
|
+
import { workflows, tasks } from "@/lib/db/schema";
|
|
4
|
+
import { eq } from "drizzle-orm";
|
|
5
|
+
import type { WorkflowDefinition } from "@/lib/workflows/types";
|
|
6
|
+
import { validateWorkflowDefinition } from "@/lib/workflows/definition-validation";
|
|
7
|
+
import { validateWorkflowDefinitionAssignments } from "@/lib/agents/profiles/assignment-validation";
|
|
8
|
+
import { executeWorkflow } from "@/lib/workflows/engine";
|
|
9
|
+
|
|
10
|
+
interface FromAssistBody {
|
|
11
|
+
name?: string;
|
|
12
|
+
projectId?: string;
|
|
13
|
+
definition?: WorkflowDefinition;
|
|
14
|
+
priority?: number;
|
|
15
|
+
assignedAgent?: string;
|
|
16
|
+
executeImmediately?: boolean;
|
|
17
|
+
parentTask?: {
|
|
18
|
+
title: string;
|
|
19
|
+
description: string;
|
|
20
|
+
agentProfile?: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function POST(req: NextRequest) {
|
|
25
|
+
const body = (await req.json()) as FromAssistBody;
|
|
26
|
+
const { name, projectId, definition, priority, assignedAgent, executeImmediately, parentTask } = body;
|
|
27
|
+
|
|
28
|
+
if (!name?.trim()) {
|
|
29
|
+
return NextResponse.json({ error: "Name is required" }, { status: 400 });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!definition) {
|
|
33
|
+
return NextResponse.json(
|
|
34
|
+
{ error: "Definition must include pattern and at least one step" },
|
|
35
|
+
{ status: 400 }
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const definitionError = validateWorkflowDefinition(definition);
|
|
40
|
+
if (definitionError) {
|
|
41
|
+
return NextResponse.json({ error: definitionError }, { status: 400 });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const compatibilityError = validateWorkflowDefinitionAssignments(definition);
|
|
45
|
+
if (compatibilityError) {
|
|
46
|
+
return NextResponse.json({ error: compatibilityError }, { status: 400 });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Transaction: create workflow + tasks + optional parent task atomically
|
|
50
|
+
const workflowId = crypto.randomUUID();
|
|
51
|
+
const now = new Date();
|
|
52
|
+
const taskIds: string[] = [];
|
|
53
|
+
let parentTaskId: string | null = null;
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
db.transaction((tx) => {
|
|
57
|
+
// Create parent task (no workflowId — visible on dashboard)
|
|
58
|
+
if (parentTask?.title) {
|
|
59
|
+
parentTaskId = crypto.randomUUID();
|
|
60
|
+
tx.insert(tasks)
|
|
61
|
+
.values({
|
|
62
|
+
id: parentTaskId,
|
|
63
|
+
title: parentTask.title,
|
|
64
|
+
description: parentTask.description || null,
|
|
65
|
+
projectId: projectId || null,
|
|
66
|
+
workflowId: null,
|
|
67
|
+
status: executeImmediately ? "running" : "planned",
|
|
68
|
+
assignedAgent: assignedAgent ?? null,
|
|
69
|
+
agentProfile: parentTask.agentProfile ?? null,
|
|
70
|
+
priority: priority ?? 2,
|
|
71
|
+
createdAt: now,
|
|
72
|
+
updatedAt: now,
|
|
73
|
+
})
|
|
74
|
+
.run();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Store sourceTaskId in definition for parent↔workflow linkage
|
|
78
|
+
const defToStore = parentTaskId
|
|
79
|
+
? { ...definition, sourceTaskId: parentTaskId }
|
|
80
|
+
: definition;
|
|
81
|
+
|
|
82
|
+
// Create workflow
|
|
83
|
+
tx.insert(workflows)
|
|
84
|
+
.values({
|
|
85
|
+
id: workflowId,
|
|
86
|
+
name: name.trim(),
|
|
87
|
+
projectId: projectId || null,
|
|
88
|
+
definition: JSON.stringify(defToStore),
|
|
89
|
+
status: executeImmediately ? "active" : "draft",
|
|
90
|
+
createdAt: now,
|
|
91
|
+
updatedAt: now,
|
|
92
|
+
})
|
|
93
|
+
.run();
|
|
94
|
+
|
|
95
|
+
// Create tasks for each step (with workflowId — hidden from dashboard)
|
|
96
|
+
for (const step of definition.steps) {
|
|
97
|
+
const taskId = crypto.randomUUID();
|
|
98
|
+
taskIds.push(taskId);
|
|
99
|
+
|
|
100
|
+
tx.insert(tasks)
|
|
101
|
+
.values({
|
|
102
|
+
id: taskId,
|
|
103
|
+
title: step.name,
|
|
104
|
+
description: step.prompt,
|
|
105
|
+
projectId: projectId || null,
|
|
106
|
+
workflowId,
|
|
107
|
+
status: "planned",
|
|
108
|
+
assignedAgent: step.assignedAgent ?? assignedAgent ?? null,
|
|
109
|
+
agentProfile: step.agentProfile ?? null,
|
|
110
|
+
priority: priority ?? 2,
|
|
111
|
+
createdAt: now,
|
|
112
|
+
updatedAt: now,
|
|
113
|
+
})
|
|
114
|
+
.run();
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
} catch (error) {
|
|
118
|
+
console.error("Failed to create workflow from assist:", error);
|
|
119
|
+
return NextResponse.json(
|
|
120
|
+
{ error: "Failed to create workflow and tasks" },
|
|
121
|
+
{ status: 500 }
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Fire-and-forget execution if requested
|
|
126
|
+
if (executeImmediately) {
|
|
127
|
+
executeWorkflow(workflowId).catch((error) => {
|
|
128
|
+
console.error(`Workflow ${workflowId} execution failed:`, error);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const [created] = await db.select().from(workflows).where(eq(workflows.id, workflowId));
|
|
133
|
+
|
|
134
|
+
return NextResponse.json(
|
|
135
|
+
{
|
|
136
|
+
workflow: created,
|
|
137
|
+
taskIds,
|
|
138
|
+
parentTaskId,
|
|
139
|
+
status: executeImmediately ? "started" : "created",
|
|
140
|
+
},
|
|
141
|
+
{ status: 201 }
|
|
142
|
+
);
|
|
143
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Suspense } from "react";
|
|
2
2
|
import { db } from "@/lib/db";
|
|
3
|
-
import { tasks, projects } from "@/lib/db/schema";
|
|
4
|
-
import { desc } from "drizzle-orm";
|
|
3
|
+
import { tasks, projects, workflows } from "@/lib/db/schema";
|
|
4
|
+
import { desc, isNull } from "drizzle-orm";
|
|
5
5
|
import { KanbanBoard } from "@/components/tasks/kanban-board";
|
|
6
6
|
import { SkeletonBoard } from "@/components/tasks/skeleton-board";
|
|
7
7
|
import type { TaskItem } from "@/components/tasks/task-card";
|
|
@@ -9,9 +9,11 @@ import type { TaskItem } from "@/components/tasks/task-card";
|
|
|
9
9
|
export const dynamic = "force-dynamic";
|
|
10
10
|
|
|
11
11
|
async function BoardContent() {
|
|
12
|
+
// Only show parent/standalone tasks — hide workflow step tasks
|
|
12
13
|
const allTasks = await db
|
|
13
14
|
.select()
|
|
14
15
|
.from(tasks)
|
|
16
|
+
.where(isNull(tasks.workflowId))
|
|
15
17
|
.orderBy(tasks.priority, desc(tasks.createdAt));
|
|
16
18
|
|
|
17
19
|
const allProjects = await db
|
|
@@ -22,10 +24,30 @@ async function BoardContent() {
|
|
|
22
24
|
// Build project name lookup for task cards
|
|
23
25
|
const projectMap = new Map(allProjects.map((p) => [p.id, p.name]));
|
|
24
26
|
|
|
27
|
+
// Look up linked workflows for parent tasks (via sourceTaskId in definition JSON)
|
|
28
|
+
const allWorkflows = await db
|
|
29
|
+
.select({ id: workflows.id, definition: workflows.definition, status: workflows.status })
|
|
30
|
+
.from(workflows);
|
|
31
|
+
|
|
32
|
+
const linkedWorkflowMap = new Map<string, { workflowId: string; workflowStatus: string }>();
|
|
33
|
+
for (const w of allWorkflows) {
|
|
34
|
+
try {
|
|
35
|
+
const def = JSON.parse(w.definition);
|
|
36
|
+
if (def.sourceTaskId) {
|
|
37
|
+
linkedWorkflowMap.set(def.sourceTaskId, {
|
|
38
|
+
workflowId: w.id,
|
|
39
|
+
workflowStatus: w.status,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
} catch { /* skip invalid JSON */ }
|
|
43
|
+
}
|
|
44
|
+
|
|
25
45
|
// Serialize Date objects for client component consumption
|
|
26
46
|
const serializedTasks: TaskItem[] = allTasks.map((t) => ({
|
|
27
47
|
...t,
|
|
28
48
|
projectName: t.projectId ? projectMap.get(t.projectId) ?? undefined : undefined,
|
|
49
|
+
linkedWorkflowId: linkedWorkflowMap.get(t.id)?.workflowId,
|
|
50
|
+
linkedWorkflowStatus: linkedWorkflowMap.get(t.id)?.workflowStatus,
|
|
29
51
|
createdAt: t.createdAt.toISOString(),
|
|
30
52
|
updatedAt: t.updatedAt.toISOString(),
|
|
31
53
|
}));
|