@swmansion/argent 0.16.2-next.1 → 0.16.2-next.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli-cmds.mjs CHANGED
@@ -1100,787 +1100,1392 @@ function createToolsClient(options = {}) {
1100
1100
  }
1101
1101
 
1102
1102
  // ../argent-tools-client/src/artifacts.ts
1103
- import { mkdir as mkdir4, readFile as readFile4, rm as rm3, stat as stat2, writeFile as writeFile4 } from "node:fs/promises";
1103
+ import { copyFile, mkdir as mkdir4, readFile as readFile4, realpath, rm as rm3, stat as stat2, writeFile as writeFile4 } from "node:fs/promises";
1104
+ import { constants as fsConstants } from "node:fs";
1104
1105
  import { tmpdir as tmpdir2 } from "node:os";
1105
- import { basename as basename3, join as join5 } from "node:path";
1106
+ import { basename as basename3, dirname as dirname5, extname, isAbsolute as isAbsolute3, join as join8, normalize, sep as sep2 } from "node:path";
1106
1107
  import { createHash as createHash3 } from "node:crypto";
1107
- var ARTIFACT_MARKER = "__argentArtifact";
1108
- function isArtifactHandle(value) {
1109
- return !!value && typeof value === "object" && value[ARTIFACT_MARKER] === true && typeof value.id === "string" && typeof value.filename === "string";
1110
- }
1111
- var SESSION_ID = null;
1112
- function sessionId() {
1113
- if (!SESSION_ID) {
1114
- const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:T]/g, (m) => m === "T" ? "-" : "").slice(0, 15);
1115
- SESSION_ID = `${stamp}-${process.pid}`;
1108
+
1109
+ // ../configuration-core/src/flags.ts
1110
+ import * as fs2 from "node:fs";
1111
+ import * as path4 from "node:path";
1112
+ import { homedir as homedir3 } from "node:os";
1113
+ var FLAG_REGISTRY = [
1114
+ {
1115
+ name: "disable-auto-screenshot",
1116
+ description: "Disable the automatic screenshot captured after interaction tools."
1117
+ },
1118
+ {
1119
+ name: "argent-lens",
1120
+ description: "Argent Lens \u2014 the propose_variant / await_user_selection tools and the Electron preview window for staging UI design variants and letting a human pick among them. Off by default while the feature is in development."
1121
+ },
1122
+ {
1123
+ name: "artifacts-list-endpoint",
1124
+ description: "Expose GET /artifacts for remote artifact inventory consumers."
1125
+ },
1126
+ {
1127
+ name: "tool-server-event-log",
1128
+ description: "Write structured tool-server lifecycle events to a JSONL file."
1129
+ },
1130
+ {
1131
+ name: "video-watermark",
1132
+ description: "Overlay the argent corner watermark on recorded screen videos. On by default; turn it off with `argent disable video-watermark`.",
1133
+ defaultEnabled: true
1116
1134
  }
1117
- return SESSION_ID;
1118
- }
1119
- function sanitizeSegment(segment) {
1120
- return segment.replace(/[^A-Za-z0-9._-]/g, "_");
1135
+ ];
1136
+ function getFlagDefinition(name, registry = FLAG_REGISTRY) {
1137
+ return registry.find((def) => def.name === name);
1121
1138
  }
