@lumenflow/cli 5.4.0 → 5.7.12

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 (227) hide show
  1. package/README.md +42 -40
  2. package/dist/db-journal-recover.js +400 -0
  3. package/dist/db-journal-recover.js.map +1 -0
  4. package/dist/docs-sync.js +8 -3
  5. package/dist/docs-sync.js.map +1 -1
  6. package/dist/gate-defaults.js +191 -9
  7. package/dist/gate-defaults.js.map +1 -1
  8. package/dist/gate-registry.js.map +1 -1
  9. package/dist/gates/monolithic-file-contention-guard.js +167 -0
  10. package/dist/gates/monolithic-file-contention-guard.js.map +1 -0
  11. package/dist/gates/prod-migration-drift.js +207 -0
  12. package/dist/gates/prod-migration-drift.js.map +1 -0
  13. package/dist/gates/test-over-deletion-guard.js +255 -0
  14. package/dist/gates/test-over-deletion-guard.js.map +1 -0
  15. package/dist/gates-runners.js +401 -2
  16. package/dist/gates-runners.js.map +1 -1
  17. package/dist/gates.js +349 -4
  18. package/dist/gates.js.map +1 -1
  19. package/dist/lumenflow-setup.js +144 -0
  20. package/dist/lumenflow-setup.js.map +1 -0
  21. package/dist/lumenflow-upgrade.js +2 -1
  22. package/dist/lumenflow-upgrade.js.map +1 -1
  23. package/dist/mem-create.js +10 -1
  24. package/dist/mem-create.js.map +1 -1
  25. package/dist/mem-signal.js +21 -4
  26. package/dist/mem-signal.js.map +1 -1
  27. package/dist/metrics-cli.js +19 -2
  28. package/dist/metrics-cli.js.map +1 -1
  29. package/dist/metrics-snapshot.js +25 -2
  30. package/dist/metrics-snapshot.js.map +1 -1
  31. package/dist/orchestrate-initiative.js +28 -3
  32. package/dist/orchestrate-initiative.js.map +1 -1
  33. package/dist/public-manifest.js +17 -0
  34. package/dist/public-manifest.js.map +1 -1
  35. package/dist/release.js +53 -18
  36. package/dist/release.js.map +1 -1
  37. package/dist/wu-done-gates.js +121 -8
  38. package/dist/wu-done-gates.js.map +1 -1
  39. package/dist/wu-done.js +30 -6
  40. package/dist/wu-done.js.map +1 -1
  41. package/dist/wu-edit-operations.js +74 -0
  42. package/dist/wu-edit-operations.js.map +1 -1
  43. package/dist/wu-edit-validators.js +58 -0
  44. package/dist/wu-edit-validators.js.map +1 -1
  45. package/dist/wu-edit.js +106 -4
  46. package/dist/wu-edit.js.map +1 -1
  47. package/dist/wu-prep.js +132 -8
  48. package/dist/wu-prep.js.map +1 -1
  49. package/dist/wu-recover.js +6 -0
  50. package/dist/wu-recover.js.map +1 -1
  51. package/dist/wu-release.js +120 -2
  52. package/dist/wu-release.js.map +1 -1
  53. package/dist/wu-sizing-validation.js +47 -17
  54. package/dist/wu-sizing-validation.js.map +1 -1
  55. package/dist/wu-status.js +33 -0
  56. package/dist/wu-status.js.map +1 -1
  57. package/package.json +13 -11
  58. package/packs/agent-runtime/package.json +1 -1
  59. package/packs/sidekick/package.json +1 -1
  60. package/packs/software-delivery/package.json +1 -1
  61. package/templates/core/AGENTS.md.template +162 -26
  62. package/templates/core/LUMENFLOW.md.template +381 -70
  63. package/templates/core/ai/onboarding/agent-invocation-guide.md.template +0 -5
  64. package/templates/core/ai/onboarding/agent-safety-card.md.template +63 -17
  65. package/templates/core/ai/onboarding/initiative-orchestration.md.template +4 -0
  66. package/templates/core/ai/onboarding/release-process.md.template +7 -7
  67. package/templates/core/ai/onboarding/vendor-support.md.template +74 -10
  68. package/templates/vendors/claude/.claude/skills/frontend-design/SKILL.md.template +1 -1
  69. package/templates/vendors/claude/.claude/skills/wu-lifecycle/SKILL.md.template +28 -0
  70. package/packs/agent-runtime/agent-heartbeat.ts +0 -163
  71. package/packs/agent-runtime/auto-session-integration.ts +0 -888
  72. package/packs/agent-runtime/capability-factory.ts +0 -104
  73. package/packs/agent-runtime/constants.ts +0 -21
  74. package/packs/agent-runtime/delegation-registry-schema.ts +0 -220
  75. package/packs/agent-runtime/delegation-registry-store.ts +0 -269
  76. package/packs/agent-runtime/delegation-tree.ts +0 -328
  77. package/packs/agent-runtime/index.ts +0 -20
  78. package/packs/agent-runtime/manifest.ts +0 -348
  79. package/packs/agent-runtime/memory-coordination-contract.ts +0 -86
  80. package/packs/agent-runtime/orchestration.ts +0 -2027
  81. package/packs/agent-runtime/pack-registration.ts +0 -110
  82. package/packs/agent-runtime/policy-factory.ts +0 -165
  83. package/packs/agent-runtime/remote-controls/index.ts +0 -7
  84. package/packs/agent-runtime/remote-controls/operations.ts +0 -405
  85. package/packs/agent-runtime/remote-controls/port.ts +0 -48
  86. package/packs/agent-runtime/remote-controls/state-store.ts +0 -258
  87. package/packs/agent-runtime/remote-controls/types.ts +0 -105
  88. package/packs/agent-runtime/session-schema.ts +0 -467
  89. package/packs/agent-runtime/tool-impl/agent-turn-tools.ts +0 -793
  90. package/packs/agent-runtime/tool-impl/index.ts +0 -6
  91. package/packs/agent-runtime/tool-impl/provider-adapters.ts +0 -1245
  92. package/packs/agent-runtime/tool-impl/remote-controls.mock.ts +0 -256
  93. package/packs/agent-runtime/tool-impl/remote-controls.ts +0 -273
  94. package/packs/agent-runtime/tools/index.ts +0 -4
  95. package/packs/agent-runtime/tools/types.ts +0 -47
  96. package/packs/agent-runtime/turn-lifecycle-events.ts +0 -590
  97. package/packs/agent-runtime/types.ts +0 -128
  98. package/packs/agent-runtime/vitest.config.ts +0 -11
  99. package/packs/sidekick/channel-ingress.ts +0 -137
  100. package/packs/sidekick/constants.ts +0 -10
  101. package/packs/sidekick/index.ts +0 -8
  102. package/packs/sidekick/manifest-schema.ts +0 -49
  103. package/packs/sidekick/manifest.ts +0 -512
  104. package/packs/sidekick/pack-registration.ts +0 -110
  105. package/packs/sidekick/policy-factory.ts +0 -38
  106. package/packs/sidekick/sidekick-events.ts +0 -694
  107. package/packs/sidekick/src/adapters/cloud-queue.ts +0 -101
  108. package/packs/sidekick/src/adapters/control-plane-bridge.adapter.ts +0 -386
  109. package/packs/sidekick/src/adapters/filesystem-bridge.adapter.ts +0 -228
  110. package/packs/sidekick/src/domain/channel.types.ts +0 -64
  111. package/packs/sidekick/src/ports/channel-bridge.port.ts +0 -92
  112. package/packs/sidekick/src/routines/commit.ts +0 -74
  113. package/packs/sidekick/tool-impl/channel-tools.ts +0 -577
  114. package/packs/sidekick/tool-impl/channel-transports.ts +0 -75
  115. package/packs/sidekick/tool-impl/index.ts +0 -29
  116. package/packs/sidekick/tool-impl/memory-tools.ts +0 -290
  117. package/packs/sidekick/tool-impl/routine-commit.ts +0 -102
  118. package/packs/sidekick/tool-impl/routine-tools.ts +0 -440
  119. package/packs/sidekick/tool-impl/runtime-context.ts +0 -28
  120. package/packs/sidekick/tool-impl/shared.ts +0 -125
  121. package/packs/sidekick/tool-impl/storage.ts +0 -325
  122. package/packs/sidekick/tool-impl/system-tools.ts +0 -160
  123. package/packs/sidekick/tool-impl/task-tools.ts +0 -506
  124. package/packs/sidekick/tools/channel-tools.ts +0 -53
  125. package/packs/sidekick/tools/index.ts +0 -9
  126. package/packs/sidekick/tools/memory-tools.ts +0 -53
  127. package/packs/sidekick/tools/routine-tools.ts +0 -53
  128. package/packs/sidekick/tools/system-tools.ts +0 -47
  129. package/packs/sidekick/tools/task-tools.ts +0 -61
  130. package/packs/sidekick/tools/types.ts +0 -57
  131. package/packs/sidekick/vitest.config.ts +0 -11
  132. package/packs/software-delivery/constants.ts +0 -10
  133. package/packs/software-delivery/extensions.ts +0 -140
  134. package/packs/software-delivery/gate-policies.ts +0 -134
  135. package/packs/software-delivery/index.ts +0 -8
  136. package/packs/software-delivery/manifest-schema.ts +0 -268
  137. package/packs/software-delivery/manifest.ts +0 -657
  138. package/packs/software-delivery/pack-registration.ts +0 -113
  139. package/packs/software-delivery/src/commands/index.ts +0 -5
  140. package/packs/software-delivery/src/config/delivery-review-contract.ts +0 -256
  141. package/packs/software-delivery/src/config/env-accessors.ts +0 -66
  142. package/packs/software-delivery/src/config/index.ts +0 -8
  143. package/packs/software-delivery/src/config/normalize-config-keys.ts +0 -9
  144. package/packs/software-delivery/src/config/schemas/lumenflow-config-schema-types.ts +0 -460
  145. package/packs/software-delivery/src/config/workspace-reader.ts +0 -375
  146. package/packs/software-delivery/src/constants/backlog-patterns.ts +0 -31
  147. package/packs/software-delivery/src/constants/client-ids.ts +0 -19
  148. package/packs/software-delivery/src/constants/config-contract.ts +0 -7
  149. package/packs/software-delivery/src/constants/docs-layout-presets.ts +0 -50
  150. package/packs/software-delivery/src/constants/duration-constants.ts +0 -20
  151. package/packs/software-delivery/src/constants/gate-constants.ts +0 -32
  152. package/packs/software-delivery/src/constants/index.ts +0 -29
  153. package/packs/software-delivery/src/constants/lock-constants.ts +0 -35
  154. package/packs/software-delivery/src/constants/object-guards.ts +0 -12
  155. package/packs/software-delivery/src/constants/section-headings.ts +0 -107
  156. package/packs/software-delivery/src/constants/wu-cli-constants.ts +0 -488
  157. package/packs/software-delivery/src/constants/wu-domain-constants.ts +0 -466
  158. package/packs/software-delivery/src/constants/wu-git-constants.ts +0 -7
  159. package/packs/software-delivery/src/constants/wu-id-format.ts +0 -327
  160. package/packs/software-delivery/src/constants/wu-paths-constants.ts +0 -384
  161. package/packs/software-delivery/src/constants/wu-statuses.ts +0 -287
  162. package/packs/software-delivery/src/constants/wu-type-helpers.ts +0 -67
  163. package/packs/software-delivery/src/constants/wu-ui-constants.ts +0 -267
  164. package/packs/software-delivery/src/constants/wu-validation-constants.ts +0 -73
  165. package/packs/software-delivery/src/domain/index.ts +0 -5
  166. package/packs/software-delivery/src/domain/orchestration.constants.ts +0 -166
  167. package/packs/software-delivery/src/domain/orchestration.schemas.ts +0 -238
  168. package/packs/software-delivery/src/domain/orchestration.types.ts +0 -176
  169. package/packs/software-delivery/src/methodology/incremental-test.ts +0 -122
  170. package/packs/software-delivery/src/methodology/index.ts +0 -6
  171. package/packs/software-delivery/src/methodology/manual-test-validator.ts +0 -292
  172. package/packs/software-delivery/src/policy/coverage-gate.ts +0 -270
  173. package/packs/software-delivery/src/policy/gates-agent-mode.ts +0 -223
  174. package/packs/software-delivery/src/policy/gates-config-internal.ts +0 -121
  175. package/packs/software-delivery/src/policy/gates-config.ts +0 -300
  176. package/packs/software-delivery/src/policy/gates-coverage.ts +0 -356
  177. package/packs/software-delivery/src/policy/gates-presets.ts +0 -134
  178. package/packs/software-delivery/src/policy/gates-schemas.ts +0 -173
  179. package/packs/software-delivery/src/policy/index.ts +0 -22
  180. package/packs/software-delivery/src/policy/package-manager-resolver.ts +0 -319
  181. package/packs/software-delivery/src/policy/resolve-policy.ts +0 -601
  182. package/packs/software-delivery/src/ports/config.ports.ts +0 -90
  183. package/packs/software-delivery/src/ports/dashboard-renderer.port.ts +0 -125
  184. package/packs/software-delivery/src/ports/index.ts +0 -10
  185. package/packs/software-delivery/src/ports/sync-validator.ports.ts +0 -59
  186. package/packs/software-delivery/src/ports/wu-helpers.ports.ts +0 -168
  187. package/packs/software-delivery/src/ports/wu-state.ports.ts +0 -241
  188. package/packs/software-delivery/src/primitives/index.ts +0 -5
  189. package/packs/software-delivery/src/runtime/index.ts +0 -6
  190. package/packs/software-delivery/src/runtime/work-classifier.ts +0 -561
  191. package/packs/software-delivery/src/sandbox/index.ts +0 -10
  192. package/packs/software-delivery/src/sandbox/sandbox-allowlist.ts +0 -118
  193. package/packs/software-delivery/src/sandbox/sandbox-backend-linux.ts +0 -88
  194. package/packs/software-delivery/src/sandbox/sandbox-backend-macos.ts +0 -154
  195. package/packs/software-delivery/src/sandbox/sandbox-backend-windows.ts +0 -47
  196. package/packs/software-delivery/src/sandbox/sandbox-profile.ts +0 -153
  197. package/packs/software-delivery/src/schemas/index.ts +0 -5
  198. package/packs/software-delivery/src/state/date-utils.ts +0 -158
  199. package/packs/software-delivery/src/state/index.ts +0 -15
  200. package/packs/software-delivery/src/state/state-machine.ts +0 -119
  201. package/packs/software-delivery/src/state/wu-doc-types.ts +0 -51
  202. package/packs/software-delivery/src/state/wu-paths.ts +0 -381
  203. package/packs/software-delivery/src/state/wu-schema.ts +0 -1139
  204. package/packs/software-delivery/src/state/wu-state-schema.ts +0 -255
  205. package/packs/software-delivery/src/state/wu-yaml.ts +0 -338
  206. package/packs/software-delivery/tool-impl/agent-tools.ts +0 -263
  207. package/packs/software-delivery/tool-impl/delegation-tools.ts +0 -66
  208. package/packs/software-delivery/tool-impl/flow-metrics-tools.ts +0 -219
  209. package/packs/software-delivery/tool-impl/git-runner.ts +0 -113
  210. package/packs/software-delivery/tool-impl/git-tools.ts +0 -316
  211. package/packs/software-delivery/tool-impl/index.ts +0 -15
  212. package/packs/software-delivery/tool-impl/initiative-orchestration-tools.ts +0 -720
  213. package/packs/software-delivery/tool-impl/lane-lock.ts +0 -246
  214. package/packs/software-delivery/tool-impl/memory-tools.ts +0 -470
  215. package/packs/software-delivery/tool-impl/pending-runtime-tools.ts +0 -21
  216. package/packs/software-delivery/tool-impl/runtime-cli-adapter.ts +0 -329
  217. package/packs/software-delivery/tool-impl/runtime-native-tools.ts +0 -687
  218. package/packs/software-delivery/tool-impl/worker-loader.ts +0 -52
  219. package/packs/software-delivery/tool-impl/worktree-tools.ts +0 -46
  220. package/packs/software-delivery/tool-impl/wu-lifecycle-tools.ts +0 -807
  221. package/packs/software-delivery/tools/delegation-tools.ts +0 -23
  222. package/packs/software-delivery/tools/git-tools.ts +0 -55
  223. package/packs/software-delivery/tools/index.ts +0 -8
  224. package/packs/software-delivery/tools/lane-lock-tool.ts +0 -37
  225. package/packs/software-delivery/tools/types.ts +0 -71
  226. package/packs/software-delivery/tools/worktree-tools.ts +0 -49
  227. package/packs/software-delivery/vitest.config.ts +0 -11
