@koalaauto/agentchannel 3.99.0 → 3.99.1
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/dist/src/cli.js +1 -1
- package/dist/src/client.d.ts +1 -0
- package/dist/src/client.js +1 -1
- package/dist/src/pool.d.ts +8 -7
- package/dist/src/pool.js +36 -25
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
package/dist/src/cli.js
CHANGED
|
@@ -1109,7 +1109,7 @@ async function dispatch(p, io) {
|
|
|
1109
1109
|
if (r.started.length || r.stopped.length)
|
|
1110
1110
|
io.err(`pool ${name}: started ${r.started.join(', ') || 'none'}; stopped ${r.stopped.join(', ') || 'none'}; running ${pool.running.size}`);
|
|
1111
1111
|
if (pool.restartDue) {
|
|
1112
|
-
io.err(`pool ${name}:
|
|
1112
|
+
io.err(`pool ${name}: no run is going; restarting on ${pool.restartDue}`);
|
|
1113
1113
|
return (await import('./selfupdate.js')).UPDATE_EXIT_CODE;
|
|
1114
1114
|
}
|
|
1115
1115
|
}
|
package/dist/src/client.d.ts
CHANGED
|
@@ -714,6 +714,7 @@ export declare class Client {
|
|
|
714
714
|
id: string;
|
|
715
715
|
name: string;
|
|
716
716
|
repos: string[];
|
|
717
|
+
busy: boolean;
|
|
717
718
|
}[]>;
|
|
718
719
|
/** A fresh key for one of the pool's agents (its old one stops working). */
|
|
719
720
|
poolAgentKey(name: string, agentId: string): Promise<string>;
|
package/dist/src/client.js
CHANGED
|
@@ -481,7 +481,7 @@ export class Client {
|
|
|
481
481
|
/** `ach pool`: the agents of a pool (this client's token is the pool's key). */
|
|
482
482
|
async poolAgents(name) {
|
|
483
483
|
const r = await this.ach('GET', `/pool/${encodeURIComponent(name)}/agents`);
|
|
484
|
-
return arr(r?.agents).map((a) => ({ id: String(a.id), name: String(a.name), repos: arr(a.repos).map(String) }));
|
|
484
|
+
return arr(r?.agents).map((a) => ({ id: String(a.id), name: String(a.name), repos: arr(a.repos).map(String), busy: a.busy === true }));
|
|
485
485
|
}
|
|
486
486
|
/** A fresh key for one of the pool's agents (its old one stops working). */
|
|
487
487
|
async poolAgentKey(name, agentId) {
|
package/dist/src/pool.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export interface PoolAgent {
|
|
|
3
3
|
name: string;
|
|
4
4
|
/** owner/name GitHub repositories its cloud session opens */
|
|
5
5
|
repos: string[];
|
|
6
|
+
/** it has a run going now, as the hub knows it */
|
|
7
|
+
busy?: boolean;
|
|
6
8
|
}
|
|
7
9
|
export interface PoolHub {
|
|
8
10
|
agents(): Promise<PoolAgent[]>;
|
|
@@ -27,7 +29,7 @@ export interface PoolOptions {
|
|
|
27
29
|
};
|
|
28
30
|
now?: () => number;
|
|
29
31
|
}
|
|
30
|
-
/** How long a pool on an old release waits for
|
|
32
|
+
/** How long a pool on an old release waits for the runs that are going before it restarts anyway. */
|
|
31
33
|
export declare const MOVE_WAIT_MS: number;
|
|
32
34
|
export interface PoolChild {
|
|
33
35
|
/** set once it has exited */
|
|
@@ -57,7 +59,7 @@ export declare class Pool {
|
|
|
57
59
|
readonly running: Map<string, Running>;
|
|
58
60
|
/** when a runner that exited may be started again, and how often it has in a row */
|
|
59
61
|
private retry;
|
|
60
|
-
/** set once the install names another release and no
|
|
62
|
+
/** set once the install names another release and no run is going: the pool should exit so that its service restarts it */
|
|
61
63
|
restartDue?: string;
|
|
62
64
|
/** when the pool saw that the install names another release than its own */
|
|
63
65
|
private movedAt?;
|
|
@@ -71,11 +73,10 @@ export declare class Pool {
|
|
|
71
73
|
stopped: string[];
|
|
72
74
|
failed: string[];
|
|
73
75
|
}>;
|
|
74
|
-
/**
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
private moving;
|
|
76
|
+
/** The release the install names when it is not the pool's own (the pool is then due to move to it), said once. */
|
|
77
|
+
private moveTo;
|
|
78
|
+
/** Stop the runners and say that the pool should restart: its service starts it, and them, on `release`. */
|
|
79
|
+
private leave;
|
|
79
80
|
stop(): void;
|
|
80
81
|
}
|
|
81
82
|
export {};
|
package/dist/src/pool.js
CHANGED
|
@@ -6,18 +6,22 @@
|
|
|
6
6
|
// that leaves the pool has its runner stopped; one whose repositories changed has it restarted.
|
|
7
7
|
//
|
|
8
8
|
// Releases (2026-11-24: every cloud workspace sat on 3.67.0 for a day while 17 releases went by): the runners are started through
|
|
9
|
-
// the install's launcher, so a runner that updated itself (it installs, sets `current`, exits) comes back on the new release
|
|
10
|
-
// pool itself moves
|
|
11
|
-
//
|
|
9
|
+
// the install's launcher, so a runner that updated itself (it installs, sets `current`, exits) comes back on the new release: the
|
|
10
|
+
// pool starts it again at once. The pool itself moves when nobody is at work: once `current` names another release than its own
|
|
11
|
+
// and the hub says none of its agents has a run going, it stops its runners and exits, so that its service starts it and them
|
|
12
|
+
// on the new release (a second or two). While a run is going it waits, and the runners that are free keep taking work.
|
|
13
|
+
// (Until 2026-11-26 it started no runner again and waited for every one to exit: one runner that did not update, or one long
|
|
14
|
+
// run, kept all the others offline, up to the half hour below. Three times in two days.)
|
|
12
15
|
import { spawn } from 'node:child_process';
|
|
13
16
|
import { chmodSync, existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
14
17
|
import { dirname, join } from 'node:path';
|
|
15
18
|
import { fileURLToPath } from 'node:url';
|
|
16
19
|
import { appDir, appVersionOf, currentVersion, inApp, launcherPath } from './appinstall.js';
|
|
17
20
|
import { cfSecretPath, keyFilePath } from './keystore.js';
|
|
21
|
+
import { UPDATE_EXIT_CODE } from './selfupdate.js';
|
|
18
22
|
/** The CLI's entry (dist/src/cli.js, next to this file). */
|
|
19
23
|
const CLI_JS = join(dirname(fileURLToPath(import.meta.url)), 'cli.js');
|
|
20
|
-
/** How long a pool on an old release waits for
|
|
24
|
+
/** How long a pool on an old release waits for the runs that are going before it restarts anyway. */
|
|
21
25
|
export const MOVE_WAIT_MS = 30 * 60_000;
|
|
22
26
|
const safe = (name) => name.replace(/[^A-Za-z0-9-]/g, '-');
|
|
23
27
|
export const agentHomeIn = (base, a) => join(base, 'homes', safe(a.name));
|
|
@@ -78,7 +82,7 @@ export class Pool {
|
|
|
78
82
|
running = new Map();
|
|
79
83
|
/** when a runner that exited may be started again, and how often it has in a row */
|
|
80
84
|
retry = new Map();
|
|
81
|
-
/** set once the install names another release and no
|
|
85
|
+
/** set once the install names another release and no run is going: the pool should exit so that its service restarts it */
|
|
82
86
|
restartDue;
|
|
83
87
|
/** when the pool saw that the install names another release than its own */
|
|
84
88
|
movedAt;
|
|
@@ -95,9 +99,13 @@ export class Pool {
|
|
|
95
99
|
/** One round: what the hub says is in the pool is what runs. Returns what changed (for the log, and the tests). */
|
|
96
100
|
async tick() {
|
|
97
101
|
const out = { started: [], stopped: [], failed: [] };
|
|
98
|
-
|
|
99
|
-
|
|
102
|
+
const move = this.moveTo();
|
|
103
|
+
// (the limit does not need the hub: a hub that does not answer never holds the pool on an old release)
|
|
104
|
+
if (move && this.now() - this.movedAt > MOVE_WAIT_MS)
|
|
105
|
+
return this.leave(move, out);
|
|
100
106
|
const agents = await this.hub.agents();
|
|
107
|
+
if (move && !agents.some((a) => a.busy))
|
|
108
|
+
return this.leave(move, out);
|
|
101
109
|
const want = new Map(agents.map((a) => [a.id, a]));
|
|
102
110
|
for (const [id, r] of this.running) {
|
|
103
111
|
const a = want.get(id);
|
|
@@ -108,6 +116,12 @@ export class Pool {
|
|
|
108
116
|
this.retry.delete(id);
|
|
109
117
|
out.stopped.push(r.agent.name);
|
|
110
118
|
}
|
|
119
|
+
else if (r.child.exited?.code === UPDATE_EXIT_CODE) {
|
|
120
|
+
// it updated itself and left for that: back at once, on the release it installed
|
|
121
|
+
this.running.delete(id);
|
|
122
|
+
this.retry.delete(id);
|
|
123
|
+
this.o.log(`[${r.agent.name}] its runner updated itself; starting it again`);
|
|
124
|
+
}
|
|
111
125
|
else if (r.child.exited) {
|
|
112
126
|
this.running.delete(id);
|
|
113
127
|
const n = (this.retry.get(id)?.n ?? 0) + 1;
|
|
@@ -140,33 +154,30 @@ export class Pool {
|
|
|
140
154
|
this.retry.delete(id);
|
|
141
155
|
return out;
|
|
142
156
|
}
|
|
143
|
-
/**
|
|
144
|
-
|
|
145
|
-
* runs first), and once none is left say that the pool should restart. One that has not exited after MOVE_WAIT_MS is stopped.
|
|
146
|
-
*/
|
|
147
|
-
moving(out) {
|
|
157
|
+
/** The release the install names when it is not the pool's own (the pool is then due to move to it), said once. */
|
|
158
|
+
moveTo() {
|
|
148
159
|
const { mine, current } = this.releases();
|
|
149
160
|
if (!mine || !current || mine === current) {
|
|
150
161
|
this.movedAt = undefined;
|
|
151
|
-
return
|
|
162
|
+
return undefined;
|
|
152
163
|
}
|
|
153
164
|
if (this.movedAt === undefined) {
|
|
154
165
|
this.movedAt = this.now();
|
|
155
|
-
this.o.log(`the install starts ${current} now (this pool is ${mine}): no
|
|
166
|
+
this.o.log(`the install starts ${current} now (this pool is ${mine}): the pool restarts on it once no run is going; runners that update themselves are started again meanwhile`);
|
|
156
167
|
}
|
|
157
|
-
|
|
158
|
-
|
|
168
|
+
return current;
|
|
169
|
+
}
|
|
170
|
+
/** Stop the runners and say that the pool should restart: its service starts it, and them, on `release`. */
|
|
171
|
+
leave(release, out) {
|
|
172
|
+
for (const r of this.running.values()) {
|
|
159
173
|
if (r.child.exited)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
this.running.delete(id);
|
|
164
|
-
out.stopped.push(r.agent.name);
|
|
165
|
-
}
|
|
174
|
+
continue;
|
|
175
|
+
r.child.stop();
|
|
176
|
+
out.stopped.push(r.agent.name);
|
|
166
177
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return
|
|
178
|
+
this.running.clear();
|
|
179
|
+
this.restartDue = release;
|
|
180
|
+
return out;
|
|
170
181
|
}
|
|
171
182
|
stop() {
|
|
172
183
|
for (const r of this.running.values())
|
package/dist/src/version.d.ts
CHANGED
package/dist/src/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koalaauto/agentchannel",
|
|
3
|
-
"version": "3.99.
|
|
3
|
+
"version": "3.99.1",
|
|
4
4
|
"description": "Hand work between your team's agents (Claude Code, Codex) and follow it in one panel: the ach CLI, MCP server and runner for AgentChannel v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentchannel",
|