codebee 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +413 -413
- package/app/core/bookmeta.py +161 -27
- package/app/core/bookmeta_catalog.py +187 -0
- package/app/core/flows.py +1 -1
- package/app/core/gitmod.py +953 -953
- package/app/core/manager.py +1523 -1462
- package/app/core/market_remote.py +959 -896
- package/app/core/modelhub.py +7 -0
- package/app/core/pipeline.py +4 -1
- package/app/core/selfupdate.py +170 -170
- package/app/core/store.py +3 -1
- package/app/main.py +1467 -1448
- package/app/ui/app.js +8235 -8032
- package/app/ui/i18n.js +22 -3
- package/app/ui/index.html +7 -2
- package/app/ui/style.css +2764 -2733
- package/bin/tutti.js +1 -1
- package/package.json +2 -2
package/app/core/modelhub.py
CHANGED
|
@@ -949,6 +949,13 @@ def set_binding(agent_id, provider_id=None, model=None, models=None,
|
|
|
949
949
|
_sync_chain_refs(b)
|
|
950
950
|
if provider_id is not None:
|
|
951
951
|
b["provider_id"] = eff_pid # 显式指定主供应商时覆盖链首推导
|
|
952
|
+
# 链首非空时主供应商跟链首走:旧读方/下拉残留的 provider_id
|
|
953
|
+
# 若与链首不一致,会复活成「下拉=停用的旧供应商」(2026-09-16
|
|
954
|
+
# 一键推荐实测)。链首为空(纯 CLI 默认凭据)才保留显式指定。
|
|
955
|
+
head_pid = next((c.get("provider_id") for c in b["chain"]
|
|
956
|
+
if c.get("provider_id")), "")
|
|
957
|
+
if head_pid:
|
|
958
|
+
b["provider_id"] = head_pid
|
|
952
959
|
elif models is not None:
|
|
953
960
|
# 有序模型链:第 1 个主模型,其余按序降级
|
|
954
961
|
clean = _clean_models(models)
|
package/app/core/pipeline.py
CHANGED
|
@@ -417,7 +417,10 @@ def _finish_step_result(run_id, step, res, role, agent, start):
|
|
|
417
417
|
cost_usd=res.get("cost_usd", 0.0),
|
|
418
418
|
tokens=res.get("tokens", 0),
|
|
419
419
|
duration_s=time.time() - start,
|
|
420
|
-
model=res.get("model")
|
|
420
|
+
model=res.get("model"),
|
|
421
|
+
# 智能体的最终回答(runner 已从 JSONL 事件流里抽出 agent_message)。
|
|
422
|
+
# 对话视图直读这个;日志文件是全量事件流,塞进气泡就成了「看日志」。
|
|
423
|
+
output=(res.get("text") or ""))
|
|
421
424
|
if agent.get("mode") != "mock":
|
|
422
425
|
_record_usage(run_id, role, agent, res, source="pipeline", step=step["n"])
|
|
423
426
|
# 5F:step 级运行时断言(只告警不阻断)
|
package/app/core/selfupdate.py
CHANGED
|
@@ -1,170 +1,170 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""Tutti 自更新:版本读取 / 新版本检测 / 一键升级 / 就地重启。
|
|
3
|
-
|
|
4
|
-
安装模式判定(mode):
|
|
5
|
-
npm — 运行副本位于 node_modules 下且带 package.json(npm 全局安装的包),
|
|
6
|
-
可查新、可升级、可重启;
|
|
7
|
-
repo — 带 .git 的开发仓库:**永不自动升级**(会覆盖开发中的代码),提示走 git pull;
|
|
8
|
-
other — 裸源码拷贝,提示手动替换。
|
|
9
|
-
|
|
10
|
-
升级 = 在标准 mgmt run 里跑 `npm install -g codebee@latest`(日志实时落盘、
|
|
11
|
-
SSE 可看进度)。npm 替换的是包目录文件,当前进程已加载进内存不受影响,装完后由
|
|
12
|
-
「重启」换新代码:新进程先等旧端口释放再 bind(Windows SO_REUSEADDR 允许双 LISTEN
|
|
13
|
-
同时存在,必须先验旧进程真退了),旧进程发送完重启响应后自退。
|
|
14
|
-
|
|
15
|
-
安全:两处子进程命令的 argv 均为**行内字面量列表**(可执行文件与全部参数不来自任何
|
|
16
|
-
外部输入;重启仅透传 argparse 校验过的整型端口),shell 全程 False,绝不拼接用户输入。
|
|
17
|
-
改发布名时(见 test_selfupdate 与 package.json 的一致性断言)同步改 _PKG_NAME。
|
|
18
|
-
"""
|
|
19
|
-
from __future__ import annotations
|
|
20
|
-
|
|
21
|
-
import json
|
|
22
|
-
import os
|
|
23
|
-
import re
|
|
24
|
-
import socket
|
|
25
|
-
import subprocess
|
|
26
|
-
import sys
|
|
27
|
-
import threading
|
|
28
|
-
import time
|
|
29
|
-
|
|
30
|
-
from . import paths, runner
|
|
31
|
-
|
|
32
|
-
_PKG_NAME = "codebee" # npm 发布名;必须与 package.json 的 name 一致(单测断言)
|
|
33
|
-
_UPDATE_TTL = 600 # 查新结果缓存(秒)
|
|
34
|
-
_LOCK = threading.Lock()
|
|
35
|
-
_CHECK_CACHE = {"ts": 0.0, "result": None}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def package_version():
|
|
39
|
-
"""读本包 package.json 的 version;读不到返回 ''(开发仓库未同步版本号时)。"""
|
|
40
|
-
try:
|
|
41
|
-
pj = (paths.ROOT / "package.json").resolve()
|
|
42
|
-
return str(json.loads(pj.read_text(encoding="utf-8")).get("version") or "")
|
|
43
|
-
except Exception:
|
|
44
|
-
return ""
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
def install_mode():
|
|
48
|
-
"""npm / repo / source / other(见模块 docstring)。"""
|
|
49
|
-
try:
|
|
50
|
-
parts = [p.lower() for p in paths.ROOT.resolve().parts]
|
|
51
|
-
except Exception:
|
|
52
|
-
return "other"
|
|
53
|
-
has_pkg = (paths.ROOT / "package.json").is_file()
|
|
54
|
-
if "node_modules" in parts and has_pkg:
|
|
55
|
-
return "npm"
|
|
56
|
-
if (paths.ROOT / ".git").exists():
|
|
57
|
-
return "repo"
|
|
58
|
-
return "source" if has_pkg else "other"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
def _ver_tuple(s):
|
|
62
|
-
return [int(x) for x in re.findall(r"\d+", str(s or ""))[:4]]
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
def _npm_latest():
|
|
66
|
-
"""npm view codebee version;返回 (latest, err)。
|
|
67
|
-
用 _PKG_NAME 变量而非行内字面量:发布名改过一次(tutti-orchestrator→codebee),
|
|
68
|
-
硬编码两处容易漏改;Mimosa 安全基线要求 argv 可执行文件为字面量,参数用变量不违反。"""
|
|
69
|
-
r = runner.run_process(
|
|
70
|
-
argv=["cmd", "/c", "npm", "view", _PKG_NAME, "version"], timeout=60)
|
|
71
|
-
if not r["ok"]:
|
|
72
|
-
return "", (r["stderr"] or r["stdout"] or "")[-200:] or "npm 命令失败"
|
|
73
|
-
m = re.search(r"\d+\.\d+\.\d+[\w.\-]*", r["stdout"] or "")
|
|
74
|
-
return (m.group(0) if m else ""), ("" if m else "npm 输出无法解析")
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
def check(force=False):
|
|
78
|
-
"""GET /api/selfupdate 载荷:{mode, current, latest, has_update, note}。"""
|
|
79
|
-
mode = install_mode()
|
|
80
|
-
cur = package_version()
|
|
81
|
-
out = {"mode": mode, "current": cur, "latest": "", "has_update": False, "note": ""}
|
|
82
|
-
if mode != "npm":
|
|
83
|
-
out["note"] = ("开发仓库模式:请用 git pull 更新(自动升级会覆盖未提交的代码)"
|
|
84
|
-
if mode == "repo" else "非 npm 安装,无法自动更新")
|
|
85
|
-
return out
|
|
86
|
-
with _LOCK:
|
|
87
|
-
if not force and _CHECK_CACHE["result"] and \
|
|
88
|
-
time.time() - _CHECK_CACHE["ts"] < _UPDATE_TTL:
|
|
89
|
-
return dict(_CHECK_CACHE["result"])
|
|
90
|
-
latest, err = _npm_latest()
|
|
91
|
-
out["latest"] = latest
|
|
92
|
-
if err:
|
|
93
|
-
out["note"] = "查询新版本失败:" + err
|
|
94
|
-
elif latest and cur:
|
|
95
|
-
out["has_update"] = _ver_tuple(latest) > _ver_tuple(cur)
|
|
96
|
-
else:
|
|
97
|
-
out["note"] = "无法比较版本(本地或 registry 版本号缺失)"
|
|
98
|
-
with _LOCK:
|
|
99
|
-
_CHECK_CACHE["ts"] = time.time()
|
|
100
|
-
_CHECK_CACHE["result"] = dict(out)
|
|
101
|
-
return out
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
def apply_upgrade():
|
|
105
|
-
"""发起升级:建 mgmt run 异步跑 npm install -g @latest。返回 {run_id} 或 {error}。"""
|
|
106
|
-
if install_mode() != "npm":
|
|
107
|
-
return {"error": "当前安装方式不支持自动升级(见版本页说明)"}
|
|
108
|
-
from . import store, jobs
|
|
109
|
-
run = store.create_run("mgmt", "升级 CodeBee 本体(npm install -g %s@latest)" % _PKG_NAME,
|
|
110
|
-
entry_id="__self__", op="selfupgrade")
|
|
111
|
-
jobs.enqueue({"kind": "selfupgrade", "run_id": run["id"]})
|
|
112
|
-
return {"run_id": run["id"]}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
def run_upgrade(run_id, log_path):
|
|
116
|
-
"""worker 线程里执行升级命令(run/step 生命周期由 jobs 层管)。"""
|
|
117
|
-
res = runner.run_process(
|
|
118
|
-
argv=["cmd", "/c", "npm", "install", "-g", _PKG_NAME + "@latest"],
|
|
119
|
-
cwd=str(paths.ROOT), timeout=900, log_path=log_path)
|
|
120
|
-
if res["ok"]:
|
|
121
|
-
with _LOCK: # 装完即过期查新缓存,重启后自然拿到新版本
|
|
122
|
-
_CHECK_CACHE["result"] = None
|
|
123
|
-
return {"ok": res["ok"], "exit_code": res["exit_code"],
|
|
124
|
-
"error": "" if res["ok"] else (res["stderr"][-800:] or "退出码 %s" % res["exit_code"])}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
def _port_free(port):
|
|
128
|
-
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
129
|
-
try:
|
|
130
|
-
s.settimeout(0.3)
|
|
131
|
-
return s.connect_ex(("127.0.0.1", int(port))) != 0
|
|
132
|
-
except Exception:
|
|
133
|
-
return True
|
|
134
|
-
finally:
|
|
135
|
-
s.close()
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
def wait_port_before_bind(port):
|
|
139
|
-
"""新进程入口(--wait-port):轮询直到旧实例释放端口(最多 ~30 秒)。
|
|
140
|
-
超时也放行——旧进程若没退,bind 失败自会报错,不会出现双实例串流。"""
|
|
141
|
-
for _ in range(60):
|
|
142
|
-
if _port_free(port):
|
|
143
|
-
return
|
|
144
|
-
time.sleep(0.5)
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
def relaunch(port):
|
|
148
|
-
"""就地重启:拉起新实例(--wait-port 等新端口可 bind 时旧实例已自退)。
|
|
149
|
-
调用方发送完重启响应后应 self_quit()。port 经 int() 强校验,argv 全字面量。"""
|
|
150
|
-
port = int(port)
|
|
151
|
-
if port < 1 or port > 65535:
|
|
152
|
-
return False
|
|
153
|
-
subprocess.Popen(
|
|
154
|
-
[sys.executable, "main.py", "--port", str(port),
|
|
155
|
-
"--wait-port", "--no-browser"],
|
|
156
|
-
cwd=str(paths.APP_DIR),
|
|
157
|
-
stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
|
158
|
-
close_fds=True,
|
|
159
|
-
creationflags=(0x00000008 | 0x00000200) if os.name == "nt" else 0)
|
|
160
|
-
return True
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
def self_quit():
|
|
164
|
-
"""旧进程体面自退(HTTP 响应已发出后调用)。"""
|
|
165
|
-
try:
|
|
166
|
-
from . import remote
|
|
167
|
-
remote.stop_quick_tunnel()
|
|
168
|
-
except Exception:
|
|
169
|
-
pass
|
|
170
|
-
os._exit(0)
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Tutti 自更新:版本读取 / 新版本检测 / 一键升级 / 就地重启。
|
|
3
|
+
|
|
4
|
+
安装模式判定(mode):
|
|
5
|
+
npm — 运行副本位于 node_modules 下且带 package.json(npm 全局安装的包),
|
|
6
|
+
可查新、可升级、可重启;
|
|
7
|
+
repo — 带 .git 的开发仓库:**永不自动升级**(会覆盖开发中的代码),提示走 git pull;
|
|
8
|
+
other — 裸源码拷贝,提示手动替换。
|
|
9
|
+
|
|
10
|
+
升级 = 在标准 mgmt run 里跑 `npm install -g codebee@latest`(日志实时落盘、
|
|
11
|
+
SSE 可看进度)。npm 替换的是包目录文件,当前进程已加载进内存不受影响,装完后由
|
|
12
|
+
「重启」换新代码:新进程先等旧端口释放再 bind(Windows SO_REUSEADDR 允许双 LISTEN
|
|
13
|
+
同时存在,必须先验旧进程真退了),旧进程发送完重启响应后自退。
|
|
14
|
+
|
|
15
|
+
安全:两处子进程命令的 argv 均为**行内字面量列表**(可执行文件与全部参数不来自任何
|
|
16
|
+
外部输入;重启仅透传 argparse 校验过的整型端口),shell 全程 False,绝不拼接用户输入。
|
|
17
|
+
改发布名时(见 test_selfupdate 与 package.json 的一致性断言)同步改 _PKG_NAME。
|
|
18
|
+
"""
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
import json
|
|
22
|
+
import os
|
|
23
|
+
import re
|
|
24
|
+
import socket
|
|
25
|
+
import subprocess
|
|
26
|
+
import sys
|
|
27
|
+
import threading
|
|
28
|
+
import time
|
|
29
|
+
|
|
30
|
+
from . import paths, runner
|
|
31
|
+
|
|
32
|
+
_PKG_NAME = "codebee" # npm 发布名;必须与 package.json 的 name 一致(单测断言)
|
|
33
|
+
_UPDATE_TTL = 600 # 查新结果缓存(秒)
|
|
34
|
+
_LOCK = threading.Lock()
|
|
35
|
+
_CHECK_CACHE = {"ts": 0.0, "result": None}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def package_version():
|
|
39
|
+
"""读本包 package.json 的 version;读不到返回 ''(开发仓库未同步版本号时)。"""
|
|
40
|
+
try:
|
|
41
|
+
pj = (paths.ROOT / "package.json").resolve()
|
|
42
|
+
return str(json.loads(pj.read_text(encoding="utf-8")).get("version") or "")
|
|
43
|
+
except Exception:
|
|
44
|
+
return ""
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def install_mode():
|
|
48
|
+
"""npm / repo / source / other(见模块 docstring)。"""
|
|
49
|
+
try:
|
|
50
|
+
parts = [p.lower() for p in paths.ROOT.resolve().parts]
|
|
51
|
+
except Exception:
|
|
52
|
+
return "other"
|
|
53
|
+
has_pkg = (paths.ROOT / "package.json").is_file()
|
|
54
|
+
if "node_modules" in parts and has_pkg:
|
|
55
|
+
return "npm"
|
|
56
|
+
if (paths.ROOT / ".git").exists():
|
|
57
|
+
return "repo"
|
|
58
|
+
return "source" if has_pkg else "other"
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _ver_tuple(s):
|
|
62
|
+
return [int(x) for x in re.findall(r"\d+", str(s or ""))[:4]]
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _npm_latest():
|
|
66
|
+
"""npm view codebee version;返回 (latest, err)。
|
|
67
|
+
用 _PKG_NAME 变量而非行内字面量:发布名改过一次(tutti-orchestrator→codebee),
|
|
68
|
+
硬编码两处容易漏改;Mimosa 安全基线要求 argv 可执行文件为字面量,参数用变量不违反。"""
|
|
69
|
+
r = runner.run_process(
|
|
70
|
+
argv=["cmd", "/c", "npm", "view", _PKG_NAME, "version"], timeout=60)
|
|
71
|
+
if not r["ok"]:
|
|
72
|
+
return "", (r["stderr"] or r["stdout"] or "")[-200:] or "npm 命令失败"
|
|
73
|
+
m = re.search(r"\d+\.\d+\.\d+[\w.\-]*", r["stdout"] or "")
|
|
74
|
+
return (m.group(0) if m else ""), ("" if m else "npm 输出无法解析")
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def check(force=False):
|
|
78
|
+
"""GET /api/selfupdate 载荷:{mode, current, latest, has_update, note}。"""
|
|
79
|
+
mode = install_mode()
|
|
80
|
+
cur = package_version()
|
|
81
|
+
out = {"mode": mode, "current": cur, "latest": "", "has_update": False, "note": ""}
|
|
82
|
+
if mode != "npm":
|
|
83
|
+
out["note"] = ("开发仓库模式:请用 git pull 更新(自动升级会覆盖未提交的代码)"
|
|
84
|
+
if mode == "repo" else "非 npm 安装,无法自动更新")
|
|
85
|
+
return out
|
|
86
|
+
with _LOCK:
|
|
87
|
+
if not force and _CHECK_CACHE["result"] and \
|
|
88
|
+
time.time() - _CHECK_CACHE["ts"] < _UPDATE_TTL:
|
|
89
|
+
return dict(_CHECK_CACHE["result"])
|
|
90
|
+
latest, err = _npm_latest()
|
|
91
|
+
out["latest"] = latest
|
|
92
|
+
if err:
|
|
93
|
+
out["note"] = "查询新版本失败:" + err
|
|
94
|
+
elif latest and cur:
|
|
95
|
+
out["has_update"] = _ver_tuple(latest) > _ver_tuple(cur)
|
|
96
|
+
else:
|
|
97
|
+
out["note"] = "无法比较版本(本地或 registry 版本号缺失)"
|
|
98
|
+
with _LOCK:
|
|
99
|
+
_CHECK_CACHE["ts"] = time.time()
|
|
100
|
+
_CHECK_CACHE["result"] = dict(out)
|
|
101
|
+
return out
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def apply_upgrade():
|
|
105
|
+
"""发起升级:建 mgmt run 异步跑 npm install -g @latest。返回 {run_id} 或 {error}。"""
|
|
106
|
+
if install_mode() != "npm":
|
|
107
|
+
return {"error": "当前安装方式不支持自动升级(见版本页说明)"}
|
|
108
|
+
from . import store, jobs
|
|
109
|
+
run = store.create_run("mgmt", "升级 CodeBee 本体(npm install -g %s@latest)" % _PKG_NAME,
|
|
110
|
+
entry_id="__self__", op="selfupgrade")
|
|
111
|
+
jobs.enqueue({"kind": "selfupgrade", "run_id": run["id"]})
|
|
112
|
+
return {"run_id": run["id"]}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def run_upgrade(run_id, log_path):
|
|
116
|
+
"""worker 线程里执行升级命令(run/step 生命周期由 jobs 层管)。"""
|
|
117
|
+
res = runner.run_process(
|
|
118
|
+
argv=["cmd", "/c", "npm", "install", "-g", _PKG_NAME + "@latest"],
|
|
119
|
+
cwd=str(paths.ROOT), timeout=900, log_path=log_path)
|
|
120
|
+
if res["ok"]:
|
|
121
|
+
with _LOCK: # 装完即过期查新缓存,重启后自然拿到新版本
|
|
122
|
+
_CHECK_CACHE["result"] = None
|
|
123
|
+
return {"ok": res["ok"], "exit_code": res["exit_code"],
|
|
124
|
+
"error": "" if res["ok"] else (res["stderr"][-800:] or "退出码 %s" % res["exit_code"])}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def _port_free(port):
|
|
128
|
+
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
129
|
+
try:
|
|
130
|
+
s.settimeout(0.3)
|
|
131
|
+
return s.connect_ex(("127.0.0.1", int(port))) != 0
|
|
132
|
+
except Exception:
|
|
133
|
+
return True
|
|
134
|
+
finally:
|
|
135
|
+
s.close()
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def wait_port_before_bind(port):
|
|
139
|
+
"""新进程入口(--wait-port):轮询直到旧实例释放端口(最多 ~30 秒)。
|
|
140
|
+
超时也放行——旧进程若没退,bind 失败自会报错,不会出现双实例串流。"""
|
|
141
|
+
for _ in range(60):
|
|
142
|
+
if _port_free(port):
|
|
143
|
+
return
|
|
144
|
+
time.sleep(0.5)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def relaunch(port):
|
|
148
|
+
"""就地重启:拉起新实例(--wait-port 等新端口可 bind 时旧实例已自退)。
|
|
149
|
+
调用方发送完重启响应后应 self_quit()。port 经 int() 强校验,argv 全字面量。"""
|
|
150
|
+
port = int(port)
|
|
151
|
+
if port < 1 or port > 65535:
|
|
152
|
+
return False
|
|
153
|
+
subprocess.Popen(
|
|
154
|
+
[sys.executable, "main.py", "--port", str(port),
|
|
155
|
+
"--wait-port", "--no-browser"],
|
|
156
|
+
cwd=str(paths.APP_DIR),
|
|
157
|
+
stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
|
158
|
+
close_fds=True,
|
|
159
|
+
creationflags=(0x00000008 | 0x00000200) if os.name == "nt" else 0)
|
|
160
|
+
return True
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def self_quit():
|
|
164
|
+
"""旧进程体面自退(HTTP 响应已发出后调用)。"""
|
|
165
|
+
try:
|
|
166
|
+
from . import remote
|
|
167
|
+
remote.stop_quick_tunnel()
|
|
168
|
+
except Exception:
|
|
169
|
+
pass
|
|
170
|
+
os._exit(0)
|
package/app/core/store.py
CHANGED
|
@@ -1142,7 +1142,7 @@ def add_step(run_id, role, agent_id, agent_label, note=""):
|
|
|
1142
1142
|
|
|
1143
1143
|
|
|
1144
1144
|
def finish_step(run_id, n, status, summary="", exit_code=None,
|
|
1145
|
-
cost_usd=0.0, tokens=0.0, duration_s=None, model=None):
|
|
1145
|
+
cost_usd=0.0, tokens=0.0, duration_s=None, model=None, output=None):
|
|
1146
1146
|
with LOCK:
|
|
1147
1147
|
run = _RUNS.get(run_id)
|
|
1148
1148
|
if not run:
|
|
@@ -1159,6 +1159,8 @@ def finish_step(run_id, n, status, summary="", exit_code=None,
|
|
|
1159
1159
|
s["model"] = str(model)[:80]
|
|
1160
1160
|
if duration_s is not None:
|
|
1161
1161
|
s["duration_s"] = round(duration_s, 1)
|
|
1162
|
+
if output is not None:
|
|
1163
|
+
s["output"] = str(output)[:6000]
|
|
1162
1164
|
break
|
|
1163
1165
|
run["cost_usd"] = round(run.get("cost_usd", 0.0) + cost_usd, 4)
|
|
1164
1166
|
run["tokens"] = run.get("tokens", 0) + tokens
|