@agentrix/cli 0.0.11 → 0.0.12

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.
@@ -6,7 +6,7 @@ var chalk = require('chalk');
6
6
  var shared = require('@agentrix/shared');
7
7
  var node_crypto = require('node:crypto');
8
8
  var axios = require('axios');
9
- var _package = require('./logger-BZKdzrRM.cjs');
9
+ var _package = require('./logger---ZD5a2u.cjs');
10
10
  var fs$1 = require('node:fs');
11
11
  var node_readline = require('node:readline');
12
12
  var fs = require('fs');
@@ -23,13 +23,13 @@ var fastify = require('fastify');
23
23
  var zod = require('zod');
24
24
  var fastifyTypeProviderZod = require('fastify-type-provider-zod');
25
25
  var require$$7 = require('url');
26
+ var promises = require('node:stream/promises');
26
27
  var claudeAgentSdk = require('@anthropic-ai/claude-agent-sdk');
27
28
  var simpleGit = require('simple-git');
28
- var promises = require('node:fs/promises');
29
+ var promises$1 = require('node:fs/promises');
29
30
  var require$$1 = require('crypto');
30
31
  var codexSdk = require('@openai/codex-sdk');
31
32
  var v3 = require('zod/v3');
32
- var promises$1 = require('node:stream/promises');
33
33
 
