@integrity-labs/agt-cli 0.28.289 → 0.28.290
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin/agt.js
CHANGED
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
success,
|
|
39
39
|
table,
|
|
40
40
|
warn
|
|
41
|
-
} from "../chunk-
|
|
41
|
+
} from "../chunk-QOEYIFPD.js";
|
|
42
42
|
import {
|
|
43
43
|
CHANNEL_REGISTRY,
|
|
44
44
|
DEFAULT_FRAMEWORK,
|
|
@@ -4826,7 +4826,7 @@ import { execFileSync, execSync } from "child_process";
|
|
|
4826
4826
|
import { existsSync as existsSync10, realpathSync as realpathSync2 } from "fs";
|
|
4827
4827
|
import chalk18 from "chalk";
|
|
4828
4828
|
import ora16 from "ora";
|
|
4829
|
-
var cliVersion = true ? "0.28.
|
|
4829
|
+
var cliVersion = true ? "0.28.290" : "dev";
|
|
4830
4830
|
async function fetchLatestVersion() {
|
|
4831
4831
|
const host2 = getHost();
|
|
4832
4832
|
if (!host2) return null;
|
|
@@ -5843,7 +5843,7 @@ function handleError(err) {
|
|
|
5843
5843
|
}
|
|
5844
5844
|
|
|
5845
5845
|
// src/bin/agt.ts
|
|
5846
|
-
var cliVersion2 = true ? "0.28.
|
|
5846
|
+
var cliVersion2 = true ? "0.28.290" : "dev";
|
|
5847
5847
|
var program = new Command();
|
|
5848
5848
|
program.name("agt").description("Augmented CLI \u2014 agent provisioning and management").version(cliVersion2).option("--json", "Emit machine-readable JSON output (suppress spinners and colors)").option("--skip-update-check", "Skip the automatic update check on startup");
|
|
5849
5849
|
program.hook("preAction", async (thisCommand, actionCommand) => {
|
|
@@ -5882,7 +5882,7 @@ function requireHost() {
|
|
|
5882
5882
|
}
|
|
5883
5883
|
|
|
5884
5884
|
// src/lib/api-client.ts
|
|
5885
|
-
var agtCliVersion = true ? "0.28.
|
|
5885
|
+
var agtCliVersion = true ? "0.28.290" : "dev";
|
|
5886
5886
|
var lastConfigHash = null;
|
|
5887
5887
|
function setConfigHash(hash) {
|
|
5888
5888
|
lastConfigHash = hash && hash.length > 0 ? hash : null;
|
|
@@ -8165,4 +8165,4 @@ export {
|
|
|
8165
8165
|
managerInstallSystemUnitCommand,
|
|
8166
8166
|
managerUninstallSystemUnitCommand
|
|
8167
8167
|
};
|
|
8168
|
-
//# sourceMappingURL=chunk-
|
|
8168
|
+
//# sourceMappingURL=chunk-QOEYIFPD.js.map
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
requireHost,
|
|
39
39
|
safeWriteJsonAtomic,
|
|
40
40
|
setConfigHash
|
|
41
|
-
} from "../chunk-
|
|
41
|
+
} from "../chunk-QOEYIFPD.js";
|
|
42
42
|
import {
|
|
43
43
|
getProjectDir as getProjectDir2,
|
|
44
44
|
getReadyTasks,
|
|
@@ -6897,7 +6897,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
|
|
|
6897
6897
|
var lastVersionCheckAt = 0;
|
|
6898
6898
|
var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
6899
6899
|
var lastResponsivenessProbeAt = 0;
|
|
6900
|
-
var agtCliVersion = true ? "0.28.
|
|
6900
|
+
var agtCliVersion = true ? "0.28.290" : "dev";
|
|
6901
6901
|
function resolveBrewPath(execFileSync2) {
|
|
6902
6902
|
try {
|
|
6903
6903
|
const out = execFileSync2("which", ["brew"], { timeout: 5e3 }).toString().trim();
|
|
@@ -43,6 +43,46 @@ function buildEnableToolsetRequest(toolset) {
|
|
|
43
43
|
params: { name: "enable_toolset", arguments: { name: toolset } }
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
+
function buildToolsListRequest() {
|
|
47
|
+
return JSON.stringify({ jsonrpc: "2.0", id: "agt-union-list", method: "tools/list", params: {} });
|
|
48
|
+
}
|
|
49
|
+
function toolName(t) {
|
|
50
|
+
return t && typeof t === "object" && typeof t.name === "string" ? t.name : "";
|
|
51
|
+
}
|
|
52
|
+
function extractToolsArray(message) {
|
|
53
|
+
try {
|
|
54
|
+
const tools = JSON.parse(message)?.result?.tools;
|
|
55
|
+
return Array.isArray(tools) ? tools : [];
|
|
56
|
+
} catch {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function parseEnableToolsetResponse(message) {
|
|
61
|
+
let payload;
|
|
62
|
+
try {
|
|
63
|
+
const obj = JSON.parse(message);
|
|
64
|
+
payload = obj?.result ?? obj;
|
|
65
|
+
const content = payload?.content;
|
|
66
|
+
if (Array.isArray(content)) {
|
|
67
|
+
const textPart = content.find(
|
|
68
|
+
(c) => c && typeof c === "object" && c.type === "text" && typeof c.text === "string"
|
|
69
|
+
);
|
|
70
|
+
if (textPart?.text) {
|
|
71
|
+
try {
|
|
72
|
+
payload = JSON.parse(textPart.text);
|
|
73
|
+
} catch {
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
} catch {
|
|
78
|
+
return { activated: null, newlyAvailable: [] };
|
|
79
|
+
}
|
|
80
|
+
const p = payload && typeof payload === "object" ? payload : null;
|
|
81
|
+
const activated = p && typeof p.activated === "string" ? p.activated : null;
|
|
82
|
+
const nat = p && Array.isArray(p.newly_available_tools) ? p.newly_available_tools : [];
|
|
83
|
+
const newlyAvailable = nat.map((t) => typeof t === "string" ? t : toolName(t)).filter((n) => typeof n === "string" && n.length > 0);
|
|
84
|
+
return { activated, newlyAvailable };
|
|
85
|
+
}
|
|
46
86
|
function parseToolAllowlist(raw) {
|
|
47
87
|
const out = /* @__PURE__ */ new Set();
|
|
48
88
|
for (const part of (raw || "").split(",")) {
|
|
@@ -126,53 +166,85 @@ function extractJsonRpcMessages(contentType, body) {
|
|
|
126
166
|
}
|
|
127
167
|
return out;
|
|
128
168
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
169
|
+
async function postRpc(token, body) {
|
|
170
|
+
const res = await fetch(remoteUrl, {
|
|
171
|
+
method: "POST",
|
|
172
|
+
headers: {
|
|
173
|
+
"Content-Type": "application/json",
|
|
174
|
+
Accept: "application/json, text/event-stream",
|
|
175
|
+
Authorization: `Bearer ${token}`
|
|
176
|
+
},
|
|
177
|
+
body,
|
|
178
|
+
signal: AbortSignal.timeout(REMOTE_FETCH_TIMEOUT_MS)
|
|
179
|
+
});
|
|
180
|
+
const text = await res.text().catch(() => "");
|
|
181
|
+
return { ok: res.ok, status: res.status, ct: res.headers.get("content-type") ?? "", text };
|
|
182
|
+
}
|
|
183
|
+
var unionOnce = null;
|
|
184
|
+
var unionToolByName = /* @__PURE__ */ new Map();
|
|
185
|
+
var toolGroupByName = /* @__PURE__ */ new Map();
|
|
186
|
+
function mergeToolsListInto(ct, text) {
|
|
187
|
+
for (const m of extractJsonRpcMessages(ct, text)) {
|
|
188
|
+
for (const t of extractToolsArray(m)) {
|
|
189
|
+
const n = toolName(t);
|
|
190
|
+
if (n) unionToolByName.set(n, t);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function ensureUnionManifest(token) {
|
|
195
|
+
if (unionOnce) return unionOnce;
|
|
196
|
+
unionOnce = (async () => {
|
|
197
|
+
try {
|
|
198
|
+
const seed = await postRpc(token, buildToolsListRequest());
|
|
199
|
+
mergeToolsListInto(seed.ct, seed.text);
|
|
200
|
+
} catch (err) {
|
|
201
|
+
logErr(`union: seed tools/list failed: ${err.message}`);
|
|
202
|
+
}
|
|
203
|
+
for (const group of preEnableToolsets) {
|
|
149
204
|
try {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
205
|
+
const en = await postRpc(token, buildEnableToolsetRequest(group));
|
|
206
|
+
if (!en.ok) {
|
|
207
|
+
logErr(`union: enable "${group}" HTTP ${en.status}`);
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
for (const m of extractJsonRpcMessages(en.ct, en.text)) {
|
|
211
|
+
for (const nm of parseEnableToolsetResponse(m).newlyAvailable) toolGroupByName.set(nm, group);
|
|
212
|
+
}
|
|
213
|
+
for (const nm of parseEnableToolsetResponse(en.text).newlyAvailable) toolGroupByName.set(nm, group);
|
|
214
|
+
const li = await postRpc(token, buildToolsListRequest());
|
|
215
|
+
mergeToolsListInto(li.ct, li.text);
|
|
216
|
+
logErr(`union: enabled "${group}" (union now ${unionToolByName.size} tools, ${toolGroupByName.size} mapped)`);
|
|
217
|
+
} catch (err) {
|
|
218
|
+
logErr(`union: enable "${group}" failed: ${err.message}`);
|
|
163
219
|
}
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
return
|
|
220
|
+
}
|
|
221
|
+
})();
|
|
222
|
+
return unionOnce;
|
|
167
223
|
}
|
|
168
|
-
async function forward(line, id, isNotification, method) {
|
|
224
|
+
async function forward(line, id, isNotification, method, params) {
|
|
169
225
|
const token = readCurrentToken(tokenFile, tokenVar);
|
|
170
226
|
if (!token) {
|
|
171
227
|
logErr(`no token in ${tokenFile} (var ${tokenVar})`);
|
|
172
228
|
return isNotification ? [] : [jsonRpcError(id, -32e3, `${label}: no current access token available (reconnect the integration)`)];
|
|
173
229
|
}
|
|
174
230
|
if (method === "tools/list" && preEnableToolsets.length > 0) {
|
|
175
|
-
await
|
|
231
|
+
await ensureUnionManifest(token);
|
|
232
|
+
let tools = [...unionToolByName.values()];
|
|
233
|
+
if (toolAllowlist.size > 0) tools = tools.filter((t) => toolAllowlist.has(toolName(t)));
|
|
234
|
+
return [JSON.stringify({ jsonrpc: "2.0", id: id ?? null, result: { tools } })];
|
|
235
|
+
}
|
|
236
|
+
if (method === "tools/call" && preEnableToolsets.length > 0) {
|
|
237
|
+
await ensureUnionManifest(token);
|
|
238
|
+
const callName = params && typeof params === "object" && typeof params.name === "string" ? params.name : "";
|
|
239
|
+
const group = callName ? toolGroupByName.get(callName) : void 0;
|
|
240
|
+
if (group) {
|
|
241
|
+
try {
|
|
242
|
+
const en = await postRpc(token, buildEnableToolsetRequest(group));
|
|
243
|
+
if (!en.ok) logErr(`per-call enable "${group}" for "${callName}" HTTP ${en.status}`);
|
|
244
|
+
} catch (err) {
|
|
245
|
+
logErr(`per-call enable "${group}" for "${callName}" failed: ${err.message}`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
176
248
|
}
|
|
177
249
|
let res;
|
|
178
250
|
try {
|
|
@@ -265,7 +337,7 @@ async function main() {
|
|
|
265
337
|
return;
|
|
266
338
|
}
|
|
267
339
|
}
|
|
268
|
-
const task = forward(text, id, isNotification, parsed.method).then(writeReplies).catch((err) => {
|
|
340
|
+
const task = forward(text, id, isNotification, parsed.method, parsed.params).then(writeReplies).catch((err) => {
|
|
269
341
|
logErr(`handler error: ${err.message}`);
|
|
270
342
|
});
|
|
271
343
|
inflight.add(task);
|
|
@@ -289,11 +361,15 @@ if (invokedDirectly) {
|
|
|
289
361
|
}
|
|
290
362
|
export {
|
|
291
363
|
buildEnableToolsetRequest,
|
|
364
|
+
buildToolsListRequest,
|
|
292
365
|
extractJsonRpcMessages,
|
|
366
|
+
extractToolsArray,
|
|
293
367
|
filterToolsListMessage,
|
|
294
368
|
isToolCallBlocked,
|
|
295
369
|
main,
|
|
370
|
+
parseEnableToolsetResponse,
|
|
296
371
|
parsePreEnableToolsets,
|
|
297
372
|
parseToolAllowlist,
|
|
298
|
-
readCurrentToken
|
|
373
|
+
readCurrentToken,
|
|
374
|
+
toolName
|
|
299
375
|
};
|
package/package.json
CHANGED
|
File without changes
|