@lousy-agents/agent-shell 5.22.5 → 5.22.6

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.
Files changed (2) hide show
  1. package/dist/index.js +725 -718
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { createRequire as __rspack_createRequire } from "node:module";
3
3
  const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
4
4
  var __webpack_modules__ = ({
5
- 317(__unused_rspack_module, __unused_rspack___webpack_exports__, __webpack_require__) {
5
+ 620(__unused_rspack_module, __unused_rspack___webpack_exports__, __webpack_require__) {
6
6
 
7
7
  ;// CONCATENATED MODULE: external "node:child_process"
8
8
  const external_node_child_process_namespaceObject = __rspack_createRequire_require("node:child_process");
@@ -12,6 +12,51 @@ const external_node_crypto_namespaceObject = __rspack_createRequire_require("nod
12
12
  const promises_namespaceObject = __rspack_createRequire_require("node:fs/promises");
13
13
  ;// CONCATENATED MODULE: external "node:readline"
14
14
  const external_node_readline_namespaceObject = __rspack_createRequire_require("node:readline");
15
+ ;// CONCATENATED MODULE: ./src/entities/sanitize.ts
16
+ /**
17
+ * Escapes ASCII and C1 control characters in error messages before writing
18
+ * to stderr. Replaces each control character with its `\xNN` hex
19
+ * representation to prevent log/terminal injection when errors embed
20
+ * untrusted data.
21
+ */ function sanitizeForStderr(err) {
22
+ const msg = err instanceof Error ? err.message : String(err);
23
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: intentionally matching control characters for sanitization
24
+ return msg.replace(/[\u0000-\u001f\u007f-\u009f]/g, (ch)=>{
25
+ return `\\x${ch.charCodeAt(0).toString(16).padStart(2, "0")}`;
26
+ });
27
+ }
28
+ /**
29
+ * Escapes ASCII and C1 control characters (except newline) in output text.
30
+ * Like sanitizeForStderr but preserves newlines for JSON formatting.
31
+ */ function sanitizeOutput(text) {
32
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: intentionally matching control characters for sanitization
33
+ return text.replace(/[\u0000-\u0009\u000b-\u001f\u007f-\u009f]/g, (ch)=>{
34
+ return `\\x${ch.charCodeAt(0).toString(16).padStart(2, "0")}`;
35
+ });
36
+ }
37
+ /**
38
+ * Sanitizes untrusted values before embedding in prompts.
39
+ * Strips newlines and all backticks that could inject instructions,
40
+ * and truncates to a safe length.
41
+ */ function sanitizePromptValue(value) {
42
+ return value.replace(/[\n\r]/g, " ").replace(/`/g, "").slice(0, 256);
43
+ }
44
+ /**
45
+ * Shell metacharacters that indicate compound or piped commands.
46
+ * Commands containing these are excluded from the allow list because
47
+ * they could mask injection (e.g. `npm test && curl evil`).
48
+ */ const SHELL_METACHAR_PATTERN = /[;|&`><$()\\\n\r]/;
49
+ /**
50
+ * Returns true if the command is non-empty, contains no shell metacharacters,
51
+ * and is safe to include in a policy allow list.
52
+ */ function isSafeCommand(command) {
53
+ const normalized = command.trim();
54
+ if (normalized.length === 0) {
55
+ return false;
56
+ }
57
+ return !SHELL_METACHAR_PATTERN.test(normalized);
58
+ }
59
+
15
60
  ;// CONCATENATED MODULE: external "node:path"
16
61
  const external_node_path_namespaceObject = __rspack_createRequire_require("node:path");
17
62
  ;// CONCATENATED MODULE: ./src/gateways/git-utils.ts
@@ -21892,82 +21937,226 @@ async function detectLanguages(targetDir) {
21892
21937
  };
21893
21938
  }
21894
21939
 
21895
- ;// CONCATENATED MODULE: ./src/gateways/shim.ts
21940
+ ;// CONCATENATED MODULE: ./src/gateways/resolve-sdk.ts
21896
21941
 
21897
- const signalCodes = new Map([
21898
- [
21899
- "SIGINT",
21900
- 2
21901
- ],
21902
- [
21903
- "SIGTERM",
21904
- 15
21905
- ],
21906
- [
21907
- "SIGTSTP",
21908
- 20
21909
- ]
21910
- ]);
21911
- const FORWARDED_SIGNALS = [
21912
- "SIGINT",
21913
- "SIGTERM",
21914
- "SIGTSTP"
21915
- ];
21916
- async function runShim(options) {
21917
- const startTime = performance.now();
21918
- return new Promise((resolve)=>{
21919
- const child = (0,external_node_child_process_namespaceObject.spawn)("/bin/sh", [
21920
- "-c",
21921
- options.command
21922
- ], {
21923
- stdio: "inherit",
21924
- detached: true
21925
- });
21926
- const handlers = new Map();
21927
- for (const signal of FORWARDED_SIGNALS){
21928
- const handler = ()=>{
21929
- if (child.pid !== undefined) {
21930
- try {
21931
- // Kill the entire process group so grandchildren (e.g. sleep spawned
21932
- // by sh without exec) also receive the signal and release any
21933
- // inherited pipes, preventing the parent from hanging on 'close'.
21934
- process.kill(-child.pid, signal);
21935
- } catch {
21936
- // Process group may have already exited; fall back to direct kill
21937
- child.kill(signal);
21938
- }
21939
- }
21940
- };
21941
- handlers.set(signal, handler);
21942
- process.on(signal, handler);
21943
- }
21944
- child.on("close", async (code, signal)=>{
21945
- for (const [sig, handler] of handlers){
21946
- process.removeListener(sig, handler);
21947
- }
21948
- const durationMs = performance.now() - startTime;
21949
- let exitCode;
21950
- if (signal) {
21951
- const signalNumber = signalCodes.get(signal) ?? 1;
21952
- exitCode = 128 + signalNumber;
21953
- } else {
21954
- exitCode = code ?? 1;
21955
- }
21956
- const result = {
21957
- exitCode,
21958
- signal: signal ?? null,
21959
- durationMs
21960
- };
21961
- if (options.onComplete) {
21942
+
21943
+
21944
+
21945
+ /**
21946
+ * Resolves an npm package's ESM entry point from the user's project directory.
21947
+ *
21948
+ * Bundled CLIs resolve bare specifiers relative to the bundle location, not
21949
+ * the user's working directory. This uses `createRequire` anchored at the
21950
+ * project root to locate the package, then reads its `package.json` exports
21951
+ * map to select the ESM entry that `import()` would use.
21952
+ *
21953
+ * @returns A file:// URL to the package ESM entry point, or null if not found
21954
+ */ function resolveSdkPath(repoRoot, packageName) {
21955
+ if (!repoRoot || !(0,external_node_path_namespaceObject.isAbsolute)(repoRoot)) return null;
21956
+ if (/^[./]/.test(packageName) || packageName.includes("..")) return null;
21957
+ try {
21958
+ const projectRequire = (0,external_node_module_namespaceObject.createRequire)((0,external_node_path_namespaceObject.resolve)(repoRoot, "package.json"));
21959
+ const cjsResolved = projectRequire.resolve(packageName);
21960
+ const esmUrl = findEsmEntry(cjsResolved, packageName);
21961
+ return esmUrl ?? (0,external_node_url_namespaceObject.pathToFileURL)(cjsResolved).href;
21962
+ } catch {
21963
+ return null;
21964
+ }
21965
+ }
21966
+ /**
21967
+ * Walks up from a resolved module path to find the package root directory,
21968
+ * then extracts the ESM entry point from its exports map.
21969
+ */ function findEsmEntry(resolvedPath, packageName) {
21970
+ let dir = (0,external_node_path_namespaceObject.dirname)(resolvedPath);
21971
+ while(true){
21972
+ try {
21973
+ const raw = (0,external_node_fs_namespaceObject.readFileSync)((0,external_node_path_namespaceObject.join)(dir, "package.json"), "utf-8");
21974
+ const pkg = JSON.parse(raw);
21975
+ if (typeof pkg === "object" && pkg !== null && pkg.name === packageName) {
21976
+ const esmEntry = extractEsmEntry(pkg);
21977
+ const full = (0,external_node_path_namespaceObject.resolve)(dir, esmEntry);
21962
21978
  try {
21963
- await options.onComplete(result);
21979
+ return (0,external_node_url_namespaceObject.pathToFileURL)((0,external_node_fs_namespaceObject.realpathSync)(full)).href;
21964
21980
  } catch {
21965
- // onComplete errors must not prevent shim result from resolving
21981
+ return null;
21966
21982
  }
21967
21983
  }
21968
- resolve(result);
21969
- });
21984
+ } catch {
21985
+ /* no package.json at this level */ }
21986
+ const parent = (0,external_node_path_namespaceObject.dirname)(dir);
21987
+ if (parent === dir) return null;
21988
+ dir = parent;
21989
+ }
21990
+ }
21991
+ /**
21992
+ * Extracts the ESM entry point from a parsed package.json object.
21993
+ */ function extractEsmEntry(pkgJson) {
21994
+ if (typeof pkgJson === "object" && pkgJson !== null) {
21995
+ const pkg = pkgJson;
21996
+ const esmPath = resolveExportsImportEntry(pkg.exports);
21997
+ if (esmPath) return esmPath;
21998
+ if (typeof pkg.main === "string" && pkg.main.length > 0) return pkg.main;
21999
+ }
22000
+ return "index.js";
22001
+ }
22002
+ /**
22003
+ * Navigates the exports map to find the ESM entry. Supports string-shaped
22004
+ * exports, string-valued `exports["."]`, `exports["."].import` (string),
22005
+ * `exports["."].import.default`, and the sugar form where condition keys
22006
+ * (`import`/`require`) appear directly on the exports object.
22007
+ */ function resolveExportsImportEntry(exports) {
22008
+ if (typeof exports === "string") return exports;
22009
+ if (typeof exports !== "object" || exports === null) return null;
22010
+ const exportsMap = exports;
22011
+ const dotEntry = exportsMap["."];
22012
+ if (typeof dotEntry === "string") return dotEntry;
22013
+ const conditionSource = typeof dotEntry === "object" && dotEntry !== null && !Array.isArray(dotEntry) ? dotEntry : exportsMap;
22014
+ const importEntry = conditionSource.import;
22015
+ if (typeof importEntry === "string") return importEntry;
22016
+ if (typeof importEntry === "object" && importEntry !== null) {
22017
+ const importMap = importEntry;
22018
+ if (typeof importMap.default === "string") return importMap.default;
22019
+ }
22020
+ return null;
22021
+ }
22022
+
22023
+ ;// CONCATENATED MODULE: ./src/lib/log-format.ts
22024
+
22025
+ function formatDuration(ms) {
22026
+ if (ms < 1000) return `${Math.round(ms)}ms`;
22027
+ if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`;
22028
+ return `${(ms / 60000).toFixed(1)}m`;
22029
+ }
22030
+ function formatTimestamp(iso) {
22031
+ const d = new Date(iso);
22032
+ return d.toISOString().replace("T", " ").replace(/\.\d{3}Z$/, "");
22033
+ }
22034
+ function truncateCommand(command, maxLen) {
22035
+ if (command.length <= maxLen) return command;
22036
+ return `${command.slice(0, maxLen - 3)}...`;
22037
+ }
22038
+ function padRight(str, width) {
22039
+ if (str.length >= width) return str;
22040
+ return str + " ".repeat(width - str.length);
22041
+ }
22042
+ const COL_TIMESTAMP = 21;
22043
+ const COL_SCRIPT = 9;
22044
+ const COL_ACTOR = 13;
22045
+ const COL_EXIT = 6;
22046
+ const COL_DURATION = 10;
22047
+ const MAX_COMMAND_LEN = 50;
22048
+ function formatEventsTable(events) {
22049
+ const header = padRight("TIMESTAMP", COL_TIMESTAMP) + padRight("SCRIPT", COL_SCRIPT) + padRight("ACTOR", COL_ACTOR) + padRight("EXIT", COL_EXIT) + padRight("DURATION", COL_DURATION) + "COMMAND";
22050
+ const rows = events.map((event)=>{
22051
+ const timestamp = formatTimestamp(event.timestamp);
22052
+ const script = event.event === "script_end" ? event.script ?? "-" : event.event === "tool_use" ? sanitizeOutput(event.tool_name) : "-";
22053
+ const actor = event.actor;
22054
+ const exitCode = event.event === "script_end" ? String(event.exit_code) : "-";
22055
+ const duration = event.event === "script_end" ? formatDuration(event.duration_ms) : "-";
22056
+ const command = truncateCommand(event.command, MAX_COMMAND_LEN);
22057
+ return padRight(timestamp, COL_TIMESTAMP) + padRight(script, COL_SCRIPT) + padRight(actor, COL_ACTOR) + padRight(exitCode, COL_EXIT) + padRight(duration, COL_DURATION) + command;
22058
+ });
22059
+ return [
22060
+ header,
22061
+ ...rows
22062
+ ].join("\n");
22063
+ }
22064
+ function formatSessionsTable(sessions) {
22065
+ const colSession = 11;
22066
+ const colFirstEvent = 21;
22067
+ const colLastEvent = 21;
22068
+ const colEvents = 9;
22069
+ const header = padRight("SESSION", colSession) + padRight("FIRST EVENT", colFirstEvent) + padRight("LAST EVENT", colLastEvent) + padRight("EVENTS", colEvents) + "ACTORS";
22070
+ const rows = sessions.map((s)=>{
22071
+ const sessionTrunc = s.sessionId.slice(0, 8);
22072
+ const firstEvent = formatTimestamp(s.firstEvent);
22073
+ const lastEvent = formatTimestamp(s.lastEvent);
22074
+ const eventCount = String(s.eventCount);
22075
+ const actors = s.actors.join(", ");
22076
+ return padRight(sessionTrunc, colSession) + padRight(firstEvent, colFirstEvent) + padRight(lastEvent, colLastEvent) + padRight(eventCount, colEvents) + actors;
21970
22077
  });
22078
+ return [
22079
+ header,
22080
+ ...rows
22081
+ ].join("\n");
22082
+ }
22083
+ function formatEventsJson(events) {
22084
+ return JSON.stringify(events, null, 2);
22085
+ }
22086
+
22087
+ ;// CONCATENATED MODULE: ./src/use-cases/log-command.ts
22088
+ function parseLogArgs(args) {
22089
+ const options = {
22090
+ failures: false,
22091
+ listSessions: false,
22092
+ json: false
22093
+ };
22094
+ let i = 0;
22095
+ while(i < args.length){
22096
+ const arg = args[i];
22097
+ switch(arg){
22098
+ case "--last":
22099
+ if (i + 1 < args.length) {
22100
+ options.last = args[++i];
22101
+ } else {
22102
+ options.errors = options.errors ?? [];
22103
+ options.errors.push("--last requires a value (e.g., 30m, 1h, 1d)");
22104
+ }
22105
+ break;
22106
+ case "--actor":
22107
+ if (i + 1 < args.length) {
22108
+ options.actor = args[++i];
22109
+ } else {
22110
+ options.errors = options.errors ?? [];
22111
+ options.errors.push("--actor requires a value");
22112
+ }
22113
+ break;
22114
+ case "--failures":
22115
+ options.failures = true;
22116
+ break;
22117
+ case "--script":
22118
+ if (i + 1 < args.length) {
22119
+ options.script = args[++i];
22120
+ } else {
22121
+ options.errors = options.errors ?? [];
22122
+ options.errors.push("--script requires a value");
22123
+ }
22124
+ break;
22125
+ case "--list-sessions":
22126
+ options.listSessions = true;
22127
+ break;
22128
+ case "--json":
22129
+ options.json = true;
22130
+ break;
22131
+ }
22132
+ i++;
22133
+ }
22134
+ return options;
22135
+ }
22136
+
22137
+ ;// CONCATENATED MODULE: ./src/entities/path-utils.ts
22138
+
22139
+ function isWithinProjectRoot(resolvedPath, projectRoot) {
22140
+ const normalizedPath = (0,external_node_path_namespaceObject.resolve)(resolvedPath);
22141
+ const normalizedRoot = (0,external_node_path_namespaceObject.resolve)(projectRoot);
22142
+ if (normalizedPath === normalizedRoot) return true;
22143
+ const rel = (0,external_node_path_namespaceObject.relative)(normalizedRoot, normalizedPath);
22144
+ // Outside the root if: empty, exact "..", starts with "../" (or "..\"), or is absolute (different drive on Windows)
22145
+ return rel !== "" && rel !== ".." && !rel.startsWith(`..${external_node_path_namespaceObject.sep}`) && !(0,external_node_path_namespaceObject.isAbsolute)(rel);
22146
+ }
22147
+ function isPathNotFoundError(err) {
22148
+ if (typeof err === "object" && err !== null && "code" in err) {
22149
+ const { code } = err;
22150
+ return code === "ENOENT" || code === "ENOTDIR";
22151
+ }
22152
+ return false;
22153
+ }
22154
+ function isNameTooLongError(err) {
22155
+ if (typeof err === "object" && err !== null && "code" in err) {
22156
+ const { code } = err;
22157
+ return code === "ENAMETOOLONG";
22158
+ }
22159
+ return false;
21971
22160
  }
21972
22161
 
21973
22162
  ;// CONCATENATED MODULE: ./node_modules/zod/v4/core/util.js
@@ -31038,6 +31227,447 @@ const HooksConfigSchema = schemas_object({
31038
31227
  }).strict()
31039
31228
  }).strict();
31040
31229
 
31230
+ ;// CONCATENATED MODULE: ./src/entities/validation.ts
31231
+ /**
31232
+ * Returns true if `value` is a non-null object (or array) that owns a
31233
+ * `__proto__` key at any nesting level up to MAX_PROTO_SCAN_DEPTH.
31234
+ *
31235
+ * Zod v4.4.2+ accepts and silently strips `__proto__` in `.strict()` mode,
31236
+ * causing non-conforming parsed objects to pass schema validation. Callers
31237
+ * must invoke this guard immediately after JSON.parse() and before any
31238
+ * `.strict()` Zod schema call to ensure such inputs are explicitly rejected.
31239
+ *
31240
+ * Structures deeper than MAX_PROTO_SCAN_DEPTH are conservatively rejected
31241
+ * to prevent unbounded recursion on attacker-controlled input.
31242
+ */ const MAX_PROTO_SCAN_DEPTH = 32;
31243
+ function hasProtoKeyAtDepth(value, depth) {
31244
+ if (depth > MAX_PROTO_SCAN_DEPTH) {
31245
+ return true;
31246
+ }
31247
+ if (typeof value !== "object" || value === null) {
31248
+ return false;
31249
+ }
31250
+ if (Object.hasOwn(value, "__proto__")) {
31251
+ return true;
31252
+ }
31253
+ for (const v of Object.values(value)){
31254
+ if (hasProtoKeyAtDepth(v, depth + 1)) {
31255
+ return true;
31256
+ }
31257
+ }
31258
+ return false;
31259
+ }
31260
+ function hasProtoKey(value) {
31261
+ return hasProtoKeyAtDepth(value, 0);
31262
+ }
31263
+
31264
+ ;// CONCATENATED MODULE: ./src/gateways/log-query.ts
31265
+ // biome-ignore-all lint/style/useNamingConvention: telemetry schema uses snake_case field names
31266
+
31267
+
31268
+
31269
+
31270
+ const DURATION_PATTERN = /^(\d+)([mhd])$/;
31271
+ const MAX_LINE_BYTES = 65_536;
31272
+ const MAX_LINES_PER_FILE = 100_000;
31273
+ const UNIT_MS = {
31274
+ m: 60 * 1000,
31275
+ h: 60 * 60 * 1000,
31276
+ d: 24 * 60 * 60 * 1000
31277
+ };
31278
+ function parseDuration(duration) {
31279
+ const match = DURATION_PATTERN.exec(duration);
31280
+ if (!match) {
31281
+ throw new Error(`Invalid duration format: "${duration}". Expected format: <number><unit> where unit is m, h, or d`);
31282
+ }
31283
+ const value = Number.parseInt(match[1], 10);
31284
+ if (value <= 0) {
31285
+ throw new Error(`Duration must be a positive value, got: "${duration}"`);
31286
+ }
31287
+ const unit = match[2];
31288
+ return value * UNIT_MS[unit];
31289
+ }
31290
+ async function resolveReadEventsDir(env, deps) {
31291
+ const projectRoot = deps.cwd();
31292
+ const defaultDir = (0,external_node_path_namespaceObject.join)(projectRoot, ".agent-shell", "events");
31293
+ const logDir = env.AGENTSHELL_LOG_DIR;
31294
+ if (logDir !== undefined && logDir !== "") {
31295
+ const projectRootReal = await deps.realpath(projectRoot);
31296
+ const candidate = (0,external_node_path_namespaceObject.resolve)(projectRoot, logDir);
31297
+ if (!(0,external_node_path_namespaceObject.isAbsolute)(logDir) && !isWithinProjectRoot(candidate, projectRoot) && !isWithinProjectRoot(candidate, projectRootReal)) {
31298
+ return {
31299
+ dir: "",
31300
+ error: "AGENTSHELL_LOG_DIR resolves outside project root"
31301
+ };
31302
+ }
31303
+ let resolved;
31304
+ try {
31305
+ resolved = await deps.realpath(candidate);
31306
+ } catch (err) {
31307
+ if (isPathNotFoundError(err)) {
31308
+ return {
31309
+ dir: "",
31310
+ error: "AGENTSHELL_LOG_DIR does not exist or is not a directory"
31311
+ };
31312
+ }
31313
+ if (isNameTooLongError(err)) {
31314
+ return {
31315
+ dir: "",
31316
+ error: "AGENTSHELL_LOG_DIR path is too long"
31317
+ };
31318
+ }
31319
+ throw err;
31320
+ }
31321
+ if (!isWithinProjectRoot(resolved, projectRootReal)) {
31322
+ return {
31323
+ dir: "",
31324
+ error: "AGENTSHELL_LOG_DIR resolves outside project root"
31325
+ };
31326
+ }
31327
+ return {
31328
+ dir: resolved
31329
+ };
31330
+ }
31331
+ return {
31332
+ dir: defaultDir
31333
+ };
31334
+ }
31335
+ function findMostRecentFile(fileMtimes) {
31336
+ let mostRecent = fileMtimes[0];
31337
+ for(let i = 1; i < fileMtimes.length; i++){
31338
+ if (fileMtimes[i].mtimeMs > mostRecent.mtimeMs) {
31339
+ mostRecent = fileMtimes[i];
31340
+ }
31341
+ }
31342
+ return mostRecent.file;
31343
+ }
31344
+ function matchesFilters(event, filters, cutoffMs) {
31345
+ if (filters.actor !== undefined && event.actor !== filters.actor) {
31346
+ return false;
31347
+ }
31348
+ if (filters.failures && !(event.event === "script_end" && event.exit_code !== 0)) {
31349
+ return false;
31350
+ }
31351
+ if (filters.script !== undefined && !(event.event === "script_end" && event.script === filters.script)) {
31352
+ return false;
31353
+ }
31354
+ if (cutoffMs !== undefined) {
31355
+ const eventMs = new Date(event.timestamp).getTime();
31356
+ if (eventMs < cutoffMs) {
31357
+ return false;
31358
+ }
31359
+ }
31360
+ return true;
31361
+ }
31362
+ function parseLine(line) {
31363
+ if (Buffer.byteLength(line, "utf-8") > MAX_LINE_BYTES) {
31364
+ return undefined;
31365
+ }
31366
+ let parsed;
31367
+ try {
31368
+ parsed = JSON.parse(line);
31369
+ } catch {
31370
+ return undefined;
31371
+ }
31372
+ if (hasProtoKey(parsed)) {
31373
+ return undefined;
31374
+ }
31375
+ const result = ScriptEventSchema.safeParse(parsed);
31376
+ if (!result.success) {
31377
+ return undefined;
31378
+ }
31379
+ return result.data;
31380
+ }
31381
+ async function queryEvents(eventsDir, filters, deps) {
31382
+ const allFiles = await deps.readdir(eventsDir);
31383
+ const jsonlFiles = allFiles.filter((f)=>f.endsWith(".jsonl"));
31384
+ if (jsonlFiles.length === 0) {
31385
+ return {
31386
+ events: [],
31387
+ truncatedFiles: []
31388
+ };
31389
+ }
31390
+ let filesToRead;
31391
+ if (filters.last === undefined) {
31392
+ const fileMtimes = await Promise.all(jsonlFiles.map(async (file)=>{
31393
+ const filePath = (0,external_node_path_namespaceObject.join)(eventsDir, file);
31394
+ const s = await deps.stat(filePath);
31395
+ return {
31396
+ file,
31397
+ mtimeMs: s.mtimeMs
31398
+ };
31399
+ }));
31400
+ filesToRead = [
31401
+ findMostRecentFile(fileMtimes)
31402
+ ];
31403
+ } else {
31404
+ filesToRead = jsonlFiles;
31405
+ }
31406
+ const cutoffMs = filters.last ? Date.now() - parseDuration(filters.last) : undefined;
31407
+ const events = [];
31408
+ const truncatedFiles = [];
31409
+ for (const file of filesToRead){
31410
+ const filePath = (0,external_node_path_namespaceObject.join)(eventsDir, file);
31411
+ let lineCount = 0;
31412
+ for await (const line of deps.readFileLines(filePath)){
31413
+ if (lineCount >= MAX_LINES_PER_FILE) {
31414
+ deps.writeStderr(`agent-shell: file ${file} exceeds ${MAX_LINES_PER_FILE} lines, truncating\n`);
31415
+ truncatedFiles.push(file);
31416
+ break;
31417
+ }
31418
+ lineCount++;
31419
+ const event = parseLine(line);
31420
+ if (event === undefined) {
31421
+ continue;
31422
+ }
31423
+ if (matchesFilters(event, filters, cutoffMs)) {
31424
+ events.push(event);
31425
+ }
31426
+ }
31427
+ }
31428
+ return {
31429
+ events,
31430
+ truncatedFiles
31431
+ };
31432
+ }
31433
+ async function listSessions(eventsDir, deps) {
31434
+ const allFiles = await deps.readdir(eventsDir);
31435
+ const jsonlFiles = allFiles.filter((f)=>f.endsWith(".jsonl"));
31436
+ if (jsonlFiles.length === 0) {
31437
+ return [];
31438
+ }
31439
+ const summaries = [];
31440
+ for (const file of jsonlFiles){
31441
+ const sessionId = file.replace(/\.jsonl$/, "");
31442
+ const filePath = (0,external_node_path_namespaceObject.join)(eventsDir, file);
31443
+ let firstEvent;
31444
+ let lastEvent;
31445
+ let eventCount = 0;
31446
+ let lineCount = 0;
31447
+ const actorSet = new Set();
31448
+ for await (const line of deps.readFileLines(filePath)){
31449
+ if (lineCount >= MAX_LINES_PER_FILE) {
31450
+ deps.writeStderr(`agent-shell: file ${file} exceeds ${MAX_LINES_PER_FILE} lines, truncating\n`);
31451
+ break;
31452
+ }
31453
+ lineCount++;
31454
+ const event = parseLine(line);
31455
+ if (event === undefined) {
31456
+ continue;
31457
+ }
31458
+ eventCount++;
31459
+ actorSet.add(event.actor);
31460
+ if (firstEvent === undefined || event.timestamp < firstEvent) {
31461
+ firstEvent = event.timestamp;
31462
+ }
31463
+ if (lastEvent === undefined || event.timestamp > lastEvent) {
31464
+ lastEvent = event.timestamp;
31465
+ }
31466
+ }
31467
+ if (eventCount > 0 && firstEvent !== undefined && lastEvent !== undefined) {
31468
+ summaries.push({
31469
+ sessionId,
31470
+ firstEvent,
31471
+ lastEvent,
31472
+ eventCount,
31473
+ actors: [
31474
+ ...actorSet
31475
+ ]
31476
+ });
31477
+ }
31478
+ }
31479
+ summaries.sort((a, b)=>b.lastEvent.localeCompare(a.lastEvent));
31480
+ return summaries;
31481
+ }
31482
+
31483
+ ;// CONCATENATED MODULE: ./src/gateways/run-log.ts
31484
+
31485
+
31486
+
31487
+
31488
+
31489
+
31490
+
31491
+
31492
+ function relativePathUnderRoot(rootDir, path) {
31493
+ const relativePath = (0,external_node_path_namespaceObject.relative)(rootDir, path);
31494
+ if (relativePath === "" || relativePath === ".." || relativePath.startsWith(`..${external_node_path_namespaceObject.sep}`) || (0,external_node_path_namespaceObject.isAbsolute)(relativePath)) {
31495
+ throw new Error("Path resolves outside project root");
31496
+ }
31497
+ return relativePath;
31498
+ }
31499
+ async function* readSafeFileLines(rootDir, path) {
31500
+ const relativePath = relativePathUnderRoot(rootDir, path);
31501
+ await statWithinRoot(rootDir, relativePath);
31502
+ const rl = (0,external_node_readline_namespaceObject.createInterface)({
31503
+ input: (0,external_node_fs_namespaceObject.createReadStream)((0,external_node_path_namespaceObject.join)(rootDir, relativePath)),
31504
+ crlfDelay: Infinity
31505
+ });
31506
+ for await (const line of rl){
31507
+ yield line;
31508
+ }
31509
+ }
31510
+ function createDefaultQueryDeps() {
31511
+ const rootDir = process.cwd();
31512
+ return {
31513
+ readdir: async (path)=>{
31514
+ const relativePath = relativePathUnderRoot(rootDir, path);
31515
+ const entries = await listDirectoryWithinRoot(rootDir, relativePath);
31516
+ return entries.map((entry)=>entry.name);
31517
+ },
31518
+ stat: async (path)=>{
31519
+ const relativePath = relativePathUnderRoot(rootDir, path);
31520
+ const s = await statWithinRoot(rootDir, relativePath);
31521
+ return {
31522
+ mtimeMs: s.mtimeMs
31523
+ };
31524
+ },
31525
+ realpath: (path)=>(0,promises_namespaceObject.realpath)(path),
31526
+ cwd: ()=>process.cwd(),
31527
+ readFileLines: (path)=>readSafeFileLines(rootDir, path),
31528
+ writeStderr: (msg)=>{
31529
+ process.stderr.write(msg);
31530
+ }
31531
+ };
31532
+ }
31533
+ async function runLog(args) {
31534
+ const options = parseLogArgs(args);
31535
+ const deps = createDefaultQueryDeps();
31536
+ if (options.errors && options.errors.length > 0) {
31537
+ for (const err of options.errors){
31538
+ process.stderr.write(`agent-shell: ${err}\n`);
31539
+ }
31540
+ return 1;
31541
+ }
31542
+ const { dir, error } = await resolveReadEventsDir(process.env, deps);
31543
+ if (error) {
31544
+ process.stderr.write(`agent-shell: ${error}\n`);
31545
+ return 1;
31546
+ }
31547
+ if (options.last) {
31548
+ try {
31549
+ parseDuration(options.last);
31550
+ } catch (err) {
31551
+ process.stderr.write(`agent-shell: ${err.message}\n`);
31552
+ return 1;
31553
+ }
31554
+ }
31555
+ try {
31556
+ await deps.readdir(dir);
31557
+ } catch {
31558
+ process.stdout.write("No events recorded yet.\n\n");
31559
+ process.stdout.write("To enable instrumentation, add to your .npmrc:\n");
31560
+ process.stdout.write(" script-shell=./node_modules/.bin/agent-shell\n");
31561
+ return 0;
31562
+ }
31563
+ if (options.listSessions) {
31564
+ const sessions = await listSessions(dir, deps);
31565
+ if (sessions.length === 0) {
31566
+ process.stdout.write("No sessions found.\n");
31567
+ return 0;
31568
+ }
31569
+ process.stdout.write(formatSessionsTable(sessions));
31570
+ process.stdout.write("\n");
31571
+ return 0;
31572
+ }
31573
+ const result = await queryEvents(dir, {
31574
+ actor: options.actor,
31575
+ failures: options.failures || undefined,
31576
+ script: options.script,
31577
+ last: options.last
31578
+ }, deps);
31579
+ if (result.events.length === 0) {
31580
+ process.stdout.write("No matching events found.\n");
31581
+ return 0;
31582
+ }
31583
+ if (options.json) {
31584
+ process.stdout.write(formatEventsJson(result.events));
31585
+ process.stdout.write("\n");
31586
+ } else {
31587
+ process.stdout.write(formatEventsTable(result.events));
31588
+ process.stdout.write("\n");
31589
+ }
31590
+ return 0;
31591
+ }
31592
+
31593
+ ;// CONCATENATED MODULE: ./src/gateways/shim.ts
31594
+
31595
+ const signalCodes = new Map([
31596
+ [
31597
+ "SIGINT",
31598
+ 2
31599
+ ],
31600
+ [
31601
+ "SIGTERM",
31602
+ 15
31603
+ ],
31604
+ [
31605
+ "SIGTSTP",
31606
+ 20
31607
+ ]
31608
+ ]);
31609
+ const FORWARDED_SIGNALS = [
31610
+ "SIGINT",
31611
+ "SIGTERM",
31612
+ "SIGTSTP"
31613
+ ];
31614
+ async function runShim(options) {
31615
+ const startTime = performance.now();
31616
+ return new Promise((resolve)=>{
31617
+ const child = (0,external_node_child_process_namespaceObject.spawn)("/bin/sh", [
31618
+ "-c",
31619
+ options.command
31620
+ ], {
31621
+ stdio: "inherit",
31622
+ detached: true
31623
+ });
31624
+ const handlers = new Map();
31625
+ for (const signal of FORWARDED_SIGNALS){
31626
+ const handler = ()=>{
31627
+ if (child.pid !== undefined) {
31628
+ try {
31629
+ // Kill the entire process group so grandchildren (e.g. sleep spawned
31630
+ // by sh without exec) also receive the signal and release any
31631
+ // inherited pipes, preventing the parent from hanging on 'close'.
31632
+ process.kill(-child.pid, signal);
31633
+ } catch {
31634
+ // Process group may have already exited; fall back to direct kill
31635
+ child.kill(signal);
31636
+ }
31637
+ }
31638
+ };
31639
+ handlers.set(signal, handler);
31640
+ process.on(signal, handler);
31641
+ }
31642
+ child.on("close", async (code, signal)=>{
31643
+ for (const [sig, handler] of handlers){
31644
+ process.removeListener(sig, handler);
31645
+ }
31646
+ const durationMs = performance.now() - startTime;
31647
+ let exitCode;
31648
+ if (signal) {
31649
+ const signalNumber = signalCodes.get(signal) ?? 1;
31650
+ exitCode = 128 + signalNumber;
31651
+ } else {
31652
+ exitCode = code ?? 1;
31653
+ }
31654
+ const result = {
31655
+ exitCode,
31656
+ signal: signal ?? null,
31657
+ durationMs
31658
+ };
31659
+ if (options.onComplete) {
31660
+ try {
31661
+ await options.onComplete(result);
31662
+ } catch {
31663
+ // onComplete errors must not prevent shim result from resolving
31664
+ }
31665
+ }
31666
+ resolve(result);
31667
+ });
31668
+ });
31669
+ }
31670
+
31041
31671
  ;// CONCATENATED MODULE: ./src/lib/actor.ts
31042
31672
  // Best-effort agent detection env vars (Phase 1):
31043
31673
  // - CLAUDE_CODE: Set by Claude Code (`CLAUDE_CODE=1`) in its shell sessions
@@ -31186,31 +31816,6 @@ function captureTags(env) {
31186
31816
  return result;
31187
31817
  }
31188
31818
 
31189
- ;// CONCATENATED MODULE: ./src/lib/path-utils.ts
31190
-
31191
- function isWithinProjectRoot(resolvedPath, projectRoot) {
31192
- const normalizedPath = (0,external_node_path_namespaceObject.resolve)(resolvedPath);
31193
- const normalizedRoot = (0,external_node_path_namespaceObject.resolve)(projectRoot);
31194
- if (normalizedPath === normalizedRoot) return true;
31195
- const rel = (0,external_node_path_namespaceObject.relative)(normalizedRoot, normalizedPath);
31196
- // Outside the root if: empty, exact "..", starts with "../" (or "..\"), or is absolute (different drive on Windows)
31197
- return rel !== "" && rel !== ".." && !rel.startsWith(`..${external_node_path_namespaceObject.sep}`) && !(0,external_node_path_namespaceObject.isAbsolute)(rel);
31198
- }
31199
- function isPathNotFoundError(err) {
31200
- if (typeof err === "object" && err !== null && "code" in err) {
31201
- const { code } = err;
31202
- return code === "ENOENT" || code === "ENOTDIR";
31203
- }
31204
- return false;
31205
- }
31206
- function isNameTooLongError(err) {
31207
- if (typeof err === "object" && err !== null && "code" in err) {
31208
- const { code } = err;
31209
- return code === "ENAMETOOLONG";
31210
- }
31211
- return false;
31212
- }
31213
-
31214
31819
  ;// CONCATENATED MODULE: ./src/gateways/telemetry.ts
31215
31820
  // biome-ignore-all lint/style/useNamingConvention: telemetry schema uses snake_case field names
31216
31821
 
@@ -31470,168 +32075,6 @@ function resolveMode(args, env) {
31470
32075
  };
31471
32076
  }
31472
32077
 
31473
- ;// CONCATENATED MODULE: ./src/lib/sanitize.ts
31474
- /**
31475
- * Escapes ASCII and C1 control characters in error messages before writing
31476
- * to stderr. Replaces each control character with its `\xNN` hex
31477
- * representation to prevent log/terminal injection when errors embed
31478
- * untrusted data.
31479
- */ function sanitizeForStderr(err) {
31480
- const msg = err instanceof Error ? err.message : String(err);
31481
- // biome-ignore lint/suspicious/noControlCharactersInRegex: intentionally matching control characters for sanitization
31482
- return msg.replace(/[\u0000-\u001f\u007f-\u009f]/g, (ch)=>{
31483
- return `\\x${ch.charCodeAt(0).toString(16).padStart(2, "0")}`;
31484
- });
31485
- }
31486
- /**
31487
- * Escapes ASCII and C1 control characters (except newline) in output text.
31488
- * Like sanitizeForStderr but preserves newlines for JSON formatting.
31489
- */ function sanitizeOutput(text) {
31490
- // biome-ignore lint/suspicious/noControlCharactersInRegex: intentionally matching control characters for sanitization
31491
- return text.replace(/[\u0000-\u0009\u000b-\u001f\u007f-\u009f]/g, (ch)=>{
31492
- return `\\x${ch.charCodeAt(0).toString(16).padStart(2, "0")}`;
31493
- });
31494
- }
31495
- /**
31496
- * Sanitizes untrusted values before embedding in prompts.
31497
- * Strips newlines and all backticks that could inject instructions,
31498
- * and truncates to a safe length.
31499
- */ function sanitizePromptValue(value) {
31500
- return value.replace(/[\n\r]/g, " ").replace(/`/g, "").slice(0, 256);
31501
- }
31502
- /**
31503
- * Shell metacharacters that indicate compound or piped commands.
31504
- * Commands containing these are excluded from the allow list because
31505
- * they could mask injection (e.g. `npm test && curl evil`).
31506
- */ const SHELL_METACHAR_PATTERN = /[;|&`><$()\\\n\r]/;
31507
- /**
31508
- * Returns true if the command is non-empty, contains no shell metacharacters,
31509
- * and is safe to include in a policy allow list.
31510
- */ function isSafeCommand(command) {
31511
- const normalized = command.trim();
31512
- if (normalized.length === 0) {
31513
- return false;
31514
- }
31515
- return !SHELL_METACHAR_PATTERN.test(normalized);
31516
- }
31517
-
31518
- ;// CONCATENATED MODULE: ./src/entities/validation.ts
31519
- /**
31520
- * Returns true if `value` is a non-null object (or array) that owns a
31521
- * `__proto__` key at any nesting level up to MAX_PROTO_SCAN_DEPTH.
31522
- *
31523
- * Zod v4.4.2+ accepts and silently strips `__proto__` in `.strict()` mode,
31524
- * causing non-conforming parsed objects to pass schema validation. Callers
31525
- * must invoke this guard immediately after JSON.parse() and before any
31526
- * `.strict()` Zod schema call to ensure such inputs are explicitly rejected.
31527
- *
31528
- * Structures deeper than MAX_PROTO_SCAN_DEPTH are conservatively rejected
31529
- * to prevent unbounded recursion on attacker-controlled input.
31530
- */ const MAX_PROTO_SCAN_DEPTH = 32;
31531
- function hasProtoKeyAtDepth(value, depth) {
31532
- if (depth > MAX_PROTO_SCAN_DEPTH) {
31533
- return true;
31534
- }
31535
- if (typeof value !== "object" || value === null) {
31536
- return false;
31537
- }
31538
- if (Object.hasOwn(value, "__proto__")) {
31539
- return true;
31540
- }
31541
- for (const v of Object.values(value)){
31542
- if (hasProtoKeyAtDepth(v, depth + 1)) {
31543
- return true;
31544
- }
31545
- }
31546
- return false;
31547
- }
31548
- function hasProtoKey(value) {
31549
- return hasProtoKeyAtDepth(value, 0);
31550
- }
31551
-
31552
- ;// CONCATENATED MODULE: ./src/gateways/resolve-sdk.ts
31553
-
31554
-
31555
-
31556
-
31557
- /**
31558
- * Resolves an npm package's ESM entry point from the user's project directory.
31559
- *
31560
- * Bundled CLIs resolve bare specifiers relative to the bundle location, not
31561
- * the user's working directory. This uses `createRequire` anchored at the
31562
- * project root to locate the package, then reads its `package.json` exports
31563
- * map to select the ESM entry that `import()` would use.
31564
- *
31565
- * @returns A file:// URL to the package ESM entry point, or null if not found
31566
- */ function resolveSdkPath(repoRoot, packageName) {
31567
- if (!repoRoot || !(0,external_node_path_namespaceObject.isAbsolute)(repoRoot)) return null;
31568
- if (/^[./]/.test(packageName) || packageName.includes("..")) return null;
31569
- try {
31570
- const projectRequire = (0,external_node_module_namespaceObject.createRequire)((0,external_node_path_namespaceObject.resolve)(repoRoot, "package.json"));
31571
- const cjsResolved = projectRequire.resolve(packageName);
31572
- const esmUrl = findEsmEntry(cjsResolved, packageName);
31573
- return esmUrl ?? (0,external_node_url_namespaceObject.pathToFileURL)(cjsResolved).href;
31574
- } catch {
31575
- return null;
31576
- }
31577
- }
31578
- /**
31579
- * Walks up from a resolved module path to find the package root directory,
31580
- * then extracts the ESM entry point from its exports map.
31581
- */ function findEsmEntry(resolvedPath, packageName) {
31582
- let dir = (0,external_node_path_namespaceObject.dirname)(resolvedPath);
31583
- while(true){
31584
- try {
31585
- const raw = (0,external_node_fs_namespaceObject.readFileSync)((0,external_node_path_namespaceObject.join)(dir, "package.json"), "utf-8");
31586
- const pkg = JSON.parse(raw);
31587
- if (typeof pkg === "object" && pkg !== null && pkg.name === packageName) {
31588
- const esmEntry = extractEsmEntry(pkg);
31589
- const full = (0,external_node_path_namespaceObject.resolve)(dir, esmEntry);
31590
- try {
31591
- return (0,external_node_url_namespaceObject.pathToFileURL)((0,external_node_fs_namespaceObject.realpathSync)(full)).href;
31592
- } catch {
31593
- return null;
31594
- }
31595
- }
31596
- } catch {
31597
- /* no package.json at this level */ }
31598
- const parent = (0,external_node_path_namespaceObject.dirname)(dir);
31599
- if (parent === dir) return null;
31600
- dir = parent;
31601
- }
31602
- }
31603
- /**
31604
- * Extracts the ESM entry point from a parsed package.json object.
31605
- */ function extractEsmEntry(pkgJson) {
31606
- if (typeof pkgJson === "object" && pkgJson !== null) {
31607
- const pkg = pkgJson;
31608
- const esmPath = resolveExportsImportEntry(pkg.exports);
31609
- if (esmPath) return esmPath;
31610
- if (typeof pkg.main === "string" && pkg.main.length > 0) return pkg.main;
31611
- }
31612
- return "index.js";
31613
- }
31614
- /**
31615
- * Navigates the exports map to find the ESM entry. Supports string-shaped
31616
- * exports, string-valued `exports["."]`, `exports["."].import` (string),
31617
- * `exports["."].import.default`, and the sugar form where condition keys
31618
- * (`import`/`require`) appear directly on the exports object.
31619
- */ function resolveExportsImportEntry(exports) {
31620
- if (typeof exports === "string") return exports;
31621
- if (typeof exports !== "object" || exports === null) return null;
31622
- const exportsMap = exports;
31623
- const dotEntry = exportsMap["."];
31624
- if (typeof dotEntry === "string") return dotEntry;
31625
- const conditionSource = typeof dotEntry === "object" && dotEntry !== null && !Array.isArray(dotEntry) ? dotEntry : exportsMap;
31626
- const importEntry = conditionSource.import;
31627
- if (typeof importEntry === "string") return importEntry;
31628
- if (typeof importEntry === "object" && importEntry !== null) {
31629
- const importMap = importEntry;
31630
- if (typeof importMap.default === "string") return importMap.default;
31631
- }
31632
- return null;
31633
- }
31634
-
31635
32078
  ;// CONCATENATED MODULE: ./src/use-cases/copilot-prompt.ts
31636
32079
 
31637
32080
  function formatScriptsSummary(scripts) {
@@ -31726,8 +32169,6 @@ ${miseList}
31726
32169
 
31727
32170
 
31728
32171
 
31729
-
31730
-
31731
32172
  const DEFAULT_MODEL = "claude-sonnet-4-6";
31732
32173
  const MAX_FILE_READ_BYTES = 102_400;
31733
32174
  const MAX_PROJECT_FILE_BYTES = 20 * 1024 * 1024;
@@ -31779,7 +32220,7 @@ const AnalysisResponseSchema = schemas_object({
31779
32220
  /**
31780
32221
  * Reads a project file safely, enforcing path traversal protection
31781
32222
  * and byte-level truncation. Extracted for testability.
31782
- */ async function readProjectFileSafe(repoRoot, pathArg) {
32223
+ */ async function readProjectFileSafe(repoRoot, pathArg, io) {
31783
32224
  if (pathArg.length === 0) {
31784
32225
  return {
31785
32226
  error: "Path is required"
@@ -31796,14 +32237,14 @@ const AnalysisResponseSchema = schemas_object({
31796
32237
  let fileBuffer;
31797
32238
  let truncated = false;
31798
32239
  try {
31799
- const fileStat = await statWithinRoot(repoRoot, relPath);
32240
+ const fileStat = await io.statWithinRoot(repoRoot, relPath);
31800
32241
  truncated = fileStat.size > MAX_FILE_READ_BYTES;
31801
32242
  if (fileStat.size > MAX_PROJECT_FILE_BYTES) {
31802
32243
  return {
31803
32244
  error: "File not found or unreadable"
31804
32245
  };
31805
32246
  }
31806
- fileBuffer = await readBytesWithinRoot(repoRoot, relPath, MAX_PROJECT_FILE_BYTES);
32247
+ fileBuffer = await io.readBytesWithinRoot(repoRoot, relPath, MAX_PROJECT_FILE_BYTES);
31807
32248
  } catch (error) {
31808
32249
  const message = error instanceof Error ? error.message : String(error);
31809
32250
  if (message.includes("symbolic link")) {
@@ -31833,7 +32274,7 @@ const AnalysisResponseSchema = schemas_object({
31833
32274
  * Creates custom tools that allow the Copilot model to read files
31834
32275
  * and validate proposed allow rules. Structured project discovery
31835
32276
  * is handled by the lousy-agents MCP server (connected via mcpServers).
31836
- */ function createCustomTools(repoRoot, defineTool) {
32277
+ */ function createCustomTools(repoRoot, io, defineTool) {
31837
32278
  const readProjectFile = defineTool("read_project_file", {
31838
32279
  description: "Read a file from the project repository. Returns file content (truncated at 100KB). Use to inspect build configs, Dockerfiles, Makefiles, etc.",
31839
32280
  parameters: {
@@ -31849,7 +32290,7 @@ const AnalysisResponseSchema = schemas_object({
31849
32290
  ]
31850
32291
  },
31851
32292
  skipPermission: true,
31852
- handler: (args)=>readProjectFileSafe(repoRoot, args.path ?? "")
32293
+ handler: (args)=>readProjectFileSafe(repoRoot, args.path ?? "", io)
31853
32294
  });
31854
32295
  const validateAllowRule = defineTool("validate_allow_rule", {
31855
32296
  description: "Check whether a proposed allow rule is safe (does not contain shell metacharacters like ;, |, &, `, $, etc.).",
@@ -31900,14 +32341,14 @@ const AnalysisResponseSchema = schemas_object({
31900
32341
  * Falls back gracefully if the SDK or Copilot CLI is not available.
31901
32342
  *
31902
32343
  * @returns Enhanced analysis results, or null if the SDK is unavailable
31903
- */ async function enhanceWithCopilot(scanResult, repoRoot, writeStderr, model = DEFAULT_MODEL) {
32344
+ */ async function enhanceWithCopilot(scanResult, repoRoot, writeStderr, io, model = DEFAULT_MODEL) {
31904
32345
  let importSucceeded = false;
31905
32346
  try {
31906
- const sdkPath = resolveSdkPath(repoRoot, "@github/copilot-sdk");
32347
+ const sdkPath = io.resolveSdkPath(repoRoot, "@github/copilot-sdk");
31907
32348
  const { CopilotClient, defineTool, approveAll } = sdkPath ? await import(/* webpackIgnore: true */ sdkPath) : await __webpack_require__.e(/* import() */ 300).then(__webpack_require__.bind(__webpack_require__, 791));
31908
32349
  importSucceeded = true;
31909
32350
  const client = new CopilotClient();
31910
- const tools = createCustomTools(repoRoot, defineTool);
32351
+ const tools = createCustomTools(repoRoot, io, defineTool);
31911
32352
  try {
31912
32353
  await client.start();
31913
32354
  const session = await client.createSession({
@@ -32017,7 +32458,6 @@ function parseAnalysisResponse(content) {
32017
32458
 
32018
32459
 
32019
32460
 
32020
-
32021
32461
  // Exact-match entries for agent-shell's own commands prevent the preToolUse
32022
32462
  // hook from blocking its sibling hooks. Wildcard entries (ending with *) cover
32023
32463
  // common read-only git commands. The final allow list is sorted alphabetically.
@@ -32202,10 +32642,10 @@ const HOOKS_SUBPATH = ".github/hooks/agent-shell/hooks.json";
32202
32642
  */ async function handlePolicyInit(deps) {
32203
32643
  const repoRoot = deps.getRepositoryRoot();
32204
32644
  deps.writeStdout("Scanning project...\n");
32205
- const scanResult = await scanProject(repoRoot);
32645
+ const scanResult = await deps.scanProject(repoRoot);
32206
32646
  deps.writeStdout(`Discovered: ${scanResult.scripts.length} npm script(s), ` + `${scanResult.workflowCommands.length} workflow command(s), ` + `${scanResult.miseTasks.length} mise task(s), ` + `${scanResult.languages.length} language(s)\n`);
32207
32647
  const policy = generatePolicy(scanResult);
32208
- const enhanced = await enhanceWithCopilot(scanResult, repoRoot, deps.writeStderr, deps.model);
32648
+ const enhanced = await enhanceWithCopilot(scanResult, repoRoot, deps.writeStderr, deps.copilotIo, deps.model);
32209
32649
  if (enhanced !== null) {
32210
32650
  deps.writeStdout("Enhanced with Copilot analysis\n");
32211
32651
  if (enhanced.additionalAllowRules.length > 0) {
@@ -32624,446 +33064,6 @@ async function handleInit(flags, deps) {
32624
33064
  return true;
32625
33065
  }
32626
33066
 
32627
- ;// CONCATENATED MODULE: ./src/gateways/log-query.ts
32628
- // biome-ignore-all lint/style/useNamingConvention: telemetry schema uses snake_case field names
32629
-
32630
-
32631
-
32632
-
32633
- const DURATION_PATTERN = /^(\d+)([mhd])$/;
32634
- const MAX_LINE_BYTES = 65_536;
32635
- const MAX_LINES_PER_FILE = 100_000;
32636
- const UNIT_MS = {
32637
- m: 60 * 1000,
32638
- h: 60 * 60 * 1000,
32639
- d: 24 * 60 * 60 * 1000
32640
- };
32641
- function parseDuration(duration) {
32642
- const match = DURATION_PATTERN.exec(duration);
32643
- if (!match) {
32644
- throw new Error(`Invalid duration format: "${duration}". Expected format: <number><unit> where unit is m, h, or d`);
32645
- }
32646
- const value = Number.parseInt(match[1], 10);
32647
- if (value <= 0) {
32648
- throw new Error(`Duration must be a positive value, got: "${duration}"`);
32649
- }
32650
- const unit = match[2];
32651
- return value * UNIT_MS[unit];
32652
- }
32653
- async function resolveReadEventsDir(env, deps) {
32654
- const projectRoot = deps.cwd();
32655
- const defaultDir = (0,external_node_path_namespaceObject.join)(projectRoot, ".agent-shell", "events");
32656
- const logDir = env.AGENTSHELL_LOG_DIR;
32657
- if (logDir !== undefined && logDir !== "") {
32658
- const projectRootReal = await deps.realpath(projectRoot);
32659
- const candidate = (0,external_node_path_namespaceObject.resolve)(projectRoot, logDir);
32660
- if (!(0,external_node_path_namespaceObject.isAbsolute)(logDir) && !isWithinProjectRoot(candidate, projectRoot) && !isWithinProjectRoot(candidate, projectRootReal)) {
32661
- return {
32662
- dir: "",
32663
- error: "AGENTSHELL_LOG_DIR resolves outside project root"
32664
- };
32665
- }
32666
- let resolved;
32667
- try {
32668
- resolved = await deps.realpath(candidate);
32669
- } catch (err) {
32670
- if (isPathNotFoundError(err)) {
32671
- return {
32672
- dir: "",
32673
- error: "AGENTSHELL_LOG_DIR does not exist or is not a directory"
32674
- };
32675
- }
32676
- if (isNameTooLongError(err)) {
32677
- return {
32678
- dir: "",
32679
- error: "AGENTSHELL_LOG_DIR path is too long"
32680
- };
32681
- }
32682
- throw err;
32683
- }
32684
- if (!isWithinProjectRoot(resolved, projectRootReal)) {
32685
- return {
32686
- dir: "",
32687
- error: "AGENTSHELL_LOG_DIR resolves outside project root"
32688
- };
32689
- }
32690
- return {
32691
- dir: resolved
32692
- };
32693
- }
32694
- return {
32695
- dir: defaultDir
32696
- };
32697
- }
32698
- function findMostRecentFile(fileMtimes) {
32699
- let mostRecent = fileMtimes[0];
32700
- for(let i = 1; i < fileMtimes.length; i++){
32701
- if (fileMtimes[i].mtimeMs > mostRecent.mtimeMs) {
32702
- mostRecent = fileMtimes[i];
32703
- }
32704
- }
32705
- return mostRecent.file;
32706
- }
32707
- function matchesFilters(event, filters, cutoffMs) {
32708
- if (filters.actor !== undefined && event.actor !== filters.actor) {
32709
- return false;
32710
- }
32711
- if (filters.failures && !(event.event === "script_end" && event.exit_code !== 0)) {
32712
- return false;
32713
- }
32714
- if (filters.script !== undefined && !(event.event === "script_end" && event.script === filters.script)) {
32715
- return false;
32716
- }
32717
- if (cutoffMs !== undefined) {
32718
- const eventMs = new Date(event.timestamp).getTime();
32719
- if (eventMs < cutoffMs) {
32720
- return false;
32721
- }
32722
- }
32723
- return true;
32724
- }
32725
- function parseLine(line) {
32726
- if (Buffer.byteLength(line, "utf-8") > MAX_LINE_BYTES) {
32727
- return undefined;
32728
- }
32729
- let parsed;
32730
- try {
32731
- parsed = JSON.parse(line);
32732
- } catch {
32733
- return undefined;
32734
- }
32735
- if (hasProtoKey(parsed)) {
32736
- return undefined;
32737
- }
32738
- const result = ScriptEventSchema.safeParse(parsed);
32739
- if (!result.success) {
32740
- return undefined;
32741
- }
32742
- return result.data;
32743
- }
32744
- async function queryEvents(eventsDir, filters, deps) {
32745
- const allFiles = await deps.readdir(eventsDir);
32746
- const jsonlFiles = allFiles.filter((f)=>f.endsWith(".jsonl"));
32747
- if (jsonlFiles.length === 0) {
32748
- return {
32749
- events: [],
32750
- truncatedFiles: []
32751
- };
32752
- }
32753
- let filesToRead;
32754
- if (filters.last === undefined) {
32755
- const fileMtimes = await Promise.all(jsonlFiles.map(async (file)=>{
32756
- const filePath = (0,external_node_path_namespaceObject.join)(eventsDir, file);
32757
- const s = await deps.stat(filePath);
32758
- return {
32759
- file,
32760
- mtimeMs: s.mtimeMs
32761
- };
32762
- }));
32763
- filesToRead = [
32764
- findMostRecentFile(fileMtimes)
32765
- ];
32766
- } else {
32767
- filesToRead = jsonlFiles;
32768
- }
32769
- const cutoffMs = filters.last ? Date.now() - parseDuration(filters.last) : undefined;
32770
- const events = [];
32771
- const truncatedFiles = [];
32772
- for (const file of filesToRead){
32773
- const filePath = (0,external_node_path_namespaceObject.join)(eventsDir, file);
32774
- let lineCount = 0;
32775
- for await (const line of deps.readFileLines(filePath)){
32776
- if (lineCount >= MAX_LINES_PER_FILE) {
32777
- deps.writeStderr(`agent-shell: file ${file} exceeds ${MAX_LINES_PER_FILE} lines, truncating\n`);
32778
- truncatedFiles.push(file);
32779
- break;
32780
- }
32781
- lineCount++;
32782
- const event = parseLine(line);
32783
- if (event === undefined) {
32784
- continue;
32785
- }
32786
- if (matchesFilters(event, filters, cutoffMs)) {
32787
- events.push(event);
32788
- }
32789
- }
32790
- }
32791
- return {
32792
- events,
32793
- truncatedFiles
32794
- };
32795
- }
32796
- async function listSessions(eventsDir, deps) {
32797
- const allFiles = await deps.readdir(eventsDir);
32798
- const jsonlFiles = allFiles.filter((f)=>f.endsWith(".jsonl"));
32799
- if (jsonlFiles.length === 0) {
32800
- return [];
32801
- }
32802
- const summaries = [];
32803
- for (const file of jsonlFiles){
32804
- const sessionId = file.replace(/\.jsonl$/, "");
32805
- const filePath = (0,external_node_path_namespaceObject.join)(eventsDir, file);
32806
- let firstEvent;
32807
- let lastEvent;
32808
- let eventCount = 0;
32809
- let lineCount = 0;
32810
- const actorSet = new Set();
32811
- for await (const line of deps.readFileLines(filePath)){
32812
- if (lineCount >= MAX_LINES_PER_FILE) {
32813
- deps.writeStderr(`agent-shell: file ${file} exceeds ${MAX_LINES_PER_FILE} lines, truncating\n`);
32814
- break;
32815
- }
32816
- lineCount++;
32817
- const event = parseLine(line);
32818
- if (event === undefined) {
32819
- continue;
32820
- }
32821
- eventCount++;
32822
- actorSet.add(event.actor);
32823
- if (firstEvent === undefined || event.timestamp < firstEvent) {
32824
- firstEvent = event.timestamp;
32825
- }
32826
- if (lastEvent === undefined || event.timestamp > lastEvent) {
32827
- lastEvent = event.timestamp;
32828
- }
32829
- }
32830
- if (eventCount > 0 && firstEvent !== undefined && lastEvent !== undefined) {
32831
- summaries.push({
32832
- sessionId,
32833
- firstEvent,
32834
- lastEvent,
32835
- eventCount,
32836
- actors: [
32837
- ...actorSet
32838
- ]
32839
- });
32840
- }
32841
- }
32842
- summaries.sort((a, b)=>b.lastEvent.localeCompare(a.lastEvent));
32843
- return summaries;
32844
- }
32845
-
32846
- ;// CONCATENATED MODULE: ./src/lib/log-format.ts
32847
-
32848
- function formatDuration(ms) {
32849
- if (ms < 1000) return `${Math.round(ms)}ms`;
32850
- if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`;
32851
- return `${(ms / 60000).toFixed(1)}m`;
32852
- }
32853
- function formatTimestamp(iso) {
32854
- const d = new Date(iso);
32855
- return d.toISOString().replace("T", " ").replace(/\.\d{3}Z$/, "");
32856
- }
32857
- function truncateCommand(command, maxLen) {
32858
- if (command.length <= maxLen) return command;
32859
- return `${command.slice(0, maxLen - 3)}...`;
32860
- }
32861
- function padRight(str, width) {
32862
- if (str.length >= width) return str;
32863
- return str + " ".repeat(width - str.length);
32864
- }
32865
- const COL_TIMESTAMP = 21;
32866
- const COL_SCRIPT = 9;
32867
- const COL_ACTOR = 13;
32868
- const COL_EXIT = 6;
32869
- const COL_DURATION = 10;
32870
- const MAX_COMMAND_LEN = 50;
32871
- function formatEventsTable(events) {
32872
- const header = padRight("TIMESTAMP", COL_TIMESTAMP) + padRight("SCRIPT", COL_SCRIPT) + padRight("ACTOR", COL_ACTOR) + padRight("EXIT", COL_EXIT) + padRight("DURATION", COL_DURATION) + "COMMAND";
32873
- const rows = events.map((event)=>{
32874
- const timestamp = formatTimestamp(event.timestamp);
32875
- const script = event.event === "script_end" ? event.script ?? "-" : event.event === "tool_use" ? sanitizeOutput(event.tool_name) : "-";
32876
- const actor = event.actor;
32877
- const exitCode = event.event === "script_end" ? String(event.exit_code) : "-";
32878
- const duration = event.event === "script_end" ? formatDuration(event.duration_ms) : "-";
32879
- const command = truncateCommand(event.command, MAX_COMMAND_LEN);
32880
- return padRight(timestamp, COL_TIMESTAMP) + padRight(script, COL_SCRIPT) + padRight(actor, COL_ACTOR) + padRight(exitCode, COL_EXIT) + padRight(duration, COL_DURATION) + command;
32881
- });
32882
- return [
32883
- header,
32884
- ...rows
32885
- ].join("\n");
32886
- }
32887
- function formatSessionsTable(sessions) {
32888
- const colSession = 11;
32889
- const colFirstEvent = 21;
32890
- const colLastEvent = 21;
32891
- const colEvents = 9;
32892
- const header = padRight("SESSION", colSession) + padRight("FIRST EVENT", colFirstEvent) + padRight("LAST EVENT", colLastEvent) + padRight("EVENTS", colEvents) + "ACTORS";
32893
- const rows = sessions.map((s)=>{
32894
- const sessionTrunc = s.sessionId.slice(0, 8);
32895
- const firstEvent = formatTimestamp(s.firstEvent);
32896
- const lastEvent = formatTimestamp(s.lastEvent);
32897
- const eventCount = String(s.eventCount);
32898
- const actors = s.actors.join(", ");
32899
- return padRight(sessionTrunc, colSession) + padRight(firstEvent, colFirstEvent) + padRight(lastEvent, colLastEvent) + padRight(eventCount, colEvents) + actors;
32900
- });
32901
- return [
32902
- header,
32903
- ...rows
32904
- ].join("\n");
32905
- }
32906
- function formatEventsJson(events) {
32907
- return JSON.stringify(events, null, 2);
32908
- }
32909
-
32910
- ;// CONCATENATED MODULE: ./src/use-cases/log-command.ts
32911
-
32912
-
32913
-
32914
-
32915
-
32916
-
32917
-
32918
- function parseLogArgs(args) {
32919
- const options = {
32920
- failures: false,
32921
- listSessions: false,
32922
- json: false
32923
- };
32924
- let i = 0;
32925
- while(i < args.length){
32926
- const arg = args[i];
32927
- switch(arg){
32928
- case "--last":
32929
- if (i + 1 < args.length) {
32930
- options.last = args[++i];
32931
- } else {
32932
- options.errors = options.errors ?? [];
32933
- options.errors.push("--last requires a value (e.g., 30m, 1h, 1d)");
32934
- }
32935
- break;
32936
- case "--actor":
32937
- if (i + 1 < args.length) {
32938
- options.actor = args[++i];
32939
- } else {
32940
- options.errors = options.errors ?? [];
32941
- options.errors.push("--actor requires a value");
32942
- }
32943
- break;
32944
- case "--failures":
32945
- options.failures = true;
32946
- break;
32947
- case "--script":
32948
- if (i + 1 < args.length) {
32949
- options.script = args[++i];
32950
- } else {
32951
- options.errors = options.errors ?? [];
32952
- options.errors.push("--script requires a value");
32953
- }
32954
- break;
32955
- case "--list-sessions":
32956
- options.listSessions = true;
32957
- break;
32958
- case "--json":
32959
- options.json = true;
32960
- break;
32961
- }
32962
- i++;
32963
- }
32964
- return options;
32965
- }
32966
- function relativePathUnderRoot(rootDir, path) {
32967
- const relativePath = (0,external_node_path_namespaceObject.relative)(rootDir, path);
32968
- if (relativePath === "" || relativePath === ".." || relativePath.startsWith(`..${external_node_path_namespaceObject.sep}`) || (0,external_node_path_namespaceObject.isAbsolute)(relativePath)) {
32969
- throw new Error("Path resolves outside project root");
32970
- }
32971
- return relativePath;
32972
- }
32973
- async function* readSafeFileLines(rootDir, path) {
32974
- const relativePath = relativePathUnderRoot(rootDir, path);
32975
- await statWithinRoot(rootDir, relativePath);
32976
- const rl = (0,external_node_readline_namespaceObject.createInterface)({
32977
- input: (0,external_node_fs_namespaceObject.createReadStream)((0,external_node_path_namespaceObject.join)(rootDir, relativePath)),
32978
- crlfDelay: Infinity
32979
- });
32980
- for await (const line of rl){
32981
- yield line;
32982
- }
32983
- }
32984
- function createDefaultQueryDeps() {
32985
- const rootDir = process.cwd();
32986
- return {
32987
- readdir: async (path)=>{
32988
- const relativePath = relativePathUnderRoot(rootDir, path);
32989
- const entries = await listDirectoryWithinRoot(rootDir, relativePath);
32990
- return entries.map((entry)=>entry.name);
32991
- },
32992
- stat: async (path)=>{
32993
- const relativePath = relativePathUnderRoot(rootDir, path);
32994
- const s = await statWithinRoot(rootDir, relativePath);
32995
- return {
32996
- mtimeMs: s.mtimeMs
32997
- };
32998
- },
32999
- realpath: (path)=>(0,promises_namespaceObject.realpath)(path),
33000
- cwd: ()=>process.cwd(),
33001
- readFileLines: (path)=>readSafeFileLines(rootDir, path),
33002
- writeStderr: (msg)=>{
33003
- process.stderr.write(msg);
33004
- }
33005
- };
33006
- }
33007
- async function runLog(args) {
33008
- const options = parseLogArgs(args);
33009
- const deps = createDefaultQueryDeps();
33010
- if (options.errors && options.errors.length > 0) {
33011
- for (const err of options.errors){
33012
- process.stderr.write(`agent-shell: ${err}\n`);
33013
- }
33014
- return 1;
33015
- }
33016
- const { dir, error } = await resolveReadEventsDir(process.env, deps);
33017
- if (error) {
33018
- process.stderr.write(`agent-shell: ${error}\n`);
33019
- return 1;
33020
- }
33021
- if (options.last) {
33022
- try {
33023
- parseDuration(options.last);
33024
- } catch (err) {
33025
- process.stderr.write(`agent-shell: ${err.message}\n`);
33026
- return 1;
33027
- }
33028
- }
33029
- try {
33030
- await deps.readdir(dir);
33031
- } catch {
33032
- process.stdout.write("No events recorded yet.\n\n");
33033
- process.stdout.write("To enable instrumentation, add to your .npmrc:\n");
33034
- process.stdout.write(" script-shell=./node_modules/.bin/agent-shell\n");
33035
- return 0;
33036
- }
33037
- if (options.listSessions) {
33038
- const sessions = await listSessions(dir, deps);
33039
- if (sessions.length === 0) {
33040
- process.stdout.write("No sessions found.\n");
33041
- return 0;
33042
- }
33043
- process.stdout.write(formatSessionsTable(sessions));
33044
- process.stdout.write("\n");
33045
- return 0;
33046
- }
33047
- const result = await queryEvents(dir, {
33048
- actor: options.actor,
33049
- failures: options.failures || undefined,
33050
- script: options.script,
33051
- last: options.last
33052
- }, deps);
33053
- if (result.events.length === 0) {
33054
- process.stdout.write("No matching events found.\n");
33055
- return 0;
33056
- }
33057
- if (options.json) {
33058
- process.stdout.write(formatEventsJson(result.events));
33059
- process.stdout.write("\n");
33060
- } else {
33061
- process.stdout.write(formatEventsTable(result.events));
33062
- process.stdout.write("\n");
33063
- }
33064
- return 0;
33065
- }
33066
-
33067
33067
  ;// CONCATENATED MODULE: ./src/use-cases/policy.ts
33068
33068
 
33069
33069
 
@@ -33226,7 +33226,6 @@ async function loadPolicy(env, deps) {
33226
33226
 
33227
33227
 
33228
33228
 
33229
-
33230
33229
  const TERMINAL_TOOLS = new Set([
33231
33230
  "bash",
33232
33231
  "zsh",
@@ -33252,7 +33251,7 @@ const TELEMETRY_TIMEOUT_MS = 5_000;
33252
33251
  async function tryEmitTelemetry(deps, command, decision, matchedRule) {
33253
33252
  try {
33254
33253
  const repoRoot = deps.policyDeps.getRepositoryRoot();
33255
- const emission = emitPolicyDecisionEvent({
33254
+ const emission = deps.emitPolicyDecisionEvent({
33256
33255
  command,
33257
33256
  decision,
33258
33257
  matched_rule: matchedRule,
@@ -33357,7 +33356,6 @@ async function handlePolicyCheck(deps) {
33357
33356
  // biome-ignore-all lint/style/useNamingConvention: telemetry schema uses snake_case field names
33358
33357
 
33359
33358
 
33360
-
33361
33359
  const record_TERMINAL_TOOLS = new Set([
33362
33360
  "bash",
33363
33361
  "zsh",
@@ -33449,7 +33447,7 @@ async function handleRecord(deps) {
33449
33447
  const command = record_TERMINAL_TOOLS.has(toolName) ? extractTerminalCommand(toolArgs) : "";
33450
33448
  try {
33451
33449
  const repoRoot = deps.getRepositoryRoot();
33452
- await emitToolUseEvent({
33450
+ await deps.emitToolUseEvent({
33453
33451
  tool_name: toolName,
33454
33452
  command,
33455
33453
  env: deps.env,
@@ -33480,6 +33478,7 @@ async function handleRecord(deps) {
33480
33478
 
33481
33479
 
33482
33480
 
33481
+
33483
33482
  const VERSION = "0.1.0";
33484
33483
  const USAGE = `Usage: agent-shell -c <command>
33485
33484
  agent-shell init [--flight-recorder] [--policy] [--no-flight-recorder] [--no-policy]
@@ -33527,7 +33526,8 @@ async function main() {
33527
33526
  readFileWithinRoot: (rootDir, relativePath, maxBytes)=>readTextWithinRoot(rootDir, relativePath, maxBytes),
33528
33527
  getRepositoryRoot
33529
33528
  },
33530
- telemetryDeps: createDefaultDeps()
33529
+ telemetryDeps: createDefaultDeps(),
33530
+ emitPolicyDecisionEvent: emitPolicyDecisionEvent
33531
33531
  });
33532
33532
  // Use exitCode + return (not process.exit) so pending stdout writes
33533
33533
  // from writeStdout can drain before the process terminates.
@@ -33542,6 +33542,12 @@ async function main() {
33542
33542
  getRepositoryRoot,
33543
33543
  writeStdout: (data)=>process.stdout.write(data),
33544
33544
  writeStderr: (data)=>process.stderr.write(data),
33545
+ scanProject: (dir)=>scanProject(dir),
33546
+ copilotIo: {
33547
+ resolveSdkPath: resolveSdkPath,
33548
+ statWithinRoot: statWithinRoot,
33549
+ readBytesWithinRoot: readBytesWithinRoot
33550
+ },
33545
33551
  model: mode.model
33546
33552
  });
33547
33553
  process.exitCode = 0;
@@ -33560,7 +33566,8 @@ async function main() {
33560
33566
  writeStderr: (data)=>process.stderr.write(data),
33561
33567
  env: process.env,
33562
33568
  telemetryDeps: createDefaultDeps(),
33563
- getRepositoryRoot
33569
+ getRepositoryRoot,
33570
+ emitToolUseEvent: emitToolUseEvent
33564
33571
  });
33565
33572
  } catch (err) {
33566
33573
  // Log unexpected exceptions but don't change exit code
@@ -33826,4 +33833,4 @@ if (installedChunkData !== 0) { // 0 means "already installed".'
33826
33833
  // module factories are used so entry inlining is disabled
33827
33834
  // startup
33828
33835
  // Load entry module and return exports
33829
- var __webpack_exports__ = __webpack_require__(317);
33836
+ var __webpack_exports__ = __webpack_require__(620);