@oyasmi/pipiclaw 0.8.10 → 0.8.11-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/README.md +3 -3
  2. package/dist/agent/channel-runner.d.ts +11 -0
  3. package/dist/agent/channel-runner.js +58 -27
  4. package/dist/agent/commands.js +2 -3
  5. package/dist/agent/effect-ledger.d.ts +1 -1
  6. package/dist/agent/effect-ledger.js +2 -2
  7. package/dist/agent/prompt/sections.js +3 -3
  8. package/dist/agent/runner-factory.d.ts +2 -0
  9. package/dist/agent/session-events.js +1 -1
  10. package/dist/main.js +6 -0
  11. package/dist/memory/commands.js +6 -1
  12. package/dist/memory/consolidation.d.ts +8 -1
  13. package/dist/memory/consolidation.js +34 -6
  14. package/dist/memory/extraction.d.ts +11 -3
  15. package/dist/memory/extraction.js +19 -6
  16. package/dist/memory/files.d.ts +2 -0
  17. package/dist/memory/files.js +14 -0
  18. package/dist/memory/maintenance-gates.d.ts +3 -0
  19. package/dist/memory/maintenance-gates.js +5 -2
  20. package/dist/memory/maintenance-jobs.js +19 -2
  21. package/dist/memory/maintenance-state.d.ts +29 -0
  22. package/dist/memory/maintenance-state.js +100 -8
  23. package/dist/memory/metadata.d.ts +9 -0
  24. package/dist/memory/metadata.js +5 -0
  25. package/dist/memory/probation.d.ts +21 -0
  26. package/dist/memory/probation.js +48 -0
  27. package/dist/memory/promotion.d.ts +26 -1
  28. package/dist/memory/promotion.js +34 -4
  29. package/dist/memory/recall.js +38 -19
  30. package/dist/memory/session-corpus.js +12 -11
  31. package/dist/memory/session-search.js +25 -6
  32. package/dist/memory/sidecar-worker.js +2 -0
  33. package/dist/memory/task-digest.d.ts +3 -2
  34. package/dist/memory/task-digest.js +22 -8
  35. package/dist/models/auth-cli.d.ts +25 -0
  36. package/dist/models/auth-cli.js +344 -0
  37. package/dist/models/login-ui.d.ts +35 -0
  38. package/dist/models/login-ui.js +145 -0
  39. package/dist/models/provider-login.d.ts +41 -0
  40. package/dist/models/provider-login.js +126 -0
  41. package/dist/models/utils.d.ts +6 -0
  42. package/dist/models/utils.js +10 -0
  43. package/dist/playbooks/memory-and-learning.md +7 -1
  44. package/dist/playbooks/outbound-media.md +7 -33
  45. package/dist/playbooks/runtime-orientation.md +2 -0
  46. package/dist/playbooks/task-closeout.md +22 -35
  47. package/dist/playbooks/task-delegation.md +13 -35
  48. package/dist/playbooks/task-driving.md +36 -56
  49. package/dist/playbooks/task-planning.md +26 -45
  50. package/dist/runtime/bootstrap.js +48 -14
  51. package/dist/runtime/delivery.js +8 -2
  52. package/dist/runtime/dingtalk.d.ts +6 -3
  53. package/dist/runtime/dingtalk.js +6 -39
  54. package/dist/runtime/events.js +4 -3
  55. package/dist/runtime/proxy.d.ts +36 -0
  56. package/dist/runtime/proxy.js +68 -0
  57. package/dist/runtime/store.d.ts +8 -2
  58. package/dist/runtime/store.js +12 -6
  59. package/dist/runtime/task-commands.d.ts +0 -2
  60. package/dist/runtime/task-commands.js +99 -112
  61. package/dist/runtime/task-driver.d.ts +5 -0
  62. package/dist/runtime/task-driver.js +155 -53
  63. package/dist/runtime/task-migration.d.ts +9 -0
  64. package/dist/runtime/task-migration.js +75 -2
  65. package/dist/security/command-guard.js +51 -17
  66. package/dist/security/path-guard.js +72 -14
  67. package/dist/shared/open-browser.d.ts +6 -0
  68. package/dist/shared/open-browser.js +22 -0
  69. package/dist/shared/recoverable-error.d.ts +1 -1
  70. package/dist/shared/recoverable-error.js +1 -1
  71. package/dist/subagents/tool.js +2 -0
  72. package/dist/tasks/control.d.ts +38 -67
  73. package/dist/tasks/control.js +90 -152
  74. package/dist/tasks/ledger.d.ts +104 -22
  75. package/dist/tasks/ledger.js +419 -56
  76. package/dist/tasks/store.d.ts +11 -10
  77. package/dist/tasks/store.js +58 -27
  78. package/dist/tasks/transitions.d.ts +8 -36
  79. package/dist/tasks/transitions.js +29 -54
  80. package/dist/tasks/verification.d.ts +2 -2
  81. package/dist/tools/index.d.ts +2 -0
  82. package/dist/tools/index.js +1 -0
  83. package/dist/tools/memory-manage.js +8 -1
  84. package/dist/tools/read.js +19 -5
  85. package/dist/tools/registry.d.ts +1 -0
  86. package/dist/tools/registry.js +1 -0
  87. package/dist/tools/task-manage/lifecycle.d.ts +1 -7
  88. package/dist/tools/task-manage/lifecycle.js +76 -77
  89. package/dist/tools/task-manage/schema.d.ts +10 -5
  90. package/dist/tools/task-manage/schema.js +35 -21
  91. package/dist/tools/task-manage/shared.d.ts +1 -1
  92. package/dist/tools/task-manage/shared.js +29 -30
  93. package/dist/tools/task-manage/types.d.ts +7 -1
  94. package/dist/tools/task-manage/verification.d.ts +4 -5
  95. package/dist/tools/task-manage/verification.js +43 -15
  96. package/dist/tools/task-manage.d.ts +1 -1
  97. package/dist/tools/task-manage.js +9 -9
  98. package/dist/tui/app.js +1 -2
  99. package/dist/tui/commands.d.ts +1 -1
  100. package/dist/tui/commands.js +1 -1
  101. package/dist/tui/turn-controller.d.ts +1 -1
  102. package/dist/usage/ledger.d.ts +1 -1
  103. package/dist/usage/ledger.js +47 -22
  104. package/dist/usage/render.d.ts +1 -1
  105. package/dist/usage/render.js +8 -6
  106. package/package.json +7 -6
