codebee 0.1.0
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/LICENSE +21 -0
- package/README.md +392 -0
- package/app/__init__.py +0 -0
- package/app/core/__init__.py +0 -0
- package/app/core/attachments.py +322 -0
- package/app/core/automation.py +585 -0
- package/app/core/bookmeta.py +296 -0
- package/app/core/capability.py +130 -0
- package/app/core/catalog.py +319 -0
- package/app/core/compaction.py +186 -0
- package/app/core/diagnostics.py +115 -0
- package/app/core/env_scrub.py +84 -0
- package/app/core/error_codes.py +65 -0
- package/app/core/flows.py +328 -0
- package/app/core/gitmod.py +949 -0
- package/app/core/goal_service.py +159 -0
- package/app/core/health.py +294 -0
- package/app/core/history.py +32 -0
- package/app/core/jobs.py +424 -0
- package/app/core/manager.py +1415 -0
- package/app/core/market.py +299 -0
- package/app/core/market_remote.py +896 -0
- package/app/core/mocks.py +64 -0
- package/app/core/modelhub.py +2750 -0
- package/app/core/paths.py +60 -0
- package/app/core/pipeline.py +2161 -0
- package/app/core/planner.py +493 -0
- package/app/core/registry.py +105 -0
- package/app/core/remote.py +303 -0
- package/app/core/repeat_guard.py +124 -0
- package/app/core/router.py +120 -0
- package/app/core/runner.py +856 -0
- package/app/core/selfupdate.py +170 -0
- package/app/core/session_log.py +162 -0
- package/app/core/sessions.py +312 -0
- package/app/core/settings.py +85 -0
- package/app/core/settings_schema.py +250 -0
- package/app/core/skillpacks/fanqie-novel.md +80 -0
- package/app/core/skillpacks/market/character-bible.md +66 -0
- package/app/core/skillpacks/market/code-risk-checklist.md +58 -0
- package/app/core/skillpacks/market/git-workflow.md +57 -0
- package/app/core/skillpacks/market/release-notes.md +72 -0
- package/app/core/skillpacks/market/weekly-report.md +71 -0
- package/app/core/skillpacks/market/worldview-consistency.md +70 -0
- package/app/core/skillpacks/qimao-signing.md +105 -0
- package/app/core/skills.py +649 -0
- package/app/core/step_runner.py +61 -0
- package/app/core/store.py +1321 -0
- package/app/core/token_meter.py +130 -0
- package/app/core/usage.py +450 -0
- package/app/main.py +1448 -0
- package/app/ui/app.js +8021 -0
- package/app/ui/i18n.js +1709 -0
- package/app/ui/icons/brand-horizontal.png +0 -0
- package/app/ui/icons/brand-square.png +0 -0
- package/app/ui/icons/icon-192.png +0 -0
- package/app/ui/icons/icon-512.png +0 -0
- package/app/ui/icons/logo-horizontal.png +0 -0
- package/app/ui/icons/logo-mark.png +0 -0
- package/app/ui/index.html +864 -0
- package/app/ui/manifest.json +16 -0
- package/app/ui/qrcode.js +2297 -0
- package/app/ui/style.css +2733 -0
- package/bin/tutti.js +121 -0
- package/package.json +39 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Step 执行器:压缩触发的重试守门(复用已渲染 prompt,不重复组装)。
|
|
3
|
+
|
|
4
|
+
设计稿:docs/migration/02-context-compaction.md §1D。
|
|
5
|
+
参考 dsh packages/core/agent-loop/src/agent.ts:307-378:
|
|
6
|
+
失败重试只在「前进 surface generation」时返回 {kind:'retry'},
|
|
7
|
+
复用已渲染 PromptAssembly,不重跑 pre-step / 组装 / 用户消息准入。
|
|
8
|
+
|
|
9
|
+
Tutti 语境:runner.run_agent 自带 prompt(已渲染);重试的风险不是重复渲染
|
|
10
|
+
(prompt 是同一个字符串),而是「不压缩直接重试」必然再次撑爆。
|
|
11
|
+
本模块的守门:仅当 maybe_compact 真正前进了 surface generation 才重试一次。
|
|
12
|
+
"""
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import logging
|
|
16
|
+
|
|
17
|
+
from .compaction import maybe_compact
|
|
18
|
+
from .error_codes import ErrorCode
|
|
19
|
+
|
|
20
|
+
log = logging.getLogger(__name__)
|
|
21
|
+
|
|
22
|
+
# 触发「压缩后重试」的错误码
|
|
23
|
+
_OVERFLOW_CODES = {ErrorCode.CONTEXT_OVERFLOW, ErrorCode.MAX_TOKENS}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def execute_step(session, run_agent_fn, prompt, *, model: str = "",
|
|
27
|
+
llm_caller=None, retain_tail_tokens=None, **kwargs):
|
|
28
|
+
"""执行一次 step;撑爆时压缩并守门重试一次。
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
session: session_log.Session(记录 replace_generation)
|
|
32
|
+
run_agent_fn: runner.run_agent(或测试替身),签名 (prompt, **kwargs) -> dict
|
|
33
|
+
prompt: 已渲染的提示词(重试时原样复用,不重新渲染)
|
|
34
|
+
model: token_meter 压力估算用模型名
|
|
35
|
+
llm_caller: 压缩摘要 LLM(None = 不压缩,永不重试)
|
|
36
|
+
**kwargs: 透传 run_agent_fn
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
(result, retried: bool)
|
|
40
|
+
"""
|
|
41
|
+
gen0 = session.replace_generation()
|
|
42
|
+
result = run_agent_fn(prompt, **kwargs)
|
|
43
|
+
code = result.get("error_code") or ""
|
|
44
|
+
if code not in _OVERFLOW_CODES or llm_caller is None:
|
|
45
|
+
return result, False
|
|
46
|
+
# 撑爆 → 尝试压缩
|
|
47
|
+
compact_kwargs = {}
|
|
48
|
+
if retain_tail_tokens is not None:
|
|
49
|
+
compact_kwargs["retain_tail_tokens"] = retain_tail_tokens
|
|
50
|
+
compacted = maybe_compact(session, model=model, llm_caller=llm_caller,
|
|
51
|
+
run_id=session.run_id, **compact_kwargs)
|
|
52
|
+
gen1 = session.replace_generation()
|
|
53
|
+
if not compacted or gen1 <= gen0:
|
|
54
|
+
# 压缩未发生或未前进 generation:重试必然再次撑爆,不重试
|
|
55
|
+
log.info("overflow but no compaction progress (gen %s->%s), no retry",
|
|
56
|
+
gen0, gen1)
|
|
57
|
+
return result, False
|
|
58
|
+
# 压缩生效:surface 已折叠,重新派生消息后用同一 prompt 重试一次
|
|
59
|
+
log.info("compaction advanced gen %s->%s, retrying step", gen0, gen1)
|
|
60
|
+
result2 = run_agent_fn(prompt, **kwargs)
|
|
61
|
+
return result2, True
|