34
34
  function _interopNamespaceDefault(e) {
35
35
  var n = Object.create(null);
@@ -12838,6 +12838,108 @@ ${errorMessage}`,
12838
12838
  }
12839
12839
  }
12840
12840
 
12841
+ const MIME_TYPE_MAP = {
12842
+ // Images
12843
+ ".jpg": "image/jpeg",
12844
+ ".jpeg": "image/jpeg",
12845
+ ".png": "image/png",
12846
+ ".gif": "image/gif",
12847
+ ".webp": "image/webp",
12848
+ ".bmp": "image/bmp",
12849
+ ".svg": "image/svg+xml",
12850
+ ".ico": "image/x-icon",
12851
+ // Documents
12852
+ ".pdf": "application/pdf",
12853
+ ".doc": "application/msword",
12854
+ ".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
12855
+ ".xls": "application/vnd.ms-excel",
12856
+ ".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
12857
+ ".ppt": "application/vnd.ms-powerpoint",
12858
+ ".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
12859
+ // Text
12860
+ ".txt": "text/plain",
12861
+ ".md": "text/markdown",
12862
+ ".csv": "text/csv",
12863
+ ".json": "application/json",
12864
+ ".xml": "application/xml",
12865
+ ".html": "text/html",
12866
+ ".css": "text/css",
12867
+ ".js": "application/javascript",
12868
+ ".ts": "application/typescript",
12869
+ // Archives
12870
+ ".zip": "application/zip",
12871
+ ".tar": "application/x-tar",
12872
+ ".gz": "application/gzip",
12873
+ ".rar": "application/vnd.rar",
12874
+ // Other
12875
+ ".mp3": "audio/mpeg",
12876
+ ".mp4": "video/mp4",
12877
+ ".wav": "audio/wav",
12878
+ ".avi": "video/x-msvideo"
12879
+ };
12880
+ function detectMimeType(extension) {
12881
+ const normalized = extension.toLowerCase();
12882
+ return MIME_TYPE_MAP[normalized] || "application/octet-stream";
12883
+ }
12884
+ function extractExtension(url) {
12885
+ try {
12886
+ const urlObj = new URL(url);
12887
+ const pathExt = path$1.extname(urlObj.pathname);
12888
+ if (pathExt) {
12889
+ return pathExt;
12890
+ }
12891
+ const filenameParam = urlObj.searchParams.get("filename") || urlObj.searchParams.get("name") || urlObj.searchParams.get("file");
12892
+ if (filenameParam) {
12893
+ const paramExt = path$1.extname(filenameParam);
12894
+ if (paramExt) {
12895
+ return paramExt;
12896
+ }
12897
+ }
12898
+ return "";
12899
+ } catch {
12900
+ return "";
12901
+ }
12902
+ }
12903
+ async function downloadFile(url, targetDir, preserveFilename = false) {
12904
+ try {
12905
+ const extension = extractExtension(url) || "";
12906
+ let filename;
12907
+ if (preserveFilename) {
12908
+ try {
12909
+ const urlPath = new URL(url).pathname;
12910
+ const originalFilename = path$1.basename(urlPath);
12911
+ filename = originalFilename && path$1.extname(originalFilename) ? originalFilename : `${node_crypto.randomUUID()}${extension || ".dat"}`;
12912
+ } catch {
12913
+ filename = `${node_crypto.randomUUID()}${extension || ".dat"}`;
12914
+ }
12915
+ } else {
12916
+ filename = `${node_crypto.randomUUID()}${extension || ".dat"}`;
12917
+ }
12918
+ const filePath = path$1.join(targetDir, filename);
12919
+ const response = await fetch(url);
12920
+ if (!response.ok) {
12921
+ throw new Error(`Failed to download file: ${response.status} ${response.statusText}`);
12922
+ }
12923
+ if (!response.body) {
12924
+ throw new Error("Response body is null");
12925
+ }
12926
+ const contentType = response.headers.get("content-type");
12927
+ const mimeType = contentType?.split(";")[0].trim() || detectMimeType(extension);
12928
+ const nodeStream = response.body;
12929
+ const fileStream = fs$1.createWriteStream(filePath);
12930
+ await promises.pipeline(nodeStream, fileStream);
12931
+ return {
12932
+ filePath,
12933
+ mimeType,
12934
+ filename
12935
+ };
12936
+ } catch (error) {
12937
+ throw new Error(
12938
+ `Failed to download file from ${url}: ${error instanceof Error ? error.message : String(error)}`
12939
+ );
12940
+ }
12941
+ }
12942
+
12841
12943
  function trimIdent(text) {
12842
12944
  const lines = text.split("\n");
12843
12945
  while (lines.length > 0 && lines[0].trim() === "") {
@@ -13146,7 +13248,7 @@ async function generateAndSavePatch(workingDirectory, fromCommit, toCommit, data
13146
13248
  return void 0;
13147
13249
  }
13148
13250
  const patchPath = path$1.join(dataDir, "patch.diff");
13149
- await promises.writeFile(patchPath, patch);
13251
+ await promises$1.writeFile(patchPath, patch);
13150
13252
  return patchPath;
13151
13253
  }
13152
13254
  async function handleGitState(workingDirectory, userId, taskId, commitMessage) {
@@ -13811,7 +13913,7 @@ Please must use the mcp__agentrix__create_pr tool to create the pull request wit
13811
13913
  this.log("info", "AGENT", `Claude agent finished for task ${this.taskId}`);
13812
13914
  }
13813
13915
  async enqueueMessage(message) {
13814
- const processedMessage = await this.processImageUrls(message);
13916
+ const processedMessage = await this.processAttachments(message);
13815
13917
  if (this.messageResolverRef.current) {
13816
13918
  const resolver = this.messageResolverRef.current;
13817
13919
  this.messageResolverRef.current = null;
@@ -13820,10 +13922,14 @@ Please must use the mcp__agentrix__create_pr tool to create the pull request wit
13820
13922
  this.messageQueue.push(processedMessage);
13821
13923
  }
13822
13924
  }
13823
- async processImageUrls(message) {
13925
+ async processAttachments(message) {
13824
13926
  if (!Array.isArray(message.message.content)) {
13825
13927
  return message;
13826
13928
  }
13929
+ const attachmentsDir = _package.machine.resolveAttachmentsDir(
13930
+ this.options.input.userId,
13931
+ this.taskId
13932
+ );
13827
13933
  const processedContent = await Promise.all(
13828
13934
  message.message.content.map(async (block) => {
13829
13935
  if (block.type === "image" && block.source?.type === "url" && block.source?.url) {
@@ -13859,6 +13965,24 @@ Please must use the mcp__agentrix__create_pr tool to create the pull request wit
13859
13965
  return block;
13860
13966
  }
13861
13967
  }
13968
+ if (block.type === "document" && block.source?.type === "url" && block.source?.url) {
13969
+ try {
13970
+ const url = block.source.url;
13971
+ this.log("info", "DOCUMENT", `Downloading document from: ${url}`);
13972
+ const { filePath, mimeType, filename } = await downloadFile(url, attachmentsDir, true);
13973
+ this.log("info", "DOCUMENT", `Document downloaded to: ${filePath}`);
13974
+ const title = block.title || filename;
13975
+ return {
13976
+ type: "text",
13977
+ text: `Document: ${filePath}
13978
+ Title: ${title}
13979
+ Type: ${mimeType}`
13980
+ };
13981
+ } catch (error) {
13982
+ this.log("error", "DOCUMENT", `Error processing document: ${error}`);
13983
+ return block;
13984
+ }
13985
+ }
13862
13986
  return block;
13863
13987
  })
13864
13988
  );
@@ -14276,7 +14400,7 @@ URL: ${result.pullRequestUrl}`
14276
14400
  }
14277
14401
  }
14278
14402
  async createLogger(options) {
14279
- const { createLogger } = await Promise.resolve().then(function () { return require('./logger-BZKdzrRM.cjs'); }).then(function (n) { return n.logger$1; });
14403
+ const { createLogger } = await Promise.resolve().then(function () { return require('./logger---ZD5a2u.cjs'); }).then(function (n) { return n.logger$1; });
14280
14404
  return createLogger(options);
14281
14405
  }
