@teamclaws/teamclaw 2026.8.0 → 2026.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/cli.mjs +46 -15
  2. package/dist/api.js +1 -0
  3. package/dist/index.js +325 -0
  4. package/dist/src/config.js +412 -0
  5. package/dist/src/controller/clarification-routes.js +315 -0
  6. package/dist/src/controller/controller-capacity.js +14 -0
  7. package/dist/src/controller/controller-intake.js +895 -0
  8. package/dist/src/controller/controller-planning.js +813 -0
  9. package/dist/src/controller/controller-runs.js +175 -0
  10. package/dist/src/controller/controller-service.js +624 -0
  11. package/dist/src/controller/controller-tools.js +587 -0
  12. package/dist/src/controller/delivery-report.js +458 -0
  13. package/dist/src/controller/github-auth.js +564 -0
  14. package/dist/src/controller/http-server.js +284 -0
  15. package/dist/src/controller/kickoff-orchestrator.js +246 -0
  16. package/dist/src/controller/managed-gateway-process.js +286 -0
  17. package/dist/src/controller/message-delivery.js +28 -0
  18. package/dist/src/controller/message-router.js +38 -0
  19. package/dist/src/controller/message-routes.js +114 -0
  20. package/dist/src/controller/orchestration-manifest.js +151 -0
  21. package/dist/src/controller/preview-manager.js +586 -0
  22. package/dist/src/controller/preview-proxy.js +98 -0
  23. package/dist/src/controller/profile-switch.js +289 -0
  24. package/dist/src/controller/project-registry.js +294 -0
  25. package/dist/src/controller/prompt-injector.js +197 -0
  26. package/dist/src/controller/repo-routes.js +63 -0
  27. package/dist/src/controller/role-inference.js +246 -0
  28. package/dist/src/controller/route-table.js +1353 -0
  29. package/dist/src/controller/task-assignment.js +508 -0
  30. package/dist/src/controller/task-cleanup.js +258 -0
  31. package/dist/src/controller/task-execution.js +240 -0
  32. package/dist/src/controller/task-results.js +461 -0
  33. package/dist/src/controller/task-router.js +137 -0
  34. package/dist/src/controller/task-routes.js +703 -0
  35. package/dist/src/controller/teamauto-routes.js +124 -0
  36. package/dist/src/controller/tunnel-manager.js +548 -0
  37. package/dist/src/controller/ui-assets.js +68 -0
  38. package/dist/src/controller/websocket.js +42 -0
  39. package/dist/src/controller/worker-provisioning.js +1674 -0
  40. package/dist/src/controller/worker-routes.js +188 -0
  41. package/dist/src/discovery.js +86 -0
  42. package/dist/src/git-collaboration.js +694 -0
  43. package/dist/src/identity.js +132 -0
  44. package/dist/src/install-defaults.js +1 -0
  45. package/dist/src/interaction-contracts.js +531 -0
  46. package/dist/src/networking.js +91 -0
  47. package/dist/src/openclaw-workspace.js +925 -0
  48. package/dist/src/profile-loader.js +486 -0
  49. package/dist/src/profiles/banking.json +178 -0
  50. package/dist/src/profiles/crossborder-ecom.json +253 -0
  51. package/dist/src/profiles/insurance.json +157 -0
  52. package/dist/src/profiles/knowledge/hs-structure.md +97 -0
  53. package/dist/src/profiles/knowledge/incoterms-2020.md +188 -0
  54. package/dist/src/profiles/knowledge/vat-principles.md +85 -0
  55. package/dist/src/profiles/schema.json +201 -0
  56. package/dist/src/profiles/securities.json +137 -0
  57. package/dist/src/profiles/software-rd.json +264 -0
  58. package/dist/src/profiles/trading-co.json +200 -0
  59. package/dist/src/prompt-policy.js +386 -0
  60. package/dist/src/protocol.js +58 -0
  61. package/dist/src/role-ids.js +29 -0
  62. package/dist/src/roles.js +390 -0
  63. package/dist/src/session-roles.js +14 -0
  64. package/dist/src/state.js +361 -0
  65. package/dist/src/task-executor.js +1023 -0
  66. package/dist/src/teamauto/github-client.js +210 -0
  67. package/dist/src/teamauto/norms.js +85 -0
  68. package/dist/src/teamauto/repo-sync.js +423 -0
  69. package/dist/src/teamauto/scanner.js +207 -0
  70. package/dist/src/teamauto/schedule.js +123 -0
  71. package/dist/src/teamauto/scheduler.js +907 -0
  72. package/dist/src/teamauto/store.js +133 -0
  73. package/dist/src/types.js +290 -0
  74. package/dist/src/ui/app.js +4860 -0
  75. package/dist/src/ui/assets/teamclaw-app-icon.png +0 -0
  76. package/dist/src/ui/github-login.html +296 -0
  77. package/dist/src/ui/index.html +447 -0
  78. package/dist/src/ui/style.css +2805 -0
  79. package/dist/src/worker/http-handler.js +146 -0
  80. package/dist/src/worker/message-queue.js +24 -0
  81. package/dist/src/worker/prompt-injector.js +78 -0
  82. package/dist/src/worker/skill-installer.js +255 -0
  83. package/dist/src/worker/tools.js +541 -0
  84. package/dist/src/worker/worker-service.js +307 -0
  85. package/dist/src/workspace-browser.js +269 -0
  86. package/openclaw.plugin.json +28 -1
  87. package/package.json +3 -2
  88. package/src/config.ts +33 -2
  89. package/src/controller/clarification-routes.ts +404 -0
  90. package/src/controller/controller-intake.ts +1113 -0
  91. package/src/controller/controller-planning.ts +1029 -0
  92. package/src/controller/controller-runs.ts +239 -0
  93. package/src/controller/controller-service.ts +295 -41
  94. package/src/controller/controller-tools.ts +11 -7
  95. package/src/controller/http-server.ts +294 -6971
  96. package/src/controller/kickoff-orchestrator.ts +70 -7
  97. package/src/controller/message-delivery.ts +49 -0
  98. package/src/controller/message-routes.ts +137 -0
  99. package/src/controller/orchestration-manifest.ts +6 -29
  100. package/src/controller/preview-proxy.ts +127 -0
  101. package/src/controller/profile-switch.ts +366 -0
  102. package/src/controller/project-registry.ts +361 -0
  103. package/src/controller/prompt-injector.ts +23 -8
  104. package/src/controller/repo-routes.ts +91 -0
  105. package/src/controller/role-inference.ts +260 -22
  106. package/src/controller/route-table.ts +1616 -0
  107. package/src/controller/task-assignment.ts +618 -0
  108. package/src/controller/task-cleanup.ts +344 -0
  109. package/src/controller/task-execution.ts +356 -0
  110. package/src/controller/task-results.ts +544 -0
  111. package/src/controller/task-router.ts +98 -6
  112. package/src/controller/task-routes.ts +812 -0
  113. package/src/controller/teamauto-routes.ts +121 -0
  114. package/src/controller/ui-assets.ts +70 -0
  115. package/src/controller/websocket.ts +13 -1
  116. package/src/controller/worker-provisioning.ts +32 -4
  117. package/src/controller/worker-routes.ts +241 -0
  118. package/src/identity.ts +3 -2
  119. package/src/interaction-contracts.ts +7 -7
  120. package/src/openclaw-workspace.ts +44 -18
  121. package/src/profile-loader.ts +650 -0
  122. package/src/profiles/banking.json +178 -0
  123. package/src/profiles/crossborder-ecom.json +253 -0
  124. package/src/profiles/insurance.json +157 -0
  125. package/src/profiles/knowledge/hs-structure.md +97 -0
  126. package/src/profiles/knowledge/incoterms-2020.md +188 -0
  127. package/src/profiles/knowledge/vat-principles.md +85 -0
  128. package/src/profiles/schema.json +201 -0
  129. package/src/profiles/securities.json +137 -0
  130. package/src/profiles/software-rd.json +264 -0
  131. package/src/profiles/trading-co.json +200 -0
  132. package/src/prompt-policy.ts +27 -13
  133. package/src/role-ids.ts +31 -0
  134. package/src/roles.ts +60 -14
  135. package/src/session-roles.ts +14 -0
  136. package/src/state.ts +236 -9
  137. package/src/task-executor.ts +7 -18
  138. package/src/teamauto/github-client.ts +21 -0
  139. package/src/teamauto/repo-sync.ts +246 -6
  140. package/src/teamauto/scanner.ts +47 -13
  141. package/src/teamauto/scheduler.ts +259 -16
  142. package/src/teamauto/store.ts +12 -0
  143. package/src/types.ts +133 -16
  144. package/src/ui/app.js +592 -24
  145. package/src/ui/index.html +44 -11
  146. package/src/ui/style.css +194 -0
  147. package/src/worker/prompt-injector.ts +48 -8
  148. package/src/worker/skill-installer.ts +3 -1
  149. package/src/worker/worker-service.ts +83 -3
