@cotal-ai/cli 0.171.2 → 0.171.3
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/command.d.ts.map +1 -1
- package/dist/command.js +140 -85
- package/dist/command.js.map +1 -1
- package/dist/commands/app-identity.d.ts +6 -0
- package/dist/commands/app-identity.d.ts.map +1 -1
- package/dist/commands/app-identity.js +4 -4
- package/dist/commands/app-identity.js.map +1 -1
- package/dist/commands/backup-maintenance.js +1 -1
- package/dist/commands/backup-maintenance.js.map +1 -1
- package/dist/commands/down.d.ts.map +1 -1
- package/dist/commands/down.js +7 -5
- package/dist/commands/down.js.map +1 -1
- package/dist/commands/ext.js +1 -1
- package/dist/commands/ext.js.map +1 -1
- package/dist/commands/help.d.ts.map +1 -1
- package/dist/commands/help.js +2 -13
- package/dist/commands/help.js.map +1 -1
- package/dist/commands/history-clear.d.ts.map +1 -1
- package/dist/commands/history-clear.js +18 -2
- package/dist/commands/history-clear.js.map +1 -1
- package/dist/commands/join.js +7 -2
- package/dist/commands/join.js.map +1 -1
- package/dist/commands/manager-service.d.ts +1 -1
- package/dist/commands/manager-service.d.ts.map +1 -1
- package/dist/commands/manager-service.js +9 -4
- package/dist/commands/manager-service.js.map +1 -1
- package/dist/commands/reset-space-apply.d.ts.map +1 -1
- package/dist/commands/reset-space-apply.js +2 -1
- package/dist/commands/reset-space-apply.js.map +1 -1
- package/dist/commands/reset-store-apply.d.ts +6 -0
- package/dist/commands/reset-store-apply.d.ts.map +1 -1
- package/dist/commands/reset-store-apply.js +22 -2
- package/dist/commands/reset-store-apply.js.map +1 -1
- package/dist/commands/service-registry.d.ts.map +1 -1
- package/dist/commands/service-registry.js +2 -0
- package/dist/commands/service-registry.js.map +1 -1
- package/dist/commands/space.d.ts +1 -0
- package/dist/commands/space.d.ts.map +1 -1
- package/dist/commands/space.js +5 -1
- package/dist/commands/space.js.map +1 -1
- package/dist/commands/spawn.d.ts +7 -2
- package/dist/commands/spawn.d.ts.map +1 -1
- package/dist/commands/spawn.js +115 -30
- package/dist/commands/spawn.js.map +1 -1
- package/dist/commands/stack-down.js +5 -2
- package/dist/commands/stack-down.js.map +1 -1
- package/dist/commands/stack-up.d.ts.map +1 -1
- package/dist/commands/stack-up.js +5 -4
- package/dist/commands/stack-up.js.map +1 -1
- package/dist/commands/status.d.ts +6 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +69 -26
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +47 -22
- package/dist/commands/up.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +3 -2
- package/dist/commands/update.js.map +1 -1
- package/dist/ext-loader.d.ts +1 -1
- package/dist/ext-loader.d.ts.map +1 -1
- package/dist/ext-loader.js +3 -3
- package/dist/ext-loader.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/local-process-stop.d.ts +2 -0
- package/dist/lib/local-process-stop.d.ts.map +1 -1
- package/dist/lib/local-process-stop.js +1 -0
- package/dist/lib/local-process-stop.js.map +1 -1
- package/dist/lib/manager-proc.d.ts +2 -1
- package/dist/lib/manager-proc.d.ts.map +1 -1
- package/dist/lib/manager-proc.js +8 -2
- package/dist/lib/manager-proc.js.map +1 -1
- package/dist/lib/nats-bin.d.ts +1 -0
- package/dist/lib/nats-bin.d.ts.map +1 -1
- package/dist/lib/nats-bin.js +1 -0
- package/dist/lib/nats-bin.js.map +1 -1
- package/dist/lib/persona-files.d.ts +1 -1
- package/dist/lib/persona-files.d.ts.map +1 -1
- package/dist/lib/persona-files.js +10 -2
- package/dist/lib/persona-files.js.map +1 -1
- package/dist/lib/restore.d.ts +4 -3
- package/dist/lib/restore.d.ts.map +1 -1
- package/dist/lib/restore.js +12 -10
- package/dist/lib/restore.js.map +1 -1
- package/dist/lib/self-exec.d.ts.map +1 -1
- package/dist/lib/self-exec.js +8 -2
- package/dist/lib/self-exec.js.map +1 -1
- package/dist/lib/service-adapters.d.ts +1 -1
- package/dist/lib/service-adapters.d.ts.map +1 -1
- package/dist/lib/service-adapters.js +2 -2
- package/dist/lib/service-adapters.js.map +1 -1
- package/dist/lib/service-census.d.ts +5 -5
- package/dist/lib/service-install-intent.d.ts +2 -2
- package/dist/lib/service-instances.d.ts +2 -2
- package/dist/lib/service-presets.d.ts +1 -1
- package/dist/lib/service-presets.d.ts.map +1 -1
- package/dist/lib/service-presets.js +4 -4
- package/dist/lib/service-presets.js.map +1 -1
- package/dist/lib/service-supervision.d.ts +1 -1
- package/dist/lib/service-systemd-attempt-read.d.ts +3 -3
- package/dist/lib/service-uninstall-intent.d.ts +2 -2
- package/dist/lib/stack-journal.d.ts +5 -2
- package/dist/lib/stack-journal.d.ts.map +1 -1
- package/dist/lib/stack-journal.js +5 -2
- package/dist/lib/stack-journal.js.map +1 -1
- package/dist/lib/team-agent-removal.d.ts +1 -1
- package/dist/lib/version.d.ts +2 -0
- package/dist/lib/version.d.ts.map +1 -1
- package/dist/lib/version.js +15 -1
- package/dist/lib/version.js.map +1 -1
- package/dist/seed/reconcile.d.ts.map +1 -1
- package/dist/seed/reconcile.js +5 -2
- package/dist/seed/reconcile.js.map +1 -1
- package/package.json +12 -4
package/dist/commands/spawn.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { spawn as spawnProcess } from "node:child_process";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
|
-
import { readFileSync, rmSync, statSync } from "node:fs";
|
|
3
|
+
import { readFileSync, realpathSync, rmSync, statSync } from "node:fs";
|
|
4
4
|
import { constants as osConstants, hostname } from "node:os";
|
|
5
5
|
import { resolve as resolvePath } from "node:path";
|
|
6
|
-
import { assertValidRole, agentFilePath, AgentGrantConflictError, connectorServers, spawnEnvAllow, deprovisionAgent, discardLaunchArtifacts, firstFreeName, reclaimWithChild, loadCotalConfig, modelPolicyRefusal, mintCreds, newIdentity, DEV_OWNER, parseShareSelection, principalKey, assertLifecycleToken, mintLifecycleUid, MANAGED_HANDOFF_FILE_ENV, parseManagedLifecycleHandoff, spawnNameError, provisionAgent, provisionAgentDurables, lowerPersonaEndpoints, copyPersonaEndpoints, registry, resolveAuthProvider, resolveReadAcl, runAgentBearer, GOAL_ENTITY_RUNNING_DETAIL_KIND, EP_UNDECLARED_ARG, seatCapFrom, acquireLock, inspectLock, localConsumerClaimPath, transferBucket, writeTransfer, peerLabel, attemptCleanup, describeCleanupFailures, rejectionText, } from "@cotal-ai/core";
|
|
7
|
-
import { parseCommaList, CommandFailure, loadLaunchPersonaFile, personaFileReference, PersonaSourceError, inputDisabledByFlag, jsonFlag, plainFlag, presentationOf, recordOperationWarning, renderReport, terminalWidth, wrapWords, writeResult, agentActorTokenKey, agentLifecycleSecretFilePaths, agentSecretFilePaths, agentSecretKeyForFile, agentSentinelCredsKey, authDir, cachedPreferences, credsFlag, launchFlags, findMesh, getSpaceAuth, loadManagerInstanceIdentity, materializeSecretToFile, mergeLaunchOptions, parseLaunchOptions, preflightOrThrow, provenance, resolveAgentType, resolveOnPath, resolveTargetOrThrow, serverFlag, spaceAccountPath, spaceFlag, spaceKey, userAuthStateDir, workspaceSecretStore, refreshRegistrationPolicy, resolveSeatControlTarget, connectUserControlOrExit, userViewAuth, oneLine, codeSpan, DEFAULT_CONNECTOR, hintedConnector, manifestExtensionNames, OFFICIAL_CONNECTORS, recordOperationSpace, resolveMeshTarget, activateTerminalSeat, issueTerminalSeat, retireTerminalSeat, seatExpiryAt, resolveControlTarget, } from "@cotal-ai/workspace";
|
|
6
|
+
import { assertValidChannel, assertValidRole, agentFilePath, AgentGrantConflictError, connectorServers, spawnEnvAllow, deprovisionAgent, discardLaunchArtifacts, firstFreeName, reclaimWithChild, loadCotalConfig, modelPolicyRefusal, mintCreds, newIdentity, DEV_OWNER, parseShareSelection, principalKey, assertLifecycleToken, mintLifecycleUid, MANAGED_HANDOFF_FILE_ENV, parseManagedLifecycleHandoff, spawnNameError, provisionAgent, provisionAgentDurables, lowerPersonaEndpoints, copyPersonaEndpoints, registry, resolveAuthProvider, resolveReadAcl, runAgentBearer, GOAL_ENTITY_RUNNING_DETAIL_KIND, EP_UNDECLARED_ARG, seatCapFrom, acquireLock, inspectLock, localConsumerClaimPath, transferBucket, writeTransfer, peerLabel, attemptCleanup, describeCleanupFailures, rejectionText, } from "@cotal-ai/core";
|
|
7
|
+
import { parseCommaList, CommandFailure, isCommandFailure, loadLaunchPersonaFile, personaFileReference, PersonaSourceError, inputDisabledByFlag, jsonFlag, plainFlag, presentationOf, recordOperationWarning, renderReport, terminalWidth, wrapWords, writeResult, agentActorTokenKey, agentLifecycleSecretFilePaths, agentSecretFilePaths, agentSecretKeyForFile, agentSentinelCredsKey, authDir, cachedPreferences, credsFlag, launchFlags, findMesh, getSpaceAuth, loadManagerInstanceIdentity, materializeSecretToFile, mergeLaunchOptions, parseLaunchOptions, preflightOrThrow, provenance, resolveAgentType, resolveOnPath, resolveTargetOrThrow, serverFlag, spaceAccountPath, spaceFlag, spaceKey, userAuthStateDir, workspaceSecretStore, refreshRegistrationPolicy, resolveSeatControlTarget, connectUserControlOrExit, userViewAuth, oneLine, codeSpan, DEFAULT_CONNECTOR, hintedConnector, manifestExtensionNames, OFFICIAL_CONNECTORS, recordOperationSpace, resolveMeshTarget, activateTerminalSeat, issueTerminalSeat, retireTerminalSeat, seatExpiryAt, resolveControlTarget, } from "@cotal-ai/workspace";
|
|
8
8
|
import { readManagedLaunch, requestManagedLaunch } from "@cotal-ai/workspace/launch";
|
|
9
9
|
import { c, stderrLine } from "../ui.js";
|
|
10
10
|
import { liveMeshNames } from "../lib/live-names.js";
|
|
@@ -325,7 +325,8 @@ function seatExpiry(values, direct) {
|
|
|
325
325
|
/** The spawn an `--on` refusal tells the caller to rerun: the persona and `-d` as given, with the
|
|
326
326
|
* `--space` or `--server` given (#7644). */
|
|
327
327
|
const spawnRerun = (values, positionals) => onRerun("cotal spawn", values, [...positionals, ...(values.detach === true ? ["-d"] : [])]);
|
|
328
|
-
/** Check the public mode and spelling before catalog preparation or identity allocation.
|
|
328
|
+
/** Check the public mode and spelling before catalog preparation or identity allocation.
|
|
329
|
+
* Return the parsed channel overrides for the foreground policy. */
|
|
329
330
|
export function validateSpawnArguments(args) {
|
|
330
331
|
const values = args.values;
|
|
331
332
|
const handoffRefusal = managedHandoffRefusal();
|
|
@@ -344,7 +345,9 @@ export function validateSpawnArguments(args) {
|
|
|
344
345
|
if (values.file !== undefined && (args.positionals.length || values.config !== undefined))
|
|
345
346
|
throw new CommandFailure("refused", "USAGE_INVALID", "choose one positional persona or --file/-f, not multiple explicit persona sources");
|
|
346
347
|
if (!internal && values.config !== undefined)
|
|
347
|
-
throw new CommandFailure("refused", "USAGE_INVALID", "--config is reserved for persisted internal launch callers
|
|
348
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "--config is reserved for persisted internal launch callers", {
|
|
349
|
+
remedy: "use `cotal spawn <persona>` for a catalog name or `cotal spawn --file <persona-file>` for a file",
|
|
350
|
+
});
|
|
348
351
|
if (values.file !== undefined) {
|
|
349
352
|
try {
|
|
350
353
|
personaFileReference(values.file);
|
|
@@ -392,7 +395,7 @@ export function validateSpawnArguments(args) {
|
|
|
392
395
|
seatExpiry(values, direct);
|
|
393
396
|
if (!values["dry-run"] && !direct && !values.detach && (values.json || values.plain || inputDisabledByFlag() || !process.stdin.isTTY || !process.stdout.isTTY))
|
|
394
397
|
throw new CommandFailure("refused", "USAGE_INVALID", "attaching to a manager's launch needs usable input and output terminals before an identity is allocated", { remedy: "add -d to wait for readiness without attaching, or drop --on to run it in this terminal", selfContained: true });
|
|
395
|
-
for (const field of ["harness", "agent", "model", "variant", "name"])
|
|
398
|
+
for (const field of ["harness", "agent", "model", "variant", "name", "cwd"])
|
|
396
399
|
if (values[field] !== undefined && !values[field].trim())
|
|
397
400
|
throw new CommandFailure("refused", "USAGE_INVALID", `--${field} cannot be empty`);
|
|
398
401
|
if (values.events && values["no-events"])
|
|
@@ -408,10 +411,39 @@ export function validateSpawnArguments(args) {
|
|
|
408
411
|
catch {
|
|
409
412
|
throw new CommandFailure("refused", "USAGE_INVALID", "invalid launch options, native role or tool-sharing selection; use declared keys and unique key=value option pairs");
|
|
410
413
|
}
|
|
414
|
+
const channels = {
|
|
415
|
+
subscribe: parseCommaList(values.subscribe),
|
|
416
|
+
"allow-subscribe": parseCommaList(values["allow-subscribe"]),
|
|
417
|
+
"allow-publish": parseCommaList(values["allow-publish"]),
|
|
418
|
+
};
|
|
419
|
+
for (const [flag, list] of Object.entries(channels)) {
|
|
420
|
+
for (const channel of list ?? []) {
|
|
421
|
+
try {
|
|
422
|
+
assertValidChannel(channel);
|
|
423
|
+
}
|
|
424
|
+
catch (error) {
|
|
425
|
+
throw new CommandFailure("refused", "USAGE_INVALID", `--${flag}: ${oneLine(error.message)}`, {
|
|
426
|
+
selfContained: true,
|
|
427
|
+
...(channel.startsWith("#") ? { remedy: `pass the channel without its #, as ${JSON.stringify(channel.slice(1))}` } : {}),
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
if (channels.subscribe !== undefined && channels["allow-subscribe"] !== undefined) {
|
|
433
|
+
try {
|
|
434
|
+
resolveReadAcl(channels.subscribe, channels["allow-subscribe"]);
|
|
435
|
+
}
|
|
436
|
+
catch (error) {
|
|
437
|
+
throw new CommandFailure("refused", "USAGE_INVALID", oneLine(error.message), {
|
|
438
|
+
remedy: "include every --subscribe channel in --allow-subscribe", selfContained: true,
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
}
|
|
411
442
|
if (!internal && args.positionals.length > 1)
|
|
412
443
|
throw new CommandFailure("refused", "USAGE_INVALID", "spawn takes one persona; pass the kickoff request with --prompt/-p");
|
|
413
444
|
if (!internal && values.config !== undefined && args.positionals.length)
|
|
414
445
|
throw new CommandFailure("refused", "USAGE_INVALID", "choose one persona input, not both a positional name and --config");
|
|
446
|
+
return channels;
|
|
415
447
|
}
|
|
416
448
|
/** Foreground `cotal spawn` resolves its `--agent` connector from the registry (spawn.ts below); on
|
|
417
449
|
* the published binary nothing static-imports connectors, so the resolved one is materialized as a
|
|
@@ -447,12 +479,10 @@ function connectorListed(name) {
|
|
|
447
479
|
* reservation reason, and the `_` remedy — before any request leaves. A courtesy only: the
|
|
448
480
|
* manager door stays the enforcement point; this is why the CLI passes the target mesh's auth
|
|
449
481
|
* mode rather than restating the grammar (static mode keys the actor on the nkey, not the name). */
|
|
450
|
-
function
|
|
482
|
+
function refuseUnmintableName(name, userMode) {
|
|
451
483
|
const refusal = spawnNameError(name, { userMode });
|
|
452
|
-
if (refusal)
|
|
453
|
-
|
|
454
|
-
process.exit(1);
|
|
455
|
-
}
|
|
484
|
+
if (refusal)
|
|
485
|
+
throw new CommandFailure("refused", "USAGE_INVALID", refusal, { selfContained: true });
|
|
456
486
|
}
|
|
457
487
|
/** Whether a managed launch can reach only this root's own manager: the instance it names, or else
|
|
458
488
|
* the only one the registry lists, is the one recorded under the target's root. An unread registry
|
|
@@ -583,7 +613,7 @@ export async function launchManagedPersona(values, positionals, events, launchOp
|
|
|
583
613
|
// resolved manager-side, so the effective identity is `--name` alone — when it is absent the
|
|
584
614
|
// manager applies the same spawnNameError to the file's `name:` at its own door.
|
|
585
615
|
if (values.name !== undefined)
|
|
586
|
-
|
|
616
|
+
refuseUnmintableName(values.name, t.mode === "user");
|
|
587
617
|
const eventsRequired = policy?.events === "required";
|
|
588
618
|
if (eventsRequired && events === false) {
|
|
589
619
|
throw new CommandFailure("refused", "PERMISSION_DENIED", `space "${t.space}" requires the event plane by registration policy; no launch was submitted`);
|
|
@@ -603,7 +633,7 @@ export async function launchManagedPersona(values, positionals, events, launchOp
|
|
|
603
633
|
// can read: ask it, so the carry looks with the connector the launch runs (#2899).
|
|
604
634
|
const agent = values.agent ?? await launchAgentOrExit(t, on, { name: ref, config: managerConfigRef, defaultAgent });
|
|
605
635
|
// The carry and its transfer-writer view stay on the mesh selected for this launch.
|
|
606
|
-
const claim = await
|
|
636
|
+
const claim = await carryTranscript({ ...flags, space: t.space, server: t.server }, on, values.resume, agent);
|
|
607
637
|
if (claim !== undefined)
|
|
608
638
|
resumeClaim = { claim, agent };
|
|
609
639
|
}
|
|
@@ -969,21 +999,33 @@ async function launchAgentOrExit(t, on, fields) {
|
|
|
969
999
|
* connector can tell a local session from one that lives on the manager's host, so a connector this
|
|
970
1000
|
* CLI cannot load is refused.
|
|
971
1001
|
*/
|
|
972
|
-
async function
|
|
1002
|
+
async function carryTranscript(flags, on, id, agent) {
|
|
1003
|
+
let connector;
|
|
1004
|
+
try {
|
|
1005
|
+
connector = await materializeExtension({ kind: "connector", name: agent });
|
|
1006
|
+
}
|
|
1007
|
+
catch (error) {
|
|
1008
|
+
if (isCommandFailure(error))
|
|
1009
|
+
throw error;
|
|
1010
|
+
if (!connectorListed(agent))
|
|
1011
|
+
throw missingConnector(agent, { space: flags.space });
|
|
1012
|
+
throw new CommandFailure("refused", "DEPENDENCY_UNAVAILABLE", `resume: ${oneLine(error.message)}`);
|
|
1013
|
+
}
|
|
973
1014
|
let found;
|
|
974
1015
|
try {
|
|
975
|
-
|
|
976
|
-
found = registry.resolve("connector", agent).resumeTranscript?.find(id, process.env);
|
|
1016
|
+
found = connector.resumeTranscript?.find(id, process.env);
|
|
977
1017
|
}
|
|
978
|
-
catch (
|
|
979
|
-
|
|
980
|
-
|
|
1018
|
+
catch (error) {
|
|
1019
|
+
if (isCommandFailure(error))
|
|
1020
|
+
throw error;
|
|
1021
|
+
throw new CommandFailure("refused", "USAGE_INVALID", `resume: ${error.message}`, { selfContained: true });
|
|
981
1022
|
}
|
|
982
1023
|
if (found === undefined)
|
|
983
1024
|
return undefined;
|
|
984
1025
|
if (on === undefined) {
|
|
985
|
-
|
|
986
|
-
|
|
1026
|
+
throw new CommandFailure("refused", "USAGE_INVALID", `resume: session ${id} is held on this host, and carrying it needs one manager instance`, {
|
|
1027
|
+
remedy: "pass --on <instance>", selfContained: true,
|
|
1028
|
+
});
|
|
987
1029
|
}
|
|
988
1030
|
const bytes = readFileSync(found.path);
|
|
989
1031
|
const sha256 = createHash("sha256").update(bytes).digest("hex");
|
|
@@ -1049,7 +1091,7 @@ async function transferWriterOrExit(flags, t, instanceId, hex) {
|
|
|
1049
1091
|
*/
|
|
1050
1092
|
export async function spawn(args) {
|
|
1051
1093
|
const positionals = args.positionals;
|
|
1052
|
-
validateSpawnArguments(args);
|
|
1094
|
+
const channels = validateSpawnArguments(args);
|
|
1053
1095
|
const values = { ...args.values, ...(typeof args.values.harness === "string" ? { agent: args.values.harness } : {}), ...(typeof args.values.file === "string" ? { config: personaFileReference(args.values.file) } : {}) };
|
|
1054
1096
|
if (values["dry-run"])
|
|
1055
1097
|
return spawnLaunchPreview({ ...args, values });
|
|
@@ -1217,6 +1259,24 @@ export async function spawn(args) {
|
|
|
1217
1259
|
stderrLine("✗ ", "--creds is only valid with --detach (it authenticates the manager control call)", c.red);
|
|
1218
1260
|
process.exit(1);
|
|
1219
1261
|
}
|
|
1262
|
+
let launchCwd;
|
|
1263
|
+
if (values.cwd !== undefined) {
|
|
1264
|
+
const requestedCwd = resolvePath(values.cwd);
|
|
1265
|
+
let reason;
|
|
1266
|
+
try {
|
|
1267
|
+
launchCwd = realpathSync(requestedCwd);
|
|
1268
|
+
if (!statSync(launchCwd).isDirectory())
|
|
1269
|
+
reason = "is not a directory";
|
|
1270
|
+
}
|
|
1271
|
+
catch (error) {
|
|
1272
|
+
const code = error.code;
|
|
1273
|
+
reason = code === "ENOENT" ? "does not exist" : code === "ENOTDIR" ? "is not a directory" : `cannot be used (${oneLine(error.message)})`;
|
|
1274
|
+
}
|
|
1275
|
+
if (reason !== undefined)
|
|
1276
|
+
throw new CommandFailure("refused", "TARGET_UNAVAILABLE", `--cwd ${JSON.stringify(requestedCwd)} ${reason}. Nothing was launched.`, {
|
|
1277
|
+
target: { path: requestedCwd }, remedy: "pass an existing directory to --cwd",
|
|
1278
|
+
});
|
|
1279
|
+
}
|
|
1220
1280
|
// An enrollment may bootstrap the stock remote user-mesh record before normal target resolution.
|
|
1221
1281
|
// Redeem only when the named space is not registered; an existing entry defers redemption until
|
|
1222
1282
|
// after persona resolution so the response actor can be checked against the requested identity.
|
|
@@ -1338,7 +1398,7 @@ export async function spawn(args) {
|
|
|
1338
1398
|
}
|
|
1339
1399
|
// #867: same door as the detached path — the effective identity (flag or file) must be mintable
|
|
1340
1400
|
// before any provision work; core's own refusal names the offender and the `_` remedy.
|
|
1341
|
-
|
|
1401
|
+
refuseUnmintableName(requested, target.mode === "user");
|
|
1342
1402
|
// #581: the same per-role model allowlist the manager enforces on a detached spawn, judged on the
|
|
1343
1403
|
// effective role, model (flag over file) and launch options before anything is provisioned or launched.
|
|
1344
1404
|
let cotalConfig;
|
|
@@ -1402,11 +1462,31 @@ export async function spawn(args) {
|
|
|
1402
1462
|
}
|
|
1403
1463
|
const binaryPins = { opencode: process.env.COTAL_OPENCODE_BIN, codex: process.env.COTAL_CODEX_BIN };
|
|
1404
1464
|
const missing = (connector.requires ?? []).filter((bin) => !resolveOnPath(binaryPins[bin]?.trim() || bin));
|
|
1405
|
-
if (missing.length)
|
|
1406
|
-
|
|
1465
|
+
if (missing.length) {
|
|
1466
|
+
const binaries = missing.join(", ");
|
|
1467
|
+
const guide = ["claude", "codex", "opencode", "jcode", "hermes", "pi"].includes(agentType) ? `https://docs.cotal.ai/docs/connect-${agentType}/` : "https://docs.cotal.ai/docs/connectors/";
|
|
1468
|
+
const message = `${agentType} needs ${binaries} on PATH; nothing was launched`;
|
|
1469
|
+
const install = `Follow ${guide} to install ${binaries}`;
|
|
1470
|
+
if (agentType === "hermes") {
|
|
1471
|
+
if (process.env.COTAL_HERMES_ADOPT_HOME?.trim()) {
|
|
1472
|
+
throw new CommandFailure("refused", "DEPENDENCY_UNAVAILABLE", message, {
|
|
1473
|
+
target: { space, path },
|
|
1474
|
+
remedy: `${install} and check the adopted Hermes profile's requirements before retrying.`,
|
|
1475
|
+
});
|
|
1476
|
+
}
|
|
1477
|
+
if (!model) {
|
|
1478
|
+
const example = codeSpan(`${displayCmd()} spawn --harness hermes --no-events --model <model>`);
|
|
1479
|
+
throw new CommandFailure("refused", "DEPENDENCY_UNAVAILABLE", `${message}. A managed Hermes profile needs a model. Set one with --model or the agent file's model: field.`, {
|
|
1480
|
+
target: { space, path },
|
|
1481
|
+
remedy: `${install}. For a basic launch: ${example}`,
|
|
1482
|
+
});
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
throw new CommandFailure("refused", "DEPENDENCY_UNAVAILABLE", message, {
|
|
1407
1486
|
target: { space, path },
|
|
1408
|
-
remedy:
|
|
1487
|
+
remedy: `${install}, then retry: \`${displayCmd()} spawn ${args.raw.map(shellWord).join(" ")}\``,
|
|
1409
1488
|
});
|
|
1489
|
+
}
|
|
1410
1490
|
if (variant && !connector.supportsModelVariant) {
|
|
1411
1491
|
throw new CommandFailure("refused", "USAGE_INVALID", `${agentType} connector does not support model variants (variant)`, { target: { space, path } });
|
|
1412
1492
|
}
|
|
@@ -1451,16 +1531,16 @@ export async function spawn(args) {
|
|
|
1451
1531
|
// connector (COTAL_SUBSCRIBE / COTAL_ALLOW_*) so the session's runtime read/post set matches its
|
|
1452
1532
|
// credentials. One source, so a `--subscribe` override can't land in the creds yet be lost at
|
|
1453
1533
|
// runtime (the connector would otherwise read only the persona file and miss the override).
|
|
1454
|
-
let subscribe =
|
|
1534
|
+
let subscribe = channels.subscribe ?? def.subscribe;
|
|
1455
1535
|
let allowSubscribe;
|
|
1456
1536
|
try {
|
|
1457
|
-
allowSubscribe = resolveReadAcl(subscribe ?? [],
|
|
1537
|
+
allowSubscribe = resolveReadAcl(subscribe ?? [], channels["allow-subscribe"] ?? def.allowSubscribe);
|
|
1458
1538
|
}
|
|
1459
1539
|
catch (e) {
|
|
1460
1540
|
stderrLine("✗ ", `${e.message}`, c.red);
|
|
1461
1541
|
process.exit(1);
|
|
1462
1542
|
}
|
|
1463
|
-
let allowPublish =
|
|
1543
|
+
let allowPublish = channels["allow-publish"] ?? def.allowPublish;
|
|
1464
1544
|
// The AG-UI event plane, refused HERE for the same reason the manager refuses it before
|
|
1465
1545
|
// provisioning: a connector that cannot emit must stop the launch while there is still nothing to
|
|
1466
1546
|
// roll back. The GRANT cannot be derived yet, because it is keyed on the principal and in user
|
|
@@ -1480,6 +1560,7 @@ export async function spawn(args) {
|
|
|
1480
1560
|
endpoints: copyPersonaEndpoints(def.endpoints) ?? [], prompt: values.prompt,
|
|
1481
1561
|
resume: values.resume, events: launchEvents, eventPayloads, eventsRequired,
|
|
1482
1562
|
mcpServers, mcpServersExclusive: shareTools !== undefined, envAllow,
|
|
1563
|
+
// Keep the foreground directory on the child spawn. Connector cwd marks a supervised seat.
|
|
1483
1564
|
workspaceRoot: target.root,
|
|
1484
1565
|
};
|
|
1485
1566
|
try {
|
|
@@ -1724,6 +1805,10 @@ export async function spawn(args) {
|
|
|
1724
1805
|
...(acceptedToken !== undefined ? { acceptedToken } : {}),
|
|
1725
1806
|
userAuth,
|
|
1726
1807
|
lifecycleUid,
|
|
1808
|
+
// Provisioning can replace the requested ACLs or add an event grant.
|
|
1809
|
+
subscribe,
|
|
1810
|
+
allowSubscribe,
|
|
1811
|
+
allowPublish,
|
|
1727
1812
|
});
|
|
1728
1813
|
}
|
|
1729
1814
|
catch (error) {
|
|
@@ -1758,7 +1843,7 @@ export async function spawn(args) {
|
|
|
1758
1843
|
env: spec.env ?? {},
|
|
1759
1844
|
// `--cwd` roots the agent at another folder/repo (launch-grammar parity with --detach); a
|
|
1760
1845
|
// relative path resolves against the invoking shell's cwd. Omitted → inherit this cwd.
|
|
1761
|
-
cwd:
|
|
1846
|
+
cwd: launchCwd,
|
|
1762
1847
|
});
|
|
1763
1848
|
}
|
|
1764
1849
|
catch (e) {
|