@@ -1,80 +1,60 @@
1
1
  ---
2
2
  name: task-driving
3
- description: 被 TASK_DRIVER 唤醒推进任务、留检查点,或任务停滞、被治理器暂停、元数据损坏时。
3
+ description: 被 TASK_DRIVER 唤醒推进任务、留检查点,或任务等待、停滞、停用、元数据损坏时。
4
4
  requires-tools: task_manage
5
5
  priority: 41
6
6
  ---
7
7
 
8
- # 任务(task)推进、断点恢复与修复
8
+ # 任务推进、断点恢复与修复
9
+
10
+ 等待来源与 `waiting` 两种形态的唯一真相源见 `task-delegation.md`;后台作业恢复细节见 `background-jobs.md`。
9
11
 
10
12
  ## 每次唤醒先恢复真相
11
13
 
12
14
  1. 打开消息指定的 `tasks/<id>.md`,不要只依赖唤醒文本、旧对话或记忆。
13
- 2. 核对 status、最新 Current Cycle note、`nextAction`、`wake`、deadline / attempt budget、`sideEffects` 和 verification。
14
- 3. 检查上一步产物**是否已经存在**。派发语义是 at-least-once,宕机或租约重放可能让同一步再次到达。
15
- 4. 只推进一个清晰的下一阶段;不要在未知状态下重复外部动作。
16
-
17
- deadline 或 attempt budget 耗尽会令任务被治理器暂停(`paused` + `pausedBy=governor`);连续 3 次唤醒都没有可见进展也会触发同样的暂停。
18
-
19
- ## 回合结束必须留下确定性状态
20
-
21
- 仍开放且正文或进展发生变化时,用 `task_manage progress` 一次性记录:发生了什么、看到了什么证据、下一步是什么、status 与 `wake`。
22
-
23
- 以下生命周期动作本身就是原子 checkpoint,不要再追加 progress:`candidate`、`done`、`skip`、`cancel`。
24
-
25
- `verify` 只更新 control、不改正文。验收与外部审批的全部门禁规则(PASS/approval 的绑定与失效、两个门并存时的顺序)以 `task-closeout.md` 为准,需要时读它,不要凭记忆推断。除此之外不要用 `set` 代替正常进度日志。
26
-
27
- ## 等待与继续
28
-
29
- - 等一个会自己叫醒你的信号(后台作业结束、用户回话):`waiting` **且不设 `wake`** —— 这是停泊,driver 不会来打扰;等待形态的完整选择见 `task-delegation.md`。
30
- - 等一个没人会通知的外部状态:`waiting` + 合理 `wake`,到点回访。
31
- - 两者都把等谁、等什么写进 `blockedReason`。
32
- - 当前仍可继续:保持 `active`,清空 `wake`。
33
- - 明确停止:由用户 pause;不要用极远的 `wake` 模拟暂停。
34
-
35
- 内建 driver 分钟级扫描 DingTalk `dm_*/group_*` channel,`wake` 到期后接续;无需 heartbeat、`.checkin` 或额外传感器。TUI 关闭后没有 daemon,不能自动唤醒。
36
-
37
- 接续节奏由这一轮**实际做了什么**决定,不需要你去操纵:产生了可见 effect(write/edit/subagent/后台 job/给用户的回复,或一条跑通并有输出的同步 bash)就立即接续;只改了台账按 continuation delay;什么都没变按 stalled retry 退避。**不要为了拿到短退避而伪造 progress 或跑无意义命令**——真做事自然就快。
38
-
39
- ## 汇报与静默
40
-
41
- 有用户需要知道的结果、风险、审批请求时正常汇报。周期 occurrence 因去重或产物已存在而明确不执行时,调用 `task_manage skip` 写入简短原因、让任务重新休眠,然后返回 `[SILENT]`;不能只静默而把周期留在 active。除此之外,确实不需要改变任务状态且没有新结果时直接返回 `[SILENT]`。完成时走 `task-closeout.md`。
42
-
43
- ---
44
-
45
- # 诊断与修复
46
-
47
- 先用 `task_manage list` 看结构化状态;让用户用 `/tasks doctor` 看带 Next step 的一致性检查,用 `/tasks stats <id>` 看本周期与累计 attempts/token/cost/wall time、最近结果和 verifier 状态。`cost: unavailable` 表示参与运行的模型缺少价格元数据,不表示免费。
15
+ 2. 核对 status、enabled/stop、Current Cycle、`nextAction`、wake、deadline、attempt budget、waitingFor 和 verification。
16
+ 3. 检查上一步产物是否已经存在。派发是 at-least-once,重放可能让同一步再次到达。
17
+ 4. 只推进一个清晰的下一阶段;外部动作前先查询真实状态,避免重复发送、发布或部署。
48
18
 
49
- ## 被治理器暂停(paused + pausedBy=governor)
19
+ ## 回合结束必须留下状态
50
20
 
51
- 治理器在 deadline、attempt budget 耗尽,或**连续 3 次唤醒都没有可见进展**(fingerprint 未变,含 silent)时暂停任务(旧称 escalated)。先读 Current Cycle 和 stats,判断是空转、范围错误还是预算过小:
21
+ 仍需继续时,用 `task_manage progress` 原子记录发生了什么、证据、下一步、status/wake;Plan 变化放在同一次 `planSteps` 中。生命周期动作 `request-verification`、`complete`、`skip`、`cancel` 本身就是 checkpoint。
52
22
 
