@lousy-agents/agent-shell 5.22.26 → 5.22.28

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 +157 -100
  2. package/package.json +1 -1
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
- 71(__unused_rspack_module, __unused_rspack___webpack_exports__, __webpack_require__) {
5
+ 444(__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");
@@ -57,8 +57,155 @@ const external_node_readline_namespaceObject = __rspack_createRequire_require("n
57
57
  return !SHELL_METACHAR_PATTERN.test(normalized);
58
58
  }
59
59
 
60
+ ;// CONCATENATED MODULE: external "node:fs"
61
+ const external_node_fs_namespaceObject = __rspack_createRequire_require("node:fs");
62
+ ;// CONCATENATED MODULE: external "node:module"
63
+ const external_node_module_namespaceObject = __rspack_createRequire_require("node:module");
60
64
  ;// CONCATENATED MODULE: external "node:path"
61
65
  const external_node_path_namespaceObject = __rspack_createRequire_require("node:path");
66
+ ;// CONCATENATED MODULE: external "node:url"
67
+ const external_node_url_namespaceObject = __rspack_createRequire_require("node:url");
68
+ ;// CONCATENATED MODULE: ./src/gateways/resolve-sdk.ts
69
+
70
+
71
+
72
+
73
+ /**
74
+ * Resolves an npm package's ESM entry point from the user's project directory.
75
+ *
76
+ * Bundled CLIs resolve bare specifiers relative to the bundle location, not
77
+ * the user's working directory. This uses `createRequire` anchored at the
78
+ * project root to locate the package, then reads its `package.json` exports
79
+ * map to select the ESM entry that `import()` would use.
80
+ *
81
+ * @returns A file:// URL to the package ESM entry point, or null if not found
82
+ */ function resolve_sdk_resolveSdkPath(repoRoot, packageName) {
83
+ if (!repoRoot || !(0,external_node_path_namespaceObject.isAbsolute)(repoRoot)) return null;
84
+ if (/^[./]/.test(packageName) || packageName.includes("..")) return null;
85
+ try {
86
+ const projectRequire = (0,external_node_module_namespaceObject.createRequire)((0,external_node_path_namespaceObject.resolve)(repoRoot, "package.json"));
87
+ const cjsResolved = projectRequire.resolve(packageName);
88
+ const esmUrl = findEsmEntry(cjsResolved, packageName);
89
+ return esmUrl ?? (0,external_node_url_namespaceObject.pathToFileURL)(cjsResolved).href;
90
+ } catch {
91
+ return null;
92
+ }
93
+ }
94
+ /**
95
+ * Walks up from a resolved module path to find the package root directory,
96
+ * then extracts the ESM entry point from its exports map.
97
+ */ function findEsmEntry(resolvedPath, packageName) {
98
+ let dir = (0,external_node_path_namespaceObject.dirname)(resolvedPath);
99
+ while(true){
100
+ try {
101
+ const raw = (0,external_node_fs_namespaceObject.readFileSync)((0,external_node_path_namespaceObject.join)(dir, "package.json"), "utf-8");
102
+ const pkg = JSON.parse(raw);
103
+ if (typeof pkg === "object" && pkg !== null && pkg.name === packageName) {
104
+ const esmEntry = extractEsmEntry(pkg);
105
+ const full = (0,external_node_path_namespaceObject.resolve)(dir, esmEntry);
106
+ try {
107
+ return (0,external_node_url_namespaceObject.pathToFileURL)((0,external_node_fs_namespaceObject.realpathSync)(full)).href;
108
+ } catch {
109
+ return null;
110
+ }
111
+ }
112
+ } catch {
113
+ /* no package.json at this level */ }
114
+ const parent = (0,external_node_path_namespaceObject.dirname)(dir);
115
+ if (parent === dir) return null;
116
+ dir = parent;
117
+ }
118
+ }
119
+ /**
120
+ * Extracts the ESM entry point from a parsed package.json object.
121
+ */ function extractEsmEntry(pkgJson) {
122
+ if (typeof pkgJson === "object" && pkgJson !== null) {
123
+ const pkg = pkgJson;
124
+ const esmPath = resolveExportsImportEntry(pkg.exports);
125
+ if (esmPath) return esmPath;
126
+ if (typeof pkg.main === "string" && pkg.main.length > 0) return pkg.main;
127
+ }
128
+ return "index.js";
129
+ }
130
+ /**
131
+ * Navigates the exports map to find the ESM entry. Supports string-shaped
132
+ * exports, string-valued `exports["."]`, `exports["."].import` (string),
133
+ * `exports["."].import.default`, and the sugar form where condition keys
134
+ * (`import`/`require`) appear directly on the exports object.
135
+ */ function resolveExportsImportEntry(exports) {
136
+ if (typeof exports === "string") return exports;
137
+ if (typeof exports !== "object" || exports === null) return null;
138
+ const exportsMap = exports;
139
+ const dotEntry = exportsMap["."];
140
+ if (typeof dotEntry === "string") return dotEntry;
141
+ const conditionSource = typeof dotEntry === "object" && dotEntry !== null && !Array.isArray(dotEntry) ? dotEntry : exportsMap;
142
+ const importEntry = conditionSource.import;
143
+ if (typeof importEntry === "string") return importEntry;
144
+ if (typeof importEntry === "object" && importEntry !== null) {
145
+ const importMap = importEntry;
146
+ if (typeof importMap.default === "string") return importMap.default;
147
+ }
148
+ return null;
149
+ }
150
+
151
+ ;// CONCATENATED MODULE: ./src/gateways/copilot-sdk-loader.ts
152
+
153
+ const SDK_PACKAGE = "@github/copilot-sdk";
154
+ /**
155
+ * Imports the SDK from the project's own copy when there is one. The bare
156
+ * package name is the fallback, kept as a literal so the bundler leaves it as
157
+ * an external import.
158
+ */ async function importSdkModule(sdkPath) {
159
+ return sdkPath ? await import(/* webpackIgnore: true */ sdkPath) : await __webpack_require__.e(/* import() */ 300).then(__webpack_require__.bind(__webpack_require__, 791));
160
+ }
161
+ const CLIENT_METHODS = [
162
+ "start",
163
+ "stop",
164
+ "createSession"
165
+ ];
166
+ /**
167
+ * Whether an object a constructor built has the methods the analysis calls on a
168
+ * client. A constructor always yields an object, so nothing else needs checking.
169
+ */ function isClientHandle(value) {
170
+ return CLIENT_METHODS.every((method)=>typeof Reflect.get(value, method) === "function");
171
+ }
172
+ function exportOf(sdkModule, name) {
173
+ return typeof sdkModule === "object" && sdkModule !== null ? Reflect.get(sdkModule, name) : undefined;
174
+ }
175
+ /**
176
+ * Wraps the SDK module in the shape the use case expects. A module that lacks
177
+ * an export fails when that export is first used, not when it is loaded.
178
+ */ function describeSdk(sdkModule) {
179
+ const clientClass = exportOf(sdkModule, "CopilotClient");
180
+ const defineTool = exportOf(sdkModule, "defineTool");
181
+ return {
182
+ createClient: ()=>{
183
+ if (typeof clientClass !== "function") {
184
+ throw new TypeError(`${SDK_PACKAGE} does not export a CopilotClient class`);
185
+ }
186
+ const client = Reflect.construct(clientClass, []);
187
+ if (!isClientHandle(client)) {
188
+ throw new TypeError(`${SDK_PACKAGE}'s CopilotClient did not produce a client with start, stop and createSession`);
189
+ }
190
+ return client;
191
+ },
192
+ defineTool: (name, config)=>{
193
+ if (typeof defineTool !== "function") {
194
+ throw new TypeError(`${SDK_PACKAGE} does not export a defineTool function`);
195
+ }
196
+ return defineTool(name, config);
197
+ },
198
+ approveAll: exportOf(sdkModule, "approveAll")
199
+ };
200
+ }
201
+ /**
202
+ * Creates the function the use case calls to load @github/copilot-sdk, an
203
+ * optional peer dependency that may not be installed.
204
+ */ function createCopilotSdkLoader(deps = {}) {
205
+ const resolveSdkPath = deps.resolveSdkPath ?? resolve_sdk_resolveSdkPath;
206
+ return async (repoRoot)=>describeSdk(await importSdkModule(resolveSdkPath(repoRoot, SDK_PACKAGE)));
207
+ }
208
+
62
209
  ;// CONCATENATED MODULE: ./src/gateways/git-utils.ts
63
210
 
64
211
 
@@ -157,8 +304,6 @@ function isNoReplaceUnsupported(error) {
157
304
  error.details?.capability === "rename-noreplace";
158
305
  }
159
306
 
160
- ;// CONCATENATED MODULE: external "node:fs"
161
- const external_node_fs_namespaceObject = __rspack_createRequire_require("node:fs");
162
307
  ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/exact-identity.js
163
308
 
164
309
 
@@ -227,8 +372,6 @@ function resolveCopyCloneMode(mode, defaultMode) {
227
372
 
228
373
  ;// CONCATENATED MODULE: external "node:async_hooks"
229
374
  const external_node_async_hooks_namespaceObject = __rspack_createRequire_require("node:async_hooks");
230
- ;// CONCATENATED MODULE: external "node:module"
231
- const external_node_module_namespaceObject = __rspack_createRequire_require("node:module");
232
375
  ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/native-binding.js
233
376
 
234
377
  function captureNativeFdClose(binding) {
@@ -3594,8 +3737,6 @@ function __resetNativeFallbackWarningsForTest() {
3594
3737
  warnedFeatures.clear();
3595
3738
  }
3596
3739
 
3597
- ;// CONCATENATED MODULE: external "node:url"
3598
- const external_node_url_namespaceObject = __rspack_createRequire_require("node:url");
3599
3740
  ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/permission-exec.js
3600
3741
 
3601
3742
 
@@ -22164,89 +22305,6 @@ async function detectLanguages(targetDir) {
22164
22305
  };
22165
22306
  }
22166
22307
 
22167
- ;// CONCATENATED MODULE: ./src/gateways/resolve-sdk.ts
22168
-
22169
-
22170
-
22171
-
22172
- /**
22173
- * Resolves an npm package's ESM entry point from the user's project directory.
22174
- *
22175
- * Bundled CLIs resolve bare specifiers relative to the bundle location, not
22176
- * the user's working directory. This uses `createRequire` anchored at the
22177
- * project root to locate the package, then reads its `package.json` exports
22178
- * map to select the ESM entry that `import()` would use.
22179
- *
22180
- * @returns A file:// URL to the package ESM entry point, or null if not found
22181
- */ function resolveSdkPath(repoRoot, packageName) {
22182
- if (!repoRoot || !(0,external_node_path_namespaceObject.isAbsolute)(repoRoot)) return null;
22183
- if (/^[./]/.test(packageName) || packageName.includes("..")) return null;
22184
- try {
22185
- const projectRequire = (0,external_node_module_namespaceObject.createRequire)((0,external_node_path_namespaceObject.resolve)(repoRoot, "package.json"));
22186
- const cjsResolved = projectRequire.resolve(packageName);
22187
- const esmUrl = findEsmEntry(cjsResolved, packageName);
22188
- return esmUrl ?? (0,external_node_url_namespaceObject.pathToFileURL)(cjsResolved).href;
22189
- } catch {
22190
- return null;
22191
- }
22192
- }
22193
- /**
22194
- * Walks up from a resolved module path to find the package root directory,
22195
- * then extracts the ESM entry point from its exports map.
22196
- */ function findEsmEntry(resolvedPath, packageName) {
22197
- let dir = (0,external_node_path_namespaceObject.dirname)(resolvedPath);
22198
- while(true){
22199
- try {
22200
- const raw = (0,external_node_fs_namespaceObject.readFileSync)((0,external_node_path_namespaceObject.join)(dir, "package.json"), "utf-8");
22201
- const pkg = JSON.parse(raw);
22202
- if (typeof pkg === "object" && pkg !== null && pkg.name === packageName) {
22203
- const esmEntry = extractEsmEntry(pkg);
22204
- const full = (0,external_node_path_namespaceObject.resolve)(dir, esmEntry);
22205
- try {
22206
- return (0,external_node_url_namespaceObject.pathToFileURL)((0,external_node_fs_namespaceObject.realpathSync)(full)).href;
22207
- } catch {
22208
- return null;
22209
- }
22210
- }
22211
- } catch {
22212
- /* no package.json at this level */ }
22213
- const parent = (0,external_node_path_namespaceObject.dirname)(dir);
22214
- if (parent === dir) return null;
22215
- dir = parent;
22216
- }
22217
- }
22218
- /**
22219
- * Extracts the ESM entry point from a parsed package.json object.
22220
- */ function extractEsmEntry(pkgJson) {
22221
- if (typeof pkgJson === "object" && pkgJson !== null) {
22222
- const pkg = pkgJson;
22223
- const esmPath = resolveExportsImportEntry(pkg.exports);
22224
- if (esmPath) return esmPath;
22225
- if (typeof pkg.main === "string" && pkg.main.length > 0) return pkg.main;
22226
- }
22227
- return "index.js";
22228
- }
22229
- /**
22230
- * Navigates the exports map to find the ESM entry. Supports string-shaped
22231
- * exports, string-valued `exports["."]`, `exports["."].import` (string),
22232
- * `exports["."].import.default`, and the sugar form where condition keys
22233
- * (`import`/`require`) appear directly on the exports object.
22234
- */ function resolveExportsImportEntry(exports) {
22235
- if (typeof exports === "string") return exports;
22236
- if (typeof exports !== "object" || exports === null) return null;
22237
- const exportsMap = exports;
22238
- const dotEntry = exportsMap["."];
22239
- if (typeof dotEntry === "string") return dotEntry;
22240
- const conditionSource = typeof dotEntry === "object" && dotEntry !== null && !Array.isArray(dotEntry) ? dotEntry : exportsMap;
22241
- const importEntry = conditionSource.import;
22242
- if (typeof importEntry === "string") return importEntry;
22243
- if (typeof importEntry === "object" && importEntry !== null) {
22244
- const importMap = importEntry;
22245
- if (typeof importMap.default === "string") return importMap.default;
22246
- }
22247
- return null;
22248
- }
22249
-
22250
22308
  ;// CONCATENATED MODULE: ./src/lib/log-format.ts
22251
22309
 
22252
22310
  function formatDuration(ms) {
@@ -33117,19 +33175,18 @@ const AnalysisResponseSchema = schemas_object({
33117
33175
  *
33118
33176
  * @returns Enhanced analysis results, or null if the SDK is unavailable
33119
33177
  */ async function enhanceWithCopilot(scanResult, repoRoot, writeStderr, io, model = DEFAULT_MODEL) {
33120
- let importSucceeded = false;
33178
+ let sdkLoaded = false;
33121
33179
  try {
33122
- const sdkPath = io.resolveSdkPath(repoRoot, "@github/copilot-sdk");
33123
- const { CopilotClient, defineTool, approveAll } = sdkPath ? await import(/* webpackIgnore: true */ sdkPath) : await __webpack_require__.e(/* import() */ 300).then(__webpack_require__.bind(__webpack_require__, 791));
33124
- importSucceeded = true;
33125
- const client = new CopilotClient();
33126
- const tools = createCustomTools(repoRoot, io, defineTool);
33180
+ const sdk = await io.loadSdk(repoRoot);
33181
+ sdkLoaded = true;
33182
+ const client = sdk.createClient();
33183
+ const tools = createCustomTools(repoRoot, io, sdk.defineTool);
33127
33184
  try {
33128
33185
  await client.start();
33129
33186
  const session = await client.createSession({
33130
33187
  model,
33131
33188
  tools,
33132
- onPermissionRequest: approveAll,
33189
+ onPermissionRequest: sdk.approveAll,
33133
33190
  systemMessage: {
33134
33191
  content: buildSystemMessage()
33135
33192
  },
@@ -33165,7 +33222,7 @@ const AnalysisResponseSchema = schemas_object({
33165
33222
  }
33166
33223
  } catch (err) {
33167
33224
  if (process.env.AGENT_SHELL_COPILOT_DEBUG) {
33168
- if (importSucceeded) {
33225
+ if (sdkLoaded) {
33169
33226
  writeStderr(`agent-shell: Copilot analysis failed — ${sanitizeForStderr(err)}\n`);
33170
33227
  } else {
33171
33228
  writeStderr("agent-shell: Copilot SDK not available — using static analysis only\n");
@@ -34319,7 +34376,7 @@ async function main() {
34319
34376
  writeStderr: (data)=>process.stderr.write(data),
34320
34377
  scanProject: (dir)=>scanProject(dir),
34321
34378
  copilotIo: {
34322
- resolveSdkPath: resolveSdkPath,
34379
+ loadSdk: createCopilotSdkLoader(),
34323
34380
  statWithinRoot: statWithinRoot,
34324
34381
  readBytesWithinRoot: readBytesWithinRoot
34325
34382
  },
@@ -34608,4 +34665,4 @@ if (installedChunkData !== 0) { // 0 means "already installed".'
34608
34665
  // module factories are used so entry inlining is disabled
34609
34666
  // startup
34610
34667
  // Load entry module and return exports
34611
- var __webpack_exports__ = __webpack_require__(71);
34668
+ var __webpack_exports__ = __webpack_require__(444);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lousy-agents/agent-shell",
3
- "version": "5.22.26",
3
+ "version": "5.22.28",
4
4
  "description": "A flight recorder for npm script execution",
5
5
  "type": "module",
6
6
  "repository": {