feat: 完成三角色工作台及金租对公Skills全流程演示

This commit is contained in:
NathanAlex7
2026-09-15 10:32:24 +08:00
parent 5f0b1f9409
commit 47ec090345
58 changed files with 2534 additions and 609 deletions
+41
View File
@@ -4,6 +4,7 @@ import sqlite3
from contextlib import contextmanager
from datetime import datetime, timezone
from hashlib import sha256
from pathlib import Path
from uuid import uuid4
@@ -50,6 +51,9 @@ def initialize(path):
lease_until REAL NOT NULL DEFAULT 0, attempts INTEGER NOT NULL DEFAULT 0);
CREATE TABLE IF NOT EXISTS assistant_meta (key TEXT PRIMARY KEY, value TEXT);
""")
schema = Path(__file__).resolve().parents[1] / "fixtures" / "xingbang_demo" / "business_flow_schema.sql"
if schema.exists():
db.executescript(schema.read_text(encoding="utf-8"))
def get(db, kind, object_id):
@@ -84,5 +88,42 @@ def event(db, project_id, action, actor, detail=None, run_id=None):
db.execute("INSERT INTO assistant_events(project_id,run_id,body) VALUES (?,?,?)", (project_id, run_id, json.dumps(body, ensure_ascii=False)))
def time_event(db, project_id, phase_code, phase_name, role, category, actor, source_type, source_id,
status="running", started_at=None, ended_at=None, detail=None, event_id=None):
"""Create an immutable phase interval; callers close it with finish_time_event."""
event_id = event_id or uid("time")
db.execute(
"INSERT INTO business_time_events VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)",
(event_id, project_id, phase_code, phase_name, role, category, status,
started_at or now(), ended_at, actor, source_type, source_id,
json.dumps(detail or {}, ensure_ascii=False)),
)
return event_id
def finish_time_event(db, source_type, source_id, status="completed", ended_at=None):
db.execute(
"UPDATE business_time_events SET status=?,ended_at=? WHERE source_type=? AND source_id=? AND status='running'",
(status, ended_at or now(), source_type, source_id),
)
def time_listing(db, project_ids=None):
query = "SELECT * FROM business_time_events"
params = []
if project_ids is not None:
if not project_ids:
return []
query += " WHERE project_id IN (" + ",".join("?" for _ in project_ids) + ")"
params.extend(project_ids)
query += " ORDER BY started_at"
result = []
for row in db.execute(query, params):
item = dict(row)
item["detail"] = json.loads(item["detail"] or "{}")
result.append(item)
return result
class Conflict(ValueError):
pass