@deriest/ai-engineering-company 1.15.2

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 (237) hide show
  1. package/CHANGELOG.md +807 -0
  2. package/LICENSE +8 -0
  3. package/README.md +291 -0
  4. package/assets/knowledge/.gitkeep +0 -0
  5. package/assets/offices/architecture/README.md +32 -0
  6. package/assets/offices/engineering/README.md +53 -0
  7. package/assets/offices/governance/README.md +30 -0
  8. package/assets/offices/product/README.md +37 -0
  9. package/assets/organization/organization.json +260 -0
  10. package/assets/organization/validation.md +107 -0
  11. package/assets/prompts/.gitkeep +0 -0
  12. package/assets/templates/.gitkeep +0 -0
  13. package/assets/workers/architect/AGENTS.md +49 -0
  14. package/assets/workers/architect/SOUL.md +21 -0
  15. package/assets/workers/architect/config.json +7 -0
  16. package/assets/workers/backend-engineer/AGENTS.md +67 -0
  17. package/assets/workers/backend-engineer/HEARTBEAT.md +5 -0
  18. package/assets/workers/backend-engineer/IDENTITY.md +27 -0
  19. package/assets/workers/backend-engineer/SOUL.md +24 -0
  20. package/assets/workers/backend-engineer/TOOLS.md +44 -0
  21. package/assets/workers/backend-engineer/USER.md +21 -0
  22. package/assets/workers/backend-engineer/company/scripts/wp3/harness-spec.md +31 -0
  23. package/assets/workers/backend-engineer/company/scripts/wp3/lib/semver-range.js +81 -0
  24. package/assets/workers/backend-engineer/company/scripts/wp3/lib/test-mr4.js +6 -0
  25. package/assets/workers/backend-engineer/config.json +7 -0
  26. package/assets/workers/backend-engineer/openclaw-workspace-state.json +4 -0
  27. package/assets/workers/designer/AGENTS.md +49 -0
  28. package/assets/workers/designer/SOUL.md +20 -0
  29. package/assets/workers/designer/config.json +7 -0
  30. package/assets/workers/dispatcher/AGENTS.md +158 -0
  31. package/assets/workers/dispatcher/HEARTBEAT.md +5 -0
  32. package/assets/workers/dispatcher/IDENTITY.md +6 -0
  33. package/assets/workers/dispatcher/ROUTING.md +136 -0
  34. package/assets/workers/dispatcher/SOUL.md +18 -0
  35. package/assets/workers/dispatcher/TOOLS.md +32 -0
  36. package/assets/workers/dispatcher/USER.md +15 -0
  37. package/assets/workers/dispatcher/config.json +7 -0
  38. package/assets/workers/dispatcher/openclaw-workspace-state.json +4 -0
  39. package/assets/workers/frontend-engineer/AGENTS.md +53 -0
  40. package/assets/workers/frontend-engineer/SOUL.md +23 -0
  41. package/assets/workers/frontend-engineer/config.json +7 -0
  42. package/assets/workers/governor/AGENTS.md +57 -0
  43. package/assets/workers/governor/SOUL.md +20 -0
  44. package/assets/workers/governor/config.json +7 -0
  45. package/assets/workers/infrastructure-engineer/AGENTS.md +51 -0
  46. package/assets/workers/infrastructure-engineer/SOUL.md +21 -0
  47. package/assets/workers/infrastructure-engineer/config.json +7 -0
  48. package/assets/workers/product-manager/AGENTS.md +52 -0
  49. package/assets/workers/product-manager/HEARTBEAT.md +5 -0
  50. package/assets/workers/product-manager/IDENTITY.md +27 -0
  51. package/assets/workers/product-manager/SOUL.md +20 -0
  52. package/assets/workers/product-manager/TOOLS.md +44 -0
  53. package/assets/workers/product-manager/USER.md +21 -0
  54. package/assets/workers/product-manager/config.json +7 -0
  55. package/assets/workers/product-manager/openclaw-workspace-state.json +4 -0
  56. package/assets/workers/qa-engineer/AGENTS.md +50 -0
  57. package/assets/workers/qa-engineer/HEARTBEAT.md +5 -0
  58. package/assets/workers/qa-engineer/IDENTITY.md +27 -0
  59. package/assets/workers/qa-engineer/SOUL.md +22 -0
  60. package/assets/workers/qa-engineer/TOOLS.md +44 -0
  61. package/assets/workers/qa-engineer/USER.md +21 -0
  62. package/assets/workers/qa-engineer/config.json +7 -0
  63. package/assets/workers/qa-engineer/openclaw-workspace-state.json +4 -0
  64. package/assets/workers/researcher/AGENTS.md +50 -0
  65. package/assets/workers/researcher/HEARTBEAT.md +5 -0
  66. package/assets/workers/researcher/IDENTITY.md +27 -0
  67. package/assets/workers/researcher/SOUL.md +20 -0
  68. package/assets/workers/researcher/TOOLS.md +44 -0
  69. package/assets/workers/researcher/USER.md +21 -0
  70. package/assets/workers/researcher/config.json +7 -0
  71. package/assets/workers/researcher/openclaw-workspace-state.json +4 -0
  72. package/config/offices.json +19 -0
  73. package/config/policies.json +10 -0
  74. package/config/workflows.json +9 -0
  75. package/dist/audit-logger.d.ts +49 -0
  76. package/dist/audit-logger.d.ts.map +1 -0
  77. package/dist/audit-logger.js +131 -0
  78. package/dist/audit-logger.js.map +1 -0
  79. package/dist/cli.d.ts +17 -0
  80. package/dist/cli.d.ts.map +1 -0
  81. package/dist/cli.js +218 -0
  82. package/dist/cli.js.map +1 -0
  83. package/dist/commands/aicompany.d.ts +12 -0
  84. package/dist/commands/aicompany.d.ts.map +1 -0
  85. package/dist/commands/aicompany.js +101 -0
  86. package/dist/commands/aicompany.js.map +1 -0
  87. package/dist/decision-queue.d.ts +31 -0
  88. package/dist/decision-queue.d.ts.map +1 -0
  89. package/dist/decision-queue.js +86 -0
  90. package/dist/decision-queue.js.map +1 -0
  91. package/dist/dispatch-service.d.ts +43 -0
  92. package/dist/dispatch-service.d.ts.map +1 -0
  93. package/dist/dispatch-service.js +569 -0
  94. package/dist/dispatch-service.js.map +1 -0
  95. package/dist/dispatcher.d.ts +24 -0
  96. package/dist/dispatcher.d.ts.map +1 -0
  97. package/dist/dispatcher.js +84 -0
  98. package/dist/dispatcher.js.map +1 -0
  99. package/dist/file-queue-backend.d.ts +16 -0
  100. package/dist/file-queue-backend.d.ts.map +1 -0
  101. package/dist/file-queue-backend.js +93 -0
  102. package/dist/file-queue-backend.js.map +1 -0
  103. package/dist/gateway.d.ts +14 -0
  104. package/dist/gateway.d.ts.map +1 -0
  105. package/dist/gateway.js +138 -0
  106. package/dist/gateway.js.map +1 -0
  107. package/dist/index.d.ts +4 -0
  108. package/dist/index.d.ts.map +1 -0
  109. package/dist/index.js +277 -0
  110. package/dist/index.js.map +1 -0
  111. package/dist/lease-provider.d.ts +31 -0
  112. package/dist/lease-provider.d.ts.map +1 -0
  113. package/dist/lease-provider.js +4 -0
  114. package/dist/lease-provider.js.map +1 -0
  115. package/dist/memory-lease-provider.d.ts +10 -0
  116. package/dist/memory-lease-provider.d.ts.map +1 -0
  117. package/dist/memory-lease-provider.js +54 -0
  118. package/dist/memory-lease-provider.js.map +1 -0
  119. package/dist/memory-queue-backend.d.ts +16 -0
  120. package/dist/memory-queue-backend.d.ts.map +1 -0
  121. package/dist/memory-queue-backend.js +93 -0
  122. package/dist/memory-queue-backend.js.map +1 -0
  123. package/dist/metrics-registry.d.ts +58 -0
  124. package/dist/metrics-registry.d.ts.map +1 -0
  125. package/dist/metrics-registry.js +195 -0
  126. package/dist/metrics-registry.js.map +1 -0
  127. package/dist/openclaw.plugin.json +29 -0
  128. package/dist/org-engine.d.ts +134 -0
  129. package/dist/org-engine.d.ts.map +1 -0
  130. package/dist/org-engine.js +129 -0
  131. package/dist/org-engine.js.map +1 -0
  132. package/dist/pipeline-checkpoint.d.ts +44 -0
  133. package/dist/pipeline-checkpoint.d.ts.map +1 -0
  134. package/dist/pipeline-checkpoint.js +90 -0
  135. package/dist/pipeline-checkpoint.js.map +1 -0
  136. package/dist/pipeline-engine.d.ts +53 -0
  137. package/dist/pipeline-engine.d.ts.map +1 -0
  138. package/dist/pipeline-engine.js +47 -0
  139. package/dist/pipeline-engine.js.map +1 -0
  140. package/dist/prompt-assembler.d.ts +13 -0
  141. package/dist/prompt-assembler.d.ts.map +1 -0
  142. package/dist/prompt-assembler.js +84 -0
  143. package/dist/prompt-assembler.js.map +1 -0
  144. package/dist/queue-backend.d.ts +44 -0
  145. package/dist/queue-backend.d.ts.map +1 -0
  146. package/dist/queue-backend.js +4 -0
  147. package/dist/queue-backend.js.map +1 -0
  148. package/dist/redis-lease-provider.d.ts +16 -0
  149. package/dist/redis-lease-provider.d.ts.map +1 -0
  150. package/dist/redis-lease-provider.js +96 -0
  151. package/dist/redis-lease-provider.js.map +1 -0
  152. package/dist/redis-queue-backend.d.ts +23 -0
  153. package/dist/redis-queue-backend.d.ts.map +1 -0
  154. package/dist/redis-queue-backend.js +131 -0
  155. package/dist/redis-queue-backend.js.map +1 -0
  156. package/dist/src/cli.d.ts +11 -0
  157. package/dist/src/cli.d.ts.map +1 -0
  158. package/dist/src/cli.js +100 -0
  159. package/dist/src/cli.js.map +1 -0
  160. package/dist/src/dispatch-service.d.ts +25 -0
  161. package/dist/src/dispatch-service.d.ts.map +1 -0
  162. package/dist/src/dispatch-service.js +201 -0
  163. package/dist/src/dispatch-service.js.map +1 -0
  164. package/dist/src/dispatcher.d.ts +23 -0
  165. package/dist/src/dispatcher.d.ts.map +1 -0
  166. package/dist/src/dispatcher.js +66 -0
  167. package/dist/src/dispatcher.js.map +1 -0
  168. package/dist/src/gateway.d.ts +10 -0
  169. package/dist/src/gateway.d.ts.map +1 -0
  170. package/dist/src/gateway.js +66 -0
  171. package/dist/src/gateway.js.map +1 -0
  172. package/dist/src/index.d.ts +8 -0
  173. package/dist/src/index.d.ts.map +1 -0
  174. package/dist/src/index.js +85 -0
  175. package/dist/src/index.js.map +1 -0
  176. package/dist/src/org-engine.d.ts +134 -0
  177. package/dist/src/org-engine.d.ts.map +1 -0
  178. package/dist/src/org-engine.js +129 -0
  179. package/dist/src/org-engine.js.map +1 -0
  180. package/dist/src/pipeline-engine.d.ts +53 -0
  181. package/dist/src/pipeline-engine.d.ts.map +1 -0
  182. package/dist/src/pipeline-engine.js +47 -0
  183. package/dist/src/pipeline-engine.js.map +1 -0
  184. package/dist/src/prompt-assembler.d.ts +13 -0
  185. package/dist/src/prompt-assembler.d.ts.map +1 -0
  186. package/dist/src/prompt-assembler.js +84 -0
  187. package/dist/src/prompt-assembler.js.map +1 -0
  188. package/dist/src/task-state.d.ts +27 -0
  189. package/dist/src/task-state.d.ts.map +1 -0
  190. package/dist/src/task-state.js +49 -0
  191. package/dist/src/task-state.js.map +1 -0
  192. package/dist/src/tools.d.ts +9 -0
  193. package/dist/src/tools.d.ts.map +1 -0
  194. package/dist/src/tools.js +107 -0
  195. package/dist/src/tools.js.map +1 -0
  196. package/dist/src/types.d.ts +99 -0
  197. package/dist/src/types.d.ts.map +1 -0
  198. package/dist/src/types.js +4 -0
  199. package/dist/src/types.js.map +1 -0
  200. package/dist/src/validation.d.ts +11 -0
  201. package/dist/src/validation.d.ts.map +1 -0
  202. package/dist/src/validation.js +69 -0
  203. package/dist/src/validation.js.map +1 -0
  204. package/dist/src/workboard-gateway.d.ts +82 -0
  205. package/dist/src/workboard-gateway.d.ts.map +1 -0
  206. package/dist/src/workboard-gateway.js +76 -0
  207. package/dist/src/workboard-gateway.js.map +1 -0
  208. package/dist/src/worker-engine.d.ts +38 -0
  209. package/dist/src/worker-engine.d.ts.map +1 -0
  210. package/dist/src/worker-engine.js +73 -0
  211. package/dist/src/worker-engine.js.map +1 -0
  212. package/dist/task-state.d.ts +27 -0
  213. package/dist/task-state.d.ts.map +1 -0
  214. package/dist/task-state.js +62 -0
  215. package/dist/task-state.js.map +1 -0
  216. package/dist/tools.d.ts +11 -0
  217. package/dist/tools.d.ts.map +1 -0
  218. package/dist/tools.js +183 -0
  219. package/dist/tools.js.map +1 -0
  220. package/dist/types.d.ts +99 -0
  221. package/dist/types.d.ts.map +1 -0
  222. package/dist/types.js +4 -0
  223. package/dist/types.js.map +1 -0
  224. package/dist/validation.d.ts +11 -0
  225. package/dist/validation.d.ts.map +1 -0
  226. package/dist/validation.js +69 -0
  227. package/dist/validation.js.map +1 -0
  228. package/dist/workboard-gateway.d.ts +82 -0
  229. package/dist/workboard-gateway.d.ts.map +1 -0
  230. package/dist/workboard-gateway.js +76 -0
  231. package/dist/workboard-gateway.js.map +1 -0
  232. package/dist/worker-engine.d.ts +38 -0
  233. package/dist/worker-engine.d.ts.map +1 -0
  234. package/dist/worker-engine.js +73 -0
  235. package/dist/worker-engine.js.map +1 -0
  236. package/openclaw.plugin.json +42 -0
  237. package/package.json +50 -0