@@ -1,512 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- import { SIDEKICK_PACK_ID, SIDEKICK_PACK_VERSION, SIDEKICK_POLICY_ID_PREFIX } from './constants.js';
5
- import {
6
- MANIFEST_POLICY_DECISIONS,
7
- MANIFEST_POLICY_TRIGGERS,
8
- SidekickManifestSchema,
9
- type SidekickManifestTool,
10
- type SidekickPackManifest,
11
- } from './manifest-schema.js';
12
- import {
13
- TOOL_PERMISSIONS,
14
- TOOL_SCOPE_ACCESS,
15
- TOOL_SCOPE_TYPES,
16
- type PathScope,
17
- type ToolPermission,
18
- } from './tools/types.js';
19
- import { SIDEKICK_EVENT_KIND_VALUES } from './sidekick-events.js';
20
-
21
- // ---------------------------------------------------------------------------
22
- // Scope constants
23
- // ---------------------------------------------------------------------------
24
-
25
- const SIDEKICK_SCOPE_READ: PathScope = {
26
- type: TOOL_SCOPE_TYPES.PATH,
27
- pattern: '.sidekick/**',
28
- access: TOOL_SCOPE_ACCESS.READ,
29
- };
30
-
31
- const SIDEKICK_SCOPE_WRITE: PathScope = {
32
- type: TOOL_SCOPE_TYPES.PATH,
33
- pattern: '.sidekick/**',
34
- access: TOOL_SCOPE_ACCESS.WRITE,
35
- };
36
-
37
- // ---------------------------------------------------------------------------
38
- // Sidekick tool contract
39
- // ---------------------------------------------------------------------------
40
-
41
- const TOOL_PERMISSIONS_MAP = {
42
- // Task tools (6)
43
- 'task:create': TOOL_PERMISSIONS.WRITE,
44
- 'task:list': TOOL_PERMISSIONS.READ,
45
- 'task:update': TOOL_PERMISSIONS.WRITE,
46
- 'task:cancel': TOOL_PERMISSIONS.ADMIN,
47
- 'task:complete': TOOL_PERMISSIONS.WRITE,
48
- 'task:schedule': TOOL_PERMISSIONS.WRITE,
49
- // Memory tools (4)
50
- 'memory:store': TOOL_PERMISSIONS.WRITE,
51
- 'memory:recall': TOOL_PERMISSIONS.READ,
52
- 'memory:update': TOOL_PERMISSIONS.WRITE,
53
- 'memory:forget': TOOL_PERMISSIONS.ADMIN,
54
- // Channel tools (5)
55
- 'channel:configure': TOOL_PERMISSIONS.WRITE,
56
- 'channel:list': TOOL_PERMISSIONS.READ,
57
- 'channel:delete': TOOL_PERMISSIONS.ADMIN,
58
- 'channel:send': TOOL_PERMISSIONS.WRITE,
59
- 'channel:receive': TOOL_PERMISSIONS.READ,
60
- // Routine tools (5)
61
- 'routine:create': TOOL_PERMISSIONS.WRITE,
62
- 'routine:list': TOOL_PERMISSIONS.READ,
63
- 'routine:update': TOOL_PERMISSIONS.WRITE,
64
- 'routine:delete': TOOL_PERMISSIONS.ADMIN,
65
- 'routine:run': TOOL_PERMISSIONS.READ, // plan-only, no execution
66
- // WU-2738 (INIT-060, ADR-013 §6 governance): plan-to-commit flow routed
67
- // through agent:execute-turn. Runtime-callable tool, no top-level
68
- // surface -- the governed dispatch is the only path to commit a plan.
69
- 'sidekick:routine:commit_plan': TOOL_PERMISSIONS.WRITE,
70
- // System tools (3)
71
- 'sidekick:init': TOOL_PERMISSIONS.WRITE,
72
- 'sidekick:status': TOOL_PERMISSIONS.READ,
73
- 'sidekick:export': TOOL_PERMISSIONS.READ, // returns data, no file write
74
- } as const satisfies Record<string, ToolPermission>;
75
-
76
- type SidekickToolName = keyof typeof TOOL_PERMISSIONS_MAP;
77
-
78
- const TASK_TOOLS_ENTRY = 'tool-impl/task-tools.ts';
79
- const MEMORY_TOOLS_ENTRY = 'tool-impl/memory-tools.ts';
80
- const CHANNEL_TOOLS_ENTRY = 'tool-impl/channel-tools.ts';
81
- const ROUTINE_TOOLS_ENTRY = 'tool-impl/routine-tools.ts';
82
- const ROUTINE_COMMIT_TOOL_ENTRY = 'tool-impl/routine-commit.ts';
83
- const SYSTEM_TOOLS_ENTRY = 'tool-impl/system-tools.ts';
84
- const POLICY_FACTORY_ENTRY = 'policy-factory.ts#createSidekickPolicyFactory';
85
-
86
- const TOOL_ENTRIES: Record<SidekickToolName, string> = {
87
- 'task:create': TASK_TOOLS_ENTRY,
88
- 'task:list': TASK_TOOLS_ENTRY,
89
- 'task:update': TASK_TOOLS_ENTRY,
90
- 'task:cancel': TASK_TOOLS_ENTRY,
91
- 'task:complete': TASK_TOOLS_ENTRY,
92
- 'task:schedule': TASK_TOOLS_ENTRY,
93
- 'memory:store': MEMORY_TOOLS_ENTRY,
94
- 'memory:recall': MEMORY_TOOLS_ENTRY,
95
- 'memory:update': MEMORY_TOOLS_ENTRY,
96
- 'memory:forget': MEMORY_TOOLS_ENTRY,
97
- 'channel:configure': CHANNEL_TOOLS_ENTRY,
98
- 'channel:list': CHANNEL_TOOLS_ENTRY,
99
- 'channel:delete': CHANNEL_TOOLS_ENTRY,
100
- 'channel:send': CHANNEL_TOOLS_ENTRY,
101
- 'channel:receive': CHANNEL_TOOLS_ENTRY,
102
- 'routine:create': ROUTINE_TOOLS_ENTRY,
103
- 'routine:list': ROUTINE_TOOLS_ENTRY,
104
- 'routine:update': ROUTINE_TOOLS_ENTRY,
105
- 'routine:delete': ROUTINE_TOOLS_ENTRY,
106
- 'routine:run': ROUTINE_TOOLS_ENTRY,
107
- 'sidekick:routine:commit_plan': ROUTINE_COMMIT_TOOL_ENTRY,
108
- 'sidekick:init': SYSTEM_TOOLS_ENTRY,
109
- 'sidekick:status': SYSTEM_TOOLS_ENTRY,
110
- 'sidekick:export': SYSTEM_TOOLS_ENTRY,
111
- };
112
-
113
- // ---------------------------------------------------------------------------
114
- // Input schemas (JSON Schema objects)
115
- // ---------------------------------------------------------------------------
116
-
117
- const TOOL_INPUT_SCHEMAS: Record<SidekickToolName, Record<string, unknown>> = {
118
- 'task:create': {
119
- type: 'object',
120
- properties: {
121
- title: { type: 'string', minLength: 1 },
122
- description: { type: 'string' },
123
- priority: { type: 'string', enum: ['P0', 'P1', 'P2', 'P3'] },
124
- due_at: { type: 'string' },
125
- tags: { type: 'array', items: { type: 'string' } },
126
- dry_run: { type: 'boolean' },
127
- },
128
- required: ['title'],
129
- additionalProperties: false,
130
- },
131
- 'task:list': {
132
- type: 'object',
133
- properties: {
134
- status: { type: 'string', enum: ['pending', 'done', 'canceled'] },
135
- priority: { type: 'string', enum: ['P0', 'P1', 'P2', 'P3'] },
136
- tags: { type: 'array', items: { type: 'string' } },
137
- search: { type: 'string' },
138
- due_before: { type: 'string' },
139
- limit: { type: 'integer', minimum: 1 },
140
- },
141
- additionalProperties: false,
142
- },
143
- 'task:update': {
144
- type: 'object',
145
- properties: {
146
- id: { type: 'string', minLength: 1 },
147
- title: { type: 'string', minLength: 1 },
148
- description: { type: 'string' },
149
- priority: { type: 'string', enum: ['P0', 'P1', 'P2', 'P3'] },
150
- tags: { type: 'array', items: { type: 'string' } },
151
- due_at: { type: 'string' },
152
- cron: { type: 'string' },
153
- dry_run: { type: 'boolean' },
154
- },
155
- required: ['id'],
156
- additionalProperties: false,
157
- },
158
- 'task:cancel': {
159
- type: 'object',
160
- properties: {
161
- id: { type: 'string', minLength: 1 },
162
- dry_run: { type: 'boolean' },
163
- },
164
- required: ['id'],
165
- additionalProperties: false,
166
- },
167
- 'task:complete': {
168
- type: 'object',
169
- properties: {
170
- id: { type: 'string', minLength: 1 },
171
- note: { type: 'string' },
172
- dry_run: { type: 'boolean' },
173
- },
174
- required: ['id'],
175
- additionalProperties: false,
176
- },
177
- 'task:schedule': {
178
- type: 'object',
179
- properties: {
180
- id: { type: 'string', minLength: 1 },
181
- due_at: { type: 'string' },
182
- cron: { type: 'string' },
183
- dry_run: { type: 'boolean' },
184
- },
185
- required: ['id'],
186
- additionalProperties: false,
187
- },
188
- 'memory:store': {
189
- type: 'object',
190
- properties: {
191
- type: { type: 'string', enum: ['fact', 'preference', 'note', 'snippet'] },
192
- content: { type: 'string', minLength: 1 },
193
- tags: { type: 'array', items: { type: 'string' } },
194
- dry_run: { type: 'boolean' },
195
- },
196
- required: ['type', 'content'],
197
- additionalProperties: false,
198
- },
199
- 'memory:recall': {
200
- type: 'object',
201
- properties: {
202
- query: { type: 'string' },
203
- type: { type: 'string', enum: ['fact', 'preference', 'note', 'snippet'] },
204
- tags: { type: 'array', items: { type: 'string' } },
205
- limit: { type: 'integer', minimum: 1 },
206
- },
207
- additionalProperties: false,
208
- },
209
- 'memory:forget': {
210
- type: 'object',
211
- properties: {
212
- id: { type: 'string', minLength: 1 },
213
- dry_run: { type: 'boolean' },
214
- },
215
- required: ['id'],
216
- additionalProperties: false,
217
- },
218
- 'memory:update': {
219
- type: 'object',
220
- properties: {
221
- id: { type: 'string', minLength: 1 },
222
- type: { type: 'string', enum: ['fact', 'preference', 'note', 'snippet'] },
223
- content: { type: 'string', minLength: 1 },
224
- tags: { type: 'array', items: { type: 'string' } },
225
- dry_run: { type: 'boolean' },
226
- },
227
- required: ['id'],
228
- additionalProperties: false,
229
- },
230
- 'channel:configure': {
231
- type: 'object',
232
- properties: {
233
- name: { type: 'string', minLength: 1 },
234
- type: { type: 'string', enum: ['terminal'] },
235
- dry_run: { type: 'boolean' },
236
- },
237
- required: ['name'],
238
- additionalProperties: false,
239
- },
240
- 'channel:list': {
241
- type: 'object',
242
- properties: {},
243
- additionalProperties: false,
244
- },
245
- 'channel:delete': {
246
- type: 'object',
247
- properties: {
248
- id: { type: 'string', minLength: 1 },
249
- dry_run: { type: 'boolean' },
250
- },
251
- required: ['id'],
252
- additionalProperties: false,
253
- },
254
- 'channel:send': {
255
- type: 'object',
256
- properties: {
257
- provider: { type: 'string' },
258
- channel: { type: 'string' },
259
- content: { type: 'string', minLength: 1 },
260
- sender: { type: 'string' },
261
- metadata: { type: 'object', additionalProperties: true },
262
- dry_run: { type: 'boolean' },
263
- },
264
- required: ['content'],
265
- additionalProperties: false,
266
- },
267
- 'channel:receive': {
268
- type: 'object',
269
- properties: {
270
- provider: { type: 'string' },
271
- channel: { type: 'string' },
272
- cursor: { type: 'string' },
273
- limit: { type: 'integer', minimum: 1 },
274
- since: { type: 'string' },
275
- metadata: { type: 'object', additionalProperties: true },
276
- },
277
- additionalProperties: false,
278
- },
279
- 'routine:create': {
280
- type: 'object',
281
- properties: {
282
- name: { type: 'string', minLength: 1 },
283
- steps: {
284
- type: 'array',
285
- minItems: 1,
286
- items: {
287
- type: 'object',
288
- properties: {
289
- tool: { type: 'string', minLength: 1 },
290
- input: { type: 'object', additionalProperties: true },
291
- },
292
- required: ['tool'],
293
- additionalProperties: false,
294
- },
295
- },
296
- cron: { type: 'string' },
297
- enabled: { type: 'boolean' },
298
- dry_run: { type: 'boolean' },
299
- },
300
- required: ['name', 'steps'],
301
- additionalProperties: false,
302
- },
303
- 'routine:list': {
304
- type: 'object',
305
- properties: {
306
- enabled_only: { type: 'boolean' },
307
- limit: { type: 'integer', minimum: 1 },
308
- },
309
- additionalProperties: false,
310
- },
311
- 'routine:update': {
312
- type: 'object',
313
- properties: {
314
- id: { type: 'string', minLength: 1 },
315
- name: { type: 'string', minLength: 1 },
316
- steps: {
317
- type: 'array',
318
- minItems: 1,
319
- items: {
320
- type: 'object',
321
- properties: {
322
- tool: { type: 'string', minLength: 1 },
323
- input: { type: 'object', additionalProperties: true },
324
- },
325
- required: ['tool'],
326
- additionalProperties: false,
327
- },
328
- },
329
- cron: { type: 'string' },
330
- enabled: { type: 'boolean' },
331
- dry_run: { type: 'boolean' },
332
- },
333
- required: ['id'],
334
- additionalProperties: false,
335
- },
336
- 'routine:delete': {
337
- type: 'object',
338
- properties: {
339
- id: { type: 'string', minLength: 1 },
340
- dry_run: { type: 'boolean' },
341
- },
342
- required: ['id'],
343
- additionalProperties: false,
344
- },
345
- 'routine:run': {
346
- type: 'object',
347
- properties: {
348
- id: { type: 'string', minLength: 1 },
349
- },
350
- required: ['id'],
351
- additionalProperties: false,
352
- },
353
- 'sidekick:routine:commit_plan': {
354
- type: 'object',
355
- properties: {
356
- plan_id: { type: 'string', minLength: 1 },
357
- attestation: {
358
- type: 'object',
359
- properties: {
360
- actor: { type: 'string', minLength: 1 },
361
- reason: { type: 'string', minLength: 1 },
362
- },
363
- required: ['actor', 'reason'],
364
- additionalProperties: true,
365
- },
366
- },
367
- required: ['plan_id', 'attestation'],
368
- additionalProperties: false,
369
- },
370
- 'sidekick:init': {
371
- type: 'object',
372
- properties: {},
373
- additionalProperties: false,
374
- },
375
- 'sidekick:status': {
376
- type: 'object',
377
- properties: {},
378
- additionalProperties: false,
379
- },
380
- 'sidekick:export': {
381
- type: 'object',
382
- properties: {
383
- include_audit: { type: 'boolean' },
384
- },
385
- additionalProperties: false,
386
- },
387
- };
388
-
389
- // ---------------------------------------------------------------------------
390
- // Generic output schema
391
- // ---------------------------------------------------------------------------
392
-
393
- const GENERIC_OUTPUT_SCHEMA: Record<string, unknown> = {
394
- type: 'object',
395
- properties: {
396
- success: { type: 'boolean' },
397
- data: { type: 'object', additionalProperties: true },
398
- error: { type: 'object', additionalProperties: true },
399
- },
400
- additionalProperties: true,
401
- };
402
-
403
- // ---------------------------------------------------------------------------
404
- // Builder helpers
405
- // ---------------------------------------------------------------------------
406
-
407
- function resolveRequiredScopes(permission: ToolPermission): PathScope[] {
408
- if (permission === TOOL_PERMISSIONS.READ) {
409
- return [SIDEKICK_SCOPE_READ];
410
- }
411
- return [SIDEKICK_SCOPE_READ, SIDEKICK_SCOPE_WRITE];
412
- }
413
-
414
- // WU-2738 (INIT-060, ADR-013 §6 governance): tool-level approval surface
415
- // declarations. Empty array means the default policy permits dispatch; a
416
- // populated array signals the cloud conductor to render an approval prompt
417
- // before the governed `agent:execute-turn` dispatch invokes the tool.
418
- const TOOL_REQUIRED_APPROVALS: Partial<Record<SidekickToolName, string[]>> = {
419
- 'sidekick:routine:commit_plan': [],
420
- };
421
-
422
- function buildTool(name: SidekickToolName): SidekickManifestTool {
423
- const permission = TOOL_PERMISSIONS_MAP[name];
424
- const requiredApprovals = TOOL_REQUIRED_APPROVALS[name];
425
- return {
426
- name,
427
- entry: TOOL_ENTRIES[name],
428
- permission,
429
- required_scopes: resolveRequiredScopes(permission),
430
- input_schema: TOOL_INPUT_SCHEMAS[name],
431
- output_schema: GENERIC_OUTPUT_SCHEMA,
432
- ...(requiredApprovals !== undefined ? { required_approvals: requiredApprovals } : {}),
433
- };
434
- }
435
-
436
- // ---------------------------------------------------------------------------
437
- // Exported manifest
438
- // ---------------------------------------------------------------------------
439
-
440
- export const SIDEKICK_TOOL_NAMES = Object.keys(TOOL_PERMISSIONS_MAP) as SidekickToolName[];
441
-
442
- /**
443
- * WU-2780 (ADR-013 §6 governance): tool names the sidekick pack forbids from
444
- * the top-level remote surface (POST /tools/:name). These tools remain
445
- * registered as runtime-callable — `agent:execute-turn` dispatches them via
446
- * the governed manifest path — but any HTTP allowlist that includes them
447
- * MUST be rejected fail-closed. ADR-013 §6 explicitly names `channel.send`:
448
- * "The sidekick pack does NOT expose `channel.send` as a top-level surface
449
- * the agent can call outside a turn. It is registered only as a
450
- * runtime-callable tool."
451
- */
452
- const ADR_013_SECTION_6_RUNTIME_ONLY_TOOLS: readonly SidekickToolName[] = ['channel:send'] as const;
453
-
454
- /**
455
- * WU-2780 (INIT-060, ADR-013 §6): sidekick pack tools that MAY be exposed on
456
- * the HTTP tool-api surface (POST /tools/:name). Mirrors the
457
- * `REMOTE_CALLABLE_TOOLS` export pattern in sibling packs (software-delivery,
458
- * agent-runtime) so integrators have a single source of truth when wiring
459
- * the surface allowlist. ADR-013 §6 runtime-only tools are excluded by
460
- * construction; the HTTP tool-api also enforces this fail-closed at router
461
- * construction.
462
- */
463
- export const SIDEKICK_REMOTE_CALLABLE_TOOLS: readonly SidekickToolName[] =
464
- SIDEKICK_TOOL_NAMES.filter(
465
- (name): name is SidekickToolName => !ADR_013_SECTION_6_RUNTIME_ONLY_TOOLS.includes(name),
466
- );
467
-
468
- /**
469
- * WU-2780 (INIT-060, ADR-013 §6): returns a fresh copy of the ordered
470
- * remote-callable tool name list. Keeps the export immutable for callers
471
- * that prefer arrays over readonly tuples.
472
- */
473
- export function getSidekickRemoteCallableToolNames(): SidekickToolName[] {
474
- return [...SIDEKICK_REMOTE_CALLABLE_TOOLS];
475
- }
476
-
477
- const SIDEKICK_MANIFEST_TEMPLATE = {
478
- id: SIDEKICK_PACK_ID,
479
- version: SIDEKICK_PACK_VERSION,
480
- config_key: SIDEKICK_PACK_ID,
481
- policy_factory: POLICY_FACTORY_ENTRY,
482
- task_types: ['sidekick'],
483
- tools: SIDEKICK_TOOL_NAMES.map((name) => buildTool(name)),
484
- policies: [
485
- {
486
- id: `${SIDEKICK_POLICY_ID_PREFIX}.default`,
487
- trigger: MANIFEST_POLICY_TRIGGERS.ON_TOOL_REQUEST,
488
- decision: MANIFEST_POLICY_DECISIONS.ALLOW,
489
- reason: 'Default sidekick policy permits declared tools within scoped access.',
490
- },
491
- ],
492
- evidence_types: ['sidekick.audited.tool-call'],
493
- emitted_event_kinds: [...SIDEKICK_EVENT_KIND_VALUES],
494
- state_aliases: {},
495
- lane_templates: [],
496
- // WU-2735 (INIT-060 WU-7a, ADR-013 §ChannelBridge): the sidekick pack
497
- // requires the `sidekick-channel` transport surface. The kernel refuses
498
- // to activate the pack if the surface isn't registered at startup.
499
- surfaces_required: ['sidekick-channel'],
500
- };
501
-
502
- export const SIDEKICK_MANIFEST: SidekickPackManifest = SidekickManifestSchema.parse(
503
- SIDEKICK_MANIFEST_TEMPLATE,
504
- );
505
-
506
- export function getSidekickManifestToolByName(name: string): SidekickManifestTool | undefined {
507
- return SIDEKICK_MANIFEST.tools.find((tool) => tool.name === name);
508
- }
509
-
510
- export function getSidekickToolCount(): number {
511
- return SIDEKICK_MANIFEST.tools.length;
512
- }
@@ -1,110 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- import { createHash } from 'node:crypto';
5
- import { readdir, readFile } from 'node:fs/promises';
6
- import path from 'node:path';
7
- import { fileURLToPath } from 'node:url';
8
- import { SHA256_ALGORITHM, SIDEKICK_MANIFEST_FILE_NAME, UTF8_ENCODING } from './constants.js';
9
- import { SIDEKICK_MANIFEST } from './manifest.js';
10
- import type { SidekickPackManifest } from './manifest-schema.js';
11
-
12
- const NULL_BYTE_BUFFER = Buffer.from([0]);
13
- const DEFAULT_EXCLUSIONS = ['node_modules/', '.git/', 'dist/', '.DS_Store'];
14
-
15
- function getDefaultPackRoot(): string {
16
- return path.dirname(fileURLToPath(import.meta.url));
17
- }
18
-
19
- function normalizeRelativePath(root: string, absolutePath: string): string {
20
- return path.relative(root, absolutePath).split(path.sep).join('/');
21
- }
22
-
23
- function shouldExclude(relativePath: string, exclusions: readonly string[]): boolean {
24
- return exclusions.some((excluded) => {
25
- if (excluded.endsWith('/')) {
26
- return relativePath.startsWith(excluded);
27
- }
28
- return relativePath === excluded || relativePath.endsWith(`/${excluded}`);
29
- });
30
- }
31
-
32
- async function collectFilesRecursive(root: string, directory: string): Promise<string[]> {
33
- const entries = await readdir(directory, { withFileTypes: true });
34
- const sortedEntries = [...entries].sort((left, right) => left.name.localeCompare(right.name));
35
- const files: string[] = [];
36
-
37
- for (const entry of sortedEntries) {
38
- const absolutePath = path.join(directory, entry.name);
39
- const relativePath = normalizeRelativePath(root, absolutePath);
40
- if (entry.isDirectory()) {
41
- files.push(...(await collectFilesRecursive(root, absolutePath)));
42
- continue;
43
- }
44
- files.push(relativePath);
45
- }
46
-
47
- return files;
48
- }
49
-
50
- async function listPackFiles(packRoot: string, exclusions: readonly string[]): Promise<string[]> {
51
- const absoluteRoot = path.resolve(packRoot);
52
- const allFiles = await collectFilesRecursive(absoluteRoot, absoluteRoot);
53
- return allFiles.filter((relativePath) => !shouldExclude(relativePath, exclusions)).sort();
54
- }
55
-
56
- export async function computeSidekickPackIntegrity(
57
- packRoot = getDefaultPackRoot(),
58
- exclusions: readonly string[] = DEFAULT_EXCLUSIONS,
59
- ): Promise<`sha256:${string}`> {
60
- const absoluteRoot = path.resolve(packRoot);
61
- const files = await listPackFiles(absoluteRoot, exclusions);
62
- const digestChunks: Buffer[] = [];
63
-
64
- for (const relativePath of files) {
65
- const fileContents = await readFile(path.join(absoluteRoot, relativePath));
66
- const fileHash = createHash(SHA256_ALGORITHM).update(fileContents).digest('hex');
67
- digestChunks.push(Buffer.from(relativePath, UTF8_ENCODING));
68
- digestChunks.push(NULL_BYTE_BUFFER);
69
- digestChunks.push(Buffer.from(fileHash, UTF8_ENCODING));
70
- digestChunks.push(NULL_BYTE_BUFFER);
71
- }
72
-
73
- const combinedDigest = createHash(SHA256_ALGORITHM)
74
- .update(digestChunks.length === 0 ? Buffer.alloc(0) : Buffer.concat(digestChunks))
75
- .digest('hex');
76
-
77
- return `sha256:${combinedDigest}`;
78
- }
79
-
80
- export async function loadSidekickManifest(
81
- packRoot = getDefaultPackRoot(),
82
- ): Promise<SidekickPackManifest> {
83
- const manifestPath = path.join(path.resolve(packRoot), SIDEKICK_MANIFEST_FILE_NAME);
84
- await readFile(manifestPath, UTF8_ENCODING);
85
- return structuredClone(SIDEKICK_MANIFEST);
86
- }
87
-
88
- export interface RegisteredSidekickPack {
89
- manifest: SidekickPackManifest;
90
- packRoot: string;
91
- manifestPath: string;
92
- integrity: `sha256:${string}`;
93
- }
94
-
95
- export async function registerSidekickPack(options?: {
96
- packRoot?: string;
97
- exclusions?: readonly string[];
98
- }): Promise<RegisteredSidekickPack> {
99
- const packRoot = path.resolve(options?.packRoot ?? getDefaultPackRoot());
100
- const exclusions = options?.exclusions ?? DEFAULT_EXCLUSIONS;
101
- const manifest = await loadSidekickManifest(packRoot);
102
- const integrity = await computeSidekickPackIntegrity(packRoot, exclusions);
103
-
104
- return {
105
- manifest,
106
- packRoot,
107
- manifestPath: path.join(packRoot, SIDEKICK_MANIFEST_FILE_NAME),
108
- integrity,
109
- };
110
- }
@@ -1,38 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- import { POLICY_TRIGGERS, type PackPolicyFactory, type PolicyRule } from '@lumenflow/kernel';
5
- import { SIDEKICK_POLICY_ID_PREFIX } from './constants.js';
6
-
7
- export const SIDEKICK_APPROVAL_REQUIRED_TOOL_NAMES = [
8
- 'task:cancel',
9
- 'memory:forget',
10
- 'channel:delete',
11
- 'routine:delete',
12
- ] as const;
13
-
14
- const SIDEKICK_APPROVAL_REQUIRED_TOOL_NAME_SET = new Set<string>(
15
- SIDEKICK_APPROVAL_REQUIRED_TOOL_NAMES,
16
- );
17
-
18
- export function isSidekickApprovalRequiredToolName(toolName: string): boolean {
19
- return SIDEKICK_APPROVAL_REQUIRED_TOOL_NAME_SET.has(toolName);
20
- }
21
-
22
- export const createSidekickPolicyFactory: PackPolicyFactory = async () => {
23
- if (SIDEKICK_APPROVAL_REQUIRED_TOOL_NAME_SET.size === 0) {
24
- return [];
25
- }
26
-
27
- const approvalRule: PolicyRule = {
28
- id: `${SIDEKICK_POLICY_ID_PREFIX}.destructive-approval`,
29
- trigger: POLICY_TRIGGERS.ON_TOOL_REQUEST,
30
- decision: 'approval_required',
31
- reason: 'Destructive Sidekick tools require explicit approval before execution.',
32
- when: (context) =>
33
- typeof context.tool_name === 'string' &&
34
- isSidekickApprovalRequiredToolName(context.tool_name.trim()),
35
- };
36
-
37
- return [approvalRule];
38
- };