@swarmclawai/swarmclaw 1.8.13 → 1.9.2

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.
Files changed (30) hide show
  1. package/README.md +19 -0
  2. package/package.json +3 -3
  3. package/scripts/ensure-sandbox-browser-image.mjs +12 -2
  4. package/src/app/api/knowledge/hygiene/route.ts +19 -1
  5. package/src/app/api/portability/export/route.test.ts +17 -0
  6. package/src/app/api/portability/export/route.ts +11 -2
  7. package/src/app/api/tasks/task-workspace-route.test.ts +112 -0
  8. package/src/components/tasks/task-card.tsx +49 -1
  9. package/src/components/tasks/task-sheet.tsx +173 -1
  10. package/src/components/ui/info-chip.tsx +3 -2
  11. package/src/features/tasks/queries.ts +2 -1
  12. package/src/lib/server/agents/delegation-advisory.test.ts +1 -0
  13. package/src/lib/server/agents/delegation-advisory.ts +10 -0
  14. package/src/lib/server/chat-execution/iteration-event-handler.ts +24 -8
  15. package/src/lib/server/chat-execution/reasoning-tag-scrubber.test.ts +117 -0
  16. package/src/lib/server/chat-execution/reasoning-tag-scrubber.ts +219 -0
  17. package/src/lib/server/knowledge-sources.test.ts +45 -0
  18. package/src/lib/server/knowledge-sources.ts +33 -0
  19. package/src/lib/server/portability/export.ts +10 -0
  20. package/src/lib/server/session-tools/crud.ts +25 -2
  21. package/src/lib/server/session-tools/manage-tasks.test.ts +7 -2
  22. package/src/lib/server/tasks/task-execution-workspace.test.ts +117 -0
  23. package/src/lib/server/tasks/task-execution-workspace.ts +321 -0
  24. package/src/lib/server/tasks/task-route-service.ts +87 -9
  25. package/src/lib/server/tasks/task-service.test.ts +60 -2
  26. package/src/lib/server/tasks/task-service.ts +35 -0
  27. package/src/lib/tasks.ts +13 -5
  28. package/src/lib/validation/schemas.ts +19 -0
  29. package/src/types/misc.ts +1 -1
  30. package/src/types/task.ts +62 -0
package/README.md CHANGED
@@ -399,6 +399,25 @@ Operational docs: https://swarmclaw.ai/docs/observability
399
399
 
400
400
  ## Releases
401
401
 
402
+ ### v1.9.2 Highlights
403
+
404
+ Bundled competitor-parity release: Hermes-style reasoning hygiene, deterministic delegation routing, Mission Control task workflow polish, OpenClaw export hardening, and Paperclip-style timeout hygiene.
405
+
406
+ - **Stateful reasoning tag scrubber.** String-streamed `<think>`, `<thinking>`, `<reasoning>`, `<thought>`, and `<REASONING_SCRATCHPAD>` blocks are removed across split deltas and routed into SwarmClaw's thinking stream instead of leaking into visible answers.
407
+ - **Deterministic delegation profiles.** `manage_tasks` now accepts explicit `workType` and `requiredCapabilities` routing hints, returns a stable `routeKey`, and can auto-assign unowned work without a classifier call when the profile is explicit.
408
+ - **Assignment workflow transitions.** Newly assigned backlog/triage/todo tasks move into the `in_progress` workflow lane without changing their runtime status or queueing execution.
409
+ - **Knowledge hygiene pruning.** Archived or superseded knowledge sources can now be pruned after a retention window, with prune actions recorded in the hygiene summary.
410
+ - **Collision-safe exports and timeout hardening.** Portability exports support timestamped attachment filenames, the sandbox browser image build has a configurable timeout, and release notes now carry the macOS quarantine workaround for ad-hoc signed desktop builds.
411
+
412
+ ### v1.9.1 Highlights
413
+
414
+ Task execution workspace release: the first Paperclip-style work-control slice for task-scoped workspaces, preview handoffs, and liveness evidence.
415
+
416
+ - **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.
417
+ - **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.
418
+ - **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.
419
+ - **Browser smoke coverage.** The browser smoke now creates a workspace-backed task and verifies the task board renders the workspace and liveness chips.
420
+
402
421
  ### v1.8.13 Highlights
403
422
 
404
423
  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).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swarmclawai/swarmclaw",
3
- "version": "1.8.13",
3
+ "version": "1.9.2",
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",
@@ -84,10 +84,10 @@
84
84
  "lint:baseline": "node ./scripts/lint-baseline.mjs check",
85
85
  "lint:baseline:update": "node ./scripts/lint-baseline.mjs update",
86
86
  "cli": "node ./bin/swarmclaw.js",
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",
87
+ "test:cli": "node --test src/cli/*.test.js bin/*.test.js scripts/electron-after-pack.test.mjs scripts/ensure-sandbox-browser-image.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/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/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/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/agents/delegation-advisory.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/chat-execution/reasoning-tag-scrubber.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/tasks/task-service.test.ts src/lib/server/session-tools/execute.test.ts src/lib/server/session-tools/manage-tasks.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/portability/export/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",
@@ -10,6 +10,7 @@ const args = new Set(process.argv.slice(2))
10
10
  const quiet = args.has('--quiet')
11
11
  const required = args.has('--required')
12
12
  const image = process.env.SWARMCLAW_SANDBOX_BROWSER_IMAGE || 'swarmclaw-sandbox-browser:bookworm-slim'
