@swarmclawai/swarmclaw 1.8.12 → 1.9.1
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 +19 -2
- package/package.json +2 -2
- package/src/app/api/tasks/task-workspace-route.test.ts +112 -0
- package/src/components/tasks/task-card.tsx +49 -1
- package/src/components/tasks/task-sheet.tsx +173 -1
- package/src/components/ui/info-chip.tsx +3 -2
- package/src/features/tasks/queries.ts +2 -1
- package/src/lib/server/runtime/queue/core.ts +11 -2
- package/src/lib/server/runtime/queue-retry-policy.test.ts +98 -0
- package/src/lib/server/session-tools/context.ts +2 -0
- package/src/lib/server/session-tools/execute.test.ts +93 -1
- package/src/lib/server/session-tools/execute.ts +4 -3
- package/src/lib/server/session-tools/index.ts +2 -1
- package/src/lib/server/tasks/task-execution-workspace.test.ts +117 -0
- package/src/lib/server/tasks/task-execution-workspace.ts +321 -0
- package/src/lib/server/tasks/task-route-service.ts +69 -8
- package/src/lib/server/tasks/task-validation.test.ts +33 -0
- package/src/lib/server/tasks/task-validation.ts +2 -1
- package/src/lib/tasks.ts +13 -5
- package/src/lib/validation/schemas.ts +17 -0
- package/src/types/task.ts +62 -0
package/README.md
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
<img src="https://raw.githubusercontent.com/swarmclawai/swarmclaw/main/public/branding/swarmclaw-org-avatar.png" alt="SwarmClaw lobster logo" width="120" />
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
|
-
<p align="center"><strong>
|
|
11
|
+
<p align="center"><strong>The self-hosted AI agent runtime and multi-agent framework for autonomous agents.</strong> Open-source agent swarms with durable agent memory, MCP tools, skills, delegation, schedules, and 23+ LLM providers — a practical Claude Code and LangChain alternative.</p>
|
|
12
12
|
|
|
13
13
|
<p align="center">
|
|
14
14
|
<img src="doc/assets/screenshots/org-chart.png" alt="SwarmClaw org chart with delegation and live agent activity" width="900" />
|
|
15
15
|
</p>
|
|
16
16
|
|
|
17
|
-
SwarmClaw is
|
|
17
|
+
SwarmClaw is an open-source, self-hosted AI agent runtime and multi-agent framework. Run autonomous AI agents, agent swarms, and orchestrators with heartbeats, schedules, delegation, agent memory, runtime skills, and reviewed conversation-to-skill learning — across OpenClaw gateways, Claude, GPT, Gemini, OpenRouter, Ollama, and 23+ other providers. Use it as your AI agent dashboard, agent orchestration platform, and home base for self-hosted multi-agent AI workflows.
|
|
18
18
|
|
|
19
19
|
GitHub: https://github.com/swarmclawai/swarmclaw
|
|
20
20
|
Docs: https://swarmclaw.ai/docs
|
|
@@ -399,6 +399,23 @@ Operational docs: https://swarmclaw.ai/docs/observability
|
|
|
399
399
|
|
|
400
400
|
## Releases
|
|
401
401
|
|
|
402
|
+
### v1.9.1 Highlights
|
|
403
|
+
|
|
404
|
+
Task execution workspace release: the first Paperclip-style work-control slice for task-scoped workspaces, preview handoffs, and liveness evidence.
|
|
405
|
+
|
|
406
|
+
- **Task-scoped execution workspaces.** Tasks can now provision a deterministic workspace under the SwarmClaw workspace root, preserving source cwd and project context while creating a task-local README for artifacts and handoffs.
|
|
407
|
+
- **Preview and runtime metadata.** Tasks can carry preview links and runtime services, and the task board surfaces those links directly on task cards and sheets.
|
|
408
|
+
- **Liveness snapshots.** Task list/read responses now compute blocked, queued, stale, retrying, ready, and terminal liveness states so operators can see why work is stopped or ready to run.
|
|
409
|
+
- **Browser smoke coverage.** The browser smoke now creates a workspace-backed task and verifies the task board renders the workspace and liveness chips.
|
|
410
|
+
|
|
411
|
+
### v1.8.13 Highlights
|
|
412
|
+
|
|
413
|
+
Task retry and host execute hotfix for issues [#68](https://github.com/swarmclawai/swarmclaw/issues/68) and [#69](https://github.com/swarmclawai/swarmclaw/issues/69).
|
|
414
|
+
|
|
415
|
+
- **Per-agent host execute.** Agents configured with `executeConfig.backend = "host"` now pass that setting into the runtime `execute` tool, so `persistent=true` uses the documented host backend.
|
|
416
|
+
- **Scheduled task validation.** Schedule-created tasks no longer get auto-classified as implementation tasks for quality gates unless they explicitly opt into a task quality gate.
|
|
417
|
+
- **Retry loop guard.** A task that fails again with the same retry reason is dead-lettered instead of spending another run on identical work.
|
|
418
|
+
|
|
402
419
|
### v1.8.12 Highlights
|
|
403
420
|
|
|
404
421
|
Gateway Fleet Command release: SwarmClaw now treats OpenClaw gateways as an operator surface instead of a background provider detail.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swarmclawai/swarmclaw",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.1",
|
|
4
4
|
"description": "Build and run autonomous AI agents with OpenClaw, Hermes, multiple model providers, orchestration, delegation, memory, skills, schedules, and chat connectors.",
|
|
5
5
|
"main": "electron-dist/main.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"test:cli": "node --test src/cli/*.test.js bin/*.test.js scripts/electron-after-pack.test.mjs scripts/postinstall.test.mjs scripts/run-next-build.test.mjs scripts/run-next-typegen.test.mjs",
|
|
88
88
|
"test:setup": "tsx --test src/app/api/setup/check-provider/route.test.ts src/lib/server/provider-model-discovery.test.ts src/components/auth/setup-wizard/utils.test.ts src/components/auth/setup-wizard/types.test.ts src/hooks/setup-done-detection.test.ts src/lib/setup-defaults.test.ts src/lib/server/storage-auth.test.ts src/lib/server/storage-auth-docker.test.ts",
|
|
89
89
|
"test:openclaw": "tsx --test src/lib/openclaw/openclaw-agent-id.test.ts src/lib/openclaw/openclaw-endpoint.test.ts src/lib/server/agents/agent-runtime-config.test.ts src/lib/server/build-llm.test.ts src/lib/server/connectors/connector-routing.test.ts src/lib/server/connectors/openclaw.test.ts src/lib/server/connectors/swarmdock.test.ts src/lib/server/gateway/protocol.test.ts src/lib/server/gateways/gateway-topology.test.ts src/lib/server/llm-response-cache.test.ts src/lib/server/mcp-conformance.test.ts src/lib/server/openclaw/agent-resolver.test.ts src/lib/server/openclaw/deploy.test.ts src/lib/server/openclaw/skills-normalize.test.ts src/lib/server/session-tools/openclaw-nodes.test.ts src/lib/server/session-tools/swarmdock.test.ts src/lib/server/tasks/task-quality-gate.test.ts src/lib/server/tasks/task-validation.test.ts src/lib/server/tool-capability-policy.test.ts src/lib/providers/openai.test.ts src/lib/providers/openclaw-exports.test.ts src/app/api/gateways/topology-route.test.ts src/app/api/openclaw/dashboard-url/route.test.ts",
|
|
90
|
-
"test:runtime": "tsx --test src/lib/a2a/agent-card.test.ts src/lib/strip-internal-metadata.test.ts src/lib/provider-sets.test.ts src/lib/providers/opencode-cli.test.ts src/lib/providers/cli-provider-metadata.test.ts src/lib/providers/cli-utils.test.ts src/lib/providers/generic-cli.test.ts src/lib/server/cli-provider-readiness.test.ts src/lib/server/provider-health.test.ts src/lib/server/mcp-gateway-runtime.test.ts src/lib/server/mcp-connection-pool.test.ts src/lib/server/knowledge-sources.test.ts src/lib/server/chat-execution/chat-execution-grounding.test.ts src/lib/server/chat-execution/chat-turn-preparation.test.ts src/lib/server/chat-execution/iteration-timers.test.ts src/lib/server/chat-execution/post-stream-finalization.test.ts src/lib/server/chats/clear-undo-snapshots.test.ts src/lib/server/connectors/email.test.ts src/lib/server/protocols/protocol-service.test.ts src/lib/server/runtime/run-ledger.test.ts src/lib/server/runs/run-brief.test.ts src/lib/server/operations/operation-pulse.test.ts src/lib/server/artifacts/artifact-resolver.test.ts src/lib/server/observability/otel-config.test.ts src/lib/server/safe-parse-body.test.ts src/lib/server/missions/mission-templates.test.ts src/lib/server/sharing/share-link-repository.test.ts src/lib/server/sharing/share-resolver.test.ts src/lib/app/view-constants.test.ts src/lib/quality/quality-summary.test.ts src/app/api/approvals/route.test.ts src/app/api/agents/agents-route.test.ts src/app/api/tasks/tasks-route.test.ts src/app/api/chats/chat-route.test.ts src/app/api/chats/clear-route.test.ts src/app/api/chats/compact-route.test.ts src/app/api/chats/context-status-route.test.ts src/app/api/connectors/connector-doctor-route.test.ts src/app/api/healthz/route.test.ts src/app/api/logs/route.test.ts src/app/api/providers/[id]/route.test.ts src/app/api/tts/route.test.ts",
|
|
90
|
+
"test:runtime": "tsx --test src/lib/a2a/agent-card.test.ts src/lib/strip-internal-metadata.test.ts src/lib/provider-sets.test.ts src/lib/providers/opencode-cli.test.ts src/lib/providers/cli-provider-metadata.test.ts src/lib/providers/cli-utils.test.ts src/lib/providers/generic-cli.test.ts src/lib/server/cli-provider-readiness.test.ts src/lib/server/provider-health.test.ts src/lib/server/mcp-gateway-runtime.test.ts src/lib/server/mcp-connection-pool.test.ts src/lib/server/knowledge-sources.test.ts src/lib/server/chat-execution/chat-execution-grounding.test.ts src/lib/server/chat-execution/chat-turn-preparation.test.ts src/lib/server/chat-execution/iteration-timers.test.ts src/lib/server/chat-execution/post-stream-finalization.test.ts src/lib/server/chats/clear-undo-snapshots.test.ts src/lib/server/connectors/email.test.ts src/lib/server/protocols/protocol-service.test.ts src/lib/server/runtime/run-ledger.test.ts src/lib/server/runtime/queue-retry-policy.test.ts src/lib/server/runs/run-brief.test.ts src/lib/server/operations/operation-pulse.test.ts src/lib/server/artifacts/artifact-resolver.test.ts src/lib/server/observability/otel-config.test.ts src/lib/server/safe-parse-body.test.ts src/lib/server/missions/mission-templates.test.ts src/lib/server/sharing/share-link-repository.test.ts src/lib/server/sharing/share-resolver.test.ts src/lib/server/tasks/task-execution-workspace.test.ts src/lib/server/session-tools/execute.test.ts src/lib/app/view-constants.test.ts src/lib/quality/quality-summary.test.ts src/app/api/approvals/route.test.ts src/app/api/agents/agents-route.test.ts src/app/api/tasks/tasks-route.test.ts src/app/api/tasks/task-workspace-route.test.ts src/app/api/chats/chat-route.test.ts src/app/api/chats/clear-route.test.ts src/app/api/chats/compact-route.test.ts src/app/api/chats/context-status-route.test.ts src/app/api/connectors/connector-doctor-route.test.ts src/app/api/healthz/route.test.ts src/app/api/logs/route.test.ts src/app/api/providers/[id]/route.test.ts src/app/api/tts/route.test.ts",
|
|
91
91
|
"test:builder": "tsx --test src/features/protocols/builder/utils/nodes-to-template.test.ts src/features/protocols/builder/utils/template-to-nodes.test.ts src/features/protocols/builder/validators/dag-validator.test.ts",
|
|
92
92
|
"test:e2e": "node --import tsx scripts/browser-e2e-smoke.ts",
|
|
93
93
|
"test:mcp:conformance": "node --import tsx ./scripts/mcp-conformance-check.ts",
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import assert from 'node:assert/strict'
|
|
2
|
+
import fs from 'node:fs'
|
|
3
|
+
import os from 'node:os'
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
import { after, before, test } from 'node:test'
|
|
6
|
+
|
|
7
|
+
import type { BoardTask } from '@/types'
|
|
8
|
+
|
|
9
|
+
const originalEnv = {
|
|
10
|
+
DATA_DIR: process.env.DATA_DIR,
|
|
11
|
+
WORKSPACE_DIR: process.env.WORKSPACE_DIR,
|
|
12
|
+
SWARMCLAW_BUILD_MODE: process.env.SWARMCLAW_BUILD_MODE,
|
|
13
|
+
SWARMCLAW_DAEMON_AUTOSTART: process.env.SWARMCLAW_DAEMON_AUTOSTART,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let tempDir = ''
|
|
17
|
+
let putTask: typeof import('./[id]/route')['PUT']
|
|
18
|
+
let getTasks: typeof import('./route')['GET']
|
|
19
|
+
let storage: typeof import('@/lib/server/storage')
|
|
20
|
+
|
|
21
|
+
function routeParams(id: string) {
|
|
22
|
+
return { params: Promise.resolve({ id }) }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function seedTask(id: string, overrides: Partial<BoardTask> = {}) {
|
|
26
|
+
const now = Date.now()
|
|
27
|
+
storage.saveTasks({
|
|
28
|
+
[id]: {
|
|
29
|
+
id,
|
|
30
|
+
title: 'Workspace Task',
|
|
31
|
+
description: '',
|
|
32
|
+
status: 'backlog',
|
|
33
|
+
agentId: 'agent-1',
|
|
34
|
+
createdAt: now,
|
|
35
|
+
updatedAt: now,
|
|
36
|
+
...overrides,
|
|
37
|
+
} as BoardTask,
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
before(async () => {
|
|
42
|
+
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'swarmclaw-task-route-'))
|
|
43
|
+
process.env.DATA_DIR = path.join(tempDir, 'data')
|
|
44
|
+
process.env.WORKSPACE_DIR = path.join(tempDir, 'workspace')
|
|
45
|
+
process.env.SWARMCLAW_BUILD_MODE = '1'
|
|
46
|
+
process.env.SWARMCLAW_DAEMON_AUTOSTART = '0'
|
|
47
|
+
storage = await import('@/lib/server/storage')
|
|
48
|
+
putTask = (await import('./[id]/route')).PUT
|
|
49
|
+
getTasks = (await import('./route')).GET
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
after(() => {
|
|
53
|
+
if (originalEnv.DATA_DIR === undefined) delete process.env.DATA_DIR
|
|
54
|
+
else process.env.DATA_DIR = originalEnv.DATA_DIR
|
|
55
|
+
if (originalEnv.WORKSPACE_DIR === undefined) delete process.env.WORKSPACE_DIR
|
|
56
|
+
else process.env.WORKSPACE_DIR = originalEnv.WORKSPACE_DIR
|
|
57
|
+
if (originalEnv.SWARMCLAW_BUILD_MODE === undefined) delete process.env.SWARMCLAW_BUILD_MODE
|
|
58
|
+
else process.env.SWARMCLAW_BUILD_MODE = originalEnv.SWARMCLAW_BUILD_MODE
|
|
59
|
+
if (originalEnv.SWARMCLAW_DAEMON_AUTOSTART === undefined) delete process.env.SWARMCLAW_DAEMON_AUTOSTART
|
|
60
|
+
else process.env.SWARMCLAW_DAEMON_AUTOSTART = originalEnv.SWARMCLAW_DAEMON_AUTOSTART
|
|
61
|
+
fs.rmSync(tempDir, { recursive: true, force: true })
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
test('PUT /api/tasks/:id provisions an execution workspace and preview links', async () => {
|
|
65
|
+
seedTask('task-route-workspace', {
|
|
66
|
+
title: 'Route Workspace',
|
|
67
|
+
projectId: 'project-route',
|
|
68
|
+
cwd: '/source/repo',
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
const response = await putTask(new Request('http://local/api/tasks/task-route-workspace', {
|
|
72
|
+
method: 'PUT',
|
|
73
|
+
headers: { 'content-type': 'application/json' },
|
|
74
|
+
body: JSON.stringify({
|
|
75
|
+
provisionWorkspace: true,
|
|
76
|
+
previewLinks: [{ label: 'Preview', url: 'http://127.0.0.1:3456', port: 3456 }],
|
|
77
|
+
runtimeServices: [{ name: 'Next dev', status: 'planned', command: 'npm run dev', port: 3456 }],
|
|
78
|
+
}),
|
|
79
|
+
}), routeParams('task-route-workspace'))
|
|
80
|
+
|
|
81
|
+
assert.equal(response.status, 200)
|
|
82
|
+
const body = await response.json() as BoardTask
|
|
83
|
+
assert.equal(body.executionWorkspace?.sourceCwd, '/source/repo')
|
|
84
|
+
assert.equal(body.previewLinks?.[0]?.url, 'http://127.0.0.1:3456')
|
|
85
|
+
assert.equal(body.runtimeServices?.[0]?.name, 'Next dev')
|
|
86
|
+
assert.equal(fs.existsSync(body.executionWorkspace?.path || ''), true)
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
test('GET /api/tasks returns computed blocked liveness without persisting a task patch', async () => {
|
|
90
|
+
seedTask('task-blocked', {
|
|
91
|
+
title: 'Blocked Route Task',
|
|
92
|
+
status: 'backlog',
|
|
93
|
+
blockedBy: ['dep-route'],
|
|
94
|
+
})
|
|
95
|
+
const tasks = storage.loadTasks()
|
|
96
|
+
tasks['dep-route'] = {
|
|
97
|
+
id: 'dep-route',
|
|
98
|
+
title: 'Dependency',
|
|
99
|
+
description: '',
|
|
100
|
+
status: 'running',
|
|
101
|
+
agentId: 'agent-1',
|
|
102
|
+
createdAt: Date.now(),
|
|
103
|
+
updatedAt: Date.now(),
|
|
104
|
+
} as BoardTask
|
|
105
|
+
storage.saveTasks(tasks)
|
|
106
|
+
|
|
107
|
+
const response = await getTasks(new Request('http://local/api/tasks'))
|
|
108
|
+
assert.equal(response.status, 200)
|
|
109
|
+
const body = await response.json() as Record<string, BoardTask>
|
|
110
|
+
assert.equal(body['task-blocked']?.liveness?.state, 'blocked')
|
|
111
|
+
assert.deepEqual(body['task-blocked']?.liveness?.blockerTaskIds, ['dep-route'])
|
|
112
|
+
})
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
import { useState, useCallback, useEffect } from 'react'
|
|
4
|
+
import { Activity, ExternalLink, FolderOpen } from 'lucide-react'
|
|
4
5
|
import { useAppStore } from '@/stores/use-app-store'
|
|
5
6
|
import { useNavigate } from '@/lib/app/navigation'
|
|
6
7
|
import { useUpdateTaskMutation } from '@/features/tasks/queries'
|
|
@@ -8,7 +9,7 @@ import { ConfirmDialog } from '@/components/shared/confirm-dialog'
|
|
|
8
9
|
import { AgentAvatar } from '@/components/agents/agent-avatar'
|
|
9
10
|
import { timeAgo } from '@/lib/time-format'
|
|
10
11
|
import { InfoChip } from '@/components/ui/info-chip'
|
|
11
|
-
import type { Agent, BoardTask, Project } from '@/types'
|
|
12
|
+
import type { Agent, BoardTask, Project, TaskLivenessState } from '@/types'
|
|
12
13
|
|
|
13
14
|
interface TaskCardProps {
|
|
14
15
|
task: BoardTask
|
|
@@ -21,6 +22,22 @@ interface TaskCardProps {
|
|
|
21
22
|
index?: number
|
|
22
23
|
}
|
|
23
24
|
|
|
25
|
+
function livenessTone(state: TaskLivenessState | undefined): 'neutral' | 'muted' | 'warning' | 'danger' | 'success' | 'info' | 'purple' | 'accent' {
|
|
26
|
+
if (state === 'stale' || state === 'retrying') return 'warning'
|
|
27
|
+
if (state === 'dead_lettered' || state === 'failed') return 'danger'
|
|
28
|
+
if (state === 'blocked') return 'purple'
|
|
29
|
+
if (state === 'completed') return 'success'
|
|
30
|
+
if (state === 'running' || state === 'queued') return 'info'
|
|
31
|
+
return 'muted'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function livenessLabel(task: BoardTask): string | null {
|
|
35
|
+
const state = task.liveness?.state
|
|
36
|
+
if (!state) return null
|
|
37
|
+
if (state === 'dead_lettered') return 'dead letter'
|
|
38
|
+
return state.replace(/_/g, ' ')
|
|
39
|
+
}
|
|
40
|
+
|
|
24
41
|
export function TaskCard({
|
|
25
42
|
task,
|
|
26
43
|
agents,
|
|
@@ -71,6 +88,8 @@ export function TaskCard({
|
|
|
71
88
|
const prio = task.priority && priorityConfig[task.priority]
|
|
72
89
|
|
|
73
90
|
const isBlocked = Array.isArray(task.blockedBy) && task.blockedBy.length > 0
|
|
91
|
+
const previewLink = task.previewLinks?.[0] || task.executionWorkspace?.previewLinks?.[0] || null
|
|
92
|
+
const liveness = livenessLabel(task)
|
|
74
93
|
const isOverdue = task.dueAt
|
|
75
94
|
&& task.dueAt < now
|
|
76
95
|
&& task.status !== 'completed'
|
|
@@ -278,6 +297,35 @@ export function TaskCard({
|
|
|
278
297
|
</div>
|
|
279
298
|
)}
|
|
280
299
|
|
|
300
|
+
{(liveness || task.executionWorkspace || previewLink) && (
|
|
301
|
+
<div className="flex flex-wrap gap-1.5 mb-3">
|
|
302
|
+
{liveness && (
|
|
303
|
+
<InfoChip tone={livenessTone(task.liveness?.state)} title={task.liveness?.reason}>
|
|
304
|
+
<Activity size={10} />
|
|
305
|
+
{liveness}
|
|
306
|
+
</InfoChip>
|
|
307
|
+
)}
|
|
308
|
+
{task.executionWorkspace && (
|
|
309
|
+
<InfoChip tone="accent" title={task.executionWorkspace.path}>
|
|
310
|
+
<FolderOpen size={10} />
|
|
311
|
+
workspace
|
|
312
|
+
</InfoChip>
|
|
313
|
+
)}
|
|
314
|
+
{previewLink && (
|
|
315
|
+
<a
|
|
316
|
+
href={previewLink.url}
|
|
317
|
+
target="_blank"
|
|
318
|
+
rel="noreferrer"
|
|
319
|
+
onClick={(e) => e.stopPropagation()}
|
|
320
|
+
className="inline-flex items-center gap-1.5 rounded-[7px] bg-emerald-500/10 px-2 py-1 text-[10px] font-600 text-emerald-300 hover:bg-emerald-500/15"
|
|
321
|
+
>
|
|
322
|
+
<ExternalLink size={10} />
|
|
323
|
+
{previewLink.label || 'Preview'}
|
|
324
|
+
</a>
|
|
325
|
+
)}
|
|
326
|
+
</div>
|
|
327
|
+
)}
|
|
328
|
+
|
|
281
329
|
<div className="flex items-center gap-2 flex-wrap">
|
|
282
330
|
{agent && (
|
|
283
331
|
<span className="px-2 py-1 rounded-[6px] bg-accent-soft text-accent-bright text-[11px] font-600">
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { useEffect, useMemo, useRef, useState } from 'react'
|
|
4
4
|
import { useRouter } from 'next/navigation'
|
|
5
|
+
import { Activity, ExternalLink, FolderOpen, PlayCircle } from 'lucide-react'
|
|
5
6
|
import ReactMarkdown from 'react-markdown'
|
|
6
7
|
import remarkGfm from 'remark-gfm'
|
|
7
8
|
import { useAppStore } from '@/stores/use-app-store'
|
|
@@ -21,10 +22,11 @@ import { DirBrowser } from '@/components/shared/dir-browser'
|
|
|
21
22
|
import { SheetFooter } from '@/components/shared/sheet-footer'
|
|
22
23
|
import { inputClass } from '@/components/shared/form-styles'
|
|
23
24
|
import { StructuredSessionLauncher } from '@/components/protocols/structured-session-launcher'
|
|
24
|
-
import type { BoardTask, TaskComment, TaskQualityGateConfig } from '@/types'
|
|
25
|
+
import type { BoardTask, TaskComment, TaskLivenessState, TaskQualityGateConfig } from '@/types'
|
|
25
26
|
import { dedup, errorMessage } from '@/lib/shared-utils'
|
|
26
27
|
import { SectionLabel } from '@/components/shared/section-label'
|
|
27
28
|
import { AgentAvatar } from '@/components/agents/agent-avatar'
|
|
29
|
+
import { InfoChip } from '@/components/ui/info-chip'
|
|
28
30
|
|
|
29
31
|
function fmtTime(ts: number) {
|
|
30
32
|
const d = new Date(ts)
|
|
@@ -44,6 +46,22 @@ function normalizeGateNumber(value: unknown, fallback: number, min: number, max:
|
|
|
44
46
|
return Math.max(min, Math.min(max, Math.trunc(parsed)))
|
|
45
47
|
}
|
|
46
48
|
|
|
49
|
+
function livenessTone(state?: TaskLivenessState): 'neutral' | 'muted' | 'warning' | 'danger' | 'success' | 'info' | 'purple' | 'accent' {
|
|
50
|
+
if (state === 'stale' || state === 'retrying') return 'warning'
|
|
51
|
+
if (state === 'dead_lettered' || state === 'failed') return 'danger'
|
|
52
|
+
if (state === 'blocked') return 'purple'
|
|
53
|
+
if (state === 'completed') return 'success'
|
|
54
|
+
if (state === 'running' || state === 'queued') return 'info'
|
|
55
|
+
return 'muted'
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function livenessLabel(task: BoardTask): string {
|
|
59
|
+
const state = task.liveness?.state
|
|
60
|
+
if (!state) return 'unknown'
|
|
61
|
+
if (state === 'dead_lettered') return 'dead letter'
|
|
62
|
+
return state.replace(/_/g, ' ')
|
|
63
|
+
}
|
|
64
|
+
|
|
47
65
|
export function TaskSheet() {
|
|
48
66
|
const router = useRouter()
|
|
49
67
|
const open = useAppStore((s) => s.taskSheetOpen)
|
|
@@ -85,6 +103,8 @@ export function TaskSheet() {
|
|
|
85
103
|
const [qualityGateRequireVerification, setQualityGateRequireVerification] = useState(false)
|
|
86
104
|
const [qualityGateRequireArtifact, setQualityGateRequireArtifact] = useState(false)
|
|
87
105
|
const [qualityGateRequireReport, setQualityGateRequireReport] = useState(false)
|
|
106
|
+
const [provisionWorkspace, setProvisionWorkspace] = useState(false)
|
|
107
|
+
const [workspacePreparing, setWorkspacePreparing] = useState(false)
|
|
88
108
|
const [structuredSessionOpen, setStructuredSessionOpen] = useState(false)
|
|
89
109
|
const formInitRef = useRef<string | null>(null)
|
|
90
110
|
|
|
@@ -139,6 +159,7 @@ export function TaskSheet() {
|
|
|
139
159
|
setQualityGateRequireVerification(gate?.requireVerification ?? defaultGateRequireVerification)
|
|
140
160
|
setQualityGateRequireArtifact(gate?.requireArtifact ?? defaultGateRequireArtifact)
|
|
141
161
|
setQualityGateRequireReport(gate?.requireReport ?? defaultGateRequireReport)
|
|
162
|
+
setProvisionWorkspace(false)
|
|
142
163
|
formInitRef.current = initKey
|
|
143
164
|
return
|
|
144
165
|
}
|
|
@@ -163,6 +184,7 @@ export function TaskSheet() {
|
|
|
163
184
|
setQualityGateRequireVerification(defaultGateRequireVerification)
|
|
164
185
|
setQualityGateRequireArtifact(defaultGateRequireArtifact)
|
|
165
186
|
setQualityGateRequireReport(defaultGateRequireReport)
|
|
187
|
+
setProvisionWorkspace(false)
|
|
166
188
|
formInitRef.current = initKey
|
|
167
189
|
}, [
|
|
168
190
|
activeProjectFilter,
|
|
@@ -212,6 +234,7 @@ export function TaskSheet() {
|
|
|
212
234
|
customFields: Object.keys(customFields).length > 0 ? customFields : undefined,
|
|
213
235
|
priority: priority || undefined,
|
|
214
236
|
qualityGate,
|
|
237
|
+
provisionWorkspace: !editing && provisionWorkspace ? true : undefined,
|
|
215
238
|
} as Partial<BoardTask> & { title: string; description: string; agentId: string }
|
|
216
239
|
try {
|
|
217
240
|
if (editing) {
|
|
@@ -263,6 +286,19 @@ export function TaskSheet() {
|
|
|
263
286
|
}
|
|
264
287
|
}
|
|
265
288
|
|
|
289
|
+
const handlePrepareWorkspace = async () => {
|
|
290
|
+
if (!editing) return
|
|
291
|
+
setWorkspacePreparing(true)
|
|
292
|
+
try {
|
|
293
|
+
await updateTaskMutation.mutateAsync({ id: editing.id, patch: { provisionWorkspace: true } })
|
|
294
|
+
setDepError(null)
|
|
295
|
+
} catch (err: unknown) {
|
|
296
|
+
setDepError(errorMessage(err))
|
|
297
|
+
} finally {
|
|
298
|
+
setWorkspacePreparing(false)
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
266
302
|
const handleUnarchive = async () => {
|
|
267
303
|
if (editing) {
|
|
268
304
|
await updateTaskMutation.mutateAsync({ id: editing.id, patch: { status: 'backlog' } })
|
|
@@ -307,6 +343,16 @@ export function TaskSheet() {
|
|
|
307
343
|
|
|
308
344
|
const taskAgent = editing ? agents[editing.agentId] : null
|
|
309
345
|
const taskProject = editing?.projectId ? projects[editing.projectId] : null
|
|
346
|
+
const previewLinks = editing
|
|
347
|
+
? (editing.previewLinks && editing.previewLinks.length > 0
|
|
348
|
+
? editing.previewLinks
|
|
349
|
+
: editing.executionWorkspace?.previewLinks || [])
|
|
350
|
+
: []
|
|
351
|
+
const runtimeServices = editing
|
|
352
|
+
? (editing.runtimeServices && editing.runtimeServices.length > 0
|
|
353
|
+
? editing.runtimeServices
|
|
354
|
+
: editing.executionWorkspace?.runtimeServices || [])
|
|
355
|
+
: []
|
|
310
356
|
|
|
311
357
|
/* ───── View-only mode ───── */
|
|
312
358
|
if (viewOnly && editing) {
|
|
@@ -385,6 +431,67 @@ export function TaskSheet() {
|
|
|
385
431
|
</div>
|
|
386
432
|
)}
|
|
387
433
|
|
|
434
|
+
<div className="mb-8">
|
|
435
|
+
<SectionLabel>Execution</SectionLabel>
|
|
436
|
+
<div className="rounded-[14px] border border-white/[0.06] bg-surface p-4 space-y-3">
|
|
437
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
438
|
+
{editing.liveness && (
|
|
439
|
+
<InfoChip tone={livenessTone(editing.liveness.state)} title={editing.liveness.reason}>
|
|
440
|
+
<Activity size={12} />
|
|
441
|
+
{livenessLabel(editing)}
|
|
442
|
+
</InfoChip>
|
|
443
|
+
)}
|
|
444
|
+
{editing.executionWorkspace ? (
|
|
445
|
+
<InfoChip tone="accent" title={editing.executionWorkspace.path}>
|
|
446
|
+
<FolderOpen size={12} />
|
|
447
|
+
Workspace ready
|
|
448
|
+
</InfoChip>
|
|
449
|
+
) : (
|
|
450
|
+
<InfoChip tone="muted">
|
|
451
|
+
<FolderOpen size={12} />
|
|
452
|
+
No workspace
|
|
453
|
+
</InfoChip>
|
|
454
|
+
)}
|
|
455
|
+
{runtimeServices.map((service) => (
|
|
456
|
+
<InfoChip key={service.id} tone={service.status === 'running' ? 'success' : service.status === 'failed' ? 'danger' : 'neutral'}>
|
|
457
|
+
<PlayCircle size={12} />
|
|
458
|
+
{service.name}: {service.status}
|
|
459
|
+
</InfoChip>
|
|
460
|
+
))}
|
|
461
|
+
</div>
|
|
462
|
+
{editing.executionWorkspace?.path && (
|
|
463
|
+
<code className="block text-[12px] text-text-3 font-mono break-all">{editing.executionWorkspace.path}</code>
|
|
464
|
+
)}
|
|
465
|
+
{previewLinks.length > 0 && (
|
|
466
|
+
<div className="flex flex-wrap gap-2">
|
|
467
|
+
{previewLinks.map((link) => (
|
|
468
|
+
<a
|
|
469
|
+
key={link.id}
|
|
470
|
+
href={link.url}
|
|
471
|
+
target="_blank"
|
|
472
|
+
rel="noreferrer"
|
|
473
|
+
className="inline-flex items-center gap-1.5 rounded-[8px] bg-emerald-500/10 px-2.5 py-1.5 text-[12px] font-600 text-emerald-300 hover:bg-emerald-500/15"
|
|
474
|
+
>
|
|
475
|
+
<ExternalLink size={12} />
|
|
476
|
+
{link.label || 'Preview'}
|
|
477
|
+
</a>
|
|
478
|
+
))}
|
|
479
|
+
</div>
|
|
480
|
+
)}
|
|
481
|
+
{!editing.executionWorkspace && (
|
|
482
|
+
<button
|
|
483
|
+
onClick={handlePrepareWorkspace}
|
|
484
|
+
disabled={workspacePreparing}
|
|
485
|
+
className="inline-flex items-center gap-2 rounded-[10px] border border-accent-bright/20 bg-accent-bright/10 px-3 py-2 text-[12px] font-600 text-accent-bright hover:bg-accent-bright/14 disabled:opacity-50"
|
|
486
|
+
style={{ fontFamily: 'inherit' }}
|
|
487
|
+
>
|
|
488
|
+
<FolderOpen size={13} />
|
|
489
|
+
{workspacePreparing ? 'Preparing...' : 'Prepare Workspace'}
|
|
490
|
+
</button>
|
|
491
|
+
)}
|
|
492
|
+
</div>
|
|
493
|
+
</div>
|
|
494
|
+
|
|
388
495
|
{/* Tags */}
|
|
389
496
|
{editing.tags && editing.tags.length > 0 && (
|
|
390
497
|
<div className="mb-8">
|
|
@@ -809,6 +916,71 @@ export function TaskSheet() {
|
|
|
809
916
|
/>
|
|
810
917
|
</div>
|
|
811
918
|
|
|
919
|
+
<div className="mb-8">
|
|
920
|
+
<SectionLabel>Execution Workspace</SectionLabel>
|
|
921
|
+
{editing ? (
|
|
922
|
+
<div className="rounded-[14px] border border-white/[0.06] bg-surface p-4 space-y-3">
|
|
923
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
924
|
+
{editing.liveness && (
|
|
925
|
+
<InfoChip tone={livenessTone(editing.liveness.state)} title={editing.liveness.reason}>
|
|
926
|
+
<Activity size={12} />
|
|
927
|
+
{livenessLabel(editing)}
|
|
928
|
+
</InfoChip>
|
|
929
|
+
)}
|
|
930
|
+
{editing.executionWorkspace ? (
|
|
931
|
+
<InfoChip tone="accent" title={editing.executionWorkspace.path}>
|
|
932
|
+
<FolderOpen size={12} />
|
|
933
|
+
Workspace ready
|
|
934
|
+
</InfoChip>
|
|
935
|
+
) : (
|
|
936
|
+
<InfoChip tone="muted">
|
|
937
|
+
<FolderOpen size={12} />
|
|
938
|
+
No workspace
|
|
939
|
+
</InfoChip>
|
|
940
|
+
)}
|
|
941
|
+
</div>
|
|
942
|
+
{editing.executionWorkspace?.path && (
|
|
943
|
+
<code className="block text-[12px] text-text-3 font-mono break-all">{editing.executionWorkspace.path}</code>
|
|
944
|
+
)}
|
|
945
|
+
{previewLinks.length > 0 && (
|
|
946
|
+
<div className="flex flex-wrap gap-2">
|
|
947
|
+
{previewLinks.map((link) => (
|
|
948
|
+
<a
|
|
949
|
+
key={link.id}
|
|
950
|
+
href={link.url}
|
|
951
|
+
target="_blank"
|
|
952
|
+
rel="noreferrer"
|
|
953
|
+
className="inline-flex items-center gap-1.5 rounded-[8px] bg-emerald-500/10 px-2.5 py-1.5 text-[12px] font-600 text-emerald-300 hover:bg-emerald-500/15"
|
|
954
|
+
>
|
|
955
|
+
<ExternalLink size={12} />
|
|
956
|
+
{link.label || 'Preview'}
|
|
957
|
+
</a>
|
|
958
|
+
))}
|
|
959
|
+
</div>
|
|
960
|
+
)}
|
|
961
|
+
<button
|
|
962
|
+
onClick={handlePrepareWorkspace}
|
|
963
|
+
disabled={workspacePreparing}
|
|
964
|
+
className="inline-flex items-center gap-2 rounded-[10px] border border-accent-bright/20 bg-accent-bright/10 px-3 py-2 text-[12px] font-600 text-accent-bright hover:bg-accent-bright/14 disabled:opacity-50"
|
|
965
|
+
style={{ fontFamily: 'inherit' }}
|
|
966
|
+
>
|
|
967
|
+
<FolderOpen size={13} />
|
|
968
|
+
{workspacePreparing ? 'Preparing...' : editing.executionWorkspace ? 'Refresh Workspace' : 'Prepare Workspace'}
|
|
969
|
+
</button>
|
|
970
|
+
</div>
|
|
971
|
+
) : (
|
|
972
|
+
<label className="flex items-center gap-2 rounded-[14px] border border-white/[0.06] bg-surface px-4 py-3 text-[13px] text-text-2">
|
|
973
|
+
<input
|
|
974
|
+
type="checkbox"
|
|
975
|
+
checked={provisionWorkspace}
|
|
976
|
+
onChange={(e) => setProvisionWorkspace(e.target.checked)}
|
|
977
|
+
className="h-4 w-4 rounded border-white/20 accent-accent"
|
|
978
|
+
/>
|
|
979
|
+
Prepare a task-scoped workspace when this task is created
|
|
980
|
+
</label>
|
|
981
|
+
)}
|
|
982
|
+
</div>
|
|
983
|
+
|
|
812
984
|
{/* Tags */}
|
|
813
985
|
<div className="mb-8">
|
|
814
986
|
<SectionLabel>Tags <span className="normal-case tracking-normal font-normal text-text-3">(optional)</span></SectionLabel>
|
|
@@ -30,11 +30,12 @@ const chipVariants = cva(
|
|
|
30
30
|
interface InfoChipProps extends VariantProps<typeof chipVariants> {
|
|
31
31
|
children: React.ReactNode
|
|
32
32
|
className?: string
|
|
33
|
+
title?: string
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
export function InfoChip({ size, tone, children, className }: InfoChipProps) {
|
|
36
|
+
export function InfoChip({ size, tone, children, className, title }: InfoChipProps) {
|
|
36
37
|
return (
|
|
37
|
-
<span className={cn(chipVariants({ size, tone }), className)}>
|
|
38
|
+
<span title={title} className={cn(chipVariants({ size, tone }), className)}>
|
|
38
39
|
{children}
|
|
39
40
|
</span>
|
|
40
41
|
)
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
updateTask,
|
|
9
9
|
type GitHubIssueImportRequest,
|
|
10
10
|
type GitHubIssueImportResult,
|
|
11
|
+
type TaskWriteInput,
|
|
11
12
|
} from '@/lib/tasks'
|
|
12
13
|
import type { BoardTask, BoardTaskStatus, TaskComment } from '@/types'
|
|
13
14
|
|
|
@@ -98,7 +99,7 @@ export function useCreateTaskMutation() {
|
|
|
98
99
|
export function useUpdateTaskMutation() {
|
|
99
100
|
const queryClient = useQueryClient()
|
|
100
101
|
return useMutation({
|
|
101
|
-
mutationFn: ({ id, patch }: { id: string; patch:
|
|
102
|
+
mutationFn: ({ id, patch }: { id: string; patch: TaskWriteInput }) => updateTask(id, patch),
|
|
102
103
|
onMutate: async ({ id, patch }) => {
|
|
103
104
|
await queryClient.cancelQueries({ queryKey: taskQueryKeys.lists() })
|
|
104
105
|
const snapshots = patchTaskCaches(queryClient, (current, includeArchived) => {
|
|
@@ -124,6 +124,14 @@ function applyTaskPolicyDefaults(task: BoardTask): void {
|
|
|
124
124
|
if (task.deadLetteredAt === undefined) task.deadLetteredAt = null
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
function formatRetryError(reason: string): string {
|
|
128
|
+
return `Retry scheduled after failure: ${reason}`.slice(0, 500)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function isRepeatedRetryFailure(previousError: unknown, reason: string): boolean {
|
|
132
|
+
return typeof previousError === 'string' && previousError === formatRetryError(reason)
|
|
133
|
+
}
|
|
134
|
+
|
|
127
135
|
export interface TaskResumeState {
|
|
128
136
|
claudeSessionId: string | null
|
|
129
137
|
codexThreadId: string | null
|
|
@@ -971,9 +979,10 @@ function scheduleRetryOrDeadLetter(task: BoardTask, reason: string): 'retry' | '
|
|
|
971
979
|
}
|
|
972
980
|
applyTaskPolicyDefaults(task)
|
|
973
981
|
const now = Date.now()
|
|
982
|
+
const repeatedRetryFailure = isRepeatedRetryFailure(task.error, reason)
|
|
974
983
|
task.attempts = (task.attempts || 0) + 1
|
|
975
984
|
|
|
976
|
-
if ((task.attempts || 0) < (task.maxAttempts || 1)) {
|
|
985
|
+
if ((task.attempts || 0) < (task.maxAttempts || 1) && !repeatedRetryFailure) {
|
|
977
986
|
const delayMs = jitteredBackoff((task.retryBackoffSec || 30) * 1000, Math.max(0, (task.attempts || 1) - 1), 6 * 3600_000)
|
|
978
987
|
task.status = 'queued'
|
|
979
988
|
task.retryScheduledAt = now + delayMs
|
|
@@ -982,7 +991,7 @@ function scheduleRetryOrDeadLetter(task: BoardTask, reason: string): 'retry' | '
|
|
|
982
991
|
// recovery loop burns CPU re-queueing a task that can never run.
|
|
983
992
|
task.checkoutRunId = null
|
|
984
993
|
task.updatedAt = now
|
|
985
|
-
task.error =
|
|
994
|
+
task.error = formatRetryError(reason)
|
|
986
995
|
if (!task.comments) task.comments = []
|
|
987
996
|
task.comments.push({
|
|
988
997
|
id: genId(),
|