14282
14406
  log(level, category, message, ...args) {
@@ -15900,28 +16024,6 @@ Example response format:
15900
16024
  CRITICAL: Respond with ONLY the JSON object, no additional text before or after. Now analyze the changes and provide your response:`;
15901
16025
  }
15902
16026
 
15903
- async function downloadImage(url, targetDir) {
15904
- try {
15905
- const urlPath = new URL(url).pathname;
15906
- const extension = path$1.extname(urlPath) || ".jpg";
15907
- const filename = `${node_crypto.randomUUID()}${extension}`;
15908
- const filePath = path$1.join(targetDir, filename);
15909
- const response = await fetch(url);
15910
- if (!response.ok) {
15911
- throw new Error(`Failed to download image: ${response.status} ${response.statusText}`);
15912
- }
15913
- if (!response.body) {
15914
- throw new Error("Response body is null");
15915
- }
15916
- const nodeStream = response.body;
15917
- const fileStream = fs$1.createWriteStream(filePath);
15918
- await promises$1.pipeline(nodeStream, fileStream);
15919
- return filePath;
15920
- } catch (error) {
15921
- throw new Error(`Failed to download image from ${url}: ${error instanceof Error ? error.message : String(error)}`);
15922
- }
15923
- }
15924
-
15925
16027
  class CodexWorker {
15926
16028
  constructor(credentials, options) {
15927
16029
  this.credentials = credentials;
@@ -16400,8 +16502,8 @@ URL: ${result.pullRequestUrl}`);
16400
16502
  }
16401
16503
  /**
16402
16504
  * Convert SDKUserMessage to Codex Input format
16403
- * Handles both text-only messages and messages with images
16404
- * Downloads images from URLs to local attachments directory
16505
+ * Handles both text-only messages and messages with images and documents
16506
+ * Downloads images and documents from URLs to local attachments directory
16405
16507
  */
16406
16508
  async convertSDKMessageToCodexInput(message) {
16407
16509
  const content = message.message.content;
@@ -16410,6 +16512,10 @@ URL: ${result.pullRequestUrl}`);
16410
16512
  }
16411
16513
  if (Array.isArray(content)) {
16412
16514
  const userInputs = [];
16515
+ const attachmentsDir = _package.machine.resolveAttachmentsDir(
16516
+ this.options.input.userId,
16517
+ this.taskId
16518
+ );
16413
16519
  for (const block of content) {
16414
16520
  if (block.type === "text" && block.text) {
16415
16521
  userInputs.push({
@@ -16419,19 +16525,30 @@ URL: ${result.pullRequestUrl}`);
16419
16525
  } else if (block.type === "image" && block.source && block.source.url) {
16420
16526
  const url = block.source.url;
16421
16527
  try {
16422
- const attachmentsDir = _package.machine.resolveAttachmentsDir(
16423
- this.options.input.userId,
16424
- this.taskId
16425
- );
16426
- const localPath = await downloadImage(url, attachmentsDir);
16427
- this.log("info", "IMAGE", `Downloaded image from ${url} to ${localPath}`);
16528
+ const { filePath } = await downloadFile(url, attachmentsDir, false);
16529
+ this.log("info", "IMAGE", `Downloaded image from ${url} to ${filePath}`);
16428
16530
  userInputs.push({
16429
16531
  type: "local_image",
16430
- path: localPath
16532
+ path: filePath
16431
16533
  });
16432
16534
  } catch (error) {
16433
16535
  this.log("error", "IMAGE", `Failed to download image from ${url}:`, error);
16434
16536
  }
16537
+ } else if (block.type === "document" && block.source && block.source.url) {
16538
+ const url = block.source.url;
16539
+ try {
16540
+ const { filePath, mimeType, filename } = await downloadFile(url, attachmentsDir, true);
16541
+ this.log("info", "DOCUMENT", `Downloaded document from ${url} to ${filePath}`);
16542
+ const title = block.title || filename;
16543
+ userInputs.push({
16544
+ type: "text",
16545
+ text: `Document: ${filePath}
16546
+ Title: ${title}
16547
+ Type: ${mimeType}`
16548
+ });
16549
+ } catch (error) {
16550
+ this.log("error", "DOCUMENT", `Failed to download document from ${url}:`, error);
16551
+ }
16435
16552
  }
16436
16553
  }
16437
16554
  if (userInputs.length === 1 && userInputs[0].type === "text") {
@@ -16955,7 +17072,7 @@ cli.command("upgrade", "Upgrade CLI to the latest version", {}, async (argv) =>
16955
17072
  }
16956
17073
  }
