create-principles-disciple 1.102.0 → 1.104.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 (160) hide show
  1. package/console/dist/server/config/pd-config-store.d.ts +50 -1
  2. package/console/dist/server/config/pd-config-store.js +364 -1
  3. package/console/dist/server/models/ActivationsConsoleModel.d.ts +7 -4
  4. package/console/dist/server/models/ActivationsConsoleModel.js +7 -6
  5. package/console/dist/server/routes/config.js +92 -2
  6. package/console/dist/ui/api.d.ts +44 -3
  7. package/console/dist/ui/api.js +58 -2
  8. package/console/dist/ui/components/onboarding/DemoResultView.js +19 -1
  9. package/console/dist/ui/i18n/en.json +63 -2
  10. package/console/dist/ui/i18n/zh-CN.json +63 -2
  11. package/console/dist/ui/pages/activation/ActivationPage.js +11 -11
  12. package/console/dist/ui/pages/activation/ActivationValidators.js +14 -13
  13. package/console/dist/ui/pages/control-center/AgentCard.js +56 -7
  14. package/console/dist/ui/pages/control-center/ControlCenterPage.js +2 -1
  15. package/console/dist/ui/pages/control-center/RuntimeProfileManager.d.ts +31 -0
  16. package/console/dist/ui/pages/control-center/RuntimeProfileManager.js +234 -0
  17. package/console/dist/ui/pages/debt/DebtPage.js +2 -2
  18. package/console/dist/ui/utils/validators.d.ts +26 -3
  19. package/console/dist/ui/utils/validators.js +23 -6
  20. package/console/dist/web/assets/app.css +41 -0
  21. package/console/dist/web/assets/app.js +1918 -1160
  22. package/core/dist/runtime-v2/__tests__/resolve-runtime-config-from-pd-config.test.js +8 -10
  23. package/core/dist/runtime-v2/__tests__/resolve-runtime-config-from-pd-config.test.js.map +1 -1
  24. package/core/dist/runtime-v2/adapter/__tests__/l2-resolve-model-compat.test.d.ts +2 -0
  25. package/core/dist/runtime-v2/adapter/__tests__/l2-resolve-model-compat.test.d.ts.map +1 -0
  26. package/core/dist/runtime-v2/adapter/__tests__/l2-resolve-model-compat.test.js +81 -0
  27. package/core/dist/runtime-v2/adapter/__tests__/l2-resolve-model-compat.test.js.map +1 -0
  28. package/core/dist/runtime-v2/adapter/__tests__/pi-ai-runtime-adapter.test.js +25 -6
  29. package/core/dist/runtime-v2/adapter/__tests__/pi-ai-runtime-adapter.test.js.map +1 -1
  30. package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.d.ts +8 -0
  31. package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
  32. package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js +4 -1
  33. package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js.map +1 -1
  34. package/core/dist/runtime-v2/candidate-intake-service.d.ts.map +1 -1
  35. package/core/dist/runtime-v2/candidate-intake-service.js +92 -6
  36. package/core/dist/runtime-v2/candidate-intake-service.js.map +1 -1
  37. package/core/dist/runtime-v2/candidate-intake.d.ts +38 -0
  38. package/core/dist/runtime-v2/candidate-intake.d.ts.map +1 -1
  39. package/core/dist/runtime-v2/candidate-intake.js +48 -0
  40. package/core/dist/runtime-v2/candidate-intake.js.map +1 -1
  41. package/core/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.js +26 -1
  42. package/core/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.js.map +1 -1
  43. package/core/dist/runtime-v2/config/__tests__/pd-config-contract.test.js +9 -5
  44. package/core/dist/runtime-v2/config/__tests__/pd-config-contract.test.js.map +1 -1
  45. package/core/dist/runtime-v2/config/__tests__/pd-config-validation-edge-cases.test.js +53 -33
  46. package/core/dist/runtime-v2/config/__tests__/pd-config-validation-edge-cases.test.js.map +1 -1
  47. package/core/dist/runtime-v2/config/pd-config-agent-binding.d.ts +2 -0
  48. package/core/dist/runtime-v2/config/pd-config-agent-binding.d.ts.map +1 -1
  49. package/core/dist/runtime-v2/config/pd-config-agent-binding.js +3 -0
  50. package/core/dist/runtime-v2/config/pd-config-agent-binding.js.map +1 -1
  51. package/core/dist/runtime-v2/config/pd-config-defaults.d.ts +7 -3
  52. package/core/dist/runtime-v2/config/pd-config-defaults.d.ts.map +1 -1
  53. package/core/dist/runtime-v2/config/pd-config-defaults.js +27 -3
  54. package/core/dist/runtime-v2/config/pd-config-defaults.js.map +1 -1
  55. package/core/dist/runtime-v2/config/pd-config-redaction.d.ts.map +1 -1
  56. package/core/dist/runtime-v2/config/pd-config-redaction.js +5 -2
  57. package/core/dist/runtime-v2/config/pd-config-redaction.js.map +1 -1
  58. package/core/dist/runtime-v2/config/pd-config-types.d.ts +6 -0
  59. package/core/dist/runtime-v2/config/pd-config-types.d.ts.map +1 -1
  60. package/core/dist/runtime-v2/config/pd-config-types.js.map +1 -1
  61. package/core/dist/runtime-v2/config/pd-config-validate.d.ts.map +1 -1
  62. package/core/dist/runtime-v2/config/pd-config-validate.js +11 -6
  63. package/core/dist/runtime-v2/config/pd-config-validate.js.map +1 -1
  64. package/core/dist/runtime-v2/index.d.ts +2 -1
  65. package/core/dist/runtime-v2/index.d.ts.map +1 -1
  66. package/core/dist/runtime-v2/index.js +1 -0
  67. package/core/dist/runtime-v2/index.js.map +1 -1
  68. package/core/dist/runtime-v2/internalization/__tests__/artificer-prompt-builder-v2.test.js +7 -0
  69. package/core/dist/runtime-v2/internalization/__tests__/artificer-prompt-builder-v2.test.js.map +1 -1
  70. package/core/dist/runtime-v2/internalization/__tests__/diag-rootcause-runner.test.js +7 -6
  71. package/core/dist/runtime-v2/internalization/__tests__/diag-rootcause-runner.test.js.map +1 -1
  72. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.js +1 -1
  73. package/core/dist/runtime-v2/internalization/diag-distiller-runner.js +4 -4
  74. package/core/dist/runtime-v2/internalization/diag-distiller-runner.js.map +1 -1
  75. package/core/dist/runtime-v2/internalization/diag-rootcause-runner.js +5 -5
  76. package/core/dist/runtime-v2/internalization/diag-rootcause-runner.js.map +1 -1
  77. package/core/dist/runtime-v2/internalization/diag-router-runner.js +4 -4
  78. package/core/dist/runtime-v2/internalization/diag-router-runner.js.map +1 -1
  79. package/core/dist/runtime-v2/pain-signal-runtime-factory.d.ts +2 -0
  80. package/core/dist/runtime-v2/pain-signal-runtime-factory.d.ts.map +1 -1
  81. package/core/dist/runtime-v2/pain-signal-runtime-factory.js +2 -0
  82. package/core/dist/runtime-v2/pain-signal-runtime-factory.js.map +1 -1
  83. package/dist/installer.d.ts.map +1 -1
  84. package/dist/installer.js +5 -1
  85. package/dist/installer.js.map +1 -1
  86. package/dist/mvp-config.d.ts.map +1 -1
  87. package/dist/mvp-config.js +22 -10
  88. package/dist/mvp-config.js.map +1 -1
  89. package/package.json +1 -1
  90. package/pd-cli/dist/commands/__tests__/runtime-probe-config.test.js +2 -2
  91. package/pd-cli/dist/commands/__tests__/runtime-probe-config.test.js.map +1 -1
  92. package/pd-cli/dist/commands/demo-story-a.d.ts.map +1 -1
  93. package/pd-cli/dist/commands/demo-story-a.js +4 -2
  94. package/pd-cli/dist/commands/demo-story-a.js.map +1 -1
  95. package/pd-cli/dist/commands/proven-channel-baseline.d.ts.map +1 -1
  96. package/pd-cli/dist/commands/proven-channel-baseline.js +4 -2
  97. package/pd-cli/dist/commands/proven-channel-baseline.js.map +1 -1
  98. package/pd-cli/dist/commands/runtime-activation.d.ts.map +1 -1
  99. package/pd-cli/dist/commands/runtime-activation.js +8 -2
  100. package/pd-cli/dist/commands/runtime-activation.js.map +1 -1
  101. package/pd-cli/dist/commands/runtime-canary.d.ts.map +1 -1
  102. package/pd-cli/dist/commands/runtime-canary.js +4 -2
  103. package/pd-cli/dist/commands/runtime-canary.js.map +1 -1
  104. package/pd-cli/dist/commands/runtime-health-snapshot.d.ts.map +1 -1
  105. package/pd-cli/dist/commands/runtime-health-snapshot.js +4 -2
  106. package/pd-cli/dist/commands/runtime-health-snapshot.js.map +1 -1
  107. package/pd-cli/dist/commands/runtime-init.js +2 -2
  108. package/pd-cli/dist/commands/runtime-init.js.map +1 -1
  109. package/pd-cli/dist/commands/runtime-internalization-integrity.d.ts.map +1 -1
  110. package/pd-cli/dist/commands/runtime-internalization-integrity.js +4 -2
  111. package/pd-cli/dist/commands/runtime-internalization-integrity.js.map +1 -1
  112. package/pd-cli/dist/services/config-doctor.d.ts.map +1 -1
  113. package/pd-cli/dist/services/config-doctor.js +9 -2
  114. package/pd-cli/dist/services/config-doctor.js.map +1 -1
  115. package/pd-cli/dist/services/runtime-adapter-resolver.d.ts.map +1 -1
  116. package/pd-cli/dist/services/runtime-adapter-resolver.js +1 -0
  117. package/pd-cli/dist/services/runtime-adapter-resolver.js.map +1 -1
  118. package/plugin/dist/commands/thinking-os.js +25 -7
  119. package/plugin/dist/commands/workflow-debug.d.ts +1 -3
  120. package/plugin/dist/commands/workflow-debug.js +26 -5
  121. package/plugin/dist/core/rule-host.d.ts +5 -2
  122. package/plugin/dist/core/rule-host.js +15 -2
  123. package/plugin/dist/hooks/after-tool-call-helpers.js +20 -3
  124. package/plugin/dist/hooks/gate.js +1 -1
  125. package/plugin/dist/i18n/commands.js +24 -0
  126. package/plugin/dist/index.js +88 -36
  127. package/plugin/dist/service/evolution-dedup.d.ts +1 -1
  128. package/plugin/dist/service/evolution-worker.d.ts +7 -31
  129. package/plugin/dist/service/evolution-worker.js +17 -36
  130. package/plugin/dist/service/queue-io.js +14 -2
  131. package/plugin/dist/service/queue-migration.d.ts +27 -26
  132. package/plugin/dist/service/queue-migration.js +57 -0
  133. package/plugin/docs/COMMAND_REFERENCE.md +0 -1
  134. package/plugin/docs/COMMAND_REFERENCE_EN.md +0 -2
  135. package/plugin/scripts/sync-plugin.mjs +12 -0
  136. package/plugin/templates/langs/en/core/AGENTS.md +2 -2
  137. package/plugin/templates/langs/en/core/TOOLS.md +1 -1
  138. package/plugin/templates/langs/en/skills/pd-mentor/SKILL.md +2 -3
  139. package/plugin/templates/langs/zh/core/AGENTS.md +2 -2
  140. package/plugin/templates/langs/zh/core/TOOLS.md +1 -1
  141. package/plugin/templates/langs/zh/skills/pd-mentor/SKILL.md +2 -3
  142. package/templates/langs/en/core/AGENTS.md +2 -2
  143. package/templates/langs/en/core/BOOTSTRAP.md +4 -17
  144. package/templates/langs/en/core/TOOLS.md +1 -1
  145. package/templates/langs/en/skills/pd-mentor/SKILL.md +8 -26
  146. package/templates/langs/zh/core/AGENTS.md +2 -2
  147. package/templates/langs/zh/core/BOOTSTRAP.md +4 -17
  148. package/templates/langs/zh/core/TOOLS.md +1 -1
  149. package/templates/langs/zh/skills/pd-mentor/SKILL.md +8 -26
  150. package/plugin/dist/constants/diagnostician.d.ts +0 -12
  151. package/plugin/dist/constants/diagnostician.js +0 -65
  152. package/plugin/dist/service/evolution-queue-migration.d.ts +0 -128
  153. package/plugin/dist/service/evolution-queue-migration.js +0 -53
  154. package/plugin/templates/langs/en/skills/pd-diagnostician/SKILL.md +0 -466
  155. package/plugin/templates/langs/zh/skills/pd-diagnostician/SKILL.md +0 -391
  156. package/templates/langs/en/skills/pd-daily/SKILL.md +0 -199
  157. package/templates/langs/en/skills/pd-grooming/SKILL.md +0 -46
  158. package/templates/langs/zh/skills/pd-daily/SKILL.md +0 -283
  159. package/templates/langs/zh/skills/pd-diagnostician/SKILL.md +0 -287
  160. package/templates/langs/zh/skills/pd-grooming/SKILL.md +0 -46
