@cotal-ai/acp 0.0.0-stage → 0.175.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.
@@ -0,0 +1,454 @@
1
+ /**
2
+ * {@link Mesh} over a real space, built from the surfaces the terminal app uses: an observer that
3
+ * reads the roster and the agents' event channels, and the manager control calls. On a user-auth
4
+ * space the observer reads with the person's own sign-in, which reads the event channels of every
5
+ * agent under their owner, so no admin grant is needed.
6
+ */
7
+ import { hostname } from "node:os";
8
+ import { AGUI_FRAME_KIND, chatSubject, DEV_OWNER, EVENT_CHANNEL_PREFIX, eventChannel, eventChannelPrincipal, isEventChannel, parsePrincipalKey, principalKey, remoteManagerActors, } from "@cotal-ai/core";
9
+ import { connectTargetOrThrow, isConnectRefusal, ownManagerInstances, resolveControlTarget, resolvePreference, resolveTargetOrThrow, SignInChangedError, signInChange, userSignInAuth } from "@cotal-ai/workspace";
10
+ import { askManager, controlPs, liveManagerIds, managerCandidate, managerRailGone, reportedManagerHost, START_TIMEOUT_MS } from "@cotal-ai/workspace/control";
11
+ import { readManagedLaunch, requestManagedLaunch } from "@cotal-ai/workspace/launch";
12
+ import { openObserver } from "@cotal-ai/workspace/view";
13
+ import { deregisterRemedy, LaunchListsRefused, NoLaunchManager, SignInRequired } from "./mesh.js";
14
+ const OBSERVER_NAME = "acp";
15
+ /** A seat's retained event history is read up to this many frames. */
16
+ const HISTORY_FRAMES = 1000;
17
+ /** The manager reads whose unanswered pinned call names the deregister command on a signed-in space.
18
+ * An unanswered `start` may have been accepted, so it never does. */
19
+ const READS = new Set(["managerStatus", "models", "listPersonas", "ps"]);
20
+ /** Whether a reply should name the deregister command: an unanswered read of one of the person's own
21
+ * registered managers. The space's own manager is not theirs to remove, and a manager that answered
22
+ * with a refusal is not gone. */
23
+ export function namesDeregister(op, instanceId, own, reply) {
24
+ return instanceId !== undefined && own.has(instanceId) && READS.has(op) && !reply.ok && reply.unanswered === true;
25
+ }
26
+ /** A manager as a choice, its host read from the roster's current row for it. On a space where people
27
+ * sign in, `owner` is the person's, and only their own manager's row counts: another member may name
28
+ * an agent after it. An offline row says nothing about where the manager runs now, so it is not live
29
+ * and not local. */
30
+ export function managerChoice(instanceId, roster, here, owner) {
31
+ const actor = remoteManagerActors(instanceId).supervisor;
32
+ const row = roster.find((p) => (owner === undefined ? parsePrincipalKey(p.card.id)?.actor === actor : p.card.id === `${owner}.${actor}`) && p.status !== "offline");
33
+ const seen = managerCandidate(instanceId, row).host;
34
+ return { instanceId, ...(seen ? { host: seen } : {}), local: seen === here, live: row !== undefined };
35
+ }
36
+ /** After a connection error, how often and how many times the bridge asks whether its sign-in changed. */
37
+ const SIGN_IN_CHECK_MS = 5_000;
38
+ const SIGN_IN_CHECKS = 12;
39
+ /** The managers that listed their agents, and the ones that did not. A manager that did not hides
40
+ * only its own agents, is logged, and is named in `silent`. When none answered, the first failure is
41
+ * the answer. */
42
+ export function answeredReads(reads, log) {
43
+ const failed = reads.filter((r) => "error" in r);
44
+ if (failed.length > 0 && failed.length === reads.length)
45
+ throw failed[0].error;
46
+ for (const f of failed)
47
+ log(`manager ${f.instanceId} did not list its agents: ${f.error.message}`);
48
+ return { answered: reads.filter((r) => "rows" in r), silent: failed.map((f) => f.instanceId) };
49
+ }
50
+ /** Which of a person's managers, as the auth service lists them, a new thread may start on, and which
51
+ * the bridge reads agents from. A new thread may start on each of the person's registered managers
52
+ * that is live once they have registered any, else on the space's manager. That is the service's
53
+ * default rule for an unnamed call, except that several live managers are each offered where the
54
+ * service would refuse to choose. Every call names its manager, so a host's `local-primary` choice
55
+ * does not apply. Agents are read from every live one, so an agent left on the space's manager stays
56
+ * listed. `why` says why nothing may start. */
57
+ export function managerPlan(listed) {
58
+ const live = (placement) => listed.filter((m) => m.placement === placement && m.state === "candidate").map((m) => m.instanceId).sort();
59
+ const remote = live("remote");
60
+ const local = live("local");
61
+ const registered = listed.filter((m) => m.placement === "remote");
62
+ const launch = registered.length > 0 ? remote : local;
63
+ const why = launch.length > 0 ? undefined
64
+ : registered.length > 0 ? `none of your managers is live (${registered.map((m) => `${m.instanceId}: ${m.state}`).join(", ")}); start one with \`cotal manager start\``
65
+ : "the space lists no live manager for you";
66
+ return { launch, read: [...remote, ...local], own: registered.map((m) => m.instanceId), ...(why ? { why } : {}) };
67
+ }
68
+ /** A seat id as a manager reports it: the principal in user mode, a bare actor otherwise. */
69
+ function principalOf(id) {
70
+ const p = parsePrincipalKey(id);
71
+ return p ?? { owner: DEV_OWNER, actor: id };
72
+ }
73
+ function failure(reply, what) {
74
+ return new Error(`${what}: ${reply.error ?? "the manager did not answer"}`);
75
+ }
76
+ /** A launch list read's failure: {@link LaunchListsRefused} when the caller may not read it. */
77
+ function listFailure(reply, what) {
78
+ return reply.code === "permission-denied" ? new LaunchListsRefused(`${what}: ${reply.error ?? "permission denied"}`) : failure(reply, what);
79
+ }
80
+ /** The frame a message carries, or undefined when it carries none. Only the agent publishes on
81
+ * its own event channel, so a frame from any other sender is none. */
82
+ export function frameOf(msg) {
83
+ const seat = msg.channel === undefined ? null : eventChannelPrincipal(msg.channel);
84
+ if (!seat || msg.from?.id !== principalKey(seat.owner, seat.actor).key)
85
+ return undefined;
86
+ const part = msg.parts.find((p) => p.kind === AGUI_FRAME_KIND);
87
+ if (!part || typeof part.runId !== "string" || typeof part.threadId !== "string" || typeof part.seq !== "number" || !Array.isArray(part.events))
88
+ return undefined;
89
+ return {
90
+ owner: seat.owner,
91
+ actor: seat.actor,
92
+ threadId: part.threadId,
93
+ runId: part.runId,
94
+ epoch: typeof part.epoch === "string" ? part.epoch : "",
95
+ seq: part.seq,
96
+ events: part.events.filter((e) => typeof e === "object" && e !== null && typeof e.type === "string"),
97
+ ts: msg.ts,
98
+ };
99
+ }
100
+ /** A workspace failure as one plain error, or {@link SignInRequired} when the client's sign-in fixes
101
+ * it: the space needs a login, or this machine records no space for `cotal setup` to fill. */
102
+ function plain(e) {
103
+ if (!isConnectRefusal(e))
104
+ return e;
105
+ const f = e.failure();
106
+ const message = f.remedy ? `${f.message} ${f.remedy}` : f.message;
107
+ const noSpace = e.cause?.code === "no-meshes";
108
+ return e.code === "AUTH_REQUIRED" || noSpace ? new SignInRequired(message) : new Error(message);
109
+ }
110
+ async function connect(options) {
111
+ let target;
112
+ let observer;
113
+ /** The event channels the observer follows, as a subject: every agent's on a static or open
114
+ * space, and the agents under the person's own owner on a user-auth space. */
115
+ let events;
116
+ /** The person's sign-in on a user-auth space. The bridge acts as this sign-in throughout. */
117
+ let started;
118
+ /** On a user-auth space: asks the exchange for the sign-in again, and stops the bridge when it changed. */
119
+ let signInNow;
120
+ /** On a user-auth space: the person's managers, as the space's auth service lists them. */
121
+ let ownManagers;
122
+ try {
123
+ target = await resolveTargetOrThrow({ space: options.space, server: options.server });
124
+ const conn = await connectTargetOrThrow(target, "admin");
125
+ const signIn = conn.bearer ? userSignInAuth(conn) : undefined;
126
+ // A re-grant retires the lifecycle the observer reads under. The bridge stops and says so.
127
+ const user = signIn && {
128
+ ...signIn,
129
+ source: () => signIn.source().catch((e) => {
130
+ if (e instanceof SignInChangedError)
131
+ options.stop(e.message);
132
+ throw e;
133
+ }),
134
+ };
135
+ started = user && { owner: user.owner, actor: user.actor, lifecycleUid: user.lifecycleUid };
136
+ signInNow = user?.source;
137
+ ownManagers = user && (() => ownManagerInstances(conn));
138
+ // Only an agent publishes on its own event channel, so on a user-auth space the sender's owner
139
+ // is the person's too.
140
+ events = user ? chatSubject(conn.space, user.owner, "*", `${EVENT_CHANNEL_PREFIX}${user.owner}.*`) : chatSubject(conn.space, "*", "*", `${EVENT_CHANNEL_PREFIX}*.*`);
141
+ observer = openObserver({ space: conn.space, server: conn.server, name: OBSERVER_NAME, ...(user ? { auth: { user }, lifecycleUid: user.lifecycleUid } : { auth: { creds: conn.creds } }) });
142
+ // A re-grant ends the connection at once, while the endpoint renews its sign-in only mid-way
143
+ // through the token. So a connection error asks the exchange now. The old lifecycle may still be
144
+ // retiring, which the exchange refuses, so it asks again for a while. A changed sign-in stops
145
+ // the bridge through the source; an unchanged one ends the checks.
146
+ let checking = false;
147
+ const checkSignIn = async (source) => {
148
+ if (checking)
149
+ return;
150
+ checking = true;
151
+ try {
152
+ for (let attempt = 1; attempt <= SIGN_IN_CHECKS; attempt++) {
153
+ try {
154
+ await source();
155
+ return;
156
+ }
157
+ catch (e) {
158
+ if (attempt === 1 || attempt === SIGN_IN_CHECKS)
159
+ options.log(`could not check the sign-in (attempt ${attempt} of ${SIGN_IN_CHECKS}): ${plain(e).message}`);
160
+ }
161
+ await new Promise((r) => setTimeout(r, SIGN_IN_CHECK_MS));
162
+ }
163
+ }
164
+ finally {
165
+ checking = false;
166
+ }
167
+ };
168
+ observer.on("error", (e) => {
169
+ options.log(`space connection: ${e.message}`);
170
+ if (user)
171
+ void checkSignIn(user.source);
172
+ });
173
+ await observer.start();
174
+ }
175
+ catch (e) {
176
+ throw plain(e);
177
+ }
178
+ return { target, observer, events, started, signInNow, ownManagers };
179
+ }
180
+ /** The manager control calls, made as the person's sign-in when there is one. */
181
+ function controls(options, c) {
182
+ const { target, observer, started, signInNow, ownManagers } = c;
183
+ const ctx = { space: target.space, server: target.server };
184
+ const client = {
185
+ versionSkew: (detail, undeclared, managerVersion) => `${detail}. The manager does not declare "${undeclared}", so it runs another Cotal release than @cotal-ai/acp${managerVersion ? ` (the manager reports ${managerVersion})` : ""}. Run both at the same release.`,
186
+ roster: async () => observer.getRoster(),
187
+ };
188
+ /** A control instrument's bearer must be the sign-in the bridge started on. One for another account
189
+ * or lifecycle stops the bridge before anything is sent. */
190
+ const checked = (t) => {
191
+ const changed = started && t.auth.bearer ? signInChange(started, t.auth.bearer) : undefined;
192
+ if (changed) {
193
+ options.stop(changed.message);
194
+ throw changed;
195
+ }
196
+ return t;
197
+ };
198
+ /** The instrument for one command, pinned to an instance when one is named. A refused instrument
199
+ * may be the sign-in changing under the bridge, as when another account may not use this manager,
200
+ * so on a user-auth space it asks once, and a changed sign-in stops the bridge as a changed bearer
201
+ * does. */
202
+ const resolve = (profile, instanceId) => resolveControlTarget(ctx, profile, instanceId, { onRefusal: "throw" }).then(checked, async (e) => {
203
+ if (signInNow)
204
+ await signInNow().catch((c) => {
205
+ if (c instanceof SignInChangedError)
206
+ throw c;
207
+ });
208
+ throw plain(e);
209
+ });
210
+ /** The person's registered managers, as the last manager list read named them. Empty off a
211
+ * signed-in space. */
212
+ let own = new Set();
213
+ /** One manager command, pinned to an instance when one is named. On a space where people sign in,
214
+ * one of the person's registered managers that does not answer a read may be one whose computer is
215
+ * gone, so the reply says how to remove it. */
216
+ const ask = async (op, args, instanceId, timeoutMs) => {
217
+ const t = await resolve("control-caller-privileged", instanceId);
218
+ const reply = await askManager(client, t.space, t.server, op, args, t.auth, t.auth.bearer ? "owner" : "any", timeoutMs, instanceId ? { instanceId } : undefined);
219
+ return namesDeregister(op, instanceId, own, reply) ? { ...reply, error: `${reply.error ?? "the manager did not answer"} ${deregisterRemedy(target.space, [instanceId])}` } : reply;
220
+ };
221
+ /** The incarnation a seat command must reach. A manager names an open- or static-mode seat by its
222
+ * bare actor and a user-mode seat by its principal. */
223
+ const expected = (seat) => ({ id: target.mode === "user" ? principalKey(seat.owner, seat.actor).key : seat.actor, lifecycleUid: seat.lifecycleUid });
224
+ /** A seat command, sent to the manager that holds the seat and checked against the run the bridge
225
+ * bound, so nothing reaches a seat that restarted. The bridge learns the holding manager from the
226
+ * spawn reply or from the pinned list read, so no name lookup can pick another manager or refuse
227
+ * two seats whose names differ only in case. */
228
+ const seatCommand = async (op, seat, args) => {
229
+ const instanceId = seat.managerInstanceId;
230
+ if (!instanceId)
231
+ throw new Error(`${seat.name}: the manager that holds it is not known`);
232
+ const t = await resolve("control-caller-admin", instanceId);
233
+ const run = expected(seat);
234
+ return askManager(client, t.space, t.server, op, args, t.auth, t.auth.bearer ? "owner" : "any", undefined, { instanceId, expectedSeat: { name: seat.name, ...run }, expectedTarget: run });
235
+ };
236
+ const choice = (instanceId) => managerChoice(instanceId, observer.getRoster(), hostname(), started?.owner);
237
+ /** On a user-auth space, the person's managers as the space's auth service lists them. The list
238
+ * spends no selection, a manager whose presence has not arrived is still listed, and each later
239
+ * call is pinned to a manager it names, which the exchange authorizes again. */
240
+ const yourManagers = async () => {
241
+ const plan = managerPlan(await ownManagers().catch((e) => Promise.reject(plain(e))));
242
+ own = new Set(plan.own);
243
+ return plan;
244
+ };
245
+ return { ctx, client, resolve, ask, seatCommand, choice, yourManagers, own: () => own };
246
+ }
247
+ /** The reads a new thread's options come from, and the launch. */
248
+ function launchCalls(c, p, defaultPersona) {
249
+ const { target, started } = c;
250
+ const { client, resolve, ask, choice, yourManagers } = p;
251
+ return {
252
+ async catalogs(instanceId) {
253
+ const [status, models] = await Promise.all([ask("managerStatus", undefined, instanceId), ask("models", undefined, instanceId)]);
254
+ if (!status.ok)
255
+ throw listFailure(status, "the manager did not report its applications");
256
+ if (!models.ok)
257
+ throw listFailure(models, "the manager did not list its models");
258
+ const rows = status.data?.connectors ?? [];
259
+ if (!Array.isArray(models.data))
260
+ throw new Error("the manager did not list its models");
261
+ const catalogs = models.data;
262
+ return rows.map((row) => ({
263
+ agent: row.agent,
264
+ available: row.state === "available",
265
+ eventPlane: row.eventPlane,
266
+ ...(row.reason ? { reason: row.reason } : {}),
267
+ models: (catalogs.find((c) => c.agent === row.agent)?.models ?? []).map((m) => ({
268
+ id: m.id,
269
+ ...(m.name ? { name: m.name } : {}),
270
+ variants: (m.variants ?? []).map((v) => v.name),
271
+ })),
272
+ }));
273
+ },
274
+ async managers() {
275
+ if (started) {
276
+ const plan = await yourManagers();
277
+ if (plan.why)
278
+ throw new NoLaunchManager(plan.why);
279
+ return plan.launch.map((instanceId) => choice(instanceId));
280
+ }
281
+ const t = await resolve("control-caller-privileged");
282
+ const ids = await liveManagerIds(t.space, t.server, t.auth);
283
+ const here = hostname();
284
+ const choices = await Promise.all(ids.map(async (instanceId) => {
285
+ // A per-instance call needs an instrument minted for that instance.
286
+ const pinned = await resolve("control-caller-privileged", instanceId);
287
+ // A registration whose host is gone has nothing subscribed on its rail, as `cotal ps`
288
+ // reports it. It is not offered, and its host is not waited for. The probe answers only
289
+ // for a gone rail, so a live manager's host answer ends it.
290
+ const stop = new AbortController();
291
+ const reported = reportedManagerHost(client, pinned.space, pinned.server, pinned.auth, instanceId).finally(() => stop.abort());
292
+ if (await managerRailGone(pinned.space, pinned.server, pinned.auth, instanceId, stop.signal))
293
+ return undefined;
294
+ const host = await reported;
295
+ return { instanceId, ...(host ? { host } : {}), local: host === here, live: host !== undefined };
296
+ }));
297
+ return choices.filter((m) => m !== undefined);
298
+ },
299
+ async manager(instanceId) {
300
+ const seen = choice(instanceId);
301
+ if (seen.host)
302
+ return seen;
303
+ // A manager whose presence row is not found here, such as the space's own, is asked its host.
304
+ const t = await resolve("control-caller-privileged", instanceId);
305
+ const host = await reportedManagerHost(client, t.space, t.server, t.auth, instanceId);
306
+ return { instanceId, ...(host ? { host } : {}), local: host === hostname(), live: host !== undefined };
307
+ },
308
+ async personas(instanceId) {
309
+ const reply = await ask("listPersonas", undefined, instanceId);
310
+ if (!reply.ok)
311
+ throw listFailure(reply, "the manager did not list its personas");
312
+ const rows = reply.data?.personas ?? [];
313
+ return rows.map((p) => p.name).sort();
314
+ },
315
+ async spawn(req) {
316
+ const reply = await requestManagedLaunch({ persona: req.persona ?? defaultPersona ?? "default", identity: req.name, agent: req.agent, model: req.model, variant: req.variant, cwd: req.cwd, prompt: req.prompt, ...(req.subscribe ? { subscribe: [...req.subscribe] } : {}), events: true }, (args) => ask("start", args, req.managerInstanceId, START_TIMEOUT_MS));
317
+ if (!reply.ok)
318
+ throw failure(reply, `${req.name} did not start`);
319
+ const { result } = readManagedLaunch(reply, { space: target.space, requestedModel: req.model ?? null, detached: true }, { space: target.space });
320
+ return { name: result.name, ...principalOf(result.id), lifecycleUid: result.lifecycleUid, managerInstanceId: result.managerInstanceId };
321
+ },
322
+ };
323
+ }
324
+ /** The agent list and the commands sent to one agent. */
325
+ function seatCalls(options, c, p) {
326
+ const { started } = c;
327
+ const { ctx, client, ask, seatCommand, yourManagers } = p;
328
+ return {
329
+ async seats() {
330
+ let answered;
331
+ let silent;
332
+ const removable = [];
333
+ if (!started) {
334
+ const reply = await controlPs(client, ctx, { readOnly: true });
335
+ if (!reply.ok)
336
+ throw new Error(reply.error);
337
+ answered = reply.answered;
338
+ // A registration whose host is gone never answers, so it is not one that may still hold the agent.
339
+ for (const id of reply.gone)
340
+ options.log(`manager ${id} is registered, but nothing is behind its rail; its host is gone and never deregistered`);
341
+ silent = [...reply.silent.filter((id) => !reply.gone.includes(id)), ...reply.failed.map((f) => f.instanceId)];
342
+ }
343
+ else {
344
+ // A user-auth bearer reads one manager per call, each pinned. A manager that does not answer
345
+ // hides only its own agents, as `cotal ps` reports it.
346
+ const plan = await yourManagers();
347
+ if (plan.read.length === 0)
348
+ throw new Error(plan.why ?? "the space lists no live manager for you");
349
+ const reads = await Promise.all(plan.read.map(async (instanceId) => {
350
+ try {
351
+ const reply = await ask("ps", undefined, instanceId);
352
+ if (!reply.ok) {
353
+ if (namesDeregister("ps", instanceId, p.own(), reply))
354
+ removable.push(instanceId);
355
+ throw failure(reply, "the manager did not list its agents");
356
+ }
357
+ return { instanceId, rows: reply.data ?? [] };
358
+ }
359
+ catch (e) {
360
+ if (e instanceof SignInChangedError)
361
+ throw e;
362
+ return { instanceId, error: plain(e) };
363
+ }
364
+ }));
365
+ ({ answered, silent } = answeredReads(reads, options.log));
366
+ }
367
+ const rows = answered.flatMap(({ instanceId, rows }) => rows.map((row) => {
368
+ const r = row;
369
+ return {
370
+ name: r.name,
371
+ ...principalOf(r.id),
372
+ lifecycleUid: r.lifecycleUid,
373
+ managerInstanceId: instanceId,
374
+ agent: r.agent,
375
+ ...(r.model ? { model: r.model } : {}),
376
+ ...(r.cwd ? { cwd: r.cwd } : {}),
377
+ status: r.status,
378
+ ...(r.uptimeMs !== undefined ? { uptimeMs: r.uptimeMs } : {}),
379
+ };
380
+ }));
381
+ return { rows, silent, removable };
382
+ },
383
+ async despawn(seat) {
384
+ const reply = await seatCommand("stop", seat, { name: seat.name, graceful: true });
385
+ if (!reply.ok)
386
+ throw failure(reply, `${seat.name} did not stop`);
387
+ },
388
+ async interrupt(seat) {
389
+ const reply = await seatCommand("interrupt", seat, { name: seat.name });
390
+ if (!reply.ok)
391
+ throw failure(reply, `${seat.name} was not interrupted`);
392
+ },
393
+ async input(seat, text) {
394
+ const reply = await seatCommand("input", seat, { name: seat.name, text, enter: true });
395
+ if (!reply.ok)
396
+ throw failure(reply, `${seat.name} did not get the prompt`);
397
+ },
398
+ };
399
+ }
400
+ /** What the observer reads: the agents' frames and presence, the roster and the channels. */
401
+ function spaceReads(c) {
402
+ const { observer, events, started } = c;
403
+ return {
404
+ followFrames(onFrame) {
405
+ let live = true;
406
+ observer.tap((_subject, msg) => {
407
+ if (!live || !msg || !isEventChannel(msg.channel))
408
+ return;
409
+ const frame = frameOf(msg);
410
+ if (frame)
411
+ onFrame(frame);
412
+ }, { subject: events });
413
+ return () => (live = false);
414
+ },
415
+ async frameHistory(seat) {
416
+ // A person's sign-in reads history through its own lifecycle's reader.
417
+ const rows = started
418
+ ? (await observer.channelHistoryPage(eventChannel(seat), { limit: HISTORY_FRAMES, publisher: seat })).items
419
+ : await observer.channelHistory(eventChannel(seat), { limit: HISTORY_FRAMES, publisher: seat });
420
+ return rows.map(frameOf).filter((f) => f !== undefined);
421
+ },
422
+ presence(seat) {
423
+ const id = principalKey(seat.owner, seat.actor).key;
424
+ const status = observer.getRoster().find((p) => p.card.id === id)?.status;
425
+ return status === "offline" ? undefined : status;
426
+ },
427
+ async roster() {
428
+ return observer.getRoster()
429
+ .filter((p) => p.card.kind === "agent" && p.status !== "offline")
430
+ .map((p) => ({ name: p.card.name, status: p.status, ...(p.card.role ? { role: p.card.role } : {}), ...(p.activity ? { activity: p.activity } : {}) }));
431
+ },
432
+ async channels() {
433
+ return (await observer.listChannels()).map((c) => c.channel).filter((c) => !isEventChannel(c)).sort();
434
+ },
435
+ async close() {
436
+ await observer.stop();
437
+ },
438
+ };
439
+ }
440
+ export async function openLiveMesh(options) {
441
+ const c = await connect(options);
442
+ const { target } = c;
443
+ const p = controls(options, c);
444
+ const defaultPersona = resolvePreference("persona", { space: target.space }).value;
445
+ const defaultAgent = resolvePreference("harness", { space: target.space }).value;
446
+ return {
447
+ space: target.space,
448
+ ...(defaultAgent ? { defaultAgent } : {}),
449
+ ...launchCalls(c, p, defaultPersona),
450
+ ...seatCalls(options, c, p),
451
+ ...spaceReads(c),
452
+ };
453
+ }
454
+ //# sourceMappingURL=live-mesh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-mesh.js","sourceRoot":"","sources":["../src/live-mesh.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EACL,eAAe,EACf,WAAW,EACX,SAAS,EACT,oBAAoB,EACpB,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,GAMpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,YAAY,EAAE,cAAc,EAAmB,MAAM,qBAAqB,CAAC;AACpO,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,gBAAgB,EAAE,eAAe,EAAE,mBAAmB,EAAE,gBAAgB,EAA0D,MAAM,6BAA6B,CAAC;AACtN,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,EAAE,cAAc,EAAyJ,MAAM,WAAW,CAAC;AAEzP,MAAM,aAAa,GAAG,KAAK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ACnB,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,cAAc,CAAC;QACpC,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;QAC3B,GAAG,UAAU,CAAC,CAAC,CAAC;KACjB,CAAC;AACJ,CAAC"}
package/dist/mesh.d.ts ADDED
@@ -0,0 +1,149 @@
1
+ /**
2
+ * What the ACP agent needs from a Cotal space, as one interface. The protocol layer in `agent.ts`
3
+ * depends on this and on nothing else in the repo, so a smoke can drive it with a fake space and
4
+ * `live-mesh.ts` binds it to a real one.
5
+ */
6
+ /** One application a manager can launch, with its model catalog. */
7
+ export interface AgentCatalog {
8
+ readonly agent: string;
9
+ /** False when the manager reports the application unavailable on its host. */
10
+ readonly available: boolean;
11
+ /** Whether the connector publishes an AG-UI event plane. The bridge needs one. */
12
+ readonly eventPlane: boolean;
13
+ readonly reason?: string;
14
+ readonly models: readonly CatalogModel[];
15
+ }
16
+ export interface CatalogModel {
17
+ readonly id: string;
18
+ readonly name?: string;
19
+ readonly variants: readonly string[];
20
+ }
21
+ /** A manager the bridge can spawn through. */
22
+ export interface ManagerChoice {
23
+ readonly instanceId: string;
24
+ readonly host?: string;
25
+ /** The manager runs on the host this process runs on. */
26
+ readonly local: boolean;
27
+ /** The manager's presence is current, or, with no presence row to read, it answered for its host.
28
+ * A registration whose computer is gone can stay listed. */
29
+ readonly live?: boolean;
30
+ }
31
+ /** One seat incarnation: its name, principal and lifecycle. */
32
+ export interface SeatRef {
33
+ readonly name: string;
34
+ readonly owner: string;
35
+ readonly actor: string;
36
+ readonly lifecycleUid: string;
37
+ /** The manager that holds the seat. Seat commands go to it. */
38
+ readonly managerInstanceId?: string;
39
+ }
40
+ /** A managed seat as a manager's `ps` lists it. */
41
+ export interface SeatRow extends SeatRef {
42
+ readonly agent: string;
43
+ readonly model?: string;
44
+ readonly cwd?: string;
45
+ readonly status: string;
46
+ readonly uptimeMs?: number;
47
+ }
48
+ export interface SpawnRequest {
49
+ readonly name: string;
50
+ readonly agent: string;
51
+ readonly model?: string;
52
+ readonly variant?: string;
53
+ readonly persona?: string;
54
+ /** Channels the seat subscribes to at launch. */
55
+ readonly subscribe?: readonly string[];
56
+ readonly cwd: string;
57
+ readonly prompt: string;
58
+ readonly managerInstanceId?: string;
59
+ }
60
+ /** One AG-UI event as the bridge reads it. Only the fields the mapping uses are named. */
61
+ export interface AguiEventLike {
62
+ readonly type: string;
63
+ readonly [key: string]: unknown;
64
+ }
65
+ /** One AG-UI frame from a seat's event channel. */
66
+ export interface SeatFrame {
67
+ /** The principal whose event channel carried the frame. */
68
+ readonly owner: string;
69
+ readonly actor: string;
70
+ readonly threadId: string;
71
+ readonly runId: string;
72
+ readonly epoch: string;
73
+ readonly seq: number;
74
+ readonly events: readonly AguiEventLike[];
75
+ /** When the frame was published, epoch ms. */
76
+ readonly ts: number;
77
+ }
78
+ export interface RosterEntry {
79
+ readonly name: string;
80
+ readonly status: string;
81
+ readonly role?: string;
82
+ readonly activity?: string;
83
+ }
84
+ /** Opening the space needs the operator to sign in first. Any other failure to open is not this. */
85
+ export declare class SignInRequired extends Error {
86
+ readonly name = "SignInRequired";
87
+ }
88
+ /** The caller may not read a manager's launch lists, its applications, models and personas: a person
89
+ * whose grant does not let them spawn agents. They still control the agents they have. */
90
+ export declare class LaunchListsRefused extends Error {
91
+ readonly name = "LaunchListsRefused";
92
+ }
93
+ /** No manager may start a new agent for the caller, as when none of a person's registered managers is
94
+ * live. The agents they have stay listed and controllable. The message says why. */
95
+ export declare class NoLaunchManager extends Error {
96
+ readonly name = "NoLaunchManager";
97
+ }
98
+ /** What a person on a space where people sign in can do about a registered manager that does not
99
+ * answer. Its registration stays listed until it is removed, as `cotal ps` says. */
100
+ export declare function deregisterRemedy(space: string, instanceIds: readonly string[]): string;
101
+ /** The seats the managers listed, and the managers that did not answer, whose seats are missing. */
102
+ export interface SeatList {
103
+ readonly rows: SeatRow[];
104
+ readonly silent: readonly string[];
105
+ /** The silent managers that are the person's own registrations and did not answer, on a space
106
+ * where people sign in. Such a registration may belong to a computer that is gone. */
107
+ readonly removable?: readonly string[];
108
+ }
109
+ export interface Mesh {
110
+ /** The space this process acts in. */
111
+ readonly space: string;
112
+ /** The application a launch uses when none is chosen, as the operator's preference names it. */
113
+ readonly defaultAgent?: string;
114
+ /** The applications and models a manager offers. Rejects with {@link LaunchListsRefused} when the
115
+ * caller may not read them. */
116
+ catalogs(managerInstanceId?: string): Promise<AgentCatalog[]>;
117
+ /** The managers this caller can spawn through. On a space where people sign in, rejects with
118
+ * {@link NoLaunchManager} when none may. */
119
+ managers(): Promise<ManagerChoice[]>;
120
+ /** One manager as a choice, described from its presence, or from its own answer when its presence
121
+ * row is not found. */
122
+ manager(instanceId: string): Promise<ManagerChoice>;
123
+ /** Persona names in a manager's catalog. Each manager holds its own. Rejects with
124
+ * {@link LaunchListsRefused} when the caller may not read them. */
125
+ personas(managerInstanceId?: string): Promise<string[]>;
126
+ /** Launch a seat and wait until the manager confirms it joined. */
127
+ spawn(request: SpawnRequest): Promise<SeatRef>;
128
+ /** Every managed seat the caller can see. */
129
+ seats(): Promise<SeatList>;
130
+ /** Stop one seat through the manager that holds it. */
131
+ despawn(seat: SeatRef): Promise<void>;
132
+ /** Interrupt the seat's live turn: its manager writes the connector's interrupt key into the
133
+ * seat's terminal. Rejects, naming why, when the manager refuses. */
134
+ interrupt(seat: SeatRef): Promise<void>;
135
+ /** Type `text` into the seat's terminal and press Enter, through its manager's `input` command, so
136
+ * it arrives as the operator's own words. Rejects, naming why, when the manager refuses. */
137
+ input(seat: SeatRef, text: string): Promise<void>;
138
+ /** Follow every seat's event frames. Returns a function that stops following. */
139
+ followFrames(onFrame: (frame: SeatFrame) => void): () => void;
140
+ /** The event frames the space still retains for one seat, oldest first. */
141
+ frameHistory(seat: SeatRef): Promise<SeatFrame[]>;
142
+ /** A seat's presence status (`idle`, `working`, `waiting`), or undefined when it is not on the
143
+ * roster. */
144
+ presence(seat: SeatRef): string | undefined;
145
+ roster(): Promise<RosterEntry[]>;
146
+ channels(): Promise<string[]>;
147
+ close(): Promise<void>;
148
+ }
149
+ //# sourceMappingURL=mesh.d.ts.map