@mndrk/agx 1.4.62 → 1.4.63
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 +40 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/BUILD_ID +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/app-build-manifest.json +68 -68
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/app-path-routes-manifest.json +14 -14
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/build-manifest.json +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/prerender-manifest.json +12 -12
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_not-found.html +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_not-found.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/audit/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/auth/[...nextauth]/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/auth/daemon-secret/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/auth/device/code/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/auth/device/token/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/auth/refresh/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/domains/[id]/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/domains/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/health/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/learnings/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/logs/stream/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/orchestrator/tasks/[taskId]/cancel/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/orchestrator/tasks/[taskId]/signal/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/orchestrator/tasks/[taskId]/start/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/orchestrator/tasks/[taskId]/status/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/projects/[id]/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/projects/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/providers/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/queue/complete/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/queue/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/stage-prompts/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/comments/[commentId]/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/comments/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/costs/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/dependencies/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/heartbeat/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/history/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/logs/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/logs/stream/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/restart-stage/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/route.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/stream/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/user-settings/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/workflows/[id]/nodes/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/workflows/[id]/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/workflows/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/auth/callback/route_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/auth/device/page.js +4 -4
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/auth/device/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/auth/device.html +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/auth/device.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/dashboard/page.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/dashboard/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/dashboard.html +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/dashboard.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/index.html +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/index.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/login.html +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/login.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/[slug]/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/[slug]/tasks/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/[slug]/workflow/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects.html +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/settings.html +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/settings.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app-paths-manifest.json +14 -14
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/6317.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/7143.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/8521.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/middleware-manifest.json +5 -5
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/pages/404.html +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/pages/500.html +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/pages-manifest.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/server-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/server-reference-manifest.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/app/auth/device/page-06eeddaf1bb867c3.js +1 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/app/dashboard/page-6140206ded1cc4ae.js +1 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/worker/index.js +8 -0
- package/lib/cli/cloud/prompts.js +35 -133
- package/lib/cli/runCli.js +159 -17
- package/lib/cli/skillText.js +1 -56
- package/lib/cli/templateDefaults.js +22 -0
- package/lib/executor.js +8 -40
- package/lib/prompts/cloudTask.js +35 -75
- package/lib/prompts/templates.js +356 -0
- package/package.json +1 -1
- package/templates/stack/postgres/init/001_agx_board_schema.sql +17 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/app/auth/device/page-39c6907dc645eb6f.js +0 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/app/dashboard/page-d35f0d29790d06ca.js +0 -1
- /package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/{_knBrbKtV87NnpUclVMJo → o_Dsarly6P4c-yqsBEkNM}/_buildManifest.js +0 -0
- /package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/{_knBrbKtV87NnpUclVMJo → o_Dsarly6P4c-yqsBEkNM}/_ssgManifest.js +0 -0
package/lib/prompts/cloudTask.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const { interpolate, CONTINUE_CLOUD_TASK, NEW_AUTONOMOUS_CLOUD_TASK, LEGACY_INSTRUCTION_FOOTER } = require('./templates');
|
|
2
|
+
|
|
1
3
|
function stripMarkdownSection(markdown, heading) {
|
|
2
4
|
if (!markdown) return '';
|
|
3
5
|
const h = String(heading || '').trim();
|
|
@@ -60,34 +62,21 @@ function buildContinueCloudTaskPrompt({
|
|
|
60
62
|
const artifactsDir = typeof runContext?.artifacts_dir === 'string' ? runContext.artifacts_dir.trim() : '';
|
|
61
63
|
|
|
62
64
|
const hasTaskPrompt = typeof task?.prompt === 'string' && task.prompt.trim();
|
|
63
|
-
let augmentedPrompt = hasTaskPrompt ? task.prompt.trim() :
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
Task Thread:
|
|
79
|
-
${(taskComments || []).map(c => `${c.author}: ${c.content}`).join('\n')}
|
|
80
|
-
"""
|
|
81
|
-
|
|
82
|
-
## Extracted State
|
|
83
|
-
|
|
84
|
-
Goal: ${task.title || 'Untitled'}
|
|
85
|
-
Plan: ${plan || '(none)'}
|
|
86
|
-
Todo: ${todo || '(none)'}
|
|
87
|
-
Checkpoints: ${checkpoints || '(none)'}
|
|
88
|
-
Learnings: ${learnings || '(none)'}
|
|
89
|
-
|
|
90
|
-
`;
|
|
65
|
+
let augmentedPrompt = hasTaskPrompt ? task.prompt.trim() : interpolate(CONTINUE_CLOUD_TASK, {
|
|
66
|
+
id: task.id,
|
|
67
|
+
title: task.title || 'Untitled',
|
|
68
|
+
stage: task.stage || 'ideation',
|
|
69
|
+
stagePrompt,
|
|
70
|
+
stageRequirement,
|
|
71
|
+
taskTitle: task?.title,
|
|
72
|
+
taskContent: sanitizeTaskContentForPrompt(task?.content),
|
|
73
|
+
taskComments: (taskComments || []).map(c => `${c.author}: ${c.content}`).join('\n'),
|
|
74
|
+
goal: task.title || 'Untitled',
|
|
75
|
+
plan: plan || '(none)',
|
|
76
|
+
todo: todo || '(none)',
|
|
77
|
+
checkpoints: checkpoints || '(none)',
|
|
78
|
+
learnings: learnings || '(none)',
|
|
79
|
+
});
|
|
91
80
|
|
|
92
81
|
if (!hasTaskPrompt && task?.engine) {
|
|
93
82
|
augmentedPrompt += `Engine: ${task.engine}\n`;
|
|
@@ -169,37 +158,17 @@ function buildNewAutonomousCloudTaskPrompt({
|
|
|
169
158
|
stagePrompt,
|
|
170
159
|
stageRequirement,
|
|
171
160
|
}) {
|
|
172
|
-
return
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
${sanitizeTaskContentForPrompt(task?.content)}
|
|
184
|
-
---
|
|
185
|
-
Task Thread:
|
|
186
|
-
${(taskComments || []).map(c => `${c.author}: ${c.content}`).join('\n')}
|
|
187
|
-
"""
|
|
188
|
-
|
|
189
|
-
---
|
|
190
|
-
|
|
191
|
-
## Instructions
|
|
192
|
-
|
|
193
|
-
You are starting a new autonomous task. Work until completion or blocked.
|
|
194
|
-
Respect the Stage Completion Requirement before using [complete] or [done].
|
|
195
|
-
|
|
196
|
-
To update the task:
|
|
197
|
-
- [done] - Mark task complete
|
|
198
|
-
- [complete: message] - Complete current stage
|
|
199
|
-
- [log: message] - Add a log entry
|
|
200
|
-
|
|
201
|
-
Goal: ${finalPrompt}
|
|
202
|
-
`;
|
|
161
|
+
return interpolate(NEW_AUTONOMOUS_CLOUD_TASK, {
|
|
162
|
+
id: task.id,
|
|
163
|
+
title: task.title || finalPrompt,
|
|
164
|
+
stage: task.stage,
|
|
165
|
+
stagePrompt,
|
|
166
|
+
stageRequirement,
|
|
167
|
+
taskTitle: task?.title,
|
|
168
|
+
taskContent: sanitizeTaskContentForPrompt(task?.content),
|
|
169
|
+
taskComments: (taskComments || []).map(c => `${c.author}: ${c.content}`).join('\n'),
|
|
170
|
+
finalPrompt,
|
|
171
|
+
});
|
|
203
172
|
}
|
|
204
173
|
|
|
205
174
|
module.exports = {
|
|
@@ -214,23 +183,14 @@ function buildLegacyInstructionFooter({ runContext, finalPrompt } = {}) {
|
|
|
214
183
|
const planDir = typeof runContext?.planDir === 'string' ? runContext.planDir.trim() : '';
|
|
215
184
|
const artifactsDir = typeof runContext?.artifactsDir === 'string' ? runContext.artifactsDir.trim() : '';
|
|
216
185
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
Respect the Stage Completion Requirement before using [complete] or [done].
|
|
221
|
-
|
|
222
|
-
${(runRoot || planDir || artifactsDir) ? `\nLocal run paths (scratch space):\n- Run root: ${runRoot || '(unset)'}\n- Plan dir: ${planDir || '(unset)'}\n- Artifacts dir: ${artifactsDir || '(unset)'}\n\nPrefer writing scratch planning docs under the run's Plan dir to avoid polluting the repo.\n` : ''}
|
|
223
|
-
|
|
224
|
-
To update the task:
|
|
225
|
-
- [done] - Mark task complete
|
|
226
|
-
- [complete: message] - Complete current stage
|
|
227
|
-
- [log: message] - Add a log entry
|
|
228
|
-
- [checkpoint: message] - Save progress checkpoint
|
|
229
|
-
- [learn: insight] - Record a learning
|
|
230
|
-
- [plan: text] - Update plan
|
|
231
|
-
- [todo: text] - Update todo list
|
|
186
|
+
const runPaths = (runRoot || planDir || artifactsDir)
|
|
187
|
+
? `\nLocal run paths (scratch space):\n- Run root: ${runRoot || '(unset)'}\n- Plan dir: ${planDir || '(unset)'}\n- Artifacts dir: ${artifactsDir || '(unset)'}\n\nPrefer writing scratch planning docs under the run's Plan dir to avoid polluting the repo.\n`
|
|
188
|
+
: '';
|
|
232
189
|
|
|
233
|
-
|
|
190
|
+
return interpolate(LEGACY_INSTRUCTION_FOOTER, {
|
|
191
|
+
runPaths,
|
|
192
|
+
finalPrompt: finalPrompt ? `Your specific task: ${finalPrompt}` : '',
|
|
193
|
+
}).trim();
|
|
234
194
|
}
|
|
235
195
|
|
|
236
196
|
function extractBodyFromContent(content) {
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Centralized prompt templates for agx.
|
|
5
|
+
*
|
|
6
|
+
* All prompt string content lives here. Builder functions that assemble
|
|
7
|
+
* conditional logic stay in their original files and import these templates.
|
|
8
|
+
*
|
|
9
|
+
* Use `interpolate(template, vars)` to fill `{{key}}` placeholders.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
function interpolate(template, vars) {
|
|
13
|
+
return template.replace(/\{\{(\w+)\}\}/g, (_, key) => vars[key] ?? '');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Static templates (no variables)
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
const DEFAULT_STAGE_PROMPT = 'Execute this stage using the latest stage prompt from the cloud task context.';
|
|
21
|
+
|
|
22
|
+
const PROJECT_CONTEXT = [
|
|
23
|
+
'AGX orchestrates autonomous AI agents with tasks defined via `agx new` and managed through `agx run`, `agx tasks`, `agx status`, and `agx context` so agents can wake, work, and sleep across sessions.',
|
|
24
|
+
'Task state lives in the cloud API (goal, criteria, progress, learnings) along with the orchestration worker (pg-boss); `agx info`/`agx context` expose structured project metadata.',
|
|
25
|
+
'Quick-start workflow: `agx new "<goal>"`, optionally `agx -a -p "<goal>"` for autonomous execution, then use `agx run`, `agx tasks`, `agx status`, and `agx context` to manage work.',
|
|
26
|
+
'Task management commands include `agx task ls`, `agx task logs`, `agx task stop`, `agx task rm`, `agx complete`, `agx pull`.',
|
|
27
|
+
'Daemon mode runs via `agx daemon start/stop/status/logs` so agents can poll for work continuously.',
|
|
28
|
+
'Providers: `agx claude` (alias `c`), `agx gemini` (alias `g`), and `agx ollama` (alias `o`).',
|
|
29
|
+
'Key flags: `-a/--autonomous`, `-p/--prompt`, `--prompt-file`, `-y/--yolo`, `--continue <task>`.',
|
|
30
|
+
'Key principles: persistent storage, criteria-driven completion, checkpoint often, ask when stuck, learn and adapt.',
|
|
31
|
+
'Agent workflow: orient on saved state, plan, execute, checkpoint, adapt to blockers, and report learnings.',
|
|
32
|
+
'State operations: define objectives via `agx new`, update learnings with `[learn: ...]`, mark completion via `agx complete`, and sync via `agx info`/`agx context`.',
|
|
33
|
+
'Project metadata: attach `--metadata key=value` and `--repo` info so `/api/projects` keeps structured context.',
|
|
34
|
+
].join('\n');
|
|
35
|
+
|
|
36
|
+
const AGX_SKILL = `---
|
|
37
|
+
name: agx
|
|
38
|
+
description: Task orchestrator for AI agents. Uses cloud API for persistence.
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
# agx - AI Agent Task Orchestrator
|
|
42
|
+
|
|
43
|
+
agx manages tasks and coordinates AI agents. Uses cloud API for persistence.
|
|
44
|
+
|
|
45
|
+
## Quick Start
|
|
46
|
+
|
|
47
|
+
\`\`\`bash
|
|
48
|
+
agx -a -p "Build a REST API" # Autonomous: works until done
|
|
49
|
+
agx -p "explain this code" # One-shot question
|
|
50
|
+
\`\`\`
|
|
51
|
+
|
|
52
|
+
## Task Lifecycle
|
|
53
|
+
|
|
54
|
+
\`\`\`bash
|
|
55
|
+
agx new "goal" # Create task
|
|
56
|
+
agx run [task] # Run a task
|
|
57
|
+
agx complete <taskId> # Mark task stage complete
|
|
58
|
+
agx status <taskId> # Show detailed info for a specific task
|
|
59
|
+
agx status # Show current status
|
|
60
|
+
\`\`\`
|
|
61
|
+
|
|
62
|
+
## Checking Tasks
|
|
63
|
+
|
|
64
|
+
\`\`\`bash
|
|
65
|
+
agx task ls # List tasks
|
|
66
|
+
agx task logs <id> [-f] # View/tail task logs
|
|
67
|
+
agx task tail <id> # Tail task logs
|
|
68
|
+
agx comments tail <id> # Tail task comments
|
|
69
|
+
agx logs tail <id> # Tail task logs
|
|
70
|
+
agx watch # Watch task updates in real-time (SSE)
|
|
71
|
+
\`\`\`
|
|
72
|
+
|
|
73
|
+
## Cloud
|
|
74
|
+
|
|
75
|
+
\`\`\`bash
|
|
76
|
+
AGX_CLOUD_URL=http://localhost:41741 agx status
|
|
77
|
+
AGX_CLOUD_URL=http://localhost:41741 agx task ls
|
|
78
|
+
agx daemon start # Start local daemon
|
|
79
|
+
\`\`\`
|
|
80
|
+
|
|
81
|
+
## Providers
|
|
82
|
+
|
|
83
|
+
claude (c), gemini (g), ollama (o), codex (x)
|
|
84
|
+
|
|
85
|
+
## Key Flags
|
|
86
|
+
|
|
87
|
+
-a Autonomous mode (daemon + work until done)
|
|
88
|
+
-p Prompt/goal
|
|
89
|
+
-y Skip confirmations (implied by -a)
|
|
90
|
+
-P, --provider <c|g|o|x> Provider for new task (claude/gemini/ollama/codex)
|
|
91
|
+
`;
|
|
92
|
+
|
|
93
|
+
// ---------------------------------------------------------------------------
|
|
94
|
+
// Parameterized templates (use with interpolate())
|
|
95
|
+
// ---------------------------------------------------------------------------
|
|
96
|
+
|
|
97
|
+
const CONTINUE_CLOUD_TASK = `## Cloud Task Context
|
|
98
|
+
|
|
99
|
+
You are continuing a cloud task. Here is the current state:
|
|
100
|
+
|
|
101
|
+
Task ID: {{id}}
|
|
102
|
+
Title: {{title}}
|
|
103
|
+
Stage: {{stage}}
|
|
104
|
+
Stage Objective: {{stagePrompt}}
|
|
105
|
+
Stage Completion Requirement: {{stageRequirement}}
|
|
106
|
+
|
|
107
|
+
\tUser Request:
|
|
108
|
+
\t"""
|
|
109
|
+
\t{{taskTitle}}
|
|
110
|
+
\t{{taskContent}}
|
|
111
|
+
\t---
|
|
112
|
+
\tTask Thread:
|
|
113
|
+
\t{{taskComments}}
|
|
114
|
+
\t"""
|
|
115
|
+
|
|
116
|
+
## Extracted State
|
|
117
|
+
|
|
118
|
+
Goal: {{goal}}
|
|
119
|
+
Plan: {{plan}}
|
|
120
|
+
Todo: {{todo}}
|
|
121
|
+
Checkpoints: {{checkpoints}}
|
|
122
|
+
Learnings: {{learnings}}
|
|
123
|
+
|
|
124
|
+
`;
|
|
125
|
+
|
|
126
|
+
const NEW_AUTONOMOUS_CLOUD_TASK = `## Cloud Task Context
|
|
127
|
+
|
|
128
|
+
\tTask ID: {{id}}
|
|
129
|
+
\tTitle: {{title}}
|
|
130
|
+
\tStage: {{stage}}
|
|
131
|
+
\tStage Objective: {{stagePrompt}}
|
|
132
|
+
\tStage Completion Requirement: {{stageRequirement}}
|
|
133
|
+
|
|
134
|
+
\tUser Request:
|
|
135
|
+
\t"""
|
|
136
|
+
\t{{taskTitle}}
|
|
137
|
+
\t{{taskContent}}
|
|
138
|
+
\t---
|
|
139
|
+
\tTask Thread:
|
|
140
|
+
\t{{taskComments}}
|
|
141
|
+
\t"""
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Instructions
|
|
146
|
+
|
|
147
|
+
You are starting a new autonomous task. Work until completion or blocked.
|
|
148
|
+
Respect the Stage Completion Requirement before using [complete] or [done].
|
|
149
|
+
|
|
150
|
+
To update the task:
|
|
151
|
+
- [done] - Mark task complete
|
|
152
|
+
- [complete: message] - Complete current stage
|
|
153
|
+
- [log: message] - Add a log entry
|
|
154
|
+
|
|
155
|
+
Goal: {{finalPrompt}}
|
|
156
|
+
`;
|
|
157
|
+
|
|
158
|
+
const LEGACY_INSTRUCTION_FOOTER = `## Instructions
|
|
159
|
+
|
|
160
|
+
Continue working on this task. Use the cloud API to sync progress.
|
|
161
|
+
Respect the Stage Completion Requirement before using [complete] or [done].
|
|
162
|
+
|
|
163
|
+
{{runPaths}}
|
|
164
|
+
|
|
165
|
+
To update the task:
|
|
166
|
+
- [done] - Mark task complete
|
|
167
|
+
- [complete: message] - Complete current stage
|
|
168
|
+
- [log: message] - Add a log entry
|
|
169
|
+
- [checkpoint: message] - Save progress checkpoint
|
|
170
|
+
- [learn: insight] - Record a learning
|
|
171
|
+
- [plan: text] - Update plan
|
|
172
|
+
- [todo: text] - Update todo list
|
|
173
|
+
|
|
174
|
+
{{finalPrompt}}`;
|
|
175
|
+
|
|
176
|
+
const AGGREGATOR_PROMPT = `You are the decision aggregator for a {{role}} run.
|
|
177
|
+
|
|
178
|
+
Task ID: {{taskId}}
|
|
179
|
+
Title: {{title}}
|
|
180
|
+
Stage: {{stage}}
|
|
181
|
+
|
|
182
|
+
User Request:
|
|
183
|
+
"""
|
|
184
|
+
{{taskTitle}}
|
|
185
|
+
{{taskContent}}
|
|
186
|
+
---
|
|
187
|
+
Task Thread:
|
|
188
|
+
{{taskComments}}
|
|
189
|
+
"""
|
|
190
|
+
|
|
191
|
+
Stage Objective: {{stagePrompt}}
|
|
192
|
+
Stage Completion Requirement: {{stageRequirement}}
|
|
193
|
+
|
|
194
|
+
Local run artifacts folder: {{runRoot}}
|
|
195
|
+
Key run files:
|
|
196
|
+
{{runFiles}}
|
|
197
|
+
|
|
198
|
+
Relevant files referenced during execution (detected from output/logs):
|
|
199
|
+
{{refsBlock}}
|
|
200
|
+
|
|
201
|
+
Decide if the task is done. If not, provide the next instruction for another iteration.
|
|
202
|
+
Only set "done": true when the Stage Completion Requirement is satisfied.
|
|
203
|
+
|
|
204
|
+
You may think through your analysis first, but you MUST end your response with valid JSON.
|
|
205
|
+
|
|
206
|
+
Output contract (strict):
|
|
207
|
+
- You may include thinking/reasoning at the start of your response
|
|
208
|
+
- Your response MUST end with exactly one raw JSON object
|
|
209
|
+
- Do not use markdown/code fences/backticks around the JSON
|
|
210
|
+
- Do not add commentary after the JSON
|
|
211
|
+
- Use double-quoted keys and strings
|
|
212
|
+
- Keep newlines escaped inside strings
|
|
213
|
+
- If "done" is false, "next_prompt" must be a non-empty actionable instruction
|
|
214
|
+
|
|
215
|
+
The final JSON in your response must have this exact shape:
|
|
216
|
+
{
|
|
217
|
+
"done": false,
|
|
218
|
+
"decision": "done|blocked|not_done|failed",
|
|
219
|
+
"explanation": "clear explanation of the decision",
|
|
220
|
+
"final_result": "final result if done, empty string otherwise",
|
|
221
|
+
"next_prompt": "specific actionable instruction for next iteration",
|
|
222
|
+
"summary": "brief summary of current state"
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
If uncertain, still return valid JSON with decision "failed" and explain why in "explanation".
|
|
226
|
+
`;
|
|
227
|
+
|
|
228
|
+
const EXECUTE_ITERATION = `EXECUTE PHASE
|
|
229
|
+
Iteration: {{iteration}}
|
|
230
|
+
|
|
231
|
+
Keep output concise and avoid dumping full file contents or long logs.
|
|
232
|
+
If you need to reference code, cite paths and describe changes instead of pasting whole files.
|
|
233
|
+
|
|
234
|
+
Output contract:
|
|
235
|
+
- Start with "PLAN:" then 2-5 bullets.
|
|
236
|
+
- Do the work.
|
|
237
|
+
- End with "IMPLEMENTATION SUMMARY:" bullets:
|
|
238
|
+
- Changed: (paths only, 10 max)
|
|
239
|
+
- Commands: (what you ran)
|
|
240
|
+
- Notes:
|
|
241
|
+
|
|
242
|
+
Task for this iteration: {{instruction}}
|
|
243
|
+
|
|
244
|
+
Do not output JSON in this phase.
|
|
245
|
+
`;
|
|
246
|
+
|
|
247
|
+
const VERIFY_PROMPT = `You are the verifier for an agx run.
|
|
248
|
+
|
|
249
|
+
Task ID: {{taskId}}
|
|
250
|
+
Title: {{title}}
|
|
251
|
+
Stage: {{stage}}
|
|
252
|
+
Iteration: {{iteration}}
|
|
253
|
+
|
|
254
|
+
Stage Objective: {{stagePrompt}}
|
|
255
|
+
Stage Completion Requirement: {{stageRequirement}}
|
|
256
|
+
|
|
257
|
+
Local run artifacts folder: {{runRoot}}
|
|
258
|
+
|
|
259
|
+
User Request:
|
|
260
|
+
"""
|
|
261
|
+
{{requestTitle}}
|
|
262
|
+
{{requestContent}}
|
|
263
|
+
"""
|
|
264
|
+
|
|
265
|
+
## Verification Strategy
|
|
266
|
+
|
|
267
|
+
Your job is to determine whether the user request is actually satisfied in the codebase. Do NOT rely solely on git status/diff or agent output summaries — these can be misleading, incomplete, or refer to the wrong workspace.
|
|
268
|
+
|
|
269
|
+
Follow this approach:
|
|
270
|
+
|
|
271
|
+
1. **Understand the request.** What concrete outcome does the user want? (e.g., a function wired to an endpoint, a new component, a bug fix)
|
|
272
|
+
|
|
273
|
+
2. **Read the actual source files.** Identify the key files that should contain the implementation and read them directly. Look for the specific functions, imports, routes, or components that the request describes. This is the primary evidence.
|
|
274
|
+
|
|
275
|
+
3. **Check verification command output.** If tests or build commands were run, use their results as supporting evidence — but only after you've confirmed the implementation exists in the source.
|
|
276
|
+
|
|
277
|
+
4. **Use git status/diff as secondary context.** Diff tells you what changed this iteration, but the feature may have been implemented in a prior iteration or already existed. Absence of a diff does NOT mean the work is incomplete.
|
|
278
|
+
|
|
279
|
+
5. **Trace the full path.** For wiring tasks, verify both ends: the data source (API helper, service function) AND the consumer (page, component, hook). For bug fixes, verify the fix AND that the triggering condition is handled.
|
|
280
|
+
|
|
281
|
+
Repo summary (git):
|
|
282
|
+
Status (porcelain):
|
|
283
|
+
{{statusShort}}
|
|
284
|
+
|
|
285
|
+
Diff (stat):
|
|
286
|
+
{{diffShort}}
|
|
287
|
+
|
|
288
|
+
Verification commands:
|
|
289
|
+
{{cmdLines}}
|
|
290
|
+
|
|
291
|
+
Agent output (last iteration):
|
|
292
|
+
{{agentOutputShort}}
|
|
293
|
+
|
|
294
|
+
Decide if the stage is complete based on what you find in the source files.
|
|
295
|
+
Ignore unrelated working tree changes; focus on whether the user request is satisfied.
|
|
296
|
+
If not complete, provide the next smallest instruction for another iteration.
|
|
297
|
+
Set "done": true when the user request is satisfied and the source code evidence supports it.
|
|
298
|
+
|
|
299
|
+
Output contract (strict): your response MUST be exactly one raw JSON object with this shape:
|
|
300
|
+
{
|
|
301
|
+
"done": false,
|
|
302
|
+
"decision": "done|blocked|not_done|failed",
|
|
303
|
+
"explanation": "clear explanation of the decision",
|
|
304
|
+
"final_result": "final result if done, empty string otherwise",
|
|
305
|
+
"next_prompt": "specific actionable instruction for next iteration",
|
|
306
|
+
"summary": "brief summary of current state",
|
|
307
|
+
"plan_md": "PLAN markdown for this iteration (newlines escaped)",
|
|
308
|
+
"implementation_summary_md": "IMPLEMENTATION SUMMARY markdown (newlines escaped)",
|
|
309
|
+
"verification_md": "VERIFICATION markdown (newlines escaped)"
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
Rules:
|
|
313
|
+
- Use double-quoted keys and strings.
|
|
314
|
+
- Keep newlines escaped inside strings (use \\n).
|
|
315
|
+
- Keep the markdown fields short and checklist-style.
|
|
316
|
+
- Always fill "explanation". For "blocked", include what is blocking and what input/action would unblock. For "failed", include what failed (command/tool/error) and a recovery step.
|
|
317
|
+
`;
|
|
318
|
+
|
|
319
|
+
const EXECUTOR_PROMPT = `# Task: {{title}}
|
|
320
|
+
|
|
321
|
+
## Stage: {{stage}}
|
|
322
|
+
|
|
323
|
+
{{stagePrompt}}
|
|
324
|
+
|
|
325
|
+
## Project Context
|
|
326
|
+
|
|
327
|
+
{{projectContext}}
|
|
328
|
+
|
|
329
|
+
## Task Details
|
|
330
|
+
|
|
331
|
+
{{content}}
|
|
332
|
+
|
|
333
|
+
## Instructions
|
|
334
|
+
|
|
335
|
+
1. Complete the work for this stage
|
|
336
|
+
2. Use [checkpoint: message] to save progress
|
|
337
|
+
3. Use [learn: insight] to record learnings
|
|
338
|
+
4. Use [done] when stage is complete
|
|
339
|
+
5. Use [blocked: reason] if you need human help
|
|
340
|
+
|
|
341
|
+
Focus on this stage only. The task will automatically advance to the next stage when complete.
|
|
342
|
+
`;
|
|
343
|
+
|
|
344
|
+
module.exports = {
|
|
345
|
+
interpolate,
|
|
346
|
+
DEFAULT_STAGE_PROMPT,
|
|
347
|
+
PROJECT_CONTEXT,
|
|
348
|
+
AGX_SKILL,
|
|
349
|
+
CONTINUE_CLOUD_TASK,
|
|
350
|
+
NEW_AUTONOMOUS_CLOUD_TASK,
|
|
351
|
+
LEGACY_INSTRUCTION_FOOTER,
|
|
352
|
+
AGGREGATOR_PROMPT,
|
|
353
|
+
EXECUTE_ITERATION,
|
|
354
|
+
VERIFY_PROMPT,
|
|
355
|
+
EXECUTOR_PROMPT,
|
|
356
|
+
};
|
package/package.json
CHANGED
|
@@ -130,6 +130,23 @@ CREATE TABLE IF NOT EXISTS agx.stage_prompts (
|
|
|
130
130
|
workflow_id uuid
|
|
131
131
|
);
|
|
132
132
|
|
|
133
|
+
CREATE TABLE IF NOT EXISTS agx.task_templates (
|
|
134
|
+
id uuid DEFAULT gen_random_uuid() NOT NULL PRIMARY KEY,
|
|
135
|
+
user_id uuid,
|
|
136
|
+
slug text NOT NULL,
|
|
137
|
+
name text NOT NULL,
|
|
138
|
+
description text,
|
|
139
|
+
provider text,
|
|
140
|
+
model text,
|
|
141
|
+
content text NOT NULL,
|
|
142
|
+
is_public boolean DEFAULT false,
|
|
143
|
+
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
144
|
+
updated_at timestamp with time zone DEFAULT now() NOT NULL
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
CREATE UNIQUE INDEX IF NOT EXISTS task_templates_public_slug_idx ON agx.task_templates (slug) WHERE user_id IS NULL;
|
|
148
|
+
CREATE UNIQUE INDEX IF NOT EXISTS task_templates_user_slug_idx ON agx.task_templates (user_id, slug) WHERE user_id IS NOT NULL;
|
|
149
|
+
|
|
133
150
|
-- Per-user preferences (default provider/model), shared between CLI and web.
|
|
134
151
|
-- `changed_at` is the user-visible last-change timestamp (may come from clients);
|
|
135
152
|
-- `updated_at` is server-maintained via trigger.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8008],{63:(e,t,r)=>{"use strict";var s=r(7260);r.o(s,"usePathname")&&r.d(t,{usePathname:function(){return s.usePathname}}),r.o(s,"useRouter")&&r.d(t,{useRouter:function(){return s.useRouter}}),r.o(s,"useSearchParams")&&r.d(t,{useSearchParams:function(){return s.useSearchParams}})},926:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{callServer:function(){return s.callServer},createServerReference:function(){return c.createServerReference},findSourceMapURL:function(){return n.findSourceMapURL}});let s=r(1209),n=r(5153),c=r(7197)},4327:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>u});var s=r(5155),n=r(2115),c=r(63),a=r(926);let l=(0,a.createServerReference)("4054e5930986779ae0371b879e98c4b45014e684bb",a.callServer,void 0,a.findSourceMapURL,"approveDeviceCode");function o(){let e=(0,c.useSearchParams)(),t=(0,c.useRouter)(),r=e.get("user_code")||"",[a,o]=(0,n.useState)(r),[u,i]=(0,n.useState)(!1),[d,f]=(0,n.useState)(null),[x,h]=(0,n.useState)(!1);(0,n.useEffect)(()=>{if(x){let e=setTimeout(()=>{t.push("/projects")},3e3);return()=>clearTimeout(e)}},[x,t]);let m=async e=>{e.preventDefault(),i(!0),f(null);try{let e=await l(a);if(!e.success)throw Error(e.error);h(!0)}catch(e){f(e.message)}finally{i(!1)}};return x?(0,s.jsx)("div",{className:"flex flex-col items-center justify-center min-h-screen bg-neutral-900 text-white p-4",children:(0,s.jsxs)("div",{className:"max-w-md w-full bg-neutral-800 p-8 rounded-xl shadow-2xl text-center",children:[(0,s.jsx)("h1",{className:"text-3xl font-bold mb-4 text-green-400",children:"Success!"}),(0,s.jsx)("p",{className:"text-gray-300 mb-2",children:"You have successfully authenticated your device."}),(0,s.jsx)("p",{className:"text-gray-400 text-sm mb-6 italic",children:"Redirecting to projects in a few seconds..."}),(0,s.jsx)("button",{onClick:()=>t.push("/projects"),className:"w-full py-3 px-4 bg-white text-black font-semibold rounded-lg hover:bg-gray-200 transition-colors",children:"Go to Projects"})]})}):(0,s.jsx)("div",{className:"flex flex-col items-center justify-center min-h-screen bg-neutral-900 text-white p-4",children:(0,s.jsxs)("div",{className:"max-w-md w-full bg-neutral-800 p-8 rounded-xl shadow-2xl",children:[(0,s.jsx)("h1",{className:"text-2xl font-bold mb-6 text-center",children:"Connect Device"}),(0,s.jsx)("p",{className:"text-gray-400 mb-8 text-center text-sm",children:"Enter the code displayed on your device to authorize it."}),(0,s.jsxs)("form",{onSubmit:m,className:"space-y-6",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"code",className:"block text-sm font-medium text-gray-400 mb-2",children:"Device Code"}),(0,s.jsx)("input",{type:"text",id:"code",value:a,onChange:e=>o(e.target.value.toUpperCase()),placeholder:"BCDF-XXXX",className:"w-full px-4 py-3 bg-neutral-900 border border-neutral-700 rounded-lg text-white placeholder-neutral-600 focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono text-center tracking-widest text-lg uppercase",required:!0})]}),d&&(0,s.jsx)("div",{className:"p-3 bg-red-900/50 border border-red-800 rounded-lg text-red-200 text-center text-sm",children:d}),(0,s.jsx)("button",{type:"submit",disabled:u,className:"w-full py-3 px-4 bg-white text-black font-semibold rounded-lg hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:u?"Verifying...":"Authorize Device"})]})]})})}function u(){return(0,s.jsx)(n.Suspense,{fallback:(0,s.jsx)("div",{children:"Loading..."}),children:(0,s.jsx)(o,{})})}},5109:(e,t,r)=>{Promise.resolve().then(r.bind(r,4327))}},e=>{e.O(0,[8441,1255,7358],()=>e(e.s=5109)),_N_E=e.O()}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5105],{63:(e,t,a)=>{"use strict";var s=a(7260);a.o(s,"usePathname")&&a.d(t,{usePathname:function(){return s.usePathname}}),a.o(s,"useRouter")&&a.d(t,{useRouter:function(){return s.useRouter}}),a.o(s,"useSearchParams")&&a.d(t,{useSearchParams:function(){return s.useSearchParams}})},415:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>f});var s=a(5155),r=a(2115),l=a(63),n=a(1460),o=a(2888),d=a(6779),i=a(2835),c=a(7290),u=a(2325),m=a(8545);function x(e){let{onClose:t,workflowId:a}=e,{workflow:l,isLoading:n,refetch:o}=(0,u.mP)({workflowId:a}),{providers:d}=(0,m.u)(),[i,c]=(0,r.useState)([]),[x,p]=(0,r.useState)(null),[h,v]=(0,r.useState)(!1),[g,b]=(0,r.useState)({}),f=e=>u.ls[e]||{icon:"\uD83D\uDCCC",label:e.charAt(0).toUpperCase()+e.slice(1),color:"var(--primary)"};(0,r.useEffect)(()=>{let e=(Array.isArray(null==l?void 0:l.nodes)?l.nodes:[]).slice().sort((e,t)=>(e.position||0)-(t.position||0)).map(e=>{var t,a;return{id:e.id,name:e.name,label:e.label||e.name,prompt:e.prompt||"",provider:e.provider||"codex",model:e.model||"",swarm:!!(null==e||null==(t=e.metadata)?void 0:t.swarm),swarm_models:Array.isArray(null==e||null==(a=e.metadata)?void 0:a.swarm_models)?e.metadata.swarm_models:[],metadata:(null==e?void 0:e.metadata)&&"object"==typeof e.metadata?e.metadata:{}}});c(e),b({}),p(t=>t&&e.some(e=>e.id===t)?t:e.length?e[0].id:null)},[null==l?void 0:l.id,null==l?void 0:l.nodes]);let j=i.findIndex(e=>e.id===x),w=j>=0?i[j]:null,N=w?{...w,...g[w.id]||{}}:null,y=(e,t)=>{w&&b(a=>({...a,[w.id]:{...a[w.id]||{},[e]:t}}))},k=async()=>{if(l){v(!0);try{let e=i.map(e=>{let t={...e,...g[e.id]||{}};return{...t,metadata:{...t.metadata||{},swarm:!!t.swarm,swarm_models:t.swarm_models||[]}}}),a=await fetch("/api/workflows/".concat(l.id,"/nodes"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({nodes:e.map(e=>({id:e.id,prompt:e.prompt,provider:e.provider,model:e.model,metadata:e.metadata}))})});if(!a.ok)throw Error("Failed to save workflow");await a.json(),o(),b({}),t()}catch(e){console.error("Error saving workflow:",e)}finally{v(!1)}}};return n&&!l?(0,s.jsx)("div",{className:"modal-backdrop p-4 flex items-center justify-center",children:(0,s.jsx)("span",{className:"spinner w-8 h-8 border-2 border-white/20 border-t-white"})}):(0,s.jsx)("div",{className:"modal-backdrop p-4",onClick:e=>e.target===e.currentTarget&&t(),children:(0,s.jsxs)("div",{className:"modal-content w-full max-w-5xl h-[85vh] flex flex-col animate-scale-in p-0 bg-[var(--card-bg)] overflow-hidden rounded-xl border border-[var(--card-border)] shadow-2xl",children:[(0,s.jsxs)("div",{className:"px-6 py-4 border-b border-[var(--border)] flex items-center justify-between bg-[var(--background)]",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("h2",{className:"text-lg font-bold flex items-center gap-2",children:[(0,s.jsx)("span",{children:"⚙️"})," Workflow Configuration"]}),(0,s.jsxs)("p",{className:"text-xs text-[var(--muted-foreground)] mt-0.5",children:["Editing: ",(0,s.jsx)("span",{className:"font-mono text-[var(--foreground)]",children:(null==l?void 0:l.name)||"Loading..."})]})]}),(0,s.jsx)("button",{onClick:t,className:"btn-ghost p-2 rounded",children:(0,s.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,s.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,s.jsxs)("div",{className:"w-64 bg-[var(--muted)]/30 border-r border-[var(--border)] overflow-y-auto p-4 flex flex-col gap-1",children:[(0,s.jsx)("div",{className:"flex items-center justify-between mb-2 px-2",children:(0,s.jsx)("span",{className:"text-xs font-bold uppercase tracking-wider text-[var(--muted-foreground)]",children:"Steps"})}),0===i.length&&(0,s.jsx)("div",{className:"text-sm text-[var(--muted-foreground)] px-2 italic",children:"No steps defined in this workflow."}),i.map(e=>{let t=f(e.name),a=!!g[e.id];return(0,s.jsxs)("button",{onClick:()=>p(e.id),className:"w-full text-left px-3 py-2.5 rounded-lg text-sm font-medium transition-all flex items-center gap-3 ".concat(x===e.id?"bg-[var(--card-bg)] text-[var(--foreground)] shadow-sm border border-[var(--border)]":"text-[var(--muted-foreground)] hover:bg-[var(--card-bg)]/50"),children:[(0,s.jsx)("span",{className:"text-base",children:t.icon}),(0,s.jsx)("span",{className:"flex-1 truncate",children:e.label||t.label}),a&&(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--accent)]"})]},e.id)})]}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto p-8 relative bg-[var(--card-bg)]",children:[N?(0,s.jsxs)("div",{className:"max-w-3xl mx-auto space-y-8 animate-fade-in",children:[(0,s.jsxs)("div",{className:"flex items-center gap-4 pb-6 border-b border-[var(--border)]",children:[(0,s.jsx)("div",{className:"w-12 h-12 rounded-xl bg-[var(--muted)]/50 flex items-center justify-center text-2xl shadow-inner",children:f(N.name).icon}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-xl font-bold",children:N.label}),(0,s.jsxs)("p",{className:"text-sm text-[var(--muted-foreground)] font-mono opacity-70",children:["ID: ",N.id," • Key: ",N.name]})]})]}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("label",{className:"text-sm font-semibold uppercase tracking-wider text-[var(--muted-foreground)]",children:"System Prompt"}),(0,s.jsx)("span",{className:"text-xs text-[var(--muted-foreground)] bg-[var(--muted)]/50 px-2 py-0.5 rounded",children:"Markdown Supported"})]}),(0,s.jsx)("textarea",{value:N.prompt||"",onChange:e=>y("prompt",e.target.value),className:"input w-full h-64 font-mono text-sm leading-relaxed resize-y p-4",placeholder:"Define the agent's behavior, constraints, and output format for this stage..."})]}),(0,s.jsxs)("div",{className:"p-6 rounded-xl bg-[var(--muted)]/20 border border-[var(--border)] space-y-6",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("h4",{className:"font-semibold flex items-center gap-2",children:[(0,s.jsx)("span",{children:"\uD83E\uDD16"})," Model Settings"]}),(0,s.jsxs)("div",{className:"flex items-center gap-3 bg-[var(--card-bg)] px-3 py-1.5 rounded-lg border border-[var(--border)]",children:[(0,s.jsx)("span",{className:"text-sm font-medium",children:"Swarm Mode"}),(0,s.jsx)("button",{onClick:()=>y("swarm",!N.swarm),className:"w-9 h-5 rounded-full transition-colors relative ".concat(N.swarm?"bg-[var(--primary)]":"bg-[var(--muted-foreground)]/30"),children:(0,s.jsx)("span",{className:"absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full transition-transform ".concat(N.swarm?"translate-x-4":"translate-x-0")})})]})]}),N.swarm?(0,s.jsxs)("div",{className:"space-y-4 animate-fade-in",children:[(0,s.jsxs)("div",{className:"flex justify-between items-center",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-[var(--muted-foreground)]",children:"Swarm Models"}),(0,s.jsx)("button",{onClick:()=>{y("swarm_models",[...N.swarm_models||[],{provider:"gemini",model:""}])},className:"btn-secondary text-xs px-2 py-1",children:"+ Add Model"})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[0===(N.swarm_models||[]).length&&(0,s.jsx)("div",{className:"text-center py-8 border-2 border-dashed border-[var(--border)] rounded-lg text-sm text-[var(--muted-foreground)]",children:"No models configured for swarm. Add one to enable."}),(N.swarm_models||[]).map((e,t)=>(0,s.jsxs)("div",{className:"flex gap-2 items-center group",children:[(0,s.jsx)("select",{value:e.provider,onChange:e=>{let a=[...N.swarm_models||[]];a[t].provider=e.target.value,y("swarm_models",a)},className:"input text-sm py-1.5 w-32",children:d.map(e=>(0,s.jsx)("option",{value:e.id,children:e.label},e.id))}),(0,s.jsx)("input",{value:e.model,onChange:e=>{let a=[...N.swarm_models||[]];a[t].model=e.target.value,y("swarm_models",a)},placeholder:"Model name (e.g. gemini-1.5-pro)",className:"input text-sm py-1.5 flex-1"}),(0,s.jsx)("button",{onClick:()=>{y("swarm_models",(N.swarm_models||[]).filter((e,a)=>a!==t))},className:"text-[var(--muted-foreground)] hover:text-[var(--destructive)] hover:bg-[var(--destructive)]/10 p-1.5 rounded opacity-0 group-hover:opacity-100 transition-all",children:"✕"})]},t))]})]}):(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-4 animate-fade-in",children:[(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("label",{className:"text-xs font-semibold text-[var(--muted-foreground)] uppercase",children:"Provider"}),(0,s.jsx)("select",{value:N.provider||"gemini",onChange:e=>y("provider",e.target.value),className:"input w-full text-sm py-2",children:d.map(e=>(0,s.jsx)("option",{value:e.id,children:e.label},e.id))})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("label",{className:"text-xs font-semibold text-[var(--muted-foreground)] uppercase",children:"Model"}),(0,s.jsx)("input",{value:N.model||"",onChange:e=>y("model",e.target.value),placeholder:"e.g. gemini-2.0-flash",className:"input w-full text-sm py-2"})]})]})]})]}):null,!w&&i.length>0&&(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-[var(--muted-foreground)]",children:[(0,s.jsx)("span",{className:"text-4xl mb-4 opacity-30",children:"\uD83D\uDC48"}),(0,s.jsx)("p",{children:"Select a step from the sidebar to configure it."})]})]})]}),(0,s.jsxs)("div",{className:"px-6 py-4 border-t border-[var(--border)] bg-[var(--background)] flex justify-end gap-3",children:[(0,s.jsx)("button",{onClick:t,className:"btn-ghost px-4 py-2",children:"Cancel"}),(0,s.jsxs)("button",{onClick:k,disabled:h||0===Object.keys(g).length,className:"btn-primary px-6 py-2 flex items-center gap-2",children:[h&&(0,s.jsx)("span",{className:"spinner w-4 h-4 border-2 border-white/20 border-t-white"}),h?"Saving...":"Save Changes"]})]})]})})}var p=a(577),h=a(91);function v(){return(0,s.jsxs)("div",{className:"p-4 rounded-xl bg-[var(--card-bg)] border border-[var(--card-border)]",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between mb-3",children:[(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsxs)("div",{className:"flex gap-2 mb-2",children:[(0,s.jsx)("div",{className:"skeleton h-4 w-8 rounded"}),(0,s.jsx)("div",{className:"skeleton h-4 w-16 rounded"})]}),(0,s.jsx)("div",{className:"skeleton h-5 w-3/4 rounded"})]}),(0,s.jsx)("div",{className:"skeleton h-5 w-20 rounded-full"})]}),(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("div",{className:"skeleton h-4 w-24 rounded"}),(0,s.jsx)("div",{className:"skeleton h-4 w-12 rounded"})]})]})}function g(){return(0,s.jsx)("div",{className:"flex gap-4 overflow-x-auto pb-4 px-4",children:[1,2,3,4,5].map(e=>(0,s.jsxs)("div",{className:"flex-shrink-0 w-72 kanban-column",children:[(0,s.jsx)("div",{className:"kanban-column-header",children:(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("div",{className:"skeleton h-6 w-6 rounded"}),(0,s.jsx)("div",{className:"skeleton h-5 w-20 rounded"})]}),(0,s.jsx)("div",{className:"skeleton h-5 w-6 rounded-full"})]})}),(0,s.jsx)("div",{className:"p-2 space-y-2",children:[1,2].map(e=>(0,s.jsxs)("div",{className:"p-3 rounded-lg bg-[var(--background)] border-l-2 border-[var(--card-border)]",children:[(0,s.jsx)("div",{className:"skeleton h-3 w-12 rounded mb-2"}),(0,s.jsx)("div",{className:"skeleton h-4 w-full rounded mb-2"}),(0,s.jsx)("div",{className:"skeleton h-3 w-20 rounded"})]},e))})]},e))})}function b(){var e,t,a,b;let f=(0,l.useRouter)(),j=(0,l.useSearchParams)(),w=(0,l.usePathname)(),N=(null==j?void 0:j.get("project"))||void 0,y=j.get("view")||"kanban",k=j.get("sort")||"newest",[C,_]=(0,r.useState)(y),[S,A]=(0,r.useState)(k),[T,D]=(0,r.useState)("all"),[E,L]=(0,r.useState)(""),[P,I]=(0,r.useState)(null),[B,R]=(0,r.useState)(null),[M,U]=(0,r.useState)(!1),[q,F]=(0,r.useState)(null),[O,X]=(0,r.useState)(!1),[z,W]=(0,r.useState)(""),[G,V]=(0,r.useState)(!1),[H,K]=(0,r.useState)("single"),[Q,Y]=(0,r.useState)("gemini"),[J,Z]=(0,r.useState)(""),[$,ee]=(0,r.useState)([]),[et,ea]=(0,r.useState)("gemini"),[es,er]=(0,r.useState)(""),[el,en]=(0,r.useState)(null),[eo,ed]=(0,r.useState)(!1),[ei,ec]=(0,r.useState)(!1),[eu,em]=(0,r.useState)(null),{providers:ex}=(0,m.u)();(0,r.useEffect)(()=>{let e=e=>{let t=e.target,a=["INPUT","TEXTAREA","SELECT"].includes(t.tagName)||t.isContentEditable;if("n"!==e.key||a||(e.preventDefault(),X(!0)),"/"===e.key&&!a){var s;e.preventDefault(),null==(s=document.getElementById("task-search"))||s.focus()}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]);let{tasks:ep,isLoading:eh,createTask:ev,updateTask:eg,deleteTask:eb,completeTaskStage:ef,cancelWorkflow:ej,refetch:ew,cancellingTaskId:eN,fetchTask:ey}=(0,p.si)({realtime:!0,project:N}),{projects:ek,isLoading:eC}=(0,h.Y)(),{comments:e_,addComment:eS,deleteComment:eA}=(0,p.LU)((null==P?void 0:P.id)||null),{learnings:eT,addLearning:eD}=(0,p.dF)((null==P?void 0:P.id)||void 0),{workflow:eE,stages:eL,stageConfig:eP,isValidTransition:eI,isLoading:eB}=(0,u.mP)(),eR=(0,r.useMemo)(()=>eL.map(e=>{var t;let a=eP[e],s=null==eE||null==(t=eE.nodes)?void 0:t.find(t=>t.name===e);return{id:e,label:(null==a?void 0:a.label)||e,icon:(null==a?void 0:a.icon)||"\uD83D\uDCCC",color:(null==a?void 0:a.color)||"var(--primary)",prompt:(null==s?void 0:s.prompt)||void 0}}),[eL,eP,eE]),eM=e=>{_(e);let t=new URLSearchParams(j);t.set("view",e),f.push("".concat(w,"?").concat(t.toString()))},eU=(0,r.useMemo)(()=>{let e=[...ep];if(E){let t=E.toLowerCase();e=e.filter(e=>{var a,s,r;return(null==(a=e.title)?void 0:a.toLowerCase().includes(t))||(null==(s=e.description)?void 0:s.toLowerCase().includes(t))||e.id.toLowerCase().includes(t)||(null==(r=e.project)?void 0:r.toLowerCase().includes(t))})}return"all"!==T&&(e="active"===T?e.filter(e=>"completed"!==e.status&&"failed"!==e.status):e.filter(e=>e.status===T)),e.sort((e,t)=>{switch(S){case"newest":return new Date(t.created_at).getTime()-new Date(e.created_at).getTime();case"oldest":return new Date(e.created_at).getTime()-new Date(t.created_at).getTime();case"priority":return(e.priority||0)-(t.priority||0);case"updated":return new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime();default:return 0}}),e},[ep,E,T,S]),eq=(0,r.useCallback)(async(e,t)=>{t&&I(t);try{let t=await ey(e);return I(t),t}catch(e){return console.error("Failed to load task details:",e),t||I(null),null!=t?t:null}},[ey]),eF=(0,r.useCallback)(async e=>{await eq(e.id,e)},[eq]),eO=(0,r.useCallback)(async e=>{var t,a;let s=N?ek.find(e=>e.slug===N):null;R({stage:e,project:null!=(t=null==s?void 0:s.slug)?t:null,project_id:null!=(a=null==s?void 0:s.id)?a:null})},[N,ek]),eX=(0,r.useCallback)(async e=>{var t,a;let s=(e.description||"").trim();if(!s)return;ec(!0);let r=e.stage||(null==B?void 0:B.stage)||"ideation";em(r);let l="done"===r?"completed":"ideation"===r?"queued":"in_progress",n=(null==eP||null==(t=eP[r])?void 0:t.label)||r,o=(e.title||"").trim()||s.split("\n")[0].replace(/^#\s*/,"")||"New Task (".concat(n,")"),d=["status: ".concat(l),"stage: ".concat(r)],i=e.project_id&&ek.find(t=>t.id===e.project_id)||e.project&&ek.find(t=>t.slug===e.project)||(N?ek.find(e=>e.slug===N):null);i&&(d.push("project: ".concat(i.slug)),d.push("project_id: ".concat(i.id)),d.push("workflow_id: ".concat(i.workflow_id||u.ou))),e.provider&&d.push("provider: ".concat(e.provider)),e.model&&d.push("model: ".concat(e.model)),void 0!==e.swarm&&d.push("swarm: ".concat(e.swarm?"true":"false"));let c="---\n".concat(d.join("\n"),"\n---\n\n# ").concat(o,"\n\n").concat(s);try{let t=e.swarm?null!=(a=e.swarm_models)?a:[]:null,s=await ev(c,t);R(null),await eq(s.id,s)}catch(e){console.error("Failed to create task:",e)}finally{ec(!1),em(null)}},[ev,B,eq,N,ek,eP]),ez=(0,r.useCallback)(async(e,t)=>{await eg(e,t)},[eg]),eW=async e=>{let t=ep.find(t=>t.id===e);F(null);try{var a;await ej({taskId:e}),await ew(),F({type:"success",message:"Cancellation requested for ".concat((null==t?void 0:t.title)||(null==t||null==(a=t.content)?void 0:a.slice(0,30))||e,".")})}catch(s){console.error("Failed to stop task",s);let a=s instanceof Error?s.message:"unknown error";F({type:"error",message:"Unable to stop ".concat((null==t?void 0:t.title)||e,": ").concat(a,".")})}},eG=async e=>{try{await ef({taskId:e,decision:"not_done",final_result:"Manual retry requested.",explanation:"Manual retry requested."})}catch(e){console.error("Failed to retry task",e)}};(0,r.useEffect)(()=>{if(!q)return;let e=setTimeout(()=>F(null),5e3);return()=>clearTimeout(e)},[q]);let eV=async()=>{if(z.trim()&&!G){V(!0);try{var e;let t=["status: queued","stage: ideation"];"single"!==H&&t.push("swarm: true");let a=el||(N?null==(e=ek.find(e=>e.slug===N))?void 0:e.id:null);if(a){let e=ek.find(e=>e.id===a);e&&(t.push("project: ".concat(e.slug)),t.push("project_id: ".concat(e.id)),t.push("workflow_id: ".concat(e.workflow_id||u.ou)))}let s="---\n".concat(t.join("\n"),"\n---\n\n# ").concat(z,"\n");await ev(s,"swarm"===H?$:null),W(""),K("single"),Y("gemini"),Z(""),ee([]),ea("gemini"),er(""),X(!1),en(null)}catch(e){console.error("Failed to create task:",e)}finally{V(!1)}}},eH=async(e,t)=>{let a="---\n".concat(["status: ".concat("ideation"===t?"queued":"in_progress"),"stage: ".concat(t)].join("\n"),"\n---\n\n# ").concat(e,"\n");await ev(a,null),ed(!1)},eK=async e=>{P&&await eS(e)},eQ=async(e,t,a)=>{var s,r;let l=(null==P||null==(r=P.project_context)||null==(s=r.project)?void 0:s.id)||(null==P?void 0:P.project_id)||(null==P?void 0:P.project)||void 0,n=null!=a?a:"global"===t?void 0:"task"===t?null==P?void 0:P.id:l;await eD(e,t,n)},eY=async e=>{P&&(I(t=>t?{...t,...e}:null),await eg(P.id,e))};return(ep.length,ep.filter(e=>"in_progress"===e.status).length,ep.filter(e=>"queued"===e.status).length,ep.filter(e=>"completed"===e.status).length,(eh||eB)&&0===ep.length)?(0,s.jsxs)("div",{className:"h-full flex flex-col p-6 animate-pulse",children:[(0,s.jsxs)("div",{className:"flex justify-between items-center mb-8",children:[(0,s.jsx)("div",{className:"h-8 w-48 bg-[var(--card-border)] rounded"}),(0,s.jsx)("div",{className:"h-10 w-32 bg-[var(--card-border)] rounded"})]}),(0,s.jsx)("div",{className:"h-12 w-full bg-[var(--card-border)] rounded mb-8"}),"kanban"===C?(0,s.jsx)(g,{}):(0,s.jsx)("div",{className:"space-y-4",children:[1,2,3].map(e=>(0,s.jsx)(v,{},e))})]}):(0,s.jsx)(n.A,{fullWidth:!0,noFooter:!0,children:(0,s.jsxs)("div",{className:"flex flex-col h-full ".concat("kanban"===C?"max-w-full":"max-w-6xl mx-auto w-full px-4"),children:[(0,s.jsxs)("div",{className:"relative flex items-center justify-center gap-4 py-3 px-4 border-b border-[var(--border)] bg-[var(--background)] flex-shrink-0 z-20",children:[(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsxs)("div",{className:"relative w-80",children:[(0,s.jsx)("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:(0,s.jsx)("svg",{className:"h-5 w-5 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,s.jsx)("path",{fillRule:"evenodd",d:"M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z",clipRule:"evenodd"})})}),(0,s.jsx)("input",{id:"task-search",type:"text",placeholder:"Search tasks... (/)",className:"block w-full rounded-md border-0 py-1.5 pl-10 text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6 bg-white shadow-sm",value:E,onChange:e=>L(e.target.value)})]}),(0,s.jsxs)("div",{className:"flex items-center bg-gray-100 p-1 rounded-lg border border-gray-200",children:[(0,s.jsx)("button",{onClick:()=>eM("list"),className:"px-3 py-1 text-xs font-medium rounded transition-all ".concat("list"===C?"bg-white shadow-sm text-gray-900":"text-gray-500 hover:text-gray-700"),children:"List"}),(0,s.jsx)("button",{onClick:()=>eM("kanban"),className:"px-3 py-1 text-xs font-medium rounded transition-all ".concat("kanban"===C?"bg-white shadow-sm text-gray-900":"text-gray-500 hover:text-gray-700"),children:"Board"})]}),(0,s.jsxs)("button",{onClick:()=>U(!0),className:"flex items-center gap-2 px-3 py-1.5 text-xs font-medium text-gray-700 bg-white border border-gray-200 rounded-lg shadow-sm hover:bg-gray-50 transition-all",title:"Configure Workflow",children:[(0,s.jsx)("span",{className:"text-base leading-none",children:"⚙️"}),(0,s.jsx)("span",{children:"Workflow"})]})]}),(0,s.jsx)("div",{className:"absolute right-4 flex items-center gap-3"})]}),q&&(0,s.jsx)("div",{className:"px-4 mt-3",children:(0,s.jsx)("div",{role:"status",className:"rounded-xl px-4 py-2 text-xs font-semibold ".concat("success"===q.type?"bg-[var(--success-muted)] text-[var(--success)]":"bg-[var(--destructive-muted)] text-[var(--destructive)]"),children:q.message})}),(0,s.jsx)("div",{className:"flex-shrink-0 mt-2 px-4",children:(0,s.jsx)(i.A,{tasks:ep,onTaskClick:I,onStop:eW,onRetry:eG,cancellingTaskId:eN})}),(0,s.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col pt-2",children:"list"===C?(0,s.jsx)("div",{className:"overflow-y-auto h-full px-4",children:(0,s.jsx)(o.A,{tasks:eU,onSelectTask:eF,onStatusChange:(e,t)=>ez(e,{status:t})})}):(0,s.jsx)(d.A,{tasks:eU,onSelectTask:eF,onTasksChange:()=>{},onTaskUpdate:ez,onAddTask:eO,stages:eL,stageConfig:eP,isValidTransition:eI,isCreatingTask:ei,creatingStage:eu})}),P&&(0,s.jsx)(c.A,{task:P,comments:P?e_:[],learnings:eT,projectContext:P.project_context,projects:ek,stages:eR,onClose:()=>I(null),onAddComment:eK,onDeleteComment:eA,onAddLearning:eQ,onUpdate:eY,onDelete:async()=>{await eb(P.id),I(null)}}),B&&(0,s.jsx)(c.A,{task:{id:"draft",title:"",description:"",content:"",stage:B.stage,status:"done"===B.stage?"completed":"ideation"===B.stage?"queued":"in_progress",created_at:new Date().toISOString(),project:null!=(a=null!=(t=B.project)?t:N)?a:void 0,project_id:null!=(b=B.project_id)?b:N?null==(e=ek.find(e=>e.slug===N))?void 0:e.id:void 0,provider:B.provider,model:B.model,swarm:B.swarm,swarm_models:B.swarm_models},comments:[],learnings:[],projectContext:null,projects:ek,stages:eR,isDraft:!0,isCreating:ei,onClose:()=>R(null),onAddComment:()=>{},onAddLearning:()=>{},onUpdate:async e=>{if(B){if(e.description||e.title)return void await eX({...B,...e});R(t=>t?{...t,...e}:t)}}}),eo&&(0,s.jsx)("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:(0,s.jsxs)("div",{className:"bg-[var(--card-bg)] p-6 rounded-xl w-full max-w-md shadow-2xl border border-[var(--card-border)] animate-scale-in",children:[(0,s.jsx)("h3",{className:"text-lg font-bold mb-4",children:"New Task"}),(0,s.jsxs)("form",{onSubmit:e=>{e.preventDefault();let t=e.target;eH(t.elements.namedItem("title").value,t.elements.namedItem("stage").value)},children:[(0,s.jsx)("input",{name:"title",autoFocus:!0,placeholder:"Task title...",className:"w-full mb-4 px-3 py-2 bg-[var(--background)] border border-[var(--card-border)] rounded focus:border-[var(--primary)] outline-none",required:!0}),(0,s.jsx)("select",{name:"stage",className:"w-full mb-6 px-3 py-2 bg-[var(--background)] border border-[var(--card-border)] rounded focus:border-[var(--primary)] outline-none",children:eL.map(e=>{var t;return(0,s.jsx)("option",{value:e,children:(null==(t=eP[e])?void 0:t.label)||e},e)})}),(0,s.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,s.jsx)("button",{type:"button",onClick:()=>ed(!1),className:"btn-ghost",children:"Cancel"}),(0,s.jsx)("button",{type:"submit",className:"btn-primary",children:"Create Task"})]})]})]})}),M&&(0,s.jsx)(x,{onClose:()=>U(!1),workflowId:null==eE?void 0:eE.id}),O&&(0,s.jsx)("div",{className:"modal-backdrop p-4",onClick:e=>e.target===e.currentTarget&&X(!1),children:(0,s.jsxs)("div",{className:"modal-content w-full max-w-lg p-6 animate-scale-in",children:[(0,s.jsxs)("h2",{className:"text-xl font-bold mb-4 flex items-center gap-2",children:[(0,s.jsx)("span",{children:"✨"})," New Task"]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,s.jsx)("button",{onClick:()=>K("single"),className:"px-3 py-1.5 text-xs font-semibold rounded-md uppercase tracking-wide transition-all ".concat("single"===H?"bg-[var(--card-bg)] text-[var(--primary)] shadow-sm border border-[var(--border)]":"text-[var(--muted-foreground)] hover:text-[var(--foreground)] border border-transparent"),children:"Single Agent"}),(0,s.jsx)("button",{onClick:()=>K("swarm"),className:"px-3 py-1.5 text-xs font-semibold rounded-md uppercase tracking-wide transition-all ".concat("swarm"===H?"bg-[var(--card-bg)] text-[var(--primary)] shadow-sm border border-[var(--border)]":"text-[var(--muted-foreground)] hover:text-[var(--foreground)] border border-transparent"),children:"Swarm"})]}),(0,s.jsx)("textarea",{value:z,onChange:e=>W(e.target.value),placeholder:"Describe what needs to be done...",className:"input h-32 resize-none mb-4",autoFocus:!0,disabled:G}),(0,s.jsxs)("label",{className:"text-xs font-semibold mb-3 block",children:["Attach to project",(0,s.jsxs)("select",{value:null!=el?el:"",onChange:e=>en(e.target.value||null),className:"input text-sm mt-1",disabled:eC,children:[(0,s.jsxs)("option",{value:"",children:["None (Current: ",N||"All",")"]}),ek.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),"single"===H?(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 mb-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-[11px] font-medium text-[var(--muted-foreground)] mb-1",children:"Provider"}),(0,s.jsx)("select",{value:Q,onChange:e=>Y(e.target.value),className:"input text-xs py-1.5 appearance-none",children:ex.map(e=>(0,s.jsx)("option",{value:e.id,children:e.label},e.id))})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-[11px] font-medium text-[var(--muted-foreground)] mb-1",children:"Model"}),(0,s.jsx)("input",{value:J,onChange:e=>Z(e.target.value),placeholder:"e.g. gpt-4.1-mini",className:"input text-xs py-1.5"})]})]}):(0,s.jsx)("div",{className:"mb-4 space-y-3",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-[11px] font-medium text-[var(--muted-foreground)] mb-2",children:"Swarm Models"}),(0,s.jsxs)("div",{className:"grid gap-2",children:[(0,s.jsxs)("div",{className:"grid grid-cols-[1fr_1.2fr_auto] gap-2",children:[(0,s.jsx)("select",{value:et,onChange:e=>ea(e.target.value),className:"input text-xs py-1.5 appearance-none",children:ex.map(e=>(0,s.jsx)("option",{value:e.id,children:e.label},e.id))}),(0,s.jsx)("input",{value:es,onChange:e=>er(e.target.value),placeholder:"model name",className:"input text-xs py-1.5"}),(0,s.jsx)("button",{type:"button",onClick:()=>{let e=es.trim();if(!e)return;let t={provider:et,model:e};$.some(e=>e.provider.toLowerCase()===t.provider.toLowerCase()&&e.model.toLowerCase()===t.model.toLowerCase())||(ee(e=>[...e,t]),er(""))},className:"btn-ghost px-3 py-1.5 text-xs",children:"Add"})]}),$.length>0&&(0,s.jsx)("div",{className:"space-y-1",children:$.map((e,t)=>(0,s.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 rounded-md border text-xs bg-[var(--background)] border-[var(--border)]",children:[(0,s.jsxs)("span",{className:"truncate",children:[(0,s.jsx)("span",{className:"text-[var(--muted-foreground)]",children:e.provider}),(0,s.jsx)("span",{className:"mx-1",children:"\xb7"}),(0,s.jsx)("span",{children:e.model})]}),(0,s.jsx)("button",{type:"button",onClick:()=>{ee(e=>e.filter((e,a)=>a!==t))},className:"text-[var(--destructive)] hover:underline",children:"Remove"})]},"".concat(e.provider,"-").concat(e.model,"-").concat(t)))})]})]})}),(0,s.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,s.jsx)("button",{onClick:()=>{X(!1),W(""),K("single"),Y("gemini"),Z(""),ee([]),ea("gemini"),er("")},disabled:G,className:"btn-ghost px-4 py-2",children:"Cancel"}),(0,s.jsx)("button",{onClick:eV,disabled:!z.trim()||G||"swarm"===H&&0===$.length,className:"btn-primary px-4 py-2 flex items-center gap-2",children:G?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"spinner w-4 h-4 border-2 border-white/20 border-t-white"}),"Creating..."]}):"Create Task"})]})]})})]})})}function f(){return(0,s.jsx)(r.Suspense,{fallback:(0,s.jsx)("div",{className:"p-8",children:"Loading..."}),children:(0,s.jsx)(b,{})})}},1460:(e,t,a)=>{"use strict";a.d(t,{A:()=>m});var s=a(5155),r=a(2619),l=a.n(r),n=a(63),o=a(4647),d=a(91),i=a(2115);function c(e){let{children:t,fullWidth:a=!1,noFooter:r=!1}=e;(0,n.usePathname)(),(0,n.useRouter)();let c=(0,n.useSearchParams)(),{user:u,loading:m,signOut:x}=(0,o.A)(),{projects:p,isLoading:h}=(0,d.Y)(),v=null==c?void 0:c.get("project");return(0,i.useMemo)(()=>v?p.find(e=>e.slug===v):null,[p,v]),(0,s.jsxs)("div",{className:"h-screen flex flex-col overflow-hidden",children:[(0,s.jsx)("nav",{className:"flex-shrink-0 border-b border-[var(--card-border)] bg-[var(--card-bg)]/80 backdrop-blur-lg z-30",children:(0,s.jsx)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:(0,s.jsxs)("div",{className:"flex items-center justify-between h-16",children:[(0,s.jsx)("div",{className:"flex items-center gap-8",children:(0,s.jsxs)(l(),{href:"/",className:"flex items-center gap-3 group",children:[(0,s.jsx)("div",{className:"w-8 h-8 rounded-lg bg-gradient-to-br from-[var(--primary)] to-[var(--accent)] flex items-center justify-center text-white font-bold text-sm shadow-lg shadow-[var(--primary)]/20 group-hover:shadow-[var(--primary)]/40 transition-shadow",children:"A"}),(0,s.jsx)("span",{className:"text-lg font-bold tracking-tight gradient-text hidden sm:block",children:"AGX Board"})]})}),(0,s.jsx)("div",{className:"flex items-center gap-3",children:(0,s.jsx)(l(),{href:"/settings",className:"text-sm font-medium text-[var(--muted-foreground)] hover:text-[var(--foreground)] transition-colors",children:"Settings"})})]})})}),(0,s.jsx)("main",{className:"flex-1 min-h-0 flex flex-col ".concat(a?"p-0":"p-4 sm:p-6 lg:p-8 overflow-y-auto"),children:t}),!r&&(0,s.jsx)("footer",{className:"flex-shrink-0 border-t border-[var(--card-border)] bg-[var(--card-bg)]/50 py-4",children:(0,s.jsxs)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 flex items-center justify-between text-xs text-[var(--muted-foreground)]",children:[(0,s.jsx)("span",{children:"AGX Board • Autonomous Agent Orchestration"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"Built with Next.js + Db"})]})})]})}function u(e){return(0,s.jsx)(i.Suspense,{fallback:(0,s.jsx)("div",{className:"h-screen flex items-center justify-center bg-[var(--background)]",children:(0,s.jsx)("span",{className:"spinner w-8 h-8 border-3 border-[var(--primary)] border-t-transparent rounded-full"})}),children:(0,s.jsx)(c,{...e})})}function m(e){let{children:t,fullWidth:a=!1,noFooter:r=!1}=e;return(0,s.jsx)(u,{fullWidth:a,noFooter:r,children:t})}},2888:(e,t,a)=>{"use strict";a.d(t,{A:()=>i});var s=a(5155),r=a(80);let l={queued:{className:"badge-status-queued",label:"Queued",dotColor:"bg-[var(--status-queued)]"},in_progress:{className:"badge-status-in_progress",label:"In Progress",dotColor:"bg-[var(--status-in-progress)]"},blocked:{className:"badge-status-blocked",label:"Blocked",dotColor:"bg-[var(--status-blocked)]"},completed:{className:"badge-status-completed",label:"Completed",dotColor:"bg-[var(--status-completed)]"},failed:{className:"badge-status-failed",label:"Failed",dotColor:"bg-[var(--status-failed)]"}},n={ideation:{icon:"\uD83D\uDCA1",label:"Ideation",prompt:"Research and scope. Define approach, estimate effort."},planning:{icon:"\uD83D\uDCCB",label:"Planning",prompt:"Create detailed plan with tasks, milestones, and dependencies."},execution:{icon:"\uD83D\uDCBB",label:"Execution",prompt:"Implement based on all the context/history/research/plan. Write clean, tested code."},verification:{icon:"\uD83E\uDDEA",label:"Verification",prompt:"Test thoroughly. Find edge cases. Fix bugs. Verify requirements are met."},done:{icon:"✅",label:"Done",prompt:"Task finished and shipped."}};function o(e){let{task:t,onClick:a,compact:o=!1,onStatusChange:d}=e;l[t.status||"queued"];let i=t.stage?n[t.stage]:null;return(0,s.jsxs)("div",{onClick:a,role:"button",tabIndex:0,onKeyDown:e=>"Enter"===e.key&&(null==a?void 0:a()),className:"group relative flex items-center gap-2 p-1.5 rounded-md \n hover:bg-[var(--item-hover-bg)] transition-colors cursor-pointer\n focus-visible:outline-2 focus-visible:outline-[var(--ring)] focus-visible:outline-offset-2\n ".concat("failed"===t.status?"bg-[var(--status-failed-bg)]":""),children:[(0,s.jsx)(r.A,{status:t.status||"queued",onStatusChange:d}),(0,s.jsxs)("div",{className:"flex-1 min-w-0 flex items-baseline gap-2",children:[(0,s.jsx)("h3",{className:"text-sm text-[var(--foreground)] truncate leading-tight\n ".concat("completed"===t.status?"text-[var(--muted-foreground)] line-through":"","\n "),children:t.title||"Untitled Task"}),(0,s.jsxs)("div",{className:"flex items-center gap-2 text-[10px] text-[var(--muted-foreground)] opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap",children:[void 0!==t.priority&&(0,s.jsxs)("span",{className:0===t.priority?"text-[var(--primary)] font-bold":"",children:["P",t.priority]}),t.project&&(0,s.jsx)("span",{className:"max-w-[80px] truncate",children:t.project})]})]}),(0,s.jsx)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:"failed"===t.status?(0,s.jsx)("span",{className:"text-[10px] text-[var(--status-failed)] font-bold",children:"FAILED"}):i&&(0,s.jsx)("span",{className:"text-[10px] opacity-40",children:i.icon})})]})}let d={in_progress:{title:"In Progress",icon:"\uD83D\uDD04",color:"var(--status-in-progress)",description:"Currently being worked on by the daemon"},blocked:{title:"Blocked",icon:"\uD83D\uDEA7",color:"var(--status-blocked)",description:"Waiting for input or resolution"},queued:{title:"Queued",icon:"\uD83D\uDCCB",color:"var(--status-queued)",description:"Ready to be picked up"},completed:{title:"Completed",icon:"✅",color:"var(--status-completed)",description:"Successfully finished"}};function i(e){let{tasks:t,onSelectTask:a,onStatusChange:r}=e;if(0===t.length)return(0,s.jsxs)("div",{className:"text-center py-20 animate-fade-in",children:[(0,s.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-2xl bg-[var(--card-bg)] border border-[var(--card-border)] mb-4",children:(0,s.jsx)("span",{className:"text-3xl",children:"\uD83D\uDCCB"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"No tasks yet"}),(0,s.jsx)("p",{className:"text-[var(--muted-foreground)] text-sm max-w-md mx-auto",children:"Create your first task to get started. Tasks will appear here organized by status."})]});let l=t.filter(e=>"in_progress"===e.status),n=t.filter(e=>"queued"===e.status),i=t.filter(e=>"blocked"===e.status),c=t.filter(e=>"completed"===e.status||"failed"===e.status),u=(e,t)=>{if(0===t.length)return null;let l=d[e];return(0,s.jsxs)("section",{className:"mb-8 animate-fade-in-up",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-lg",style:{backgroundColor:"color-mix(in srgb, ".concat(l.color," 10%, transparent)")},children:[(0,s.jsx)("span",{className:"text-lg",children:l.icon}),(0,s.jsx)("h3",{className:"text-sm font-semibold",style:{color:l.color},children:l.title}),(0,s.jsx)("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium",style:{backgroundColor:"color-mix(in srgb, ".concat(l.color," 15%, transparent)"),color:l.color},children:t.length})]}),(0,s.jsx)("p",{className:"text-xs text-[var(--muted-foreground)] hidden sm:block",children:l.description})]}),(0,s.jsx)("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:t.map((e,t)=>(0,s.jsx)("div",{className:"animate-fade-in-up",style:{animationDelay:"".concat(50*t,"ms")},children:(0,s.jsx)(o,{task:e,onClick:()=>null==a?void 0:a(e),onStatusChange:r?t=>r(e.id,t):void 0})},e.id))})]})};return(0,s.jsxs)("div",{children:[u("in_progress",l),u("blocked",i),u("queued",n),u("completed",c)]})}},4647:(e,t,a)=>{"use strict";a.d(t,{A:()=>i,AuthProvider:()=>d});var s=a(5155),r=a(2115),l=a(1483),n=a(5704);let o=(0,r.createContext)({user:null,loading:!0,signOut:async()=>{}});function d(e){let{children:t}=e,a="1"===n.env.NEXT_PUBLIC_AGX_BOARD_DISABLE_AUTH,[d,i]=(0,r.useState)(null),[c,u]=(0,r.useState)(!0);(0,r.useEffect)(()=>{if(a){i({id:n.env.NEXT_PUBLIC_AGX_BOARD_USER_ID||"00000000-0000-0000-0000-000000000001",email:n.env.NEXT_PUBLIC_AGX_BOARD_USER_EMAIL||"local@agx.board",user_metadata:{name:n.env.NEXT_PUBLIC_AGX_BOARD_USER_NAME||"Local Board User",full_name:n.env.NEXT_PUBLIC_AGX_BOARD_USER_NAME||"Local Board User"},app_metadata:{},aud:"authenticated",created_at:new Date().toISOString()}),u(!1);return}let e=(0,l.O)();e.auth.getSession().then(e=>{var t,a;i(null!=(a=null==(t=e.data.session)?void 0:t.user)?a:null),u(!1)});let{data:{subscription:t}}=e.auth.onAuthStateChange((e,t)=>{var a;i(null!=(a=null==t?void 0:t.user)?a:null),u(!1)});return()=>t.unsubscribe()},[a]);let m=async()=>{if(a)return;let e=(0,l.O)();await e.auth.signOut(),i(null)};return(0,s.jsx)(o.Provider,{value:{user:d,loading:c,signOut:m},children:t})}function i(){return(0,r.useContext)(o)}},9620:(e,t,a)=>{Promise.resolve().then(a.bind(a,415))}},e=>{e.O(0,[5004,277,2619,650,9027,5608,8960,9337,8441,1255,7358],()=>e(e.s=9620)),_N_E=e.O()}]);
|
|
File without changes
|