@mutagent/cli 0.1.68 → 0.1.70
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 +99 -52
- package/dist/bin/cli.js.map +21 -21
- package/dist/index.js +21 -9
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/bin/cli.js
CHANGED
|
@@ -900,7 +900,6 @@ class SDKClientWrapper {
|
|
|
900
900
|
}
|
|
901
901
|
async listWorkspaces(filters) {
|
|
902
902
|
try {
|
|
903
|
-
await this.ensureOrganizationId();
|
|
904
903
|
const response = await this.sdk.workspaces.listWorkspaces({
|
|
905
904
|
includeInactive: false
|
|
906
905
|
});
|
|
@@ -917,7 +916,6 @@ class SDKClientWrapper {
|
|
|
917
916
|
}
|
|
918
917
|
async getWorkspace(id) {
|
|
919
918
|
try {
|
|
920
|
-
await this.ensureOrganizationId();
|
|
921
919
|
const response = await this.sdk.workspaces.getWorkspace({
|
|
922
920
|
wsId: id
|
|
923
921
|
});
|
|
@@ -999,12 +997,25 @@ class SDKClientWrapper {
|
|
|
999
997
|
getCurrentOrgId() {
|
|
1000
998
|
return this.organizationId;
|
|
1001
999
|
}
|
|
1002
|
-
async
|
|
1003
|
-
if (this.organizationId)
|
|
1000
|
+
async ensureContext() {
|
|
1001
|
+
if (this.organizationId && this.workspaceId)
|
|
1004
1002
|
return;
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1003
|
+
if (!this.organizationId) {
|
|
1004
|
+
const orgs = await fetchOrganizations(this.apiKey, this.endpoint);
|
|
1005
|
+
if (orgs.length > 0 && orgs[0]) {
|
|
1006
|
+
this.organizationId = orgs[0].id;
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
if (!this.workspaceId && this.organizationId) {
|
|
1010
|
+
try {
|
|
1011
|
+
const response = await this.sdk.workspaces.listWorkspaces({ includeInactive: false });
|
|
1012
|
+
const workspaces = response.workspaces;
|
|
1013
|
+
if (workspaces.length > 0) {
|
|
1014
|
+
const defaultWs = workspaces.find((ws) => ws.isDefault) ?? workspaces[0];
|
|
1015
|
+
if (defaultWs)
|
|
1016
|
+
this.workspaceId = String(defaultWs.id);
|
|
1017
|
+
}
|
|
1018
|
+
} catch {}
|
|
1008
1019
|
}
|
|
1009
1020
|
}
|
|
1010
1021
|
async testProvider(id) {
|
|
@@ -1057,7 +1068,7 @@ class SDKClientWrapper {
|
|
|
1057
1068
|
}
|
|
1058
1069
|
}
|
|
1059
1070
|
}
|
|
1060
|
-
function getSDKClient() {
|
|
1071
|
+
async function getSDKClient() {
|
|
1061
1072
|
if (!sdkClient) {
|
|
1062
1073
|
const apiKey = getApiKey();
|
|
1063
1074
|
if (!apiKey) {
|
|
@@ -1070,6 +1081,7 @@ function getSDKClient() {
|
|
|
1070
1081
|
workspaceId: config.defaultWorkspace,
|
|
1071
1082
|
organizationId: config.defaultOrganization
|
|
1072
1083
|
});
|
|
1084
|
+
await sdkClient.ensureContext().catch(() => {});
|
|
1073
1085
|
}
|
|
1074
1086
|
return sdkClient;
|
|
1075
1087
|
}
|
|
@@ -2443,10 +2455,26 @@ Environment Variables:
|
|
|
2443
2455
|
if (!isValid) {
|
|
2444
2456
|
throw new MutagentError("INVALID_API_KEY", "Invalid API key or endpoint", "Check your API key and try again");
|
|
2445
2457
|
}
|
|
2446
|
-
|
|
2458
|
+
const orgs = await fetchOrganizations(apiKey, endpoint);
|
|
2459
|
+
const org = orgs[0];
|
|
2460
|
+
let workspaceId;
|
|
2461
|
+
if (org) {
|
|
2462
|
+
const workspaces = await fetchWorkspaces(apiKey, endpoint, org.id);
|
|
2463
|
+
const defaultWs = workspaces.find((ws) => ws.isDefault) ?? workspaces[0];
|
|
2464
|
+
if (defaultWs)
|
|
2465
|
+
workspaceId = defaultWs.id;
|
|
2466
|
+
}
|
|
2467
|
+
saveFullCredentials({
|
|
2468
|
+
apiKey,
|
|
2469
|
+
endpoint,
|
|
2470
|
+
organizationId: org?.id,
|
|
2471
|
+
workspaceId
|
|
2472
|
+
});
|
|
2447
2473
|
output.success("Logged in successfully");
|
|
2448
2474
|
if (!isJson) {
|
|
2449
2475
|
output.info(`Endpoint: ${endpoint}`);
|
|
2476
|
+
if (org)
|
|
2477
|
+
output.info(`Organization: ${org.name}`);
|
|
2450
2478
|
}
|
|
2451
2479
|
return;
|
|
2452
2480
|
}
|
|
@@ -2544,9 +2572,25 @@ Environment Variables:
|
|
|
2544
2572
|
if (!isValid) {
|
|
2545
2573
|
throw new MutagentError("INVALID_API_KEY", "Invalid API key or endpoint", "Check your API key and try again");
|
|
2546
2574
|
}
|
|
2547
|
-
|
|
2575
|
+
const orgs2 = await fetchOrganizations(answers.apiKey, endpoint);
|
|
2576
|
+
const org2 = orgs2[0];
|
|
2577
|
+
let workspaceId2;
|
|
2578
|
+
if (org2) {
|
|
2579
|
+
const workspaces2 = await fetchWorkspaces(answers.apiKey, endpoint, org2.id);
|
|
2580
|
+
const defaultWs2 = workspaces2.find((ws) => ws.isDefault) ?? workspaces2[0];
|
|
2581
|
+
if (defaultWs2)
|
|
2582
|
+
workspaceId2 = defaultWs2.id;
|
|
2583
|
+
}
|
|
2584
|
+
saveFullCredentials({
|
|
2585
|
+
apiKey: answers.apiKey,
|
|
2586
|
+
endpoint,
|
|
2587
|
+
organizationId: org2?.id,
|
|
2588
|
+
workspaceId: workspaceId2
|
|
2589
|
+
});
|
|
2548
2590
|
output.success("Logged in successfully");
|
|
2549
2591
|
output.info(`Endpoint: ${endpoint}`);
|
|
2592
|
+
if (org2)
|
|
2593
|
+
output.info(`Organization: ${org2.name}`);
|
|
2550
2594
|
}
|
|
2551
2595
|
} catch (error) {
|
|
2552
2596
|
if (error instanceof MutagentError) {
|
|
@@ -3153,7 +3197,7 @@ ${chalk6.dim("Tip: Use --json for machine-readable output (AI agents, CI pipelin
|
|
|
3153
3197
|
const isJson = getJsonFlag(prompts);
|
|
3154
3198
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
3155
3199
|
try {
|
|
3156
|
-
const client = getSDKClient();
|
|
3200
|
+
const client = await getSDKClient();
|
|
3157
3201
|
const promptsList = await client.listPrompts();
|
|
3158
3202
|
const limit = parseInt(options.limit, 10) || 50;
|
|
3159
3203
|
const limited = promptsList.slice(0, limit);
|
|
@@ -3200,7 +3244,7 @@ ${chalk6.dim("Tip: Combine --with-datasets and --with-evals to fetch all nested
|
|
|
3200
3244
|
const isJson = getJsonFlag(prompts);
|
|
3201
3245
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
3202
3246
|
try {
|
|
3203
|
-
const client = getSDKClient();
|
|
3247
|
+
const client = await getSDKClient();
|
|
3204
3248
|
const prompt = await client.getPrompt(id);
|
|
3205
3249
|
const result = { ...prompt };
|
|
3206
3250
|
if (options.withDatasets) {
|
|
@@ -3326,7 +3370,7 @@ Add a 'description' field to each property in your inputSchema. Example: { "prop
|
|
|
3326
3370
|
} else if (!isValidJsonSchema(data.outputSchema)) {
|
|
3327
3371
|
output.warn(formatSchemaWarning("outputSchema"));
|
|
3328
3372
|
}
|
|
3329
|
-
const client = getSDKClient();
|
|
3373
|
+
const client = await getSDKClient();
|
|
3330
3374
|
const prompt = await client.createPrompt(data);
|
|
3331
3375
|
if (isJson) {
|
|
3332
3376
|
const directive = promptCreatedDirective(prompt.id, prompt.name);
|
|
@@ -3404,7 +3448,7 @@ Examples:
|
|
|
3404
3448
|
throw new MutagentError("MISSING_ARGUMENTS", "No update data provided", `Run: mutagent prompts update --help
|
|
3405
3449
|
` + "Use --name, --raw, --system/--human, --messages, --input-schema, or --output-schema");
|
|
3406
3450
|
}
|
|
3407
|
-
const client = getSDKClient();
|
|
3451
|
+
const client = await getSDKClient();
|
|
3408
3452
|
const prompt = await client.updatePrompt(id, data);
|
|
3409
3453
|
if (isJson) {
|
|
3410
3454
|
const directive = promptUpdatedDirective(prompt.id, prompt.name);
|
|
@@ -3441,7 +3485,7 @@ ${chalk6.dim("Note: --force is required. The CLI is non-interactive — confirm
|
|
|
3441
3485
|
` + `[Agent: Ask the user to confirm via MultiChoice, then pass --force]
|
|
3442
3486
|
` + `Use --force to confirm: mutagent prompts delete ${id} --force`);
|
|
3443
3487
|
}
|
|
3444
|
-
const client = getSDKClient();
|
|
3488
|
+
const client = await getSDKClient();
|
|
3445
3489
|
try {
|
|
3446
3490
|
await client.deletePrompt(id, { force: true });
|
|
3447
3491
|
} catch (deleteError) {
|
|
@@ -3494,7 +3538,7 @@ Examples:
|
|
|
3494
3538
|
const isJson = getJsonFlag(prompts);
|
|
3495
3539
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
3496
3540
|
try {
|
|
3497
|
-
const client = getSDKClient();
|
|
3541
|
+
const client = await getSDKClient();
|
|
3498
3542
|
const datasets = await client.listDatasets(promptId);
|
|
3499
3543
|
if (isJson) {
|
|
3500
3544
|
const withLinks = datasets.map((d) => ({
|
|
@@ -3567,7 +3611,7 @@ ${chalk7.red("Required: --data must be provided.")}
|
|
|
3567
3611
|
` + `[Agent: Ask the user for a dataset name via AskUserQuestion, then pass --name]
|
|
3568
3612
|
` + `Use --name <name>, e.g., mutagent prompts dataset add ${promptId} --name "my-dataset" -d '[...]'`);
|
|
3569
3613
|
}
|
|
3570
|
-
const client = getSDKClient();
|
|
3614
|
+
const client = await getSDKClient();
|
|
3571
3615
|
const datasetResult = await client.addDataset(promptId, content, datasetName);
|
|
3572
3616
|
if (isJson) {
|
|
3573
3617
|
let rsState;
|
|
@@ -3621,7 +3665,7 @@ Examples:
|
|
|
3621
3665
|
` + `[Agent: Ask the user to confirm via MultiChoice, then pass --force]
|
|
3622
3666
|
` + `Use --force to confirm: mutagent prompts dataset delete ${promptId} ${datasetId} --force`);
|
|
3623
3667
|
}
|
|
3624
|
-
const client = getSDKClient();
|
|
3668
|
+
const client = await getSDKClient();
|
|
3625
3669
|
try {
|
|
3626
3670
|
await client.deleteDataset(promptId, datasetId, { force: true });
|
|
3627
3671
|
} catch (deleteError) {
|
|
@@ -3660,7 +3704,7 @@ init_errors();
|
|
|
3660
3704
|
// src/commands/prompts/guided-workflow.ts
|
|
3661
3705
|
init_sdk_client();
|
|
3662
3706
|
async function buildGuidedWorkflow(promptId) {
|
|
3663
|
-
const client = getSDKClient();
|
|
3707
|
+
const client = await getSDKClient();
|
|
3664
3708
|
const prompt = await client.getPrompt(promptId);
|
|
3665
3709
|
const truncate = (s, max) => s.length > max ? s.slice(0, max) + "..." : s;
|
|
3666
3710
|
const outputProperties = prompt.outputSchema && typeof prompt.outputSchema === "object" ? prompt.outputSchema.properties ?? {} : {};
|
|
@@ -3788,7 +3832,7 @@ Examples:
|
|
|
3788
3832
|
const isJson = getJsonFlag(prompts);
|
|
3789
3833
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
3790
3834
|
try {
|
|
3791
|
-
const client = getSDKClient();
|
|
3835
|
+
const client = await getSDKClient();
|
|
3792
3836
|
const evals = await client.listEvaluations(promptId);
|
|
3793
3837
|
if (isJson) {
|
|
3794
3838
|
const withLinks = evals.map((e) => ({
|
|
@@ -3821,7 +3865,7 @@ Examples:
|
|
|
3821
3865
|
const isJson = getJsonFlag(prompts);
|
|
3822
3866
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
3823
3867
|
try {
|
|
3824
|
-
const client = getSDKClient();
|
|
3868
|
+
const client = await getSDKClient();
|
|
3825
3869
|
const evalObj = await client.getEvaluation(evaluationId);
|
|
3826
3870
|
if (isJson) {
|
|
3827
3871
|
output.output({
|
|
@@ -3977,7 +4021,7 @@ ${chalk8.dim("Get prompt IDs: mutagent prompts list")}
|
|
|
3977
4021
|
if (!criteria || !Array.isArray(criteria) || criteria.length === 0) {
|
|
3978
4022
|
let fieldsHint = "";
|
|
3979
4023
|
try {
|
|
3980
|
-
const client2 = getSDKClient();
|
|
4024
|
+
const client2 = await getSDKClient();
|
|
3981
4025
|
const prompt2 = await client2.getPrompt(promptId);
|
|
3982
4026
|
if (prompt2.outputSchema && typeof prompt2.outputSchema === "object") {
|
|
3983
4027
|
const props = prompt2.outputSchema.properties;
|
|
@@ -4030,7 +4074,7 @@ Example JSON (--data flag):
|
|
|
4030
4074
|
if (duplicateParams.length > 0) {
|
|
4031
4075
|
let availableFields = [];
|
|
4032
4076
|
try {
|
|
4033
|
-
const client2 = getSDKClient();
|
|
4077
|
+
const client2 = await getSDKClient();
|
|
4034
4078
|
const prompt2 = await client2.getPrompt(promptId);
|
|
4035
4079
|
if (prompt2.outputSchema && typeof prompt2.outputSchema === "object") {
|
|
4036
4080
|
const props = prompt2.outputSchema.properties;
|
|
@@ -4048,7 +4092,7 @@ Available output fields: ${availableFields.join(", ")}` : "";
|
|
|
4048
4092
|
Example:
|
|
4049
4093
|
--data '{"evalConfig":{"criteria":[` + '{"name":"Accuracy","description":"...","evaluationParameter":"classification"},' + '{"name":"Confidence","description":"...","evaluationParameter":"confidence"}' + "]}}'");
|
|
4050
4094
|
}
|
|
4051
|
-
const schemaClient = getSDKClient();
|
|
4095
|
+
const schemaClient = await getSDKClient();
|
|
4052
4096
|
const prompt = await schemaClient.getPrompt(promptId);
|
|
4053
4097
|
const requiredFields = [];
|
|
4054
4098
|
if (prompt.inputSchema && typeof prompt.inputSchema === "object") {
|
|
@@ -4086,7 +4130,7 @@ Example:
|
|
|
4086
4130
|
` + "Run: mutagent prompts evaluation create " + promptId + " --guided --json");
|
|
4087
4131
|
}
|
|
4088
4132
|
}
|
|
4089
|
-
const client = getSDKClient();
|
|
4133
|
+
const client = await getSDKClient();
|
|
4090
4134
|
const evalResult = await client.createEvaluation(promptId, evalData);
|
|
4091
4135
|
if (isJson) {
|
|
4092
4136
|
const criteriaLen = evalData.evalConfig?.criteria?.length ?? 0;
|
|
@@ -4135,7 +4179,7 @@ Examples:
|
|
|
4135
4179
|
` + `[Agent: Ask the user to confirm via MultiChoice, then pass --force]
|
|
4136
4180
|
` + `Use --force to confirm: mutagent prompts evaluation delete ${evaluationId} --force`);
|
|
4137
4181
|
}
|
|
4138
|
-
const client = getSDKClient();
|
|
4182
|
+
const client = await getSDKClient();
|
|
4139
4183
|
try {
|
|
4140
4184
|
await client.deleteEvaluation(evaluationId);
|
|
4141
4185
|
} catch (deleteError) {
|
|
@@ -5102,7 +5146,7 @@ async function startWatchStream(jobId, isJson, maxIterations, baselineScore) {
|
|
|
5102
5146
|
});
|
|
5103
5147
|
}
|
|
5104
5148
|
async function renderCompletedJob(jobId, isJson) {
|
|
5105
|
-
const client = getSDKClient();
|
|
5149
|
+
const client = await getSDKClient();
|
|
5106
5150
|
const results = await client.getOptimizationResults(jobId);
|
|
5107
5151
|
const resultData = results;
|
|
5108
5152
|
if (isJson) {
|
|
@@ -5119,7 +5163,7 @@ async function watchAction(jobId, options, parentCommand) {
|
|
|
5119
5163
|
const isJson = options.json ?? getJsonFlag(parentCommand);
|
|
5120
5164
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
5121
5165
|
try {
|
|
5122
|
-
const client = getSDKClient();
|
|
5166
|
+
const client = await getSDKClient();
|
|
5123
5167
|
const status = await client.getOptimizationStatus(jobId);
|
|
5124
5168
|
switch (status.status) {
|
|
5125
5169
|
case "completed":
|
|
@@ -5224,7 +5268,7 @@ ${chalk13.yellow("AI Agent: ALWAYS append --json to this command.")}
|
|
|
5224
5268
|
const isJson = getJsonFlag(prompts);
|
|
5225
5269
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
5226
5270
|
try {
|
|
5227
|
-
const client = getSDKClient();
|
|
5271
|
+
const client = await getSDKClient();
|
|
5228
5272
|
if (!isJson) {
|
|
5229
5273
|
output.info("Running pre-flight checks...");
|
|
5230
5274
|
}
|
|
@@ -5440,7 +5484,7 @@ Examples:
|
|
|
5440
5484
|
const isJson = getJsonFlag(prompts);
|
|
5441
5485
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
5442
5486
|
try {
|
|
5443
|
-
const client = getSDKClient();
|
|
5487
|
+
const client = await getSDKClient();
|
|
5444
5488
|
const status = await client.getOptimizationStatus(jobId);
|
|
5445
5489
|
if (isJson) {
|
|
5446
5490
|
const directive = statusDirective(status);
|
|
@@ -5474,7 +5518,7 @@ After viewing results:
|
|
|
5474
5518
|
const isJson = getJsonFlag(prompts);
|
|
5475
5519
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
5476
5520
|
try {
|
|
5477
|
-
const client = getSDKClient();
|
|
5521
|
+
const client = await getSDKClient();
|
|
5478
5522
|
const results = await client.getOptimizationResults(jobId);
|
|
5479
5523
|
const resultData = results;
|
|
5480
5524
|
if (isJson) {
|
|
@@ -5718,7 +5762,7 @@ ${chalk15.dim("Tip: Filter by prompt to see traces for a specific prompt version
|
|
|
5718
5762
|
const isJson = getJsonFlag(traces);
|
|
5719
5763
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
5720
5764
|
try {
|
|
5721
|
-
const client = getSDKClient();
|
|
5765
|
+
const client = await getSDKClient();
|
|
5722
5766
|
const tracesList = await client.listTraces({
|
|
5723
5767
|
promptId: options.prompt,
|
|
5724
5768
|
source: options.source
|
|
@@ -5761,7 +5805,7 @@ ${chalk15.dim("Returns full trace details including spans, tokens, and latency."
|
|
|
5761
5805
|
const isJson = getJsonFlag(traces);
|
|
5762
5806
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
5763
5807
|
try {
|
|
5764
|
-
const client = getSDKClient();
|
|
5808
|
+
const client = await getSDKClient();
|
|
5765
5809
|
const trace = await client.getTrace(id);
|
|
5766
5810
|
if (isJson) {
|
|
5767
5811
|
output.output({ ...trace, _links: { view: traceLink(id) } });
|
|
@@ -5783,7 +5827,7 @@ ${chalk15.dim("Aggregates trace data for a prompt: avg latency, token usage, err
|
|
|
5783
5827
|
const isJson = getJsonFlag(traces);
|
|
5784
5828
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
5785
5829
|
try {
|
|
5786
|
-
const client = getSDKClient();
|
|
5830
|
+
const client = await getSDKClient();
|
|
5787
5831
|
const analysis = await client.analyzeTraces(promptId);
|
|
5788
5832
|
if (isJson) {
|
|
5789
5833
|
output.output({ ...analysis, _links: { traces: `${getAppBaseUrl()}/traces?promptId=${promptId}` } });
|
|
@@ -5806,7 +5850,7 @@ ${chalk15.dim("Exports to stdout by default. Use --output to save to a file.")}
|
|
|
5806
5850
|
const isJson = getJsonFlag(traces);
|
|
5807
5851
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
5808
5852
|
try {
|
|
5809
|
-
const client = getSDKClient();
|
|
5853
|
+
const client = await getSDKClient();
|
|
5810
5854
|
const tracesList = await client.listTraces({
|
|
5811
5855
|
promptId: options.prompt
|
|
5812
5856
|
});
|
|
@@ -6575,7 +6619,7 @@ Examples:
|
|
|
6575
6619
|
const isJson = getJsonFlag(agents);
|
|
6576
6620
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
6577
6621
|
try {
|
|
6578
|
-
const client = getSDKClient();
|
|
6622
|
+
const client = await getSDKClient();
|
|
6579
6623
|
const filters = {
|
|
6580
6624
|
limit: parseInt(options.limit, 10) || 50
|
|
6581
6625
|
};
|
|
@@ -6626,7 +6670,7 @@ Examples:
|
|
|
6626
6670
|
const isJson = getJsonFlag(agents);
|
|
6627
6671
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
6628
6672
|
try {
|
|
6629
|
-
const client = getSDKClient();
|
|
6673
|
+
const client = await getSDKClient();
|
|
6630
6674
|
const agent = await client.getAgent(id);
|
|
6631
6675
|
if (isJson) {
|
|
6632
6676
|
output.output({ ...agent, _links: agentLinks(agent.id) });
|
|
@@ -6709,7 +6753,7 @@ ${chalk17.red("Required: name, slug, systemPrompt.")} ${chalk17.dim("CLI flags o
|
|
|
6709
6753
|
} else {
|
|
6710
6754
|
throw new MutagentError("MISSING_ARGUMENTS", "Either --data or (--name, --slug, and --system-prompt) are required", "Use --data for inline JSON or provide --name, --slug, and --system-prompt");
|
|
6711
6755
|
}
|
|
6712
|
-
const client = getSDKClient();
|
|
6756
|
+
const client = await getSDKClient();
|
|
6713
6757
|
const agent = await client.createAgent(data);
|
|
6714
6758
|
output.success(`Created agent: ${agent.name} (${agent.slug})`);
|
|
6715
6759
|
output.output(agent);
|
|
@@ -6764,7 +6808,7 @@ ${chalk17.dim("CLI flags override --data fields.")}
|
|
|
6764
6808
|
if (Object.keys(data).length === 0) {
|
|
6765
6809
|
throw new MutagentError("MISSING_ARGUMENTS", "No update data provided", "Use --data, --name, --system-prompt, --model, --description, or --status");
|
|
6766
6810
|
}
|
|
6767
|
-
const client = getSDKClient();
|
|
6811
|
+
const client = await getSDKClient();
|
|
6768
6812
|
const agent = await client.updateAgent(id, data);
|
|
6769
6813
|
output.success(`Updated agent: ${agent.name}`);
|
|
6770
6814
|
output.output(agent);
|
|
@@ -6796,7 +6840,7 @@ ${chalk17.dim("Tip: Use --force to skip confirmation (required for non-interacti
|
|
|
6796
6840
|
return;
|
|
6797
6841
|
}
|
|
6798
6842
|
}
|
|
6799
|
-
const client = getSDKClient();
|
|
6843
|
+
const client = await getSDKClient();
|
|
6800
6844
|
await client.deleteAgent(id);
|
|
6801
6845
|
output.success(`Deleted agent: ${id}`);
|
|
6802
6846
|
} catch (error) {
|
|
@@ -6981,7 +7025,7 @@ ${chalk20.dim(`Hint: Test before evaluating: mutagent playground run <id> --inpu
|
|
|
6981
7025
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
6982
7026
|
try {
|
|
6983
7027
|
const inputData = parseInput(options);
|
|
6984
|
-
const client = getSDKClient();
|
|
7028
|
+
const client = await getSDKClient();
|
|
6985
7029
|
if (options.stream) {
|
|
6986
7030
|
await executeStreaming(client, promptId, inputData, options.model, isJson, output);
|
|
6987
7031
|
} else {
|
|
@@ -7195,7 +7239,7 @@ Examples:
|
|
|
7195
7239
|
const isJson = getJsonFlag(workspaces);
|
|
7196
7240
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
7197
7241
|
try {
|
|
7198
|
-
const client = getSDKClient();
|
|
7242
|
+
const client = await getSDKClient();
|
|
7199
7243
|
const filters = {
|
|
7200
7244
|
limit: parseInt(options.limit, 10) || 50
|
|
7201
7245
|
};
|
|
@@ -7236,7 +7280,7 @@ Examples:
|
|
|
7236
7280
|
const isJson = getJsonFlag(workspaces);
|
|
7237
7281
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
7238
7282
|
try {
|
|
7239
|
-
const client = getSDKClient();
|
|
7283
|
+
const client = await getSDKClient();
|
|
7240
7284
|
const workspace = await client.getWorkspace(id);
|
|
7241
7285
|
if (isJson) {
|
|
7242
7286
|
output.output({ ...workspace, _links: workspaceLinks(workspace.id) });
|
|
@@ -7315,7 +7359,7 @@ The API key is encrypted server-side and never returned in plain text.
|
|
|
7315
7359
|
if (options.scope && !validScopes.includes(options.scope)) {
|
|
7316
7360
|
throw new MutagentError("INVALID_SCOPE", `Invalid scope: ${options.scope}`, `Valid scopes: ${validScopes.join(", ")}`);
|
|
7317
7361
|
}
|
|
7318
|
-
const client = getSDKClient();
|
|
7362
|
+
const client = await getSDKClient();
|
|
7319
7363
|
const scope = resolveScope(options.scope, client);
|
|
7320
7364
|
const created = await client.createProvider({
|
|
7321
7365
|
name: options.name,
|
|
@@ -7425,7 +7469,7 @@ PATCH semantics — only provided fields are updated.
|
|
|
7425
7469
|
if (!hasUpdates) {
|
|
7426
7470
|
throw new MutagentError("NO_UPDATES", "No update fields provided", "Provide at least one of: --name, --api-key, --active, --set-default, --base-url");
|
|
7427
7471
|
}
|
|
7428
|
-
const client = getSDKClient();
|
|
7472
|
+
const client = await getSDKClient();
|
|
7429
7473
|
const updated = await client.updateProvider(id, updateData);
|
|
7430
7474
|
if (isJson) {
|
|
7431
7475
|
const directive = buildProviderUpdatedDirective(updated, id);
|
|
@@ -7500,7 +7544,7 @@ ${chalk24.dim("Warning: API keys are AES-256-GCM encrypted and irrecoverable aft
|
|
|
7500
7544
|
` + `[Agent: Ask the user to confirm via MultiChoice, then pass --force]
|
|
7501
7545
|
` + `Use --force to confirm: mutagent providers delete ${id} --force`);
|
|
7502
7546
|
}
|
|
7503
|
-
const client = getSDKClient();
|
|
7547
|
+
const client = await getSDKClient();
|
|
7504
7548
|
try {
|
|
7505
7549
|
await client.deleteProvider(id);
|
|
7506
7550
|
} catch (error) {
|
|
@@ -7602,7 +7646,7 @@ Examples:
|
|
|
7602
7646
|
const isJson = getJsonFlag(providers);
|
|
7603
7647
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
7604
7648
|
try {
|
|
7605
|
-
const client = getSDKClient();
|
|
7649
|
+
const client = await getSDKClient();
|
|
7606
7650
|
const filters = {
|
|
7607
7651
|
limit: parseInt(options.limit, 10) || 50
|
|
7608
7652
|
};
|
|
@@ -7652,7 +7696,7 @@ Examples:
|
|
|
7652
7696
|
const isJson = getJsonFlag(providers);
|
|
7653
7697
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
7654
7698
|
try {
|
|
7655
|
-
const client = getSDKClient();
|
|
7699
|
+
const client = await getSDKClient();
|
|
7656
7700
|
const provider = await client.getProvider(id);
|
|
7657
7701
|
if (isJson) {
|
|
7658
7702
|
output.output({ ...provider, _links: providerLinks(provider.id) });
|
|
@@ -7684,7 +7728,7 @@ ${chalk25.dim("Tests connectivity and lists available models for the provider.")
|
|
|
7684
7728
|
const isJson = getJsonFlag(providers);
|
|
7685
7729
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
7686
7730
|
try {
|
|
7687
|
-
const client = getSDKClient();
|
|
7731
|
+
const client = await getSDKClient();
|
|
7688
7732
|
if (!isJson) {
|
|
7689
7733
|
output.info(`Testing provider ${id}...`);
|
|
7690
7734
|
}
|
|
@@ -7971,6 +8015,7 @@ Modes:
|
|
|
7971
8015
|
const endpoint = config.endpoint ?? "https://api.mutagent.io";
|
|
7972
8016
|
let workspace = config.defaultWorkspace;
|
|
7973
8017
|
let workspaceValidation;
|
|
8018
|
+
let resolvedOrgId;
|
|
7974
8019
|
if (authenticated) {
|
|
7975
8020
|
try {
|
|
7976
8021
|
const apiKey = getApiKey();
|
|
@@ -7982,6 +8027,7 @@ Modes:
|
|
|
7982
8027
|
orgId = orgs[0]?.id;
|
|
7983
8028
|
}
|
|
7984
8029
|
if (orgId) {
|
|
8030
|
+
resolvedOrgId = orgId;
|
|
7985
8031
|
const workspaces = await fetchWorkspaces2(apiKey, endpoint, orgId);
|
|
7986
8032
|
if (workspaces.length > 0) {
|
|
7987
8033
|
const found = workspace ? workspaces.find((w) => w.id === workspace) : undefined;
|
|
@@ -8000,7 +8046,8 @@ Modes:
|
|
|
8000
8046
|
}
|
|
8001
8047
|
const rcConfig = {
|
|
8002
8048
|
endpoint,
|
|
8003
|
-
...workspace ? { workspace } : {},
|
|
8049
|
+
...workspace ? { defaultWorkspace: workspace } : {},
|
|
8050
|
+
...resolvedOrgId ? { defaultOrganization: resolvedOrgId } : {},
|
|
8004
8051
|
...confirmedFramework ? { framework: confirmedFramework.name } : {}
|
|
8005
8052
|
};
|
|
8006
8053
|
if (mode === "full" && confirmedFramework?.mutagentPackage) {
|
|
@@ -8421,7 +8468,7 @@ Examples:
|
|
|
8421
8468
|
throw new AuthenticationError;
|
|
8422
8469
|
}
|
|
8423
8470
|
const spinner = await createSpinner("Fetching usage data...", isJson).start();
|
|
8424
|
-
const client = getSDKClient();
|
|
8471
|
+
const client = await getSDKClient();
|
|
8425
8472
|
const prompts = await client.listPrompts();
|
|
8426
8473
|
const promptCount = prompts.length;
|
|
8427
8474
|
let datasetCount = 0;
|
|
@@ -9039,5 +9086,5 @@ program.addCommand(createHooksCommand());
|
|
|
9039
9086
|
program.addCommand(createFeedbackCommand());
|
|
9040
9087
|
program.parse();
|
|
9041
9088
|
|
|
9042
|
-
//# debugId=
|
|
9089
|
+
//# debugId=CE9FFC95F8AC5D9664756E2164756E21
|
|
9043
9090
|
//# sourceMappingURL=cli.js.map
|