53
- - 方向错:修 Manual/`nextAction`、重新拆解或 cancel。
54
- - 预算确实不足:向用户说明后用 `task_manage set` 调整 budget/deadline,并把 status 设回 `active`。
23
+ - 当前可继续:`active`,清除 wake。
24
+ - 等外部 job/user/verifier:`waiting`,无 wake 并写 waitingFor;driver 不会轮询 parked task。
25
+ - 等未来时间:`waiting + wake),waitingFor=time。
26
+ - 周期闭环:`complete` 或 `skip` 进入 sleeping,runtime 计算下一 occurrence。
27
+ - 一次性放弃:`cancel` 归档。
55
28
 
56
- 被暂停的任务不能 progress/candidate;`set`(或 `/tasks resume`)是审查原因后的修复入口,**不要反射性加预算**。
29
+ ## Driver 语义
57
30
 
58
- ## 不唤醒或频繁唤醒
31
+ driver 只派发 enabled 且 active 的任务。waiting 到 wake 时 runtime 先原子写 active/clear wake,再派发;sleeping 到 wake 时先打开 cycle、重置周期数据,再按普通 active wake 派发。enabled=false 的 active/waiting/sleeping 都零 dispatch。
59
32
 
60
- driver 可推进状态包括 `active`、`waiting` 和 `verifying`:其中 `verifying` 会进入只读 checker 回合;三者还必须非停泊(`waiting` 且无 `wake`),且 `wake` 缺失、无效或已到期。`done` 周期任务只在下一次 `wake` 到期时由 runtime 打开新周期,`cancelled`/`paused` 不推进。
33
+ 任务被唤醒后会按真实 effect、台账 fingerprint 和 backoff 继续。不要为了获得短延迟伪造 progress 或运行无意义命令;只记录真实工作。普通用户闲聊不会批量点燃 waiting task。
61
34
 
62
- - 停泊中:这是有意的,等外部信号即可;确认没人会来叫时用 `/tasks run <id>` 或改回 `active`。
63
- - `paused`:用户 `/tasks resume <id>`;若是治理器因预算耗尽暂停,得先 `/tasks set <id> attempts <n>` 放宽,否则 resume 会被拒绝。
64
- - `wake` 太远:纠正 `wake`;急催用 `/tasks run <id>`。
65
- - TUI 已关闭:没有 daemon,不能自动唤醒。
66
- - 反复空转:查最新 note 和 `nextAction`,修 Manual。
35
+ ## 治理器停止
67
36
 
68
- ## 坏 frontmatter / control
37
+ deadline、active attempt budget 或连续三次 active wake 没有可见进展时,runtime 写:
69
38
 
70
- frontmatter 只认开头 `---` 块中的 status/wake/schedule/recurrence/control;`control` 必须是单行 JSON。driver 对不可读 frontmatter fail-open 以便唤醒修复,`task_manage` 对坏 control fail-closed 防止覆盖。
39
+ ```text
40
+ enabled: false
41
+ status: active
42
+ control.stop.by: governor
43
+ control.stop.reason: <确定性原因>
44
+ ```
71
45
 
72
- 先 `read`,**只有此场景**才用 `edit` 修合法 frontmatter;随后用 `task_manage set` 让后续更新回到工具轨道。control 不确定时删除坏行,再用 `set` 重建默认结构。
46
+ 治理器直接发送确定性 receipt,不开启诊断回合。先检查 Current Cycle、真实产物和 `/tasks stats <id>`;修正范围、deadline 或 budget 后用 `/tasks resume <id>` 保留原阶段,或让 Agent cancel。
73
47
 
74
- ## 失效的门禁与孤儿事件
48
+ ## Doctor 与损坏文件
75
49
 
76
- 改动契约段或产物后 done 被拒绝:重跑 verifier 或请用户重新 approve,不绕过。完整绑定规则和无失效顺序见 `task-closeout.md`。
50
+ `/tasks doctor` 的每条问题都带 Next step。重点检查:
77
51
 
78
- done/cancel 会清理 `task.<channelId>.<id>.*` 事件;孤儿事件用 `event_manage` 删除。旧的 `.checkin` / `.schedule` 事件是 legacy——把 cron 折进 frontmatter 的 `schedule` 后删除事件,以 `wake` 为单一恢复条件(`/tasks doctor` 会给出迁移提示)。
52
+ - active 隐藏 future wake;
53
+ - waitingFor 与 wake 组合;
54
+ - waiting parked 是否有明确 user/job/verification 来源;
55
+ - sleeping 的 schedule、wake 和 occurrence;
56
+ - enabled 与 stop 是否一致;
57
+ - required verification 的 attestation、contract hash、artifact subject;
58
+ - retired control keys 和不可读 frontmatter。
79
59
 
80
- daemon 重启会清空内存 cooldown,可推进任务可能很快重放。任务文件是恢复真相:每次先核对已完成产物,避免重复外部动作。
60
+ 修复 metadata 不执行外部动作。坏 frontmatter 会 fail-open 让问题显现;坏 control 先修 JSON,再用 task_manage set。daemon restart 后按任务文件重新恢复,仍须遵守幂等检查。
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: task-planning
3
- description: 创建或重构长程任务(task)、在 task 与事件(event)之间取舍,或设定周期节奏(schedule)。
3
+ description: 创建或重构长程任务(task)、选择 task 与事件(event),或设定周期节奏(schedule)。
4
4
  requires-tools: task_manage
5
5
  priority: 40
6
6
  ---
@@ -9,7 +9,7 @@ priority: 40
9
9
 
10
10
  ## 什么时候创建 task
11
11
 
12
- 只有工作需要**跨回合恢复**时才建:多步骤目标、等待人或外部系统、委派工作、周期性产出。当前回合能完成的简单请求不要建台账;纯提醒(无产出、无验收)用事件(event),见 `event-scheduling.md`。
12
+ 只有工作需要跨回合恢复时才建:多步骤目标、等待人或外部系统、委派工作、周期性产出。当前回合能完成的简单请求不要建台账;纯提醒或外部条件探测用 event。
13
13
 
14
14
  ## 创建内容
15
15
 
@@ -17,59 +17,40 @@ priority: 40
17
17
 
18
18
  - `id`:稳定的 kebab-case。
19
19
  - `title`:一句话标题。
20
- - `goal`:最终要成立的**结果**,不写行动清单。
21
- - `dod`:客观验收标准,每项必须是 `- [ ]` checkbox;纯 prose 或编号列表会被拒。
22
- - `manual`:可复用的执行步骤、预检与返工教训。
23
- - `verificationPlan`:验收者能独立执行的确定性检查。
20
+ - `goal`:最终要成立的结果,不写行动清单。
21
+ - `dod`:客观验收标准,每项必须是 `- [ ]` checkbox。
22
+ - `manual`:可复用的执行步骤、预检、幂等方法和返工教训。
23
+ - `verificationPlan`:独立验收者能执行的确定性检查。
24
24
 
25
- 默认不要求独立验收,只有有限尝试预算。任务产出了验收者能独立检查的产物(代码、配置、可运行命令)时,创建时设 `control.verificationRequired: true`;`sideEffects: external` 的任务会自动打开它。
25
+ Task 创建即持续委托;是否触达外部系统由可用工具、security 配置、任务 Goal 和幂等检查共同约束。不存在按动作逐次授权字段。
26
26
 
27
- ## control 决策
27
+ 有代码、配置或可复现产物时,显式设置 `control.verificationRequired: true`;纯提醒、沟通和主观写作通常保持默认 false。
28
28
 
29
- - `priority` / `deadline`:表达调度重要性和硬期限,不用 `wake` 冒充 deadline。
30
- - `nextAction`:下一条可执行动作,避免写抽象愿望。
31
- - `maxAttempts`:唯一的按任务停止条件,默认 12,按风险和规模调整。它在**本周期、回合边界**检查,不会中断正在运行的单个回合。周期任务每开一个新周期清零,**一次性任务则是终身额度**——预计要十几步以上的长程任务,创建时就把它调高,不要等治理器把任务停掉再补。
32
- - `sideEffects`:`workspace` 或 `external`。发送、发布、部署、修改外部系统必须选 `external`,它会要求用户 `/tasks approve` 后才能 done。
33
- - 任务之间没有父子或依赖字段。需要表达先后次序时写进 `goal`/`manual`,或用 `wake` 把后续任务排到合适的时间;每个任务只按自己的 DoD 收尾。
34
-
35
- 外部副作用与独立验收并存时,DoD/Verification 只验收"**待执行动作及其输入已准备正确**",不要把尚未获批的外部动作本身写成必须勾选的项;理由与完整门禁顺序见 `task-closeout.md`。
36
-
37
- DoD 描述最终可验收结果,不把未执行动作写成 `[x] skipped`。存在条件分支时,用一个结果项表达“完成 A,或在条件不成立时交付 B 并附理由”;执行哪条路径由 evidence 证明。
38
-
39
- ## 六个状态与时间
40
-
41
- 每个状态只对应一种 driver 行为:
29
+ ## Control 决策
42
30
 
43
- - `active`:可推进(受 `wake` 门控)。
44
- - `waiting`:等用户/外部条件/委派结果;等谁、等什么写进 `control.blockedReason`。
45
- - `verifying`:只做独立验收,不继续实现。
46
- - `paused`:driver 不运行。用户暂停记 `pausedBy=user`,治理器停止记 `pausedBy=governor`。
47
- - `done`:完成;有 `schedule` 则原地睡到下次 occurrence,否则归档。
48
- - `cancelled`:放弃并归档。
49
-
50
- `wake` 是**最早重新检查时间**,不是截止时间。等待时设置现实的 `wake`;可继续时清空 `wake`,让 driver 按 cooldown 接续。写本地时间(如 `2026-07-27T07:30:00+08:00`),不要手算 UTC;也可以写相对量 `+2h`/`+45m`/`+3d`。
51
-
52
- ## 周期性任务(schedule)
53
-
54
- 一个周期任务就是**一个文件**:`tasks/<id>.md`。节奏写在 frontmatter 的 `schedule`(五段 cron,按主机时区解释;部署时用 `TZ` 固定所需 IANA 时区),做法与跨周期经验写在正文。没有配套事件,也没有 `.schedule` 命名约定。`recurrence` 只是给人看的可选标注(如 `每周一`),没有机器语义——**周期性 = `schedule` 是否存在**。
31
+ - `priority` / `deadline`:表达调度重要性和硬期限,不用 `wake` 冒充 deadline。
32
+ - `nextAction`:下一条可执行动作,避免抽象愿望。
33
+ - `maxAttempts`:唯一按任务计数的 attempt stop-loss,默认 12;周期任务每次开新 cycle 清零。
34
+ - `waitingFor`:记录恢复源:time、user、job、verification 或 external-signal。
35
+ - `blockedReason`:写清楚等待的对象、条件和下一步。
36
+ - `wake`:最早回访时间;future wake 会使任务规范为 waiting。
37
+ - `schedule`:五字段 cron;存在即 recurring。
55
38
 
56
- ```
57
- task_manage create id=weekly-report title=... goal=... dod=... schedule="30 9 * * 1"
58
- ```
39
+ Goal/DoD/Manual/Verification 描述最终结果和检查方法,不把“查不到状态”写成已完成。外部动作必须先查询真实状态,携带稳定 request/message id,成功后把结果写入 Current Cycle 或 completion evidence。
59
40
 
60
- cron 最密每 30 分钟一次,落盘前校验。纯提醒不建 task,用普通 periodic 事件。
41
+ ## Plan:手段层
61
42
 
62
- **首次执行遵循 cron 语义**:不显式传 `wake` 时,create 会把 `wake` 预约到下一次 occurrence,任务处于 `active` + 未来 `wake`——像 crontab 一样,创建不等于立刻跑。需要立刻开跑就显式传一个当下或过去的 `wake`。
43
+ 预计需要多次唤醒时,用 `plan` 创建步骤,或用 `task_manage progress` 的 `planSteps` 更新。Plan 是手段,不是第二份 DoD;每步写可验证产出,可选 `→ dod:1,2` 引用。四态为 `[ ]` todo、`[x]` done、`[!]` blocked、`[~]` dropped。当前步骤由 runtime 从文档顺序推导。
63
44
 
64
- 到点后 **runtime 直接开下一周期**,不需要(也没有)手工开周期的动作:折叠上一周期日志和 evidence 入 History、限制工作正文只保留最近周期、清空本周期用量与验收授权元数据、置 `active`,然后派发一条普通驱动唤醒。累计审计 usage 不会清零。你醒来面对的就是一个待推进的新周期,和其他唤醒无异。
45
+ ## 三态与周期
65
46
 
66
- - 改节奏:`task_manage set schedule="<新 cron>"`;只要这次调用没有同时显式给 `wake`,写盘就会把 `wake` 重算到新节奏的下一次 occurrence(不论当前 status,停泊任务除外)。一处真相。
67
- - 暂停 / 恢复:`/tasks pause <id>` / `/tasks resume <id>`。
68
- - 退役:`task_manage cancel`,归档任务并清理全部 task-owned 事件。
69
- - 上周期未完成:不要覆盖或虚勾 DoD。先完成、如实缩小本轮范围并验收,或与用户确认后 cancel 整项任务。
47
+ - `active`:当前有具体工作可推进。
48
+ - `waiting`:等待真实条件;有 wake 是定时回访,无 wake 是 signal parked,driver 不轮询。
49
+ - `sleeping`:recurring occurrence 已闭环,等待 schedule 的下一次 wake。
50
+ - `enabled: false`:正交停用,保留 status、wake、schedule;恢复只改回 true。
70
51
 
71
- 每轮闭环前把返工原因、预检步骤和格式偏好写回 Manual;跨任务可复用时才沉淀成 workspace skill。
52
+ recurring create 始终写 `sleeping + enabled: true + next wake`,创建不派发首轮。首轮和续轮都由 runtime 的 cycle-open 操作初始化 Current Cycle;首轮不把占位内容写进 History。一次性任务不能 sleeping,闭环后归档。
72
53
 
73
54
  ## 建档后自检
74
55
 
75
- 创建后读取落盘文件,确认 Goal、DoD、Manual、Verification 和 control 与真实意图一致。后续每个驱动回合按 `task-driving.md` 推进。
56
+ 创建后读取落盘文件,确认 Goal、DoD、Manual、Verification、status、enabled、wake 和 control 与真实意图一致。后续驱动回合按 `task-driving.md`,验收和闭环按 `task-closeout.md`。
@@ -19,7 +19,7 @@ import { formatConfigDiagnostic } from "../shared/config-diagnostic.js";
19
19
  import { fileStamp } from "../shared/file-stamp.js";
20
20
  import { errorMessage } from "../shared/text-utils.js";
21
21
  import { readActiveTasks } from "../tasks/ledger.js";
22
- import { finishTaskAttempt } from "../tasks/store.js";
22
+ import { activateWaitingTask, claimTaskAttempt, finishTaskAttempt } from "../tasks/store.js";
23
23
  import { getToolsConfigPath, loadToolsConfig, loadToolsConfigWithDiagnostics } from "../tools/config.js";
24
24
  import { getUsageLedger } from "../usage/ledger.js";
25
25
  import { parseUsageMode, renderUsageReport } from "../usage/render.js";
@@ -30,10 +30,11 @@ import { DingTalkBot, isBusyMessageDefaultConfig, isResponseModeConfig, normaliz
30
30
  import { DurableDispatchService } from "./durable-dispatch.js";
31
31
  import { handleEventsCommand as runEventsCommand } from "./event-commands.js";
32
32
  import { createEventsWatcher } from "./events.js";
33
+ import { installLlmProxy } from "./proxy.js";
33
34
  import { ChannelStore } from "./store.js";
34
35
  import { pauseTask, handleTasksCommand as runTasksCommand } from "./task-commands.js";
35
- import { createTaskDriverEvent, TaskDriver } from "./task-driver.js";
36
- import { migrateLegacyTaskScheduleEvents } from "./task-migration.js";
36
+ import { createTaskDriverEvent, createTaskVerificationEvent, TaskDriver } from "./task-driver.js";
37
+ import { migrateLegacyTaskScheduleEvents, migrateLegacyTaskState } from "./task-migration.js";
37
38
  import { DEFAULT_AGENTS, DEFAULT_SOUL } from "./workspace-templates.js";
38
39
  const DEFAULT_MEMORY = `# Workspace Memory