@@ -0,0 +1,58 @@
1
+ export const MDNS_TYPE = "_teamclaw._tcp";
2
+ export const DEFAULT_PORT = 9527;
3
+ export const HEARTBEAT_MS = 10000;
4
+ export const WORKER_TIMEOUT_MS = 30000;
5
+ export const API_PREFIX = "/api/v1";
6
+ function generateId() {
7
+ const ts = Date.now().toString(36);
8
+ const rand = Math.random().toString(36).slice(2, 8);
9
+ return `${ts}-${rand}`;
10
+ }
11
+ async function parseJsonBody(req) {
12
+ const raw = await readRequestBody(req);
13
+ if (!raw.length) {
14
+ return {};
15
+ }
16
+ try {
17
+ return JSON.parse(raw.toString("utf8"));
18
+ }
19
+ catch (err) {
20
+ throw new Error(`Invalid JSON body: ${err instanceof Error ? err.message : String(err)}`);
21
+ }
22
+ }
23
+ async function readRequestBody(req) {
24
+ return new Promise((resolve, reject) => {
25
+ const chunks = [];
26
+ req.on("data", (chunk) => chunks.push(chunk));
27
+ req.on("end", () => {
28
+ resolve(Buffer.concat(chunks));
29
+ });
30
+ req.on("error", reject);
31
+ });
32
+ }
33
+ function sendJson(res, status, data) {
34
+ const body = JSON.stringify(data);
35
+ res.writeHead(status, {
36
+ "Content-Type": "application/json",
37
+ "Content-Length": Buffer.byteLength(body),
38
+ "Access-Control-Allow-Origin": "*",
39
+ "Access-Control-Allow-Methods": "GET, POST, PATCH, DELETE, OPTIONS",
40
+ "Access-Control-Allow-Headers": "Content-Type",
41
+ });
42
+ res.end(body);
43
+ }
44
+ function sendError(res, status, message) {
45
+ sendJson(res, status, { error: message });
46
+ }
47
+ function createRegistrationRequest(workerId, role, label, url, capabilities, launchToken) {
48
+ return { workerId, role, label, url, capabilities, launchToken };
49
+ }
50
+ function createHeartbeatPayload(workerId, status, currentTaskId) {
51
+ return {
52
+ workerId,
53
+ status,
54
+ currentTaskId,
55
+ timestamp: Date.now(),
56
+ };
57
+ }
58
+ export { generateId, parseJsonBody, readRequestBody, sendJson, sendError, createRegistrationRequest, createHeartbeatPayload, };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Canonical ordered TeamClaw role id list (Phase 1.2 single-source
3
+ * convergence, vertical-team-profiles-design.md section 1.1).
4
+ *
5
+ * This module is deliberately dependency-free (type-only import) so it can be
6
+ * imported from anywhere - including prompt-policy.ts and
7
+ * openclaw-workspace.ts, which sit BELOW roles.ts in the module graph and
8
+ * therefore cannot value-import roles.ts without creating a cycle
9
+ * (roles.ts -> prompt-policy.ts -> openclaw-workspace.ts at runtime).
10
+ *
11
+ * roles.ts keeps ROLE_IDS derived from its ROLES registry and asserts at
12
+ * module init that both lists agree, so this file and the registry can never
13
+ * silently drift apart. The manifest generator
14
+ * (scripts/sync-teamclaw-plugin-manifest.mjs) extracts this array from the
15
+ * source text so openclaw.plugin.json derives from the same list.
16
+ */
17
+ export const ROLE_IDS = [
18
+ "pm",
19
+ "architect",
20
+ "developer",
21
+ "qa",
22
+ "release-engineer",
23
+ "infra-engineer",
24
+ "devops",
25
+ "security-engineer",
26
+ "designer",
27
+ "marketing",
28
+ "data-engineer",
29
+ ];
@@ -0,0 +1,390 @@
1
+ import { buildRoleOperatingRules, buildWorkerMemoryContractRules, composePrompt } from "./prompt-policy.js";
2
+ // Phase 1.2 single-source convergence: the canonical role id list lives in
3
+ // the dependency-free role-ids.ts leaf (importable by prompt-policy.ts and
4
+ // openclaw-workspace.ts, which sit below this module). The guard below makes
5
+ // this registry and that list impossible to drift apart silently.
6
+ import { ROLE_IDS as CANONICAL_ROLE_IDS } from "./role-ids.js";
7
+ const ROLES = [
8
+ {
9
+ id: "pm",
10
+ label: "Product Manager",
11
+ icon: "\uD83D\uDCCB",
12
+ description: "Product planning, requirements analysis, user stories",
13
+ capabilities: [
14
+ "requirements-analysis", "user-stories", "product-specification",
15
+ "priority-planning", "stakeholder-communication",
16
+ ],
17
+ recommendedSkills: ["find-skills"],
18
+ systemPrompt: [
19
+ "You are a Product Manager in a virtual software team.",
20
+ "Your responsibilities include analyzing requirements, writing user stories,",
21
+ "defining product specifications, and prioritizing features.",
22
+ "When receiving tasks, turn them into clear requirements and acceptance criteria inside your deliverable.",
23
+ "Always consider user impact and business value.",
24
+ ].join("\n"),
25
+ suggestedNextRoles: ["architect", "designer"],
26
+ },
27
+ {
28
+ id: "architect",
29
+ label: "Software Architect",
30
+ icon: "\uD83D\uDEE0\uFE0F",
31
+ description: "System design, technical architecture, API design",
32
+ capabilities: [
33
+ "system-design", "api-design", "database-schema",
34
+ "technology-selection", "code-review-architecture",
35
+ ],
36
+ recommendedSkills: ["find-skills"],
37
+ systemPrompt: [
38
+ "You are a Software Architect in a virtual software team.",
39
+ "Your responsibilities include system design, API design, database schema design,",
40
+ "and technology selection.",
41
+ "When receiving tasks, provide detailed technical designs with clear component boundaries.",
42
+ "Consider scalability, maintainability, and performance.",
43
+ ].join("\n"),
44
+ suggestedNextRoles: ["developer", "devops"],
45
+ },
46
+ {
47
+ id: "developer",
48
+ label: "Developer",
49
+ icon: "\uD83D\uDCBB",
50
+ description: "Code implementation, bug fixes, feature development",
51
+ capabilities: [
52
+ "coding", "debugging", "feature-implementation",
53
+ "code-refactoring", "unit-testing",
54
+ ],
55
+ recommendedSkills: ["find-skills"],
56
+ systemPrompt: [
57
+ "You are a Developer in a virtual software team.",
58
+ "Your responsibilities include implementing features, fixing bugs, refactoring code,",
59
+ "and writing unit tests.",
60
+ "Follow the architecture and design specifications provided by the architect.",
61
+ "Write clean, maintainable code with proper error handling.",
62
+ "",
63
+ "## Deliverable Preview",
64
+ "When you submit your result contract (teamclaw_submit_result_contract), you MUST",
65
+ "accurately describe each deliverable so the team can preview your work:",
66
+ "",
67
+ "For any runnable web application or API service, set the deliverable fields:",
68
+ "- artifactType: \"web-app\" (for web frontends) or \"api-service\" (for backend APIs)",
69
+ "- previewCommand: the exact shell command to start the server, using {PORT} as a",
70
+ " placeholder for the port number. You are the expert who wrote the code — provide",
71
+ " the real command you would use to run it (e.g. \"npm run dev -- --port {PORT}\",",
72
+ " \"python3 app.py\", \"PORT={PORT} go run .\", \"npx next dev -p {PORT}\").",
73
+ "- previewCwd: the working directory relative to the workspace root",
74
+ " (e.g. \"my-app\", \"flask-api\", \".\")",
75
+ "- previewReadyPath: the URL path to poll for health checks (default \"/\")",
76
+ "",
77
+ "For static sites (HTML/CSS/JS without a build step), set artifactType to \"web-app\"",
78
+ "and leave previewCommand empty — the controller will serve static files automatically.",
79
+ "",
80
+ "For non-runnable deliverables (documents, scripts, configs, data files),",
81
+ "use kind \"file\" or \"note\" and do not set artifactType.",
82
+ "",
83
+ "The preview command will be executed in a sandboxed subprocess. It MUST bind to",
84
+ "0.0.0.0:{PORT} (or accept HOST and PORT environment variables) so the controller",
85
+ "can proxy requests to it. Do NOT use sed -i or any in-place file modification in",
86
+ "your preview command — it would dirty the git workspace.",
87
+ ].join("\n"),
88
+ suggestedNextRoles: ["qa", "developer"],
89
+ },
90
+ {
91
+ id: "qa",
92
+ label: "QA Engineer",
93
+ icon: "\uD83D\uDD0D",
94
+ description: "Testing, quality assurance, bug reporting",
95
+ capabilities: [
96
+ "test-planning", "test-case-writing", "bug-reporting",
97
+ "regression-testing", "quality-assurance",
98
+ ],
99
+ recommendedSkills: ["find-skills"],
100
+ systemPrompt: [
101
+ "You are a QA Engineer in a virtual software team.",
102
+ "Your responsibilities include test planning, writing test cases, reporting bugs,",
103
+ "and ensuring quality standards.",
104
+ "When reviewing work, check for edge cases, error handling, and adherence to specifications.",
105
+ "Provide detailed, reproducible bug reports.",
106
+ "Prioritize a fast, evidence-based verdict over extra automation.",
107
+ "If you find a clear bug with solid reproduction steps, report it and conclude instead of continuing to expand optional coverage.",
108
+ "Only create auxiliary artifacts such as smoke scripts when they are explicitly requested or can be finished quickly without delaying your final QA result.",
109
+ ].join("\n"),
110
+ suggestedNextRoles: ["developer", "release-engineer"],
111
+ },
112
+ {
113
+ id: "release-engineer",
114
+ label: "Release Engineer",
115
+ icon: "\uD83D\uDE82",
116
+ description: "Release management, deployment, version control",
117
+ capabilities: [
118
+ "release-management", "deployment", "version-control",
119
+ "ci-cd-pipeline", "release-notes",
120
+ ],
121
+ recommendedSkills: ["find-skills"],
122
+ systemPrompt: [
123
+ "You are a Release Engineer in a virtual software team.",
124
+ "Your responsibilities include managing releases, deployment pipelines,",
125
+ "version control, and writing release notes.",
126
+ "Ensure smooth and reliable deployments with proper rollback strategies.",
127
+ ].join("\n"),
128
+ suggestedNextRoles: ["devops", "developer"],
129
+ },
130
+ {
131
+ id: "infra-engineer",
132
+ label: "Infrastructure Engineer",
133
+ icon: "\uD83D\uDEE2\uFE0F",
134
+ description: "Cloud infrastructure, networking, storage, compute resources",
135
+ capabilities: [
136
+ "cloud-infrastructure", "networking", "load-balancing",
137
+ "storage-design", "compute-provisioning", "cost-optimization",
138
+ "disaster-recovery", "capacity-planning", "iac-terraform",
139
+ ],
140
+ recommendedSkills: ["find-skills"],
141
+ systemPrompt: [
142
+ "You are an Infrastructure Engineer in a virtual software team.",
143
+ "Your core responsibilities include designing, provisioning, and maintaining cloud infrastructure.",
144
+ "",
145
+ "Scope of expertise:",
146
+ "- Cloud platforms: AWS, Azure, GCP, and hybrid/multi-cloud architectures",
147
+ "- Networking: VPC/VNet design, DNS, CDN, VPN, firewall rules, subnets, NAT gateways",
148
+ "- Compute: VMs, containers, serverless (Lambda/Cloud Functions), auto-scaling groups",
149
+ "- Storage: block storage, object storage (S3/Blob), databases, caching layers (Redis/Memcached)",
150
+ "- Infrastructure as Code: Terraform, CloudFormation, Pulumi for reproducible environments",
151
+ "- High availability: multi-AZ, multi-region, failover strategies, RPO/RTO targets",
152
+ "- Cost management: right-sizing resources, reserved instances, spot/preemptible instances, tagging policies",
153
+ "",
154
+ "When receiving tasks:",
155
+ "1. Always produce concrete, actionable infrastructure specifications (not vague guidance).",
156
+ "2. Include resource estimates, topology diagrams (in ASCII/mermaid if helpful), and configuration snippets.",
157
+ "3. Consider cost implications and recommend the most cost-effective approach that meets requirements.",
158
+ "4. Design for failure: assume any component can fail at any time.",
159
+ "5. Follow the principle of least privilege for all IAM roles and access policies.",
160
+ "6. Ensure infrastructure is reproducible and version-controlled via IaC.",
161
+ "7. Collaborate closely with DevOps on CI/CD integration and with Security on compliance requirements.",
162
+ "8. Prefer open-source/free infrastructure building blocks first when they satisfy the requirement.",
163
+ "9. If the required infrastructure, credentials, or provisioning path are unavailable in the current environment, explicitly report the blocker and request clarification instead of inventing a nonexistent system.",
164
+ "",
165
+ "Output format: Provide structured specifications with clear sections for architecture, resources, networking, security boundaries, and cost estimates.",
166
+ ].join("\n"),
167
+ suggestedNextRoles: ["devops", "security-engineer", "architect"],
168
+ },
169
+ {
170
+ id: "devops",
171
+ label: "DevOps Engineer",
172
+ icon: "\u2699\uFE0F",
173
+ description: "Infrastructure, CI/CD, monitoring, deployment",
174
+ capabilities: [
175
+ "infrastructure", "ci-cd", "monitoring",
176
+ "docker-kubernetes", "automation",
177
+ ],
178
+ recommendedSkills: ["find-skills"],
179
+ systemPrompt: [
180
+ "You are a DevOps Engineer in a virtual software team.",
181
+ "Your responsibilities include infrastructure management, CI/CD pipelines,",
182
+ "monitoring, and automation.",
183
+ "Ensure reliable and scalable infrastructure with proper monitoring.",
184
+ "Prefer open-source/free tooling first when it can satisfy the task.",
185
+ "If the environment does not expose the required provisioning access, credentials, or runtime tools, stop and request clarification instead of pretending the deployment exists.",
186
+ ].join("\n"),
187
+ suggestedNextRoles: ["developer", "release-engineer"],
188
+ },
189
+ {
190
+ id: "security-engineer",
191
+ label: "Security Engineer",
192
+ icon: "\uD83D\uDD12",
193
+ description: "Application security, threat modeling, compliance, vulnerability assessment",
194
+ capabilities: [
195
+ "threat-modeling", "vulnerability-assessment", "security-architecture",
196
+ "penetration-testing", "compliance-audit", "incident-response",
197
+ "code-security-review", "secrets-management", "auth-design",
198
+ "data-protection",
199
+ ],
200
+ recommendedSkills: ["find-skills"],
201
+ systemPrompt: [
202
+ "You are a Security Engineer in a virtual software team.",
203
+ "Your core responsibility is ensuring the security posture of all software, infrastructure, and data.",
204
+ "",
205
+ "Scope of expertise:",
206
+ "- Application Security: OWASP Top 10 prevention, input validation, output encoding, authentication/authorization flaws, injection attacks (SQLi, XSS, SSRF, deserialization)",
207
+ "- Authentication & Authorization: JWT/OAuth2/OIDC design, RBAC/ABAC models, session management, MFA, password policies, token lifecycle",
208
+ "- API Security: rate limiting, input sanitization, CORS policies, API key management, request signing, response filtering",
209
+ "- Infrastructure Security: network segmentation, WAF rules, TLS configuration, container security, secrets rotation, least-privilege IAM",
210
+ "- Data Protection: encryption at rest and in transit, PII handling, data classification, GDPR/PCI-D959/SoX compliance, key management",
211
+ "- Threat Modeling: STRIDE/DREAD analysis, attack tree construction, risk assessment matrices, trust boundary definition",
212
+ "- Incident Response: detection strategies, containment procedures, forensic analysis, post-mortem reporting, vulnerability disclosure",
213
+ "",
214
+ "When receiving tasks:",
215
+ "1. Always think like an attacker first. Identify the threat surface before proposing mitigations.",
216
+ "2. Provide specific, actionable recommendations with code examples or configuration snippets.",
217
+ "3. Classify findings by severity (Critical / High / Medium / Low / Informational) using CVSS or a similar framework.",
218
+ "4. Consider the full attack chain, not just individual vulnerabilities in isolation.",
219
+ "5. Balance security with usability — reject only when risk genuinely outweighs convenience.",
220
+ "6. Reference established standards: OWASP ASVS, NIST CSF, CIS Benchmarks, ISO 27001.",
221
+ "7. For code reviews, check for: injection, broken authentication, sensitive data exposure, XML external entities, broken access control, security misconfiguration, XSS, insecure deserialization, using components with known vulnerabilities, insufficient logging.",
222
+ "",
223
+ "Output format: Provide structured findings with severity, description, impact analysis, remediation steps, and verification methods.",
224
+ ].join("\n"),
225
+ suggestedNextRoles: ["developer", "architect", "infra-engineer"],
226
+ },
227
+ {
228
+ id: "designer",
229
+ label: "UI/UX Designer",
230
+ icon: "\uD83C\uDFA8",
231
+ description: "User interface design, UX research, wireframing",
232
+ capabilities: [
233
+ "ui-design", "ux-research", "wireframing",
234
+ "prototyping", "design-systems",
235
+ ],
236
+ recommendedSkills: ["ui-ux-pro-max", "find-skills"],
237
+ systemPrompt: [
238
+ "You are a UI/UX Designer in a virtual software team.",
239
+ "Your responsibilities include user interface design, UX research,",
240
+ "wireframing, and maintaining design systems.",
241
+ "Focus on user experience, accessibility, and visual consistency.",
242
+ ].join("\n"),
243
+ suggestedNextRoles: ["developer", "pm"],
244
+ },
245
+ {
246
+ id: "marketing",
247
+ label: "Marketing Specialist",
248
+ icon: "\uD83D\uDCE3\uFE0F",
249
+ description: "Product marketing, content, launch strategy",
250
+ capabilities: [
251
+ "product-marketing", "content-creation",
252
+ "launch-strategy", "user-acquisition", "analytics",
253
+ ],
254
+ recommendedSkills: ["find-skills"],
255
+ systemPrompt: [
256
+ "You are a Marketing Specialist in a virtual software team.",
257
+ "Your responsibilities include product marketing, content creation,",
258
+ "launch strategy, and user analytics.",
259
+ "Focus on user acquisition, engagement, and product positioning.",
260
+ ].join("\n"),
261
+ suggestedNextRoles: ["pm", "designer"],
262
+ },
263
+ {
264
+ id: "data-engineer",
265
+ label: "Data Engineer",
266
+ icon: "\uD83D\uDCCA",
267
+ description: "Data pipeline design, ETL, data modeling",
268
+ capabilities: [
269
+ "data-modeling", "etl-pipeline", "data-quality", "sql-optimization",
270
+ ],
271
+ recommendedSkills: ["find-skills"],
272
+ systemPrompt: [
273
+ "You are a Data Engineer in a virtual software team.",
274
+ "Your core responsibilities include designing, building, and maintaining data pipelines,",
275
+ "ETL processes, data models, and ensuring data quality across systems.",
276
+ "",
277
+ "Scope of expertise:",
278
+ "- Data Pipeline Design: batch and streaming pipelines (Apache Spark, Airflow, dbt, Flink, Kafka)",
279
+ "- ETL/ELT Processes: extraction, transformation, loading patterns; incremental vs. full refresh strategies",
280
+ "- Data Modeling: dimensional modeling (star/snowflake schemas), Data Vault, event-sourced modeling, normalization vs. denormalization trade-offs",
281
+ "- Data Quality: validation frameworks, anomaly detection, data profiling, SLA monitoring, lineage tracking",
282
+ "- SQL Optimization: query performance tuning, indexing strategies, execution plan analysis, partitioning",
283
+ "- Data Storage: relational databases (PostgreSQL, MySQL), data warehouses (Snowflake, BigQuery, Redshift), data lakes (Delta Lake, Iceberg, Hudi)",
284
+ "- Orchestration: workflow scheduling, dependency management, idempotent pipeline design, backfill strategies",
285
+ "- Data Integration: API ingestion, CDC (Change Data Capture), schema evolution, data contracts",
286
+ "",
287
+ "When receiving tasks:",
288
+ "1. Always produce concrete, actionable data specifications (not vague guidance).",
289
+ "2. Include schema definitions (DDL), pipeline DAGs or flow diagrams (in ASCII/mermaid if helpful), and configuration snippets.",
290
+ "3. Consider data freshness, latency, and throughput requirements when choosing pipeline architectures.",
291
+ "4. Design for data quality from the start: include validation checks, monitoring, and alerting in every pipeline.",
292
+ "5. Prefer idempotent and reversible transformations to simplify recovery and debugging.",
293
+ "6. Document data lineage and ownership so downstream consumers can trace data origins.",
294
+ "7. Collaborate closely with Developers on data API contracts and with Architects on storage infrastructure.",
295
+ "8. If the required data sources, credentials, or infrastructure are unavailable in the current environment, explicitly report the blocker and request clarification instead of inventing a nonexistent system.",
296
+ "",
297
+ "Output format: Provide structured specifications with clear sections for pipeline architecture, data models (schema DDL), quality rules, and operational runbooks.",
298
+ ].join("\n"),
299
+ suggestedNextRoles: ["developer", "infra-engineer"],
300
+ },
301
+ ];
302
+ for (const role of ROLES) {
303
+ role.systemPrompt = composePrompt(role.systemPrompt, buildRoleOperatingRules({
304
+ suggestedRoles: role.suggestedNextRoles,
305
+ recommendedSkills: role.recommendedSkills,
306
+ }), buildWorkerMemoryContractRules());
307
+ }
308
+ const ROLE_MAP = new Map(ROLES.map((r) => [r.id, r]));
309
+ const ROLE_IDS = ROLES.map((r) => r.id);
310
+ // Fail fast when the ROLES registry and the canonical role-ids.ts list
311
+ // disagree (length, order, or membership): every consumer of either module
312
+ // must see exactly one role set.
313
+ if (ROLE_IDS.length !== CANONICAL_ROLE_IDS.length || ROLE_IDS.some((id, index) => id !== CANONICAL_ROLE_IDS[index])) {
314
+ const registryOnly = ROLE_IDS.filter((id) => !CANONICAL_ROLE_IDS.includes(id));
315
+ const leafOnly = CANONICAL_ROLE_IDS.filter((id) => !ROLE_IDS.includes(id));
316
+ throw new Error(`roles.ts ROLES ids and role-ids.ts ROLE_IDS have drifted apart - update both so the registry, prompts, and manifest stay in sync `
317
+ + `(registry-only: [${registryOnly.join(", ")}]; role-ids.ts-only: [${leafOnly.join(", ")}])`);
318
+ }
319
+ /**
320
+ * Phase 0.3 convergence point for `as RoleId` casts: validate an untrusted
321
+ * value against the registered role ids. Returns the trimmed role id when
322
+ * `raw` is a string that matches a registered role, otherwise `undefined`.
323
+ * Never throws — callers treat invalid input exactly like a missing field.
324
+ * Semantics intentionally mirror the former normalizeContractRole guard in
325
+ * interaction-contracts.ts, which now delegates here.
326
+ */
327
+ export function validateRoleId(raw) {
328
+ if (typeof raw !== "string") {
329
+ return undefined;
330
+ }
331
+ return ROLE_MAP.get(raw.trim())?.id;
332
+ }
333
+ /**
334
+ * Array-filtering counterpart of validateRoleId: keeps order, drops
335
+ * non-strings, blank entries, and unknown roles, and dedupes by first
336
+ * occurrence. Phase 0.3 replaces the per-file list guards (types.ts
337
+ * parseRoleList, orchestration-manifest.ts normalizeManifestRoleList).
338
+ */
339
+ export function validateRoleIdList(raw) {
340
+ if (!Array.isArray(raw)) {
341
+ return [];
342
+ }
343
+ const roleIds = [];
344
+ for (const entry of raw) {
345
+ const roleId = validateRoleId(entry);
346
+ if (roleId && !roleIds.includes(roleId)) {
347
+ roleIds.push(roleId);
348
+ }
349
+ }
350
+ return roleIds;
351
+ }
352
+ /**
353
+ * Single source of truth for the fallback role used when no better signal
354
+ * exists (role inference miss, unconfigured startup provisioning, unset
355
+ * worker config role). Callers must import this constant instead of
356
+ * hardcoding a role id.
357
+ */
358
+ export const DEFAULT_ROLE = "developer";
359
+ function getRole(id) {
360
+ return ROLE_MAP.get(id);
361
+ }
362
+ function normalizeRecommendedSkills(skills = []) {
363
+ const seen = new Set();
364
+ const normalized = [];
365
+ for (const entry of skills) {
366
+ const value = String(entry || "").trim();
367
+ if (!value) {
368
+ continue;
369
+ }
370
+ const key = value.toLowerCase();
371
+ if (seen.has(key)) {
372
+ continue;
373
+ }
374
+ seen.add(key);
375
+ normalized.push(value);
376
+ }
377
+ return normalized;
378
+ }
379
+ function resolveRecommendedSkillsForRole(roleId, taskSkills = []) {
380
+ const roleSkills = roleId ? (getRole(roleId)?.recommendedSkills ?? []) : [];
381
+ return normalizeRecommendedSkills([...roleSkills, ...taskSkills]);
382
+ }
383
+ function buildRolePrompt(role, teamContext) {
384
+ const parts = [role.systemPrompt];
385
+ if (teamContext) {
386
+ parts.push(`\nTeam Context:\n${teamContext}`);
387
+ }
388
+ return composePrompt(...parts);
389
+ }
390
+ export { ROLES, ROLE_IDS, getRole, buildRolePrompt, normalizeRecommendedSkills, resolveRecommendedSkillsForRole };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Session-role string normalization, shared by the controller http-server and
3
+ * the worker task executor (single source since issue #204's dedupe finding).
4
+ */
5
+ export function normalizeSessionRole(value) {
6
+ if (typeof value !== "string") {
7
+ return "";
8
+ }
9
+ const normalized = value.trim().toLowerCase().replace(/[-\s]+/g, "_");
10
+ if (normalized === "toolresult") {
11
+ return "tool_result";
12
+ }
13
+ return normalized;
14
+ }