@aiden-ade/sandbox-agent 0.1.17 → 0.1.18

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.cjs +111 -26
  2. package/package.json +3 -3
package/dist/index.cjs CHANGED
@@ -3404,7 +3404,7 @@ var require_websocket = __commonJS({
3404
3404
  var http2 = require("http");
3405
3405
  var net = require("net");
3406
3406
  var tls = require("tls");
3407
- var { randomBytes: randomBytes2, createHash: createHash4 } = require("crypto");
3407
+ var { randomBytes: randomBytes2, createHash: createHash3 } = require("crypto");
3408
3408
  var { Duplex, Readable } = require("stream");
3409
3409
  var { URL } = require("url");
3410
3410
  var PerMessageDeflate = require_permessage_deflate();
@@ -4061,7 +4061,7 @@ var require_websocket = __commonJS({
4061
4061
  abortHandshake(websocket, socket, "Invalid Upgrade header");
4062
4062
  return;
4063
4063
  }
4064
- const digest = createHash4("sha1").update(key + GUID).digest("base64");
4064
+ const digest = createHash3("sha1").update(key + GUID).digest("base64");
4065
4065
  if (res.headers["sec-websocket-accept"] !== digest) {
4066
4066
  abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
4067
4067
  return;
@@ -4428,7 +4428,7 @@ var require_websocket_server = __commonJS({
4428
4428
  var EventEmitter = require("events");
4429
4429
  var http2 = require("http");
4430
4430
  var { Duplex } = require("stream");
4431
- var { createHash: createHash4 } = require("crypto");
4431
+ var { createHash: createHash3 } = require("crypto");
4432
4432
  var extension = require_extension();
4433
4433
  var PerMessageDeflate = require_permessage_deflate();
4434
4434
  var subprotocol = require_subprotocol();
@@ -4725,7 +4725,7 @@ var require_websocket_server = __commonJS({
4725
4725
  );
4726
4726
  }
4727
4727
  if (this._state > RUNNING) return abortHandshake(socket, 503);
4728
- const digest = createHash4("sha1").update(key + GUID).digest("base64");
4728
+ const digest = createHash3("sha1").update(key + GUID).digest("base64");
4729
4729
  const headers = [
4730
4730
  "HTTP/1.1 101 Switching Protocols",
4731
4731
  "Upgrade: websocket",
@@ -5238,9 +5238,7 @@ var import_crypto = require("crypto");
5238
5238
  var import_fs = require("fs");
5239
5239
  var import_os = require("os");
5240
5240
  var import_path = require("path");
5241
- var import_crypto2 = require("crypto");
5242
5241
  var import_fs2 = require("fs");
5243
- var import_fs3 = require("fs");
5244
5242
  var import_os2 = require("os");
5245
5243
  var import_path2 = require("path");
5246
5244
  var import_readline = require("readline");
@@ -5273,9 +5271,12 @@ var DEFAULT_TEAM_STATUSES = STATUS_OPTIONS.map((o) => ({
5273
5271
  }));
5274
5272
 
5275
5273
  // ../agent-core/dist/index.js
5276
- var import_fs4 = require("fs");
5274
+ var import_fs3 = require("fs");
5277
5275
  var import_os3 = require("os");
5278
5276
  var import_path3 = require("path");
5277
+ var import_fs4 = require("fs");
5278
+ var import_os4 = require("os");
5279
+ var import_path4 = require("path");
5279
5280
  function isLikelyProviderAuthError(stderr) {
5280
5281
  const lower = stderr.toLowerCase();
5281
5282
  return lower.includes("api key") || lower.includes("api_key") || lower.includes("invalid api key") || lower.includes("api key invalid") || lower.includes("unauthorized") || lower.includes("authentication failed") || lower.includes("authentication error") || lower.includes("provider settings") || lower.includes("invalid token") || lower.includes("token expired");
@@ -5583,19 +5584,15 @@ async function replayCodexMcpToolEventsFromSessionLog(context, state) {
5583
5584
  }
5584
5585
  }
5585
5586
  }
5586
- function kimiSessionId(cwd) {
5587
- let resolved = cwd;
5588
- try {
5589
- resolved = (0, import_fs2.realpathSync)(cwd);
5590
- } catch {
5587
+ var KIMI_RESUME_SESSION_RE = /To resume this session:\s*kimi(?:-cli)?\s+(?:-[rS]|--session|--resume)\s+([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;
5588
+ function parseKimiStderrLine(line, state) {
5589
+ const match = line.match(KIMI_RESUME_SESSION_RE);
5590
+ if (match?.[1]) {
5591
+ state.runtimeSessionId = match[1];
5591
5592
  }
5592
- return (0, import_crypto2.createHash)("md5").update(resolved).digest("hex");
5593
5593
  }
5594
5594
  function parseKimiStructuredLine(line, context, state) {
5595
5595
  const presenter = context.presenter;
5596
- if (!state.runtimeSessionId) {
5597
- state.runtimeSessionId = kimiSessionId(context.cwd);
5598
- }
5599
5596
  let parsed;
5600
5597
  try {
5601
5598
  parsed = JSON.parse(line);
@@ -5680,11 +5677,11 @@ function createImageTempDirectory(cwd) {
5680
5677
  ].filter((value2) => Boolean(value2));
5681
5678
  for (const candidate of candidates) {
5682
5679
  try {
5683
- return (0, import_fs3.mkdtempSync)(candidate);
5680
+ return (0, import_fs2.mkdtempSync)(candidate);
5684
5681
  } catch {
5685
5682
  }
5686
5683
  }
5687
- return (0, import_fs3.mkdtempSync)((0, import_path2.join)((0, import_os2.tmpdir)(), "aiden-images-"));
5684
+ return (0, import_fs2.mkdtempSync)((0, import_path2.join)((0, import_os2.tmpdir)(), "aiden-images-"));
5688
5685
  }
5689
5686
  function writeImagesToTempFiles(images, cwd) {
5690
5687
  if (!images?.length) return { paths: [], files: [], cleanup: () => {
@@ -5695,7 +5692,7 @@ function writeImagesToTempFiles(images, cwd) {
5695
5692
  for (const img of images) {
5696
5693
  const ext = imageFileExtension(img.mimeType);
5697
5694
  const filePath = (0, import_path2.join)(directory, `aiden-img-${img.id}.${ext}`);
5698
- (0, import_fs3.writeFileSync)(filePath, Buffer.from(img.data, "base64"));
5695
+ (0, import_fs2.writeFileSync)(filePath, Buffer.from(img.data, "base64"));
5699
5696
  paths.push(filePath);
5700
5697
  files.push({
5701
5698
  filename: img.filename,
@@ -5710,7 +5707,7 @@ function writeImagesToTempFiles(images, cwd) {
5710
5707
  files,
5711
5708
  cleanup: () => {
5712
5709
  try {
5713
- (0, import_fs3.rmSync)(directory, { recursive: true, force: true });
5710
+ (0, import_fs2.rmSync)(directory, { recursive: true, force: true });
5714
5711
  } catch {
5715
5712
  }
5716
5713
  }
@@ -5799,6 +5796,9 @@ function createGenericCliBackend(options) {
5799
5796
  });
5800
5797
  stderrRl.on("line", (line) => {
5801
5798
  presenter.recordRawTranscript?.("stderr", line);
5799
+ if (options.parseStderrLine) {
5800
+ options.parseStderrLine(line, context, state);
5801
+ }
5802
5802
  if (line.trim().length > 0) {
5803
5803
  stderrLines.push(line);
5804
5804
  void presenter.onLog(`[${options.kind}] ${line}`);
@@ -6301,7 +6301,8 @@ function createKimiCliBackend(command = "kimi-cli", defaultArgs = []) {
6301
6301
  return [...args, ...defaultArgs, "--prompt", prompt];
6302
6302
  },
6303
6303
  augmentPrompt: (ctx) => buildPromptWithImagePathReferences(ctx, imageFiles),
6304
- parseStructuredLine: parseKimiStructuredLine
6304
+ parseStructuredLine: parseKimiStructuredLine,
6305
+ parseStderrLine: (line, _ctx, state) => parseKimiStderrLine(line, state)
6305
6306
  }).run(context);
6306
6307
  } finally {
6307
6308
  cleanup();
@@ -7237,6 +7238,85 @@ function createCopilotCliBackend(command = "copilot", defaultArgs = []) {
7237
7238
  }
7238
7239
  };
7239
7240
  }
7241
+ var SKILL_COMMAND_RE = /^\s*\/([A-Za-z0-9][A-Za-z0-9._:-]*)(?:\s+([\s\S]*))?$/;
7242
+ function parseSkillInvocation(text) {
7243
+ const match = text.match(SKILL_COMMAND_RE);
7244
+ if (!match) return null;
7245
+ return {
7246
+ command: match[1],
7247
+ userRequest: match[2]?.trim() ?? ""
7248
+ };
7249
+ }
7250
+ function candidateRoots(cwd) {
7251
+ const roots = [];
7252
+ if (cwd) {
7253
+ roots.push((0, import_path4.join)(cwd, ".agents", "skills"));
7254
+ roots.push((0, import_path4.join)(cwd, ".claude", "skills"));
7255
+ roots.push((0, import_path4.join)(cwd, ".codex", "skills"));
7256
+ if ((0, import_fs4.existsSync)(cwd)) {
7257
+ let entries = [];
7258
+ try {
7259
+ entries = (0, import_fs4.readdirSync)(cwd, { withFileTypes: true });
7260
+ } catch {
7261
+ }
7262
+ for (const entry of entries) {
7263
+ if (!entry.isDirectory()) continue;
7264
+ if (entry.name.startsWith(".")) continue;
7265
+ const child = (0, import_path4.join)(cwd, entry.name);
7266
+ roots.push((0, import_path4.join)(child, ".agents", "skills"));
7267
+ roots.push((0, import_path4.join)(child, ".claude", "skills"));
7268
+ roots.push((0, import_path4.join)(child, ".codex", "skills"));
7269
+ }
7270
+ }
7271
+ }
7272
+ const home = (0, import_os4.homedir)();
7273
+ roots.push((0, import_path4.join)(home, ".agents", "skills"));
7274
+ roots.push((0, import_path4.join)(home, ".claude", "skills"));
7275
+ roots.push((0, import_path4.join)(home, ".codex", "skills"));
7276
+ return Array.from(new Set(roots));
7277
+ }
7278
+ function resolveSkillInvocation(text, cwd) {
7279
+ const parsed = parseSkillInvocation(text);
7280
+ if (!parsed) return null;
7281
+ for (const root of candidateRoots(cwd)) {
7282
+ const skillPath = (0, import_path4.join)(root, parsed.command, "SKILL.md");
7283
+ if (!(0, import_fs4.existsSync)(skillPath)) continue;
7284
+ let content;
7285
+ try {
7286
+ content = (0, import_fs4.readFileSync)(skillPath, "utf-8");
7287
+ } catch {
7288
+ continue;
7289
+ }
7290
+ return {
7291
+ command: parsed.command,
7292
+ skillPath,
7293
+ content,
7294
+ userRequest: parsed.userRequest
7295
+ };
7296
+ }
7297
+ return null;
7298
+ }
7299
+ function expandSkillInvocationPrompt(text, cwd) {
7300
+ const invocation = resolveSkillInvocation(text, cwd);
7301
+ if (!invocation) return { text, invocation: null };
7302
+ const request = invocation.userRequest || "(No additional request text was provided.)";
7303
+ return {
7304
+ invocation,
7305
+ text: [
7306
+ `The user invoked the \`/${invocation.command}\` skill.`,
7307
+ `Skill source: ${invocation.skillPath}`,
7308
+ "",
7309
+ "Follow the skill instructions below for this turn.",
7310
+ "",
7311
+ `<skill_instructions command="${invocation.command}">`,
7312
+ invocation.content.trim(),
7313
+ "</skill_instructions>",
7314
+ "",
7315
+ "User request after the slash command:",
7316
+ request
7317
+ ].join("\n")
7318
+ };
7319
+ }
7240
7320
  var DEFAULT_MODEL = "claude-sonnet-4-6";
7241
7321
  var DROID_DEFAULT_MODEL = "claude-opus-4-7";
7242
7322
  function defaultSelectedModelForBackend(backendKind) {
@@ -7258,7 +7338,7 @@ function defaultSelectedModelForBackend(backendKind) {
7258
7338
  function canonicalizePath(inputPath) {
7259
7339
  try {
7260
7340
  const resolved = (0, import_path3.resolve)(inputPath);
7261
- return (0, import_fs4.existsSync)(resolved) ? (0, import_fs4.realpathSync)(resolved) : resolved;
7341
+ return (0, import_fs3.existsSync)(resolved) ? (0, import_fs3.realpathSync)(resolved) : resolved;
7262
7342
  } catch {
7263
7343
  return null;
7264
7344
  }
@@ -7416,11 +7496,16 @@ Prefer relative paths and keep your work scoped to this project.`
7416
7496
  async runCliBackend(config, safeProjectPath) {
7417
7497
  const backendKind = this.resolveBackendKind(config);
7418
7498
  const defaultCwd = (0, import_path3.join)((0, import_os3.homedir)(), "Documents", "aiden");
7419
- if (!(0, import_fs4.existsSync)(defaultCwd)) {
7420
- (0, import_fs4.mkdirSync)(defaultCwd, { recursive: true });
7499
+ if (!(0, import_fs3.existsSync)(defaultCwd)) {
7500
+ (0, import_fs3.mkdirSync)(defaultCwd, { recursive: true });
7421
7501
  }
7422
7502
  let runtimeConfig = this.buildRuntimeConfig(config, safeProjectPath);
7423
7503
  const cwd = runtimeConfig.worktreePath || safeProjectPath || runtimeConfig.cwd || defaultCwd;
7504
+ const skillExpansion = expandSkillInvocationPrompt(runtimeConfig.task, cwd);
7505
+ if (skillExpansion.invocation) {
7506
+ runtimeConfig = { ...runtimeConfig, task: skillExpansion.text };
7507
+ void this.presenter.onLog(`Using /${skillExpansion.invocation.command} skill`);
7508
+ }
7424
7509
  const env = await this.buildCliEnvironment();
7425
7510
  const promptText = this.buildPromptText(runtimeConfig);
7426
7511
  const runtimeCommand = runtimeConfig.runtimeCommand || this.runtime.runtimeCommand;
@@ -7521,7 +7606,7 @@ Prefer relative paths and keep your work scoped to this project.`
7521
7606
  const canonicalized = canonicalizePath(initialConfig.teamPath);
7522
7607
  if (canonicalized) safeProjectPath = canonicalized;
7523
7608
  }
7524
- if (safeProjectPath && !(0, import_fs4.existsSync)(safeProjectPath)) {
7609
+ if (safeProjectPath && !(0, import_fs3.existsSync)(safeProjectPath)) {
7525
7610
  const message = `Local path no longer exists: "${safeProjectPath}". Please update the team's local path in team settings before running the agent.`;
7526
7611
  this.presenter.onError(message, true);
7527
7612
  const result = {
@@ -11940,7 +12025,7 @@ var WSClient = class {
11940
12025
  };
11941
12026
 
11942
12027
  // src/version.ts
11943
- var AGENT_VERSION = "0.1.17";
12028
+ var AGENT_VERSION = "0.1.18";
11944
12029
 
11945
12030
  // src/sandbox.ts
11946
12031
  async function runSandbox(config) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiden-ade/sandbox-agent",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "aiden-agent": "./dist/index.cjs"
@@ -19,8 +19,8 @@
19
19
  "tsup": "^8.5.1",
20
20
  "tsx": "^4.19.0",
21
21
  "typescript": "~5.9.3",
22
- "@aiden/agent-core": "0.1.0",
23
- "@aiden/shared": "0.1.0"
22
+ "@aiden/shared": "0.1.0",
23
+ "@aiden/agent-core": "0.1.0"
24
24
  },
25
25
  "scripts": {
26
26
  "build": "tsup",