Wizzas commited on
Commit
e1a6941
·
verified ·
1 Parent(s): 3b68268

DefectRAG phase 5: incremental real-model application migration

Browse files
backend/inspection_requests.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Bind resumable item IDs to image content, product and batch within a repository."""
2
+ import hashlib
3
+ import json
4
+ import re
5
+
6
+ def fingerprint(content,category,batch):
7
+ metadata=json.dumps([category,batch.strip()],separators=(',',':')).encode()
8
+ return hashlib.sha256(metadata+b'\0'+content).hexdigest()
9
+
10
+ def existing_request(repo,request_id,content,category,batch):
11
+ if not request_id:return None
12
+ if not re.fullmatch('[a-f0-9]{32}',request_id):
13
+ raise ValueError('Invalid inspection request ID. Start a new batch.')
14
+ record=repo.get(request_id)
15
+ if record and record.get('request_fingerprint')!=fingerprint(content,category,batch):
16
+ raise ValueError('This request ID belongs to another upload. Start a new batch.')
17
+ return record
backend/main.py CHANGED
@@ -8,6 +8,7 @@ import logging
8
  import re
9
  import uuid
10
  import warnings
 
11
  from fastapi import FastAPI, UploadFile, File, Form, HTTPException, Query, Request
12
  from fastapi.responses import JSONResponse, FileResponse, HTMLResponse, Response
13
  from fastapi.exceptions import RequestValidationError
@@ -68,10 +69,18 @@ def create_app(settings=None, detector=None, workflow=None, repository=None):
68
  if not record: raise HTTPException(404,'Inspection not found')
69
  return record
70
 
71
- def inspect_bytes(content,category,batch,filename):
 
 
 
 
72
  if category not in CATEGORIES: raise HTTPException(422,'Choose a supported VisA product category')
73
  if len(batch)>80: raise HTTPException(422,'Batch label is limited to 80 characters')
74
  if len(content)>settings.max_upload: raise HTTPException(413,'Image limit is 10 MB')
 
 
 
 
75
  try:
76
  with warnings.catch_warnings():
77
  warnings.simplefilter('error',Image.DecompressionBombWarning)
@@ -82,7 +91,7 @@ def create_app(settings=None, detector=None, workflow=None, repository=None):
82
  image=ImageOps.exif_transpose(opened).convert('RGB')
83
  image.load()
84
  except (ValueError,UnidentifiedImageError,OSError,Image.DecompressionBombError,Image.DecompressionBombWarning) as exc:
85
- raise HTTPException(422,'Invalid image: '+str(exc))
86
  try:
87
  result,heatmap=detector.predict(image,category)
88
  except ModelUnavailable as exc:
@@ -92,13 +101,14 @@ def create_app(settings=None, detector=None, workflow=None, repository=None):
92
  log.exception('Model inference failed')
93
  repo.failure(category,'inference_failed')
94
  raise HTTPException(503,'Model execution failed. No inspection was saved.')
95
- identifier=uuid.uuid4().hex
96
  image_path=artifacts/f'{identifier}.jpg'; heatmap_path=artifacts/f'{identifier}_heatmap.jpg'
97
  try:
98
  image.thumbnail((1600,1600)); image.save(image_path,quality=92)
99
  heatmap.save(heatmap_path,quality=92)
100
  record={**result,'id':identifier,'created_at':now(),'batch':batch.strip(),'filename':Path(filename).name[:160],
101
- 'image_url':f'/api/inspections/{identifier}/image','heatmap_url':f'/api/inspections/{identifier}/heatmap'}
 
102
  return repo.save(record)
103
  except Exception:
104
  image_path.unlink(missing_ok=True); heatmap_path.unlink(missing_ok=True)
@@ -134,10 +144,10 @@ def create_app(settings=None, detector=None, workflow=None, repository=None):
134
  if not path.exists(): raise HTTPException(404,'Sample not available')
135
  return FileResponse(path)
136
  @app.post('/api/inspect')
137
- def inspect(category:str=Form(...),batch:str=Form(''),file:UploadFile=File(...)):
138
  try:
139
  content=file.file.read(settings.max_upload+1)
140
- return {'data':inspect_bytes(content,category,batch,file.filename or 'upload')}
141
  finally: file.file.close()
142
  @app.post('/api/batch')
143
  def inspect_batch(category:str=Form(...),batch:str=Form(...),files:list[UploadFile]=File(...)):
@@ -194,12 +204,34 @@ def create_app(settings=None, detector=None, workflow=None, repository=None):
194
  def report(identifier:str):
195
  record=require(identifier)
196
  esc=lambda v:html.escape(str(v))
197
- rows=''.join(f'<tr><th>{esc(k.replace("_"," "))}</th><td>{esc(v)}</td></tr>' for k,v in record.items() if not isinstance(v,(dict,list)))
 
 
 
 
 
 
 
198
  messages=repo.messages(identifier)
199
  evidence=''.join(f'<p>{esc(m.get("answer",m.get("question","")))}</p>' for m in messages) or '<p>No saved conversation yet. Ask the Evidence Assistant a question for this inspection, then refresh this report.</p>'
200
  sources={s['chunk_id']:s for m in messages for s in m.get('evidence',[])}
201
  source_html=''.join('<article><h3>'+esc(k)+' · '+esc(s['title'])+'</h3><p>'+esc(s['text'])+'</p><p>'+esc(s['url'])+' · '+esc(s['scope'])+'</p></article>' for k,s in sources.items()) or '<p>No document passages saved. Measurement-only answers come directly from the saved inspection and do not require a document citation.</p>'
202
- return HTMLResponse('<!doctype html><html lang="en"><meta charset="utf-8"><title>DefectRAG inspection report</title><style>body{font:15px system-ui;max-width:900px;margin:40px auto;color:#17292c}table{width:100%;border-collapse:collapse}th,td{text-align:left;border-bottom:1px solid #ddd;padding:8px}img{width:46%}article{border-top:1px solid #ddd}@media print{button{display:none}}</style><h1>DefectRAG inspection report</h1><p>Benchmark screening evidence · model score is not a probability</p><button onclick="window.print()">Print / save PDF</button><table>'+rows+'</table><h2>Image and localization</h2><img src="'+record['image_url']+'"><img src="'+record['heatmap_url']+'"><h2>Evidence conversation</h2>'+evidence+'<h2>Retrieved documentation</h2>'+source_html+'</html>')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  class Question(BaseModel):
204
  inspection_id:str=Field(min_length=32,max_length=32,pattern='^[0-9a-f]{32}$')
205
  question:str=Field(min_length=3,max_length=1200)
@@ -229,10 +261,10 @@ def create_app(settings=None, detector=None, workflow=None, repository=None):
229
  if not repo.acknowledge(identifier): raise HTTPException(404,'Alert not found')
230
  return {'data':{'acknowledged':True}}
231
  @app.get('/api/export.csv')
232
- def export():
233
  output=StringIO(); fields=['id','created_at','category','batch','verdict','score','threshold','inference_ms','model_id']
234
  writer=csv.DictWriter(output,fieldnames=fields,extrasaction='ignore'); writer.writeheader()
235
- for record in repo.list(limit=10000):
236
  safe={k:("'"+v if isinstance(v,str) and v.startswith(('=','+','-','@','\t','\r')) else v) for k,v in record.items()}
237
  writer.writerow(safe)
238
  return Response(output.getvalue(),media_type='text/csv',headers={'Content-Disposition':'attachment; filename="defectrag-inspections.csv"'})
 
8
  import re
9
  import uuid
10
  import warnings
11
+ import threading
12
  from fastapi import FastAPI, UploadFile, File, Form, HTTPException, Query, Request
13
  from fastapi.responses import JSONResponse, FileResponse, HTMLResponse, Response
14
  from fastapi.exceptions import RequestValidationError
 
69
  if not record: raise HTTPException(404,'Inspection not found')
70
  return record
71
 
72
+ inspection_lock=threading.RLock()
73
+ def inspect_bytes(*args,**kwargs):
74
+ with inspection_lock:return _inspect_bytes(*args,**kwargs)
75
+
76
+ def _inspect_bytes(content,category,batch,filename,request_id=''):
77
  if category not in CATEGORIES: raise HTTPException(422,'Choose a supported VisA product category')
78
  if len(batch)>80: raise HTTPException(422,'Batch label is limited to 80 characters')
79
  if len(content)>settings.max_upload: raise HTTPException(413,'Image limit is 10 MB')
80
+ from .inspection_requests import existing_request,fingerprint
81
+ try:existing=existing_request(repo,request_id,content,category,batch)
82
+ except ValueError as exc:raise HTTPException(409,str(exc))
83
+ if existing:return existing
84
  try:
85
  with warnings.catch_warnings():
86
  warnings.simplefilter('error',Image.DecompressionBombWarning)
 
91
  image=ImageOps.exif_transpose(opened).convert('RGB')
92
  image.load()
93
  except (ValueError,UnidentifiedImageError,OSError,Image.DecompressionBombError,Image.DecompressionBombWarning) as exc:
94
+ raise HTTPException(422,'This file could not be read as a supported image. Use a valid JPEG, PNG or WebP within the stated size limits.')
95
  try:
96
  result,heatmap=detector.predict(image,category)
97
  except ModelUnavailable as exc:
 
101
  log.exception('Model inference failed')
102
  repo.failure(category,'inference_failed')
103
  raise HTTPException(503,'Model execution failed. No inspection was saved.')
104
+ identifier=request_id or uuid.uuid4().hex
105
  image_path=artifacts/f'{identifier}.jpg'; heatmap_path=artifacts/f'{identifier}_heatmap.jpg'
106
  try:
107
  image.thumbnail((1600,1600)); image.save(image_path,quality=92)
108
  heatmap.save(heatmap_path,quality=92)
109
  record={**result,'id':identifier,'created_at':now(),'batch':batch.strip(),'filename':Path(filename).name[:160],
110
+ 'image_url':f'/api/inspections/{identifier}/image','heatmap_url':f'/api/inspections/{identifier}/heatmap',
111
+ 'request_fingerprint':fingerprint(content,category,batch)}
112
  return repo.save(record)
113
  except Exception:
114
  image_path.unlink(missing_ok=True); heatmap_path.unlink(missing_ok=True)
 
144
  if not path.exists(): raise HTTPException(404,'Sample not available')
145
  return FileResponse(path)
146
  @app.post('/api/inspect')
147
+ def inspect(category:str=Form(...),batch:str=Form(''),file:UploadFile=File(...),request_id:str=Form('',max_length=32)):
148
  try:
149
  content=file.file.read(settings.max_upload+1)
150
+ return {'data':inspect_bytes(content,category,batch,file.filename or 'upload',request_id)}
151
  finally: file.file.close()
152
  @app.post('/api/batch')
153
  def inspect_batch(category:str=Form(...),batch:str=Form(...),files:list[UploadFile]=File(...)):
 
204
  def report(identifier:str):
205
  record=require(identifier)
206
  esc=lambda v:html.escape(str(v))
207
+ fields=('id','created_at','category','batch','filename','verdict','score','threshold',
208
+ 'uncertainty_margin','model_id','profile','model_sha256','inference_ms',
209
+ 'total_model_ms','localization','scope','alert_acknowledged')
210
+ rows=''.join(f'<tr><th>{esc(k.replace("_"," "))}</th><td>{esc(record[k])}</td></tr>' for k in fields if k in record)
211
+ reviews=repo.review_history(identifier)
212
+ review_html=''.join('<article><strong>'+esc(r['status'])+' · '+esc(r['decision'])+'</strong><p>'+esc(r['reviewer'])+' · '+esc(r['created_at'])+'</p><p>'+esc(r['note'])+'</p></article>' for r in reviews) or '<p>No human review decision has been recorded.</p>'
213
+ from .reviews import parse_review
214
+ review_html+=''.join('<article><strong>'+esc(n['reviewer'])+' · '+esc(n['created_at'])+'</strong><p>'+esc(n['body'])+'</p></article>' for n in repo.review_notes(identifier) if not parse_review(n['body']))
215
  messages=repo.messages(identifier)
216
  evidence=''.join(f'<p>{esc(m.get("answer",m.get("question","")))}</p>' for m in messages) or '<p>No saved conversation yet. Ask the Evidence Assistant a question for this inspection, then refresh this report.</p>'
217
  sources={s['chunk_id']:s for m in messages for s in m.get('evidence',[])}
218
  source_html=''.join('<article><h3>'+esc(k)+' · '+esc(s['title'])+'</h3><p>'+esc(s['text'])+'</p><p>'+esc(s['url'])+' · '+esc(s['scope'])+'</p></article>' for k,s in sources.items()) or '<p>No document passages saved. Measurement-only answers come directly from the saved inspection and do not require a document citation.</p>'
219
+ return HTMLResponse('<!doctype html><html lang="en"><meta charset="utf-8"><title>DefectRAG inspection report</title><style>body{font:15px system-ui;max-width:900px;margin:40px auto;color:#17292c}table{width:100%;border-collapse:collapse}th,td{text-align:left;border-bottom:1px solid #ddd;padding:8px}img{width:46%}article{border-top:1px solid #ddd}@media print{button{display:none}}</style><h1>DefectRAG inspection report</h1><p>Benchmark screening evidence · model score is not a probability</p><button onclick="window.print()">Print / save PDF</button><table>'+rows+'</table><h2>Human review</h2>'+review_html+'<h2>Image and localization</h2><img src="'+esc(record['image_url'])+'"><img src="'+esc(record['heatmap_url'])+'"><h2>Evidence conversation</h2>'+evidence+'<h2>Retrieved documentation</h2>'+source_html+'</html>')
220
+ class HumanReview(BaseModel):
221
+ status:str=Field(pattern='^(Needs review|In review|Reviewed)$')
222
+ decision:str=Field(pattern='^(Pending|Hold|Accept|Reject)$')
223
+ note:str=Field(default='',max_length=1000)
224
+ @app.get('/api/inspections/{identifier}/reviews')
225
+ def review_history(identifier:str):
226
+ require(identifier)
227
+ return {'data':repo.review_history(identifier)}
228
+ @app.post('/api/inspections/{identifier}/review')
229
+ def save_review(identifier:str,payload:HumanReview):
230
+ require(identifier)
231
+ from .reviews import validate_review
232
+ try:validate_review(payload.status,payload.decision,payload.note)
233
+ except ValueError as exc:raise HTTPException(422,str(exc))
234
+ return {'data':repo.add_review(identifier,payload.status,payload.decision,payload.note)}
235
  class Question(BaseModel):
236
  inspection_id:str=Field(min_length=32,max_length=32,pattern='^[0-9a-f]{32}$')
237
  question:str=Field(min_length=3,max_length=1200)
 
261
  if not repo.acknowledge(identifier): raise HTTPException(404,'Alert not found')
262
  return {'data':{'acknowledged':True}}
263
  @app.get('/api/export.csv')
264
+ def export(category:str='',verdict:str='',batch:str=''):
265
  output=StringIO(); fields=['id','created_at','category','batch','verdict','score','threshold','inference_ms','model_id']
266
  writer=csv.DictWriter(output,fieldnames=fields,extrasaction='ignore'); writer.writeheader()
267
+ for record in repo.list(category=category,verdict=verdict,batch=batch,limit=10000):
268
  safe={k:("'"+v if isinstance(v,str) and v.startswith(('=','+','-','@','\t','\r')) else v) for k,v in record.items()}
269
  writer.writerow(safe)
270
  return Response(output.getvalue(),media_type='text/csv',headers={'Content-Disposition':'attachment; filename="defectrag-inspections.csv"'})
backend/reviews.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Append-only human reviews, stored separately from immutable model measurements."""
2
+ import json
3
+
4
+ PREFIX='DEFECTRAG_REVIEW_V1:'
5
+ STATUSES=('Needs review','In review','Reviewed')
6
+ DECISIONS=('Pending','Hold','Accept','Reject')
7
+
8
+ def validate_review(status,decision,note=''):
9
+ if (status not in STATUSES or decision not in DECISIONS or
10
+ (status=='Reviewed') == (decision=='Pending') or not isinstance(note,str) or len(note)>1000):
11
+ raise ValueError('Choose a review status and a compatible decision.')
12
+ return {'status':status,'decision':decision,'note':note.strip()}
13
+
14
+ def review_body(status,decision,note=''):
15
+ return PREFIX+json.dumps(validate_review(status,decision,note))
16
+
17
+ def parse_review(body):
18
+ if not isinstance(body,str) or not body.startswith(PREFIX):return None
19
+ try:
20
+ value=json.loads(body[len(PREFIX):])
21
+ return validate_review(value['status'],value['decision'],value.get('note',''))
22
+ except (ValueError,KeyError,TypeError):return None
backend/storage.py CHANGED
@@ -95,3 +95,19 @@ class SQLiteRepository:
95
  def failure(self,category,error):