1122
- function projectSlug() {
1123
- const cwd = process.cwd();
1124
- const hash = createHash3("sha1").update(cwd).digest("hex").slice(0, 6);
1125
- const name = sanitizeSegment(basename3(cwd)) || "root";
1126
- return `${name}-${hash}`;
1139
+ var PROJECT_MARKERS = [".argent", ".git", "package.json"];
1140
+ function findProjectRoot(startDir) {
1141
+ let current = path4.resolve(startDir);
1142
+ while (true) {
1143
+ for (const marker of PROJECT_MARKERS) {
1144
+ if (fs2.existsSync(path4.join(current, marker))) return current;
1145
+ }
1146
+ const parent = path4.dirname(current);
1147
+ if (parent === current) return null;
1148
+ current = parent;
1149
+ }
1127
1150
  }
1128
- function artifactsRoot() {
1129
- return process.env.ARGENT_ARTIFACTS_DIR ?? join5(tmpdir2(), "argent-artifacts");
1151
+ function resolveProjectRoot(startDir) {
1152
+ return findProjectRoot(startDir) ?? path4.resolve(startDir);
1130
1153
  }
1131
- function artifactDir(deviceId) {
1132
- const parts = [artifactsRoot(), projectSlug(), sessionId()];
1133
- if (deviceId) parts.push(sanitizeSegment(deviceId));
1134
- return join5(...parts);
1154
+ function getFlagsPath(scope, options = {}) {
1155
+ const home = options.homeDir ?? homedir3();
1156
+ if (scope === "global") {
1157
+ return path4.join(home, ".argent", "flags.json");
1158
+ }
1159
+ const cwd = options.cwd ?? process.cwd();
1160
+ return path4.join(resolveProjectRoot(cwd), ".argent", "flags.json");
1135
1161
  }
1136
- async function resolveLocalFile(handle) {
1137
- if (!handle.hostPath) return null;
1162
+ function readFlagsFile(filePath) {
1163
+ let raw;
1138
1164
  try {
1139
- const st = await stat2(handle.hostPath);
1140
- if (handle.archive) {
1141
- return st.isDirectory() ? handle.hostPath : null;
1142
- }
1143
- if (!st.isFile()) return null;
1144
- if (st.size !== handle.size) return null;
1145
- if (handle.mtimeMs != null && Math.round(st.mtimeMs) !== Math.round(handle.mtimeMs)) {
1146
- return null;
1147
- }
1148
- return handle.hostPath;
1165
+ raw = fs2.readFileSync(filePath, "utf8");
1149
1166
  } catch {
1150
- return null;
1167
+ return {};
1151
1168
  }
1152
- }
1153
- async function downloadAndExtractArchive(handle, data, dir) {
1154
- const tarball2 = join5(dir, `${sanitizeSegment(handle.filename)}.tar.gz`);
1169
+ let parsed;
1155
1170
  try {
1156
- await writeFile4(tarball2, data);
1157
- return await safeExtractTarGz(tarball2, dir, handle.filename);
1171
+ parsed = JSON.parse(raw);
1158
1172
  } catch {
1159
- return null;
1160
- } finally {
1161
- await rm3(tarball2, { force: true }).catch(() => {
1162
- });
1173
+ return {};
1163
1174
  }
1164
- }
1165
- async function materializeArtifacts(result, ctx) {
1166
- const images = [];
1167
- const fetchFn = ctx.fetchImpl ?? fetch;
1168
- const authHeaders3 = ctx.authToken ? { Authorization: `Bearer ${ctx.authToken}` } : {};
1169
- const dir = artifactDir(ctx.deviceId);
1170
- let dirReady = false;
1171
- async function ensureDir() {
1172
- if (!dirReady) {
1173
- await mkdir4(dir, { recursive: true });
1174
- dirReady = true;
1175
- }
1175
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
1176
+ const flags2 = parsed.flags;
1177
+ if (!flags2 || typeof flags2 !== "object" || Array.isArray(flags2)) return {};
1178
+ const out = {};
1179
+ for (const [k, v] of Object.entries(flags2)) {
1180
+ if (typeof v === "boolean") out[k] = v;
1176
1181
  }
1177
- async function walk(value) {
1178
- if (isArtifactHandle(value)) {
1179
- const localPath = await resolveLocalFile(value);
1180
- if (localPath) {
1181
- if (value.mimeType.startsWith("image/")) {
1182
- images.push({ localPath, data: await readFile4(localPath), mimeType: value.mimeType });
1183
- }
1184
- return localPath;
1185
- }
1186
- try {
1187
- const res = await fetchFn(`${ctx.toolsUrl}/artifacts/${value.id}`, {
1188
- headers: authHeaders3
1189
- });
1190
- if (!res.ok) return null;
1191
- const data = Buffer.from(await res.arrayBuffer());
1192
- await ensureDir();
1193
- if (value.archive === "tar.gz") {
1194
- return await downloadAndExtractArchive(value, data, dir);
1195
- }
1196
- if (value.size > 0 && data.length !== value.size) return null;
1197
- const downloadedPath = join5(dir, sanitizeSegment(value.filename));
1198
- await writeFile4(downloadedPath, data);
1199
- if (value.mimeType.startsWith("image/")) {
1200
- images.push({ localPath: downloadedPath, data, mimeType: value.mimeType });
1201
- }
1202
- return downloadedPath;
1203
- } catch {
1204
- return null;
1205
- }
1206
- }
1207
- if (Array.isArray(value)) {
1208
- return Promise.all(value.map(walk));
1209
- }
1210
- if (value && typeof value === "object") {
1211
- const out = {};
1212
- for (const [k, v] of Object.entries(value)) {
1213
- out[k] = await walk(v);
1182
+ return out;
1183
+ }
1184
+ function writeFlagsFile(filePath, flags2) {
1185
+ if (Object.keys(flags2).length === 0) {
1186
+ if (fs2.existsSync(filePath)) fs2.rmSync(filePath, { force: true });
1187
+ const parent = path4.dirname(filePath);
1188
+ try {
1189
+ if (fs2.existsSync(parent) && fs2.readdirSync(parent).length === 0) {
1190
+ fs2.rmdirSync(parent);
1214
1191
  }
1215
- return out;
1192
+ } catch {
1216
1193
  }
1217
- return value;
1194
+ return;
1218
1195
  }
1219
- const rewritten = await walk(result);
1220
- return { result: rewritten, images };
1196
+ fs2.mkdirSync(path4.dirname(filePath), { recursive: true });
1197
+ const tmp = `${filePath}.${process.pid}.tmp`;
1198
+ fs2.writeFileSync(tmp, JSON.stringify({ flags: flags2 }, null, 2) + "\n");
1199
+ fs2.renameSync(tmp, filePath);
1221
1200
  }
1222
- function getDeviceIdFromArgs(args) {
1223
- if (!args || typeof args !== "object") return void 0;
1224
- const rec = args;
1225
- if (typeof rec.udid === "string") return rec.udid;
1226
- if (typeof rec.device_id === "string") return rec.device_id;
1227
- return void 0;
1201
+ function readFlags(scope, options = {}) {
1202
+ return readFlagsFile(getFlagsPath(scope, options));
1228
1203
  }
1229
-
1230
- // ../../node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
1231
- import { dirname as dirname4, posix as posix2, sep as sep2 } from "path";
1232
- function createModulerModifier() {
1233
- const getModuleFromFileName = createGetModuleFromFilename();
1234
- return async (frames) => {
1235
- for (const frame of frames) frame.module = getModuleFromFileName(frame.filename);
1236
- return frames;
1237
- };
1204
+ function setFlag(name, value, scope, options = {}) {
1205
+ const filePath = getFlagsPath(scope, options);
1206
+ const current = readFlagsFile(filePath);
1207
+ current[name] = value;
1208
+ writeFlagsFile(filePath, current);
1238
1209
  }
1239
- function createGetModuleFromFilename(basePath = process.argv[1] ? dirname4(process.argv[1]) : process.cwd(), isWindows = "\\" === sep2) {
1240
- const normalizedBase = isWindows ? normalizeWindowsPath(basePath) : basePath;
1241
- return (filename) => {
1242
- if (!filename) return;
1243
- const normalizedFilename = isWindows ? normalizeWindowsPath(filename) : filename;
1244
- let { dir, base: file, ext } = posix2.parse(normalizedFilename);
1245
- if (".js" === ext || ".mjs" === ext || ".cjs" === ext) file = file.slice(0, -1 * ext.length);
1246
- const decodedFile = decodeURIComponent(file);
1247
- if (!dir) dir = ".";
1248
- const n2 = dir.lastIndexOf("/node_modules");
1249
- if (n2 > -1) return `${dir.slice(n2 + 14).replace(/\//g, ".")}:${decodedFile}`;
1250
- if (dir.startsWith(normalizedBase)) {
1251
- const moduleName = dir.slice(normalizedBase.length + 1).replace(/\//g, ".");
1252
- return moduleName ? `${moduleName}:${decodedFile}` : decodedFile;
1253
- }
1254
- return decodedFile;
1255
- };
1210
+ function unsetFlag(name, scope, options = {}) {
1211
+ const filePath = getFlagsPath(scope, options);
1212
+ const current = readFlagsFile(filePath);
1213
+ if (!Object.hasOwn(current, name)) return false;
1214
+ delete current[name];
1215
+ writeFlagsFile(filePath, current);
1216
+ return true;
1256
1217
  }
1257
- function normalizeWindowsPath(path15) {
1258
- return path15.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
1218
+ function isFlagEnabled(name, options = {}) {
1219
+ const projectFlags = readFlags("project", options);
1220
+ if (Object.hasOwn(projectFlags, name)) return projectFlags[name];
1221
+ const globalFlags = readFlags("global", options);
1222
+ if (Object.hasOwn(globalFlags, name)) return globalFlags[name];
1223
+ return options.default ?? false;
1259
1224
  }
1260
1225
 
1261
- // ../../node_modules/@posthog/core/dist/featureFlagUtils.mjs
1262
- var normalizeFlagsResponse = (flagsResponse) => {
1263
- if ("flags" in flagsResponse) {
1264
- const featureFlags = getFlagValuesFromFlags(flagsResponse.flags);
1265
- const featureFlagPayloads = getPayloadsFromFlags(flagsResponse.flags);
1266
- return {
1267
- ...flagsResponse,
1268
- featureFlags,
1269
- featureFlagPayloads
1270
- };
1226
+ // ../configuration-core/src/paths.ts
1227
+ import * as os from "node:os";
1228
+ import * as path5 from "node:path";
1229
+ function nonEmpty(value) {
1230
+ if (value == void 0) return null;
1231
+ const trimmed = value.trim();
1232
+ return trimmed === "" ? null : value;
1233
+ }
1234
+ function argentHomeDir() {
1235
+ const home = process.platform === "win32" ? nonEmpty(process.env.USERPROFILE) ?? os.homedir() : nonEmpty(process.env.HOME) ?? os.homedir();
1236
+ return path5.join(home, ".argent");
1237
+ }
1238
+ function configDir(scope = "global", options = {}) {
1239
+ if (scope === "global") {
1240
+ return options.homeDir ? path5.join(options.homeDir, ".argent") : argentHomeDir();
1271
1241
  }
1272
- {
1273
- const featureFlags = flagsResponse.featureFlags ?? {};
1274
- const featureFlagPayloads = Object.fromEntries(Object.entries(flagsResponse.featureFlagPayloads || {}).map(([k, v]) => [
1275
- k,
1276
- parsePayload(v)
1277
- ]));
1278
- const flags2 = Object.fromEntries(Object.entries(featureFlags).map(([key, value]) => [
1279
- key,
1280
- getFlagDetailFromFlagAndPayload(key, value, featureFlagPayloads[key])
1281
- ]));
1282
- return {
1283
- ...flagsResponse,
1284
- featureFlags,
1285
- featureFlagPayloads,
1286
- flags: flags2
1287
- };
1242
+ const cwd = options.cwd ?? process.cwd();
1243
+ return path5.join(resolveProjectRoot(cwd), ".argent");
1244
+ }
1245
+ function configFilePath(scope = "global", options = {}) {
1246
+ return path5.join(configDir(scope, options), "config.json");
1247
+ }
1248
+
1249
+ // ../configuration-core/src/config.ts
1250
+ import * as crypto from "node:crypto";
1251
+ import * as fs3 from "node:fs";
1252
+ import * as path6 from "node:path";
1253
+ function readConfigObject(scope = "global", options = {}) {
1254
+ try {
1255
+ const raw = fs3.readFileSync(configFilePath(scope, options), "utf8");
1256
+ const json = JSON.parse(raw);
1257
+ if (json && typeof json === "object" && !Array.isArray(json)) {
1258
+ return json;
1259
+ }
1260
+ } catch {
1288
1261
  }
1289
- };
1290
- function getFlagDetailFromFlagAndPayload(key, value, payload) {
1291
- return {
1292
- key,
1293
- enabled: "string" == typeof value ? true : value,
1294
- variant: "string" == typeof value ? value : void 0,
1295
- reason: void 0,
1296
- metadata: {
1297
- id: void 0,
1298
- version: void 0,
1299
- payload: payload ? JSON.stringify(payload) : void 0,
1300
- description: void 0
1262
+ return {};
1263
+ }
1264
+ var FORBIDDEN_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
1265
+ function splitKey(dottedKey) {
1266
+ const parts = dottedKey.split(".");
1267
+ if (parts.length === 0 || parts.some((p) => p === "")) {
1268
+ throw new Error(`Invalid config key "${dottedKey}": empty path segment`);
1269
+ }
1270
+ for (const p of parts) {
1271
+ if (FORBIDDEN_SEGMENTS.has(p)) {
1272
+ throw new Error(`Invalid config key "${dottedKey}": forbidden segment "${p}"`);
1301
1273
  }
1302
- };
1274
+ }
1275
+ return parts;
1303
1276
  }
1304
- var getFlagValuesFromFlags = (flags2) => Object.fromEntries(Object.entries(flags2 ?? {}).map(([key, detail]) => [
1305
- key,
1306
- getFeatureFlagValue(detail)
1307
- ]).filter(([, value]) => void 0 !== value));
1308
- var getPayloadsFromFlags = (flags2) => {
1309
- const safeFlags = flags2 ?? {};
1310
- return Object.fromEntries(Object.keys(safeFlags).filter((flag) => {
1311
- const details = safeFlags[flag];
1312
- return details.enabled && details.metadata && void 0 !== details.metadata.payload;
1313
- }).map((flag) => {
1314
- const payload = safeFlags[flag].metadata?.payload;
1315
- return [
1316
- flag,
1317
- payload ? parsePayload(payload) : void 0
1318
- ];
1319
- }));
1320
- };
1321
- var getFeatureFlagValue = (detail) => void 0 === detail ? void 0 : detail.variant ?? detail.enabled;
1322
- var parsePayload = (response) => {
1323
- if ("string" != typeof response) return response;
1277
+ function isPlainObject(value) {
1278
+ return !!value && typeof value === "object" && !Array.isArray(value);
1279
+ }
1280
+ function getAtPath(obj, dottedKey) {
1281
+ const parts = splitKey(dottedKey);
1282
+ let cur = obj;
1283
+ for (const part of parts) {
1284
+ if (!isPlainObject(cur)) return void 0;
1285
+ cur = cur[part];
1286
+ }
1287
+ return cur;
1288
+ }
1289
+ function setAtPath(obj, dottedKey, value) {
1290
+ const parts = splitKey(dottedKey);
1291
+ let cur = obj;
1292
+ for (let i2 = 0; i2 < parts.length - 1; i2++) {
1293
+ const part = parts[i2];
1294
+ const next = cur[part];
1295
+ if (!isPlainObject(next)) {
1296
+ cur[part] = {};
1297
+ }
1298
+ cur = cur[part];
1299
+ }
1300
+ cur[parts[parts.length - 1]] = value;
1301
+ }
1302
+ function deleteAtPath(obj, dottedKey) {
1303
+ const parts = splitKey(dottedKey);
1304
+ let cur = obj;
1305
+ for (let i2 = 0; i2 < parts.length - 1; i2++) {
1306
+ const next = cur[parts[i2]];
1307
+ if (!isPlainObject(next)) return false;
1308
+ cur = next;
1309
+ }
1310
+ const leaf = parts[parts.length - 1];
1311
+ if (!Object.hasOwn(cur, leaf)) return false;
1312
+ delete cur[leaf];
1313
+ return true;
1314
+ }
1315
+ var LOCK_STALE_MS2 = 1e4;
1316
+ var LOCK_MAX_WAIT_MS = 2e3;
1317
+ var LOCK_RETRY_MS = 25;
1318
+ function sleepSync(ms) {
1319
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
1320
+ }
1321
+ function acquireConfigLock(finalPath) {
1322
+ const lockPath = finalPath + ".lock";
1323
+ const deadline = Date.now() + LOCK_MAX_WAIT_MS;
1324
+ for (; ; ) {
1325
+ try {
1326
+ const fd = fs3.openSync(lockPath, "wx", 384);
1327
+ try {
1328
+ fs3.writeSync(fd, `${process.pid}
1329
+ `);
1330
+ } catch {
1331
+ }
1332
+ return { fd, lockPath };
1333
+ } catch (err) {
1334
+ if (err.code !== "EEXIST") return null;
1335
+ try {
1336
+ if (Date.now() - fs3.statSync(lockPath).mtimeMs > LOCK_STALE_MS2) {
1337
+ fs3.unlinkSync(lockPath);
1338
+ continue;
1339
+ }
1340
+ } catch {
1341
+ }
1342
+ if (Date.now() >= deadline) return null;
1343
+ sleepSync(LOCK_RETRY_MS);
1344
+ }
1345
+ }
1346
+ }
1347
+ function releaseConfigLock(lock) {
1324
1348
  try {
1325
- return JSON.parse(response);
1349
+ fs3.closeSync(lock.fd);
1326
1350
  } catch {
1327
- return response;
1328
1351
  }
1329
- };
1330
-
1331
- // ../../node_modules/@posthog/core/dist/types.mjs
1332
- var types_PostHogPersistedProperty = /* @__PURE__ */ (function(PostHogPersistedProperty) {
1333
- PostHogPersistedProperty["AnonymousId"] = "anonymous_id";
1334
- PostHogPersistedProperty["DistinctId"] = "distinct_id";
1335
- PostHogPersistedProperty["Props"] = "props";
1336
- PostHogPersistedProperty["EnablePersonProcessing"] = "enable_person_processing";
1337
- PostHogPersistedProperty["PersonMode"] = "person_mode";
1338
- PostHogPersistedProperty["FeatureFlagDetails"] = "feature_flag_details";
1339
- PostHogPersistedProperty["FeatureFlags"] = "feature_flags";
1340
- PostHogPersistedProperty["FeatureFlagPayloads"] = "feature_flag_payloads";
1341
- PostHogPersistedProperty["BootstrapFeatureFlagDetails"] = "bootstrap_feature_flag_details";
1342
- PostHogPersistedProperty["BootstrapFeatureFlags"] = "bootstrap_feature_flags";
1343
- PostHogPersistedProperty["BootstrapFeatureFlagPayloads"] = "bootstrap_feature_flag_payloads";
1344
- PostHogPersistedProperty["OverrideFeatureFlags"] = "override_feature_flags";
1345
- PostHogPersistedProperty["Queue"] = "queue";
1346
- PostHogPersistedProperty["LogsQueue"] = "logs_queue";
1347
- PostHogPersistedProperty["OptedOut"] = "opted_out";
1348
- PostHogPersistedProperty["SessionId"] = "session_id";
1349
- PostHogPersistedProperty["SessionStartTimestamp"] = "session_start_timestamp";
1350
- PostHogPersistedProperty["SessionLastTimestamp"] = "session_timestamp";
1351
- PostHogPersistedProperty["PersonProperties"] = "person_properties";
1352
- PostHogPersistedProperty["GroupProperties"] = "group_properties";
1353
- PostHogPersistedProperty["InstalledAppBuild"] = "installed_app_build";
1354
- PostHogPersistedProperty["InstalledAppVersion"] = "installed_app_version";
1355
- PostHogPersistedProperty["SessionReplay"] = "session_replay";
1356
- PostHogPersistedProperty["SessionReplayEventTriggerActivatedSession"] = "session_replay_event_trigger_activated_session";
1357
- PostHogPersistedProperty["SurveyLastSeenDate"] = "survey_last_seen_date";
1358
- PostHogPersistedProperty["SurveysSeen"] = "surveys_seen";
1359
- PostHogPersistedProperty["Surveys"] = "surveys";
1360
- PostHogPersistedProperty["RemoteConfig"] = "remote_config";
1361
- PostHogPersistedProperty["FlagsEndpointWasHit"] = "flags_endpoint_was_hit";
1362
- PostHogPersistedProperty["DeviceId"] = "device_id";
1363
- return PostHogPersistedProperty;
1364
- })({});
1365
-
1366
- // ../../node_modules/@posthog/core/dist/gzip.mjs
1367
- function isGzipSupported() {
1368
- return "CompressionStream" in globalThis && "TextEncoder" in globalThis && "Response" in globalThis && "function" == typeof Response.prototype.blob;
1369
- }
1370
- var NATIVE_GZIP_VALIDATION_ERROR = "NativeGzipValidationError";
1371
- var GZIP_MAGIC_FIRST_BYTE = 31;
1372
- var GZIP_MAGIC_SECOND_BYTE = 139;
1373
- var GZIP_DEFLATE_METHOD = 8;
1374
- var hasGzipMagic = (bytes) => bytes.length >= 2 && bytes[0] === GZIP_MAGIC_FIRST_BYTE && bytes[1] === GZIP_MAGIC_SECOND_BYTE;
1375
- var crc32Table;
1376
- var getCrc32Table = () => {
1377
- if (crc32Table) return crc32Table;
1378
- crc32Table = [];
1379
- for (let i2 = 0; i2 < 256; i2++) {
1380
- let crc = i2;
1381
- for (let j = 0; j < 8; j++) crc = 1 & crc ? 3988292384 ^ crc >>> 1 : crc >>> 1;
1382
- crc32Table[i2] = crc >>> 0;
1352
+ try {
1353
+ fs3.unlinkSync(lock.lockPath);
1354
+ } catch {
1383
1355
  }
1384
- return crc32Table;
1385
- };
1386
- var crc32 = (bytes) => {
1387
- const table = getCrc32Table();
1388
- let crc = 4294967295;
1389
- for (let i2 = 0; i2 < bytes.length; i2++) crc = table[(crc ^ bytes[i2]) & 255] ^ crc >>> 8;
1390
- return (4294967295 ^ crc) >>> 0;
1391
- };
1392
- var throwNativeGzipValidationError = (reason) => {
1393
- const error = new Error(`Native gzip produced invalid output: ${reason}`);
1394
- error.name = NATIVE_GZIP_VALIDATION_ERROR;
1395
- throw error;
1396
- };
1397
- var validateNativeGzip = async (compressed, inputBytes) => {
1398
- if (compressed.size < 18) throwNativeGzipValidationError("too-short");
1399
- const header = new Uint8Array(await compressed.slice(0, 10).arrayBuffer());
1400
- if (!hasGzipMagic(header) || header[2] !== GZIP_DEFLATE_METHOD) throwNativeGzipValidationError("invalid-header");
1401
- const trailer = new DataView(await compressed.slice(compressed.size - 8).arrayBuffer());
1402
- if (trailer.getUint32(0, true) !== crc32(inputBytes)) throwNativeGzipValidationError("invalid-crc");
1403
- const inputSize = inputBytes.length >>> 0;
1404
- if (trailer.getUint32(4, true) !== inputSize) throwNativeGzipValidationError("invalid-size");
1405
- };
1406
- async function gzipCompress(input, isDebug = true, options) {
1356
+ }
1357
+ function updateConfig(mutate, scope = "global", options = {}) {
1358
+ const dir = configDir(scope, options);
1359
+ fs3.mkdirSync(dir, { recursive: true });
1360
+ const finalPath = configFilePath(scope, options);
1361
+ const lock = acquireConfigLock(finalPath);
1407
1362
  try {
1408
- const inputBytes = new TextEncoder().encode(input);
1409
- const compressedStream = new CompressionStream("gzip");
1410
- const writer = compressedStream.writable.getWriter();
1411
- const writePromise = writer.write(inputBytes).then(() => writer.close()).catch(async (err) => {
1363
+ const next = readConfigObject(scope, options);
1364
+ mutate(next);
1365
+ const tmpPath = path6.join(dir, `.config.tmp.${process.pid}.${crypto.randomUUID()}`);
1366
+ const fd = fs3.openSync(tmpPath, "wx", 384);
1367
+ try {
1368
+ fs3.writeSync(fd, JSON.stringify(next, null, 2) + "\n");
1369
+ fs3.fsyncSync(fd);
1370
+ } finally {
1371
+ fs3.closeSync(fd);
1372
+ }
1373
+ try {
1374
+ fs3.renameSync(tmpPath, finalPath);
1375
+ } catch (err) {
1412
1376
  try {
1413
- await writer.abort(err);
1377
+ fs3.unlinkSync(tmpPath);
1414
1378
  } catch {
1415
1379
  }
1416
1380
  throw err;
1417
- });
1418
- const responsePromise = new Response(compressedStream.readable).blob();
1419
- const [compressed] = await Promise.all([
1420
- responsePromise,
1421
- writePromise
1422
- ]);
1423
- await validateNativeGzip(compressed, inputBytes);
1424
- return compressed;
1425
- } catch (error) {
1426
- if (options?.rethrow) throw error;
1427
- if (isDebug) console.error("Failed to gzip compress data", error);
1428
- return null;
1381
+ }
1382
+ } finally {
1383
+ if (lock) releaseConfigLock(lock);
1429
1384
  }
1430
1385
  }
1431
1386
 
1432
- // ../../node_modules/@posthog/core/dist/utils/bot-detection.mjs
1433
- var DEFAULT_BLOCKED_UA_STRS = [
1434
- "amazonbot",
1435
- "amazonproductbot",
1436
- "app.hypefactors.com",
1437
- "applebot",
1438
- "archive.org_bot",
1439
- "awariobot",
1440
- "backlinksextendedbot",
1441
- "baiduspider",
1442
- "bingbot",
1443
- "bingpreview",
1444
- "chrome-lighthouse",
1445
- "dataforseobot",
1446
- "deepscan",
1447
- "duckduckbot",
1448
- "facebookexternal",
1449
- "facebookcatalog",
1450
- "http://yandex.com/bots",
1451
- "hubspot",
1452
- "ia_archiver",
1453
- "leikibot",
1454
- "linkedinbot",
1455
- "meta-externalagent",
1456
- "mj12bot",
1457
- "msnbot",
1458
- "nessus",
1459
- "petalbot",
1460
- "pinterest",
1461
- "prerender",
1462
- "rogerbot",
1463
- "screaming frog",
1464
- "sebot-wa",
1465
- "sitebulb",
1466
- "slackbot",
1467
- "slurp",
1468
- "trendictionbot",
1469
- "turnitin",
1470
- "twitterbot",
1471
- "vercel-screenshot",
1472
- "vercelbot",
1473
- "yahoo! slurp",
1474
- "yandexbot",
1475
- "zoombot",
1476
- "bot.htm",
1477
- "bot.php",
1478
- "(bot;",
1479
- "bot/",
1480
- "crawler",
1481
- "ahrefsbot",
1482
- "ahrefssiteaudit",
1483
- "semrushbot",
1484
- "siteauditbot",
1485
- "splitsignalbot",
1486
- "gptbot",
1487
- "oai-searchbot",
1488
- "chatgpt-user",
1489
- "perplexitybot",
1490
- "better uptime bot",
1491
- "sentryuptimebot",
1492
- "uptimerobot",
1493
- "headlesschrome",
1494
- "cypress",
1495
- "google-hoteladsverifier",
1496
- "adsbot-google",
1497
- "apis-google",
1498
- "duplexweb-google",
1499
- "feedfetcher-google",
1500
- "google favicon",
1501
- "google web preview",
1502
- "google-read-aloud",
1503
- "googlebot",
1504
- "googleother",
1505
- "google-cloudvertexbot",
1506
- "googleweblight",
1507
- "mediapartners-google",
1508
- "storebot-google",
1509
- "google-inspectiontool",
1510
- "bytespider"
1511
- ];
1512
- var isBlockedUA = function(ua, customBlockedUserAgents = []) {
1513
- if (!ua) return false;
1514
- const uaLower = ua.toLowerCase();
1515
- return DEFAULT_BLOCKED_UA_STRS.concat(customBlockedUserAgents).some((blockedUA) => {
1516
- const blockedUaLower = blockedUA.toLowerCase();
1517
- return -1 !== uaLower.indexOf(blockedUaLower);
1518
- });
1519
- };
1520
-
1521
- // ../../node_modules/@posthog/core/dist/utils/type-utils.mjs
1522
- var nativeIsArray = Array.isArray;
1523
- var ObjProto = Object.prototype;
1524
- var type_utils_hasOwnProperty = ObjProto.hasOwnProperty;
1525
- var type_utils_toString = ObjProto.toString;
1526
- var isArray = nativeIsArray || function(obj) {
1527
- return "[object Array]" === type_utils_toString.call(obj);
1528
- };
1529
- var isObject = (x) => x === Object(x) && !isArray(x);
1530
- var isUndefined = (x) => void 0 === x;
1531
- var isString = (x) => "[object String]" == type_utils_toString.call(x);
1532
- var isEmptyString = (x) => isString(x) && 0 === x.trim().length;
1533
- var isNumber = (x) => "[object Number]" == type_utils_toString.call(x) && x === x;
1534
- var isPlainError = (x) => x instanceof Error;
1535
- function isPrimitive(value) {
1536
- return null === value || "object" != typeof value;
1537
- }
1538
- function isBuiltin(candidate, className) {
1539
- return Object.prototype.toString.call(candidate) === `[object ${className}]`;
1387
+ // ../configuration-core/src/merge.ts
1388
+ function mergeRestrictive(local, global2) {
1389
+ if (local === void 0) return global2;
1390
+ if (global2 === void 0) return local;
1391
+ if (typeof local === "boolean" && typeof global2 === "boolean") {
1392
+ return local && global2;
1393
+ }
1394
+ if (typeof local === "number" && typeof global2 === "number") {
1395
+ return Math.min(local, global2);
1396
+ }
1397
+ return local;
1540
1398
  }
1541
- function isErrorEvent(event) {
1542
- return isBuiltin(event, "ErrorEvent");
1399
+ function toArray(value) {
1400
+ return Array.isArray(value) ? value : null;
1543
1401
  }
1544
- function isEvent(candidate) {
1545
- return "undefined" != typeof Event && isInstanceOf(candidate, Event);
1402
+ function mergeUnion(local, global2) {
1403
+ const l2 = toArray(local);
1404
+ const g = toArray(global2);
1405
+ if (l2 === null && g === null) return local ?? global2;
1406
+ const merged = [...g ?? [], ...l2 ?? []];
1407
+ return Array.from(new Set(merged));
1546
1408
  }
1547
- function isPlainObject(candidate) {
1548
- return isBuiltin(candidate, "Object");
1409
+ function mergeIntersection(local, global2) {
1410
+ const l2 = toArray(local);
1411
+ const g = toArray(global2);
1412
+ if (l2 === null && g === null) return local ?? global2;
1413
+ if (l2 === null) return global2;
1414
+ if (g === null) return local;
1415
+ const globalSet = new Set(g);
1416
+ return l2.filter((item) => globalSet.has(item));
1549
1417
  }
1550
- function isInstanceOf(candidate, base) {
1551
- try {
1552
- return candidate instanceof base;
1553
- } catch {
1554
- return false;
1418
+ function applyMergePolicy(policy, local, global2) {
1419
+ if (typeof policy === "function") return policy({ local, global: global2 });
1420
+ switch (policy) {
1421
+ case "prioritize-local":
1422
+ return local ?? global2;
1423
+ case "prioritize-global":
1424
+ return global2 ?? local;
1425
+ case "prioritize-restrictive":
1426
+ return mergeRestrictive(local, global2);
1427
+ case "union":
1428
+ return mergeUnion(local, global2);
1429
+ case "intersection":
1430
+ return mergeIntersection(local, global2);
1431
+ default: {
1432
+ const _exhaustive = policy;
1433
+ return _exhaustive;
1434
+ }
1555
1435
  }
1556
1436
  }
1557
1437
 
1558
- // ../../node_modules/@posthog/core/dist/utils/number-utils.mjs
1559
- function clampToRange(value, min, max, logger, fallbackValue) {
1560
- if (min > max) {
1561
- logger.warn("min cannot be greater than max.");
1562
- min = max;
1563
- }
1564
- if (isNumber(value)) if (value > max) {
1565
- logger.warn(" cannot be greater than max: " + max + ". Using max value instead.");
1566
- return max;
1567
- } else {
1568
- if (!(value < min)) return value;
1569
- logger.warn(" cannot be less than min: " + min + ". Using min value instead.");
1570
- return min;
1438
+ // ../configuration-core/src/config-schema.ts
1439
+ function asBoolean(raw) {
1440
+ return typeof raw === "boolean" ? raw : void 0;
1441
+ }
1442
+ function asString(raw) {
1443
+ if (typeof raw !== "string") return void 0;
1444
+ const trimmed = raw.trim();
1445
+ return trimmed === "" ? void 0 : trimmed;
1446
+ }
1447
+ var CONFIG_SCHEMA = [
1448
+ {
1449
+ key: "telemetry.enabled",
1450
+ description: "Whether anonymous opt-out telemetry is enabled (on by default; environment opt-outs like DO_NOT_TRACK are not reflected here \u2014 `argent telemetry status` shows effective consent).",
1451
+ scopes: ["global"],
1452
+ parse: asBoolean,
1453
+ // A committed project file must never re-enable telemetry a user disabled
1454
+ // globally, so the more-restrictive (opt-out) value always wins.
1455
+ merge: "prioritize-restrictive",
1456
+ // Telemetry is opt-out: with nothing stored, consent.ts treats it as
1457
+ // enabled, and the config surface must report the same instead of "(unset)".
1458
+ default: true,
1459
+ // Read-only under `argent config`: opt-in/out goes through the dedicated
1460
+ // command so the live client is drained/reset, not just the file rewritten.
1461
+ manageCommand: "argent telemetry"
1462
+ },
1463
+ {
1464
+ key: "lens.agent",
1465
+ description: "Coding-agent id remembered by `argent lens` to skip the picker.",
1466
+ scopes: ["project", "global"],
1467
+ parse: asString,
1468
+ // A repo can pin the agent its screenshots should use; falls back to the
1469
+ // user's global remembered choice.
1470
+ merge: "prioritize-local",
1471
+ example: "claude"
1571
1472
  }
1572
- logger.warn(" must be a number. using max or fallback. max: " + max + ", fallback: " + fallbackValue);
1573
- return clampToRange(fallbackValue || max, min, max, logger);
1473
+ ];
1474
+ function getConfigDefinition(key, registry = CONFIG_SCHEMA) {
1475
+ return registry.find((def) => def.key === key);
1574
1476
  }
1575
1477
 
1576
- // ../../node_modules/@posthog/core/dist/utils/bucketed-rate-limiter.mjs
1577
- var ONE_DAY_IN_MS = 864e5;
1578
- var BucketedRateLimiter = class {
1579
- constructor(options) {
1580
- this._buckets = {};
1581
- this._onBucketRateLimited = options._onBucketRateLimited;
1582
- this._bucketSize = clampToRange(options.bucketSize, 0, 100, options._logger);
1583
- this._refillRate = clampToRange(options.refillRate, 0, this._bucketSize, options._logger);
1584
- this._refillInterval = clampToRange(options.refillInterval, 0, ONE_DAY_IN_MS, options._logger);
1478
+ // ../configuration-core/src/config-access.ts
1479
+ function readScopeValue(def, scope, options) {
1480
+ if (!def.scopes.includes(scope)) return void 0;
1481
+ const raw = getAtPath(readConfigObject(scope, options), def.key);
1482
+ return raw === void 0 ? void 0 : def.parse(raw);
1483
+ }
1484
+ function getConfigValue(def, options = {}) {
1485
+ const local = readScopeValue(def, "project", options);
1486
+ const global2 = readScopeValue(def, "global", options);
1487
+ const merged = applyMergePolicy(def.merge, local, global2);
1488
+ return merged ?? def.default;
1489
+ }
1490
+ function getConfigValueAtScope(key, scope, options = {}, registry = CONFIG_SCHEMA) {
1491
+ const def = requireDefinition(key, registry);
1492
+ return readScopeValue(def, scope, options);
1493
+ }
1494
+ function getConfigValueByKey(key, options = {}, registry = CONFIG_SCHEMA) {
1495
+ const def = requireDefinition(key, registry);
1496
+ return getConfigValue(def, options);
1497
+ }
1498
+ function requireDefinition(key, registry = CONFIG_SCHEMA) {
1499
+ const def = getConfigDefinition(key, registry);
1500
+ if (!def) {
1501
+ throw new UnknownConfigKeyError(key);
1585
1502
  }
1586
- _applyRefill(bucket, now) {
1587
- const elapsedMs = now - bucket.lastAccess;
1588
- const refillIntervals = Math.floor(elapsedMs / this._refillInterval);
1589
- if (refillIntervals > 0) {
1590
- const tokensToAdd = refillIntervals * this._refillRate;
1591
- bucket.tokens = Math.min(bucket.tokens + tokensToAdd, this._bucketSize);
1592
- bucket.lastAccess = bucket.lastAccess + refillIntervals * this._refillInterval;
1593
- }
1503
+ return def;
1504
+ }
1505
+ var UnknownConfigKeyError = class extends Error {
1506
+ constructor(key) {
1507
+ super(`Unknown configuration key "${key}".`);
1508
+ this.key = key;
1509
+ this.name = "UnknownConfigKeyError";
1594
1510
  }
1595
- consumeRateLimit(key) {
1596
- const now = Date.now();
1597
- const keyStr = String(key);
1598
- let bucket = this._buckets[keyStr];
1599
- if (bucket) this._applyRefill(bucket, now);
1600
- else {
1601
- bucket = {
1602
- tokens: this._bucketSize,
1603
- lastAccess: now
1604
- };
1605
- this._buckets[keyStr] = bucket;
1606
- }
1607
- if (0 === bucket.tokens) return true;
1608
- bucket.tokens--;
1609
- if (0 === bucket.tokens) this._onBucketRateLimited?.(key);
1610
- return 0 === bucket.tokens;
1511
+ key;
1512
+ };
1513
+ var ConfigScopeError = class extends Error {
1514
+ constructor(key, scope, allowed) {
1515
+ super(`Config key "${key}" cannot be set at ${scope} scope (allowed: ${allowed.join(", ")}).`);
1516
+ this.key = key;
1517
+ this.scope = scope;
1518
+ this.allowed = allowed;
1519
+ this.name = "ConfigScopeError";
1611
1520
  }
1612
- stop() {
1613
- this._buckets = {};
1521
+ key;
1522
+ scope;
1523
+ allowed;
1524
+ };
1525
+ var ConfigValidationError = class extends Error {
1526
+ constructor(key) {
1527
+ super(`Invalid value for config key "${key}".`);
1528
+ this.key = key;
1529
+ this.name = "ConfigValidationError";
1614
1530
  }
1531
+ key;
1615
1532
  };
1616
-
1617
- // ../../node_modules/@posthog/core/dist/vendor/uuidv7.mjs
1618
- var DIGITS = "0123456789abcdef";
1619
- var UUID = class _UUID {
1620
- constructor(bytes) {
1621
- this.bytes = bytes;
1533
+ var ConfigManagedElsewhereError = class extends Error {
1534
+ constructor(key, command) {
1535
+ super(`Config key "${key}" is managed by \`${command}\`.`);
1536
+ this.key = key;
1537
+ this.command = command;
1538
+ this.name = "ConfigManagedElsewhereError";
1622
1539
  }
1623
- static ofInner(bytes) {
1624
- if (16 === bytes.length) return new _UUID(bytes);
1625
- throw new TypeError("not 128-bit length");
1540
+ key;
1541
+ command;
1542
+ };
1543
+ function setConfigValue(key, rawValue, scope = "global", options = {}, registry = CONFIG_SCHEMA) {
1544
+ const def = requireDefinition(key, registry);
1545
+ if (def.manageCommand) throw new ConfigManagedElsewhereError(key, def.manageCommand);
1546
+ if (!def.scopes.includes(scope)) throw new ConfigScopeError(key, scope, def.scopes);
1547
+ const parsed = def.parse(rawValue);
1548
+ if (parsed === void 0) throw new ConfigValidationError(key);
1549
+ updateConfig((config2) => setAtPath(config2, key, parsed), scope, options);
1550
+ return parsed;
1551
+ }
1552
+ function unsetConfigValue(key, scope = "global", options = {}, registry = CONFIG_SCHEMA) {
1553
+ const def = requireDefinition(key, registry);
1554
+ if (def.manageCommand) throw new ConfigManagedElsewhereError(key, def.manageCommand);
1555
+ if (!def.scopes.includes(scope)) throw new ConfigScopeError(key, scope, def.scopes);
1556
+ if (getAtPath(readConfigObject(scope, options), key) === void 0) return false;
1557
+ let removed = false;
1558
+ updateConfig(
1559
+ (config2) => {
1560
+ removed = deleteAtPath(config2, key);
1561
+ },
1562
+ scope,
1563
+ options
1564
+ );
1565
+ return removed;
1566
+ }
1567
+ function listConfig(options = {}, registry = CONFIG_SCHEMA) {
1568
+ return registry.map((def) => ({
1569
+ key: def.key,
1570
+ description: def.description,
1571
+ scopes: def.scopes,
1572
+ ...def.manageCommand ? { manageCommand: def.manageCommand } : {},
1573
+ effective: getConfigValue(def, options),
1574
+ project: readScopeValue(def, "project", options),
1575
+ global: readScopeValue(def, "global", options)
1576
+ }));
1577
+ }
1578
+ function coerceCliValue(raw) {
1579
+ try {
1580
+ return JSON.parse(raw);
1581
+ } catch {
1582
+ return raw;
1626
1583
  }
1627
- static fromFieldsV7(unixTsMs, randA, randBHi, randBLo) {
1628
- if (!Number.isInteger(unixTsMs) || !Number.isInteger(randA) || !Number.isInteger(randBHi) || !Number.isInteger(randBLo) || unixTsMs < 0 || randA < 0 || randBHi < 0 || randBLo < 0 || unixTsMs > 281474976710655 || randA > 4095 || randBHi > 1073741823 || randBLo > 4294967295) throw new RangeError("invalid field value");
1629
- const bytes = new Uint8Array(16);
1630
- bytes[0] = unixTsMs / 2 ** 40;
1631
- bytes[1] = unixTsMs / 2 ** 32;
1632
- bytes[2] = unixTsMs / 2 ** 24;
1633
- bytes[3] = unixTsMs / 2 ** 16;
1634
- bytes[4] = unixTsMs / 256;
1635
- bytes[5] = unixTsMs;
1636
- bytes[6] = 112 | randA >>> 8;
1637
- bytes[7] = randA;
1638
- bytes[8] = 128 | randBHi >>> 24;
1639
- bytes[9] = randBHi >>> 16;
1640
- bytes[10] = randBHi >>> 8;
1641
- bytes[11] = randBHi;
1642
- bytes[12] = randBLo >>> 24;
1643
- bytes[13] = randBLo >>> 16;
1644
- bytes[14] = randBLo >>> 8;
1645
- bytes[15] = randBLo;
1646
- return new _UUID(bytes);
1584
+ }
1585
+ var LENS_AGENT_KEY = "lens.agent";
1586
+ function getRememberedAgent(options = {}) {
1587
+ const value = getConfigValueByKey(LENS_AGENT_KEY, options);
1588
+ return typeof value === "string" && value.trim() ? value : null;
1589
+ }
1590
+ function setRememberedAgent(agentId, options = {}) {
1591
+ setConfigValue(LENS_AGENT_KEY, agentId, "global", options);
1592
+ }
1593
+ function clearRememberedAgent(options = {}) {
1594
+ unsetConfigValue(LENS_AGENT_KEY, "global", options);
1595
+ }
1596
+
1597
+ // ../argent-tools-client/src/artifacts.ts
1598
+ var ARTIFACT_MARKER = "__argentArtifact";
1599
+ function isArtifactHandle(value) {
1600
+ return !!value && typeof value === "object" && value[ARTIFACT_MARKER] === true && typeof value.id === "string" && typeof value.filename === "string";
1601
+ }
1602
+ var SESSION_ID = null;
1603
+ function sessionId() {
1604
+ if (!SESSION_ID) {
1605
+ const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:T]/g, (m) => m === "T" ? "-" : "").slice(0, 15);
1606
+ SESSION_ID = `${stamp}-${process.pid}`;
1647
1607
  }
1648
- static parse(uuid) {
1649
- let hex;
1650
- switch (uuid.length) {
1651
- case 32:
1652
- hex = /^[0-9a-f]{32}$/i.exec(uuid)?.[0];
1653
- break;
1654
- case 36:
1655
- hex = /^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(uuid)?.slice(1, 6).join("");
1656
- break;
1657
- case 38:
1658
- hex = /^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(uuid)?.slice(1, 6).join("");
1659
- break;
1660
- case 45:
1661
- hex = /^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(uuid)?.slice(1, 6).join("");
1662
- break;
1663
- default:
1664
- break;
1665
- }
1666
- if (hex) {
1667
- const inner = new Uint8Array(16);
1668
- for (let i2 = 0; i2 < 16; i2 += 4) {
1669
- const n2 = parseInt(hex.substring(2 * i2, 2 * i2 + 8), 16);
1670
- inner[i2 + 0] = n2 >>> 24;
1671
- inner[i2 + 1] = n2 >>> 16;
1672
- inner[i2 + 2] = n2 >>> 8;
1673
- inner[i2 + 3] = n2;
1674
- }
1675
- return new _UUID(inner);
1676
- }
1677
- throw new SyntaxError("could not parse UUID string");
1608
+ return SESSION_ID;
1609
+ }
1610
+ function sanitizeSegment(segment) {
1611
+ return segment.replace(/[^A-Za-z0-9._-]/g, "_");
1612
+ }
1613
+ function projectSlug() {
1614
+ const cwd = process.cwd();
1615
+ const hash = createHash3("sha1").update(cwd).digest("hex").slice(0, 6);
1616
+ const name = sanitizeSegment(basename3(cwd)) || "root";
1617
+ return `${name}-${hash}`;
1618
+ }
1619
+ function artifactsRoot() {
1620
+ return process.env.ARGENT_ARTIFACTS_DIR ?? join8(tmpdir2(), "argent-artifacts");
1621
+ }
1622
+ function artifactDir(deviceId) {
1623
+ const parts = [artifactsRoot(), projectSlug(), sessionId()];
1624
+ if (deviceId) parts.push(sanitizeSegment(deviceId));
1625
+ return join8(...parts);
1626
+ }
1627
+ function durableBaseDir() {
1628
+ const projectRoot = findProjectRoot(process.cwd());
1629
+ return projectRoot ?? dirname5(argentHomeDir());
1630
+ }
1631
+ var ALLOWED_SAVE_DIRS = /* @__PURE__ */ new Set([normalize(".argent/recordings")]);
1632
+ var MAX_DURABLE_BYTES = 2 * 1024 * 1024 * 1024;
1633
+ async function readCapped(res, cap) {
1634
+ const headers = res.headers;
1635
+ const declared = Number(headers?.get?.("content-length"));
1636
+ if (Number.isFinite(declared) && declared > cap) return null;
1637
+ const body = res.body;
1638
+ if (!body?.getReader) {
1639
+ const buf = Buffer.from(await res.arrayBuffer());
1640
+ return buf.length > cap ? null : buf;
1678
1641
  }
1679
- toString() {
1680
- let text2 = "";
1681
- for (let i2 = 0; i2 < this.bytes.length; i2++) {
1682
- text2 += DIGITS.charAt(this.bytes[i2] >>> 4);
1683
- text2 += DIGITS.charAt(15 & this.bytes[i2]);
1684
- if (3 === i2 || 5 === i2 || 7 === i2 || 9 === i2) text2 += "-";
1642
+ const reader = body.getReader();
1643
+ const chunks = [];
1644
+ let total = 0;
1645
+ for (; ; ) {
1646
+ const { done, value } = await reader.read();
1647
+ if (done) break;
1648
+ total += value.byteLength;
1649
+ if (total > cap) {
1650
+ await reader.cancel().catch(() => {
1651
+ });
1652
+ return null;
1685
1653
  }
1686
- return text2;
1654
+ chunks.push(Buffer.from(value));
1687
1655
  }
1688
- toHex() {
1689
- let text2 = "";
1690
- for (let i2 = 0; i2 < this.bytes.length; i2++) {
1691
- text2 += DIGITS.charAt(this.bytes[i2] >>> 4);
1692
- text2 += DIGITS.charAt(15 & this.bytes[i2]);
1656
+ return Buffer.concat(chunks);
1657
+ }
1658
+ async function writeDurableUnique(dir, filename, write) {
1659
+ const ext = extname(filename);
1660
+ const stem = filename.slice(0, filename.length - ext.length);
1661
+ for (let i2 = 1; i2 <= 1e3; i2++) {
1662
+ const candidate = i2 === 1 ? filename : `${stem} (${i2})${ext}`;
1663
+ const path15 = join8(dir, candidate);
1664
+ try {
1665
+ await write(path15);
1666
+ return path15;
1667
+ } catch (err) {
1668
+ if (err?.code === "EEXIST") continue;
1669
+ throw err;
1693
1670
  }
1694
- return text2;
1695
- }
1696
- toJSON() {
1697
- return this.toString();
1698
- }
1699
- getVariant() {
1700
- const n2 = this.bytes[8] >>> 4;
1701
- if (n2 < 0) throw new Error("unreachable");
1702
- if (n2 <= 7) return this.bytes.every((e) => 0 === e) ? "NIL" : "VAR_0";
1703
- if (n2 <= 11) return "VAR_10";
1704
- if (n2 <= 13) return "VAR_110";
1705
- if (n2 <= 15) return this.bytes.every((e) => 255 === e) ? "MAX" : "VAR_RESERVED";
1706
- else throw new Error("unreachable");
1707
- }
1708
- getVersion() {
1709
- return "VAR_10" === this.getVariant() ? this.bytes[6] >>> 4 : void 0;
1710
1671
  }
1711
- clone() {
1712
- return new _UUID(this.bytes.slice(0));
1672
+ return null;
1673
+ }
1674
+ function durableSaveTarget(handle) {
1675
+ if (typeof handle.saveDir !== "string" || !handle.saveDir || handle.archive) return null;
1676
+ const rel = normalize(handle.saveDir);
1677
+ if (isAbsolute3(rel) || rel === ".." || rel.startsWith(`..${sep2}`) || rel.split(sep2).includes("..")) {
1678
+ return null;
1713
1679
  }
1714
- equals(other) {
1715
- return 0 === this.compareTo(other);
1680
+ if (!ALLOWED_SAVE_DIRS.has(rel)) return null;
1681
+ const base = durableBaseDir();
1682
+ const dir = join8(base, rel);
1683
+ return { dir, path: join8(dir, sanitizeSegment(handle.filename)), base, rel };
1684
+ }
1685
+ async function confineToRealBase(dir, base, rel) {
1686
+ try {
1687
+ const realDir = await realpath(dir);
1688
+ const realBase = await realpath(base);
1689
+ return realDir === join8(realBase, rel);
1690
+ } catch {
1691
+ return false;
1716
1692
  }
1717
- compareTo(other) {
1718
- for (let i2 = 0; i2 < 16; i2++) {
1719
- const diff = this.bytes[i2] - other.bytes[i2];
1720
- if (0 !== diff) return Math.sign(diff);
1693
+ }
1694
+ async function resolveLocalFile(handle) {
1695
+ if (!handle.hostPath) return null;
1696
+ try {
1697
+ const st = await stat2(handle.hostPath);
1698
+ if (handle.archive) {
1699
+ return st.isDirectory() ? handle.hostPath : null;
1721
1700
  }
1722
- return 0;
1723
- }
1724
- };
1725
- var V7Generator = class {
1726
- constructor(randomNumberGenerator) {
1727
- this.timestamp = 0;
1728
- this.counter = 0;
1729
- this.random = randomNumberGenerator ?? getDefaultRandom();
1730
- }
1731
- generate() {
1732
- return this.generateOrResetCore(Date.now(), 1e4);
1701
+ if (!st.isFile()) return null;
1702
+ if (st.size !== handle.size) return null;
1703
+ if (handle.mtimeMs != null && Math.round(st.mtimeMs) !== Math.round(handle.mtimeMs)) {
1704
+ return null;
1705
+ }
1706
+ return handle.hostPath;
1707
+ } catch {
1708
+ return null;
1733
1709
  }
1734
- generateOrAbort() {
1735
- return this.generateOrAbortCore(Date.now(), 1e4);
1710
+ }
1711
+ async function downloadAndExtractArchive(handle, data, dir) {
1712
+ const tarball2 = join8(dir, `${sanitizeSegment(handle.filename)}.tar.gz`);
1713
+ try {
1714
+ await writeFile4(tarball2, data);
1715
+ return await safeExtractTarGz(tarball2, dir, handle.filename);
1716
+ } catch {
1717
+ return null;
1718
+ } finally {
1719
+ await rm3(tarball2, { force: true }).catch(() => {
1720
+ });
1736
1721
  }
1737
- generateOrResetCore(unixTsMs, rollbackAllowance) {
1738
- let value = this.generateOrAbortCore(unixTsMs, rollbackAllowance);
1739
- if (void 0 === value) {
1740
- this.timestamp = 0;
1741
- value = this.generateOrAbortCore(unixTsMs, rollbackAllowance);
1722
+ }
1723
+ async function materializeArtifacts(result, ctx) {
1724
+ const images = [];
1725
+ const fetchFn = ctx.fetchImpl ?? fetch;
1726
+ const authHeaders3 = ctx.authToken ? { Authorization: `Bearer ${ctx.authToken}` } : {};
1727
+ const dir = artifactDir(ctx.deviceId);
1728
+ let dirReady = false;
1729
+ async function ensureDir() {
1730
+ if (!dirReady) {
1731
+ await mkdir4(dir, { recursive: true });
1732
+ dirReady = true;
1742
1733
  }
1743
- return value;
1744
1734
  }
1745
- generateOrAbortCore(unixTsMs, rollbackAllowance) {
1746
- const MAX_COUNTER = 4398046511103;
1747
- if (!Number.isInteger(unixTsMs) || unixTsMs < 1 || unixTsMs > 281474976710655) throw new RangeError("`unixTsMs` must be a 48-bit positive integer");
1748
- if (rollbackAllowance < 0 || rollbackAllowance > 281474976710655) throw new RangeError("`rollbackAllowance` out of reasonable range");
1749
- if (unixTsMs > this.timestamp) {
1750
- this.timestamp = unixTsMs;
1751
- this.resetCounter();
1752
- } else {
1753
- if (!(unixTsMs + rollbackAllowance >= this.timestamp)) return;
1754
- this.counter++;
1755
- if (this.counter > MAX_COUNTER) {
1756
- this.timestamp++;
1757
- this.resetCounter();
1735
+ async function walk(value) {
1736
+ if (isArtifactHandle(value)) {
1737
+ const localPath = await resolveLocalFile(value);
1738
+ const saveTarget = durableSaveTarget(value);
1739
+ if (saveTarget) {
1740
+ const filename = basename3(saveTarget.path);
1741
+ try {
1742
+ await mkdir4(saveTarget.dir, { recursive: true });
1743
+ if (!await confineToRealBase(saveTarget.dir, saveTarget.base, saveTarget.rel)) {
1744
+ return null;
1745
+ }
1746
+ if (localPath) {
1747
+ const finalPath2 = await writeDurableUnique(
1748
+ saveTarget.dir,
1749
+ filename,
1750
+ (p) => copyFile(localPath, p, fsConstants.COPYFILE_EXCL)
1751
+ );
1752
+ if (!finalPath2) return null;
1753
+ if (value.mimeType.startsWith("image/")) {
1754
+ images.push({
1755
+ localPath: finalPath2,
1756
+ data: await readFile4(finalPath2),
1757
+ mimeType: value.mimeType
1758
+ });
1759
+ }
1760
+ return finalPath2;
1761
+ }
1762
+ if (!Number.isInteger(value.size) || value.size <= 0 || value.size > MAX_DURABLE_BYTES) {
1763
+ return null;
1764
+ }
1765
+ const res = await fetchFn(`${ctx.toolsUrl}/artifacts/${value.id}`, {
1766
+ headers: authHeaders3
1767
+ });
1768
+ if (!res.ok) return null;
1769
+ const data = await readCapped(res, value.size);
1770
+ if (!data || data.length !== value.size) return null;
1771
+ const finalPath = await writeDurableUnique(
1772
+ saveTarget.dir,
1773
+ filename,
1774
+ (p) => writeFile4(p, data, { flag: "wx" })
1775
+ );
1776
+ if (!finalPath) return null;
1777
+ if (value.mimeType.startsWith("image/")) {
1778
+ images.push({ localPath: finalPath, data, mimeType: value.mimeType });
1779
+ }
1780
+ return finalPath;
1781
+ } catch {
1782
+ return null;
1783
+ }
1784
+ }
1785
+ if (localPath) {
1786
+ if (value.mimeType.startsWith("image/")) {
1787
+ images.push({ localPath, data: await readFile4(localPath), mimeType: value.mimeType });
1788
+ }
1789
+ return localPath;
1790
+ }
1791
+ try {
1792
+ const res = await fetchFn(`${ctx.toolsUrl}/artifacts/${value.id}`, {
1793
+ headers: authHeaders3
1794
+ });
1795
+ if (!res.ok) return null;
1796
+ const data = Buffer.from(await res.arrayBuffer());
1797
+ await ensureDir();
1798
+ if (value.archive === "tar.gz") {
1799
+ return await downloadAndExtractArchive(value, data, dir);
1800
+ }
1801
+ if (value.size > 0 && data.length !== value.size) return null;
1802
+ const downloadedPath = join8(dir, sanitizeSegment(value.filename));
1803
+ await writeFile4(downloadedPath, data);
1804
+ if (value.mimeType.startsWith("image/")) {
1805
+ images.push({ localPath: downloadedPath, data, mimeType: value.mimeType });
1806
+ }
1807
+ return downloadedPath;
1808
+ } catch {
1809
+ return null;
1758
1810
  }
1759
1811
  }
1760
- return UUID.fromFieldsV7(this.timestamp, Math.trunc(this.counter / 2 ** 30), this.counter & 2 ** 30 - 1, this.random.nextUint32());
1761
- }
1762
- resetCounter() {
1763
- this.counter = 1024 * this.random.nextUint32() + (1023 & this.random.nextUint32());
1764
- }
1765
- generateV4() {
1766
- const bytes = new Uint8Array(Uint32Array.of(this.random.nextUint32(), this.random.nextUint32(), this.random.nextUint32(), this.random.nextUint32()).buffer);
1767
- bytes[6] = 64 | bytes[6] >>> 4;
1768
- bytes[8] = 128 | bytes[8] >>> 2;
1769
- return UUID.ofInner(bytes);
1770
- }
1771
- };
1772
- var getDefaultRandom = () => ({
1773
- nextUint32: () => 65536 * Math.trunc(65536 * Math.random()) + Math.trunc(65536 * Math.random())
1774
- });
1775
- var defaultGenerator;
1776
- var uuidv7 = () => uuidv7obj().toString();
1777
- var uuidv7obj = () => (defaultGenerator || (defaultGenerator = new V7Generator())).generate();
1778
-
1779
- // ../../node_modules/@posthog/core/dist/utils/promise-queue.mjs
1780
- var PromiseQueue = class {
1781
- add(promise) {
1782
- const promiseUUID = uuidv7();
1783
- this.promiseByIds[promiseUUID] = promise;
1784
- promise.catch(() => {
1785
- }).finally(() => {
1786
- delete this.promiseByIds[promiseUUID];
1787
- });
1788
- return promise;
1789
- }
1790
- async join() {
1791
- let promises = Object.values(this.promiseByIds);
1792
- let length = promises.length;
1793
- while (length > 0) {
1794
- await Promise.all(promises);
1795
- promises = Object.values(this.promiseByIds);
1796
- length = promises.length;
1812
+ if (Array.isArray(value)) {
1813
+ return Promise.all(value.map(walk));
1797
1814
  }
1815
+ if (value && typeof value === "object") {
1816
+ const out = {};
1817
+ for (const [k, v] of Object.entries(value)) {
1818
+ out[k] = await walk(v);
1819
+ }
1820
+ return out;
1821
+ }
1822
+ return value;
1798
1823
  }
1799
- get length() {
1800
- return Object.keys(this.promiseByIds).length;
1801
- }
1802
- constructor() {
1803
- this.promiseByIds = {};
1804
- }
1805
- };
1824
+ const rewritten = await walk(result);
1825
+ return { result: rewritten, images };
1826
+ }
1827
+ function getDeviceIdFromArgs(args) {
1828
+ if (!args || typeof args !== "object") return void 0;
1829
+ const rec = args;
1830
+ if (typeof rec.udid === "string") return rec.udid;
1831
+ if (typeof rec.device_id === "string") return rec.device_id;
1832
+ return void 0;
1833
+ }
1806
1834
 
1807
- // ../../node_modules/@posthog/core/dist/utils/logger.mjs
1808
- function createConsole(consoleLike = console) {
1809
- const lockedMethods = {
1810
- log: consoleLike.log.bind(consoleLike),
1811
- warn: consoleLike.warn.bind(consoleLike),
1812
- error: consoleLike.error.bind(consoleLike),
1813
- debug: consoleLike.debug.bind(consoleLike)
1835
+ // ../../node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
1836
+ import { dirname as dirname6, posix as posix2, sep as sep3 } from "path";
1837
+ function createModulerModifier() {
1838
+ const getModuleFromFileName = createGetModuleFromFilename();
1839
+ return async (frames) => {
1840
+ for (const frame of frames) frame.module = getModuleFromFileName(frame.filename);
1841
+ return frames;
1814
1842
  };
1815
- return lockedMethods;
1816
1843
  }
1817
- var _createLogger = (prefix, maybeCall, consoleLike) => {
1818
- function _log(level, ...args) {
1819
- maybeCall(() => {
1820
- const consoleMethod = consoleLike[level];
1821
- consoleMethod(prefix, ...args);
1822
- });
1823
- }
1824
- const logger = {
1825
- debug: (...args) => {
1826
- _log("debug", ...args);
1827
- },
1828
- info: (...args) => {
1829
- _log("log", ...args);
1830
- },
1831
- warn: (...args) => {
1832
- _log("warn", ...args);
1833
- },
1834
- error: (...args) => {
1835
- _log("error", ...args);
1836
- },
1837
- critical: (...args) => {
1838
- consoleLike["error"](prefix, ...args);
1839
- },
1840
- createLogger: (additionalPrefix) => _createLogger(`${prefix} ${additionalPrefix}`, maybeCall, consoleLike)
1844
+ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname6(process.argv[1]) : process.cwd(), isWindows = "\\" === sep3) {
1845
+ const normalizedBase = isWindows ? normalizeWindowsPath(basePath) : basePath;
1846
+ return (filename) => {
1847
+ if (!filename) return;
1848
+ const normalizedFilename = isWindows ? normalizeWindowsPath(filename) : filename;
1849
+ let { dir, base: file, ext } = posix2.parse(normalizedFilename);
1850
+ if (".js" === ext || ".mjs" === ext || ".cjs" === ext) file = file.slice(0, -1 * ext.length);
1851
+ const decodedFile = decodeURIComponent(file);
1852
+ if (!dir) dir = ".";
1853
+ const n2 = dir.lastIndexOf("/node_modules");
1854
+ if (n2 > -1) return `${dir.slice(n2 + 14).replace(/\//g, ".")}:${decodedFile}`;
1855
+ if (dir.startsWith(normalizedBase)) {
1856
+ const moduleName = dir.slice(normalizedBase.length + 1).replace(/\//g, ".");
1857
+ return moduleName ? `${moduleName}:${decodedFile}` : decodedFile;
1858
+ }
1859
+ return decodedFile;
1841
1860
  };
1842
- return logger;
1843
- };
1844
- var passThrough = (fn) => fn();
1845
- function createLogger(prefix, maybeCall = passThrough) {
1846
- return _createLogger(prefix, maybeCall, createConsole());
1861
+ }
1862
+ function normalizeWindowsPath(path15) {
1863
+ return path15.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
1847
1864
  }
1848
1865
 
1849
- // ../../node_modules/@posthog/core/dist/utils/user-agent-utils.mjs
1850
- var MOBILE = "Mobile";
1851
- var IOS = "iOS";
1852
- var ANDROID = "Android";
1853
- var TABLET = "Tablet";
1854
- var ANDROID_TABLET = ANDROID + " " + TABLET;
1855
- var APPLE = "Apple";
1856
- var APPLE_WATCH = APPLE + " Watch";
1857
- var SAFARI = "Safari";
1858
- var BLACKBERRY = "BlackBerry";
1859
- var SAMSUNG = "Samsung";
1860
- var SAMSUNG_BROWSER = SAMSUNG + "Browser";
1861
- var SAMSUNG_INTERNET = SAMSUNG + " Internet";
1862
- var CHROME = "Chrome";
1863
- var CHROME_OS = CHROME + " OS";
1864
- var CHROME_IOS = CHROME + " " + IOS;
1865
- var INTERNET_EXPLORER = "Internet Explorer";
1866
- var INTERNET_EXPLORER_MOBILE = INTERNET_EXPLORER + " " + MOBILE;
1867
- var OPERA = "Opera";
1868
- var OPERA_MINI = OPERA + " Mini";
1869
- var EDGE = "Edge";
1870
- var MICROSOFT_EDGE = "Microsoft " + EDGE;
1871
- var FIREFOX = "Firefox";
1872
- var FIREFOX_IOS = FIREFOX + " " + IOS;
1873
- var NINTENDO = "Nintendo";
1874
- var PLAYSTATION = "PlayStation";
1875
- var XBOX = "Xbox";
1876
- var ANDROID_MOBILE = ANDROID + " " + MOBILE;
1877
- var MOBILE_SAFARI = MOBILE + " " + SAFARI;
1878
- var WINDOWS = "Windows";
1879
- var WINDOWS_PHONE = WINDOWS + " Phone";
1880
- var GENERIC = "Generic";
1881
- var GENERIC_MOBILE = GENERIC + " " + MOBILE.toLowerCase();
1882
- var GENERIC_TABLET = GENERIC + " " + TABLET.toLowerCase();
1883
- var KONQUEROR = "Konqueror";
1866
+ // ../../node_modules/@posthog/core/dist/featureFlagUtils.mjs
1867
+ var normalizeFlagsResponse = (flagsResponse) => {
1868
+ if ("flags" in flagsResponse) {
1869
+ const featureFlags = getFlagValuesFromFlags(flagsResponse.flags);
1870
+ const featureFlagPayloads = getPayloadsFromFlags(flagsResponse.flags);
1871
+ return {
1872
+ ...flagsResponse,
1873
+ featureFlags,
1874
+ featureFlagPayloads
1875
+ };
1876
+ }
1877
+ {
1878
+ const featureFlags = flagsResponse.featureFlags ?? {};
1879
+ const featureFlagPayloads = Object.fromEntries(Object.entries(flagsResponse.featureFlagPayloads || {}).map(([k, v]) => [
1880
+ k,
1881
+ parsePayload(v)
1882
+ ]));
1883
+ const flags2 = Object.fromEntries(Object.entries(featureFlags).map(([key, value]) => [
1884
+ key,
1885
+ getFlagDetailFromFlagAndPayload(key, value, featureFlagPayloads[key])
1886
+ ]));
1887
+ return {
1888
+ ...flagsResponse,
1889
+ featureFlags,
1890
+ featureFlagPayloads,
1891
+ flags: flags2
1892
+ };
1893
+ }
1894
+ };
1895
+ function getFlagDetailFromFlagAndPayload(key, value, payload) {
1896
+ return {
1897
+ key,
1898
+ enabled: "string" == typeof value ? true : value,
1899
+ variant: "string" == typeof value ? value : void 0,
1900
+ reason: void 0,
1901
+ metadata: {
1902
+ id: void 0,
1903
+ version: void 0,
1904
+ payload: payload ? JSON.stringify(payload) : void 0,
1905
+ description: void 0
1906
+ }
1907
+ };
1908
+ }
1909
+ var getFlagValuesFromFlags = (flags2) => Object.fromEntries(Object.entries(flags2 ?? {}).map(([key, detail]) => [
1910
+ key,
1911
+ getFeatureFlagValue(detail)
1912
+ ]).filter(([, value]) => void 0 !== value));
1913
+ var getPayloadsFromFlags = (flags2) => {
1914
+ const safeFlags = flags2 ?? {};
1915
+ return Object.fromEntries(Object.keys(safeFlags).filter((flag) => {
1916
+ const details = safeFlags[flag];
1917
+ return details.enabled && details.metadata && void 0 !== details.metadata.payload;
1918
+ }).map((flag) => {
1919
+ const payload = safeFlags[flag].metadata?.payload;
1920
+ return [
1921
+ flag,
1922
+ payload ? parsePayload(payload) : void 0
1923
+ ];
1924
+ }));
1925
+ };
1926
+ var getFeatureFlagValue = (detail) => void 0 === detail ? void 0 : detail.variant ?? detail.enabled;
1927
+ var parsePayload = (response) => {
1928
+ if ("string" != typeof response) return response;
1929
+ try {
1930
+ return JSON.parse(response);
1931
+ } catch {
1932
+ return response;
1933
+ }
1934
+ };
1935
+
1936
+ // ../../node_modules/@posthog/core/dist/types.mjs
1937
+ var types_PostHogPersistedProperty = /* @__PURE__ */ (function(PostHogPersistedProperty) {
1938
+ PostHogPersistedProperty["AnonymousId"] = "anonymous_id";
1939
+ PostHogPersistedProperty["DistinctId"] = "distinct_id";
1940
+ PostHogPersistedProperty["Props"] = "props";
1941
+ PostHogPersistedProperty["EnablePersonProcessing"] = "enable_person_processing";
1942
+ PostHogPersistedProperty["PersonMode"] = "person_mode";
1943
+ PostHogPersistedProperty["FeatureFlagDetails"] = "feature_flag_details";
1944
+ PostHogPersistedProperty["FeatureFlags"] = "feature_flags";
1945
+ PostHogPersistedProperty["FeatureFlagPayloads"] = "feature_flag_payloads";
1946
+ PostHogPersistedProperty["BootstrapFeatureFlagDetails"] = "bootstrap_feature_flag_details";
1947
+ PostHogPersistedProperty["BootstrapFeatureFlags"] = "bootstrap_feature_flags";
1948
+ PostHogPersistedProperty["BootstrapFeatureFlagPayloads"] = "bootstrap_feature_flag_payloads";
1949
+ PostHogPersistedProperty["OverrideFeatureFlags"] = "override_feature_flags";
1950
+ PostHogPersistedProperty["Queue"] = "queue";
1951
+ PostHogPersistedProperty["LogsQueue"] = "logs_queue";
1952
+ PostHogPersistedProperty["OptedOut"] = "opted_out";
1953
+ PostHogPersistedProperty["SessionId"] = "session_id";
1954
+ PostHogPersistedProperty["SessionStartTimestamp"] = "session_start_timestamp";
1955
+ PostHogPersistedProperty["SessionLastTimestamp"] = "session_timestamp";
1956
+ PostHogPersistedProperty["PersonProperties"] = "person_properties";
1957
+ PostHogPersistedProperty["GroupProperties"] = "group_properties";
1958
+ PostHogPersistedProperty["InstalledAppBuild"] = "installed_app_build";
1959
+ PostHogPersistedProperty["InstalledAppVersion"] = "installed_app_version";
1960
+ PostHogPersistedProperty["SessionReplay"] = "session_replay";
1961
+ PostHogPersistedProperty["SessionReplayEventTriggerActivatedSession"] = "session_replay_event_trigger_activated_session";
1962
+ PostHogPersistedProperty["SurveyLastSeenDate"] = "survey_last_seen_date";
1963
+ PostHogPersistedProperty["SurveysSeen"] = "surveys_seen";
1964
+ PostHogPersistedProperty["Surveys"] = "surveys";
1965
+ PostHogPersistedProperty["RemoteConfig"] = "remote_config";
1966
+ PostHogPersistedProperty["FlagsEndpointWasHit"] = "flags_endpoint_was_hit";
1967
+ PostHogPersistedProperty["DeviceId"] = "device_id";
1968
+ return PostHogPersistedProperty;
1969
+ })({});
1970
+
1971
+ // ../../node_modules/@posthog/core/dist/gzip.mjs
1972
+ function isGzipSupported() {
1973
+ return "CompressionStream" in globalThis && "TextEncoder" in globalThis && "Response" in globalThis && "function" == typeof Response.prototype.blob;
1974
+ }
1975
+ var NATIVE_GZIP_VALIDATION_ERROR = "NativeGzipValidationError";
1976
+ var GZIP_MAGIC_FIRST_BYTE = 31;
1977
+ var GZIP_MAGIC_SECOND_BYTE = 139;
1978
+ var GZIP_DEFLATE_METHOD = 8;
1979
+ var hasGzipMagic = (bytes) => bytes.length >= 2 && bytes[0] === GZIP_MAGIC_FIRST_BYTE && bytes[1] === GZIP_MAGIC_SECOND_BYTE;
1980
+ var crc32Table;
1981
+ var getCrc32Table = () => {
1982
+ if (crc32Table) return crc32Table;
1983
+ crc32Table = [];
1984
+ for (let i2 = 0; i2 < 256; i2++) {
1985
+ let crc = i2;
1986
+ for (let j = 0; j < 8; j++) crc = 1 & crc ? 3988292384 ^ crc >>> 1 : crc >>> 1;
1987
+ crc32Table[i2] = crc >>> 0;
1988
+ }
1989
+ return crc32Table;
1990
+ };
1991
+ var crc32 = (bytes) => {
1992
+ const table = getCrc32Table();
1993
+ let crc = 4294967295;
1994
+ for (let i2 = 0; i2 < bytes.length; i2++) crc = table[(crc ^ bytes[i2]) & 255] ^ crc >>> 8;
1995
+ return (4294967295 ^ crc) >>> 0;
1996
+ };
1997
+ var throwNativeGzipValidationError = (reason) => {
1998
+ const error = new Error(`Native gzip produced invalid output: ${reason}`);
1999
+ error.name = NATIVE_GZIP_VALIDATION_ERROR;
2000
+ throw error;
2001
+ };
2002
+ var validateNativeGzip = async (compressed, inputBytes) => {
2003
+ if (compressed.size < 18) throwNativeGzipValidationError("too-short");
2004
+ const header = new Uint8Array(await compressed.slice(0, 10).arrayBuffer());
2005
+ if (!hasGzipMagic(header) || header[2] !== GZIP_DEFLATE_METHOD) throwNativeGzipValidationError("invalid-header");
2006
+ const trailer = new DataView(await compressed.slice(compressed.size - 8).arrayBuffer());
2007
+ if (trailer.getUint32(0, true) !== crc32(inputBytes)) throwNativeGzipValidationError("invalid-crc");
2008
+ const inputSize = inputBytes.length >>> 0;
2009
+ if (trailer.getUint32(4, true) !== inputSize) throwNativeGzipValidationError("invalid-size");
2010
+ };
2011
+ async function gzipCompress(input, isDebug = true, options) {
2012
+ try {
2013
+ const inputBytes = new TextEncoder().encode(input);
2014
+ const compressedStream = new CompressionStream("gzip");
2015
+ const writer = compressedStream.writable.getWriter();
2016
+ const writePromise = writer.write(inputBytes).then(() => writer.close()).catch(async (err) => {
2017
+ try {
2018
+ await writer.abort(err);
2019
+ } catch {
2020
+ }
2021
+ throw err;
2022
+ });
2023
+ const responsePromise = new Response(compressedStream.readable).blob();
2024
+ const [compressed] = await Promise.all([
2025
+ responsePromise,
2026
+ writePromise
2027
+ ]);
2028
+ await validateNativeGzip(compressed, inputBytes);
2029
+ return compressed;
2030
+ } catch (error) {
2031
+ if (options?.rethrow) throw error;
2032
+ if (isDebug) console.error("Failed to gzip compress data", error);
2033
+ return null;
2034
+ }
2035
+ }
2036
+
2037
+ // ../../node_modules/@posthog/core/dist/utils/bot-detection.mjs
2038
+ var DEFAULT_BLOCKED_UA_STRS = [
2039
+ "amazonbot",
2040
+ "amazonproductbot",
2041
+ "app.hypefactors.com",
2042
+ "applebot",
2043
+ "archive.org_bot",
2044
+ "awariobot",
2045
+ "backlinksextendedbot",
2046
+ "baiduspider",
2047
+ "bingbot",
2048
+ "bingpreview",
2049
+ "chrome-lighthouse",
2050
+ "dataforseobot",
2051
+ "deepscan",
2052
+ "duckduckbot",
2053
+ "facebookexternal",
2054
+ "facebookcatalog",
2055
+ "http://yandex.com/bots",
2056
+ "hubspot",
2057
+ "ia_archiver",
2058
+ "leikibot",
2059
+ "linkedinbot",
2060
+ "meta-externalagent",
2061
+ "mj12bot",
2062
+ "msnbot",
2063
+ "nessus",
2064
+ "petalbot",
2065
+ "pinterest",
2066
+ "prerender",
2067
+ "rogerbot",
2068
+ "screaming frog",
2069
+ "sebot-wa",
2070
+ "sitebulb",
2071
+ "slackbot",
2072
+ "slurp",
2073
+ "trendictionbot",
2074
+ "turnitin",
2075
+ "twitterbot",
2076
+ "vercel-screenshot",
2077
+ "vercelbot",
2078
+ "yahoo! slurp",
2079
+ "yandexbot",
2080
+ "zoombot",
2081
+ "bot.htm",
2082
+ "bot.php",
2083
+ "(bot;",
2084
+ "bot/",
2085
+ "crawler",
2086
+ "ahrefsbot",
2087
+ "ahrefssiteaudit",
2088
+ "semrushbot",
2089
+ "siteauditbot",
2090
+ "splitsignalbot",
2091
+ "gptbot",
2092
+ "oai-searchbot",
2093
+ "chatgpt-user",
2094
+ "perplexitybot",
2095
+ "better uptime bot",
2096
+ "sentryuptimebot",
2097
+ "uptimerobot",
2098
+ "headlesschrome",
2099
+ "cypress",
2100
+ "google-hoteladsverifier",
2101
+ "adsbot-google",
2102
+ "apis-google",
2103
+ "duplexweb-google",
2104
+ "feedfetcher-google",
2105
+ "google favicon",
2106
+ "google web preview",
2107
+ "google-read-aloud",
2108
+ "googlebot",
2109
+ "googleother",
2110
+ "google-cloudvertexbot",
2111
+ "googleweblight",
2112
+ "mediapartners-google",
2113
+ "storebot-google",
2114
+ "google-inspectiontool",
2115
+ "bytespider"
2116
+ ];
2117
+ var isBlockedUA = function(ua, customBlockedUserAgents = []) {
2118
+ if (!ua) return false;
2119
+ const uaLower = ua.toLowerCase();
2120
+ return DEFAULT_BLOCKED_UA_STRS.concat(customBlockedUserAgents).some((blockedUA) => {
2121
+ const blockedUaLower = blockedUA.toLowerCase();
2122
+ return -1 !== uaLower.indexOf(blockedUaLower);
2123
+ });
2124
+ };
2125
+
2126
+ // ../../node_modules/@posthog/core/dist/utils/type-utils.mjs
2127
+ var nativeIsArray = Array.isArray;
2128
+ var ObjProto = Object.prototype;
2129
+ var type_utils_hasOwnProperty = ObjProto.hasOwnProperty;
2130
+ var type_utils_toString = ObjProto.toString;
2131
+ var isArray = nativeIsArray || function(obj) {
2132
+ return "[object Array]" === type_utils_toString.call(obj);
2133
+ };
2134
+ var isObject = (x) => x === Object(x) && !isArray(x);
2135
+ var isUndefined = (x) => void 0 === x;
2136
+ var isString = (x) => "[object String]" == type_utils_toString.call(x);
2137
+ var isEmptyString = (x) => isString(x) && 0 === x.trim().length;
2138
+ var isNumber = (x) => "[object Number]" == type_utils_toString.call(x) && x === x;
2139
+ var isPlainError = (x) => x instanceof Error;
2140
+ function isPrimitive(value) {
2141
+ return null === value || "object" != typeof value;
2142
+ }
2143
+ function isBuiltin(candidate, className) {
2144
+ return Object.prototype.toString.call(candidate) === `[object ${className}]`;
2145
+ }
2146
+ function isErrorEvent(event) {
2147
+ return isBuiltin(event, "ErrorEvent");
2148
+ }
2149
+ function isEvent(candidate) {
2150
+ return "undefined" != typeof Event && isInstanceOf(candidate, Event);
2151
+ }
2152
+ function isPlainObject2(candidate) {
2153
+ return isBuiltin(candidate, "Object");
2154
+ }
2155
+ function isInstanceOf(candidate, base) {
2156
+ try {
2157
+ return candidate instanceof base;
2158
+ } catch {
2159
+ return false;
2160
+ }
2161
+ }
2162
+
2163
+ // ../../node_modules/@posthog/core/dist/utils/number-utils.mjs
2164
+ function clampToRange(value, min, max, logger, fallbackValue) {
2165
+ if (min > max) {
2166
+ logger.warn("min cannot be greater than max.");
2167
+ min = max;
2168
+ }
2169
+ if (isNumber(value)) if (value > max) {
2170
+ logger.warn(" cannot be greater than max: " + max + ". Using max value instead.");
2171
+ return max;
2172
+ } else {
2173
+ if (!(value < min)) return value;
2174
+ logger.warn(" cannot be less than min: " + min + ". Using min value instead.");
2175
+ return min;
2176
+ }
2177
+ logger.warn(" must be a number. using max or fallback. max: " + max + ", fallback: " + fallbackValue);
2178
+ return clampToRange(fallbackValue || max, min, max, logger);
2179
+ }
2180
+
2181
+ // ../../node_modules/@posthog/core/dist/utils/bucketed-rate-limiter.mjs
2182
+ var ONE_DAY_IN_MS = 864e5;
2183
+ var BucketedRateLimiter = class {
2184
+ constructor(options) {
2185
+ this._buckets = {};
2186
+ this._onBucketRateLimited = options._onBucketRateLimited;
2187
+ this._bucketSize = clampToRange(options.bucketSize, 0, 100, options._logger);
2188
+ this._refillRate = clampToRange(options.refillRate, 0, this._bucketSize, options._logger);
2189
+ this._refillInterval = clampToRange(options.refillInterval, 0, ONE_DAY_IN_MS, options._logger);
2190
+ }
2191
+ _applyRefill(bucket, now) {
2192
+ const elapsedMs = now - bucket.lastAccess;
2193
+ const refillIntervals = Math.floor(elapsedMs / this._refillInterval);
2194
+ if (refillIntervals > 0) {
2195
+ const tokensToAdd = refillIntervals * this._refillRate;
2196
+ bucket.tokens = Math.min(bucket.tokens + tokensToAdd, this._bucketSize);
2197
+ bucket.lastAccess = bucket.lastAccess + refillIntervals * this._refillInterval;
2198
+ }
2199
+ }
2200
+ consumeRateLimit(key) {
2201
+ const now = Date.now();
2202
+ const keyStr = String(key);
2203
+ let bucket = this._buckets[keyStr];
2204
+ if (bucket) this._applyRefill(bucket, now);
2205
+ else {
2206
+ bucket = {
2207
+ tokens: this._bucketSize,
2208
+ lastAccess: now
2209
+ };
2210
+ this._buckets[keyStr] = bucket;
2211
+ }
2212
+ if (0 === bucket.tokens) return true;
2213
+ bucket.tokens--;
2214
+ if (0 === bucket.tokens) this._onBucketRateLimited?.(key);
2215
+ return 0 === bucket.tokens;
2216
+ }
2217
+ stop() {
2218
+ this._buckets = {};
2219
+ }
2220
+ };
2221
+
2222
+ // ../../node_modules/@posthog/core/dist/vendor/uuidv7.mjs
2223
+ var DIGITS = "0123456789abcdef";
2224
+ var UUID = class _UUID {
2225
+ constructor(bytes) {
2226
+ this.bytes = bytes;
2227
+ }
2228
+ static ofInner(bytes) {
2229
+ if (16 === bytes.length) return new _UUID(bytes);
2230
+ throw new TypeError("not 128-bit length");
2231
+ }
2232
+ static fromFieldsV7(unixTsMs, randA, randBHi, randBLo) {
2233
+ if (!Number.isInteger(unixTsMs) || !Number.isInteger(randA) || !Number.isInteger(randBHi) || !Number.isInteger(randBLo) || unixTsMs < 0 || randA < 0 || randBHi < 0 || randBLo < 0 || unixTsMs > 281474976710655 || randA > 4095 || randBHi > 1073741823 || randBLo > 4294967295) throw new RangeError("invalid field value");
2234
+ const bytes = new Uint8Array(16);
2235
+ bytes[0] = unixTsMs / 2 ** 40;
2236
+ bytes[1] = unixTsMs / 2 ** 32;
2237
+ bytes[2] = unixTsMs / 2 ** 24;
2238
+ bytes[3] = unixTsMs / 2 ** 16;
2239
+ bytes[4] = unixTsMs / 256;
2240
+ bytes[5] = unixTsMs;
2241
+ bytes[6] = 112 | randA >>> 8;
2242
+ bytes[7] = randA;
2243
+ bytes[8] = 128 | randBHi >>> 24;
2244
+ bytes[9] = randBHi >>> 16;
2245
+ bytes[10] = randBHi >>> 8;
2246
+ bytes[11] = randBHi;
2247
+ bytes[12] = randBLo >>> 24;
2248
+ bytes[13] = randBLo >>> 16;
2249
+ bytes[14] = randBLo >>> 8;
2250
+ bytes[15] = randBLo;
2251
+ return new _UUID(bytes);
2252
+ }
2253
+ static parse(uuid) {
2254
+ let hex;
2255
+ switch (uuid.length) {
2256
+ case 32:
2257
+ hex = /^[0-9a-f]{32}$/i.exec(uuid)?.[0];
2258
+ break;
2259
+ case 36:
2260
+ hex = /^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(uuid)?.slice(1, 6).join("");
2261
+ break;
2262
+ case 38:
2263
+ hex = /^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(uuid)?.slice(1, 6).join("");
2264
+ break;
2265
+ case 45:
2266
+ hex = /^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(uuid)?.slice(1, 6).join("");
2267
+ break;
2268
+ default:
2269
+ break;
2270
+ }
2271
+ if (hex) {
2272
+ const inner = new Uint8Array(16);
2273
+ for (let i2 = 0; i2 < 16; i2 += 4) {
2274
+ const n2 = parseInt(hex.substring(2 * i2, 2 * i2 + 8), 16);
2275
+ inner[i2 + 0] = n2 >>> 24;
2276
+ inner[i2 + 1] = n2 >>> 16;
2277
+ inner[i2 + 2] = n2 >>> 8;
2278
+ inner[i2 + 3] = n2;
2279
+ }
2280
+ return new _UUID(inner);
2281
+ }
2282
+ throw new SyntaxError("could not parse UUID string");
2283
+ }
2284
+ toString() {
2285
+ let text2 = "";
2286
+ for (let i2 = 0; i2 < this.bytes.length; i2++) {
2287
+ text2 += DIGITS.charAt(this.bytes[i2] >>> 4);
2288
+ text2 += DIGITS.charAt(15 & this.bytes[i2]);
2289
+ if (3 === i2 || 5 === i2 || 7 === i2 || 9 === i2) text2 += "-";
2290
+ }
2291
+ return text2;
2292
+ }
2293
+ toHex() {
2294
+ let text2 = "";
2295
+ for (let i2 = 0; i2 < this.bytes.length; i2++) {
2296
+ text2 += DIGITS.charAt(this.bytes[i2] >>> 4);
2297
+ text2 += DIGITS.charAt(15 & this.bytes[i2]);
2298
+ }
2299
+ return text2;
2300
+ }
2301
+ toJSON() {
2302
+ return this.toString();
2303
+ }
2304
+ getVariant() {
2305
+ const n2 = this.bytes[8] >>> 4;
2306
+ if (n2 < 0) throw new Error("unreachable");
2307
+ if (n2 <= 7) return this.bytes.every((e) => 0 === e) ? "NIL" : "VAR_0";
2308
+ if (n2 <= 11) return "VAR_10";
2309
+ if (n2 <= 13) return "VAR_110";
2310
+ if (n2 <= 15) return this.bytes.every((e) => 255 === e) ? "MAX" : "VAR_RESERVED";
2311
+ else throw new Error("unreachable");
2312
+ }
2313
+ getVersion() {
2314
+ return "VAR_10" === this.getVariant() ? this.bytes[6] >>> 4 : void 0;
2315
+ }
2316
+ clone() {
2317
+ return new _UUID(this.bytes.slice(0));
2318
+ }
2319
+ equals(other) {
2320
+ return 0 === this.compareTo(other);
2321
+ }
2322
+ compareTo(other) {
2323
+ for (let i2 = 0; i2 < 16; i2++) {
2324
+ const diff = this.bytes[i2] - other.bytes[i2];
2325
+ if (0 !== diff) return Math.sign(diff);
2326
+ }
2327
+ return 0;
2328
+ }
2329
+ };
2330
+ var V7Generator = class {
2331
+ constructor(randomNumberGenerator) {
2332
+ this.timestamp = 0;
2333
+ this.counter = 0;
2334
+ this.random = randomNumberGenerator ?? getDefaultRandom();
2335
+ }
2336
+ generate() {
2337
+ return this.generateOrResetCore(Date.now(), 1e4);
2338
+ }
2339
+ generateOrAbort() {
2340
+ return this.generateOrAbortCore(Date.now(), 1e4);
2341
+ }
2342
+ generateOrResetCore(unixTsMs, rollbackAllowance) {
2343
+ let value = this.generateOrAbortCore(unixTsMs, rollbackAllowance);
2344
+ if (void 0 === value) {
2345
+ this.timestamp = 0;
2346
+ value = this.generateOrAbortCore(unixTsMs, rollbackAllowance);
2347
+ }
2348
+ return value;
2349
+ }
2350
+ generateOrAbortCore(unixTsMs, rollbackAllowance) {
2351
+ const MAX_COUNTER = 4398046511103;
2352
+ if (!Number.isInteger(unixTsMs) || unixTsMs < 1 || unixTsMs > 281474976710655) throw new RangeError("`unixTsMs` must be a 48-bit positive integer");
2353
+ if (rollbackAllowance < 0 || rollbackAllowance > 281474976710655) throw new RangeError("`rollbackAllowance` out of reasonable range");
2354
+ if (unixTsMs > this.timestamp) {
2355
+ this.timestamp = unixTsMs;
2356
+ this.resetCounter();
2357
+ } else {
2358
+ if (!(unixTsMs + rollbackAllowance >= this.timestamp)) return;
2359
+ this.counter++;
2360
+ if (this.counter > MAX_COUNTER) {
2361
+ this.timestamp++;
2362
+ this.resetCounter();
2363
+ }
2364
+ }
2365
+ return UUID.fromFieldsV7(this.timestamp, Math.trunc(this.counter / 2 ** 30), this.counter & 2 ** 30 - 1, this.random.nextUint32());
2366
+ }
2367
+ resetCounter() {
2368
+ this.counter = 1024 * this.random.nextUint32() + (1023 & this.random.nextUint32());
2369
+ }
2370
+ generateV4() {
2371
+ const bytes = new Uint8Array(Uint32Array.of(this.random.nextUint32(), this.random.nextUint32(), this.random.nextUint32(), this.random.nextUint32()).buffer);
2372
+ bytes[6] = 64 | bytes[6] >>> 4;
2373
+ bytes[8] = 128 | bytes[8] >>> 2;
2374
+ return UUID.ofInner(bytes);
2375
+ }
2376
+ };
2377
+ var getDefaultRandom = () => ({
2378
+ nextUint32: () => 65536 * Math.trunc(65536 * Math.random()) + Math.trunc(65536 * Math.random())
2379
+ });
2380
+ var defaultGenerator;
2381
+ var uuidv7 = () => uuidv7obj().toString();
2382
+ var uuidv7obj = () => (defaultGenerator || (defaultGenerator = new V7Generator())).generate();
2383
+
2384
+ // ../../node_modules/@posthog/core/dist/utils/promise-queue.mjs
2385
+ var PromiseQueue = class {
2386
+ add(promise) {
2387
+ const promiseUUID = uuidv7();
2388
+ this.promiseByIds[promiseUUID] = promise;
2389
+ promise.catch(() => {
2390
+ }).finally(() => {
2391
+ delete this.promiseByIds[promiseUUID];
2392
+ });
2393
+ return promise;
2394
+ }
2395
+ async join() {
2396
+ let promises = Object.values(this.promiseByIds);
2397
+ let length = promises.length;
2398
+ while (length > 0) {
2399
+ await Promise.all(promises);
2400
+ promises = Object.values(this.promiseByIds);
2401
+ length = promises.length;
2402
+ }
2403
+ }
2404
+ get length() {
2405
+ return Object.keys(this.promiseByIds).length;
2406
+ }
2407
+ constructor() {
2408
+ this.promiseByIds = {};
2409
+ }
2410
+ };
2411
+
2412
+ // ../../node_modules/@posthog/core/dist/utils/logger.mjs
2413
+ function createConsole(consoleLike = console) {
2414
+ const lockedMethods = {
2415
+ log: consoleLike.log.bind(consoleLike),
2416
+ warn: consoleLike.warn.bind(consoleLike),
2417
+ error: consoleLike.error.bind(consoleLike),
2418
+ debug: consoleLike.debug.bind(consoleLike)
2419
+ };
2420
+ return lockedMethods;
2421
+ }
2422
+ var _createLogger = (prefix, maybeCall, consoleLike) => {
2423
+ function _log(level, ...args) {
2424
+ maybeCall(() => {
2425
+ const consoleMethod = consoleLike[level];
2426
+ consoleMethod(prefix, ...args);
2427
+ });
2428
+ }
2429
+ const logger = {
2430
+ debug: (...args) => {
2431
+ _log("debug", ...args);
2432
+ },
2433
+ info: (...args) => {
2434
+ _log("log", ...args);
2435
+ },
2436
+ warn: (...args) => {
2437
+ _log("warn", ...args);
2438
+ },
2439
+ error: (...args) => {
2440
+ _log("error", ...args);
2441
+ },
2442
+ critical: (...args) => {
2443
+ consoleLike["error"](prefix, ...args);
2444
+ },
2445
+ createLogger: (additionalPrefix) => _createLogger(`${prefix} ${additionalPrefix}`, maybeCall, consoleLike)
2446
+ };
2447
+ return logger;
2448
+ };
2449
+ var passThrough = (fn) => fn();
2450
+ function createLogger(prefix, maybeCall = passThrough) {
2451
+ return _createLogger(prefix, maybeCall, createConsole());
2452
+ }
2453
+
2454
+ // ../../node_modules/@posthog/core/dist/utils/user-agent-utils.mjs
2455
+ var MOBILE = "Mobile";
2456
+ var IOS = "iOS";
2457
+ var ANDROID = "Android";
2458
+ var TABLET = "Tablet";
2459
+ var ANDROID_TABLET = ANDROID + " " + TABLET;
2460
+ var APPLE = "Apple";
2461
+ var APPLE_WATCH = APPLE + " Watch";
2462
+ var SAFARI = "Safari";
2463
+ var BLACKBERRY = "BlackBerry";
2464
+ var SAMSUNG = "Samsung";
2465
+ var SAMSUNG_BROWSER = SAMSUNG + "Browser";
2466
+ var SAMSUNG_INTERNET = SAMSUNG + " Internet";
2467
+ var CHROME = "Chrome";
2468
+ var CHROME_OS = CHROME + " OS";
2469
+ var CHROME_IOS = CHROME + " " + IOS;
2470
+ var INTERNET_EXPLORER = "Internet Explorer";
2471
+ var INTERNET_EXPLORER_MOBILE = INTERNET_EXPLORER + " " + MOBILE;
2472
+ var OPERA = "Opera";
2473
+ var OPERA_MINI = OPERA + " Mini";
2474
+ var EDGE = "Edge";
2475
+ var MICROSOFT_EDGE = "Microsoft " + EDGE;
2476
+ var FIREFOX = "Firefox";
2477
+ var FIREFOX_IOS = FIREFOX + " " + IOS;
2478
+ var NINTENDO = "Nintendo";
2479
+ var PLAYSTATION = "PlayStation";
2480
+ var XBOX = "Xbox";
2481
+ var ANDROID_MOBILE = ANDROID + " " + MOBILE;
2482
+ var MOBILE_SAFARI = MOBILE + " " + SAFARI;
2483
+ var WINDOWS = "Windows";
2484
+ var WINDOWS_PHONE = WINDOWS + " Phone";
2485
+ var GENERIC = "Generic";
2486
+ var GENERIC_MOBILE = GENERIC + " " + MOBILE.toLowerCase();
2487
+ var GENERIC_TABLET = GENERIC + " " + TABLET.toLowerCase();
2488
+ var KONQUEROR = "Konqueror";
1884
2489
  var OCULUS_BROWSER = "Oculus Browser";
1885
2490
  var VIVALDI = "Vivaldi";
1886
2491
  var YANDEX = "Yandex";
@@ -3959,14 +4564,14 @@ function snipLine(line, colno) {
3959
4564
  }
3960
4565
 
3961
4566
  // ../../node_modules/posthog-node/dist/extensions/error-tracking/modifiers/relative-path.node.mjs
3962
- import { isAbsolute as isAbsolute3, relative as relative2, sep as sep3 } from "path";
4567
+ import { isAbsolute as isAbsolute4, relative as relative2, sep as sep4 } from "path";
3963
4568
  function createRelativePathModifier(basePath = process.cwd()) {
3964
- const isWindows = "\\" === sep3;
4569
+ const isWindows = "\\" === sep4;
3965
4570
  const toUnix = (p) => isWindows ? p.replace(/\\/g, "/") : p;
3966
4571
  const normalizedBase = toUnix(basePath);
3967
4572
  return async (frames) => {
3968
4573
  for (const frame of frames) if (!(!frame.filename || frame.filename.startsWith("node:") || frame.filename.startsWith("data:"))) {
3969
- if (isAbsolute3(frame.filename)) frame.filename = toUnix(relative2(normalizedBase, toUnix(frame.filename)));
4574
+ if (isAbsolute4(frame.filename)) frame.filename = toUnix(relative2(normalizedBase, toUnix(frame.filename)));
3970
4575
  }
3971
4576
  return frames;
3972
4577
  };
@@ -5780,7 +6385,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
5780
6385
  };
5781
6386
  const personProperties = {};
5782
6387
  const groupProperties = {};
5783
- for (const [key, value] of Object.entries(eventProperties)) if (isPlainObject(value) && groups && key in groups) {
6388
+ for (const [key, value] of Object.entries(eventProperties)) if (isPlainObject2(value) && groups && key in groups) {
5784
6389
  const groupProps = {};
5785
6390
  for (const [groupKey, groupValue] of Object.entries(value)) groupProps[String(groupKey)] = String(groupValue);
5786
6391
  groupProperties[String(key)] = groupProps;
@@ -6120,8 +6725,8 @@ function resetClient() {
6120
6725
 
6121
6726
  // ../registry/src/artifacts.ts
6122
6727
  import { stat as stat3 } from "node:fs/promises";
6123
- import { randomUUID as randomUUID2 } from "node:crypto";
6124
- import { basename as basename4, extname } from "node:path";
6728
+ import { randomUUID as randomUUID3 } from "node:crypto";
6729
+ import { basename as basename4, extname as extname2 } from "node:path";
6125
6730
 
6126
6731
  // ../registry/src/failure-codes.ts
6127
6732
  var FAILURE_CODES = {
@@ -6306,6 +6911,21 @@ var FAILURE_CODES = {
6306
6911
  NATIVE_PROFILER_PERFETTO_PROCESS_ERROR: "NATIVE_PROFILER_PERFETTO_PROCESS_ERROR",
6307
6912
  NATIVE_PROFILER_PERFETTO_READY_TIMEOUT: "NATIVE_PROFILER_PERFETTO_READY_TIMEOUT",
6308
6913
  NATIVE_PROFILER_PERFETTO_READY_EXITED: "NATIVE_PROFILER_PERFETTO_READY_EXITED",
6914
+ // screen-recording-start / screen-recording-stop. One capture path for every
6915
+ // platform (simulator-server's frame stream into ffmpeg), so the stages name
6916
+ // the step that failed rather than the device family.
6917
+ SCREEN_RECORDING_FACTORY_OPTIONS_MISSING: "SCREEN_RECORDING_FACTORY_OPTIONS_MISSING",
6918
+ SCREEN_RECORDING_WRONG_PLATFORM: "SCREEN_RECORDING_WRONG_PLATFORM",
6919
+ SCREEN_RECORDING_ALREADY_ACTIVE: "SCREEN_RECORDING_ALREADY_ACTIVE",
6920
+ SCREEN_RECORDING_NO_ACTIVE_SESSION: "SCREEN_RECORDING_NO_ACTIVE_SESSION",
6921
+ SCREEN_RECORDING_STOP_IN_PROGRESS: "SCREEN_RECORDING_STOP_IN_PROGRESS",
6922
+ SCREEN_RECORDING_START_EXITED: "SCREEN_RECORDING_START_EXITED",
6923
+ SCREEN_RECORDING_START_TIMEOUT: "SCREEN_RECORDING_START_TIMEOUT",
6924
+ SCREEN_RECORDING_PROCESS_ERROR: "SCREEN_RECORDING_PROCESS_ERROR",
6925
+ SCREEN_RECORDING_OUTPUT_MISSING: "SCREEN_RECORDING_OUTPUT_MISSING",
6926
+ SCREEN_RECORDING_SERVER_SHUTTING_DOWN: "SCREEN_RECORDING_SERVER_SHUTTING_DOWN",
6927
+ SCREEN_RECORDING_STREAM_UNAVAILABLE: "SCREEN_RECORDING_STREAM_UNAVAILABLE",
6928
+ SCREEN_RECORDING_FFMPEG_NOT_FOUND: "SCREEN_RECORDING_FFMPEG_NOT_FOUND",
6309
6929
  FLOW_PROJECT_ROOT_REQUIRED: "FLOW_PROJECT_ROOT_REQUIRED",
6310
6930
  FLOW_PROJECT_ROOT_INVALID: "FLOW_PROJECT_ROOT_INVALID",
6311
6931
  FLOW_NAME_INVALID: "FLOW_NAME_INVALID",
@@ -6377,6 +6997,7 @@ var FAILURE_COMMANDS = [
6377
6997
  "android_devtools",
6378
6998
  "ax_service",
6379
6999
  "simulator_server",
7000
+ "ffmpeg",
6380
7001
  "cdp",
6381
7002
  "electron",
6382
7003
  "npm",
@@ -6409,7 +7030,7 @@ var FAILURE_SIGNAL_NAME_SET = new Set(FAILURE_SIGNAL_NAMES);
6409
7030
  var FAILURE_SPAWN_CODE_SET = new Set(FAILURE_SPAWN_CODES);
6410
7031
 
6411
7032
  // ../registry/src/registry.ts
6412
- import { randomUUID as randomUUID3 } from "node:crypto";
7033
+ import { randomUUID as randomUUID4 } from "node:crypto";
6413
7034
 
6414
7035
  // ../telemetry/src/events.ts
6415
7036
  var PLATFORMS = [
@@ -6620,7 +7241,7 @@ var ALLOWED = {
6620
7241
  },
6621
7242
  "toolserver:start": {},
6622
7243
  "toolserver:stop": {
6623
- reason: oneOf(["idle", "signal", "crash"]),
7244
+ reason: oneOf(["idle", "signal", "crash", "deferred"]),
6624
7245
  uptime_ms: DURATION_MS,
6625
7246
  total_tool_calls: COUNT,
6626
7247
  ...FAILURE_SIGNAL,
@@ -6677,10 +7298,10 @@ function sanitize(event, raw) {
6677
7298
  }
6678
7299
 
6679
7300
  // ../telemetry/src/base-props.ts
6680
- import { randomUUID as randomUUID4 } from "node:crypto";
7301
+ import { randomUUID as randomUUID5 } from "node:crypto";
6681
7302
 
6682
7303
  // ../telemetry/src/cloud-agent-detect.ts
6683
- import { existsSync as existsSync2 } from "node:fs";
7304
+ import { existsSync as existsSync3 } from "node:fs";
6684
7305
  var CLAUDE_CLOUD_ENV_KINDS = /* @__PURE__ */ new Set(["byoc", "anthropic_cloud"]);
6685
7306
  var CLAUDE_REMOTE_ENTRYPOINTS = /* @__PURE__ */ new Set([
6686
7307
  "remote",
@@ -6715,949 +7336,464 @@ function safeExists(fileExists, path15) {
6715
7336
  try {
6716
7337
  return fileExists(path15);
6717
7338
  } catch {
6718
- return false;
6719
- }
6720
- }
6721
- function detectCloudAgent(env = process.env, opts = {}) {
6722
- if (isClaudeCodeCloud(env)) return "claude_code";
6723
- if (isCursorCloud(env)) return "cursor";
6724
- if (isCopilotAgent(env)) return "copilot";
6725
- if (isReplitAgent(env)) return "replit";
6726
- const fileExists = opts.fileExists ?? existsSync2;
6727
- if (safeExists(fileExists, DEVIN_MARKER_PATH)) return "devin";
6728
- if (safeExists(fileExists, JULES_MARKER_PATH)) return "jules";
6729
- return null;
6730
- }
6731
-
6732
- // ../../node_modules/ci-info/vendors.json
6733
- var vendors_default = [
6734
- {
6735
- name: "Agola CI",
6736
- constant: "AGOLA",
6737
- env: "AGOLA_GIT_REF",
6738
- pr: "AGOLA_PULL_REQUEST_ID"
6739
- },
6740
- {
6741
- name: "Alpic",
6742
- constant: "ALPIC",
6743
- env: "ALPIC_HOST"
6744
- },
6745
- {
6746
- name: "Appcircle",
6747
- constant: "APPCIRCLE",
6748
- env: "AC_APPCIRCLE",
6749
- pr: {
6750
- env: "AC_GIT_PR",
6751
- ne: "false"
6752
- }
6753
- },
6754
- {
6755
- name: "AppVeyor",
6756
- constant: "APPVEYOR",
6757
- env: "APPVEYOR",
6758
- pr: "APPVEYOR_PULL_REQUEST_NUMBER"
6759
- },
6760
- {
6761
- name: "AWS CodeBuild",
6762
- constant: "CODEBUILD",
6763
- env: "CODEBUILD_BUILD_ARN",
6764
- pr: {
6765
- env: "CODEBUILD_WEBHOOK_EVENT",
6766
- any: [
6767
- "PULL_REQUEST_CREATED",
6768
- "PULL_REQUEST_UPDATED",
6769
- "PULL_REQUEST_REOPENED"
6770
- ]
6771
- }
6772
- },
6773
- {
6774
- name: "Azure Pipelines",
6775
- constant: "AZURE_PIPELINES",
6776
- env: "TF_BUILD",
6777
- pr: {
6778
- BUILD_REASON: "PullRequest"
6779
- }
6780
- },
6781
- {
6782
- name: "Bamboo",
6783
- constant: "BAMBOO",
6784
- env: "bamboo_planKey"
6785
- },
6786
- {
6787
- name: "Bitbucket Pipelines",
6788
- constant: "BITBUCKET",
6789
- env: "BITBUCKET_COMMIT",
6790
- pr: "BITBUCKET_PR_ID"
6791
- },
6792
- {
6793
- name: "Bitrise",
6794
- constant: "BITRISE",
6795
- env: "BITRISE_IO",
6796
- pr: "BITRISE_PULL_REQUEST"
6797
- },
6798
- {
6799
- name: "Buddy",
6800
- constant: "BUDDY",
6801
- env: "BUDDY_WORKSPACE_ID",
6802
- pr: "BUDDY_EXECUTION_PULL_REQUEST_ID"
6803
- },
6804
- {
6805
- name: "Buildkite",
6806
- constant: "BUILDKITE",
6807
- env: "BUILDKITE",
6808
- pr: {
6809
- env: "BUILDKITE_PULL_REQUEST",
6810
- ne: "false"
6811
- }
6812
- },
6813
- {
6814
- name: "CircleCI",
6815
- constant: "CIRCLE",
6816
- env: "CIRCLECI",
6817
- pr: "CIRCLE_PULL_REQUEST"
6818
- },
6819
- {
6820
- name: "Cirrus CI",
6821
- constant: "CIRRUS",
6822
- env: "CIRRUS_CI",
6823
- pr: "CIRRUS_PR"
6824
- },
6825
- {
6826
- name: "Cloudflare Pages",
6827
- constant: "CLOUDFLARE_PAGES",
6828
- env: "CF_PAGES"
6829
- },
6830
- {
6831
- name: "Cloudflare Workers",
6832
- constant: "CLOUDFLARE_WORKERS",
6833
- env: "WORKERS_CI"
6834
- },
6835
- {
6836
- name: "Codefresh",
6837
- constant: "CODEFRESH",
6838
- env: "CF_BUILD_ID",
6839
- pr: {
6840
- any: [
6841
- "CF_PULL_REQUEST_NUMBER",
6842
- "CF_PULL_REQUEST_ID"
6843
- ]
6844
- }
6845
- },
6846
- {
6847
- name: "Codemagic",
6848
- constant: "CODEMAGIC",
6849
- env: "CM_BUILD_ID",
6850
- pr: "CM_PULL_REQUEST"
6851
- },
6852
- {
6853
- name: "Codeship",
6854
- constant: "CODESHIP",
6855
- env: {
6856
- CI_NAME: "codeship"
6857
- }
6858
- },
6859
- {
6860
- name: "Drone",
6861
- constant: "DRONE",
6862
- env: "DRONE",
6863
- pr: {
6864
- DRONE_BUILD_EVENT: "pull_request"
6865
- }
6866
- },
6867
- {
6868
- name: "dsari",
6869
- constant: "DSARI",
6870
- env: "DSARI"
6871
- },
6872
- {
6873
- name: "Earthly",
6874
- constant: "EARTHLY",
6875
- env: "EARTHLY_CI"
6876
- },
6877
- {
6878
- name: "Expo Application Services",
6879
- constant: "EAS",
6880
- env: "EAS_BUILD"
6881
- },
6882
- {
6883
- name: "Gerrit",
6884
- constant: "GERRIT",
6885
- env: "GERRIT_PROJECT"
6886
- },
6887
- {
6888
- name: "Gitea Actions",
6889
- constant: "GITEA_ACTIONS",
6890
- env: "GITEA_ACTIONS"
6891
- },
6892
- {
6893
- name: "GitHub Actions",
6894
- constant: "GITHUB_ACTIONS",
6895
- env: "GITHUB_ACTIONS",
6896
- pr: {
6897
- GITHUB_EVENT_NAME: "pull_request"
6898
- }
6899
- },
6900
- {
6901
- name: "GitLab CI",
6902
- constant: "GITLAB",
6903
- env: "GITLAB_CI",
6904
- pr: "CI_MERGE_REQUEST_ID"
6905
- },
6906
- {
6907
- name: "GoCD",
6908
- constant: "GOCD",
6909
- env: "GO_PIPELINE_LABEL"
6910
- },
6911
- {
6912
- name: "Google Cloud Build",
6913
- constant: "GOOGLE_CLOUD_BUILD",
6914
- env: "BUILDER_OUTPUT"
6915
- },
6916
- {
6917
- name: "Harness CI",
6918
- constant: "HARNESS",
6919
- env: "HARNESS_BUILD_ID"
6920
- },
6921
- {
6922
- name: "Heroku",
6923
- constant: "HEROKU",
6924
- env: {
6925
- env: "NODE",
6926
- includes: "/app/.heroku/node/bin/node"
6927
- }
6928
- },
6929
- {
6930
- name: "Hudson",
6931
- constant: "HUDSON",
6932
- env: "HUDSON_URL"
6933
- },
6934
- {
6935
- name: "Jenkins",
6936
- constant: "JENKINS",
6937
- env: [
6938
- "JENKINS_URL",
6939
- "BUILD_ID"
6940
- ],
6941
- pr: {
6942
- any: [
6943
- "ghprbPullId",
6944
- "CHANGE_ID"
6945
- ]
6946
- }
6947
- },
6948
- {
6949
- name: "LayerCI",
6950
- constant: "LAYERCI",
6951
- env: "LAYERCI",
6952
- pr: "LAYERCI_PULL_REQUEST"
6953
- },
7339
+ return false;
7340
+ }
7341
+ }
7342
+ function detectCloudAgent(env = process.env, opts = {}) {
7343
+ if (isClaudeCodeCloud(env)) return "claude_code";
7344
+ if (isCursorCloud(env)) return "cursor";
7345
+ if (isCopilotAgent(env)) return "copilot";
7346
+ if (isReplitAgent(env)) return "replit";
7347
+ const fileExists = opts.fileExists ?? existsSync3;
7348
+ if (safeExists(fileExists, DEVIN_MARKER_PATH)) return "devin";
7349
+ if (safeExists(fileExists, JULES_MARKER_PATH)) return "jules";
7350
+ return null;
7351
+ }
7352
+
7353
+ // ../../node_modules/ci-info/vendors.json
7354
+ var vendors_default = [
6954
7355
  {
6955
- name: "Magnum CI",
6956
- constant: "MAGNUM",
6957
- env: "MAGNUM"
7356
+ name: "Agola CI",
7357
+ constant: "AGOLA",
7358
+ env: "AGOLA_GIT_REF",
7359
+ pr: "AGOLA_PULL_REQUEST_ID"
6958
7360
  },
6959
7361
  {
6960
- name: "Netlify CI",
6961
- constant: "NETLIFY",
6962
- env: "NETLIFY",
6963
- pr: {
6964
- env: "PULL_REQUEST",
6965
- ne: "false"
6966
- }
7362
+ name: "Alpic",
7363
+ constant: "ALPIC",
7364
+ env: "ALPIC_HOST"
6967
7365
  },
6968
7366
  {
6969
- name: "Nevercode",
6970
- constant: "NEVERCODE",
6971
- env: "NEVERCODE",
7367
+ name: "Appcircle",
7368
+ constant: "APPCIRCLE",
7369
+ env: "AC_APPCIRCLE",
6972
7370
  pr: {
6973
- env: "NEVERCODE_PULL_REQUEST",
7371
+ env: "AC_GIT_PR",
6974
7372
  ne: "false"
6975
7373
  }
6976
7374
  },
6977
7375
  {
6978
- name: "Prow",
6979
- constant: "PROW",
6980
- env: "PROW_JOB_ID"
6981
- },
6982
- {
6983
- name: "ReleaseHub",
6984
- constant: "RELEASEHUB",
6985
- env: "RELEASE_BUILD_ID"
7376
+ name: "AppVeyor",
7377
+ constant: "APPVEYOR",
7378
+ env: "APPVEYOR",
7379
+ pr: "APPVEYOR_PULL_REQUEST_NUMBER"
6986
7380
  },
6987
7381
  {
6988
- name: "Render",
6989
- constant: "RENDER",
6990
- env: "RENDER",
7382
+ name: "AWS CodeBuild",
7383
+ constant: "CODEBUILD",
7384
+ env: "CODEBUILD_BUILD_ARN",
6991
7385
  pr: {
6992
- IS_PULL_REQUEST: "true"
7386
+ env: "CODEBUILD_WEBHOOK_EVENT",
7387
+ any: [
7388
+ "PULL_REQUEST_CREATED",
7389
+ "PULL_REQUEST_UPDATED",
7390
+ "PULL_REQUEST_REOPENED"
7391
+ ]
6993
7392
  }
6994
7393
  },
6995
7394
  {
6996
- name: "Sail CI",
6997
- constant: "SAIL",
6998
- env: "SAILCI",
6999
- pr: "SAIL_PULL_REQUEST_NUMBER"
7000
- },
7001
- {
7002
- name: "Screwdriver",
7003
- constant: "SCREWDRIVER",
7004
- env: "SCREWDRIVER",
7395
+ name: "Azure Pipelines",
7396
+ constant: "AZURE_PIPELINES",
7397
+ env: "TF_BUILD",
7005
7398
  pr: {
7006
- env: "SD_PULL_REQUEST",
7007
- ne: "false"
7399
+ BUILD_REASON: "PullRequest"
7008
7400
  }
7009
7401
  },
7010
7402
  {
7011
- name: "Semaphore",
7012
- constant: "SEMAPHORE",
7013
- env: "SEMAPHORE",
7014
- pr: "PULL_REQUEST_NUMBER"
7015
- },
7016
- {
7017
- name: "Sourcehut",
7018
- constant: "SOURCEHUT",
7019
- env: {
7020
- CI_NAME: "sourcehut"
7021
- }
7403
+ name: "Bamboo",
7404
+ constant: "BAMBOO",
7405
+ env: "bamboo_planKey"
7022
7406
  },
7023
7407
  {
7024
- name: "Strider CD",
7025
- constant: "STRIDER",
7026
- env: "STRIDER"
7408
+ name: "Bitbucket Pipelines",
7409
+ constant: "BITBUCKET",
7410
+ env: "BITBUCKET_COMMIT",
7411
+ pr: "BITBUCKET_PR_ID"
7027
7412
  },
7028
7413
  {
7029
- name: "TaskCluster",
7030
- constant: "TASKCLUSTER",
7031
- env: [
7032
- "TASK_ID",
7033
- "RUN_ID"
7034
- ]
7414
+ name: "Bitrise",
7415
+ constant: "BITRISE",
7416
+ env: "BITRISE_IO",
7417
+ pr: "BITRISE_PULL_REQUEST"
7035
7418
  },
7036
7419
  {
7037
- name: "TeamCity",
7038
- constant: "TEAMCITY",
7039
- env: "TEAMCITY_VERSION"
7420
+ name: "Buddy",
7421
+ constant: "BUDDY",
7422
+ env: "BUDDY_WORKSPACE_ID",
7423
+ pr: "BUDDY_EXECUTION_PULL_REQUEST_ID"
7040
7424
  },
7041
7425
  {
7042
- name: "Travis CI",
7043
- constant: "TRAVIS",
7044
- env: "TRAVIS",
7426
+ name: "Buildkite",
7427
+ constant: "BUILDKITE",
7428
+ env: "BUILDKITE",
7045
7429
  pr: {
7046
- env: "TRAVIS_PULL_REQUEST",
7430
+ env: "BUILDKITE_PULL_REQUEST",
7047
7431
  ne: "false"
7048
7432
  }
7049
7433
  },
7050
7434
  {
7051
- name: "Vela",
7052
- constant: "VELA",
7053
- env: "VELA",
7054
- pr: {
7055
- VELA_PULL_REQUEST: "1"
7056
- }
7057
- },
7058
- {
7059
- name: "Vercel",
7060
- constant: "VERCEL",
7061
- env: {
7062
- any: [
7063
- "NOW_BUILDER",
7064
- "VERCEL"
7065
- ]
7066
- },
7067
- pr: "VERCEL_GIT_PULL_REQUEST_ID"
7068
- },
7069
- {
7070
- name: "Visual Studio App Center",
7071
- constant: "APPCENTER",
7072
- env: "APPCENTER_BUILD_ID"
7073
- },
7074
- {
7075
- name: "Woodpecker",
7076
- constant: "WOODPECKER",
7077
- env: {
7078
- CI: "woodpecker"
7079
- },
7080
- pr: {
7081
- CI_BUILD_EVENT: "pull_request"
7082
- }
7083
- },
7084
- {
7085
- name: "Xcode Cloud",
7086
- constant: "XCODE_CLOUD",
7087
- env: "CI_XCODE_PROJECT",
7088
- pr: "CI_PULL_REQUEST_NUMBER"
7089
- },
7090
- {
7091
- name: "Xcode Server",
7092
- constant: "XCODE_SERVER",
7093
- env: "XCS"
7094
- }
7095
- ];
7096
-
7097
- // ../telemetry/src/ci-detect.ts
7098
- var GENERIC_CI_ENV_VARS = [
7099
- "BUILD_ID",
7100
- "BUILD_NUMBER",
7101
- "CI",
7102
- "CI_APP_ID",
7103
- "CI_BUILD_ID",
7104
- "CI_BUILD_NUMBER",
7105
- "CI_NAME",
7106
- "CONTINUOUS_INTEGRATION",
7107
- "RUN_ID"
7108
- ];
7109
- function checkEnv(env, def) {
7110
- if (typeof def === "string") return Boolean(env[def]);
7111
- if ("env" in def) {
7112
- const value = env[def.env];
7113
- return Boolean(value && value.includes(def.includes));
7114
- }
7115
- if ("any" in def && Array.isArray(def.any)) {
7116
- return def.any.some((key) => Boolean(env[key]));
7117
- }
7118
- return Object.entries(def).every(([key, value]) => env[key] === value);
7119
- }
7120
- function isKnownVendorCi(env) {
7121
- return vendors_default.some((vendor) => {
7122
- const defs = Array.isArray(vendor.env) ? vendor.env : [vendor.env];
7123
- return defs.every((def) => checkEnv(env, def));
7124
- });
7125
- }
7126
- function isCi(env = process.env) {
7127
- if (env.CI === "false") return false;
7128
- if (GENERIC_CI_ENV_VARS.some((name) => Boolean(env[name]))) return true;
7129
- return isKnownVendorCi(env);
7130
- }
7131
- var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
7132
-
7133
- // ../telemetry/src/base-props.ts
7134
- var SESSION_ID2 = randomUUID4();
7135
- function readCliVersion() {
7136
- if (true) {
7137
- return "0.16.1";
7138
- }
7139
- return "0.0.0";
7140
- }
7141
- function readNodeVersionMajor() {
7142
- const m = /^v?(\d+)/.exec(process.version);
7143
- return m ? m[1] : "unknown";
7144
- }
7145
- var invariantProps = null;
7146
- function getInvariantProps() {
7147
- if (!invariantProps) {
7148
- invariantProps = {
7149
- cli_version: readCliVersion(),
7150
- node_version_major: readNodeVersionMajor(),
7151
- os: process.platform,
7152
- arch: process.arch,
7153
- is_tty: Boolean(process.stdout.isTTY),
7154
- is_ci: isCi(),
7155
- cloud_agent: detectCloudAgent(),
7156
- $process_person_profile: false
7157
- };
7158
- }
7159
- return invariantProps;
7160
- }
7161
- function getBaseProps(runtime) {
7162
- return {
7163
- ...getInvariantProps(),
7164
- runtime,
7165
- $session_id: SESSION_ID2
7166
- };
7167
- }
7168
-
7169
- // ../telemetry/src/identity.ts
7170
- import * as crypto2 from "node:crypto";
7171
- import * as fs4 from "node:fs";
7172
- import * as path8 from "node:path";
7173
-
7174
- // ../telemetry/src/paths.ts
7175
- import * as path7 from "node:path";
7176
-
7177
- // ../configuration-core/src/flags.ts
7178
- import * as fs2 from "node:fs";
7179
- import * as path4 from "node:path";
7180
- import { homedir as homedir3 } from "node:os";
7181
- var FLAG_REGISTRY = [
7435
+ name: "CircleCI",
7436
+ constant: "CIRCLE",
7437
+ env: "CIRCLECI",
7438
+ pr: "CIRCLE_PULL_REQUEST"
7439
+ },
7182
7440
  {
7183
- name: "disable-auto-screenshot",
7184
- description: "Disable the automatic screenshot captured after interaction tools."
7441
+ name: "Cirrus CI",
7442
+ constant: "CIRRUS",
7443
+ env: "CIRRUS_CI",
7444
+ pr: "CIRRUS_PR"
7185
7445
  },
7186
7446
  {
7187
- name: "argent-lens",
7188
- description: "Argent Lens \u2014 the propose_variant / await_user_selection tools and the Electron preview window for staging UI design variants and letting a human pick among them. Off by default while the feature is in development."
7447
+ name: "Cloudflare Pages",
7448
+ constant: "CLOUDFLARE_PAGES",
7449
+ env: "CF_PAGES"
7189
7450
  },
7190
7451
  {
7191
- name: "artifacts-list-endpoint",
7192
- description: "Expose GET /artifacts for remote artifact inventory consumers."
7452
+ name: "Cloudflare Workers",
7453
+ constant: "CLOUDFLARE_WORKERS",
7454
+ env: "WORKERS_CI"
7193
7455
  },
7194
7456
  {
7195
- name: "tool-server-event-log",
7196
- description: "Write structured tool-server lifecycle events to a JSONL file."
7197
- }
7198
- ];
7199
- function getFlagDefinition(name, registry = FLAG_REGISTRY) {
7200
- return registry.find((def) => def.name === name);
7201
- }
7202
- var PROJECT_MARKERS = [".argent", ".git", "package.json"];
7203
- function findProjectRoot(startDir) {
7204
- let current = path4.resolve(startDir);
7205
- while (true) {
7206
- for (const marker of PROJECT_MARKERS) {
7207
- if (fs2.existsSync(path4.join(current, marker))) return current;
7457
+ name: "Codefresh",
7458
+ constant: "CODEFRESH",
7459
+ env: "CF_BUILD_ID",
7460
+ pr: {
7461
+ any: [
7462
+ "CF_PULL_REQUEST_NUMBER",
7463
+ "CF_PULL_REQUEST_ID"
7464
+ ]
7208
7465
  }
7209
- const parent = path4.dirname(current);
7210
- if (parent === current) return null;
7211
- current = parent;
7212
- }
7213
- }
7214
- function resolveProjectRoot(startDir) {
7215
- return findProjectRoot(startDir) ?? path4.resolve(startDir);
7216
- }
7217
- function getFlagsPath(scope, options = {}) {
7218
- const home = options.homeDir ?? homedir3();
7219
- if (scope === "global") {
7220
- return path4.join(home, ".argent", "flags.json");
7221
- }
7222
- const cwd = options.cwd ?? process.cwd();
7223
- return path4.join(resolveProjectRoot(cwd), ".argent", "flags.json");
7224
- }
7225
- function readFlagsFile(filePath) {
7226
- let raw;
7227
- try {
7228
- raw = fs2.readFileSync(filePath, "utf8");
7229
- } catch {
7230
- return {};
7231
- }
7232
- let parsed;
7233
- try {
7234
- parsed = JSON.parse(raw);
7235
- } catch {
7236
- return {};
7237
- }
7238
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
7239
- const flags2 = parsed.flags;
7240
- if (!flags2 || typeof flags2 !== "object" || Array.isArray(flags2)) return {};
7241
- const out = {};
7242
- for (const [k, v] of Object.entries(flags2)) {
7243
- if (typeof v === "boolean") out[k] = v;
7244
- }
7245
- return out;
7246
- }
7247
- function writeFlagsFile(filePath, flags2) {
7248
- if (Object.keys(flags2).length === 0) {
7249
- if (fs2.existsSync(filePath)) fs2.rmSync(filePath, { force: true });
7250
- const parent = path4.dirname(filePath);
7251
- try {
7252
- if (fs2.existsSync(parent) && fs2.readdirSync(parent).length === 0) {
7253
- fs2.rmdirSync(parent);
7254
- }
7255
- } catch {
7466
+ },
7467
+ {
7468
+ name: "Codemagic",
7469
+ constant: "CODEMAGIC",
7470
+ env: "CM_BUILD_ID",
7471
+ pr: "CM_PULL_REQUEST"
7472
+ },
7473
+ {
7474
+ name: "Codeship",
7475
+ constant: "CODESHIP",
7476
+ env: {
7477
+ CI_NAME: "codeship"
7256
7478
  }
7257
- return;
7258
- }
7259
- fs2.mkdirSync(path4.dirname(filePath), { recursive: true });
7260
- const tmp = `${filePath}.${process.pid}.tmp`;
7261
- fs2.writeFileSync(tmp, JSON.stringify({ flags: flags2 }, null, 2) + "\n");
7262
- fs2.renameSync(tmp, filePath);
7263
- }
7264
- function readFlags(scope, options = {}) {
7265
- return readFlagsFile(getFlagsPath(scope, options));
7266
- }
7267
- function setFlag(name, value, scope, options = {}) {
7268
- const filePath = getFlagsPath(scope, options);
7269
- const current = readFlagsFile(filePath);
7270
- current[name] = value;
7271
- writeFlagsFile(filePath, current);
7272
- }
7273
- function unsetFlag(name, scope, options = {}) {
7274
- const filePath = getFlagsPath(scope, options);
7275
- const current = readFlagsFile(filePath);
7276
- if (!Object.hasOwn(current, name)) return false;
7277
- delete current[name];
7278
- writeFlagsFile(filePath, current);
7279
- return true;
7280
- }
7281
- function isFlagEnabled(name, options = {}) {
7282
- const projectFlags = readFlags("project", options);
7283
- if (Object.hasOwn(projectFlags, name)) return projectFlags[name];
7284
- const globalFlags = readFlags("global", options);
7285
- if (Object.hasOwn(globalFlags, name)) return globalFlags[name];
7286
- return false;
7287
- }
7288
-
7289
- // ../configuration-core/src/paths.ts
7290
- import * as os from "node:os";
7291
- import * as path5 from "node:path";
7292
- function nonEmpty(value) {
7293
- if (value == void 0) return null;
7294
- const trimmed = value.trim();
7295
- return trimmed === "" ? null : value;
7296
- }
7297
- function argentHomeDir() {
7298
- const home = process.platform === "win32" ? nonEmpty(process.env.USERPROFILE) ?? os.homedir() : nonEmpty(process.env.HOME) ?? os.homedir();
7299
- return path5.join(home, ".argent");
7300
- }
7301
- function configDir(scope = "global", options = {}) {
7302
- if (scope === "global") {
7303
- return options.homeDir ? path5.join(options.homeDir, ".argent") : argentHomeDir();
7304
- }
7305
- const cwd = options.cwd ?? process.cwd();
7306
- return path5.join(resolveProjectRoot(cwd), ".argent");
7307
- }
7308
- function configFilePath(scope = "global", options = {}) {
7309
- return path5.join(configDir(scope, options), "config.json");
7310
- }
7311
-
7312
- // ../configuration-core/src/config.ts
7313
- import * as crypto from "node:crypto";
7314
- import * as fs3 from "node:fs";
7315
- import * as path6 from "node:path";
7316
- function readConfigObject(scope = "global", options = {}) {
7317
- try {
7318
- const raw = fs3.readFileSync(configFilePath(scope, options), "utf8");
7319
- const json = JSON.parse(raw);
7320
- if (json && typeof json === "object" && !Array.isArray(json)) {
7321
- return json;
7479
+ },
7480
+ {
7481
+ name: "Drone",
7482
+ constant: "DRONE",
7483
+ env: "DRONE",
7484
+ pr: {
7485
+ DRONE_BUILD_EVENT: "pull_request"
7322
7486
  }
7323
- } catch {
7324
- }
7325
- return {};
7326
- }
7327
- var FORBIDDEN_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
7328
- function splitKey(dottedKey) {
7329
- const parts = dottedKey.split(".");
7330
- if (parts.length === 0 || parts.some((p) => p === "")) {
7331
- throw new Error(`Invalid config key "${dottedKey}": empty path segment`);
7332
- }
7333
- for (const p of parts) {
7334
- if (FORBIDDEN_SEGMENTS.has(p)) {
7335
- throw new Error(`Invalid config key "${dottedKey}": forbidden segment "${p}"`);
7487
+ },
7488
+ {
7489
+ name: "dsari",
7490
+ constant: "DSARI",
7491
+ env: "DSARI"
7492
+ },
7493
+ {
7494
+ name: "Earthly",
7495
+ constant: "EARTHLY",
7496
+ env: "EARTHLY_CI"
7497
+ },
7498
+ {
7499
+ name: "Expo Application Services",
7500
+ constant: "EAS",
7501
+ env: "EAS_BUILD"
7502
+ },
7503
+ {
7504
+ name: "Gerrit",
7505
+ constant: "GERRIT",
7506
+ env: "GERRIT_PROJECT"
7507
+ },
7508
+ {
7509
+ name: "Gitea Actions",
7510
+ constant: "GITEA_ACTIONS",
7511
+ env: "GITEA_ACTIONS"
7512
+ },
7513
+ {
7514
+ name: "GitHub Actions",
7515
+ constant: "GITHUB_ACTIONS",
7516
+ env: "GITHUB_ACTIONS",
7517
+ pr: {
7518
+ GITHUB_EVENT_NAME: "pull_request"
7519
+ }
7520
+ },
7521
+ {
7522
+ name: "GitLab CI",
7523
+ constant: "GITLAB",
7524
+ env: "GITLAB_CI",
7525
+ pr: "CI_MERGE_REQUEST_ID"
7526
+ },
7527
+ {
7528
+ name: "GoCD",
7529
+ constant: "GOCD",
7530
+ env: "GO_PIPELINE_LABEL"
7531
+ },
7532
+ {
7533
+ name: "Google Cloud Build",
7534
+ constant: "GOOGLE_CLOUD_BUILD",
7535
+ env: "BUILDER_OUTPUT"
7536
+ },
7537
+ {
7538
+ name: "Harness CI",
7539
+ constant: "HARNESS",
7540
+ env: "HARNESS_BUILD_ID"
7541
+ },
7542
+ {
7543
+ name: "Heroku",
7544
+ constant: "HEROKU",
7545
+ env: {
7546
+ env: "NODE",
7547
+ includes: "/app/.heroku/node/bin/node"
7548
+ }
7549
+ },
7550
+ {
7551
+ name: "Hudson",
7552
+ constant: "HUDSON",
7553
+ env: "HUDSON_URL"
7554
+ },
7555
+ {
7556
+ name: "Jenkins",
7557
+ constant: "JENKINS",
7558
+ env: [
7559
+ "JENKINS_URL",
7560
+ "BUILD_ID"
7561
+ ],
7562
+ pr: {
7563
+ any: [
7564
+ "ghprbPullId",
7565
+ "CHANGE_ID"
7566
+ ]
7336
7567
  }
7337
- }
7338
- return parts;
7339
- }
7340
- function isPlainObject2(value) {
7341
- return !!value && typeof value === "object" && !Array.isArray(value);
7342
- }
7343
- function getAtPath(obj, dottedKey) {
7344
- const parts = splitKey(dottedKey);
7345
- let cur = obj;
7346
- for (const part of parts) {
7347
- if (!isPlainObject2(cur)) return void 0;
7348
- cur = cur[part];
7349
- }
7350
- return cur;
7351
- }
7352
- function setAtPath(obj, dottedKey, value) {
7353
- const parts = splitKey(dottedKey);
7354
- let cur = obj;
7355
- for (let i2 = 0; i2 < parts.length - 1; i2++) {
7356
- const part = parts[i2];
7357
- const next = cur[part];
7358
- if (!isPlainObject2(next)) {
7359
- cur[part] = {};
7568
+ },
7569
+ {
7570
+ name: "LayerCI",
7571
+ constant: "LAYERCI",
7572
+ env: "LAYERCI",
7573
+ pr: "LAYERCI_PULL_REQUEST"
7574
+ },
7575
+ {
7576
+ name: "Magnum CI",
7577
+ constant: "MAGNUM",
7578
+ env: "MAGNUM"
7579
+ },
7580
+ {
7581
+ name: "Netlify CI",
7582
+ constant: "NETLIFY",
7583
+ env: "NETLIFY",
7584
+ pr: {
7585
+ env: "PULL_REQUEST",
7586
+ ne: "false"
7360
7587
  }
7361
- cur = cur[part];
7362
- }
7363
- cur[parts[parts.length - 1]] = value;
7364
- }
7365
- function deleteAtPath(obj, dottedKey) {
7366
- const parts = splitKey(dottedKey);
7367
- let cur = obj;
7368
- for (let i2 = 0; i2 < parts.length - 1; i2++) {
7369
- const next = cur[parts[i2]];
7370
- if (!isPlainObject2(next)) return false;
7371
- cur = next;
7372
- }
7373
- const leaf = parts[parts.length - 1];
7374
- if (!Object.hasOwn(cur, leaf)) return false;
7375
- delete cur[leaf];
7376
- return true;
7377
- }
7378
- var LOCK_STALE_MS2 = 1e4;
7379
- var LOCK_MAX_WAIT_MS = 2e3;
7380
- var LOCK_RETRY_MS = 25;
7381
- function sleepSync(ms) {
7382
- Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
7383
- }
7384
- function acquireConfigLock(finalPath) {
7385
- const lockPath = finalPath + ".lock";
7386
- const deadline = Date.now() + LOCK_MAX_WAIT_MS;
7387
- for (; ; ) {
7388
- try {
7389
- const fd = fs3.openSync(lockPath, "wx", 384);
7390
- try {
7391
- fs3.writeSync(fd, `${process.pid}
7392
- `);
7393
- } catch {
7394
- }
7395
- return { fd, lockPath };
7396
- } catch (err) {
7397
- if (err.code !== "EEXIST") return null;
7398
- try {
7399
- if (Date.now() - fs3.statSync(lockPath).mtimeMs > LOCK_STALE_MS2) {
7400
- fs3.unlinkSync(lockPath);
7401
- continue;
7402
- }
7403
- } catch {
7404
- }
7405
- if (Date.now() >= deadline) return null;
7406
- sleepSync(LOCK_RETRY_MS);
7588
+ },
7589
+ {
7590
+ name: "Nevercode",
7591
+ constant: "NEVERCODE",
7592
+ env: "NEVERCODE",
7593
+ pr: {
7594
+ env: "NEVERCODE_PULL_REQUEST",
7595
+ ne: "false"
7407
7596
  }
7408
- }
7409
- }
7410
- function releaseConfigLock(lock) {
7411
- try {
7412
- fs3.closeSync(lock.fd);
7413
- } catch {
7414
- }
7415
- try {
7416
- fs3.unlinkSync(lock.lockPath);
7417
- } catch {
7418
- }
7419
- }
7420
- function updateConfig(mutate, scope = "global", options = {}) {
7421
- const dir = configDir(scope, options);
7422
- fs3.mkdirSync(dir, { recursive: true });
7423
- const finalPath = configFilePath(scope, options);
7424
- const lock = acquireConfigLock(finalPath);
7425
- try {
7426
- const next = readConfigObject(scope, options);
7427
- mutate(next);
7428
- const tmpPath = path6.join(dir, `.config.tmp.${process.pid}.${crypto.randomUUID()}`);
7429
- const fd = fs3.openSync(tmpPath, "wx", 384);
7430
- try {
7431
- fs3.writeSync(fd, JSON.stringify(next, null, 2) + "\n");
7432
- fs3.fsyncSync(fd);
7433
- } finally {
7434
- fs3.closeSync(fd);
7597
+ },
7598
+ {
7599
+ name: "Prow",
7600
+ constant: "PROW",
7601
+ env: "PROW_JOB_ID"
7602
+ },
7603
+ {
7604
+ name: "ReleaseHub",
7605
+ constant: "RELEASEHUB",
7606
+ env: "RELEASE_BUILD_ID"
7607
+ },
7608
+ {
7609
+ name: "Render",
7610
+ constant: "RENDER",
7611
+ env: "RENDER",
7612
+ pr: {
7613
+ IS_PULL_REQUEST: "true"
7435
7614
  }
7436
- try {
7437
- fs3.renameSync(tmpPath, finalPath);
7438
- } catch (err) {
7439
- try {
7440
- fs3.unlinkSync(tmpPath);
7441
- } catch {
7442
- }
7443
- throw err;
7615
+ },
7616
+ {
7617
+ name: "Sail CI",
7618
+ constant: "SAIL",
7619
+ env: "SAILCI",
7620
+ pr: "SAIL_PULL_REQUEST_NUMBER"
7621
+ },
7622
+ {
7623
+ name: "Screwdriver",
7624
+ constant: "SCREWDRIVER",
7625
+ env: "SCREWDRIVER",
7626
+ pr: {
7627
+ env: "SD_PULL_REQUEST",
7628
+ ne: "false"
7444
7629
  }
7445
- } finally {
7446
- if (lock) releaseConfigLock(lock);
7447
- }
7448
- }
7449
-
7450
- // ../configuration-core/src/merge.ts
7451
- function mergeRestrictive(local, global2) {
7452
- if (local === void 0) return global2;
7453
- if (global2 === void 0) return local;
7454
- if (typeof local === "boolean" && typeof global2 === "boolean") {
7455
- return local && global2;
7456
- }
7457
- if (typeof local === "number" && typeof global2 === "number") {
7458
- return Math.min(local, global2);
7459
- }
7460
- return local;
7461
- }
7462
- function toArray(value) {
7463
- return Array.isArray(value) ? value : null;
7464
- }
7465
- function mergeUnion(local, global2) {
7466
- const l2 = toArray(local);
7467
- const g = toArray(global2);
7468
- if (l2 === null && g === null) return local ?? global2;
7469
- const merged = [...g ?? [], ...l2 ?? []];
7470
- return Array.from(new Set(merged));
7471
- }
7472
- function mergeIntersection(local, global2) {
7473
- const l2 = toArray(local);
7474
- const g = toArray(global2);
7475
- if (l2 === null && g === null) return local ?? global2;
7476
- if (l2 === null) return global2;
7477
- if (g === null) return local;
7478
- const globalSet = new Set(g);
7479
- return l2.filter((item) => globalSet.has(item));
7480
- }
7481
- function applyMergePolicy(policy, local, global2) {
7482
- if (typeof policy === "function") return policy({ local, global: global2 });
7483
- switch (policy) {
7484
- case "prioritize-local":
7485
- return local ?? global2;
7486
- case "prioritize-global":
7487
- return global2 ?? local;
7488
- case "prioritize-restrictive":
7489
- return mergeRestrictive(local, global2);
7490
- case "union":
7491
- return mergeUnion(local, global2);
7492
- case "intersection":
7493
- return mergeIntersection(local, global2);
7494
- default: {
7495
- const _exhaustive = policy;
7496
- return _exhaustive;
7630
+ },
7631
+ {
7632
+ name: "Semaphore",
7633
+ constant: "SEMAPHORE",
7634
+ env: "SEMAPHORE",
7635
+ pr: "PULL_REQUEST_NUMBER"
7636
+ },
7637
+ {
7638
+ name: "Sourcehut",
7639
+ constant: "SOURCEHUT",
7640
+ env: {
7641
+ CI_NAME: "sourcehut"
7642
+ }
7643
+ },
7644
+ {
7645
+ name: "Strider CD",
7646
+ constant: "STRIDER",
7647
+ env: "STRIDER"
7648
+ },
7649
+ {
7650
+ name: "TaskCluster",
7651
+ constant: "TASKCLUSTER",
7652
+ env: [
7653
+ "TASK_ID",
7654
+ "RUN_ID"
7655
+ ]
7656
+ },
7657
+ {
7658
+ name: "TeamCity",
7659
+ constant: "TEAMCITY",
7660
+ env: "TEAMCITY_VERSION"
7661
+ },
7662
+ {
7663
+ name: "Travis CI",
7664
+ constant: "TRAVIS",
7665
+ env: "TRAVIS",
7666
+ pr: {
7667
+ env: "TRAVIS_PULL_REQUEST",
7668
+ ne: "false"
7497
7669
  }
7498
- }
7499
- }
7500
-
7501
- // ../configuration-core/src/config-schema.ts
7502
- function asBoolean(raw) {
7503
- return typeof raw === "boolean" ? raw : void 0;
7504
- }
7505
- function asString(raw) {
7506
- if (typeof raw !== "string") return void 0;
7507
- const trimmed = raw.trim();
7508
- return trimmed === "" ? void 0 : trimmed;
7509
- }
7510
- var CONFIG_SCHEMA = [
7670
+ },
7511
7671
  {
7512
- key: "telemetry.enabled",
7513
- description: "Whether anonymous opt-out telemetry is enabled (on by default; environment opt-outs like DO_NOT_TRACK are not reflected here \u2014 `argent telemetry status` shows effective consent).",
7514
- scopes: ["global"],
7515
- parse: asBoolean,
7516
- // A committed project file must never re-enable telemetry a user disabled
7517
- // globally, so the more-restrictive (opt-out) value always wins.
7518
- merge: "prioritize-restrictive",
7519
- // Telemetry is opt-out: with nothing stored, consent.ts treats it as
7520
- // enabled, and the config surface must report the same instead of "(unset)".
7521
- default: true,
7522
- // Read-only under `argent config`: opt-in/out goes through the dedicated
7523
- // command so the live client is drained/reset, not just the file rewritten.
7524
- manageCommand: "argent telemetry"
7672
+ name: "Vela",
7673
+ constant: "VELA",
7674
+ env: "VELA",
7675
+ pr: {
7676
+ VELA_PULL_REQUEST: "1"
7677
+ }
7525
7678
  },
7526
7679
  {
7527
- key: "lens.agent",
7528
- description: "Coding-agent id remembered by `argent lens` to skip the picker.",
7529
- scopes: ["project", "global"],
7530
- parse: asString,
7531
- // A repo can pin the agent its screenshots should use; falls back to the
7532
- // user's global remembered choice.
7533
- merge: "prioritize-local",
7534
- example: "claude"
7680
+ name: "Vercel",
7681
+ constant: "VERCEL",
7682
+ env: {
7683
+ any: [
7684
+ "NOW_BUILDER",
7685
+ "VERCEL"
7686
+ ]
7687
+ },
7688
+ pr: "VERCEL_GIT_PULL_REQUEST_ID"
7689
+ },
7690
+ {
7691
+ name: "Visual Studio App Center",
7692
+ constant: "APPCENTER",
7693
+ env: "APPCENTER_BUILD_ID"
7694
+ },
7695
+ {
7696
+ name: "Woodpecker",
7697
+ constant: "WOODPECKER",
7698
+ env: {
7699
+ CI: "woodpecker"
7700
+ },
7701
+ pr: {
7702
+ CI_BUILD_EVENT: "pull_request"
7703
+ }
7704
+ },
7705
+ {
7706
+ name: "Xcode Cloud",
7707
+ constant: "XCODE_CLOUD",
7708
+ env: "CI_XCODE_PROJECT",
7709
+ pr: "CI_PULL_REQUEST_NUMBER"
7710
+ },
7711
+ {
7712
+ name: "Xcode Server",
7713
+ constant: "XCODE_SERVER",
7714
+ env: "XCS"
7535
7715
  }
7536
7716
  ];
7537
- function getConfigDefinition(key, registry = CONFIG_SCHEMA) {
7538
- return registry.find((def) => def.key === key);
7539
- }
7540
7717
 
7541
- // ../configuration-core/src/config-access.ts
7542
- function readScopeValue(def, scope, options) {
7543
- if (!def.scopes.includes(scope)) return void 0;
7544
- const raw = getAtPath(readConfigObject(scope, options), def.key);
7545
- return raw === void 0 ? void 0 : def.parse(raw);
7546
- }
7547
- function getConfigValue(def, options = {}) {
7548
- const local = readScopeValue(def, "project", options);
7549
- const global2 = readScopeValue(def, "global", options);
7550
- const merged = applyMergePolicy(def.merge, local, global2);
7551
- return merged ?? def.default;
7552
- }
7553
- function getConfigValueAtScope(key, scope, options = {}, registry = CONFIG_SCHEMA) {
7554
- const def = requireDefinition(key, registry);
7555
- return readScopeValue(def, scope, options);
7556
- }
7557
- function getConfigValueByKey(key, options = {}, registry = CONFIG_SCHEMA) {
7558
- const def = requireDefinition(key, registry);
7559
- return getConfigValue(def, options);
7560
- }
7561
- function requireDefinition(key, registry = CONFIG_SCHEMA) {
7562
- const def = getConfigDefinition(key, registry);
7563
- if (!def) {
7564
- throw new UnknownConfigKeyError(key);
7565
- }
7566
- return def;
7567
- }
7568
- var UnknownConfigKeyError = class extends Error {
7569
- constructor(key) {
7570
- super(`Unknown configuration key "${key}".`);
7571
- this.key = key;
7572
- this.name = "UnknownConfigKeyError";
7573
- }
7574
- key;
7575
- };
7576
- var ConfigScopeError = class extends Error {
7577
- constructor(key, scope, allowed) {
7578
- super(`Config key "${key}" cannot be set at ${scope} scope (allowed: ${allowed.join(", ")}).`);
7579
- this.key = key;
7580
- this.scope = scope;
7581
- this.allowed = allowed;
7582
- this.name = "ConfigScopeError";
7583
- }
7584
- key;
7585
- scope;
7586
- allowed;
7587
- };
7588
- var ConfigValidationError = class extends Error {
7589
- constructor(key) {
7590
- super(`Invalid value for config key "${key}".`);
7591
- this.key = key;
7592
- this.name = "ConfigValidationError";
7718
+ // ../telemetry/src/ci-detect.ts
7719
+ var GENERIC_CI_ENV_VARS = [
7720
+ "BUILD_ID",
7721
+ "BUILD_NUMBER",
7722
+ "CI",
7723
+ "CI_APP_ID",
7724
+ "CI_BUILD_ID",
7725
+ "CI_BUILD_NUMBER",
7726
+ "CI_NAME",
7727
+ "CONTINUOUS_INTEGRATION",
7728
+ "RUN_ID"
7729
+ ];
7730
+ function checkEnv(env, def) {
7731
+ if (typeof def === "string") return Boolean(env[def]);
7732
+ if ("env" in def) {
7733
+ const value = env[def.env];
7734
+ return Boolean(value && value.includes(def.includes));
7593
7735
  }
7594
- key;
7595
- };
7596
- var ConfigManagedElsewhereError = class extends Error {
7597
- constructor(key, command) {
7598
- super(`Config key "${key}" is managed by \`${command}\`.`);
7599
- this.key = key;
7600
- this.command = command;
7601
- this.name = "ConfigManagedElsewhereError";
7736
+ if ("any" in def && Array.isArray(def.any)) {
7737
+ return def.any.some((key) => Boolean(env[key]));
7602
7738
  }
7603
- key;
7604
- command;
7605
- };
7606
- function setConfigValue(key, rawValue, scope = "global", options = {}, registry = CONFIG_SCHEMA) {
7607
- const def = requireDefinition(key, registry);
7608
- if (def.manageCommand) throw new ConfigManagedElsewhereError(key, def.manageCommand);
7609
- if (!def.scopes.includes(scope)) throw new ConfigScopeError(key, scope, def.scopes);
7610
- const parsed = def.parse(rawValue);
7611
- if (parsed === void 0) throw new ConfigValidationError(key);
7612
- updateConfig((config2) => setAtPath(config2, key, parsed), scope, options);
7613
- return parsed;
7739
+ return Object.entries(def).every(([key, value]) => env[key] === value);
7614
7740
  }
7615
- function unsetConfigValue(key, scope = "global", options = {}, registry = CONFIG_SCHEMA) {
7616
- const def = requireDefinition(key, registry);
7617
- if (def.manageCommand) throw new ConfigManagedElsewhereError(key, def.manageCommand);
7618
- if (!def.scopes.includes(scope)) throw new ConfigScopeError(key, scope, def.scopes);
7619
- if (getAtPath(readConfigObject(scope, options), key) === void 0) return false;
7620
- let removed = false;
7621
- updateConfig(
7622
- (config2) => {
7623
- removed = deleteAtPath(config2, key);
7624
- },
7625
- scope,
7626
- options
7627
- );
7628
- return removed;
7741
+ function isKnownVendorCi(env) {
7742
+ return vendors_default.some((vendor) => {
7743
+ const defs = Array.isArray(vendor.env) ? vendor.env : [vendor.env];
7744
+ return defs.every((def) => checkEnv(env, def));
7745
+ });
7629
7746
  }
7630
- function listConfig(options = {}, registry = CONFIG_SCHEMA) {
7631
- return registry.map((def) => ({
7632
- key: def.key,
7633
- description: def.description,
7634
- scopes: def.scopes,
7635
- ...def.manageCommand ? { manageCommand: def.manageCommand } : {},
7636
- effective: getConfigValue(def, options),
7637
- project: readScopeValue(def, "project", options),
7638
- global: readScopeValue(def, "global", options)
7639
- }));
7747
+ function isCi(env = process.env) {
7748
+ if (env.CI === "false") return false;
7749
+ if (GENERIC_CI_ENV_VARS.some((name) => Boolean(env[name]))) return true;
7750
+ return isKnownVendorCi(env);
7640
7751
  }
7641
- function coerceCliValue(raw) {
7642
- try {
7643
- return JSON.parse(raw);
7644
- } catch {
7645
- return raw;
7752
+ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
7753
+
7754
+ // ../telemetry/src/base-props.ts
7755
+ var SESSION_ID2 = randomUUID5();
7756
+ function readCliVersion() {
7757
+ if (true) {
7758
+ return "0.16.1";
7646
7759
  }
7760
+ return "0.0.0";
7647
7761
  }
7648
- var LENS_AGENT_KEY = "lens.agent";
7649
- function getRememberedAgent(options = {}) {
7650
- const value = getConfigValueByKey(LENS_AGENT_KEY, options);
7651
- return typeof value === "string" && value.trim() ? value : null;
7762
+ function readNodeVersionMajor() {
7763
+ const m = /^v?(\d+)/.exec(process.version);
7764
+ return m ? m[1] : "unknown";
7652
7765
  }
7653
- function setRememberedAgent(agentId, options = {}) {
7654
- setConfigValue(LENS_AGENT_KEY, agentId, "global", options);
7766
+ var invariantProps = null;
7767
+ function getInvariantProps() {
7768
+ if (!invariantProps) {
7769
+ invariantProps = {
7770
+ cli_version: readCliVersion(),
7771
+ node_version_major: readNodeVersionMajor(),
7772
+ os: process.platform,
7773
+ arch: process.arch,
7774
+ is_tty: Boolean(process.stdout.isTTY),
7775
+ is_ci: isCi(),
7776
+ cloud_agent: detectCloudAgent(),
7777
+ $process_person_profile: false
7778
+ };
7779
+ }
7780
+ return invariantProps;
7655
7781
  }
7656
- function clearRememberedAgent(options = {}) {
7657
- unsetConfigValue(LENS_AGENT_KEY, "global", options);
7782
+ function getBaseProps(runtime) {
7783
+ return {
7784
+ ...getInvariantProps(),
7785
+ runtime,
7786
+ $session_id: SESSION_ID2
7787
+ };
7658
7788
  }
7659
7789
 
7790
+ // ../telemetry/src/identity.ts
7791
+ import * as crypto2 from "node:crypto";
7792
+ import * as fs4 from "node:fs";
7793
+ import * as path8 from "node:path";
7794
+
7660
7795
  // ../telemetry/src/paths.ts
7796
+ import * as path7 from "node:path";
7661
7797
  function identityFilePath() {
7662
7798
  return path7.join(argentHomeDir(), "telemetry-id");
7663
7799
  }
@@ -9680,12 +9816,12 @@ function isSessionAlive(session) {
9680
9816
  // ../argent-cli/src/lens-pty.ts
9681
9817
  import { chmodSync as chmodSync2, readdirSync as readdirSync2 } from "node:fs";
9682
9818
  import { createRequire } from "node:module";
9683
- import { dirname as dirname7, join as join14 } from "node:path";
9819
+ import { dirname as dirname8, join as join14 } from "node:path";
9684
9820
  var nodeRequire = createRequire(import.meta.url);
9685
9821
  function ensureSpawnHelperExecutable(req = nodeRequire) {
9686
9822
  if (process.platform !== "darwin") return;
9687
9823
  try {
9688
- const prebuilds = join14(dirname7(req.resolve("node-pty/package.json")), "prebuilds");
9824
+ const prebuilds = join14(dirname8(req.resolve("node-pty/package.json")), "prebuilds");
9689
9825
  for (const entry of readdirSync2(prebuilds)) {
9690
9826
  try {
9691
9827
  chmodSync2(join14(prebuilds, entry, "spawn-helper"), 493);
@@ -9830,10 +9966,10 @@ function parseSseBuffer(buffer) {
9830
9966
  const events = [];
9831
9967
  let rest = normalised;
9832
9968
  for (; ; ) {
9833
- const sep4 = rest.indexOf("\n\n");
9834
- if (sep4 === -1) break;
9835
- const rawFrame = rest.slice(0, sep4);
9836
- rest = rest.slice(sep4 + 2);
9969
+ const sep5 = rest.indexOf("\n\n");
9970
+ if (sep5 === -1) break;
9971
+ const rawFrame = rest.slice(0, sep5);
9972
+ rest = rest.slice(sep5 + 2);
9837
9973
  let event = "message";
9838
9974
  const dataLines = [];
9839
9975
  for (const line of rawFrame.split("\n")) {
@@ -10511,6 +10647,8 @@ function runToggle(argv, command, registry) {
10511
10647
  try {
10512
10648
  if (command === "enable") {
10513
10649
  setFlag(parsed.name, true, parsed.scope);
10650
+ } else if (getFlagDefinition(parsed.name, registry)?.defaultEnabled) {
10651
+ setFlag(parsed.name, false, parsed.scope);
10514
10652
  } else {
10515
10653
  unsetFlag(parsed.name, parsed.scope);
10516
10654
  }
@@ -10555,7 +10693,8 @@ Options:
10555
10693
  return {
10556
10694
  name: def.name,
10557
10695
  description: def.description,
10558
- enabled: eff?.value ?? false,
10696
+ // An unset opt-out flag reads as on (its declared default).
10697
+ enabled: eff?.value ?? def.defaultEnabled ?? false,
10559
10698
  scope: eff?.scope ?? null
10560
10699
  };
10561
10700
  });
@@ -11572,7 +11711,7 @@ import { styleText as styleText2, stripVTControlCharacters } from "node:util";
11572
11711
  import process$1 from "node:process";
11573
11712
  var import_sisteransi2 = __toESM(require_src(), 1);
11574
11713
  import { existsSync as existsSync7, lstatSync as lstatSync3, readdirSync as readdirSync3 } from "node:fs";
11575
- import { dirname as dirname9, join as join17 } from "node:path";
11714
+ import { dirname as dirname10, join as join17 } from "node:path";
11576
11715
  function isUnicodeSupported() {
11577
11716
  if (process$1.platform !== "win32") {
11578
11717
  return process$1.env.TERM !== "linux";