DefectRAG phase 4: incremental real-model application migration
Browse files- README.md +1 -1
- app.py +1 -1
- deployment/space/app.py +11 -0
- deployment/space/publish.py +7 -0
- deployment/space/supabase_repository.py +10 -4
- deployment/space/verify_file_boundary.py +21 -0
- docs/FRONTEND_LICENSES.txt +94 -0
- docs/THIRD_PARTY_NOTICES.md +5 -0
- frontend/dist/assets/TeamWorkspace-DP0lHhvS.js +41 -0
- frontend/dist/assets/index-DKpML3Dj.js +0 -0
- frontend/dist/config.js +5 -1
- frontend/dist/index.html +1 -1
- models/BGE-LICENSE.txt +21 -0
README.md
CHANGED
|
@@ -12,7 +12,7 @@ pinned: false
|
|
| 12 |
short_description: Live React dashboard and DINOv2 inspection on ZeroGPU
|
| 13 |
---
|
| 14 |
|
| 15 |
-
# DefectRAG — migration phase
|
| 16 |
|
| 17 |
Existing React UI, real frozen DINOv2 inspection across all 12 VisA categories,
|
| 18 |
original normal-reference banks, calibration and heatmaps. No training rerun.
|
|
|
|
| 12 |
short_description: Live React dashboard and DINOv2 inspection on ZeroGPU
|
| 13 |
---
|
| 14 |
|
| 15 |
+
# DefectRAG — migration phase 4
|
| 16 |
|
| 17 |
Existing React UI, real frozen DINOv2 inspection across all 12 VisA categories,
|
| 18 |
original normal-reference banks, calibration and heatmaps. No training rerun.
|
app.py
CHANGED
|
@@ -3,6 +3,6 @@ from pathlib import Path
|
|
| 3 |
os.environ['DEFECTRAG_SPACE_UI']=str(Path(__file__).parent/'frontend/dist')
|
| 4 |
os.environ['GRADIO_ANALYTICS_ENABLED']='False'
|
| 5 |
os.environ['DEFECTRAG_LIVE_RAG']='1'
|
| 6 |
-
os.environ['DEFECTRAG_STAFF_BACKEND']='
|
| 7 |
from deployment.space.app import server
|
| 8 |
server.launch(server_name='0.0.0.0',server_port=7860,ssr_mode=False,show_error=True,run_history=False)
|
|
|
|
| 3 |
os.environ['DEFECTRAG_SPACE_UI']=str(Path(__file__).parent/'frontend/dist')
|
| 4 |
os.environ['GRADIO_ANALYTICS_ENABLED']='False'
|
| 5 |
os.environ['DEFECTRAG_LIVE_RAG']='1'
|
| 6 |
+
os.environ['DEFECTRAG_STAFF_BACKEND']='1'
|
| 7 |
from deployment.space.app import server
|
| 8 |
server.launch(server_name='0.0.0.0',server_port=7860,ssr_mode=False,show_error=True,run_history=False)
|
deployment/space/app.py
CHANGED
|
@@ -94,6 +94,17 @@ else:
|
|
| 94 |
WORKFLOW=None
|
| 95 |
cpu_app = create_app(Settings(), detector=MetadataDetector(), repository=REPO,workflow=WORKFLOW)
|
| 96 |
server = Server(title='DefectRAG')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
|
| 98 |
|
| 99 |
@server.middleware('http')
|
|
|
|
| 94 |
WORKFLOW=None
|
| 95 |
cpu_app = create_app(Settings(), detector=MetadataDetector(), repository=REPO,workflow=WORKFLOW)
|
| 96 |
server = Server(title='DefectRAG')
|
| 97 |
+
server.exception_handlers.update(cpu_app.exception_handlers)
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
@server.exception_handler(ValueError)
|
| 101 |
+
async def staff_access_error(request,exc):
|
| 102 |
+
return JSONResponse({'error':{'message':str(exc)}},status_code=403)
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
@server.exception_handler(RuntimeError)
|
| 106 |
+
async def cloud_storage_error(request,exc):
|
| 107 |
+
return JSONResponse({'error':{'message':str(exc)}},status_code=503)
|
| 108 |
|
| 109 |
|
| 110 |
@server.middleware('http')
|
deployment/space/publish.py
CHANGED
|
@@ -15,7 +15,14 @@ def main():
|
|
| 15 |
parser = argparse.ArgumentParser()
|
| 16 |
parser.add_argument('--phase', type=int, choices=(2,3,4,5), required=True)
|
| 17 |
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
| 18 |
files = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
for directory in ('backend','deployment/space'):
|
| 20 |
for path in (ROOT/directory).glob('*.py'):
|
| 21 |
files[path.relative_to(ROOT).as_posix()] = path
|
|
|
|
| 15 |
parser = argparse.ArgumentParser()
|
| 16 |
parser.add_argument('--phase', type=int, choices=(2,3,4,5), required=True)
|
| 17 |
args = parser.parse_args()
|
| 18 |
+
if args.phase>=4:
|
| 19 |
+
confirmation=OUT/'migration-confirmed.json'
|
| 20 |
+
assert confirmation.exists() and json.loads(confirmation.read_text()).get('user_confirmed_manual_execution'), 'Wait for the user to confirm manual SQL execution before enabling staff persistence.'
|
| 21 |
files = {}
|
| 22 |
+
for relative in ('docs/THIRD_PARTY_NOTICES.md','docs/FRONTEND_LICENSES.txt','models/BGE-LICENSE.txt'):
|
| 23 |
+
path=ROOT/relative
|
| 24 |
+
if path.exists():
|
| 25 |
+
files[relative]=path
|
| 26 |
for directory in ('backend','deployment/space'):
|
| 27 |
for path in (ROOT/directory).glob('*.py'):
|
| 28 |
files[path.relative_to(ROOT).as_posix()] = path
|
deployment/space/supabase_repository.py
CHANGED
|
@@ -7,7 +7,6 @@ import threading
|
|
| 7 |
import time
|
| 8 |
from urllib.parse import quote
|
| 9 |
import httpx
|
| 10 |
-
from backend.storage import now
|
| 11 |
|
| 12 |
log=logging.getLogger('defectrag.cloud')
|
| 13 |
_staff_cache={}
|
|
@@ -98,17 +97,24 @@ class StaffRepository:
|
|
| 98 |
return self.decorate(self.raw(identifier))
|
| 99 |
|
| 100 |
def raw_list(self,category='',verdict='',batch='',limit=100,offset=0,archived=False):
|
| 101 |
-
params={'select':'
|
| 102 |
'order':'created_at.desc','limit':str(limit),'offset':str(offset)}
|
| 103 |
for key,value in (('category',category),('verdict',verdict),('batch',batch)):
|
| 104 |
if value:
|
| 105 |
params['payload->>'+key]='eq.'+value
|
| 106 |
return self.request('GET','/rest/v1/shared_inspections',params=params)
|
| 107 |
|
| 108 |
-
def list(self,
|
| 109 |
# Lists need no images until a record is opened. Avoid two storage API
|
| 110 |
# calls per row for large history pages.
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
def stats(self):
|
| 114 |
rows=self.list(limit=1000)
|
|
|
|
| 7 |
import time
|
| 8 |
from urllib.parse import quote
|
| 9 |
import httpx
|
|
|
|
| 10 |
|
| 11 |
log=logging.getLogger('defectrag.cloud')
|
| 12 |
_staff_cache={}
|
|
|
|
| 97 |
return self.decorate(self.raw(identifier))
|
| 98 |
|
| 99 |
def raw_list(self,category='',verdict='',batch='',limit=100,offset=0,archived=False):
|
| 100 |
+
params={'select':'id,owner_id,created_at,payload,image_path,heatmap_path,archived_at','archived_at':'not.is.null' if archived else 'is.null',
|
| 101 |
'order':'created_at.desc','limit':str(limit),'offset':str(offset)}
|
| 102 |
for key,value in (('category',category),('verdict',verdict),('batch',batch)):
|
| 103 |
if value:
|
| 104 |
params['payload->>'+key]='eq.'+value
|
| 105 |
return self.request('GET','/rest/v1/shared_inspections',params=params)
|
| 106 |
|
| 107 |
+
def list(self,category='',verdict='',batch='',limit=100,offset=0,archived=False):
|
| 108 |
# Lists need no images until a record is opened. Avoid two storage API
|
| 109 |
# calls per row for large history pages.
|
| 110 |
+
rows=[]
|
| 111 |
+
while len(rows)<limit:
|
| 112 |
+
count=min(1000,limit-len(rows))
|
| 113 |
+
page=self.raw_list(category,verdict,batch,count,offset+len(rows),archived)
|
| 114 |
+
rows.extend(page)
|
| 115 |
+
if len(page)<count:
|
| 116 |
+
break
|
| 117 |
+
return [{**row['payload'],'storage':'supabase','owner_id':row['owner_id']} for row in rows]
|
| 118 |
|
| 119 |
def stats(self):
|
| 120 |
rows=self.list(limit=1000)
|
deployment/space/verify_file_boundary.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Read-only negative tests: generic Gradio routes must not expose private files."""
|
| 2 |
+
import hashlib
|
| 3 |
+
import json
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
from urllib.parse import quote
|
| 6 |
+
import requests
|
| 7 |
+
|
| 8 |
+
root=Path(__file__).resolve().parents[2]
|
| 9 |
+
support=root/'development-support/space'
|
| 10 |
+
vision=json.loads((support/'phase2-cloud.json').read_text())
|
| 11 |
+
rag=json.loads((support/'phase3-cloud.json').read_text())
|
| 12 |
+
owner=hashlib.sha256(vision['session'].encode()).hexdigest()
|
| 13 |
+
paths=[f'/app/runtime/space-development/sessions/{owner}/inspection.sqlite3',
|
| 14 |
+
f"/app/runtime/space-development/artifacts/{rag['inspection_id']}.jpg"]
|
| 15 |
+
results=[]
|
| 16 |
+
for path in paths:
|
| 17 |
+
with requests.get('https://wizzas-defectrag.hf.space/gradio_api/file='+quote(path,safe='/'),timeout=20,stream=True) as response:
|
| 18 |
+
results.append({'kind':'database' if path.endswith('.sqlite3') else 'image','status':response.status_code})
|
| 19 |
+
assert response.status_code in (401,403,404), 'Generic Gradio file route exposed a private artifact'
|
| 20 |
+
(support/'file-boundary.json').write_text(json.dumps({'status':'passed','checks':results},indent=2))
|
| 21 |
+
print(json.dumps(results))
|
docs/FRONTEND_LICENSES.txt
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
+
react / LICENSE
|
| 4 |
+
|
| 5 |
+
MIT License
|
| 6 |
+
|
| 7 |
+
Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 8 |
+
|
| 9 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 10 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 11 |
+
in the Software without restriction, including without limitation the rights
|
| 12 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 13 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 14 |
+
furnished to do so, subject to the following conditions:
|
| 15 |
+
|
| 16 |
+
The above copyright notice and this permission notice shall be included in all
|
| 17 |
+
copies or substantial portions of the Software.
|
| 18 |
+
|
| 19 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 20 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 21 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 22 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 23 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 24 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 25 |
+
SOFTWARE.
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
react-dom / LICENSE
|
| 29 |
+
|
| 30 |
+
MIT License
|
| 31 |
+
|
| 32 |
+
Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 33 |
+
|
| 34 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 35 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 36 |
+
in the Software without restriction, including without limitation the rights
|
| 37 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 38 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 39 |
+
furnished to do so, subject to the following conditions:
|
| 40 |
+
|
| 41 |
+
The above copyright notice and this permission notice shall be included in all
|
| 42 |
+
copies or substantial portions of the Software.
|
| 43 |
+
|
| 44 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 45 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 46 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 47 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 48 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 49 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 50 |
+
SOFTWARE.
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
scheduler / LICENSE
|
| 54 |
+
|
| 55 |
+
MIT License
|
| 56 |
+
|
| 57 |
+
Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 58 |
+
|
| 59 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 60 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 61 |
+
in the Software without restriction, including without limitation the rights
|
| 62 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 63 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 64 |
+
furnished to do so, subject to the following conditions:
|
| 65 |
+
|
| 66 |
+
The above copyright notice and this permission notice shall be included in all
|
| 67 |
+
copies or substantial portions of the Software.
|
| 68 |
+
|
| 69 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 70 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 71 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 72 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 73 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 74 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 75 |
+
SOFTWARE.
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
lucide-react / LICENSE
|
| 79 |
+
|
| 80 |
+
ISC License
|
| 81 |
+
|
| 82 |
+
Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2022 as part of Feather (MIT). All other copyright (c) for Lucide are held by Lucide Contributors 2022.
|
| 83 |
+
|
| 84 |
+
Permission to use, copy, modify, and/or distribute this software for any
|
| 85 |
+
purpose with or without fee is hereby granted, provided that the above
|
| 86 |
+
copyright notice and this permission notice appear in all copies.
|
| 87 |
+
|
| 88 |
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 89 |
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 90 |
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 91 |
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 92 |
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 93 |
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
| 94 |
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
docs/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -32,6 +32,11 @@ Qwen is an optional separately installed Ollama model and is not bundled. No raw
|
|
| 32 |
user history, credentials, full dataset, training cache or dependency environment
|
| 33 |
is included in the release ZIP.
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
DINOv2 Small/14: Meta, Apache2.0. Public tensors are fetched without remote-code
|
| 36 |
execution from https://huggingface.co/facebook/dinov2-small . The pinned source
|
| 37 |
revision and tensor checksum are saved beside the downloaded assets. The new
|
|
|
|
| 32 |
user history, credentials, full dataset, training cache or dependency environment
|
| 33 |
is included in the release ZIP.
|
| 34 |
|
| 35 |
+
The optional live Hugging Face Space downloads Qwen/Qwen3-4B-Instruct-2507 directly
|
| 36 |
+
from its official repository at revision cdbee75f17c01a7cc42f958dc650907174af0554.
|
| 37 |
+
Qwen Team, Apache-2.0: https://huggingface.co/Qwen/Qwen3-4B-Instruct-2507 .
|
| 38 |
+
These cloud-cached weights are not copied into the local release or checkpoint.
|
| 39 |
+
|
| 40 |
DINOv2 Small/14: Meta, Apache2.0. Public tensors are fetched without remote-code
|
| 41 |
execution from https://huggingface.co/facebook/dinov2-small . The pinned source
|
| 42 |
revision and tensor checksum are saved beside the downloaded assets. The new
|
frontend/dist/assets/TeamWorkspace-DP0lHhvS.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import{c as h,r as n,a as Q,b as d,R as e,L as X,S as $,A as ee,d as te}from"./index-DKpML3Dj.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 ae=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 _=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 re=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 ne=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 le=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 se=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 ce=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 oe=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 me(){var D;const[c,A]=n.useState(null),[l,x]=n.useState(null),[v,M]=n.useState([]),[S,H]=n.useState({}),[g,F]=n.useState(""),[R,L]=n.useState(""),[o,q]=n.useState(!1),[P,y]=n.useState(""),[E,W]=n.useState(!1),[s,w]=n.useState(null),[B,V]=n.useState([]),[K,G]=n.useState([]),[k,z]=n.useState(""),[Y,I]=n.useState(!1),[U,O]=n.useState(""),[Z,N]=n.useState(!1),C=Q();async function i(t){q(!0),y("");try{await t()}catch(r){y(r.message||"Team request failed.")}finally{q(!1)}}async function b(){const{client:t,staff:r}=await te();x(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:f},{data:u,error:p}]=await Promise.all([a,t.from("staff_members").select("*")]);if(f)throw f;if(p)throw p;M(m||[]),H(Object.fromEntries((u||[]).map(T=>[T.user_id,T.display_name])))}n.useEffect(()=>{if(!C)return;let t=!1,r;return d().then(async a=>{r=a.auth.onAuthStateChange((f,u)=>{t||(A((u==null?void 0:u.user)||null),f==="PASSWORD_RECOVERY"&&I(!0))}).data.subscription;const{data:m}=await a.auth.getUser();t||A(m.user)}).catch(a=>{t||y(a.message)}),()=>{t=!0,r==null||r.unsubscribe()}},[C]),n.useEffect(()=>{if(!c)return;let t=!1;b().catch(a=>{t||y(a.message)});const r=setInterval(()=>b().catch(a=>{t||y(a.message)}),15e3);return()=>{t=!0,clearInterval(r)}},[c==null?void 0:c.id,E]);async function j(t){await i(async()=>{const r=await d(),a=r.storage.from("team-inspections"),m=await Promise.all([t.image_path,t.heatmap_path].map(p=>a.createSignedUrl(p,900)));if(m.some(p=>p.error))throw new Error("Private images could not be loaded. Check staff/storage policies.");const{data:f,error:u}=await r.from("staff_notes").select("*").eq("inspection_id",t.id).order("created_at");if(u)throw u;w(t),V(m.map(p=>p.data.signedUrl)),G(f||[])})}async function J(){await i(async()=>{const t=await d(),r=v.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}w(null),N(!1),await b()})}return C?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(oe,{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(_,{size:13})," SUPABASE")),P&&e.createElement("div",{className:"error",role:"alert"},P),c?e.createElement(e.Fragment,null,e.createElement("div",{className:"team-toolbar"},e.createElement("div",null,e.createElement($,{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:()=>i(b)},e.createElement(se,{size:16})," Refresh"),e.createElement("button",{className:"secondary",onClick:()=>i(async()=>{await(await d()).auth.signOut(),M([]),w(null),x(null)})},e.createElement(le,{size:16})," Sign out")),Y&&e.createElement("form",{className:"login-form",onSubmit:t=>{t.preventDefault(),i(async()=>{const r=await d(),{error:a}=await r.auth.updateUser({password:U});if(a)throw a;O(""),I(!1)})}},e.createElement("label",{className:"field"},"Set a new password",e.createElement("input",{type:"password",minLength:12,autoComplete:"new-password",value:U,onChange:t=>O(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 ",v.length," shared records · refreshes every 15 seconds"),(l==null?void 0:l.role)==="developer"&&e.createElement("button",{className:"secondary",onClick:()=>{W(!E),w(null)}},e.createElement(ae,{size:16}),E?"Active history":"Developer recovery"),!E&&e.createElement("button",{className:"secondary danger",disabled:o||!v.some(t=>t.owner_id===c.id),onClick:()=>N(!0)},e.createElement(ee,{size:16})," Archive my visible history")),Z&&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:J},"Archive my records"),e.createElement("button",{className:"secondary",onClick:()=>N(!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,v.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:()=>j(t)},"Review"),E&&(l==null?void 0:l.role)==="developer"&&e.createElement("button",{className:"text-button",disabled:o,onClick:()=>i(async()=>{const a=await d(),{error:m}=await a.rpc("restore_team_inspections",{p_ids:[t.id]});if(m)throw m;await b()})},"Restore")))}))),!v.length&&e.createElement("div",{className:"empty"},e.createElement(_,{size:30}),e.createElement("p",null,E?"No archived records to recover.":"No shared inspections yet. In the local app, open a result and select Share with staff.")))):e.createElement("form",{className:"login-form",onSubmit:t=>{t.preventDefault(),i(async()=>{const r=await d(),{error:a}=await r.auth.signInWithPassword({email:g,password:R});if(a)throw a;L("")})}},e.createElement("label",{className:"field"},"Work email",e.createElement("input",{type:"email",autoComplete:"username",value:g,onChange:t=>F(t.target.value),required:!0})),e.createElement("label",{className:"field"},"Password",e.createElement("input",{type:"password",autoComplete:"current-password",value:R,onChange:t=>L(t.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:o},o?e.createElement(X,{className:"spin",size:17}):e.createElement(ne,{size:17})," Sign in"),e.createElement("button",{type:"button",className:"text-button",disabled:!g||o,onClick:()=>i(async()=>{const t=await d(),{error:r}=await t.auth.resetPasswordForEmail(g,{redirectTo:location.origin+location.pathname});if(r)throw r;y("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 ",S[s.owner_id]||"a colleague",". This page does not run a new prediction.")),e.createElement("button",{className:"text-button",onClick:()=>w(null)},"Close")),e.createElement("div",{className:"shared-images"},B.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"),(D=s.conversation)!=null&&D.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."),e.createElement("h3",{className:"section-gap"},"Staff review notes"),K.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()))),!s.archived_at&&e.createElement("form",{className:"question-form",onSubmit:t=>{t.preventDefault(),i(async()=>{const r=await d(),{error:a}=await r.from("staff_notes").insert({inspection_id:s.id,author_id:c.id,body:k.trim()});if(a)throw a;z(""),await j(s)})}},e.createElement("input",{"aria-label":"Staff review note",maxLength:2e3,placeholder:"Add a review note for your colleagues…",value:k,onChange:t=>z(t.target.value)}),e.createElement("button",{className:"primary",disabled:o||!k.trim()},e.createElement(ce,{size:16})," Add note")))):e.createElement("section",{className:"card cloud-setup"},e.createElement("div",{className:"setup-icon"},e.createElement(_,{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(re,{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{me as default};
|
frontend/dist/assets/index-DKpML3Dj.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/dist/config.js
CHANGED
|
@@ -1 +1,5 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
};
|
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-
|
| 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-DKpML3Dj.js"></script>
|
| 2 |
<link rel="stylesheet" crossorigin href="./assets/index-Bn4HF2vD.css">
|
| 3 |
</head><body><div id="root"></div></body></html>
|
models/BGE-LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2022 staoxiao
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|