96
  with self.connect() as db:
97
  db.execute('INSERT INTO failures VALUES(?,?,?,?)',(uuid.uuid4().hex,now(),category,error))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  def failure(self,category,error):
96
  with self.connect() as db:
97
  db.execute('INSERT INTO failures VALUES(?,?,?,?)',(uuid.uuid4().hex,now(),category,error))
98
+
99
+ def add_review(self,identifier,status,decision,note=''):
100
+ from .reviews import validate_review
101
+ review={**validate_review(status,decision,note),'inspection_id':identifier,
102
+ 'reviewer':'Local operator (single-user workspace)','created_at':now()}
103
+ with self.connect() as db:
104
+ db.execute('INSERT INTO audit_events VALUES(?,?,?,?)',
105
+ (uuid.uuid4().hex,review['created_at'],'human_review',json.dumps(review)))
106
+ return review
107
+
108
+ def review_history(self,identifier):
109
+ with self.connect() as db:
110
+ rows=db.execute("SELECT payload FROM audit_events WHERE action='human_review' AND json_extract(payload,'$.inspection_id')=? ORDER BY created_at",(identifier,)).fetchall()
111
+ return [json.loads(row['payload']) for row in rows]
112
+
113
+ def review_notes(self,identifier):return []
deployment/space/app.py CHANGED
@@ -146,13 +146,16 @@ def ready(message: str) -> dict:
146
  for name in ('gradio','spaces','torch','transformers','huggingface-hub')}}
147
 
148
 
149
- def inspect_one(image_b64, filename, category, batch):
150
  if category not in CARDS or len(batch)>80 or len(image_b64)>14*1024*1024:
151
  raise ValueError('Choose a supported category, image up to 10 MB and batch label up to 80 characters.')
152
  try:
153
  content = base64.b64decode(image_b64, validate=True)
154
  if len(content)>10*1024*1024:
155
  raise ValueError('Image limit is 10 MB')
 
 
 
156
  with warnings.catch_warnings():
157
  warnings.simplefilter('error', Image.DecompressionBombWarning)
158
  with Image.open(BytesIO(content)) as opened:
@@ -160,13 +163,13 @@ def inspect_one(image_b64, filename, category, batch):
160
  raise ValueError('Use JPEG, PNG or WebP, 32px minimum, up to 25 MP and 4:1 aspect ratio.')
161
  image = ImageOps.exif_transpose(opened).convert('RGB')
162
  except (ValueError, OSError, UnidentifiedImageError, Image.DecompressionBombWarning, Image.DecompressionBombError) as exc:
163
- raise ValueError(f'Invalid image: {exc}') from None
164
  start = time.perf_counter()
165
  output = compute(np.asarray(image), category)
166
  card = CARDS[category]
167
  threshold, margin, score = card['threshold'], card['uncertainty_margin'], output['score']
168
  verdict = 'Uncertain' if abs(score-threshold)<=margin else 'Anomalous' if score>=threshold else 'Good'
169
- identifier = uuid.uuid4().hex
170
  preview = image.copy()
171
  preview.thumbnail((1000,1000))
172
  heatmap = display_map(restore_map(output['raw'],output['geometry'],preview.size),preview,card['heatmap_scale'])
@@ -176,6 +179,7 @@ def inspect_one(image_b64, filename, category, batch):
176
  record = {key:output[key] for key in ('inference_ms','device','gpu_name','peak_gpu_mb','foreground_fraction')}