@@ -26,15 +26,10 @@ disable-model-invocation: true
26
26
  | 命令 | 用途 | 适用场景 |
27
27
  |------|------|----------|
28
28
  | `/pd-init` | 初始化战略与OKR | 新项目启动 |
29
- | `/pd-okr` | 目标与关键结果管理 | 周/月度复盘 |
30
29
  | `/pd-bootstrap` | 环境工具扫描与升级 | 装备升级 |
31
30
  | `/pd-research` | 发起工具升级研究 | 深度调研 |
32
31
  | `/pd-thinking` | 管理思维模型与候选方案 | 元认知管理 |
33
- | `/pd-evolve` | 执行完整进化循环 | 问题修复 |
34
- | `/pd-daily` | 配置并发送进化日报 | 日常查看 |
35
- | `/pd-trust` | 查看信任积分与安全等级 | 权限查询 |
36
32
  | `/pd-status` | 查看系统状态(GFI和痛苦词典) | 健康检查 |
37
- | `/pd-grooming` | 工作区数字大扫除 | 熵减维护 |
38
33
  | `/pd-help` | 获取交互式命令引导 | 本技能 |
39
34
 
40
35
  ---
@@ -60,7 +55,7 @@ disable-model-invocation: true
60
55
 
61
56
  **推荐流程**:
