@mutagent/cli 0.2.116 → 0.2.118
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/bin/cli.js +23 -56
- package/dist/index.js +12 -5
- package/package.json +2 -2
package/dist/bin/cli.js
CHANGED
|
@@ -305,14 +305,16 @@ function loadConfig() {
|
|
|
305
305
|
const fileSelection = fileDescribesKey ? credentials?.defaultWorkspace : undefined;
|
|
306
306
|
const selected = fileSelection ?? rcConfig?.defaultWorkspace;
|
|
307
307
|
const defaultWorkspace = envWorkspace !== "" ? envWorkspace : selected;
|
|
308
|
-
const
|
|
308
|
+
const inSandbox = inCloudSandbox();
|
|
309
|
+
const storedKey = inSandbox ? undefined : credentials?.apiKey ?? rcConfig?.apiKey;
|
|
310
|
+
const storedEndpoint = inSandbox ? undefined : credentials?.endpoint ?? rcConfig?.endpoint;
|
|
309
311
|
const merged = {
|
|
310
312
|
providers: {},
|
|
311
313
|
environment: "production",
|
|
312
314
|
...rcConfig,
|
|
313
315
|
...credentials,
|
|
314
316
|
apiKey: envKey ?? storedKey,
|
|
315
|
-
endpoint: process.env.MUTAGENT_ENDPOINT ??
|
|
317
|
+
endpoint: process.env.MUTAGENT_ENDPOINT ?? storedEndpoint,
|
|
316
318
|
defaultWorkspace,
|
|
317
319
|
workspaceOrigin: envWorkspace !== "" ? "override" : selected ? "selection" : undefined,
|
|
318
320
|
workspaceName: envWorkspace === "" && fileSelection !== undefined && fileSelection === selected ? credentials?.workspaceName : undefined,
|
|
@@ -372,6 +374,8 @@ function clearCredentials() {
|
|
|
372
374
|
function hasCredentials() {
|
|
373
375
|
if (process.env.MUTAGENT_API_KEY)
|
|
374
376
|
return true;
|
|
377
|
+
if (inCloudSandbox())
|
|
378
|
+
return true;
|
|
375
379
|
if (!existsSync(CREDENTIALS_FILE))
|
|
376
380
|
return false;
|
|
377
381
|
const credentials = parseJsonSafe(readFileSync(CREDENTIALS_FILE, "utf-8"), credentialsSchema);
|
|
@@ -440,6 +444,9 @@ var init_config = __esm(() => {
|
|
|
440
444
|
function present(value) {
|
|
441
445
|
return value !== undefined && value.trim() !== "";
|
|
442
446
|
}
|
|
447
|
+
function inSandboxSession(env = process.env) {
|
|
448
|
+
return present(env[SANDBOX_TOKEN_VAR2]);
|
|
449
|
+
}
|
|
443
450
|
function signedInWithSessionToken(env = process.env) {
|
|
444
451
|
return present(env[SANDBOX_TOKEN_VAR2]) && !present(getApiKey());
|
|
445
452
|
}
|
|
@@ -713,7 +720,7 @@ function errorBody(error) {
|
|
|
713
720
|
if (error instanceof WorkspaceContextError) {
|
|
714
721
|
body.remediation = { setWorkspace: "mutagent workspaces use <name>", listWorkspaces: "mutagent workspaces list" };
|
|
715
722
|
}
|
|
716
|
-
if (error instanceof ApiError && error.statusCode === 403) {
|
|
723
|
+
if (error instanceof ApiError && error.statusCode === 403 && !inSandboxSession()) {
|
|
717
724
|
body.remediation = {
|
|
718
725
|
interactive: SIGN_IN_COMMAND,
|
|
719
726
|
nonInteractive: "export MUTAGENT_API_KEY=<your-key>",
|
|
@@ -735,7 +742,7 @@ function printHuman(error) {
|
|
|
735
742
|
} else if (error instanceof WorkspaceContextError) {
|
|
736
743
|
console.error("");
|
|
737
744
|
console.error(WORKSPACE_REMEDIATION_MESSAGE);
|
|
738
|
-
} else if (error instanceof ApiError && error.statusCode === 403) {
|
|
745
|
+
} else if (error instanceof ApiError && error.statusCode === 403 && !inSandboxSession()) {
|
|
739
746
|
console.error("");
|
|
740
747
|
console.error("Access denied. To fix:");
|
|
741
748
|
console.error(` ${SIGN_IN_COMMAND} # Re-authenticate`);
|
|
@@ -27210,31 +27217,6 @@ async function runNativeSession(options) {
|
|
|
27210
27217
|
}
|
|
27211
27218
|
}
|
|
27212
27219
|
|
|
27213
|
-
// src/commands/helix/sub-session.ts
|
|
27214
|
-
init_errors();
|
|
27215
|
-
init_output();
|
|
27216
|
-
function isSandboxSubSession(plan) {
|
|
27217
|
-
return plan.factory !== undefined && plan.sandbox === undefined && resolveCredential().kind === "sandbox-token";
|
|
27218
|
-
}
|
|
27219
|
-
function followCommands(target) {
|
|
27220
|
-
return ["mutagent traces sessions --since 1h", `mutagent factory stage list ${target.subject} --stage ${target.stage}`];
|
|
27221
|
-
}
|
|
27222
|
-
function subSessionFollowRefusal(mode, target) {
|
|
27223
|
-
if (mode === "text")
|
|
27224
|
-
return;
|
|
27225
|
-
return new MutagentError("SUBSESSION_DETACHED", `A sub-session runs in its own sandbox, which this sandbox's token cannot attach to, so --${mode === "rpc" ? "rpc" : "mode json"} cannot follow it.`, `Launch it with -p "<task>" (detached), then follow it with: ${followCommands(target).join(" or ")}`);
|
|
27226
|
-
}
|
|
27227
|
-
function printSubSessionReceipt(reference, target, isJson) {
|
|
27228
|
-
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
27229
|
-
const next = followCommands(target);
|
|
27230
|
-
if (isJson) {
|
|
27231
|
-
output.output({ success: true, session: reference, subject: target.subject, stage: target.stage, detached: true, next });
|
|
27232
|
-
return;
|
|
27233
|
-
}
|
|
27234
|
-
output.success(`Launched sub-session ${reference} for ${target.subject} (${target.stage}); it runs in its own sandbox.`);
|
|
27235
|
-
output.info(`Follow it with: ${next.join(" or ")}`);
|
|
27236
|
-
}
|
|
27237
|
-
|
|
27238
27220
|
// src/commands/helix/run-cloud.ts
|
|
27239
27221
|
function repositoryFields(flags) {
|
|
27240
27222
|
return {
|
|
@@ -27242,7 +27224,7 @@ function repositoryFields(flags) {
|
|
|
27242
27224
|
...flags.branch === undefined ? {} : { branch: flags.branch }
|
|
27243
27225
|
};
|
|
27244
27226
|
}
|
|
27245
|
-
async function runCloudLaunch(plan, mode
|
|
27227
|
+
async function runCloudLaunch(plan, mode) {
|
|
27246
27228
|
checkSandboxId(plan.sandbox);
|
|
27247
27229
|
checkArgsForRoute(plan.args);
|
|
27248
27230
|
const sandbox = plan.sandbox?.trim();
|
|
@@ -27270,33 +27252,21 @@ async function runCloudLaunch(plan, mode, options = {}) {
|
|
|
27270
27252
|
...plan.environment === undefined ? {} : { environment: plan.environment },
|
|
27271
27253
|
...plan.cwd === undefined ? {} : { cwd: plan.cwd }
|
|
27272
27254
|
};
|
|
27273
|
-
const launch = () => launchHelixSession({
|
|
27274
|
-
...body,
|
|
27275
|
-
...plan.preset === undefined ? {} : { preset: plan.preset },
|
|
27276
|
-
...plan.sandboxProvider === undefined ? {} : { sandboxProvider: plan.sandboxProvider },
|
|
27277
|
-
...repositoryFields(plan),
|
|
27278
|
-
...plan.factory === undefined ? {} : { subject: plan.factory.subject, stage: plan.factory.stage }
|
|
27279
|
-
}).catch((error) => {
|
|
27280
|
-
throw entryRefusal(launchRepositoryRefusal(error));
|
|
27281
|
-
});
|
|
27282
|
-
if (plan.factory !== undefined && isSandboxSubSession(plan)) {
|
|
27283
|
-
const refusal = subSessionFollowRefusal(mode, plan.factory);
|
|
27284
|
-
if (refusal !== undefined)
|
|
27285
|
-
throw refusal;
|
|
27286
|
-
const session = await launch();
|
|
27287
|
-
if (!session.reference) {
|
|
27288
|
-
throw new MutagentError("INVALID_RESPONSE", "The server did not return a session reference.", "Run: mutagent traces sessions --since 1h");
|
|
27289
|
-
}
|
|
27290
|
-
printSubSessionReceipt(session.reference, plan.factory, options.json === true);
|
|
27291
|
-
return;
|
|
27292
|
-
}
|
|
27293
27255
|
let interruptRequested = false;
|
|
27294
27256
|
const queueInterrupt = () => {
|
|
27295
27257
|
interruptRequested = true;
|
|
27296
27258
|
};
|
|
27297
27259
|
process.on("SIGINT", queueInterrupt);
|
|
27298
27260
|
try {
|
|
27299
|
-
const session = sandbox ? await startSession(sandbox, body) : await
|
|
27261
|
+
const session = sandbox ? await startSession(sandbox, body) : await launchHelixSession({
|
|
27262
|
+
...body,
|
|
27263
|
+
...plan.preset === undefined ? {} : { preset: plan.preset },
|
|
27264
|
+
...plan.sandboxProvider === undefined ? {} : { sandboxProvider: plan.sandboxProvider },
|
|
27265
|
+
...repositoryFields(plan),
|
|
27266
|
+
...plan.factory === undefined ? {} : { subject: plan.factory.subject, stage: plan.factory.stage }
|
|
27267
|
+
}).catch((error) => {
|
|
27268
|
+
throw entryRefusal(launchRepositoryRefusal(error));
|
|
27269
|
+
});
|
|
27300
27270
|
if (!session.reference) {
|
|
27301
27271
|
throw new MutagentError("INVALID_RESPONSE", "The server did not return a session reference.", "Run: mutagent helix doctor");
|
|
27302
27272
|
}
|
|
@@ -27867,9 +27837,6 @@ function registerAgentCommand(parent, registration, deps = defaultPlanDeps()) {
|
|
|
27867
27837
|
" Without --subject the entry is MUTAGENT_SUBJECT_ID, else the session's, else this checkout's .mutagent/factory.json.",
|
|
27868
27838
|
" Errors: FLAG_CONFLICT (--subject without --stage, or either with @id); MISSING_ARGUMENTS (no entry inferred: pass --subject);",
|
|
27869
27839
|
" ENTRY_NOT_FOUND (run: mutagent factory list); VALIDATION_ERROR (--stage is one of the six stages).",
|
|
27870
|
-
" Inside a cloud sandbox (its own token), this launches a sub-session for the bound entry, detached:",
|
|
27871
|
-
" it runs in its own sandbox; the receipt names its hs1_ id and how to follow it",
|
|
27872
|
-
" (mutagent traces sessions). --mode json and --rpc are refused there: SUBSESSION_DETACHED.",
|
|
27873
27840
|
"",
|
|
27874
27841
|
"Definition and task:",
|
|
27875
27842
|
" The first argument (or --prompt, --file, --name) defines the agent; -p gives the task.",
|
|
@@ -27954,7 +27921,7 @@ function registerAgentCommand(parent, registration, deps = defaultPlanDeps()) {
|
|
|
27954
27921
|
...plan.prime ? ["--prime"] : [],
|
|
27955
27922
|
...plan.nativeArgs
|
|
27956
27923
|
]
|
|
27957
|
-
}, mode
|
|
27924
|
+
}, mode);
|
|
27958
27925
|
} catch (error) {
|
|
27959
27926
|
handleLaunchFailure(error, {
|
|
27960
27927
|
isJson: isJson && !hasNativeMode(argv) && options.rpc !== true,
|
|
@@ -40516,4 +40483,4 @@ if (process.env.CLI_VERSION) {
|
|
|
40516
40483
|
}
|
|
40517
40484
|
runCli(process.argv.slice(2), cliVersion);
|
|
40518
40485
|
|
|
40519
|
-
//# debugId=
|
|
40486
|
+
//# debugId=7B351CAFF933F24B64756E2164756E21
|
package/dist/index.js
CHANGED
|
@@ -285,14 +285,16 @@ function loadConfig() {
|
|
|
285
285
|
const fileSelection = fileDescribesKey ? credentials?.defaultWorkspace : undefined;
|
|
286
286
|
const selected = fileSelection ?? rcConfig?.defaultWorkspace;
|
|
287
287
|
const defaultWorkspace = envWorkspace !== "" ? envWorkspace : selected;
|
|
288
|
-
const
|
|
288
|
+
const inSandbox = inCloudSandbox();
|
|
289
|
+
const storedKey = inSandbox ? undefined : credentials?.apiKey ?? rcConfig?.apiKey;
|
|
290
|
+
const storedEndpoint = inSandbox ? undefined : credentials?.endpoint ?? rcConfig?.endpoint;
|
|
289
291
|
const merged = {
|
|
290
292
|
providers: {},
|
|
291
293
|
environment: "production",
|
|
292
294
|
...rcConfig,
|
|
293
295
|
...credentials,
|
|
294
296
|
apiKey: envKey ?? storedKey,
|
|
295
|
-
endpoint: process.env.MUTAGENT_ENDPOINT ??
|
|
297
|
+
endpoint: process.env.MUTAGENT_ENDPOINT ?? storedEndpoint,
|
|
296
298
|
defaultWorkspace,
|
|
297
299
|
workspaceOrigin: envWorkspace !== "" ? "override" : selected ? "selection" : undefined,
|
|
298
300
|
workspaceName: envWorkspace === "" && fileSelection !== undefined && fileSelection === selected ? credentials?.workspaceName : undefined,
|
|
@@ -352,6 +354,8 @@ function clearCredentials() {
|
|
|
352
354
|
function hasCredentials() {
|
|
353
355
|
if (process.env.MUTAGENT_API_KEY)
|
|
354
356
|
return true;
|
|
357
|
+
if (inCloudSandbox())
|
|
358
|
+
return true;
|
|
355
359
|
if (!existsSync(CREDENTIALS_FILE))
|
|
356
360
|
return false;
|
|
357
361
|
const credentials = parseJsonSafe(readFileSync(CREDENTIALS_FILE, "utf-8"), credentialsSchema);
|
|
@@ -439,6 +443,9 @@ var runningPath;
|
|
|
439
443
|
function present(value) {
|
|
440
444
|
return value !== undefined && value.trim() !== "";
|
|
441
445
|
}
|
|
446
|
+
function inSandboxSession(env = process.env) {
|
|
447
|
+
return present(env[SANDBOX_TOKEN_VAR2]);
|
|
448
|
+
}
|
|
442
449
|
function signedInWithSessionToken(env = process.env) {
|
|
443
450
|
return present(env[SANDBOX_TOKEN_VAR2]) && !present(getApiKey());
|
|
444
451
|
}
|
|
@@ -712,7 +719,7 @@ function errorBody(error) {
|
|
|
712
719
|
if (error instanceof WorkspaceContextError) {
|
|
713
720
|
body.remediation = { setWorkspace: "mutagent workspaces use <name>", listWorkspaces: "mutagent workspaces list" };
|
|
714
721
|
}
|
|
715
|
-
if (error instanceof ApiError && error.statusCode === 403) {
|
|
722
|
+
if (error instanceof ApiError && error.statusCode === 403 && !inSandboxSession()) {
|
|
716
723
|
body.remediation = {
|
|
717
724
|
interactive: SIGN_IN_COMMAND,
|
|
718
725
|
nonInteractive: "export MUTAGENT_API_KEY=<your-key>",
|
|
@@ -734,7 +741,7 @@ function printHuman(error) {
|
|
|
734
741
|
} else if (error instanceof WorkspaceContextError) {
|
|
735
742
|
console.error("");
|
|
736
743
|
console.error(WORKSPACE_REMEDIATION_MESSAGE);
|
|
737
|
-
} else if (error instanceof ApiError && error.statusCode === 403) {
|
|
744
|
+
} else if (error instanceof ApiError && error.statusCode === 403 && !inSandboxSession()) {
|
|
738
745
|
console.error("");
|
|
739
746
|
console.error("Access denied. To fix:");
|
|
740
747
|
console.error(` ${SIGN_IN_COMMAND} # Re-authenticate`);
|
|
@@ -2081,4 +2088,4 @@ export {
|
|
|
2081
2088
|
version
|
|
2082
2089
|
};
|
|
2083
2090
|
|
|
2084
|
-
//# debugId=
|
|
2091
|
+
//# debugId=2497007B7285F9A164756E2164756E21
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mutagent/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.118",
|
|
4
4
|
"description": "Bun-native CLI for the MutagenT AI platform - auth, provider config, and lifecycle-tool installer for AI-native workflows",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@inquirer/prompts": "^8.7.2",
|
|
48
|
-
"@mutagent/sdk": "0.8.
|
|
48
|
+
"@mutagent/sdk": "0.8.61",
|
|
49
49
|
"@sinclair/typebox": "^0.34.0",
|
|
50
50
|
"chalk": "^5.3.0",
|
|
51
51
|
"commander": "^12.1.0",
|