@kinetica/admin-agent 0.2.0 → 0.2.1
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/README.md +13 -11
- package/dist/admin-agent.js +374 -237
- package/knowledge/references/bundle/support-bundle.md +22 -1
- package/knowledge/references/rank-architecture.md +12 -0
- package/package.json +1 -1
package/dist/admin-agent.js
CHANGED
|
@@ -37,10 +37,10 @@ __export(cli_exports, {
|
|
|
37
37
|
verbose: () => verbose
|
|
38
38
|
});
|
|
39
39
|
module.exports = __toCommonJS(cli_exports);
|
|
40
|
-
var
|
|
40
|
+
var import_picocolors15 = __toESM(require("picocolors"));
|
|
41
41
|
|
|
42
42
|
// src/cli/banner.ts
|
|
43
|
-
var
|
|
43
|
+
var import_picocolors2 = __toESM(require("picocolors"));
|
|
44
44
|
|
|
45
45
|
// src/cli/version.ts
|
|
46
46
|
var import_fs = require("fs");
|
|
@@ -62,6 +62,29 @@ function getVersion() {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
// src/output/brand-colors.ts
|
|
66
|
+
var import_picocolors = __toESM(require("picocolors"));
|
|
67
|
+
var BRAND_PURPLE = [147, 51, 234];
|
|
68
|
+
var BRAND_PINK = [236, 72, 153];
|
|
69
|
+
var SOFTEN_TARGET = [210, 210, 210];
|
|
70
|
+
var SOFTEN_PURPLE = 0.55;
|
|
71
|
+
var SOFTEN_PINK = 0.45;
|
|
72
|
+
function soften([r, g, b], amount) {
|
|
73
|
+
const [tr, tg, tb] = SOFTEN_TARGET;
|
|
74
|
+
return [
|
|
75
|
+
Math.round(r + (tr - r) * amount),
|
|
76
|
+
Math.round(g + (tg - g) * amount),
|
|
77
|
+
Math.round(b + (tb - b) * amount)
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
var TEXT_PURPLE = soften(BRAND_PURPLE, SOFTEN_PURPLE);
|
|
81
|
+
var TEXT_PINK = soften(BRAND_PINK, SOFTEN_PINK);
|
|
82
|
+
function truecolor([r, g, b]) {
|
|
83
|
+
return (s) => import_picocolors.default.isColorSupported ? `\x1B[38;2;${r};${g};${b}m${s}\x1B[39m` : s;
|
|
84
|
+
}
|
|
85
|
+
var purple = truecolor(TEXT_PURPLE);
|
|
86
|
+
var pink = truecolor(TEXT_PINK);
|
|
87
|
+
|
|
65
88
|
// src/cli/banner.ts
|
|
66
89
|
var LOGO = ` \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557
|
|
67
90
|
\u2588\u2588\u2551 \u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557
|
|
@@ -86,13 +109,11 @@ function dimRgb(color, factor) {
|
|
|
86
109
|
var SHADOW_CHARS = /* @__PURE__ */ new Set(["\u2557", "\u2554", "\u2551", "\u255D", "\u255A", "\u2550"]);
|
|
87
110
|
var DIM_FACTOR = 0.4;
|
|
88
111
|
function gradientize(text2) {
|
|
89
|
-
const PURPLE = [147, 51, 234];
|
|
90
|
-
const HOT_PINK = [236, 72, 153];
|
|
91
112
|
const RESET = "\x1B[0m";
|
|
92
113
|
const lines = text2.split("\n");
|
|
93
114
|
const maxIdx = Math.max(lines.length - 1, 1);
|
|
94
115
|
return lines.map((line, i) => {
|
|
95
|
-
const bright = lerpRgb(
|
|
116
|
+
const bright = lerpRgb(BRAND_PURPLE, BRAND_PINK, i / maxIdx);
|
|
96
117
|
const dim = dimRgb(bright, DIM_FACTOR);
|
|
97
118
|
let result = "";
|
|
98
119
|
let currentMode = null;
|
|
@@ -110,20 +131,53 @@ function gradientize(text2) {
|
|
|
110
131
|
}
|
|
111
132
|
function printBanner(model) {
|
|
112
133
|
const version = getVersion();
|
|
113
|
-
const subtitle = `admin-agent ${
|
|
134
|
+
const subtitle = `admin-agent ${import_picocolors2.default.dim(`v${version}`)}`;
|
|
114
135
|
const header = model ? `${subtitle}
|
|
115
|
-
${
|
|
136
|
+
${import_picocolors2.default.dim(`Model: ${model}`)}` : subtitle;
|
|
116
137
|
process.stderr.write("\n\n" + gradientize(LOGO) + "\n\n" + header + "\n");
|
|
117
138
|
return subtitle;
|
|
118
139
|
}
|
|
119
140
|
|
|
120
|
-
// src/
|
|
121
|
-
var
|
|
141
|
+
// src/output/themed-prompts.ts
|
|
142
|
+
var import_prompts = require("@inquirer/prompts");
|
|
143
|
+
|
|
144
|
+
// src/output/prompt-theme.ts
|
|
145
|
+
var PROMPT_THEME = {
|
|
146
|
+
style: {
|
|
147
|
+
answer: pink,
|
|
148
|
+
highlight: pink
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// src/output/themed-prompts.ts
|
|
153
|
+
function input(...args) {
|
|
154
|
+
const [config, ...rest] = args;
|
|
155
|
+
return (0, import_prompts.input)({ theme: PROMPT_THEME, ...config }, ...rest);
|
|
156
|
+
}
|
|
157
|
+
function confirm(...args) {
|
|
158
|
+
const [config, ...rest] = args;
|
|
159
|
+
return (0, import_prompts.confirm)({ theme: PROMPT_THEME, ...config }, ...rest);
|
|
160
|
+
}
|
|
161
|
+
function password(...args) {
|
|
162
|
+
const [config, ...rest] = args;
|
|
163
|
+
return (0, import_prompts.password)({ theme: PROMPT_THEME, ...config }, ...rest);
|
|
164
|
+
}
|
|
165
|
+
function select(...args) {
|
|
166
|
+
const [config, ...rest] = args;
|
|
167
|
+
return (0, import_prompts.select)({ theme: PROMPT_THEME, ...config }, ...rest);
|
|
168
|
+
}
|
|
169
|
+
function search(...args) {
|
|
170
|
+
const [config, ...rest] = args;
|
|
171
|
+
return (0, import_prompts.search)({ theme: PROMPT_THEME, ...config }, ...rest);
|
|
172
|
+
}
|
|
173
|
+
function checkbox(...args) {
|
|
174
|
+
const [config, ...rest] = args;
|
|
175
|
+
return (0, import_prompts.checkbox)({ theme: PROMPT_THEME, ...config }, ...rest);
|
|
176
|
+
}
|
|
122
177
|
|
|
123
178
|
// src/agent/run-agent.ts
|
|
124
179
|
var import_claude_agent_sdk5 = require("@anthropic-ai/claude-agent-sdk");
|
|
125
|
-
var
|
|
126
|
-
var import_picocolors8 = __toESM(require("picocolors"));
|
|
180
|
+
var import_picocolors9 = __toESM(require("picocolors"));
|
|
127
181
|
|
|
128
182
|
// src/agent/diagnostic-sql.ts
|
|
129
183
|
function has(columns, name) {
|
|
@@ -500,7 +554,7 @@ var BUILDER_REGISTRY = [
|
|
|
500
554
|
// src/tools/index.ts
|
|
501
555
|
var import_claude_agent_sdk2 = require("@anthropic-ai/claude-agent-sdk");
|
|
502
556
|
var import_zod16 = require("zod");
|
|
503
|
-
var
|
|
557
|
+
var import_picocolors5 = __toESM(require("picocolors"));
|
|
504
558
|
|
|
505
559
|
// src/approval/registry.ts
|
|
506
560
|
var DEFAULT_READ_ONLY_TOOLS = /* @__PURE__ */ new Set();
|
|
@@ -854,7 +908,7 @@ var GetSystemPropertiesSchema = import_zod.z.object({
|
|
|
854
908
|
category: import_zod.z.string().optional(),
|
|
855
909
|
key_pattern: import_zod.z.string().optional()
|
|
856
910
|
});
|
|
857
|
-
async function getSystemProperties(session2,
|
|
911
|
+
async function getSystemProperties(session2, input2) {
|
|
858
912
|
try {
|
|
859
913
|
const response = await session2.makeRequest("/show/system/properties", {
|
|
860
914
|
options: {}
|
|
@@ -884,7 +938,7 @@ async function getSystemProperties(session2, input5) {
|
|
|
884
938
|
const inner = parseDataStr(parsed.data_str, raw);
|
|
885
939
|
if (!inner.ok) return inner;
|
|
886
940
|
const propertyMap = inner.data?.property_map ?? {};
|
|
887
|
-
const filteredMap = applyFilters(propertyMap,
|
|
941
|
+
const filteredMap = applyFilters(propertyMap, input2);
|
|
888
942
|
return {
|
|
889
943
|
ok: true,
|
|
890
944
|
data: flatObjectToRows(filteredMap, "property", "value"),
|
|
@@ -900,8 +954,8 @@ async function getSystemProperties(session2, input5) {
|
|
|
900
954
|
};
|
|
901
955
|
}
|
|
902
956
|
}
|
|
903
|
-
function applyFilters(propertyMap,
|
|
904
|
-
const { category, key_pattern } =
|
|
957
|
+
function applyFilters(propertyMap, input2) {
|
|
958
|
+
const { category, key_pattern } = input2;
|
|
905
959
|
if (category === void 0 && key_pattern === void 0) {
|
|
906
960
|
return propertyMap;
|
|
907
961
|
}
|
|
@@ -1137,7 +1191,7 @@ var GetLogsSchema = import_zod2.z.object({
|
|
|
1137
1191
|
message: "duration and start_time/end_time are mutually exclusive -- use one or the other, not both"
|
|
1138
1192
|
}
|
|
1139
1193
|
);
|
|
1140
|
-
function buildStubResponse(
|
|
1194
|
+
function buildStubResponse(input2) {
|
|
1141
1195
|
return {
|
|
1142
1196
|
ok: true,
|
|
1143
1197
|
data: {
|
|
@@ -1145,39 +1199,39 @@ function buildStubResponse(input5) {
|
|
|
1145
1199
|
endpoint: "/admin/show/logs",
|
|
1146
1200
|
status: "stub",
|
|
1147
1201
|
requested_params: {
|
|
1148
|
-
source:
|
|
1149
|
-
min_severity:
|
|
1150
|
-
duration:
|
|
1151
|
-
start_time:
|
|
1152
|
-
end_time:
|
|
1153
|
-
node_id:
|
|
1154
|
-
limit:
|
|
1202
|
+
source: input2.source,
|
|
1203
|
+
min_severity: input2.min_severity,
|
|
1204
|
+
duration: input2.duration,
|
|
1205
|
+
start_time: input2.start_time,
|
|
1206
|
+
end_time: input2.end_time,
|
|
1207
|
+
node_id: input2.node_id,
|
|
1208
|
+
limit: input2.limit
|
|
1155
1209
|
}
|
|
1156
1210
|
}
|
|
1157
1211
|
};
|
|
1158
1212
|
}
|
|
1159
|
-
async function getLogs(session2,
|
|
1213
|
+
async function getLogs(session2, input2) {
|
|
1160
1214
|
const params = {
|
|
1161
|
-
source:
|
|
1162
|
-
severity:
|
|
1163
|
-
limit:
|
|
1215
|
+
source: input2.source,
|
|
1216
|
+
severity: input2.min_severity,
|
|
1217
|
+
limit: input2.limit
|
|
1164
1218
|
};
|
|
1165
|
-
if (
|
|
1166
|
-
params.duration =
|
|
1219
|
+
if (input2.duration !== void 0) {
|
|
1220
|
+
params.duration = input2.duration;
|
|
1167
1221
|
}
|
|
1168
|
-
if (
|
|
1169
|
-
params.start_time =
|
|
1222
|
+
if (input2.start_time !== void 0) {
|
|
1223
|
+
params.start_time = input2.start_time;
|
|
1170
1224
|
}
|
|
1171
|
-
if (
|
|
1172
|
-
params.end_time =
|
|
1225
|
+
if (input2.end_time !== void 0) {
|
|
1226
|
+
params.end_time = input2.end_time;
|
|
1173
1227
|
}
|
|
1174
|
-
if (
|
|
1175
|
-
params.node_id =
|
|
1228
|
+
if (input2.node_id !== void 0) {
|
|
1229
|
+
params.node_id = input2.node_id;
|
|
1176
1230
|
}
|
|
1177
1231
|
try {
|
|
1178
1232
|
const response = await session2.makeRequest("/admin/show/logs", params);
|
|
1179
1233
|
if (!response.ok) {
|
|
1180
|
-
return buildStubResponse(
|
|
1234
|
+
return buildStubResponse(input2);
|
|
1181
1235
|
}
|
|
1182
1236
|
const raw = await response.text();
|
|
1183
1237
|
try {
|
|
@@ -1187,10 +1241,10 @@ async function getLogs(session2, input5) {
|
|
|
1187
1241
|
data
|
|
1188
1242
|
};
|
|
1189
1243
|
} catch {
|
|
1190
|
-
return buildStubResponse(
|
|
1244
|
+
return buildStubResponse(input2);
|
|
1191
1245
|
}
|
|
1192
1246
|
} catch {
|
|
1193
|
-
return buildStubResponse(
|
|
1247
|
+
return buildStubResponse(input2);
|
|
1194
1248
|
}
|
|
1195
1249
|
}
|
|
1196
1250
|
|
|
@@ -1335,12 +1389,12 @@ var ResourceGroupsSchema = import_zod4.z.object({
|
|
|
1335
1389
|
names: import_zod4.z.array(import_zod4.z.string()).optional().default([""]),
|
|
1336
1390
|
show_tier_usage: import_zod4.z.boolean().optional()
|
|
1337
1391
|
});
|
|
1338
|
-
async function getResourceGroups(session2,
|
|
1392
|
+
async function getResourceGroups(session2, input2) {
|
|
1339
1393
|
try {
|
|
1340
1394
|
const response = await session2.makeRequest("/show/resourcegroups", {
|
|
1341
|
-
names:
|
|
1395
|
+
names: input2.names,
|
|
1342
1396
|
options: {
|
|
1343
|
-
show_tier_usage: String(
|
|
1397
|
+
show_tier_usage: String(input2.show_tier_usage ?? false),
|
|
1344
1398
|
show_default_values: "true",
|
|
1345
1399
|
show_default_group: "true"
|
|
1346
1400
|
}
|
|
@@ -1391,18 +1445,18 @@ var VerifyDbSchema = import_zod5.z.object({
|
|
|
1391
1445
|
verify_persist: import_zod5.z.boolean().optional(),
|
|
1392
1446
|
verify_rank0: import_zod5.z.boolean().optional()
|
|
1393
1447
|
});
|
|
1394
|
-
async function verifyDb(session2,
|
|
1448
|
+
async function verifyDb(session2, input2) {
|
|
1395
1449
|
const options = {
|
|
1396
1450
|
concurrent_safe: "true"
|
|
1397
1451
|
};
|
|
1398
|
-
if (
|
|
1399
|
-
options.verify_nulls = String(
|
|
1452
|
+
if (input2.verify_nulls !== void 0) {
|
|
1453
|
+
options.verify_nulls = String(input2.verify_nulls);
|
|
1400
1454
|
}
|
|
1401
|
-
if (
|
|
1402
|
-
options.verify_persist = String(
|
|
1455
|
+
if (input2.verify_persist !== void 0) {
|
|
1456
|
+
options.verify_persist = String(input2.verify_persist);
|
|
1403
1457
|
}
|
|
1404
|
-
if (
|
|
1405
|
-
options.verify_rank0 = String(
|
|
1458
|
+
if (input2.verify_rank0 !== void 0) {
|
|
1459
|
+
options.verify_rank0 = String(input2.verify_rank0);
|
|
1406
1460
|
}
|
|
1407
1461
|
try {
|
|
1408
1462
|
const response = await session2.makeRequest("/admin/verifydb", { options });
|
|
@@ -1455,10 +1509,10 @@ var import_zod6 = require("zod");
|
|
|
1455
1509
|
var ShowSecuritySchema = import_zod6.z.object({
|
|
1456
1510
|
names: import_zod6.z.array(import_zod6.z.string()).optional().default([""])
|
|
1457
1511
|
});
|
|
1458
|
-
async function showSecurity(session2,
|
|
1512
|
+
async function showSecurity(session2, input2) {
|
|
1459
1513
|
try {
|
|
1460
1514
|
const response = await session2.makeRequest("/show/security", {
|
|
1461
|
-
names:
|
|
1515
|
+
names: input2.names,
|
|
1462
1516
|
options: {}
|
|
1463
1517
|
});
|
|
1464
1518
|
if (!response.ok) {
|
|
@@ -1554,10 +1608,10 @@ var ShowTableSchema = import_zod7.z.object({
|
|
|
1554
1608
|
get_access_data: import_zod7.z.boolean().optional(),
|
|
1555
1609
|
get_column_info: import_zod7.z.boolean().optional()
|
|
1556
1610
|
});
|
|
1557
|
-
function resolveColumnInfoOption(
|
|
1558
|
-
if (
|
|
1559
|
-
if (
|
|
1560
|
-
return
|
|
1611
|
+
function resolveColumnInfoOption(input2) {
|
|
1612
|
+
if (input2.get_column_info === true) return "true";
|
|
1613
|
+
if (input2.get_column_info === false) return "false";
|
|
1614
|
+
return input2.table_name !== "" ? "true" : "false";
|
|
1561
1615
|
}
|
|
1562
1616
|
function parseColumnProperties(propertiesJson) {
|
|
1563
1617
|
try {
|
|
@@ -1623,19 +1677,19 @@ async function fetchIndexes(session2, tableName) {
|
|
|
1623
1677
|
return [];
|
|
1624
1678
|
}
|
|
1625
1679
|
}
|
|
1626
|
-
async function showTable(session2,
|
|
1680
|
+
async function showTable(session2, input2) {
|
|
1627
1681
|
const options = {
|
|
1628
|
-
get_sizes: String(
|
|
1682
|
+
get_sizes: String(input2.get_sizes ?? true),
|
|
1629
1683
|
show_children: "false",
|
|
1630
1684
|
no_error_if_not_exists: "true",
|
|
1631
|
-
get_column_info: resolveColumnInfoOption(
|
|
1685
|
+
get_column_info: resolveColumnInfoOption(input2)
|
|
1632
1686
|
};
|
|
1633
|
-
if (
|
|
1634
|
-
options.get_access_data = String(
|
|
1687
|
+
if (input2.get_access_data !== void 0) {
|
|
1688
|
+
options.get_access_data = String(input2.get_access_data);
|
|
1635
1689
|
}
|
|
1636
1690
|
try {
|
|
1637
1691
|
const response = await session2.makeRequest("/show/table", {
|
|
1638
|
-
table_name:
|
|
1692
|
+
table_name: input2.table_name,
|
|
1639
1693
|
options
|
|
1640
1694
|
});
|
|
1641
1695
|
if (!response.ok) {
|
|
@@ -1687,7 +1741,7 @@ async function showTable(session2, input5) {
|
|
|
1687
1741
|
properties: properties[0] ?? ""
|
|
1688
1742
|
};
|
|
1689
1743
|
const columns = buildColumnEntries(typeSchemas?.[0], typeSchemas ? properties[0] : void 0);
|
|
1690
|
-
const indexes = await fetchIndexes(session2,
|
|
1744
|
+
const indexes = await fetchIndexes(session2, input2.table_name);
|
|
1691
1745
|
return {
|
|
1692
1746
|
ok: true,
|
|
1693
1747
|
data: { table, columns, indexes }
|
|
@@ -1722,16 +1776,16 @@ var ResourceObjectsSchema = import_zod8.z.object({
|
|
|
1722
1776
|
order_by: import_zod8.z.string().optional(),
|
|
1723
1777
|
limit: import_zod8.z.number().int().min(1).max(1e4).optional().default(100)
|
|
1724
1778
|
});
|
|
1725
|
-
async function getResourceObjects(session2,
|
|
1779
|
+
async function getResourceObjects(session2, input2) {
|
|
1726
1780
|
const options = {
|
|
1727
|
-
table_names:
|
|
1728
|
-
limit: String(
|
|
1781
|
+
table_names: input2.table_names ?? "*",
|
|
1782
|
+
limit: String(input2.limit ?? 100)
|
|
1729
1783
|
};
|
|
1730
|
-
if (
|
|
1731
|
-
options.tiers =
|
|
1784
|
+
if (input2.tiers !== void 0) {
|
|
1785
|
+
options.tiers = input2.tiers;
|
|
1732
1786
|
}
|
|
1733
|
-
if (
|
|
1734
|
-
options.order_by =
|
|
1787
|
+
if (input2.order_by !== void 0) {
|
|
1788
|
+
options.order_by = input2.order_by;
|
|
1735
1789
|
}
|
|
1736
1790
|
try {
|
|
1737
1791
|
const response = await session2.makeRequest("/show/resource/objects", {
|
|
@@ -2135,8 +2189,8 @@ function computeVerification(requestedMap, afterState) {
|
|
|
2135
2189
|
}
|
|
2136
2190
|
return "confirmed";
|
|
2137
2191
|
}
|
|
2138
|
-
async function alterSystemProperties(session2,
|
|
2139
|
-
const requestedKeys = Object.keys(
|
|
2192
|
+
async function alterSystemProperties(session2, input2) {
|
|
2193
|
+
const requestedKeys = Object.keys(input2.property_updates_map);
|
|
2140
2194
|
const disallowed = findDisallowedProperties(requestedKeys);
|
|
2141
2195
|
if (disallowed.length > 0) {
|
|
2142
2196
|
return {
|
|
@@ -2151,7 +2205,7 @@ async function alterSystemProperties(session2, input5) {
|
|
|
2151
2205
|
let rawText;
|
|
2152
2206
|
try {
|
|
2153
2207
|
mutationResponse = await session2.makeRequest("/alter/system/properties", {
|
|
2154
|
-
property_updates_map:
|
|
2208
|
+
property_updates_map: input2.property_updates_map
|
|
2155
2209
|
});
|
|
2156
2210
|
rawText = await mutationResponse.text();
|
|
2157
2211
|
} catch (error) {
|
|
@@ -2213,7 +2267,7 @@ async function alterSystemProperties(session2, input5) {
|
|
|
2213
2267
|
afterState = Object.fromEntries(
|
|
2214
2268
|
requestedKeys.filter((key) => Object.prototype.hasOwnProperty.call(verifyPropertyMap, key)).map((key) => [key, verifyPropertyMap[key]])
|
|
2215
2269
|
);
|
|
2216
|
-
verification = computeVerification(
|
|
2270
|
+
verification = computeVerification(input2.property_updates_map, afterState);
|
|
2217
2271
|
}
|
|
2218
2272
|
}
|
|
2219
2273
|
} catch {
|
|
@@ -2357,29 +2411,29 @@ async function readShardState(session2) {
|
|
|
2357
2411
|
return {};
|
|
2358
2412
|
}
|
|
2359
2413
|
}
|
|
2360
|
-
async function adminRebalance(session2,
|
|
2414
|
+
async function adminRebalance(session2, input2) {
|
|
2361
2415
|
const beforeState = await readShardState(session2);
|
|
2362
2416
|
const options = {};
|
|
2363
|
-
if (
|
|
2364
|
-
options.rebalance_sharded_data = String(
|
|
2417
|
+
if (input2.rebalance_sharded_data !== void 0) {
|
|
2418
|
+
options.rebalance_sharded_data = String(input2.rebalance_sharded_data);
|
|
2365
2419
|
}
|
|
2366
|
-
if (
|
|
2367
|
-
options.rebalance_unsharded_data = String(
|
|
2420
|
+
if (input2.rebalance_unsharded_data !== void 0) {
|
|
2421
|
+
options.rebalance_unsharded_data = String(input2.rebalance_unsharded_data);
|
|
2368
2422
|
}
|
|
2369
|
-
if (
|
|
2370
|
-
options.table_includes =
|
|
2423
|
+
if (input2.table_includes !== void 0) {
|
|
2424
|
+
options.table_includes = input2.table_includes;
|
|
2371
2425
|
}
|
|
2372
|
-
if (
|
|
2373
|
-
options.table_excludes =
|
|
2426
|
+
if (input2.table_excludes !== void 0) {
|
|
2427
|
+
options.table_excludes = input2.table_excludes;
|
|
2374
2428
|
}
|
|
2375
|
-
if (
|
|
2376
|
-
options.aggressiveness = String(
|
|
2429
|
+
if (input2.aggressiveness !== void 0) {
|
|
2430
|
+
options.aggressiveness = String(input2.aggressiveness);
|
|
2377
2431
|
}
|
|
2378
|
-
if (
|
|
2379
|
-
options.compact_after_rebalance = String(
|
|
2432
|
+
if (input2.compact_after_rebalance !== void 0) {
|
|
2433
|
+
options.compact_after_rebalance = String(input2.compact_after_rebalance);
|
|
2380
2434
|
}
|
|
2381
|
-
if (
|
|
2382
|
-
options.compact_only = String(
|
|
2435
|
+
if (input2.compact_only !== void 0) {
|
|
2436
|
+
options.compact_only = String(input2.compact_only);
|
|
2383
2437
|
}
|
|
2384
2438
|
try {
|
|
2385
2439
|
const response = await session2.makeRequest("/admin/rebalance", { options });
|
|
@@ -2452,7 +2506,7 @@ async function readCurrentConfig(session2) {
|
|
|
2452
2506
|
return void 0;
|
|
2453
2507
|
}
|
|
2454
2508
|
}
|
|
2455
|
-
async function alterConfiguration(session2,
|
|
2509
|
+
async function alterConfiguration(session2, input2) {
|
|
2456
2510
|
if (!session2.makeRequestToPort) {
|
|
2457
2511
|
return {
|
|
2458
2512
|
ok: false,
|
|
@@ -2468,7 +2522,7 @@ async function alterConfiguration(session2, input5) {
|
|
|
2468
2522
|
let rawText;
|
|
2469
2523
|
try {
|
|
2470
2524
|
mutationResponse = await session2.makeRequestToPort(hmPort, "/admin/alter/configuration", {
|
|
2471
|
-
config_string:
|
|
2525
|
+
config_string: input2.config_string
|
|
2472
2526
|
});
|
|
2473
2527
|
rawText = await mutationResponse.text();
|
|
2474
2528
|
} catch (error) {
|
|
@@ -2523,28 +2577,26 @@ async function alterConfiguration(session2, input5) {
|
|
|
2523
2577
|
|
|
2524
2578
|
// src/tools/mutation/alter-table-columns.ts
|
|
2525
2579
|
var import_zod15 = require("zod");
|
|
2526
|
-
var
|
|
2527
|
-
var import_picocolors3 = __toESM(require("picocolors"));
|
|
2580
|
+
var import_picocolors4 = __toESM(require("picocolors"));
|
|
2528
2581
|
var import_claude_agent_sdk = require("@anthropic-ai/claude-agent-sdk");
|
|
2529
2582
|
|
|
2530
2583
|
// src/approval/checklist.ts
|
|
2531
|
-
var
|
|
2532
|
-
var
|
|
2533
|
-
var DIVIDER = import_picocolors2.default.dim("\u2500".repeat(60));
|
|
2584
|
+
var import_picocolors3 = __toESM(require("picocolors"));
|
|
2585
|
+
var DIVIDER = import_picocolors3.default.dim("\u2500".repeat(60));
|
|
2534
2586
|
function renderChecklist(header, summary, items) {
|
|
2535
2587
|
const lines = [
|
|
2536
2588
|
"",
|
|
2537
2589
|
DIVIDER,
|
|
2538
|
-
` ${
|
|
2590
|
+
` ${import_picocolors3.default.bold(import_picocolors3.default.yellow(header))}`,
|
|
2539
2591
|
"",
|
|
2540
|
-
` ${
|
|
2592
|
+
` ${import_picocolors3.default.dim("Summary:")} ${summary}`,
|
|
2541
2593
|
"",
|
|
2542
|
-
` ${
|
|
2594
|
+
` ${import_picocolors3.default.bold(`${items.length} proposed column change(s):`)}`,
|
|
2543
2595
|
""
|
|
2544
2596
|
];
|
|
2545
2597
|
for (let i = 0; i < items.length; i++) {
|
|
2546
2598
|
const item = items[i];
|
|
2547
|
-
lines.push(` ${
|
|
2599
|
+
lines.push(` ${import_picocolors3.default.bold(`${i + 1}.`)} ${item.label}`, ` ${import_picocolors3.default.dim(item.description)}`);
|
|
2548
2600
|
}
|
|
2549
2601
|
lines.push("", DIVIDER, "");
|
|
2550
2602
|
return lines.join("\n");
|
|
@@ -2553,7 +2605,7 @@ async function showChecklist(header, summary, items) {
|
|
|
2553
2605
|
const panel = renderChecklist(header, summary, items);
|
|
2554
2606
|
process.stderr.write(panel);
|
|
2555
2607
|
try {
|
|
2556
|
-
const selected = await
|
|
2608
|
+
const selected = await checkbox({
|
|
2557
2609
|
message: "Select columns to alter (space to toggle, enter to confirm):",
|
|
2558
2610
|
choices: items.map((item, i) => ({
|
|
2559
2611
|
value: i,
|
|
@@ -2588,12 +2640,12 @@ function buildAlterTableSql(tableName, columns) {
|
|
|
2588
2640
|
return `ALTER TABLE ${tableName}
|
|
2589
2641
|
${clauses.join(",\n")}`;
|
|
2590
2642
|
}
|
|
2591
|
-
var SQL_DIVIDER =
|
|
2643
|
+
var SQL_DIVIDER = import_picocolors4.default.dim("\u2500".repeat(60));
|
|
2592
2644
|
async function confirmSqlExecution(sql) {
|
|
2593
2645
|
const panel = [
|
|
2594
2646
|
"",
|
|
2595
2647
|
SQL_DIVIDER,
|
|
2596
|
-
` ${
|
|
2648
|
+
` ${import_picocolors4.default.bold(import_picocolors4.default.yellow("Generated SQL:"))}`,
|
|
2597
2649
|
"",
|
|
2598
2650
|
sql.split("\n").map((line) => ` ${line}`).join("\n"),
|
|
2599
2651
|
"",
|
|
@@ -2602,7 +2654,7 @@ async function confirmSqlExecution(sql) {
|
|
|
2602
2654
|
].join("\n");
|
|
2603
2655
|
process.stderr.write(panel);
|
|
2604
2656
|
try {
|
|
2605
|
-
const response = await
|
|
2657
|
+
const response = await input({ message: "Execute? (y/n):" });
|
|
2606
2658
|
return response.trim().toLowerCase() === "y";
|
|
2607
2659
|
} catch {
|
|
2608
2660
|
return false;
|
|
@@ -2740,8 +2792,8 @@ function redactNamedField(key, value) {
|
|
|
2740
2792
|
}
|
|
2741
2793
|
return redactValue(value);
|
|
2742
2794
|
}
|
|
2743
|
-
function redactAuditInput(
|
|
2744
|
-
return Object.fromEntries(Object.entries(
|
|
2795
|
+
function redactAuditInput(input2) {
|
|
2796
|
+
return Object.fromEntries(Object.entries(input2).map(([k, v]) => [k, redactNamedField(k, v)]));
|
|
2745
2797
|
}
|
|
2746
2798
|
|
|
2747
2799
|
// src/tools/index.ts
|
|
@@ -2778,14 +2830,14 @@ function applyOutputPipeline(result) {
|
|
|
2778
2830
|
${body}` : body;
|
|
2779
2831
|
return truncateOutput(withNote);
|
|
2780
2832
|
}
|
|
2781
|
-
function logMutationAudit(toolName, result,
|
|
2782
|
-
const statusLabel = result.ok ?
|
|
2783
|
-
const redacted = redactAuditInput(
|
|
2833
|
+
function logMutationAudit(toolName, result, input2) {
|
|
2834
|
+
const statusLabel = result.ok ? import_picocolors5.default.bold(import_picocolors5.default.green("EXECUTED")) : import_picocolors5.default.bold(import_picocolors5.default.red("FAILED"));
|
|
2835
|
+
const redacted = redactAuditInput(input2);
|
|
2784
2836
|
const inputSummary = Object.entries(redacted).map(([k, v]) => `${k}=${typeof v === "string" ? v : JSON.stringify(v)}`).join(", ");
|
|
2785
2837
|
const displayName = formatToolName(toolName);
|
|
2786
2838
|
process.stderr.write(
|
|
2787
|
-
` ${
|
|
2788
|
-
${
|
|
2839
|
+
` ${import_picocolors5.default.dim("MUTATION")} ${statusLabel} ${displayName}
|
|
2840
|
+
${import_picocolors5.default.dim(inputSummary)}
|
|
2789
2841
|
|
|
2790
2842
|
`
|
|
2791
2843
|
);
|
|
@@ -3739,11 +3791,11 @@ function isValidBudget(value) {
|
|
|
3739
3791
|
function estimateTurnCostUsd(usage, model) {
|
|
3740
3792
|
if (!usage) return 0;
|
|
3741
3793
|
const price = MODEL_PRICING[model];
|
|
3742
|
-
const
|
|
3794
|
+
const input2 = safeCount(usage.inputTokens);
|
|
3743
3795
|
const output = safeCount(usage.outputTokens);
|
|
3744
3796
|
const cacheRead = safeCount(usage.cacheReadInputTokens);
|
|
3745
3797
|
const cacheCreation = safeCount(usage.cacheCreationInputTokens);
|
|
3746
|
-
return (
|
|
3798
|
+
return (input2 * price.inputPerMTok + output * price.outputPerMTok + cacheRead * price.cacheReadPerMTok + cacheCreation * price.cacheCreationPerMTok) / 1e6;
|
|
3747
3799
|
}
|
|
3748
3800
|
function resolveMaxBudgetUsd(flagValue2, env = process.env) {
|
|
3749
3801
|
if (isValidBudget(flagValue2)) return flagValue2;
|
|
@@ -4157,6 +4209,32 @@ function filterIni(entries, opts = {}) {
|
|
|
4157
4209
|
var import_node_fs4 = require("fs");
|
|
4158
4210
|
var import_node_readline = require("readline");
|
|
4159
4211
|
|
|
4212
|
+
// src/bundle/unwrap-loki-jsonl.ts
|
|
4213
|
+
var LEADING_TS_RE = /^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+)\s+/;
|
|
4214
|
+
var HEADER_BODY_SEP = " : ";
|
|
4215
|
+
function unwrapLokiJsonl(line) {
|
|
4216
|
+
let i = 0;
|
|
4217
|
+
while (i < line.length && line.charCodeAt(i) <= 32) i++;
|
|
4218
|
+
if (line.charCodeAt(i) !== 123) return void 0;
|
|
4219
|
+
let obj;
|
|
4220
|
+
try {
|
|
4221
|
+
obj = JSON.parse(line);
|
|
4222
|
+
} catch {
|
|
4223
|
+
return void 0;
|
|
4224
|
+
}
|
|
4225
|
+
if (typeof obj !== "object" || obj === null) return void 0;
|
|
4226
|
+
const inner = obj.line;
|
|
4227
|
+
if (typeof inner !== "string") return void 0;
|
|
4228
|
+
const tsMatch = LEADING_TS_RE.exec(inner);
|
|
4229
|
+
const sepIdx = inner.indexOf(HEADER_BODY_SEP);
|
|
4230
|
+
if (tsMatch && sepIdx !== -1) {
|
|
4231
|
+
const ts = tsMatch[1];
|
|
4232
|
+
const body = inner.slice(sepIdx + HEADER_BODY_SEP.length).trim();
|
|
4233
|
+
return `${ts} ${body}`;
|
|
4234
|
+
}
|
|
4235
|
+
return inner;
|
|
4236
|
+
}
|
|
4237
|
+
|
|
4160
4238
|
// src/bundle/parse-log-line.ts
|
|
4161
4239
|
var PREFIX_RE = /^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+)\s+([A-Z]+)\s+\(([^)]*)\)\s*(.*)$/;
|
|
4162
4240
|
var CORE_TAIL_RE = /^(\S+)\s+(\S+:\d+)\s+-\s+(.*)$/;
|
|
@@ -4175,9 +4253,10 @@ function severityRank(severity) {
|
|
|
4175
4253
|
return SEVERITY_RANK[severity] ?? -1;
|
|
4176
4254
|
}
|
|
4177
4255
|
function parseLogLine(line) {
|
|
4178
|
-
const
|
|
4256
|
+
const effective = unwrapLokiJsonl(line) ?? line;
|
|
4257
|
+
const match = PREFIX_RE.exec(effective);
|
|
4179
4258
|
if (!match) {
|
|
4180
|
-
return { message:
|
|
4259
|
+
return { message: effective, raw: line };
|
|
4181
4260
|
}
|
|
4182
4261
|
const [, timestamp, severity, paren, rest] = match;
|
|
4183
4262
|
const parts = paren.split(",");
|
|
@@ -4334,9 +4413,12 @@ var import_promises4 = require("fs/promises");
|
|
|
4334
4413
|
var import_node_path5 = require("path");
|
|
4335
4414
|
|
|
4336
4415
|
// src/bundle/classify-file.ts
|
|
4337
|
-
var ROLLING_ID_RE = /core-gpudb-rolling-(r\d+|hm)\.log
|
|
4416
|
+
var ROLLING_ID_RE = /core-gpudb-rolling-(r\d+|hm)\.log(?:\.\d+)?$/;
|
|
4338
4417
|
var EXE_ID_RE = /gpudb-exe-(r\d+|hm)-/;
|
|
4339
4418
|
var HOST_RE = /\b(node\w+)\b/;
|
|
4419
|
+
var LOG_RE = /\.log(?:\.\d+)?$/;
|
|
4420
|
+
var LOKI_RANK_RE = /^rank(\d+)\.log$/;
|
|
4421
|
+
var LOKI_HM_BASE = "hostmanager.log";
|
|
4340
4422
|
function rankOrService(id) {
|
|
4341
4423
|
return id === "hm" ? { service: "host-manager" } : { rank: id };
|
|
4342
4424
|
}
|
|
@@ -4352,7 +4434,7 @@ function inferHost(relPath) {
|
|
|
4352
4434
|
return HOST_RE.exec(relPath)?.[1] ?? void 0;
|
|
4353
4435
|
}
|
|
4354
4436
|
function componentName(base) {
|
|
4355
|
-
return base.replace(/(\.log)+$/, "").replace(/^core-gpudb-/, "").replace(/^gpudb-/, "").replace(/-node\w+$/, "");
|
|
4437
|
+
return base.replace(/\.\d+$/, "").replace(/(\.log)+$/, "").replace(/^core-gpudb-/, "").replace(/^gpudb-/, "").replace(/-node\w+$/, "");
|
|
4356
4438
|
}
|
|
4357
4439
|
function classifyFile(relPath) {
|
|
4358
4440
|
const base = basename2(relPath);
|
|
@@ -4374,12 +4456,17 @@ function classifyFile(relPath) {
|
|
|
4374
4456
|
if (exeId) {
|
|
4375
4457
|
return { kind: "process-info", ...rankOrService(exeId[1]), ...host ? { host } : {} };
|
|
4376
4458
|
}
|
|
4377
|
-
if (
|
|
4459
|
+
if (LOG_RE.test(base)) {
|
|
4378
4460
|
const rolling = ROLLING_ID_RE.exec(base);
|
|
4379
4461
|
if (rolling) {
|
|
4380
4462
|
return { kind: "core-log", ...rankOrService(rolling[1]), ...host ? { host } : {} };
|
|
4381
4463
|
}
|
|
4382
4464
|
if (dir === "logs") {
|
|
4465
|
+
const lokiRank = LOKI_RANK_RE.exec(base);
|
|
4466
|
+
const lokiId = lokiRank ? `r${lokiRank[1]}` : base === LOKI_HM_BASE ? "hm" : void 0;
|
|
4467
|
+
if (lokiId !== void 0) {
|
|
4468
|
+
return { kind: "loki-tail", ...rankOrService(lokiId), ...host ? { host } : {} };
|
|
4469
|
+
}
|
|
4383
4470
|
return { kind: "loki-tail", component: componentName(base), ...host ? { host } : {} };
|
|
4384
4471
|
}
|
|
4385
4472
|
return { kind: "component-log", component: componentName(base), ...host ? { host } : {} };
|
|
@@ -4428,17 +4515,25 @@ async function buildIndex(rootDir) {
|
|
|
4428
4515
|
var GPUDB_VERSION_RE = /GPUdb version\s*:\s*(\S+)/;
|
|
4429
4516
|
function selectLogFiles(index, opts) {
|
|
4430
4517
|
if (opts.component !== void 0) {
|
|
4431
|
-
return index.filter(
|
|
4518
|
+
return index.filter(
|
|
4519
|
+
(e) => (e.kind === "component-log" || e.kind === "loki-tail") && e.component === opts.component
|
|
4520
|
+
);
|
|
4432
4521
|
}
|
|
4433
4522
|
if (opts.hostManager) {
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4523
|
+
const hmCore = index.filter((e) => e.kind === "core-log" && e.service === "host-manager");
|
|
4524
|
+
if (hmCore.length > 0) return hmCore;
|
|
4525
|
+
return index.filter((e) => e.kind === "loki-tail" && e.service === "host-manager");
|
|
4526
|
+
}
|
|
4527
|
+
const matchesRank = (e) => opts.rank === void 0 || e.rank === opts.rank;
|
|
4528
|
+
const coreLogs = index.filter((e) => e.kind === "core-log" && matchesRank(e));
|
|
4529
|
+
const ranksWithCore = new Set(
|
|
4530
|
+
coreLogs.map((e) => e.rank).filter((r) => r !== void 0)
|
|
4438
4531
|
);
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4532
|
+
const supplementalTails = index.filter(
|
|
4533
|
+
(e) => e.kind === "loki-tail" && e.rank !== void 0 && matchesRank(e) && !ranksWithCore.has(e.rank)
|
|
4534
|
+
);
|
|
4535
|
+
const rankBearing = [...coreLogs, ...supplementalTails];
|
|
4536
|
+
const core = rankBearing.length > 0 ? rankBearing : index.filter((e) => e.kind === "loki-tail" && matchesRank(e));
|
|
4442
4537
|
if (opts.includeComponents) {
|
|
4443
4538
|
return [...core, ...index.filter((e) => e.kind === "component-log")];
|
|
4444
4539
|
}
|
|
@@ -4982,7 +5077,6 @@ function createBundleHolder(initial) {
|
|
|
4982
5077
|
}
|
|
4983
5078
|
|
|
4984
5079
|
// src/cli/pick-bundle-path.ts
|
|
4985
|
-
var import_prompts3 = require("@inquirer/prompts");
|
|
4986
5080
|
var import_promises7 = require("fs/promises");
|
|
4987
5081
|
var import_node_path7 = require("path");
|
|
4988
5082
|
function isPermissionError(err) {
|
|
@@ -4991,10 +5085,10 @@ function isPermissionError(err) {
|
|
|
4991
5085
|
return code === "EACCES" || code === "EPERM";
|
|
4992
5086
|
}
|
|
4993
5087
|
async function listDirectoryCandidates(term) {
|
|
4994
|
-
const
|
|
4995
|
-
const endsWithSep =
|
|
4996
|
-
const baseDir = endsWithSep ?
|
|
4997
|
-
const prefix = endsWithSep ? "" : (0, import_node_path7.basename)(
|
|
5088
|
+
const input2 = term.trim() === "" ? "." : term;
|
|
5089
|
+
const endsWithSep = input2.endsWith("/");
|
|
5090
|
+
const baseDir = endsWithSep ? input2 : (0, import_node_path7.dirname)(input2) || ".";
|
|
5091
|
+
const prefix = endsWithSep ? "" : (0, import_node_path7.basename)(input2);
|
|
4998
5092
|
const resolved = (0, import_node_path7.resolve)(baseDir);
|
|
4999
5093
|
let entries;
|
|
5000
5094
|
try {
|
|
@@ -5024,7 +5118,7 @@ function listingToChoices(listing) {
|
|
|
5024
5118
|
async function promptBundleDirectory() {
|
|
5025
5119
|
if (!process.stdin.isTTY) return void 0;
|
|
5026
5120
|
try {
|
|
5027
|
-
return await
|
|
5121
|
+
return await search({
|
|
5028
5122
|
message: "Select the support bundle directory (type to filter):",
|
|
5029
5123
|
source: async (term) => listingToChoices(await listDirectoryCandidates(term ?? ""))
|
|
5030
5124
|
});
|
|
@@ -5033,32 +5127,29 @@ async function promptBundleDirectory() {
|
|
|
5033
5127
|
}
|
|
5034
5128
|
}
|
|
5035
5129
|
|
|
5036
|
-
// src/approval/gate.ts
|
|
5037
|
-
var import_prompts4 = require("@inquirer/prompts");
|
|
5038
|
-
|
|
5039
5130
|
// src/approval/display.ts
|
|
5040
|
-
var
|
|
5131
|
+
var import_picocolors6 = __toESM(require("picocolors"));
|
|
5041
5132
|
var IMPACT_FALLBACK = "Impact unknown \u2014 review parameters carefully";
|
|
5042
|
-
var DIVIDER2 =
|
|
5133
|
+
var DIVIDER2 = import_picocolors6.default.dim("\u2500".repeat(50));
|
|
5043
5134
|
var LABEL_WIDTH = 8;
|
|
5044
5135
|
function formatLabel(label) {
|
|
5045
5136
|
return ` ${label.padEnd(LABEL_WIDTH)}: `;
|
|
5046
5137
|
}
|
|
5047
5138
|
function renderApprovalPanel(toolName, toolInput, impact, beforeAfter, reasoningSummary) {
|
|
5048
|
-
const header =
|
|
5049
|
-
const action = `${formatLabel("Action")}${
|
|
5139
|
+
const header = import_picocolors6.default.bold(import_picocolors6.default.yellow(" Mutation Approval Required"));
|
|
5140
|
+
const action = `${formatLabel("Action")}${import_picocolors6.default.bold(formatToolName(toolName))}`;
|
|
5050
5141
|
const paramEntries = Object.entries(toolInput);
|
|
5051
5142
|
const paramSection = paramEntries.length === 0 ? " (no parameters)" : paramEntries.map(([key, value]) => {
|
|
5052
5143
|
const formatted = typeof value === "string" ? value : JSON.stringify(value, null, 2);
|
|
5053
|
-
return ` ${
|
|
5144
|
+
return ` ${import_picocolors6.default.dim(key)}: ${formatted}`;
|
|
5054
5145
|
}).join("\n");
|
|
5055
5146
|
const impactLine = `${formatLabel("Impact")}${impact ?? IMPACT_FALLBACK}`;
|
|
5056
|
-
const prompt =
|
|
5147
|
+
const prompt = import_picocolors6.default.dim(
|
|
5057
5148
|
`${formatLabel("Respond")}y (proceed) | n (abort) | explain (show reasoning)`
|
|
5058
5149
|
);
|
|
5059
5150
|
const hasBeforeAfter = beforeAfter !== void 0 && beforeAfter.length > 0;
|
|
5060
5151
|
const beforeAfterSection = hasBeforeAfter ? beforeAfter.map(
|
|
5061
|
-
(entry) => ` ${
|
|
5152
|
+
(entry) => ` ${import_picocolors6.default.dim(entry.key)}: ${entry.current} ${import_picocolors6.default.yellow("->")} ${entry.proposed}`
|
|
5062
5153
|
).join("\n") : null;
|
|
5063
5154
|
const hasReasoning = reasoningSummary !== void 0 && reasoningSummary.length > 0;
|
|
5064
5155
|
const reasoningSection = hasReasoning ? `${formatLabel("Reason")}${reasoningSummary}` : null;
|
|
@@ -5090,7 +5181,7 @@ function createApprovalGate(isReadOnly) {
|
|
|
5090
5181
|
console.error(panel);
|
|
5091
5182
|
while (true) {
|
|
5092
5183
|
try {
|
|
5093
|
-
const raw = await
|
|
5184
|
+
const raw = await input({ message: "Proceed? (y/n/explain):" }, { signal: options.signal });
|
|
5094
5185
|
const normalized = raw.trim().toLowerCase();
|
|
5095
5186
|
if (normalized === "y") {
|
|
5096
5187
|
process.stderr.write("\n");
|
|
@@ -5152,26 +5243,74 @@ function createTurnGate() {
|
|
|
5152
5243
|
}
|
|
5153
5244
|
|
|
5154
5245
|
// src/output/render-markdown.ts
|
|
5155
|
-
var
|
|
5156
|
-
var BOLD_RE = /\*\*(.+?)\*\*/g;
|
|
5246
|
+
var import_picocolors7 = __toESM(require("picocolors"));
|
|
5157
5247
|
var HEADING_RE = /^(#{1,6})\s+(.+)$/;
|
|
5248
|
+
var HRULE_RE = /^\s*([-*_])\1{2,}\s*$/;
|
|
5249
|
+
var BULLET_RE = /^(\s*)[-*+]\s+(.*)$/;
|
|
5250
|
+
var BOLD_RE = /\*\*(.+?)\*\*/g;
|
|
5251
|
+
var INLINE_CODE_RE = /`([^`]+)`/g;
|
|
5252
|
+
var UPPERWORD_RE = /[A-Z]{2,}/;
|
|
5253
|
+
var ANSI_RE = /\x1b\[[0-9;]*m/g;
|
|
5254
|
+
var DEFAULT_WIDTH = 80;
|
|
5255
|
+
function terminalWidth() {
|
|
5256
|
+
const cols = process.stderr.columns;
|
|
5257
|
+
return typeof cols === "number" && cols > 0 ? cols : DEFAULT_WIDTH;
|
|
5258
|
+
}
|
|
5259
|
+
var SEVERITY_RULES = [
|
|
5260
|
+
{ re: /\b(FATAL|ERROR|UERR|CRITICAL|SEGV|SIGSEGV)\b/, color: import_picocolors7.default.red, glyph: "\u2717" },
|
|
5261
|
+
{ re: /\b(WARN|WARNING)\b/, color: import_picocolors7.default.yellow, glyph: "\u26A0" },
|
|
5262
|
+
{ re: /\b(OK|PASS|PASSED|HEALTHY)\b/, color: import_picocolors7.default.green, glyph: "\u2713" }
|
|
5263
|
+
];
|
|
5264
|
+
function firstSeverityRule(text2) {
|
|
5265
|
+
return SEVERITY_RULES.find((rule) => rule.re.test(text2));
|
|
5266
|
+
}
|
|
5267
|
+
function styleInline(text2) {
|
|
5268
|
+
let out = text2;
|
|
5269
|
+
if (out.includes("`")) out = out.replace(INLINE_CODE_RE, (_, code) => purple(code));
|
|
5270
|
+
if (out.includes("**")) out = out.replace(BOLD_RE, (_, b) => import_picocolors7.default.bold(b));
|
|
5271
|
+
if (UPPERWORD_RE.test(out)) {
|
|
5272
|
+
for (const rule of SEVERITY_RULES) {
|
|
5273
|
+
out = out.replace(rule.re, (token) => rule.color(token));
|
|
5274
|
+
}
|
|
5275
|
+
}
|
|
5276
|
+
return out;
|
|
5277
|
+
}
|
|
5278
|
+
function bulletFor(itemText) {
|
|
5279
|
+
const rule = firstSeverityRule(itemText);
|
|
5280
|
+
return rule ? rule.color(rule.glyph) : purple("\u2022");
|
|
5281
|
+
}
|
|
5282
|
+
function visibleWidth(text2) {
|
|
5283
|
+
return styleInline(text2).replace(ANSI_RE, "").length;
|
|
5284
|
+
}
|
|
5158
5285
|
function renderMarkdownLine(line) {
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5286
|
+
if (HRULE_RE.test(line)) {
|
|
5287
|
+
return import_picocolors7.default.dim("\u2500".repeat(terminalWidth()));
|
|
5288
|
+
}
|
|
5289
|
+
const heading = HEADING_RE.exec(line);
|
|
5290
|
+
if (heading) {
|
|
5291
|
+
const level = heading[1].length;
|
|
5292
|
+
const text2 = heading[2];
|
|
5293
|
+
if (level === 1) {
|
|
5294
|
+
return `
|
|
5295
|
+
${import_picocolors7.default.bold(pink(text2))}
|
|
5296
|
+
${import_picocolors7.default.dim("\u2500".repeat(terminalWidth()))}`;
|
|
5297
|
+
}
|
|
5298
|
+
if (level === 2) {
|
|
5299
|
+
return `
|
|
5300
|
+
${import_picocolors7.default.bold(pink(`\u258C ${text2}`))}`;
|
|
5301
|
+
}
|
|
5302
|
+
return import_picocolors7.default.bold(purple(text2));
|
|
5162
5303
|
}
|
|
5163
|
-
|
|
5164
|
-
|
|
5304
|
+
const bullet = BULLET_RE.exec(line);
|
|
5305
|
+
if (bullet) {
|
|
5306
|
+
const [, indent, item] = bullet;
|
|
5307
|
+
return `${indent}${bulletFor(item)} ${styleInline(item)}`;
|
|
5165
5308
|
}
|
|
5166
|
-
return line;
|
|
5309
|
+
return styleInline(line);
|
|
5167
5310
|
}
|
|
5168
5311
|
|
|
5169
5312
|
// src/output/reformat-tables.ts
|
|
5170
5313
|
var SEPARATOR_CELL_RE = /^:?-+:?$/;
|
|
5171
|
-
var BOLD_MARKERS_RE = /\*\*(.+?)\*\*/g;
|
|
5172
|
-
function visualWidth(text2) {
|
|
5173
|
-
return text2.replace(BOLD_MARKERS_RE, "$1").length;
|
|
5174
|
-
}
|
|
5175
5314
|
function isSeparatorCell(cell) {
|
|
5176
5315
|
return SEPARATOR_CELL_RE.test(cell);
|
|
5177
5316
|
}
|
|
@@ -5195,7 +5334,7 @@ function reformatTableBlock(lines) {
|
|
|
5195
5334
|
{ length: colCount },
|
|
5196
5335
|
(_, col) => Math.max(
|
|
5197
5336
|
3,
|
|
5198
|
-
...normalised.filter((row) => !isSeparatorRow(row)).map((row) =>
|
|
5337
|
+
...normalised.filter((row) => !isSeparatorRow(row)).map((row) => visibleWidth(row[col]))
|
|
5199
5338
|
)
|
|
5200
5339
|
);
|
|
5201
5340
|
const borderRow = `+${colWidths.map((w) => "-".repeat(w + 2)).join("+")}+`;
|
|
@@ -5204,8 +5343,8 @@ function reformatTableBlock(lines) {
|
|
|
5204
5343
|
return borderRow;
|
|
5205
5344
|
}
|
|
5206
5345
|
const cells = row.map((cell, col) => {
|
|
5207
|
-
const rendered =
|
|
5208
|
-
const pad = colWidths[col] -
|
|
5346
|
+
const rendered = styleInline(cell);
|
|
5347
|
+
const pad = colWidths[col] - visibleWidth(cell);
|
|
5209
5348
|
return rendered + " ".repeat(Math.max(0, pad));
|
|
5210
5349
|
});
|
|
5211
5350
|
return `| ${cells.join(" | ")} |`;
|
|
@@ -5254,7 +5393,7 @@ function createStreamingTableAligner() {
|
|
|
5254
5393
|
}
|
|
5255
5394
|
|
|
5256
5395
|
// src/output/spinner.ts
|
|
5257
|
-
var
|
|
5396
|
+
var import_picocolors8 = __toESM(require("picocolors"));
|
|
5258
5397
|
var FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
5259
5398
|
var FRAME_INTERVAL_MS = 80;
|
|
5260
5399
|
var DEFAULT_LABEL = "Thinking";
|
|
@@ -5266,7 +5405,7 @@ function createSpinner() {
|
|
|
5266
5405
|
frameIndex = 0;
|
|
5267
5406
|
timer = setInterval(() => {
|
|
5268
5407
|
const frame = FRAMES[frameIndex % FRAMES.length];
|
|
5269
|
-
process.stderr.write(`\r${
|
|
5408
|
+
process.stderr.write(`\r${import_picocolors8.default.dim(`${frame} ${label}...`)}`);
|
|
5270
5409
|
frameIndex += 1;
|
|
5271
5410
|
}, FRAME_INTERVAL_MS);
|
|
5272
5411
|
timer.unref();
|
|
@@ -5339,7 +5478,9 @@ async function* makeInteractivePrompt(abortController, turnGate, spinner) {
|
|
|
5339
5478
|
while (!abortController.signal.aborted) {
|
|
5340
5479
|
try {
|
|
5341
5480
|
process.stderr.write("\n");
|
|
5342
|
-
const issue = await
|
|
5481
|
+
const issue = await input({
|
|
5482
|
+
message: "Describe the issue to investigate:"
|
|
5483
|
+
});
|
|
5343
5484
|
process.stderr.write("\n");
|
|
5344
5485
|
const trimmed = issue.trim();
|
|
5345
5486
|
if (!trimmed) continue;
|
|
@@ -5356,7 +5497,7 @@ async function* makeInteractivePrompt(abortController, turnGate, spinner) {
|
|
|
5356
5497
|
await turnGate.wait();
|
|
5357
5498
|
if (abortController.signal.aborted) break;
|
|
5358
5499
|
process.stderr.write("\n");
|
|
5359
|
-
const response = await
|
|
5500
|
+
const response = await input({ message: "You:" });
|
|
5360
5501
|
process.stderr.write("\n");
|
|
5361
5502
|
const trimmed = response.trim();
|
|
5362
5503
|
if (!trimmed) continue;
|
|
@@ -5374,33 +5515,33 @@ async function displayDegradedStatus(session2) {
|
|
|
5374
5515
|
hostManagerStatus(session2),
|
|
5375
5516
|
hostManagerAlerts(session2)
|
|
5376
5517
|
]);
|
|
5377
|
-
process.stderr.write(
|
|
5518
|
+
process.stderr.write(import_picocolors9.default.bold("\u2500\u2500 Host Manager Status \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n"));
|
|
5378
5519
|
if (statusResult.ok) {
|
|
5379
5520
|
const rows = statusResult.data;
|
|
5380
5521
|
const maxKeyLen = rows.reduce((max, r) => Math.max(max, r.key.length), 0);
|
|
5381
5522
|
for (const row of rows) {
|
|
5382
|
-
process.stderr.write(` ${
|
|
5523
|
+
process.stderr.write(` ${import_picocolors9.default.dim(row.key.padEnd(maxKeyLen))} ${row.value}
|
|
5383
5524
|
`);
|
|
5384
5525
|
}
|
|
5385
5526
|
} else {
|
|
5386
|
-
process.stderr.write(` ${
|
|
5527
|
+
process.stderr.write(` ${import_picocolors9.default.red(`Error: ${statusResult.error}`)}
|
|
5387
5528
|
`);
|
|
5388
5529
|
}
|
|
5389
5530
|
process.stderr.write("\n");
|
|
5390
|
-
process.stderr.write(
|
|
5531
|
+
process.stderr.write(import_picocolors9.default.bold("\u2500\u2500 Recent Alerts \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n"));
|
|
5391
5532
|
if (alertsResult.ok) {
|
|
5392
5533
|
const alerts = alertsResult.data;
|
|
5393
5534
|
if (alerts.length === 0) {
|
|
5394
|
-
process.stderr.write(` ${
|
|
5535
|
+
process.stderr.write(` ${import_picocolors9.default.dim("No recent alerts.")}
|
|
5395
5536
|
`);
|
|
5396
5537
|
} else {
|
|
5397
5538
|
for (const alert of alerts) {
|
|
5398
|
-
process.stderr.write(` ${
|
|
5539
|
+
process.stderr.write(` ${import_picocolors9.default.dim(alert.timestamp)} ${alert.type} ${alert.params}
|
|
5399
5540
|
`);
|
|
5400
5541
|
}
|
|
5401
5542
|
}
|
|
5402
5543
|
} else {
|
|
5403
|
-
process.stderr.write(` ${
|
|
5544
|
+
process.stderr.write(` ${import_picocolors9.default.dim(`Unavailable: ${alertsResult.error}`)}
|
|
5404
5545
|
`);
|
|
5405
5546
|
}
|
|
5406
5547
|
process.stderr.write("\n");
|
|
@@ -5429,13 +5570,13 @@ async function runAgent(session2, kineticaVersion, degraded, model, runOptions)
|
|
|
5429
5570
|
const budget = checkPromptBudget(systemPrompt);
|
|
5430
5571
|
if (process.env.DEBUG) {
|
|
5431
5572
|
process.stderr.write(
|
|
5432
|
-
|
|
5573
|
+
import_picocolors9.default.dim(`System prompt: ~${budget.tokens} tokens (${budget.chars} chars)
|
|
5433
5574
|
`)
|
|
5434
5575
|
);
|
|
5435
5576
|
}
|
|
5436
5577
|
if (budget.overBudget) {
|
|
5437
5578
|
process.stderr.write(
|
|
5438
|
-
|
|
5579
|
+
import_picocolors9.default.yellow(
|
|
5439
5580
|
`\u26A0 system prompt is ~${budget.tokens} tokens (threshold ${budget.threshold}) \u2014 knowledge corpus is getting expensive; consider keyword-based playbook selection.
|
|
5440
5581
|
`
|
|
5441
5582
|
)
|
|
@@ -5453,7 +5594,7 @@ async function runAgent(session2, kineticaVersion, degraded, model, runOptions)
|
|
|
5453
5594
|
const confirmPath = async (path2) => {
|
|
5454
5595
|
spinner.stop();
|
|
5455
5596
|
try {
|
|
5456
|
-
const answer = await
|
|
5597
|
+
const answer = await input({
|
|
5457
5598
|
message: `Load support bundle from "${path2}"? The agent will be able to read files under that directory. (y/n):`
|
|
5458
5599
|
});
|
|
5459
5600
|
return answer.trim().toLowerCase() === "y";
|
|
@@ -5510,8 +5651,8 @@ async function runAgent(session2, kineticaVersion, degraded, model, runOptions)
|
|
|
5510
5651
|
abortController,
|
|
5511
5652
|
env: { ...process.env, CLAUDE_AGENT_SDK_CLIENT_APP: "admin-agent" }
|
|
5512
5653
|
};
|
|
5513
|
-
const guardLine = dollarCapped ?
|
|
5514
|
-
`) :
|
|
5654
|
+
const guardLine = dollarCapped ? import_picocolors9.default.dim(`Budget guard: $${resolvedBudgetUsd.toFixed(2)} (raise with --max-budget)
|
|
5655
|
+
`) : import_picocolors9.default.dim("Budget guard: subscription (Pro/Max) \u2014 turn-limited\n");
|
|
5515
5656
|
const bundleSummary = () => {
|
|
5516
5657
|
const src = bundleHolder.get();
|
|
5517
5658
|
if (!src) return "";
|
|
@@ -5536,7 +5677,7 @@ async function runAgent(session2, kineticaVersion, degraded, model, runOptions)
|
|
|
5536
5677
|
);
|
|
5537
5678
|
} else {
|
|
5538
5679
|
process.stderr.write(
|
|
5539
|
-
|
|
5680
|
+
import_picocolors9.default.dim("Tip: ask me to analyze a support bundle to add offline log/config analysis.\n")
|
|
5540
5681
|
);
|
|
5541
5682
|
}
|
|
5542
5683
|
} else {
|
|
@@ -5603,7 +5744,7 @@ async function runAgent(session2, kineticaVersion, degraded, model, runOptions)
|
|
|
5603
5744
|
if (budgetTracker.shouldWarn()) {
|
|
5604
5745
|
spinner.stop();
|
|
5605
5746
|
process.stderr.write(
|
|
5606
|
-
|
|
5747
|
+
import_picocolors9.default.yellow(
|
|
5607
5748
|
`
|
|
5608
5749
|
\u26A0 Approaching budget guard (~$${budgetTracker.spentUsd().toFixed(2)} / $${resolvedBudgetUsd.toFixed(2)}) \u2014 wrapping up soon. Save a partial report now if you want to preserve findings.
|
|
5609
5750
|
`
|
|
@@ -5626,7 +5767,7 @@ async function runAgent(session2, kineticaVersion, degraded, model, runOptions)
|
|
|
5626
5767
|
if (assistantMsg.error) {
|
|
5627
5768
|
spinner.stop();
|
|
5628
5769
|
const label = ERROR_LABELS[assistantMsg.error] ?? assistantMsg.error;
|
|
5629
|
-
process.stderr.write(
|
|
5770
|
+
process.stderr.write(import_picocolors9.default.yellow(`
|
|
5630
5771
|
API error: ${label}
|
|
5631
5772
|
`));
|
|
5632
5773
|
turnGate.open();
|
|
@@ -5643,7 +5784,7 @@ API error: ${label}
|
|
|
5643
5784
|
cacheCreationTokens = usages.reduce((sum, u) => sum + (u.cacheCreationInputTokens ?? 0), 0);
|
|
5644
5785
|
if (resultMsg.subtype === "error_max_turns") {
|
|
5645
5786
|
process.stderr.write(
|
|
5646
|
-
|
|
5787
|
+
import_picocolors9.default.yellow(
|
|
5647
5788
|
`
|
|
5648
5789
|
Reached the turn limit (${numTurns} turns) \u2014 a safety guard, not an error. Any report the agent saved is in reports/. Start a fresh session to continue.
|
|
5649
5790
|
`
|
|
@@ -5652,7 +5793,7 @@ Reached the turn limit (${numTurns} turns) \u2014 a safety guard, not an error.
|
|
|
5652
5793
|
} else if (resultMsg.subtype === "error_max_budget_usd") {
|
|
5653
5794
|
const spentStr = totalCostUsd > 0 ? ` ($${totalCostUsd.toFixed(2)} spent)` : "";
|
|
5654
5795
|
process.stderr.write(
|
|
5655
|
-
|
|
5796
|
+
import_picocolors9.default.yellow(
|
|
5656
5797
|
`
|
|
5657
5798
|
Reached the $${resolvedBudgetUsd.toFixed(2)} budget guard${spentStr} \u2014 a safety limit, not an error. Re-run with --max-budget=<amount> (or set ADMIN_AGENT_MAX_BUDGET) for more headroom. Any report the agent saved is in reports/.
|
|
5658
5799
|
`
|
|
@@ -5711,7 +5852,7 @@ Warning: MCP server "${s.name}" failed to connect (${s.status})
|
|
|
5711
5852
|
const statusStr = retryMsg.error_status !== null ? ` (HTTP ${retryMsg.error_status})` : "";
|
|
5712
5853
|
const delaySec = Math.round(retryMsg.retry_delay_ms / 1e3);
|
|
5713
5854
|
process.stderr.write(
|
|
5714
|
-
|
|
5855
|
+
import_picocolors9.default.yellow(
|
|
5715
5856
|
`
|
|
5716
5857
|
API error${statusStr}. Retrying (attempt ${retryMsg.attempt}/${retryMsg.max_retries}) in ${delaySec}s...
|
|
5717
5858
|
`
|
|
@@ -5740,7 +5881,7 @@ Rate limited \u2014 requests rejected.${resetStr}
|
|
|
5740
5881
|
} else if (message.type === "control_request") {
|
|
5741
5882
|
const controlMsg = message;
|
|
5742
5883
|
if (controlMsg.request.subtype === "claude_authenticate") {
|
|
5743
|
-
process.stderr.write(
|
|
5884
|
+
process.stderr.write(import_picocolors9.default.yellow("\nRe-authentication requested by SDK...\n"));
|
|
5744
5885
|
}
|
|
5745
5886
|
}
|
|
5746
5887
|
}
|
|
@@ -5751,7 +5892,7 @@ Rate limited \u2014 requests rejected.${resetStr}
|
|
|
5751
5892
|
} else {
|
|
5752
5893
|
hadNonAbortError = true;
|
|
5753
5894
|
const message = error instanceof Error ? error.message : String(error);
|
|
5754
|
-
process.stderr.write(
|
|
5895
|
+
process.stderr.write(import_picocolors9.default.red(`
|
|
5755
5896
|
Agent error: ${message}
|
|
5756
5897
|
`));
|
|
5757
5898
|
}
|
|
@@ -5765,7 +5906,7 @@ Agent error: ${message}
|
|
|
5765
5906
|
const sessionCost = dollarCapped ? totalCostUsd : void 0;
|
|
5766
5907
|
if (process.env.DEBUG && (cacheReadTokens > 0 || cacheCreationTokens > 0)) {
|
|
5767
5908
|
process.stderr.write(
|
|
5768
|
-
|
|
5909
|
+
import_picocolors9.default.dim(
|
|
5769
5910
|
`Cache: ${cacheReadTokens} read / ${cacheCreationTokens} created input tokens (read > 0 confirms the system prompt is served from cache)
|
|
5770
5911
|
`
|
|
5771
5912
|
)
|
|
@@ -5793,7 +5934,7 @@ var MODEL_LABELS = {
|
|
|
5793
5934
|
opus: "Opus \u2014 deepest reasoning, slower & pricier"
|
|
5794
5935
|
};
|
|
5795
5936
|
async function selectModel() {
|
|
5796
|
-
return
|
|
5937
|
+
return select({
|
|
5797
5938
|
message: "Select model for this session:",
|
|
5798
5939
|
default: DEFAULT_AGENT_MODEL,
|
|
5799
5940
|
choices: SUPPORTED_MODELS.map((value) => ({ value, name: MODEL_LABELS[value] }))
|
|
@@ -5804,7 +5945,7 @@ async function selectModel() {
|
|
|
5804
5945
|
var import_claude_agent_sdk6 = require("@anthropic-ai/claude-agent-sdk");
|
|
5805
5946
|
|
|
5806
5947
|
// src/auth/oauth-flow.ts
|
|
5807
|
-
var
|
|
5948
|
+
var import_picocolors10 = __toESM(require("picocolors"));
|
|
5808
5949
|
|
|
5809
5950
|
// src/auth/open-browser.ts
|
|
5810
5951
|
var import_child_process = require("child_process");
|
|
@@ -5830,21 +5971,21 @@ async function resolveAuthentication(agentQuery, options) {
|
|
|
5830
5971
|
const { manualUrl, automaticUrl } = await query3.claudeAuthenticate(options.loginWithClaudeAi);
|
|
5831
5972
|
const opened = openBrowser(automaticUrl);
|
|
5832
5973
|
if (opened) {
|
|
5833
|
-
process.stderr.write(
|
|
5974
|
+
process.stderr.write(import_picocolors10.default.dim("Browser opened for login. Waiting for authentication...\n"));
|
|
5834
5975
|
} else {
|
|
5835
5976
|
process.stderr.write(`
|
|
5836
5977
|
Open this URL in your browser to log in:
|
|
5837
|
-
${
|
|
5978
|
+
${import_picocolors10.default.bold(manualUrl)}
|
|
5838
5979
|
|
|
5839
5980
|
`);
|
|
5840
|
-
process.stderr.write(
|
|
5981
|
+
process.stderr.write(import_picocolors10.default.dim("Waiting for browser login to complete...\n"));
|
|
5841
5982
|
}
|
|
5842
5983
|
await query3.claudeOAuthWaitForCompletion();
|
|
5843
5984
|
return { method: "oauth" };
|
|
5844
5985
|
} catch (err) {
|
|
5845
5986
|
const message = err instanceof Error ? err.message : String(err);
|
|
5846
5987
|
process.stderr.write(
|
|
5847
|
-
|
|
5988
|
+
import_picocolors10.default.yellow(`
|
|
5848
5989
|
Warning: OAuth login failed (${message}). SDK may retry automatically.
|
|
5849
5990
|
`)
|
|
5850
5991
|
);
|
|
@@ -5948,8 +6089,7 @@ async function logout() {
|
|
|
5948
6089
|
var import_fs2 = require("fs");
|
|
5949
6090
|
var import_promises8 = require("fs/promises");
|
|
5950
6091
|
var import_path2 = require("path");
|
|
5951
|
-
var
|
|
5952
|
-
var import_picocolors10 = __toESM(require("picocolors"));
|
|
6092
|
+
var import_picocolors11 = __toESM(require("picocolors"));
|
|
5953
6093
|
function parseEnvContent(content) {
|
|
5954
6094
|
const entries = [];
|
|
5955
6095
|
for (const line of content.split("\n")) {
|
|
@@ -6031,7 +6171,7 @@ function loadEnvFile(dir, env = process.env) {
|
|
|
6031
6171
|
async function offerSaveCredentials(url, user, dir) {
|
|
6032
6172
|
if (!process.stdin.isTTY) return;
|
|
6033
6173
|
try {
|
|
6034
|
-
const shouldSave = await
|
|
6174
|
+
const shouldSave = await confirm({
|
|
6035
6175
|
message: "Save KINETICA_URL and KINETICA_USER to .env? (password is never saved)",
|
|
6036
6176
|
default: true
|
|
6037
6177
|
});
|
|
@@ -6044,47 +6184,45 @@ async function offerSaveCredentials(url, user, dir) {
|
|
|
6044
6184
|
}
|
|
6045
6185
|
const content = buildEnvContent(url, user, existing);
|
|
6046
6186
|
await (0, import_promises8.writeFile)(filePath, content, "utf8");
|
|
6047
|
-
console.error(
|
|
6187
|
+
console.error(import_picocolors11.default.dim("Saved to .env"));
|
|
6048
6188
|
} catch (err) {
|
|
6049
6189
|
const message = err instanceof Error ? err.message : String(err);
|
|
6050
|
-
console.error(
|
|
6190
|
+
console.error(import_picocolors11.default.yellow(`Could not save .env file: ${message}`));
|
|
6051
6191
|
}
|
|
6052
6192
|
}
|
|
6053
6193
|
|
|
6054
6194
|
// src/session/verify.ts
|
|
6055
|
-
var
|
|
6056
|
-
var import_prompts10 = require("@inquirer/prompts");
|
|
6195
|
+
var import_picocolors14 = __toESM(require("picocolors"));
|
|
6057
6196
|
|
|
6058
6197
|
// src/session/collect.ts
|
|
6059
|
-
var
|
|
6060
|
-
var import_picocolors11 = __toESM(require("picocolors"));
|
|
6198
|
+
var import_picocolors12 = __toESM(require("picocolors"));
|
|
6061
6199
|
async function collectCredentials() {
|
|
6062
6200
|
const prompted = /* @__PURE__ */ new Set();
|
|
6063
6201
|
const envUrl = process.env.KINETICA_URL;
|
|
6064
6202
|
const envUser = process.env.KINETICA_USER;
|
|
6065
6203
|
if (envUrl && envUser && process.stdin.isTTY) {
|
|
6066
|
-
console.error(
|
|
6067
|
-
const useSaved = await
|
|
6204
|
+
console.error(import_picocolors12.default.dim(`Saved connection: ${envUrl} (${envUser})`));
|
|
6205
|
+
const useSaved = await confirm({
|
|
6068
6206
|
message: "Use saved connection?",
|
|
6069
6207
|
default: true
|
|
6070
6208
|
});
|
|
6071
6209
|
if (!useSaved) {
|
|
6072
6210
|
prompted.add("url");
|
|
6073
6211
|
prompted.add("user");
|
|
6074
|
-
const url2 = await
|
|
6075
|
-
const user2 = await
|
|
6076
|
-
const pass2 = await
|
|
6212
|
+
const url2 = await input({ message: "Kinetica endpoint URL:" });
|
|
6213
|
+
const user2 = await input({ message: "Admin username:" });
|
|
6214
|
+
const pass2 = await password({ message: "Admin password:", mask: "*" });
|
|
6077
6215
|
return { credentials: { url: url2, user: user2, pass: pass2 }, prompted };
|
|
6078
6216
|
}
|
|
6079
6217
|
}
|
|
6080
|
-
const url = envUrl ?? (prompted.add("url"), await
|
|
6081
|
-
const user = envUser ?? (prompted.add("user"), await
|
|
6082
|
-
const pass = process.env.KINETICA_PASS ?? await
|
|
6218
|
+
const url = envUrl ?? (prompted.add("url"), await input({ message: "Kinetica endpoint URL:" }));
|
|
6219
|
+
const user = envUser ?? (prompted.add("user"), await input({ message: "Admin username:" }));
|
|
6220
|
+
const pass = process.env.KINETICA_PASS ?? await password({ message: "Admin password:", mask: "*" });
|
|
6083
6221
|
return { credentials: { url, user, pass }, prompted };
|
|
6084
6222
|
}
|
|
6085
6223
|
async function repromptCredentials() {
|
|
6086
|
-
const user = await
|
|
6087
|
-
const pass = await
|
|
6224
|
+
const user = await input({ message: "Admin username:" });
|
|
6225
|
+
const pass = await password({ message: "Admin password:", mask: "*" });
|
|
6088
6226
|
return { user, pass };
|
|
6089
6227
|
}
|
|
6090
6228
|
|
|
@@ -6120,13 +6258,12 @@ function createSession(url, user, pass, options) {
|
|
|
6120
6258
|
}
|
|
6121
6259
|
|
|
6122
6260
|
// src/session/resolve-url.ts
|
|
6123
|
-
var
|
|
6124
|
-
var import_prompts9 = require("@inquirer/prompts");
|
|
6261
|
+
var import_picocolors13 = __toESM(require("picocolors"));
|
|
6125
6262
|
var PROBE_TIMEOUT_MS2 = 3e3;
|
|
6126
6263
|
var HTTP_PROTOCOL_RE = /^https?:\/\//i;
|
|
6127
6264
|
var ANY_PROTOCOL_RE = /^[a-z][a-z0-9+.-]*:\/\//i;
|
|
6128
|
-
function hasProtocol(
|
|
6129
|
-
return HTTP_PROTOCOL_RE.test(
|
|
6265
|
+
function hasProtocol(input2) {
|
|
6266
|
+
return HTTP_PROTOCOL_RE.test(input2);
|
|
6130
6267
|
}
|
|
6131
6268
|
function stripTrailingSlashes(url) {
|
|
6132
6269
|
return url.replace(/\/+$/, "");
|
|
@@ -6150,20 +6287,20 @@ function isInteractive() {
|
|
|
6150
6287
|
}
|
|
6151
6288
|
async function confirmHttpFallback(host) {
|
|
6152
6289
|
process.stderr.write(
|
|
6153
|
-
"\n" +
|
|
6154
|
-
|
|
6290
|
+
"\n" + import_picocolors13.default.red(
|
|
6291
|
+
import_picocolors13.default.bold(
|
|
6155
6292
|
` WARNING: HTTPS unavailable at ${host}.
|
|
6156
6293
|
Falling back to plaintext HTTP will transmit your Kinetica credentials in the clear.
|
|
6157
6294
|
`
|
|
6158
6295
|
)
|
|
6159
|
-
) +
|
|
6296
|
+
) + import_picocolors13.default.dim(
|
|
6160
6297
|
` Set KINETICA_HTTPS_ONLY=1 to refuse this fallback automatically, or pass an explicit http:// prefix to silence this prompt.
|
|
6161
6298
|
|
|
6162
6299
|
`
|
|
6163
6300
|
)
|
|
6164
6301
|
);
|
|
6165
6302
|
try {
|
|
6166
|
-
return await
|
|
6303
|
+
return await confirm({
|
|
6167
6304
|
message: "Continue over plaintext HTTP?",
|
|
6168
6305
|
default: false
|
|
6169
6306
|
});
|
|
@@ -6171,8 +6308,8 @@ async function confirmHttpFallback(host) {
|
|
|
6171
6308
|
return false;
|
|
6172
6309
|
}
|
|
6173
6310
|
}
|
|
6174
|
-
async function resolveUrl(
|
|
6175
|
-
const trimmed =
|
|
6311
|
+
async function resolveUrl(input2, options = {}) {
|
|
6312
|
+
const trimmed = input2.trim();
|
|
6176
6313
|
if (trimmed === "") {
|
|
6177
6314
|
return { ok: false, error: "URL is empty" };
|
|
6178
6315
|
}
|
|
@@ -6189,7 +6326,7 @@ async function resolveUrl(input5, options = {}) {
|
|
|
6189
6326
|
}
|
|
6190
6327
|
const httpsUrl = `https://${normalized}`;
|
|
6191
6328
|
const httpUrl = `http://${normalized}`;
|
|
6192
|
-
console.error(
|
|
6329
|
+
console.error(import_picocolors13.default.dim("Detecting protocol..."));
|
|
6193
6330
|
if (await probeProtocol(httpsUrl)) {
|
|
6194
6331
|
return { ok: true, url: httpsUrl };
|
|
6195
6332
|
}
|
|
@@ -6294,7 +6431,7 @@ async function connectWithRetry() {
|
|
|
6294
6431
|
const { credentials, prompted } = await collectCredentials();
|
|
6295
6432
|
const resolved = await resolveUrl(credentials.url);
|
|
6296
6433
|
if (!resolved.ok) {
|
|
6297
|
-
console.error(
|
|
6434
|
+
console.error(import_picocolors14.default.red(resolved.error));
|
|
6298
6435
|
process.exit(1);
|
|
6299
6436
|
}
|
|
6300
6437
|
const resolvedUrl = resolved.url;
|
|
@@ -6306,17 +6443,17 @@ async function connectWithRetry() {
|
|
|
6306
6443
|
for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
|
|
6307
6444
|
try {
|
|
6308
6445
|
const kineticaVersion = await verifyConnectivity(session2);
|
|
6309
|
-
console.error(
|
|
6446
|
+
console.error(import_picocolors14.default.green("Connected to Kinetica successfully."));
|
|
6310
6447
|
if (prompted.size > 0 || wasReprompted) {
|
|
6311
6448
|
await offerSaveCredentials(resolvedUrl, currentUser);
|
|
6312
6449
|
}
|
|
6313
6450
|
return { session: session2, kineticaVersion, degraded: false };
|
|
6314
6451
|
} catch (err) {
|
|
6315
6452
|
const msg = err instanceof Error ? err.message : String(err);
|
|
6316
|
-
console.error(
|
|
6453
|
+
console.error(import_picocolors14.default.red(`Connection failed (attempt ${attempt}/${MAX_RETRIES}): ${msg}`));
|
|
6317
6454
|
if (isCredentialError(msg)) {
|
|
6318
6455
|
if (process.stdin.isTTY && repromptCount < MAX_REPROMPTS) {
|
|
6319
|
-
const shouldRetry = await
|
|
6456
|
+
const shouldRetry = await confirm({
|
|
6320
6457
|
message: "Credentials may be incorrect. Re-enter?",
|
|
6321
6458
|
default: true
|
|
6322
6459
|
});
|
|
@@ -6331,15 +6468,15 @@ async function connectWithRetry() {
|
|
|
6331
6468
|
continue;
|
|
6332
6469
|
}
|
|
6333
6470
|
}
|
|
6334
|
-
console.error(
|
|
6471
|
+
console.error(import_picocolors14.default.red("Authentication failed. Exiting."));
|
|
6335
6472
|
process.exit(1);
|
|
6336
6473
|
}
|
|
6337
6474
|
if (attempt === MAX_RETRIES) {
|
|
6338
|
-
console.error(
|
|
6475
|
+
console.error(import_picocolors14.default.yellow("DB engine unreachable. Probing host manager on port 9300..."));
|
|
6339
6476
|
const hmResult = await probeHostManager(session2);
|
|
6340
6477
|
if (hmResult.ok) {
|
|
6341
6478
|
console.error(
|
|
6342
|
-
|
|
6479
|
+
import_picocolors14.default.yellow(
|
|
6343
6480
|
"Connected in DEGRADED MODE (host manager only). Most diagnostic tools will be unavailable."
|
|
6344
6481
|
)
|
|
6345
6482
|
);
|
|
@@ -6348,7 +6485,7 @@ async function connectWithRetry() {
|
|
|
6348
6485
|
}
|
|
6349
6486
|
return { session: session2, kineticaVersion: hmResult.version, degraded: true };
|
|
6350
6487
|
}
|
|
6351
|
-
console.error(
|
|
6488
|
+
console.error(import_picocolors14.default.red("Host manager also unreachable. Exiting."));
|
|
6352
6489
|
process.exit(1);
|
|
6353
6490
|
}
|
|
6354
6491
|
}
|
|
@@ -6429,7 +6566,7 @@ async function main() {
|
|
|
6429
6566
|
} else {
|
|
6430
6567
|
const valid = SUPPORTED_MODELS.join(", ");
|
|
6431
6568
|
process.stderr.write(
|
|
6432
|
-
|
|
6569
|
+
import_picocolors15.default.red(`Error: unknown --model value "${modelValue}". Valid models: ${valid}
|
|
6433
6570
|
`)
|
|
6434
6571
|
);
|
|
6435
6572
|
process.exitCode = 1;
|
|
@@ -6442,7 +6579,7 @@ async function main() {
|
|
|
6442
6579
|
const parsed = Number(budgetValue);
|
|
6443
6580
|
if (!isValidBudget(parsed)) {
|
|
6444
6581
|
process.stderr.write(
|
|
6445
|
-
|
|
6582
|
+
import_picocolors15.default.red(
|
|
6446
6583
|
`Error: invalid --max-budget value "${budgetValue}". Use a positive number, e.g. --max-budget=10
|
|
6447
6584
|
`
|
|
6448
6585
|
)
|
|
@@ -6455,7 +6592,7 @@ async function main() {
|
|
|
6455
6592
|
const bundlePath = flagValue(args, "--bundle");
|
|
6456
6593
|
if (bundlePath?.trim() === "") {
|
|
6457
6594
|
process.stderr.write(
|
|
6458
|
-
|
|
6595
|
+
import_picocolors15.default.red(
|
|
6459
6596
|
"Error: --bundle requires a directory path, e.g. --bundle=/path/to/extracted-bundle\n"
|
|
6460
6597
|
)
|
|
6461
6598
|
);
|
|
@@ -6468,28 +6605,28 @@ async function main() {
|
|
|
6468
6605
|
model = await selectModel();
|
|
6469
6606
|
}
|
|
6470
6607
|
const effectiveModel = model ?? DEFAULT_AGENT_MODEL;
|
|
6471
|
-
process.stderr.write(
|
|
6608
|
+
process.stderr.write(import_picocolors15.default.dim(`Model: ${effectiveModel}
|
|
6472
6609
|
`));
|
|
6473
6610
|
const authResult = await authenticateAnthropic({ forceLogin, loginMethod, loginOrgUUID });
|
|
6474
6611
|
if (authResult.method === "oauth") {
|
|
6475
6612
|
const acctInfo = authResult.email ? ` (${authResult.email})` : "";
|
|
6476
|
-
process.stderr.write(
|
|
6613
|
+
process.stderr.write(import_picocolors15.default.dim(`Authenticated via OAuth${acctInfo}
|
|
6477
6614
|
`));
|
|
6478
6615
|
} else {
|
|
6479
|
-
process.stderr.write(
|
|
6616
|
+
process.stderr.write(import_picocolors15.default.dim("Authenticated via API key\n"));
|
|
6480
6617
|
}
|
|
6481
6618
|
const maxBudgetUsd = resolveMaxBudgetUsd(maxBudgetFlag);
|
|
6482
6619
|
if (bundlePath !== void 0) {
|
|
6483
6620
|
const result = await verifyBundle(bundlePath);
|
|
6484
6621
|
if (!result.ok) {
|
|
6485
|
-
process.stderr.write(
|
|
6622
|
+
process.stderr.write(import_picocolors15.default.red(`Error: ${result.error}
|
|
6486
6623
|
`));
|
|
6487
6624
|
process.exitCode = 1;
|
|
6488
6625
|
return;
|
|
6489
6626
|
}
|
|
6490
6627
|
if (result.missingExpected.length > 0) {
|
|
6491
6628
|
process.stderr.write(
|
|
6492
|
-
|
|
6629
|
+
import_picocolors15.default.yellow(
|
|
6493
6630
|
`Warning: bundle is missing expected artifact(s): ${result.missingExpected.join(", ")}. Diagnosing with what is present.
|
|
6494
6631
|
`
|
|
6495
6632
|
)
|
|
@@ -6497,11 +6634,11 @@ async function main() {
|
|
|
6497
6634
|
}
|
|
6498
6635
|
const live = await connectBestEffort();
|
|
6499
6636
|
process.stderr.write(
|
|
6500
|
-
live ?
|
|
6637
|
+
live ? import_picocolors15.default.dim("Live connection available \u2014 bundle + live verification enabled.\n") : import_picocolors15.default.dim("No reachable live connection \u2014 offline bundle analysis only.\n")
|
|
6501
6638
|
);
|
|
6502
6639
|
if (live?.kineticaVersion && result.kineticaVersion && live.kineticaVersion !== result.kineticaVersion) {
|
|
6503
6640
|
process.stderr.write(
|
|
6504
|
-
|
|
6641
|
+
import_picocolors15.default.yellow(
|
|
6505
6642
|
`Warning: live cluster version (${live.kineticaVersion}) differs from the bundle's captured version (${result.kineticaVersion}). Reasoning over the bundle uses the captured version; the live cluster may have been upgraded since capture.
|
|
6506
6643
|
`
|
|
6507
6644
|
)
|
|
@@ -6533,7 +6670,7 @@ function getSession() {
|
|
|
6533
6670
|
if (process.env.NODE_ENV !== "test") {
|
|
6534
6671
|
main().catch((err) => {
|
|
6535
6672
|
const message = err instanceof Error ? err.message : String(err);
|
|
6536
|
-
process.stderr.write(
|
|
6673
|
+
process.stderr.write(import_picocolors15.default.red(`Error: ${message}
|
|
6537
6674
|
`));
|
|
6538
6675
|
if (verbose && err instanceof Error && err.stack) {
|
|
6539
6676
|
process.stderr.write(err.stack + "\n");
|