@zhushanwen/pi-subagent-workflow 8.8.0 → 8.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.
Files changed (38) hide show
  1. package/package.json +9 -8
  2. package/skills/subagent-ext-config/SKILL.md +21 -1
  3. package/src/host/pi-host.ts +5 -4
  4. package/src/index.ts +145 -464
  5. package/src/injectors/__tests__/engine-awareness.test.ts +4 -2
  6. package/src/injectors/__tests__/engine-section-stability.test.ts +42 -29
  7. package/src/injectors/engine-awareness.ts +80 -4
  8. package/src/injectors/resource-list-injector.ts +209 -0
  9. package/src/injectors/subagent-list-injector.ts +30 -143
  10. package/src/injectors/workflow-list-injector.ts +23 -150
  11. package/src/interface/__tests__/detectors.test.ts +1 -1
  12. package/src/interface/__tests__/subagent-tool-path-guard.test.ts +42 -26
  13. package/src/interface/__tests__/subagent-tool-prompt.test.ts +15 -6
  14. package/src/interface/__tests__/tool-workflow-run-builtin-name.test.ts +1 -1
  15. package/src/interface/__tests__/tool-workflow-throw-paths.test.ts +1 -1
  16. package/src/interface/bg-notify-render.ts +4 -4
  17. package/src/interface/commands.ts +115 -75
  18. package/src/interface/format.ts +339 -241
  19. package/src/interface/helpers.ts +2 -2
  20. package/src/interface/list-component.ts +163 -116
  21. package/src/interface/list-shared.ts +2 -2
  22. package/src/interface/list-view.ts +129 -72
  23. package/src/interface/subagent-actions.ts +5 -5
  24. package/src/interface/subagent-tool-schema.ts +21 -6
  25. package/src/interface/subagent-tool.ts +31 -29
  26. package/src/interface/subagents.ts +8 -7
  27. package/src/interface/tool-render.ts +2 -2
  28. package/src/interface/tool-workflow-script.ts +15 -14
  29. package/src/interface/tool-workflow.ts +14 -11
  30. package/src/interface/tui-kit.ts +305 -0
  31. package/src/interface/views/WorkflowsView.ts +267 -196
  32. package/src/interface/views/__tests__/WorkflowsView-signature.test.ts +3 -3
  33. package/src/interface/views/__tests__/detail-content-session-file.test.ts +7 -4
  34. package/src/interface/views/detail-content.ts +16 -14
  35. package/src/interface/views/view-constants.ts +19 -0
  36. package/src/jsonl-run-store.ts +11 -7
  37. package/src/session-lifecycle.ts +561 -0
  38. package/src/interface/views/format.ts +0 -281
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhushanwen/pi-subagent-workflow",
3
- "version": "8.8.0",
3
+ "version": "8.9.0",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
6
  "description": "Unified subagent execution and multi-agent workflow orchestration for Pi — spawned-process agent runtime with sync/background modes, stateful workflow management with persistence, state machine, and execution tracing.",
@@ -24,6 +24,7 @@
24
24
  "relay/",
25
25
  "src/index.ts",
26
26
  "src/jsonl-run-store.ts",
27
+ "src/session-lifecycle.ts",
27
28
  "src/host/",
28
29
  "src/injectors/",
29
30
  "src/interface/"
@@ -53,19 +54,19 @@
53
54
  ]
54
55
  },
55
56
  "dependencies": {
56
- "@xyz-agent/session-delivery": "0.3.0",
57
- "@zhushanwen/pi-ext-guards": "0.2.0",
58
- "@zhushanwen/pi-extension-logger": "0.4.0",
59
- "@xyz-agent/extension-protocol": "0.8.0",
60
- "@zhushanwen/subagent-core": "0.4.0"
57
+ "@xyz-agent/extension-protocol": "0.8.2",
58
+ "@xyz-agent/session-delivery": "0.3.1",
59
+ "@zhushanwen/pi-ext-guards": "0.2.1",
60
+ "@zhushanwen/pi-extension-logger": "0.4.1",
61
+ "@zhushanwen/subagent-core": "0.6.0"
61
62
  },
62
63
  "peerDependencies": {
63
64
  "@earendil-works/pi-ai": "^0.84.4",
64
65
  "@earendil-works/pi-coding-agent": "^0.84.4",
65
66
  "@earendil-works/pi-tui": "^0.84.4",
66
67
  "typebox": "*",
67
- "@zhushanwen/pi-structured-output": "5.1.2",
68
- "@zhushanwen/pi-pending-notifications": "0.5.2"
68
+ "@zhushanwen/pi-pending-notifications": "0.5.3",
69
+ "@zhushanwen/pi-structured-output": "5.1.3"
69
70
  },