177
  record.update(id=identifier,created_at=now(),category=category,batch=batch.strip(),filename=Path(filename).name[:160],
178
  verdict=verdict,score=score,threshold=threshold,uncertainty_margin=margin,defect_category=None,
 
179
  model_id=card['model_id'],model_sha256=card['bank_sha256'],profile='dinov2_highres_v1',calibration=card['calibration'],
180
  total_model_ms=round((time.perf_counter()-start)*1000,2),
181
  localization=f"{output['geometry']['grid'][0]} x {output['geometry']['grid'][1]} DINOv2 patch distances with PCA foreground heuristic; interpolated, not supervised segmentation",
@@ -186,10 +190,10 @@ def inspect_one(image_b64, filename, category, batch):
186
 
187
 
188
  @server.api(name='inspect',concurrency_limit=1,concurrency_id='model-work')
189
- def inspect(image_b64: str, filename: str, category: str, batch: str, session: str, token: str='') -> dict:
190
  with identity(session,token):
191
  REPO.current() # Validate signed-in staff membership before consuming GPU.
192
- return inspect_one(image_b64,filename,category,batch)
193
 
194
 
195
  @server.api(name='assistant',concurrency_limit=1,concurrency_id='model-work')
@@ -246,6 +250,10 @@ for route in cpu_app.routes:
246
  def queued_only(operation: str):
247
  raise HTTPException(409,'Use the dashboard Gradio queue for model execution.')
248
 
 
 
 
 
249
 
250
  @server.get('/')
251
  def dashboard():
 
146
  for name in ('gradio','spaces','torch','transformers','huggingface-hub')}}
147
 
148
 
149
+ def inspect_one(image_b64, filename, category, batch, request_id=''):
150
  if category not in CARDS or len(batch)>80 or len(image_b64)>14*1024*1024:
151
  raise ValueError('Choose a supported category, image up to 10 MB and batch label up to 80 characters.')
152
  try:
153
  content = base64.b64decode(image_b64, validate=True)
154
  if len(content)>10*1024*1024:
155
  raise ValueError('Image limit is 10 MB')
156
+ from backend.inspection_requests import existing_request,fingerprint
157
+ existing=existing_request(REPO,request_id,content,category,batch)
158
+ if existing:return existing
159
  with warnings.catch_warnings():
160
  warnings.simplefilter('error', Image.DecompressionBombWarning)
161
  with Image.open(BytesIO(content)) as opened:
 
163
  raise ValueError('Use JPEG, PNG or WebP, 32px minimum, up to 25 MP and 4:1 aspect ratio.')
164
  image = ImageOps.exif_transpose(opened).convert('RGB')
165
  except (ValueError, OSError, UnidentifiedImageError, Image.DecompressionBombWarning, Image.DecompressionBombError) as exc:
166
+ raise ValueError('Invalid image. Use a readable JPEG, PNG or WebP: at least 32 pixels per side, up to 25 MP, 10 MB and 4:1 aspect ratio.') from None
167
  start = time.perf_counter()
168
  output = compute(np.asarray(image), category)
169
  card = CARDS[category]
170
  threshold, margin, score = card['threshold'], card['uncertainty_margin'], output['score']
171
  verdict = 'Uncertain' if abs(score-threshold)<=margin else 'Anomalous' if score>=threshold else 'Good'
172
+ identifier = request_id or uuid.uuid4().hex
173
  preview = image.copy()
174
  preview.thumbnail((1000,1000))
175
  heatmap = display_map(restore_map(output['raw'],output['geometry'],preview.size),preview,card['heatmap_scale'])
 
179
  record = {key:output[key] for key in ('inference_ms','device','gpu_name','peak_gpu_mb','foreground_fraction')}
