@cotal-ai/cli 0.6.0 → 0.8.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/commands/channels.d.ts +4 -2
- package/dist/commands/channels.d.ts.map +1 -1
- package/dist/commands/channels.js +17 -18
- package/dist/commands/channels.js.map +1 -1
- package/dist/commands/console.d.ts.map +1 -1
- package/dist/commands/console.js +13 -29
- package/dist/commands/console.js.map +1 -1
- package/dist/commands/down-manifest.d.ts +6 -0
- package/dist/commands/down-manifest.d.ts.map +1 -0
- package/dist/commands/down-manifest.js +282 -0
- package/dist/commands/down-manifest.js.map +1 -0
- package/dist/commands/down.d.ts +5 -3
- package/dist/commands/down.d.ts.map +1 -1
- package/dist/commands/down.js +30 -3
- package/dist/commands/down.js.map +1 -1
- package/dist/commands/history.d.ts.map +1 -1
- package/dist/commands/history.js +6 -13
- package/dist/commands/history.js.map +1 -1
- package/dist/commands/join.d.ts.map +1 -1
- package/dist/commands/join.js +20 -7
- package/dist/commands/join.js.map +1 -1
- package/dist/commands/meshes.d.ts +5 -0
- package/dist/commands/meshes.d.ts.map +1 -0
- package/dist/commands/meshes.js +25 -0
- package/dist/commands/meshes.js.map +1 -0
- package/dist/commands/mint.d.ts.map +1 -1
- package/dist/commands/mint.js +2 -1
- package/dist/commands/mint.js.map +1 -1
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +66 -16
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/spawn-manifest.d.ts +10 -0
- package/dist/commands/spawn-manifest.d.ts.map +1 -0
- package/dist/commands/spawn-manifest.js +197 -0
- package/dist/commands/spawn-manifest.js.map +1 -0
- package/dist/commands/spawn.d.ts +4 -2
- package/dist/commands/spawn.d.ts.map +1 -1
- package/dist/commands/spawn.js +84 -25
- package/dist/commands/spawn.js.map +1 -1
- package/dist/commands/topology.d.ts +10 -0
- package/dist/commands/topology.d.ts.map +1 -0
- package/dist/commands/topology.js +46 -0
- package/dist/commands/topology.js.map +1 -0
- package/dist/commands/up.d.ts +4 -0
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +223 -6
- package/dist/commands/up.js.map +1 -1
- package/dist/commands/use.d.ts +7 -0
- package/dist/commands/use.d.ts.map +1 -0
- package/dist/commands/use.js +27 -0
- package/dist/commands/use.js.map +1 -0
- package/dist/commands/web.d.ts.map +1 -1
- package/dist/commands/web.js +60 -28
- package/dist/commands/web.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/connect.d.ts +74 -0
- package/dist/lib/connect.d.ts.map +1 -0
- package/dist/lib/connect.js +91 -0
- package/dist/lib/connect.js.map +1 -0
- package/dist/lib/delivery-proc.d.ts.map +1 -1
- package/dist/lib/delivery-proc.js +2 -1
- package/dist/lib/delivery-proc.js.map +1 -1
- package/dist/lib/manager-proc.d.ts +4 -0
- package/dist/lib/manager-proc.d.ts.map +1 -1
- package/dist/lib/manager-proc.js +17 -0
- package/dist/lib/manager-proc.js.map +1 -1
- package/dist/lib/manifest/apply.d.ts +29 -0
- package/dist/lib/manifest/apply.d.ts.map +1 -0
- package/dist/lib/manifest/apply.js +138 -0
- package/dist/lib/manifest/apply.js.map +1 -0
- package/dist/lib/manifest/errors.d.ts +21 -0
- package/dist/lib/manifest/errors.d.ts.map +1 -0
- package/dist/lib/manifest/errors.js +19 -0
- package/dist/lib/manifest/errors.js.map +1 -0
- package/dist/lib/manifest/index.d.ts +13 -0
- package/dist/lib/manifest/index.d.ts.map +1 -0
- package/dist/lib/manifest/index.js +21 -0
- package/dist/lib/manifest/index.js.map +1 -0
- package/dist/lib/manifest/ledger.d.ts +81 -0
- package/dist/lib/manifest/ledger.d.ts.map +1 -0
- package/dist/lib/manifest/ledger.js +213 -0
- package/dist/lib/manifest/ledger.js.map +1 -0
- package/dist/lib/manifest/live.d.ts +25 -0
- package/dist/lib/manifest/live.d.ts.map +1 -0
- package/dist/lib/manifest/live.js +61 -0
- package/dist/lib/manifest/live.js.map +1 -0
- package/dist/lib/manifest/model.d.ts +71 -0
- package/dist/lib/manifest/model.d.ts.map +1 -0
- package/dist/lib/manifest/model.js +2 -0
- package/dist/lib/manifest/model.js.map +1 -0
- package/dist/lib/manifest/preflight.d.ts +12 -0
- package/dist/lib/manifest/preflight.d.ts.map +1 -0
- package/dist/lib/manifest/preflight.js +43 -0
- package/dist/lib/manifest/preflight.js.map +1 -0
- package/dist/lib/manifest/prepare.d.ts +57 -0
- package/dist/lib/manifest/prepare.d.ts.map +1 -0
- package/dist/lib/manifest/prepare.js +95 -0
- package/dist/lib/manifest/prepare.js.map +1 -0
- package/dist/lib/manifest/render.d.ts +41 -0
- package/dist/lib/manifest/render.d.ts.map +1 -0
- package/dist/lib/manifest/render.js +177 -0
- package/dist/lib/manifest/render.js.map +1 -0
- package/dist/lib/manifest/resolve.d.ts +5 -0
- package/dist/lib/manifest/resolve.d.ts.map +1 -0
- package/dist/lib/manifest/resolve.js +185 -0
- package/dist/lib/manifest/resolve.js.map +1 -0
- package/dist/lib/manifest/schema.d.ts +103 -0
- package/dist/lib/manifest/schema.d.ts.map +1 -0
- package/dist/lib/manifest/schema.js +77 -0
- package/dist/lib/manifest/schema.js.map +1 -0
- package/dist/lib/manifest/spawn-plan.d.ts +87 -0
- package/dist/lib/manifest/spawn-plan.d.ts.map +1 -0
- package/dist/lib/manifest/spawn-plan.js +75 -0
- package/dist/lib/manifest/spawn-plan.js.map +1 -0
- package/dist/lib/meshes.d.ts +2 -0
- package/dist/lib/meshes.d.ts.map +1 -0
- package/dist/lib/meshes.js +6 -0
- package/dist/lib/meshes.js.map +1 -0
- package/dist/lib/onboard.js +6 -6
- package/dist/lib/onboard.js.map +1 -1
- package/dist/lib/paths.js +1 -1
- package/dist/lib/paths.js.map +1 -1
- package/dist/lib/status.d.ts.map +1 -1
- package/dist/lib/status.js +2 -1
- package/dist/lib/status.js.map +1 -1
- package/dist/lib/transient.d.ts +7 -6
- package/dist/lib/transient.d.ts.map +1 -1
- package/dist/lib/transient.js +6 -25
- package/dist/lib/transient.js.map +1 -1
- package/dist/web/graph.html +207 -0
- package/dist/web/graph.js +508 -0
- package/dist/web/index.html +6 -0
- package/package.json +6 -2
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cotal spawn -f cotal.yaml` — deploy a mesh manifest onto a RUNNING mesh (additive). The only
|
|
3
|
+
* command that touches a mesh it doesn't own, so it is creation-only + ownership-scoped:
|
|
4
|
+
*
|
|
5
|
+
* - classifies channels (new → seed + own · existing → `exists-unmanaged`, card untouched) and
|
|
6
|
+
* agents (will-create · already-owned · stale) against the live mesh + any prior ledger;
|
|
7
|
+
* - boots agents through the workspace-local manager's admin `launch` op (it reads the run spec by
|
|
8
|
+
* id and mints from the resolved policy — the control wire carries no authority);
|
|
9
|
+
* - records exactly what it created in a `cotal-ledger/v1` ledger so `down -f` removes only that;
|
|
10
|
+
* - flags unmanaged actors on declared channels as a SECURITY warning (an explicit lower bound).
|
|
11
|
+
*
|
|
12
|
+
* `--dry-run` prints the plan and mutates nothing; a stale declared agent exits non-zero unless
|
|
13
|
+
* `--allow-stale <names>`.
|
|
14
|
+
*/
|
|
15
|
+
import { readFileSync } from "node:fs";
|
|
16
|
+
import { resolve } from "node:path";
|
|
17
|
+
import { DEFAULT_SERVER, readChannelRegistry, seedChannelRegistry, } from "@cotal-ai/core";
|
|
18
|
+
import { c } from "../ui.js";
|
|
19
|
+
import { cotalRoot } from "../lib/paths.js";
|
|
20
|
+
import { connectOrExit } from "../lib/connect.js";
|
|
21
|
+
import { managerUp, startManagerDetached } from "../lib/manager-proc.js";
|
|
22
|
+
import { loadManifest } from "../lib/manifest/index.js";
|
|
23
|
+
import { buildLaunchSpec, channelsSeed, genRunId, preflightConnectors, writeLaunchSpec } from "../lib/manifest/apply.js";
|
|
24
|
+
import { buildLedger, hashManifestSource, listLedgers, writeLedger } from "../lib/manifest/ledger.js";
|
|
25
|
+
import { classifyAgents, classifyChannels, detectUnmanagedActors } from "../lib/manifest/spawn-plan.js";
|
|
26
|
+
import { connectProbe, launchAgent, settleRoster, waitManagerReady } from "../lib/manifest/live.js";
|
|
27
|
+
import { renderInherited, renderSpawnPlan, renderSpawnSummary, renderWarnings } from "../lib/manifest/render.js";
|
|
28
|
+
import { failManifest } from "./topology.js";
|
|
29
|
+
const RUNTIMES = ["pty", "tmux", "cmux"];
|
|
30
|
+
export async function spawnManifest(file, flags) {
|
|
31
|
+
const abs = resolve(file);
|
|
32
|
+
let prepared;
|
|
33
|
+
try {
|
|
34
|
+
prepared = loadManifest(abs);
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
failManifest(e);
|
|
38
|
+
}
|
|
39
|
+
if (flags.runtime && !RUNTIMES.includes(flags.runtime)) {
|
|
40
|
+
console.error(c.red(`✗ unknown --runtime "${flags.runtime}" — expected ${RUNTIMES.join(", ")}`));
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
const eff = applyOverrides(prepared, flags);
|
|
44
|
+
const m = eff.manifest;
|
|
45
|
+
const space = m.space;
|
|
46
|
+
const runtime = m.runtime ?? "pty";
|
|
47
|
+
// Connectors + their binaries must exist before any mutation (no fallback).
|
|
48
|
+
const connErr = preflightConnectors(eff);
|
|
49
|
+
if (connErr) {
|
|
50
|
+
console.error(c.red(`✗ connector preflight failed: ${connErr}`));
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
// spawn -f deploys onto a RUNNING mesh — the broker MUST be reachable (opposite of up -f). Resolve
|
|
54
|
+
// the mesh + mint a manager (admin-control) cred from the local registry/auth (same-checkout).
|
|
55
|
+
const connection = await connectOrExit({ server: m.broker?.servers ?? flags.server, space }, "manager");
|
|
56
|
+
const root = cotalRoot();
|
|
57
|
+
// Same-checkout invariant (security/UX): the launch spec, the ledger, and the manager `spawn -f`
|
|
58
|
+
// drives all live under THIS checkout's `.cotal`. Deploying onto a mesh recorded by a different
|
|
59
|
+
// checkout would decouple those local artifacts from that mesh's root/manager. Refuse unless the
|
|
60
|
+
// resolved mesh is registered to this root; a raw off-registry target (no recorded root) isn't
|
|
61
|
+
// supported for a manifest deploy.
|
|
62
|
+
if (!connection.root) {
|
|
63
|
+
console.error(c.red(`✗ spawn -f needs a mesh registered to this checkout — a raw off-registry target (--server/--space) isn't supported for a manifest deploy`));
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
if (resolve(connection.root) !== resolve(root)) {
|
|
67
|
+
console.error(c.red(`✗ mesh "${space}" belongs to a different checkout (${connection.root}) — \`spawn -f\` / \`down -f\` are same-checkout; run them from ${connection.root}`));
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
const manifestHash = hashManifestSource(readFileSync(abs, "utf8"));
|
|
71
|
+
// A prior ledger for this manifest content ⇒ a re-apply (reuse its runId, classify against it).
|
|
72
|
+
// listLedgers fails closed (throws) on a symlinked `.cotal/manifests` — surface it cleanly.
|
|
73
|
+
let priors;
|
|
74
|
+
try {
|
|
75
|
+
priors = listLedgers(root).filter((l) => l.ledger.manifestHash === manifestHash && l.ledger.space === space);
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
console.error(c.red(`✗ ${e.message}`));
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
if (priors.length > 1) {
|
|
82
|
+
console.error(c.red(`✗ ${priors.length} runs already deployed this manifest (${priors.map((p) => p.ledger.runId).join(", ")}) — tear one down first: \`cotal down -f ${file} --run <id>\``));
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
const prior = priors[0]?.ledger;
|
|
86
|
+
const runId = prior?.runId ?? genRunId();
|
|
87
|
+
const ownedKeys = new Set(prior?.created.channels ?? []);
|
|
88
|
+
const ownedIds = new Set((prior?.created.agents ?? []).map((a) => a.id));
|
|
89
|
+
const ownedNames = new Set((prior?.created.agents ?? []).map((a) => a.name));
|
|
90
|
+
const liveRegistry = await readChannelRegistry({ servers: connection.server, space, creds: connection.creds });
|
|
91
|
+
const ep = await connectProbe({ space, server: connection.server, creds: connection.creds });
|
|
92
|
+
try {
|
|
93
|
+
const roster = await settleRoster(ep);
|
|
94
|
+
const membership = await ep.readMembership().catch(() => null);
|
|
95
|
+
const channelPlan = classifyChannels(m.channels, liveRegistry, ownedKeys);
|
|
96
|
+
const agentPlan = classifyAgents(eff.agents, roster, prior);
|
|
97
|
+
const unmanaged = detectUnmanagedActors(m.channels.map((ch) => ch.name), membership, roster, { ids: ownedIds, names: ownedNames });
|
|
98
|
+
if (flags.dryRun) {
|
|
99
|
+
console.log(renderSpawnPlan(eff, channelPlan, agentPlan, unmanaged, { server: connection.server, runId, dryRun: true }));
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
// Stale gate (apply-only): a re-declared owned agent whose resolved policy changed must restart —
|
|
103
|
+
// never silently keep running the old policy. Exit non-zero unless explicitly waived by name.
|
|
104
|
+
const allow = new Set(flags.allowStale ?? []);
|
|
105
|
+
const unwaived = agentPlan.stale.filter((e) => !allow.has(e.agent.name));
|
|
106
|
+
if (unwaived.length) {
|
|
107
|
+
console.error(c.red(`✗ ${unwaived.length} declared agent(s) are stale (policy changed) — restart required:`));
|
|
108
|
+
for (const e of unwaived)
|
|
109
|
+
console.error(c.red(` ${e.agent.name}: ${e.prior?.name} hash ${e.prior?.hash.slice(0, 8)} → ${e.hash.slice(0, 8)}`));
|
|
110
|
+
console.error(c.dim(` Waive (they keep running the OLD policy until restarted): --allow-stale ${unwaived.map((e) => e.agent.name).join(",")}`));
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
console.log(renderSpawnPlan(eff, channelPlan, agentPlan, unmanaged, { server: connection.server, runId, dryRun: false }), "\n");
|
|
114
|
+
// 1) Seed ONLY brand-new channel keys — no defaults, no pre-existing/unmanaged card mutation.
|
|
115
|
+
if (channelPlan.create.length)
|
|
116
|
+
await seedChannelRegistry({ servers: connection.server, space, creds: connection.creds, file: channelsSeed(channelPlan.create) });
|
|
117
|
+
// 2-4) Boot the will-create agents through the workspace-local manager's admin `launch` op,
|
|
118
|
+
// capturing the SPAWNED name + id the ledger keys on (creds are filed under the
|
|
119
|
+
// collision-numbered spawned name, not the manifest key). Skipped entirely for a
|
|
120
|
+
// channels-only deploy — no need to stand up a manager.
|
|
121
|
+
const agents = [...(prior?.created.agents ?? [])];
|
|
122
|
+
const launchedNow = [];
|
|
123
|
+
if (agentPlan.willCreate.length) {
|
|
124
|
+
// The manager reads the run spec by runId on each `launch`.
|
|
125
|
+
writeLaunchSpec(root, buildLaunchSpec(eff, runId), { update: Boolean(prior) });
|
|
126
|
+
if (!managerUp())
|
|
127
|
+
startManagerDetached({ space, server: connection.server, runtime });
|
|
128
|
+
if (!(await waitManagerReady(ep))) {
|
|
129
|
+
console.error(c.red("✗ manager did not become ready for control — see .cotal/manager.log"));
|
|
130
|
+
process.exit(1);
|
|
131
|
+
}
|
|
132
|
+
for (const e of agentPlan.willCreate) {
|
|
133
|
+
const reply = await launchAgent(ep, runId, e.agent.name);
|
|
134
|
+
if (!reply.ok) {
|
|
135
|
+
console.error(c.red(`✗ ${e.agent.name}: ${reply.error ?? "launch failed"}`));
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
const d = reply.data;
|
|
139
|
+
agents.push({ requested: d.requested, name: d.name, id: d.id, hash: d.hash });
|
|
140
|
+
launchedNow.push(d.name);
|
|
141
|
+
console.log(c.green(`✓ launched ${d.name}`) + c.dim(` (${e.agent.agentType})`));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// 5) Write/update the creation-only ownership ledger (prior owned ∪ this run's new).
|
|
145
|
+
const createdChannels = dedupe([...(prior?.created.channels ?? []), ...channelPlan.create.map((ch) => ch.name)]);
|
|
146
|
+
const ledger = buildLedger({ runId, space, server: connection.server, manifestHash, manifestPath: abs, channels: createdChannels, agents: dedupeAgents(agents) });
|
|
147
|
+
const ledgerPath = writeLedger(root, ledger, { update: Boolean(prior) });
|
|
148
|
+
// 6) Summary + the exact ownership-scoped teardown command.
|
|
149
|
+
console.log("\n" + renderSpawnSummary({
|
|
150
|
+
space,
|
|
151
|
+
server: connection.server,
|
|
152
|
+
runId,
|
|
153
|
+
ledgerPath,
|
|
154
|
+
manifestPath: abs,
|
|
155
|
+
created: channelPlan.create.map((ch) => ch.name),
|
|
156
|
+
launched: launchedNow,
|
|
157
|
+
existsUnmanaged: channelPlan.existsUnmanaged.map((x) => x.channel.name),
|
|
158
|
+
unmanaged,
|
|
159
|
+
}));
|
|
160
|
+
const inh = renderInherited(eff);
|
|
161
|
+
if (inh)
|
|
162
|
+
console.log("\n" + inh);
|
|
163
|
+
if (eff.warnings.length)
|
|
164
|
+
console.log("\n" + renderWarnings(eff.warnings));
|
|
165
|
+
}
|
|
166
|
+
finally {
|
|
167
|
+
await ep.stop();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/** CLI overrides for `spawn -f` (flag > manifest > default): the connect target + runtime. No
|
|
171
|
+
* host/open — we connect to an existing broker, not bind one. */
|
|
172
|
+
function applyOverrides(prepared, o) {
|
|
173
|
+
const m = prepared.manifest;
|
|
174
|
+
const broker = { ...m.broker };
|
|
175
|
+
if (o.server)
|
|
176
|
+
broker.servers = o.server;
|
|
177
|
+
if (!broker.servers)
|
|
178
|
+
broker.servers = DEFAULT_SERVER;
|
|
179
|
+
return {
|
|
180
|
+
...prepared,
|
|
181
|
+
manifest: {
|
|
182
|
+
...m,
|
|
183
|
+
broker,
|
|
184
|
+
space: o.space ?? m.space,
|
|
185
|
+
runtime: o.runtime ?? m.runtime,
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
const dedupe = (xs) => [...new Set(xs)];
|
|
190
|
+
/** Keep one entry per nkey id (defensive — `willCreate` excludes prior-owned, so no dup in practice). */
|
|
191
|
+
function dedupeAgents(agents) {
|
|
192
|
+
const byId = new Map();
|
|
193
|
+
for (const a of agents)
|
|
194
|
+
byId.set(a.id, a);
|
|
195
|
+
return [...byId.values()];
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=spawn-manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spawn-manifest.js","sourceRoot":"","sources":["../../src/commands/spawn-manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,mBAAmB,GAIpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,CAAC,EAAE,MAAM,UAAU,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,YAAY,EAAyB,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACzH,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,WAAW,EAAE,WAAW,EAAoB,MAAM,2BAA2B,CAAC;AACxH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACxG,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACpG,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACjH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAW7C,MAAM,QAAQ,GAAG,CAAC,K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AuB,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,MAAM;QAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AAC5B,CAAC"}
|
package/dist/commands/spawn.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type CompletionResult } from "@cotal-ai/core";
|
|
2
|
-
/** Completion for `cotal spawn <
|
|
3
|
-
*
|
|
2
|
+
/** Completion for `cotal spawn` — `--space <TAB>` lists the running meshes, and the first positional
|
|
3
|
+
* is a persona from the mesh this spawn would target. Resolved OFFLINE (registry + `current`, no
|
|
4
|
+
* probe — a <TAB> must stay cheap and never open the network), so it lists the *target* mesh's
|
|
5
|
+
* personas, not the cwd's. */
|
|
4
6
|
export declare function spawnComplete(argv: string[]): CompletionResult;
|
|
5
7
|
export declare function spawn(argv: string[]): Promise<void>;
|
|
6
8
|
//# sourceMappingURL=spawn.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../src/commands/spawn.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../src/commands/spawn.ts"],"names":[],"mappings":"AAIA,OAAO,EAcL,KAAK,gBAAgB,EAGtB,MAAM,gBAAgB,CAAC;AAOxB;;;+BAG+B;AAC/B,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAe9D;AAmED,wBAAsB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA2LzD"}
|
package/dist/commands/spawn.js
CHANGED
|
@@ -2,15 +2,31 @@ import { spawn as spawnProcess } from "node:child_process";
|
|
|
2
2
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { join, dirname } from "node:path";
|
|
4
4
|
import { parseArgs } from "node:util";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
import { agentFilePath, connectorServers, firstFreeName, isReachable, loadAgentFile, loadCotalConfig, mintCreds, newIdentity, parseShareSelection, provisionAgent, registry, CotalEndpoint, } from "@cotal-ai/core";
|
|
6
|
+
import { authDir, loadMeshes, resolveMeshTarget } from "@cotal-ai/workspace";
|
|
7
|
+
import { c } from "../ui.js";
|
|
8
|
+
import { preflightOrExit, resolveTargetOrExit } from "../lib/connect.js";
|
|
9
|
+
import { listPersonas } from "../lib/personas.js";
|
|
10
|
+
import { spawnManifest } from "./spawn-manifest.js";
|
|
11
|
+
/** Completion for `cotal spawn` — `--space <TAB>` lists the running meshes, and the first positional
|
|
12
|
+
* is a persona from the mesh this spawn would target. Resolved OFFLINE (registry + `current`, no
|
|
13
|
+
* probe — a <TAB> must stay cheap and never open the network), so it lists the *target* mesh's
|
|
14
|
+
* personas, not the cwd's. */
|
|
11
15
|
export function spawnComplete(argv) {
|
|
12
|
-
if (argv.length
|
|
13
|
-
return { items:
|
|
16
|
+
if (argv[argv.length - 2] === "--space")
|
|
17
|
+
return { items: loadMeshes().map((m) => ({ value: m.space })), directive: "nofiles" };
|
|
18
|
+
// Only the first word after `spawn` is the persona positional; once it's typed, defer to the shell.
|
|
19
|
+
if (argv.length <= 1) {
|
|
20
|
+
try {
|
|
21
|
+
const target = resolveMeshTarget(process.cwd());
|
|
22
|
+
return { items: listPersonas(target.root).map((p) => ({ value: p.name })), directive: "nofiles" };
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// No single target (no mesh, or several with no `current`) — fail CLOSED: offer no personas
|
|
26
|
+
// rather than throw. `cotal spawn --space <TAB>` still lists the running meshes.
|
|
27
|
+
return { items: [], directive: "nofiles" };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
14
30
|
return { items: [], directive: "nofiles" };
|
|
15
31
|
}
|
|
16
32
|
/**
|
|
@@ -25,6 +41,10 @@ export function spawnComplete(argv) {
|
|
|
25
41
|
* shared with the manager); only *how the spec runs* differs — foreground exec
|
|
26
42
|
* here vs. a supervised runtime in the manager. The connector is resolved from
|
|
27
43
|
* the registry by agent type, composed at the root.
|
|
44
|
+
*
|
|
45
|
+
* The mesh it joins — creds and personas together — is resolved by {@link resolveMeshTarget}, so a
|
|
46
|
+
* bare `cotal spawn <persona>` from any directory finds the running mesh (one up, or the `current`
|
|
47
|
+
* default) instead of mistaking `~/.cotal` for a space.
|
|
28
48
|
*/
|
|
29
49
|
/**
|
|
30
50
|
* Auto-number `requested` past any peer already present on the mesh (foo → foo-2 → foo-3) — the same
|
|
@@ -88,46 +108,83 @@ export async function spawn(argv) {
|
|
|
88
108
|
subscribe: { type: "string" }, // read set override (comma-separated)
|
|
89
109
|
"allow-subscribe": { type: "string" }, // read ACL override
|
|
90
110
|
"allow-publish": { type: "string" }, // post ACL override
|
|
111
|
+
file: { type: "string", short: "f" }, // a mesh manifest (cotal.yaml) — deploy onto the running mesh
|
|
112
|
+
"dry-run": { type: "boolean" }, // with -f: print the plan, mutate nothing
|
|
113
|
+
"allow-stale": { type: "string" }, // with -f: waive named stale agents (apply-only)
|
|
114
|
+
runtime: { type: "string" }, // with -f: override the manifest's runtime (pty | tmux | cmux)
|
|
91
115
|
},
|
|
92
116
|
});
|
|
93
117
|
const splitFlag = (v) => (v ? v.split(",").map((s) => s.trim()).filter(Boolean) : undefined);
|
|
118
|
+
// `spawn -f cotal.yaml` is a distinct path: deploy a manifest onto a RUNNING mesh (additive,
|
|
119
|
+
// ownership-scoped). The broker must already be reachable; bringing up a fresh mesh is `up -f`.
|
|
120
|
+
if (values.file) {
|
|
121
|
+
await spawnManifest(values.file, {
|
|
122
|
+
dryRun: Boolean(values["dry-run"]),
|
|
123
|
+
server: values.server,
|
|
124
|
+
space: values.space,
|
|
125
|
+
runtime: values.runtime,
|
|
126
|
+
allowStale: splitFlag(values["allow-stale"]),
|
|
127
|
+
});
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
94
130
|
// Transcript mirroring to `tr-<name>` is OFF by default; `--transcript` opts in
|
|
95
131
|
// (`--no-transcript` is accepted too, to be explicit about the default).
|
|
96
132
|
const transcript = values.transcript ? true : values["no-transcript"] ? false : false;
|
|
133
|
+
// Which mesh this spawn joins — creds + personas together, resolved from --server/--space, a local
|
|
134
|
+
// project, or the registry (the running mesh / the `current` default).
|
|
135
|
+
const target = await resolveTargetOrExit({ server: values.server, space: values.space });
|
|
136
|
+
const { space, server, auth } = target;
|
|
97
137
|
// Where the config lives: --config, else the positional <name-or-path>, else --name
|
|
98
|
-
// (.cotal/agents/<name>.md). With none
|
|
99
|
-
// `cotal spawn` with no args launches
|
|
138
|
+
// (.cotal/agents/<name>.md under the TARGET mesh's root). With none, fall back to its `default`
|
|
139
|
+
// persona — `cotal spawn` with no args launches `<root>/.cotal/agents/default.md`.
|
|
100
140
|
const ref = values.config ?? positionals[0] ?? values.name ?? "default";
|
|
101
|
-
const path = agentFilePath(
|
|
141
|
+
const path = agentFilePath(target.root, ref);
|
|
102
142
|
let def;
|
|
103
143
|
try {
|
|
104
144
|
def = loadAgentFile(path);
|
|
105
145
|
}
|
|
106
146
|
catch (e) {
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
147
|
+
const code = e.code;
|
|
148
|
+
if (code === "ENOENT") {
|
|
149
|
+
console.error(c.red(ref === "default"
|
|
150
|
+
? "✗ no default persona yet — run `cotal setup` to seed one, or name a persona: `cotal spawn <name>`"
|
|
151
|
+
: `✗ no persona "${ref}" in ${target.space}'s ${target.personaRoot} — use \`--config <path>\` for a file elsewhere`));
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
console.error(c.red(`✗ ${e.message}`));
|
|
155
|
+
}
|
|
111
156
|
process.exit(1);
|
|
112
157
|
}
|
|
113
158
|
// --name / --role override the file (name defaults from the file's frontmatter).
|
|
114
159
|
const requested = values.name ?? def.name;
|
|
115
160
|
const role = values.role ?? def.role;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
161
|
+
// Preflight: fail with one sentence if the mesh is down or won't take our creds, instead of
|
|
162
|
+
// crashing mid-connect with a raw NATS Authorization Violation.
|
|
163
|
+
await preflightOrExit(target);
|
|
119
164
|
// A second `cotal spawn` of the same agent would otherwise join under a duplicate mesh identity:
|
|
120
165
|
// auto-number the name past anyone already present (best-effort — this path bypasses the manager's
|
|
121
166
|
// race-free reservation; see uniqueMeshName). Everything below (creds path, launch) uses `name`.
|
|
122
167
|
const name = await uniqueMeshName(requested, { space, server, auth });
|
|
123
168
|
if (name !== requested)
|
|
124
169
|
console.error(`"${requested}" is already on the mesh — spawning as ${name} instead`);
|
|
170
|
+
// When the target was auto-resolved (one mesh up, or the `current` default), say which mesh we
|
|
171
|
+
// picked — it isn't obvious from the cwd. An explicit --space/--server or a local project is
|
|
172
|
+
// self-evident, so stay quiet there.
|
|
173
|
+
if (target.source === "registry" || target.source === "current")
|
|
174
|
+
console.error(c.dim(`→ joining mesh ${space} (${server}) as ${name}`));
|
|
125
175
|
// Auth mode (`.cotal/auth` present): mint a stable identity + scoped creds for this agent
|
|
126
176
|
// and pre-create its bind-only durables, via a short-lived privileged provisioner — the
|
|
127
177
|
// same onboarding the manager does, so the foreground launch joins the authed mesh too.
|
|
128
178
|
// Open mode (no `.cotal/auth`): unchanged — the session connects without creds.
|
|
129
179
|
let id;
|
|
130
180
|
let credsPath;
|
|
181
|
+
// The agent's access policy (flags > persona file) — minted into the creds AND forwarded to the
|
|
182
|
+
// connector (COTAL_SUBSCRIBE / COTAL_ALLOW_*) so the session's runtime read/post set matches its
|
|
183
|
+
// credentials. One source, so a `--subscribe` override can't land in the creds yet be lost at
|
|
184
|
+
// runtime (the connector would otherwise read only the persona file / fall back to `general`).
|
|
185
|
+
const subscribe = splitFlag(values.subscribe) ?? def.subscribe;
|
|
186
|
+
const allowSubscribe = splitFlag(values["allow-subscribe"]) ?? def.allowSubscribe ?? subscribe;
|
|
187
|
+
const allowPublish = splitFlag(values["allow-publish"]) ?? def.allowPublish;
|
|
131
188
|
if (auth) {
|
|
132
189
|
const identity = newIdentity();
|
|
133
190
|
const prov = new CotalEndpoint({
|
|
@@ -142,7 +199,6 @@ export async function spawn(argv) {
|
|
|
142
199
|
});
|
|
143
200
|
prov.on("error", (e) => console.error(`! provisioner: ${e.message}`));
|
|
144
201
|
await prov.start();
|
|
145
|
-
const subscribe = splitFlag(values.subscribe) ?? def.subscribe;
|
|
146
202
|
// Direct foreground spawn is LIVE-ONLY: this short-lived provisioner is not a managing Plane-3 host,
|
|
147
203
|
// and no long-lived manager knows this agent (it's in no manager's `agents` ledger), so a durable
|
|
148
204
|
// boot membership could be neither authorized for reader delivery nor leaved via self-service. Skip
|
|
@@ -150,24 +206,24 @@ export async function spawn(argv) {
|
|
|
150
206
|
// (`cotal start` / `cotal up`).
|
|
151
207
|
const creds = await provisionAgent(prov, auth, identity, {
|
|
152
208
|
subscribe,
|
|
153
|
-
allowSubscribe
|
|
154
|
-
allowPublish
|
|
209
|
+
allowSubscribe,
|
|
210
|
+
allowPublish,
|
|
155
211
|
role,
|
|
156
212
|
capabilities: def.capabilities,
|
|
157
213
|
durableMembership: false,
|
|
158
214
|
});
|
|
159
215
|
await prov.stop();
|
|
160
|
-
credsPath = join(authDir(
|
|
216
|
+
credsPath = join(authDir(target.root), "creds", `${name}.creds`);
|
|
161
217
|
mkdirSync(dirname(credsPath), { recursive: true });
|
|
162
218
|
writeFileSync(credsPath, creds, { mode: 0o600 });
|
|
163
219
|
id = identity.id;
|
|
164
220
|
console.error(`minted creds for ${name} (auth mode) → ${credsPath}`);
|
|
165
221
|
}
|
|
166
222
|
// Which of the operator's personal MCP servers to share with this agent: declared in the cotal
|
|
167
|
-
// config (global ~/.config/cotal +
|
|
168
|
-
// selection. Default (no config) is none — the connector launches isolated.
|
|
223
|
+
// config (global ~/.config/cotal + the target mesh's .cotal), narrowed by an optional
|
|
224
|
+
// --share-tools selection. Default (no config) is none — the connector launches isolated.
|
|
169
225
|
const agentType = values.agent ?? "claude";
|
|
170
|
-
const mcpServers = connectorServers(loadCotalConfig(
|
|
226
|
+
const mcpServers = connectorServers(loadCotalConfig(target.root), agentType, parseShareSelection(values["share-tools"]));
|
|
171
227
|
const connector = registry.resolve("connector", agentType);
|
|
172
228
|
const spec = connector.buildLaunch({
|
|
173
229
|
space,
|
|
@@ -177,6 +233,9 @@ export async function spawn(argv) {
|
|
|
177
233
|
creds: credsPath,
|
|
178
234
|
servers: server,
|
|
179
235
|
configPath: path,
|
|
236
|
+
subscribe,
|
|
237
|
+
allowSubscribe,
|
|
238
|
+
allowPublish,
|
|
180
239
|
prompt: values.prompt,
|
|
181
240
|
transcript,
|
|
182
241
|
mcpServers,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawn.js","sourceRoot":"","sources":["../../src/commands/spawn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"spawn.js","sourceRoot":"","sources":["../../src/commands/spawn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACL,aAAa,EACb,gBAAgB,EACh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AO,CAAC,KAAK,CAAC,sBAAsB,IAAI,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YAClE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;YACrB,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YACxB,OAAO,CAAC,QAAQ,GAAG,IAAI,IAAI,CAAC,CAAC;YAC7B,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cotal topology view -f cotal.yaml` — validate a mesh manifest and print its access graph:
|
|
3
|
+
* per-channel and per-agent subscribe/read/post (with humane labels), any persona-inherited
|
|
4
|
+
* unmanaged scopes, and warnings. Read-only — it mutates nothing and needs no running broker, so
|
|
5
|
+
* it's the safe way to see what `up -f` / `spawn -f` WOULD launch.
|
|
6
|
+
*/
|
|
7
|
+
export declare function topology(argv: string[]): Promise<void>;
|
|
8
|
+
/** Print a manifest/file error as one red block (located issues for a ManifestError) and exit 1. */
|
|
9
|
+
export declare function failManifest(e: unknown): never;
|
|
10
|
+
//# sourceMappingURL=topology.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topology.d.ts","sourceRoot":"","sources":["../../src/commands/topology.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB5D;AAED,oGAAoG;AACpG,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,KAAK,CAM9C"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { parseArgs } from "node:util";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { loadManifest, renderTopology, ManifestError } from "../lib/manifest/index.js";
|
|
4
|
+
import { c } from "../ui.js";
|
|
5
|
+
/**
|
|
6
|
+
* `cotal topology view -f cotal.yaml` — validate a mesh manifest and print its access graph:
|
|
7
|
+
* per-channel and per-agent subscribe/read/post (with humane labels), any persona-inherited
|
|
8
|
+
* unmanaged scopes, and warnings. Read-only — it mutates nothing and needs no running broker, so
|
|
9
|
+
* it's the safe way to see what `up -f` / `spawn -f` WOULD launch.
|
|
10
|
+
*/
|
|
11
|
+
export async function topology(argv) {
|
|
12
|
+
const [sub, ...rest] = argv;
|
|
13
|
+
if (sub !== "view") {
|
|
14
|
+
console.error(c.red(`✗ unknown topology subcommand "${sub ?? ""}" — expected: view`));
|
|
15
|
+
console.error(c.dim("cotal topology view -f <cotal.yaml>"));
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
const { values, positionals } = parseArgs({
|
|
19
|
+
args: rest,
|
|
20
|
+
allowPositionals: true,
|
|
21
|
+
options: { file: { type: "string", short: "f" } },
|
|
22
|
+
});
|
|
23
|
+
const file = values.file ?? positionals[0];
|
|
24
|
+
if (!file) {
|
|
25
|
+
console.error(c.red("✗ a manifest file is required — `cotal topology view -f <cotal.yaml>`"));
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const prepared = loadManifest(resolve(file));
|
|
30
|
+
console.log(renderTopology(prepared));
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
failManifest(e);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Print a manifest/file error as one red block (located issues for a ManifestError) and exit 1. */
|
|
37
|
+
export function failManifest(e) {
|
|
38
|
+
if (e instanceof ManifestError)
|
|
39
|
+
console.error(c.red(e.message));
|
|
40
|
+
else if (e?.code === "ENOENT")
|
|
41
|
+
console.error(c.red(`✗ manifest file not found: ${e.path ?? ""}`));
|
|
42
|
+
else
|
|
43
|
+
console.error(c.red(`✗ ${e.message}`));
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=topology.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topology.js","sourceRoot":"","sources":["../../src/commands/topology.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,CAAC,EAAE,MAAM,UAAU,CAAC;AAE7B;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAc;IAC3C,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAC5B,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;QACnB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,kCAAkC,GAAG,IAAI,EAAE,oBAAoB,CAAC,CAAC,CAAC;QACtF,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC,CAAC;QAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,SAAS,CAAC;QACxC,IAAI,EAAE,IAAI;QACV,gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;KAClD,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;IAC3C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,uEAAuE,CAAC,CAAC,CAAC;QAC9F,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7C,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,YAAY,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,oGAAoG;AACpG,MAAM,UAAU,YAAY,CAAC,CAAU;IACrC,IAAI,CAAC,YAAY,aAAa;QAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;SAC3D,IAAK,CAA2B,EAAE,IAAI,KAAK,QAAQ;QACtD,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,8BAA+B,CAA2B,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;;QAC3F,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAM,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACvD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
package/dist/commands/up.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ChannelRegistryFile } from "@cotal-ai/core";
|
|
1
2
|
export declare function up(argv: string[]): Promise<void>;
|
|
2
3
|
export interface DetachOpts {
|
|
3
4
|
server?: string;
|
|
@@ -6,6 +7,9 @@ export interface DetachOpts {
|
|
|
6
7
|
open?: boolean;
|
|
7
8
|
channels?: string;
|
|
8
9
|
host?: string;
|
|
10
|
+
/** Channel-registry seed in memory (the `cotal up -f` manifest path), used instead of reading a
|
|
11
|
+
* `--channels` file. Takes precedence over {@link channels}. */
|
|
12
|
+
seed?: ChannelRegistryFile;
|
|
9
13
|
/** Live boot lines, tailed from the server's log file (safe for a detached child). */
|
|
10
14
|
onLine?: (line: string) => void;
|
|
11
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"up.d.ts","sourceRoot":"","sources":["../../src/commands/up.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"up.d.ts","sourceRoot":"","sources":["../../src/commands/up.ts"],"names":[],"mappings":"AAaA,OAAO,EAWL,KAAK,mBAAmB,EACzB,MAAM,gBAAgB,CAAC;AAyBxB,wBAAsB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA6HtD;AA8GD,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;qEACiE;IACjE,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,sFAAsF;IACtF,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,GAAE,UAAe,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAsCvH"}
|