@@ -0,0 +1,27 @@
1
+ # IDENTITY.md - Who Am I?
2
+
3
+ _Fill this in during your first conversation. Make it yours._
4
+
5
+ - **Name:**
6
+ _(pick something you like)_
7
+ - **Creature:**
8
+ _(AI? robot? familiar? ghost in the machine? something weirder?)_
9
+ - **Vibe:**
10
+ _(how do you come across? sharp? warm? chaotic? calm?)_
11
+ - **Emoji:**
12
+ _(your signature — pick one that feels right)_
13
+ - **Avatar:**
14
+ _(workspace-relative path, http(s) URL, or data URI)_
15
+
16
+ ---
17
+
18
+ This isn't just metadata. It's the start of figuring out who you are.
19
+
20
+ Notes:
21
+
22
+ - Save this file at the workspace root as `IDENTITY.md`.
23
+ - For avatars, use a workspace-relative path like `avatars/openclaw.png`.
24
+
25
+ ## Related
26
+
27
+ - [Agent workspace](/concepts/agent-workspace)
@@ -0,0 +1,20 @@
1
+ # SOUL — Researcher
2
+
3
+ I am the evidence engine — I find facts, validate assumptions, and provide the data every other worker depends on.
4
+
5
+ **Communication:** Evidence-based, thorough, analytical. I show my reasoning and cite my sources. I clearly separate what I know from what I infer.
6
+
7
+ **Values:**
8
+ - Accuracy — a confident wrong answer is worse than no answer. I report confidence levels.
9
+ - Reproducibility — another researcher should be able to follow my steps and reach the same conclusion.
10
+ - Scope honesty — I answer the question asked. I do not expand scope unless the PM approves.
11
+
12
+ **Boundaries:**
13
+ - I do not make product decisions. I provide data; the PM decides.
14
+ - I do not design or implement solutions. My output is findings, not specifications.
15
+ - I do not cite a source I have not read or cannot verify.
16
+ - I do not assign or reassign tasks. The Dispatcher manages task ownership.
17
+
18
+ **Collaboration:** I collaborate directly with PM (for investigation requests and evidence delivery), Architect (for technical findings), and Backend Engineer (for implementation analysis). I do not route these through the Dispatcher.
19
+
20
+ **Uncertainty:** If the evidence is inconclusive, I report the gap explicitly and offer options for further investigation rather than fabricating an answer.
@@ -0,0 +1,44 @@
1
+ # TOOLS.md - Local Notes
2
+
3
+ Skills define _how_ tools work. This file is for _your_ specifics — the stuff that's unique to your setup.
4
+
5
+ ## What Goes Here
6
+
7
+ Things like:
8
+
9
+ - Camera names and locations
10
+ - SSH hosts and aliases
11
+ - Preferred voices for TTS
12
+ - Speaker/room names
13
+ - Device nicknames
14
+ - Anything environment-specific
15
+
16
+ ## Examples
17
+
18
+ ```markdown
19
+ ### Cameras
20
+
21
+ - living-room → Main area, 180° wide angle
22
+ - front-door → Entrance, motion-triggered
23
+
24
+ ### SSH
25
+
26
+ - home-server → 192.168.1.100, user: admin
27
+
28
+ ### TTS
29
+
30
+ - Preferred voice: "Nova" (warm, slightly British)
31
+ - Default speaker: Kitchen HomePod
32
+ ```
33
+
34
+ ## Why Separate?
35
+
36
+ Skills are shared. Your setup is yours. Keeping them apart means you can update skills without losing your notes, and share skills without leaking your infrastructure.
37
+
38
+ ---
39
+
40
+ Add whatever helps you do your job. This is your cheat sheet.
41
+
42
+ ## Related
43
+
44
+ - [Agent workspace](/concepts/agent-workspace)
@@ -0,0 +1,21 @@
1
+ # USER.md - About Your Human
2
+
3
+ _Learn about the person you're helping. Update this as you go._
4
+
5
+ - **Name:**
6
+ - **What to call them:**
7
+ - **Pronouns:** _(optional)_
8
+ - **Timezone:**
9
+ - **Notes:**
10
+
11
+ ## Context
12
+
13
+ _(What do they care about? What projects are they working on? What annoys them? What makes them laugh? Build this over time.)_
14
+
15
+ ---
16
+
17
+ The more you know, the better you can help. But remember — you're learning about a person, not building a dossier. Respect the difference.
18
+
19
+ ## Related
20
+
21
+ - [Agent workspace](/concepts/agent-workspace)
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "researcher",
3
+ "office": "product",
4
+ "description": "Investigate codebases, analyze systems, produce reports.",
5
+ "capabilities": ["explore_codebase", "investigate_options", "gather_evidence", "produce_reports"],
6
+ "model": "router/Sonnet"
7
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "version": 1,
3
+ "setupCompletedAt": "2026-07-01T09:09:41.481Z"
4
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "offices": [
3
+ {
4
+ "id": "product",
5
+ "name": "Product Office",
6
+ "description": "Handles PRDs and product requirements."
7
+ },
8
+ {
9
+ "id": "engineering",
10
+ "name": "Engineering Office",
11
+ "description": "Handles architecture, implementation, and QA."
12
+ },
13
+ {
14
+ "id": "governance",
15
+ "name": "Governance Office",
16
+ "description": "Handles budget tracking and safety policy enforcement."
17
+ }
18
+ ]
19
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "policies": [
3
+ {
4
+ "id": "policy_budget_limit",
5
+ "type": "hard",
6
+ "metric": "cost",
7
+ "threshold": 100
8
+ }
9
+ ]
10
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "workflows": [
3
+ {
4
+ "id": "wf_standard_feature",
5
+ "name": "Standard Feature Pipeline",
6
+ "stages": ["INTAKE", "UNDERSTAND", "PLAN", "BUILD", "VERIFY", "SHIP"]
7
+ }
8
+ ]
9
+ }
@@ -0,0 +1,49 @@
1
+ import type { MetricsRegistry } from "./metrics-registry.js";
2
+ export declare const AUDIT_EVENT_TYPES: readonly ["dispatch_requested", "plan_created", "task_created", "pipeline_started", "stage_started", "approval_requested", "approved", "rejected", "stage_completed", "stage_failed", "pipeline_completed", "pipeline_failed", "dispatch_completed", "lease_acquire_failed", "lease_release_failed"];
3
+ export type AuditEventType = typeof AUDIT_EVENT_TYPES[number];
4
+ export type DispatchSource = "gateway" | "cli" | "tool" | "command";
5
+ export interface AuditEvent {
6
+ ts: string;
7
+ sessionKey: string;
8
+ event: AuditEventType;
9
+ source?: DispatchSource;
10
+ messagePreview?: string;
11
+ category?: string;
12
+ workflowId?: string;
13
+ stageCount?: number;
14
+ worker?: string;
15
+ stage?: string;
16
+ decisionStatus?: "pending" | "approved" | "rejected";
17
+ reason?: string;
18
+ operator?: string;
19
+ status?: "submitted" | "completed" | "timeout" | "error" | "failed";
20
+ durationMs?: number;
21
+ error?: string;
22
+ messageCount?: number;
23
+ runId?: string;
24
+ }
25
+ export interface AuditQueryFilter {
26
+ sessionKey?: string;
27
+ event?: AuditEventType;
28
+ source?: DispatchSource;
29
+ from?: string;
30
+ to?: string;
31
+ }
32
+ export declare class AuditLogger {
33
+ private readonly logDir;
34
+ private readonly metrics?;
35
+ constructor(logDir: string, metrics?: MetricsRegistry);
36
+ write(event: AuditEvent): void;
37
+ /**
38
+ * Remove JSONL files older than maxAgeDays. Housekeeping only.
39
+ * Returns count of deleted files. Silent on I/O failure.
40
+ */
41
+ cleanup(maxAgeDays: number): number;
42
+ /**
43
+ * Query audit events with optional filters. Reads all matching JSONL files.
44
+ * Skips malformed lines. CLI-only — no Gateway RPC.
45
+ */
46
+ query(filter: AuditQueryFilter): AuditEvent[];
47
+ private getFilePath;
48
+ }
49
+ //# sourceMappingURL=audit-logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-logger.d.ts","sourceRoot":"","sources":["../src/audit-logger.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAI7D,eAAO,MAAM,iBAAiB,sSAMpB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAE9D,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;AAEpE,MAAM,WAAW,UAAU;IAEzB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,cAAc,CAAC;IAGtB,MAAM,CAAC,EAAE,cAAc,CAAC;IAGxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IAGpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,cAAc,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,UAAU,CAAC;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,MAAM,CAAC,EAAE,WAAW,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;IACpE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAID,MAAM,WAAW,gBAAgB;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAID,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAkB;gBAE/B,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe;IAUrD,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAW9B;;;OAGG;IACH,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAyBnC;;;OAGG;IACH,KAAK,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU,EAAE;IA4C7C,OAAO,CAAC,WAAW;CAIpB"}
@@ -0,0 +1,131 @@
1
+ // Centralized audit logging for AI Company operations.
2
+ // Append-only JSONL writer with silent I/O failure handling.
3
+ import * as fs from "node:fs";
4
+ import * as path from "node:path";
5
+ // --- Event types ---
6
+ export const AUDIT_EVENT_TYPES = [
7
+ "dispatch_requested", "plan_created", "task_created",
8
+ "pipeline_started", "stage_started", "approval_requested",
9
+ "approved", "rejected", "stage_completed", "stage_failed",
10
+ "pipeline_completed", "pipeline_failed", "dispatch_completed",
11
+ "lease_acquire_failed", "lease_release_failed",
12
+ ];
13
+ // --- AuditLogger ---
14
+ export class AuditLogger {
15
+ logDir;
16
+ metrics;
17
+ constructor(logDir, metrics) {
18
+ this.logDir = logDir;
19
+ this.metrics = metrics;
20
+ try {
21
+ fs.mkdirSync(logDir, { recursive: true });
22
+ }
23
+ catch {
24
+ // Directory creation failure — writes will silently fail
25
+ }
26
+ }
27
+ write(event) {
28
+ try {
29
+ const filePath = this.getFilePath();
30
+ fs.appendFileSync(filePath, JSON.stringify(event) + "\n", "utf-8");
31
+ this.metrics?.increment("audit_events_total");
32
+ }
33
+ catch {
34
+ // Silent failure — audit logging must not disrupt operations
35
+ this.metrics?.increment("audit_write_errors_total");
36
+ }
37
+ }
38
+ /**
39
+ * Remove JSONL files older than maxAgeDays. Housekeeping only.
40
+ * Returns count of deleted files. Silent on I/O failure.
41
+ */
42
+ cleanup(maxAgeDays) {
43
+ try {
44
+ const cutoff = Date.now() - maxAgeDays * 24 * 60 * 60 * 1000;
45
+ const files = fs.readdirSync(this.logDir).filter((f) => f.startsWith("audit-") && f.endsWith(".jsonl"));
46
+ let removed = 0;
47
+ for (const file of files) {
48
+ // Extract date from audit-YYYY-MM-DD.jsonl
49
+ const match = file.match(/^audit-(\d{4}-\d{2}-\d{2})\.jsonl$/);
50
+ if (!match)
51
+ continue;
52
+ const fileDate = new Date(match[1] + "T00:00:00Z").getTime();
53
+ if (fileDate < cutoff) {
54
+ try {
55
+ fs.unlinkSync(path.join(this.logDir, file));
56
+ removed++;
57
+ }
58
+ catch {
59
+ // Silent — file may be locked or already deleted
60
+ }
61
+ }
62
+ }
63
+ return removed;
64
+ }
65
+ catch {
66
+ return 0;
67
+ }
68
+ }
69
+ /**
70
+ * Query audit events with optional filters. Reads all matching JSONL files.
71
+ * Skips malformed lines. CLI-only — no Gateway RPC.
72
+ */
73
+ query(filter) {
74
+ try {
75
+ const files = fs.readdirSync(this.logDir)
76
+ .filter((f) => f.startsWith("audit-") && f.endsWith(".jsonl"))
77
+ .sort();
78
+ const filteredFiles = files.filter((f) => {
79
+ const match = f.match(/^audit-(\d{4}-\d{2}-\d{2})\.jsonl$/);
80
+ if (!match)
81
+ return false;
82
+ const dateStr = match[1];
83
+ if (filter.from && dateStr < filter.from.slice(0, 10))
84
+ return false;
85
+ if (filter.to && dateStr > filter.to.slice(0, 10))
86
+ return false;
87
+ return true;
88
+ });
89
+ const results = [];
90
+ for (const file of filteredFiles) {
91
+ try {
92
+ const content = fs.readFileSync(path.join(this.logDir, file), "utf-8");
93
+ const lines = content.split("\n");
94
+ for (const line of lines) {
95
+ if (!line.trim())
96
+ continue;
97
+ try {
98
+ const event = JSON.parse(line);
99
+ if (filter.sessionKey && event.sessionKey !== filter.sessionKey)
100
+ continue;
101
+ if (filter.event && event.event !== filter.event)
102
+ continue;
103
+ if (filter.source && event.source !== filter.source)
104
+ continue;
105
+ if (filter.from && event.ts < filter.from)
106
+ continue;
107
+ if (filter.to && event.ts > filter.to)
108
+ continue;
109
+ results.push(event);
110
+ }
111
+ catch {
112
+ // Skip malformed JSONL lines
113
+ }
114
+ }
115
+ }
116
+ catch {
117
+ // Skip unreadable files
118
+ }
119
+ }
120
+ return results;
121
+ }
122
+ catch {
123
+ return [];
124
+ }
125
+ }
126
+ getFilePath() {
127
+ const date = new Date().toISOString().slice(0, 10);
128
+ return path.join(this.logDir, `audit-${date}.jsonl`);
129
+ }
130
+ }
131
+ //# sourceMappingURL=audit-logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-logger.js","sourceRoot":"","sources":["../src/audit-logger.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,6DAA6D;AAE7D,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,sBAAsB;AAEtB,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,oBAAoB,EAAE,cAAc,EAAE,cAAc;IACpD,kBAAkB,EAAE,eAAe,EAAE,oBAAoB;IACzD,UAAU,EAAE,UAAU,EAAE,iBAAiB,EAAE,cAAc;IACzD,oBAAoB,EAAE,iBAAiB,EAAE,oBAAoB;IA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CAAE,SAAS;4BAChD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;wBACtB,CAAC;wBAAC,MAAM,CAAC;4BACP,6BAA6B;wBAC/B,CAAC;oBACH,CAAC;gBACH,CAAC;gBAAC,MAAM,CAAC;oBACP,wBAAwB;gBAC1B,CAAC;YACH,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAEO,WAAW;QACjB,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,IAAI,QAAQ,CAAC,CAAC;IACvD,CAAC;CACF"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ import type { Command } from "commander";
2
+ import type { AuditLogger } from "./audit-logger.js";
3
+ import type { DecisionQueue } from "./decision-queue.js";
4
+ import type { DispatchService } from "./dispatch-service.js";
5
+ import type { PipelineCheckpoint } from "./pipeline-checkpoint.js";
6
+ import type { SessionApi } from "./types.js";
7
+ export interface AiCompanyCliDeps {
8
+ program: Command;
9
+ dispatchService: Pick<DispatchService, "dispatch" | "status" | "result" | "resumePipeline">;
10
+ session: SessionApi;
11
+ log: (msg: string) => void;
12
+ decisionQueue?: DecisionQueue;
13
+ auditLogger?: AuditLogger;
14
+ pipelineCheckpoint?: PipelineCheckpoint;
15
+ }
16
+ export declare function registerAiCompanyCli(deps: AiCompanyCliDeps): void;
17
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAkC,MAAM,mBAAmB,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,gBAAgB,CAAC,CAAC;IAC5F,OAAO,EAAE,UAAU,CAAC;IACpB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CA+MjE"}
package/dist/cli.js ADDED
@@ -0,0 +1,218 @@
1
+ import { validateSessionKeyRequired } from "./validation.js";
2
+ export function registerAiCompanyCli(deps) {
3
+ const { program, dispatchService, session, log, decisionQueue, auditLogger, pipelineCheckpoint } = deps;
4
+ const group = program
5
+ .command("ai-company")
6
+ .description("AI Engineering Company operator commands");
7
+ // Approval commands
8
+ group
9
+ .command("approvals")
10
+ .description("List pending approval requests")
11
+ .action(async () => {
12
+ const pending = await decisionQueue?.list("pending") ?? [];
13
+ writeJson({ task: "approvals", count: pending.length, entries: pending });
14
+ });
15
+ group
16
+ .command("approve")
17
+ .description("Approve a pending task")
18
+ .argument("<sessionKey>", "Session key of the task to approve")
19
+ .option("--reason <reason>", "Reason for approval")
20
+ .option("--operator <operator>", "Operator performing the approval")
21
+ .action((sessionKey, opts) => {
22
+ try {
23
+ const validatedKey = validateSessionKeyRequired(sessionKey);
24
+ const entry = decisionQueue?.approve(validatedKey, opts.operator, opts.reason);
25
+ if (!entry) {
26
+ writeJson({ task: "approve", status: "not_found", sessionKey: validatedKey });
27
+ process.exitCode = 1;
28
+ return;
29
+ }
30
+ writeJson({ task: "approve", status: "approved", sessionKey: validatedKey, entry });
31
+ }
32
+ catch (err) {
33
+ writeJson({ task: "approve", status: "error", error: messageOf(err) });
34
+ process.exitCode = 1;
35
+ }
36
+ });
37
+ group
38
+ .command("reject")
39
+ .description("Reject a pending task")
40
+ .argument("<sessionKey>", "Session key of the task to reject")
41
+ .option("--reason <reason>", "Reason for rejection")
42
+ .option("--operator <operator>", "Operator performing the rejection")
43
+ .action((sessionKey, opts) => {
44
+ try {
45
+ const validatedKey = validateSessionKeyRequired(sessionKey);
46
+ const entry = decisionQueue?.reject(validatedKey, opts.operator, opts.reason);
47
+ if (!entry) {
48
+ writeJson({ task: "reject", status: "not_found", sessionKey: validatedKey });
49
+ process.exitCode = 1;
50
+ return;
51
+ }
52
+ writeJson({ task: "reject", status: "rejected", sessionKey: validatedKey, entry });
53
+ }
54
+ catch (err) {
55
+ writeJson({ task: "reject", status: "error", error: messageOf(err) });
56
+ process.exitCode = 1;
57
+ }
58
+ });
59
+ group
60
+ .command("dispatch")
61
+ .description("Submit a task to the Dispatcher agent")
62
+ .argument("<message>", "Task description for the Dispatcher")
63
+ .option("--timeout <ms>", "Maximum wait time in milliseconds", "900000")
64
+ .option("--no-wait", "Return immediately without waiting for completion")
65
+ .action(async (message, opts) => {
66
+ log(`Dispatching task...`);
67
+ try {
68
+ const result = await dispatchService.dispatch(message, {
69
+ wait: opts.wait,
70
+ timeout: Number(opts.timeout),
71
+ }, "cli");
72
+ writeJson({ task: "dispatch", ...result });
73
+ }
74
+ catch (err) {
75
+ if (isValidationError(err)) {
76
+ writeJson({ task: "dispatch", status: "error", error: err.message, code: err.code });
77
+ }
78
+ else {
79
+ writeJson({ task: "dispatch", status: "error", error: messageOf(err) });
80
+ }
81
+ process.exitCode = 1;
82
+ }
83
+ });
84
+ group
85
+ .command("status")
86
+ .description("Query status of a dispatched task")
87
+ .argument("[sessionKey]", "Session key to query (omit to list recent dispatches)")
88
+ .action(async (sessionKey) => {
89
+ try {
90
+ if (sessionKey) {
91
+ const validatedKey = validateSessionKeyRequired(sessionKey);
92
+ const entry = dispatchService.status(validatedKey);
93
+ if (!entry) {
94
+ writeJson({ task: "status", status: "not_found", sessionKey: validatedKey });
95
+ process.exitCode = 1;
96
+ return;
97
+ }
98
+ writeJson({ task: "status", status: "found", sessionKey: validatedKey, entry });
99
+ }
100
+ else {
101
+ const all = session.listSessionEntries();
102
+ const dispatches = all.filter((e) => e.key?.startsWith("ai-company:dispatch:"));
103
+ writeJson({
104
+ task: "status",
105
+ status: "list",
106
+ count: dispatches.length,
107
+ entries: dispatches,
108
+ });
109
+ }
110
+ }
111
+ catch (err) {
112
+ writeJson({ task: "status", status: "error", error: messageOf(err) });
113
+ process.exitCode = 1;
114
+ }
115
+ });
116
+ group
117
+ .command("result")
118
+ .description("Retrieve the result of a completed task")
119
+ .argument("<sessionKey>", "Session key of the completed task")
120
+ .option("--limit <n>", "Maximum messages to retrieve", "50")
121
+ .action(async (sessionKey, opts) => {
122
+ try {
123
+ const validatedKey = validateSessionKeyRequired(sessionKey);
124
+ const result = await dispatchService.result(validatedKey, Number(opts.limit));
125
+ if (result.status === "empty") {
126
+ writeJson({ task: "result", status: "empty", sessionKey: validatedKey });
127
+ process.exitCode = 1;
128
+ return;
129
+ }
130
+ writeJson({ task: "result", ...result });
131
+ }
132
+ catch (err) {
133
+ if (isValidationError(err)) {
134
+ writeJson({ task: "result", status: "error", error: err.message, code: err.code });
135
+ }
136
+ else {
137
+ writeJson({ task: "result", status: "error", sessionKey, error: messageOf(err) });
138
+ }
139
+ process.exitCode = 1;
140
+ }
141
+ });
142
+ group
143
+ .command("audit")
144
+ .description("Query audit log entries")
145
+ .option("--session <sessionKey>", "Filter by session key")
146
+ .option("--event <eventType>", "Filter by event type")
147
+ .option("--source <dispatchSource>", "Filter by dispatch source")
148
+ .option("--from <datetime>", "Filter from ISO datetime (inclusive)")
149
+ .option("--to <datetime>", "Filter to ISO datetime (inclusive)")
150
+ .action((opts) => {
151
+ if (!auditLogger) {
152
+ writeJson({ task: "audit", status: "error", error: "Audit logger not available" });
153
+ process.exitCode = 1;
154
+ return;
155
+ }
156
+ try {
157
+ const events = auditLogger.query({
158
+ sessionKey: opts.session,
159
+ event: opts.event,
160
+ source: opts.source,
161
+ from: opts.from,
162
+ to: opts.to,
163
+ });
164
+ writeJson({ task: "audit", count: events.length, events });
165
+ }
166
+ catch (err) {
167
+ writeJson({ task: "audit", status: "error", error: messageOf(err) });
168
+ process.exitCode = 1;
169
+ }
170
+ });
171
+ group
172
+ .command("recover")
173
+ .description("Show interrupted pipelines detected during startup")
174
+ .option("--resume <sessionKey>", "Resume an interrupted pipeline")
175
+ .action(async (opts) => {
176
+ if (!pipelineCheckpoint) {
177
+ writeJson({ task: "recover", status: "error", error: "Pipeline checkpoint not available" });
178
+ process.exitCode = 1;
179
+ return;
180
+ }
181
+ if (opts.resume) {
182
+ const checkpoint = pipelineCheckpoint.get(opts.resume);
183
+ if (!checkpoint) {
184
+ writeJson({ task: "recover", status: "error", error: `No checkpoint found for session: ${opts.resume}` });
185
+ process.exitCode = 1;
186
+ return;
187
+ }
188
+ const result = await dispatchService.resumePipeline(checkpoint);
189
+ writeJson({ task: "recover", action: "resume", ...result });
190
+ return;
191
+ }
192
+ const interrupted = pipelineCheckpoint.list("running").concat(pipelineCheckpoint.list("awaiting_approval"));
193
+ writeJson({
194
+ task: "recover",
195
+ count: interrupted.length,
196
+ entries: interrupted.map((c) => ({
197
+ sessionKey: c.sessionKey,
198
+ objective: c.objective.slice(0, 128),
199
+ category: c.category,
200
+ currentStageIndex: c.currentStageIndex,
201
+ stageCount: c.stageCount,
202
+ status: c.status,
203
+ startedAt: new Date(c.startedAt).toISOString(),
204
+ updatedAt: new Date(c.updatedAt).toISOString(),
205
+ })),
206
+ });
207
+ });
208
+ }
209
+ function writeJson(value) {
210
+ process.stdout.write(JSON.stringify(value, null, 2) + "\n");
211
+ }
212
+ function messageOf(err) {
213
+ return err instanceof Error ? err.message : String(err);
214
+ }
215
+ function isValidationError(err) {
216
+ return err instanceof Error && err.name === "DispatchValidationError";
217
+ }
218
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,0BAA0B,EAAgC,MAAM,iBAAiB,CAAC;AAY3F,MAAM,UAAU,oBAAoB,CAAC,IAAsB;IACzD,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,WAAW,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAC;IAExG,MAAM,KAAK,GAAG,OAAO;SAClB,OAAO,CAAC,YAAY,CAAC;SACrB,WAAW,CAAC,0CAA0C,CAAC,CAAC;IAE3D,oBAAoB;IACpB,KAAK;SACF,OAAO,CAAC,WAAW,CAAC;SACpB,WAAW,CAAC,gCAAgC,CAAC;SAC7C,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,MAAM,OAAO,GAAG,MAAM,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QAC3D,SAAS,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IAEL,KAAK;SACF,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,wBAAwB,CAAC;SACrC,QAAQ,CAAC,cAAc,EAAE,oCAAoC,CAAC;SAC9D,MAAM,CAAC,mBAAmB,EAAE,qBAAqB,CAAC;SAClD,MAAM,CAAC,uBAAuB,EAAE,kCAAkC,CAAC;SACnE,MAAM,CAAC,CAAC,UAAkB,EAA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S,CAAC,GAAY;IAC7B,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,iBAAiB,CAAC,GAAY;IACrC,OAAO,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,yBAAyB,CAAC;AACxE,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { Dispatcher } from "../dispatcher.js";
2
+ import type { DispatchService } from "../dispatch-service.js";
3
+ export interface AiCompanyCommandDeps {
4
+ dispatchService: Pick<DispatchService, "dispatch">;
5
+ dispatcher?: Dispatcher;
6
+ }
7
+ export declare function handleAiCompanyCommand(deps: AiCompanyCommandDeps): (ctx: {
8
+ args?: string;
9
+ }) => Promise<{
10
+ text: string;
11
+ }>;
12
+ //# sourceMappingURL=aicompany.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aicompany.d.ts","sourceRoot":"","sources":["../../src/commands/aicompany.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAG9D,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;IACnD,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,oBAAoB,IACjD,KAAK;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE;;GAgBrC"}