mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-16 00:21:57 +00:00
自由形蓝图(前端):「谁来做」卡片按服务端的 derived_people 摆,只定每一步由谁做
为什么:服务端已按导入的图列出「谁来做」(自由形蓝图后端那个提交),卡片要照那一份摆出来,发布摘要里「你来定」才指得到一张 真实存在的卡片(05-已知遗留 (d))。 做了什么:Blueprint 带 derived_people(typesBlueprint.DerivedPerson)。BlueprintCards 的 people 卡片对自由形按它一行一行画: 行名、每处用途只读;岗位行和「写入结果不明时谁去核实」一行复用 ItemRow 的人或组编辑(改了发 bp_set 到那一行的 path);发起人、 表达式、外部系统回调的步骤只读;不能加减步骤、不改会签和时限(卡片上写明在画布上改)。卡片上的问题按那几行的 path 归进来。 termsBlueprint 加四句。服务端 blueprint_out 对没有 graph 属性的对象(契约测试里的替身)按没有图算。
This commit is contained in:
@@ -379,7 +379,7 @@ def _derived_people(blueprint: Any) -> list[dict[str, Any]]:
|
||||
from app.blueprints.templates import freeform
|
||||
from app.blueprints.templates._common import with_graph
|
||||
|
||||
return freeform.people_rows(with_graph(blueprint.spec or {}, blueprint.graph))
|
||||
return freeform.people_rows(with_graph(blueprint.spec or {}, getattr(blueprint, "graph", None)))
|
||||
|
||||
|
||||
def blueprint_out(blueprint: Any, *, issues: bool = True, extra: list[dict[str, Any]] | None = None) -> dict[str, Any]:
|
||||
@@ -398,7 +398,7 @@ def blueprint_out(blueprint: Any, *, issues: bool = True, extra: list[dict[str,
|
||||
"conversation_id": blueprint.conversation_id, "workflow_id": blueprint.workflow_id, "app_id": blueprint.app_id,
|
||||
"last_trial_run_id": blueprint.last_trial_run_id, "graph_hash": blueprint.graph_hash, "joints": joints,
|
||||
"copied_from": blueprint.copied_from,
|
||||
"reconciler_needed": needs_reconciler(with_graph(blueprint.spec or {}, blueprint.graph)),
|
||||
"reconciler_needed": needs_reconciler(with_graph(blueprint.spec or {}, getattr(blueprint, "graph", None))),
|
||||
"derived_people": _derived_people(blueprint) if is_freeform(blueprint.spec or {}) else None,
|
||||
"created_at": blueprint.created_at.isoformat() if blueprint.created_at else None,
|
||||
"updated_at": blueprint.updated_at.isoformat() if blueprint.updated_at else None,
|
||||
|
||||
@@ -356,6 +356,13 @@ export const BP_EDIT_TEXT = {
|
||||
reconcilerHint: '这项写入能力没登记查询:写回的结果不明时(请求发出去了、没拿到答复),平台查不了,也不会自动重发,'
|
||||
+ '要有人去目标系统里看写进去没有。只能由你来选。',
|
||||
reconcilerUnused: '这项写入能力已经登记了查询,结果不明时平台自己去查:这一项用不上了,发布时不会派给他们。',
|
||||
/**
|
||||
* 自由形的「谁来做」(05-已知遗留 (d)):按导入的图列出,只定由谁做;行名、会签、时限、超时都来自图,要改回画布
|
||||
*/
|
||||
freeformPeopleHint: '按导入的图列出:这里只定每一步由谁做,会签、时限、超时和步骤本身在画布上改。',
|
||||
freeformPeopleEmpty: '导入的图里没有要指定由谁处理的步骤。',
|
||||
freeformWho: '谁来做',
|
||||
freeformReadOnly: '图上已经写定,这里不用选',
|
||||
removeTitle: (where: string) => `删掉${where}?`,
|
||||
removeConfirm: '删掉',
|
||||
template: '换一个场景',
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
* 哪些项必填(P7)。
|
||||
*
|
||||
* 写回卡片上「结果不明时谁去核实」只在目标能力没登记查询时摆(服务端 Blueprint.reconciler_needed),只能由人选(同「谁能看」)。
|
||||
* 自由形的「谁来做」按服务端给的 derived_people 摆(FreeformPeople):骨架是导入的图,卡片只定每一步由谁做。
|
||||
*
|
||||
* 每一项可以点「修改」:改完发一个 bp_set(值是纯值,服务端记成来源「你」、已确认);待确认的可以直接点「确认」(只改状态,
|
||||
* 来源不变),一张卡片上待确认的不止一项时卡头另有「确认全部」,一次修改带上这几项的状态(服务端整批落或整批不落)。
|
||||
@@ -26,7 +27,7 @@ import {
|
||||
} from '../../lib/terms'
|
||||
import { chatBusy, useBlueprint } from '../../store/blueprint'
|
||||
import type {
|
||||
Blueprint, BpDataItem, BpField, BpItem, BpOp, BpStep, ItemStatus, JointState, PlainIssue, TemplateInfo,
|
||||
Blueprint, BpDataItem, BpField, BpItem, BpOp, BpStep, DerivedPerson, ItemStatus, JointState, PlainIssue, TemplateInfo,
|
||||
} from '../../typesBlueprint'
|
||||
import { SELF_RECORDS, ValueEditor, valueText, type EditorKind, type EditorScope } from './editors'
|
||||
import { isItem, missingPaths, visibleCards, type CardKey } from './shared'
|
||||
@@ -175,6 +176,7 @@ function CardFor({ card, ctx, template }: { card: CardKey; ctx: CardCtx; templat
|
||||
</Card>
|
||||
)
|
||||
case 'people': {
|
||||
if (ctx.bp.derived_people) return <FreeformPeople ctx={ctx} rows={ctx.bp.derived_people} note={note} />
|
||||
const items = spec.people.flatMap((s, i) => STEP_KEYS.map((k) => [`/people/${i}/${k}`, s[k] as BpItem] as [string, BpItem]))
|
||||
return (
|
||||
<Card card={card} note={note} issues={issues} status={cardStatus(ctx, card, items)}
|
||||
@@ -254,6 +256,45 @@ function Empty() {
|
||||
return <p className="text-2xs text-faint">{BLUEPRINT_TEXT.empty}</p>
|
||||
}
|
||||
|
||||
/**
|
||||
* 自由形的「谁来做」(05-已知遗留 (d)):按服务端给的 derived_people 一行一行摆,不自己从图里推。岗位行、核实人那一行只定
|
||||
* 由谁做(改了发 bp_set 到那一行的 path);发起人、表达式、外部系统回调的步骤只读。不能加减步骤、不能改会签和时限:骨架是
|
||||
* 导入的图,要改回画布
|
||||
*/
|
||||
function FreeformPeople({ ctx, rows, note }: { ctx: CardCtx; rows: DerivedPerson[]; note?: string }) {
|
||||
const spec = ctx.bp.spec
|
||||
const itemOf = (row: DerivedPerson): BpItem | null => {
|
||||
if (row.kind === 'reconciler') return spec.writeback?.reconciler ?? UNSET
|
||||
if (row.kind !== 'slot') return null
|
||||
return spec.people.find((s) => s.id === row.slot)?.who ?? UNSET
|
||||
}
|
||||
const items = rows.flatMap((r): [string, BpItem][] => {
|
||||
const item = itemOf(r)
|
||||
return r.path && item ? [[r.path, item]] : []
|
||||
})
|
||||
const paths = new Set(items.map(([p]) => p))
|
||||
const issues = (ctx.bp.issues ?? []).filter((i) => i.path === '/people' || (i.path != null && paths.has(i.path)))
|
||||
return (
|
||||
<Card card="people" note={note} issues={issues} status={cardStatus(ctx, 'people', items)}>
|
||||
<p className="text-2xs leading-relaxed text-dim" data-bp-freeform-people={rows.length}>{BP_EDIT_TEXT.freeformPeopleHint}</p>
|
||||
{rows.length === 0 && <p className="text-2xs text-faint">{BP_EDIT_TEXT.freeformPeopleEmpty}</p>}
|
||||
{rows.map((row, i) => {
|
||||
const item = itemOf(row)
|
||||
return (
|
||||
<div key={`${row.kind}-${row.slot ?? i}`} className="rounded-md border p-2" data-bp-derived={row.kind}
|
||||
data-bp-slot={row.slot ?? undefined}>
|
||||
<div className="mb-1 text-xs font-medium text-fg">{row.label}</div>
|
||||
<p className="mb-1 text-2xs leading-relaxed text-dim">{row.detail}</p>
|
||||
{row.path && item
|
||||
? <ItemRow ctx={ctx} path={row.path} item={item} label={BP_EDIT_TEXT.freeformWho} kind="grantees" />
|
||||
: <p className="text-2xs text-faint">{BP_EDIT_TEXT.freeformReadOnly}</p>}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
|
||||
function Card({ card, status, note, actions, issues, children }: {
|
||||
card: CardKey; status: ItemStatus | null; note?: string; actions?: ReactNode; issues?: PlainIssue[]; children: ReactNode
|
||||
}) {
|
||||
|
||||
@@ -45,6 +45,21 @@ export interface BpStep {
|
||||
|
||||
export interface BpField { name: string; spec: BpItem<Record<string, any>>; sensitive: boolean }
|
||||
|
||||
/**
|
||||
* 自由形「谁来做」的一行。slot:图里引用的一个岗位(path 是 /people/<i>/who,只定由谁做);reconciler:写入能力没登记查询时
|
||||
* 的核实人(path 是 /writeback/reconciler);initiator / expression / hook:不按岗位派的步骤,只读(path 为空)。
|
||||
* label 是节点在图上的名字,detail 写全每一处用途
|
||||
*/
|
||||
export interface DerivedPerson {
|
||||
kind: 'slot' | 'reconciler' | 'initiator' | 'expression' | 'hook'
|
||||
slot: string | null
|
||||
label: string
|
||||
detail: string
|
||||
path: string | null
|
||||
who: BpPrincipal[] | null
|
||||
uses: { node_id: string; title: string; role: string }[]
|
||||
}
|
||||
|
||||
export interface BpWriteback {
|
||||
capability: BpItem<string>
|
||||
mapping: BpItem<Record<string, string>>
|
||||
@@ -132,6 +147,11 @@ export interface Blueprint {
|
||||
* templates/_common.needs_reconciler,界面不自己判)。老服务端不给时按不要
|
||||
*/
|
||||
reconciler_needed?: boolean
|
||||
/**
|
||||
* 自由形按导入的图列出的「谁来做」(服务端 templates/freeform.people_rows,05-已知遗留 (d)):界面照这一份画,不自己从图里推。
|
||||
* 别的模板、老服务端为空
|
||||
*/
|
||||
derived_people?: DerivedPerson[] | null
|
||||
/** 蓝图检查(bp.* / tpl.*),带白话 */
|
||||
issues?: PlainIssue[]
|
||||
created_at: string
|
||||
|
||||
Reference in New Issue
Block a user