This commit is contained in:
@@ -3,7 +3,7 @@ from pathlib import Path
|
||||
from .provider import Provider,UnknownOutcome
|
||||
from providers.errors import known_model_unavailable, public_model_error
|
||||
|
||||
PUBLIC_CORE_FIELDS={'error_code','task_id','state','revision','title','eda_engine','delivery_revoked','metrics','questions','proposal','proposal_hash','selected_option','delivery','delivery_review','download_ready','manufacturing_package','error','findings','manufacturing_blockers','native_job_id'}
|
||||
PUBLIC_CORE_FIELDS={'error_code','task_id','state','revision','title','eda_engine','delivery_revoked','metrics','questions','proposal','proposal_hash','proposal_version','proposal_feedback','mounting_holes','selected_option','delivery','delivery_review','download_ready','manufacturing_package','error','findings','manufacturing_blockers','native_job_id'}
|
||||
|
||||
class Engine:
|
||||
def __init__(self,settings,store):
|
||||
|
||||
@@ -14,7 +14,7 @@ MAX_UPLOAD=64*1024*1024
|
||||
ALLOWED_EXT={'.pdf','.png','.jpg','.jpeg','.webp','.step','.stp','.dxf','.obj','.zip','.json','.txt','.md','.csv','.xlsx','.epro2','.eprj3'}
|
||||
ACTIONS={'create','message','select','advance','status','events','cancel','recover','review','accept'}
|
||||
PAYLOAD_FIELDS={'create':{'description','request','selection_policy','attachments'},
|
||||
'message':{'task_id','text','attachments'},'select':{'task_id','proposal_hash','option_id'},
|
||||
'message':{'task_id','text','attachments','proposal_hash'},'select':{'task_id','proposal_hash','option_id'},
|
||||
'events':{'task_id','after'},'review':{'task_id','manifest_sha256','accepted'},
|
||||
'accept':{'task_id','manifest_sha256','accepted'}}
|
||||
|
||||
|
||||
@@ -12,11 +12,11 @@ import zipfile
|
||||
from fastapi import HTTPException
|
||||
|
||||
MAX_EXPORT_BYTES = 256 * 1024 * 1024
|
||||
LABELS = {'assessing': '整理需求', 'needs_input': '等待补充需求', 'awaiting_selection': '等待选择方案',
|
||||
LABELS = {'assessing': '整理需求', 'needs_input': '等待补充需求', 'awaiting_selection': '等待审核方案',
|
||||
'designing': '正在设计与检查', 'exporting': '正在打包成果', 'needs_operator': '服务器自动恢复中',
|
||||
'draft_ready': '草稿:检查未通过', 'delivery_ready': '检查通过,等待审核',
|
||||
'completed': '已完成,可下载', 'failed': '本次设计未能完成', 'cancelled': '已取消'}
|
||||
REPORT = re.compile(r'^(?:erc|drc|drc-reopened|mechanical|final-audit|circuit-failure|repair-baseline|semantic|metrics|failure|schema-failure|attempt-\d+-failure|repair-\d+-(?:context|decision)|part-mechanical-preflight|selection-bindings|selection-native-\d+|selection-failure-\d+|native-checks|intake-check|plan-check|plan-review|pcb-(?:dsn-export|layout|placement-check|pad-resolution|routing-completion|connectivity-refresh|mechanical-geometry|mechanical-preflight|mechanical-check|pipeline|routing|net-mapping|drill-preservation|copper-audit|signal-angle-audit)|schematic-(?:net-plan|pin-plan|logical-netlist|wiring|wiring-check|layout|native-pin-aliases|sheet-history))\.json$')
|
||||
REPORT = re.compile(r'^(?:erc|drc|drc-reopened|mechanical|final-audit|circuit-failure|repair-baseline|semantic|metrics|failure|schema-failure|attempt-\d+-failure|repair-\d+-(?:context|decision)|part-mechanical-preflight|selection-bindings|selection-native-\d+|selection-failure-\d+|native-checks|intake-check|plan-check|plan-review|pcb-(?:dsn-export|layout|placement-check|pad-resolution|routing-completion|connectivity-refresh|mechanical-geometry|mechanical-preflight|mechanical-check|mounting-holes|pipeline|routing|net-mapping|drill-preservation|copper-audit|signal-angle-audit)|schematic-(?:net-plan|pin-plan|logical-netlist|wiring|wiring-check|layout|native-pin-aliases|sheet-history))\.json$')
|
||||
|
||||
|
||||
def json_bytes(value):
|
||||
@@ -118,7 +118,8 @@ def markdown(report):
|
||||
f"- 导出时间:{report['exported_at']}", f"- 完整执行记录:{report['event_count']} 条", '', report['snapshot_note'], '',
|
||||
'## 用户需求与补充', '']
|
||||
for index, entry in enumerate(report['conversation'], 1):
|
||||
lines += [f"### {index}. {entry.get('role', '')}", '', entry.get('text', ''), '']
|
||||
label = '方案评论' if entry.get('kind') == 'proposal_feedback' else entry.get('role', '')
|
||||
lines += [f"### {index}. {label}", '', entry.get('text', ''), '']
|
||||
lines += ['## 当前问题', *['- ' + q for q in task.get('questions', [])], '', '## 方案与选择', '']
|
||||
if plan.get('summary'):
|
||||
lines += [plan['summary'], '']
|
||||
|
||||
@@ -499,6 +499,12 @@ class EDAController:
|
||||
outlines=a.execute('return (await eda.pcb_PrimitivePolyline.getAll()).filter(p=>p.getState_Layer()===11).map(p=>({id:p.getState_PrimitiveId(),polygon:p.getState_Polygon().getSource()}));')
|
||||
from .drills import READ_DRILLS
|
||||
value={'parts':parts,'copper':copper,'outlines':outlines,'drills':a.execute(READ_DRILLS)}
|
||||
from .mounting import confirmed_holes, read_holes
|
||||
holes=confirmed_holes(t.get('request') or {})
|
||||
if holes:
|
||||
value['mounting_holes']=read_holes(a,holes)
|
||||
if len(value['mounting_holes'])!=len(holes):
|
||||
raise DesignError('保存后的 PCB 缺少已确认的安装孔。')
|
||||
else:
|
||||
value=a.execute('const f=await eda.sch_ManufactureData.getNetlistFile("persistence");'
|
||||
'const nl=JSON.parse(await f.text());const parts=[];for(const c of await eda.sch_PrimitiveComponent.getAll("part"))'
|
||||
|
||||
@@ -7,6 +7,7 @@ import math
|
||||
import re
|
||||
from collections import Counter
|
||||
from .board_policy import can_grow
|
||||
from .mounting import hole_geometry
|
||||
|
||||
EDGE, GAP = .6, .4
|
||||
|
||||
@@ -57,7 +58,7 @@ def _place_once(parts,board,holes,anchor):
|
||||
if not all(math.isfinite(v) and v>0 for v in (width,height)):raise ValueError('Invalid board dimensions')
|
||||
occupied=[];placed={};placed_shapes={};conflicts=[]
|
||||
for hole in holes:
|
||||
r=float(hole.get('diameter_mm',3))/2+1;x,y=float(hole['x_mm']),float(hole['y_mm'])
|
||||
r,x,y=hole_geometry(hole)
|
||||
occupied.append((x-r,y-r,x+r,y+r))
|
||||
frequency=Counter(n for p in parts for n in set(p['nets']) if n)
|
||||
options={p['id']:list(variants(p)) for p in parts}
|
||||
@@ -189,7 +190,7 @@ def audit_placement(parts,layout,holes=(),tolerance_mm=.06):
|
||||
for name,other in boxes:
|
||||
if not separated(r,other):errors.append('Component clearance conflict '+p['designator']+'/'+name)
|
||||
for hole in holes:
|
||||
radius=float(hole.get('diameter_mm',3))/2+1;x,y=float(hole['x_mm']),float(hole['y_mm'])
|
||||
radius,x,y=hole_geometry(hole)
|
||||
if not separated(r,(x-radius,y-radius,x+radius,y+radius)):errors.append('Mounting clearance conflict '+p['designator'])
|
||||
boxes.append((p['designator'],r))
|
||||
if {p['id'] for p in parts}!=set(expected):errors.append('Placement component identities changed')
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
"""Resolve mounting requirements before review and verify native NPTH geometry."""
|
||||
import math
|
||||
import re
|
||||
|
||||
from .state import DesignError, canonical
|
||||
from .pad_mapping import records
|
||||
|
||||
CLEARANCE_MM = {'2': 2.2, '2.5': 2.7, '3': 3.2, '4': 4.3}
|
||||
SCREW = re.compile(r'(?<![A-Za-z0-9])M\s*(2(?:\.5)?|3|4)(?!\d|\.\d)', re.I)
|
||||
HOLE_MARGIN_MM = 1.0
|
||||
NATIVE_TOLERANCE_MIL = .01
|
||||
|
||||
|
||||
def finite_number(value):
|
||||
try:
|
||||
return type(value) in (int, float) and math.isfinite(value)
|
||||
except OverflowError:
|
||||
return False
|
||||
|
||||
|
||||
def hole_geometry(hole):
|
||||
diameter = hole.get('diameter_mm', 3)
|
||||
x, y = hole.get('x_mm'), hole.get('y_mm')
|
||||
if not all(finite_number(v) for v in (diameter, x, y)) or diameter <= 0:
|
||||
raise DesignError(f"请先确定安装孔 {hole.get('id', '')} 的孔径和坐标(mm)。")
|
||||
return diameter / 2 + HOLE_MARGIN_MM, x, y
|
||||
|
||||
|
||||
def plan_holes(request):
|
||||
"""Keep explicit geometry. Offer symmetric defaults for a free rectangular board."""
|
||||
mounting = request.get('mounting') or {}
|
||||
holes = [dict(hole) for hole in mounting.get('holes', [])]
|
||||
count = mounting.get('hole_count')
|
||||
if not holes and not count:
|
||||
if mounting.get('requirement') == 'required':
|
||||
raise DesignError('请补充需要几个安装孔,以及螺钉规格或孔径。')
|
||||
return []
|
||||
if count is not None and (type(count) is not int or count < 1 or holes and len(holes) != count):
|
||||
raise DesignError('安装孔数量与孔位列表不一致,请确认所需的孔数和孔位。')
|
||||
if not holes:
|
||||
if count not in (1, 2, 4):
|
||||
raise DesignError('请提供各安装孔的位置,或给出可以确定孔位的尺寸图。')
|
||||
holes = [{'id': f'MH{i + 1}', 'diameter_mm': None, 'x_mm': None,
|
||||
'y_mm': None, 'plating': 'unknown'} for i in range(count)]
|
||||
|
||||
board = request['board']
|
||||
width, height = board.get('width_mm'), board.get('height_mm')
|
||||
if not all(finite_number(v) and v > 0 for v in (width, height)):
|
||||
raise DesignError('请给出板宽和板高,以便确定安装孔能否放下。')
|
||||
ids = [h['id'] for h in holes]
|
||||
if len(ids) != len(set(ids)):
|
||||
raise DesignError('安装孔位号重复,请确认各孔的位置和数量。')
|
||||
for hole in holes:
|
||||
if hole.get('plating') == 'pth':
|
||||
raise DesignError(f"安装孔 {hole['id']} 指定了镀铜。当前自动布局支持非金属化定位孔,请确认能否改用非金属化孔。")
|
||||
if hole.get('diameter_mm') is None:
|
||||
sizes = set(SCREW.findall(hole.get('notes') or '')) or set(SCREW.findall(mounting.get('description') or ''))
|
||||
if len(sizes) != 1:
|
||||
raise DesignError(f"请提供安装孔 {hole['id']} 的孔径(mm)或明确的螺钉规格。")
|
||||
hole['diameter_mm'] = CLEARANCE_MM[sizes.pop()]
|
||||
if not finite_number(hole['diameter_mm']) or hole['diameter_mm'] <= 0:
|
||||
raise DesignError(f"请提供安装孔 {hole['id']} 的有效孔径(mm)。")
|
||||
hole['plating'] = 'npth'
|
||||
|
||||
coordinates = [(h.get('x_mm'), h.get('y_mm')) for h in holes]
|
||||
if any(None in point for point in coordinates):
|
||||
fixed_geometry = mounting.get('asset_ids') or mounting.get('spacing_constraints') or board.get('outline_asset_id')
|
||||
if (fixed_geometry or board.get('shape', 'rectangle') != 'rectangle'
|
||||
or len(holes) not in (1, 2, 4) or any(point != (None, None) for point in coordinates)):
|
||||
raise DesignError('请补充每个安装孔相对板子左下角的 X、Y 坐标(mm),以保留指定的孔距或机械约束。')
|
||||
inset = max(4.0, max(h['diameter_mm'] / 2 for h in holes) + HOLE_MARGIN_MM + .6)
|
||||
if len(holes) == 1:
|
||||
positions = [(width / 2, inset)]
|
||||
elif len(holes) == 2:
|
||||
positions = [(inset, inset), (width - inset, inset)]
|
||||
else:
|
||||
positions = [(inset, inset), (width - inset, inset),
|
||||
(width - inset, height - inset), (inset, height - inset)]
|
||||
for hole, (x, y) in zip(holes, positions):
|
||||
hole.update(x_mm=round(x, 3), y_mm=round(y, 3))
|
||||
|
||||
for index, hole in enumerate(holes):
|
||||
radius, x, y = hole_geometry(hole)
|
||||
if min(x, y, width - x, height - y) < radius:
|
||||
raise DesignError(f"安装孔 {hole['id']} 与板边距离不足,请调整孔位或板框。")
|
||||
for previous in holes[:index]:
|
||||
other_radius, other_x, other_y = hole_geometry(previous)
|
||||
if math.hypot(x - other_x, y - other_y) < radius + other_radius:
|
||||
raise DesignError(f"安装孔 {hole['id']} 和 {previous['id']} 间距不足,请调整孔位。")
|
||||
by_id = {hole['id']: hole for hole in holes}
|
||||
for constraint in mounting.get('spacing_constraints', []):
|
||||
a = by_id.get(constraint['from_hole'])
|
||||
b = by_id.get(constraint['to_hole'])
|
||||
if not a or not b:
|
||||
raise DesignError('孔距约束引用了未知安装孔,请确认位号和坐标。')
|
||||
dx, dy = abs(a['x_mm'] - b['x_mm']), abs(a['y_mm'] - b['y_mm'])
|
||||
spacing = {'x': dx, 'y': dy, 'distance': math.hypot(dx, dy)}[constraint['axis']]
|
||||
if not math.isclose(spacing, constraint['center_spacing_mm'], rel_tol=0, abs_tol=.001):
|
||||
raise DesignError(f"安装孔 {a['id']} 和 {b['id']} 的坐标与指定孔距不一致,请确认。")
|
||||
return holes
|
||||
|
||||
|
||||
def confirmed_holes(request):
|
||||
holes = plan_holes(request)
|
||||
if holes != ((request.get('mounting') or {}).get('holes') or []):
|
||||
raise DesignError('这版方案的安装孔尺寸尚未确认。请通过方案评论重新生成,再审核孔径和位置。')
|
||||
return holes
|
||||
|
||||
|
||||
def hole_readback(source, holes):
|
||||
"""An empty multilayer circular fill is exported by EasyEDA as a round NPTH."""
|
||||
circles = []
|
||||
for header, body in records(source):
|
||||
if header.get('type') != 'FILL' or body.get('layerId') != 12 or body.get('netName'):
|
||||
continue
|
||||
paths = body.get('path')
|
||||
if isinstance(paths, list) and len(paths) == 1:
|
||||
path = paths[0]
|
||||
if isinstance(path, list) and len(path) == 4 and path[0] == 'CIRCLE':
|
||||
circles.append((header['id'], path[1:]))
|
||||
found = {}
|
||||
for hole in holes:
|
||||
expected = (hole['x_mm'] / .0254, hole['y_mm'] / .0254, hole['diameter_mm'] / .0508)
|
||||
matches = [identity for identity, actual in circles
|
||||
if all(abs(a - b) <= NATIVE_TOLERANCE_MIL for a, b in zip(actual, expected))]
|
||||
if len(matches) > 1:
|
||||
raise DesignError(f"安装孔 {hole['id']} 的原生几何重复。")
|
||||
if matches:
|
||||
found[hole['id']] = matches[0]
|
||||
return found
|
||||
|
||||
|
||||
def read_holes(adapter, holes):
|
||||
source = adapter.execute('return await eda.sys_FileManager.getDocumentSource();')
|
||||
return hole_readback(source, holes)
|
||||
|
||||
|
||||
def ensure_native_holes(controller, task, holes):
|
||||
adapter = controller.adapter(task)
|
||||
present = read_holes(adapter, holes)
|
||||
missing = [h for h in holes if h['id'] not in present]
|
||||
if missing:
|
||||
controller.remote(task, 'pcb_mounting_holes',
|
||||
'const holes='+canonical(missing)+';'
|
||||
'for(const h of holes){const p=eda.pcb_MathPolygon.createPolygon(["CIRCLE",h.x_mm/.0254,h.y_mm/.0254,h.diameter_mm/.0508]);'
|
||||
'const drill=await eda.pcb_PrimitiveFill.create(12,p,"",0,10,false);'
|
||||
'if(!drill)throw Error("Mounting hole creation failed: "+h.id);}'
|
||||
'await eda.pcb_Document.save();return true;')
|
||||
result = read_holes(adapter, holes)
|
||||
if len(result) != len(holes):
|
||||
raise DesignError('安装孔写入后的原生回读不完整。')
|
||||
return result
|
||||
@@ -6,6 +6,7 @@ from .layout import place, power_net, placement_moves, audit_placement
|
||||
from .pad_mapping import compare_nets, resolve, collect_evidence
|
||||
from .connector_geometry import constraints as connector_constraints
|
||||
from .drills import READ_DRILLS,compare as compare_drills
|
||||
from .mounting import confirmed_holes, ensure_native_holes
|
||||
|
||||
|
||||
READ_PARTS = '''
|
||||
@@ -57,6 +58,8 @@ def signal_angle_audit(copper):
|
||||
|
||||
def build(controller,t):
|
||||
from .eda import CREATE_FOOTPRINTS_JS
|
||||
request=t['request']
|
||||
holes=confirmed_holes(request)
|
||||
a=controller.adapter(t)
|
||||
work=controller.state.path(t['task_id'])/'project/work'
|
||||
controller.focus(t,'schematic')
|
||||
@@ -107,8 +110,6 @@ def build(controller,t):
|
||||
netcheck=compare_nets(nl,parts,pad_evidence);write(work/'pcb-net-mapping.json',netcheck)
|
||||
if not netcheck['passed']:raise DesignError('PCB net assignment readback failed: '+'; '.join(netcheck['errors']))
|
||||
blockers=[]
|
||||
if (t['request'].get('mounting') or {}).get('holes'):
|
||||
blockers.append('Mechanical mounting hole geometry requires review')
|
||||
measured=[]
|
||||
for p in parts:
|
||||
box=p.get('bbox')
|
||||
@@ -122,7 +123,6 @@ def build(controller,t):
|
||||
'y':(pin['y']-(box['minY']+box['maxY'])/2)*.0254} for pin in p['pads']],
|
||||
'dx':((box['minX']+box['maxX'])/2-p['x'])*.0254,
|
||||
'dy':((box['minY']+box['maxY'])/2-p['y'])*.0254})
|
||||
request=t['request'];holes=(request.get('mounting') or {}).get('holes') or []
|
||||
layout=place(measured,request['board'],holes)
|
||||
write(work/'pcb-layout.json',layout)
|
||||
blockers.extend(layout['conflicts'])
|
||||
@@ -153,6 +153,9 @@ def build(controller,t):
|
||||
drill_check=compare_drills(drill_baseline,a.execute(READ_DRILLS))
|
||||
write(work/'pcb-drill-preservation.json',drill_check)
|
||||
if not drill_check['passed']:raise DesignError('Placement altered drill geometry')
|
||||
if holes:
|
||||
native_holes=ensure_native_holes(controller,t,holes)
|
||||
write(work/'pcb-mounting-holes.json',{'passed':True,'holes':holes,'primitive_ids':native_holes})
|
||||
from .mechanical import collect as collect_mechanical, audit as audit_mechanical
|
||||
mechanical=collect_mechanical(a,parts)
|
||||
write(work/'pcb-mechanical-geometry.json',mechanical)
|
||||
|
||||
@@ -18,6 +18,7 @@ from .eda import EDAController,RetryableEDA
|
||||
from . import delivery as D
|
||||
from . import schematic as S
|
||||
from .part_metadata import selection_properties
|
||||
from .mounting import confirmed_holes, plan_holes
|
||||
|
||||
|
||||
class Cancelled(DesignError):pass
|
||||
@@ -31,7 +32,7 @@ class DesignService:
|
||||
self.blender,self.max_rounds=blender,max_rounds
|
||||
def close(self):self.state.close()
|
||||
def public(self,t):
|
||||
fields=['error_code','eda_engine','title','delivery_revoked','task_id','state','revision','questions','proposal','proposal_hash','selected_option','delivery','delivery_review','download_ready','manufacturing_package','error','findings','manufacturing_blockers','native_job_id']
|
||||
fields=['error_code','eda_engine','title','delivery_revoked','task_id','state','revision','questions','proposal','proposal_hash','proposal_version','proposal_feedback','mounting_holes','selected_option','delivery','delivery_review','download_ready','manufacturing_package','error','findings','manufacturing_blockers','native_job_id']
|
||||
result={key:t[key] for key in fields if key in t}
|
||||
if self._cancelled(t) and t['state'] not in {'completed','delivery_ready','draft_ready','cancelled'}:
|
||||
result['state']='cancelled' if t['state'] in {'needs_input','awaiting_selection'} else 'cancel_requested'
|
||||
@@ -160,7 +161,7 @@ class DesignService:
|
||||
action=message['action'];p=message['payload']
|
||||
if not isinstance(p,dict):raise DesignError('payload must be an object')
|
||||
allowed={'create':{'description','request','selection_policy','attachments'},
|
||||
'message':{'task_id','text','attachments'},'select':{'task_id','proposal_hash','option_id'},
|
||||
'message':{'task_id','text','attachments','proposal_hash'},'select':{'task_id','proposal_hash','option_id'},
|
||||
'advance':{'task_id'},'recover':{'task_id','native_resolution'},
|
||||
'review':{'task_id','manifest_sha256','accepted'},'accept':{'task_id','manifest_sha256','accepted'},'cancel':{'task_id'},
|
||||
'status':{'task_id'},'events':{'task_id','after'}}
|
||||
@@ -186,8 +187,14 @@ class DesignService:
|
||||
with lock(self.state.root/'dispatch.lock'):
|
||||
t=self._create(p);self.state.save(t,origin_request_id=message['request_id']);result=self._advance_guarded(t)
|
||||
else:
|
||||
t=self.state.get(p.get('task_id'))
|
||||
with lock(self.state.root/'dispatch.lock'),lock(self._path(t)/'task.lock'):
|
||||
task_id=p.get('task_id')
|
||||
with lock(self.state.root/'dispatch.lock'),lock(self.state.path(task_id)/'task.lock'):
|
||||
t=self.state.get(task_id)
|
||||
if action=='message' and 'proposal_hash' in p:
|
||||
if t['state']!='awaiting_selection' or p['proposal_hash']!=t.get('proposal_hash'):
|
||||
raise DesignError('方案已变化,请查看最新版后再发表评论。')
|
||||
if len(p['text'].strip())>3000:
|
||||
raise DesignError('方案评论最多 3000 字。')
|
||||
if self._cancelled(t) and action!='recover':raise DesignError('Task cancelled; create a new task')
|
||||
if action=='message' and t['state']=='needs_operator' and not t.get('native_job_id') and not t.get('active_agent_call'):
|
||||
# A design blocked on a user decision (for example approving connector parts) may be
|
||||
@@ -202,10 +209,19 @@ class DesignService:
|
||||
elif action=='message':
|
||||
if t['state'] not in {'needs_input','awaiting_selection'}:raise DesignError('Answers are accepted only before design; create a new task for a changed design')
|
||||
if not isinstance(p.get('text'),str) or not p['text'].strip():raise DesignError('Nonempty answer required')
|
||||
t['conversation'].append({'role':'user','text':p['text']})
|
||||
t['intake_version']+=1
|
||||
self._attach(t,p.get('attachments',[]))
|
||||
entry={'role':'user','text':p['text'].strip()}
|
||||
if t['state']=='awaiting_selection':
|
||||
entry.update(kind='proposal_feedback',proposal_hash=t['proposal_hash'])
|
||||
t['proposal_feedback']=entry['text']
|
||||
t['revision_input']={'previous_proposal':t['proposal'], 'comment':entry['text']}
|
||||
t['auto_authorized']=False
|
||||
t['conversation'].append(entry)
|
||||
t['intake_version']+=1
|
||||
self.state.save(t,state='assessing',proposal=None,proposal_hash=None,questions=[],error=None)
|
||||
if entry.get('kind')=='proposal_feedback':
|
||||
self.state.event(t['task_id'],'proposal.revision_requested',
|
||||
{'proposal_hash':entry['proposal_hash']},snapshot=self.public(t))
|
||||
result=self._advance_guarded(t)
|
||||
elif action=='select':
|
||||
self._select(t,p)
|
||||
@@ -278,7 +294,9 @@ class DesignService:
|
||||
def _assess(self,t):
|
||||
version=t['intake_version'];project=self._path(t)/'project'
|
||||
from .board_policy import intake_schema, bind_size_policy
|
||||
revision=t.get('revision_input')
|
||||
intake=self._agent(t,'intake',{'conversation':t['conversation'],'assets':t['assets'],
|
||||
'proposal_revision':revision,
|
||||
'request_schema':intake_schema(load(PACK/'schemas/request.schema.json')),'server_project_id':t['task_id'],
|
||||
'instruction':'Normalize supplied requirements into request_json. Ask concise plain-language questions ONLY before design when '
|
||||
'missing or conflicting facts change circuit behavior, voltage safety, required interface or mechanical fit. '
|
||||
@@ -289,13 +307,26 @@ class DesignService:
|
||||
'Set board.size_origin=user_requirement only for an explicit user dimensional/enclosure constraint and copy its exact text into size_evidence. '
|
||||
'If the user leaves size to engineering (including a reference picture with no dimensional requirement), set size_origin=ai_provisional, '
|
||||
'size_evidence explaining the assumption, and choose an initial envelope. A provisional envelope is adjustable after measuring footprints; '
|
||||
'never label it a hard maximum. If the source is ambiguous, use unknown.'},
|
||||
'never label it a hard maximum. If the source is ambiguous, use unknown. '
|
||||
'For proposal feedback, keep requirements the user did not change. '
|
||||
'Record the requested screw size, hole count, explicit hole coordinates and spacing in mounting. '
|
||||
'If the user gives a common screw size and count and delegates layout, leave unset dimensions as null for the fixed planner instead of asking for them.'},
|
||||
C.INTAKE,f'intake-{version}')
|
||||
request=json.loads(intake['request_json']);request['project_id']=t['task_id'];request['selection_policy']=t['selection_policy']
|
||||
request=self._fill_defaults(request)
|
||||
request=bind_size_policy(request,t['conversation'],t['assets'])
|
||||
write(project/'inputs/request.json',request);t['request']=request
|
||||
questions=list(intake.get('questions') or [])
|
||||
try:
|
||||
holes=plan_holes(request)
|
||||
except DesignError as exc:
|
||||
holes=[]
|
||||
questions.append(str(exc))
|
||||
else:
|
||||
if holes:
|
||||
request['mounting'].update(holes=holes,hole_count=len(holes))
|
||||
write(project/'inputs/request.json',request)
|
||||
t['request']=request
|
||||
t['mounting_holes']=holes
|
||||
if not request.get('power_inputs'):
|
||||
questions.append('这块板由什么电源供电,输入电压是多少?')
|
||||
if questions:
|
||||
@@ -320,12 +351,15 @@ class DesignService:
|
||||
plan_schema['properties']['schema_version']['type']='string'
|
||||
plan_schema['properties']['selection']={'type':'null'}
|
||||
proposal=self._agent(t,'proposal',{'request':request,'pending':report.get('pending') or [],'assets':t['assets'],'references':self._reference_digest(t),
|
||||
'proposal_revision':revision,
|
||||
'reference_root':str(REF_ROOT),'project_root':str(project),'plan_schema':plan_schema,
|
||||
'instruction':'Return the plan object directly, matching plan_schema with selection=null. Do not wrap it in a string or plan_json field. Keep going with documented assumptions instead of blocking: '
|
||||
'the user delegates part choice and verification to you. Do not list missing manufacturer drawings or library IDs as blockers; '
|
||||
'they are resolved in the design phase. Prioritize a complete minimum reference circuit. Distinguish user-required features '
|
||||
'from optional additions; do not turn optional extra protection/features into mandatory scope. '
|
||||
'One clear option is enough; add a second only if it is a real alternative. '
|
||||
'When proposal_revision is present, revise that proposal to address the user comment and summarize the changes in the option implementation. '
|
||||
'Treat any resolved mounting holes in request.mounting as exact geometry to be reviewed by the user. '
|
||||
'Keep implementation under 1200 characters, at most 3 advantages/disadvantages per option, '
|
||||
'and at most 6 resolved requirements and 6 assumptions. Do not repeat the full request in each field.'},
|
||||
plan_schema,f'proposal-object-{version}')
|
||||
@@ -346,13 +380,16 @@ class DesignService:
|
||||
write(project/'work/plan-review.json',plan_review)
|
||||
if not plan_review['approved']:
|
||||
self.state.event(t['task_id'],'plan.review_overridden',{'findings':[str(f)[:160] for f in (plan_review.get('findings') or [])[:4]]})
|
||||
self.state.save(t,state='awaiting_selection',questions=[],proposal=plan,proposal_hash=sha(plan))
|
||||
t.pop('revision_input',None)
|
||||
self.state.save(t,state='awaiting_selection',questions=[],proposal=plan,proposal_hash=sha(plan),
|
||||
proposal_version=version,error=None,error_code=None)
|
||||
self.state.event(t['task_id'],'proposal.ready',{'proposal_hash':t['proposal_hash']})
|
||||
if t['auto_authorized']:
|
||||
self._select(t,{'proposal_hash':t['proposal_hash'],'option_id':plan['recommended_option_id']},automatic=True)
|
||||
def _select(self,t,p,automatic=False):
|
||||
if t['state']!='awaiting_selection' or p.get('proposal_hash')!=t['proposal_hash']:raise DesignError('Stale proposal or invalid selection state')
|
||||
if p.get('option_id') not in {o['id'] for o in t['proposal']['options']}:raise DesignError('Unknown option ID')
|
||||
confirmed_holes(t['request'])
|
||||
plan=t['proposal'];selection={'option_id':p['option_id'],'basis':'delegated_auto' if automatic else 'user_choice',
|
||||
'evidence':'Explicit create.selection_policy=auto' if automatic else 'Caller-supplied local selection event bound to proposal '+t['proposal_hash'],
|
||||
'recorded_at':datetime.now(timezone.utc).isoformat()}
|
||||
|
||||
@@ -67,11 +67,13 @@ class State:
|
||||
def get(self,tid):return load(self.path(tid)/'task.json')
|
||||
def save(self,t,**updates):
|
||||
t.update(updates);t['updated_at']=time.time();write(self.path(t['task_id'])/'task.json',t)
|
||||
def event(self,tid,kind,data):
|
||||
def event(self,tid,kind,data,snapshot=None):
|
||||
created=time.time()
|
||||
cursor=self.db.execute('INSERT INTO events(task_id,kind,data,created) VALUES(?,?,?,?)',(tid,kind,canonical(data),created))
|
||||
if self.event_callback:
|
||||
try:self.event_callback({'seq':cursor.lastrowid,'task_id':tid,'kind':kind,'data':data,'created':created})
|
||||
event={'seq':cursor.lastrowid,'task_id':tid,'kind':kind,'data':data,'created':created}
|
||||
if snapshot is not None:event['snapshot']=snapshot
|
||||
try:self.event_callback(event)
|
||||
except Exception:pass # Observers must not change a committed business transition.
|
||||
def begin_request(self,rid,payload):
|
||||
if not isinstance(rid,str) or not 1<=len(rid)<=128:raise DesignError('request_id must contain 1..128 characters')
|
||||
|
||||
@@ -120,6 +120,10 @@
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"proposal_hash": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"attachments": {
|
||||
"type": "array",
|
||||
"maxItems": 32,
|
||||
|
||||
@@ -22,7 +22,7 @@ from .selection import PartSelectionError
|
||||
|
||||
|
||||
TERMINAL = {'delivery_ready', 'draft_ready', 'completed', 'cancelled', 'failed', 'needs_input', 'awaiting_selection'}
|
||||
FIELDS = ['task_id', 'state', 'revision', 'title', 'eda_engine', 'delivery_revoked', 'questions', 'proposal', 'proposal_hash',
|
||||
FIELDS = ['task_id', 'state', 'revision', 'title', 'eda_engine', 'delivery_revoked', 'questions', 'proposal', 'proposal_hash', 'proposal_version', 'proposal_feedback',
|
||||
'selected_option', 'delivery', 'download_ready', 'manufacturing_package', 'error', 'findings', 'manufacturing_blockers', 'metrics']
|
||||
|
||||
|
||||
@@ -128,7 +128,8 @@ class NativeService:
|
||||
description = '\n'.join(c['text'] for c in task['conversation'])
|
||||
plan = self.agent(task).call('plan', {'conversation': task['conversation'], 'attachments': text,
|
||||
'common_installed_parts': COMMON, 'common_parts_are_examples_only': True,
|
||||
'instruction': 'Normalize requirements and propose one complete minimum design. Common parts are NON-EXHAUSTIVE EXAMPLES, never an allowed-model list. Unlisted real models and compatible generic/family symbols are permitted; do not report unavailable solely because a model is absent from examples or the local hint catalogue. Use exact installed symbol and footprint IDs when known, with a complete BOM. Preserve full manufacturer ordering codes and functional differences between variants. Give every capacitor and resistor an engineering value. All near fields must be an exact other component reference or empty. Questions only before design for circuit-changing unknowns. Respond in concise Chinese prose except technical identifiers.'}, schemas.PLAN, images=images)
|
||||
'proposal_revision': task.get('revision_input'),
|
||||
'instruction': 'Normalize requirements and propose one complete minimum design. When proposal_revision is present, revise the previous plan according to the latest comment and keep other requirements. Common parts are NON-EXHAUSTIVE EXAMPLES, never an allowed-model list. Unlisted real models and compatible generic/family symbols are permitted; do not report unavailable solely because a model is absent from examples or the local hint catalogue. Use exact installed symbol and footprint IDs when known, with a complete BOM. Preserve full manufacturer ordering codes and functional differences between variants. Give every capacitor and resistor an engineering value. All near fields must be an exact other component reference or empty. Questions only before design for circuit-changing unknowns. Respond in concise Chinese prose except technical identifiers.'}, schemas.PLAN, images=images)
|
||||
plan = normalize_plan(plan, description)
|
||||
if plan['questions']:
|
||||
self.state.save(task, state='needs_input', questions=plan['questions'], plan=plan)
|
||||
@@ -181,7 +182,10 @@ class NativeService:
|
||||
'advantages': ['原生可编辑工程与检查记录', '通过检查后提供完整 PCB 下载包'],
|
||||
'disadvantages': ['软件检查不代替样机电气、热与 EMC 验证']}],
|
||||
'recommended_option_id': 'A', 'assumptions': plan['assumptions'], 'requirements': plan['requirements']}
|
||||
self.state.save(task, state='awaiting_selection', questions=[], proposal=proposal, proposal_hash=digest(proposal),
|
||||
version = task.get('proposal_version', 1)
|
||||
task.pop('revision_input', None)
|
||||
self.state.save(task, state='awaiting_selection', questions=[], proposal=proposal,
|
||||
proposal_version=version, proposal_hash=digest({'version': version, 'proposal': proposal}),
|
||||
findings=plan['assumptions'], error=None)
|
||||
self.snapshot(task, 'proposal.ready')
|
||||
if task['selection_policy'] == 'auto':
|
||||
@@ -316,9 +320,23 @@ class NativeService:
|
||||
raise StateError('需求补充仅在设计开始前接收')
|
||||
if not isinstance(payload.get('text'), str) or not payload['text'].strip():
|
||||
raise StateError('补充内容不能为空')
|
||||
task['conversation'].append({'role': 'user', 'text': payload['text']})
|
||||
if 'proposal_hash' in payload:
|
||||
if task['state'] != 'awaiting_selection' or payload['proposal_hash'] != task.get('proposal_hash'):
|
||||
raise StateError('方案已变化,请查看最新版后再发表评论。')
|
||||
if len(payload['text'].strip()) > 3000:
|
||||
raise StateError('方案评论最多 3000 字。')
|
||||
self.attachments(task, payload.get('attachments', []))
|
||||
self.state.save(task, state='assessing')
|
||||
entry = {'role': 'user', 'text': payload['text'].strip()}
|
||||
if task['state'] == 'awaiting_selection':
|
||||
entry.update(kind='proposal_feedback', proposal_hash=task['proposal_hash'])
|
||||
task['proposal_version'] = task.get('proposal_version', 1) + 1
|
||||
task['proposal_feedback'] = entry['text']
|
||||
task['revision_input'] = {'previous_plan': task.get('plan') or task['proposal'], 'comment': entry['text']}
|
||||
task['selection_policy'] = 'propose'
|
||||
task['conversation'].append(entry)
|
||||
self.state.save(task, state='assessing', proposal=None, proposal_hash=None, error=None)
|
||||
if entry.get('kind') == 'proposal_feedback':
|
||||
self.snapshot(task, 'proposal.revision_requested')
|
||||
result = self.advance(task)
|
||||
elif action == 'advance':
|
||||
result = self.advance(task)
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
"""Regression checks for repeatable proposal review and null mounting geometry."""
|
||||
from copy import deepcopy
|
||||
import json
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
BACKEND = Path(__file__).resolve().parents[1]
|
||||
sys.path[:0] = [str(BACKEND / 'easyeda_backend'), str(BACKEND)]
|
||||
|
||||
from design_runtime.layout import place
|
||||
from design_runtime.mounting import confirmed_holes, plan_holes
|
||||
from design_runtime.service import DesignService
|
||||
from design_runtime.state import DesignError
|
||||
|
||||
|
||||
def request_with_holes():
|
||||
return {
|
||||
'board': {'width_mm': 45, 'height_mm': 75, 'shape': 'rectangle'},
|
||||
'power_inputs': [{'id': 'VIN'}],
|
||||
'mounting': {
|
||||
'requirement': 'required', 'description': '四个M2定位孔',
|
||||
'hole_count': 4, 'asset_ids': [], 'spacing_constraints': [],
|
||||
'holes': [{'id': f'MH{i}', 'diameter_mm': None, 'x_mm': None,
|
||||
'y_mm': None, 'plating': 'unknown'} for i in range(1, 5)],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class MountingTests(unittest.TestCase):
|
||||
def test_delegated_four_hole_pattern_reaches_layout(self):
|
||||
request = request_with_holes()
|
||||
original = deepcopy(request)
|
||||
holes = plan_holes(request)
|
||||
self.assertEqual(request, original)
|
||||
self.assertEqual([(h['x_mm'], h['y_mm']) for h in holes],
|
||||
[(4, 4), (41, 4), (41, 71), (4, 71)])
|
||||
self.assertTrue(all(h['diameter_mm'] == 2.2 and h['plating'] == 'npth' for h in holes))
|
||||
with self.assertRaisesRegex(DesignError, '尚未确认'):
|
||||
confirmed_holes(request)
|
||||
request['mounting']['holes'] = holes
|
||||
self.assertTrue(place([], request['board'], confirmed_holes(request))['passed'])
|
||||
|
||||
def test_mechanical_constraints_block_guessed_positions(self):
|
||||
request = request_with_holes()
|
||||
request['mounting']['asset_ids'] = ['asset-drawing']
|
||||
with self.assertRaisesRegex(DesignError, 'X、Y 坐标'):
|
||||
plan_holes(request)
|
||||
|
||||
def test_legacy_null_layout_is_reported_as_incomplete_geometry(self):
|
||||
request = request_with_holes()
|
||||
with self.assertRaisesRegex(DesignError, 'MH1.*孔径和坐标'):
|
||||
place([], request['board'], request['mounting']['holes'])
|
||||
|
||||
|
||||
class ProposalReviewTests(unittest.TestCase):
|
||||
def test_two_comment_rounds_and_confirmation_of_current_proposal_only(self):
|
||||
events, contexts = [], []
|
||||
|
||||
def agent(task, role, payload, schema, name):
|
||||
if role == 'intake':
|
||||
return {'request_json': json.dumps(request_with_holes()), 'questions': []}
|
||||
self.assertEqual(role, 'proposal')
|
||||
contexts.append(payload)
|
||||
return {'options': [{'id': 'A'}], 'recommended_option_id': 'A'}
|
||||
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
service = DesignService(directory, event_callback=events.append)
|
||||
self.addCleanup(service.close)
|
||||
with (patch.object(service, '_agent', side_effect=agent),
|
||||
patch.object(service, '_design') as design,
|
||||
patch('design_runtime.service.check', return_value={'design_allowed': True}),
|
||||
patch('design_runtime.service.search', return_value={'catalog_complete': True, 'matches': []})):
|
||||
task = service.handle({'request_id': 'create', 'action': 'create',
|
||||
'payload': {'description': '45×75 mm,四个M2孔'}})
|
||||
first_hash = task['proposal_hash']
|
||||
tid = task['task_id']
|
||||
for index, comment in enumerate(('把电源接口移到左边', '保留接口位置,补充 USB 保护'), 1):
|
||||
previous = task
|
||||
command = {'request_id': f'comment-{index}', 'action': 'message',
|
||||
'payload': {'task_id': tid, 'proposal_hash': previous['proposal_hash'], 'text': comment}}
|
||||
task = service.handle(command)
|
||||
self.assertEqual(task['state'], 'awaiting_selection')
|
||||
self.assertEqual(task['proposal_version'], index + 1)
|
||||
self.assertNotEqual(task['proposal_hash'], previous['proposal_hash'])
|
||||
self.assertEqual(task['proposal_feedback'], comment)
|
||||
self.assertEqual(contexts[-1]['proposal_revision'],
|
||||
{'previous_proposal': previous['proposal'], 'comment': comment})
|
||||
self.assertEqual(len(task['mounting_holes']), 4)
|
||||
self.assertEqual(service.handle(command), task)
|
||||
invalid = service.handle({'request_id': 'old-confirmation', 'action': 'select',
|
||||
'payload': {'task_id': tid, 'proposal_hash': first_hash, 'option_id': 'A'}})
|
||||
self.assertIn('Stale proposal', invalid['message'])
|
||||
design.assert_not_called()
|
||||
current = service.handle({'request_id': 'confirm', 'action': 'select',
|
||||
'payload': {'task_id': tid, 'proposal_hash': task['proposal_hash'], 'option_id': 'A'}})
|
||||
self.assertEqual(current['state'], 'designing')
|
||||
design.assert_called_once()
|
||||
saved = service.state.get(tid)
|
||||
self.assertEqual([c['kind'] for c in saved['conversation'][1:]], ['proposal_feedback'] * 2)
|
||||
self.assertEqual(len(confirmed_holes(saved['contract']['request'])), 4)
|
||||
self.assertEqual([e['snapshot']['state'] for e in events if e['kind'] == 'proposal.revision_requested'],
|
||||
['assessing', 'assessing'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -52,6 +52,8 @@ function remember(key: string, value: string | null) {
|
||||
const eventNames: Record<string, string> = {
|
||||
'agent.started': '模型开始处理',
|
||||
'agent.completed': '模型完成当前步骤',
|
||||
'proposal.revision_requested': '已提交方案评论,AI 正在修订',
|
||||
'proposal.ready': '方案已就绪,等待审核',
|
||||
'design.round': '设计检查点',
|
||||
'design.fallback_started': '执行固定绘图流程',
|
||||
'schematic.wiring_verified': '引脚连接已核对',
|
||||
@@ -108,6 +110,7 @@ export function PcbServiceDock({
|
||||
[text, setText] = useState(''),
|
||||
[answer, setAnswer] = useState(''),
|
||||
[sending, setSending] = useState(false);
|
||||
const [feedbackDraft, setFeedbackDraft] = useState<{ key: string; text: string } | null>(null);
|
||||
const [attachments, setAttachments] = useState<{ upload_id: string; name: string }[]>([]),
|
||||
[uploading, setUploading] = useState(false);
|
||||
const [preview, setPreview] = useState<Artifact | null>(null),
|
||||
@@ -419,6 +422,8 @@ export function PcbServiceDock({
|
||||
};
|
||||
const artifacts = task?.delivery?.artifacts ?? [],
|
||||
busy = sending || !!pending || !!queued || uploading;
|
||||
const feedbackKey = task?.proposal_hash ? task.task_id + ':' + task.proposal_hash : '';
|
||||
const feedback = feedbackDraft?.key === feedbackKey ? feedbackDraft.text : '';
|
||||
return createPortal(
|
||||
<div className="ze-app pcb-service-root">
|
||||
<button className="pcb-service-launch" onClick={() => setOpen((v) => !v)}>
|
||||
@@ -514,7 +519,9 @@ export function PcbServiceDock({
|
||||
<>
|
||||
<h2>{task.title || 'PCB 设计任务'}</h2>
|
||||
<p>
|
||||
<strong>{stateLabel[task.state] || task.state}</strong> · {task.revision} ·{' '}
|
||||
<strong>{task.state === 'assessing' && task.proposal_feedback
|
||||
? '正在根据评论修订方案'
|
||||
: stateLabel[task.state] || task.state}</strong> · {task.revision} ·{' '}
|
||||
<code>{task.task_id}</code>
|
||||
</p>
|
||||
<WorkflowDownloads key={task.task_id} taskId={task.task_id} connected={connected} onError={setError} />
|
||||
@@ -544,14 +551,34 @@ export function PcbServiceDock({
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
{task.state === 'awaiting_selection' &&
|
||||
task.proposal?.options.map((o) => (
|
||||
<article key={o.id}>
|
||||
<h3>{o.summary}</h3>
|
||||
<p>{o.implementation}</p>
|
||||
<ul>
|
||||
{o.advantages.map((v) => (
|
||||
<li key={v}>{v}</li>
|
||||
{task.state === 'awaiting_selection' && task.proposal && (
|
||||
<section aria-label="方案审核">
|
||||
<h3>设计方案{task.proposal_version ? ` · 第 ${task.proposal_version} 版` : ''}</h3>
|
||||
{task.proposal_feedback && <p>本轮评论 {task.proposal_feedback}</p>}
|
||||
{!!task.mounting_holes?.length && (
|
||||
<>
|
||||
<h4>安装孔</h4>
|
||||
<p>坐标以板子左下角为原点,单位为 mm。确认方案后按这些尺寸绘制。</p>
|
||||
<ul>
|
||||
{task.mounting_holes.map((hole) => (
|
||||
<li key={hole.id}>{hole.id} · 非金属化孔 Ø{hole.diameter_mm} · X {hole.x_mm} · Y {hole.y_mm}</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
{!!task.proposal.assumptions?.length && (
|
||||
<>
|
||||
<h4>方案假设</h4>
|
||||
<ul>{task.proposal.assumptions.map((item, i) => <li key={i}>{item}</li>)}</ul>
|
||||
</>
|
||||
)}
|
||||
{task.proposal.options.map((o) => (
|
||||
<article key={o.id}>
|
||||
<h3>{o.summary}</h3>
|
||||
<p>{o.implementation}</p>
|
||||
<ul>
|
||||
{o.advantages.map((v) => (
|
||||
<li key={v}>{v}</li>
|
||||
))}
|
||||
</ul>
|
||||
<p>{o.disadvantages.join(';')}</p>
|
||||
@@ -565,10 +592,33 @@ export function PcbServiceDock({
|
||||
})
|
||||
}
|
||||
>
|
||||
采用这个方案
|
||||
确认此方案并开始绘制
|
||||
</button>
|
||||
</article>
|
||||
))}
|
||||
))}
|
||||
<label>
|
||||
方案评论
|
||||
<textarea
|
||||
aria-label="方案评论"
|
||||
placeholder="描述想改的地方,可以注明方案名称"
|
||||
value={feedback}
|
||||
maxLength={3000}
|
||||
disabled={busy}
|
||||
onChange={(e) => setFeedbackDraft({ key: feedbackKey, text: e.target.value })}
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
disabled={busy || !feedback.trim() || !task.proposal_hash}
|
||||
onClick={() => void invoke('message', {
|
||||
task_id: task.task_id,
|
||||
proposal_hash: task.proposal_hash,
|
||||
text: feedback.trim(),
|
||||
})}
|
||||
>
|
||||
提交评论,请 AI 修订
|
||||
</button>
|
||||
</section>
|
||||
)}
|
||||
{!terminal.has(task.state) && (
|
||||
<p>服务器正在执行,可稍后重新打开查看。中途异常由服务端核对恢复。</p>
|
||||
)}
|
||||
|
||||
@@ -18,7 +18,11 @@ export interface Task {
|
||||
revision?: string;
|
||||
questions?: string[];
|
||||
proposal_hash?: string;
|
||||
proposal_version?: number;
|
||||
proposal_feedback?: string;
|
||||
mounting_holes?: { id: string; x_mm: number; y_mm: number; diameter_mm: number }[];
|
||||
proposal?: {
|
||||
assumptions?: string[];
|
||||
options: {
|
||||
id: string;
|
||||
summary: string;
|
||||
@@ -130,7 +134,7 @@ export const terminal = new Set([
|
||||
export const stateLabel: Record<string, string> = {
|
||||
assessing: '整理需求',
|
||||
needs_input: '等待补充需求',
|
||||
awaiting_selection: '等待选择方案',
|
||||
awaiting_selection: '等待审核方案',
|
||||
designing: '正在设计与检查',
|
||||
exporting: '正在打包成果',
|
||||
needs_operator: '服务器自动恢复中',
|
||||
|
||||
Reference in New Issue
Block a user