@zhushanwen/subagent-core 0.7.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-VURUAGMM.js → chunk-LZJOEDGQ.js} +603 -154
- package/dist/engine-discovery-scan-Da4Dkzsi.d.cts +818 -0
- package/dist/engine-discovery-scan-Da4Dkzsi.d.ts +818 -0
- package/dist/execution/engine/engine-discovery-scan.cjs +325 -154
- package/dist/execution/engine/engine-discovery-scan.d.cts +1 -2
- package/dist/execution/engine/engine-discovery-scan.d.ts +1 -2
- package/dist/execution/engine/engine-discovery-scan.js +1 -1
- package/dist/execution/relay-env.js +5 -4
- package/dist/index.cjs +9799 -7954
- package/dist/index.d.cts +1896 -1360
- package/dist/index.d.ts +1896 -1360
- package/dist/index.js +8952 -7513
- package/dist.bundle/index.cjs +7897 -6054
- package/package.json +5 -5
- package/src/__tests__/manifest-store.test.ts +16 -15
- package/src/__tests__/record-store-last-line.test.ts +12 -0
- package/src/__tests__/robustness-medium-batch1.test.ts +10 -14
- package/src/__tests__/robustness-medium-batch2.test.ts +7 -2
- package/src/core/logger.ts +1 -1
- package/src/execution/__tests__/alive-store.test.ts +117 -1
- package/src/execution/__tests__/batch-finalized.test.ts +206 -0
- package/src/execution/__tests__/chat-engine-routing.test.ts +117 -1
- package/src/execution/__tests__/{cold-resurrect.test.ts → cold-lookup.test.ts} +133 -33
- package/src/execution/__tests__/collect-coordinator-service.test.ts +7 -5
- package/src/execution/__tests__/conversation-continuation.test.ts +1452 -0
- package/src/execution/__tests__/delivery-methods.test.ts +90 -176
- package/src/execution/__tests__/dialog-queue.test.ts +70 -3
- package/src/execution/__tests__/dispose-manifest-recovery.test.ts +475 -0
- package/src/execution/__tests__/execute-and-await-worktree.test.ts +3 -3
- package/src/execution/__tests__/execute-nesting.test.ts +8 -5
- package/src/execution/__tests__/execution-record.test.ts +8 -148
- package/src/execution/__tests__/finalize-record.test.ts +295 -129
- package/src/execution/__tests__/get-record-for-action-restart.test.ts +21 -29
- package/src/execution/__tests__/helpers/fake-engine-port.ts +13 -68
- package/src/execution/__tests__/helpers/legacy-sidecar.ts +33 -0
- package/src/execution/__tests__/helpers/subagent-service-mocks.ts +9 -5
- package/src/execution/__tests__/idle-gc.test.ts +60 -0
- package/src/execution/__tests__/inflight-production-wiring.test.ts +223 -0
- package/src/execution/__tests__/lifecycle-manager.test.ts +3 -254
- package/src/execution/__tests__/manifest-store-tmp-recovery.test.ts +43 -22
- package/src/execution/__tests__/model-config-service.test.ts +111 -0
- package/src/execution/__tests__/nested-visibility-env-propagation.test.ts +10 -6
- package/src/execution/__tests__/nested-visibility.test.ts +13 -1
- package/src/execution/__tests__/notify-ledger.test.ts +42 -1
- package/src/execution/__tests__/rebuild-indexes.test.ts +329 -0
- package/src/execution/__tests__/record-binding.test.ts +613 -0
- package/src/execution/__tests__/record-origin.test.ts +318 -0
- package/src/execution/__tests__/record-store-intent-api.test.ts +600 -0
- package/src/execution/__tests__/record-store-orphan-revive.test.ts +71 -3
- package/src/execution/__tests__/record-store.test.ts +72 -54
- package/src/execution/__tests__/recursive-visibility-baseline.test.ts +8 -5
- package/src/execution/__tests__/round-supervisor-workflow-origin.test.ts +205 -0
- package/src/execution/__tests__/run-orchestration-write-lease.test.ts +293 -0
- package/src/execution/__tests__/run-orchestration.test.ts +199 -0
- package/src/execution/__tests__/session-file-gc.test.ts +35 -4
- package/src/execution/__tests__/session-reconstructor.test.ts +78 -0
- package/src/execution/__tests__/state-marker.test.ts +288 -0
- package/src/execution/__tests__/stream-sink-retirement.test.ts +8 -5
- package/src/execution/__tests__/subagent-actions-core.test.ts +67 -16
- package/src/execution/__tests__/subagent-service-multiproc-guard.test.ts +0 -1
- package/src/execution/__tests__/subagent-service-notify-gate.test.ts +27 -11
- package/src/execution/__tests__/subagent-service-parent-guard.test.ts +17 -11
- package/src/execution/__tests__/subagent-service-recovery-bounds.test.ts +130 -53
- package/src/execution/__tests__/subagent-service.test.ts +17 -215
- package/src/execution/__tests__/subprocess-agent-runner-no-progress-killall.test.ts +138 -0
- package/src/execution/__tests__/subprocess-agent-runner.test.ts +105 -660
- package/src/execution/__tests__/sync-collect-recovery.test.ts +23 -16
- package/src/execution/__tests__/terminal-write-latency.test.ts +79 -0
- package/src/execution/__tests__/workflow-agent-dispatch.test.ts +782 -0
- package/src/execution/alive-store.ts +37 -28
- package/src/execution/{cold-resurrect.ts → cold-lookup.ts} +48 -45
- package/src/execution/config.ts +1 -1
- package/src/execution/conversation-continuation.ts +541 -0
- package/src/execution/dialog-queue.ts +60 -12
- package/src/execution/engine/__tests__/common/capability-gate.test.ts +1 -1
- package/src/execution/engine/__tests__/common/journal-wiring.test.ts +16 -1
- package/src/execution/engine/__tests__/conformance/__fixtures__/engine-protocol/fake-engine-protocol.mjs +17 -51
- package/src/execution/engine/__tests__/conformance/__fixtures__/engine-protocol/smoke-run.fixture.json +0 -5
- package/src/execution/engine/__tests__/conformance/engine-conformance.live.test.ts +1 -1
- package/src/execution/engine/__tests__/conformance/protocol-blackbox.test.ts +5 -9
- package/src/execution/engine/__tests__/conformance/registry-fork-filter.test.ts +55 -53
- package/src/execution/engine/__tests__/engine-discovery-scan.test.ts +0 -3
- package/src/execution/engine/__tests__/engine-discovery.test.ts +0 -3
- package/src/execution/engine/__tests__/inflight-snapshot.test.ts +180 -0
- package/src/execution/engine/__tests__/model-prompt.test.ts +0 -3
- package/src/execution/engine/__tests__/registry.test.ts +0 -1
- package/src/execution/engine/__tests__/routing.test.ts +0 -1
- package/src/execution/engine/__tests__/run-failure-worktree-cleanup.test.ts +0 -3
- package/src/execution/engine/client/__tests__/__fixtures__/fake-engine.mjs +0 -3
- package/src/execution/engine/client/__tests__/engine-client-reap.test.ts +212 -0
- package/src/execution/engine/client/__tests__/mirror.test.ts +73 -1
- package/src/execution/engine/client/__tests__/protocol-closure.test.ts +2 -9
- package/src/execution/engine/client/__tests__/remote-engine.test.ts +46 -12
- package/src/execution/engine/client/engine-client.ts +111 -26
- package/src/execution/engine/client/mirror.ts +9 -0
- package/src/execution/engine/client/remote-engine.ts +52 -34
- package/src/execution/engine/client/reverse-router.ts +6 -27
- package/src/execution/engine/common/__tests__/run-signals.test.ts +79 -0
- package/src/execution/engine/common/capability-gate.ts +27 -0
- package/src/execution/engine/common/data-dir.ts +3 -2
- package/src/execution/engine/common/errors.ts +1 -1
- package/src/execution/engine/common/journal-wiring.ts +18 -9
- package/src/execution/engine/common/run-signals.ts +83 -0
- package/src/execution/engine/d8-compat.ts +1 -1
- package/src/execution/engine/host/__tests__/host-bridge.test.ts +3 -18
- package/src/execution/engine/host/host-bridge.ts +26 -41
- package/src/execution/engine/host/pi-host-binding.ts +5 -5
- package/src/execution/engine/host/spawned-children.ts +1 -1
- package/src/execution/engine/inflight-snapshot.ts +92 -0
- package/src/execution/engine/port.ts +52 -54
- package/src/execution/engine/types.ts +11 -14
- package/src/execution/execution-record.ts +15 -47
- package/src/execution/finalize-record.ts +94 -197
- package/src/execution/idle-gc.ts +9 -3
- package/src/execution/lifecycle-manager.ts +25 -361
- package/src/execution/lifecycle-predicates.ts +22 -19
- package/src/execution/manifest-store.ts +40 -42
- package/src/execution/model-config-service.ts +1 -1
- package/src/execution/notifier.ts +39 -1
- package/src/execution/notify-host.ts +13 -4
- package/src/execution/path-encoding.ts +6 -0
- package/src/execution/record-entry.ts +20 -2
- package/src/execution/record-store.ts +925 -160
- package/src/execution/relay-env.ts +8 -3
- package/src/execution/round-supervisor/domain.ts +17 -5
- package/src/execution/round-supervisor/service-binding.test.ts +89 -53
- package/src/execution/round-supervisor/service-binding.ts +71 -21
- package/src/execution/round-supervisor/supervisor.ts +23 -9
- package/src/execution/service/record-access.ts +547 -0
- package/src/execution/service/record-lifecycle.ts +542 -0
- package/src/execution/service/run-orchestration.ts +1647 -0
- package/src/execution/service/service-bootstrap.ts +111 -0
- package/src/execution/service/service-constants.ts +27 -0
- package/src/execution/service/session-baselines.ts +401 -0
- package/src/execution/service/sync-collect-domain.ts +442 -0
- package/src/execution/service/workflow-dispatch.ts +567 -0
- package/src/execution/session-file-gc.ts +11 -8
- package/src/execution/session-reconstructor.ts +44 -1
- package/src/execution/sessions-index.ts +20 -3
- package/src/execution/settled-watchdog.ts +86 -43
- package/src/execution/state-marker.ts +516 -0
- package/src/execution/stream-sink.ts +1 -1
- package/src/execution/subagent-actions-core.ts +53 -31
- package/src/execution/subagent-service.ts +643 -2955
- package/src/execution/subprocess-agent-runner.ts +46 -323
- package/src/execution/types.ts +60 -43
- package/src/execution/ui-request-handler-factory.ts +5 -0
- package/src/execution/worktree-manager.ts +1 -1
- package/src/execution/worktree-registry.ts +12 -8
- package/src/index.ts +16 -5
- package/src/orchestration/__tests__/agent-call-catch-fallback.test.ts +2 -3
- package/src/orchestration/__tests__/agent-call-stream.test.ts +24 -49
- package/src/orchestration/__tests__/error-recovery-terminal-hardening.test.ts +4 -4
- package/src/orchestration/__tests__/file-run-store.test.ts +5 -7
- package/src/orchestration/__tests__/lifecycle-abort-broadcast-signal.test.ts +2 -3
- package/src/orchestration/__tests__/run-snapshot.test.ts +27 -43
- package/src/orchestration/__tests__/worker-message-pump-workflow-dispatch.test.ts +274 -0
- package/src/orchestration/execute-agent-call.ts +1 -1
- package/src/orchestration/file-run-store.ts +1 -1
- package/src/orchestration/models/ports.ts +20 -13
- package/src/orchestration/models/types.ts +11 -13
- package/src/orchestration/run-snapshot.ts +18 -22
- package/src/orchestration/worker-message-pump.ts +33 -57
- package/src/shared/atomic-write.ts +10 -8
- package/dist/chunk-T2SYBW3I.js +0 -24
- package/dist/engine-discovery-scan-ocpM8FmI.d.cts +0 -1608
- package/dist/engine-discovery-scan-ocpM8FmI.d.ts +0 -1608
- package/src/execution/__tests__/chat-round-first-round-watchdog.test.ts +0 -255
- package/src/execution/__tests__/finalized-marker.test.ts +0 -104
- package/src/execution/__tests__/lifecycle-manager-lock.test.ts +0 -211
- package/src/execution/__tests__/subprocess-agent-runner-routing.test.ts +0 -488
- package/src/execution/__tests__/subprocess-agent-runner-timeout.test.ts +0 -75
- package/src/execution/__tests__/tombstone-store.test.ts +0 -73
- package/src/execution/engine/__tests__/conformance/chat-round-protocol.test.ts +0 -230
- package/src/execution/finalized-marker.ts +0 -70
- package/src/execution/tombstone-store.ts +0 -72
|
@@ -28,6 +28,33 @@ import { deriveOutcome } from "./execution-record.ts";
|
|
|
28
28
|
import { getBoundNotifyLedger, NOTIFY_CUSTOM_TYPE } from "./notify-ledger.ts";
|
|
29
29
|
import type { ClosedReason, ExecutionOutcome } from "./types.ts";
|
|
30
30
|
|
|
31
|
+
// ============================================================
|
|
32
|
+
// [T4① / PS-2] notify 门(H1 U2 自 subagent-service.ts 迁入——Continuation
|
|
33
|
+
// 成功/失败分支双闸共用;原位置 re-export 保持既有 import 路径不变)
|
|
34
|
+
// ============================================================
|
|
35
|
+
|
|
36
|
+
/** notify 门拦截集:disposeAllRecords 因这两类原因关闭的 record,其迟到的
|
|
37
|
+
* 轮次完成回注不得注入新 session——/new、/fork 的决策([v4 A-6])
|
|
38
|
+
* 是「被关 record 的告知改由 list 的 closedReason 表达」,不主动通知;旧门只排除
|
|
39
|
+
* cancelled,parent-new/parent-fork 放行 → 新对话被「Subagent X failed: closed due to
|
|
40
|
+
* parent-new」的僵尸回执 triggerTurn 唤醒,已废弃会话的通知注入新上下文。 */
|
|
41
|
+
const NOTIFY_BLOCKED_CLOSED_REASONS: ReadonlySet<ClosedReason> = new Set(["parent-new", "parent-fork"]);
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* [T4① / PS-2] 轮次完成回注的 notify 门(按 closedReason 白名单放行)。
|
|
45
|
+
*
|
|
46
|
+
* cancelled(cancelBackground 自己 notify)与 parent-new/parent-fork(编排性关闭,
|
|
47
|
+
* 告知由 list 的 closedReason 表达)不放行;其余(undefined = 本路径抢到 CAS 尚未
|
|
48
|
+
* 终态化的迟到回调、user-close/gc 等真实终态)照旧回注。导出供测试与调用点复用。
|
|
49
|
+
* [H1 U2] 消费面扩为三处:Continuation 成功分支(route 前)、失败分支(独立载荷
|
|
50
|
+
* 发出前,B#19 投递门照迁移)、泛化派发主干尾部(one-shot 回注,现状不变)。
|
|
51
|
+
*/
|
|
52
|
+
export function notifyGateAllowsDelivery(closedReason: ClosedReason | undefined): boolean {
|
|
53
|
+
if (closedReason === undefined) return true;
|
|
54
|
+
if (closedReason === "cancelled") return false;
|
|
55
|
+
return !NOTIFY_BLOCKED_CLOSED_REASONS.has(closedReason);
|
|
56
|
+
}
|
|
57
|
+
|
|
31
58
|
/** U4:delivery warn 出口注入用——facade 同 component 同引用,与 index.ts 的
|
|
32
59
|
* getLogger("subagents") 共享单例;configureCore 后透明切换到宿主实现。 */
|
|
33
60
|
const notifyLogger = getLogger("subagents");
|
|
@@ -78,6 +105,14 @@ export interface BgNotifyRecord {
|
|
|
78
105
|
* 回执匹配 / 幂等去重共用——details 携带(不进文案,G4 字节锁定不受影响),
|
|
79
106
|
* 重复注入条目凭此可识别为同一条(G2 at-least-once 幂等键)。 */
|
|
80
107
|
notifyId?: string;
|
|
108
|
+
/**
|
|
109
|
+
* [drain-drop 修复] notifyId 构造的显式覆盖(notify() 优先消费;缺省 = 既有
|
|
110
|
+
* `id` / `id:round` 语义零变化)。供「同轮先导通知与派生通知必须区分」的场景使用:
|
|
111
|
+
* 现行唯一消费方 = drain 队列丢弃通知(`${id}:${round}:drain-drop`)——同轮
|
|
112
|
+
* settleRoundFailed 失败通知缺省 key 为 `id:round`,丢弃通知若沿用同 key 会被
|
|
113
|
+
* ledger/内核按 key 永久去重吞掉(「队列消息被丢」的显式反馈永不可达)。
|
|
114
|
+
*/
|
|
115
|
+
dedupKey?: string;
|
|
81
116
|
/** [C-2] close 终态通知的轮次统计(文案 "completed after N rounds." 用)。
|
|
82
117
|
* 仅 chatMode close 语义(notifyClosed)构造时携带——此时 dedup 身份 round 已被
|
|
83
118
|
* 置 undefined(与轮次通知的 id:round key 区分,终态不被吞),轮数改由本字段进
|
|
@@ -507,7 +542,10 @@ export function createNotifier(host: NotifierHost): BgNotifier {
|
|
|
507
542
|
// 构造)。running(轮次通知)语义上无 outcome,不物化。消源自 record 的浅拷贝
|
|
508
543
|
// ——不改写入方对象(BgNotifyRecord 由调用方持有)。notifyId 同批物化(U2:
|
|
509
544
|
// dedupe key 与账本身份键同源,details 携带供回执匹配)。
|
|
510
|
-
|
|
545
|
+
// notifyId 构造:dedupKey 显式覆盖优先(drain 丢弃通知等派生通知的独立去重
|
|
546
|
+
// 身份),缺省维持既有 `id:round` / `id` 语义(既有通知面 key 零变化)。
|
|
547
|
+
const notifyId =
|
|
548
|
+
record.dedupKey ?? (record.round != null ? `${record.id}:${record.round}` : record.id);
|
|
511
549
|
const payload: BgNotifyRecord =
|
|
512
550
|
record.status === "closed"
|
|
513
551
|
? { ...record, outcome: record.outcome ?? deriveOutcome(record.closedReason, record.error), notifyId }
|
|
@@ -25,7 +25,7 @@ export interface PiLike {
|
|
|
25
25
|
options?: { triggerTurn?: boolean; deliverAs?: "steer" | "followUp" | "nextTurn" }, // g4-allow: 类型注解——PiLike 接口形状(pi.sendMessage 签面子集),非投递调用
|
|
26
26
|
): void;
|
|
27
27
|
/** 订阅 pi 事件(D8:notifier 的 settled 边沿订阅用 'agent_settled')。
|
|
28
|
-
* pi 0.84.
|
|
28
|
+
* pi 0.84.4 的 on 返回 void 且无 off——退订语义由调用侧 disposed 标志包装兑现。
|
|
29
29
|
* 可选:旧测试 mock pi 可能未实现 on,缺省时 notifier 退化为内核退避路径。 */
|
|
30
30
|
on?(event: "agent_settled", handler: () => void): void;
|
|
31
31
|
}
|
|
@@ -122,11 +122,19 @@ export function createNotifyHost(deps: NotifyHostDeps): NotifyHost {
|
|
|
122
122
|
* 正在执行(running + 活进程 + 非 timer-armed)返回 undefined(调用方 notifyComplete 跳过)。
|
|
123
123
|
* SP-1: closed 统一终态,closedReason 由 BgNotifyRecord 携带。 */
|
|
124
124
|
const toNotifyRecord = (record: ExecutionRecord): BgNotifyRecord | undefined => {
|
|
125
|
+
// [H2 W2 / D6] workflow origin 回注全静默(单漏斗 origin gate):完成/关闭/失败
|
|
126
|
+
// 回注经此全部拒绝——workflow agent 结果由脚本返回值承载(无 message 对端),
|
|
127
|
+
// 回注只会把已隐藏的 record 通知主 agent(设计 D6 出口枚举化;失败回注同静默,
|
|
128
|
+
// v3 扩)。单漏斗盖住全部调用点(notifyComplete/notifyClosed/collectCoordinator
|
|
129
|
+
// route 六调用面全经此,禁止散改调用点);监督器 steer 通知族不经本漏斗——随
|
|
130
|
+
// adopt 豁免对 workflow record 零触发。
|
|
131
|
+
if (record.origin === "workflow") return undefined;
|
|
125
132
|
const snap = snapshot(record);
|
|
126
133
|
const s = snap.status;
|
|
127
134
|
// [N1] isResumable 放行:SP-5 one-shot 成功完成后 finalizeRoundToIdle 把 record 回退
|
|
128
|
-
// running-resumable——进程已死且永不 arm idle timer(armIdleTimer
|
|
129
|
-
//
|
|
135
|
+
// running-resumable——进程已死且永不 arm idle timer(armIdleTimer 的 arm 链随 H1 U6
|
|
136
|
+
// 长驻退役失活,全仓无生产调用,见 lifecycle-predicates.ts 头注释),旧守卫
|
|
137
|
+
// (closed / isIdle only)对其恒拒绝 → 完成通知静默丢失,
|
|
130
138
|
// 而 one-shot 失败走 finalizeRecord 保持 closed 反而通知——与 tool 契约「runs once,
|
|
131
139
|
// notifies on completion」完全倒置。isResumable = running + 无活进程,恰为该完成态;
|
|
132
140
|
// 在跑轮的 record 有活进程,不会被误放行。
|
|
@@ -177,7 +185,8 @@ export function createNotifyHost(deps: NotifyHostDeps): NotifyHost {
|
|
|
177
185
|
* 收不到带指针行的终态通知(审查 C-1)。故 round 置 undefined(key 回退为裸 id),
|
|
178
186
|
* 轮数改经 totalRounds 进文案 "completed after N rounds."(C-2)。
|
|
179
187
|
*
|
|
180
|
-
* 仅 chatMode close 语义调用(closeChatIdle
|
|
188
|
+
* 仅 chatMode close 语义调用(closeChatIdle 终态化成功后;[H1 U6] 旧
|
|
189
|
+
* closeAfterRoundSettled 消费点已随 chat 域退役)。
|
|
181
190
|
* one-shot 显式拒绝(G4:one-shot close 路径现状无终态通知,字节不变);cancel 走
|
|
182
191
|
* cancelBackground 自己的 notifyComplete,不经本方法。幂等性:两条 close 路径均由
|
|
183
192
|
* closeSubagent 的 status 分流守卫(closed 后幂等 no-op)/ CAS 抢锁保证只执行一次,
|
|
@@ -19,6 +19,12 @@ export function encodeCwd(cwd: string): string {
|
|
|
19
19
|
/**
|
|
20
20
|
* 获取 subagent session 持久化目录路径。
|
|
21
21
|
*
|
|
22
|
+
* C-ext-21(跨包隐式契约):本函数产出的 `subagents/<enc>/sessions` 路径形态被
|
|
23
|
+
* extensions/universal/rename-session/src/llm.ts 的 isSubagentSession 嗅探
|
|
24
|
+
* (路径含 `<sep>subagents<sep>` 段 → 判为 subagent 会话并跳过重命名)——改本布局
|
|
25
|
+
* (移动/改名 subagents 段)必须同步该嗅探逻辑,反之亦然;约束登记见
|
|
26
|
+
* docs/constraints.json C-ext-21,设计依据 rename-session-three-modes.md §3.3 D7。
|
|
27
|
+
*
|
|
22
28
|
* D-004: 用主 cwd 编码——保证同一主 cwd 下所有 subagent 的 session 文件
|
|
23
29
|
* 存放在同一目录,便于 session-file-gc 统一清理。
|
|
24
30
|
* [MF-3] worktree 模式下调用方必须传树根 cwd(ROOT mainCwd,经 PI_SUBAGENT_ROOT_CWD
|
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
DisplayItem,
|
|
18
18
|
ExecutionMode,
|
|
19
19
|
ExecutionStatus,
|
|
20
|
+
RecordOrigin,
|
|
20
21
|
SubagentRecord,
|
|
21
22
|
} from "./types.ts";
|
|
22
23
|
|
|
@@ -30,10 +31,11 @@ export const SUBAGENT_RECORD_CUSTOM_TYPE = "subagent-record";
|
|
|
30
31
|
* `subagent-record` entry 的 data schema(v1)。
|
|
31
32
|
*
|
|
32
33
|
* = 完整 SubagentRecord 快照(GUI 侧列表/详情需要的全部持久化字段)+ 版本号。
|
|
33
|
-
*
|
|
34
|
+
* 显式排除两个非持久化字段(与 SubagentRecord 的差集):
|
|
34
35
|
* - currentActivity:running 时的瞬时流态,重开 session 无重建价值;
|
|
35
|
-
* - externalInstance:跨重启探活态(pid/startedAt),由 .alive sidecar 重建;
|
|
36
36
|
* - worktreeHandle:不可 JSON 序列化的运行时句柄(布尔投影 worktree 保留)。
|
|
37
|
+
*([U4a / D3b (a)] externalInstance 投影已随字段链删除——探活态由 .alive sidecar
|
|
38
|
+
* 现查探针承担,不再进 record 快照。)
|
|
37
39
|
*
|
|
38
40
|
* undefined 字段经 JSON.stringify 自然缺省(与 SubagentRecord 重建侧语义一致)。
|
|
39
41
|
*
|
|
@@ -109,6 +111,18 @@ export interface SubagentRecordEntryData {
|
|
|
109
111
|
* 未离开批 / 旧 entry 零迁移。消费方:U5 E1 重建扫描只收无标记成员(防双重通知)。
|
|
110
112
|
*/
|
|
111
113
|
batchFinalized?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* 来源身份(H2 W1,设计 subagent-workflow-record-unification §3.3 D1)。
|
|
116
|
+
* undefined(存量 entry)= "tool" 语义,消费方零迁移。重启后 origin 过滤面
|
|
117
|
+
* (subagents list / renderer / TUI)生效的唯一持久化载体——漏本字段则重启后
|
|
118
|
+
* workflow record 逃过全部投影过滤。
|
|
119
|
+
*/
|
|
120
|
+
origin?: RecordOrigin;
|
|
121
|
+
/**
|
|
122
|
+
* origin="workflow" 时所属 workflow run id(W2 写入);tool 来源恒缺省。
|
|
123
|
+
* W2/W3 run 视图按 collectRecordsByParentRunId 从本字段回查本 run 的 record 集。
|
|
124
|
+
*/
|
|
125
|
+
parentRunId?: string;
|
|
112
126
|
}
|
|
113
127
|
|
|
114
128
|
/** SubagentRecord → 自描述 entry data(快照投影,不 mutate 源)。
|
|
@@ -150,5 +164,9 @@ export function toSubagentRecordEntry(record: SubagentRecord): SubagentRecordEnt
|
|
|
150
164
|
// 旧记录/旧 entry 序列化产物字节不变(零迁移)。
|
|
151
165
|
collectMode: record.collectMode,
|
|
152
166
|
batchFinalized: record.batchFinalized,
|
|
167
|
+
// 来源身份两字段(H2 W1):undefined 经 JSON.stringify 自然缺省,存量 entry
|
|
168
|
+
// 序列化字节不变(零迁移)。
|
|
169
|
+
origin: record.origin,
|
|
170
|
+
parentRunId: record.parentRunId,
|
|
153
171
|
};
|
|
154
172
|
}
|