62
57
  1. `/pd-status` - 检查系统状态(GFI 和痛苦词典)
63
- 2. `/pd-evolve` - 启动完整的进化循环
58
+ 2. `/pd-evolution-status` - 启动完整的进化循环
64
59
 
65
60
  **话术**: "问题就是进化的燃料。让我帮你系统化地诊断和修复。"
66
61
 
@@ -71,38 +66,26 @@ disable-model-invocation: true
71
66
  **触发条件**: 用户说"今天干了什么"、"看看进度"、"汇报一下"
72
67
 
73
68
  **推荐流程**:
74
- 1. `/pd-daily` - 发送今日进化日报
75
- 2. `/pd-trust` - 查看当前信任积分
76
- 3. `/pd-okr` - 检查 OKR 对齐情况
69
+ 1. `/pd-evolution-status` - 发送今日进化日报
70
+ 2. `/pd-evolution-status` - 查看当前信任积分
77
71
 
78
72
  **话术**: "日报在手,进化我有。让我帮你回顾今天的成果。"
79
73
 
80
74
  ---
81
75
 
82
- ### 场景 4: 工作区太乱
83
-
84
- **触发条件**: 用户说"项目太乱了"、"文件一堆"、"需要整理"
85
-
86
- **推荐流程**:
87
- 1. `/pd-grooming` - 启动工作区大扫除
88
-
89
- **话术**: "数字洁癖是一种美德。让我帮你熵减。"
90
-
91
- ---
92
-
93
- ### 场景 5: 权限或安全相关
76
+ ### 场景 4: 权限或安全相关
94
77
 
