dsh-team-bots 0.2.455 → 0.2.460
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/package.json +1 -1
- package/src/config.js +3 -0
- package/src/db-migrations.js +4 -0
- package/src/db.js +1 -0
- package/src/http.js +11 -5
- package/src/services/chat.js +13 -6
- package/src/services/runtime/prompt.js +17 -6
- package/src/services/system.js +1 -1
- package/src/services/task-dispatch.js +3 -0
- package/src/services/tasks.js +12 -4
- package/src/services/write-scopes.js +38 -0
- package/src/tools.js +2 -1
- package/ui/app.js +2 -1
- package/ui/i18n/en/tasks.js +8 -0
- package/ui/i18n/zh/tasks.js +8 -0
- package/ui/modules/events-click.js +5 -0
- package/ui/modules/file-preview.js +89 -0
- package/ui/modules/modal-forms.js +8 -9
- package/ui/modules/modal-layer.js +2 -0
- package/ui/modules/tasks.js +20 -0
- package/ui/modules/util.js +39 -0
- package/ui/styles/base.css +13 -13
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -346,6 +346,9 @@ export function resolveConfig(config = {}) {
|
|
|
346
346
|
uiLanguage: normalizeUiLanguage(config.uiLanguage ?? process.env.DSH_TEAM_UI_LANGUAGE ?? 'auto'),
|
|
347
347
|
// 群聊只放结论,完整交付进任务评论。
|
|
348
348
|
chatReplyMaxChars: int(config.chatReplyMaxChars ?? process.env.DSH_TEAM_CHAT_MAX_CHARS, 800, 80, 8_000),
|
|
349
|
+
// 交付报告体量红线(DSHBOTS-345 复盘):任务交付报告 ≤ 此字符数,且只引用交付物路径,
|
|
350
|
+
// 禁止把已写入工作区的文件正文复述进报告/聊天——生成侧 output 与复审上下文双省。
|
|
351
|
+
deliveryReportMaxChars: int(config.deliveryReportMaxChars ?? process.env.DSH_TEAM_DELIVERY_REPORT_MAX_CHARS, 2_000, 200, 20_000),
|
|
349
352
|
// 私信自动归档(DSHBOTS-171):单聊默认视图只留「每 bot 最近 keep 条 且 days 天内」的
|
|
350
353
|
// 交集,超出任一阈值即归档(默认视图隐去,数据保留,messagesPage 翻页仍可查回)。
|
|
351
354
|
// 0 = 关闭该维过滤。
|
package/src/db-migrations.js
CHANGED
|
@@ -143,6 +143,7 @@ export function runMigrations(db) {
|
|
|
143
143
|
recordMigration(db, 'bots_file_policy')
|
|
144
144
|
recordMigration(db, 'tasks_runs_write_scopes')
|
|
145
145
|
recordMigration(db, 'tasks_time_budget_minutes')
|
|
146
|
+
recordMigration(db, 'tasks_deliverables')
|
|
146
147
|
recordMigration(db, 'runs_retry_after_ms')
|
|
147
148
|
recordMigration(db, 'bots_fallback_model')
|
|
148
149
|
recordMigration(db, 'runs_model_override')
|
|
@@ -212,9 +213,12 @@ function migrateRuns(db) {
|
|
|
212
213
|
// tasks.write_scopes 存任务声明的写范围(JSON 路径数组);空数组 = 未声明,
|
|
213
214
|
// 调度器据此把同项目写运行改为「范围不重叠才并行」。
|
|
214
215
|
// tasks.time_budget_minutes 存发布时的时效要求(分钟,NULL = 未声明不注入提示词)。
|
|
216
|
+
// tasks.deliverables 存卡面声明的交付物文件路径(JSON 路径数组);核验按路径直接读文件,
|
|
217
|
+
// 交付报告只引用路径不复述正文(DSHBOTS-345 复盘)。
|
|
215
218
|
function migrateTasks(db) {
|
|
216
219
|
addColumn(db, 'tasks', 'write_scopes', "TEXT NOT NULL DEFAULT '[]'")
|
|
217
220
|
addColumn(db, 'tasks', 'time_budget_minutes', 'INTEGER')
|
|
221
|
+
addColumn(db, 'tasks', 'deliverables', "TEXT NOT NULL DEFAULT '[]'")
|
|
218
222
|
}
|
|
219
223
|
|
|
220
224
|
// projects.disabled_skills 存项目内关闭的技能 slug JSON 数组。
|
package/src/db.js
CHANGED
|
@@ -160,6 +160,7 @@ CREATE TABLE IF NOT EXISTS tasks (
|
|
|
160
160
|
estimate REAL,
|
|
161
161
|
time_budget_minutes INTEGER,
|
|
162
162
|
write_scopes TEXT NOT NULL DEFAULT '[]',
|
|
163
|
+
deliverables TEXT NOT NULL DEFAULT '[]',
|
|
163
164
|
version INTEGER NOT NULL DEFAULT 1,
|
|
164
165
|
created_at TEXT NOT NULL,
|
|
165
166
|
updated_at TEXT NOT NULL,
|
package/src/http.js
CHANGED
|
@@ -17,6 +17,7 @@ const MAX_BODY = 32 * 1024 * 1024
|
|
|
17
17
|
const MAX_ARTIFACT_BYTES = 5 * 1024 * 1024
|
|
18
18
|
// 聊天图片通道的单文件上限,任务口径 10MB;MIME 白名单与防穿越在 service.chatFile。
|
|
19
19
|
const MAX_CHAT_IMAGE_BYTES = 10 * 1024 * 1024
|
|
20
|
+
const MAX_CHAT_TEXT_BYTES = 2 * 1024 * 1024
|
|
20
21
|
const ARTIFACT_TYPES = {
|
|
21
22
|
'.png': 'image/png',
|
|
22
23
|
'.jpg': 'image/jpeg',
|
|
@@ -175,6 +176,7 @@ export function installHttp(ctx, service, logger = console) {
|
|
|
175
176
|
route('/api/dsh-team/modules/composer.js', ['GET'], moduleScript('composer.js'))
|
|
176
177
|
route('/api/dsh-team/modules/tasks.js', ['GET'], moduleScript('tasks.js'))
|
|
177
178
|
route('/api/dsh-team/modules/modal-layer.js', ['GET'], moduleScript('modal-layer.js'))
|
|
179
|
+
route('/api/dsh-team/modules/file-preview.js', ['GET'], moduleScript('file-preview.js'))
|
|
178
180
|
route('/api/dsh-team/modules/dom-morph.js', ['GET'], moduleScript('dom-morph.js'))
|
|
179
181
|
route('/api/dsh-team/modules/modal-forms.js', ['GET'], moduleScript('modal-forms.js'))
|
|
180
182
|
route('/api/dsh-team/modules/bot-quota.js', ['GET'], moduleScript('bot-quota.js'))
|
|
@@ -314,9 +316,9 @@ export function installHttp(ctx, service, logger = console) {
|
|
|
314
316
|
}
|
|
315
317
|
})
|
|
316
318
|
|
|
317
|
-
//
|
|
318
|
-
// 10MB 上限、路径防穿越都在 service.chatFile
|
|
319
|
-
//
|
|
319
|
+
// 聊天文件通道:只读项目工作区 / 单聊 Bot 工作区内的白名单图片与文本(MIME 白名单、
|
|
320
|
+
// 图片 10MB / 文本 2MB 上限、路径防穿越都在 service.chatFile 与此层做)。与 /api 同前缀
|
|
321
|
+
// 注册,鉴权由宿主路由层承担;失败走 AppError,不落含查询串的日志。
|
|
320
322
|
route('/api/dsh-team/file', ['GET'], async (request) => {
|
|
321
323
|
try {
|
|
322
324
|
const params = searchParams(request)
|
|
@@ -326,9 +328,13 @@ export function installHttp(ctx, service, logger = console) {
|
|
|
326
328
|
if (!relPath) throw new AppError('BAD_REQUEST', '缺少参数 path', 400)
|
|
327
329
|
if (!projectId === !soloBotId) throw new AppError('BAD_REQUEST', 'projectId 与 soloBotId 必须二选一', 400)
|
|
328
330
|
const { absolutePath, size, contentType } = service.chatFile({ projectId, soloBotId, path: relPath })
|
|
329
|
-
|
|
331
|
+
// 图片 10MB、文本 2MB(DSHBOTS-347):文本弹层有前端截断,上限收紧防大文件拖垮请求。
|
|
332
|
+
const textFile = !contentType.startsWith('image/')
|
|
333
|
+
const maxBytes = textFile ? MAX_CHAT_TEXT_BYTES : MAX_CHAT_IMAGE_BYTES
|
|
334
|
+
const sizeLabel = textFile ? '文本文件超过 2MB 上限' : '图片超过 10MB 上限'
|
|
335
|
+
if (size > maxBytes) throw new AppError('FILE_TOO_LARGE', sizeLabel, 413)
|
|
330
336
|
const body = await readFile(absolutePath)
|
|
331
|
-
if (body.byteLength >
|
|
337
|
+
if (body.byteLength > maxBytes) throw new AppError('FILE_TOO_LARGE', sizeLabel, 413)
|
|
332
338
|
return response(body, contentType)
|
|
333
339
|
} catch (error) {
|
|
334
340
|
return errorResponse(error)
|
package/src/services/chat.js
CHANGED
|
@@ -395,10 +395,11 @@ export const chatMethods = {
|
|
|
395
395
|
}))
|
|
396
396
|
},
|
|
397
397
|
|
|
398
|
-
// ──
|
|
399
|
-
//
|
|
400
|
-
//
|
|
401
|
-
// SVG
|
|
398
|
+
// ── 聊天文件通道(GET /api/dsh-team/file)──────────────────────────────
|
|
399
|
+
// 定位聊天消息与交付产物引用的工作区文件:只认项目工作目录或单聊 Bot 工作区
|
|
400
|
+
// 内的白名单类型,路径解析 + realpath 双重防穿越(与 artifactFile 同口径)。
|
|
401
|
+
// SVG 可执行脚本、.env 常带密钥,永不放行;文本扩展与前端 FILE_TEXT_EXT 同口径,
|
|
402
|
+
// 统一以 text/plain 下发(前端只 textContent 渲染,新窗口兜底也只见源码)。
|
|
402
403
|
chatFile({ projectId, soloBotId, path } = {} ) {
|
|
403
404
|
const CHAT_IMAGE_TYPES = {
|
|
404
405
|
'.png': 'image/png',
|
|
@@ -407,6 +408,11 @@ export const chatMethods = {
|
|
|
407
408
|
'.gif': 'image/gif',
|
|
408
409
|
'.webp': 'image/webp',
|
|
409
410
|
}
|
|
411
|
+
const CHAT_TEXT_TYPES = new Set([
|
|
412
|
+
'.md', '.markdown', '.txt', '.log', '.json', '.csv', '.ini', '.toml',
|
|
413
|
+
'.yaml', '.yml', '.ts', '.tsx', '.js', '.mjs', '.cjs', '.jsx',
|
|
414
|
+
'.css', '.html', '.htm', '.sh', '.xml', '.py', '.sql',
|
|
415
|
+
])
|
|
410
416
|
const relPath = String(path ?? '').trim()
|
|
411
417
|
if (!relPath) throw badRequest('缺少参数 path')
|
|
412
418
|
let dir
|
|
@@ -419,8 +425,9 @@ export const chatMethods = {
|
|
|
419
425
|
} else {
|
|
420
426
|
throw badRequest('缺少参数 projectId 或 soloBotId')
|
|
421
427
|
}
|
|
422
|
-
const
|
|
423
|
-
|
|
428
|
+
const ext = extname(relPath).toLowerCase()
|
|
429
|
+
const contentType = CHAT_IMAGE_TYPES[ext] ?? (CHAT_TEXT_TYPES.has(ext) ? 'text/plain; charset=utf-8' : '')
|
|
430
|
+
if (!contentType) throw badRequest('仅支持白名单图片或文本文件')
|
|
424
431
|
let absolutePath
|
|
425
432
|
try {
|
|
426
433
|
absolutePath = assertInside(dir, join(dir, relPath))
|
|
@@ -16,7 +16,7 @@ import { parseDisabledSkills } from '../../util.js'
|
|
|
16
16
|
import { dmPrompt, replyDeliveryPrompt } from '../../botmsg.js'
|
|
17
17
|
import { rolloverPendingKey, rolloverSummaryKey } from '../../config.js'
|
|
18
18
|
import { taskDeadlineInfo } from '../tasks.js'
|
|
19
|
-
import { readWriteScopes } from '../write-scopes.js'
|
|
19
|
+
import { readDeliverables, readWriteScopes } from '../write-scopes.js'
|
|
20
20
|
import { displayPath, sanitizeTmpBotDirName } from '../../paths.js'
|
|
21
21
|
import { sandboxMethods } from './sandbox-policy.js'
|
|
22
22
|
import {
|
|
@@ -68,7 +68,7 @@ export const PROMPT_SEGMENT_DEFAULTS = {
|
|
|
68
68
|
communication: COMMUNICATION_RULES.map(line => line.replace(/^- /, '')).join('\n'),
|
|
69
69
|
subtask: 'Before closing: if this task cannot be finished in one run or new closing conditions emerge, file subtasks via team_assign_task with parent_task_id and report in the group — no verbal-only follow-ups. Subtasks are product-grade (general capability, full tests, real persistence), no throwaway patches. Do not split what one run can finish. List every subtask KEY-N in the closing report.',
|
|
70
70
|
splitting: 'Split only when all hold: the task has 2+ independent parts, parts have disjoint write scopes, and the joined cost of split cards stays below one-run delivery. One card per part: parent_task_id to this task, blocked_by where order matters. Not the project owner? Propose the split in your delivery report. Example: API card (src/api/) + docs card, run concurrently.',
|
|
71
|
-
selfcheck: 'Before reporting delivery, self-run the reproducible verification and put the evidence in the delivery report: the exact test/build commands you ran with their results, the list of files you changed, and the counts or links the acceptance criteria name (grep hits, test pass counts, commit hashes). Verify your own claims first — re-run the target tests and re-check the anchors yourself; do not report delivery on unverified work. Self-checking is always cheaper than rework: a delivery report without evidence will be returned.',
|
|
71
|
+
selfcheck: 'Before reporting delivery, self-run the reproducible verification and put the evidence in the delivery report: the exact test/build commands you ran with their results, the list of files you changed, and the counts or links the acceptance criteria name (grep hits, test pass counts, commit hashes). Verify your own claims first — re-run the target tests and re-check the anchors yourself; do not report delivery on unverified work. Self-checking is always cheaper than rework: a delivery report without evidence will be returned. The report lists deliverables as file paths only — never file contents.',
|
|
72
72
|
}
|
|
73
73
|
export const PROMPT_SEGMENT_MAX_CHARS = 2000
|
|
74
74
|
export const PROMPT_TRIO_BUDGET = 1200
|
|
@@ -445,7 +445,7 @@ Transcription requirements:
|
|
|
445
445
|
Original message from ${chatMessage?.sender_type ?? 'user'}:${chatMessage?.sender_id ?? ''}
|
|
446
446
|
${(chatMessage?.body ?? '(no text)').slice(0, 2_000)}`
|
|
447
447
|
},
|
|
448
|
-
promptFor({ run, bot, project, task, chatMessage, extraMessages, sessionId }
|
|
448
|
+
promptFor({ run, bot, project, task, chatMessage, extraMessages, sessionId } ) {
|
|
449
449
|
if (run.kind === 'solo_chat') return this.soloRunPrompt({ run, bot, chatMessage, extraMessages, sessionId })
|
|
450
450
|
if (run.kind === 'vision') return this.visionRunPrompt({ run, bot, project, chatMessage })
|
|
451
451
|
// 结转摘要(DSHBOTS-145):先于 header 判定——单聊摘要运行没有项目,
|
|
@@ -499,6 +499,9 @@ ${deadlineLine}`.trimEnd()
|
|
|
499
499
|
// 任务派生分支共用 truncateTaskDescription 的同一截断点与盲区口径(任务分支见 DSHBOTS-254)。
|
|
500
500
|
const writeScopes = readWriteScopes(task.write_scopes)
|
|
501
501
|
const declaredScopes = writeScopes.length ? writeScopes.join(', ') : '(none declared)'
|
|
502
|
+
// 交付物声明(DSHBOTS-345 复盘):核验按路径直接读文件,交付报告只作声明清单。
|
|
503
|
+
const declaredDeliverables = readDeliverables(task.deliverables)
|
|
504
|
+
const deliverablesScopesLine = declaredDeliverables.length ? declaredDeliverables.join(', ') : '(none declared)'
|
|
502
505
|
const description = truncateTaskDescription(task.description)
|
|
503
506
|
if (run.kind === 'review') {
|
|
504
507
|
// 委派核验模板(DSHBOTS-107 review-verification):核验工作由子代理并行完成,
|
|
@@ -508,6 +511,7 @@ ${deadlineLine}`.trimEnd()
|
|
|
508
511
|
|
|
509
512
|
The owner delegated the acceptance verification of this delivered task to you. Verify the delivery report item by item; do not redo the work and do not make the final call:
|
|
510
513
|
- Scope: compare what the delivery report says was changed against the declared write scopes below; flag any out-of-scope change.
|
|
514
|
+
- Deliverables: every declared deliverable path below must exist; read the files directly — the report's prose about them is claims, not evidence.
|
|
511
515
|
- Target tests: run only the test files this task names (for example node --test <files>), not the whole suite — full-suite numbers are the deliverer's responsibility on a clean tree. If the read-only sandbox blocks a check, say so explicitly instead of skipping it.
|
|
512
516
|
- Red verification: design at least one negative check (a change that should make the target tests fail) and state the expected number of red cases; when the sandbox forbids mutating files, give the exact command and the reasoned prediction.
|
|
513
517
|
- Conclusion: a recommendation of 建议 accept or 建议 return with reasons tied to the evidence below.
|
|
@@ -520,12 +524,13 @@ Your final reply is recorded as a task comment automatically. It MUST start with
|
|
|
520
524
|
Title: ${task.title}
|
|
521
525
|
Status: ${task.status}
|
|
522
526
|
Declared write scopes: ${declaredScopes}
|
|
527
|
+
Declared deliverables: ${deliverablesScopesLine}
|
|
523
528
|
Description:
|
|
524
529
|
${description}${threads}${timeBudgetBlockFor(task)}`
|
|
525
530
|
}
|
|
526
531
|
return `${header}
|
|
527
532
|
|
|
528
|
-
As the project owner, review the delivered result below against the task description. Check the delivery report claims when needed (files exist, tests pass). Then decide:
|
|
533
|
+
As the project owner, review the delivered result below against the task description. Check the delivery report claims when needed (files exist, tests pass); when deliverables are declared below, open the files at those paths instead of trusting the report prose. Then decide:
|
|
529
534
|
- If the work is acceptable, call team_review_task with decision "accept".
|
|
530
535
|
- If it needs rework, call team_review_task with decision "return" and a concrete rework reason in comment.
|
|
531
536
|
Do not redo the task yourself, and do not start parallel work here. Reply in the user's language with a short verdict.
|
|
@@ -534,6 +539,7 @@ Do not redo the task yourself, and do not start parallel work here. Reply in the
|
|
|
534
539
|
Title: ${task.title}
|
|
535
540
|
Status: ${task.status}
|
|
536
541
|
Declared write scopes: ${declaredScopes}
|
|
542
|
+
Declared deliverables: ${deliverablesScopesLine}
|
|
537
543
|
Description:
|
|
538
544
|
${description}${threads}${timeBudgetBlockFor(task)}`
|
|
539
545
|
}
|
|
@@ -674,14 +680,19 @@ Execute each card yourself, or hand it to a dedicated child agent (subagent/suba
|
|
|
674
680
|
|
|
675
681
|
# Parallel work inside this task
|
|
676
682
|
${parallelMergeBody(this.config.maxTeammates)}` : ''
|
|
683
|
+
// 交付物路径声明(DSHBOTS-345 复盘):卡面声明的交付文件,核验按路径直接读文件。
|
|
684
|
+
// 单行注入在 Status 与自检段之间:不新增段落、不动「描述后即结尾」截断口径。
|
|
685
|
+
const deliverablesLine = readDeliverables(task.deliverables).length
|
|
686
|
+
? `\nDeliverables (file paths): ${readDeliverables(task.deliverables).join(', ')}`
|
|
687
|
+
: ''
|
|
677
688
|
return `${header}${subtaskDisciplineBlock}${splittingGuidanceBlock}
|
|
678
689
|
|
|
679
|
-
Do the task in the project workspace. End with a
|
|
690
|
+
Do the task in the project workspace. End with a delivery report (≤${this.config.deliveryReportMaxChars} chars): what changed, verification performed, blockers or risks — not just a plan. Never paste file contents into the report or chat — reference paths; reviewers open the files.${parallel}${parallelMerge}
|
|
680
691
|
|
|
681
692
|
# Assigned task ${project.key}-${task.number}
|
|
682
693
|
Title: ${task.title}
|
|
683
694
|
Priority: ${task.priority}
|
|
684
|
-
Status: ${task.status}${deliverySelfcheckBlock}
|
|
695
|
+
Status: ${task.status}${deliverablesLine}${deliverySelfcheckBlock}
|
|
685
696
|
Description:
|
|
686
697
|
${description}${threads}${timeBudgetBlock}${urgentExemptionBlock}${recoveryNoteBlock}`
|
|
687
698
|
}
|
package/src/services/system.js
CHANGED
|
@@ -164,7 +164,7 @@ export const systemMethods = {
|
|
|
164
164
|
`SELECT t.*, b.name AS assignee_name FROM tasks t LEFT JOIN bots b ON b.id = t.assignee_bot_id
|
|
165
165
|
WHERE t.project_id = ? ORDER BY
|
|
166
166
|
CASE t.status WHEN 'in_progress' THEN 0 WHEN 'blocked' THEN 1 WHEN 'in_review' THEN 2 WHEN 'todo' THEN 3 WHEN 'backlog' THEN 4 ELSE 5 END,
|
|
167
|
-
t.position, t.updated_at DESC
|
|
167
|
+
t.position, t.updated_at DESC`,
|
|
168
168
|
project.id,
|
|
169
169
|
).map(task => this.taskView(task))
|
|
170
170
|
view.runs = this.store.all(
|
|
@@ -355,6 +355,7 @@ export const taskDispatchMethods = {
|
|
|
355
355
|
if (input.title !== undefined) patch.title = input.title
|
|
356
356
|
if (input.description !== undefined) patch.description = input.description
|
|
357
357
|
if (input.priority !== undefined) patch.priority = input.priority
|
|
358
|
+
if (input.deliverables !== undefined) patch.deliverables = input.deliverables
|
|
358
359
|
if (Object.keys(patch).length) await this.updateTask(task.id, patch, actor)
|
|
359
360
|
// 派单预算优先级分档兜底(DSHBOTS-325)重派路:input.priority 已被 updateTask
|
|
360
361
|
// 校验(无效即抛,到不了这里),按改后生效优先级取档;COALESCE 只补存量 NULL
|
|
@@ -420,6 +421,8 @@ export const taskDispatchMethods = {
|
|
|
420
421
|
priority: input.priority,
|
|
421
422
|
// 透传原始清单(DSHBOTS-168):清洗+审计由 createTask 统一做(审计挂真实 taskId)。
|
|
422
423
|
writeScopes: parsedScopes,
|
|
424
|
+
// 交付物路径声明(DSHBOTS-345 复盘):新卡可带;重派已有任务经改卡分支同步修正。
|
|
425
|
+
deliverables: input.deliverables,
|
|
423
426
|
// 总监派单可带父子/依赖关系(snake_case 透传,createTask 内统一校验与落库)。
|
|
424
427
|
parentTaskId: input.parent_task_id,
|
|
425
428
|
blockedBy: input.blocked_by,
|
package/src/services/tasks.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { badRequest, conflict, notFound } from '../errors.js'
|
|
8
8
|
import { clampNumber, id, nowIso, projectKey, TASK_ID_PATTERN, text } from '../util.js'
|
|
9
|
-
import { parseWriteScopes, parseWriteScopesFromDescription, readWriteScopes } from './write-scopes.js'
|
|
9
|
+
import { parseDeliverables, parseWriteScopes, parseWriteScopesFromDescription, readDeliverables, readWriteScopes } from './write-scopes.js'
|
|
10
10
|
import { ensureAttentionSchema, parseAttention } from './attention-schema.js'
|
|
11
11
|
import { SANDBOX_OVERRIDES } from './file-policy.js'
|
|
12
12
|
import { ensureTaskSandboxSchema } from './task-sandbox-schema.js'
|
|
@@ -156,6 +156,9 @@ export const tasksMethods = {
|
|
|
156
156
|
throw badRequest(`沙箱覆盖无效,允许值:inherit / ${SANDBOX_OVERRIDES.join(' / ')}`)
|
|
157
157
|
}
|
|
158
158
|
const sandboxOverride = !rawSandboxOverride || rawSandboxOverride === 'inherit' ? null : rawSandboxOverride
|
|
159
|
+
// 交付物路径声明(DSHBOTS-345 复盘):卡面声明的交付文件,核验按路径直接读文件;
|
|
160
|
+
// camelCase 与 snake_case 都收,空数组 = 未声明。
|
|
161
|
+
const deliverables = parseDeliverables(input.deliverables ?? input.deliverables_paths ?? undefined)
|
|
159
162
|
const taskId = id('task')
|
|
160
163
|
const createdAt = nowIso()
|
|
161
164
|
// 终态时间在创建时补齐(DSHBOTS-69):以 done/canceled 建档的任务终态列取同一 createdAt,
|
|
@@ -178,8 +181,8 @@ export const tasksMethods = {
|
|
|
178
181
|
this.store.run(
|
|
179
182
|
`INSERT INTO tasks(id, project_id, number, title, description, status, priority, assignee_bot_id,
|
|
180
183
|
creator_type, creator_id, review_target, source_message_id, parent_id, parent_task_id, blocked_by, position, due_at, estimate,
|
|
181
|
-
time_budget_minutes, write_scopes, sandbox_override, version, created_at, updated_at, completed_at, canceled_at)
|
|
182
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?, ?, ?)`,
|
|
184
|
+
time_budget_minutes, write_scopes, deliverables, sandbox_override, version, created_at, updated_at, completed_at, canceled_at)
|
|
185
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?, ?, ?)`,
|
|
183
186
|
taskId, project.id, number, title, text(input.description, 40_000), status, priority,
|
|
184
187
|
assigneeId, actor.type, actor.id, actor.type === 'bot' ? 'owner_bot' : 'user',
|
|
185
188
|
input.sourceMessageId ?? null, input.parentId ?? null,
|
|
@@ -187,6 +190,7 @@ export const tasksMethods = {
|
|
|
187
190
|
Number.isFinite(Number(input.position)) ? Number(input.position) : number,
|
|
188
191
|
input.dueAt ? new Date(input.dueAt).toISOString() : null,
|
|
189
192
|
clampNumber(input.estimate, 0, 1000, null), timeBudgetMinutes, JSON.stringify(writeScopes),
|
|
193
|
+
JSON.stringify(deliverables),
|
|
190
194
|
sandboxOverride, createdAt, createdAt,
|
|
191
195
|
completedAt, canceledAt,
|
|
192
196
|
)
|
|
@@ -246,7 +250,7 @@ export const tasksMethods = {
|
|
|
246
250
|
task.id,
|
|
247
251
|
)
|
|
248
252
|
const project = this.store.get('SELECT key FROM projects WHERE id = ?', task.project_id)
|
|
249
|
-
const { write_scopes: rawScopes, time_budget_minutes: rawTimeBudget, ...rest } = task
|
|
253
|
+
const { write_scopes: rawScopes, deliverables: rawDeliverables, time_budget_minutes: rawTimeBudget, ...rest } = task
|
|
250
254
|
// 阶段按事实推导(task-stage 块):与 latestRun 同源;attention 取最近运行的待回答提问。
|
|
251
255
|
const attention = runs[0] ? parseAttention(runs[0].attention_json) : null
|
|
252
256
|
const stage = taskStage(task, runs[0] ?? null, attention)
|
|
@@ -256,6 +260,7 @@ export const tasksMethods = {
|
|
|
256
260
|
identifier: `${project?.key ?? 'T'}-${task.number}`,
|
|
257
261
|
labels,
|
|
258
262
|
writeScopes: readWriteScopes(rawScopes),
|
|
263
|
+
deliverables: readDeliverables(rawDeliverables),
|
|
259
264
|
// 时效要求(分钟):null=发布方未提;供 UI 展示与提示词注入共用一个口径。
|
|
260
265
|
timeBudgetMinutes: Number.isFinite(rawTimeBudget) ? rawTimeBudget : null,
|
|
261
266
|
attention,
|
|
@@ -350,6 +355,9 @@ export const tasksMethods = {
|
|
|
350
355
|
if (patch.writeScopes !== undefined) {
|
|
351
356
|
updates.write_scopes = JSON.stringify(parseWriteScopes(patch.writeScopes))
|
|
352
357
|
}
|
|
358
|
+
if (patch.deliverables !== undefined) {
|
|
359
|
+
updates.deliverables = JSON.stringify(parseDeliverables(patch.deliverables))
|
|
360
|
+
}
|
|
353
361
|
// 延期阀(DSHBOTS-274):update_task 实改 time_budget_minutes 后整卡死线按新预算重算——
|
|
354
362
|
// 记 budget_updated_at 标记新预算生效;派发基准统一为最新派发(DSHBOTS-281 重派即新窗口),
|
|
355
363
|
// 改预算与重派各自独立生效,改后重派拿到「新预算 × 新窗口」。
|
|
@@ -99,6 +99,44 @@ export function readWriteScopes(raw) {
|
|
|
99
99
|
return scopes
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
// ── 交付产物(deliverables)──────────────────────────────────────────
|
|
103
|
+
// 卡面声明的交付物文件路径(相对项目工作目录,路径归一化与写范围同一条 normalizeScopePath)。
|
|
104
|
+
// 核验方按路径直接读文件,交付报告降级为声明清单——不复述文件正文(DSHBOTS-345 复盘)。
|
|
105
|
+
export const DELIVERABLES_MAX = 20
|
|
106
|
+
|
|
107
|
+
// 解析外部输入(数组或 JSON 字符串):非法条目直接报错,不静默降级。
|
|
108
|
+
// 与写范围不同:不剥 package.json(交付物可以是任何文件),上限 20 条。
|
|
109
|
+
export function parseDeliverables(input) {
|
|
110
|
+
if (input === undefined || input === null) return []
|
|
111
|
+
const list = typeof input === 'string' ? jsonParse(input, null) : input
|
|
112
|
+
if (!Array.isArray(list)) throw badRequest('交付物必须是路径数组')
|
|
113
|
+
if (list.length > DELIVERABLES_MAX) throw badRequest(`交付物最多 ${DELIVERABLES_MAX} 条`)
|
|
114
|
+
const paths = []
|
|
115
|
+
for (const item of list) {
|
|
116
|
+
if (typeof item !== 'string') throw badRequest('交付物必须是路径数组')
|
|
117
|
+
const path = normalizeScopePath(item)
|
|
118
|
+
if (!path) throw badRequest(`交付物包含非法路径:${item}`)
|
|
119
|
+
if (path.length > WRITE_SCOPE_MAX_LEN) throw badRequest(`交付物路径过长(上限 ${WRITE_SCOPE_MAX_LEN} 字符)`)
|
|
120
|
+
if (!paths.includes(path)) paths.push(path)
|
|
121
|
+
}
|
|
122
|
+
return paths
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// 库内快照容错读取:坏数据一律回退空数组(展示与提示词注入不因脏数据炸掉)。
|
|
126
|
+
export function readDeliverables(raw) {
|
|
127
|
+
if (raw === undefined || raw === null || raw === '') return []
|
|
128
|
+
const list = typeof raw === 'string' ? jsonParse(raw, null) : raw
|
|
129
|
+
if (!Array.isArray(list)) return []
|
|
130
|
+
const paths = []
|
|
131
|
+
for (const item of list) {
|
|
132
|
+
if (typeof item !== 'string') return []
|
|
133
|
+
const path = normalizeScopePath(item)
|
|
134
|
+
if (!path || path.length > WRITE_SCOPE_MAX_LEN) return []
|
|
135
|
+
if (!paths.includes(path)) paths.push(path)
|
|
136
|
+
}
|
|
137
|
+
return paths
|
|
138
|
+
}
|
|
139
|
+
|
|
102
140
|
// 两条写范围路径是否指向同一片区域:相等,或一方是另一方的目录前缀(按路径分段比较)。
|
|
103
141
|
export function writeScopePathsOverlap(left, right) {
|
|
104
142
|
if (left === right) return true
|
package/src/tools.js
CHANGED
|
@@ -84,9 +84,10 @@ export function installTeamTools(ctx, service) {
|
|
|
84
84
|
properties: {
|
|
85
85
|
assignee: { type: 'string', description: 'Exact bot name from the project member list' },
|
|
86
86
|
title: { type: 'string', description: 'Short actionable task title (new tasks; on re-dispatch it amends the card)' },
|
|
87
|
-
description: { type: 'string', description: 'Self-contained instructions, constraints and acceptance criteria (new tasks; on re-dispatch it amends the card and the assignee is notified to correct course)' },
|
|
87
|
+
description: { type: 'string', description: 'Self-contained instructions, constraints and acceptance criteria (new tasks; on re-dispatch it amends the card and the assignee is notified to correct course). Name the expected deliverable file paths inside the write scopes, and never instruct the bot to paste file contents into its delivery report — the report references paths, reviewers read the files' },
|
|
88
88
|
priority: { type: 'string', enum: ['urgent', 'high', 'medium', 'low', 'none'], description: 'Task priority (new tasks and card amendment on re-dispatch)' },
|
|
89
89
|
write_scopes: { type: 'array', items: { type: 'string' }, description: 'Workspace-relative paths this task will modify (new tasks only); the scheduler runs tasks with disjoint scopes in parallel. Omit to parse a `写范围:`/`write_scopes:` line from the description instead' },
|
|
90
|
+
deliverables: { type: 'array', items: { type: 'string' }, description: 'Expected deliverable file paths, workspace-relative and inside the write scopes (new tasks; on re-dispatch it amends the card). The assignee references these paths in its delivery report instead of pasting file contents; reviewers read the files at these paths' },
|
|
90
91
|
force_duplicate: { type: 'boolean', description: 'Escape hatch (new tasks only): skip the same-write-scope duplicate check when an unfinished task in this project already declares identical write scopes. Use only when a second task on the same paths is intentional; every use is audited as dispatch_force_duplicate' },
|
|
91
92
|
time_budget_minutes: { type: 'integer', description: 'Required delivery time limit in minutes (new tasks only, 1-10080): injected into the task prompt, and the run is aborted when the budget expires. The effective timeout is the smaller of this budget and the global run timeout. Omit to take the priority-tier budget (urgent/high 45, medium 30, low/none 15 minutes); non-dispatch task creation falls back to env DSH_TEAM_TASK_TIME_BUDGET_MINUTES > stall-watchdog minutes > 20 minutes' },
|
|
92
93
|
parent_task_id: { type: 'string', description: 'Nest the new task as a subtask under this main task id (new tasks only): pass it when the main item cannot be finished in this run or a new closing condition emerged, so follow-up work lands as a product-grade card instead of a verbal note; also pass it to split a large task into parallel subtask cards for speed (independent parts, disjoint write_scopes, so the cards run concurrently). Must reference an existing task in the same project; self-reference is rejected. The backend validates' },
|
package/ui/app.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { state, STATUS, STATUS_ORDER, PRIORITY, PROPOSAL_STATUS, COLORS, COLOR_NAMES, BOT_STATUS, RUN_STATUS, RUN_KIND, CHAT_PAGE_SIZE, CHAT_ACTIVE_TASK_LIMIT, SKILL_STATUS, MEMORY_STATUS, PROPOSAL_KIND, TERMINAL_STATUS, CREATOR_TYPE, EFFORT, FILE_POLICY, DEFAULT_FILE_POLICY, VIEW_ACTION, NAV, SOLO_NAV } from './modules/state.js'
|
|
2
2
|
import { icon } from './modules/icons.js'
|
|
3
|
-
import { applyUiScale, applyUiTheme, esc, attr, pathCode, costValue, clamp, botById, shortRefId, actorLabel, taskById, activeProject, inSoloContext, pageProject, activeBots, formatNumber, CURRENCY_SYMBOL, formatCost, timeAgo, formatTime, duration, avatar, statusPill, runDot, memberRunDot, runDotHtml, memorySource, toast, filePolicyOptions } from './modules/util.js'
|
|
3
|
+
import { applyUiScale, applyUiTheme, initColorScheme, esc, attr, pathCode, costValue, clamp, botById, shortRefId, actorLabel, taskById, activeProject, inSoloContext, pageProject, activeBots, formatNumber, CURRENCY_SYMBOL, formatCost, timeAgo, formatTime, duration, avatar, statusPill, runDot, memberRunDot, runDotHtml, memorySource, toast, filePolicyOptions } from './modules/util.js'
|
|
4
4
|
import { richText, mdPlainSummary, mdChatScope } from './modules/markdown.js'
|
|
5
5
|
import { api, loadState, markVisibleChatRead } from './modules/api.js'
|
|
6
6
|
import { t, setLanguage } from './modules/i18n.js'
|
|
@@ -35,6 +35,7 @@ const savedScale = (() => {
|
|
|
35
35
|
try { return Number(localStorage.getItem(UI_SCALE_KEY)) || null } catch { return null }
|
|
36
36
|
})()
|
|
37
37
|
if (savedScale) applyUiScale(savedScale)
|
|
38
|
+
initColorScheme()
|
|
38
39
|
state.theme = applyUiTheme((() => {
|
|
39
40
|
try { return localStorage.getItem(UI_THEME_KEY) } catch { return null }
|
|
40
41
|
})())
|
package/ui/i18n/en/tasks.js
CHANGED
|
@@ -229,4 +229,12 @@ export default {
|
|
|
229
229
|
// DSHBOTS-246: keys added by the full t() literal audit
|
|
230
230
|
"(待办不含已取消)": " (todo excludes canceled)",
|
|
231
231
|
",按": "; ",
|
|
232
|
+
// DSHBOTS-345: deliverables declaration on the task card
|
|
233
|
+
"交付产物": "Deliverables",
|
|
234
|
+
"核验按路径直接读文件;交付报告只引用路径,不复述正文。": "Verification reads the files at these paths; the delivery report references paths only, never file contents.",
|
|
235
|
+
// DSHBOTS-347: in-app preview for text-like files
|
|
236
|
+
"文件预览": "File preview",
|
|
237
|
+
"文件较大,已截断,仅显示开头部分。": "Large file; showing a truncated head only.",
|
|
238
|
+
"新窗口打开": "Open in new window",
|
|
239
|
+
"加载文件失败:": "Failed to load file: ",
|
|
232
240
|
}
|
package/ui/i18n/zh/tasks.js
CHANGED
|
@@ -229,4 +229,12 @@ export default {
|
|
|
229
229
|
// DSHBOTS-246:全量 t() 实参清点补齐(原文即键)
|
|
230
230
|
"(待办不含已取消)": "(待办不含已取消)",
|
|
231
231
|
",按": ",按",
|
|
232
|
+
// DSHBOTS-345:任务卡交付物路径声明
|
|
233
|
+
"交付产物": "交付产物",
|
|
234
|
+
"核验按路径直接读文件;交付报告只引用路径,不复述正文。": "核验按路径直接读文件;交付报告只引用路径,不复述正文。",
|
|
235
|
+
// DSHBOTS-347:文本型文件应用内预览
|
|
236
|
+
"文件预览": "文件预览",
|
|
237
|
+
"文件较大,已截断,仅显示开头部分。": "文件较大,已截断,仅显示开头部分。",
|
|
238
|
+
"新窗口打开": "新窗口打开",
|
|
239
|
+
"加载文件失败:": "加载文件失败:",
|
|
232
240
|
}
|
|
@@ -9,6 +9,7 @@ import { exportUsageCsv, switchUsageWindow, usageMode } from './usage.js'
|
|
|
9
9
|
import { focusApprovalCard, focusQuestionCard, questionDraftSelection, questionSelectOption } from './cards.js'
|
|
10
10
|
import { loadSoloDetail } from './chat.js'
|
|
11
11
|
import { searchMemories } from './tasks.js'
|
|
12
|
+
import { openFilePreview } from './file-preview.js'
|
|
12
13
|
import { handleBoardAction } from './events-board.js'
|
|
13
14
|
import { refresh, renderKeepingChatScroll, render, beginChatPending, endChatPending } from '../app.js'
|
|
14
15
|
|
|
@@ -507,6 +508,10 @@ document.addEventListener('click', async (event) => {
|
|
|
507
508
|
window.open(target.dataset.url, '_blank', 'noopener')
|
|
508
509
|
break
|
|
509
510
|
}
|
|
511
|
+
case 'preview-file': {
|
|
512
|
+
await openFilePreview(target.dataset.url, target.dataset.path)
|
|
513
|
+
break
|
|
514
|
+
}
|
|
510
515
|
case 'delete-secret': {
|
|
511
516
|
const name = target.dataset.secretName || t("该密钥")
|
|
512
517
|
// DSHBOTS-106 起明文只在批准时一次性物化到数据目录,项目工作区不再有明文密钥文件;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { state } from './state.js'
|
|
2
|
+
import { attr, esc } from './util.js'
|
|
3
|
+
import { t } from './i18n.js'
|
|
4
|
+
import { modalShell, renderModalLayer } from './modal-layer.js'
|
|
5
|
+
|
|
6
|
+
// file-preview-logic:start —— 文本预览纯逻辑(tests/file-preview.test.js 抽取此块断言)。
|
|
7
|
+
// 白名单与后端 chatFile 的文本扩展同口径;SVG 可执行脚本、.env 常带密钥,永不入列。
|
|
8
|
+
const FILE_TEXT_EXT = /\.(md|markdown|txt|log|json|csv|ini|toml|yaml|yml|ts|tsx|js|mjs|cjs|jsx|css|html|htm|sh|xml|py|sql)$/i
|
|
9
|
+
const PREVIEW_MAX_CHARS = 256 * 1024
|
|
10
|
+
const PREVIEW_MAX_LINES = 2000
|
|
11
|
+
function isPreviewableText(path) {
|
|
12
|
+
return FILE_TEXT_EXT.test(String(path ?? ''))
|
|
13
|
+
}
|
|
14
|
+
// 超限截断:256KB 与 2000 行先到先裁;弹层只提示,不改写内容本身。
|
|
15
|
+
function clipPreviewText(text) {
|
|
16
|
+
const source = String(text ?? '')
|
|
17
|
+
let body = source.length > PREVIEW_MAX_CHARS ? source.slice(0, PREVIEW_MAX_CHARS) : source
|
|
18
|
+
const lines = body.split('\n')
|
|
19
|
+
if (lines.length > PREVIEW_MAX_LINES) body = lines.slice(0, PREVIEW_MAX_LINES).join('\n')
|
|
20
|
+
return { body, truncated: body.length < source.length }
|
|
21
|
+
}
|
|
22
|
+
// 交付产物 chip → /api/dsh-team/file(拼法与 markdown.ts mdImageFileUrl 同口径);
|
|
23
|
+
// 绝对路径或含 .. 段不生成链接,越界交给服务端防穿越兜底。
|
|
24
|
+
function deliverableFileUrl(projectId, path) {
|
|
25
|
+
const rel = String(path ?? '')
|
|
26
|
+
if (!projectId || !rel || rel.startsWith('/') || rel.split('/').includes('..')) return null
|
|
27
|
+
const params = new URLSearchParams()
|
|
28
|
+
params.set('projectId', String(projectId))
|
|
29
|
+
params.set('path', rel)
|
|
30
|
+
return `/api/dsh-team/file?${params.toString()}`
|
|
31
|
+
}
|
|
32
|
+
// file-preview-logic:end
|
|
33
|
+
|
|
34
|
+
// 交付产物文件链接基建:图片走原 artifact-file 内联缩略,文本扩展改应用内预览。
|
|
35
|
+
const ARTIFACT_IMAGE = /\.(png|jpe?g|gif|webp)$/i
|
|
36
|
+
const artifactFileUrl = (runId, path) =>
|
|
37
|
+
`/api/dsh-team/artifact-file?runId=${encodeURIComponent(runId)}&path=${encodeURIComponent(path)}`
|
|
38
|
+
const artifactExt = (path) =>
|
|
39
|
+
(String(path).match(/\.([a-z0-9]+)$/i)?.[1] ?? 'file').toUpperCase().slice(0, 6)
|
|
40
|
+
|
|
41
|
+
// 文本预览弹层:正文绝不进 HTML 模板,hydrateFilePreview 只走 textContent 通道;
|
|
42
|
+
// footer 保留「新窗口打开」(复用 open-artifact 的开窗行为)。
|
|
43
|
+
function modalFilePreview(modal) {
|
|
44
|
+
const path = String(modal?.path ?? '')
|
|
45
|
+
if (modal?.error) {
|
|
46
|
+
return modalShell({
|
|
47
|
+
title: path || t("文件预览"),
|
|
48
|
+
body: `<div class="note">${t("加载文件失败:")}${esc(modal.error)}</div>`,
|
|
49
|
+
footer: `<button class="btn" data-action="close-modal">${t("关闭")}</button>`,
|
|
50
|
+
size: 'wide',
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
return modalShell({
|
|
54
|
+
title: path || t("文件预览"),
|
|
55
|
+
subtitle: modal?.truncated ? t("文件较大,已截断,仅显示开头部分。") : '',
|
|
56
|
+
body: `<pre class="detail-pre" id="dsh-file-preview-pre"></pre>`,
|
|
57
|
+
footer: `<button class="btn" data-action="close-modal">${t("关闭")}</button><button class="btn" data-action="open-artifact" data-url="${attr(modal?.url ?? '')}">${t("新窗口打开")}</button>`,
|
|
58
|
+
size: 'wide',
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 正文水合:把已取回的文本写进占位 pre。滚动守卫可能把补拍延后约 120ms,
|
|
63
|
+
// 首拍未命中节点时短重试,避免补拍后弹层空白。
|
|
64
|
+
function hydrateFilePreview(retry = 3) {
|
|
65
|
+
const pre = document.getElementById('dsh-file-preview-pre')
|
|
66
|
+
if (!pre) {
|
|
67
|
+
if (retry > 0) setTimeout(() => hydrateFilePreview(retry - 1), 150)
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
if (state.modal?.type === 'file-preview') pre.textContent = state.modal.content ?? ''
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function openFilePreview(url, path) {
|
|
74
|
+
if (!url) return
|
|
75
|
+
state.modal = { type: 'file-preview', loading: true, title: String(path ?? '').split('/').pop() || t("文件预览"), url, path }
|
|
76
|
+
renderModalLayer()
|
|
77
|
+
try {
|
|
78
|
+
const res = await fetch(url)
|
|
79
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`)
|
|
80
|
+
const { body, truncated } = clipPreviewText(await res.text())
|
|
81
|
+
state.modal = { type: 'file-preview', url, path, content: body, truncated }
|
|
82
|
+
} catch (error ) {
|
|
83
|
+
state.modal = { type: 'file-preview', url, path, error: String(error?.message ?? error) }
|
|
84
|
+
}
|
|
85
|
+
renderModalLayer()
|
|
86
|
+
hydrateFilePreview()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export { FILE_TEXT_EXT, isPreviewableText, clipPreviewText, deliverableFileUrl, ARTIFACT_IMAGE, artifactFileUrl, artifactExt, modalFilePreview, hydrateFilePreview, openFilePreview }
|
|
@@ -4,11 +4,12 @@ import { activeBots, activeProject, attr, avatar, botById, duration, esc, filePo
|
|
|
4
4
|
import { api } from './api.js'
|
|
5
5
|
import { mdChatScope, richText } from './markdown.js'
|
|
6
6
|
import { t, tMaybe } from './i18n.js'
|
|
7
|
-
import { currentSkillVersion, skillVersions, taskUsageBlock } from './tasks.js'
|
|
7
|
+
import { currentSkillVersion, skillVersions, taskDeliverablesBlock, taskUsageBlock } from './tasks.js'
|
|
8
8
|
import { ensureComposerImageInput, ensureImageViewer } from './composer.js'
|
|
9
9
|
import { app, refresh, panelAttrs, render, updateRunClocks } from '../app.js'
|
|
10
10
|
import { modalShell, modalLoading, renderModalLayer } from './modal-layer.js'
|
|
11
11
|
import { botQuotaBlock } from './bot-quota.js'
|
|
12
|
+
import { ARTIFACT_IMAGE, FILE_TEXT_EXT, artifactFileUrl, artifactExt } from './file-preview.js'
|
|
12
13
|
|
|
13
14
|
function modelOptions(provider, model) {
|
|
14
15
|
const models = state.data?.models ?? []
|
|
@@ -320,11 +321,8 @@ function modalSkill(detail) {
|
|
|
320
321
|
})
|
|
321
322
|
}
|
|
322
323
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
`/api/dsh-team/artifact-file?runId=${encodeURIComponent(runId)}&path=${encodeURIComponent(path)}`
|
|
326
|
-
|
|
327
|
-
// 已完成写运行的交付产物:默认收起(与「查看输出」同一折叠口径),展开后图片内联预览(点击新窗口打开),其余文件列出路径与扩展名徽标。
|
|
324
|
+
// 已完成写运行的交付产物:默认收起(与「查看输出」同一折叠口径),展开后图片内联预览,
|
|
325
|
+
// 文本型文件应用内预览(DSHBOTS-347),其余文件列路径与扩展名徽标、新窗口打开。
|
|
328
326
|
function runArtifacts(state, run) {
|
|
329
327
|
const list = Array.isArray(run.artifacts) ? run.artifacts : []
|
|
330
328
|
if (run.status !== 'succeeded' || list.length === 0) return ''
|
|
@@ -335,9 +333,10 @@ function runArtifacts(state, run) {
|
|
|
335
333
|
const url = artifactFileUrl(run.id, path)
|
|
336
334
|
if (ARTIFACT_IMAGE.test(path)) {
|
|
337
335
|
rows.push(`<button type="button" class="artifact-thumb" data-action="open-artifact" data-url="${attr(url)}" title="${attr(path)}"><img src="${attr(url)}" alt="${attr(path)}" loading="lazy"></button>`)
|
|
336
|
+
} else if (FILE_TEXT_EXT.test(path)) {
|
|
337
|
+
rows.push(`<button type="button" class="artifact-file" data-action="preview-file" data-url="${attr(url)}" data-path="${attr(path)}" title="${attr(path)}"><span class="artifact-path">${esc(path)}</span><span class="artifact-ext mono">${esc(artifactExt(path))}</span></button>`)
|
|
338
338
|
} else {
|
|
339
|
-
|
|
340
|
-
rows.push(`<a class="artifact-file" href="${attr(url)}" target="_blank" rel="noopener"><span class="artifact-path">${esc(path)}</span><span class="artifact-ext mono">${esc(ext)}</span></a>`)
|
|
339
|
+
rows.push(`<a class="artifact-file" href="${attr(url)}" target="_blank" rel="noopener"><span class="artifact-path">${esc(path)}</span><span class="artifact-ext mono">${esc(artifactExt(path))}</span></a>`)
|
|
341
340
|
}
|
|
342
341
|
}
|
|
343
342
|
if (!rows.length) return ''
|
|
@@ -460,7 +459,7 @@ function modalTask(task) {
|
|
|
460
459
|
${editingScopes ? scopesEdit : `${scopesEditable ? `<div class="btn-row" style="margin-bottom:6px"><button class="btn small" type="button" data-action="edit-scopes" data-task-id="${attr(task.id)}">${icon('edit')}${t("编辑")}</button></div>` : ''}${scopesView}
|
|
461
460
|
<div class="hint" style="margin-top:6px">${t("写范围是并行调度依据:同项目内路径互不重叠的任务才会并行。")}</div>`}
|
|
462
461
|
</div>
|
|
463
|
-
${task.timeBudgetMinutes ? `<div class="scope-block">
|
|
462
|
+
${taskDeliverablesBlock(task)}${task.timeBudgetMinutes ? `<div class="scope-block">
|
|
464
463
|
<div class="eyebrow" style="margin-bottom:6px">${t('taskForm.timeBudgetLabel')}</div>
|
|
465
464
|
<div class="note" style="color:var(--ink)">${t('task.timeBudgetValue', { minutes: Number(task.timeBudgetMinutes) })}</div>
|
|
466
465
|
<div class="hint" style="margin-top:6px">${t('task.timeBudgetNote')}</div>
|
|
@@ -2,6 +2,7 @@ import { state } from './state.js'
|
|
|
2
2
|
import { attr, esc } from './util.js'
|
|
3
3
|
import { render, updateRunClocks } from '../app.js'
|
|
4
4
|
import { modalNewProject, modalRemoveTracking, modalRemoveBotTracking, modalBot, modalInviteMember, modalNewTask, modalTask, modalSkill, modalMemory, modalProposal, modalPrice, modalTrajectory } from './modal-forms.js'
|
|
5
|
+
import { modalFilePreview } from './file-preview.js'
|
|
5
6
|
import { t } from './i18n.js'
|
|
6
7
|
|
|
7
8
|
function modalShell({ title, subtitle = '', body = '', footer = '', size = '', badge = '' }) {
|
|
@@ -44,6 +45,7 @@ function renderModal() {
|
|
|
44
45
|
case 'proposal': return modalProposal(modal.kind)
|
|
45
46
|
case 'price': return modalPrice(modal.price ?? {})
|
|
46
47
|
case 'trajectory': return modalTrajectory(modal.detail, modal.runId)
|
|
48
|
+
case 'file-preview': return modalFilePreview(modal)
|
|
47
49
|
default: return ''
|
|
48
50
|
}
|
|
49
51
|
}
|
package/ui/modules/tasks.js
CHANGED
|
@@ -3,6 +3,7 @@ import { icon } from './icons.js'
|
|
|
3
3
|
import { activeProject, actorLabel, attr, avatar, botById, canaryText, duration, esc, evaluationText, formatCost, formatNumber, formatTime, inSoloContext, memberRunDot, memorySource, pageProject, proposalPreview, runDot, tildePath, timeAgo } from './util.js'
|
|
4
4
|
import { api } from './api.js'
|
|
5
5
|
import { t } from './i18n.js'
|
|
6
|
+
import { isPreviewableText, deliverableFileUrl } from './file-preview.js'
|
|
6
7
|
import { refresh, startTerminalPoll, panelAttrs, render, noProject } from '../app.js'
|
|
7
8
|
|
|
8
9
|
// task-sort:start —— 任务面板排序的纯逻辑(tests/task-sort.test.js 按本标记块抽取断言)。
|
|
@@ -774,4 +775,23 @@ export function taskUsageBlock(usage) {
|
|
|
774
775
|
<div class="divider"></div>`
|
|
775
776
|
}
|
|
776
777
|
|
|
778
|
+
// 交付产物块(DSHBOTS-345 复盘):卡面声明的交付文件路径,核验按路径直接读文件;未声明不渲染。
|
|
779
|
+
// 文本型 chip 可点开应用内预览(DSHBOTS-347),其余保持纯文字。
|
|
780
|
+
export function taskDeliverablesBlock(task) {
|
|
781
|
+
const deliverables = Array.isArray(task?.deliverables) ? task.deliverables.filter(item => typeof item === 'string' && item) : []
|
|
782
|
+
if (!deliverables.length) return ''
|
|
783
|
+
const projectId = String(task?.project_id ?? pageProject()?.id ?? '')
|
|
784
|
+
const chip = (path) => {
|
|
785
|
+
const url = isPreviewableText(path) ? deliverableFileUrl(projectId, path) : null
|
|
786
|
+
return url
|
|
787
|
+
? `<button type="button" class="approval-chip mono" data-action="preview-file" data-url="${attr(url)}" data-path="${attr(path)}" title="${attr(path)}">${esc(path)}</button>`
|
|
788
|
+
: `<span class="approval-chip mono" title="${attr(path)}">${esc(path)}</span>`
|
|
789
|
+
}
|
|
790
|
+
return `<div class="scope-block">
|
|
791
|
+
<div class="eyebrow" style="margin-bottom:6px">${t("交付产物")}</div>
|
|
792
|
+
<div class="scope-chips">${deliverables.map(chip).join('')}</div>
|
|
793
|
+
<div class="hint" style="margin-top:6px">${t("核验按路径直接读文件;交付报告只引用路径,不复述正文。")}</div>
|
|
794
|
+
</div>`
|
|
795
|
+
}
|
|
796
|
+
|
|
777
797
|
export { renderTasks, taskGroupKey, taskChildrenKey, terminalOutputText, renderTerminal, renderBotsOverview, renderMembers, renderSkills, searchMemories, renderMemory, currentSkillVersion, skillVersions, renderEvolution }
|
package/ui/modules/util.js
CHANGED
|
@@ -13,6 +13,45 @@ export function applyUiTheme(value) {
|
|
|
13
13
|
else document.documentElement.setAttribute('data-theme', theme)
|
|
14
14
|
return theme
|
|
15
15
|
}
|
|
16
|
+
|
|
17
|
+
// color-scheme:start —— 深/浅色判定唯一出口(DSHBOTS-349/351)。
|
|
18
|
+
// 宿主深色不走媒体查询(WebView 的 prefers-color-scheme 失真恒报 light),而是给
|
|
19
|
+
// 同源祖先文档 body 打 data-ds-dark-theme:嵌入态自直接父逐层上溯到 window.top,
|
|
20
|
+
// 任一祖先带属性才判 dark;祖先链全程无属性、跨源访问异常与独立态一律回落系统
|
|
21
|
+
// 媒体查询——单一层级信号失真不再绝对压过系统偏好。
|
|
22
|
+
export function resolveColorScheme() {
|
|
23
|
+
try {
|
|
24
|
+
for (let current = window.parent; current && current !== window; current = current.parent) {
|
|
25
|
+
if (current.document.body.hasAttribute('data-ds-dark-theme')) return 'dark'
|
|
26
|
+
if (current === window.top) break
|
|
27
|
+
}
|
|
28
|
+
} catch { /* 跨源祖先不可读:回落系统媒体查询 */ }
|
|
29
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function applyColorScheme() {
|
|
33
|
+
const scheme = resolveColorScheme()
|
|
34
|
+
document.documentElement.setAttribute('data-color-scheme', scheme)
|
|
35
|
+
document.documentElement.style.colorScheme = scheme
|
|
36
|
+
return scheme
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 宿主切换深浅时实时跟随:观察祖先链各层 body 的主题属性变化 + 自身媒体查询变化。
|
|
40
|
+
export function initColorScheme() {
|
|
41
|
+
applyColorScheme()
|
|
42
|
+
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', applyColorScheme)
|
|
43
|
+
try {
|
|
44
|
+
const observer = new MutationObserver(applyColorScheme)
|
|
45
|
+
for (let current = window.parent; current && current !== window; current = current.parent) {
|
|
46
|
+
observer.observe(current.document.body, {
|
|
47
|
+
attributes: true,
|
|
48
|
+
attributeFilter: ['data-ds-dark-theme'],
|
|
49
|
+
})
|
|
50
|
+
if (current === window.top) break
|
|
51
|
+
}
|
|
52
|
+
} catch { /* 跨源宿主:仅跟媒体查询 */ }
|
|
53
|
+
}
|
|
54
|
+
// color-scheme:end
|
|
16
55
|
export const esc = (value) => String(value ?? '')
|
|
17
56
|
.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>')
|
|
18
57
|
.replaceAll('"', '"').replaceAll("'", ''')
|
package/ui/styles/base.css
CHANGED
|
@@ -108,15 +108,18 @@
|
|
|
108
108
|
/* legacy aliases used by inline styles in app.js */
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
111
|
+
/* 深色由 :root[data-color-scheme="dark"] 承载(DSHBOTS-349):宿主深色不走媒体查询
|
|
112
|
+
(其 WebView 的 prefers-color-scheme 失真恒报 light),而是给同源父文档 body 打
|
|
113
|
+
data-ds-dark-theme——util.ts resolveColorScheme() 据此同步本属性,嵌入态实时
|
|
114
|
+
跟随宿主深浅,独立态与跨源异常回落系统媒体查询。 */
|
|
115
|
+
:root[data-color-scheme="dark"] .card,
|
|
116
|
+
:root[data-color-scheme="dark"] .side-card {
|
|
117
|
+
box-shadow:
|
|
118
|
+
var(--shadow-1),
|
|
119
|
+
inset 0 1px 0 rgba(255, 255, 255, 0.05);
|
|
120
|
+
}
|
|
121
|
+
:root[data-color-scheme="dark"] {
|
|
122
|
+
color-scheme: dark;
|
|
120
123
|
--bg: #101219;
|
|
121
124
|
--surface: #191b26;
|
|
122
125
|
--surface-2: #21242f;
|
|
@@ -158,7 +161,6 @@
|
|
|
158
161
|
0 2px 12px -2px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.3);
|
|
159
162
|
--shadow-3:
|
|
160
163
|
0 28px 64px -12px rgba(0, 0, 0, 0.62), 0 2px 10px rgba(0, 0, 0, 0.4);
|
|
161
|
-
}
|
|
162
164
|
}
|
|
163
165
|
|
|
164
166
|
/* Palette option: Catppuccin (Latte in light mode, Macchiato in dark mode).
|
|
@@ -205,8 +207,7 @@
|
|
|
205
207
|
0 2px 8px rgba(76, 79, 105, 0.07);
|
|
206
208
|
}
|
|
207
209
|
|
|
208
|
-
|
|
209
|
-
:root[data-theme="catppuccin"] {
|
|
210
|
+
:root[data-color-scheme="dark"][data-theme="catppuccin"] {
|
|
210
211
|
--bg: #181926;
|
|
211
212
|
--surface: #24273a;
|
|
212
213
|
--surface-2: #363a4f;
|
|
@@ -246,7 +247,6 @@
|
|
|
246
247
|
0 2px 12px -2px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.3);
|
|
247
248
|
--shadow-3:
|
|
248
249
|
0 28px 64px -12px rgba(0, 0, 0, 0.62), 0 2px 10px rgba(0, 0, 0, 0.4);
|
|
249
|
-
}
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
* {
|