39
40
 
@@ -436,6 +437,14 @@ export function createRuntimeContext(options) {
436
437
  // `bot` is defined below in this same scope and initialized before any message
437
438
  // (and thus any getRunner call) can arrive.
438
439
  mediaSender: bot,
440
+ dispatchVerification: async (taskId) => {
441
+ const entries = await readActiveTasks(join(channelDir, "tasks"));
442
+ const entry = entries.find((candidate) => candidate.id === taskId);
443
+ if (!entry)
444
+ return false;
445
+ const verificationEvent = createTaskVerificationEvent(channelId, entry, Date.now());
446
+ return (await durableDispatch?.dispatch(verificationEvent)) ?? false;
447
+ },
439
448
  });
440
449
  channelRunners.set(channelId, runner);
441
450
  }
@@ -455,12 +464,11 @@ export function createRuntimeContext(options) {
455
464
  let pausedTaskId;
456
465
  if (runner?.isBusy()) {
457
466
  runner.requestStop();
458
- const taskId = /^\[TASK_(?:DRIVER|CYCLE):([A-Za-z0-9._-]+)\]/.exec(runner.getTurnStatus().taskText ?? "")?.[1];
467
+ const taskId = /^\[TASK_DRIVER:([A-Za-z0-9._-]+)\]/.exec(runner.getTurnStatus().taskText ?? "")?.[1];
459
468
  if (taskId) {
460
469
  const pauseResult = await pauseTask({
461
470
  args: "",
462
471
  channelDir: getChannelDir(options.paths.workspaceDir, channelId),
463
- approver: "user via /stop",
464
472
  }, taskId);
465
473
  pausedTaskId = taskId;
466
474
  log.logInfo(`[${channelId}] ${pauseResult}`);
@@ -472,13 +480,18 @@ export function createRuntimeContext(options) {
472
480
  if (dropped > 0) {
473
481
  log.logInfo(`[${channelId}] Dropped ${dropped} queued message(s) on stop`);
474
482
  }
475
- const canceled = await durableDispatch?.cancelChannel(channelId);
476
- if (canceled) {
477
- log.logInfo(`[${channelId}] Reset ${canceled} durable-dispatch lease(s) on stop`);
478
- }
479
483
  void runner.abort().catch((err) => {
480
484
  log.logWarning(`[${channelId}] Failed to abort run`, errorMessage(err));
481
485
  });
486
+ void durableDispatch
487
+ ?.cancelChannel(channelId)
488
+ .then((canceled) => {
489
+ if (canceled)
490
+ log.logInfo(`[${channelId}] Reset ${canceled} durable-dispatch lease(s) on stop`);
491
+ })
492
+ .catch((err) => {
493
+ log.logWarning(`[${channelId}] Failed to reset durable-dispatch leases on stop`, errorMessage(err));
494
+ });
482
495
  log.logInfo(`[${channelId}] Stop requested`);
483
496
  }
484
497
  return { pausedTaskId };
@@ -497,7 +510,6 @@ export function createRuntimeContext(options) {
497
510
  channelDir: getChannelDir(options.paths.workspaceDir, event.channelId),
498
511
  workspaceDir: options.paths.workspaceDir,
499
512
  channelId: event.channelId,
500
- approver: event.userName && event.userName !== event.user ? `${event.userName} (${event.user})` : event.user,
501
513
  dispatchTask: async (id, attemptGeneration) => {
502
514
  const channelDir = getChannelDir(options.paths.workspaceDir, event.channelId);
503
515
  const entry = (await readActiveTasks(join(channelDir, "tasks"))).find((candidate) => candidate.id === id);
@@ -524,7 +536,7 @@ export function createRuntimeContext(options) {
524
536
  await bot.sendPlain(event.channelId, response);
525
537
  },
526
538
  async handleUsageCommand(event, bot, args) {
527
- const response = renderUsageReport(getUsageLedger(), event.channelId, parseUsageMode(args), new Date());
539
+ const response = await renderUsageReport(getUsageLedger(), event.channelId, parseUsageMode(args), new Date());
528
540
  await bot.sendPlain(event.channelId, response);
529
541
  },
530
542
  // Read-only prompt accounting; safe mid-turn, so it is answered here rather than by
@@ -654,13 +666,30 @@ export function createRuntimeContext(options) {
654
666
  // task-driver turn is measured as a delta (turns on a channel are serialized)
655
667
  // and credited to the task it was dispatched for.
656
668
  const effectsBefore = channelEffectCount(event.channelId);
669
+ const jobTaskId = /^\[JOB:[^\]]+\][\s\S]*?belongs to task ([A-Za-z0-9._-]+)\./.exec(event.text)?.[1];
670
+ let recoveredJobTaskId;
671
+ if (jobTaskId) {
672
+ const channelDir = getChannelDir(options.paths.workspaceDir, event.channelId);
673
+ const activated = await activateWaitingTask(channelDir, jobTaskId, "job");
674
+ if (activated)
675
+ recoveredJobTaskId = jobTaskId;
676
+ if (activated?.fields.control) {
677
+ const claim = await claimTaskAttempt(channelDir, jobTaskId, new Date());
678
+ if (claim)
679
+ event.taskAttemptGeneration = claim.generation;
680
+ }
681
+ }
657
682
  const result = await runner.run(ctx, store);
658
683
  const taskDriverMatch = /^\[TASK_DRIVER:([A-Za-z0-9._-]+)\]/.exec(event.text);
684
+ const taskAttemptId = taskDriverMatch?.[1] ?? recoveredJobTaskId;
659
685
  if (taskDriverMatch?.[1]) {
660
686
  noteTaskEffects(event.channelId, taskDriverMatch[1], channelEffectCount(event.channelId) - effectsBefore);
661
687
  }
662
- if (taskDriverMatch?.[1] && result.usage && result.durationMs !== undefined) {
663
- await finishTaskAttempt(getChannelDir(options.paths.workspaceDir, event.channelId), taskDriverMatch[1], {
688
+ if (recoveredJobTaskId) {
689
+ noteTaskEffects(event.channelId, recoveredJobTaskId, channelEffectCount(event.channelId) - effectsBefore);
690
+ }
691
+ if (taskAttemptId && result.usage && result.durationMs !== undefined) {
692
+ await finishTaskAttempt(getChannelDir(options.paths.workspaceDir, event.channelId), taskAttemptId, {
664
693
  tokens: result.usage.total,
665
694
  costUsd: result.usage.cost.total,
666
695
  costKnown: result.costKnown === true,
@@ -684,7 +713,7 @@ export function createRuntimeContext(options) {
684
713
  finally {
685
714
  await durableDispatch?.markCompleted(event.dispatchId);
686
715
  runner.endTurn();
687
- // A finished turn may have written task files (progress/done/set); rescan
716
+ // A finished turn may have written task files (progress/complete/set); rescan
688
717
  // now so a continuing task chain advances immediately instead of after a full sleep.
689
718
  taskDriver.nudge?.();
690
719
  }
@@ -770,6 +799,7 @@ export function createRuntimeContext(options) {
770
799
  dispatch: (event) => durableDispatch?.dispatch(event) ?? false,
771
800
  onDispatch: options.onTaskDriverDispatch,
772
801
  getEffectCount: taskEffectCount,
802
+ notify: (receipt) => bot.sendPlain(receipt.channelId, receipt.text),
773
803
  getSettings: () => {
774
804
  runtimeSettingsManager.reload();
775
805
  return runtimeSettingsManager.getTaskDriverSettings();
@@ -863,6 +893,7 @@ export function createRuntimeContext(options) {
863
893
  // One-time close of the 027 migration window: fold any residual legacy `.schedule`
864
894
  // events into task frontmatter before the driver relies on frontmatter as the only cadence.
865
895
  void migrateLegacyTaskScheduleEvents(options.paths.workspaceDir);
896
+ void migrateLegacyTaskState(options.paths.workspaceDir);
866
897
  eventsWatcher.start();
867
898
  memoryMaintenanceScheduler.start();
868
899
  taskDriver.start();
@@ -891,6 +922,9 @@ export function createRuntimeContext(options) {
891
922
  * existing "diagnostics logged with default logging config" ordering.
892
923
  */
893
924
  export function prepareAppServices(paths = DEFAULT_BOOTSTRAP_PATHS) {
925
+ // Shared by the DingTalk daemon and the TUI (both call prepareAppServices), so this
926
+ // covers every entrypoint that talks to an LLM provider.
927
+ installLlmProxy();
894
928
  const settingsManager = new PipiclawSettingsManager(paths.appHomeDir);
895
929
  for (const { scope, error } of settingsManager.drainErrors()) {
896
930
  log.logWarning(`Failed to load ${scope} settings`, `${error.message}\n${paths.settingsConfigPath}`);
@@ -254,8 +254,14 @@ class ChannelDeliveryController {
254
254
  }
255
255
  else if (mode === "finalize-existing") {
256
256
  if (content || this.cardWarmupTriggered) {
257
- const finalProgressText = this.progressStyle === "rolling" ? this.buildSummaryText() : progressText;
258
- touchedRemote = await this.bot.replaceCard(this.event.channelId, content || this.progressStyle === "rolling" ? finalProgressText : NO_CONTENT, true);
257
+ const isRolling = this.progressStyle === "rolling";
258
+ const finalProgressText = isRolling ? this.buildSummaryText() : progressText;
259
+ // A warmed-but-empty card in full mode has nothing to show, so it finalizes
260
+ // blank; rolling mode always has its closing summary to put there.
261
+ // (`||` binds tighter than `?:` — this used to read as one condition and
262
+ // was a standing invitation to misparse it.)
263
+ const finalCardText = content || isRolling ? finalProgressText : NO_CONTENT;
264
+ touchedRemote = await this.bot.replaceCard(this.event.channelId, finalCardText, true);
259
265
  if (!touchedRemote) {
260
266
  this.bot.discardCard(this.event.channelId);
261
267
  }
@@ -52,7 +52,7 @@ export type BusyMessageResult = {
52
52
  };
53
53
  /**
54
54
  * What `/stop` actually did. Stopping a task-driven turn also pauses that task, which the user
55
- * has to be told: a paused task is never picked up again until `/tasks resume <id>`, so silence
55
+ * has to be told: a disabled task is never picked up again until `/tasks resume <id>`, so silence
56
56
  * here reads as "the turn was interrupted" while the whole task has in fact gone quiet.
57
57
  */
58
58
  export interface StopOutcome {
@@ -160,6 +160,9 @@ export declare class DingTalkBot implements MediaSender {
160
160
  discardCard(channelId: string): void;
161
161
  /**
162
162
  * Send a normal message natively mapping DM and Group to correct endpoints (fallback when no card).
163
+ *
164
+ * Only the message shape is decided here; the DM-vs-group routing and the POST itself belong to
165
+ * `sendRobotMessage`, which every other outbound message type already goes through.
163
166
  */
164
167
  sendPlain(channelId: string, text: string): Promise<boolean>;
165
168
  /**
@@ -178,8 +181,8 @@ export declare class DingTalkBot implements MediaSender {
178
181
  private uploadMedia;
179
182
  /**
180
183
  * POST a robot message with an arbitrary msgKey/msgParam, routing DM vs group
181
- * to the correct endpoint. Shared by the media path; `sendPlain` predates this
182
- * and keeps its own inlined copy to avoid a regression-prone refactor.
184
+ * to the correct endpoint. The single outbound path for every non-card message:
185
+ * plain text/markdown, images, and files.
183
186
  */
184
187
  private sendRobotMessage;
185
188
  private createCard;
@@ -680,53 +680,20 @@ export class DingTalkBot {
680
680
  }
681
681
  /**
682
682
  * Send a normal message natively mapping DM and Group to correct endpoints (fallback when no card).
683
+ *
684
+ * Only the message shape is decided here; the DM-vs-group routing and the POST itself belong to
685
+ * `sendRobotMessage`, which every other outbound message type already goes through.
683
686
  */
684
687
  async sendPlain(channelId, text) {
685
- const token = await this.getAccessToken();
686
- if (!token)
687
- return false;
688
688
  const meta = this.getConversationMeta(channelId);
689
689
  if (!meta) {
690
690
  log.logWarning(`No conversation metadata for ${channelId}, cannot send plain message`);
691
691
  return false;
692
692
  }
693
- const robotCode = this.config.robotCode || this.config.clientId;
694
- const isGroup = meta.conversationType === "2";
695
693
  const hasMarkdown = /^#{1,6}\s|^\s*[-*]\s|\*\*.*\*\*|```|`[^`]+`|\[.*?\]\(.*?\)/m.test(text);
696
694
  const msgKey = hasMarkdown ? "sampleMarkdown" : "sampleText";
697
695
  const msgParam = hasMarkdown ? JSON.stringify({ text, title: "Bot" }) : JSON.stringify({ content: text });
698
- const url = isGroup
699
- ? `${DINGTALK_API}/v1.0/robot/groupMessages/send`
700
- : `${DINGTALK_API}/v1.0/robot/oToMessages/batchSend`;
701
- const body = {
702
- robotCode,
703
- msgKey,
704
- msgParam,
705
- };
706
- if (isGroup) {
707
- body.openConversationId = meta.conversationId;
708
- }
709
- else {
710
- body.userIds = [meta.senderId];
711
- }
712
- try {
713
- await http.post(url, body, {
714
- headers: {
715
- "x-acs-dingtalk-access-token": token,
716
- "Content-Type": "application/json",
717
- },
718
- });
719
- return true;
720
- }
721
- catch (err) {
722
- if (axios.isAxiosError(err) && err.response) {
723
- log.logWarning(`DingTalk plain send failed (${err.response.status})`, JSON.stringify(err.response.data));
724
- }
725
- else {
726
- log.logWarning("DingTalk plain send error", errorMessage(err));
727
- }
728
- return false;
729
- }
696
+ return this.sendRobotMessage(meta, msgKey, msgParam);
730
697
  }
731
698
  // ==========================================================================
732
699
  // Media (image / file) delivery — MediaSender contract
@@ -810,8 +777,8 @@ export class DingTalkBot {
810
777
  }
811
778
  /**
812
779
  * POST a robot message with an arbitrary msgKey/msgParam, routing DM vs group
813
- * to the correct endpoint. Shared by the media path; `sendPlain` predates this
814
- * and keeps its own inlined copy to avoid a regression-prone refactor.
780
+ * to the correct endpoint. The single outbound path for every non-card message:
781
+ * plain text/markdown, images, and files.
815
782
  */
816
783
  async sendRobotMessage(meta, msgKey, msgParam) {
817
784
  const token = await this.getAccessToken();
@@ -9,7 +9,6 @@ import { formatLocalTime, parseLocalTime } from "../shared/local-time.js";
9
9
  import { taskEventPrefix } from "../shared/task-events.js";
10
10
  import { errorMessage, eventNameFromFilename } from "../shared/text-utils.js";
11
11
  import { parseTaskFrontmatter } from "../tasks/ledger.js";
12
- import { TERMINAL_TASK_STATUSES } from "../tasks/transitions.js";
13
12
  import { MAX_EVENT_FILES, MAX_ONE_SHOT_DELAY_MS, validateScheduledEvent } from "./event-validation.js";
14
13
  // ============================================================================
15
14
  // EventsWatcher
@@ -499,8 +498,10 @@ export class EventsWatcher {
499
498
  catch {
500
499
  return `owning task ${taskId} no longer exists`;
501
500
  }
502
- const status = parseTaskFrontmatter(content).status ?? "";
503
- return TERMINAL_TASK_STATUSES.has(status) ? `owning task ${taskId} is ${status}` : undefined;
501
+ const frontmatter = parseTaskFrontmatter(content);
502
+ return frontmatter.archiveOutcome
503
+ ? `owning task ${taskId} is archived (${frontmatter.archiveOutcome})`
504
+ : undefined;
504
505
  }
505
506
  async execute(filename, event, deleteAfter = true, occurrence = new Date()) {
506
507
  const orphaned = await this.orphanedOwnerReason(filename, event);
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Node's built-in `fetch` (undici under the hood) ignores `*_PROXY` env vars entirely —
3
+ * only a global dispatcher makes it respect a proxy. This is the sole viable injection
4
+ * point for LLM traffic: the Anthropic/OpenAI/Mistral SDKs default to `globalThis.fetch`,
5
+ * and pi-ai's Google adapters throw if handed a custom `fetch` (see google-generative-ai.js),
6
+ * so per-call fetch injection cannot cover every provider. A global dispatcher also
7
+ * transparently covers OAuth token refresh and model-catalog calls this module never sees.
8
+ *
9
+ * axios (DingTalk's HTTP client) and `ws` (its stream connection) are unaffected — axios
10
+ * reads `HTTP(S)_PROXY` itself via a separate code path, and `ws` reads nothing. That is
11
+ * why `PIPICLAW_PROXY` exists as a distinct variable: it lets an operator route only LLM
12
+ * traffic through a proxy without also pulling DingTalk's HTTP calls through it while its
13
+ * ws connection stays direct (a split that is easy to get into by accident with the
14
+ * standard `HTTPS_PROXY` var, since axios and undici don't agree on what it should mean
15
+ * beyond "proxy this http-ish traffic").
16
+ */
17
+ export type ProxyInstallSource = "PIPICLAW_PROXY" | "env" | "none";
18
+ export interface ProxyInstallResult {
19
+ installed: boolean;
20
+ source: ProxyInstallSource;
21
+ }
22
+ /**
23
+ * Install a global undici dispatcher that routes outbound `fetch` traffic (LLM API calls,
24
+ * OAuth refresh, model catalog lookups) through an HTTP/HTTPS proxy, if one is configured.
25
+ *
26
+ * Precedence: `PIPICLAW_PROXY` (+ optional `PIPICLAW_NO_PROXY`) wins outright. Otherwise,
27
+ * standard `HTTP_PROXY`/`HTTPS_PROXY`/`NO_PROXY` (any case) are honored as-is — matching
28
+ * what axios and the rest of the process already do, so LLM traffic just joins the same
29
+ * behavior instead of being a silent exception to it.
30
+ *
31
+ * Deliberately does nothing when no proxy env var is set at all, rather than always
32
+ * installing an `EnvHttpProxyAgent`: that keeps the default (no proxy configured) path
33
+ * running on undici's plain `Agent` instead of swapping in different connection-pooling
34
+ * behavior for every install, most of which never proxy anything.
35
+ */
36
+ export declare function installLlmProxy(): ProxyInstallResult;
@@ -0,0 +1,68 @@
1
+ import { EnvHttpProxyAgent, setGlobalDispatcher } from "undici";
2
+ import * as log from "../log.js";
3
+ const SUPPORTED_PROXY_PROTOCOLS = new Set(["http:", "https:"]);
4
+ /** Redact credentials from a proxy URL before it ever reaches a log line. */
5
+ function redactProxyUrl(raw) {
6
+ let url;
7
+ try {
8
+ url = new URL(raw);
9
+ }
10
+ catch {
11
+ return "[unparseable]";
12
+ }
13
+ if (url.username || url.password) {
14
+ url.username = "***";
15
+ url.password = "";
16
+ }
17
+ return url.toString();
18
+ }
19
+ function hasStandardProxyEnv() {
20
+ return Boolean(process.env.http_proxy || process.env.HTTP_PROXY || process.env.https_proxy || process.env.HTTPS_PROXY);
21
+ }
22
+ /**
23
+ * Install a global undici dispatcher that routes outbound `fetch` traffic (LLM API calls,
24
+ * OAuth refresh, model catalog lookups) through an HTTP/HTTPS proxy, if one is configured.
25
+ *
26
+ * Precedence: `PIPICLAW_PROXY` (+ optional `PIPICLAW_NO_PROXY`) wins outright. Otherwise,
27
+ * standard `HTTP_PROXY`/`HTTPS_PROXY`/`NO_PROXY` (any case) are honored as-is — matching
28
+ * what axios and the rest of the process already do, so LLM traffic just joins the same
29
+ * behavior instead of being a silent exception to it.
30
+ *
31
+ * Deliberately does nothing when no proxy env var is set at all, rather than always
32
+ * installing an `EnvHttpProxyAgent`: that keeps the default (no proxy configured) path
33
+ * running on undici's plain `Agent` instead of swapping in different connection-pooling
34
+ * behavior for every install, most of which never proxy anything.
35
+ */
36
+ export function installLlmProxy() {
37
+ const explicitProxy = process.env.PIPICLAW_PROXY?.trim();
38
+ if (explicitProxy) {
39
+ let parsed;
40
+ try {
41
+ parsed = new URL(explicitProxy);
42
+ }
43
+ catch {
44
+ log.logWarning("PIPICLAW_PROXY is not a valid URL; LLM requests will connect directly", explicitProxy);
45
+ return { installed: false, source: "none" };
46
+ }
47
+ if (!SUPPORTED_PROXY_PROTOCOLS.has(parsed.protocol)) {
48
+ log.logWarning(`PIPICLAW_PROXY uses unsupported protocol "${parsed.protocol}" (only http:// and https:// proxy URLs are supported, no SOCKS); LLM requests will connect directly`, explicitProxy);
49
+ return { installed: false, source: "none" };
50
+ }
51
+ const noProxy = process.env.PIPICLAW_NO_PROXY?.trim();
52
+ setGlobalDispatcher(new EnvHttpProxyAgent({
53
+ httpProxy: explicitProxy,
54
+ httpsProxy: explicitProxy,
55
+ // Falling through to undefined (rather than "") lets EnvHttpProxyAgent fall
56
+ // back to reading the standard NO_PROXY/no_proxy env var on its own.
57
+ noProxy: noProxy || undefined,
58
+ }));
59
+ log.logInfo(`LLM requests routed through proxy from PIPICLAW_PROXY (${redactProxyUrl(explicitProxy)})`);
60
+ return { installed: true, source: "PIPICLAW_PROXY" };
61
+ }
62
+ if (hasStandardProxyEnv()) {
63
+ setGlobalDispatcher(new EnvHttpProxyAgent());
64
+ log.logInfo("LLM requests routed through proxy from HTTP(S)_PROXY (note: this also routes DingTalk's HTTP API calls, though not its websocket connection)");
65
+ return { installed: true, source: "env" };
66
+ }
67
+ return { installed: false, source: "none" };
68
+ }