「flow:按**步序位置**推送声明的模版」(AM 07)。原先这条链只有写面没有读面,
活动的 viewTemplates 是一行占位字符串,工作台视图区永远只显示一份硬编码概览。
补齐整条链:
· 步声明新增 `view`:这一步呈现哪张模版 —— 推什么由声明给定,不由临场决定。
· 新增模版填数的纯函数(interaction/domain):`data-slot` 取值、`data-rows` 逐条展开。
**填数只做取值与转义**,没有表达式、没有分支、没有循环 —— 一旦模版能算,
它就成了代码,容器的「无脚本执行权」也就形同虚设。填充**消费槽位**,
交出去的是干净 HTML,不是带模板属性的半成品。
· interaction 补读面 `viewOf`;desk 路由把推送的 HTML 交给前端;
ViewRegion 经 `@ui` 的 ViewContainer(sandbox="" 的 iframe)渲染 —— feature 不碰 innerHTML。
· A1 写了三张真模版(事态全景 / 打标判据 / 成果预览),内联自带样式
(沙箱页面不继承工作台 CSS),按步序位置挂在 S3 / S5 / S6 上。
沿路两处修:
① 取值路径遇到**本身带点号的键**(台账地址 `域.对象`)会被拆成两级、永远取不到。
改为整键优先、找不到再下行;`view-render` 与 `step-sequence` 两处同修。
② 「本单交付」不能画成台账全表:任务视图是正式版 + 我的草稿的合并结果,
直接拿来列会把**别单**放行过的记录一并列出。本单自己写下的行单独放在
`mine:域.对象` 下(整键,取值不歧义)。
另:视图推送失败原先静默吞掉 —— 会让「视图区一直空着」变成查不出原因的怪事;
改为留痕(仍不影响步序推进,呈现是投影)。
实测:一封 RFQ 入站 → 放行前那一屏列出本单交付 LM358DR / TI / 12000 / 8.2 / 10周,
以及 Type A「直接快答」的分类结论与四项打标判据。
gates: tsc / eslint / depcruise(321 模块)/ api-report / 423 测试 全绿
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KeDBx2PHLavbURXB8LJJ7m
319 lines
12 KiB
TypeScript
319 lines
12 KiB
TypeScript
/**
|
|
* 活动包清单 —— 统一报价 A1 · RFQ 需求分析(受理归一)。
|
|
*
|
|
* 业务素材出处:docs/MVP示例工作流.html §1.1;按 README《归一化对照表》映射为:
|
|
* SOP 节点 → **标准活动(flow)**;作业指导书 S1…S6 → **步序声明**(四种步型);
|
|
* 步内判断 D1 完整度 → **条件谓词**;三分类规则 P-03 → **DMN 决策表**;
|
|
* SLA(受理<15min、打标<45min)→ Harness 时限与预算。
|
|
*/
|
|
import type { ActivityManifest, DmnModel } from '@contracts';
|
|
import { activityIdSchema } from '@contracts';
|
|
import { INTAKE_CLASSIFIED, INTAKE_OVERVIEW, INTAKE_RELEASE } from './views/report.ts';
|
|
|
|
const INTAKE_DOMAIN = 'quote_intake';
|
|
const ACTIVITY_ID = activityIdSchema.parse('quote-intake');
|
|
|
|
/**
|
|
* 三分类规则 P-03 —— 把「装得下的判断」从 LLM 手里拿走。
|
|
* 由纯工具步 `quote-intake.classify` 逐条求值,命中规则行留痕。
|
|
*/
|
|
export const P03_DMN: DmnModel = {
|
|
drd: [{ decision: 'p03-type', requires: [], inputs: ['historyDays', 'marketStable', 'lifecycle'] }],
|
|
tables: [{
|
|
id: 'p03-type',
|
|
label: '三分类规则 P-03',
|
|
hitPolicy: 'FIRST' as const,
|
|
inputs: [
|
|
{ name: 'historyDays', expression: 'historyDays' },
|
|
{ name: 'marketStable', expression: 'marketStable' },
|
|
{ name: 'lifecycle', expression: 'lifecycle' },
|
|
],
|
|
outputs: [{ name: 'type' }, { name: 'play' }],
|
|
rules: [
|
|
{ id: 'p03-c', when: ['-', '-', '"EOL","缺货","要求替代"'], then: ['C', '转案处理'], annotation: 'EOL/缺货/要替代 → C' },
|
|
{ id: 'p03-a', when: ['<= 90', 'true', '-'], then: ['A', '直接快答'], annotation: '历史价≤90天且行情稳 → A' },
|
|
{ id: 'p03-b', when: ['-', '-', '-'], then: ['B', '重估后报'], annotation: '无历史/过期/波动 → B' },
|
|
],
|
|
}],
|
|
};
|
|
|
|
export const manifest: ActivityManifest = {
|
|
identity: {
|
|
activityId: ACTIVITY_ID,
|
|
name: 'A1 · RFQ 需求分析',
|
|
packageVersion: '0.1.7',
|
|
category: '统一报价',
|
|
paradigm: 'flow',
|
|
sdkVersion: '0.1.0-m5',
|
|
checksum: 'dev-checksum-quote-intake',
|
|
},
|
|
|
|
/* 契约七件 */
|
|
contract: {
|
|
activityId: ACTIVITY_ID,
|
|
version: '0.1.0',
|
|
input: {
|
|
data: {
|
|
type: 'object',
|
|
required: ['customerCode', 'rfqRef'],
|
|
properties: {
|
|
customerCode: { type: 'string' },
|
|
rfqRef: { type: 'string' },
|
|
subject: { type: 'string' },
|
|
/** 询价原文 —— 归一步拆解的对象 */
|
|
body: { type: 'string' },
|
|
},
|
|
},
|
|
messageAllowed: true,
|
|
messageHint: '客户口头急单等特殊性写这里',
|
|
},
|
|
output: {
|
|
mandatory: [
|
|
{
|
|
name: 'intake',
|
|
payload: {
|
|
type: 'object',
|
|
required: ['records'],
|
|
properties: { records: { type: 'array' } },
|
|
},
|
|
description: '统一受理记录(已打标)',
|
|
},
|
|
],
|
|
selective: [],
|
|
},
|
|
requiredDeliverables: [
|
|
{ key: 'intake-record', label: '统一受理记录(打标)' },
|
|
{ key: 'type-table', label: '料号分类表' },
|
|
],
|
|
acceptanceCriteria: [
|
|
{ key: 'fields-complete', label: '八字段齐(PN/EAU/交期为必要三要素)', level: 'L1', predicate: 'missingKeyFields = 0' },
|
|
{ key: 'typed', label: '每条都已打标 A/B/C', level: 'L2', predicate: 'untyped = 0' },
|
|
{ key: 'downgrade-safe', label: '吃不准降 B,不许臆断 A', level: 'L3' },
|
|
{ key: 'owner-release', label: 'BD 放行', level: 'L5' },
|
|
],
|
|
prohibitions: [
|
|
{ key: 'no-guess-a', statement: '吃不准的一律降 B,不得臆断为 A' },
|
|
{ key: 'no-external-write', statement: '不得在放行前写任何外部系统' },
|
|
],
|
|
authorization: {
|
|
discretion: [{ key: 'ask-back', statement: '缺次要字段可受理并追问,缺 PN/数量/交期必须退回补全' }],
|
|
preauthorizedActions: [],
|
|
humanCallBudget: 4,
|
|
},
|
|
resources: {
|
|
tools: [{ name: 'crm.history-price-read' }],
|
|
skills: [],
|
|
models: ['quote-extractor'],
|
|
roles: ['BD'],
|
|
budget: { steps: 40, tokens: 120_000, activeMinutes: 60, humanCalls: 4 },
|
|
},
|
|
},
|
|
|
|
/* 声明 */
|
|
declarations: {
|
|
models: ['quote-extractor'],
|
|
tools: [{ name: 'crm.history-price-read' }],
|
|
ledger: [
|
|
{
|
|
domain: INTAKE_DOMAIN,
|
|
object: 'record',
|
|
label: '统一受理记录',
|
|
fields: [
|
|
{ name: 'customer_code', type: 'text', primaryKey: true, masked: false, label: '客户码' },
|
|
{ name: 'pn', type: 'text', primaryKey: true, masked: false, label: 'PN' },
|
|
{ name: 'brand', type: 'text', primaryKey: false, masked: false, label: '厂牌' },
|
|
{ name: 'eau', type: 'integer', primaryKey: false, masked: false, label: 'EAU' },
|
|
{ name: 'type_tag', type: 'text', primaryKey: false, masked: false, label: 'Type 标' },
|
|
{ name: 'target_price', type: 'number', primaryKey: false, masked: false, label: '目标价' },
|
|
{ name: 'lead_time', type: 'text', primaryKey: false, masked: false, label: '交期' },
|
|
{ name: 'status', type: 'text', primaryKey: false, masked: false, label: '状态' },
|
|
{ name: 'missing_key_fields', type: 'integer', primaryKey: false, masked: false, label: '缺关键字段数' },
|
|
],
|
|
},
|
|
{
|
|
domain: INTAKE_DOMAIN,
|
|
object: 'type_table',
|
|
label: '料号分类表',
|
|
fields: [
|
|
{ name: 'pn', type: 'text', primaryKey: true, masked: false },
|
|
{ name: 'type_tag', type: 'text', primaryKey: false, masked: false },
|
|
{ name: 'basis', type: 'text', primaryKey: false, masked: false, label: '分级依据' },
|
|
{ name: 'history_hit', type: 'boolean', primaryKey: false, masked: false, label: '历史价命中' },
|
|
// 打标的三个判据必须落表:S5 的 DMN 从这里读,不落就无米下锅
|
|
{ name: 'history_days', type: 'integer', primaryKey: false, masked: false, label: '距上次报价天数' },
|
|
{ name: 'market_stable', type: 'boolean', primaryKey: false, masked: false, label: '行情稳定' },
|
|
{ name: 'lifecycle', type: 'text', primaryKey: false, masked: false, label: '生命周期' },
|
|
],
|
|
},
|
|
],
|
|
listeners: [
|
|
{
|
|
origin: 'static',
|
|
eventType: 'human',
|
|
keyFilter: { kind: 'elicitation' },
|
|
semantic: 'complete-step',
|
|
// 时限必配 —— 悬空监听安装时拒绝
|
|
deadline: 'P1D',
|
|
escalation: ['nudge', 'escalate'],
|
|
},
|
|
],
|
|
harness: {
|
|
memoryWindow: 20,
|
|
// SLA:受理<15min、打标<45min —— 停滞检测按此设
|
|
stallAfter: 'PT45M',
|
|
nudge: [{ after: 'PT15M', action: 'nudge' }],
|
|
retry: { times: 2, backoff: 'PT30S' },
|
|
},
|
|
},
|
|
|
|
/* 资产初始版:flow = 步序声明 */
|
|
assets: {
|
|
businessModel: {
|
|
paradigm: 'flow',
|
|
steps: [
|
|
{
|
|
kind: 'llm',
|
|
name: 'S3_normalize',
|
|
label: 'S3 逐条解析归一',
|
|
input: { rfqRef: 'rfqRef', customerCode: 'customerCode', subject: 'subject', body: 'body' },
|
|
/*
|
|
* 出参路径要对得上**自己声明的 outputSchema**:模型回的是
|
|
* `{ records: [...], missingKeyFields }`,不是一堆扁平字段。
|
|
* MVP 逐条办的第一条 = `records.0`;`customerCode` 不在模型出参里,
|
|
* 它来自起单入参,由作用域补上。
|
|
*/
|
|
output: {
|
|
domain: INTAKE_DOMAIN,
|
|
object: 'record',
|
|
key: { customer_code: 'customerCode', pn: 'records.0.pn' },
|
|
fields: {
|
|
pn: 'records.0.pn',
|
|
brand: 'records.0.brand',
|
|
eau: 'records.0.eau',
|
|
target_price: 'records.0.targetPrice',
|
|
lead_time: 'records.0.leadTime',
|
|
// 完整度判定要有据可依:D1 的谓词读的就是它
|
|
missing_key_fields: 'missingKeyFields',
|
|
},
|
|
},
|
|
model: 'quote-extractor',
|
|
// 出参形状由网关按 outputSchema 统一附上,模板只讲**这件事本身**
|
|
template:
|
|
'按《询价受理规范》把下面这封询价拆解为逐条需求,逐条抄录 ' +
|
|
'pn(型号)/ brand(厂牌)/ eau(年用量,整数)/ targetPrice(目标价,数字)/ leadTime(交期)。' +
|
|
'原文没写的字段留空,不要编造;每缺一个关键字段(pn / eau / leadTime)就把 missingKeyFields 加一。\n\n' +
|
|
'询价单号:{{rfqRef}}\n客户编码:{{customerCode}}\n主题:{{subject}}\n正文:\n{{body}}',
|
|
outputSchema: {
|
|
type: 'object',
|
|
required: ['records'],
|
|
properties: {
|
|
records: {
|
|
type: 'array',
|
|
items: {
|
|
type: 'object',
|
|
required: ['pn'],
|
|
properties: {
|
|
pn: { type: 'string' },
|
|
brand: { type: 'string' },
|
|
eau: { type: 'integer' },
|
|
targetPrice: { type: 'number' },
|
|
leadTime: { type: 'string' },
|
|
},
|
|
},
|
|
},
|
|
missingKeyFields: { type: 'integer' },
|
|
},
|
|
},
|
|
view: 'intake-overview',
|
|
failure: { retry: { times: 2, backoff: 'PT30S' }, fallback: { kind: 'human', workOrder: 'execution' } },
|
|
},
|
|
{
|
|
kind: 'human',
|
|
name: 'S2_ask_back',
|
|
label: 'S2 追问补全信息',
|
|
// D1 判断完整度:缺 PN/数量/交期三要素才走补全 —— 条件必谓词,由引擎求值
|
|
when: 'missing_key_fields > 0',
|
|
input: {},
|
|
workOrder: 'execution',
|
|
card: { title: '缺关键字段,请向客户追问补全', fields: ['pn', 'eau', 'leadTime'] },
|
|
deadline: 'P1D',
|
|
failure: { retry: { times: 0, backoff: 'PT30S' }, fallback: { kind: 'blocked' } },
|
|
},
|
|
{
|
|
kind: 'tool',
|
|
name: 'S4_history',
|
|
label: 'S4 查历史价',
|
|
input: { pn: 'pn' },
|
|
// 情报四件全部落表:S5 打标要的就是这三件,只落 hit 会让下一步无米下锅
|
|
output: {
|
|
domain: INTAKE_DOMAIN,
|
|
object: 'type_table',
|
|
key: { pn: 'pn' },
|
|
fields: {
|
|
history_hit: 'hit',
|
|
history_days: 'historyDays',
|
|
market_stable: 'marketStable',
|
|
lifecycle: 'lifecycle',
|
|
},
|
|
},
|
|
tool: 'crm.history-price-read',
|
|
failure: { retry: { times: 2, backoff: 'PT1M' }, fallback: { kind: 'human', workOrder: 'execution' } },
|
|
},
|
|
{
|
|
kind: 'pure-tool',
|
|
name: 'S5_classify',
|
|
label: 'S5 逐条打标(DMN · 三分类规则 P-03)',
|
|
// 入参名 ← 作用域路径:作用域里是 S4 落表后的字段名
|
|
input: { historyDays: 'history_days', marketStable: 'market_stable', lifecycle: 'lifecycle' },
|
|
output: {
|
|
domain: INTAKE_DOMAIN,
|
|
object: 'type_table',
|
|
key: { pn: 'pn' },
|
|
fields: { type_tag: 'type', basis: 'play' },
|
|
},
|
|
tool: 'quote-intake.classify',
|
|
view: 'intake-classified',
|
|
failure: { retry: { times: 1, backoff: 'PT10S' }, fallback: { kind: 'blocked' } },
|
|
},
|
|
{
|
|
kind: 'human',
|
|
name: 'S6_release',
|
|
label: 'S6 分流复核与派单 · 验收放行',
|
|
input: {},
|
|
workOrder: 'acceptance',
|
|
card: { title: '统一受理记录(打标)请验收' },
|
|
view: 'intake-release',
|
|
deadline: 'P1D',
|
|
failure: { retry: { times: 0, backoff: 'PT30S' }, fallback: { kind: 'blocked' } },
|
|
},
|
|
],
|
|
parallelGroups: [],
|
|
},
|
|
skills: [],
|
|
// 三张模版对应三种局面(事态全景 / 进展 / 成果预览),由步序声明按位置推送
|
|
viewTemplates: [
|
|
{ name: 'intake-overview', html: INTAKE_OVERVIEW },
|
|
{ name: 'intake-classified', html: INTAKE_CLASSIFIED },
|
|
{ name: 'intake-release', html: INTAKE_RELEASE },
|
|
],
|
|
cardSchemas: {},
|
|
distillHooks: [
|
|
{
|
|
on: 'terminal',
|
|
prompt: '归纳本单受理归一的经验:字段缺口形态、打标依据、被驳回的理由。',
|
|
},
|
|
],
|
|
},
|
|
|
|
/* 样例集 —— 首装审以静态审 + 样例集替代回放审 */
|
|
samples: [
|
|
{
|
|
name: '车规 Analog 询价',
|
|
input: { customerCode: 'C001', rfqRef: 'mail:m-1001', subject: '询价 RFQ - 车规 Analog' },
|
|
expect: { ports: ['intake'] },
|
|
},
|
|
],
|
|
|
|
entry: { file: 'index.js', checksum: 'dev-entry-quote-intake' },
|
|
};
|