@fish-under-sea/dsh-agent-teams-fish 1.0.2 → 2.0.0
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/NOTICE.md +13 -7
- package/README.en.md +20 -12
- package/README.md +20 -12
- package/compatibility.json +82 -46
- package/icon.png +0 -0
- package/lib/artifacts.js +148 -25
- package/lib/client/ActivityPanel.js +26 -5
- package/lib/client/WorkspaceActivity.js +6 -4
- package/lib/client/activity-monitor.js +113 -41
- package/lib/client/locales.js +14 -0
- package/lib/client.js +433 -199
- package/lib/client.js.map +1 -1
- package/lib/command.js +7 -4
- package/lib/git-artifact-stamp.json +2 -2
- package/lib/harness-compat.js +120 -62
- package/lib/index.js +7 -10
- package/lib/mailbox.js +15 -5
- package/lib/members.js +221 -154
- package/lib/snapshot.js +15 -10
- package/lib/state.js +41 -8
- package/lib/tools.js +123 -64
- package/lib/types/artifacts.d.ts +6 -3
- package/lib/types/client/activity-monitor.d.ts +13 -4
- package/lib/types/client/locales.d.ts +14 -0
- package/lib/types/harness-compat.d.ts +63 -16
- package/lib/types/mailbox.d.ts +2 -0
- package/lib/types/members.d.ts +5 -17
- package/lib/types/snapshot.d.ts +12 -7
- package/lib/types/state.d.ts +10 -3
- package/lib/types/types.d.ts +5 -0
- package/lib/types/web-routes.d.ts +2 -0
- package/lib/types/workspace-audit-service.d.ts +35 -0
- package/lib/types/workspace-audit-worker.d.ts +1 -0
- package/lib/web-routes.js +31 -0
- package/lib/workspace-audit-service.js +165 -0
- package/lib/workspace-audit-worker.js +11 -0
- package/lib/workspace-audit.js +6 -5
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +69 -64
- package/pnpm-workspace.yaml +306 -273
- package/release-notes/v0.1.25.md +16 -0
- package/release-notes/v0.1.26.md +19 -0
- package/release-notes/v0.1.27.md +42 -0
- package/release-notes/v0.1.28.md +45 -0
- package/release-notes/v0.1.29.md +23 -0
- package/release-notes/v1.1.0.md +42 -0
- package/release-notes/v2.0.0.md +17 -0
- package/scripts/artwork-role-match.test.mjs +517 -0
- package/scripts/capabilities.test.mjs +301 -0
- package/scripts/check-install-channel.mjs +55 -0
- package/scripts/check-install-channel.test.mjs +39 -0
- package/scripts/clean-build.mjs +14 -0
- package/scripts/client-harness-migration.test.mjs +46 -0
- package/scripts/compatibility.mjs +20 -0
- package/scripts/compatibility.test.mjs +187 -0
- package/scripts/corrupt-teamjson.test.mjs +180 -0
- package/scripts/custom-artwork.test.mjs +273 -0
- package/scripts/fallback-tdd.mjs +61 -0
- package/scripts/fixtures/harness-benchmark-scope.mjs +16 -0
- package/scripts/fixtures/harness-benchmark-scope.test.mjs +18 -0
- package/scripts/fixtures/harness-complex-case.mjs +201 -0
- package/scripts/fixtures/harness-complex-case.test.mjs +21 -0
- package/scripts/fixtures/harness-complex-oracle.mjs +63 -0
- package/scripts/fixtures/harness-issue-case.mjs +51 -0
- package/scripts/fixtures/harness-issue159-case.mjs +28 -0
- package/scripts/fixtures/harness-model-case.mjs +127 -0
- package/scripts/fixtures/harness-model-case.test.mjs +37 -0
- package/scripts/fixtures/harness-model-driver.mjs +100 -0
- package/scripts/fixtures/harness-runtime-credentials.mjs +23 -0
- package/scripts/fixtures/harness-runtime-entry.mjs +171 -0
- package/scripts/fixtures/harness-runtime-idle.mjs +42 -0
- package/scripts/fixtures/harness-runtime-llm.mjs +193 -0
- package/scripts/fixtures/harness-runtime-protocol.mjs +187 -0
- package/scripts/fixtures/harness-runtime-resume.mjs +24 -0
- package/scripts/fixtures/harness-runtime-stability.mjs +282 -0
- package/scripts/fixtures/harness-runtime-tools.mjs +13 -0
- package/scripts/fixtures/harness-runtime-web-approval.mjs +341 -0
- package/scripts/fixtures/issue-336-audit-worker.mjs +18 -0
- package/scripts/git-artifacts.mjs +64 -0
- package/scripts/git-artifacts.test.mjs +32 -0
- package/scripts/harness-compat-tdd.mjs +492 -0
- package/scripts/harness-issue-verify.mjs +26 -0
- package/scripts/harness-model-benchmark.mjs +163 -0
- package/scripts/harness-runtime-platform.test.mjs +31 -0
- package/scripts/harness-runtime-scenarios.mjs +297 -0
- package/scripts/harness-runtime-verify.mjs +169 -0
- package/scripts/harness-source-verify.mjs +211 -0
- package/scripts/harness-source-verify.test.mjs +97 -0
- package/scripts/harness-validation.mjs +68 -0
- package/scripts/harness-validation.test.mjs +95 -0
- package/scripts/http-body.test.mjs +72 -0
- package/scripts/import-vendor-artwork.mjs +78 -0
- package/scripts/inline-plan-blank-optional-tdd.mjs +121 -0
- package/scripts/issue-159.test.mjs +78 -0
- package/scripts/issue-188.test.mjs +148 -0
- package/scripts/issue-189.test.mjs +100 -0
- package/scripts/issue-203-card.test.mjs +181 -0
- package/scripts/issue-205.test.mjs +163 -0
- package/scripts/issue-234.test.mjs +424 -0
- package/scripts/issue-236-stale-module.test.mjs +63 -0
- package/scripts/issue-236.test.mjs +59 -0
- package/scripts/issue-262.test.mjs +98 -0
- package/scripts/issue-336.test.mjs +404 -0
- package/scripts/legacy-session-source-repair.test.mjs +201 -0
- package/scripts/lifecycle-verify.mjs +1573 -0
- package/scripts/lineage-identity.test.mjs +77 -0
- package/scripts/member-failure-tdd.mjs +451 -0
- package/scripts/member-spawn-recovery.test.mjs +92 -0
- package/scripts/quality-gates-amend.test.mjs +161 -0
- package/scripts/quality-gates-content-bound.test.mjs +572 -0
- package/scripts/quality-gates-cross-binding.test.mjs +184 -0
- package/scripts/quality-gates-excluded-scope.test.mjs +163 -0
- package/scripts/quality-gates-repair-scope.test.mjs +143 -0
- package/scripts/quality-gates-repair-wiring.test.mjs +189 -0
- package/scripts/quality-gates-tdd.mjs +1238 -0
- package/scripts/quality-gates-work-order.test.mjs +494 -0
- package/scripts/readme-version.mjs +89 -0
- package/scripts/readme-version.test.mjs +77 -0
- package/scripts/release-metadata.mjs +45 -0
- package/scripts/release-metadata.test.mjs +66 -0
- package/scripts/scoped-release.test.mjs +52 -0
- package/scripts/stability-tdd.mjs +144 -0
- package/scripts/stress-verify.mjs +548 -0
- package/scripts/symlink-support.mjs +46 -0
- package/scripts/sync-skill.mjs +103 -0
- package/scripts/tool-policies.test.mjs +280 -0
- package/scripts/update-skills.mjs +105 -0
- package/scripts/update-skills.test.mjs +79 -0
- package/scripts/upgrade-status.mjs +66 -0
- package/scripts/upgrade-status.test.mjs +83 -0
- package/scripts/verify-package.mjs +73 -0
- package/scripts/verify.mjs +2199 -0
- package/scripts/web-routes-verify.mjs +142 -0
- package/scripts/workspace-activity.test.mjs +346 -0
- package/scripts/workspace-summary.test.mjs +49 -0
- package/src/artifacts.ts +487 -0
- package/src/artwork-source.ts +262 -0
- package/src/capabilities.ts +113 -0
- package/src/client/ActivityPanel.module.css +2390 -0
- package/src/client/ActivityPanel.tsx +1507 -0
- package/src/client/AgentTeamsCard.module.css +148 -0
- package/src/client/AgentTeamsCard.tsx +155 -0
- package/src/client/StagingPlanEditor.tsx +829 -0
- package/src/client/TeamChatEntry.tsx +27 -0
- package/src/client/WorkspaceActivity.module.css +41 -0
- package/src/client/WorkspaceActivity.tsx +137 -0
- package/src/client/activity-model.ts +372 -0
- package/src/client/activity-monitor.ts +440 -0
- package/src/client/agent-teams-card-definition.ts +250 -0
- package/src/client/artwork.ts +374 -0
- package/src/client/icons.tsx +17 -0
- package/src/client/index.tsx +140 -0
- package/src/client/locales.ts +481 -0
- package/src/client/panel-geometry.ts +194 -0
- package/src/client/session-navigation.ts +73 -0
- package/src/client/workspace-state.ts +52 -0
- package/src/command.ts +145 -0
- package/src/css-modules.d.ts +4 -0
- package/src/event-types.ts +177 -0
- package/src/events.ts +78 -0
- package/src/harness-compat.ts +570 -0
- package/src/index.ts +599 -0
- package/src/lineage.ts +248 -0
- package/src/mailbox.ts +185 -0
- package/src/members.ts +1230 -0
- package/src/profiles.ts +765 -0
- package/src/quality-gates.ts +2124 -0
- package/src/scheduler.ts +554 -0
- package/src/snapshot.ts +333 -0
- package/src/state.ts +1317 -0
- package/src/tool-names.ts +14 -0
- package/src/tool-policies.ts +219 -0
- package/src/tools.ts +2939 -0
- package/src/types.ts +414 -0
- package/src/web-routes.ts +128 -0
- package/src/workspace-audit-service.ts +182 -0
- package/src/workspace-audit-worker.ts +12 -0
- package/src/workspace-audit.ts +57 -0
package/src/snapshot.ts
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Team activity snapshot assembly for the activity panel.
|
|
3
|
+
*
|
|
4
|
+
* Server-side assembly mirrors the Claude Code desktop teamWatcher: read the
|
|
5
|
+
* durable team files (the truth source) and enrich with live subagent
|
|
6
|
+
* activity, so the panel always reflects the on-disk state even when a model
|
|
7
|
+
* skipped a tool "ritual" (e.g. not calling update_task on completion).
|
|
8
|
+
* @module dsh-agent-teams/snapshot
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { Context } from '@deepseek-ai/cordis'
|
|
12
|
+
import type { SessionId } from '@deepseek-ai/dsh-session'
|
|
13
|
+
import { readdir } from 'node:fs/promises'
|
|
14
|
+
import { join } from 'node:path'
|
|
15
|
+
import { captainRouteOf, memberActivity } from './members.ts'
|
|
16
|
+
import { canDeclareDelivery, describeQualityLoop, verdictAuditNotes } from './quality-gates.ts'
|
|
17
|
+
import { workspaceAuditor } from './workspace-audit-service.ts'
|
|
18
|
+
import {
|
|
19
|
+
CAPTAIN_KEY, listArchivedTeamIds, readArchivedTeam, readUnreadMailbox, readTeam,
|
|
20
|
+
taskDepthsById, taskVisualState,
|
|
21
|
+
} from './state.ts'
|
|
22
|
+
import type { MemberStatus, TeamState, TeamTask } from './types.ts'
|
|
23
|
+
|
|
24
|
+
/** Visual task state for the activity panel. */
|
|
25
|
+
export type VisualTaskState = 'blocked' | 'open' | 'claimed' | 'running' | 'completed' | 'failed' | 'cancelled'
|
|
26
|
+
|
|
27
|
+
/** One member row of the activity snapshot. */
|
|
28
|
+
export interface TeamActivityMember {
|
|
29
|
+
readonly id: string
|
|
30
|
+
readonly name: string
|
|
31
|
+
readonly role: string
|
|
32
|
+
readonly provider: string
|
|
33
|
+
readonly model: string
|
|
34
|
+
readonly reasoningEffort: string
|
|
35
|
+
readonly executionPrompt?: string
|
|
36
|
+
readonly status: MemberStatus
|
|
37
|
+
readonly activity: 'working' | 'idle' | 'unknown'
|
|
38
|
+
readonly progress: number
|
|
39
|
+
readonly done: number
|
|
40
|
+
readonly total: number
|
|
41
|
+
readonly currentTask: string
|
|
42
|
+
readonly unread: number
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** One task row of the activity snapshot. */
|
|
46
|
+
export interface TeamActivityTask {
|
|
47
|
+
readonly id: string
|
|
48
|
+
readonly subject: string
|
|
49
|
+
readonly description?: string
|
|
50
|
+
readonly status: string
|
|
51
|
+
readonly state: VisualTaskState
|
|
52
|
+
readonly assignee: string
|
|
53
|
+
readonly model: string
|
|
54
|
+
readonly dependencies: readonly string[]
|
|
55
|
+
readonly depth: number
|
|
56
|
+
readonly kind?: string
|
|
57
|
+
readonly round?: number
|
|
58
|
+
readonly verdict?: string
|
|
59
|
+
/**
|
|
60
|
+
* Set when this task's verdict or auto-generated work order no longer
|
|
61
|
+
* describes the current bytes; the panel must not render a bare pass badge.
|
|
62
|
+
*/
|
|
63
|
+
readonly verdictStale?: string
|
|
64
|
+
/** Durable last-write stamp; drives the finished-member ordering (issue #192). */
|
|
65
|
+
readonly updatedAt: number
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** One captain-inbox preview row. */
|
|
69
|
+
export interface TeamActivityMessage {
|
|
70
|
+
readonly from: string
|
|
71
|
+
readonly content: string
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** The full panel payload for one team. */
|
|
75
|
+
export interface TeamActivitySnapshot {
|
|
76
|
+
readonly workspace: string
|
|
77
|
+
readonly teamId: string
|
|
78
|
+
readonly name: string
|
|
79
|
+
readonly description?: string
|
|
80
|
+
readonly captainSessionId: string
|
|
81
|
+
/**
|
|
82
|
+
* The captain's model route, so the panel can pick the captain's vendor
|
|
83
|
+
* artwork the same way it does for members. Empty when the host could not
|
|
84
|
+
* resolve it, in which case the client keeps the packaged fallback.
|
|
85
|
+
*/
|
|
86
|
+
readonly captainProvider: string
|
|
87
|
+
readonly captainModel: string
|
|
88
|
+
readonly phase: 'staged' | 'running'
|
|
89
|
+
readonly planReviewState?: 'awaiting_review' | 'awaiting_feedback'
|
|
90
|
+
readonly halted?: boolean
|
|
91
|
+
readonly members: readonly TeamActivityMember[]
|
|
92
|
+
readonly tasks: readonly TeamActivityTask[]
|
|
93
|
+
readonly messageCount: number
|
|
94
|
+
readonly captainInbox: readonly TeamActivityMessage[]
|
|
95
|
+
/** Present when the snapshot could audit the workspace bytes. */
|
|
96
|
+
readonly loopState?: string
|
|
97
|
+
readonly deliverable?: boolean
|
|
98
|
+
readonly delivery?: { readonly ok: boolean; readonly blockers: readonly string[]; readonly warnings: readonly string[] }
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Snapshot projection switches for live and archived teams. */
|
|
102
|
+
export interface TeamSnapshotOptions {
|
|
103
|
+
/** Running panels omit the long text used only by the staging editor. */
|
|
104
|
+
readonly summary?: boolean
|
|
105
|
+
/** Historic review must retain members that were marked removed at shutdown. */
|
|
106
|
+
readonly includeRemoved?: boolean
|
|
107
|
+
/** Archived teams have no meaningful live activity after their sessions stop. */
|
|
108
|
+
readonly historic?: boolean
|
|
109
|
+
/**
|
|
110
|
+
* Absolute workspace path of the owning workspace. When present, the snapshot
|
|
111
|
+
* audits the current bytes behind every recorded verdict, so the panel and
|
|
112
|
+
* the model-facing status tool cannot report different delivery verdicts.
|
|
113
|
+
*/
|
|
114
|
+
readonly workspacePath?: string
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** The current task of a member: its first unfinished owned task. */
|
|
118
|
+
function currentTaskOf(memberName: string, tasks: readonly TeamTask[]): string {
|
|
119
|
+
for (const task of tasks) {
|
|
120
|
+
if (task.status === 'in_progress' && task.assignee === memberName) return task.id
|
|
121
|
+
}
|
|
122
|
+
return ''
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Compact `provider/model` route for the activity panel, or just the model. */
|
|
126
|
+
export function memberModelRoute(member: { provider?: string; model?: string } | undefined): string {
|
|
127
|
+
if (member === undefined) return ''
|
|
128
|
+
const provider = member.provider?.trim() ?? ''
|
|
129
|
+
const model = member.model?.trim() ?? ''
|
|
130
|
+
if (provider !== '' && model !== '') return `${provider}/${model}`
|
|
131
|
+
return model
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Assemble one team snapshot from its durable files plus live activity.
|
|
136
|
+
* @param ctx - the plugin context (injects `subagents`, used for activity).
|
|
137
|
+
* @param stateRoot - resolved absolute state root of the owning workspace.
|
|
138
|
+
* @param workspace - display name of the owning workspace.
|
|
139
|
+
* @param state - the durable team record.
|
|
140
|
+
* @returns the panel snapshot.
|
|
141
|
+
*/
|
|
142
|
+
export async function assembleTeamSnapshot(
|
|
143
|
+
ctx: Context,
|
|
144
|
+
stateRoot: string,
|
|
145
|
+
workspace: string,
|
|
146
|
+
state: TeamState,
|
|
147
|
+
options: TeamSnapshotOptions = {},
|
|
148
|
+
): Promise<TeamActivitySnapshot> {
|
|
149
|
+
const tasks = state.tasks
|
|
150
|
+
const includePlanText = options.summary !== true || state.phase === 'staged' || options.historic === true
|
|
151
|
+
const depths = taskDepthsById(tasks)
|
|
152
|
+
const roster = options.includeRemoved === true
|
|
153
|
+
? state.members
|
|
154
|
+
: state.members.filter((member) => member.status !== 'removed')
|
|
155
|
+
const activity = options.historic === true
|
|
156
|
+
? new Map<string, 'running' | 'idle' | 'ready'>()
|
|
157
|
+
: memberActivity(ctx, roster.map((member) => member.id))
|
|
158
|
+
const unreadByMember = new Map<string, number>()
|
|
159
|
+
for (const member of roster) {
|
|
160
|
+
try {
|
|
161
|
+
unreadByMember.set(member.name, (await readUnreadMailbox(stateRoot, state.id, member.name)).length)
|
|
162
|
+
} catch (error: unknown) {
|
|
163
|
+
ctx.logger.warn(`agent-teams: mailbox read failed for ${member.name}: ${String(error)}`)
|
|
164
|
+
unreadByMember.set(member.name, 0)
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const members: TeamActivityMember[] = roster.map((member) => {
|
|
168
|
+
const owned = tasks.filter((task) => task.assignee === member.name)
|
|
169
|
+
const done = owned.filter((task) => task.status === 'completed').length
|
|
170
|
+
return {
|
|
171
|
+
id: member.id,
|
|
172
|
+
name: member.name,
|
|
173
|
+
role: member.role ?? '',
|
|
174
|
+
provider: member.provider?.trim() ?? '',
|
|
175
|
+
model: member.model?.trim() ?? '',
|
|
176
|
+
reasoningEffort: member.reasoningEffort?.trim() ?? '',
|
|
177
|
+
...includePlanText ? { executionPrompt: member.executionPrompt ?? '' } : {},
|
|
178
|
+
status: member.status,
|
|
179
|
+
activity: options.historic === true
|
|
180
|
+
? 'idle'
|
|
181
|
+
: member.id !== ''
|
|
182
|
+
? (activity.get(member.id) === 'running'
|
|
183
|
+
? 'working'
|
|
184
|
+
: activity.get(member.id) === 'idle' || activity.get(member.id) === 'ready'
|
|
185
|
+
? 'idle'
|
|
186
|
+
: 'unknown')
|
|
187
|
+
: 'idle',
|
|
188
|
+
progress: owned.length === 0 ? 0 : Math.round((done / owned.length) * 100),
|
|
189
|
+
done,
|
|
190
|
+
total: owned.length,
|
|
191
|
+
currentTask: currentTaskOf(member.name, tasks),
|
|
192
|
+
unread: unreadByMember.get(member.name) ?? 0,
|
|
193
|
+
}
|
|
194
|
+
})
|
|
195
|
+
const captainInbox = await readUnreadMailbox(stateRoot, state.id, CAPTAIN_KEY)
|
|
196
|
+
// The captain's live route wins over the durable snapshot: a user who
|
|
197
|
+
// switches the session model mid-team should see the captain art follow,
|
|
198
|
+
// while a cold/absent session still answers from what creation recorded.
|
|
199
|
+
const liveCaptain = ctx.agents.get(state.captainSessionId as SessionId)
|
|
200
|
+
const liveRoute = liveCaptain === undefined ? undefined : captainRouteOf(liveCaptain)
|
|
201
|
+
const captainProvider = liveRoute?.captainProvider ?? state.captainProvider ?? ''
|
|
202
|
+
const captainModel = liveRoute?.captainModel ?? state.captainModel ?? ''
|
|
203
|
+
// The panel must reach the same delivery conclusion as the status tool, so
|
|
204
|
+
// it reads the same current bytes instead of trusting task records alone.
|
|
205
|
+
const audit = options.workspacePath === undefined ? undefined : await workspaceAuditor(ctx).audit(options.workspacePath, state, stateRoot)
|
|
206
|
+
const deliveryCheck = audit === undefined ? canDeclareDelivery(state) : canDeclareDelivery(state, audit)
|
|
207
|
+
const loop = audit === undefined ? describeQualityLoop(state) : describeQualityLoop(state, audit)
|
|
208
|
+
const staleById = new Map<string, string[]>()
|
|
209
|
+
if (audit !== undefined) {
|
|
210
|
+
for (const note of verdictAuditNotes(state, audit)) {
|
|
211
|
+
staleById.set(note.taskId, [...staleById.get(note.taskId) ?? [], note.message])
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
workspace,
|
|
216
|
+
teamId: state.id,
|
|
217
|
+
name: state.name,
|
|
218
|
+
...state.description !== undefined ? { description: state.description } : {},
|
|
219
|
+
captainSessionId: state.captainSessionId,
|
|
220
|
+
captainProvider,
|
|
221
|
+
captainModel,
|
|
222
|
+
phase: state.phase ?? 'running',
|
|
223
|
+
...state.phase === 'staged'
|
|
224
|
+
? { planReviewState: state.planReviewState ?? 'awaiting_review' as const }
|
|
225
|
+
: {},
|
|
226
|
+
...state.halted === true ? { halted: true } : {},
|
|
227
|
+
...audit === undefined ? {} : {
|
|
228
|
+
loopState: loop.state,
|
|
229
|
+
deliverable: loop.deliverable,
|
|
230
|
+
delivery: { ok: deliveryCheck.ok, blockers: [...deliveryCheck.blockers], warnings: [...deliveryCheck.warnings] },
|
|
231
|
+
},
|
|
232
|
+
members,
|
|
233
|
+
tasks: tasks.map((task) => ({
|
|
234
|
+
id: task.id,
|
|
235
|
+
subject: task.subject,
|
|
236
|
+
...includePlanText ? { description: task.description ?? '' } : {},
|
|
237
|
+
status: task.status,
|
|
238
|
+
state: taskVisualState(task.status, task.dependencies, tasks),
|
|
239
|
+
assignee: task.assignee ?? '',
|
|
240
|
+
model: memberModelRoute(roster.find((member) => member.name === task.assignee)),
|
|
241
|
+
dependencies: task.dependencies,
|
|
242
|
+
depth: depths.get(task.id) ?? 0,
|
|
243
|
+
...task.kind === undefined ? {} : { kind: task.kind },
|
|
244
|
+
...task.round === undefined ? {} : { round: task.round },
|
|
245
|
+
...task.verdict === undefined ? {} : { verdict: task.verdict },
|
|
246
|
+
...staleById.get(task.id) === undefined ? {} : { verdictStale: (staleById.get(task.id) as string[]).join('; ') },
|
|
247
|
+
updatedAt: task.updatedAt,
|
|
248
|
+
})),
|
|
249
|
+
messageCount: captainInbox.length
|
|
250
|
+
+ members.reduce((count, member) => count + member.unread, 0),
|
|
251
|
+
captainInbox: captainInbox.slice(-5).map((message) => ({
|
|
252
|
+
from: message.from,
|
|
253
|
+
content: message.content,
|
|
254
|
+
})),
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Collect live teams under the given workspace state roots.
|
|
260
|
+
* @param ctx - the plugin context.
|
|
261
|
+
* @param roots - `{ workspace, stateRoot }` pairs (resolved absolute roots).
|
|
262
|
+
* @param captainSessionId - when present, assemble only the requested captain's teams.
|
|
263
|
+
* @param summary - omit editor-only text from running teams.
|
|
264
|
+
* @returns the snapshots in stable order (workspace, then team id).
|
|
265
|
+
*/
|
|
266
|
+
export async function collectTeamsActivity(
|
|
267
|
+
ctx: Context,
|
|
268
|
+
roots: readonly { workspace: string; stateRoot: string; workspacePath?: string }[],
|
|
269
|
+
captainSessionId?: string,
|
|
270
|
+
summary = false,
|
|
271
|
+
): Promise<TeamActivitySnapshot[]> {
|
|
272
|
+
const snapshots: TeamActivitySnapshot[] = []
|
|
273
|
+
for (const root of roots) {
|
|
274
|
+
let entries
|
|
275
|
+
try {
|
|
276
|
+
entries = await readdir(root.stateRoot, { withFileTypes: true })
|
|
277
|
+
} catch (error: unknown) {
|
|
278
|
+
if (error instanceof Error && 'code' in error && (error as NodeJS.ErrnoException).code === 'ENOENT') {
|
|
279
|
+
continue
|
|
280
|
+
}
|
|
281
|
+
throw error
|
|
282
|
+
}
|
|
283
|
+
for (const entry of entries) {
|
|
284
|
+
if (!entry.isDirectory()) continue
|
|
285
|
+
try {
|
|
286
|
+
const state = await readTeam(root.stateRoot, entry.name)
|
|
287
|
+
if (state === undefined || (captainSessionId !== undefined && state.captainSessionId !== captainSessionId)) continue
|
|
288
|
+
snapshots.push(await assembleTeamSnapshot(ctx, root.stateRoot, root.workspace, state, {
|
|
289
|
+
summary,
|
|
290
|
+
...root.workspacePath === undefined ? {} : { workspacePath: root.workspacePath },
|
|
291
|
+
}))
|
|
292
|
+
} catch {
|
|
293
|
+
ctx.logger.warn(`agent-teams: skipped unreadable team state "${entry.name}" in workspace "${root.workspace}"`)
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return snapshots
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Collect archived teams under the given workspace state roots (the
|
|
302
|
+
* `archive/` subdirectory of each state root). Used by the historic panel
|
|
303
|
+
* path to restore full team detail after deletion.
|
|
304
|
+
* @param ctx - the plugin context.
|
|
305
|
+
* @param roots - `{ workspace, stateRoot }` pairs.
|
|
306
|
+
* @param captainSessionId - when present, assemble only the requested captain's teams.
|
|
307
|
+
* @returns the archived snapshots in stable order.
|
|
308
|
+
*/
|
|
309
|
+
export async function collectArchivedTeamsActivity(
|
|
310
|
+
ctx: Context,
|
|
311
|
+
roots: readonly { workspace: string; stateRoot: string }[],
|
|
312
|
+
captainSessionId?: string,
|
|
313
|
+
): Promise<TeamActivitySnapshot[]> {
|
|
314
|
+
const snapshots: TeamActivitySnapshot[] = []
|
|
315
|
+
for (const root of roots) {
|
|
316
|
+
for (const teamId of await listArchivedTeamIds(root.stateRoot)) {
|
|
317
|
+
try {
|
|
318
|
+
const state = await readArchivedTeam(root.stateRoot, teamId)
|
|
319
|
+
if (state === undefined || (captainSessionId !== undefined && state.captainSessionId !== captainSessionId)) continue
|
|
320
|
+
snapshots.push(await assembleTeamSnapshot(
|
|
321
|
+
ctx,
|
|
322
|
+
join(root.stateRoot, 'archive'),
|
|
323
|
+
root.workspace,
|
|
324
|
+
state,
|
|
325
|
+
{ includeRemoved: true, historic: true },
|
|
326
|
+
))
|
|
327
|
+
} catch {
|
|
328
|
+
ctx.logger.warn(`agent-teams: skipped unreadable archived team "${teamId}" in workspace "${root.workspace}"`)
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return snapshots
|
|
333
|
+
}
|