180
  record.update(id=identifier,created_at=now(),category=category,batch=batch.strip(),filename=Path(filename).name[:160],
181
  verdict=verdict,score=score,threshold=threshold,uncertainty_margin=margin,defect_category=None,
182
+ request_fingerprint=fingerprint(content,category,batch),
183
  model_id=card['model_id'],model_sha256=card['bank_sha256'],profile='dinov2_highres_v1',calibration=card['calibration'],
184
  total_model_ms=round((time.perf_counter()-start)*1000,2),
185
  localization=f"{output['geometry']['grid'][0]} x {output['geometry']['grid'][1]} DINOv2 patch distances with PCA foreground heuristic; interpolated, not supervised segmentation",
 
190
 
191
 
192
  @server.api(name='inspect',concurrency_limit=1,concurrency_id='model-work')
193
+ def inspect(image_b64: str, filename: str, category: str, batch: str, session: str, token: str='', request_id: str='') -> dict:
194
  with identity(session,token):
195
  REPO.current() # Validate signed-in staff membership before consuming GPU.
196
+ return inspect_one(image_b64,filename,category,batch,request_id)
197
 
198
 
199
  @server.api(name='assistant',concurrency_limit=1,concurrency_id='model-work')
 
250
  def queued_only(operation: str):
251
  raise HTTPException(409,'Use the dashboard Gradio queue for model execution.')
252
 
253
+ @server.get('/api/{unknown:path}')
254
+ def unknown_api(unknown: str):
255
+ raise HTTPException(404,'API route not found')
256
+
257
 
258
  @server.get('/')
259
  def dashboard():
deployment/space/sessions.py CHANGED
@@ -133,5 +133,20 @@ class SessionRepository:
133
  def list(self, *args, **kwargs):
134
  return [self.decorate(row) for row in self.current().list(*args, **kwargs)]
135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  def __getattr__(self, name):
137
  return getattr(self.current(), name)
 
133
  def list(self, *args, **kwargs):
134
  return [self.decorate(row) for row in self.current().list(*args, **kwargs)]
135
 
136
+ def review_repository(self,identifier):
137
+ current=self.current()
138
+ if self.cloud_config and STAFF_TOKEN.get() and current.raw(identifier) is None:
139
+ return self.local()
140
+ return current
141
+
142
+ def add_review(self,identifier,*args,**kwargs):
143
+ return self.review_repository(identifier).add_review(identifier,*args,**kwargs)
144
+
145
+ def review_history(self,identifier):
146
+ return self.review_repository(identifier).review_history(identifier)
147
+
148
+ def review_notes(self,identifier):
149
+ return self.review_repository(identifier).review_notes(identifier)
150
+
151
  def __getattr__(self, name):
152
  return getattr(self.current(), name)
deployment/space/supabase_repository.py CHANGED
@@ -154,3 +154,24 @@ class StaffRepository:
154
 
155
  def failure(self,category,error):
156
  log.warning('Model failure in authenticated workspace: category=%s error=%s',category,error)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
 
155
  def failure(self,category,error):
156
  log.warning('Model failure in authenticated workspace: category=%s error=%s',category,error)
157
+
158
+ def add_review(self,identifier,status,decision,note=''):
159
+ from backend.reviews import review_body,validate_review
160
+ body=review_body(status,decision,note)
161
+ rows=self.request('POST','/rest/v1/staff_notes',json={
162
+ 'inspection_id':identifier,'author_id':self.user['id'],'body':body},
163
+ headers={'Prefer':'return=representation'})
164
+ return {**validate_review(status,decision,note),'reviewer':self.staff['display_name'],
165
+ 'reviewer_id':self.user['id'],'created_at':rows[0]['created_at']}
166
+
167
+ def review_notes(self,identifier):
168
+ rows=self.request('GET','/rest/v1/staff_notes',params={
169
+ 'inspection_id':'eq.'+identifier,'select':'body,author_id,created_at','order':'created_at.asc'})
170
+ people=self.request('GET','/rest/v1/staff_members',params={'select':'user_id,display_name'})
171
+ directory={row['user_id']:row['display_name'] for row in people}
172
+ return [{**row,'reviewer':directory.get(row['author_id'],'Staff member')} for row in rows]
173
+
174
+ def review_history(self,identifier):
175
+ from backend.reviews import parse_review
176
+ return [{**value,'reviewer':row['reviewer'],'reviewer_id':row['author_id'],'created_at':row['created_at']}
177
+ for row in self.review_notes(identifier) if (value:=parse_review(row['body']))]
frontend/dist/assets/TeamWorkspace-BNQz-sS3.js ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import{c as h,r as n,a as re,b as i,R as e,L as ne,S as se,A as le,d as ce,e as oe,w as _,p as G,f as ie}from"./index-DVE6dn1R.js";/**
2
+ * @license lucide-react v0.468.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const de=h("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/**
7
+ * @license lucide-react v0.468.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const q=h("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/**
12
+ * @license lucide-react v0.468.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const me=h("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
17
+ * @license lucide-react v0.468.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const ue=h("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/**
22
+ * @license lucide-react v0.468.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const pe=h("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
27
+ * @license lucide-react v0.468.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const he=h("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
32
+ * @license lucide-react v0.468.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const Ee=h("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/**
37
+ * @license lucide-react v0.468.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */const ye=h("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);function ve({onOpenInspection:P}){var V;const y=n.useRef(0),[c,z]=n.useState(null),[l,U]=n.useState(null),[w,O]=n.useState([]),[b,Y]=n.useState({}),[N,Z]=n.useState(""),[I,j]=n.useState(""),[o,D]=n.useState(!1),[T,f]=n.useState(""),[E,J]=n.useState(!1),[s,v]=n.useState(null),[Q,X]=n.useState([]),[A,$]=n.useState([]),[R,F]=n.useState(""),[ee,H]=n.useState(!1),[B,W]=n.useState(""),[te,x]=n.useState(!1),M=re();async function d(t){D(!0),f("");try{await t()}catch(r){f(r.message||"Team request failed.")}finally{D(!1)}}async function g(){const{client:t,staff:r}=await ie();U(r);let a=t.from("shared_inspections").select("*").order("created_at",{ascending:!1}).limit(200);a=E?a.not("archived_at","is",null):a.is("archived_at",null);const[{data:m,error:u},{data:p,error:C}]=await Promise.all([a,t.from("staff_members").select("*")]);if(u)throw u;if(C)throw C;O(m||[]),Y(Object.fromEntries((p||[]).map(S=>[S.user_id,S.display_name])))}n.useEffect(()=>{if(!M)return;let t=!1,r;return i().then(async a=>{r=a.auth.onAuthStateChange((u,p)=>{t||(y.current++,v(null),z((p==null?void 0:p.user)||null),u==="PASSWORD_RECOVERY"&&H(!0))}).data.subscription;const{data:m}=await a.auth.getUser();t||z(m.user)}).catch(a=>{t||f(a.message)}),()=>{t=!0,y.current++,r==null||r.unsubscribe()}},[M]),n.useEffect(()=>{if(!c)return;let t=!1;g().catch(a=>{t||f(a.message)});const r=setInterval(()=>g().catch(a=>{t||f(a.message)}),15e3);return()=>{t=!0,clearInterval(r)}},[c==null?void 0:c.id,E]);async function L(t){const r=++y.current;await d(async()=>{const a=await i(),m=a.storage.from("team-inspections"),[{data:u,error:p},{data:C,error:S}]=await Promise.all([a.from("shared_inspections").select("*").eq("id",t.id).single(),a.from("staff_notes").select("*").eq("inspection_id",t.id).order("created_at")]);if(p)throw p;if(S)throw S;const K=await Promise.all([u.image_path,u.heatmap_path].map(k=>m.createSignedUrl(k,900)));if(K.some(k=>k.error))throw new Error("Private images could not be loaded. Check staff/storage policies.");r===y.current&&(v(u),X(K.map(k=>k.data.signedUrl)),$(C||[]))})}async function ae(){await d(async()=>{const t=await i(),r=w.filter(a=>a.owner_id===c.id).map(a=>a.id);if(r.length){const{error:a}=await t.rpc("archive_team_inspections",{p_ids:r});if(a)throw a}y.current++,v(null),x(!1),await g(),_()})}return M?e.createElement(e.Fragment,null,e.createElement("section",{className:"card"},e.createElement("div",{className:"section-title"},e.createElement("div",null,e.createElement("h2",null,e.createElement(ye,{size:21})," Staff workspace"),e.createElement("p",null,"Signed-in staff share saved inspections and review notes. Live AI runs on the connected inspection backend.")),e.createElement("span",{className:"subtle-tag"},e.createElement(q,{size:13})," SUPABASE")),T&&e.createElement("div",{className:"error",role:"alert"},T),c?e.createElement(e.Fragment,null,e.createElement("div",{className:"team-toolbar"},e.createElement("div",null,e.createElement(se,{size:18}),e.createElement("strong",null,(l==null?void 0:l.display_name)||c.email),e.createElement("span",{className:"subtle-tag"},(l==null?void 0:l.role)||"CHECKING MEMBERSHIP")),e.createElement("button",{className:"secondary",disabled:o,onClick:()=>d(g)},e.createElement(he,{size:16})," Refresh"),e.createElement("button",{className:"secondary",onClick:()=>d(async()=>{await(await i()).auth.signOut(),O([]),v(null),U(null)})},e.createElement(pe,{size:16})," Sign out")),ee&&e.createElement("form",{className:"login-form",onSubmit:t=>{t.preventDefault(),d(async()=>{const r=await i(),{error:a}=await r.auth.updateUser({password:B});if(a)throw a;W(""),H(!1)})}},e.createElement("label",{className:"field"},"Set a new password",e.createElement("input",{type:"password",minLength:12,autoComplete:"new-password",value:B,onChange:t=>W(t.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:o},"Save password")),e.createElement("div",{className:"team-toolbar"},e.createElement("span",null,"Latest ",w.length," shared records · refreshes every 15 seconds"),(l==null?void 0:l.role)==="developer"&&e.createElement("button",{className:"secondary",onClick:()=>{J(!E),v(null)}},e.createElement(de,{size:16}),E?"Active history":"Developer recovery"),!E&&e.createElement("button",{className:"secondary danger",disabled:o||!w.some(t=>t.owner_id===c.id),onClick:()=>x(!0)},e.createElement(le,{size:16})," Archive my visible history")),te&&e.createElement("div",{className:"note"},e.createElement("div",null,e.createElement("strong",null,"Archive your visible records?"),e.createElement("p",null,"They will leave the shared active history. Original files and conversations remain recoverable by a developer. Other staff members’ records will stay active."),e.createElement("div",{className:"button-row"},e.createElement("button",{className:"primary",disabled:o,onClick:ae},"Archive my records"),e.createElement("button",{className:"secondary",onClick:()=>x(!1)},"Cancel")))),e.createElement("div",{className:"table-wrap"},e.createElement("table",null,e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Inspection"),e.createElement("th",null,"Product"),e.createElement("th",null,"Result"),e.createElement("th",null,"Shared by"),e.createElement("th",null,"Saved"),e.createElement("th",null))),e.createElement("tbody",null,w.map(t=>{var r;return e.createElement("tr",{key:t.id},e.createElement("td",null,e.createElement("strong",null,t.id.slice(0,8))),e.createElement("td",null,t.payload.category),e.createElement("td",null,e.createElement("span",{className:"badge "+((r=t.payload.verdict)==null?void 0:r.toLowerCase())},t.payload.verdict)),e.createElement("td",null,b[t.owner_id]||"Staff member"),e.createElement("td",null,new Date(t.created_at).toLocaleString()),e.createElement("td",null,e.createElement("button",{className:"text-button",onClick:()=>L(t)},"Review"),E&&(l==null?void 0:l.role)==="developer"&&e.createElement("button",{className:"text-button",disabled:o,onClick:()=>d(async()=>{const a=await i(),{error:m}=await a.rpc("restore_team_inspections",{p_ids:[t.id]});if(m)throw m;await g(),_()})},"Restore")))}))),!w.length&&e.createElement("div",{className:"empty"},e.createElement(q,{size:30}),e.createElement("p",null,E?"No archived records to recover.":"No shared inspections yet. Open an inspection result and select Share with staff.")))):e.createElement("form",{className:"login-form",onSubmit:t=>{t.preventDefault(),d(async()=>{const r=await i(),{error:a}=await r.auth.signInWithPassword({email:N,password:I});if(a)throw a;j("")})}},e.createElement("label",{className:"field"},"Work email",e.createElement("input",{type:"email",autoComplete:"username",value:N,onChange:t=>Z(t.target.value),required:!0})),e.createElement("label",{className:"field"},"Password",e.createElement("input",{type:"password",autoComplete:"current-password",value:I,onChange:t=>j(t.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:o},o?e.createElement(ne,{className:"spin",size:17}):e.createElement(ue,{size:17})," Sign in"),e.createElement("button",{type:"button",className:"text-button",disabled:!N||o,onClick:()=>d(async()=>{const t=await i(),{error:r}=await t.auth.resetPasswordForEmail(N,{redirectTo:location.origin+location.pathname});if(r)throw r;f("Password reset requested. Check your email.")})},"Reset password"),e.createElement("p",{className:"caption"},"Accounts must be invited and approved by your workspace developer. Signing up alone does not grant staff access."))),c&&s&&e.createElement("section",{className:"card"},e.createElement("div",{className:"section-title"},e.createElement("div",null,e.createElement("h2",null,"Shared inspection · ",s.id.slice(0,8)),e.createElement("p",null,"Saved snapshot from ",b[s.owner_id]||"a colleague",". This page does not run a new prediction.")),e.createElement("div",{className:"button-row"},P&&!s.archived_at&&e.createElement("button",{className:"secondary",onClick:()=>P(s)},"Open inspection & assistant"),e.createElement("button",{className:"text-button",onClick:()=>{y.current++,v(null)}},"Close"))),e.createElement("div",{className:"shared-images"},Q.map((t,r)=>e.createElement("img",{key:t,src:t,alt:r?"Saved anomaly heatmap":"Saved inspected product"}))),e.createElement("div",{className:"observation"},e.createElement("strong",null,"SAVED MEASUREMENTS"),e.createElement("span",null,s.payload.verdict," · score ",Number(s.payload.score).toFixed(5)," · threshold ",Number(s.payload.threshold).toFixed(5))),e.createElement("h3",{className:"section-gap"},"Recorded evidence"),(V=s.conversation)!=null&&V.length?s.conversation.map((t,r)=>e.createElement("p",{className:"cloud-message",key:r},e.createElement("strong",null,t.role==="user"?"Inspector":"Evidence Assistant",": "),t.question||t.answer)):e.createElement("p",{className:"caption"},"No conversation was included when this inspection was shared."),!s.archived_at&&e.createElement(ce,{key:s.id+String(A.length),current:A.map(t=>G(t,b)).filter(Boolean).at(-1),disabled:o,onSave:async t=>{const r=await i(),{error:a}=await r.from("staff_notes").insert({inspection_id:s.id,author_id:c.id,body:oe(t.status,t.decision,t.note)});if(a)throw a;await L(s),_()}}),e.createElement("h3",{className:"section-gap"},"Staff review notes"),A.filter(t=>!G(t,b)).map(t=>e.createElement("div",{className:"cloud-message",key:t.id},e.createElement("strong",null,b[t.author_id]||"Staff member"),e.createElement("p",null,t.body),e.createElement("small",null,new Date(t.created_at).toLocaleString()))),!s.archived_at&&e.createElement("form",{className:"question-form",onSubmit:t=>{t.preventDefault(),d(async()=>{const r=await i(),{error:a}=await r.from("staff_notes").insert({inspection_id:s.id,author_id:c.id,body:R.trim()});if(a)throw a;F(""),await L(s),_()})}},e.createElement("input",{"aria-label":"Staff review note",maxLength:2e3,placeholder:"Add a review note for your colleagues…",value:R,onChange:t=>F(t.target.value)}),e.createElement("button",{className:"primary",disabled:o||!R.trim()},e.createElement(Ee,{size:16})," Add note")))):e.createElement("section",{className:"card cloud-setup"},e.createElement("div",{className:"setup-icon"},e.createElement(q,{size:32})),e.createElement("span",{className:"eyebrow"},"TEAM WORKSPACE"),e.createElement("h2",null,"One shared view of inspection."),e.createElement("p",null,"The staff workspace is ready to connect to your own Supabase project. No cloud project or account has been created for you."),e.createElement("div",{className:"setup-grid"},[["01","Create a free project","Use your Supabase account and select an eligible Free plan."],["02","Set up staff access","Run the supplied schema, add your developer account and invite colleagues."],["03","Connect this dashboard","Add the project URL and publishable key to config.js, then reload."]].map(([t,r,a])=>e.createElement("div",{key:t},e.createElement("b",null,t),e.createElement("h3",null,r),e.createElement("p",null,a)))),e.createElement("a",{className:"primary",href:"https://supabase.com/dashboard",target:"_blank",rel:"noreferrer"},"Open Supabase ",e.createElement(me,{size:16})),e.createElement("p",{className:"caption"},"Setup files: deployment/SUPABASE_SETUP.md and deployment/supabase.sql. Never place a service-role key in the browser. Local inspection works without cloud setup."))}export{ve as default};
frontend/dist/assets/TeamWorkspace-BZTK8DKv.js ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import{c as h,r as n,a as re,b as i,R as e,L as ne,S as se,A as le,d as ce,e as oe,w as _,p as G,f as ie}from"./index-BJSwmtGs.js";/**
2
+ * @license lucide-react v0.468.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const de=h("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/**
7
+ * @license lucide-react v0.468.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const q=h("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/**
12
+ * @license lucide-react v0.468.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const me=h("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
17
+ * @license lucide-react v0.468.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const ue=h("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/**
22
+ * @license lucide-react v0.468.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const pe=h("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
27
+ * @license lucide-react v0.468.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const he=h("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
32
+ * @license lucide-react v0.468.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const Ee=h("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/**
37
+ * @license lucide-react v0.468.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */const ye=h("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);function ve({onOpenInspection:P}){var V;const y=n.useRef(0),[c,z]=n.useState(null),[l,U]=n.useState(null),[w,O]=n.useState([]),[b,Y]=n.useState({}),[N,Z]=n.useState(""),[I,j]=n.useState(""),[o,D]=n.useState(!1),[T,f]=n.useState(""),[E,J]=n.useState(!1),[s,v]=n.useState(null),[Q,X]=n.useState([]),[A,$]=n.useState([]),[R,F]=n.useState(""),[ee,H]=n.useState(!1),[B,W]=n.useState(""),[te,x]=n.useState(!1),M=re();async function d(t){D(!0),f("");try{await t()}catch(r){f(r.message||"Team request failed.")}finally{D(!1)}}async function g(){const{client:t,staff:r}=await ie();U(r);let a=t.from("shared_inspections").select("*").order("created_at",{ascending:!1}).limit(200);a=E?a.not("archived_at","is",null):a.is("archived_at",null);const[{data:m,error:u},{data:p,error:C}]=await Promise.all([a,t.from("staff_members").select("*")]);if(u)throw u;if(C)throw C;O(m||[]),Y(Object.fromEntries((p||[]).map(S=>[S.user_id,S.display_name])))}n.useEffect(()=>{if(!M)return;let t=!1,r;return i().then(async a=>{r=a.auth.onAuthStateChange((u,p)=>{t||(y.current++,v(null),z((p==null?void 0:p.user)||null),u==="PASSWORD_RECOVERY"&&H(!0))}).data.subscription;const{data:m}=await a.auth.getUser();t||z(m.user)}).catch(a=>{t||f(a.message)}),()=>{t=!0,y.current++,r==null||r.unsubscribe()}},[M]),n.useEffect(()=>{if(!c)return;let t=!1;g().catch(a=>{t||f(a.message)});const r=setInterval(()=>g().catch(a=>{t||f(a.message)}),15e3);return()=>{t=!0,clearInterval(r)}},[c==null?void 0:c.id,E]);async function L(t){const r=++y.current;await d(async()=>{const a=await i(),m=a.storage.from("team-inspections"),[{data:u,error:p},{data:C,error:S}]=await Promise.all([a.from("shared_inspections").select("*").eq("id",t.id).single(),a.from("staff_notes").select("*").eq("inspection_id",t.id).order("created_at")]);if(p)throw p;if(S)throw S;const K=await Promise.all([u.image_path,u.heatmap_path].map(k=>m.createSignedUrl(k,900)));if(K.some(k=>k.error))throw new Error("Private images could not be loaded. Check staff/storage policies.");r===y.current&&(v(u),X(K.map(k=>k.data.signedUrl)),$(C||[]))})}async function ae(){await d(async()=>{const t=await i(),r=w.filter(a=>a.owner_id===c.id).map(a=>a.id);if(r.length){const{error:a}=await t.rpc("archive_team_inspections",{p_ids:r});if(a)throw a}y.current++,v(null),x(!1),await g(),_()})}return M?e.createElement(e.Fragment,null,e.createElement("section",{className:"card"},e.createElement("div",{className:"section-title"},e.createElement("div",null,e.createElement("h2",null,e.createElement(ye,{size:21})," Staff workspace"),e.createElement("p",null,"Signed-in staff share saved inspections and review notes. Live AI runs on the connected inspection backend.")),e.createElement("span",{className:"subtle-tag"},e.createElement(q,{size:13})," SUPABASE")),T&&e.createElement("div",{className:"error",role:"alert"},T),c?e.createElement(e.Fragment,null,e.createElement("div",{className:"team-toolbar"},e.createElement("div",null,e.createElement(se,{size:18}),e.createElement("strong",null,(l==null?void 0:l.display_name)||c.email),e.createElement("span",{className:"subtle-tag"},(l==null?void 0:l.role)||"CHECKING MEMBERSHIP")),e.createElement("button",{className:"secondary",disabled:o,onClick:()=>d(g)},e.createElement(he,{size:16})," Refresh"),e.createElement("button",{className:"secondary",onClick:()=>d(async()=>{await(await i()).auth.signOut(),O([]),v(null),U(null)})},e.createElement(pe,{size:16})," Sign out")),ee&&e.createElement("form",{className:"login-form",onSubmit:t=>{t.preventDefault(),d(async()=>{const r=await i(),{error:a}=await r.auth.updateUser({password:B});if(a)throw a;W(""),H(!1)})}},e.createElement("label",{className:"field"},"Set a new password",e.createElement("input",{type:"password",minLength:12,autoComplete:"new-password",value:B,onChange:t=>W(t.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:o},"Save password")),e.createElement("div",{className:"team-toolbar"},e.createElement("span",null,"Latest ",w.length," shared records · refreshes every 15 seconds"),(l==null?void 0:l.role)==="developer"&&e.createElement("button",{className:"secondary",onClick:()=>{J(!E),v(null)}},e.createElement(de,{size:16}),E?"Active history":"Developer recovery"),!E&&e.createElement("button",{className:"secondary danger",disabled:o||!w.some(t=>t.owner_id===c.id),onClick:()=>x(!0)},e.createElement(le,{size:16})," Archive my visible history")),te&&e.createElement("div",{className:"note"},e.createElement("div",null,e.createElement("strong",null,"Archive your visible records?"),e.createElement("p",null,"They will leave the shared active history. Original files and conversations remain recoverable by a developer. Other staff members’ records will stay active."),e.createElement("div",{className:"button-row"},e.createElement("button",{className:"primary",disabled:o,onClick:ae},"Archive my records"),e.createElement("button",{className:"secondary",onClick:()=>x(!1)},"Cancel")))),e.createElement("div",{className:"table-wrap"},e.createElement("table",null,e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Inspection"),e.createElement("th",null,"Product"),e.createElement("th",null,"Result"),e.createElement("th",null,"Shared by"),e.createElement("th",null,"Saved"),e.createElement("th",null))),e.createElement("tbody",null,w.map(t=>{var r;return e.createElement("tr",{key:t.id},e.createElement("td",null,e.createElement("strong",null,t.id.slice(0,8))),e.createElement("td",null,t.payload.category),e.createElement("td",null,e.createElement("span",{className:"badge "+((r=t.payload.verdict)==null?void 0:r.toLowerCase())},t.payload.verdict)),e.createElement("td",null,b[t.owner_id]||"Staff member"),e.createElement("td",null,new Date(t.created_at).toLocaleString()),e.createElement("td",null,e.createElement("button",{className:"text-button",onClick:()=>L(t)},"Review"),E&&(l==null?void 0:l.role)==="developer"&&e.createElement("button",{className:"text-button",disabled:o,onClick:()=>d(async()=>{const a=await i(),{error:m}=await a.rpc("restore_team_inspections",{p_ids:[t.id]});if(m)throw m;await g(),_()})},"Restore")))}))),!w.length&&e.createElement("div",{className:"empty"},e.createElement(q,{size:30}),e.createElement("p",null,E?"No archived records to recover.":"No shared inspections yet. Open an inspection result and select Share with staff.")))):e.createElement("form",{className:"login-form",onSubmit:t=>{t.preventDefault(),d(async()=>{const r=await i(),{error:a}=await r.auth.signInWithPassword({email:N,password:I});if(a)throw a;j("")})}},e.createElement("label",{className:"field"},"Work email",e.createElement("input",{type:"email",autoComplete:"username",value:N,onChange:t=>Z(t.target.value),required:!0})),e.createElement("label",{className:"field"},"Password",e.createElement("input",{type:"password",autoComplete:"current-password",value:I,onChange:t=>j(t.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:o},o?e.createElement(ne,{className:"spin",size:17}):e.createElement(ue,{size:17})," Sign in"),e.createElement("button",{type:"button",className:"text-button",disabled:!N||o,onClick:()=>d(async()=>{const t=await i(),{error:r}=await t.auth.resetPasswordForEmail(N,{redirectTo:location.origin+location.pathname});if(r)throw r;f("Password reset requested. Check your email.")})},"Reset password"),e.createElement("p",{className:"caption"},"Accounts must be invited and approved by your workspace developer. Signing up alone does not grant staff access."))),c&&s&&e.createElement("section",{className:"card"},e.createElement("div",{className:"section-title"},e.createElement("div",null,e.createElement("h2",null,"Shared inspection · ",s.id.slice(0,8)),e.createElement("p",null,"Saved snapshot from ",b[s.owner_id]||"a colleague",". This page does not run a new prediction.")),e.createElement("div",{className:"button-row"},P&&!s.archived_at&&e.createElement("button",{className:"secondary",onClick:()=>P(s)},"Open inspection & assistant"),e.createElement("button",{className:"text-button",onClick:()=>{y.current++,v(null)}},"Close"))),e.createElement("div",{className:"shared-images"},Q.map((t,r)=>e.createElement("img",{key:t,src:t,alt:r?"Saved anomaly heatmap":"Saved inspected product"}))),e.createElement("div",{className:"observation"},e.createElement("strong",null,"SAVED MEASUREMENTS"),e.createElement("span",null,s.payload.verdict," · score ",Number(s.payload.score).toFixed(5)," · threshold ",Number(s.payload.threshold).toFixed(5))),e.createElement("h3",{className:"section-gap"},"Recorded evidence"),(V=s.conversation)!=null&&V.length?s.conversation.map((t,r)=>e.createElement("p",{className:"cloud-message",key:r},e.createElement("strong",null,t.role==="user"?"Inspector":"Evidence Assistant",": "),t.question||t.answer)):e.createElement("p",{className:"caption"},"No conversation was included when this inspection was shared."),!s.archived_at&&e.createElement(ce,{key:s.id+String(A.length),current:A.map(t=>G(t,b)).filter(Boolean).at(-1),disabled:o,onSave:async t=>{const r=await i(),{error:a}=await r.from("staff_notes").insert({inspection_id:s.id,author_id:c.id,body:oe(t.status,t.decision,t.note)});if(a)throw a;await L(s),_()}}),e.createElement("h3",{className:"section-gap"},"Staff review notes"),A.filter(t=>!G(t,b)).map(t=>e.createElement("div",{className:"cloud-message",key:t.id},e.createElement("strong",null,b[t.author_id]||"Staff member"),e.createElement("p",null,t.body),e.createElement("small",null,new Date(t.created_at).toLocaleString()))),!s.archived_at&&e.createElement("form",{className:"question-form",onSubmit:t=>{t.preventDefault(),d(async()=>{const r=await i(),{error:a}=await r.from("staff_notes").insert({inspection_id:s.id,author_id:c.id,body:R.trim()});if(a)throw a;F(""),await L(s),_()})}},e.createElement("input",{"aria-label":"Staff review note",maxLength:2e3,placeholder:"Add a review note for your colleagues…",value:R,onChange:t=>F(t.target.value)}),e.createElement("button",{className:"primary",disabled:o||!R.trim()},e.createElement(Ee,{size:16})," Add note")))):e.createElement("section",{className:"card cloud-setup"},e.createElement("div",{className:"setup-icon"},e.createElement(q,{size:32})),e.createElement("span",{className:"eyebrow"},"TEAM WORKSPACE"),e.createElement("h2",null,"One shared view of inspection."),e.createElement("p",null,"The staff workspace is ready to connect to your own Supabase project. No cloud project or account has been created for you."),e.createElement("div",{className:"setup-grid"},[["01","Create a free project","Use your Supabase account and select an eligible Free plan."],["02","Set up staff access","Run the supplied schema, add your developer account and invite colleagues."],["03","Connect this dashboard","Add the project URL and publishable key to config.js, then reload."]].map(([t,r,a])=>e.createElement("div",{key:t},e.createElement("b",null,t),e.createElement("h3",null,r),e.createElement("p",null,a)))),e.createElement("a",{className:"primary",href:"https://supabase.com/dashboard",target:"_blank",rel:"noreferrer"},"Open Supabase ",e.createElement(me,{size:16})),e.createElement("p",{className:"caption"},"Setup files: deployment/SUPABASE_SETUP.md and deployment/supabase.sql. Never place a service-role key in the browser. Local inspection works without cloud setup."))}export{ve as default};
frontend/dist/assets/TeamWorkspace-CX27w4bi.js ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import{c as h,r as n,a as re,b as i,R as e,L as ne,S as se,A as le,d as ce,e as oe,w as _,p as G,f as ie}from"./index-xxtqWM4_.js";/**
2
+ * @license lucide-react v0.468.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const de=h("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/**
7
+ * @license lucide-react v0.468.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const q=h("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/**
12
+ * @license lucide-react v0.468.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const me=h("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
17
+ * @license lucide-react v0.468.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const ue=h("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/**
22
+ * @license lucide-react v0.468.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const pe=h("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
27
+ * @license lucide-react v0.468.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const he=h("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
32
+ * @license lucide-react v0.468.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const Ee=h("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/**
37
+ * @license lucide-react v0.468.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */const ye=h("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);function ve({onOpenInspection:P}){var V;const y=n.useRef(0),[c,z]=n.useState(null),[l,U]=n.useState(null),[w,O]=n.useState([]),[b,Y]=n.useState({}),[N,Z]=n.useState(""),[I,j]=n.useState(""),[o,D]=n.useState(!1),[T,f]=n.useState(""),[E,J]=n.useState(!1),[s,v]=n.useState(null),[Q,X]=n.useState([]),[A,$]=n.useState([]),[R,F]=n.useState(""),[ee,H]=n.useState(!1),[B,W]=n.useState(""),[te,x]=n.useState(!1),M=re();async function d(t){D(!0),f("");try{await t()}catch(r){f(r.message||"Team request failed.")}finally{D(!1)}}async function g(){const{client:t,staff:r}=await ie();U(r);let a=t.from("shared_inspections").select("*").order("created_at",{ascending:!1}).limit(200);a=E?a.not("archived_at","is",null):a.is("archived_at",null);const[{data:m,error:u},{data:p,error:C}]=await Promise.all([a,t.from("staff_members").select("*")]);if(u)throw u;if(C)throw C;O(m||[]),Y(Object.fromEntries((p||[]).map(S=>[S.user_id,S.display_name])))}n.useEffect(()=>{if(!M)return;let t=!1,r;return i().then(async a=>{r=a.auth.onAuthStateChange((u,p)=>{t||(y.current++,v(null),z((p==null?void 0:p.user)||null),u==="PASSWORD_RECOVERY"&&H(!0))}).data.subscription;const{data:m}=await a.auth.getUser();t||z(m.user)}).catch(a=>{t||f(a.message)}),()=>{t=!0,y.current++,r==null||r.unsubscribe()}},[M]),n.useEffect(()=>{if(!c)return;let t=!1;g().catch(a=>{t||f(a.message)});const r=setInterval(()=>g().catch(a=>{t||f(a.message)}),15e3);return()=>{t=!0,clearInterval(r)}},[c==null?void 0:c.id,E]);async function L(t){const r=++y.current;await d(async()=>{const a=await i(),m=a.storage.from("team-inspections"),[{data:u,error:p},{data:C,error:S}]=await Promise.all([a.from("shared_inspections").select("*").eq("id",t.id).single(),a.from("staff_notes").select("*").eq("inspection_id",t.id).order("created_at")]);if(p)throw p;if(S)throw S;const K=await Promise.all([u.image_path,u.heatmap_path].map(k=>m.createSignedUrl(k,900)));if(K.some(k=>k.error))throw new Error("Private images could not be loaded. Check staff/storage policies.");r===y.current&&(v(u),X(K.map(k=>k.data.signedUrl)),$(C||[]))})}async function ae(){await d(async()=>{const t=await i(),r=w.filter(a=>a.owner_id===c.id).map(a=>a.id);if(r.length){const{error:a}=await t.rpc("archive_team_inspections",{p_ids:r});if(a)throw a}y.current++,v(null),x(!1),await g(),_()})}return M?e.createElement(e.Fragment,null,e.createElement("section",{className:"card"},e.createElement("div",{className:"section-title"},e.createElement("div",null,e.createElement("h2",null,e.createElement(ye,{size:21})," Staff workspace"),e.createElement("p",null,"Signed-in staff share saved inspections and review notes. Live AI runs on the connected inspection backend.")),e.createElement("span",{className:"subtle-tag"},e.createElement(q,{size:13})," SUPABASE")),T&&e.createElement("div",{className:"error",role:"alert"},T),c?e.createElement(e.Fragment,null,e.createElement("div",{className:"team-toolbar"},e.createElement("div",null,e.createElement(se,{size:18}),e.createElement("strong",null,(l==null?void 0:l.display_name)||c.email),e.createElement("span",{className:"subtle-tag"},(l==null?void 0:l.role)||"CHECKING MEMBERSHIP")),e.createElement("button",{className:"secondary",disabled:o,onClick:()=>d(g)},e.createElement(he,{size:16})," Refresh"),e.createElement("button",{className:"secondary",onClick:()=>d(async()=>{await(await i()).auth.signOut(),O([]),v(null),U(null)})},e.createElement(pe,{size:16})," Sign out")),ee&&e.createElement("form",{className:"login-form",onSubmit:t=>{t.preventDefault(),d(async()=>{const r=await i(),{error:a}=await r.auth.updateUser({password:B});if(a)throw a;W(""),H(!1)})}},e.createElement("label",{className:"field"},"Set a new password",e.createElement("input",{type:"password",minLength:12,autoComplete:"new-password",value:B,onChange:t=>W(t.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:o},"Save password")),e.createElement("div",{className:"team-toolbar"},e.createElement("span",null,"Latest ",w.length," shared records · refreshes every 15 seconds"),(l==null?void 0:l.role)==="developer"&&e.createElement("button",{className:"secondary",onClick:()=>{J(!E),v(null)}},e.createElement(de,{size:16}),E?"Active history":"Developer recovery"),!E&&e.createElement("button",{className:"secondary danger",disabled:o||!w.some(t=>t.owner_id===c.id),onClick:()=>x(!0)},e.createElement(le,{size:16})," Archive my visible history")),te&&e.createElement("div",{className:"note"},e.createElement("div",null,e.createElement("strong",null,"Archive your visible records?"),e.createElement("p",null,"They will leave the shared active history. Original files and conversations remain recoverable by a developer. Other staff members’ records will stay active."),e.createElement("div",{className:"button-row"},e.createElement("button",{className:"primary",disabled:o,onClick:ae},"Archive my records"),e.createElement("button",{className:"secondary",onClick:()=>x(!1)},"Cancel")))),e.createElement("div",{className:"table-wrap"},e.createElement("table",null,e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Inspection"),e.createElement("th",null,"Product"),e.createElement("th",null,"Result"),e.createElement("th",null,"Shared by"),e.createElement("th",null,"Saved"),e.createElement("th",null))),e.createElement("tbody",null,w.map(t=>{var r;return e.createElement("tr",{key:t.id},e.createElement("td",null,e.createElement("strong",null,t.id.slice(0,8))),e.createElement("td",null,t.payload.category),e.createElement("td",null,e.createElement("span",{className:"badge "+((r=t.payload.verdict)==null?void 0:r.toLowerCase())},t.payload.verdict)),e.createElement("td",null,b[t.owner_id]||"Staff member"),e.createElement("td",null,new Date(t.created_at).toLocaleString()),e.createElement("td",null,e.createElement("button",{className:"text-button",onClick:()=>L(t)},"Review"),E&&(l==null?void 0:l.role)==="developer"&&e.createElement("button",{className:"text-button",disabled:o,onClick:()=>d(async()=>{const a=await i(),{error:m}=await a.rpc("restore_team_inspections",{p_ids:[t.id]});if(m)throw m;await g(),_()})},"Restore")))}))),!w.length&&e.createElement("div",{className:"empty"},e.createElement(q,{size:30}),e.createElement("p",null,E?"No archived records to recover.":"No shared inspections yet. Open an inspection result and select Share with staff.")))):e.createElement("form",{className:"login-form",onSubmit:t=>{t.preventDefault(),d(async()=>{const r=await i(),{error:a}=await r.auth.signInWithPassword({email:N,password:I});if(a)throw a;j("")})}},e.createElement("label",{className:"field"},"Work email",e.createElement("input",{type:"email",autoComplete:"username",value:N,onChange:t=>Z(t.target.value),required:!0})),e.createElement("label",{className:"field"},"Password",e.createElement("input",{type:"password",autoComplete:"current-password",value:I,onChange:t=>j(t.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:o},o?e.createElement(ne,{className:"spin",size:17}):e.createElement(ue,{size:17})," Sign in"),e.createElement("button",{type:"button",className:"text-button",disabled:!N||o,onClick:()=>d(async()=>{const t=await i(),{error:r}=await t.auth.resetPasswordForEmail(N,{redirectTo:location.origin+location.pathname});if(r)throw r;f("Password reset requested. Check your email.")})},"Reset password"),e.createElement("p",{className:"caption"},"Accounts must be invited and approved by your workspace developer. Signing up alone does not grant staff access."))),c&&s&&e.createElement("section",{className:"card"},e.createElement("div",{className:"section-title"},e.createElement("div",null,e.createElement("h2",null,"Shared inspection · ",s.id.slice(0,8)),e.createElement("p",null,"Saved snapshot from ",b[s.owner_id]||"a colleague",". This page does not run a new prediction.")),e.createElement("div",{className:"button-row"},P&&!s.archived_at&&e.createElement("button",{className:"secondary",onClick:()=>P(s)},"Open inspection & assistant"),e.createElement("button",{className:"text-button",onClick:()=>{y.current++,v(null)}},"Close"))),e.createElement("div",{className:"shared-images"},Q.map((t,r)=>e.createElement("img",{key:t,src:t,alt:r?"Saved anomaly heatmap":"Saved inspected product"}))),e.createElement("div",{className:"observation"},e.createElement("strong",null,"SAVED MEASUREMENTS"),e.createElement("span",null,s.payload.verdict," · score ",Number(s.payload.score).toFixed(5)," · threshold ",Number(s.payload.threshold).toFixed(5))),e.createElement("h3",{className:"section-gap"},"Recorded evidence"),(V=s.conversation)!=null&&V.length?s.conversation.map((t,r)=>e.createElement("p",{className:"cloud-message",key:r},e.createElement("strong",null,t.role==="user"?"Inspector":"Evidence Assistant",": "),t.question||t.answer)):e.createElement("p",{className:"caption"},"No conversation was included when this inspection was shared."),!s.archived_at&&e.createElement(ce,{key:s.id+String(A.length),current:A.map(t=>G(t,b)).filter(Boolean).at(-1),disabled:o,onSave:async t=>{const r=await i(),{error:a}=await r.from("staff_notes").insert({inspection_id:s.id,author_id:c.id,body:oe(t.status,t.decision,t.note)});if(a)throw a;await L(s),_()}}),e.createElement("h3",{className:"section-gap"},"Staff review notes"),A.filter(t=>!G(t,b)).map(t=>e.createElement("div",{className:"cloud-message",key:t.id},e.createElement("strong",null,b[t.author_id]||"Staff member"),e.createElement("p",null,t.body),e.createElement("small",null,new Date(t.created_at).toLocaleString()))),!s.archived_at&&e.createElement("form",{className:"question-form",onSubmit:t=>{t.preventDefault(),d(async()=>{const r=await i(),{error:a}=await r.from("staff_notes").insert({inspection_id:s.id,author_id:c.id,body:R.trim()});if(a)throw a;F(""),await L(s),_()})}},e.createElement("input",{"aria-label":"Staff review note",maxLength:2e3,placeholder:"Add a review note for your colleagues…",value:R,onChange:t=>F(t.target.value)}),e.createElement("button",{className:"primary",disabled:o||!R.trim()},e.createElement(Ee,{size:16})," Add note")))):e.createElement("section",{className:"card cloud-setup"},e.createElement("div",{className:"setup-icon"},e.createElement(q,{size:32})),e.createElement("span",{className:"eyebrow"},"TEAM WORKSPACE"),e.createElement("h2",null,"One shared view of inspection."),e.createElement("p",null,"The staff workspace is ready to connect to your own Supabase project. No cloud project or account has been created for you."),e.createElement("div",{className:"setup-grid"},[["01","Create a free project","Use your Supabase account and select an eligible Free plan."],["02","Set up staff access","Run the supplied schema, add your developer account and invite colleagues."],["03","Connect this dashboard","Add the project URL and publishable key to config.js, then reload."]].map(([t,r,a])=>e.createElement("div",{key:t},e.createElement("b",null,t),e.createElement("h3",null,r),e.createElement("p",null,a)))),e.createElement("a",{className:"primary",href:"https://supabase.com/dashboard",target:"_blank",rel:"noreferrer"},"Open Supabase ",e.createElement(me,{size:16})),e.createElement("p",{className:"caption"},"Setup files: deployment/SUPABASE_SETUP.md and deployment/supabase.sql. Never place a service-role key in the browser. Local inspection works without cloud setup."))}export{ve as default};
frontend/dist/assets/TeamWorkspace-DDXXc4AJ.js ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import{c as E,r as n,a as ne,b as d,R as e,L as le,S as se,A as ce,d as oe,e as ie,w as _,p as Y,f as de}from"./index-qDlSPG-N.js";/**
2
+ * @license lucide-react v0.468.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const me=E("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/**
7
+ * @license lucide-react v0.468.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const q=E("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/**
12
+ * @license lucide-react v0.468.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const ue=E("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
17
+ * @license lucide-react v0.468.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const pe=E("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/**
22
+ * @license lucide-react v0.468.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const he=E("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
27
+ * @license lucide-react v0.468.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const Ee=E("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
32
+ * @license lucide-react v0.468.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const ye=E("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/**
37
+ * @license lucide-react v0.468.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */const fe=E("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);function we({onOpenInspection:P}){var K;const v=n.useRef(0),z=n.useRef(null),[c,U]=n.useState(null),[s,O]=n.useState(null),[g,I]=n.useState([]),[S,Z]=n.useState({}),[C,J]=n.useState(""),[j,D]=n.useState(""),[i,T]=n.useState(!1),[F,w]=n.useState(""),[y,Q]=n.useState(!1),[l,b]=n.useState(null),[X,$]=n.useState([]),[R,ee]=n.useState([]),[A,H]=n.useState(""),[te,B]=n.useState(!1),[W,V]=n.useState(""),[ae,x]=n.useState(!1),M=ne();async function m(t){T(!0),w("");try{await t()}catch(r){w(r.message||"Team request failed.")}finally{T(!1)}}async function k(){const{client:t,staff:r}=await de();O(r);let a=t.from("shared_inspections").select("*").order("created_at",{ascending:!1}).limit(200);a=y?a.not("archived_at","is",null):a.is("archived_at",null);const[{data:u,error:p},{data:o,error:f}]=await Promise.all([a,t.from("staff_members").select("*")]);if(p)throw p;if(f)throw f;I(u||[]),Z(Object.fromEntries((o||[]).map(h=>[h.user_id,h.display_name])))}n.useEffect(()=>{if(!M)return;let t=!1,r;return d().then(async a=>{r=a.auth.onAuthStateChange((p,o)=>{var f;if(!t){const h=((f=o==null?void 0:o.user)==null?void 0:f.id)||null;z.current!==h&&(v.current++,b(null),z.current=h),U((o==null?void 0:o.user)||null),p==="PASSWORD_RECOVERY"&&B(!0)}}).data.subscription;const{data:u}=await a.auth.getUser();t||U(u.user)}).catch(a=>{t||w(a.message)}),()=>{t=!0,v.current++,r==null||r.unsubscribe()}},[M]),n.useEffect(()=>{if(!c)return;let t=!1;k().catch(a=>{t||w(a.message)});const r=setInterval(()=>k().catch(a=>{t||w(a.message)}),15e3);return()=>{t=!0,clearInterval(r)}},[c==null?void 0:c.id,y]);async function L(t){const r=++v.current;await m(async()=>{const a=await d(),u=a.storage.from("team-inspections"),[{data:p,error:o},{data:f,error:h}]=await Promise.all([a.from("shared_inspections").select("*").eq("id",t.id).single(),a.from("staff_notes").select("*").eq("inspection_id",t.id).order("created_at")]);if(o)throw o;if(h)throw h;const G=await Promise.all([p.image_path,p.heatmap_path].map(N=>u.createSignedUrl(N,900)));if(G.some(N=>N.error))throw new Error("Private images could not be loaded. Check staff/storage policies.");r===v.current&&(b(p),$(G.map(N=>N.data.signedUrl)),ee(f||[]))})}async function re(){await m(async()=>{const t=await d(),r=g.filter(a=>a.owner_id===c.id).map(a=>a.id);if(r.length){const{error:a}=await t.rpc("archive_team_inspections",{p_ids:r});if(a)throw a}v.current++,b(null),x(!1),await k(),_()})}return M?e.createElement(e.Fragment,null,e.createElement("section",{className:"card"},e.createElement("div",{className:"section-title"},e.createElement("div",null,e.createElement("h2",null,e.createElement(fe,{size:21})," Staff workspace"),e.createElement("p",null,"Signed-in staff share saved inspections and review notes. Live AI runs on the connected inspection backend.")),e.createElement("span",{className:"subtle-tag"},e.createElement(q,{size:13})," SUPABASE")),F&&e.createElement("div",{className:"error",role:"alert"},F),c?e.createElement(e.Fragment,null,e.createElement("div",{className:"team-toolbar"},e.createElement("div",null,e.createElement(se,{size:18}),e.createElement("strong",null,(s==null?void 0:s.display_name)||c.email),e.createElement("span",{className:"subtle-tag"},(s==null?void 0:s.role)||"CHECKING MEMBERSHIP")),e.createElement("button",{className:"secondary",disabled:i,onClick:()=>m(k)},e.createElement(Ee,{size:16})," Refresh"),e.createElement("button",{className:"secondary",onClick:()=>m(async()=>{await(await d()).auth.signOut(),I([]),b(null),O(null)})},e.createElement(he,{size:16})," Sign out")),te&&e.createElement("form",{className:"login-form",onSubmit:t=>{t.preventDefault(),m(async()=>{const r=await d(),{error:a}=await r.auth.updateUser({password:W});if(a)throw a;V(""),B(!1)})}},e.createElement("label",{className:"field"},"Set a new password",e.createElement("input",{type:"password",minLength:12,autoComplete:"new-password",value:W,onChange:t=>V(t.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:i},"Save password")),e.createElement("div",{className:"team-toolbar"},e.createElement("span",null,"Latest ",g.length," shared records · refreshes every 15 seconds"),(s==null?void 0:s.role)==="developer"&&e.createElement("button",{className:"secondary",onClick:()=>{Q(!y),b(null)}},e.createElement(me,{size:16}),y?"Active history":"Developer recovery"),!y&&e.createElement("button",{className:"secondary danger",disabled:i||!g.some(t=>t.owner_id===c.id),onClick:()=>x(!0)},e.createElement(ce,{size:16})," Archive my visible history")),ae&&e.createElement("div",{className:"note"},e.createElement("div",null,e.createElement("strong",null,"Archive your visible records?"),e.createElement("p",null,"They will leave the shared active history. Original files and conversations remain recoverable by a developer. Other staff members’ records will stay active."),e.createElement("div",{className:"button-row"},e.createElement("button",{className:"primary",disabled:i,onClick:re},"Archive my records"),e.createElement("button",{className:"secondary",onClick:()=>x(!1)},"Cancel")))),e.createElement("div",{className:"table-wrap"},e.createElement("table",null,e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Inspection"),e.createElement("th",null,"Product"),e.createElement("th",null,"Result"),e.createElement("th",null,"Shared by"),e.createElement("th",null,"Saved"),e.createElement("th",null))),e.createElement("tbody",null,g.map(t=>{var r;return e.createElement("tr",{key:t.id},e.createElement("td",null,e.createElement("strong",null,t.id.slice(0,8))),e.createElement("td",null,t.payload.category),e.createElement("td",null,e.createElement("span",{className:"badge "+((r=t.payload.verdict)==null?void 0:r.toLowerCase())},t.payload.verdict)),e.createElement("td",null,S[t.owner_id]||"Staff member"),e.createElement("td",null,new Date(t.created_at).toLocaleString()),e.createElement("td",null,e.createElement("button",{className:"text-button",onClick:()=>L(t)},"Review"),y&&(s==null?void 0:s.role)==="developer"&&e.createElement("button",{className:"text-button",disabled:i,onClick:()=>m(async()=>{const a=await d(),{error:u}=await a.rpc("restore_team_inspections",{p_ids:[t.id]});if(u)throw u;await k(),_()})},"Restore")))}))),!g.length&&e.createElement("div",{className:"empty"},e.createElement(q,{size:30}),e.createElement("p",null,y?"No archived records to recover.":"No shared inspections yet. Open an inspection result and select Share with staff.")))):e.createElement("form",{className:"login-form",onSubmit:t=>{t.preventDefault(),m(async()=>{const r=await d(),{error:a}=await r.auth.signInWithPassword({email:C,password:j});if(a)throw a;D("")})}},e.createElement("label",{className:"field"},"Work email",e.createElement("input",{type:"email",autoComplete:"username",value:C,onChange:t=>J(t.target.value),required:!0})),e.createElement("label",{className:"field"},"Password",e.createElement("input",{type:"password",autoComplete:"current-password",value:j,onChange:t=>D(t.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:i},i?e.createElement(le,{className:"spin",size:17}):e.createElement(pe,{size:17})," Sign in"),e.createElement("button",{type:"button",className:"text-button",disabled:!C||i,onClick:()=>m(async()=>{const t=await d(),{error:r}=await t.auth.resetPasswordForEmail(C,{redirectTo:location.origin+location.pathname});if(r)throw r;w("Password reset requested. Check your email.")})},"Reset password"),e.createElement("p",{className:"caption"},"Accounts must be invited and approved by your workspace developer. Signing up alone does not grant staff access."))),c&&l&&e.createElement("section",{className:"card"},e.createElement("div",{className:"section-title"},e.createElement("div",null,e.createElement("h2",null,"Shared inspection · ",l.id.slice(0,8)),e.createElement("p",null,"Saved snapshot from ",S[l.owner_id]||"a colleague",". This page does not run a new prediction.")),e.createElement("div",{className:"button-row"},P&&!l.archived_at&&e.createElement("button",{className:"secondary",onClick:()=>P(l)},"Open inspection & assistant"),e.createElement("button",{className:"text-button",onClick:()=>{v.current++,b(null)}},"Close"))),e.createElement("div",{className:"shared-images"},X.map((t,r)=>e.createElement("img",{key:t,src:t,alt:r?"Saved anomaly heatmap":"Saved inspected product"}))),e.createElement("div",{className:"observation"},e.createElement("strong",null,"SAVED MEASUREMENTS"),e.createElement("span",null,l.payload.verdict," · score ",Number(l.payload.score).toFixed(5)," · threshold ",Number(l.payload.threshold).toFixed(5))),e.createElement("h3",{className:"section-gap"},"Recorded evidence"),(K=l.conversation)!=null&&K.length?l.conversation.map((t,r)=>e.createElement("p",{className:"cloud-message",key:r},e.createElement("strong",null,t.role==="user"?"Inspector":"Evidence Assistant",": "),t.question||t.answer)):e.createElement("p",{className:"caption"},"No conversation was included when this inspection was shared."),!l.archived_at&&e.createElement(oe,{key:l.id+String(R.length),current:R.map(t=>Y(t,S)).filter(Boolean).at(-1),disabled:i,onSave:async t=>{const r=await d(),{error:a}=await r.from("staff_notes").insert({inspection_id:l.id,author_id:c.id,body:ie(t.status,t.decision,t.note)});if(a)throw a;await L(l),_()}}),e.createElement("h3",{className:"section-gap"},"Staff review notes"),R.filter(t=>!Y(t,S)).map(t=>e.createElement("div",{className:"cloud-message",key:t.id},e.createElement("strong",null,S[t.author_id]||"Staff member"),e.createElement("p",null,t.body),e.createElement("small",null,new Date(t.created_at).toLocaleString()))),!l.archived_at&&e.createElement("form",{className:"question-form",onSubmit:t=>{t.preventDefault(),m(async()=>{const r=await d(),{error:a}=await r.from("staff_notes").insert({inspection_id:l.id,author_id:c.id,body:A.trim()});if(a)throw a;H(""),await L(l),_()})}},e.createElement("input",{"aria-label":"Staff review note",maxLength:2e3,placeholder:"Add a review note for your colleagues…",value:A,onChange:t=>H(t.target.value)}),e.createElement("button",{className:"primary",disabled:i||!A.trim()},e.createElement(ye,{size:16})," Add note")))):e.createElement("section",{className:"card cloud-setup"},e.createElement("div",{className:"setup-icon"},e.createElement(q,{size:32})),e.createElement("span",{className:"eyebrow"},"TEAM WORKSPACE"),e.createElement("h2",null,"One shared view of inspection."),e.createElement("p",null,"The staff workspace is ready to connect to your own Supabase project. No cloud project or account has been created for you."),e.createElement("div",{className:"setup-grid"},[["01","Create a free project","Use your Supabase account and select an eligible Free plan."],["02","Set up staff access","Run the supplied schema, add your developer account and invite colleagues."],["03","Connect this dashboard","Add the project URL and publishable key to config.js, then reload."]].map(([t,r,a])=>e.createElement("div",{key:t},e.createElement("b",null,t),e.createElement("h3",null,r),e.createElement("p",null,a)))),e.createElement("a",{className:"primary",href:"https://supabase.com/dashboard",target:"_blank",rel:"noreferrer"},"Open Supabase ",e.createElement(ue,{size:16})),e.createElement("p",{className:"caption"},"Setup files: deployment/SUPABASE_SETUP.md and deployment/supabase.sql. Never place a service-role key in the browser. Local inspection works without cloud setup."))}export{we as default};
frontend/dist/assets/index-BJSwmtGs.js ADDED
The diff for this file is too large to render. See raw diff
 