16957
17074
  try {
16958
- const { version } = await Promise.resolve().then(function () { return require('./logger-BZKdzrRM.cjs'); }).then(function (n) { return n._package; });
17075
+ const { version } = await Promise.resolve().then(function () { return require('./logger---ZD5a2u.cjs'); }).then(function (n) { return n._package; });
16959
17076
  console.log(chalk.green(`
16960
17077
  \u2713 Now running version: ${version}`));
16961
17078
  } catch {
@@ -17137,7 +17254,7 @@ cli.command(
17137
17254
  },
17138
17255
  async (argv) => {
17139
17256
  try {
17140
- const { testCommand } = await Promise.resolve().then(function () { return require('./index-DuBvuZ3A.cjs'); });
17257
+ const { testCommand } = await Promise.resolve().then(function () { return require('./index-BdFjpsoN.cjs'); });
17141
17258
  await testCommand(argv);
17142
17259
  } catch (error) {
17143
17260
  console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Test mode failed");
@@ -4,10 +4,10 @@ var React = require('react');
4
4
  var ink = require('ink');
5
5
  var TextInput = require('ink-text-input');
6
6
  var SelectInput = require('ink-select-input');
7
- var _package = require('./logger-BZKdzrRM.cjs');
7
+ var _package = require('./logger---ZD5a2u.cjs');
8
8
  var shared = require('@agentrix/shared');
9
9
  var require$$0$3 = require('events');
10
- var index = require('./index-Dw2iFM1t.cjs');
10
+ var index = require('./index-A8QO7gdw.cjs');
11
11
  var require$$2$1 = require('http');
12
12
  var fs = require('fs');
13
13
  var require$$1$2 = require('zlib');
@@ -44,11 +44,11 @@ require('cross-spawn');
44
44
  require('fastify');
45
45
  require('zod');
46
46
  require('fastify-type-provider-zod');
47
+ require('node:stream/promises');
47
48
  require('@anthropic-ai/claude-agent-sdk');
48
49
  require('simple-git');
49
50
  require('@openai/codex-sdk');
50
51
  require('zod/v3');
51
- require('node:stream/promises');
52
52
 
53
53
  const Header = ({ agentId, model, cwd, status }) => {
54
54
  const getStatusColor = () => {
@@ -2,10 +2,10 @@ import{createRequire as _pkgrollCR}from"node:module";const require=_pkgrollCR(im
2
2
  import { Box, Text, useInput, useApp, render } from 'ink';
3
3
  import TextInput from 'ink-text-input';
4
4
  import SelectInput from 'ink-select-input';
5
- import { m as machine } from './logger-7E71dnBD.mjs';
5
+ import { m as machine } from './logger-D-ioMWe6.mjs';
6
6
  import { loadAgentConfig, createEventId } from '@agentrix/shared';
7
7
  import require$$0$3, { EventEmitter } from 'events';
8
- import { r as requireMimeTypes, g as getAugmentedNamespace, a as getDefaultExportFromCjs, s as spawnAgentrixCLI } from './index-CvGINSkT.mjs';
8
+ import { r as requireMimeTypes, g as getAugmentedNamespace, a as getDefaultExportFromCjs, s as spawnAgentrixCLI } from './index-Dzjo3uhE.mjs';
9
9
  import require$$2$1, { createServer } from 'http';
10
10
  import fs from 'fs';
11
11
  import require$$1$2 from 'zlib';
@@ -42,11 +42,11 @@ import 'cross-spawn';
42
42
  import 'fastify';
43
43
  import 'zod';
44
44
  import 'fastify-type-provider-zod';
45
+ import 'node:stream/promises';
45
46
  import '@anthropic-ai/claude-agent-sdk';
46
47
  import 'simple-git';
47
48
  import '@openai/codex-sdk';
48
49
  import 'zod/v3';
49
- import 'node:stream/promises';
50
50
 
51
51
  const Header = ({ agentId, model, cwd, status }) => {
52
52
  const getStatusColor = () => {
@@ -2,11 +2,11 @@ import yargs from 'yargs';
2
2
  import { hideBin } from 'yargs/helpers';
3
3
  import chalk from 'chalk';
4
4
  import { encodeBase64, createKeyPairWithUit8Array, encryptMachineEncryptionKey, generateAESKey, decodeBase64, decryptWithEphemeralKey, createEventId, encryptFileContent, machineAuth, encryptSdkMessage, decryptSdkMessage, loadAgentConfig, getAgentContext, workerAuth } from '@agentrix/shared';
5
- import { randomBytes, randomUUID as randomUUID$1 } from 'node:crypto';
5
+ import { randomBytes, randomUUID } from 'node:crypto';
6
6
  import axios from 'axios';
7
- import { m as machine, l as logger, p as projectPath, a as packageJson, c as createLogger, g as getLogPath, b as logger$1 } from './logger-7E71dnBD.mjs';
7
+ import { m as machine, l as logger, p as projectPath, a as packageJson, c as createLogger, g as getLogPath, b as logger$1 } from './logger-D-ioMWe6.mjs';
8
8
  import * as fs from 'node:fs';
9
- import { existsSync, rmSync, readdirSync, mkdirSync, createWriteStream } from 'node:fs';
9
+ import { existsSync, rmSync, createWriteStream, readdirSync, mkdirSync } from 'node:fs';
10
10
  import { createInterface } from 'node:readline';
11
11
  import fs$1, { readFileSync, existsSync as existsSync$1 } from 'fs';
12
12
  import path$1, { join } from 'path';
@@ -15,7 +15,7 @@ import open from 'open';
15
15
  import { io } from 'socket.io-client';
16
16
  import { EventEmitter } from 'node:events';
17
17
  import * as path from 'node:path';
18
- import { join as join$1, dirname, extname } from 'node:path';
18
+ import { join as join$1, basename, extname, dirname } from 'node:path';
19
19
  import { spawn, execSync } from 'child_process';
20
20
  import psList from 'ps-list';
21
21
  import spawn$1 from 'cross-spawn';
@@ -23,13 +23,13 @@ import fastify from 'fastify';
23
23
  import { z } from 'zod';
24
24
  import { validatorCompiler, serializerCompiler } from 'fastify-type-provider-zod';
25
25
  import { pathToFileURL } from 'url';
26
+ import { pipeline } from 'node:stream/promises';
26
27
  import { AbortError, query, createSdkMcpServer, tool } from '@anthropic-ai/claude-agent-sdk';
27
28
  import simpleGit, { CheckRepoActions } from 'simple-git';
28
29
  import { writeFile } from 'node:fs/promises';
29
- import { randomUUID } from 'crypto';
30
+ import { randomUUID as randomUUID$1 } from 'crypto';
30
31
  import { Codex } from '@openai/codex-sdk';
31
32
  import { ZodFirstPartyTypeKind } from 'zod/v3';
32
- import { pipeline } from 'node:stream/promises';
33
33
 
34
34
  async function delay(ms) {
35
35
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -12818,6 +12818,108 @@ ${errorMessage}`,
12818
12818
  }
12819
12819
  }
12820
12820
 
12821
+ const MIME_TYPE_MAP = {
12822
+ // Images
12823
+ ".jpg": "image/jpeg",
12824
+ ".jpeg": "image/jpeg",
12825
+ ".png": "image/png",
12826
+ ".gif": "image/gif",
12827
+ ".webp": "image/webp",
12828
+ ".bmp": "image/bmp",
12829
+ ".svg": "image/svg+xml",
12830
+ ".ico": "image/x-icon",
12831
+ // Documents
12832
+ ".pdf": "application/pdf",
12833
+ ".doc": "application/msword",
12834
+ ".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
12835
+ ".xls": "application/vnd.ms-excel",
12836
+ ".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
12837
+ ".ppt": "application/vnd.ms-powerpoint",
12838
+ ".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
12839
+ // Text
12840
+ ".txt": "text/plain",
12841
+ ".md": "text/markdown",
12842
+ ".csv": "text/csv",
12843
+ ".json": "application/json",
12844
+ ".xml": "application/xml",
12845
+ ".html": "text/html",
12846
+ ".css": "text/css",
12847
+ ".js": "application/javascript",
12848
+ ".ts": "application/typescript",
12849
+ // Archives
12850
+ ".zip": "application/zip",
12851
+ ".tar": "application/x-tar",
12852
+ ".gz": "application/gzip",
12853
+ ".rar": "application/vnd.rar",
12854
+ // Other
12855
+ ".mp3": "audio/mpeg",
12856
+ ".mp4": "video/mp4",
12857
+ ".wav": "audio/wav",
12858
+ ".avi": "video/x-msvideo"
12859
+ };
12860
+ function detectMimeType(extension) {
12861
+ const normalized = extension.toLowerCase();
12862
+ return MIME_TYPE_MAP[normalized] || "application/octet-stream";
12863
+ }
12864
+ function extractExtension(url) {
12865
+ try {
12866
+ const urlObj = new URL(url);
12867
+ const pathExt = extname(urlObj.pathname);
12868
+ if (pathExt) {
12869
+ return pathExt;
12870
+ }
12871
+ const filenameParam = urlObj.searchParams.get("filename") || urlObj.searchParams.get("name") || urlObj.searchParams.get("file");
12872
+ if (filenameParam) {
12873
+ const paramExt = extname(filenameParam);
12874
+ if (paramExt) {
12875
+ return paramExt;
12876
+ }
12877
+ }
12878
+ return "";
12879
+ } catch {
12880
+ return "";
12881
+ }
12882
+ }
12883
+ async function downloadFile(url, targetDir, preserveFilename = false) {
12884
+ try {
12885
+ const extension = extractExtension(url) || "";
12886
+ let filename;
12887
+ if (preserveFilename) {
12888
+ try {
12889
+ const urlPath = new URL(url).pathname;
12890
+ const originalFilename = basename(urlPath);
12891
+ filename = originalFilename && extname(originalFilename) ? originalFilename : `${randomUUID()}${extension || ".dat"}`;
12892
+ } catch {
12893
+ filename = `${randomUUID()}${extension || ".dat"}`;
12894
+ }
12895
+ } else {
12896
+ filename = `${randomUUID()}${extension || ".dat"}`;
12897
+ }
12898
+ const filePath = join$1(targetDir, filename);
12899
+ const response = await fetch(url);
12900
+ if (!response.ok) {
12901
+ throw new Error(`Failed to download file: ${response.status} ${response.statusText}`);
12902
+ }
12903
+ if (!response.body) {
12904
+ throw new Error("Response body is null");
12905
+ }
12906
+ const contentType = response.headers.get("content-type");
12907
+ const mimeType = contentType?.split(";")[0].trim() || detectMimeType(extension);
12908
+ const nodeStream = response.body;
12909
+ const fileStream = createWriteStream(filePath);
12910
+ await pipeline(nodeStream, fileStream);
12911
+ return {
12912
+ filePath,
12913
+ mimeType,
12914
+ filename
12915
+ };
12916
+ } catch (error) {
12917
+ throw new Error(
12918
+ `Failed to download file from ${url}: ${error instanceof Error ? error.message : String(error)}`
12919
+ );
12920
+ }
12921
+ }
12922
+
12821
12923
  function trimIdent(text) {
12822
12924
  const lines = text.split("\n");
12823
12925
  while (lines.length > 0 && lines[0].trim() === "") {
@@ -13183,7 +13285,7 @@ async function markCommitAsSent(userId, taskId, commitHash) {
13183
13285
 
13184
13286
  function executeCommandStreaming(command, cwd, callbacks, timeoutMs = 6e4) {
13185
13287
  return new Promise((resolve) => {
13186
- const toolUseId = `shell_${randomUUID().replace(/-/g, "")}`;
13288
+ const toolUseId = `shell_${randomUUID$1().replace(/-/g, "")}`;
13187
13289
  callbacks.onOutput({
13188
13290
  type: "assistant",
13189
13291
  message: {
@@ -13791,7 +13893,7 @@ Please must use the mcp__agentrix__create_pr tool to create the pull request wit
13791
13893
  this.log("info", "AGENT", `Claude agent finished for task ${this.taskId}`);
13792
13894
  }
13793
13895
  async enqueueMessage(message) {
13794
- const processedMessage = await this.processImageUrls(message);
13896
+ const processedMessage = await this.processAttachments(message);
13795
13897
  if (this.messageResolverRef.current) {
13796
13898
  const resolver = this.messageResolverRef.current;
13797
13899
  this.messageResolverRef.current = null;
@@ -13800,10 +13902,14 @@ Please must use the mcp__agentrix__create_pr tool to create the pull request wit
13800
13902
  this.messageQueue.push(processedMessage);
13801
13903
  }
13802
13904
  }
13803
- async processImageUrls(message) {
13905
+ async processAttachments(message) {
13804
13906
  if (!Array.isArray(message.message.content)) {
13805
13907
  return message;
13806
13908
  }
13909
+ const attachmentsDir = machine.resolveAttachmentsDir(
13910
+ this.options.input.userId,
13911
+ this.taskId
13912
+ );
13807
13913
  const processedContent = await Promise.all(
13808
13914
  message.message.content.map(async (block) => {
13809
13915
  if (block.type === "image" && block.source?.type === "url" && block.source?.url) {
@@ -13839,6 +13945,24 @@ Please must use the mcp__agentrix__create_pr tool to create the pull request wit
13839
13945
  return block;
13840
13946
  }
13841
13947
  }
13948
+ if (block.type === "document" && block.source?.type === "url" && block.source?.url) {
13949
+ try {
13950
+ const url = block.source.url;
13951
+ this.log("info", "DOCUMENT", `Downloading document from: ${url}`);
13952
+ const { filePath, mimeType, filename } = await downloadFile(url, attachmentsDir, true);
13953
+ this.log("info", "DOCUMENT", `Document downloaded to: ${filePath}`);
13954
+ const title = block.title || filename;
13955
+ return {
13956
+ type: "text",
13957
+ text: `Document: ${filePath}
13958
+ Title: ${title}
13959
+ Type: ${mimeType}`
13960
+ };
13961
+ } catch (error) {
13962
+ this.log("error", "DOCUMENT", `Error processing document: ${error}`);
13963
+ return block;
13964
+ }
13965
+ }
13842
13966
  return block;
13843
13967
  })
13844
13968
  );
@@ -14256,7 +14380,7 @@ URL: ${result.pullRequestUrl}`
14256
14380
  }
14257
14381
  }
14258
14382
  async createLogger(options) {
14259
- const { createLogger } = await import('./logger-7E71dnBD.mjs').then(function (n) { return n.b; });
14383
+ const { createLogger } = await import('./logger-D-ioMWe6.mjs').then(function (n) { return n.b; });
14260
14384
  return createLogger(options);
14261
14385
  }
14262
14386
  log(level, category, message, ...args) {
@@ -14277,7 +14401,7 @@ async function runClaude(credentials, options) {
14277
14401
  var require$$0 = /*@__PURE__*/getAugmentedNamespace(logger$1);
14278
14402
 
14279
14403
  function generateAndMapToolId(itemId, idMapper) {
14280
- const uniqueId = randomUUID$1();
14404
+ const uniqueId = randomUUID();
14281
14405
  idMapper.set(itemId, uniqueId);
14282
14406
  return uniqueId;
14283
14407
  }
@@ -14360,7 +14484,7 @@ function convertAgentMessage(item) {
14360
14484
  },
14361
14485
  parent_tool_use_id: null,
14362
14486
  session_id: "",
14363
- uuid: randomUUID$1().toString()
14487
+ uuid: randomUUID().toString()
14364
14488
  };
14365
14489
  }
14366
14490
  function convertCommandExecutionStarted(item, idMapper) {
@@ -15880,28 +16004,6 @@ Example response format:
15880
16004
  CRITICAL: Respond with ONLY the JSON object, no additional text before or after. Now analyze the changes and provide your response:`;
15881
16005
  }
15882
16006
 
15883
- async function downloadImage(url, targetDir) {
15884
- try {
15885
- const urlPath = new URL(url).pathname;
15886
- const extension = extname(urlPath) || ".jpg";
15887
- const filename = `${randomUUID$1()}${extension}`;
15888
- const filePath = join$1(targetDir, filename);
15889
- const response = await fetch(url);
15890
- if (!response.ok) {
15891
- throw new Error(`Failed to download image: ${response.status} ${response.statusText}`);
15892
- }
15893
- if (!response.body) {
15894
- throw new Error("Response body is null");
15895
- }
15896
- const nodeStream = response.body;
15897
- const fileStream = createWriteStream(filePath);
15898
- await pipeline(nodeStream, fileStream);
15899
- return filePath;
15900
- } catch (error) {
15901
- throw new Error(`Failed to download image from ${url}: ${error instanceof Error ? error.message : String(error)}`);
15902
- }
15903
- }
15904
-
15905
16007
  class CodexWorker {
15906
16008
  constructor(credentials, options) {
15907
16009
  this.credentials = credentials;
@@ -16309,7 +16411,7 @@ Please try again or create the PR manually.`
16309
16411
  const message = {
16310
16412
  type: "assistant",
16311
16413
  message: {
16312
- id: randomUUID$1().toString(),
16414
+ id: randomUUID().toString(),
16313
16415
  type: "message",
16314
16416
  container: null,
16315
16417
  role: "assistant",
@@ -16326,7 +16428,7 @@ Please try again or create the PR manually.`
16326
16428
  },
16327
16429
  parent_tool_use_id: null,
16328
16430
  session_id: "",
16329
- uuid: randomUUID$1().toString()
16431
+ uuid: randomUUID().toString()
16330
16432
  };
16331
16433
  this.context.workClient.sendTaskMessage(message);
16332
16434
  }
@@ -16380,8 +16482,8 @@ URL: ${result.pullRequestUrl}`);
16380
16482
  }
16381
16483
  /**
16382
16484
  * Convert SDKUserMessage to Codex Input format
16383
- * Handles both text-only messages and messages with images
16384
- * Downloads images from URLs to local attachments directory
16485
+ * Handles both text-only messages and messages with images and documents
16486
+ * Downloads images and documents from URLs to local attachments directory
16385
16487
  */
16386
16488
  async convertSDKMessageToCodexInput(message) {
16387
16489
  const content = message.message.content;
@@ -16390,6 +16492,10 @@ URL: ${result.pullRequestUrl}`);
16390
16492
  }
16391
16493
  if (Array.isArray(content)) {
16392
16494
  const userInputs = [];
16495
+ const attachmentsDir = machine.resolveAttachmentsDir(
16496
+ this.options.input.userId,
16497
+ this.taskId
16498
+ );
16393
16499
  for (const block of content) {
16394
16500
  if (block.type === "text" && block.text) {
16395
16501
  userInputs.push({
@@ -16399,19 +16505,30 @@ URL: ${result.pullRequestUrl}`);
16399
16505
  } else if (block.type === "image" && block.source && block.source.url) {
16400
16506
  const url = block.source.url;
16401
16507
  try {
16402
- const attachmentsDir = machine.resolveAttachmentsDir(
16403
- this.options.input.userId,
16404
- this.taskId
16405
- );
16406
- const localPath = await downloadImage(url, attachmentsDir);
16407
- this.log("info", "IMAGE", `Downloaded image from ${url} to ${localPath}`);
16508
+ const { filePath } = await downloadFile(url, attachmentsDir, false);
16509
+ this.log("info", "IMAGE", `Downloaded image from ${url} to ${filePath}`);
16408
16510
  userInputs.push({
16409
16511
  type: "local_image",
16410
- path: localPath
16512
+ path: filePath
16411
16513
  });
16412
16514
  } catch (error) {
16413
16515
  this.log("error", "IMAGE", `Failed to download image from ${url}:`, error);
16414
16516
  }
16517
+ } else if (block.type === "document" && block.source && block.source.url) {
16518
+ const url = block.source.url;
16519
+ try {
16520
+ const { filePath, mimeType, filename } = await downloadFile(url, attachmentsDir, true);
16521
+ this.log("info", "DOCUMENT", `Downloaded document from ${url} to ${filePath}`);
16522
+ const title = block.title || filename;
16523
+ userInputs.push({
16524
+ type: "text",
16525
+ text: `Document: ${filePath}
16526
+ Title: ${title}
16527
+ Type: ${mimeType}`
16528
+ });
16529
+ } catch (error) {
16530
+ this.log("error", "DOCUMENT", `Failed to download document from ${url}:`, error);
16531
+ }
16415
16532
  }
16416
16533
  }
16417
16534
  if (userInputs.length === 1 && userInputs[0].type === "text") {
@@ -16935,7 +17052,7 @@ cli.command("upgrade", "Upgrade CLI to the latest version", {}, async (argv) =>
16935
17052
  }
16936
17053
  }
16937
17054
  try {
16938
- const { version } = await import('./logger-7E71dnBD.mjs').then(function (n) { return n._; });
17055
+ const { version } = await import('./logger-D-ioMWe6.mjs').then(function (n) { return n._; });
16939
17056
  console.log(chalk.green(`
16940
17057
  \u2713 Now running version: ${version}`));
16941
17058
  } catch {
@@ -17117,7 +17234,7 @@ cli.command(
17117
17234
  },
17118
17235
  async (argv) => {
17119
17236
  try {
17120
- const { testCommand } = await import('./index-zM9f-RKY.mjs');
17237
+ const { testCommand } = await import('./index-D1ipaIV_.mjs');
17121
17238
  await testCommand(argv);
17122
17239
  } catch (error) {
17123
17240
  console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Test mode failed");
package/dist/index.cjs CHANGED
@@ -3,8 +3,8 @@
3
3
  require('yargs');
4
4
  require('yargs/helpers');
5
5
  require('chalk');
6
- require('./index-Dw2iFM1t.cjs');
7
- require('./logger-BZKdzrRM.cjs');
6
+ require('./index-A8QO7gdw.cjs');
7
+ require('./logger---ZD5a2u.cjs');
8
8
  require('@agentrix/shared');
9
9
  require('node:crypto');
10
10
  require('axios');
@@ -24,12 +24,12 @@ require('fastify');
24
24
  require('zod');
25
25
  require('fastify-type-provider-zod');
26
26
  require('url');
27
+ require('node:stream/promises');
27
28
  require('@anthropic-ai/claude-agent-sdk');
28
29
  require('simple-git');
29
30
  require('node:fs/promises');
30
31
  require('crypto');
31
32
  require('@openai/codex-sdk');
32
33
  require('zod/v3');
33
- require('node:stream/promises');
34
34
  require('winston');
35
35
 
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import 'yargs';
2
2
  import 'yargs/helpers';
3
3
  import 'chalk';
4
- import './index-CvGINSkT.mjs';
5
- import './logger-7E71dnBD.mjs';
4
+ import './index-Dzjo3uhE.mjs';
5
+ import './logger-D-ioMWe6.mjs';
6
6
  import '@agentrix/shared';
7
7
  import 'node:crypto';
8
8
  import 'axios';
@@ -22,11 +22,11 @@ import 'fastify';
22
22
  import 'zod';
23
23
  import 'fastify-type-provider-zod';
24
24
  import 'url';
25
+ import 'node:stream/promises';
25
26
  import '@anthropic-ai/claude-agent-sdk';
26
27
  import 'simple-git';
27
28
  import 'node:fs/promises';
28
29
  import 'crypto';
29
30
  import '@openai/codex-sdk';
30
31
  import 'zod/v3';
31
- import 'node:stream/promises';
32
32
  import 'winston';
package/dist/lib.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var _package = require('./logger-BZKdzrRM.cjs');
3
+ var _package = require('./logger---ZD5a2u.cjs');
4
4
  require('winston');
5
5
  require('chalk');
6
6
  require('node:os');
package/dist/lib.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { M as Machine, l as logger, m as machine } from './logger-7E71dnBD.mjs';
1
+ export { M as Machine, l as logger, m as machine } from './logger-D-ioMWe6.mjs';
2
2
  import 'winston';
3
3
  import 'chalk';
4
4
  import 'node:os';
@@ -13,7 +13,7 @@ var require$$7 = require('url');
13
13
 
14
14
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
15
15
  var name = "@agentrix/cli";
16
- var version = "0.0.11";
16
+ var version = "0.0.12";
17
17
  var description = "Mobile and Web client for Claude Code and Codex";
18
18
  var author = "agentrix.xmz.ai";
19
19
  var type = "module";
@@ -189,7 +189,7 @@ var _package = /*#__PURE__*/Object.freeze({
189
189
  version: version
190
190
  });
191
191
 
192
- const __dirname$1 = path.dirname(require$$7.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('logger-BZKdzrRM.cjs', document.baseURI).href))));
192
+ const __dirname$1 = path.dirname(require$$7.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('logger---ZD5a2u.cjs', document.baseURI).href))));
193
193
  function projectPath() {
194
194
  const path$1 = path.resolve(__dirname$1, "..");
195
195
  return path$1;
@@ -10,7 +10,7 @@ import { dirname, resolve } from 'path';
10
10
  import { fileURLToPath } from 'url';
11
11
 
12
12
  var name = "@agentrix/cli";
13
- var version = "0.0.11";
13
+ var version = "0.0.12";
14
14
  var description = "Mobile and Web client for Claude Code and Codex";
15
15
  var author = "agentrix.xmz.ai";
16
16
  var type = "module";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentrix/cli",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "Mobile and Web client for Claude Code and Codex",
5
5
  "author": "agentrix.xmz.ai",
6
6
  "type": "module",