dsh-mobile-plugin 0.5.45 → 0.5.47
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/lib/client.js +179 -130
- package/lib/impl.js +9 -0
- package/lib/mirror/pusher.cjs +92 -17
- package/lib/mobile/approval-facts.js +116 -24
- package/lib/mobile/history-derive.js +51 -10
- package/lib/mobile/run-timeline.js +2 -2
- package/lib/mobile/session-cache.js +16 -0
- package/lib/mobile/stats-collect.cjs +73 -1
- package/lib/mobile/stats-ledger.cjs +9 -0
- package/lib/mobile/stream.js +8 -0
- package/lib/mobile/workflow-live.js +74 -0
- package/lib/mobile/workflow-runs.js +194 -0
- package/lib/mobile/workspace-tools.js +594 -0
- package/lib/panel/index.html +15 -15
- package/lib/routes/control-plane.js +32 -1
- package/package.json +1 -1
package/lib/mirror/pusher.cjs
CHANGED
|
@@ -83,6 +83,21 @@ const AUDIENCE_IDLE_MS = 30_000;
|
|
|
83
83
|
* `MIRROR_SNAPSHOT_TTL_MS`(15s),否则 sidecar 的镜像快照会被判过期。
|
|
84
84
|
*/
|
|
85
85
|
const BG_COLD_ROTATE_MIN_INTERVAL_MS = 5000;
|
|
86
|
+
/**
|
|
87
|
+
* 清单重建的兜底窗:没有事件说「变了」时,最长隔这么久重新问一次宿主。
|
|
88
|
+
*
|
|
89
|
+
* 会话清单的构建是**全目录扫描**(列目录 + 每个会话开文件解压读头部):1800 条会话、
|
|
90
|
+
* 60 个项目目录的机器上单次一百多毫秒。旧实现不管变没变,每 500ms 都整份重建一遍 ——
|
|
91
|
+
* 「内容没变就跳过」那道判重只能省掉推送,省不掉扫描本身。
|
|
92
|
+
*
|
|
93
|
+
* 而变没变,宿主的会话事件流本来就在说(turn/start、turn/end、session/title、
|
|
94
|
+
* session/disposed、以及任何 host/* 帧)。所以现在只有三类时刻才真去重建:
|
|
95
|
+
* ① 从没构建过;② 有事件帧报告过变化(`listDirty`);③ 距上次构建超过这个窗。
|
|
96
|
+
*
|
|
97
|
+
* 取 5s 与冷会话轮转同一个窗口:事件覆盖不到的改动(例如只落了盘、没走会话事件的那类)
|
|
98
|
+
* 最多旧 5 秒,仍远小于 sidecar 的镜像快照 TTL(15s),也不会让镜像被判过期。
|
|
99
|
+
*/
|
|
100
|
+
const BG_LIST_REBUILD_FALLBACK_MS = 5000;
|
|
86
101
|
/**
|
|
87
102
|
* 全量补推(隧道连上那一次、主机级事件帧)之间的最小间隔。
|
|
88
103
|
*
|
|
@@ -787,6 +802,8 @@ function createMirrorPusher(deps) {
|
|
|
787
802
|
return;
|
|
788
803
|
}
|
|
789
804
|
retainSessionSignals(sessionsBody);
|
|
805
|
+
// 这条路径刚刚真的扫过一遍目录:把结果记进缓存,后台 tick 接下来就不必再扫。
|
|
806
|
+
rememberSessionsBody(sessionsBody);
|
|
790
807
|
await pushMirrorPayload({
|
|
791
808
|
kind: 'sync', at: Date.now(),
|
|
792
809
|
activeSessionId: sessionId,
|
|
@@ -873,6 +890,7 @@ function createMirrorPusher(deps) {
|
|
|
873
890
|
return
|
|
874
891
|
}
|
|
875
892
|
retainSessionSignals(sessionsBody);
|
|
893
|
+
rememberSessionsBody(sessionsBody);
|
|
876
894
|
const list = sessionsBody.body.items || [];
|
|
877
895
|
const highPrio = sessionIds
|
|
878
896
|
? list.filter(s => sessionIds.includes(String(s.sessionId)))
|
|
@@ -917,6 +935,41 @@ function createMirrorPusher(deps) {
|
|
|
917
935
|
let lastColdRotateAt = 0;
|
|
918
936
|
// 上一轮后台扫描真正跑起来的时刻(见 IDLE_TICK_INTERVAL_MS 的降频)。
|
|
919
937
|
let lastBgScanAt = 0;
|
|
938
|
+
// 最近一次成功构建出来的会话清单与工作区体,以及构建时刻(见 BG_LIST_REBUILD_FALLBACK_MS)。
|
|
939
|
+
// 缓存的是**整份响应体**:既有 revision 可以判重,也能让「这一轮不用重建」的冷轮转
|
|
940
|
+
// 直接拿它去推,不必再扫一遍目录。
|
|
941
|
+
let cachedSessionsBody = null;
|
|
942
|
+
let cachedWorkspacesBody = null;
|
|
943
|
+
let cachedSessionsAt = 0;
|
|
944
|
+
let cachedWorkspacesAt = 0;
|
|
945
|
+
// 「宿主那边可能变了」:由事件流置起,成功重建清单后清掉。它把「每 500ms 盲目重扫」
|
|
946
|
+
// 换成「事件说变了才重扫」,而兜底窗保证即使漏了事件也不会长期停在旧数据上。
|
|
947
|
+
let listDirty = false;
|
|
948
|
+
|
|
949
|
+
const sessionItemsOf = (body) => (body && body.body && Array.isArray(body.body.items) ? body.body.items : []);
|
|
950
|
+
|
|
951
|
+
/** 记下一份新构建出来的清单(只记成功的;「没取到」绝不能被后续轮次当成权威数据)。 */
|
|
952
|
+
const rememberSessionsBody = (body) => {
|
|
953
|
+
cachedSessionsBody = body;
|
|
954
|
+
cachedSessionsAt = Date.now();
|
|
955
|
+
listDirty = false;
|
|
956
|
+
};
|
|
957
|
+
|
|
958
|
+
/**
|
|
959
|
+
* 工作区体:与清单同一套「脏了才重建」的口径。
|
|
960
|
+
*
|
|
961
|
+
* 复用缓存也照旧过一次 `observeWorkspaces`:工作区信号就是从这里喂给手机的,
|
|
962
|
+
* 复用那一份时同样要保证信号基准是对的(它是幂等的)。守卫失败不覆盖旧缓存。
|
|
963
|
+
*/
|
|
964
|
+
const loadWorkspacesBody = async (stale) => {
|
|
965
|
+
if (!stale && cachedWorkspacesBody) return observeWorkspaces(cachedWorkspacesBody) || cachedWorkspacesBody;
|
|
966
|
+
const body = await workspaces.buildWorkspacesBody(ctx).then(observeWorkspaces);
|
|
967
|
+
if (body && body.ok !== false) {
|
|
968
|
+
cachedWorkspacesBody = body;
|
|
969
|
+
cachedWorkspacesAt = Date.now();
|
|
970
|
+
}
|
|
971
|
+
return body;
|
|
972
|
+
};
|
|
920
973
|
|
|
921
974
|
const processBgQueue = async () => {
|
|
922
975
|
if (bgQueueBusy) return;
|
|
@@ -935,21 +988,46 @@ function createMirrorPusher(deps) {
|
|
|
935
988
|
bgQueueBusy = true;
|
|
936
989
|
let shouldAnnounceRevision = true;
|
|
937
990
|
try {
|
|
938
|
-
const
|
|
939
|
-
//
|
|
940
|
-
//
|
|
941
|
-
|
|
942
|
-
|
|
991
|
+
const now = Date.now();
|
|
992
|
+
// 清单重建判据(见 BG_LIST_REBUILD_FALLBACK_MS):构建会话清单是**全目录扫描**,
|
|
993
|
+
// 旧实现每 500ms 无条件重扫一遍,而「内容没变就跳过」那道判重只能省掉推送、省不掉
|
|
994
|
+
// 扫描。变没变宿主的会话事件流本来就在说,所以这里只在三种时刻真去问宿主:
|
|
995
|
+
// 从没构建过、有事件报告过变化(listDirty)、或距上次构建超过兜底窗。
|
|
996
|
+
const listStale = !cachedSessionsBody || listDirty || now - cachedSessionsAt >= BG_LIST_REBUILD_FALLBACK_MS;
|
|
997
|
+
let sessionsBody;
|
|
998
|
+
if (listStale) {
|
|
999
|
+
sessionsBody = await sessions.buildSessionsResponse(ctx, 'legacy');
|
|
1000
|
+
// 空列表此前只是静默 return,看不出是「真的没会话」还是「没取到」;这里让守卫
|
|
1001
|
+
// 判定并记录理由,别再无声无息。
|
|
1002
|
+
const sessionsBlocked = guardSessions(sessionsBody);
|
|
1003
|
+
if (sessionsBlocked) {
|
|
1004
|
+
// 「没取到」不能进缓存:留着上一份好快照,下一 tick 重试重建。
|
|
1005
|
+
listDirty = true;
|
|
1006
|
+
if (online) recordMirrorPush(false, sessionsBlocked);
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
rememberSessionsBody(sessionsBody);
|
|
1010
|
+
} else {
|
|
1011
|
+
sessionsBody = cachedSessionsBody;
|
|
1012
|
+
}
|
|
943
1013
|
retainSessionSignals(sessionsBody);
|
|
944
1014
|
// 清单内容版本(lib/shared/list-revision.js 的哈希):既是广播判据,也是下面
|
|
945
1015
|
// 「中转镜像里那一版是不是这份」的比对基准 —— 全函数只算这一次。
|
|
946
1016
|
const revision = sessionsRevisionOf(sessionsBody && sessionsBody.body);
|
|
1017
|
+
// 这一轮要不要重扫由上面的 listStale 决定;用缓存时工作区也走缓存(见 loadWorkspacesBody),
|
|
1018
|
+
// 「什么都没变」的那一轮到这里其实只剩几次内存比对,判定统一放在下面的冷轮转门里。
|
|
947
1019
|
if (!online) {
|
|
948
1020
|
// 离线:只广播「清单变了」,不推送也不记推送状态(否则会变成每 tick 一条假故障)。
|
|
949
1021
|
announceSessionsRevision(revision);
|
|
950
1022
|
return;
|
|
951
1023
|
}
|
|
952
|
-
const list = sessionsBody
|
|
1024
|
+
const list = sessionItemsOf(sessionsBody);
|
|
1025
|
+
// 工作区体也是一份重活(含几十 KB 的归档会话 id 列表),判据与清单同一套:
|
|
1026
|
+
// 清单刚重建过、或过了兜底窗才重问宿主,否则复用上一份。
|
|
1027
|
+
const workspacesBody = await loadWorkspacesBody(
|
|
1028
|
+
listStale || !cachedWorkspacesBody || now - cachedWorkspacesAt >= BG_LIST_REBUILD_FALLBACK_MS,
|
|
1029
|
+
);
|
|
1030
|
+
const workspacesRevision = workspacesBody && typeof workspacesBody.revision === 'string' ? workspacesBody.revision : '';
|
|
953
1031
|
if (list.length === 0) {
|
|
954
1032
|
// 空清单**也要推**。守卫放行的空清单是「用户真的清空了」(body.emptyConfirmed
|
|
955
1033
|
// 由 mobile/sessions.js 按 items.length === 0 现算),不推的话中转镜像里那份旧
|
|
@@ -959,8 +1037,7 @@ function createMirrorPusher(deps) {
|
|
|
959
1037
|
// 跨包契约:中转侧对「空覆盖非空」有同口径保护,只认 emptyConfirmed === true 的空
|
|
960
1038
|
// 清单(中转的镜像状态里同一条谓词)。这里推的是 buildSessionsResponse 的原样 body,
|
|
961
1039
|
// 天然带这个字段。
|
|
962
|
-
const
|
|
963
|
-
const wsBlockedEmpty = guardWorkspaces(workspacesBodyEmpty);
|
|
1040
|
+
const wsBlockedEmpty = guardWorkspaces(workspacesBody);
|
|
964
1041
|
if (wsBlockedEmpty) {
|
|
965
1042
|
// 工作区那份快照不可用:别拿一份「没取到」的工作区去覆盖镜像,只广播清单。
|
|
966
1043
|
recordMirrorPush(false, wsBlockedEmpty);
|
|
@@ -971,18 +1048,12 @@ function createMirrorPusher(deps) {
|
|
|
971
1048
|
kind: 'sync', at: Date.now(),
|
|
972
1049
|
activeSessionId: null,
|
|
973
1050
|
sessions: sessionsBody.body,
|
|
974
|
-
workspaces:
|
|
1051
|
+
workspaces: workspacesBody,
|
|
975
1052
|
messages: {}, stats: {}, models: {},
|
|
976
1053
|
});
|
|
977
1054
|
announceSessionsRevision(revision);
|
|
978
1055
|
return;
|
|
979
1056
|
}
|
|
980
|
-
// 门(见 BG_COLD_ROTATE_MIN_INTERVAL_MS):清单与工作区都还停在中转镜像里那一版、
|
|
981
|
-
// 又不到冷会话轮转时间时,这一轮到此为止 —— 省掉统计/模型投影与一个冷会话的 200 条
|
|
982
|
-
// 正文(那才是这个 tick 的大头)。工作区体提前到这里构建,正是为了拿到它的 revision。
|
|
983
|
-
const workspacesBody = await workspaces.buildWorkspacesBody(ctx).then(observeWorkspaces);
|
|
984
|
-
const workspacesRevision = workspacesBody && typeof workspacesBody.revision === 'string' ? workspacesBody.revision : '';
|
|
985
|
-
const now = Date.now();
|
|
986
1057
|
// 清掉已经不在清单里的会话(归档/删除),免得这张表无限长。
|
|
987
1058
|
const hasPendingRetry = sessionPushFailures.size > 0;
|
|
988
1059
|
if (hasPendingRetry) {
|
|
@@ -1086,10 +1157,10 @@ function createMirrorPusher(deps) {
|
|
|
1086
1157
|
const p = frame?.payload;
|
|
1087
1158
|
const type = typeof frame?.type === 'string' ? frame.type : (p && typeof p.type === 'string' ? p.type : '');
|
|
1088
1159
|
if (!type.startsWith('session/') && !type.startsWith('host/')) continue;
|
|
1089
|
-
if (type.startsWith('host/')) { void pushMirror(); continue; }
|
|
1160
|
+
if (type.startsWith('host/')) { listDirty = true; void pushMirror(); continue; }
|
|
1090
1161
|
// session/event 事件本身就是变更发生,按高优先级立即推送
|
|
1091
1162
|
const sessionId = frame?.sessionId || p?.sessionId;
|
|
1092
|
-
if (!sessionId) { void pushMirror(); continue; }
|
|
1163
|
+
if (!sessionId) { listDirty = true; void pushMirror(); continue; }
|
|
1093
1164
|
// assistant/chunk 是逐块流式增量,一轮生成里可达上千条。镜像只需要粗粒度状态:
|
|
1094
1165
|
// 同一轮收尾时的 assistant/message 会把完整消息带进来,手机侧的实时文本由
|
|
1095
1166
|
// session/stream 的 SSE 负责。不跳的话每条增量都要重建五份全量快照并推一次
|
|
@@ -1099,6 +1170,10 @@ function createMirrorPusher(deps) {
|
|
|
1099
1170
|
// 只认 turn/end,其余事件进来一行就退;它自己吞掉所有异常,不拖这条流。
|
|
1100
1171
|
void observeAutoContinue(ctx, sessionId, p?.event);
|
|
1101
1172
|
if (p?.event?.type === 'assistant/chunk') continue;
|
|
1173
|
+
// 到这里说明这一帧真会改清单行(turn/start、turn/end、session/title、
|
|
1174
|
+
// session/disposed …):给后台 tick 留个「脏」标记,它下一轮才去重扫目录。
|
|
1175
|
+
// 放在 chunk 之后 —— 流式增量只改正文、不改清单,不该把整份清单拖着重扫一遍。
|
|
1176
|
+
listDirty = true;
|
|
1102
1177
|
// iOS 推送:turn/end 是「可能刚收尾」的信号,把事实(lastTurnOf 现读)交给
|
|
1103
1178
|
// 通知器判断——只有 completed / failed 且这一轮之前没推过才会真发一帧。
|
|
1104
1179
|
// 标题从镜像快照现查:中转与苹果都只认纯文本,没查到就用会话 id 前缀。
|
|
@@ -9,9 +9,15 @@
|
|
|
9
9
|
* 一句话分工:headline 是 agent 自己说的(reason / displayReason),事实行是电脑从原始参数
|
|
10
10
|
* 算出来的;删除 / 推送 / 装软件高亮。算不出来就**不出这一行**,绝不糊一句会让用户误判的话。
|
|
11
11
|
*
|
|
12
|
-
* 动作类别键 `classKey`(`<tool>:<class
|
|
12
|
+
* 动作类别键 `classKey`(`<tool>:<class>[@档位]`)既做「这一类以后都同意」的记账键,也做「同一轮
|
|
13
13
|
* 重复请求」的比较键,两处必须用同一份,所以只在这里算一遍。
|
|
14
14
|
*
|
|
15
|
+
* 「以后都同意」的粒度是这里最要紧的一处判断,四条都只认参数本身(`rememberable`):
|
|
16
|
+
* - 删除 / 推送 / 装软件 / 跑第三方包(`isIrreversibleClass`);
|
|
17
|
+
* - 写到**会话工作区之外**(`isWithin`):记 `write:abs` 等于「以后任意路径都能静默改」;
|
|
18
|
+
* - **解析不出内容的壳**:内联执行的代码(`node -e` / `python3 -c`)、带命令替换的 shell;
|
|
19
|
+
* - 只起包装作用的程序先剥掉(`WRAPPERS`),否则记的是 `env` / `timeout` / `xargs` 这类壳。
|
|
20
|
+
*
|
|
15
21
|
* 详见 docs/dev-map / decisions 里这条改动的原因。
|
|
16
22
|
*/
|
|
17
23
|
|
|
@@ -24,6 +30,23 @@ const MAX_CLAUSES = 3;
|
|
|
24
30
|
|
|
25
31
|
/** 删除类程序:高亮。 */
|
|
26
32
|
const DELETE_PROGS = new Set(['rm', 'rmdir', 'unlink', 'shred']);
|
|
33
|
+
/**
|
|
34
|
+
* 只是把后面那条命令包起来、自己不干活的程序:剥掉再判它包的是什么。
|
|
35
|
+
*
|
|
36
|
+
* 不剥的代价很实在:`env A=1 rm -rf x`、`timeout 60 rm -rf x`、`xargs rm -rf` 的类别键会落成
|
|
37
|
+
* `bash:env` / `bash:timeout` / `bash:xargs`,于是「以后都同意 env」等于「以后任意命令静默放行」。
|
|
38
|
+
*/
|
|
39
|
+
const WRAPPERS = new Set(['sudo', 'env', 'nohup', 'nice', 'stdbuf', 'command', 'exec', 'xargs', 'watch', 'time', 'timeout']);
|
|
40
|
+
/** 拿走了第一个参数、其后才是真正命令的那几个(`timeout 60 rm`、`nice -n 10 rm`)。 */
|
|
41
|
+
const WRAPPER_WITH_ARG = new Set(['timeout', 'nice', 'time']);
|
|
42
|
+
/** 包装器的这些选项自带取值:`sudo -u root rm` 里 `root` 是用户名,不是命令。 */
|
|
43
|
+
const OPTS_WITH_VALUE = new Set(['-u', '-g', '-n', '-p', '-C', '-S', '-I', '-L', '-P', '--signal', '--kill-after', '--user', '--group', '-s']);
|
|
44
|
+
/** 跑第三方包的程序:等同于装软件,不给记忆(见 `isIrreversibleClass` 的理由)。 */
|
|
45
|
+
const RUNNER_PROGS = new Set(['npx', 'bunx', 'uvx']);
|
|
46
|
+
/** 内联执行代码的解释器:`node -e …` / `python3 -c …` 看不出来里面干了什么。 */
|
|
47
|
+
const INTERPRETERS = new Set(['node', 'deno', 'bun', 'python', 'python3', 'ruby', 'perl', 'php']);
|
|
48
|
+
/** 记账键里的档位尾巴:只有这两档是真档位,`unknown` 不加(见 `deriveApprovalFacts`)。 */
|
|
49
|
+
const KEY_TIERS = new Set(['workspace-write', 'danger-full-access']);
|
|
27
50
|
/** 包管理器 → 装包动词集合。 */
|
|
28
51
|
const PM_INSTALL = {
|
|
29
52
|
npm: new Set(['install', 'i', 'add']),
|
|
@@ -52,12 +75,13 @@ function baseOf(p) {
|
|
|
52
75
|
return idx >= 0 ? norm.slice(idx + 1) : norm;
|
|
53
76
|
}
|
|
54
77
|
|
|
55
|
-
/** 相对 cwd 的第一段目录;超出 cwd / 取不到就 `abs
|
|
78
|
+
/** 相对 cwd 的第一段目录;超出 cwd / 取不到就 `abs`。相对路径按 cwd 拼出来再判。 */
|
|
56
79
|
function dirKeyOf(p, cwd) {
|
|
57
80
|
if (typeof p !== 'string' || !p) return 'abs';
|
|
58
81
|
if (typeof cwd !== 'string' || !cwd) return 'abs';
|
|
59
|
-
const norm = p.replace(/\\/g, '/');
|
|
60
82
|
const root = cwd.replace(/\\/g, '/').replace(/\/+$/, '');
|
|
83
|
+
let norm = p.replace(/\\/g, '/');
|
|
84
|
+
if (!/^[A-Za-z]:|^\//.test(norm) && !norm.startsWith('~')) norm = `${root}/${norm}`;
|
|
61
85
|
if (!norm.startsWith(`${root}/`)) return 'abs';
|
|
62
86
|
const rel = norm.slice(root.length + 1);
|
|
63
87
|
const seg = rel.split('/')[0];
|
|
@@ -72,6 +96,23 @@ function pathOf(args) {
|
|
|
72
96
|
return '';
|
|
73
97
|
}
|
|
74
98
|
|
|
99
|
+
/**
|
|
100
|
+
* 这个落点是不是「会话工作区里面」。
|
|
101
|
+
*
|
|
102
|
+
* 判不准的一律算外面(不给记忆):`~` 开头的路径本函数不展开,相对路径在没有 cwd 时也说不清
|
|
103
|
+
* —— 把说不清的当里面,等于给了一条能静默改到 `~/.zshrc` 的规则。
|
|
104
|
+
*/
|
|
105
|
+
function isWithin(p, cwd) {
|
|
106
|
+
if (typeof p !== 'string' || !p) return false;
|
|
107
|
+
if (typeof cwd !== 'string' || !cwd) return false;
|
|
108
|
+
if (p.startsWith('~')) return false;
|
|
109
|
+
const norm = p.replace(/\\/g, '/');
|
|
110
|
+
const root = cwd.replace(/\\/g, '/').replace(/\/+$/, '');
|
|
111
|
+
if (/^[A-Za-z]:|^\//.test(norm)) return norm === root || norm.startsWith(`${root}/`);
|
|
112
|
+
// 相对路径:没写 `..` 就算在工作区里(`../x` 或 `a/../../x` 一律当外面)。
|
|
113
|
+
return !/(^|\/)\.\.(\/|$)/.test(norm);
|
|
114
|
+
}
|
|
115
|
+
|
|
75
116
|
/** 把一个目标清单收成「a、b 等 N 个」,最多 `MAX_TARGETS` 个。 */
|
|
76
117
|
function listTargets(names) {
|
|
77
118
|
const clean = names.map((n) => String(n || '').trim()).filter(Boolean);
|
|
@@ -80,7 +121,34 @@ function listTargets(names) {
|
|
|
80
121
|
return `${clean.slice(0, MAX_TARGETS).join('、')} 等 ${clean.length} 个`;
|
|
81
122
|
}
|
|
82
123
|
|
|
83
|
-
/**
|
|
124
|
+
/**
|
|
125
|
+
* 剥掉只起包装作用的程序(`sudo` / `env` / `timeout 60` / `nohup` / `xargs` …),露出真正干活
|
|
126
|
+
* 的那一条。剥不干净的代价见 `WRAPPERS` 的注释:类别键会落在包装器上,「以后都同意 env」等于
|
|
127
|
+
* 「以后任意命令都静默放行」。认不出来的包装器一律不动,宁可少剥一层。
|
|
128
|
+
*/
|
|
129
|
+
function stripWrappers(tokens) {
|
|
130
|
+
let out = tokens;
|
|
131
|
+
for (let guard = 0; guard < 8; guard += 1) {
|
|
132
|
+
if (out.length === 0) return out;
|
|
133
|
+
const prog = baseOf(out[0]);
|
|
134
|
+
if (!WRAPPERS.has(prog)) return out;
|
|
135
|
+
let rest = out.slice(1);
|
|
136
|
+
// 选项连同它的取值一起剥:`sudo -u root cmd`、`nice -n 10 cmd` 里那个词是参数不是命令。
|
|
137
|
+
while (rest.length && rest[0].startsWith('-')) {
|
|
138
|
+
const opt = rest[0];
|
|
139
|
+
rest = rest.slice(1);
|
|
140
|
+
if (OPTS_WITH_VALUE.has(opt) && rest.length) rest = rest.slice(1);
|
|
141
|
+
}
|
|
142
|
+
// `env A=1 cmd`:剥完 `env` 之后还压着一层赋值,继续剥掉。
|
|
143
|
+
while (rest.length && /^[A-Za-z_][A-Za-z0-9_]*=/.test(rest[0])) rest = rest.slice(1);
|
|
144
|
+
// `timeout 60 cmd` / `nice 10 cmd`:包装器自己吃掉一个参数,其后才是命令。
|
|
145
|
+
if (WRAPPER_WITH_ARG.has(prog) && rest.length > 1 && /^[\d.]+[smhd]?$/.test(rest[0])) rest = rest.slice(1);
|
|
146
|
+
out = rest;
|
|
147
|
+
}
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** 按 `&&` `||` `;` `|` 换行切段,剥包装器与 VAR=val 前缀,返回每段的 token 数组。 */
|
|
84
152
|
function splitSegments(command) {
|
|
85
153
|
if (typeof command !== 'string') return [];
|
|
86
154
|
// 先把 sh -c "…" / bash -c "…" 剥一层(常见且便宜)。
|
|
@@ -94,12 +162,7 @@ function splitSegments(command) {
|
|
|
94
162
|
if (!seg) continue;
|
|
95
163
|
// 剥段首赋值 VAR=value
|
|
96
164
|
seg = seg.replace(/^(?:[A-Za-z_][A-Za-z0-9_]*=\S*\s+)+/, '');
|
|
97
|
-
|
|
98
|
-
// 剥 sudo(可能带选项)
|
|
99
|
-
while (tokens[0] === 'sudo') {
|
|
100
|
-
tokens = tokens.slice(1);
|
|
101
|
-
while (tokens.length && tokens[0].startsWith('-')) tokens = tokens.slice(1);
|
|
102
|
-
}
|
|
165
|
+
const tokens = stripWrappers(seg.split(/\s+/).filter(Boolean));
|
|
103
166
|
if (tokens.length === 0) continue;
|
|
104
167
|
out.push(tokens);
|
|
105
168
|
}
|
|
@@ -178,10 +241,11 @@ function clauseOfSegment(tokens) {
|
|
|
178
241
|
return { clause: host ? `连 ${host}` : `跑 ${prog}`, highlight: false, prog };
|
|
179
242
|
}
|
|
180
243
|
|
|
181
|
-
// 重定向写文件(段内出现 > 或
|
|
244
|
+
// 重定向写文件(段内出现 > 或 >>)。写到工作区外与 write 同一口径:句子照旧说,但不给记忆。
|
|
182
245
|
const redirect = tokens.findIndex((t) => t === '>' || t === '>>');
|
|
183
246
|
if (redirect >= 0 && tokens[redirect + 1]) {
|
|
184
|
-
|
|
247
|
+
const target = unquote(tokens[redirect + 1]);
|
|
248
|
+
return { clause: `写 ${baseOf(target)}`, highlight: false, nowhere: !isWithin(target, opts.cwd), prog };
|
|
185
249
|
}
|
|
186
250
|
|
|
187
251
|
// 其它程序
|
|
@@ -228,7 +292,15 @@ function isOpaque(toolName, args) {
|
|
|
228
292
|
return false;
|
|
229
293
|
}
|
|
230
294
|
|
|
231
|
-
/**
|
|
295
|
+
/** 判断一段命令是不是「内联执行代码」:`node -e …` / `python3 -c …` / `<prog> -m …` 之类。 */
|
|
296
|
+
function isInlineCode(tokens) {
|
|
297
|
+
if (!tokens || tokens.length === 0) return false;
|
|
298
|
+
const prog = baseOf(tokens[0] || '');
|
|
299
|
+
if (!INTERPRETERS.has(prog)) return false;
|
|
300
|
+
return tokens.slice(1).some((t) => t === '-e' || t === '--eval' || t === '-c' || t === '-m' || /^-[a-z]*[ecm]$/.test(t));
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/** 单次调用 → `{ clause, highlight, nowhere, classKey }`。 */
|
|
232
304
|
function callToPiece(toolName, args) {
|
|
233
305
|
const name = typeof toolName === 'string' ? toolName : '';
|
|
234
306
|
if (name === 'bash') {
|
|
@@ -238,23 +310,32 @@ function callToPiece(toolName, args) {
|
|
|
238
310
|
if (isOpaque(name, args)) {
|
|
239
311
|
const segs = splitSegments(args.command);
|
|
240
312
|
const prog = segs.length ? baseOf(segs[0][0] || '') : 'bash';
|
|
241
|
-
|
|
313
|
+
// 解析不出来的壳不给记忆:`node -e` / `python3 -c` 里面能写任何东西,记成「以后同意 node」
|
|
314
|
+
// 就是「以后任意脚本静默放行」。
|
|
315
|
+
return { clause: `跑 ${prog}(内容无法静态解析)`, highlight: false, nowhere: true, classKey: `bash:${prog}` };
|
|
242
316
|
}
|
|
243
317
|
const segs = splitSegments(args.command);
|
|
244
318
|
const clauses = [];
|
|
245
319
|
let highlight = false;
|
|
320
|
+
let nowhere = false;
|
|
246
321
|
for (const tokens of segs) {
|
|
322
|
+
// 段内联执行代码(`python3 -c "…"`):整张卡不给记忆,理由同上面的 `isOpaque`。
|
|
323
|
+
if (isInlineCode(tokens)) nowhere = true;
|
|
247
324
|
const piece = clauseOfSegment(tokens);
|
|
248
325
|
if (!piece) continue;
|
|
249
326
|
if (piece.clause) clauses.push(piece.clause);
|
|
250
327
|
if (piece.highlight) highlight = true;
|
|
328
|
+
if (piece.nowhere) nowhere = true;
|
|
251
329
|
}
|
|
252
|
-
return { clause: clauses.join(';'), highlight, classKey: bashClassKey(args.command) };
|
|
330
|
+
return { clause: clauses.join(';'), highlight, nowhere, classKey: bashClassKey(args.command) };
|
|
253
331
|
}
|
|
254
332
|
|
|
255
333
|
if (name === 'write' || name === 'edit') {
|
|
256
334
|
const p = pathOf(args);
|
|
257
335
|
if (!p) return { clause: '', highlight: false, classKey: `tool:${name}` };
|
|
336
|
+
// 工作区外一律不给记忆(`nowhere` 只管「能不能记」,不改这一行的颜色):写 `~/.zshrc`、
|
|
337
|
+
// `~/.ssh/authorized_keys`、开机启动项都是这一类,而用户点头时想的是「工作区里改文件」。
|
|
338
|
+
if (!isWithin(p, opts.cwd)) return { clause: `改 ${baseOf(p)}`, highlight: false, nowhere: true, classKey: `${name}:abs` };
|
|
258
339
|
const d = dirKeyOf(p, opts.cwd);
|
|
259
340
|
return { clause: `改 ${baseOf(p)}`, highlight: false, classKey: `${name}:${d}` };
|
|
260
341
|
}
|
|
@@ -288,17 +369,18 @@ function callToPiece(toolName, args) {
|
|
|
288
369
|
|
|
289
370
|
/** 危险度排序,用于多调用聚合时取「最危险那条」做 classKey。 */
|
|
290
371
|
function dangerRank(classKey) {
|
|
291
|
-
|
|
292
|
-
if (
|
|
293
|
-
if (
|
|
294
|
-
if (
|
|
295
|
-
if (/^
|
|
372
|
+
const key = String(classKey || '').replace(/@(?:workspace-write|danger-full-access|unknown)$/, '');
|
|
373
|
+
if (/^(bash:rm|bash:rmdir|bash:unlink|bash:shred)$/.test(key)) return 5;
|
|
374
|
+
if (key === 'bash:git:push' || key === 'bash:git:reset' || key === 'bash:git:clean') return 5;
|
|
375
|
+
if (INSTALL_MANAGERS.has((key.split(':')[1] || '').split(':')[0]) && /install|add|:i$/.test(key)) return 4;
|
|
376
|
+
if (/^(write|edit):/.test(key)) return 3;
|
|
377
|
+
if (/^read:/.test(key)) return 2;
|
|
296
378
|
return 1;
|
|
297
379
|
}
|
|
298
380
|
|
|
299
|
-
/** 把 classKey 翻成给人看的一句(撤销页 /
|
|
381
|
+
/** 把 classKey 翻成给人看的一句(撤销页 / 按钮用)。档位尾巴只进键,不进这句人话。 */
|
|
300
382
|
function labelOf(classKey) {
|
|
301
|
-
const parts = String(classKey || '').split(':');
|
|
383
|
+
const parts = String(classKey || '').replace(/@(?:workspace-write|danger-full-access|unknown)$/, '').split(':');
|
|
302
384
|
const tool = parts[0];
|
|
303
385
|
if (tool === 'bash') {
|
|
304
386
|
if (parts[1] === 'git' && parts[2]) {
|
|
@@ -338,6 +420,8 @@ function deriveApprovalFacts(calls, options) {
|
|
|
338
420
|
const nonEmpty = pieces.filter((p) => p.clause);
|
|
339
421
|
const joined = nonEmpty.map((p) => p.clause).slice(0, MAX_CLAUSES).join(';');
|
|
340
422
|
const highlight = pieces.some((p) => p.highlight);
|
|
423
|
+
/** 有一处写到了工作区外 / 是解析不出内容的壳:整张卡不给「以后都同意」。 */
|
|
424
|
+
const nowhere = pieces.some((p) => p.nowhere);
|
|
341
425
|
let fact = joined;
|
|
342
426
|
if (fact.length > FACT_MAX) {
|
|
343
427
|
// 先保数量与动词、再保目标名:若带「等 N 个」,保住这段后缀,只截前面的目标清单。
|
|
@@ -358,7 +442,12 @@ function deriveApprovalFacts(calls, options) {
|
|
|
358
442
|
}
|
|
359
443
|
// 高亮是同一份解析给出的第二个信号:删除 / 推送 / reset / clean / 装包只在这几处点亮
|
|
360
444
|
// (见 `clauseOfSegment`)。组合命令的类别键容易把危险那一段藏进 `a+b`,两条一起看才不漏。
|
|
361
|
-
|
|
445
|
+
// `nowhere` 是第三个信号:写到了工作区外面(含重定向),那类不给记忆,理由见 `callToPiece`。
|
|
446
|
+
let rememberable = isRememberable(classKey) && !highlight && !nowhere;
|
|
447
|
+
// 档位尾巴:`workspace-write` 与 `danger-full-access` 下的同名动作不是同一条授权 —— 「以后
|
|
448
|
+
// 都同意在工作区里改文件」不该把「升到完全访问」也一起放行。记在键里,换档后重新弹卡;
|
|
449
|
+
// 档位认不出(`unknown`)就不加尾巴,那种键只和同样认不出档位的请求互相匹配。
|
|
450
|
+
if (rememberable && KEY_TIERS.has(opts.tier)) classKey = `${classKey}@${opts.tier}`;
|
|
362
451
|
return {
|
|
363
452
|
fact,
|
|
364
453
|
highlight,
|
|
@@ -381,7 +470,8 @@ function deriveApprovalFacts(calls, options) {
|
|
|
381
470
|
* 宁可多推一张卡。
|
|
382
471
|
*/
|
|
383
472
|
function isIrreversibleClass(classKey) {
|
|
384
|
-
|
|
473
|
+
// 记账键可能带档位尾巴(`bash:git:push@danger-full-access`),先剥掉再判。
|
|
474
|
+
const key = String(classKey || '').replace(/@(?:workspace-write|danger-full-access|unknown)$/, '');
|
|
385
475
|
if (!key) return false;
|
|
386
476
|
// `git rm` 也是删文件(只是经过了 git),`git push/reset/clean` 会动远端或不可恢复。
|
|
387
477
|
if (key === 'bash:git:push' || key === 'bash:git:reset' || key === 'bash:git:clean' || key === 'bash:git:rm') return true;
|
|
@@ -392,6 +482,8 @@ function isIrreversibleClass(classKey) {
|
|
|
392
482
|
if (!prog) continue;
|
|
393
483
|
if (DELETE_PROGS.has(prog)) return true;
|
|
394
484
|
if (INSTALL_MANAGERS.has(prog) && PM_INSTALL[prog].has(String(verb || '').toLowerCase())) return true;
|
|
485
|
+
// `npx 某个包`:跑的就是刚装下来的第三方包,与装软件同一条理由。
|
|
486
|
+
if (RUNNER_PROGS.has(prog)) return true;
|
|
395
487
|
}
|
|
396
488
|
return false;
|
|
397
489
|
}
|
|
@@ -44,6 +44,7 @@ const {
|
|
|
44
44
|
toolStepSummary,
|
|
45
45
|
toolStepState,
|
|
46
46
|
} = require('./step-index.js');
|
|
47
|
+
const { deriveWorkflowRuns } = require('./workflow-runs.js');
|
|
47
48
|
|
|
48
49
|
/**
|
|
49
50
|
* 从 session.list 摘要行取会话标题(与桌面端侧栏同源,不再从 history 窗口猜):
|
|
@@ -307,13 +308,13 @@ function blocksToText(blocks) {
|
|
|
307
308
|
/**
|
|
308
309
|
* 照片说明行的哨兵(U+2063 INVISIBLE SEPARATOR)。
|
|
309
310
|
*
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
* 用户看到的是「我发的消息自己变长了」。
|
|
311
|
+
* **只服务老消息**:早先版本发送时会在图片块之后追加一个 text 块告诉模型「这张是什么时候
|
|
312
|
+
* 拍的、多大」(现在不这么发了)。那些消息的 content 里还留着那一行,而 `blocksToText` 把
|
|
313
|
+
* 所有 text 块用换行拼成用户消息的展示文本,重进会话 / 断线补齐时用户气泡里就会凭空长出一行
|
|
314
|
+
* 「[照片 …]」—— 用户看到的是「我发的消息自己变长了」。
|
|
314
315
|
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
316
|
+
* 当年那一行带了这个不可见前缀,这里在**算用户消息的展示文本时**把带它的整行去掉。字面量与
|
|
317
|
+
* 语义的单一来源是 `app/src/services/viewmodels/photo-caption.ts` 的
|
|
317
318
|
* `PHOTO_CAPTION_SENTINEL`(那边定义了常量与剥离函数,这里只出现同一个字符)。
|
|
318
319
|
*
|
|
319
320
|
* **为什么剥在插件而不是 App**:历史正文是这里拼的,App 拿到的 `item.text` 只是展示出口;
|
|
@@ -523,8 +524,7 @@ function deriveMessages(events, sessionId, lookbackEvents) {
|
|
|
523
524
|
// 预扫描 tool/result 事件(同批次事件内,结果可能在调用块之前/之后出现)。
|
|
524
525
|
// `lookbackEvents` 是这一页**再往前**的一小段:倒着分页时工具结果常常落在比消息更早的位置
|
|
525
526
|
// (一轮里先跑工具、最后才写正文),只看这一页就看不出这一轮出过哪些图。
|
|
526
|
-
const toolResults = buildToolResultMap(lookbackEvents && lookbackEvents.length ? events.concat(lookbackEvents) : events);
|
|
527
|
-
// 倒着分页时,一页的边界可能正好切在「工具调用」与「它的结果」之间:这一页只有调用,
|
|
527
|
+
const toolResults = buildToolResultMap(lookbackEvents && lookbackEvents.length ? events.concat(lookbackEvents) : events); // 倒着分页时,一页的边界可能正好切在「工具调用」与「它的结果」之间:这一页只有调用,
|
|
528
528
|
// 结果在更新的一页(本机早就拿到过)。把那些记在进程里的结果并进来,图就跟着消息一起
|
|
529
529
|
// 下发,手机侧那一行在挂载那一帧就是终高(见 tool-result-cache.js)。
|
|
530
530
|
const remembered = toolResultsFor(sessionId);
|
|
@@ -670,6 +670,13 @@ function deriveMessages(events, sessionId, lookbackEvents) {
|
|
|
670
670
|
*/
|
|
671
671
|
const stepsByTurn = new Map();
|
|
672
672
|
const openerByTurn = new Map();
|
|
673
|
+
/**
|
|
674
|
+
* 工作流那四类事件(`tool-workflow/*`)原样攒着,最后交给 `workflow-runs.js` 折成树。
|
|
675
|
+
*
|
|
676
|
+
* 不在主循环里就地折:一次运行的数据横跨四条事件、还要看「开启它的那一轮有没有被中断」,
|
|
677
|
+
* 那些判据只有整窗看完才成立。攒的时候连 seq 一起留(要按位置归轮)。
|
|
678
|
+
*/
|
|
679
|
+
const workflowEntries = [];
|
|
673
680
|
let lastOpener = null;
|
|
674
681
|
const collectSteps = (content, e) => {
|
|
675
682
|
if (!Array.isArray(content)) return;
|
|
@@ -842,6 +849,11 @@ function deriveMessages(events, sessionId, lookbackEvents) {
|
|
|
842
849
|
const e = entry.event || entry;
|
|
843
850
|
const seq = e.seq;
|
|
844
851
|
const time = e.time;
|
|
852
|
+
// 工作流那四类事件不在这里就地折:攒起来整窗看(见 `workflowEntries`)。
|
|
853
|
+
if (typeof e.type === 'string' && e.type.startsWith('tool-workflow/')) {
|
|
854
|
+
workflowEntries.push(entry.event ? entry : { event: e });
|
|
855
|
+
continue;
|
|
856
|
+
}
|
|
845
857
|
if (e.type === 'user/message' && e.data) {
|
|
846
858
|
const msg = e.data;
|
|
847
859
|
const src = msg.source;
|
|
@@ -1173,9 +1185,38 @@ function deriveMessages(events, sessionId, lookbackEvents) {
|
|
|
1173
1185
|
for (const item of out) {
|
|
1174
1186
|
if (item.kind === 'compaction' && typeof item.text !== 'string') item.text = '';
|
|
1175
1187
|
}
|
|
1188
|
+
// 工作流运行:`tool-workflow/*` 折成「运行 → 阶段 → 成员」三层(形状与桌面 `workflow-run`
|
|
1189
|
+
// 节点一致,见 `workflow-runs.js`)。这些事件原先整族没人认、手机上一张卡都不出现。
|
|
1190
|
+
//
|
|
1191
|
+
// 「被撇下」按**开启这次运行的那一轮**判:历史窗口里可能横跨好几轮,只有那一轮是被中断 /
|
|
1192
|
+
// 分叉的,这条运行才再也不会长(桌面的 `turnAbandoned` 读的正是 run-start 所在那一轮的
|
|
1193
|
+
// `turn.end.reason`)。所以逐条给 runId,不能整批按「当前这一轮」算。
|
|
1194
|
+
if (workflowEntries.length > 0) {
|
|
1195
|
+
const abandonedTurns = new Set();
|
|
1196
|
+
for (const entry of events) {
|
|
1197
|
+
const e = entry.event || entry;
|
|
1198
|
+
if (!e || e.type !== 'turn/end' || !e.data || typeof e.data.turn !== 'number') continue;
|
|
1199
|
+
const reason = e.data.reason && e.data.reason.kind;
|
|
1200
|
+
if (reason === 'interrupted' || reason === 'forked') abandonedTurns.add(e.data.turn);
|
|
1201
|
+
}
|
|
1202
|
+
const abandonedRunIds = [];
|
|
1203
|
+
if (abandonedTurns.size > 0) {
|
|
1204
|
+
for (const entry of events) {
|
|
1205
|
+
const e = entry.event || entry;
|
|
1206
|
+
if (!e || e.type !== 'tool-workflow/run-start' || !e.data) continue;
|
|
1207
|
+
const turn = turnOfSeq(e.seq, turnIndex.bySeq, turnIndex.starts);
|
|
1208
|
+
if (turn !== null && abandonedTurns.has(turn) && e.data.runId !== undefined) {
|
|
1209
|
+
abandonedRunIds.push(String(e.data.runId));
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
const workflowRows = abandonedRunIds.length > 0
|
|
1214
|
+
? deriveWorkflowRuns(workflowEntries, { abandonedRunIds })
|
|
1215
|
+
: deriveWorkflowRuns(workflowEntries);
|
|
1216
|
+
for (const row of workflowRows) out.push(row);
|
|
1217
|
+
}
|
|
1176
1218
|
// 严格按事件 seq 升序(与消息混排;compaction 行升级/替换后位置以最终事件为准)。
|
|
1177
|
-
out.sort((a, b) => (a.seq ?? 0) - (b.seq ?? 0));
|
|
1178
|
-
// 存进缓存的是**已经排好序的最终结果**:调用方拿到的是同一份引用,拿去 filter / map 都好,
|
|
1219
|
+
out.sort((a, b) => (a.seq ?? 0) - (b.seq ?? 0)); // 存进缓存的是**已经排好序的最终结果**:调用方拿到的是同一份引用,拿去 filter / map 都好,
|
|
1179
1220
|
// 但不要再就地改(要改就先拷一份)。见 shared/derived-cache.js 的说明。
|
|
1180
1221
|
if (cacheKey) derivedCache.set(sessionId, cacheKey, out);
|
|
1181
1222
|
return out;
|
|
@@ -240,8 +240,8 @@ function turnMetaOf(events, turn) {
|
|
|
240
240
|
if (event.type === 'turn/start' && typeof event.time === 'number') startedAt = event.time;
|
|
241
241
|
if (event.type === 'user/message') {
|
|
242
242
|
const content = event.data && Array.isArray(event.data.content) ? event.data.content : [];
|
|
243
|
-
// 轮标题取的是「用户说了什么」:用 `userVisibleText` 而不是裸 `blocksToText` ——
|
|
244
|
-
//
|
|
243
|
+
// 轮标题取的是「用户说了什么」:用 `userVisibleText` 而不是裸 `blocksToText` —— 老消息里
|
|
244
|
+
// 留下的照片说明行(现在不再发,哨兵见 `app/src/services/viewmodels/photo-caption.ts`)
|
|
245
245
|
// 混进标题就是时间线上一行「[照片 …]」,而用户其实什么都没写。
|
|
246
246
|
const text = userVisibleText(parseBlocks(content, toolResults)).trim();
|
|
247
247
|
if (text !== '' && title === '') title = text.length > 120 ? `${text.slice(0, 119)}…` : text;
|
|
@@ -65,6 +65,11 @@ const liveStepWriters = new WeakMap();
|
|
|
65
65
|
// 的 attachLiveSteps / broadcastLiveSteps)。
|
|
66
66
|
const liveStepSinks = new WeakMap();
|
|
67
67
|
|
|
68
|
+
// 直播中的工作流运行:这一轮收到的 `tool-workflow/*` 事件攒成一份、折成运行→阶段→成员
|
|
69
|
+
// (见 workflow-live.js)。与上面的直播过程副本同一类状态:属于宿主进程里「这一轮跑到哪」,
|
|
70
|
+
// 所以按 ctx 隔离、按会话分桶。
|
|
71
|
+
const workflowLiveStates = new WeakMap();
|
|
72
|
+
|
|
68
73
|
// 隔离工作树的自动回收节流(见 worktree-lifecycle.js):上次跑的时刻与在途标记。
|
|
69
74
|
// 收尾那一发挂在会话列表刷新上,是热点路径 —— 每台宿主各一份,不能跨 ctx 串。
|
|
70
75
|
const isolationSweepStates = new WeakMap();
|
|
@@ -492,11 +497,22 @@ function liveStepSinkOf(ctx) {
|
|
|
492
497
|
return state;
|
|
493
498
|
}
|
|
494
499
|
|
|
500
|
+
/** 直播中的工作流运行:`ctx → Map<sessionId, { entries, runs }>`(见 workflow-live.js)。 */
|
|
501
|
+
function workflowLiveOf(ctx) {
|
|
502
|
+
let state = workflowLiveStates.get(ctx);
|
|
503
|
+
if (!state) {
|
|
504
|
+
state = new Map();
|
|
505
|
+
workflowLiveStates.set(ctx, state);
|
|
506
|
+
}
|
|
507
|
+
return state;
|
|
508
|
+
}
|
|
509
|
+
|
|
495
510
|
module.exports = {
|
|
496
511
|
canonicalDeviceKey,
|
|
497
512
|
liveStepTurnOf,
|
|
498
513
|
liveStepWriterOf,
|
|
499
514
|
liveStepSinkOf,
|
|
515
|
+
workflowLiveOf,
|
|
500
516
|
sessionModelsStateOf,
|
|
501
517
|
invalidateSessionModels,
|
|
502
518
|
dropSessionModelsForDevice,
|