olakai-cli 0.1.2 → 0.1.3
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/index.js +475 -0
- package/dist/index.js.map +1 -1
- package/package.json +11 -9
package/dist/index.js
CHANGED
|
@@ -404,6 +404,178 @@ async function deleteWorkflow(id) {
|
|
|
404
404
|
throw new Error(error.error || "Failed to delete workflow");
|
|
405
405
|
}
|
|
406
406
|
}
|
|
407
|
+
async function listKpis(options) {
|
|
408
|
+
const token = getValidToken();
|
|
409
|
+
if (!token) {
|
|
410
|
+
throw new Error("Not logged in. Run 'olakai login' first.");
|
|
411
|
+
}
|
|
412
|
+
const params = new URLSearchParams();
|
|
413
|
+
if (options?.agentId) {
|
|
414
|
+
params.set("agentId", options.agentId);
|
|
415
|
+
}
|
|
416
|
+
if (options?.includeInactive) {
|
|
417
|
+
params.set("includeInactive", "true");
|
|
418
|
+
}
|
|
419
|
+
const url = `${getBaseUrl()}/api/config/kpis${params.toString() ? `?${params}` : ""}`;
|
|
420
|
+
const response = await fetch(url, {
|
|
421
|
+
headers: {
|
|
422
|
+
Authorization: `Bearer ${token}`
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
if (!response.ok) {
|
|
426
|
+
if (response.status === 401) {
|
|
427
|
+
throw new Error("Session expired. Run 'olakai login' to authenticate again.");
|
|
428
|
+
}
|
|
429
|
+
const error = await response.json();
|
|
430
|
+
throw new Error(error.error || "Failed to list KPIs");
|
|
431
|
+
}
|
|
432
|
+
const data = await response.json();
|
|
433
|
+
return data.kpiDefinitions;
|
|
434
|
+
}
|
|
435
|
+
async function getKpi(id) {
|
|
436
|
+
const token = getValidToken();
|
|
437
|
+
if (!token) {
|
|
438
|
+
throw new Error("Not logged in. Run 'olakai login' first.");
|
|
439
|
+
}
|
|
440
|
+
const response = await fetch(`${getBaseUrl()}/api/config/kpis/${id}`, {
|
|
441
|
+
headers: {
|
|
442
|
+
Authorization: `Bearer ${token}`
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
if (!response.ok) {
|
|
446
|
+
if (response.status === 401) {
|
|
447
|
+
throw new Error("Session expired. Run 'olakai login' to authenticate again.");
|
|
448
|
+
}
|
|
449
|
+
if (response.status === 404) {
|
|
450
|
+
throw new Error("KPI definition not found");
|
|
451
|
+
}
|
|
452
|
+
const error = await response.json();
|
|
453
|
+
throw new Error(error.error || "Failed to get KPI");
|
|
454
|
+
}
|
|
455
|
+
return await response.json();
|
|
456
|
+
}
|
|
457
|
+
async function createKpi(payload) {
|
|
458
|
+
const token = getValidToken();
|
|
459
|
+
if (!token) {
|
|
460
|
+
throw new Error("Not logged in. Run 'olakai login' first.");
|
|
461
|
+
}
|
|
462
|
+
const response = await fetch(`${getBaseUrl()}/api/config/kpis`, {
|
|
463
|
+
method: "POST",
|
|
464
|
+
headers: {
|
|
465
|
+
Authorization: `Bearer ${token}`,
|
|
466
|
+
"Content-Type": "application/json"
|
|
467
|
+
},
|
|
468
|
+
body: JSON.stringify(payload)
|
|
469
|
+
});
|
|
470
|
+
if (!response.ok) {
|
|
471
|
+
if (response.status === 401) {
|
|
472
|
+
throw new Error("Session expired. Run 'olakai login' to authenticate again.");
|
|
473
|
+
}
|
|
474
|
+
if (response.status === 409) {
|
|
475
|
+
throw new Error("A KPI definition with this name already exists");
|
|
476
|
+
}
|
|
477
|
+
const error = await response.json();
|
|
478
|
+
throw new Error(error.error || "Failed to create KPI");
|
|
479
|
+
}
|
|
480
|
+
return await response.json();
|
|
481
|
+
}
|
|
482
|
+
async function updateKpi(id, payload) {
|
|
483
|
+
const token = getValidToken();
|
|
484
|
+
if (!token) {
|
|
485
|
+
throw new Error("Not logged in. Run 'olakai login' first.");
|
|
486
|
+
}
|
|
487
|
+
const response = await fetch(`${getBaseUrl()}/api/config/kpis/${id}`, {
|
|
488
|
+
method: "PUT",
|
|
489
|
+
headers: {
|
|
490
|
+
Authorization: `Bearer ${token}`,
|
|
491
|
+
"Content-Type": "application/json"
|
|
492
|
+
},
|
|
493
|
+
body: JSON.stringify(payload)
|
|
494
|
+
});
|
|
495
|
+
if (!response.ok) {
|
|
496
|
+
if (response.status === 401) {
|
|
497
|
+
throw new Error("Session expired. Run 'olakai login' to authenticate again.");
|
|
498
|
+
}
|
|
499
|
+
if (response.status === 404) {
|
|
500
|
+
throw new Error("KPI definition not found");
|
|
501
|
+
}
|
|
502
|
+
if (response.status === 409) {
|
|
503
|
+
throw new Error("A KPI definition with this name already exists");
|
|
504
|
+
}
|
|
505
|
+
const error = await response.json();
|
|
506
|
+
throw new Error(error.error || "Failed to update KPI");
|
|
507
|
+
}
|
|
508
|
+
return await response.json();
|
|
509
|
+
}
|
|
510
|
+
async function deleteKpi(id) {
|
|
511
|
+
const token = getValidToken();
|
|
512
|
+
if (!token) {
|
|
513
|
+
throw new Error("Not logged in. Run 'olakai login' first.");
|
|
514
|
+
}
|
|
515
|
+
const response = await fetch(`${getBaseUrl()}/api/config/kpis/${id}`, {
|
|
516
|
+
method: "DELETE",
|
|
517
|
+
headers: {
|
|
518
|
+
Authorization: `Bearer ${token}`
|
|
519
|
+
}
|
|
520
|
+
});
|
|
521
|
+
if (!response.ok) {
|
|
522
|
+
if (response.status === 401) {
|
|
523
|
+
throw new Error("Session expired. Run 'olakai login' to authenticate again.");
|
|
524
|
+
}
|
|
525
|
+
if (response.status === 404) {
|
|
526
|
+
throw new Error("KPI definition not found");
|
|
527
|
+
}
|
|
528
|
+
const error = await response.json();
|
|
529
|
+
throw new Error(error.error || "Failed to delete KPI");
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
async function getKpiContextVariables(agentId) {
|
|
533
|
+
const token = getValidToken();
|
|
534
|
+
if (!token) {
|
|
535
|
+
throw new Error("Not logged in. Run 'olakai login' first.");
|
|
536
|
+
}
|
|
537
|
+
const params = new URLSearchParams();
|
|
538
|
+
if (agentId) {
|
|
539
|
+
params.set("agentId", agentId);
|
|
540
|
+
}
|
|
541
|
+
const url = `${getBaseUrl()}/api/config/kpis/context-variables${params.toString() ? `?${params}` : ""}`;
|
|
542
|
+
const response = await fetch(url, {
|
|
543
|
+
headers: {
|
|
544
|
+
Authorization: `Bearer ${token}`
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
if (!response.ok) {
|
|
548
|
+
if (response.status === 401) {
|
|
549
|
+
throw new Error("Session expired. Run 'olakai login' to authenticate again.");
|
|
550
|
+
}
|
|
551
|
+
const error = await response.json();
|
|
552
|
+
throw new Error(error.error || "Failed to get context variables");
|
|
553
|
+
}
|
|
554
|
+
const data = await response.json();
|
|
555
|
+
return data.contextVariables;
|
|
556
|
+
}
|
|
557
|
+
async function validateKpiFormula(formula, agentId) {
|
|
558
|
+
const token = getValidToken();
|
|
559
|
+
if (!token) {
|
|
560
|
+
throw new Error("Not logged in. Run 'olakai login' first.");
|
|
561
|
+
}
|
|
562
|
+
const response = await fetch(`${getBaseUrl()}/api/config/kpis/validate`, {
|
|
563
|
+
method: "POST",
|
|
564
|
+
headers: {
|
|
565
|
+
Authorization: `Bearer ${token}`,
|
|
566
|
+
"Content-Type": "application/json"
|
|
567
|
+
},
|
|
568
|
+
body: JSON.stringify({ formula, agentId })
|
|
569
|
+
});
|
|
570
|
+
if (!response.ok) {
|
|
571
|
+
if (response.status === 401) {
|
|
572
|
+
throw new Error("Session expired. Run 'olakai login' to authenticate again.");
|
|
573
|
+
}
|
|
574
|
+
const error = await response.json();
|
|
575
|
+
throw new Error(error.error || "Failed to validate formula");
|
|
576
|
+
}
|
|
577
|
+
return await response.json();
|
|
578
|
+
}
|
|
407
579
|
|
|
408
580
|
// src/commands/login.ts
|
|
409
581
|
var POLL_INTERVAL_MS = 5e3;
|
|
@@ -834,6 +1006,308 @@ function registerWorkflowsCommand(program2) {
|
|
|
834
1006
|
workflows.command("delete <id>").description("Delete a workflow").option("--force", "Skip confirmation").action(deleteCommand2);
|
|
835
1007
|
}
|
|
836
1008
|
|
|
1009
|
+
// src/commands/kpis.ts
|
|
1010
|
+
var AGGREGATION_METHODS = [
|
|
1011
|
+
"SUM",
|
|
1012
|
+
"AVERAGE",
|
|
1013
|
+
"COUNT",
|
|
1014
|
+
"MIN",
|
|
1015
|
+
"MAX",
|
|
1016
|
+
"LATEST"
|
|
1017
|
+
];
|
|
1018
|
+
var CALCULATOR_IDS = ["formula", "classifier", "llm-data"];
|
|
1019
|
+
function formatKpiTable(kpis) {
|
|
1020
|
+
if (kpis.length === 0) {
|
|
1021
|
+
console.log("No KPI definitions found.");
|
|
1022
|
+
return;
|
|
1023
|
+
}
|
|
1024
|
+
const headers = ["ID", "NAME", "CALCULATOR", "AGGREGATION", "STATUS"];
|
|
1025
|
+
const rows = kpis.map((kpi) => [
|
|
1026
|
+
kpi.id.slice(0, 12) + "...",
|
|
1027
|
+
kpi.name.slice(0, 25),
|
|
1028
|
+
kpi.calculatorId,
|
|
1029
|
+
kpi.defaultAggregationMethod,
|
|
1030
|
+
kpi.isActive ? "Active" : "Inactive"
|
|
1031
|
+
]);
|
|
1032
|
+
const widths = headers.map(
|
|
1033
|
+
(h, i) => Math.max(h.length, ...rows.map((r) => r[i].length))
|
|
1034
|
+
);
|
|
1035
|
+
console.log(headers.map((h, i) => h.padEnd(widths[i])).join(" "));
|
|
1036
|
+
console.log(widths.map((w) => "-".repeat(w)).join(" "));
|
|
1037
|
+
for (const row of rows) {
|
|
1038
|
+
console.log(row.map((cell, i) => cell.padEnd(widths[i])).join(" "));
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
function formatKpiDetail(kpi) {
|
|
1042
|
+
console.log(`ID: ${kpi.id}`);
|
|
1043
|
+
console.log(`Name: ${kpi.name}`);
|
|
1044
|
+
console.log(`Description: ${kpi.description || "-"}`);
|
|
1045
|
+
console.log(`Type: ${kpi.type}`);
|
|
1046
|
+
console.log(`Category: ${kpi.category || "-"}`);
|
|
1047
|
+
console.log(`Agent ID: ${kpi.agentId || "-"}`);
|
|
1048
|
+
console.log(`Calculator: ${kpi.calculatorId}`);
|
|
1049
|
+
console.log(`Aggregation: ${kpi.defaultAggregationMethod}`);
|
|
1050
|
+
console.log(`Unit: ${kpi.unit || "-"}`);
|
|
1051
|
+
console.log(`Status: ${kpi.isActive ? "Active" : "Inactive"}`);
|
|
1052
|
+
if (kpi.calculatorParams) {
|
|
1053
|
+
console.log("");
|
|
1054
|
+
console.log("Calculator Parameters:");
|
|
1055
|
+
console.log(JSON.stringify(kpi.calculatorParams, null, 2));
|
|
1056
|
+
}
|
|
1057
|
+
if (kpi.createdAt) {
|
|
1058
|
+
console.log("");
|
|
1059
|
+
console.log(`Created: ${new Date(kpi.createdAt).toISOString()}`);
|
|
1060
|
+
}
|
|
1061
|
+
if (kpi.updatedAt) {
|
|
1062
|
+
console.log(`Updated: ${new Date(kpi.updatedAt).toISOString()}`);
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
function formatContextVariablesTable(variables) {
|
|
1066
|
+
if (variables.length === 0) {
|
|
1067
|
+
console.log("No context variables found.");
|
|
1068
|
+
return;
|
|
1069
|
+
}
|
|
1070
|
+
const headers = ["NAME", "TYPE", "SOURCE", "DESCRIPTION"];
|
|
1071
|
+
const rows = variables.map((v) => [
|
|
1072
|
+
v.name,
|
|
1073
|
+
v.type,
|
|
1074
|
+
v.source,
|
|
1075
|
+
v.description.slice(0, 50)
|
|
1076
|
+
]);
|
|
1077
|
+
const widths = headers.map(
|
|
1078
|
+
(h, i) => Math.max(h.length, ...rows.map((r) => r[i].length))
|
|
1079
|
+
);
|
|
1080
|
+
console.log(headers.map((h, i) => h.padEnd(widths[i])).join(" "));
|
|
1081
|
+
console.log(widths.map((w) => "-".repeat(w)).join(" "));
|
|
1082
|
+
for (const row of rows) {
|
|
1083
|
+
console.log(row.map((cell, i) => cell.padEnd(widths[i])).join(" "));
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
async function listCommand3(options) {
|
|
1087
|
+
try {
|
|
1088
|
+
const kpis = await listKpis({
|
|
1089
|
+
agentId: options.agentId,
|
|
1090
|
+
includeInactive: options.includeInactive
|
|
1091
|
+
});
|
|
1092
|
+
if (options.json) {
|
|
1093
|
+
console.log(JSON.stringify(kpis, null, 2));
|
|
1094
|
+
} else {
|
|
1095
|
+
formatKpiTable(kpis);
|
|
1096
|
+
}
|
|
1097
|
+
} catch (error) {
|
|
1098
|
+
console.error(
|
|
1099
|
+
`Error: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1100
|
+
);
|
|
1101
|
+
process.exit(1);
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
async function getCommand3(id, options) {
|
|
1105
|
+
try {
|
|
1106
|
+
const kpi = await getKpi(id);
|
|
1107
|
+
if (options.json) {
|
|
1108
|
+
console.log(JSON.stringify(kpi, null, 2));
|
|
1109
|
+
} else {
|
|
1110
|
+
formatKpiDetail(kpi);
|
|
1111
|
+
}
|
|
1112
|
+
} catch (error) {
|
|
1113
|
+
console.error(
|
|
1114
|
+
`Error: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1115
|
+
);
|
|
1116
|
+
process.exit(1);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
async function createCommand3(options) {
|
|
1120
|
+
try {
|
|
1121
|
+
if (!options.name) {
|
|
1122
|
+
console.error("Error: --name is required");
|
|
1123
|
+
process.exit(1);
|
|
1124
|
+
}
|
|
1125
|
+
if (!options.calculatorId) {
|
|
1126
|
+
console.error("Error: --calculator-id is required");
|
|
1127
|
+
console.error(`Valid values: ${CALCULATOR_IDS.join(", ")}`);
|
|
1128
|
+
process.exit(1);
|
|
1129
|
+
}
|
|
1130
|
+
if (!CALCULATOR_IDS.includes(options.calculatorId)) {
|
|
1131
|
+
console.error(`Error: Invalid calculator ID "${options.calculatorId}"`);
|
|
1132
|
+
console.error(`Valid values: ${CALCULATOR_IDS.join(", ")}`);
|
|
1133
|
+
process.exit(1);
|
|
1134
|
+
}
|
|
1135
|
+
let calculatorParams;
|
|
1136
|
+
if (options.calculatorId === "formula") {
|
|
1137
|
+
if (!options.formula) {
|
|
1138
|
+
console.error(
|
|
1139
|
+
"Error: --formula is required when calculator-id is 'formula'"
|
|
1140
|
+
);
|
|
1141
|
+
process.exit(1);
|
|
1142
|
+
}
|
|
1143
|
+
calculatorParams = { formula: options.formula };
|
|
1144
|
+
}
|
|
1145
|
+
let aggregation;
|
|
1146
|
+
if (options.aggregation) {
|
|
1147
|
+
const upperAggregation = options.aggregation.toUpperCase();
|
|
1148
|
+
if (!AGGREGATION_METHODS.includes(upperAggregation)) {
|
|
1149
|
+
console.error(`Error: Invalid aggregation method "${options.aggregation}"`);
|
|
1150
|
+
console.error(`Valid values: ${AGGREGATION_METHODS.join(", ")}`);
|
|
1151
|
+
process.exit(1);
|
|
1152
|
+
}
|
|
1153
|
+
aggregation = upperAggregation;
|
|
1154
|
+
}
|
|
1155
|
+
const payload = {
|
|
1156
|
+
name: options.name,
|
|
1157
|
+
calculatorId: options.calculatorId,
|
|
1158
|
+
description: options.description,
|
|
1159
|
+
type: options.type === "PREDEFINED" ? "PREDEFINED" : "USER_DEFINED",
|
|
1160
|
+
category: options.category,
|
|
1161
|
+
agentId: options.agentId,
|
|
1162
|
+
calculatorParams,
|
|
1163
|
+
unit: options.unit,
|
|
1164
|
+
defaultAggregationMethod: aggregation
|
|
1165
|
+
};
|
|
1166
|
+
const kpi = await createKpi(payload);
|
|
1167
|
+
if (options.json) {
|
|
1168
|
+
console.log(JSON.stringify(kpi, null, 2));
|
|
1169
|
+
} else {
|
|
1170
|
+
console.log("KPI definition created successfully!");
|
|
1171
|
+
console.log("");
|
|
1172
|
+
formatKpiDetail(kpi);
|
|
1173
|
+
}
|
|
1174
|
+
} catch (error) {
|
|
1175
|
+
console.error(
|
|
1176
|
+
`Error: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1177
|
+
);
|
|
1178
|
+
process.exit(1);
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
async function updateCommand3(id, options) {
|
|
1182
|
+
try {
|
|
1183
|
+
const payload = {};
|
|
1184
|
+
if (options.name !== void 0) payload.name = options.name;
|
|
1185
|
+
if (options.description !== void 0)
|
|
1186
|
+
payload.description = options.description;
|
|
1187
|
+
if (options.category !== void 0) payload.category = options.category;
|
|
1188
|
+
if (options.agentId !== void 0) payload.agentId = options.agentId;
|
|
1189
|
+
if (options.calculatorId !== void 0)
|
|
1190
|
+
payload.calculatorId = options.calculatorId;
|
|
1191
|
+
if (options.unit !== void 0) payload.unit = options.unit;
|
|
1192
|
+
if (options.active) payload.isActive = true;
|
|
1193
|
+
if (options.inactive) payload.isActive = false;
|
|
1194
|
+
if (options.formula !== void 0) {
|
|
1195
|
+
payload.calculatorParams = { formula: options.formula };
|
|
1196
|
+
}
|
|
1197
|
+
if (options.aggregation) {
|
|
1198
|
+
const upperAggregation = options.aggregation.toUpperCase();
|
|
1199
|
+
if (!AGGREGATION_METHODS.includes(upperAggregation)) {
|
|
1200
|
+
console.error(`Error: Invalid aggregation method "${options.aggregation}"`);
|
|
1201
|
+
console.error(`Valid values: ${AGGREGATION_METHODS.join(", ")}`);
|
|
1202
|
+
process.exit(1);
|
|
1203
|
+
}
|
|
1204
|
+
payload.defaultAggregationMethod = upperAggregation;
|
|
1205
|
+
}
|
|
1206
|
+
if (Object.keys(payload).length === 0) {
|
|
1207
|
+
console.error("Error: At least one field to update is required");
|
|
1208
|
+
process.exit(1);
|
|
1209
|
+
}
|
|
1210
|
+
const kpi = await updateKpi(id, payload);
|
|
1211
|
+
if (options.json) {
|
|
1212
|
+
console.log(JSON.stringify(kpi, null, 2));
|
|
1213
|
+
} else {
|
|
1214
|
+
console.log("KPI definition updated successfully!");
|
|
1215
|
+
console.log("");
|
|
1216
|
+
formatKpiDetail(kpi);
|
|
1217
|
+
}
|
|
1218
|
+
} catch (error) {
|
|
1219
|
+
console.error(
|
|
1220
|
+
`Error: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1221
|
+
);
|
|
1222
|
+
process.exit(1);
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
async function deleteCommand3(id, options) {
|
|
1226
|
+
try {
|
|
1227
|
+
if (!options.force) {
|
|
1228
|
+
console.log("Are you sure you want to delete this KPI definition?");
|
|
1229
|
+
console.log("Use --force to confirm deletion.");
|
|
1230
|
+
process.exit(1);
|
|
1231
|
+
}
|
|
1232
|
+
await deleteKpi(id);
|
|
1233
|
+
console.log("KPI definition deleted successfully.");
|
|
1234
|
+
} catch (error) {
|
|
1235
|
+
console.error(
|
|
1236
|
+
`Error: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1237
|
+
);
|
|
1238
|
+
process.exit(1);
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
async function contextVariablesCommand(options) {
|
|
1242
|
+
try {
|
|
1243
|
+
const variables = await getKpiContextVariables(options.agentId);
|
|
1244
|
+
if (options.json) {
|
|
1245
|
+
console.log(JSON.stringify(variables, null, 2));
|
|
1246
|
+
} else {
|
|
1247
|
+
console.log("Available context variables for KPI formulas:");
|
|
1248
|
+
console.log("");
|
|
1249
|
+
formatContextVariablesTable(variables);
|
|
1250
|
+
console.log("");
|
|
1251
|
+
console.log(
|
|
1252
|
+
"Use these variable names in your formula expressions, e.g.:"
|
|
1253
|
+
);
|
|
1254
|
+
console.log(" IF(PII detected, 1, 0)");
|
|
1255
|
+
console.log(" Documents count * 10");
|
|
1256
|
+
console.log(' IF(CODE detected AND SECRET detected, "high-risk", "normal")');
|
|
1257
|
+
}
|
|
1258
|
+
} catch (error) {
|
|
1259
|
+
console.error(
|
|
1260
|
+
`Error: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1261
|
+
);
|
|
1262
|
+
process.exit(1);
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
async function validateCommand(options) {
|
|
1266
|
+
try {
|
|
1267
|
+
if (!options.formula) {
|
|
1268
|
+
console.error("Error: --formula is required");
|
|
1269
|
+
process.exit(1);
|
|
1270
|
+
}
|
|
1271
|
+
const result = await validateKpiFormula(options.formula, options.agentId);
|
|
1272
|
+
if (options.json) {
|
|
1273
|
+
console.log(JSON.stringify(result, null, 2));
|
|
1274
|
+
} else {
|
|
1275
|
+
if (result.valid) {
|
|
1276
|
+
console.log("Formula is valid!");
|
|
1277
|
+
console.log(`Result type: ${result.type || "unknown"}`);
|
|
1278
|
+
} else {
|
|
1279
|
+
console.error("Formula is invalid:");
|
|
1280
|
+
console.error(` ${result.error}`);
|
|
1281
|
+
if (result.charIndex !== void 0) {
|
|
1282
|
+
console.error(` Position: character ${result.charIndex}`);
|
|
1283
|
+
}
|
|
1284
|
+
process.exit(1);
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
} catch (error) {
|
|
1288
|
+
console.error(
|
|
1289
|
+
`Error: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1290
|
+
);
|
|
1291
|
+
process.exit(1);
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
function registerKpisCommand(program2) {
|
|
1295
|
+
const kpis = program2.command("kpis").description("Manage KPI definitions");
|
|
1296
|
+
kpis.command("list").description("List all KPI definitions").option("--json", "Output as JSON").option("--agent-id <id>", "Filter by agent ID").option("--include-inactive", "Include inactive KPI definitions").action(listCommand3);
|
|
1297
|
+
kpis.command("get <id>").description("Get KPI definition details").option("--json", "Output as JSON").action(getCommand3);
|
|
1298
|
+
kpis.command("create").description("Create a new KPI definition").requiredOption("--name <name>", "KPI name").requiredOption(
|
|
1299
|
+
"--calculator-id <id>",
|
|
1300
|
+
"Calculator type: formula, classifier, or llm-data"
|
|
1301
|
+
).option("--description <description>", "KPI description").option("--type <type>", "KPI type: PREDEFINED or USER_DEFINED (default)").option("--category <category>", "KPI category for grouping").option("--agent-id <id>", "Associate KPI with a specific agent").option("--formula <formula>", "Formula expression (required for formula calculator)").option("--unit <unit>", 'Display unit (e.g., "ms", "%", "count")').option(
|
|
1302
|
+
"--aggregation <method>",
|
|
1303
|
+
"Default aggregation: SUM, AVERAGE, COUNT, MIN, MAX, LATEST (default)"
|
|
1304
|
+
).option("--json", "Output as JSON").action(createCommand3);
|
|
1305
|
+
kpis.command("update <id>").description("Update a KPI definition").option("--name <name>", "KPI name").option("--description <description>", "KPI description").option("--category <category>", "KPI category").option("--agent-id <id>", "Associate with agent").option("--calculator-id <id>", "Calculator type").option("--formula <formula>", "Formula expression").option("--unit <unit>", "Display unit").option("--aggregation <method>", "Default aggregation method").option("--active", "Set KPI as active").option("--inactive", "Set KPI as inactive").option("--json", "Output as JSON").action(updateCommand3);
|
|
1306
|
+
kpis.command("delete <id>").description("Delete a KPI definition").option("--force", "Skip confirmation").action(deleteCommand3);
|
|
1307
|
+
kpis.command("context-variables").description("List available context variables for formulas").option("--json", "Output as JSON").option("--agent-id <id>", "Include agent-specific variables").action(contextVariablesCommand);
|
|
1308
|
+
kpis.command("validate").description("Validate a KPI formula expression").requiredOption("--formula <formula>", "Formula expression to validate").option("--agent-id <id>", "Include agent-specific context").option("--json", "Output as JSON").action(validateCommand);
|
|
1309
|
+
}
|
|
1310
|
+
|
|
837
1311
|
// src/index.ts
|
|
838
1312
|
var program = new Command();
|
|
839
1313
|
program.name("olakai").description("Olakai CLI tool").version("0.1.0").option(
|
|
@@ -857,5 +1331,6 @@ program.command("logout").description("Log out from Olakai").action(logoutComman
|
|
|
857
1331
|
program.command("whoami").description("Show current logged-in user").action(whoamiCommand);
|
|
858
1332
|
registerAgentsCommand(program);
|
|
859
1333
|
registerWorkflowsCommand(program);
|
|
1334
|
+
registerKpisCommand(program);
|
|
860
1335
|
program.parse();
|
|
861
1336
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/commands/login.ts","../src/lib/config.ts","../src/lib/auth.ts","../src/lib/api.ts","../src/commands/logout.ts","../src/commands/whoami.ts","../src/commands/agents.ts","../src/commands/workflows.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Command } from \"commander\";\nimport { loginCommand } from \"./commands/login.js\";\nimport { logoutCommand } from \"./commands/logout.js\";\nimport { whoamiCommand } from \"./commands/whoami.js\";\nimport { registerAgentsCommand } from \"./commands/agents.js\";\nimport { registerWorkflowsCommand } from \"./commands/workflows.js\";\nimport {\n setEnvironment,\n isValidEnvironment,\n getValidEnvironments,\n type Environment,\n} from \"./lib/config.js\";\n\nconst program = new Command();\n\nprogram\n .name(\"olakai\")\n .description(\"Olakai CLI tool\")\n .version(\"0.1.0\")\n .option(\n \"-e, --env <environment>\",\n `Environment to use (${getValidEnvironments().join(\", \")})`,\n \"production\",\n )\n .hook(\"preAction\", (thisCommand) => {\n const options = thisCommand.opts();\n if (options.env) {\n if (!isValidEnvironment(options.env)) {\n console.error(\n `Invalid environment: ${options.env}. Valid options: ${getValidEnvironments().join(\", \")}`,\n );\n process.exit(1);\n }\n setEnvironment(options.env as Environment);\n }\n });\n\nprogram\n .command(\"login\")\n .description(\"Log in to Olakai using browser authentication\")\n .action(loginCommand);\n\nprogram\n .command(\"logout\")\n .description(\"Log out from Olakai\")\n .action(logoutCommand);\n\nprogram\n .command(\"whoami\")\n .description(\"Show current logged-in user\")\n .action(whoamiCommand);\n\n// Register subcommands for config management\nregisterAgentsCommand(program);\nregisterWorkflowsCommand(program);\n\nprogram.parse();\n","import open from \"open\";\nimport { requestDeviceCode, pollForToken, getCurrentUser } from \"../lib/api.js\";\nimport { saveToken, isTokenValid } from \"../lib/auth.js\";\nimport { getEnvironment } from \"../lib/config.js\";\n\nconst POLL_INTERVAL_MS = 5000; // 5 seconds\n\n/**\n * Login command handler\n */\nexport async function loginCommand(): Promise<void> {\n // Check if already logged in\n if (isTokenValid()) {\n try {\n const user = await getCurrentUser();\n console.log(`Already logged in as ${user.email}`);\n console.log(\"Run 'olakai logout' to log out first.\");\n return;\n } catch {\n // Token is invalid, continue with login\n }\n }\n\n console.log(`Logging in to Olakai (${getEnvironment()})...\\n`);\n\n try {\n // Request device code\n const deviceCode = await requestDeviceCode();\n\n // Display instructions\n console.log(\"To complete login, visit:\");\n console.log(`\\n ${deviceCode.verification_uri_complete}\\n`);\n console.log(`Or go to ${deviceCode.verification_uri} and enter code:`);\n console.log(`\\n ${deviceCode.user_code}\\n`);\n\n // Try to open browser\n console.log(\"Opening browser...\");\n try {\n await open(deviceCode.verification_uri_complete);\n } catch {\n console.log(\"(Could not open browser automatically)\");\n }\n\n console.log(\"\\nWaiting for authorization...\");\n\n // Poll for token\n const expiresAt = Date.now() + deviceCode.expires_in * 1000;\n\n while (Date.now() < expiresAt) {\n await sleep(POLL_INTERVAL_MS);\n\n try {\n const tokenResponse = await pollForToken(deviceCode.device_code);\n\n if (tokenResponse) {\n // Save token\n saveToken(tokenResponse.access_token, tokenResponse.expires_in);\n\n // Get user info\n const user = await getCurrentUser();\n\n console.log(`\\nLogged in as ${user.email}`);\n console.log(`Account: ${user.accountId}`);\n console.log(`Role: ${user.role}`);\n return;\n }\n\n // Still pending, show spinner\n process.stdout.write(\".\");\n } catch (error) {\n if (error instanceof Error) {\n console.error(`\\nLogin failed: ${error.message}`);\n } else {\n console.error(\"\\nLogin failed: Unknown error\");\n }\n process.exit(1);\n }\n }\n\n console.error(\"\\nLogin timed out. Please try again.\");\n process.exit(1);\n } catch (error) {\n if (error instanceof Error) {\n console.error(`Login failed: ${error.message}`);\n } else {\n console.error(\"Login failed: Unknown error\");\n }\n process.exit(1);\n }\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","export type Environment = \"production\" | \"staging\" | \"local\";\n\nconst HOSTS: Record<Environment, string> = {\n production: \"https://app.olakai.ai\",\n staging: \"https://staging.app.olakai.ai\",\n local: \"http://localhost:3000\",\n};\n\n// CLI client identifier\nexport const CLIENT_ID = \"olakai-cli\";\n\nlet currentEnvironment: Environment = \"production\";\n\n/**\n * Set the current environment\n */\nexport function setEnvironment(env: Environment): void {\n currentEnvironment = env;\n}\n\n/**\n * Get the current environment from:\n * 1. Environment variable OLAKAI_ENV\n * 2. Programmatically set value\n * 3. Default to \"production\"\n */\nexport function getEnvironment(): Environment {\n const envVar = process.env.OLAKAI_ENV as Environment | undefined;\n if (envVar && isValidEnvironment(envVar)) {\n return envVar;\n }\n return currentEnvironment;\n}\n\n/**\n * Get the API base URL for the current environment\n */\nexport function getBaseUrl(): string {\n return HOSTS[getEnvironment()];\n}\n\n/**\n * Check if a string is a valid environment\n */\nexport function isValidEnvironment(env: string): env is Environment {\n return env === \"production\" || env === \"staging\" || env === \"local\";\n}\n\n/**\n * Get list of valid environments for CLI help\n */\nexport function getValidEnvironments(): Environment[] {\n return [\"production\", \"staging\", \"local\"];\n}\n","import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport * as os from \"node:os\";\nimport { type Environment, getEnvironment } from \"./config.js\";\n\ninterface StoredCredentials {\n token: string;\n expiresAt: number; // Unix timestamp in seconds\n environment: Environment;\n}\n\n/**\n * Get the credentials file path\n */\nfunction getCredentialsPath(): string {\n const configDir = path.join(os.homedir(), \".config\", \"olakai\");\n return path.join(configDir, \"credentials.json\");\n}\n\n/**\n * Ensure the config directory exists\n */\nfunction ensureConfigDir(): void {\n const configDir = path.dirname(getCredentialsPath());\n if (!fs.existsSync(configDir)) {\n fs.mkdirSync(configDir, { recursive: true, mode: 0o700 });\n }\n}\n\n/**\n * Save an access token to disk\n */\nexport function saveToken(token: string, expiresIn: number): void {\n ensureConfigDir();\n\n const credentials: StoredCredentials = {\n token,\n expiresAt: Math.floor(Date.now() / 1000) + expiresIn,\n environment: getEnvironment(),\n };\n\n const credentialsPath = getCredentialsPath();\n fs.writeFileSync(credentialsPath, JSON.stringify(credentials, null, 2), {\n mode: 0o600, // Read/write for owner only\n });\n}\n\n/**\n * Load the stored token\n */\nexport function loadToken(): StoredCredentials | null {\n const credentialsPath = getCredentialsPath();\n\n if (!fs.existsSync(credentialsPath)) {\n return null;\n }\n\n try {\n const content = fs.readFileSync(credentialsPath, \"utf-8\");\n const credentials = JSON.parse(content) as StoredCredentials;\n return credentials;\n } catch {\n return null;\n }\n}\n\n/**\n * Clear stored credentials\n */\nexport function clearToken(): void {\n const credentialsPath = getCredentialsPath();\n\n if (fs.existsSync(credentialsPath)) {\n fs.unlinkSync(credentialsPath);\n }\n}\n\n/**\n * Check if the stored token is valid (exists and not expired)\n */\nexport function isTokenValid(): boolean {\n const credentials = loadToken();\n\n if (!credentials) {\n return false;\n }\n\n // Check if expired (with 60 second buffer)\n const now = Math.floor(Date.now() / 1000);\n if (credentials.expiresAt <= now + 60) {\n return false;\n }\n\n // Check if environment matches\n if (credentials.environment !== getEnvironment()) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Get the current valid token or null\n */\nexport function getValidToken(): string | null {\n if (!isTokenValid()) {\n return null;\n }\n\n const credentials = loadToken();\n return credentials?.token ?? null;\n}\n","import { getBaseUrl, CLIENT_ID } from \"./config.js\";\nimport { getValidToken } from \"./auth.js\";\n\nexport interface DeviceCodeResponse {\n device_code: string;\n user_code: string;\n verification_uri: string;\n verification_uri_complete: string;\n expires_in: number;\n interval: number;\n}\n\nexport interface TokenResponse {\n access_token: string;\n token_type: string;\n expires_in: number;\n}\n\nexport interface TokenErrorResponse {\n error: \"authorization_pending\" | \"expired_token\" | \"access_denied\";\n error_description?: string;\n}\n\nexport interface UserMeResponse {\n id: string;\n email: string;\n firstName: string;\n lastName: string;\n role: string;\n accountId: string;\n}\n\n// Config API Types\nexport interface AgentApiKey {\n id: string;\n key?: string; // Only present on creation\n keyMasked: string;\n isActive: boolean;\n createdAt?: string;\n}\n\nexport interface KpiDefinition {\n id: string;\n name: string;\n description: string | null;\n type: \"PREDEFINED\" | \"USER_DEFINED\";\n category: string | null;\n agentId: string | null;\n calculatorId: string;\n calculatorParams: Record<string, unknown> | null;\n unit: string | null;\n isActive: boolean;\n createdAt?: string;\n updatedAt?: string;\n}\n\nexport interface Agent {\n id: string;\n name: string;\n description: string;\n role: \"WORKER\" | \"COORDINATOR\";\n source: \"SDK\" | \"AUTOMATION_PROVIDER\";\n workflowId: string | null;\n category: string | null;\n apiKey: AgentApiKey | null;\n kpiDefinitions?: KpiDefinition[];\n workflow?: Workflow | null;\n}\n\nexport interface Workflow {\n id: string;\n name: string;\n description: string | null;\n isActive: boolean;\n agentCount: number;\n agents?: Agent[];\n createdAt?: string;\n updatedAt?: string;\n}\n\nexport interface CreateAgentPayload {\n name: string;\n description?: string;\n role?: \"WORKER\" | \"COORDINATOR\";\n workflowId?: string;\n createApiKey?: boolean;\n category?: string;\n}\n\nexport interface UpdateAgentPayload {\n name?: string;\n description?: string;\n role?: \"WORKER\" | \"COORDINATOR\";\n workflowId?: string | null;\n category?: string | null;\n}\n\nexport interface CreateWorkflowPayload {\n name: string;\n description?: string;\n}\n\nexport interface UpdateWorkflowPayload {\n name?: string;\n description?: string | null;\n isActive?: boolean;\n}\n\n/**\n * Request a device code to start the login flow\n */\nexport async function requestDeviceCode(): Promise<DeviceCodeResponse> {\n const response = await fetch(`${getBaseUrl()}/api/auth/device/code`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ client_id: CLIENT_ID }),\n });\n\n if (!response.ok) {\n const error = (await response.json()) as { error_description?: string; error?: string };\n throw new Error(error.error_description || error.error || \"Failed to request device code\");\n }\n\n return (await response.json()) as DeviceCodeResponse;\n}\n\n/**\n * Poll for token exchange\n * Returns the token response if approved, or throws an error\n */\nexport async function pollForToken(\n deviceCode: string,\n): Promise<TokenResponse | null> {\n const response = await fetch(`${getBaseUrl()}/api/auth/device/token`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n grant_type: \"urn:ietf:params:oauth:grant-type:device_code\",\n device_code: deviceCode,\n client_id: CLIENT_ID,\n }),\n });\n\n const data = (await response.json()) as TokenResponse | TokenErrorResponse;\n\n if (!response.ok) {\n if (\"error\" in data && data.error === \"authorization_pending\") {\n return null; // Still waiting for user\n }\n const errorMsg = \"error_description\" in data ? data.error_description : (\"error\" in data ? data.error : \"Token exchange failed\");\n throw new Error(errorMsg || \"Token exchange failed\");\n }\n\n return data as TokenResponse;\n}\n\n/**\n * Get current user info\n */\nexport async function getCurrentUser(): Promise<UserMeResponse> {\n const token = getValidToken();\n\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const response = await fetch(`${getBaseUrl()}/api/user/me`, {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n throw new Error(\"Failed to get user info\");\n }\n\n return (await response.json()) as UserMeResponse;\n}\n\n// ============================================\n// Config API - Agents\n// ============================================\n\n/**\n * List agents for the current account\n */\nexport async function listAgents(options?: {\n includeKpis?: boolean;\n}): Promise<Agent[]> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const params = new URLSearchParams();\n if (options?.includeKpis) {\n params.set(\"includeKpis\", \"true\");\n }\n\n const url = `${getBaseUrl()}/api/config/agents${params.toString() ? `?${params}` : \"\"}`;\n const response = await fetch(url, {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to list agents\");\n }\n\n const data = (await response.json()) as { agents: Agent[] };\n return data.agents;\n}\n\n/**\n * Get a single agent by ID\n */\nexport async function getAgent(id: string): Promise<Agent> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const response = await fetch(`${getBaseUrl()}/api/config/agents/${id}`, {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n if (response.status === 404) {\n throw new Error(\"Agent not found\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to get agent\");\n }\n\n return (await response.json()) as Agent;\n}\n\n/**\n * Create a new agent\n */\nexport async function createAgent(payload: CreateAgentPayload): Promise<Agent> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const response = await fetch(`${getBaseUrl()}/api/config/agents`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${token}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n if (response.status === 409) {\n throw new Error(\"An agent with this name already exists\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to create agent\");\n }\n\n return (await response.json()) as Agent;\n}\n\n/**\n * Update an agent\n */\nexport async function updateAgent(\n id: string,\n payload: UpdateAgentPayload,\n): Promise<Agent> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const response = await fetch(`${getBaseUrl()}/api/config/agents/${id}`, {\n method: \"PUT\",\n headers: {\n Authorization: `Bearer ${token}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n if (response.status === 404) {\n throw new Error(\"Agent not found\");\n }\n if (response.status === 409) {\n throw new Error(\"An agent with this name already exists\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to update agent\");\n }\n\n return (await response.json()) as Agent;\n}\n\n/**\n * Delete an agent\n */\nexport async function deleteAgent(id: string): Promise<void> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const response = await fetch(`${getBaseUrl()}/api/config/agents/${id}`, {\n method: \"DELETE\",\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n if (response.status === 404) {\n throw new Error(\"Agent not found\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to delete agent\");\n }\n}\n\n// ============================================\n// Config API - Workflows\n// ============================================\n\n/**\n * List workflows for the current account\n */\nexport async function listWorkflows(options?: {\n includeAgents?: boolean;\n includeInactive?: boolean;\n}): Promise<Workflow[]> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const params = new URLSearchParams();\n if (options?.includeAgents) {\n params.set(\"includeAgents\", \"true\");\n }\n if (options?.includeInactive) {\n params.set(\"includeInactive\", \"true\");\n }\n\n const url = `${getBaseUrl()}/api/config/workflows${params.toString() ? `?${params}` : \"\"}`;\n const response = await fetch(url, {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to list workflows\");\n }\n\n const data = (await response.json()) as { workflows: Workflow[] };\n return data.workflows;\n}\n\n/**\n * Get a single workflow by ID\n */\nexport async function getWorkflow(id: string): Promise<Workflow> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const response = await fetch(`${getBaseUrl()}/api/config/workflows/${id}`, {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n if (response.status === 404) {\n throw new Error(\"Workflow not found\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to get workflow\");\n }\n\n return (await response.json()) as Workflow;\n}\n\n/**\n * Create a new workflow\n */\nexport async function createWorkflow(\n payload: CreateWorkflowPayload,\n): Promise<Workflow> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const response = await fetch(`${getBaseUrl()}/api/config/workflows`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${token}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n if (response.status === 409) {\n throw new Error(\"A workflow with this name already exists\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to create workflow\");\n }\n\n return (await response.json()) as Workflow;\n}\n\n/**\n * Update a workflow\n */\nexport async function updateWorkflow(\n id: string,\n payload: UpdateWorkflowPayload,\n): Promise<Workflow> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const response = await fetch(`${getBaseUrl()}/api/config/workflows/${id}`, {\n method: \"PUT\",\n headers: {\n Authorization: `Bearer ${token}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n if (response.status === 404) {\n throw new Error(\"Workflow not found\");\n }\n if (response.status === 409) {\n throw new Error(\"A workflow with this name already exists\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to update workflow\");\n }\n\n return (await response.json()) as Workflow;\n}\n\n/**\n * Delete a workflow\n */\nexport async function deleteWorkflow(id: string): Promise<void> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const response = await fetch(`${getBaseUrl()}/api/config/workflows/${id}`, {\n method: \"DELETE\",\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n if (response.status === 404) {\n throw new Error(\"Workflow not found\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to delete workflow\");\n }\n}\n","import { clearToken, isTokenValid } from \"../lib/auth.js\";\n\n/**\n * Logout command handler\n */\nexport function logoutCommand(): void {\n if (!isTokenValid()) {\n console.log(\"Not currently logged in.\");\n return;\n }\n\n clearToken();\n console.log(\"Logged out successfully.\");\n}\n","import { getCurrentUser } from \"../lib/api.js\";\nimport { isTokenValid } from \"../lib/auth.js\";\nimport { getEnvironment } from \"../lib/config.js\";\n\n/**\n * Whoami command handler\n */\nexport async function whoamiCommand(): Promise<void> {\n if (!isTokenValid()) {\n console.log(\"Not logged in. Run 'olakai login' to authenticate.\");\n process.exit(1);\n }\n\n try {\n const user = await getCurrentUser();\n\n console.log(`Email: ${user.email}`);\n console.log(`Name: ${user.firstName} ${user.lastName}`);\n console.log(`Role: ${user.role}`);\n console.log(`Account ID: ${user.accountId}`);\n console.log(`Environment: ${getEnvironment()}`);\n } catch (error) {\n if (error instanceof Error) {\n console.error(`Error: ${error.message}`);\n } else {\n console.error(\"Failed to get user info\");\n }\n process.exit(1);\n }\n}\n","import { Command } from \"commander\";\nimport {\n listAgents,\n getAgent,\n createAgent,\n updateAgent,\n deleteAgent,\n type Agent,\n} from \"../lib/api.js\";\n\nfunction formatAgentTable(agents: Agent[]): void {\n if (agents.length === 0) {\n console.log(\"No agents found.\");\n return;\n }\n\n // Calculate column widths\n const headers = [\"ID\", \"NAME\", \"ROLE\", \"WORKFLOW\", \"API KEY\"];\n const rows = agents.map((agent) => [\n agent.id.slice(0, 12) + \"...\",\n agent.name.slice(0, 30),\n agent.role,\n agent.workflowId ? agent.workflowId.slice(0, 12) + \"...\" : \"-\",\n agent.apiKey ? (agent.apiKey.isActive ? \"Active\" : \"Inactive\") : \"None\",\n ]);\n\n const widths = headers.map((h, i) =>\n Math.max(h.length, ...rows.map((r) => r[i].length))\n );\n\n // Print header\n console.log(headers.map((h, i) => h.padEnd(widths[i])).join(\" \"));\n console.log(widths.map((w) => \"-\".repeat(w)).join(\" \"));\n\n // Print rows\n for (const row of rows) {\n console.log(row.map((cell, i) => cell.padEnd(widths[i])).join(\" \"));\n }\n}\n\nfunction formatAgentDetail(agent: Agent): void {\n console.log(`ID: ${agent.id}`);\n console.log(`Name: ${agent.name}`);\n console.log(`Description: ${agent.description || \"-\"}`);\n console.log(`Role: ${agent.role}`);\n console.log(`Source: ${agent.source}`);\n console.log(`Category: ${agent.category || \"-\"}`);\n console.log(`Workflow ID: ${agent.workflowId || \"-\"}`);\n\n if (agent.workflow) {\n console.log(`Workflow: ${agent.workflow.name}`);\n }\n\n console.log(\"\");\n console.log(\"API Key:\");\n if (agent.apiKey) {\n console.log(` ID: ${agent.apiKey.id}`);\n if (agent.apiKey.key) {\n console.log(` Key: ${agent.apiKey.key}`);\n } else {\n console.log(` Key: ${agent.apiKey.keyMasked}`);\n }\n console.log(` Status: ${agent.apiKey.isActive ? \"Active\" : \"Inactive\"}`);\n } else {\n console.log(\" None\");\n }\n\n if (agent.kpiDefinitions && agent.kpiDefinitions.length > 0) {\n console.log(\"\");\n console.log(\"KPI Definitions:\");\n for (const kpi of agent.kpiDefinitions) {\n console.log(` - ${kpi.name} (${kpi.type})`);\n }\n }\n}\n\nasync function listCommand(options: {\n json?: boolean;\n includeKpis?: boolean;\n}): Promise<void> {\n try {\n const agents = await listAgents({ includeKpis: options.includeKpis });\n\n if (options.json) {\n console.log(JSON.stringify(agents, null, 2));\n } else {\n formatAgentTable(agents);\n }\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nasync function getCommand(id: string, options: { json?: boolean }): Promise<void> {\n try {\n const agent = await getAgent(id);\n\n if (options.json) {\n console.log(JSON.stringify(agent, null, 2));\n } else {\n formatAgentDetail(agent);\n }\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nasync function createCommand(options: {\n name: string;\n description?: string;\n role?: string;\n workflow?: string;\n withApiKey?: boolean;\n category?: string;\n json?: boolean;\n}): Promise<void> {\n try {\n if (!options.name) {\n console.error(\"Error: --name is required\");\n process.exit(1);\n }\n\n const agent = await createAgent({\n name: options.name,\n description: options.description || \"\",\n role: (options.role as \"WORKER\" | \"COORDINATOR\") || \"WORKER\",\n workflowId: options.workflow,\n createApiKey: options.withApiKey || false,\n category: options.category,\n });\n\n if (options.json) {\n console.log(JSON.stringify(agent, null, 2));\n } else {\n console.log(\"Agent created successfully!\");\n console.log(\"\");\n formatAgentDetail(agent);\n\n if (agent.apiKey?.key) {\n console.log(\"\");\n console.log(\n \"IMPORTANT: Save your API key now. It will not be shown again.\"\n );\n }\n }\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nasync function updateCommand(\n id: string,\n options: {\n name?: string;\n description?: string;\n role?: string;\n workflow?: string;\n category?: string;\n json?: boolean;\n }\n): Promise<void> {\n try {\n const payload: {\n name?: string;\n description?: string;\n role?: \"WORKER\" | \"COORDINATOR\";\n workflowId?: string | null;\n category?: string | null;\n } = {};\n\n if (options.name !== undefined) payload.name = options.name;\n if (options.description !== undefined)\n payload.description = options.description;\n if (options.role !== undefined)\n payload.role = options.role as \"WORKER\" | \"COORDINATOR\";\n if (options.workflow !== undefined) payload.workflowId = options.workflow;\n if (options.category !== undefined) payload.category = options.category;\n\n if (Object.keys(payload).length === 0) {\n console.error(\"Error: At least one field to update is required\");\n process.exit(1);\n }\n\n const agent = await updateAgent(id, payload);\n\n if (options.json) {\n console.log(JSON.stringify(agent, null, 2));\n } else {\n console.log(\"Agent updated successfully!\");\n console.log(\"\");\n formatAgentDetail(agent);\n }\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nasync function deleteCommand(\n id: string,\n options: { force?: boolean }\n): Promise<void> {\n try {\n if (!options.force) {\n // In a real CLI, we'd use readline for confirmation\n // For now, require --force flag\n console.log(\"Are you sure you want to delete this agent?\");\n console.log(\"Use --force to confirm deletion.\");\n process.exit(1);\n }\n\n await deleteAgent(id);\n console.log(\"Agent deleted successfully.\");\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nexport function registerAgentsCommand(program: Command): void {\n const agents = program\n .command(\"agents\")\n .description(\"Manage agents\");\n\n agents\n .command(\"list\")\n .description(\"List all agents\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--include-kpis\", \"Include KPI definitions\")\n .action(listCommand);\n\n agents\n .command(\"get <id>\")\n .description(\"Get agent details\")\n .option(\"--json\", \"Output as JSON\")\n .action(getCommand);\n\n agents\n .command(\"create\")\n .description(\"Create a new agent\")\n .requiredOption(\"--name <name>\", \"Agent name\")\n .option(\"--description <description>\", \"Agent description\")\n .option(\"--role <role>\", \"Agent role (WORKER or COORDINATOR)\", \"WORKER\")\n .option(\"--workflow <id>\", \"Workflow ID to assign\")\n .option(\"--with-api-key\", \"Create an API key for this agent\")\n .option(\"--category <category>\", \"Agent category\")\n .option(\"--json\", \"Output as JSON\")\n .action(createCommand);\n\n agents\n .command(\"update <id>\")\n .description(\"Update an agent\")\n .option(\"--name <name>\", \"Agent name\")\n .option(\"--description <description>\", \"Agent description\")\n .option(\"--role <role>\", \"Agent role (WORKER or COORDINATOR)\")\n .option(\"--workflow <id>\", \"Workflow ID to assign\")\n .option(\"--category <category>\", \"Agent category\")\n .option(\"--json\", \"Output as JSON\")\n .action(updateCommand);\n\n agents\n .command(\"delete <id>\")\n .description(\"Delete an agent\")\n .option(\"--force\", \"Skip confirmation\")\n .action(deleteCommand);\n}\n","import { Command } from \"commander\";\nimport {\n listWorkflows,\n getWorkflow,\n createWorkflow,\n updateWorkflow,\n deleteWorkflow,\n type Workflow,\n} from \"../lib/api.js\";\n\nfunction formatWorkflowTable(workflows: Workflow[]): void {\n if (workflows.length === 0) {\n console.log(\"No workflows found.\");\n return;\n }\n\n // Calculate column widths\n const headers = [\"ID\", \"NAME\", \"AGENTS\", \"STATUS\"];\n const rows = workflows.map((wf) => [\n wf.id.slice(0, 12) + \"...\",\n wf.name.slice(0, 30),\n wf.agentCount.toString(),\n wf.isActive ? \"Active\" : \"Inactive\",\n ]);\n\n const widths = headers.map((h, i) =>\n Math.max(h.length, ...rows.map((r) => r[i].length))\n );\n\n // Print header\n console.log(headers.map((h, i) => h.padEnd(widths[i])).join(\" \"));\n console.log(widths.map((w) => \"-\".repeat(w)).join(\" \"));\n\n // Print rows\n for (const row of rows) {\n console.log(row.map((cell, i) => cell.padEnd(widths[i])).join(\" \"));\n }\n}\n\nfunction formatWorkflowDetail(workflow: Workflow): void {\n console.log(`ID: ${workflow.id}`);\n console.log(`Name: ${workflow.name}`);\n console.log(`Description: ${workflow.description || \"-\"}`);\n console.log(`Status: ${workflow.isActive ? \"Active\" : \"Inactive\"}`);\n console.log(`Agents: ${workflow.agentCount}`);\n if (workflow.createdAt) {\n console.log(`Created: ${new Date(workflow.createdAt).toISOString()}`);\n }\n if (workflow.updatedAt) {\n console.log(`Updated: ${new Date(workflow.updatedAt).toISOString()}`);\n }\n\n if (workflow.agents && workflow.agents.length > 0) {\n console.log(\"\");\n console.log(\"Agents:\");\n for (const agent of workflow.agents) {\n const apiKeyStatus = agent.apiKey\n ? agent.apiKey.isActive\n ? \"API Key: Active\"\n : \"API Key: Inactive\"\n : \"No API Key\";\n console.log(` - ${agent.name} (${agent.role}) - ${apiKeyStatus}`);\n }\n }\n}\n\nasync function listCommand(options: {\n json?: boolean;\n includeAgents?: boolean;\n includeInactive?: boolean;\n}): Promise<void> {\n try {\n const workflows = await listWorkflows({\n includeAgents: options.includeAgents,\n includeInactive: options.includeInactive,\n });\n\n if (options.json) {\n console.log(JSON.stringify(workflows, null, 2));\n } else {\n formatWorkflowTable(workflows);\n }\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nasync function getCommand(id: string, options: { json?: boolean }): Promise<void> {\n try {\n const workflow = await getWorkflow(id);\n\n if (options.json) {\n console.log(JSON.stringify(workflow, null, 2));\n } else {\n formatWorkflowDetail(workflow);\n }\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nasync function createCommand(options: {\n name: string;\n description?: string;\n json?: boolean;\n}): Promise<void> {\n try {\n if (!options.name) {\n console.error(\"Error: --name is required\");\n process.exit(1);\n }\n\n const workflow = await createWorkflow({\n name: options.name,\n description: options.description,\n });\n\n if (options.json) {\n console.log(JSON.stringify(workflow, null, 2));\n } else {\n console.log(\"Workflow created successfully!\");\n console.log(\"\");\n formatWorkflowDetail(workflow);\n }\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nasync function updateCommand(\n id: string,\n options: {\n name?: string;\n description?: string;\n active?: boolean;\n inactive?: boolean;\n json?: boolean;\n }\n): Promise<void> {\n try {\n const payload: {\n name?: string;\n description?: string | null;\n isActive?: boolean;\n } = {};\n\n if (options.name !== undefined) payload.name = options.name;\n if (options.description !== undefined)\n payload.description = options.description;\n if (options.active) payload.isActive = true;\n if (options.inactive) payload.isActive = false;\n\n if (Object.keys(payload).length === 0) {\n console.error(\"Error: At least one field to update is required\");\n process.exit(1);\n }\n\n const workflow = await updateWorkflow(id, payload);\n\n if (options.json) {\n console.log(JSON.stringify(workflow, null, 2));\n } else {\n console.log(\"Workflow updated successfully!\");\n console.log(\"\");\n formatWorkflowDetail(workflow);\n }\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nasync function deleteCommand(\n id: string,\n options: { force?: boolean }\n): Promise<void> {\n try {\n if (!options.force) {\n // In a real CLI, we'd use readline for confirmation\n // For now, require --force flag\n console.log(\"Are you sure you want to delete this workflow?\");\n console.log(\"Use --force to confirm deletion.\");\n process.exit(1);\n }\n\n await deleteWorkflow(id);\n console.log(\"Workflow deleted successfully.\");\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nexport function registerWorkflowsCommand(program: Command): void {\n const workflows = program\n .command(\"workflows\")\n .description(\"Manage workflows\");\n\n workflows\n .command(\"list\")\n .description(\"List all workflows\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--include-agents\", \"Include agent details\")\n .option(\"--include-inactive\", \"Include inactive workflows\")\n .action(listCommand);\n\n workflows\n .command(\"get <id>\")\n .description(\"Get workflow details\")\n .option(\"--json\", \"Output as JSON\")\n .action(getCommand);\n\n workflows\n .command(\"create\")\n .description(\"Create a new workflow\")\n .requiredOption(\"--name <name>\", \"Workflow name\")\n .option(\"--description <description>\", \"Workflow description\")\n .option(\"--json\", \"Output as JSON\")\n .action(createCommand);\n\n workflows\n .command(\"update <id>\")\n .description(\"Update a workflow\")\n .option(\"--name <name>\", \"Workflow name\")\n .option(\"--description <description>\", \"Workflow description\")\n .option(\"--active\", \"Set workflow as active\")\n .option(\"--inactive\", \"Set workflow as inactive\")\n .option(\"--json\", \"Output as JSON\")\n .action(updateCommand);\n\n workflows\n .command(\"delete <id>\")\n .description(\"Delete a workflow\")\n .option(\"--force\", \"Skip confirmation\")\n .action(deleteCommand);\n}\n"],"mappings":";;;AAEA,SAAS,eAAe;;;ACFxB,OAAO,UAAU;;;ACEjB,IAAM,QAAqC;AAAA,EACzC,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,OAAO;AACT;AAGO,IAAM,YAAY;AAEzB,IAAI,qBAAkC;AAK/B,SAAS,eAAe,KAAwB;AACrD,uBAAqB;AACvB;AAQO,SAAS,iBAA8B;AAC5C,QAAM,SAAS,QAAQ,IAAI;AAC3B,MAAI,UAAU,mBAAmB,MAAM,GAAG;AACxC,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAKO,SAAS,aA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EAC3C,OAAO,cAAc,0BAA0B,EAC/C,OAAO,UAAU,gBAAgB,EACjC,OAAOC,cAAa;AAEvB,YACG,QAAQ,aAAa,EACrB,YAAY,mBAAmB,EAC/B,OAAO,WAAW,mBAAmB,EACrC,OAAOC,cAAa;AACzB;;;ARzOA,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,QAAQ,EACb,YAAY,iBAAiB,EAC7B,QAAQ,OAAO,EACf;AAAA,EACC;AAAA,EACA,uBAAuB,qBAAqB,EAAE,KAAK,IAAI,CAAC;AAAA,EACxD;AACF,EACC,KAAK,aAAa,CAAC,gBAAgB;AAClC,QAAM,UAAU,YAAY,KAAK;AACjC,MAAI,QAAQ,KAAK;AACf,QAAI,CAAC,mBAAmB,QAAQ,GAAG,GAAG;AACpC,cAAQ;AAAA,QACN,wBAAwB,QAAQ,GAAG,oBAAoB,qBAAqB,EAAE,KAAK,IAAI,CAAC;AAAA,MAC1F;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,mBAAe,QAAQ,GAAkB;AAAA,EAC3C;AACF,CAAC;AAEH,QACG,QAAQ,OAAO,EACf,YAAY,+CAA+C,EAC3D,OAAO,YAAY;AAEtB,QACG,QAAQ,QAAQ,EAChB,YAAY,qBAAqB,EACjC,OAAO,aAAa;AAEvB,QACG,QAAQ,QAAQ,EAChB,YAAY,6BAA6B,EACzC,OAAO,aAAa;AAGvB,sBAAsB,OAAO;AAC7B,yBAAyB,OAAO;AAEhC,QAAQ,MAAM;","names":["program","listCommand","getCommand","createCommand","updateCommand","deleteCommand","program"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/commands/login.ts","../src/lib/config.ts","../src/lib/auth.ts","../src/lib/api.ts","../src/commands/logout.ts","../src/commands/whoami.ts","../src/commands/agents.ts","../src/commands/workflows.ts","../src/commands/kpis.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Command } from \"commander\";\nimport { loginCommand } from \"./commands/login.js\";\nimport { logoutCommand } from \"./commands/logout.js\";\nimport { whoamiCommand } from \"./commands/whoami.js\";\nimport { registerAgentsCommand } from \"./commands/agents.js\";\nimport { registerWorkflowsCommand } from \"./commands/workflows.js\";\nimport { registerKpisCommand } from \"./commands/kpis.js\";\nimport {\n setEnvironment,\n isValidEnvironment,\n getValidEnvironments,\n type Environment,\n} from \"./lib/config.js\";\n\nconst program = new Command();\n\nprogram\n .name(\"olakai\")\n .description(\"Olakai CLI tool\")\n .version(\"0.1.0\")\n .option(\n \"-e, --env <environment>\",\n `Environment to use (${getValidEnvironments().join(\", \")})`,\n \"production\",\n )\n .hook(\"preAction\", (thisCommand) => {\n const options = thisCommand.opts();\n if (options.env) {\n if (!isValidEnvironment(options.env)) {\n console.error(\n `Invalid environment: ${options.env}. Valid options: ${getValidEnvironments().join(\", \")}`,\n );\n process.exit(1);\n }\n setEnvironment(options.env as Environment);\n }\n });\n\nprogram\n .command(\"login\")\n .description(\"Log in to Olakai using browser authentication\")\n .action(loginCommand);\n\nprogram\n .command(\"logout\")\n .description(\"Log out from Olakai\")\n .action(logoutCommand);\n\nprogram\n .command(\"whoami\")\n .description(\"Show current logged-in user\")\n .action(whoamiCommand);\n\n// Register subcommands for config management\nregisterAgentsCommand(program);\nregisterWorkflowsCommand(program);\nregisterKpisCommand(program);\n\nprogram.parse();\n","import open from \"open\";\nimport { requestDeviceCode, pollForToken, getCurrentUser } from \"../lib/api.js\";\nimport { saveToken, isTokenValid } from \"../lib/auth.js\";\nimport { getEnvironment } from \"../lib/config.js\";\n\nconst POLL_INTERVAL_MS = 5000; // 5 seconds\n\n/**\n * Login command handler\n */\nexport async function loginCommand(): Promise<void> {\n // Check if already logged in\n if (isTokenValid()) {\n try {\n const user = await getCurrentUser();\n console.log(`Already logged in as ${user.email}`);\n console.log(\"Run 'olakai logout' to log out first.\");\n return;\n } catch {\n // Token is invalid, continue with login\n }\n }\n\n console.log(`Logging in to Olakai (${getEnvironment()})...\\n`);\n\n try {\n // Request device code\n const deviceCode = await requestDeviceCode();\n\n // Display instructions\n console.log(\"To complete login, visit:\");\n console.log(`\\n ${deviceCode.verification_uri_complete}\\n`);\n console.log(`Or go to ${deviceCode.verification_uri} and enter code:`);\n console.log(`\\n ${deviceCode.user_code}\\n`);\n\n // Try to open browser\n console.log(\"Opening browser...\");\n try {\n await open(deviceCode.verification_uri_complete);\n } catch {\n console.log(\"(Could not open browser automatically)\");\n }\n\n console.log(\"\\nWaiting for authorization...\");\n\n // Poll for token\n const expiresAt = Date.now() + deviceCode.expires_in * 1000;\n\n while (Date.now() < expiresAt) {\n await sleep(POLL_INTERVAL_MS);\n\n try {\n const tokenResponse = await pollForToken(deviceCode.device_code);\n\n if (tokenResponse) {\n // Save token\n saveToken(tokenResponse.access_token, tokenResponse.expires_in);\n\n // Get user info\n const user = await getCurrentUser();\n\n console.log(`\\nLogged in as ${user.email}`);\n console.log(`Account: ${user.accountId}`);\n console.log(`Role: ${user.role}`);\n return;\n }\n\n // Still pending, show spinner\n process.stdout.write(\".\");\n } catch (error) {\n if (error instanceof Error) {\n console.error(`\\nLogin failed: ${error.message}`);\n } else {\n console.error(\"\\nLogin failed: Unknown error\");\n }\n process.exit(1);\n }\n }\n\n console.error(\"\\nLogin timed out. Please try again.\");\n process.exit(1);\n } catch (error) {\n if (error instanceof Error) {\n console.error(`Login failed: ${error.message}`);\n } else {\n console.error(\"Login failed: Unknown error\");\n }\n process.exit(1);\n }\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","export type Environment = \"production\" | \"staging\" | \"local\";\n\nconst HOSTS: Record<Environment, string> = {\n production: \"https://app.olakai.ai\",\n staging: \"https://staging.app.olakai.ai\",\n local: \"http://localhost:3000\",\n};\n\n// CLI client identifier\nexport const CLIENT_ID = \"olakai-cli\";\n\nlet currentEnvironment: Environment = \"production\";\n\n/**\n * Set the current environment\n */\nexport function setEnvironment(env: Environment): void {\n currentEnvironment = env;\n}\n\n/**\n * Get the current environment from:\n * 1. Environment variable OLAKAI_ENV\n * 2. Programmatically set value\n * 3. Default to \"production\"\n */\nexport function getEnvironment(): Environment {\n const envVar = process.env.OLAKAI_ENV as Environment | undefined;\n if (envVar && isValidEnvironment(envVar)) {\n return envVar;\n }\n return currentEnvironment;\n}\n\n/**\n * Get the API base URL for the current environment\n */\nexport function getBaseUrl(): string {\n return HOSTS[getEnvironment()];\n}\n\n/**\n * Check if a string is a valid environment\n */\nexport function isValidEnvironment(env: string): env is Environment {\n return env === \"production\" || env === \"staging\" || env === \"local\";\n}\n\n/**\n * Get list of valid environments for CLI help\n */\nexport function getValidEnvironments(): Environment[] {\n return [\"production\", \"staging\", \"local\"];\n}\n","import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport * as os from \"node:os\";\nimport { type Environment, getEnvironment } from \"./config.js\";\n\ninterface StoredCredentials {\n token: string;\n expiresAt: number; // Unix timestamp in seconds\n environment: Environment;\n}\n\n/**\n * Get the credentials file path\n */\nfunction getCredentialsPath(): string {\n const configDir = path.join(os.homedir(), \".config\", \"olakai\");\n return path.join(configDir, \"credentials.json\");\n}\n\n/**\n * Ensure the config directory exists\n */\nfunction ensureConfigDir(): void {\n const configDir = path.dirname(getCredentialsPath());\n if (!fs.existsSync(configDir)) {\n fs.mkdirSync(configDir, { recursive: true, mode: 0o700 });\n }\n}\n\n/**\n * Save an access token to disk\n */\nexport function saveToken(token: string, expiresIn: number): void {\n ensureConfigDir();\n\n const credentials: StoredCredentials = {\n token,\n expiresAt: Math.floor(Date.now() / 1000) + expiresIn,\n environment: getEnvironment(),\n };\n\n const credentialsPath = getCredentialsPath();\n fs.writeFileSync(credentialsPath, JSON.stringify(credentials, null, 2), {\n mode: 0o600, // Read/write for owner only\n });\n}\n\n/**\n * Load the stored token\n */\nexport function loadToken(): StoredCredentials | null {\n const credentialsPath = getCredentialsPath();\n\n if (!fs.existsSync(credentialsPath)) {\n return null;\n }\n\n try {\n const content = fs.readFileSync(credentialsPath, \"utf-8\");\n const credentials = JSON.parse(content) as StoredCredentials;\n return credentials;\n } catch {\n return null;\n }\n}\n\n/**\n * Clear stored credentials\n */\nexport function clearToken(): void {\n const credentialsPath = getCredentialsPath();\n\n if (fs.existsSync(credentialsPath)) {\n fs.unlinkSync(credentialsPath);\n }\n}\n\n/**\n * Check if the stored token is valid (exists and not expired)\n */\nexport function isTokenValid(): boolean {\n const credentials = loadToken();\n\n if (!credentials) {\n return false;\n }\n\n // Check if expired (with 60 second buffer)\n const now = Math.floor(Date.now() / 1000);\n if (credentials.expiresAt <= now + 60) {\n return false;\n }\n\n // Check if environment matches\n if (credentials.environment !== getEnvironment()) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Get the current valid token or null\n */\nexport function getValidToken(): string | null {\n if (!isTokenValid()) {\n return null;\n }\n\n const credentials = loadToken();\n return credentials?.token ?? null;\n}\n","import { getBaseUrl, CLIENT_ID } from \"./config.js\";\nimport { getValidToken } from \"./auth.js\";\n\nexport interface DeviceCodeResponse {\n device_code: string;\n user_code: string;\n verification_uri: string;\n verification_uri_complete: string;\n expires_in: number;\n interval: number;\n}\n\nexport interface TokenResponse {\n access_token: string;\n token_type: string;\n expires_in: number;\n}\n\nexport interface TokenErrorResponse {\n error: \"authorization_pending\" | \"expired_token\" | \"access_denied\";\n error_description?: string;\n}\n\nexport interface UserMeResponse {\n id: string;\n email: string;\n firstName: string;\n lastName: string;\n role: string;\n accountId: string;\n}\n\n// Config API Types\nexport interface AgentApiKey {\n id: string;\n key?: string; // Only present on creation\n keyMasked: string;\n isActive: boolean;\n createdAt?: string;\n}\n\nexport type DefaultAggregationMethod =\n | \"SUM\"\n | \"AVERAGE\"\n | \"COUNT\"\n | \"MIN\"\n | \"MAX\"\n | \"LATEST\";\n\nexport interface KpiDefinition {\n id: string;\n name: string;\n description: string | null;\n type: \"PREDEFINED\" | \"USER_DEFINED\";\n category: string | null;\n agentId: string | null;\n calculatorId: string;\n calculatorParams: Record<string, unknown> | null;\n unit: string | null;\n defaultAggregationMethod: DefaultAggregationMethod;\n isActive: boolean;\n createdAt?: string;\n updatedAt?: string;\n}\n\nexport interface CreateKpiPayload {\n name: string;\n description?: string;\n type?: \"PREDEFINED\" | \"USER_DEFINED\";\n category?: string;\n agentId?: string;\n calculatorId: string;\n calculatorParams?: Record<string, unknown>;\n unit?: string;\n defaultAggregationMethod?: DefaultAggregationMethod;\n}\n\nexport interface UpdateKpiPayload {\n name?: string;\n description?: string | null;\n type?: \"PREDEFINED\" | \"USER_DEFINED\";\n category?: string | null;\n agentId?: string | null;\n calculatorId?: string;\n calculatorParams?: Record<string, unknown>;\n unit?: string | null;\n defaultAggregationMethod?: DefaultAggregationMethod;\n isActive?: boolean;\n}\n\nexport interface ContextVariable {\n name: string;\n description: string;\n type: \"string\" | \"number\" | \"boolean\";\n sampleValue?: string | number | boolean;\n source: \"shared\" | \"custom\";\n}\n\nexport interface FormulaValidationResult {\n valid: boolean;\n error?: string;\n type?: string | null;\n charIndex?: number;\n parsedFormula?: unknown;\n}\n\nexport interface Agent {\n id: string;\n name: string;\n description: string;\n role: \"WORKER\" | \"COORDINATOR\";\n source: \"SDK\" | \"AUTOMATION_PROVIDER\";\n workflowId: string | null;\n category: string | null;\n apiKey: AgentApiKey | null;\n kpiDefinitions?: KpiDefinition[];\n workflow?: Workflow | null;\n}\n\nexport interface Workflow {\n id: string;\n name: string;\n description: string | null;\n isActive: boolean;\n agentCount: number;\n agents?: Agent[];\n createdAt?: string;\n updatedAt?: string;\n}\n\nexport interface CreateAgentPayload {\n name: string;\n description?: string;\n role?: \"WORKER\" | \"COORDINATOR\";\n workflowId?: string;\n createApiKey?: boolean;\n category?: string;\n}\n\nexport interface UpdateAgentPayload {\n name?: string;\n description?: string;\n role?: \"WORKER\" | \"COORDINATOR\";\n workflowId?: string | null;\n category?: string | null;\n}\n\nexport interface CreateWorkflowPayload {\n name: string;\n description?: string;\n}\n\nexport interface UpdateWorkflowPayload {\n name?: string;\n description?: string | null;\n isActive?: boolean;\n}\n\n/**\n * Request a device code to start the login flow\n */\nexport async function requestDeviceCode(): Promise<DeviceCodeResponse> {\n const response = await fetch(`${getBaseUrl()}/api/auth/device/code`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ client_id: CLIENT_ID }),\n });\n\n if (!response.ok) {\n const error = (await response.json()) as { error_description?: string; error?: string };\n throw new Error(error.error_description || error.error || \"Failed to request device code\");\n }\n\n return (await response.json()) as DeviceCodeResponse;\n}\n\n/**\n * Poll for token exchange\n * Returns the token response if approved, or throws an error\n */\nexport async function pollForToken(\n deviceCode: string,\n): Promise<TokenResponse | null> {\n const response = await fetch(`${getBaseUrl()}/api/auth/device/token`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n grant_type: \"urn:ietf:params:oauth:grant-type:device_code\",\n device_code: deviceCode,\n client_id: CLIENT_ID,\n }),\n });\n\n const data = (await response.json()) as TokenResponse | TokenErrorResponse;\n\n if (!response.ok) {\n if (\"error\" in data && data.error === \"authorization_pending\") {\n return null; // Still waiting for user\n }\n const errorMsg = \"error_description\" in data ? data.error_description : (\"error\" in data ? data.error : \"Token exchange failed\");\n throw new Error(errorMsg || \"Token exchange failed\");\n }\n\n return data as TokenResponse;\n}\n\n/**\n * Get current user info\n */\nexport async function getCurrentUser(): Promise<UserMeResponse> {\n const token = getValidToken();\n\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const response = await fetch(`${getBaseUrl()}/api/user/me`, {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n throw new Error(\"Failed to get user info\");\n }\n\n return (await response.json()) as UserMeResponse;\n}\n\n// ============================================\n// Config API - Agents\n// ============================================\n\n/**\n * List agents for the current account\n */\nexport async function listAgents(options?: {\n includeKpis?: boolean;\n}): Promise<Agent[]> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const params = new URLSearchParams();\n if (options?.includeKpis) {\n params.set(\"includeKpis\", \"true\");\n }\n\n const url = `${getBaseUrl()}/api/config/agents${params.toString() ? `?${params}` : \"\"}`;\n const response = await fetch(url, {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to list agents\");\n }\n\n const data = (await response.json()) as { agents: Agent[] };\n return data.agents;\n}\n\n/**\n * Get a single agent by ID\n */\nexport async function getAgent(id: string): Promise<Agent> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const response = await fetch(`${getBaseUrl()}/api/config/agents/${id}`, {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n if (response.status === 404) {\n throw new Error(\"Agent not found\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to get agent\");\n }\n\n return (await response.json()) as Agent;\n}\n\n/**\n * Create a new agent\n */\nexport async function createAgent(payload: CreateAgentPayload): Promise<Agent> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const response = await fetch(`${getBaseUrl()}/api/config/agents`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${token}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n if (response.status === 409) {\n throw new Error(\"An agent with this name already exists\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to create agent\");\n }\n\n return (await response.json()) as Agent;\n}\n\n/**\n * Update an agent\n */\nexport async function updateAgent(\n id: string,\n payload: UpdateAgentPayload,\n): Promise<Agent> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const response = await fetch(`${getBaseUrl()}/api/config/agents/${id}`, {\n method: \"PUT\",\n headers: {\n Authorization: `Bearer ${token}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n if (response.status === 404) {\n throw new Error(\"Agent not found\");\n }\n if (response.status === 409) {\n throw new Error(\"An agent with this name already exists\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to update agent\");\n }\n\n return (await response.json()) as Agent;\n}\n\n/**\n * Delete an agent\n */\nexport async function deleteAgent(id: string): Promise<void> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const response = await fetch(`${getBaseUrl()}/api/config/agents/${id}`, {\n method: \"DELETE\",\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n if (response.status === 404) {\n throw new Error(\"Agent not found\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to delete agent\");\n }\n}\n\n// ============================================\n// Config API - Workflows\n// ============================================\n\n/**\n * List workflows for the current account\n */\nexport async function listWorkflows(options?: {\n includeAgents?: boolean;\n includeInactive?: boolean;\n}): Promise<Workflow[]> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const params = new URLSearchParams();\n if (options?.includeAgents) {\n params.set(\"includeAgents\", \"true\");\n }\n if (options?.includeInactive) {\n params.set(\"includeInactive\", \"true\");\n }\n\n const url = `${getBaseUrl()}/api/config/workflows${params.toString() ? `?${params}` : \"\"}`;\n const response = await fetch(url, {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to list workflows\");\n }\n\n const data = (await response.json()) as { workflows: Workflow[] };\n return data.workflows;\n}\n\n/**\n * Get a single workflow by ID\n */\nexport async function getWorkflow(id: string): Promise<Workflow> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const response = await fetch(`${getBaseUrl()}/api/config/workflows/${id}`, {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n if (response.status === 404) {\n throw new Error(\"Workflow not found\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to get workflow\");\n }\n\n return (await response.json()) as Workflow;\n}\n\n/**\n * Create a new workflow\n */\nexport async function createWorkflow(\n payload: CreateWorkflowPayload,\n): Promise<Workflow> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const response = await fetch(`${getBaseUrl()}/api/config/workflows`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${token}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n if (response.status === 409) {\n throw new Error(\"A workflow with this name already exists\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to create workflow\");\n }\n\n return (await response.json()) as Workflow;\n}\n\n/**\n * Update a workflow\n */\nexport async function updateWorkflow(\n id: string,\n payload: UpdateWorkflowPayload,\n): Promise<Workflow> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const response = await fetch(`${getBaseUrl()}/api/config/workflows/${id}`, {\n method: \"PUT\",\n headers: {\n Authorization: `Bearer ${token}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n if (response.status === 404) {\n throw new Error(\"Workflow not found\");\n }\n if (response.status === 409) {\n throw new Error(\"A workflow with this name already exists\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to update workflow\");\n }\n\n return (await response.json()) as Workflow;\n}\n\n/**\n * Delete a workflow\n */\nexport async function deleteWorkflow(id: string): Promise<void> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const response = await fetch(`${getBaseUrl()}/api/config/workflows/${id}`, {\n method: \"DELETE\",\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n if (response.status === 404) {\n throw new Error(\"Workflow not found\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to delete workflow\");\n }\n}\n\n// ============================================\n// Config API - KPIs\n// ============================================\n\n/**\n * List KPI definitions for the current account\n */\nexport async function listKpis(options?: {\n agentId?: string;\n includeInactive?: boolean;\n}): Promise<KpiDefinition[]> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const params = new URLSearchParams();\n if (options?.agentId) {\n params.set(\"agentId\", options.agentId);\n }\n if (options?.includeInactive) {\n params.set(\"includeInactive\", \"true\");\n }\n\n const url = `${getBaseUrl()}/api/config/kpis${params.toString() ? `?${params}` : \"\"}`;\n const response = await fetch(url, {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to list KPIs\");\n }\n\n const data = (await response.json()) as { kpiDefinitions: KpiDefinition[] };\n return data.kpiDefinitions;\n}\n\n/**\n * Get a single KPI definition by ID\n */\nexport async function getKpi(id: string): Promise<KpiDefinition> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const response = await fetch(`${getBaseUrl()}/api/config/kpis/${id}`, {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n if (response.status === 404) {\n throw new Error(\"KPI definition not found\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to get KPI\");\n }\n\n return (await response.json()) as KpiDefinition;\n}\n\n/**\n * Create a new KPI definition\n */\nexport async function createKpi(payload: CreateKpiPayload): Promise<KpiDefinition> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const response = await fetch(`${getBaseUrl()}/api/config/kpis`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${token}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n if (response.status === 409) {\n throw new Error(\"A KPI definition with this name already exists\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to create KPI\");\n }\n\n return (await response.json()) as KpiDefinition;\n}\n\n/**\n * Update a KPI definition\n */\nexport async function updateKpi(\n id: string,\n payload: UpdateKpiPayload,\n): Promise<KpiDefinition> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const response = await fetch(`${getBaseUrl()}/api/config/kpis/${id}`, {\n method: \"PUT\",\n headers: {\n Authorization: `Bearer ${token}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n if (response.status === 404) {\n throw new Error(\"KPI definition not found\");\n }\n if (response.status === 409) {\n throw new Error(\"A KPI definition with this name already exists\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to update KPI\");\n }\n\n return (await response.json()) as KpiDefinition;\n}\n\n/**\n * Delete a KPI definition\n */\nexport async function deleteKpi(id: string): Promise<void> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const response = await fetch(`${getBaseUrl()}/api/config/kpis/${id}`, {\n method: \"DELETE\",\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n if (response.status === 404) {\n throw new Error(\"KPI definition not found\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to delete KPI\");\n }\n}\n\n/**\n * Get available context variables for KPI formulas\n */\nexport async function getKpiContextVariables(\n agentId?: string,\n): Promise<ContextVariable[]> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const params = new URLSearchParams();\n if (agentId) {\n params.set(\"agentId\", agentId);\n }\n\n const url = `${getBaseUrl()}/api/config/kpis/context-variables${params.toString() ? `?${params}` : \"\"}`;\n const response = await fetch(url, {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to get context variables\");\n }\n\n const data = (await response.json()) as { contextVariables: ContextVariable[] };\n return data.contextVariables;\n}\n\n/**\n * Validate a KPI formula expression\n */\nexport async function validateKpiFormula(\n formula: string,\n agentId?: string,\n): Promise<FormulaValidationResult> {\n const token = getValidToken();\n if (!token) {\n throw new Error(\"Not logged in. Run 'olakai login' first.\");\n }\n\n const response = await fetch(`${getBaseUrl()}/api/config/kpis/validate`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${token}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ formula, agentId }),\n });\n\n if (!response.ok) {\n if (response.status === 401) {\n throw new Error(\"Session expired. Run 'olakai login' to authenticate again.\");\n }\n const error = (await response.json()) as { error?: string };\n throw new Error(error.error || \"Failed to validate formula\");\n }\n\n return (await response.json()) as FormulaValidationResult;\n}\n","import { clearToken, isTokenValid } from \"../lib/auth.js\";\n\n/**\n * Logout command handler\n */\nexport function logoutCommand(): void {\n if (!isTokenValid()) {\n console.log(\"Not currently logged in.\");\n return;\n }\n\n clearToken();\n console.log(\"Logged out successfully.\");\n}\n","import { getCurrentUser } from \"../lib/api.js\";\nimport { isTokenValid } from \"../lib/auth.js\";\nimport { getEnvironment } from \"../lib/config.js\";\n\n/**\n * Whoami command handler\n */\nexport async function whoamiCommand(): Promise<void> {\n if (!isTokenValid()) {\n console.log(\"Not logged in. Run 'olakai login' to authenticate.\");\n process.exit(1);\n }\n\n try {\n const user = await getCurrentUser();\n\n console.log(`Email: ${user.email}`);\n console.log(`Name: ${user.firstName} ${user.lastName}`);\n console.log(`Role: ${user.role}`);\n console.log(`Account ID: ${user.accountId}`);\n console.log(`Environment: ${getEnvironment()}`);\n } catch (error) {\n if (error instanceof Error) {\n console.error(`Error: ${error.message}`);\n } else {\n console.error(\"Failed to get user info\");\n }\n process.exit(1);\n }\n}\n","import { Command } from \"commander\";\nimport {\n listAgents,\n getAgent,\n createAgent,\n updateAgent,\n deleteAgent,\n type Agent,\n} from \"../lib/api.js\";\n\nfunction formatAgentTable(agents: Agent[]): void {\n if (agents.length === 0) {\n console.log(\"No agents found.\");\n return;\n }\n\n // Calculate column widths\n const headers = [\"ID\", \"NAME\", \"ROLE\", \"WORKFLOW\", \"API KEY\"];\n const rows = agents.map((agent) => [\n agent.id.slice(0, 12) + \"...\",\n agent.name.slice(0, 30),\n agent.role,\n agent.workflowId ? agent.workflowId.slice(0, 12) + \"...\" : \"-\",\n agent.apiKey ? (agent.apiKey.isActive ? \"Active\" : \"Inactive\") : \"None\",\n ]);\n\n const widths = headers.map((h, i) =>\n Math.max(h.length, ...rows.map((r) => r[i].length))\n );\n\n // Print header\n console.log(headers.map((h, i) => h.padEnd(widths[i])).join(\" \"));\n console.log(widths.map((w) => \"-\".repeat(w)).join(\" \"));\n\n // Print rows\n for (const row of rows) {\n console.log(row.map((cell, i) => cell.padEnd(widths[i])).join(\" \"));\n }\n}\n\nfunction formatAgentDetail(agent: Agent): void {\n console.log(`ID: ${agent.id}`);\n console.log(`Name: ${agent.name}`);\n console.log(`Description: ${agent.description || \"-\"}`);\n console.log(`Role: ${agent.role}`);\n console.log(`Source: ${agent.source}`);\n console.log(`Category: ${agent.category || \"-\"}`);\n console.log(`Workflow ID: ${agent.workflowId || \"-\"}`);\n\n if (agent.workflow) {\n console.log(`Workflow: ${agent.workflow.name}`);\n }\n\n console.log(\"\");\n console.log(\"API Key:\");\n if (agent.apiKey) {\n console.log(` ID: ${agent.apiKey.id}`);\n if (agent.apiKey.key) {\n console.log(` Key: ${agent.apiKey.key}`);\n } else {\n console.log(` Key: ${agent.apiKey.keyMasked}`);\n }\n console.log(` Status: ${agent.apiKey.isActive ? \"Active\" : \"Inactive\"}`);\n } else {\n console.log(\" None\");\n }\n\n if (agent.kpiDefinitions && agent.kpiDefinitions.length > 0) {\n console.log(\"\");\n console.log(\"KPI Definitions:\");\n for (const kpi of agent.kpiDefinitions) {\n console.log(` - ${kpi.name} (${kpi.type})`);\n }\n }\n}\n\nasync function listCommand(options: {\n json?: boolean;\n includeKpis?: boolean;\n}): Promise<void> {\n try {\n const agents = await listAgents({ includeKpis: options.includeKpis });\n\n if (options.json) {\n console.log(JSON.stringify(agents, null, 2));\n } else {\n formatAgentTable(agents);\n }\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nasync function getCommand(id: string, options: { json?: boolean }): Promise<void> {\n try {\n const agent = await getAgent(id);\n\n if (options.json) {\n console.log(JSON.stringify(agent, null, 2));\n } else {\n formatAgentDetail(agent);\n }\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nasync function createCommand(options: {\n name: string;\n description?: string;\n role?: string;\n workflow?: string;\n withApiKey?: boolean;\n category?: string;\n json?: boolean;\n}): Promise<void> {\n try {\n if (!options.name) {\n console.error(\"Error: --name is required\");\n process.exit(1);\n }\n\n const agent = await createAgent({\n name: options.name,\n description: options.description || \"\",\n role: (options.role as \"WORKER\" | \"COORDINATOR\") || \"WORKER\",\n workflowId: options.workflow,\n createApiKey: options.withApiKey || false,\n category: options.category,\n });\n\n if (options.json) {\n console.log(JSON.stringify(agent, null, 2));\n } else {\n console.log(\"Agent created successfully!\");\n console.log(\"\");\n formatAgentDetail(agent);\n\n if (agent.apiKey?.key) {\n console.log(\"\");\n console.log(\n \"IMPORTANT: Save your API key now. It will not be shown again.\"\n );\n }\n }\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nasync function updateCommand(\n id: string,\n options: {\n name?: string;\n description?: string;\n role?: string;\n workflow?: string;\n category?: string;\n json?: boolean;\n }\n): Promise<void> {\n try {\n const payload: {\n name?: string;\n description?: string;\n role?: \"WORKER\" | \"COORDINATOR\";\n workflowId?: string | null;\n category?: string | null;\n } = {};\n\n if (options.name !== undefined) payload.name = options.name;\n if (options.description !== undefined)\n payload.description = options.description;\n if (options.role !== undefined)\n payload.role = options.role as \"WORKER\" | \"COORDINATOR\";\n if (options.workflow !== undefined) payload.workflowId = options.workflow;\n if (options.category !== undefined) payload.category = options.category;\n\n if (Object.keys(payload).length === 0) {\n console.error(\"Error: At least one field to update is required\");\n process.exit(1);\n }\n\n const agent = await updateAgent(id, payload);\n\n if (options.json) {\n console.log(JSON.stringify(agent, null, 2));\n } else {\n console.log(\"Agent updated successfully!\");\n console.log(\"\");\n formatAgentDetail(agent);\n }\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nasync function deleteCommand(\n id: string,\n options: { force?: boolean }\n): Promise<void> {\n try {\n if (!options.force) {\n // In a real CLI, we'd use readline for confirmation\n // For now, require --force flag\n console.log(\"Are you sure you want to delete this agent?\");\n console.log(\"Use --force to confirm deletion.\");\n process.exit(1);\n }\n\n await deleteAgent(id);\n console.log(\"Agent deleted successfully.\");\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nexport function registerAgentsCommand(program: Command): void {\n const agents = program\n .command(\"agents\")\n .description(\"Manage agents\");\n\n agents\n .command(\"list\")\n .description(\"List all agents\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--include-kpis\", \"Include KPI definitions\")\n .action(listCommand);\n\n agents\n .command(\"get <id>\")\n .description(\"Get agent details\")\n .option(\"--json\", \"Output as JSON\")\n .action(getCommand);\n\n agents\n .command(\"create\")\n .description(\"Create a new agent\")\n .requiredOption(\"--name <name>\", \"Agent name\")\n .option(\"--description <description>\", \"Agent description\")\n .option(\"--role <role>\", \"Agent role (WORKER or COORDINATOR)\", \"WORKER\")\n .option(\"--workflow <id>\", \"Workflow ID to assign\")\n .option(\"--with-api-key\", \"Create an API key for this agent\")\n .option(\"--category <category>\", \"Agent category\")\n .option(\"--json\", \"Output as JSON\")\n .action(createCommand);\n\n agents\n .command(\"update <id>\")\n .description(\"Update an agent\")\n .option(\"--name <name>\", \"Agent name\")\n .option(\"--description <description>\", \"Agent description\")\n .option(\"--role <role>\", \"Agent role (WORKER or COORDINATOR)\")\n .option(\"--workflow <id>\", \"Workflow ID to assign\")\n .option(\"--category <category>\", \"Agent category\")\n .option(\"--json\", \"Output as JSON\")\n .action(updateCommand);\n\n agents\n .command(\"delete <id>\")\n .description(\"Delete an agent\")\n .option(\"--force\", \"Skip confirmation\")\n .action(deleteCommand);\n}\n","import { Command } from \"commander\";\nimport {\n listWorkflows,\n getWorkflow,\n createWorkflow,\n updateWorkflow,\n deleteWorkflow,\n type Workflow,\n} from \"../lib/api.js\";\n\nfunction formatWorkflowTable(workflows: Workflow[]): void {\n if (workflows.length === 0) {\n console.log(\"No workflows found.\");\n return;\n }\n\n // Calculate column widths\n const headers = [\"ID\", \"NAME\", \"AGENTS\", \"STATUS\"];\n const rows = workflows.map((wf) => [\n wf.id.slice(0, 12) + \"...\",\n wf.name.slice(0, 30),\n wf.agentCount.toString(),\n wf.isActive ? \"Active\" : \"Inactive\",\n ]);\n\n const widths = headers.map((h, i) =>\n Math.max(h.length, ...rows.map((r) => r[i].length))\n );\n\n // Print header\n console.log(headers.map((h, i) => h.padEnd(widths[i])).join(\" \"));\n console.log(widths.map((w) => \"-\".repeat(w)).join(\" \"));\n\n // Print rows\n for (const row of rows) {\n console.log(row.map((cell, i) => cell.padEnd(widths[i])).join(\" \"));\n }\n}\n\nfunction formatWorkflowDetail(workflow: Workflow): void {\n console.log(`ID: ${workflow.id}`);\n console.log(`Name: ${workflow.name}`);\n console.log(`Description: ${workflow.description || \"-\"}`);\n console.log(`Status: ${workflow.isActive ? \"Active\" : \"Inactive\"}`);\n console.log(`Agents: ${workflow.agentCount}`);\n if (workflow.createdAt) {\n console.log(`Created: ${new Date(workflow.createdAt).toISOString()}`);\n }\n if (workflow.updatedAt) {\n console.log(`Updated: ${new Date(workflow.updatedAt).toISOString()}`);\n }\n\n if (workflow.agents && workflow.agents.length > 0) {\n console.log(\"\");\n console.log(\"Agents:\");\n for (const agent of workflow.agents) {\n const apiKeyStatus = agent.apiKey\n ? agent.apiKey.isActive\n ? \"API Key: Active\"\n : \"API Key: Inactive\"\n : \"No API Key\";\n console.log(` - ${agent.name} (${agent.role}) - ${apiKeyStatus}`);\n }\n }\n}\n\nasync function listCommand(options: {\n json?: boolean;\n includeAgents?: boolean;\n includeInactive?: boolean;\n}): Promise<void> {\n try {\n const workflows = await listWorkflows({\n includeAgents: options.includeAgents,\n includeInactive: options.includeInactive,\n });\n\n if (options.json) {\n console.log(JSON.stringify(workflows, null, 2));\n } else {\n formatWorkflowTable(workflows);\n }\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nasync function getCommand(id: string, options: { json?: boolean }): Promise<void> {\n try {\n const workflow = await getWorkflow(id);\n\n if (options.json) {\n console.log(JSON.stringify(workflow, null, 2));\n } else {\n formatWorkflowDetail(workflow);\n }\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nasync function createCommand(options: {\n name: string;\n description?: string;\n json?: boolean;\n}): Promise<void> {\n try {\n if (!options.name) {\n console.error(\"Error: --name is required\");\n process.exit(1);\n }\n\n const workflow = await createWorkflow({\n name: options.name,\n description: options.description,\n });\n\n if (options.json) {\n console.log(JSON.stringify(workflow, null, 2));\n } else {\n console.log(\"Workflow created successfully!\");\n console.log(\"\");\n formatWorkflowDetail(workflow);\n }\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nasync function updateCommand(\n id: string,\n options: {\n name?: string;\n description?: string;\n active?: boolean;\n inactive?: boolean;\n json?: boolean;\n }\n): Promise<void> {\n try {\n const payload: {\n name?: string;\n description?: string | null;\n isActive?: boolean;\n } = {};\n\n if (options.name !== undefined) payload.name = options.name;\n if (options.description !== undefined)\n payload.description = options.description;\n if (options.active) payload.isActive = true;\n if (options.inactive) payload.isActive = false;\n\n if (Object.keys(payload).length === 0) {\n console.error(\"Error: At least one field to update is required\");\n process.exit(1);\n }\n\n const workflow = await updateWorkflow(id, payload);\n\n if (options.json) {\n console.log(JSON.stringify(workflow, null, 2));\n } else {\n console.log(\"Workflow updated successfully!\");\n console.log(\"\");\n formatWorkflowDetail(workflow);\n }\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nasync function deleteCommand(\n id: string,\n options: { force?: boolean }\n): Promise<void> {\n try {\n if (!options.force) {\n // In a real CLI, we'd use readline for confirmation\n // For now, require --force flag\n console.log(\"Are you sure you want to delete this workflow?\");\n console.log(\"Use --force to confirm deletion.\");\n process.exit(1);\n }\n\n await deleteWorkflow(id);\n console.log(\"Workflow deleted successfully.\");\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nexport function registerWorkflowsCommand(program: Command): void {\n const workflows = program\n .command(\"workflows\")\n .description(\"Manage workflows\");\n\n workflows\n .command(\"list\")\n .description(\"List all workflows\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--include-agents\", \"Include agent details\")\n .option(\"--include-inactive\", \"Include inactive workflows\")\n .action(listCommand);\n\n workflows\n .command(\"get <id>\")\n .description(\"Get workflow details\")\n .option(\"--json\", \"Output as JSON\")\n .action(getCommand);\n\n workflows\n .command(\"create\")\n .description(\"Create a new workflow\")\n .requiredOption(\"--name <name>\", \"Workflow name\")\n .option(\"--description <description>\", \"Workflow description\")\n .option(\"--json\", \"Output as JSON\")\n .action(createCommand);\n\n workflows\n .command(\"update <id>\")\n .description(\"Update a workflow\")\n .option(\"--name <name>\", \"Workflow name\")\n .option(\"--description <description>\", \"Workflow description\")\n .option(\"--active\", \"Set workflow as active\")\n .option(\"--inactive\", \"Set workflow as inactive\")\n .option(\"--json\", \"Output as JSON\")\n .action(updateCommand);\n\n workflows\n .command(\"delete <id>\")\n .description(\"Delete a workflow\")\n .option(\"--force\", \"Skip confirmation\")\n .action(deleteCommand);\n}\n","import { Command } from \"commander\";\nimport {\n listKpis,\n getKpi,\n createKpi,\n updateKpi,\n deleteKpi,\n getKpiContextVariables,\n validateKpiFormula,\n type KpiDefinition,\n type ContextVariable,\n type CreateKpiPayload,\n type DefaultAggregationMethod,\n} from \"../lib/api.js\";\n\nconst AGGREGATION_METHODS: DefaultAggregationMethod[] = [\n \"SUM\",\n \"AVERAGE\",\n \"COUNT\",\n \"MIN\",\n \"MAX\",\n \"LATEST\",\n];\n\nconst CALCULATOR_IDS = [\"formula\", \"classifier\", \"llm-data\"];\n\nfunction formatKpiTable(kpis: KpiDefinition[]): void {\n if (kpis.length === 0) {\n console.log(\"No KPI definitions found.\");\n return;\n }\n\n // Calculate column widths\n const headers = [\"ID\", \"NAME\", \"CALCULATOR\", \"AGGREGATION\", \"STATUS\"];\n const rows = kpis.map((kpi) => [\n kpi.id.slice(0, 12) + \"...\",\n kpi.name.slice(0, 25),\n kpi.calculatorId,\n kpi.defaultAggregationMethod,\n kpi.isActive ? \"Active\" : \"Inactive\",\n ]);\n\n const widths = headers.map((h, i) =>\n Math.max(h.length, ...rows.map((r) => r[i].length))\n );\n\n // Print header\n console.log(headers.map((h, i) => h.padEnd(widths[i])).join(\" \"));\n console.log(widths.map((w) => \"-\".repeat(w)).join(\" \"));\n\n // Print rows\n for (const row of rows) {\n console.log(row.map((cell, i) => cell.padEnd(widths[i])).join(\" \"));\n }\n}\n\nfunction formatKpiDetail(kpi: KpiDefinition): void {\n console.log(`ID: ${kpi.id}`);\n console.log(`Name: ${kpi.name}`);\n console.log(`Description: ${kpi.description || \"-\"}`);\n console.log(`Type: ${kpi.type}`);\n console.log(`Category: ${kpi.category || \"-\"}`);\n console.log(`Agent ID: ${kpi.agentId || \"-\"}`);\n console.log(`Calculator: ${kpi.calculatorId}`);\n console.log(`Aggregation: ${kpi.defaultAggregationMethod}`);\n console.log(`Unit: ${kpi.unit || \"-\"}`);\n console.log(`Status: ${kpi.isActive ? \"Active\" : \"Inactive\"}`);\n\n if (kpi.calculatorParams) {\n console.log(\"\");\n console.log(\"Calculator Parameters:\");\n console.log(JSON.stringify(kpi.calculatorParams, null, 2));\n }\n\n if (kpi.createdAt) {\n console.log(\"\");\n console.log(`Created: ${new Date(kpi.createdAt).toISOString()}`);\n }\n if (kpi.updatedAt) {\n console.log(`Updated: ${new Date(kpi.updatedAt).toISOString()}`);\n }\n}\n\nfunction formatContextVariablesTable(variables: ContextVariable[]): void {\n if (variables.length === 0) {\n console.log(\"No context variables found.\");\n return;\n }\n\n // Calculate column widths\n const headers = [\"NAME\", \"TYPE\", \"SOURCE\", \"DESCRIPTION\"];\n const rows = variables.map((v) => [\n v.name,\n v.type,\n v.source,\n v.description.slice(0, 50),\n ]);\n\n const widths = headers.map((h, i) =>\n Math.max(h.length, ...rows.map((r) => r[i].length))\n );\n\n // Print header\n console.log(headers.map((h, i) => h.padEnd(widths[i])).join(\" \"));\n console.log(widths.map((w) => \"-\".repeat(w)).join(\" \"));\n\n // Print rows\n for (const row of rows) {\n console.log(row.map((cell, i) => cell.padEnd(widths[i])).join(\" \"));\n }\n}\n\nasync function listCommand(options: {\n json?: boolean;\n agentId?: string;\n includeInactive?: boolean;\n}): Promise<void> {\n try {\n const kpis = await listKpis({\n agentId: options.agentId,\n includeInactive: options.includeInactive,\n });\n\n if (options.json) {\n console.log(JSON.stringify(kpis, null, 2));\n } else {\n formatKpiTable(kpis);\n }\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nasync function getCommand(\n id: string,\n options: { json?: boolean }\n): Promise<void> {\n try {\n const kpi = await getKpi(id);\n\n if (options.json) {\n console.log(JSON.stringify(kpi, null, 2));\n } else {\n formatKpiDetail(kpi);\n }\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nasync function createCommand(options: {\n name: string;\n calculatorId: string;\n description?: string;\n type?: string;\n category?: string;\n agentId?: string;\n formula?: string;\n unit?: string;\n aggregation?: string;\n json?: boolean;\n}): Promise<void> {\n try {\n if (!options.name) {\n console.error(\"Error: --name is required\");\n process.exit(1);\n }\n\n if (!options.calculatorId) {\n console.error(\"Error: --calculator-id is required\");\n console.error(`Valid values: ${CALCULATOR_IDS.join(\", \")}`);\n process.exit(1);\n }\n\n if (!CALCULATOR_IDS.includes(options.calculatorId)) {\n console.error(`Error: Invalid calculator ID \"${options.calculatorId}\"`);\n console.error(`Valid values: ${CALCULATOR_IDS.join(\", \")}`);\n process.exit(1);\n }\n\n // Build calculator params\n let calculatorParams: Record<string, unknown> | undefined;\n if (options.calculatorId === \"formula\") {\n if (!options.formula) {\n console.error(\n \"Error: --formula is required when calculator-id is 'formula'\"\n );\n process.exit(1);\n }\n calculatorParams = { formula: options.formula };\n }\n\n // Validate aggregation method\n let aggregation: DefaultAggregationMethod | undefined;\n if (options.aggregation) {\n const upperAggregation =\n options.aggregation.toUpperCase() as DefaultAggregationMethod;\n if (!AGGREGATION_METHODS.includes(upperAggregation)) {\n console.error(`Error: Invalid aggregation method \"${options.aggregation}\"`);\n console.error(`Valid values: ${AGGREGATION_METHODS.join(\", \")}`);\n process.exit(1);\n }\n aggregation = upperAggregation;\n }\n\n const payload: CreateKpiPayload = {\n name: options.name,\n calculatorId: options.calculatorId,\n description: options.description,\n type:\n options.type === \"PREDEFINED\" ? \"PREDEFINED\" : \"USER_DEFINED\",\n category: options.category,\n agentId: options.agentId,\n calculatorParams,\n unit: options.unit,\n defaultAggregationMethod: aggregation,\n };\n\n const kpi = await createKpi(payload);\n\n if (options.json) {\n console.log(JSON.stringify(kpi, null, 2));\n } else {\n console.log(\"KPI definition created successfully!\");\n console.log(\"\");\n formatKpiDetail(kpi);\n }\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nasync function updateCommand(\n id: string,\n options: {\n name?: string;\n description?: string;\n category?: string;\n agentId?: string;\n calculatorId?: string;\n formula?: string;\n unit?: string;\n aggregation?: string;\n active?: boolean;\n inactive?: boolean;\n json?: boolean;\n }\n): Promise<void> {\n try {\n const payload: Record<string, unknown> = {};\n\n if (options.name !== undefined) payload.name = options.name;\n if (options.description !== undefined)\n payload.description = options.description;\n if (options.category !== undefined) payload.category = options.category;\n if (options.agentId !== undefined) payload.agentId = options.agentId;\n if (options.calculatorId !== undefined)\n payload.calculatorId = options.calculatorId;\n if (options.unit !== undefined) payload.unit = options.unit;\n if (options.active) payload.isActive = true;\n if (options.inactive) payload.isActive = false;\n\n // Handle formula update\n if (options.formula !== undefined) {\n payload.calculatorParams = { formula: options.formula };\n }\n\n // Validate and set aggregation method\n if (options.aggregation) {\n const upperAggregation =\n options.aggregation.toUpperCase() as DefaultAggregationMethod;\n if (!AGGREGATION_METHODS.includes(upperAggregation)) {\n console.error(`Error: Invalid aggregation method \"${options.aggregation}\"`);\n console.error(`Valid values: ${AGGREGATION_METHODS.join(\", \")}`);\n process.exit(1);\n }\n payload.defaultAggregationMethod = upperAggregation;\n }\n\n if (Object.keys(payload).length === 0) {\n console.error(\"Error: At least one field to update is required\");\n process.exit(1);\n }\n\n const kpi = await updateKpi(id, payload);\n\n if (options.json) {\n console.log(JSON.stringify(kpi, null, 2));\n } else {\n console.log(\"KPI definition updated successfully!\");\n console.log(\"\");\n formatKpiDetail(kpi);\n }\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nasync function deleteCommand(\n id: string,\n options: { force?: boolean }\n): Promise<void> {\n try {\n if (!options.force) {\n console.log(\"Are you sure you want to delete this KPI definition?\");\n console.log(\"Use --force to confirm deletion.\");\n process.exit(1);\n }\n\n await deleteKpi(id);\n console.log(\"KPI definition deleted successfully.\");\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nasync function contextVariablesCommand(options: {\n json?: boolean;\n agentId?: string;\n}): Promise<void> {\n try {\n const variables = await getKpiContextVariables(options.agentId);\n\n if (options.json) {\n console.log(JSON.stringify(variables, null, 2));\n } else {\n console.log(\"Available context variables for KPI formulas:\");\n console.log(\"\");\n formatContextVariablesTable(variables);\n console.log(\"\");\n console.log(\n \"Use these variable names in your formula expressions, e.g.:\"\n );\n console.log(' IF(PII detected, 1, 0)');\n console.log(' Documents count * 10');\n console.log(' IF(CODE detected AND SECRET detected, \"high-risk\", \"normal\")');\n }\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nasync function validateCommand(options: {\n formula: string;\n agentId?: string;\n json?: boolean;\n}): Promise<void> {\n try {\n if (!options.formula) {\n console.error(\"Error: --formula is required\");\n process.exit(1);\n }\n\n const result = await validateKpiFormula(options.formula, options.agentId);\n\n if (options.json) {\n console.log(JSON.stringify(result, null, 2));\n } else {\n if (result.valid) {\n console.log(\"Formula is valid!\");\n console.log(`Result type: ${result.type || \"unknown\"}`);\n } else {\n console.error(\"Formula is invalid:\");\n console.error(` ${result.error}`);\n if (result.charIndex !== undefined) {\n console.error(` Position: character ${result.charIndex}`);\n }\n process.exit(1);\n }\n }\n } catch (error) {\n console.error(\n `Error: ${error instanceof Error ? error.message : \"Unknown error\"}`\n );\n process.exit(1);\n }\n}\n\nexport function registerKpisCommand(program: Command): void {\n const kpis = program\n .command(\"kpis\")\n .description(\"Manage KPI definitions\");\n\n kpis\n .command(\"list\")\n .description(\"List all KPI definitions\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--agent-id <id>\", \"Filter by agent ID\")\n .option(\"--include-inactive\", \"Include inactive KPI definitions\")\n .action(listCommand);\n\n kpis\n .command(\"get <id>\")\n .description(\"Get KPI definition details\")\n .option(\"--json\", \"Output as JSON\")\n .action(getCommand);\n\n kpis\n .command(\"create\")\n .description(\"Create a new KPI definition\")\n .requiredOption(\"--name <name>\", \"KPI name\")\n .requiredOption(\n \"--calculator-id <id>\",\n \"Calculator type: formula, classifier, or llm-data\"\n )\n .option(\"--description <description>\", \"KPI description\")\n .option(\"--type <type>\", \"KPI type: PREDEFINED or USER_DEFINED (default)\")\n .option(\"--category <category>\", \"KPI category for grouping\")\n .option(\"--agent-id <id>\", \"Associate KPI with a specific agent\")\n .option(\"--formula <formula>\", \"Formula expression (required for formula calculator)\")\n .option(\"--unit <unit>\", 'Display unit (e.g., \"ms\", \"%\", \"count\")')\n .option(\n \"--aggregation <method>\",\n \"Default aggregation: SUM, AVERAGE, COUNT, MIN, MAX, LATEST (default)\"\n )\n .option(\"--json\", \"Output as JSON\")\n .action(createCommand);\n\n kpis\n .command(\"update <id>\")\n .description(\"Update a KPI definition\")\n .option(\"--name <name>\", \"KPI name\")\n .option(\"--description <description>\", \"KPI description\")\n .option(\"--category <category>\", \"KPI category\")\n .option(\"--agent-id <id>\", \"Associate with agent\")\n .option(\"--calculator-id <id>\", \"Calculator type\")\n .option(\"--formula <formula>\", \"Formula expression\")\n .option(\"--unit <unit>\", \"Display unit\")\n .option(\"--aggregation <method>\", \"Default aggregation method\")\n .option(\"--active\", \"Set KPI as active\")\n .option(\"--inactive\", \"Set KPI as inactive\")\n .option(\"--json\", \"Output as JSON\")\n .action(updateCommand);\n\n kpis\n .command(\"delete <id>\")\n .description(\"Delete a KPI definition\")\n .option(\"--force\", \"Skip confirmation\")\n .action(deleteCommand);\n\n kpis\n .command(\"context-variables\")\n .description(\"List available context variables for formulas\")\n .option(\"--json\", \"Output as JSON\")\n .option(\"--agent-id <id>\", \"Include agent-specific variables\")\n .action(contextVariablesCommand);\n\n kpis\n .command(\"validate\")\n .description(\"Validate a KPI formula expression\")\n .requiredOption(\"--formula <formula>\", \"Formula expression to validate\")\n .option(\"--agent-id <id>\", \"Include agent-specific context\")\n .option(\"--json\", \"Output as JSON\")\n .action(validateCommand);\n}\n"],"mappings":";;;AAEA,SAAS,eAAe;;;ACFxB,OAAO,UAAU;;;ACEjB,IAAM,QAAqC;AAAA,EACzC,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,OAAO;AACT;A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AAC,mBAAmB,QAAQ,GAAG,GAAG;AACpC,cAAQ;AAAA,QACN,wBAAwB,QAAQ,GAAG,oBAAoB,qBAAqB,EAAE,KAAK,IAAI,CAAC;AAAA,MAC1F;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,mBAAe,QAAQ,GAAkB;AAAA,EAC3C;AACF,CAAC;AAEH,QACG,QAAQ,OAAO,EACf,YAAY,+CAA+C,EAC3D,OAAO,YAAY;AAEtB,QACG,QAAQ,QAAQ,EAChB,YAAY,qBAAqB,EACjC,OAAO,aAAa;AAEvB,QACG,QAAQ,QAAQ,EAChB,YAAY,6BAA6B,EACzC,OAAO,aAAa;AAGvB,sBAAsB,OAAO;AAC7B,yBAAyB,OAAO;AAChC,oBAAoB,OAAO;AAE3B,QAAQ,MAAM;","names":["program","listCommand","getCommand","createCommand","updateCommand","deleteCommand","program","listCommand","getCommand","createCommand","updateCommand","deleteCommand","program"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "olakai-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Olakai CLI tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -10,6 +10,14 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"dist"
|
|
12
12
|
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsup",
|
|
15
|
+
"dev": "tsx src/index.ts",
|
|
16
|
+
"start": "node dist/index.js",
|
|
17
|
+
"lint": "eslint src --ext .ts",
|
|
18
|
+
"type-check": "tsc --noEmit",
|
|
19
|
+
"prepublishOnly": "pnpm build"
|
|
20
|
+
},
|
|
13
21
|
"keywords": [
|
|
14
22
|
"olakai",
|
|
15
23
|
"cli"
|
|
@@ -32,11 +40,5 @@
|
|
|
32
40
|
"commander": "^12.0.0",
|
|
33
41
|
"open": "^10.0.0"
|
|
34
42
|
},
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
"dev": "tsx src/index.ts",
|
|
38
|
-
"start": "node dist/index.js",
|
|
39
|
-
"lint": "eslint src --ext .ts",
|
|
40
|
-
"type-check": "tsc --noEmit"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
+
"packageManager": "pnpm@10.10.0"
|
|
44
|
+
}
|