mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-20 09:01:59 +00:00
普通用户建应用集成收尾:
- 问数据和个人应用的图放行绑定只读查询等合规工具的调用工具节点,只读和遮罩在这条路径上生效;被治理成写入的工具在只读运行里直接拒;知识库范围在工具层固定(图级默认值、参数名纠错、Agent 都改不了) - 个人应用的刷新和个人蓝图的试运行只有拥有者能读:运行、事件、证据、工件、文件、运行与审批列表、对比、可验证报告、质询、假设分析、提取工作流一并收紧;个人蓝图的试运行不论谁发起都按个人应用约束 - 共享蓝图只给拥有者、对应应用的管理者、管理员,看不到的一律 404;审核副本归审核人;管理员看别人的个人应用只有元数据、可以归档 - 记录表跨版本汇总(只读挂载旧版本、按当前列 UNION ALL、各版本各自固定高水位,缺的版本照实写进印章);停用前发起的运行可以继续写旧版本;更正沿用原提交人、更正人记审计 - 约定收口:待办种类 review、事件 file.extracted、表单错误 file、模板定义带示例与预置;前端类型一次补齐、去掉临时的局部类型;审核待办卡不再给打不开的链接;读附件事件有中文说法;检查脚本补断言
This commit is contained in:
@@ -41,7 +41,7 @@ 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,
|
||||
FormError, ReviewTaskPayload, Task, TaskAssignment, TaskKind, TaskMyResponse, TaskProgress, TaskRespond,
|
||||
} from '../typesApp'
|
||||
import { Markdown } from './Markdown'
|
||||
import { ApprovalReports, ApprovalRunClass } from './ApprovalReport'
|
||||
@@ -71,10 +71,7 @@ export interface TaskCardProps {
|
||||
trial?: boolean
|
||||
}
|
||||
|
||||
/** 待办的种类,多一种 review(个人应用提交审核):typesApp 的 TaskKind 还没有它(契约待补),先在这里按多一种认 */
|
||||
type CardKind = TaskKind | 'review'
|
||||
|
||||
const KIND_ICON: Record<CardKind, typeof Hand> = {
|
||||
const KIND_ICON: Record<TaskKind, typeof Hand> = {
|
||||
approve: Hand, input: Keyboard, edit: PenLine, tool: Wrench, code: Code, dual_check: Hand,
|
||||
action_confirm: Send, reconcile: SearchCheck, signal: Webhook, review: UserCheck,
|
||||
}
|
||||
@@ -85,7 +82,7 @@ const STALE_MS = 24 * 3_600_000
|
||||
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 as CardKind
|
||||
const kind = task.kind
|
||||
const pending = task.status === 'pending'
|
||||
const canAct = pending && task.can_respond
|
||||
const inquiring = useInquiryBusy(task.run_id)
|
||||
@@ -301,9 +298,10 @@ function Review({ task, canAct, busy, note, setNote, onReject }: {
|
||||
const me = usePrincipal()
|
||||
const actor = useLocalActor()
|
||||
const [copying, setCopying] = useState(false)
|
||||
const payload: Record<string, any> = task.payload ?? {}
|
||||
const payload: Partial<ReviewTaskPayload> = 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 copies = 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
|
||||
@@ -382,7 +380,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 as CardKind] ?? task.kind}</span>
|
||||
<span>{TASK_KIND_LABEL[task.kind] ?? 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></>}
|
||||
@@ -774,15 +772,22 @@ function Signer() {
|
||||
)
|
||||
}
|
||||
|
||||
/** 去实例页(应用里的)或记录页(别处的,搭建者以上才看得到记录页) */
|
||||
/**
|
||||
* 去实例页(应用里的)或记录页(别处的,搭建者以上才看得到记录页)。
|
||||
*
|
||||
* 审核个人应用的待办不给这两个:run_id 是提交人那次个人应用的刷新、app_id 是他的个人应用,只有拥有者读得到(服务端
|
||||
* auth/access.private_owner,处理人是管理员、搭建者也不例外),链出去只会是打不开的页面。处理人要看的是取副本之后在副本
|
||||
* 蓝图上试运行出来的(Review 里的「取副本,去发布」「打开我的副本」)
|
||||
*/
|
||||
function TaskLinks({ task }: { task: Task }) {
|
||||
const builder = useAtLeast('builder')
|
||||
const links = useMemo(() => {
|
||||
const out: { to: string; label: string }[] = []
|
||||
if (task.kind === 'review') return out
|
||||
if (task.app_id) out.push({ to: `/apps/${encodeURIComponent(task.app_id)}/i/${encodeURIComponent(task.run_id)}`, label: TASK_TEXT.openInstance })
|
||||
if (builder) out.push({ to: `/runs/${encodeURIComponent(task.run_id)}`, label: TASK_TEXT.openRun })
|
||||
return out
|
||||
}, [task.app_id, task.run_id, builder])
|
||||
}, [task.kind, task.app_id, task.run_id, builder])
|
||||
if (!links.length) return null
|
||||
return (
|
||||
<div className="mt-1.5 flex flex-wrap gap-x-3 text-2xs">
|
||||
|
||||
+28
-12
@@ -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, BP_OP_TEXT, TEMPLATE_LABEL, bpPathText,
|
||||
VERIFY_TRUNCATED_TEXT, BP_OP_TEXT, TEMPLATE_LABEL, bpPathText, FILE_TEXT,
|
||||
claimTally,
|
||||
evidenceTally, issuanceLabel, nodeTypeLabel,
|
||||
} from '../lib/terms'
|
||||
@@ -2798,6 +2798,28 @@ export function decodeRun(events: RunEvent[], final?: RunFinal, opts?: DecodeOpt
|
||||
break
|
||||
}
|
||||
|
||||
case 'file.extracted': {
|
||||
// 模板函数 file_text 读入一个附件的文字(服务端 files/text.py):读入多少字、全文多少字、是否截断,读入的那一段存成
|
||||
// 工件可以点开;抽不出时 ok=false、reason 写原因。截断、抽不出都要看得见:下游拿到的不是全文
|
||||
const name = typeof d.name === 'string' ? d.name.trim() : ''
|
||||
const chars = num(d.chars)
|
||||
const total = num(d.total_chars)
|
||||
const failedRead = d.ok === false
|
||||
const cut = !failedRead && d.truncated === true
|
||||
const reason = typeof d.reason === 'string' && d.reason.trim() ? d.reason.trim() : undefined
|
||||
push({
|
||||
id: `fx-${seq}`, seq, kind: 'tool', nodeId, status: 'done', code: 'file_extracted',
|
||||
...(failedRead || cut ? { level: 'warn' as const } : {}),
|
||||
title: failedRead ? FILE_TEXT.extractFailed(name) : FILE_TEXT.extracted(name, chars != null ? formatNumber(chars) : null),
|
||||
...(failedRead ? (reason ? { sub: reason } : {})
|
||||
: total == null ? {}
|
||||
: !cut ? { sub: FILE_TEXT.extractedAll(formatNumber(total)) }
|
||||
: chars != null ? { sub: FILE_TEXT.extractedCut(formatNumber(chars), formatNumber(total)) } : {}),
|
||||
...(typeof d.artifact === 'string' && d.artifact ? { artifact: d.artifact } : {}),
|
||||
}, nodeId)
|
||||
break
|
||||
}
|
||||
|
||||
default:
|
||||
// 新增事件类型时不要静默吞掉——宁可显示一条,也比让人觉得"什么都没
|
||||
// 发生"好。但内部类型名(agent.route.end 这种)对使用者是一串代码,
|
||||
@@ -3171,13 +3193,6 @@ 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[] 当作表类型读
|
||||
@@ -3190,7 +3205,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 = (x.kind === 'capability' || x.kind === 'workflow_version' || x.kind === 'caliber' ? x.kind : 'table') as LookObject['kind']
|
||||
const kind: LookObject['kind'] = x.kind === 'capability' || x.kind === 'workflow_version' || x.kind === 'caliber' ? x.kind : 'table'
|
||||
const total = num(x.total)
|
||||
const explored = num(x.explored)
|
||||
return {
|
||||
@@ -3213,10 +3228,10 @@ export function lookEventOf(op: CopilotOp): LookEvent | null {
|
||||
}
|
||||
|
||||
/** 这一类对象一共给了几个(表:点名的 + 挑出的 + 补上的,去重) */
|
||||
function lookCount(objects: LookObject[], kind: LookKind): number {
|
||||
function lookCount(objects: LookObject[], kind: LookObject['kind']): number {
|
||||
const seen = new Set<string>()
|
||||
for (const o of objects) {
|
||||
if (kindOf(o) !== kind) continue
|
||||
if (o.kind !== kind) continue
|
||||
for (const n of [...o.named, ...(o.picked ?? []), ...(o.joined ?? [])]) seen.add(`${o.source ?? ''}\u0000${n}`)
|
||||
}
|
||||
return seen.size
|
||||
@@ -3236,7 +3251,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 kind = kindOf(o)
|
||||
// 口径卡(caliber)是蓝图对到的已发布口径卡上的指标(docs/design/normal-user-apps.md N2)
|
||||
const kind = o.kind
|
||||
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(';')}` : ''
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* 文件字段(normal-user-apps N9):输入节点的字段写 type: file,转成 type 为 object、x-widget 为 file 的字段,允许的类型
|
||||
* 和大小(accept、max_mb)进 x-file。值是上传后拿回的引用,没上传的不传。
|
||||
*/
|
||||
import type { FormField, FormSchema } from '../typesApp'
|
||||
import type { FileLimits, FormField, FormSchema } from '../typesApp'
|
||||
|
||||
/** 输入节点的一个字段(canvas/nodeDefs 的 ioFields;type / enum / format / 上下限是应用平台新加的,老图没有) */
|
||||
export interface InputField {
|
||||
@@ -17,8 +17,8 @@ export interface InputField {
|
||||
description?: string
|
||||
default?: unknown
|
||||
example?: unknown
|
||||
/** file:文件(上传后拿回的引用) */
|
||||
type?: FormField['type'] | 'file'
|
||||
/** file:文件(上传后拿回的引用);表单里的 object 只给文件控件,输入节点上写 file */
|
||||
type?: Exclude<FormField['type'], 'object'> | 'file'
|
||||
enum?: (string | number)[]
|
||||
format?: FormField['format']
|
||||
/** 数字类型的上下限(闭区间,表单子集没有 exclusiveMinimum:「大于 0」的金额写 0.01) */
|
||||
@@ -29,15 +29,15 @@ export interface InputField {
|
||||
max_mb?: number
|
||||
}
|
||||
|
||||
/** 文件字段:type 为 object(typesApp.FormField 还没列 object 和 x-file,见报告的接口约定请求) */
|
||||
/** 文件字段:type 为 object、x-widget 为 file,限制进 x-file(同服务端 apps/forms.input_schema) */
|
||||
function fileField(f: InputField): FormField {
|
||||
const limits: { accept?: string[]; max_mb?: number } = {}
|
||||
const limits: FileLimits = {}
|
||||
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' }
|
||||
const field: FormField = { 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
|
||||
return field
|
||||
}
|
||||
|
||||
const TYPES = new Set(['string', 'number', 'integer', 'boolean', 'array'])
|
||||
@@ -53,7 +53,7 @@ export function inputSchemaOf(fields: InputField[]): FormSchema {
|
||||
if (f.required) required.push(f.name)
|
||||
continue
|
||||
}
|
||||
const type = f.type && TYPES.has(f.type) ? f.type as FormField['type'] : 'string'
|
||||
const type = f.type && TYPES.has(f.type) ? f.type as Exclude<FormField['type'], 'object'> : '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
|
||||
|
||||
Reference in New Issue
Block a user