@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,210 @@
1
+ /**
2
+ * Minimal GitHub REST client for TeamAuto: ETag-conditional GETs, light
3
+ * pagination, and the write endpoints we need. All requests ride the stored
4
+ * device-flow token via the auth manager (transparent refresh).
5
+ */
6
+ const API = "https://api.github.com";
7
+ const VERSION = "2026-03-10";
8
+ const USER_AGENT = "teamclaw-teamauto";
9
+ export class GithubClientError extends Error {
10
+ status;
11
+ constructor(message, status) {
12
+ super(message);
13
+ this.name = "GithubClientError";
14
+ this.status = status;
15
+ }
16
+ }
17
+ export function createGithubClient(auth) {
18
+ async function request(method, urlPath, options = {}) {
19
+ const headers = {
20
+ ...(await auth.getAuthHeaders()),
21
+ "User-Agent": USER_AGENT,
22
+ "X-GitHub-Api-Version": VERSION,
23
+ };
24
+ if (options.body !== undefined) {
25
+ headers["Content-Type"] = "application/json";
26
+ }
27
+ const etagKey = options.etagKey ? `${method} ${urlPath}` : undefined;
28
+ if (etagKey && options.etags?.[etagKey]) {
29
+ headers["If-None-Match"] = options.etags[etagKey];
30
+ }
31
+ const response = await fetch(`${API}${urlPath}`, {
32
+ method,
33
+ headers,
34
+ body: options.body === undefined ? undefined : JSON.stringify(options.body),
35
+ signal: AbortSignal.timeout(20_000),
36
+ });
37
+ if (etagKey) {
38
+ const etag = response.headers.get("etag");
39
+ if (etag && options.etags) {
40
+ options.etags[etagKey] = etag;
41
+ }
42
+ }
43
+ if (response.status === 304) {
44
+ return { status: 304, data: null, notModified: true };
45
+ }
46
+ const text = await response.text();
47
+ let data = null;
48
+ if (text) {
49
+ try {
50
+ data = JSON.parse(text);
51
+ }
52
+ catch {
53
+ data = { raw: text.slice(0, 500) };
54
+ }
55
+ }
56
+ if (!response.ok) {
57
+ const message = data?.message ?? `HTTP ${response.status}`;
58
+ throw new GithubClientError(message, response.status);
59
+ }
60
+ return { status: response.status, data, notModified: false };
61
+ }
62
+ async function getJson(urlPath, etags) {
63
+ const { data, notModified } = await request("GET", urlPath, { etagKey: etags ? urlPath : undefined, etags });
64
+ return notModified ? null : data;
65
+ }
66
+ return {
67
+ request,
68
+ async getRepoInfo(owner, repo) {
69
+ const data = await getJson(`/repos/${owner}/${repo}`);
70
+ if (!data) {
71
+ throw new GithubClientError("unexpected 304 without etag", 500);
72
+ }
73
+ const perms = (data.permissions ?? {});
74
+ return {
75
+ fullName: String(data.full_name ?? `${owner}/${repo}`),
76
+ defaultBranch: String(data.default_branch ?? "main"),
77
+ cloneUrl: String(data.clone_url ?? `https://github.com/${owner}/${repo}.git`),
78
+ permissions: { push: Boolean(perms.push), pull: Boolean(perms.pull ?? true) },
79
+ };
80
+ },
81
+ /** Issues updated since the cursor; pass 0 for a first (bounded) backfill. */
82
+ async listIssues(owner, repo, sinceMs, etags) {
83
+ const since = sinceMs > 0 ? new Date(sinceMs).toISOString() : new Date(Date.now() - 7 * 24 * 3600_000).toISOString();
84
+ const data = await getJson(`/repos/${owner}/${repo}/issues?state=open&sort=updated&direction=desc&per_page=50&since=${encodeURIComponent(since)}`, etags);
85
+ if (!data) {
86
+ return [];
87
+ }
88
+ return data
89
+ .filter((raw) => {
90
+ const item = raw;
91
+ // The issues API also returns PRs; drop them (pull_request field).
92
+ return !item.pull_request;
93
+ })
94
+ .map((raw) => {
95
+ const item = raw;
96
+ return {
97
+ number: Number(item.number ?? 0),
98
+ title: String(item.title ?? ""),
99
+ body: String(item.body ?? ""),
100
+ state: item.state === "closed" ? "closed" : "open",
101
+ assignees: Array.isArray(item.assignees) ? item.assignees.map((a) => String(a.login ?? "")) : [],
102
+ labels: Array.isArray(item.labels) ? item.labels.map((l) => String(l.name ?? "")) : [],
103
+ updatedAt: String(item.updated_at ?? ""),
104
+ user: String(item.user?.login ?? ""),
105
+ htmlUrl: String(item.html_url ?? ""),
106
+ };
107
+ });
108
+ },
109
+ async listPulls(owner, repo, etags) {
110
+ const data = await getJson(`/repos/${owner}/${repo}/pulls?state=open&sort=updated&direction=desc&per_page=30`, etags);
111
+ if (!data) {
112
+ return [];
113
+ }
114
+ return data.map((raw) => {
115
+ const item = raw;
116
+ return {
117
+ number: Number(item.number ?? 0),
118
+ title: String(item.title ?? ""),
119
+ body: String(item.body ?? ""),
120
+ state: item.state === "closed" ? "closed" : "open",
121
+ draft: Boolean(item.draft),
122
+ updated_at: String(item.updated_at ?? ""),
123
+ user: String(item.user?.login ?? ""),
124
+ head: String(item.head?.ref ?? ""),
125
+ htmlUrl: String(item.html_url ?? ""),
126
+ };
127
+ });
128
+ },
129
+ async listCommits(owner, repo, sinceSha) {
130
+ const suffix = sinceSha ? `?sha=${encodeURIComponent(sinceSha)}` : "?per_page=20";
131
+ void suffix;
132
+ // Compare-style walk is heavy; use the commits feed and filter client-side.
133
+ const data = await getJson(`/repos/${owner}/${repo}/commits?per_page=30`);
134
+ if (!data) {
135
+ return [];
136
+ }
137
+ const commits = data.map((raw) => {
138
+ const item = raw;
139
+ return {
140
+ sha: String(item.sha ?? ""),
141
+ message: String(item.commit?.message ?? "").split("\n")[0],
142
+ };
143
+ });
144
+ if (!sinceSha) {
145
+ return commits.slice(0, 10);
146
+ }
147
+ const index = commits.findIndex((c) => c.sha.startsWith(sinceSha.slice(0, 10)));
148
+ return index === -1 ? commits.slice(0, 5) : commits.slice(0, index);
149
+ },
150
+ // ---- write side (require Contents/Issues/PR write on the App) ----
151
+ async postIssueComment(owner, repo, issueNumber, body) {
152
+ const { data } = await request("POST", `/repos/${owner}/${repo}/issues/${issueNumber}/comments`, { body: { body } });
153
+ return Number(data.id ?? 0);
154
+ },
155
+ async postPullReviewComment(owner, repo, pullNumber, body) {
156
+ await request("POST", `/repos/${owner}/${repo}/pulls/${pullNumber}/reviews`, { body: { event: "COMMENT", body } });
157
+ },
158
+ async createIssue(owner, repo, title, body, labels) {
159
+ const { data } = await request("POST", `/repos/${owner}/${repo}/issues`, {
160
+ body: { title, body, ...(labels?.length ? { labels } : {}) },
161
+ });
162
+ return Number(data.number ?? 0);
163
+ },
164
+ async assignIssue(owner, repo, issueNumber, assignee) {
165
+ await request("POST", `/repos/${owner}/${repo}/issues/${issueNumber}/assignees`, { body: { assignees: [assignee] } });
166
+ },
167
+ /** Open a PR from a task worktree branch (collaboration contract delivery). */
168
+ async createPullRequest(owner, repo, head, base, title, body) {
169
+ const { data } = await request("POST", `/repos/${owner}/${repo}/pulls`, {
170
+ body: { title, head, base, body },
171
+ });
172
+ const item = data;
173
+ return { number: Number(item.number ?? 0), url: String(item.html_url ?? "") };
174
+ },
175
+ /**
176
+ * Worktree-GC delivery oracle (#173 follow-up 5): after a squash merge +
177
+ * branch deletion, ls-remote for the task branch is empty and the local
178
+ * rev-list own-count never drains (squash shas differ from the branch
179
+ * commits). True only on positive proof: a PR from this exact branch whose
180
+ * head tip is EXACTLY the given sha was merged. A closed-unmerged PR, a
181
+ * head-tip mismatch (worker committed after the push), or any API failure
182
+ * resolves false - the GC then retains the worktree (fails toward keep).
183
+ */
184
+ async prHeadDelivered(owner, repo, branch, headTip) {
185
+ const data = await getJson(`/repos/${owner}/${repo}/pulls?state=all&head=${encodeURIComponent(`${owner}:${branch}`)}`);
186
+ if (!Array.isArray(data) || data.length === 0) {
187
+ return false;
188
+ }
189
+ const pr = data[0];
190
+ const headSha = String(pr.head?.sha ?? "");
191
+ return Boolean(pr.merged) && headSha === headTip;
192
+ },
193
+ /** Repos the logged-in user can select in the TeamAuto bind picker. */
194
+ async listUserRepos() {
195
+ const data = await getJson("/user/repos?affiliation=owner,collaborator,organization_member&sort=pushed&per_page=100");
196
+ if (!data) {
197
+ return [];
198
+ }
199
+ return data.map((raw) => {
200
+ const item = raw;
201
+ return {
202
+ id: String(item.full_name ?? ""),
203
+ fullName: String(item.full_name ?? ""),
204
+ private: Boolean(item.private),
205
+ pushedAt: typeof item.pushed_at === "string" ? item.pushed_at : null,
206
+ };
207
+ }).filter((r) => r.id);
208
+ },
209
+ };
210
+ }
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Norms learning: absorb the target repo's collaboration conventions
3
+ * (CONTRIBUTING, issue/PR templates, commit style) so every TeamClaw worker
4
+ * prompt for that repo carries them - "转手目标仓库里面的协作规范".
5
+ */
6
+ const CONVENTIONAL_RE = /^(\w+)(\([^)]+\))?!?:\s.+/;
7
+ function detectCommitStyle(messages) {
8
+ if (!messages.length) {
9
+ return "unspecified - keep subject lines short and descriptive";
10
+ }
11
+ const matches = messages.filter((m) => CONVENTIONAL_RE.test(m)).length;
12
+ if (matches >= messages.length * 0.6) {
13
+ return "conventional commits (type(scope)!: subject)";
14
+ }
15
+ const chinese = messages.filter((m) => /[\u4e00-\u9fff]/.test(m)).length;
16
+ if (chinese >= messages.length * 0.6) {
17
+ return "plain subject lines, Chinese";
18
+ }
19
+ return "plain subject lines, English";
20
+ }
21
+ export async function learnNorms(repo, client, sync, cloneUrl, defaultBranch) {
22
+ let dir = null;
23
+ try {
24
+ dir = await sync.ensureCloned(repo.id, cloneUrl, defaultBranch);
25
+ }
26
+ catch {
27
+ dir = null;
28
+ }
29
+ const [owner, name] = repo.id.split("/");
30
+ const fetchRemote = async (apiPath) => {
31
+ try {
32
+ const { data } = await client.request("GET", apiPath);
33
+ const record = data;
34
+ if (typeof record.content === "string" && record.encoding === "base64") {
35
+ return Buffer.from(record.content, "base64").toString("utf8");
36
+ }
37
+ }
38
+ catch {
39
+ // absent file is fine
40
+ }
41
+ return null;
42
+ };
43
+ const contributing = (await fetchRemote(`/repos/${owner}/${name}/contents/CONTRIBUTING.md`)) ??
44
+ (dir ? await sync.readFileIfPresent(dir, "CONTRIBUTING.md") : null);
45
+ const issueTemplate = (await fetchRemote(`/repos/${owner}/${name}/contents/.github/ISSUE_TEMPLATE.md`)) ??
46
+ (dir ? await sync.readFileIfPresent(dir, ".github/ISSUE_TEMPLATE.md") : null);
47
+ const prTemplate = (await fetchRemote(`/repos/${owner}/${name}/contents/.github/PULL_REQUEST_TEMPLATE.md`)) ??
48
+ (dir ? await sync.readFileIfPresent(dir, ".github/PULL_REQUEST_TEMPLATE.md") : null);
49
+ let commitStyle = "unspecified";
50
+ if (dir) {
51
+ try {
52
+ commitStyle = detectCommitStyle(await sync.recentCommitMessages(dir, 100));
53
+ }
54
+ catch {
55
+ commitStyle = "unspecified";
56
+ }
57
+ }
58
+ return {
59
+ commitStyle,
60
+ issueTemplate: issueTemplate?.slice(0, 2000) ?? null,
61
+ prTemplate: prTemplate?.slice(0, 2000) ?? null,
62
+ contributing: contributing?.slice(0, 4000) ?? null,
63
+ learnedAt: Date.now(),
64
+ };
65
+ }
66
+ /** Render the learned norms into a compact prompt block for workers. */
67
+ export function renderNormsBlock(norms, repoId) {
68
+ if (!norms) {
69
+ return `Target repo: ${repoId}\nCollaboration norms: not learned yet - follow common sense and read existing issues/PRs for style.\n`;
70
+ }
71
+ const lines = [
72
+ `Target repo: ${repoId}`,
73
+ `Commit style: ${norms.commitStyle}`,
74
+ ];
75
+ if (norms.contributing) {
76
+ lines.push(`CONTRIBUTING.md excerpt:\n${norms.contributing.slice(0, 1500)}`);
77
+ }
78
+ if (norms.issueTemplate) {
79
+ lines.push(`Issue template excerpt:\n${norms.issueTemplate.slice(0, 800)}`);
80
+ }
81
+ if (norms.prTemplate) {
82
+ lines.push(`PR template excerpt:\n${norms.prTemplate.slice(0, 800)}`);
83
+ }
84
+ return lines.join("\n") + "\n";
85
+ }