@koalaauto/agentchannel 3.21.0 → 3.22.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/dist/src/cli.js +3 -2
- package/dist/src/client.d.ts +5 -0
- package/dist/src/client.js +13 -1
- package/dist/src/selfupdate.d.ts +7 -0
- package/dist/src/selfupdate.js +20 -0
- 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
|
@@ -1584,7 +1584,9 @@ async function runCommand(p, io) {
|
|
|
1584
1584
|
const cfg = loadConfig(env);
|
|
1585
1585
|
if (!cfg.key)
|
|
1586
1586
|
throw new UsageError('run: no agent key. Run `ach login` or set ACH_KEY.');
|
|
1587
|
-
|
|
1587
|
+
// the hub names the newest release on every answer: the updater hears it at once instead of at its next 6-hourly check
|
|
1588
|
+
let updater;
|
|
1589
|
+
const c = clientFromConfig(cfg, { fetch: io.fetch, role: 'runner', onLatestClient: (latest) => void updater?.heardLatest(latest)?.catch(() => { }) });
|
|
1588
1590
|
const home = achHome(env);
|
|
1589
1591
|
const dir = resolve(io.cwd ?? process.cwd(), str(v.dir) ?? '.');
|
|
1590
1592
|
const { GitWorkspace, parseRepoFlags } = await import('./runner/workspace.js');
|
|
@@ -1631,7 +1633,6 @@ async function runCommand(p, io) {
|
|
|
1631
1633
|
const { makeAdapter } = await import('./adapters/index.js');
|
|
1632
1634
|
const adapter = makeAdapter(runtime, { model: str(v.model) });
|
|
1633
1635
|
// keeps this runner on the hub's release: waits for the runs in flight, installs, exits UPDATE_EXIT_CODE so the service restarts
|
|
1634
|
-
let updater;
|
|
1635
1636
|
const runner = new Runner({
|
|
1636
1637
|
client: c,
|
|
1637
1638
|
adapter,
|
package/dist/src/client.d.ts
CHANGED
|
@@ -302,6 +302,8 @@ export interface ClientOptions {
|
|
|
302
302
|
fetch?: FetchLike;
|
|
303
303
|
/** `runner`: this is `ach run` polling, not a person's session or an MCP server (the hub notes which agents have a runner). */
|
|
304
304
|
role?: 'runner';
|
|
305
|
+
/** Called with the newest CLI release the hub names (`x-ach-latest-client`, on every answer, errors included). */
|
|
306
|
+
onLatestClient?: (latest: string) => void;
|
|
305
307
|
}
|
|
306
308
|
/** Round 2: human-facing CLI text in Chinese when LANG/LC_ALL starts with zh. */
|
|
307
309
|
export declare function isZh(env: NodeJS.ProcessEnv): boolean;
|
|
@@ -310,6 +312,7 @@ export declare function clientFromConfig(cfg: Config, opts?: {
|
|
|
310
312
|
admin?: boolean;
|
|
311
313
|
fetch?: FetchLike;
|
|
312
314
|
role?: 'runner';
|
|
315
|
+
onLatestClient?: (latest: string) => void;
|
|
313
316
|
}): Client;
|
|
314
317
|
/** Accept either `{task, handoff, messages, history}` or a bare task record. */
|
|
315
318
|
export declare function normalizeBundle(raw: any): TaskBundle;
|
|
@@ -321,6 +324,8 @@ export declare class Client {
|
|
|
321
324
|
private fetchFn;
|
|
322
325
|
constructor(o: ClientOptions);
|
|
323
326
|
private role?;
|
|
327
|
+
/** Set after construction when the listener needs the client first (the runner's updater is built later). */
|
|
328
|
+
onLatestClient?: (latest: string) => void;
|
|
324
329
|
private ownFetch;
|
|
325
330
|
/**
|
|
326
331
|
* The hub's change stream (GET /api/ach/events, a WebSocket that says "something changed", ids only). The token
|
package/dist/src/client.js
CHANGED
|
@@ -50,7 +50,7 @@ export function clientFromConfig(cfg, opts = {}) {
|
|
|
50
50
|
: 'No hub configured: run the `ach join ach2....` line from the panel or your admin (or set ACH_HUB).');
|
|
51
51
|
}
|
|
52
52
|
const token = opts.admin ? cfg.adminToken : cfg.runToken || cfg.key;
|
|
53
|
-
return new Client({ hub: cfg.hub, token, cfId: cfg.cfId, cfSecret: cfg.cfSecret, fetch: opts.fetch, role: opts.role });
|
|
53
|
+
return new Client({ hub: cfg.hub, token, cfId: cfg.cfId, cfSecret: cfg.cfSecret, fetch: opts.fetch, role: opts.role, onLatestClient: opts.onLatestClient });
|
|
54
54
|
}
|
|
55
55
|
function arr(v) {
|
|
56
56
|
return Array.isArray(v) ? v : [];
|
|
@@ -81,8 +81,11 @@ export class Client {
|
|
|
81
81
|
this.fetchFn = o.fetch ?? ((u, i) => fetch(u, i));
|
|
82
82
|
this.ownFetch = !!o.fetch;
|
|
83
83
|
this.role = o.role;
|
|
84
|
+
this.onLatestClient = o.onLatestClient;
|
|
84
85
|
}
|
|
85
86
|
role;
|
|
87
|
+
/** Set after construction when the listener needs the client first (the runner's updater is built later). */
|
|
88
|
+
onLatestClient;
|
|
86
89
|
ownFetch;
|
|
87
90
|
/**
|
|
88
91
|
* The hub's change stream (GET /api/ach/events, a WebSocket that says "something changed", ids only). The token
|
|
@@ -131,6 +134,15 @@ export class Client {
|
|
|
131
134
|
if (accessBlocked(res)) {
|
|
132
135
|
throw new HubError(403, `${method} ${path}: blocked by Cloudflare Access in front of ${new URL(url).host}: no valid access token (use a join line that includes it, or set ACH_CF_ID and ACH_CF_SECRET)`, 'cf_access');
|
|
133
136
|
}
|
|
137
|
+
const latest = res.headers?.get?.('x-ach-latest-client');
|
|
138
|
+
if (latest) {
|
|
139
|
+
try {
|
|
140
|
+
this.onLatestClient?.(latest);
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
/* a listener must not fail a request */
|
|
144
|
+
}
|
|
145
|
+
}
|
|
134
146
|
const text = await res.text();
|
|
135
147
|
let data = undefined;
|
|
136
148
|
if (text) {
|
package/dist/src/selfupdate.d.ts
CHANGED
|
@@ -112,6 +112,13 @@ export declare class SelfUpdater {
|
|
|
112
112
|
stop(): void;
|
|
113
113
|
/** The hub just refused this release (426): check now, but not more than once in 10 minutes (the runner polls again every 30 s). */
|
|
114
114
|
nudge(): Promise<CheckResult> | undefined;
|
|
115
|
+
private heard;
|
|
116
|
+
/**
|
|
117
|
+
* The hub names a release on every answer (`x-ach-latest-client`): when it is newer than this one, check now instead of at the
|
|
118
|
+
* next 6-hourly tick. Once per release, and again after an hour if this one is still behind (a try that failed or backed off).
|
|
119
|
+
* What a check can never fix by itself (a manual verdict, ACH_AUTO_UPDATE=0) is not asked again for that release.
|
|
120
|
+
*/
|
|
121
|
+
heardLatest(latest: string): Promise<CheckResult> | undefined;
|
|
115
122
|
check(): Promise<CheckResult>;
|
|
116
123
|
}
|
|
117
124
|
export declare function staleText(latest: string, lang?: 'en' | 'zh', current?: string): string;
|
package/dist/src/selfupdate.js
CHANGED
|
@@ -175,6 +175,26 @@ export class SelfUpdater {
|
|
|
175
175
|
this.lastNudge = now;
|
|
176
176
|
return this.check();
|
|
177
177
|
}
|
|
178
|
+
heard = new Map();
|
|
179
|
+
/**
|
|
180
|
+
* The hub names a release on every answer (`x-ach-latest-client`): when it is newer than this one, check now instead of at the
|
|
181
|
+
* next 6-hourly tick. Once per release, and again after an hour if this one is still behind (a try that failed or backed off).
|
|
182
|
+
* What a check can never fix by itself (a manual verdict, ACH_AUTO_UPDATE=0) is not asked again for that release.
|
|
183
|
+
*/
|
|
184
|
+
heardLatest(latest) {
|
|
185
|
+
const now = (this.o.now ?? Date.now)();
|
|
186
|
+
if (this.stopped || this.working || this.restarting || !isVersion(latest) || !newerVersion(latest, this.o.version ?? VERSION))
|
|
187
|
+
return undefined;
|
|
188
|
+
const at = this.heard.get(latest);
|
|
189
|
+
if (at !== undefined && (at < 0 || now - at < 3600_000))
|
|
190
|
+
return undefined;
|
|
191
|
+
this.heard.set(latest, now);
|
|
192
|
+
return this.check().then((r) => {
|
|
193
|
+
if (r === 'manual' || r === 'off')
|
|
194
|
+
this.heard.set(latest, -1);
|
|
195
|
+
return r;
|
|
196
|
+
});
|
|
197
|
+
}
|
|
178
198
|
async check() {
|
|
179
199
|
if (this.working || this.restarting)
|
|
180
200
|
return 'busy';
|
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.
|
|
3
|
+
"version": "3.22.0",
|
|
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",
|