@swmansion/argent 0.18.1-next.2 → 0.18.1-next.21
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 +1 -1
- package/dist/cli-cmds.mjs +955 -197
- package/dist/cli.js +10 -6
- package/dist/cli.js.map +1 -1
- package/dist/installer-help.d.ts +13 -2
- package/dist/installer-help.js +41 -2
- package/dist/installer-help.js.map +1 -1
- package/dist/installer.mjs +834 -464
- package/dist/mcp-server.mjs +402 -68
- package/dist/tool-server.cjs +2376 -1740
- package/package.json +4 -1
- package/skills/argent-create-flow/SKILL.md +6 -1
- package/skills/argent-device-interact/SKILL.md +13 -3
- package/skills/argent-test-ui-flow/SKILL.md +1 -1
package/dist/cli-cmds.mjs
CHANGED
|
@@ -5,7 +5,13 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var
|
|
8
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
9
|
+
get: (a2, b) => (typeof require !== "undefined" ? require : a2)[b]
|
|
10
|
+
}) : x)(function(x) {
|
|
11
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
+
});
|
|
14
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
9
15
|
try {
|
|
10
16
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
17
|
} catch (e) {
|
|
@@ -33,6 +39,325 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
33
39
|
mod
|
|
34
40
|
));
|
|
35
41
|
|
|
42
|
+
// ../../node_modules/dotenv/lib/main.js
|
|
43
|
+
var require_main = __commonJS({
|
|
44
|
+
"../../node_modules/dotenv/lib/main.js"(exports, module) {
|
|
45
|
+
var fs12 = __require("fs");
|
|
46
|
+
var path17 = __require("path");
|
|
47
|
+
var os3 = __require("os");
|
|
48
|
+
var crypto3 = __require("crypto");
|
|
49
|
+
var TIPS = [
|
|
50
|
+
"\u25C8 encrypted .env [www.dotenvx.com]",
|
|
51
|
+
"\u25C8 secrets for agents [www.dotenvx.com]",
|
|
52
|
+
"\u2301 auth for agents [www.vestauth.com]",
|
|
53
|
+
"\u2318 custom filepath { path: '/custom/path/.env' }",
|
|
54
|
+
"\u2318 enable debugging { debug: true }",
|
|
55
|
+
"\u2318 override existing { override: true }",
|
|
56
|
+
"\u2318 suppress logs { quiet: true }",
|
|
57
|
+
"\u2318 multiple files { path: ['.env.local', '.env'] }"
|
|
58
|
+
];
|
|
59
|
+
function _getRandomTip() {
|
|
60
|
+
return TIPS[Math.floor(Math.random() * TIPS.length)];
|
|
61
|
+
}
|
|
62
|
+
function parseBoolean(value) {
|
|
63
|
+
if (typeof value === "string") {
|
|
64
|
+
return !["false", "0", "no", "off", ""].includes(value.toLowerCase());
|
|
65
|
+
}
|
|
66
|
+
return Boolean(value);
|
|
67
|
+
}
|
|
68
|
+
function supportsAnsi() {
|
|
69
|
+
return process.stdout.isTTY;
|
|
70
|
+
}
|
|
71
|
+
function dim(text2) {
|
|
72
|
+
return supportsAnsi() ? `\x1B[2m${text2}\x1B[0m` : text2;
|
|
73
|
+
}
|
|
74
|
+
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
75
|
+
function parse(src) {
|
|
76
|
+
const obj = {};
|
|
77
|
+
let lines = src.toString();
|
|
78
|
+
lines = lines.replace(/\r\n?/mg, "\n");
|
|
79
|
+
let match;
|
|
80
|
+
while ((match = LINE.exec(lines)) != null) {
|
|
81
|
+
const key = match[1];
|
|
82
|
+
let value = match[2] || "";
|
|
83
|
+
value = value.trim();
|
|
84
|
+
const maybeQuote = value[0];
|
|
85
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
|
|
86
|
+
if (maybeQuote === '"') {
|
|
87
|
+
value = value.replace(/\\n/g, "\n");
|
|
88
|
+
value = value.replace(/\\r/g, "\r");
|
|
89
|
+
}
|
|
90
|
+
obj[key] = value;
|
|
91
|
+
}
|
|
92
|
+
return obj;
|
|
93
|
+
}
|
|
94
|
+
function _parseVault(options) {
|
|
95
|
+
options = options || {};
|
|
96
|
+
const vaultPath = _vaultPath(options);
|
|
97
|
+
options.path = vaultPath;
|
|
98
|
+
const result = DotenvModule.configDotenv(options);
|
|
99
|
+
if (!result.parsed) {
|
|
100
|
+
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
101
|
+
err.code = "MISSING_DATA";
|
|
102
|
+
throw err;
|
|
103
|
+
}
|
|
104
|
+
const keys = _dotenvKey(options).split(",");
|
|
105
|
+
const length = keys.length;
|
|
106
|
+
let decrypted;
|
|
107
|
+
for (let i2 = 0; i2 < length; i2++) {
|
|
108
|
+
try {
|
|
109
|
+
const key = keys[i2].trim();
|
|
110
|
+
const attrs = _instructions(result, key);
|
|
111
|
+
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
112
|
+
break;
|
|
113
|
+
} catch (error) {
|
|
114
|
+
if (i2 + 1 >= length) {
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return DotenvModule.parse(decrypted);
|
|
120
|
+
}
|
|
121
|
+
function _warn(message) {
|
|
122
|
+
console.error(`\u26A0 ${message}`);
|
|
123
|
+
}
|
|
124
|
+
function _debug(message) {
|
|
125
|
+
console.log(`\u2506 ${message}`);
|
|
126
|
+
}
|
|
127
|
+
function _log(message) {
|
|
128
|
+
console.log(`\u25C7 ${message}`);
|
|
129
|
+
}
|
|
130
|
+
function _dotenvKey(options) {
|
|
131
|
+
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
|
132
|
+
return options.DOTENV_KEY;
|
|
133
|
+
}
|
|
134
|
+
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
|
135
|
+
return process.env.DOTENV_KEY;
|
|
136
|
+
}
|
|
137
|
+
return "";
|
|
138
|
+
}
|
|
139
|
+
function _instructions(result, dotenvKey) {
|
|
140
|
+
let uri;
|
|
141
|
+
try {
|
|
142
|
+
uri = new URL(dotenvKey);
|
|
143
|
+
} catch (error) {
|
|
144
|
+
if (error.code === "ERR_INVALID_URL") {
|
|
145
|
+
const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
|
|
146
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
147
|
+
throw err;
|
|
148
|
+
}
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
const key = uri.password;
|
|
152
|
+
if (!key) {
|
|
153
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing key part");
|
|
154
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
155
|
+
throw err;
|
|
156
|
+
}
|
|
157
|
+
const environment = uri.searchParams.get("environment");
|
|
158
|
+
if (!environment) {
|
|
159
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
|
|
160
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
161
|
+
throw err;
|
|
162
|
+
}
|
|
163
|
+
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
164
|
+
const ciphertext = result.parsed[environmentKey];
|
|
165
|
+
if (!ciphertext) {
|
|
166
|
+
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
167
|
+
err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
|
|
168
|
+
throw err;
|
|
169
|
+
}
|
|
170
|
+
return { ciphertext, key };
|
|
171
|
+
}
|
|
172
|
+
function _vaultPath(options) {
|
|
173
|
+
let possibleVaultPath = null;
|
|
174
|
+
if (options && options.path && options.path.length > 0) {
|
|
175
|
+
if (Array.isArray(options.path)) {
|
|
176
|
+
for (const filepath of options.path) {
|
|
177
|
+
if (fs12.existsSync(filepath)) {
|
|
178
|
+
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
183
|
+
}
|
|
184
|
+
} else {
|
|
185
|
+
possibleVaultPath = path17.resolve(process.cwd(), ".env.vault");
|
|
186
|
+
}
|
|
187
|
+
if (fs12.existsSync(possibleVaultPath)) {
|
|
188
|
+
return possibleVaultPath;
|
|
189
|
+
}
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
function _resolveHome(envPath) {
|
|
193
|
+
return envPath[0] === "~" ? path17.join(os3.homedir(), envPath.slice(1)) : envPath;
|
|
194
|
+
}
|
|
195
|
+
function _configVault(options) {
|
|
196
|
+
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
197
|
+
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
198
|
+
if (debug || !quiet) {
|
|
199
|
+
_log("loading env from encrypted .env.vault");
|
|
200
|
+
}
|
|
201
|
+
const parsed = DotenvModule._parseVault(options);
|
|
202
|
+
let processEnv = process.env;
|
|
203
|
+
if (options && options.processEnv != null) {
|
|
204
|
+
processEnv = options.processEnv;
|
|
205
|
+
}
|
|
206
|
+
DotenvModule.populate(processEnv, parsed, options);
|
|
207
|
+
return { parsed };
|
|
208
|
+
}
|
|
209
|
+
function configDotenv(options) {
|
|
210
|
+
const dotenvPath = path17.resolve(process.cwd(), ".env");
|
|
211
|
+
let encoding = "utf8";
|
|
212
|
+
let processEnv = process.env;
|
|
213
|
+
if (options && options.processEnv != null) {
|
|
214
|
+
processEnv = options.processEnv;
|
|
215
|
+
}
|
|
216
|
+
let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
217
|
+
let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
218
|
+
if (options && options.encoding) {
|
|
219
|
+
encoding = options.encoding;
|
|
220
|
+
} else {
|
|
221
|
+
if (debug) {
|
|
222
|
+
_debug("no encoding is specified (UTF-8 is used by default)");
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
let optionPaths = [dotenvPath];
|
|
226
|
+
if (options && options.path) {
|
|
227
|
+
if (!Array.isArray(options.path)) {
|
|
228
|
+
optionPaths = [_resolveHome(options.path)];
|
|
229
|
+
} else {
|
|
230
|
+
optionPaths = [];
|
|
231
|
+
for (const filepath of options.path) {
|
|
232
|
+
optionPaths.push(_resolveHome(filepath));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
let lastError;
|
|
237
|
+
const parsedAll = {};
|
|
238
|
+
for (const path18 of optionPaths) {
|
|
239
|
+
try {
|
|
240
|
+
const parsed = DotenvModule.parse(fs12.readFileSync(path18, { encoding }));
|
|
241
|
+
DotenvModule.populate(parsedAll, parsed, options);
|
|
242
|
+
} catch (e) {
|
|
243
|
+
if (debug) {
|
|
244
|
+
_debug(`failed to load ${path18} ${e.message}`);
|
|
245
|
+
}
|
|
246
|
+
lastError = e;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
const populated = DotenvModule.populate(processEnv, parsedAll, options);
|
|
250
|
+
debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
|
|
251
|
+
quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
|
|
252
|
+
if (debug || !quiet) {
|
|
253
|
+
const keysCount = Object.keys(populated).length;
|
|
254
|
+
const shortPaths = [];
|
|
255
|
+
for (const filePath of optionPaths) {
|
|
256
|
+
try {
|
|
257
|
+
const relative4 = path17.relative(process.cwd(), filePath);
|
|
258
|
+
shortPaths.push(relative4);
|
|
259
|
+
} catch (e) {
|
|
260
|
+
if (debug) {
|
|
261
|
+
_debug(`failed to load ${filePath} ${e.message}`);
|
|
262
|
+
}
|
|
263
|
+
lastError = e;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
_log(`injected env (${keysCount}) from ${shortPaths.join(",")} ${dim(`// tip: ${_getRandomTip()}`)}`);
|
|
267
|
+
}
|
|
268
|
+
if (lastError) {
|
|
269
|
+
return { parsed: parsedAll, error: lastError };
|
|
270
|
+
} else {
|
|
271
|
+
return { parsed: parsedAll };
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function config2(options) {
|
|
275
|
+
if (_dotenvKey(options).length === 0) {
|
|
276
|
+
return DotenvModule.configDotenv(options);
|
|
277
|
+
}
|
|
278
|
+
const vaultPath = _vaultPath(options);
|
|
279
|
+
if (!vaultPath) {
|
|
280
|
+
_warn(`you set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}`);
|
|
281
|
+
return DotenvModule.configDotenv(options);
|
|
282
|
+
}
|
|
283
|
+
return DotenvModule._configVault(options);
|
|
284
|
+
}
|
|
285
|
+
function decrypt(encrypted, keyStr) {
|
|
286
|
+
const key = Buffer.from(keyStr.slice(-64), "hex");
|
|
287
|
+
let ciphertext = Buffer.from(encrypted, "base64");
|
|
288
|
+
const nonce = ciphertext.subarray(0, 12);
|
|
289
|
+
const authTag = ciphertext.subarray(-16);
|
|
290
|
+
ciphertext = ciphertext.subarray(12, -16);
|
|
291
|
+
try {
|
|
292
|
+
const aesgcm = crypto3.createDecipheriv("aes-256-gcm", key, nonce);
|
|
293
|
+
aesgcm.setAuthTag(authTag);
|
|
294
|
+
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
295
|
+
} catch (error) {
|
|
296
|
+
const isRange = error instanceof RangeError;
|
|
297
|
+
const invalidKeyLength = error.message === "Invalid key length";
|
|
298
|
+
const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
|
|
299
|
+
if (isRange || invalidKeyLength) {
|
|
300
|
+
const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
|
301
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
302
|
+
throw err;
|
|
303
|
+
} else if (decryptionFailed) {
|
|
304
|
+
const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
|
|
305
|
+
err.code = "DECRYPTION_FAILED";
|
|
306
|
+
throw err;
|
|
307
|
+
} else {
|
|
308
|
+
throw error;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
function populate(processEnv, parsed, options = {}) {
|
|
313
|
+
const debug = Boolean(options && options.debug);
|
|
314
|
+
const override = Boolean(options && options.override);
|
|
315
|
+
const populated = {};
|
|
316
|
+
if (typeof parsed !== "object") {
|
|
317
|
+
const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
|
318
|
+
err.code = "OBJECT_REQUIRED";
|
|
319
|
+
throw err;
|
|
320
|
+
}
|
|
321
|
+
for (const key of Object.keys(parsed)) {
|
|
322
|
+
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
323
|
+
if (override === true) {
|
|
324
|
+
processEnv[key] = parsed[key];
|
|
325
|
+
populated[key] = parsed[key];
|
|
326
|
+
}
|
|
327
|
+
if (debug) {
|
|
328
|
+
if (override === true) {
|
|
329
|
+
_debug(`"${key}" is already defined and WAS overwritten`);
|
|
330
|
+
} else {
|
|
331
|
+
_debug(`"${key}" is already defined and was NOT overwritten`);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
} else {
|
|
335
|
+
processEnv[key] = parsed[key];
|
|
336
|
+
populated[key] = parsed[key];
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return populated;
|
|
340
|
+
}
|
|
341
|
+
var DotenvModule = {
|
|
342
|
+
configDotenv,
|
|
343
|
+
_configVault,
|
|
344
|
+
_parseVault,
|
|
345
|
+
config: config2,
|
|
346
|
+
decrypt,
|
|
347
|
+
parse,
|
|
348
|
+
populate
|
|
349
|
+
};
|
|
350
|
+
module.exports.configDotenv = DotenvModule.configDotenv;
|
|
351
|
+
module.exports._configVault = DotenvModule._configVault;
|
|
352
|
+
module.exports._parseVault = DotenvModule._parseVault;
|
|
353
|
+
module.exports.config = DotenvModule.config;
|
|
354
|
+
module.exports.decrypt = DotenvModule.decrypt;
|
|
355
|
+
module.exports.parse = DotenvModule.parse;
|
|
356
|
+
module.exports.populate = DotenvModule.populate;
|
|
357
|
+
module.exports = DotenvModule;
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
|
|
36
361
|
// ../../node_modules/picocolors/picocolors.js
|
|
37
362
|
var require_picocolors = __commonJS({
|
|
38
363
|
"../../node_modules/picocolors/picocolors.js"(exports, module) {
|
|
@@ -162,8 +487,8 @@ var require_src = __commonJS({
|
|
|
162
487
|
});
|
|
163
488
|
|
|
164
489
|
// ../argent-cli/src/run.ts
|
|
165
|
-
import * as
|
|
166
|
-
import * as
|
|
490
|
+
import * as fs9 from "node:fs";
|
|
491
|
+
import * as path12 from "node:path";
|
|
167
492
|
|
|
168
493
|
// ../argent-tools-client/src/launcher.ts
|
|
169
494
|
import * as net from "node:net";
|
|
@@ -204,7 +529,7 @@ function generateAuthToken() {
|
|
|
204
529
|
return generateToken();
|
|
205
530
|
}
|
|
206
531
|
function findFreePort() {
|
|
207
|
-
return new Promise((
|
|
532
|
+
return new Promise((resolve10, reject) => {
|
|
208
533
|
const srv = net.createServer();
|
|
209
534
|
srv.listen(0, "127.0.0.1", () => {
|
|
210
535
|
const addr = srv.address();
|
|
@@ -215,7 +540,7 @@ function findFreePort() {
|
|
|
215
540
|
const port = addr.port;
|
|
216
541
|
srv.close((err) => {
|
|
217
542
|
if (err) reject(err);
|
|
218
|
-
else
|
|
543
|
+
else resolve10(port);
|
|
219
544
|
});
|
|
220
545
|
});
|
|
221
546
|
srv.on("error", reject);
|
|
@@ -316,7 +641,7 @@ function killSpawnedChild(child, pid) {
|
|
|
316
641
|
}
|
|
317
642
|
}
|
|
318
643
|
function spawnToolsServer(paths, port, options = {}) {
|
|
319
|
-
return new Promise((
|
|
644
|
+
return new Promise((resolve10, reject) => {
|
|
320
645
|
let logFd;
|
|
321
646
|
try {
|
|
322
647
|
fs.mkdirSync(STATE_DIR, { recursive: true });
|
|
@@ -353,7 +678,7 @@ function spawnToolsServer(paths, port, options = {}) {
|
|
|
353
678
|
rl.close();
|
|
354
679
|
child.stdout?.resume();
|
|
355
680
|
child.stdout?.unref?.();
|
|
356
|
-
settle(() =>
|
|
681
|
+
settle(() => resolve10({ port: actualPort, pid }));
|
|
357
682
|
}
|
|
358
683
|
});
|
|
359
684
|
child.on("error", (err) => {
|
|
@@ -742,8 +1067,8 @@ function parseLinkTarget(input) {
|
|
|
742
1067
|
const host = u3.hostname.startsWith("[") ? u3.hostname.slice(1, -1) : u3.hostname;
|
|
743
1068
|
if (!host) throw new Error(`URL "${input}" is missing a host.`);
|
|
744
1069
|
const port = u3.port ? Number(u3.port) : u3.protocol === "https:" ? 443 : 80;
|
|
745
|
-
const
|
|
746
|
-
const url = `${u3.protocol}//${u3.host}${
|
|
1070
|
+
const path17 = u3.pathname === "/" ? "" : u3.pathname.replace(/\/+$/, "");
|
|
1071
|
+
const url = `${u3.protocol}//${u3.host}${path17}`;
|
|
747
1072
|
const token = u3.username ? decodeURIComponent(u3.username) : void 0;
|
|
748
1073
|
return { url, host, port, ...token ? { token } : {} };
|
|
749
1074
|
}
|
|
@@ -879,9 +1204,9 @@ async function tarball(sourcePath) {
|
|
|
879
1204
|
return tarPath;
|
|
880
1205
|
}
|
|
881
1206
|
function sha256File(filePath) {
|
|
882
|
-
return new Promise((
|
|
1207
|
+
return new Promise((resolve10, reject) => {
|
|
883
1208
|
const hash = createHash2("sha256");
|
|
884
|
-
createReadStream(filePath).on("data", (chunk) => hash.update(chunk)).on("end", () =>
|
|
1209
|
+
createReadStream(filePath).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve10(hash.digest("hex"))).on("error", reject);
|
|
885
1210
|
});
|
|
886
1211
|
}
|
|
887
1212
|
async function uploadTar(tarPath, endpoint) {
|
|
@@ -1103,7 +1428,7 @@ function createToolsClient(options = {}) {
|
|
|
1103
1428
|
import { copyFile, mkdir as mkdir4, readFile as readFile4, realpath, rm as rm3, stat as stat2, writeFile as writeFile4 } from "node:fs/promises";
|
|
1104
1429
|
import { constants as fsConstants } from "node:fs";
|
|
1105
1430
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
1106
|
-
import { basename as basename3, dirname as dirname5, extname, isAbsolute as isAbsolute3, join as
|
|
1431
|
+
import { basename as basename3, dirname as dirname5, extname, isAbsolute as isAbsolute3, join as join9, normalize, resolve as resolve6, sep as sep2 } from "node:path";
|
|
1107
1432
|
import { createHash as createHash3 } from "node:crypto";
|
|
1108
1433
|
|
|
1109
1434
|
// ../configuration-core/src/flags.ts
|
|
@@ -1304,15 +1629,20 @@ function setAtPath(obj, dottedKey, value) {
|
|
|
1304
1629
|
}
|
|
1305
1630
|
function deleteAtPath(obj, dottedKey) {
|
|
1306
1631
|
const parts = splitKey(dottedKey);
|
|
1307
|
-
|
|
1632
|
+
const chain = [obj];
|
|
1308
1633
|
for (let i2 = 0; i2 < parts.length - 1; i2++) {
|
|
1309
|
-
const next =
|
|
1634
|
+
const next = chain[i2][parts[i2]];
|
|
1310
1635
|
if (!isPlainObject(next)) return false;
|
|
1311
|
-
|
|
1636
|
+
chain.push(next);
|
|
1312
1637
|
}
|
|
1638
|
+
const parent = chain[parts.length - 1];
|
|
1313
1639
|
const leaf = parts[parts.length - 1];
|
|
1314
|
-
if (!Object.hasOwn(
|
|
1315
|
-
delete
|
|
1640
|
+
if (!Object.hasOwn(parent, leaf)) return false;
|
|
1641
|
+
delete parent[leaf];
|
|
1642
|
+
for (let i2 = chain.length - 1; i2 >= 1; i2--) {
|
|
1643
|
+
if (Object.keys(chain[i2]).length > 0) break;
|
|
1644
|
+
delete chain[i2 - 1][parts[i2 - 1]];
|
|
1645
|
+
}
|
|
1316
1646
|
return true;
|
|
1317
1647
|
}
|
|
1318
1648
|
var LOCK_STALE_MS2 = 1e4;
|
|
@@ -1387,6 +1717,97 @@ function updateConfig(mutate, scope = "global", options = {}) {
|
|
|
1387
1717
|
}
|
|
1388
1718
|
}
|
|
1389
1719
|
|
|
1720
|
+
// ../configuration-core/src/secrets.ts
|
|
1721
|
+
var import_dotenv = __toESM(require_main(), 1);
|
|
1722
|
+
import * as fs4 from "node:fs";
|
|
1723
|
+
import * as path7 from "node:path";
|
|
1724
|
+
var SECRET_ENV_PREFIX = "ARGENT_SECRET_";
|
|
1725
|
+
var SECRETS_FILE_NAME = "secrets.env";
|
|
1726
|
+
var SHARED_ENV_FILES = [".env.local", ".env"];
|
|
1727
|
+
var SECRET_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
1728
|
+
function envSource(env) {
|
|
1729
|
+
const values = /* @__PURE__ */ new Map();
|
|
1730
|
+
for (const [key, value] of Object.entries(env)) {
|
|
1731
|
+
if (value === void 0 || !key.startsWith(SECRET_ENV_PREFIX)) continue;
|
|
1732
|
+
const name = key.slice(SECRET_ENV_PREFIX.length);
|
|
1733
|
+
if (SECRET_NAME_RE.test(name)) values.set(name, value);
|
|
1734
|
+
}
|
|
1735
|
+
return {
|
|
1736
|
+
label: `environment (${SECRET_ENV_PREFIX}*)`,
|
|
1737
|
+
kind: "env",
|
|
1738
|
+
present: true,
|
|
1739
|
+
names: [...values.keys()].sort(),
|
|
1740
|
+
values
|
|
1741
|
+
};
|
|
1742
|
+
}
|
|
1743
|
+
function fileSource(filePath, exposure) {
|
|
1744
|
+
const label = filePath;
|
|
1745
|
+
const absent = {
|
|
1746
|
+
label,
|
|
1747
|
+
kind: "file",
|
|
1748
|
+
present: false,
|
|
1749
|
+
names: [],
|
|
1750
|
+
values: /* @__PURE__ */ new Map()
|
|
1751
|
+
};
|
|
1752
|
+
if (!fs4.statSync(filePath, { throwIfNoEntry: false })) return absent;
|
|
1753
|
+
let content;
|
|
1754
|
+
try {
|
|
1755
|
+
content = fs4.readFileSync(filePath, "utf8");
|
|
1756
|
+
} catch {
|
|
1757
|
+
return absent;
|
|
1758
|
+
}
|
|
1759
|
+
const values = /* @__PURE__ */ new Map();
|
|
1760
|
+
let skippedUnprefixed = false;
|
|
1761
|
+
for (const [key, value] of Object.entries((0, import_dotenv.parse)(content))) {
|
|
1762
|
+
const prefixed = key.startsWith(SECRET_ENV_PREFIX);
|
|
1763
|
+
if (exposure === "shared" && !prefixed) {
|
|
1764
|
+
skippedUnprefixed = true;
|
|
1765
|
+
continue;
|
|
1766
|
+
}
|
|
1767
|
+
const name = prefixed ? key.slice(SECRET_ENV_PREFIX.length) : key;
|
|
1768
|
+
if (SECRET_NAME_RE.test(name)) values.set(name, value);
|
|
1769
|
+
}
|
|
1770
|
+
return {
|
|
1771
|
+
label,
|
|
1772
|
+
kind: "file",
|
|
1773
|
+
present: true,
|
|
1774
|
+
names: [...values.keys()].sort(),
|
|
1775
|
+
values,
|
|
1776
|
+
...values.size === 0 && skippedUnprefixed ? { needsPrefix: true } : {}
|
|
1777
|
+
};
|
|
1778
|
+
}
|
|
1779
|
+
function secretSources(options = {}) {
|
|
1780
|
+
const sources = [envSource(options.env ?? process.env)];
|
|
1781
|
+
const projectRoot = findProjectRoot(options.cwd ?? process.cwd());
|
|
1782
|
+
const filePaths = [];
|
|
1783
|
+
if (projectRoot) {
|
|
1784
|
+
filePaths.push({
|
|
1785
|
+
path: path7.join(projectRoot, ".argent", SECRETS_FILE_NAME),
|
|
1786
|
+
exposure: "dedicated"
|
|
1787
|
+
});
|
|
1788
|
+
for (const name of SHARED_ENV_FILES) {
|
|
1789
|
+
filePaths.push({ path: path7.join(projectRoot, name), exposure: "shared" });
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
filePaths.push({
|
|
1793
|
+
path: path7.join(resolveHomeDir(options), ".argent", SECRETS_FILE_NAME),
|
|
1794
|
+
exposure: "dedicated"
|
|
1795
|
+
});
|
|
1796
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1797
|
+
for (const entry of filePaths) {
|
|
1798
|
+
const resolved = path7.resolve(entry.path);
|
|
1799
|
+
if (seen.has(resolved)) continue;
|
|
1800
|
+
seen.add(resolved);
|
|
1801
|
+
sources.push(fileSource(resolved, entry.exposure));
|
|
1802
|
+
}
|
|
1803
|
+
return sources;
|
|
1804
|
+
}
|
|
1805
|
+
function secretNames(sources) {
|
|
1806
|
+
const names = /* @__PURE__ */ new Set();
|
|
1807
|
+
for (const source of sources) for (const name of source.names) names.add(name);
|
|
1808
|
+
return [...names].sort();
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1390
1811
|
// ../configuration-core/src/merge.ts
|
|
1391
1812
|
function mergeRestrictive(local, global2) {
|
|
1392
1813
|
if (local === void 0) return global2;
|
|
@@ -1447,6 +1868,9 @@ function asString(raw) {
|
|
|
1447
1868
|
const trimmed = raw.trim();
|
|
1448
1869
|
return trimmed === "" ? void 0 : trimmed;
|
|
1449
1870
|
}
|
|
1871
|
+
function asNumber(raw) {
|
|
1872
|
+
return typeof raw === "number" && Number.isFinite(raw) ? raw : void 0;
|
|
1873
|
+
}
|
|
1450
1874
|
function asStringArray(raw) {
|
|
1451
1875
|
if (!Array.isArray(raw)) return void 0;
|
|
1452
1876
|
const out = [];
|
|
@@ -1455,6 +1879,15 @@ function asStringArray(raw) {
|
|
|
1455
1879
|
}
|
|
1456
1880
|
return out;
|
|
1457
1881
|
}
|
|
1882
|
+
var PARSER_EXPECTATIONS = /* @__PURE__ */ new Map([
|
|
1883
|
+
[asBoolean, "a boolean (true or false)"],
|
|
1884
|
+
[asString, "a non-empty string"],
|
|
1885
|
+
[asNumber, "a number"],
|
|
1886
|
+
[asStringArray, "an array of strings"]
|
|
1887
|
+
]);
|
|
1888
|
+
function describeExpectedValue(def) {
|
|
1889
|
+
return def.expected ?? PARSER_EXPECTATIONS.get(def.parse);
|
|
1890
|
+
}
|
|
1458
1891
|
var CONFIG_SCHEMA = [
|
|
1459
1892
|
{
|
|
1460
1893
|
key: "telemetry.enabled",
|
|
@@ -1512,7 +1945,7 @@ function getConfigDefinition(key, registry = CONFIG_SCHEMA) {
|
|
|
1512
1945
|
}
|
|
1513
1946
|
|
|
1514
1947
|
// ../configuration-core/src/config-access.ts
|
|
1515
|
-
import * as
|
|
1948
|
+
import * as path8 from "node:path";
|
|
1516
1949
|
function readScopeValue(def, scope, options) {
|
|
1517
1950
|
if (!def.scopes.includes(scope)) return void 0;
|
|
1518
1951
|
const raw = getAtPath(readConfigObject(scope, options), def.key);
|
|
@@ -1560,12 +1993,18 @@ var ConfigScopeError = class extends Error {
|
|
|
1560
1993
|
allowed;
|
|
1561
1994
|
};
|
|
1562
1995
|
var ConfigValidationError = class extends Error {
|
|
1563
|
-
constructor(key) {
|
|
1564
|
-
super(
|
|
1996
|
+
constructor(key, expected, example) {
|
|
1997
|
+
super(
|
|
1998
|
+
expected ? `Invalid value for config key "${key}": expected ${expected}.` : `Invalid value for config key "${key}".`
|
|
1999
|
+
);
|
|
1565
2000
|
this.key = key;
|
|
2001
|
+
this.expected = expected;
|
|
2002
|
+
this.example = example;
|
|
1566
2003
|
this.name = "ConfigValidationError";
|
|
1567
2004
|
}
|
|
1568
2005
|
key;
|
|
2006
|
+
expected;
|
|
2007
|
+
example;
|
|
1569
2008
|
};
|
|
1570
2009
|
var ConfigManagedElsewhereError = class extends Error {
|
|
1571
2010
|
constructor(key, command) {
|
|
@@ -1582,7 +2021,8 @@ function setConfigValue(key, rawValue, scope = "global", options = {}, registry
|
|
|
1582
2021
|
if (def.manageCommand) throw new ConfigManagedElsewhereError(key, def.manageCommand);
|
|
1583
2022
|
if (!def.scopes.includes(scope)) throw new ConfigScopeError(key, scope, def.scopes);
|
|
1584
2023
|
const parsed = def.parse(rawValue);
|
|
1585
|
-
if (parsed === void 0)
|
|
2024
|
+
if (parsed === void 0)
|
|
2025
|
+
throw new ConfigValidationError(def.key, describeExpectedValue(def), def.example);
|
|
1586
2026
|
updateConfig((config2) => setAtPath(config2, key, parsed), scope, options);
|
|
1587
2027
|
return parsed;
|
|
1588
2028
|
}
|
|
@@ -1607,6 +2047,8 @@ function listConfig(options = {}, registry = CONFIG_SCHEMA) {
|
|
|
1607
2047
|
description: def.description,
|
|
1608
2048
|
scopes: def.scopes,
|
|
1609
2049
|
...def.manageCommand ? { manageCommand: def.manageCommand } : {},
|
|
2050
|
+
...describeExpectedValue(def) ? { expected: describeExpectedValue(def) } : {},
|
|
2051
|
+
...def.example ? { example: def.example } : {},
|
|
1610
2052
|
effective: getConfigValue(def, options),
|
|
1611
2053
|
project: readScopeValue(def, "project", options),
|
|
1612
2054
|
global: readScopeValue(def, "global", options)
|
|
@@ -1654,12 +2096,12 @@ function projectSlug() {
|
|
|
1654
2096
|
return `${name}-${hash}`;
|
|
1655
2097
|
}
|
|
1656
2098
|
function artifactsRoot() {
|
|
1657
|
-
return process.env.ARGENT_ARTIFACTS_DIR ??
|
|
2099
|
+
return process.env.ARGENT_ARTIFACTS_DIR ?? join9(tmpdir2(), "argent-artifacts");
|
|
1658
2100
|
}
|
|
1659
2101
|
function artifactDir(deviceId) {
|
|
1660
2102
|
const parts = [artifactsRoot(), projectSlug(), sessionId()];
|
|
1661
2103
|
if (deviceId) parts.push(sanitizeSegment(deviceId));
|
|
1662
|
-
return
|
|
2104
|
+
return join9(...parts);
|
|
1663
2105
|
}
|
|
1664
2106
|
function durableBaseDir() {
|
|
1665
2107
|
const projectRoot = findProjectRoot(process.cwd());
|
|
@@ -1678,8 +2120,8 @@ function configuredRecordingsDir() {
|
|
|
1678
2120
|
const trimmed = value.trim();
|
|
1679
2121
|
if (trimmed === "") return null;
|
|
1680
2122
|
const home = dirname5(argentHomeDir());
|
|
1681
|
-
const expanded = trimmed === "~" ? home : trimmed.startsWith("~/") || trimmed.startsWith(`~${sep2}`) ?
|
|
1682
|
-
return
|
|
2123
|
+
const expanded = trimmed === "~" ? home : trimmed.startsWith("~/") || trimmed.startsWith(`~${sep2}`) ? join9(home, trimmed.slice(2)) : trimmed;
|
|
2124
|
+
return resolve6(durableBaseDir(), expanded);
|
|
1683
2125
|
}
|
|
1684
2126
|
var MAX_DURABLE_BYTES = 2 * 1024 * 1024 * 1024;
|
|
1685
2127
|
async function readCapped(res, cap) {
|
|
@@ -1712,10 +2154,10 @@ async function writeDurableUnique(dir, filename, write) {
|
|
|
1712
2154
|
const stem = filename.slice(0, filename.length - ext.length);
|
|
1713
2155
|
for (let i2 = 1; i2 <= 1e3; i2++) {
|
|
1714
2156
|
const candidate = i2 === 1 ? filename : `${stem} (${i2})${ext}`;
|
|
1715
|
-
const
|
|
2157
|
+
const path17 = join9(dir, candidate);
|
|
1716
2158
|
try {
|
|
1717
|
-
await write(
|
|
1718
|
-
return
|
|
2159
|
+
await write(path17);
|
|
2160
|
+
return path17;
|
|
1719
2161
|
} catch (err) {
|
|
1720
2162
|
if (err?.code === "EEXIST") continue;
|
|
1721
2163
|
throw err;
|
|
@@ -1735,21 +2177,21 @@ function durableSaveTarget(handle) {
|
|
|
1735
2177
|
if (configured) {
|
|
1736
2178
|
return {
|
|
1737
2179
|
dir: configured,
|
|
1738
|
-
path:
|
|
2180
|
+
path: join9(configured, sanitizeSegment(handle.filename)),
|
|
1739
2181
|
base: configured,
|
|
1740
2182
|
rel: ""
|
|
1741
2183
|
};
|
|
1742
2184
|
}
|
|
1743
2185
|
}
|
|
1744
2186
|
const base = durableBaseDir();
|
|
1745
|
-
const dir =
|
|
1746
|
-
return { dir, path:
|
|
2187
|
+
const dir = join9(base, rel);
|
|
2188
|
+
return { dir, path: join9(dir, sanitizeSegment(handle.filename)), base, rel };
|
|
1747
2189
|
}
|
|
1748
2190
|
async function confineToRealBase(dir, base, rel) {
|
|
1749
2191
|
try {
|
|
1750
2192
|
const realDir = await realpath(dir);
|
|
1751
2193
|
const realBase = await realpath(base);
|
|
1752
|
-
return realDir ===
|
|
2194
|
+
return realDir === join9(realBase, rel);
|
|
1753
2195
|
} catch {
|
|
1754
2196
|
return false;
|
|
1755
2197
|
}
|
|
@@ -1772,7 +2214,7 @@ async function resolveLocalFile(handle) {
|
|
|
1772
2214
|
}
|
|
1773
2215
|
}
|
|
1774
2216
|
async function downloadAndExtractArchive(handle, data, dir) {
|
|
1775
|
-
const tarball2 =
|
|
2217
|
+
const tarball2 = join9(dir, `${sanitizeSegment(handle.filename)}.tar.gz`);
|
|
1776
2218
|
try {
|
|
1777
2219
|
await writeFile4(tarball2, data);
|
|
1778
2220
|
return await safeExtractTarGz(tarball2, dir, handle.filename);
|
|
@@ -1862,7 +2304,7 @@ async function materializeArtifacts(result, ctx) {
|
|
|
1862
2304
|
return await downloadAndExtractArchive(value, data, dir);
|
|
1863
2305
|
}
|
|
1864
2306
|
if (value.size > 0 && data.length !== value.size) return null;
|
|
1865
|
-
const downloadedPath =
|
|
2307
|
+
const downloadedPath = join9(dir, sanitizeSegment(value.filename));
|
|
1866
2308
|
await writeFile4(downloadedPath, data);
|
|
1867
2309
|
if (value.mimeType.startsWith("image/")) {
|
|
1868
2310
|
images.push({ localPath: downloadedPath, data, mimeType: value.mimeType });
|
|
@@ -1922,8 +2364,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname6(proce
|
|
|
1922
2364
|
return decodedFile;
|
|
1923
2365
|
};
|
|
1924
2366
|
}
|
|
1925
|
-
function normalizeWindowsPath(
|
|
1926
|
-
return
|
|
2367
|
+
function normalizeWindowsPath(path17) {
|
|
2368
|
+
return path17.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
|
|
1927
2369
|
}
|
|
1928
2370
|
|
|
1929
2371
|
// ../../node_modules/@posthog/core/dist/featureFlagUtils.mjs
|
|
@@ -4475,15 +4917,15 @@ async function addSourceContext(frames) {
|
|
|
4475
4917
|
LRU_FILE_CONTENTS_CACHE.reduce();
|
|
4476
4918
|
return frames;
|
|
4477
4919
|
}
|
|
4478
|
-
function getContextLinesFromFile(
|
|
4479
|
-
return new Promise((
|
|
4480
|
-
const stream = createReadStream2(
|
|
4920
|
+
function getContextLinesFromFile(path17, ranges, output) {
|
|
4921
|
+
return new Promise((resolve10) => {
|
|
4922
|
+
const stream = createReadStream2(path17);
|
|
4481
4923
|
const lineReaded = createInterface2({
|
|
4482
4924
|
input: stream
|
|
4483
4925
|
});
|
|
4484
4926
|
function destroyStreamAndResolve() {
|
|
4485
4927
|
stream.destroy();
|
|
4486
|
-
|
|
4928
|
+
resolve10();
|
|
4487
4929
|
}
|
|
4488
4930
|
let lineNumber = 0;
|
|
4489
4931
|
let currentRangeIndex = 0;
|
|
@@ -4492,7 +4934,7 @@ function getContextLinesFromFile(path16, ranges, output) {
|
|
|
4492
4934
|
let rangeStart = range[0];
|
|
4493
4935
|
let rangeEnd = range[1];
|
|
4494
4936
|
function onStreamError() {
|
|
4495
|
-
LRU_FILE_CONTENTS_FS_READ_FAILED.set(
|
|
4937
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(path17, 1);
|
|
4496
4938
|
lineReaded.close();
|
|
4497
4939
|
lineReaded.removeAllListeners();
|
|
4498
4940
|
destroyStreamAndResolve();
|
|
@@ -4553,8 +4995,8 @@ function clearLineContext(frame) {
|
|
|
4553
4995
|
delete frame.context_line;
|
|
4554
4996
|
delete frame.post_context;
|
|
4555
4997
|
}
|
|
4556
|
-
function shouldSkipContextLinesForFile(
|
|
4557
|
-
return
|
|
4998
|
+
function shouldSkipContextLinesForFile(path17) {
|
|
4999
|
+
return path17.startsWith("node:") || path17.endsWith(".min.js") || path17.endsWith(".min.cjs") || path17.endsWith(".min.mjs") || path17.startsWith("data:");
|
|
4558
5000
|
}
|
|
4559
5001
|
function shouldSkipContextLinesForFrame(frame) {
|
|
4560
5002
|
if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
|
|
@@ -5780,9 +6222,9 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
|
|
|
5780
6222
|
if (!waitUntil) return;
|
|
5781
6223
|
if (this.disabled || this.optedOut) return;
|
|
5782
6224
|
if (!this._waitUntilCycle) {
|
|
5783
|
-
let
|
|
6225
|
+
let resolve10;
|
|
5784
6226
|
const promise = new Promise((r2) => {
|
|
5785
|
-
|
|
6227
|
+
resolve10 = r2;
|
|
5786
6228
|
});
|
|
5787
6229
|
try {
|
|
5788
6230
|
waitUntil(promise);
|
|
@@ -5790,7 +6232,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
|
|
|
5790
6232
|
return;
|
|
5791
6233
|
}
|
|
5792
6234
|
this._waitUntilCycle = {
|
|
5793
|
-
resolve:
|
|
6235
|
+
resolve: resolve10,
|
|
5794
6236
|
startedAt: Date.now(),
|
|
5795
6237
|
timer: void 0
|
|
5796
6238
|
};
|
|
@@ -5814,12 +6256,12 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
|
|
|
5814
6256
|
return cycle?.resolve;
|
|
5815
6257
|
}
|
|
5816
6258
|
async resolveWaitUntilFlush() {
|
|
5817
|
-
const
|
|
6259
|
+
const resolve10 = this._consumeWaitUntilCycle();
|
|
5818
6260
|
try {
|
|
5819
6261
|
await super.flush();
|
|
5820
6262
|
} catch {
|
|
5821
6263
|
} finally {
|
|
5822
|
-
|
|
6264
|
+
resolve10?.();
|
|
5823
6265
|
}
|
|
5824
6266
|
}
|
|
5825
6267
|
getPersistedProperty(key) {
|
|
@@ -5940,15 +6382,15 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
|
|
|
5940
6382
|
async waitForLocalEvaluationReady(timeoutMs = THIRTY_SECONDS) {
|
|
5941
6383
|
if (this.isLocalEvaluationReady()) return true;
|
|
5942
6384
|
if (void 0 === this.featureFlagsPoller) return false;
|
|
5943
|
-
return new Promise((
|
|
6385
|
+
return new Promise((resolve10) => {
|
|
5944
6386
|
const timeout = setTimeout(() => {
|
|
5945
6387
|
cleanup();
|
|
5946
|
-
|
|
6388
|
+
resolve10(false);
|
|
5947
6389
|
}, timeoutMs);
|
|
5948
6390
|
const cleanup = this._events.on("localEvaluationFlagsLoaded", (count) => {
|
|
5949
6391
|
clearTimeout(timeout);
|
|
5950
6392
|
cleanup();
|
|
5951
|
-
|
|
6393
|
+
resolve10(count > 0);
|
|
5952
6394
|
});
|
|
5953
6395
|
});
|
|
5954
6396
|
}
|
|
@@ -6403,14 +6845,14 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
|
|
|
6403
6845
|
this.context?.enter(data, options);
|
|
6404
6846
|
}
|
|
6405
6847
|
async _shutdown(shutdownTimeoutMs) {
|
|
6406
|
-
const
|
|
6848
|
+
const resolve10 = this._consumeWaitUntilCycle();
|
|
6407
6849
|
await this.featureFlagsPoller?.stopPoller(shutdownTimeoutMs);
|
|
6408
6850
|
this.errorTracking.shutdown();
|
|
6409
6851
|
try {
|
|
6410
6852
|
return await super._shutdown(shutdownTimeoutMs);
|
|
6411
6853
|
} finally {
|
|
6412
6854
|
this.distinctIdHasSentFlagCalls = {};
|
|
6413
|
-
|
|
6855
|
+
resolve10?.();
|
|
6414
6856
|
}
|
|
6415
6857
|
}
|
|
6416
6858
|
async _requestRemoteConfigPayload(flagKey) {
|
|
@@ -6808,6 +7250,7 @@ var FAILURE_CODES = {
|
|
|
6808
7250
|
CLI_RUN_FLAG_PARSE_FAILED: "CLI_RUN_FLAG_PARSE_FAILED",
|
|
6809
7251
|
CLI_RUN_ARGS_NOT_OBJECT: "CLI_RUN_ARGS_NOT_OBJECT",
|
|
6810
7252
|
CLI_RUN_ARGS_JSON_INVALID: "CLI_RUN_ARGS_JSON_INVALID",
|
|
7253
|
+
CLI_RUN_INPUT_VALIDATION_FAILED: "CLI_RUN_INPUT_VALIDATION_FAILED",
|
|
6811
7254
|
CLI_RUN_TOOL_CALL_FAILED: "CLI_RUN_TOOL_CALL_FAILED",
|
|
6812
7255
|
CLI_RUN_SAVE_IMAGE_FAILED: "CLI_RUN_SAVE_IMAGE_FAILED",
|
|
6813
7256
|
TOOL_CAPABILITY_UNSUPPORTED_OPERATION: "TOOL_CAPABILITY_UNSUPPORTED_OPERATION",
|
|
@@ -7009,6 +7452,7 @@ var FAILURE_CODES = {
|
|
|
7009
7452
|
CHROMIUM_DEVICE_ID_INVALID: "CHROMIUM_DEVICE_ID_INVALID",
|
|
7010
7453
|
CHROMIUM_PARAM_INVALID: "CHROMIUM_PARAM_INVALID",
|
|
7011
7454
|
CHROMIUM_INPUT_INVALID: "CHROMIUM_INPUT_INVALID",
|
|
7455
|
+
CHROMIUM_WINDOW_HIDDEN: "CHROMIUM_WINDOW_HIDDEN",
|
|
7012
7456
|
CHROMIUM_VIEWPORT_READ_FAILED: "CHROMIUM_VIEWPORT_READ_FAILED",
|
|
7013
7457
|
CHROMIUM_SCREENSHOT_FAILED: "CHROMIUM_SCREENSHOT_FAILED",
|
|
7014
7458
|
CHROMIUM_STORAGE_EVAL_FAILED: "CHROMIUM_STORAGE_EVAL_FAILED",
|
|
@@ -7395,9 +7839,9 @@ function isReplitAgent(env) {
|
|
|
7395
7839
|
}
|
|
7396
7840
|
var DEVIN_MARKER_PATH = "/opt/.devin";
|
|
7397
7841
|
var JULES_MARKER_PATH = "/opt/environment_summary.sh";
|
|
7398
|
-
function safeExists(fileExists,
|
|
7842
|
+
function safeExists(fileExists, path17) {
|
|
7399
7843
|
try {
|
|
7400
|
-
return fileExists(
|
|
7844
|
+
return fileExists(path17);
|
|
7401
7845
|
} catch {
|
|
7402
7846
|
return false;
|
|
7403
7847
|
}
|
|
@@ -7818,7 +8262,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
|
|
|
7818
8262
|
var SESSION_ID2 = randomUUID5();
|
|
7819
8263
|
function readCliVersion() {
|
|
7820
8264
|
if (true) {
|
|
7821
|
-
return "0.18.
|
|
8265
|
+
return "0.18.1";
|
|
7822
8266
|
}
|
|
7823
8267
|
return "0.0.0";
|
|
7824
8268
|
}
|
|
@@ -7852,16 +8296,16 @@ function getBaseProps(runtime) {
|
|
|
7852
8296
|
|
|
7853
8297
|
// ../telemetry/src/identity.ts
|
|
7854
8298
|
import * as crypto2 from "node:crypto";
|
|
7855
|
-
import * as
|
|
7856
|
-
import * as
|
|
8299
|
+
import * as fs5 from "node:fs";
|
|
8300
|
+
import * as path10 from "node:path";
|
|
7857
8301
|
|
|
7858
8302
|
// ../telemetry/src/paths.ts
|
|
7859
|
-
import * as
|
|
8303
|
+
import * as path9 from "node:path";
|
|
7860
8304
|
function identityFilePath() {
|
|
7861
|
-
return
|
|
8305
|
+
return path9.join(argentHomeDir(), "telemetry-id");
|
|
7862
8306
|
}
|
|
7863
8307
|
function debugLogPath() {
|
|
7864
|
-
return
|
|
8308
|
+
return path9.join(argentHomeDir(), "telemetry-debug.log");
|
|
7865
8309
|
}
|
|
7866
8310
|
|
|
7867
8311
|
// ../telemetry/src/identity.ts
|
|
@@ -7960,66 +8404,66 @@ function resolveFingerprintOnce(resolveFingerprint) {
|
|
|
7960
8404
|
function isCorruptIdFile(filePath) {
|
|
7961
8405
|
let isRegularFile;
|
|
7962
8406
|
try {
|
|
7963
|
-
isRegularFile =
|
|
8407
|
+
isRegularFile = fs5.lstatSync(filePath).isFile();
|
|
7964
8408
|
} catch {
|
|
7965
8409
|
return false;
|
|
7966
8410
|
}
|
|
7967
8411
|
return isRegularFile && tryReadId(filePath) === null;
|
|
7968
8412
|
}
|
|
7969
8413
|
function writeIdFileAtomic(finalPath, id) {
|
|
7970
|
-
|
|
8414
|
+
fs5.mkdirSync(argentHomeDir(), { recursive: true });
|
|
7971
8415
|
let occupant;
|
|
7972
8416
|
try {
|
|
7973
|
-
occupant =
|
|
8417
|
+
occupant = fs5.lstatSync(finalPath);
|
|
7974
8418
|
} catch (err) {
|
|
7975
8419
|
if (err.code !== "ENOENT") throw err;
|
|
7976
8420
|
}
|
|
7977
8421
|
if (occupant && !occupant.isFile()) {
|
|
7978
8422
|
throw new Error("telemetry: refusing to replace a non-regular file at the identity path");
|
|
7979
8423
|
}
|
|
7980
|
-
const tmpPath =
|
|
8424
|
+
const tmpPath = path10.join(
|
|
7981
8425
|
argentHomeDir(),
|
|
7982
8426
|
`.telemetry-id.tmp.${process.pid}.${crypto2.randomUUID()}`
|
|
7983
8427
|
);
|
|
7984
|
-
const fd =
|
|
8428
|
+
const fd = fs5.openSync(tmpPath, "wx", 384);
|
|
7985
8429
|
try {
|
|
7986
8430
|
try {
|
|
7987
|
-
|
|
7988
|
-
|
|
8431
|
+
fs5.writeSync(fd, id);
|
|
8432
|
+
fs5.fsyncSync(fd);
|
|
7989
8433
|
} finally {
|
|
7990
|
-
|
|
8434
|
+
fs5.closeSync(fd);
|
|
7991
8435
|
}
|
|
7992
|
-
|
|
8436
|
+
fs5.renameSync(tmpPath, finalPath);
|
|
7993
8437
|
} finally {
|
|
7994
8438
|
try {
|
|
7995
|
-
|
|
8439
|
+
fs5.unlinkSync(tmpPath);
|
|
7996
8440
|
} catch {
|
|
7997
8441
|
}
|
|
7998
8442
|
}
|
|
7999
8443
|
}
|
|
8000
8444
|
function mintRandomId(finalPath) {
|
|
8001
|
-
|
|
8445
|
+
fs5.mkdirSync(argentHomeDir(), { recursive: true });
|
|
8002
8446
|
let value = crypto2.randomUUID();
|
|
8003
8447
|
for (let attempt = 0; attempt < 3; attempt++) {
|
|
8004
|
-
const tmpPath =
|
|
8448
|
+
const tmpPath = path10.join(
|
|
8005
8449
|
argentHomeDir(),
|
|
8006
8450
|
`.telemetry-id.tmp.${process.pid}.${crypto2.randomUUID()}`
|
|
8007
8451
|
);
|
|
8008
8452
|
let fd;
|
|
8009
8453
|
try {
|
|
8010
|
-
fd =
|
|
8454
|
+
fd = fs5.openSync(tmpPath, "wx", 384);
|
|
8011
8455
|
} catch (err) {
|
|
8012
8456
|
if (err.code === "EEXIST") continue;
|
|
8013
8457
|
throw err;
|
|
8014
8458
|
}
|
|
8015
8459
|
try {
|
|
8016
8460
|
try {
|
|
8017
|
-
|
|
8018
|
-
|
|
8461
|
+
fs5.writeSync(fd, value);
|
|
8462
|
+
fs5.fsyncSync(fd);
|
|
8019
8463
|
} finally {
|
|
8020
|
-
|
|
8464
|
+
fs5.closeSync(fd);
|
|
8021
8465
|
}
|
|
8022
|
-
|
|
8466
|
+
fs5.linkSync(tmpPath, finalPath);
|
|
8023
8467
|
cached = { path: finalPath, id: value };
|
|
8024
8468
|
return value;
|
|
8025
8469
|
} catch (err) {
|
|
@@ -8038,7 +8482,7 @@ function mintRandomId(finalPath) {
|
|
|
8038
8482
|
throw err;
|
|
8039
8483
|
} finally {
|
|
8040
8484
|
try {
|
|
8041
|
-
|
|
8485
|
+
fs5.unlinkSync(tmpPath);
|
|
8042
8486
|
} catch {
|
|
8043
8487
|
}
|
|
8044
8488
|
}
|
|
@@ -8046,12 +8490,12 @@ function mintRandomId(finalPath) {
|
|
|
8046
8490
|
throw new Error("telemetry: failed to create identity after retries");
|
|
8047
8491
|
}
|
|
8048
8492
|
function claimCorruptOccupant(finalPath) {
|
|
8049
|
-
const claimed =
|
|
8493
|
+
const claimed = path10.join(
|
|
8050
8494
|
argentHomeDir(),
|
|
8051
8495
|
`.telemetry-id.corrupt.${process.pid}.${crypto2.randomUUID()}`
|
|
8052
8496
|
);
|
|
8053
8497
|
try {
|
|
8054
|
-
|
|
8498
|
+
fs5.renameSync(finalPath, claimed);
|
|
8055
8499
|
} catch {
|
|
8056
8500
|
return null;
|
|
8057
8501
|
}
|
|
@@ -8060,7 +8504,7 @@ function claimCorruptOccupant(finalPath) {
|
|
|
8060
8504
|
grabbed = tryReadId(claimed);
|
|
8061
8505
|
} finally {
|
|
8062
8506
|
try {
|
|
8063
|
-
|
|
8507
|
+
fs5.unlinkSync(claimed);
|
|
8064
8508
|
} catch {
|
|
8065
8509
|
}
|
|
8066
8510
|
}
|
|
@@ -8072,9 +8516,9 @@ function peekAnonId() {
|
|
|
8072
8516
|
function tryReadId(filePath) {
|
|
8073
8517
|
let raw;
|
|
8074
8518
|
try {
|
|
8075
|
-
const stats =
|
|
8519
|
+
const stats = fs5.lstatSync(filePath);
|
|
8076
8520
|
if (!stats.isFile()) return null;
|
|
8077
|
-
raw =
|
|
8521
|
+
raw = fs5.readFileSync(filePath, "utf8");
|
|
8078
8522
|
} catch (err) {
|
|
8079
8523
|
if (err.code === "ENOENT") return null;
|
|
8080
8524
|
return null;
|
|
@@ -8088,12 +8532,12 @@ function tryReadId(filePath) {
|
|
|
8088
8532
|
import { execFileSync as execFileSync2, spawn as spawn2 } from "node:child_process";
|
|
8089
8533
|
|
|
8090
8534
|
// ../native-devtools-ios/src/index.ts
|
|
8091
|
-
import * as
|
|
8092
|
-
import * as
|
|
8093
|
-
var DYLIB_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_DIR ??
|
|
8094
|
-
var BIN_DIR = process.env.ARGENT_SIMULATOR_SERVER_DIR ??
|
|
8095
|
-
var DYLIB_TCP_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_TCP_DIR ??
|
|
8096
|
-
var DYLIB_TVOS_DIR =
|
|
8535
|
+
import * as path11 from "node:path";
|
|
8536
|
+
import * as fs6 from "node:fs";
|
|
8537
|
+
var DYLIB_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_DIR ?? path11.join(__dirname, "..", "dylibs");
|
|
8538
|
+
var BIN_DIR = process.env.ARGENT_SIMULATOR_SERVER_DIR ?? path11.join(__dirname, "..", "bin");
|
|
8539
|
+
var DYLIB_TCP_DIR = process.env.ARGENT_NATIVE_DEVTOOLS_TCP_DIR ?? path11.join(DYLIB_DIR, "tcp");
|
|
8540
|
+
var DYLIB_TVOS_DIR = path11.join(DYLIB_DIR, "tvos");
|
|
8097
8541
|
function hostPlatformKey() {
|
|
8098
8542
|
if (process.platform === "linux" && process.arch === "arm64") {
|
|
8099
8543
|
return "linux-arm64";
|
|
@@ -8104,14 +8548,14 @@ function simulatorServerBinaryName() {
|
|
|
8104
8548
|
return process.platform === "win32" ? "simulator-server.exe" : "simulator-server";
|
|
8105
8549
|
}
|
|
8106
8550
|
function platformBinDir() {
|
|
8107
|
-
return
|
|
8551
|
+
return path11.join(BIN_DIR, hostPlatformKey());
|
|
8108
8552
|
}
|
|
8109
8553
|
function simulatorServerBinaryPath() {
|
|
8110
8554
|
const binaryName = simulatorServerBinaryName();
|
|
8111
|
-
const p =
|
|
8112
|
-
if (!
|
|
8113
|
-
const flat =
|
|
8114
|
-
const migrationHint =
|
|
8555
|
+
const p = path11.join(platformBinDir(), binaryName);
|
|
8556
|
+
if (!fs6.existsSync(p)) {
|
|
8557
|
+
const flat = path11.join(BIN_DIR, binaryName);
|
|
8558
|
+
const migrationHint = fs6.existsSync(flat) ? ` Found a binary at the old flat path ${flat}; move it to ${p} or update ARGENT_SIMULATOR_SERVER_DIR to point at the parent of the platform subdirectory.` : "";
|
|
8115
8559
|
throw new Error(
|
|
8116
8560
|
`simulator-server binary not found for platform "${hostPlatformKey()}" at ${p}. Supported hosts today: darwin, linux (x86_64 and arm64), win32.${migrationHint}`
|
|
8117
8561
|
);
|
|
@@ -8144,12 +8588,12 @@ function resolveHostFingerprint() {
|
|
|
8144
8588
|
}
|
|
8145
8589
|
}
|
|
8146
8590
|
function resolveHostFingerprintAsync() {
|
|
8147
|
-
return new Promise((
|
|
8591
|
+
return new Promise((resolve10) => {
|
|
8148
8592
|
let binary;
|
|
8149
8593
|
try {
|
|
8150
8594
|
binary = simulatorServerBinaryPath();
|
|
8151
8595
|
} catch {
|
|
8152
|
-
|
|
8596
|
+
resolve10(null);
|
|
8153
8597
|
return;
|
|
8154
8598
|
}
|
|
8155
8599
|
let settled = false;
|
|
@@ -8162,7 +8606,7 @@ function resolveHostFingerprintAsync() {
|
|
|
8162
8606
|
child?.kill("SIGKILL");
|
|
8163
8607
|
} catch {
|
|
8164
8608
|
}
|
|
8165
|
-
|
|
8609
|
+
resolve10(value);
|
|
8166
8610
|
};
|
|
8167
8611
|
const watchdog = setTimeout(() => finish(null), FINGERPRINT_TIMEOUT_MS);
|
|
8168
8612
|
watchdog.unref?.();
|
|
@@ -8195,13 +8639,13 @@ function resolveHostFingerprintAsync() {
|
|
|
8195
8639
|
}
|
|
8196
8640
|
|
|
8197
8641
|
// ../telemetry/src/consent.ts
|
|
8198
|
-
import * as
|
|
8642
|
+
import * as fs7 from "node:fs";
|
|
8199
8643
|
var cache = { current: null };
|
|
8200
8644
|
var sessionOverride = null;
|
|
8201
8645
|
function readConfigOverride() {
|
|
8202
8646
|
let stats;
|
|
8203
8647
|
try {
|
|
8204
|
-
stats =
|
|
8648
|
+
stats = fs7.lstatSync(configFilePath());
|
|
8205
8649
|
} catch (err) {
|
|
8206
8650
|
if (err.code === "ENOENT") {
|
|
8207
8651
|
cache.current = { mtimeMs: null, fingerprint: null, enabledOverride: null };
|
|
@@ -8221,7 +8665,7 @@ function readConfigOverride() {
|
|
|
8221
8665
|
}
|
|
8222
8666
|
let parsedEnabled = null;
|
|
8223
8667
|
try {
|
|
8224
|
-
const raw =
|
|
8668
|
+
const raw = fs7.readFileSync(configFilePath(), "utf8");
|
|
8225
8669
|
const json = JSON.parse(raw);
|
|
8226
8670
|
if (json && typeof json === "object") {
|
|
8227
8671
|
const t2 = json.telemetry;
|
|
@@ -8282,7 +8726,7 @@ function writeConsentFlag(enabled) {
|
|
|
8282
8726
|
}
|
|
8283
8727
|
|
|
8284
8728
|
// ../telemetry/src/debug.ts
|
|
8285
|
-
import * as
|
|
8729
|
+
import * as fs8 from "node:fs";
|
|
8286
8730
|
function isDebugEnabled(env = process.env) {
|
|
8287
8731
|
const v = env.ARGENT_TELEMETRY_DEBUG;
|
|
8288
8732
|
if (!v) return false;
|
|
@@ -8309,8 +8753,8 @@ function emitDebugPayload(payload) {
|
|
|
8309
8753
|
} catch {
|
|
8310
8754
|
}
|
|
8311
8755
|
try {
|
|
8312
|
-
|
|
8313
|
-
|
|
8756
|
+
fs8.mkdirSync(argentHomeDir(), { recursive: true });
|
|
8757
|
+
fs8.appendFileSync(debugLogPath(), line + "\n");
|
|
8314
8758
|
} catch {
|
|
8315
8759
|
}
|
|
8316
8760
|
}
|
|
@@ -8404,7 +8848,7 @@ async function shutdown(timeoutMs = SHORT_FLUSH_TIMEOUT_MS) {
|
|
|
8404
8848
|
try {
|
|
8405
8849
|
await Promise.race([
|
|
8406
8850
|
client2.shutdown(timeoutMs),
|
|
8407
|
-
new Promise((
|
|
8851
|
+
new Promise((resolve10) => setTimeout(resolve10, timeoutMs + 250).unref())
|
|
8408
8852
|
]);
|
|
8409
8853
|
} catch (err) {
|
|
8410
8854
|
emitDebugError("shutdown failed", err);
|
|
@@ -8424,7 +8868,7 @@ async function markDisabled() {
|
|
|
8424
8868
|
try {
|
|
8425
8869
|
await Promise.race([
|
|
8426
8870
|
client2.shutdown(SHORT_FLUSH_TIMEOUT_MS),
|
|
8427
|
-
new Promise((
|
|
8871
|
+
new Promise((resolve10) => setTimeout(resolve10, SHORT_FLUSH_TIMEOUT_MS).unref())
|
|
8428
8872
|
]);
|
|
8429
8873
|
} catch {
|
|
8430
8874
|
}
|
|
@@ -8457,6 +8901,18 @@ var FlagParseException = class extends Error {
|
|
|
8457
8901
|
function isScalarType(type) {
|
|
8458
8902
|
return type === "string" || type === "number" || type === "integer" || type === "boolean";
|
|
8459
8903
|
}
|
|
8904
|
+
function isJsonField(prop) {
|
|
8905
|
+
return prop?.type === "object" || prop?.type === "array" && !isScalarType(prop.items?.type);
|
|
8906
|
+
}
|
|
8907
|
+
function flagNameFor(name, prop) {
|
|
8908
|
+
return isJsonField(prop) ? `--${name}-json` : `--${name}`;
|
|
8909
|
+
}
|
|
8910
|
+
function booleanLiteral(raw) {
|
|
8911
|
+
const value = raw.trim().toLowerCase();
|
|
8912
|
+
if (value === "true" || value === "1") return true;
|
|
8913
|
+
if (value === "false" || value === "0") return false;
|
|
8914
|
+
return void 0;
|
|
8915
|
+
}
|
|
8460
8916
|
function coerceScalar(raw, type, field) {
|
|
8461
8917
|
if (type === "number") {
|
|
8462
8918
|
if (raw.trim() === "")
|
|
@@ -8474,9 +8930,9 @@ function coerceScalar(raw, type, field) {
|
|
|
8474
8930
|
return n2;
|
|
8475
8931
|
}
|
|
8476
8932
|
if (type === "boolean") {
|
|
8477
|
-
|
|
8478
|
-
if (
|
|
8479
|
-
throw new FlagParseException(`--${field} expected true/false, got "${raw}"`);
|
|
8933
|
+
const value = booleanLiteral(raw);
|
|
8934
|
+
if (value !== void 0) return value;
|
|
8935
|
+
throw new FlagParseException(`--${field} expected true/false (or 1/0), got "${raw}"`);
|
|
8480
8936
|
}
|
|
8481
8937
|
return raw;
|
|
8482
8938
|
}
|
|
@@ -8553,6 +9009,12 @@ function parseFlags(argv, schema) {
|
|
|
8553
9009
|
if (inlineValue !== void 0) {
|
|
8554
9010
|
throw new FlagParseException(`--no-${fieldName} does not take a value`);
|
|
8555
9011
|
}
|
|
9012
|
+
const following = i2 + 1 < argv.length ? booleanLiteral(argv[i2 + 1]) : void 0;
|
|
9013
|
+
if (following !== void 0) {
|
|
9014
|
+
throw new FlagParseException(
|
|
9015
|
+
`--no-${fieldName} does not take a value; use --${fieldName} ${following}`
|
|
9016
|
+
);
|
|
9017
|
+
}
|
|
8556
9018
|
args[fieldName] = false;
|
|
8557
9019
|
continue;
|
|
8558
9020
|
}
|
|
@@ -8561,6 +9023,12 @@ function parseFlags(argv, schema) {
|
|
|
8561
9023
|
if (propSchema?.type === "boolean") {
|
|
8562
9024
|
if (inlineValue !== void 0) {
|
|
8563
9025
|
args[flag] = coerceScalar(inlineValue, "boolean", flag);
|
|
9026
|
+
continue;
|
|
9027
|
+
}
|
|
9028
|
+
const next = i2 + 1 < argv.length ? booleanLiteral(argv[i2 + 1]) : void 0;
|
|
9029
|
+
if (next !== void 0) {
|
|
9030
|
+
args[flag] = next;
|
|
9031
|
+
i2 += 1;
|
|
8564
9032
|
} else {
|
|
8565
9033
|
args[flag] = true;
|
|
8566
9034
|
}
|
|
@@ -8618,14 +9086,19 @@ function formatSchemaUsage(schema) {
|
|
|
8618
9086
|
const desc = prop.description ? ` ${prop.description}` : "";
|
|
8619
9087
|
lines.push(` ${flag} ${typeLabel}${req}${desc}`);
|
|
8620
9088
|
}
|
|
9089
|
+
if (entries.some(([, prop]) => prop.type === "boolean")) {
|
|
9090
|
+
lines.push(
|
|
9091
|
+
"",
|
|
9092
|
+
" Booleans: --flag, --flag true, or --flag 1 sets true; --flag false, --flag 0, --flag=false, or --no-flag sets false."
|
|
9093
|
+
);
|
|
9094
|
+
}
|
|
8621
9095
|
return lines.join("\n");
|
|
8622
9096
|
}
|
|
8623
9097
|
function renderFlagName(name, prop) {
|
|
8624
|
-
|
|
8625
|
-
|
|
8626
|
-
|
|
8627
|
-
|
|
8628
|
-
return `--${name} <value>`;
|
|
9098
|
+
const flag = flagNameFor(name, prop);
|
|
9099
|
+
if (isJsonField(prop)) return `${flag} <json>`;
|
|
9100
|
+
if (prop.type === "boolean") return flag;
|
|
9101
|
+
return `${flag} <value>`;
|
|
8629
9102
|
}
|
|
8630
9103
|
function renderType(prop) {
|
|
8631
9104
|
if (prop.enum && Array.isArray(prop.enum)) {
|
|
@@ -8639,6 +9112,93 @@ function renderType(prop) {
|
|
|
8639
9112
|
return prop.type ?? "any";
|
|
8640
9113
|
}
|
|
8641
9114
|
|
|
9115
|
+
// ../argent-cli/src/run-validation.ts
|
|
9116
|
+
function findMissingRequired(payload, schema) {
|
|
9117
|
+
const required = new Set(schema?.required ?? []);
|
|
9118
|
+
if (required.size === 0) return [];
|
|
9119
|
+
const declared = Object.keys(schema?.properties ?? {});
|
|
9120
|
+
const names = [...declared.filter((n2) => required.has(n2))];
|
|
9121
|
+
for (const name of required) {
|
|
9122
|
+
if (!names.includes(name)) names.push(name);
|
|
9123
|
+
}
|
|
9124
|
+
return names.filter((name) => !Object.hasOwn(payload, name));
|
|
9125
|
+
}
|
|
9126
|
+
function describeServerValidationFailure(err, payload, schema) {
|
|
9127
|
+
const message = err instanceof Error ? err.message : typeof err === "string" ? err : null;
|
|
9128
|
+
if (message === null) return null;
|
|
9129
|
+
let parsed;
|
|
9130
|
+
try {
|
|
9131
|
+
parsed = JSON.parse(message);
|
|
9132
|
+
} catch {
|
|
9133
|
+
return null;
|
|
9134
|
+
}
|
|
9135
|
+
if (!Array.isArray(parsed) || parsed.length === 0) return null;
|
|
9136
|
+
if (!parsed.every(isValidationIssue)) return null;
|
|
9137
|
+
const properties = schema?.properties ?? {};
|
|
9138
|
+
const addressesThisTool = (issue) => issue.path.length === 0 || typeof issue.path[0] === "string" && Object.hasOwn(properties, issue.path[0]);
|
|
9139
|
+
if (!parsed.every(addressesThisTool)) return null;
|
|
9140
|
+
const required = new Set(schema?.required ?? []);
|
|
9141
|
+
const missing = [];
|
|
9142
|
+
const invalid = [];
|
|
9143
|
+
for (const issue of parsed) {
|
|
9144
|
+
const head = issue.path[0];
|
|
9145
|
+
if (issue.path.length === 1 && typeof head === "string" && required.has(head) && !Object.hasOwn(payload, head)) {
|
|
9146
|
+
missing.push(head);
|
|
9147
|
+
} else {
|
|
9148
|
+
invalid.push({ path: issue.path, message: issue.message });
|
|
9149
|
+
}
|
|
9150
|
+
}
|
|
9151
|
+
return { missing: sortBySchemaOrder(missing, schema), invalid, rawIssues: parsed };
|
|
9152
|
+
}
|
|
9153
|
+
function formatValidationError(report, schema) {
|
|
9154
|
+
const properties = schema?.properties ?? {};
|
|
9155
|
+
const lines = [];
|
|
9156
|
+
if (report.missing.length > 0) {
|
|
9157
|
+
const flags2 = sortBySchemaOrder(report.missing, schema).map(
|
|
9158
|
+
(name) => flagNameFor(name, properties[name])
|
|
9159
|
+
);
|
|
9160
|
+
const noun = flags2.length === 1 ? "flag" : "flags";
|
|
9161
|
+
lines.push(`missing required ${noun} ${flags2.join(", ")}`);
|
|
9162
|
+
}
|
|
9163
|
+
for (const field of report.invalid) {
|
|
9164
|
+
lines.push(describeInvalidField(field, properties));
|
|
9165
|
+
}
|
|
9166
|
+
return lines.join("\n ");
|
|
9167
|
+
}
|
|
9168
|
+
function missingFlagNames(report, schema) {
|
|
9169
|
+
const properties = schema?.properties ?? {};
|
|
9170
|
+
return sortBySchemaOrder(report.missing, schema).map(
|
|
9171
|
+
(name) => flagNameFor(name, properties[name])
|
|
9172
|
+
);
|
|
9173
|
+
}
|
|
9174
|
+
function describeInvalidField(field, properties) {
|
|
9175
|
+
if (field.path.length === 0) return field.message;
|
|
9176
|
+
const [head, ...rest] = field.path;
|
|
9177
|
+
if (typeof head !== "string") return field.message;
|
|
9178
|
+
const flag = flagNameFor(head, properties[head]);
|
|
9179
|
+
const nested = rest.length > 0 ? ` ${head}${renderPathTail(rest)}` : "";
|
|
9180
|
+
return `${flag}${nested} ${field.message}`;
|
|
9181
|
+
}
|
|
9182
|
+
function renderPathTail(rest) {
|
|
9183
|
+
return rest.map((part) => typeof part === "number" ? `[${part}]` : `.${part}`).join("");
|
|
9184
|
+
}
|
|
9185
|
+
function sortBySchemaOrder(names, schema) {
|
|
9186
|
+
const order = Object.keys(schema?.properties ?? {});
|
|
9187
|
+
return [...names].sort((a2, b) => {
|
|
9188
|
+
const ia = order.indexOf(a2);
|
|
9189
|
+
const ib = order.indexOf(b);
|
|
9190
|
+
if (ia === -1 && ib === -1) return a2.localeCompare(b);
|
|
9191
|
+
if (ia === -1) return 1;
|
|
9192
|
+
if (ib === -1) return -1;
|
|
9193
|
+
return ia - ib;
|
|
9194
|
+
});
|
|
9195
|
+
}
|
|
9196
|
+
function isValidationIssue(value) {
|
|
9197
|
+
if (value === null || typeof value !== "object") return false;
|
|
9198
|
+
const issue = value;
|
|
9199
|
+
return typeof issue.code === "string" && Array.isArray(issue.path) && typeof issue.message === "string";
|
|
9200
|
+
}
|
|
9201
|
+
|
|
8642
9202
|
// ../argent-cli/src/run.ts
|
|
8643
9203
|
function splitOptions(argv) {
|
|
8644
9204
|
let json = false;
|
|
@@ -8666,13 +9226,13 @@ function splitOptions(argv) {
|
|
|
8666
9226
|
return { json, outPath, argvForFlags: rest };
|
|
8667
9227
|
}
|
|
8668
9228
|
async function readStdin() {
|
|
8669
|
-
return new Promise((
|
|
9229
|
+
return new Promise((resolve10, reject) => {
|
|
8670
9230
|
let data = "";
|
|
8671
9231
|
process.stdin.setEncoding("utf8");
|
|
8672
9232
|
process.stdin.on("data", (chunk) => {
|
|
8673
9233
|
data += chunk;
|
|
8674
9234
|
});
|
|
8675
|
-
process.stdin.on("end", () =>
|
|
9235
|
+
process.stdin.on("end", () => resolve10(data));
|
|
8676
9236
|
process.stdin.on("error", reject);
|
|
8677
9237
|
});
|
|
8678
9238
|
}
|
|
@@ -8704,8 +9264,8 @@ async function fetchImageToFile(result, outPath) {
|
|
|
8704
9264
|
const res = await fetch(url);
|
|
8705
9265
|
if (!res.ok) throw new Error(`Failed to download image: ${res.status} ${res.statusText}`);
|
|
8706
9266
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
8707
|
-
|
|
8708
|
-
|
|
9267
|
+
fs9.mkdirSync(path12.dirname(path12.resolve(outPath)), { recursive: true });
|
|
9268
|
+
fs9.writeFileSync(outPath, buf);
|
|
8709
9269
|
}
|
|
8710
9270
|
function renderResult(result, outputHint, images, json) {
|
|
8711
9271
|
if (json) return JSON.stringify(result, null, 2);
|
|
@@ -8750,7 +9310,25 @@ Examples:
|
|
|
8750
9310
|
`);
|
|
8751
9311
|
return;
|
|
8752
9312
|
}
|
|
8753
|
-
|
|
9313
|
+
let cliOptions;
|
|
9314
|
+
try {
|
|
9315
|
+
cliOptions = splitOptions(rest);
|
|
9316
|
+
} catch (err) {
|
|
9317
|
+
if (err instanceof FlagParseException) {
|
|
9318
|
+
console.error(`Error: ${err.message}
|
|
9319
|
+
`);
|
|
9320
|
+
console.error(`Run \`argent run ${toolName} --help\` to see this tool's flags.`);
|
|
9321
|
+
await trackRunFailure(toolName, startedAt, {
|
|
9322
|
+
error_code: FAILURE_CODES.CLI_RUN_FLAG_PARSE_FAILED,
|
|
9323
|
+
failure_stage: "cli_run_split_options",
|
|
9324
|
+
failure_area: "cli",
|
|
9325
|
+
error_kind: "validation"
|
|
9326
|
+
});
|
|
9327
|
+
process.exit(2);
|
|
9328
|
+
}
|
|
9329
|
+
throw err;
|
|
9330
|
+
}
|
|
9331
|
+
const { json, outPath, argvForFlags } = cliOptions;
|
|
8754
9332
|
const meta = await fetchTool(toolName);
|
|
8755
9333
|
if (!meta) {
|
|
8756
9334
|
console.error(`Tool "${toolName}" not found. Run \`argent tools\` to list available tools.`);
|
|
@@ -8762,9 +9340,37 @@ Examples:
|
|
|
8762
9340
|
});
|
|
8763
9341
|
process.exit(1);
|
|
8764
9342
|
}
|
|
9343
|
+
const schema = meta.inputSchema;
|
|
9344
|
+
const failValidation = async (report, stage) => {
|
|
9345
|
+
const summary = formatValidationError(report, schema);
|
|
9346
|
+
if (json) {
|
|
9347
|
+
console.error(
|
|
9348
|
+
JSON.stringify(
|
|
9349
|
+
{
|
|
9350
|
+
error: summary,
|
|
9351
|
+
missing: missingFlagNames(report, schema),
|
|
9352
|
+
issues: report.rawIssues ?? []
|
|
9353
|
+
},
|
|
9354
|
+
null,
|
|
9355
|
+
2
|
|
9356
|
+
)
|
|
9357
|
+
);
|
|
9358
|
+
} else {
|
|
9359
|
+
console.error(`Error: ${summary}
|
|
9360
|
+
`);
|
|
9361
|
+
printToolHelp(meta);
|
|
9362
|
+
}
|
|
9363
|
+
await trackRunFailure(toolName, startedAt, {
|
|
9364
|
+
error_code: FAILURE_CODES.CLI_RUN_INPUT_VALIDATION_FAILED,
|
|
9365
|
+
failure_stage: stage,
|
|
9366
|
+
failure_area: "cli",
|
|
9367
|
+
error_kind: "validation"
|
|
9368
|
+
});
|
|
9369
|
+
process.exit(2);
|
|
9370
|
+
};
|
|
8765
9371
|
let parsed;
|
|
8766
9372
|
try {
|
|
8767
|
-
parsed = parseFlags(argvForFlags,
|
|
9373
|
+
parsed = parseFlags(argvForFlags, schema);
|
|
8768
9374
|
} catch (err) {
|
|
8769
9375
|
if (err instanceof FlagParseException) {
|
|
8770
9376
|
console.error(`Error: ${err.message}
|
|
@@ -8784,6 +9390,11 @@ Examples:
|
|
|
8784
9390
|
printToolHelp(meta);
|
|
8785
9391
|
return;
|
|
8786
9392
|
}
|
|
9393
|
+
if (parsed.positional.length > 0) {
|
|
9394
|
+
console.error(
|
|
9395
|
+
`Note: ignoring unused argument(s): ${parsed.positional.join(", ")}. Pass values as --flag <value> or --flag=<value>.`
|
|
9396
|
+
);
|
|
9397
|
+
}
|
|
8787
9398
|
let payload = {};
|
|
8788
9399
|
if (parsed.rawArgs !== null) {
|
|
8789
9400
|
let rawJson = parsed.rawArgs;
|
|
@@ -8817,6 +9428,10 @@ Examples:
|
|
|
8817
9428
|
for (const [k, v] of Object.entries(parsed.args)) {
|
|
8818
9429
|
payload[k] = v;
|
|
8819
9430
|
}
|
|
9431
|
+
const missing = findMissingRequired(payload, schema);
|
|
9432
|
+
if (missing.length > 0) {
|
|
9433
|
+
await failValidation({ missing, invalid: [], rawIssues: null }, "cli_run_required_flags");
|
|
9434
|
+
}
|
|
8820
9435
|
let result;
|
|
8821
9436
|
let note;
|
|
8822
9437
|
let images = [];
|
|
@@ -8832,6 +9447,10 @@ Examples:
|
|
|
8832
9447
|
images = materialized.images;
|
|
8833
9448
|
note = resp.note;
|
|
8834
9449
|
} catch (err) {
|
|
9450
|
+
const report = describeServerValidationFailure(err, payload, schema);
|
|
9451
|
+
if (report) {
|
|
9452
|
+
await failValidation(report, "cli_run_server_validation");
|
|
9453
|
+
}
|
|
8835
9454
|
console.error(err instanceof Error ? err.message : String(err));
|
|
8836
9455
|
await trackRunFailure(toolName, startedAt, {
|
|
8837
9456
|
error_code: FAILURE_CODES.CLI_RUN_TOOL_CALL_FAILED,
|
|
@@ -8844,8 +9463,8 @@ Examples:
|
|
|
8844
9463
|
if (outPath && meta.outputHint === "image") {
|
|
8845
9464
|
try {
|
|
8846
9465
|
if (images.length > 0) {
|
|
8847
|
-
|
|
8848
|
-
|
|
9466
|
+
fs9.mkdirSync(path12.dirname(path12.resolve(outPath)), { recursive: true });
|
|
9467
|
+
fs9.writeFileSync(outPath, images[0].data);
|
|
8849
9468
|
} else if (result && typeof result === "object") {
|
|
8850
9469
|
await fetchImageToFile(result, outPath);
|
|
8851
9470
|
}
|
|
@@ -8869,7 +9488,7 @@ Examples:
|
|
|
8869
9488
|
|
|
8870
9489
|
// ../argent-cli/src/flow.ts
|
|
8871
9490
|
import * as fsp from "node:fs/promises";
|
|
8872
|
-
import * as
|
|
9491
|
+
import * as path13 from "node:path";
|
|
8873
9492
|
var STATUS_GLYPH = {
|
|
8874
9493
|
pass: "\u2713",
|
|
8875
9494
|
fail: "\u2717",
|
|
@@ -8933,6 +9552,12 @@ function parseRunArgs(argv) {
|
|
|
8933
9552
|
};
|
|
8934
9553
|
const noValue = (name) => {
|
|
8935
9554
|
if (inline !== void 0) throw new FlagParseException(`${name} does not take a value`);
|
|
9555
|
+
const next = argv[i2 + 1]?.trim().toLowerCase();
|
|
9556
|
+
if (next === "true" || next === "false") {
|
|
9557
|
+
throw new FlagParseException(
|
|
9558
|
+
`${name} does not take a value \u2014 it is a switch; omit it to leave the option off`
|
|
9559
|
+
);
|
|
9560
|
+
}
|
|
8936
9561
|
};
|
|
8937
9562
|
if (flag === "--update-baselines") {
|
|
8938
9563
|
noValue("--update-baselines");
|
|
@@ -8970,8 +9595,10 @@ function renderUnderStepLine(s, n2, text2) {
|
|
|
8970
9595
|
function renderSummary(report, opts = {}) {
|
|
8971
9596
|
const warnings = report.steps.filter((s) => s.warning).length;
|
|
8972
9597
|
const warningsNote = warnings ? `, ${warnings} warning${warnings === 1 ? "" : "s"}` : "";
|
|
8973
|
-
const where = opts.withDevice ? ` on ${report.device}` : "";
|
|
8974
|
-
|
|
9598
|
+
const where = opts.withDevice && report.device ? ` on ${report.device}` : "";
|
|
9599
|
+
const nothingCounted = report.ok && report.passed + report.failed + report.errored + report.skipped === 0;
|
|
9600
|
+
const note = nothingCounted ? " (no test steps)" : "";
|
|
9601
|
+
return `${report.ok ? "PASS" : "FAIL"}${where} \u2014 ${report.passed} passed, ${report.failed} failed, ${report.errored} errored, ${report.skipped} skipped${warningsNote}${note}`;
|
|
8975
9602
|
}
|
|
8976
9603
|
function renderArtifactLines(report) {
|
|
8977
9604
|
const lines = [];
|
|
@@ -9001,12 +9628,12 @@ async function exportFailureArtifacts(report, outputDir, ctx) {
|
|
|
9001
9628
|
if (!key || !SAFE_ARTIFACT_NAME.test(key)) continue;
|
|
9002
9629
|
const { result } = await materializeArtifacts(s.artifacts, ctx);
|
|
9003
9630
|
s.artifacts = result;
|
|
9004
|
-
const dir =
|
|
9631
|
+
const dir = path13.join(outputDir, report.flow);
|
|
9005
9632
|
for (const [role, value] of Object.entries(s.artifacts)) {
|
|
9006
9633
|
if (typeof value !== "string") continue;
|
|
9007
|
-
const dest =
|
|
9008
|
-
const rel =
|
|
9009
|
-
if (rel.startsWith("..") ||
|
|
9634
|
+
const dest = path13.join(dir, `${key}-${role}.png`);
|
|
9635
|
+
const rel = path13.relative(outputDir, dest);
|
|
9636
|
+
if (rel.startsWith("..") || path13.isAbsolute(rel)) continue;
|
|
9010
9637
|
try {
|
|
9011
9638
|
await fsp.mkdir(dir, { recursive: true });
|
|
9012
9639
|
await fsp.copyFile(value, dest);
|
|
@@ -9022,7 +9649,7 @@ async function exportFailureArtifacts(report, outputDir, ctx) {
|
|
|
9022
9649
|
function keyFromBaselinePath(artifacts) {
|
|
9023
9650
|
const baseline = artifacts.baseline;
|
|
9024
9651
|
if (typeof baseline !== "string") return null;
|
|
9025
|
-
return
|
|
9652
|
+
return path13.basename(baseline).replace(/\.png$/, "");
|
|
9026
9653
|
}
|
|
9027
9654
|
function resolveArtifactDisplayPaths(report) {
|
|
9028
9655
|
for (const s of report.steps) {
|
|
@@ -9034,12 +9661,12 @@ function resolveArtifactDisplayPaths(report) {
|
|
|
9034
9661
|
}
|
|
9035
9662
|
function exitAfterFlush(code, streams = [process.stdout, process.stderr]) {
|
|
9036
9663
|
return Promise.all(
|
|
9037
|
-
streams.map((s) => new Promise((
|
|
9664
|
+
streams.map((s) => new Promise((resolve10) => s.write("", () => resolve10())))
|
|
9038
9665
|
).then(() => process.exit(code));
|
|
9039
9666
|
}
|
|
9040
9667
|
function renderReport(report) {
|
|
9041
9668
|
const lines = [];
|
|
9042
|
-
lines.push(`Flow "${report.flow}" on ${report.device}`);
|
|
9669
|
+
lines.push(`Flow "${report.flow}"${report.device ? ` on ${report.device}` : ""}`);
|
|
9043
9670
|
if (report.executionPrerequisite) {
|
|
9044
9671
|
lines.push(` assumes: ${report.executionPrerequisite}`);
|
|
9045
9672
|
}
|
|
@@ -9071,7 +9698,7 @@ async function flow(argv, options) {
|
|
|
9071
9698
|
}
|
|
9072
9699
|
const { callTool, baseUrl } = createToolsClient({ paths: options.paths });
|
|
9073
9700
|
if (sub === "list") {
|
|
9074
|
-
const dir =
|
|
9701
|
+
const dir = path13.join(process.cwd(), ".argent", "flows");
|
|
9075
9702
|
try {
|
|
9076
9703
|
const entries = await fsp.readdir(dir);
|
|
9077
9704
|
const names = entries.filter((f) => f.endsWith(".yaml")).map((f) => f.replace(/\.yaml$/, ""));
|
|
@@ -9150,7 +9777,7 @@ async function flow(argv, options) {
|
|
|
9150
9777
|
}
|
|
9151
9778
|
if (args.output) {
|
|
9152
9779
|
const { url, token } = await baseUrl();
|
|
9153
|
-
await exportFailureArtifacts(report,
|
|
9780
|
+
await exportFailureArtifacts(report, path13.resolve(args.output), {
|
|
9154
9781
|
toolsUrl: url,
|
|
9155
9782
|
authToken: token
|
|
9156
9783
|
});
|
|
@@ -9215,10 +9842,27 @@ ${sorted.length} tools. Run \`argent tools describe <name>\` for details.`);
|
|
|
9215
9842
|
console.log(formatSchemaUsage(meta.inputSchema));
|
|
9216
9843
|
if (meta.outputHint) console.log(`
|
|
9217
9844
|
Output hint: ${meta.outputHint}`);
|
|
9845
|
+
}
|
|
9846
|
+
function printUsage4() {
|
|
9847
|
+
console.log(`Usage:
|
|
9848
|
+
argent tools List available tools
|
|
9849
|
+
argent tools describe <name> Show one tool's flags and description
|
|
9850
|
+
|
|
9851
|
+
Options:
|
|
9852
|
+
--json Print machine-readable JSON
|
|
9853
|
+
--help, -h Show this help
|
|
9854
|
+
|
|
9855
|
+
Listing tools contacts the argent tool-server, starting one if none is running.
|
|
9856
|
+
`);
|
|
9218
9857
|
}
|
|
9219
9858
|
const json = argv.includes("--json");
|
|
9220
|
-
const
|
|
9859
|
+
const isHelpFlag = (a2) => a2 === "--help" || a2 === "-h";
|
|
9860
|
+
const positional = argv.filter((a2) => !a2.startsWith("--") || isHelpFlag(a2));
|
|
9221
9861
|
const sub = positional[0];
|
|
9862
|
+
if (sub !== void 0 && isHelpFlag(sub)) {
|
|
9863
|
+
printUsage4();
|
|
9864
|
+
return;
|
|
9865
|
+
}
|
|
9222
9866
|
if (!sub) {
|
|
9223
9867
|
await listTools(json);
|
|
9224
9868
|
return;
|
|
@@ -9232,27 +9876,17 @@ Output hint: ${meta.outputHint}`);
|
|
|
9232
9876
|
await describeTool(name, json);
|
|
9233
9877
|
return;
|
|
9234
9878
|
}
|
|
9235
|
-
if (sub === "--help" || sub === "-h") {
|
|
9236
|
-
console.log(`Usage:
|
|
9237
|
-
argent tools List available tools
|
|
9238
|
-
argent tools describe <name> Show one tool's flags and description
|
|
9239
|
-
|
|
9240
|
-
Options:
|
|
9241
|
-
--json Print machine-readable JSON
|
|
9242
|
-
`);
|
|
9243
|
-
return;
|
|
9244
|
-
}
|
|
9245
9879
|
console.error(`Unknown subcommand: tools ${sub}`);
|
|
9246
9880
|
process.exit(1);
|
|
9247
9881
|
}
|
|
9248
9882
|
|
|
9249
9883
|
// ../argent-cli/src/server.ts
|
|
9250
|
-
import * as
|
|
9251
|
-
import * as
|
|
9884
|
+
import * as fs10 from "node:fs";
|
|
9885
|
+
import * as path14 from "node:path";
|
|
9252
9886
|
import { homedir as homedir5, networkInterfaces } from "node:os";
|
|
9253
9887
|
import { spawn as spawn3 } from "node:child_process";
|
|
9254
|
-
var STATE_DIR2 =
|
|
9255
|
-
var LOG_FILE2 =
|
|
9888
|
+
var STATE_DIR2 = path14.join(homedir5(), ".argent");
|
|
9889
|
+
var LOG_FILE2 = path14.join(STATE_DIR2, "tool-server.log");
|
|
9256
9890
|
async function describeForeignServers(ownBundlePath) {
|
|
9257
9891
|
const others = (await readAllToolsServerStates()).filter(
|
|
9258
9892
|
({ state: state2 }) => state2.bundlePath !== ownBundlePath && isToolsServerProcessAlive(state2.pid)
|
|
@@ -9311,12 +9945,12 @@ Stop one with: kill <pid>`);
|
|
|
9311
9945
|
console.log(`tool-server stopped (pid ${state2.pid}).`);
|
|
9312
9946
|
}
|
|
9313
9947
|
function logsCmd(follow) {
|
|
9314
|
-
if (!
|
|
9948
|
+
if (!fs10.existsSync(LOG_FILE2)) {
|
|
9315
9949
|
console.log(`No log file at ${LOG_FILE2}`);
|
|
9316
9950
|
return;
|
|
9317
9951
|
}
|
|
9318
9952
|
if (!follow) {
|
|
9319
|
-
process.stdout.write(
|
|
9953
|
+
process.stdout.write(fs10.readFileSync(LOG_FILE2, "utf8"));
|
|
9320
9954
|
return;
|
|
9321
9955
|
}
|
|
9322
9956
|
const child = spawn3("tail", ["-f", LOG_FILE2], { stdio: "inherit" });
|
|
@@ -9659,9 +10293,9 @@ async function server(argv, options) {
|
|
|
9659
10293
|
}
|
|
9660
10294
|
|
|
9661
10295
|
// ../argent-cli/src/lens.ts
|
|
9662
|
-
import * as
|
|
10296
|
+
import * as fs11 from "node:fs";
|
|
9663
10297
|
import * as os2 from "node:os";
|
|
9664
|
-
import * as
|
|
10298
|
+
import * as path15 from "node:path";
|
|
9665
10299
|
|
|
9666
10300
|
// ../argent-cli/src/lens-terminal.ts
|
|
9667
10301
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
@@ -9879,15 +10513,15 @@ function isSessionAlive(session) {
|
|
|
9879
10513
|
// ../argent-cli/src/lens-pty.ts
|
|
9880
10514
|
import { chmodSync as chmodSync2, readdirSync as readdirSync2 } from "node:fs";
|
|
9881
10515
|
import { createRequire } from "node:module";
|
|
9882
|
-
import { dirname as dirname8, join as
|
|
10516
|
+
import { dirname as dirname8, join as join15 } from "node:path";
|
|
9883
10517
|
var nodeRequire = createRequire(import.meta.url);
|
|
9884
10518
|
function ensureSpawnHelperExecutable(req = nodeRequire) {
|
|
9885
10519
|
if (process.platform !== "darwin") return;
|
|
9886
10520
|
try {
|
|
9887
|
-
const prebuilds =
|
|
10521
|
+
const prebuilds = join15(dirname8(req.resolve("node-pty/package.json")), "prebuilds");
|
|
9888
10522
|
for (const entry of readdirSync2(prebuilds)) {
|
|
9889
10523
|
try {
|
|
9890
|
-
chmodSync2(
|
|
10524
|
+
chmodSync2(join15(prebuilds, entry, "spawn-helper"), 493);
|
|
9891
10525
|
} catch {
|
|
9892
10526
|
}
|
|
9893
10527
|
}
|
|
@@ -9919,7 +10553,7 @@ function ptyInjectBeats(text2) {
|
|
|
9919
10553
|
];
|
|
9920
10554
|
}
|
|
9921
10555
|
function sleep(ms) {
|
|
9922
|
-
return new Promise((
|
|
10556
|
+
return new Promise((resolve10) => setTimeout(resolve10, ms));
|
|
9923
10557
|
}
|
|
9924
10558
|
var DEFAULT_COLS = 80;
|
|
9925
10559
|
var DEFAULT_ROWS = 24;
|
|
@@ -10140,7 +10774,7 @@ var SPAWN_GRACE_MS = 8e3;
|
|
|
10140
10774
|
var DEATH_CONFIRMATIONS = 3;
|
|
10141
10775
|
var SSE_RECONNECT_MS = 1e3;
|
|
10142
10776
|
function sleep2(ms) {
|
|
10143
|
-
return new Promise((
|
|
10777
|
+
return new Promise((resolve10) => setTimeout(resolve10, ms));
|
|
10144
10778
|
}
|
|
10145
10779
|
var TRUST_PROMPT_RE = /trust this folder|do you trust|yes,? i trust|trust the files in this/i;
|
|
10146
10780
|
async function dismissTrustPrompt(session) {
|
|
@@ -10296,8 +10930,15 @@ function parseArgs(argv) {
|
|
|
10296
10930
|
for (let i2 = 0; i2 < argv.length; i2++) {
|
|
10297
10931
|
const tok = argv[i2];
|
|
10298
10932
|
if (tok === "--help" || tok === "-h") help = true;
|
|
10299
|
-
else if (tok === "--forget")
|
|
10300
|
-
|
|
10933
|
+
else if (tok === "--forget") {
|
|
10934
|
+
forget = true;
|
|
10935
|
+
const next = argv[i2 + 1]?.trim().toLowerCase();
|
|
10936
|
+
if (next === "true" || next === "false") {
|
|
10937
|
+
process.stderr.write(`lens: --forget does not take a value; omit it to keep the state
|
|
10938
|
+
`);
|
|
10939
|
+
process.exit(2);
|
|
10940
|
+
}
|
|
10941
|
+
} else if (tok === "--terminal" || tok === "-t") {
|
|
10301
10942
|
const v = argv[++i2];
|
|
10302
10943
|
if (v === "iterm" || v === "terminal") terminal = v;
|
|
10303
10944
|
else {
|
|
@@ -10413,12 +11054,12 @@ async function lens(argv, options) {
|
|
|
10413
11054
|
await endSession(baseUrl);
|
|
10414
11055
|
process.exit(1);
|
|
10415
11056
|
}
|
|
10416
|
-
const seedFile =
|
|
10417
|
-
|
|
11057
|
+
const seedFile = path15.join(os2.tmpdir(), `argent-lens-seed-${process.pid}-${Date.now()}.txt`);
|
|
11058
|
+
fs11.writeFileSync(seedFile, buildSeedPrompt(), "utf8");
|
|
10418
11059
|
const launchCmd = agent.launch(shellQuote(process.cwd()), shellQuote(seedFile));
|
|
10419
11060
|
const removeSeedFile = () => {
|
|
10420
11061
|
try {
|
|
10421
|
-
|
|
11062
|
+
fs11.rmSync(seedFile, { force: true });
|
|
10422
11063
|
} catch {
|
|
10423
11064
|
}
|
|
10424
11065
|
};
|
|
@@ -10808,7 +11449,7 @@ Options:
|
|
|
10808
11449
|
|
|
10809
11450
|
// ../argent-cli/src/config.ts
|
|
10810
11451
|
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
10811
|
-
import * as
|
|
11452
|
+
import * as path16 from "node:path";
|
|
10812
11453
|
function config(argv) {
|
|
10813
11454
|
if (argv.length === 0 || argv[0] === "--help" || argv[0] === "-h") {
|
|
10814
11455
|
printUsage();
|
|
@@ -10858,6 +11499,7 @@ the raw value stored at each scope.`);
|
|
|
10858
11499
|
}
|
|
10859
11500
|
function scopeDetail(e) {
|
|
10860
11501
|
const parts = [`scopes: ${e.scopes.join(", ")}`];
|
|
11502
|
+
if (e.expected) parts.push(`value: ${e.expected}${e.example ? `, e.g. ${e.example}` : ""}`);
|
|
10861
11503
|
if (e.project !== void 0) parts.push(`project=${formatValuePlain(e.project)}`);
|
|
10862
11504
|
if (e.global !== void 0) parts.push(`global=${formatValuePlain(e.global)}`);
|
|
10863
11505
|
return parts.join(" \xB7 ");
|
|
@@ -10922,7 +11564,7 @@ parsed (e.g. \`true\`, \`42\`, \`["a","b"]\`); anything else is stored as a stri
|
|
|
10922
11564
|
if (warning) console.error(import_picocolors2.default.yellow(warning));
|
|
10923
11565
|
console.log(`Set ${import_picocolors2.default.bold(key)} = ${formatValuePlain(stored)} (${scopeLabel(targetScope)}).`);
|
|
10924
11566
|
} catch (err) {
|
|
10925
|
-
reportError(err);
|
|
11567
|
+
reportError(err, () => suggestCorrectedSet(err, key, rawValue, scope));
|
|
10926
11568
|
}
|
|
10927
11569
|
}
|
|
10928
11570
|
function cmdUnset(argv) {
|
|
@@ -10991,16 +11633,16 @@ function wantsHelp(argv) {
|
|
|
10991
11633
|
}
|
|
10992
11634
|
function scopeLabel(scope) {
|
|
10993
11635
|
if (scope === "global") return "global";
|
|
10994
|
-
return `project: ${
|
|
11636
|
+
return `project: ${path16.dirname(configDir("project"))}`;
|
|
10995
11637
|
}
|
|
10996
11638
|
function degenerateProjectScopeWarning(scope) {
|
|
10997
11639
|
if (scope !== "project") return null;
|
|
10998
11640
|
const projDir = configDir("project");
|
|
10999
|
-
if (
|
|
11000
|
-
return `WARNING: no project found between ${process.cwd()} and your home directory \u2014 "project" scope resolved to the home directory, so this writes the GLOBAL config file (${
|
|
11641
|
+
if (path16.resolve(projDir) === path16.resolve(configDir("global"))) {
|
|
11642
|
+
return `WARNING: no project found between ${process.cwd()} and your home directory \u2014 "project" scope resolved to the home directory, so this writes the GLOBAL config file (${path16.join(projDir, "config.json")}).`;
|
|
11001
11643
|
}
|
|
11002
11644
|
if (findProjectRoot(process.cwd()) === null) {
|
|
11003
|
-
return `WARNING: no project markers (.argent, .git, package.json) found above ${process.cwd()} \u2014 treating it as the project root and creating ${
|
|
11645
|
+
return `WARNING: no project markers (.argent, .git, package.json) found above ${process.cwd()} \u2014 treating it as the project root and creating ${path16.join(projDir, "config.json")}.`;
|
|
11004
11646
|
}
|
|
11005
11647
|
return null;
|
|
11006
11648
|
}
|
|
@@ -11015,7 +11657,20 @@ function formatValue(value) {
|
|
|
11015
11657
|
}
|
|
11016
11658
|
return formatValuePlain(value);
|
|
11017
11659
|
}
|
|
11018
|
-
function
|
|
11660
|
+
function quoteForShell(value) {
|
|
11661
|
+
if (/^[A-Za-z0-9._/@:+-]+$/.test(value)) return value;
|
|
11662
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
11663
|
+
}
|
|
11664
|
+
function suggestCorrectedSet(err, key, rawValue, scope) {
|
|
11665
|
+
if (!(err instanceof ConfigValidationError)) return null;
|
|
11666
|
+
const def = getConfigDefinition(key);
|
|
11667
|
+
if (!def) return null;
|
|
11668
|
+
const wrapped = def.parse([rawValue]);
|
|
11669
|
+
if (wrapped === void 0) return null;
|
|
11670
|
+
const scopeFlag = scope ? ` --scope ${scope}` : "";
|
|
11671
|
+
return `argent config set ${key} ${quoteForShell(JSON.stringify([rawValue]))}${scopeFlag}`;
|
|
11672
|
+
}
|
|
11673
|
+
function reportError(err, suggest) {
|
|
11019
11674
|
if (err instanceof ConfigManagedElsewhereError) {
|
|
11020
11675
|
console.error(`Error: ${err.message} Use \`${err.command}\` instead.`);
|
|
11021
11676
|
} else if (err instanceof UnknownConfigKeyError || err instanceof ConfigScopeError || err instanceof ConfigValidationError) {
|
|
@@ -11023,6 +11678,15 @@ function reportError(err) {
|
|
|
11023
11678
|
if (err instanceof UnknownConfigKeyError) {
|
|
11024
11679
|
console.error(`Run \`argent config list\` to see available keys.`);
|
|
11025
11680
|
}
|
|
11681
|
+
if (err instanceof ConfigValidationError) {
|
|
11682
|
+
const corrected = suggest?.() ?? null;
|
|
11683
|
+
if (corrected) {
|
|
11684
|
+
console.error(`Did you mean: ${corrected}`);
|
|
11685
|
+
} else if (err.example) {
|
|
11686
|
+
console.error(`Example: argent config set ${err.key} ${quoteForShell(err.example)}`);
|
|
11687
|
+
}
|
|
11688
|
+
console.error(`Run \`argent config list\` to see each key's expected value.`);
|
|
11689
|
+
}
|
|
11026
11690
|
} else {
|
|
11027
11691
|
console.error(`Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
11028
11692
|
}
|
|
@@ -11054,6 +11718,99 @@ ${keyLines.join("\n")}
|
|
|
11054
11718
|
Run \`argent config <command> --help\` for command-specific help.`);
|
|
11055
11719
|
}
|
|
11056
11720
|
|
|
11721
|
+
// ../argent-cli/src/secrets.ts
|
|
11722
|
+
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
11723
|
+
async function secrets(argv) {
|
|
11724
|
+
const [sub, ...rest] = argv;
|
|
11725
|
+
if (sub === void 0 || sub === "list") return cmdList2(rest);
|
|
11726
|
+
if (sub === "--help" || sub === "-h") return printUsage2();
|
|
11727
|
+
if (sub === "--json") return cmdList2([sub, ...rest]);
|
|
11728
|
+
console.error(`Error: unknown subcommand "secrets ${sub}". Try \`argent secrets --help\`.`);
|
|
11729
|
+
process.exit(2);
|
|
11730
|
+
}
|
|
11731
|
+
function printUsage2() {
|
|
11732
|
+
console.log(`Usage: argent secrets [list] [--json]
|
|
11733
|
+
|
|
11734
|
+
List the secrets a \`{{secret:<NAME>}}\` placeholder can resolve, and the sources
|
|
11735
|
+
they come from. Names only \u2014 a value is never printed.
|
|
11736
|
+
|
|
11737
|
+
A name is resolved by the machine running the tool-server, taking the first
|
|
11738
|
+
source that defines it:
|
|
11739
|
+
|
|
11740
|
+
1. ${SECRET_ENV_PREFIX}<NAME> in the environment prefixed variables only
|
|
11741
|
+
2. <project>/.argent/secrets.env every key (gitignore this file)
|
|
11742
|
+
3. <project>/.env.local, then <project>/.env only ${SECRET_ENV_PREFIX}-prefixed keys
|
|
11743
|
+
4. ~/.argent/secrets.env every key, any project
|
|
11744
|
+
|
|
11745
|
+
A secrets file applies to the next tool call \u2014 no restart. An environment
|
|
11746
|
+
variable only reaches a tool-server started after it was exported.
|
|
11747
|
+
|
|
11748
|
+
Examples:
|
|
11749
|
+
echo 'APP_PASSWORD=\u2026' >> ~/.argent/secrets.env # available in every project
|
|
11750
|
+
argent secrets # check it is picked up`);
|
|
11751
|
+
}
|
|
11752
|
+
async function cmdList2(argv) {
|
|
11753
|
+
if (argv.includes("--help") || argv.includes("-h")) return printUsage2();
|
|
11754
|
+
const json = argv.includes("--json");
|
|
11755
|
+
const sources = secretSources();
|
|
11756
|
+
const all = secretNames(sources);
|
|
11757
|
+
if (json) {
|
|
11758
|
+
console.log(
|
|
11759
|
+
JSON.stringify(
|
|
11760
|
+
{
|
|
11761
|
+
secrets: all,
|
|
11762
|
+
sources: sources.map((s) => ({
|
|
11763
|
+
source: s.label,
|
|
11764
|
+
present: s.present,
|
|
11765
|
+
names: s.names,
|
|
11766
|
+
...s.needsPrefix ? { needsPrefix: true } : {}
|
|
11767
|
+
}))
|
|
11768
|
+
},
|
|
11769
|
+
null,
|
|
11770
|
+
2
|
|
11771
|
+
)
|
|
11772
|
+
);
|
|
11773
|
+
return;
|
|
11774
|
+
}
|
|
11775
|
+
console.log(`Secrets available to \`{{secret:<NAME>}}\` on this machine:
|
|
11776
|
+
`);
|
|
11777
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
11778
|
+
for (const source of sources) {
|
|
11779
|
+
console.log(` ${source.label}`);
|
|
11780
|
+
if (!source.present) {
|
|
11781
|
+
console.log(` ${import_picocolors3.default.dim("not found")}`);
|
|
11782
|
+
} else if (source.needsPrefix) {
|
|
11783
|
+
console.log(
|
|
11784
|
+
` ${import_picocolors3.default.dim(`no ${SECRET_ENV_PREFIX}* keys \u2014 only prefixed keys are exposed from a file the app shares`)}`
|
|
11785
|
+
);
|
|
11786
|
+
} else if (source.names.length === 0) {
|
|
11787
|
+
console.log(` ${import_picocolors3.default.dim("no secrets")}`);
|
|
11788
|
+
} else {
|
|
11789
|
+
const rendered = source.names.map(
|
|
11790
|
+
(name) => claimed.has(name) ? import_picocolors3.default.dim(`${name} (shadowed above)`) : name
|
|
11791
|
+
);
|
|
11792
|
+
for (const name of source.names) claimed.add(name);
|
|
11793
|
+
console.log(` ${rendered.join(", ")}`);
|
|
11794
|
+
}
|
|
11795
|
+
}
|
|
11796
|
+
console.log(
|
|
11797
|
+
`
|
|
11798
|
+
${all.length === 0 ? "No secrets are defined." : `${all.length} name${all.length === 1 ? "" : "s"} in effect: ${all.join(", ")}`}`
|
|
11799
|
+
);
|
|
11800
|
+
console.log(
|
|
11801
|
+
import_picocolors3.default.dim("Values are never printed. Run `argent secrets --help` to see where to add one.")
|
|
11802
|
+
);
|
|
11803
|
+
const routed = await getResolvedToolsUrl().catch(() => ({ url: null }));
|
|
11804
|
+
if (routed.url) {
|
|
11805
|
+
console.log(
|
|
11806
|
+
import_picocolors3.default.yellow(
|
|
11807
|
+
`
|
|
11808
|
+
Note: a remote tool-server is linked (${routed.url}). Placeholders resolve there, against that machine's environment and secrets files \u2014 not the ones listed above.`
|
|
11809
|
+
)
|
|
11810
|
+
);
|
|
11811
|
+
}
|
|
11812
|
+
}
|
|
11813
|
+
|
|
11057
11814
|
// ../../node_modules/@clack/core/dist/index.mjs
|
|
11058
11815
|
import { styleText } from "node:util";
|
|
11059
11816
|
import { stdout, stdin } from "node:process";
|
|
@@ -11774,7 +12531,7 @@ import { styleText as styleText2, stripVTControlCharacters } from "node:util";
|
|
|
11774
12531
|
import process$1 from "node:process";
|
|
11775
12532
|
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
11776
12533
|
import { existsSync as existsSync7, lstatSync as lstatSync3, readdirSync as readdirSync3 } from "node:fs";
|
|
11777
|
-
import { dirname as dirname10, join as
|
|
12534
|
+
import { dirname as dirname10, join as join18 } from "node:path";
|
|
11778
12535
|
function isUnicodeSupported() {
|
|
11779
12536
|
if (process$1.platform !== "win32") {
|
|
11780
12537
|
return process$1.env.TERM !== "linux";
|
|
@@ -12211,7 +12968,7 @@ ${r2}
|
|
|
12211
12968
|
}).prompt();
|
|
12212
12969
|
|
|
12213
12970
|
// ../argent-cli/src/link.ts
|
|
12214
|
-
var
|
|
12971
|
+
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
12215
12972
|
var WILDCARD_HOSTS = /* @__PURE__ */ new Set(["0.0.0.0", "::", "::0", ""]);
|
|
12216
12973
|
function isLoopback2(host) {
|
|
12217
12974
|
return host === "127.0.0.1" || host === "localhost" || host === "::1";
|
|
@@ -12469,7 +13226,7 @@ async function preflightHealth(url, token) {
|
|
|
12469
13226
|
}
|
|
12470
13227
|
function printRestartHint() {
|
|
12471
13228
|
console.log(
|
|
12472
|
-
|
|
13229
|
+
import_picocolors4.default.dim("Restart your editor to apply the change to any running `argent mcp` session.")
|
|
12473
13230
|
);
|
|
12474
13231
|
}
|
|
12475
13232
|
function printSecurityCaveat(host, token, url) {
|
|
@@ -12478,7 +13235,7 @@ function printSecurityCaveat(host, token, url) {
|
|
|
12478
13235
|
if (tls) {
|
|
12479
13236
|
if (!token) {
|
|
12480
13237
|
process.stderr.write(
|
|
12481
|
-
|
|
13238
|
+
import_picocolors4.default.yellow(
|
|
12482
13239
|
`WARNING: ${host} is reached over HTTPS but with NO token \u2014 anyone who can reach the URL can drive the server. Pair with a token.
|
|
12483
13240
|
`
|
|
12484
13241
|
)
|
|
@@ -12488,7 +13245,7 @@ function printSecurityCaveat(host, token, url) {
|
|
|
12488
13245
|
}
|
|
12489
13246
|
if (token) {
|
|
12490
13247
|
process.stderr.write(
|
|
12491
|
-
|
|
13248
|
+
import_picocolors4.default.dim(
|
|
12492
13249
|
`Note: ${host} is reached over plain HTTP (bearer-token auth, no TLS). Keep this link to a trusted network or VPN, or front it with an https:// tunnel.
|
|
12493
13250
|
`
|
|
12494
13251
|
)
|
|
@@ -12496,7 +13253,7 @@ function printSecurityCaveat(host, token, url) {
|
|
|
12496
13253
|
return;
|
|
12497
13254
|
}
|
|
12498
13255
|
process.stderr.write(
|
|
12499
|
-
|
|
13256
|
+
import_picocolors4.default.yellow(
|
|
12500
13257
|
`WARNING: linked target ${host} is non-loopback and has NO token \u2014 tool calls travel over plain HTTP with no auth. Treat this link as trusted-network-only, or pair with a token (start the server without --no-auth).
|
|
12501
13258
|
`
|
|
12502
13259
|
)
|
|
@@ -12529,9 +13286,9 @@ async function link(argv) {
|
|
|
12529
13286
|
if (flags2.host !== null) {
|
|
12530
13287
|
host = flags2.host;
|
|
12531
13288
|
} else {
|
|
12532
|
-
intro(
|
|
13289
|
+
intro(import_picocolors4.default.bgCyan(import_picocolors4.default.black(" argent link ")));
|
|
12533
13290
|
if (existing) {
|
|
12534
|
-
log.info(`Current link: ${
|
|
13291
|
+
log.info(`Current link: ${import_picocolors4.default.cyan(existing.url)} (${existing.createdAt})`);
|
|
12535
13292
|
}
|
|
12536
13293
|
host = await promptHost(existing);
|
|
12537
13294
|
}
|
|
@@ -12547,12 +13304,12 @@ async function link(argv) {
|
|
|
12547
13304
|
let url = flags2.url ?? formatUrl(host, port);
|
|
12548
13305
|
if (!flags2.yes && existing) {
|
|
12549
13306
|
if (existing.url === url) {
|
|
12550
|
-
log.info(`Already linked to ${
|
|
13307
|
+
log.info(`Already linked to ${import_picocolors4.default.cyan(url)}.`);
|
|
12551
13308
|
outro("No changes.");
|
|
12552
13309
|
return;
|
|
12553
13310
|
}
|
|
12554
13311
|
const overwrite = await confirm({
|
|
12555
|
-
message: `Replace existing link ${
|
|
13312
|
+
message: `Replace existing link ${import_picocolors4.default.dim(existing.url)} with ${import_picocolors4.default.cyan(url)}?`,
|
|
12556
13313
|
initialValue: true
|
|
12557
13314
|
});
|
|
12558
13315
|
if (isCancel(overwrite) || !overwrite) {
|
|
@@ -12570,10 +13327,10 @@ async function link(argv) {
|
|
|
12570
13327
|
}
|
|
12571
13328
|
const result = await preflightHealth(url, token);
|
|
12572
13329
|
if (result.ok) {
|
|
12573
|
-
if (spinner2) spinner2.stop(
|
|
13330
|
+
if (spinner2) spinner2.stop(import_picocolors4.default.green("Tool-server reachable."));
|
|
12574
13331
|
break;
|
|
12575
13332
|
}
|
|
12576
|
-
if (spinner2) spinner2.stop(
|
|
13333
|
+
if (spinner2) spinner2.stop(import_picocolors4.default.red("Verification failed."));
|
|
12577
13334
|
const detail = result.error ? ` (${result.error})` : "";
|
|
12578
13335
|
if (flags2.yes) {
|
|
12579
13336
|
console.error(
|
|
@@ -12613,15 +13370,15 @@ async function link(argv) {
|
|
|
12613
13370
|
};
|
|
12614
13371
|
await writeLinkConfig(cfg);
|
|
12615
13372
|
if (existing && existing.url !== url) {
|
|
12616
|
-
console.log(`${
|
|
13373
|
+
console.log(`${import_picocolors4.default.green("\u2713")} Link updated: ${import_picocolors4.default.dim(existing.url)} \u2192 ${import_picocolors4.default.cyan(url)}`);
|
|
12617
13374
|
} else {
|
|
12618
|
-
console.log(`${
|
|
13375
|
+
console.log(`${import_picocolors4.default.green("\u2713")} Linked: ${import_picocolors4.default.cyan(url)}`);
|
|
12619
13376
|
}
|
|
12620
|
-
if (token) console.log(
|
|
13377
|
+
if (token) console.log(import_picocolors4.default.dim(" auth: token stored in ~/.argent/link.json (0600)"));
|
|
12621
13378
|
printSecurityCaveat(host, token, url);
|
|
12622
13379
|
if (process.env.ARGENT_TOOLS_URL) {
|
|
12623
13380
|
console.log(
|
|
12624
|
-
|
|
13381
|
+
import_picocolors4.default.yellow(
|
|
12625
13382
|
`Note: ARGENT_TOOLS_URL=${process.env.ARGENT_TOOLS_URL} is set in your environment and takes precedence over the link.`
|
|
12626
13383
|
)
|
|
12627
13384
|
);
|
|
@@ -12652,7 +13409,7 @@ async function unlink3(argv) {
|
|
|
12652
13409
|
}
|
|
12653
13410
|
if (!flags2.yes) {
|
|
12654
13411
|
const confirmed = await confirm({
|
|
12655
|
-
message: `Remove link to ${
|
|
13412
|
+
message: `Remove link to ${import_picocolors4.default.cyan(existing.url)}?`,
|
|
12656
13413
|
initialValue: true
|
|
12657
13414
|
});
|
|
12658
13415
|
if (isCancel(confirmed) || !confirmed) {
|
|
@@ -12661,10 +13418,10 @@ async function unlink3(argv) {
|
|
|
12661
13418
|
}
|
|
12662
13419
|
}
|
|
12663
13420
|
await clearLinkConfig();
|
|
12664
|
-
console.log(`${
|
|
13421
|
+
console.log(`${import_picocolors4.default.green("\u2713")} Unlinked from ${import_picocolors4.default.dim(existing.url)}.`);
|
|
12665
13422
|
if (process.env.ARGENT_TOOLS_URL) {
|
|
12666
13423
|
console.log(
|
|
12667
|
-
|
|
13424
|
+
import_picocolors4.default.yellow(
|
|
12668
13425
|
`The env var ARGENT_TOOLS_URL is also set in your shell (=${process.env.ARGENT_TOOLS_URL}) and takes precedence \u2014 unset it manually if you want fully local behaviour.`
|
|
12669
13426
|
)
|
|
12670
13427
|
);
|
|
@@ -12673,13 +13430,13 @@ async function unlink3(argv) {
|
|
|
12673
13430
|
}
|
|
12674
13431
|
|
|
12675
13432
|
// ../argent-cli/src/telemetry.ts
|
|
12676
|
-
var
|
|
13433
|
+
var import_picocolors5 = __toESM(require_picocolors(), 1);
|
|
12677
13434
|
async function telemetry(args) {
|
|
12678
13435
|
const sub = args[0];
|
|
12679
13436
|
init("cli");
|
|
12680
13437
|
switch (sub) {
|
|
12681
13438
|
case void 0:
|
|
12682
|
-
|
|
13439
|
+
printUsage3();
|
|
12683
13440
|
await shutdown();
|
|
12684
13441
|
return;
|
|
12685
13442
|
case "status":
|
|
@@ -12694,7 +13451,7 @@ async function telemetry(args) {
|
|
|
12694
13451
|
return;
|
|
12695
13452
|
case "--help":
|
|
12696
13453
|
case "-h":
|
|
12697
|
-
|
|
13454
|
+
printUsage3();
|
|
12698
13455
|
await shutdown();
|
|
12699
13456
|
return;
|
|
12700
13457
|
default:
|
|
@@ -12703,7 +13460,7 @@ async function telemetry(args) {
|
|
|
12703
13460
|
process.exit(1);
|
|
12704
13461
|
}
|
|
12705
13462
|
}
|
|
12706
|
-
function
|
|
13463
|
+
function printUsage3() {
|
|
12707
13464
|
console.log(`Usage:
|
|
12708
13465
|
argent telemetry status Show telemetry state and device id
|
|
12709
13466
|
argent telemetry enable Enable telemetry
|
|
@@ -12721,21 +13478,21 @@ async function cmdEnable() {
|
|
|
12721
13478
|
const wasEnabled = isEnabled();
|
|
12722
13479
|
markEnabled();
|
|
12723
13480
|
if (wasEnabled) {
|
|
12724
|
-
console.log(
|
|
13481
|
+
console.log(import_picocolors5.default.dim("Telemetry was already enabled."));
|
|
12725
13482
|
} else {
|
|
12726
|
-
console.log(
|
|
13483
|
+
console.log(import_picocolors5.default.green("Telemetry enabled."));
|
|
12727
13484
|
}
|
|
12728
13485
|
await shutdown();
|
|
12729
13486
|
}
|
|
12730
13487
|
async function cmdDisable() {
|
|
12731
13488
|
const wasEnabled = isEnabled();
|
|
12732
13489
|
if (!wasEnabled) {
|
|
12733
|
-
console.log(
|
|
13490
|
+
console.log(import_picocolors5.default.dim("Telemetry was already disabled."));
|
|
12734
13491
|
await shutdown();
|
|
12735
13492
|
return;
|
|
12736
13493
|
}
|
|
12737
13494
|
await markDisabled();
|
|
12738
|
-
console.log(
|
|
13495
|
+
console.log(import_picocolors5.default.red("Telemetry disabled."));
|
|
12739
13496
|
await shutdown();
|
|
12740
13497
|
}
|
|
12741
13498
|
export {
|
|
@@ -12750,6 +13507,7 @@ export {
|
|
|
12750
13507
|
lens,
|
|
12751
13508
|
link,
|
|
12752
13509
|
run,
|
|
13510
|
+
secrets,
|
|
12753
13511
|
server,
|
|
12754
13512
|
telemetry,
|
|
12755
13513
|
tools,
|