ai-control-center 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 (154) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +584 -0
  3. package/bin/aicc.js +772 -0
  4. package/lib/actions/approve.js +71 -0
  5. package/lib/actions/assign-project.js +132 -0
  6. package/lib/actions/browser-test.js +64 -0
  7. package/lib/actions/cleanup.js +174 -0
  8. package/lib/actions/debug.js +298 -0
  9. package/lib/actions/deploy.js +1229 -0
  10. package/lib/actions/fix-bug.js +134 -0
  11. package/lib/actions/new-feature.js +255 -0
  12. package/lib/actions/reject.js +307 -0
  13. package/lib/actions/review.js +706 -0
  14. package/lib/actions/status.js +47 -0
  15. package/lib/agents/browser-qa-agent.js +611 -0
  16. package/lib/agents/payment-agent.js +116 -0
  17. package/lib/agents/suggestion-agent.js +88 -0
  18. package/lib/cli.js +303 -0
  19. package/lib/config.js +243 -0
  20. package/lib/hub/hub-server.js +440 -0
  21. package/lib/hub/project-poller.js +75 -0
  22. package/lib/hub/skill-registry.js +89 -0
  23. package/lib/hub/state-aggregator.js +204 -0
  24. package/lib/index.js +471 -0
  25. package/lib/init/doctor.js +523 -0
  26. package/lib/init/presets.js +222 -0
  27. package/lib/init/skill-fetcher.js +77 -0
  28. package/lib/init/wizard.js +973 -0
  29. package/lib/integrations/codex-runner.js +128 -0
  30. package/lib/integrations/github-actions.js +248 -0
  31. package/lib/integrations/github-reporter.js +229 -0
  32. package/lib/integrations/screenshot-store.js +102 -0
  33. package/lib/openclaw/bridge.js +650 -0
  34. package/lib/openclaw/generate-skill.js +235 -0
  35. package/lib/openclaw/openclaw.json +64 -0
  36. package/lib/orchestrator/autonomous-loop.js +429 -0
  37. package/lib/orchestrator/thread-triggers.js +63 -0
  38. package/lib/roleplay/agent-messenger.js +75 -0
  39. package/lib/roleplay/discussion-threads.js +303 -0
  40. package/lib/roleplay/health-monitor.js +121 -0
  41. package/lib/roleplay/pm-agent.js +513 -0
  42. package/lib/roleplay/roleplay-config.js +25 -0
  43. package/lib/roleplay/room.js +164 -0
  44. package/lib/shared/action-runner.js +2330 -0
  45. package/lib/shared/event-bus.js +185 -0
  46. package/lib/slack/bot.js +378 -0
  47. package/lib/telegram/bot.js +416 -0
  48. package/lib/telegram/commands.js +1267 -0
  49. package/lib/telegram/keyboards.js +113 -0
  50. package/lib/telegram/notifications.js +247 -0
  51. package/lib/twitch/bot.js +354 -0
  52. package/lib/twitch/commands.js +302 -0
  53. package/lib/twitch/notifications.js +63 -0
  54. package/lib/utils/achievements.js +191 -0
  55. package/lib/utils/activity-log.js +182 -0
  56. package/lib/utils/agent-leaderboard.js +119 -0
  57. package/lib/utils/audit-logger.js +232 -0
  58. package/lib/utils/codebase-context.js +288 -0
  59. package/lib/utils/codebase-indexer.js +381 -0
  60. package/lib/utils/config-schema.js +230 -0
  61. package/lib/utils/context-compressor.js +172 -0
  62. package/lib/utils/correlation.js +63 -0
  63. package/lib/utils/cost-tracker.js +423 -0
  64. package/lib/utils/cron-scheduler.js +53 -0
  65. package/lib/utils/db-adapter.js +293 -0
  66. package/lib/utils/display.js +272 -0
  67. package/lib/utils/errors.js +116 -0
  68. package/lib/utils/format.js +134 -0
  69. package/lib/utils/intent-engine.js +464 -0
  70. package/lib/utils/mcp-client.js +238 -0
  71. package/lib/utils/model-ab-test.js +164 -0
  72. package/lib/utils/notify.js +122 -0
  73. package/lib/utils/persona-loader.js +80 -0
  74. package/lib/utils/pipeline-lock.js +73 -0
  75. package/lib/utils/pipeline.js +214 -0
  76. package/lib/utils/plugin-runner.js +234 -0
  77. package/lib/utils/rate-limiter.js +84 -0
  78. package/lib/utils/rbac.js +74 -0
  79. package/lib/utils/runner.js +1809 -0
  80. package/lib/utils/security.js +191 -0
  81. package/lib/utils/self-healer.js +144 -0
  82. package/lib/utils/skill-loader.js +255 -0
  83. package/lib/utils/spinner.js +132 -0
  84. package/lib/utils/stage-queue.js +50 -0
  85. package/lib/utils/state-machine.js +89 -0
  86. package/lib/utils/status-bar.js +327 -0
  87. package/lib/utils/token-estimator.js +101 -0
  88. package/lib/utils/ux-analyzer.js +101 -0
  89. package/lib/utils/webhook-emitter.js +83 -0
  90. package/lib/web/public/css/styles.css +417 -0
  91. package/lib/web/public/dark-mode.js +44 -0
  92. package/lib/web/public/hub/kanban.html +206 -0
  93. package/lib/web/public/index.html +45 -0
  94. package/lib/web/public/js/app.js +71 -0
  95. package/lib/web/public/js/ask.js +110 -0
  96. package/lib/web/public/js/dashboard.js +165 -0
  97. package/lib/web/public/js/deploy.js +72 -0
  98. package/lib/web/public/js/feature.js +79 -0
  99. package/lib/web/public/js/health.js +65 -0
  100. package/lib/web/public/js/logs.js +93 -0
  101. package/lib/web/public/js/review.js +123 -0
  102. package/lib/web/public/js/ws-client.js +82 -0
  103. package/lib/web/public/office/css/office.css +678 -0
  104. package/lib/web/public/office/index.html +148 -0
  105. package/lib/web/public/office/js/achievements-ui.js +117 -0
  106. package/lib/web/public/office/js/character.js +1056 -0
  107. package/lib/web/public/office/js/chat-bubbles.js +177 -0
  108. package/lib/web/public/office/js/cost-overlay.js +123 -0
  109. package/lib/web/public/office/js/day-night.js +68 -0
  110. package/lib/web/public/office/js/effects.js +632 -0
  111. package/lib/web/public/office/js/engine.js +146 -0
  112. package/lib/web/public/office/js/feature-ticket.js +216 -0
  113. package/lib/web/public/office/js/hub-client.js +60 -0
  114. package/lib/web/public/office/js/main.js +1757 -0
  115. package/lib/web/public/office/js/office-layout.js +1524 -0
  116. package/lib/web/public/office/js/pathfinding.js +144 -0
  117. package/lib/web/public/office/js/pixel-sprites.js +1454 -0
  118. package/lib/web/public/office/js/progress-bars.js +117 -0
  119. package/lib/web/public/office/js/replay.js +191 -0
  120. package/lib/web/public/office/js/sound-effects.js +91 -0
  121. package/lib/web/public/office/js/sprite-renderer.js +211 -0
  122. package/lib/web/public/office/js/stamina-system.js +89 -0
  123. package/lib/web/public/office/js/ui.js +107 -0
  124. package/lib/web/public/onboarding/index.html +243 -0
  125. package/lib/web/public/timeline/index.html +195 -0
  126. package/lib/web/routes/api.js +499 -0
  127. package/lib/web/routes/logs.js +20 -0
  128. package/lib/web/routes/metrics.js +99 -0
  129. package/lib/web/server.js +183 -0
  130. package/lib/web/ws/handler.js +65 -0
  131. package/package.json +67 -0
  132. package/templates/agent-architect.md +69 -0
  133. package/templates/agent-gemini-pm.md +49 -0
  134. package/templates/agent-gemini-reviewer.md +52 -0
  135. package/templates/copilot-instructions.md +36 -0
  136. package/templates/pipelines/mobile.json +27 -0
  137. package/templates/pipelines/nodejs-api.json +27 -0
  138. package/templates/pipelines/python.json +27 -0
  139. package/templates/pipelines/react.json +27 -0
  140. package/templates/pipelines/salesforce.json +27 -0
  141. package/templates/role-gemini.md +97 -0
  142. package/templates/skill-architect.md +114 -0
  143. package/templates/skill-browser-qa.md +50 -0
  144. package/templates/skill-bug-from-qa.md +58 -0
  145. package/templates/skill-chatbot.md +93 -0
  146. package/templates/skill-implement.md +78 -0
  147. package/templates/skill-openclaw.md +174 -0
  148. package/templates/skill-payment.md +110 -0
  149. package/templates/skill-pm-spec.md +77 -0
  150. package/templates/skill-requirement-capture.md +97 -0
  151. package/templates/skill-review.md +108 -0
  152. package/templates/skill-reviewer-qa.md +44 -0
  153. package/templates/skill-suggestion.md +45 -0
  154. package/templates/skill-template.md +142 -0
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Structured Error Codes for AI Control Center.
3
+ *
4
+ * Error Code Reference:
5
+ * E001 AI_TIMEOUT — AI subprocess exceeded its time limit
6
+ * E002 AI_RATE_LIMIT — Temporary rate limit (429) from AI provider
7
+ * E003 AI_CAPACITY — Daily quota/capacity exhausted for AI provider
8
+ * E004 AI_CIRCUIT_OPEN — Circuit breaker is OPEN for provider, skipping
9
+ * E005 PIPELINE_STALL — Pipeline stage stuck with no progress
10
+ * E006 TOKEN_BUDGET — Token budget exceeded for pipeline run
11
+ * E007 CHECKPOINT_CORRUPT — Checkpoint file failed integrity check
12
+ * E008 STATE_WRITE_FAIL — Failed to write state file atomically
13
+ * E009 SESSION_CORRUPT — AI session file is corrupt or unreadable
14
+ * E010 PROVIDER_CHAIN_EXHAUSTED — All models/providers in fallback chain failed
15
+ * E011 RESPONSE_INVALID — AI response failed validation (empty/truncated)
16
+ * E012 GEMINI_HUNG — Gemini process produced no output (watchdog kill)
17
+ */
18
+
19
+ export const ErrorCodes = {
20
+ AI_TIMEOUT: 'E001',
21
+ AI_RATE_LIMIT: 'E002',
22
+ AI_CAPACITY: 'E003',
23
+ AI_CIRCUIT_OPEN: 'E004',
24
+ PIPELINE_STALL: 'E005',
25
+ TOKEN_BUDGET: 'E006',
26
+ CHECKPOINT_CORRUPT: 'E007',
27
+ STATE_WRITE_FAIL: 'E008',
28
+ SESSION_CORRUPT: 'E009',
29
+ PROVIDER_CHAIN_EXHAUSTED: 'E010',
30
+ RESPONSE_INVALID: 'E011',
31
+ GEMINI_HUNG: 'E012',
32
+ };
33
+
34
+ /**
35
+ * Base error class for AICC with structured error code.
36
+ */
37
+ export class AIControlError extends Error {
38
+ constructor(code, message) {
39
+ super(`[${code}] ${message}`);
40
+ this.name = 'AIControlError';
41
+ this.code = code;
42
+ }
43
+ }
44
+
45
+ /**
46
+ * AI subprocess exceeded its configured timeout.
47
+ */
48
+ export class AITimeoutError extends AIControlError {
49
+ constructor(agent, timeoutMs, command = '') {
50
+ super(ErrorCodes.AI_TIMEOUT, `TIMEOUT: ${agent} hung after ${Math.round(timeoutMs / 1000)}s`);
51
+ this.name = 'AITimeoutError';
52
+ this.agent = agent;
53
+ this.timeoutMs = timeoutMs;
54
+ this.command = command;
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Circuit breaker is OPEN — provider is temporarily blocked.
60
+ */
61
+ export class CircuitOpenError extends AIControlError {
62
+ constructor(provider) {
63
+ super(ErrorCodes.AI_CIRCUIT_OPEN, `Circuit breaker OPEN for ${provider} — skipping`);
64
+ this.name = 'CircuitOpenError';
65
+ this.provider = provider;
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Token budget exceeded for a pipeline run.
71
+ */
72
+ export class TokenBudgetError extends AIControlError {
73
+ constructor(used, limit, featureId) {
74
+ super(ErrorCodes.TOKEN_BUDGET, `Token budget exceeded: ${used.toLocaleString()}/${limit.toLocaleString()} for ${featureId}`);
75
+ this.name = 'TokenBudgetError';
76
+ this.used = used;
77
+ this.limit = limit;
78
+ this.featureId = featureId;
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Checkpoint integrity check failed.
84
+ */
85
+ export class CheckpointCorruptError extends AIControlError {
86
+ constructor(featureId, stage) {
87
+ super(ErrorCodes.CHECKPOINT_CORRUPT, `Checkpoint corrupt for ${featureId}/${stage}`);
88
+ this.name = 'CheckpointCorruptError';
89
+ this.featureId = featureId;
90
+ this.stage = stage;
91
+ }
92
+ }
93
+
94
+ /**
95
+ * AI response failed validation (empty, truncated, missing required sections).
96
+ */
97
+ export class ResponseValidationError extends AIControlError {
98
+ constructor(agent, reason) {
99
+ super(ErrorCodes.RESPONSE_INVALID, `${agent} response validation failed: ${reason}`);
100
+ this.name = 'ResponseValidationError';
101
+ this.agent = agent;
102
+ this.reason = reason;
103
+ }
104
+ }
105
+
106
+ /**
107
+ * Pipeline stalled — no stage change for extended period.
108
+ */
109
+ export class PipelineStallError extends AIControlError {
110
+ constructor(stage, minutesElapsed) {
111
+ super(ErrorCodes.PIPELINE_STALL, `Pipeline stalled on "${stage}" for ${minutesElapsed} minutes`);
112
+ this.name = 'PipelineStallError';
113
+ this.stage = stage;
114
+ this.minutesElapsed = minutesElapsed;
115
+ }
116
+ }
@@ -0,0 +1,134 @@
1
+ /**
2
+ * lib/utils/format.js — Per-platform message formatting.
3
+ *
4
+ * The AI always outputs CommonMark-style markdown. This module converts
5
+ * that to whatever each chat platform expects before sending.
6
+ *
7
+ * Supported platforms: telegram | whatsapp | twitch | plain
8
+ */
9
+
10
+ // ─── Telegram ─────────────────────────────────────────────────────────────────
11
+ // Telegram HTML mode is the most reliable:
12
+ // - Doesn't require escaping every special char (unlike MarkdownV2)
13
+ // - Supports: <b> <i> <s> <u> <code> <pre> <a>
14
+
15
+ /**
16
+ * Convert CommonMark markdown to Telegram HTML.
17
+ * Handles the most common AI output patterns.
18
+ */
19
+ export function markdownToTelegramHTML(text) {
20
+ if (!text) return '';
21
+
22
+ let result = text;
23
+
24
+ // 1. Extract and protect code blocks first (avoid mangling their content)
25
+ const codeBlocks = [];
26
+ result = result.replace(/```(\w*)\n?([\s\S]*?)```/g, (_, lang, code) => {
27
+ const idx = codeBlocks.length;
28
+ codeBlocks.push(`<pre><code>${escapeHTML(code.trim())}</code></pre>`);
29
+ return `\x00CODE${idx}\x00`;
30
+ });
31
+
32
+ // 2. Protect inline code
33
+ const inlineCodes = [];
34
+ result = result.replace(/`([^`\n]+)`/g, (_, code) => {
35
+ const idx = inlineCodes.length;
36
+ inlineCodes.push(`<code>${escapeHTML(code)}</code>`);
37
+ return `\x00INLINE${idx}\x00`;
38
+ });
39
+
40
+ // 3. Escape HTML special chars in regular text
41
+ result = escapeHTML(result);
42
+
43
+ // 4. Headers → bold line
44
+ result = result.replace(/^#{1,3} (.+)$/gm, '<b>$1</b>');
45
+
46
+ // 5. Bold: **text** or __text__
47
+ result = result.replace(/\*\*([^*\n]+)\*\*/g, '<b>$1</b>');
48
+ result = result.replace(/__([^_\n]+)__/g, '<b>$1</b>');
49
+
50
+ // 6. Italic: *text* or _text_ (single, not touching word boundaries weirdly)
51
+ result = result.replace(/\*([^*\n]+)\*/g, '<i>$1</i>');
52
+ result = result.replace(/(?<!\w)_([^_\n]+)_(?!\w)/g, '<i>$1</i>');
53
+
54
+ // 7. Strikethrough: ~~text~~
55
+ result = result.replace(/~~([^~\n]+)~~/g, '<s>$1</s>');
56
+
57
+ // 8. Horizontal rules → divider
58
+ result = result.replace(/^[-*_]{3,}$/gm, '─────────────────');
59
+
60
+ // 9. Restore code blocks and inline code
61
+ result = result.replace(/\x00CODE(\d+)\x00/g, (_, i) => codeBlocks[+i]);
62
+ result = result.replace(/\x00INLINE(\d+)\x00/g, (_, i) => inlineCodes[+i]);
63
+
64
+ return result.trim();
65
+ }
66
+
67
+ function escapeHTML(str) {
68
+ return str
69
+ .replace(/&/g, '&amp;')
70
+ .replace(/</g, '&lt;')
71
+ .replace(/>/g, '&gt;');
72
+ }
73
+
74
+ // ─── WhatsApp ─────────────────────────────────────────────────────────────────
75
+ // WhatsApp uses: *bold*, _italic_, ~strikethrough~, ```code```
76
+
77
+ export function markdownToWhatsApp(text) {
78
+ if (!text) return '';
79
+ let result = text;
80
+
81
+ // Code blocks stay as-is (WhatsApp supports ```)
82
+ // Bold: **text** → *text*
83
+ result = result.replace(/\*\*([^*\n]+)\*\*/g, '*$1*');
84
+ result = result.replace(/__([^_\n]+)__/g, '*$1*');
85
+ // Italic: *text* (single) → _text_
86
+ result = result.replace(/(?<![*])\*([^*\n]+)\*(?![*])/g, '_$1_');
87
+ // Strikethrough: ~~text~~ → ~text~
88
+ result = result.replace(/~~([^~\n]+)~~/g, '~$1~');
89
+ // Headers → bold
90
+ result = result.replace(/^#{1,3} (.+)$/gm, '*$1*');
91
+
92
+ return result.trim();
93
+ }
94
+
95
+ // ─── Twitch ───────────────────────────────────────────────────────────────────
96
+ // Twitch chat has no markdown — strip all formatting, keep text clean
97
+
98
+ export function markdownToTwitch(text) {
99
+ if (!text) return '';
100
+ return text
101
+ .replace(/```[\w]*\n?([\s\S]*?)```/g, '$1') // code blocks → plain
102
+ .replace(/`([^`]+)`/g, '$1') // inline code → plain
103
+ .replace(/\*\*([^*]+)\*\*/g, '$1') // bold → plain
104
+ .replace(/__([^_]+)__/g, '$1')
105
+ .replace(/\*([^*]+)\*/g, '$1')
106
+ .replace(/_([^_]+)_/g, '$1')
107
+ .replace(/~~([^~]+)~~/g, '$1')
108
+ .replace(/^#{1,6} /gm, '') // headers → plain
109
+ .replace(/^\s*[-*+] /gm, '• ') // bullets → •
110
+ .trim();
111
+ }
112
+
113
+ // ─── Platform dispatcher ─────────────────────────────────────────────────────
114
+
115
+ /**
116
+ * Format AI markdown output for a specific chat platform.
117
+ * Returns { text, options } ready to pass to the platform SDK.
118
+ *
119
+ * @param {string} text Raw markdown from AI
120
+ * @param {string} platform 'telegram' | 'whatsapp' | 'twitch' | 'plain'
121
+ * @returns {{ text: string, options: object }}
122
+ */
123
+ export function formatForPlatform(text, platform = 'telegram') {
124
+ switch (platform) {
125
+ case 'telegram':
126
+ return { text: markdownToTelegramHTML(text), options: { parse_mode: 'HTML' } };
127
+ case 'whatsapp':
128
+ return { text: markdownToWhatsApp(text), options: {} };
129
+ case 'twitch':
130
+ return { text: markdownToTwitch(text), options: {} };
131
+ default:
132
+ return { text, options: {} };
133
+ }
134
+ }