95
78
  **触发条件**: 用户说"权限不够"、"被拦截了"、"安全等级"
96
79
 
97
80
  **推荐流程**:
98
- 1. `/pd-trust` - 查看信任积分和安全等级
81
+ 1. `/pd-evolution-status` - 查看信任积分和安全等级
99
82
  2. 解释当前等级的能力边界
100
83
 
101
84
  **话术**: "信任是挣来的,不是给的。让我帮你了解当前的安全等级。"
102
85
 
103
86
  ---
104
87
 
105
- ### 场景 6: 工具升级需求
88
+ ### 场景 5: 工具升级需求
106
89
 
107
90
  **触发条件**: 用户说"想升级工具"、"研究新版本"、"技术栈更新"
108
91
 
@@ -160,7 +143,6 @@ disable-model-invocation: true
160
143
  - 🆕 新项目初始化
161
144
  - 🐛 问题修复
162
145
  - 📊 日常回顾
163
- - 🧹 工作区清理
164
146
  - 🔐 权限/安全
165
147
  - 🔧 工具升级
166
148
  - ❓ 其他
@@ -185,9 +167,9 @@ disable-model-invocation: true
185
167
 
186
168
  | 场景 | 组合流程 |
187
169
  |------|----------|
188
- | 大型重构 | `/pd-evolve` → `deductive-audit` → 执行 |
170
+ | 大型重构 | `/pd-evolution-status` → `deductive-audit` → 执行 |
189
171
  | 系统优化 | `/pd-status` → `evolve-system` → `root-cause` |
