Spaces:
Sleeping
Sleeping
Deploy verified conversational workbench and isolated Java application previews
Browse filesSource baseline: a1793a9a4a5c43fa566a2274c2c27d81e0eb8c98. Credentials are runtime Secrets only.
- deploy/hf/app.py +37 -1
- deploy/hf/package-manifest.json +15 -11
- examples/delete-release-cloud-rejections-2026-10-29.json +60 -0
- examples/hf-ingress-validation.json +10 -22
- sites/zkcoding-workbench/dist/admin/admin.css +10 -8
- sites/zkcoding-workbench/dist/admin/admin.js +18 -2
- sites/zkcoding-workbench/dist/admin/workflow-editor.js +1 -1
deploy/hf/app.py
CHANGED
|
@@ -2,6 +2,9 @@
|
|
| 2 |
import os
|
| 3 |
import sqlite3
|
| 4 |
import time
|
|
|
|
|
|
|
|
|
|
| 5 |
from pathlib import Path
|
| 6 |
from urllib.parse import urlsplit
|
| 7 |
from src.adapters.llm.chat_completion import ChatCompletionProvider
|
|
@@ -38,6 +41,37 @@ class LimitedProvider:
|
|
| 38 |
return self.provider.complete(messages,max_tokens,cancelled)
|
| 39 |
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
def providers_from_environment(root):
|
| 42 |
# Remove the provider secret before spawning trusted tools/VM emulators.
|
| 43 |
token=os.environ.pop('DASHSCOPE_API_KEY',None)
|
|
@@ -61,6 +95,8 @@ def providers_from_environment(root):
|
|
| 61 |
|
| 62 |
def create_app():
|
| 63 |
data=ROOT/'.local/hf-runtime';data.mkdir(parents=True,exist_ok=True)
|
| 64 |
-
|
|
|
|
| 65 |
engine.identity.seed_demo_users();engine.preview_origin=ORIGIN
|
|
|
|
| 66 |
return SpaceIngress(create_web(engine,7860),ORIGIN,bridge=PreviewBridge(engine))
|
|
|
|
| 2 |
import os
|
| 3 |
import sqlite3
|
| 4 |
import time
|
| 5 |
+
import json
|
| 6 |
+
import hashlib
|
| 7 |
+
import threading
|
| 8 |
from pathlib import Path
|
| 9 |
from urllib.parse import urlsplit
|
| 10 |
from src.adapters.llm.chat_completion import ChatCompletionProvider
|
|
|
|
| 41 |
return self.provider.complete(messages,max_tokens,cancelled)
|
| 42 |
|
| 43 |
|
| 44 |
+
def initialize_model_health(providers,path):
|
| 45 |
+
"""Real, budgeted probes inside the Space; uncertain attempts are never replayed."""
|
| 46 |
+
path=Path(path);path.parent.mkdir(parents=True,exist_ok=True)
|
| 47 |
+
selected=[p for p in providers if p.selectable]
|
| 48 |
+
if not selected:return
|
| 49 |
+
binding=hashlib.sha256((VERSION+'\0'+selected[0].endpoint+'\0'+selected[0]._token).encode()).hexdigest()
|
| 50 |
+
report={'binding':binding,'models':{}}
|
| 51 |
+
if path.is_file():
|
| 52 |
+
previous=json.loads(path.read_text(encoding='utf-8'))
|
| 53 |
+
if previous.get('binding')==binding:report=previous
|
| 54 |
+
def save():
|
| 55 |
+
pending=path.with_suffix('.tmp');pending.write_text(json.dumps(report),encoding='utf-8');pending.replace(path)
|
| 56 |
+
for provider in selected:
|
| 57 |
+
old=report['models'].get(provider.model)
|
| 58 |
+
if old:
|
| 59 |
+
provider.health={**old,'status':'unknown' if old['status']=='reserved' else old['status']};continue
|
| 60 |
+
row={'status':'reserved','checked_at':time.time()};report['models'][provider.model]=row;save()
|
| 61 |
+
try:
|
| 62 |
+
reply=provider.complete([{'role':'system','content':'Return JSON only.'},
|
| 63 |
+
{'role':'user','content':'Return exactly {"summary":"ok"}.'}],64,lambda:False)
|
| 64 |
+
row.update(status='healthy' if reply.content=={'summary':'ok'} else 'rejected',
|
| 65 |
+
request_id=reply.request_id,input_tokens=reply.input_tokens,output_tokens=reply.output_tokens)
|
| 66 |
+
if row['status']!='healthy':row['code']='PROBE_CONTRACT_INVALID'
|
| 67 |
+
except ProviderFailure as exc:
|
| 68 |
+
row.update(status='rejected' if exc.rejected else 'unknown',code=exc.code,
|
| 69 |
+
input_tokens=exc.input_tokens,output_tokens=exc.output_tokens)
|
| 70 |
+
except Exception:
|
| 71 |
+
row.update(status='unknown',code='PROBE_RESULT_UNKNOWN')
|
| 72 |
+
provider.health=dict(row);save()
|
| 73 |
+
|
| 74 |
+
|
| 75 |
def providers_from_environment(root):
|
| 76 |
# Remove the provider secret before spawning trusted tools/VM emulators.
|
| 77 |
token=os.environ.pop('DASHSCOPE_API_KEY',None)
|
|
|
|
| 95 |
|
| 96 |
def create_app():
|
| 97 |
data=ROOT/'.local/hf-runtime';data.mkdir(parents=True,exist_ok=True)
|
| 98 |
+
providers=providers_from_environment(data)
|
| 99 |
+
engine=LocalWorkbench(data,providers,sandbox_capacity=int(os.environ.get('ZKCODING_SANDBOX_CAPACITY','3')))
|
| 100 |
engine.identity.seed_demo_users();engine.preview_origin=ORIGIN
|
| 101 |
+
threading.Thread(target=initialize_model_health,args=(providers,data/'model-health.json'),daemon=True,name='space-model-health').start()
|
| 102 |
return SpaceIngress(create_web(engine,7860),ORIGIN,bridge=PreviewBridge(engine))
|
deploy/hf/package-manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
{
|
| 2 |
-
"git_commit": "
|
| 3 |
"files": {
|
| 4 |
"AGENTS.md": {
|
| 5 |
"sha256": "4df6d563018fb1a26bb220f7e3732572cd9fffdc5129c6aa64eb80af98497e47",
|
|
@@ -29,6 +29,10 @@
|
|
| 29 |
"sha256": "1bd72676e17489c4203ef34fce6eb6a2182e647624dd81cce42753df06f9dd88",
|
| 30 |
"bytes": 88082
|
| 31 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
"examples/delete-release-local-validation-2026-10-28.json": {
|
| 33 |
"sha256": "2750191f692e562cee5e63f13fbb43fe448347ac09106b396db28b20d13565e0",
|
| 34 |
"bytes": 8289
|
|
@@ -62,8 +66,8 @@
|
|
| 62 |
"bytes": 16581
|
| 63 |
},
|
| 64 |
"examples/hf-ingress-validation.json": {
|
| 65 |
-
"sha256": "
|
| 66 |
-
"bytes":
|
| 67 |
},
|
| 68 |
"examples/hf-localized-cloud-validation.json": {
|
| 69 |
"sha256": "8e436a05a85a250e0c78d212deb17525715af1079cd6ac773c8eaa44c70fa9eb",
|
|
@@ -114,8 +118,8 @@
|
|
| 114 |
"bytes": 4282
|
| 115 |
},
|
| 116 |
"deploy/hf/app.py": {
|
| 117 |
-
"sha256": "
|
| 118 |
-
"bytes":
|
| 119 |
},
|
| 120 |
"deploy/hf/base-vm-manifest.json": {
|
| 121 |
"sha256": "d3caa63f01a5a0587edf2c514769110023b764005b4c79edc0d21a502dd776ee",
|
|
@@ -470,20 +474,20 @@
|
|
| 470 |
"bytes": 12812
|
| 471 |
},
|
| 472 |
"sites/zkcoding-workbench/dist/admin/admin.css": {
|
| 473 |
-
"sha256": "
|
| 474 |
-
"bytes":
|
| 475 |
},
|
| 476 |
"sites/zkcoding-workbench/dist/admin/admin.js": {
|
| 477 |
-
"sha256": "
|
| 478 |
-
"bytes":
|
| 479 |
},
|
| 480 |
"sites/zkcoding-workbench/dist/admin/index.html": {
|
| 481 |
"sha256": "770a8748b33b41fade244184b8e2994143f3ea93715fcd1b06d928f76822c949",
|
| 482 |
"bytes": 1282
|
| 483 |
},
|
| 484 |
"sites/zkcoding-workbench/dist/admin/workflow-editor.js": {
|
| 485 |
-
"sha256": "
|
| 486 |
-
"bytes":
|
| 487 |
},
|
| 488 |
"sites/zkcoding-workbench/dist/admin/workos-admin-base.css": {
|
| 489 |
"sha256": "515abb29b4c53dd540d9dedc77fc5bd4614c0a7b9a2062a53e8a2cebafecf6e4",
|
|
|
|
| 1 |
{
|
| 2 |
+
"git_commit": "a1793a9a4a5c43fa566a2274c2c27d81e0eb8c98",
|
| 3 |
"files": {
|
| 4 |
"AGENTS.md": {
|
| 5 |
"sha256": "4df6d563018fb1a26bb220f7e3732572cd9fffdc5129c6aa64eb80af98497e47",
|
|
|
|
| 29 |
"sha256": "1bd72676e17489c4203ef34fce6eb6a2182e647624dd81cce42753df06f9dd88",
|
| 30 |
"bytes": 88082
|
| 31 |
},
|
| 32 |
+
"examples/delete-release-cloud-rejections-2026-10-29.json": {
|
| 33 |
+
"sha256": "1430e304afe4554c5d036cdfa46d6d4ef75889410247ea7c7fdd17158b1ac6e2",
|
| 34 |
+
"bytes": 2501
|
| 35 |
+
},
|
| 36 |
"examples/delete-release-local-validation-2026-10-28.json": {
|
| 37 |
"sha256": "2750191f692e562cee5e63f13fbb43fe448347ac09106b396db28b20d13565e0",
|
| 38 |
"bytes": 8289
|
|
|
|
| 66 |
"bytes": 16581
|
| 67 |
},
|
| 68 |
"examples/hf-ingress-validation.json": {
|
| 69 |
+
"sha256": "b3a1a51e464d5c2deda306e15b48715dfdd826558c3e4efa0b1a5e54d393c214",
|
| 70 |
+
"bytes": 1833
|
| 71 |
},
|
| 72 |
"examples/hf-localized-cloud-validation.json": {
|
| 73 |
"sha256": "8e436a05a85a250e0c78d212deb17525715af1079cd6ac773c8eaa44c70fa9eb",
|
|
|
|
| 118 |
"bytes": 4282
|
| 119 |
},
|
| 120 |
"deploy/hf/app.py": {
|
| 121 |
+
"sha256": "857effc073f2ceb82bb22f121aff5b9444d247c57dbc48ed0d9ef5a10f38c40b",
|
| 122 |
+
"bytes": 5796
|
| 123 |
},
|
| 124 |
"deploy/hf/base-vm-manifest.json": {
|
| 125 |
"sha256": "d3caa63f01a5a0587edf2c514769110023b764005b4c79edc0d21a502dd776ee",
|
|
|
|
| 474 |
"bytes": 12812
|
| 475 |
},
|
| 476 |
"sites/zkcoding-workbench/dist/admin/admin.css": {
|
| 477 |
+
"sha256": "68e894cde112b941d7b15b96009e0e70bebe5af57f8c59f97b6e4c77d41a3604",
|
| 478 |
+
"bytes": 18598
|
| 479 |
},
|
| 480 |
"sites/zkcoding-workbench/dist/admin/admin.js": {
|
| 481 |
+
"sha256": "64e1c499cad66ad49adaf9e05d6efd850b6464151eed06c8820a1712f1e7758d",
|
| 482 |
+
"bytes": 39401
|
| 483 |
},
|
| 484 |
"sites/zkcoding-workbench/dist/admin/index.html": {
|
| 485 |
"sha256": "770a8748b33b41fade244184b8e2994143f3ea93715fcd1b06d928f76822c949",
|
| 486 |
"bytes": 1282
|
| 487 |
},
|
| 488 |
"sites/zkcoding-workbench/dist/admin/workflow-editor.js": {
|
| 489 |
+
"sha256": "47821d17ec40b955f0174bff479df6c4a87dca42f2165ec5c9962c05a4c1ca09",
|
| 490 |
+
"bytes": 42866
|
| 491 |
},
|
| 492 |
"sites/zkcoding-workbench/dist/admin/workos-admin-base.css": {
|
| 493 |
"sha256": "515abb29b4c53dd540d9dedc77fc5bd4614c0a7b9a2062a53e8a2cebafecf6e4",
|
examples/delete-release-cloud-rejections-2026-10-29.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"deployment": "5ca3c165e2b2cad21504a966f5395fc1c8a3365c",
|
| 3 |
+
"physical_model_calls": 0,
|
| 4 |
+
"failures": [
|
| 5 |
+
{
|
| 6 |
+
"case": "business-base",
|
| 7 |
+
"run_id": "run-565eca1a3cfc49cf9749b3ecb936d115",
|
| 8 |
+
"status": "failed",
|
| 9 |
+
"error": "MODEL_ROUTE_UNAVAILABLE",
|
| 10 |
+
"model_calls": [],
|
| 11 |
+
"failure": "{'id': 'run-565eca1a3cfc49cf9749b3ecb936d115', 'status': 'failed', 'error': 'MODEL_ROUTE_UNAVAILABLE', 'diagnostics': None}",
|
| 12 |
+
"at_utc": "2026-10-28T15:59:16.490810+00:00"
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"case": "business-variant",
|
| 16 |
+
"run_id": "run-fb7b60fee36e44dcb00a446d00247b6e",
|
| 17 |
+
"status": "failed",
|
| 18 |
+
"error": "MODEL_ROUTE_UNAVAILABLE",
|
| 19 |
+
"model_calls": [],
|
| 20 |
+
"failure": "{'id': 'run-fb7b60fee36e44dcb00a446d00247b6e', 'status': 'failed', 'error': 'MODEL_ROUTE_UNAVAILABLE', 'diagnostics': None}",
|
| 21 |
+
"at_utc": "2026-10-28T16:00:04.355867+00:00"
|
| 22 |
+
},
|
| 23 |
+
{
|
| 24 |
+
"case": "calculator-base",
|
| 25 |
+
"run_id": "run-0928e9a04d9c43f6ab7483de7ef0eba5",
|
| 26 |
+
"status": "failed",
|
| 27 |
+
"error": "MODEL_ROUTE_UNAVAILABLE",
|
| 28 |
+
"model_calls": [],
|
| 29 |
+
"failure": "{'id': 'run-0928e9a04d9c43f6ab7483de7ef0eba5', 'status': 'failed', 'error': 'MODEL_ROUTE_UNAVAILABLE', 'diagnostics': None}",
|
| 30 |
+
"at_utc": "2026-10-28T15:59:35.801413+00:00"
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"case": "calculator-variant",
|
| 34 |
+
"run_id": "run-3516c1ff4fb146cb8646ae66dfc9ac03",
|
| 35 |
+
"status": "failed",
|
| 36 |
+
"error": "MODEL_ROUTE_UNAVAILABLE",
|
| 37 |
+
"model_calls": [],
|
| 38 |
+
"failure": "{'id': 'run-3516c1ff4fb146cb8646ae66dfc9ac03', 'status': 'failed', 'error': 'MODEL_ROUTE_UNAVAILABLE', 'diagnostics': None}",
|
| 39 |
+
"at_utc": "2026-10-28T16:00:19.366824+00:00"
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"case": "pdf-base",
|
| 43 |
+
"run_id": "run-bf29d290106a4bcfa5f095656d22404d",
|
| 44 |
+
"status": "failed",
|
| 45 |
+
"error": "MODEL_ROUTE_UNAVAILABLE",
|
| 46 |
+
"model_calls": [],
|
| 47 |
+
"failure": "{'id': 'run-bf29d290106a4bcfa5f095656d22404d', 'status': 'failed', 'error': 'MODEL_ROUTE_UNAVAILABLE', 'diagnostics': None}",
|
| 48 |
+
"at_utc": "2026-10-28T15:59:49.628891+00:00"
|
| 49 |
+
},
|
| 50 |
+
{
|
| 51 |
+
"case": "pdf-variant",
|
| 52 |
+
"run_id": "run-35f54839244546aabb0456c1ea6b58fb",
|
| 53 |
+
"status": "failed",
|
| 54 |
+
"error": "MODEL_ROUTE_UNAVAILABLE",
|
| 55 |
+
"model_calls": [],
|
| 56 |
+
"failure": "{'id': 'run-35f54839244546aabb0456c1ea6b58fb', 'status': 'failed', 'error': 'MODEL_ROUTE_UNAVAILABLE', 'diagnostics': None}",
|
| 57 |
+
"at_utc": "2026-10-28T16:00:35.854204+00:00"
|
| 58 |
+
}
|
| 59 |
+
]
|
| 60 |
+
}
|
examples/hf-ingress-validation.json
CHANGED
|
@@ -1,17 +1,16 @@
|
|
| 1 |
{
|
| 2 |
"checks": [
|
| 3 |
-
"
|
| 4 |
-
"
|
| 5 |
-
"
|
| 6 |
-
"
|
| 7 |
-
"
|
| 8 |
-
"popup receives the exact parent identity; an independent programmer remains denied"
|
| 9 |
],
|
| 10 |
"errors": [],
|
| 11 |
-
"platform_code_digest": "
|
| 12 |
"cloud_runtime_files": {
|
| 13 |
"deploy/hf/adapter.py": "0088b19648ab9661bb6eb6bdf4fa34de368f5fe5d6c347a58504c60331f42e95",
|
| 14 |
-
"deploy/hf/app.py": "
|
| 15 |
"deploy/hf/prepare_image.py": "8c548bf8881ee0510fd65e5d2de6b464df3d4212bcc5f736363bbdaac32ff0c7",
|
| 16 |
"deploy/hf/Dockerfile": "e18a9d956fec5943436409223be6ec5df6f85be46980a58458e02c9ce3439f31",
|
| 17 |
"deploy/hf/preview_bridge.py": "9a5fe782621e8a9afe2ff199f294018ae4910c007244e350c31829eaaf19d093",
|
|
@@ -20,18 +19,7 @@
|
|
| 20 |
"deploy/hf/preview-bridge.js": "239498ba76cc07d3d263221be5687e8e304f23622fd8699afe8194f835bbee41",
|
| 21 |
"deploy/hf/preview-bridge.html": "0f709ec2027d6f623cfa5c4b6aad4f104355895fdc768907b8c6dd31a52b06cc"
|
| 22 |
},
|
| 23 |
-
"scope": "local HTTPS
|
| 24 |
-
"
|
| 25 |
-
|
| 26 |
-
"image": "zkcoding-qemu@sha256:91bfeedd419e4c56e1a2e3bd5d9a08bccdf255c3e4f9d1bcf9d1a2cb7e749a60",
|
| 27 |
-
"config_digest": "693847819807c1f01dda3455c82277a4fb3b5a0c07f32ab6d5933168d7d9bca9",
|
| 28 |
-
"classes_digest": "779f483b28864a212c3e199cedc317c3664d207bc8eab14f7d48e47d6be085ad",
|
| 29 |
-
"tests": 39,
|
| 30 |
-
"tests_origin": "separate-disposable-vm",
|
| 31 |
-
"suite_digest": "05e353f239f8919946d419e91e63fedccbf62b02386fa12f39ad8795b6a4de4d",
|
| 32 |
-
"network": "none",
|
| 33 |
-
"host_mounts": []
|
| 34 |
-
},
|
| 35 |
-
"passed": 6,
|
| 36 |
-
"tested_at_utc": "2026-10-28T15:55:54.867804+00:00"
|
| 37 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"checks": [
|
| 3 |
+
"全新浏览器直接打开管理端即出现登录表单,未访问工作台;未登录管理 API 拒绝访问",
|
| 4 |
+
"错误密码被拒绝,已有 manager 账号可直接登录;服务端真实 admin 角色与 CSRF 会话生效",
|
| 5 |
+
"独立登录后原子库可通过浏览器原生拖动新增真实节点,实例独立且缺失连接标红",
|
| 6 |
+
"拖入节点可删除、撤销、保存并刷新恢复,后端保留同一节点 ID 和原子版本",
|
| 7 |
+
"退出后会话失效;reviewer 可独立登录查看,不能拖入或保存,并明确提示只读原因"
|
|
|
|
| 8 |
],
|
| 9 |
"errors": [],
|
| 10 |
+
"platform_code_digest": "dafdc25cb77e25512db6a2c6219760a4e06e3689fa2980600c690e8513113286",
|
| 11 |
"cloud_runtime_files": {
|
| 12 |
"deploy/hf/adapter.py": "0088b19648ab9661bb6eb6bdf4fa34de368f5fe5d6c347a58504c60331f42e95",
|
| 13 |
+
"deploy/hf/app.py": "857effc073f2ceb82bb22f121aff5b9444d247c57dbc48ed0d9ef5a10f38c40b",
|
| 14 |
"deploy/hf/prepare_image.py": "8c548bf8881ee0510fd65e5d2de6b464df3d4212bcc5f736363bbdaac32ff0c7",
|
| 15 |
"deploy/hf/Dockerfile": "e18a9d956fec5943436409223be6ec5df6f85be46980a58458e02c9ce3439f31",
|
| 16 |
"deploy/hf/preview_bridge.py": "9a5fe782621e8a9afe2ff199f294018ae4910c007244e350c31829eaaf19d093",
|
|
|
|
| 19 |
"deploy/hf/preview-bridge.js": "239498ba76cc07d3d263221be5687e8e304f23622fd8699afe8194f835bbee41",
|
| 20 |
"deploy/hf/preview-bridge.html": "0f709ec2027d6f623cfa5c4b6aad4f104355895fdc768907b8c6dd31a52b06cc"
|
| 21 |
},
|
| 22 |
+
"scope": "local HTTPS standalone admin login, native drag and persistence; not HF runtime",
|
| 23 |
+
"passed": 5,
|
| 24 |
+
"tested_at_utc": "2026-10-28T16:13:31.219290+00:00"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
}
|
sites/zkcoding-workbench/dist/admin/admin.css
CHANGED
|
@@ -10,22 +10,24 @@
|
|
| 10 |
.mode-badge{color:#348572;background:#eaf6f0;border:1px solid #d7eadf;padding:3px 7px;border-radius:5px;font-size:11px;white-space:nowrap}.canvas-feedback{padding:7px 14px;min-height:39px;max-height:83px;overflow:auto;font-size:12px;line-height:1.6;background:#f8fbff;border-bottom:1px solid #dee7f2;color:#607a9e;display:flex;justify-content:space-between;gap:14px;align-items:center}.canvas-feedback.warning{background:#fff8eb;color:#93672c}.canvas-feedback button{white-space:nowrap;padding:3px 8px;font-size:11px;flex-shrink:0}.canvas-feedback .has-issues{color:#a36b26;border-color:#e9ce96}.node .node-meta{font-size:11px;padding:6px 12px;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.node-bottom>span:first-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:142px}.node-bottom .state{white-space:nowrap}.node .port{width:26px;height:26px;top:35px;background:white;border:1.5px solid #91a9ca;display:flex;align-items:center;justify-content:center;color:#6586b2;font-size:10px;font-style:normal;z-index:3}.node .port.in{left:-14px}.node .port.out{right:-14px}.node .port span{pointer-events:none}.node .port:hover,.node .port:focus-visible,.node .port.connecting,.node .port.drop-ready{color:#fff;background:#5483e8;border-color:#3769ca;outline:3px solid #c6d9fc}.node.connection-error{border-color:#d98f76}.node.connection-error .state{color:#b56e49}.node.connection-warning{border-style:dashed;border-color:#c6ad71}.node.focus-target{box-shadow:0 0 0 5px #75a1f64d,0 5px 25px #5c88dd55}.input-binding{padding:10px;border:1px solid #dfe7f1;border-radius:7px;margin:9px 0;background:#fafcff}.input-binding label{margin:0}.input-binding label small{float:right}.input-binding select{display:block;width:100%;max-width:100%;border:1px solid #d1deed;border-radius:5px;padding:7px;margin-top:8px;color:#385c85;background:white;font-size:12px}.input-binding .binding-state{font-size:11px;color:#7b91ac;line-height:1.7;margin:8px 0 0;overflow-wrap:anywhere}.input-binding.missing-binding{border-color:#e1b486;background:#fffaf3}.field-error{outline:2px solid #e1a365;outline-offset:2px}.technical-details{border-top:1px solid #e4ebf3;margin-top:20px;padding-top:12px}.technical-details summary{color:#6e85a4;font-size:12px;cursor:pointer}.technical-details .kv{margin-top:15px}#locateCount{font-size:11px;color:#7890af;min-width:30px;white-space:nowrap}.edges path.selected-edge{stroke:#de8f38;stroke-width:4}.edges g.selected-edge rect{stroke:#de8f38;stroke-width:2}.located-issue{margin-bottom:15px}.issue-warning strong{color:#aa7b30}#mappingHint{margin:14px 0}#mappingTarget{width:100%}.node-edit-panel details{margin:14px 0;font-size:12px;color:#7188a5}.node-edit-panel select{max-width:100%}
|
| 11 |
|
| 12 |
/* Dot appearance is separate from the generous pointer/keyboard target. */
|
| 13 |
-
.node .port{width:24px;height:24px;top:35px;border:0;background:transparent;color:transparent;outline:none}
|
| 14 |
-
.node .port.in{left:-13px}.node .port.out{right:-13px}
|
| 15 |
.node .port::after{content:'';width:10px;height:10px;border-radius:50%;border:2px solid #6e809b;background:#fff;pointer-events:none}
|
| 16 |
.node .port.connected::after{border-color:#19805b;background:#2aa776}
|
| 17 |
.node .port.missing::after{border-color:#c52f40;background:#ed5360}
|
| 18 |
.node .port:hover,.node .port:focus-visible,.node .port.connecting,.node .port.drop-ready{background:transparent;outline:none}
|
| 19 |
.node .port:hover::after,.node .port:focus-visible::after,.node .port.connecting::after,.node .port.drop-ready::after{box-shadow:0 0 0 4px #8eb7ff88}
|
| 20 |
-
.node.connection-error,.node.connection-warning{border:2px solid #dc3547;background:#fff7f7}
|
| 21 |
-
.node.connection-error:hover:not(:disabled),.node.connection-warning:hover:not(:disabled){border-color:#dc3547;background:#fff1f3}
|
| 22 |
-
.node.connection-error.selected,.node.connection-warning.selected{outline:2px solid #dc3547}
|
| 23 |
-
.node.connection-error .port,.node.connection-warning .port{top:34px}
|
| 24 |
-
.node.connection-error .port.in,.node.connection-warning .port.in{left:-14px}
|
| 25 |
-
.node.connection-error .port.out,.node.connection-warning .port.out{right:-14px}
|
| 26 |
.node.connection-error .node-heading,.node.connection-warning .node-heading{background:#ffecef}
|
| 27 |
.node.connection-error .state,.node.connection-warning .state{color:#bb2538}
|
| 28 |
.input-binding.missing-binding{border-color:#dc3547;background:#fff1f3}
|
| 29 |
.field-error{outline-color:#dc3547}
|
| 30 |
.canvas-feedback.warning{background:#fff1f3;color:#b72d3f}
|
| 31 |
.canvas-feedback .has-issues{color:#b72d3f;border-color:#e68d98;background:#fff6f7}
|
|
|
|
|
|
|
|
|
| 10 |
.mode-badge{color:#348572;background:#eaf6f0;border:1px solid #d7eadf;padding:3px 7px;border-radius:5px;font-size:11px;white-space:nowrap}.canvas-feedback{padding:7px 14px;min-height:39px;max-height:83px;overflow:auto;font-size:12px;line-height:1.6;background:#f8fbff;border-bottom:1px solid #dee7f2;color:#607a9e;display:flex;justify-content:space-between;gap:14px;align-items:center}.canvas-feedback.warning{background:#fff8eb;color:#93672c}.canvas-feedback button{white-space:nowrap;padding:3px 8px;font-size:11px;flex-shrink:0}.canvas-feedback .has-issues{color:#a36b26;border-color:#e9ce96}.node .node-meta{font-size:11px;padding:6px 12px;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.node-bottom>span:first-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:142px}.node-bottom .state{white-space:nowrap}.node .port{width:26px;height:26px;top:35px;background:white;border:1.5px solid #91a9ca;display:flex;align-items:center;justify-content:center;color:#6586b2;font-size:10px;font-style:normal;z-index:3}.node .port.in{left:-14px}.node .port.out{right:-14px}.node .port span{pointer-events:none}.node .port:hover,.node .port:focus-visible,.node .port.connecting,.node .port.drop-ready{color:#fff;background:#5483e8;border-color:#3769ca;outline:3px solid #c6d9fc}.node.connection-error{border-color:#d98f76}.node.connection-error .state{color:#b56e49}.node.connection-warning{border-style:dashed;border-color:#c6ad71}.node.focus-target{box-shadow:0 0 0 5px #75a1f64d,0 5px 25px #5c88dd55}.input-binding{padding:10px;border:1px solid #dfe7f1;border-radius:7px;margin:9px 0;background:#fafcff}.input-binding label{margin:0}.input-binding label small{float:right}.input-binding select{display:block;width:100%;max-width:100%;border:1px solid #d1deed;border-radius:5px;padding:7px;margin-top:8px;color:#385c85;background:white;font-size:12px}.input-binding .binding-state{font-size:11px;color:#7b91ac;line-height:1.7;margin:8px 0 0;overflow-wrap:anywhere}.input-binding.missing-binding{border-color:#e1b486;background:#fffaf3}.field-error{outline:2px solid #e1a365;outline-offset:2px}.technical-details{border-top:1px solid #e4ebf3;margin-top:20px;padding-top:12px}.technical-details summary{color:#6e85a4;font-size:12px;cursor:pointer}.technical-details .kv{margin-top:15px}#locateCount{font-size:11px;color:#7890af;min-width:30px;white-space:nowrap}.edges path.selected-edge{stroke:#de8f38;stroke-width:4}.edges g.selected-edge rect{stroke:#de8f38;stroke-width:2}.located-issue{margin-bottom:15px}.issue-warning strong{color:#aa7b30}#mappingHint{margin:14px 0}#mappingTarget{width:100%}.node-edit-panel details{margin:14px 0;font-size:12px;color:#7188a5}.node-edit-panel select{max-width:100%}
|
| 11 |
|
| 12 |
/* Dot appearance is separate from the generous pointer/keyboard target. */
|
| 13 |
+
.node .port{width:24px;height:24px;top:35px;border:0;background:transparent;color:transparent;outline:none}
|
| 14 |
+
.node .port.in{left:-13px}.node .port.out{right:-13px}
|
| 15 |
.node .port::after{content:'';width:10px;height:10px;border-radius:50%;border:2px solid #6e809b;background:#fff;pointer-events:none}
|
| 16 |
.node .port.connected::after{border-color:#19805b;background:#2aa776}
|
| 17 |
.node .port.missing::after{border-color:#c52f40;background:#ed5360}
|
| 18 |
.node .port:hover,.node .port:focus-visible,.node .port.connecting,.node .port.drop-ready{background:transparent;outline:none}
|
| 19 |
.node .port:hover::after,.node .port:focus-visible::after,.node .port.connecting::after,.node .port.drop-ready::after{box-shadow:0 0 0 4px #8eb7ff88}
|
| 20 |
+
.node.connection-error,.node.connection-warning{border:2px solid #dc3547;background:#fff7f7}
|
| 21 |
+
.node.connection-error:hover:not(:disabled),.node.connection-warning:hover:not(:disabled){border-color:#dc3547;background:#fff1f3}
|
| 22 |
+
.node.connection-error.selected,.node.connection-warning.selected{outline:2px solid #dc3547}
|
| 23 |
+
.node.connection-error .port,.node.connection-warning .port{top:34px}
|
| 24 |
+
.node.connection-error .port.in,.node.connection-warning .port.in{left:-14px}
|
| 25 |
+
.node.connection-error .port.out,.node.connection-warning .port.out{right:-14px}
|
| 26 |
.node.connection-error .node-heading,.node.connection-warning .node-heading{background:#ffecef}
|
| 27 |
.node.connection-error .state,.node.connection-warning .state{color:#bb2538}
|
| 28 |
.input-binding.missing-binding{border-color:#dc3547;background:#fff1f3}
|
| 29 |
.field-error{outline-color:#dc3547}
|
| 30 |
.canvas-feedback.warning{background:#fff1f3;color:#b72d3f}
|
| 31 |
.canvas-feedback .has-issues{color:#b72d3f;border-color:#e68d98;background:#fff6f7}
|
| 32 |
+
|
| 33 |
+
.admin-login{min-height:100%;display:grid;place-items:center;padding:30px}.admin-login form{background:#fff;border:1px solid #dce4ef;border-radius:12px;padding:30px;width:380px;max-width:100%;box-shadow:0 8px 35px #1932560a}.admin-login h1{font-size:21px}.admin-login p{color:#71839c;font-size:13px}.admin-login label{display:block;margin:16px 0;font-size:13px}.admin-login input{display:block;width:100%;padding:10px;margin-top:6px;border:1px solid #cfdbeb;border-radius:6px}.admin-login small{display:block;margin-top:17px}.admin-login #adminLoginError{color:#b72d3f;min-height:20px}.admin-login button{width:100%}#account button{font-size:12px;padding:3px 8px;margin-left:8px}
|
sites/zkcoding-workbench/dist/admin/admin.js
CHANGED
|
@@ -110,6 +110,22 @@ function focusIssue(issue){const f=store.flow,target=resolveIssueLocation(f.defi
|
|
| 110 |
|
| 111 |
function renderTrace(){const t=store.trace;$('#tracePanel').innerHTML=`<div class="trace-head"><span><strong>运行轨迹</strong> · ${esc(t.id)} · ${pill(t.status,t.lease_expired?'租约已过期,结果待核实':t.pending?.scope==='acceptance'?'等待用户验收':label(t.status))} ${t.error?esc(t.error):''} ${t.web_status&&t.web_status!==t.status?' · 任务记录:'+esc(label(t.web_status)):''}</span><span><a href="${esc(t.record_url)}" target="_blank" rel="noopener">原始运行记录 ↗</a> <button id="refreshTrace">刷新</button> <button id="collapseTrace" aria-label="收起运行轨迹">收起</button></span></div><div id="traceEvents"></div><button id="moreEvents" ${t.after?'':'hidden'}>加载后续日志 (${t.total_events} 条)</button>`;appendEvents(t.events);$('#moreEvents').onclick=async()=>{try{const p=await api('workflow-runs/'+encodeURIComponent(t.id)+'?after='+t.after);appendEvents(p.events);t.after=p.after;$('#moreEvents').hidden=!t.after}catch(e){error(e)}};$('#refreshTrace').onclick=()=>openWorkflow(t.workflow,{run:t.id}).catch(error);$('#collapseTrace').onclick=()=>{$('#tracePanel').style.maxHeight=$('#tracePanel').style.maxHeight?'':'49px'};}
|
| 112 |
function appendEvents(events){$('#traceEvents').insertAdjacentHTML('beforeend',events.map(e=>`<div class="event"><span>${time(e.timestamp)}</span><button data-event-node="${esc(e.stage)}">${esc(e.stage)}</button><span class="${e.code?'error':''}">${esc(label(e.status))} ${esc(e.code||'')}</span><small>${esc(e.summary)}</small></div>`).join(''));$$('[data-event-node]').forEach(b=>{const known=store.flow.nodes.some(n=>n.id===b.dataset.eventNode);b.title=known?'定位实际节点':'运行器内部事件,不是工作流节点';b.onclick=()=>{if(known)selectNode(b.dataset.eventNode);else status('运行器内部事件 '+b.dataset.eventNode+',未虚构图节点');};});}
|
| 113 |
-
async function route(){const current=++store.route;$('#notice').hidden=true;$('.modal-backdrop')?.remove();const h=location.hash.slice(1)||'workflows';$$('[data-page]').forEach(a=>a.classList.toggle('active',a.dataset.page===(h.startsWith('run=')?'runs':h.startsWith('workflow=')?'workflows':h)));try{if(h==='atoms')atoms();else if(h==='runs')await runs();else if(h.startsWith('workflow='))await openWorkflow(decodeURIComponent(h.slice(9)));else if(h.startsWith('run=')){const t=await api('workflow-runs/'+encodeURIComponent(h.slice(4)));if(current===store.route)await openWorkflow(t.workflow,{run:t.id})}else workflows();}catch(e){if(current===store.route)error(e);}}
|
| 114 |
window.addEventListener('hashchange',route);window.addEventListener('resize',()=>{if($('#canvas'))transform()});document.addEventListener('keydown',e=>{if(e.key==='Escape'){if($('.modal-backdrop'))$('.modal-backdrop').remove();else closeInspector()}});
|
| 115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
function renderTrace(){const t=store.trace;$('#tracePanel').innerHTML=`<div class="trace-head"><span><strong>运行轨迹</strong> · ${esc(t.id)} · ${pill(t.status,t.lease_expired?'租约已过期,结果待核实':t.pending?.scope==='acceptance'?'等待用户验收':label(t.status))} ${t.error?esc(t.error):''} ${t.web_status&&t.web_status!==t.status?' · 任务记录:'+esc(label(t.web_status)):''}</span><span><a href="${esc(t.record_url)}" target="_blank" rel="noopener">原始运行记录 ↗</a> <button id="refreshTrace">刷新</button> <button id="collapseTrace" aria-label="收起运行轨迹">收起</button></span></div><div id="traceEvents"></div><button id="moreEvents" ${t.after?'':'hidden'}>加载后续日志 (${t.total_events} 条)</button>`;appendEvents(t.events);$('#moreEvents').onclick=async()=>{try{const p=await api('workflow-runs/'+encodeURIComponent(t.id)+'?after='+t.after);appendEvents(p.events);t.after=p.after;$('#moreEvents').hidden=!t.after}catch(e){error(e)}};$('#refreshTrace').onclick=()=>openWorkflow(t.workflow,{run:t.id}).catch(error);$('#collapseTrace').onclick=()=>{$('#tracePanel').style.maxHeight=$('#tracePanel').style.maxHeight?'':'49px'};}
|
| 112 |
function appendEvents(events){$('#traceEvents').insertAdjacentHTML('beforeend',events.map(e=>`<div class="event"><span>${time(e.timestamp)}</span><button data-event-node="${esc(e.stage)}">${esc(e.stage)}</button><span class="${e.code?'error':''}">${esc(label(e.status))} ${esc(e.code||'')}</span><small>${esc(e.summary)}</small></div>`).join(''));$$('[data-event-node]').forEach(b=>{const known=store.flow.nodes.some(n=>n.id===b.dataset.eventNode);b.title=known?'定位实际节点':'运行器内部事件,不是工作流节点';b.onclick=()=>{if(known)selectNode(b.dataset.eventNode);else status('运行器内部事件 '+b.dataset.eventNode+',未虚构图节点');};});}
|
| 113 |
+
async function route(){if(!store.actorId){showLogin();return;}const current=++store.route;$('#notice').hidden=true;$('.modal-backdrop')?.remove();const h=location.hash.slice(1)||'workflows';$$('[data-page]').forEach(a=>a.classList.toggle('active',a.dataset.page===(h.startsWith('run=')?'runs':h.startsWith('workflow=')?'workflows':h)));try{if(h==='atoms')atoms();else if(h==='runs')await runs();else if(h.startsWith('workflow='))await openWorkflow(decodeURIComponent(h.slice(9)));else if(h.startsWith('run=')){const t=await api('workflow-runs/'+encodeURIComponent(h.slice(4)));if(current===store.route)await openWorkflow(t.workflow,{run:t.id})}else workflows();}catch(e){if(current===store.route)error(e);}}
|
| 114 |
window.addEventListener('hashchange',route);window.addEventListener('resize',()=>{if($('#canvas'))transform()});document.addEventListener('keydown',e=>{if(e.key==='Escape'){if($('.modal-backdrop'))$('.modal-backdrop').remove();else closeInspector()}});
|
| 115 |
+
async function loadAdmin(){
|
| 116 |
+
const session=await fetch('/api/session',{cache:'no-store'}).then(r=>r.json());
|
| 117 |
+
if(!session.authenticated){showLogin();return;}
|
| 118 |
+
store.canEdit=session.actor?.roles?.some(r=>['admin','skill_manager'].includes(r));store.actorId=session.actor?.user_id;store.csrf=session.csrf;store.previewOrigin=session.preview_origin;
|
| 119 |
+
$('#account').innerHTML='<span>'+esc(session.username||'已登录')+'</span> <button id="adminLogout">退出</button>';
|
| 120 |
+
$('#adminLogout').onclick=async()=>{const r=await fetch('/api/session/logout',{method:'POST',headers:{'X-CSRF-Token':store.csrf}});if(r.ok){edgePan.stop();store.actorId=null;store.canEdit=false;store.selected=null;store.selectedEdge=null;store.flow=null;showLogin();}else error(Error('退出未完成,请重试'));};
|
| 121 |
+
try{[store.workflows,store.atoms]=await Promise.all([api('workflows'),api('workflow-atoms')]);$('#connection').textContent='已连接真实配置';await route();}
|
| 122 |
+
catch(e){store.actorId=null;showLogin(e.message);}
|
| 123 |
+
}
|
| 124 |
+
function showLogin(message=''){store.actorId=null;store.canEdit=false;edgePan.stop();
|
| 125 |
+
$('#notice').hidden=true;$('#account').textContent='未登录';$('#connection').textContent='管理端独立登录';$('#pageTitle').textContent='登录管理端';
|
| 126 |
+
content.inert=false;content.removeAttribute('aria-busy');content.innerHTML=`<div class="admin-login"><form id="adminLogin"><h1>登录管理端</h1><p>使用已有账号直接登录,无需先打开工作台。</p><label>账号<input id="adminUsername" name="username" autocomplete="username" value="manager" required></label><label>密码<input id="adminPassword" name="password" type="password" autocomplete="current-password" required></label><p id="adminLoginError" role="alert">${esc(message)}</p><button type="submit" class="primary">登录</button><small>使用已有管理账号密码;演示管理员为 manager(周宁)。</small></form></div>`;
|
| 127 |
+
$('#adminLogin').onsubmit=async e=>{e.preventDefault();const button=e.target.querySelector('[type=submit]');button.disabled=true;$('#adminLoginError').textContent='';try{const r=await fetch('/api/session/login',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({username:$('#adminUsername').value.trim(),password:$('#adminPassword').value})});const data=await r.json();if(!r.ok)throw Error(data.message||'登录失败');$('#adminPassword').value='';await loadAdmin();}catch(err){$('#adminLoginError').textContent=err.message;}finally{button.disabled=false;}};
|
| 128 |
+
status('使用真实账号登录后按已有角色权限访问管理端');
|
| 129 |
+
}
|
| 130 |
+
if(location.hostname==='dellweb3-vibecoding.hf.space'){$('.nav-bottom').firstChild.textContent='HF 演示环境';$('.phase').textContent='草稿编辑 · 空间内试运行';$('footer span:last-child').textContent='工作台与预览 · 同一 HTTPS 入口';}
|
| 131 |
+
await loadAdmin();
|
sites/zkcoding-workbench/dist/admin/workflow-editor.js
CHANGED
|
@@ -147,7 +147,7 @@ export function createEditor(ctx){
|
|
| 147 |
}
|
| 148 |
|
| 149 |
function palette(){
|
| 150 |
-
$$('[data-palette-atom]').forEach(button=>{button.draggable=editable();button.title=editable()?'拖入画布添加节点;点击查看定义':'
|
| 151 |
}
|
| 152 |
function dropTarget(view){view.ondragover=e=>{if(editable()&&[...e.dataTransfer.types].includes('application/x-zkcoding-atom')){e.preventDefault();e.dataTransfer.dropEffect='copy';edgePan.update(e,()=>{});}};view.ondragleave=e=>{if(!view.contains(e.relatedTarget))edgePan.stop();};view.ondrop=e=>{e.preventDefault();edgePan.stop();const ref=e.dataTransfer.getData('application/x-zkcoding-atom');const atom=store.atoms.find(a=>a.ref===ref);if(!editable()||!atom)return;addAtom(atom,e.clientX,e.clientY);};}
|
| 153 |
function addAtom(atom,clientX,clientY){
|
|
|
|
| 147 |
}
|
| 148 |
|
| 149 |
function palette(){
|
| 150 |
+
$$('[data-palette-atom]').forEach(button=>{button.draggable=editable();button.title=editable()?'拖入画布添加节点;点击查看定义':!store.canEdit?'当前账号只读,请用管理账号登录':'历史版本只读,请选择当前草稿';button.ondragstart=e=>{if(!editable()){e.preventDefault();return;}const ref=button.dataset.paletteAtom;if(ref.startsWith('AO12@')||ref.startsWith('AO13@')){e.preventDefault();error(Error('修复由运行器管理,新的工作流不再加入模型检视'));return;}e.dataTransfer.setData('application/x-zkcoding-atom',ref);e.dataTransfer.effectAllowed='copy';};});
|
| 151 |
}
|
| 152 |
function dropTarget(view){view.ondragover=e=>{if(editable()&&[...e.dataTransfer.types].includes('application/x-zkcoding-atom')){e.preventDefault();e.dataTransfer.dropEffect='copy';edgePan.update(e,()=>{});}};view.ondragleave=e=>{if(!view.contains(e.relatedTarget))edgePan.stop();};view.ondrop=e=>{e.preventDefault();edgePan.stop();const ref=e.dataTransfer.getData('application/x-zkcoding-atom');const atom=store.atoms.find(a=>a.ref===ref);if(!editable()||!atom)return;addAtom(atom,e.clientX,e.clientY);};}
|
| 153 |
function addAtom(atom,clientX,clientY){
|