mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-24 03:21:59 +00:00
普通用户建应用(前端):新建应用的三个起点(说需求、场景模板、从已有的开始);蓝图页(对话加卡片、反问选项、关节逐组进度、试运行、发布摘要按你来定 / 助手可以修 / 要找管理员分栏、逐步打勾、接着做);问数据「做成应用」改走蓝图;问数据和画布的反问收尾;页面上直接改(选中、改字、隐藏、挪动、删除、加数据卡片、自动存草稿);文件控件;我的记录列表;个人应用的界面(我的应用、刷新与剩余次数、提交审核、审核待办卡);设置页的个人应用开关;四个新检查脚本并加进完整关口
This commit is contained in:
@@ -14,7 +14,7 @@ import { splitShrunk } from '../canvas/copilotMerge'
|
||||
import { confirmDialog, IconButton, StatusBadge, toast } from '../components/ui'
|
||||
import { formatCost, formatLapse, formatOffset, formatSpan, formatTokens, shortId, NONE } from '../lib/format'
|
||||
import { statusLabel } from '../lib/status'
|
||||
import { runClassLabel, SQL_CHECK_TEXT } from '../lib/terms'
|
||||
import { CHAT_BLUEPRINT_TEXT, runClassLabel, SQL_CHECK_TEXT } from '../lib/terms'
|
||||
import { sortSqlChecks } from '../lib/sqlcheck'
|
||||
import type { RunUsage, ToolChange } from '../types'
|
||||
import { AssistantStream, type StreamTurn } from './AssistantStream'
|
||||
@@ -164,6 +164,10 @@ function copilotTurn(
|
||||
statusCode = 'cancelled'
|
||||
} else if (t.phase === 'error' || errorOp) {
|
||||
status = '本轮未能完成'
|
||||
} else if (out.kind !== 'built' && t.ops.some((o) => o.op === 'ask')) {
|
||||
// 助手问回来一句、画布没动(N11):这一轮在等你回答,不是「未修改画布」那种没下文
|
||||
status = CHAT_BLUEPRINT_TEXT.asked
|
||||
statusCode = 'waiting'
|
||||
} else if (reply && out.kind !== 'built') {
|
||||
status = '已回答(未修改画布)'
|
||||
} else if (out.kind === 'built') {
|
||||
|
||||
+101
-14
@@ -7,7 +7,9 @@
|
||||
* - 时限与升级:剩多久、超了多久、升级过几次;超时只会提醒、升级或驳回,不会自动批准;
|
||||
* - 动作确认的哈希卡:遮罩后的预览、内容哈希前 8 位、环境;确认时原样带回哈希,服务端发送前重算,对不上不发(P8);
|
||||
* - 核实待办:已生效(填外部单号)/ 未生效重新发送 / 未生效放弃,结果未知永远不会自动重发;
|
||||
* - 等外部系统(signal):说明由入站钩子完成,不在这里处理。
|
||||
* - 等外部系统(signal):说明由入站钩子完成,不在这里处理;
|
||||
* - 审核个人应用(review,docs/design/normal-user-apps.md N7):同意不在这里点,处理人取一份共享副本、在副本上试运行和
|
||||
* 走发布单(发布单做完这条待办自动记为已发布);不发布就退回。
|
||||
*
|
||||
* 不碰画布的 store:恢复之后谁去重新接事件流、刷新哪张列表,由调用方在 onResolved 里决定。会签时一个人的回复记下了、
|
||||
* 还没凑齐(resolved 为假),照样回调——调用方据此刷新卡片。
|
||||
@@ -17,10 +19,10 @@
|
||||
*/
|
||||
import { useMemo, useState } from 'react'
|
||||
import type { ReactNode } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { Link, useNavigate } from 'react-router-dom'
|
||||
import {
|
||||
Ban, Check, CheckCheck, Clock, Code, ExternalLink, Hand, Keyboard, PenLine, Send, SearchCheck, TriangleAlert,
|
||||
Webhook, Wrench,
|
||||
Ban, Check, CheckCheck, Clock, Code, Copy, ExternalLink, Hand, Keyboard, PenLine, Send, SearchCheck, TriangleAlert,
|
||||
UserCheck, Webhook, Wrench,
|
||||
} from 'lucide-react'
|
||||
import clsx from 'clsx'
|
||||
import { ApiError, api } from '../api/client'
|
||||
@@ -33,8 +35,10 @@ import { formatDateTime, formatSpan, formatTime, parseServerTime } from '../lib/
|
||||
import { cleanValues, formErrorsOf, validateForm, withDefaults } from '../lib/schemaForm'
|
||||
import {
|
||||
ACTION_CONFIRM_TEXT, ACTION_ENV_LABEL, INQUIRY_TEXT, RECONCILE_TEXT, SIGNAL_TEXT, TASK_KIND_LABEL, TASK_STATUS_LABEL,
|
||||
TASK_TEXT, TOOL_TRUST_TEXT, runName,
|
||||
TASK_TEXT, TOOL_TRUST_TEXT, TRIAL_TEXT, runName,
|
||||
} from '../lib/terms'
|
||||
import { REVIEW_TASK_TEXT } from '../lib/termsApp'
|
||||
import { blueprintPath } from '../pages/blueprints/shared'
|
||||
import type { Approval, ApprovalReport } from '../types'
|
||||
import type {
|
||||
FormError, Task, TaskAssignment, TaskKind, TaskMyResponse, TaskProgress, TaskRespond,
|
||||
@@ -60,20 +64,28 @@ export interface TaskCardProps {
|
||||
showOwner?: boolean
|
||||
/** 画不画会签进度。应用页上同一页另有会签组件时服务端说不画(signoffs_on_page),同一页上不写两遍 */
|
||||
showSignoffs?: boolean
|
||||
/**
|
||||
* 试运行里的待办(docs/design/normal-user-apps.md N4):派给了试运行的人自己,按钮写「以试运行身份同意 / 驳回 / 提交」,
|
||||
* 别让人以为这是在批一张真单子
|
||||
*/
|
||||
trial?: boolean
|
||||
}
|
||||
|
||||
const KIND_ICON: Record<TaskKind, typeof Hand> = {
|
||||
/** 待办的种类,多一种 review(个人应用提交审核):typesApp 的 TaskKind 还没有它(契约待补),先在这里按多一种认 */
|
||||
type CardKind = TaskKind | 'review'
|
||||
|
||||
const KIND_ICON: Record<CardKind, typeof Hand> = {
|
||||
approve: Hand, input: Keyboard, edit: PenLine, tool: Wrench, code: Code, dual_check: Hand,
|
||||
action_confirm: Send, reconcile: SearchCheck, signal: Webhook,
|
||||
action_confirm: Send, reconcile: SearchCheck, signal: Webhook, review: UserCheck,
|
||||
}
|
||||
|
||||
/** 一天没人处理就用琥珀色写等了多久,同审批卡 */
|
||||
const STALE_MS = 24 * 3_600_000
|
||||
|
||||
export function TaskCard({ task, onResolved, compact = false, send, showOwner = true, showSignoffs = true }: TaskCardProps) {
|
||||
export function TaskCard({ task, onResolved, compact = false, send, showOwner = true, showSignoffs = true, trial = false }: TaskCardProps) {
|
||||
const toast = useToast()
|
||||
const payload: Record<string, any> = task.payload ?? {}
|
||||
const kind = task.kind
|
||||
const kind = task.kind as CardKind
|
||||
const pending = task.status === 'pending'
|
||||
const canAct = pending && task.can_respond
|
||||
const inquiring = useInquiryBusy(task.run_id)
|
||||
@@ -203,11 +215,15 @@ export function TaskCard({ task, onResolved, compact = false, send, showOwner =
|
||||
onSubmit={(body) => void respond(body, RECONCILE_TEXT.done)} />
|
||||
)}
|
||||
{kind === 'signal' && <SignalNote payload={payload} />}
|
||||
{kind === 'review' && (
|
||||
<Review task={task} canAct={canAct} busy={busy} note={note} setNote={setNote}
|
||||
onReject={() => void respond({ decision: 'reject' }, REVIEW_TASK_TEXT.rejected)} />
|
||||
)}
|
||||
|
||||
{showForm && (
|
||||
<div className="mb-2 rounded border bg-bg p-2.5">
|
||||
<SchemaForm schema={task.form!} value={values} errors={errors} readOnly={!canAct}
|
||||
idPrefix={`task-${task.id}`} onSubmit={canAct ? approve : undefined}
|
||||
idPrefix={`task-${task.id}`} onSubmit={canAct ? approve : undefined} fileContext={{ task_id: task.id }}
|
||||
onChange={(v) => { setValues(v); if (errors.length) setErrors([]) }} />
|
||||
</div>
|
||||
)}
|
||||
@@ -225,7 +241,8 @@ export function TaskCard({ task, onResolved, compact = false, send, showOwner =
|
||||
<div className="flex gap-2">
|
||||
<button type="button" className="btn btn-primary flex-1 justify-center" disabled={busy || inquiring}
|
||||
data-task-approve="" onClick={approve}>
|
||||
{busy ? <Spinner size={12} /> : <Check size={12} aria-hidden />} {binary ? TASK_TEXT.approve : TASK_TEXT.submit}
|
||||
{busy ? <Spinner size={12} /> : <Check size={12} aria-hidden />}{' '}
|
||||
{binary ? (trial ? TRIAL_TEXT.approve : TASK_TEXT.approve) : (trial ? TRIAL_TEXT.submit : TASK_TEXT.submit)}
|
||||
</button>
|
||||
{trustKey && (
|
||||
<button type="button" className="btn flex-1 justify-center" disabled={busy || inquiring} data-approval-always=""
|
||||
@@ -236,7 +253,8 @@ export function TaskCard({ task, onResolved, compact = false, send, showOwner =
|
||||
)}
|
||||
<button type="button" className="btn btn-danger flex-1 justify-center" disabled={busy || inquiring}
|
||||
data-task-reject="" onClick={reject}>
|
||||
<Ban size={12} aria-hidden /> {binary ? TASK_TEXT.reject : TASK_TEXT.rejectStop}
|
||||
<Ban size={12} aria-hidden />{' '}
|
||||
{binary ? (trial ? TRIAL_TEXT.reject : TASK_TEXT.reject) : (trial ? TRIAL_TEXT.rejectStop : TASK_TEXT.rejectStop)}
|
||||
</button>
|
||||
</div>
|
||||
{inquiring && (
|
||||
@@ -259,7 +277,7 @@ export function TaskCard({ task, onResolved, compact = false, send, showOwner =
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{pending && !task.can_respond && kind !== 'signal' && (
|
||||
{pending && !task.can_respond && kind !== 'signal' && kind !== 'review' && (
|
||||
task.my_response
|
||||
? <div className="mt-1 text-2xs leading-relaxed text-dim" data-task-readonly="responded">{respondedText(task.my_response)}</div>
|
||||
: <div className="mt-1 text-2xs leading-relaxed text-dim" data-task-readonly="">{TASK_TEXT.cannotRespond}</div>
|
||||
@@ -271,6 +289,75 @@ export function TaskCard({ task, onResolved, compact = false, send, showOwner =
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核个人应用:提交人、目的、说明;处理人取一份共享副本去发布(取过的打开自己那一份),不发布就退回。
|
||||
* 副本只有这条审核派给的人取得到(服务端 blueprints/personal.copy_for_review),取副本不改原来的个人应用
|
||||
*/
|
||||
function Review({ task, canAct, busy, note, setNote, onReject }: {
|
||||
task: Task; canAct: boolean; busy: boolean; note: string; setNote: (v: string) => void; onReject: () => void
|
||||
}) {
|
||||
const toast = useToast()
|
||||
const navigate = useNavigate()
|
||||
const me = usePrincipal()
|
||||
const actor = useLocalActor()
|
||||
const [copying, setCopying] = useState(false)
|
||||
const payload: Record<string, any> = task.payload ?? {}
|
||||
const blueprintId = typeof payload.blueprint_id === 'string' ? payload.blueprint_id : null
|
||||
const copies: { id: string; owner: string | null; status: string }[] = Array.isArray(payload.copies) ? payload.copies : []
|
||||
const myName = me?.username ?? actor ?? null
|
||||
const mine = copies.find((c) => c.owner === myName)
|
||||
const submitter = typeof payload.submitted_by === 'string' ? payload.submitted_by : null
|
||||
|
||||
const copy = async () => {
|
||||
if (!blueprintId || copying) return
|
||||
setCopying(true)
|
||||
try {
|
||||
const row = await api.blueprints.copyForReview(blueprintId)
|
||||
navigate(blueprintPath(row.id))
|
||||
} catch (e) {
|
||||
toast.error(e)
|
||||
} finally {
|
||||
setCopying(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="mb-2 space-y-2" data-task-review="">
|
||||
<p className="text-2xs leading-relaxed text-dim">{REVIEW_TASK_TEXT.intro}</p>
|
||||
<dl className="space-y-1 rounded border bg-bg p-2 text-2xs leading-relaxed">
|
||||
{submitter && <div className="text-dim">{REVIEW_TASK_TEXT.submittedBy(personName(submitter, task.people))}</div>}
|
||||
{typeof payload.purpose === 'string' && payload.purpose && (
|
||||
<div><dt className="inline text-faint">{REVIEW_TASK_TEXT.purpose}:</dt><dd className="inline">{payload.purpose}</dd></div>
|
||||
)}
|
||||
{typeof payload.note === 'string' && payload.note && (
|
||||
<div><dt className="inline text-faint">{REVIEW_TASK_TEXT.note}:</dt><dd className="inline whitespace-pre-wrap">{payload.note}</dd></div>
|
||||
)}
|
||||
</dl>
|
||||
{canAct && (
|
||||
<>
|
||||
<div className="flex gap-2">
|
||||
{mine
|
||||
? <Link className="btn btn-primary flex-1 justify-center" to={blueprintPath(mine.id)} data-task-review-open="">
|
||||
<ExternalLink size={12} aria-hidden /> {REVIEW_TASK_TEXT.openCopy}
|
||||
</Link>
|
||||
: <button type="button" className="btn btn-primary flex-1 justify-center" disabled={busy || copying || !blueprintId}
|
||||
onClick={() => void copy()} data-task-review-copy="">
|
||||
{copying ? <Spinner size={12} /> : <Copy size={12} aria-hidden />} {copying ? REVIEW_TASK_TEXT.copying : REVIEW_TASK_TEXT.copy}
|
||||
</button>}
|
||||
<button type="button" className="btn btn-danger flex-1 justify-center" disabled={busy || copying}
|
||||
onClick={onReject} data-task-review-reject="">
|
||||
<Ban size={12} aria-hidden /> {REVIEW_TASK_TEXT.reject}
|
||||
</button>
|
||||
</div>
|
||||
<input className="field" aria-label={REVIEW_TASK_TEXT.rejectNote} placeholder={REVIEW_TASK_TEXT.rejectNote}
|
||||
value={note} onChange={(e) => setNote(e.target.value)} />
|
||||
<div className="text-2xs leading-relaxed text-dim">{REVIEW_TASK_TEXT.rejectHint}</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** DualCheckApproval 认的是审批记录:按待办拼一份它要的几项 */
|
||||
function asApproval(task: Task, runClass: 'formal' | 'exploratory' | null): Approval {
|
||||
return {
|
||||
@@ -295,7 +382,7 @@ function TaskMeta({ task, showOwner }: { task: Task; showOwner: boolean }) {
|
||||
const owner = !showOwner ? null : task.app_name ? task.app_name : task.workflow_name ? runName(task) : null
|
||||
return (
|
||||
<div className="tnum mb-2 flex flex-wrap items-center gap-x-1.5 gap-y-0.5 text-2xs text-dim">
|
||||
<span>{TASK_KIND_LABEL[task.kind] ?? task.kind}</span>
|
||||
<span>{TASK_KIND_LABEL[task.kind as CardKind] ?? task.kind}</span>
|
||||
{owner && <><span aria-hidden>·</span><span>{owner}</span></>}
|
||||
{where && <><span aria-hidden>·</span><span>{TASK_TEXT.node(where)}</span></>}
|
||||
{created && <><span aria-hidden>·</span><span title={formatDateTime(created)}>{TASK_TEXT.createdAt(formatTime(created))}</span></>}
|
||||
|
||||
+56
-11
@@ -6,7 +6,7 @@ import {
|
||||
ABSENCE_CLAIM_TEXT, ACTION_CONFIRM_TEXT, ACTION_ENV_LABEL, ACTION_LOG_TEXT, CATALOG_DRIFT_TEXT, CATALOG_PATCH_TEXT, COPILOT_CONTEXT_TEXT, JUDGE_TEXT, LOOK_TEXT, MERGE_TEXT,
|
||||
ORIGIN_TEXT, RUN_SQL_CHECK_TEXT, SQL_CHECK_TEXT, TASK_KIND_LABEL, TASK_LOG_TEXT, TASK_STATUS_LABEL, TASK_TEXT, TYPE_LABEL, originLabel,
|
||||
CATALOG_TABLE_FIELD_LABEL, CHALLENGE_TEXT, DUAL_CHECK_TEXT, INQUIRY_TEXT, JUDGE_TRUNCATED_TEXT, MASKED_CELL_TEXT, NODE_TYPE_LABEL,
|
||||
VERIFY_TRUNCATED_TEXT,
|
||||
VERIFY_TRUNCATED_TEXT, BP_OP_TEXT, TEMPLATE_LABEL, bpPathText,
|
||||
claimTally,
|
||||
evidenceTally, issuanceLabel, nodeTypeLabel,
|
||||
} from '../lib/terms'
|
||||
@@ -3171,6 +3171,13 @@ export function catalogDrift(d: Record<string, any>): {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看对象的类型。口径卡(caliber,docs/design/normal-user-apps.md N2:蓝图对到已发布的口径卡)typesApp 的 LookObject 还没有,
|
||||
* 契约待补,先在这里按多一种认
|
||||
*/
|
||||
type LookKind = LookObject['kind'] | 'caliber'
|
||||
const kindOf = (o: LookObject): LookKind => o.kind as LookKind
|
||||
|
||||
/**
|
||||
* look 事件(L2,服务端 app/look/base.py 的形状)读进来:objects 按类型标记;字段缺了的补空,认不出的形状返回 null
|
||||
* (不出这一行,也不报错)。旧写法 sources[] 当作表类型读
|
||||
@@ -3183,7 +3190,7 @@ export function lookEventOf(op: CopilotOp): LookEvent | null {
|
||||
const objects: LookObject[] = list
|
||||
.filter((x): x is Record<string, any> => !!x && typeof x === 'object')
|
||||
.map((x) => {
|
||||
const kind: LookObject['kind'] = x.kind === 'capability' || x.kind === 'workflow_version' ? x.kind : 'table'
|
||||
const kind = (x.kind === 'capability' || x.kind === 'workflow_version' || x.kind === 'caliber' ? x.kind : 'table') as LookObject['kind']
|
||||
const total = num(x.total)
|
||||
const explored = num(x.explored)
|
||||
return {
|
||||
@@ -3206,10 +3213,10 @@ export function lookEventOf(op: CopilotOp): LookEvent | null {
|
||||
}
|
||||
|
||||
/** 这一类对象一共给了几个(表:点名的 + 挑出的 + 补上的,去重) */
|
||||
function lookCount(objects: LookObject[], kind: LookObject['kind']): number {
|
||||
function lookCount(objects: LookObject[], kind: LookKind): number {
|
||||
const seen = new Set<string>()
|
||||
for (const o of objects) {
|
||||
if (o.kind !== kind) continue
|
||||
if (kindOf(o) !== kind) continue
|
||||
for (const n of [...o.named, ...(o.picked ?? []), ...(o.joined ?? [])]) seen.add(`${o.source ?? ''}\u0000${n}`)
|
||||
}
|
||||
return seen.size
|
||||
@@ -3229,7 +3236,8 @@ function lookLine(o: LookObject): string {
|
||||
o.picked?.length ? LOOK_TEXT.picked(o.picked) : '',
|
||||
o.joined?.length ? LOOK_TEXT.joined(o.joined) : '',
|
||||
].filter(Boolean)
|
||||
const head = o.kind === 'table' ? `「${o.source ?? ''}」` : o.kind === 'capability' ? '能力' : '工作流版本'
|
||||
const kind = kindOf(o)
|
||||
const head = kind === 'table' ? `「${o.source ?? ''}」` : kind === 'capability' ? '能力' : kind === 'caliber' ? '口径卡' : '工作流版本'
|
||||
const partial = o.total != null && o.explored != null ? `(${LOOK_TEXT.partial(o.total, o.explored)})` : ''
|
||||
return parts.length ? `${head}${partial}:${parts.join(';')}` : ''
|
||||
}
|
||||
@@ -3248,8 +3256,9 @@ export function copilotLook(op: CopilotOp):
|
||||
const tables = lookCount(look.objects, 'table')
|
||||
const caps = lookCount(look.objects, 'capability')
|
||||
const versions = lookCount(look.objects, 'workflow_version')
|
||||
const calibers = lookCount(look.objects, 'caliber')
|
||||
const what = [tables ? LOOK_TEXT.tables(tables) : '', caps ? LOOK_TEXT.capabilities(caps) : '',
|
||||
versions ? LOOK_TEXT.versions(versions) : ''].filter(Boolean).join('、')
|
||||
versions ? LOOK_TEXT.versions(versions) : '', calibers ? LOOK_TEXT.calibers(calibers) : ''].filter(Boolean).join('、')
|
||||
const tableObjs = look.objects.filter((o) => o.kind === 'table' && o.source)
|
||||
const missing = look.objects.filter((o) => o.missing.length)
|
||||
.map((o) => LOOK_TEXT.missing(o.kind === 'table' ? `「${o.source ?? ''}」` : '', o.missing))
|
||||
@@ -3267,8 +3276,8 @@ export function copilotLook(op: CopilotOp):
|
||||
}
|
||||
const title = !what ? LOOK_TEXT.nothing
|
||||
: look.by === 'system'
|
||||
? tables && !caps && !versions ? LOOK_TEXT.systemTables(what)
|
||||
: versions && !tables && !caps ? LOOK_TEXT.systemVersions(what) : LOOK_TEXT.system(what)
|
||||
? tables && !caps && !versions && !calibers ? LOOK_TEXT.systemTables(what)
|
||||
: versions && !tables && !caps && !calibers ? LOOK_TEXT.systemVersions(what) : LOOK_TEXT.system(what)
|
||||
: LOOK_TEXT.title(what)
|
||||
const where = [...new Set(tableObjs.map((o) => o.source))].join('、')
|
||||
const how = [...new Set(tableObjs.map(lookHow))].join('、')
|
||||
@@ -3368,14 +3377,15 @@ const APP_SET_LABEL: Record<string, string> = {
|
||||
}
|
||||
|
||||
export function decodeCopilot(ops: CopilotOp[], opts?: {
|
||||
/** app:应用编辑器里的助手(应用润色),操作是应用操作,结局说的是应用草稿 */
|
||||
context?: 'canvas' | 'chat' | 'app'
|
||||
/** app:应用编辑器里的助手(应用润色),操作是应用操作,结局说的是应用草稿;blueprint:蓝图助手,操作是 bp_* */
|
||||
context?: 'canvas' | 'chat' | 'app' | 'blueprint'
|
||||
unchanged?: boolean
|
||||
/** 画布上的节点名。自查问题、「去掉了」这类只带 id 的行据此写成名字 */
|
||||
labelOf?: (id: string) => string | undefined
|
||||
}): Step[] {
|
||||
const canvas = opts?.context === 'canvas'
|
||||
const app = opts?.context === 'app'
|
||||
const blueprint = opts?.context === 'blueprint'
|
||||
const labels = labelsOf(ops, opts?.labelOf)
|
||||
const out: Step[] = []
|
||||
let i = 0
|
||||
@@ -3477,6 +3487,34 @@ export function decodeCopilot(ops: CopilotOp[], opts?: {
|
||||
add({ id: `ca-${i}`, seq: i, kind: 'note', status: 'done', code: 'copilot_ask',
|
||||
title: LOOK_TEXT.ask, detail: String(op.question ?? '') || undefined, next: LOOK_TEXT.askNext })
|
||||
break
|
||||
case 'bp_ask':
|
||||
// 蓝图助手的反问(N2):带候选,选项画在对话下面(蓝图页),这里记一行
|
||||
settleAll('done')
|
||||
add({ id: `ba-${i}`, seq: i, kind: 'note', status: 'done', code: 'blueprint_ask', title: BP_OP_TEXT.ask,
|
||||
detail: [String(op.question ?? ''), ...(Array.isArray(op.options) ? op.options.map((o: unknown) => `· ${String(o)}`) : [])]
|
||||
.filter(Boolean).join('\n') || undefined,
|
||||
next: BP_OP_TEXT.askNext })
|
||||
break
|
||||
case 'bp_set':
|
||||
case 'bp_add':
|
||||
case 'bp_remove':
|
||||
case 'bp_template': {
|
||||
// 蓝图的改动(服务端 BlueprintApplier 落地后转出):一行一个,说改了哪张卡片的哪一项
|
||||
const where = bpPathText(op.path)
|
||||
const tid = String(op.template?.id ?? '')
|
||||
const title = op.op === 'bp_template' ? BP_OP_TEXT.template(TEMPLATE_LABEL[tid] ?? tid)
|
||||
: op.op === 'bp_add' ? BP_OP_TEXT.add(where)
|
||||
: op.op === 'bp_remove' ? BP_OP_TEXT.remove(where)
|
||||
: /\/status$/.test(String(op.path ?? '')) && op.value === 'confirmed' ? BP_OP_TEXT.confirm(where)
|
||||
: BP_OP_TEXT.set(where)
|
||||
add({ id: `bo-${i}`, seq: i, kind: 'note', status: 'done', code: 'blueprint_op', title: clip(title) })
|
||||
break
|
||||
}
|
||||
case 'fill_joint':
|
||||
// 填关节(N3):模型只填模板声明过的位置,一行一个
|
||||
add({ id: `bj-${i}`, seq: i, kind: 'note', status: 'done', code: 'blueprint_joint',
|
||||
title: clip(BP_OP_TEXT.fill(String(op.label ?? op.joint ?? ''))) })
|
||||
break
|
||||
case 'app_add':
|
||||
case 'app_update':
|
||||
case 'app_remove':
|
||||
@@ -3530,7 +3568,7 @@ export function decodeCopilot(ops: CopilotOp[], opts?: {
|
||||
// 心跳那条"正在理解需求…"要收尾,否则生成完了它还在转圈
|
||||
settleAll('done')
|
||||
add({ id: `cd-${i}`, seq: i, kind: 'lifecycle', status: 'done',
|
||||
title: app ? '应用草稿已调整完成' : `工作流已搭建完成,新增 ${nodeCount} 个步骤`,
|
||||
title: app ? '应用草稿已调整完成' : blueprint ? BP_OP_TEXT.done : `工作流已搭建完成,新增 ${nodeCount} 个步骤`,
|
||||
detail: String(op.explanation ?? '') || undefined })
|
||||
break
|
||||
case 'check': {
|
||||
@@ -3561,6 +3599,7 @@ export function decodeCopilot(ops: CopilotOp[], opts?: {
|
||||
title: op.status === 'failed'
|
||||
? canvas
|
||||
? `自查后仍有 ${issues.length} 处问题未能自动修正`
|
||||
: blueprint ? BP_OP_TEXT.checkLeft(issues.length)
|
||||
: `自查后仍有 ${issues.length} 处问题,未自动运行`
|
||||
: String(op.message ?? '自查未能完成'),
|
||||
detail: [...lines, ...droppedOf(op).map((x) => x.message)].join('\n') || undefined,
|
||||
@@ -3585,6 +3624,12 @@ export function decodeCopilot(ops: CopilotOp[], opts?: {
|
||||
: `工作流已搭建完成,共 ${total} 个步骤`
|
||||
}
|
||||
settleAll('done')
|
||||
// 蓝图助手提的改动有的没采纳(越界、和你确认过的卡片冲突):服务端在 final.issues 里照实交回,这里一行说清
|
||||
if (blueprint && Array.isArray(op.issues) && op.issues.length) {
|
||||
const lines = op.issues.map((x: any) => String(x?.message ?? '')).filter(Boolean)
|
||||
add({ id: `bn-${i}`, seq: i, kind: 'note', status: 'done', level: 'warn', code: 'blueprint_refused',
|
||||
title: BP_OP_TEXT.refused(lines.length), detail: lines.join('\n') || undefined })
|
||||
}
|
||||
// 模型写了不存在的节点类型:那一步被跳过了。不说出来的话"共 N 步"是
|
||||
// 一句不完整的真话,用户要到运行结果不对才发现少了一步
|
||||
for (const t of skippedTypes(op)) {
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
* 正式运行的表单由服务端转好放在版本详情里(VersionDetailOut.input_schema,服务端 app/apps/forms.input_schema);
|
||||
* 画布试运行用的是画布上还没保存的入口字段,只能在这里按同一套规则转:没写类型的按文本,可选值变成下拉,
|
||||
* 说明、默认值照搬。两处规则对不上时以服务端为准——发起时服务端照版本快照校验,这里只决定怎么画。
|
||||
*
|
||||
* 文件字段(normal-user-apps N9):输入节点的字段写 type: file,转成 type 为 object、x-widget 为 file 的字段,允许的类型
|
||||
* 和大小(accept、max_mb)进 x-file。值是上传后拿回的引用,没上传的不传。
|
||||
*/
|
||||
import type { FormField, FormSchema } from '../typesApp'
|
||||
|
||||
@@ -14,12 +17,27 @@ export interface InputField {
|
||||
description?: string
|
||||
default?: unknown
|
||||
example?: unknown
|
||||
type?: FormField['type']
|
||||
/** file:文件(上传后拿回的引用) */
|
||||
type?: FormField['type'] | 'file'
|
||||
enum?: (string | number)[]
|
||||
format?: FormField['format']
|
||||
/** 数字类型的上下限(闭区间,表单子集没有 exclusiveMinimum:「大于 0」的金额写 0.01) */
|
||||
minimum?: number
|
||||
maximum?: number
|
||||
/** 文件字段:允许的类型(MIME 或扩展名)、大小上限(MB) */
|
||||
accept?: string[]
|
||||
max_mb?: number
|
||||
}
|
||||
|
||||
/** 文件字段:type 为 object(typesApp.FormField 还没列 object 和 x-file,见报告的接口约定请求) */
|
||||
function fileField(f: InputField): FormField {
|
||||
const limits: { accept?: string[]; max_mb?: number } = {}
|
||||
if (Array.isArray(f.accept) && f.accept.length) limits.accept = f.accept.filter((a) => typeof a === 'string' && a)
|
||||
if (typeof f.max_mb === 'number' && Number.isFinite(f.max_mb) && f.max_mb > 0) limits.max_mb = f.max_mb
|
||||
const field: Record<string, unknown> = { type: 'object', title: f.name, 'x-widget': 'file' }
|
||||
if (f.description) field.description = f.description
|
||||
if (Object.keys(limits).length) field['x-file'] = limits
|
||||
return field as unknown as FormField
|
||||
}
|
||||
|
||||
const TYPES = new Set(['string', 'number', 'integer', 'boolean', 'array'])
|
||||
@@ -30,7 +48,12 @@ export function inputSchemaOf(fields: InputField[]): FormSchema {
|
||||
const required: string[] = []
|
||||
for (const f of fields) {
|
||||
if (!f?.name) continue
|
||||
const type = f.type && TYPES.has(f.type) ? f.type : 'string'
|
||||
if (f.type === 'file') {
|
||||
properties[f.name] = fileField(f)
|
||||
if (f.required) required.push(f.name)
|
||||
continue
|
||||
}
|
||||
const type = f.type && TYPES.has(f.type) ? f.type as FormField['type'] : 'string'
|
||||
const options = Array.isArray(f.enum) && f.enum.length ? f.enum : null
|
||||
const field: FormField = { type, title: f.name }
|
||||
if (f.description) field.description = f.description
|
||||
@@ -65,6 +88,10 @@ export function inputPayload(schema: FormSchema, values: Record<string, unknown>
|
||||
const typed = values[name]
|
||||
const blank = typed == null || (typeof typed === 'string' && typed.trim() === '')
|
||||
if (blank && field.default == null && (field.type === 'number' || field.type === 'integer')) continue // 没填的数字不传,不传空串
|
||||
if (field['x-widget'] === 'file') { // 文件:上传后拿回的引用原样传,没上传的不传
|
||||
if (!blank) payload[name] = typed
|
||||
continue
|
||||
}
|
||||
const raw = blank ? field.default ?? (field.type === 'array' ? [] : field.type === 'boolean' ? false : '') : typed
|
||||
if (field.type === 'string' && !field.enum && typeof raw === 'string' && /^\s*[[{]/.test(raw)) {
|
||||
try { payload[name] = JSON.parse(raw) } catch { payload[name] = raw }
|
||||
|
||||
Reference in New Issue
Block a user