@mutagent/cli 0.1.3 → 0.1.5
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 +123 -24
- package/dist/bin/cli.js.map +6 -6
- package/dist/index.js +44 -16
- package/dist/index.js.map +4 -4
- package/package.json +2 -2
package/dist/bin/cli.js
CHANGED
|
@@ -200,9 +200,9 @@ function serverURLFromOptions(options) {
|
|
|
200
200
|
var SDK_METADATA = {
|
|
201
201
|
language: "typescript",
|
|
202
202
|
openapiDocVersion: "2.0.0",
|
|
203
|
-
sdkVersion: "0.2.
|
|
203
|
+
sdkVersion: "0.2.23",
|
|
204
204
|
genVersion: "2.812.2",
|
|
205
|
-
userAgent: "speakeasy-sdk/typescript 0.2.
|
|
205
|
+
userAgent: "speakeasy-sdk/typescript 0.2.23 2.812.2 2.0.0 @mutagent/sdk"
|
|
206
206
|
};
|
|
207
207
|
// ../mutagent-sdk/dist/esm/lib/http.js
|
|
208
208
|
var DEFAULT_FETCHER = (input, init) => {
|
|
@@ -13446,19 +13446,21 @@ class SDKClientWrapper {
|
|
|
13446
13446
|
}
|
|
13447
13447
|
async updatePrompt(id, data) {
|
|
13448
13448
|
try {
|
|
13449
|
-
const
|
|
13450
|
-
|
|
13451
|
-
|
|
13452
|
-
|
|
13453
|
-
|
|
13454
|
-
|
|
13455
|
-
|
|
13456
|
-
|
|
13457
|
-
|
|
13458
|
-
|
|
13459
|
-
|
|
13460
|
-
|
|
13461
|
-
}
|
|
13449
|
+
const body = {
|
|
13450
|
+
description: data.description ?? undefined,
|
|
13451
|
+
isLatest: data.isLatest ?? undefined,
|
|
13452
|
+
systemPrompt: data.systemPrompt ?? undefined,
|
|
13453
|
+
humanPrompt: data.humanPrompt ?? undefined,
|
|
13454
|
+
rawPrompt: data.rawPrompt ?? undefined,
|
|
13455
|
+
outputSchema: data.outputSchema,
|
|
13456
|
+
metadata: data.metadata,
|
|
13457
|
+
tags: data.tags ?? undefined
|
|
13458
|
+
};
|
|
13459
|
+
if (data.name !== undefined) {
|
|
13460
|
+
body.name = data.name;
|
|
13461
|
+
}
|
|
13462
|
+
const updateArgs = { id: parseInt(id, 10), body };
|
|
13463
|
+
const response = await this.sdk.prompt.updatePrompt(updateArgs);
|
|
13462
13464
|
return response;
|
|
13463
13465
|
} catch (error) {
|
|
13464
13466
|
this.handleError(error);
|
|
@@ -13822,6 +13824,32 @@ async function validateApiKey(apiKey, endpoint) {
|
|
|
13822
13824
|
return false;
|
|
13823
13825
|
}
|
|
13824
13826
|
}
|
|
13827
|
+
async function fetchOrganizations(apiKey, endpoint) {
|
|
13828
|
+
try {
|
|
13829
|
+
const response = await fetch(`${endpoint}/api/organizations`, {
|
|
13830
|
+
headers: { "x-api-key": apiKey }
|
|
13831
|
+
});
|
|
13832
|
+
if (!response.ok)
|
|
13833
|
+
return [];
|
|
13834
|
+
const data = await response.json();
|
|
13835
|
+
return data.data ?? [];
|
|
13836
|
+
} catch {
|
|
13837
|
+
return [];
|
|
13838
|
+
}
|
|
13839
|
+
}
|
|
13840
|
+
async function fetchWorkspaces(apiKey, endpoint, orgId) {
|
|
13841
|
+
try {
|
|
13842
|
+
const response = await fetch(`${endpoint}/api/workspaces`, {
|
|
13843
|
+
headers: { "x-api-key": apiKey, "x-organization-id": orgId }
|
|
13844
|
+
});
|
|
13845
|
+
if (!response.ok)
|
|
13846
|
+
return [];
|
|
13847
|
+
const data = await response.json();
|
|
13848
|
+
return data.workspaces ?? [];
|
|
13849
|
+
} catch {
|
|
13850
|
+
return [];
|
|
13851
|
+
}
|
|
13852
|
+
}
|
|
13825
13853
|
|
|
13826
13854
|
// src/lib/output.ts
|
|
13827
13855
|
import chalk from "chalk";
|
|
@@ -14111,7 +14139,21 @@ Environment Variables:
|
|
|
14111
14139
|
if (!isValid) {
|
|
14112
14140
|
throw new MutagentError2("INVALID_API_KEY", "Invalid API key or endpoint", "Check your API key and try again");
|
|
14113
14141
|
}
|
|
14114
|
-
|
|
14142
|
+
const orgs = await fetchOrganizations(apiKey, endpoint);
|
|
14143
|
+
let orgId;
|
|
14144
|
+
let wsId;
|
|
14145
|
+
if (orgs.length >= 1 && orgs[0]) {
|
|
14146
|
+
orgId = orgs[0].id;
|
|
14147
|
+
const workspaces = await fetchWorkspaces(apiKey, endpoint, orgId);
|
|
14148
|
+
const defaultWs = workspaces.find((w) => w.isDefault);
|
|
14149
|
+
wsId = defaultWs?.id ?? workspaces[0]?.id;
|
|
14150
|
+
}
|
|
14151
|
+
saveFullCredentials({
|
|
14152
|
+
apiKey,
|
|
14153
|
+
endpoint,
|
|
14154
|
+
workspaceId: wsId,
|
|
14155
|
+
organizationId: orgId
|
|
14156
|
+
});
|
|
14115
14157
|
output.success("Authenticated successfully");
|
|
14116
14158
|
if (!isJson) {
|
|
14117
14159
|
output.info(`Endpoint: ${endpoint}`);
|
|
@@ -14208,8 +14250,55 @@ Environment Variables:
|
|
|
14208
14250
|
if (!isValid) {
|
|
14209
14251
|
throw new MutagentError2("INVALID_API_KEY", "Invalid API key or endpoint", "Check your API key and try again");
|
|
14210
14252
|
}
|
|
14211
|
-
|
|
14253
|
+
let selectedOrgId;
|
|
14254
|
+
let selectedOrgName;
|
|
14255
|
+
let selectedWsId;
|
|
14256
|
+
let selectedWsName;
|
|
14257
|
+
const orgs = await fetchOrganizations(apiKey, endpoint);
|
|
14258
|
+
if (orgs.length === 1 && orgs[0]) {
|
|
14259
|
+
selectedOrgId = orgs[0].id;
|
|
14260
|
+
selectedOrgName = orgs[0].name;
|
|
14261
|
+
} else if (orgs.length > 1) {
|
|
14262
|
+
const orgAnswer = await inquirer.prompt([{
|
|
14263
|
+
type: "list",
|
|
14264
|
+
name: "orgId",
|
|
14265
|
+
message: "Select organization:",
|
|
14266
|
+
choices: orgs.map((o) => ({ name: o.name, value: o.id }))
|
|
14267
|
+
}]);
|
|
14268
|
+
selectedOrgId = orgAnswer.orgId;
|
|
14269
|
+
selectedOrgName = orgs.find((o) => o.id === selectedOrgId)?.name;
|
|
14270
|
+
}
|
|
14271
|
+
if (selectedOrgId) {
|
|
14272
|
+
const workspaces = await fetchWorkspaces(apiKey, endpoint, selectedOrgId);
|
|
14273
|
+
const defaultWs = workspaces.find((w) => w.isDefault);
|
|
14274
|
+
if (workspaces.length === 1 && workspaces[0]) {
|
|
14275
|
+
selectedWsId = workspaces[0].id;
|
|
14276
|
+
selectedWsName = workspaces[0].name;
|
|
14277
|
+
} else if (defaultWs) {
|
|
14278
|
+
selectedWsId = defaultWs.id;
|
|
14279
|
+
selectedWsName = defaultWs.name;
|
|
14280
|
+
} else if (workspaces.length > 1) {
|
|
14281
|
+
const wsAnswer = await inquirer.prompt([{
|
|
14282
|
+
type: "list",
|
|
14283
|
+
name: "wsId",
|
|
14284
|
+
message: "Select workspace:",
|
|
14285
|
+
choices: workspaces.map((w) => ({ name: w.name + (w.isDefault ? " (default)" : ""), value: w.id }))
|
|
14286
|
+
}]);
|
|
14287
|
+
selectedWsId = wsAnswer.wsId;
|
|
14288
|
+
selectedWsName = workspaces.find((w) => w.id === selectedWsId)?.name;
|
|
14289
|
+
}
|
|
14290
|
+
}
|
|
14291
|
+
saveFullCredentials({
|
|
14292
|
+
apiKey,
|
|
14293
|
+
endpoint,
|
|
14294
|
+
workspaceId: selectedWsId,
|
|
14295
|
+
organizationId: selectedOrgId
|
|
14296
|
+
});
|
|
14212
14297
|
output.success("Authenticated successfully");
|
|
14298
|
+
if (selectedOrgName)
|
|
14299
|
+
output.info("Organization: " + selectedOrgName);
|
|
14300
|
+
if (selectedWsName)
|
|
14301
|
+
output.info("Workspace: " + selectedWsName);
|
|
14213
14302
|
output.info("Endpoint: " + endpoint);
|
|
14214
14303
|
}
|
|
14215
14304
|
} catch (error) {
|
|
@@ -14558,10 +14647,10 @@ Prompt Input Methods (pick one):
|
|
|
14558
14647
|
}
|
|
14559
14648
|
const client = getSDKClient();
|
|
14560
14649
|
const prompt = await client.createPrompt(data);
|
|
14561
|
-
output.success(`Created prompt: ${prompt.name}`);
|
|
14562
14650
|
if (isJson) {
|
|
14563
14651
|
output.output({ ...prompt, _links: promptLinks(prompt.id) });
|
|
14564
14652
|
} else {
|
|
14653
|
+
output.success(`Created prompt: ${prompt.name}`);
|
|
14565
14654
|
output.output(prompt);
|
|
14566
14655
|
output.info(`View: ${APP_URL}/prompts/${String(prompt.id)}`);
|
|
14567
14656
|
}
|
|
@@ -14614,8 +14703,12 @@ Examples:
|
|
|
14614
14703
|
}
|
|
14615
14704
|
const client = getSDKClient();
|
|
14616
14705
|
const prompt = await client.updatePrompt(id, data);
|
|
14617
|
-
|
|
14618
|
-
|
|
14706
|
+
if (isJson) {
|
|
14707
|
+
output.output({ ...prompt, _links: promptLinks(prompt.id) });
|
|
14708
|
+
} else {
|
|
14709
|
+
output.success(`Updated prompt: ${prompt.name}`);
|
|
14710
|
+
output.output(prompt);
|
|
14711
|
+
}
|
|
14619
14712
|
} catch (error) {
|
|
14620
14713
|
handleError(error, isJson);
|
|
14621
14714
|
}
|
|
@@ -14685,7 +14778,9 @@ ${chalk4.dim("Supported formats: JSONL, CSV")}
|
|
|
14685
14778
|
const content = readFileSync2(options.file, "utf-8");
|
|
14686
14779
|
const client = getSDKClient();
|
|
14687
14780
|
const datasetResult = await client.addDataset(promptId, content);
|
|
14688
|
-
|
|
14781
|
+
if (!isJson) {
|
|
14782
|
+
output.success(`Added dataset to prompt: ${promptId}`);
|
|
14783
|
+
}
|
|
14689
14784
|
output.output(datasetResult);
|
|
14690
14785
|
} catch (error) {
|
|
14691
14786
|
handleError(error, isJson);
|
|
@@ -14739,7 +14834,9 @@ ${chalk4.dim("Tip: Get the dataset ID from: mutagent prompts dataset list <promp
|
|
|
14739
14834
|
try {
|
|
14740
14835
|
const client = getSDKClient();
|
|
14741
14836
|
const evalRun = await client.runEvaluation(promptId, options.dataset);
|
|
14742
|
-
|
|
14837
|
+
if (!isJson) {
|
|
14838
|
+
output.success(`Started evaluation: ${String(evalRun.id)}`);
|
|
14839
|
+
}
|
|
14743
14840
|
output.output(evalRun);
|
|
14744
14841
|
} catch (error) {
|
|
14745
14842
|
handleError(error, isJson);
|
|
@@ -14780,7 +14877,9 @@ ${chalk4.dim("Tip: Monitor progress with: mutagent prompts optimize status <job-
|
|
|
14780
14877
|
try {
|
|
14781
14878
|
const client = getSDKClient();
|
|
14782
14879
|
const job = await client.startOptimization(promptId, options.dataset);
|
|
14783
|
-
|
|
14880
|
+
if (!isJson) {
|
|
14881
|
+
output.success(`Started optimization job: ${job.jobId}`);
|
|
14882
|
+
}
|
|
14784
14883
|
output.output(job);
|
|
14785
14884
|
} catch (error) {
|
|
14786
14885
|
handleError(error, isJson);
|
|
@@ -17150,5 +17249,5 @@ program.addCommand(createWorkspacesCommand());
|
|
|
17150
17249
|
program.addCommand(createProvidersCommand());
|
|
17151
17250
|
program.parse();
|
|
17152
17251
|
|
|
17153
|
-
//# debugId=
|
|
17252
|
+
//# debugId=3C8E76A3ACED3E0764756E2164756E21
|
|
17154
17253
|
//# sourceMappingURL=cli.js.map
|