@ljoukov/llm 3.0.12 → 3.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -7996,13 +7996,52 @@ var IMAGE_MIME_BY_EXTENSION = {
7996
7996
  ".webp": "image/webp",
7997
7997
  ".gif": "image/gif"
7998
7998
  };
7999
+ function parseOptionalString(value) {
8000
+ if (value === null || value === void 0) {
8001
+ return void 0;
8002
+ }
8003
+ if (typeof value !== "string") {
8004
+ return void 0;
8005
+ }
8006
+ const trimmed = value.trim();
8007
+ if (trimmed.length === 0) {
8008
+ return void 0;
8009
+ }
8010
+ return trimmed;
8011
+ }
7999
8012
  var codexReadFileInputSchema = import_zod6.z.object({
8000
- file_path: import_zod6.z.string().min(1).describe(
8001
- "Path to the file (relative to cwd, or absolute. In sandbox mode, / maps to the sandbox root)."
8013
+ file_path: import_zod6.z.preprocess(
8014
+ (value) => parseOptionalString(value),
8015
+ import_zod6.z.string().min(1).optional().describe(
8016
+ "Path to the file (relative to cwd, or absolute. In sandbox mode, / maps to the sandbox root)."
8017
+ )
8018
+ ),
8019
+ path: import_zod6.z.preprocess(
8020
+ (value) => parseOptionalString(value),
8021
+ import_zod6.z.string().min(1).optional().describe(
8022
+ "Alias for file_path. If both file_path and path are provided they must be identical."
8023
+ )
8002
8024
  ),
8003
8025
  offset: import_zod6.z.number().int().min(1).nullish().describe("The line number to start reading from. Must be 1 or greater."),
8004
8026
  limit: import_zod6.z.number().int().min(1).nullish().describe("The maximum number of lines to return.")
8005
- }).strict();
8027
+ }).strict().superRefine((value, context) => {
8028
+ const filePath = value.file_path?.trim() ?? "";
8029
+ const aliasPath = value.path?.trim() ?? "";
8030
+ if (filePath.length === 0 && aliasPath.length === 0) {
8031
+ context.addIssue({
8032
+ code: import_zod6.z.ZodIssueCode.custom,
8033
+ message: "read_file requires file_path (or path alias).",
8034
+ path: ["file_path"]
8035
+ });
8036
+ }
8037
+ if (filePath.length > 0 && aliasPath.length > 0 && filePath !== aliasPath) {
8038
+ context.addIssue({
8039
+ code: import_zod6.z.ZodIssueCode.custom,
8040
+ message: "file_path and path must match when both are provided.",
8041
+ path: ["path"]
8042
+ });
8043
+ }
8044
+ });
8006
8045
  var codexListDirInputSchema = import_zod6.z.object({
8007
8046
  dir_path: import_zod6.z.string().min(1).describe(
8008
8047
  "Path to the directory to list (relative to cwd, or absolute. In sandbox mode, / maps to the sandbox root)."
@@ -8235,9 +8274,24 @@ function createGlobTool(options = {}) {
8235
8274
  execute: async (input) => globFilesGemini(input, options)
8236
8275
  });
8237
8276
  }
8277
+ function resolveCodexReadFilePath(input) {
8278
+ const filePath = parseOptionalString(input.file_path);
8279
+ if (filePath) {
8280
+ return filePath;
8281
+ }
8282
+ const aliasPath = parseOptionalString(input.path);
8283
+ if (aliasPath) {
8284
+ return aliasPath;
8285
+ }
8286
+ throw new Error("read_file requires file_path");
8287
+ }
8238
8288
  async function readFileCodex(input, options) {
8239
8289
  const runtime = resolveRuntime(options);
8240
- const filePath = resolvePathWithPolicy(input.file_path, runtime.cwd, runtime.allowOutsideCwd);
8290
+ const filePath = resolvePathWithPolicy(
8291
+ resolveCodexReadFilePath(input),
8292
+ runtime.cwd,
8293
+ runtime.allowOutsideCwd
8294
+ );
8241
8295
  await runAccessHook2(runtime, {
8242
8296
  cwd: runtime.cwd,
8243
8297
  tool: "read_file",