70
71
  "peerDependenciesMeta": {
71
72
  "@earendil-works/pi-coding-agent": {
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: subagent-ext-config
3
- description: "使用或排查 @zhushanwen/pi-subagent-workflow 的引擎路由配置时加载。说明 config.json 三环境路径与动态推导方法、字段表(defaultEngine / engineRouting.strict / maxConcurrent)、三层路由优先级、生效时机(新 session 生效)、probe 缓存语义、验证步骤与常见错误。触发词:subagent 引擎配置、切换 subagent 引擎、defaultEngine、zcode 派发、subagent 配置在哪、engineFallback、engine_not_found、subagent-ext-config。"
3
+ description: "使用或排查 @zhushanwen/pi-subagent-workflow 的引擎路由与同步收集配置时加载。说明 config.json 三环境路径与动态推导方法、字段表(defaultEngine / engineRouting.strict / maxConcurrent / collectSync 三键)、三层路由优先级、生效时机(新 session 生效)、probe 缓存语义、collectSync 预算(perItemChars/totalChars)热读时机、验证步骤与常见错误。触发词:subagent 引擎配置、切换 subagent 引擎、defaultEngine、zcode 派发、subagent 配置在哪、engineFallback、engine_not_found、collectSync、sync collect、collect 配置、subagent-ext-config。"
4
4
  ---
5
5
 
6
6
  # subagent-workflow 引擎路由配置指南
@@ -42,6 +42,26 @@ config.json 位于 pi agent 目录下的 `subagents/config.json`,随环境不
42
42
  }
43
43
  ```
44
44
 
45
+ ## collectSync 节(同步收集)
46
+
47
+ `collectSync` 控制 subagent 同步收集(`collect:"sync"` 批通知)的默认模式与结果预算。整节缺失 = 不落键,消费方兜底默认(与 defaultEngine/engineRouting 同风格);逐字段 sanitize——坏字段回该字段默认、好字段透传(部分覆盖合法);非对象值(字符串/null 等)整节回默认。坏值不炸启动(与 maxConcurrent 同判)。
48
+
49
+ | 字段 | 类型 | 默认 | 说明 |
50
+ |------|------|------|------|
51
+ | `collectSync.default` | string | `"async"` | start 未显式传 `collect` 参数时的缺省通知模式。合法值 `"async"` / `"sync"`,其它值回 `"async"`。工具调用显式传 `collect` 时覆盖本值 |
52
+ | `collectSync.perItemChars` | number | `4000` | sync 批通知单条目结果正文预算(字符):超出截断,尾接 `session_read {"action":"result","session":"<id>"}` 指针行。正整数,坏值回默认 |
53
+ | `collectSync.totalChars` | number | `24000` | sync 批通知全批正文总量预算(字符):Σ 超限时统一收紧每条目有效预算 `effectivePerItem = clamp(floor(totalChars/n), 200, perItemChars)`(n = 批成员数;折算低于 200 的条目退化为「头行 + 指针行」纯清单)。正整数,坏值回默认 |
54
+
55
+ 示例:
56
+
57
+ ```json
58
+ {
59
+ "collectSync": { "default": "async", "perItemChars": 4000, "totalChars": 24000 }
60
+ }
61
+ ```
62
+
63
+ **生效时机**:`default` 与 `defaultEngine` 同时机(新 session 生效)。两个预算值在批通知组装(flush)时从配置缓存读取(非派发时定格),但配置文件本身仍按「重要前提」规则缓存——因此改 collectSync 后的可靠生效方式与其它字段一致:**新建 session**。
64
+
45
65
  ## 三层路由优先级
46
66
 
47
67
  一次 subagent 派发用哪个引擎,按以下顺序决定(高优先级覆盖低优先级):
@@ -35,9 +35,10 @@ import { getLogger } from "@zhushanwen/pi-extension-logger";
35
35
  import { countActiveFromEntries } from "@zhushanwen/pi-pending-notifications";
36
36
  import { createDelivery } from "@xyz-agent/session-delivery";
37
37
 
38
- import type { DiscoveryRoot, HostServices } from "@zhushanwen/subagent-core/core/host-services.ts";
39
- import type { LogLevel } from "@zhushanwen/subagent-core/core/logger.ts";
40
- import type { NotifyDomainPorts } from "@zhushanwen/subagent-core/core/notify-ports.ts";
38
+ import type { DiscoveryRoot, HostServices } from "@zhushanwen/subagent-core";
39
+ import type { LogLevel } from "@zhushanwen/subagent-core";
40
+ import type { NotifyDomainPorts } from "@zhushanwen/subagent-core";
41
+ import { toErrorMessage } from "@zhushanwen/pi-ext-guards";
41
42
 
42
43
  /**
43
44
  * core 包(@zhushanwen/subagent-core)agents/ 资产进 pi 发现面的注入根(C5⑥,
@@ -71,7 +72,7 @@ function corePackageNpmRoot(): string | undefined {
71
72
  // module-level mock 可能返回 undefined,模块级持有会在 import 期踩 undefined)
72
73
  getLogger("pi-host").warn(
73
74
  "[pi-host] core 包 agents/ 注入根解析失败——10 内置角色可能不可发现",
74
- { reason: err instanceof Error ? err.message : String(err) },
75
+ { reason: toErrorMessage(err) },
75
76
  );
76
77
  return undefined;
77
78
  }