frontend/dist/assets/index-DVE6dn1R.js ADDED
The diff for this file is too large to render. See raw diff
 
frontend/dist/assets/index-qDlSPG-N.js ADDED
The diff for this file is too large to render. See raw diff
 
frontend/dist/assets/index-xxtqWM4_.js ADDED
The diff for this file is too large to render. See raw diff
 
frontend/dist/config.js CHANGED
@@ -1,5 +1,5 @@
1
  // Public settings only. Never put a service-role key or password in this file.
2
  window.DEFECTRAG_PUBLIC_CONFIG = {
3
- supabaseUrl: 'https://zrzqpbcomlorfzszolrs.supabase.co',
4
- supabasePublishableKey: 'sb_publishable_ff0gl6l7ZWb_zKcklF6e3g_VT7Qi7FF'
5
  };
 
1
  // Public settings only. Never put a service-role key or password in this file.
2
  window.DEFECTRAG_PUBLIC_CONFIG = {
3
+ supabaseUrl: '',
4
+ supabasePublishableKey: ''
5
  };
frontend/dist/index.html CHANGED
@@ -1,3 +1,3 @@
1
- <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><meta name="theme-color" content="#132e32"/><meta name="description" content="Local visual anomaly inspection with traceable evidence."/><title>DefectRAG · Inspection intelligence</title><link rel="icon" type="image/svg+xml" href="./logo.svg"><script src="./config.js"></script> <script type="module" crossorigin src="./assets/index-CWVSOzCk.js"></script>
2
  <link rel="stylesheet" crossorigin href="./assets/index-Bn4HF2vD.css">
3
  </head><body><div id="root"></div></body></html>
 
1
+ <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><meta name="theme-color" content="#132e32"/><meta name="description" content="Local visual anomaly inspection with traceable evidence."/><title>DefectRAG · Inspection intelligence</title><link rel="icon" type="image/svg+xml" href="./logo.svg"><script src="./config.js"></script> <script type="module" crossorigin src="./assets/index-qDlSPG-N.js"></script>
2
  <link rel="stylesheet" crossorigin href="./assets/index-Bn4HF2vD.css">
3
  </head><body><div id="root"></div></body></html>