@tea-agent/loop-agent 0.53.0-next.1 → 0.53.0-next.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/CHANGELOG.md +18 -52
- package/dist/build-stamp.json +3 -3
- package/dist/shared/pi-context-pressure/compaction-policy.js +22 -34
- package/dist/shared/pi-context-pressure/index.js +1 -1
- package/dist/worker/console/automation-actions.js +62 -7
- package/dist/worker/console/chat/api-workbench-core.js +131 -4
- package/dist/worker/console/chat/api-workbench-schema.js +278 -0
- package/dist/worker/console/chat/api-workbench-spring.js +333 -0
- package/dist/worker/console/chat/api-workbench.js +88 -2
- package/dist/worker/console/chat/human-gate-card.js +16 -1
- package/dist/worker/console/chat/image-cache.js +39 -8
- package/dist/worker/console/chat/pi-runtime/custom-tools/apiworkbench-tools.js +120 -5
- package/dist/worker/console/chat/pi-runtime.js +2 -3
- package/dist/worker/console/chat/provider-error.js +12 -2
- package/dist/worker/console/chat/repo-walk.js +8 -0
- package/dist/worker/console/chat/routes.js +125 -13
- package/dist/worker/console/chat/todo-diff.js +90 -0
- package/dist/worker/console/chat/turn-process.js +3 -0
- package/dist/worker/console/network-proxy-settings.js +67 -1
- package/dist/worker/console/operator-actions.js +25 -0
- package/dist/worker/console/pi-compaction-settings.js +16 -13
- package/dist/worker/console/server.js +20 -0
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-CR1jj_rz.js → abnfDiagram-N423BO3Z-9YdcTSkA.js} +1 -1
- package/dist/worker/console/static/assets/{arc-CjxcQfEu.js → arc-5o9a24RM.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-D-3u2qFL.js → architectureDiagram-T3A2C74G-kk-Y4K8w.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-Bdr7gWVo.js → blockDiagram-VBNYF7ZC-BuMyp-i-.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-hQHNe5T3.js → c4Diagram-5PPSVZJV-BnAbUXQM.js} +1 -1
- package/dist/worker/console/static/assets/channel-DzpJs7JM.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-BEg_su6q.js → chunk-2GRJ4B5K-sQ2VjuFx.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-DZnV6VTC.js → chunk-2Q5K7J3B-CbkqzTV8.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-Dg0LzAqO.js → chunk-5RXB4S5H-CaP8JTC3.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-D2vqr52W.js → chunk-5VM5RSS4-D7yUFtwu.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-D8We_g6R.js → chunk-6Q2QTUOP-zowLlgmO.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-DbEU8drD.js → chunk-GF5L2VYU-KGzLFdSC.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-Boi8TJYN.js → chunk-JWPE2WC7-DuVIxg_I.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-CjJmKa9f.js → chunk-KBJHAD2P-CXP8iZrQ.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-C-KV-ag7.js → chunk-RYQCIY6F-DASfOCYV.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-DZlTonsZ.js → chunk-XXDRQBXY-DFwLDf-r.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-ClK7LSSv.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-ClK7LSSv.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-BIvFe3yn.js → cose-bilkent-JH36ORCC-CIrJSuNM.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-BOBPfv8u.js → cynefinDiagram-MW4NZA55-BrI5M-XP.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-BF54orLO.js → dagre-VZM6K2ZE-BEJlUQi2.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-CxjAP2AP.js → diagram-7IWD3JNH-Buw7nAqS.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-BXYkuNGt.js → diagram-B4RE2ZJO-DHURLBbb.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-DQTu-2Iy.js → diagram-LBJQPF4R-CEFuptxk.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-DNURuIYc.js → diagram-Q27KOJAE-Cejgl71p.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-D69uANY8.js → diagram-UB23O5K3-Bwxq3Xoa.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-C658EcrV.js → ebnfDiagram-BXEA7PRR-i4NNenm0.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-BRccYtAl.js → erDiagram-JOGREHBK-BaSp03BR.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-DnIR4sLs.js → flowDiagram-UKHOOZJN-CQtgCCPg.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-Bo3eWFVC.js → ganttDiagram-PKOTCBZU-DkS9Vbt8.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-EyWDCNU_.js → gitGraphDiagram-DS77QQ5N-Dm64UQgY.js} +1 -1
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-B0Eld9u0.js → infoDiagram-6WML65LV-BpcLrRRV.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-DsJQiJ27.js → ishikawaDiagram-WSZJBQD7-DFjxaE3Q.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-fpE0yqjC.js → journeyDiagram-NVQOT4AX-G6kuLGYK.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-Dq9IrDdT.js → kanban-definition-27J2QSJJ-DistDdnp.js} +1 -1
- package/dist/worker/console/static/assets/{linear-CFV4BDyf.js → linear-Cadcj4Jf.js} +1 -1
- package/dist/worker/console/static/assets/main-CKu0wCrM.js +654 -0
- package/dist/worker/console/static/assets/main-DpBoCiky.css +1 -0
- package/dist/worker/console/static/assets/{mermaid.core-BMMXqtrB.js → mermaid.core-CVqQBsGx.js} +4 -4
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-DurrK_Gi.js → mindmap-definition-FAOFIHXS-oIAAXLn3.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-CzZayNy2.js → pegDiagram-VL7TDLO6-BgBPFLA0.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-B1W7Y0cE.js → pieDiagram-7S7Q4E2Y-RTyZdL9S.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-BdbL83CU.js → quadrantDiagram-CIZ2JOQS-BHEYQMZx.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-W-bQpd18.js → railroadDiagram-AXF67PYL-B2JIrks2.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-C9bi4tQJ.js → requirementDiagram-LRYGKXZP-TJ5_MWbY.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-D4kO56Wd.js → sankeyDiagram-W5VNT64P-BzjUsr0j.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-CIbesK1e.js → sequenceDiagram-SI44F4Z6-DrmrPPVE.js} +1 -1
- package/dist/worker/console/static/assets/{sheet-workbook-kFN3yUBr.js → sheet-workbook-DCQgjy0Q.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-Dk4XAK7C.js → sizeCapture-X5ZJPWSS-BLp8F5fC.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-Bz9B6UZ7.js → stateDiagram-OKZ733FA-5MNm447q.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-gP-t-MQJ.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-qLEds93n.js → swimlanes-SLNWSIFB-Cs2RUkNq.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-D6MJJUTV.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-C9rVFC0h.js → timeline-definition-Z64GVDOM-BoeTHoWc.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-CoKJ9hU0.js → vennDiagram-T6HMQDX7-DFWej-Mm.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-tHz_S7-L.js → wardleyDiagram-T6FBY63Y-BcD0_2m5.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-DKzKYnvG.js → xychartDiagram-ELKLHX3M-y4PQYZiq.js} +1 -1
- package/dist/worker/console/static/index.html +2 -2
- package/dist/worker/console/static-src/markdown-incremental.js +138 -0
- package/dist/worker/console/static-src/operator-chat/automation-catalog-model.js +43 -0
- package/dist/worker/console/static-src/operator-chat/composer-drop.js +138 -0
- package/dist/worker/console/static-src/operator-chat/composer-image-paths.js +25 -5
- package/dist/worker/console/static-src/operator-chat/composer-image-preview.js +115 -0
- package/dist/worker/console/static-src/operator-chat/composer-session-ledger.js +44 -2
- package/dist/worker/console/static-src/operator-chat/composer-upload.js +115 -0
- package/dist/worker/console/static-src/operator-chat/gate-expiry.js +43 -0
- package/dist/worker/console/static-src/operator-chat/process-label.js +15 -2
- package/dist/worker/console/static-src/operator-chat/schedule-relative-time.js +54 -0
- package/dist/worker/console/static-src/operator-chat/schedule-rule-summary.js +213 -0
- package/dist/worker/console/static-src/operator-chat/tasks-model.js +4 -0
- package/dist/worker/console/static-src/operator-chat/turn-group-equality.js +8 -0
- package/dist/worker/console/static-src/operator-chat/turn-process-disclosure.js +12 -0
- package/dist/worker/console/static-src/operator-chat/turn-state-projection.js +51 -0
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +22 -2
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +15 -1
- package/dist/worker/console/static-src/operator-chat/useComposer.js +290 -21
- package/dist/worker/console/static-src/operator-chat/useSessionAutomationCounts.js +98 -0
- package/dist/worker/console/static-src/pages/api-request-template.js +144 -0
- package/dist/worker/console/static-src/session-search-shortcut.js +38 -0
- package/dist/worker/console/version-notes-comparison.js +52 -0
- package/dist/worker/console/version-notes.js +16 -1
- package/dist/worker/console/workspace-context.js +10 -0
- package/dist/worker/observe/static/console-theme.css +50 -3
- package/dist/worker/observe/static/console-theme.js +86 -1
- package/dist/worker/scheduler/automation-across-workspaces.js +120 -0
- package/docs/README.md +1 -0
- package/docs/operations/README.md +1 -0
- package/package.json +3 -3
- package/dist/worker/console/static/assets/channel-CBlJfald.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-mNUYCdDo.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-mNUYCdDo.js +0 -1
- package/dist/worker/console/static/assets/main-D-ZQ4gLb.css +0 -1
- package/dist/worker/console/static/assets/main-Dwhb3ZRq.js +0 -645
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-BBRlxIq8.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-CRBvOMCQ.js +0 -8
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse the `todos` array out of a `todo_write` call's arguments.
|
|
3
|
+
*
|
|
4
|
+
* Arguments arrive either already parsed or as the raw JSON string the model
|
|
5
|
+
* emitted, so both are accepted. Returns null when the shape is not a todo list
|
|
6
|
+
* at all — the caller then renders no summary rather than a wrong one.
|
|
7
|
+
*
|
|
8
|
+
* @param value - the tool call's `args`, in either form.
|
|
9
|
+
* @returns the parsed items, or null when this is not a todo write.
|
|
10
|
+
*/
|
|
11
|
+
export function parseTodoArgs(value) {
|
|
12
|
+
let parsed = value;
|
|
13
|
+
if (typeof parsed === "string") {
|
|
14
|
+
try {
|
|
15
|
+
parsed = JSON.parse(parsed);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (!parsed || typeof parsed !== "object")
|
|
22
|
+
return null;
|
|
23
|
+
const todos = parsed.todos;
|
|
24
|
+
if (!Array.isArray(todos))
|
|
25
|
+
return null;
|
|
26
|
+
return todos.filter((item) => Boolean(item) &&
|
|
27
|
+
typeof item === "object" &&
|
|
28
|
+
typeof item.content === "string" &&
|
|
29
|
+
(item.status === "pending" ||
|
|
30
|
+
item.status === "in_progress" ||
|
|
31
|
+
item.status === "completed"));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Compare the current list with the one the previous call left behind.
|
|
35
|
+
*
|
|
36
|
+
* An empty or absent baseline is the FIRST write of a turn: every task counts
|
|
37
|
+
* as added, because from the reader's point of view the list appeared. This
|
|
38
|
+
* matches DSH, where the first write's baseline is the empty list
|
|
39
|
+
* (`todo-history.ts:39-56`).
|
|
40
|
+
*
|
|
41
|
+
* @param current - the list this call wrote.
|
|
42
|
+
* @param previous - the list the previous call in the same turn wrote, if any.
|
|
43
|
+
* @returns the counts plus the totals the caller renders alongside them.
|
|
44
|
+
*/
|
|
45
|
+
export function diffTodoLists(current, previous) {
|
|
46
|
+
const before = previous ?? [];
|
|
47
|
+
const beforeStatus = new Map(before.map((todo) => [todo.content, todo.status]));
|
|
48
|
+
const currentContents = new Set(current.map((todo) => todo.content));
|
|
49
|
+
let added = 0;
|
|
50
|
+
let updated = 0;
|
|
51
|
+
for (const todo of current) {
|
|
52
|
+
const prior = beforeStatus.get(todo.content);
|
|
53
|
+
if (prior === undefined)
|
|
54
|
+
added += 1;
|
|
55
|
+
else if (prior !== todo.status)
|
|
56
|
+
updated += 1;
|
|
57
|
+
}
|
|
58
|
+
let removed = 0;
|
|
59
|
+
for (const todo of before) {
|
|
60
|
+
if (!currentContents.has(todo.content))
|
|
61
|
+
removed += 1;
|
|
62
|
+
}
|
|
63
|
+
const done = current.filter((todo) => todo.status === "completed").length;
|
|
64
|
+
const active = current.find((todo) => todo.status === "in_progress");
|
|
65
|
+
return {
|
|
66
|
+
added,
|
|
67
|
+
updated,
|
|
68
|
+
removed,
|
|
69
|
+
total: current.length,
|
|
70
|
+
done,
|
|
71
|
+
...(active?.content ? { activeContent: active.content } : {}),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Render one delta as the short line the card shows after its summary.
|
|
76
|
+
*
|
|
77
|
+
* Order is added / removed / updated, and a part with a zero count is omitted
|
|
78
|
+
* entirely. A delta with nothing to report returns an empty string so the card
|
|
79
|
+
* does not grow a「+0 −0」that reads as a change.
|
|
80
|
+
*
|
|
81
|
+
* @param delta - counts from {@link diffTodoLists}.
|
|
82
|
+
* @returns e.g. `+2 −1 ~3`, or the empty string.
|
|
83
|
+
*/
|
|
84
|
+
export function formatTodoDelta(delta) {
|
|
85
|
+
return [
|
|
86
|
+
delta.added > 0 ? `+${delta.added}` : "",
|
|
87
|
+
delta.removed > 0 ? `−${delta.removed}` : "",
|
|
88
|
+
delta.updated > 0 ? `~${delta.updated}` : "",
|
|
89
|
+
].filter(Boolean).join(" ");
|
|
90
|
+
}
|
|
@@ -678,6 +678,9 @@ export function buildTurnProcessGroups(input) {
|
|
|
678
678
|
: undefined;
|
|
679
679
|
if (turnState !== undefined)
|
|
680
680
|
group.turnState = turnState;
|
|
681
|
+
const turnSource = group.turnId ? input.turnSourcesById?.[group.turnId] : undefined;
|
|
682
|
+
if (turnSource !== undefined)
|
|
683
|
+
group.turnSource = turnSource;
|
|
681
684
|
group.turnClosed =
|
|
682
685
|
turnState === "settled" ||
|
|
683
686
|
turnState === "aborted" ||
|
|
@@ -75,8 +75,19 @@ async function readStored(file) {
|
|
|
75
75
|
throw new NetworkProxyError("PROXY_SETTINGS_UNREADABLE", "无法读取网络代理设置,请检查程序数据目录中的 settings/network-proxy.json", 503);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Where a connectivity probe should go.
|
|
80
|
+
*
|
|
81
|
+
* A proxy can be perfectly valid and still be the wrong one, so the probe has to
|
|
82
|
+
* reach the same place real traffic reaches. The caller supplies the model
|
|
83
|
+
* endpoint when it knows one; otherwise the probe falls back to a small,
|
|
84
|
+
* unauthenticated public endpoint that any proxy should be able to relay.
|
|
85
|
+
*/
|
|
86
|
+
const FALLBACK_PROBE_TARGET = "https://api.deepseek.com/";
|
|
78
87
|
/** One persisted setting per Console data root; network ownership is process-wide. */
|
|
79
|
-
export async function createNetworkProxySettings(appDataRoot
|
|
88
|
+
export async function createNetworkProxySettings(appDataRoot,
|
|
89
|
+
/** Resolves the model endpoint to probe; absent means "use the fallback". */
|
|
90
|
+
probeTarget) {
|
|
80
91
|
const file = path.join(appDataRoot, "settings", "network-proxy.json");
|
|
81
92
|
let stored = await readStored(file);
|
|
82
93
|
const runtime = createNetworkProxyRuntime(stored.settings);
|
|
@@ -138,6 +149,61 @@ export async function createNetworkProxySettings(appDataRoot) {
|
|
|
138
149
|
await lock.release();
|
|
139
150
|
}
|
|
140
151
|
}),
|
|
152
|
+
/**
|
|
153
|
+
* Send one request through the path real traffic takes.
|
|
154
|
+
*
|
|
155
|
+
* It deliberately uses the global `fetch` — which the runtime replaced with
|
|
156
|
+
* its own dispatcher — rather than a fresh agent: probing a client nobody uses
|
|
157
|
+
* would answer a different question than the operator asked.
|
|
158
|
+
*
|
|
159
|
+
* Only `HEAD` is issued, any HTTP status counts as reachable (a 401 from the
|
|
160
|
+
* model endpoint still proves the connection works), and the body is never
|
|
161
|
+
* read, so the probe cannot leak or download anything.
|
|
162
|
+
*/
|
|
163
|
+
probe: () => serialize(async () => {
|
|
164
|
+
if (closed)
|
|
165
|
+
throw new NetworkProxyError("PROXY_CLOSED", "服务正在关闭", 503);
|
|
166
|
+
const target = (await probeTarget?.().catch(() => undefined)) ?? FALLBACK_PROBE_TARGET;
|
|
167
|
+
let origin;
|
|
168
|
+
try {
|
|
169
|
+
origin = new URL(target);
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
origin = new URL(FALLBACK_PROBE_TARGET);
|
|
173
|
+
}
|
|
174
|
+
const effective = runtime.getEffective();
|
|
175
|
+
const proxied = Boolean(effective.httpProxy || effective.httpsProxy);
|
|
176
|
+
const started = Date.now();
|
|
177
|
+
const controller = new AbortController();
|
|
178
|
+
const timer = setTimeout(() => controller.abort(), 10_000);
|
|
179
|
+
try {
|
|
180
|
+
await fetch(origin.href, {
|
|
181
|
+
method: "HEAD", redirect: "follow", signal: controller.signal,
|
|
182
|
+
// A proxy may refuse HEAD; a plain GET of a HEAD-rejecting host is still
|
|
183
|
+
// cheaper than reporting a false failure.
|
|
184
|
+
headers: { accept: "*/*" },
|
|
185
|
+
});
|
|
186
|
+
return {
|
|
187
|
+
ok: true, target: origin.origin, elapsedMs: Date.now() - started,
|
|
188
|
+
route: proxied ? "proxy" : "direct",
|
|
189
|
+
proxy: effective.httpsProxy ?? effective.httpProxy ?? null,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
catch (reason) {
|
|
193
|
+
const aborted = reason instanceof Error && reason.name === "AbortError";
|
|
194
|
+
return {
|
|
195
|
+
ok: false, target: origin.origin, elapsedMs: Date.now() - started,
|
|
196
|
+
route: proxied ? "proxy" : "direct",
|
|
197
|
+
proxy: effective.httpsProxy ?? effective.httpProxy ?? null,
|
|
198
|
+
message: aborted
|
|
199
|
+
? "连接超时(10 秒)。请检查代理地址是否可达,或改为「不用代理」。"
|
|
200
|
+
: "无法连接。请检查代理地址与服务是否正在运行,或改为「不用代理」。",
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
finally {
|
|
204
|
+
clearTimeout(timer);
|
|
205
|
+
}
|
|
206
|
+
}),
|
|
141
207
|
close: async () => { closed = true; await pending; await runtime.dispose(); },
|
|
142
208
|
};
|
|
143
209
|
}
|
|
@@ -2,6 +2,7 @@ import { prepareScheduledTask } from "./chat/scheduled-goal-request.js";
|
|
|
2
2
|
import { scheduledGoalHash } from "../scheduler/scheduled-goal-store.js";
|
|
3
3
|
import { AutomationStore } from "../scheduler/automation-store.js";
|
|
4
4
|
import { executeAutomationAction } from "./automation-actions.js";
|
|
5
|
+
import { findWorkspaceOwningTask, listAcrossWorkspaces } from "../scheduler/automation-across-workspaces.js";
|
|
5
6
|
import { SCHEDULE_TOOL_IDS } from "../../shared/automation/types.js";
|
|
6
7
|
import { ScheduleError } from "../../shared/automation/time.js";
|
|
7
8
|
import { prepareScheduledGoalBooking, confirmScheduledGoalBooking, getScheduledGoalBooking } from "./chat/scheduled-goal-booking.js";
|
|
@@ -965,6 +966,30 @@ export async function dispatchOperatorAction(ctx, req) {
|
|
|
965
966
|
store: ctx.automationStore ?? new AutomationStore(ctx.repoRoot), sessions: ctx.automationSessions ?? new ChatSessionStore(ctx.appData),
|
|
966
967
|
scope: human ? { kind: "workspace" } : { kind: "session", sessionId: ctx.chatSessionRef },
|
|
967
968
|
deleteConsent, onChanged: ctx.onAutomationChanged,
|
|
969
|
+
/*
|
|
970
|
+
* Only the human UI reads across workspaces. A model call stays scoped to
|
|
971
|
+
* the session it speaks for, so a tool result never depends on which
|
|
972
|
+
* repositories this machine happens to have registered.
|
|
973
|
+
*/
|
|
974
|
+
...(human && ctx.automationWorkspaces
|
|
975
|
+
? {
|
|
976
|
+
listAcrossWorkspaces: async () => {
|
|
977
|
+
const workspaces = await ctx.automationWorkspaces();
|
|
978
|
+
return listAcrossWorkspaces(workspaces);
|
|
979
|
+
},
|
|
980
|
+
/*
|
|
981
|
+
* Reads and writes that name a task id resolve the owning workspace
|
|
982
|
+
* first, so a task listed from elsewhere can also be opened, edited
|
|
983
|
+
* and deleted. Without this the row was clickable and then answered
|
|
984
|
+
* `schedule_not_found`.
|
|
985
|
+
*/
|
|
986
|
+
storeForTask: async (taskId) => {
|
|
987
|
+
const workspaces = await ctx.automationWorkspaces();
|
|
988
|
+
const owner = await findWorkspaceOwningTask(workspaces, taskId);
|
|
989
|
+
return owner ? new AutomationStore(owner.repoRoot) : undefined;
|
|
990
|
+
},
|
|
991
|
+
}
|
|
992
|
+
: {}),
|
|
968
993
|
});
|
|
969
994
|
return { kind: "sync", status: 200, body: operatorSucceeded(action, result) };
|
|
970
995
|
}
|
|
@@ -8,8 +8,10 @@
|
|
|
8
8
|
* model's declared `contextWindow`. The old model exposed that as an absolute
|
|
9
9
|
* "gateway limit", which silently stops working the moment the conversation
|
|
10
10
|
* moves to a model with a different window. The policy now follows DSH: a
|
|
11
|
-
* window fraction
|
|
12
|
-
*
|
|
11
|
+
* window fraction, so one setting stays correct across models.
|
|
12
|
+
*
|
|
13
|
+
* The absolute headroom was removed: it was a second ceiling competing with the
|
|
14
|
+
* ratio, and it usually won, which made the ratio an operator set unreachable.
|
|
13
15
|
*
|
|
14
16
|
* Environment variables remain supported and take precedence, so an operator
|
|
15
17
|
* can override without touching saved settings (see `resolveCompactionSettings`).
|
|
@@ -17,7 +19,7 @@
|
|
|
17
19
|
import { readFile, rename, writeFile } from "node:fs/promises";
|
|
18
20
|
import path from "node:path";
|
|
19
21
|
import { ensureSecureDir } from "../../infrastructure/console/app-data.js";
|
|
20
|
-
import {
|
|
22
|
+
import { DEFAULT_RETAIN_RATIO, DEFAULT_THRESHOLD_RATIO, } from "../../shared/pi-context-pressure/compaction-policy.js";
|
|
21
23
|
export const PI_COMPACTION_SETTINGS_SCHEMA_VERSION = 1;
|
|
22
24
|
export class PiCompactionSettingsError extends Error {
|
|
23
25
|
code;
|
|
@@ -32,8 +34,6 @@ export class PiCompactionSettingsError extends Error {
|
|
|
32
34
|
/** Bounds mirror the environment parser so the two sources cannot disagree. */
|
|
33
35
|
export const THRESHOLD_RATIO_MIN = 0.05;
|
|
34
36
|
export const THRESHOLD_RATIO_MAX = 1;
|
|
35
|
-
export const HEADROOM_MIN = 0;
|
|
36
|
-
export const HEADROOM_MAX = 10_000_000;
|
|
37
37
|
export const RETAIN_RATIO_MIN = 0.01;
|
|
38
38
|
export const RETAIN_RATIO_MAX = 0.99;
|
|
39
39
|
/**
|
|
@@ -45,8 +45,17 @@ export const RETAIN_RATIO_MAX = 0.99;
|
|
|
45
45
|
* now derived from the window. Ignoring them means an upgraded install lands on
|
|
46
46
|
* the DSH defaults instead of on a silently wrong value.
|
|
47
47
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
/*
|
|
49
|
+
* `headroomTokens` joins the legacy set.
|
|
50
|
+
*
|
|
51
|
+
* It was a second ceiling subtracted before the ratio applied, so the ratio an operator
|
|
52
|
+
* set was frequently unreachable — a 128K window at 100% triggered at 48K. Dropping it
|
|
53
|
+
* rather than migrating is deliberate: there is no correct way to convert "absolute
|
|
54
|
+
* distance from the top" into "how full the window should get". An upgraded install
|
|
55
|
+
* lands on the ratio default, which is the number it always should have been reading.
|
|
56
|
+
*/
|
|
57
|
+
const LEGACY_KEYS = new Set(["gatewayInputLimitTokens", "keepRecentTokens", "headroomTokens"]);
|
|
58
|
+
const CURRENT_KEYS = ["thresholdRatio", "retainRatio"];
|
|
50
59
|
function isRecord(value) {
|
|
51
60
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
52
61
|
}
|
|
@@ -72,7 +81,6 @@ export function parsePiCompactionSettings(value) {
|
|
|
72
81
|
throw new PiCompactionSettingsError("INVALID_INPUT", `压缩设置包含无效字段:${unknownKeys.join(", ")}`);
|
|
73
82
|
}
|
|
74
83
|
const thresholdRatio = boundedNumber(value.thresholdRatio, "窗口比例", THRESHOLD_RATIO_MIN, THRESHOLD_RATIO_MAX);
|
|
75
|
-
const headroomTokens = boundedNumber(value.headroomTokens, "额外余量", HEADROOM_MIN, HEADROOM_MAX);
|
|
76
84
|
const retainRatio = boundedNumber(value.retainRatio, "保留比例", RETAIN_RATIO_MIN, RETAIN_RATIO_MAX);
|
|
77
85
|
if (thresholdRatio !== undefined &&
|
|
78
86
|
retainRatio !== undefined &&
|
|
@@ -83,7 +91,6 @@ export function parsePiCompactionSettings(value) {
|
|
|
83
91
|
}
|
|
84
92
|
return {
|
|
85
93
|
...(thresholdRatio === undefined ? {} : { thresholdRatio }),
|
|
86
|
-
...(headroomTokens === undefined ? {} : { headroomTokens }),
|
|
87
94
|
...(retainRatio === undefined ? {} : { retainRatio }),
|
|
88
95
|
};
|
|
89
96
|
}
|
|
@@ -103,11 +110,9 @@ export function resolveCompactionSettings(input) {
|
|
|
103
110
|
return Number.isFinite(parsed) ? parsed : undefined;
|
|
104
111
|
};
|
|
105
112
|
const thresholdFromEnv = readEnv("HARNESS_COMPACTION_THRESHOLD_RATIO");
|
|
106
|
-
const headroomFromEnv = readEnv("HARNESS_COMPACTION_HEADROOM_TOKENS");
|
|
107
113
|
const retainFromEnv = readEnv("HARNESS_COMPACTION_RETAIN_RATIO");
|
|
108
114
|
return {
|
|
109
115
|
thresholdRatio: thresholdFromEnv ?? saved.thresholdRatio,
|
|
110
|
-
headroomTokens: headroomFromEnv ?? saved.headroomTokens,
|
|
111
116
|
retainRatio: retainFromEnv ?? saved.retainRatio,
|
|
112
117
|
};
|
|
113
118
|
}
|
|
@@ -115,7 +120,6 @@ export function resolveCompactionSettings(input) {
|
|
|
115
120
|
export function effectiveCompactionSettings(settings) {
|
|
116
121
|
return {
|
|
117
122
|
thresholdRatio: settings.thresholdRatio ?? DEFAULT_THRESHOLD_RATIO,
|
|
118
|
-
headroomTokens: settings.headroomTokens ?? DEFAULT_HEADROOM_TOKENS,
|
|
119
123
|
retainRatio: settings.retainRatio ?? DEFAULT_RETAIN_RATIO,
|
|
120
124
|
};
|
|
121
125
|
}
|
|
@@ -184,7 +188,6 @@ export async function createPiCompactionSettings(appDataRoot) {
|
|
|
184
188
|
effective: resolved,
|
|
185
189
|
envOverrides: {
|
|
186
190
|
thresholdRatio: effective.thresholdRatio !== stored.settings.thresholdRatio,
|
|
187
|
-
headroomTokens: effective.headroomTokens !== stored.settings.headroomTokens,
|
|
188
191
|
retainRatio: effective.retainRatio !== stored.settings.retainRatio,
|
|
189
192
|
},
|
|
190
193
|
};
|
|
@@ -1088,6 +1088,26 @@ export async function createConsoleServer(options) {
|
|
|
1088
1088
|
sendJson(res, 200, await networkProxy.read());
|
|
1089
1089
|
return;
|
|
1090
1090
|
}
|
|
1091
|
+
/*
|
|
1092
|
+
* A POST probes connectivity through the current settings.
|
|
1093
|
+
*
|
|
1094
|
+
* The page could previously only say "saved", so an operator had no way
|
|
1095
|
+
* to tell a working proxy from a typo. The probe goes through the same
|
|
1096
|
+
* dispatcher real traffic uses.
|
|
1097
|
+
*/
|
|
1098
|
+
if (method === "POST") {
|
|
1099
|
+
const failure = evaluateMutationGate(req, {
|
|
1100
|
+
cookieName: bootToken.cookieName, bootToken: bootToken.value,
|
|
1101
|
+
confirmationToken: bootToken.confirmationToken,
|
|
1102
|
+
consoleOrigin: getConsoleOrigin(), allowNonLoopbackAccess: !loopbackBind,
|
|
1103
|
+
});
|
|
1104
|
+
if (failure) {
|
|
1105
|
+
sendJson(res, failure.status, { ok: false, error: failure });
|
|
1106
|
+
return;
|
|
1107
|
+
}
|
|
1108
|
+
sendJson(res, 200, { ok: true, probe: await networkProxy.probe() });
|
|
1109
|
+
return;
|
|
1110
|
+
}
|
|
1091
1111
|
if (method !== "PUT") {
|
|
1092
1112
|
sendJson(res, 405, { ok: false, error: { code: "METHOD_NOT_ALLOWED", message: "method not allowed" } });
|
|
1093
1113
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as p,r as u,d as a}from"./chunk-6Q2QTUOP-
|
|
1
|
+
import{g as p,r as u,d as a}from"./chunk-6Q2QTUOP-zowLlgmO.js";import{p as f}from"./chunk-JWPE2WC7-DuVIxg_I.js";import{_ as n,l as o}from"./mermaid.core-CVqQBsGx.js";import{M as c,b as d}from"./cynefin-VYW2F7L2-BIFL8KrA.js";import"./FilePreviewDocx-ybM3ZqSl.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},B={parser:R,db:a,renderer:u,styles:p};export{B as diagram};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Y as ln,$ as an,a0 as F,a1 as q,a2 as j,a3 as un,a4 as y,a5 as tn,a6 as J,a7 as _,a8 as rn,a9 as o,aa as on,ab as sn,ac as fn}from"./mermaid.core-
|
|
1
|
+
import{Y as ln,$ as an,a0 as F,a1 as q,a2 as j,a3 as un,a4 as y,a5 as tn,a6 as J,a7 as _,a8 as rn,a9 as o,aa as on,ab as sn,ac as fn}from"./mermaid.core-CVqQBsGx.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,I,D,v,A,z,a){var O=I-l,i=D-h,n=z-v,d=a-A,u=d*O-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*O,h+u*i]}function U(l,h,I,D,v,A,z){var a=l-I,O=h-D,i=(z?A:-A)/J(a*a+O*O),n=i*O,d=-i*a,u=l+n,s=h+d,f=I+n,c=D+d,B=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,S=(g<0?-1:1)*J(on(0,T*T*R-P*P)),Y=(P*g-m*S)/R,$=(-P*m-g*S)/R,w=(P*g+m*S)/R,p=(-P*m+g*S)/R,x=Y-B,e=$-t,r=w-B,C=p-t;return x*x+e*e>r*r+C*C&&(Y=w,$=p),{cx:Y,cy:$,x01:-n,y01:-d,x11:Y*(v/T-1),y11:$*(v/T-1)}}function hn(){var l=cn,h=yn,I=j(0),D=null,v=gn,A=dn,z=mn,a=null,O=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,B=rn(c-f),t=c>f;if(a||(a=n=O()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(B>tn-y)a.moveTo(s*F(f),s*q(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*F(c),u*q(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=B,S=B,Y=z.apply(this,arguments)/2,$=Y>y&&(D?+D.apply(this,arguments):J(u*u+s*s)),w=_(rn(s-u)/2,+I.apply(this,arguments)),p=w,x=w,e,r;if($>y){var C=sn($/u*q(Y)),K=sn($/s*q(Y));(P-=C*2)>y?(C*=t?1:-1,R+=C,T-=C):(P=0,R=T=(f+c)/2),(S-=K*2)>y?(K*=t?1:-1,m+=K,g-=K):(S=0,m=g=(f+c)/2)}var G=s*F(m),H=s*q(m),L=u*F(T),M=u*q(T);if(w>y){var N=s*F(g),Q=s*q(g),V=u*F(R),W=u*q(R),E;if(B<an)if(E=pn(G,H,V,W,N,Q,L,M)){var X=G-E[0],Z=H-E[1],b=N-E[0],k=Q-E[1],nn=1/q(fn((X*b+Z*k)/(J(X*X+Z*Z)*J(b*b+k*k)))/2),en=J(E[0]*E[0]+E[1]*E[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}S>y?x>y?(e=U(V,W,G,H,s,x,t),r=U(N,Q,L,M,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(G,H),a.arc(0,0,s,m,g,!t)):a.moveTo(G,H),!(u>y)||!(P>y)?a.lineTo(L,M):p>y?(e=U(L,M,N,Q,u,-p,t),r=U(G,H,V,W,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[F(d)*n,q(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:j(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:j(+n),i):h},i.cornerRadius=function(n){return arguments.length?(I=typeof n=="function"?n:j(+n),i):I},i.padRadius=function(n){return arguments.length?(D=n==null?null:typeof n=="function"?n:j(+n),i):D},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:j(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:j(+n),i):A},i.padAngle=function(n){return arguments.length?(z=typeof n=="function"?n:j(+n),i):z},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
|