@mutagent/cli 0.2.116 → 0.2.117
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 +17 -54
- package/dist/index.js +6 -3
- package/package.json +2 -2
package/dist/bin/cli.js
CHANGED
|
@@ -440,6 +440,9 @@ var init_config = __esm(() => {
|
|
|
440
440
|
function present(value) {
|
|
441
441
|
return value !== undefined && value.trim() !== "";
|
|
442
442
|
}
|
|
443
|
+
function inSandboxSession(env = process.env) {
|
|
444
|
+
return present(env[SANDBOX_TOKEN_VAR2]);
|
|
445
|
+
}
|
|
443
446
|
function signedInWithSessionToken(env = process.env) {
|
|
444
447
|
return present(env[SANDBOX_TOKEN_VAR2]) && !present(getApiKey());
|
|
445
448
|
}
|
|
@@ -713,7 +716,7 @@ function errorBody(error) {
|
|
|
713
716
|
if (error instanceof WorkspaceContextError) {
|
|
714
717
|
body.remediation = { setWorkspace: "mutagent workspaces use <name>", listWorkspaces: "mutagent workspaces list" };
|
|
715
718
|
}
|
|
716
|
-
if (error instanceof ApiError && error.statusCode === 403) {
|
|
719
|
+
if (error instanceof ApiError && error.statusCode === 403 && !inSandboxSession()) {
|
|
717
720
|
body.remediation = {
|
|
718
721
|
interactive: SIGN_IN_COMMAND,
|
|
719
722
|
nonInteractive: "export MUTAGENT_API_KEY=<your-key>",
|
|
@@ -735,7 +738,7 @@ function printHuman(error) {
|
|
|
735
738
|
} else if (error instanceof WorkspaceContextError) {
|
|
736
739
|
console.error("");
|
|
737
740
|
console.error(WORKSPACE_REMEDIATION_MESSAGE);
|
|
738
|
-
} else if (error instanceof ApiError && error.statusCode === 403) {
|
|
741
|
+
} else if (error instanceof ApiError && error.statusCode === 403 && !inSandboxSession()) {
|
|
739
742
|
console.error("");
|
|
740
743
|
console.error("Access denied. To fix:");
|
|
741
744
|
console.error(` ${SIGN_IN_COMMAND} # Re-authenticate`);
|
|
@@ -27210,31 +27213,6 @@ async function runNativeSession(options) {
|
|
|
27210
27213
|
}
|
|
27211
27214
|
}
|
|
27212
27215
|
|
|
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
27216
|
// src/commands/helix/run-cloud.ts
|
|
27239
27217
|
function repositoryFields(flags) {
|
|
27240
27218
|
return {
|
|
@@ -27242,7 +27220,7 @@ function repositoryFields(flags) {
|
|
|
27242
27220
|
...flags.branch === undefined ? {} : { branch: flags.branch }
|
|
27243
27221
|
};
|
|
27244
27222
|
}
|
|
27245
|
-
async function runCloudLaunch(plan, mode
|
|
27223
|
+
async function runCloudLaunch(plan, mode) {
|
|
27246
27224
|
checkSandboxId(plan.sandbox);
|
|
27247
27225
|
checkArgsForRoute(plan.args);
|
|
27248
27226
|
const sandbox = plan.sandbox?.trim();
|
|
@@ -27270,33 +27248,21 @@ async function runCloudLaunch(plan, mode, options = {}) {
|
|
|
27270
27248
|
...plan.environment === undefined ? {} : { environment: plan.environment },
|
|
27271
27249
|
...plan.cwd === undefined ? {} : { cwd: plan.cwd }
|
|
27272
27250
|
};
|
|
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
27251
|
let interruptRequested = false;
|
|
27294
27252
|
const queueInterrupt = () => {
|
|
27295
27253
|
interruptRequested = true;
|
|
27296
27254
|
};
|
|
27297
27255
|
process.on("SIGINT", queueInterrupt);
|
|
27298
27256
|
try {
|
|
27299
|
-
const session = sandbox ? await startSession(sandbox, body) : await
|
|
27257
|
+
const session = sandbox ? await startSession(sandbox, body) : await launchHelixSession({
|
|
27258
|
+
...body,
|
|
27259
|
+
...plan.preset === undefined ? {} : { preset: plan.preset },
|
|
27260
|
+
...plan.sandboxProvider === undefined ? {} : { sandboxProvider: plan.sandboxProvider },
|
|
27261
|
+
...repositoryFields(plan),
|
|
27262
|
+
...plan.factory === undefined ? {} : { subject: plan.factory.subject, stage: plan.factory.stage }
|
|
27263
|
+
}).catch((error) => {
|
|
27264
|
+
throw entryRefusal(launchRepositoryRefusal(error));
|
|
27265
|
+
});
|
|
27300
27266
|
if (!session.reference) {
|
|
27301
27267
|
throw new MutagentError("INVALID_RESPONSE", "The server did not return a session reference.", "Run: mutagent helix doctor");
|
|
27302
27268
|
}
|
|
@@ -27867,9 +27833,6 @@ function registerAgentCommand(parent, registration, deps = defaultPlanDeps()) {
|
|
|
27867
27833
|
" Without --subject the entry is MUTAGENT_SUBJECT_ID, else the session's, else this checkout's .mutagent/factory.json.",
|
|
27868
27834
|
" Errors: FLAG_CONFLICT (--subject without --stage, or either with @id); MISSING_ARGUMENTS (no entry inferred: pass --subject);",
|
|
27869
27835
|
" 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
27836
|
"",
|
|
27874
27837
|
"Definition and task:",
|
|
27875
27838
|
" The first argument (or --prompt, --file, --name) defines the agent; -p gives the task.",
|
|
@@ -27954,7 +27917,7 @@ function registerAgentCommand(parent, registration, deps = defaultPlanDeps()) {
|
|
|
27954
27917
|
...plan.prime ? ["--prime"] : [],
|
|
27955
27918
|
...plan.nativeArgs
|
|
27956
27919
|
]
|
|
27957
|
-
}, mode
|
|
27920
|
+
}, mode);
|
|
27958
27921
|
} catch (error) {
|
|
27959
27922
|
handleLaunchFailure(error, {
|
|
27960
27923
|
isJson: isJson && !hasNativeMode(argv) && options.rpc !== true,
|
|
@@ -40516,4 +40479,4 @@ if (process.env.CLI_VERSION) {
|
|
|
40516
40479
|
}
|
|
40517
40480
|
runCli(process.argv.slice(2), cliVersion);
|
|
40518
40481
|
|
|
40519
|
-
//# debugId=
|
|
40482
|
+
//# debugId=2264DB47597DFDB064756E2164756E21
|
package/dist/index.js
CHANGED
|
@@ -439,6 +439,9 @@ var runningPath;
|
|
|
439
439
|
function present(value) {
|
|
440
440
|
return value !== undefined && value.trim() !== "";
|
|
441
441
|
}
|
|
442
|
+
function inSandboxSession(env = process.env) {
|
|
443
|
+
return present(env[SANDBOX_TOKEN_VAR2]);
|
|
444
|
+
}
|
|
442
445
|
function signedInWithSessionToken(env = process.env) {
|
|
443
446
|
return present(env[SANDBOX_TOKEN_VAR2]) && !present(getApiKey());
|
|
444
447
|
}
|
|
@@ -712,7 +715,7 @@ function errorBody(error) {
|
|
|
712
715
|
if (error instanceof WorkspaceContextError) {
|
|
713
716
|
body.remediation = { setWorkspace: "mutagent workspaces use <name>", listWorkspaces: "mutagent workspaces list" };
|
|
714
717
|
}
|
|
715
|
-
if (error instanceof ApiError && error.statusCode === 403) {
|
|
718
|
+
if (error instanceof ApiError && error.statusCode === 403 && !inSandboxSession()) {
|
|
716
719
|
body.remediation = {
|
|
717
720
|
interactive: SIGN_IN_COMMAND,
|
|
718
721
|
nonInteractive: "export MUTAGENT_API_KEY=<your-key>",
|
|
@@ -734,7 +737,7 @@ function printHuman(error) {
|
|
|
734
737
|
} else if (error instanceof WorkspaceContextError) {
|
|
735
738
|
console.error("");
|
|
736
739
|
console.error(WORKSPACE_REMEDIATION_MESSAGE);
|
|
737
|
-
} else if (error instanceof ApiError && error.statusCode === 403) {
|
|
740
|
+
} else if (error instanceof ApiError && error.statusCode === 403 && !inSandboxSession()) {
|
|
738
741
|
console.error("");
|
|
739
742
|
console.error("Access denied. To fix:");
|
|
740
743
|
console.error(` ${SIGN_IN_COMMAND} # Re-authenticate`);
|
|
@@ -2081,4 +2084,4 @@ export {
|
|
|
2081
2084
|
version
|
|
2082
2085
|
};
|
|
2083
2086
|
|
|
2084
|
-
//# debugId=
|
|
2087
|
+
//# debugId=A87B4098338999E864756E2164756E21
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mutagent/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.117",
|
|
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",
|