@cotal-ai/cli 0.101.2 → 0.101.4
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/help.d.ts +5 -3
- package/dist/commands/help.d.ts.map +1 -1
- package/dist/commands/help.js +6 -5
- package/dist/commands/help.js.map +1 -1
- package/dist/commands/spawn.d.ts.map +1 -1
- package/dist/commands/spawn.js +119 -8
- package/dist/commands/spawn.js.map +1 -1
- package/dist/help.d.ts +6 -4
- package/dist/help.d.ts.map +1 -1
- package/dist/help.js +26 -23
- package/dist/help.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/held-name.d.ts +49 -0
- package/dist/lib/held-name.d.ts.map +1 -0
- package/dist/lib/held-name.js +125 -0
- package/dist/lib/held-name.js.map +1 -0
- package/dist/lib/manager-choice.d.ts +23 -0
- package/dist/lib/manager-choice.d.ts.map +1 -1
- package/dist/lib/manager-choice.js +32 -0
- package/dist/lib/manager-choice.js.map +1 -1
- package/dist/lib/manager-proc.d.ts +2 -2
- package/package.json +4 -4
package/dist/commands/help.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { type ParsedArgs } from "@cotal-ai/core";
|
|
2
|
+
/** `--all`, the older way to ask for every command, which help now always lists. It is accepted and
|
|
3
|
+
* changes nothing, and neither help nor completion offers it. */
|
|
2
4
|
export declare const helpFlags: readonly [{
|
|
3
5
|
readonly name: "all";
|
|
4
6
|
readonly type: "boolean";
|
|
5
|
-
readonly description: "
|
|
7
|
+
readonly description: "accepted for scripts written before help listed every command; it changes nothing";
|
|
6
8
|
}];
|
|
7
|
-
/** `cotal help [command…]
|
|
8
|
-
*
|
|
9
|
+
/** `cotal help [command…]`: every command, or the help of the command the words name. The words
|
|
10
|
+
* are literal nesting: a command (or its alias), then one of its subcommands. */
|
|
9
11
|
export declare function help(args: ParsedArgs): Promise<void>;
|
|
10
12
|
export declare const versionFlags: readonly [{
|
|
11
13
|
readonly name: "json";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAO/E,eAAO,MAAM,SAAS;;;;
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAO/E;kEACkE;AAClE,eAAO,MAAM,SAAS;;;;EAAgJ,CAAC;AAEvK;kFACkF;AAClF,wBAAsB,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAO1D;AAED,eAAO,MAAM,YAAY;;;;;EAAsB,CAAC;AAEhD;;mEAEmE;AACnE,wBAAsB,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CA8B7D"}
|
package/dist/commands/help.js
CHANGED
|
@@ -4,15 +4,16 @@ import { commandSurface } from "../ext-loader.js";
|
|
|
4
4
|
import { printCommandList, printHelpPath } from "../help.js";
|
|
5
5
|
import { unknownCommandMessage } from "../lib/nearest-word.js";
|
|
6
6
|
import { cliVersion, extensionVersions, readExtensionVersions } from "../lib/version.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/** `--all`, the older way to ask for every command, which help now always lists. It is accepted and
|
|
8
|
+
* changes nothing, and neither help nor completion offers it. */
|
|
9
|
+
export const helpFlags = [{ name: "all", type: "boolean", description: "accepted for scripts written before help listed every command; it changes nothing" }];
|
|
10
|
+
/** `cotal help [command…]`: every command, or the help of the command the words name. The words
|
|
11
|
+
* are literal nesting: a command (or its alias), then one of its subcommands. */
|
|
10
12
|
export async function help(args) {
|
|
11
|
-
const values = args.values;
|
|
12
13
|
const [word, ...path] = args.positionals;
|
|
13
14
|
const commands = commandSurface();
|
|
14
15
|
if (word === undefined)
|
|
15
|
-
return printCommandList(commands
|
|
16
|
+
return printCommandList(commands);
|
|
16
17
|
const cmd = findCommand(commands, word);
|
|
17
18
|
if (!cmd || cmd.name.startsWith("__"))
|
|
18
19
|
throw new Error(unknownCommandMessage(commands, word));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAoC,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAEzF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAoC,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAEzF;kEACk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C,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE;YAC5G,GAAG,CAAC,UAAU,KAAK,SAAS;gBAC1B,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC;oBACE,YAAY,EAAE,SAAS;oBACvB,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,8CAA8C,UAAU,EAAE,EAAE,CAAC;oBAChI,OAAO,EAAE,EAAE,OAAO,EAAE,8CAA8C,EAAE,MAAM,EAAE,oDAAoD,EAAE;iBACnI,CAAC;SACP,EACD,GAAG,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CACzB,CAAC;QACF,OAAO;IACT,CAAC;IACD,MAAM,IAAI,GAAG,iBAAiB,EAAE,CAAC;IACjC,MAAM,KAAK,GAAG,CAAC,YAAY,UAAU,EAAE,EAAE,CAAC,CAAC;IAC3C,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;QACzD,KAAK,MAAM,CAAC,IAAI,IAAI;YAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -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"],"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3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AA+XD;;yFAEyF;AACzF,wBAAsB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAIjH"}
|
package/dist/commands/spawn.js
CHANGED
|
@@ -3,8 +3,8 @@ 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, acquireLock, inspectLock, localConsumerClaimPath, transferBucket, writeTransfer, peerLabel, } from "@cotal-ai/core";
|
|
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, } from "@cotal-ai/workspace";
|
|
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";
|
|
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";
|
|
10
10
|
import { displayCmd } from "../lib/self-exec.js";
|
|
@@ -21,6 +21,8 @@ import { callerHarness, missingPersona, spawnPersona, spawnUsesManager } from ".
|
|
|
21
21
|
import { spawnLaunchPreview } from "./spawn-preview.js";
|
|
22
22
|
import { protectedCredentialReference, readLocalRecordSource } from "../lib/protected-records.js";
|
|
23
23
|
import { attachSeat } from "./agents.js";
|
|
24
|
+
import { AgentAlreadyRunning, heldAnswer, settleHeldName } from "../lib/held-name.js";
|
|
25
|
+
import { shellWord } from "../lib/endpoint-errors.js";
|
|
24
26
|
import { extensionNames, materializeExtension } from "../ext-loader.js";
|
|
25
27
|
import { claimManagedHandoff, holdsManagedHandoff, managedHandoffRefusal } from "../managed-handoff.js";
|
|
26
28
|
import { checkDialPolicy, checkEnforcement, checkServer, checkUserBundle, persistRemoteUserEntry, probeEnforcement, tlsIntent, userExchangeIssuer, verifyUserExchange, } from "./meshes-add.js";
|
|
@@ -264,7 +266,7 @@ async function provisionFreshForeground(requested, autoName, provision) {
|
|
|
264
266
|
return { name, provisioned: await provision(name) };
|
|
265
267
|
}
|
|
266
268
|
catch (e) {
|
|
267
|
-
if (!autoName || !(e instanceof ForegroundActorCollision || e instanceof AgentGrantConflictError))
|
|
269
|
+
if (!autoName || !(e instanceof ForegroundActorCollision || e instanceof AgentGrantConflictError || e instanceof AgentAlreadyRunning))
|
|
268
270
|
throw e;
|
|
269
271
|
occupied.add(name);
|
|
270
272
|
}
|
|
@@ -451,7 +453,7 @@ export async function launchManagedPersona(values, positionals, events, launchOp
|
|
|
451
453
|
// `COTAL_DEFAULT_PERSONA` > `default`). Identity is separate:
|
|
452
454
|
// when `--name` is given it OVERRIDES the file's `name:` (foreground's `requested`), threaded
|
|
453
455
|
// as the op's `identity` so it is never silently dropped in detached mode.
|
|
454
|
-
|
|
456
|
+
let on = await managerPin(values, "cotal spawn <persona>");
|
|
455
457
|
// From a managed seat's own shell the launch is the SEAT's, as its `cotal_spawn` tool is: the
|
|
456
458
|
// manager records the seat as the spawner, so the seat can stop the child it asked for (#718).
|
|
457
459
|
// `--on` keeps the pin on that path too.
|
|
@@ -464,6 +466,19 @@ export async function launchManagedPersona(values, positionals, events, launchOp
|
|
|
464
466
|
// typed folder is checked under a view of that manager acquired after it is answered, and the
|
|
465
467
|
// launch acquires its own below.
|
|
466
468
|
let cwd = values.cwd;
|
|
469
|
+
// On a user-auth mesh, a launch with no --on goes to the manager the exchange picks, your only
|
|
470
|
+
// live one. On a terminal that pick is read once, its view dropped, and the launch is pinned to it,
|
|
471
|
+
// so the folder question asks about the manager that runs the agent. If that manager is gone by
|
|
472
|
+
// the time the launch is sent, the launch is refused and goes to no other manager.
|
|
473
|
+
if (cwd === undefined && on === undefined && !seatIntent && values.creds === undefined && canPrompt()) {
|
|
474
|
+
let mode;
|
|
475
|
+
try {
|
|
476
|
+
mode = resolveMeshTarget(process.cwd(), { space: flags.space, server: flags.server }).mode;
|
|
477
|
+
}
|
|
478
|
+
catch { /* not a registered mesh */ }
|
|
479
|
+
if (mode === "user")
|
|
480
|
+
on = (await resolveControlTarget(flags, "control-caller-privileged", undefined, { onRefusal: "throw" })).auth.managerInstanceId;
|
|
481
|
+
}
|
|
467
482
|
if (cwd === undefined && on !== undefined && !seatIntent && canPrompt()) {
|
|
468
483
|
const selection = await managerSelection(values, on);
|
|
469
484
|
if (selection.manager.host !== hostname()) {
|
|
@@ -523,7 +538,7 @@ export async function launchManagedPersona(values, positionals, events, launchOp
|
|
|
523
538
|
(toStdout ? console.log : console.error)(renderReport({ sections: [{ title: "Managed launch", blocks: [{ kind: "fields", rows: [["Space", t.space], ["Manager selector", on ?? t.auth.managerInstanceId ?? "native class selection"], ["Persona", ref], ["File source", managerConfigRef ? `${managerConfigRef} · manager execution host` : "selected manager's persona catalog"], ["File transfer", "none"]] }, { kind: "lines", lines: [{ text: "The accepting manager validates its own visible file before allocation. No local file is uploaded, and a pin never selects a replacement manager.", tone: "hint" }] }] }] }, presentationOf(values) === "plain" ? "plain" : "rich", terminalWidth(toStdout ? process.stdout : process.stderr)));
|
|
524
539
|
for (const line of wrapWords("waiting for the manager: it answers when it refuses the launch, or when the agent joins or exits (at most about 30s) …", terminalWidth(process.stderr)))
|
|
525
540
|
console.error(c.dim(line));
|
|
526
|
-
const
|
|
541
|
+
const start = () => askManager(t.space, t.server, "start", {
|
|
527
542
|
name: ref,
|
|
528
543
|
identity: values.name,
|
|
529
544
|
role: values.role,
|
|
@@ -555,9 +570,38 @@ export async function launchManagedPersona(values, positionals, events, launchOp
|
|
|
555
570
|
// readiness backstop) — the start request must outlive that window, not the 5s op default.
|
|
556
571
|
// `--on <instance>` pins the spawn to that exact manager instance (P2 item 3 multi-manager).
|
|
557
572
|
}, t.auth, "owner", START_TIMEOUT_MS, { instanceId: on });
|
|
573
|
+
// A refusal before execution launched nothing, so the launch is sent again once a name held by a
|
|
574
|
+
// lifecycle that is not running is released. A name that runs is not launched a second time.
|
|
575
|
+
let reply;
|
|
576
|
+
try {
|
|
577
|
+
let mesh;
|
|
578
|
+
try {
|
|
579
|
+
mesh = resolveMeshTarget(process.cwd(), { space: flags.space, server: flags.server });
|
|
580
|
+
}
|
|
581
|
+
catch { /* no registered mesh: nothing to release */ }
|
|
582
|
+
reply = await settleHeldName(flags, start, (o) => "value" in o && !o.value.ok && o.value.nativeOutcome === "not-executed"
|
|
583
|
+
? heldAnswer({ code: o.value.code, details: o.value.details, message: o.value.error ?? "" }, values.name) : undefined, meshRelease(mesh));
|
|
584
|
+
}
|
|
585
|
+
catch (e) {
|
|
586
|
+
if (!(e instanceof AgentAlreadyRunning))
|
|
587
|
+
throw e;
|
|
588
|
+
if (observer)
|
|
589
|
+
throw new CommandFailure("refused", "CONFLICT", `${e.message}; nothing new was launched`, { target: { space: t.space, agent: e.agent, managerInstanceId: e.manager?.instanceId ?? null } });
|
|
590
|
+
return reportAlreadyRunning(e, values, t.space, t.server);
|
|
591
|
+
}
|
|
558
592
|
const target = { space: t.space, managerInstanceId: reply.managerInstanceId ?? on ?? null, managerEpoch: reply.managerEpoch ?? null, ...(reply.intent ? { requestId: reply.intent.requestId, requestedGoalId: reply.intent.requestedGoalId ?? null } : {}), ...(reply.request ? { acceptedGoalId: reply.request.goalId ?? null } : {}) };
|
|
593
|
+
// A launch whose process the manager reports running is starting: one that waits for the operator at
|
|
594
|
+
// a screen its harness names was ready once it ran, and one that did not join in time may still be
|
|
595
|
+
// coming up or sitting at a prompt. Either way the operator is sent to its terminal.
|
|
596
|
+
const started = reply.ok ? reply.data : undefined;
|
|
597
|
+
const running = !reply.ok && reply.code === "uncertain" && reply.details?.some((d) => d.kind === GOAL_ENTITY_RUNNING_DETAIL_KIND) === true;
|
|
598
|
+
const startedName = typeof started?.name === "string" ? started.name : reply.request?.allocation?.name;
|
|
599
|
+
if (!observer && reply.managerInstanceId && startedName && (typeof started?.waitingFor === "string" || running)) {
|
|
600
|
+
const expected = typeof started?.id === "string" && typeof started.lifecycleUid === "string" ? { id: started.id, lifecycleUid: started.lifecycleUid } : undefined;
|
|
601
|
+
return reportStarting({ name: startedName, managerInstanceId: reply.managerInstanceId, ...(typeof started?.waitingFor === "string" ? { waitingFor: started.waitingFor } : {}), ...(expected ? { expected } : {}) }, values, t.space, t.server, target);
|
|
602
|
+
}
|
|
559
603
|
if (!reply.ok) {
|
|
560
|
-
const refusal = { "permission-denied": "PERMISSION_DENIED", "unauthenticated": "AUTH_REQUIRED", "not-found": "TARGET_NOT_FOUND", "unavailable": "TARGET_UNAVAILABLE", "bad-request": "SCHEMA_INVALID", "failed-precondition": "LIFECYCLE_BLOCKED", "already-exists": "CONFLICT", "unimplemented": "UNSUPPORTED" };
|
|
604
|
+
const refusal = { "permission-denied": "PERMISSION_DENIED", "unauthenticated": "AUTH_REQUIRED", "not-found": "TARGET_NOT_FOUND", "unavailable": "TARGET_UNAVAILABLE", "bad-request": "SCHEMA_INVALID", "failed-precondition": "LIFECYCLE_BLOCKED", "already-exists": "CONFLICT", "conflict": "CONFLICT", "unimplemented": "UNSUPPORTED" };
|
|
561
605
|
const code = reply.code === undefined ? undefined : refusal[reply.code];
|
|
562
606
|
const native = { code: reply.code, outcome: reply.nativeOutcome, ...(reply.request || reply.intent ? { detail: { request: reply.request ?? null, intent: reply.intent ?? null, observation: reply.observationCause ?? null } } : {}) };
|
|
563
607
|
// The broker attested that no manager received an unpinned launch: none takes the class queue.
|
|
@@ -623,6 +667,67 @@ export async function launchManagedPersona(values, positionals, events, launchOp
|
|
|
623
667
|
throw new CommandFailure("partial", "OPERATION_PARTIAL", "the agent joined, but its exact native terminal was unavailable before setup could open the view; no replacement was launched", { target, changed: [result], remedy: "inspect the original lifecycle and manager before another startup" });
|
|
624
668
|
console.error(renderReport({ sections: [{ title: verdict.kind === "gone" ? "Attach target unavailable" : verdict.reason === "detached" ? "Detached" : "Attach session ended", blocks: [{ kind: "fields", rows: [["Agent", d.name], ["Identity", d.id], ["Manager", reply.managerInstanceId]] }, { kind: "lines", lines: [{ text: "Leaving the view sent no stop request. The original lifecycle was not replaced.", tone: "hint" }] }] }] }, "rich", terminalWidth(process.stderr)));
|
|
625
669
|
}
|
|
670
|
+
/** The mesh's release of one agent lifecycle, when `mesh` is a remote user-auth mesh that advertises
|
|
671
|
+
* an agent-provisioning endpoint and the auth provider can call it there. */
|
|
672
|
+
function meshRelease(mesh) {
|
|
673
|
+
const ua = mesh?.mode === "user" && mesh.userAuth?.remote ? mesh.userAuth : undefined;
|
|
674
|
+
const url = ua?.endpoints?.agentProvisioningUrl;
|
|
675
|
+
if (!ua || !url)
|
|
676
|
+
return undefined;
|
|
677
|
+
const provider = resolveAuthProvider();
|
|
678
|
+
if (!provider.releaseAgentLifecycle)
|
|
679
|
+
return undefined;
|
|
680
|
+
return (lifecycleUid, agent) => provider.releaseAgentLifecycle({ url, idpUrl: ua.idp.url, lifecycleUid, actor: agent });
|
|
681
|
+
}
|
|
682
|
+
/** A managed launch whose process runs but has not joined the mesh: say where it runs and, when its
|
|
683
|
+
* harness waits for the operator, at which screen. A terminal attaches to an operator screen at once,
|
|
684
|
+
* even with -d, and to a starting agent only when the spawn was not detached; otherwise the attach
|
|
685
|
+
* command is printed. */
|
|
686
|
+
async function reportStarting(start, values, space, server, target) {
|
|
687
|
+
const selection = await managerSelection(values, start.managerInstanceId).catch(() => undefined);
|
|
688
|
+
const selector = selection?.selector ?? start.managerInstanceId, host = selection?.manager.host ?? null;
|
|
689
|
+
const attach = `${displayCmd()} attach ${shellWord(start.name)} --on ${shellWord(selector)}`;
|
|
690
|
+
const presentation = presentationOf(values);
|
|
691
|
+
const now = presentation !== "json" && canPrompt() && (start.waitingFor !== undefined || !values.detach);
|
|
692
|
+
const place = `on ${selector}${host && host !== selector ? ` (${host})` : ""}`;
|
|
693
|
+
writeResult(presentation, {
|
|
694
|
+
command: "spawn",
|
|
695
|
+
target,
|
|
696
|
+
result: { kind: "managed-launch-running", name: start.name, managerInstanceId: start.managerInstanceId, host, waitingFor: start.waitingFor ?? null, attach },
|
|
697
|
+
}, (r) => ({ sections: [{ title: r.waitingFor ? "Waiting for you" : "Agent starting", blocks: [{ kind: "lines", lines: [
|
|
698
|
+
r.waitingFor ? `${r.name} is running ${place} and waiting for you at ${r.waitingFor}.` : `${r.name} is running ${place} and has not joined the mesh yet; it may still be starting or waiting at a prompt.`,
|
|
699
|
+
{ text: now ? "Attaching to it now." : `Attach to it: ${r.attach}`, tone: "hint" },
|
|
700
|
+
] }] }] }));
|
|
701
|
+
if (!now)
|
|
702
|
+
return;
|
|
703
|
+
const verdict = await attachSeat({ space, server, creds: values.creds, name: start.name, ...(start.expected ? { expectedTarget: start.expected } : {}) }, { on: start.managerInstanceId, reconnect: true, onRefusal: "throw" });
|
|
704
|
+
if (verdict.kind === "failed")
|
|
705
|
+
stderrLine("! ", `${start.name} could not be attached: ${verdict.message}; attach to it with ${attach}`, c.yellow);
|
|
706
|
+
}
|
|
707
|
+
/** The agent a spawn asked for already runs, so nothing new is launched: say where it runs, then
|
|
708
|
+
* attach to it in this terminal unless the spawn was detached or cannot attach, or print the
|
|
709
|
+
* command that does. */
|
|
710
|
+
async function reportAlreadyRunning(running, values, space, server) {
|
|
711
|
+
const where = running.manager;
|
|
712
|
+
const attach = where ? `${displayCmd()} attach ${shellWord(running.agent)} --on ${shellWord(where.selector)}` : null;
|
|
713
|
+
const presentation = presentationOf(values);
|
|
714
|
+
const now = where !== null && !values.detach && presentation !== "json" && canPrompt();
|
|
715
|
+
const place = where ? `on ${where.selector}${where.host && where.host !== where.selector ? ` (${where.host})` : ""}` : "on the mesh, not on a manager of yours";
|
|
716
|
+
writeResult(presentation, {
|
|
717
|
+
command: "spawn",
|
|
718
|
+
target: { space, agent: running.agent, managerInstanceId: where?.instanceId ?? null },
|
|
719
|
+
result: { kind: "already-running", name: running.agent, managerInstanceId: where?.instanceId ?? null, host: where?.host ?? null, attach },
|
|
720
|
+
noOp: true,
|
|
721
|
+
}, (r) => ({ sections: [{ title: "Already running", blocks: [{ kind: "lines", lines: [
|
|
722
|
+
`${r.name} is already running ${place}; nothing new was launched.`,
|
|
723
|
+
{ text: now ? "Attaching to it now." : r.attach ? `Attach to it: ${r.attach}` : "To start a second agent, pick another name with --name <other>.", tone: "hint" },
|
|
724
|
+
] }] }] }));
|
|
725
|
+
if (!now)
|
|
726
|
+
return;
|
|
727
|
+
const verdict = await attachSeat({ space, server, creds: values.creds, name: running.agent }, { on: where.instanceId, reconnect: true, onRefusal: "throw" });
|
|
728
|
+
if (verdict.kind === "failed")
|
|
729
|
+
stderrLine("! ", `${running.agent} could not be attached: ${verdict.message}; attach to it with ${attach}`, c.yellow);
|
|
730
|
+
}
|
|
626
731
|
/** Whether the manager `on` pins can launch an agent in `path`, answered by its `resolve-cwd` over
|
|
627
732
|
* a view of that manager acquired for this check alone. A path it cannot use is its refusal; a
|
|
628
733
|
* check it does not answer refuses the launch. */
|
|
@@ -1292,7 +1397,11 @@ export async function spawn(args) {
|
|
|
1292
1397
|
lifecycleUid = remote.material.lifecycleUid;
|
|
1293
1398
|
}
|
|
1294
1399
|
else if (remoteProvisioningUrl) {
|
|
1295
|
-
const selected = await provisionFreshForeground(requested, values.name === undefined, (candidate) => provisionRemoteUserForeground(target, candidate, { provisioningUrl: remoteProvisioningUrl }))
|
|
1400
|
+
const selected = await provisionFreshForeground(requested, values.name === undefined, (candidate) => provisionRemoteUserForeground(target, candidate, { provisioningUrl: remoteProvisioningUrl }))
|
|
1401
|
+
.catch((e) => { if (e instanceof AgentAlreadyRunning)
|
|
1402
|
+
return e; throw e; });
|
|
1403
|
+
if (selected instanceof AgentAlreadyRunning)
|
|
1404
|
+
return reportAlreadyRunning(selected, values, target.space, target.server);
|
|
1296
1405
|
name = selected.name;
|
|
1297
1406
|
const remote = selected.provisioned;
|
|
1298
1407
|
userAuth = remote.userAuth;
|
|
@@ -1641,8 +1750,10 @@ async function provisionRemoteUserForeground(target, name, source, refusals) {
|
|
|
1641
1750
|
// no-login gate names the `cotal login --idp …` line, a refusal carries the mesh's own reason.
|
|
1642
1751
|
if (!provider.postAgentProvisioning)
|
|
1643
1752
|
return fail(`the registered auth provider "${provider.name}" cannot provision agents on a remote mesh - run the agent where the mesh runs`);
|
|
1753
|
+
// A name held by a lifecycle that is not running is released and asked for again.
|
|
1644
1754
|
try {
|
|
1645
|
-
body = await provider.postAgentProvisioning({ url: source.provisioningUrl, idpUrl, actor: name })
|
|
1755
|
+
body = await settleHeldName({ space }, () => provider.postAgentProvisioning({ url: source.provisioningUrl, idpUrl, actor: name }), (o) => "error" in o
|
|
1756
|
+
? heldAnswer({ code: o.error?.code, details: o.error?.details, message: rejectionText(o.error) }, name) : undefined, meshRelease(target));
|
|
1646
1757
|
}
|
|
1647
1758
|
catch (e) {
|
|
1648
1759
|
materialClaim.release();
|