@teamclaws/teamclaw 2026.6.0 → 2026.7.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.
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/src/controller/worker-provisioning.ts +36 -3
- package/src/teamauto/schedule.ts +136 -0
- package/src/teamauto/scheduler.ts +15 -19
- package/src/ui/app.js +2 -0
- package/src/ui/index.html +1 -0
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "teamclaw",
|
|
3
3
|
"name": "TeamClaw",
|
|
4
4
|
"description": "Virtual team collaboration - multiple OpenClaw instances form a virtual software company with role-based task routing.",
|
|
5
|
-
"version": "2026.
|
|
5
|
+
"version": "2026.7.0",
|
|
6
6
|
"activation": {
|
|
7
7
|
"onStartup": true
|
|
8
8
|
},
|
package/package.json
CHANGED
|
@@ -1353,7 +1353,7 @@ function createProvisionerBackend(
|
|
|
1353
1353
|
}
|
|
1354
1354
|
}
|
|
1355
1355
|
|
|
1356
|
-
function buildProvisionedWorkerConfig(
|
|
1356
|
+
export function buildProvisionedWorkerConfig(
|
|
1357
1357
|
baseConfig: Record<string, unknown>,
|
|
1358
1358
|
controllerConfig: PluginConfig,
|
|
1359
1359
|
spec: {
|
|
@@ -1381,13 +1381,46 @@ function buildProvisionedWorkerConfig(
|
|
|
1381
1381
|
// so fold the teamclaw entry's model back into the legacy
|
|
1382
1382
|
// agents.defaults.model and drop the entries map. New-schema workers also
|
|
1383
1383
|
// accept agents.defaults, keeping the folded config compatible both ways.
|
|
1384
|
-
const agentsRecord = agents as {
|
|
1384
|
+
const agentsRecord = agents as {
|
|
1385
|
+
entries?: Record<string, { model?: string }>;
|
|
1386
|
+
};
|
|
1385
1387
|
if (agentsRecord.entries && typeof agentsRecord.entries === "object") {
|
|
1386
1388
|
const entryModel = agentsRecord.entries[TEAMCLAW_AGENT_ID]?.model;
|
|
1387
1389
|
if (entryModel && !agentDefaults.model) {
|
|
1388
1390
|
agentDefaults.model = entryModel;
|
|
1389
1391
|
}
|
|
1390
|
-
|
|
1392
|
+
// Container backends may run older openclaw runtimes that reject the
|
|
1393
|
+
// keyed agents schema ("Unrecognized key: entries") - fold down to
|
|
1394
|
+
// legacy defaults there. Process workers share the controller's own
|
|
1395
|
+
// runtime, which REQUIRES at least one entry ("agents.entries must
|
|
1396
|
+
// contain at least one configured agent" crash-loop, exit 78, observed
|
|
1397
|
+
// 2026-11-03 when entries was deleted unconditionally) - keep only the
|
|
1398
|
+
// teamclaw worker entry for them.
|
|
1399
|
+
const containerized =
|
|
1400
|
+
controllerConfig.workerProvisioningType === "docker" ||
|
|
1401
|
+
controllerConfig.workerProvisioningType === "kubernetes";
|
|
1402
|
+
if (containerized) {
|
|
1403
|
+
delete agentsRecord.entries;
|
|
1404
|
+
} else {
|
|
1405
|
+
agentsRecord.entries = {
|
|
1406
|
+
[TEAMCLAW_AGENT_ID]: agentsRecord.entries[TEAMCLAW_AGENT_ID] ?? {},
|
|
1407
|
+
};
|
|
1408
|
+
// Pruning entries can dangle defaults.heartbeat.agentId /
|
|
1409
|
+
// defaults.systemAgent.agentId ("main" no longer exists in the worker
|
|
1410
|
+
// config) - remap any dangling agentId reference to the surviving
|
|
1411
|
+
// teamclaw entry.
|
|
1412
|
+
for (const sectionKey of Object.keys(agentDefaults)) {
|
|
1413
|
+
const section = (agentDefaults as Record<string, unknown>)[sectionKey];
|
|
1414
|
+
if (
|
|
1415
|
+
section &&
|
|
1416
|
+
typeof section === "object" &&
|
|
1417
|
+
typeof (section as { agentId?: unknown }).agentId === "string" &&
|
|
1418
|
+
!agentsRecord.entries[(section as { agentId: string }).agentId]
|
|
1419
|
+
) {
|
|
1420
|
+
(section as { agentId: string }).agentId = TEAMCLAW_AGENT_ID;
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1391
1424
|
}
|
|
1392
1425
|
agents.defaults = agentDefaults;
|
|
1393
1426
|
config.agents = agents;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// Wall-clock aligned schedule resolution for TeamAuto sweeps.
|
|
2
|
+
//
|
|
3
|
+
// The previous implementation translated an expression into a plain
|
|
4
|
+
// interval and chained setTimeout()s from "now". Two problems:
|
|
5
|
+
//
|
|
6
|
+
// 1. Every gateway restart reset the countdown: with restarts less than
|
|
7
|
+
// one period apart, star-slash-30 never fired at all (observed
|
|
8
|
+
// 2026-11-02: three restarts within 30 minutes froze both repos).
|
|
9
|
+
// 2. Unrecognised expressions silently fell back to "first number of
|
|
10
|
+
// digits x 1 minute" - "0 9 * * *" (daily at nine) became a sweep
|
|
11
|
+
// every single minute.
|
|
12
|
+
//
|
|
13
|
+
// This module resolves schedules to the NEXT WALL-CLOCK boundary
|
|
14
|
+
// (local time, matching cron semantics) so a restart costs at most one
|
|
15
|
+
// partial period, and unsupported expressions throw ScheduleParseError
|
|
16
|
+
// instead of guessing a cadence.
|
|
17
|
+
//
|
|
18
|
+
// Supported expressions (5-field cron, local time):
|
|
19
|
+
// every N minutes: star-slash-N in the minute field
|
|
20
|
+
// hourly at minute M: "M * * * *"
|
|
21
|
+
// every N hours on :00: "0 star-slash-N * * *"
|
|
22
|
+
// daily at H:M: "M H * * *"
|
|
23
|
+
// @hourly @daily @weekly (Monday 00:00) @monthly (1st 00:00)
|
|
24
|
+
|
|
25
|
+
export class ScheduleParseError extends Error {
|
|
26
|
+
constructor(schedule: string) {
|
|
27
|
+
super(
|
|
28
|
+
`unsupported schedule "${schedule}": use */N * * * *, M * * * *, 0 */N * * *, M H * * *, @hourly, @daily, @weekly or @monthly`,
|
|
29
|
+
);
|
|
30
|
+
this.name = "ScheduleParseError";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function nextFireMs(schedule: string, now: number = Date.now()): number {
|
|
35
|
+
const s = schedule.trim();
|
|
36
|
+
const next = new Date(now);
|
|
37
|
+
next.setSeconds(0, 0);
|
|
38
|
+
|
|
39
|
+
if (s === "@hourly") {
|
|
40
|
+
next.setMinutes(0);
|
|
41
|
+
if (next.getTime() <= now) {
|
|
42
|
+
next.setHours(next.getHours() + 1);
|
|
43
|
+
}
|
|
44
|
+
return next.getTime() - now;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (s === "@daily") {
|
|
48
|
+
next.setHours(0, 0, 0, 0);
|
|
49
|
+
if (next.getTime() <= now) {
|
|
50
|
+
next.setDate(next.getDate() + 1);
|
|
51
|
+
}
|
|
52
|
+
return next.getTime() - now;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (s === "@weekly") {
|
|
56
|
+
next.setHours(0, 0, 0, 0);
|
|
57
|
+
if (next.getTime() <= now) {
|
|
58
|
+
next.setDate(next.getDate() + 1);
|
|
59
|
+
}
|
|
60
|
+
// Monday = day 1. Day-0 first guarantees strictly-future even on Mondays.
|
|
61
|
+
while (next.getDay() !== 1) {
|
|
62
|
+
next.setDate(next.getDate() + 1);
|
|
63
|
+
}
|
|
64
|
+
return next.getTime() - now;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (s === "@monthly") {
|
|
68
|
+
next.setDate(1);
|
|
69
|
+
next.setHours(0, 0, 0, 0);
|
|
70
|
+
if (next.getTime() <= now) {
|
|
71
|
+
next.setMonth(next.getMonth() + 1);
|
|
72
|
+
}
|
|
73
|
+
return next.getTime() - now;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const stepMin = s.match(/^\*\/(\d{1,2})\s+\*\s+\*\s+\*\s+\*$/);
|
|
77
|
+
if (stepMin) {
|
|
78
|
+
const n = Number(stepMin[1]);
|
|
79
|
+
if (n < 1 || n > 59) {
|
|
80
|
+
throw new ScheduleParseError(s);
|
|
81
|
+
}
|
|
82
|
+
if (next.getTime() <= now) {
|
|
83
|
+
next.setMinutes(next.getMinutes() + 1);
|
|
84
|
+
}
|
|
85
|
+
while (next.getMinutes() % n !== 0) {
|
|
86
|
+
next.setMinutes(next.getMinutes() + 1);
|
|
87
|
+
}
|
|
88
|
+
return next.getTime() - now;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const hourlyAt = s.match(/^(\d{1,2})\s+\*\s+\*\s+\*\s+\*$/);
|
|
92
|
+
if (hourlyAt) {
|
|
93
|
+
const m = Number(hourlyAt[1]);
|
|
94
|
+
if (m > 59) {
|
|
95
|
+
throw new ScheduleParseError(s);
|
|
96
|
+
}
|
|
97
|
+
next.setMinutes(m);
|
|
98
|
+
if (next.getTime() <= now) {
|
|
99
|
+
next.setHours(next.getHours() + 1);
|
|
100
|
+
}
|
|
101
|
+
return next.getTime() - now;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const hourStep = s.match(/^0\s+\*\/(\d{1,2})\s+\*\s+\*\s+\*$/);
|
|
105
|
+
if (hourStep) {
|
|
106
|
+
const n = Number(hourStep[1]);
|
|
107
|
+
if (n < 1 || n > 23) {
|
|
108
|
+
throw new ScheduleParseError(s);
|
|
109
|
+
}
|
|
110
|
+
next.setMinutes(0);
|
|
111
|
+
if (next.getTime() <= now) {
|
|
112
|
+
next.setHours(next.getHours() + 1);
|
|
113
|
+
}
|
|
114
|
+
while (next.getHours() % n !== 0) {
|
|
115
|
+
next.setHours(next.getHours() + 1);
|
|
116
|
+
}
|
|
117
|
+
return next.getTime() - now;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const daily = s.match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+\*$/);
|
|
121
|
+
if (daily) {
|
|
122
|
+
const m = Number(daily[1]);
|
|
123
|
+
const h = Number(daily[2]);
|
|
124
|
+
if (m > 59 || h > 23) {
|
|
125
|
+
throw new ScheduleParseError(s);
|
|
126
|
+
}
|
|
127
|
+
next.setMinutes(m);
|
|
128
|
+
next.setHours(h);
|
|
129
|
+
if (next.getTime() <= now) {
|
|
130
|
+
next.setDate(next.getDate() + 1);
|
|
131
|
+
}
|
|
132
|
+
return next.getTime() - now;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
throw new ScheduleParseError(s);
|
|
136
|
+
}
|
|
@@ -6,6 +6,7 @@ import type { RoleId, TaskInfo, TeamState } from "../types.js";
|
|
|
6
6
|
import { createGithubClient } from "./github-client.js";
|
|
7
7
|
import { learnNorms, renderNormsBlock } from "./norms.js";
|
|
8
8
|
import { createRepoSync, teamAutoProjectDir } from "./repo-sync.js";
|
|
9
|
+
import { nextFireMs } from "./schedule.js";
|
|
9
10
|
import { advanceCursors, sweepRepo, type Candidate } from "./scanner.js";
|
|
10
11
|
import {
|
|
11
12
|
consumeDailyBudget,
|
|
@@ -34,22 +35,7 @@ function newId(prefix: string): string {
|
|
|
34
35
|
return `${prefix}-${Date.now().toString(36)}-${randomBytes(4).toString("hex")}`;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
export function nextFireMs(schedule: string): number {
|
|
39
|
-
const trimmed = schedule.trim();
|
|
40
|
-
if (trimmed === "@hourly") {
|
|
41
|
-
return 3600_000;
|
|
42
|
-
}
|
|
43
|
-
if (trimmed === "@daily") {
|
|
44
|
-
return 24 * 3600_000;
|
|
45
|
-
}
|
|
46
|
-
const match = trimmed.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);
|
|
47
|
-
if (match) {
|
|
48
|
-
return Math.max(1, Number(match[1])) * 60_000;
|
|
49
|
-
}
|
|
50
|
-
const digits = trimmed.match(/\d+/);
|
|
51
|
-
return digits ? Math.max(1, Number(digits[0])) * 60_000 : 30 * 60_000;
|
|
52
|
-
}
|
|
38
|
+
export { nextFireMs, ScheduleParseError } from "./schedule.js";
|
|
53
39
|
export type TeamAutoSchedulerDeps = {
|
|
54
40
|
logger: PluginLogger;
|
|
55
41
|
auth: GithubAuthManager;
|
|
@@ -98,10 +84,12 @@ export function createTeamAutoScheduler(deps: TeamAutoSchedulerDeps) {
|
|
|
98
84
|
if (!info.permissions.pull) {
|
|
99
85
|
throw new Error(`no read access to ${normalized}`);
|
|
100
86
|
}
|
|
87
|
+
const schedule = options.schedule?.trim() || "*/30 * * * *";
|
|
88
|
+
nextFireMs(schedule); // validates: throws ScheduleParseError for unsupported expressions
|
|
101
89
|
const repo: TeamAutoRepo = {
|
|
102
90
|
id: normalized,
|
|
103
91
|
enabled: true,
|
|
104
|
-
schedule
|
|
92
|
+
schedule,
|
|
105
93
|
addedAt: Date.now(),
|
|
106
94
|
lastSweepAt: 0,
|
|
107
95
|
lastSweepSummary: null,
|
|
@@ -190,7 +178,9 @@ export function createTeamAutoScheduler(deps: TeamAutoSchedulerDeps) {
|
|
|
190
178
|
throw new Error(`${repoId} not bound`);
|
|
191
179
|
}
|
|
192
180
|
if (patch.schedule?.trim()) {
|
|
193
|
-
|
|
181
|
+
const schedule = patch.schedule.trim();
|
|
182
|
+
nextFireMs(schedule); // validates before persisting
|
|
183
|
+
repo.schedule = schedule;
|
|
194
184
|
}
|
|
195
185
|
if (typeof patch.maxTasksPerSweep === "number" && patch.maxTasksPerSweep > 0) {
|
|
196
186
|
repo.policy.maxTasksPerSweep = Math.min(20, Math.floor(patch.maxTasksPerSweep));
|
|
@@ -519,7 +509,13 @@ export function createTeamAutoScheduler(deps: TeamAutoSchedulerDeps) {
|
|
|
519
509
|
if (!repo.enabled) {
|
|
520
510
|
return;
|
|
521
511
|
}
|
|
522
|
-
|
|
512
|
+
let delay: number;
|
|
513
|
+
try {
|
|
514
|
+
delay = nextFireMs(repo.schedule);
|
|
515
|
+
} catch (err) {
|
|
516
|
+
logger.error(`TeamAuto: ${repo.id} has an unsupported schedule "${repo.schedule}" and will not be scheduled: ${err instanceof Error ? err.message : String(err)}`);
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
523
519
|
const timer = setTimeout(() => {
|
|
524
520
|
void (async () => {
|
|
525
521
|
const s = await ensureStore();
|
package/src/ui/app.js
CHANGED
|
@@ -144,6 +144,7 @@
|
|
|
144
144
|
"teamauto.provisioning": "preparing",
|
|
145
145
|
"teamauto.provisionFailed": "setup failed",
|
|
146
146
|
"teamauto.hint": "Pick one of your GitHub repositories. TeamClaw sweeps it on its own schedule, reviews issues/PRs, takes ownership of unassigned issues, and posts results with teamclaw markers.",
|
|
147
|
+
"teamauto.scheduleHint": "Schedules: */N * * * * (every N min), M * * * * (hourly at :M), 0 */N * * * (every N h), M H * * * (daily at H:M), @hourly, @daily, @weekly, @monthly. Sweeps align to the clock and survive restarts.",
|
|
147
148
|
"teamauto.loginFirst": "Sign in to GitHub first (top-right Login).",
|
|
148
149
|
"teamauto.loadingRepos": "Loading your repos...",
|
|
149
150
|
"teamauto.noCandidates": "No selectable repos (check GitHub login). You can type owner/repo manually:",
|
|
@@ -302,6 +303,7 @@
|
|
|
302
303
|
"teamauto.provisioning": "准备中",
|
|
303
304
|
"teamauto.provisionFailed": "准备失败",
|
|
304
305
|
"teamauto.hint": "选择你的 GitHub 仓库。TeamClaw 按各自节奏定时扫描,自主 review issue/PR、认领未分配 issue,并以 teamclaw 标识写回结果。",
|
|
306
|
+
"teamauto.scheduleHint": "支持的表达式:*/N * * * *(每 N 分钟)、M * * * *(每小时第 M 分)、0 */N * * *(每 N 小时)、M H * * *(每天 H:M)、@hourly、@daily、@weekly、@monthly。扫描按墙钟对齐,重启后自动恢复。",
|
|
305
307
|
"teamauto.loginFirst": "请先登录 GitHub(右上角 Login)。",
|
|
306
308
|
"teamauto.loadingRepos": "正在加载你的仓库...",
|
|
307
309
|
"teamauto.noCandidates": "无可选仓库(请检查 GitHub 登录),可手动输入 owner/repo:",
|
package/src/ui/index.html
CHANGED
|
@@ -210,6 +210,7 @@
|
|
|
210
210
|
<button id="teamauto-bind" class="btn btn-primary btn-small" type="button" data-i18n="teamauto.bind">Bind</button>
|
|
211
211
|
</div>
|
|
212
212
|
<div id="teamauto-bind-msg" class="teamauto-msg"></div>
|
|
213
|
+
<p class="teamauto-hint" data-i18n="teamauto.scheduleHint">Schedules: */N * * * * (every N min), M * * * * (hourly at :M), 0 */N * * * (every N h), M H * * * (daily at H:M), @hourly, @daily, @weekly, @monthly. Sweeps align to the clock and survive restarts.</p>
|
|
213
214
|
<div id="teamauto-bind-overlay" class="ta-bind-overlay is-hidden" role="dialog" aria-modal="true">
|
|
214
215
|
<div class="ta-bind-dialog">
|
|
215
216
|
<div class="ta-bind-title" id="teamauto-bind-title">Binding...</div>
|