cotal-ai 0.164.12 → 0.164.13
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/daemon/desktop-setup.js +33 -0
- package/dist/daemon/desktop.js +4 -1
- package/dist/daemon/install.js +3 -0
- package/dist/daemon/manager.js +149 -34
- package/package.json +19 -19
- package/seeded-connectors/_shared/docs-bundle.bin +0 -0
- package/seeded-connectors/_shared/docs-index.bin +0 -0
- package/seeded-connectors/_shared/placements.json +2 -2
- package/seeded-connectors/claude/dist/index.js +1 -1
- package/seeded-connectors/claude/dist/mcp.cjs +2 -2
- package/seeded-connectors/claude/package.json +1 -1
- package/seeded-connectors/codex/dist/host.js +2 -2
- package/seeded-connectors/codex/dist/index.js +1 -1
- package/seeded-connectors/codex/dist/personal.js +2 -2
- package/seeded-connectors/codex/package.json +1 -1
- package/seeded-connectors/hermes/dist/index.js +1 -1
- package/seeded-connectors/hermes/dist/launch.js +2 -2
- package/seeded-connectors/hermes/package.json +1 -1
- package/seeded-connectors/hermes/plugin/cotal/_sidecar/standalone.cjs +2 -2
- package/seeded-connectors/jcode/dist/host.js +2 -2
- package/seeded-connectors/jcode/dist/index.js +1 -1
- package/seeded-connectors/jcode/dist/mcp.js +1 -1
- package/seeded-connectors/jcode/package.json +1 -1
- package/seeded-connectors/opencode/dist/index.js +1 -1
- package/seeded-connectors/opencode/dist/plugin/index.js +2 -2
- package/seeded-connectors/opencode/package.json +1 -1
- package/seeded-connectors/pi/dist/index.js +2 -2
- package/seeded-connectors/pi/dist/standalone.js +2 -2
- package/seeded-connectors/pi/package.json +1 -1
- package/seeded-connectors/web/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { readFileSync, realpathSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { CommandFailure } from "@cotal-ai/workspace/local-observation";
|
|
4
|
+
/** An incomplete desktop replacement must never be started through the service controls. */
|
|
5
|
+
export function assertDesktopSetupComplete(executable = process.execPath, localAppData = process.env.LOCALAPPDATA, platform = process.platform) {
|
|
6
|
+
if (platform !== "win32" || !localAppData)
|
|
7
|
+
return;
|
|
8
|
+
const installPath = dirname(executable);
|
|
9
|
+
let state;
|
|
10
|
+
try {
|
|
11
|
+
state = JSON.parse(readFileSync(join(localAppData, "CotalSetup", "service-update.json"), "utf8"));
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
if (error.code === "ENOENT")
|
|
15
|
+
return;
|
|
16
|
+
throw new CommandFailure("refused", "CONFLICT", "Setup was interrupted or its handover could not be read. Run the installer again before starting the service.");
|
|
17
|
+
}
|
|
18
|
+
const record = state && typeof state === "object" ? state : undefined;
|
|
19
|
+
if (!record || record.schema !== 1 || typeof record.installPath !== "string")
|
|
20
|
+
throw new CommandFailure("refused", "CONFLICT", "Setup was interrupted and its handover is invalid. Run the installer again before starting the service.");
|
|
21
|
+
let sameInstallation;
|
|
22
|
+
try {
|
|
23
|
+
sameInstallation = realpathSync.native(record.installPath).toLowerCase() === realpathSync.native(installPath).toLowerCase();
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
throw new CommandFailure("refused", "CONFLICT", "Setup was interrupted and its installation folder could not be identified. Run the installer again before starting the service.");
|
|
27
|
+
}
|
|
28
|
+
if (!sameInstallation)
|
|
29
|
+
return;
|
|
30
|
+
if (record.phase === "ready")
|
|
31
|
+
return;
|
|
32
|
+
throw new CommandFailure("refused", "CONFLICT", "Setup was interrupted. Run the installer again before starting the service.");
|
|
33
|
+
}
|
package/dist/daemon/desktop.js
CHANGED
|
@@ -11,6 +11,7 @@ import { applyInstall, planUninstall, startInstalled } from "./install.js";
|
|
|
11
11
|
import { encode, isDaemonSpaceName } from "./protocol.js";
|
|
12
12
|
import { runSetup } from "./setup.js";
|
|
13
13
|
import { desktopApplicationPath } from "./desktop-path.js";
|
|
14
|
+
import { assertDesktopSetupComplete } from "./desktop-setup.js";
|
|
14
15
|
/** No renderer-supplied command, path, credentials or arbitrary arguments cross this boundary. */
|
|
15
16
|
export function parseDesktopRequest(value) {
|
|
16
17
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
@@ -150,6 +151,8 @@ export async function runDesktopBridge(opts) {
|
|
|
150
151
|
emit({ v: 1, event: "result", ok: true, result: { assets } });
|
|
151
152
|
return;
|
|
152
153
|
}
|
|
154
|
+
if (req.op === "status" || req.op === "install" || req.op === "setup")
|
|
155
|
+
assertDesktopSetupComplete();
|
|
153
156
|
target = opts.resolveTarget();
|
|
154
157
|
const { paths, home } = target;
|
|
155
158
|
const client = { paths, peerUid: opts.peerUid, peerPid: opts.peerPid };
|
|
@@ -244,7 +247,7 @@ export async function runDesktopBridge(opts) {
|
|
|
244
247
|
}
|
|
245
248
|
catch (e) {
|
|
246
249
|
const code = e instanceof EndpointRefusal || e instanceof CommandFailure ? e.code : "OPERATION_FAILED";
|
|
247
|
-
const message = e instanceof CommandFailure && (req.op === "setup" || (req.op === "install" && e.native?.code !== "NOT_ANSWERING")) ? e.message
|
|
250
|
+
const message = e instanceof CommandFailure && (e.code === "CONFLICT" || req.op === "setup" || (req.op === "install" && e.native?.code !== "NOT_ANSWERING")) ? e.message
|
|
248
251
|
: code === "NOT_RUNNING" ? (target && serviceInstalled(target)
|
|
249
252
|
? "The background service is installed but stopped. Choose Start service to start it."
|
|
250
253
|
: "The daemon is not running. Install its background service first.")
|
package/dist/daemon/install.js
CHANGED
|
@@ -51,6 +51,7 @@ import { launchAgentService, xmlText } from "./install-darwin.js";
|
|
|
51
51
|
import { scheduledTaskName, scheduledTaskService } from "./install-win32.js";
|
|
52
52
|
import { daemonCommandCopy } from "./guidance.js";
|
|
53
53
|
import { recoverPausedTask } from "./restart-recovery.js";
|
|
54
|
+
import { assertDesktopSetupComplete } from "./desktop-setup.js";
|
|
54
55
|
import { removeAllServiceRecords } from "./service-records.js";
|
|
55
56
|
import { readReceipt, unitReceiptFile } from "./install-receipt.js";
|
|
56
57
|
export { unitReceiptFile } from "./install-receipt.js";
|
|
@@ -343,6 +344,7 @@ export function planInstalledPathRefresh(paths, daemonHome) {
|
|
|
343
344
|
}
|
|
344
345
|
/** Start only the recorded, unchanged service. This does not restart an already-running daemon. */
|
|
345
346
|
export async function startInstalled(paths, daemonHome, expectedVersion, report) {
|
|
347
|
+
assertDesktopSetupComplete();
|
|
346
348
|
if (process.platform === "win32")
|
|
347
349
|
return restartWindowsInstalled(paths, daemonHome, expectedVersion, report, true);
|
|
348
350
|
const { receipt, plan, service } = recordedUnit(paths, daemonHome);
|
|
@@ -390,6 +392,7 @@ export function daemonStartedByOwnedService(paths, daemonHome) {
|
|
|
390
392
|
}
|
|
391
393
|
/** A delayed Windows native child must not publish after uninstall removed its installation. */
|
|
392
394
|
export function admitWindowsNativeDaemon(paths, daemonHome) {
|
|
395
|
+
assertDesktopSetupComplete();
|
|
393
396
|
const receipt = readReceipt(paths);
|
|
394
397
|
if (!receipt || receipt.mechanism !== "scheduled-task" || receipt.daemonHome !== daemonHome ||
|
|
395
398
|
receipt.unit !== scheduledTaskName(daemonHome, windowsUserSid()) || receipt.unitPath !== join(paths.state, "service-task.xml"))
|
package/dist/daemon/manager.js
CHANGED
|
@@ -3,12 +3,12 @@ import { randomUUID } from "node:crypto";
|
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
4
|
import { appendFileSync, chmodSync, existsSync, lstatSync, readFileSync, readdirSync, renameSync, rmSync, statSync } from "node:fs";
|
|
5
5
|
import { join } from "node:path";
|
|
6
|
-
import { assertLifecycleToken, mkSecretDir, parseRemoteEndpointDeregisterResult, registry, writeSecretFileAtomic } from "@cotal-ai/core";
|
|
6
|
+
import { assertLifecycleToken, BASELINE_LIFECYCLE_ENDPOINT, controlReplyFrom, dialerFor, drainAndClose, invokeRepairingSplit, issuedUserCaller, jwtFromCreds, mkSecretDir, parseRemoteEndpointDeregisterResult, registry, resolveService, standaloneConnectOpts, unansweredRequest, writeSecretFileAtomic, } from "@cotal-ai/core";
|
|
7
7
|
import { daemonArgv } from "@cotal-ai/cli/self-exec";
|
|
8
8
|
import { writeDefaultPersonaForLaunch } from "@cotal-ai/cli/default-persona";
|
|
9
9
|
import { loadIdpSession, retainManagerAuthorityRoute, withIdpSessionDir } from "@cotal-ai/auth";
|
|
10
|
-
import { findMesh, homeCotalDir, resolveControlTarget, spaceFromSegment, spaceSegment, userAuthStateDir, workspaceSecretStore
|
|
11
|
-
import {
|
|
10
|
+
import { controlCaller, findMesh, homeCotalDir, isCommandFailure, isConnectRefusal, resolveControlTarget, spaceFromSegment, spaceSegment, userAuthStateDir, workspaceSecretStore } from "@cotal-ai/workspace";
|
|
11
|
+
import { DIAL_TIMEOUT_MS, DialNotAdmitted, dialWithRetry, epRailFailure, notAdmittedRefusal } from "@cotal-ai/workspace/control";
|
|
12
12
|
import { installedGenerationVersion, reconcileHostedConnectors, ReplacedDaemonGeneration } from "./generation.js";
|
|
13
13
|
import { daemonPaths, daemonPathsFor } from "./endpoint.js";
|
|
14
14
|
import { daemonStartedByOwnedService, installedDaemonIdentity, unitReceiptFile } from "./install.js";
|
|
@@ -152,35 +152,131 @@ export function createHostedManagers(home = homeCotalDir(), version = installedG
|
|
|
152
152
|
}
|
|
153
153
|
return { space, state: "stopped", restarts: 0 };
|
|
154
154
|
};
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
const isRateLimited = (error) => (isConnectRefusal(error) && error.native?.code === "RATE_LIMITED")
|
|
156
|
+
|| (error instanceof Error && (error.code === "rate-limited" || /RATE_LIMITED|over its limit of \d+ connects a minute/.test(error.message)));
|
|
157
|
+
const closeProbeSession = (l, expected) => {
|
|
158
|
+
const current = l.probeSession;
|
|
159
|
+
if (!current || (expected && current !== expected))
|
|
160
|
+
return;
|
|
161
|
+
l.probeSession = undefined;
|
|
162
|
+
void drainAndClose(current.nc, 2000).catch(() => { });
|
|
163
|
+
};
|
|
164
|
+
const openProbeSession = async (l, child, selected) => {
|
|
165
|
+
if (l.exchangeFailedUntil !== undefined && Date.now() < l.exchangeFailedUntil) {
|
|
166
|
+
throw l.lastExchangeError ?? new Error("hosted Manager status exchange failed recently; retrying after backoff");
|
|
167
|
+
}
|
|
168
|
+
let nc;
|
|
169
|
+
try {
|
|
170
|
+
const target = await withIdpSessionDir(home, () => resolveControlTarget({ space: l.view.space }, "control-caller-privileged", selected, { onRefusal: "throw", readOnly: true }));
|
|
171
|
+
const who = controlCaller(target.auth);
|
|
172
|
+
if ("refusal" in who)
|
|
173
|
+
throw new Error(who.refusal);
|
|
174
|
+
let connectOpts = {};
|
|
175
|
+
nc = await dialWithRetry(() => {
|
|
176
|
+
connectOpts = standaloneConnectOpts(target.auth.creds ? { creds: target.auth.creds, tls: target.auth.tls === true } : target.auth.bearer ? { bearer: target.auth.bearer, sentinelCreds: target.auth.sentinelCreds, tls: target.auth.tls === true } : { tls: target.auth.tls === true });
|
|
177
|
+
return dialerFor(target.server)({ servers: target.server, ...connectOpts, timeout: DIAL_TIMEOUT_MS, maxReconnectAttempts: 0 });
|
|
178
|
+
}).catch((e) => {
|
|
179
|
+
if (!(e instanceof DialNotAdmitted))
|
|
180
|
+
throw e;
|
|
181
|
+
throw notAdmittedRefusal(e, `manager instance ${selected}`, "nothing was sent to the manager", { space: l.view.space, managerInstanceId: selected }, target.auth.bearer !== undefined);
|
|
182
|
+
});
|
|
183
|
+
const caller = target.auth.bearer !== undefined && target.auth.managerInstanceId !== undefined
|
|
184
|
+
? await issuedUserCaller(nc, l.view.space, String(connectOpts.name), who.caller)
|
|
185
|
+
: who.caller;
|
|
186
|
+
const token = target.auth.bearer ?? jwtFromCreds(target.auth.creds ?? "");
|
|
187
|
+
let expiresAtMs = Date.now() + 300_000;
|
|
188
|
+
if (token) {
|
|
189
|
+
try {
|
|
190
|
+
const payload = JSON.parse(Buffer.from(token.split(".")[1] ?? "", "base64url").toString("utf8"));
|
|
191
|
+
if (typeof payload.exp === "number" && Number.isFinite(payload.exp))
|
|
192
|
+
expiresAtMs = payload.exp * 1000;
|
|
193
|
+
}
|
|
194
|
+
catch { }
|
|
195
|
+
}
|
|
196
|
+
if (closed || l.stopping || l.child !== child || (l.view.instanceId !== undefined && l.view.instanceId !== selected)) {
|
|
197
|
+
void drainAndClose(nc, 2000).catch(() => { });
|
|
198
|
+
throw new Error("the hosted Manager changed or stopped while opening its control session");
|
|
199
|
+
}
|
|
200
|
+
const session = { child, instanceId: selected, nc, caller, expiresAtMs };
|
|
201
|
+
l.exchangeFailedUntil = undefined;
|
|
202
|
+
l.lastExchangeError = undefined;
|
|
203
|
+
l.probeSession = session;
|
|
204
|
+
void nc.closed().then(() => { if (l.probeSession === session)
|
|
205
|
+
l.probeSession = undefined; });
|
|
206
|
+
return session;
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
if (nc)
|
|
210
|
+
void drainAndClose(nc, 2000).catch(() => { });
|
|
211
|
+
l.exchangeFailedUntil = Date.now() + 5000;
|
|
212
|
+
l.lastExchangeError = error;
|
|
213
|
+
throw error;
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
const probe = async (l, selected) => {
|
|
217
|
+
const child = l.child;
|
|
218
|
+
if (!child)
|
|
219
|
+
return { ok: false, error: "the hosted Manager is not running" };
|
|
220
|
+
let session = l.probeSession;
|
|
221
|
+
if (session && (session.child !== child || session.instanceId !== selected || session.nc.isClosed() || Date.now() + 30_000 >= session.expiresAtMs)) {
|
|
222
|
+
closeProbeSession(l, session);
|
|
223
|
+
session = undefined;
|
|
224
|
+
}
|
|
225
|
+
if (!session) {
|
|
226
|
+
session = await (l.probeOpening ??= openProbeSession(l, child, selected).finally(() => { l.probeOpening = undefined; }));
|
|
227
|
+
}
|
|
228
|
+
try {
|
|
229
|
+
const service = await resolveService(session.nc, l.view.space, BASELINE_LIFECYCLE_ENDPOINT, session.caller, { deadlineMs: 10_000, commands: ["status"], instanceId: selected });
|
|
230
|
+
const r = await invokeRepairingSplit(session.nc, l.view.space, service, "status", undefined, { deadlineMs: 3000, id: randomUUID() });
|
|
231
|
+
if (r.reply.ok !== true) {
|
|
232
|
+
closeProbeSession(l, session);
|
|
233
|
+
return { ok: false, error: controlReplyFrom(r.reply).error ?? "the hosted Manager did not answer status" };
|
|
234
|
+
}
|
|
235
|
+
return { ok: true, data: r.reply.data };
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
if (!unansweredRequest(error) || session.nc.isClosed()) {
|
|
239
|
+
closeProbeSession(l, session);
|
|
240
|
+
l.exchangeFailedUntil = Date.now() + 5000;
|
|
241
|
+
l.lastExchangeError = error;
|
|
242
|
+
}
|
|
243
|
+
return { ok: false, error: epRailFailure(controlClient, error, { instanceId: selected }).error ?? (error instanceof Error ? error.message : String(error)) };
|
|
244
|
+
}
|
|
245
|
+
};
|
|
159
246
|
const refresh = async (space) => {
|
|
160
247
|
const l = live.get(space);
|
|
161
248
|
if (generationPending && l?.child)
|
|
162
249
|
return { ...status(space), state: "starting", reason: "an installed generation transition is pending", next: command(`wait for activation or read \`cotal daemon status --space ${space}\``) };
|
|
163
250
|
if (!l?.child || !l.view.instanceId || l.stopping || l.starting || recordError(space))
|
|
164
251
|
return status(space);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
252
|
+
return l.refreshing ??= (async () => {
|
|
253
|
+
const child = l.child, selected = l.view.instanceId;
|
|
254
|
+
let deadline;
|
|
255
|
+
try {
|
|
256
|
+
// This includes caller issuance, broker admission and contract resolution, not only status.
|
|
257
|
+
const reply = await Promise.race([probe(l, selected), new Promise((_, reject) => { deadline = setTimeout(() => reject(new Error("the pinned Manager status observation did not complete within 15000ms")), 15_000); })]);
|
|
258
|
+
if (!reply.ok)
|
|
259
|
+
throw new Error(reply.error ?? "the hosted Manager did not answer status");
|
|
260
|
+
if (l.child === child && !l.stopping && !closed && !generationPending)
|
|
261
|
+
l.view = { ...l.view, state: "answering", connectors: connectors(reply.data), reason: undefined, next: undefined, observedAt: new Date().toISOString() };
|
|
262
|
+
}
|
|
263
|
+
catch (error) {
|
|
264
|
+
if (l.child === child && !l.stopping && !closed && !generationPending) {
|
|
265
|
+
const reason = safeDiagnostic(error instanceof Error ? error.message : String(error)).slice(0, 1500);
|
|
266
|
+
if (!isRateLimited(error)) {
|
|
267
|
+
l.view = { ...l.view, state: "starting", reason, observedAt: new Date().toISOString(), next: `inspect \`cotal daemon status --space ${space}\`; restore its connection, then run \`cotal daemon setup --space ${space}\`` };
|
|
268
|
+
}
|
|
269
|
+
else if (l.view.observedAt === undefined) {
|
|
270
|
+
l.view = { ...l.view, state: "starting", reason, next: `wait for the CLI connect limit to refill, then run \`cotal daemon status --space ${space}\` again` };
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
finally {
|
|
275
|
+
if (deadline)
|
|
276
|
+
clearTimeout(deadline);
|
|
277
|
+
}
|
|
278
|
+
return status(space);
|
|
279
|
+
})().finally(() => { l.refreshing = undefined; });
|
|
184
280
|
};
|
|
185
281
|
const observe = (l) => {
|
|
186
282
|
if (l.healthTimer)
|
|
@@ -252,6 +348,7 @@ export function createHostedManagers(home = homeCotalDir(), version = installedG
|
|
|
252
348
|
return l.stopTask ??= stopChildOnce(l).finally(() => { l.stopTask = undefined; });
|
|
253
349
|
}
|
|
254
350
|
async function stopChildOnce(l) {
|
|
351
|
+
closeProbeSession(l);
|
|
255
352
|
const child = l.child;
|
|
256
353
|
if (!child)
|
|
257
354
|
return;
|
|
@@ -391,7 +488,10 @@ export function createHostedManagers(home = homeCotalDir(), version = installedG
|
|
|
391
488
|
chmodSync(logFile, 0o600);
|
|
392
489
|
};
|
|
393
490
|
const [node, ...argv] = daemonArgv();
|
|
394
|
-
l
|
|
491
|
+
closeProbeSession(l);
|
|
492
|
+
l.exchangeFailedUntil = undefined;
|
|
493
|
+
l.lastExchangeError = undefined;
|
|
494
|
+
l.view = { ...l.view, state: "starting", reason: "waiting for the hosted Manager to initialize and register", next: undefined, observedAt: undefined };
|
|
395
495
|
let nativeReason;
|
|
396
496
|
let authorityTerminal = false;
|
|
397
497
|
let authorityStatus;
|
|
@@ -449,14 +549,18 @@ export function createHostedManagers(home = homeCotalDir(), version = installedG
|
|
|
449
549
|
if (frame.kind !== "manager-instance" || typeof frame.instanceId !== "string")
|
|
450
550
|
return;
|
|
451
551
|
try {
|
|
452
|
-
|
|
552
|
+
const nextInstanceId = assertLifecycleToken(frame.instanceId, "instanceId");
|
|
553
|
+
if (instanceId !== undefined && instanceId !== nextInstanceId)
|
|
554
|
+
closeProbeSession(l);
|
|
555
|
+
instanceId = nextInstanceId;
|
|
453
556
|
}
|
|
454
557
|
catch { /* an invalid frame never selects another instance */ }
|
|
455
558
|
});
|
|
456
559
|
let ended = false;
|
|
457
560
|
l.exited = new Promise((resolve) => {
|
|
458
|
-
child.once("error", (error) => { nativeReason = safeDiagnostic(error.message).slice(0, 1500); ended = true; resolve(); });
|
|
561
|
+
child.once("error", (error) => { closeProbeSession(l); nativeReason = safeDiagnostic(error.message).slice(0, 1500); ended = true; resolve(); });
|
|
459
562
|
child.once("exit", (code, signal) => {
|
|
563
|
+
closeProbeSession(l);
|
|
460
564
|
stdoutLine("", true);
|
|
461
565
|
stderrLine("", true);
|
|
462
566
|
child.stdout?.destroy();
|
|
@@ -501,7 +605,7 @@ export function createHostedManagers(home = homeCotalDir(), version = installedG
|
|
|
501
605
|
if (instanceId && ready) {
|
|
502
606
|
const selected = instanceId;
|
|
503
607
|
l.view = { ...l.view, instanceId: selected };
|
|
504
|
-
const reply = await probe(
|
|
608
|
+
const reply = await probe(l, selected);
|
|
505
609
|
if (reply.ok && !ended && !l.stopping && !closed) {
|
|
506
610
|
const path = daemonManagerIntentFile(space, home);
|
|
507
611
|
const cleanup = readManagerCleanup(home, space);
|
|
@@ -520,7 +624,10 @@ export function createHostedManagers(home = homeCotalDir(), version = installedG
|
|
|
520
624
|
}
|
|
521
625
|
catch (error) {
|
|
522
626
|
last = error;
|
|
523
|
-
|
|
627
|
+
const reason = safeDiagnostic(error instanceof Error ? error.message : String(error)).slice(0, 1500);
|
|
628
|
+
l.view = isRateLimited(error)
|
|
629
|
+
? { ...l.view, state: "starting", reason, next: `wait for the CLI connect limit to refill, then run \`cotal daemon status --space ${space}\` again` }
|
|
630
|
+
: { ...l.view, reason, observedAt: new Date().toISOString() };
|
|
524
631
|
}
|
|
525
632
|
await pause(250);
|
|
526
633
|
}
|
|
@@ -558,7 +665,7 @@ export function createHostedManagers(home = homeCotalDir(), version = installedG
|
|
|
558
665
|
return l.starting;
|
|
559
666
|
if (l.child && l.view.instanceId) {
|
|
560
667
|
try {
|
|
561
|
-
const reply = await probe(
|
|
668
|
+
const reply = await probe(l, l.view.instanceId);
|
|
562
669
|
if (!reply.ok)
|
|
563
670
|
throw new Error(reply.error ?? "the hosted Manager did not answer status");
|
|
564
671
|
if (closed || l.stopping || !l.child)
|
|
@@ -609,7 +716,13 @@ export function createHostedManagers(home = homeCotalDir(), version = installedG
|
|
|
609
716
|
catch (error) {
|
|
610
717
|
if (error instanceof HostedManagerRefusal)
|
|
611
718
|
throw error;
|
|
612
|
-
|
|
719
|
+
const reason = error instanceof Error ? safeDiagnostic(error.message).slice(0, 1500) : "the hosted Manager did not answer status";
|
|
720
|
+
if (!isRateLimited(error)) {
|
|
721
|
+
l.view = { ...l.view, state: "starting", reason, next: `read \`cotal daemon status --space ${space}\`; correct its connection or restart the daemon`, observedAt: new Date().toISOString() };
|
|
722
|
+
}
|
|
723
|
+
else if (l.view.observedAt === undefined) {
|
|
724
|
+
l.view = { ...l.view, state: "starting", reason, next: `wait for the CLI connect limit to refill, then run \`cotal daemon status --space ${space}\` again` };
|
|
725
|
+
}
|
|
613
726
|
}
|
|
614
727
|
return { ...l.view };
|
|
615
728
|
}
|
|
@@ -729,7 +842,7 @@ export function createHostedManagers(home = homeCotalDir(), version = installedG
|
|
|
729
842
|
while (l.view.state !== "answering" && l.child === child && !closed && !l.stopping && selected && Date.now() < deadline) {
|
|
730
843
|
let timer;
|
|
731
844
|
try {
|
|
732
|
-
const reply = await Promise.race([probe(l
|
|
845
|
+
const reply = await Promise.race([probe(l, selected), new Promise((_, reject) => {
|
|
733
846
|
timer = setTimeout(() => reject(new Error("the pinned Manager status probe did not answer")), Math.min(3500, deadline - Date.now()));
|
|
734
847
|
})]);
|
|
735
848
|
if (!reply.ok)
|
|
@@ -953,6 +1066,7 @@ export function createHostedManagers(home = homeCotalDir(), version = installedG
|
|
|
953
1066
|
closed = true;
|
|
954
1067
|
await Promise.all([...live.values()].map(async (l) => {
|
|
955
1068
|
l.stopping = true;
|
|
1069
|
+
closeProbeSession(l);
|
|
956
1070
|
if (l.timer)
|
|
957
1071
|
clearTimeout(l.timer);
|
|
958
1072
|
if (l.healthTimer)
|
|
@@ -960,6 +1074,7 @@ export function createHostedManagers(home = homeCotalDir(), version = installedG
|
|
|
960
1074
|
await stopChild(l);
|
|
961
1075
|
await l.healthTask;
|
|
962
1076
|
await l.starting;
|
|
1077
|
+
await l.refreshing;
|
|
963
1078
|
}));
|
|
964
1079
|
},
|
|
965
1080
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cotal-ai",
|
|
3
|
-
"version": "0.164.
|
|
3
|
+
"version": "0.164.13",
|
|
4
4
|
"description": "Cotal — lateral agent coordination over NATS. Run `npx cotal-ai` for the CLI.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -33,28 +33,28 @@
|
|
|
33
33
|
"node": ">=22.10"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@cotal-ai/auth": "0.164.
|
|
37
|
-
"@cotal-ai/cli": "0.164.
|
|
38
|
-
"@cotal-ai/connector-core": "0.164.
|
|
39
|
-
"@cotal-ai/core": "0.164.
|
|
40
|
-
"@cotal-ai/delivery": "0.164.
|
|
41
|
-
"@cotal-ai/manager": "0.164.
|
|
42
|
-
"@cotal-ai/registry": "0.164.
|
|
43
|
-
"@cotal-ai/runtime": "0.164.
|
|
44
|
-
"@cotal-ai/seat": "0.164.
|
|
45
|
-
"@cotal-ai/workspace": "0.164.
|
|
36
|
+
"@cotal-ai/auth": "0.164.13",
|
|
37
|
+
"@cotal-ai/cli": "0.164.13",
|
|
38
|
+
"@cotal-ai/connector-core": "0.164.13",
|
|
39
|
+
"@cotal-ai/core": "0.164.13",
|
|
40
|
+
"@cotal-ai/delivery": "0.164.13",
|
|
41
|
+
"@cotal-ai/manager": "0.164.13",
|
|
42
|
+
"@cotal-ai/registry": "0.164.13",
|
|
43
|
+
"@cotal-ai/runtime": "0.164.13",
|
|
44
|
+
"@cotal-ai/seat": "0.164.13",
|
|
45
|
+
"@cotal-ai/workspace": "0.164.13",
|
|
46
46
|
"jose": "^6.2.3"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@cotal-ai/connector-claude-code": "0.164.
|
|
50
|
-
"@cotal-ai/connector-codex": "0.164.
|
|
51
|
-
"@cotal-ai/connector-hermes": "0.164.
|
|
52
|
-
"@cotal-ai/connector-jcode": "0.164.
|
|
53
|
-
"@cotal-ai/connector-opencode": "0.164.
|
|
54
|
-
"@cotal-ai/linear": "0.164.
|
|
55
|
-
"@cotal-ai/pi": "0.164.
|
|
49
|
+
"@cotal-ai/connector-claude-code": "0.164.13",
|
|
50
|
+
"@cotal-ai/connector-codex": "0.164.13",
|
|
51
|
+
"@cotal-ai/connector-hermes": "0.164.13",
|
|
52
|
+
"@cotal-ai/connector-jcode": "0.164.13",
|
|
53
|
+
"@cotal-ai/connector-opencode": "0.164.13",
|
|
54
|
+
"@cotal-ai/linear": "0.164.13",
|
|
55
|
+
"@cotal-ai/pi": "0.164.13",
|
|
56
56
|
"@cotal-ai/smoke-kit": "0.0.0",
|
|
57
|
-
"@cotal-ai/web": "0.164.
|
|
57
|
+
"@cotal-ai/web": "0.164.13",
|
|
58
58
|
"@nats-io/jetstream": "^3.4.0",
|
|
59
59
|
"@nats-io/transport-node": "^3.4.0",
|
|
60
60
|
"typescript": "^5.9.3"
|
|
Binary file
|
|
Binary file
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"v": 1,
|
|
3
3
|
"files": {
|
|
4
|
-
"docs-bundle.bin": "
|
|
5
|
-
"docs-index.bin": "
|
|
4
|
+
"docs-bundle.bin": "688f7c4f13b71696983d60ca731139e3b612efeb9dc527ba1a259af8d62f3873",
|
|
5
|
+
"docs-index.bin": "589984f46fd5f5b63c7fa0f39ea2b04ac7d59362d552c16f7553ab78205295c7"
|
|
6
6
|
},
|
|
7
7
|
"placements": {
|
|
8
8
|
"claude": [
|