@cotal-ai/cli 0.102.0 → 0.103.1
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/spawn.d.ts.map +1 -1
- package/dist/commands/spawn.js +54 -30
- package/dist/commands/spawn.js.map +1 -1
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +18 -1
- package/dist/commands/up.js.map +1 -1
- package/dist/lib/control.d.ts +11 -0
- package/dist/lib/control.d.ts.map +1 -1
- package/dist/lib/control.js +21 -0
- package/dist/lib/control.js.map +1 -1
- package/dist/lib/delivery-proc.d.ts.map +1 -1
- package/dist/lib/delivery-proc.js +6 -5
- package/dist/lib/delivery-proc.js.map +1 -1
- package/dist/lib/local-process-stop.d.ts +2 -2
- package/dist/lib/local-process-stop.d.ts.map +1 -1
- package/dist/lib/local-process-stop.js +4 -0
- package/dist/lib/local-process-stop.js.map +1 -1
- package/dist/lib/manager-choice.d.ts +12 -2
- package/dist/lib/manager-choice.d.ts.map +1 -1
- package/dist/lib/manager-choice.js +15 -6
- package/dist/lib/manager-choice.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../src/commands/spawn.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../src/commands/spawn.ts"],"names":[],"mappings":"AAKA,OAAO,EAuCL,KAAK,gBAAgB,EAGrB,KAAK,YAAY,EAEjB,KAAK,UAAU,EAEf,KAAK,UAAU,EAEf,KAAK,uBAAuB,EAC5B,KAAK,UAAU,EAGhB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACmN,KAAK,aAAa,EAAoB,KAAK,MAAM,EA0C1Q,MAAM,qBAAqB,CAAC;AAQ7B,OAAO,EAAgN,KAAK,oBAAoB,EAAE,KAAK,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAa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E,MAAM,EAAE,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAIjH"}
|
package/dist/commands/spawn.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createHash } from "node:crypto";
|
|
|
3
3
|
import { readFileSync, rmSync, statSync } from "node:fs";
|
|
4
4
|
import { hostname } from "node:os";
|
|
5
5
|
import { resolve as resolvePath } from "node:path";
|
|
6
|
-
import { assertValidRole, agentFilePath, AgentGrantConflictError, connectorServers, spawnEnvAllow, deprovisionAgent, discardLaunchArtifacts, firstFreeName, isReachable, reclaimWithChild, loadCotalConfig, modelPolicyRefusal, mintCreds, newIdentity, DEV_OWNER, parseShareSelection, principalKey, assertLifecycleToken, mintLifecycleUid, MANAGED_HANDOFF_FILE_ENV, parseManagedLifecycleHandoff, spawnNameError, provisionAgent, provisionAgentDurables, registry, resolveAuthProvider, resolveReadAcl, runAgentBearer, CotalEndpoint, GOAL_ENTITY_RUNNING_DETAIL_KIND, acquireLock, inspectLock, localConsumerClaimPath, transferBucket, writeTransfer, peerLabel, } from "@cotal-ai/core";
|
|
6
|
+
import { assertValidRole, agentFilePath, AgentGrantConflictError, connectorServers, spawnEnvAllow, deprovisionAgent, discardLaunchArtifacts, firstFreeName, isReachable, reclaimWithChild, loadCotalConfig, modelPolicyRefusal, mintCreds, newIdentity, DEV_OWNER, parseShareSelection, principalKey, assertLifecycleToken, mintLifecycleUid, MANAGED_HANDOFF_FILE_ENV, parseManagedLifecycleHandoff, spawnNameError, provisionAgent, provisionAgentDurables, registry, resolveAuthProvider, resolveReadAcl, runAgentBearer, CotalEndpoint, GOAL_ENTITY_RUNNING_DETAIL_KIND, seatCapFrom, acquireLock, inspectLock, localConsumerClaimPath, transferBucket, writeTransfer, peerLabel, } from "@cotal-ai/core";
|
|
7
7
|
import { CommandFailure, loadLaunchPersonaFile, personaFileReference, PersonaSourceError, inputDisabledByFlag, jsonFlag, plainFlag, presentationOf, recordOperationWarning, renderReport, terminalWidth, wrapWords, writeResult, agentActorTokenKey, agentCredsKey, agentSecretFilePaths, agentSentinelCredsKey, authDir, cachedPreferences, credsFlag, launchFlags, findMesh, getSpaceAuth, materializeSecretToFile, mergeLaunchOptions, parseLaunchOptions, preflightOrThrow, provenance, resolveAgentType, resolvePreference, resolveTargetOrThrow, serverFlag, spaceAccountPath, spaceFlag, spaceKey, userAuthStateDir, workspaceSecretStore, refreshRegistrationPolicy, resolveSeatControlTarget, connectUserControlOrExit, userViewAuth, oneLine, DEFAULT_CONNECTOR, hintedConnector, manifestExtensionNames, OFFICIAL_CONNECTORS, recordOperationSpace, resolveMeshTarget, } from "@cotal-ai/workspace";
|
|
8
8
|
import { c, stderrLine } from "../ui.js";
|
|
9
9
|
import { liveMeshNames } from "../lib/live-names.js";
|
|
@@ -13,7 +13,7 @@ import { completedFlagValue, completingFlagValue, hasCompletedFlagValue, positio
|
|
|
13
13
|
import { preflightOrExit, resolveTargetOrExit } from "../lib/connect.js";
|
|
14
14
|
import { runningStackManagerPid, stackManagerAbsent, stackManagerStarting } from "../lib/stack-journal.js";
|
|
15
15
|
import { askManager, describeUnanswered, failIfNotOk, liveManagerIds, managerRailGone, onInstance, refuseUnregisteredManager, refuseWithoutLiveManager, resolveControlTarget, START_TIMEOUT_MS, withControlConnection } from "../lib/control.js";
|
|
16
|
-
import { askManagerFolder, askSpawnPlace, managerPin, managerSelection, managersWithPersona, rerunOn } from "../lib/manager-choice.js";
|
|
16
|
+
import { askManagerFolder, askSpawnPlace, managerPin, managerSelection, managersWithPersona, rerunOn, rerunWithCwd } from "../lib/manager-choice.js";
|
|
17
17
|
import { canPrompt } from "./meshes-wizard.js";
|
|
18
18
|
import { listDeclaredChannels, listDeclaredRoles, listPersonaNames } from "../lib/personas.js";
|
|
19
19
|
import { personaCatalog } from "../lib/persona-files.js";
|
|
@@ -446,6 +446,16 @@ export function managedLaunchView(r) {
|
|
|
446
446
|
] }] }] : []),
|
|
447
447
|
] };
|
|
448
448
|
}
|
|
449
|
+
/** The auth mode of the mesh `flags` name, or undefined when they name no registered mesh, which
|
|
450
|
+
* the launch's own resolve then reports. */
|
|
451
|
+
function meshMode(flags) {
|
|
452
|
+
try {
|
|
453
|
+
return resolveMeshTarget(process.cwd(), { space: flags.space, server: flags.server }).mode;
|
|
454
|
+
}
|
|
455
|
+
catch {
|
|
456
|
+
return undefined;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
449
459
|
/** Shared managed launch. The manager resolves its persona and returns real readiness before
|
|
450
460
|
* any view opens. Detach changes terminal attachment, not the launch or caller authority. */
|
|
451
461
|
export async function launchManagedPersona(values, positionals, events, launchOptions, observer) {
|
|
@@ -461,31 +471,31 @@ export async function launchManagedPersona(values, positionals, events, launchOp
|
|
|
461
471
|
const seatIntent = Boolean(process.env.COTAL_NAME || process.env.COTAL_ID || process.env.COTAL_LIFECYCLE_UID || process.env.COTAL_ACCEPTED_TOKEN);
|
|
462
472
|
if (seatIntent && values.creds !== undefined)
|
|
463
473
|
throw new CommandFailure("refused", "USAGE_INVALID", "a managed seat's child launch uses that seat's own caller, not a --creds override");
|
|
464
|
-
// On a terminal, a pinned manager that is not known to run on this host is asked which of its
|
|
465
|
-
// folders the agent works in, unless -C names one. The question holds no manager credential: a
|
|
466
|
-
// typed folder is checked under a view of that manager acquired after it is answered, and the
|
|
467
|
-
// launch acquires its own below.
|
|
468
474
|
let cwd = values.cwd;
|
|
469
|
-
// On a
|
|
470
|
-
//
|
|
471
|
-
//
|
|
472
|
-
//
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
475
|
+
// On a terminal, a pinned manager that is not known to run on this host is asked which of its
|
|
476
|
+
// folders the agent works in, unless -C names one. One resolve, dropped again here, answers
|
|
477
|
+
// everything that question needs: that the mesh runs and the pin names a manager that is running,
|
|
478
|
+
// which manager an unpinned launch on a user-auth mesh goes to (the exchange picks your only live
|
|
479
|
+
// one, and the launch is pinned to it so the question asks about the manager that runs the
|
|
480
|
+
// agent), and the host that manager reports. So an unknown --on or a stopped mesh is refused
|
|
481
|
+
// before anything is asked, and the question still holds no manager credential: a typed folder is
|
|
482
|
+
// checked under a view of that manager acquired after it is answered, and the launch acquires its
|
|
483
|
+
// own below. A manager that has stopped by the time the launch is sent is refused there and goes
|
|
484
|
+
// to no other manager.
|
|
485
|
+
if (cwd === undefined && !seatIntent && canPrompt() && (on !== undefined || (values.creds === undefined && meshMode(flags) === "user"))) {
|
|
486
|
+
const probe = await resolveControlTarget(flags, "control-caller-privileged", on, { onRefusal: "throw" });
|
|
487
|
+
const pin = on ?? probe.auth.managerInstanceId;
|
|
488
|
+
if (pin !== undefined) {
|
|
489
|
+
if (!probe.auth.bearer)
|
|
490
|
+
await refuseUnregisteredManager(probe.space, probe.server, probe.auth, pin);
|
|
491
|
+
on = pin;
|
|
492
|
+
const selection = await managerSelection(values, pin, probe);
|
|
493
|
+
if (selection.manager.host !== hostname()) {
|
|
494
|
+
const folder = await askManagerFolder(selection, process.argv.slice(2), (path) => checkFolder(flags, pin, path));
|
|
495
|
+
if (folder === null)
|
|
496
|
+
process.exit(0);
|
|
497
|
+
cwd = folder;
|
|
498
|
+
}
|
|
489
499
|
}
|
|
490
500
|
}
|
|
491
501
|
let seat;
|
|
@@ -613,6 +623,16 @@ export async function launchManagedPersona(values, positionals, events, launchOp
|
|
|
613
623
|
// So does an unpinned one: no manager answered, and the launch was never published.
|
|
614
624
|
if (on === undefined && describeUnanswered(reply))
|
|
615
625
|
throw unansweredClassLaunch(t, { target, native: { code: reply.code, ...(reply.error ? { detail: oneLine(reply.error) } : {}) } });
|
|
626
|
+
// The owner's seat cap. Keyed on the marker, not the code: the numbers are what a script acts
|
|
627
|
+
// on, and the remedy is the operator's knob, neither of which a code alone can carry. It is a
|
|
628
|
+
// CONFLICT with the seats this owner already holds, the same shape as a pinned-name collision:
|
|
629
|
+
// nothing here is unreachable or unauthorized, and freeing one seat admits the launch.
|
|
630
|
+
const cap = seatCapFrom(reply);
|
|
631
|
+
if (cap !== undefined)
|
|
632
|
+
throw new CommandFailure("refused", "CONFLICT", reply.error ? oneLine(reply.error) : "the manager refused the launch: this owner is at its seat cap", {
|
|
633
|
+
target, native: { code: reply.code, outcome: reply.nativeOutcome, detail: { owner: cap.owner, seats: cap.seats, cap: cap.cap } },
|
|
634
|
+
remedy: `nothing was launched; stop one of this owner's seats with cotal stop --name <name>, or ask the operator who runs that manager to restart it with a higher --seat-cap (it admits ${cap.cap} per owner)`,
|
|
635
|
+
});
|
|
616
636
|
// A manager without the connector: it is added where that manager runs, not on this machine.
|
|
617
637
|
const absent = reply.nativeOutcome === "not-executed" && reply.error !== undefined ? hintedConnector(reply.error) : undefined;
|
|
618
638
|
if (absent !== undefined) {
|
|
@@ -733,8 +753,11 @@ async function reportAlreadyRunning(running, values, space, server) {
|
|
|
733
753
|
stderrLine("! ", `${running.agent} could not be attached: ${verdict.message}; attach to it with ${attach}`, c.yellow);
|
|
734
754
|
}
|
|
735
755
|
/** Whether the manager `on` pins can launch an agent in `path`, answered by its `resolve-cwd` over
|
|
736
|
-
* a view of that manager acquired for this check alone. A path it cannot use is its refusal
|
|
737
|
-
* check it does not answer refuses the launch
|
|
756
|
+
* a view of that manager acquired for this check alone. A path it cannot use is its refusal, which
|
|
757
|
+
* the question shows and asks again. A check it does not answer refuses the launch: the reason
|
|
758
|
+
* rides the structured cause rather than the sentence, because a responder's own words there are
|
|
759
|
+
* an internal subject and a spec reference, and the way past it is `-C <dir>`, which sends the
|
|
760
|
+
* folder with the launch and asks nothing. */
|
|
738
761
|
async function checkFolder(flags, on, path) {
|
|
739
762
|
const t = await resolveControlTarget(flags, "control-caller-privileged", on, { onRefusal: "throw" });
|
|
740
763
|
const reply = await askManager(t.space, t.server, "resolveCwd", { cwd: path }, t.auth, "owner", undefined, { instanceId: on });
|
|
@@ -743,9 +766,10 @@ async function checkFolder(flags, on, path) {
|
|
|
743
766
|
return { cwd };
|
|
744
767
|
if (!reply.ok && reply.code === "failed-precondition" && reply.error)
|
|
745
768
|
return { refusal: oneLine(reply.error) };
|
|
746
|
-
throw new CommandFailure("refused", "TARGET_UNAVAILABLE", `
|
|
769
|
+
throw new CommandFailure("refused", "TARGET_UNAVAILABLE", `the folder ${JSON.stringify(path)} could not be checked with manager instance ${on}, so nothing was launched`, {
|
|
747
770
|
target: { space: t.space, managerInstanceId: on },
|
|
748
|
-
|
|
771
|
+
...(reply.error ? { native: { ...(reply.code ? { code: reply.code } : {}), detail: { reason: oneLine(reply.error) } } } : {}),
|
|
772
|
+
remedy: `send the folder with the launch instead of answering the question: ${rerunWithCwd(process.argv.slice(2), path, on)}`,
|
|
749
773
|
});
|
|
750
774
|
}
|
|
751
775
|
/** Why no manager received an unpinned launch. A manager whose boot inventory found no agent
|