190
- | 项目复盘 | `/pd-daily` → `/pd-okr` → `reflection-log` |
172
+ | 项目复盘 | `/pd-evolution-status` → `/pd-status` → `reflection-log` |
191
173
 
192
174
  ### 内部技能调用
193
175
 
@@ -1,12 +0,0 @@
1
- /**
2
- * Diagnostician 协议常量
3
- *
4
- * 用于 Runtime V2 diagnostician prompt
5
- * 与 templates/langs/zh/skills/pd-diagnostician/SKILL.md 保持一致
6
- */
7
- /**
8
- * 诊断协议摘要(用于 HEARTBEAT.md 注入)
9
- *
10
- * 完整版见: templates/langs/zh/skills/pd-diagnostician/SKILL.md
11
- */
12
- export declare const DIAGNOSTICIAN_PROTOCOL_SUMMARY = "## Diagnostic Protocol (5 Whys)\n\n**Phase 1 - Evidence Gathering**:\n- Use the task input/context provided by Runtime V2 for pain context\n- Read .state/logs/events.jsonl recent entries\n- Search codebase for error patterns from Reason field\n- Record all evidence sources (file:line)\n\n**Phase 2 - Causal Chain (5 Whys)**:\n- Why 1: Surface symptom (what you can see)\n- Why 2: Direct cause (what triggered it)\n- Why 3: Process gap (what should have caught it)\n- Why 4: Design flaw (why the gap exists)\n- Why 5: Root cause (systemic issue to fix)\n- Each Why MUST have evidence. Stop at actionable root cause.\n\n**Phase 3 - Root Cause Classification**:\nClassify into one of:\n- **People**: Human error, missing knowledge, communication gap\n- **Design**: Architecture flaw, missing validation, poor abstraction\n- **Assumption**: Invalid assumption, outdated context, edge case\n- **Tooling**: Tool limitation, environment issue, dependency problem\n- For Design: analyze why existing hooks/rules didn't catch this\n\n**Phase 4 - Principle Extraction**:\nExtract a HIGHLY ABSTRACTED principle (not an operational rule):\n- **trigger_pattern**: regex/keywords for when this occurs\n- **action**: what to do differently\n- **abstracted_principle**: ONE sentence, max 40 chars, cross-scenario applicable\n - \u274C Bad: \"\u5199\u5165\u524D\u68C0\u67E5\u76EE\u5F55\u662F\u5426\u5B58\u5728\" (too specific)\n - \u2705 Good: \"\u4EFB\u4F55\u5199\u5165\u64CD\u4F5C\u5FC5\u987B\u786E\u4FDD\u76EE\u6807\u73AF\u5883\u7684\u5B8C\u6574\u6027\" (abstract, reusable)\n\n**Output Format** (single JSON object):\n```json\n{\n \"diagnosis_report\": {\n \"task_id\": \"pain-xxx\",\n \"summary\": \"One-line root cause\",\n \"causal_chain\": [\n { \"why\": 1, \"answer\": \"...\", \"evidence\": \"file:line\" }\n ],\n \"root_cause\": {\n \"category\": \"Design|People|Assumption|Tooling\",\n \"description\": \"...\"\n },\n \"principle\": {\n \"trigger_pattern\": \"...\",\n \"action\": \"...\",\n \"abstracted_principle\": \"\u9AD8\u5EA6\u62BD\u8C61\u7684\u4E00\u53E5\u8BDD\u539F\u5219\"\n }\n }\n}\n```\n";
@@ -1,65 +0,0 @@
1
- /**
2
- * Diagnostician 协议常量
3
- *
4
- * 用于 Runtime V2 diagnostician prompt
5
- * 与 templates/langs/zh/skills/pd-diagnostician/SKILL.md 保持一致
6
- */
7
- /**
8
- * 诊断协议摘要(用于 HEARTBEAT.md 注入)
9
- *
10
- * 完整版见: templates/langs/zh/skills/pd-diagnostician/SKILL.md
11
- */
12
- export const DIAGNOSTICIAN_PROTOCOL_SUMMARY = `## Diagnostic Protocol (5 Whys)
13
-
14
- **Phase 1 - Evidence Gathering**:
15
- - Use the task input/context provided by Runtime V2 for pain context
16
- - Read .state/logs/events.jsonl recent entries
17
- - Search codebase for error patterns from Reason field
18
- - Record all evidence sources (file:line)
19
-
20
- **Phase 2 - Causal Chain (5 Whys)**:
21
- - Why 1: Surface symptom (what you can see)
22
- - Why 2: Direct cause (what triggered it)
23
- - Why 3: Process gap (what should have caught it)
24
- - Why 4: Design flaw (why the gap exists)
25
- - Why 5: Root cause (systemic issue to fix)
26
- - Each Why MUST have evidence. Stop at actionable root cause.
27
-
28
- **Phase 3 - Root Cause Classification**:
29
- Classify into one of:
30
- - **People**: Human error, missing knowledge, communication gap
31
- - **Design**: Architecture flaw, missing validation, poor abstraction
32
- - **Assumption**: Invalid assumption, outdated context, edge case
33
- - **Tooling**: Tool limitation, environment issue, dependency problem
34
- - For Design: analyze why existing hooks/rules didn't catch this
35
-
36
- **Phase 4 - Principle Extraction**:
37
- Extract a HIGHLY ABSTRACTED principle (not an operational rule):
38
- - **trigger_pattern**: regex/keywords for when this occurs
39
- - **action**: what to do differently
40
- - **abstracted_principle**: ONE sentence, max 40 chars, cross-scenario applicable
41
- - ❌ Bad: "写入前检查目录是否存在" (too specific)
42
- - ✅ Good: "任何写入操作必须确保目标环境的完整性" (abstract, reusable)
43
-
44
- **Output Format** (single JSON object):
45
- \`\`\`json
46
- {
47
- "diagnosis_report": {
48
- "task_id": "pain-xxx",
49
- "summary": "One-line root cause",
50
- "causal_chain": [
51
- { "why": 1, "answer": "...", "evidence": "file:line" }
52
- ],
53
- "root_cause": {
54
- "category": "Design|People|Assumption|Tooling",
55
- "description": "..."
56
- },
57
- "principle": {
58
- "trigger_pattern": "...",
59
- "action": "...",
60
- "abstracted_principle": "高度抽象的一句话原则"
61
- }
62
- }
63
- }
64
- \`\`\`
65
- `;
@@ -1,128 +0,0 @@
1
- /**
2
- * Evolution Queue Migration — V1 to V2 Schema
3
- *
4
- * Pure transformation functions and shared queue types.
5
- */
6
- import type { TaskKind, TaskPriority } from '../core/trajectory-types.js';
7
- export type { TaskKind, TaskPriority } from '../core/trajectory-types.js';
8
- /**
9
- * Queue item status values.
10
- */
11
- export type QueueStatus = 'pending' | 'in_progress' | 'completed' | 'failed' | 'canceled';
12
- /**
13
- * Task resolution strings.
14
- */
15
- export type TaskResolution = 'marker_detected' | 'auto_completed_timeout' | 'failed_max_retries' | 'runtime_unavailable' | 'canceled' | 'late_marker_principle_created' | 'late_marker_no_principle' | 'stub_fallback' | 'skipped_thin_violation' | 'noise_classified' | 'retired';
16
- /**
17
- * Recent pain context for sleep_reflection tasks.
18
- * Attached to queue items to provide pain signal context.
19
- */
20
- export interface RecentPainContext {
21
- mostRecent: {
22
- score: number;
23
- source: string;
24
- reason: string;
25
- timestamp: string;
26
- sessionId: string;
27
- } | null;
28
- recentPainCount: number;
29
- recentMaxPainScore: number;
30
- }
31
- /**
32
- * Default values for new V2 fields when migrating legacy items.
33
- */
34
- export declare const DEFAULT_TASK_KIND: TaskKind;
35
- export declare const DEFAULT_PRIORITY: TaskPriority;
36
- export declare const DEFAULT_MAX_RETRIES = 3;
37
- /**
38
- * Legacy (pre-V2) queue item schema.
39
- */
40
- export interface LegacyEvolutionQueueItem {
41
- id: string;
42
- source: string;
43
- traceId?: string;
44
- task?: string;
45
- score: number;
46
- reason: string;
47
- timestamp: string;
48
- enqueued_at?: string;
49
- started_at?: string;
50
- completed_at?: string;
51
- assigned_session_key?: string;
52
- trigger_text_preview?: string;
53
- status?: string;
54
- resolution?: string;
55
- session_id?: string;
56
- agent_id?: string;
57
- taskKind?: string;
58
- priority?: string;
59
- retryCount?: number;
60
- maxRetries?: number;
61
- lastError?: string;
62
- resultRef?: string;
63
- }
64
- /**
65
- * V2 queue item schema.
66
- */
67
- export interface EvolutionQueueItem {
68
- id: string;
69
- taskKind: TaskKind;
70
- priority: TaskPriority;
71
- source: string;
72
- traceId?: string;
73
- task?: string;
74
- score: number;
75
- reason: string;
76
- timestamp: string;
77
- enqueued_at?: string;
78
- started_at?: string;
79
- completed_at?: string;
80
- assigned_session_key?: string;
81
- trigger_text_preview?: string;
82
- status: QueueStatus;
83
- resolution?: TaskResolution;
84
- session_id?: string;
85
- agent_id?: string;
86
- retryCount: number;
87
- maxRetries: number;
88
- lastError?: string;
89
- resultRef?: string;
90
- recentPainContext?: RecentPainContext;
91
- }
92
- export type RawQueueItem = Record<string, unknown>;
93
- /**
94
- * Migrate a legacy queue item to V2 schema.
95
- * Old items without taskKind are assumed to be pain_diagnosis for backward compatibility.
96
- */
97
- export declare function migrateToV2(item: LegacyEvolutionQueueItem): {
98
- id: string;
99
- taskKind: TaskKind;
100
- priority: TaskPriority;
101
- source: string;
102
- traceId?: string;
103
- task?: string;
104
- score: number;
105
- reason: string;
106
- timestamp: string;
107
- enqueued_at?: string;
108
- started_at?: string;
109
- completed_at?: string;
110
- assigned_session_key?: string;
111
- trigger_text_preview?: string;
112
- status: QueueStatus;
113
- resolution?: TaskResolution;
114
- session_id?: string;
115
- agent_id?: string;
116
- retryCount: number;
117
- maxRetries: number;
118
- lastError?: string;
119
- resultRef?: string;
120
- };
121
- /**
122
- * Check if an item is a legacy (pre-V2) queue item.
123
- */
124
- export declare function isLegacyQueueItem(item: RawQueueItem): boolean;
125
- /**
126
- * Migrate entire queue to V2 schema if needed.
127
- */
128
- export declare function migrateQueueToV2(queue: RawQueueItem[]): ReturnType<typeof migrateToV2>[];
@@ -1,53 +0,0 @@
1
- /**
2
- * Evolution Queue Migration — V1 to V2 Schema
3
- *
4
- * Pure transformation functions and shared queue types.
5
- */
6
- /**
7
- * Default values for new V2 fields when migrating legacy items.
8
- */
9
- export const DEFAULT_TASK_KIND = 'pain_diagnosis';
10
- export const DEFAULT_PRIORITY = 'medium';
11
- export const DEFAULT_MAX_RETRIES = 3;
12
- /**
13
- * Migrate a legacy queue item to V2 schema.
14
- * Old items without taskKind are assumed to be pain_diagnosis for backward compatibility.
15
- */
16
- export function migrateToV2(item) {
17
- return {
18
- id: item.id,
19
- taskKind: item.taskKind || DEFAULT_TASK_KIND,
20
- priority: item.priority || DEFAULT_PRIORITY,
21
- source: item.source,
22
- traceId: item.traceId,
23
- task: item.task,
24
- score: item.score,
25
- reason: item.reason,
26
- timestamp: item.timestamp,
27
- enqueued_at: item.enqueued_at,
28
- started_at: item.started_at,
29
- completed_at: item.completed_at,
30
- assigned_session_key: item.assigned_session_key,
31
- trigger_text_preview: item.trigger_text_preview,
32
- status: item.status || 'pending',
33
- resolution: item.resolution,
34
- session_id: item.session_id,
35
- agent_id: item.agent_id,
36
- retryCount: item.retryCount || 0,
37
- maxRetries: item.maxRetries || DEFAULT_MAX_RETRIES,
38
- lastError: item.lastError,
39
- resultRef: item.resultRef,
40
- };
41
- }
42
- /**
43
- * Check if an item is a legacy (pre-V2) queue item.
44
- */
45
- export function isLegacyQueueItem(item) {
46
- return item && typeof item === 'object' && !('taskKind' in item);
47
- }
48
- /**
49
- * Migrate entire queue to V2 schema if needed.
50
- */
51
- export function migrateQueueToV2(queue) {
52
- return queue.map(item => isLegacyQueueItem(item) ? migrateToV2(item) : item);
53
- }