13
+ const DEFAULT_BUILD_TIMEOUT_MS = 20 * 60 * 1000
13
14
  const SOURCE_LABEL = 'swarmclaw.sandboxBrowserSourceHash'
14
15
 
15
16
  function log(message) {
@@ -29,6 +30,11 @@ function run(command, commandArgs, options = {}) {
29
30
  })
30
31
  }
31
32
 
33
+ function readPositiveInteger(value, fallback) {
34
+ const parsed = Number.parseInt(String(value || ''), 10)
35
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback
36
+ }
37
+
32
38
  function commandExists(name) {
33
39
  const lookup = process.platform === 'win32' ? 'where' : 'which'
34
40
  const result = run(lookup, [name])
@@ -56,6 +62,7 @@ function readImageLabel(name, label) {
56
62
  }
57
63
 
58
64
  function buildImage(sourceHash) {
65
+ const timeoutMs = readPositiveInteger(process.env.SWARMCLAW_SANDBOX_BROWSER_BUILD_TIMEOUT_MS, DEFAULT_BUILD_TIMEOUT_MS)
59
66
  log(`Building sandbox browser image ${image}...`)
60
67
  const result = spawnSync(
61
68
  'docker',
@@ -69,13 +76,16 @@ function buildImage(sourceHash) {
69
76
  {
70
77
  cwd,
71
78
  stdio: 'inherit',
79
+ timeout: timeoutMs,
72
80
  },
73
81
  )
74
82
  if (result.error || (result.status ?? 1) !== 0) {
83
+ const timedOut = result.error?.code === 'ETIMEDOUT' || result.signal === 'SIGTERM'
84
+ const detail = timedOut ? ` Build timed out after ${timeoutMs}ms.` : ''
75
85
  if (required) {
76
- fail(`Failed to build sandbox browser image ${image}.`, result.status ?? 1)
86
+ fail(`Failed to build sandbox browser image ${image}.${detail}`, result.status ?? 1)
77
87
  }
78
- log(`Skipping sandbox browser image after build failure.`)
88
+ log(`Skipping sandbox browser image after build failure.${detail}`)
79
89
  return false
80
90
  }
81
91
  log(`Sandbox browser image ready: ${image}`)
@@ -1,6 +1,7 @@
1
1
  import { NextResponse } from 'next/server'
2
2
  import {
3
3
  getKnowledgeHygieneSummary,
4
+ pruneArchivedKnowledgeSources,
4
5
  runKnowledgeHygieneMaintenance,
5
6
  } from '@/lib/server/knowledge-sources'
6
7
 
@@ -8,6 +9,23 @@ export async function GET() {
8
9
  return NextResponse.json(await getKnowledgeHygieneSummary())
9
10
  }
10
11
 
11
- export async function POST() {
12
+ export async function POST(req: Request) {
13
+ let body: Record<string, unknown> | null = null
14
+ if ((req.headers.get('content-type') || '').includes('application/json')) {
15
+ try {
16
+ const parsed = await req.json()
17
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) body = parsed as Record<string, unknown>
18
+ } catch {
19
+ body = null
20
+ }
21
+ }
22
+
23
+ if (body?.action === 'prune') {
24
+ const olderThanDays = typeof body.olderThanDays === 'number' ? body.olderThanDays : null
25
+ const result = await pruneArchivedKnowledgeSources({ olderThanDays })
26
+ const summary = await getKnowledgeHygieneSummary()
27
+ return NextResponse.json({ ...summary, prune: result })
28
+ }
29
+
12
30
  return NextResponse.json(await runKnowledgeHygieneMaintenance())
13
31
  }
@@ -0,0 +1,17 @@
1
+ import assert from 'node:assert/strict'
2
+ import { describe, it } from 'node:test'
3
+
4
+ import { GET } from './route'
5
+ import { buildPortableExportFilename } from '@/lib/server/portability/export'
6
+
7
+ describe('GET /api/portability/export', () => {
8
+ it('returns a collision-resistant attachment filename for downloads', async () => {
9
+ const response = await GET(new Request('http://local/api/portability/export?download=true'))
10
+ assert.equal(response.status, 200)
11
+ assert.equal(response.headers.get('content-type'), 'application/json; charset=utf-8')
12
+ const disposition = response.headers.get('content-disposition') || ''
13
+ assert.match(disposition, /^attachment; filename="swarmclaw-export-\d{8}-\d{6}\d{3}Z\.json"$/)
14
+ const body = await response.json()
15
+ assert.equal(disposition, `attachment; filename="${buildPortableExportFilename(body)}"`)
16
+ })
17
+ })
@@ -1,8 +1,17 @@
1
1
  import { NextResponse } from 'next/server'
2
- import { exportConfig } from '@/lib/server/portability/export'
2
+ import { buildPortableExportFilename, exportConfig } from '@/lib/server/portability/export'
3
3
  export const dynamic = 'force-dynamic'
4
4
 
5
- export async function GET() {
5
+ export async function GET(req: Request) {
6
6
  const manifest = exportConfig()
7
+ const { searchParams } = new URL(req.url)
8
+ if (searchParams.get('download') === 'true') {
9
+ return new NextResponse(JSON.stringify(manifest, null, 2), {
10
+ headers: {
11
+ 'content-type': 'application/json; charset=utf-8',
12
+ 'content-disposition': `attachment; filename="${buildPortableExportFilename(manifest)}"`,
13
+ },
14
+ })
15
+ }
7
16
  return NextResponse.json(manifest)
8
17
  }
@@ -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: Partial<BoardTask> }) => updateTask(id, 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) => {