@tea-agent/loop-agent 0.52.0 → 0.53.0-next.2
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 +62 -4
- package/dist/build-stamp.json +3 -3
- package/dist/executors/dag-pi/plan/finalize-tools.js +13 -0
- package/dist/executors/dag-pi/plan/record-tools.js +37 -11
- package/dist/executors/dag-pi/sessions/plan-batches.js +1 -1
- package/dist/executors/dag-pi/sessions/segmented-plan.js +28 -20
- package/dist/executors/dag-pi/tools/plan-decision-tools.js +2 -1
- package/dist/executors/dag-pi-executor.js +50 -5
- package/dist/executors/pi-executor.js +12 -0
- package/dist/executors/pi-sdk-executor.js +2 -2
- package/dist/shared/frontend-execution-policy.js +28 -2
- package/dist/shared/pi-context-pressure/compaction-policy.js +22 -34
- package/dist/shared/pi-context-pressure/index.js +1 -1
- package/dist/task/config-types.js +2 -2
- package/dist/task/source-prepare/prepare.js +1 -1
- package/dist/task/source-prepare/semantic-intake.js +2 -2
- package/dist/task/source-prepare/source-fidelity-pi.js +2 -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/dist/workflows/dag/checkpoint.js +6 -1
- package/dist/workflows/dag/frontend-committed-facts.js +38 -5
- package/dist/workflows/dag/frontend-design-policy.js +22 -0
- package/dist/workflows/dag/frontend-implementation-contract.js +39 -12
- package/dist/workflows/dag/frontend-imported-run-artifacts.js +126 -0
- package/dist/workflows/dag/frontend-recovery-run.js +7 -110
- package/dist/workflows/dag/frontend-test-framework-adapters.js +14 -0
- package/dist/workflows/dag/frontend-verification-trace.js +20 -8
- package/dist/workflows/dag/frontend-writer-reuse.js +104 -0
- package/dist/workflows/dag/frontend-writer-status.js +0 -4
- package/dist/workflows/dag/hybrid/templates/frontend.js +15 -8
- package/dist/workflows/dag/init-hybrid.js +1 -1
- package/dist/workflows/dag/reconcile-run.js +11 -1
- package/dist/workflows/dag/recovery-lease.js +23 -0
- package/dist/workflows/dag/rerun-feedback.js +4 -2
- package/dist/workflows/dag/rerun-run.js +40 -0
- package/dist/workflows/dag/runner.js +11 -0
- package/dist/workflows/dag/terminal-status.js +2 -1
- 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,213 @@
|
|
|
1
|
+
import { browserTimeZone, zoneDisplayName } from "./automation-catalog-model.js";
|
|
2
|
+
const WEEKDAY_NAMES = ["一", "二", "三", "四", "五", "六", "日"];
|
|
3
|
+
/**
|
|
4
|
+
* Clock part of a stored time, without the millisecond suffix a rule may carry.
|
|
5
|
+
*
|
|
6
|
+
* @param value - a stored `HH:mm:ss` (optionally with `.SSS`).
|
|
7
|
+
* @returns the `HH:mm:ss` prefix, or the input when it does not parse.
|
|
8
|
+
*/
|
|
9
|
+
function clock(value) {
|
|
10
|
+
if (value === undefined)
|
|
11
|
+
return "";
|
|
12
|
+
const match = /^(\d{2}:\d{2}:\d{2})/.exec(value);
|
|
13
|
+
return match ? match[1] : value;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Calendar date of a one-shot instant, in the operator's own zone.
|
|
17
|
+
*
|
|
18
|
+
* `at` is a UTC instant; the task fires at a wall-clock moment that the reader
|
|
19
|
+
* experiences locally, so the date has to be rendered in local time. DSH writes
|
|
20
|
+
* it as `YYYY/MM/DD` (`task-timing.ts`: `slashDate`).
|
|
21
|
+
*
|
|
22
|
+
* The zone is a PARAMETER, not the host's: this function is documented as pure,
|
|
23
|
+
* and reading `getFullYear()`/`getHours()` made the rendered rows depend on
|
|
24
|
+
* wherever the code happened to run. That showed up as a test passing locally
|
|
25
|
+
* (Asia/Shanghai) and failing on a UTC CI runner, and would have been a real
|
|
26
|
+
* bug for any operator whose Console process runs in a different zone from
|
|
27
|
+
* their browser.
|
|
28
|
+
*
|
|
29
|
+
* @param instant - ISO instant, or undefined.
|
|
30
|
+
* @param timeZone - IANA zone to render in.
|
|
31
|
+
* @returns `YYYY/MM/DD`, or an empty string when absent.
|
|
32
|
+
*/
|
|
33
|
+
function localDate(instant, timeZone) {
|
|
34
|
+
if (instant === undefined)
|
|
35
|
+
return "";
|
|
36
|
+
const at = new Date(instant);
|
|
37
|
+
if (Number.isNaN(at.getTime()))
|
|
38
|
+
return "";
|
|
39
|
+
const parts = zonedParts(at, timeZone);
|
|
40
|
+
if (!parts)
|
|
41
|
+
return "";
|
|
42
|
+
return `${parts.year}/${parts.month}/${parts.day}`;
|
|
43
|
+
}
|
|
44
|
+
/** Local wall-clock time of a one-shot instant, `HH:mm:ss`. */
|
|
45
|
+
function localClock(instant, timeZone) {
|
|
46
|
+
if (instant === undefined)
|
|
47
|
+
return "";
|
|
48
|
+
const at = new Date(instant);
|
|
49
|
+
if (Number.isNaN(at.getTime()))
|
|
50
|
+
return "";
|
|
51
|
+
const parts = zonedParts(at, timeZone);
|
|
52
|
+
if (!parts)
|
|
53
|
+
return "";
|
|
54
|
+
return `${parts.hour}:${parts.minute}:${parts.second}`;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Wall-clock parts of an instant in one IANA zone.
|
|
58
|
+
*
|
|
59
|
+
* `Intl.DateTimeFormat` is the only portable way to do this: `getHours()` is
|
|
60
|
+
* fixed to the host zone, and there is no `Temporal` in the supported runtime
|
|
61
|
+
* baseline. `hourCycle: "h23"` keeps midnight as `00`, which `hour12: false`
|
|
62
|
+
* alone does not guarantee on every ICU version.
|
|
63
|
+
*
|
|
64
|
+
* @returns the zero-padded parts, or undefined when the zone is unusable.
|
|
65
|
+
*/
|
|
66
|
+
function zonedParts(at, timeZone) {
|
|
67
|
+
let formatter;
|
|
68
|
+
try {
|
|
69
|
+
formatter = new Intl.DateTimeFormat("en-CA", {
|
|
70
|
+
timeZone,
|
|
71
|
+
year: "numeric",
|
|
72
|
+
month: "2-digit",
|
|
73
|
+
day: "2-digit",
|
|
74
|
+
hour: "2-digit",
|
|
75
|
+
minute: "2-digit",
|
|
76
|
+
second: "2-digit",
|
|
77
|
+
hourCycle: "h23",
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
// An unknown zone must not blank the whole card; fall back to the host.
|
|
82
|
+
formatter = new Intl.DateTimeFormat("en-CA", {
|
|
83
|
+
year: "numeric",
|
|
84
|
+
month: "2-digit",
|
|
85
|
+
day: "2-digit",
|
|
86
|
+
hour: "2-digit",
|
|
87
|
+
minute: "2-digit",
|
|
88
|
+
second: "2-digit",
|
|
89
|
+
hourCycle: "h23",
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const parts = formatter.formatToParts(at);
|
|
93
|
+
const read = (type) => parts.find((part) => part.type === type)?.value;
|
|
94
|
+
const year = read("year");
|
|
95
|
+
const month = read("month");
|
|
96
|
+
const day = read("day");
|
|
97
|
+
const hour = read("hour");
|
|
98
|
+
const minute = read("minute");
|
|
99
|
+
const second = read("second");
|
|
100
|
+
if (!year || !month || !day || !hour || !minute || !second)
|
|
101
|
+
return undefined;
|
|
102
|
+
return { year, month, day, hour, minute, second };
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Describe how often a task runs and when.
|
|
106
|
+
*
|
|
107
|
+
* @param task - the task whose rule is described.
|
|
108
|
+
* @param systemZone - the operator's zone, used to mark a system default.
|
|
109
|
+
* @returns the rows to render.
|
|
110
|
+
*/
|
|
111
|
+
export function scheduleRuleSummary(task, systemZone = browserTimeZone()) {
|
|
112
|
+
const rule = task.rule;
|
|
113
|
+
switch (rule.kind) {
|
|
114
|
+
case "at": {
|
|
115
|
+
/*
|
|
116
|
+
* A one-shot CAN carry a zone, and usually does.
|
|
117
|
+
*
|
|
118
|
+
* `normalizeAutomationTiming` has two paths for `at` (`shared/automation/time.ts`):
|
|
119
|
+
* a bare ISO string stores the instant with `timeZone: "UTC"`, while
|
|
120
|
+
* `{date, time, time_zone}` resolves the wall clock in the chosen zone and
|
|
121
|
+
* keeps it. The editor always sends the second form, so a one-shot made in the
|
|
122
|
+
* UI does have a zone — hiding the row implied a setting that did not exist,
|
|
123
|
+
* which was exactly backwards.
|
|
124
|
+
*
|
|
125
|
+
* The row is shown whenever a zone is stored; the caveat appears only for the
|
|
126
|
+
* bare-instant case, where the displayed time really is the local rendering of
|
|
127
|
+
* a zone-less moment.
|
|
128
|
+
*/
|
|
129
|
+
const zone = typeof task.timeZone === "string" ? task.timeZone.trim() : "";
|
|
130
|
+
const stored = zone !== "" && zone !== "UTC";
|
|
131
|
+
return {
|
|
132
|
+
repeat: "仅一次",
|
|
133
|
+
rows: [
|
|
134
|
+
{ label: "日期", value: localDate(rule.at, stored ? zone : systemZone) },
|
|
135
|
+
{ label: "时间", value: localClock(rule.at, stored ? zone : systemZone) },
|
|
136
|
+
...(stored ? [{ label: "时区", value: zoneDisplayName(zone, systemZone) }] : []),
|
|
137
|
+
],
|
|
138
|
+
...(stored ? {} : { hint: "单次任务只保存触发时刻,不保存时区;日期和时间按本地时区换算" }),
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
case "every": {
|
|
142
|
+
const seconds = typeof rule.seconds === "number" ? rule.seconds : 0;
|
|
143
|
+
return {
|
|
144
|
+
repeat: "固定间隔",
|
|
145
|
+
rows: [
|
|
146
|
+
{ label: "间隔", value: describeInterval(seconds) },
|
|
147
|
+
{ label: "时区", value: storedZoneLabel(task, systemZone) },
|
|
148
|
+
],
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
case "daily":
|
|
152
|
+
return {
|
|
153
|
+
repeat: "每日",
|
|
154
|
+
rows: [
|
|
155
|
+
{ label: "时间", value: clock(rule.time) },
|
|
156
|
+
{ label: "时区", value: storedZoneLabel(task, systemZone) },
|
|
157
|
+
],
|
|
158
|
+
};
|
|
159
|
+
case "weekly": {
|
|
160
|
+
const days = Array.isArray(rule.weekdays) ? [...rule.weekdays].sort((a, b) => a - b) : [];
|
|
161
|
+
const names = days.map((day) => WEEKDAY_NAMES[day - 1]).filter(Boolean).join("、");
|
|
162
|
+
return {
|
|
163
|
+
repeat: "每周",
|
|
164
|
+
rows: [
|
|
165
|
+
{ label: "星期", value: names === "" ? "未设置" : `周${names}` },
|
|
166
|
+
{ label: "时间", value: clock(rule.time) },
|
|
167
|
+
{ label: "时区", value: storedZoneLabel(task, systemZone) },
|
|
168
|
+
],
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
case "cron":
|
|
172
|
+
return {
|
|
173
|
+
repeat: "Cron",
|
|
174
|
+
rows: [
|
|
175
|
+
{ label: "表达式", value: rule.expression?.trim() || "未设置", title: rule.expression },
|
|
176
|
+
{ label: "时区", value: storedZoneLabel(task, systemZone) },
|
|
177
|
+
],
|
|
178
|
+
};
|
|
179
|
+
default:
|
|
180
|
+
return { repeat: "未知规则", rows: [] };
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* The task's zone, marked as the system default when it is one.
|
|
185
|
+
*
|
|
186
|
+
* @param task - the task carrying the zone.
|
|
187
|
+
* @param systemZone - the operator's zone.
|
|
188
|
+
* @returns the display label, or「按本地时区」when the task stores none.
|
|
189
|
+
*/
|
|
190
|
+
function storedZoneLabel(task, systemZone) {
|
|
191
|
+
const zone = typeof task.timeZone === "string" ? task.timeZone.trim() : "";
|
|
192
|
+
if (zone === "")
|
|
193
|
+
return "按本地时区";
|
|
194
|
+
return zoneDisplayName(zone, systemZone);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* An interval in the largest unit that divides it evenly.
|
|
198
|
+
*
|
|
199
|
+
* `every 3600` reads as「1 小时」rather than「3600 秒」: the rule stores seconds,
|
|
200
|
+
* but an operator thinks in the unit they chose.
|
|
201
|
+
*
|
|
202
|
+
* @param seconds - the stored interval.
|
|
203
|
+
* @returns a human interval, or a second count that does not divide evenly.
|
|
204
|
+
*/
|
|
205
|
+
export function describeInterval(seconds) {
|
|
206
|
+
if (!Number.isFinite(seconds) || seconds <= 0)
|
|
207
|
+
return "未设置";
|
|
208
|
+
for (const unit of [{ size: 86_400, name: "天" }, { size: 3_600, name: "小时" }, { size: 60, name: "分钟" }]) {
|
|
209
|
+
if (seconds % unit.size === 0)
|
|
210
|
+
return `${seconds / unit.size} ${unit.name}`;
|
|
211
|
+
}
|
|
212
|
+
return `${seconds} 秒`;
|
|
213
|
+
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Consolidates agent subtasks, workflow runs, background jobs and fold aggregates
|
|
5
5
|
* into a single unified tree and graph data model with hierarchical topology.
|
|
6
6
|
*/
|
|
7
|
+
import { formatTokenCount } from "../../chat/usage.js";
|
|
7
8
|
export function formatDuration(startedAt, finishedAt, now = Date.now()) {
|
|
8
9
|
if (!startedAt)
|
|
9
10
|
return "—";
|
|
@@ -143,6 +144,9 @@ export function buildTasksModel(input) {
|
|
|
143
144
|
startedAt: task.startedAt,
|
|
144
145
|
finishedAt: task.finishedAt,
|
|
145
146
|
durationText: formatDuration(task.startedAt, task.finishedAt, now),
|
|
147
|
+
...(typeof task.tokenTotal === "number" && Number.isFinite(task.tokenTotal) && task.tokenTotal > 0
|
|
148
|
+
? { tokenText: formatTokenCount(task.tokenTotal) }
|
|
149
|
+
: {}),
|
|
146
150
|
activityText: task.lastActivityText,
|
|
147
151
|
rootSessionId: task.rootSessionId ?? task.parentSessionId,
|
|
148
152
|
parentSessionId: task.parentSessionId,
|
|
@@ -10,6 +10,14 @@ export function sameTurnGroupInputs(previous, next) {
|
|
|
10
10
|
previous.user === next.user &&
|
|
11
11
|
previous.standaloneEvent === next.standaloneEvent &&
|
|
12
12
|
previous.turnState === next.turnState &&
|
|
13
|
+
/*
|
|
14
|
+
* The origin must be compared too: it arrives from its own map, so a
|
|
15
|
+
* group can be built before its `turnSource` is known and then be
|
|
16
|
+
* reused by the cache forever — the wake-up row would never appear.
|
|
17
|
+
* Both sides come from the same `turnSourcesById` value, so identity
|
|
18
|
+
* comparison is sound.
|
|
19
|
+
*/
|
|
20
|
+
previous.turnSource === next.turnSource &&
|
|
13
21
|
previous.turnClosed === next.turnClosed &&
|
|
14
22
|
previous.live === next.live &&
|
|
15
23
|
previous.workspaceChanges === next.workspaceChanges &&
|
|
@@ -10,6 +10,18 @@ export function isTurnProcessCompact(input) {
|
|
|
10
10
|
return false;
|
|
11
11
|
if (input.manualOpen)
|
|
12
12
|
return false;
|
|
13
|
+
/*
|
|
14
|
+
* A stopped or failed turn never auto-folds. The reader comes back to such a
|
|
15
|
+
* turn because something went wrong, and the process rows are the evidence —
|
|
16
|
+
* the same reason DSH's `turnProcessAlwaysOpen` refuses to fold
|
|
17
|
+
* aborted/interrupted/error turns (`turn-process.ts:53-58`).
|
|
18
|
+
*
|
|
19
|
+
* This is checked BEFORE `manualClosed`, so a persisted manual close does not
|
|
20
|
+
* re-hide a failed turn on the next load. That matches DSH, where such a turn
|
|
21
|
+
* has no fold control at all.
|
|
22
|
+
*/
|
|
23
|
+
if (input.turnState === "aborted" || input.turnState === "failed")
|
|
24
|
+
return false;
|
|
13
25
|
if (input.manualClosed)
|
|
14
26
|
return true;
|
|
15
27
|
if (input.mode === "full")
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read one turn's origin out of a state summary.
|
|
3
|
+
*
|
|
4
|
+
* @param value - the summary's `source` field, still untrusted.
|
|
5
|
+
* @returns the source, or undefined for an operator-started turn.
|
|
6
|
+
*/
|
|
7
|
+
export function normalizeTurnSource(value) {
|
|
8
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
9
|
+
return undefined;
|
|
10
|
+
const record = value;
|
|
11
|
+
if (record.kind !== "goal")
|
|
12
|
+
return undefined;
|
|
13
|
+
return {
|
|
14
|
+
kind: "goal",
|
|
15
|
+
...(typeof record.round === "number" && Number.isSafeInteger(record.round) && record.round > 0
|
|
16
|
+
? { round: record.round }
|
|
17
|
+
: {}),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
1
20
|
export const TURN_STATE_RECONCILE_DELAYS_MS = [0, 75, 200, 500];
|
|
2
21
|
export const TURN_STATE_QUEUE_RETRY_DELAYS_MS = [0, 75, 200, 500, 2_000];
|
|
3
22
|
const MAX_TURN_STATE_QUERY_BATCH = 8;
|
|
@@ -38,6 +57,38 @@ export function setProjectedTurnState(current, turnId, state) {
|
|
|
38
57
|
}
|
|
39
58
|
return { ...current, [turnId]: merged };
|
|
40
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Merge projected turn origins.
|
|
62
|
+
*
|
|
63
|
+
* Kept separate from {@link mergeTurnStateSummaries} on purpose: a turn's state
|
|
64
|
+
* changes many times while its origin never does, so folding them into one
|
|
65
|
+
* record would make every state transition churn the origin map too. A merge
|
|
66
|
+
* that learns nothing new returns the input reference, so React can skip.
|
|
67
|
+
*
|
|
68
|
+
* @param current - origins known so far.
|
|
69
|
+
* @param summaries - incoming summaries, whose `source` may be absent.
|
|
70
|
+
* @returns the merged map, or the same reference when nothing changed.
|
|
71
|
+
*/
|
|
72
|
+
export function mergeTurnSources(current, summaries) {
|
|
73
|
+
if (!summaries?.length)
|
|
74
|
+
return current;
|
|
75
|
+
let next;
|
|
76
|
+
for (const summary of summaries) {
|
|
77
|
+
if (typeof summary.turnId !== "string" || !summary.turnId)
|
|
78
|
+
continue;
|
|
79
|
+
const source = normalizeTurnSource(summary.source);
|
|
80
|
+
if (source === undefined)
|
|
81
|
+
continue;
|
|
82
|
+
const previous = (next ?? current)[summary.turnId];
|
|
83
|
+
// Origin is immutable once recorded; a later frame that repeats it is a no-op.
|
|
84
|
+
if (previous !== undefined && previous.kind === source.kind
|
|
85
|
+
&& previous.round === source.round)
|
|
86
|
+
continue;
|
|
87
|
+
next ??= { ...current };
|
|
88
|
+
next[summary.turnId] = source;
|
|
89
|
+
}
|
|
90
|
+
return next ?? current;
|
|
91
|
+
}
|
|
41
92
|
function mergeDurableTurnState(current, incoming) {
|
|
42
93
|
if (!incoming)
|
|
43
94
|
return current;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useEffect } from "react";
|
|
1
|
+
import { useCallback, useEffect, useState } from "react";
|
|
2
2
|
import { formatOperatorUserError } from "../../operator-user-error.js";
|
|
3
3
|
import { inspectChatSseContinuity, readChatStreamReadyCursor, selectChatSseRepairBlocks, selectLaterChatEventId, } from "./chat-stream-continuity.js";
|
|
4
4
|
import { confirmationToken, requestId, sleep } from "./format.js";
|
|
@@ -127,6 +127,21 @@ export function useChatStream(params) {
|
|
|
127
127
|
return;
|
|
128
128
|
setNotice({ id: Date.now(), message });
|
|
129
129
|
}, [setNotice]);
|
|
130
|
+
/**
|
|
131
|
+
* Whether the live event stream is currently delivering.
|
|
132
|
+
*
|
|
133
|
+
* The reconnect loop sets `state.ready = false` and then retries in silence, so
|
|
134
|
+
* a dropped connection looked exactly like a quiet session: the transcript
|
|
135
|
+
* simply stopped moving, with nothing to tell the operator why. This mirrors
|
|
136
|
+
* that internal flag into render state so the composer can say「连接已断开,正在重连」.
|
|
137
|
+
*
|
|
138
|
+
* `undefined` means "no stream started yet", which is not the same as broken
|
|
139
|
+
* and must not raise an alarm.
|
|
140
|
+
*/
|
|
141
|
+
const [eventsConnected, setEventsConnected] = useState(undefined);
|
|
142
|
+
const markEventsReady = useCallback((ready) => {
|
|
143
|
+
setEventsConnected((current) => (current === ready ? current : ready));
|
|
144
|
+
}, []);
|
|
130
145
|
const releaseSubmitOwnership = useCallback((pendingClientRequestId) => {
|
|
131
146
|
const bag = ownershipBagFromRefs(refs);
|
|
132
147
|
releaseOwnershipBag(bag, pendingClientRequestId);
|
|
@@ -184,6 +199,7 @@ export function useChatStream(params) {
|
|
|
184
199
|
state.generation !== generation)
|
|
185
200
|
return;
|
|
186
201
|
state.ready = false;
|
|
202
|
+
markEventsReady(false);
|
|
187
203
|
try {
|
|
188
204
|
const headers = {
|
|
189
205
|
Accept: "text/event-stream",
|
|
@@ -242,6 +258,7 @@ export function useChatStream(params) {
|
|
|
242
258
|
if (current?.sessionId === sessionId &&
|
|
243
259
|
current.generation === generation)
|
|
244
260
|
current.ready = true;
|
|
261
|
+
markEventsReady(true);
|
|
245
262
|
replay = false;
|
|
246
263
|
liveContinuityCursor = readChatStreamReadyCursor(block);
|
|
247
264
|
// Fall through: the applier owns the buffered-replay flush and
|
|
@@ -284,8 +301,10 @@ export function useChatStream(params) {
|
|
|
284
301
|
}
|
|
285
302
|
const current = refs.eventsStreamStateRef.current;
|
|
286
303
|
if (current?.sessionId === sessionId &&
|
|
287
|
-
current.generation === generation)
|
|
304
|
+
current.generation === generation) {
|
|
288
305
|
current.ready = false;
|
|
306
|
+
markEventsReady(false);
|
|
307
|
+
}
|
|
289
308
|
// A detected hole is expected to be immediately recoverable from the
|
|
290
309
|
// durable ring. Other EOFs retain the normal reconnect backoff.
|
|
291
310
|
if (!replayRepairNeeded)
|
|
@@ -1390,6 +1409,7 @@ export function useChatStream(params) {
|
|
|
1390
1409
|
};
|
|
1391
1410
|
}, [session, recoveryVersion, refs, startEventsStream]);
|
|
1392
1411
|
return {
|
|
1412
|
+
eventsConnected,
|
|
1393
1413
|
sendPrompt,
|
|
1394
1414
|
handleStop,
|
|
1395
1415
|
cancelDeferredTurn,
|
|
@@ -11,7 +11,7 @@ import { invalidateSessionDetailCacheSeed } from "./useChatSessions.js";
|
|
|
11
11
|
import { mergeSubagentCatalogItems, projectSubagentCatalogFromToolCalls, subagentSummary, } from "./subagent-catalog.js";
|
|
12
12
|
import { sameTurnGroupInputs } from "./turn-group-equality.js";
|
|
13
13
|
import { conversationNodesFromEvents, } from "../../chat/conversation-nodes.js";
|
|
14
|
-
import { mergeTurnStateSummaries, setProjectedTurnState, } from "./turn-state-projection.js";
|
|
14
|
+
import { mergeTurnSources, mergeTurnStateSummaries, setProjectedTurnState, } from "./turn-state-projection.js";
|
|
15
15
|
function latestWorkspaceChanges(items) {
|
|
16
16
|
return [...new Map(items.map(item => [item.turnId, item])).values()];
|
|
17
17
|
}
|
|
@@ -153,9 +153,18 @@ export function useChatThread(params) {
|
|
|
153
153
|
const [operatorActions, setOperatorActions] = useState([]);
|
|
154
154
|
const [conversationNodes, setConversationNodes] = useState([]);
|
|
155
155
|
const [turnStatesById, setTurnStatesById] = useState({});
|
|
156
|
+
/*
|
|
157
|
+
* Which turns the runtime woke on its own.
|
|
158
|
+
*
|
|
159
|
+
* Separate from `turnStatesById` because a turn's state changes many times
|
|
160
|
+
* while its origin never does. Both come from the same summaries, so they are
|
|
161
|
+
* reconciled together rather than through a second request.
|
|
162
|
+
*/
|
|
163
|
+
const [turnSourcesById, setTurnSourcesById] = useState({});
|
|
156
164
|
const [workspaceChanges, setWorkspaceChanges] = useState([]);
|
|
157
165
|
const reconcileTurnStates = useCallback((summaries) => {
|
|
158
166
|
setTurnStatesById((current) => mergeTurnStateSummaries(current, summaries));
|
|
167
|
+
setTurnSourcesById((current) => mergeTurnSources(current, summaries));
|
|
159
168
|
}, []);
|
|
160
169
|
const [sddSessionIdentity, setSddSessionIdentity] = useState(null);
|
|
161
170
|
const [streaming, setStreaming] = useState(false);
|
|
@@ -395,6 +404,7 @@ export function useChatThread(params) {
|
|
|
395
404
|
activeAssistantId: streamingAssistantId,
|
|
396
405
|
conversationNodes,
|
|
397
406
|
turnStatesById,
|
|
407
|
+
turnSourcesById,
|
|
398
408
|
workspaceChanges,
|
|
399
409
|
});
|
|
400
410
|
// Preserve completed group objects across streaming tokens. Stable
|
|
@@ -487,6 +497,7 @@ export function useChatThread(params) {
|
|
|
487
497
|
return [...byId.values()].sort((a, b) => a.createdAt - b.createdAt);
|
|
488
498
|
});
|
|
489
499
|
setTurnStatesById((current) => mergeTurnStateSummaries(current, collectedTurnStates));
|
|
500
|
+
setTurnSourcesById((current) => mergeTurnSources(current, collectedTurnStates));
|
|
490
501
|
setHistoryHasMore(hasMore);
|
|
491
502
|
setHistoryNextCursor(beforeId || null);
|
|
492
503
|
return input?.untilMessageId ? found : true;
|
|
@@ -594,6 +605,7 @@ export function useChatThread(params) {
|
|
|
594
605
|
setToolCalls(next.toolCalls);
|
|
595
606
|
setConversationNodes(conversationNodesFromEvents(next.conversationEvents ?? []));
|
|
596
607
|
setTurnStatesById(mergeTurnStateSummaries({}, next.turnStates));
|
|
608
|
+
setTurnSourcesById(mergeTurnSources({}, next.turnStates));
|
|
597
609
|
setOperationCards([]);
|
|
598
610
|
setHumanGateCards([]);
|
|
599
611
|
setArtifactCards([]);
|
|
@@ -676,6 +688,7 @@ export function useChatThread(params) {
|
|
|
676
688
|
const hydrated = hydrateSessionThread(body.session.messages ?? [], visuallyStopped ? undefined : activeTurnId ?? undefined);
|
|
677
689
|
setConversationNodes(conversationNodesFromEvents(body.conversationEvents ?? []));
|
|
678
690
|
setTurnStatesById((current) => mergeTurnStateSummaries(current, body.session?.turnStates));
|
|
691
|
+
setTurnSourcesById((current) => mergeTurnSources(current, body.session?.turnStates));
|
|
679
692
|
// Recovery is addressed to targetSessionId, so an optimistic
|
|
680
693
|
// submission from another session must never be projected into
|
|
681
694
|
// this snapshot (the activation path enforces the same owner gate).
|
|
@@ -752,6 +765,7 @@ export function useChatThread(params) {
|
|
|
752
765
|
operatorActions,
|
|
753
766
|
conversationNodes,
|
|
754
767
|
turnStatesById,
|
|
768
|
+
turnSourcesById,
|
|
755
769
|
reconcileTurnStates,
|
|
756
770
|
sddSessionIdentity,
|
|
757
771
|
setSddSessionIdentity,
|