Skip to content

Commit 8abe00a

Browse files
authored
Merge pull request #133 from recombyn/chore/drop-remaining-aliases
chore: drop remaining dual-read aliases
2 parents 9c14622 + cc926bd commit 8abe00a

143 files changed

Lines changed: 705 additions & 1283 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/api/app/api/routes/admin/common.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class GenerateCardKeysIn(BaseModel):
126126
"""credit = unified 积分 top-up; plan = membership + monthly 积分."""
127127
kind: str = Field(default="credit", max_length=16)
128128
# Face value in 积分.
129-
tokens: int = Field(default=0, ge=0, le=50_000_000)
129+
credits: int = Field(default=0, ge=0, le=50_000_000)
130130
planId: str | None = Field(default=None, max_length=16)
131131
expiresDays: int = Field(default=365, ge=0, le=3650)
132132
# Dedicated generate password (CARD_KEY_OPS_PASSWORD), not the login password.

‎apps/api/app/api/routes/admin/users.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def admin_generate_card_keys(
117117
try:
118118
keys = generate_card_keys(
119119
count=body.count,
120-
tokens=body.tokens,
120+
credits=body.credits,
121121
expires_days=body.expiresDays,
122122
kind=body.kind,
123123
plan_id=body.planId,
@@ -131,7 +131,7 @@ def admin_generate_card_keys(
131131
"count": len(keys),
132132
"kind": first.get("kind") or body.kind,
133133
"planId": first.get("planId") or body.planId,
134-
"tokens": first.get("tokens") if keys else body.tokens,
134+
"credits": first.get("credits") if keys else body.credits,
135135
"expiresDays": body.expiresDays,
136136
"keys": keys,
137137
}

‎apps/api/app/api/routes/auth.py‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
)
5353
from app.services.wallet.db import (
5454
ensure_user_balance,
55-
get_user_tokens,
5655
get_wallet,
5756
init_wallet_db,
5857
list_ledger,
@@ -510,10 +509,8 @@ def email_login(body: EmailLoginIn, request: Request) -> dict[str, Any]:
510509

511510
@router.get("/me", response_model=AuthMeOut)
512511
def auth_me(current_user: CurrentUser) -> dict[str, Any]:
513-
init_wallet_db()
514512
return {
515513
"user": _user_payload(current_user),
516-
"tokens": get_user_tokens(current_user.id),
517514
}
518515

519516

@@ -578,10 +575,9 @@ def _wallet_plan_fields(snap: dict[str, Any]) -> dict[str, Any]:
578575
def wallet_me(current_user: CurrentUser) -> dict[str, Any]:
579576
init_wallet_db()
580577
snap = get_wallet(current_user.id)
581-
credits = int(snap.get("credits") or snap.get("tokens") or 0)
578+
credits = int(snap.get("credits") or 0)
582579
return {
583580
"credits": credits,
584-
"tokens": credits,
585581
**_wallet_plan_fields(snap),
586582
"ledger": list_ledger(current_user.id),
587583
}
@@ -600,10 +596,9 @@ def wallet_ledger(
600596
"""
601597
init_wallet_db()
602598
snap = get_wallet(current_user.id)
603-
credits = int(snap.get("credits") or snap.get("tokens") or 0)
599+
credits = int(snap.get("credits") or 0)
604600
return {
605601
"credits": credits,
606-
"tokens": credits,
607602
**_wallet_plan_fields(snap),
608603
**list_ledger_page(current_user.id, page=page, page_size=pageSize, kind=kind),
609604
}
@@ -640,14 +635,12 @@ def wallet_redeem(
640635
) from err
641636
clear_redeem_rate_limit(user_id=current_user.id, ip=ip)
642637
snap = get_wallet(current_user.id)
643-
credits = int(snap.get("credits") or snap.get("tokens") or 0)
644-
added = int(result.get("creditsAdded") or result.get("tokensAdded") or 0)
638+
credits = int(snap.get("credits") or 0)
639+
added = int(result.get("creditsAdded") or 0)
645640
return {
646641
"kind": result.get("kind") or "credit",
647642
"creditsAdded": added,
648-
"tokensAdded": added,
649643
"credits": credits,
650-
"tokens": credits,
651644
**_wallet_plan_fields(snap),
652645
"ledger": list_ledger(current_user.id),
653646
}

‎apps/api/app/crud.py‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2438,17 +2438,15 @@ def _bind(val: Any) -> str:
24382438
where.append(f"status = {_bind(status.strip())}")
24392439
if q and q.strip():
24402440
like = f"%{q.strip()}%"
2441-
b1, b2, b3, b4, b5 = (
2442-
_bind(like),
2441+
b1, b2, b3, b4 = (
24432442
_bind(like),
24442443
_bind(like),
24452444
_bind(like),
24462445
_bind(like),
24472446
)
24482447
where.append(
24492448
f"(id LIKE {b1} OR user_id LIKE {b2} OR prompt LIKE {b3} OR "
2450-
f"coalesce(json_extract(meta_json, '$.trace_id'), '') LIKE {b4} OR "
2451-
f"coalesce(json_extract(meta_json, '$.decision_log.trace_id'), '') LIKE {b5})"
2449+
f"coalesce(json_extract(meta_json, '$.decision_log.trace_id'), '') LIKE {b4})"
24522450
)
24532451
route_filter = (route or "").strip().lower()
24542452
if route_filter:
@@ -2477,24 +2475,20 @@ def _bind(val: Any) -> str:
24772475
f"""
24782476
SELECT
24792477
id, user_id, scene, status, prompt, error_message, created_at, updated_at,
2480-
json_extract(meta_json, '$.trace_id') AS trace_id,
24812478
json_extract(meta_json, '$.control') AS control,
24822479
json_extract(meta_json, '$.flow_id') AS flow_id,
2480+
json_extract(meta_json, '$.flow_version') AS flow_version,
24832481
json_extract(meta_json, '$.decision_log.trace_id') AS dl_trace,
24842482
json_extract(meta_json, '$.decision_log.route') AS dl_route,
24852483
json_extract(meta_json, '$.decision_log.intent') AS dl_intent,
2486-
json_extract(meta_json, '$.execution_log.trace_id') AS el_trace,
2487-
json_extract(meta_json, '$.execution_log.intent') AS el_intent,
2488-
json_extract(meta_json, '$.execution_log.flow_id') AS el_flow,
24892484
json_extract(meta_json, '$.execution_log.ops_count') AS ops_count,
24902485
json_extract(meta_json, '$.execution_log.total_tokens') AS total_tokens,
24912486
json_extract(meta_json, '$.execution_log.total_duration_ms') AS total_duration_ms,
24922487
json_extract(meta_json, '$.execution_log.painted') AS painted,
24932488
json_extract(meta_json, '$.execution_log.task_tier') AS task_tier,
24942489
json_extract(meta_json, '$.execution_log.vision_used') AS vision_used,
24952490
json_extract(meta_json, '$.execution_log.model') AS model,
2496-
json_extract(meta_json, '$.execution_log.skills_loaded') AS el_skills,
2497-
json_extract(meta_json, '$.decision_log.skills_loaded') AS dl_skills
2491+
json_extract(meta_json, '$.execution_log.skills_loaded') AS el_skills
24982492
FROM design_task
24992493
WHERE {sql_where}
25002494
ORDER BY created_at DESC

‎apps/api/app/models.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class AuthSessionOut(SQLModel):
4848

4949
class AuthMeOut(SQLModel):
5050
user: UserPublic
51-
tokens: int | float | None = None
5251

5352

5453
class OkOut(SQLModel):

‎apps/api/app/services/admin/users.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from app.services.db import init_schema
1313
from app.services.wallet.db import (
1414
credit_tokens,
15-
get_user_tokens,
1615
get_wallet,
1716
list_ledger_page,
1817
normalize_plan,
@@ -97,7 +96,7 @@ def adjust_tokens(user_id: str, amount: int, detail: str = "") -> dict[str, Any]
9796
else:
9897
balance = spend_tokens(uid, abs(amt), detail=note, force=True)
9998

100-
return {"userId": uid, "tokens": balance, "amount": amt}
99+
return {"userId": uid, "credits": balance, "amount": amt}
101100

102101

103102
def user_ledger(
@@ -110,7 +109,7 @@ def user_ledger(
110109
snap = get_wallet(user_id)
111110
expires = snap.get("planExpiresAt")
112111
return {
113-
"tokens": int(snap.get("tokens") or get_user_tokens(user_id) or 0),
112+
"credits": int(snap.get("credits") or 0),
114113
"planId": snap.get("planId") or "free",
115114
"planStored": snap.get("planStored") or "free",
116115
"planExpiresAt": int(float(expires) * 1000) if expires is not None else None,
@@ -149,7 +148,7 @@ def _user_to_out(user: User, bal: UserBalance | None) -> dict[str, Any]:
149148
"provider": user.provider or "email",
150149
"role": user.role or "user",
151150
"status": user.status or "active",
152-
"tokens": int(bal.tokens or 0) if bal else 0,
151+
"credits": int(bal.tokens or 0) if bal else 0,
153152
"planId": plan_id,
154153
"planStored": stored,
155154
"planExpiresAt": int(expires_at * 1000) if expires_at is not None else None,

‎apps/api/app/services/agent_memory/episodes.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ def _summarize_actions(ops: list[Any] | None) -> list[dict[str, Any]]:
6666
for item in ops or []:
6767
if not isinstance(item, dict):
6868
continue
69-
name = str(item.get("op") or item.get("type") or item.get("name") or "").strip()
69+
name = str(item.get("name") or "").strip()
7070
if not name:
7171
continue
72-
slim: dict[str, Any] = {"op": name[:64]}
72+
slim: dict[str, Any] = {"name": name[:64]}
7373
for key in ("id", "frameId", "targetId", "name"):
7474
val = item.get(key)
7575
if val is not None and str(val).strip():
@@ -280,9 +280,9 @@ def _row_to_hit(r: Any, *, retrieve: str, score: float | None = None) -> dict[st
280280
except Exception:
281281
actions = []
282282
op_names = [
283-
str(a.get("op") or "")
283+
str(a.get("name") or "")
284284
for a in actions
285-
if isinstance(a, dict) and a.get("op")
285+
if isinstance(a, dict) and a.get("name")
286286
]
287287
hit: dict[str, Any] = {
288288
"id": str(_col(r, "id") or ""),

‎apps/api/app/services/agent_memory/kg.py‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def extract_factual_triples_from_episode(
206206
op_names: list[str] = []
207207
for a in actions or []:
208208
if isinstance(a, dict):
209-
name = str(a.get("op") or a.get("name") or "").strip()
209+
name = str(a.get("name") or "").strip()
210210
if name:
211211
op_names.append(name)
212212
elif isinstance(a, str) and a.strip():
@@ -553,17 +553,15 @@ def _parse_triples_json(
553553
raw = None
554554
items: list[Any] = []
555555
if isinstance(raw, dict):
556-
items = raw.get("triples") or raw.get("items") or raw.get("edges") or []
557-
elif isinstance(raw, list):
558-
items = raw
556+
items = raw.get("triples") or []
559557
sc = (scene or "").strip().lower() or ""
560558
out: list[tuple[str, str, str]] = []
561559
for it in items:
562560
if not isinstance(it, dict):
563561
continue
564-
s = str(it.get("s") or it.get("subject") or "").strip()
565-
p = str(it.get("p") or it.get("predicate") or "").strip()
566-
o = str(it.get("o") or it.get("object") or "").strip()
562+
s = str(it.get("s") or "").strip()
563+
p = str(it.get("p") or "").strip()
564+
o = str(it.get("o") or "").strip()
567565
if not p or not o:
568566
continue
569567
if p not in allowed:

‎apps/api/app/services/agent_memory/schema.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def slim_review_for_memory(review: dict[str, Any] | None) -> dict[str, Any]:
127127
out["overall"] = int(src.get("overall"))
128128
except (TypeError, ValueError):
129129
pass
130-
action = str(src.get("action") or src.get("review_action") or "").strip()
130+
action = str(src.get("action") or "").strip()
131131
if action:
132132
out["action"] = action
133133
summary = str(src.get("summary") or "").strip()
@@ -357,7 +357,7 @@ def trim_short_turn(turn: dict[str, Any]) -> dict[str, Any] | None:
357357
role = str(turn.get("role") or "").strip().lower()
358358
if role not in ("user", "assistant"):
359359
return None
360-
text = str(turn.get("text") or turn.get("content") or "").strip()
360+
text = str(turn.get("text") or "").strip()
361361
if not text:
362362
return None
363363
if re_looks_like_markup(text):
@@ -373,4 +373,4 @@ def trim_short_turn(turn: dict[str, Any]) -> dict[str, Any] | None:
373373
def re_looks_like_markup(text: str) -> bool:
374374
import re
375375

376-
return bool(re.search(r"<svg\b|</svg>|\{\s*\"tool_ops\"|\"ops\"\s*:", text, flags=re.I))
376+
return bool(re.search(r"<svg\b|</svg>|\{\s*\"tool_ops\"", text, flags=re.I))

‎apps/api/app/services/agent_memory/short_term.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def assistant_facing_text(text: str, *, max_chars: int = 800) -> str:
8282

8383
def normalize_turn_for_dialogue(turn: dict[str, Any], *, per_turn_chars: int) -> dict[str, Any] | None:
8484
role = str(turn.get("role") or "").strip().lower()
85-
raw = str(turn.get("text") or turn.get("content") or "").strip()
85+
raw = str(turn.get("text") or "").strip()
8686
if not raw or role not in ("user", "assistant"):
8787
return None
8888
text = assistant_facing_text(raw, max_chars=per_turn_chars) if role == "assistant" else raw[:per_turn_chars]
@@ -278,7 +278,7 @@ def trim_turns_by_chars(
278278
lc_msgs: list[BaseMessage] = []
279279
for t in turns:
280280
role = str(t.get("role") or "")
281-
text = str(t.get("text") or t.get("content") or "")
281+
text = str(t.get("text") or "")
282282
if role == "user":
283283
lc_msgs.append(HumanMessage(content=text))
284284
elif role == "assistant":
@@ -378,7 +378,7 @@ def update_dialogue_after_run(
378378
names: list[str] = []
379379
for op in tool_ops_applied[:6]:
380380
if isinstance(op, dict):
381-
n = str(op.get("name") or op.get("op") or "").strip()
381+
n = str(op.get("name") or "").strip()
382382
if n:
383383
names.append(n)
384384
elif isinstance(op, str) and op.strip():

0 commit comments

Comments
 (0)